[FFmpeg-devel] [PATCH 2/4] lavc/qsvenc: enable hevc gpb option

Zhong Li zhong.li at intel.com
Wed Mar 27 14:51:45 EET 2019


GPB is the default type, just contains forward references but the
slice_type is B slice.
Add this option to allow user to set regular P slice.

Fix ticket#6870

Signed-off-by: Zhong Li <zhong.li at intel.com>
---
 libavcodec/qsvenc.c      | 7 +++++++
 libavcodec/qsvenc.h      | 4 ++++
 libavcodec/qsvenc_hevc.c | 2 ++
 3 files changed, 13 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 1d9893efbf..2e98de93f1 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -270,6 +270,10 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q,
 #if QSV_HAVE_CO3
     av_log(avctx, AV_LOG_VERBOSE,"WinBRCMaxAvgKbps: %"PRIu32"; WinBRCSize: %"PRId32"\n",
            co3->WinBRCMaxAvgKbps, co3->WinBRCSize);
+#if QSV_HAVE_GPB
+    av_log(avctx, AV_LOG_VERBOSE,"GPB: %s\n", print_threestate(co3->GPB));
+#endif
+
 #endif
 
     if (avctx->codec_id == AV_CODEC_ID_H264) {
@@ -743,6 +747,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
         q->extco3.Header.BufferSz      = sizeof(q->extco3);
         q->extco3.WinBRCMaxAvgKbps     = q->win_brc_max_avg_kbps;
         q->extco3.WinBRCSize           = q->win_brc_size;
+#if QSV_HAVE_GPB
+        q->extco3.GPB                  = q->gpb_off ? MFX_CODINGOPTION_OFF : MFX_CODINGOPTION_UNKNOWN;
+#endif
         q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extco3;
 #else
         if (q->win_brc_max_avg_kbps || q->win_brc_size) {
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index f01453e67f..3030e4413f 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -47,6 +47,8 @@
 #define QSV_HAVE_LA_HRD QSV_VERSION_ATLEAST(1, 11)
 #define QSV_HAVE_VDENC  QSV_VERSION_ATLEAST(1, 15)
 
+#define QSV_HAVE_GPB    QSV_VERSION_ATLEAST(1, 18)
+
 #if defined(_WIN32) || defined(__CYGWIN__)
 #define QSV_HAVE_AVBR   QSV_VERSION_ATLEAST(1, 3)
 #define QSV_HAVE_ICQ    QSV_VERSION_ATLEAST(1, 8)
@@ -179,6 +181,8 @@ typedef struct QSVEncContext {
     int win_brc_max_avg_kbps;
     int win_brc_size;
 
+    int gpb_off;
+
     int a53_cc;
 
 #if QSV_HAVE_MF
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index df6ef24b72..1e822efece 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -242,6 +242,8 @@ static const AVOption options[] = {
     { "main10",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAIN10  }, INT_MIN, INT_MAX,     VE, "profile" },
     { "mainsp",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAINSP  }, INT_MIN, INT_MAX,     VE, "profile" },
 
+    { "gpb_off", "turn off GPB (generalized P/B frame) and use regular P frame", OFFSET(qsv.gpb_off), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE},
+
     { NULL },
 };
 
-- 
2.17.1



More information about the ffmpeg-devel mailing list