History

avcodec/imc: Avoid superfluous VLC structures

Of all these VLCs here, only VLC.table was really used after init, so use the ff_vlc_init_tables API to get rid of them.

Andreas Rheinhardt committed 3 years ago

Commit 7fee90e1 parent 6fb96ef1 file · +11 −17Browse files

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

Unified · Split

libavcodec/imc.c+11−17
@@ -106,7 +106,7 @@ typedef struct IMCContext { · 105 unmodified lines
106106 AVCodecContext *avctx;
107107 } IMCContext;
108108
109−static VLC huffman_vlc[4][4];
109+static const VLCElem *huffman_vlc[4][4];
110110
111111 #define IMC_VLC_BITS 9
112112 #define VLC_TABLES_SIZE 9512
@@ -171,16 +171,15 @@ static av_cold void iac_generate_tabs(IMCContext *q, int sampling_rate) · 58 unmodified lines
171171
172172 static av_cold void imc_init_static(void)
173173 {
174+ VLCInitState state = VLC_INIT_STATE(vlc_tables);
174175 /* initialize the VLC tables */
175− for (int i = 0, offset = 0; i < 4 ; i++) {
176+ for (int i = 0; i < 4 ; i++) {
176177 for (int j = 0; j < 4; j++) {
177− huffman_vlc[i][j].table = &vlc_tables[offset];
178− huffman_vlc[i][j].table_allocated = VLC_TABLES_SIZE - offset;
179− ff_vlc_init_from_lengths(&huffman_vlc[i][j], IMC_VLC_BITS, imc_huffman_sizes[i],
180− imc_huffman_lens[i][j], 1,
181− imc_huffman_syms[i][j], 1, 1,
182− 0, VLC_INIT_STATIC_OVERLONG, NULL);
183− offset += huffman_vlc[i][j].table_size;
178+ huffman_vlc[i][j] =
179+ ff_vlc_init_tables_from_lengths(&state, IMC_VLC_BITS, imc_huffman_sizes[i],
180+ imc_huffman_lens[i][j], 1,
181+ imc_huffman_syms[i][j], 1, 1,
182+ 0, 0);
184183 }
185184 }
186185 }
@@ -311,16 +310,11 @@ static void imc_read_level_coeffs(IMCContext *q, int stream_format_code, · 124 unmodified lines
311310 int *levlCoeffs)
312311 {
313312 int i;
314− VLC *hufftab[4];
315313 int start = 0;
316314 const uint8_t *cb_sel;
317− int s;
315+ int s = stream_format_code >> 1;
316+ const VLCElem * const *const hufftab = huffman_vlc[s];
318317
319− s = stream_format_code >> 1;
320− hufftab[0] = &huffman_vlc[s][0];
321− hufftab[1] = &huffman_vlc[s][1];
322− hufftab[2] = &huffman_vlc[s][2];
323− hufftab[3] = &huffman_vlc[s][3];
324318 cb_sel = imc_cb_select[s];
325319
326320 if (stream_format_code & 4)
@@ -328,7 +322,7 @@ static void imc_read_level_coeffs(IMCContext *q, int stream_format_code, · 1 unmodified line
328322 if (start)
329323 levlCoeffs[0] = get_bits(&q->gb, 7);
330324 for (i = start; i < BANDS; i++) {
331− levlCoeffs[i] = get_vlc2(&q->gb, hufftab[cb_sel[i]]->table,
325+ levlCoeffs[i] = get_vlc2(&q->gb, hufftab[cb_sel[i]],
332326 IMC_VLC_BITS, 2);
333327 if (levlCoeffs[i] == 17)
334328 levlCoeffs[i] += get_bits(&q->gb, 4);

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