[FFmpeg-cvslog] put_bits: fix invalid shift by 32 in flush_put_bits()

Mans Rullgard git at videolan.org
Mon Mar 19 05:30:30 CET 2012


ffmpeg | branch: release/0.8 | Mans Rullgard <mans at mansr.com> | Sat Oct  8 02:09:42 2011 +0100| [e52e85ac3ab6527a38e950142ea92f203909bf96] | committer: Reinhard Tartler

put_bits: fix invalid shift by 32 in flush_put_bits()

If flush_put_bits() is called when the 32-bit buffer is empty,
e.g. after writing a multiple of 32 bits, and invalid shift by
32 is performed.  Since flush_put_bits() is called infrequently,
this additional check should have negligible performance impact.

Signed-off-by: Mans Rullgard <mans at mansr.com>
(cherry picked from commit ac6eab1496aad6f8b09deabbef4fe5fd829e142d)

Signed-off-by: Anton Khirnov <anton at khirnov.net>

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

 libavcodec/put_bits.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h
index 3849e6d..2cae36e 100644
--- a/libavcodec/put_bits.h
+++ b/libavcodec/put_bits.h
@@ -100,7 +100,8 @@ static inline void flush_put_bits(PutBitContext *s)
     align_put_bits(s);
 #else
 #ifndef BITSTREAM_WRITER_LE
-    s->bit_buf<<= s->bit_left;
+    if (s->bit_left < 32)
+        s->bit_buf<<= s->bit_left;
 #endif
     while (s->bit_left < 32) {
         /* XXX: should test end of buffer */



More information about the ffmpeg-cvslog mailing list