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;
246 uint32_t *pal = s->
pal[0];
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);
284 if (s->
bpp >= 8 && !s->
ham) {
307 if (!s->
bpp || s->
bpp > 32) {
310 }
else if (s->
ham >= 8) {
327 ham_count = 8 * (1 << s->
ham);
336 memset(s->
ham_palbuf, 0, (1 << s->
ham) * 2 * sizeof (uint32_t));
337 for (i=0; i <
count; i++) {
343 for (i=0; i <
count; i++) {
348 for (i=0; i <
count; i++) {
349 uint32_t
tmp = i << (8 - s->
ham);
350 tmp |= tmp >> s->
ham;
355 s->
ham_palbuf[(i+count*2)*2+1] = 0xFF000000 | tmp;
356 s->
ham_palbuf[(i+count*3)*2+1] = 0xFF000000 | tmp << 8;
359 for (i = 0; i < ham_count; i++)
454 uint64_t v =
AV_RN64A(dst) | lut[*buf++];
457 }
while (--buf_size);
471 unsigned mask = (*buf >> 2) & ~3;
472 dst[0] |= lut[mask++];
473 dst[1] |= lut[mask++];
474 dst[2] |= lut[mask++];
476 mask = (*buf++ << 2) & 0x3F;
477 dst[4] |= lut[mask++];
478 dst[5] |= lut[mask++];
479 dst[6] |= lut[mask++];
482 }
while (--buf_size);
485 #define DECODE_HAM_PLANE32(x) \
486 first = buf[x] << 1; \
487 second = buf[(x)+1] << 1; \
488 delta &= pal[first++]; \
489 delta |= pal[first]; \
491 delta &= pal[second++]; \
492 delta |= pal[second]; \
504 const uint32_t *
const pal,
unsigned buf_size)
506 uint32_t
delta = pal[1];
508 uint32_t first, second;
515 }
while (--buf_size);
519 const uint32_t *
const pal,
unsigned width)
522 *dst++ = pal[*buf++];
539 for (x = 0; x < dst_size && bytestream2_get_bytes_left(gb) > 0;) {
541 const int8_t
value = bytestream2_get_byte(gb);
545 if (length < value + 1)
547 }
else if (value > -128) {
548 length =
FFMIN(-value + 1, dst_size - x);
549 memset(dst + x, bytestream2_get_byte(gb), length);
557 memset(dst+x, 0, dst_size - x);
562 #define DECODE_RGBX_COMMON(type) \
564 length = bytestream2_get_byte(gb); \
566 length = bytestream2_get_be16(gb); \
571 for (i = 0; i < length; i++) { \
572 *(type *)(dst + y*linesize + x * sizeof(type)) = pixel; \
591 int x = 0, y = 0, i,
length;
593 uint32_t
pixel = 0xFF000000 | bytestream2_get_be24(gb);
594 length = bytestream2_get_byte(gb) & 0x7F;
608 int x = 0, y = 0, i,
length;
610 uint32_t
pixel = bytestream2_get_be16u(gb);
611 length = pixel & 0x7;
628 const uint8_t *src_end = src + src_size;
630 while (src + 5 <= src_end) {
632 opcode = *(int8_t *)src++;
634 int size = opcode + 1;
635 for (i = 0; i <
size; i++) {
637 memcpy(dst + y*linesize + x * 4, src, length * 4);
649 int size = -opcode + 1;
651 for (i = 0; i <
size; i++) {
652 *(uint32_t *)(dst + y*linesize + x * 4) =
pixel;
678 int x = 0, y = 0,
plane = 0;
682 for (i = 0; i < src_size * 2;) {
683 #define GETNIBBLE ((i & 1) ? (src[i>>1] & 0xF) : (src[i>>1] >> 4))
691 if (i >= src_size * 2)
695 d =
FFMIN(d, width - x);
696 for (j = 0; j < d; j++) {
718 int w,
int bpp,
int dst_size)
720 int planepitch =
FFALIGN(w, 16) >> 3;
721 int pitch = planepitch * bpp;
724 unsigned ofssrc, pos;
730 for (k = 0; k < bpp; k++) {
731 ofssrc = bytestream2_get_be32(&ptrs);
737 if (ofssrc >= buf_end - buf)
742 int16_t
offset = bytestream2_get_be16(&gb);
746 unsigned data = bytestream2_get_be16(&gb);
749 noffset = (pos / planepitch) * pitch + (pos % planepitch) + k * planepitch;
751 bytestream2_put_be16(&pb, data);
753 uint16_t
count = bytestream2_get_be16(&gb);
755 pos += 2 * -(offset + 2);
756 for (i = 0; i <
count; i++) {
757 uint16_t
data = bytestream2_get_be16(&gb);
760 noffset = (pos / planepitch) * pitch + (pos % planepitch) + k * planepitch;
762 bytestream2_put_be16(&pb, data);
771 int w,
int xor,
int bpp,
int dst_size)
773 int ncolumns = ((w + 15) / 16) * 2;
774 int dstpitch = ncolumns * bpp;
775 unsigned ofsdst, ofssrc, opcode, x;
783 for (k = 0; k < bpp; k++) {
784 ofssrc = bytestream2_get_be32(&ptrs);
789 if (ofssrc >= buf_end - buf)
793 for (j = 0; j < ncolumns; j++) {
794 ofsdst = j + k * ncolumns;
796 i = bytestream2_get_byte(&gb);
798 opcode = bytestream2_get_byte(&gb);
801 opcode = bytestream2_get_byte(&gb);
802 x = bytestream2_get_byte(&gb);
806 if (xor && ofsdst < dst_size) {
807 bytestream2_put_byte(&pb, dst[ofsdst] ^ x);
809 bytestream2_put_byte(&pb, x);
814 }
else if (opcode < 0x80) {
815 ofsdst += opcode * dstpitch;
821 if (xor && ofsdst < dst_size) {
822 bytestream2_put_byte(&pb, dst[ofsdst] ^ bytestream2_get_byte(&gb));
824 bytestream2_put_byte(&pb, bytestream2_get_byte(&gb));
838 int w,
int h,
int bpp,
int dst_size)
844 int planepitch_byte = (w + 7) / 8;
845 int planepitch = ((w + 15) / 16) * 2;
846 int kludge_j,
b,
g,
r, d;
849 pitch = planepitch * bpp;
850 kludge_j = w < 320 ? (320 - w) / 8 / 2 : 0;
855 type = bytestream2_get_be16(&gb);
861 flag = bytestream2_get_be16(&gb);
862 cols = bytestream2_get_be16(&gb);
863 groups = bytestream2_get_be16(&gb);
865 for (g = 0; g <
groups; g++) {
866 offset = bytestream2_get_be16(&gb);
872 offset = ((offset / (320 / 8)) * pitch) + (offset % (320 / 8)) - kludge_j;
874 offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte);
876 for (b = 0; b < cols; b++) {
877 for (d = 0; d < bpp; d++) {
880 if (offset >= dst_size)
889 offset += planepitch;
892 if ((cols * bpp) & 1)
897 flag = bytestream2_get_be16(&gb);
898 rows = bytestream2_get_be16(&gb);
899 bytes = bytestream2_get_be16(&gb);
900 groups = bytestream2_get_be16(&gb);
902 for (g = 0; g <
groups; g++) {
903 offset = bytestream2_get_be16(&gb);
906 offset = ((offset / (320 / 8)) * pitch) + (offset % (320/ 8)) - kludge_j;
908 offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte);
910 for (r = 0; r < rows; r++) {
911 for (d = 0; d < bpp; d++) {
912 unsigned noffset = offset + (r * pitch) + d * planepitch;
917 for (b = 0; b < bytes; b++) {
920 if (noffset >= dst_size)
933 if ((rows * bytes * bpp) & 1)
945 int w,
int bpp,
int dst_size)
947 int ncolumns = (w + 15) >> 4;
948 int dstpitch = ncolumns * bpp * 2;
949 unsigned ofsdst, ofssrc, ofsdata, opcode, x;
954 if (buf_end - buf <= 64)
961 for (k = 0; k < bpp; k++) {
962 ofssrc = bytestream2_get_be32(&ptrs);
963 ofsdata = bytestream2_get_be32(&dptrs);
968 if (ofssrc >= buf_end - buf)
971 if (ofsdata >= buf_end - buf)
976 for (j = 0; j < ncolumns; j++) {
977 ofsdst = (j + k * ncolumns) * 2;
979 i = bytestream2_get_byte(&gb);
981 opcode = bytestream2_get_byte(&gb);
984 opcode = bytestream2_get_byte(&gb);
985 x = bytestream2_get_be16(&dgb);
989 bytestream2_put_be16(&pb, x);
993 }
else if (opcode < 0x80) {
994 ofsdst += opcode * dstpitch;
1000 bytestream2_put_be16(&pb, bytestream2_get_be16(&dgb));
1013 int w,
int bpp,
int dst_size)
1015 int ncolumns = (w + 31) >> 5;
1016 int dstpitch = ((w + 15) / 16 * 2) * bpp;
1017 unsigned ofsdst, ofssrc, ofsdata, opcode, x;
1022 if (buf_end - buf <= 64)
1025 h = (((w + 15) / 16 * 2) != ((w + 31) / 32 * 4)) ? 1 : 0;
1030 for (k = 0; k < bpp; k++) {
1031 ofssrc = bytestream2_get_be32(&ptrs);
1032 ofsdata = bytestream2_get_be32(&dptrs);
1037 if (ofssrc >= buf_end - buf)
1040 if (ofsdata >= buf_end - buf)
1045 for (j = 0; j < ncolumns; j++) {
1046 ofsdst = (j + k * ncolumns) * 4 - h * (2 * k);
1048 i = bytestream2_get_byte(&gb);
1050 opcode = bytestream2_get_byte(&gb);
1053 opcode = bytestream2_get_byte(&gb);
1054 if (h && (j == (ncolumns - 1))) {
1055 x = bytestream2_get_be16(&dgb);
1058 x = bytestream2_get_be32(&dgb);
1063 if (h && (j == (ncolumns - 1))) {
1064 bytestream2_put_be16(&pb, x);
1066 bytestream2_put_be32(&pb, x);
1071 }
else if (opcode < 0x80) {
1072 ofsdst += opcode * dstpitch;
1078 if (h && (j == (ncolumns - 1))) {
1079 bytestream2_put_be16(&pb, bytestream2_get_be16(&dgb));
1082 bytestream2_put_be32(&pb, bytestream2_get_be32(&dgb));
1096 int w,
int bpp,
int dst_size)
1098 int ncolumns = (w + 15) >> 4;
1099 int dstpitch = ncolumns * bpp * 2;
1100 unsigned ofsdst, ofssrc, opcode, x;
1108 for (k = 0; k < bpp; k++) {
1109 ofssrc = bytestream2_get_be32(&ptrs);
1114 if (ofssrc >= buf_end - buf)
1118 for (j = 0; j < ncolumns; j++) {
1119 ofsdst = (j + k * ncolumns) * 2;
1121 i = bytestream2_get_be16(&gb);
1123 opcode = bytestream2_get_be16(&gb);
1126 opcode = bytestream2_get_be16(&gb);
1127 x = bytestream2_get_be16(&gb);
1131 bytestream2_put_be16(&pb, x);
1135 }
else if (opcode < 0x8000) {
1136 ofsdst += opcode * dstpitch;
1143 bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
1156 int w,
int bpp,
int dst_size)
1158 int ncolumns = (w + 31) >> 5;
1159 int dstpitch = ((w + 15) / 16 * 2) * bpp;
1160 unsigned ofsdst, ofssrc, opcode, x;
1161 unsigned skip = 0x80000000,
mask = skip - 1;
1166 h = (((w + 15) / 16 * 2) != ((w + 31) / 32 * 4)) ? 1 : 0;
1170 for (k = 0; k < bpp; k++) {
1171 ofssrc = bytestream2_get_be32(&ptrs);
1176 if (ofssrc >= buf_end - buf)
1180 for (j = 0; j < ncolumns; j++) {
1181 ofsdst = (j + k * ncolumns) * 4 - h * (2 * k);
1183 if (h && (j == (ncolumns - 1))) {
1188 i = bytestream2_get_be32(&gb);
1190 opcode = bytestream2_get_be32(&gb);
1193 if (h && (j == ncolumns - 1)) {
1194 opcode = bytestream2_get_be16(&gb);
1195 x = bytestream2_get_be16(&gb);
1197 opcode = bytestream2_get_be32(&gb);
1198 x = bytestream2_get_be32(&gb);
1203 if (h && (j == ncolumns - 1))
1204 bytestream2_put_be16(&pb, x);
1206 bytestream2_put_be32(&pb, x);
1210 }
else if (opcode < skip) {
1211 ofsdst += opcode * dstpitch;
1218 if (h && (j == ncolumns - 1)) {
1219 bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
1221 bytestream2_put_be32(&pb, bytestream2_get_be32(&gb));
1235 int w,
int flag,
int bpp,
int dst_size)
1237 int planepitch =
FFALIGN(w, 16) >> 3;
1238 int pitch = planepitch * bpp;
1239 int planepitch_byte = (w + 7) / 8;
1240 unsigned entries, ofssrc;
1245 if (buf_end - buf <= 4 * bpp)
1251 for (k = 0; k < bpp; k++) {
1252 ofssrc = bytestream2_get_be32(&ptrs);
1257 if (ofssrc >= buf_end - buf)
1262 entries = bytestream2_get_be32(&gb);
1264 int32_t opcode = bytestream2_get_be32(&gb);
1265 unsigned offset = bytestream2_get_be32(&gb);
1267 bytestream2_seek_p(&pb, (offset / planepitch_byte) * pitch + (offset % planepitch_byte) + k * planepitch, SEEK_SET);
1269 uint32_t x = bytestream2_get_be32(&gb);
1271 bytestream2_put_be32(&pb, x);
1278 bytestream2_put_be32(&pb, bytestream2_get_be32(&gb));
1290 int w,
int flag,
int bpp,
int dst_size)
1292 int planepitch =
FFALIGN(w, 16) >> 3;
1293 int pitch = planepitch * bpp;
1294 int planepitch_byte = (w + 7) / 8;
1295 unsigned entries, ofssrc;
1300 if (buf_end - buf <= 4 * bpp)
1306 for (k = 0; k < bpp; k++) {
1307 ofssrc = bytestream2_get_be32(&ptrs);
1312 if (ofssrc >= buf_end - buf)
1317 entries = bytestream2_get_be16(&gb);
1319 int16_t opcode = bytestream2_get_be16(&gb);
1320 unsigned offset = bytestream2_get_be32(&gb);
1322 bytestream2_seek_p(&pb, (offset / planepitch_byte) * pitch + (offset % planepitch_byte) + k * planepitch, SEEK_SET);
1324 uint16_t x = bytestream2_get_be16(&gb);
1326 bytestream2_put_be16(&pb, x);
1333 bytestream2_put_be16(&pb, bytestream2_get_be16(&gb));
1345 int w,
int flag,
int bpp,
int dst_size)
1349 unsigned poff0, poff1;
1351 int planepitch_byte = (w + 7) / 8;
1352 int planepitch = ((w + 15) / 16) * 2;
1353 int pitch = planepitch * bpp;
1355 if (buf_end - buf <= 64)
1362 dstpitch = flag ? (((w + 7) / 8) * bpp): 2;
1364 for (k = 0; k < bpp; k++) {
1365 poff0 = bytestream2_get_be32(&off0);
1366 poff1 = bytestream2_get_be32(&off1);
1371 if (2LL * poff0 >= buf_end - buf)
1374 if (2LL * poff1 >= buf_end - buf)
1381 uint32_t
offset = bytestream2_get_be16(&ogb);
1382 int16_t cnt = bytestream2_get_be16(&ogb);
1385 offset = ((2 *
offset) / planepitch_byte) * pitch + ((2 *
offset) % planepitch_byte) + k * planepitch;
1389 data = bytestream2_get_be16(&dgb);
1390 for (i = 0; i < cnt; i++) {
1391 bytestream2_put_be16(&pb, data);
1396 for (i = 0; i < cnt; i++) {
1397 data = bytestream2_get_be16(&dgb);
1398 bytestream2_put_be16(&pb, data);
1414 void *
data,
int *got_frame,
1420 int buf_size = avpkt->
size;
1421 const uint8_t *buf_end = buf + buf_size;
1460 for (plane = 0; plane < s->
bpp; plane++) {
1461 for (y = 0; y < avctx->
height && buf < buf_end; y++) {
1467 }
else if (s->
ham) {
1469 for (y = 0; y < avctx->
height; y++) {
1472 for (plane = 0; plane < s->
bpp; plane++) {
1474 if (start >= buf_end)
1485 for (y = 0; y < avctx->
height && buf < buf_end; y++) {
1487 memcpy(row, buf,
FFMIN(raw_width, buf_end - buf));
1490 for (x = 0; x < avctx->
width; x++)
1491 row[4 * x + 3] = row[4 * x + 3] & 0xF0 | (row[4 * x + 3] >> 4);
1499 for (y = 0; y < avctx->
height; y++) {
1501 memset(row, 0, avctx->
width);
1502 for (plane = 0; plane < s->
bpp && buf < buf_end; plane++) {
1507 }
else if (s->
ham) {
1508 for (y = 0; y < avctx->
height; y++) {
1511 for (plane = 0; plane < s->
bpp && buf < buf_end; plane++) {
1518 for (y = 0; y < avctx->
height; y++) {
1520 memset(row, 0, avctx->
width << 2);
1521 for (plane = 0; plane < s->
bpp && buf < buf_end; plane++) {
1530 for (y = 0; y < avctx->
height && buf_end >
buf; y++) {
1532 memcpy(row, buf,
FFMIN(avctx->
width, buf_end - buf));
1535 }
else if (s->
ham) {
1536 for (y = 0; y < avctx->
height && buf_end >
buf; y++) {
1552 for (y = 0; y < avctx->
height; y++) {
1554 memset(row, 0, avctx->
width);
1555 for (plane = 0; plane < s->
bpp; plane++) {
1565 for (y = 0; y < avctx->
height; y++) {
1568 for (plane = 0; plane < s->
bpp; plane++) {
1574 }
else if (s->
ham) {
1576 for (y = 0; y < avctx->
height; y++) {
1579 for (plane = 0; plane < s->
bpp; plane++) {
1590 for (y = 0; y < avctx->
height; y++) {
1592 memset(row, 0, avctx->
width << 2);
1593 for (plane = 0; plane < s->
bpp; plane++) {
1601 for (y = 0; y < avctx->
height; y++) {
1605 }
else if (s->
ham) {
1606 for (y = 0; y < avctx->
height; y++) {
1684 memcpy(s->
pal[1], s->
pal[0], 256 * 4);
1691 for (y = 0; y < avctx->
height; y++) {
1693 memset(row, 0, avctx->
width);
1694 for (plane = 0; plane < s->
bpp; plane++) {
1699 memcpy(frame->
data[1], s->
pal[0], 256 * 4);
1700 }
else if (s->
ham) {
1704 memset(s->
ham_palbuf, 0, (1 << s->
ham) * 2 *
sizeof(uint32_t));
1705 for (i = 0; i <
count; i++) {
1708 for (i = 0; i <
count; i++) {
1709 uint32_t
tmp = i << (8 - s->
ham);
1710 tmp |= tmp >> s->
ham;
1715 s->
ham_palbuf[(i+count*2)*2+1] = 0xFF000000 | tmp;
1716 s->
ham_palbuf[(i+count*3)*2+1] = 0xFF000000 | tmp << 8;
1719 for (i = 0; i < 8 * (1 << s->
ham); i++)
1722 for (y = 0; y < avctx->
height; y++) {
1725 for (plane = 0; plane < s->
bpp; plane++) {
1754 #if CONFIG_IFF_ILBM_DECODER
1755 AVCodec ff_iff_ilbm_decoder = {
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.
ptrdiff_t const GLvoid * data
uint32_t * mask_palbuf
masking palette table
#define AV_LOG_WARNING
Something somehow does not look correct.
unsigned masking
TODO: masking method used.
static av_cold int init(AVCodecContext *avctx)
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)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
#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_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
#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.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_RL24
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.
GLsizei GLboolean const GLfloat * value
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.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
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)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
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)
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
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 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
#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.