[FFmpeg-cvslog] avcodec/lagarith: Avoid unnecessary VLC structure

Andreas Rheinhardt git at videolan.org
Tue Oct 31 22:15:45 EET 2023


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Sep 24 15:56:44 2023 +0200| [0a610e22c168b361ee65f5abbd1362ee7fd5ceee] | committer: Andreas Rheinhardt

avcodec/lagarith: Avoid unnecessary VLC structure

Everything besides VLC.table is basically write-only
and even VLC.table can be removed by accessing the
underlying table directly.

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

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

 libavcodec/lagarith.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c
index 9574f78871..75b557e518 100644
--- a/libavcodec/lagarith.c
+++ b/libavcodec/lagarith.c
@@ -60,7 +60,7 @@ typedef struct LagarithContext {
     int zeros_rem;              /**< number of zero bytes remaining to output */
 } LagarithContext;
 
-static VLC lag_tab;
+static VLCElem lag_tab[1 << VLC_BITS];
 
 static const uint8_t lag_bits[] = {
     7, 7, 2, 7, 3, 4, 5, 6, 7, 7, 7, 7, 7, 6, 7, 4, 5, 7, 7, 7, 7,
@@ -85,8 +85,8 @@ static const uint8_t lag_symbols[] = {
 
 static av_cold void lag_init_static_data(void)
 {
-    VLC_INIT_SPARSE_STATIC(&lag_tab, VLC_BITS, FF_ARRAY_ELEMS(lag_bits),
-                           lag_bits, 1, 1, lag_codes, 1, 1, lag_symbols, 1, 1, 128);
+    VLC_INIT_STATIC_SPARSE_TABLE(lag_tab, VLC_BITS, FF_ARRAY_ELEMS(lag_bits),
+                                 lag_bits, 1, 1, lag_codes, 1, 1, lag_symbols, 1, 1, 0);
 }
 
 /**
@@ -136,7 +136,7 @@ static int lag_decode_prob(GetBitContext *gb, uint32_t *value)
 {
     unsigned val, bits;
 
-    bits = get_vlc2(gb, lag_tab.table, VLC_BITS, 1);
+    bits = get_vlc2(gb, lag_tab, VLC_BITS, 1);
     if (bits > 31) {
         *value = 0;
         return AVERROR_INVALIDDATA;



More information about the ffmpeg-cvslog mailing list