History

avcodec/hqxvlc: Make cbp_vlc static

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

Andreas Rheinhardt committed 1 year ago

Commit 5dd83ec1 parent c9d87f42 files · +10 −12Browse files

Showing the changes to libavcodec (2 of 2 files). Show all

Unified · Split

2 files
  1. libavcodec/hqx.c +5 −10
  2. libavcodec/hqxvlc.h +5 −2
libavcodec/hqx.c+5−10
@@ -68,7 +68,6 @@ typedef struct HQXContext { · 67 unmodified lines
6868 unsigned int data_size;
6969 uint32_t slice_off[17];
7070
71− VLC cbp_vlc;
7271 VLC dc_vlc[3];
7372 } HQXContext;
7473
@@ -224,12 +223,12 @@ static int hqx_decode_422a(HQXContext *ctx, int slice_no, int x, int y) · 149 unmodified lines
224223 int i, ret;
225224 int cbp;
226225
227− cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1);
228−
229226 for (i = 0; i < 12; i++)
230227 memset(slice->block[i], 0, sizeof(**slice->block) * 64);
231228 for (i = 0; i < 12; i++)
232229 slice->block[i][0] = -0x800;
230+
231+ cbp = get_vlc2(gb, cbp_vlc, HQX_CBP_VLC_BITS, 1);
233232 if (cbp) {
234233 if (ctx->interlaced)
235234 flag = get_bits1(gb);
@@ -310,12 +309,12 @@ static int hqx_decode_444a(HQXContext *ctx, int slice_no, int x, int y) · 74 unmodified lines
310309 int i, ret;
311310 int cbp;
312311
313− cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1);
314−
315312 for (i = 0; i < 16; i++)
316313 memset(slice->block[i], 0, sizeof(**slice->block) * 64);
317314 for (i = 0; i < 16; i++)
318315 slice->block[i][0] = -0x800;
316+
317+ cbp = get_vlc2(gb, cbp_vlc, HQX_CBP_VLC_BITS, 1);
319318 if (cbp) {
320319 if (ctx->interlaced)
321320 flag = get_bits1(gb);
@@ -543,7 +542,6 @@ static av_cold int hqx_decode_close(AVCodecContext *avctx) · 221 unmodified lines
543542 int i;
544543 HQXContext *ctx = avctx->priv_data;
545544
546− ff_vlc_free(&ctx->cbp_vlc);
547545 for (i = 0; i < 3; i++) {
548546 ff_vlc_free(&ctx->dc_vlc[i]);
549547 }
@@ -555,10 +553,7 @@ static av_cold int hqx_decode_init(AVCodecContext *avctx) · 5 unmodified lines
555553 {
556554 static AVOnce init_static_once = AV_ONCE_INIT;
557555 HQXContext *ctx = avctx->priv_data;
558− int ret = vlc_init(&ctx->cbp_vlc, HQX_CBP_VLC_BITS, FF_ARRAY_ELEMS(cbp_vlc_lens),
559− cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
560− if (ret < 0)
561− return ret;
556+ int ret;
562557
563558 INIT_DC_TABLE(0, dc9);
564559 INIT_DC_TABLE(1, dc10);
libavcodec/hqxvlc.h+5−2
@@ -1529,7 +1529,7 @@ static const uint8_t hqx_ac_lens[] = { · 1528 unmodified lines
15291529
15301530 static const uint16_t hqx_ac_nb_elems[] = { 815, 907, 512, 354, 257, 194 };
15311531
1532−static RL_VLC_ELEM hqx_ac_rl_vlc[15630];
1532+static VLCElem cbp_vlc[(1 << HQX_CBP_VLC_BITS) + 15630 /* RL_VLC_ELEMS for hqx_ac */];
15331533
15341534 #define INIT_DC_TABLE(idx, name) \
15351535 do { \
@@ -1543,10 +1543,13 @@ static RL_VLC_ELEM hqx_ac_rl_vlc[15630]; · 7 unmodified lines
15431543
15441544 static av_cold av_unused void hqx_init_static(void)
15451545 {
1546− VLCInitState state = VLC_INIT_STATE(hqx_ac_rl_vlc);
1546+ VLCInitState state = VLC_INIT_STATE(cbp_vlc);
15471547 const uint8_t *lens = hqx_ac_lens;
15481548 const int16_t *run_level = hqx_ac_run_level;
15491549
1550+ ff_vlc_init_tables(&state, HQX_CBP_VLC_BITS, FF_ARRAY_ELEMS(cbp_vlc_lens),
1551+ cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
1552+
15501553 for (int i = 0; i < NUM_HQX_AC; ++i) {
15511554 RL_VLC_ELEM *lut = state.table;
15521555 unsigned nb_codes = state.size;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t