diff --git a/libavcodec/rl.c b/libavcodec/rl.c index fab96d63a1..4ce003ccf4 100644 --- a/libavcodec/rl.c +++ b/libavcodec/rl.c @@ -27,16 +27,13 @@ av_cold void ff_rl_init(RLTable *rl, uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3]) { - int8_t max_level[MAX_RUN + 1], max_run[MAX_LEVEL + 1]; - uint8_t index_run[MAX_RUN + 1]; int last, run, level, start, end, i; - /* If rl->max_level[0] is set, this RLTable has already been initialized */ - if (rl->max_level[0]) - return; - /* compute max_level[], max_run[] and index_run[] */ for (last = 0; last < 2; last++) { + int8_t *max_level = static_store[last]; + int8_t *max_run = static_store[last] + MAX_RUN + 1; + uint8_t *index_run = static_store[last] + MAX_RUN + 1 + MAX_LEVEL + 1; if (last == 0) { start = 0; end = rl->last; @@ -45,8 +42,6 @@ av_cold void ff_rl_init(RLTable *rl, end = rl->n; } - memset(max_level, 0, MAX_RUN + 1); - memset(max_run, 0, MAX_LEVEL + 1); memset(index_run, rl->n, MAX_RUN + 1); for (i = start; i < end; i++) { run = rl->table_run[i]; @@ -58,12 +53,9 @@ av_cold void ff_rl_init(RLTable *rl, if (run > max_run[level]) max_run[level] = run; } - rl->max_level[last] = static_store[last]; - memcpy(rl->max_level[last], max_level, MAX_RUN + 1); - rl->max_run[last] = static_store[last] + MAX_RUN + 1; - memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1); - rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2; - memcpy(rl->index_run[last], index_run, MAX_RUN + 1); + rl->max_level[last] = max_level; + rl->max_run[last] = max_run; + rl->index_run[last] = index_run; } } diff --git a/libavcodec/rl.h b/libavcodec/rl.h index 5aae698e31..07e3da5003 100644 --- a/libavcodec/rl.h +++ b/libavcodec/rl.h @@ -72,15 +72,12 @@ void ff_rl_init_vlc(RLTable *rl, unsigned static_size); #define INIT_VLC_RL(rl, static_size)\ {\ - int q;\ static RL_VLC_ELEM rl_vlc_table[32][static_size];\ \ - if(!rl.rl_vlc[0]){\ - for(q=0; q<32; q++)\ - rl.rl_vlc[q]= rl_vlc_table[q];\ + for (int q = 0; q < 32; q++) \ + rl.rl_vlc[q] = rl_vlc_table[q]; \ \ - ff_rl_init_vlc(&rl, static_size);\ - }\ + ff_rl_init_vlc(&rl, static_size); \ } #define INIT_FIRST_VLC_RL(rl, static_size) \