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

[CFL] Convert cfl_alpha to q3

Alpha's biggest fraction is 1/8, so Q3 does not change the bitstream.

Results on Subset1 (compared to 503aca74 with CfL enabled)

  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

Change-Id: I1fe5b2ace97179d5f950d7406a4f3d391924f89d
parent 65f2435e
......@@ -227,16 +227,16 @@ static void cfl_compute_averages(CFL_CTX *cfl, TX_SIZE tx_size) {
assert(a <= MAX_NUM_TXB);
}
static INLINE double cfl_idx_to_alpha(int alpha_idx, CFL_SIGN_TYPE alpha_sign,
CFL_PRED_TYPE pred_type) {
static INLINE int cfl_idx_to_alpha(int alpha_idx, CFL_SIGN_TYPE alpha_sign,
CFL_PRED_TYPE pred_type) {
const int mag_idx = cfl_alpha_codes[alpha_idx][pred_type];
const double abs_alpha = cfl_alpha_mags[mag_idx];
const int abs_alpha_q3 = cfl_alpha_mags_q3[mag_idx];
if (alpha_sign == CFL_SIGN_POS) {
return abs_alpha;
return abs_alpha_q3;
} else {
assert(abs_alpha != 0.0);
assert(cfl_alpha_mags[mag_idx + 1] == -abs_alpha);
return -abs_alpha;
assert(abs_alpha_q3 != 0);
assert(cfl_alpha_mags_q3[mag_idx + 1] == -abs_alpha_q3);
return -abs_alpha_q3;
}
}
......@@ -255,10 +255,8 @@ void cfl_predict_block(MACROBLOCKD *const xd, uint8_t *dst, int dst_stride,
const uint8_t *y_pix = cfl->y_down_pix;
const int dc_pred = cfl->dc_pred[plane - 1];
const double alpha = cfl_idx_to_alpha(
const int alpha_q3 = cfl_idx_to_alpha(
mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs[plane - 1], plane - 1);
// TODO(ltrudeau) Convert alpha to fixed point.
const int alpha_q3 = (int)(alpha * 8);
const int avg_row =
(row << tx_size_wide_log2[0]) >> tx_size_wide_log2[tx_size];
......
......@@ -65,9 +65,7 @@ typedef struct {
int mi_row, mi_col;
} CFL_CTX;
static const double cfl_alpha_mags[CFL_MAGS_SIZE] = {
0., 0.125, -0.125, 0.25, -0.25, 0.5, -0.5
};
static const int cfl_alpha_mags_q3[CFL_MAGS_SIZE] = { 0, 1, -1, 2, -2, 4, -4 };
static const int cfl_alpha_codes[CFL_ALPHABET_SIZE][CFL_PRED_PLANES] = {
// barrbrain's simple 1D quant ordered by subset 3 likelihood
......
......@@ -1428,11 +1428,11 @@ static int cfl_alpha_dist(const uint8_t *y_pix, int y_stride,
const int y_averages_q3[MAX_NUM_TXB],
const uint8_t *src, int src_stride, int width,
int height, TX_SIZE tx_size, int dc_pred,
double alpha, int *dist_neg_out) {
int alpha_q3, int *dist_neg_out) {
int dist = 0;
int diff;
if (alpha == 0.0) {
if (alpha_q3 == 0) {
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
diff = src[i] - dc_pred;
......@@ -1446,8 +1446,6 @@ static int cfl_alpha_dist(const uint8_t *y_pix, int y_stride,
return dist;
}
// TODO(ltrudeau) Convert alpha to fixed point
const int alpha_q3 = (int)(alpha * 8);
int dist_neg = 0;
const int tx_height = tx_size_high[tx_size];
const int tx_width = tx_size_wide[tx_size];
......@@ -1543,13 +1541,13 @@ static void cfl_compute_alpha_ind(MACROBLOCK *const x, FRAME_CONTEXT *ec_ctx,
width, height, tx_size, dc_pred_v, 0, NULL);
for (int m = 1; m < CFL_MAGS_SIZE; m += 2) {
assert(cfl_alpha_mags[m + 1] == -cfl_alpha_mags[m]);
assert(cfl_alpha_mags_q3[m + 1] == -cfl_alpha_mags_q3[m]);
sse[CFL_PRED_U][m] = cfl_alpha_dist(
y_pix, MAX_SB_SIZE, y_averages_q3, src_u, src_stride_u, width, height,
tx_size, dc_pred_u, cfl_alpha_mags[m], &sse[CFL_PRED_U][m + 1]);
tx_size, dc_pred_u, cfl_alpha_mags_q3[m], &sse[CFL_PRED_U][m + 1]);
sse[CFL_PRED_V][m] = cfl_alpha_dist(
y_pix, MAX_SB_SIZE, y_averages_q3, src_v, src_stride_v, width, height,
tx_size, dc_pred_v, cfl_alpha_mags[m], &sse[CFL_PRED_V][m + 1]);
tx_size, dc_pred_v, cfl_alpha_mags_q3[m], &sse[CFL_PRED_V][m + 1]);
}
int 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