diff options
Diffstat (limited to 'libavcodec/zmbv.c')
-rw-r--r-- | libavcodec/zmbv.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index bec7abd..b7ebaf9 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -2,20 +2,20 @@ * Zip Motion Blocks Video (ZMBV) decoder * Copyright (c) 2006 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -404,12 +404,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac int zret = Z_OK; // Zlib return code int len = buf_size; int hi_ver, lo_ver, ret; - uint8_t *tmp; if (c->pic.data[0]) avctx->release_buffer(avctx, &c->pic); - c->pic.reference = 1; + c->pic.reference = 3; c->pic.buffer_hints = FF_BUFFER_HINTS_VALID; if ((ret = avctx->get_buffer(avctx, &c->pic)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); @@ -420,6 +419,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac c->flags = buf[0]; buf++; len--; if (c->flags & ZMBV_KEYFRAME) { + void *decode_intra = NULL; + c->decode_intra= NULL; hi_ver = buf[0]; lo_ver = buf[1]; c->comp = buf[2]; @@ -451,29 +452,28 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac switch (c->fmt) { case ZMBV_FMT_8BPP: c->bpp = 8; - c->decode_intra = zmbv_decode_intra; + decode_intra = zmbv_decode_intra; c->decode_xor = zmbv_decode_xor_8; break; case ZMBV_FMT_15BPP: case ZMBV_FMT_16BPP: c->bpp = 16; - c->decode_intra = zmbv_decode_intra; + decode_intra = zmbv_decode_intra; c->decode_xor = zmbv_decode_xor_16; break; #ifdef ZMBV_ENABLE_24BPP case ZMBV_FMT_24BPP: c->bpp = 24; - c->decode_intra = zmbv_decode_intra; + decode_intra = zmbv_decode_intra; c->decode_xor = zmbv_decode_xor_24; break; #endif //ZMBV_ENABLE_24BPP case ZMBV_FMT_32BPP: c->bpp = 32; - c->decode_intra = zmbv_decode_intra; + decode_intra = zmbv_decode_intra; c->decode_xor = zmbv_decode_xor_32; break; default: - c->decode_intra = NULL; c->decode_xor = NULL; av_log_ask_for_sample(avctx, "Unsupported (for now) format %i\n", c->fmt); @@ -486,16 +486,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac return -1; } - tmp = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8)); - if (!tmp) - return AVERROR(ENOMEM); - c->cur = tmp; - tmp = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8)); - if (!tmp) - return AVERROR(ENOMEM); - c->prev = tmp; - c->bx = (c->width + c->bw - 1) / c->bw; - c->by = (c->height + c->bh - 1) / c->bh; + c->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8)); + c->prev = av_realloc_f(c->prev, avctx->width * avctx->height, (c->bpp / 8)); + c->bx = (c->width + c->bw - 1) / c->bw; + c->by = (c->height+ c->bh - 1) / c->bh; + if (!c->cur || !c->prev) + return -1; + c->decode_intra= decode_intra; } if (c->decode_intra == NULL) { @@ -620,6 +617,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->width = avctx->width; c->height = avctx->height; + avcodec_get_frame_defaults(&c->pic); c->bpp = avctx->bits_per_coded_sample; |