Commit 89f5876f authored by Nathan E. Egge's avatar Nathan E. Egge

Use aom_reader with generic_decode().

Change the generic_decode() function to take an aom_reader struct
 instead of an od_ec_dec struct.

Change-Id: Ifa19ab1dbdd9fa1af19e6740839708b27ab4a44b
parent e1308619
......@@ -22,12 +22,14 @@
# define GENERIC_TABLES 12
#if OD_ACCOUNTING
# define generic_decode(dec, model, max, ex_q16, integration, str) generic_decode_(dec, model, max, ex_q16, integration, str)
# define generic_decode(r, model, max, ex_q16, integration, str) \
generic_decode_(r, model, max, ex_q16, integration, str)
# define aom_decode_cdf_adapt_q15(r, cdf, n, count, rate, str) \
aom_decode_cdf_adapt_q15_(r, cdf, n, count, rate, str)
# define od_decode_cdf_adapt(ec, cdf, n, increment, str) od_decode_cdf_adapt_(ec, cdf, n, increment, str)
#else
# define generic_decode(dec, model, max, ex_q16, integration, str) generic_decode_(dec, model, max, ex_q16, integration)
# define generic_decode(r, model, max, ex_q16, integration, str) \
generic_decode_(r, model, max, ex_q16, integration)
# define aom_decode_cdf_adapt_q15(r, cdf, n, count, rate, str) \
aom_decode_cdf_adapt_q15_(r, cdf, n, count, rate)
# define od_decode_cdf_adapt(ec, cdf, n, increment, str) od_decode_cdf_adapt_(ec, cdf, n, increment)
......@@ -79,7 +81,7 @@ double od_encode_cdf_cost(int val, uint16_t *cdf, int n);
int aom_decode_cdf_adapt_q15_(aom_reader *r, uint16_t *cdf, int n,
int *count, int rate OD_ACC_STR);
int generic_decode_(od_ec_dec *dec, generic_encoder *model, int max,
int generic_decode_(aom_reader *r, generic_encoder *model, int max,
int *ex_q16, int integration OD_ACC_STR);
int log_ex(int ex_q16);
......
......@@ -372,14 +372,10 @@ static int av1_pvq_decode_helper(od_dec_ctx *dec, int16_t *ref_coeff,
for (i = 0; i < blk_size * blk_size; i++) dqcoeff_pvq[i] = out_int32[i];
if (!has_dc_skip || dqcoeff_pvq[0]) {
#if CONFIG_DAALA_EC
dqcoeff_pvq[0] =
has_dc_skip +
generic_decode(&dec->r->ec, &dec->state.adapt.model_dc[pli], -1,
&dec->state.adapt.ex_dc[pli][bs][0], 2, "dc:mag");
#else
#error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
has_dc_skip + generic_decode(dec->r, &dec->state.adapt.model_dc[pli],
-1, &dec->state.adapt.ex_dc[pli][bs][0], 2,
"dc:mag");
if (dqcoeff_pvq[0])
dqcoeff_pvq[0] *= aom_read_bit(dec->r, "dc:sign") ? -1 : 1;
}
......
......@@ -78,7 +78,7 @@ int od_decode_cdf_adapt_(od_ec_dec *ec, uint16_t *cdf, int n,
* distribution is one-sided (zero and up), has a single mode, and decays
* exponentially past the model.
*
* @param [in,out] dec range decoder
* @param [in,out] r multi-symbol entropy decoder
* @param [in,out] model generic probability model
* @param [in] x variable being encoded
* @param [in,out] ExQ16 expectation of x (adapted)
......@@ -87,7 +87,7 @@ int od_decode_cdf_adapt_(od_ec_dec *ec, uint16_t *cdf, int n,
*
* @retval decoded variable x
*/
int generic_decode_(od_ec_dec *dec, generic_encoder *model, int max,
int generic_decode_(aom_reader *r, generic_encoder *model, int max,
int *ex_q16, int integration OD_ACC_STR) {
int lg_q1;
int shift;
......@@ -108,8 +108,8 @@ int generic_decode_(od_ec_dec *dec, generic_encoder *model, int max,
id = OD_MINI(GENERIC_TABLES - 1, lg_q1);
cdf = model->cdf[id];
ms = (max + (1 << shift >> 1)) >> shift;
if (max == -1) xs = od_ec_decode_cdf_unscaled(dec, cdf, 16);
else xs = od_ec_decode_cdf_unscaled(dec, cdf, OD_MINI(ms + 1, 16));
if (max == -1) xs = aom_read_symbol_unscaled(r, cdf, 16, acc_str);
else xs = aom_read_symbol_unscaled(r, cdf, OD_MINI(ms + 1, 16), acc_str);
if (xs == 15) {
int e;
unsigned decay;
......@@ -120,14 +120,22 @@ int generic_decode_(od_ec_dec *dec, generic_encoder *model, int max,
OD_ASSERT(*ex_q16 < INT_MAX >> 1);
e = ((2**ex_q16 >> 8) + (1 << shift >> 1)) >> shift;
decay = OD_MAXI(2, OD_MINI(254, 256*e/(e + 256)));
xs += laplace_decode_special(dec, decay, (max == -1) ? -1 : ms - 15, acc_str);
#if CONFIG_DAALA_EC
xs += laplace_decode_special(&r->ec, decay, (max == -1) ? -1 : ms - 15, acc_str);
#else
# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
}
if (shift != 0) {
int special;
/* Because of the rounding, there's only half the number of possibilities
for xs=0 */
special = xs == 0;
if (shift - special > 0) lsb = od_ec_dec_bits(dec, shift - special, acc_str);
#if CONFIG_DAALA_EC
if (shift - special > 0) lsb = od_ec_dec_bits(&r->ec, shift - special, acc_str);
#else
# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
lsb -= !special << (shift - 1);
}
x = (xs << shift) + lsb;
......
......@@ -198,11 +198,7 @@ static void pvq_decode_partition(aom_reader *r,
if (qg > 0) {
int tmp;
tmp = *exg;
#if CONFIG_DAALA_EC
qg = 1 + generic_decode(&r->ec, &model[!*noref], -1, &tmp, 2, "pvq:gain");
#else
# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
qg = 1 + generic_decode(r, &model[!*noref], -1, &tmp, 2, "pvq:gain");
OD_IIR_DIADIC(*exg, qg << 16, 2);
}
*skip = 0;
......@@ -248,12 +244,8 @@ static void pvq_decode_partition(aom_reader *r,
if (itheta > 1 && (nodesync || max_theta > 3)) {
int tmp;
tmp = *ext;
#if CONFIG_DAALA_EC
itheta = 2 + generic_decode(&r->ec, &model[2],
itheta = 2 + generic_decode(r, &model[2],
nodesync ? -1 : max_theta - 3, &tmp, 2, "pvq:theta");
#else
# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
OD_IIR_DIADIC(*ext, itheta << 16, 2);
}
theta = od_pvq_compute_theta(itheta, max_theta);
......
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