From 296140ebfb7242211852f7736f72dc7f05f0c458 Mon Sep 17 00:00:00 2001 From: Stephan Hilb Date: Sat, 1 Sep 2012 10:12:33 +0200 Subject: [PATCH] cpia: move reget_buffer after header check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the header is invalid, there is no need to get at buffer. Do it after the header has been checked. Suggested by Reimar Döffinger --- libavcodec/cpia.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/cpia.c b/libavcodec/cpia.c index c45936b65f..a631a05108 100644 --- a/libavcodec/cpia.c +++ b/libavcodec/cpia.c @@ -61,12 +61,6 @@ static int cpia_decode_frame(AVCodecContext* avctx, AVFrame* const frame = &cpia->frame; uint8_t *y, *u, *v, *y_end, *u_end, *v_end; - // Get buffer filled with previous frame - if ((ret = avctx->reget_buffer(avctx, frame)) < 0) { - av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed!\n"); - return ret; - } - // Check header if ( avpkt->size < FRAME_HEADER_SIZE || header[0] != MAGIC_0 || header[1] != MAGIC_1 @@ -104,6 +98,12 @@ static int cpia_decode_frame(AVCodecContext* avctx, frame->key_frame = 0; } + // Get buffer filled with previous frame + if ((ret = avctx->reget_buffer(avctx, frame)) < 0) { + av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed!\n"); + return ret; + } + for ( i = 0; i < frame->height;