123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888 |
- #ifndef SWSCALE_SWSCALE_INTERNAL_H
- #define SWSCALE_SWSCALE_INTERNAL_H
- #include "config.h"
- #if HAVE_ALTIVEC_H
- #include <altivec.h>
- #endif
- #include "version.h"
- #include "libavutil/avassert.h"
- #include "libavutil/avutil.h"
- #include "libavutil/common.h"
- #include "libavutil/intreadwrite.h"
- #include "libavutil/log.h"
- #include "libavutil/pixfmt.h"
- #include "libavutil/pixdesc.h"
- #define STR(s) AV_TOSTRING(s)
- #define YUVRGB_TABLE_HEADROOM 128
- #define MAX_FILTER_SIZE SWS_MAX_FILTER_SIZE
- #define DITHER1XBPP
- #if HAVE_BIGENDIAN
- #define ALT32_CORR (-1)
- #else
- #define ALT32_CORR 1
- #endif
- #if ARCH_X86_64
- # define APCK_PTR2 8
- # define APCK_COEF 16
- # define APCK_SIZE 24
- #else
- # define APCK_PTR2 4
- # define APCK_COEF 8
- # define APCK_SIZE 16
- #endif
- struct SwsContext;
- typedef enum SwsDither {
- SWS_DITHER_NONE = 0,
- SWS_DITHER_AUTO,
- SWS_DITHER_BAYER,
- SWS_DITHER_ED,
- SWS_DITHER_A_DITHER,
- SWS_DITHER_X_DITHER,
- NB_SWS_DITHER,
- } SwsDither;
- typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[]);
- typedef void (*yuv2planar1_fn)(const int16_t *src, uint8_t *dest, int dstW,
- const uint8_t *dither, int offset);
- typedef void (*yuv2planarX_fn)(const int16_t *filter, int filterSize,
- const int16_t **src, uint8_t *dest, int dstW,
- const uint8_t *dither, int offset);
- typedef 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);
- typedef 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);
- typedef 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);
- typedef 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);
- typedef void (*yuv2anyX_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);
- typedef struct SwsContext {
-
- const AVClass *av_class;
-
- SwsFunc swscale;
- int srcW;
- int srcH;
- int dstH;
- int chrSrcW;
- int chrSrcH;
- int chrDstW;
- int chrDstH;
- int lumXInc, chrXInc;
- int lumYInc, chrYInc;
- enum AVPixelFormat dstFormat;
- enum AVPixelFormat srcFormat;
- int dstFormatBpp;
- int srcFormatBpp;
- int dstBpc, srcBpc;
- int chrSrcHSubSample;
- int chrSrcVSubSample;
- int chrDstHSubSample;
- int chrDstVSubSample;
- int vChrDrop;
- int sliceDir;
- double param[2];
- uint32_t pal_yuv[256];
- uint32_t pal_rgb[256];
-
-
- int16_t **lumPixBuf;
- int16_t **chrUPixBuf;
- int16_t **chrVPixBuf;
- int16_t **alpPixBuf;
- int vLumBufSize;
- int vChrBufSize;
- int lastInLumBuf;
- int lastInChrBuf;
- int lumBufIndex;
- int chrBufIndex;
-
- uint8_t *formatConvBuffer;
-
-
- int16_t *hLumFilter;
- int16_t *hChrFilter;
- int16_t *vLumFilter;
- int16_t *vChrFilter;
- int32_t *hLumFilterPos;
- int32_t *hChrFilterPos;
- int32_t *vLumFilterPos;
- int32_t *vChrFilterPos;
- int hLumFilterSize;
- int hChrFilterSize;
- int vLumFilterSize;
- int vChrFilterSize;
-
- int lumMmxextFilterCodeSize;
- int chrMmxextFilterCodeSize;
- uint8_t *lumMmxextFilterCode;
- uint8_t *chrMmxextFilterCode;
- int canMMXEXTBeUsed;
- int dstY;
- int flags;
- void *yuvTable;
-
-
- DECLARE_ALIGNED(16, int, table_gV)[256 + 2*YUVRGB_TABLE_HEADROOM];
- 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];
- DECLARE_ALIGNED(16, int32_t, input_rgb2yuv_table)[16+40*4];
- #define RY_IDX 0
- #define GY_IDX 1
- #define BY_IDX 2
- #define RU_IDX 3
- #define GU_IDX 4
- #define BU_IDX 5
- #define RV_IDX 6
- #define GV_IDX 7
- #define BV_IDX 8
- #define RGB2YUV_SHIFT 15
- int *dither_error[4];
-
- int contrast, brightness, saturation;
- int srcColorspaceTable[4];
- int dstColorspaceTable[4];
- int srcRange;
- int dstRange;
- 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;
- #define RED_DITHER "0*8"
- #define GREEN_DITHER "1*8"
- #define BLUE_DITHER "2*8"
- #define Y_COEFF "3*8"
- #define VR_COEFF "4*8"
- #define UB_COEFF "5*8"
- #define VG_COEFF "6*8"
- #define UG_COEFF "7*8"
- #define Y_OFFSET "8*8"
- #define U_OFFSET "9*8"
- #define V_OFFSET "10*8"
- #define LUM_MMX_FILTER_OFFSET "11*8"
- #define CHR_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)
- #define DSTW_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2"
- #define ESP_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+8"
- #define VROUNDER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+16"
- #define U_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+24"
- #define V_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+32"
- #define Y_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+40"
- #define ALP_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+48"
- #define UV_OFF_PX "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+48"
- #define UV_OFF_BYTE "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+56"
- #define DITHER16 "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+64"
- #define DITHER32 "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+80"
- #define DITHER32_INT (11*8+4*4*MAX_FILTER_SIZE*3+80)
- 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);
- int32_t lumMmxFilter[4 * MAX_FILTER_SIZE];
- int32_t chrMmxFilter[4 * MAX_FILTER_SIZE];
- int dstW;
- 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);
- int32_t alpMmxFilter[4 * MAX_FILTER_SIZE];
-
-
-
- DECLARE_ALIGNED(8, ptrdiff_t, uv_off);
- DECLARE_ALIGNED(8, ptrdiff_t, uv_offx2);
- DECLARE_ALIGNED(8, uint16_t, dither16)[8];
- DECLARE_ALIGNED(8, uint32_t, dither32)[8];
- const uint8_t *chrDither8, *lumDither8;
- #if HAVE_ALTIVEC
- vector signed short CY;
- vector signed short CRV;
- vector signed short CBU;
- vector signed short CGU;
- vector signed short CGV;
- vector signed short OY;
- vector unsigned short CSHIFT;
- vector signed short *vYCoeffsBank, *vCCoeffsBank;
- #endif
- int use_mmx_vfilter;
- #define XYZ_GAMMA (2.6f)
- #define RGB_GAMMA (2.2f)
- 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);
-
- void (*alpToYV12)(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3,
- int width, uint32_t *pal);
-
- 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);
-
-
- void (*readLumPlanar)(uint8_t *dst, const uint8_t *src[4], int width, int32_t *rgb2yuv);
- 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);
- 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);
- void (*hcScale)(struct SwsContext *c, int16_t *dst, int dstW,
- const uint8_t *src, const int16_t *filter,
- const int32_t *filterPos, int filterSize);
-
-
- void (*lumConvertRange)(int16_t *dst, int width);
-
- void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width);
- int needs_hcscale;
- SwsDither dither;
- } SwsContext;
- SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c);
- int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
- int fullRange, int brightness,
- int contrast, int saturation);
- void ff_yuv2rgb_init_tables_ppc(SwsContext *c, const int inv_table[4],
- int brightness, int contrast, int saturation);
- void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
- int lastInLumBuf, int lastInChrBuf);
- av_cold void ff_sws_init_range_convert(SwsContext *c);
- SwsFunc ff_yuv2rgb_init_x86(SwsContext *c);
- SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c);
- #if FF_API_SWS_FORMAT_NAME
- attribute_deprecated
- const char *sws_format_name(enum AVPixelFormat format);
- #endif
- static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return desc->comp[0].depth_minus1 == 15;
- }
- static av_always_inline int is9_OR_10BPS(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return desc->comp[0].depth_minus1 >= 8 && desc->comp[0].depth_minus1 <= 13;
- }
- #define isNBPS(x) is9_OR_10BPS(x)
- static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return desc->flags & AV_PIX_FMT_FLAG_BE;
- }
- static av_always_inline int isYUV(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;
- }
- static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return ((desc->flags & AV_PIX_FMT_FLAG_PLANAR) && isYUV(pix_fmt));
- }
- static av_always_inline int isRGB(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return (desc->flags & AV_PIX_FMT_FLAG_RGB);
- }
- #if 0
- #define isGray(x) \
- (!(av_pix_fmt_desc_get(x)->flags & AV_PIX_FMT_FLAG_PAL) && \
- av_pix_fmt_desc_get(x)->nb_components <= 2)
- #else
- #define isGray(x) \
- ((x) == AV_PIX_FMT_GRAY8 || \
- (x) == AV_PIX_FMT_Y400A || \
- (x) == AV_PIX_FMT_GRAY16BE || \
- (x) == AV_PIX_FMT_GRAY16LE)
- #endif
- #define isRGBinInt(x) \
- ( \
- (x) == AV_PIX_FMT_RGB48BE || \
- (x) == AV_PIX_FMT_RGB48LE || \
- (x) == AV_PIX_FMT_RGB32 || \
- (x) == AV_PIX_FMT_RGB32_1 || \
- (x) == AV_PIX_FMT_RGB24 || \
- (x) == AV_PIX_FMT_RGB565BE || \
- (x) == AV_PIX_FMT_RGB565LE || \
- (x) == AV_PIX_FMT_RGB555BE || \
- (x) == AV_PIX_FMT_RGB555LE || \
- (x) == AV_PIX_FMT_RGB444BE || \
- (x) == AV_PIX_FMT_RGB444LE || \
- (x) == AV_PIX_FMT_RGB8 || \
- (x) == AV_PIX_FMT_RGB4 || \
- (x) == AV_PIX_FMT_RGB4_BYTE || \
- (x) == AV_PIX_FMT_RGBA64BE || \
- (x) == AV_PIX_FMT_RGBA64LE || \
- (x) == AV_PIX_FMT_MONOBLACK || \
- (x) == AV_PIX_FMT_MONOWHITE \
- )
- #define isBGRinInt(x) \
- ( \
- (x) == AV_PIX_FMT_BGR48BE || \
- (x) == AV_PIX_FMT_BGR48LE || \
- (x) == AV_PIX_FMT_BGR32 || \
- (x) == AV_PIX_FMT_BGR32_1 || \
- (x) == AV_PIX_FMT_BGR24 || \
- (x) == AV_PIX_FMT_BGR565BE || \
- (x) == AV_PIX_FMT_BGR565LE || \
- (x) == AV_PIX_FMT_BGR555BE || \
- (x) == AV_PIX_FMT_BGR555LE || \
- (x) == AV_PIX_FMT_BGR444BE || \
- (x) == AV_PIX_FMT_BGR444LE || \
- (x) == AV_PIX_FMT_BGR8 || \
- (x) == AV_PIX_FMT_BGR4 || \
- (x) == AV_PIX_FMT_BGR4_BYTE || \
- (x) == AV_PIX_FMT_BGRA64BE || \
- (x) == AV_PIX_FMT_BGRA64LE || \
- (x) == AV_PIX_FMT_MONOBLACK || \
- (x) == AV_PIX_FMT_MONOWHITE \
- )
- #define isRGBinBytes(x) ( \
- (x) == AV_PIX_FMT_RGB48BE \
- || (x) == AV_PIX_FMT_RGB48LE \
- || (x) == AV_PIX_FMT_RGBA64BE \
- || (x) == AV_PIX_FMT_RGBA64LE \
- || (x) == AV_PIX_FMT_RGBA \
- || (x) == AV_PIX_FMT_ARGB \
- || (x) == AV_PIX_FMT_RGB24 \
- )
- #define isBGRinBytes(x) ( \
- (x) == AV_PIX_FMT_BGR48BE \
- || (x) == AV_PIX_FMT_BGR48LE \
- || (x) == AV_PIX_FMT_BGRA64BE \
- || (x) == AV_PIX_FMT_BGRA64LE \
- || (x) == AV_PIX_FMT_BGRA \
- || (x) == AV_PIX_FMT_ABGR \
- || (x) == AV_PIX_FMT_BGR24 \
- )
- #define isBayer(x) ( \
- (x)==AV_PIX_FMT_BAYER_BGGR8 \
- || (x)==AV_PIX_FMT_BAYER_BGGR16LE \
- || (x)==AV_PIX_FMT_BAYER_BGGR16BE \
- || (x)==AV_PIX_FMT_BAYER_RGGB8 \
- || (x)==AV_PIX_FMT_BAYER_RGGB16LE \
- || (x)==AV_PIX_FMT_BAYER_RGGB16BE \
- || (x)==AV_PIX_FMT_BAYER_GBRG8 \
- || (x)==AV_PIX_FMT_BAYER_GBRG16LE \
- || (x)==AV_PIX_FMT_BAYER_GBRG16BE \
- || (x)==AV_PIX_FMT_BAYER_GRBG8 \
- || (x)==AV_PIX_FMT_BAYER_GRBG16LE \
- || (x)==AV_PIX_FMT_BAYER_GRBG16BE \
- )
- #define isAnyRGB(x) \
- ( \
- isBayer(x) || \
- isRGBinInt(x) || \
- isBGRinInt(x) || \
- isRGB(x) \
- )
- static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- if (pix_fmt == AV_PIX_FMT_PAL8)
- return 1;
- return desc->flags & AV_PIX_FMT_FLAG_ALPHA;
- }
- #if 1
- #define isPacked(x) ( \
- (x)==AV_PIX_FMT_PAL8 \
- || (x)==AV_PIX_FMT_YUYV422 \
- || (x)==AV_PIX_FMT_YVYU422 \
- || (x)==AV_PIX_FMT_UYVY422 \
- || (x)==AV_PIX_FMT_Y400A \
- || isRGBinInt(x) \
- || isBGRinInt(x) \
- )
- #else
- static av_always_inline int isPacked(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return ((desc->nb_components >= 2 && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) ||
- pix_fmt == AV_PIX_FMT_PAL8);
- }
- #endif
- static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return (desc->nb_components >= 2 && (desc->flags & AV_PIX_FMT_FLAG_PLANAR));
- }
- static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return ((desc->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) == AV_PIX_FMT_FLAG_RGB);
- }
- static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return ((desc->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) ==
- (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB));
- }
- static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
- {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return (desc->flags & AV_PIX_FMT_FLAG_PAL) || (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL);
- }
- extern const uint64_t ff_dither4[2];
- extern const uint64_t ff_dither8[2];
- extern const uint8_t ff_dither_2x2_4[3][8];
- extern const uint8_t ff_dither_2x2_8[3][8];
- extern const uint8_t ff_dither_4x4_16[5][8];
- extern const uint8_t ff_dither_8x8_32[9][8];
- extern const uint8_t ff_dither_8x8_73[9][8];
- extern const uint8_t ff_dither_8x8_128[9][8];
- extern const uint8_t ff_dither_8x8_220[9][8];
- extern const int32_t ff_yuv2rgb_coeffs[8][4];
- extern const AVClass sws_context_class;
- void ff_get_unscaled_swscale(SwsContext *c);
- void ff_get_unscaled_swscale_ppc(SwsContext *c);
- void ff_get_unscaled_swscale_arm(SwsContext *c);
- SwsFunc ff_getSwsFunc(SwsContext *c);
- void ff_sws_init_input_funcs(SwsContext *c);
- void ff_sws_init_output_funcs(SwsContext *c,
- yuv2planar1_fn *yuv2plane1,
- yuv2planarX_fn *yuv2planeX,
- yuv2interleavedX_fn *yuv2nv12cX,
- yuv2packed1_fn *yuv2packed1,
- yuv2packed2_fn *yuv2packed2,
- yuv2packedX_fn *yuv2packedX,
- yuv2anyX_fn *yuv2anyX);
- void ff_sws_init_swscale_ppc(SwsContext *c);
- void ff_sws_init_swscale_x86(SwsContext *c);
- void ff_hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
- const uint8_t *src, int srcW, int xInc);
- void ff_hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2,
- int dstWidth, const uint8_t *src1,
- const uint8_t *src2, int srcW, int xInc);
- static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y,
- int alpha, int bits, const int big_endian)
- {
- int i, j;
- uint8_t *ptr = plane + stride * y;
- int v = alpha ? 0xFFFF>>(15-bits) : (1<<bits);
- for (i = 0; i < height; i++) {
- #define FILL(wfunc) \
- for (j = 0; j < width; j++) {\
- wfunc(ptr+2*j, v);\
- }
- if (big_endian) {
- FILL(AV_WB16);
- } else {
- FILL(AV_WL16);
- }
- ptr += stride;
- }
- }
- #endif
|