[FFmpeg-cvslog] Move WMA case from ff_get_audio_frame_size() to av_get_audio_frame_duration()

Michael Niedermayer git at videolan.org
Thu Aug 14 03:10:59 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Aug 14 02:42:14 2014 +0200| [7b59217b60cc7133766ea33ee8519efda9ec4c5c] | committer: Michael Niedermayer

Move WMA case from ff_get_audio_frame_size() to av_get_audio_frame_duration()

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7b59217b60cc7133766ea33ee8519efda9ec4c5c
---

 libavcodec/utils.c  |    7 +++++++
 libavformat/utils.c |    7 +------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4531311..b3715a9 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -3310,6 +3310,13 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
     if (avctx->frame_size > 1 && frame_bytes)
         return avctx->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 (avctx->bit_rate>0 && frame_bytes>0 && avctx->sample_rate>0 && avctx->block_align>1) {
+        if (avctx->codec_id == AV_CODEC_ID_WMAV1 || avctx->codec_id == AV_CODEC_ID_WMAV2)
+            return  (frame_bytes * 8LL * avctx->sample_rate) / avctx->bit_rate;
+    }
+
     return 0;
 }
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index c695e37..364796a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -722,12 +722,7 @@ int ff_get_audio_frame_size(AVCodecContext *enc, int size, int mux)
     if ((frame_size = av_get_audio_frame_duration(enc, size)) > 0)
         return 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;
 }



More information about the ffmpeg-cvslog mailing list