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 <ffmpegagent-at-gmail.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 37/48] avcodec/mpegvideo: Move mb_skip_run to {RV34Dec, MPVEnc}Context
Date: Mon, 23 Jun 2025 13:36:37 +0000
Message-ID: <686a0b9ef9526fb2c6eee384419b4365317e797d.1750685809.git.ffmpegagent@gmail.com> (raw)
In-Reply-To: <pull.102.ffstaging.FFmpeg.1750685808.ffmpegagent@gmail.com>

From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h261enc.c       | 12 ++++++------
 libavcodec/mpeg12enc.c     |  8 ++++----
 libavcodec/mpegvideo.h     |  1 -
 libavcodec/mpegvideo_enc.c | 11 ++++++-----
 libavcodec/mpegvideoenc.h  |  2 ++
 libavcodec/rv34.c          |  4 ++--
 libavcodec/rv34.h          |  1 +
 libavcodec/rv40.c          |  8 ++++----
 8 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index c217fb6233..466a0387c5 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -92,7 +92,7 @@ static int h261_encode_picture_header(MPVMainEncContext *const m)
 
     put_bits(&s->pb, 1, 0); /* no PEI */
     h->gob_number = h->format - 1;
-    s->c.mb_skip_run = 0;
+    s->mb_skip_run = 0;
 
     return 0;
 }
@@ -112,7 +112,7 @@ static void h261_encode_gob_header(MPVEncContext *const s, int mb_line)
     put_bits(&s->pb, 4, h->gob_number); /* GN */
     put_bits(&s->pb, 5, s->c.qscale);     /* GQUANT */
     put_bits(&s->pb, 1, 0);             /* no GEI */
-    s->c.mb_skip_run = 0;
+    s->mb_skip_run = 0;
     s->c.last_mv[0][0][0] = 0;
     s->c.last_mv[0][0][1] = 0;
 }
@@ -248,7 +248,7 @@ static void h261_encode_mb(MPVEncContext *const s, int16_t block[6][64],
 
         if ((cbp | mvd) == 0) {
             /* skip macroblock */
-            s->c.mb_skip_run++;
+            s->mb_skip_run++;
             s->c.last_mv[0][0][0] = 0;
             s->c.last_mv[0][0][1] = 0;
             s->c.qscale -= s->dquant;
@@ -258,9 +258,9 @@ static void h261_encode_mb(MPVEncContext *const s, int16_t block[6][64],
 
     /* MB is not skipped, encode MBA */
     put_bits(&s->pb,
-             ff_h261_mba_bits[s->c.mb_skip_run],
-             ff_h261_mba_code[s->c.mb_skip_run]);
-    s->c.mb_skip_run = 0;
+             ff_h261_mba_bits[s->mb_skip_run],
+             ff_h261_mba_code[s->mb_skip_run]);
+    s->mb_skip_run = 0;
 
     /* calculate MTYPE */
     if (!s->c.mb_intra) {
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 96957235e9..521a915aa0 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -688,7 +688,7 @@ static av_always_inline void mpeg1_encode_mb_internal(MPVEncContext *const s,
            ((s->c.mv_dir & MV_DIR_BACKWARD)
             ? ((s->c.mv[1][0][0] - s->c.last_mv[1][0][0]) |
                (s->c.mv[1][0][1] - s->c.last_mv[1][0][1])) : 0)) == 0))) {
-        s->c.mb_skip_run++;
+        s->mb_skip_run++;
         s->c.qscale -= s->dquant;
         s->misc_bits++;
         s->last_bits++;
@@ -700,10 +700,10 @@ static av_always_inline void mpeg1_encode_mb_internal(MPVEncContext *const s,
         }
     } else {
         if (first_mb) {
-            av_assert0(s->c.mb_skip_run == 0);
+            av_assert0(s->mb_skip_run == 0);
             encode_mb_skip_run(s, s->c.mb_x);
         } else {
-            encode_mb_skip_run(s, s->c.mb_skip_run);
+            encode_mb_skip_run(s, s->mb_skip_run);
         }
 
         if (s->c.pict_type == AV_PICTURE_TYPE_I) {
@@ -925,7 +925,7 @@ static av_always_inline void mpeg1_encode_mb_internal(MPVEncContext *const s,
         for (i = 0; i < mb_block_count; i++)
             if (cbp & (1 << (mb_block_count - 1 - i)))
                 mpeg1_encode_block(s, block[i], i);
-        s->c.mb_skip_run = 0;
+        s->mb_skip_run = 0;
         if (s->c.mb_intra)
             s->i_tex_bits += get_bits_diff(s);
         else
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 7e92ac8be9..4c5f034690 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -196,7 +196,6 @@ typedef struct MpegEncContext {
 
     /* macroblock layer */
     int mb_x, mb_y;
-    int mb_skip_run;
     int mb_intra;
 
     int block_index[6]; ///< index to current MB in block based arrays with edges
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index afdc2fb787..a16cb6bd19 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2647,11 +2647,12 @@ typedef struct MBBackup {
         int last_mv[2][2][2];
         int mv_type, mv_dir;
         int last_dc[3];
-        int mb_intra, mb_skipped, mb_skip_run;
+        int mb_intra, mb_skipped;
         int qscale;
         int block_last_index[8];
         int interlaced_dct;
     } c;
+    int mb_skip_run;
     int mv_bits, i_tex_bits, p_tex_bits, i_count, misc_bits, last_bits;
     int dquant;
     int esc3_level_length;
@@ -2667,7 +2668,7 @@ static inline void BEFORE ##_context_before_encode(DST_TYPE *const d,       \
     memcpy(d->c.last_mv, s->c.last_mv, 2*2*2*sizeof(int));                  \
                                                                             \
     /* MPEG-1 */                                                            \
-    d->c.mb_skip_run = s->c.mb_skip_run;                                    \
+    d->mb_skip_run = s->mb_skip_run;                                        \
     for (int i = 0; i < 3; i++)                                             \
         d->c.last_dc[i] = s->c.last_dc[i];                                  \
                                                                             \
@@ -2695,7 +2696,7 @@ static inline void AFTER ## _context_after_encode(DST_TYPE *const d,        \
     memcpy(d->c.last_mv, s->c.last_mv, 2*2*2*sizeof(int));                  \
                                                                             \
     /* MPEG-1 */                                                            \
-    d->c.mb_skip_run = s->c.mb_skip_run;                                    \
+    d->mb_skip_run = s->mb_skip_run;                                        \
     for (int i = 0; i < 3; i++)                                             \
         d->c.last_dc[i] = s->c.last_dc[i];                                  \
                                                                             \
@@ -3029,7 +3030,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
         ff_mpeg4_init_partitions(s);
 #endif
     }
-    s->c.mb_skip_run = 0;
+    s->mb_skip_run = 0;
     memset(s->c.last_mv, 0, sizeof(s->c.last_mv));
 
     s->last_mv_dir = 0;
@@ -3108,7 +3109,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
                     if (s->c.mb_x == 0 && s->c.mb_y != 0) is_gob_start = 1;
                 case AV_CODEC_ID_MPEG1VIDEO:
                     if (s->c.codec_id == AV_CODEC_ID_MPEG1VIDEO && s->c.mb_y >= 175 ||
-                        s->c.mb_skip_run)
+                        s->mb_skip_run)
                         is_gob_start=0;
                     break;
                 case AV_CODEC_ID_MJPEG:
diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index 2a04abab26..7aa8af5412 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -136,6 +136,8 @@ typedef struct MPVEncContext {
     int misc_bits; ///< cbp, mb_type
     int last_bits; ///< temp var used for calculating the above vars
 
+    int mb_skip_run;
+
     /* H.263 specific */
     int mb_info;                   ///< interval for outputting info about mb offsets as side data
     int prev_mb_info, last_mb_info;
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index bb08c9bc5c..4feab95eb5 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1364,7 +1364,7 @@ static int check_slice_end(RV34DecContext *r, MpegEncContext *s)
         return 1;
     if (!r->mb_num_left)
         return 1;
-    if(r->s.mb_skip_run > 1)
+    if (r->mb_skip_run > 1)
         return 0;
     bits = get_bits_left(&r->gb);
     if (bits <= 0 || (bits < 8 && !show_bits(&r->gb, bits)))
@@ -1447,7 +1447,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
     r->si.end = end;
     s->qscale = r->si.quant;
     r->mb_num_left = r->si.end - r->si.start;
-    r->s.mb_skip_run = 0;
+    r->mb_skip_run = 0;
 
     mb_pos = s->mb_x + s->mb_y * s->mb_width;
     if(r->si.start != mb_pos){
diff --git a/libavcodec/rv34.h b/libavcodec/rv34.h
index 92bcbba933..85ab6b4c2c 100644
--- a/libavcodec/rv34.h
+++ b/libavcodec/rv34.h
@@ -99,6 +99,7 @@ typedef struct RV34DecContext{
     SliceInfo si;            ///< current slice information
 
     int mb_num_left;         ///< number of MBs left in this video packet
+    int mb_skip_run;
 
     int *mb_type;            ///< internal macroblock types
     int block_type;          ///< current block type
diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c
index 79e99e9efd..2b010295dd 100644
--- a/libavcodec/rv40.c
+++ b/libavcodec/rv40.c
@@ -231,13 +231,13 @@ static int rv40_decode_mb_info(RV34DecContext *r)
     int prev_type = 0;
     int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
 
-    if(!r->s.mb_skip_run) {
-        r->s.mb_skip_run = get_interleaved_ue_golomb(gb) + 1;
-        if(r->s.mb_skip_run > (unsigned)s->mb_num)
+    if (!r->mb_skip_run) {
+        r->mb_skip_run = get_interleaved_ue_golomb(gb) + 1;
+        if (r->mb_skip_run > (unsigned)s->mb_num)
             return -1;
     }
 
-    if(--r->s.mb_skip_run)
+    if (--r->mb_skip_run)
          return RV34_MB_SKIP;
 
     if(r->avail_cache[6-4]){
-- 
ffmpeg-codebot

_______________________________________________
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:[~2025-06-23 13:44 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 13:36 [FFmpeg-devel] [PATCH 00/48] H263DecContext ffmpegagent
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 01/48] avcodec/ituh263dec: Use correct logcontext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 02/48] avcodec/rl: Avoid branch in index lookup Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 03/48] avcodec/ituh263enc: Simplify creating LUT Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 04/48] avcodec/ituh263dec: Only initialize ff_h263_rl_inter when needed Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 05/48] avcodec/mpegvideoenc: Allocate blocks as part of MPVEncContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 06/48] avcodec/mpegvideo: Add MPVContext typedef Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 07/48] avcodec/mpegvideo_dec: Factor debugging dct coefficients out Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 08/48] avcodec/mpegvideo_dec: Reindent after the previous commit Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 09/48] avcodec/mpeg_er: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 10/48] avcodec/mpegvideodec: Remove size expectation from ff_mpv_reconstruct_mb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 11/48] avcodec/h261dec: Stop using MpegEncContext.gb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 12/48] avcodec/h261dec: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 13/48] avcodec/mpeg12dec: Put GetBitContext on the stack where advantageous Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 14/48] avcodec/mpeg12dec: Remove unused function parameter Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 15/48] avcodec/rv34: Don't use MpegEncContext.gb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 16/48] avcodec/rv34: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 17/48] avcodec/intrax8: Don't pretend to need more than one int16_t[64] Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 18/48] avcodec/vc1: Stop using MpegEncContext.gb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 19/48] avcodec/vc1: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 20/48] avcodec/mpeg12dec: Deduplicate variables Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 21/48] avcodec/mpegvideo: Move flipflop_rounding to {MSMPEG4Dec, MPVEnc}Context Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 22/48] avcodec/mpegvideo: Move unrestricted_mv to MotionEstContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 23/48] avcodec/mpeg4videodec: Avoid unnecessary indirections Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 24/48] avcodec/{h263, mpeg4video}dec: Pass MPVContext*, not Mpeg4DecContext* Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 25/48] avcodec/mpegvideo: Move dct_precision to Mpeg4DecContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 26/48] avcodec/h263dec: Add H263DecContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 27/48] avcodec/h263dec: Remove redundant block parameter from decode_mb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 28/48] avcodec/h263dec: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 29/48] avcodec/h263dec: Stop using MpegEncContext.gb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 30/48] avcodec/mpeg12dec: Add Mpeg12SliceContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 31/48] avcodec/mpegvideo: Add missing headers Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 32/48] avcodec/mpeg12dec: Move MpegEncContext.gb to Mpeg12SliceContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 33/48] avcodec/mpeg12dec: Don't use MPVContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 34/48] avcodec/mpegvideo: Move fields only used by H.263 decoders to H263DecCtx Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 35/48] avcodec/mpegvideo: Move mb_num_left to {H263, RV34}DecContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 36/48] avcodec/mpeg12dec: Put mb_skip_run on the stack Andreas Rheinhardt
2025-06-23 13:36 ` Andreas Rheinhardt [this message]
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 38/48] avcodec/mpegvideo: Move SLICE_* defs to h263dec.h, h261dec.c Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 39/48] avcodec/msmpeg4dec: Move ff_msmpeg4_decode_init() down Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 40/48] avcodec/h263dec: Use function ptr for decode_picture_header Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 41/48] avcodec/ituh263enc: Inline value of h263_flv Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 42/48] avcodec/flvdec: Binarize h263_flv Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 43/48] avcodec/mpegvideo: Move fields to {H263Dec, MPVEnc}Context when possible Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 44/48] avcodec/mpeg_er: Allow to skip setting partitioned_frame, p[pb]_time Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 45/48] avcodec/mpegvideo: Move partitioned_frame to {H263Dec, MPVEnc}Context Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 46/48] avcodec/mpegvideo: Move loop_filter to {H263Dec, MPVEnc, VC1}Context Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 47/48] avcodec/rv34: Don't report progress unnecessarily Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 48/48] avcodec/rv34: Fix spelling mistake 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=686a0b9ef9526fb2c6eee384419b4365317e797d.1750685809.git.ffmpegagent@gmail.com \
    --to=ffmpegagent-at-gmail.com@ffmpeg.org \
    --cc=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