[FFmpeg-cvslog] avcodec: Pass PutBitContext into ff_h263_encode_motion() instead of MpegEncContext

Michael Niedermayer git at videolan.org
Sun May 24 17:22:14 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun May 24 17:07:51 2015 +0200| [404fe63e23433aa559cee5366cb26f78b425e7e5] | committer: Michael Niedermayer

avcodec: Pass PutBitContext into ff_h263_encode_motion() instead of MpegEncContext

This avoids the need to dereference MpegEncContext->pb if it is
already available outside ff_h263_encode_motion()

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

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

 libavcodec/h263.h       |    6 +++---
 libavcodec/ituh263enc.c |    8 ++++----
 libavcodec/svq1enc.c    |    4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavcodec/h263.h b/libavcodec/h263.h
index 8b2e016..1f954cd 100644
--- a/libavcodec/h263.h
+++ b/libavcodec/h263.h
@@ -123,7 +123,7 @@ int av_const h263_get_picture_format(int width, int height);
 
 void ff_clean_h263_qscales(MpegEncContext *s);
 int ff_h263_resync(MpegEncContext *s);
-void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code);
+void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code);
 
 
 static inline int h263_get_motion_length(int val, int f_code){
@@ -149,8 +149,8 @@ static inline void ff_h263_encode_motion_vector(MpegEncContext * s, int x, int y
             h263_get_motion_length(x, f_code)
            +h263_get_motion_length(y, f_code));
     }else{
-        ff_h263_encode_motion(s, x, f_code);
-        ff_h263_encode_motion(s, y, f_code);
+        ff_h263_encode_motion(&s->pb, x, f_code);
+        ff_h263_encode_motion(&s->pb, y, f_code);
     }
 }
 
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index aeb2202..cbe8acb 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -642,14 +642,14 @@ void ff_h263_encode_mb(MpegEncContext * s,
     }
 }
 
-void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code)
+void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code)
 {
     int range, bit_size, sign, code, bits;
 
     if (val == 0) {
         /* zero vector */
         code = 0;
-        put_bits(&s->pb, ff_mvtab[code][1], ff_mvtab[code][0]);
+        put_bits(pb, ff_mvtab[code][1], ff_mvtab[code][0]);
     } else {
         bit_size = f_code - 1;
         range = 1 << bit_size;
@@ -663,9 +663,9 @@ void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code)
         code = (val >> bit_size) + 1;
         bits = val & (range - 1);
 
-        put_bits(&s->pb, ff_mvtab[code][1] + 1, (ff_mvtab[code][0] << 1) | sign);
+        put_bits(pb, ff_mvtab[code][1] + 1, (ff_mvtab[code][0] << 1) | sign);
         if (bit_size > 0) {
-            put_bits(&s->pb, bit_size, bits);
+            put_bits(pb, bit_size, bits);
         }
     }
 }
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index a1bab42..3fc7eca 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -421,8 +421,8 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
                     av_assert1(my     >= -32 && my     <= 31);
                     av_assert1(pred_x >= -32 && pred_x <= 31);
                     av_assert1(pred_y >= -32 && pred_y <= 31);
-                    ff_h263_encode_motion(&s->m, mx - pred_x, 1);
-                    ff_h263_encode_motion(&s->m, my - pred_y, 1);
+                    ff_h263_encode_motion(&s->m.pb, mx - pred_x, 1);
+                    ff_h263_encode_motion(&s->m.pb, my - pred_y, 1);
                     s->reorder_pb[5] = s->m.pb;
                     score[1]        += lambda * put_bits_count(&s->reorder_pb[5]);
 



More information about the ffmpeg-cvslog mailing list