diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-04-07 16:52:52 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-04-11 12:53:26 +0200 |
commit | 2fcc50d1f536a76978d39396afb43f885cc89667 (patch) | |
tree | 415464080721ae21e542e20c4c76f3f2e1d86600 /libavcodec/ac3enc.c | |
parent | 1042ee36cd3f7a46ac86bb40d8716912809cdd57 (diff) | |
download | ffmpeg-2fcc50d1f536a76978d39396afb43f885cc89667.tar.gz |
avcodec/ac3enc: Share more code between fixed/float encoders
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r-- | libavcodec/ac3enc.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index c1ac5dd884..e5b0be0969 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -315,7 +315,7 @@ static void validate_mix_level(void *log_ctx, const char *opt_name, * * @param s AC-3 encoder private context */ -int ff_ac3_validate_metadata(AC3EncodeContext *s) +static int ac3_validate_metadata(AC3EncodeContext *s) { AVCodecContext *avctx = s->avctx; AC3EncOptions *opt = &s->options; @@ -488,7 +488,7 @@ int ff_ac3_validate_metadata(AC3EncodeContext *s) * * @param s AC-3 encoder private context */ -void ff_ac3_adjust_frame_size(AC3EncodeContext *s) +static void ac3_adjust_frame_size(AC3EncodeContext *s) { while (s->bits_written >= s->bit_rate && s->samples_written >= s->sample_rate) { s->bits_written -= s->bit_rate; @@ -1984,9 +1984,16 @@ int ff_ac3_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, AC3EncodeContext *const s = avctx->priv_data; int ret; - ret = s->encode_frame(s, frame); - if (ret < 0) - return ret; + if (s->options.allow_per_frame_metadata) { + ret = ac3_validate_metadata(s); + if (ret) + return ret; + } + + if (s->bit_alloc.sr_code == 1 || s->eac3) + ac3_adjust_frame_size(s); + + s->encode_frame(s, frame); ac3_apply_rematrixing(s); @@ -2328,7 +2335,7 @@ static av_cold int validate_options(AC3EncodeContext *s) if (s->cutoff > (s->sample_rate >> 1)) s->cutoff = s->sample_rate >> 1; - ret = ff_ac3_validate_metadata(s); + ret = ac3_validate_metadata(s); if (ret) return ret; |