diff options
author | Manuel Stoeckl <code@mstoeckl.com> | 2021-09-24 19:09:15 -0400 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-09-26 16:26:10 +0200 |
commit | 32329397e289cc70550f110b72820ef3d219f7e0 (patch) | |
tree | 7439a04eff86627a2dafc457f0f83ae4e819bb42 /libswscale | |
parent | 0760d9153c39e95e175c434e56916e7d950a4f03 (diff) | |
download | ffmpeg-32329397e289cc70550f110b72820ef3d219f7e0.tar.gz |
swscale: add input/output support for X2BGR10LE
Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libswscale')
-rw-r--r-- | libswscale/input.c | 15 | ||||
-rw-r--r-- | libswscale/output.c | 9 | ||||
-rw-r--r-- | libswscale/utils.c | 1 | ||||
-rw-r--r-- | libswscale/yuv2rgb.c | 9 |
4 files changed, 28 insertions, 6 deletions
diff --git a/libswscale/input.c b/libswscale/input.c index b65aaf7c06..477dc3d6b2 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -245,7 +245,8 @@ rgb48funcs(bgr, BE, AV_PIX_FMT_BGR48BE) origin == AV_PIX_FMT_ARGB || \ origin == AV_PIX_FMT_ABGR) \ ? AV_RN32A(&src[(i) * 4]) \ - : ((origin == AV_PIX_FMT_X2RGB10LE) \ + : ((origin == AV_PIX_FMT_X2RGB10LE || \ + origin == AV_PIX_FMT_X2BGR10LE) \ ? AV_RL32(&src[(i) * 4]) \ : (isBE(origin) ? AV_RB16(&src[(i) * 2]) \ : AV_RL16(&src[(i) * 2])))) @@ -393,6 +394,7 @@ rgb16_32_wrapper(AV_PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, rgb16_32_wrapper(AV_PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7) rgb16_32_wrapper(AV_PIX_FMT_RGB444BE, rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4) rgb16_32_wrapper(AV_PIX_FMT_X2RGB10LE, rgb30le, 16, 6, 0, 0, 0x3FF00000, 0xFFC00, 0x3FF, 0, 0, 4, RGB2YUV_SHIFT + 6) +rgb16_32_wrapper(AV_PIX_FMT_X2BGR10LE, bgr30le, 0, 6, 16, 0, 0x3FF, 0xFFC00, 0x3FF00000, 4, 0, 0, RGB2YUV_SHIFT + 6) static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc, @@ -1344,6 +1346,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_X2RGB10LE: c->chrToYV12 = rgb30leToUV_half_c; break; + case AV_PIX_FMT_X2BGR10LE: + c->chrToYV12 = bgr30leToUV_half_c; + break; } } else { switch (srcFormat) { @@ -1428,6 +1433,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_X2RGB10LE: c->chrToYV12 = rgb30leToUV_c; break; + case AV_PIX_FMT_X2BGR10LE: + c->chrToYV12 = bgr30leToUV_c; + break; } } @@ -1708,7 +1716,10 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) c->lumToYV12 = y210le_Y_c; break; case AV_PIX_FMT_X2RGB10LE: - c->lumToYV12 =rgb30leToY_c; + c->lumToYV12 = rgb30leToY_c; + break; + case AV_PIX_FMT_X2BGR10LE: + c->lumToYV12 = bgr30leToY_c; break; } if (c->needAlpha) { diff --git a/libswscale/output.c b/libswscale/output.c index f1d9a61d53..58b10f85a5 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -1603,7 +1603,7 @@ yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2, dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1]; dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]; - } else if (target == AV_PIX_FMT_X2RGB10) { + } else if (target == AV_PIX_FMT_X2RGB10 || target == AV_PIX_FMT_X2BGR10) { uint32_t *dest = (uint32_t *) _dest; const uint32_t *r = (const uint32_t *) _r; const uint32_t *g = (const uint32_t *) _g; @@ -1848,6 +1848,7 @@ YUV2RGBWRAPPER(yuv2rgb,, 8, AV_PIX_FMT_RGB8, 0) YUV2RGBWRAPPER(yuv2rgb,, 4, AV_PIX_FMT_RGB4, 0) YUV2RGBWRAPPER(yuv2rgb,, 4b, AV_PIX_FMT_RGB4_BYTE, 0) YUV2RGBWRAPPER(yuv2, rgb, x2rgb10, AV_PIX_FMT_X2RGB10, 0) +YUV2RGBWRAPPER(yuv2, rgb, x2bgr10, AV_PIX_FMT_X2BGR10, 0) static av_always_inline void yuv2rgb_write_full(SwsContext *c, uint8_t *dest, int i, int Y, int A, int U, int V, @@ -3000,6 +3001,12 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, *yuv2packed2 = yuv2x2rgb10_2_c; *yuv2packedX = yuv2x2rgb10_X_c; break; + case AV_PIX_FMT_X2BGR10LE: + case AV_PIX_FMT_X2BGR10BE: + *yuv2packed1 = yuv2x2bgr10_1_c; + *yuv2packed2 = yuv2x2bgr10_2_c; + *yuv2packedX = yuv2x2bgr10_X_c; + break; } } switch (dstFormat) { diff --git a/libswscale/utils.c b/libswscale/utils.c index 6828a967f6..367b0ea501 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -267,6 +267,7 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_NV42] = { 1, 1 }, [AV_PIX_FMT_Y210LE] = { 1, 0 }, [AV_PIX_FMT_X2RGB10LE] = { 1, 1 }, + [AV_PIX_FMT_X2BGR10LE] = { 1, 1 }, }; int sws_isSupportedInput(enum AVPixelFormat pix_fmt) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index c2e8d4894c..353de2f822 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -783,6 +783,8 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], c->dstFormat == AV_PIX_FMT_RGB555LE || c->dstFormat == AV_PIX_FMT_RGB444BE || c->dstFormat == AV_PIX_FMT_RGB444LE || + c->dstFormat == AV_PIX_FMT_X2RGB10BE || + c->dstFormat == AV_PIX_FMT_X2RGB10LE || c->dstFormat == AV_PIX_FMT_RGB8 || c->dstFormat == AV_PIX_FMT_RGB4 || c->dstFormat == AV_PIX_FMT_RGB4_BYTE || @@ -793,7 +795,8 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], c->dstFormat == AV_PIX_FMT_NE(BGR565LE, BGR565BE) || c->dstFormat == AV_PIX_FMT_NE(BGR555LE, BGR555BE) || c->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE) || - c->dstFormat == AV_PIX_FMT_NE(X2RGB10LE, X2RGB10BE); + c->dstFormat == AV_PIX_FMT_NE(X2RGB10LE, X2RGB10BE) || + c->dstFormat == AV_PIX_FMT_NE(X2BGR10LE, X2BGR10BE); const int bpp = c->dstFormatBpp; uint8_t *y_table; uint16_t *y_table16; @@ -966,9 +969,9 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], fill_gv_table(c->table_gV, 1, cgv); break; case 30: - rbase = 20; + rbase = isRgb ? 20 : 0; gbase = 10; - bbase = 0; + bbase = isRgb ? 0 : 20; needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat); if (!needAlpha) abase = 30; |