[FFmpeg-cvslog] avcodec/h261dec: Simplify decoding motion vectors

Andreas Rheinhardt git at videolan.org
Thu Jun 20 20:01:16 EEST 2024


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Jun 13 15:45:19 2024 +0200| [9933dfe103166c43569a3b5bd4649b2e7fcefa0a] | committer: Andreas Rheinhardt

avcodec/h261dec: Simplify decoding motion vectors

Don't use a LUT to negate followed by a conditional ordinary
negation immediately thereafter. Instead fold the two.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

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

 libavcodec/h261dec.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 6df8588bb6..852de8d535 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -208,10 +208,6 @@ static int h261_decode_mb_skipped(H261DecContext *h, int mba1, int mba2)
     return 0;
 }
 
-static const int mvmap[17] = {
-    0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16
-};
-
 static int decode_mv_component(GetBitContext *gb, int v)
 {
     int mv_diff = get_vlc2(gb, h261_mv_vlc, H261_MV_VLC_BITS, 2);
@@ -220,9 +216,7 @@ static int decode_mv_component(GetBitContext *gb, int v)
     if (mv_diff < 0)
         return v;
 
-    mv_diff = mvmap[mv_diff];
-
-    if (mv_diff && !get_bits1(gb))
+    if (mv_diff && get_bits1(gb))
         mv_diff = -mv_diff;
 
     v += mv_diff;



More information about the ffmpeg-cvslog mailing list