Add a CDF for coding delta_q.
Also remove forward updates for delta_q when EC_ADAPT
is enabled.
Change-Id: Idf71b57bfe7763bc60595bc45768e624dd7b67bd
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index c39da5b..b057a56 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -556,18 +556,31 @@
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
#if CONFIG_DELTA_Q
-static void write_delta_qindex(const AV1_COMMON *cm, int delta_qindex,
- aom_writer *w) {
+static void write_delta_qindex(const AV1_COMMON *cm, const MACROBLOCKD *xd,
+ int delta_qindex, aom_writer *w) {
int sign = delta_qindex < 0;
int abs = sign ? -delta_qindex : delta_qindex;
- int rem_bits, thr, i = 0;
+ int rem_bits, thr;
int smallval = abs < DELTA_Q_SMALL ? 1 : 0;
+#if CONFIG_EC_ADAPT
+ FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
+ (void)cm;
+#else
+ FRAME_CONTEXT *ec_ctx = cm->fc;
+ (void)xd;
+#endif
+#if CONFIG_EC_MULTISYMBOL
+ aom_write_symbol(w, AOMMIN(abs, DELTA_Q_SMALL), ec_ctx->delta_q_cdf,
+ DELTA_Q_PROBS + 1);
+#else
+ int i = 0;
while (i < DELTA_Q_SMALL && i <= abs) {
int bit = (i < abs);
- aom_write(w, bit, cm->fc->delta_q_prob[i]);
+ aom_write(w, bit, ec_ctx->delta_q_prob[i]);
i++;
}
+#endif
if (!smallval) {
rem_bits = OD_ILOG_NZ(abs - 1) - 1;
@@ -580,6 +593,7 @@
}
}
+#if !CONFIG_EC_ADAPT
static void update_delta_q_probs(AV1_COMMON *cm, aom_writer *w,
FRAME_COUNTS *counts) {
int k;
@@ -593,7 +607,8 @@
probwt);
}
}
-#endif
+#endif // CONFIG_EC_ADAPT
+#endif // CONFIG_DELTA_Q
static void update_skip_probs(AV1_COMMON *cm, aom_writer *w,
FRAME_COUNTS *counts) {
@@ -1534,7 +1549,7 @@
if ((bsize != BLOCK_64X64 || skip == 0) && super_block_upper_left) {
int reduced_delta_qindex =
(mbmi->current_q_index - xd->prev_qindex) / cm->delta_q_res;
- write_delta_qindex(cm, reduced_delta_qindex, w);
+ write_delta_qindex(cm, xd, reduced_delta_qindex, w);
xd->prev_qindex = mbmi->current_q_index;
}
}
@@ -1916,7 +1931,7 @@
if ((bsize != BLOCK_64X64 || skip == 0) && super_block_upper_left) {
int reduced_delta_qindex =
(mbmi->current_q_index - xd->prev_qindex) / cm->delta_q_res;
- write_delta_qindex(cm, reduced_delta_qindex, w);
+ write_delta_qindex(cm, xd, reduced_delta_qindex, w);
xd->prev_qindex = mbmi->current_q_index;
}
}
@@ -4720,7 +4735,7 @@
#endif
update_skip_probs(cm, header_bc, counts);
-#if CONFIG_DELTA_Q
+#if !CONFIG_EC_ADAPT && CONFIG_DELTA_Q
update_delta_q_probs(cm, header_bc, counts);
#endif
#if !CONFIG_EC_ADAPT