From patchwork Sun Jul 15 13:13:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 9727 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp1354312jad; Sun, 15 Jul 2018 06:14:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf2ASi3xQoPo///p3hOpaS8FU2PX5WrYvl63oZIQrRBAezWBC+W6YQ725olAAGTadPGetCd X-Received: by 2002:adf:e8c2:: with SMTP id k2-v6mr3598976wrn.31.1531660449663; Sun, 15 Jul 2018 06:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531660449; cv=none; d=google.com; s=arc-20160816; b=ln4hkUGgSgDDkOpZaOh9Tqo8CEZitR9YBFNtPeSemPCrXuIPAFaOuntqJnxkm4ZhVg j8xEQXjZkhjLQr7xX35jryE7FzM99WxvYU9LBzJ0+YU+rgypOizmXf89/xoViUNxLZdE VHUCItVucEyiTNPvvVU8uqm9udf29/1Ey57BKWKHSLpVsHTRNOolFNdrhqWn6F/pR7NG XFZNkL5Qq/btu74u5Z5tghgn5WYFlpPJ1hRSxnNpVhHl37ZcJkd0nUYyxTZNK+FVXa04 xOjWUdsP7EdMjkrQ8ZHHMAw2sP+eTAMQYnNdNk2TSscYD9JHhh32+ypNYWaxf4Ih/W/8 YK1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=4DGuzv0HiSesVoHgg2jKpcnZyi+ScPO1HrnvQH/hnlE=; b=FrofMxhFToH4FSsfKnhwTC6ZVOoOTYSqr88/qoklAVII0NlaBXwAEzPLz7FYmCklST El+mqx7+B9HX3zKSGe3tmhNpHXGRYihsJ7XoYRJWaI4o4GlqNKMhQjNU0OXbn3rHkJ03 zwxHBcQjZQKaXxEDSaJiC6WuAXxzt58ZQ2aEReMisvN+ys1U45ZIwFtgPFnVk2EOhbgc Ri/INizN5DrGkkyHBLHzcBgtmtrEqjHT2j0i/4lLQ2eMfAOJAyao+BkL9+WDgrFyjsWB s5j5N8KyQ3SJIu2vMHLzXNtR6fRHMoKPYv2EuWRN7MCejczY2jJDyUtiS8lad3vHd/it /6qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g37-v6si1431651wrd.260.2018.07.15.06.14.08; Sun, 15 Jul 2018 06:14:09 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C527168A399; Sun, 15 Jul 2018 16:13:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe07-3.mx.upcmail.net (vie01a-dmta-pe07-3.mx.upcmail.net [84.116.36.19]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C6A7B689957 for ; Sun, 15 Jul 2018 16:13:50 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe07.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fegqe-0005gB-2C for ffmpeg-devel@ffmpeg.org; Sun, 15 Jul 2018 15:14:00 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id B1Dq1y01n0S5wYM011DsSi; Sun, 15 Jul 2018 15:13:52 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 15 Jul 2018 15:13:39 +0200 Message-Id: <20180715131341.28705-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180715131341.28705-1-michael@niedermayer.cc> References: <20180715131341.28705-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/tscc: Move reading the side data palette before other checks X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" We do not want to loose the side data in case of errors Signed-off-by: Michael Niedermayer --- libavcodec/tscc.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c index f891932342..fc9510451b 100644 --- a/libavcodec/tscc.c +++ b/libavcodec/tscc.c @@ -69,6 +69,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, CamtasiaContext * const c = avctx->priv_data; AVFrame *frame = c->frame; int ret; + int palette_has_changed = 0; + + if (c->avctx->pix_fmt == AV_PIX_FMT_PAL8) { + int size; + const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); + + if (pal && size == AVPALETTE_SIZE) { + palette_has_changed = 1; + memcpy(c->pal, pal, AVPALETTE_SIZE); + } else if (pal) { + av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); + } + } ret = inflateReset(&c->zstream); if (ret != Z_OK) { @@ -97,15 +110,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, /* make the palette available on the way out */ if (c->avctx->pix_fmt == AV_PIX_FMT_PAL8) { - int size; - const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); - - if (pal && size == AVPALETTE_SIZE) { - frame->palette_has_changed = 1; - memcpy(c->pal, pal, AVPALETTE_SIZE); - } else if (pal) { - av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); - } + frame->palette_has_changed = palette_has_changed; memcpy(frame->data[1], c->pal, AVPALETTE_SIZE); }