Re-design base level context modeling Reduce the context model size required to code the base level syntax values from 42 to 32 per transform size. Change-Id: I08485fdb563bc5c3323b0e147d69b47c286b9bb5
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c index 9d14964..f5ba47c 100644 --- a/av1/encoder/encodetxb.c +++ b/av1/encoder/encodetxb.c
@@ -570,7 +570,8 @@ const int row = c >> bwl; const int col = c - (row << bwl); const int stride = 1 << bwl; - int mag[NUM_BASE_LEVELS] = { 0 }; + int mag_count[NUM_BASE_LEVELS] = { 0 }; + int nb_mag[NUM_BASE_LEVELS][3] = { { 0 } }; int idx; tran_low_t abs_coeff; int i; @@ -587,13 +588,19 @@ for (i = 0; i < NUM_BASE_LEVELS; ++i) { ctx_set[i] += abs_coeff > i; - if (base_ref_offset[idx][0] >= 0 && base_ref_offset[idx][1] >= 0) - mag[i] |= abs_coeff > (i + 1); + if (base_ref_offset[idx][0] == 0 && base_ref_offset[idx][1] == 1) + nb_mag[i][0] = abs_coeff; + if (base_ref_offset[idx][0] == 1 && base_ref_offset[idx][1] == 0) + nb_mag[i][1] = abs_coeff; + if (base_ref_offset[idx][0] == 1 && base_ref_offset[idx][1] == 1) + nb_mag[i][2] = abs_coeff; } } for (i = 0; i < NUM_BASE_LEVELS; ++i) { - ctx_set[i] = get_base_ctx_from_count_mag(row, col, ctx_set[i], mag[i]); + for (idx = 0; idx < 3; ++idx) mag_count[i] += nb_mag[i][idx] > i + 1; + ctx_set[i] = get_base_ctx_from_count_mag(row, col, ctx_set[i], + AOMMIN(2, mag_count[i])); } return; }