51 #define CHECK_PIXEL_PTR(n) \
52 if ((pixel_ptr + n > pixel_limit) || (pixel_ptr + n < 0)) { \
53 av_log (s->avctx, AV_LOG_ERROR, "Problem: pixel_ptr = %d, pixel_limit = %d\n",\
54 pixel_ptr + n, pixel_limit); \
62 int row_inc =
s->frame->linesize[0];
65 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
79 while (lines_to_change) {
80 skip = bytestream2_get_byte(&
s->g);
81 rle_code = (int8_t)bytestream2_get_byte(&
s->g);
87 pixel_ptr = row_ptr + 2 * 8 * (skip & 0x7f);
89 pixel_ptr += 2 * 8 * skip;
101 pi0 = bytestream2_get_byte(&
s->g);
102 pi1 = bytestream2_get_byte(&
s->g);
106 rgb[pixel_ptr++] = (pi0 >> 7) & 0x01;
107 rgb[pixel_ptr++] = (pi0 >> 6) & 0x01;
108 rgb[pixel_ptr++] = (pi0 >> 5) & 0x01;
109 rgb[pixel_ptr++] = (pi0 >> 4) & 0x01;
110 rgb[pixel_ptr++] = (pi0 >> 3) & 0x01;
111 rgb[pixel_ptr++] = (pi0 >> 2) & 0x01;
112 rgb[pixel_ptr++] = (pi0 >> 1) & 0x01;
113 rgb[pixel_ptr++] = pi0 & 0x01;
114 rgb[pixel_ptr++] = (pi1 >> 7) & 0x01;
115 rgb[pixel_ptr++] = (pi1 >> 6) & 0x01;
116 rgb[pixel_ptr++] = (pi1 >> 5) & 0x01;
117 rgb[pixel_ptr++] = (pi1 >> 4) & 0x01;
118 rgb[pixel_ptr++] = (pi1 >> 3) & 0x01;
119 rgb[pixel_ptr++] = (pi1 >> 2) & 0x01;
120 rgb[pixel_ptr++] = (pi1 >> 1) & 0x01;
121 rgb[pixel_ptr++] = pi1 & 0x01;
129 int x = bytestream2_get_byte(&
s->g);
130 rgb[pixel_ptr++] = (x >> 7) & 0x01;
131 rgb[pixel_ptr++] = (x >> 6) & 0x01;
132 rgb[pixel_ptr++] = (x >> 5) & 0x01;
133 rgb[pixel_ptr++] = (x >> 4) & 0x01;
134 rgb[pixel_ptr++] = (x >> 3) & 0x01;
135 rgb[pixel_ptr++] = (x >> 2) & 0x01;
136 rgb[pixel_ptr++] = (x >> 1) & 0x01;
137 rgb[pixel_ptr++] = x & 0x01;
144 int lines_to_change,
int bpp)
148 int row_inc =
s->frame->linesize[0];
151 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
152 int num_pixels = (bpp == 4) ? 8 : 16;
154 while (lines_to_change--) {
155 pixel_ptr = row_ptr + (num_pixels * (bytestream2_get_byte(&
s->g) - 1));
158 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
163 pixel_ptr += (num_pixels * (bytestream2_get_byte(&
s->g) - 1));
165 }
else if (rle_code < 0) {
167 rle_code = -rle_code;
170 for (
i = num_pixels-1;
i >= 0;
i--) {
171 pi[num_pixels-1-
i] = (bytestream2_peek_byte(&
s->g) >> ((
i*bpp) & 0x07)) & ((1<<bpp)-1);
176 memcpy(&
rgb[pixel_ptr], &pi, num_pixels);
177 pixel_ptr += num_pixels;
185 int x = bytestream2_get_byte(&
s->g);
186 rgb[pixel_ptr++] = (x >> 4) & 0x0f;
187 rgb[pixel_ptr++] = x & 0x0f;
189 int x = bytestream2_get_byte(&
s->g);
190 rgb[pixel_ptr++] = (x >> 6) & 0x03;
191 rgb[pixel_ptr++] = (x >> 4) & 0x03;
192 rgb[pixel_ptr++] = (x >> 2) & 0x03;
193 rgb[pixel_ptr++] = x & 0x03;
206 int row_inc =
s->frame->linesize[0];
209 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
211 while (lines_to_change--) {
212 pixel_ptr = row_ptr + (4 * (bytestream2_get_byte(&
s->g) - 1));
215 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
220 pixel_ptr += (4 * (bytestream2_get_byte(&
s->g) - 1));
222 }
else if (rle_code < 0) {
224 rle_code = -rle_code;
227 pi1 = bytestream2_get_byte(&
s->g);
228 pi2 = bytestream2_get_byte(&
s->g);
229 pi3 = bytestream2_get_byte(&
s->g);
230 pi4 = bytestream2_get_byte(&
s->g);
235 rgb[pixel_ptr++] = pi1;
236 rgb[pixel_ptr++] = pi2;
237 rgb[pixel_ptr++] = pi3;
238 rgb[pixel_ptr++] = pi4;
246 pixel_ptr += rle_code;
257 int row_inc =
s->frame->linesize[0];
260 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
262 while (lines_to_change--) {
263 pixel_ptr = row_ptr + (bytestream2_get_byte(&
s->g) - 1) * 2;
266 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
271 pixel_ptr += (bytestream2_get_byte(&
s->g) - 1) * 2;
273 }
else if (rle_code < 0) {
275 rle_code = -rle_code;
276 rgb16 = bytestream2_get_be16(&
s->g);
281 *(uint16_t *)(&
rgb[pixel_ptr]) = rgb16;
289 rgb16 = bytestream2_get_be16(&
s->g);
290 *(uint16_t *)(&
rgb[pixel_ptr]) = rgb16;
301 int rle_code, rle_code_half;
303 int row_inc =
s->frame->linesize[0];
307 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
309 while (lines_to_change--) {
310 pixel_ptr = row_ptr + (bytestream2_get_byte(&
s->g) - 1) * 3;
313 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
318 pixel_ptr += (bytestream2_get_byte(&
s->g) - 1) * 3;
320 }
else if (rle_code < 0) {
322 rle_code = -rle_code;
324 b = bytestream2_get_byte(&
s->g);
330 rgb[pixel_ptr + 2] =
b;
336 rle_code_half = rle_code / 2;
338 while (rle_code_half--) {
344 if (rle_code % 2 != 0){
346 rgb[pixel_ptr + 2] = bytestream2_get_byte(&
s->g);
357 int rle_code, rle_code_half;
359 int row_inc =
s->frame->linesize[0];
362 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
364 while (lines_to_change--) {
365 pixel_ptr = row_ptr + (bytestream2_get_byte(&
s->g) - 1) * 4;
368 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
373 pixel_ptr += (bytestream2_get_byte(&
s->g) - 1) * 4;
375 }
else if (rle_code < 0) {
377 rle_code = -rle_code;
390 rle_code_half = rle_code / 2;
391 while (rle_code_half--) {
396 if (rle_code % 2 != 0){
449 void *
data,
int *got_frame,
462 if (avpkt->
size < 8) {
468 size = bytestream2_get_be32(&
s->g) & 0x3FFFFFFF;
474 header = bytestream2_get_be16(&
s->g);
478 if (avpkt->
size < 14) {
482 start_line = bytestream2_get_be16(&
s->g);
484 height = bytestream2_get_be16(&
s->g);
486 if (
height >
s->avctx->height - start_line) {
497 row_ptr =
s->frame->linesize[0] * start_line;
547 s->frame->palette_has_changed = 1;
558 if (!
s->frame->data[0])