Move IntraModeSearchState::best_pred_rd to InterModeSearchState The member variable best_pred_rd is used for compound inter modes and shouldn't be in INtraModeSearchState. BUG=aomedia:2863 Change-Id: If85b0f08769a02075a33ae3a8fd301849cfd86b6
diff --git a/av1/encoder/intra_mode_search.c b/av1/encoder/intra_mode_search.c index 048f5b9..d50f8ea 100644 --- a/av1/encoder/intra_mode_search.c +++ b/av1/encoder/intra_mode_search.c
@@ -851,7 +851,8 @@ BLOCK_SIZE bsize, unsigned int ref_frame_cost, const PICK_MODE_CONTEXT *ctx, RD_STATS *rd_stats, RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv, - int64_t best_rd, int64_t *best_intra_rd) { + int64_t best_rd, int64_t *best_intra_rd, + int64_t *best_pred_rd) { const AV1_COMMON *cm = &cpi->common; const SPEED_FEATURES *const sf = &cpi->sf; MACROBLOCKD *const xd = &x->e_mbd; @@ -1018,8 +1019,7 @@ } for (int i = 0; i < REFERENCE_MODES; ++i) { - intra_search_state->best_pred_rd[i] = - AOMMIN(intra_search_state->best_pred_rd[i], this_rd); + best_pred_rd[i] = AOMMIN(best_pred_rd[i], this_rd); } return this_rd;
diff --git a/av1/encoder/intra_mode_search.h b/av1/encoder/intra_mode_search.h index 4e52f02..974b3b9 100644 --- a/av1/encoder/intra_mode_search.h +++ b/av1/encoder/intra_mode_search.h
@@ -66,11 +66,6 @@ PALETTE_MODE_INFO pmi_uv; /*!< \brief Color map if mode_uv is palette */ int8_t uv_angle_delta; /*!< \brief Angle delta if mode_uv directional */ /**@}*/ - - /*! - * \brief Keep track of best intra rd for use in compound mode. - */ - int64_t best_pred_rd[REFERENCE_MODES]; } IntraModeSearchState; /*!\brief Evaluate a given intra-mode for inter frames. @@ -89,24 +84,23 @@ * support palette mode prediction in the luma channel, but it does search for * palette mode in the chroma channel. * - * \param[in] intra_search_state Structure to hold the best luma intra mode - * and cache chroma prediction for speed up. - * \param[in] cpi Top-level encoder structure. - * \param[in] x Pointer to structure holding all the data - * for the current macroblock. - * \param[in] bsize Current partition block size. - * \param[in] ref_frame_cost The entropy cost for signaling that the - * current ref frame is an intra frame. - * \param[in] ctx Structure to hold the number of 4x4 blks to - * copy the tx_type and txfm_skip arrays. - * \param[in] rd_stats Struct to keep track of the current + * \param[in,out] intra_search_state Structure to hold the best luma intra + * mode and cache chroma prediction for speed up. \param[in] cpi Top-level + * encoder structure. \param[in,out] x Pointer to structure + * holding all the data for the current macroblock. \param[in] bsize Current + * partition block size. \param[in] ref_frame_cost The entropy cost for + * signaling that the current ref frame is an intra frame. \param[in] ctx + * Structure to hold the number of 4x4 blks to copy the tx_type and txfm_skip + * arrays. \param[out] rd_stats Struct to keep track of the current * intra-mode's rd_stats. - * \param[in] rd_stats_y Struct to keep track of the current + * \param[out] rd_stats_y Struct to keep track of the current * intra-mode's rd_stats (luma only). - * \param[in] rd_stats_uv Struct to keep track of the current + * \param[out] rd_stats_uv Struct to keep track of the current * intra-mode's rd_stats (chroma only). * \param[in] best_rd Best RD seen for this block so far. - * \param[in] best_intra_rd Best intra RD seen for this block so far. + * \param[in,out] best_intra_rd Best intra RD seen for this block so + * far. \param[out] best_pred_rd Array of best pred rd for + * single/compound refs. * * \return Returns the rdcost of the current intra-mode if it's available, * otherwise returns INT64_MAX. The corresponding values in x->e_mbd.mi[0], @@ -121,7 +115,8 @@ BLOCK_SIZE bsize, unsigned int ref_frame_cost, const PICK_MODE_CONTEXT *ctx, RD_STATS *rd_stats, RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv, - int64_t best_rd, int64_t *best_intra_rd); + int64_t best_rd, int64_t *best_intra_rd, + int64_t *best_pred_rd); /*!\brief Evaluate luma palette mode for inter frames. *
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index 8b131e3..026d9a1 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c
@@ -317,6 +317,11 @@ int64_t mode_threshold[MAX_MODES]; int64_t best_intra_rd; unsigned int best_pred_sse; + + /*! + * \brief Keep track of best intra rd for use in compound mode. + */ + int64_t best_pred_rd[REFERENCE_MODES]; int64_t best_pred_diff[REFERENCE_MODES]; // Save a set of single_newmv for each checked ref_mv. int_mv single_newmv[MAX_REF_MV_SEARCH][REF_FRAMES]; @@ -3956,8 +3961,6 @@ av1_zero(intra_search_state->directional_mode_skip_mask); intra_search_state->rate_uv_intra = INT_MAX; av1_zero(intra_search_state->pmi_uv); - for (int i = 0; i < REFERENCE_MODES; ++i) - intra_search_state->best_pred_rd[i] = INT64_MAX; } static AOM_INLINE void init_inter_mode_search_state( @@ -4042,6 +4045,10 @@ } av1_zero(search_state->single_state_cnt); av1_zero(search_state->single_state_modelled_cnt); + + for (int i = 0; i < REFERENCE_MODES; ++i) { + search_state->best_pred_rd[i] = INT64_MAX; + } } static bool mask_says_skip(const mode_skip_mask_t *mode_skip_mask, @@ -4881,20 +4888,14 @@ hybrid_rd = RDCOST(rdmult, hybrid_rate, rd_stats->dist); if (!comp_pred) { - if (single_rd < - search_state->intra_search_state.best_pred_rd[SINGLE_REFERENCE]) - search_state->intra_search_state.best_pred_rd[SINGLE_REFERENCE] = - single_rd; + if (single_rd < search_state->best_pred_rd[SINGLE_REFERENCE]) + search_state->best_pred_rd[SINGLE_REFERENCE] = single_rd; } else { - if (single_rd < - search_state->intra_search_state.best_pred_rd[COMPOUND_REFERENCE]) - search_state->intra_search_state.best_pred_rd[COMPOUND_REFERENCE] = - single_rd; + if (single_rd < search_state->best_pred_rd[COMPOUND_REFERENCE]) + search_state->best_pred_rd[COMPOUND_REFERENCE] = single_rd; } - if (hybrid_rd < - search_state->intra_search_state.best_pred_rd[REFERENCE_MODE_SELECT]) - search_state->intra_search_state.best_pred_rd[REFERENCE_MODE_SELECT] = - hybrid_rd; + if (hybrid_rd < search_state->best_pred_rd[REFERENCE_MODE_SELECT]) + search_state->best_pred_rd[REFERENCE_MODE_SELECT] = hybrid_rd; } // Does a transform search over a list of the best inter mode candidates. @@ -5452,7 +5453,8 @@ intra_rd_stats.rdcost = av1_handle_intra_mode( &search_state.intra_search_state, cpi, x, bsize, intra_ref_frame_cost, ctx, &intra_rd_stats, &intra_rd_stats_y, &intra_rd_stats_uv, - search_state.best_rd, &search_state.best_intra_rd); + search_state.best_rd, &search_state.best_intra_rd, + search_state.best_pred_rd); // Collect mode stats for multiwinner mode processing const int txfm_search_done = 1; @@ -5567,12 +5569,11 @@ } for (i = 0; i < REFERENCE_MODES; ++i) { - if (search_state.intra_search_state.best_pred_rd[i] == INT64_MAX) { + if (search_state.best_pred_rd[i] == INT64_MAX) { search_state.best_pred_diff[i] = INT_MIN; } else { search_state.best_pred_diff[i] = - search_state.best_rd - - search_state.intra_search_state.best_pred_rd[i]; + search_state.best_rd - search_state.best_pred_rd[i]; } }