Use aom_writer with pvq_encode_partition().
Change the pvq_encode_partition() function to take an aom_writer struct
instead of an od_ec_enc struct.
Change-Id: I459d31c600467958c9a1cbebd632fec05e01f534
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 62486c5..305a9d7 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -2130,7 +2130,7 @@
if (i == 0 || (!pvq->skip_rest &&
!(pvq->skip_dir & (1 << ((i - 1) % 3))))) {
pvq_encode_partition(
- &w->ec, pvq->qg[i], pvq->theta[i], pvq->max_theta[i],
+ w, pvq->qg[i], pvq->theta[i], pvq->max_theta[i],
pvq->y + pvq->off[i], pvq->size[i], pvq->k[i], model, adapt,
exg + i, ext + i, robust || is_keyframe,
(plane != 0) * OD_TXSIZES * PVQ_MAX_PARTITIONS +
diff --git a/av1/encoder/pvq_encoder.c b/av1/encoder/pvq_encoder.c
index 6051d9c..3028d41 100644
--- a/av1/encoder/pvq_encoder.c
+++ b/av1/encoder/pvq_encoder.c
@@ -616,7 +616,7 @@
/** Encodes a single vector of integers (eg, a partition within a
* coefficient block) using PVQ
*
- * @param [in,out] ec range encoder
+ * @param [in,out] w multi-symbol entropy encoder
* @param [in] qg quantized gain
* @param [in] theta quantized post-prediction theta
* @param [in] max_theta maximum possible quantized theta value
@@ -635,7 +635,7 @@
* @param [in] encode_flip whether we need to encode the CfL flip flag now
* @param [in] flip value of the CfL flip flag
*/
-void pvq_encode_partition(od_ec_enc *ec,
+void pvq_encode_partition(aom_writer *w,
int qg,
int theta,
int max_theta,
@@ -667,30 +667,46 @@
}
/* Jointly code gain, theta and noref for small values. Then we handle
larger gain and theta values. For noref, theta = -1. */
- od_encode_cdf_adapt(ec, id, &adapt->pvq.pvq_gaintheta_cdf[cdf_ctx][0],
+#if CONFIG_DAALA_EC
+ od_encode_cdf_adapt(&w->ec, 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.
An early attempt using a "toogle" flag with simple adaptation wasn't
worth the trouble. */
- od_ec_enc_bits(ec, flip, 1);
+ aom_write_bit(w, flip);
}
if (qg > 0) {
int tmp;
tmp = *exg;
- generic_encode(ec, &model[!noref], qg - 1, -1, &tmp, 2);
+#if CONFIG_DAALA_EC
+ generic_encode(&w->ec, &model[!noref], qg - 1, -1, &tmp, 2);
+#else
+# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
+#endif
OD_IIR_DIADIC(*exg, qg << 16, 2);
}
if (theta > 1 && (nodesync || max_theta > 3)) {
int tmp;
tmp = *ext;
- generic_encode(ec, &model[2], theta - 2, nodesync ? -1 : max_theta - 3,
+#if CONFIG_DAALA_EC
+ generic_encode(&w->ec, &model[2], theta - 2, nodesync ? -1 : max_theta - 3,
&tmp, 2);
+#else
+# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
+#endif
OD_IIR_DIADIC(*ext, theta << 16, 2);
}
- od_encode_pvq_codeword(ec, &adapt->pvq.pvq_codeword_ctx, in,
+#if CONFIG_DAALA_EC
+ od_encode_pvq_codeword(&w->ec, &adapt->pvq.pvq_codeword_ctx, in,
n - (theta != -1), k);
+#else
+# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
+#endif
}
/** Quantizes a scalar with rate-distortion optimization (RDO)
@@ -964,15 +980,11 @@
/* Encode CFL flip bit just after the first time it's used. */
encode_flip = pli != 0 && is_keyframe && theta[i] != -1 && !cfl_encoded;
if (i == 0 || (!skip_rest && !(skip_dir & (1 << ((i - 1)%3))))) {
-#if CONFIG_DAALA_EC
- pvq_encode_partition(&enc->w.ec, qg[i], theta[i], max_theta[i],
- y + off[i], size[i], k[i], model, &enc->state.adapt, exg + i, ext + i,
+ pvq_encode_partition(&enc->w, qg[i], theta[i], max_theta[i], y + off[i],
+ size[i], k[i], model, &enc->state.adapt, exg + i, ext + i,
robust || is_keyframe, (pli != 0)*OD_TXSIZES*PVQ_MAX_PARTITIONS
+ bs*PVQ_MAX_PARTITIONS + i, is_keyframe, i == 0 && (i < nb_bands - 1),
skip_rest, encode_flip, flip);
-#else
-#error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
-#endif
}
if (i == 0 && !skip_rest && bs > 0) {
#if CONFIG_DAALA_EC
diff --git a/av1/encoder/pvq_encoder.h b/av1/encoder/pvq_encoder.h
index ef50cbe..c4fbf3e 100644
--- a/av1/encoder/pvq_encoder.h
+++ b/av1/encoder/pvq_encoder.h
@@ -13,6 +13,7 @@
#if !defined(_pvq_encoder_H)
# define _pvq_encoder_H (1)
+# include "aom_dsp/bitwriter.h"
# include "aom_dsp/entenc.h"
# include "av1/common/blockd.h"
# include "av1/common/pvq.h"
@@ -30,7 +31,7 @@
int by, int skip);
#endif
-void pvq_encode_partition(od_ec_enc *ec,
+void pvq_encode_partition(aom_writer *w,
int qg,
int theta,
int max_theta,