[FFmpeg-cvslog] avcodec/mpegvideo: Redo resetting intra table entry

Andreas Rheinhardt git at videolan.org
Sat Jun 21 23:21:05 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Jun 13 01:38:43 2025 +0200| [13527b39bb1c07881bbfab220ea3ce48da273d98] | committer: Andreas Rheinhardt

avcodec/mpegvideo: Redo resetting intra table entry

All callers check the corresponding entry of MpegEncContext.mbintra_table
and if set (indicating that the intra tables might have been written to
when decodeing a intra MB, so that they are "dirty"), call
ff_clean_intra_table_entries(), which resets them to default values
and resets the mbintra_table entry. Move resetting to the callers
(via an inline function that also performs the checks). This currently
has the advantage that the additional load of the mbintra_table ptr
can be avoided. It will also allow to simplify
ff_clean_intra_table_entries() (by using block_index[4] and [5]).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=13527b39bb1c07881bbfab220ea3ce48da273d98
---

 libavcodec/h263.h          | 8 ++++++++
 libavcodec/h263dec.c       | 3 +--
 libavcodec/mpeg4videodec.c | 6 ++----
 libavcodec/mpegvideo.c     | 2 --
 libavcodec/mpegvideo_enc.c | 7 +++++--
 5 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/libavcodec/h263.h b/libavcodec/h263.h
index 59f937070e..2fee0df4cd 100644
--- a/libavcodec/h263.h
+++ b/libavcodec/h263.h
@@ -44,4 +44,12 @@ void ff_h263_init_rl_inter(void);
 void ff_h263_update_motion_val(MpegEncContext * s);
 void ff_h263_loop_filter(MpegEncContext * s);
 
+static inline void ff_h263_clean_intra_table_entries(MpegEncContext *s, int xy)
+{
+    if (s->mbintra_table[xy]) {
+        s->mbintra_table[xy] = 0;
+        ff_clean_intra_table_entries(s);
+    }
+}
+
 #endif /* AVCODEC_H263_H */
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 37abf3382e..52b17663db 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -260,8 +260,7 @@ static int decode_slice(MpegEncContext *s)
             if (s->h263_pred || s->h263_aic) {
                 int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
                 if (!s->mb_intra) {
-                    if (s->mbintra_table[mb_xy])
-                        ff_clean_intra_table_entries(s);
+                    ff_h263_clean_intra_table_entries(s, mb_xy);
                 } else
                     s->mbintra_table[mb_xy] = 1;
             }
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 32b2dec1d6..1294138d05 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1073,8 +1073,7 @@ try_again:
                     mot_val[1 + stride] =
                     mot_val[3 + stride] = my;
 
-                    if (s->mbintra_table[xy])
-                        ff_clean_intra_table_entries(s);
+                    ff_h263_clean_intra_table_entries(s, xy);
                     continue;
                 }
 
@@ -1103,8 +1102,7 @@ try_again:
                     mot_val[1 + stride] =
                     mot_val[3 + stride] = 0;
                 } else {
-                    if (s->mbintra_table[xy])
-                        ff_clean_intra_table_entries(s);
+                    ff_h263_clean_intra_table_entries(s, xy);
 
                     if (s->pict_type == AV_PICTURE_TYPE_S &&
                         ctx->vol_sprite_usage == GMC_SPRITE &&
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index f6e997193d..b8f0957ec5 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -508,8 +508,6 @@ void ff_clean_intra_table_entries(MpegEncContext *s)
     /* ac pred */
     memset(s->ac_val[1][xy], 0, 16 * sizeof(int16_t));
     memset(s->ac_val[2][xy], 0, 16 * sizeof(int16_t));
-
-    s->mbintra_table[xy]= 0;
 }
 
 void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 60abe08d7a..04cebee9c6 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3559,8 +3559,11 @@ static int encode_thread(AVCodecContext *c, void *arg){
             if (s->c.mb_intra /* && I,P,S_TYPE */) {
                 s->p_mv_table[xy][0]=0;
                 s->p_mv_table[xy][1]=0;
-            } else if ((s->c.h263_pred || s->c.h263_aic) && s->c.mbintra_table[xy])
-                ff_clean_intra_table_entries(&s->c);
+#if CONFIG_H263_ENCODER
+            } else if (s->c.h263_pred || s->c.h263_aic) {
+                ff_h263_clean_intra_table_entries(&s->c, xy);
+#endif
+            }
 
             if (s->c.avctx->flags & AV_CODEC_FLAG_PSNR) {
                 int w= 16;



More information about the ffmpeg-cvslog mailing list