af_lavcac3enc: don't use deprecated `avcodec_close`

Deprecated upstream 1cc24d7495

We need to reallocate the context here because `avcodec_free_context`
also frees the context, and we want to reuse the context with some
reconfig.
This commit is contained in:
llyyr 2024-02-19 01:54:29 +05:30 committed by sfan5
parent 0ef78c1aa5
commit 6a5a3ec3bf
1 changed files with 9 additions and 1 deletions

View File

@ -103,7 +103,15 @@ static bool reinit(struct mp_filter *f)
if (!bit_rate && chmap.num < AC3_MAX_CHANNELS + 1)
bit_rate = default_bit_rate[chmap.num];
avcodec_close(s->lavc_actx);
avcodec_free_context(&s->lavc_actx);
s->lavc_actx = avcodec_alloc_context3(s->lavc_acodec);
if (!s->lavc_actx) {
MP_ERR(f, "Audio LAVC, couldn't reallocate context!\n");
return false;
}
if (mp_set_avopts(f->log, s->lavc_actx, s->opts->avopts) < 0)
return false;
// Put sample parameters
s->lavc_actx->sample_fmt = af_to_avformat(format);