History

avcodec/dca_xll: add detection of DTS:X and DTS:X IMAX

Marth64 committed 3 years ago

Commit 98a46991 parent 96ed0435 files · +48 −13Browse files

Unified · Split

5 files
  1. libavcodec/avcodec.h +9 −6
  2. libavcodec/dca_syncwords.h +3 −0
  3. libavcodec/dca_xll.c +25 −1
  4. libavcodec/dca_xll.h +3 −0
  5. libavcodec/profiles.c +8 −6
libavcodec/avcodec.h+9−6
@@ -1584,12 +1584,15 @@ typedef struct AVCodecContext { · 1583 unmodified lines
15841584 #define FF_PROFILE_DNXHR_HQX 4
15851585 #define FF_PROFILE_DNXHR_444 5
15861586
1587−#define FF_PROFILE_DTS 20
1588−#define FF_PROFILE_DTS_ES 30
1589−#define FF_PROFILE_DTS_96_24 40
1590−#define FF_PROFILE_DTS_HD_HRA 50
1591−#define FF_PROFILE_DTS_HD_MA 60
1592−#define FF_PROFILE_DTS_EXPRESS 70
1587+#define FF_PROFILE_DTS 20
1588+#define FF_PROFILE_DTS_ES 30
1589+#define FF_PROFILE_DTS_96_24 40
1590+#define FF_PROFILE_DTS_HD_HRA 50
1591+#define FF_PROFILE_DTS_HD_MA 60
1592+#define FF_PROFILE_DTS_EXPRESS 70
1593+#define FF_PROFILE_DTS_HD_MA_X 61
1594+#define FF_PROFILE_DTS_HD_MA_X_IMAX 62
1595+
15931596
15941597 #define FF_PROFILE_EAC3_DDP_ATMOS 30
15951598
libavcodec/dca_syncwords.h+3−0
@@ -33,4 +33,7 @@ · 32 unmodified lines
3333 #define DCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U
3434 #define DCA_SYNCWORD_REV1AUX 0x9A1105A0U
3535
36+#define DCA_SYNCWORD_XLL_X 0x02000850U
37+#define DCA_SYNCWORD_XLL_X_IMAX 0xF14000D0U
38+
3639 #endif /* AVCODEC_DCA_SYNCWORDS_H */
libavcodec/dca_xll.c+25−1
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919 */
2020
21+#include "avcodec.h"
2122 #include "libavutil/channel_layout.h"
2223 #include "dcadec.h"
2324 #include "dcadata.h"
@@ -1054,6 +1055,22 @@ static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssA · 1030 unmodified lines
10541055 return ret;
10551056 if ((ret = parse_band_data(s)) < 0)
10561057 return ret;
1058+
1059+ if (s->frame_size * 8 > FFALIGN(get_bits_count(&s->gb), 32)) {
1060+ unsigned int extradata_syncword;
1061+
1062+ // Align to dword
1063+ skip_bits_long(&s->gb, -get_bits_count(&s->gb) & 31);
1064+
1065+ extradata_syncword = show_bits_long(&s->gb, 32);
1066+
1067+ if (extradata_syncword == DCA_SYNCWORD_XLL_X) {
1068+ s->x_syncword_present = 1;
1069+ } else if ((extradata_syncword >> 1) == (DCA_SYNCWORD_XLL_X_IMAX >> 1)) {
1070+ s->x_imax_syncword_present = 1;
1071+ }
1072+ }
1073+
10571074 if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) {
10581075 av_log(s->avctx, AV_LOG_ERROR, "Read past end of XLL frame\n");
10591076 return AVERROR_INVALIDDATA;
@@ -1428,8 +1445,15 @@ int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame) · 368 unmodified lines
14281445 return AVERROR(EINVAL);
14291446 }
14301447
1448+ if (s->x_imax_syncword_present) {
1449+ avctx->profile = FF_PROFILE_DTS_HD_MA_X_IMAX;
1450+ } else if (s->x_syncword_present) {
1451+ avctx->profile = FF_PROFILE_DTS_HD_MA_X;
1452+ } else {
1453+ avctx->profile = FF_PROFILE_DTS_HD_MA;
1454+ }
1455+
14311456 avctx->bits_per_raw_sample = p->storage_bit_res;
1432− avctx->profile = FF_PROFILE_DTS_HD_MA;
14331457 avctx->bit_rate = 0;
14341458
14351459 frame->nb_samples = nsamples = s->nframesamples << (s->nfreqbands - 1);
libavcodec/dca_xll.h+3−0
@@ -135,6 +135,9 @@ typedef struct DCAXllDecoder { · 134 unmodified lines
135135
136136 DCADSPContext *dcadsp;
137137
138+ int x_syncword_present; ///< Syncword for extension data at end of frame (DTS:X) is present
139+ int x_imax_syncword_present; ///< Syncword for extension data at end of frame (DTS:X IMAX) is present
140+
138141 int output_mask;
139142 int32_t *output_samples[DCA_SPEAKER_COUNT];
140143 } DCAXllDecoder;
libavcodec/profiles.c+8−6
@@ -36,12 +36,14 @@ const AVProfile ff_aac_profiles[] = { · 35 unmodified lines
3636 };
3737
3838 const AVProfile ff_dca_profiles[] = {
39− { FF_PROFILE_DTS, "DTS" },
40− { FF_PROFILE_DTS_ES, "DTS-ES" },
41− { FF_PROFILE_DTS_96_24, "DTS 96/24" },
42− { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
43− { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
44− { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
39+ { FF_PROFILE_DTS, "DTS" },
40+ { FF_PROFILE_DTS_ES, "DTS-ES" },
41+ { FF_PROFILE_DTS_96_24, "DTS 96/24" },
42+ { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
43+ { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
44+ { FF_PROFILE_DTS_HD_MA_X, "DTS-HD MA + DTS:X" },
45+ { FF_PROFILE_DTS_HD_MA_X_IMAX, "DTS-HD MA + DTS:X IMAX" },
46+ { FF_PROFILE_DTS_EXPRESS, "DTS Express" },
4547 { FF_PROFILE_UNKNOWN },
4648 };
4749

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

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

Repository code

Go to file
t