[FFmpeg-devel] [PATCH] Doxument some of SwsContext.
Michael Niedermayer
michaelni
Fri Jan 15 01:56:52 CET 2010
On Thu, Jan 14, 2010 at 04:13:36AM -0200, Ramiro Polla wrote:
> Hi,
>
> This is an attempt to document most of SwsContext. It also reorders
> some fields and existing documentation around cosmetically.
>
> I am not confident enough to document the yuv2rgb stuff since I still
> don't understand it (specially the tables generation). Michael,
> Kostya, could you please help out by describing a bit the cryptic
> variable names in ff_yuv2rgb_c_init_tables (such as yb) and the
> magical values (such as const int yoffs = fullRange ? 384 : 326;)?
>
> I believe it will take a few rounds to get most documentation ok, so
> I'd prefer if the good chunks were ok'd and could be applied in small
> steps instead of resending a new entire patch all the time.
>
> Ramiro Polla
> swscale_internal.h | 195 ++++++++++++++++++++++++++++++++++++-----------------
> 1 file changed, 136 insertions(+), 59 deletions(-)
> ed56b2b7b257322ddcd005a281da898d684689ac 0004-Doxument-some-of-SwsContext.patch
> From 75a2d3731971c0c3ab002bb070dc20972b70562c Mon Sep 17 00:00:00 2001
> From: Ramiro Polla <ramiro.polla at gmail.com>
> Date: Thu, 14 Jan 2010 04:00:36 -0200
> Subject: [PATCH] Doxument some of SwsContext.
>
> ---
> swscale_internal.h | 195 ++++++++++++++++++++++++++++++++++++----------------
> 1 files changed, 136 insertions(+), 59 deletions(-)
>
> diff --git a/swscale_internal.h b/swscale_internal.h
> index b6a4e58..885d3fc 100644
> --- a/swscale_internal.h
> +++ b/swscale_internal.h
> @@ -75,65 +75,104 @@ typedef struct SwsContext {
> * sws_scale() wrapper so they can be freely modified here.
> */
> SwsFunc swScale;
> - int srcW, srcH, dstH;
> - int chrSrcW, chrSrcH, chrDstW, chrDstH;
> - int lumXInc, chrXInc;
> - int lumYInc, chrYInc;
> - enum PixelFormat dstFormat, srcFormat; ///< format 4:2:0 type is always YV12
> - int chrSrcHSubSample, chrSrcVSubSample;
> - int chrDstHSubSample, chrDstVSubSample;
> - int vChrDrop;
> - int sliceDir;
> - double param[2];
> -
> - uint32_t pal_yuv[256];
> - uint32_t pal_rgb[256];
> -
> - int16_t **lumPixBuf;
> - int16_t **chrPixBuf;
> - int16_t **alpPixBuf;
> - int16_t *hLumFilter;
> - int16_t *hLumFilterPos;
> - int16_t *hChrFilter;
> - int16_t *hChrFilterPos;
> - int16_t *vLumFilter;
> - int16_t *vLumFilterPos;
> - int16_t *vChrFilter;
> - int16_t *vChrFilterPos;
> -
> - uint8_t formatConvBuffer[VOF]; //FIXME dynamic allocation, but we have to change a lot of code for this to be useful
> -
> - int hLumFilterSize;
> - int hChrFilterSize;
> - int vLumFilterSize;
> - int vChrFilterSize;
> - int vLumBufSize;
> - int vChrBufSize;
> -
> - int lumMmx2FilterCodeSize;
> - int chrMmx2FilterCodeSize;
> - uint8_t *lumMmx2FilterCode;
> - uint8_t *chrMmx2FilterCode;
> -
> - int canMMX2BeUsed;
> -
> - int lastInLumBuf;
> - int lastInChrBuf;
> - int lumBufIndex;
> - int chrBufIndex;
> - int dstY;
> - int flags;
> - void * yuvTable; // pointer to the yuv->rgb table start so it can be freed()
> - uint8_t * table_rV[256];
> - uint8_t * table_gU[256];
> - int table_gV[256];
> - uint8_t * table_bU[256];
> + 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.
ok
> + int lumXInc; ///< Horizontal scale factor between source and destination luma/alpha planes.
> + int chrXInc; ///< Horizontal scale factor between source and destination chroma planes.
> + int lumYInc; ///< Vertical scale factor between source and destination luma/alpha planes.
> + int chrYInc; ///< Vertical scale factor between source and destination chroma planes.
> + enum PixelFormat dstFormat; ///< Destination pixel format.
> + enum PixelFormat srcFormat; ///< Source pixel format.
probably ok
> + int chrSrcHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source image.
log2 is shorter
> + 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 (top-to-bottom or bottom-to-top).
its a int not a string ;) which is which
> + double param[2]; ///< Input parameters for scaling algorithms that need them.
ok
> +
> + uint32_t pal_yuv[256]; ///< YUV values corresponding to palettized data from source pixel format.
> + uint32_t pal_rgb[256]; ///< RGB32 values corresponding to palettized data from source pixel format.
> +
> + /**
> + * @name 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.
> + */
> + //@{
> + int16_t **lumPixBuf; ///< Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
> + int16_t **chrPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
> + int16_t **alpPixBuf; ///< Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
> + int vLumBufSize; ///< Number of vertical luma/alpha lines allocated in the ring buffer.
> + int vChrBufSize; ///< Number of vertical chroma lines allocated in the ring buffer.
> + 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.
> + //@}
sounds probable, you know its long ago that i worked much on sws
i could miss some wrong but probable sounding things ...
> +
> + /**
> + * @name Horizontal and vertical filters.
> + * To better understand the following fields, here is a pseudo-code of
> + * their usage in filtering a horizontal line:
> + * @code
> + * 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 ];
> + * }
> + * @endcode
> + */
> + //@{
> + 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.
> + int16_t *hLumFilterPos; ///< Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
> + int16_t *hChrFilterPos; ///< Array of horizontal filter starting positions for each dst[i] for chroma planes.
> + int16_t *vLumFilterPos; ///< Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
> + int16_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.
> + //@}
> +
> + //FIXME dynamic allocation, but we have to change a lot of code for this to be useful
> + uint8_t formatConvBuffer[VOF]; ///< Intermediate horizontal scaler buffer used for unscaled conversion of input data to YV12.
> +
> + int canMMX2BeUsed; ///< Whether the runtime-generated MMX2 horizontal fast bilinear scaler can be used.
> + int lumMmx2FilterCodeSize; ///< Runtime-generated MMX2 horizontal fast bilinear scaler code size for luma/alpha planes.
> + int chrMmx2FilterCodeSize; ///< Runtime-generated MMX2 horizontal fast bilinear scaler code size for chroma planes.
> + uint8_t *lumMmx2FilterCode; ///< Runtime-generated MMX2 horizontal fast bilinear scaler code for luma/alpha planes.
> + uint8_t *chrMmx2FilterCode; ///< Runtime-generated MMX2 horizontal fast bilinear scaler code for chroma planes.
> +
> + int dstY; ///< Last destination vertical line output from last slice.
> + int flags; ///< Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
ok
> +
> + void *yuvTable; ///< Pointer to the yuv->rgb table start so it can be freed().
> + uint8_t *table_rV[256];
> + uint8_t *table_gU[256];
> + int table_gV[256];
> + uint8_t *table_bU[256];
>
> //Colorspace stuff
> - int contrast, brightness, saturation; // for sws_getColorspaceDetails
> + int contrast;
> + int brightness;
> + int saturation; // for sws_getColorspaceDetails
> int srcColorspaceTable[4];
> int dstColorspaceTable[4];
> - int srcRange, dstRange;
> + 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 yuv2rgb_y_offset;
> int yuv2rgb_y_coeff;
> int yuv2rgb_v2r_coeff;
ok
[...]
> @@ -231,39 +280,67 @@ typedef struct SwsContext {
> uint8_t *dest,
> uint8_t *uDest, uint8_t *vDest, uint8_t *aDest,
> long dstW, long chrDstW);
> + /**
> + * Vertical YV12 to RGB converter without scaling or interpolating.
> + */
> void (*yuv2packed1)(struct SwsContext *c,
> const uint16_t *buf0,
> const uint16_t *uvbuf0, const uint16_t *uvbuf1,
> const uint16_t *abuf0,
> uint8_t *dest,
> int dstW, int uvalpha, int dstFormat, int flags, int y);
theres a check for uvalpha < 2048 and interpolation in there
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Democracy is the form of government in which you can choose your dictator
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100115/e98baa04/attachment.pgp>
More information about the ffmpeg-devel
mailing list