FFmpeg
Public Member Functions | Public Attributes | List of all members
SwsContext Struct Reference

Public Member Functions

 DECLARE_ALIGNED (16, int, table_gV)[256+2 *YUVRGB_TABLE_HEADROOM]
 
 DECLARE_ALIGNED (16, int32_t, input_rgb2yuv_table)[16+40 *4]
 
 DECLARE_ALIGNED (8, uint64_t, redDither)
 
 DECLARE_ALIGNED (8, uint64_t, greenDither)
 
 DECLARE_ALIGNED (8, uint64_t, blueDither)
 
 DECLARE_ALIGNED (8, uint64_t, yCoeff)
 
 DECLARE_ALIGNED (8, uint64_t, vrCoeff)
 
 DECLARE_ALIGNED (8, uint64_t, ubCoeff)
 
 DECLARE_ALIGNED (8, uint64_t, vgCoeff)
 
 DECLARE_ALIGNED (8, uint64_t, ugCoeff)
 
 DECLARE_ALIGNED (8, uint64_t, yOffset)
 
 DECLARE_ALIGNED (8, uint64_t, uOffset)
 
 DECLARE_ALIGNED (8, uint64_t, vOffset)
 
 DECLARE_ALIGNED (8, uint64_t, esp)
 
 DECLARE_ALIGNED (8, uint64_t, vRounder)
 
 DECLARE_ALIGNED (8, uint64_t, u_temp)
 
 DECLARE_ALIGNED (8, uint64_t, v_temp)
 
 DECLARE_ALIGNED (8, uint64_t, y_temp)
 
 DECLARE_ALIGNED (8, ptrdiff_t, uv_off)
 offset (in pixels) between u and v planes
 
 DECLARE_ALIGNED (8, ptrdiff_t, uv_offx2)
 offset (in bytes) between u and v planes
 
 DECLARE_ALIGNED (8, uint16_t, dither16)[8]
 
 DECLARE_ALIGNED (8, uint32_t, dither32)[8]
 

Public Attributes

const AVClassav_class
 info on struct for av_log
 
SwsFunc swscale
 Note that src, dst, srcStride, dstStride will be copied in the sws_scale() wrapper so they can be freely modified here.
 
int srcW
 Width of source luma/alpha planes.
 
int srcH
 Height of source luma/alpha planes.
 
int dstH
 Height of destination luma/alpha planes.
 
int chrSrcW
 Width of source chroma planes.
 
int chrSrcH
 Height of source chroma planes.
 
int chrDstW
 Width of destination chroma planes.
 
int chrDstH
 Height of destination chroma planes.
 
int lumXInc
 
int chrXInc
 
int lumYInc
 
int chrYInc
 
enum AVPixelFormat dstFormat
 Destination pixel format.
 
enum AVPixelFormat srcFormat
 Source pixel format.
 
int dstFormatBpp
 Number of bits per pixel of the destination pixel format.
 
int srcFormatBpp
 Number of bits per pixel of the source pixel format.
 
int dstBpc
 
int srcBpc
 
int chrSrcHSubSample
 Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source image.
 
int chrSrcVSubSample
 Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image.
 
int chrDstHSubSample
 Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image.
 
int chrDstVSubSample
 Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination image.
 
int vChrDrop
 Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user.
 
int sliceDir
 Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top).
 
double param [2]
 Input parameters for scaling algorithms that need them.
 
struct SwsContextcascaded_context [3]
 
int cascaded_tmpStride [4]
 
uint8_t * cascaded_tmp [4]
 
int cascaded1_tmpStride [4]
 
uint8_t * cascaded1_tmp [4]
 
int cascaded_mainindex
 
double gamma_value
 
int gamma_flag
 
int is_internal_gamma
 
uint16_t * gamma
 
uint16_t * inv_gamma
 
int numDesc
 
int descIndex [2]
 
int numSlice
 
struct SwsSliceslice
 
struct SwsFilterDescriptordesc
 
uint32_t pal_yuv [256]
 
uint32_t pal_rgb [256]
 
uint8_t * formatConvBuffer
 
int needAlpha
 
int lumMmxextFilterCodeSize
 Runtime-generated MMXEXT horizontal fast bilinear scaler code size for luma/alpha planes.
 
int chrMmxextFilterCodeSize
 Runtime-generated MMXEXT horizontal fast bilinear scaler code size for chroma planes.
 
uint8_t * lumMmxextFilterCode
 Runtime-generated MMXEXT horizontal fast bilinear scaler code for luma/alpha planes.
 
uint8_t * chrMmxextFilterCode
 Runtime-generated MMXEXT horizontal fast bilinear scaler code for chroma planes.
 
int canMMXEXTBeUsed
 
int warned_unuseable_bilinear
 
int dstY
 Last destination vertical line output from last slice.
 
int flags
 Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
 
void * yuvTable
 
uint8_t * table_rV [256+2 *YUVRGB_TABLE_HEADROOM]
 
uint8_t * table_gU [256+2 *YUVRGB_TABLE_HEADROOM]
 
uint8_t * table_bU [256+2 *YUVRGB_TABLE_HEADROOM]
 
int * dither_error [4]
 
int contrast
 
int brightness
 
int saturation
 
int srcColorspaceTable [4]
 
int dstColorspaceTable [4]
 
int srcRange
 0 = MPG YUV range, 1 = JPG YUV range (source image).
 
int dstRange
 0 = MPG YUV range, 1 = JPG YUV range (destination image).
 
int src0Alpha
 
int dst0Alpha
 
int srcXYZ
 
int dstXYZ
 
int src_h_chr_pos
 
int dst_h_chr_pos
 
int src_v_chr_pos
 
int dst_v_chr_pos
 
int yuv2rgb_y_offset
 
int yuv2rgb_y_coeff
 
int yuv2rgb_v2r_coeff
 
int yuv2rgb_v2g_coeff
 
int yuv2rgb_u2g_coeff
 
int yuv2rgb_u2b_coeff
 
int32_t lumMmxFilter [4 *MAX_FILTER_SIZE]
 
int32_t chrMmxFilter [4 *MAX_FILTER_SIZE]
 
int dstW
 Width of destination luma/alpha planes.
 
int32_t alpMmxFilter [4 *MAX_FILTER_SIZE]
 
const uint8_t * chrDither8
 
const uint8_t * lumDither8
 
int use_mmx_vfilter
 
int16_t * xyzgamma
 
int16_t * rgbgamma
 
int16_t * xyzgammainv
 
int16_t * rgbgammainv
 
int16_t xyz2rgb_matrix [3][4]
 
int16_t rgb2xyz_matrix [3][4]
 
yuv2planar1_fn yuv2plane1
 
yuv2planarX_fn yuv2planeX
 
yuv2interleavedX_fn yuv2nv12cX
 
yuv2packed1_fn yuv2packed1
 
yuv2packed2_fn yuv2packed2
 
yuv2packedX_fn yuv2packedX
 
yuv2anyX_fn yuv2anyX
 
void(* lumToYV12 )(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3, int width, uint32_t *pal)
 Unscaled conversion of luma plane to YV12 for horizontal scaler.
 
void(* alpToYV12 )(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3, int width, uint32_t *pal)
 Unscaled conversion of alpha plane to YV12 for horizontal scaler.
 
void(* chrToYV12 )(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, int width, uint32_t *pal)
 Unscaled conversion of chroma planes to YV12 for horizontal scaler.
 
void(* lumConvertRange )(int16_t *dst, int width)
 Color range conversion function for luma plane if needed.
 
void(* chrConvertRange )(int16_t *dst1, int16_t *dst2, int width)
 Color range conversion function for chroma planes if needed.
 
int needs_hcscale
 Set if there are chroma planes to be converted.
 
SwsDither dither
 
SwsAlphaBlend alphablend
 
Scaled horizontal lines ring buffer.

The horizontal scaler keeps just enough scaled lines in a ring buffer so they may be passed to the vertical scaler.

The pointers to the allocated buffers for each line are duplicated in sequence in the ring buffer to simplify indexing and avoid wrapping around between lines inside the vertical scaler code. The wrapping is done before the vertical scaler is called.

int lastInLumBuf
 Last scaled horizontal luma/alpha line from source in the ring buffer.
 
int lastInChrBuf
 Last scaled horizontal chroma line from source in the ring buffer.
 
int lumBufIndex
 Index in ring buffer of the last scaled horizontal luma/alpha line from source.
 
int chrBufIndex
 Index in ring buffer of the last scaled horizontal chroma line from source.
 
Horizontal and vertical filters.

To better understand the following fields, here is a pseudo-code of their usage in filtering a horizontal line:

for (i = 0; i < width; i++) {
dst[i] = 0;
for (j = 0; j < filterSize; j++)
dst[i] += src[ filterPos[i] + j ] * filter[ filterSize * i + j ];
dst[i] >>= FRAC_BITS; // The actual implementation is fixed-point.
}
int16_t * hLumFilter
 Array of horizontal filter coefficients for luma/alpha planes.
 
int16_t * hChrFilter
 Array of horizontal filter coefficients for chroma planes.
 
int16_t * vLumFilter
 Array of vertical filter coefficients for luma/alpha planes.
 
int16_t * vChrFilter
 Array of vertical filter coefficients for chroma planes.
 
int32_t * hLumFilterPos
 Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
 
int32_t * hChrFilterPos
 Array of horizontal filter starting positions for each dst[i] for chroma planes.
 
int32_t * vLumFilterPos
 Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
 
int32_t * vChrFilterPos
 Array of vertical filter starting positions for each dst[i] for chroma planes.
 
int hLumFilterSize
 Horizontal filter size for luma/alpha pixels.
 
int hChrFilterSize
 Horizontal filter size for chroma pixels.
 
int vLumFilterSize
 Vertical filter size for luma/alpha pixels.
 
int vChrFilterSize
 Vertical filter size for chroma pixels.
 
void(* readLumPlanar )(uint8_t *dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
 Functions to read planar input, such as planar RGB, and convert internally to Y/UV/A.
 
void(* readChrPlanar )(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv)
 
void(* readAlpPlanar )(uint8_t *dst, const uint8_t *src[4], int width, int32_t *rgb2yuv)
 
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. More...
 
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)
 
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 (differently sized) line of output data. More...
 
void(* hcScale )(struct SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize)
 

Member Data Documentation

§ hyScale

void(* SwsContext::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 (differently sized) line of output data.

Parameters
dstpointer to destination buffer for horizontally scaled data. If the number of bits per component of one destination pixel (SwsContext->dstBpc) is <= 10, data will be 15 bpc in 16 bits (int16_t) width. Else (i.e. SwsContext->dstBpc == 16), data will be 19bpc in 32 bits (int32_t) width.
dstWwidth of destination image
srcpointer to source data to be scaled. If the number of bits per component of a source pixel (SwsContext->srcBpc) is 8, this is 8bpc in 8 bits (uint8_t) width. Else (i.e. SwsContext->dstBpc > 8), this is native depth in 16 bits (uint16_t) width. In other words, for 9-bit YUV input, this is 9bpc, for 10-bit YUV input, this is 10bpc, and for 16-bit RGB or YUV, this is 16bpc.
filterfilter coefficients to be used per output pixel for scaling. This contains 14bpp filtering coefficients. Guaranteed to contain dstW * filterSize entries.
filterPosposition of the first input pixel to be used for each output pixel during scaling. Guaranteed to contain dstW entries.
filterSizethe number of input coefficients to be used (and thus the number of input pixels to be used) for creating a single output pixel. Is aligned to 4 (and input coefficients thus padded with zeroes) to simplify creating SIMD code.

§ hyscale_fast

void(* SwsContext::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.

Compared to SwsContext->hScale(), please take note of the following caveats when using these:

  • Scaling is done using only 7 bits instead of 14-bit coefficients.
  • You can use no more than 5 input pixels to produce 4 output pixels. Therefore, this filter should not be used for downscaling by more than ~20% in width (because that equals more than 5/4th downscaling and thus more than 5 pixels input per 4 pixels output).
  • In general, bilinear filters create artifacts during downscaling (even when <20%), because one output pixel will span more than one input pixel, and thus some pixels will need edges of both neighbor pixels to interpolate the output pixel. Since you can use at most two input pixels per output pixel in bilinear scaling, this is impossible and thus downscaling by any size will create artifacts. To enable this type of scaling, set SWS_FLAG_FAST_BILINEAR in SwsContext->flags.

The documentation for this struct was generated from the following file: