Skip to content

Commit

Permalink
[ffNvEnc] Add maximum number of reference frames to encoder configura…
Browse files Browse the repository at this point in the history
…tion

We have no means to let user know if the hardware does not support custom
number of reference frames, so with B-frames enabled, encoder setup may
fail when max refs is set to a non-zero value. Nevertheless, the resulting
video stream will have the necessary number of ref frames. Therefore, the
default is 0 which means automatic.
  • Loading branch information
eumagga0x2a committed Apr 29, 2022
1 parent ef6e4ea commit a379d2c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions avidemux_plugins/ADM_videoEncoder/ffNvEnc/ADM_ffNvEnc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ bool ADM_ffNvEncEncoder::configureContext(void)
_context->rc_max_rate = -1;

_context->gop_size = NvEncSettings.gopsize;
_context->refs = NvEncSettings.refs;
_context->max_b_frames =
#ifdef H265_ENCODER
NvEncSettings.bframes;
Expand Down Expand Up @@ -377,6 +378,7 @@ bool ffNvEncConfigure(void)
diaElemUInteger maxBitrate(PX(max_bitrate),QT_TRANSLATE_NOOP("ffnvenc","Max Bitrate (kbps):"),1,500000);

diaElemUInteger gopSize(PX(gopsize),QT_TRANSLATE_NOOP("ffnvenc","GOP Size:"),0,1000);
diaElemUInteger maxRefs(PX(refs),QT_TRANSLATE_NOOP("ffnvenc","Maximum Reference Frames:"),0,7);
diaElemUInteger maxBframes(PX(bframes),QT_TRANSLATE_NOOP("ffnvenc","Maximum Consecutive B-Frames:"),0,4);

diaElemUInteger lookAhead(PX(lookahead),QT_TRANSLATE_NOOP("ffnvenc","Lookahead:"),0,NV_MX_LOOKAHEAD);
Expand Down Expand Up @@ -417,6 +419,7 @@ bool ffNvEncConfigure(void)
spatAq.link(1,&aqStrength);

frameControl.swallow(&gopSize);
frameControl.swallow(&maxRefs);
frameControl.swallow(&maxBframes);

/* First Tab : basic settings */
Expand Down
1 change: 1 addition & 0 deletions avidemux_plugins/ADM_videoEncoder/ffNvEnc/ADM_ffNvEnc.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ enum FF_NVencBframeRefMode
5000, /* bitrate */ \
10000, /* max_bitrate */ \
100, /* gopsize */ \
0, /* refs */ \
0, /* bframes */ \
2, /* b_ref_mode */ \
0, /* lookahead */ \
Expand Down
1 change: 1 addition & 0 deletions avidemux_plugins/ADM_videoEncoder/ffNvEnc/ffnvenc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ uint32_t:quality
uint32_t:bitrate
uint32_t:max_bitrate
uint32_t:gopsize
uint32_t:refs
uint32_t:bframes
uint32_t:b_ref_mode
uint32_t:lookahead
Expand Down
1 change: 1 addition & 0 deletions avidemux_plugins/ADM_videoEncoder/ffNvEnc/ffnvenc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ uint32_t quality;
uint32_t bitrate;
uint32_t max_bitrate;
uint32_t gopsize;
uint32_t refs;
uint32_t bframes;
uint32_t b_ref_mode;
uint32_t lookahead;
Expand Down
1 change: 1 addition & 0 deletions avidemux_plugins/ADM_videoEncoder/ffNvEnc/ffnvenc_desc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern const ADM_paramList ffnvenc_encoder_param[]={
{"bitrate",offsetof(ffnvenc_encoder,bitrate),"uint32_t",ADM_param_uint32_t},
{"max_bitrate",offsetof(ffnvenc_encoder,max_bitrate),"uint32_t",ADM_param_uint32_t},
{"gopsize",offsetof(ffnvenc_encoder,gopsize),"uint32_t",ADM_param_uint32_t},
{"refs",offsetof(ffnvenc_encoder,refs),"uint32_t",ADM_param_uint32_t},
{"bframes",offsetof(ffnvenc_encoder,bframes),"uint32_t",ADM_param_uint32_t},
{"b_ref_mode",offsetof(ffnvenc_encoder,b_ref_mode),"uint32_t",ADM_param_uint32_t},
{"lookahead",offsetof(ffnvenc_encoder,lookahead),"uint32_t",ADM_param_uint32_t},
Expand Down
1 change: 1 addition & 0 deletions avidemux_plugins/ADM_videoEncoder/ffNvEnc/ffnvenc_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ json.addUint32("quality",key->quality);
json.addUint32("bitrate",key->bitrate);
json.addUint32("max_bitrate",key->max_bitrate);
json.addUint32("gopsize",key->gopsize);
json.addUint32("refs",key->refs);
json.addUint32("bframes",key->bframes);
json.addUint32("b_ref_mode",key->b_ref_mode);
json.addUint32("lookahead",key->lookahead);
Expand Down

0 comments on commit a379d2c

Please sign in to comment.