avcodec/smc: Move transient GetByteContext from context to stack

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
pull/388/head
Andreas Rheinhardt 2 years ago
parent 6a8b3e7eb1
commit 353108bfab
  1. 11
      libavcodec/smc.c

@ -46,8 +46,6 @@ typedef struct SmcContext {
AVCodecContext *avctx; AVCodecContext *avctx;
AVFrame *frame; AVFrame *frame;
GetByteContext gb;
/* SMC color tables */ /* SMC color tables */
uint8_t color_pairs[COLORS_PER_TABLE * CPAIR]; uint8_t color_pairs[COLORS_PER_TABLE * CPAIR];
uint8_t color_quads[COLORS_PER_TABLE * CQUAD]; uint8_t color_quads[COLORS_PER_TABLE * CQUAD];
@ -75,9 +73,8 @@ typedef struct SmcContext {
} \ } \
} }
static int smc_decode_stream(SmcContext *s) static int smc_decode_stream(SmcContext *s, GetByteContext *gb)
{ {
GetByteContext *gb = &s->gb;
int width = s->avctx->width; int width = s->avctx->width;
int height = s->avctx->height; int height = s->avctx->height;
int stride = s->frame->linesize[0]; int stride = s->frame->linesize[0];
@ -430,20 +427,20 @@ static int smc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
SmcContext *s = avctx->priv_data; SmcContext *s = avctx->priv_data;
GetByteContext gb;
int ret; int ret;
int total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4); int total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
if (total_blocks / 1024 > avpkt->size) if (total_blocks / 1024 > avpkt->size)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
bytestream2_init(&s->gb, buf, buf_size);
if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0) if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
return ret; return ret;
s->frame->palette_has_changed = ff_copy_palette(s->pal, avpkt, avctx); s->frame->palette_has_changed = ff_copy_palette(s->pal, avpkt, avctx);
ret = smc_decode_stream(s); bytestream2_init(&gb, buf, buf_size);
ret = smc_decode_stream(s, &gb);
if (ret < 0) if (ret < 0)
return ret; return ret;

Loading…
Cancel
Save