diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-01-26 00:51:25 +0400 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2013-01-28 00:28:07 +0400 |
commit | 4eb93bed4e9b6daca7d3dd716a7517cd53dd5a95 (patch) | |
tree | 0c83aa474451868dd4aeb823b264eb606b5608a8 /libswscale/output.c | |
parent | 2026eb1408a718c37835eb4b258c63714ab3205e (diff) |
swscale: GBRP output support
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libswscale/output.c')
-rw-r--r-- | libswscale/output.c | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/libswscale/output.c b/libswscale/output.c index 4953290018..4ea2e4858a 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -1261,13 +1261,75 @@ YUV2RGBWRAPPERX(yuv2, rgb_full, xrgb32_full, AV_PIX_FMT_ARGB, 0) YUV2RGBWRAPPERX(yuv2, rgb_full, bgr24_full, AV_PIX_FMT_BGR24, 0) YUV2RGBWRAPPERX(yuv2, rgb_full, rgb24_full, AV_PIX_FMT_RGB24, 0) +static void +yuv2gbrp_full_X_c(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) +{ + int i; + int hasAlpha = 0; + + for (i = 0; i < dstW; i++) { + int j; + int Y = 1 << 9; + int U = (1 << 9) - (128 << 19); + int V = (1 << 9) - (128 << 19); + int R, G, B, A; + + for (j = 0; j < lumFilterSize; j++) + Y += lumSrc[j][i] * lumFilter[j]; + + for (j = 0; j < chrFilterSize; j++) { + U += chrUSrc[j][i] * chrFilter[j]; + V += chrVSrc[j][i] * chrFilter[j]; + } + + Y >>= 10; + U >>= 10; + V >>= 10; + + if (hasAlpha) { + A = 1 << 18; + + for (j = 0; j < lumFilterSize; j++) + A += alpSrc[j][i] * lumFilter[j]; + + A >>= 19; + + if (A & 0x100) + A = av_clip_uint8(A); + } + + Y -= c->yuv2rgb_y_offset; + Y *= c->yuv2rgb_y_coeff; + Y += 1 << 21; + R = Y + V * c->yuv2rgb_v2r_coeff; + G = Y + V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; + B = Y + U * c->yuv2rgb_u2b_coeff; + + if ((R | G | B) & 0xC0000000) { + R = av_clip_uintp2(R, 30); + G = av_clip_uintp2(G, 30); + B = av_clip_uintp2(B, 30); + } + + dest[0][i] = G >> 22; + dest[1][i] = B >> 22; + dest[2][i] = R >> 22; + } +} + av_cold 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) + yuv2packedX_fn *yuv2packedX, + yuv2anyX_fn *yuv2anyX) { enum AVPixelFormat dstFormat = c->dstFormat; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat); @@ -1354,6 +1416,9 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, case AV_PIX_FMT_BGR24: *yuv2packedX = yuv2bgr24_full_X_c; break; + case AV_PIX_FMT_GBRP: + *yuv2anyX = yuv2gbrp_full_X_c; + break; } } else { switch (dstFormat) { |