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/6] libavcodec/qsvenc: Add max_frame_size reset support to qsv
@ 2022-08-18  6:59 Wenbin Chen
  2022-08-18  6:59 ` [FFmpeg-devel] [PATCH 2/6] libavcodec/qsvenc: Add gop_size reset support to qsvenc Wenbin Chen
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Wenbin Chen @ 2022-08-18  6:59 UTC (permalink / raw)
  To: ffmpeg-devel

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

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6d73f74196..69fa46f3ea 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3344,6 +3344,10 @@ Following options can be used durning qsv encoding.
 @item @var{b_quant_offset}
 Supported in h264_qsv and hevc_qsv.
 Change these value to reset qsv codec's qp configuration.
+
+@item @var{max_frame_size}
+Supported in h264_qsv and hevc_qsv.
+Change this value to reset qsv codec's MaxFrameSize configuration.
 @end table
 
 @subsection H264 options
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 4831640868..c911b81e7d 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -828,6 +828,7 @@ 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;
+            q->old_max_frame_size = q->max_frame_size;
             if (q->int_ref_type >= 0)
                 q->extco2.IntRefType = q->int_ref_type;
             if (q->int_ref_cycle_size >= 0)
@@ -1673,6 +1674,24 @@ static int update_qp(AVCodecContext *avctx, QSVEncContext *q)
     return updated;
 }
 
+static int update_max_frame_size(AVCodecContext *avctx, QSVEncContext *q)
+{
+    int updated = 0;
+
+    if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC)
+        return 0;
+
+    UPDATE_PARAM(q->old_max_frame_size, q->max_frame_size);
+    if (!updated)
+        return 0;
+
+    q->extco2.MaxFrameSize  = FFMAX(0, q->max_frame_size);
+    av_log(avctx, AV_LOG_DEBUG,
+           "Reset MaxFrameSize: %d;\n", q->extco2.MaxFrameSize);
+
+    return updated;
+}
+
 static int update_parameters(AVCodecContext *avctx, QSVEncContext *q,
                              const AVFrame *frame)
 {
@@ -1682,6 +1701,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q,
         return 0;
 
     needReset = update_qp(avctx, q);
+    needReset |= update_max_frame_size(avctx, q);
     if (!needReset)
         return 0;
 
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index d35a1318f2..c452c5b806 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -235,6 +235,8 @@ typedef struct QSVEncContext {
     float old_i_quant_offset;
     float old_b_quant_factor;
     float old_b_quant_offset;
+    // This is used for max_frame_size reset
+    int old_max_frame_size;
 } QSVEncContext;
 
 int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q);
-- 
2.32.0

_______________________________________________
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] 8+ messages in thread

end of thread, other threads:[~2022-09-06  8:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18  6:59 [FFmpeg-devel] [PATCH 1/6] libavcodec/qsvenc: Add max_frame_size reset support to qsv Wenbin Chen
2022-08-18  6:59 ` [FFmpeg-devel] [PATCH 2/6] libavcodec/qsvenc: Add gop_size reset support to qsvenc Wenbin Chen
2022-09-06  1:53   ` Xiang, Haihao
2022-09-06  8:44     ` Chen, Wenbin
2022-08-18  6:59 ` [FFmpeg-devel] [PATCH 3/6] libavcodec/qsvenc: Add "slice" intra refresh type " Wenbin Chen
2022-08-18  6:59 ` [FFmpeg-devel] [PATCH 4/6] libavcodec/qsvenc: Add intra refresh reset support " Wenbin Chen
2022-08-18  6:59 ` [FFmpeg-devel] [PATCH 5/6] libavcodec/qsvenc: Add max/min qp reset support in qsvenc Wenbin Chen
2022-08-18  6:59 ` [FFmpeg-devel] [PATCH 6/6] libavcodec/qsvenc: Add low_delay_brc reset support to qsvenc Wenbin Chen

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