Browse Source

swscale/output: add XV48 output support

Signed-off-by: James Almer <jamrial@gmail.com>
James Almer 4 months ago
parent
commit
a67ba3c132

+ 24 - 13
libswscale/output.c

@@ -2577,7 +2577,8 @@ yuv2ayuv64_X_c(SwsInternal *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 is_be)
+               const int16_t **_alpSrc, uint8_t *dest, int dstW, int y,
+               int A_offset, int Y_offset, int U_offset, int V_offset, int is_be)
 {
     const int32_t **lumSrc  = (const int32_t **) _lumSrc,
                   **chrUSrc = (const int32_t **) _chrUSrc,
@@ -2612,20 +2613,19 @@ yuv2ayuv64_X_c(SwsInternal *c, const int16_t *lumFilter,
         Y = 0x8000 + av_clip_int16(Y >> 15);
         U = 0x8000 + av_clip_int16(U >> 15);
         V = 0x8000 + av_clip_int16(V >> 15);
-        A = 0x8000 + av_clip_int16(A >> 15);
+        if (hasAlpha)
+            A = 0x8000 + av_clip_int16(A >> 15);
 
-        output_pixels(dest + 8 * i, hasAlpha ? A : 65535);
-        output_pixels(dest + 8 * i + 2, Y);
-        output_pixels(dest + 8 * i + 4, U);
-        output_pixels(dest + 8 * i + 6, V);
+        output_pixels(dest + 8 * i + A_offset, hasAlpha ? A : 65535);
+        output_pixels(dest + 8 * i + Y_offset, Y);
+        output_pixels(dest + 8 * i + U_offset, U);
+        output_pixels(dest + 8 * i + V_offset, V);
     }
 }
 
-#undef output_pixels
-
-#define YUV2AYUV64(BE_LE, is_be) \
+#define YUV2AYUV64(pixfmt, BE_LE, A, Y, U, V, is_be) \
 static void \
-yuv2ayuv64 ## BE_LE ##_X_c(SwsInternal *c, const int16_t *lumFilter, \
+yuv2 ## pixfmt ## BE_LE ##_X_c(SwsInternal *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, \
@@ -2633,11 +2633,16 @@ yuv2ayuv64 ## BE_LE ##_X_c(SwsInternal *c, const int16_t *lumFilter, \
 { \
     yuv2ayuv64_X_c(c, lumFilter, lumSrc, lumFilterSize, \
                    chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
-                   alpSrc, dest, dstW, y, is_be); \
+                   alpSrc, dest, dstW, y, A, Y, U, V, is_be); \
 }
 
-YUV2AYUV64(le, 0)
-YUV2AYUV64(be, 1)
+YUV2AYUV64(ayuv64, le, 0, 2, 4, 6, 0)
+YUV2AYUV64(ayuv64, be, 0, 2, 4, 6, 1)
+
+YUV2AYUV64(xv48, le, 6, 2, 0, 4, 0)
+YUV2AYUV64(xv48, be, 6, 2, 0, 4, 1)
+
+#undef output_pixels
 
 static av_always_inline void
 yuv2v30_X_c_template(SwsInternal *c, const int16_t *lumFilter,
@@ -3692,6 +3697,12 @@ av_cold void ff_sws_init_output_funcs(SwsInternal *c,
     case AV_PIX_FMT_XV36BE:
         *yuv2packedX = yuv2xv36be_X_c;
         break;
+    case AV_PIX_FMT_XV48LE:
+        *yuv2packedX = yuv2xv48le_X_c;
+        break;
+    case AV_PIX_FMT_XV48BE:
+        *yuv2packedX = yuv2xv48be_X_c;
+        break;
     case AV_PIX_FMT_Y210LE:
         *yuv2packedX = yuv2y210le_X_c;
         break;

+ 2 - 2
libswscale/utils.c

@@ -277,8 +277,8 @@ static const FormatEntry format_entries[] = {
     [AV_PIX_FMT_XV30LE]      = { 1, 1 },
     [AV_PIX_FMT_XV36LE]      = { 1, 1 },
     [AV_PIX_FMT_XV36BE]      = { 1, 1 },
-    [AV_PIX_FMT_XV48LE]      = { 1, 0 },
-    [AV_PIX_FMT_XV48BE]      = { 1, 0 },
+    [AV_PIX_FMT_XV48LE]      = { 1, 1 },
+    [AV_PIX_FMT_XV48BE]      = { 1, 1 },
     [AV_PIX_FMT_AYUV]        = { 1, 1 },
     [AV_PIX_FMT_UYVA]        = { 1, 1 },
     [AV_PIX_FMT_VYU444]      = { 1, 1 },

+ 1 - 1
libswscale/version.h

@@ -29,7 +29,7 @@
 #include "version_major.h"
 
 #define LIBSWSCALE_VERSION_MINOR   9
-#define LIBSWSCALE_VERSION_MICRO 100
+#define LIBSWSCALE_VERSION_MICRO 101
 
 #define LIBSWSCALE_VERSION_INT  AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
                                                LIBSWSCALE_VERSION_MINOR, \

+ 1 - 0
tests/ref/fate/filter-pixdesc-xv48be

@@ -0,0 +1 @@
+pixdesc-xv48be      9d848c07ad49d025b9d1421b906ee191

+ 1 - 0
tests/ref/fate/filter-pixdesc-xv48le

@@ -0,0 +1 @@
+pixdesc-xv48le      35c1874574e1cf438ea3e97ef2a5a85e

+ 2 - 0
tests/ref/fate/filter-pixfmts-copy

@@ -109,6 +109,8 @@ x2rgb10le           c1e3ac21be04a16bb157b22784524520
 xv30le              7dfdd664a9792bb06a19a63353828da0
 xv36be              9f556ee59a672fd8725f0bb36ce3e4b0
 xv36le              e08dcbde02f1c28a3554f372ad1278e2
+xv48be              ce34993b4b4411bba1d852b9b86aa39e
+xv48le              30b5271d569d1ad6aba916fa5cdf82bd
 xyz12be             a1ef56bf746d71f59669c28e48fc8450
 xyz12le             831ff03c1ba4ef19374686f16a064d8c
 y210le              04e9487b6cce38e7531437e946cdd586

+ 2 - 0
tests/ref/fate/filter-pixfmts-crop

@@ -106,6 +106,8 @@ x2rgb10le           f4265aca7a67dbfa9354370098ca6f33
 xv30le              7e2350aea136c6fb76dae54e9d3fe1f8
 xv36be              23b6f253fcb375e4145cfcb562268c5f
 xv36le              778286003497f92b84d0bd8258d6b85d
+xv48be              c90889b2cf54cc78bd58e8c47d4eb791
+xv48le              60d81aa388fd40e5bf8aa3323bc4e60f
 xyz12be             cb4571f9aaa7b59f999ef327276104b7
 xyz12le             cd6aae8d26b18bdb4b9d068586276d91
 ya16be              a3d18014454942a96f15a49947c0c55d

+ 2 - 0
tests/ref/fate/filter-pixfmts-field

@@ -109,6 +109,8 @@ x2rgb10le           a18bc4ae5274e0a8cca9137ecd50c677
 xv30le              a8e8bfb66178ad5cbef5c82cedc1d3da
 xv36be              bcc7bda2d0a5d43db4464af6a4cb5d65
 xv36le              ba99f258370f2a56993e8760e6b30194
+xv48be              2abcd986a34789ba4310be3969020d0d
+xv48le              90591fca801a6d0ee3fb19bf3c8587f8
 xyz12be             d2fa69ec91d3ed862f2dac3f8e7a3437
 xyz12le             02bccd5e0b6824779a1f848b0ea3e3b5
 y210le              4c2fba1dc40322584977d15dd07c9146

+ 2 - 0
tests/ref/fate/filter-pixfmts-fieldorder

@@ -98,6 +98,8 @@ x2rgb10le           cdf6a9e8a8d081aa768c6ae2e6221676
 xv30le              8d1921d4a210d8107c20a805cb9a8117
 xv36be              962386c88268f4382004c3a7a82c5eb8
 xv36le              bcceffc985aaa8414c4b8072aa0889bd
+xv48be              4d6e4004b03767f12df8bb4e76c98ddf
+xv48le              f1b19076ff69cb8d587454615015297a
 xyz12be             15f5cda71de5fef9cec5e75e3833b6bc
 xyz12le             7be6c8781f38c21a6b8f602f62ca31e6
 y210le              22b1a02a39c4b325726bf8793bf1e8f2

+ 2 - 0
tests/ref/fate/filter-pixfmts-hflip

@@ -106,6 +106,8 @@ x2rgb10le           d4a8189b65395a88d0a38a7053f3359f
 xv30le              7370eadd13a2fc79186443713a639332
 xv36be              98f578df965eed369f46cb135e2d1345
 xv36le              e478b4b54698beb3ce1b9a2dd691d544
+xv48be              e030a2c7b1b600cfacb691b6e90c2e3d
+xv48le              d2fd726fcd96a696ea67cb6281c45b6b
 xyz12be             25f90259ff8a226befdaec3dfe82996e
 xyz12le             926c0791d59aaff61b2778e8ada3316d
 ya16be              d5b342355bdd9e3197e01b13b7c6301e

Some files were not shown because too many files changed in this diff