[FFmpeg-cvslog] lavc/qsvenc: pass the color properties to the SDK

Haihao Xiang git at videolan.org
Wed Aug 4 16:08:18 EEST 2021


ffmpeg | branch: master | Haihao Xiang <haihao.xiang at intel.com> | Wed Jul 28 16:15:47 2021 +0800| [65fdc0e589551179f793f69528a975b2253699d2] | committer: James Almer

lavc/qsvenc: pass the color properties to the SDK

Otherwise the color properties won't be encoded into the bitstream
header

Reviewed-by: Xiang, Haihao <haihao.xiang at intel.com>
Reviewed-by: Soft Works <softworkz at hotmail.com>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=65fdc0e589551179f793f69528a975b2253699d2
---

 libavcodec/qsvenc.c | 18 ++++++++++++++++++
 libavcodec/qsvenc.h |  4 +++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index f6fa759447..e7e65ebfcf 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -805,6 +805,24 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
     }
 #endif
 
+    q->extvsi.VideoFullRange = (avctx->color_range == AVCOL_RANGE_JPEG);
+    q->extvsi.ColourDescriptionPresent = 0;
+
+    if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
+        avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
+        avctx->colorspace != AVCOL_SPC_UNSPECIFIED) {
+        q->extvsi.ColourDescriptionPresent = 1;
+        q->extvsi.ColourPrimaries = avctx->color_primaries;
+        q->extvsi.TransferCharacteristics = avctx->color_trc;
+        q->extvsi.MatrixCoefficients = avctx->colorspace;
+    }
+
+    if (q->extvsi.VideoFullRange || q->extvsi.ColourDescriptionPresent) {
+        q->extvsi.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO;
+        q->extvsi.Header.BufferSz = sizeof(q->extvsi);
+        q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extvsi;
+    }
+
     if (!check_enc_param(avctx,q)) {
         av_log(avctx, AV_LOG_ERROR,
                "some encoding parameters are not supported by the QSV "
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 6d305f87dd..fc8a14143e 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -139,7 +139,9 @@ typedef struct QSVEncContext {
     mfxFrameSurface1       **opaque_surfaces;
     AVBufferRef             *opaque_alloc_buf;
 
-    mfxExtBuffer  *extparam_internal[2 + QSV_HAVE_CO2 + QSV_HAVE_CO3 + (QSV_HAVE_MF * 2)];
+    mfxExtVideoSignalInfo extvsi;
+
+    mfxExtBuffer  *extparam_internal[3 + QSV_HAVE_CO2 + QSV_HAVE_CO3 + (QSV_HAVE_MF * 2)];
     int         nb_extparam_internal;
 
     mfxExtBuffer **extparam;



More information about the ffmpeg-cvslog mailing list