[FFmpeg-devel] [PATCH 2/2] lavc/qsv: Add support for decoding & encoding 8bit 4:4:4 content

Xiang, Haihao haihao.xiang at intel.com
Fri Aug 12 07:20:53 EEST 2022


From: Haihao Xiang <haihao.xiang at intel.com>

AV_PIX_FMT_VUYA is used in FFmpeg and MFX_FOURCC_AYUV is used in the SDK
---
 libavcodec/qsv.c         | 12 ++++++++++++
 libavcodec/qsvdec.c      |  2 ++
 libavcodec/qsvenc_hevc.c |  1 +
 libavcodec/qsvenc_vp9.c  |  1 +
 4 files changed, 16 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 3449789a2c..6a4730a482 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -211,6 +211,7 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc)
 #if CONFIG_VAAPI
     case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
     case MFX_FOURCC_Y210: return AV_PIX_FMT_Y210;
+    case MFX_FOURCC_AYUV: return AV_PIX_FMT_VUYA;
 #endif
     }
     return AV_PIX_FMT_NONE;
@@ -243,6 +244,9 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc)
     case AV_PIX_FMT_Y210:
         *fourcc = MFX_FOURCC_Y210;
         return AV_PIX_FMT_Y210;
+    case AV_PIX_FMT_VUYA:
+        *fourcc = MFX_FOURCC_AYUV;
+        return AV_PIX_FMT_VUYA;
 #endif
     default:
         return AVERROR(ENOSYS);
@@ -277,6 +281,14 @@ int ff_qsv_map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface)
         surface->Data.U16 = (mfxU16 *)frame->data[0] + 1;
         surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
         break;
+
+    case AV_PIX_FMT_VUYA:
+        surface->Data.V = frame->data[0];
+        surface->Data.U = frame->data[0] + 1;
+        surface->Data.Y = frame->data[0] + 2;
+        surface->Data.A = frame->data[0] + 3;
+        break;
+
     default:
         return AVERROR(ENOSYS);
     }
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 89ec5dcee8..f7b1371586 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -141,6 +141,7 @@ static int qsv_get_continuous_buffer(AVCodecContext *avctx, AVFrame *frame,
         frame->linesize[0] = 2 * FFALIGN(avctx->width, 128);
         break;
     case AV_PIX_FMT_Y210:
+    case AV_PIX_FMT_VUYA:
         frame->linesize[0] = 4 * FFALIGN(avctx->width, 128);
         break;
     default:
@@ -1041,6 +1042,7 @@ const FFCodec ff_##x##_qsv_decoder = { \
                                                     AV_PIX_FMT_P010, \
                                                     AV_PIX_FMT_YUYV422, \
                                                     AV_PIX_FMT_Y210, \
+                                                    AV_PIX_FMT_VUYA, \
                                                     AV_PIX_FMT_QSV, \
                                                     AV_PIX_FMT_NONE }, \
     .hw_configs     = qsv_hw_configs, \
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index e11f5dec4a..df6bb40648 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -311,6 +311,7 @@ const FFCodec ff_hevc_qsv_encoder = {
                                                     AV_PIX_FMT_QSV,
                                                     AV_PIX_FMT_BGRA,
                                                     AV_PIX_FMT_X2RGB10,
+                                                    AV_PIX_FMT_VUYA,
                                                     AV_PIX_FMT_NONE },
     .p.priv_class   = &class,
     .defaults       = qsv_enc_defaults,
diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c
index c738da3904..5b3e24ed54 100644
--- a/libavcodec/qsvenc_vp9.c
+++ b/libavcodec/qsvenc_vp9.c
@@ -113,6 +113,7 @@ const FFCodec ff_vp9_qsv_encoder = {
     .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID,
     .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
                                                     AV_PIX_FMT_P010,
+                                                    AV_PIX_FMT_VUYA,
                                                     AV_PIX_FMT_QSV,
                                                     AV_PIX_FMT_NONE },
     .p.priv_class   = &class,
-- 
2.17.1



More information about the ffmpeg-devel mailing list