ff_get_audio_frame_size: try to fix wma in wav
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 6 Jan 2013 18:15:16 +0000 (19:15 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 6 Jan 2013 18:46:04 +0000 (19:46 +0100)
Fixes Ticket1905, Ticket2114

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/utils.c

index cd9ddfe..5cbf7ca 100644 (file)
@@ -831,6 +831,13 @@ int ff_get_audio_frame_size(AVCodecContext *enc, int size, int mux)
     if (enc->frame_size > 1)
         return enc->frame_size;
 
+    //For WMA we currently have no other means to calculate duration thus we
+    //do it here by assuming CBR, which is true for all known cases.
+    if(!mux && enc->bit_rate>0 && size>0 && enc->sample_rate>0 && enc->block_align>1) {
+        if (enc->codec_id == AV_CODEC_ID_WMAV1 || enc->codec_id == AV_CODEC_ID_WMAV2)
+            return  ((int64_t)size * 8 * enc->sample_rate) / enc->bit_rate;
+    }
+
     return -1;
 }