* [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
[not found] <306450>
@ 2023-02-12 0:31 ` Marth64
2023-02-17 10:59 ` Anton Khirnov
2023-02-12 0:52 ` Marth64
` (3 subsequent siblings)
4 siblings, 1 reply; 29+ messages in thread
From: Marth64 @ 2023-02-12 0:31 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marth64
---
- Switched to using profiles for presentation
- Updated IMAX DTS:X syncword for earlier detection
libavcodec/ac3dec.c | 4 ++++
libavcodec/ac3dec.h | 1 +
libavcodec/avcodec.h | 18 ++++++++++++------
libavcodec/codec_desc.c | 2 ++
libavcodec/dca_syncwords.h | 3 +++
libavcodec/dca_xll.c | 24 +++++++++++++++++++++++-
libavcodec/dca_xll.h | 3 +++
libavcodec/eac3dec.c | 11 ++++++++++-
libavcodec/mlpdec.c | 15 +++++++++++++--
libavcodec/profiles.c | 24 ++++++++++++++++++------
libavcodec/profiles.h | 2 ++
11 files changed, 91 insertions(+), 16 deletions(-)
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 0b120e6140..d7070645e6 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -43,6 +43,7 @@
#include "ac3dec.h"
#include "ac3dec_data.h"
#include "ac3defs.h"
+#include "avcodec.h"
#include "decode.h"
#include "kbdwin.h"
@@ -1714,6 +1715,9 @@ skip:
if (!err) {
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate + s->prev_bit_rate;
+
+ if (s->eac3_extension_type_a == 1)
+ avctx->profile = FF_PROFILE_EAC3_DDP_ATMOS;
}
if (!avctx->sample_rate) {
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 138b462abb..0829f4b40d 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -102,6 +102,7 @@ typedef struct AC3DecodeContext {
int eac3; ///< indicates if current frame is E-AC-3
int eac3_frame_dependent_found; ///< bitstream has E-AC-3 dependent frame(s)
int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s)
+ int eac3_extension_type_a; ///< bitstream has E-AC-3 extension type A enabled frame(s)
int dolby_surround_mode; ///< dolby surround mode (dsurmod)
int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod)
int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 755e543fac..2d3a7a4625 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1616,12 +1616,18 @@ typedef struct AVCodecContext {
#define FF_PROFILE_DNXHR_HQX 4
#define FF_PROFILE_DNXHR_444 5
-#define FF_PROFILE_DTS 20
-#define FF_PROFILE_DTS_ES 30
-#define FF_PROFILE_DTS_96_24 40
-#define FF_PROFILE_DTS_HD_HRA 50
-#define FF_PROFILE_DTS_HD_MA 60
-#define FF_PROFILE_DTS_EXPRESS 70
+#define FF_PROFILE_DTS 20
+#define FF_PROFILE_DTS_ES 30
+#define FF_PROFILE_DTS_96_24 40
+#define FF_PROFILE_DTS_HD_HRA 50
+#define FF_PROFILE_DTS_HD_MA 60
+#define FF_PROFILE_DTS_HD_MA_X 61
+#define FF_PROFILE_DTS_HD_MA_X_IMAX 62
+#define FF_PROFILE_DTS_EXPRESS 70
+
+#define FF_PROFILE_EAC3_DDP_ATMOS 30
+
+#define FF_PROFILE_TRUEHD_ATMOS 30
#define FF_PROFILE_MPEG2_422 0
#define FF_PROFILE_MPEG2_HIGH 1
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 57d0f98211..f33bbcd124 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "eac3",
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ .profiles = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
},
{
.id = AV_CODEC_ID_SIPR,
@@ -2959,6 +2960,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "truehd",
.long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
.props = AV_CODEC_PROP_LOSSLESS,
+ .profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
},
{
.id = AV_CODEC_ID_MP4ALS,
diff --git a/libavcodec/dca_syncwords.h b/libavcodec/dca_syncwords.h
index 4d2cd5f56d..200702f89e 100644
--- a/libavcodec/dca_syncwords.h
+++ b/libavcodec/dca_syncwords.h
@@ -33,4 +33,7 @@
#define DCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U
#define DCA_SYNCWORD_REV1AUX 0x9A1105A0U
+#define DCA_SYNCWORD_XLL_X 0x00020008U
+#define DCA_SYNCWORD_XLL_X_IMAX 0x00F14000U
+
#endif /* AVCODEC_DCA_SYNCWORDS_H */
diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
index fe2c766d98..efbbae67f8 100644
--- a/libavcodec/dca_xll.c
+++ b/libavcodec/dca_xll.c
@@ -19,6 +19,7 @@
*/
#include "libavutil/channel_layout.h"
+#include "avcodec.h"
#include "dcadec.h"
#include "dcadata.h"
#include "dcamath.h"
@@ -1043,6 +1044,7 @@ static int parse_band_data(DCAXllDecoder *s)
static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssAsset *asset)
{
int ret;
+ int extradata_peek_pos;
if ((ret = init_get_bits8(&s->gb, data, size)) < 0)
return ret;
@@ -1054,10 +1056,23 @@ static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssA
return ret;
if ((ret = parse_band_data(s)) < 0)
return ret;
+
+ extradata_peek_pos = (get_bits_count(&s->gb) + 31) & ~31;
+ if (s->frame_size * 8 > extradata_peek_pos) {
+ unsigned int extradata_syncword = show_bits_long(&s->gb, 32);
+
+ if (extradata_syncword == DCA_SYNCWORD_XLL_X) {
+ s->x_syncword_present = 1;
+ } else if (extradata_syncword == DCA_SYNCWORD_XLL_X_IMAX) {
+ s->x_imax_syncword_present = 1;
+ }
+ }
+
if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) {
av_log(s->avctx, AV_LOG_ERROR, "Read past end of XLL frame\n");
return AVERROR_INVALIDDATA;
}
+
return ret;
}
@@ -1428,8 +1443,15 @@ int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame)
return AVERROR(EINVAL);
}
+ if (s->x_imax_syncword_present) {
+ avctx->profile = FF_PROFILE_DTS_HD_MA_X_IMAX;
+ } else if (s->x_syncword_present) {
+ avctx->profile = FF_PROFILE_DTS_HD_MA_X;
+ } else {
+ avctx->profile = FF_PROFILE_DTS_HD_MA;
+ }
+
avctx->bits_per_raw_sample = p->storage_bit_res;
- avctx->profile = FF_PROFILE_DTS_HD_MA;
avctx->bit_rate = 0;
frame->nb_samples = nsamples = s->nframesamples << (s->nfreqbands - 1);
diff --git a/libavcodec/dca_xll.h b/libavcodec/dca_xll.h
index d7c1a13ec8..a22bbb8d77 100644
--- a/libavcodec/dca_xll.h
+++ b/libavcodec/dca_xll.h
@@ -135,6 +135,9 @@ typedef struct DCAXllDecoder {
DCADSPContext *dcadsp;
+ int x_syncword_present; ///< Syncword for extension data at end of frame (DTS:X) is present
+ int x_imax_syncword_present; ///< Syncword for extension data at end of frame (DTS:X IMAX) is present
+
int output_mask;
int32_t *output_samples[DCA_SPEAKER_COUNT];
} DCAXllDecoder;
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index deca51dd3d..5c71751a0c 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
if (get_bits1(gbc)) {
int addbsil = get_bits(gbc, 6);
for (i = 0; i < addbsil + 1; i++) {
- skip_bits(gbc, 8); // skip additional bit stream info
+ if (i == 0) {
+ /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
+ which can be used to detect Atmos presence */
+ skip_bits(gbc, 7);
+ if (get_bits1(gbc)) {
+ s->eac3_extension_type_a = 1;
+ }
+ } else {
+ skip_bits(gbc, 8); // skip additional bit stream info
+ }
}
}
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 0ee1f0982c..e95357e35a 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -28,20 +28,21 @@
#include <stdint.h>
-#include "avcodec.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/channel_layout.h"
#include "libavutil/mem_internal.h"
#include "libavutil/thread.h"
#include "libavutil/opt.h"
+#include "avcodec.h"
#include "codec_internal.h"
+#include "config.h"
#include "decode.h"
#include "get_bits.h"
#include "mlp_parse.h"
#include "mlpdsp.h"
#include "mlp.h"
-#include "config.h"
+#include "profiles.h"
/** number of bits used for VLC lookup - longest Huffman code is 9 */
#if ARCH_ARM
@@ -392,6 +393,15 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
m->num_substreams = mh.num_substreams;
m->substream_info = mh.substream_info;
+ /* If there is a 4th substream and the MSB of substream_info is set,
+ * there is a 16-channel spatial presentation (Atmos in TrueHD).
+ */
+ if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD
+ && m->num_substreams == 4
+ && m->substream_info >> 7 == 1) {
+ m->avctx->profile = FF_PROFILE_TRUEHD_ATMOS;
+ }
+
/* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for non-audio data */
m->max_decoded_substream = FFMIN(m->num_substreams - 1, 2);
@@ -1452,5 +1462,6 @@ const FFCodec ff_truehd_decoder = {
FF_CODEC_DECODE_CB(read_access_unit),
.flush = mlp_decode_flush,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
+ .p.profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
};
#endif /* CONFIG_TRUEHD_DECODER */
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..52066185b1 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -36,15 +36,27 @@ const AVProfile ff_aac_profiles[] = {
};
const AVProfile ff_dca_profiles[] = {
- { FF_PROFILE_DTS, "DTS" },
- { FF_PROFILE_DTS_ES, "DTS-ES" },
- { FF_PROFILE_DTS_96_24, "DTS 96/24" },
- { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
- { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
- { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
+ { FF_PROFILE_DTS, "DTS" },
+ { FF_PROFILE_DTS_ES, "DTS-ES" },
+ { FF_PROFILE_DTS_96_24, "DTS 96/24" },
+ { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
+ { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
+ { FF_PROFILE_DTS_HD_MA_X, "DTS-HD MA + DTS:X" },
+ { FF_PROFILE_DTS_HD_MA_X_IMAX, "DTS-HD MA + DTS:X IMAX" },
+ { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
{ FF_PROFILE_UNKNOWN },
};
+const AVProfile ff_eac3_profiles[] = {
+ { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"},
+ { FF_PROFILE_UNKNOWN },
+};
+
+const AVProfile ff_truehd_profiles[] = {
+ { FF_PROFILE_TRUEHD_ATMOS, "Dolby TrueHD + Dolby Atmos"},
+ { FF_PROFILE_UNKNOWN },
+};
+
const AVProfile ff_dnxhd_profiles[] = {
{ FF_PROFILE_DNXHD, "DNXHD"},
{ FF_PROFILE_DNXHR_LB, "DNXHR LB"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 41a19aa9ad..1d523992fc 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -58,6 +58,8 @@
extern const AVProfile ff_aac_profiles[];
extern const AVProfile ff_dca_profiles[];
+extern const AVProfile ff_eac3_profiles[];
+extern const AVProfile ff_truehd_profiles[];
extern const AVProfile ff_dnxhd_profiles[];
extern const AVProfile ff_h264_profiles[];
extern const AVProfile ff_hevc_profiles[];
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
[not found] <306450>
2023-02-12 0:31 ` [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions Marth64
@ 2023-02-12 0:52 ` Marth64
2023-02-16 12:36 ` Hendrik Leppkes
2023-02-17 4:46 ` Marth64
` (2 subsequent siblings)
4 siblings, 1 reply; 29+ messages in thread
From: Marth64 @ 2023-02-12 0:52 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marth64
Signed-off-by: Marth64 <marth64@proxyid.net>
---
- Signed the commit
libavcodec/ac3dec.c | 4 ++++
libavcodec/ac3dec.h | 1 +
libavcodec/avcodec.h | 18 ++++++++++++------
libavcodec/codec_desc.c | 2 ++
libavcodec/dca_syncwords.h | 3 +++
libavcodec/dca_xll.c | 24 +++++++++++++++++++++++-
libavcodec/dca_xll.h | 3 +++
libavcodec/eac3dec.c | 11 ++++++++++-
libavcodec/mlpdec.c | 15 +++++++++++++--
libavcodec/profiles.c | 24 ++++++++++++++++++------
libavcodec/profiles.h | 2 ++
11 files changed, 91 insertions(+), 16 deletions(-)
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 0b120e6140..d7070645e6 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -43,6 +43,7 @@
#include "ac3dec.h"
#include "ac3dec_data.h"
#include "ac3defs.h"
+#include "avcodec.h"
#include "decode.h"
#include "kbdwin.h"
@@ -1714,6 +1715,9 @@ skip:
if (!err) {
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate + s->prev_bit_rate;
+
+ if (s->eac3_extension_type_a == 1)
+ avctx->profile = FF_PROFILE_EAC3_DDP_ATMOS;
}
if (!avctx->sample_rate) {
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 138b462abb..0829f4b40d 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -102,6 +102,7 @@ typedef struct AC3DecodeContext {
int eac3; ///< indicates if current frame is E-AC-3
int eac3_frame_dependent_found; ///< bitstream has E-AC-3 dependent frame(s)
int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s)
+ int eac3_extension_type_a; ///< bitstream has E-AC-3 extension type A enabled frame(s)
int dolby_surround_mode; ///< dolby surround mode (dsurmod)
int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod)
int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 755e543fac..2d3a7a4625 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1616,12 +1616,18 @@ typedef struct AVCodecContext {
#define FF_PROFILE_DNXHR_HQX 4
#define FF_PROFILE_DNXHR_444 5
-#define FF_PROFILE_DTS 20
-#define FF_PROFILE_DTS_ES 30
-#define FF_PROFILE_DTS_96_24 40
-#define FF_PROFILE_DTS_HD_HRA 50
-#define FF_PROFILE_DTS_HD_MA 60
-#define FF_PROFILE_DTS_EXPRESS 70
+#define FF_PROFILE_DTS 20
+#define FF_PROFILE_DTS_ES 30
+#define FF_PROFILE_DTS_96_24 40
+#define FF_PROFILE_DTS_HD_HRA 50
+#define FF_PROFILE_DTS_HD_MA 60
+#define FF_PROFILE_DTS_HD_MA_X 61
+#define FF_PROFILE_DTS_HD_MA_X_IMAX 62
+#define FF_PROFILE_DTS_EXPRESS 70
+
+#define FF_PROFILE_EAC3_DDP_ATMOS 30
+
+#define FF_PROFILE_TRUEHD_ATMOS 30
#define FF_PROFILE_MPEG2_422 0
#define FF_PROFILE_MPEG2_HIGH 1
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 57d0f98211..f33bbcd124 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "eac3",
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ .profiles = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
},
{
.id = AV_CODEC_ID_SIPR,
@@ -2959,6 +2960,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "truehd",
.long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
.props = AV_CODEC_PROP_LOSSLESS,
+ .profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
},
{
.id = AV_CODEC_ID_MP4ALS,
diff --git a/libavcodec/dca_syncwords.h b/libavcodec/dca_syncwords.h
index 4d2cd5f56d..200702f89e 100644
--- a/libavcodec/dca_syncwords.h
+++ b/libavcodec/dca_syncwords.h
@@ -33,4 +33,7 @@
#define DCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U
#define DCA_SYNCWORD_REV1AUX 0x9A1105A0U
+#define DCA_SYNCWORD_XLL_X 0x00020008U
+#define DCA_SYNCWORD_XLL_X_IMAX 0x00F14000U
+
#endif /* AVCODEC_DCA_SYNCWORDS_H */
diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
index fe2c766d98..efbbae67f8 100644
--- a/libavcodec/dca_xll.c
+++ b/libavcodec/dca_xll.c
@@ -19,6 +19,7 @@
*/
#include "libavutil/channel_layout.h"
+#include "avcodec.h"
#include "dcadec.h"
#include "dcadata.h"
#include "dcamath.h"
@@ -1043,6 +1044,7 @@ static int parse_band_data(DCAXllDecoder *s)
static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssAsset *asset)
{
int ret;
+ int extradata_peek_pos;
if ((ret = init_get_bits8(&s->gb, data, size)) < 0)
return ret;
@@ -1054,10 +1056,23 @@ static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssA
return ret;
if ((ret = parse_band_data(s)) < 0)
return ret;
+
+ extradata_peek_pos = (get_bits_count(&s->gb) + 31) & ~31;
+ if (s->frame_size * 8 > extradata_peek_pos) {
+ unsigned int extradata_syncword = show_bits_long(&s->gb, 32);
+
+ if (extradata_syncword == DCA_SYNCWORD_XLL_X) {
+ s->x_syncword_present = 1;
+ } else if (extradata_syncword == DCA_SYNCWORD_XLL_X_IMAX) {
+ s->x_imax_syncword_present = 1;
+ }
+ }
+
if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) {
av_log(s->avctx, AV_LOG_ERROR, "Read past end of XLL frame\n");
return AVERROR_INVALIDDATA;
}
+
return ret;
}
@@ -1428,8 +1443,15 @@ int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame)
return AVERROR(EINVAL);
}
+ if (s->x_imax_syncword_present) {
+ avctx->profile = FF_PROFILE_DTS_HD_MA_X_IMAX;
+ } else if (s->x_syncword_present) {
+ avctx->profile = FF_PROFILE_DTS_HD_MA_X;
+ } else {
+ avctx->profile = FF_PROFILE_DTS_HD_MA;
+ }
+
avctx->bits_per_raw_sample = p->storage_bit_res;
- avctx->profile = FF_PROFILE_DTS_HD_MA;
avctx->bit_rate = 0;
frame->nb_samples = nsamples = s->nframesamples << (s->nfreqbands - 1);
diff --git a/libavcodec/dca_xll.h b/libavcodec/dca_xll.h
index d7c1a13ec8..a22bbb8d77 100644
--- a/libavcodec/dca_xll.h
+++ b/libavcodec/dca_xll.h
@@ -135,6 +135,9 @@ typedef struct DCAXllDecoder {
DCADSPContext *dcadsp;
+ int x_syncword_present; ///< Syncword for extension data at end of frame (DTS:X) is present
+ int x_imax_syncword_present; ///< Syncword for extension data at end of frame (DTS:X IMAX) is present
+
int output_mask;
int32_t *output_samples[DCA_SPEAKER_COUNT];
} DCAXllDecoder;
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index deca51dd3d..5c71751a0c 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
if (get_bits1(gbc)) {
int addbsil = get_bits(gbc, 6);
for (i = 0; i < addbsil + 1; i++) {
- skip_bits(gbc, 8); // skip additional bit stream info
+ if (i == 0) {
+ /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
+ which can be used to detect Atmos presence */
+ skip_bits(gbc, 7);
+ if (get_bits1(gbc)) {
+ s->eac3_extension_type_a = 1;
+ }
+ } else {
+ skip_bits(gbc, 8); // skip additional bit stream info
+ }
}
}
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 0ee1f0982c..e95357e35a 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -28,20 +28,21 @@
#include <stdint.h>
-#include "avcodec.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/channel_layout.h"
#include "libavutil/mem_internal.h"
#include "libavutil/thread.h"
#include "libavutil/opt.h"
+#include "avcodec.h"
#include "codec_internal.h"
+#include "config.h"
#include "decode.h"
#include "get_bits.h"
#include "mlp_parse.h"
#include "mlpdsp.h"
#include "mlp.h"
-#include "config.h"
+#include "profiles.h"
/** number of bits used for VLC lookup - longest Huffman code is 9 */
#if ARCH_ARM
@@ -392,6 +393,15 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
m->num_substreams = mh.num_substreams;
m->substream_info = mh.substream_info;
+ /* If there is a 4th substream and the MSB of substream_info is set,
+ * there is a 16-channel spatial presentation (Atmos in TrueHD).
+ */
+ if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD
+ && m->num_substreams == 4
+ && m->substream_info >> 7 == 1) {
+ m->avctx->profile = FF_PROFILE_TRUEHD_ATMOS;
+ }
+
/* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for non-audio data */
m->max_decoded_substream = FFMIN(m->num_substreams - 1, 2);
@@ -1452,5 +1462,6 @@ const FFCodec ff_truehd_decoder = {
FF_CODEC_DECODE_CB(read_access_unit),
.flush = mlp_decode_flush,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
+ .p.profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
};
#endif /* CONFIG_TRUEHD_DECODER */
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..52066185b1 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -36,15 +36,27 @@ const AVProfile ff_aac_profiles[] = {
};
const AVProfile ff_dca_profiles[] = {
- { FF_PROFILE_DTS, "DTS" },
- { FF_PROFILE_DTS_ES, "DTS-ES" },
- { FF_PROFILE_DTS_96_24, "DTS 96/24" },
- { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
- { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
- { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
+ { FF_PROFILE_DTS, "DTS" },
+ { FF_PROFILE_DTS_ES, "DTS-ES" },
+ { FF_PROFILE_DTS_96_24, "DTS 96/24" },
+ { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
+ { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
+ { FF_PROFILE_DTS_HD_MA_X, "DTS-HD MA + DTS:X" },
+ { FF_PROFILE_DTS_HD_MA_X_IMAX, "DTS-HD MA + DTS:X IMAX" },
+ { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
{ FF_PROFILE_UNKNOWN },
};
+const AVProfile ff_eac3_profiles[] = {
+ { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"},
+ { FF_PROFILE_UNKNOWN },
+};
+
+const AVProfile ff_truehd_profiles[] = {
+ { FF_PROFILE_TRUEHD_ATMOS, "Dolby TrueHD + Dolby Atmos"},
+ { FF_PROFILE_UNKNOWN },
+};
+
const AVProfile ff_dnxhd_profiles[] = {
{ FF_PROFILE_DNXHD, "DNXHD"},
{ FF_PROFILE_DNXHR_LB, "DNXHR LB"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 41a19aa9ad..1d523992fc 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -58,6 +58,8 @@
extern const AVProfile ff_aac_profiles[];
extern const AVProfile ff_dca_profiles[];
+extern const AVProfile ff_eac3_profiles[];
+extern const AVProfile ff_truehd_profiles[];
extern const AVProfile ff_dnxhd_profiles[];
extern const AVProfile ff_h264_profiles[];
extern const AVProfile ff_hevc_profiles[];
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-12 0:52 ` Marth64
@ 2023-02-16 12:36 ` Hendrik Leppkes
2023-02-16 23:20 ` Marth64
0 siblings, 1 reply; 29+ messages in thread
From: Hendrik Leppkes @ 2023-02-16 12:36 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sun, Feb 12, 2023 at 1:53 AM Marth64 <marth64@proxyid.net> wrote:
> diff --git a/libavcodec/dca_syncwords.h b/libavcodec/dca_syncwords.h
> index 4d2cd5f56d..200702f89e 100644
> --- a/libavcodec/dca_syncwords.h
> +++ b/libavcodec/dca_syncwords.h
> @@ -33,4 +33,7 @@
> #define DCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U
> #define DCA_SYNCWORD_REV1AUX 0x9A1105A0U
>
> +#define DCA_SYNCWORD_XLL_X 0x00020008U
> +#define DCA_SYNCWORD_XLL_X_IMAX 0x00F14000U
> +
> #endif /* AVCODEC_DCA_SYNCWORDS_H */
> diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
> index fe2c766d98..efbbae67f8 100644
> --- a/libavcodec/dca_xll.c
> +++ b/libavcodec/dca_xll.c
> @@ -19,6 +19,7 @@
> */
>
> #include "libavutil/channel_layout.h"
> +#include "avcodec.h"
> #include "dcadec.h"
> #include "dcadata.h"
> #include "dcamath.h"
> @@ -1043,6 +1044,7 @@ static int parse_band_data(DCAXllDecoder *s)
> static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssAsset *asset)
> {
> int ret;
> + int extradata_peek_pos;
>
> if ((ret = init_get_bits8(&s->gb, data, size)) < 0)
> return ret;
> @@ -1054,10 +1056,23 @@ static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssA
> return ret;
> if ((ret = parse_band_data(s)) < 0)
> return ret;
> +
> + extradata_peek_pos = (get_bits_count(&s->gb) + 31) & ~31;
> + if (s->frame_size * 8 > extradata_peek_pos) {
> + unsigned int extradata_syncword = show_bits_long(&s->gb, 32);
> +
> + if (extradata_syncword == DCA_SYNCWORD_XLL_X) {
> + s->x_syncword_present = 1;
> + } else if (extradata_syncword == DCA_SYNCWORD_XLL_X_IMAX) {
> + s->x_imax_syncword_present = 1;
> + }
> + }
> +
I was testing this, and the DTS detections were not very reliable for
me. This is what I came up with instead:
#define DCA_SYNCWORD_XLL_X 0x02000850U
#define DCA_SYNCWORD_XLL_X_IMAX 0xF14000D0U
if (s->frame_size * 8 > FFALIGN(get_bits_count(&s->gb), 32)) {
unsigned int extradata_syncword;
// align to dword
skip_bits_long(&s->gb, -get_bits_count(&s->gb) & 31);
// get sync code
extradata_syncword = show_bits_long(&s->gb, 32);
if (extradata_syncword == DCA_SYNCWORD_XLL_X) {
s->x_syncword_present = 1;
} else if ((extradata_syncword >> 1) ==
(DCA_SYNCWORD_XLL_X_IMAX >> 1)) {
s->x_imax_syncword_present = 1;
}
}
I don't have many DTS:X discs, but this worked on them, the old code did not.
Aligning to DWORD for a new section is a typical DTS thing to do,
which then also resulted in the syncwords to shift a bit, and actually
include more digits.
The IMAX case is a bit weird, there seems to be an extra bit in there
thats not stable, so shifting it out improves the detection (or it
could be masked out, but same difference).
- Hendrik
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-16 12:36 ` Hendrik Leppkes
@ 2023-02-16 23:20 ` Marth64
0 siblings, 0 replies; 29+ messages in thread
From: Marth64 @ 2023-02-16 23:20 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Hi Hendrik,
Thank you for taking the time to help me test this. I will verify this as
well on my corpus of 15 or so titles and commit/sign if it passes there
too. Will update within 24.
Respectfully,
Marth64
On Thu, Feb 16, 2023 at 06:37 Hendrik Leppkes <h.leppkes@gmail.com> wrote:
> On Sun, Feb 12, 2023 at 1:53 AM Marth64 <marth64@proxyid.net> wrote:
> > diff --git a/libavcodec/dca_syncwords.h b/libavcodec/dca_syncwords.h
> > index 4d2cd5f56d..200702f89e 100644
> > --- a/libavcodec/dca_syncwords.h
> > +++ b/libavcodec/dca_syncwords.h
> > @@ -33,4 +33,7 @@
> > #define DCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U
> > #define DCA_SYNCWORD_REV1AUX 0x9A1105A0U
> >
> > +#define DCA_SYNCWORD_XLL_X 0x00020008U
> > +#define DCA_SYNCWORD_XLL_X_IMAX 0x00F14000U
> > +
> > #endif /* AVCODEC_DCA_SYNCWORDS_H */
> > diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
> > index fe2c766d98..efbbae67f8 100644
> > --- a/libavcodec/dca_xll.c
> > +++ b/libavcodec/dca_xll.c
> > @@ -19,6 +19,7 @@
> > */
> >
> > #include "libavutil/channel_layout.h"
> > +#include "avcodec.h"
> > #include "dcadec.h"
> > #include "dcadata.h"
> > #include "dcamath.h"
> > @@ -1043,6 +1044,7 @@ static int parse_band_data(DCAXllDecoder *s)
> > static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size,
> DCAExssAsset *asset)
> > {
> > int ret;
> > + int extradata_peek_pos;
> >
> > if ((ret = init_get_bits8(&s->gb, data, size)) < 0)
> > return ret;
> > @@ -1054,10 +1056,23 @@ static int parse_frame(DCAXllDecoder *s, const
> uint8_t *data, int size, DCAExssA
> > return ret;
> > if ((ret = parse_band_data(s)) < 0)
> > return ret;
> > +
> > + extradata_peek_pos = (get_bits_count(&s->gb) + 31) & ~31;
> > + if (s->frame_size * 8 > extradata_peek_pos) {
> > + unsigned int extradata_syncword = show_bits_long(&s->gb, 32);
> > +
> > + if (extradata_syncword == DCA_SYNCWORD_XLL_X) {
> > + s->x_syncword_present = 1;
> > + } else if (extradata_syncword == DCA_SYNCWORD_XLL_X_IMAX) {
> > + s->x_imax_syncword_present = 1;
> > + }
> > + }
> > +
>
>
> I was testing this, and the DTS detections were not very reliable for
> me. This is what I came up with instead:
>
> #define DCA_SYNCWORD_XLL_X 0x02000850U
> #define DCA_SYNCWORD_XLL_X_IMAX 0xF14000D0U
>
>
> if (s->frame_size * 8 > FFALIGN(get_bits_count(&s->gb), 32)) {
> unsigned int extradata_syncword;
>
> // align to dword
> skip_bits_long(&s->gb, -get_bits_count(&s->gb) & 31);
>
> // get sync code
> extradata_syncword = show_bits_long(&s->gb, 32);
>
> if (extradata_syncword == DCA_SYNCWORD_XLL_X) {
> s->x_syncword_present = 1;
> } else if ((extradata_syncword >> 1) ==
> (DCA_SYNCWORD_XLL_X_IMAX >> 1)) {
> s->x_imax_syncword_present = 1;
> }
> }
>
> I don't have many DTS:X discs, but this worked on them, the old code did
> not.
> Aligning to DWORD for a new section is a typical DTS thing to do,
> which then also resulted in the syncwords to shift a bit, and actually
> include more digits.
>
> The IMAX case is a bit weird, there seems to be an extra bit in there
> thats not stable, so shifting it out improves the detection (or it
> could be masked out, but same difference).
>
> - Hendrik
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
[not found] <306450>
2023-02-12 0:31 ` [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions Marth64
2023-02-12 0:52 ` Marth64
@ 2023-02-17 4:46 ` Marth64
2023-02-17 19:46 ` Marth64
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Marth64
4 siblings, 0 replies; 29+ messages in thread
From: Marth64 @ 2023-02-17 4:46 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marth64
Signed-off-by: Marth64 <marth64@proxyid.net>
---
- Align to dword and use more exact syncwords for DTS:X detection
libavcodec/ac3dec.c | 4 ++++
libavcodec/ac3dec.h | 1 +
libavcodec/avcodec.h | 18 ++++++++++++------
libavcodec/codec_desc.c | 2 ++
libavcodec/dca_syncwords.h | 3 +++
libavcodec/dca_xll.c | 27 ++++++++++++++++++++++++++-
libavcodec/dca_xll.h | 3 +++
libavcodec/eac3dec.c | 11 ++++++++++-
libavcodec/mlpdec.c | 15 +++++++++++++--
libavcodec/profiles.c | 24 ++++++++++++++++++------
libavcodec/profiles.h | 2 ++
11 files changed, 94 insertions(+), 16 deletions(-)
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 0b120e6140..d7070645e6 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -43,6 +43,7 @@
#include "ac3dec.h"
#include "ac3dec_data.h"
#include "ac3defs.h"
+#include "avcodec.h"
#include "decode.h"
#include "kbdwin.h"
@@ -1714,6 +1715,9 @@ skip:
if (!err) {
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate + s->prev_bit_rate;
+
+ if (s->eac3_extension_type_a == 1)
+ avctx->profile = FF_PROFILE_EAC3_DDP_ATMOS;
}
if (!avctx->sample_rate) {
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 138b462abb..0829f4b40d 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -102,6 +102,7 @@ typedef struct AC3DecodeContext {
int eac3; ///< indicates if current frame is E-AC-3
int eac3_frame_dependent_found; ///< bitstream has E-AC-3 dependent frame(s)
int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s)
+ int eac3_extension_type_a; ///< bitstream has E-AC-3 extension type A enabled frame(s)
int dolby_surround_mode; ///< dolby surround mode (dsurmod)
int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod)
int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 755e543fac..2d3a7a4625 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1616,12 +1616,18 @@ typedef struct AVCodecContext {
#define FF_PROFILE_DNXHR_HQX 4
#define FF_PROFILE_DNXHR_444 5
-#define FF_PROFILE_DTS 20
-#define FF_PROFILE_DTS_ES 30
-#define FF_PROFILE_DTS_96_24 40
-#define FF_PROFILE_DTS_HD_HRA 50
-#define FF_PROFILE_DTS_HD_MA 60
-#define FF_PROFILE_DTS_EXPRESS 70
+#define FF_PROFILE_DTS 20
+#define FF_PROFILE_DTS_ES 30
+#define FF_PROFILE_DTS_96_24 40
+#define FF_PROFILE_DTS_HD_HRA 50
+#define FF_PROFILE_DTS_HD_MA 60
+#define FF_PROFILE_DTS_HD_MA_X 61
+#define FF_PROFILE_DTS_HD_MA_X_IMAX 62
+#define FF_PROFILE_DTS_EXPRESS 70
+
+#define FF_PROFILE_EAC3_DDP_ATMOS 30
+
+#define FF_PROFILE_TRUEHD_ATMOS 30
#define FF_PROFILE_MPEG2_422 0
#define FF_PROFILE_MPEG2_HIGH 1
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 57d0f98211..f33bbcd124 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "eac3",
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ .profiles = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
},
{
.id = AV_CODEC_ID_SIPR,
@@ -2959,6 +2960,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "truehd",
.long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
.props = AV_CODEC_PROP_LOSSLESS,
+ .profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
},
{
.id = AV_CODEC_ID_MP4ALS,
diff --git a/libavcodec/dca_syncwords.h b/libavcodec/dca_syncwords.h
index 4d2cd5f56d..649bbd90dc 100644
--- a/libavcodec/dca_syncwords.h
+++ b/libavcodec/dca_syncwords.h
@@ -33,4 +33,7 @@
#define DCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U
#define DCA_SYNCWORD_REV1AUX 0x9A1105A0U
+#define DCA_SYNCWORD_XLL_X 0x02000850U
+#define DCA_SYNCWORD_XLL_X_IMAX 0xF14000D0U
+
#endif /* AVCODEC_DCA_SYNCWORDS_H */
diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
index fe2c766d98..802ad1197d 100644
--- a/libavcodec/dca_xll.c
+++ b/libavcodec/dca_xll.c
@@ -19,6 +19,7 @@
*/
#include "libavutil/channel_layout.h"
+#include "avcodec.h"
#include "dcadec.h"
#include "dcadata.h"
#include "dcamath.h"
@@ -1054,10 +1055,27 @@ static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssA
return ret;
if ((ret = parse_band_data(s)) < 0)
return ret;
+
+ if (s->frame_size * 8 > FFALIGN(get_bits_count(&s->gb), 32)) {
+ unsigned int extradata_syncword;
+
+ // Align to dword
+ skip_bits_long(&s->gb, -get_bits_count(&s->gb) & 31);
+
+ extradata_syncword = show_bits_long(&s->gb, 32);
+
+ if (extradata_syncword == DCA_SYNCWORD_XLL_X) {
+ s->x_syncword_present = 1;
+ } else if ((extradata_syncword >> 1) == (DCA_SYNCWORD_XLL_X_IMAX >> 1)) {
+ s->x_imax_syncword_present = 1;
+ }
+ }
+
if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) {
av_log(s->avctx, AV_LOG_ERROR, "Read past end of XLL frame\n");
return AVERROR_INVALIDDATA;
}
+
return ret;
}
@@ -1428,8 +1446,15 @@ int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame)
return AVERROR(EINVAL);
}
+ if (s->x_imax_syncword_present) {
+ avctx->profile = FF_PROFILE_DTS_HD_MA_X_IMAX;
+ } else if (s->x_syncword_present) {
+ avctx->profile = FF_PROFILE_DTS_HD_MA_X;
+ } else {
+ avctx->profile = FF_PROFILE_DTS_HD_MA;
+ }
+
avctx->bits_per_raw_sample = p->storage_bit_res;
- avctx->profile = FF_PROFILE_DTS_HD_MA;
avctx->bit_rate = 0;
frame->nb_samples = nsamples = s->nframesamples << (s->nfreqbands - 1);
diff --git a/libavcodec/dca_xll.h b/libavcodec/dca_xll.h
index d7c1a13ec8..a22bbb8d77 100644
--- a/libavcodec/dca_xll.h
+++ b/libavcodec/dca_xll.h
@@ -135,6 +135,9 @@ typedef struct DCAXllDecoder {
DCADSPContext *dcadsp;
+ int x_syncword_present; ///< Syncword for extension data at end of frame (DTS:X) is present
+ int x_imax_syncword_present; ///< Syncword for extension data at end of frame (DTS:X IMAX) is present
+
int output_mask;
int32_t *output_samples[DCA_SPEAKER_COUNT];
} DCAXllDecoder;
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index deca51dd3d..5c71751a0c 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
if (get_bits1(gbc)) {
int addbsil = get_bits(gbc, 6);
for (i = 0; i < addbsil + 1; i++) {
- skip_bits(gbc, 8); // skip additional bit stream info
+ if (i == 0) {
+ /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
+ which can be used to detect Atmos presence */
+ skip_bits(gbc, 7);
+ if (get_bits1(gbc)) {
+ s->eac3_extension_type_a = 1;
+ }
+ } else {
+ skip_bits(gbc, 8); // skip additional bit stream info
+ }
}
}
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 0ee1f0982c..e95357e35a 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -28,20 +28,21 @@
#include <stdint.h>
-#include "avcodec.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/channel_layout.h"
#include "libavutil/mem_internal.h"
#include "libavutil/thread.h"
#include "libavutil/opt.h"
+#include "avcodec.h"
#include "codec_internal.h"
+#include "config.h"
#include "decode.h"
#include "get_bits.h"
#include "mlp_parse.h"
#include "mlpdsp.h"
#include "mlp.h"
-#include "config.h"
+#include "profiles.h"
/** number of bits used for VLC lookup - longest Huffman code is 9 */
#if ARCH_ARM
@@ -392,6 +393,15 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
m->num_substreams = mh.num_substreams;
m->substream_info = mh.substream_info;
+ /* If there is a 4th substream and the MSB of substream_info is set,
+ * there is a 16-channel spatial presentation (Atmos in TrueHD).
+ */
+ if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD
+ && m->num_substreams == 4
+ && m->substream_info >> 7 == 1) {
+ m->avctx->profile = FF_PROFILE_TRUEHD_ATMOS;
+ }
+
/* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for non-audio data */
m->max_decoded_substream = FFMIN(m->num_substreams - 1, 2);
@@ -1452,5 +1462,6 @@ const FFCodec ff_truehd_decoder = {
FF_CODEC_DECODE_CB(read_access_unit),
.flush = mlp_decode_flush,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
+ .p.profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
};
#endif /* CONFIG_TRUEHD_DECODER */
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..52066185b1 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -36,15 +36,27 @@ const AVProfile ff_aac_profiles[] = {
};
const AVProfile ff_dca_profiles[] = {
- { FF_PROFILE_DTS, "DTS" },
- { FF_PROFILE_DTS_ES, "DTS-ES" },
- { FF_PROFILE_DTS_96_24, "DTS 96/24" },
- { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
- { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
- { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
+ { FF_PROFILE_DTS, "DTS" },
+ { FF_PROFILE_DTS_ES, "DTS-ES" },
+ { FF_PROFILE_DTS_96_24, "DTS 96/24" },
+ { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
+ { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
+ { FF_PROFILE_DTS_HD_MA_X, "DTS-HD MA + DTS:X" },
+ { FF_PROFILE_DTS_HD_MA_X_IMAX, "DTS-HD MA + DTS:X IMAX" },
+ { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
{ FF_PROFILE_UNKNOWN },
};
+const AVProfile ff_eac3_profiles[] = {
+ { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"},
+ { FF_PROFILE_UNKNOWN },
+};
+
+const AVProfile ff_truehd_profiles[] = {
+ { FF_PROFILE_TRUEHD_ATMOS, "Dolby TrueHD + Dolby Atmos"},
+ { FF_PROFILE_UNKNOWN },
+};
+
const AVProfile ff_dnxhd_profiles[] = {
{ FF_PROFILE_DNXHD, "DNXHD"},
{ FF_PROFILE_DNXHR_LB, "DNXHR LB"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 41a19aa9ad..1d523992fc 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -58,6 +58,8 @@
extern const AVProfile ff_aac_profiles[];
extern const AVProfile ff_dca_profiles[];
+extern const AVProfile ff_eac3_profiles[];
+extern const AVProfile ff_truehd_profiles[];
extern const AVProfile ff_dnxhd_profiles[];
extern const AVProfile ff_h264_profiles[];
extern const AVProfile ff_hevc_profiles[];
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-12 0:31 ` [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions Marth64
@ 2023-02-17 10:59 ` Anton Khirnov
2023-02-17 14:51 ` Marth64
0 siblings, 1 reply; 29+ messages in thread
From: Anton Khirnov @ 2023-02-17 10:59 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Marth64
Quoting Marth64 (2023-02-12 01:31:41)
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 755e543fac..2d3a7a4625 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1616,12 +1616,18 @@ typedef struct AVCodecContext {
> #define FF_PROFILE_DNXHR_HQX 4
> #define FF_PROFILE_DNXHR_444 5
>
> -#define FF_PROFILE_DTS 20
> -#define FF_PROFILE_DTS_ES 30
> -#define FF_PROFILE_DTS_96_24 40
> -#define FF_PROFILE_DTS_HD_HRA 50
> -#define FF_PROFILE_DTS_HD_MA 60
> -#define FF_PROFILE_DTS_EXPRESS 70
> +#define FF_PROFILE_DTS 20
> +#define FF_PROFILE_DTS_ES 30
> +#define FF_PROFILE_DTS_96_24 40
> +#define FF_PROFILE_DTS_HD_HRA 50
> +#define FF_PROFILE_DTS_HD_MA 60
> +#define FF_PROFILE_DTS_HD_MA_X 61
> +#define FF_PROFILE_DTS_HD_MA_X_IMAX 62
> +#define FF_PROFILE_DTS_EXPRESS 70
> +
> +#define FF_PROFILE_EAC3_DDP_ATMOS 30
> +
> +#define FF_PROFILE_TRUEHD_ATMOS 30
This is new public API and so needs a minor version bump and an entry in
doc/APIchanges
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-17 10:59 ` Anton Khirnov
@ 2023-02-17 14:51 ` Marth64
2023-02-20 16:41 ` Anton Khirnov
0 siblings, 1 reply; 29+ messages in thread
From: Marth64 @ 2023-02-17 14:51 UTC (permalink / raw)
To: FFmpeg development discussions and patches, Marth64
I can do the doc update, just not sure how to do the version. Is there an
example? (Or is this not something I can do). Thank you!
On Fri, Feb 17, 2023 at 04:59 Anton Khirnov <anton@khirnov.net> wrote:
> Quoting Marth64 (2023-02-12 01:31:41)
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index 755e543fac..2d3a7a4625 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -1616,12 +1616,18 @@ typedef struct AVCodecContext {
> > #define FF_PROFILE_DNXHR_HQX 4
> > #define FF_PROFILE_DNXHR_444 5
> >
> > -#define FF_PROFILE_DTS 20
> > -#define FF_PROFILE_DTS_ES 30
> > -#define FF_PROFILE_DTS_96_24 40
> > -#define FF_PROFILE_DTS_HD_HRA 50
> > -#define FF_PROFILE_DTS_HD_MA 60
> > -#define FF_PROFILE_DTS_EXPRESS 70
> > +#define FF_PROFILE_DTS 20
> > +#define FF_PROFILE_DTS_ES 30
> > +#define FF_PROFILE_DTS_96_24 40
> > +#define FF_PROFILE_DTS_HD_HRA 50
> > +#define FF_PROFILE_DTS_HD_MA 60
> > +#define FF_PROFILE_DTS_HD_MA_X 61
> > +#define FF_PROFILE_DTS_HD_MA_X_IMAX 62
> > +#define FF_PROFILE_DTS_EXPRESS 70
> > +
> > +#define FF_PROFILE_EAC3_DDP_ATMOS 30
> > +
> > +#define FF_PROFILE_TRUEHD_ATMOS 30
>
> This is new public API and so needs a minor version bump and an entry in
> doc/APIchanges
>
> --
> Anton Khirnov
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
[not found] <306450>
` (2 preceding siblings ...)
2023-02-17 4:46 ` Marth64
@ 2023-02-17 19:46 ` Marth64
2023-02-17 22:43 ` James Almer
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Marth64
4 siblings, 1 reply; 29+ messages in thread
From: Marth64 @ 2023-02-17 19:46 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marth64
Signed-off-by: Marth64 <marth64@proxyid.net>
---
Update doc/APIchanges and update libavcodec minor version
doc/APIchanges | 4 ++++
libavcodec/ac3dec.c | 4 ++++
libavcodec/ac3dec.h | 1 +
libavcodec/avcodec.h | 18 ++++++++++++------
libavcodec/codec_desc.c | 2 ++
libavcodec/dca_syncwords.h | 3 +++
libavcodec/dca_xll.c | 27 ++++++++++++++++++++++++++-
libavcodec/dca_xll.h | 3 +++
libavcodec/eac3dec.c | 11 ++++++++++-
libavcodec/mlpdec.c | 15 +++++++++++++--
libavcodec/profiles.c | 24 ++++++++++++++++++------
libavcodec/profiles.h | 2 ++
libavcodec/version.h | 2 +-
13 files changed, 99 insertions(+), 17 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 6baf914760..04dda4132e 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,10 @@ libavutil: 2021-04-27
API changes, most recent first:
+2023-0x-xx - xxxxxxxxxx - lavc 59.64.100
+ Add DCA_SYNCWORD_XLL_X and DCA_SYNCWORD_XLL_X_IMAX syncword constants
+ as part of facilitating DTS:X and DTS:X IMAX detection.
+
2023-0x-xx - xxxxxxxxxx - lavc 59.63.100
Allow AV_CODEC_FLAG_COPY_OPAQUE to be used with decoders.
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 0b120e6140..d7070645e6 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -43,6 +43,7 @@
#include "ac3dec.h"
#include "ac3dec_data.h"
#include "ac3defs.h"
+#include "avcodec.h"
#include "decode.h"
#include "kbdwin.h"
@@ -1714,6 +1715,9 @@ skip:
if (!err) {
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate + s->prev_bit_rate;
+
+ if (s->eac3_extension_type_a == 1)
+ avctx->profile = FF_PROFILE_EAC3_DDP_ATMOS;
}
if (!avctx->sample_rate) {
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 138b462abb..0829f4b40d 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -102,6 +102,7 @@ typedef struct AC3DecodeContext {
int eac3; ///< indicates if current frame is E-AC-3
int eac3_frame_dependent_found; ///< bitstream has E-AC-3 dependent frame(s)
int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s)
+ int eac3_extension_type_a; ///< bitstream has E-AC-3 extension type A enabled frame(s)
int dolby_surround_mode; ///< dolby surround mode (dsurmod)
int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod)
int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 755e543fac..2d3a7a4625 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1616,12 +1616,18 @@ typedef struct AVCodecContext {
#define FF_PROFILE_DNXHR_HQX 4
#define FF_PROFILE_DNXHR_444 5
-#define FF_PROFILE_DTS 20
-#define FF_PROFILE_DTS_ES 30
-#define FF_PROFILE_DTS_96_24 40
-#define FF_PROFILE_DTS_HD_HRA 50
-#define FF_PROFILE_DTS_HD_MA 60
-#define FF_PROFILE_DTS_EXPRESS 70
+#define FF_PROFILE_DTS 20
+#define FF_PROFILE_DTS_ES 30
+#define FF_PROFILE_DTS_96_24 40
+#define FF_PROFILE_DTS_HD_HRA 50
+#define FF_PROFILE_DTS_HD_MA 60
+#define FF_PROFILE_DTS_HD_MA_X 61
+#define FF_PROFILE_DTS_HD_MA_X_IMAX 62
+#define FF_PROFILE_DTS_EXPRESS 70
+
+#define FF_PROFILE_EAC3_DDP_ATMOS 30
+
+#define FF_PROFILE_TRUEHD_ATMOS 30
#define FF_PROFILE_MPEG2_422 0
#define FF_PROFILE_MPEG2_HIGH 1
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 57d0f98211..f33bbcd124 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "eac3",
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ .profiles = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
},
{
.id = AV_CODEC_ID_SIPR,
@@ -2959,6 +2960,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "truehd",
.long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
.props = AV_CODEC_PROP_LOSSLESS,
+ .profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
},
{
.id = AV_CODEC_ID_MP4ALS,
diff --git a/libavcodec/dca_syncwords.h b/libavcodec/dca_syncwords.h
index 4d2cd5f56d..649bbd90dc 100644
--- a/libavcodec/dca_syncwords.h
+++ b/libavcodec/dca_syncwords.h
@@ -33,4 +33,7 @@
#define DCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U
#define DCA_SYNCWORD_REV1AUX 0x9A1105A0U
+#define DCA_SYNCWORD_XLL_X 0x02000850U
+#define DCA_SYNCWORD_XLL_X_IMAX 0xF14000D0U
+
#endif /* AVCODEC_DCA_SYNCWORDS_H */
diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
index fe2c766d98..802ad1197d 100644
--- a/libavcodec/dca_xll.c
+++ b/libavcodec/dca_xll.c
@@ -19,6 +19,7 @@
*/
#include "libavutil/channel_layout.h"
+#include "avcodec.h"
#include "dcadec.h"
#include "dcadata.h"
#include "dcamath.h"
@@ -1054,10 +1055,27 @@ static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssA
return ret;
if ((ret = parse_band_data(s)) < 0)
return ret;
+
+ if (s->frame_size * 8 > FFALIGN(get_bits_count(&s->gb), 32)) {
+ unsigned int extradata_syncword;
+
+ // Align to dword
+ skip_bits_long(&s->gb, -get_bits_count(&s->gb) & 31);
+
+ extradata_syncword = show_bits_long(&s->gb, 32);
+
+ if (extradata_syncword == DCA_SYNCWORD_XLL_X) {
+ s->x_syncword_present = 1;
+ } else if ((extradata_syncword >> 1) == (DCA_SYNCWORD_XLL_X_IMAX >> 1)) {
+ s->x_imax_syncword_present = 1;
+ }
+ }
+
if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) {
av_log(s->avctx, AV_LOG_ERROR, "Read past end of XLL frame\n");
return AVERROR_INVALIDDATA;
}
+
return ret;
}
@@ -1428,8 +1446,15 @@ int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame)
return AVERROR(EINVAL);
}
+ if (s->x_imax_syncword_present) {
+ avctx->profile = FF_PROFILE_DTS_HD_MA_X_IMAX;
+ } else if (s->x_syncword_present) {
+ avctx->profile = FF_PROFILE_DTS_HD_MA_X;
+ } else {
+ avctx->profile = FF_PROFILE_DTS_HD_MA;
+ }
+
avctx->bits_per_raw_sample = p->storage_bit_res;
- avctx->profile = FF_PROFILE_DTS_HD_MA;
avctx->bit_rate = 0;
frame->nb_samples = nsamples = s->nframesamples << (s->nfreqbands - 1);
diff --git a/libavcodec/dca_xll.h b/libavcodec/dca_xll.h
index d7c1a13ec8..a22bbb8d77 100644
--- a/libavcodec/dca_xll.h
+++ b/libavcodec/dca_xll.h
@@ -135,6 +135,9 @@ typedef struct DCAXllDecoder {
DCADSPContext *dcadsp;
+ int x_syncword_present; ///< Syncword for extension data at end of frame (DTS:X) is present
+ int x_imax_syncword_present; ///< Syncword for extension data at end of frame (DTS:X IMAX) is present
+
int output_mask;
int32_t *output_samples[DCA_SPEAKER_COUNT];
} DCAXllDecoder;
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index deca51dd3d..5c71751a0c 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
if (get_bits1(gbc)) {
int addbsil = get_bits(gbc, 6);
for (i = 0; i < addbsil + 1; i++) {
- skip_bits(gbc, 8); // skip additional bit stream info
+ if (i == 0) {
+ /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
+ which can be used to detect Atmos presence */
+ skip_bits(gbc, 7);
+ if (get_bits1(gbc)) {
+ s->eac3_extension_type_a = 1;
+ }
+ } else {
+ skip_bits(gbc, 8); // skip additional bit stream info
+ }
}
}
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 0ee1f0982c..e95357e35a 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -28,20 +28,21 @@
#include <stdint.h>
-#include "avcodec.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/channel_layout.h"
#include "libavutil/mem_internal.h"
#include "libavutil/thread.h"
#include "libavutil/opt.h"
+#include "avcodec.h"
#include "codec_internal.h"
+#include "config.h"
#include "decode.h"
#include "get_bits.h"
#include "mlp_parse.h"
#include "mlpdsp.h"
#include "mlp.h"
-#include "config.h"
+#include "profiles.h"
/** number of bits used for VLC lookup - longest Huffman code is 9 */
#if ARCH_ARM
@@ -392,6 +393,15 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
m->num_substreams = mh.num_substreams;
m->substream_info = mh.substream_info;
+ /* If there is a 4th substream and the MSB of substream_info is set,
+ * there is a 16-channel spatial presentation (Atmos in TrueHD).
+ */
+ if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD
+ && m->num_substreams == 4
+ && m->substream_info >> 7 == 1) {
+ m->avctx->profile = FF_PROFILE_TRUEHD_ATMOS;
+ }
+
/* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for non-audio data */
m->max_decoded_substream = FFMIN(m->num_substreams - 1, 2);
@@ -1452,5 +1462,6 @@ const FFCodec ff_truehd_decoder = {
FF_CODEC_DECODE_CB(read_access_unit),
.flush = mlp_decode_flush,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
+ .p.profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
};
#endif /* CONFIG_TRUEHD_DECODER */
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..52066185b1 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -36,15 +36,27 @@ const AVProfile ff_aac_profiles[] = {
};
const AVProfile ff_dca_profiles[] = {
- { FF_PROFILE_DTS, "DTS" },
- { FF_PROFILE_DTS_ES, "DTS-ES" },
- { FF_PROFILE_DTS_96_24, "DTS 96/24" },
- { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
- { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
- { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
+ { FF_PROFILE_DTS, "DTS" },
+ { FF_PROFILE_DTS_ES, "DTS-ES" },
+ { FF_PROFILE_DTS_96_24, "DTS 96/24" },
+ { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
+ { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
+ { FF_PROFILE_DTS_HD_MA_X, "DTS-HD MA + DTS:X" },
+ { FF_PROFILE_DTS_HD_MA_X_IMAX, "DTS-HD MA + DTS:X IMAX" },
+ { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
{ FF_PROFILE_UNKNOWN },
};
+const AVProfile ff_eac3_profiles[] = {
+ { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"},
+ { FF_PROFILE_UNKNOWN },
+};
+
+const AVProfile ff_truehd_profiles[] = {
+ { FF_PROFILE_TRUEHD_ATMOS, "Dolby TrueHD + Dolby Atmos"},
+ { FF_PROFILE_UNKNOWN },
+};
+
const AVProfile ff_dnxhd_profiles[] = {
{ FF_PROFILE_DNXHD, "DNXHD"},
{ FF_PROFILE_DNXHR_LB, "DNXHR LB"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 41a19aa9ad..1d523992fc 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -58,6 +58,8 @@
extern const AVProfile ff_aac_profiles[];
extern const AVProfile ff_dca_profiles[];
+extern const AVProfile ff_eac3_profiles[];
+extern const AVProfile ff_truehd_profiles[];
extern const AVProfile ff_dnxhd_profiles[];
extern const AVProfile ff_h264_profiles[];
extern const AVProfile ff_hevc_profiles[];
diff --git a/libavcodec/version.h b/libavcodec/version.h
index a80dc4776d..80d3aae05e 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "version_major.h"
-#define LIBAVCODEC_VERSION_MINOR 63
+#define LIBAVCODEC_VERSION_MINOR 64
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-17 19:46 ` Marth64
@ 2023-02-17 22:43 ` James Almer
2023-02-17 23:09 ` Marth64
0 siblings, 1 reply; 29+ messages in thread
From: James Almer @ 2023-02-17 22:43 UTC (permalink / raw)
To: ffmpeg-devel
On 2/17/2023 4:46 PM, Marth64 wrote:
> Signed-off-by: Marth64 <marth64@proxyid.net>
> ---
> Update doc/APIchanges and update libavcodec minor version
>
> doc/APIchanges | 4 ++++
> libavcodec/ac3dec.c | 4 ++++
> libavcodec/ac3dec.h | 1 +
> libavcodec/avcodec.h | 18 ++++++++++++------
> libavcodec/codec_desc.c | 2 ++
> libavcodec/dca_syncwords.h | 3 +++
> libavcodec/dca_xll.c | 27 ++++++++++++++++++++++++++-
> libavcodec/dca_xll.h | 3 +++
> libavcodec/eac3dec.c | 11 ++++++++++-
> libavcodec/mlpdec.c | 15 +++++++++++++--
> libavcodec/profiles.c | 24 ++++++++++++++++++------
> libavcodec/profiles.h | 2 ++
> libavcodec/version.h | 2 +-
> 13 files changed, 99 insertions(+), 17 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 6baf914760..04dda4132e 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -14,6 +14,10 @@ libavutil: 2021-04-27
>
> API changes, most recent first:
>
> +2023-0x-xx - xxxxxxxxxx - lavc 59.64.100
> + Add DCA_SYNCWORD_XLL_X and DCA_SYNCWORD_XLL_X_IMAX syncword constants
> + as part of facilitating DTS:X and DTS:X IMAX detection.
This should mention the new API that's exposed in public headers. In
this case it's the new FF_PROFILE_* defines.
Also, could you split this in three patches? One for DTS, one for EAC3
and one for TrueHD? The order is not important, and the version bump and
the APIChanges entry would then be added in the last patch.
Also, remove the mention about ffprobe since you're not touching it at
all. The new profiles will be reported by any tool that prints them,
like ffmpeg, not just ffprobe.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-17 22:43 ` James Almer
@ 2023-02-17 23:09 ` Marth64
0 siblings, 0 replies; 29+ messages in thread
From: Marth64 @ 2023-02-17 23:09 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Yes will take care of it, np
On Fri, Feb 17, 2023 at 4:42 PM James Almer <jamrial@gmail.com> wrote:
> On 2/17/2023 4:46 PM, Marth64 wrote:
> > Signed-off-by: Marth64 <marth64@proxyid.net>
> > ---
> > Update doc/APIchanges and update libavcodec minor version
> >
> > doc/APIchanges | 4 ++++
> > libavcodec/ac3dec.c | 4 ++++
> > libavcodec/ac3dec.h | 1 +
> > libavcodec/avcodec.h | 18 ++++++++++++------
> > libavcodec/codec_desc.c | 2 ++
> > libavcodec/dca_syncwords.h | 3 +++
> > libavcodec/dca_xll.c | 27 ++++++++++++++++++++++++++-
> > libavcodec/dca_xll.h | 3 +++
> > libavcodec/eac3dec.c | 11 ++++++++++-
> > libavcodec/mlpdec.c | 15 +++++++++++++--
> > libavcodec/profiles.c | 24 ++++++++++++++++++------
> > libavcodec/profiles.h | 2 ++
> > libavcodec/version.h | 2 +-
> > 13 files changed, 99 insertions(+), 17 deletions(-)
> >
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index 6baf914760..04dda4132e 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -14,6 +14,10 @@ libavutil: 2021-04-27
> >
> > API changes, most recent first:
> >
> > +2023-0x-xx - xxxxxxxxxx - lavc 59.64.100
> > + Add DCA_SYNCWORD_XLL_X and DCA_SYNCWORD_XLL_X_IMAX syncword constants
> > + as part of facilitating DTS:X and DTS:X IMAX detection.
>
> This should mention the new API that's exposed in public headers. In
> this case it's the new FF_PROFILE_* defines.
>
> Also, could you split this in three patches? One for DTS, one for EAC3
> and one for TrueHD? The order is not important, and the version bump and
> the APIChanges entry would then be added in the last patch.
> Also, remove the mention about ffprobe since you're not touching it at
> all. The new profiles will be reported by any tool that prints them,
> like ffmpeg, not just ffprobe.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
[not found] <306450>
` (3 preceding siblings ...)
2023-02-17 19:46 ` Marth64
@ 2023-02-18 1:14 ` Marth64
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 2/4] avcodec/mlpdec: add detection of Atmos spatial extension profile in TrueHD Marth64
` (4 more replies)
4 siblings, 5 replies; 29+ messages in thread
From: Marth64 @ 2023-02-18 1:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marth64
Signed-off-by: Marth64 <marth64@proxyid.net>
---
libavcodec/ac3dec.c | 3 +++
libavcodec/ac3dec.h | 1 +
libavcodec/avcodec.h | 2 ++
libavcodec/codec_desc.c | 1 +
libavcodec/eac3dec.c | 11 ++++++++++-
libavcodec/profiles.c | 5 +++++
libavcodec/profiles.h | 1 +
7 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 0b120e6140..8cede139b8 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1714,6 +1714,9 @@ skip:
if (!err) {
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate + s->prev_bit_rate;
+
+ if (s->eac3_extension_type_a == 1)
+ avctx->profile = FF_PROFILE_EAC3_DDP_ATMOS;
}
if (!avctx->sample_rate) {
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 138b462abb..0829f4b40d 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -102,6 +102,7 @@ typedef struct AC3DecodeContext {
int eac3; ///< indicates if current frame is E-AC-3
int eac3_frame_dependent_found; ///< bitstream has E-AC-3 dependent frame(s)
int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s)
+ int eac3_extension_type_a; ///< bitstream has E-AC-3 extension type A enabled frame(s)
int dolby_surround_mode; ///< dolby surround mode (dsurmod)
int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod)
int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 39881a1d2b..0e85dd50a4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1591,6 +1591,8 @@ typedef struct AVCodecContext {
#define FF_PROFILE_DTS_HD_MA 60
#define FF_PROFILE_DTS_EXPRESS 70
+#define FF_PROFILE_EAC3_DDP_ATMOS 30
+
#define FF_PROFILE_MPEG2_422 0
#define FF_PROFILE_MPEG2_HIGH 1
#define FF_PROFILE_MPEG2_SS 2
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 199f62df15..4098d4f5a5 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "eac3",
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ .profiles = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
},
{
.id = AV_CODEC_ID_SIPR,
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index deca51dd3d..5c71751a0c 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
if (get_bits1(gbc)) {
int addbsil = get_bits(gbc, 6);
for (i = 0; i < addbsil + 1; i++) {
- skip_bits(gbc, 8); // skip additional bit stream info
+ if (i == 0) {
+ /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
+ which can be used to detect Atmos presence */
+ skip_bits(gbc, 7);
+ if (get_bits1(gbc)) {
+ s->eac3_extension_type_a = 1;
+ }
+ } else {
+ skip_bits(gbc, 8); // skip additional bit stream info
+ }
}
}
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..343b08f363 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -45,6 +45,11 @@ const AVProfile ff_dca_profiles[] = {
{ FF_PROFILE_UNKNOWN },
};
+const AVProfile ff_eac3_profiles[] = {
+ { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"},
+ { FF_PROFILE_UNKNOWN },
+};
+
const AVProfile ff_dnxhd_profiles[] = {
{ FF_PROFILE_DNXHD, "DNXHD"},
{ FF_PROFILE_DNXHR_LB, "DNXHR LB"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 41a19aa9ad..6ebedbd03f 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -58,6 +58,7 @@
extern const AVProfile ff_aac_profiles[];
extern const AVProfile ff_dca_profiles[];
+extern const AVProfile ff_eac3_profiles[];
extern const AVProfile ff_dnxhd_profiles[];
extern const AVProfile ff_h264_profiles[];
extern const AVProfile ff_hevc_profiles[];
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* [FFmpeg-devel] [PATCH v2 2/4] avcodec/mlpdec: add detection of Atmos spatial extension profile in TrueHD
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Marth64
@ 2023-02-18 1:14 ` Marth64
2023-02-18 16:50 ` Hendrik Leppkes
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 3/4] avcodec/dca_xll: add detection of DTS:X and DTS:X IMAX Marth64
` (3 subsequent siblings)
4 siblings, 1 reply; 29+ messages in thread
From: Marth64 @ 2023-02-18 1:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marth64
Signed-off-by: Marth64 <marth64@proxyid.net>
---
libavcodec/avcodec.h | 2 ++
libavcodec/codec_desc.c | 1 +
libavcodec/mlpdec.c | 11 +++++++++++
libavcodec/profiles.c | 5 +++++
libavcodec/profiles.h | 1 +
5 files changed, 20 insertions(+)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 0e85dd50a4..3feab75741 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1593,6 +1593,8 @@ typedef struct AVCodecContext {
#define FF_PROFILE_EAC3_DDP_ATMOS 30
+#define FF_PROFILE_TRUEHD_ATMOS 30
+
#define FF_PROFILE_MPEG2_422 0
#define FF_PROFILE_MPEG2_HIGH 1
#define FF_PROFILE_MPEG2_SS 2
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 4098d4f5a5..e80ac07700 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2960,6 +2960,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.name = "truehd",
.long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
.props = AV_CODEC_PROP_LOSSLESS,
+ .profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
},
{
.id = AV_CODEC_ID_MP4ALS,
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 0ee1f0982c..85d6207b9c 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -42,6 +42,7 @@
#include "mlpdsp.h"
#include "mlp.h"
#include "config.h"
+#include "profiles.h"
/** number of bits used for VLC lookup - longest Huffman code is 9 */
#if ARCH_ARM
@@ -392,6 +393,15 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
m->num_substreams = mh.num_substreams;
m->substream_info = mh.substream_info;
+ /* If there is a 4th substream and the MSB of substream_info is set,
+ * there is a 16-channel spatial presentation (Atmos in TrueHD).
+ */
+ if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD
+ && m->num_substreams == 4
+ && m->substream_info >> 7 == 1) {
+ m->avctx->profile = FF_PROFILE_TRUEHD_ATMOS;
+ }
+
/* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for non-audio data */
m->max_decoded_substream = FFMIN(m->num_substreams - 1, 2);
@@ -1452,5 +1462,6 @@ const FFCodec ff_truehd_decoder = {
FF_CODEC_DECODE_CB(read_access_unit),
.flush = mlp_decode_flush,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
+ .p.profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
};
#endif /* CONFIG_TRUEHD_DECODER */
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 343b08f363..5bd91d9c5c 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -50,6 +50,11 @@ const AVProfile ff_eac3_profiles[] = {
{ FF_PROFILE_UNKNOWN },
};
+const AVProfile ff_truehd_profiles[] = {
+ { FF_PROFILE_TRUEHD_ATMOS, "Dolby TrueHD + Dolby Atmos"},
+ { FF_PROFILE_UNKNOWN },
+};
+
const AVProfile ff_dnxhd_profiles[] = {
{ FF_PROFILE_DNXHD, "DNXHD"},
{ FF_PROFILE_DNXHR_LB, "DNXHR LB"},
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 6ebedbd03f..1d523992fc 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -59,6 +59,7 @@
extern const AVProfile ff_aac_profiles[];
extern const AVProfile ff_dca_profiles[];
extern const AVProfile ff_eac3_profiles[];
+extern const AVProfile ff_truehd_profiles[];
extern const AVProfile ff_dnxhd_profiles[];
extern const AVProfile ff_h264_profiles[];
extern const AVProfile ff_hevc_profiles[];
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* [FFmpeg-devel] [PATCH v2 3/4] avcodec/dca_xll: add detection of DTS:X and DTS:X IMAX
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Marth64
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 2/4] avcodec/mlpdec: add detection of Atmos spatial extension profile in TrueHD Marth64
@ 2023-02-18 1:14 ` Marth64
2023-02-18 16:46 ` Hendrik Leppkes
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 4/4] avcodec/version: bump minor version to accommodate spatial audio detection Marth64
` (2 subsequent siblings)
4 siblings, 1 reply; 29+ messages in thread
From: Marth64 @ 2023-02-18 1:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marth64
Signed-off-by: Marth64 <marth64@proxyid.net>
---
libavcodec/avcodec.h | 15 +++++++++------
libavcodec/dca_syncwords.h | 3 +++
libavcodec/dca_xll.c | 26 +++++++++++++++++++++++++-
libavcodec/dca_xll.h | 3 +++
libavcodec/profiles.c | 14 ++++++++------
5 files changed, 48 insertions(+), 13 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3feab75741..363f895302 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1584,12 +1584,15 @@ typedef struct AVCodecContext {
#define FF_PROFILE_DNXHR_HQX 4
#define FF_PROFILE_DNXHR_444 5
-#define FF_PROFILE_DTS 20
-#define FF_PROFILE_DTS_ES 30
-#define FF_PROFILE_DTS_96_24 40
-#define FF_PROFILE_DTS_HD_HRA 50
-#define FF_PROFILE_DTS_HD_MA 60
-#define FF_PROFILE_DTS_EXPRESS 70
+#define FF_PROFILE_DTS 20
+#define FF_PROFILE_DTS_ES 30
+#define FF_PROFILE_DTS_96_24 40
+#define FF_PROFILE_DTS_HD_HRA 50
+#define FF_PROFILE_DTS_HD_MA 60
+#define FF_PROFILE_DTS_EXPRESS 70
+#define FF_PROFILE_DTS_HD_MA_X 61
+#define FF_PROFILE_DTS_HD_MA_X_IMAX 62
+
#define FF_PROFILE_EAC3_DDP_ATMOS 30
diff --git a/libavcodec/dca_syncwords.h b/libavcodec/dca_syncwords.h
index 4d2cd5f56d..649bbd90dc 100644
--- a/libavcodec/dca_syncwords.h
+++ b/libavcodec/dca_syncwords.h
@@ -33,4 +33,7 @@
#define DCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U
#define DCA_SYNCWORD_REV1AUX 0x9A1105A0U
+#define DCA_SYNCWORD_XLL_X 0x02000850U
+#define DCA_SYNCWORD_XLL_X_IMAX 0xF14000D0U
+
#endif /* AVCODEC_DCA_SYNCWORDS_H */
diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
index fe2c766d98..b8cf37a35f 100644
--- a/libavcodec/dca_xll.c
+++ b/libavcodec/dca_xll.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "avcodec.h"
#include "libavutil/channel_layout.h"
#include "dcadec.h"
#include "dcadata.h"
@@ -1054,6 +1055,22 @@ static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssA
return ret;
if ((ret = parse_band_data(s)) < 0)
return ret;
+
+ if (s->frame_size * 8 > FFALIGN(get_bits_count(&s->gb), 32)) {
+ unsigned int extradata_syncword;
+
+ // Align to dword
+ skip_bits_long(&s->gb, -get_bits_count(&s->gb) & 31);
+
+ extradata_syncword = show_bits_long(&s->gb, 32);
+
+ if (extradata_syncword == DCA_SYNCWORD_XLL_X) {
+ s->x_syncword_present = 1;
+ } else if ((extradata_syncword >> 1) == (DCA_SYNCWORD_XLL_X_IMAX >> 1)) {
+ s->x_imax_syncword_present = 1;
+ }
+ }
+
if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) {
av_log(s->avctx, AV_LOG_ERROR, "Read past end of XLL frame\n");
return AVERROR_INVALIDDATA;
@@ -1428,8 +1445,15 @@ int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame)
return AVERROR(EINVAL);
}
+ if (s->x_imax_syncword_present) {
+ avctx->profile = FF_PROFILE_DTS_HD_MA_X_IMAX;
+ } else if (s->x_syncword_present) {
+ avctx->profile = FF_PROFILE_DTS_HD_MA_X;
+ } else {
+ avctx->profile = FF_PROFILE_DTS_HD_MA;
+ }
+
avctx->bits_per_raw_sample = p->storage_bit_res;
- avctx->profile = FF_PROFILE_DTS_HD_MA;
avctx->bit_rate = 0;
frame->nb_samples = nsamples = s->nframesamples << (s->nfreqbands - 1);
diff --git a/libavcodec/dca_xll.h b/libavcodec/dca_xll.h
index d7c1a13ec8..a22bbb8d77 100644
--- a/libavcodec/dca_xll.h
+++ b/libavcodec/dca_xll.h
@@ -135,6 +135,9 @@ typedef struct DCAXllDecoder {
DCADSPContext *dcadsp;
+ int x_syncword_present; ///< Syncword for extension data at end of frame (DTS:X) is present
+ int x_imax_syncword_present; ///< Syncword for extension data at end of frame (DTS:X IMAX) is present
+
int output_mask;
int32_t *output_samples[DCA_SPEAKER_COUNT];
} DCAXllDecoder;
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 5bd91d9c5c..52066185b1 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -36,12 +36,14 @@ const AVProfile ff_aac_profiles[] = {
};
const AVProfile ff_dca_profiles[] = {
- { FF_PROFILE_DTS, "DTS" },
- { FF_PROFILE_DTS_ES, "DTS-ES" },
- { FF_PROFILE_DTS_96_24, "DTS 96/24" },
- { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
- { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
- { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
+ { FF_PROFILE_DTS, "DTS" },
+ { FF_PROFILE_DTS_ES, "DTS-ES" },
+ { FF_PROFILE_DTS_96_24, "DTS 96/24" },
+ { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
+ { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
+ { FF_PROFILE_DTS_HD_MA_X, "DTS-HD MA + DTS:X" },
+ { FF_PROFILE_DTS_HD_MA_X_IMAX, "DTS-HD MA + DTS:X IMAX" },
+ { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
{ FF_PROFILE_UNKNOWN },
};
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* [FFmpeg-devel] [PATCH v2 4/4] avcodec/version: bump minor version to accommodate spatial audio detection
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Marth64
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 2/4] avcodec/mlpdec: add detection of Atmos spatial extension profile in TrueHD Marth64
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 3/4] avcodec/dca_xll: add detection of DTS:X and DTS:X IMAX Marth64
@ 2023-02-18 1:14 ` Marth64
2023-02-18 16:45 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Hendrik Leppkes
2023-02-18 16:46 ` Hendrik Leppkes
4 siblings, 0 replies; 29+ messages in thread
From: Marth64 @ 2023-02-18 1:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marth64
Signed-off-by: Marth64 <marth64@proxyid.net>
---
doc/APIchanges | 6 ++++++
libavcodec/version.h | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 29161e30bf..35ff906662 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,12 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
+2023-02-xx - xxxxxxxxxx - lavc 60.3.100 - profiles.h dca_syncwords.h
+ Add ff_eac3_profiles and ff_truehd_profiles in profiles.h to accomodate
+ awareness of Atmos in EAC3/TrueHD.
+ Add DCA_SYNCWORD_XLL_X and DCA_SYNCWORD_XLL_X_IMAX syncword constants
+ as part of facilitating DTS:X and DTS:X IMAX detection.
+
2023-02-16 - xxxxxxxxxx - lavf 60.2.100 - avformat.h
Deprecate AVFormatContext io_close callback.
The superior io_close2 callback should be used instead.
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 0550d7b0d8..43794ea588 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "version_major.h"
-#define LIBAVCODEC_VERSION_MINOR 2
+#define LIBAVCODEC_VERSION_MINOR 3
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Marth64
` (2 preceding siblings ...)
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 4/4] avcodec/version: bump minor version to accommodate spatial audio detection Marth64
@ 2023-02-18 16:45 ` Hendrik Leppkes
2023-02-18 16:46 ` Hendrik Leppkes
4 siblings, 0 replies; 29+ messages in thread
From: Hendrik Leppkes @ 2023-02-18 16:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sat, Feb 18, 2023 at 2:15 AM Marth64 <marth64@proxyid.net> wrote:
>
> Signed-off-by: Marth64 <marth64@proxyid.net>
> ---
> libavcodec/ac3dec.c | 3 +++
> libavcodec/ac3dec.h | 1 +
> libavcodec/avcodec.h | 2 ++
> libavcodec/codec_desc.c | 1 +
> libavcodec/eac3dec.c | 11 ++++++++++-
> libavcodec/profiles.c | 5 +++++
> libavcodec/profiles.h | 1 +
> 7 files changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
> index 0b120e6140..8cede139b8 100644
> --- a/libavcodec/ac3dec.c
> +++ b/libavcodec/ac3dec.c
> @@ -1714,6 +1714,9 @@ skip:
> if (!err) {
> avctx->sample_rate = s->sample_rate;
> avctx->bit_rate = s->bit_rate + s->prev_bit_rate;
> +
> + if (s->eac3_extension_type_a == 1)
> + avctx->profile = FF_PROFILE_EAC3_DDP_ATMOS;
> }
This should probably be something like:
avctx->profile = s->eac3_extension_type_a == 1 ?
FF_PROFILE_EAC3_DDP_ATMOS : FF_PROFILE_UNKNOWN;
This way the profile is properly reset when there is no extension (anymore).
>
> if (!avctx->sample_rate) {
> diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
> index 138b462abb..0829f4b40d 100644
> --- a/libavcodec/ac3dec.h
> +++ b/libavcodec/ac3dec.h
> @@ -102,6 +102,7 @@ typedef struct AC3DecodeContext {
> int eac3; ///< indicates if current frame is E-AC-3
> int eac3_frame_dependent_found; ///< bitstream has E-AC-3 dependent frame(s)
> int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s)
> + int eac3_extension_type_a; ///< bitstream has E-AC-3 extension type A enabled frame(s)
> int dolby_surround_mode; ///< dolby surround mode (dsurmod)
> int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod)
> int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod)
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 39881a1d2b..0e85dd50a4 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1591,6 +1591,8 @@ typedef struct AVCodecContext {
> #define FF_PROFILE_DTS_HD_MA 60
> #define FF_PROFILE_DTS_EXPRESS 70
>
> +#define FF_PROFILE_EAC3_DDP_ATMOS 30
> +
> #define FF_PROFILE_MPEG2_422 0
> #define FF_PROFILE_MPEG2_HIGH 1
> #define FF_PROFILE_MPEG2_SS 2
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index 199f62df15..4098d4f5a5 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
> .name = "eac3",
> .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
> .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
> + .profiles = NULL_IF_CONFIG_SMALL(ff_eac3_profiles),
> },
> {
> .id = AV_CODEC_ID_SIPR,
> diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
> index deca51dd3d..5c71751a0c 100644
> --- a/libavcodec/eac3dec.c
> +++ b/libavcodec/eac3dec.c
> @@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
> if (get_bits1(gbc)) {
> int addbsil = get_bits(gbc, 6);
> for (i = 0; i < addbsil + 1; i++) {
> - skip_bits(gbc, 8); // skip additional bit stream info
> + if (i == 0) {
> + /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
> + which can be used to detect Atmos presence */
> + skip_bits(gbc, 7);
> + if (get_bits1(gbc)) {
> + s->eac3_extension_type_a = 1;
> + }
> + } else {
> + skip_bits(gbc, 8); // skip additional bit stream info
> + }
> }
> }
>
> diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
> index 7af7fbeb13..343b08f363 100644
> --- a/libavcodec/profiles.c
> +++ b/libavcodec/profiles.c
> @@ -45,6 +45,11 @@ const AVProfile ff_dca_profiles[] = {
> { FF_PROFILE_UNKNOWN },
> };
>
> +const AVProfile ff_eac3_profiles[] = {
> + { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + Dolby Atmos"},
> + { FF_PROFILE_UNKNOWN },
> +};
> +
> const AVProfile ff_dnxhd_profiles[] = {
> { FF_PROFILE_DNXHD, "DNXHD"},
> { FF_PROFILE_DNXHR_LB, "DNXHR LB"},
> diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
> index 41a19aa9ad..6ebedbd03f 100644
> --- a/libavcodec/profiles.h
> +++ b/libavcodec/profiles.h
> @@ -58,6 +58,7 @@
>
> extern const AVProfile ff_aac_profiles[];
> extern const AVProfile ff_dca_profiles[];
> +extern const AVProfile ff_eac3_profiles[];
> extern const AVProfile ff_dnxhd_profiles[];
> extern const AVProfile ff_h264_profiles[];
> extern const AVProfile ff_hevc_profiles[];
> --
> 2.25.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Marth64
` (3 preceding siblings ...)
2023-02-18 16:45 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Hendrik Leppkes
@ 2023-02-18 16:46 ` Hendrik Leppkes
4 siblings, 0 replies; 29+ messages in thread
From: Hendrik Leppkes @ 2023-02-18 16:46 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sat, Feb 18, 2023 at 2:15 AM Marth64 <marth64@proxyid.net> wrote:
>
> Signed-off-by: Marth64 <marth64@proxyid.net>
> ---
Another thing I noticed, you should add the profiles to the eac3
decoder AVCodec in ac3_float.c
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 3/4] avcodec/dca_xll: add detection of DTS:X and DTS:X IMAX
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 3/4] avcodec/dca_xll: add detection of DTS:X and DTS:X IMAX Marth64
@ 2023-02-18 16:46 ` Hendrik Leppkes
0 siblings, 0 replies; 29+ messages in thread
From: Hendrik Leppkes @ 2023-02-18 16:46 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sat, Feb 18, 2023 at 2:15 AM Marth64 <marth64@proxyid.net> wrote:
>
> Signed-off-by: Marth64 <marth64@proxyid.net>
> ---
> libavcodec/avcodec.h | 15 +++++++++------
> libavcodec/dca_syncwords.h | 3 +++
> libavcodec/dca_xll.c | 26 +++++++++++++++++++++++++-
> libavcodec/dca_xll.h | 3 +++
> libavcodec/profiles.c | 14 ++++++++------
> 5 files changed, 48 insertions(+), 13 deletions(-)
>
LGTM
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/4] avcodec/mlpdec: add detection of Atmos spatial extension profile in TrueHD
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 2/4] avcodec/mlpdec: add detection of Atmos spatial extension profile in TrueHD Marth64
@ 2023-02-18 16:50 ` Hendrik Leppkes
2023-02-18 17:22 ` Marth64
0 siblings, 1 reply; 29+ messages in thread
From: Hendrik Leppkes @ 2023-02-18 16:50 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sat, Feb 18, 2023 at 2:15 AM Marth64 <marth64@proxyid.net> wrote:
>
> Signed-off-by: Marth64 <marth64@proxyid.net>
> ---
> libavcodec/avcodec.h | 2 ++
> libavcodec/codec_desc.c | 1 +
> libavcodec/mlpdec.c | 11 +++++++++++
> libavcodec/profiles.c | 5 +++++
> libavcodec/profiles.h | 1 +
> 5 files changed, 20 insertions(+)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 0e85dd50a4..3feab75741 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1593,6 +1593,8 @@ typedef struct AVCodecContext {
>
> #define FF_PROFILE_EAC3_DDP_ATMOS 30
>
> +#define FF_PROFILE_TRUEHD_ATMOS 30
> +
> #define FF_PROFILE_MPEG2_422 0
> #define FF_PROFILE_MPEG2_HIGH 1
> #define FF_PROFILE_MPEG2_SS 2
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index 4098d4f5a5..e80ac07700 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -2960,6 +2960,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
> .name = "truehd",
> .long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
> .props = AV_CODEC_PROP_LOSSLESS,
> + .profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
> },
> {
> .id = AV_CODEC_ID_MP4ALS,
> diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
> index 0ee1f0982c..85d6207b9c 100644
> --- a/libavcodec/mlpdec.c
> +++ b/libavcodec/mlpdec.c
> @@ -42,6 +42,7 @@
> #include "mlpdsp.h"
> #include "mlp.h"
> #include "config.h"
> +#include "profiles.h"
>
> /** number of bits used for VLC lookup - longest Huffman code is 9 */
> #if ARCH_ARM
> @@ -392,6 +393,15 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
> m->num_substreams = mh.num_substreams;
> m->substream_info = mh.substream_info;
>
> + /* If there is a 4th substream and the MSB of substream_info is set,
> + * there is a 16-channel spatial presentation (Atmos in TrueHD).
> + */
> + if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD
> + && m->num_substreams == 4
> + && m->substream_info >> 7 == 1) {
> + m->avctx->profile = FF_PROFILE_TRUEHD_ATMOS;
> + }
> +
Nit: maybe put the if into two lines instead of three? The two
substream checks look like they should fit in one line quite well. But
this is just a style question, so feel free to ignore.
Otherwise LGTM
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/4] avcodec/mlpdec: add detection of Atmos spatial extension profile in TrueHD
2023-02-18 16:50 ` Hendrik Leppkes
@ 2023-02-18 17:22 ` Marth64
0 siblings, 0 replies; 29+ messages in thread
From: Marth64 @ 2023-02-18 17:22 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Good nit. Fix on the way,
On Sat, Feb 18, 2023 at 10:50 AM Hendrik Leppkes <h.leppkes@gmail.com>
wrote:
> On Sat, Feb 18, 2023 at 2:15 AM Marth64 <marth64@proxyid.net> wrote:
> >
> > Signed-off-by: Marth64 <marth64@proxyid.net>
> > ---
> > libavcodec/avcodec.h | 2 ++
> > libavcodec/codec_desc.c | 1 +
> > libavcodec/mlpdec.c | 11 +++++++++++
> > libavcodec/profiles.c | 5 +++++
> > libavcodec/profiles.h | 1 +
> > 5 files changed, 20 insertions(+)
> >
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index 0e85dd50a4..3feab75741 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -1593,6 +1593,8 @@ typedef struct AVCodecContext {
> >
> > #define FF_PROFILE_EAC3_DDP_ATMOS 30
> >
> > +#define FF_PROFILE_TRUEHD_ATMOS 30
> > +
> > #define FF_PROFILE_MPEG2_422 0
> > #define FF_PROFILE_MPEG2_HIGH 1
> > #define FF_PROFILE_MPEG2_SS 2
> > diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> > index 4098d4f5a5..e80ac07700 100644
> > --- a/libavcodec/codec_desc.c
> > +++ b/libavcodec/codec_desc.c
> > @@ -2960,6 +2960,7 @@ static const AVCodecDescriptor codec_descriptors[]
> = {
> > .name = "truehd",
> > .long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
> > .props = AV_CODEC_PROP_LOSSLESS,
> > + .profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
> > },
> > {
> > .id = AV_CODEC_ID_MP4ALS,
> > diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
> > index 0ee1f0982c..85d6207b9c 100644
> > --- a/libavcodec/mlpdec.c
> > +++ b/libavcodec/mlpdec.c
> > @@ -42,6 +42,7 @@
> > #include "mlpdsp.h"
> > #include "mlp.h"
> > #include "config.h"
> > +#include "profiles.h"
> >
> > /** number of bits used for VLC lookup - longest Huffman code is 9 */
> > #if ARCH_ARM
> > @@ -392,6 +393,15 @@ static int read_major_sync(MLPDecodeContext *m,
> GetBitContext *gb)
> > m->num_substreams = mh.num_substreams;
> > m->substream_info = mh.substream_info;
> >
> > + /* If there is a 4th substream and the MSB of substream_info is
> set,
> > + * there is a 16-channel spatial presentation (Atmos in TrueHD).
> > + */
> > + if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD
> > + && m->num_substreams == 4
> > + && m->substream_info >> 7 == 1) {
> > + m->avctx->profile = FF_PROFILE_TRUEHD_ATMOS;
> > + }
> > +
>
> Nit: maybe put the if into two lines instead of three? The two
> substream checks look like they should fit in one line quite well. But
> this is just a style question, so feel free to ignore.
>
> Otherwise LGTM
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-17 14:51 ` Marth64
@ 2023-02-20 16:41 ` Anton Khirnov
2023-02-20 16:57 ` Marth64
0 siblings, 1 reply; 29+ messages in thread
From: Anton Khirnov @ 2023-02-20 16:41 UTC (permalink / raw)
To: FFmpeg development discussions and patches, Marth64
Quoting Marth64 (2023-02-17 15:51:09)
> I can do the doc update, just not sure how to do the version. Is there an
> example? (Or is this not something I can do). Thank you!
Just increase the minor version number in libavcodec/version.h
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-20 16:41 ` Anton Khirnov
@ 2023-02-20 16:57 ` Marth64
2023-03-10 2:17 ` Marth64
0 siblings, 1 reply; 29+ messages in thread
From: Marth64 @ 2023-02-20 16:57 UTC (permalink / raw)
To: FFmpeg development discussions and patches, Marth64
Thank you,
It’s done in v2 set
On Mon, Feb 20, 2023 at 10:41 Anton Khirnov <anton@khirnov.net> wrote:
> Quoting Marth64 (2023-02-17 15:51:09)
> > I can do the doc update, just not sure how to do the version. Is there an
> > example? (Or is this not something I can do). Thank you!
>
> Just increase the minor version number in libavcodec/version.h
>
> --
> Anton Khirnov
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-20 16:57 ` Marth64
@ 2023-03-10 2:17 ` Marth64
2023-03-10 11:53 ` Hendrik Leppkes
0 siblings, 1 reply; 29+ messages in thread
From: Marth64 @ 2023-03-10 2:17 UTC (permalink / raw)
To: Marth64; +Cc: FFmpeg development discussions and patches
Hi,
If there is still interest I can refine this to match the latest ffmpeg
branch. Thank you!
On Mon, Feb 20, 2023 at 10:57 AM Marth64 <marth64@proxyid.net> wrote:
> Thank you,
> It’s done in v2 set
>
> On Mon, Feb 20, 2023 at 10:41 Anton Khirnov <anton@khirnov.net> wrote:
>
>> Quoting Marth64 (2023-02-17 15:51:09)
>> > I can do the doc update, just not sure how to do the version. Is there
>> an
>> > example? (Or is this not something I can do). Thank you!
>>
>> Just increase the minor version number in libavcodec/version.h
>>
>> --
>> Anton Khirnov
>>
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-03-10 2:17 ` Marth64
@ 2023-03-10 11:53 ` Hendrik Leppkes
2023-03-10 22:00 ` Marth64
0 siblings, 1 reply; 29+ messages in thread
From: Hendrik Leppkes @ 2023-03-10 11:53 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, Mar 10, 2023 at 3:18 AM Marth64 <marth64@proxyid.net> wrote:
>
> Hi,
>
> If there is still interest I can refine this to match the latest ffmpeg
> branch. Thank you!
>
>
Your patches have already been merged to git master.
- Hendrik
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-03-10 11:53 ` Hendrik Leppkes
@ 2023-03-10 22:00 ` Marth64
0 siblings, 0 replies; 29+ messages in thread
From: Marth64 @ 2023-03-10 22:00 UTC (permalink / raw)
To: FFmpeg development discussions and patches
I didn't know that. Thank you so much for your guidance along the way!
Cheers
On Fri, Mar 10, 2023 at 5:53 AM Hendrik Leppkes <h.leppkes@gmail.com> wrote:
> On Fri, Mar 10, 2023 at 3:18 AM Marth64 <marth64@proxyid.net> wrote:
> >
> > Hi,
> >
> > If there is still interest I can refine this to match the latest ffmpeg
> > branch. Thank you!
> >
> >
>
> Your patches have already been merged to git master.
>
> - Hendrik
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-09 22:34 ` Michael Niedermayer
@ 2023-02-10 0:07 ` Marth64
0 siblings, 0 replies; 29+ messages in thread
From: Marth64 @ 2023-02-10 0:07 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Ack'd. Nice catch. Thank you!
On Thu, Feb 9, 2023 at 4:35 PM Michael Niedermayer <michael@niedermayer.cc>
wrote:
> On Wed, Feb 08, 2023 at 10:41:00PM -0600, Marth64 wrote:
> > Signed-off-by: Marth64 <marth64@proxyid.net>
> > ---
> > Adds detection of spatial/object-based audio extensions in E-AC-3,
> > TrueHD, and DCA XLL (DTS). This includes Atmos, DTS:X, and IMAX formats.
> > Please let me know what I could improve, I'm learning still.
> > Thank you.
> [...]
> > @@ -1054,10 +1055,23 @@ static int parse_frame(DCAXllDecoder *s, const
> uint8_t *data, int size, DCAExssA
> > return ret;
> > if ((ret = parse_band_data(s)) < 0)
> > return ret;
> > +
> > + extradata_peek_pos = (get_bits_count(&s->gb) + 31) & ~31;
> > + if (s->frame_size * 8 > extradata_peek_pos) {
> > + unsigned int extradata_syncword = show_bits(&s->gb, 32);
>
> show_bits_long()
>
>
> [..]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The misfortune of the wise is better than the prosperity of the fool.
> -- Epicurus
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-09 20:12 ` Hendrik Leppkes
@ 2023-02-10 0:03 ` Marth64
0 siblings, 0 replies; 29+ messages in thread
From: Marth64 @ 2023-02-10 0:03 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Hi,
Thank you for your time and thoughts. Some of this I had wondered about the
same.
Re: Hendrik, Using profile >
This was an original intention of mine but I changed course. I'm happy to
do it, but felt too unsure for a first pass.
My reasoning being that I'm not sure if the presence of extension metadata
itself qualifies as a discrete profile. For DCA in particular, I was
worried since DCA already expands to profiles (ES, XLL, etc.). I did not
want to clutter those distinctions with a "somewhat profile of a profile,
based on an educated guess without the reference docs" and break any
existing integrations. Likewise, EAC3 and TrueHD didn't have profiles, so
it felt tacked on for this case. So I settled with "extension" as the
marker. That said, I wasn't too thrilled about adding to AVCodecContext
either. I discovered and considered priv_data but then realized that this
is a pattern across 3 codecs, maybe more in the future. So definitely open
to guidance here. Profile is probably the next best bet.
I had gone down the frame-level inspection road at some point, but came to
a similar conclusion as you, it makes this less useful as a feature.
I am open to other's interpretation. Will ponder this a little more.
Re: Michael, show_bits_long >
Will fix. I am trying to procure another IMAX DTS material to test the
syncword better, so will push any of those changes together in the next 2
days.
Thank you!
On Thu, Feb 9, 2023 at 2:12 PM Hendrik Leppkes <h.leppkes@gmail.com> wrote:
> On Thu, Feb 9, 2023 at 5:42 AM Marth64 <marth64@proxyid.net> wrote:
> >
> > Signed-off-by: Marth64 <marth64@proxyid.net>
> > ---
> > Adds detection of spatial/object-based audio extensions in E-AC-3,
> > TrueHD, and DCA XLL (DTS). This includes Atmos, DTS:X, and IMAX formats.
> > Please let me know what I could improve, I'm learning still.
> > Thank you.
> >
>
> The detection itself seems fine to me, however we should talk about
> how the presence is communicated back to the user.
>
> A new flag in AVCodecContext goes against a variety of designs we try
> to avoid - namely having codec-specific things in a global struct, as
> well as having only one value, rather then per-frame values.
>
> So options that present themself to me:
> (a) Use "profile". At least for DTS that would fit quite nicely, as it
> already has profiles, and it seems like a logical extension. TrueHD
> and eac3 do not have profiles, but it might still be sensible to put
> it there. The advantage here is that it also automatically is conveyed
> in AVCodecParameters after avformat opens a stream, so the information
> is available early and lets players decide how to handle the stream.
> (b) Use per-frame side data. The early-availability advantage is not
> present here, so its not my favorite. side-data could be used in the
> future to transport the actual object metadata, if needed.
>
> So from where I'm standing we should maybe define profiles to use for
> these. In the past profiles were at least suggested for TrueHD Atmos
> before, but there were some objections, so maybe a good time to
> revisit and see where we go from here.
>
> - Hendrik
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-09 4:41 [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions Marth64
2023-02-09 20:12 ` Hendrik Leppkes
@ 2023-02-09 22:34 ` Michael Niedermayer
2023-02-10 0:07 ` Marth64
1 sibling, 1 reply; 29+ messages in thread
From: Michael Niedermayer @ 2023-02-09 22:34 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 932 bytes --]
On Wed, Feb 08, 2023 at 10:41:00PM -0600, Marth64 wrote:
> Signed-off-by: Marth64 <marth64@proxyid.net>
> ---
> Adds detection of spatial/object-based audio extensions in E-AC-3,
> TrueHD, and DCA XLL (DTS). This includes Atmos, DTS:X, and IMAX formats.
> Please let me know what I could improve, I'm learning still.
> Thank you.
[...]
> @@ -1054,10 +1055,23 @@ static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssA
> return ret;
> if ((ret = parse_band_data(s)) < 0)
> return ret;
> +
> + extradata_peek_pos = (get_bits_count(&s->gb) + 31) & ~31;
> + if (s->frame_size * 8 > extradata_peek_pos) {
> + unsigned int extradata_syncword = show_bits(&s->gb, 32);
show_bits_long()
[..]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
2023-02-09 4:41 [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions Marth64
@ 2023-02-09 20:12 ` Hendrik Leppkes
2023-02-10 0:03 ` Marth64
2023-02-09 22:34 ` Michael Niedermayer
1 sibling, 1 reply; 29+ messages in thread
From: Hendrik Leppkes @ 2023-02-09 20:12 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, Feb 9, 2023 at 5:42 AM Marth64 <marth64@proxyid.net> wrote:
>
> Signed-off-by: Marth64 <marth64@proxyid.net>
> ---
> Adds detection of spatial/object-based audio extensions in E-AC-3,
> TrueHD, and DCA XLL (DTS). This includes Atmos, DTS:X, and IMAX formats.
> Please let me know what I could improve, I'm learning still.
> Thank you.
>
The detection itself seems fine to me, however we should talk about
how the presence is communicated back to the user.
A new flag in AVCodecContext goes against a variety of designs we try
to avoid - namely having codec-specific things in a global struct, as
well as having only one value, rather then per-frame values.
So options that present themself to me:
(a) Use "profile". At least for DTS that would fit quite nicely, as it
already has profiles, and it seems like a logical extension. TrueHD
and eac3 do not have profiles, but it might still be sensible to put
it there. The advantage here is that it also automatically is conveyed
in AVCodecParameters after avformat opens a stream, so the information
is available early and lets players decide how to handle the stream.
(b) Use per-frame side data. The early-availability advantage is not
present here, so its not my favorite. side-data could be used in the
future to transport the actual object metadata, if needed.
So from where I'm standing we should maybe define profiles to use for
these. In the past profiles were at least suggested for TrueHD Atmos
before, but there were some objections, so maybe a good time to
revisit and see where we go from here.
- Hendrik
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
* [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions
@ 2023-02-09 4:41 Marth64
2023-02-09 20:12 ` Hendrik Leppkes
2023-02-09 22:34 ` Michael Niedermayer
0 siblings, 2 replies; 29+ messages in thread
From: Marth64 @ 2023-02-09 4:41 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marth64
Signed-off-by: Marth64 <marth64@proxyid.net>
---
Adds detection of spatial/object-based audio extensions in E-AC-3,
TrueHD, and DCA XLL (DTS). This includes Atmos, DTS:X, and IMAX formats.
Please let me know what I could improve, I'm learning still.
Thank you.
doc/ffprobe.xsd | 1 +
fftools/ffprobe.c | 3 +++
libavcodec/ac3dec.c | 1 +
libavcodec/ac3dec.h | 1 +
libavcodec/avcodec.h | 6 ++++++
libavcodec/codec_par.c | 2 ++
libavcodec/codec_par.h | 6 ++++++
libavcodec/dca_syncwords.h | 3 +++
libavcodec/dca_xll.c | 14 ++++++++++++++
libavcodec/eac3dec.c | 11 ++++++++++-
libavcodec/mlpdec.c | 9 +++++++++
11 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd
index 0920380108..a01a4359dc 100644
--- a/doc/ffprobe.xsd
+++ b/doc/ffprobe.xsd
@@ -247,6 +247,7 @@
<xsd:attribute name="channel_layout" type="xsd:string"/>
<xsd:attribute name="bits_per_sample" type="xsd:int"/>
<xsd:attribute name="initial_padding" type="xsd:int"/>
+ <xsd:attribute name="spatial_ext" type="xsd:boolean"/>
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="r_frame_rate" type="xsd:string" use="required"/>
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index dfa7ff1b24..7e81088c56 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3071,6 +3071,9 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id));
print_int("initial_padding", par->initial_padding);
+ if (par->spatial_ext > 0) {
+ print_int("spatial_ext", par->spatial_ext);
+ }
break;
case AVMEDIA_TYPE_SUBTITLE:
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 0b120e6140..009acd9ff6 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1714,6 +1714,7 @@ skip:
if (!err) {
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate + s->prev_bit_rate;
+ avctx->spatial_ext = s->eac3_extension_type_a == 1;
}
if (!avctx->sample_rate) {
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 138b462abb..0829f4b40d 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -102,6 +102,7 @@ typedef struct AC3DecodeContext {
int eac3; ///< indicates if current frame is E-AC-3
int eac3_frame_dependent_found; ///< bitstream has E-AC-3 dependent frame(s)
int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s)
+ int eac3_extension_type_a; ///< bitstream has E-AC-3 extension type A enabled frame(s)
int dolby_surround_mode; ///< dolby surround mode (dsurmod)
int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod)
int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 755e543fac..8b54a99313 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2104,6 +2104,12 @@ typedef struct AVCodecContext {
* The decoder can then override during decoding as needed.
*/
AVChannelLayout ch_layout;
+
+ /**
+ * Audio only. Whether or not a spatial audio extension is
+ * detected in the stream (object-based surround).
+ */
+ int spatial_ext;
} AVCodecContext;
/**
diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c
index abda649aa8..02f6da5059 100644
--- a/libavcodec/codec_par.c
+++ b/libavcodec/codec_par.c
@@ -161,6 +161,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
par->initial_padding = codec->initial_padding;
par->trailing_padding = codec->trailing_padding;
par->seek_preroll = codec->seek_preroll;
+ par->spatial_ext = codec->spatial_ext;
break;
case AVMEDIA_TYPE_SUBTITLE:
par->width = codec->width;
@@ -243,6 +244,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
codec->initial_padding = par->initial_padding;
codec->trailing_padding = par->trailing_padding;
codec->seek_preroll = par->seek_preroll;
+ codec->spatial_ext = par->spatial_ext;
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = par->width;
diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h
index f51d27c590..287b138b6b 100644
--- a/libavcodec/codec_par.h
+++ b/libavcodec/codec_par.h
@@ -211,6 +211,12 @@ typedef struct AVCodecParameters {
* Audio only. The channel layout and number of channels.
*/
AVChannelLayout ch_layout;
+
+ /**
+ * Audio only. Whether or not a spatial audio extension is
+ * detected in the stream (object-based surround).
+ */
+ int spatial_ext;
} AVCodecParameters;
/**
diff --git a/libavcodec/dca_syncwords.h b/libavcodec/dca_syncwords.h
index 4d2cd5f56d..ccbc38bb38 100644
--- a/libavcodec/dca_syncwords.h
+++ b/libavcodec/dca_syncwords.h
@@ -33,4 +33,7 @@
#define DCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U
#define DCA_SYNCWORD_REV1AUX 0x9A1105A0U
+#define DCA_SYNCWORD_XLL_X 0x20008
+#define DCA_SYNCWORD_XLL_IMAX (0xF14000D0 >> 1)
+
#endif /* AVCODEC_DCA_SYNCWORDS_H */
diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
index fe2c766d98..6b64f907cc 100644
--- a/libavcodec/dca_xll.c
+++ b/libavcodec/dca_xll.c
@@ -1043,6 +1043,7 @@ static int parse_band_data(DCAXllDecoder *s)
static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssAsset *asset)
{
int ret;
+ int extradata_peek_pos;
if ((ret = init_get_bits8(&s->gb, data, size)) < 0)
return ret;
@@ -1054,10 +1055,23 @@ static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssA
return ret;
if ((ret = parse_band_data(s)) < 0)
return ret;
+
+ extradata_peek_pos = (get_bits_count(&s->gb) + 31) & ~31;
+ if (s->frame_size * 8 > extradata_peek_pos) {
+ unsigned int extradata_syncword = show_bits(&s->gb, 32);
+
+ if (extradata_syncword == DCA_SYNCWORD_XLL_X) {
+ s->avctx->spatial_ext = 1;
+ } else if ((extradata_syncword >> 1) == DCA_SYNCWORD_XLL_IMAX) {
+ s->avctx->spatial_ext = 1;
+ }
+ }
+
if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) {
av_log(s->avctx, AV_LOG_ERROR, "Read past end of XLL frame\n");
return AVERROR_INVALIDDATA;
}
+
return ret;
}
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index deca51dd3d..5c71751a0c 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
if (get_bits1(gbc)) {
int addbsil = get_bits(gbc, 6);
for (i = 0; i < addbsil + 1; i++) {
- skip_bits(gbc, 8); // skip additional bit stream info
+ if (i == 0) {
+ /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a
+ which can be used to detect Atmos presence */
+ skip_bits(gbc, 7);
+ if (get_bits1(gbc)) {
+ s->eac3_extension_type_a = 1;
+ }
+ } else {
+ skip_bits(gbc, 8); // skip additional bit stream info
+ }
}
}
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 0ee1f0982c..547e68342e 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -392,6 +392,15 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
m->num_substreams = mh.num_substreams;
m->substream_info = mh.substream_info;
+ /* If there is a 4th substream and the MSB of substream_info is set,
+ * there is a 16-channel spatial presentation (Atmos in TrueHD).
+ */
+ if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD
+ && m->num_substreams == 4
+ && m->substream_info >> 7 == 1) {
+ m->avctx->spatial_ext = 1;
+ }
+
/* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for non-audio data */
m->max_decoded_substream = FFMIN(m->num_substreams - 1, 2);
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2023-03-10 22:01 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <306450>
2023-02-12 0:31 ` [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions Marth64
2023-02-17 10:59 ` Anton Khirnov
2023-02-17 14:51 ` Marth64
2023-02-20 16:41 ` Anton Khirnov
2023-02-20 16:57 ` Marth64
2023-03-10 2:17 ` Marth64
2023-03-10 11:53 ` Hendrik Leppkes
2023-03-10 22:00 ` Marth64
2023-02-12 0:52 ` Marth64
2023-02-16 12:36 ` Hendrik Leppkes
2023-02-16 23:20 ` Marth64
2023-02-17 4:46 ` Marth64
2023-02-17 19:46 ` Marth64
2023-02-17 22:43 ` James Almer
2023-02-17 23:09 ` Marth64
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Marth64
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 2/4] avcodec/mlpdec: add detection of Atmos spatial extension profile in TrueHD Marth64
2023-02-18 16:50 ` Hendrik Leppkes
2023-02-18 17:22 ` Marth64
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 3/4] avcodec/dca_xll: add detection of DTS:X and DTS:X IMAX Marth64
2023-02-18 16:46 ` Hendrik Leppkes
2023-02-18 1:14 ` [FFmpeg-devel] [PATCH v2 4/4] avcodec/version: bump minor version to accommodate spatial audio detection Marth64
2023-02-18 16:45 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile Hendrik Leppkes
2023-02-18 16:46 ` Hendrik Leppkes
2023-02-09 4:41 [FFmpeg-devel] [PATCH] ffprobe/eac3/mlp/dca: add detection of spatial audio extensions Marth64
2023-02-09 20:12 ` Hendrik Leppkes
2023-02-10 0:03 ` Marth64
2023-02-09 22:34 ` Michael Niedermayer
2023-02-10 0:07 ` Marth64
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git