diff mbox

[FFmpeg-devel,5/5] libavcodec/vc1: Remove bits variable

Message ID 20191208213120.15190-5-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Dec. 8, 2019, 9:31 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/mss2.c      |  2 --
 libavcodec/vc1.h       |  2 --
 libavcodec/vc1_block.c | 16 ++++++++--------
 libavcodec/vc1dec.c    |  2 --
 4 files changed, 8 insertions(+), 14 deletions(-)

Comments

Michael Niedermayer Jan. 11, 2020, 10:39 p.m. UTC | #1
On Sun, Dec 08, 2019 at 10:31:20PM +0100, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/mss2.c      |  2 --
>  libavcodec/vc1.h       |  2 --
>  libavcodec/vc1_block.c | 16 ++++++++--------
>  libavcodec/vc1dec.c    |  2 --
>  4 files changed, 8 insertions(+), 14 deletions(-)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index d977cb1160..9434a740a7 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -412,8 +412,6 @@  static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size,
 
     ff_mpeg_er_frame_start(s);
 
-    v->bits = buf_size * 8;
-
     v->end_mb_x = (w + 15) >> 4;
     s->end_mb_y = (h + 15) >> 4;
     if (v->respic & 1)
diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index 69f6ca9e4d..4559a06cb6 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -176,8 +176,6 @@  typedef struct VC1Context{
     H264ChromaContext h264chroma;
     VC1DSPContext vc1dsp;
 
-    int bits;
-
     /** Simple/Main Profile sequence header */
     //@{
     int res_sprite;       ///< reserved, sprite mode
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 0ccaf6b022..16542dba3a 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -2632,10 +2632,10 @@  static void vc1_decode_i_blocks(VC1Context *v)
             if (v->s.loop_filter)
                 ff_vc1_i_loop_filter(v);
 
-            if (get_bits_count(&s->gb) > v->bits) {
+            if (get_bits_left(&s->gb) < 0) {
                 ff_er_add_slice(&s->er, 0, 0, s->mb_x, s->mb_y, ER_MB_ERROR);
                 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
-                       get_bits_count(&s->gb), v->bits);
+                       get_bits_count(&s->gb), s->gb.size_in_bits);
                 return;
             }
 
@@ -2778,11 +2778,11 @@  static int vc1_decode_i_blocks_adv(VC1Context *v)
             if (v->s.loop_filter)
                 ff_vc1_i_loop_filter(v);
 
-            if (get_bits_count(&s->gb) > v->bits) {
+            if (get_bits_left(&s->gb) < 0) {
                 // TODO: may need modification to handle slice coding
                 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
                 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
-                       get_bits_count(&s->gb), v->bits);
+                       get_bits_count(&s->gb), s->gb.size_in_bits);
                 return 0;
             }
             inc_blk_idx(v->topleft_blk_idx);
@@ -2862,11 +2862,11 @@  static void vc1_decode_p_blocks(VC1Context *v)
                 if (apply_loop_filter)
                     ff_vc1_p_loop_filter(v);
             }
-            if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
+            if (get_bits_left(&s->gb) < 0 || get_bits_count(&s->gb) < 0) {
                 // TODO: may need modification to handle slice coding
                 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
                 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n",
-                       get_bits_count(&s->gb), v->bits, s->mb_x, s->mb_y);
+                       get_bits_count(&s->gb), s->gb.size_in_bits, s->mb_x, s->mb_y);
                 return;
             }
             inc_blk_idx(v->topleft_blk_idx);
@@ -2951,11 +2951,11 @@  static void vc1_decode_b_blocks(VC1Context *v)
                 if (v->s.loop_filter)
                     ff_vc1_i_loop_filter(v);
             }
-            if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
+            if (get_bits_left(&s->gb) < 0 || get_bits_count(&s->gb) < 0) {
                 // TODO: may need modification to handle slice coding
                 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
                 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n",
-                       get_bits_count(&s->gb), v->bits, s->mb_x, s->mb_y);
+                       get_bits_count(&s->gb), s->gb.size_in_bits, s->mb_x, s->mb_y);
                 return;
             }
         }
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index a67957448d..b84c16eef0 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1031,7 +1031,6 @@  static int vc1_decode_frame(AVCodecContext *avctx, void *data,
 
         ff_mpeg_er_frame_start(s);
 
-        v->bits = FFMIN(buf_size * 8, s->gb.size_in_bits);
         v->end_mb_x = s->mb_width;
         if (v->field_mode) {
             s->current_picture.f->linesize[0] <<= 1;
@@ -1107,7 +1106,6 @@  static int vc1_decode_frame(AVCodecContext *avctx, void *data,
             ff_vc1_decode_blocks(v);
             if (i != n_slices) {
                 s->gb = slices[i].gb;
-                v->bits = FFMIN(buf_size * 8, s->gb.size_in_bits);
             }
         }
         if (v->field_mode) {