[CFL] separate uv_mode CDFs, split on is_cfl_allowed
This is to exclude coding CFL for block sizes where it is normatively
not allowed.
Reuse the alternate CDFs from the --disable-cfl path.
This yields some improvement on subset1:
PSNR | PSNR Cb | PSNR Cr | PSNR HVS | SSIM | MS SSIM | CIEDE 2000
-0.0113 | -0.2630 | -0.2138 | 0.0021 | -0.0110 | -0.0157 | -0.0511
BUG=aomedia:1182
Change-Id: I1e5f23ef7f2debcf8edce788bfa63ec95db4a679
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index bd89081..e31f028 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -1101,11 +1101,18 @@
static void write_intra_uv_mode(FRAME_CONTEXT *frame_ctx,
UV_PREDICTION_MODE uv_mode,
- PREDICTION_MODE y_mode, aom_writer *w) {
-#if !CONFIG_CFL
- uv_mode = get_uv_mode(uv_mode);
+ PREDICTION_MODE y_mode,
+#if CONFIG_CFL
+ CFL_ALLOWED_TYPE cfl_allowed,
#endif
+ aom_writer *w) {
+#if CONFIG_CFL
+ aom_write_symbol(w, uv_mode, frame_ctx->uv_mode_cdf[cfl_allowed][y_mode],
+ UV_INTRA_MODES - !cfl_allowed);
+#else
+ uv_mode = get_uv_mode(uv_mode);
aom_write_symbol(w, uv_mode, frame_ctx->uv_mode_cdf[y_mode], UV_INTRA_MODES);
+#endif
}
#if CONFIG_CFL
@@ -1334,18 +1341,12 @@
write_intra_mode(ec_ctx, bsize, mode, w);
if (is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
xd->plane[1].subsampling_y)) {
+#if !CONFIG_CFL
write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mode, w);
-
-#if CONFIG_CFL
- if (mbmi->uv_mode == UV_CFL_PRED) {
- if (!is_cfl_allowed(mbmi)) {
- aom_internal_error(
- &cm->error, AOM_CODEC_UNSUP_BITSTREAM,
- "Chroma from Luma (CfL) cannot be signaled for a %dx%d block.",
- block_size_wide[bsize], block_size_high[bsize]);
- }
+#else
+ write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mode, is_cfl_allowed(mbmi), w);
+ if (mbmi->uv_mode == UV_CFL_PRED)
write_cfl_alphas(ec_ctx, mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs, w);
- }
#endif
}
@@ -1645,18 +1646,13 @@
if (is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
xd->plane[1].subsampling_y)) {
+#if !CONFIG_CFL
write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mbmi->mode, w);
-
-#if CONFIG_CFL
- if (mbmi->uv_mode == UV_CFL_PRED) {
- if (!is_cfl_allowed(mbmi)) {
- aom_internal_error(
- &cm->error, AOM_CODEC_UNSUP_BITSTREAM,
- "Chroma from Luma (CfL) cannot be signaled for a %dx%d block.",
- block_size_wide[bsize], block_size_high[bsize]);
- }
+#else
+ write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mbmi->mode, is_cfl_allowed(mbmi),
+ w);
+ if (mbmi->uv_mode == UV_CFL_PRED)
write_cfl_alphas(ec_ctx, mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs, w);
- }
#endif
}