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 ESMTPS id C25B64CAD5 for ; Thu, 13 Mar 2025 11:16:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 29D5168CEFE; Thu, 13 Mar 2025 13:15:25 +0200 (EET) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 88CDB68E785 for ; Thu, 13 Mar 2025 13:15:19 +0200 (EET) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-43948f77f1aso5208255e9.0 for ; Thu, 13 Mar 2025 04:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741864519; x=1742469319; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DLmCv6FoKJgMMEbGv5z9sOZu6Z2bb8uoVjGxTTQbEfI=; b=DryaixHLHNDjGhfLUYlyZQ/nkVBtkQneBiKRiy2ulj5SlpX9JFMhBlzBjx2AsBnXHa 7C+8+PQbE6uH3bdVZ+22h9Hr2f1w4zxHNHprC/a8LQxpdojSYK6RL0lBx2jF2ngtDbIb 98Cv1+2mrw1gn5RNCjWp9flG+JBqeqc9GO5Y6Xmm2uLU+BrThIVDSrmrsrXH8PRbvsGU unk1EswUxo2izK0IvOXoqHeS/oF8d5XMfWD1nuDjVCHOIOPXmkXJy7O81soU34kNES/w gVojjZcFC+ubvNJ43pt2kak1Tsly8/RIFzf4s1PG6QKMuHj8DyfSrQJTR3tAhHgCu4si 6adw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741864519; x=1742469319; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DLmCv6FoKJgMMEbGv5z9sOZu6Z2bb8uoVjGxTTQbEfI=; b=k2OpobrAAY47UEHv4bo5DyQ4C2f2bnh2KhPgqeUsYSD4Ba5QQ00Rm55ff8EOEbuOin 5QLM9huQm7MH61HqV4G0HYWrVIBvhZy7uVzoB0rHUhuo2YgxScpbByZPtiC1FqDqnCo7 VxOtPt509NxA/pM4TFZd9ARizvfXQS1Y75aYa33/QbQ7efOCwM41KkrzhQehjF9TjWCg 9hX0vQrYv3npGQi0S/8XUs7NMhl/ZgmV81lmF6uALvSspy+m51fXzKqrcjlsYEbq2xR3 PBYaoD0zrjQm9I6ANenwmod+odp2SzsUVbBjIMeYu8MxiXObFLBjmiURwVSNOeVaaOKK VGGg== X-Gm-Message-State: AOJu0Yx0st3/Jg89e7r+x1TyUgVZg5uvsFWPby+1uG2SBZXiqWgx/QRy 1QqHPDR96sYwlHwTNUvX1Jjh+FByd9A1bEdGrfSaxI4uK8utbAa6cqfQzg== X-Gm-Gg: ASbGnct0UROFBm3igqovxPm9TfrsrBZyzPhvcJHW6aMh7aEP5eKLmjyIgjIZ3i2dwh4 aLohvpdKUlGRIwJgukNKbiYiDww2zP/ZukyT9ZxPZoZmd+UQT5pxX7fTXXbToedQq9hqAeQa/TM ZTg9r/itkF2g5DHW9cRAuyTeYJO9hAMOQXbiTT6JHRXxTJYQivK7oLv4STql6y5XsG6xBehf35E Sb1Jq/My7hR6ldfg0zNSNI64Vr5A765/3va9lTeTYaqNQERtkCK5t7ZHAXYGAbBOxFg6PxDwDXA ldhZ5hD3aA+K12i3L28ahwp5Jzq8h/TErMT/fpK8TS7UzKwQX4UqW3rryo46pNm81uTw2L6sEAT yGixO8o1apj9vbsZt4Kti+AG27CKloXJ2oSeJ0O5cyYg5tDSsp4F0tCI= X-Google-Smtp-Source: AGHT+IHc1zt0em/c6mS+SWCupw2zXwO/91ir8t2TdNslDWKOA9TvHCkuHpvkEshTm/qIzkozf2pGwQ== X-Received: by 2002:a05:600c:1546:b0:43d:a90:9f1 with SMTP id 5b1f17b1804b1-43d0a900bb5mr45425905e9.6.1741864518330; Thu, 13 Mar 2025 04:15:18 -0700 (PDT) Received: from flagship3.deu.mlau.at (p200300c0271f29004c5623f045c27bca.dip0.t-ipconnect.de. [2003:c0:271f:2900:4c56:23f0:45c2:7bca]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d0a75b324sm50153795e9.24.2025.03.13.04.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 04:15:17 -0700 (PDT) From: Manuel Lauss To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Mar 2025 12:15:04 +0100 Message-ID: <20250313111505.166786-12-manuel.lauss@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250313111505.166786-1-manuel.lauss@gmail.com> References: <20250313111505.166786-1-manuel.lauss@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/12] avcodec/sanm: change GetByteContext member to pointer 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 Cc: Manuel Lauss 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: In order do properly support the ANIM STOR/FTCH system, the FTCH must replay a stored FOBJ and change the SANMContext's "GetByteContext" member temporarily. Signed-off-by: Manuel Lauss --- libavcodec/sanm.c | 394 +++++++++++++++++++++++----------------------- 1 file changed, 198 insertions(+), 196 deletions(-) diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index a8a3e04156..207db4a8fb 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -262,7 +262,7 @@ static const int8_t c37_mv[] = { typedef struct SANMVideoContext { AVCodecContext *avctx; - GetByteContext gb; + GetByteContext *gb; int version, subversion, have_dimensions; uint32_t pal[PALETTE_SIZE]; @@ -606,11 +606,11 @@ static int codec4_load_tiles(SANMVideoContext *ctx, uint16_t param2, uint8_t clr if (param2 > 256) return AVERROR_INVALIDDATA; - if (bytestream2_get_bytes_left(&ctx->gb) < loop) + if (bytestream2_get_bytes_left(ctx->gb) < loop) return AVERROR_INVALIDDATA; while (loop--) { - c = bytestream2_get_byteu(&ctx->gb); + c = bytestream2_get_byteu(ctx->gb); *dst++ = (c >> 4) + clr; *dst++ = (c & 0xf) + clr; } @@ -702,9 +702,9 @@ static int old_codec4(SANMVideoContext *ctx, int left, int top, int w, int h, pxoff = j + left + ((top + i) * p); if (param2 > 0) { if (bits == 0) { - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - mask = bytestream2_get_byteu(&ctx->gb); + mask = bytestream2_get_byteu(ctx->gb); bits = 8; } bit = !!(mask & 0x80); @@ -714,9 +714,9 @@ static int old_codec4(SANMVideoContext *ctx, int left, int top, int w, int h, bit = 0; } - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - idx = bytestream2_get_byteu(&ctx->gb); + idx = bytestream2_get_byteu(ctx->gb); if ((bit == 0) && (idx == 0x80) && (codec != 5)) continue; @@ -761,18 +761,18 @@ static int rle_decode(SANMVideoContext *ctx, uint8_t *dst, const int out_size) int opcode, color, run_len, left = out_size; while (left > 0) { - opcode = bytestream2_get_byte(&ctx->gb); + opcode = bytestream2_get_byte(ctx->gb); run_len = (opcode >> 1) + 1; - if (run_len > left || bytestream2_get_bytes_left(&ctx->gb) <= 0) + if (run_len > left || bytestream2_get_bytes_left(ctx->gb) <= 0) return AVERROR_INVALIDDATA; if (opcode & 1) { - color = bytestream2_get_byte(&ctx->gb); + color = bytestream2_get_byte(ctx->gb); memset(dst, color, run_len); } else { - if (bytestream2_get_bytes_left(&ctx->gb) < run_len) + if (bytestream2_get_bytes_left(ctx->gb) < run_len) return AVERROR_INVALIDDATA; - bytestream2_get_bufferu(&ctx->gb, dst, run_len); + bytestream2_get_bufferu(ctx->gb, dst, run_len); } dst += run_len; @@ -795,30 +795,30 @@ static int old_codec23(SANMVideoContext *ctx, int top, int left, int width, for (i = 0; i < 256; i++) lut[i] = (i + param + 0xd0) & 0xff; } else if (param2 == 256) { - if (bytestream2_get_bytes_left(&ctx->gb) < 256) + if (bytestream2_get_bytes_left(ctx->gb) < 256) return AVERROR_INVALIDDATA; - bytestream2_get_bufferu(&ctx->gb, ctx->c23lut, 256); + bytestream2_get_bufferu(ctx->gb, ctx->c23lut, 256); } else if (param2 < 256) { for (i = 0; i < 256; i++) lut[i] = (i + param2) & 0xff; } else { memcpy(lut, ctx->c23lut, 256); } - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return 0; /* some c23 frames just set up the LUT */ dst = (uint8_t *)ctx->frm0; for (i = 0; i < height; i++) { - if (bytestream2_get_bytes_left(&ctx->gb) < 2) + if (bytestream2_get_bytes_left(ctx->gb) < 2) return 0; pxoff = left + ((top + i) * ctx->pitch); - k = bytestream2_get_le16u(&ctx->gb); + k = bytestream2_get_le16u(ctx->gb); sk = 1; pc = 0; while (k > 0 && pc <= width) { - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - j = bytestream2_get_byteu(&ctx->gb); + j = bytestream2_get_byteu(ctx->gb); if (sk) { pxoff += j; pc += j; @@ -847,25 +847,25 @@ static int old_codec21(SANMVideoContext *ctx, int top, int left, int width, dst = (uint8_t *)ctx->frm0; for (i = 0; i < height; i++) { - if (bytestream2_get_bytes_left(&ctx->gb) < 2) + if (bytestream2_get_bytes_left(ctx->gb) < 2) return 0; pxoff = left + ((top + i) * ctx->pitch); - k = bytestream2_get_le16u(&ctx->gb); + k = bytestream2_get_le16u(ctx->gb); sk = 1; pc = 0; while (k > 0 && pc <= width) { - if (bytestream2_get_bytes_left(&ctx->gb) < 2) + if (bytestream2_get_bytes_left(ctx->gb) < 2) return AVERROR_INVALIDDATA; - j = bytestream2_get_le16u(&ctx->gb); + j = bytestream2_get_le16u(ctx->gb); k -= 2; if (sk) { pxoff += j; pc += j; } else { - if (bytestream2_get_bytes_left(&ctx->gb) < (j + 1)) + if (bytestream2_get_bytes_left(ctx->gb) < (j + 1)) return AVERROR_INVALIDDATA; do { - c = bytestream2_get_byteu(&ctx->gb); + c = bytestream2_get_byteu(ctx->gb); if (pxoff >=0 && pxoff < maxpxo) { *(dst + pxoff) = c; } @@ -889,22 +889,22 @@ static int old_codec1(SANMVideoContext *ctx, int top, uint8_t *dst = (uint8_t *)ctx->frm0; for (i = 0; i < height; i++) { - if (bytestream2_get_bytes_left(&ctx->gb) < 2) + if (bytestream2_get_bytes_left(ctx->gb) < 2) return AVERROR_INVALIDDATA; - len = bytestream2_get_le16u(&ctx->gb); - end = bytestream2_tell(&ctx->gb) + len; + len = bytestream2_get_le16u(ctx->gb); + end = bytestream2_tell(ctx->gb) + len; pxoff = left + ((top + i) * ctx->pitch); - while (bytestream2_tell(&ctx->gb) < end) { - if (bytestream2_get_bytes_left(&ctx->gb) < 2) + while (bytestream2_tell(ctx->gb) < end) { + if (bytestream2_get_bytes_left(ctx->gb) < 2) return AVERROR_INVALIDDATA; - code = bytestream2_get_byteu(&ctx->gb); + code = bytestream2_get_byteu(ctx->gb); flag = code & 1; code = (code >> 1) + 1; if (flag) { - val = bytestream2_get_byteu(&ctx->gb); + val = bytestream2_get_byteu(ctx->gb); if (val || opaque) { for (j = 0; j < code; j++) { if (pxoff >= 0 && pxoff < maxpxo) @@ -915,10 +915,10 @@ static int old_codec1(SANMVideoContext *ctx, int top, pxoff += code; } } else { - if (bytestream2_get_bytes_left(&ctx->gb) < code) + if (bytestream2_get_bytes_left(ctx->gb) < code) return AVERROR_INVALIDDATA; for (j = 0; j < code; j++) { - val = bytestream2_get_byteu(&ctx->gb); + val = bytestream2_get_byteu(ctx->gb); if ((pxoff >= 0) && (pxoff < maxpxo) && (val || opaque)) *(dst + pxoff) = val; pxoff++; @@ -937,10 +937,10 @@ static int old_codec2(SANMVideoContext *ctx, int top, uint8_t *dst = (uint8_t *)ctx->frm0, col; int16_t xpos = left, ypos = top; - while (bytestream2_get_bytes_left(&ctx->gb) > 3) { - xpos += bytestream2_get_le16u(&ctx->gb); - ypos += bytestream2_get_byteu(&ctx->gb); - col = bytestream2_get_byteu(&ctx->gb); + while (bytestream2_get_bytes_left(ctx->gb) > 3) { + xpos += bytestream2_get_le16u(ctx->gb); + ypos += bytestream2_get_byteu(ctx->gb); + col = bytestream2_get_byteu(ctx->gb); if (xpos >= 0 && ypos >= 0 && xpos < ctx->width && ypos < ctx->height) { *(dst + xpos + ypos * ctx->pitch) = col; @@ -974,15 +974,15 @@ static int old_codec37(SANMVideoContext *ctx, int width, int height) ptrdiff_t stride = ctx->pitch; uint8_t *dst, *prev; int skip_run = 0; - int compr = bytestream2_get_byte(&ctx->gb); - int mvoff = bytestream2_get_byte(&ctx->gb); - int seq = bytestream2_get_le16(&ctx->gb); - uint32_t decoded_size = bytestream2_get_le32(&ctx->gb); + int compr = bytestream2_get_byte(ctx->gb); + int mvoff = bytestream2_get_byte(ctx->gb); + int seq = bytestream2_get_le16(ctx->gb); + uint32_t decoded_size = bytestream2_get_le32(ctx->gb); int flags; - bytestream2_skip(&ctx->gb, 4); - flags = bytestream2_get_byte(&ctx->gb); - bytestream2_skip(&ctx->gb, 3); + bytestream2_skip(ctx->gb, 4); + flags = bytestream2_get_byte(ctx->gb); + bytestream2_skip(ctx->gb, 3); if (decoded_size > ctx->height * stride) { decoded_size = ctx->height * stride; @@ -1006,7 +1006,7 @@ static int old_codec37(SANMVideoContext *ctx, int width, int height) switch (compr) { case 0: for (i = 0; i < height; i++) { - bytestream2_get_buffer(&ctx->gb, dst, width); + bytestream2_get_buffer(ctx->gb, dst, width); dst += stride; } memset(ctx->frm2, 0, ctx->height * stride); @@ -1019,9 +1019,9 @@ static int old_codec37(SANMVideoContext *ctx, int width, int height) for (j = 0; j < height; j += 4) { for (i = 0; i < width; i += 4) { if (len < 0) { - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - code = bytestream2_get_byte(&ctx->gb); + code = bytestream2_get_byte(ctx->gb); len = code >> 1; run = code & 1; skip = 0; @@ -1030,29 +1030,29 @@ static int old_codec37(SANMVideoContext *ctx, int width, int height) } if (!skip) { - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - code = bytestream2_get_byte(&ctx->gb); + code = bytestream2_get_byte(ctx->gb); if (code == 0xff) { len--; for (k = 0; k < 4; k++) { for (l = 0; l < 4; l++) { if (len < 0) { - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - code = bytestream2_get_byte(&ctx->gb); + code = bytestream2_get_byte(ctx->gb); len = code >> 1; run = code & 1; if (run) { - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - code = bytestream2_get_byte(&ctx->gb); + code = bytestream2_get_byte(ctx->gb); } } if (!run) { - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - code = bytestream2_get_byte(&ctx->gb); + code = bytestream2_get_byte(ctx->gb); } *(dst + i + (k * stride) + l) = code; len--; @@ -1087,23 +1087,23 @@ static int old_codec37(SANMVideoContext *ctx, int width, int height) copy_block4(dst + i, prev + i, stride, stride, 4); continue; } - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - code = bytestream2_get_byteu(&ctx->gb); + code = bytestream2_get_byteu(ctx->gb); if (code == 0xFF) { - if (bytestream2_get_bytes_left(&ctx->gb) < 16) + if (bytestream2_get_bytes_left(ctx->gb) < 16) return AVERROR_INVALIDDATA; for (k = 0; k < 4; k++) - bytestream2_get_bufferu(&ctx->gb, dst + i + k * stride, 4); + bytestream2_get_bufferu(ctx->gb, dst + i + k * stride, 4); } else if ((flags & 4) && (code == 0xFE)) { - if (bytestream2_get_bytes_left(&ctx->gb) < 4) + if (bytestream2_get_bytes_left(ctx->gb) < 4) return AVERROR_INVALIDDATA; for (k = 0; k < 4; k++) - memset(dst + i + k * stride, bytestream2_get_byteu(&ctx->gb), 4); + memset(dst + i + k * stride, bytestream2_get_byteu(ctx->gb), 4); } else if ((flags & 4) && (code == 0xFD)) { - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - t = bytestream2_get_byteu(&ctx->gb); + t = bytestream2_get_byteu(ctx->gb); for (k = 0; k < 4; k++) memset(dst + i + k * stride, t, 4); } else { @@ -1113,7 +1113,7 @@ static int old_codec37(SANMVideoContext *ctx, int width, int height) ctx->height, stride, i + mx, j + my); if ((compr == 4) && (code == 0)) - skip_run = bytestream2_get_byteu(&ctx->gb); + skip_run = bytestream2_get_byteu(ctx->gb); } } dst += stride * 4; @@ -1137,20 +1137,20 @@ static int process_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1, uint8_t colors[2]; int8_t *pglyph; - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - code = bytestream2_get_byteu(&ctx->gb); + code = bytestream2_get_byteu(ctx->gb); if (code >= 0xF8) { switch (code) { case 0xFF: if (size == 2) { - if (bytestream2_get_bytes_left(&ctx->gb) < 4) + if (bytestream2_get_bytes_left(ctx->gb) < 4) return AVERROR_INVALIDDATA; - dst[0] = bytestream2_get_byteu(&ctx->gb); - dst[1] = bytestream2_get_byteu(&ctx->gb); - dst[0 + stride] = bytestream2_get_byteu(&ctx->gb); - dst[1 + stride] = bytestream2_get_byteu(&ctx->gb); + dst[0] = bytestream2_get_byteu(ctx->gb); + dst[1] = bytestream2_get_byteu(ctx->gb); + dst[0 + stride] = bytestream2_get_byteu(ctx->gb); + dst[1 + stride] = bytestream2_get_byteu(ctx->gb); } else { size >>= 1; if (process_block(ctx, dst, prev1, prev2, stride, tbl, size)) @@ -1169,20 +1169,20 @@ static int process_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1, } break; case 0xFE: - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - t = bytestream2_get_byteu(&ctx->gb); + t = bytestream2_get_byteu(ctx->gb); for (k = 0; k < size; k++) memset(dst + k * stride, t, size); break; case 0xFD: - if (bytestream2_get_bytes_left(&ctx->gb) < 3) + if (bytestream2_get_bytes_left(ctx->gb) < 3) return AVERROR_INVALIDDATA; - code = bytestream2_get_byteu(&ctx->gb); + code = bytestream2_get_byteu(ctx->gb); pglyph = (size == 8) ? ctx->p8x8glyphs[code] : ctx->p4x4glyphs[code]; - bytestream2_get_bufferu(&ctx->gb, colors, 2); + bytestream2_get_bufferu(ctx->gb, colors, 2); for (k = 0; k < size; k++) for (t = 0; t < size; t++) @@ -1193,10 +1193,10 @@ static int process_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1, memcpy(dst + k * stride, prev1 + k * stride, size); break; default: - k = bytestream2_tell(&ctx->gb); - bytestream2_seek(&ctx->gb, tbl + (code & 7), SEEK_SET); - t = bytestream2_get_byte(&ctx->gb); - bytestream2_seek(&ctx->gb, k, SEEK_SET); + k = bytestream2_tell(ctx->gb); + bytestream2_seek(ctx->gb, tbl + (code & 7), SEEK_SET); + t = bytestream2_get_byte(ctx->gb); + bytestream2_seek(ctx->gb, k, SEEK_SET); for (k = 0; k < size; k++) memset(dst + k * stride, t, size); } @@ -1228,7 +1228,7 @@ static void codec47_read_interptable(SANMVideoContext *ctx) for (i = 0; i < 256; i++) { p1 = p2 = itbl + i; for (j = 256 - i; j; j--) { - *p1 = *p2 = bytestream2_get_byte(&ctx->gb); + *p1 = *p2 = bytestream2_get_byte(ctx->gb); p1 += 1; p2 += 256; } @@ -1245,12 +1245,12 @@ static void codec47_comp1(SANMVideoContext *ctx, uint8_t *dst_in, int width, dst = dst_in + stride; for (i = 0; i < height; i += 2) { - p1 = bytestream2_get_byte(&ctx->gb); + p1 = bytestream2_get_byte(ctx->gb); *dst++ = p1; *dst++ = p1; px = p1; for (j = 2; j < width; j += 2) { - p1 = bytestream2_get_byte(&ctx->gb); + p1 = bytestream2_get_byte(ctx->gb); px = (px << 8) | p1; *dst++ = itbl[px]; *dst++ = p1; @@ -1278,17 +1278,17 @@ static int old_codec47(SANMVideoContext *ctx, int width, int height) uint8_t *prev1 = (uint8_t *)ctx->frm1; uint8_t *prev2 = (uint8_t *)ctx->frm2; uint8_t auxcol[2]; - int tbl_pos = bytestream2_tell(&ctx->gb); - int seq = bytestream2_get_le16(&ctx->gb); - int compr = bytestream2_get_byte(&ctx->gb); - int new_rot = bytestream2_get_byte(&ctx->gb); - int skip = bytestream2_get_byte(&ctx->gb); - - bytestream2_skip(&ctx->gb, 7); - auxcol[0] = bytestream2_get_byteu(&ctx->gb); - auxcol[1] = bytestream2_get_byteu(&ctx->gb); - decoded_size = bytestream2_get_le32(&ctx->gb); - bytestream2_skip(&ctx->gb, 8); + int tbl_pos = bytestream2_tell(ctx->gb); + int seq = bytestream2_get_le16(ctx->gb); + int compr = bytestream2_get_byte(ctx->gb); + int new_rot = bytestream2_get_byte(ctx->gb); + int skip = bytestream2_get_byte(ctx->gb); + + bytestream2_skip(ctx->gb, 7); + auxcol[0] = bytestream2_get_byteu(ctx->gb); + auxcol[1] = bytestream2_get_byteu(ctx->gb); + decoded_size = bytestream2_get_le32(ctx->gb); + bytestream2_skip(ctx->gb, 8); if (decoded_size > ctx->height * stride) { decoded_size = ctx->height * stride; @@ -1296,7 +1296,7 @@ static int old_codec47(SANMVideoContext *ctx, int width, int height) } if (skip & 1) { - if (bytestream2_get_bytes_left(&ctx->gb) < 0x8080) + if (bytestream2_get_bytes_left(ctx->gb) < 0x8080) return AVERROR_INVALIDDATA; codec47_read_interptable(ctx); } @@ -1308,15 +1308,15 @@ static int old_codec47(SANMVideoContext *ctx, int width, int height) switch (compr) { case 0: - if (bytestream2_get_bytes_left(&ctx->gb) < width * height) + if (bytestream2_get_bytes_left(ctx->gb) < width * height) return AVERROR_INVALIDDATA; for (j = 0; j < height; j++) { - bytestream2_get_bufferu(&ctx->gb, dst, width); + bytestream2_get_bufferu(ctx->gb, dst, width); dst += stride; } break; case 1: - if (bytestream2_get_bytes_left(&ctx->gb) < ((width + 1) >> 1) * ((height + 1) >> 1)) + if (bytestream2_get_bytes_left(ctx->gb) < ((width + 1) >> 1) * ((height + 1) >> 1)) return AVERROR_INVALIDDATA; codec47_comp1(ctx, dst, width, height, stride); break; @@ -1381,24 +1381,24 @@ static int codec48_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *db, int16_t mvofs; uint32_t ofs; - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return 1; - opc = bytestream2_get_byteu(&ctx->gb); + opc = bytestream2_get_byteu(ctx->gb); switch (opc) { case 0xFF: // 1x1 -> 8x8 block scale - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return 1; - opc = bytestream2_get_byteu(&ctx->gb); + opc = bytestream2_get_byteu(ctx->gb); for (i = 0; i < 16; i++) sb[i] = opc; c48_4to8(dst, sb, w); break; case 0xFE: // 1x 8x8 copy from deltabuf, 16bit mv from source - if (bytestream2_get_bytes_left(&ctx->gb) < 2) + if (bytestream2_get_bytes_left(ctx->gb) < 2) return 1; - mvofs = bytestream2_get_le16(&ctx->gb); + mvofs = bytestream2_get_le16(ctx->gb); for (i = 0; i < 8; i++) { ofs = w * i; for (k = 0; k < 8; k++) @@ -1406,12 +1406,12 @@ static int codec48_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *db, } break; case 0xFD: // 2x2 -> 8x8 block scale - if (bytestream2_get_bytes_left(&ctx->gb) < 4) + if (bytestream2_get_bytes_left(ctx->gb) < 4) return 1; - sb[ 5] = bytestream2_get_byteu(&ctx->gb); - sb[ 7] = bytestream2_get_byteu(&ctx->gb); - sb[13] = bytestream2_get_byteu(&ctx->gb); - sb[15] = bytestream2_get_byteu(&ctx->gb); + sb[ 5] = bytestream2_get_byteu(ctx->gb); + sb[ 7] = bytestream2_get_byteu(ctx->gb); + sb[13] = bytestream2_get_byteu(ctx->gb); + sb[15] = bytestream2_get_byteu(ctx->gb); sb[0] = sb[1] = sb[4] = sb[5]; sb[2] = sb[3] = sb[6] = sb[7]; @@ -1420,11 +1420,11 @@ static int codec48_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *db, c48_4to8(dst, sb, w); break; case 0xFC: // 4x copy 4x4 block, per-block c37_mv from source - if (bytestream2_get_bytes_left(&ctx->gb) < 4) + if (bytestream2_get_bytes_left(ctx->gb) < 4) return 1; for (i = 0; i < 8; i += 4) { for (k = 0; k < 8; k += 4) { - opc = bytestream2_get_byteu(&ctx->gb); + opc = bytestream2_get_byteu(ctx->gb); mvofs = c37_mv[opc * 2] + (c37_mv[opc * 2 + 1] * w); for (j = 0; j < 4; j++) { ofs = (w * (j + i)) + k; @@ -1435,11 +1435,11 @@ static int codec48_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *db, } break; case 0xFB: // Copy 4x 4x4 blocks, per-block mv from source - if (bytestream2_get_bytes_left(&ctx->gb) < 8) + if (bytestream2_get_bytes_left(ctx->gb) < 8) return 1; for (i = 0; i < 8; i += 4) { for (k = 0; k < 8; k += 4) { - mvofs = bytestream2_get_le16(&ctx->gb); + mvofs = bytestream2_get_le16(ctx->gb); for (j = 0; j < 4; j++) { ofs = (w * (j + i)) + k; for (l = 0; l < 4; l++) @@ -1449,18 +1449,18 @@ static int codec48_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *db, } break; case 0xFA: // scale 4x4 input block to 8x8 dest block - if (bytestream2_get_bytes_left(&ctx->gb) < 16) + if (bytestream2_get_bytes_left(ctx->gb) < 16) return 1; - bytestream2_get_bufferu(&ctx->gb, sb, 16); + bytestream2_get_bufferu(ctx->gb, sb, 16); c48_4to8(dst, sb, w); break; case 0xF9: // 16x 2x2 copy from delta, per-block c37_mv from source - if (bytestream2_get_bytes_left(&ctx->gb) < 16) + if (bytestream2_get_bytes_left(ctx->gb) < 16) return 1; for (i = 0; i < 8; i += 2) { for (j = 0; j < 8; j += 2) { ofs = (w * i) + j; - opc = bytestream2_get_byteu(&ctx->gb); + opc = bytestream2_get_byteu(ctx->gb); mvofs = c37_mv[opc * 2] + (c37_mv[opc * 2 + 1] * w); for (l = 0; l < 2; l++) { *(dst + ofs + l + 0) = *(db + ofs + l + 0 + mvofs); @@ -1470,12 +1470,12 @@ static int codec48_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *db, } break; case 0xF8: // 16x 2x2 blocks copy, 16bit mv from source - if (bytestream2_get_bytes_left(&ctx->gb) < 32) + if (bytestream2_get_bytes_left(ctx->gb) < 32) return 1; for (i = 0; i < 8; i += 2) { for (j = 0; j < 8; j += 2) { ofs = w * i + j; - mvofs = bytestream2_get_le16(&ctx->gb); + mvofs = bytestream2_get_le16(ctx->gb); for (l = 0; l < 2; l++) { *(dst + ofs + l + 0) = *(db + ofs + l + 0 + mvofs); *(dst + ofs + l + w) = *(db + ofs + l + w + mvofs); @@ -1484,12 +1484,12 @@ static int codec48_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *db, } break; case 0xF7: // copy 8x8 block from src to dest - if (bytestream2_get_bytes_left(&ctx->gb) < 64) + if (bytestream2_get_bytes_left(ctx->gb) < 64) return 1; for (i = 0; i < 8; i++) { ofs = i * w; for (l = 0; l < 8; l++) - *(dst + ofs + l) = bytestream2_get_byteu(&ctx->gb); + *(dst + ofs + l) = bytestream2_get_byteu(ctx->gb); } break; default: // copy 8x8 block from prev, c37_mv from source @@ -1507,10 +1507,10 @@ static int codec48_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *db, static int old_codec48(SANMVideoContext *ctx, int width, int height) { uint8_t *dst, *prev; - int compr = bytestream2_get_byte(&ctx->gb); - int mvidx = bytestream2_get_byte(&ctx->gb); - int seq = bytestream2_get_le16(&ctx->gb); - uint32_t decoded_size = bytestream2_get_le32(&ctx->gb); + int compr = bytestream2_get_byte(ctx->gb); + int mvidx = bytestream2_get_byte(ctx->gb); + int seq = bytestream2_get_le16(ctx->gb); + uint32_t decoded_size = bytestream2_get_le32(ctx->gb); int i, j, flags; // all codec48 videos use 1, but just to be safe... @@ -1519,12 +1519,12 @@ static int old_codec48(SANMVideoContext *ctx, int width, int height) return AVERROR_INVALIDDATA; } - bytestream2_skip(&ctx->gb, 4); - flags = bytestream2_get_byte(&ctx->gb); - bytestream2_skip(&ctx->gb, 3); + bytestream2_skip(ctx->gb, 4); + flags = bytestream2_get_byte(ctx->gb); + bytestream2_skip(ctx->gb, 3); if (flags & 8) { - if (bytestream2_get_bytes_left(&ctx->gb) < 0x8080) + if (bytestream2_get_bytes_left(ctx->gb) < 0x8080) return AVERROR_INVALIDDATA; codec47_read_interptable(ctx); } @@ -1539,10 +1539,10 @@ static int old_codec48(SANMVideoContext *ctx, int width, int height) switch (compr) { case 0: - if (bytestream2_get_bytes_left(&ctx->gb) < width * height) + if (bytestream2_get_bytes_left(ctx->gb) < width * height) return AVERROR_INVALIDDATA; for (j = 0; j < height; j++) { - bytestream2_get_bufferu(&ctx->gb, dst, width); + bytestream2_get_bufferu(ctx->gb, dst, width); dst += width; } break; @@ -1563,7 +1563,7 @@ static int old_codec48(SANMVideoContext *ctx, int width, int height) } break; case 5: - if (bytestream2_get_bytes_left(&ctx->gb) < ((width + 1) >> 1) * ((height + 1) >> 1)) + if (bytestream2_get_bytes_left(ctx->gb) < ((width + 1) >> 1) * ((height + 1) >> 1)) return AVERROR_INVALIDDATA; codec47_comp1(ctx, dst, width, height, width); break; @@ -1581,14 +1581,14 @@ static int old_codec48(SANMVideoContext *ctx, int width, int height) static int process_frame_obj(SANMVideoContext *ctx) { uint16_t parm2; - uint8_t codec = bytestream2_get_byteu(&ctx->gb); - uint8_t param = bytestream2_get_byteu(&ctx->gb); - int16_t left = bytestream2_get_le16u(&ctx->gb); - int16_t top = bytestream2_get_le16u(&ctx->gb); - uint16_t w = bytestream2_get_le16u(&ctx->gb); - uint16_t h = bytestream2_get_le16u(&ctx->gb); - bytestream2_skip(&ctx->gb, 2); - parm2 = bytestream2_get_le16u(&ctx->gb); + uint8_t codec = bytestream2_get_byteu(ctx->gb); + uint8_t param = bytestream2_get_byteu(ctx->gb); + int16_t left = bytestream2_get_le16u(ctx->gb); + int16_t top = bytestream2_get_le16u(ctx->gb); + uint16_t w = bytestream2_get_le16u(ctx->gb); + uint16_t h = bytestream2_get_le16u(ctx->gb); + bytestream2_skip(ctx->gb, 2); + parm2 = bytestream2_get_le16u(ctx->gb); if (w < 1 || h < 1 || w > 800 || h > 600 || left > 800 || top > 600) { av_log(ctx->avctx, AV_LOG_WARNING, @@ -1679,8 +1679,8 @@ static int process_xpal(SANMVideoContext *ctx, int size) uint8_t c[3]; int i, j; - bytestream2_skip(&ctx->gb, 2); - cmd = bytestream2_get_be16(&ctx->gb); + bytestream2_skip(ctx->gb, 2); + cmd = bytestream2_get_be16(ctx->gb); if (cmd == 1) { for (i = 0; i < PALETTE_DELTA; i += 3) { @@ -1700,11 +1700,11 @@ static int process_xpal(SANMVideoContext *ctx, int size) return AVERROR_INVALIDDATA; } for (i = 0; i < PALETTE_DELTA; i++) - dp[i] = bytestream2_get_le16u(&ctx->gb); + dp[i] = bytestream2_get_le16u(ctx->gb); if (size >= PALETTE_DELTA * 2 + 4 + PALETTE_SIZE * 3) { for (i = 0; i < PALETTE_SIZE; i++) - ctx->pal[i] = 0xFFU << 24 | bytestream2_get_be24u(&ctx->gb); + ctx->pal[i] = 0xFFU << 24 | bytestream2_get_be24u(ctx->gb); if (ctx->subversion < 2) ctx->pal[0] = 0xFFU << 24; } @@ -1717,13 +1717,13 @@ static int decode_0(SANMVideoContext *ctx) uint16_t *frm = ctx->frm0; int x, y; - if (bytestream2_get_bytes_left(&ctx->gb) < ctx->width * ctx->height * 2) { + if (bytestream2_get_bytes_left(ctx->gb) < ctx->width * ctx->height * 2) { av_log(ctx->avctx, AV_LOG_ERROR, "Insufficient data for raw frame.\n"); return AVERROR_INVALIDDATA; } for (y = 0; y < ctx->height; y++) { for (x = 0; x < ctx->width; x++) - frm[x] = bytestream2_get_le16u(&ctx->gb); + frm[x] = bytestream2_get_le16u(ctx->gb); frm += ctx->pitch; } return 0; @@ -1793,10 +1793,10 @@ static int opcode_0xf7(SANMVideoContext *ctx, int cx, int cy, int block_size, pt if (block_size == 2) { uint32_t indices; - if (bytestream2_get_bytes_left(&ctx->gb) < 4) + if (bytestream2_get_bytes_left(ctx->gb) < 4) return AVERROR_INVALIDDATA; - indices = bytestream2_get_le32u(&ctx->gb); + indices = bytestream2_get_le32u(ctx->gb); dst[0] = ctx->codebook[indices & 0xFF]; indices >>= 8; dst[1] = ctx->codebook[indices & 0xFF]; @@ -1808,12 +1808,12 @@ static int opcode_0xf7(SANMVideoContext *ctx, int cx, int cy, int block_size, pt uint16_t fgcolor, bgcolor; int glyph; - if (bytestream2_get_bytes_left(&ctx->gb) < 3) + if (bytestream2_get_bytes_left(ctx->gb) < 3) return AVERROR_INVALIDDATA; - glyph = bytestream2_get_byteu(&ctx->gb); - bgcolor = ctx->codebook[bytestream2_get_byteu(&ctx->gb)]; - fgcolor = ctx->codebook[bytestream2_get_byteu(&ctx->gb)]; + glyph = bytestream2_get_byteu(ctx->gb); + bgcolor = ctx->codebook[bytestream2_get_byteu(ctx->gb)]; + fgcolor = ctx->codebook[bytestream2_get_byteu(ctx->gb)]; draw_glyph(ctx, dst, glyph, fgcolor, bgcolor, block_size, pitch); } @@ -1825,23 +1825,23 @@ static int opcode_0xf8(SANMVideoContext *ctx, int cx, int cy, int block_size, pt uint16_t *dst = ctx->frm0 + cx + cy * ctx->pitch; if (block_size == 2) { - if (bytestream2_get_bytes_left(&ctx->gb) < 8) + if (bytestream2_get_bytes_left(ctx->gb) < 8) return AVERROR_INVALIDDATA; - dst[0] = bytestream2_get_le16u(&ctx->gb); - dst[1] = bytestream2_get_le16u(&ctx->gb); - dst[pitch] = bytestream2_get_le16u(&ctx->gb); - dst[pitch + 1] = bytestream2_get_le16u(&ctx->gb); + dst[0] = bytestream2_get_le16u(ctx->gb); + dst[1] = bytestream2_get_le16u(ctx->gb); + dst[pitch] = bytestream2_get_le16u(ctx->gb); + dst[pitch + 1] = bytestream2_get_le16u(ctx->gb); } else { uint16_t fgcolor, bgcolor; int glyph; - if (bytestream2_get_bytes_left(&ctx->gb) < 5) + if (bytestream2_get_bytes_left(ctx->gb) < 5) return AVERROR_INVALIDDATA; - glyph = bytestream2_get_byteu(&ctx->gb); - bgcolor = bytestream2_get_le16u(&ctx->gb); - fgcolor = bytestream2_get_le16u(&ctx->gb); + glyph = bytestream2_get_byteu(ctx->gb); + bgcolor = bytestream2_get_le16u(ctx->gb); + fgcolor = bytestream2_get_le16u(ctx->gb); draw_glyph(ctx, dst, glyph, fgcolor, bgcolor, block_size, pitch); } @@ -1869,10 +1869,10 @@ static int codec2subblock(SANMVideoContext *ctx, int cx, int cy, int blk_size) int16_t mx, my, index; int opcode; - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; - opcode = bytestream2_get_byteu(&ctx->gb); + opcode = bytestream2_get_byteu(ctx->gb); switch (opcode) { default: @@ -1886,9 +1886,9 @@ static int codec2subblock(SANMVideoContext *ctx, int cx, int cy, int blk_size) } break; case 0xF5: - if (bytestream2_get_bytes_left(&ctx->gb) < 2) + if (bytestream2_get_bytes_left(ctx->gb) < 2) return AVERROR_INVALIDDATA; - index = bytestream2_get_le16u(&ctx->gb); + index = bytestream2_get_le16u(ctx->gb); mx = index % ctx->width; my = index / ctx->width; @@ -1919,16 +1919,16 @@ static int codec2subblock(SANMVideoContext *ctx, int cx, int cy, int blk_size) ctx->small_codebook[opcode - 0xf9], blk_size, ctx->pitch); break; case 0xFD: - if (bytestream2_get_bytes_left(&ctx->gb) < 1) + if (bytestream2_get_bytes_left(ctx->gb) < 1) return AVERROR_INVALIDDATA; fill_block(ctx->frm0 + cx + cy * ctx->pitch, - ctx->codebook[bytestream2_get_byteu(&ctx->gb)], blk_size, ctx->pitch); + ctx->codebook[bytestream2_get_byteu(ctx->gb)], blk_size, ctx->pitch); break; case 0xFE: - if (bytestream2_get_bytes_left(&ctx->gb) < 2) + if (bytestream2_get_bytes_left(ctx->gb) < 2) return AVERROR_INVALIDDATA; fill_block(ctx->frm0 + cx + cy * ctx->pitch, - bytestream2_get_le16u(&ctx->gb), blk_size, ctx->pitch); + bytestream2_get_le16u(ctx->gb), blk_size, ctx->pitch); break; case 0xFF: if (blk_size == 2) { @@ -2001,12 +2001,12 @@ static int decode_6(SANMVideoContext *ctx) int npixels = ctx->npixels; uint16_t *frm = ctx->frm0; - if (bytestream2_get_bytes_left(&ctx->gb) < npixels) { + if (bytestream2_get_bytes_left(ctx->gb) < npixels) { av_log(ctx->avctx, AV_LOG_ERROR, "Insufficient data for frame.\n"); return AVERROR_INVALIDDATA; } while (npixels--) - *frm++ = ctx->codebook[bytestream2_get_byteu(&ctx->gb)]; + *frm++ = ctx->codebook[bytestream2_get_byteu(ctx->gb)]; return 0; } @@ -2044,38 +2044,38 @@ static int read_frame_header(SANMVideoContext *ctx, SANMFrameHeader *hdr) { int i, ret; - if ((ret = bytestream2_get_bytes_left(&ctx->gb)) < 560) { + if ((ret = bytestream2_get_bytes_left(ctx->gb)) < 560) { av_log(ctx->avctx, AV_LOG_ERROR, "Input frame too short (%d bytes).\n", ret); return AVERROR_INVALIDDATA; } - bytestream2_skip(&ctx->gb, 8); // skip pad + bytestream2_skip(ctx->gb, 8); // skip pad - hdr->width = bytestream2_get_le32u(&ctx->gb); - hdr->height = bytestream2_get_le32u(&ctx->gb); + hdr->width = bytestream2_get_le32u(ctx->gb); + hdr->height = bytestream2_get_le32u(ctx->gb); if (hdr->width != ctx->width || hdr->height != ctx->height) { avpriv_report_missing_feature(ctx->avctx, "Variable size frames"); return AVERROR_PATCHWELCOME; } - hdr->seq_num = bytestream2_get_le16u(&ctx->gb); - hdr->codec = bytestream2_get_byteu(&ctx->gb); - hdr->rotate_code = bytestream2_get_byteu(&ctx->gb); + hdr->seq_num = bytestream2_get_le16u(ctx->gb); + hdr->codec = bytestream2_get_byteu(ctx->gb); + hdr->rotate_code = bytestream2_get_byteu(ctx->gb); - bytestream2_skip(&ctx->gb, 4); // skip pad + bytestream2_skip(ctx->gb, 4); // skip pad for (i = 0; i < 4; i++) - ctx->small_codebook[i] = bytestream2_get_le16u(&ctx->gb); - hdr->bg_color = bytestream2_get_le16u(&ctx->gb); + ctx->small_codebook[i] = bytestream2_get_le16u(ctx->gb); + hdr->bg_color = bytestream2_get_le16u(ctx->gb); - bytestream2_skip(&ctx->gb, 2); // skip pad + bytestream2_skip(ctx->gb, 2); // skip pad - hdr->rle_output_size = bytestream2_get_le32u(&ctx->gb); + hdr->rle_output_size = bytestream2_get_le32u(ctx->gb); for (i = 0; i < 256; i++) - ctx->codebook[i] = bytestream2_get_le16u(&ctx->gb); + ctx->codebook[i] = bytestream2_get_le16u(ctx->gb); - bytestream2_skip(&ctx->gb, 8); // skip pad + bytestream2_skip(ctx->gb, 8); // skip pad return 0; } @@ -2114,10 +2114,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *pkt) { SANMVideoContext *ctx = avctx->priv_data; + GetByteContext gb; int i, ret; ctx->frame = frame; - bytestream2_init(&ctx->gb, pkt->data, pkt->size); + bytestream2_init(&gb, pkt->data, pkt->size); + ctx->gb = &gb; if (!ctx->version) { int to_store = 0, have_pic = 0; @@ -2126,15 +2128,15 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, if (ctx->frm0_size) memset(ctx->frm0, 0, ctx->frm0_size); - while (bytestream2_get_bytes_left(&ctx->gb) >= 8) { + while (bytestream2_get_bytes_left(ctx->gb) >= 8) { uint32_t sig, size; int pos; - sig = bytestream2_get_be32u(&ctx->gb); - size = bytestream2_get_be32u(&ctx->gb); - pos = bytestream2_tell(&ctx->gb); + sig = bytestream2_get_be32u(ctx->gb); + size = bytestream2_get_be32u(ctx->gb); + pos = bytestream2_tell(ctx->gb); - if (bytestream2_get_bytes_left(&ctx->gb) < size) { + if (bytestream2_get_bytes_left(ctx->gb) < size) { av_log(avctx, AV_LOG_ERROR, "Incorrect chunk size %"PRIu32".\n", size); break; } @@ -2146,7 +2148,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, return AVERROR_INVALIDDATA; } for (i = 0; i < PALETTE_SIZE; i++) - ctx->pal[i] = 0xFFU << 24 | bytestream2_get_be24u(&ctx->gb); + ctx->pal[i] = 0xFFU << 24 | bytestream2_get_be24u(ctx->gb); if (ctx->subversion < 2) ctx->pal[0] = 0xFFU << 24; break; @@ -2169,15 +2171,15 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, have_pic = 1; break; default: - bytestream2_skip(&ctx->gb, size); + bytestream2_skip(ctx->gb, size); av_log(avctx, AV_LOG_DEBUG, "Unknown/unsupported chunk %"PRIx32".\n", sig); break; } - bytestream2_seek(&ctx->gb, pos + size, SEEK_SET); + bytestream2_seek(ctx->gb, pos + size, SEEK_SET); if (size & 1) - bytestream2_skip(&ctx->gb, 1); + bytestream2_skip(ctx->gb, 1); } if (to_store) memcpy(ctx->stored_frame, ctx->frm0, ctx->buf_size); -- 2.48.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".