diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-06-04 06:31:35 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-06-04 06:35:17 +0200 |
commit | 87f40364d1a22aff5c9c245fa4ad07275c954248 (patch) | |
tree | 4aec0853f83ac15ce8f299631505c145f48fe71e /libswscale/swscale_template.c | |
parent | e4e2db9c74a10b2342297489edc00e99b10d5eb3 (diff) | |
parent | dc6632f1195c929a87ddf1b02d12b681c6de79ad (diff) | |
download | ffmpeg-87f40364d1a22aff5c9c245fa4ad07275c954248.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (21 commits)
build: simplify commands for clean target
swscale: split swscale.c in unscaled and generic conversion routines.
swscale: cosmetics.
swscale: integrate (literally) swscale_template.c in swscale.c.
swscale: split out x86/swscale_template.c from swscale.c.
swscale: enable hScale_altivec_real.
swscale: split out ppc _template.c files from main swscale.c.
swscale: remove indirections in ppc/swscale_template.c.
swscale: split out unscaled altivec YUV converters in their own file.
mpegvideoenc: fix multislice fate tests with threading disabled.
mpegts: Wrap #ifdef DEBUG and av_hex_dump_log() combination in a macro.
build: Simplify texi2html invocation through the --output option.
Mark some variables with av_unused
Replace avcodec_get_pix_fmt_name() by av_get_pix_fmt_name().
svq3: Check negative mb_type to fix potential crash.
svq3: Move svq3-specific fields to their own context.
rawdec: initialize return value to 0.
Remove unused get_psnr() prototype
rawdec: don't leak option strings.
bktr: get default framerate from video standard.
...
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswscale/swscale_template.c')
-rw-r--r-- | libswscale/swscale_template.c | 243 |
1 files changed, 0 insertions, 243 deletions
diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c index 58e05ac7b3..9ae9fc771c 100644 --- a/libswscale/swscale_template.c +++ b/libswscale/swscale_template.c @@ -242,93 +242,6 @@ static inline void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV, nvXXtoUV_c(dstV, dstU, src1, width); } -static inline void bgr24ToY_c(int16_t *dst, const uint8_t *src, - int width, uint32_t *unused) -{ - int i; - for (i=0; i<width; i++) { - int b= src[i*3+0]; - int g= src[i*3+1]; - int r= src[i*3+2]; - - dst[i]= ((RY*r + GY*g + BY*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6)); - } -} - -static inline void bgr24ToUV_c(int16_t *dstU, int16_t *dstV, const uint8_t *src1, - const uint8_t *src2, int width, uint32_t *unused) -{ - int i; - for (i=0; i<width; i++) { - int b= src1[3*i + 0]; - int g= src1[3*i + 1]; - int r= src1[3*i + 2]; - - dstU[i]= (RU*r + GU*g + BU*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6); - dstV[i]= (RV*r + GV*g + BV*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6); - } - assert(src1 == src2); -} - -static inline void bgr24ToUV_half_c(int16_t *dstU, int16_t *dstV, const uint8_t *src1, - const uint8_t *src2, int width, uint32_t *unused) -{ - int i; - for (i=0; i<width; i++) { - int b= src1[6*i + 0] + src1[6*i + 3]; - int g= src1[6*i + 1] + src1[6*i + 4]; - int r= src1[6*i + 2] + src1[6*i + 5]; - - dstU[i]= (RU*r + GU*g + BU*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5); - dstV[i]= (RV*r + GV*g + BV*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5); - } - assert(src1 == src2); -} - -static inline void rgb24ToY_c(int16_t *dst, const uint8_t *src, int width, - uint32_t *unused) -{ - int i; - for (i=0; i<width; i++) { - int r= src[i*3+0]; - int g= src[i*3+1]; - int b= src[i*3+2]; - - dst[i]= ((RY*r + GY*g + BY*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6)); - } -} - -static inline void rgb24ToUV_c(int16_t *dstU, int16_t *dstV, const uint8_t *src1, - const uint8_t *src2, int width, uint32_t *unused) -{ - int i; - assert(src1==src2); - for (i=0; i<width; i++) { - int r= src1[3*i + 0]; - int g= src1[3*i + 1]; - int b= src1[3*i + 2]; - - dstU[i]= (RU*r + GU*g + BU*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6); - dstV[i]= (RV*r + GV*g + BV*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6); - } -} - -static inline void rgb24ToUV_half_c(int16_t *dstU, int16_t *dstV, const uint8_t *src1, - const uint8_t *src2, int width, uint32_t *unused) -{ - int i; - assert(src1==src2); - for (i=0; i<width; i++) { - int r= src1[6*i + 0] + src1[6*i + 3]; - int g= src1[6*i + 1] + src1[6*i + 4]; - int b= src1[6*i + 2] + src1[6*i + 5]; - - dstU[i]= (RU*r + GU*g + BU*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5); - dstV[i]= (RV*r + GV*g + BV*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5); - } -} - - // bilinear / bicubic scaling static inline void hScale_c(int16_t *dst, int dstW, const uint8_t *src, int srcW, int xInc, @@ -349,162 +262,6 @@ static inline void hScale_c(int16_t *dst, int dstW, const uint8_t *src, } } -static inline void hScale16_c(int16_t *dst, int dstW, const uint16_t *src, int srcW, int xInc, - const int16_t *filter, const int16_t *filterPos, long filterSize, int shift) -{ - int i, j; - - for (i=0; i<dstW; i++) { - int srcPos= filterPos[i]; - int val=0; - for (j=0; j<filterSize; j++) { - val += ((int)src[srcPos + j])*filter[filterSize*i + j]; - } - dst[i] = FFMIN(val>>shift, (1<<15)-1); // the cubic equation does overflow ... - } -} - -static inline void hScale16X_c(int16_t *dst, int dstW, const uint16_t *src, int srcW, int xInc, - const int16_t *filter, const int16_t *filterPos, long filterSize, int shift) -{ - int i, j; - for (i=0; i<dstW; i++) { - int srcPos= filterPos[i]; - int val=0; - for (j=0; j<filterSize; j++) { - val += ((int)av_bswap16(src[srcPos + j]))*filter[filterSize*i + j]; - } - dst[i] = FFMIN(val>>shift, (1<<15)-1); // the cubic equation does overflow ... - } -} - -//FIXME all pal and rgb srcFormats could do this convertion as well -//FIXME all scalers more complex than bilinear could do half of this transform -static void chrRangeToJpeg_c(int16_t *dstU, int16_t *dstV, int width) -{ - int i; - for (i = 0; i < width; i++) { - dstU[i] = (FFMIN(dstU[i],30775)*4663 - 9289992)>>12; //-264 - dstV[i] = (FFMIN(dstV[i],30775)*4663 - 9289992)>>12; //-264 - } -} -static void chrRangeFromJpeg_c(int16_t *dstU, int16_t *dstV, int width) -{ - int i; - for (i = 0; i < width; i++) { - dstU[i] = (dstU[i]*1799 + 4081085)>>11; //1469 - dstV[i] = (dstV[i]*1799 + 4081085)>>11; //1469 - } -} -static void lumRangeToJpeg_c(int16_t *dst, int width) -{ - int i; - for (i = 0; i < width; i++) - dst[i] = (FFMIN(dst[i],30189)*19077 - 39057361)>>14; -} -static void lumRangeFromJpeg_c(int16_t *dst, int width) -{ - int i; - for (i = 0; i < width; i++) - dst[i] = (dst[i]*14071 + 33561947)>>14; -} - -static inline void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, - const uint8_t *src, int srcW, int xInc) -{ - int i; - unsigned int xpos=0; - for (i=0;i<dstWidth;i++) { - register unsigned int xx=xpos>>16; - register unsigned int xalpha=(xpos&0xFFFF)>>9; - dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha; - xpos+=xInc; - } - for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) - dst[i] = src[srcW-1]*128; -} - - // *** horizontal scale Y line to temp buffer -static inline void hyscale_c(SwsContext *c, uint16_t *dst, int dstWidth, - const uint8_t *src, int srcW, int xInc, - const int16_t *hLumFilter, - const int16_t *hLumFilterPos, int hLumFilterSize, - uint8_t *formatConvBuffer, - uint32_t *pal, int isAlpha) -{ - void (*toYV12)(uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12; - void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange; - - src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset; - - if (toYV12) { - toYV12(formatConvBuffer, src, srcW, pal); - src= formatConvBuffer; - } - - if (c->hScale16) { - int shift= isAnyRGB(c->srcFormat) || c->srcFormat==PIX_FMT_PAL8 ? 13 : av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; - c->hScale16(dst, dstWidth, (const uint16_t*)src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize, shift); - } else if (!c->hyscale_fast) { - c->hScale(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); - } else { // fast bilinear upscale / crap downscale - c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc); - } - - if (convertRange) - convertRange(dst, dstWidth); -} - -static inline void 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) -{ - int i; - unsigned int xpos=0; - for (i=0;i<dstWidth;i++) { - register unsigned int xx=xpos>>16; - register unsigned int xalpha=(xpos&0xFFFF)>>9; - dst1[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha); - dst2[i]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha); - xpos+=xInc; - } - for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) { - dst1[i] = src1[srcW-1]*128; - dst2[i] = src2[srcW-1]*128; - } -} - -inline static void hcscale_c(SwsContext *c, uint16_t *dst1, uint16_t *dst2, int dstWidth, - const uint8_t *src1, const uint8_t *src2, - int srcW, int xInc, const int16_t *hChrFilter, - const int16_t *hChrFilterPos, int hChrFilterSize, - uint8_t *formatConvBuffer, uint32_t *pal) -{ - - src1 += c->chrSrcOffset; - src2 += c->chrSrcOffset; - - if (c->chrToYV12) { - uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16); - c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal); - src1= formatConvBuffer; - src2= buf2; - } - - if (c->hScale16) { - int shift= isAnyRGB(c->srcFormat) || c->srcFormat==PIX_FMT_PAL8 ? 13 : av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; - c->hScale16(dst1, dstWidth, (const uint16_t*)src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize, shift); - c->hScale16(dst2, dstWidth, (const uint16_t*)src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize, shift); - } else if (!c->hcscale_fast) { - c->hScale(dst1, dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); - c->hScale(dst2, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); - } else { // fast bilinear upscale / crap downscale - c->hcscale_fast(c, dst1, dst2, dstWidth, src1, src2, srcW, xInc); - } - - if (c->chrConvertRange) - c->chrConvertRange(dst1, dst2, dstWidth); -} #define DEBUG_SWSCALE_BUFFERS 0 #define DEBUG_BUFFERS(...) if (DEBUG_SWSCALE_BUFFERS) av_log(c, AV_LOG_DEBUG, __VA_ARGS__) |