Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH v2 22/24] avcodec/eatgq: Move transient GetByteContext from context to stack
Date: Fri, 21 Oct 2022 22:12:58 +0200
Message-ID: <AS8P250MB0744E57CFCD44D5D4C1185BF8F2D9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB07440727410EF826F84418C68F2D9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/eatgq.c | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c
index 627615b4e8..89e9f20880 100644
--- a/libavcodec/eatgq.c
+++ b/libavcodec/eatgq.c
@@ -45,7 +45,6 @@ typedef struct TgqContext {
     int width, height;
     int qtable[64];
     DECLARE_ALIGNED(16, int16_t, block)[6][64];
-    GetByteContext gb;
 } TgqContext;
 
 static av_cold int tgq_decode_init(AVCodecContext *avctx)
@@ -147,34 +146,35 @@ static void tgq_idct_put_mb_dconly(TgqContext *s, AVFrame *frame,
     }
 }
 
-static int tgq_decode_mb(TgqContext *s, AVFrame *frame, int mb_y, int mb_x)
+static int tgq_decode_mb(TgqContext *s, GetByteContext *gbyte,
+                         AVFrame *frame, int mb_y, int mb_x)
 {
     int mode;
     int i;
     int8_t dc[6];
 
-    mode = bytestream2_get_byte(&s->gb);
+    mode = bytestream2_get_byte(gbyte);
     if (mode > 12) {
         GetBitContext gb;
-        int ret = init_get_bits8(&gb, s->gb.buffer, FFMIN(bytestream2_get_bytes_left(&s->gb), mode));
+        int ret = init_get_bits8(&gb, gbyte->buffer, FFMIN(bytestream2_get_bytes_left(gbyte), mode));
         if (ret < 0)
             return ret;
 
         for (i = 0; i < 6; i++)
             tgq_decode_block(s, s->block[i], &gb);
         tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y);
-        bytestream2_skip(&s->gb, mode);
+        bytestream2_skip(gbyte, mode);
     } else {
         if (mode == 3) {
-            memset(dc, bytestream2_get_byte(&s->gb), 4);
-            dc[4] = bytestream2_get_byte(&s->gb);
-            dc[5] = bytestream2_get_byte(&s->gb);
+            memset(dc, bytestream2_get_byte(gbyte), 4);
+            dc[4] = bytestream2_get_byte(gbyte);
+            dc[5] = bytestream2_get_byte(gbyte);
         } else if (mode == 6) {
-            bytestream2_get_buffer(&s->gb, dc, 6);
+            bytestream2_get_buffer(gbyte, dc, 6);
         } else if (mode == 12) {
             for (i = 0; i < 6; i++) {
-                dc[i] = bytestream2_get_byte(&s->gb);
-                bytestream2_skip(&s->gb, 1);
+                dc[i] = bytestream2_get_byte(gbyte);
+                bytestream2_skip(gbyte, 1);
             }
         } else {
             av_log(s->avctx, AV_LOG_ERROR, "unsupported mb mode %i\n", mode);
@@ -202,6 +202,7 @@ static int tgq_decode_frame(AVCodecContext *avctx, AVFrame *frame,
     const uint8_t *buf = avpkt->data;
     int buf_size       = avpkt->size;
     TgqContext *s      = avctx->priv_data;
+    GetByteContext gbyte;
     int x, y, ret;
     int big_endian;
 
@@ -210,21 +211,21 @@ static int tgq_decode_frame(AVCodecContext *avctx, AVFrame *frame,
         return AVERROR_INVALIDDATA;
     }
     big_endian = AV_RL32(&buf[4]) > 0x000FFFFF;
-    bytestream2_init(&s->gb, buf + 8, buf_size - 8);
+    bytestream2_init(&gbyte, buf + 8, buf_size - 8);
     if (big_endian) {
-        s->width  = bytestream2_get_be16u(&s->gb);
-        s->height = bytestream2_get_be16u(&s->gb);
+        s->width  = bytestream2_get_be16u(&gbyte);
+        s->height = bytestream2_get_be16u(&gbyte);
     } else {
-        s->width  = bytestream2_get_le16u(&s->gb);
-        s->height = bytestream2_get_le16u(&s->gb);
+        s->width  = bytestream2_get_le16u(&gbyte);
+        s->height = bytestream2_get_le16u(&gbyte);
     }
 
     ret = ff_set_dimensions(s->avctx, s->width, s->height);
     if (ret < 0)
         return ret;
 
-    tgq_calculate_qtable(s, bytestream2_get_byteu(&s->gb));
-    bytestream2_skip(&s->gb, 3);
+    tgq_calculate_qtable(s, bytestream2_get_byteu(&gbyte));
+    bytestream2_skipu(&gbyte, 3);
 
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
@@ -233,7 +234,7 @@ static int tgq_decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
     for (y = 0; y < FFALIGN(avctx->height, 16) >> 4; y++)
         for (x = 0; x < FFALIGN(avctx->width, 16) >> 4; x++)
-            if (tgq_decode_mb(s, frame, y, x) < 0)
+            if (tgq_decode_mb(s, &gbyte, frame, y, x) < 0)
                 return AVERROR_INVALIDDATA;
 
     *got_frame = 1;
-- 
2.34.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".

  parent reply	other threads:[~2022-10-21 20:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-21 20:11 [FFmpeg-devel] [PATCH v2 01/24] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 02/24] avcodec/eamad: Don't use IDCTDSP-API unnecessarily Andreas Rheinhardt
2022-10-22  0:07   ` Peter Ross
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 03/24] avcodec/eatgq: " Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 04/24] avcodec/eatqi: " Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 05/24] avcodec/aic: Remove useless ScanTable Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 06/24] avcodec/imm4: " Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 07/24] avcodec/idctdsp: Add function to apply permutation to array Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 08/24] avcodec/agm: Only keep what is used from ScanTable Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 09/24] avcodec/asvdec: " Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 10/24] avcodec/dnxhddec: " Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 11/24] avcodec/cavs: Only keep what is needed from IDCTDSP-API Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 12/24] avcodec/g2meet: Only keep what is used from ScanTable Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 13/24] avcodec/g2meet: Pre-permute quantization tables Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 14/24] avcodec/intrax8: Only keep what is used from ScanTable Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 15/24] avcodec/mdec: " Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 16/24] avcodec/mimic: " Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 17/24] avcodec/mjpegdec: " Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 18/24] avcodec/mjpegenc_common: Only pass " Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 19/24] avcodec/speedhqdec: Only keep " Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 20/24] avcodec/wmv2dec: Remove unnecessary ScanTables Andreas Rheinhardt
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 21/24] avcodec/idctdsp: Move ScanTable to mpegvideo Andreas Rheinhardt
2022-10-21 20:12 ` Andreas Rheinhardt [this message]
2022-10-21 20:12 ` [FFmpeg-devel] [PATCH v2 23/24] avcodec/mpegvideo: Move ASM-offset warning to its proper place Andreas Rheinhardt
2022-10-21 20:13 ` [FFmpeg-devel] [PATCH v2 24/24] avcodec/mpegvideo: Don't use ScanTable where unnecessary Andreas Rheinhardt
2022-10-23 11:17 ` [FFmpeg-devel] [PATCH v2 01/24] configure: Add idctdsp dependency to codecs that need it Andreas Rheinhardt

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=AS8P250MB0744E57CFCD44D5D4C1185BF8F2D9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --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