Skip to content

Commit

Permalink
lavc/qsvenc: enable lookahead for hevc encoding
Browse files Browse the repository at this point in the history
Update version based on the patch:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/[email protected]/

Signed-off-by: Daniel Socek <[email protected]>
Signed-off-by: Haihao Xiang <[email protected]>
Signed-off-by: Zhong Li <[email protected]>
  • Loading branch information
lizhong1008 authored and xhaihao committed Dec 23, 2021
1 parent 0598b38 commit 7e4747e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libavcodec/qsvenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q,
av_log(avctx, AV_LOG_VERBOSE,
"BufferSizeInKB: %"PRIu16"; InitialDelayInKB: %"PRIu16"; TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"; BRCParamMultiplier: %"PRIu16"\n",
info->BufferSizeInKB, info->InitialDelayInKB, info->TargetKbps, info->MaxKbps, info->BRCParamMultiplier);
#if QSV_HAVE_LA
if (info->RateControlMethod == MFX_RATECONTROL_VBR && q->extbrc && q->look_ahead_depth > 0 ) {
av_log(avctx, AV_LOG_VERBOSE, "LookAheadDepth: %"PRIu16"\n",co2->LookAheadDepth);
}
#endif
} else if (info->RateControlMethod == MFX_RATECONTROL_CQP) {
av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: %"PRIu16"\n",
info->QPI, info->QPP, info->QPB);
Expand Down Expand Up @@ -742,6 +747,11 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
switch (q->param.mfx.RateControlMethod) {
case MFX_RATECONTROL_CBR:
case MFX_RATECONTROL_VBR:
#if QSV_HAVE_LA
if (q->extbrc) {
q->extco2.LookAheadDepth = q->look_ahead_depth;
}
#endif
#if QSV_HAVE_VCM
case MFX_RATECONTROL_VCM:
#endif
Expand Down
3 changes: 3 additions & 0 deletions libavcodec/qsvenc_hevc.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ static const AVOption options[] = {
{ "load_plugins", "A :-separate list of hexadecimal plugin UIDs to load in an internal session",
OFFSET(qsv.load_plugins), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VE },

#if QSV_HAVE_LA
{ "look_ahead_depth", "Depth of look ahead in number frames, available when extbrc option is enabled", OFFSET(qsv.look_ahead_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, 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" },
{ "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
Expand Down

0 comments on commit 7e4747e

Please sign in to comment.