X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fpcx.c;h=bbca8bce7ad97cadb4be82acfaa900275964d65f;hb=b3507d398b703ed8f06d8608f254c3937a7a42b0;hp=785f715b54bc019d63bfdb410eaec3ed1138cfd2;hpb=bcdb2378f77daa2e7cf21039bb6247c197af8e0c;p=ffmpeg diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c index 785f715b54b..bbca8bce7ad 100644 --- a/libavcodec/pcx.c +++ b/libavcodec/pcx.c @@ -24,7 +24,7 @@ #include "avcodec.h" #include "bytestream.h" -#include "bitstream.h" +#include "get_bits.h" typedef struct PCXContext { AVFrame picture; @@ -42,20 +42,25 @@ static av_cold int pcx_init(AVCodecContext *avctx) { /** * @return advanced src pointer */ -static const char *pcx_rle_decode(const uint8_t *src, uint8_t *dst, - unsigned int bytes_per_scanline) { +static const uint8_t *pcx_rle_decode(const uint8_t *src, uint8_t *dst, + unsigned int bytes_per_scanline, int compressed) { unsigned int i = 0; unsigned char run, value; - while (i= 0xc0) { - run = value & 0x3f; + if (compressed) { + while (i= 0xc0) { + run = value & 0x3f; + value = *src++; + } + while (idata; + int buf_size = avpkt->size; PCXContext * const s = avctx->priv_data; AVFrame *picture = data; AVFrame * const p = &s->picture; - int xmin, ymin, xmax, ymax; + int compressed, xmin, ymin, xmax, ymax; unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes, stride, y, x, bytes_per_scanline; uint8_t *ptr; uint8_t const *bufstart = buf; - if (buf[0] != 0x0a || buf[1] > 5 || buf[1] == 1 || buf[2] != 1) { + if (buf[0] != 0x0a || buf[1] > 5) { av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n"); return -1; } + compressed = buf[2]; xmin = AV_RL16(buf+ 4); ymin = AV_RL16(buf+ 6); xmax = AV_RL16(buf+ 8); @@ -149,7 +158,7 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t scanline[bytes_per_scanline]; for (y=0; y> (x&7), v = 0; @@ -242,7 +251,7 @@ AVCodec pcx_decoder = { NULL, pcx_end, pcx_decode_frame, - 0, + CODEC_CAP_DR1, NULL, - .long_name = "PC Paintbrush PCX image", + .long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"), };