50 #define CHECK_PIXEL_PTR(n) \
51 if ((pixel_ptr + n > pixel_limit) || (pixel_ptr + n < 0)) { \
52 av_log (s->avctx, AV_LOG_ERROR, "Problem: pixel_ptr = %d, pixel_limit = %d\n",\
53 pixel_ptr + n, pixel_limit); \
61 int row_inc =
s->frame->linesize[0];
64 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
78 while (lines_to_change) {
79 skip = bytestream2_get_byte(&
s->g);
80 rle_code = (int8_t)bytestream2_get_byte(&
s->g);
86 pixel_ptr = row_ptr + 2 * 8 * (skip & 0x7f);
88 pixel_ptr += 2 * 8 * skip;
100 pi0 = bytestream2_get_byte(&
s->g);
101 pi1 = bytestream2_get_byte(&
s->g);
105 rgb[pixel_ptr++] = (pi0 >> 7) & 0x01;
106 rgb[pixel_ptr++] = (pi0 >> 6) & 0x01;
107 rgb[pixel_ptr++] = (pi0 >> 5) & 0x01;
108 rgb[pixel_ptr++] = (pi0 >> 4) & 0x01;
109 rgb[pixel_ptr++] = (pi0 >> 3) & 0x01;
110 rgb[pixel_ptr++] = (pi0 >> 2) & 0x01;
111 rgb[pixel_ptr++] = (pi0 >> 1) & 0x01;
112 rgb[pixel_ptr++] = pi0 & 0x01;
113 rgb[pixel_ptr++] = (pi1 >> 7) & 0x01;
114 rgb[pixel_ptr++] = (pi1 >> 6) & 0x01;
115 rgb[pixel_ptr++] = (pi1 >> 5) & 0x01;
116 rgb[pixel_ptr++] = (pi1 >> 4) & 0x01;
117 rgb[pixel_ptr++] = (pi1 >> 3) & 0x01;
118 rgb[pixel_ptr++] = (pi1 >> 2) & 0x01;
119 rgb[pixel_ptr++] = (pi1 >> 1) & 0x01;
120 rgb[pixel_ptr++] = pi1 & 0x01;
128 int x = bytestream2_get_byte(&
s->g);
129 rgb[pixel_ptr++] = (x >> 7) & 0x01;
130 rgb[pixel_ptr++] = (x >> 6) & 0x01;
131 rgb[pixel_ptr++] = (x >> 5) & 0x01;
132 rgb[pixel_ptr++] = (x >> 4) & 0x01;
133 rgb[pixel_ptr++] = (x >> 3) & 0x01;
134 rgb[pixel_ptr++] = (x >> 2) & 0x01;
135 rgb[pixel_ptr++] = (x >> 1) & 0x01;
136 rgb[pixel_ptr++] = x & 0x01;
143 int lines_to_change,
int bpp)
147 int row_inc =
s->frame->linesize[0];
150 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
151 int num_pixels = (bpp == 4) ? 8 : 16;
153 while (lines_to_change--) {
154 pixel_ptr = row_ptr + (num_pixels * (bytestream2_get_byte(&
s->g) - 1));
157 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
162 pixel_ptr += (num_pixels * (bytestream2_get_byte(&
s->g) - 1));
164 }
else if (rle_code < 0) {
166 rle_code = -rle_code;
169 for (
i = num_pixels-1;
i >= 0;
i--) {
170 pi[num_pixels-1-
i] = (bytestream2_peek_byte(&
s->g) >> ((
i*bpp) & 0x07)) & ((1<<bpp)-1);
175 memcpy(&rgb[pixel_ptr], &pi, num_pixels);
176 pixel_ptr += num_pixels;
184 int x = bytestream2_get_byte(&
s->g);
185 rgb[pixel_ptr++] = (x >> 4) & 0x0f;
186 rgb[pixel_ptr++] = x & 0x0f;
188 int x = bytestream2_get_byte(&
s->g);
189 rgb[pixel_ptr++] = (x >> 6) & 0x03;
190 rgb[pixel_ptr++] = (x >> 4) & 0x03;
191 rgb[pixel_ptr++] = (x >> 2) & 0x03;
192 rgb[pixel_ptr++] = x & 0x03;
205 int row_inc =
s->frame->linesize[0];
208 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
210 while (lines_to_change--) {
211 pixel_ptr = row_ptr + (4 * (bytestream2_get_byte(&
s->g) - 1));
214 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
219 pixel_ptr += (4 * (bytestream2_get_byte(&
s->g) - 1));
221 }
else if (rle_code < 0) {
223 rle_code = -rle_code;
226 pi1 = bytestream2_get_byte(&
s->g);
227 pi2 = bytestream2_get_byte(&
s->g);
228 pi3 = bytestream2_get_byte(&
s->g);
229 pi4 = bytestream2_get_byte(&
s->g);
234 rgb[pixel_ptr++] = pi1;
235 rgb[pixel_ptr++] = pi2;
236 rgb[pixel_ptr++] = pi3;
237 rgb[pixel_ptr++] = pi4;
245 pixel_ptr += rle_code;
256 int row_inc =
s->frame->linesize[0];
259 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
261 while (lines_to_change--) {
262 pixel_ptr = row_ptr + (bytestream2_get_byte(&
s->g) - 1) * 2;
265 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
270 pixel_ptr += (bytestream2_get_byte(&
s->g) - 1) * 2;
272 }
else if (rle_code < 0) {
274 rle_code = -rle_code;
275 rgb16 = bytestream2_get_be16(&
s->g);
280 *(uint16_t *)(&rgb[pixel_ptr]) = rgb16;
288 rgb16 = bytestream2_get_be16(&
s->g);
289 *(uint16_t *)(&rgb[pixel_ptr]) = rgb16;
300 int rle_code, rle_code_half;
302 int row_inc =
s->frame->linesize[0];
306 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
308 while (lines_to_change--) {
309 pixel_ptr = row_ptr + (bytestream2_get_byte(&
s->g) - 1) * 3;
312 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
317 pixel_ptr += (bytestream2_get_byte(&
s->g) - 1) * 3;
319 }
else if (rle_code < 0) {
321 rle_code = -rle_code;
323 b = bytestream2_get_byte(&
s->g);
329 rgb[pixel_ptr + 2] =
b;
335 rle_code_half = rle_code / 2;
337 while (rle_code_half--) {
343 if (rle_code % 2 != 0){
345 rgb[pixel_ptr + 2] = bytestream2_get_byte(&
s->g);
356 int rle_code, rle_code_half;
358 int row_inc =
s->frame->linesize[0];
361 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
363 while (lines_to_change--) {
364 pixel_ptr = row_ptr + (bytestream2_get_byte(&
s->g) - 1) * 4;
367 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
372 pixel_ptr += (bytestream2_get_byte(&
s->g) - 1) * 4;
374 }
else if (rle_code < 0) {
376 rle_code = -rle_code;
389 rle_code_half = rle_code / 2;
390 while (rle_code_half--) {
395 if (rle_code % 2 != 0){
448 void *
data,
int *got_frame,
464 size = bytestream2_get_be32(&
s->g) & 0x3FFFFFFF;
470 header = bytestream2_get_be16(&
s->g);
474 if (avpkt->
size < 14)
476 start_line = bytestream2_get_be16(&
s->g);
478 height = bytestream2_get_be16(&
s->g);
480 if (
height >
s->avctx->height - start_line)
489 row_ptr =
s->frame->linesize[0] * start_line;
539 s->frame->palette_has_changed = 1;