Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/3] libavcodec/qsvenc: Add max slice size support to hevc_qsv
@ 2022-01-24  2:59 Wenbin Chen
  2022-01-24  2:59 ` [FFmpeg-devel] [PATCH 2/3] libavcodec/qsvenc: Add b_strategy option " Wenbin Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Wenbin Chen @ 2022-01-24  2:59 UTC (permalink / raw)
  To: ffmpeg-devel

Add max_slice_size option to hevc_qsv as well.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 doc/encoders.texi   | 3 +++
 libavcodec/qsvenc.c | 9 ++++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index e3adbf4325..8966610263 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3397,6 +3397,9 @@ Enable rate distortion optimization.
 @item @var{max_frame_size}
 Maximum encoded frame size in bytes.
 
+@item @var{max_slice_size}
+Maximum encoded slice size in bytes.
+
 @item @var{p_strategy}
 Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0).
 
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 413e5ae8f6..f311cd9ce4 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -877,11 +877,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
             if (q->mbbrc >= 0)
                 q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 
-#if QSV_HAVE_MAX_SLICE_SIZE
-            if (q->max_slice_size >= 0)
-                q->extco2.MaxSliceSize = q->max_slice_size;
-#endif
-
 #if QSV_HAVE_TRELLIS
             if (avctx->trellis >= 0)
                 q->extco2.Trellis = (avctx->trellis == 0) ? MFX_TRELLIS_OFF : (MFX_TRELLIS_I | MFX_TRELLIS_P | MFX_TRELLIS_B);
@@ -907,6 +902,10 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
                 q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
             if (q->max_frame_size >= 0)
                 q->extco2.MaxFrameSize = q->max_frame_size;
+#if QSV_HAVE_MAX_SLICE_SIZE
+            if (q->max_slice_size >= 0)
+                q->extco2.MaxSliceSize = q->max_slice_size;
+#endif
 #if QSV_HAVE_DISABLEDEBLOCKIDC
             q->extco2.DisableDeblockingIdc = q->dblk_idc;
 #endif
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 2/3] libavcodec/qsvenc: Add b_strategy option to hevc_qsv
  2022-01-24  2:59 [FFmpeg-devel] [PATCH 1/3] libavcodec/qsvenc: Add max slice size support to hevc_qsv Wenbin Chen
@ 2022-01-24  2:59 ` Wenbin Chen
  2022-01-25  3:22   ` Xiang, Haihao
  2022-01-24  2:59 ` [FFmpeg-devel] [PATCH 3/3] libavcodec/qsvenc: Add intra refresh to hevc_qsv and add new intra refresh parameter Wenbin Chen
  2022-01-25  3:23 ` [FFmpeg-devel] [PATCH 1/3] libavcodec/qsvenc: Add max slice size support to hevc_qsv Xiang, Haihao
  2 siblings, 1 reply; 7+ messages in thread
From: Wenbin Chen @ 2022-01-24  2:59 UTC (permalink / raw)
  To: ffmpeg-devel

Add b_strategy option to hevc_qsv. By enabling this option, encoder can
use b frames as reference.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 doc/encoders.texi   | 3 +++
 libavcodec/qsvenc.c | 6 ++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 8966610263..6c1c4df57a 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3403,6 +3403,9 @@ Maximum encoded slice size in bytes.
 @item @var{p_strategy}
 Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0).
 
+@item @var{b_strategy}
+This option controls usage of B frames as reference.
+
 @item @var{dblk_idc}
 This option disable deblocking. It has value in range 0~2.
 
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index f311cd9ce4..a8d876d6d9 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -888,8 +888,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
             q->extco2.LookAheadDS = q->look_ahead_downsampling;
             q->extco2.RepeatPPS   = q->repeat_pps ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 
-            if (q->b_strategy >= 0)
-                q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
             if (q->adaptive_i >= 0)
                 q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
             if (q->adaptive_b >= 0)
@@ -910,6 +908,10 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
             q->extco2.DisableDeblockingIdc = q->dblk_idc;
 #endif
 
+#if QSV_VERSION_ATLEAST(1, 8)
+            if (q->b_strategy >= 0)
+                q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
+#endif
 #if QSV_VERSION_ATLEAST(1, 9)
             if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) {
                 av_log(avctx, AV_LOG_ERROR, "qmin and or qmax are set but invalid, please make sure min <= max\n");
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 3/3] libavcodec/qsvenc: Add intra refresh to hevc_qsv and add new intra refresh parameter
  2022-01-24  2:59 [FFmpeg-devel] [PATCH 1/3] libavcodec/qsvenc: Add max slice size support to hevc_qsv Wenbin Chen
  2022-01-24  2:59 ` [FFmpeg-devel] [PATCH 2/3] libavcodec/qsvenc: Add b_strategy option " Wenbin Chen
@ 2022-01-24  2:59 ` Wenbin Chen
  2022-01-25  3:22   ` Xiang, Haihao
  2022-01-25  3:23 ` [FFmpeg-devel] [PATCH 1/3] libavcodec/qsvenc: Add max slice size support to hevc_qsv Xiang, Haihao
  2 siblings, 1 reply; 7+ messages in thread
From: Wenbin Chen @ 2022-01-24  2:59 UTC (permalink / raw)
  To: ffmpeg-devel

Add intra refresh support to hevc_qsv as well.
Add an new intra refresh type: "horizontal", and an new param
ref_cycle_dist. This param specify the distance between the
beginnings of the intra-refresh cycles in frames.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 doc/encoders.texi        | 26 +++++++++++++++++++++++++-
 libavcodec/qsvenc.c      | 23 ++++++++++++++---------
 libavcodec/qsvenc.h      |  1 +
 libavcodec/qsvenc_h264.c |  7 +++++--
 libavcodec/qsvenc_hevc.c |  9 +++++++++
 5 files changed, 54 insertions(+), 12 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6c1c4df57a..4e35e50e4d 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3344,7 +3344,8 @@ Specifies intra refresh type. The major goal of intra refresh is improvement of
 error resilience without significant impact on encoded bitstream size caused by
 I frames. The SDK encoder achieves this by encoding part of each frame in
 refresh cycle using intra MBs. @var{none} means no refresh. @var{vertical} means
-vertical refresh, by column of MBs.
+vertical refresh, by column of MBs. To enable intra refresh, B frame should be
+set to 0.
 
 @item @var{int_ref_cycle_size}
 Specifies number of pictures within refresh cycle starting from 2. 0 and 1 are
@@ -3355,6 +3356,9 @@ Specifies QP difference for inserted intra MBs. This is signed value in
 [-51, 51] range if target encoding bit-depth for luma samples is 8 and this
 range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth respectively.
 
+@item @var{int_ref_cycle_dist}
+Distance between the beginnings of the intra-refresh cycles in frames.
+
 @item @var{profile}
 @table @samp
 @item unknown
@@ -3463,6 +3467,26 @@ Insert picture timing SEI with pic_struct_syntax element.
 @item @var{transform_skip}
 Turn this option ON to enable transformskip. It is supported on platform equal
 or newer than ICL.
+
+@item @var{int_ref_type}
+Specifies intra refresh type. The major goal of intra refresh is improvement of
+error resilience without significant impact on encoded bitstream size caused by
+I frames. The SDK encoder achieves this by encoding part of each frame in
+refresh cycle using intra MBs. @var{none} means no refresh. @var{vertical} means
+vertical refresh, by column of MBs. To enable intra refresh, B frame should be
+set to 0.
+
+@item @var{int_ref_cycle_size}
+Specifies number of pictures within refresh cycle starting from 2. 0 and 1 are
+invalid values.
+
+@item @var{int_ref_qp_delta}
+Specifies QP difference for inserted intra MBs. This is signed value in
+[-51, 51] range if target encoding bit-depth for luma samples is 8 and this
+range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth respectively.
+
+@item @var{int_ref_cycle_dist}
+Distance between the beginnings of the intra-refresh cycles in frames.
 @end table
 
 @subsection MPEG2 Options
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index a8d876d6d9..af1529936e 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -267,8 +267,10 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q,
 
 #if QSV_HAVE_CO2
     av_log(avctx, AV_LOG_VERBOSE,
-           "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n",
-           print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta);
+           "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16
+           "; IntRefQPDelta: %"PRId16"; IntRefCycleDist: %"PRId16"\n",
+           print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2->IntRefCycleSize,
+           co2->IntRefQPDelta, co3->IntRefCycleDist);
 
     av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2->MaxFrameSize);
 #if QSV_HAVE_MAX_SLICE_SIZE
@@ -865,13 +867,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
 
 #if QSV_HAVE_CO2
         if (avctx->codec_id == AV_CODEC_ID_H264) {
-            if (q->int_ref_type >= 0)
-                q->extco2.IntRefType = q->int_ref_type;
-            if (q->int_ref_cycle_size >= 0)
-                q->extco2.IntRefCycleSize = q->int_ref_cycle_size;
-            if (q->int_ref_qp_delta != INT16_MIN)
-                q->extco2.IntRefQPDelta = q->int_ref_qp_delta;
-
             if (q->bitrate_limit >= 0)
                 q->extco2.BitrateLimit = q->bitrate_limit ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
             if (q->mbbrc >= 0)
@@ -900,6 +895,12 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
                 q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
             if (q->max_frame_size >= 0)
                 q->extco2.MaxFrameSize = q->max_frame_size;
+            if (q->int_ref_type >= 0)
+                q->extco2.IntRefType = q->int_ref_type;
+            if (q->int_ref_cycle_size >= 0)
+                q->extco2.IntRefCycleSize = q->int_ref_cycle_size;
+            if (q->int_ref_qp_delta != INT16_MIN)
+                q->extco2.IntRefQPDelta = q->int_ref_qp_delta;
 #if QSV_HAVE_MAX_SLICE_SIZE
             if (q->max_slice_size >= 0)
                 q->extco2.MaxSliceSize = q->max_slice_size;
@@ -973,6 +974,10 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
                 av_log(avctx, AV_LOG_WARNING,
                        "Please set max_b_frames(-bf) to 0 to enable P-pyramid\n");
             }
+#endif
+#if QSV_VERSION_ATLEAST(1, 16)
+            if (q->int_ref_cycle_dist >= 0)
+                q->extco3.IntRefCycleDist = q->int_ref_cycle_dist;
 #endif
         }
 
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 65f035045c..5fa0b6f5ba 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -195,6 +195,7 @@ typedef struct QSVEncContext {
     int int_ref_type;
     int int_ref_cycle_size;
     int int_ref_qp_delta;
+    int int_ref_cycle_dist;
     int recovery_point_sei;
 
     int repeat_pps;
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 9f127607b7..bec3633268 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -126,13 +126,16 @@ static const AVOption options[] = {
     { "4x"                     , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_4x      }, INT_MIN, INT_MAX,     VE, "look_ahead_downsampling" },
 #endif
 
-    { "int_ref_type", "Intra refresh type",                                      OFFSET(qsv.int_ref_type),            AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE, "int_ref_type" },
+    { "int_ref_type", "Intra refresh type. B frames should be set to 0.",        OFFSET(qsv.int_ref_type),            AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE, "int_ref_type" },
         { "none",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = VE, "int_ref_type" },
         { "vertical", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = VE, "int_ref_type" },
+        { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .flags = VE, "int_ref_type" },
     { "int_ref_cycle_size", "Number of frames in the intra refresh cycle",       OFFSET(qsv.int_ref_cycle_size),      AV_OPT_TYPE_INT, { .i64 = -1 },               -1, UINT16_MAX, VE },
     { "int_ref_qp_delta",   "QP difference for the refresh MBs",                 OFFSET(qsv.int_ref_qp_delta),        AV_OPT_TYPE_INT, { .i64 = INT16_MIN }, INT16_MIN,  INT16_MAX, VE },
     { "recovery_point_sei", "Insert recovery point SEI messages",                OFFSET(qsv.recovery_point_sei),      AV_OPT_TYPE_INT, { .i64 = -1 },               -1,          1, VE },
-
+#if QSV_VERSION_ATLEAST(1, 16)
+    { "int_ref_cycle_dist",   "Distance between the beginnings of the intra-refresh cycles in frames",  OFFSET(qsv.int_ref_cycle_dist),      AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT16_MAX, VE },
+#endif
     { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" },
     { "unknown" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN      }, INT_MIN, INT_MAX,     VE, "profile" },
     { "baseline", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_BASELINE }, INT_MIN, INT_MAX,     VE, "profile" },
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 91a316f9c8..5cac141c4d 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -258,6 +258,15 @@ static const AVOption options[] = {
 #if QSV_VERSION_ATLEAST(1, 26)
     { "transform_skip", "Turn this option ON to enable transformskip",   OFFSET(qsv.transform_skip),          AV_OPT_TYPE_INT,    { .i64 = -1},   -1, 1,  VE},
 #endif
+    { "int_ref_type", "Intra refresh type. B frames should be set to 0",         OFFSET(qsv.int_ref_type),            AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE, "int_ref_type" },
+        { "none",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = VE, "int_ref_type" },
+        { "vertical", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = VE, "int_ref_type" },
+        { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .flags = VE, "int_ref_type" },
+    { "int_ref_cycle_size", "Number of frames in the intra refresh cycle",       OFFSET(qsv.int_ref_cycle_size),      AV_OPT_TYPE_INT, { .i64 = -1 },               -1, UINT16_MAX, VE },
+    { "int_ref_qp_delta",   "QP difference for the refresh MBs",                 OFFSET(qsv.int_ref_qp_delta),        AV_OPT_TYPE_INT, { .i64 = INT16_MIN }, INT16_MIN,  INT16_MAX, VE },
+#if QSV_VERSION_ATLEAST(1, 16)
+    { "int_ref_cycle_dist",   "Distance between the beginnings of the intra-refresh cycles in frames",  OFFSET(qsv.int_ref_cycle_dist),      AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT16_MAX, VE },
+#endif
 
     { NULL },
 };
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 3/3] libavcodec/qsvenc: Add intra refresh to hevc_qsv and add new intra refresh parameter
  2022-01-24  2:59 ` [FFmpeg-devel] [PATCH 3/3] libavcodec/qsvenc: Add intra refresh to hevc_qsv and add new intra refresh parameter Wenbin Chen
@ 2022-01-25  3:22   ` Xiang, Haihao
  2022-01-25  4:59     ` Chen, Wenbin
  0 siblings, 1 reply; 7+ messages in thread
From: Xiang, Haihao @ 2022-01-25  3:22 UTC (permalink / raw)
  To: ffmpeg-devel

On Mon, 2022-01-24 at 10:59 +0800, Wenbin Chen wrote:
> Add intra refresh support to hevc_qsv as well.
> Add an new intra refresh type: "horizontal", and an new param
> ref_cycle_dist. This param specify the distance between the
> beginnings of the intra-refresh cycles in frames.
> 
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
>  doc/encoders.texi        | 26 +++++++++++++++++++++++++-
>  libavcodec/qsvenc.c      | 23 ++++++++++++++---------
>  libavcodec/qsvenc.h      |  1 +
>  libavcodec/qsvenc_h264.c |  7 +++++--
>  libavcodec/qsvenc_hevc.c |  9 +++++++++
>  5 files changed, 54 insertions(+), 12 deletions(-)
> 
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 6c1c4df57a..4e35e50e4d 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -3344,7 +3344,8 @@ Specifies intra refresh type. The major goal of intra
> refresh is improvement of
>  error resilience without significant impact on encoded bitstream size caused
> by
>  I frames. The SDK encoder achieves this by encoding part of each frame in
>  refresh cycle using intra MBs. @var{none} means no refresh. @var{vertical}
> means
> -vertical refresh, by column of MBs.
> +vertical refresh, by column of MBs. To enable intra refresh, B frame should
> be
> +set to 0.
>  
>  @item @var{int_ref_cycle_size}
>  Specifies number of pictures within refresh cycle starting from 2. 0 and 1
> are
> @@ -3355,6 +3356,9 @@ Specifies QP difference for inserted intra MBs. This is
> signed value in
>  [-51, 51] range if target encoding bit-depth for luma samples is 8 and this
>  range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth
> respectively.
>  
> +@item @var{int_ref_cycle_dist}
> +Distance between the beginnings of the intra-refresh cycles in frames.
> +
>  @item @var{profile}
>  @table @samp
>  @item unknown
> @@ -3463,6 +3467,26 @@ Insert picture timing SEI with pic_struct_syntax
> element.
>  @item @var{transform_skip}
>  Turn this option ON to enable transformskip. It is supported on platform
> equal
>  or newer than ICL.
> +
> +@item @var{int_ref_type}
> +Specifies intra refresh type. The major goal of intra refresh is improvement
> of
> +error resilience without significant impact on encoded bitstream size caused
> by
> +I frames. The SDK encoder achieves this by encoding part of each frame in
> +refresh cycle using intra MBs. @var{none} means no refresh. @var{vertical}
> means
> +vertical refresh, by column of MBs. To enable intra refresh, B frame should
> be
> +set to 0.
> +
> +@item @var{int_ref_cycle_size}
> +Specifies number of pictures within refresh cycle starting from 2. 0 and 1
> are
> +invalid values.
> +
> +@item @var{int_ref_qp_delta}
> +Specifies QP difference for inserted intra MBs. This is signed value in
> +[-51, 51] range if target encoding bit-depth for luma samples is 8 and this
> +range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth
> respectively.
> +
> +@item @var{int_ref_cycle_dist}
> +Distance between the beginnings of the intra-refresh cycles in frames.
>  @end table
>  
>  @subsection MPEG2 Options
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index a8d876d6d9..af1529936e 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -267,8 +267,10 @@ static void dump_video_param(AVCodecContext *avctx,
> QSVEncContext *q,
>  
>  #if QSV_HAVE_CO2
>      av_log(avctx, AV_LOG_VERBOSE,
> -           "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize:
> %"PRIu16"; IntRefQPDelta: %"PRId16"\n",
> -           print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2-
> >IntRefCycleSize, co2->IntRefQPDelta);
> +           "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize:
> %"PRIu16
> +           "; IntRefQPDelta: %"PRId16"; IntRefCycleDist: %"PRId16"\n",
> +           print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2-
> >IntRefCycleSize,
> +           co2->IntRefQPDelta, co3->IntRefCycleDist);


IntRefCycleDist is a member of mfxExtCodingOption3, and was introduced in mfx
version 1.16, so it should be used under QSV_HAVE_CO3 && QSV_VERSION_ATLEAST(1,
16), not QSV_HAVE_CO2. 

Thanks
Haihao


>  
>      av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2->MaxFrameSize);
>  #if QSV_HAVE_MAX_SLICE_SIZE
> @@ -865,13 +867,6 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>  
>  #if QSV_HAVE_CO2
>          if (avctx->codec_id == AV_CODEC_ID_H264) {
> -            if (q->int_ref_type >= 0)
> -                q->extco2.IntRefType = q->int_ref_type;
> -            if (q->int_ref_cycle_size >= 0)
> -                q->extco2.IntRefCycleSize = q->int_ref_cycle_size;
> -            if (q->int_ref_qp_delta != INT16_MIN)
> -                q->extco2.IntRefQPDelta = q->int_ref_qp_delta;
> -
>              if (q->bitrate_limit >= 0)
>                  q->extco2.BitrateLimit = q->bitrate_limit ?
> MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
>              if (q->mbbrc >= 0)
> @@ -900,6 +895,12 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>                  q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON :
> MFX_CODINGOPTION_OFF;
>              if (q->max_frame_size >= 0)
>                  q->extco2.MaxFrameSize = q->max_frame_size;
> +            if (q->int_ref_type >= 0)
> +                q->extco2.IntRefType = q->int_ref_type;
> +            if (q->int_ref_cycle_size >= 0)
> +                q->extco2.IntRefCycleSize = q->int_ref_cycle_size;
> +            if (q->int_ref_qp_delta != INT16_MIN)
> +                q->extco2.IntRefQPDelta = q->int_ref_qp_delta;
>  #if QSV_HAVE_MAX_SLICE_SIZE
>              if (q->max_slice_size >= 0)
>                  q->extco2.MaxSliceSize = q->max_slice_size;
> @@ -973,6 +974,10 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>                  av_log(avctx, AV_LOG_WARNING,
>                         "Please set max_b_frames(-bf) to 0 to enable P-
> pyramid\n");
>              }
> +#endif
> +#if QSV_VERSION_ATLEAST(1, 16)
> +            if (q->int_ref_cycle_dist >= 0)
> +                q->extco3.IntRefCycleDist = q->int_ref_cycle_dist;
>  #endif
>          }
>  
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> index 65f035045c..5fa0b6f5ba 100644
> --- a/libavcodec/qsvenc.h
> +++ b/libavcodec/qsvenc.h
> @@ -195,6 +195,7 @@ typedef struct QSVEncContext {
>      int int_ref_type;
>      int int_ref_cycle_size;
>      int int_ref_qp_delta;
> +    int int_ref_cycle_dist;
>      int recovery_point_sei;
>  
>      int repeat_pps;
> diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
> index 9f127607b7..bec3633268 100644
> --- a/libavcodec/qsvenc_h264.c
> +++ b/libavcodec/qsvenc_h264.c
> @@ -126,13 +126,16 @@ static const AVOption options[] = {
>      { "4x"                     , NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> MFX_LOOKAHEAD_DS_4x      }, INT_MIN, INT_MAX,     VE,
> "look_ahead_downsampling" },
>  #endif
>  
> -    { "int_ref_type", "Intra refresh
> type",                                      OFFSET(qsv.int_ref_type),         
>    AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE, "int_ref_type" },
> +    { "int_ref_type", "Intra refresh type. B frames should be set to
> 0.",        OFFSET(qsv.int_ref_type),            AV_OPT_TYPE_INT, { .i64 = -1
> }, -1, UINT16_MAX, VE, "int_ref_type" },
>          { "none",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = VE,
> "int_ref_type" },
>          { "vertical", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = VE,
> "int_ref_type" },
> +        { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .flags =
> VE, "int_ref_type" },
>      { "int_ref_cycle_size", "Number of frames in the intra refresh
> cycle",       OFFSET(qsv.int_ref_cycle_size),      AV_OPT_TYPE_INT, { .i64 =
> -1 },               -1, UINT16_MAX, VE },
>      { "int_ref_qp_delta",   "QP difference for the refresh
> MBs",                 OFFSET(qsv.int_ref_qp_delta),        AV_OPT_TYPE_INT, {
> .i64 = INT16_MIN }, INT16_MIN,  INT16_MAX, VE },
>      { "recovery_point_sei", "Insert recovery point SEI
> messages",                OFFSET(qsv.recovery_point_sei),      AV_OPT_TYPE_INT
> , { .i64 = -1 },               -1,          1, VE },
> -
> +#if QSV_VERSION_ATLEAST(1, 16)
> +    { "int_ref_cycle_dist",   "Distance between the beginnings of the intra-
> refresh cycles in
> frames",  OFFSET(qsv.int_ref_cycle_dist),      AV_OPT_TYPE_INT, { .i64 = -1 },
> -1, INT16_MAX, VE },
> +#endif
>      { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 =
> MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" },
>      { "unknown" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> MFX_PROFILE_UNKNOWN      }, INT_MIN, INT_MAX,     VE, "profile" },
>      { "baseline", NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> MFX_PROFILE_AVC_BASELINE }, INT_MIN, INT_MAX,     VE, "profile" },
> diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
> index 91a316f9c8..5cac141c4d 100644
> --- a/libavcodec/qsvenc_hevc.c
> +++ b/libavcodec/qsvenc_hevc.c
> @@ -258,6 +258,15 @@ static const AVOption options[] = {
>  #if QSV_VERSION_ATLEAST(1, 26)
>      { "transform_skip", "Turn this option ON to enable
> transformskip",   OFFSET(qsv.transform_skip),          AV_OPT_TYPE_INT,    {
> .i64 = -1},   -1, 1,  VE},
>  #endif
> +    { "int_ref_type", "Intra refresh type. B frames should be set to
> 0",         OFFSET(qsv.int_ref_type),            AV_OPT_TYPE_INT, { .i64 = -1
> }, -1, UINT16_MAX, VE, "int_ref_type" },
> +        { "none",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = VE,
> "int_ref_type" },
> +        { "vertical", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = VE,
> "int_ref_type" },
> +        { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .flags =
> VE, "int_ref_type" },
> +    { "int_ref_cycle_size", "Number of frames in the intra refresh
> cycle",       OFFSET(qsv.int_ref_cycle_size),      AV_OPT_TYPE_INT, { .i64 =
> -1 },               -1, UINT16_MAX, VE },
> +    { "int_ref_qp_delta",   "QP difference for the refresh
> MBs",                 OFFSET(qsv.int_ref_qp_delta),        AV_OPT_TYPE_INT, {
> .i64 = INT16_MIN }, INT16_MIN,  INT16_MAX, VE },
> +#if QSV_VERSION_ATLEAST(1, 16)
> +    { "int_ref_cycle_dist",   "Distance between the beginnings of the intra-
> refresh cycles in
> frames",  OFFSET(qsv.int_ref_cycle_dist),      AV_OPT_TYPE_INT, { .i64 = -1 },
> -1, INT16_MAX, VE },
> +#endif
>  
>      { NULL },
>  };
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/3] libavcodec/qsvenc: Add b_strategy option to hevc_qsv
  2022-01-24  2:59 ` [FFmpeg-devel] [PATCH 2/3] libavcodec/qsvenc: Add b_strategy option " Wenbin Chen
@ 2022-01-25  3:22   ` Xiang, Haihao
  0 siblings, 0 replies; 7+ messages in thread
From: Xiang, Haihao @ 2022-01-25  3:22 UTC (permalink / raw)
  To: ffmpeg-devel

On Mon, 2022-01-24 at 10:59 +0800, Wenbin Chen wrote:
> Add b_strategy option to hevc_qsv. By enabling this option, encoder can
> use b frames as reference.
> 
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
>  doc/encoders.texi   | 3 +++
>  libavcodec/qsvenc.c | 6 ++++--
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 8966610263..6c1c4df57a 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -3403,6 +3403,9 @@ Maximum encoded slice size in bytes.
>  @item @var{p_strategy}
>  Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0).
>  
> +@item @var{b_strategy}
> +This option controls usage of B frames as reference.
> +
>  @item @var{dblk_idc}
>  This option disable deblocking. It has value in range 0~2.
>  
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index f311cd9ce4..a8d876d6d9 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -888,8 +888,6 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>              q->extco2.LookAheadDS = q->look_ahead_downsampling;
>              q->extco2.RepeatPPS   = q->repeat_pps ? MFX_CODINGOPTION_ON :
> MFX_CODINGOPTION_OFF;
>  
> -            if (q->b_strategy >= 0)
> -                q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID :
> MFX_B_REF_OFF;
>              if (q->adaptive_i >= 0)
>                  q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON :
> MFX_CODINGOPTION_OFF;
>              if (q->adaptive_b >= 0)
> @@ -910,6 +908,10 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>              q->extco2.DisableDeblockingIdc = q->dblk_idc;
>  #endif
>  
> +#if QSV_VERSION_ATLEAST(1, 8)
> +            if (q->b_strategy >= 0)
> +                q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID :
> MFX_B_REF_OFF;
> +#endif
>  #if QSV_VERSION_ATLEAST(1, 9)
>              if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx-
> >qmax) {
>                  av_log(avctx, AV_LOG_ERROR, "qmin and or qmax are set but
> invalid, please make sure min <= max\n");

LGTM, thx

-Haihao

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/3] libavcodec/qsvenc: Add max slice size support to hevc_qsv
  2022-01-24  2:59 [FFmpeg-devel] [PATCH 1/3] libavcodec/qsvenc: Add max slice size support to hevc_qsv Wenbin Chen
  2022-01-24  2:59 ` [FFmpeg-devel] [PATCH 2/3] libavcodec/qsvenc: Add b_strategy option " Wenbin Chen
  2022-01-24  2:59 ` [FFmpeg-devel] [PATCH 3/3] libavcodec/qsvenc: Add intra refresh to hevc_qsv and add new intra refresh parameter Wenbin Chen
@ 2022-01-25  3:23 ` Xiang, Haihao
  2 siblings, 0 replies; 7+ messages in thread
From: Xiang, Haihao @ 2022-01-25  3:23 UTC (permalink / raw)
  To: ffmpeg-devel

On Mon, 2022-01-24 at 10:59 +0800, Wenbin Chen wrote:
> Add max_slice_size option to hevc_qsv as well.
> 
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
>  doc/encoders.texi   | 3 +++
>  libavcodec/qsvenc.c | 9 ++++-----
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index e3adbf4325..8966610263 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -3397,6 +3397,9 @@ Enable rate distortion optimization.
>  @item @var{max_frame_size}
>  Maximum encoded frame size in bytes.
>  
> +@item @var{max_slice_size}
> +Maximum encoded slice size in bytes.
> +
>  @item @var{p_strategy}
>  Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0).
>  
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 413e5ae8f6..f311cd9ce4 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -877,11 +877,6 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>              if (q->mbbrc >= 0)
>                  q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON :
> MFX_CODINGOPTION_OFF;
>  
> -#if QSV_HAVE_MAX_SLICE_SIZE
> -            if (q->max_slice_size >= 0)
> -                q->extco2.MaxSliceSize = q->max_slice_size;
> -#endif
> -
>  #if QSV_HAVE_TRELLIS
>              if (avctx->trellis >= 0)
>                  q->extco2.Trellis = (avctx->trellis == 0) ? MFX_TRELLIS_OFF :
> (MFX_TRELLIS_I | MFX_TRELLIS_P | MFX_TRELLIS_B);
> @@ -907,6 +902,10 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>                  q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON :
> MFX_CODINGOPTION_OFF;
>              if (q->max_frame_size >= 0)
>                  q->extco2.MaxFrameSize = q->max_frame_size;
> +#if QSV_HAVE_MAX_SLICE_SIZE
> +            if (q->max_slice_size >= 0)
> +                q->extco2.MaxSliceSize = q->max_slice_size;
> +#endif
>  #if QSV_HAVE_DISABLEDEBLOCKIDC
>              q->extco2.DisableDeblockingIdc = q->dblk_idc;
>  #endif

LGTM, thx

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 3/3] libavcodec/qsvenc: Add intra refresh to hevc_qsv and add new intra refresh parameter
  2022-01-25  3:22   ` Xiang, Haihao
@ 2022-01-25  4:59     ` Chen, Wenbin
  0 siblings, 0 replies; 7+ messages in thread
From: Chen, Wenbin @ 2022-01-25  4:59 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

> On Mon, 2022-01-24 at 10:59 +0800, Wenbin Chen wrote:
> > Add intra refresh support to hevc_qsv as well.
> > Add an new intra refresh type: "horizontal", and an new param
> > ref_cycle_dist. This param specify the distance between the
> > beginnings of the intra-refresh cycles in frames.
> >
> > Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> > ---
> >  doc/encoders.texi        | 26 +++++++++++++++++++++++++-
> >  libavcodec/qsvenc.c      | 23 ++++++++++++++---------
> >  libavcodec/qsvenc.h      |  1 +
> >  libavcodec/qsvenc_h264.c |  7 +++++--
> >  libavcodec/qsvenc_hevc.c |  9 +++++++++
> >  5 files changed, 54 insertions(+), 12 deletions(-)
> >
> > diff --git a/doc/encoders.texi b/doc/encoders.texi
> > index 6c1c4df57a..4e35e50e4d 100644
> > --- a/doc/encoders.texi
> > +++ b/doc/encoders.texi
> > @@ -3344,7 +3344,8 @@ Specifies intra refresh type. The major goal of
> intra
> > refresh is improvement of
> >  error resilience without significant impact on encoded bitstream size
> caused
> > by
> >  I frames. The SDK encoder achieves this by encoding part of each frame in
> >  refresh cycle using intra MBs. @var{none} means no refresh. @var{vertical}
> > means
> > -vertical refresh, by column of MBs.
> > +vertical refresh, by column of MBs. To enable intra refresh, B frame
> should
> > be
> > +set to 0.
> >
> >  @item @var{int_ref_cycle_size}
> >  Specifies number of pictures within refresh cycle starting from 2. 0 and 1
> > are
> > @@ -3355,6 +3356,9 @@ Specifies QP difference for inserted intra MBs.
> This is
> > signed value in
> >  [-51, 51] range if target encoding bit-depth for luma samples is 8 and this
> >  range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth
> > respectively.
> >
> > +@item @var{int_ref_cycle_dist}
> > +Distance between the beginnings of the intra-refresh cycles in frames.
> > +
> >  @item @var{profile}
> >  @table @samp
> >  @item unknown
> > @@ -3463,6 +3467,26 @@ Insert picture timing SEI with pic_struct_syntax
> > element.
> >  @item @var{transform_skip}
> >  Turn this option ON to enable transformskip. It is supported on platform
> > equal
> >  or newer than ICL.
> > +
> > +@item @var{int_ref_type}
> > +Specifies intra refresh type. The major goal of intra refresh is
> improvement
> > of
> > +error resilience without significant impact on encoded bitstream size
> caused
> > by
> > +I frames. The SDK encoder achieves this by encoding part of each frame in
> > +refresh cycle using intra MBs. @var{none} means no refresh.
> @var{vertical}
> > means
> > +vertical refresh, by column of MBs. To enable intra refresh, B frame
> should
> > be
> > +set to 0.
> > +
> > +@item @var{int_ref_cycle_size}
> > +Specifies number of pictures within refresh cycle starting from 2. 0 and 1
> > are
> > +invalid values.
> > +
> > +@item @var{int_ref_qp_delta}
> > +Specifies QP difference for inserted intra MBs. This is signed value in
> > +[-51, 51] range if target encoding bit-depth for luma samples is 8 and this
> > +range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth
> > respectively.
> > +
> > +@item @var{int_ref_cycle_dist}
> > +Distance between the beginnings of the intra-refresh cycles in frames.
> >  @end table
> >
> >  @subsection MPEG2 Options
> > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> > index a8d876d6d9..af1529936e 100644
> > --- a/libavcodec/qsvenc.c
> > +++ b/libavcodec/qsvenc.c
> > @@ -267,8 +267,10 @@ static void dump_video_param(AVCodecContext
> *avctx,
> > QSVEncContext *q,
> >
> >  #if QSV_HAVE_CO2
> >      av_log(avctx, AV_LOG_VERBOSE,
> > -           "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize:
> > %"PRIu16"; IntRefQPDelta: %"PRId16"\n",
> > -           print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2-
> > >IntRefCycleSize, co2->IntRefQPDelta);
> > +           "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize:
> > %"PRIu16
> > +           "; IntRefQPDelta: %"PRId16"; IntRefCycleDist: %"PRId16"\n",
> > +           print_threestate(co->RecoveryPointSEI), co2->IntRefType, co2-
> > >IntRefCycleSize,
> > +           co2->IntRefQPDelta, co3->IntRefCycleDist);
> 
> 
> IntRefCycleDist is a member of mfxExtCodingOption3, and was introduced in
> mfx
> version 1.16, so it should be used under QSV_HAVE_CO3 &&
> QSV_VERSION_ATLEAST(1,
> 16), not QSV_HAVE_CO2.
> 
> Thanks
> Haihao

Thanks for review. I will fix this.

Thanks
Wenbin

> 
> 
> >
> >      av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2-
> >MaxFrameSize);
> >  #if QSV_HAVE_MAX_SLICE_SIZE
> > @@ -865,13 +867,6 @@ static int init_video_param(AVCodecContext
> *avctx,
> > QSVEncContext *q)
> >
> >  #if QSV_HAVE_CO2
> >          if (avctx->codec_id == AV_CODEC_ID_H264) {
> > -            if (q->int_ref_type >= 0)
> > -                q->extco2.IntRefType = q->int_ref_type;
> > -            if (q->int_ref_cycle_size >= 0)
> > -                q->extco2.IntRefCycleSize = q->int_ref_cycle_size;
> > -            if (q->int_ref_qp_delta != INT16_MIN)
> > -                q->extco2.IntRefQPDelta = q->int_ref_qp_delta;
> > -
> >              if (q->bitrate_limit >= 0)
> >                  q->extco2.BitrateLimit = q->bitrate_limit ?
> > MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
> >              if (q->mbbrc >= 0)
> > @@ -900,6 +895,12 @@ static int init_video_param(AVCodecContext
> *avctx,
> > QSVEncContext *q)
> >                  q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON :
> > MFX_CODINGOPTION_OFF;
> >              if (q->max_frame_size >= 0)
> >                  q->extco2.MaxFrameSize = q->max_frame_size;
> > +            if (q->int_ref_type >= 0)
> > +                q->extco2.IntRefType = q->int_ref_type;
> > +            if (q->int_ref_cycle_size >= 0)
> > +                q->extco2.IntRefCycleSize = q->int_ref_cycle_size;
> > +            if (q->int_ref_qp_delta != INT16_MIN)
> > +                q->extco2.IntRefQPDelta = q->int_ref_qp_delta;
> >  #if QSV_HAVE_MAX_SLICE_SIZE
> >              if (q->max_slice_size >= 0)
> >                  q->extco2.MaxSliceSize = q->max_slice_size;
> > @@ -973,6 +974,10 @@ static int init_video_param(AVCodecContext
> *avctx,
> > QSVEncContext *q)
> >                  av_log(avctx, AV_LOG_WARNING,
> >                         "Please set max_b_frames(-bf) to 0 to enable P-
> > pyramid\n");
> >              }
> > +#endif
> > +#if QSV_VERSION_ATLEAST(1, 16)
> > +            if (q->int_ref_cycle_dist >= 0)
> > +                q->extco3.IntRefCycleDist = q->int_ref_cycle_dist;
> >  #endif
> >          }
> >
> > diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> > index 65f035045c..5fa0b6f5ba 100644
> > --- a/libavcodec/qsvenc.h
> > +++ b/libavcodec/qsvenc.h
> > @@ -195,6 +195,7 @@ typedef struct QSVEncContext {
> >      int int_ref_type;
> >      int int_ref_cycle_size;
> >      int int_ref_qp_delta;
> > +    int int_ref_cycle_dist;
> >      int recovery_point_sei;
> >
> >      int repeat_pps;
> > diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
> > index 9f127607b7..bec3633268 100644
> > --- a/libavcodec/qsvenc_h264.c
> > +++ b/libavcodec/qsvenc_h264.c
> > @@ -126,13 +126,16 @@ static const AVOption options[] = {
> >      { "4x"                     , NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> > MFX_LOOKAHEAD_DS_4x      }, INT_MIN, INT_MAX,     VE,
> > "look_ahead_downsampling" },
> >  #endif
> >
> > -    { "int_ref_type", "Intra refresh
> > type",                                      OFFSET(qsv.int_ref_type),
> >    AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE, "int_ref_type" },
> > +    { "int_ref_type", "Intra refresh type. B frames should be set to
> > 0.",        OFFSET(qsv.int_ref_type),            AV_OPT_TYPE_INT, { .i64 = -1
> > }, -1, UINT16_MAX, VE, "int_ref_type" },
> >          { "none",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = VE,
> > "int_ref_type" },
> >          { "vertical", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = VE,
> > "int_ref_type" },
> > +        { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .flags =
> > VE, "int_ref_type" },
> >      { "int_ref_cycle_size", "Number of frames in the intra refresh
> > cycle",       OFFSET(qsv.int_ref_cycle_size),      AV_OPT_TYPE_INT, { .i64 =
> > -1 },               -1, UINT16_MAX, VE },
> >      { "int_ref_qp_delta",   "QP difference for the refresh
> > MBs",                 OFFSET(qsv.int_ref_qp_delta),        AV_OPT_TYPE_INT, {
> > .i64 = INT16_MIN }, INT16_MIN,  INT16_MAX, VE },
> >      { "recovery_point_sei", "Insert recovery point SEI
> > messages",                OFFSET(qsv.recovery_point_sei),      AV_OPT_TYPE_INT
> > , { .i64 = -1 },               -1,          1, VE },
> > -
> > +#if QSV_VERSION_ATLEAST(1, 16)
> > +    { "int_ref_cycle_dist",   "Distance between the beginnings of the intra-
> > refresh cycles in
> > frames",  OFFSET(qsv.int_ref_cycle_dist),      AV_OPT_TYPE_INT, { .i64 = -1 },
> > -1, INT16_MAX, VE },
> > +#endif
> >      { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 =
> > MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" },
> >      { "unknown" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> > MFX_PROFILE_UNKNOWN      }, INT_MIN, INT_MAX,     VE, "profile" },
> >      { "baseline", NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> > MFX_PROFILE_AVC_BASELINE }, INT_MIN, INT_MAX,     VE, "profile" },
> > diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
> > index 91a316f9c8..5cac141c4d 100644
> > --- a/libavcodec/qsvenc_hevc.c
> > +++ b/libavcodec/qsvenc_hevc.c
> > @@ -258,6 +258,15 @@ static const AVOption options[] = {
> >  #if QSV_VERSION_ATLEAST(1, 26)
> >      { "transform_skip", "Turn this option ON to enable
> > transformskip",   OFFSET(qsv.transform_skip),          AV_OPT_TYPE_INT,    {
> > .i64 = -1},   -1, 1,  VE},
> >  #endif
> > +    { "int_ref_type", "Intra refresh type. B frames should be set to
> > 0",         OFFSET(qsv.int_ref_type),            AV_OPT_TYPE_INT, { .i64 = -1
> > }, -1, UINT16_MAX, VE, "int_ref_type" },
> > +        { "none",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = VE,
> > "int_ref_type" },
> > +        { "vertical", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = VE,
> > "int_ref_type" },
> > +        { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .flags =
> > VE, "int_ref_type" },
> > +    { "int_ref_cycle_size", "Number of frames in the intra refresh
> > cycle",       OFFSET(qsv.int_ref_cycle_size),      AV_OPT_TYPE_INT, { .i64 =
> > -1 },               -1, UINT16_MAX, VE },
> > +    { "int_ref_qp_delta",   "QP difference for the refresh
> > MBs",                 OFFSET(qsv.int_ref_qp_delta),        AV_OPT_TYPE_INT, {
> > .i64 = INT16_MIN }, INT16_MIN,  INT16_MAX, VE },
> > +#if QSV_VERSION_ATLEAST(1, 16)
> > +    { "int_ref_cycle_dist",   "Distance between the beginnings of the intra-
> > refresh cycles in
> > frames",  OFFSET(qsv.int_ref_cycle_dist),      AV_OPT_TYPE_INT, { .i64 = -1 },
> > -1, INT16_MAX, VE },
> > +#endif
> >
> >      { NULL },
> >  };
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-25  4:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24  2:59 [FFmpeg-devel] [PATCH 1/3] libavcodec/qsvenc: Add max slice size support to hevc_qsv Wenbin Chen
2022-01-24  2:59 ` [FFmpeg-devel] [PATCH 2/3] libavcodec/qsvenc: Add b_strategy option " Wenbin Chen
2022-01-25  3:22   ` Xiang, Haihao
2022-01-24  2:59 ` [FFmpeg-devel] [PATCH 3/3] libavcodec/qsvenc: Add intra refresh to hevc_qsv and add new intra refresh parameter Wenbin Chen
2022-01-25  3:22   ` Xiang, Haihao
2022-01-25  4:59     ` Chen, Wenbin
2022-01-25  3:23 ` [FFmpeg-devel] [PATCH 1/3] libavcodec/qsvenc: Add max slice size support to hevc_qsv Xiang, Haihao

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git