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

Function decode_short_vertical_delta2

libavcodec/iff.c:1133–1191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1131}
1132
1133static void decode_short_vertical_delta2(uint8_t *dst,
1134 const uint8_t *buf, const uint8_t *buf_end,
1135 int w, int bpp, int dst_size)
1136{
1137 int ncolumns = (w + 15) >> 4;
1138 int dstpitch = ncolumns * bpp * 2;
1139 unsigned ofsdst, ofssrc, opcode, x;
1140 GetByteContext ptrs, gb;
1141 PutByteContext pb;
1142 int i, j, k;
1143
1144 bytestream2_init(&ptrs, buf, buf_end - buf);
1145 bytestream2_init_writer(&pb, dst, dst_size);
1146
1147 for (k = 0; k < bpp; k++) {
1148 ofssrc = bytestream2_get_be32(&ptrs);
1149
1150 if (!ofssrc)
1151 continue;
1152
1153 if (ofssrc >= buf_end - buf)
1154 continue;
1155
1156 bytestream2_init(&gb, buf + ofssrc, buf_end - (buf + ofssrc));
1157 for (j = 0; j < ncolumns; j++) {
1158 ofsdst = (j + k * ncolumns) * 2;
1159
1160 i = bytestream2_get_be16(&gb);
1161 while (i > 0 && bytestream2_get_bytes_left(&gb) > 4) {
1162 opcode = bytestream2_get_be16(&gb);
1163
1164 if (opcode == 0) {
1165 opcode = bytestream2_get_be16(&gb);
1166 x = bytestream2_get_be16(&gb);
1167
1168 while (opcode && bytestream2_get_bytes_left_p(&pb) > 1) {
1169 bytestream2_seek_p(&pb, ofsdst, SEEK_SET);
1170 bytestream2_put_be16(&pb, x);
1171 ofsdst += dstpitch;
1172 opcode--;
1173 }
1174 } else if (opcode < 0x8000) {
1175 ofsdst += opcode * dstpitch;
1176 } else {
1177 opcode &= 0x7fff;
1178
1179 while (opcode && bytestream2_get_bytes_left(&gb) > 1 &&
1180 bytestream2_get_bytes_left_p(&pb) > 1) {
1181 bytestream2_seek_p(&pb, ofsdst, SEEK_SET);
1182 bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
1183 ofsdst += dstpitch;
1184 opcode--;
1185 }
1186 }
1187 i--;
1188 }
1189 }
1190 }

Callers 1

decode_frameFunction · 0.85

Calls 5

bytestream2_initFunction · 0.85
bytestream2_init_writerFunction · 0.85
bytestream2_seek_pFunction · 0.85

Tested by

no test coverage detected