1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/hqxvlc: Make cbp_vlc static

This is trivial as well as beneficial because frame threads
now use the same table, saving cache/memory.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-03-13 21:04:39 +01:00
parent c9d87f4a85
commit 5dd83ecfb2
2 changed files with 10 additions and 12 deletions

View File

@ -68,7 +68,6 @@ typedef struct HQXContext {
unsigned int data_size;
uint32_t slice_off[17];
VLC cbp_vlc;
VLC dc_vlc[3];
} HQXContext;
@ -224,12 +223,12 @@ static int hqx_decode_422a(HQXContext *ctx, int slice_no, int x, int y)
int i, ret;
int cbp;
cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1);
for (i = 0; i < 12; i++)
memset(slice->block[i], 0, sizeof(**slice->block) * 64);
for (i = 0; i < 12; i++)
slice->block[i][0] = -0x800;
cbp = get_vlc2(gb, cbp_vlc, HQX_CBP_VLC_BITS, 1);
if (cbp) {
if (ctx->interlaced)
flag = get_bits1(gb);
@ -310,12 +309,12 @@ static int hqx_decode_444a(HQXContext *ctx, int slice_no, int x, int y)
int i, ret;
int cbp;
cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1);
for (i = 0; i < 16; i++)
memset(slice->block[i], 0, sizeof(**slice->block) * 64);
for (i = 0; i < 16; i++)
slice->block[i][0] = -0x800;
cbp = get_vlc2(gb, cbp_vlc, HQX_CBP_VLC_BITS, 1);
if (cbp) {
if (ctx->interlaced)
flag = get_bits1(gb);
@ -543,7 +542,6 @@ static av_cold int hqx_decode_close(AVCodecContext *avctx)
int i;
HQXContext *ctx = avctx->priv_data;
ff_vlc_free(&ctx->cbp_vlc);
for (i = 0; i < 3; i++) {
ff_vlc_free(&ctx->dc_vlc[i]);
}
@ -555,10 +553,7 @@ static av_cold int hqx_decode_init(AVCodecContext *avctx)
{
static AVOnce init_static_once = AV_ONCE_INIT;
HQXContext *ctx = avctx->priv_data;
int ret = vlc_init(&ctx->cbp_vlc, HQX_CBP_VLC_BITS, FF_ARRAY_ELEMS(cbp_vlc_lens),
cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
if (ret < 0)
return ret;
int ret;
INIT_DC_TABLE(0, dc9);
INIT_DC_TABLE(1, dc10);

View File

@ -1529,7 +1529,7 @@ static const uint8_t hqx_ac_lens[] = {
static const uint16_t hqx_ac_nb_elems[] = { 815, 907, 512, 354, 257, 194 };
static RL_VLC_ELEM hqx_ac_rl_vlc[15630];
static VLCElem cbp_vlc[(1 << HQX_CBP_VLC_BITS) + 15630 /* RL_VLC_ELEMS for hqx_ac */];
#define INIT_DC_TABLE(idx, name) \
do { \
@ -1543,10 +1543,13 @@ static RL_VLC_ELEM hqx_ac_rl_vlc[15630];
static av_cold av_unused void hqx_init_static(void)
{
VLCInitState state = VLC_INIT_STATE(hqx_ac_rl_vlc);
VLCInitState state = VLC_INIT_STATE(cbp_vlc);
const uint8_t *lens = hqx_ac_lens;
const int16_t *run_level = hqx_ac_run_level;
ff_vlc_init_tables(&state, HQX_CBP_VLC_BITS, FF_ARRAY_ELEMS(cbp_vlc_lens),
cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
for (int i = 0; i < NUM_HQX_AC; ++i) {
RL_VLC_ELEM *lut = state.table;
unsigned nb_codes = state.size;