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

Function read_table

libavcodec/dstdec.c:150–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150static int read_table(GetBitContext *gb, Table *t, const int8_t code_pred_coeff[3][3],
151 int length_bits, int coeff_bits, int is_signed, int offset)
152{
153 unsigned int i, j, k;
154 for (i = 0; i < t->elements; i++) {
155 t->length[i] = get_bits(gb, length_bits) + 1;
156 if (!get_bits1(gb)) {
157 read_uncoded_coeff(gb, t->coeff[i], t->length[i], coeff_bits, is_signed, offset);
158 } else {
159 int method = get_bits(gb, 2), lsb_size;
160 if (method == 3)
161 return AVERROR_INVALIDDATA;
162
163 read_uncoded_coeff(gb, t->coeff[i], method + 1, coeff_bits, is_signed, offset);
164
165 lsb_size = get_bits(gb, 3);
166 for (j = method + 1; j < t->length[i]; j++) {
167 int c, x = 0;
168 for (k = 0; k < method + 1; k++)
169 x += code_pred_coeff[method][k] * (unsigned)t->coeff[i][j - k - 1];
170 c = get_sr_golomb_dst(gb, lsb_size);
171 if (x >= 0)
172 c -= (x + 4) / 8;
173 else
174 c += (-x + 3) / 8;
175 if (!is_signed) {
176 if (c < offset || c >= offset + (1<<coeff_bits))
177 return AVERROR_INVALIDDATA;
178 }
179 t->coeff[i][j] = c;
180 }
181 }
182 }
183 return 0;
184}
185
186static void ac_init(ArithCoder *ac, GetBitContext *gb)
187{

Callers 1

decode_frameFunction · 0.70

Calls 4

get_bits1Function · 0.85
read_uncoded_coeffFunction · 0.85
get_sr_golomb_dstFunction · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected