History

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]).

Andreas Rheinhardt committed 1 year ago

Commit 13527b31 parent 514e5ea5 files · +16 −10Browse files

Unified · Split

5 files
  1. libavcodec/h263.h +8 −0
  2. libavcodec/h263dec.c +1 −2
  3. libavcodec/mpeg4videodec.c +2 −4
  4. libavcodec/mpegvideo.c +0 −2
  5. libavcodec/mpegvideo_enc.c +5 −2
libavcodec/h263.h+8−0
@@ -44,4 +44,12 @@ void ff_h263_init_rl_inter(void); · 43 unmodified lines
4444 void ff_h263_update_motion_val(MpegEncContext * s);
4545 void ff_h263_loop_filter(MpegEncContext * s);
4646
47+static inline void ff_h263_clean_intra_table_entries(MpegEncContext *s, int xy)
48+{
49+ if (s->mbintra_table[xy]) {
50+ s->mbintra_table[xy] = 0;
51+ ff_clean_intra_table_entries(s);
52+ }
53+}
54+
4755 #endif /* AVCODEC_H263_H */
libavcodec/h263dec.c+1−2
@@ -260,8 +260,7 @@ static int decode_slice(MpegEncContext *s) · 259 unmodified lines
260260 if (s->h263_pred || s->h263_aic) {
261261 int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
262262 if (!s->mb_intra) {
263− if (s->mbintra_table[mb_xy])
264− ff_clean_intra_table_entries(s);
263+ ff_h263_clean_intra_table_entries(s, mb_xy);
265264 } else
266265 s->mbintra_table[mb_xy] = 1;
267266 }
libavcodec/mpeg4videodec.c+2−4
@@ -1073,8 +1073,7 @@ try_again: · 1072 unmodified lines
10731073 mot_val[1 + stride] =
10741074 mot_val[3 + stride] = my;
10751075
1076− if (s->mbintra_table[xy])
1077− ff_clean_intra_table_entries(s);
1076+ ff_h263_clean_intra_table_entries(s, xy);
10781077 continue;
10791078 }
10801079
@@ -1103,8 +1102,7 @@ try_again: · 22 unmodified lines
11031102 mot_val[1 + stride] =
11041103 mot_val[3 + stride] = 0;
11051104 } else {
1106− if (s->mbintra_table[xy])
1107− ff_clean_intra_table_entries(s);
1105+ ff_h263_clean_intra_table_entries(s, xy);
11081106
11091107 if (s->pict_type == AV_PICTURE_TYPE_S &&
11101108 ctx->vol_sprite_usage == GMC_SPRITE &&
libavcodec/mpegvideo.c+0−2
@@ -508,8 +508,6 @@ void ff_clean_intra_table_entries(MpegEncContext *s) · 507 unmodified lines
508508 /* ac pred */
509509 memset(s->ac_val[1][xy], 0, 16 * sizeof(int16_t));
510510 memset(s->ac_val[2][xy], 0, 16 * sizeof(int16_t));
511−
512− s->mbintra_table[xy]= 0;
513511 }
514512
515513 void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
libavcodec/mpegvideo_enc.c+5−2
@@ -3559,8 +3559,11 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 3558 unmodified lines
35593559 if (s->c.mb_intra /* && I,P,S_TYPE */) {
35603560 s->p_mv_table[xy][0]=0;
35613561 s->p_mv_table[xy][1]=0;
3562− } else if ((s->c.h263_pred || s->c.h263_aic) && s->c.mbintra_table[xy])
3563− ff_clean_intra_table_entries(&s->c);
3562+#if CONFIG_H263_ENCODER
3563+ } else if (s->c.h263_pred || s->c.h263_aic) {
3564+ ff_h263_clean_intra_table_entries(&s->c, xy);
3565+#endif
3566+ }
35643567
35653568 if (s->c.avctx->flags & AV_CODEC_FLAG_PSNR) {
35663569 int w= 16;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t