#define PCX_HEADER_SIZE 128
-static void pcx_rle_decode(GetByteContext *gb,
+static int pcx_rle_decode(GetByteContext *gb,
uint8_t *dst,
unsigned int bytes_per_scanline,
int compressed)
unsigned int i = 0;
unsigned char run, value;
+ if (bytestream2_get_bytes_left(gb) < 1)
+ return AVERROR_INVALIDDATA;
+
if (compressed) {
while (i < bytes_per_scanline && bytestream2_get_bytes_left(gb)>0) {
run = 1;
} else {
bytestream2_get_buffer(gb, dst, bytes_per_scanline);
}
+ return 0;
}
static void pcx_palette(GetByteContext *gb, uint32_t *dst, int pallen)
if (nplanes == 3 && bits_per_pixel == 8) {
for (y = 0; y < h; y++) {
- pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
+ ret = pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
+ if (ret < 0)
+ goto end;
for (x = 0; x < w; x++) {
ptr[3 * x] = scanline[x];
}
for (y = 0; y < h; y++, ptr += stride) {
- pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
+ ret = pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
+ if (ret < 0)
+ goto end;
memcpy(ptr, scanline, w);
}
for (y = 0; y < h; y++) {
init_get_bits8(&s, scanline, bytes_per_scanline);
- pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
+ ret = pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
+ if (ret < 0)
+ goto end;
for (x = 0; x < w; x++)
ptr[x] = get_bits(&s, bits_per_pixel);
int i;
for (y = 0; y < h; y++) {
- pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
+ ret = pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
+ if (ret < 0)
+ goto end;
for (x = 0; x < w; x++) {
int m = 0x80 >> (x & 7), v = 0;
return ret;
}
-AVCodec ff_pcx_decoder = {
+const AVCodec ff_pcx_decoder = {
.name = "pcx",
.long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"),
.type = AVMEDIA_TYPE_VIDEO,