... | ... |
@@ -24,6 +24,7 @@ |
24 | 24 |
#include "libavutil/error.h" |
25 | 25 |
|
26 | 26 |
#include "dca.h" |
27 |
+#include "dca_syncwords.h" |
|
27 | 28 |
#include "put_bits.h" |
28 | 29 |
|
29 | 30 |
const uint32_t avpriv_dca_sample_rates[16] = { |
... | ... |
@@ -45,18 +46,18 @@ int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, |
45 | 45 |
|
46 | 46 |
mrk = AV_RB32(src); |
47 | 47 |
switch (mrk) { |
48 |
- case DCA_MARKER_RAW_BE: |
|
48 |
+ case DCA_SYNCWORD_CORE_BE: |
|
49 | 49 |
memcpy(dst, src, src_size); |
50 | 50 |
return src_size; |
51 |
- case DCA_MARKER_RAW_LE: |
|
51 |
+ case DCA_SYNCWORD_CORE_LE: |
|
52 | 52 |
for (i = 0; i < (src_size + 1) >> 1; i++) |
53 | 53 |
*sdst++ = av_bswap16(*ssrc++); |
54 | 54 |
return src_size; |
55 |
- case DCA_MARKER_14B_BE: |
|
56 |
- case DCA_MARKER_14B_LE: |
|
55 |
+ case DCA_SYNCWORD_CORE_14B_BE: |
|
56 |
+ case DCA_SYNCWORD_CORE_14B_LE: |
|
57 | 57 |
init_put_bits(&pb, dst, max_size); |
58 | 58 |
for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) { |
59 |
- tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF; |
|
59 |
+ tmp = ((mrk == DCA_SYNCWORD_CORE_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF; |
|
60 | 60 |
put_bits(&pb, 14, tmp); |
61 | 61 |
} |
62 | 62 |
flush_put_bits(&pb); |
... | ... |
@@ -35,15 +35,6 @@ |
35 | 35 |
#include "fmtconvert.h" |
36 | 36 |
#include "get_bits.h" |
37 | 37 |
|
38 |
-/** DCA syncwords, also used for bitstream type detection */ |
|
39 |
-#define DCA_MARKER_RAW_BE 0x7FFE8001 |
|
40 |
-#define DCA_MARKER_RAW_LE 0xFE7F0180 |
|
41 |
-#define DCA_MARKER_14B_BE 0x1FFFE800 |
|
42 |
-#define DCA_MARKER_14B_LE 0xFF1F00E8 |
|
43 |
- |
|
44 |
-/** DCA-HD specific block starts with this marker. */ |
|
45 |
-#define DCA_HD_MARKER 0x64582025 |
|
46 |
- |
|
47 | 38 |
#define DCA_PRIM_CHANNELS_MAX (7) |
48 | 39 |
#define DCA_ABITS_MAX (32) /* Should be 28 */ |
49 | 40 |
#define DCA_SUBSUBFRAMES_MAX (4) |
... | ... |
@@ -23,6 +23,7 @@ |
23 | 23 |
*/ |
24 | 24 |
|
25 | 25 |
#include "dca.h" |
26 |
+#include "dca_syncwords.h" |
|
26 | 27 |
#include "get_bits.h" |
27 | 28 |
#include "parser.h" |
28 | 29 |
|
... | ... |
@@ -35,9 +36,9 @@ typedef struct DCAParseContext { |
35 | 35 |
} DCAParseContext; |
36 | 36 |
|
37 | 37 |
#define IS_MARKER(state, i, buf, buf_size) \ |
38 |
- ((state == DCA_MARKER_14B_LE && (i < buf_size - 2) && (buf[i + 1] & 0xF0) == 0xF0 && buf[i + 2] == 0x07) || \ |
|
39 |
- (state == DCA_MARKER_14B_BE && (i < buf_size - 2) && buf[i + 1] == 0x07 && (buf[i + 2] & 0xF0) == 0xF0) || \ |
|
40 |
- state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE) |
|
38 |
+ ((state == DCA_SYNCWORD_CORE_14B_LE && (i < buf_size - 2) && (buf[i + 1] & 0xF0) == 0xF0 && buf[i + 2] == 0x07) || \ |
|
39 |
+ (state == DCA_SYNCWORD_CORE_14B_BE && (i < buf_size - 2) && buf[i + 1] == 0x07 && (buf[i + 2] & 0xF0) == 0xF0) || \ |
|
40 |
+ state == DCA_SYNCWORD_CORE_LE || state == DCA_SYNCWORD_CORE_BE) |
|
41 | 41 |
|
42 | 42 |
/** |
43 | 43 |
* Find the end of the current frame in the bitstream. |
... | ... |
@@ -75,7 +76,7 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, |
75 | 75 |
for (; i < buf_size; i++) { |
76 | 76 |
pc1->size++; |
77 | 77 |
state = (state << 8) | buf[i]; |
78 |
- if (state == DCA_HD_MARKER && !pc1->hd_pos) |
|
78 |
+ if (state == DCA_SYNCWORD_SUBSTREAM && !pc1->hd_pos) |
|
79 | 79 |
pc1->hd_pos = pc1->size; |
80 | 80 |
if (state == pc1->lastmarker && IS_MARKER(state, i, buf, buf_size)) { |
81 | 81 |
if (pc1->framesize > pc1->size) |
82 | 82 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,37 @@ |
0 |
+/* |
|
1 |
+ * This file is part of Libav. |
|
2 |
+ * |
|
3 |
+ * Libav is free software; you can redistribute it and/or |
|
4 |
+ * modify it under the terms of the GNU Lesser General Public |
|
5 |
+ * License as published by the Free Software Foundation; either |
|
6 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
7 |
+ * |
|
8 |
+ * Libav is distributed in the hope that it will be useful, |
|
9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
11 |
+ * Lesser General Public License for more details. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the GNU Lesser General Public |
|
14 |
+ * License along with Libav; if not, write to the Free Software |
|
15 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 |
+ */ |
|
17 |
+ |
|
18 |
+#ifndef AVCODEC_DCA_SYNCWORDS_H |
|
19 |
+#define AVCODEC_DCA_SYNCWORDS_H |
|
20 |
+ |
|
21 |
+enum DCASyncwords { |
|
22 |
+ DCA_SYNCWORD_CORE_BE = 0x7FFE8001, |
|
23 |
+ DCA_SYNCWORD_CORE_LE = 0xFE7F0180, |
|
24 |
+ DCA_SYNCWORD_CORE_14B_BE = 0x1FFFE800, |
|
25 |
+ DCA_SYNCWORD_CORE_14B_LE = 0xFF1F00E8, |
|
26 |
+ DCA_SYNCWORD_XCH = 0x5A5A5A5A, |
|
27 |
+ DCA_SYNCWORD_XXCH = 0x47004A03, |
|
28 |
+ DCA_SYNCWORD_X96 = 0x1D95F262, |
|
29 |
+ DCA_SYNCWORD_XBR = 0x655E315E, |
|
30 |
+ DCA_SYNCWORD_LBR = 0x0A801921, |
|
31 |
+ DCA_SYNCWORD_XLL = 0x41A29547, |
|
32 |
+ DCA_SYNCWORD_SUBSTREAM = 0x64582025, |
|
33 |
+ DCA_SYNCWORD_SUBSTREAM_CORE = 0x02B09261, |
|
34 |
+}; |
|
35 |
+ |
|
36 |
+#endif /* AVCODEC_DCA_SYNCWORDS_H */ |
... | ... |
@@ -37,6 +37,7 @@ |
37 | 37 |
|
38 | 38 |
#include "avcodec.h" |
39 | 39 |
#include "dca.h" |
40 |
+#include "dca_syncwords.h" |
|
40 | 41 |
#include "dcadata.h" |
41 | 42 |
#include "dcadsp.h" |
42 | 43 |
#include "dcahuff.h" |
... | ... |
@@ -1100,7 +1101,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, |
1100 | 1100 |
uint32_t bits = get_bits_long(&s->gb, 32); |
1101 | 1101 |
|
1102 | 1102 |
switch (bits) { |
1103 |
- case 0x5a5a5a5a: { |
|
1103 |
+ case DCA_SYNCWORD_XCH: { |
|
1104 | 1104 |
int ext_amode, xch_fsize; |
1105 | 1105 |
|
1106 | 1106 |
s->xch_base_channel = s->prim_channels; |
... | ... |
@@ -1137,7 +1138,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, |
1137 | 1137 |
s->xch_present = 1; |
1138 | 1138 |
break; |
1139 | 1139 |
} |
1140 |
- case 0x47004a03: |
|
1140 |
+ case DCA_SYNCWORD_XXCH: |
|
1141 | 1141 |
/* XXCh: extended channels */ |
1142 | 1142 |
/* usually found either in core or HD part in DTS-HD HRA streams, |
1143 | 1143 |
* but not in DTS-ES which contains XCh extensions instead */ |
... | ... |
@@ -1174,7 +1175,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, |
1174 | 1174 |
|
1175 | 1175 |
/* check for ExSS (HD part) */ |
1176 | 1176 |
if (s->dca_buffer_size - s->frame_size > 32 && |
1177 |
- get_bits_long(&s->gb, 32) == DCA_HD_MARKER) |
|
1177 |
+ get_bits_long(&s->gb, 32) == DCA_SYNCWORD_SUBSTREAM) |
|
1178 | 1178 |
ff_dca_exss_parse_header(s); |
1179 | 1179 |
|
1180 | 1180 |
avctx->profile = s->profile; |
... | ... |
@@ -20,14 +20,11 @@ |
20 | 20 |
*/ |
21 | 21 |
|
22 | 22 |
#include "libavcodec/bytestream.h" |
23 |
+#include "libavcodec/dca_syncwords.h" |
|
24 |
+ |
|
23 | 25 |
#include "avformat.h" |
24 | 26 |
#include "rawdec.h" |
25 | 27 |
|
26 |
-#define DCA_MARKER_14B_BE 0x1FFFE800 |
|
27 |
-#define DCA_MARKER_14B_LE 0xFF1F00E8 |
|
28 |
-#define DCA_MARKER_RAW_BE 0x7FFE8001 |
|
29 |
-#define DCA_MARKER_RAW_LE 0xFE7F0180 |
|
30 |
- |
|
31 | 28 |
static int dts_probe(AVProbeData *p) |
32 | 29 |
{ |
33 | 30 |
const uint8_t *buf, *bufp; |
... | ... |
@@ -42,16 +39,16 @@ static int dts_probe(AVProbeData *p) |
42 | 42 |
state = (state << 16) | bytestream_get_be16(&bufp); |
43 | 43 |
|
44 | 44 |
/* regular bitstream */ |
45 |
- if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE) |
|
45 |
+ if (state == DCA_SYNCWORD_CORE_BE || state == DCA_SYNCWORD_CORE_LE) |
|
46 | 46 |
markers[0]++; |
47 | 47 |
|
48 | 48 |
/* 14 bits big-endian bitstream */ |
49 |
- if (state == DCA_MARKER_14B_BE) |
|
49 |
+ if (state == DCA_SYNCWORD_CORE_14B_BE) |
|
50 | 50 |
if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0) |
51 | 51 |
markers[1]++; |
52 | 52 |
|
53 | 53 |
/* 14 bits little-endian bitstream */ |
54 |
- if (state == DCA_MARKER_14B_LE) |
|
54 |
+ if (state == DCA_SYNCWORD_CORE_14B_LE) |
|
55 | 55 |
if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007) |
56 | 56 |
markers[2]++; |
57 | 57 |
} |
... | ... |
@@ -51,6 +51,7 @@ |
51 | 51 |
#include "spdif.h" |
52 | 52 |
#include "libavcodec/ac3.h" |
53 | 53 |
#include "libavcodec/dca.h" |
54 |
+#include "libavcodec/dca_syncwords.h" |
|
54 | 55 |
#include "libavcodec/aacadtsdec.h" |
55 | 56 |
#include "libavutil/opt.h" |
56 | 57 |
|
... | ... |
@@ -251,25 +252,25 @@ static int spdif_header_dts(AVFormatContext *s, AVPacket *pkt) |
251 | 251 |
return AVERROR_INVALIDDATA; |
252 | 252 |
|
253 | 253 |
switch (syncword_dts) { |
254 |
- case DCA_MARKER_RAW_BE: |
|
254 |
+ case DCA_SYNCWORD_CORE_BE: |
|
255 | 255 |
blocks = (AV_RB16(pkt->data + 4) >> 2) & 0x7f; |
256 | 256 |
core_size = ((AV_RB24(pkt->data + 5) >> 4) & 0x3fff) + 1; |
257 | 257 |
sample_rate = avpriv_dca_sample_rates[(pkt->data[8] >> 2) & 0x0f]; |
258 | 258 |
break; |
259 |
- case DCA_MARKER_RAW_LE: |
|
259 |
+ case DCA_SYNCWORD_CORE_LE: |
|
260 | 260 |
blocks = (AV_RL16(pkt->data + 4) >> 2) & 0x7f; |
261 | 261 |
ctx->extra_bswap = 1; |
262 | 262 |
break; |
263 |
- case DCA_MARKER_14B_BE: |
|
263 |
+ case DCA_SYNCWORD_CORE_14B_BE: |
|
264 | 264 |
blocks = |
265 | 265 |
(((pkt->data[5] & 0x07) << 4) | ((pkt->data[6] & 0x3f) >> 2)); |
266 | 266 |
break; |
267 |
- case DCA_MARKER_14B_LE: |
|
267 |
+ case DCA_SYNCWORD_CORE_14B_LE: |
|
268 | 268 |
blocks = |
269 | 269 |
(((pkt->data[4] & 0x07) << 4) | ((pkt->data[7] & 0x3f) >> 2)); |
270 | 270 |
ctx->extra_bswap = 1; |
271 | 271 |
break; |
272 |
- case DCA_HD_MARKER: |
|
272 |
+ case DCA_SYNCWORD_SUBSTREAM: |
|
273 | 273 |
/* We only handle HD frames that are paired with core. However, |
274 | 274 |
sometimes DTS-HD streams with core have a stray HD frame without |
275 | 275 |
core in the beginning of the stream. */ |