Commit ad424477 authored by Jean-Marc Valin's avatar Jean-Marc Valin Committed by Jean-Marc Valin
Browse files

Fix CDEF strength search

Previous code was using options selected for N=8 rather than the chosen
number of options.

low-latency, cpu=4:

  PSNR | PSNR Cb | PSNR Cr | PSNR HVS |    SSIM | MS SSIM | CIEDE 2000
0.0077 |  0.0286 | -0.1166 |  -0.0059 | -0.0479 |  0.0025 |    -0.0101

Properly save the best strengths

Change-Id: I629e929c2bc7a0a9592a9e49bfd7898d95174235
parent 0955881a
......@@ -201,7 +201,6 @@ void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
uint64_t(*mse[3])[TOTAL_STRENGTHS];
int clpf_damping = 3 + (cm->base_qindex >> 6);
int i;
int best_lev[CDEF_MAX_STRENGTHS];
int nb_strengths;
int nb_strength_bits;
int quantizer;
......@@ -329,6 +328,8 @@ void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
nb_strength_bits = 0;
/* Search for different number of signalling bits. */
for (i = 0; i <= 3; i++) {
int j;
int best_lev[CDEF_MAX_STRENGTHS];
nb_strengths = 1 << i;
tot_mse = joint_strength_search(best_lev, nb_strengths, mse[0], sb_count);
/* Count superblock signalling cost. */
......@@ -338,22 +339,24 @@ void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
if (tot_mse < best_tot_mse) {
best_tot_mse = tot_mse;
nb_strength_bits = i;
for (j = 0; j < 1 << nb_strength_bits; j++) {
cm->cdef_strengths[j] = best_lev[j];
}
}
}
nb_strengths = 1 << nb_strength_bits;
cm->cdef_bits = nb_strength_bits;
cm->nb_cdef_strengths = nb_strengths;
for (i = 0; i < nb_strengths; i++) cm->cdef_strengths[i] = best_lev[i];
for (i = 0; i < sb_count; i++) {
int gi;
int best_gi;
uint64_t best_mse = (uint64_t)1 << 63;
best_gi = 0;
for (gi = 0; gi < cm->nb_cdef_strengths; gi++) {
if (mse[0][i][best_lev[gi]] < best_mse) {
if (mse[0][i][cm->cdef_strengths[gi]] < best_mse) {
best_gi = gi;
best_mse = mse[0][i][best_lev[gi]];
best_mse = mse[0][i][cm->cdef_strengths[gi]];
}
}
selected_strength[i] = best_gi;
......
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