diff mbox

[FFmpeg-devel,v2,3/3] swscale: Add swscale input support for Y210

Message ID 1568794854-6921-1-git-send-email-linjie.fu@intel.com
State Superseded
Headers show

Commit Message

Fu, Linjie Sept. 18, 2019, 8:20 a.m. UTC
Add swscale input support for Y210, output support and fate
test could be added later if there is requirement for software
CSC to this packed format.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libswscale/input.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 libswscale/utils.c |  2 ++
 2 files changed, 50 insertions(+)

Comments

Carl Eugen Hoyos Sept. 18, 2019, 8:44 a.m. UTC | #1
> Am 18.09.2019 um 10:20 schrieb Linjie Fu <linjie.fu@intel.com>:
> 
> Add swscale input support for Y210, output support and fate
> test could be added later if there is requirement for software
> CSC to this packed format.

Is the patch missing support for 16bit output or does the infrastructure not allow this?

Carl Eugen
Fu, Linjie Sept. 18, 2019, 9:12 a.m. UTC | #2
> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Carl Eugen Hoyos

> Sent: Wednesday, September 18, 2019 16:44

> To: FFmpeg development discussions and patches <ffmpeg-

> devel@ffmpeg.org>

> Subject: Re: [FFmpeg-devel] [PATCH, v2 3/3] swscale: Add swscale input

> support for Y210

> 

> 

> 

> > Am 18.09.2019 um 10:20 schrieb Linjie Fu <linjie.fu@intel.com>:

> >

> > Add swscale input support for Y210, output support and fate

> > test could be added later if there is requirement for software

> > CSC to this packed format.

> 

> Is the patch missing support for 16bit output or does the infrastructure not

> allow this?

> 


Verified with "-pix_fmt yuv420p16le", the output image is good as expected.

Verified with HEVC QSV decode + software CSC:
ffmpeg -hwaccel qsv -hwaccel_device /dev/dri/renderD128 -v verbose -c:v hevc_qsv -load_plugin hevc_hw -i ./Main_422_10_A_RExt_Sony_2.bin -vf hwdownload,format=y210le -pix_fmt yuv420p16le out.yuv

This v2 version  is for the missing chrToYV12/ lumToYV12 entry for y210.

- linjie
diff mbox

Patch

diff --git a/libswscale/input.c b/libswscale/input.c
index 73d1aa9..f02f24a 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -571,6 +571,42 @@  static void ayuvToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, con
     av_assert1(src1 == src2);
 }
 
+static void y210le_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++) {
+        AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> 6);
+        AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> 6);
+    }
+}
+
+static void y210be_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++) {
+        AV_WN16(dstU + i * 2, AV_RB16(src + i * 8 + 2) >> 6);
+        AV_WN16(dstV + i * 2, AV_RB16(src + i * 8 + 6) >> 6);
+    }
+}
+
+static void y210le_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++)
+        AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> 6);
+}
+
+static void y210be_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++)
+        AV_WN16(dst + i * 2 ,AV_RB16(src + i * 4) >> 6);
+}
+
 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
                        uint32_t *unused)
 {
@@ -1176,6 +1212,12 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_AYUV:
         c->chrToYV12 = ayuvToUV_c;
         break;
+    case AV_PIX_FMT_Y210LE:
+        c->chrToYV12 = y210le_UV_c;
+        break;
+    case AV_PIX_FMT_Y210BE:
+        c->chrToYV12 = y210be_UV_c;
+        break;
     }
     if (c->chrSrcHSubSample) {
         switch (srcFormat) {
@@ -1611,6 +1653,12 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_AYUV:
         c->lumToYV12 = ayuvToY_c;
         break;
+    case AV_PIX_FMT_Y210LE:
+        c->lumToYV12 = y210le_Y_c;
+        break;
+    case AV_PIX_FMT_Y210BE:
+        c->chrToYV12 = y210be_Y_c;
+        break;
     }
     if (c->needAlpha) {
         if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 1e12e21..ad5f669 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -266,6 +266,8 @@  static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
     [AV_PIX_FMT_YUVA444P12LE] = { 1, 1 },
     [AV_PIX_FMT_NV24]        = { 1, 1 },
     [AV_PIX_FMT_NV42]        = { 1, 1 },
+    [AV_PIX_FMT_Y210BE]      = { 1, 0 },
+    [AV_PIX_FMT_Y210LE]      = { 1, 0 },
     [AV_PIX_FMT_AYUV]        = { 1, 1 },
 };