MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__jpeg_decode_block_prog_dc

Function stbi__jpeg_decode_block_prog_dc

Source/Utils/stb_image.h:2264–2290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2262}
2263
2264static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b)
2265{
2266 int diff,dc;
2267 int t;
2268 if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
2269
2270 if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
2271
2272 if (j->succ_high == 0) {
2273 // first scan for DC coefficient, must be first
2274 memset(data,0,64*sizeof(data[0])); // 0 all the ac values now
2275 t = stbi__jpeg_huff_decode(j, hdc);
2276 if (t < 0 || t > 15) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
2277 diff = t ? stbi__extend_receive(j, t) : 0;
2278
2279 if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta", "Corrupt JPEG");
2280 dc = j->img_comp[b].dc_pred + diff;
2281 j->img_comp[b].dc_pred = dc;
2282 if (!stbi__mul2shorts_valid(dc, 1 << j->succ_low)) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
2283 data[0] = (short) (dc * (1 << j->succ_low));
2284 } else {
2285 // refinement scan for DC coefficient
2286 if (stbi__jpeg_get_bit(j))
2287 data[0] += (short) (1 << j->succ_low);
2288 }
2289 return 1;
2290}
2291
2292// @OPTIMIZE: store non-zigzagged during the decode passes,
2293// and only de-zigzag when dequantizing

Callers 1

Calls 7

stbi__errFunction · 0.85
stbi__grow_buffer_unsafeFunction · 0.85
stbi__jpeg_huff_decodeFunction · 0.85
stbi__extend_receiveFunction · 0.85
stbi__addints_validFunction · 0.85
stbi__mul2shorts_validFunction · 0.85
stbi__jpeg_get_bitFunction · 0.85

Tested by

no test coverage detected