diff mbox series

[FFmpeg-devel,2/9] avcodec/dvdec: Use ff_init_vlc_from_lengths()

Message ID AS8P250MB0744CC7DB9C6C294750FCEA98F7C9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 297e91ed2b3b51ec3bfa63a4c955941ba68a2419
Headers show
Series [FFmpeg-devel,1/9] avcodec/dvdata: Order code table by codes | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 4, 2022, 9:58 p.m. UTC
This is possible because the codes are already ordered
from left to right in the tree. It avoids having to create
the codes ourselves and will enable the codes table
to be removed altogether once the encoder stops using it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dvdec.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 3af3e82eab..8f68d2715d 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -137,7 +137,6 @@  static void dv_init_static(void)
 {
     VLCElem vlc_buf[FF_ARRAY_ELEMS(dv_rl_vlc)] = { 0 };
     VLC dv_vlc = { .table = vlc_buf, .table_allocated = FF_ARRAY_ELEMS(vlc_buf) };
-    uint16_t  new_dv_vlc_bits[NB_DV_VLC * 2];
     uint8_t    new_dv_vlc_len[NB_DV_VLC * 2];
     uint8_t    new_dv_vlc_run[NB_DV_VLC * 2];
     int16_t  new_dv_vlc_level[NB_DV_VLC * 2];
@@ -145,17 +144,14 @@  static void dv_init_static(void)
 
     /* it's faster to include sign bit in a generic VLC parsing scheme */
     for (i = 0, j = 0; i < NB_DV_VLC; i++, j++) {
-        new_dv_vlc_bits[j]  = ff_dv_vlc_bits[i];
         new_dv_vlc_len[j]   = ff_dv_vlc_len[i];
         new_dv_vlc_run[j]   = ff_dv_vlc_run[i];
         new_dv_vlc_level[j] = ff_dv_vlc_level[i];
 
         if (ff_dv_vlc_level[i]) {
-            new_dv_vlc_bits[j] <<= 1;
             new_dv_vlc_len[j]++;
 
             j++;
-            new_dv_vlc_bits[j]  = (ff_dv_vlc_bits[i] << 1) | 1;
             new_dv_vlc_len[j]   =  ff_dv_vlc_len[i] + 1;
             new_dv_vlc_run[j]   =  ff_dv_vlc_run[i];
             new_dv_vlc_level[j] = -ff_dv_vlc_level[i];
@@ -164,8 +160,9 @@  static void dv_init_static(void)
 
     /* NOTE: as a trick, we use the fact the no codes are unused
      * to accelerate the parsing of partial codes */
-    init_vlc(&dv_vlc, TEX_VLC_BITS, j, new_dv_vlc_len,
-             1, 1, new_dv_vlc_bits, 2, 2, INIT_VLC_USE_NEW_STATIC);
+    ff_init_vlc_from_lengths(&dv_vlc, TEX_VLC_BITS, j,
+                             new_dv_vlc_len, 1,
+                             NULL, 0, 0, 0, INIT_VLC_USE_NEW_STATIC, NULL);
     av_assert1(dv_vlc.table_size == 1664);
 
     for (int i = 0; i < dv_vlc.table_size; i++) {