summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorllyyr <llyyr.public@gmail.com>2024-02-19 01:54:29 +0530
committersfan5 <sfan5@live.de>2024-02-19 18:09:58 +0100
commit6a5a3ec3bf27b9ead07f9f83f6ad79d8c9ea9342 (patch)
tree9b57e54329cfd4455bac385dec86032c7852ba35
parent0ef78c1aa54217fcf1fe7553c7f86257259b351b (diff)
downloadmpv-6a5a3ec3bf27b9ead07f9f83f6ad79d8c9ea9342.tar.bz2
mpv-6a5a3ec3bf27b9ead07f9f83f6ad79d8c9ea9342.tar.xz
af_lavcac3enc: don't use deprecated `avcodec_close`
Deprecated upstream https://github.com/FFmpeg/FFmpeg/commit/1cc24d749569a42510399a29b034f7a77bdec34e 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.
-rw-r--r--audio/filter/af_lavcac3enc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/audio/filter/af_lavcac3enc.c b/audio/filter/af_lavcac3enc.c
index b4a1d59fe7..abf67233dc 100644
--- a/audio/filter/af_lavcac3enc.c
+++ b/audio/filter/af_lavcac3enc.c
@@ -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);