Remove PVQ code

Change-Id: Id377c68e30031ad4697ca1ba311487b803a8af4c
diff --git a/av1/decoder/decint.h b/av1/decoder/decint.h
deleted file mode 100644
index e887ad5..0000000
--- a/av1/decoder/decint.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2001-2016, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 2 Clause License and
- * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
- * was not distributed with this source code in the LICENSE file, you can
- * obtain it at www.aomedia.org/license/software. If the Alliance for Open
- * Media Patent License 1.0 was not distributed with this source code in the
- * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
- */
-
-/* clang-format off */
-
-#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;
-
-typedef struct daala_dec_ctx od_dec_ctx;
-
-
-struct daala_dec_ctx {
-  /* Stores context-adaptive CDFs for PVQ. */
-  od_state state;
-  /* AOM entropy decoder. */
-  aom_reader *r;
-  int use_activity_masking;
-  /* Mode of quantization matrice : FLAT (0) or HVS (1) */
-  int qm;
-};
-
-#endif
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index bd26fd8..0abca0b 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -73,16 +73,6 @@
 #define MAX_AV1_HEADER_SIZE 80
 #define ACCT_STR __func__
 
-#if CONFIG_PVQ
-#include "av1/common/partition.h"
-#include "av1/common/pvq.h"
-#include "av1/common/scan.h"
-#include "av1/decoder/decint.h"
-#include "av1/decoder/pvq_decoder.h"
-#include "av1/encoder/encodemb.h"
-#include "av1/encoder/hybrid_fwd_txfm.h"
-#endif
-
 #if CONFIG_CFL
 #include "av1/common/cfl.h"
 #endif
@@ -279,189 +269,14 @@
   return row * max_blocks_wide + col * txh_unit;
 }
 
-#if CONFIG_PVQ
-static int av1_pvq_decode_helper(MACROBLOCKD *xd, tran_low_t *ref_coeff,
-                                 tran_low_t *dqcoeff, int16_t *quant, int pli,
-                                 int bs, TX_TYPE tx_type, int xdec,
-                                 PVQ_SKIP_TYPE ac_dc_coded) {
-  unsigned int flags;  // used for daala's stream analyzer.
-  int off;
-  const int is_keyframe = 0;
-  const int has_dc_skip = 1;
-  int coeff_shift = 3 - av1_get_tx_scale(bs);
-  int hbd_downshift = 0;
-  int rounding_mask;
-  // DC quantizer for PVQ
-  int pvq_dc_quant;
-  int lossless = (quant[0] == 0);
-  const int blk_size = tx_size_wide[bs];
-  int eob = 0;
-  int i;
-  od_dec_ctx *dec = &xd->daala_dec;
-  int use_activity_masking = dec->use_activity_masking;
-  DECLARE_ALIGNED(16, tran_low_t, dqcoeff_pvq[OD_TXSIZE_MAX * OD_TXSIZE_MAX]);
-  DECLARE_ALIGNED(16, tran_low_t, ref_coeff_pvq[OD_TXSIZE_MAX * OD_TXSIZE_MAX]);
-
-  od_coeff ref_int32[OD_TXSIZE_MAX * OD_TXSIZE_MAX];
-  od_coeff out_int32[OD_TXSIZE_MAX * OD_TXSIZE_MAX];
-
-  hbd_downshift = xd->bd - 8;
-
-  od_raster_to_coding_order(ref_coeff_pvq, blk_size, tx_type, ref_coeff,
-                            blk_size);
-
-  assert(OD_COEFF_SHIFT >= 4);
-  if (lossless)
-    pvq_dc_quant = 1;
-  else {
-    if (use_activity_masking)
-      pvq_dc_quant =
-          OD_MAXI(1,
-                  (quant[0] << (OD_COEFF_SHIFT - 3) >> hbd_downshift) *
-                          dec->state.pvq_qm_q4[pli][od_qm_get_index(bs, 0)] >>
-                      4);
-    else
-      pvq_dc_quant =
-          OD_MAXI(1, quant[0] << (OD_COEFF_SHIFT - 3) >> hbd_downshift);
-  }
-
-  off = od_qm_offset(bs, xdec);
-
-  // copy int16 inputs to int32
-  for (i = 0; i < blk_size * blk_size; i++) {
-    ref_int32[i] =
-        AOM_SIGNED_SHL(ref_coeff_pvq[i], OD_COEFF_SHIFT - coeff_shift) >>
-        hbd_downshift;
-  }
-
-  od_pvq_decode(dec, ref_int32, out_int32,
-                OD_MAXI(1, quant[1] << (OD_COEFF_SHIFT - 3) >> hbd_downshift),
-                pli, bs, OD_PVQ_BETA[use_activity_masking][pli][bs],
-                is_keyframe, &flags, ac_dc_coded, dec->state.qm + off,
-                dec->state.qm_inv + off);
-
-  if (!has_dc_skip || out_int32[0]) {
-    out_int32[0] =
-        has_dc_skip + generic_decode(dec->r, &dec->state.adapt->model_dc[pli],
-                                     &dec->state.adapt->ex_dc[pli][bs][0], 2,
-                                     "dc:mag");
-    if (out_int32[0]) out_int32[0] *= aom_read_bit(dec->r, "dc:sign") ? -1 : 1;
-  }
-  out_int32[0] = out_int32[0] * pvq_dc_quant + ref_int32[0];
-
-  // copy int32 result back to int16
-  assert(OD_COEFF_SHIFT > coeff_shift);
-  rounding_mask = (1 << (OD_COEFF_SHIFT - coeff_shift - 1)) - 1;
-  for (i = 0; i < blk_size * blk_size; i++) {
-    out_int32[i] = AOM_SIGNED_SHL(out_int32[i], hbd_downshift);
-    dqcoeff_pvq[i] = (out_int32[i] + (out_int32[i] < 0) + rounding_mask) >>
-                     (OD_COEFF_SHIFT - coeff_shift);
-  }
-
-  od_coding_order_to_raster(dqcoeff, blk_size, tx_type, dqcoeff_pvq, blk_size);
-
-  eob = blk_size * blk_size;
-
-  return eob;
-}
-
-static PVQ_SKIP_TYPE read_pvq_skip(AV1_COMMON *cm, MACROBLOCKD *const xd,
-                                   int plane, TX_SIZE tx_size) {
-  // 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
-  const int ac_dc_coded = aom_read_symbol(
-      xd->daala_dec.r,
-      xd->daala_dec.state.adapt->skip_cdf[2 * tx_size + (plane != 0)], 4,
-      "skip");
-  if (ac_dc_coded < 0 || ac_dc_coded > 3) {
-    aom_internal_error(&cm->error, AOM_CODEC_INVALID_PARAM,
-                       "Invalid PVQ Skip Type");
-  }
-  return ac_dc_coded;
-}
-
-static int av1_pvq_decode_helper2(AV1_COMMON *cm, MACROBLOCKD *const xd,
-                                  MB_MODE_INFO *const mbmi, int plane, int row,
-                                  int col, TX_SIZE tx_size, TX_TYPE tx_type) {
-  struct macroblockd_plane *const pd = &xd->plane[plane];
-  // transform block size in pixels
-  int tx_blk_size = tx_size_wide[tx_size];
-  int i, j;
-  tran_low_t *pvq_ref_coeff = pd->pvq_ref_coeff;
-  const int diff_stride = tx_blk_size;
-  int16_t *pred = pd->pred;
-  tran_low_t *const dqcoeff = pd->dqcoeff;
-  uint8_t *dst;
-  int eob;
-  const PVQ_SKIP_TYPE ac_dc_coded = read_pvq_skip(cm, xd, plane, tx_size);
-
-  eob = 0;
-  dst = &pd->dst.buf[4 * row * pd->dst.stride + 4 * col];
-
-  if (ac_dc_coded) {
-    int xdec = pd->subsampling_x;
-    int seg_id = mbmi->segment_id;
-    int16_t *quant;
-    TxfmParam txfm_param;
-    // ToDo(yaowu): correct this with optimal number from decoding process.
-    const int max_scan_line = tx_size_2d[tx_size];
-#if CONFIG_HIGHBITDEPTH
-    if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-      for (j = 0; j < tx_blk_size; j++)
-        for (i = 0; i < tx_blk_size; i++)
-          pred[diff_stride * j + i] =
-              CONVERT_TO_SHORTPTR(dst)[pd->dst.stride * j + i];
-    } else {
-#endif
-      for (j = 0; j < tx_blk_size; j++)
-        for (i = 0; i < tx_blk_size; i++)
-          pred[diff_stride * j + i] = dst[pd->dst.stride * j + i];
-#if CONFIG_HIGHBITDEPTH
-    }
-#endif
-
-    txfm_param.tx_type = tx_type;
-    txfm_param.tx_size = tx_size;
-    txfm_param.lossless = xd->lossless[seg_id];
-
-#if CONFIG_HIGHBITDEPTH
-    if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-      txfm_param.bd = xd->bd;
-      av1_highbd_fwd_txfm(pred, pvq_ref_coeff, diff_stride, &txfm_param);
-    } else {
-#endif  // CONFIG_HIGHBITDEPTH
-      av1_fwd_txfm(pred, pvq_ref_coeff, diff_stride, &txfm_param);
-#if CONFIG_HIGHBITDEPTH
-    }
-#endif  // CONFIG_HIGHBITDEPTH
-
-    quant = &pd->seg_dequant[seg_id][0];  // aom's quantizer
-
-    eob = av1_pvq_decode_helper(xd, pvq_ref_coeff, dqcoeff, quant, plane,
-                                tx_size, tx_type, xdec, ac_dc_coded);
-
-    inverse_transform_block(xd, plane, tx_type, tx_size, dst, pd->dst.stride,
-                            max_scan_line, eob);
-  }
-
-  return eob;
-}
-#endif
-
 static void predict_and_reconstruct_intra_block(
     AV1_COMMON *cm, MACROBLOCKD *const xd, aom_reader *const r,
     MB_MODE_INFO *const mbmi, int plane, int row, int col, TX_SIZE tx_size) {
   PLANE_TYPE plane_type = get_plane_type(plane);
   const int block_idx = get_block_idx(xd, plane, row, col);
-#if CONFIG_PVQ
-  (void)r;
-#endif
   av1_predict_intra_block_facade(cm, xd, plane, block_idx, col, row, tx_size);
 
   if (!mbmi->skip) {
-#if !CONFIG_PVQ
     struct macroblockd_plane *const pd = &xd->plane[plane];
 #if CONFIG_LV_MAP
     int16_t max_scan_line = 0;
@@ -490,11 +305,6 @@
                               tx_type, tx_size, dst, pd->dst.stride,
                               max_scan_line, eob);
     }
-#else   // !CONFIG_PVQ
-    const TX_TYPE tx_type =
-        av1_get_tx_type(plane_type, xd, row, col, block_idx, tx_size);
-    av1_pvq_decode_helper2(cm, xd, mbmi, plane, row, col, tx_size, tx_type);
-#endif  // !CONFIG_PVQ
   }
 #if CONFIG_CFL
   if (plane == AOM_PLANE_Y && xd->cfl->store_y) {
@@ -598,15 +408,8 @@
                                    TX_SIZE tx_size) {
   PLANE_TYPE plane_type = get_plane_type(plane);
   int block_idx = get_block_idx(xd, plane, row, col);
-#if CONFIG_PVQ
-  int eob;
-  (void)r;
-  (void)segment_id;
-#else
   struct macroblockd_plane *const pd = &xd->plane[plane];
-#endif
 
-#if !CONFIG_PVQ
 #if CONFIG_LV_MAP
   (void)segment_id;
   int16_t max_scan_line = 0;
@@ -635,12 +438,7 @@
 #endif
                             tx_type, tx_size, dst, pd->dst.stride,
                             max_scan_line, eob);
-#else
-  const TX_TYPE tx_type =
-      av1_get_tx_type(plane_type, xd, row, col, block_idx, tx_size);
-  eob = av1_pvq_decode_helper2(cm, xd, &xd->mi[0]->mbmi, plane, row, col,
-                               tx_size, tx_type);
-#endif
+
   return eob;
 }
 #endif  // !CONFIG_VAR_TX || CONFIG_SUPER_TX
@@ -878,13 +676,10 @@
       int row_y, col_y, row_c, col_c;
       int plane;
 
-// TODO(anybody) : remove this flag when PVQ supports pallete coding tool
-#if !CONFIG_PVQ
       for (plane = 0; plane <= 1; ++plane) {
         if (mbmi->palette_mode_info.palette_size[plane])
           av1_decode_palette_tokens(xd, plane, r);
       }
-#endif  // !CONFIG_PVQ
 
       for (row_y = 0; row_y < tu_num_h_y; row_y++) {
         for (col_y = 0; col_y < tu_num_w_y; col_y++) {
@@ -965,13 +760,10 @@
   if (!is_inter_block(mbmi)) {
     int plane;
 
-// TODO(anybody) : remove this flag when PVQ supports pallete coding tool
-#if !CONFIG_PVQ
     for (plane = 0; plane <= 1; ++plane) {
       if (mbmi->palette_mode_info.palette_size[plane])
         av1_decode_palette_tokens(xd, plane, r);
     }
-#endif  // #if !CONFIG_PVQ
 
     for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
       const struct macroblockd_plane *const pd = &xd->plane[plane];
@@ -1336,11 +1128,6 @@
                        block_size_wide[subsize], block_size_high[subsize]);
   }
 
-#if CONFIG_PVQ
-  assert(partition < PARTITION_TYPES);
-  assert(subsize < BLOCK_SIZES_ALL);
-#endif
-
 #define DEC_BLOCK_STX_ARG
 #if CONFIG_EXT_PARTITION_TYPES
 #define DEC_BLOCK_EPT_ARG partition,
@@ -2580,52 +2367,6 @@
   }
 }
 
-#if CONFIG_PVQ
-static void daala_dec_init(AV1_COMMON *const cm, daala_dec_ctx *daala_dec,
-                           aom_reader *r) {
-  daala_dec->r = r;
-
-  // TODO(yushin) : activity masking info needs be signaled by a bitstream
-  daala_dec->use_activity_masking = AV1_PVQ_ENABLE_ACTIVITY_MASKING;
-
-  if (daala_dec->use_activity_masking)
-    daala_dec->qm = OD_HVS_QM;
-  else
-    daala_dec->qm = OD_FLAT_QM;
-
-  od_init_qm(daala_dec->state.qm, daala_dec->state.qm_inv,
-             daala_dec->qm == OD_HVS_QM ? OD_QM8_Q4_HVS : OD_QM8_Q4_FLAT);
-
-  if (daala_dec->use_activity_masking) {
-    int pli;
-    int use_masking = daala_dec->use_activity_masking;
-    int segment_id = 0;
-    int qindex = av1_get_qindex(&cm->seg, segment_id, cm->base_qindex);
-
-    for (pli = 0; pli < MAX_MB_PLANE; pli++) {
-      int i;
-      int q;
-
-      q = qindex;
-      if (q <= OD_DEFAULT_QMS[use_masking][0][pli].interp_q << OD_COEFF_SHIFT) {
-        od_interp_qm(&daala_dec->state.pvq_qm_q4[pli][0], q,
-                     &OD_DEFAULT_QMS[use_masking][0][pli], NULL);
-      } else {
-        i = 0;
-        while (OD_DEFAULT_QMS[use_masking][i + 1][pli].qm_q4 != NULL &&
-               q > OD_DEFAULT_QMS[use_masking][i + 1][pli].interp_q
-                       << OD_COEFF_SHIFT) {
-          i++;
-        }
-        od_interp_qm(&daala_dec->state.pvq_qm_q4[pli][0], q,
-                     &OD_DEFAULT_QMS[use_masking][i][pli],
-                     &OD_DEFAULT_QMS[use_masking][i + 1][pli]);
-      }
-    }
-  }
-}
-#endif  // #if CONFIG_PVQ
-
 #if CONFIG_LOOPFILTERING_ACROSS_TILES
 static void dec_setup_across_tile_boundary_info(
     const AV1_COMMON *const cm, const TileInfo *const tile_info) {
@@ -2744,9 +2485,6 @@
               ? &cm->counts
               : NULL;
       av1_zero(td->dqcoeff);
-#if CONFIG_PVQ
-      av1_zero(td->pvq_ref_coeff);
-#endif
       av1_tile_init(&td->xd.tile, td->cm, tile_row, tile_col);
       setup_bool_decoder(buf->data, data_end, buf->size, &cm->error,
                          &td->bit_reader,
@@ -2762,9 +2500,6 @@
       }
 #endif
       av1_init_macroblockd(cm, &td->xd,
-#if CONFIG_PVQ
-                           td->pvq_ref_coeff,
-#endif
 #if CONFIG_CFL
                            &td->cfl,
 #endif
@@ -2773,12 +2508,6 @@
       // Initialise the tile context from the frame context
       td->tctx = *cm->fc;
       td->xd.tile_ctx = &td->tctx;
-
-#if CONFIG_PVQ
-      daala_dec_init(cm, &td->xd.daala_dec, &td->bit_reader);
-      td->xd.daala_dec.state.adapt = &td->tctx.pvq_context;
-#endif
-
       td->xd.plane[0].color_index_map = td->color_index_map[0];
       td->xd.plane[1].color_index_map = td->color_index_map[1];
 #if CONFIG_MRC_TX
@@ -4293,9 +4022,6 @@
                                   num_bwd_ctxs);
       av1_average_tile_loopfilter_cdfs(pbi->common.fc, tile_ctxs, cdf_ptrs,
                                        num_bwd_ctxs);
-#if CONFIG_PVQ
-      av1_average_tile_pvq_cdfs(pbi->common.fc, tile_ctxs, num_bwd_ctxs);
-#endif  // CONFIG_PVQ
 #if CONFIG_ADAPT_SCAN
       av1_adapt_scan_order(cm);
 #endif  // CONFIG_ADAPT_SCAN
diff --git a/av1/decoder/decoder.c b/av1/decoder/decoder.c
index c9bc612..bc34561 100644
--- a/av1/decoder/decoder.c
+++ b/av1/decoder/decoder.c
@@ -36,9 +36,7 @@
 #if CONFIG_NCOBMC_ADAPT_WEIGHT
 #include "av1/common/ncobmc_kernels.h"
 #endif  // CONFIG_NCOBMC_ADAPT_WEIGHT
-#if !CONFIG_PVQ
 #include "av1/decoder/detokenize.h"
-#endif
 
 static void initialize_dec(void) {
   static volatile int init_done = 0;
diff --git a/av1/decoder/decoder.h b/av1/decoder/decoder.h
index 0871995..dcd0caf 100644
--- a/av1/decoder/decoder.h
+++ b/av1/decoder/decoder.h
@@ -29,12 +29,6 @@
 #include "av1/decoder/inspection.h"
 #endif
 
-#if CONFIG_PVQ
-#include "aom_dsp/entdec.h"
-#include "av1/decoder/decint.h"
-#include "av1/encoder/encodemb.h"
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -46,10 +40,6 @@
   DECLARE_ALIGNED(16, MACROBLOCKD, xd);
   /* dqcoeff are shared by all the planes. So planes must be decoded serially */
   DECLARE_ALIGNED(16, tran_low_t, dqcoeff[MAX_TX_SQUARE]);
-#if CONFIG_PVQ
-  /* forward transformed predicted image, a reference for PVQ */
-  DECLARE_ALIGNED(16, tran_low_t, pvq_ref_coeff[OD_TXSIZE_MAX * OD_TXSIZE_MAX]);
-#endif
 #if CONFIG_CFL
   CFL_CTX cfl;
 #endif
@@ -67,10 +57,6 @@
   DECLARE_ALIGNED(16, MACROBLOCKD, xd);
   /* dqcoeff are shared by all the planes. So planes must be decoded serially */
   DECLARE_ALIGNED(16, tran_low_t, dqcoeff[MAX_TX_SQUARE]);
-#if CONFIG_PVQ
-  /* forward transformed predicted image, a reference for PVQ */
-  DECLARE_ALIGNED(16, tran_low_t, pvq_ref_coeff[OD_TXSIZE_MAX * OD_TXSIZE_MAX]);
-#endif
 #if CONFIG_CFL
   CFL_CTX cfl;
 #endif
diff --git a/av1/decoder/detokenize.c b/av1/decoder/detokenize.c
index a59a7ba..b352c65 100644
--- a/av1/decoder/detokenize.c
+++ b/av1/decoder/detokenize.c
@@ -10,25 +10,18 @@
  */
 
 #include "./aom_config.h"
-#if !CONFIG_PVQ
 #include "aom_mem/aom_mem.h"
 #include "aom_ports/mem.h"
-#endif  // !CONFIG_PVQ
-
 #include "av1/common/blockd.h"
 #include "av1/decoder/detokenize.h"
 
 #define ACCT_STR __func__
 
-#if !CONFIG_PVQ || CONFIG_VAR_TX
 #include "av1/common/common.h"
 #include "av1/common/entropy.h"
 #include "av1/common/idct.h"
-#endif
-
 #include "av1/decoder/symbolrate.h"
 
-#if !CONFIG_PVQ || CONFIG_VAR_TX
 #define EOB_CONTEXT_NODE 0
 #define ZERO_CONTEXT_NODE 1
 #define ONE_CONTEXT_NODE 2
@@ -247,7 +240,6 @@
 
   return c;
 }
-#endif  // !CONFIG_PVQ
 
 static void decode_color_map_tokens(Av1ColorMapParam *param, aom_reader *r) {
   uint8_t color_order[PALETTE_MAX_SIZE];
@@ -359,7 +351,6 @@
 }
 #endif  // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
 
-#if !CONFIG_PVQ || CONFIG_VAR_TX
 int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
                             const SCAN_ORDER *sc, int x, int y, TX_SIZE tx_size,
                             TX_TYPE tx_type, int16_t *max_scan_line,
@@ -398,4 +389,3 @@
 #endif
   return eob;
 }
-#endif  // !CONFIG_PVQ
diff --git a/av1/decoder/detokenize.h b/av1/decoder/detokenize.h
index eb31d58..bfd4b23 100644
--- a/av1/decoder/detokenize.h
+++ b/av1/decoder/detokenize.h
@@ -13,9 +13,7 @@
 #define AV1_DECODER_DETOKENIZE_H_
 
 #include "./aom_config.h"
-#if !CONFIG_PVQ || CONFIG_VAR_TX
 #include "av1/common/scan.h"
-#endif  // !CONFIG_PVQ || CONFIG_VAR_TX
 #include "av1/decoder/decoder.h"
 
 #ifdef __cplusplus
@@ -24,12 +22,11 @@
 
 void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane, aom_reader *r);
 
-#if !CONFIG_PVQ || CONFIG_VAR_TX
 int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
                             const SCAN_ORDER *sc, int x, int y, TX_SIZE tx_size,
                             TX_TYPE tx_type, int16_t *max_scan_line,
                             aom_reader *r, int seg_id);
-#endif  // !CONFIG_PVQ
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif
diff --git a/av1/decoder/generic_decoder.c b/av1/decoder/generic_decoder.c
deleted file mode 100644
index 0c7d71b..0000000
--- a/av1/decoder/generic_decoder.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2001-2016, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 2 Clause License and
- * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
- * was not distributed with this source code in the LICENSE file, you can
- * obtain it at www.aomedia.org/license/software. If the Alliance for Open
- * Media Patent License 1.0 was not distributed with this source code in the
- * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
- */
-
-/* clang-format off */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-
-#include "aom_dsp/bitreader.h"
-#include "av1/common/generic_code.h"
-#include "av1/common/odintrin.h"
-#include "pvq_decoder.h"
-
-/** Decodes a value from 0 to N-1 (with N up to 16) based on a cdf and adapts
- * the cdf accordingly.
- *
- * @param [in,out] r     multi-symbol entropy decoder
- * @param [in,out] cdf   CDF of the variable (Q15)
- * @param [in]     n     number of values possible
- * @param [in,out] count number of symbols encoded with that cdf so far
- * @param [in]     rate  adaptation rate shift (smaller is faster)
- * @return decoded variable
- */
-int aom_decode_cdf_adapt_q15_(aom_reader *r, uint16_t *cdf, int n,
- int *count, int rate ACCT_STR_PARAM) {
-  int val;
-  int i;
-  if (*count == 0) {
-    int ft;
-    ft = cdf[n - 1];
-    for (i = 0; i < n; i++) {
-      cdf[i] = AOM_ICDF(cdf[i]*32768/ft);
-    }
-  }
-  val = aom_read_cdf(r, cdf, n, ACCT_STR_NAME);
-  aom_cdf_adapt_q15(val, cdf, n, count, rate);
-  return val;
-}
-
-/** Encodes a random variable using a "generic" model, assuming that the
- * distribution is one-sided (zero and up), has a single mode, and decays
- * exponentially past the model.
- *
- * @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)
- * @param [in]     integration integration period of ExQ16 (leaky average over
- * 1<<integration samples)
- *
- * @retval decoded variable x
- */
-int generic_decode_(aom_reader *r, generic_encoder *model,
- int *ex_q16, int integration ACCT_STR_PARAM) {
-  int lg_q1;
-  int shift;
-  int id;
-  uint16_t *cdf;
-  int xs;
-  int lsb;
-  int x;
-  lsb = 0;
-  lg_q1 = log_ex(*ex_q16);
-  /* If expectation is too large, shift x to ensure that
-     all we have past xs=15 is the exponentially decaying tail
-     of the distribution. */
-  shift = OD_MAXI(0, (lg_q1 - 5) >> 1);
-  /* Choose the cdf to use: we have two per "octave" of ExQ16. */
-  id = OD_MINI(GENERIC_TABLES - 1, lg_q1);
-  cdf = model->cdf[id];
-  xs = aom_read_symbol_pvq(r, cdf, 16, ACCT_STR_NAME);
-  if (xs == 15) {
-    int e;
-    unsigned decay;
-    /* Estimate decay based on the assumption that the distribution is close
-       to Laplacian for large values. We should probably have an adaptive
-       estimate instead. Note: The 2* is a kludge that's not fully understood
-       yet. */
-    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 += aom_laplace_decode_special(r, decay, ACCT_STR_NAME);
-  }
-  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 = aom_read_literal(r, shift - special, ACCT_STR_NAME);
-    }
-    lsb -= !special << (shift - 1);
-  }
-  x = (xs << shift) + lsb;
-  generic_model_update(ex_q16, x, integration);
-  OD_LOG((OD_LOG_ENTROPY_CODER, OD_LOG_DEBUG,
-   "dec: %d %d %d %d %d %x", *ex_q16, x, shift, id, xs, dec->rng));
-  return x;
-}
diff --git a/av1/decoder/laplace_decoder.c b/av1/decoder/laplace_decoder.c
deleted file mode 100644
index 5cc080e..0000000
--- a/av1/decoder/laplace_decoder.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2001-2016, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 2 Clause License and
- * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
- * was not distributed with this source code in the LICENSE file, you can
- * obtain it at www.aomedia.org/license/software. If the Alliance for Open
- * Media Patent License 1.0 was not distributed with this source code in the
- * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
- */
-/* clang-format off */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-
-#include "aom_dsp/bitreader.h"
-#include "av1/common/pvq.h"
-#include "pvq_decoder.h"
-
-#define aom_decode_pvq_split(r, adapt, sum, ctx, ACCT_STR_NAME) \
-  aom_decode_pvq_split_(r, adapt, sum, ctx ACCT_STR_ARG(ACCT_STR_NAME))
-
-static int aom_decode_pvq_split_(aom_reader *r, od_pvq_codeword_ctx *adapt,
- int sum, int ctx ACCT_STR_PARAM) {
-  int shift;
-  int count;
-  int msbs;
-  int fctx;
-  count = 0;
-  if (sum == 0) return 0;
-  shift = OD_MAXI(0, OD_ILOG(sum) - 3);
-  fctx = 7*ctx + (sum >> shift) - 1;
-  msbs = aom_read_symbol_pvq(r, adapt->pvq_split_cdf[fctx], (sum >> shift) + 1,
-      ACCT_STR_NAME);
-  if (shift) count = aom_read_literal(r, shift, ACCT_STR_NAME);
-  count += msbs << shift;
-  if (count > sum) {
-    count = sum;
-#if !CONFIG_ANS
-    r->ec.error = 1;
-#else
-# error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
-  }
-  return count;
-}
-
-void aom_decode_band_pvq_splits(aom_reader *r, od_pvq_codeword_ctx *adapt,
- od_coeff *y, int n, int k, int level) {
-  int mid;
-  int count_right;
-  if (n == 1) {
-    y[0] = k;
-  }
-  else if (k == 0) {
-    OD_CLEAR(y, n);
-  }
-  else if (k == 1 && n <= 16) {
-    int cdf_id;
-    int pos;
-    cdf_id = od_pvq_k1_ctx(n, level == 0);
-    OD_CLEAR(y, n);
-    pos = aom_read_symbol_pvq(r, adapt->pvq_k1_cdf[cdf_id], n, "pvq:k1");
-    y[pos] = 1;
-  }
-  else {
-    mid = n >> 1;
-    count_right = aom_decode_pvq_split(r, adapt, k, od_pvq_size_ctx(n),
-     "pvq:split");
-    aom_decode_band_pvq_splits(r, adapt, y, mid, k - count_right, level + 1);
-    aom_decode_band_pvq_splits(r, adapt, y + mid, n - mid, count_right,
-     level + 1);
-  }
-}
-
-/** Decodes the tail of a Laplace-distributed variable, i.e. it doesn't
- * do anything special for the zero case.
- *
- * @param [dec] range decoder
- * @param [decay] decay factor of the distribution, i.e. pdf ~= decay^x
- *
- * @retval decoded variable x
- */
-int aom_laplace_decode_special_(aom_reader *r, unsigned decay ACCT_STR_PARAM) {
-  int pos;
-  int shift;
-  int xs;
-  int sym;
-  const uint16_t *cdf;
-  shift = 0;
-  /* We don't want a large decay value because that would require too many
-     symbols. */
-  while (decay > 235) {
-    decay = (decay*decay + 128) >> 8;
-    shift++;
-  }
-  decay = OD_MINI(decay, 254);
-  decay = OD_MAXI(decay, 2);
-  cdf = EXP_CDF_TABLE[(decay + 1) >> 1];
-  OD_LOG((OD_LOG_PVQ, OD_LOG_DEBUG, "decay = %d\n", decay));
-  xs = 0;
-  do {
-    sym = OD_MINI(xs, 15);
-    {
-      int i;
-      OD_LOG((OD_LOG_PVQ, OD_LOG_DEBUG, "%d %d %d", xs, shift, sym));
-      for (i = 0; i < 16; i++) {
-        OD_LOG_PARTIAL((OD_LOG_PVQ, OD_LOG_DEBUG, "%d ", cdf[i]));
-      }
-      OD_LOG_PARTIAL((OD_LOG_PVQ, OD_LOG_DEBUG, "\n"));
-    }
-    sym = aom_read_cdf(r, cdf, 16, ACCT_STR_NAME);
-    xs += sym;
-  } while (sym >= 15);
-  if (shift) pos = (xs << shift) + aom_read_literal(r, shift, ACCT_STR_NAME);
-  else pos = xs;
-  return pos;
-}
diff --git a/av1/decoder/pvq_decoder.c b/av1/decoder/pvq_decoder.c
deleted file mode 100644
index d9a8e80..0000000
--- a/av1/decoder/pvq_decoder.c
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * Copyright (c) 2001-2016, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 2 Clause License and
- * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
- * was not distributed with this source code in the LICENSE file, you can
- * obtain it at www.aomedia.org/license/software. If the Alliance for Open
- * Media Patent License 1.0 was not distributed with this source code in the
- * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
- */
-
-/* clang-format off */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "./aom_config.h"
-#include "aom_dsp/bitreader.h"
-#include "aom_dsp/entcode.h"
-#include "aom_dsp/entdec.h"
-#include "av1/common/odintrin.h"
-#include "av1/common/partition.h"
-#include "av1/common/pvq_state.h"
-#include "av1/decoder/decint.h"
-#include "av1/decoder/pvq_decoder.h"
-#include "aom_ports/system_state.h"
-
-int aom_read_symbol_pvq_(aom_reader *r, aom_cdf_prob *cdf, int nsymbs
- ACCT_STR_PARAM) {
-  if (cdf[0] == 0)
-    aom_cdf_init_q15_1D(cdf, nsymbs, CDF_SIZE(nsymbs));
-  return aom_read_symbol(r, cdf, nsymbs, ACCT_STR_NAME);
-}
-
-static void aom_decode_pvq_codeword(aom_reader *r, od_pvq_codeword_ctx *ctx,
- od_coeff *y, int n, int k) {
-  int i;
-  aom_decode_band_pvq_splits(r, ctx, y, n, k, 0);
-  for (i = 0; i < n; i++) {
-    if (y[i] && aom_read_bit(r, "pvq:sign")) y[i] = -y[i];
-  }
-}
-
-/** Inverse of neg_interleave; decodes the interleaved gain.
- *
- * @param [in]      x      quantized/interleaved gain to decode
- * @param [in]      ref    quantized gain of the reference
- * @return                 original quantized gain value
- */
-static int neg_deinterleave(int x, int ref) {
-  if (x < 2*ref-1) {
-    if (x & 1) return ref - 1 - (x >> 1);
-    else return ref + (x >> 1);
-  }
-  else return x+1;
-}
-
-/** Synthesizes one parition of coefficient values from a PVQ-encoded
- * vector.
- *
- * @param [out]     xcoeff  output coefficient partition (x in math doc)
- * @param [in]      ypulse  PVQ-encoded values (y in math doc); in the noref
- *                          case, this vector has n entries, in the
- *                          reference case it contains n-1 entries
- *                          (the m-th entry is not included)
- * @param [in]      ref     reference vector (prediction)
- * @param [in]      n       number of elements in this partition
- * @param [in]      gr      gain of the reference vector (prediction)
- * @param [in]      noref   indicates presence or lack of prediction
- * @param [in]      g       decoded quantized vector gain
- * @param [in]      theta   decoded theta (prediction error)
- * @param [in]      qm      QM with magnitude compensation
- * @param [in]      qm_inv  Inverse of QM with magnitude compensation
- */
-static void pvq_synthesis(od_coeff *xcoeff, od_coeff *ypulse, od_val16 *r16,
- int n, od_val32 gr, int noref, od_val32 g, od_val32 theta, const int16_t *qm_inv,
- int shift) {
-  int s;
-  int m;
-  /* Sign of the Householder reflection vector */
-  s = 0;
-  /* Direction of the Householder reflection vector */
-  m = noref ? 0 : od_compute_householder(r16, n, gr, &s, shift);
-  od_pvq_synthesis_partial(xcoeff, ypulse, r16, n, noref, g, theta, m, s,
-   qm_inv);
-}
-
-typedef struct {
-  od_coeff *ref;
-  int nb_coeffs;
-  int allow_flip;
-} cfl_ctx;
-
-/** Decodes a single vector of integers (eg, a partition within a
- *  coefficient block) encoded using PVQ
- *
- * @param [in,out] ec          range encoder
- * @param [in]     q0          scale/quantizer
- * @param [in]     n           number of coefficients in partition
- * @param [in,out] model       entropy decoder state
- * @param [in,out] adapt       adaptation context
- * @param [in,out] exg         ExQ16 expectation of decoded gain value
- * @param [in,out] ext         ExQ16 expectation of decoded theta value
- * @param [in]     ref         'reference' (prediction) vector
- * @param [out]    out         decoded partition
- * @param [out]    noref       boolean indicating absence of reference
- * @param [in]     beta        per-band activity masking beta param
- * @param [in]     is_keyframe whether we're encoding a keyframe
- * @param [in]     pli         plane index
- * @param [in]     cdf_ctx     selects which cdf context to use
- * @param [in,out] skip_rest   whether to skip further bands in each direction
- * @param [in]     band        index of the band being decoded
- * @param [in]     band        index of the band being decoded
- * @param [out]    skip        skip flag with range [0,1]
- * @param [in]     qm          QM with magnitude compensation
- * @param [in]     qm_inv      Inverse of QM with magnitude compensation
- */
-static void pvq_decode_partition(aom_reader *r,
-                                 int q0,
-                                 int n,
-                                 generic_encoder model[3],
-                                 od_adapt_ctx *adapt,
-                                 int *exg,
-                                 int *ext,
-                                 od_coeff *ref,
-                                 od_coeff *out,
-                                 int *noref,
-                                 od_val16 beta,
-                                 int is_keyframe,
-                                 int pli,
-                                 int cdf_ctx,
-                                 cfl_ctx *cfl,
-                                 int has_skip,
-                                 int *skip_rest,
-                                 int band,
-                                 int *skip,
-                                 const int16_t *qm,
-                                 const int16_t *qm_inv) {
-  int k;
-  od_val32 qcg;
-  int itheta;
-  od_val32 theta;
-  od_val32 gr;
-  od_val32 gain_offset;
-  od_coeff y[MAXN];
-  int qg;
-  int id;
-  int i;
-  od_val16 ref16[MAXN];
-  int rshift;
-  theta = 0;
-  gr = 0;
-  gain_offset = 0;
-  /* Skip is per-direction. For band=0, we can use any of the flags. */
-  if (skip_rest[(band + 2) % 3]) {
-    qg = 0;
-    if (is_keyframe) {
-      itheta = -1;
-      *noref = 1;
-    }
-    else {
-      itheta = 0;
-      *noref = 0;
-    }
-  }
-  else {
-    /* Jointly decode gain, itheta and noref for small values. Then we handle
-       larger gain. */
-    id = aom_read_symbol_pvq(r, &adapt->pvq.pvq_gaintheta_cdf[cdf_ctx][0],
-     8 + 7*has_skip, "pvq:gaintheta");
-    if (!is_keyframe && id >= 10) id++;
-    if (is_keyframe && id >= 8) id++;
-    if (id >= 8) {
-      id -= 8;
-      skip_rest[0] = skip_rest[1] = skip_rest[2] = 1;
-    }
-    qg = id & 1;
-    itheta = (id >> 1) - 1;
-    *noref = (itheta == -1);
-  }
-  /* The CfL flip bit is only decoded on the first band that has noref=0. */
-  if (cfl->allow_flip && !*noref) {
-    int flip;
-    flip = aom_read_bit(r, "cfl:flip");
-    if (flip) {
-      for (i = 0; i < cfl->nb_coeffs; i++) cfl->ref[i] = -cfl->ref[i];
-    }
-    cfl->allow_flip = 0;
-  }
-  if (qg > 0) {
-    int tmp;
-    tmp = *exg;
-    qg = 1 + generic_decode(r, &model[!*noref], &tmp, 2, "pvq:gain");
-    OD_IIR_DIADIC(*exg, qg << 16, 2);
-  }
-  *skip = 0;
-#if defined(OD_FLOAT_PVQ)
-  rshift = 0;
-#else
-  /* Shift needed to make the reference fit in 15 bits, so that the Householder
-     vector can fit in 16 bits. */
-  rshift = OD_MAXI(0, od_vector_log_mag(ref, n) - 14);
-#endif
-  for (i = 0; i < n; i++) {
-#if defined(OD_FLOAT_PVQ)
-    ref16[i] = ref[i]*(double)qm[i]*OD_QM_SCALE_1;
-#else
-    ref16[i] = OD_SHR_ROUND(ref[i]*qm[i], OD_QM_SHIFT + rshift);
-#endif
-  }
-  if(!*noref){
-    /* we have a reference; compute its gain */
-    od_val32 cgr;
-    int icgr;
-    int cfl_enabled;
-    cfl_enabled = pli != 0 && is_keyframe && !OD_DISABLE_CFL;
-    cgr = od_pvq_compute_gain(ref16, n, q0, &gr, beta, rshift);
-    if (cfl_enabled) cgr = OD_CGAIN_SCALE;
-#if defined(OD_FLOAT_PVQ)
-    icgr = (int)floor(.5 + cgr);
-#else
-    icgr = OD_SHR_ROUND(cgr, OD_CGAIN_SHIFT);
-#endif
-    /* quantized gain is interleave encoded when there's a reference;
-       deinterleave it now */
-    if (is_keyframe) qg = neg_deinterleave(qg, icgr);
-    else {
-      qg = neg_deinterleave(qg, icgr + 1) - 1;
-      if (qg == 0) *skip = (icgr ? OD_PVQ_SKIP_ZERO : OD_PVQ_SKIP_COPY);
-    }
-    if (qg == icgr && itheta == 0 && !cfl_enabled) *skip = OD_PVQ_SKIP_COPY;
-    gain_offset = cgr - OD_SHL(icgr, OD_CGAIN_SHIFT);
-    qcg = OD_SHL(qg, OD_CGAIN_SHIFT) + gain_offset;
-    /* read and decode first-stage PVQ error theta */
-    if (itheta > 1) {
-      int tmp;
-      tmp = *ext;
-      itheta = 2 + generic_decode(r, &model[2], &tmp, 2, "pvq:theta");
-      OD_IIR_DIADIC(*ext, itheta << 16, 2);
-    }
-    theta = od_pvq_compute_theta(itheta, od_pvq_compute_max_theta(qcg, beta));
-  }
-  else{
-    itheta = 0;
-    if (!is_keyframe) qg++;
-    qcg = OD_SHL(qg, OD_CGAIN_SHIFT);
-    if (qg == 0) *skip = OD_PVQ_SKIP_ZERO;
-  }
-
-  k = od_pvq_compute_k(qcg, itheta, *noref, n, beta);
-  if (k != 0) {
-    /* when noref==0, y is actually size n-1 */
-    aom_decode_pvq_codeword(r, &adapt->pvq.pvq_codeword_ctx, y,
-     n - !*noref, k);
-  }
-  else {
-    OD_CLEAR(y, n);
-  }
-  if (*skip) {
-    if (*skip == OD_PVQ_SKIP_COPY) OD_COPY(out, ref, n);
-    else OD_CLEAR(out, n);
-  }
-  else {
-    od_val32 g;
-    g = od_gain_expand(qcg, q0, beta);
-    pvq_synthesis(out, y, ref16, n, gr, *noref, g, theta, qm_inv, rshift);
-  }
-  /* If OD_PVQ_SKIP_ZERO or OD_PVQ_SKIP_COPY, set skip to 1 for visualization */
-  if (*skip) *skip = 1;
-}
-
-/** Decodes a coefficient block (except for DC) encoded using PVQ
- *
- * @param [in,out] dec         daala decoder context
- * @param [in]     ref         'reference' (prediction) vector
- * @param [out]    out         decoded partition
- * @param [in]     q0          quantizer
- * @param [in]     pli         plane index
- * @param [in]     bs          log of the block size minus two
- * @param [in]     beta        per-band activity masking beta param
- * @param [in]     is_keyframe whether we're encoding a keyframe
- * @param [out]    flags       bitmask of the per band skip and noref flags
- * @param [in]     ac_dc_coded skip flag for the block (range 0-3)
- * @param [in]     qm          QM with magnitude compensation
- * @param [in]     qm_inv      Inverse of QM with magnitude compensation
- */
-void od_pvq_decode(daala_dec_ctx *dec,
-                   od_coeff *ref,
-                   od_coeff *out,
-                   int q0,
-                   int pli,
-                   int bs,
-                   const od_val16 *beta,
-                   int is_keyframe,
-                   unsigned int *flags,
-                   PVQ_SKIP_TYPE ac_dc_coded,
-                   const int16_t *qm,
-                   const int16_t *qm_inv){
-
-  int noref[PVQ_MAX_PARTITIONS];
-  int skip[PVQ_MAX_PARTITIONS];
-  int *exg;
-  int *ext;
-  int nb_bands;
-  int i;
-  const int *off;
-  int size[PVQ_MAX_PARTITIONS];
-  generic_encoder *model;
-  int skip_rest[3] = {0};
-  cfl_ctx cfl;
-  const unsigned char *pvq_qm;
-  int use_masking;
-
-  aom_clear_system_state();
-
-  /*Default to skip=1 and noref=0 for all bands.*/
-  for (i = 0; i < PVQ_MAX_PARTITIONS; i++) {
-    noref[i] = 0;
-    skip[i] = 1;
-  }
-
-  use_masking = dec->use_activity_masking;
-
-  if (use_masking)
-    pvq_qm = &dec->state.pvq_qm_q4[pli][0];
-  else
-    pvq_qm = 0;
-
-  exg = &dec->state.adapt->pvq.pvq_exg[pli][bs][0];
-  ext = dec->state.adapt->pvq.pvq_ext + bs*PVQ_MAX_PARTITIONS;
-  model = dec->state.adapt->pvq.pvq_param_model;
-  nb_bands = OD_BAND_OFFSETS[bs][0];
-  off = &OD_BAND_OFFSETS[bs][1];
-  out[0] = ac_dc_coded & DC_CODED;
-  if (ac_dc_coded < AC_CODED) {
-    if (is_keyframe) for (i = 1; i < 1 << (2*bs + 4); i++) out[i] = 0;
-    else for (i = 1; i < 1 << (2*bs + 4); i++) out[i] = ref[i];
-  }
-  else {
-    for (i = 0; i < nb_bands; i++) size[i] = off[i+1] - off[i];
-    cfl.ref = ref;
-    cfl.nb_coeffs = off[nb_bands];
-    cfl.allow_flip = pli != 0 && is_keyframe;
-    for (i = 0; i < nb_bands; i++) {
-      int q;
-
-      if (use_masking)
-        q = OD_MAXI(1, q0 * pvq_qm[od_qm_get_index(bs, i + 1)] >> 4);
-      else
-        q = OD_MAXI(1, q0);
-
-      pvq_decode_partition(dec->r, q, size[i],
-       model, dec->state.adapt, exg + i, ext + i, ref + off[i], out + off[i],
-       &noref[i], beta[i], 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]);
-      if (i == 0 && !skip_rest[0] && bs > 0) {
-        int skip_dir;
-        int j;
-        skip_dir = aom_read_symbol(dec->r,
-         &dec->state.adapt->pvq.pvq_skip_dir_cdf[(pli != 0) + 2*(bs - 1)][0], 7,
-         "pvq:skiprest");
-        for (j = 0; j < 3; j++) skip_rest[j] = !!(skip_dir & (1 << j));
-      }
-    }
-  }
-  *flags = 0;
-  for (i = nb_bands - 1; i >= 0; i--) {
-    *flags <<= 1;
-    *flags |= noref[i]&1;
-    *flags <<= 1;
-    *flags |= skip[i]&1;
-  }
-}
diff --git a/av1/decoder/pvq_decoder.h b/av1/decoder/pvq_decoder.h
deleted file mode 100644
index 9897066..0000000
--- a/av1/decoder/pvq_decoder.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2001-2016, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 2 Clause License and
- * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
- * was not distributed with this source code in the LICENSE file, you can
- * obtain it at www.aomedia.org/license/software. If the Alliance for Open
- * Media Patent License 1.0 was not distributed with this source code in the
- * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
- */
-
-/* clang-format off */
-
-#if !defined(_pvq_decoder_H)
-# define _pvq_decoder_H (1)
-# include "aom_dsp/bitreader.h"
-# include "aom_dsp/entdec.h"
-# include "av1/common/pvq.h"
-# include "av1/decoder/decint.h"
-
-#define aom_read_symbol_pvq(r, cdf, nsymbs, ACCT_STR_NAME) \
-  aom_read_symbol_pvq_(r, cdf, nsymbs ACCT_STR_ARG(ACCT_STR_NAME))
-
-int aom_read_symbol_pvq_(aom_reader *r, aom_cdf_prob *cdf, int nsymbs
-  ACCT_STR_PARAM);
-
-void aom_decode_band_pvq_splits(aom_reader *r, od_pvq_codeword_ctx *adapt,
- od_coeff *y, int n, int k, int level);
-
-#define aom_laplace_decode_special(r, decay, ACCT_STR_NAME) \
-  aom_laplace_decode_special_(r, decay ACCT_STR_ARG(ACCT_STR_NAME))
-
-int aom_laplace_decode_special_(aom_reader *r, unsigned decay ACCT_STR_PARAM);
-
-void od_pvq_decode(daala_dec_ctx *dec, od_coeff *ref, od_coeff *out, int q0,
-    int pli, int bs, const od_val16 *beta, int is_keyframe,
-    unsigned int *flags, PVQ_SKIP_TYPE ac_dc_coded, const int16_t *qm,
-    const int16_t *qm_inv);
-
-#endif