X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fpgxdec.c;h=1d659e82c2c8f883487436463db454223d49918a;hb=1c7f252783aec37e4ff8049476386f63afe91756;hp=a72d6fe6fe57a02098059c5295dbe8b105aabc25;hpb=8821df6fcfc0a3b75c7079617f5917c031d0a63c;p=ffmpeg diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c index a72d6fe6fe5..1d659e82c2c 100644 --- a/libavcodec/pgxdec.c +++ b/libavcodec/pgxdec.c @@ -95,14 +95,14 @@ error: } #define WRITE_FRAME(D, PIXEL, suffix) \ - static inline void write_frame_ ##D(AVPacket *avpkt, AVFrame *frame, GetByteContext *g, \ + static inline void write_frame_ ##D(AVFrame *frame, GetByteContext *g, \ int width, int height, int sign, int depth) \ { \ int i, j; \ for (i = 0; i < height; i++) { \ PIXEL *line = (PIXEL*)frame->data[0] + i*frame->linesize[0]/sizeof(PIXEL); \ for (j = 0; j < width; j++) { \ - int val; \ + unsigned val; \ if (sign) \ val = (PIXEL)bytestream2_get_ ##suffix(g) + (1 << (depth - 1)); \ else \ @@ -133,14 +133,14 @@ static int pgx_decode_frame(AVCodecContext *avctx, void *data, if ((ret = ff_set_dimensions(avctx, width, height)) < 0) return ret; - if (depth <= 8) { + if (depth > 0 && depth <= 8) { avctx->pix_fmt = AV_PIX_FMT_GRAY8; bpp = 8; - } else if (depth <= 16) { + } else if (depth > 0 && depth <= 16) { avctx->pix_fmt = AV_PIX_FMT_GRAY16; bpp = 16; } else { - av_log(avctx, AV_LOG_ERROR, "Maximum depth of 16 bits supported.\n"); + av_log(avctx, AV_LOG_ERROR, "depth %d is invalid or unsupported.\n", depth); return AVERROR_PATCHWELCOME; } if (bytestream2_get_bytes_left(&g) < width * height * (bpp >> 3)) @@ -151,14 +151,14 @@ static int pgx_decode_frame(AVCodecContext *avctx, void *data, p->key_frame = 1; avctx->bits_per_raw_sample = depth; if (bpp == 8) - write_frame_8(avpkt, p, &g, width, height, sign, depth); + write_frame_8(p, &g, width, height, sign, depth); else if (bpp == 16) - write_frame_16(avpkt, p, &g, width, height, sign, depth); + write_frame_16(p, &g, width, height, sign, depth); *got_frame = 1; return 0; } -AVCodec ff_pgx_decoder = { +const AVCodec ff_pgx_decoder = { .name = "pgx", .long_name = NULL_IF_CONFIG_SMALL("PGX (JPEG2000 Test Format)"), .type = AVMEDIA_TYPE_VIDEO,