From: Wenbin Chen <wenbin.chen-at-intel.com@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH V3 3/4] libavcodec/qsvenc: Add low latency P-pyramid support to qsv Date: Thu, 13 Jan 2022 13:12:20 +0800 Message-ID: <20220113051221.66453-3-wenbin.chen@intel.com> (raw) In-Reply-To: <20220113051221.66453-1-wenbin.chen@intel.com> Add low latency P-pyramid support to qsv. This feature relates to command line option "-p_strategy". To enable this flag, user also need to set "-bf" to 0. P-strategy has two modes "1-simple" and "2-pyramid". The details of the two models refer to https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#preftype Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> --- doc/encoders.texi | 6 ++++++ libavcodec/qsvenc.c | 36 ++++++++++++++++++++++++++++++++++++ libavcodec/qsvenc.h | 3 +++ 3 files changed, 45 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 6fc94daa11..3d7c944fba 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3296,6 +3296,9 @@ to allow changing of frame type from P and B to I. @item @var{adaptive_b} This flag controls changing of frame type from B to P. +@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. @@ -3394,6 +3397,9 @@ Enable rate distortion optimization. @item @var{max_frame_size} Maximum encoded frame 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{dblk_idc} This option disable deblocking. It has value in range 0~2. diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index e87b69369a..f2ba0241c6 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -315,6 +315,14 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, case MFX_B_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid"); break; default: av_log(avctx, AV_LOG_VERBOSE, "auto"); break; } + + av_log(avctx, AV_LOG_VERBOSE, "; PRefType: "); + switch (co3->PRefType) { + case MFX_P_REF_DEFAULT: av_log(avctx, AV_LOG_VERBOSE, "default"); break; + case MFX_P_REF_SIMPLE: av_log(avctx, AV_LOG_VERBOSE, "simple"); break; + case MFX_P_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid"); break; + default: av_log(avctx, AV_LOG_VERBOSE, "unknown"); break; + } av_log(avctx, AV_LOG_VERBOSE, "\n"); #endif @@ -934,6 +942,34 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) #if QSV_HAVE_CO3 q->extco3.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3; q->extco3.Header.BufferSz = sizeof(q->extco3); + + if (avctx->codec_id == AV_CODEC_ID_HEVC || + avctx->codec_id == AV_CODEC_ID_H264) { +#if QSV_HAVE_PREF + switch (q->p_strategy) { + case 0: + q->extco3.PRefType = MFX_P_REF_DEFAULT; + break; + case 1: + q->extco3.PRefType = MFX_P_REF_SIMPLE; + break; + case 2: + q->extco3.PRefType = MFX_P_REF_PYRAMID; + break; + default: + q->extco3.PRefType = MFX_P_REF_DEFAULT; + av_log(avctx, AV_LOG_WARNING, + "invalid p_strategy, set to default\n"); + break; + } + if (q->extco3.PRefType == MFX_P_REF_PYRAMID && + avctx->max_b_frames != 0) { + av_log(avctx, AV_LOG_WARNING, + "Please set max_b_frames(-bf) to 0 to enable P-pyramid\n"); + } +#endif + } + #if QSV_HAVE_GPB if (avctx->codec_id == AV_CODEC_ID_HEVC) q->extco3.GPB = q->gpb ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index aa49b35f07..960604cb9a 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -51,6 +51,7 @@ #define QSV_HAVE_LA_DS QSV_VERSION_ATLEAST(1, 8) #define QSV_HAVE_LA_HRD QSV_VERSION_ATLEAST(1, 11) #define QSV_HAVE_VDENC QSV_VERSION_ATLEAST(1, 15) +#define QSV_HAVE_PREF QSV_VERSION_ATLEAST(1, 16) #define QSV_HAVE_GPB QSV_VERSION_ATLEAST(1, 18) @@ -95,6 +96,7 @@ { "extbrc", "Extended bitrate control", OFFSET(qsv.extbrc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \ { "adaptive_i", "Adaptive I-frame placement", OFFSET(qsv.adaptive_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \ { "adaptive_b", "Adaptive B-frame placement", OFFSET(qsv.adaptive_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \ +{ "p_strategy", "Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0).", OFFSET(qsv.p_strategy), AV_OPT_TYPE_INT, { .i64 = 0}, 0, 2, VE }, \ { "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(qsv.b_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \ { "forced_idr", "Forcing I frames as IDR frames", OFFSET(qsv.forced_idr), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE }, \ { "low_power", "enable low power mode(experimental: many limitations by mfx version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, VE},\ @@ -187,6 +189,7 @@ typedef struct QSVEncContext { int adaptive_i; int adaptive_b; int b_strategy; + int p_strategy; int cavlc; int int_ref_type; -- 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".
next prev parent reply other threads:[~2022-01-13 5:14 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-13 5:12 [FFmpeg-devel] [PATCH V3 1/4] libavcodec/qsvenc: Add max_frame_size support to hevc_qsv Wenbin Chen 2022-01-13 5:12 ` [FFmpeg-devel] [PATCH V3 2/4] libavcodec/qsvenc: Add DisableDeblockingIdc support to qsv Wenbin Chen 2022-01-13 7:08 ` Xiang, Haihao 2022-01-13 8:16 ` Chen, Wenbin 2022-01-13 5:12 ` Wenbin Chen [this message] 2022-01-13 7:15 ` [FFmpeg-devel] [PATCH V3 3/4] libavcodec/qsvenc: Add low latency P-pyramid " Xiang, Haihao 2022-01-13 5:12 ` [FFmpeg-devel] [PATCH V3 4/4] libavcodec/qsvenc: Add transform skip to hevc_qsv Wenbin Chen 2022-01-13 7:32 ` Xiang, Haihao 2022-01-13 8:18 ` Chen, Wenbin 2022-01-13 7:09 ` [FFmpeg-devel] [PATCH V3 1/4] libavcodec/qsvenc: Add max_frame_size support " Xiang, Haihao
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220113051221.66453-3-wenbin.chen@intel.com \ --to=wenbin.chen-at-intel.com@ffmpeg.org \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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