PR #24400 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24400 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24400.patch
E-AC3 samples may be comprised of a single independent E-AC3 stream, or they may carry either an AC3 or E-AC3 as the core stream alongside an E-AC3 dependent sub-stream, but none of this is reflected by lavc in any form. The only way to reveal it would be to pass the stream through the eac3_core bsf and look at the output. This commit adds new profile values to signal this. Fixes issue #24390. >From a835edbe76b9ec9d7ad65259be131c57fcfc583d Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Sun, 6 Sep 2026 20:18:25 -0300 Subject: [PATCH] avcodec/ac3dec: add profiles to signal core and dependent streams E-AC3 samples may be comprised of a single independent E-AC3 stream, or they may carry either an AC3 or E-AC3 as the core stream alongside an E-AC3 dependent sub-stream, but none of this is reflected by lavc in any form. The only way to reveal it would be to pass the stream through the eac3_core bsf and look at the output. This commit adds new profile values to signal this. Fixes issue #24390. Signed-off-by: James Almer <[email protected]> --- libavcodec/ac3dec.c | 14 +++++++++++++- libavcodec/ac3dec.h | 1 + libavcodec/defs.h | 3 +++ libavcodec/profiles.c | 5 ++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 79a8751154..90194a274e 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1643,6 +1643,7 @@ dependent_frame: } else { buf += s->frame_size; buf_size -= s->frame_size; + s->prev_bitstream_id = s->bitstream_id; s->prev_output_mode = s->output_mode; s->prev_bit_rate = s->bit_rate; got_independent_frame = 1; @@ -1658,7 +1659,18 @@ skip: if (!err) { avctx->sample_rate = s->sample_rate; avctx->bit_rate = s->bit_rate + s->prev_bit_rate; - avctx->profile = s->eac3_extension_type_a == 1 ? AV_PROFILE_EAC3_DDP_ATMOS : AV_PROFILE_UNKNOWN; + if (s->eac3_extension_type_a == 1) + avctx->profile = AV_PROFILE_EAC3_DDP_ATMOS; + else if (got_independent_frame) { + if (s->prev_bitstream_id <= 10) + avctx->profile = AV_PROFILE_EAC3_DDP_AC3; + else + avctx->profile = AV_PROFILE_EAC3_DDP; + } else if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT || + s->frame_type == EAC3_FRAME_TYPE_AC3_CONVERT) + avctx->profile = AV_PROFILE_EAC3; + else + avctx->profile = AV_PROFILE_UNKNOWN; } if (!avctx->sample_rate) { diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h index 25ce1b1c90..e574db534a 100644 --- a/libavcodec/ac3dec.h +++ b/libavcodec/ac3dec.h @@ -106,6 +106,7 @@ typedef struct AC3DecodeContext { int sample_rate; ///< sample frequency, in Hz int num_blocks; ///< number of audio blocks int bitstream_id; ///< bitstream id (bsid) + int prev_bitstream_id; ///< bitstream id for previous frame int bitstream_mode; ///< bitstream mode (bsmod) int channel_mode; ///< channel mode (acmod) int lfe_on; ///< lfe channel in use diff --git a/libavcodec/defs.h b/libavcodec/defs.h index b13e983b13..c742ae54c7 100644 --- a/libavcodec/defs.h +++ b/libavcodec/defs.h @@ -93,6 +93,9 @@ #define AV_PROFILE_DTS_HD_MA_X 61 #define AV_PROFILE_DTS_HD_MA_X_IMAX 62 +#define AV_PROFILE_EAC3 0 +#define AV_PROFILE_EAC3_DDP 1 +#define AV_PROFILE_EAC3_DDP_AC3 2 #define AV_PROFILE_EAC3_DDP_ATMOS 30 #define AV_PROFILE_TRUEHD_ATMOS 30 diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c index 1b67870c43..dc5b29e4f4 100644 --- a/libavcodec/profiles.c +++ b/libavcodec/profiles.c @@ -50,7 +50,10 @@ const AVProfile ff_dca_profiles[] = { }; const AVProfile ff_eac3_profiles[] = { - { AV_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"}, + { AV_PROFILE_EAC3, "Dolby Digital Plus" }, + { AV_PROFILE_EAC3_DDP, "Dolby Digital Plus + Dolby Digital Plus" }, + { AV_PROFILE_EAC3_DDP_AC3, "Dolby Digital Plus + Dolby Digital" }, + { AV_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos" }, { AV_PROFILE_UNKNOWN }, }; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
