31 uchar *p1, *_p1, *dest;
34 float af, rf, gf, bf, *p1f, *_p1f, *destf;
35 bool do_rect, do_float;
46 for (
y = ibuf2->
y;
y > 0;
y--) {
49 for (
x = ibuf2->
x;
x > 0;
x--) {
73 *(destf++) = 0.5f * af;
74 *(destf++) = 0.5f * bf;
75 *(destf++) = 0.5f * gf;
76 *(destf++) = 0.5f * rf;
80 _p1 += (ibuf1->
x << 2);
83 _p1f += (ibuf1->
x << 2);
92 if (ibuf1 ==
nullptr) {
104 if (ibuf2 ==
nullptr) {
115 uchar *p1, *p2, *_p1, *dest;
118 float af, rf, gf, bf, *p1f, *p2f, *_p1f, *destf;
132 for (
y = ibuf2->
y;
y > 0;
y--) {
135 p2 = _p1 + (ibuf1->
x << 2);
139 p2f = _p1f + (ibuf1->
x << 2);
141 for (
x = ibuf2->
x;
x > 0;
x--) {
165 *(destf++) = 0.5f * af;
166 *(destf++) = 0.5f * bf;
167 *(destf++) = 0.5f * gf;
168 *(destf++) = 0.5f * rf;
172 _p1 += (ibuf1->
x << 3);
175 _p1f += (ibuf1->
x << 3);
184 if (ibuf1 ==
nullptr) {
196 if (ibuf2 ==
nullptr) {
220 if (
color[3] <= 255) {
257 uchar *cp1, *cp2, *dest;
262 for (
y = ibuf2->
y;
y > 0;
y--) {
263 cp2 = cp1 + (ibuf1->
x << 2);
264 for (
x = ibuf2->
x;
x > 0;
x--) {
265 ushort p1i[8], p2i[8], desti[4];
272 desti[0] = (
uint(p1i[0]) + p2i[0] + p1i[4] + p2i[4]) >> 2;
273 desti[1] = (
uint(p1i[1]) + p2i[1] + p1i[5] + p2i[5]) >> 2;
274 desti[2] = (
uint(p1i[2]) + p2i[2] + p1i[6] + p2i[6]) >> 2;
275 desti[3] = (
uint(p1i[3]) + p2i[3] + p1i[7] + p2i[7]) >> 2;
291 float *p1f, *p2f, *destf;
295 for (
y = ibuf2->
y;
y > 0;
y--) {
296 p2f = p1f + (ibuf1->
x << 2);
297 for (
x = ibuf2->
x;
x > 0;
x--) {
298 destf[0] = 0.25f * (p1f[0] + p2f[0] + p1f[4] + p2f[4]);
299 destf[1] = 0.25f * (p1f[1] + p2f[1] + p1f[5] + p2f[5]);
300 destf[2] = 0.25f * (p1f[2] + p2f[2] + p1f[6] + p2f[6]);
301 destf[3] = 0.25f * (p1f[3] + p2f[3] + p1f[7] + p2f[7]);
318 if (ibuf1 ==
nullptr) {
333 if (ibuf2 ==
nullptr) {
345 *r_dst_byte =
nullptr;
347 *r_dst_byte =
static_cast<uchar4 *
>(
349 if (*r_dst_byte ==
nullptr) {
353 *r_dst_float =
nullptr;
355 *r_dst_float =
static_cast<float *
>(
357 if (*r_dst_float ==
nullptr) {
396 memcpy(
ptr, &pix,
sizeof(*
ptr));
400 memcpy(
ptr, &pix,
sizeof(*
ptr));
409 static void op(
const T *src,
T *dst,
int ibufx,
int ibufy,
int newx,
int ,
bool threaded)
412 const float add = (ibufx - 0.01f) / newx;
413 const float inv_add = 1.0f /
add;
415 const int grain_size = threaded ? 32 : ibufy;
417 for (
const int y : range) {
418 const T *src_ptr = src +
y * ibufx;
419 T *dst_ptr = dst +
y * newx;
423 for (
int x = 0;
x < newx;
x++) {
448 static void op(
const T *src,
T *dst,
int ibufx,
int ibufy,
int ,
int newy,
bool threaded)
451 const float add = (ibufy - 0.01f) / newy;
452 const float inv_add = 1.0f /
add;
454 const int grain_size = threaded ? 32 : ibufx;
456 for (
const int x : range) {
457 const T *src_ptr = src +
x;
458 T *dst_ptr = dst +
x;
462 for (
int y = 0;
y < newy;
y++) {
487 static void op(
const T *src,
T *dst,
int ibufx,
int ibufy,
int newx,
int ,
bool threaded)
490 const float add = (ibufx - 0.001f) / newx;
493 for (
int y = ibufy;
y > 0;
y--) {
494 for (
int x = newx;
x > 0;
x--) {
502 const int grain_size = threaded ? 32 : ibufy;
504 for (
const int y : range) {
507 const T *src_ptr = src +
y * ibufx;
508 T *dst_ptr = dst +
y * newx;
516 for (
int x = 0;
x < newx;
x++) {
522 if (counter + 1 < ibufx) {
540 static void op(
const T *src,
T *dst,
int ibufx,
int ibufy,
int ,
int newy,
bool threaded)
543 const float add = (ibufy - 0.001f) / newy;
546 for (
int y = newy;
y > 0;
y--) {
547 memcpy(dst, src,
sizeof(
T) * ibufx);
552 const int grain_size = threaded ? 32 : ibufx;
554 for (
const int x : range) {
557 const T *src_ptr = src +
x;
558 T *dst_ptr = dst +
x;
564 src_ptr += ibufx * 2;
568 for (
int y = 0;
y < newy;
y++) {
574 if (counter + 1 < ibufy) {
599 if (dst_byte !=
nullptr) {
601 T::op(src, dst_byte, ibuf->
x, ibuf->
y, newx, newy, threaded);
603 if (dst_float !=
nullptr) {
609 T::op(src, (
float2 *)dst_float, ibuf->
x, ibuf->
y, newx, newy, threaded);
613 T::op(src, (
float3 *)dst_float, ibuf->
x, ibuf->
y, newx, newy, threaded);
617 T::op(src, (
float4 *)dst_float, ibuf->
x, ibuf->
y, newx, newy, threaded);
623 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
630 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
637 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
644 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
651 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded);
656 uchar4 *dst_byte =
nullptr;
657 float *dst_float =
nullptr;
659 if (dst_byte ==
nullptr && dst_float ==
nullptr) {
664 func(ibuf, newx, newy, dst_byte, dst_float, threaded);
667 if (dst_byte !=
nullptr) {
671 if (dst_float !=
nullptr) {
681 if (newx != 0 && (newx < ibuf->
x)) {
684 if (newy != 0 && (newy < ibuf->
y)) {
687 if (newx != 0 && (newx > ibuf->
x)) {
690 if (newy != 0 && (newy > ibuf->
y)) {
700 constexpr int FRAC_BITS = 16;
701 int64_t stepx = ((
int64_t(ibufx) << FRAC_BITS) + newx / 2) / newx;
702 int64_t stepy = ((
int64_t(ibufy) << FRAC_BITS) + newy / 2) / newy;
704 dst += y_range.
first() * newx;
705 for (
const int y : y_range) {
707 const T *row = src + (posy >> FRAC_BITS) * ibufx;
709 for (
int x = 0;
x < newx;
x++, posx += stepx) {
710 *dst = row[posx >> FRAC_BITS];
718 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
722 const int grain_size = threaded ? 64 : newy;
725 if (dst_byte !=
nullptr) {
730 if (dst_float !=
nullptr) {
751 const ImBuf *ibuf,
int newx,
int newy,
uchar4 *dst_byte,
float *dst_float,
bool threaded)
756 const int grain_size = threaded ? 32 : newy;
758 float factor_x =
float(ibuf->
x) / newx;
759 float factor_y =
float(ibuf->
y) / newy;
761 for (
const int y : y_range) {
762 float v = (
float(
y) + 0.5f) * factor_y - 0.5f;
763 for (
int x = 0;
x < newx;
x++) {
764 float u = (
float(
x) + 0.5f) * factor_x - 0.5f;
770 float *pixel = dst_float + ibuf->
channels * offset;
781 BLI_assert_msg(newx > 0 && newy > 0,
"Images must be at least 1 on both dimensions!");
782 if (ibuf ==
nullptr) {
785 if (newx == ibuf->
x && newy == ibuf->
y) {
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
Function declarations for filter.cc.
void imb_freerectImBuf(ImBuf *ibuf)
void imb_freerectfloatImBuf(ImBuf *ibuf)
ImBuf * IMB_dupImBuf(const ImBuf *ibuf1)
void IMB_assign_float_buffer(ImBuf *ibuf, float *buffer_data, ImBufOwnership ownership)
bool imb_addrectImBuf(ImBuf *ibuf, bool initialize_pixels=true)
void IMB_assign_byte_buffer(ImBuf *ibuf, uint8_t *buffer_data, ImBufOwnership ownership)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
ATTR_WARN_UNUSED_RESULT const BMVert * v
constexpr int64_t first() const
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
struct ImBuf * IMB_allocImBuf(unsigned int, unsigned int, unsigned char, unsigned int)
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
#define unit_ushort_to_uchar(val)
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
MINLINE void straight_uchar_to_premul_ushort(ushort result[4], const uchar color[4])
static void alloc_scale_dst_buffers(const ImBuf *ibuf, uint newx, uint newy, uchar4 **r_dst_byte, float **r_dst_float)
ImBuf * IMB_onehalf(ImBuf *ibuf1)
static void scale_nearest(const T *src, T *dst, int ibufx, int ibufy, int newx, int newy, blender::IndexRange y_range)
bool IMB_scale(ImBuf *ibuf, uint newx, uint newy, IMBScaleFilter filter, bool threaded)
ImBuf * IMB_half_x(ImBuf *ibuf1)
static void scale_with_function(ImBuf *ibuf, int newx, int newy, ScaleFunction func, bool threaded)
ImBuf * IMB_half_y(ImBuf *ibuf1)
void imb_onehalf_no_alloc(ImBuf *ibuf2, ImBuf *ibuf1)
static void imb_scale_box(ImBuf *ibuf, uint newx, uint newy, bool threaded)
static void imb_half_x_no_alloc(ImBuf *ibuf2, ImBuf *ibuf1)
static void scale_up_y_func(const ImBuf *ibuf, int newx, int newy, uchar4 *dst_byte, float *dst_float, bool threaded)
MINLINE void premul_ushort_to_straight_uchar(uchar *result, const ushort color[4])
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 imb_half_y_no_alloc(ImBuf *ibuf2, ImBuf *ibuf1)
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)
void(*)( const ImBuf *ibuf, int newx, int newy, uchar4 *dst_byte, float *dst_float, bool threaded) ScaleFunction
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)
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)