Blender  V3.3
Classes | Typedefs | Functions
scaling.c File Reference
#include <math.h>
#include "BLI_math_color.h"
#include "BLI_math_interp.h"
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "imbuf.h"
#include "IMB_filter.h"
#include "BLI_sys_types.h"

Go to the source code of this file.

Classes

struct  scale_outpix_byte
 
struct  scale_outpix_float
 
struct  imbufRGBA
 
struct  ScaleTreadInitData
 
struct  ScaleThreadData
 

Typedefs

typedef struct ScaleTreadInitData ScaleTreadInitData
 
typedef struct ScaleThreadData ScaleThreadData
 

Functions

static void imb_half_x_no_alloc (struct ImBuf *ibuf2, struct ImBuf *ibuf1)
 
struct ImBufIMB_half_x (struct ImBuf *ibuf1)
 
struct ImBufIMB_double_fast_x (struct ImBuf *ibuf1)
 
struct ImBufIMB_double_x (struct ImBuf *ibuf1)
 
static void imb_half_y_no_alloc (struct ImBuf *ibuf2, struct ImBuf *ibuf1)
 
struct ImBufIMB_half_y (struct ImBuf *ibuf1)
 
struct ImBufIMB_double_fast_y (struct ImBuf *ibuf1)
 
struct ImBufIMB_double_y (struct ImBuf *ibuf1)
 
MINLINE void straight_uchar_to_premul_ushort (unsigned short result[4], const unsigned char color[4])
 
MINLINE void premul_ushort_to_straight_uchar (unsigned char *result, const unsigned short color[4])
 
void imb_onehalf_no_alloc (struct ImBuf *ibuf2, struct ImBuf *ibuf1)
 
ImBufIMB_onehalf (struct ImBuf *ibuf1)
 
static void enlarge_picture_byte (unsigned char *src, unsigned char *dst, int src_width, int src_height, int dst_width, int dst_height)
 
static void shrink_picture_byte (unsigned char *src, unsigned char *dst, int src_width, int src_height, int dst_width, int dst_height)
 
static void q_scale_byte (unsigned char *in, unsigned char *out, int in_width, int in_height, int dst_width, int dst_height)
 
static void enlarge_picture_float (float *src, float *dst, int src_width, int src_height, int dst_width, int dst_height)
 
static void shrink_picture_float (const float *src, float *dst, int src_width, int src_height, int dst_width, int dst_height)
 
static void q_scale_float (float *in, float *out, int in_width, int in_height, int dst_width, int dst_height)
 
static bool q_scale_linear_interpolation (struct ImBuf *ibuf, int newx, int newy)
 
static ImBufscaledownx (struct ImBuf *ibuf, int newx)
 
static ImBufscaledowny (struct ImBuf *ibuf, int newy)
 
static ImBufscaleupx (struct ImBuf *ibuf, int newx)
 
static ImBufscaleupy (struct ImBuf *ibuf, int newy)
 
static void scalefast_Z_ImBuf (ImBuf *ibuf, int newx, int newy)
 
bool IMB_scaleImBuf (struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
 
bool IMB_scalefastImBuf (struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
 
static void scale_thread_init (void *data_v, int start_line, int tot_line, void *init_data_v)
 
static voiddo_scale_thread (void *data_v)
 
void IMB_scaleImBuf_threaded (ImBuf *ibuf, unsigned int newx, unsigned int newy)
 

Typedef Documentation

◆ ScaleThreadData

◆ ScaleTreadInitData

Function Documentation

◆ do_scale_thread()

static void* do_scale_thread ( void data_v)
static

◆ enlarge_picture_byte()

static void enlarge_picture_byte ( unsigned char *  src,
unsigned char *  dst,
int  src_width,
int  src_height,
int  dst_width,
int  dst_height 
)
static

Definition at line 463 of file scaling.c.

References double(), src, and x.

Referenced by q_scale_byte().

◆ enlarge_picture_float()

static void enlarge_picture_float ( float src,
float dst,
int  src_width,
int  src_height,
int  dst_width,
int  dst_height 
)
static

Definition at line 661 of file scaling.c.

References double(), float(), src, and x.

Referenced by q_scale_float().

◆ IMB_double_fast_x()

struct ImBuf* IMB_double_fast_x ( struct ImBuf ibuf1)
Attention
defined in scaling.c

Definition at line 107 of file scaling.c.

References col, dest, ImBuf::flags, IMB_allocImBuf(), NULL, ImBuf::planes, ImBuf::rect, ImBuf::rect_float, ImBuf::x, and ImBuf::y.

Referenced by IMB_double_x().

◆ IMB_double_fast_y()

struct ImBuf* IMB_double_fast_y ( struct ImBuf ibuf1)
Attention
defined in scaling.c

Definition at line 260 of file scaling.c.

References ImBuf::flags, IMB_allocImBuf(), NULL, ImBuf::planes, ImBuf::rect, ImBuf::rect_float, x, ImBuf::x, y, and ImBuf::y.

Referenced by IMB_double_y().

◆ IMB_double_x()

struct ImBuf* IMB_double_x ( struct ImBuf ibuf1)
Attention
defined in scaling.c

Definition at line 152 of file scaling.c.

References IMB_double_fast_x(), imb_filterx(), NULL, ImBuf::rect, and ImBuf::rect_float.

◆ IMB_double_y()

struct ImBuf* IMB_double_y ( struct ImBuf ibuf1)
Attention
defined in scaling.c

Definition at line 307 of file scaling.c.

References IMB_double_fast_y(), IMB_filtery(), NULL, and ImBuf::rect.

◆ IMB_half_x()

struct ImBuf* IMB_half_x ( struct ImBuf ibuf1)

◆ imb_half_x_no_alloc()

static void imb_half_x_no_alloc ( struct ImBuf ibuf2,
struct ImBuf ibuf1 
)
static

◆ IMB_half_y()

struct ImBuf* IMB_half_y ( struct ImBuf ibuf1)

◆ imb_half_y_no_alloc()

static void imb_half_y_no_alloc ( struct ImBuf ibuf2,
struct ImBuf ibuf1 
)
static

◆ IMB_onehalf()

ImBuf* IMB_onehalf ( struct ImBuf ibuf1)

◆ imb_onehalf_no_alloc()

void imb_onehalf_no_alloc ( struct ImBuf ibuf2,
struct ImBuf ibuf1 
)

◆ IMB_scalefastImBuf()

bool IMB_scalefastImBuf ( struct ImBuf ibuf,
unsigned int  newx,
unsigned int  newy 
)

◆ IMB_scaleImBuf()

bool IMB_scaleImBuf ( struct ImBuf ibuf,
unsigned int  newx,
unsigned int  newy 
)

◆ IMB_scaleImBuf_threaded()

void IMB_scaleImBuf_threaded ( struct ImBuf ibuf,
unsigned int  newx,
unsigned int  newy 
)

◆ premul_ushort_to_straight_uchar()

MINLINE void premul_ushort_to_straight_uchar ( unsigned char *  result,
const unsigned short  color[4] 
)

Definition at line 338 of file scaling.c.

References color, result, and unit_ushort_to_uchar().

Referenced by imb_onehalf_no_alloc().

◆ q_scale_byte()

static void q_scale_byte ( unsigned char *  in,
unsigned char *  out,
int  in_width,
int  in_height,
int  dst_width,
int  dst_height 
)
static

Definition at line 646 of file scaling.c.

References enlarge_picture_byte(), usdtokens::out(), and shrink_picture_byte().

Referenced by q_scale_linear_interpolation().

◆ q_scale_float()

static void q_scale_float ( float in,
float out,
int  in_width,
int  in_height,
int  dst_width,
int  dst_height 
)
static

◆ q_scale_linear_interpolation()

static bool q_scale_linear_interpolation ( struct ImBuf ibuf,
int  newx,
int  newy 
)
static

q_scale_linear_interpolation (derived from ppmqscale, http://libdv.sf.net)

q stands for quick and quality :)

only handles common cases when we either

scale both, x and y or shrink both, x and y

but that is pretty fast:

  • does only blit once instead of two passes like the old code (fewer cache misses)
  • uses fixed point integer arithmetic for byte buffers
  • doesn't branch in tight loops

Should be comparable in speed to the ImBuf ..._fast functions at least for byte-buffers.

NOTE: disabled, due to unacceptable inaccuracy and quality loss, see bug T18609 (ton)

Definition at line 864 of file scaling.c.

References IB_rect, IB_rectfloat, imb_freerectfloatImBuf(), imb_freerectImBuf(), ImBuf::mall, MEM_mallocN, q_scale_byte(), q_scale_float(), ImBuf::rect, ImBuf::rect_float, x, ImBuf::x, y, and ImBuf::y.

Referenced by IMB_scaleImBuf().

◆ scale_thread_init()

static void scale_thread_init ( void data_v,
int  start_line,
int  tot_line,
void init_data_v 
)
static

Definition at line 1812 of file scaling.c.

References data, and init_data().

Referenced by IMB_scaleImBuf_threaded().

◆ scaledownx()

static ImBuf* scaledownx ( struct ImBuf ibuf,
int  newx 
)
static

◆ scaledowny()

static ImBuf* scaledowny ( struct ImBuf ibuf,
int  newy 
)
static

◆ scalefast_Z_ImBuf()

static void scalefast_Z_ImBuf ( ImBuf ibuf,
int  newx,
int  newy 
)
static

◆ scaleupx()

static ImBuf* scaleupx ( struct ImBuf ibuf,
int  newx 
)
static

◆ scaleupy()

static ImBuf* scaleupy ( struct ImBuf ibuf,
int  newy 
)
static

◆ shrink_picture_byte()

static void shrink_picture_byte ( unsigned char *  src,
unsigned char *  dst,
int  src_width,
int  src_height,
int  dst_width,
int  dst_height 
)
static

◆ shrink_picture_float()

static void shrink_picture_float ( const float src,
float dst,
int  src_width,
int  src_height,
int  dst_width,
int  dst_height 
)
static

◆ straight_uchar_to_premul_ushort()

MINLINE void straight_uchar_to_premul_ushort ( unsigned short  result[4],
const unsigned char  color[4] 
)

Definition at line 327 of file scaling.c.

References color, and result.

Referenced by imb_onehalf_no_alloc().