Commit 803bea26 authored by Luc Trudeau's avatar Luc Trudeau

[CFL] Fix always use partition size to compute DC_PRED

plane_bsize is now computed properly. This also includes support for the
special case of blocks < 4X4

Results on subset1 (compared to 8e689e4b with CfL)
   PSNR | PSNR Cb | PSNR Cr | PSNR HVS |    SSIM | MS SSIM | CIEDE 2000
-0.0218 | -0.2328 | -0.2555 |  -0.0230 | -0.0379 | -0.0723 |    -0.1205

Change-Id: I6ec87d818d8df6a40ecf3bb1b86954e59c952930
parent b732c1ea
......@@ -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;
......
......@@ -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) {
......
......@@ -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(
......
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment