aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-09-04 22:44:04 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-09-07 00:07:45 +0200
commit232e88928eee71afa55233d021eeda25eb3ed5b4 (patch)
treed7e7cdba3369d8ee481fb2722bd913febcd15974 /libavcodec
parentcca7f571bac7e5c7fb35f2faef5e4a23eb77516a (diff)
downloadffmpeg-232e88928eee71afa55233d021eeda25eb3ed5b4.tar.gz
avcodec/wmaprodec: Use symbol table more efficiently
By using a symbol table one can already bake in applying a LUT on the return value of get_vlc2(). So change the symbol table for the vec2 and vec4 tables to avoid using the symbol_to_vec2/4 LUTs. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/wmaprodata.h147
-rw-r--r--libavcodec/wmaprodec.c22
2 files changed, 72 insertions, 97 deletions
diff --git a/libavcodec/wmaprodata.h b/libavcodec/wmaprodata.h
index 3a30be40b5..057ce1d02d 100644
--- a/libavcodec/wmaprodata.h
+++ b/libavcodec/wmaprodata.h
@@ -325,67 +325,73 @@ static const float coef1_level[HUFF_COEF1_SIZE] = {
*/
#define HUFF_VEC4_SIZE 127
#define HUFF_VEC4_MAXBITS 14
-static const uint8_t vec4_table[HUFF_VEC4_SIZE][2] = {
- { 126, 1 }, { 76, 6 }, { 28, 8 }, { 93, 10 }, { 69, 10 },
- { 117, 10 }, { 98, 10 }, { 31, 8 }, { 84, 8 }, { 38, 10 },
- { 9, 10 }, { 108, 9 }, { 96, 8 }, { 73, 8 }, { 67, 9 },
- { 121, 12 }, { 90, 12 }, { 110, 11 }, { 35, 12 }, { 54, 12 },
- { 17, 11 }, { 86, 9 }, { 44, 9 }, { 82, 8 }, { 41, 8 },
- { 36, 9 }, { 103, 9 }, { 78, 8 }, { 66, 8 }, { 11, 9 },
- { 97, 9 }, { 4, 12 }, { 19, 12 }, { 70, 12 }, { 55, 14 },
- { 20, 14 }, { 5, 13 }, { 51, 11 }, { 94, 11 }, { 106, 9 },
- { 101, 8 }, { 83, 9 }, { 42, 9 }, { 45, 11 }, { 46, 11 },
- { 112, 10 }, { 99, 9 }, { 8, 8 }, { 56, 6 }, { 1, 6 },
- { 75, 6 }, { 27, 6 }, { 72, 6 }, { 62, 6 }, { 113, 11 },
- { 124, 11 }, { 114, 10 }, { 15, 11 }, { 116, 11 }, { 24, 10 },
- { 59, 10 }, { 39, 11 }, { 10, 11 }, { 118, 9 }, { 105, 7 },
- { 71, 6 }, { 77, 7 }, { 85, 7 }, { 21, 6 }, { 7, 6 },
- { 6, 6 }, { 0, 5 }, { 79, 7 }, { 100, 11 }, { 48, 11 },
- { 87, 10 }, { 107, 9 }, { 92, 8 }, { 57, 6 }, { 119, 9 },
- { 29, 9 }, { 16, 10 }, { 49, 10 }, { 64, 9 }, { 95, 8 },
- { 58, 8 }, { 26, 6 }, { 61, 6 }, { 22, 6 }, { 23, 8 },
- { 81, 8 }, { 13, 9 }, { 53, 12 }, { 52, 12 }, { 123, 11 },
- { 33, 10 }, { 12, 8 }, { 40, 8 }, { 30, 8 }, { 47, 10 },
- { 111, 10 }, { 3, 10 }, { 68, 10 }, { 74, 9 }, { 115, 9 },
- { 91, 8 }, { 120, 10 }, { 25, 11 }, { 122, 11 }, { 89, 9 },
- { 2, 8 }, { 37, 8 }, { 65, 8 }, { 43, 9 }, { 34, 9 },
- { 14, 10 }, { 60, 11 }, { 18, 12 }, { 125, 12 }, { 50, 9 },
- { 80, 9 }, { 88, 9 }, { 109, 8 }, { 32, 8 }, { 102, 7 },
- { 104, 7 }, { 63, 7 },
+static const uint8_t vec4_lens[HUFF_VEC4_SIZE] = {
+ 1, 6, 8, 10, 10, 10, 10, 8, 8, 10, 10, 9, 8, 8, 9, 12, 12, 11,
+ 12, 12, 11, 9, 9, 8, 8, 9, 9, 8, 8, 9, 9, 12, 12, 12, 14, 14,
+ 13, 11, 11, 9, 8, 9, 9, 11, 11, 10, 9, 8, 6, 6, 6, 6, 6, 6,
+ 11, 11, 10, 11, 11, 10, 10, 11, 11, 9, 7, 6, 7, 7, 6, 6, 6, 5,
+ 7, 11, 11, 10, 9, 8, 6, 9, 9, 10, 10, 9, 8, 8, 6, 6, 6, 8,
+ 8, 9, 12, 12, 11, 10, 8, 8, 8, 10, 10, 10, 10, 9, 9, 8, 10, 11,
+ 11, 9, 8, 8, 8, 9, 9, 10, 11, 12, 12, 9, 9, 9, 8, 8, 7, 7,
+ 7,
+};
+
+/* The entry in the following table with symbol zero indicates
+ * that four further entries are coded explicitly; all other
+ * entries encode four numbers in the 0..15 range via
+ * the four nibbles of (symbol - 1). */
+static const uint16_t vec4_syms[HUFF_VEC4_SIZE] = {
+ 0, 4370, 275, 8195, 4146, 12545, 8225, 290, 4625, 515,
+ 20, 8706, 8210, 4355, 4131, 16385, 5121, 8961, 321, 1041,
+ 51, 4641, 546, 4610, 530, 513, 8451, 4385, 4130, 33,
+ 8211, 5, 66, 4161, 1281, 81, 6, 801, 8196, 8481,
+ 8449, 4611, 531, 561, 769, 12290, 8226, 19, 4097, 2,
+ 4369, 274, 4354, 4114, 12291, 16641, 12305, 49, 12321, 260,
+ 4100, 516, 21, 12546, 8466, 4353, 4371, 4626, 257, 18,
+ 17, 1, 4386, 8241, 771, 4865, 8705, 8194, 4098, 12561,
+ 276, 50, 785, 4116, 8209, 4099, 273, 4113, 258, 259,
+ 4609, 35, 1026, 1025, 16401, 305, 34, 529, 289, 770,
+ 12289, 4, 4145, 4356, 12306, 8193, 12801, 261, 16386, 4881,
+ 3, 514, 4129, 545, 306, 36, 4101, 65, 20481, 786,
+ 4401, 4866, 8721, 291, 8450, 8465, 4115,
};
#define HUFF_VEC2_SIZE 137
#define HUFF_VEC2_MAXBITS 12
+/* The entry in the following table with symbol zero indicates
+ * that two further entries are coded explicitly; all other
+ * entries encode two numbers in the 0..15 range via
+ * (symbol - 1) & 0xF and (symbol - 1) >> 4. */
static const uint8_t vec2_table[HUFF_VEC2_SIZE][2] = {
- { 18, 5 }, { 119, 10 }, { 132, 11 }, { 44, 11 }, { 68, 10 },
- { 121, 11 }, { 11, 11 }, { 75, 8 }, { 72, 7 }, { 36, 7 },
- { 104, 9 }, { 122, 10 }, { 27, 10 }, { 88, 9 }, { 66, 9 },
- { 33, 5 }, { 48, 6 }, { 91, 9 }, { 7, 9 }, { 85, 8 },
- { 62, 7 }, { 136, 3 }, { 64, 8 }, { 97, 9 }, { 80, 10 },
- { 123, 10 }, { 92, 8 }, { 120, 10 }, { 9, 10 }, { 42, 10 },
- { 108, 10 }, { 59, 6 }, { 20, 6 }, { 23, 8 }, { 109, 9 },
- { 25, 9 }, { 58, 7 }, { 4, 7 }, { 134, 11 }, { 133, 12 },
- { 14, 12 }, { 124, 10 }, { 110, 9 }, { 93, 8 }, { 38, 8 },
- { 78, 9 }, { 105, 9 }, { 73, 7 }, { 50, 7 }, { 40, 9 },
- { 56, 10 }, { 30, 11 }, { 126, 11 }, { 125, 10 }, { 69, 10 },
- { 111, 9 }, { 35, 6 }, { 60, 6 }, { 31, 6 }, { 2, 6 },
- { 16, 6 }, { 1, 6 }, { 86, 8 }, { 76, 8 }, { 94, 8 },
- { 52, 8 }, { 46, 5 }, { 19, 5 }, { 98, 9 }, { 54, 9 },
- { 28, 10 }, { 127, 10 }, { 106, 9 }, { 81, 8 }, { 6, 8 },
- { 89, 9 }, { 12, 11 }, { 135, 12 }, { 15, 12 }, { 43, 10 },
- { 112, 9 }, { 67, 9 }, { 82, 7 }, { 22, 7 }, { 74, 7 },
- { 63, 7 }, { 128, 10 }, { 115, 10 }, { 100, 9 }, { 65, 8 },
- { 47, 5 }, { 34, 5 }, { 95, 8 }, { 57, 10 }, { 10, 10 },
- { 116, 9 }, { 0, 7 }, { 3, 6 }, { 45, 6 }, { 61, 6 },
- { 8, 9 }, { 26, 9 }, { 101, 8 }, { 37, 7 }, { 49, 6 },
- { 83, 7 }, { 24, 8 }, { 113, 9 }, { 79, 9 }, { 87, 8 },
- { 117, 9 }, { 129, 10 }, { 131, 10 }, { 107, 9 }, { 99, 9 },
- { 39, 8 }, { 102, 8 }, { 41, 9 }, { 118, 9 }, { 96, 8 },
- { 77, 8 }, { 70, 7 }, { 5, 7 }, { 51, 7 }, { 55, 9 },
- { 29, 10 }, { 130, 11 }, { 13, 11 }, { 114, 9 }, { 90, 9 },
- { 71, 6 }, { 21, 6 }, { 84, 7 }, { 103, 8 }, { 53, 8 },
- { 17, 4 }, { 32, 4 },
+ { 19, 5 }, { 165, 10 }, { 211, 11 }, { 46, 11 }, { 75, 10 },
+ { 177, 11 }, { 12, 11 }, { 86, 8 }, { 83, 7 }, { 38, 7 },
+ { 133, 9 }, { 178, 10 }, { 28, 10 }, { 104, 9 }, { 73, 9 },
+ { 35, 5 }, { 52, 6 }, { 113, 9 }, { 8, 9 }, { 101, 8 },
+ { 69, 7 }, { 0, 3 }, { 71, 8 }, { 119, 9 }, { 91, 10 },
+ { 179, 10 }, { 114, 8 }, { 166, 10 }, { 10, 10 }, { 44, 10 },
+ { 145, 10 }, { 66, 6 }, { 21, 6 }, { 24, 8 }, { 146, 9 },
+ { 26, 9 }, { 65, 7 }, { 5, 7 }, { 226, 11 }, { 225, 12 },
+ { 15, 12 }, { 180, 10 }, { 147, 9 }, { 115, 8 }, { 40, 8 },
+ { 89, 9 }, { 134, 9 }, { 84, 7 }, { 54, 7 }, { 42, 9 },
+ { 60, 10 }, { 31, 11 }, { 193, 11 }, { 181, 10 }, { 76, 10 },
+ { 148, 9 }, { 37, 6 }, { 67, 6 }, { 33, 6 }, { 3, 6 },
+ { 17, 6 }, { 2, 6 }, { 102, 8 }, { 87, 8 }, { 116, 8 },
+ { 56, 8 }, { 50, 5 }, { 20, 5 }, { 120, 9 }, { 58, 9 },
+ { 29, 10 }, { 194, 10 }, { 135, 9 }, { 97, 8 }, { 7, 8 },
+ { 105, 9 }, { 13, 11 }, { 241, 12 }, { 16, 12 }, { 45, 10 },
+ { 149, 9 }, { 74, 9 }, { 98, 7 }, { 23, 7 }, { 85, 7 },
+ { 70, 7 }, { 195, 10 }, { 161, 10 }, { 129, 9 }, { 72, 8 },
+ { 51, 5 }, { 36, 5 }, { 117, 8 }, { 61, 10 }, { 11, 10 },
+ { 162, 9 }, { 1, 7 }, { 4, 6 }, { 49, 6 }, { 68, 6 },
+ { 9, 9 }, { 27, 9 }, { 130, 8 }, { 39, 7 }, { 53, 6 },
+ { 99, 7 }, { 25, 8 }, { 150, 9 }, { 90, 9 }, { 103, 8 },
+ { 163, 9 }, { 196, 10 }, { 210, 10 }, { 136, 9 }, { 121, 9 },
+ { 41, 8 }, { 131, 8 }, { 43, 9 }, { 164, 9 }, { 118, 8 },
+ { 88, 8 }, { 81, 7 }, { 6, 7 }, { 55, 7 }, { 59, 9 },
+ { 30, 10 }, { 209, 11 }, { 14, 11 }, { 151, 9 }, { 106, 9 },
+ { 82, 6 }, { 22, 6 }, { 100, 7 }, { 132, 8 }, { 57, 8 },
+ { 18, 4 }, { 34, 4 },
};
@@ -414,37 +420,6 @@ static const uint8_t vec1_table[HUFF_VEC1_SIZE][2] = {
{ 80, 10 }, { 81, 10 }, { 43, 8 }, { 44, 8 }, { 24, 6 },
{ 12, 4 },
};
-
-
-static const uint16_t symbol_to_vec4[HUFF_VEC4_SIZE] = {
- 0, 1, 2, 3, 4, 5, 16, 17, 18, 19,
- 20, 32, 33, 34, 35, 48, 49, 50, 64, 65,
- 80, 256, 257, 258, 259, 260, 272, 273, 274, 275,
- 288, 289, 290, 304, 305, 320, 512, 513, 514, 515,
- 528, 529, 530, 544, 545, 560, 768, 769, 770, 784,
- 785, 800, 1024, 1025, 1040, 1280, 4096, 4097, 4098, 4099,
- 4100, 4112, 4113, 4114, 4115, 4128, 4129, 4130, 4144, 4145,
- 4160, 4352, 4353, 4354, 4355, 4368, 4369, 4370, 4384, 4385,
- 4400, 4608, 4609, 4610, 4624, 4625, 4640, 4864, 4865, 4880,
- 5120, 8192, 8193, 8194, 8195, 8208, 8209, 8210, 8224, 8225,
- 8240, 8448, 8449, 8450, 8464, 8465, 8480, 8704, 8705, 8720,
- 8960, 12288, 12289, 12290, 12304, 12305, 12320, 12544, 12545, 12560,
- 12800, 16384, 16385, 16400, 16640, 20480, 0,
-};
-
-
-static const uint8_t symbol_to_vec2[HUFF_VEC2_SIZE] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 64, 65,
- 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 80, 81, 82, 83, 84,
- 85, 86, 87, 88, 89, 90, 96, 97, 98, 99, 100, 101, 102, 103, 104,
- 105, 112, 113, 114, 115, 116, 117, 118, 119, 120, 128, 129, 130, 131, 132,
- 133, 134, 135, 144, 145, 146, 147, 148, 149, 150, 160, 161, 162, 163, 164,
- 165, 176, 177, 178, 179, 180, 192, 193, 194, 195, 208, 209, 210, 224, 225,
- 240, 0,
-};
/** @} */
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 698841dcaf..701dfa955c 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -331,11 +331,11 @@ static av_cold void decode_init_static(void)
&coef1_table[0][1], 2,
&coef1_table[0][0], 2, 1, 0, 0, 3912);
INIT_VLC_STATIC_FROM_LENGTHS(&vec4_vlc, VLCBITS, HUFF_VEC4_SIZE,
- &vec4_table[0][1], 2,
- &vec4_table[0][0], 2, 1, 0, 0, 604);
+ vec4_lens, 1,
+ vec4_syms, 2, 2, -1, 0, 604);
INIT_VLC_STATIC_FROM_LENGTHS(&vec2_vlc, VLCBITS, HUFF_VEC2_SIZE,
&vec2_table[0][1], 2,
- &vec2_table[0][0], 2, 1, 0, 0, 562);
+ &vec2_table[0][0], 2, 1, -1, 0, 562);
INIT_VLC_STATIC_FROM_LENGTHS(&vec1_vlc, VLCBITS, HUFF_VEC1_SIZE,
&vec1_table[0][1], 2,
&vec1_table[0][0], 2, 1, 0, 0, 562);
@@ -957,10 +957,10 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c)
idx = get_vlc2(&s->gb, vec4_vlc.table, VLCBITS, VEC4MAXDEPTH);
- if (idx == HUFF_VEC4_SIZE - 1) {
+ if ((int)idx < 0) {
for (i = 0; i < 4; i += 2) {
idx = get_vlc2(&s->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH);
- if (idx == HUFF_VEC2_SIZE - 1) {
+ if ((int)idx < 0) {
uint32_t v0, v1;
v0 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);
if (v0 == HUFF_VEC1_SIZE - 1)
@@ -971,15 +971,15 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c)
vals[i ] = av_float2int(v0);
vals[i+1] = av_float2int(v1);
} else {
- vals[i] = fval_tab[symbol_to_vec2[idx] >> 4 ];
- vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF];
+ vals[i] = fval_tab[idx >> 4 ];
+ vals[i+1] = fval_tab[idx & 0xF];
}
}
} else {
- vals[0] = fval_tab[ symbol_to_vec4[idx] >> 12 ];
- vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF];
- vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF];
- vals[3] = fval_tab[ symbol_to_vec4[idx] & 0xF];
+ vals[0] = fval_tab[ idx >> 12 ];
+ vals[1] = fval_tab[(idx >> 8) & 0xF];
+ vals[2] = fval_tab[(idx >> 4) & 0xF];
+ vals[3] = fval_tab[ idx & 0xF];
}
/** decode sign */