History

avcodec/eac3dec: add detection of Atmos spatial extension profile

Marth64 committed 3 years ago

Commit a4e5b941 parent 814178f8 files · +23 −1Browse files

Unified · Split

8 files
  1. libavcodec/ac3dec.c +1 −0
  2. libavcodec/ac3dec.h +1 −0
  3. libavcodec/ac3dec_float.c +2 −0
  4. libavcodec/avcodec.h +2 −0
  5. libavcodec/codec_desc.c +1 −0
  6. libavcodec/eac3dec.c +10 −1
  7. libavcodec/profiles.c +5 −0
  8. libavcodec/profiles.h +1 −0
libavcodec/ac3dec.c+1−0
@@ -1714,6 +1714,7 @@ skip: · 1713 unmodified lines
17141714 if (!err) {
17151715 avctx->sample_rate = s->sample_rate;
17161716 avctx->bit_rate = s->bit_rate + s->prev_bit_rate;
1717+ avctx->profile = s->eac3_extension_type_a == 1 ? FF_PROFILE_EAC3_DDP_ATMOS : FF_PROFILE_UNKNOWN;
17171718 }
17181719
17191720 if (!avctx->sample_rate) {
libavcodec/ac3dec.h+1−0
@@ -102,6 +102,7 @@ typedef struct AC3DecodeContext { · 101 unmodified lines
102102 int eac3; ///< indicates if current frame is E-AC-3
103103 int eac3_frame_dependent_found; ///< bitstream has E-AC-3 dependent frame(s)
104104 int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s)
105+ int eac3_extension_type_a; ///< bitstream has E-AC-3 extension type A enabled frame(s)
105106 int dolby_surround_mode; ///< dolby surround mode (dsurmod)
106107 int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod)
107108 int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod)
libavcodec/ac3dec_float.c+2−0
@@ -33,6 +33,7 @@ · 32 unmodified lines
3333
3434 #include "ac3dec.h"
3535 #include "codec_internal.h"
36+#include "profiles.h"
3637 #include "eac3dec.c"
3738 #include "ac3dec.c"
3839
@@ -92,6 +93,7 @@ const FFCodec ff_eac3_decoder = { · 53 unmodified lines
9293 .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
9394 AV_SAMPLE_FMT_NONE },
9495 .p.priv_class = &ac3_eac3_decoder_class,
96+ .p.profiles = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
9597 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
9698 };
9799 #endif
libavcodec/avcodec.h+2−0
@@ -1591,6 +1591,8 @@ typedef struct AVCodecContext { · 1590 unmodified lines
15911591 #define FF_PROFILE_DTS_HD_MA 60
15921592 #define FF_PROFILE_DTS_EXPRESS 70
15931593
1594+#define FF_PROFILE_EAC3_DDP_ATMOS 30
1595+
15941596 #define FF_PROFILE_MPEG2_422 0
15951597 #define FF_PROFILE_MPEG2_HIGH 1
15961598 #define FF_PROFILE_MPEG2_SS 2
libavcodec/codec_desc.c+1−0
@@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = { · 2930 unmodified lines
29312931 .name = "eac3",
29322932 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
29332933 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
2934+ .profiles = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
29342935 },
29352936 {
29362937 .id = AV_CODEC_ID_SIPR,
libavcodec/eac3dec.c+10−1
@@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s) · 463 unmodified lines
464464 if (get_bits1(gbc)) {
465465 int addbsil = get_bits(gbc, 6);
466466 for (i = 0; i < addbsil + 1; i++) {
467− skip_bits(gbc, 8); // skip additional bit stream info
467+ if (i == 0) {
468+ /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
469+ which can be used to detect Atmos presence */
470+ skip_bits(gbc, 7);
471+ if (get_bits1(gbc)) {
472+ s->eac3_extension_type_a = 1;
473+ }
474+ } else {
475+ skip_bits(gbc, 8); // skip additional bit stream info
476+ }
468477 }
469478 }
470479
libavcodec/profiles.c+5−0
@@ -45,6 +45,11 @@ const AVProfile ff_dca_profiles[] = { · 44 unmodified lines
4545 { FF_PROFILE_UNKNOWN },
4646 };
4747
48+const AVProfile ff_eac3_profiles[] = {
49+ { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"},
50+ { FF_PROFILE_UNKNOWN },
51+};
52+
4853 const AVProfile ff_dnxhd_profiles[] = {
4954 { FF_PROFILE_DNXHD, "DNXHD"},
5055 { FF_PROFILE_DNXHR_LB, "DNXHR LB"},
libavcodec/profiles.h+1−0
@@ -58,6 +58,7 @@ · 57 unmodified lines
5858
5959 extern const AVProfile ff_aac_profiles[];
6060 extern const AVProfile ff_dca_profiles[];
61+extern const AVProfile ff_eac3_profiles[];
6162 extern const AVProfile ff_dnxhd_profiles[];
6263 extern const AVProfile ff_h264_profiles[];
6364 extern const AVProfile ff_hevc_profiles[];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t