diff mbox series

[FFmpeg-devel,018/114] avcodec/clearvideo: Apply VLC offset during init

Message ID 20201110104851.321029-19-andreas.rheinhardt@gmail.com
State Superseded
Headers show
Series VLC, esp. init_vlc patches
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 10, 2020, 10:47 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/clearvideo.c     |  7 +++--
 libavcodec/clearvideodata.h | 54 ++++++++++++++-----------------------
 2 files changed, 23 insertions(+), 38 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c
index 1d88a9a776..9b4f03d15e 100644
--- a/libavcodec/clearvideo.c
+++ b/libavcodec/clearvideo.c
@@ -90,7 +90,6 @@  static inline int decode_block(CLVContext *ctx, int16_t *blk, int has_ac,
 
     memset(blk, 0, sizeof(*blk) * 64);
     blk[0] = get_vlc2(gb, ctx->dc_vlc.table, CLV_VLC_BITS, 3);
-    blk[0] -= 63;
 
     if (!has_ac)
         return 0;
@@ -715,9 +714,9 @@  static av_cold int clv_decode_init(AVCodecContext *avctx)
         return AVERROR(ENOMEM);
 
     ff_idctdsp_init(&c->idsp, avctx);
-    ret = init_vlc(&c->dc_vlc, CLV_VLC_BITS, NUM_DC_CODES,
-                   clv_dc_bits,  1, 1,
-                   clv_dc_codes, 1, 1, 0);
+    ret = ff_init_vlc_from_lengths(&c->dc_vlc, CLV_VLC_BITS, NUM_DC_CODES,
+                                   clv_dc_lens, 1,
+                                   clv_dc_syms, 1, 1, -63, 0);
     if (ret) {
         av_log(avctx, AV_LOG_ERROR, "Error initialising DC VLC\n");
         return ret;
diff --git a/libavcodec/clearvideodata.h b/libavcodec/clearvideodata.h
index d2c658eb5d..7fd3793dee 100644
--- a/libavcodec/clearvideodata.h
+++ b/libavcodec/clearvideodata.h
@@ -28,42 +28,28 @@ 
 #define NUM_DC_CODES 127
 #define NUM_AC_CODES 104
 
-static const uint8_t clv_dc_codes[NUM_DC_CODES] = {
-    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-    0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
-    0x10, 0x11, 0x12, 0x13, 0x13, 0x14, 0x07, 0x0B,
-    0x0C, 0x08, 0x08, 0x09, 0x04, 0x06, 0x07, 0x05,
-    0x04, 0x05, 0x04, 0x06, 0x05, 0x06, 0x07, 0x05,
-    0x06, 0x07, 0x06, 0x07, 0x08, 0x06, 0x07, 0x08,
-    0x09, 0x0A, 0x0B, 0x07, 0x08, 0x09, 0x07, 0x08,
-    0x06, 0x07, 0x08, 0x06, 0x04, 0x05, 0x02, 0x01,
-    0x03, 0x06, 0x07, 0x07, 0x09, 0x0A, 0x0B, 0x09,
-    0x0A, 0x0B, 0x0A, 0x0B, 0x0C, 0x0D, 0x0C, 0x09,
-    0x0D, 0x0A, 0x0B, 0x08, 0x09, 0x0A, 0x0B, 0x07,
-    0x08, 0x09, 0x0A, 0x0B, 0x06, 0x07, 0x06, 0x08,
-    0x07, 0x09, 0x0A, 0x0B, 0x09, 0x0A, 0x0B, 0x0C,
-    0x14, 0x0D, 0x0D, 0x0E, 0x0F, 0x15, 0x15, 0x16,
-    0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E,
-    0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+static const uint8_t clv_dc_lens[NUM_DC_CODES] = {
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+    21, 21, 21, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18,
+    17, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14,
+    13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 10, 10, 10,
+    10, 10, 10, 10, 10,  9,  9,  9,  9,  9,  9,  9,  8,  8,  8,  8,  8,  7,  7,
+     7,  7,  7,  7,  6,  6,  5,  5,  5,  5,  3,  3,  1,
 };
 
-static const uint8_t clv_dc_bits[NUM_DC_CODES] = {
-    22, 22, 22, 22, 22, 22, 22, 22,
-    22, 22, 22, 22, 22, 22, 22, 22,
-    22, 22, 22, 21, 22, 22, 19, 20,
-    20, 19, 18, 18, 15, 17, 17, 16,
-    14, 15, 12, 13, 14, 14, 14, 12,
-    12, 12, 11, 11, 11, 10, 10, 10,
-    10, 10, 10,  9,  9,  9,  8,  8,
-     7,  7,  7,  6,  5,  5,  3,  1,
-     3,  5,  5,  6,  7,  7,  7,  8,
-     8,  8,  9,  9,  9,  9, 10, 11,
-    10, 11, 11, 12, 12, 12, 12, 13,
-    14, 14, 14, 14, 15, 15, 16, 17,
-    16, 17, 18, 18, 19, 19, 19, 19,
-    21, 19, 20, 19, 19, 21, 22, 22,
-    22, 22, 22, 22, 22, 22, 22, 22,
-    22, 22, 22, 22, 22, 22, 22,
+static const uint8_t clv_dc_syms[NUM_DC_CODES] = {
+    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
+    0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x14, 0x15, 0x6E, 0x6F, 0x70,
+    0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C,
+    0x7D, 0x7E, 0x13, 0x68, 0x6D, 0x17, 0x18, 0x6A, 0x16, 0x19, 0x64, 0x65,
+    0x66, 0x67, 0x69, 0x6B, 0x6C, 0x1A, 0x1B, 0x62, 0x63, 0x1D, 0x1E, 0x5F,
+    0x61, 0x1F, 0x5E, 0x60, 0x1C, 0x21, 0x5C, 0x5D, 0x20, 0x24, 0x25, 0x26,
+    0x58, 0x59, 0x5A, 0x5B, 0x23, 0x57, 0x22, 0x27, 0x28, 0x29, 0x53, 0x54,
+    0x55, 0x56, 0x2A, 0x2B, 0x2C, 0x4F, 0x51, 0x52, 0x2D, 0x2E, 0x2F, 0x30,
+    0x31, 0x32, 0x4E, 0x50, 0x33, 0x34, 0x35, 0x4A, 0x4B, 0x4C, 0x4D, 0x36,
+    0x37, 0x47, 0x48, 0x49, 0x38, 0x39, 0x3A, 0x44, 0x45, 0x46, 0x3B, 0x43,
+    0x3C, 0x3D, 0x41, 0x42, 0x3E, 0x40, 0x3F,
 };
 
 static const uint16_t clv_ac_syms[NUM_AC_CODES] = {