Originally committed as revision 24972 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -57,7 +57,7 @@ OBJS-$(CONFIG_DIRAC_MUXER) += raw.o |
| 57 | 57 |
OBJS-$(CONFIG_DNXHD_DEMUXER) += raw.o |
| 58 | 58 |
OBJS-$(CONFIG_DNXHD_MUXER) += raw.o |
| 59 | 59 |
OBJS-$(CONFIG_DSICIN_DEMUXER) += dsicin.o |
| 60 |
-OBJS-$(CONFIG_DTS_DEMUXER) += raw.o |
|
| 60 |
+OBJS-$(CONFIG_DTS_DEMUXER) += dtsdec.o raw.o |
|
| 61 | 61 |
OBJS-$(CONFIG_DTS_MUXER) += raw.o |
| 62 | 62 |
OBJS-$(CONFIG_DV_DEMUXER) += dv.o |
| 63 | 63 |
OBJS-$(CONFIG_DV_MUXER) += dvenc.o |
| 64 | 64 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,78 @@ |
| 0 |
+/* |
|
| 1 |
+ * RAW DTS demuxer |
|
| 2 |
+ * Copyright (c) 2008 Benjamin Larsson |
|
| 3 |
+ * |
|
| 4 |
+ * This file is part of FFmpeg. |
|
| 5 |
+ * |
|
| 6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
| 7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
| 8 |
+ * License as published by the Free Software Foundation; either |
|
| 9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
| 10 |
+ * |
|
| 11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
| 12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 14 |
+ * Lesser General Public License for more details. |
|
| 15 |
+ * |
|
| 16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
| 17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
| 18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
| 19 |
+ */ |
|
| 20 |
+ |
|
| 21 |
+#include "libavcodec/bytestream.h" |
|
| 22 |
+#include "avformat.h" |
|
| 23 |
+#include "raw.h" |
|
| 24 |
+ |
|
| 25 |
+#define DCA_MARKER_14B_BE 0x1FFFE800 |
|
| 26 |
+#define DCA_MARKER_14B_LE 0xFF1F00E8 |
|
| 27 |
+#define DCA_MARKER_RAW_BE 0x7FFE8001 |
|
| 28 |
+#define DCA_MARKER_RAW_LE 0xFE7F0180 |
|
| 29 |
+ |
|
| 30 |
+static int dts_probe(AVProbeData *p) |
|
| 31 |
+{
|
|
| 32 |
+ const uint8_t *buf, *bufp; |
|
| 33 |
+ uint32_t state = -1; |
|
| 34 |
+ int markers[3] = {0};
|
|
| 35 |
+ int sum, max; |
|
| 36 |
+ |
|
| 37 |
+ buf = p->buf; |
|
| 38 |
+ |
|
| 39 |
+ for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
|
|
| 40 |
+ bufp = buf; |
|
| 41 |
+ state = (state << 16) | bytestream_get_be16(&bufp); |
|
| 42 |
+ |
|
| 43 |
+ /* regular bitstream */ |
|
| 44 |
+ if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE) |
|
| 45 |
+ markers[0]++; |
|
| 46 |
+ |
|
| 47 |
+ /* 14 bits big-endian bitstream */ |
|
| 48 |
+ if (state == DCA_MARKER_14B_BE) |
|
| 49 |
+ if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0) |
|
| 50 |
+ markers[1]++; |
|
| 51 |
+ |
|
| 52 |
+ /* 14 bits little-endian bitstream */ |
|
| 53 |
+ if (state == DCA_MARKER_14B_LE) |
|
| 54 |
+ if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007) |
|
| 55 |
+ markers[2]++; |
|
| 56 |
+ } |
|
| 57 |
+ sum = markers[0] + markers[1] + markers[2]; |
|
| 58 |
+ max = markers[1] > markers[0]; |
|
| 59 |
+ max = markers[2] > markers[max] ? 2 : max; |
|
| 60 |
+ if (markers[max] > 3 && p->buf_size / markers[max] < 32*1024 && |
|
| 61 |
+ markers[max] * 4 > sum * 3) |
|
| 62 |
+ return AVPROBE_SCORE_MAX/2+1; |
|
| 63 |
+ |
|
| 64 |
+ return 0; |
|
| 65 |
+} |
|
| 66 |
+ |
|
| 67 |
+AVInputFormat dts_demuxer = {
|
|
| 68 |
+ "dts", |
|
| 69 |
+ NULL_IF_CONFIG_SMALL("raw DTS"),
|
|
| 70 |
+ 0, |
|
| 71 |
+ dts_probe, |
|
| 72 |
+ ff_raw_audio_read_header, |
|
| 73 |
+ ff_raw_read_partial_packet, |
|
| 74 |
+ .flags= AVFMT_GENERIC_INDEX, |
|
| 75 |
+ .extensions = "dts", |
|
| 76 |
+ .value = CODEC_ID_DTS, |
|
| 77 |
+}; |
| ... | ... |
@@ -233,7 +233,7 @@ int pcm_read_seek(AVFormatContext *s, |
| 233 | 233 |
return 0; |
| 234 | 234 |
} |
| 235 | 235 |
|
| 236 |
-static int audio_read_header(AVFormatContext *s, |
|
| 236 |
+int ff_raw_audio_read_header(AVFormatContext *s, |
|
| 237 | 237 |
AVFormatParameters *ap) |
| 238 | 238 |
{
|
| 239 | 239 |
AVStream *st = av_new_stream(s, 0); |
| ... | ... |
@@ -519,49 +519,6 @@ static int h261_probe(AVProbeData *p) |
| 519 | 519 |
} |
| 520 | 520 |
#endif |
| 521 | 521 |
|
| 522 |
-#if CONFIG_DTS_DEMUXER |
|
| 523 |
-#define DCA_MARKER_14B_BE 0x1FFFE800 |
|
| 524 |
-#define DCA_MARKER_14B_LE 0xFF1F00E8 |
|
| 525 |
-#define DCA_MARKER_RAW_BE 0x7FFE8001 |
|
| 526 |
-#define DCA_MARKER_RAW_LE 0xFE7F0180 |
|
| 527 |
-static int dts_probe(AVProbeData *p) |
|
| 528 |
-{
|
|
| 529 |
- const uint8_t *buf, *bufp; |
|
| 530 |
- uint32_t state = -1; |
|
| 531 |
- int markers[3] = {0};
|
|
| 532 |
- int sum, max; |
|
| 533 |
- |
|
| 534 |
- buf = p->buf; |
|
| 535 |
- |
|
| 536 |
- for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
|
|
| 537 |
- bufp = buf; |
|
| 538 |
- state = (state << 16) | bytestream_get_be16(&bufp); |
|
| 539 |
- |
|
| 540 |
- /* regular bitstream */ |
|
| 541 |
- if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE) |
|
| 542 |
- markers[0]++; |
|
| 543 |
- |
|
| 544 |
- /* 14 bits big-endian bitstream */ |
|
| 545 |
- if (state == DCA_MARKER_14B_BE) |
|
| 546 |
- if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0) |
|
| 547 |
- markers[1]++; |
|
| 548 |
- |
|
| 549 |
- /* 14 bits little-endian bitstream */ |
|
| 550 |
- if (state == DCA_MARKER_14B_LE) |
|
| 551 |
- if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007) |
|
| 552 |
- markers[2]++; |
|
| 553 |
- } |
|
| 554 |
- sum = markers[0] + markers[1] + markers[2]; |
|
| 555 |
- max = markers[1] > markers[0]; |
|
| 556 |
- max = markers[2] > markers[max] ? 2 : max; |
|
| 557 |
- if (markers[max] > 3 && p->buf_size / markers[max] < 32*1024 && |
|
| 558 |
- markers[max] * 4 > sum * 3) |
|
| 559 |
- return AVPROBE_SCORE_MAX/2+1; |
|
| 560 |
- |
|
| 561 |
- return 0; |
|
| 562 |
-} |
|
| 563 |
-#endif |
|
| 564 |
- |
|
| 565 | 522 |
#if CONFIG_DIRAC_DEMUXER |
| 566 | 523 |
static int dirac_probe(AVProbeData *p) |
| 567 | 524 |
{
|
| ... | ... |
@@ -656,7 +613,7 @@ AVInputFormat ac3_demuxer = {
|
| 656 | 656 |
NULL_IF_CONFIG_SMALL("raw AC-3"),
|
| 657 | 657 |
0, |
| 658 | 658 |
ac3_probe, |
| 659 |
- audio_read_header, |
|
| 659 |
+ ff_raw_audio_read_header, |
|
| 660 | 660 |
ff_raw_read_partial_packet, |
| 661 | 661 |
.flags= AVFMT_GENERIC_INDEX, |
| 662 | 662 |
.extensions = "ac3", |
| ... | ... |
@@ -735,20 +692,6 @@ AVOutputFormat dnxhd_muxer = {
|
| 735 | 735 |
}; |
| 736 | 736 |
#endif |
| 737 | 737 |
|
| 738 |
-#if CONFIG_DTS_DEMUXER |
|
| 739 |
-AVInputFormat dts_demuxer = {
|
|
| 740 |
- "dts", |
|
| 741 |
- NULL_IF_CONFIG_SMALL("raw DTS"),
|
|
| 742 |
- 0, |
|
| 743 |
- dts_probe, |
|
| 744 |
- audio_read_header, |
|
| 745 |
- ff_raw_read_partial_packet, |
|
| 746 |
- .flags= AVFMT_GENERIC_INDEX, |
|
| 747 |
- .extensions = "dts", |
|
| 748 |
- .value = CODEC_ID_DTS, |
|
| 749 |
-}; |
|
| 750 |
-#endif |
|
| 751 |
- |
|
| 752 | 738 |
#if CONFIG_DTS_MUXER |
| 753 | 739 |
AVOutputFormat dts_muxer = {
|
| 754 | 740 |
"dts", |
| ... | ... |
@@ -770,7 +713,7 @@ AVInputFormat eac3_demuxer = {
|
| 770 | 770 |
NULL_IF_CONFIG_SMALL("raw E-AC-3"),
|
| 771 | 771 |
0, |
| 772 | 772 |
eac3_probe, |
| 773 |
- audio_read_header, |
|
| 773 |
+ ff_raw_audio_read_header, |
|
| 774 | 774 |
ff_raw_read_partial_packet, |
| 775 | 775 |
.flags= AVFMT_GENERIC_INDEX, |
| 776 | 776 |
.extensions = "eac3", |
| ... | ... |
@@ -799,7 +742,7 @@ AVInputFormat gsm_demuxer = {
|
| 799 | 799 |
NULL_IF_CONFIG_SMALL("raw GSM"),
|
| 800 | 800 |
0, |
| 801 | 801 |
NULL, |
| 802 |
- audio_read_header, |
|
| 802 |
+ ff_raw_audio_read_header, |
|
| 803 | 803 |
ff_raw_read_partial_packet, |
| 804 | 804 |
.flags= AVFMT_GENERIC_INDEX, |
| 805 | 805 |
.extensions = "gsm", |
| ... | ... |
@@ -987,7 +930,7 @@ AVInputFormat mlp_demuxer = {
|
| 987 | 987 |
NULL_IF_CONFIG_SMALL("raw MLP"),
|
| 988 | 988 |
0, |
| 989 | 989 |
NULL, |
| 990 |
- audio_read_header, |
|
| 990 |
+ ff_raw_audio_read_header, |
|
| 991 | 991 |
ff_raw_read_partial_packet, |
| 992 | 992 |
.flags= AVFMT_GENERIC_INDEX, |
| 993 | 993 |
.extensions = "mlp", |
| ... | ... |
@@ -1028,7 +971,7 @@ AVInputFormat truehd_demuxer = {
|
| 1028 | 1028 |
NULL_IF_CONFIG_SMALL("raw TrueHD"),
|
| 1029 | 1029 |
0, |
| 1030 | 1030 |
NULL, |
| 1031 |
- audio_read_header, |
|
| 1031 |
+ ff_raw_audio_read_header, |
|
| 1032 | 1032 |
ff_raw_read_partial_packet, |
| 1033 | 1033 |
.flags= AVFMT_GENERIC_INDEX, |
| 1034 | 1034 |
.extensions = "thd", |
| ... | ... |
@@ -1157,7 +1100,7 @@ AVInputFormat shorten_demuxer = {
|
| 1157 | 1157 |
NULL_IF_CONFIG_SMALL("raw Shorten"),
|
| 1158 | 1158 |
0, |
| 1159 | 1159 |
NULL, |
| 1160 |
- audio_read_header, |
|
| 1160 |
+ ff_raw_audio_read_header, |
|
| 1161 | 1161 |
ff_raw_read_partial_packet, |
| 1162 | 1162 |
.flags= AVFMT_GENERIC_INDEX, |
| 1163 | 1163 |
.extensions = "shn", |