summaryrefslogtreecommitdiff
path: root/libavcodec/vp3.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-11-06 10:35:12 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-12-08 17:51:46 +0100
commit4cb4345f7895d1a169941df087152bf18f78a2f6 (patch)
treec54d1bbfbeb7c5a41a45e8bc43e53b112be985c4 /libavcodec/vp3.c
parent22241d12c7bc7f317832d8101ebed8d2db78a41f (diff)
avcodec/vp3: Make tables used to initialize VLCs smaller
This is possible by switching to ff_init_vlc_from_lengths() because it allows to replace codes of type uint16_t by symbols of type uint8_t; in some cases (like here) it also allows to replace explicitly coded codes by implicitly coded symbols. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/vp3.c')
-rw-r--r--libavcodec/vp3.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 34c48f8725..7d1d2411ab 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -2434,17 +2434,21 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
/* init VLC tables */
if (s->version < 2) {
for (i = 0; i < FF_ARRAY_ELEMS(s->coeff_vlc); i++) {
- if ((ret = init_vlc(&s->coeff_vlc[i], 11, 32,
- &vp3_bias[i][0][1], 4, 2,
- &vp3_bias[i][0][0], 4, 2, 0)) < 0)
+ ret = ff_init_vlc_from_lengths(&s->coeff_vlc[i], 11, 32,
+ &vp3_bias[i][0][1], 2,
+ &vp3_bias[i][0][0], 2, 1,
+ 0, 0, avctx);
+ if (ret < 0)
return ret;
}
#if CONFIG_VP4_DECODER
} else { /* version >= 2 */
for (i = 0; i < FF_ARRAY_ELEMS(s->coeff_vlc); i++) {
- if ((ret = init_vlc(&s->coeff_vlc[i], 11, 32,
- &vp4_bias[i][0][1], 4, 2,
- &vp4_bias[i][0][0], 4, 2, 0)) < 0)
+ ret = ff_init_vlc_from_lengths(&s->coeff_vlc[i], 11, 32,
+ &vp4_bias[i][0][1], 2,
+ &vp4_bias[i][0][0], 2, 1,
+ 0, 0, avctx);
+ if (ret < 0)
return ret;
}
#endif
@@ -2463,14 +2467,16 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
if (ret < 0)
return ret;
- if ((ret = init_vlc(&s->fragment_run_length_vlc, 5, 30,
- &fragment_run_length_vlc_table[0][1], 4, 2,
- &fragment_run_length_vlc_table[0][0], 4, 2, 0)) < 0)
+ ret = ff_init_vlc_from_lengths(&s->fragment_run_length_vlc, 5, 30,
+ fragment_run_length_vlc_len, 1,
+ NULL, 0, 0, 0, 0, avctx);
+ if (ret < 0)
return ret;
- if ((ret = init_vlc(&s->mode_code_vlc, 3, 8,
- &mode_code_vlc_table[0][1], 2, 1,
- &mode_code_vlc_table[0][0], 2, 1, 0)) < 0)
+ ret = ff_init_vlc_from_lengths(&s->mode_code_vlc, 3, 8,
+ mode_code_vlc_len, 1,
+ NULL, 0, 0, 0, 0, avctx);
+ if (ret < 0)
return ret;
if ((ret = init_vlc(&s->motion_vector_vlc, 6, 63,