diff options
Diffstat (limited to 'ffmpeg/libavcodec/pictordec.c')
| -rw-r--r-- | ffmpeg/libavcodec/pictordec.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/ffmpeg/libavcodec/pictordec.c b/ffmpeg/libavcodec/pictordec.c index bf138b2..1bc51bc 100644 --- a/ffmpeg/libavcodec/pictordec.c +++ b/ffmpeg/libavcodec/pictordec.c @@ -140,10 +140,12 @@ static int decode_frame(AVCodecContext *avctx, avctx->pix_fmt = AV_PIX_FMT_PAL8; + if (av_image_check_size(s->width, s->height, 0, avctx) < 0) + return -1; if (s->width != avctx->width && s->height != avctx->height) { - if (av_image_check_size(s->width, s->height, 0, avctx) < 0) - return -1; - avcodec_set_dimensions(avctx, s->width, s->height); + ret = ff_set_dimensions(avctx, s->width, s->height); + if (ret < 0) + return ret; } if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) @@ -201,7 +203,7 @@ static int decode_frame(AVCodecContext *avctx, if (bytestream2_get_le16(&s->g)) { x = 0; plane = 0; - while (y >= 0 && bytestream2_get_bytes_left(&s->g) >= 6) { + while (bytestream2_get_bytes_left(&s->g) >= 6) { int stop_size, marker, t1, t2; t1 = bytestream2_get_bytes_left(&s->g); @@ -211,7 +213,7 @@ static int decode_frame(AVCodecContext *avctx, bytestream2_skip(&s->g, 2); marker = bytestream2_get_byte(&s->g); - while (plane < s->nb_planes && y >= 0 && + while (plane < s->nb_planes && bytestream2_get_bytes_left(&s->g) > stop_size) { int run = 1; val = bytestream2_get_byte(&s->g); @@ -226,13 +228,15 @@ static int decode_frame(AVCodecContext *avctx, if (bits_per_plane == 8) { picmemset_8bpp(s, frame, val, run, &x, &y); + if (y < 0) + goto finish; } else { picmemset(s, frame, val, run, &x, &y, &plane, bits_per_plane); } } } - if (x < avctx->width && y >= 0) { + if (x < avctx->width) { int run = (y + 1) * avctx->width - x; if (bits_per_plane == 8) picmemset_8bpp(s, frame, val, run, &x, &y); @@ -246,6 +250,7 @@ static int decode_frame(AVCodecContext *avctx, y--; } } +finish: *got_frame = 1; return avpkt->size; @@ -253,10 +258,10 @@ static int decode_frame(AVCodecContext *avctx, AVCodec ff_pictor_decoder = { .name = "pictor", + .long_name = NULL_IF_CONFIG_SMALL("Pictor/PC Paint"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_PICTOR, .priv_data_size = sizeof(PicContext), .decode = decode_frame, .capabilities = CODEC_CAP_DR1, - .long_name = NULL_IF_CONFIG_SMALL("Pictor/PC Paint"), }; |
