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

Function decode_long_vertical_delta2

libavcodec/iff.c:1193–1273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1191}
1192
1193static void decode_long_vertical_delta2(uint8_t *dst,
1194 const uint8_t *buf, const uint8_t *buf_end,
1195 int w, int bpp, int dst_size)
1196{
1197 int ncolumns = (w + 31) >> 5;
1198 int dstpitch = ((w + 15) / 16 * 2) * bpp;
1199 unsigned ofsdst, ofssrc, opcode, x;
1200 unsigned skip = 0x80000000, mask = skip - 1;
1201 GetByteContext ptrs, gb;
1202 PutByteContext pb;
1203 int i, j, k, h;
1204
1205 h = (((w + 15) / 16 * 2) != ((w + 31) / 32 * 4)) ? 1 : 0;
1206 bytestream2_init(&ptrs, buf, buf_end - buf);
1207 bytestream2_init_writer(&pb, dst, dst_size);
1208
1209 for (k = 0; k < bpp; k++) {
1210 ofssrc = bytestream2_get_be32(&ptrs);
1211
1212 if (!ofssrc)
1213 continue;
1214
1215 if (ofssrc >= buf_end - buf)
1216 continue;
1217
1218 bytestream2_init(&gb, buf + ofssrc, buf_end - (buf + ofssrc));
1219 for (j = 0; j < ncolumns; j++) {
1220 ofsdst = (j + k * ncolumns) * 4 - h * (2 * k);
1221
1222 if (h && (j == (ncolumns - 1))) {
1223 skip = 0x8000;
1224 mask = skip - 1;
1225 }
1226
1227 i = bytestream2_get_be32(&gb);
1228 while (i > 0 && bytestream2_get_bytes_left(&gb) > 4) {
1229 opcode = bytestream2_get_be32(&gb);
1230
1231 if (opcode == 0) {
1232 if (h && (j == ncolumns - 1)) {
1233 opcode = bytestream2_get_be16(&gb);
1234 x = bytestream2_get_be16(&gb);
1235 } else {
1236 opcode = bytestream2_get_be32(&gb);
1237 x = bytestream2_get_be32(&gb);
1238 }
1239
1240 if (ofsdst + (opcode - 1LL) * dstpitch > bytestream2_size_p(&pb))
1241 return;
1242
1243 while (opcode && bytestream2_get_bytes_left_p(&pb) > 1) {
1244 bytestream2_seek_p(&pb, ofsdst, SEEK_SET);
1245 if (h && (j == ncolumns - 1))
1246 bytestream2_put_be16(&pb, x);
1247 else
1248 bytestream2_put_be32(&pb, x);
1249 ofsdst += dstpitch;
1250 opcode--;

Callers 1

decode_frameFunction · 0.85

Calls 6

bytestream2_initFunction · 0.85
bytestream2_init_writerFunction · 0.85
bytestream2_size_pFunction · 0.85
bytestream2_seek_pFunction · 0.85

Tested by

no test coverage detected