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

Function decode_delta_d

libavcodec/iff.c:1275–1332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1273}
1274
1275static void decode_delta_d(uint8_t *dst,
1276 const uint8_t *buf, const uint8_t *buf_end,
1277 int w, int flag, int bpp, int dst_size)
1278{
1279 int planepitch = FFALIGN(w, 16) >> 3;
1280 int pitch = planepitch * bpp;
1281 int planepitch_byte = (w + 7) / 8;
1282 unsigned entries, ofssrc;
1283 GetByteContext gb, ptrs;
1284 PutByteContext pb;
1285 int k;
1286
1287 if (buf_end - buf <= 4 * bpp)
1288 return;
1289
1290 bytestream2_init_writer(&pb, dst, dst_size);
1291 bytestream2_init(&ptrs, buf, bpp * 4);
1292
1293 for (k = 0; k < bpp; k++) {
1294 ofssrc = bytestream2_get_be32(&ptrs);
1295
1296 if (!ofssrc)
1297 continue;
1298
1299 if (ofssrc >= buf_end - buf)
1300 continue;
1301
1302 bytestream2_init(&gb, buf + ofssrc, buf_end - (buf + ofssrc));
1303
1304 entries = bytestream2_get_be32(&gb);
1305 if (entries * 8LL > bytestream2_get_bytes_left(&gb))
1306 return;
1307
1308 while (entries && bytestream2_get_bytes_left(&gb) >= 8) {
1309 int32_t opcode = bytestream2_get_be32(&gb);
1310 unsigned offset = bytestream2_get_be32(&gb);
1311
1312 bytestream2_seek_p(&pb, (offset / planepitch_byte) * pitch + (offset % planepitch_byte) + k * planepitch, SEEK_SET);
1313 if (opcode >= 0) {
1314 uint32_t x = bytestream2_get_be32(&gb);
1315 if (opcode && 4 + (opcode - 1LL) * pitch > bytestream2_get_bytes_left_p(&pb))
1316 continue;
1317 while (opcode && bytestream2_get_bytes_left_p(&pb) > 0) {
1318 bytestream2_put_be32(&pb, x);
1319 bytestream2_skip_p(&pb, pitch - 4);
1320 opcode--;
1321 }
1322 } else {
1323 while (opcode && bytestream2_get_bytes_left(&gb) > 0) {
1324 bytestream2_put_be32(&pb, bytestream2_get_be32(&gb));
1325 bytestream2_skip_p(&pb, pitch - 4);
1326 opcode++;
1327 }
1328 }
1329 entries--;
1330 }
1331 }
1332}

Callers 1

decode_frameFunction · 0.85

Calls 6

bytestream2_init_writerFunction · 0.85
bytestream2_initFunction · 0.85
bytestream2_seek_pFunction · 0.85
bytestream2_skip_pFunction · 0.85

Tested by

no test coverage detected