Replace od_ec_dec with aom_reader in daala_dec_ctx.

Use the generic AOM entropy decoder in the daala_dec_ctx struct.
This is done in preparation for migrating other entropy coder calls to
 use the more generic entropy coding API.

Change-Id: I473a278174195401bcf35730fb5db7eb368b097a
diff --git a/av1/decoder/decint.h b/av1/decoder/decint.h
index fb756d4..e887ad5 100644
--- a/av1/decoder/decint.h
+++ b/av1/decoder/decint.h
@@ -14,6 +14,7 @@
 #if !defined(_decint_H)
 # define _decint_H (1)
 # include "av1/common/pvq_state.h"
+# include "aom_dsp/bitreader.h"
 # include "aom_dsp/entdec.h"
 
 typedef struct daala_dec_ctx daala_dec_ctx;
@@ -24,8 +25,8 @@
 struct daala_dec_ctx {
   /* Stores context-adaptive CDFs for PVQ. */
   od_state state;
-  /* Daala entropy decoder. */
-  od_ec_dec *ec;
+  /* AOM entropy decoder. */
+  aom_reader *r;
   int use_activity_masking;
   /* Mode of quantization matrice : FLAT (0) or HVS (1) */
   int qm;
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 4ccdd6b..16fe5ca 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -66,7 +66,6 @@
 #include "av1/common/pvq.h"
 #include "av1/encoder/encodemb.h"
 
-#include "aom_dsp/entdec.h"
 #include "av1/common/partition.h"
 #include "av1/decoder/decint.h"
 #include "av1/encoder/hybrid_fwd_txfm.h"
@@ -373,12 +372,16 @@
   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->ec, &dec->state.adapt.model_dc[pli],
-                                     -1, &dec->state.adapt.ex_dc[pli][bs][0], 2,
-                                     "dc:mag");
+        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
     if (dqcoeff_pvq[0])
-      dqcoeff_pvq[0] *= od_ec_dec_bits(dec->ec, 1, "dc:sign") ? -1 : 1;
+      dqcoeff_pvq[0] *= aom_read_bit(dec->r, "dc:sign") ? -1 : 1;
   }
   dqcoeff_pvq[0] = dqcoeff_pvq[0] * pvq_dc_quant + ref_coeff_pvq[0];
 
@@ -407,15 +410,18 @@
   eob = 0;
   dst = &pd->dst.buf[4 * row * pd->dst.stride + 4 * col];
 
+#if CONFIG_DAALA_EC
   // decode ac/dc coded flag. bit0: DC coded, bit1 : AC coded
   // NOTE : we don't use 5 symbols for luma here in aom codebase,
   // since block partition is taken care of by aom.
   // So, only AC/DC skip info is coded
   ac_dc_coded = od_decode_cdf_adapt(
-      xd->daala_dec.ec,
+      &xd->daala_dec.r->ec,
       xd->daala_dec.state.adapt.skip_cdf[2 * tx_size + (plane != 0)], 4,
       xd->daala_dec.state.adapt.skip_increment, "skip");
-
+#else
+#error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
+#endif
   if (ac_dc_coded) {
     int xdec = pd->subsampling_x;
     int seg_id = mbmi->segment_id;
@@ -3086,8 +3092,8 @@
 
 #if CONFIG_PVQ
 static void daala_dec_init(AV1_COMMON *const cm, daala_dec_ctx *daala_dec,
-                           od_ec_dec *ec) {
-  daala_dec->ec = ec;
+                           aom_reader *r) {
+  daala_dec->r = r;
   od_adapt_ctx_reset(&daala_dec->state.adapt, 0);
 
   // TODO(yushin) : activity masking info needs be signaled by a bitstream
@@ -3232,7 +3238,7 @@
 #endif
                            td->dqcoeff);
 #if CONFIG_PVQ
-      daala_dec_init(cm, &td->xd.daala_dec, &td->bit_reader.ec);
+      daala_dec_init(cm, &td->xd.daala_dec, &td->bit_reader);
 #endif
 #if CONFIG_PALETTE
       td->xd.plane[0].color_index_map = td->color_index_map[0];
@@ -3566,7 +3572,7 @@
 #endif
                              twd->dqcoeff);
 #if CONFIG_PVQ
-        daala_dec_init(cm, &twd->xd.daala_dec, &twd->bit_reader.ec);
+        daala_dec_init(cm, &twd->xd.daala_dec, &twd->bit_reader);
 #endif
 #if CONFIG_PALETTE
         twd->xd.plane[0].color_index_map = twd->color_index_map[0];
diff --git a/av1/decoder/pvq_decoder.c b/av1/decoder/pvq_decoder.c
index 76fbed1..df6ae16 100644
--- a/av1/decoder/pvq_decoder.c
+++ b/av1/decoder/pvq_decoder.c
@@ -354,18 +354,26 @@
       else
         q = OD_MAXI(1, q0);
 
-      pvq_decode_partition(dec->ec, q, size[i],
+#if CONFIG_DAALA_EC
+      pvq_decode_partition(&dec->r->ec, q, size[i],
        model, &dec->state.adapt, exg + i, ext + i, ref + off[i], out + off[i],
        &noref[i], beta[i], robust, is_keyframe, pli,
        (pli != 0)*OD_TXSIZES*PVQ_MAX_PARTITIONS + bs*PVQ_MAX_PARTITIONS + i,
        &cfl, i == 0 && (i < nb_bands - 1), skip_rest, i, &skip[i],
        qm + off[i], qm_inv + off[i]);
+#else
+#error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
+#endif
       if (i == 0 && !skip_rest[0] && bs > 0) {
         int skip_dir;
         int j;
-        skip_dir = od_decode_cdf_adapt(dec->ec,
+#if CONFIG_DAALA_EC
+        skip_dir = od_decode_cdf_adapt(&dec->r->ec,
          &dec->state.adapt.pvq.pvq_skip_dir_cdf[(pli != 0) + 2*(bs - 1)][0], 7,
          dec->state.adapt.pvq.pvq_skip_dir_increment, "pvq:skiprest");
+#else
+#error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
+#endif
         for (j = 0; j < 3; j++) skip_rest[j] = !!(skip_dir & (1 << j));
       }
     }