MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / read_code_table

Function read_code_table

libavcodec/cllc.c:46–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44} CLLCContext;
45
46static int read_code_table(CLLCContext *ctx, GetBitContext *gb, VLC *vlc)
47{
48 uint8_t symbols[256];
49 uint8_t bits[256];
50 int num_lens, num_codes, num_codes_sum;
51 int i, j, count;
52
53 count = 0;
54 num_codes_sum = 0;
55
56 num_lens = get_bits(gb, 5);
57
58 if (num_lens > VLC_BITS * VLC_DEPTH) {
59 av_log(ctx->avctx, AV_LOG_ERROR, "To long VLCs %d\n", num_lens);
60 return AVERROR_INVALIDDATA;
61 }
62
63 for (i = 0; i < num_lens; i++) {
64 num_codes = get_bits(gb, 9);
65 num_codes_sum += num_codes;
66
67 if (num_codes_sum > 256) {
68 av_log(ctx->avctx, AV_LOG_ERROR,
69 "Too many VLCs (%d) to be read.\n", num_codes_sum);
70 return AVERROR_INVALIDDATA;
71 }
72
73 for (j = 0; j < num_codes; j++) {
74 symbols[count] = get_bits(gb, 8);
75 bits[count] = i + 1;
76
77 count++;
78 }
79 }
80
81 return ff_vlc_init_from_lengths(vlc, VLC_BITS, count, bits, 1,
82 symbols, 1, 1, 0, 0, ctx->avctx);
83}
84
85/*
86 * Unlike the RGB24 read/restore, which reads in a component at a time,

Callers 3

decode_argb_frameFunction · 0.85
decode_rgb24_frameFunction · 0.85
decode_yuv_frameFunction · 0.85

Calls 3

av_logFunction · 0.85
ff_vlc_init_from_lengthsFunction · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected