Skip to content

Commit 2562dd9

Browse files
committed
vaapi_encode: Always reapply global parameters after the sequence header
The codec sequence headers may contain fields which can overwrite the fine parameters given in the specific settings (e.g. a crude bitrate value vs. the max-rate / target-percentage / etc. values in VAEncMiscParameterRateControl). Always reapply all global parameters after a sequence header to avoid this causing problems.
1 parent ac31d84 commit 2562dd9

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

libavcodec/vaapi_encode.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,16 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
207207

208208
pic->nb_param_buffers = 0;
209209

210-
if (pic->encode_order == 0) {
211-
// Global parameter buffers are set on the first picture only.
210+
if (pic->type == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) {
211+
err = vaapi_encode_make_param_buffer(avctx, pic,
212+
VAEncSequenceParameterBufferType,
213+
ctx->codec_sequence_params,
214+
ctx->codec->sequence_params_size);
215+
if (err < 0)
216+
goto fail;
217+
}
212218

219+
if (pic->type == PICTURE_TYPE_IDR) {
213220
for (i = 0; i < ctx->nb_global_params; i++) {
214221
err = vaapi_encode_make_param_buffer(avctx, pic,
215222
VAEncMiscParameterBufferType,
@@ -220,15 +227,6 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
220227
}
221228
}
222229

223-
if (pic->type == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) {
224-
err = vaapi_encode_make_param_buffer(avctx, pic,
225-
VAEncSequenceParameterBufferType,
226-
ctx->codec_sequence_params,
227-
ctx->codec->sequence_params_size);
228-
if (err < 0)
229-
goto fail;
230-
}
231-
232230
if (ctx->codec->init_picture_params) {
233231
err = ctx->codec->init_picture_params(avctx, pic);
234232
if (err < 0) {

0 commit comments

Comments
 (0)