diff mbox series

[FFmpeg-devel,3/6] avcodec/smc: Move transient GetByteContext from context to stack

Message ID GV1P250MB0737869FD453209F4702525C8F4A9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 353108bfab46903b06343fb6f0e4d32fb0fdfb1e
Headers show
Series [FFmpeg-devel,1/6] fate/ffmpeg: Use transcode instead of enc_dec in shortest-sub test | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 18, 2022, 2:01 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/smc.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/smc.c b/libavcodec/smc.c
index e6d01791c2..2b10e74386 100644
--- a/libavcodec/smc.c
+++ b/libavcodec/smc.c
@@ -46,8 +46,6 @@  typedef struct SmcContext {
     AVCodecContext *avctx;
     AVFrame *frame;
 
-    GetByteContext gb;
-
     /* SMC color tables */
     uint8_t color_pairs[COLORS_PER_TABLE * CPAIR];
     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 height = s->avctx->height;
     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;
     int buf_size = avpkt->size;
     SmcContext *s = avctx->priv_data;
+    GetByteContext gb;
     int ret;
     int total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
 
     if (total_blocks / 1024 > avpkt->size)
         return AVERROR_INVALIDDATA;
 
-    bytestream2_init(&s->gb, buf, buf_size);
-
     if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
         return ret;
 
     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)
         return ret;