From e48cd2de98c3dbac998c76c54749d1b534b32ff6 Mon Sep 17 00:00:00 2001 From: Reimar Döffinger Date: Sun, 31 Aug 2014 20:07:40 +0200 Subject: rl.h: Use on-stack temporary VLC tables instead of having them static. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Reimar Döffinger --- libavcodec/mpeg12.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'libavcodec/mpeg12.c') diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index cb00baf809..fc43a53701 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -70,22 +70,21 @@ static const uint8_t table_mb_btype[11][2] = { #define INIT_2D_VLC_RL(rl, static_size)\ {\ static RL_VLC_ELEM rl_vlc_table[static_size];\ - VLC tmp_vlc;\ - INIT_VLC_STATIC(&tmp_vlc, TEX_VLC_BITS, rl.n + 2,\ - &rl.table_vlc[0][1], 4, 2,\ - &rl.table_vlc[0][0], 4, 2, static_size);\ -\ rl.rl_vlc[0] = rl_vlc_table;\ - init_2d_vlc_rl(&rl, &tmp_vlc);\ + init_2d_vlc_rl(&rl, static_size);\ } -static av_cold void init_2d_vlc_rl(RLTable *rl, const VLC *vlc) +static av_cold void init_2d_vlc_rl(RLTable *rl, unsigned static_size) { int i; - - for (i = 0; i < vlc->table_size; i++) { - int code = vlc->table[i][0]; - int len = vlc->table[i][1]; + VLC_TYPE table[680][2] = {{0}}; + VLC vlc = { .table = table, .table_allocated = static_size }; + av_assert0(static_size <= FF_ARRAY_ELEMS(table)); + init_vlc(&vlc, TEX_VLC_BITS, rl->n + 2, &rl->table_vlc[0][1], 4, 2, &rl->table_vlc[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC); + + for (i = 0; i < vlc.table_size; i++) { + int code = vlc.table[i][0]; + int len = vlc.table[i][1]; int level, run; if (len == 0) { // illegal code -- cgit v1.2.3