diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-04-14 19:55:06 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-04-14 20:04:55 +0200 |
commit | d4956b0bfbf92a4301529b35096a03f16f355a1b (patch) | |
tree | e5d5e557051791ff9def2c67be19838ae55d3a27 /libswscale/swscale.c | |
parent | 41ebb64511dca3ac4ea27fcdca661fbe12f93b26 (diff) | |
download | ffmpeg-d4956b0bfbf92a4301529b35096a03f16f355a1b.tar.gz |
sws/input: replace hardcoded rgb2yuv coefficients by table
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswscale/swscale.c')
-rw-r--r-- | libswscale/swscale.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c index bb908191dc..0dcd39b74f 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -254,7 +254,7 @@ static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, toYV12(formatConvBuffer, src, src_in[1], src_in[2], srcW, pal); src = formatConvBuffer; } else if (c->readLumPlanar && !isAlpha) { - c->readLumPlanar(formatConvBuffer, src_in, srcW); + c->readLumPlanar(formatConvBuffer, src_in, srcW, c->input_rgb2yuv_table); src = formatConvBuffer; } @@ -307,7 +307,7 @@ static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, } else if (c->readChrPlanar) { uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16); - c->readChrPlanar(formatConvBuffer, buf2, src_in, srcW); + c->readChrPlanar(formatConvBuffer, buf2, src_in, srcW, c->input_rgb2yuv_table); src1 = formatConvBuffer; src2 = buf2; } @@ -383,6 +383,20 @@ static int swScale(SwsContext *c, const uint8_t *src[], int lastInLumBuf = c->lastInLumBuf; int lastInChrBuf = c->lastInChrBuf; + if (!usePal(c->srcFormat)) { + pal = c->input_rgb2yuv_table; +#define RGB2YUV_SHIFT 15 + pal[BY_IDX] = ((int)(0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)); + pal[BV_IDX] = (-(int)(0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)); + pal[BU_IDX] = ((int)(0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)); + pal[GY_IDX] = ((int)(0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)); + pal[GV_IDX] = (-(int)(0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)); + pal[GU_IDX] = (-(int)(0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)); + pal[RY_IDX] = ((int)(0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)); + pal[RV_IDX] = ((int)(0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)); + pal[RU_IDX] = (-(int)(0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)); + } + if (isPacked(c->srcFormat)) { src[0] = src[1] = |