Commit 39051a77 authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Nathan Egge

Use aom_writer with od_encode_cdf_adapt().

Change the od_encode_cdf_adapt() function to take an aom_writer
 struct instead of an od_ec_enc struct.
Rename od_encode_cdf_adapt() to aom_encode_cdf_adapt().

Change-Id: I00de05b8b7428f67139c234160ab9aaf8900f967
parent 140069eb
......@@ -65,7 +65,7 @@ void aom_cdf_adapt_q15(int val, uint16_t *cdf, int n, int *count, int rate);
void aom_encode_cdf_adapt_q15(aom_writer *w, int val, uint16_t *cdf, int n,
int *count, int rate);
void od_encode_cdf_adapt(od_ec_enc *ec, int val, uint16_t *cdf, int n,
void aom_encode_cdf_adapt(aom_writer *w, int val, uint16_t *cdf, int n,
int increment);
int od_decode_cdf_adapt_(od_ec_dec *ec, uint16_t *cdf, int n,
......
......@@ -2116,9 +2116,9 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
pvq = get_pvq_block(cpi->td.mb.pvq_q);
// encode block skip info
od_encode_cdf_adapt(&w->ec, pvq->ac_dc_coded,
adapt->skip_cdf[2 * tx_size + (plane != 0)], 4,
adapt->skip_increment);
aom_encode_cdf_adapt(w, pvq->ac_dc_coded,
adapt->skip_cdf[2 * tx_size + (plane != 0)], 4,
adapt->skip_increment);
// AC coeffs coded?
if (pvq->ac_dc_coded & 0x02) {
......@@ -2136,8 +2136,8 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
pvq->skip_rest, encode_flip, flip);
}
if (i == 0 && !pvq->skip_rest && pvq->bs > 0) {
od_encode_cdf_adapt(
&w->ec, pvq->skip_dir,
aom_encode_cdf_adapt(
w, pvq->skip_dir,
&adapt->pvq
.pvq_skip_dir_cdf[(plane != 0) + 2 * (pvq->bs - 1)][0],
7, adapt->pvq.pvq_skip_dir_increment);
......
......@@ -60,10 +60,10 @@ void aom_encode_cdf_adapt_q15(aom_writer *w, int val, uint16_t *cdf, int n,
* @param [in] n number of values possible
* @param [in] increment adaptation speed (Q15)
*/
void od_encode_cdf_adapt(od_ec_enc *ec, int val, uint16_t *cdf, int n,
void aom_encode_cdf_adapt(aom_writer *w, int val, uint16_t *cdf, int n,
int increment) {
int i;
od_ec_encode_cdf_unscaled(ec, val, cdf, n);
aom_write_cdf_unscaled(w, val, cdf, n);
if (cdf[n-1] + increment > 32767) {
for (i = 0; i < n; i++) {
/* Second term ensures that the pdf is non-null */
......
......@@ -37,9 +37,9 @@ static void aom_encode_pvq_split(aom_writer *w, od_pvq_codeword_ctx *adapt,
sum >>= shift;
}
fctx = 7*ctx + sum - 1;
aom_encode_cdf_adapt(w, count, adapt->pvq_split_cdf[fctx], sum + 1,
adapt->pvq_split_increment);
#if CONFIG_DAALA_EC
od_encode_cdf_adapt(&w->ec, count, adapt->pvq_split_cdf[fctx],
sum + 1, adapt->pvq_split_increment);
if (shift) od_ec_enc_bits(&w->ec, rest, shift);
#else
# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
......@@ -58,12 +58,8 @@ void aom_encode_band_pvq_splits(aom_writer *w, od_pvq_codeword_ctx *adapt,
cdf_id = od_pvq_k1_ctx(n, level == 0);
for (pos = 0; !y[pos]; pos++);
OD_ASSERT(pos < n);
#if CONFIG_DAALA_EC
od_encode_cdf_adapt(&w->ec, pos, adapt->pvq_k1_cdf[cdf_id], n,
aom_encode_cdf_adapt(w, pos, adapt->pvq_k1_cdf[cdf_id], n,
adapt->pvq_k1_increment);
#else
# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
}
else {
mid = n >> 1;
......
......@@ -679,12 +679,8 @@ void pvq_encode_partition(aom_writer *w,
}
/* Jointly code gain, theta and noref for small values. Then we handle
larger gain and theta values. For noref, theta = -1. */
#if CONFIG_DAALA_EC
od_encode_cdf_adapt(&w->ec, id, &adapt->pvq.pvq_gaintheta_cdf[cdf_ctx][0],
aom_encode_cdf_adapt(w, id, &adapt->pvq.pvq_gaintheta_cdf[cdf_ctx][0],
8 + 7*code_skip, adapt->pvq.pvq_gaintheta_increment);
#else
# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
if (encode_flip) {
/* We could eventually do some smarter entropy coding here, but it would
have to be good enough to overcome the overhead of the entropy coder.
......@@ -747,13 +743,9 @@ void od_encode_quantizer_scaling(daala_enc_ctx *enc, int q_scaling,
: 0;
left = sbx > 0 ? enc->state.sb_q_scaling[sby*enc->state.nhsb + (sbx - 1)]
: 0;
#if CONFIG_DAALA_EC
od_encode_cdf_adapt(&enc->w.ec, q_scaling,
aom_encode_cdf_adapt(&enc->w, q_scaling,
enc->state.adapt.q_cdf[above + left*4], 4,
enc->state.adapt.q_increment);
#else
#error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
}
}
#endif
......@@ -934,12 +926,8 @@ int od_pvq_encode(daala_enc_ctx *enc,
#error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
/* Code as if we're not skipping. */
#if CONFIG_DAALA_EC
od_encode_cdf_adapt(&enc->w.ec, 2 + (out[0] != 0), skip_cdf,
aom_encode_cdf_adapt(&enc->w, 2 + (out[0] != 0), skip_cdf,
4, enc->state.adapt.skip_increment);
#else
#error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
if (pvq_info)
pvq_info->ac_dc_coded = 2 + (out[0] != 0);
#if OD_SIGNAL_Q_SCALING
......@@ -987,13 +975,9 @@ int od_pvq_encode(daala_enc_ctx *enc,
skip_rest, encode_flip, flip);
}
if (i == 0 && !skip_rest && bs > 0) {
#if CONFIG_DAALA_EC
od_encode_cdf_adapt(&enc->w.ec, skip_dir,
aom_encode_cdf_adapt(&enc->w, skip_dir,
&enc->state.adapt.pvq.pvq_skip_dir_cdf[(pli != 0) + 2*(bs - 1)][0], 7,
enc->state.adapt.pvq.pvq_skip_dir_increment);
#else
#error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
}
if (encode_flip) cfl_encoded = 1;
}
......@@ -1057,12 +1041,8 @@ int od_pvq_encode(daala_enc_ctx *enc,
}
/* We decide to skip, roll back everything as it was before. */
od_encode_rollback(enc, &buf);
#if CONFIG_DAALA_EC
od_encode_cdf_adapt(&enc->w.ec, out[0] != 0, skip_cdf,
aom_encode_cdf_adapt(&enc->w, out[0] != 0, skip_cdf,
4, enc->state.adapt.skip_increment);
#else
#error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
if (pvq_info)
pvq_info->ac_dc_coded = (out[0] != 0);
#if OD_SIGNAL_Q_SCALING
......
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