]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/rl: Allow to create only a few VLC tables
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 8 Dec 2020 21:38:05 +0000 (22:38 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 25 Jan 2021 13:51:53 +0000 (14:51 +0100)
It is not uncommon that only the first one is used; this is similar to
ff_init_2d_vlc_rl().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/rl.c
libavcodec/rl.h

index c532b5bf5654444e9899fcdde635b8b12fe5c529..93153ff7234ff4839a74e5ea3ef907307cb6e17d 100644 (file)
@@ -80,6 +80,9 @@ av_cold void ff_rl_init_vlc(RLTable *rl, unsigned static_size)
         int qmul = q * 2;
         int qadd = (q - 1) | 1;
 
+        if (!rl->rl_vlc[q])
+            return;
+
         if (q == 0) {
             qmul = 1;
             qadd = 0;
index a83debccf78879e679b1f97271551627696429da..26e0b32a907a1baa2e1b369aeab7bb3600c67ca4 100644 (file)
@@ -68,6 +68,14 @@ void ff_rl_init_vlc(RLTable *rl, unsigned static_size);
     }\
 }
 
+#define INIT_FIRST_VLC_RL(rl, static_size)              \
+do {                                                    \
+    static RL_VLC_ELEM rl_vlc_table[static_size];       \
+                                                        \
+    rl.rl_vlc[0] = rl_vlc_table;                        \
+    ff_rl_init_vlc(&rl, static_size);                   \
+} while (0)
+
 static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
 {
     int index;