1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avcodec/faxcompr: 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.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2023-09-20 19:09:37 +02:00
parent a99285aedf
commit 363837de0e

View File

@ -95,28 +95,24 @@ static const uint8_t ccitt_group3_2d_lens[11] = {
4, 3, 7, 6, 3, 1, 3, 6, 7, 7, 9 4, 3, 7, 6, 3, 1, 3, 6, 7, 7, 9
}; };
static VLC ccitt_vlc[2], ccitt_group3_2d_vlc; // Also contains the other VLC tables pointed to by ccitt_vlc
static VLCElem ccitt_group3_2d_vlc[512 + 528 + 648];
static const VLCElem *ccitt_vlc[2];
static av_cold void ccitt_unpack_init(void) static av_cold void ccitt_unpack_init(void)
{ {
static VLCElem code_table1[528]; VLCInitState state = VLC_INIT_STATE(ccitt_group3_2d_vlc);
static VLCElem code_table2[648];
int i; int i;
ccitt_vlc[0].table = code_table1; ff_vlc_init_tables(&state, 9, 11,
ccitt_vlc[0].table_allocated = 528; ccitt_group3_2d_lens, 1, 1,
ccitt_vlc[1].table = code_table2; ccitt_group3_2d_bits, 1, 1, 0);
ccitt_vlc[1].table_allocated = 648;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
ff_vlc_init_sparse(&ccitt_vlc[i], 9, CCITT_SYMS, ccitt_vlc[i] = ff_vlc_init_tables_sparse(&state, 9, CCITT_SYMS,
ccitt_codes_lens[i], 1, 1, ccitt_codes_lens[i], 1, 1,
ccitt_codes_bits[i], 1, 1, ccitt_codes_bits[i], 1, 1,
ccitt_syms, 2, 2, ccitt_syms, 2, 2, 0);
VLC_INIT_USE_STATIC);
} }
VLC_INIT_STATIC(&ccitt_group3_2d_vlc, 9, 11,
ccitt_group3_2d_lens, 1, 1,
ccitt_group3_2d_bits, 1, 1, 512);
} }
av_cold void ff_ccitt_unpack_init(void) av_cold void ff_ccitt_unpack_init(void)
@ -213,7 +209,7 @@ static int decode_group3_1d_line(AVCodecContext *avctx, GetBitContext *gb,
for (;;) { for (;;) {
if (get_bits_left(gb) <= 0) if (get_bits_left(gb) <= 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
t = get_vlc2(gb, ccitt_vlc[mode].table, 9, 2); t = get_vlc2(gb, ccitt_vlc[mode], 9, 2);
run += t; run += t;
if (t < 64) { if (t < 64) {
*runs++ = run; *runs++ = run;
@ -261,7 +257,7 @@ static int decode_group3_2d_line(AVCodecContext *avctx, GetBitContext *gb,
int cmode; int cmode;
if (get_bits_left(gb) <= 0) if (get_bits_left(gb) <= 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
cmode = get_vlc2(gb, ccitt_group3_2d_vlc.table, 9, 1); cmode = get_vlc2(gb, ccitt_group3_2d_vlc, 9, 1);
if (cmode == -1) { if (cmode == -1) {
av_log(avctx, AV_LOG_ERROR, "Incorrect mode VLC\n"); av_log(avctx, AV_LOG_ERROR, "Incorrect mode VLC\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
@ -285,7 +281,7 @@ static int decode_group3_2d_line(AVCodecContext *avctx, GetBitContext *gb,
for (;;) { for (;;) {
if (get_bits_left(gb) <= 0) if (get_bits_left(gb) <= 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
t = get_vlc2(gb, ccitt_vlc[mode].table, 9, 2); t = get_vlc2(gb, ccitt_vlc[mode], 9, 2);
if (t == -1) { if (t == -1) {
av_log(avctx, AV_LOG_ERROR, "Incorrect code\n"); av_log(avctx, AV_LOG_ERROR, "Incorrect code\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;