21 #ifndef SWSCALE_SWSCALE_INTERNAL_H
22 #define SWSCALE_SWSCALE_INTERNAL_H
35 #define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
37 #define FAST_BGR2YV12 // use 7-bit instead of 15-bit coefficients
39 #define MAX_FILTER_SIZE 256
42 #define ALT32_CORR (-1)
60 int srcStride[],
int srcSliceY,
int srcSliceH,
61 uint8_t *dst[],
int dstStride[]);
76 const uint8_t *
dither,
int offset);
92 const int16_t **src, uint8_t *dest,
int dstW,
93 const uint8_t *
dither,
int offset);
111 const int16_t *chrFilter,
113 const int16_t **chrUSrc,
114 const int16_t **chrVSrc,
115 uint8_t *dest,
int dstW);
147 const int16_t *chrUSrc[2],
148 const int16_t *chrVSrc[2],
149 const int16_t *alpSrc, uint8_t *dest,
150 int dstW,
int uvalpha,
int y);
180 const int16_t *chrUSrc[2],
181 const int16_t *chrVSrc[2],
182 const int16_t *alpSrc[2],
184 int dstW,
int yalpha,
int uvalpha,
int y);
212 const int16_t **lumSrc,
int lumFilterSize,
213 const int16_t *chrFilter,
214 const int16_t **chrUSrc,
215 const int16_t **chrVSrc,
int chrFilterSize,
216 const int16_t **alpSrc, uint8_t *dest,
336 #define RED_DITHER "0*8"
337 #define GREEN_DITHER "1*8"
338 #define BLUE_DITHER "2*8"
339 #define Y_COEFF "3*8"
340 #define VR_COEFF "4*8"
341 #define UB_COEFF "5*8"
342 #define VG_COEFF "6*8"
343 #define UG_COEFF "7*8"
344 #define Y_OFFSET "8*8"
345 #define U_OFFSET "9*8"
346 #define V_OFFSET "10*8"
347 #define LUM_MMX_FILTER_OFFSET "11*8"
348 #define CHR_MMX_FILTER_OFFSET "11*8+4*4*256"
349 #define DSTW_OFFSET "11*8+4*4*256*2" //do not change, it is hardcoded in the ASM
350 #define ESP_OFFSET "11*8+4*4*256*2+8"
351 #define VROUNDER_OFFSET "11*8+4*4*256*2+16"
352 #define U_TEMP "11*8+4*4*256*2+24"
353 #define V_TEMP "11*8+4*4*256*2+32"
354 #define Y_TEMP "11*8+4*4*256*2+40"
355 #define ALP_MMX_FILTER_OFFSET "11*8+4*4*256*2+48"
356 #define UV_OFF_PX "11*8+4*4*256*3+48"
357 #define UV_OFF_BYTE "11*8+4*4*256*3+56"
358 #define DITHER16 "11*8+4*4*256*3+64"
359 #define DITHER32 "11*8+4*4*256*3+80"
393 vector
signed short CY;
394 vector
signed short CRV;
395 vector
signed short CBU;
396 vector
signed short CGU;
397 vector
signed short CGV;
398 vector
signed short OY;
399 vector
unsigned short CSHIFT;
400 vector
signed short *vYCoeffsBank, *vCCoeffsBank;
431 int width, uint32_t *pal);
434 int width, uint32_t *pal);
437 const uint8_t *src1,
const uint8_t *src2,
438 int width, uint32_t *pal);
470 int16_t *dst,
int dstWidth,
471 const uint8_t *src,
int srcW,
int xInc);
473 int16_t *dst1, int16_t *dst2,
int dstWidth,
474 const uint8_t *src1,
const uint8_t *src2,
510 const uint8_t *src,
const int16_t *
filter,
511 const int32_t *filterPos,
int filterSize);
513 const uint8_t *src,
const int16_t *
filter,
514 const int32_t *filterPos,
int filterSize);
546 (av_pix_fmt_descriptors[x].comp[0].depth_minus1 == 15)
548 #define is9_OR_10BPS(x) \
549 (av_pix_fmt_descriptors[x].comp[0].depth_minus1 == 8 || \
550 av_pix_fmt_descriptors[x].comp[0].depth_minus1 == 9)
553 (av_pix_fmt_descriptors[x].flags & PIX_FMT_BE)
556 (!(av_pix_fmt_descriptors[x].flags & PIX_FMT_RGB) && \
557 av_pix_fmt_descriptors[x].nb_components >= 2)
559 #define isPlanarYUV(x) \
560 ((av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR) && \
564 (av_pix_fmt_descriptors[x].flags & PIX_FMT_RGB)
568 (!(av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) && \
569 av_pix_fmt_descriptors[x].nb_components <= 2)
572 ((x) == PIX_FMT_GRAY8 || \
573 (x) == PIX_FMT_Y400A || \
574 (x) == PIX_FMT_GRAY16BE || \
575 (x) == PIX_FMT_GRAY16LE)
578 #define isRGBinInt(x) \
579 ((x) == PIX_FMT_RGB48BE || \
580 (x) == PIX_FMT_RGB48LE || \
581 (x) == PIX_FMT_RGB32 || \
582 (x) == PIX_FMT_RGB32_1 || \
583 (x) == PIX_FMT_RGB24 || \
584 (x) == PIX_FMT_RGB565BE || \
585 (x) == PIX_FMT_RGB565LE || \
586 (x) == PIX_FMT_RGB555BE || \
587 (x) == PIX_FMT_RGB555LE || \
588 (x) == PIX_FMT_RGB444BE || \
589 (x) == PIX_FMT_RGB444LE || \
590 (x) == PIX_FMT_RGB8 || \
591 (x) == PIX_FMT_RGB4 || \
592 (x) == PIX_FMT_RGB4_BYTE || \
593 (x) == PIX_FMT_MONOBLACK || \
594 (x) == PIX_FMT_MONOWHITE)
596 #define isBGRinInt(x) \
597 ((x) == PIX_FMT_BGR48BE || \
598 (x) == PIX_FMT_BGR48LE || \
599 (x) == PIX_FMT_BGR32 || \
600 (x) == PIX_FMT_BGR32_1 || \
601 (x) == PIX_FMT_BGR24 || \
602 (x) == PIX_FMT_BGR565BE || \
603 (x) == PIX_FMT_BGR565LE || \
604 (x) == PIX_FMT_BGR555BE || \
605 (x) == PIX_FMT_BGR555LE || \
606 (x) == PIX_FMT_BGR444BE || \
607 (x) == PIX_FMT_BGR444LE || \
608 (x) == PIX_FMT_BGR8 || \
609 (x) == PIX_FMT_BGR4 || \
610 (x) == PIX_FMT_BGR4_BYTE || \
611 (x) == PIX_FMT_MONOBLACK || \
612 (x) == PIX_FMT_MONOWHITE)
614 #define isAnyRGB(x) \
619 (av_pix_fmt_descriptors[x].nb_components == 2 || \
620 av_pix_fmt_descriptors[x].nb_components == 4)
622 #define isPacked(x) \
623 ((av_pix_fmt_descriptors[x].nb_components >= 2 && \
624 !(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR)) || \
627 #define isPlanar(x) \
628 (av_pix_fmt_descriptors[x].nb_components >= 2 && \
629 (av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR))
631 #define usePal(x) ((av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) || (x) == PIX_FMT_Y400A)
int16_t ** alpPixBuf
Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
ptrdiff_t uv_off_px
offset (in pixels) between u and v planes
const uint64_t ff_dither8[2]
int chrBufIndex
Index in ring buffer of the last scaled horizontal chroma line from source.
void(* hcscale_fast)(struct SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc)
int chrSrcH
Height of source chroma planes.
void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex, int lastInLumBuf, int lastInChrBuf)
int vChrDrop
Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user...
int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
#define DECLARE_ALIGNED(n, t, v)
void(* readChrPlanar)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int width)
int srcRange
0 = MPG YUV range, 1 = JPG YUV range (source image).
const uint8_t * lumDither8
int dstY
Last destination vertical line output from last slice.
SwsFunc swScale
Note that src, dst, srcStride, dstStride will be copied in the sws_scale() wrapper so they can be fre...
enum PixelFormat srcFormat
Source pixel format.
void(* readLumPlanar)(uint8_t *dst, const uint8_t *src[4], int width)
Functions to read planar input, such as planar RGB, and convert internally to Y/UV.
int srcH
Height of source luma/alpha planes.
int chrMmx2FilterCodeSize
Runtime-generated MMX2 horizontal fast bilinear scaler code size for chroma planes.
int chrDstVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination i...
void(* yuv2interleavedX_fn)(struct SwsContext *c, const int16_t *chrFilter, int chrFilterSize, const int16_t **chrUSrc, const int16_t **chrVSrc, uint8_t *dest, int dstW)
Write one line of horizontally scaled chroma to interleaved output with multi-point vertical scaling ...
int vChrFilterSize
Vertical filter size for chroma pixels.
int16_t ** lumPixBuf
Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
uint8_t * chrMmx2FilterCode
Runtime-generated MMX2 horizontal fast bilinear scaler code for chroma planes.
int lastInLumBuf
Last scaled horizontal luma/alpha line from source in the ring buffer.
int chrSrcHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source imag...
yuv2packedX_fn yuv2packedX
void(* lumConvertRange)(int16_t *dst, int width)
Color range conversion function for luma plane if needed.
int32_t * vChrFilterPos
Array of vertical filter starting positions for each dst[i] for chroma planes.
int dstH
Height of destination luma/alpha planes.
void(* yuv2packed1_fn)(struct SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc[2], const int16_t *chrVSrc[2], const int16_t *alpSrc, uint8_t *dest, int dstW, int uvalpha, int y)
Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB output without any additional v...
struct SwsContext SwsContext
void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4], int brightness, int contrast, int saturation)
const uint64_t ff_dither4[2]
int16_t ** chrVPixBuf
Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
int32_t * hChrFilterPos
Array of horizontal filter starting positions for each dst[i] for chroma planes.
int hLumFilterSize
Horizontal filter size for luma/alpha pixels.
yuv2packed1_fn yuv2packed1
const char * sws_format_name(enum PixelFormat format)
int vChrBufSize
Number of vertical chroma lines allocated in the ring buffer.
void ff_bfin_get_unscaled_swscale(SwsContext *c)
int chrDstW
Width of destination chroma planes.
void(* alpToYV12)(uint8_t *dst, const uint8_t *src, int width, uint32_t *pal)
Unscaled conversion of alpha plane to YV12 for horizontal scaler.
void(* chrConvertRange)(int16_t *dst1, int16_t *dst2, int width)
Color range conversion function for chroma planes if needed.
int32_t alpMmxFilter[4 *MAX_FILTER_SIZE]
int32_t * hLumFilterPos
Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
int hChrFilterSize
Horizontal filter size for chroma pixels.
SwsFunc ff_yuv2rgb_init_mlib(SwsContext *c)
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
ptrdiff_t uv_off_byte
offset (in bytes) between u and v planes
int dstRange
0 = MPG YUV range, 1 = JPG YUV range (destination image).
void(* yuv2planar1_fn)(const int16_t *src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
Write one line of horizontally scaled data to planar output without any additional vertical scaling (...
uint8_t * formatConvBuffer
void(* chrToYV12)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *pal)
Unscaled conversion of chroma planes to YV12 for horizontal scaler.
yuv2planar1_fn yuv2plane1
int vLumBufSize
Number of vertical luma/alpha lines allocated in the ring buffer.
int16_t ** chrUPixBuf
Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
yuv2interleavedX_fn yuv2nv12cX
void(* hcScale)(struct SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
int lumMmx2FilterCodeSize
Runtime-generated MMX2 horizontal fast bilinear scaler code size for luma/alpha planes.
int srcColorspaceTable[4]
int dstW
Width of destination luma/alpha planes.
void ff_swscale_get_unscaled_altivec(SwsContext *c)
int sliceDir
Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top).
int needs_hcscale
Set if there are chroma planes to be converted.
int32_t * vLumFilterPos
Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
int32_t lumMmxFilter[4 *MAX_FILTER_SIZE]
static const uint16_t dither[8][8]
SwsFunc ff_getSwsFunc(SwsContext *c)
Return function pointer to fastest main scaler path function depending on architecture and available ...
int dstColorspaceTable[4]
const AVClass * av_class
info on struct for av_log
yuv2planarX_fn yuv2planeX
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
int chrDstH
Height of destination chroma planes.
SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c)
int(* SwsFunc)(struct SwsContext *context, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
Describe the class of an AVClass context structure.
SwsFunc ff_yuv2rgb_init_vis(SwsContext *c)
int vLumFilterSize
Vertical filter size for luma/alpha pixels.
SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c)
int16_t * vChrFilter
Array of vertical filter coefficients for chroma planes.
int16_t * hLumFilter
Array of horizontal filter coefficients for luma/alpha planes.
const uint8_t * chrDither8
int lumBufIndex
Index in ring buffer of the last scaled horizontal luma/alpha line from source.
int lastInChrBuf
Last scaled horizontal chroma line from source in the ring buffer.
yuv2packed2_fn yuv2packed2
void(* yuv2planarX_fn)(const int16_t *filter, int filterSize, const int16_t **src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
Write one line of horizontally scaled data to planar output with multi-point vertical scaling between...
double param[2]
Input parameters for scaling algorithms that need them.
void(* yuv2packed2_fn)(struct SwsContext *c, const int16_t *lumSrc[2], const int16_t *chrUSrc[2], const int16_t *chrVSrc[2], const int16_t *alpSrc[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB output by doing bilinear scalin...
void(* yuv2packedX_fn)(struct SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB output by doing multi-point ver...
int32_t chrMmxFilter[4 *MAX_FILTER_SIZE]
void(* hyscale_fast)(struct SwsContext *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc)
Scale one horizontal line of input data using a bilinear filter to produce one line of output data...
const AVClass sws_context_class
int srcFormatBpp
Number of bits per pixel of the source pixel format.
int16_t * vLumFilter
Array of vertical filter coefficients for luma/alpha planes.
void ff_sws_init_swScale_altivec(SwsContext *c)
void ff_sws_init_swScale_mmx(SwsContext *c)
int16_t * hChrFilter
Array of horizontal filter coefficients for chroma planes.
enum PixelFormat dstFormat
Destination pixel format.
int chrDstHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination...
int chrSrcW
Width of source chroma planes.
void ff_get_unscaled_swscale(SwsContext *c)
Set c->swScale to an unscaled converter if one exists for the specific source and destination formats...
int srcW
Width of source luma/alpha planes.
int chrSrcVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image...
int flags
Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
void(* lumToYV12)(uint8_t *dst, const uint8_t *src, int width, uint32_t *pal)
Unscaled conversion of luma plane to YV12 for horizontal scaler.
void(* hyScale)(struct SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
Scale one horizontal line of input data using a filter over the input lines, to produce one (differen...
uint8_t * lumMmx2FilterCode
Runtime-generated MMX2 horizontal fast bilinear scaler code for luma/alpha planes.