diff --git a/av1/common/cfl.c b/av1/common/cfl.c index 061bae09515ad1405ecf9c51de3d121ff0ca4bb1..004bbeb75be19dd5a927d41d18fb85fd0f22ba31 100644 --- a/av1/common/cfl.c +++ b/av1/common/cfl.c @@ -28,7 +28,7 @@ void cfl_init(CFL_CTX *cfl, AV1_COMMON *cm) { // CfL computes its own block-level DC_PRED. This is required to compute both // alpha_cb and alpha_cr before the prediction are computed. -void cfl_dc_pred(MACROBLOCKD *xd, BLOCK_SIZE plane_bsize, TX_SIZE tx_size) { +void cfl_dc_pred(MACROBLOCKD *xd, BLOCK_SIZE plane_bsize) { const struct macroblockd_plane *const pd_u = &xd->plane[AOM_PLANE_U]; const struct macroblockd_plane *const pd_v = &xd->plane[AOM_PLANE_V]; @@ -38,12 +38,9 @@ void cfl_dc_pred(MACROBLOCKD *xd, BLOCK_SIZE plane_bsize, TX_SIZE tx_size) { const int dst_u_stride = pd_u->dst.stride; const int dst_v_stride = pd_v->dst.stride; - const int block_width = (plane_bsize != BLOCK_INVALID) - ? block_size_wide[plane_bsize] - : tx_size_wide[tx_size]; - const int block_height = (plane_bsize != BLOCK_INVALID) - ? block_size_high[plane_bsize] - : tx_size_high[tx_size]; + assert(plane_bsize != BLOCK_INVALID); + const int block_width = block_size_wide[plane_bsize]; + const int block_height = block_size_high[plane_bsize]; // Number of pixel on the top and left borders. const double num_pel = block_width + block_height; diff --git a/av1/common/cfl.h b/av1/common/cfl.h index 165ad099d190bc453b1d7cf832a2d9c320cba9c5..b5b77ccc08bf4074715ca9e19f96b05f268de555 100644 --- a/av1/common/cfl.h +++ b/av1/common/cfl.h @@ -59,7 +59,7 @@ static const int cfl_alpha_codes[CFL_ALPHABET_SIZE][CFL_PRED_PLANES] = { void cfl_init(CFL_CTX *cfl, AV1_COMMON *cm); -void cfl_dc_pred(MACROBLOCKD *xd, BLOCK_SIZE plane_bsize, TX_SIZE tx_size); +void cfl_dc_pred(MACROBLOCKD *xd, BLOCK_SIZE plane_bsize); static INLINE double cfl_idx_to_alpha(int alpha_idx, CFL_SIGN_TYPE alpha_sign, CFL_PRED_TYPE pred_type) { diff --git a/av1/common/reconintra.c b/av1/common/reconintra.c index 3da11e9948dccef4792f95d6999d57f93de11cd9..f336ccbf807c1c7d499414f5f6fd9bb9a7ee4159 100644 --- a/av1/common/reconintra.c +++ b/av1/common/reconintra.c @@ -2528,11 +2528,15 @@ void av1_predict_intra_block_facade(MACROBLOCKD *xd, int plane, int block_idx, #if CONFIG_CFL if (plane != AOM_PLANE_Y && mbmi->uv_mode == DC_PRED) { if (plane == AOM_PLANE_U && blk_col == 0 && blk_row == 0) { - // Compute the block-level DC_PRED for both chromatic planes prior to - // processing the first chromatic plane in order to compute alpha_cb and - // alpha_cr. Note: This is not required on the decoder side because alpha - // is signaled. - cfl_dc_pred(xd, get_plane_block_size(block_idx, pd), tx_size); +// Compute the block-level DC_PRED for both chromatic planes. DC_PRED replaces +// beta in the linear model. +#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2 + const BLOCK_SIZE plane_bsize = + AOMMAX(BLOCK_4X4, get_plane_block_size(mbmi->sb_type, pd)); +#else + const BLOCK_SIZE plane_bsize = get_plane_block_size(mbmi->sb_type, pd); +#endif + cfl_dc_pred(xd, plane_bsize); } cfl_predict_block( diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c index cbcfad1d0fc6b340d2ddb93bbb7938a30b99aad3..acd915f6761d9d389d2395c7de3595b9d1389b88 100644 --- a/av1/encoder/encodemb.c +++ b/av1/encoder/encodemb.c @@ -1636,11 +1636,23 @@ void av1_predict_intra_block_encoder_facade(MACROBLOCK *x, if (blk_col == 0 && blk_row == 0 && plane == AOM_PLANE_U) { CFL_CTX *const cfl = xd->cfl; cfl_update_costs(cfl, ec_ctx); - cfl_dc_pred(xd, plane_bsize, tx_size); + cfl_dc_pred(xd, plane_bsize); mbmi->cfl_alpha_idx = cfl_compute_alpha_ind(x, cfl, plane_bsize, mbmi->cfl_alpha_signs); } } +#if CONFIG_DEBUG +// av1_predict_intra_block_facade does not pass plane_bsize, we need to validate +// that we will get the same value of plane_bsize on the other side. +#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2 + const BLOCK_SIZE plane_bsize_val = + AOMMAX(BLOCK_4X4, get_plane_block_size(mbmi->sb_type, &xd->plane[plane])); +#else + const BLOCK_SIZE plane_bsize_val = + get_plane_block_size(mbmi->sb_type, &xd->plane[plane]); +#endif // CONFIG_CB4X4 && !CONFIG_CHROMA_2X2 + assert(plane_bsize == plane_bsize_val); +#endif // CONFIG_DEBUG av1_predict_intra_block_facade(xd, plane, block_idx, blk_col, blk_row, tx_size); }