From e2511e158b97a27cc559e0a08cf718335b82700c Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin <jmvalin@jmvalin.ca> Date: Tue, 8 Mar 2016 23:20:34 -0500 Subject: [PATCH] Deringing cleanup: don't hardcode the number of levels No change in code behaviour. Change-Id: If612c1340b4ca30e290947607ecb64a0cb30e95e --- vp10/common/dering.c | 2 +- vp10/common/dering.h | 2 ++ vp10/decoder/decodeframe.c | 2 +- vp10/encoder/bitstream.c | 2 +- vp10/encoder/pickdering.c | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/vp10/common/dering.c b/vp10/common/dering.c index 6e8fdc297d..f657c83fde 100644 --- a/vp10/common/dering.c +++ b/vp10/common/dering.c @@ -20,7 +20,7 @@ int compute_level_from_index(int global_level, int gi) { - static const int dering_gains[4] = {0, 11, 16, 22}; + static const int dering_gains[DERING_REFINEMENT_LEVELS] = {0, 11, 16, 22}; int level; if (global_level == 0) return 0; level = (global_level*dering_gains[gi] + 8) >> 4; diff --git a/vp10/common/dering.h b/vp10/common/dering.h index 9a292cb28a..946366a67a 100644 --- a/vp10/common/dering.h +++ b/vp10/common/dering.h @@ -15,6 +15,8 @@ extern "C" { #define MAX_DERING_LEVEL (1 << DERING_LEVEL_BITS) #define DERING_REFINEMENT 1 +#define DERING_REFINEMENT_BITS 2 +#define DERING_REFINEMENT_LEVELS 4 int compute_level_from_index(int global_level, int gi); int sb_all_skip(const VP10_COMMON *const cm, int mi_row, int mi_col); diff --git a/vp10/decoder/decodeframe.c b/vp10/decoder/decodeframe.c index c2513379a7..c9c0676f28 100644 --- a/vp10/decoder/decodeframe.c +++ b/vp10/decoder/decodeframe.c @@ -976,7 +976,7 @@ static void decode_partition(VP10Decoder *const pbi, MACROBLOCKD *const xd, if (bsize == BLOCK_64X64) { if (cm->dering_level != 0 && !sb_all_skip(cm, mi_row, mi_col)) { cm->mi_grid_visible[mi_row*cm->mi_stride + mi_col]->mbmi.dering_gain = - vpx_read_literal(r, 2); + vpx_read_literal(r, DERING_REFINEMENT_BITS); } else { cm->mi_grid_visible[mi_row*cm->mi_stride + mi_col]->mbmi.dering_gain = 0; } diff --git a/vp10/encoder/bitstream.c b/vp10/encoder/bitstream.c index 471d39cf27..c03a10f731 100644 --- a/vp10/encoder/bitstream.c +++ b/vp10/encoder/bitstream.c @@ -611,7 +611,7 @@ static void write_modes_sb(VP10_COMP *cpi, const TileInfo *const tile, !sb_all_skip(cm, mi_row, mi_col)) { vpx_write_literal( w, cm->mi_grid_visible[mi_row*cm->mi_stride + mi_col]->mbmi.dering_gain, - 2); + DERING_REFINEMENT_BITS); } #endif } diff --git a/vp10/encoder/pickdering.c b/vp10/encoder/pickdering.c index 556580a3ed..a7f69d26d3 100644 --- a/vp10/encoder/pickdering.c +++ b/vp10/encoder/pickdering.c @@ -155,7 +155,7 @@ int vp10_dering_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref, int best_gi; int best_mse = mse[nhsb*sbr+sbc][0]; best_gi = 0; - for (gi = 1; gi < 4; gi++) { + for (gi = 1; gi < DERING_REFINEMENT_LEVELS; gi++) { level = compute_level_from_index(best_level, gi); if (mse[nhsb*sbr+sbc][level] < best_mse) { best_gi = gi; -- GitLab