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]).
Unified · Split
| @@ -44,4 +44,12 @@ void ff_h263_init_rl_inter(void); · 43 unmodified lines | |||
| 44 | void ff_h263_update_motion_val(MpegEncContext * s); | 44 | void ff_h263_update_motion_val(MpegEncContext * s); |
| 45 | void ff_h263_loop_filter(MpegEncContext * s); | 45 | void ff_h263_loop_filter(MpegEncContext * s); |
| 46 | 46 | ||
| 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 | |||
| 47 | #endif /* AVCODEC_H263_H */ | 55 | #endif /* AVCODEC_H263_H */ |
| @@ -260,8 +260,7 @@ static int decode_slice(MpegEncContext *s) · 259 unmodified lines | |||
| 260 | if (s->h263_pred || s->h263_aic) { | 260 | if (s->h263_pred || s->h263_aic) { |
| 261 | int mb_xy = s->mb_y * s->mb_stride + s->mb_x; | 261 | int mb_xy = s->mb_y * s->mb_stride + s->mb_x; |
| 262 | if (!s->mb_intra) { | 262 | if (!s->mb_intra) { |
| 263 | if (s->mbintra_table[mb_xy]) | 263 | ff_h263_clean_intra_table_entries(s, mb_xy); |
| 264 | ff_clean_intra_table_entries(s); | ||
| 265 | } else | 264 | } else |
| 266 | s->mbintra_table[mb_xy] = 1; | 265 | s->mbintra_table[mb_xy] = 1; |
| 267 | } | 266 | } |
| @@ -1073,8 +1073,7 @@ try_again: · 1072 unmodified lines | |||
| 1073 | mot_val[1 + stride] = | 1073 | mot_val[1 + stride] = |
| 1074 | mot_val[3 + stride] = my; | 1074 | mot_val[3 + stride] = my; |
| 1075 | 1075 | ||
| 1076 | if (s->mbintra_table[xy]) | 1076 | ff_h263_clean_intra_table_entries(s, xy); |
| 1077 | ff_clean_intra_table_entries(s); | ||
| 1078 | continue; | 1077 | continue; |
| 1079 | } | 1078 | } |
| 1080 | 1079 | ||
| @@ -1103,8 +1102,7 @@ try_again: · 22 unmodified lines | |||
| 1103 | mot_val[1 + stride] = | 1102 | mot_val[1 + stride] = |
| 1104 | mot_val[3 + stride] = 0; | 1103 | mot_val[3 + stride] = 0; |
| 1105 | } else { | 1104 | } else { |
| 1106 | if (s->mbintra_table[xy]) | 1105 | ff_h263_clean_intra_table_entries(s, xy); |
| 1107 | ff_clean_intra_table_entries(s); | ||
| 1108 | 1106 | ||
| 1109 | if (s->pict_type == AV_PICTURE_TYPE_S && | 1107 | if (s->pict_type == AV_PICTURE_TYPE_S && |
| 1110 | ctx->vol_sprite_usage == GMC_SPRITE && | 1108 | ctx->vol_sprite_usage == GMC_SPRITE && |
| @@ -508,8 +508,6 @@ void ff_clean_intra_table_entries(MpegEncContext *s) · 507 unmodified lines | |||
| 508 | /* ac pred */ | 508 | /* ac pred */ |
| 509 | memset(s->ac_val[1][xy], 0, 16 * sizeof(int16_t)); | 509 | memset(s->ac_val[1][xy], 0, 16 * sizeof(int16_t)); |
| 510 | memset(s->ac_val[2][xy], 0, 16 * sizeof(int16_t)); | 510 | memset(s->ac_val[2][xy], 0, 16 * sizeof(int16_t)); |
| 511 | |||
| 512 | s->mbintra_table[xy]= 0; | ||
| 513 | } | 511 | } |
| 514 | 512 | ||
| 515 | void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename | 513 | void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename |
| @@ -3559,8 +3559,11 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 3558 unmodified lines | |||
| 3559 | if (s->c.mb_intra /* && I,P,S_TYPE */) { | 3559 | if (s->c.mb_intra /* && I,P,S_TYPE */) { |
| 3560 | s->p_mv_table[xy][0]=0; | 3560 | s->p_mv_table[xy][0]=0; |
| 3561 | s->p_mv_table[xy][1]=0; | 3561 | s->p_mv_table[xy][1]=0; |
| 3562 | } else if ((s->c.h263_pred || s->c.h263_aic) && s->c.mbintra_table[xy]) | 3562 | #if CONFIG_H263_ENCODER |
| 3563 | ff_clean_intra_table_entries(&s->c); | 3563 | } else if (s->c.h263_pred || s->c.h263_aic) { |
| 3564 | ff_h263_clean_intra_table_entries(&s->c, xy); | ||
| 3565 | #endif | ||
| 3566 | } | ||
| 3564 | 3567 | ||
| 3565 | if (s->c.avctx->flags & AV_CODEC_FLAG_PSNR) { | 3568 | if (s->c.avctx->flags & AV_CODEC_FLAG_PSNR) { |
| 3566 | int w= 16; | 3569 | int w= 16; |