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, 1U << plane, \ 117 0, 0, 1U << plane, 0, \ 118 0, 0, 1U << plane, 1U << plane, \ 119 0, 1U << plane, 0, 0, \ 120 0, 1U << plane, 0, 1U << plane, \ 121 0, 1U << plane, 1U << plane, 0, \ 122 0, 1U << plane, 1U << plane, 1U << plane, \ 123 1U << plane, 0, 0, 0, \ 124 1U << plane, 0, 0, 1U << plane, \ 125 1U << plane, 0, 1U << plane, 0, \ 126 1U << plane, 0, 1U << plane, 1U << plane, \ 127 1U << plane, 1U << plane, 0, 0, \ 128 1U << plane, 1U << plane, 0, 1U << plane, \ 129 1U << plane, 1U << plane, 1U << plane, 0, \ 130 1U << plane, 1U << plane, 1U << plane, 1U << 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++)
188 for (i = 0; i < count; i++)
209 unsigned buf_size = 0;
225 chunk_id = bytestream2_get_le32(gb);
226 data_size = bytestream2_get_be32(gb);
228 if (chunk_id ==
MKTAG(
'B',
'M',
'H',
'D')) {
230 }
else if (chunk_id ==
MKTAG(
'A',
'N',
'H',
'D')) {
237 extra = bytestream2_get_be32(gb);
243 }
else if (chunk_id ==
MKTAG(
'D',
'L',
'T',
'A') ||
244 chunk_id ==
MKTAG(
'B',
'O',
'D',
'Y')) {
245 if (chunk_id ==
MKTAG(
'B',
'O',
'D',
'Y'))
248 }
else if (chunk_id ==
MKTAG(
'C',
'M',
'A',
'P')) {
249 int count = data_size / 3;
255 for (i = 0; i < count; i++)
256 pal[i] = 0xFF000000 | bytestream2_get_le24(gb);
258 for (i = 0; i < count; i++)
259 pal[i] = 0xFF000000 | bytestream2_get_be24(gb);
268 buf_size = bytestream_get_be16(&buf);
269 if (buf_size <= 1 || palette_size < 0) {
271 "Invalid palette size received: %u -> palette data offset: %d\n",
272 buf_size, palette_size);
277 if (buf_size >= 41) {
279 s->
bpp = bytestream_get_byte(&buf);
280 s->
ham = bytestream_get_byte(&buf);
281 s->
flags = bytestream_get_byte(&buf);
283 s->
masking = bytestream_get_byte(&buf);
284 for (i = 0; i < 16; i++)
285 s->
tvdc[i] = bytestream_get_be16(&buf);
291 }
else if (s->
ham != (s->
bpp > 6 ? 6 : 4)) {
298 if (s->
bpp >= 8 && !s->
ham) {
321 if (!s->
bpp || s->
bpp > 32) {
332 int i, count =
FFMIN(palette_size / 3, 1 << s->
ham);
344 ham_count = 8 * (1 << s->
ham);
353 memset(s->
ham_palbuf, 0, (1 << s->
ham) * 2 * sizeof (uint32_t));
354 for (i=0; i < count; i++) {
360 for (i=0; i < count; i++) {
365 for (i=0; i < count; i++) {
366 uint32_t
tmp = i << (8 - s->
ham);
367 tmp |= tmp >> s->
ham;
371 s->
ham_palbuf[(i+count)*2+1] = 0xFF000000 | tmp << 16;
372 s->
ham_palbuf[(i+count*2)*2+1] = 0xFF000000 | tmp;
373 s->
ham_palbuf[(i+count*3)*2+1] = 0xFF000000 | tmp << 8;
376 for (i = 0; i < ham_count; i++)
474 uint64_t v =
AV_RN64A(dst) | lut[*buf++];
477 }
while (--buf_size);
491 unsigned mask = (*buf >> 2) & ~3;
492 dst[0] |= lut[mask++];
493 dst[1] |= lut[mask++];
494 dst[2] |= lut[mask++];
496 mask = (*buf++ << 2) & 0x3F;
497 dst[4] |= lut[mask++];
498 dst[5] |= lut[mask++];
499 dst[6] |= lut[mask++];
502 }
while (--buf_size);
505 #define DECODE_HAM_PLANE32(x) \ 506 first = buf[x] << 1; \ 507 second = buf[(x)+1] << 1; \ 508 delta &= pal[first++]; \ 509 delta |= pal[first]; \ 511 delta &= pal[second++]; \ 512 delta |= pal[second]; \ 524 const uint32_t *
const pal,
unsigned buf_size)
526 uint32_t
delta = pal[1];
528 uint32_t first, second;
535 }
while (--buf_size);
539 const uint32_t *
const pal,
unsigned width)
542 *dst++ = pal[*buf++];
559 for (x = 0; x < dst_size && bytestream2_get_bytes_left(gb) > 0;) {
561 const int8_t
value = bytestream2_get_byte(gb);
565 if (length < value + 1)
567 }
else if (value > -128) {
568 length =
FFMIN(-value + 1, dst_size - x);
569 memset(dst + x, bytestream2_get_byte(gb), length);
577 memset(dst+x, 0, dst_size - x);
587 int i, y_pos = 0, x_pos = 0;
589 if (bytestream2_get_be32(gb) !=
MKBETAG(
'V',
'D',
'A',
'T'))
593 count = bytestream2_get_be16(gb) - 2;
600 for (i = 0; i < count && x_pos < line_size; i++) {
601 int8_t cmd = bytestream2_get_byte(&cmds);
605 l = bytestream2_get_be16(gb);
606 while (l-- > 0 && x_pos < line_size) {
607 dst[x_pos + y_pos * line_size ] = bytestream2_get_byte(gb);
608 dst[x_pos + y_pos++ * line_size + 1] = bytestream2_get_byte(gb);
609 if (y_pos >= height) {
614 }
else if (cmd < 0) {
616 while (l-- > 0 && x_pos < line_size) {
617 dst[x_pos + y_pos * line_size ] = bytestream2_get_byte(gb);
618 dst[x_pos + y_pos++ * line_size + 1] = bytestream2_get_byte(gb);
619 if (y_pos >= height) {
624 }
else if (cmd == 1) {
625 l = bytestream2_get_be16(gb);
626 r = bytestream2_get_be16(gb);
627 while (l-- > 0 && x_pos < line_size) {
628 dst[x_pos + y_pos * line_size ] = r >> 8;
629 dst[x_pos + y_pos++ * line_size + 1] = r & 0xFF;
630 if (y_pos >= height) {
637 r = bytestream2_get_be16(gb);
638 while (l-- > 0 && x_pos < line_size) {
639 dst[x_pos + y_pos * line_size ] = r >> 8;
640 dst[x_pos + y_pos++ * line_size + 1] = r & 0xFF;
641 if (y_pos >= height) {
652 #define DECODE_RGBX_COMMON(type) \ 654 length = bytestream2_get_byte(gb); \ 656 length = bytestream2_get_be16(gb); \ 661 for (i = 0; i < length; i++) { \ 662 *(type *)(dst + y*linesize + x * sizeof(type)) = pixel; \ 681 int x = 0, y = 0,
i, length;
683 uint32_t
pixel = 0xFF000000 | bytestream2_get_be24(gb);
684 length = bytestream2_get_byte(gb) & 0x7F;
698 int x = 0, y = 0,
i, length;
700 uint32_t
pixel = bytestream2_get_be16u(gb);
701 length = pixel & 0x7;
718 const uint8_t *src_end = src + src_size;
720 while (src_end - src >= 5) {
722 opcode = *(int8_t *)src++;
724 int size = opcode + 1;
726 int length =
FFMIN(size -
i, width - x);
727 if (src_end - src < length * 4)
729 memcpy(dst + y*linesize + x * 4, src, length * 4);
741 int size = -opcode + 1;
744 *(uint32_t *)(dst + y*linesize + x * 4) =
pixel;
770 int x = 0, y = 0, plane = 0;
774 for (i = 0; i < src_size * 2;) {
775 #define GETNIBBLE ((i & 1) ? (src[i>>1] & 0xF) : (src[i>>1] >> 4)) 780 dst[y * linesize + x*4 + plane] =
pixel;
783 if (i >= src_size * 2)
787 d =
FFMIN(d, width - x);
788 for (j = 0; j < d; j++) {
789 dst[y * linesize + x*4 + plane] =
pixel;
810 int w,
int bpp,
int dst_size)
812 int planepitch =
FFALIGN(w, 16) >> 3;
813 int pitch = planepitch *
bpp;
816 unsigned ofssrc,
pos;
822 for (k = 0; k <
bpp; k++) {
823 ofssrc = bytestream2_get_be32(&ptrs);
829 if (ofssrc >= buf_end - buf)
834 int16_t
offset = bytestream2_get_be16(&gb);
838 unsigned data = bytestream2_get_be16(&gb);
841 noffset = (pos / planepitch) * pitch + (pos % planepitch) + k * planepitch;
843 bytestream2_put_be16(&pb, data);
845 uint16_t count = bytestream2_get_be16(&gb);
847 pos += 2 * -(offset + 2);
848 for (i = 0; i < count; i++) {
849 uint16_t
data = bytestream2_get_be16(&gb);
852 noffset = (pos / planepitch) * pitch + (pos % planepitch) + k * planepitch;
854 bytestream2_put_be16(&pb, data);
863 int w,
int xor,
int bpp,
int dst_size)
865 int ncolumns = ((w + 15) / 16) * 2;
866 int dstpitch = ncolumns *
bpp;
867 unsigned ofsdst, ofssrc, opcode, x;
875 for (k = 0; k <
bpp; k++) {
876 ofssrc = bytestream2_get_be32(&ptrs);
881 if (ofssrc >= buf_end - buf)
885 for (j = 0; j < ncolumns; j++) {
886 ofsdst = j + k * ncolumns;
888 i = bytestream2_get_byte(&gb);
890 opcode = bytestream2_get_byte(&gb);
893 opcode = bytestream2_get_byte(&gb);
894 x = bytestream2_get_byte(&gb);
898 if (xor && ofsdst < dst_size) {
899 bytestream2_put_byte(&pb, dst[ofsdst] ^ x);
901 bytestream2_put_byte(&pb, x);
906 }
else if (opcode < 0x80) {
907 ofsdst += opcode * dstpitch;
913 if (xor && ofsdst < dst_size) {
914 bytestream2_put_byte(&pb, dst[ofsdst] ^ bytestream2_get_byte(&gb));
916 bytestream2_put_byte(&pb, bytestream2_get_byte(&gb));
930 int w,
int h,
int bpp,
int dst_size)
936 int planepitch_byte = (w + 7) / 8;
937 int planepitch = ((w + 15) / 16) * 2;
938 int kludge_j,
b,
g,
r, d;
941 pitch = planepitch *
bpp;
942 kludge_j = w < 320 ? (320 -
w) / 8 / 2 : 0;
947 type = bytestream2_get_be16(&gb);
953 flag = bytestream2_get_be16(&gb);
954 cols = bytestream2_get_be16(&gb);
955 groups = bytestream2_get_be16(&gb);
957 for (g = 0; g <
groups; g++) {
958 offset = bytestream2_get_be16(&gb);
966 offset = ((offset / (320 / 8)) * pitch) + (offset % (320 / 8)) - kludge_j;
968 offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte);
970 for (b = 0; b < cols; b++) {
971 for (d = 0; d <
bpp; d++) {
974 if (offset >= dst_size)
983 offset += planepitch;
986 if ((cols * bpp) & 1)
991 flag = bytestream2_get_be16(&gb);
992 rows = bytestream2_get_be16(&gb);
993 bytes = bytestream2_get_be16(&gb);
994 groups = bytestream2_get_be16(&gb);
996 for (g = 0; g <
groups; g++) {
997 offset = bytestream2_get_be16(&gb);
1000 offset = ((offset / (320 / 8)) * pitch) + (offset % (320/ 8)) - kludge_j;
1002 offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte);
1004 for (r = 0; r < rows; r++) {
1005 for (d = 0; d <
bpp; d++) {
1006 unsigned noffset = offset + (r * pitch) + d * planepitch;
1013 for (b = 0; b < bytes; b++) {
1016 if (noffset >= dst_size)
1018 ptr = dst + noffset;
1029 if ((rows * bytes * bpp) & 1)
1041 int w,
int bpp,
int dst_size)
1043 int ncolumns = (w + 15) >> 4;
1044 int dstpitch = ncolumns * bpp * 2;
1045 unsigned ofsdst, ofssrc, ofsdata, opcode, x;
1050 if (buf_end - buf <= 64)
1057 for (k = 0; k <
bpp; k++) {
1058 ofssrc = bytestream2_get_be32(&ptrs);
1059 ofsdata = bytestream2_get_be32(&dptrs);
1064 if (ofssrc >= buf_end - buf)
1067 if (ofsdata >= buf_end - buf)
1072 for (j = 0; j < ncolumns; j++) {
1073 ofsdst = (j + k * ncolumns) * 2;
1075 i = bytestream2_get_byte(&gb);
1077 opcode = bytestream2_get_byte(&gb);
1080 opcode = bytestream2_get_byte(&gb);
1081 x = bytestream2_get_be16(&dgb);
1085 bytestream2_put_be16(&pb, x);
1089 }
else if (opcode < 0x80) {
1090 ofsdst += opcode * dstpitch;
1096 bytestream2_put_be16(&pb, bytestream2_get_be16(&dgb));
1109 int w,
int bpp,
int dst_size)
1111 int ncolumns = (w + 31) >> 5;
1112 int dstpitch = ((w + 15) / 16 * 2) *
bpp;
1113 unsigned ofsdst, ofssrc, ofsdata, opcode, x;
1118 if (buf_end - buf <= 64)
1121 h = (((w + 15) / 16 * 2) != ((w + 31) / 32 * 4)) ? 1 : 0;
1126 for (k = 0; k <
bpp; k++) {
1127 ofssrc = bytestream2_get_be32(&ptrs);
1128 ofsdata = bytestream2_get_be32(&dptrs);
1133 if (ofssrc >= buf_end - buf)
1136 if (ofsdata >= buf_end - buf)
1141 for (j = 0; j < ncolumns; j++) {
1142 ofsdst = (j + k * ncolumns) * 4 - h * (2 * k);
1144 i = bytestream2_get_byte(&gb);
1146 opcode = bytestream2_get_byte(&gb);
1149 opcode = bytestream2_get_byte(&gb);
1150 if (h && (j == (ncolumns - 1))) {
1151 x = bytestream2_get_be16(&dgb);
1154 x = bytestream2_get_be32(&dgb);
1162 if (h && (j == (ncolumns - 1))) {
1163 bytestream2_put_be16(&pb, x);
1165 bytestream2_put_be32(&pb, x);
1170 }
else if (opcode < 0x80) {
1171 ofsdst += opcode * dstpitch;
1177 if (h && (j == (ncolumns - 1))) {
1178 bytestream2_put_be16(&pb, bytestream2_get_be16(&dgb));
1181 bytestream2_put_be32(&pb, bytestream2_get_be32(&dgb));
1195 int w,
int bpp,
int dst_size)
1197 int ncolumns = (w + 15) >> 4;
1198 int dstpitch = ncolumns * bpp * 2;
1199 unsigned ofsdst, ofssrc, opcode, x;
1207 for (k = 0; k <
bpp; k++) {
1208 ofssrc = bytestream2_get_be32(&ptrs);
1213 if (ofssrc >= buf_end - buf)
1217 for (j = 0; j < ncolumns; j++) {
1218 ofsdst = (j + k * ncolumns) * 2;
1220 i = bytestream2_get_be16(&gb);
1222 opcode = bytestream2_get_be16(&gb);
1225 opcode = bytestream2_get_be16(&gb);
1226 x = bytestream2_get_be16(&gb);
1230 bytestream2_put_be16(&pb, x);
1234 }
else if (opcode < 0x8000) {
1235 ofsdst += opcode * dstpitch;
1242 bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
1255 int w,
int bpp,
int dst_size)
1257 int ncolumns = (w + 31) >> 5;
1258 int dstpitch = ((w + 15) / 16 * 2) *
bpp;
1259 unsigned ofsdst, ofssrc, opcode, x;
1260 unsigned skip = 0x80000000,
mask = skip - 1;
1265 h = (((w + 15) / 16 * 2) != ((w + 31) / 32 * 4)) ? 1 : 0;
1269 for (k = 0; k <
bpp; k++) {
1270 ofssrc = bytestream2_get_be32(&ptrs);
1275 if (ofssrc >= buf_end - buf)
1279 for (j = 0; j < ncolumns; j++) {
1280 ofsdst = (j + k * ncolumns) * 4 - h * (2 * k);
1282 if (h && (j == (ncolumns - 1))) {
1287 i = bytestream2_get_be32(&gb);
1289 opcode = bytestream2_get_be32(&gb);
1292 if (h && (j == ncolumns - 1)) {
1293 opcode = bytestream2_get_be16(&gb);
1294 x = bytestream2_get_be16(&gb);
1296 opcode = bytestream2_get_be32(&gb);
1297 x = bytestream2_get_be32(&gb);
1305 if (h && (j == ncolumns - 1))
1306 bytestream2_put_be16(&pb, x);
1308 bytestream2_put_be32(&pb, x);
1312 }
else if (opcode < skip) {
1313 ofsdst += opcode * dstpitch;
1320 if (h && (j == ncolumns - 1)) {
1321 bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
1323 bytestream2_put_be32(&pb, bytestream2_get_be32(&gb));
1337 int w,
int flag,
int bpp,
int dst_size)
1339 int planepitch =
FFALIGN(w, 16) >> 3;
1340 int pitch = planepitch *
bpp;
1341 int planepitch_byte = (w + 7) / 8;
1342 unsigned entries, ofssrc;
1347 if (buf_end - buf <= 4 * bpp)
1353 for (k = 0; k <
bpp; k++) {
1354 ofssrc = bytestream2_get_be32(&ptrs);
1359 if (ofssrc >= buf_end - buf)
1364 entries = bytestream2_get_be32(&gb);
1369 int32_t opcode = bytestream2_get_be32(&gb);
1370 unsigned offset = bytestream2_get_be32(&gb);
1372 bytestream2_seek_p(&pb, (offset / planepitch_byte) * pitch + (offset % planepitch_byte) + k * planepitch, SEEK_SET);
1374 uint32_t x = bytestream2_get_be32(&gb);
1378 bytestream2_put_be32(&pb, x);
1384 bytestream2_put_be32(&pb, bytestream2_get_be32(&gb));
1396 int w,
int flag,
int bpp,
int dst_size)
1398 int planepitch =
FFALIGN(w, 16) >> 3;
1399 int pitch = planepitch *
bpp;
1400 int planepitch_byte = (w + 7) / 8;
1401 unsigned entries, ofssrc;
1406 if (buf_end - buf <= 4 * bpp)
1412 for (k = 0; k <
bpp; k++) {
1413 ofssrc = bytestream2_get_be32(&ptrs);
1418 if (ofssrc >= buf_end - buf)
1423 entries = bytestream2_get_be16(&gb);
1425 int16_t opcode = bytestream2_get_be16(&gb);
1426 unsigned offset = bytestream2_get_be32(&gb);
1428 bytestream2_seek_p(&pb, (offset / planepitch_byte) * pitch + (offset % planepitch_byte) + k * planepitch, SEEK_SET);
1430 uint16_t x = bytestream2_get_be16(&gb);
1432 bytestream2_put_be16(&pb, x);
1439 bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
1451 int w,
int flag,
int bpp,
int dst_size)
1455 unsigned poff0, poff1;
1457 int planepitch_byte = (w + 7) / 8;
1458 int planepitch = ((w + 15) / 16) * 2;
1459 int pitch = planepitch *
bpp;
1461 if (buf_end - buf <= 64)
1468 dstpitch = flag ? (((w + 7) / 8) *
bpp): 2;
1470 for (k = 0; k <
bpp; k++) {
1471 poff0 = bytestream2_get_be32(&off0);
1472 poff1 = bytestream2_get_be32(&off1);
1477 if (2LL * poff0 >= buf_end - buf)
1480 if (2LL * poff1 >= buf_end - buf)
1487 uint32_t
offset = bytestream2_get_be16(&ogb);
1488 int16_t cnt = bytestream2_get_be16(&ogb);
1491 offset = ((2 *
offset) / planepitch_byte) * pitch + ((2 *
offset) % planepitch_byte) + k * planepitch;
1497 data = bytestream2_get_be16(&dgb);
1498 for (i = 0; i < cnt; i++) {
1499 bytestream2_put_be16(&pb, data);
1506 for (i = 0; i < cnt; i++) {
1507 data = bytestream2_get_be16(&dgb);
1508 bytestream2_put_be16(&pb, data);
1524 void *
data,
int *got_frame,
1530 int buf_size = avpkt->
size;
1531 const uint8_t *buf_end = buf + buf_size;
1570 for (plane = 0; plane < s->
bpp; plane++) {
1571 for (y = 0; y < avctx->
height && buf < buf_end; y++) {
1577 }
else if (s->
ham) {
1579 for (y = 0; y < avctx->
height; y++) {
1582 for (plane = 0; plane < s->
bpp; plane++) {
1584 if (start >= buf_end)
1595 for (y = 0; y < avctx->
height && buf < buf_end; y++) {
1597 memcpy(row, buf,
FFMIN(raw_width, buf_end - buf));
1600 for (x = 0; x < avctx->
width; x++)
1601 row[4 * x + 3] = row[4 * x + 3] & 0xF0 | (row[4 * x + 3] >> 4);
1609 for (y = 0; y < avctx->
height; y++) {
1611 memset(row, 0, avctx->
width);
1612 for (plane = 0; plane < s->
bpp && buf < buf_end; plane++) {
1617 }
else if (s->
ham) {
1618 for (y = 0; y < avctx->
height; y++) {
1621 for (plane = 0; plane < s->
bpp && buf < buf_end; plane++) {
1628 for (y = 0; y < avctx->
height; y++) {
1630 memset(row, 0, avctx->
width << 2);
1631 for (plane = 0; plane < s->
bpp && buf < buf_end; plane++) {
1640 for (y = 0; y < avctx->
height && buf_end > buf; y++) {
1642 memcpy(row, buf,
FFMIN(avctx->
width, buf_end - buf));
1645 }
else if (s->
ham) {
1646 for (y = 0; y < avctx->
height && buf_end > buf; y++) {
1664 for (y = 0; y < avctx->
height; y++) {
1666 memset(row, 0, avctx->
width);
1667 for (plane = 0; plane < s->
bpp; plane++) {
1677 for (y = 0; y < avctx->
height; y++) {
1680 for (plane = 0; plane < s->
bpp; plane++) {
1686 }
else if (s->
ham) {
1688 for (y = 0; y < avctx->
height; y++) {
1691 for (plane = 0; plane < s->
bpp; plane++) {
1702 for (y = 0; y < avctx->
height; y++) {
1704 memset(row, 0, avctx->
width << 2);
1705 for (plane = 0; plane < s->
bpp; plane++) {
1713 for (y = 0; y < avctx->
height; y++) {
1717 }
else if (s->
ham) {
1718 for (y = 0; y < avctx->
height; y++) {
1733 for (plane = 0; plane < s->
bpp; plane++) {
1734 for (y = 0; y < avctx->
height && buf < buf_end; y++) {
1740 }
else if (s->
ham) {
1742 for (y = 0; y < avctx->
height; y++) {
1745 for (plane = 0; plane < s->
bpp; plane++) {
1747 if (start >= buf_end)
1762 for (plane = 0; plane < s->
bpp; plane++) {
1764 for (y = 0; y < avctx->
height; y++) {
1843 for (y = 0; y < avctx->
height; y++) {
1845 memset(row, 0, avctx->
width);
1846 for (plane = 0; plane < s->
bpp; plane++) {
1852 memcpy(frame->
data[1], s->
pal, 256 * 4);
1853 }
else if (s->
ham) {
1854 int i, count = 1 << s->
ham;
1857 memset(s->
ham_palbuf, 0, (1 << s->
ham) * 2 *
sizeof(uint32_t));
1858 for (i = 0; i < count; i++) {
1861 for (i = 0; i < count; i++) {
1862 uint32_t
tmp = i << (8 - s->
ham);
1863 tmp |= tmp >> s->
ham;
1867 s->
ham_palbuf[(i+count)*2+1] = 0xFF000000 | tmp << 16;
1868 s->
ham_palbuf[(i+count*2)*2+1] = 0xFF000000 | tmp;
1869 s->
ham_palbuf[(i+count*3)*2+1] = 0xFF000000 | tmp << 8;
1872 for (i = 0; i < 8 * (1 << s->
ham); i++)
1875 for (y = 0; y < avctx->
height; y++) {
1878 for (plane = 0; plane < s->
bpp; plane++) {
1906 #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.
#define avpriv_request_sample(...)
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)
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.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
static av_always_inline int bytestream2_get_bytes_left_p(PutByteContext *p)
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)
#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.
static av_always_inline int bytestream2_size_p(PutByteContext *p)
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.