• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavformat/dtsdec.c

Go to the documentation of this file.
00001 /*
00002  * RAW DTS demuxer
00003  * Copyright (c) 2008 Benjamin Larsson
00004  *
00005  * This file is part of Libav.
00006  *
00007  * Libav is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * Libav is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with Libav; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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         /* regular bitstream */
00045         if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
00046             markers[0]++;
00047 
00048         /* 14 bits big-endian bitstream */
00049         if (state == DCA_MARKER_14B_BE)
00050             if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
00051                 markers[1]++;
00052 
00053         /* 14 bits little-endian bitstream */
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 };
Generated on Thu Jul 11 2013 15:38:23 for Libav by doxygen 1.7.1