summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <[email protected]>2025-06-13 01:38:43 +0200
committerAndreas Rheinhardt <[email protected]>2025-06-21 22:08:52 +0200
commit13527b39bb1c07881bbfab220ea3ce48da273d98 (patch)
tree388cc8da9b2b8605b23b9f0498645515b2bddcc6
parent514e5ea0db841416c0bc86bb536c83ecdae2dc2f (diff)
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 <[email protected]>
-rw-r--r--libavcodec/h263.h8
-rw-r--r--libavcodec/h263dec.c3
-rw-r--r--libavcodec/mpeg4videodec.c6
-rw-r--r--libavcodec/mpegvideo.c2
-rw-r--r--libavcodec/mpegvideo_enc.c7
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;