Commit b79f1b67 authored by Dake He's avatar Dake He

[lv_map_multi] simplify update_cdf

remove tmp0 in update_cdf due to the use of EC_MIN_PROB introduced by
Thomas Davies.

further changes to update_cdf include:
1. Start the rate at 3+get_msb(nsymbs) and increase the rate by one at
counts 16 and 32.
2. Check if tmp is less than cdf[i] to avoid shifting a negative number.

Change-Id: I5088ebd450d6e57ec6c3e92bb2f47a078489b947
parent 4ca633dc
......@@ -13,6 +13,7 @@
#define AOM_DSP_PROB_H_
#include <assert.h>
#include <stdio.h>
#include "./aom_config.h"
#include "./aom_dsp_common.h"
......@@ -221,10 +222,33 @@ static INLINE void update_cdf(aom_cdf_prob *cdf, int val, int nsymbs) {
const int rate2 = 5;
int i, tmp;
int diff;
#if 1
#if CONFIG_LV_MAP_MULTI
rate = 3 + (cdf[nsymbs] > 15) + (cdf[nsymbs] > 31) + get_msb(nsymbs);
tmp = AOM_ICDF(0);
(void)rate2;
(void)diff;
// Single loop (faster)
for (i = 0; i < nsymbs - 1; ++i) {
tmp = (i == val) ? 0 : tmp;
#if 1
if (tmp < cdf[i]) {
cdf[i] -= ((cdf[i] - tmp) >> rate);
} else {
cdf[i] += ((tmp - cdf[i]) >> rate);
}
#else
cdf[i] += ((tmp - cdf[i]) >> rate);
#endif
}
#else
const int tmp0 = 1 << rate2;
tmp = AOM_ICDF(tmp0);
diff = ((CDF_PROB_TOP - (nsymbs << rate2)) >> rate) << rate;
// Single loop (faster)
#if !CONFIG_ANS
for (i = 0; i < nsymbs - 1; ++i, tmp -= tmp0) {
......@@ -237,6 +261,9 @@ static INLINE void update_cdf(aom_cdf_prob *cdf, int val, int nsymbs) {
cdf[i] -= ((cdf[i] - tmp) >> rate);
}
#endif
#endif
#else
for (i = 0; i < nsymbs; ++i) {
tmp = (i + 1) << rate2;
......
......@@ -71,7 +71,12 @@ void av1_cost_tokens_from_cdf(int *costs, const aom_cdf_prob *cdf,
int i;
aom_cdf_prob prev_cdf = 0;
for (i = 0;; ++i) {
#if CONFIG_LV_MAP_MULTI
aom_cdf_prob p15 = AOM_ICDF(cdf[i]) - prev_cdf;
p15 = (p15 < EC_MIN_PROB) ? EC_MIN_PROB : p15;
#else
aom_cdf_prob p15 = AOM_ICDF(cdf[i]) - prev_cdf;
#endif
prev_cdf = AOM_ICDF(cdf[i]);
if (inv_map)
......
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