]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/vocdec.c
flvenc: only write the framerate tag based on avg_frame_rate
[ffmpeg] / libavformat / vocdec.c
index e8c11afbe3ecc57327a6e462d084edf97f07856a..2fb84409316981ea313b3dc375e12467be8fa9c2 100644 (file)
@@ -86,12 +86,16 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
 
         switch (type) {
         case VOC_TYPE_VOICE_DATA:
-            dec->sample_rate = 1000000 / (256 - avio_r8(pb));
-            if (sample_rate)
-                dec->sample_rate = sample_rate;
-            dec->channels = channels;
+            if (!dec->sample_rate) {
+                dec->sample_rate = 1000000 / (256 - avio_r8(pb));
+                if (sample_rate)
+                    dec->sample_rate = sample_rate;
+                avpriv_set_pts_info(st, 64, 1, dec->sample_rate);
+                dec->channels = channels;
+                dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id);
+            } else
+                avio_skip(pb, 1);
             tmp_codec = avio_r8(pb);
-            dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id);
             voc->remaining_size -= 2;
             max_size -= 2;
             channels = 1;
@@ -110,9 +114,13 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
             break;
 
         case VOC_TYPE_NEW_VOICE_DATA:
-            dec->sample_rate = avio_rl32(pb);
-            dec->bits_per_coded_sample = avio_r8(pb);
-            dec->channels = avio_r8(pb);
+            if (!dec->sample_rate) {
+                dec->sample_rate = avio_rl32(pb);
+                avpriv_set_pts_info(st, 64, 1, dec->sample_rate);
+                dec->bits_per_coded_sample = avio_r8(pb);
+                dec->channels = avio_r8(pb);
+            } else
+                avio_skip(pb, 6);
             tmp_codec = avio_rl16(pb);
             avio_skip(pb, 4);
             voc->remaining_size -= 12;
@@ -129,12 +137,12 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
 
     if (tmp_codec >= 0) {
         tmp_codec = ff_codec_get_id(ff_voc_codec_tags, tmp_codec);
-        if (dec->codec_id == CODEC_ID_NONE)
+        if (dec->codec_id == AV_CODEC_ID_NONE)
             dec->codec_id = tmp_codec;
         else if (dec->codec_id != tmp_codec)
             av_log(s, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n");
-        if (dec->codec_id == CODEC_ID_NONE) {
-            if (s->audio_codec_id == CODEC_ID_NONE) {
+        if (dec->codec_id == AV_CODEC_ID_NONE) {
+            if (s->audio_codec_id == AV_CODEC_ID_NONE) {
                 av_log(s, AV_LOG_ERROR, "unknown codec tag\n");
                 return AVERROR(EINVAL);
             }
@@ -158,10 +166,10 @@ static int voc_read_packet(AVFormatContext *s, AVPacket *pkt)
 
 AVInputFormat ff_voc_demuxer = {
     .name           = "voc",
-    .long_name      = NULL_IF_CONFIG_SMALL("Creative Voice file format"),
+    .long_name      = NULL_IF_CONFIG_SMALL("Creative Voice"),
     .priv_data_size = sizeof(VocDecContext),
     .read_probe     = voc_probe,
     .read_header    = voc_read_header,
     .read_packet    = voc_read_packet,
-    .codec_tag=(const AVCodecTag* const []){ff_voc_codec_tags, 0},
+    .codec_tag      = (const AVCodecTag* const []){ ff_voc_codec_tags, 0 },
 };