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

Function decode_delta_e

libavcodec/iff.c:1334–1387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1332}
1333
1334static void decode_delta_e(uint8_t *dst,
1335 const uint8_t *buf, const uint8_t *buf_end,
1336 int w, int flag, int bpp, int dst_size)
1337{
1338 int planepitch = FFALIGN(w, 16) >> 3;
1339 int pitch = planepitch * bpp;
1340 int planepitch_byte = (w + 7) / 8;
1341 unsigned entries, ofssrc;
1342 GetByteContext gb, ptrs;
1343 PutByteContext pb;
1344 int k;
1345
1346 if (buf_end - buf <= 4 * bpp)
1347 return;
1348
1349 bytestream2_init_writer(&pb, dst, dst_size);
1350 bytestream2_init(&ptrs, buf, bpp * 4);
1351
1352 for (k = 0; k < bpp; k++) {
1353 ofssrc = bytestream2_get_be32(&ptrs);
1354
1355 if (!ofssrc)
1356 continue;
1357
1358 if (ofssrc >= buf_end - buf)
1359 continue;
1360
1361 bytestream2_init(&gb, buf + ofssrc, buf_end - (buf + ofssrc));
1362
1363 entries = bytestream2_get_be16(&gb);
1364 while (entries && bytestream2_get_bytes_left(&gb) >= 6) {
1365 int16_t opcode = bytestream2_get_be16(&gb);
1366 unsigned offset = bytestream2_get_be32(&gb);
1367
1368 bytestream2_seek_p(&pb, (offset / planepitch_byte) * pitch + (offset % planepitch_byte) + k * planepitch, SEEK_SET);
1369 if (opcode >= 0) {
1370 uint16_t x = bytestream2_get_be16(&gb);
1371 while (opcode && bytestream2_get_bytes_left_p(&pb) > 0) {
1372 bytestream2_put_be16(&pb, x);
1373 bytestream2_skip_p(&pb, pitch - 2);
1374 opcode--;
1375 }
1376 } else {
1377 opcode = -opcode;
1378 while (opcode && bytestream2_get_bytes_left(&gb) > 0) {
1379 bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
1380 bytestream2_skip_p(&pb, pitch - 2);
1381 opcode--;
1382 }
1383 }
1384 entries--;
1385 }
1386 }
1387}
1388
1389static void decode_delta_l(uint8_t *dst,
1390 const uint8_t *buf, const uint8_t *buf_end,

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