History

avcodec/speedhqdec: Avoid unnecessary VLC structure

Everything besides VLC.table is basically write-only and even VLC.table can be removed by accessing the underlying table directly.

Andreas Rheinhardt committed 3 years ago

Commit fd4cb6e1 parent 0a610e21 file · +26 −26Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/speedhqdec.c+26−26
@@ -71,10 +71,10 @@ static const uint8_t unscaled_quant_matrix[64] = { · 70 unmodified lines
7171 27, 29, 35, 38, 46, 56, 69, 83
7272 };
7373
74−static VLC dc_lum_vlc_le;
75−static VLC dc_chroma_vlc_le;
76−static VLC dc_alpha_run_vlc_le;
77−static VLC dc_alpha_level_vlc_le;
74+static VLCElem dc_lum_vlc_le[512];
75+static VLCElem dc_chroma_vlc_le[514];
76+static VLCElem dc_alpha_run_vlc_le[160];
77+static VLCElem dc_alpha_level_vlc_le[288];
7878
7979 static RL_VLC_ELEM speedhq_rl_vlc[674];
8080
@@ -83,9 +83,9 @@ static inline int decode_dc_le(GetBitContext *gb, int component) · 2 unmodified lines
8383 int code, diff;
8484
8585 if (component == 0 || component == 3) {
86− code = get_vlc2(gb, dc_lum_vlc_le.table, DC_VLC_BITS, 2);
86+ code = get_vlc2(gb, dc_lum_vlc_le, DC_VLC_BITS, 2);
8787 } else {
88− code = get_vlc2(gb, dc_chroma_vlc_le.table, DC_VLC_BITS, 2);
88+ code = get_vlc2(gb, dc_chroma_vlc_le, DC_VLC_BITS, 2);
8989 }
9090 if (!code) {
9191 diff = 0;
@@ -109,7 +109,7 @@ static inline int decode_alpha_block(const SHQContext *s, GetBitContext *gb, uin · 17 unmodified lines
109109 int run, level;
110110
111111 UPDATE_CACHE_LE(re, gb);
112− GET_VLC(run, re, gb, dc_alpha_run_vlc_le.table, ALPHA_VLC_BITS, 2);
112+ GET_VLC(run, re, gb, dc_alpha_run_vlc_le, ALPHA_VLC_BITS, 2);
113113
114114 if (run < 0) break;
115115 i += run;
@@ -117,7 +117,7 @@ static inline int decode_alpha_block(const SHQContext *s, GetBitContext *gb, uin · 1 unmodified line
117117 return AVERROR_INVALIDDATA;
118118
119119 UPDATE_CACHE_LE(re, gb);
120− GET_VLC(level, re, gb, dc_alpha_level_vlc_le.table, ALPHA_VLC_BITS, 2);
120+ GET_VLC(level, re, gb, dc_alpha_level_vlc_le, ALPHA_VLC_BITS, 2);
121121 block[i++] = level;
122122 }
123123
@@ -506,11 +506,11 @@ static av_cold void compute_alpha_vlcs(void) · 382 unmodified lines
506506
507507 av_assert0(entry == FF_ARRAY_ELEMS(run_code));
508508
509− VLC_INIT_LE_SPARSE_STATIC(&dc_alpha_run_vlc_le, ALPHA_VLC_BITS,
510− FF_ARRAY_ELEMS(run_code),
511− run_bits, 1, 1,
512− run_code, 2, 2,
513− run_symbols, 2, 2, 160);
509+ VLC_INIT_STATIC_SPARSE_TABLE(dc_alpha_run_vlc_le, ALPHA_VLC_BITS,
510+ FF_ARRAY_ELEMS(run_code),
511+ run_bits, 1, 1,
512+ run_code, 2, 2,
513+ run_symbols, 2, 2, VLC_INIT_LE);
514514
515515 /* Initialize VLC for alpha level. */
516516 entry = 0;
@@ -546,24 +546,24 @@ static av_cold void compute_alpha_vlcs(void) · 29 unmodified lines
546546
547547 av_assert0(entry == FF_ARRAY_ELEMS(level_code));
548548
549− VLC_INIT_LE_SPARSE_STATIC(&dc_alpha_level_vlc_le, ALPHA_VLC_BITS,
550− FF_ARRAY_ELEMS(level_code),
551− level_bits, 1, 1,
552− level_code, 2, 2,
553− level_symbols, 2, 2, 288);
549+ VLC_INIT_STATIC_SPARSE_TABLE(dc_alpha_level_vlc_le, ALPHA_VLC_BITS,
550+ FF_ARRAY_ELEMS(level_code),
551+ level_bits, 1, 1,
552+ level_code, 2, 2,
553+ level_symbols, 2, 2, VLC_INIT_LE);
554554 }
555555
556556 static av_cold void speedhq_static_init(void)
557557 {
558558 /* Exactly the same as MPEG-2, except for a little-endian reader. */
559− VLC_INIT_CUSTOM_STATIC(&dc_lum_vlc_le, DC_VLC_BITS, 12,
560− ff_mpeg12_vlc_dc_lum_bits, 1, 1,
561− ff_mpeg12_vlc_dc_lum_code, 2, 2,
562− VLC_INIT_OUTPUT_LE, 512);
563− VLC_INIT_CUSTOM_STATIC(&dc_chroma_vlc_le, DC_VLC_BITS, 12,
564− ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
565− ff_mpeg12_vlc_dc_chroma_code, 2, 2,
566− VLC_INIT_OUTPUT_LE, 514);
559+ VLC_INIT_STATIC_TABLE(dc_lum_vlc_le, DC_VLC_BITS, 12,
560+ ff_mpeg12_vlc_dc_lum_bits, 1, 1,
561+ ff_mpeg12_vlc_dc_lum_code, 2, 2,
562+ VLC_INIT_OUTPUT_LE);
563+ VLC_INIT_STATIC_TABLE(dc_chroma_vlc_le, DC_VLC_BITS, 12,
564+ ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
565+ ff_mpeg12_vlc_dc_chroma_code, 2, 2,
566+ VLC_INIT_OUTPUT_LE);
567567
568568 ff_init_2d_vlc_rl(ff_speedhq_vlc_table, speedhq_rl_vlc, ff_speedhq_run,
569569 ff_speedhq_level, SPEEDHQ_RL_NB_ELEMS,

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