提交 d4956b0b 编写于 作者: M Michael Niedermayer

sws/input: replace hardcoded rgb2yuv coefficients by table

Signed-off-by: NMichael Niedermayer <michaelni@gmx.at>
上级 41ebb645
此差异已折叠。
......@@ -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] =
......
......@@ -360,6 +360,16 @@ typedef struct SwsContext {
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];
int32_t input_rgb2yuv_table[16]; // 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
int *dither_error[4];
......@@ -489,9 +499,9 @@ typedef struct SwsContext {
* internally to Y/UV.
*/
/** @{ */
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);
/** @} */
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册