32 #define HNM4_CHUNK_ID_PL 19536
33 #define HNM4_CHUNK_ID_IZ 23113
34 #define HNM4_CHUNK_ID_IU 21833
35 #define HNM4_CHUNK_ID_SD 17491
54 *bitbuf = bytestream2_get_le32(gb);
70 uint32_t bitbuf = 0, writeoffset = 0,
count = 0;
78 if (
getbit(&gb, &bitbuf, &bits)) {
81 "Attempting to write out of bounds\n");
84 hnm->
current[writeoffset++] = bytestream2_get_byte(&gb);
86 if (
getbit(&gb, &bitbuf, &bits)) {
87 word = bytestream2_get_le16(&gb);
89 offset = (word >> 3) - 0x2000;
91 count = bytestream2_get_byte(&gb);
97 offset = bytestream2_get_byte(&gb) - 0x0100;
100 offset += writeoffset;
101 if (offset < 0 || offset + count >= hnm->
width * hnm->
height) {
106 "Attempting to write out of bounds\n");
119 uint32_t x,
y, src_x, src_y;
121 for (y = 0; y < hnm->
height; y++) {
123 src_x = src_y * hnm->
width + (y % 2);
124 for (x = 0; x < hnm->
width; x++) {
138 for (y = 0; y < hnm->
height; y++) {
139 memcpy(dst, src, hnm->
width);
149 uint32_t writeoffset = 0;
151 uint8_t tag, previous, backline, backward, swap;
156 count = bytestream2_peek_byte(&gb) & 0x1F;
158 tag = bytestream2_get_byte(&gb) & 0xE0;
166 hnm->
current[writeoffset++] = bytestream2_get_byte(&gb);
167 hnm->
current[writeoffset++] = bytestream2_get_byte(&gb);
168 }
else if (tag == 1) {
169 writeoffset += bytestream2_get_byte(&gb) * 2;
170 }
else if (tag == 2) {
171 count = bytestream2_get_le16(&gb);
173 writeoffset +=
count;
174 }
else if (tag == 3) {
175 count = bytestream2_get_byte(&gb) * 2;
176 if (writeoffset + count > hnm->
width * hnm->
height) {
181 hnm->
current[writeoffset++] = bytestream2_peek_byte(&gb);
193 previous = bytestream2_peek_byte(&gb) & 0x20;
194 backline = bytestream2_peek_byte(&gb) & 0x40;
195 backward = bytestream2_peek_byte(&gb) & 0x80;
197 swap = bytestream2_peek_byte(&gb) & 0x01;
198 offset = bytestream2_get_le16(&gb);
199 offset = (offset >> 1) & 0x7FFF;
200 offset = writeoffset + (offset * 2) - 0x8000;
204 if (!backward && offset + 2*count > hnm->
width * hnm->
height) {
207 }
else if (backward && offset + 1 >= hnm->
width * hnm->
height) {
210 }
else if (writeoffset + 2*count > hnm->
width * hnm->
height) {
212 "Attempting to write out of bounds\n");
216 if (offset < (!!backline)*(2 * hnm->
width - 1) + 2*(left-1)) {
221 if (offset < (!!backline)*(2 * hnm->
width - 1)) {
259 writeoffset -= count * 2;
261 swap = hnm->
current[writeoffset];
263 hnm->
current[writeoffset + 1] = swap;
277 uint32_t writeoffset = 0,
offset;
283 count = bytestream2_peek_byte(&gb) & 0x3F;
285 tag = bytestream2_get_byte(&gb) & 0xC0;
288 writeoffset += bytestream2_get_byte(&gb);
289 }
else if (tag == 1) {
294 hnm->
current[writeoffset] = bytestream2_get_byte(&gb);
295 hnm->
current[writeoffset + hnm->
width] = bytestream2_get_byte(&gb);
297 }
else if (tag == 2) {
298 writeoffset += hnm->
width;
299 }
else if (tag == 3) {
307 delta = bytestream2_peek_byte(&gb) & 0x80;
308 previous = bytestream2_peek_byte(&gb) & 0x40;
312 offset += bytestream2_get_le16(&gb);
358 int eight_bit_colors;
360 eight_bit_colors = src[7] & 0x80 && hnm->
version == 0x4a;
366 start = bytestream2_get_byte(&gb);
367 count = bytestream2_get_byte(&gb);
368 if (start == 255 && count == 255)
374 hnm->
palette[writeoffset] = bytestream2_get_be24(&gb);
375 if (!eight_bit_colors)
376 hnm->
palette[writeoffset] <<= 2;
400 if (avpkt->
size < 8) {
410 if (avpkt->
size < 12) {
459 "Extradata missing, decoder requires version number\n");