From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 9B4FF43F44 for ; Thu, 18 Aug 2022 22:35:58 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 65E5B68B7CC; Fri, 19 Aug 2022 01:35:46 +0300 (EEST) Received: from vie01a-dmta-at03-1.mx.upcmail.net (vie01a-dmta-at03-1.mx.upcmail.net [62.179.121.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6D24068B8ED for ; Fri, 19 Aug 2022 01:35:38 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-at03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1oOo6y-00GsY6-P3 for ffmpeg-devel@ffmpeg.org; Fri, 19 Aug 2022 00:35:36 +0200 Received: from ren-mail-psmtp-mg01. ([80.109.253.241]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id Oo6yoxtTD8s8UOo6yolzmg; Fri, 19 Aug 2022 00:35:36 +0200 Received: from localhost ([213.47.68.29]) by ren-mail-psmtp-mg01. with ESMTP id Oo6xo481ROPqFOo6xoRE3d; Fri, 19 Aug 2022 00:35:35 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.4 cv=OcX7sjfY c=1 sm=1 tr=0 ts=62febeb8 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=kCjymV7rsJuVYsGs5Z4A:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 19 Aug 2022 00:35:32 +0200 Message-Id: <20220818223535.13078-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfA3RAIXNbvKSszyQ51ZPszgVERCdfcSAELd4DSQvucCJlmwNwb3od/RhK8+fs2YVMJ/d6lO9GN7qpGSjvg6muZT0iU2TB1Nq3vv/A5TdG57ZpgG9kK6m H/U1QpbvJdQn8T7VJZyTFNPlvOIJhD/hMXwDMxJR35Wb3K+4u5H0aXLMyjL70V+Lq5SzZs9RP1ADzw== Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/bethsoftvideo: Pass GetByteContext into set_palette() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Michael Niedermayer --- libavcodec/bethsoftvideo.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c index a2e8f412d6..1d0f9198cf 100644 --- a/libavcodec/bethsoftvideo.c +++ b/libavcodec/bethsoftvideo.c @@ -51,16 +51,16 @@ static av_cold int bethsoftvid_decode_init(AVCodecContext *avctx) return 0; } -static int set_palette(BethsoftvidContext *ctx) +static int set_palette(BethsoftvidContext *ctx, GetByteContext *g) { uint32_t *palette = (uint32_t *)ctx->frame->data[1]; int a; - if (bytestream2_get_bytes_left(&ctx->g) < 256*3) + if (bytestream2_get_bytes_left(g) < 256*3) return AVERROR_INVALIDDATA; for(a = 0; a < 256; a++){ - palette[a] = 0xFFU << 24 | bytestream2_get_be24u(&ctx->g) * 4; + palette[a] = 0xFFU << 24 | bytestream2_get_be24u(g) * 4; palette[a] |= palette[a] >> 6 & 0x30303; } ctx->frame->palette_has_changed = 1; @@ -85,9 +85,10 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx, AVFrame *rframe, if (avpkt->side_data_elems > 0 && avpkt->side_data[0].type == AV_PKT_DATA_PALETTE) { - bytestream2_init(&vid->g, avpkt->side_data[0].data, + GetByteContext g; + bytestream2_init(&g, avpkt->side_data[0].data, avpkt->side_data[0].size); - if ((ret = set_palette(vid)) < 0) + if ((ret = set_palette(vid, &g)) < 0) return ret; } @@ -98,7 +99,7 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx, AVFrame *rframe, switch(block_type = bytestream2_get_byte(&vid->g)){ case PALETTE_BLOCK: { *got_frame = 0; - if ((ret = set_palette(vid)) < 0) { + if ((ret = set_palette(vid, &vid->g)) < 0) { av_log(avctx, AV_LOG_ERROR, "error reading palette\n"); return ret; } -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".