36 unsigned char rle_code;
37 unsigned char extra_byte, odd_pixel;
38 unsigned char stream_byte;
43 while (
line >= 0 && pixel_ptr <= avctx->
width) {
46 "MS RLE: bytestream overrun, %dx%d left\n",
50 rle_code = stream_byte = bytestream2_get_byteu(gb);
53 stream_byte = bytestream2_get_byte(gb);
54 if (stream_byte == 0) {
58 }
else if (stream_byte == 1) {
61 }
else if (stream_byte == 2) {
63 stream_byte = bytestream2_get_byte(gb);
64 pixel_ptr += stream_byte;
65 stream_byte = bytestream2_get_byte(gb);
69 odd_pixel = stream_byte & 1;
70 rle_code = (stream_byte + 1) / 2;
71 extra_byte = rle_code & 0x01;
72 if (pixel_ptr + 2*rle_code - odd_pixel > avctx->
width ||
75 "MS RLE: frame/stream ptr just went out of bounds (copy)\n");
79 for (
i = 0;
i < rle_code;
i++) {
80 if (pixel_ptr >= avctx->
width)
82 stream_byte = bytestream2_get_byteu(gb);
85 if (
i + 1 == rle_code && odd_pixel)
87 if (pixel_ptr >= avctx->
width)
99 if (pixel_ptr + rle_code > avctx->
width + 1) {
101 "MS RLE: frame ptr just went out of bounds (run) %d %d %d\n", pixel_ptr, rle_code, avctx->
width);
104 stream_byte = bytestream2_get_byte(gb);
105 for (
i = 0;
i < rle_code;
i++) {
106 if (pixel_ptr >= avctx->
width)
120 "MS RLE: ended frame decode with %d bytes left over\n",
142 p1 = bytestream2_get_byteu(gb);
144 p2 = bytestream2_get_byte(gb);
147 if (bytestream2_get_be16(gb) == 1) {
151 "Next line is beyond picture bounds (%d bytes left)\n",
163 p1 = bytestream2_get_byte(gb);
164 p2 = bytestream2_get_byte(gb);
176 if (
output + p2 * (depth >> 3) > output_end) {
184 if ((depth == 8) || (depth == 24)) {
186 output += p2 * (depth >> 3);
189 if(depth == 8 && (p2 & 1)) {
192 }
else if (depth == 16) {
193 for(
i = 0;
i < p2;
i++) {
194 *(uint16_t*)
output = bytestream2_get_le16u(gb);
197 }
else if (depth == 32) {
198 for(
i = 0;
i < p2;
i++) {
199 *(uint32_t*)
output = bytestream2_get_le32u(gb);
206 if (
output + p1 * (depth >> 3) > output_end)
211 pix[0] = bytestream2_get_byte(gb);
212 memset(
output, pix[0], p1);
216 pix16 = bytestream2_get_le16(gb);
217 for(
i = 0;
i < p1;
i++) {
218 *(uint16_t*)
output = pix16;
223 pix[0] = bytestream2_get_byte(gb);
224 pix[1] = bytestream2_get_byte(gb);
225 pix[2] = bytestream2_get_byte(gb);
226 for(
i = 0;
i < p1;
i++) {
233 pix32 = bytestream2_get_le32(gb);
234 for(
i = 0;
i < p1;
i++) {
235 *(uint32_t*)
output = pix32;