From f7813a5324be39d13ab536c245d15dfc602a7849 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 29 Dec 2013 12:19:38 +0000 Subject: basic type mechanism working --- ffmpeg/libswscale/swscale_internal.h | 124 +++++++++++++++++++++++------------ 1 file changed, 81 insertions(+), 43 deletions(-) (limited to 'ffmpeg/libswscale/swscale_internal.h') diff --git a/ffmpeg/libswscale/swscale_internal.h b/ffmpeg/libswscale/swscale_internal.h index 83d3a00..443615d 100644 --- a/ffmpeg/libswscale/swscale_internal.h +++ b/ffmpeg/libswscale/swscale_internal.h @@ -39,8 +39,6 @@ #define YUVRGB_TABLE_HEADROOM 128 -#define FAST_BGR2YV12 // use 7-bit instead of 15-bit coefficients - #define MAX_FILTER_SIZE 256 #define DITHER1XBPP @@ -63,6 +61,14 @@ struct SwsContext; +typedef enum SwsDither { + SWS_DITHER_NONE = 0, + SWS_DITHER_AUTO, + SWS_DITHER_BAYER, + SWS_DITHER_ED, + 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[]); @@ -268,7 +274,7 @@ typedef struct SwsContext { * Note that src, dst, srcStride, dstStride will be copied in the * sws_scale() wrapper so they can be freely modified here. */ - SwsFunc swScale; + SwsFunc swscale; int srcW; ///< Width of source luma/alpha planes. int srcH; ///< Height of source luma/alpha planes. int dstH; ///< Height of destination luma/alpha planes. @@ -356,10 +362,23 @@ typedef struct SwsContext { 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; // pointer to the yuv->rgb table start so it can be freed() + // alignment ensures the offset can be added in a single + // instruction on e.g. ARM + 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]; - int table_gV[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]; // This table can contain both C and SIMD formatted values, teh C vales are always at the XY_IDX points +#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]; @@ -371,6 +390,12 @@ typedef struct SwsContext { 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; @@ -464,7 +489,17 @@ typedef struct SwsContext { #endif int use_mmx_vfilter; - /* function pointers for swScale() */ +/* pre defined color-spaces gamma */ +#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]; + + /* function pointers for swscale() */ yuv2planar1_fn yuv2plane1; yuv2planarX_fn yuv2planeX; yuv2interleavedX_fn yuv2nv12cX; @@ -486,12 +521,13 @@ typedef struct SwsContext { /** * Functions to read planar input, such as planar RGB, and convert - * internally to Y/UV. + * internally to Y/UV/A. */ /** @{ */ - void (*readLumPlanar)(uint8_t *dst, const uint8_t *src[4], int width); + 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); + int width, int32_t *rgb2yuv); + void (*readAlpPlanar)(uint8_t *dst, const uint8_t *src[4], int width, int32_t *rgb2yuv); /** @} */ /** @@ -567,6 +603,8 @@ typedef struct SwsContext { void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width); int needs_hcscale; ///< Set if there are chroma planes to be converted. + + SwsDither dither; } SwsContext; //FIXME check init (where 0) @@ -574,17 +612,16 @@ 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 ff_yuv2rgb_init_tables_altivec(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); -SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c); +SwsFunc ff_yuv2rgb_init_x86(SwsContext *c); SwsFunc ff_yuv2rgb_init_vis(SwsContext *c); -SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c); -SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c); -void ff_bfin_get_unscaled_swscale(SwsContext *c); +SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c); +SwsFunc ff_yuv2rgb_init_bfin(SwsContext *c); #if FF_API_SWS_FORMAT_NAME /** @@ -614,33 +651,33 @@ 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 & PIX_FMT_BE; + 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 & PIX_FMT_RGB) && desc->nb_components >= 2; + 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 & PIX_FMT_PLANAR) && isYUV(pix_fmt)); + 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 & PIX_FMT_RGB); + return (desc->flags & AV_PIX_FMT_FLAG_RGB); } #if 0 // FIXME #define isGray(x) \ - (!(av_pix_fmt_desc_get(x)->flags & PIX_FMT_PAL) && \ + (!(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) \ @@ -716,23 +753,16 @@ static av_always_inline int isRGB(enum AVPixelFormat pix_fmt) ( \ isRGBinInt(x) || \ isBGRinInt(x) || \ - isRGB(x) || \ - (x)==AV_PIX_FMT_GBRP9LE || \ - (x)==AV_PIX_FMT_GBRP9BE || \ - (x)==AV_PIX_FMT_GBRP10LE || \ - (x)==AV_PIX_FMT_GBRP10BE || \ - (x)==AV_PIX_FMT_GBRP12LE || \ - (x)==AV_PIX_FMT_GBRP12BE || \ - (x)==AV_PIX_FMT_GBRP14LE || \ - (x)==AV_PIX_FMT_GBRP14BE || \ - (x)==AV_PIX_FMT_GBR24P \ + 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); - return desc->flags & PIX_FMT_ALPHA; + if (pix_fmt == AV_PIX_FMT_PAL8) + return 1; + return desc->flags & AV_PIX_FMT_FLAG_ALPHA; } #if 1 @@ -749,7 +779,7 @@ 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 & PIX_FMT_PLANAR)) || + return ((desc->nb_components >= 2 && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) || pix_fmt == AV_PIX_FMT_PAL8); } @@ -758,46 +788,54 @@ 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 & PIX_FMT_PLANAR)); + 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 & (PIX_FMT_PLANAR | PIX_FMT_RGB)) == PIX_FMT_RGB); + 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 & (PIX_FMT_PLANAR | PIX_FMT_RGB)) == - (PIX_FMT_PLANAR | PIX_FMT_RGB)); + 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 & PIX_FMT_PAL) || (desc->flags & PIX_FMT_PSEUDOPAL); + 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 dithers[8][8][8]; -extern const uint16_t dither_scale[15][16]; +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; /** - * Set c->swScale to an unscaled converter if one exists for the specific + * Set c->swscale to an unscaled converter if one exists for the specific * source and destination formats, bit depths, flags, etc. */ void ff_get_unscaled_swscale(SwsContext *c); - -void ff_swscale_get_unscaled_altivec(SwsContext *c); +void ff_get_unscaled_swscale_bfin(SwsContext *c); +void ff_get_unscaled_swscale_ppc(SwsContext *c); +void ff_get_unscaled_swscale_arm(SwsContext *c); /** * Return function pointer to fastest main scaler path function depending @@ -814,8 +852,8 @@ void ff_sws_init_output_funcs(SwsContext *c, yuv2packed2_fn *yuv2packed2, yuv2packedX_fn *yuv2packedX, yuv2anyX_fn *yuv2anyX); -void ff_sws_init_swScale_altivec(SwsContext *c); -void ff_sws_init_swScale_mmx(SwsContext *c); +void ff_sws_init_swscale_ppc(SwsContext *c); +void ff_sws_init_swscale_x86(SwsContext *c); static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y, int alpha, int bits, const int big_endian) -- cgit v1.2.3