diff mbox series

[FFmpeg-devel,06/61] avcodec/h264_cavlc: Remove code duplication

Message ID GV1P250MB0737B04ECFD6ED88E83154F58FC3A@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit ab8a8246c84463fa144ddc97eba7e65e07af202c
Headers show
Series [FFmpeg-devel,01/61] avcodec/vlc: Add functions to init static VLCElem[] without VLC | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 26, 2023, 10:16 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h264_cavlc.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index f17e30e853..19f067afb4 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -419,20 +419,13 @@  static int decode_residual(const H264Context *h, H264SliceContext *sl,
         else
             coeff_token = get_vlc2(gb, chroma422_dc_coeff_token_vlc_table,
                                    CHROMA422_DC_COEFF_TOKEN_VLC_BITS, 1);
-        total_coeff= coeff_token>>2;
     }else{
-        if(n >= LUMA_DC_BLOCK_INDEX){
-            total_coeff= pred_non_zero_count(h, sl, (n - LUMA_DC_BLOCK_INDEX)*16);
-            coeff_token = get_vlc2(gb, coeff_token_vlc[total_coeff],
-                                   COEFF_TOKEN_VLC_BITS, 2);
-            total_coeff= coeff_token>>2;
-        }else{
-            total_coeff= pred_non_zero_count(h, sl, n);
-            coeff_token = get_vlc2(gb, coeff_token_vlc[total_coeff],
-                                   COEFF_TOKEN_VLC_BITS, 2);
-            total_coeff= coeff_token>>2;
-        }
+        total_coeff = pred_non_zero_count(h, sl, n >= LUMA_DC_BLOCK_INDEX ?
+                                                 (n - LUMA_DC_BLOCK_INDEX) * 16 : n);
+        coeff_token = get_vlc2(gb, coeff_token_vlc[total_coeff],
+                               COEFF_TOKEN_VLC_BITS, 2);
     }
+    total_coeff = coeff_token >> 2;
     sl->non_zero_count_cache[scan8[n]] = total_coeff;
 
     //FIXME set last_non_zero?