32 *r_dst_byte =
nullptr;
35 if (*r_dst_byte ==
nullptr) {
39 *r_dst_float =
nullptr;
43 if (*r_dst_float ==
nullptr) {
82 memcpy(
ptr, &pix,
sizeof(*
ptr));
86 memcpy(
ptr, &pix,
sizeof(*
ptr));
95 static void op(
const T *src,
T *dst,
int ibufx,
int ibufy,
int newx,
int ,
bool threaded)
98 const float add = (ibufx - 0.01f) / newx;
99 const float inv_add = 1.0f /
add;
101 const int grain_size = threaded ? 32 : ibufy;
103 for (
const int y : range) {
104 const T *src_ptr = src + (
int64_t(
y) * ibufx);
109 for (
int x = 0;
x < newx;
x++) {
134 static void op(
const T *src,
T *dst,
int ibufx,
int ibufy,
int ,
int newy,
bool threaded)
137 const float add = (ibufy - 0.01f) / newy;
138 const float inv_add = 1.0f /
add;
140 const int grain_size = threaded ? 32 : ibufx;
142 for (
const int x : range) {
143 const T *src_ptr = src +
x;
144 T *dst_ptr = dst +
x;
148 for (
int y = 0;
y < newy;
y++) {
173 static void op(
const T *src,
T *dst,
int ibufx,
int ibufy,
int newx,
int ,
bool threaded)
176 const float add = (ibufx - 0.001f) / newx;
179 for (
int y = ibufy;
y > 0;
y--) {
180 for (
int x = newx;
x > 0;
x--) {
188 const int grain_size = threaded ? 32 : ibufy;
190 for (
const int y : range) {
193 const T *src_ptr = src + (
int64_t(
y) * ibufx);
202 for (
int x = 0;
x < newx;
x++) {
208 if (counter + 1 < ibufx) {
226 static void op(
const T *src,
T *dst,
int ibufx,
int ibufy,
int ,
int newy,
bool threaded)
229 const float add = (ibufy - 0.001f) / newy;
232 for (
int y = newy;
y > 0;
y--) {
233 memcpy(dst, src,
sizeof(
T) * ibufx);
238 const int grain_size = threaded ? 32 : ibufx;
240 for (
const int x : range) {
243 const T *src_ptr = src +
x;
244 T *dst_ptr = dst +
x;
250 src_ptr += ibufx * 2;
254 for (
int y = 0;
y < newy;
y++) {
260 if (counter + 1 < ibufy) {
285 if (dst_byte !=
nullptr) {
287 T::op(src, dst_byte, ibuf->
x, ibuf->
y, newx, newy, threaded);
289 if (dst_float !=
nullptr) {
295 T::op(src, (
float2 *)dst_float, ibuf->
x, ibuf->
y, newx, newy, threaded);
299 T::op(src, (
float3 *)dst_float, ibuf->
x, ibuf->
y, newx, newy, threaded);
303 T::op(src, (
float4 *)dst_float, ibuf->
x, ibuf->
y, newx, newy, threaded);
309 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
316 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
323 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
330 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
337 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded);
342 uchar4 *dst_byte =
nullptr;
343 float *dst_float =
nullptr;
345 if (dst_byte ==
nullptr && dst_float ==
nullptr) {
350 func(ibuf, newx, newy, dst_byte, dst_float, threaded);
353 if (dst_byte !=
nullptr) {
357 if (dst_float !=
nullptr) {
367 if (newx != 0 && (newx < ibuf->
x)) {
370 if (newy != 0 && (newy < ibuf->
y)) {
373 if (newx != 0 && (newx > ibuf->
x)) {
376 if (newy != 0 && (newy > ibuf->
y)) {
386 constexpr int FRAC_BITS = 16;
387 int64_t stepx = ((
int64_t(ibufx) << FRAC_BITS) + newx / 2) / newx;
388 int64_t stepy = ((
int64_t(ibufy) << FRAC_BITS) + newy / 2) / newy;
390 dst += y_range.
first() * newx;
391 for (
const int y : y_range) {
393 const T *row = src + (posy >> FRAC_BITS) * ibufx;
395 for (
int x = 0;
x < newx;
x++, posx += stepx) {
396 *dst = row[posx >> FRAC_BITS];
404 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
408 const int grain_size = threaded ? 64 : newy;
411 if (dst_byte !=
nullptr) {
416 if (dst_float !=
nullptr) {
437 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
442 const int grain_size = threaded ? 32 : newy;
444 float factor_x =
float(ibuf->
x) / newx;
445 float factor_y =
float(ibuf->
y) / newy;
447 for (
const int y : y_range) {
448 float v = (
float(
y) + 0.5f) * factor_y - 0.5f;
449 for (
int x = 0;
x < newx;
x++) {
450 float u = (
float(
x) + 0.5f) * factor_x - 0.5f;
456 float *pixel = dst_float + ibuf->
channels * offset;
467 BLI_assert_msg(newx > 0 && newy > 0,
"Images must be at least 1 on both dimensions!");
468 if (ibuf ==
nullptr) {
471 if (newx == ibuf->
x && newy == ibuf->
y) {
492 BLI_assert_msg(newx > 0 && newy > 0,
"Images must be at least 1 on both dimensions!");
493 if (ibuf ==
nullptr) {
497 if (newx == ibuf->
x && newy == ibuf->
y) {
504 uchar4 *dst_byte =
nullptr;
505 float *dst_float =
nullptr;
507 if (dst_byte ==
nullptr && dst_float ==
nullptr) {
520 uchar4 *tmp_byte =
nullptr;
521 float *tmp_float =
nullptr;
523 if (tmp_byte ==
nullptr && tmp_float ==
nullptr) {
524 if (dst_byte !=
nullptr) {
527 if (dst_byte !=
nullptr) {
532 if (newx < ibuf->
x) {
542 if (tmp_byte !=
nullptr) {
546 if (tmp_float !=
nullptr) {
549 if (newy < ibuf->
y) {
556 if (tmp_byte !=
nullptr) {
559 if (tmp_float !=
nullptr) {
570 if (dst_byte !=
nullptr) {
574 if (dst_float !=
nullptr) {
#define BLI_assert_msg(a, msg)
Function declarations for filter.cc.
ImBuf * IMB_dupImBuf(const ImBuf *ibuf1)
void IMB_assign_float_buffer(ImBuf *ibuf, float *buffer_data, ImBufOwnership ownership)
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
void IMB_free_float_pixels(ImBuf *ibuf)
void IMB_free_byte_pixels(ImBuf *ibuf)
bool IMB_initImBuf(ImBuf *ibuf, unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
void IMB_assign_byte_buffer(ImBuf *ibuf, uint8_t *buffer_data, ImBufOwnership ownership)
@ IB_DO_NOT_TAKE_OWNERSHIP
@ IB_uninitialized_pixels
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v
constexpr int64_t first() const
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
static void add(blender::Map< std::string, std::string > &messages, Message &msg)
uchar4 interpolate_bilinear_byte(const ImBuf *in, float u, float v)
float4 interpolate_bilinear_fl(const float *buffer, int width, int height, float u, float v)
T max(const T &a, const T &b)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
blender::VecBase< uint8_t, 4 > uchar4
VecBase< float, 4 > float4
VecBase< float, 2 > float2
VecBase< float, 3 > float3
static void alloc_scale_dst_buffers(const ImBuf *ibuf, uint newx, uint newy, uchar4 **r_dst_byte, float **r_dst_float)
static void scale_nearest(const T *src, T *dst, int ibufx, int ibufy, int newx, int newy, blender::IndexRange y_range)
ImBuf * IMB_scale_into_new(const ImBuf *ibuf, uint newx, uint newy, IMBScaleFilter filter, bool threaded)
bool IMB_scale(ImBuf *ibuf, uint newx, uint newy, IMBScaleFilter filter, bool threaded)
void(*)( const ImBuf *ibuf, int newx, int newy, uchar4 *dst_byte, float *dst_float, bool threaded) ScaleFunction
static void scale_with_function(ImBuf *ibuf, int newx, int newy, ScaleFunction func, bool threaded)
static void imb_scale_box(ImBuf *ibuf, uint newx, uint newy, bool threaded)
static void scale_up_y_func(const ImBuf *ibuf, int newx, int newy, uchar4 *dst_byte, float *dst_float, bool threaded)
static void scale_down_y_func(const ImBuf *ibuf, int newx, int newy, uchar4 *dst_byte, float *dst_float, bool threaded)
static void store_pixel(float4 pix, uchar4 *ptr)
static void scale_bilinear_func(const ImBuf *ibuf, int newx, int newy, uchar4 *dst_byte, float *dst_float, bool threaded)
static void scale_nearest_func(const ImBuf *ibuf, int newx, int newy, uchar4 *dst_byte, float *dst_float, bool threaded)
static void scale_down_x_func(const ImBuf *ibuf, int newx, int newy, uchar4 *dst_byte, float *dst_float, bool threaded)
static void instantiate_pixel_op(T &, const ImBuf *ibuf, int newx, int newy, uchar4 *dst_byte, float *dst_float, bool threaded)
static void scale_up_x_func(const ImBuf *ibuf, int newx, int newy, uchar4 *dst_byte, float *dst_float, bool threaded)
static float4 load_pixel(const uchar4 *ptr)
const ColorSpace * colorspace
const ColorSpace * colorspace
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
static void op(const T *src, T *dst, int ibufx, int ibufy, int newx, int, bool threaded)
static void op(const T *src, T *dst, int ibufx, int ibufy, int, int newy, bool threaded)
static void op(const T *src, T *dst, int ibufx, int ibufy, int newx, int, bool threaded)
static void op(const T *src, T *dst, int ibufx, int ibufy, int, int newy, bool threaded)