diff mbox series

[FFmpeg-devel,1/2] lavc/qsvdec: add decode support for HEVC 4:2:2 8-bit and 10-bit

Message ID 1582596080-1035-1-git-send-email-linjie.fu@intel.com
State Superseded
Headers show
Series [FFmpeg-devel,1/2] lavc/qsvdec: add decode support for HEVC 4:2:2 8-bit and 10-bit
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Fu, Linjie Feb. 25, 2020, 2:01 a.m. UTC
Enables HEVC Range Extension decoding support for 4:2:2 8/10 bit
on ICL+ (gen11 +) platform.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libavcodec/qsv.c          | 12 ++++++++++++
 libavutil/hwcontext_qsv.c | 22 ++++++++++++++++++++++
 2 files changed, 34 insertions(+)

Comments

Mark Thompson Feb. 25, 2020, 10:59 p.m. UTC | #1
On 25/02/2020 02:01, Linjie Fu wrote:
> Enables HEVC Range Extension decoding support for 4:2:2 8/10 bit
> on ICL+ (gen11 +) platform.
> 
> Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> ---
>  libavcodec/qsv.c          | 12 ++++++++++++
>  libavutil/hwcontext_qsv.c | 22 ++++++++++++++++++++++
>  2 files changed, 34 insertions(+)

Should this be gated somehow to stop it being run on Windows?  There it will probably fail in some ugly way inside the D3D code which doesn't support YUYV formats.

Similarly, do you need a specific libva version or is that already implied by the libmfx version?

- Mark
Fu, Linjie Feb. 26, 2020, 8:39 a.m. UTC | #2
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Mark Thompson
> Sent: Wednesday, February 26, 2020 06:59
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] lavc/qsvdec: add decode support
> for HEVC 4:2:2 8-bit and 10-bit
> 
> On 25/02/2020 02:01, Linjie Fu wrote:
> > Enables HEVC Range Extension decoding support for 4:2:2 8/10 bit
> > on ICL+ (gen11 +) platform.
> >
> > Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> > ---
> >  libavcodec/qsv.c          | 12 ++++++++++++
> >  libavutil/hwcontext_qsv.c | 22 ++++++++++++++++++++++
> >  2 files changed, 34 insertions(+)
> 
> Should this be gated somehow to stop it being run on Windows?  There it will
> probably fail in some ugly way inside the D3D code which doesn't support
> YUYV formats.

Yes, thanks for pointing this out,  fixed and verified on windows, no crash observed anymore
in the D3D path for windows.

> Similarly, do you need a specific libva version or is that already implied by the
> libmfx version?

IMHO it's implied by libmfx version already.
A successfully built MSDK with API version > 1.27 should have supported VA_FOURCC_Y210 [1] in libva.

[1] https://github.com/Intel-Media-SDK/MediaSDK/blob/master/_studio/shared/src/libmfx_allocator_vaapi.cpp#L87

Thanks,

- Linjie
diff mbox series

Patch

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index db98c75..23504b5 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -195,6 +195,10 @@  enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc)
     case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
     case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
     case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
+    case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
+#if QSV_VERSION_ATLEAST(1, 27)
+    case MFX_FOURCC_Y210: return AV_PIX_FMT_Y210;
+#endif
     }
     return AV_PIX_FMT_NONE;
 }
@@ -211,6 +215,14 @@  int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc)
     case AV_PIX_FMT_P010:
         *fourcc = MFX_FOURCC_P010;
         return AV_PIX_FMT_P010;
+    case AV_PIX_FMT_YUV422P:
+        *fourcc = MFX_FOURCC_YUY2;
+        return AV_PIX_FMT_YUYV422;
+#if QSV_VERSION_ATLEAST(1, 27)
+    case AV_PIX_FMT_YUV422P10:
+        *fourcc = MFX_FOURCC_Y210;
+        return AV_PIX_FMT_Y210;
+#endif
     default:
         return AVERROR(ENOSYS);
     }
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index b1b6740..854dd3c 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -44,6 +44,10 @@ 
 #include "pixdesc.h"
 #include "time.h"
 
+#define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
+    (MFX_VERSION_MAJOR > (MAJOR) ||         \
+     MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
+
 typedef struct QSVDevicePriv {
     AVBufferRef *child_device_ctx;
 } QSVDevicePriv;
@@ -103,6 +107,12 @@  static const struct {
     { AV_PIX_FMT_BGRA, MFX_FOURCC_RGB4 },
     { AV_PIX_FMT_P010, MFX_FOURCC_P010 },
     { AV_PIX_FMT_PAL8, MFX_FOURCC_P8   },
+    { AV_PIX_FMT_YUYV422,
+                       MFX_FOURCC_YUY2 },
+#if QSV_VERSION_ATLEAST(1, 27)
+    { AV_PIX_FMT_Y210,
+                       MFX_FOURCC_Y210 },
+#endif
 };
 
 static uint32_t qsv_fourcc_from_pix_fmt(enum AVPixelFormat pix_fmt)
@@ -774,6 +784,18 @@  static int map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface)
         surface->Data.A = frame->data[0] + 3;
         break;
 
+    case AV_PIX_FMT_YUYV422:
+        surface->Data.Y = frame->data[0];
+        surface->Data.U = frame->data[0] + 1;
+        surface->Data.V = frame->data[0] + 3;
+        break;
+
+    case AV_PIX_FMT_Y210:
+        surface->Data.Y16 = frame->data[0];
+        surface->Data.U16 = frame->data[0] + 2;
+        surface->Data.V16 = frame->data[0] + 6;
+        break;
+
     default:
         return MFX_ERR_UNSUPPORTED;
     }