From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/bethsoftvideo: Pass GetByteContext into set_palette()
Date: Fri, 19 Aug 2022 00:35:32 +0200
Message-ID: <20220818223535.13078-1-michael@niedermayer.cc> (raw)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
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".
next reply other threads:[~2022-08-18 22:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-18 22:35 Michael Niedermayer [this message]
2022-08-18 22:35 ` [FFmpeg-devel] [PATCH 2/4] avcodec/bethsoftvideo: Check block_type before frame alloc Michael Niedermayer
2022-08-28 17:40 ` Michael Niedermayer
2022-08-18 22:35 ` [FFmpeg-devel] [PATCH 3/4] tools/target_dec_fuzzer: Adjust threshold for bethsoftvid Michael Niedermayer
2022-08-28 17:41 ` Michael Niedermayer
2022-08-18 22:35 ` [FFmpeg-devel] [PATCH 4/4] avcodec/speedhq: Check width Michael Niedermayer
2022-08-21 10:54 ` Paul B Mahol
2022-08-21 14:23 ` Michael Niedermayer
2022-08-28 17:39 ` Michael Niedermayer
2022-09-02 9:02 ` Michael Niedermayer
2022-08-28 17:41 ` [FFmpeg-devel] [PATCH 1/4] avcodec/bethsoftvideo: Pass GetByteContext into set_palette() Michael Niedermayer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220818223535.13078-1-michael@niedermayer.cc \
--to=michael@niedermayer.cc \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git