]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/wav.c
some sanity checks on what is muxed, invalid timestamps in mpeg are very common and...
[ffmpeg] / libavformat / wav.c
index e0f134b47fdb520e2469ba078ec2e32d441c6f68..f2bb503b212782e1bc164447b45317a10d4c1526 100644 (file)
@@ -34,9 +34,11 @@ const CodecTag codec_wav_tags[] = {
     { CODEC_ID_ADPCM_IMA_DK3, 0x62 },  /* rogue format number */
     { CODEC_ID_WMAV1, 0x160 },
     { CODEC_ID_WMAV2, 0x161 },
+    { CODEC_ID_AAC, 0x706d },
     { CODEC_ID_VORBIS, ('V'<<8)+'o' }, //HACK/FIXME, does vorbis in WAV/AVI have an (in)official id?
     { CODEC_ID_SONIC, 0x2048 },
     { CODEC_ID_SONIC_LS, 0x2048 },
+    { CODEC_ID_ADPCM_CT, 0x200 },
     { 0, 0 },
 };
 
@@ -69,7 +71,7 @@ int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
     }
     
     if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) {
-        blkalign = 1;
+        blkalign = enc->frame_size; //this is wrong, but seems many demuxers dont work if this is set correctly
         //blkalign = 144 * enc->bit_rate/enc->sample_rate;
     } else if (enc->block_align != 0) { /* specified by the codec */
         blkalign = enc->block_align;
@@ -152,7 +154,7 @@ void get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size)
        if (codec->extradata_size > 0) {
            if (codec->extradata_size > size - 18)
                codec->extradata_size = size - 18;
-            codec->extradata = av_mallocz(codec->extradata_size);
+            codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
             get_buffer(pb, codec->extradata, codec->extradata_size);
         } else
            codec->extradata_size = 0;
@@ -299,7 +301,9 @@ static int wav_read_header(AVFormatContext *s,
 
     get_wav_header(pb, &st->codec, size);
     st->need_parsing = 1;
-    
+
+    av_set_pts_info(st, 64, 1, st->codec.sample_rate);
+
     size = find_tag(pb, MKTAG('d', 'a', 't', 'a'));
     if (size < 0)
         return -1;
@@ -343,7 +347,7 @@ static int wav_read_close(AVFormatContext *s)
 }
 
 static int wav_read_seek(AVFormatContext *s, 
-                         int stream_index, int64_t timestamp)
+                         int stream_index, int64_t timestamp, int flags)
 {
     AVStream *st;
 
@@ -358,7 +362,7 @@ static int wav_read_seek(AVFormatContext *s,
     default:
         break;
     }
-    return pcm_read_seek(s, stream_index, timestamp);
+    return pcm_read_seek(s, stream_index, timestamp, flags);
 }