50 void init(
const float4x4 &transform_matrix,
const bool has_source_crop)
55 init_destination_region(transform_matrix, has_source_crop);
59 void init_destination_region(
const float4x4 &transform_matrix,
const bool has_source_crop)
61 if (!has_source_crop) {
76 for (
int i = 0; i < 4; i++) {
77 int2 src_co = src_coords[i];
104 return image->byte_buffer.data + (size_t(y) * image->x +
x) * image->channels;
108 return image->float_buffer.data + (size_t(y) * image->x +
x) * image->channels;
124template<eIMBInterpolationFilterMode Filter,
typename T,
int NumChannels,
bool WrapUV>
127 if constexpr (WrapUV) {
138 if constexpr (Filter ==
IMB_FILTER_BILINEAR && std::is_same_v<T, float> && NumChannels == 4) {
141 else if constexpr (Filter ==
IMB_FILTER_NEAREST && std::is_same_v<T, uchar> && NumChannels == 4)
145 else if constexpr (Filter ==
IMB_FILTER_BILINEAR && std::is_same_v<T, uchar> && NumChannels == 4)
150 if constexpr (WrapUV) {
224 if constexpr (SrcChannels == 4) {
227 else if constexpr (SrcChannels == 3) {
230 else if constexpr (SrcChannels == 2) {
233 else if constexpr (SrcChannels == 1) {
266 const float inv_count = 1.0f / (sub_count_x * sub_count_y);
270 for (
int yi : y_range) {
277 for (
int sub_y = 0; sub_y < sub_count_y; sub_y++) {
278 for (
int sub_x = 0; sub_x < sub_count_x; sub_x++) {
279 float2 delta = (sub_x + 0.5f) * sub_step_x + (sub_y + 0.5f) * sub_step_y;
280 float2 sub_uv = uv + delta;
286 WrapUV>(ctx.
src, sub_uv.x, sub_uv.y, sub_sample);
303 for (
int yi : y_range) {
319template<eIMBInterpolationFilterMode Filter,
typename T,
int SrcChannels>
338template<eIMBInterpolationFilterMode Filter>
348 else if (channels == 3) {
351 else if (channels == 2) {
354 else if (channels == 1) {
400 for (
int line_idx = 0; line_idx < 4; line_idx++) {
405 float length =
math::max(abs_delta.x, abs_delta.y);
409 bool is_steep = length == abs_delta.y;
414 constexpr float NO_ROTATION = 1.0e-6f;
415 constexpr float NO_AA_CONTRIB = 1.0e-2f;
417 if ((abs_delta.x < NO_ROTATION) && (
fabsf(ptA.x - roundf(ptA.x)) < NO_AA_CONTRIB)) {
422 if ((abs_delta.y < NO_ROTATION) && (
fabsf(ptA.y - roundf(ptA.y)) < NO_AA_CONTRIB)) {
432 for (
int i = 0; i <
length; i++) {
435 if (ipos.x >= 0 && ipos.x < ctx.
dst->
x && ipos.y >= 0 && ipos.y < ctx.
dst->
y) {
437 size_t idx = (size_t(ipos.y) * ctx.
dst->
x + ipos.x) * 4;
448 for (
int i = 0; i <
length; i++) {
451 if (ipos.x >= 0 && ipos.x < ctx.
dst->
x && ipos.y >= 0 && ipos.y < ctx.
dst->
y) {
453 size_t idx = (size_t(ipos.y) * ctx.
dst->
x + ipos.x) * 4;
470 const float transform_matrix[4][4],
471 const rctf *src_crop)
474 "No source crop rect given, but crop source is requested. Or source crop rect "
475 "was given, but crop source was not requested.");
489 if (filter == IMB_FILTER_NEAREST) {
490 transform_scanlines_filter<IMB_FILTER_NEAREST>(ctx, y_range);
#define BLI_assert_unreachable()
#define BLI_STATIC_ASSERT(a, msg)
#define BLI_assert_msg(a, msg)
MINLINE void straight_uchar_to_premul_float(float result[4], const unsigned char color[4])
MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float color[4])
MINLINE void add_v4_v4(float r[4], const float a[4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w)
MINLINE void copy_v4_v4_uchar(unsigned char r[4], const unsigned char a[4])
MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rcti_init_minmax(struct rcti *rect)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
eIMBTransformMode
Transform modes to use for IMB_transform function.
@ IMB_TRANSFORM_MODE_WRAP_REPEAT
Wrap repeat the source buffer. Only supported in with nearest filtering.
@ IMB_TRANSFORM_MODE_REGULAR
Do not crop or repeat.
@ IMB_TRANSFORM_MODE_CROP_SRC
Crop the source buffer.
eIMBInterpolationFilterMode
@ IMB_FILTER_CUBIC_BSPLINE
@ IMB_FILTER_CUBIC_MITCHELL
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
btMatrix3x3 inverse() const
Return the inverse of the matrix.
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
constexpr int64_t first() const
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
float4 interpolate_bilinear_fl(const ImBuf *in, float u, float v)
uchar4 interpolate_nearest_border_byte(const ImBuf *in, float u, float v)
uchar4 interpolate_bilinear_byte(const ImBuf *in, float u, float v)
uchar4 interpolate_cubic_mitchell_byte(const ImBuf *in, float u, float v)
uchar4 interpolate_cubic_bspline_byte(const ImBuf *in, float u, float v)
T clamp(const T &a, const T &min, const T &max)
void interpolate_nearest_border_fl(const float *buffer, float *output, int width, int height, int components, float u, float v)
T length(const VecBase< T, Size > &a)
float4 interpolate_bilinear_wrap_fl(const float *buffer, int width, int height, float u, float v)
float4 interpolate_cubic_bspline_fl(const float *buffer, int width, int height, float u, float v)
CartesianBasis invert(const CartesianBasis &basis)
float4 interpolate_bilinear_fl(const float *buffer, int width, int height, float u, float v)
float4 interpolate_cubic_mitchell_fl(const float *buffer, int width, int height, float u, float v)
T max(const T &a, const T &b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
VecBase< T, 2 > xy() const
IndexRange dst_region_y_range
void init(const float4x4 &transform_matrix, const bool has_source_crop)
IndexRange dst_region_x_range