]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/pcx.c
h264_mvpred: constify all uses of H264Context
[ffmpeg] / libavcodec / pcx.c
index 05a8f7c3fb35ec9722b7a98a7d634358fccc672b..61c971e073f2e400dba95482c9862f2e344de284 100644 (file)
@@ -109,7 +109,7 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     nplanes            = buf[65];
     bytes_per_scanline = nplanes * bytes_per_line;
 
-    if (bytes_per_scanline < w * bits_per_pixel * nplanes / 8 ||
+    if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8 ||
         (!compressed && bytes_per_scanline > buf_size / h)) {
         av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");
         return AVERROR_INVALIDDATA;
@@ -135,10 +135,9 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
 
     buf += 128;
 
-    if ((ret = av_image_check_size(w, h, 0, avctx)) < 0)
+    if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
         return ret;
-    if (w != avctx->width || h != avctx->height)
-        avcodec_set_dimensions(avctx, w, h);
+
     if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return ret;
@@ -241,9 +240,9 @@ end:
 
 AVCodec ff_pcx_decoder = {
     .name         = "pcx",
+    .long_name    = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"),
     .type         = AVMEDIA_TYPE_VIDEO,
     .id           = AV_CODEC_ID_PCX,
     .decode       = pcx_decode_frame,
     .capabilities = CODEC_CAP_DR1,
-    .long_name    = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"),
 };