Commit d998a007 authored by Nathan E. Egge's avatar Nathan E. Egge
Browse files

Delete unused laplace decoder functions.

Delete the unused od_laplace_decode(), od_laplace_decode_vector(), and
 laplace_decode_vector_delta() functions.

Change-Id: Iec581e8cdb0bc9cac9199c09486891500c707c03
parent 5c7acc9e
......@@ -150,189 +150,3 @@ int od_laplace_decode_special_(od_ec_dec *dec, unsigned decay, int max OD_ACC_ST
OD_ASSERT(pos <= max || max == -1);
return pos;
}
/** Decodes a Laplace-distributed variable for use in PVQ.
*
* @param [in,out] dec range decoder
* @param [in] ExQ8 expectation of the absolute value of x
* @param [in] K maximum value of |x|
*
* @retval decoded variable (including sign)
*/
int od_laplace_decode_(od_ec_dec *dec, unsigned ex_q8, int k OD_ACC_STR) {
int j;
int shift;
uint16_t cdf[16];
int sym;
int lsb;
int decay;
int offset;
lsb = 0;
/* Shift down x if expectation is too high. */
shift = OD_ILOG(ex_q8) - 11;
if (shift < 0) shift = 0;
/* Apply the shift with rounding to Ex, K and xs. */
ex_q8 = (ex_q8 + (1 << shift >> 1)) >> shift;
k = (k + (1 << shift >> 1)) >> shift;
decay = OD_MINI(254, OD_DIVU(256*ex_q8, (ex_q8 + 256)));
offset = LAPLACE_OFFSET[(decay + 1) >> 1];
for (j = 0; j < 16; j++) {
cdf[j] = EXP_CDF_TABLE[(decay + 1) >> 1][j] - offset;
}
/* Simple way of truncating the pdf when we have a bound */
if (k == 0) sym = 0;
else sym = od_ec_decode_cdf_unscaled(dec, cdf, OD_MINI(k + 1, 16));
if (shift) {
int special;
/* Because of the rounding, there's only half the number of possibilities
for xs=0 */
special = (sym == 0);
if (shift - special > 0) lsb = od_ec_dec_bits(dec, shift - special, acc_str);
lsb -= (!special << (shift - 1));
}
/* Handle the exponentially-decaying tail of the distribution */
if (sym == 15) sym += laplace_decode_special(dec, decay, k - 15, acc_str);
return (sym << shift) + lsb;
}
#if OD_ACCOUNTING
# define laplace_decode_vector_delta(dec, y, n, k, curr, means, str) laplace_decode_vector_delta_(dec, y, n, k, curr, means, str)
#else
# define laplace_decode_vector_delta(dec, y, n, k, curr, means, str) laplace_decode_vector_delta_(dec, y, n, k, curr, means)
#endif
static void laplace_decode_vector_delta_(od_ec_dec *dec, od_coeff *y, int n, int k,
int32_t *curr, const int32_t *means
OD_ACC_STR) {
int i;
int prev;
int sum_ex;
int sum_c;
int coef;
int pos;
int k0;
int sign;
int first;
int k_left;
prev = 0;
sum_ex = 0;
sum_c = 0;
coef = 256*means[OD_ADAPT_COUNT_Q8]/
(1 + means[OD_ADAPT_COUNT_EX_Q8]);
pos = 0;
sign = 0;
first = 1;
k_left = k;
for (i = 0; i < n; i++) y[i] = 0;
k0 = k_left;
coef = OD_MAXI(coef, 1);
for (i = 0; i < k0; i++) {
int count;
if (first) {
int decay;
int ex = coef*(n - prev)/k_left;
if (ex > 65280) decay = 255;
else {
decay = OD_MINI(255,
(int)((256*ex/(ex + 256) + (ex>>5)*ex/((n + 1)*(n - 1)*(n - 1)))));
}
/*Update mean position.*/
count = laplace_decode_special(dec, decay, n - 1, acc_str);
first = 0;
}
else count = laplace_decode(dec, coef*(n - prev)/k_left, n - prev - 1, acc_str);
sum_ex += 256*(n - prev);
sum_c += count*k_left;
pos += count;
OD_ASSERT(pos < n);
if (y[pos] == 0)
sign = od_ec_dec_bits(dec, 1, acc_str);
y[pos] += sign ? -1 : 1;
prev = pos;
k_left--;
if (k_left == 0) break;
}
if (k > 0) {
curr[OD_ADAPT_COUNT_Q8] = 256*sum_c;
curr[OD_ADAPT_COUNT_EX_Q8] = sum_ex;
}
else {
curr[OD_ADAPT_COUNT_Q8] = -1;
curr[OD_ADAPT_COUNT_EX_Q8] = 0;
}
curr[OD_ADAPT_K_Q8] = 0;
curr[OD_ADAPT_SUM_EX_Q8] = 0;
}
/** Decodes a vector of integers assumed to come from rounding a sequence of
* Laplace-distributed real values in decreasing order of variance.
*
* @param [in,out] dec range decoder
* @param [in] y decoded vector
* @param [in] N dimension of the vector
* @param [in] K sum of the absolute value of components of y
* @param [out] curr Adaptation context output, may alias means.
* @param [in] means Adaptation context input.
*/
void od_laplace_decode_vector_(od_ec_dec *dec, od_coeff *y, int n, int k,
int32_t *curr, const int32_t *means OD_ACC_STR) {
int i;
int sum_ex;
int kn;
int exp_q8;
int mean_k_q8;
int mean_sum_ex_q8;
int ran_delta;
ran_delta = 0;
if (k <= 1) {
laplace_decode_vector_delta(dec, y, n, k, curr, means, acc_str);
return;
}
if (k == 0) {
curr[OD_ADAPT_COUNT_Q8] = OD_ADAPT_NO_VALUE;
curr[OD_ADAPT_COUNT_EX_Q8] = OD_ADAPT_NO_VALUE;
curr[OD_ADAPT_K_Q8] = 0;
curr[OD_ADAPT_SUM_EX_Q8] = 0;
for (i = 0; i < n; i++) y[i] = 0;
return;
}
sum_ex = 0;
kn = k;
/* Estimates the factor relating pulses_left and positions_left to E(|x|).*/
mean_k_q8 = means[OD_ADAPT_K_Q8];
mean_sum_ex_q8 = means[OD_ADAPT_SUM_EX_Q8];
if (mean_k_q8 < 1 << 23) exp_q8 = 256*mean_k_q8/(1 + mean_sum_ex_q8);
else exp_q8 = mean_k_q8/(1 + (mean_sum_ex_q8 >> 8));
for (i = 0; i < n; i++) {
int ex;
int x;
if (kn == 0) break;
if (kn <= 1 && i != n - 1) {
laplace_decode_vector_delta(dec, y + i, n - i, kn, curr, means, acc_str);
ran_delta = 1;
i = n;
break;
}
/* Expected value of x (round-to-nearest) is
expQ8*pulses_left/positions_left. */
ex = (2*exp_q8*kn + (n - i))/(2*(n - i));
if (ex > kn*256) ex = kn*256;
sum_ex += (2*256*kn + (n - i))/(2*(n - i));
/* No need to encode the magnitude for the last bin. */
if (i != n - 1) x = laplace_decode(dec, ex, kn, acc_str);
else x = kn;
if (x != 0) {
if (od_ec_dec_bits(dec, 1, acc_str)) x = -x;
}
y[i] = x;
kn -= abs(x);
}
/* Adapting the estimates for expQ8. */
if (!ran_delta) {
curr[OD_ADAPT_COUNT_Q8] = OD_ADAPT_NO_VALUE;
curr[OD_ADAPT_COUNT_EX_Q8] = OD_ADAPT_NO_VALUE;
}
curr[OD_ADAPT_K_Q8] = k - kn;
curr[OD_ADAPT_SUM_EX_Q8] = sum_ex;
for (; i < n; i++) y[i] = 0;
}
......@@ -22,20 +22,11 @@ void aom_decode_band_pvq_splits(aom_reader *r, od_pvq_codeword_ctx *adapt,
#if OD_ACCOUNTING
# define laplace_decode_special(dec, decay, max, str) od_laplace_decode_special_(dec, decay, max, str)
# define laplace_decode(dec, ex_q8, k, str) od_laplace_decode_(dec, ex_q8, k, str)
#define laplace_decode_vector(dec, y, n, k, curr, means, str) od_laplace_decode_vector_(dec, y, n, k, curr, means, str)
#else
# define laplace_decode_special(dec, decay, max, str) od_laplace_decode_special_(dec, decay, max)
# define laplace_decode(dec, ex_q8, k, str) od_laplace_decode_(dec, ex_q8, k)
#define laplace_decode_vector(dec, y, n, k, curr, means, str) od_laplace_decode_vector_(dec, y, n, k, curr, means)
#endif
int od_laplace_decode_special_(od_ec_dec *dec, unsigned decay, int max OD_ACC_STR);
int od_laplace_decode_(od_ec_dec *dec, unsigned ex_q8, int k OD_ACC_STR);
void od_laplace_decode_vector_(od_ec_dec *dec, od_coeff *y, int n, int k,
int32_t *curr, const int32_t *means
OD_ACC_STR);
void od_pvq_decode(daala_dec_ctx *dec, od_coeff *ref, od_coeff *out, int q0,
int pli, int bs, const od_val16 *beta, int robust, int is_keyframe,
......
Supports Markdown
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