00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "libavcodec/bytestream.h"
00023 #include "avformat.h"
00024 #include "rawdec.h"
00025
00026 #define DCA_MARKER_14B_BE 0x1FFFE800
00027 #define DCA_MARKER_14B_LE 0xFF1F00E8
00028 #define DCA_MARKER_RAW_BE 0x7FFE8001
00029 #define DCA_MARKER_RAW_LE 0xFE7F0180
00030
00031 static int dts_probe(AVProbeData *p)
00032 {
00033 const uint8_t *buf, *bufp;
00034 uint32_t state = -1;
00035 int markers[3] = {0};
00036 int sum, max;
00037
00038 buf = p->buf;
00039
00040 for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
00041 bufp = buf;
00042 state = (state << 16) | bytestream_get_be16(&bufp);
00043
00044
00045 if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
00046 markers[0]++;
00047
00048
00049 if (state == DCA_MARKER_14B_BE)
00050 if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
00051 markers[1]++;
00052
00053
00054 if (state == DCA_MARKER_14B_LE)
00055 if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
00056 markers[2]++;
00057 }
00058 sum = markers[0] + markers[1] + markers[2];
00059 max = markers[1] > markers[0];
00060 max = markers[2] > markers[max] ? 2 : max;
00061 if (markers[max] > 3 && p->buf_size / markers[max] < 32*1024 &&
00062 markers[max] * 4 > sum * 3)
00063 return AVPROBE_SCORE_MAX/2+1;
00064
00065 return 0;
00066 }
00067
00068 AVInputFormat ff_dts_demuxer = {
00069 .name = "dts",
00070 .long_name = NULL_IF_CONFIG_SMALL("raw DTS"),
00071 .read_probe = dts_probe,
00072 .read_header = ff_raw_audio_read_header,
00073 .read_packet = ff_raw_read_partial_packet,
00074 .flags= AVFMT_GENERIC_INDEX,
00075 .extensions = "dts",
00076 .value = CODEC_ID_DTS,
00077 };