36 unsigned char rle_code;
37 unsigned char extra_byte, odd_pixel;
38 unsigned char stream_byte;
39 unsigned int pixel_ptr = 0;
41 int row_ptr = (avctx->
height - 1) * row_dec;
45 while (row_ptr >= 0) {
48 "MS RLE: bytestream overrun, %d rows left\n",
52 rle_code = stream_byte = bytestream2_get_byteu(gb);
55 stream_byte = bytestream2_get_byte(gb);
56 if (stream_byte == 0) {
60 }
else if (stream_byte == 1) {
63 }
else if (stream_byte == 2) {
65 stream_byte = bytestream2_get_byte(gb);
66 pixel_ptr += stream_byte;
67 stream_byte = bytestream2_get_byte(gb);
68 row_ptr -= stream_byte * row_dec;
71 odd_pixel = stream_byte & 1;
72 rle_code = (stream_byte + 1) / 2;
73 extra_byte = rle_code & 0x01;
74 if (row_ptr + pixel_ptr + stream_byte > frame_size ||
77 "MS RLE: frame/stream ptr just went out of bounds (copy)\n");
81 for (i = 0; i < rle_code; i++) {
82 if (pixel_ptr >= avctx->
width)
84 stream_byte = bytestream2_get_byteu(gb);
85 pic->
data[0][row_ptr + pixel_ptr] = stream_byte >> 4;
87 if (i + 1 == rle_code && odd_pixel)
89 if (pixel_ptr >= avctx->
width)
91 pic->
data[0][row_ptr + pixel_ptr] = stream_byte & 0x0F;
101 if (row_ptr + pixel_ptr + stream_byte > frame_size) {
103 "MS RLE: frame ptr just went out of bounds (run)\n");
106 stream_byte = bytestream2_get_byte(gb);
107 for (i = 0; i < rle_code; i++) {
108 if (pixel_ptr >= avctx->
width)
111 pic->
data[0][row_ptr + pixel_ptr] = stream_byte >> 4;
113 pic->
data[0][row_ptr + pixel_ptr] = stream_byte & 0x0F;
122 "MS RLE: ended frame decode with %d bytes left over\n",
144 p1 = bytestream2_get_byteu(gb);
146 p2 = bytestream2_get_byte(gb);
149 if (bytestream2_get_be16(gb) == 1) {
153 "Next line is beyond picture bounds (%d bytes left)\n",
165 p1 = bytestream2_get_byte(gb);
166 p2 = bytestream2_get_byte(gb);
173 output = pic->
data[0] + line * pic->
linesize[0] + pos * (depth >> 3);
178 if (output + p2 * (depth >> 3) > output_end) {
186 if ((depth == 8) || (depth == 24)) {
187 for(i = 0; i < p2 * (depth >> 3); i++) {
188 *output++ = bytestream2_get_byteu(gb);
191 if(depth == 8 && (p2 & 1)) {
194 }
else if (depth == 16) {
195 for(i = 0; i < p2; i++) {
196 *(uint16_t*)output = bytestream2_get_le16u(gb);
199 }
else if (depth == 32) {
200 for(i = 0; i < p2; i++) {
201 *(uint32_t*)output = bytestream2_get_le32u(gb);
208 if (output + p1 * (depth >> 3) > output_end)
213 pix[0] = bytestream2_get_byte(gb);
214 for(i = 0; i < p1; i++)
218 pix16 = bytestream2_get_le16(gb);
219 for(i = 0; i < p1; i++) {
220 *(uint16_t*)output = pix16;
225 pix[0] = bytestream2_get_byte(gb);
226 pix[1] = bytestream2_get_byte(gb);
227 pix[2] = bytestream2_get_byte(gb);
228 for(i = 0; i < p1; i++) {
235 pix32 = bytestream2_get_le32(gb);
236 for(i = 0; i < p1; i++) {
237 *(uint32_t*)output = pix32;