diff mbox series

[FFmpeg-devel] swscale/input: add VUYA input support

Message ID 20220804221819.3720-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel] swscale/input: add VUYA input support | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

James Almer Aug. 4, 2022, 10:18 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libswscale/input.c | 35 +++++++++++++++++++++++++++++++++++
 libswscale/utils.c |  1 +
 2 files changed, 36 insertions(+)

Comments

Philip Langdale Aug. 4, 2022, 11:45 p.m. UTC | #1
On Thu,  4 Aug 2022 19:18:19 -0300
James Almer <jamrial@gmail.com> wrote:

> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libswscale/input.c | 35 +++++++++++++++++++++++++++++++++++
>  libswscale/utils.c |  1 +
>  2 files changed, 36 insertions(+)

This appears to work fine, but in the testing process I've realised
that `ffmpeg` is not handling vaapi correctly and somehow requesting an
incompatible surface pool, so I did all my testing with mpv, where
everything works.

I tested by explicitly loading the lavfi format filter to convert to
yuva444p. Before your change, I got an error and after your change, mpv
gave me correct looking output.

--phil
diff mbox series

Patch

diff --git a/libswscale/input.c b/libswscale/input.c
index 750367b28b..68abc4d62c 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -650,6 +650,32 @@  static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *u
         AV_WN16(dst + i * 2, AV_RL16(src + i * 8));
 }
 
+static void read_vuya_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
+                           const uint8_t *unused1, int width, uint32_t *unused2)
+{
+    int i;
+    for (i = 0; i < width; i++) {
+        dstU[i] = src[i * 4 + 1];
+        dstV[i] = src[i * 4];
+    }
+}
+
+static void read_vuya_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
+                          uint32_t *unused2)
+{
+    int i;
+    for (i = 0; i < width; i++)
+        dst[i] = src[i * 4 + 2];
+}
+
+static void read_vuya_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
+                          uint32_t *unused2)
+{
+    int i;
+    for (i = 0; i < width; i++)
+        dst[i] = src[i * 4 + 3];
+}
+
 /* This is almost identical to the previous, end exists only because
  * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
 static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,  int width,
@@ -1229,6 +1255,9 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
         c->chrToYV12 = bswap16UV_c;
         break;
 #endif
+    case AV_PIX_FMT_VUYA:
+        c->chrToYV12 = read_vuya_UV_c;
+        break;
     case AV_PIX_FMT_AYUV64LE:
         c->chrToYV12 = read_ayuv64le_UV_c;
         break;
@@ -1591,6 +1620,9 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_YA16BE:
         c->lumToYV12 = read_ya16be_gray_c;
         break;
+    case AV_PIX_FMT_VUYA:
+        c->lumToYV12 = read_vuya_Y_c;
+        break;
     case AV_PIX_FMT_AYUV64LE:
         c->lumToYV12 = read_ayuv64le_Y_c;
         break;
@@ -1746,6 +1778,9 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
         case AV_PIX_FMT_YA16BE:
             c->alpToYV12 = read_ya16be_alpha_c;
             break;
+        case AV_PIX_FMT_VUYA:
+            c->alpToYV12 = read_vuya_A_c;
+            break;
         case AV_PIX_FMT_AYUV64LE:
             c->alpToYV12 = read_ayuv64le_A_c;
             break;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index c0504a6dfc..bc3d1c955c 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -258,6 +258,7 @@  static const FormatEntry format_entries[] = {
     [AV_PIX_FMT_P416BE]      = { 1, 1 },
     [AV_PIX_FMT_P416LE]      = { 1, 1 },
     [AV_PIX_FMT_NV16]        = { 1, 1 },
+    [AV_PIX_FMT_VUYA]        = { 1, 0 },
 };
 
 int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos,