]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/raw.c
ADTS AAC probe.
[ffmpeg] / libavformat / raw.c
index 65d13aa785ed82a8452884a16f53d801ac012c97..f552fee61f87a04c416f967e814ac4effbc2e71f 100644 (file)
@@ -48,7 +48,7 @@ static int flac_write_trailer(struct AVFormatContext *s)
     ByteIOContext *pb = s->pb;
     uint8_t *streaminfo = s->streams[0]->codec->extradata;
     int len = s->streams[0]->codec->extradata_size;
-    offset_t file_size;
+    int64_t file_size;
 
     if (streaminfo && len > 0 && !url_is_streamed(s->pb)) {
         file_size = url_ftell(pb);
@@ -113,7 +113,8 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
         switch(st->codec->codec_type) {
         case CODEC_TYPE_AUDIO:
             st->codec->sample_rate = ap->sample_rate;
-            st->codec->channels = ap->channels;
+            if(ap->channels) st->codec->channels = ap->channels;
+            else             st->codec->channels = 1;
             av_set_pts_info(st, 64, 1, st->codec->sample_rate);
             break;
         case CODEC_TYPE_VIDEO:
@@ -504,6 +505,17 @@ static int dirac_probe(AVProbeData *p)
 }
 #endif
 
+#ifdef CONFIG_DNXHD_DEMUXER
+static int dnxhd_probe(AVProbeData *p)
+{
+    static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
+    if (!memcmp(p->buf, header, 5))
+        return AVPROBE_SCORE_MAX;
+    else
+        return 0;
+}
+#endif
+
 #if defined(CONFIG_AC3_DEMUXER) || defined(CONFIG_EAC3_DEMUXER)
 static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
 {
@@ -565,6 +577,38 @@ static int flac_probe(AVProbeData *p)
 }
 #endif
 
+#ifdef CONFIG_AAC_DEMUXER
+static int adts_aac_probe(AVProbeData *p)
+{
+    int max_frames = 0, first_frames = 0;
+    int fsize, frames;
+    uint8_t *buf2;
+    uint8_t *buf = p->buf;
+    uint8_t *end = buf + p->buf_size - 7;
+
+    for(; buf < end; buf= buf2+1) {
+        buf2 = buf;
+
+        for(frames = 0; buf2 < end; frames++) {
+            uint32_t header = AV_RB16(buf2);
+            if((header&0xFFF6) != 0xFFF0)
+                break;
+            fsize = (AV_RB32(buf2+3)>>13) & 0x8FFF;
+            if(fsize < 7)
+                break;
+            buf2 += fsize;
+        }
+        max_frames = FFMAX(max_frames, frames);
+        if(buf == p->buf)
+            first_frames= frames;
+    }
+    if   (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
+    else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
+    else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
+    else if(max_frames>=1) return 1;
+    else                   return 0;
+}
+#endif
 
 /* Note: Do not forget to add new entries to the Makefile as well. */
 
@@ -573,7 +617,7 @@ AVInputFormat aac_demuxer = {
     "aac",
     NULL_IF_CONFIG_SMALL("ADTS AAC"),
     0,
-    NULL,
+    adts_aac_probe,
     audio_read_header,
     raw_read_partial_packet,
     .flags= AVFMT_GENERIC_INDEX,
@@ -639,6 +683,34 @@ AVOutputFormat dirac_muxer = {
 };
 #endif
 
+#ifdef CONFIG_DNXHD_DEMUXER
+AVInputFormat dnxhd_demuxer = {
+    "dnxhd",
+    NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
+    0,
+    dnxhd_probe,
+    video_read_header,
+    raw_read_partial_packet,
+    .flags= AVFMT_GENERIC_INDEX,
+    .value = CODEC_ID_DNXHD,
+};
+#endif
+
+#ifdef CONFIG_DNXHD_MUXER
+AVOutputFormat dnxhd_muxer = {
+    "dnxhd",
+    NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
+    NULL,
+    "dnxhd",
+    0,
+    CODEC_ID_NONE,
+    CODEC_ID_DNXHD,
+    NULL,
+    raw_write_packet,
+    .flags= AVFMT_NOTIMESTAMPS,
+};
+#endif
+
 #ifdef CONFIG_DTS_DEMUXER
 AVInputFormat dts_demuxer = {
     "dts",