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",
47 avctx->
width - pixel_ptr, line);
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);
68 odd_pixel = stream_byte & 1;
69 rle_code = (stream_byte + 1) / 2;
70 extra_byte = rle_code & 0x01;
71 if (pixel_ptr + 2*rle_code - odd_pixel > avctx->
width ||
74 "MS RLE: frame/stream ptr just went out of bounds (copy)\n");
78 for (i = 0; i < rle_code; i++) {
79 if (pixel_ptr >= avctx->
width)
81 stream_byte = bytestream2_get_byteu(gb);
82 pic->
data[0][line * pic->
linesize[0] + pixel_ptr] = stream_byte >> 4;
84 if (i + 1 == rle_code && odd_pixel)
86 if (pixel_ptr >= avctx->
width)
88 pic->
data[0][line * pic->
linesize[0] + pixel_ptr] = stream_byte & 0x0F;
98 if (pixel_ptr + rle_code > avctx->
width + 1) {
100 "MS RLE: frame ptr just went out of bounds (run)\n");
103 stream_byte = bytestream2_get_byte(gb);
104 for (i = 0; i < rle_code; i++) {
105 if (pixel_ptr >= avctx->
width)
108 pic->
data[0][line * pic->
linesize[0] + pixel_ptr] = stream_byte >> 4;
110 pic->
data[0][line * pic->
linesize[0] + pixel_ptr] = stream_byte & 0x0F;
119 "MS RLE: ended frame decode with %d bytes left over\n",
141 p1 = bytestream2_get_byteu(gb);
143 p2 = bytestream2_get_byte(gb);
146 if (bytestream2_get_be16(gb) == 1) {
150 "Next line is beyond picture bounds (%d bytes left)\n",
162 p1 = bytestream2_get_byte(gb);
163 p2 = bytestream2_get_byte(gb);
170 output = pic->
data[0] + line * pic->
linesize[0] + pos * (depth >> 3);
175 if (output + p2 * (depth >> 3) > output_end) {
183 if ((depth == 8) || (depth == 24)) {
185 output += p2 * (depth >> 3);
188 if(depth == 8 && (p2 & 1)) {
191 }
else if (depth == 16) {
192 for(i = 0; i < p2; i++) {
193 *(uint16_t*)output = bytestream2_get_le16u(gb);
196 }
else if (depth == 32) {
197 for(i = 0; i < p2; i++) {
198 *(uint32_t*)output = bytestream2_get_le32u(gb);
205 if (output + p1 * (depth >> 3) > output_end)
210 pix[0] = bytestream2_get_byte(gb);
211 memset(output, pix[0], p1);
215 pix16 = bytestream2_get_le16(gb);
216 for(i = 0; i < p1; i++) {
217 *(uint16_t*)output = pix16;
222 pix[0] = bytestream2_get_byte(gb);
223 pix[1] = bytestream2_get_byte(gb);
224 pix[2] = bytestream2_get_byte(gb);
225 for(i = 0; i < p1; i++) {
232 pix32 = bytestream2_get_le32(gb);
233 for(i = 0; i < p1; i++) {
234 *(uint32_t*)output = pix32;
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
#define AV_LOG_WARNING
Something somehow does not look correct.
static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int depth, GetByteContext *gb)
static av_always_inline unsigned int bytestream2_get_bufferu(GetByteContext *g, uint8_t *dst, unsigned int size)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointers to the image data planes
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
Libavcodec external API header.
int width
picture width / height.
main external API structure.
int ff_msrle_decode(AVCodecContext *avctx, AVPicture *pic, int depth, GetByteContext *gb)
Decode stream in MS RLE format into frame.
static int msrle_decode_pal4(AVCodecContext *avctx, AVPicture *pic, GetByteContext *gb)