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
1584#define FF_PROFILE_DNXHR_HQX 41584#define FF_PROFILE_DNXHR_HQX 4
1585#define FF_PROFILE_DNXHR_444 51585#define FF_PROFILE_DNXHR_444 5
1586 1586
1587#define FF_PROFILE_DTS 201587#define FF_PROFILE_DTS 20
1588#define FF_PROFILE_DTS_ES 301588#define FF_PROFILE_DTS_ES 30
1589#define FF_PROFILE_DTS_96_24 401589#define FF_PROFILE_DTS_96_24 40
1590#define FF_PROFILE_DTS_HD_HRA 501590#define FF_PROFILE_DTS_HD_HRA 50
1591#define FF_PROFILE_DTS_HD_MA 601591#define FF_PROFILE_DTS_HD_MA 60
1592#define FF_PROFILE_DTS_EXPRESS 701592#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
1593 1596
1594#define FF_PROFILE_EAC3_DDP_ATMOS 301597#define FF_PROFILE_EAC3_DDP_ATMOS 30
1595 1598
libavcodec/dca_syncwords.h+3−0
@@ -33,4 +33,7 @@ · 32 unmodified lines
33#define DCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U33#define DCA_SYNCWORD_SUBSTREAM_CORE 0x02B09261U
34#define DCA_SYNCWORD_REV1AUX 0x9A1105A0U34#define DCA_SYNCWORD_REV1AUX 0x9A1105A0U
35 35
36#define DCA_SYNCWORD_XLL_X 0x02000850U
37#define DCA_SYNCWORD_XLL_X_IMAX 0xF14000D0U
38
36#endif /* AVCODEC_DCA_SYNCWORDS_H */39#endif /* AVCODEC_DCA_SYNCWORDS_H */
libavcodec/dca_xll.c+25−1
@@ -18,6 +18,7 @@ · 17 unmodified lines
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */19 */
20 20
21#include "avcodec.h"
21#include "libavutil/channel_layout.h"22#include "libavutil/channel_layout.h"
22#include "dcadec.h"23#include "dcadec.h"
23#include "dcadata.h"24#include "dcadata.h"
@@ -1054,6 +1055,22 @@ static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssA · 1030 unmodified lines
1054 return ret;1055 return ret;
1055 if ((ret = parse_band_data(s)) < 0)1056 if ((ret = parse_band_data(s)) < 0)
1056 return ret;1057 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
1057 if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) {1074 if (ff_dca_seek_bits(&s->gb, s->frame_size * 8)) {
1058 av_log(s->avctx, AV_LOG_ERROR, "Read past end of XLL frame\n");1075 av_log(s->avctx, AV_LOG_ERROR, "Read past end of XLL frame\n");
1059 return AVERROR_INVALIDDATA;1076 return AVERROR_INVALIDDATA;
@@ -1428,8 +1445,15 @@ int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame) · 368 unmodified lines
1428 return AVERROR(EINVAL);1445 return AVERROR(EINVAL);
1429 }1446 }
1430 1447
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
1431 avctx->bits_per_raw_sample = p->storage_bit_res;1456 avctx->bits_per_raw_sample = p->storage_bit_res;
1432 avctx->profile = FF_PROFILE_DTS_HD_MA;
1433 avctx->bit_rate = 0;1457 avctx->bit_rate = 0;
1434 1458
1435 frame->nb_samples = nsamples = s->nframesamples << (s->nfreqbands - 1);1459 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
135 135
136 DCADSPContext *dcadsp;136 DCADSPContext *dcadsp;
137 137
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
138 int output_mask;141 int output_mask;
139 int32_t *output_samples[DCA_SPEAKER_COUNT];142 int32_t *output_samples[DCA_SPEAKER_COUNT];
140} DCAXllDecoder;143} DCAXllDecoder;
libavcodec/profiles.c+8−6
@@ -36,12 +36,14 @@ const AVProfile ff_aac_profiles[] = { · 35 unmodified lines
36};36};
37 37
38const AVProfile ff_dca_profiles[] = {38const AVProfile ff_dca_profiles[] = {
39 { FF_PROFILE_DTS, "DTS" },39 { FF_PROFILE_DTS, "DTS" },
40 { FF_PROFILE_DTS_ES, "DTS-ES" },40 { FF_PROFILE_DTS_ES, "DTS-ES" },
41 { FF_PROFILE_DTS_96_24, "DTS 96/24" },41 { FF_PROFILE_DTS_96_24, "DTS 96/24" },
42 { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },42 { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
43 { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },43 { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
44 { FF_PROFILE_DTS_EXPRESS, "DTS Express" },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" },
45 { FF_PROFILE_UNKNOWN },47 { FF_PROFILE_UNKNOWN },
46};48};
47 49

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