[FFmpeg-devel] [PATCH 04/19] avcodec/vc1: Don't use VLC to read bfraction

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Oct 31 01:56:16 EET 2022


The VLC here is very simple, so that it can just be read
by two get_bits().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/vc1.c     |  8 ++++----
 libavcodec/vc1data.c | 21 ---------------------
 libavcodec/vc1data.h |  4 ----
 3 files changed, 4 insertions(+), 29 deletions(-)

diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index 9b4e951baa..f6468b54c7 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -613,7 +613,10 @@ static void rotate_luts(VC1Context *v)
 }
 
 static int read_bfraction(VC1Context *v, GetBitContext* gb) {
-    int bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
+    int bfraction_lut_index = get_bits(gb, 3);
+
+    if (bfraction_lut_index == 7)
+        bfraction_lut_index = 7 + get_bits(gb, 4);
 
     if (bfraction_lut_index == 21) {
         av_log(v->s.avctx, AV_LOG_ERROR, "bfraction invalid\n");
@@ -1582,9 +1585,6 @@ static av_cold void vc1_init_static(void)
 {
     static VLCElem vlc_table[32372];
 
-    INIT_VLC_STATIC(&ff_vc1_bfraction_vlc, VC1_BFRACTION_VLC_BITS, 23,
-                    ff_vc1_bfraction_bits,  1, 1,
-                    ff_vc1_bfraction_codes, 1, 1, 1 << VC1_BFRACTION_VLC_BITS);
     INIT_VLC_STATIC(&ff_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4,
                     ff_vc1_norm2_bits,  1, 1,
                     ff_vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS);
diff --git a/libavcodec/vc1data.c b/libavcodec/vc1data.c
index 844bc0f5c5..01a9767d51 100644
--- a/libavcodec/vc1data.c
+++ b/libavcodec/vc1data.c
@@ -102,8 +102,6 @@ const uint8_t ff_vc1_pquant_table[3][32] = {
  *  @todo TODO move this into the context
  */
 //@{
-#define VC1_BFRACTION_VLC_BITS 7
-VLC ff_vc1_bfraction_vlc;
 #define VC1_IMODE_VLC_BITS 4
 VLC ff_vc1_imode_vlc;
 #define VC1_NORM2_VLC_BITS 3
@@ -171,25 +169,6 @@ const int16_t ff_vc1_bfraction_lut[23] = {
 };
 #endif
 
-const uint8_t ff_vc1_bfraction_bits[23] = {
-    3, 3, 3, 3,
-    3, 3, 3,
-    7, 7, 7, 7,
-    7, 7, 7, 7,
-    7, 7, 7, 7,
-    7, 7,
-    7, 7
-};
-const uint8_t ff_vc1_bfraction_codes[23] = {
-      0,   1,   2,   3,
-      4,   5,   6,
-    112, 113, 114, 115,
-    116, 117, 118, 119,
-    120, 121, 122, 123,
-    124, 125,
-    126, 127
-};
-
 //Same as H.264
 const AVRational ff_vc1_pixel_aspect[16] = {
     {   0,  1 },
diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h
index 90dd8baf61..3e45ef1e79 100644
--- a/libavcodec/vc1data.h
+++ b/libavcodec/vc1data.h
@@ -53,8 +53,6 @@ extern const uint8_t ff_vc1_mbmode_intfrp[2][15][4];
  *  @todo TODO move this into the context
  */
 //@{
-#define VC1_BFRACTION_VLC_BITS 7
-extern VLC ff_vc1_bfraction_vlc;
 #define VC1_IMODE_VLC_BITS 4
 extern VLC ff_vc1_imode_vlc;
 #define VC1_NORM2_VLC_BITS 3
@@ -100,8 +98,6 @@ extern VLC ff_vc1_ac_coeff_table[8];
 
 /* pre-computed scales for all bfractions and base=256 */
 extern const int16_t ff_vc1_bfraction_lut[23];
-extern const uint8_t ff_vc1_bfraction_bits[23];
-extern const uint8_t ff_vc1_bfraction_codes[23];
 
 //Same as H.264
 extern const AVRational ff_vc1_pixel_aspect[16];
-- 
2.34.1



More information about the ffmpeg-devel mailing list