+ int rle_code;
+ int pixel_ptr = 0;
+ int row_inc = s->frame.linesize[0];
+ unsigned char pi0, pi1; /* 2 8-pixel values */
+ unsigned char *rgb = s->frame.data[0];
+ int pixel_limit = s->frame.linesize[0] * s->avctx->height;
+ int skip;
+
+ while (lines_to_change) {
+ skip = bytestream2_get_byte(&s->g);
+ rle_code = (signed char)bytestream2_get_byte(&s->g);
+ if (rle_code == 0)
+ break;
+ if(skip & 0x80) {
+ lines_to_change--;
+ row_ptr += row_inc;
+ pixel_ptr = row_ptr + 2 * (skip & 0x7f);
+ } else
+ pixel_ptr += 2 * skip;
+ CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
+
+ if (rle_code < 0) {
+ /* decode the run length code */
+ rle_code = -rle_code;
+ /* get the next 2 bytes from the stream, treat them as groups
+ * of 8 pixels, and output them rle_code times */
+
+ pi0 = bytestream2_get_byte(&s->g);
+ pi1 = bytestream2_get_byte(&s->g);
+ CHECK_PIXEL_PTR(rle_code * 2);
+
+ while (rle_code--) {
+ rgb[pixel_ptr++] = pi0;
+ rgb[pixel_ptr++] = pi1;
+ }
+ } else {
+ /* copy the same pixel directly to output 2 times */
+ rle_code *= 2;
+ CHECK_PIXEL_PTR(rle_code);