Commit 4e26d667 authored by Luc Trudeau's avatar Luc Trudeau

[CFL] Move Subsampling in Store

Pixels are subsampled when they are stored in the CfL prediction
buffer. This allows to avoid having two buffers. No impact on the
bitstream.

Results on subset1 (Compared to parent)

  PSNR | PSNR Cb | PSNR Cr | PSNR HVS |   SSIM | MS SSIM | CIEDE 2000
0.0000 |  0.0000 |  0.0000 |   0.0000 | 0.0000 |  0.0000 |     0.0000

https://arewecompressedyet.com/?job=cfl-avg-on-fly%402017-09-23T21%3A38%3A04.440Z&job=cfl-Sub-On-Store%402017-09-24T15%3A01%3A41.161Z

Change-Id: If051e34d6d7078d77609542305a2afebef5cb177
parent 5a010aac
......@@ -695,15 +695,14 @@ typedef struct {
(CFL_SUB8X8_VAL_MI_SIZE * CFL_SUB8X8_VAL_MI_SIZE)
#endif // CONFIG_CHROMA_SUB8X8 && CONFIG_DEBUG
typedef struct cfl_ctx {
// Pixel buffer containing the luma pixels used as prediction for chroma
// TODO(ltrudeau) Convert to uint16 for HBD support
uint8_t y_pix[MAX_SB_SQUARE];
// Downsampled luma pixels (in Q3) used for chroma prediction
int y_down_pix_q3[MAX_SB_SQUARE];
// Height and width of the luma prediction block currently in the pixel buffer
int y_height, y_width;
// The CfL prediction buffer is used in two steps:
// 1. Stores Q3 reconstructed luma pixels
// (only Q2 is required, but Q3 is used to avoid shifts)
// 2. Stores Q3 AC contributions (step1 - tx block avg)
int16_t pred_buf_q3[MAX_SB_SQUARE];
// Height and width currently used in the CfL prediction buffer.
int buf_height, buf_width;
// Height and width of the chroma prediction block currently associated with
// this context
......
This diff is collapsed.
......@@ -14,8 +14,8 @@
#include "av1/common/blockd.h"
static INLINE int get_scaled_luma_q0(int alpha_q3, int y_down_pix_q3) {
int scaled_luma_q6 = alpha_q3 * y_down_pix_q3;
static INLINE int get_scaled_luma_q0(int alpha_q3, int16_t pred_buf_q3) {
int scaled_luma_q6 = alpha_q3 * pred_buf_q3;
return ROUND_POWER_OF_TWO_SIGNED(scaled_luma_q6, 6);
}
......
......@@ -5845,7 +5845,7 @@ static int rd_pick_intra_angle_sbuv(const AV1_COMP *const cpi, MACROBLOCK *x,
#endif // CONFIG_EXT_INTRA
#if CONFIG_CFL
static int64_t cfl_alpha_dist(const int *y_pix_q3, const uint8_t *src,
static int64_t cfl_alpha_dist(const int16_t *pred_buf_q3, const uint8_t *src,
int src_stride, int width, int height,
int dc_pred, int alpha_q3,
int64_t *dist_neg_out) {
......@@ -5870,7 +5870,7 @@ static int64_t cfl_alpha_dist(const int *y_pix_q3, const uint8_t *src,
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
const int uv = src[i];
const int scaled_luma = get_scaled_luma_q0(alpha_q3, y_pix_q3[i]);
const int scaled_luma = get_scaled_luma_q0(alpha_q3, pred_buf_q3[i]);
// TODO(ltrudeau) add support for HBD.
diff = uv - clamp(scaled_luma + dc_pred, 0, 255);
......@@ -5880,7 +5880,7 @@ static int64_t cfl_alpha_dist(const int *y_pix_q3, const uint8_t *src,
diff = uv - clamp(-scaled_luma + dc_pred, 0, 255);
dist_neg += diff * diff;
}
y_pix_q3 += MAX_SB_SIZE;
pred_buf_q3 += MAX_SB_SIZE;
src += src_stride;
}
......@@ -5906,23 +5906,23 @@ static int cfl_rd_pick_alpha(MACROBLOCK *const x, TX_SIZE tx_size) {
const int height = cfl->uv_height;
const int dc_pred_u = cfl->dc_pred[CFL_PRED_U];
const int dc_pred_v = cfl->dc_pred[CFL_PRED_V];
const int *y_pix_q3 = cfl->y_down_pix_q3;
const int16_t *pred_buf_q3 = cfl->pred_buf_q3;
int64_t sse[CFL_PRED_PLANES][CFL_MAGS_SIZE];
sse[CFL_PRED_U][0] = cfl_alpha_dist(y_pix_q3, src_u, src_stride_u, width,
sse[CFL_PRED_U][0] = cfl_alpha_dist(pred_buf_q3, src_u, src_stride_u, width,
height, dc_pred_u, 0, NULL);
sse[CFL_PRED_V][0] = cfl_alpha_dist(y_pix_q3, src_v, src_stride_v, width,
sse[CFL_PRED_V][0] = cfl_alpha_dist(pred_buf_q3, src_v, src_stride_v, width,
height, dc_pred_v, 0, NULL);
for (int c = 0; c < CFL_ALPHABET_SIZE; c++) {
const int m = c * 2 + 1;
const int abs_alpha_q3 = c + 1;
sse[CFL_PRED_U][m] =
cfl_alpha_dist(y_pix_q3, src_u, src_stride_u, width, height, dc_pred_u,
abs_alpha_q3, &sse[CFL_PRED_U][m + 1]);
cfl_alpha_dist(pred_buf_q3, src_u, src_stride_u, width, height,
dc_pred_u, abs_alpha_q3, &sse[CFL_PRED_U][m + 1]);
sse[CFL_PRED_V][m] =
cfl_alpha_dist(y_pix_q3, src_v, src_stride_v, width, height, dc_pred_v,
abs_alpha_q3, &sse[CFL_PRED_V][m + 1]);
cfl_alpha_dist(pred_buf_q3, src_v, src_stride_v, width, height,
dc_pred_v, abs_alpha_q3, &sse[CFL_PRED_V][m + 1]);
}
int64_t dist;
......
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