71 #define LUT8_PART(plane, v) \ 72 AV_LE2NE64C(UINT64_C(0x0000000)<<32 | v) << plane, \ 73 AV_LE2NE64C(UINT64_C(0x1000000)<<32 | v) << plane, \ 74 AV_LE2NE64C(UINT64_C(0x0010000)<<32 | v) << plane, \ 75 AV_LE2NE64C(UINT64_C(0x1010000)<<32 | v) << plane, \ 76 AV_LE2NE64C(UINT64_C(0x0000100)<<32 | v) << plane, \ 77 AV_LE2NE64C(UINT64_C(0x1000100)<<32 | v) << plane, \ 78 AV_LE2NE64C(UINT64_C(0x0010100)<<32 | v) << plane, \ 79 AV_LE2NE64C(UINT64_C(0x1010100)<<32 | v) << plane, \ 80 AV_LE2NE64C(UINT64_C(0x0000001)<<32 | v) << plane, \ 81 AV_LE2NE64C(UINT64_C(0x1000001)<<32 | v) << plane, \ 82 AV_LE2NE64C(UINT64_C(0x0010001)<<32 | v) << plane, \ 83 AV_LE2NE64C(UINT64_C(0x1010001)<<32 | v) << plane, \ 84 AV_LE2NE64C(UINT64_C(0x0000101)<<32 | v) << plane, \ 85 AV_LE2NE64C(UINT64_C(0x1000101)<<32 | v) << plane, \ 86 AV_LE2NE64C(UINT64_C(0x0010101)<<32 | v) << plane, \ 87 AV_LE2NE64C(UINT64_C(0x1010101)<<32 | v) << plane 89 #define LUT8(plane) { \ 90 LUT8_PART(plane, 0x0000000), \ 91 LUT8_PART(plane, 0x1000000), \ 92 LUT8_PART(plane, 0x0010000), \ 93 LUT8_PART(plane, 0x1010000), \ 94 LUT8_PART(plane, 0x0000100), \ 95 LUT8_PART(plane, 0x1000100), \ 96 LUT8_PART(plane, 0x0010100), \ 97 LUT8_PART(plane, 0x1010100), \ 98 LUT8_PART(plane, 0x0000001), \ 99 LUT8_PART(plane, 0x1000001), \ 100 LUT8_PART(plane, 0x0010001), \ 101 LUT8_PART(plane, 0x1010001), \ 102 LUT8_PART(plane, 0x0000101), \ 103 LUT8_PART(plane, 0x1000101), \ 104 LUT8_PART(plane, 0x0010101), \ 105 LUT8_PART(plane, 0x1010101), \ 114 #define LUT32(plane) { \ 116 0, 0, 0, 1 << plane, \ 117 0, 0, 1 << plane, 0, \ 118 0, 0, 1 << plane, 1 << plane, \ 119 0, 1 << plane, 0, 0, \ 120 0, 1 << plane, 0, 1 << plane, \ 121 0, 1 << plane, 1 << plane, 0, \ 122 0, 1 << plane, 1 << plane, 1 << plane, \ 123 1 << plane, 0, 0, 0, \ 124 1 << plane, 0, 0, 1 << plane, \ 125 1 << plane, 0, 1 << plane, 0, \ 126 1 << plane, 0, 1 << plane, 1 << plane, \ 127 1 << plane, 1 << plane, 0, 0, \ 128 1 << plane, 1 << plane, 0, 1 << plane, \ 129 1 << plane, 1 << plane, 1 << plane, 0, \ 130 1 << plane, 1 << plane, 1 << plane, 1 << plane, \ 147 return x << 16 | x << 8 | x;
167 count =
FFMIN(palette_size / 3, count);
169 for (i = 0; i <
count; i++)
170 pal[i] = 0xFF000000 |
AV_RB24(palette + i*3);
171 if (s->
flags && count >= 32) {
172 for (i = 0; i < 32; i++)
173 pal[i + 32] = 0xFF000000 | (
AV_RB24(palette + i*3) & 0xFEFEFE) >> 1;
174 count =
FFMAX(count, 64);
179 for (i = 0; i <
count; i++)
184 for (i = 0; i <
count; i++)
205 unsigned buf_size = 0;
221 chunk_id = bytestream2_get_le32(gb);
222 data_size = bytestream2_get_be32(gb);
224 if (chunk_id ==
MKTAG(
'B',
'M',
'H',
'D')) {
226 }
else if (chunk_id ==
MKTAG(
'A',
'N',
'H',
'D')) {
233 extra = bytestream2_get_be32(gb);
239 }
else if (chunk_id ==
MKTAG(
'D',
'L',
'T',
'A') ||
240 chunk_id ==
MKTAG(
'B',
'O',
'D',
'Y')) {
241 if (chunk_id ==
MKTAG(
'B',
'O',
'D',
'Y'))
244 }
else if (chunk_id ==
MKTAG(
'C',
'M',
'A',
'P')) {
245 int count = data_size / 3;
251 for (i = 0; i <
count; i++)
252 pal[i] = 0xFF000000 | bytestream2_get_le24(gb);
254 for (i = 0; i <
count; i++)
255 pal[i] = 0xFF000000 | bytestream2_get_be24(gb);
264 buf_size = bytestream_get_be16(&buf);
265 if (buf_size <= 1 || palette_size < 0) {
267 "Invalid palette size received: %u -> palette data offset: %d\n",
268 buf_size, palette_size);
273 if (buf_size >= 41) {
275 s->
bpp = bytestream_get_byte(&buf);
276 s->
ham = bytestream_get_byte(&buf);
277 s->
flags = bytestream_get_byte(&buf);
279 s->
masking = bytestream_get_byte(&buf);
280 for (i = 0; i < 16; i++)
281 s->
tvdc[i] = bytestream_get_be16(&buf);
287 }
if (s->
ham != (s->
bpp > 6 ? 6 : 4)) {
294 if (s->
bpp >= 8 && !s->
ham) {
317 if (!s->
bpp || s->
bpp > 32) {
334 ham_count = 8 * (1 << s->
ham);
343 memset(s->
ham_palbuf, 0, (1 << s->
ham) * 2 * sizeof (uint32_t));
344 for (i=0; i <
count; i++) {
350 for (i=0; i <
count; i++) {
355 for (i=0; i <
count; i++) {
356 uint32_t
tmp = i << (8 - s->
ham);
357 tmp |= tmp >> s->
ham;
362 s->
ham_palbuf[(i+count*2)*2+1] = 0xFF000000 | tmp;
363 s->
ham_palbuf[(i+count*3)*2+1] = 0xFF000000 | tmp << 8;
366 for (i = 0; i < ham_count; i++)
461 uint64_t v =
AV_RN64A(dst) | lut[*buf++];
464 }
while (--buf_size);
478 unsigned mask = (*buf >> 2) & ~3;
479 dst[0] |= lut[mask++];
480 dst[1] |= lut[mask++];
481 dst[2] |= lut[mask++];
483 mask = (*buf++ << 2) & 0x3F;
484 dst[4] |= lut[mask++];
485 dst[5] |= lut[mask++];
486 dst[6] |= lut[mask++];
489 }
while (--buf_size);
492 #define DECODE_HAM_PLANE32(x) \ 493 first = buf[x] << 1; \ 494 second = buf[(x)+1] << 1; \ 495 delta &= pal[first++]; \ 496 delta |= pal[first]; \ 498 delta &= pal[second++]; \ 499 delta |= pal[second]; \ 511 const uint32_t *
const pal,
unsigned buf_size)
513 uint32_t
delta = pal[1];
515 uint32_t first, second;
522 }
while (--buf_size);
526 const uint32_t *
const pal,
unsigned width)
529 *dst++ = pal[*buf++];
546 for (x = 0; x < dst_size && bytestream2_get_bytes_left(gb) > 0;) {
548 const int8_t
value = bytestream2_get_byte(gb);
552 if (length < value + 1)
554 }
else if (value > -128) {
555 length =
FFMIN(-value + 1, dst_size - x);
556 memset(dst + x, bytestream2_get_byte(gb), length);
564 memset(dst+x, 0, dst_size - x);
574 int i, y_pos = 0, x_pos = 0;
576 if (bytestream2_get_be32(gb) !=
MKBETAG(
'V',
'D',
'A',
'T'))
580 count = bytestream2_get_be16(gb) - 2;
587 for (i = 0; i < count && x_pos < line_size; i++) {
588 int8_t cmd = bytestream2_get_byte(&cmds);
592 l = bytestream2_get_be16(gb);
593 while (l-- > 0 && x_pos < line_size) {
594 dst[x_pos + y_pos * line_size ] = bytestream2_get_byte(gb);
595 dst[x_pos + y_pos++ * line_size + 1] = bytestream2_get_byte(gb);
596 if (y_pos >= height) {
601 }
else if (cmd < 0) {
603 while (l-- > 0 && x_pos < line_size) {
604 dst[x_pos + y_pos * line_size ] = bytestream2_get_byte(gb);
605 dst[x_pos + y_pos++ * line_size + 1] = bytestream2_get_byte(gb);
606 if (y_pos >= height) {
611 }
else if (cmd == 1) {
612 l = bytestream2_get_be16(gb);
613 r = bytestream2_get_be16(gb);
614 while (l-- > 0 && x_pos < line_size) {
615 dst[x_pos + y_pos * line_size ] = r >> 8;
616 dst[x_pos + y_pos++ * line_size + 1] = r & 0xFF;
617 if (y_pos >= height) {
624 r = bytestream2_get_be16(gb);
625 while (l-- > 0 && x_pos < line_size) {
626 dst[x_pos + y_pos * line_size ] = r >> 8;
627 dst[x_pos + y_pos++ * line_size + 1] = r & 0xFF;
628 if (y_pos >= height) {
639 #define DECODE_RGBX_COMMON(type) \ 641 length = bytestream2_get_byte(gb); \ 643 length = bytestream2_get_be16(gb); \ 648 for (i = 0; i < length; i++) { \ 649 *(type *)(dst + y*linesize + x * sizeof(type)) = pixel; \ 668 int x = 0, y = 0, i,
length;
670 uint32_t
pixel = 0xFF000000 | bytestream2_get_be24(gb);
671 length = bytestream2_get_byte(gb) & 0x7F;
685 int x = 0, y = 0, i,
length;
687 uint32_t
pixel = bytestream2_get_be16u(gb);
688 length = pixel & 0x7;
705 const uint8_t *src_end = src + src_size;
707 while (src + 5 <= src_end) {
709 opcode = *(int8_t *)src++;
711 int size = opcode + 1;
712 for (i = 0; i <
size; i++) {
714 memcpy(dst + y*linesize + x * 4, src, length * 4);
726 int size = -opcode + 1;
728 for (i = 0; i <
size; i++) {
729 *(uint32_t *)(dst + y*linesize + x * 4) =
pixel;
755 int x = 0, y = 0,
plane = 0;
759 for (i = 0; i < src_size * 2;) {
760 #define GETNIBBLE ((i & 1) ? (src[i>>1] & 0xF) : (src[i>>1] >> 4)) 768 if (i >= src_size * 2)
772 d =
FFMIN(d, width - x);
773 for (j = 0; j < d; j++) {
795 int w,
int bpp,
int dst_size)
797 int planepitch =
FFALIGN(w, 16) >> 3;
798 int pitch = planepitch *
bpp;
801 unsigned ofssrc, pos;
807 for (k = 0; k <
bpp; k++) {
808 ofssrc = bytestream2_get_be32(&ptrs);
814 if (ofssrc >= buf_end - buf)
819 int16_t
offset = bytestream2_get_be16(&gb);
823 unsigned data = bytestream2_get_be16(&gb);
826 noffset = (pos / planepitch) * pitch + (pos % planepitch) + k * planepitch;
828 bytestream2_put_be16(&pb, data);
830 uint16_t
count = bytestream2_get_be16(&gb);
832 pos += 2 * -(offset + 2);
833 for (i = 0; i <
count; i++) {
834 uint16_t
data = bytestream2_get_be16(&gb);
837 noffset = (pos / planepitch) * pitch + (pos % planepitch) + k * planepitch;
839 bytestream2_put_be16(&pb, data);
848 int w,
int xor,
int bpp,
int dst_size)
850 int ncolumns = ((w + 15) / 16) * 2;
851 int dstpitch = ncolumns *
bpp;
852 unsigned ofsdst, ofssrc, opcode, x;
860 for (k = 0; k <
bpp; k++) {
861 ofssrc = bytestream2_get_be32(&ptrs);
866 if (ofssrc >= buf_end - buf)
870 for (j = 0; j < ncolumns; j++) {
871 ofsdst = j + k * ncolumns;
873 i = bytestream2_get_byte(&gb);
875 opcode = bytestream2_get_byte(&gb);
878 opcode = bytestream2_get_byte(&gb);
879 x = bytestream2_get_byte(&gb);
883 if (xor && ofsdst < dst_size) {
884 bytestream2_put_byte(&pb, dst[ofsdst] ^ x);
886 bytestream2_put_byte(&pb, x);
891 }
else if (opcode < 0x80) {
892 ofsdst += opcode * dstpitch;
898 if (xor && ofsdst < dst_size) {
899 bytestream2_put_byte(&pb, dst[ofsdst] ^ bytestream2_get_byte(&gb));
901 bytestream2_put_byte(&pb, bytestream2_get_byte(&gb));
915 int w,
int h,
int bpp,
int dst_size)
921 int planepitch_byte = (w + 7) / 8;
922 int planepitch = ((w + 15) / 16) * 2;
923 int kludge_j,
b,
g,
r, d;
926 pitch = planepitch *
bpp;
927 kludge_j = w < 320 ? (320 -
w) / 8 / 2 : 0;
932 type = bytestream2_get_be16(&gb);
938 flag = bytestream2_get_be16(&gb);
939 cols = bytestream2_get_be16(&gb);
940 groups = bytestream2_get_be16(&gb);
942 for (g = 0; g <
groups; g++) {
943 offset = bytestream2_get_be16(&gb);
951 offset = ((offset / (320 / 8)) * pitch) + (offset % (320 / 8)) - kludge_j;
953 offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte);
955 for (b = 0; b < cols; b++) {
956 for (d = 0; d <
bpp; d++) {
959 if (offset >= dst_size)
968 offset += planepitch;
971 if ((cols * bpp) & 1)
976 flag = bytestream2_get_be16(&gb);
977 rows = bytestream2_get_be16(&gb);
978 bytes = bytestream2_get_be16(&gb);
979 groups = bytestream2_get_be16(&gb);
981 for (g = 0; g <
groups; g++) {
982 offset = bytestream2_get_be16(&gb);
985 offset = ((offset / (320 / 8)) * pitch) + (offset % (320/ 8)) - kludge_j;
987 offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte);
989 for (r = 0; r < rows; r++) {
990 for (d = 0; d <
bpp; d++) {
991 unsigned noffset = offset + (r * pitch) + d * planepitch;
998 for (b = 0; b < bytes; b++) {
1001 if (noffset >= dst_size)
1003 ptr = dst + noffset;
1014 if ((rows * bytes * bpp) & 1)
1026 int w,
int bpp,
int dst_size)
1028 int ncolumns = (w + 15) >> 4;
1029 int dstpitch = ncolumns * bpp * 2;
1030 unsigned ofsdst, ofssrc, ofsdata, opcode, x;
1035 if (buf_end - buf <= 64)
1042 for (k = 0; k <
bpp; k++) {
1043 ofssrc = bytestream2_get_be32(&ptrs);
1044 ofsdata = bytestream2_get_be32(&dptrs);
1049 if (ofssrc >= buf_end - buf)
1052 if (ofsdata >= buf_end - buf)
1057 for (j = 0; j < ncolumns; j++) {
1058 ofsdst = (j + k * ncolumns) * 2;
1060 i = bytestream2_get_byte(&gb);
1062 opcode = bytestream2_get_byte(&gb);
1065 opcode = bytestream2_get_byte(&gb);
1066 x = bytestream2_get_be16(&dgb);
1070 bytestream2_put_be16(&pb, x);
1074 }
else if (opcode < 0x80) {
1075 ofsdst += opcode * dstpitch;
1081 bytestream2_put_be16(&pb, bytestream2_get_be16(&dgb));
1094 int w,
int bpp,
int dst_size)
1096 int ncolumns = (w + 31) >> 5;
1097 int dstpitch = ((w + 15) / 16 * 2) *
bpp;
1098 unsigned ofsdst, ofssrc, ofsdata, opcode, x;
1103 if (buf_end - buf <= 64)
1106 h = (((w + 15) / 16 * 2) != ((w + 31) / 32 * 4)) ? 1 : 0;
1111 for (k = 0; k <
bpp; k++) {
1112 ofssrc = bytestream2_get_be32(&ptrs);
1113 ofsdata = bytestream2_get_be32(&dptrs);
1118 if (ofssrc >= buf_end - buf)
1121 if (ofsdata >= buf_end - buf)
1126 for (j = 0; j < ncolumns; j++) {
1127 ofsdst = (j + k * ncolumns) * 4 - h * (2 * k);
1129 i = bytestream2_get_byte(&gb);
1131 opcode = bytestream2_get_byte(&gb);
1134 opcode = bytestream2_get_byte(&gb);
1135 if (h && (j == (ncolumns - 1))) {
1136 x = bytestream2_get_be16(&dgb);
1139 x = bytestream2_get_be32(&dgb);
1144 if (h && (j == (ncolumns - 1))) {
1145 bytestream2_put_be16(&pb, x);
1147 bytestream2_put_be32(&pb, x);
1152 }
else if (opcode < 0x80) {
1153 ofsdst += opcode * dstpitch;
1159 if (h && (j == (ncolumns - 1))) {
1160 bytestream2_put_be16(&pb, bytestream2_get_be16(&dgb));
1163 bytestream2_put_be32(&pb, bytestream2_get_be32(&dgb));
1177 int w,
int bpp,
int dst_size)
1179 int ncolumns = (w + 15) >> 4;
1180 int dstpitch = ncolumns * bpp * 2;
1181 unsigned ofsdst, ofssrc, opcode, x;
1189 for (k = 0; k <
bpp; k++) {
1190 ofssrc = bytestream2_get_be32(&ptrs);
1195 if (ofssrc >= buf_end - buf)
1199 for (j = 0; j < ncolumns; j++) {
1200 ofsdst = (j + k * ncolumns) * 2;
1202 i = bytestream2_get_be16(&gb);
1204 opcode = bytestream2_get_be16(&gb);
1207 opcode = bytestream2_get_be16(&gb);
1208 x = bytestream2_get_be16(&gb);
1212 bytestream2_put_be16(&pb, x);
1216 }
else if (opcode < 0x8000) {
1217 ofsdst += opcode * dstpitch;
1224 bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
1237 int w,
int bpp,
int dst_size)
1239 int ncolumns = (w + 31) >> 5;
1240 int dstpitch = ((w + 15) / 16 * 2) *
bpp;
1241 unsigned ofsdst, ofssrc, opcode, x;
1242 unsigned skip = 0x80000000,
mask = skip - 1;
1247 h = (((w + 15) / 16 * 2) != ((w + 31) / 32 * 4)) ? 1 : 0;
1251 for (k = 0; k <
bpp; k++) {
1252 ofssrc = bytestream2_get_be32(&ptrs);
1257 if (ofssrc >= buf_end - buf)
1261 for (j = 0; j < ncolumns; j++) {
1262 ofsdst = (j + k * ncolumns) * 4 - h * (2 * k);
1264 if (h && (j == (ncolumns - 1))) {
1269 i = bytestream2_get_be32(&gb);
1271 opcode = bytestream2_get_be32(&gb);
1274 if (h && (j == ncolumns - 1)) {
1275 opcode = bytestream2_get_be16(&gb);
1276 x = bytestream2_get_be16(&gb);
1278 opcode = bytestream2_get_be32(&gb);
1279 x = bytestream2_get_be32(&gb);
1284 if (h && (j == ncolumns - 1))
1285 bytestream2_put_be16(&pb, x);
1287 bytestream2_put_be32(&pb, x);
1291 }
else if (opcode < skip) {
1292 ofsdst += opcode * dstpitch;
1299 if (h && (j == ncolumns - 1)) {
1300 bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
1302 bytestream2_put_be32(&pb, bytestream2_get_be32(&gb));
1316 int w,
int flag,
int bpp,
int dst_size)
1318 int planepitch =
FFALIGN(w, 16) >> 3;
1319 int pitch = planepitch *
bpp;
1320 int planepitch_byte = (w + 7) / 8;
1321 unsigned entries, ofssrc;
1326 if (buf_end - buf <= 4 * bpp)
1332 for (k = 0; k <
bpp; k++) {
1333 ofssrc = bytestream2_get_be32(&ptrs);
1338 if (ofssrc >= buf_end - buf)
1343 entries = bytestream2_get_be32(&gb);
1345 int32_t opcode = bytestream2_get_be32(&gb);
1346 unsigned offset = bytestream2_get_be32(&gb);
1348 bytestream2_seek_p(&pb, (offset / planepitch_byte) * pitch + (offset % planepitch_byte) + k * planepitch, SEEK_SET);
1350 uint32_t x = bytestream2_get_be32(&gb);
1352 bytestream2_put_be32(&pb, x);
1359 bytestream2_put_be32(&pb, bytestream2_get_be32(&gb));
1371 int w,
int flag,
int bpp,
int dst_size)
1373 int planepitch =
FFALIGN(w, 16) >> 3;
1374 int pitch = planepitch *
bpp;
1375 int planepitch_byte = (w + 7) / 8;
1376 unsigned entries, ofssrc;
1381 if (buf_end - buf <= 4 * bpp)
1387 for (k = 0; k <
bpp; k++) {
1388 ofssrc = bytestream2_get_be32(&ptrs);
1393 if (ofssrc >= buf_end - buf)
1398 entries = bytestream2_get_be16(&gb);
1400 int16_t opcode = bytestream2_get_be16(&gb);
1401 unsigned offset = bytestream2_get_be32(&gb);
1403 bytestream2_seek_p(&pb, (offset / planepitch_byte) * pitch + (offset % planepitch_byte) + k * planepitch, SEEK_SET);
1405 uint16_t x = bytestream2_get_be16(&gb);
1407 bytestream2_put_be16(&pb, x);
1414 bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
1426 int w,
int flag,
int bpp,
int dst_size)
1430 unsigned poff0, poff1;
1432 int planepitch_byte = (w + 7) / 8;
1433 int planepitch = ((w + 15) / 16) * 2;
1434 int pitch = planepitch *
bpp;
1436 if (buf_end - buf <= 64)
1443 dstpitch = flag ? (((w + 7) / 8) *
bpp): 2;
1445 for (k = 0; k <
bpp; k++) {
1446 poff0 = bytestream2_get_be32(&off0);
1447 poff1 = bytestream2_get_be32(&off1);
1452 if (2LL * poff0 >= buf_end - buf)
1455 if (2LL * poff1 >= buf_end - buf)
1462 uint32_t
offset = bytestream2_get_be16(&ogb);
1463 int16_t cnt = bytestream2_get_be16(&ogb);
1466 offset = ((2 *
offset) / planepitch_byte) * pitch + ((2 *
offset) % planepitch_byte) + k * planepitch;
1472 data = bytestream2_get_be16(&dgb);
1473 for (i = 0; i < cnt; i++) {
1474 bytestream2_put_be16(&pb, data);
1481 for (i = 0; i < cnt; i++) {
1482 data = bytestream2_get_be16(&dgb);
1483 bytestream2_put_be16(&pb, data);
1499 void *
data,
int *got_frame,
1505 int buf_size = avpkt->
size;
1506 const uint8_t *buf_end = buf + buf_size;
1545 for (plane = 0; plane < s->
bpp; plane++) {
1546 for (y = 0; y < avctx->
height && buf < buf_end; y++) {
1552 }
else if (s->
ham) {
1554 for (y = 0; y < avctx->
height; y++) {
1557 for (plane = 0; plane < s->
bpp; plane++) {
1559 if (start >= buf_end)
1570 for (y = 0; y < avctx->
height && buf < buf_end; y++) {
1572 memcpy(row, buf,
FFMIN(raw_width, buf_end - buf));
1575 for (x = 0; x < avctx->
width; x++)
1576 row[4 * x + 3] = row[4 * x + 3] & 0xF0 | (row[4 * x + 3] >> 4);
1584 for (y = 0; y < avctx->
height; y++) {
1586 memset(row, 0, avctx->
width);
1587 for (plane = 0; plane < s->
bpp && buf < buf_end; plane++) {
1592 }
else if (s->
ham) {
1593 for (y = 0; y < avctx->
height; y++) {
1596 for (plane = 0; plane < s->
bpp && buf < buf_end; plane++) {
1603 for (y = 0; y < avctx->
height; y++) {
1605 memset(row, 0, avctx->
width << 2);
1606 for (plane = 0; plane < s->
bpp && buf < buf_end; plane++) {
1615 for (y = 0; y < avctx->
height && buf_end >
buf; y++) {
1617 memcpy(row, buf,
FFMIN(avctx->
width, buf_end - buf));
1620 }
else if (s->
ham) {
1621 for (y = 0; y < avctx->
height && buf_end >
buf; y++) {
1639 for (y = 0; y < avctx->
height; y++) {
1641 memset(row, 0, avctx->
width);
1642 for (plane = 0; plane < s->
bpp; plane++) {
1652 for (y = 0; y < avctx->
height; y++) {
1655 for (plane = 0; plane < s->
bpp; plane++) {
1661 }
else if (s->
ham) {
1663 for (y = 0; y < avctx->
height; y++) {
1666 for (plane = 0; plane < s->
bpp; plane++) {
1677 for (y = 0; y < avctx->
height; y++) {
1679 memset(row, 0, avctx->
width << 2);
1680 for (plane = 0; plane < s->
bpp; plane++) {
1688 for (y = 0; y < avctx->
height; y++) {
1692 }
else if (s->
ham) {
1693 for (y = 0; y < avctx->
height; y++) {
1708 for (plane = 0; plane < s->
bpp; plane++) {
1709 for (y = 0; y < avctx->
height && buf < buf_end; y++) {
1715 }
else if (s->
ham) {
1717 for (y = 0; y < avctx->
height; y++) {
1720 for (plane = 0; plane < s->
bpp; plane++) {
1722 if (start >= buf_end)
1737 for (plane = 0; plane < s->
bpp; plane++) {
1739 for (y = 0; y < avctx->
height; y++) {
1818 for (y = 0; y < avctx->
height; y++) {
1820 memset(row, 0, avctx->
width);
1821 for (plane = 0; plane < s->
bpp; plane++) {
1826 memcpy(frame->
data[1], s->
pal, 256 * 4);
1827 }
else if (s->
ham) {
1831 memset(s->
ham_palbuf, 0, (1 << s->
ham) * 2 *
sizeof(uint32_t));
1832 for (i = 0; i <
count; i++) {
1835 for (i = 0; i <
count; i++) {
1836 uint32_t
tmp = i << (8 - s->
ham);
1837 tmp |= tmp >> s->
ham;
1842 s->
ham_palbuf[(i+count*2)*2+1] = 0xFF000000 | tmp;
1843 s->
ham_palbuf[(i+count*3)*2+1] = 0xFF000000 | tmp << 8;
1846 for (i = 0; i < 8 * (1 << s->
ham); i++)
1849 for (y = 0; y < avctx->
height; y++) {
1852 for (plane = 0; plane < s->
bpp; plane++) {
1880 #if CONFIG_IFF_ILBM_DECODER #define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
unsigned is_brush
video is in ANBR format
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void decodeplane32(uint32_t *dst, const uint8_t *buf, int buf_size, int plane)
Decode interleaved plane buffer up to 24bpp.
unsigned compression
delta compression method used
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
uint32_t * mask_palbuf
masking palette table
#define AV_LOG_WARNING
Something somehow does not look correct.
unsigned masking
TODO: masking method used.
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
unsigned transparency
TODO: transparency color index in palette.
static int cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
Convert CMAP buffer (stored in extradata) to lavc palette format.
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define AV_PIX_FMT_RGB444
unsigned flags
1 for EHB, 0 is no extra half darkening
unsigned is_short
short compression method used
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static void decode_delta_e(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int flag, int bpp, int dst_size)
static void decodeplane8(uint8_t *dst, const uint8_t *buf, int buf_size, int plane)
Decode interleaved plane buffer up to 8bpp.
uint32_t * mask_buf
temporary buffer for palette indices
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
#define DECODE_HAM_PLANE32(x)
static av_cold int decode_end(AVCodecContext *avctx)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static void decode_deep_tvdc32(uint8_t *dst, const uint8_t *src, int src_size, int width, int height, int linesize, const int16_t *tvdc)
Decode DEEP TVDC 32-bit buffer.
8 bits with AV_PIX_FMT_RGB32 palette
uint8_t * ham_buf
temporary buffer for planar to chunky conversation
static const OptionGroupDef groups[]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline unsigned int bytestream2_get_bytes_left_p(PutByteContext *p)
static const uint16_t mask[17]
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
#define AV_PIX_FMT_0BGR32
const char * name
Name of the codec implementation.
static const uint8_t offset[127][2]
unsigned is_interlaced
video is interlaced
int flags
A combination of AV_PKT_FLAG values.
static av_always_inline void bytestream2_skip_p(PutByteContext *p, unsigned int size)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
enum AVPictureType pict_type
Picture type of the frame.
static void decode_short_vertical_delta(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int bpp, int dst_size)
int width
picture width / height.
static void decode_short_horizontal_delta(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int bpp, int dst_size)
static int decode_byterun(uint8_t *dst, int dst_size, GetByteContext *gb)
Decode one complete byterun1 encoded line.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static av_always_inline int bytestream2_seek_p(PutByteContext *p, int offset, int whence)
static av_always_inline int bytestream2_tell(GetByteContext *g)
static void decode_long_vertical_delta(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int bpp, int dst_size)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AVCodec ff_iff_ilbm_decoder
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define DECODE_RGBX_COMMON(type)
main external API structure.
static void decode_short_vertical_delta2(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int bpp, int dst_size)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void decode_delta_j(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int h, int bpp, int dst_size)
static av_always_inline uint32_t gray2rgb(const uint32_t x)
static void decode_rgbn(GetByteContext *gb, uint8_t *dst, int width, int height, int linesize)
Decode RGBN buffer.
static void decode_long_vertical_delta2(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int bpp, int dst_size)
static void decode_delta_l(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int flag, int bpp, int dst_size)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void decode_byte_vertical_delta(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int xor, int bpp, int dst_size)
common internal api header.
unsigned ham
0 if non-HAM or number of hold bits (6 for bpp > 6, 4 otherwise)
static const uint32_t plane32_lut[32][16 *4]
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static void decode_delta_d(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int flag, int bpp, int dst_size)
static void decode_rgb8(GetByteContext *gb, uint8_t *dst, int width, int height, int linesize)
Decode RGB8 buffer.
static void decode_ham_plane32(uint32_t *dst, const uint8_t *buf, const uint32_t *const pal, unsigned buf_size)
Converts one line of HAM6/8-encoded chunky buffer to 24bpp.
#define MKBETAG(a, b, c, d)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static av_cold int decode_init(AVCodecContext *avctx)
static const uint64_t plane8_lut[8][256]
int key_frame
1 -> keyframe, 0-> not
static int decode_byterun2(uint8_t *dst, int height, int line_size, GetByteContext *gb)
#define FFSWAP(type, a, b)
static int extract_header(AVCodecContext *const avctx, const AVPacket *const avpkt)
Extracts the IFF extra context and updates internal decoder structures.
static void lookup_pal_indicies(uint32_t *dst, const uint32_t *buf, const uint32_t *const pal, unsigned width)
int16_t tvdc[16]
TVDC lookup table.
static int unsupported(AVCodecContext *avctx)
#define MKTAG(a, b, c, d)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
uint32_t * ham_palbuf
HAM decode table.
unsigned bpp
bits per plane to decode (differs from bits_per_coded_sample if HAM)
static void decode_deep_rle32(uint8_t *dst, const uint8_t *src, int src_size, int width, int height, int linesize)
Decode DEEP RLE 32-bit buffer.