diff mbox series

[FFmpeg-devel] swscale/output: add full chroma interpolation support for x2rgb10

Message ID 20241030152019.9494-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel] swscale/output: add full chroma interpolation support for x2rgb10 | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch

Commit Message

James Almer Oct. 30, 2024, 3:20 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libswscale/output.c                 | 25 +++++++++++++++++++++++++
 libswscale/utils.c                  |  4 +++-
 tests/ref/fate/filter-pixfmts-scale |  4 ++--
 3 files changed, 30 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libswscale/output.c b/libswscale/output.c
index 1923df20db..f49dc372a2 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -1970,6 +1970,18 @@  static av_always_inline void yuv2rgb_write_full(SwsInternal *c,
         dest[2] = R >> 22;
         dest[3] = hasAlpha ? A : 255;
         break;
+    case AV_PIX_FMT_X2RGB10LE:
+        R >>= 20;
+        G >>= 20;
+        B >>= 20;
+        AV_WL32(dest, (3U << 30) + (R << 20) + (G << 10) + B);
+        break;
+    case AV_PIX_FMT_X2BGR10LE:
+        R >>= 20;
+        G >>= 20;
+        B >>= 20;
+        AV_WL32(dest, (3U << 30) + (B << 20) + (G << 10) + R);
+        break;
     case AV_PIX_FMT_BGR4_BYTE:
     case AV_PIX_FMT_RGB4_BYTE:
     case AV_PIX_FMT_BGR8:
@@ -2242,6 +2254,9 @@  YUV2RGBWRAPPER(yuv2, rgb_full, rgb4_byte_full,  AV_PIX_FMT_RGB4_BYTE, 0)
 YUV2RGBWRAPPER(yuv2, rgb_full, bgr8_full,   AV_PIX_FMT_BGR8,  0)
 YUV2RGBWRAPPER(yuv2, rgb_full, rgb8_full,   AV_PIX_FMT_RGB8,  0)
 
+YUV2RGBWRAPPER(yuv2, rgb_full, x2rgb10_full, AV_PIX_FMT_X2RGB10LE,  0)
+YUV2RGBWRAPPER(yuv2, rgb_full, x2bgr10_full, AV_PIX_FMT_X2BGR10LE,  0)
+
 static void
 yuv2gbrp_full_X_c(SwsInternal *c, const int16_t *lumFilter,
                   const int16_t **lumSrc, int lumFilterSize,
@@ -3397,6 +3412,16 @@  av_cold void ff_sws_init_output_funcs(SwsInternal *c,
             *yuv2packed2 = yuv2rgb8_full_2_c;
             *yuv2packed1 = yuv2rgb8_full_1_c;
             break;
+        case AV_PIX_FMT_X2RGB10LE:
+            *yuv2packedX = yuv2x2rgb10_full_X_c;
+            *yuv2packed2 = yuv2x2rgb10_full_2_c;
+            *yuv2packed1 = yuv2x2rgb10_full_1_c;
+            break;
+        case AV_PIX_FMT_X2BGR10LE:
+            *yuv2packedX = yuv2x2bgr10_full_X_c;
+            *yuv2packed2 = yuv2x2bgr10_full_2_c;
+            *yuv2packed1 = yuv2x2bgr10_full_1_c;
+            break;
         case AV_PIX_FMT_GBRP:
         case AV_PIX_FMT_GBRP9BE:
         case AV_PIX_FMT_GBRP9LE:
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 1c3b4083df..8603f78dc9 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1517,7 +1517,9 @@  static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
         dstFormat != AV_PIX_FMT_BGR4_BYTE &&
         dstFormat != AV_PIX_FMT_RGB4_BYTE &&
         dstFormat != AV_PIX_FMT_BGR8 &&
-        dstFormat != AV_PIX_FMT_RGB8
+        dstFormat != AV_PIX_FMT_RGB8 &&
+        dstFormat != AV_PIX_FMT_X2RGB10LE &&
+        dstFormat != AV_PIX_FMT_X2BGR10LE
     ) {
         av_log(c, AV_LOG_WARNING,
                "full chroma interpolation for destination format '%s' not yet implemented\n",
diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale
index 8e5526935f..8f7f862d70 100644
--- a/tests/ref/fate/filter-pixfmts-scale
+++ b/tests/ref/fate/filter-pixfmts-scale
@@ -104,8 +104,8 @@  v30xle              8cba1fdc0ba2c39eb6fb5885dcf628a7
 vuya                ffa817e283bf6a0b6fba21b07523ccaa
 vuyx                a6ff68f46c6b4b7595ec91b2a497df8e
 vyu444              d663334119da56e36aca1e8e4eb29a39
-x2bgr10le           d57b9a99033cc7b65ddd111578f2d385
-x2rgb10le           d56bdb23fa6a8e12a0b4394987f89935
+x2bgr10le           94fcdae6bb03cc55675fec1f708ae765
+x2rgb10le           99ca41ff2365b1615c05f8d197471105
 xv30le              a2a351cbf936651b558abfc70a925057
 xv36be              4d084adca0228d7750d1e2e877e0d79b
 xv36le              de9c74e94dc19c828e1572aa283d8aca