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
68 unsigned int data_size;68 unsigned int data_size;
69 uint32_t slice_off[17];69 uint32_t slice_off[17];
70 70
71 VLC cbp_vlc;
72 VLC dc_vlc[3];71 VLC dc_vlc[3];
73} HQXContext;72} HQXContext;
74 73
@@ -224,12 +223,12 @@ static int hqx_decode_422a(HQXContext *ctx, int slice_no, int x, int y) · 149 unmodified lines
224 int i, ret;223 int i, ret;
225 int cbp;224 int cbp;
226 225
227 cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1);
228
229 for (i = 0; i < 12; i++)226 for (i = 0; i < 12; i++)
230 memset(slice->block[i], 0, sizeof(**slice->block) * 64);227 memset(slice->block[i], 0, sizeof(**slice->block) * 64);
231 for (i = 0; i < 12; i++)228 for (i = 0; i < 12; i++)
232 slice->block[i][0] = -0x800;229 slice->block[i][0] = -0x800;
230
231 cbp = get_vlc2(gb, cbp_vlc, HQX_CBP_VLC_BITS, 1);
233 if (cbp) {232 if (cbp) {
234 if (ctx->interlaced)233 if (ctx->interlaced)
235 flag = get_bits1(gb);234 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
310 int i, ret;309 int i, ret;
311 int cbp;310 int cbp;
312 311
313 cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1);
314
315 for (i = 0; i < 16; i++)312 for (i = 0; i < 16; i++)
316 memset(slice->block[i], 0, sizeof(**slice->block) * 64);313 memset(slice->block[i], 0, sizeof(**slice->block) * 64);
317 for (i = 0; i < 16; i++)314 for (i = 0; i < 16; i++)
318 slice->block[i][0] = -0x800;315 slice->block[i][0] = -0x800;
316
317 cbp = get_vlc2(gb, cbp_vlc, HQX_CBP_VLC_BITS, 1);
319 if (cbp) {318 if (cbp) {
320 if (ctx->interlaced)319 if (ctx->interlaced)
321 flag = get_bits1(gb);320 flag = get_bits1(gb);
@@ -543,7 +542,6 @@ static av_cold int hqx_decode_close(AVCodecContext *avctx) · 221 unmodified lines
543 int i;542 int i;
544 HQXContext *ctx = avctx->priv_data;543 HQXContext *ctx = avctx->priv_data;
545 544
546 ff_vlc_free(&ctx->cbp_vlc);
547 for (i = 0; i < 3; i++) {545 for (i = 0; i < 3; i++) {
548 ff_vlc_free(&ctx->dc_vlc[i]);546 ff_vlc_free(&ctx->dc_vlc[i]);
549 }547 }
@@ -555,10 +553,7 @@ static av_cold int hqx_decode_init(AVCodecContext *avctx) · 5 unmodified lines
555{553{
556 static AVOnce init_static_once = AV_ONCE_INIT;554 static AVOnce init_static_once = AV_ONCE_INIT;
557 HQXContext *ctx = avctx->priv_data;555 HQXContext *ctx = avctx->priv_data;
558 int ret = vlc_init(&ctx->cbp_vlc, HQX_CBP_VLC_BITS, FF_ARRAY_ELEMS(cbp_vlc_lens),556 int ret;
559 cbp_vlc_lens, 1, 1, cbp_vlc_bits, 1, 1, 0);
560 if (ret < 0)
561 return ret;
562 557
563 INIT_DC_TABLE(0, dc9);558 INIT_DC_TABLE(0, dc9);
564 INIT_DC_TABLE(1, dc10);559 INIT_DC_TABLE(1, dc10);
libavcodec/hqxvlc.h+5−2
@@ -1529,7 +1529,7 @@ static const uint8_t hqx_ac_lens[] = { · 1528 unmodified lines
1529 1529
1530static const uint16_t hqx_ac_nb_elems[] = { 815, 907, 512, 354, 257, 194 };1530static const uint16_t hqx_ac_nb_elems[] = { 815, 907, 512, 354, 257, 194 };
1531 1531
1532static RL_VLC_ELEM hqx_ac_rl_vlc[15630];1532static VLCElem cbp_vlc[(1 << HQX_CBP_VLC_BITS) + 15630 /* RL_VLC_ELEMS for hqx_ac */];
1533 1533
1534#define INIT_DC_TABLE(idx, name) \1534#define INIT_DC_TABLE(idx, name) \
1535 do { \1535 do { \
@@ -1543,10 +1543,13 @@ static RL_VLC_ELEM hqx_ac_rl_vlc[15630]; · 7 unmodified lines
1543 1543
1544static av_cold av_unused void hqx_init_static(void)1544static av_cold av_unused void hqx_init_static(void)
1545{1545{
1546 VLCInitState state = VLC_INIT_STATE(hqx_ac_rl_vlc);1546 VLCInitState state = VLC_INIT_STATE(cbp_vlc);
1547 const uint8_t *lens = hqx_ac_lens;1547 const uint8_t *lens = hqx_ac_lens;
1548 const int16_t *run_level = hqx_ac_run_level;1548 const int16_t *run_level = hqx_ac_run_level;
1549 1549
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
1550 for (int i = 0; i < NUM_HQX_AC; ++i) {1553 for (int i = 0; i < NUM_HQX_AC; ++i) {
1551 RL_VLC_ELEM *lut = state.table;1554 RL_VLC_ELEM *lut = state.table;
1552 unsigned nb_codes = state.size;1555 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