[FFmpeg-cvslog] wmaenc: check final frame size against output packet size

Justin Ruggles git at videolan.org
Mon Mar 5 00:28:53 CET 2012


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Fri Mar  2 16:42:21 2012 -0500| [5d652e063bd3a180f9de8915e5137aa4f938846d] | committer: Justin Ruggles

wmaenc: check final frame size against output packet size

Currently we have an assert() that prevents the frame from being too large,
but it is more user-friendly to give an error message instead of aborting on
assert(). This condition is quite unlikely due to the minimum bit rate check
in encode_init(), but it is still worth having.

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

 libavcodec/wmaenc.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index 5135b98..c00f136 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -394,11 +394,13 @@ static int encode_superframe(AVCodecContext *avctx,
     }
 #endif
 
-    encode_frame(s, s->coefs, buf, buf_size, total_gain);
+    if ((i = encode_frame(s, s->coefs, buf, buf_size, total_gain)) >= 0) {
+        av_log(avctx, AV_LOG_ERROR, "required frame size too large. please "
+               "use a higher bit rate.\n");
+        return AVERROR(EINVAL);
+    }
     assert((put_bits_count(&s->pb) & 7) == 0);
-    i= s->block_align - (put_bits_count(&s->pb)+7)/8;
-    assert(i>=0);
-    while(i--)
+    while (i++)
         put_bits(&s->pb, 8, 'N');
 
     flush_put_bits(&s->pb);



More information about the ffmpeg-cvslog mailing list