X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fzmbv.c;h=f49cbdb014f72c438260069a8a851a9e80afe6f8;hb=3a651f599a18b023602370b67a77eb0efa309b20;hp=8cf6a0cb5bfedbc34e5eafe0b08ad6ad7d6cdc3d;hpb=759001c534287a96dc96d1e274665feb7059145d;p=ffmpeg diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index 8cf6a0cb5bf..f49cbdb014f 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -432,18 +432,15 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n", c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh); if (hi_ver != 0 || lo_ver != 1) { - av_log_ask_for_sample(avctx, "Unsupported version %i.%i\n", - hi_ver, lo_ver); + avpriv_request_sample(avctx, "Version %i.%i", hi_ver, lo_ver); return AVERROR_PATCHWELCOME; } if (c->bw == 0 || c->bh == 0) { - av_log_ask_for_sample(avctx, "Unsupported block size %ix%i\n", - c->bw, c->bh); + avpriv_request_sample(avctx, "Block size %ix%i", c->bw, c->bh); return AVERROR_PATCHWELCOME; } if (c->comp != 0 && c->comp != 1) { - av_log_ask_for_sample(avctx, "Unsupported compression type %i\n", - c->comp); + avpriv_request_sample(avctx, "Compression type %i", c->comp); return AVERROR_PATCHWELCOME; } @@ -474,8 +471,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac default: c->decode_intra = NULL; c->decode_xor = NULL; - av_log_ask_for_sample(avctx, "Unsupported (for now) format %i\n", - c->fmt); + avpriv_request_sample(avctx, "Format %i", c->fmt); return AVERROR_PATCHWELCOME; } @@ -497,14 +493,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac c->by = (c->height + c->bh - 1) / c->bh; } - if (c->decode_intra == NULL) { + if (!c->decode_intra) { av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n"); return AVERROR_INVALIDDATA; } if (c->comp == 0) { //Uncompressed data + if (c->decomp_size < len) { + av_log(avctx, AV_LOG_ERROR, "Buffer too small\n"); + return AVERROR_INVALIDDATA; + } memcpy(c->decomp_buf, buf, len); - c->decomp_size = 1; } else { // ZLIB-compressed data c->zstream.total_in = c->zstream.total_out = 0; c->zstream.next_in = buf; @@ -622,7 +621,7 @@ static av_cold int decode_init(AVCodecContext *avctx) /* Allocate decompression buffer */ if (c->decomp_size) { - if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) { + if (!(c->decomp_buf = av_malloc(c->decomp_size))) { av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); return AVERROR(ENOMEM); @@ -656,6 +655,7 @@ static av_cold int decode_end(AVCodecContext *avctx) AVCodec ff_zmbv_decoder = { .name = "zmbv", + .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_ZMBV, .priv_data_size = sizeof(ZmbvContext), @@ -663,5 +663,4 @@ AVCodec ff_zmbv_decoder = { .close = decode_end, .decode = decode_frame, .capabilities = CODEC_CAP_DR1, - .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"), };