Remove PVQ code
Change-Id: Id377c68e30031ad4697ca1ba311487b803a8af4c
diff --git a/aom_dsp/aom_dsp.mk b/aom_dsp/aom_dsp.mk
index 5b872d6..13dc5e5 100644
--- a/aom_dsp/aom_dsp.mk
+++ b/aom_dsp/aom_dsp.mk
@@ -219,7 +219,7 @@
DSP_SRCS-$(HAVE_MSA) += mips/txfm_macros_msa.h
# forward transform
-ifneq ($(findstring yes,$(CONFIG_AV1)$(CONFIG_PVQ)),)
+ifneq ($(findstring yes,$(CONFIG_AV1)),)
DSP_SRCS-$(HAVE_AVX2) += x86/txfm_common_avx2.h
ifeq ($(CONFIG_AV1_ENCODER),yes)
DSP_SRCS-yes += fwd_txfm.c
diff --git a/aom_dsp/aom_dsp_rtcd_defs.pl b/aom_dsp/aom_dsp_rtcd_defs.pl
index 206bb92..841707b 100755
--- a/aom_dsp/aom_dsp_rtcd_defs.pl
+++ b/aom_dsp/aom_dsp_rtcd_defs.pl
@@ -550,7 +550,7 @@
#
# Forward transform
#
-if ((aom_config("CONFIG_AV1_ENCODER") eq "yes") || (aom_config("CONFIG_PVQ") eq "yes")){
+if (aom_config("CONFIG_AV1_ENCODER") eq "yes"){
if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
add_proto qw/void aom_fdct4x4/, "const int16_t *input, tran_low_t *output, int stride";
specialize qw/aom_fdct4x4 sse2/;
diff --git a/av1/av1.cmake b/av1/av1.cmake
index 140eec8..287827e 100644
--- a/av1/av1.cmake
+++ b/av1/av1.cmake
@@ -420,65 +420,6 @@
"${AOM_ROOT}/av1/common/ncobmc_kernels.h")
endif ()
-if (CONFIG_PVQ)
- set(AOM_AV1_COMMON_SOURCES
- ${AOM_AV1_COMMON_SOURCES}
- "${AOM_ROOT}/av1/common/laplace_tables.c"
- "${AOM_ROOT}/av1/common/pvq.c"
- "${AOM_ROOT}/av1/common/pvq.h"
- "${AOM_ROOT}/av1/common/pvq_state.c"
- "${AOM_ROOT}/av1/common/pvq_state.h"
- "${AOM_ROOT}/av1/common/partition.c"
- "${AOM_ROOT}/av1/common/partition.h"
- "${AOM_ROOT}/av1/common/generic_code.c"
- "${AOM_ROOT}/av1/common/generic_code.h"
- "${AOM_ROOT}/av1/common/zigzag4.c"
- "${AOM_ROOT}/av1/common/zigzag8.c"
- "${AOM_ROOT}/av1/common/zigzag16.c"
- "${AOM_ROOT}/av1/common/zigzag32.c")
-
- set(AOM_AV1_DECODER_SOURCES
- ${AOM_AV1_DECODER_SOURCES}
- "${AOM_ROOT}/av1/decoder/decint.h"
- "${AOM_ROOT}/av1/decoder/pvq_decoder.c"
- "${AOM_ROOT}/av1/decoder/pvq_decoder.h"
- "${AOM_ROOT}/av1/decoder/generic_decoder.c"
- "${AOM_ROOT}/av1/decoder/laplace_decoder.c")
-
- set(AOM_AV1_ENCODER_SOURCES
- ${AOM_AV1_ENCODER_SOURCES}
- "${AOM_ROOT}/av1/encoder/daala_compat_enc.c"
- "${AOM_ROOT}/av1/encoder/encint.h"
- "${AOM_ROOT}/av1/encoder/pvq_encoder.c"
- "${AOM_ROOT}/av1/encoder/pvq_encoder.h"
- "${AOM_ROOT}/av1/encoder/generic_encoder.c"
- "${AOM_ROOT}/av1/encoder/laplace_encoder.c")
-
- set(AOM_AV1_COMMON_INTRIN_SSE4_1
- ${AOM_AV1_COMMON_INTRIN_SSE4_1}
- "${AOM_ROOT}/av1/common/x86/pvq_sse4.c"
- "${AOM_ROOT}/av1/common/x86/pvq_sse4.h")
-
- if (NOT CONFIG_AV1_ENCODER)
- # TODO(tomfinegan): These should probably be in av1/common, and in a
- # common source list. For now this mirrors the original build system.
- set(AOM_AV1_DECODER_SOURCES
- ${AOM_AV1_DECODER_SOURCES}
- "${AOM_ROOT}/av1/encoder/dct.c"
- "${AOM_ROOT}/av1/encoder/hybrid_fwd_txfm.c"
- "${AOM_ROOT}/av1/encoder/hybrid_fwd_txfm.h")
-
- set(AOM_AV1_DECODER_ASM_SSE2
- ${AOM_AV1_DECODER_ASM_SSE2}
- "${AOM_ROOT}/av1/encoder/x86/dct_sse2.asm")
-
- set(AOM_AV1_DECODER_INTRIN_SSE2
- ${AOM_AV1_DECODER_INTRIN_SSE2}
- "${AOM_ROOT}/av1/encoder/x86/dct_intrin_sse2.c")
-
- endif ()
-endif ()
-
if (CONFIG_WARPED_MOTION OR CONFIG_GLOBAL_MOTION)
set(AOM_AV1_COMMON_SOURCES
${AOM_AV1_COMMON_SOURCES}
diff --git a/av1/av1_common.mk b/av1/av1_common.mk
index 35466ac..95d5d13 100644
--- a/av1/av1_common.mk
+++ b/av1/av1_common.mk
@@ -128,28 +128,6 @@
AV1_COMMON_SRCS-yes += common/obmc.h
endif
-ifeq ($(CONFIG_PVQ),yes)
-# PVQ from daala
-AV1_COMMON_SRCS-yes += common/pvq.c
-AV1_COMMON_SRCS-yes += common/partition.c
-AV1_COMMON_SRCS-yes += common/partition.h
-AV1_COMMON_SRCS-yes += common/zigzag4.c
-AV1_COMMON_SRCS-yes += common/zigzag8.c
-AV1_COMMON_SRCS-yes += common/zigzag16.c
-AV1_COMMON_SRCS-yes += common/zigzag32.c
-AV1_COMMON_SRCS-yes += common/zigzag.h
-AV1_COMMON_SRCS-yes += common/generic_code.c
-AV1_COMMON_SRCS-yes += common/pvq_state.c
-AV1_COMMON_SRCS-yes += common/laplace_tables.c
-AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/x86/pvq_sse4.c
-AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/x86/pvq_sse4.h
-endif
-ifneq ($(findstring yes,$(CONFIG_PVQ)$(CONFIG_DAALA_DIST)$(CONFIG_XIPHRC)),)
-AV1_COMMON_SRCS-yes += common/pvq.h
-AV1_COMMON_SRCS-yes += common/pvq_state.h
-AV1_COMMON_SRCS-yes += common/generic_code.h
-endif
-
# common (msa)
AV1_COMMON_SRCS-$(HAVE_MSA) += common/mips/msa/av1_idct4x4_msa.c
AV1_COMMON_SRCS-$(HAVE_MSA) += common/mips/msa/av1_idct8x8_msa.c
diff --git a/av1/av1_cx.mk b/av1/av1_cx.mk
index f5d62c9..ec23aa3 100644
--- a/av1/av1_cx.mk
+++ b/av1/av1_cx.mk
@@ -118,17 +118,6 @@
ifeq ($(CONFIG_CDEF),yes)
AV1_CX_SRCS-yes += encoder/pickcdef.c
endif
-ifeq ($(CONFIG_PVQ),yes)
-# PVQ from daala
-AV1_CX_SRCS-yes += encoder/daala_compat_enc.c
-AV1_CX_SRCS-yes += encoder/pvq_encoder.c
-AV1_CX_SRCS-yes += encoder/pvq_encoder.h
-AV1_CX_SRCS-yes += encoder/generic_encoder.c
-AV1_CX_SRCS-yes += encoder/laplace_encoder.c
-endif
-ifneq ($(findstring yes,$(CONFIG_XIPHRC)$(CONFIG_PVQ)),)
-AV1_CX_SRCS-yes += encoder/encint.h
-endif
AV1_CX_SRCS-$(HAVE_SSE2) += encoder/x86/av1_quantize_sse2.c
AV1_CX_SRCS-$(HAVE_AVX2) += encoder/x86/av1_quantize_avx2.c
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 63f0035..106e2c0 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -328,14 +328,6 @@
if (extra_cfg->tuning == AOM_TUNE_SSIM)
ERROR("Option --tune=ssim is not currently supported in AV1.");
-// TODO(anybody) : remove this flag when PVQ supports pallete coding tool
-#if CONFIG_PVQ
- if (extra_cfg->content == AOM_CONTENT_SCREEN)
- ERROR(
- "Option --tune-content=screen is not currently supported when PVQ is "
- "enabled.");
-#endif // CONFIG_PVQ
-
if (cfg->g_pass == AOM_RC_LAST_PASS) {
#if !CONFIG_XIPHRC
const size_t packet_sz = sizeof(FIRSTPASS_STATS);
diff --git a/av1/av1_dx.mk b/av1/av1_dx.mk
index 6f113c3..21fdd98 100644
--- a/av1/av1_dx.mk
+++ b/av1/av1_dx.mk
@@ -44,24 +44,4 @@
AV1_DX_SRCS-yes += decoder/inspection.h
endif
-ifeq ($(CONFIG_PVQ),yes)
-# PVQ from daala
-AV1_DX_SRCS-yes += decoder/pvq_decoder.c
-AV1_DX_SRCS-yes += decoder/pvq_decoder.h
-AV1_DX_SRCS-yes += decoder/decint.h
-AV1_DX_SRCS-yes += decoder/generic_decoder.c
-AV1_DX_SRCS-yes += decoder/laplace_decoder.c
-AV1_DX_SRCS-yes += encoder/hybrid_fwd_txfm.c
-AV1_DX_SRCS-yes += encoder/hybrid_fwd_txfm.h
-
-AV1_DX_SRCS-yes += encoder/dct.c
-AV1_DX_SRCS-$(HAVE_SSE2) += encoder/x86/dct_sse2.asm
-AV1_DX_SRCS-$(HAVE_SSE2) += encoder/x86/dct_intrin_sse2.c
-
-AV1_DX_SRCS-$(HAVE_MSA) += encoder/mips/msa/fdct4x4_msa.c
-AV1_DX_SRCS-$(HAVE_MSA) += encoder/mips/msa/fdct8x8_msa.c
-AV1_DX_SRCS-$(HAVE_MSA) += encoder/mips/msa/fdct16x16_msa.c
-AV1_DX_SRCS-$(HAVE_MSA) += encoder/mips/msa/fdct_msa.h
-endif
-
AV1_DX_SRCS-yes := $(filter-out $(AV1_DX_SRCS_REMOVE-yes),$(AV1_DX_SRCS-yes))
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl
index f2434fa..3f68091 100755
--- a/av1/common/av1_rtcd_defs.pl
+++ b/av1/common/av1_rtcd_defs.pl
@@ -503,38 +503,6 @@
}
# end encoder functions
-# If PVQ is enabled, fwd transforms are required by decoder
-if (aom_config("CONFIG_PVQ") eq "yes") {
- # fdct functions
-
- if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
- add_proto qw/void av1_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, struct txfm_param *param";
- specialize qw/av1_fht4x4 sse2/;
-
- add_proto qw/void av1_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, struct txfm_param *param";
- specialize qw/av1_fht8x8 sse2/;
-
- add_proto qw/void av1_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, struct txfm_param *param";
- specialize qw/av1_fht16x16 sse2/;
-
- add_proto qw/void av1_fwht4x4/, "const int16_t *input, tran_low_t *output, int stride";
- specialize qw/av1_fwht4x4 sse2/;
- } else {
- add_proto qw/void av1_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, struct txfm_param *param";
- specialize qw/av1_fht4x4 sse2 msa/;
-
- add_proto qw/void av1_fht8x8/, "const int16_t *input, tran_low_t *output, int stride, struct txfm_param *param";
- specialize qw/av1_fht8x8 sse2 msa/;
-
- add_proto qw/void av1_fht16x16/, "const int16_t *input, tran_low_t *output, int stride, struct txfm_param *param";
- specialize qw/av1_fht16x16 sse2 msa/;
-
- add_proto qw/void av1_fwht4x4/, "const int16_t *input, tran_low_t *output, int stride";
- specialize qw/av1_fwht4x4 msa sse2/;
- }
-
-}
-
# Deringing Functions
if (aom_config("CONFIG_CDEF") eq "yes") {
@@ -586,13 +554,6 @@
}
}
-# PVQ Functions
-
-if (aom_config("CONFIG_PVQ") eq "yes") {
- add_proto qw/double pvq_search_rdo_double/, "const od_val16 *xcoeff, int n, int k, int *ypulse, double g2, double pvq_norm_lambda, int prev_k";
- specialize qw/pvq_search_rdo_double sse4_1/;
-}
-
# WARPED_MOTION / GLOBAL_MOTION functions
if ((aom_config("CONFIG_WARPED_MOTION") eq "yes") ||
diff --git a/av1/common/blockd.c b/av1/common/blockd.c
index be7d737..89a4caf 100644
--- a/av1/common/blockd.c
+++ b/av1/common/blockd.c
@@ -187,7 +187,6 @@
}
#endif
-#if !CONFIG_PVQ || CONFIG_VAR_TX
void av1_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd,
int plane, TX_SIZE tx_size, int has_eob, int aoff,
int loff) {
@@ -225,8 +224,6 @@
memset(l, has_eob, sizeof(ENTROPY_CONTEXT) * txs_high);
}
}
-#endif
-
void av1_reset_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col,
BLOCK_SIZE bsize) {
int i;
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index cf741d5..a43c103 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -26,11 +26,7 @@
#include "av1/common/scale.h"
#include "av1/common/seg_common.h"
#include "av1/common/tile_common.h"
-#if CONFIG_PVQ
-#include "av1/common/pvq.h"
-#include "av1/common/pvq_state.h"
-#include "av1/decoder/decint.h"
-#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -87,32 +83,6 @@
return mode >= NEARESTMV && mode <= NEW_NEWMV;
}
-#if CONFIG_PVQ
-typedef struct PVQ_INFO {
- int theta[PVQ_MAX_PARTITIONS];
- int qg[PVQ_MAX_PARTITIONS];
- int k[PVQ_MAX_PARTITIONS];
- od_coeff y[OD_TXSIZE_MAX * OD_TXSIZE_MAX];
- int nb_bands;
- int off[PVQ_MAX_PARTITIONS];
- int size[PVQ_MAX_PARTITIONS];
- int skip_rest;
- int skip_dir;
- int bs; // log of the block size minus two,
- // i.e. equivalent to aom's TX_SIZE
- // Block skip info, indicating whether DC/AC, is coded.
- PVQ_SKIP_TYPE ac_dc_coded; // bit0: DC coded, bit1 : AC coded (1 means coded)
- tran_low_t dq_dc_residue;
-} PVQ_INFO;
-
-typedef struct PVQ_QUEUE {
- PVQ_INFO *buf; // buffer for pvq info, stored in encoding order
- int curr_pos; // curr position to write PVQ_INFO
- int buf_len; // allocated buffer length
- int last_pos; // last written position of PVQ_INFO in a tile
-} PVQ_QUEUE;
-#endif
-
#if CONFIG_NCOBMC_ADAPT_WEIGHT
typedef struct superblock_mi_boundaries {
int mi_row_begin;
@@ -613,13 +583,9 @@
const dequant_val_type_nuq *dequant_val_nuq[QUANT_PROFILES];
#endif // CONFIG_NEW_QUANT
-#if CONFIG_PVQ || CONFIG_DIST_8X8
+#if CONFIG_DIST_8X8
DECLARE_ALIGNED(16, int16_t, pred[MAX_SB_SQUARE]);
#endif
-#if CONFIG_PVQ
- // PVQ: forward transformed predicted image, a reference for PVQ.
- tran_low_t *pvq_ref_coeff;
-#endif
} MACROBLOCKD_PLANE;
#define BLOCK_OFFSET(x, i) \
@@ -761,9 +727,6 @@
CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][MAX_REF_MV_STACK_SIZE];
uint8_t is_sec_rect;
-#if CONFIG_PVQ
- daala_dec_ctx daala_dec;
-#endif
FRAME_CONTEXT *tile_ctx;
/* Bit depth: 8, 10, 12 */
int bd;
diff --git a/av1/common/entropy.c b/av1/common/entropy.c
index b53f52b..3209d3c 100644
--- a/av1/common/entropy.c
+++ b/av1/common/entropy.c
@@ -2417,67 +2417,3 @@
AVERAGE_TILE_CDFS(lpf_sign_cdf);
#endif // CONFIG_LPF_SB
}
-
-#if CONFIG_PVQ
-// Averaging PVQ's expected values for symbol coding
-static void av1_average_pvq_ex(int *cxt_ptr[], int *fc_cxt_ptr, int cxt_size,
- const int num_tiles) {
- int i, j;
- for (i = 0; i < cxt_size; ++i) {
- int sum = 0;
- for (j = 0; j < num_tiles; ++j) sum += cxt_ptr[j][i];
- fc_cxt_ptr[i] = sum / num_tiles;
- }
-}
-
-#define AVERAGE_TILE_PVQ_EX(cname) \
- for (i = 0; i < num_tiles; ++i) cxt_ptr[i] = (int *)&ec_ctxs[i]->cname; \
- fc_cxt_ptr = (int *)&fc->cname; \
- cxt_size = (int)sizeof(fc->cname) / sizeof(int); \
- av1_average_pvq_ex(cxt_ptr, fc_cxt_ptr, cxt_size, num_tiles);
-
-void av1_default_pvq_probs(AV1_COMMON *cm) {
- od_adapt_ctx *adapt = &cm->fc->pvq_context;
-
- // Init with flat probabilities.
- od_adapt_ctx_reset(adapt, 0);
-
- // TODO(yushin): Prepare offline cdf and context table for PVQ,
- // i.e. od_adapt_ctx, then load them from table,
- // for example od_adapt_ctx default_pvq_context.
- // Then do sth like this:
- // av1_copy(cm->fc->pvq_context, default_pvq_context);
-}
-
-void av1_average_tile_pvq_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
- const int num_tiles) {
- int i, j, cdf_size, cxt_size;
-
- aom_cdf_prob *cdf_ptr[MAX_TILE_ROWS * MAX_TILE_COLS];
- aom_cdf_prob *fc_cdf_ptr;
- int *cxt_ptr[MAX_TILE_ROWS * MAX_TILE_COLS];
- int *fc_cxt_ptr;
-
- AVERAGE_TILE_PVQ_EX(pvq_context.ex_dc)
- AVERAGE_TILE_PVQ_EX(pvq_context.ex_g)
-
- for (j = 0; j < OD_NPLANES_MAX; j++) {
- AVERAGE_TILE_CDFS(pvq_context.model_dc[j].cdf)
- }
-
- AVERAGE_TILE_CDFS(pvq_context.skip_cdf)
-
- AVERAGE_TILE_PVQ_EX(pvq_context.pvq.pvq_codeword_ctx.pvq_adapt)
- AVERAGE_TILE_CDFS(pvq_context.pvq.pvq_codeword_ctx.pvq_k1_cdf)
- AVERAGE_TILE_CDFS(pvq_context.pvq.pvq_codeword_ctx.pvq_split_cdf)
-
- for (j = 0; j < 3; j++) {
- AVERAGE_TILE_CDFS(pvq_context.pvq.pvq_param_model[j].cdf)
- }
-
- AVERAGE_TILE_PVQ_EX(pvq_context.pvq.pvq_ext)
- AVERAGE_TILE_PVQ_EX(pvq_context.pvq.pvq_exg)
- AVERAGE_TILE_CDFS(pvq_context.pvq.pvq_gaintheta_cdf)
- AVERAGE_TILE_CDFS(pvq_context.pvq.pvq_skip_dir_cdf)
-}
-#endif // CONFIG_PVQ
diff --git a/av1/common/entropy.h b/av1/common/entropy.h
index bb05c14..497d4c2 100644
--- a/av1/common/entropy.h
+++ b/av1/common/entropy.h
@@ -388,11 +388,6 @@
void av1_average_tile_loopfilter_cdfs(struct frame_contexts *fc,
struct frame_contexts *ec_ctxs[],
aom_cdf_prob *cdf_ptrs[], int num_tiles);
-#if CONFIG_PVQ
-void av1_default_pvq_probs(struct AV1Common *cm);
-void av1_average_tile_pvq_cdfs(struct frame_contexts *fc,
- struct frame_contexts *ec_ctxs[], int num_tiles);
-#endif // CONFIG_PVQ
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index c56ac06..52a3e0c 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -6674,9 +6674,6 @@
#if CONFIG_LV_MAP
av1_init_lv_map(cm);
#endif
-#if CONFIG_PVQ
- av1_default_pvq_probs(cm);
-#endif // CONFIG_PVQ
#if CONFIG_ADAPT_SCAN
av1_init_scan_order(cm);
#endif
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h
index 9c9d64d..c59a2a2 100644
--- a/av1/common/entropymode.h
+++ b/av1/common/entropymode.h
@@ -18,12 +18,6 @@
#include "av1/common/seg_common.h"
#include "aom_dsp/aom_filter.h"
-#if CONFIG_PVQ
-#include "av1/common/pvq.h"
-#include "av1/common/pvq_state.h"
-#include "av1/common/generic_code.h"
-#endif // CONFIG_PVQ
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -375,11 +369,6 @@
#endif // CONFIG_LOOPFILTER_LEVEL
aom_prob delta_lf_prob[DELTA_LF_PROBS];
#endif
-#if CONFIG_PVQ
- // TODO(any): If PVQ is enabled, most of coefficient related cdf,
- // such as coef_cdfs[], coef_tail_cdfs[], and coef_heaf_cdfs[] can be removed.
- od_adapt_ctx pvq_context;
-#endif // CONFIG_PVQ
#if CONFIG_CFL
aom_cdf_prob cfl_sign_cdf[CDF_SIZE(CFL_JOINT_SIGNS)];
aom_cdf_prob cfl_alpha_cdf[CFL_ALPHA_CONTEXTS][CDF_SIZE(CFL_ALPHABET_SIZE)];
diff --git a/av1/common/generic_code.c b/av1/common/generic_code.c
deleted file mode 100644
index 7285dec..0000000
--- a/av1/common/generic_code.c
+++ /dev/null
@@ -1,112 +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 "generic_code.h"
-
-void aom_cdf_init_q15_1D(uint16_t *cdf, int nsyms, int cdf_size) {
- int i;
- for (i = 0; i < nsyms; i++)
- cdf[i] = AOM_ICDF((i + 1)*CDF_PROB_TOP/nsyms);
-
- cdf[cdf_size - 1] = 0;
-}
-
-/** Adapts a Q15 cdf after encoding/decoding a symbol. */
-void aom_cdf_adapt_q15(int val, uint16_t *cdf, int n, int *count, int rate) {
- int i;
- *count = OD_MINI(*count + 1, 1 << rate);
- OD_ASSERT(AOM_ICDF(cdf[n - 1]) == 32768);
- if (*count >= 1 << rate) {
- /* Steady-state adaptation based on a simple IIR with dyadic rate. */
- for (i = 0; i < n; i++) {
- int tmp;
- /* When (i < val), we want the adjustment ((cdf[i] - tmp) >> rate) to be
- positive so long as (cdf[i] > i + 1), and 0 when (cdf[i] == i + 1),
- to ensure we don't drive any probabilities to 0. Replacing cdf[i] with
- (i + 2) and solving ((i + 2 - tmp) >> rate == 1) for tmp produces
- tmp == i + 2 - (1 << rate). Using this value of tmp with
- cdf[i] == i + 1 instead gives an adjustment of 0 as desired.
-
- When (i >= val), we want ((cdf[i] - tmp) >> rate) to be negative so
- long as cdf[i] < 32768 - (n - 1 - i), and 0 when
- cdf[i] == 32768 - (n - 1 - i), again to ensure we don't drive any
- probabilities to 0. Since right-shifting any negative value is still
- negative, we can solve (32768 - (n - 1 - i) - tmp == 0) for tmp,
- producing tmp = 32769 - n + i. Using this value of tmp with smaller
- values of cdf[i] instead gives negative adjustments, as desired.
-
- Combining the two cases gives the expression below. These could be
- stored in a lookup table indexed by n and rate to avoid the
- arithmetic. */
- tmp = 2 - (1<<rate) + i + (32767 + (1<<rate) - n)*(i >= val);
- cdf[i] = AOM_ICDF(AOM_ICDF(cdf[i]) - ((AOM_ICDF(cdf[i]) - tmp) >> rate));
- }
- }
- else {
- int alpha;
- /* Initial adaptation for the first symbols. The adaptation rate is
- computed to be equivalent to what od_{en,de}code_cdf_adapt() does
- when the initial cdf is set to increment/4. */
- alpha = 4*32768/(n + 4**count);
- for (i = 0; i < n; i++) {
- int tmp;
- tmp = (32768 - n)*(i >= val) + i + 1;
- cdf[i] = AOM_ICDF(AOM_ICDF(cdf[i])
- - (((AOM_ICDF(cdf[i]) - tmp)*alpha) >> 15));
- }
- }
- OD_ASSERT(AOM_ICDF(cdf[n - 1]) == 32768);
-}
-
-/** Takes the base-2 log of E(x) in Q1.
- *
- * @param [in] ExQ16 expectation of x in Q16
- *
- * @retval 2*log2(ExQ16/2^16)
- */
-int log_ex(int ex_q16) {
- int lg;
- int lg_q1;
- int odd;
- lg = OD_ILOG(ex_q16);
- if (lg < 15) {
- odd = ex_q16*ex_q16 > 2 << 2*lg;
- }
- else {
- int tmp;
- tmp = ex_q16 >> (lg - 8);
- odd = tmp*tmp > (1 << 15);
- }
- lg_q1 = OD_MAXI(0, 2*lg - 33 + odd);
- return lg_q1;
-}
-
-/** Updates the probability model based on the encoded/decoded value
- *
- * @param [in,out] model generic prob model
- * @param [in,out] ExQ16 expectation of x
- * @param [in] x variable encoded/decoded (used for ExQ16)
- * @param [in] xs variable x after shift (used for the model)
- * @param [in] id id of the icdf to adapt
- * @param [in] integration integration period of ExQ16 (leaky average over
- * 1<<integration samples)
- */
-void generic_model_update(int *ex_q16, int x, int integration) {
- /* We could have saturated ExQ16 directly, but this is safe and simpler */
- x = OD_MINI(x, 32767);
- OD_IIR_DIADIC(*ex_q16, x << 16, integration);
-}
diff --git a/av1/common/generic_code.h b/av1/common/generic_code.h
deleted file mode 100644
index e1620ee..0000000
--- a/av1/common/generic_code.h
+++ /dev/null
@@ -1,81 +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(_generic_code_H)
-# define _generic_code_H
-
-# include "aom_dsp/bitreader.h"
-# include "aom_dsp/bitwriter.h"
-
-# define GENERIC_TABLES 12
-
-#define generic_decode(r, model, ex_q16, integration, ACCT_STR_NAME) \
- generic_decode_(r, model, ex_q16, integration ACCT_STR_ARG(ACCT_STR_NAME))
-#define aom_decode_cdf_adapt_q15(r, cdf, n, count, rate, ACCT_STR_NAME) \
- aom_decode_cdf_adapt_q15_(r, cdf, n, count, rate ACCT_STR_ARG(ACCT_STR_NAME))
-#define aom_decode_cdf_adapt(r, cdf, n, increment, ACCT_STR_NAME) \
- aom_decode_cdf_adapt_(r, cdf, n, increment ACCT_STR_ARG(ACCT_STR_NAME))
-
-typedef struct {
- /** cdf for multiple expectations of x */
- uint16_t cdf[GENERIC_TABLES][CDF_SIZE(16)];
-} generic_encoder;
-
-#define OD_IIR_DIADIC(y, x, shift) ((y) += ((x) - (y)) >> (shift))
-
-void generic_model_init(generic_encoder *model);
-
-/* Initialize a CDF for use by aom_write_symbol_pvq()/aom_read_symbol_pvq().
- This is used for CDFs whose size might not match the declared array size.
- The only real requirement is that the first value of every CDF be zero.
- Then aom_cdf_init_q15_1D() will be called with the real size the first time
- the CDF is used. */
-#define OD_CDFS_INIT_DYNAMIC(cdf) (memset(cdf, 0, sizeof(cdf)))
-
-// WARNING: DO NOT USE this init function,
-// if the size of cdf is different from what is declared by code.
-#define OD_CDFS_INIT_Q15(cdfs) \
- { int n_cdfs = sizeof(cdfs)/sizeof(cdfs[0]); \
- int cdf_size = sizeof(cdfs[0])/sizeof(cdfs[0][0]); \
- int nsyms = cdf_size - 1; \
- int i_; \
- for (i_ = 0; i_ < n_cdfs; i_++) \
- aom_cdf_init_q15_1D(cdfs[i_], nsyms, cdf_size); \
- }
-
-void aom_cdf_init(uint16_t *cdf, int ncdfs, int nsyms, int val, int first);
-
-void aom_cdf_init_q15_1D(uint16_t *cdf, int nsyms, int cdf_size);
-
-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 generic_encode(aom_writer *w, generic_encoder *model, int x,
- int *ex_q16, int integration);
-double generic_encode_cost(generic_encoder *model, int x, int *ex_q16);
-
-double od_encode_cdf_cost(int val, uint16_t *cdf, int n);
-
-int aom_decode_cdf_adapt_q15_(aom_reader *r, uint16_t *cdf, int n,
- int *count, int rate ACCT_STR_PARAM);
-
-int generic_decode_(aom_reader *r, generic_encoder *model,
- int *ex_q16, int integration ACCT_STR_PARAM);
-
-int log_ex(int ex_q16);
-
-void generic_model_update(int *ex_q16, int x, int integration);
-
-#endif
diff --git a/av1/common/idct.c b/av1/common/idct.c
index 358f558..90c6141 100644
--- a/av1/common/idct.c
+++ b/av1/common/idct.c
@@ -3237,19 +3237,7 @@
TX_TYPE tx_type, TX_SIZE tx_size, uint8_t *dst,
int stride, int eob) {
if (!eob) return;
-#if CONFIG_PVQ
- const BLOCK_SIZE tx_bsize = txsize_to_bsize[tx_size];
- const int txb_width = block_size_wide[tx_bsize];
- const int txb_height = block_size_high[tx_bsize];
- if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
- for (int r = 0; r < txb_height; r++)
- for (int c = 0; c < txb_width; c++)
- CONVERT_TO_SHORTPTR(dst)[r * stride + c] = 0;
- } else {
- for (int r = 0; r < txb_height; r++)
- for (int c = 0; c < txb_width; c++) dst[r * stride + c] = 0;
- }
-#endif // CONFIG_PVQ
+
TxfmParam txfm_param;
init_txfm_param(xd, tx_size, tx_type, eob, &txfm_param);
#if CONFIG_LGT || CONFIG_MRC_TX
diff --git a/av1/common/laplace_tables.c b/av1/common/laplace_tables.c
deleted file mode 100644
index ab87848..0000000
--- a/av1/common/laplace_tables.c
+++ /dev/null
@@ -1,657 +0,0 @@
-/* This file is auto-generated using "gen_laplace_tables 128 7" */
-
-/* clang-format off */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "aom_dsp/prob.h"
-#include "pvq.h"
-
-const uint16_t EXP_CDF_TABLE[128][16] = {
- {AOM_ICDF(32753), AOM_ICDF(32754), AOM_ICDF(32755), AOM_ICDF(32756),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(32499), AOM_ICDF(32753), AOM_ICDF(32755), AOM_ICDF(32756),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(32243), AOM_ICDF(32747), AOM_ICDF(32755), AOM_ICDF(32756),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(31987), AOM_ICDF(32737), AOM_ICDF(32755), AOM_ICDF(32756),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(31732), AOM_ICDF(32724), AOM_ICDF(32755), AOM_ICDF(32756),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(31476), AOM_ICDF(32706), AOM_ICDF(32754), AOM_ICDF(32756),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(31220), AOM_ICDF(32684), AOM_ICDF(32753), AOM_ICDF(32756),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(30964), AOM_ICDF(32658), AOM_ICDF(32751), AOM_ICDF(32756),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(30708), AOM_ICDF(32628), AOM_ICDF(32748), AOM_ICDF(32756),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(30452), AOM_ICDF(32594), AOM_ICDF(32745), AOM_ICDF(32756),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(30198), AOM_ICDF(32558), AOM_ICDF(32742), AOM_ICDF(32756),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(29941), AOM_ICDF(32515), AOM_ICDF(32736), AOM_ICDF(32755),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(29686), AOM_ICDF(32470), AOM_ICDF(32731), AOM_ICDF(32755),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(29429), AOM_ICDF(32419), AOM_ICDF(32723), AOM_ICDF(32754),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(29174), AOM_ICDF(32366), AOM_ICDF(32715), AOM_ICDF(32753),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(28918), AOM_ICDF(32308), AOM_ICDF(32705), AOM_ICDF(32752),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(28662), AOM_ICDF(32246), AOM_ICDF(32694), AOM_ICDF(32750),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(28406), AOM_ICDF(32180), AOM_ICDF(32681), AOM_ICDF(32748),
- AOM_ICDF(32757), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(28150), AOM_ICDF(32110), AOM_ICDF(32667), AOM_ICDF(32745),
- AOM_ICDF(32756), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(27894), AOM_ICDF(32036), AOM_ICDF(32651), AOM_ICDF(32742),
- AOM_ICDF(32756), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(27639), AOM_ICDF(31959), AOM_ICDF(32634), AOM_ICDF(32739),
- AOM_ICDF(32755), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(27383), AOM_ICDF(31877), AOM_ICDF(32614), AOM_ICDF(32735),
- AOM_ICDF(32755), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(27126), AOM_ICDF(31790), AOM_ICDF(32592), AOM_ICDF(32730),
- AOM_ICDF(32754), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(26871), AOM_ICDF(31701), AOM_ICDF(32569), AOM_ICDF(32725),
- AOM_ICDF(32753), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(26615), AOM_ICDF(31607), AOM_ICDF(32543), AOM_ICDF(32719),
- AOM_ICDF(32752), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(26361), AOM_ICDF(31511), AOM_ICDF(32517), AOM_ICDF(32713),
- AOM_ICDF(32751), AOM_ICDF(32758), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(26104), AOM_ICDF(31408), AOM_ICDF(32485), AOM_ICDF(32704),
- AOM_ICDF(32748), AOM_ICDF(32757), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(25848), AOM_ICDF(31302), AOM_ICDF(32452), AOM_ICDF(32695),
- AOM_ICDF(32746), AOM_ICDF(32757), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(25591), AOM_ICDF(31191), AOM_ICDF(32416), AOM_ICDF(32684),
- AOM_ICDF(32743), AOM_ICDF(32756), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(25336), AOM_ICDF(31078), AOM_ICDF(32379), AOM_ICDF(32674),
- AOM_ICDF(32741), AOM_ICDF(32756), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(25080), AOM_ICDF(30960), AOM_ICDF(32338), AOM_ICDF(32661),
- AOM_ICDF(32737), AOM_ICDF(32755), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(24824), AOM_ICDF(30838), AOM_ICDF(32295), AOM_ICDF(32648),
- AOM_ICDF(32733), AOM_ICDF(32754), AOM_ICDF(32759), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(24568), AOM_ICDF(30712), AOM_ICDF(32248), AOM_ICDF(32632),
- AOM_ICDF(32728), AOM_ICDF(32752), AOM_ICDF(32758), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(24313), AOM_ICDF(30583), AOM_ICDF(32199), AOM_ICDF(32616),
- AOM_ICDF(32723), AOM_ICDF(32751), AOM_ICDF(32758), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(24057), AOM_ICDF(30449), AOM_ICDF(32147), AOM_ICDF(32598),
- AOM_ICDF(32718), AOM_ICDF(32750), AOM_ICDF(32758), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(23801), AOM_ICDF(30311), AOM_ICDF(32091), AOM_ICDF(32578),
- AOM_ICDF(32711), AOM_ICDF(32747), AOM_ICDF(32757), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(23546), AOM_ICDF(30170), AOM_ICDF(32033), AOM_ICDF(32557),
- AOM_ICDF(32704), AOM_ICDF(32745), AOM_ICDF(32757), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(23288), AOM_ICDF(30022), AOM_ICDF(31969), AOM_ICDF(32532),
- AOM_ICDF(32695), AOM_ICDF(32742), AOM_ICDF(32756), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(23033), AOM_ICDF(29873), AOM_ICDF(31904), AOM_ICDF(32507),
- AOM_ICDF(32686), AOM_ICDF(32739), AOM_ICDF(32755), AOM_ICDF(32760),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(22778), AOM_ICDF(29720), AOM_ICDF(31835), AOM_ICDF(32479),
- AOM_ICDF(32675), AOM_ICDF(32735), AOM_ICDF(32753), AOM_ICDF(32759),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(22521), AOM_ICDF(29561), AOM_ICDF(31761), AOM_ICDF(32449),
- AOM_ICDF(32664), AOM_ICDF(32731), AOM_ICDF(32752), AOM_ICDF(32759),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(22267), AOM_ICDF(29401), AOM_ICDF(31686), AOM_ICDF(32418),
- AOM_ICDF(32652), AOM_ICDF(32727), AOM_ICDF(32751), AOM_ICDF(32759),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(22011), AOM_ICDF(29235), AOM_ICDF(31605), AOM_ICDF(32383),
- AOM_ICDF(32638), AOM_ICDF(32722), AOM_ICDF(32749), AOM_ICDF(32758),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(21754), AOM_ICDF(29064), AOM_ICDF(31520), AOM_ICDF(32345),
- AOM_ICDF(32622), AOM_ICDF(32715), AOM_ICDF(32746), AOM_ICDF(32757),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(21501), AOM_ICDF(28893), AOM_ICDF(31434), AOM_ICDF(32307),
- AOM_ICDF(32607), AOM_ICDF(32710), AOM_ICDF(32745), AOM_ICDF(32757),
- AOM_ICDF(32761), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(21243), AOM_ICDF(28713), AOM_ICDF(31339), AOM_ICDF(32262),
- AOM_ICDF(32587), AOM_ICDF(32701), AOM_ICDF(32741), AOM_ICDF(32755),
- AOM_ICDF(32760), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(20988), AOM_ICDF(28532), AOM_ICDF(31243), AOM_ICDF(32217),
- AOM_ICDF(32567), AOM_ICDF(32693), AOM_ICDF(32738), AOM_ICDF(32754),
- AOM_ICDF(32760), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(20730), AOM_ICDF(28344), AOM_ICDF(31140), AOM_ICDF(32167),
- AOM_ICDF(32544), AOM_ICDF(32682), AOM_ICDF(32733), AOM_ICDF(32752),
- AOM_ICDF(32759), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(20476), AOM_ICDF(28156), AOM_ICDF(31036), AOM_ICDF(32116),
- AOM_ICDF(32521), AOM_ICDF(32673), AOM_ICDF(32730), AOM_ICDF(32751),
- AOM_ICDF(32759), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(20220), AOM_ICDF(27962), AOM_ICDF(30926), AOM_ICDF(32061),
- AOM_ICDF(32495), AOM_ICDF(32661), AOM_ICDF(32725), AOM_ICDF(32749),
- AOM_ICDF(32758), AOM_ICDF(32762), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(19963), AOM_ICDF(27763), AOM_ICDF(30810), AOM_ICDF(32000),
- AOM_ICDF(32465), AOM_ICDF(32647), AOM_ICDF(32718), AOM_ICDF(32746),
- AOM_ICDF(32757), AOM_ICDF(32761), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(19708), AOM_ICDF(27562), AOM_ICDF(30691), AOM_ICDF(31938),
- AOM_ICDF(32435), AOM_ICDF(32633), AOM_ICDF(32712), AOM_ICDF(32743),
- AOM_ICDF(32756), AOM_ICDF(32761), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(19454), AOM_ICDF(27358), AOM_ICDF(30569), AOM_ICDF(31873),
- AOM_ICDF(32403), AOM_ICDF(32618), AOM_ICDF(32705), AOM_ICDF(32741),
- AOM_ICDF(32755), AOM_ICDF(32761), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(19196), AOM_ICDF(27146), AOM_ICDF(30438), AOM_ICDF(31801),
- AOM_ICDF(32365), AOM_ICDF(32599), AOM_ICDF(32696), AOM_ICDF(32736),
- AOM_ICDF(32753), AOM_ICDF(32760), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(18942), AOM_ICDF(26934), AOM_ICDF(30306), AOM_ICDF(31728),
- AOM_ICDF(32328), AOM_ICDF(32581), AOM_ICDF(32688), AOM_ICDF(32733),
- AOM_ICDF(32752), AOM_ICDF(32760), AOM_ICDF(32763), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(18684), AOM_ICDF(26714), AOM_ICDF(30164), AOM_ICDF(31647),
- AOM_ICDF(32284), AOM_ICDF(32558), AOM_ICDF(32676), AOM_ICDF(32727),
- AOM_ICDF(32749), AOM_ICDF(32758), AOM_ICDF(32762), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(18429), AOM_ICDF(26493), AOM_ICDF(30021), AOM_ICDF(31565),
- AOM_ICDF(32240), AOM_ICDF(32535), AOM_ICDF(32664), AOM_ICDF(32721),
- AOM_ICDF(32746), AOM_ICDF(32757), AOM_ICDF(32762), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(18174), AOM_ICDF(26268), AOM_ICDF(29872), AOM_ICDF(31477),
- AOM_ICDF(32192), AOM_ICDF(32510), AOM_ICDF(32652), AOM_ICDF(32715),
- AOM_ICDF(32743), AOM_ICDF(32756), AOM_ICDF(32762), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(17920), AOM_ICDF(26040), AOM_ICDF(29719), AOM_ICDF(31386),
- AOM_ICDF(32141), AOM_ICDF(32483), AOM_ICDF(32638), AOM_ICDF(32708),
- AOM_ICDF(32740), AOM_ICDF(32754), AOM_ICDF(32761), AOM_ICDF(32764),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(17661), AOM_ICDF(25803), AOM_ICDF(29556), AOM_ICDF(31286),
- AOM_ICDF(32083), AOM_ICDF(32451), AOM_ICDF(32620), AOM_ICDF(32698),
- AOM_ICDF(32734), AOM_ICDF(32751), AOM_ICDF(32759), AOM_ICDF(32763),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(17406), AOM_ICDF(25566), AOM_ICDF(29391), AOM_ICDF(31184),
- AOM_ICDF(32024), AOM_ICDF(32418), AOM_ICDF(32603), AOM_ICDF(32690),
- AOM_ICDF(32731), AOM_ICDF(32750), AOM_ICDF(32759), AOM_ICDF(32763),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(17151), AOM_ICDF(25325), AOM_ICDF(29220), AOM_ICDF(31076),
- AOM_ICDF(31961), AOM_ICDF(32383), AOM_ICDF(32584), AOM_ICDF(32680),
- AOM_ICDF(32726), AOM_ICDF(32748), AOM_ICDF(32758), AOM_ICDF(32763),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(16896), AOM_ICDF(25080), AOM_ICDF(29044), AOM_ICDF(30964),
- AOM_ICDF(31894), AOM_ICDF(32344), AOM_ICDF(32562), AOM_ICDF(32668),
- AOM_ICDF(32719), AOM_ICDF(32744), AOM_ICDF(32756), AOM_ICDF(32762),
- AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(16639), AOM_ICDF(24829), AOM_ICDF(28860), AOM_ICDF(30844),
- AOM_ICDF(31821), AOM_ICDF(32302), AOM_ICDF(32539), AOM_ICDF(32655),
- AOM_ICDF(32712), AOM_ICDF(32740), AOM_ICDF(32754), AOM_ICDF(32761),
- AOM_ICDF(32764), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(28672), AOM_ICDF(30720),
- AOM_ICDF(31744), AOM_ICDF(32256), AOM_ICDF(32512), AOM_ICDF(32640),
- AOM_ICDF(32704), AOM_ICDF(32736), AOM_ICDF(32752), AOM_ICDF(32760),
- AOM_ICDF(32764), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(16130), AOM_ICDF(24320), AOM_ICDF(28479), AOM_ICDF(30591),
- AOM_ICDF(31663), AOM_ICDF(32208), AOM_ICDF(32485), AOM_ICDF(32625),
- AOM_ICDF(32696), AOM_ICDF(32732), AOM_ICDF(32750), AOM_ICDF(32759),
- AOM_ICDF(32764), AOM_ICDF(32766), AOM_ICDF(32767), AOM_ICDF(32768)},
- {AOM_ICDF(15872), AOM_ICDF(24056), AOM_ICDF(28276), AOM_ICDF(30452),
- AOM_ICDF(31574), AOM_ICDF(32152), AOM_ICDF(32450), AOM_ICDF(32604),
- AOM_ICDF(32683), AOM_ICDF(32724), AOM_ICDF(32745), AOM_ICDF(32756),
- AOM_ICDF(32762), AOM_ICDF(32765), AOM_ICDF(32766), AOM_ICDF(32768)},
- {AOM_ICDF(15615), AOM_ICDF(23789), AOM_ICDF(28068), AOM_ICDF(30308),
- AOM_ICDF(31480), AOM_ICDF(32094), AOM_ICDF(32415), AOM_ICDF(32583),
- AOM_ICDF(32671), AOM_ICDF(32717), AOM_ICDF(32741), AOM_ICDF(32754),
- AOM_ICDF(32761), AOM_ICDF(32764), AOM_ICDF(32766), AOM_ICDF(32768)},
- {AOM_ICDF(15361), AOM_ICDF(23521), AOM_ICDF(27856), AOM_ICDF(30159),
- AOM_ICDF(31382), AOM_ICDF(32032), AOM_ICDF(32377), AOM_ICDF(32560),
- AOM_ICDF(32657), AOM_ICDF(32709), AOM_ICDF(32737), AOM_ICDF(32752),
- AOM_ICDF(32760), AOM_ICDF(32764), AOM_ICDF(32766), AOM_ICDF(32768)},
- {AOM_ICDF(15103), AOM_ICDF(23245), AOM_ICDF(27634), AOM_ICDF(30000),
- AOM_ICDF(31275), AOM_ICDF(31963), AOM_ICDF(32334), AOM_ICDF(32534),
- AOM_ICDF(32642), AOM_ICDF(32700), AOM_ICDF(32731), AOM_ICDF(32748),
- AOM_ICDF(32757), AOM_ICDF(32762), AOM_ICDF(32765), AOM_ICDF(32768)},
- {AOM_ICDF(14848), AOM_ICDF(22968), AOM_ICDF(27409), AOM_ICDF(29837),
- AOM_ICDF(31165), AOM_ICDF(31891), AOM_ICDF(32288), AOM_ICDF(32505),
- AOM_ICDF(32624), AOM_ICDF(32689), AOM_ICDF(32725), AOM_ICDF(32744),
- AOM_ICDF(32755), AOM_ICDF(32761), AOM_ICDF(32764), AOM_ICDF(32768)},
- {AOM_ICDF(14592), AOM_ICDF(22686), AOM_ICDF(27176), AOM_ICDF(29666),
- AOM_ICDF(31047), AOM_ICDF(31813), AOM_ICDF(32238), AOM_ICDF(32474),
- AOM_ICDF(32605), AOM_ICDF(32678), AOM_ICDF(32718), AOM_ICDF(32740),
- AOM_ICDF(32752), AOM_ICDF(32759), AOM_ICDF(32763), AOM_ICDF(32768)},
- {AOM_ICDF(14336), AOM_ICDF(22400), AOM_ICDF(26936), AOM_ICDF(29488),
- AOM_ICDF(30923), AOM_ICDF(31730), AOM_ICDF(32184), AOM_ICDF(32439),
- AOM_ICDF(32583), AOM_ICDF(32664), AOM_ICDF(32709), AOM_ICDF(32735),
- AOM_ICDF(32749), AOM_ICDF(32757), AOM_ICDF(32762), AOM_ICDF(32768)},
- {AOM_ICDF(14079), AOM_ICDF(22109), AOM_ICDF(26689), AOM_ICDF(29301),
- AOM_ICDF(30791), AOM_ICDF(31641), AOM_ICDF(32125), AOM_ICDF(32401),
- AOM_ICDF(32559), AOM_ICDF(32649), AOM_ICDF(32700), AOM_ICDF(32729),
- AOM_ICDF(32746), AOM_ICDF(32756), AOM_ICDF(32761), AOM_ICDF(32768)},
- {AOM_ICDF(13825), AOM_ICDF(21817), AOM_ICDF(26437), AOM_ICDF(29108),
- AOM_ICDF(30652), AOM_ICDF(31545), AOM_ICDF(32061), AOM_ICDF(32359),
- AOM_ICDF(32532), AOM_ICDF(32632), AOM_ICDF(32690), AOM_ICDF(32723),
- AOM_ICDF(32742), AOM_ICDF(32753), AOM_ICDF(32759), AOM_ICDF(32768)},
- {AOM_ICDF(13568), AOM_ICDF(21518), AOM_ICDF(26176), AOM_ICDF(28905),
- AOM_ICDF(30504), AOM_ICDF(31441), AOM_ICDF(31990), AOM_ICDF(32312),
- AOM_ICDF(32501), AOM_ICDF(32611), AOM_ICDF(32676), AOM_ICDF(32714),
- AOM_ICDF(32736), AOM_ICDF(32749), AOM_ICDF(32757), AOM_ICDF(32768)},
- {AOM_ICDF(13314), AOM_ICDF(21218), AOM_ICDF(25911), AOM_ICDF(28697),
- AOM_ICDF(30351), AOM_ICDF(31333), AOM_ICDF(31916), AOM_ICDF(32262),
- AOM_ICDF(32468), AOM_ICDF(32590), AOM_ICDF(32662), AOM_ICDF(32705),
- AOM_ICDF(32731), AOM_ICDF(32746), AOM_ICDF(32755), AOM_ICDF(32768)},
- {AOM_ICDF(13054), AOM_ICDF(20908), AOM_ICDF(25633), AOM_ICDF(28475),
- AOM_ICDF(30185), AOM_ICDF(31214), AOM_ICDF(31833), AOM_ICDF(32205),
- AOM_ICDF(32429), AOM_ICDF(32564), AOM_ICDF(32645), AOM_ICDF(32694),
- AOM_ICDF(32723), AOM_ICDF(32741), AOM_ICDF(32752), AOM_ICDF(32768)},
- {AOM_ICDF(12803), AOM_ICDF(20603), AOM_ICDF(25356), AOM_ICDF(28252),
- AOM_ICDF(30017), AOM_ICDF(31093), AOM_ICDF(31748), AOM_ICDF(32147),
- AOM_ICDF(32390), AOM_ICDF(32538), AOM_ICDF(32628), AOM_ICDF(32683),
- AOM_ICDF(32717), AOM_ICDF(32737), AOM_ICDF(32749), AOM_ICDF(32768)},
- {AOM_ICDF(12544), AOM_ICDF(20286), AOM_ICDF(25064), AOM_ICDF(28013),
- AOM_ICDF(29833), AOM_ICDF(30956), AOM_ICDF(31649), AOM_ICDF(32077),
- AOM_ICDF(32341), AOM_ICDF(32504), AOM_ICDF(32605), AOM_ICDF(32667),
- AOM_ICDF(32705), AOM_ICDF(32729), AOM_ICDF(32744), AOM_ICDF(32768)},
- {AOM_ICDF(12288), AOM_ICDF(19968), AOM_ICDF(24768), AOM_ICDF(27768),
- AOM_ICDF(29643), AOM_ICDF(30815), AOM_ICDF(31547), AOM_ICDF(32005),
- AOM_ICDF(32291), AOM_ICDF(32470), AOM_ICDF(32582), AOM_ICDF(32652),
- AOM_ICDF(32696), AOM_ICDF(32723), AOM_ICDF(32740), AOM_ICDF(32768)},
- {AOM_ICDF(12033), AOM_ICDF(19647), AOM_ICDF(24465), AOM_ICDF(27514),
- AOM_ICDF(29443), AOM_ICDF(30664), AOM_ICDF(31437), AOM_ICDF(31926),
- AOM_ICDF(32235), AOM_ICDF(32431), AOM_ICDF(32555), AOM_ICDF(32633),
- AOM_ICDF(32683), AOM_ICDF(32714), AOM_ICDF(32734), AOM_ICDF(32768)},
- {AOM_ICDF(11777), AOM_ICDF(19321), AOM_ICDF(24154), AOM_ICDF(27250),
- AOM_ICDF(29233), AOM_ICDF(30504), AOM_ICDF(31318), AOM_ICDF(31839),
- AOM_ICDF(32173), AOM_ICDF(32387), AOM_ICDF(32524), AOM_ICDF(32612),
- AOM_ICDF(32668), AOM_ICDF(32704), AOM_ICDF(32727), AOM_ICDF(32768)},
- {AOM_ICDF(11521), AOM_ICDF(18991), AOM_ICDF(23835), AOM_ICDF(26976),
- AOM_ICDF(29013), AOM_ICDF(30334), AOM_ICDF(31190), AOM_ICDF(31745),
- AOM_ICDF(32105), AOM_ICDF(32338), AOM_ICDF(32489), AOM_ICDF(32587),
- AOM_ICDF(32651), AOM_ICDF(32692), AOM_ICDF(32719), AOM_ICDF(32768)},
- {AOM_ICDF(11265), AOM_ICDF(18657), AOM_ICDF(23508), AOM_ICDF(26691),
- AOM_ICDF(28780), AOM_ICDF(30151), AOM_ICDF(31051), AOM_ICDF(31641),
- AOM_ICDF(32028), AOM_ICDF(32282), AOM_ICDF(32449), AOM_ICDF(32559),
- AOM_ICDF(32631), AOM_ICDF(32678), AOM_ICDF(32709), AOM_ICDF(32768)},
- {AOM_ICDF(11006), AOM_ICDF(18316), AOM_ICDF(23170), AOM_ICDF(26394),
- AOM_ICDF(28535), AOM_ICDF(29957), AOM_ICDF(30901), AOM_ICDF(31528),
- AOM_ICDF(31944), AOM_ICDF(32220), AOM_ICDF(32404), AOM_ICDF(32526),
- AOM_ICDF(32607), AOM_ICDF(32661), AOM_ICDF(32697), AOM_ICDF(32768)},
- {AOM_ICDF(10752), AOM_ICDF(17976), AOM_ICDF(22830), AOM_ICDF(26091),
- AOM_ICDF(28282), AOM_ICDF(29754), AOM_ICDF(30743), AOM_ICDF(31408),
- AOM_ICDF(31854), AOM_ICDF(32154), AOM_ICDF(32356), AOM_ICDF(32491),
- AOM_ICDF(32582), AOM_ICDF(32643), AOM_ICDF(32684), AOM_ICDF(32768)},
- {AOM_ICDF(10496), AOM_ICDF(17630), AOM_ICDF(22479), AOM_ICDF(25775),
- AOM_ICDF(28015), AOM_ICDF(29538), AOM_ICDF(30573), AOM_ICDF(31276),
- AOM_ICDF(31754), AOM_ICDF(32079), AOM_ICDF(32300), AOM_ICDF(32450),
- AOM_ICDF(32552), AOM_ICDF(32621), AOM_ICDF(32668), AOM_ICDF(32768)},
- {AOM_ICDF(10240), AOM_ICDF(17280), AOM_ICDF(22120), AOM_ICDF(25448),
- AOM_ICDF(27736), AOM_ICDF(29309), AOM_ICDF(30390), AOM_ICDF(31133),
- AOM_ICDF(31644), AOM_ICDF(31995), AOM_ICDF(32237), AOM_ICDF(32403),
- AOM_ICDF(32517), AOM_ICDF(32595), AOM_ICDF(32649), AOM_ICDF(32768)},
- { AOM_ICDF(9984), AOM_ICDF(16926), AOM_ICDF(21753), AOM_ICDF(25109),
- AOM_ICDF(27443), AOM_ICDF(29066), AOM_ICDF(30194), AOM_ICDF(30978),
- AOM_ICDF(31523), AOM_ICDF(31902), AOM_ICDF(32166), AOM_ICDF(32349),
- AOM_ICDF(32476), AOM_ICDF(32565), AOM_ICDF(32627), AOM_ICDF(32768)},
- { AOM_ICDF(9728), AOM_ICDF(16568), AOM_ICDF(21377), AOM_ICDF(24759),
- AOM_ICDF(27137), AOM_ICDF(28809), AOM_ICDF(29984), AOM_ICDF(30811),
- AOM_ICDF(31392), AOM_ICDF(31801), AOM_ICDF(32088), AOM_ICDF(32290),
- AOM_ICDF(32432), AOM_ICDF(32532), AOM_ICDF(32602), AOM_ICDF(32768)},
- { AOM_ICDF(9474), AOM_ICDF(16208), AOM_ICDF(20995), AOM_ICDF(24399),
- AOM_ICDF(26819), AOM_ICDF(28539), AOM_ICDF(29762), AOM_ICDF(30631),
- AOM_ICDF(31249), AOM_ICDF(31688), AOM_ICDF(32000), AOM_ICDF(32222),
- AOM_ICDF(32380), AOM_ICDF(32492), AOM_ICDF(32572), AOM_ICDF(32768)},
- { AOM_ICDF(9216), AOM_ICDF(15840), AOM_ICDF(20601), AOM_ICDF(24023),
- AOM_ICDF(26483), AOM_ICDF(28251), AOM_ICDF(29522), AOM_ICDF(30435),
- AOM_ICDF(31091), AOM_ICDF(31563), AOM_ICDF(31902), AOM_ICDF(32146),
- AOM_ICDF(32321), AOM_ICDF(32447), AOM_ICDF(32537), AOM_ICDF(32768)},
- { AOM_ICDF(8959), AOM_ICDF(15469), AOM_ICDF(20199), AOM_ICDF(23636),
- AOM_ICDF(26133), AOM_ICDF(27947), AOM_ICDF(29265), AOM_ICDF(30223),
- AOM_ICDF(30919), AOM_ICDF(31425), AOM_ICDF(31792), AOM_ICDF(32059),
- AOM_ICDF(32253), AOM_ICDF(32394), AOM_ICDF(32496), AOM_ICDF(32768)},
- { AOM_ICDF(8705), AOM_ICDF(15097), AOM_ICDF(19791), AOM_ICDF(23238),
- AOM_ICDF(25770), AOM_ICDF(27629), AOM_ICDF(28994), AOM_ICDF(29997),
- AOM_ICDF(30733), AOM_ICDF(31274), AOM_ICDF(31671), AOM_ICDF(31963),
- AOM_ICDF(32177), AOM_ICDF(32334), AOM_ICDF(32449), AOM_ICDF(32768)},
- { AOM_ICDF(8449), AOM_ICDF(14719), AOM_ICDF(19373), AOM_ICDF(22827),
- AOM_ICDF(25390), AOM_ICDF(27292), AOM_ICDF(28704), AOM_ICDF(29752),
- AOM_ICDF(30530), AOM_ICDF(31107), AOM_ICDF(31535), AOM_ICDF(31853),
- AOM_ICDF(32089), AOM_ICDF(32264), AOM_ICDF(32394), AOM_ICDF(32768)},
- { AOM_ICDF(8192), AOM_ICDF(14336), AOM_ICDF(18944), AOM_ICDF(22400),
- AOM_ICDF(24992), AOM_ICDF(26936), AOM_ICDF(28394), AOM_ICDF(29488),
- AOM_ICDF(30308), AOM_ICDF(30923), AOM_ICDF(31384), AOM_ICDF(31730),
- AOM_ICDF(31989), AOM_ICDF(32184), AOM_ICDF(32330), AOM_ICDF(32768)},
- { AOM_ICDF(7936), AOM_ICDF(13950), AOM_ICDF(18507), AOM_ICDF(21961),
- AOM_ICDF(24578), AOM_ICDF(26561), AOM_ICDF(28064), AOM_ICDF(29203),
- AOM_ICDF(30066), AOM_ICDF(30720), AOM_ICDF(31216), AOM_ICDF(31592),
- AOM_ICDF(31877), AOM_ICDF(32093), AOM_ICDF(32256), AOM_ICDF(32768)},
- { AOM_ICDF(7678), AOM_ICDF(13558), AOM_ICDF(18060), AOM_ICDF(21507),
- AOM_ICDF(24146), AOM_ICDF(26166), AOM_ICDF(27713), AOM_ICDF(28897),
- AOM_ICDF(29804), AOM_ICDF(30498), AOM_ICDF(31030), AOM_ICDF(31437),
- AOM_ICDF(31749), AOM_ICDF(31988), AOM_ICDF(32171), AOM_ICDF(32768)},
- { AOM_ICDF(7423), AOM_ICDF(13165), AOM_ICDF(17606), AOM_ICDF(21041),
- AOM_ICDF(23698), AOM_ICDF(25753), AOM_ICDF(27342), AOM_ICDF(28571),
- AOM_ICDF(29522), AOM_ICDF(30257), AOM_ICDF(30826), AOM_ICDF(31266),
- AOM_ICDF(31606), AOM_ICDF(31869), AOM_ICDF(32073), AOM_ICDF(32768)},
- { AOM_ICDF(7168), AOM_ICDF(12768), AOM_ICDF(17143), AOM_ICDF(20561),
- AOM_ICDF(23231), AOM_ICDF(25317), AOM_ICDF(26947), AOM_ICDF(28220),
- AOM_ICDF(29215), AOM_ICDF(29992), AOM_ICDF(30599), AOM_ICDF(31073),
- AOM_ICDF(31444), AOM_ICDF(31734), AOM_ICDF(31960), AOM_ICDF(32768)},
- { AOM_ICDF(6911), AOM_ICDF(12365), AOM_ICDF(16669), AOM_ICDF(20065),
- AOM_ICDF(22744), AOM_ICDF(24858), AOM_ICDF(26526), AOM_ICDF(27842),
- AOM_ICDF(28881), AOM_ICDF(29701), AOM_ICDF(30348), AOM_ICDF(30858),
- AOM_ICDF(31261), AOM_ICDF(31579), AOM_ICDF(31830), AOM_ICDF(32768)},
- { AOM_ICDF(6657), AOM_ICDF(11961), AOM_ICDF(16188), AOM_ICDF(19556),
- AOM_ICDF(22240), AOM_ICDF(24379), AOM_ICDF(26083), AOM_ICDF(27441),
- AOM_ICDF(28523), AOM_ICDF(29385), AOM_ICDF(30072), AOM_ICDF(30620),
- AOM_ICDF(31056), AOM_ICDF(31404), AOM_ICDF(31681), AOM_ICDF(32768)},
- { AOM_ICDF(6400), AOM_ICDF(11550), AOM_ICDF(15694), AOM_ICDF(19029),
- AOM_ICDF(21712), AOM_ICDF(23871), AOM_ICDF(25609), AOM_ICDF(27007),
- AOM_ICDF(28132), AOM_ICDF(29037), AOM_ICDF(29766), AOM_ICDF(30352),
- AOM_ICDF(30824), AOM_ICDF(31204), AOM_ICDF(31509), AOM_ICDF(32768)},
- { AOM_ICDF(6142), AOM_ICDF(11134), AOM_ICDF(15190), AOM_ICDF(18486),
- AOM_ICDF(21164), AOM_ICDF(23340), AOM_ICDF(25108), AOM_ICDF(26544),
- AOM_ICDF(27711), AOM_ICDF(28659), AOM_ICDF(29429), AOM_ICDF(30055),
- AOM_ICDF(30564), AOM_ICDF(30977), AOM_ICDF(31313), AOM_ICDF(32768)},
- { AOM_ICDF(5890), AOM_ICDF(10720), AOM_ICDF(14682), AOM_ICDF(17932),
- AOM_ICDF(20598), AOM_ICDF(22785), AOM_ICDF(24579), AOM_ICDF(26051),
- AOM_ICDF(27258), AOM_ICDF(28248), AOM_ICDF(29060), AOM_ICDF(29726),
- AOM_ICDF(30273), AOM_ICDF(30721), AOM_ICDF(31089), AOM_ICDF(32768)},
- { AOM_ICDF(5631), AOM_ICDF(10295), AOM_ICDF(14157), AOM_ICDF(17356),
- AOM_ICDF(20005), AOM_ICDF(22199), AOM_ICDF(24016), AOM_ICDF(25520),
- AOM_ICDF(26766), AOM_ICDF(27798), AOM_ICDF(28652), AOM_ICDF(29359),
- AOM_ICDF(29945), AOM_ICDF(30430), AOM_ICDF(30832), AOM_ICDF(32768)},
- { AOM_ICDF(5377), AOM_ICDF(9871), AOM_ICDF(13628), AOM_ICDF(16768),
- AOM_ICDF(19393), AOM_ICDF(21587), AOM_ICDF(23421), AOM_ICDF(24954),
- AOM_ICDF(26236), AOM_ICDF(27308), AOM_ICDF(28204), AOM_ICDF(28953),
- AOM_ICDF(29579), AOM_ICDF(30102), AOM_ICDF(30539), AOM_ICDF(32768)},
- { AOM_ICDF(5121), AOM_ICDF(9441), AOM_ICDF(13086), AOM_ICDF(16161),
- AOM_ICDF(18756), AOM_ICDF(20945), AOM_ICDF(22792), AOM_ICDF(24351),
- AOM_ICDF(25666), AOM_ICDF(26776), AOM_ICDF(27712), AOM_ICDF(28502),
- AOM_ICDF(29169), AOM_ICDF(29731), AOM_ICDF(30206), AOM_ICDF(32768)},
- { AOM_ICDF(4865), AOM_ICDF(9007), AOM_ICDF(12534), AOM_ICDF(15538),
- AOM_ICDF(18096), AOM_ICDF(20274), AOM_ICDF(22129), AOM_ICDF(23708),
- AOM_ICDF(25053), AOM_ICDF(26198), AOM_ICDF(27173), AOM_ICDF(28004),
- AOM_ICDF(28711), AOM_ICDF(29313), AOM_ICDF(29826), AOM_ICDF(32768)},
- { AOM_ICDF(4608), AOM_ICDF(8568), AOM_ICDF(11971), AOM_ICDF(14896),
- AOM_ICDF(17409), AOM_ICDF(19569), AOM_ICDF(21425), AOM_ICDF(23020),
- AOM_ICDF(24391), AOM_ICDF(25569), AOM_ICDF(26581), AOM_ICDF(27451),
- AOM_ICDF(28199), AOM_ICDF(28842), AOM_ICDF(29394), AOM_ICDF(32768)},
- { AOM_ICDF(4351), AOM_ICDF(8125), AOM_ICDF(11398), AOM_ICDF(14236),
- AOM_ICDF(16697), AOM_ICDF(18831), AOM_ICDF(20682), AOM_ICDF(22287),
- AOM_ICDF(23679), AOM_ICDF(24886), AOM_ICDF(25933), AOM_ICDF(26841),
- AOM_ICDF(27628), AOM_ICDF(28311), AOM_ICDF(28903), AOM_ICDF(32768)},
- { AOM_ICDF(4096), AOM_ICDF(7680), AOM_ICDF(10816), AOM_ICDF(13560),
- AOM_ICDF(15961), AOM_ICDF(18062), AOM_ICDF(19900), AOM_ICDF(21508),
- AOM_ICDF(22915), AOM_ICDF(24146), AOM_ICDF(25224), AOM_ICDF(26167),
- AOM_ICDF(26992), AOM_ICDF(27714), AOM_ICDF(28346), AOM_ICDF(32768)},
- { AOM_ICDF(3840), AOM_ICDF(7230), AOM_ICDF(10223), AOM_ICDF(12865),
- AOM_ICDF(15197), AOM_ICDF(17256), AOM_ICDF(19074), AOM_ICDF(20679),
- AOM_ICDF(22096), AOM_ICDF(23347), AOM_ICDF(24451), AOM_ICDF(25426),
- AOM_ICDF(26287), AOM_ICDF(27047), AOM_ICDF(27718), AOM_ICDF(32768)},
- { AOM_ICDF(3584), AOM_ICDF(6776), AOM_ICDF(9619), AOM_ICDF(12151),
- AOM_ICDF(14406), AOM_ICDF(16414), AOM_ICDF(18203), AOM_ICDF(19796),
- AOM_ICDF(21215), AOM_ICDF(22479), AOM_ICDF(23604), AOM_ICDF(24606),
- AOM_ICDF(25499), AOM_ICDF(26294), AOM_ICDF(27002), AOM_ICDF(32768)},
- { AOM_ICDF(3328), AOM_ICDF(6318), AOM_ICDF(9004), AOM_ICDF(11417),
- AOM_ICDF(13585), AOM_ICDF(15533), AOM_ICDF(17283), AOM_ICDF(18856),
- AOM_ICDF(20269), AOM_ICDF(21538), AOM_ICDF(22678), AOM_ICDF(23703),
- AOM_ICDF(24624), AOM_ICDF(25451), AOM_ICDF(26194), AOM_ICDF(32768)},
- { AOM_ICDF(3072), AOM_ICDF(5856), AOM_ICDF(8379), AOM_ICDF(10665),
- AOM_ICDF(12737), AOM_ICDF(14615), AOM_ICDF(16317), AOM_ICDF(17859),
- AOM_ICDF(19257), AOM_ICDF(20524), AOM_ICDF(21672), AOM_ICDF(22712),
- AOM_ICDF(23655), AOM_ICDF(24509), AOM_ICDF(25283), AOM_ICDF(32768)},
- { AOM_ICDF(2816), AOM_ICDF(5390), AOM_ICDF(7743), AOM_ICDF(9894),
- AOM_ICDF(11860), AOM_ICDF(13657), AOM_ICDF(15299), AOM_ICDF(16800),
- AOM_ICDF(18172), AOM_ICDF(19426), AOM_ICDF(20573), AOM_ICDF(21621),
- AOM_ICDF(22579), AOM_ICDF(23455), AOM_ICDF(24255), AOM_ICDF(32768)},
- { AOM_ICDF(2560), AOM_ICDF(4920), AOM_ICDF(7096), AOM_ICDF(9102),
- AOM_ICDF(10951), AOM_ICDF(12656), AOM_ICDF(14227), AOM_ICDF(15676),
- AOM_ICDF(17011), AOM_ICDF(18242), AOM_ICDF(19377), AOM_ICDF(20423),
- AOM_ICDF(21388), AOM_ICDF(22277), AOM_ICDF(23097), AOM_ICDF(32768)},
- { AOM_ICDF(2304), AOM_ICDF(4446), AOM_ICDF(6437), AOM_ICDF(8288),
- AOM_ICDF(10009), AOM_ICDF(11609), AOM_ICDF(13097), AOM_ICDF(14480),
- AOM_ICDF(15766), AOM_ICDF(16961), AOM_ICDF(18072), AOM_ICDF(19105),
- AOM_ICDF(20066), AOM_ICDF(20959), AOM_ICDF(21789), AOM_ICDF(32768)},
- { AOM_ICDF(2048), AOM_ICDF(3968), AOM_ICDF(5768), AOM_ICDF(7456),
- AOM_ICDF(9038), AOM_ICDF(10521), AOM_ICDF(11911), AOM_ICDF(13215),
- AOM_ICDF(14437), AOM_ICDF(15583), AOM_ICDF(16657), AOM_ICDF(17664),
- AOM_ICDF(18608), AOM_ICDF(19493), AOM_ICDF(20323), AOM_ICDF(32768)},
- { AOM_ICDF(1792), AOM_ICDF(3486), AOM_ICDF(5087), AOM_ICDF(6601),
- AOM_ICDF(8032), AOM_ICDF(9385), AOM_ICDF(10664), AOM_ICDF(11873),
- AOM_ICDF(13016), AOM_ICDF(14096), AOM_ICDF(15117), AOM_ICDF(16082),
- AOM_ICDF(16995), AOM_ICDF(17858), AOM_ICDF(18673), AOM_ICDF(32768)},
- { AOM_ICDF(1536), AOM_ICDF(3000), AOM_ICDF(4395), AOM_ICDF(5725),
- AOM_ICDF(6993), AOM_ICDF(8201), AOM_ICDF(9353), AOM_ICDF(10451),
- AOM_ICDF(11497), AOM_ICDF(12494), AOM_ICDF(13444), AOM_ICDF(14350),
- AOM_ICDF(15213), AOM_ICDF(16036), AOM_ICDF(16820), AOM_ICDF(32768)},
- { AOM_ICDF(1280), AOM_ICDF(2510), AOM_ICDF(3692), AOM_ICDF(4828),
- AOM_ICDF(5919), AOM_ICDF(6968), AOM_ICDF(7976), AOM_ICDF(8944),
- AOM_ICDF(9875), AOM_ICDF(10769), AOM_ICDF(11628), AOM_ICDF(12454),
- AOM_ICDF(13248), AOM_ICDF(14011), AOM_ICDF(14744), AOM_ICDF(32768)},
- { AOM_ICDF(1024), AOM_ICDF(2016), AOM_ICDF(2977), AOM_ICDF(3908),
- AOM_ICDF(4810), AOM_ICDF(5684), AOM_ICDF(6530), AOM_ICDF(7350),
- AOM_ICDF(8144), AOM_ICDF(8913), AOM_ICDF(9658), AOM_ICDF(10380),
- AOM_ICDF(11080), AOM_ICDF(11758), AOM_ICDF(12415), AOM_ICDF(32768)},
- { AOM_ICDF(768), AOM_ICDF(1518), AOM_ICDF(2250), AOM_ICDF(2965),
- AOM_ICDF(3663), AOM_ICDF(4345), AOM_ICDF(5011), AOM_ICDF(5662),
- AOM_ICDF(6297), AOM_ICDF(6917), AOM_ICDF(7523), AOM_ICDF(8115),
- AOM_ICDF(8693), AOM_ICDF(9257), AOM_ICDF(9808), AOM_ICDF(32768)},
- { AOM_ICDF(512), AOM_ICDF(1016), AOM_ICDF(1512), AOM_ICDF(2000),
- AOM_ICDF(2481), AOM_ICDF(2954), AOM_ICDF(3420), AOM_ICDF(3879),
- AOM_ICDF(4330), AOM_ICDF(4774), AOM_ICDF(5211), AOM_ICDF(5642),
- AOM_ICDF(6066), AOM_ICDF(6483), AOM_ICDF(6894), AOM_ICDF(32768)},
- { AOM_ICDF(256), AOM_ICDF(510), AOM_ICDF(762), AOM_ICDF(1012),
- AOM_ICDF(1260), AOM_ICDF(1506), AOM_ICDF(1750), AOM_ICDF(1992),
- AOM_ICDF(2232), AOM_ICDF(2471), AOM_ICDF(2708), AOM_ICDF(2943),
- AOM_ICDF(3176), AOM_ICDF(3407), AOM_ICDF(3636), AOM_ICDF(32768)},
-};
-
-
-const uint16_t LAPLACE_OFFSET[128] = {
- 0,
- 29871,
- 28672,
- 27751,
- 26975,
- 26291,
- 25673,
- 25105,
- 24576,
- 24079,
- 23609,
- 23162,
- 22734,
- 22325,
- 21931,
- 21550,
- 21182,
- 20826,
- 20480,
- 20143,
- 19815,
- 19495,
- 19183,
- 18877,
- 18579,
- 18286,
- 17999,
- 17718,
- 17442,
- 17170,
- 16904,
- 16642,
- 16384,
- 16129,
- 15879,
- 15633,
- 15390,
- 15150,
- 14913,
- 14680,
- 14450,
- 14222,
- 13997,
- 13775,
- 13556,
- 13338,
- 13124,
- 12911,
- 12701,
- 12493,
- 12288,
- 12084,
- 11882,
- 11682,
- 11484,
- 11288,
- 11094,
- 10901,
- 10710,
- 10521,
- 10333,
- 10147,
- 9962,
- 9779,
- 9597,
- 9417,
- 9238,
- 9060,
- 8884,
- 8709,
- 8535,
- 8363,
- 8192,
- 8021,
- 7853,
- 7685,
- 7518,
- 7352,
- 7188,
- 7025,
- 6862,
- 6701,
- 6540,
- 6381,
- 6222,
- 6065,
- 5908,
- 5753,
- 5598,
- 5444,
- 5291,
- 5138,
- 4987,
- 4837,
- 4687,
- 4538,
- 4390,
- 4242,
- 4096,
- 3950,
- 3804,
- 3660,
- 3516,
- 3373,
- 3231,
- 3089,
- 2948,
- 2808,
- 2668,
- 2529,
- 2391,
- 2253,
- 2116,
- 1979,
- 1843,
- 1708,
- 1573,
- 1439,
- 1306,
- 1172,
- 1040,
- 908,
- 777,
- 646,
- 516,
- 386,
- 257,
- 128,
-};
diff --git a/av1/common/odintrin.h b/av1/common/odintrin.h
index a50c456..8ee2531 100644
--- a/av1/common/odintrin.h
+++ b/av1/common/odintrin.h
@@ -77,16 +77,6 @@
# define OD_LOG(a)
# define OD_LOG_PARTIAL(a)
-/*Possible block sizes, note that OD_BLOCK_NXN = log2(N) - 2.*/
-#define OD_BLOCK_4X4 (0)
-#define OD_BLOCK_8X8 (1)
-#define OD_BLOCK_16X16 (2)
-#define OD_BLOCK_32X32 (3)
-#define OD_BLOCK_SIZES (OD_BLOCK_32X32 + 1)
-
-# define OD_LIMIT_BSIZE_MIN (OD_BLOCK_4X4)
-# define OD_LIMIT_BSIZE_MAX (OD_BLOCK_32X32)
-
typedef int od_coeff;
/*This is the strength reduced version of ((_a)/(1 << (_b))).
@@ -206,55 +196,13 @@
/** Silence unused parameter/variable warnings */
# define OD_UNUSED(expr) (void)(expr)
-#if defined(OD_FLOAT_PVQ)
-typedef double od_val16;
-typedef double od_val32;
-# define OD_QCONST32(x, bits) (x)
-# define OD_ROUND16(x) (x)
-# define OD_ROUND32(x) (x)
-# define OD_SHL(x, shift) (x)
-# define OD_SHR(x, shift) (x)
-# define OD_SHR_ROUND(x, shift) (x)
-# define OD_ABS(x) (fabs(x))
-# define OD_MULT16_16(a, b) ((a)*(b))
-# define OD_MULT16_32_Q16(a, b) ((a)*(b))
-#else
typedef int16_t od_val16;
typedef int32_t od_val32;
/** Compile-time conversion of float constant to 32-bit value */
# define OD_QCONST32(x, bits) ((od_val32)(.5 + (x)*(((od_val32)1) << (bits))))
# define OD_ROUND16(x) (int16_t)(floor(.5 + (x)))
# define OD_ROUND32(x) (int32_t)(floor(.5 + (x)))
-/*Shift x left by shift*/
-# define OD_SHL(a, shift) ((int32_t)((uint32_t)(a) << (shift)))
-/*Shift x right by shift (without rounding)*/
-# define OD_SHR(x, shift) \
- ((int32_t)((x) >> (shift)))
-/*Shift x right by shift (with rounding)*/
-# define OD_SHR_ROUND(x, shift) \
- ((int32_t)(((x) + (1 << (shift) >> 1)) >> (shift)))
-/*Shift x right by shift (without rounding) or left by -shift if shift
- is negative.*/
-# define OD_VSHR(x, shift) \
- (((shift) > 0) ? OD_SHR(x, shift) : OD_SHL(x, -(shift)))
-/*Shift x right by shift (with rounding) or left by -shift if shift
- is negative.*/
-# define OD_VSHR_ROUND(x, shift) \
- (((shift) > 0) ? OD_SHR_ROUND(x, shift) : OD_SHL(x, -(shift)))
# define OD_ABS(x) (abs(x))
-/* (od_val32)(od_val16) gives TI compiler a hint that it's 16x16->32 multiply */
-/** 16x16 multiplication where the result fits in 32 bits */
-# define OD_MULT16_16(a, b) \
- (((od_val32)(od_val16)(a))*((od_val32)(od_val16)(b)))
-/* Multiplies 16-bit a by 32-bit b and keeps bits [16:47]. */
-# define OD_MULT16_32_Q16(a, b) ((int16_t)(a)*(int64_t)(int32_t)(b) >> 16)
-/*16x16 multiplication where the result fits in 16 bits, without rounding.*/
-# define OD_MULT16_16_Q15(a, b) \
- (((int16_t)(a)*((int32_t)(int16_t)(b))) >> 15)
-/*16x16 multiplication where the result fits in 16 bits, without rounding.*/
-# define OD_MULT16_16_Q16(a, b) \
- ((((int16_t)(a))*((int32_t)(int16_t)(b))) >> 16)
-#endif
/*All of these macros should expect floats as arguments.*/
/*These two should compile as a single SSE instruction.*/
@@ -266,9 +214,6 @@
# define OD_SIGNMASK(a) (-((a) < 0))
# define OD_FLIPSIGNI(a, b) (((a) + OD_SIGNMASK(b)) ^ OD_SIGNMASK(b))
-# define OD_MULT16_16_Q15(a, b) \
- (((int16_t)(a)*((int32_t)(int16_t)(b))) >> 15)
-
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index fbe1e9e..00d7bff 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -32,9 +32,6 @@
#endif // CONFIG_LOOP_RESTORATION
#include "av1/common/tile_common.h"
#include "av1/common/odintrin.h"
-#if CONFIG_PVQ
-#include "av1/common/pvq.h"
-#endif
#if CONFIG_CFL
#include "av1/common/cfl.h"
#endif
@@ -688,18 +685,12 @@
#endif // CONFIG_CFL
static INLINE void av1_init_macroblockd(AV1_COMMON *cm, MACROBLOCKD *xd,
-#if CONFIG_PVQ
- tran_low_t *pvq_ref_coeff,
-#endif
#if CONFIG_CFL
CFL_CTX *cfl,
#endif
tran_low_t *dqcoeff) {
for (int i = 0; i < MAX_MB_PLANE; ++i) {
xd->plane[i].dqcoeff = dqcoeff;
-#if CONFIG_PVQ
- xd->plane[i].pvq_ref_coeff = pvq_ref_coeff;
-#endif
xd->above_context[i] = cm->above_context[i];
if (xd->plane[i].plane_type == PLANE_TYPE_Y) {
memcpy(xd->plane[i].seg_dequant, cm->y_dequant, sizeof(cm->y_dequant));
diff --git a/av1/common/partition.c b/av1/common/partition.c
deleted file mode 100644
index 634a9ed..0000000
--- a/av1/common/partition.c
+++ /dev/null
@@ -1,256 +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 "enums.h"
-#include "odintrin.h"
-#include "partition.h"
-#include "zigzag.h"
-
-OD_EXTERN const index_pair *OD_ZIGZAG4[4] = {
- OD_ZIGZAG4_DCT_DCT,
- OD_ZIGZAG4_ADST_DCT,
- OD_ZIGZAG4_DCT_ADST,
- OD_ZIGZAG4_ADST_ADST
-};
-
-OD_EXTERN const index_pair *OD_ZIGZAG8[4] = {
- OD_ZIGZAG8_DCT_DCT,
- OD_ZIGZAG8_ADST_DCT,
- OD_ZIGZAG8_DCT_ADST,
- OD_ZIGZAG8_ADST_ADST
-};
-
-OD_EXTERN const index_pair *OD_ZIGZAG16[4] = {
- OD_ZIGZAG16_DCT_DCT,
- OD_ZIGZAG16_ADST_DCT,
- OD_ZIGZAG16_DCT_ADST,
- OD_ZIGZAG16_ADST_ADST
-};
-
-OD_EXTERN const index_pair *OD_ZIGZAG32[4] = {
- OD_ZIGZAG32_DCT_DCT,
- OD_ZIGZAG32_DCT_DCT,
- OD_ZIGZAG32_DCT_DCT,
- OD_ZIGZAG32_DCT_DCT
-};
-
-/* The tables below specify how coefficient blocks are translated to
- and from PVQ partition coding scan order for 4x4, 8x8 and 16x16 */
-
-static const int OD_LAYOUT32_OFFSETS[4] = { 0, 128, 256, 768 };
-const band_layout OD_LAYOUT32 = {
- OD_ZIGZAG32,
- 32,
- 3,
- OD_LAYOUT32_OFFSETS
-};
-
-static const int OD_LAYOUT16_OFFSETS[4] = { 0, 32, 64, 192 };
-const band_layout OD_LAYOUT16 = {
- OD_ZIGZAG16,
- 16,
- 3,
- OD_LAYOUT16_OFFSETS
-};
-
-const int OD_LAYOUT8_OFFSETS[4] = { 0, 8, 16, 48 };
-const band_layout OD_LAYOUT8 = {
- OD_ZIGZAG8,
- 8,
- 3,
- OD_LAYOUT8_OFFSETS
-};
-
-static const int OD_LAYOUT4_OFFSETS[2] = { 0, 15 };
-const band_layout OD_LAYOUT4 = {
- OD_ZIGZAG4,
- 4,
- 1,
- OD_LAYOUT4_OFFSETS
-};
-
-/* First element is the number of bands, followed by the list all the band
- boundaries. */
-static const int OD_BAND_OFFSETS4[] = {1, 1, 16};
-static const int OD_BAND_OFFSETS8[] = {4, 1, 16, 24, 32, 64};
-static const int OD_BAND_OFFSETS16[] = {7, 1, 16, 24, 32, 64, 96, 128, 256};
-static const int OD_BAND_OFFSETS32[] = {10, 1, 16, 24, 32, 64, 96, 128, 256,
- 384, 512, 1024};
-static const int OD_BAND_OFFSETS64[] = {13, 1, 16, 24, 32, 64, 96, 128, 256,
- 384, 512, 1024, 1536, 2048, 4096};
-
-const int *const OD_BAND_OFFSETS[OD_TXSIZES + 1] = {
- OD_BAND_OFFSETS4,
- OD_BAND_OFFSETS8,
- OD_BAND_OFFSETS16,
- OD_BAND_OFFSETS32,
- OD_BAND_OFFSETS64
-};
-
-/** Perform a single stage of conversion from a coefficient block in
- * raster order into coding scan order
- *
- * @param [in] layout scan order specification
- * @param [out] dst destination vector
- * @param [in] src source coefficient block
- * @param [int] int source vector row stride
- */
-static void od_band_from_raster(const band_layout *layout, tran_low_t *dst,
- const tran_low_t *src, int stride, TX_TYPE tx_type) {
- int i;
- int len;
- len = layout->band_offsets[layout->nb_bands];
- for (i = 0; i < len; i++) {
- dst[i] = src[layout->dst_table[tx_type][i][1]*stride + layout->dst_table[tx_type][i][0]];
- }
-}
-
-/** Perform a single stage of conversion from a vector in coding scan
- order back into a coefficient block in raster order
- *
- * @param [in] layout scan order specification
- * @param [out] dst destination coefficient block
- * @param [in] src source vector
- * @param [int] stride destination vector row stride
- */
-static void od_raster_from_band(const band_layout *layout, tran_low_t *dst,
- int stride, TX_TYPE tx_type, const tran_low_t *src) {
- int i;
- int len;
- len = layout->band_offsets[layout->nb_bands];
- for (i = 0; i < len; i++) {
- dst[layout->dst_table[tx_type][i][1]*stride + layout->dst_table[tx_type][i][0]] = src[i];
- }
-}
-
-static const band_layout *const OD_LAYOUTS[] = {&OD_LAYOUT4, &OD_LAYOUT8,
- &OD_LAYOUT16, &OD_LAYOUT32};
-
-/** Converts a coefficient block in raster order into a vector in
- * coding scan order with the PVQ partitions laid out one after
- * another. This works in stages; the 4x4 conversion is applied to
- * the coefficients nearest DC, then the 8x8 applied to the 8x8 block
- * nearest DC that was not already coded by 4x4, then 16x16 following
- * the same pattern.
- *
- * @param [out] dst destination vector
- * @param [in] n block size (along one side)
- * @param [in] ty_type transfrom type
- * @param [in] src source coefficient block
- * @param [in] stride source vector row stride
- */
-void od_raster_to_coding_order(tran_low_t *dst, int n, TX_TYPE ty_type,
- const tran_low_t *src, int stride) {
- int bs;
- /* dst + 1 because DC is not included for 4x4 blocks. */
- od_band_from_raster(OD_LAYOUTS[0], dst + 1, src, stride, ty_type);
- for (bs = 1; bs < OD_TXSIZES; bs++) {
- int size;
- int offset;
- /* Length of block size > 4. */
- size = 1 << (OD_LOG_BSIZE0 + bs);
- /* Offset is the size of the previous block squared. */
- offset = 1 << 2*(OD_LOG_BSIZE0 - 1 + bs);
- if (n >= size) {
- /* 3 16x16 bands come after 3 8x8 bands, which come after 2 4x4 bands. */
- od_band_from_raster(OD_LAYOUTS[bs], dst + offset, src, stride, ty_type);
- }
- }
- dst[0] = src[0];
-}
-
-/** Converts a vector in coding scan order witht he PVQ partitions
- * laid out one after another into a coefficient block in raster
- * order. This works in stages in the reverse order of raster->scan
- * order; the 16x16 conversion is applied to the coefficients that
- * don't appear in an 8x8 block, then the 8x8 applied to the 8x8 block
- * sans the 4x4 block it contains, then 4x4 is converted sans DC.
- *
- * @param [out] dst destination coefficient block
- * @param [in] stride destination vector row stride
- * @param [in] src source vector
- * @param [in] n block size (along one side)
- */
-void od_coding_order_to_raster(tran_low_t *dst, int stride, TX_TYPE ty_type,
- const tran_low_t *src, int n) {
- int bs;
- /* src + 1 because DC is not included for 4x4 blocks. */
- od_raster_from_band(OD_LAYOUTS[0], dst, stride, ty_type, src + 1);
- for (bs = 1; bs < OD_TXSIZES; bs++) {
- int size;
- int offset;
- /* Length of block size > 4 */
- size = 1 << (OD_LOG_BSIZE0 + bs);
- /* Offset is the size of the previous block squared. */
- offset = 1 << 2*(OD_LOG_BSIZE0 - 1 + bs);
- if (n >= size) {
- /* 3 16x16 bands come after 3 8x8 bands, which come after 2 4x4 bands. */
- od_raster_from_band(OD_LAYOUTS[bs], dst, stride, ty_type, src + offset);
- }
- }
- dst[0] = src[0];
-}
-
-/** Perform a single stage of conversion from a coefficient block in
- * raster order into coding scan order
- *
- * @param [in] layout scan order specification
- * @param [out] dst destination vector
- * @param [in] src source coefficient block
- * @param [int] int source vector row stride
- */
-static void od_band_from_raster_16(const band_layout *layout, int16_t *dst,
- const int16_t *src, int stride) {
- int i;
- int len;
- len = layout->band_offsets[layout->nb_bands];
- for (i = 0; i < len; i++) {
- dst[i] = src[layout->dst_table[DCT_DCT][i][1]*stride + layout->dst_table[DCT_DCT][i][0]];
- }
-}
-
-/** Converts a coefficient block in raster order into a vector in
- * coding scan order with the PVQ partitions laid out one after
- * another. This works in stages; the 4x4 conversion is applied to
- * the coefficients nearest DC, then the 8x8 applied to the 8x8 block
- * nearest DC that was not already coded by 4x4, then 16x16 following
- * the same pattern.
- *
- * @param [out] dst destination vector
- * @param [in] n block size (along one side)
- * @param [in] src source coefficient block
- * @param [in] stride source vector row stride
- */
-void od_raster_to_coding_order_16(int16_t *dst, int n, const int16_t *src,
- int stride) {
- int bs;
- /* dst + 1 because DC is not included for 4x4 blocks. */
- od_band_from_raster_16(OD_LAYOUTS[0], dst + 1, src, stride);
- for (bs = 1; bs < OD_TXSIZES; bs++) {
- int size;
- int offset;
- /* Length of block size > 4. */
- size = 1 << (OD_LOG_BSIZE0 + bs);
- /* Offset is the size of the previous block squared. */
- offset = 1 << 2*(OD_LOG_BSIZE0 - 1 + bs);
- if (n >= size) {
- /* 3 16x16 bands come after 3 8x8 bands, which come after 2 4x4 bands. */
- od_band_from_raster_16(OD_LAYOUTS[bs], dst + offset, src, stride);
- }
- }
- dst[0] = src[0];
-}
diff --git a/av1/common/partition.h b/av1/common/partition.h
deleted file mode 100644
index bd308f9..0000000
--- a/av1/common/partition.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(_partition_H)
-# define _partition_H
-
-#include "av1/common/enums.h"
-#include "odintrin.h"
-
-typedef unsigned char index_pair[2];
-
-typedef struct {
- const index_pair **const dst_table;
- int size;
- int nb_bands;
- const int *const band_offsets;
-} band_layout;
-
-extern const int *const OD_BAND_OFFSETS[OD_TXSIZES + 1];
-
-void od_raster_to_coding_order(tran_low_t *dst, int n, TX_TYPE ty_type,
- const tran_low_t *src, int stride);
-
-void od_coding_order_to_raster(tran_low_t *dst, int stride, TX_TYPE ty_type,
- const tran_low_t *src, int n);
-
-void od_raster_to_coding_order_16(int16_t *dst, int n, const int16_t *src,
- int stride);
-
-#endif
diff --git a/av1/common/pvq.c b/av1/common/pvq.c
deleted file mode 100644
index 221c90c..0000000
--- a/av1/common/pvq.c
+++ /dev/null
@@ -1,1007 +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 "odintrin.h"
-#include "partition.h"
-#include "pvq.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* Imported from encode.c in daala */
-/* These are the PVQ equivalent of quantization matrices, except that
- the values are per-band. */
-#define OD_MASKING_DISABLED 0
-#define OD_MASKING_ENABLED 1
-
-const unsigned char OD_LUMA_QM_Q4[2][OD_QM_SIZE] = {
-/* Flat quantization for PSNR. The DC component isn't 16 because the DC
- magnitude compensation is done here for inter (Haar DC doesn't need it).
- Masking disabled: */
- {
- 16, 16,
- 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16
- },
-/* The non-flat AC coefficients compensate for the non-linear scaling caused
- by activity masking. The values are currently hand-tuned so that the rate
- of each band remains roughly constant when enabling activity masking
- on intra.
- Masking enabled: */
- {
- 16, 16,
- 16, 18, 28, 32,
- 16, 14, 20, 20, 28, 32,
- 16, 11, 14, 14, 17, 17, 22, 28
- }
-};
-
-const unsigned char OD_CHROMA_QM_Q4[2][OD_QM_SIZE] = {
-/* Chroma quantization is different because of the reduced lapping.
- FIXME: Use the same matrix as luma for 4:4:4.
- Masking disabled: */
- {
- 16, 16,
- 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16
- },
-/* The AC part is flat for chroma because it has no activity masking.
- Masking enabled: */
- {
- 16, 16,
- 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16
- }
-};
-
-/* No interpolation, always use od_flat_qm_q4, but use a different scale for
- each plane.
- FIXME: Add interpolation and properly tune chroma. */
-const od_qm_entry OD_DEFAULT_QMS[2][2][OD_NPLANES_MAX] = {
- /* Masking disabled */
- { { { 4, 256, OD_LUMA_QM_Q4[OD_MASKING_DISABLED] },
- { 4, 256, OD_CHROMA_QM_Q4[OD_MASKING_DISABLED] },
- { 4, 256, OD_CHROMA_QM_Q4[OD_MASKING_DISABLED] } },
- { { 0, 0, NULL},
- { 0, 0, NULL},
- { 0, 0, NULL} } },
- /* Masking enabled */
- { { { 4, 256, OD_LUMA_QM_Q4[OD_MASKING_ENABLED] },
- { 4, 256, OD_CHROMA_QM_Q4[OD_MASKING_ENABLED] },
- { 4, 256, OD_CHROMA_QM_Q4[OD_MASKING_ENABLED] } },
- { { 0, 0, NULL},
- { 0, 0, NULL},
- { 0, 0, NULL} } }
-};
-
-/* Constants for the beta parameter, which controls how activity masking is
- used.
- beta = 1 / (1 - alpha), so when beta is 1, alpha is 0 and activity
- masking is disabled. When beta is 1.5, activity masking is used. Note that
- activity masking is neither used for 4x4 blocks nor for chroma. */
-#define OD_BETA(b) OD_QCONST32(b, OD_BETA_SHIFT)
-static const od_val16 OD_PVQ_BETA4_LUMA[1] = {OD_BETA(1.)};
-static const od_val16 OD_PVQ_BETA8_LUMA[4] = {OD_BETA(1.), OD_BETA(1.),
- OD_BETA(1.), OD_BETA(1.)};
-static const od_val16 OD_PVQ_BETA16_LUMA[7] = {OD_BETA(1.), OD_BETA(1.),
- OD_BETA(1.), OD_BETA(1.), OD_BETA(1.), OD_BETA(1.), OD_BETA(1.)};
-static const od_val16 OD_PVQ_BETA32_LUMA[10] = {OD_BETA(1.), OD_BETA(1.),
- OD_BETA(1.), OD_BETA(1.), OD_BETA(1.), OD_BETA(1.), OD_BETA(1.), OD_BETA(1.),
- OD_BETA(1.), OD_BETA(1.)};
-
-static const od_val16 OD_PVQ_BETA4_LUMA_MASKING[1] = {OD_BETA(1.)};
-static const od_val16 OD_PVQ_BETA8_LUMA_MASKING[4] = {OD_BETA(1.5),
- OD_BETA(1.5), OD_BETA(1.5), OD_BETA(1.5)};
-static const od_val16 OD_PVQ_BETA16_LUMA_MASKING[7] = {OD_BETA(1.5),
- OD_BETA(1.5), OD_BETA(1.5), OD_BETA(1.5), OD_BETA(1.5), OD_BETA(1.5),
- OD_BETA(1.5)};
-static const od_val16 OD_PVQ_BETA32_LUMA_MASKING[10] = {OD_BETA(1.5),
- OD_BETA(1.5), OD_BETA(1.5), OD_BETA(1.5), OD_BETA(1.5), OD_BETA(1.5),
- OD_BETA(1.5), OD_BETA(1.5), OD_BETA(1.5), OD_BETA(1.5)};
-
-static const od_val16 OD_PVQ_BETA4_CHROMA[1] = {OD_BETA(1.)};
-static const od_val16 OD_PVQ_BETA8_CHROMA[4] = {OD_BETA(1.), OD_BETA(1.),
- OD_BETA(1.), OD_BETA(1.)};
-static const od_val16 OD_PVQ_BETA16_CHROMA[7] = {OD_BETA(1.), OD_BETA(1.),
- OD_BETA(1.), OD_BETA(1.), OD_BETA(1.), OD_BETA(1.), OD_BETA(1.)};
-static const od_val16 OD_PVQ_BETA32_CHROMA[10] = {OD_BETA(1.), OD_BETA(1.),
- OD_BETA(1.), OD_BETA(1.), OD_BETA(1.), OD_BETA(1.), OD_BETA(1.), OD_BETA(1.),
- OD_BETA(1.), OD_BETA(1.)};
-
-const od_val16 *const OD_PVQ_BETA[2][OD_NPLANES_MAX][OD_TXSIZES + 1] = {
- {{OD_PVQ_BETA4_LUMA, OD_PVQ_BETA8_LUMA,
- OD_PVQ_BETA16_LUMA, OD_PVQ_BETA32_LUMA},
- {OD_PVQ_BETA4_CHROMA, OD_PVQ_BETA8_CHROMA,
- OD_PVQ_BETA16_CHROMA, OD_PVQ_BETA32_CHROMA},
- {OD_PVQ_BETA4_CHROMA, OD_PVQ_BETA8_CHROMA,
- OD_PVQ_BETA16_CHROMA, OD_PVQ_BETA32_CHROMA}},
- {{OD_PVQ_BETA4_LUMA_MASKING, OD_PVQ_BETA8_LUMA_MASKING,
- OD_PVQ_BETA16_LUMA_MASKING, OD_PVQ_BETA32_LUMA_MASKING},
- {OD_PVQ_BETA4_CHROMA, OD_PVQ_BETA8_CHROMA,
- OD_PVQ_BETA16_CHROMA, OD_PVQ_BETA32_CHROMA},
- {OD_PVQ_BETA4_CHROMA, OD_PVQ_BETA8_CHROMA,
- OD_PVQ_BETA16_CHROMA, OD_PVQ_BETA32_CHROMA}}
-};
-
-
-void od_interp_qm(unsigned char *out, int q, const od_qm_entry *entry1,
- const od_qm_entry *entry2) {
- int i;
- if (entry2 == NULL || entry2->qm_q4 == NULL
- || q < entry1->interp_q << OD_COEFF_SHIFT) {
- /* Use entry1. */
- for (i = 0; i < OD_QM_SIZE; i++) {
- out[i] = OD_MINI(255, entry1->qm_q4[i]*entry1->scale_q8 >> 8);
- }
- }
- else if (entry1 == NULL || entry1->qm_q4 == NULL
- || q > entry2->interp_q << OD_COEFF_SHIFT) {
- /* Use entry2. */
- for (i = 0; i < OD_QM_SIZE; i++) {
- out[i] = OD_MINI(255, entry2->qm_q4[i]*entry2->scale_q8 >> 8);
- }
- }
- else {
- /* Interpolate between entry1 and entry2. The interpolation is linear
- in terms of log(q) vs log(m*scale). Considering that we're ultimately
- multiplying the result it makes sense, but we haven't tried other
- interpolation methods. */
- double x;
- const unsigned char *m1;
- const unsigned char *m2;
- int q1;
- int q2;
- m1 = entry1->qm_q4;
- m2 = entry2->qm_q4;
- q1 = entry1->interp_q << OD_COEFF_SHIFT;
- q2 = entry2->interp_q << OD_COEFF_SHIFT;
- x = (log(q)-log(q1))/(log(q2)-log(q1));
- for (i = 0; i < OD_QM_SIZE; i++) {
- out[i] = OD_MINI(255, (int)floor(.5 + (1./256)*exp(
- x*log(m2[i]*entry2->scale_q8) + (1 - x)*log(m1[i]*entry1->scale_q8))));
- }
- }
-}
-
-void od_adapt_pvq_ctx_reset(od_pvq_adapt_ctx *state, int is_keyframe) {
- od_pvq_codeword_ctx *ctx;
- int i;
- int pli;
- int bs;
- ctx = &state->pvq_codeword_ctx;
- OD_CDFS_INIT_DYNAMIC(state->pvq_param_model[0].cdf);
- OD_CDFS_INIT_DYNAMIC(state->pvq_param_model[1].cdf);
- OD_CDFS_INIT_DYNAMIC(state->pvq_param_model[2].cdf);
- for (i = 0; i < 2*OD_TXSIZES; i++) {
- ctx->pvq_adapt[4*i + OD_ADAPT_K_Q8] = 384;
- ctx->pvq_adapt[4*i + OD_ADAPT_SUM_EX_Q8] = 256;
- ctx->pvq_adapt[4*i + OD_ADAPT_COUNT_Q8] = 104;
- ctx->pvq_adapt[4*i + OD_ADAPT_COUNT_EX_Q8] = 128;
- }
- OD_CDFS_INIT_DYNAMIC(ctx->pvq_k1_cdf);
- for (pli = 0; pli < OD_NPLANES_MAX; pli++) {
- for (bs = 0; bs < OD_TXSIZES; bs++)
- for (i = 0; i < PVQ_MAX_PARTITIONS; i++) {
- state->pvq_exg[pli][bs][i] = 2 << 16;
- }
- }
- for (i = 0; i < OD_TXSIZES*PVQ_MAX_PARTITIONS; i++) {
- state->pvq_ext[i] = is_keyframe ? 24576 : 2 << 16;
- }
- OD_CDFS_INIT_DYNAMIC(state->pvq_gaintheta_cdf);
- OD_CDFS_INIT_Q15(state->pvq_skip_dir_cdf);
- OD_CDFS_INIT_DYNAMIC(ctx->pvq_split_cdf);
-}
-
-/* QMs are arranged from smallest to largest blocksizes, first for
- blocks with decimation=0, followed by blocks with decimation=1.*/
-int od_qm_offset(int bs, int xydec)
-{
- return xydec*OD_QM_STRIDE + OD_QM_OFFSET(bs);
-}
-
-#if defined(OD_FLOAT_PVQ)
-#define OD_DEFAULT_MAG 1.0
-#else
-#define OD_DEFAULT_MAG OD_QM_SCALE
-#endif
-
-/* Initialize the quantization matrix. */
-// Note: When hybrid transform and corresponding scan order is used by PVQ,
-// we don't need seperate qm and qm_inv for each transform type,
-// because AOM does not do magnitude compensation (i.e. simplay x16 for all coeffs).
-void od_init_qm(int16_t *x, int16_t *x_inv, const int *qm) {
- int i;
- int j;
- int16_t y[OD_TXSIZE_MAX*OD_TXSIZE_MAX];
- int16_t y_inv[OD_TXSIZE_MAX*OD_TXSIZE_MAX];
- int16_t *x1;
- int16_t *x1_inv;
- int off;
- int bs;
- int xydec;
- for (bs = 0; bs < OD_TXSIZES; bs++) {
- for (xydec = 0; xydec < 2; xydec++) {
- off = od_qm_offset(bs, xydec);
- x1 = x + off;
- x1_inv = x_inv + off;
- for (i = 0; i < 4 << bs; i++) {
- for (j = 0; j < 4 << bs; j++) {
- /*This will ultimately be clamped to fit in 16 bits.*/
- od_val32 mag;
- int16_t ytmp;
- mag = OD_DEFAULT_MAG;
- if (i != 0 || j != 0) {
-#if defined(OD_FLOAT_PVQ)
- mag /= 0.0625*qm[(i << 1 >> bs)*8 + (j << 1 >> bs)];
-#else
- int qmv;
- qmv = qm[(i << 1 >> bs)*8 + (j << 1 >> bs)];
- mag *= 16;
- mag = (mag + (qmv >> 1))/qmv;
-#endif
- OD_ASSERT(mag > 0.0);
- }
- /*Convert to fit in 16 bits.*/
-#if defined(OD_FLOAT_PVQ)
- y[i*(4 << bs) + j] = (int16_t)OD_MINI(OD_QM_SCALE_MAX,
- (int32_t)floor(.5 + mag*OD_QM_SCALE));
- y_inv[i*(4 << bs) + j] = (int16_t)floor(.5
- + OD_QM_SCALE*OD_QM_INV_SCALE/(double)y[i*(4 << bs) + j]);
-#else
- y[i*(4 << bs) + j] = (int16_t)OD_MINI(OD_QM_SCALE_MAX, mag);
- ytmp = y[i*(4 << bs) + j];
- y_inv[i*(4 << bs) + j] = (int16_t)((OD_QM_SCALE*OD_QM_INV_SCALE
- + (ytmp >> 1))/ytmp);
-#endif
- }
- }
- od_raster_to_coding_order_16(x1, 4 << bs, y, 4 << bs);
- od_raster_to_coding_order_16(x1_inv, 4 << bs, y_inv, 4 << bs);
- }
- }
-}
-
-/* Maps each possible size (n) in the split k-tokenizer to a different value.
- Possible values of n are:
- 2, 3, 4, 7, 8, 14, 15, 16, 31, 32, 63, 64, 127, 128
- Since we don't care about the order (even in the bit-stream) the simplest
- ordering (implemented here) is:
- 14, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64, 127, 128 */
-int od_pvq_size_ctx(int n) {
- int logn;
- int odd;
- logn = OD_ILOG(n - 1);
- odd = n & 1;
- return 2*logn - 1 - odd - 7*(n == 14);
-}
-
-/* Maps a length n to a context for the (k=1, n<=16) coder, with a special
- case when n is the original length (orig_length=1) of the vector (i.e. we
- haven't split it yet). For orig_length=0, we use the same mapping as
- od_pvq_size_ctx() up to n=16. When orig_length=1, we map lengths
- 7, 8, 14, 15 to contexts 8 to 11. */
-int od_pvq_k1_ctx(int n, int orig_length) {
- if (orig_length) return 8 + 2*(n > 8) + (n & 1);
- else return od_pvq_size_ctx(n);
-}
-
-/* Indexing for the packed quantization matrices. */
-int od_qm_get_index(int bs, int band) {
- /* The -band/3 term is due to the fact that we force corresponding horizontal
- and vertical bands to have the same quantization. */
- OD_ASSERT(bs >= 0 && bs < OD_TXSIZES);
- return bs*(bs + 1) + band - band/3;
-}
-
-#if !defined(OD_FLOAT_PVQ)
-/*See celt/mathops.c in Opus and tools/cos_search.c.*/
-static int16_t od_pvq_cos_pi_2(int16_t x)
-{
- int16_t x2;
- x2 = OD_MULT16_16_Q15(x, x);
- return OD_MINI(32767, (1073758164 - x*x + x2*(-7654 + OD_MULT16_16_Q16(x2,
- 16573 + OD_MULT16_16_Q16(-2529, x2)))) >> 15);
-}
-#endif
-
-/*Approximates cos(x) for -pi < x < pi.
- Input is in OD_THETA_SCALE.*/
-od_val16 od_pvq_cos(od_val32 x) {
-#if defined(OD_FLOAT_PVQ)
- return cos(x);
-#else
- /*Wrap x around by masking, since cos is periodic.*/
- x = x & 0x0001ffff;
- if (x > (1 << 16)) {
- x = (1 << 17) - x;
- }
- if (x & 0x00007fff) {
- if (x < (1 << 15)) {
- return od_pvq_cos_pi_2((int16_t)x);
- }
- else {
- return -od_pvq_cos_pi_2((int16_t)(65536 - x));
- }
- }
- else {
- if (x & 0x0000ffff) {
- return 0;
- }
- else if (x & 0x0001ffff) {
- return -32767;
- }
- else {
- return 32767;
- }
- }
-#endif
-}
-
-/*Approximates sin(x) for 0 <= x < pi.
- Input is in OD_THETA_SCALE.*/
-od_val16 od_pvq_sin(od_val32 x) {
-#if defined(OD_FLOAT_PVQ)
- return sin(x);
-#else
- return od_pvq_cos(32768 - x);
-#endif
-}
-
-#if !defined(OD_FLOAT_PVQ)
-/* Computes an upper-bound on the number of bits required to store the L2 norm
- of a vector (excluding sign). */
-int od_vector_log_mag(const od_coeff *x, int n) {
- int i;
- int32_t sum;
- sum = 0;
- for (i = 0; i < n; i++) {
- int16_t tmp;
- tmp = x[i] >> 8;
- sum += tmp*(int32_t)tmp;
- }
- /* We add one full bit (instead of rounding OD_ILOG() up) for safety because
- the >> 8 above causes the sum to be slightly underestimated. */
- return 8 + 1 + OD_ILOG(n + sum)/2;
-}
-#endif
-
-/** Computes Householder reflection that aligns the reference r to the
- * dimension in r with the greatest absolute value. The reflection
- * vector is returned in r.
- *
- * @param [in,out] r reference vector to be reflected, reflection
- * also returned in r
- * @param [in] n number of dimensions in r
- * @param [in] gr gain of reference vector
- * @param [out] sign sign of reflection
- * @return dimension number to which reflection aligns
- **/
-int od_compute_householder(od_val16 *r, int n, od_val32 gr, int *sign,
- int shift) {
- int m;
- int i;
- int s;
- od_val16 maxr;
- OD_UNUSED(shift);
- /* Pick component with largest magnitude. Not strictly
- * necessary, but it helps numerical stability */
- m = 0;
- maxr = 0;
- for (i = 0; i < n; i++) {
- if (OD_ABS(r[i]) > maxr) {
- maxr = OD_ABS(r[i]);
- m = i;
- }
- }
- s = r[m] > 0 ? 1 : -1;
- /* This turns r into a Householder reflection vector that would reflect
- * the original r[] to e_m */
- r[m] += OD_SHR_ROUND(gr*s, shift);
- *sign = s;
- return m;
-}
-
-#if !defined(OD_FLOAT_PVQ)
-#define OD_RCP_INSHIFT 15
-#define OD_RCP_OUTSHIFT 14
-static od_val16 od_rcp(od_val16 x)
-{
- int i;
- od_val16 n;
- od_val16 r;
- i = OD_ILOG(x) - 1;
- /*n is Q15 with range [0,1).*/
- n = OD_VSHR_ROUND(x, i - OD_RCP_INSHIFT) - (1 << OD_RCP_INSHIFT);
- /*Start with a linear approximation:
- r = 1.8823529411764706-0.9411764705882353*n.
- The coefficients and the result are Q14 in the range [15420,30840].*/
- r = 30840 + OD_MULT16_16_Q15(-15420, n);
- /*Perform two Newton iterations:
- r -= r*((r*n)-1.Q15)
- = r*((r*n)+(r-1.Q15)).*/
- r = r - OD_MULT16_16_Q15(r, (OD_MULT16_16_Q15(r, n) + r - 32768));
- /*We subtract an extra 1 in the second iteration to avoid overflow; it also
- neatly compensates for truncation error in the rest of the process.*/
- r = r - (1 + OD_MULT16_16_Q15(r, OD_MULT16_16_Q15(r, n) + r - 32768));
- /*r is now the Q15 solution to 2/(n+1), with a maximum relative error
- of 7.05346E-5, a (relative) RMSE of 2.14418E-5, and a peak absolute
- error of 1.24665/32768.*/
- return OD_VSHR_ROUND(r, i - OD_RCP_OUTSHIFT);
-}
-#endif
-
-/** Applies Householder reflection from compute_householder(). The
- * reflection is its own inverse.
- *
- * @param [out] out reflected vector
- * @param [in] x vector to be reflected
- * @param [in] r reflection
- * @param [in] n number of dimensions in x,r
- */
-void od_apply_householder(od_val16 *out, const od_val16 *x, const od_val16 *r,
- int n) {
- int i;
- od_val32 proj;
- od_val16 proj_1;
- od_val32 l2r;
-#if !defined(OD_FLOAT_PVQ)
- od_val16 proj_norm;
- od_val16 l2r_norm;
- od_val16 rcp;
- int proj_shift;
- int l2r_shift;
- int outshift;
-#endif
- /*FIXME: Can we get l2r and/or l2r_shift from an earlier computation?*/
- l2r = 0;
- for (i = 0; i < n; i++) {
- l2r += OD_MULT16_16(r[i], r[i]);
- }
- /* Apply Householder reflection */
- proj = 0;
- for (i = 0; i < n; i++) {
- proj += OD_MULT16_16(r[i], x[i]);
- }
-#if defined(OD_FLOAT_PVQ)
- proj_1 = proj*2./(1e-100 + l2r);
- for (i = 0; i < n; i++) {
- out[i] = x[i] - r[i]*proj_1;
- }
-#else
- /*l2r_norm is [0.5, 1.0[ in Q15.*/
- l2r_shift = (OD_ILOG(l2r) - 1) - 14;
- l2r_norm = OD_VSHR_ROUND(l2r, l2r_shift);
- rcp = od_rcp(l2r_norm);
- proj_shift = (OD_ILOG(abs(proj)) - 1) - 14;
- /*proj_norm is [0.5, 1.0[ in Q15.*/
- proj_norm = OD_VSHR_ROUND(proj, proj_shift);
- proj_1 = OD_MULT16_16_Q15(proj_norm, rcp);
- /*The proj*2. in the float code becomes -1 in the final outshift.
- The sign of l2r_shift is positive since we're taking the reciprocal of
- l2r_norm and this is a right shift.*/
- outshift = OD_MINI(30, OD_RCP_OUTSHIFT - proj_shift - 1 + l2r_shift);
- if (outshift >= 0) {
- for (i = 0; i < n; i++) {
- int32_t tmp;
- tmp = OD_MULT16_16(r[i], proj_1);
- tmp = OD_SHR_ROUND(tmp, outshift);
- out[i] = x[i] - tmp;
- }
- }
- else {
- /*FIXME: Can we make this case impossible?
- Right now, if r[] is all zeros except for 1, 2, or 3 ones, and
- if x[] is all zeros except for large values at the same position as the
- ones in r[], then we can end up with a shift of -1.*/
- for (i = 0; i < n; i++) {
- int32_t tmp;
- tmp = OD_MULT16_16(r[i], proj_1);
- tmp = OD_SHL(tmp, -outshift);
- out[i] = x[i] - tmp;
- }
- }
-#endif
-}
-
-#if !defined(OD_FLOAT_PVQ)
-static od_val16 od_beta_rcp(od_val16 beta){
- if (beta == OD_BETA(1.))
- return OD_BETA(1.);
- else if (beta == OD_BETA(1.5))
- return OD_BETA(1./1.5);
- else {
- od_val16 rcp_beta;
- /*Shift by 1 less, transposing beta to range [.5, .75] and thus < 32768.*/
- rcp_beta = od_rcp(beta << (OD_RCP_INSHIFT - 1 - OD_BETA_SHIFT));
- return OD_SHR_ROUND(rcp_beta, OD_RCP_OUTSHIFT + 1 - OD_BETA_SHIFT);
- }
-}
-
-#define OD_EXP2_INSHIFT 15
-#define OD_EXP2_FRACSHIFT 15
-#define OD_EXP2_OUTSHIFT 15
-static const int32_t OD_EXP2_C[5] = {32768, 22709, 7913, 1704, 443};
-/*Output is [1.0, 2.0) in Q(OD_EXP2_FRACSHIFT).
- It does not include the integer offset, which is added in od_exp2 after the
- final shift).*/
-static int32_t od_exp2_frac(int32_t x)
-{
- return OD_MULT16_16_Q15(x, (OD_EXP2_C[1] + OD_MULT16_16_Q15(x,
- (OD_EXP2_C[2] + OD_MULT16_16_Q15(x, (OD_EXP2_C[3]
- + OD_MULT16_16_Q15(x, OD_EXP2_C[4])))))));
-}
-
-/** Base-2 exponential approximation (2^x) with Q15 input and output.*/
-static int32_t od_exp2(int32_t x)
-{
- int integer;
- int32_t frac;
- integer = x >> OD_EXP2_INSHIFT;
- if (integer > 14)
- return 0x7f000000;
- else if (integer < -15)
- return 0;
- frac = od_exp2_frac(x - OD_SHL(integer, OD_EXP2_INSHIFT));
- return OD_VSHR_ROUND(OD_EXP2_C[0] + frac, -integer) + 1;
-}
-
-#define OD_LOG2_INSHIFT 15
-#define OD_LOG2_OUTSHIFT 15
-#define OD_LOG2_INSCALE_1 (1./(1 << OD_LOG2_INSHIFT))
-#define OD_LOG2_OUTSCALE (1 << OD_LOG2_OUTSHIFT)
-static int16_t od_log2(int16_t x)
-{
- return x + OD_MULT16_16_Q15(x, (14482 + OD_MULT16_16_Q15(x, (-23234
- + OD_MULT16_16_Q15(x, (13643 + OD_MULT16_16_Q15(x, (-6403
- + OD_MULT16_16_Q15(x, 1515)))))))));
-}
-
-static int32_t od_pow(int32_t x, od_val16 beta)
-{
- int16_t t;
- int xshift;
- int log2_x;
- od_val32 logr;
- /*FIXME: this conditional is to avoid doing log2(0).*/
- if (x == 0)
- return 0;
- log2_x = (OD_ILOG(x) - 1);
- xshift = log2_x - OD_LOG2_INSHIFT;
- /*t should be in range [0.0, 1.0[ in Q(OD_LOG2_INSHIFT).*/
- t = OD_VSHR(x, xshift) - (1 << OD_LOG2_INSHIFT);
- /*log2(g/OD_COMPAND_SCALE) = log2(x) - OD_COMPAND_SHIFT in
- Q(OD_LOG2_OUTSHIFT).*/
- logr = od_log2(t) + (log2_x - OD_COMPAND_SHIFT)*OD_LOG2_OUTSCALE;
- logr = (od_val32)OD_MULT16_32_QBETA(beta, logr);
- return od_exp2(logr);
-}
-#endif
-
-/** Gain companding: raises gain to the power 1/beta for activity masking.
- *
- * @param [in] g real (uncompanded) gain
- * @param [in] q0 uncompanded quality parameter
- * @param [in] beta activity masking beta param (exponent)
- * @return g^(1/beta)
- */
-static od_val32 od_gain_compand(od_val32 g, int q0, od_val16 beta) {
-#if defined(OD_FLOAT_PVQ)
- if (beta == 1) return OD_CGAIN_SCALE*g/(double)q0;
- else {
- return OD_CGAIN_SCALE*OD_COMPAND_SCALE*pow(g*OD_COMPAND_SCALE_1,
- 1./beta)/(double)q0;
- }
-#else
- if (beta == OD_BETA(1)) return (OD_CGAIN_SCALE*g + (q0 >> 1))/q0;
- else {
- int32_t expr;
- expr = od_pow(g, od_beta_rcp(beta));
- expr <<= OD_CGAIN_SHIFT + OD_COMPAND_SHIFT - OD_EXP2_OUTSHIFT;
- return (expr + (q0 >> 1))/q0;
- }
-#endif
-}
-
-#if !defined(OD_FLOAT_PVQ)
-#define OD_SQRT_INSHIFT 16
-#define OD_SQRT_OUTSHIFT 15
-static int16_t od_rsqrt_norm(int16_t x);
-
-static int16_t od_sqrt_norm(int32_t x)
-{
- OD_ASSERT(x < 65536);
- return OD_MINI(OD_SHR_ROUND(x*od_rsqrt_norm(x), OD_SQRT_OUTSHIFT), 32767);
-}
-
-static int16_t od_sqrt(int32_t x, int *sqrt_shift)
-{
- int k;
- int s;
- int32_t t;
- if (x == 0) {
- *sqrt_shift = 0;
- return 0;
- }
- OD_ASSERT(x < (1 << 30));
- k = ((OD_ILOG(x) - 1) >> 1);
- /*t is x in the range [0.25, 1) in QINSHIFT, or x*2^(-s).
- Shift by log2(x) - log2(0.25*(1 << INSHIFT)) to ensure 0.25 lower bound.*/
- s = 2*k - (OD_SQRT_INSHIFT - 2);
- t = OD_VSHR(x, s);
- /*We want to express od_sqrt() in terms of od_sqrt_norm(), which is
- defined as (2^OUTSHIFT)*sqrt(t*(2^-INSHIFT)) with t=x*(2^-s).
- This simplifies to 2^(OUTSHIFT-(INSHIFT/2)-(s/2))*sqrt(x), so the caller
- needs to shift right by OUTSHIFT - INSHIFT/2 - s/2.*/
- *sqrt_shift = OD_SQRT_OUTSHIFT - ((s + OD_SQRT_INSHIFT) >> 1);
- return od_sqrt_norm(t);
-}
-#endif
-
-/** Gain expanding: raises gain to the power beta for activity masking.
- *
- * @param [in] cg companded gain
- * @param [in] q0 uncompanded quality parameter
- * @param [in] beta activity masking beta param (exponent)
- * @return g^beta
- */
-od_val32 od_gain_expand(od_val32 cg0, int q0, od_val16 beta) {
- if (beta == OD_BETA(1)) {
- /*The multiply fits into 28 bits because the expanded gain has a range from
- 0 to 2^20.*/
- return OD_SHR_ROUND(cg0*q0, OD_CGAIN_SHIFT);
- }
- else if (beta == OD_BETA(1.5)) {
-#if defined(OD_FLOAT_PVQ)
- double cg;
- cg = cg0*OD_CGAIN_SCALE_1;
- cg *= q0*OD_COMPAND_SCALE_1;
- return OD_COMPAND_SCALE*cg*sqrt(cg);
-#else
- int32_t irt;
- int64_t tmp;
- int sqrt_inshift;
- int sqrt_outshift;
- /*cg0 is in Q(OD_CGAIN_SHIFT) and we need to divide it by
- 2^OD_COMPAND_SHIFT.*/
- irt = od_sqrt(cg0*q0, &sqrt_outshift);
- sqrt_inshift = (OD_CGAIN_SHIFT + OD_COMPAND_SHIFT) >> 1;
- /*tmp is in Q(OD_CGAIN_SHIFT + OD_COMPAND_SHIFT).*/
- tmp = cg0*q0*(int64_t)irt;
- /*Expanded gain must be in Q(OD_COMPAND_SHIFT), thus OD_COMPAND_SHIFT is
- not included here.*/
- return OD_MAXI(1,
- OD_VSHR_ROUND(tmp, OD_CGAIN_SHIFT + sqrt_outshift + sqrt_inshift));
-#endif
- }
- else {
-#if defined(OD_FLOAT_PVQ)
- /*Expanded gain must be in Q(OD_COMPAND_SHIFT), hence the multiply by
- OD_COMPAND_SCALE.*/
- double cg;
- cg = cg0*OD_CGAIN_SCALE_1;
- return OD_COMPAND_SCALE*pow(cg*q0*OD_COMPAND_SCALE_1, beta);
-#else
- int32_t expr;
- int32_t cg;
- cg = OD_SHR_ROUND(cg0*q0, OD_CGAIN_SHIFT);
- expr = od_pow(cg, beta);
- /*Expanded gain must be in Q(OD_COMPAND_SHIFT), hence the subtraction by
- OD_COMPAND_SHIFT.*/
- return OD_MAXI(1, OD_SHR_ROUND(expr, OD_EXP2_OUTSHIFT - OD_COMPAND_SHIFT));
-#endif
- }
-}
-
-/** Computes the raw and quantized/companded gain of a given input
- * vector
- *
- * @param [in] x vector of input data
- * @param [in] n number of elements in vector x
- * @param [in] q0 quantizer
- * @param [out] g raw gain
- * @param [in] beta activity masking beta param
- * @param [in] bshift shift to be applied to raw gain
- * @return quantized/companded gain
- */
-od_val32 od_pvq_compute_gain(const od_val16 *x, int n, int q0, od_val32 *g,
- od_val16 beta, int bshift) {
- int i;
- od_val32 acc;
-#if !defined(OD_FLOAT_PVQ)
- od_val32 irt;
- int sqrt_shift;
-#else
- OD_UNUSED(bshift);
-#endif
- acc = 0;
- for (i = 0; i < n; i++) {
- acc += x[i]*(od_val32)x[i];
- }
-#if defined(OD_FLOAT_PVQ)
- *g = sqrt(acc);
-#else
- irt = od_sqrt(acc, &sqrt_shift);
- *g = OD_VSHR_ROUND(irt, sqrt_shift - bshift);
-#endif
- /* Normalize gain by quantization step size and apply companding
- (if ACTIVITY != 1). */
- return od_gain_compand(*g, q0, beta);
-}
-
-/** Compute theta quantization range from quantized/companded gain
- *
- * @param [in] qcg quantized companded gain value
- * @param [in] beta activity masking beta param
- * @return max theta value
- */
-int od_pvq_compute_max_theta(od_val32 qcg, od_val16 beta){
- /* Set angular resolution (in ra) to match the encoded gain */
-#if defined(OD_FLOAT_PVQ)
- int ts = (int)floor(.5 + qcg*OD_CGAIN_SCALE_1*M_PI/(2*beta));
-#else
- int ts = OD_SHR_ROUND(qcg*OD_MULT16_16_QBETA(OD_QCONST32(M_PI/2,
- OD_CGAIN_SHIFT), od_beta_rcp(beta)), OD_CGAIN_SHIFT*2);
-#endif
- /* Special case for low gains -- will need to be tuned anyway */
- if (qcg < OD_QCONST32(1.4, OD_CGAIN_SHIFT)) ts = 1;
- return ts;
-}
-
-/** Decode quantized theta value from coded value
- *
- * @param [in] t quantized companded gain value
- * @param [in] max_theta maximum theta value
- * @return decoded theta value
- */
-od_val32 od_pvq_compute_theta(int t, int max_theta) {
- if (max_theta != 0) {
-#if defined(OD_FLOAT_PVQ)
- return OD_MINI(t, max_theta - 1)*.5*M_PI/max_theta;
-#else
- return (OD_MAX_THETA_SCALE*OD_MINI(t, max_theta - 1)
- + (max_theta >> 1))/max_theta;
-#endif
- }
- else return 0;
-}
-
-#define OD_SQRT_TBL_SHIFT (10)
-
-#define OD_ITHETA_SHIFT 15
-/** Compute the number of pulses used for PVQ encoding a vector from
- * available metrics (encode and decode side)
- *
- * @param [in] qcg quantized companded gain value
- * @param [in] itheta quantized PVQ error angle theta
- * @param [in] noref indicates present or lack of reference
- * (prediction)
- * @param [in] n number of elements to be coded
- * @param [in] beta activity masking beta param
- * @return number of pulses to use for coding
- */
-int od_pvq_compute_k(od_val32 qcg, int itheta, int noref, int n,
- od_val16 beta) {
-#if !defined(OD_FLOAT_PVQ)
- /*Lookup table for sqrt(n+3/2) and sqrt(n+2/2) in Q10.
- Real max values are 32792 and 32784, but clamped to stay within 16 bits.
- Update with tools/gen_sqrt_tbl if needed.*/
- static const od_val16 od_sqrt_table[2][13] = {
- {0, 0, 0, 0, 2290, 2985, 4222, 0, 8256, 0, 16416, 0, 32767},
- {0, 0, 0, 0, 2401, 3072, 4284, 0, 8287, 0, 16432, 0, 32767}};
-#endif
- if (noref) {
- if (qcg == 0) return 0;
- if (n == 15 && qcg == OD_CGAIN_SCALE && beta > OD_BETA(1.25)) {
- return 1;
- }
- else {
-#if defined(OD_FLOAT_PVQ)
- return OD_MAXI(1, (int)floor(.5 + (qcg*OD_CGAIN_SCALE_1 - .2)*
- sqrt((n + 3)/2)/beta));
-#else
- od_val16 rt;
- OD_ASSERT(OD_ILOG(n + 1) < 13);
- rt = od_sqrt_table[1][OD_ILOG(n + 1)];
- /*FIXME: get rid of 64-bit mul.*/
- return OD_MAXI(1, OD_SHR_ROUND((int64_t)((qcg
- - (int64_t)OD_QCONST32(.2, OD_CGAIN_SHIFT))*
- OD_MULT16_16_QBETA(od_beta_rcp(beta), rt)), OD_CGAIN_SHIFT
- + OD_SQRT_TBL_SHIFT));
-#endif
- }
- }
- else {
- if (itheta == 0) return 0;
- /* Sets K according to gain and theta, based on the high-rate
- PVQ distortion curves (see PVQ document). Low-rate will have to be
- perceptually tuned anyway. We subtract 0.2 from the radius as an
- approximation for the fact that the coefficients aren't identically
- distributed within a band so at low gain the number of dimensions that
- are likely to have a pulse is less than n. */
-#if defined(OD_FLOAT_PVQ)
- return OD_MAXI(1, (int)floor(.5 + (itheta - .2)*sqrt((n + 2)/2)));
-#else
- od_val16 rt;
- OD_ASSERT(OD_ILOG(n + 1) < 13);
- rt = od_sqrt_table[0][OD_ILOG(n + 1)];
- /*FIXME: get rid of 64-bit mul.*/
- return OD_MAXI(1, OD_VSHR_ROUND(((OD_SHL(itheta, OD_ITHETA_SHIFT)
- - OD_QCONST32(.2, OD_ITHETA_SHIFT)))*(int64_t)rt,
- OD_SQRT_TBL_SHIFT + OD_ITHETA_SHIFT));
-#endif
- }
-}
-
-#if !defined(OD_FLOAT_PVQ)
-#define OD_RSQRT_INSHIFT 16
-#define OD_RSQRT_OUTSHIFT 14
-/** Reciprocal sqrt approximation where the input is in the range [0.25,1) in
- Q16 and the output is in the range (1.0, 2.0] in Q14).
- Error is always within +/1 of round(1/sqrt(t))*/
-static int16_t od_rsqrt_norm(int16_t t)
-{
- int16_t n;
- int32_t r;
- int32_t r2;
- int32_t ry;
- int32_t y;
- int32_t ret;
- /* Range of n is [-16384,32767] ([-0.5,1) in Q15).*/
- n = t - 32768;
- OD_ASSERT(n >= -16384);
- /*Get a rough initial guess for the root.
- The optimal minimax quadratic approximation (using relative error) is
- r = 1.437799046117536+n*(-0.823394375837328+n*0.4096419668459485).
- Coefficients here, and the final result r, are Q14.*/
- r = (23565 + OD_MULT16_16_Q15(n, (-13481 + OD_MULT16_16_Q15(n, 6711))));
- /*We want y = t*r*r-1 in Q15, but t is 32-bit Q16 and r is Q14.
- We can compute the result from n and r using Q15 multiplies with some
- adjustment, carefully done to avoid overflow.*/
- r2 = r*r;
- y = (((r2 >> 15)*n + r2) >> 12) - 131077;
- ry = r*y;
- /*Apply a 2nd-order Householder iteration: r += r*y*(y*0.375-0.5).
- This yields the Q14 reciprocal square root of the Q16 t, with a maximum
- relative error of 1.04956E-4, a (relative) RMSE of 2.80979E-5, and a peak
- absolute error of 2.26591/16384.*/
- ret = r + ((((ry >> 16)*(3*y) >> 3) - ry) >> 18);
- OD_ASSERT(ret >= 16384 && ret < 32768);
- return (int16_t)ret;
-}
-
-static int16_t od_rsqrt(int32_t x, int *rsqrt_shift)
-{
- int k;
- int s;
- int16_t t;
- k = (OD_ILOG(x) - 1) >> 1;
- /*t is x in the range [0.25, 1) in QINSHIFT, or x*2^(-s).
- Shift by log2(x) - log2(0.25*(1 << INSHIFT)) to ensure 0.25 lower bound.*/
- s = 2*k - (OD_RSQRT_INSHIFT - 2);
- t = OD_VSHR(x, s);
- /*We want to express od_rsqrt() in terms of od_rsqrt_norm(), which is
- defined as (2^OUTSHIFT)/sqrt(t*(2^-INSHIFT)) with t=x*(2^-s).
- This simplifies to 2^(OUTSHIFT+(INSHIFT/2)+(s/2))/sqrt(x), so the caller
- needs to shift right by OUTSHIFT + INSHIFT/2 + s/2.*/
- *rsqrt_shift = OD_RSQRT_OUTSHIFT + ((s + OD_RSQRT_INSHIFT) >> 1);
- return od_rsqrt_norm(t);
-}
-#endif
-
-/** Synthesizes one parition of coefficient values from a PVQ-encoded
- * vector. This 'partial' version is called by the encode loop where
- * the Householder reflection has already been computed and there's no
- * need to recompute it.
- *
- * @param [out] xcoeff output coefficient partition (x in math doc)
- * @param [in] ypulse PVQ-encoded values (y in the 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] r reference vector (prediction)
- * @param [in] n number of elements in this partition
- * @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] m alignment dimension of Householder reflection
- * @param [in] s sign of Householder reflection
- * @param [in] qm_inv inverse of the QM with magnitude compensation
- */
-void od_pvq_synthesis_partial(od_coeff *xcoeff, const od_coeff *ypulse,
- const od_val16 *r16, int n, int noref, od_val32 g, od_val32 theta, int m, int s,
- const int16_t *qm_inv) {
- int i;
- int yy;
- od_val32 scale;
- int nn;
-#if !defined(OD_FLOAT_PVQ)
- int gshift;
- int qshift;
-#endif
- OD_ASSERT(g != 0);
- nn = n-(!noref); /* when noref==0, vector in is sized n-1 */
- yy = 0;
- for (i = 0; i < nn; i++)
- yy += ypulse[i]*(int32_t)ypulse[i];
-#if !defined(OD_FLOAT_PVQ)
- /* Shift required for the magnitude of the pre-qm synthesis to be guaranteed
- to fit in 16 bits. In practice, the range will be 8192-16384 after scaling
- most of the time. */
- gshift = OD_MAXI(0, OD_ILOG(g) - 14);
-#endif
- /*scale is g/sqrt(yy) in Q(16-gshift) so that x[]*scale has a norm that fits
- in 16 bits.*/
- if (yy == 0) scale = 0;
-#if defined(OD_FLOAT_PVQ)
- else {
- scale = g/sqrt(yy);
- }
-#else
- else {
- int rsqrt_shift;
- int16_t rsqrt;
- /*FIXME: should be < int64_t*/
- int64_t tmp;
- rsqrt = od_rsqrt(yy, &rsqrt_shift);
- tmp = rsqrt*(int64_t)g;
- scale = OD_VSHR_ROUND(tmp, rsqrt_shift + gshift - 16);
- }
- /* Shift to apply after multiplying by the inverse QM, taking into account
- gshift. */
- qshift = OD_QM_INV_SHIFT - gshift;
-#endif
- if (noref) {
- for (i = 0; i < n; i++) {
- od_val32 x;
- /* This multiply doesn't round, so it introduces some bias.
- It would be nice (but not critical) to fix this. */
- x = (od_val32)OD_MULT16_32_Q16(ypulse[i], scale);
-#if defined(OD_FLOAT_PVQ)
- xcoeff[i] = (od_coeff)floor(.5
- + x*(qm_inv[i]*OD_QM_INV_SCALE_1));
-#else
- xcoeff[i] = OD_SHR_ROUND(x*qm_inv[i], qshift);
-#endif
- }
- }
- else{
- od_val16 x[MAXN];
- scale = OD_ROUND32(scale*OD_TRIG_SCALE_1*od_pvq_sin(theta));
- /* The following multiply doesn't round, but it's probably OK since
- the Householder reflection is likely to undo most of the resulting
- bias. */
- for (i = 0; i < m; i++)
- x[i] = OD_MULT16_32_Q16(ypulse[i], scale);
- x[m] = OD_ROUND16(-s*(OD_SHR_ROUND(g, gshift))*OD_TRIG_SCALE_1*
- od_pvq_cos(theta));
- for (i = m; i < nn; i++)
- x[i+1] = OD_MULT16_32_Q16(ypulse[i], scale);
- od_apply_householder(x, x, r16, n);
- for (i = 0; i < n; i++) {
-#if defined(OD_FLOAT_PVQ)
- xcoeff[i] = (od_coeff)floor(.5 + (x[i]*(qm_inv[i]*OD_QM_INV_SCALE_1)));
-#else
- xcoeff[i] = OD_SHR_ROUND(x[i]*qm_inv[i], qshift);
-#endif
- }
- }
-}
diff --git a/av1/common/pvq.h b/av1/common/pvq.h
deleted file mode 100644
index 4adf22f..0000000
--- a/av1/common/pvq.h
+++ /dev/null
@@ -1,179 +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_H)
-# define _pvq_H (1)
-# include "generic_code.h"
-# include "odintrin.h"
-
-extern const uint16_t EXP_CDF_TABLE[][16];
-extern const uint16_t LAPLACE_OFFSET[];
-
-#define AV1_PVQ_ENABLE_ACTIVITY_MASKING (0)
-
-# define PVQ_MAX_PARTITIONS (1 + 3*(OD_TXSIZES-1))
-
-# define OD_NOREF_ADAPT_SPEED (4)
-/* Normalized lambda for PVQ quantizer. Since we normalize the gain by q, the
- distortion is normalized by q^2 and lambda does not need the q^2 factor.
- At high rate, this would be log(2)/6, but we're using a slightly more
- aggressive value, closer to:
- Li, Xiang, et al. "Laplace distribution based Lagrangian rate distortion
- optimization for hybrid video coding." Circuits and Systems for Video
- Technology, IEEE Transactions on 19.2 (2009): 193-205.
- */
-# define OD_PVQ_LAMBDA (.1146)
-
-#define OD_PVQ_SKIP_ZERO 1
-#define OD_PVQ_SKIP_COPY 2
-
-/* Maximum size for coding a PVQ band. */
-#define OD_MAX_PVQ_SIZE (1024)
-
-#if defined(OD_FLOAT_PVQ)
-#define OD_QM_SHIFT (15)
-#else
-#define OD_QM_SHIFT (11)
-#endif
-#define OD_QM_SCALE (1 << OD_QM_SHIFT)
-#if defined(OD_FLOAT_PVQ)
-#define OD_QM_SCALE_1 (1./OD_QM_SCALE)
-#endif
-#define OD_QM_SCALE_MAX 32767
-#define OD_QM_INV_SHIFT (12)
-#define OD_QM_INV_SCALE (1 << OD_QM_INV_SHIFT)
-#if defined(OD_FLOAT_PVQ)
-#define OD_QM_INV_SCALE_1 (1./OD_QM_INV_SCALE)
-#endif
-#define OD_QM_OFFSET(bs) ((((1 << 2*bs) - 1) << 2*OD_LOG_BSIZE0)/3)
-#define OD_QM_STRIDE (OD_QM_OFFSET(OD_TXSIZES))
-#define OD_QM_BUFFER_SIZE (2*OD_QM_STRIDE)
-
-#if !defined(OD_FLOAT_PVQ)
-#define OD_THETA_SHIFT (15)
-#define OD_THETA_SCALE ((1 << OD_THETA_SHIFT)*2./M_PI)
-#define OD_MAX_THETA_SCALE (1 << OD_THETA_SHIFT)
-#define OD_TRIG_SCALE (32768)
-#define OD_BETA_SHIFT (12)
-#define OD_BETA_SCALE_1 (1./(1 << OD_BETA_SHIFT))
-/*Multiplies 16-bit a by 32-bit b and keeps bits [16:64-OD_BETA_SHIFT-1].*/
-#define OD_MULT16_32_QBETA(a, b) \
- ((int16_t)(a)*(int64_t)(int32_t)(b) >> OD_BETA_SHIFT)
-# define OD_MULT16_16_QBETA(a, b) \
- ((((int16_t)(a))*((int32_t)(int16_t)(b))) >> OD_BETA_SHIFT)
-#define OD_CGAIN_SHIFT (8)
-#define OD_CGAIN_SCALE (1 << OD_CGAIN_SHIFT)
-#else
-#define OD_BETA_SCALE_1 (1.)
-#define OD_THETA_SCALE (1)
-#define OD_TRIG_SCALE (1)
-#define OD_CGAIN_SCALE (1)
-#endif
-#define OD_THETA_SCALE_1 (1./OD_THETA_SCALE)
-#define OD_TRIG_SCALE_1 (1./OD_TRIG_SCALE)
-#define OD_CGAIN_SCALE_1 (1./OD_CGAIN_SCALE)
-#define OD_CGAIN_SCALE_2 (OD_CGAIN_SCALE_1*OD_CGAIN_SCALE_1)
-
-/* Largest PVQ partition is half the coefficients of largest block size. */
-#define MAXN (OD_TXSIZE_MAX*OD_TXSIZE_MAX/2)
-
-#define OD_COMPAND_SHIFT (8 + OD_COEFF_SHIFT)
-#define OD_COMPAND_SCALE (1 << OD_COMPAND_SHIFT)
-#define OD_COMPAND_SCALE_1 (1./OD_COMPAND_SCALE)
-
-#define OD_QM_SIZE (OD_TXSIZES*(OD_TXSIZES + 1))
-
-#define OD_FLAT_QM 0
-#define OD_HVS_QM 1
-
-# define OD_NSB_ADAPT_CTXS (4)
-
-# define OD_ADAPT_K_Q8 0
-# define OD_ADAPT_SUM_EX_Q8 1
-# define OD_ADAPT_COUNT_Q8 2
-# define OD_ADAPT_COUNT_EX_Q8 3
-
-# define OD_ADAPT_NO_VALUE (-2147483647-1)
-
-typedef enum {
- PVQ_SKIP = 0x0,
- DC_CODED = 0x1,
- AC_CODED = 0x2,
- AC_DC_CODED = 0x3,
-} PVQ_SKIP_TYPE;
-
-typedef struct od_pvq_adapt_ctx od_pvq_adapt_ctx;
-typedef struct od_pvq_codeword_ctx od_pvq_codeword_ctx;
-
-struct od_pvq_codeword_ctx {
- int pvq_adapt[2*OD_TXSIZES*OD_NSB_ADAPT_CTXS];
- /* CDFs are size 16 despite the fact that we're using less than that. */
- uint16_t pvq_k1_cdf[12][CDF_SIZE(16)];
- uint16_t pvq_split_cdf[22*7][CDF_SIZE(8)];
-};
-
-struct od_pvq_adapt_ctx {
- od_pvq_codeword_ctx pvq_codeword_ctx;
- generic_encoder pvq_param_model[3];
- int pvq_ext[OD_TXSIZES*PVQ_MAX_PARTITIONS];
- int pvq_exg[OD_NPLANES_MAX][OD_TXSIZES][PVQ_MAX_PARTITIONS];
- uint16_t pvq_gaintheta_cdf[2*OD_TXSIZES*PVQ_MAX_PARTITIONS][CDF_SIZE(16)];
- uint16_t pvq_skip_dir_cdf[2*(OD_TXSIZES-1)][CDF_SIZE(7)];
-};
-
-typedef struct od_qm_entry {
- int interp_q;
- int scale_q8;
- const unsigned char *qm_q4;
-} od_qm_entry;
-
-extern const od_qm_entry OD_DEFAULT_QMS[2][2][OD_NPLANES_MAX];
-
-void od_adapt_pvq_ctx_reset(od_pvq_adapt_ctx *state, int is_keyframe);
-int od_pvq_size_ctx(int n);
-int od_pvq_k1_ctx(int n, int orig_size);
-
-od_val16 od_pvq_sin(od_val32 x);
-od_val16 od_pvq_cos(od_val32 x);
-#if !defined(OD_FLOAT_PVQ)
-int od_vector_log_mag(const od_coeff *x, int n);
-#endif
-
-void od_interp_qm(unsigned char *out, int q, const od_qm_entry *entry1,
- const od_qm_entry *entry2);
-
-int od_qm_get_index(int bs, int band);
-
-extern const od_val16 *const OD_PVQ_BETA[2][OD_NPLANES_MAX][OD_TXSIZES + 1];
-
-void od_init_qm(int16_t *x, int16_t *x_inv, const int *qm);
-int od_compute_householder(od_val16 *r, int n, od_val32 gr, int *sign,
- int shift);
-void od_apply_householder(od_val16 *out, const od_val16 *x, const od_val16 *r,
- int n);
-void od_pvq_synthesis_partial(od_coeff *xcoeff, const od_coeff *ypulse,
- const od_val16 *r, int n,
- int noref, od_val32 g,
- od_val32 theta, int m, int s,
- const int16_t *qm_inv);
-od_val32 od_gain_expand(od_val32 cg, int q0, od_val16 beta);
-od_val32 od_pvq_compute_gain(const od_val16 *x, int n, int q0, od_val32 *g,
- od_val16 beta, int bshift);
-int od_pvq_compute_max_theta(od_val32 qcg, od_val16 beta);
-od_val32 od_pvq_compute_theta(int t, int max_theta);
-int od_pvq_compute_k(od_val32 qcg, int itheta, int noref, int n, od_val16 beta);
-
-int od_vector_is_null(const od_coeff *x, int len);
-int od_qm_offset(int bs, int xydec);
-
-#endif
diff --git a/av1/common/pvq_state.c b/av1/common/pvq_state.c
deleted file mode 100644
index 197b9b3..0000000
--- a/av1/common/pvq_state.c
+++ /dev/null
@@ -1,50 +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.
- */
-
-#include "av1/common/pvq_state.h"
-#include "av1/common/odintrin.h"
-
-void od_adapt_ctx_reset(od_adapt_ctx *adapt, int is_keyframe) {
- int pli;
- od_adapt_pvq_ctx_reset(&adapt->pvq, is_keyframe);
- OD_CDFS_INIT_Q15(adapt->skip_cdf);
- for (pli = 0; pli < OD_NPLANES_MAX; pli++) {
- int i;
- OD_CDFS_INIT_DYNAMIC(adapt->model_dc[pli].cdf);
- for (i = 0; i < OD_TXSIZES; i++) {
- int j;
- adapt->ex_g[pli][i] = 8;
- for (j = 0; j < 3; j++) {
- adapt->ex_dc[pli][i][j] = pli > 0 ? 8 : 32768;
- }
- }
- }
-}
-
-void od_init_skipped_coeffs(int16_t *d, int16_t *pred, int is_keyframe, int bo,
- int n, int w) {
- int i;
- int j;
- if (is_keyframe) {
- for (i = 0; i < n; i++) {
- for (j = 0; j < n; j++) {
- /* skip DC */
- if (i || j) d[bo + i * w + j] = 0;
- }
- }
- } else {
- for (i = 0; i < n; i++) {
- for (j = 0; j < n; j++) {
- d[bo + i * w + j] = pred[i * n + j];
- }
- }
- }
-}
diff --git a/av1/common/pvq_state.h b/av1/common/pvq_state.h
deleted file mode 100644
index 84d454e..0000000
--- a/av1/common/pvq_state.h
+++ /dev/null
@@ -1,52 +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(_state_H)
-# define _state_H (1)
-
-typedef struct od_state od_state;
-typedef struct od_adapt_ctx od_adapt_ctx;
-
-# include "generic_code.h"
-# include "odintrin.h"
-# include "pvq.h"
-
-/*Adaptation speed of scalar Laplace encoding.*/
-# define OD_SCALAR_ADAPT_SPEED (4)
-
-struct od_adapt_ctx {
- /* Support for PVQ encode/decode */
- od_pvq_adapt_ctx pvq;
-
- generic_encoder model_dc[OD_NPLANES_MAX];
-
- int ex_dc[OD_NPLANES_MAX][OD_TXSIZES][3];
- int ex_g[OD_NPLANES_MAX][OD_TXSIZES];
-
- /* Joint skip flag for DC and AC */
- uint16_t skip_cdf[OD_TXSIZES*2][CDF_SIZE(4)];
-};
-
-struct od_state {
- od_adapt_ctx *adapt;
- unsigned char pvq_qm_q4[OD_NPLANES_MAX][OD_QM_SIZE];
- /* Quantization matrices and their inverses. */
- int16_t qm[OD_QM_BUFFER_SIZE];
- int16_t qm_inv[OD_QM_BUFFER_SIZE];
-};
-
-void od_adapt_ctx_reset(od_adapt_ctx *state, int is_keyframe);
-void od_init_skipped_coeffs(int16_t *d, int16_t *pred, int is_keyframe,
- int bo, int n, int w);
-
-#endif
diff --git a/av1/common/quant_common.c b/av1/common/quant_common.c
index a278ce8..1b0af4c 100644
--- a/av1/common/quant_common.c
+++ b/av1/common/quant_common.c
@@ -13785,62 +13785,3 @@
},
};
#endif
-
-#if CONFIG_PVQ
-/* Quantization matrices for 8x8. For other block sizes, we currently just do
- resampling. */
-/* Flat quantization, i.e. optimize for PSNR. */
-const int OD_QM8_Q4_FLAT[] = { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16 };
-#if 0
-/* M1: MPEG2 matrix for inter (which has a dead zone). */
-const int OD_QM8_Q4[] = {
- 16, 17, 18, 19, 20, 21, 22, 23,
- 17, 18, 19, 20, 21, 22, 23, 24,
- 18, 19, 20, 21, 22, 23, 24, 25,
- 19, 20, 21, 22, 23, 24, 26, 27,
- 20, 21, 22, 23, 25, 26, 27, 28,
- 21, 22, 23, 24, 26, 27, 28, 30,
- 22, 23, 24, 26, 27, 28, 30, 31,
- 23, 24, 25, 27, 28, 30, 31, 33};
-#endif
-#if 0
-/* M2: MPEG2 matrix for intra (no dead zone). */
-const int OD_QM8_Q4[] = {
- 16, 16, 19, 22, 22, 26, 26, 27,
- 16, 16, 22, 22, 26, 27, 27, 29,
- 19, 22, 26, 26, 27, 29, 29, 35,
- 22, 24, 27, 27, 29, 32, 34, 38,
- 26, 27, 29, 29, 32, 35, 38, 46,
- 27, 29, 34, 34, 35, 40, 46, 56,
- 29, 34, 34, 37, 40, 48, 56, 69,
- 34, 37, 38, 40, 48, 58, 69, 83
-};
-#endif
-#if 0
-/* M3: Taken from dump_psnrhvs. */
-const int OD_QM8_Q4[] = {
- 16, 16, 17, 20, 24, 29, 36, 42,
- 16, 17, 17, 19, 22, 26, 31, 37,
- 17, 17, 21, 23, 26, 30, 34, 40,
- 20, 19, 23, 28, 31, 35, 39, 45,
- 24, 22, 26, 31, 36, 41, 46, 51,
- 29, 26, 30, 35, 41, 47, 52, 58,
- 36, 31, 34, 39, 46, 52, 59, 66,
- 42, 37, 40, 45, 51, 58, 66, 73
-};
-#endif
-#if 1
-/* M4: a compromise equal to .5*(M3 + .5*(M2+transpose(M2))) */
-const int OD_QM8_Q4_HVS[] = { 16, 16, 18, 21, 24, 28, 32, 36, 16, 17, 20,
- 21, 24, 27, 31, 35, 18, 20, 24, 25, 27, 31,
- 33, 38, 21, 21, 25, 28, 30, 34, 37, 42, 24,
- 24, 27, 30, 34, 38, 43, 49, 28, 27, 31, 34,
- 38, 44, 50, 58, 32, 31, 33, 37, 43, 50, 58,
- 68, 36, 35, 38, 42, 49, 58, 68, 78 };
-#endif
-#endif
diff --git a/av1/common/quant_common.h b/av1/common/quant_common.h
index 92843fe..3e2e9b3 100644
--- a/av1/common/quant_common.h
+++ b/av1/common/quant_common.h
@@ -97,11 +97,6 @@
}
#endif // CONFIG_NEW_QUANT
-#if CONFIG_PVQ
-extern const int OD_QM8_Q4_FLAT[];
-extern const int OD_QM8_Q4_HVS[];
-#endif
-
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/av1/common/x86/pvq_sse4.c b/av1/common/x86/pvq_sse4.c
deleted file mode 100644
index b3ed9ef..0000000
--- a/av1/common/x86/pvq_sse4.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (c) 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.
- */
-
-#include <smmintrin.h>
-#include <emmintrin.h>
-#include <tmmintrin.h>
-#include <float.h>
-
-#include "./av1_rtcd.h"
-#include "av1/common/x86/pvq_sse4.h"
-#include "../odintrin.h"
-#include "av1/common/pvq.h"
-
-#define EPSILON 1e-15f
-
-static __m128 horizontal_sum_ps(__m128 x) {
- x = _mm_add_ps(x, _mm_shuffle_ps(x, x, _MM_SHUFFLE(1, 0, 3, 2)));
- x = _mm_add_ps(x, _mm_shuffle_ps(x, x, _MM_SHUFFLE(2, 3, 0, 1)));
- return x;
-}
-
-static __m128i horizontal_sum_epi32(__m128i x) {
- x = _mm_add_epi32(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
- x = _mm_add_epi32(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(2, 3, 0, 1)));
- return x;
-}
-
-static INLINE float rsqrtf(float x) {
- float y;
- _mm_store_ss(&y, _mm_rsqrt_ss(_mm_load_ss(&x)));
- return y;
-}
-
-/** Find the codepoint on the given PSphere closest to the desired
- * vector. This is a float-precision PVQ search just to make sure
- * our tests aren't limited by numerical accuracy. It's close to the
- * pvq_search_rdo_double_c implementation, but is not bit accurate and
- * it performs slightly worse on PSNR. One reason is that this code runs
- * more RDO iterations than the C code. It also uses single precision
- * floating point math, whereas the C version uses double precision.
- *
- * @param [in] xcoeff input vector to quantize (x in the math doc)
- * @param [in] n number of dimensions
- * @param [in] k number of pulses
- * @param [out] ypulse optimal codevector found (y in the math doc)
- * @param [in] g2 multiplier for the distortion (typically squared
- * gain units)
- * @param [in] pvq_norm_lambda enc->pvq_norm_lambda for quantized RDO
- * @param [in] prev_k number of pulses already in ypulse that we should
- * reuse for the search (or 0 for a new search)
- * @return cosine distance between x and y (between 0 and 1)
- */
-double pvq_search_rdo_double_sse4_1(const od_val16 *xcoeff, int n, int k,
- int *ypulse, double g2,
- double pvq_norm_lambda, int prev_k) {
- int i, j;
- int reuse_pulses = prev_k > 0 && prev_k <= k;
- /* TODO - This blows our 8kB stack space budget and should be fixed when
- converting PVQ to fixed point. */
- float xx = 0, xy = 0, yy = 0;
- float x[MAXN + 3];
- float y[MAXN + 3];
- float sign_y[MAXN + 3];
- for (i = 0; i < n; i++) {
- float tmp = (float)xcoeff[i];
- xx += tmp * tmp;
- x[i] = xcoeff[i];
- }
-
- x[n] = x[n + 1] = x[n + 2] = 0;
- ypulse[n] = ypulse[n + 1] = ypulse[n + 2] = 0;
-
- __m128 sums = _mm_setzero_ps();
- for (i = 0; i < n; i += 4) {
- __m128 x4 = _mm_loadu_ps(&x[i]);
- __m128 s4 = _mm_cmplt_ps(x4, _mm_setzero_ps());
- /* Save the sign, we'll put it back later. */
- _mm_storeu_ps(&sign_y[i], s4);
- /* Get rid of the sign. */
- x4 = _mm_andnot_ps(_mm_set_ps1(-0.f), x4);
- sums = _mm_add_ps(sums, x4);
- if (!reuse_pulses) {
- /* Clear y and ypulse in case we don't do the projection. */
- _mm_storeu_ps(&y[i], _mm_setzero_ps());
- _mm_storeu_si128((__m128i *)&ypulse[i], _mm_setzero_si128());
- }
- _mm_storeu_ps(&x[i], x4);
- }
- sums = horizontal_sum_ps(sums);
- int pulses_left = k;
- {
- __m128i pulses_sum;
- __m128 yy4, xy4;
- xy4 = yy4 = _mm_setzero_ps();
- pulses_sum = _mm_setzero_si128();
- if (reuse_pulses) {
- /* We reuse pulses from a previous search so we don't have to search them
- again. */
- for (j = 0; j < n; j += 4) {
- __m128 x4, y4;
- __m128i iy4;
- iy4 = _mm_abs_epi32(_mm_loadu_si128((__m128i *)&ypulse[j]));
- pulses_sum = _mm_add_epi32(pulses_sum, iy4);
- _mm_storeu_si128((__m128i *)&ypulse[j], iy4);
- y4 = _mm_cvtepi32_ps(iy4);
- x4 = _mm_loadu_ps(&x[j]);
- xy4 = _mm_add_ps(xy4, _mm_mul_ps(x4, y4));
- yy4 = _mm_add_ps(yy4, _mm_mul_ps(y4, y4));
- /* Double the y[] vector so we don't have to do it in the search loop.
- */
- _mm_storeu_ps(&y[j], _mm_add_ps(y4, y4));
- }
- pulses_left -= _mm_cvtsi128_si32(horizontal_sum_epi32(pulses_sum));
- xy4 = horizontal_sum_ps(xy4);
- xy = _mm_cvtss_f32(xy4);
- yy4 = horizontal_sum_ps(yy4);
- yy = _mm_cvtss_f32(yy4);
- } else if (k > (n >> 1)) {
- /* Do a pre-search by projecting on the pyramid. */
- __m128 rcp4;
- float sum = _mm_cvtss_f32(sums);
- /* If x is too small, just replace it with a pulse at 0. This prevents
- infinities and NaNs from causing too many pulses to be allocated. Here,
- 64 is an
- approximation of infinity. */
- if (sum <= EPSILON) {
- x[0] = 1.f;
- for (i = 1; i < n; i++) {
- x[i] = 0;
- }
- sums = _mm_set_ps1(1.f);
- }
- /* Using k + e with e < 1 guarantees we cannot get more than k pulses. */
- rcp4 = _mm_mul_ps(_mm_set_ps1((float)k + .8f), _mm_rcp_ps(sums));
- xy4 = yy4 = _mm_setzero_ps();
- pulses_sum = _mm_setzero_si128();
- for (j = 0; j < n; j += 4) {
- __m128 rx4, x4, y4;
- __m128i iy4;
- x4 = _mm_loadu_ps(&x[j]);
- rx4 = _mm_mul_ps(x4, rcp4);
- iy4 = _mm_cvttps_epi32(rx4);
- pulses_sum = _mm_add_epi32(pulses_sum, iy4);
- _mm_storeu_si128((__m128i *)&ypulse[j], iy4);
- y4 = _mm_cvtepi32_ps(iy4);
- xy4 = _mm_add_ps(xy4, _mm_mul_ps(x4, y4));
- yy4 = _mm_add_ps(yy4, _mm_mul_ps(y4, y4));
- /* Double the y[] vector so we don't have to do it in the search loop.
- */
- _mm_storeu_ps(&y[j], _mm_add_ps(y4, y4));
- }
- pulses_left -= _mm_cvtsi128_si32(horizontal_sum_epi32(pulses_sum));
- xy = _mm_cvtss_f32(horizontal_sum_ps(xy4));
- yy = _mm_cvtss_f32(horizontal_sum_ps(yy4));
- }
- x[n] = x[n + 1] = x[n + 2] = -100;
- y[n] = y[n + 1] = y[n + 2] = 100;
- }
-
- /* This should never happen. */
- OD_ASSERT(pulses_left <= n + 3);
-
- float lambda_delta_rate[MAXN + 3];
- if (pulses_left) {
- /* Hoist lambda to avoid the multiply in the loop. */
- float lambda =
- 0.5f * sqrtf(xx) * (float)pvq_norm_lambda / (FLT_MIN + (float)g2);
- float delta_rate = 3.f / n;
- __m128 count = _mm_set_ps(3, 2, 1, 0);
- for (i = 0; i < n; i += 4) {
- _mm_storeu_ps(&lambda_delta_rate[i],
- _mm_mul_ps(count, _mm_set_ps1(lambda * delta_rate)));
- count = _mm_add_ps(count, _mm_set_ps(4, 4, 4, 4));
- }
- }
- lambda_delta_rate[n] = lambda_delta_rate[n + 1] = lambda_delta_rate[n + 2] =
- 1e30f;
-
- for (i = 0; i < pulses_left; i++) {
- int best_id = 0;
- __m128 xy4, yy4;
- __m128 max, max2;
- __m128i count;
- __m128i pos;
-
- /* The squared magnitude term gets added anyway, so we might as well
- add it outside the loop. */
- yy = yy + 1;
- xy4 = _mm_load1_ps(&xy);
- yy4 = _mm_load1_ps(&yy);
- max = _mm_setzero_ps();
- pos = _mm_setzero_si128();
- count = _mm_set_epi32(3, 2, 1, 0);
- for (j = 0; j < n; j += 4) {
- __m128 x4, y4, r4;
- x4 = _mm_loadu_ps(&x[j]);
- y4 = _mm_loadu_ps(&y[j]);
- x4 = _mm_add_ps(x4, xy4);
- y4 = _mm_add_ps(y4, yy4);
- y4 = _mm_rsqrt_ps(y4);
- r4 = _mm_mul_ps(x4, y4);
- /* Subtract lambda. */
- r4 = _mm_sub_ps(r4, _mm_loadu_ps(&lambda_delta_rate[j]));
- /* Update the index of the max. */
- pos = _mm_max_epi16(
- pos, _mm_and_si128(count, _mm_castps_si128(_mm_cmpgt_ps(r4, max))));
- /* Update the max. */
- max = _mm_max_ps(max, r4);
- /* Update the indices (+4) */
- count = _mm_add_epi32(count, _mm_set_epi32(4, 4, 4, 4));
- }
- /* Horizontal max. */
- max2 = _mm_max_ps(max, _mm_shuffle_ps(max, max, _MM_SHUFFLE(1, 0, 3, 2)));
- max2 =
- _mm_max_ps(max2, _mm_shuffle_ps(max2, max2, _MM_SHUFFLE(2, 3, 0, 1)));
- /* Now that max2 contains the max at all positions, look at which value(s)
- of the
- partial max is equal to the global max. */
- pos = _mm_and_si128(pos, _mm_castps_si128(_mm_cmpeq_ps(max, max2)));
- pos = _mm_max_epi16(pos, _mm_unpackhi_epi64(pos, pos));
- pos = _mm_max_epi16(pos, _mm_shufflelo_epi16(pos, _MM_SHUFFLE(1, 0, 3, 2)));
- best_id = _mm_cvtsi128_si32(pos);
- OD_ASSERT(best_id < n);
- /* Updating the sums of the new pulse(s) */
- xy = xy + x[best_id];
- /* We're multiplying y[j] by two so we don't have to do it here. */
- yy = yy + y[best_id];
- /* Only now that we've made the final choice, update y/ypulse. */
- /* Multiplying y[j] by 2 so we don't have to do it everywhere else. */
- y[best_id] += 2;
- ypulse[best_id]++;
- }
-
- /* Put the original sign back. */
- for (i = 0; i < n; i += 4) {
- __m128i y4;
- __m128i s4;
- y4 = _mm_loadu_si128((__m128i *)&ypulse[i]);
- s4 = _mm_castps_si128(_mm_loadu_ps(&sign_y[i]));
- y4 = _mm_xor_si128(_mm_add_epi32(y4, s4), s4);
- _mm_storeu_si128((__m128i *)&ypulse[i], y4);
- }
- return xy * rsqrtf(xx * yy + FLT_MIN);
-}
diff --git a/av1/common/x86/pvq_sse4.h b/av1/common/x86/pvq_sse4.h
deleted file mode 100644
index 3c4ce85..0000000
--- a/av1/common/x86/pvq_sse4.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright (c) 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.
- */
-#ifndef AOM_COMMON_PVQ_X86_SSE4_H_
-#define AOM_COMMON_PVQ_X86_SSE4_H_
-#endif // AOM_COMMON_PVQ_X86_SSE4_H_
diff --git a/av1/common/zigzag.h b/av1/common/zigzag.h
deleted file mode 100644
index c58b18b..0000000
--- a/av1/common/zigzag.h
+++ /dev/null
@@ -1,33 +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(_zigzag_H)
-# define _zigzag_H (1)
-
-extern const unsigned char OD_ZIGZAG4_DCT_DCT[15][2];
-extern const unsigned char OD_ZIGZAG4_ADST_DCT[15][2];
-extern const unsigned char OD_ZIGZAG4_DCT_ADST[15][2];
-#define OD_ZIGZAG4_ADST_ADST OD_ZIGZAG4_DCT_DCT
-
-extern const unsigned char OD_ZIGZAG8_DCT_DCT[48][2];
-extern const unsigned char OD_ZIGZAG8_ADST_DCT[48][2];
-extern const unsigned char OD_ZIGZAG8_DCT_ADST[48][2];
-#define OD_ZIGZAG8_ADST_ADST OD_ZIGZAG8_DCT_DCT
-
-extern const unsigned char OD_ZIGZAG16_DCT_DCT[192][2];
-extern const unsigned char OD_ZIGZAG16_ADST_DCT[192][2];
-extern const unsigned char OD_ZIGZAG16_DCT_ADST[192][2];
-#define OD_ZIGZAG16_ADST_ADST OD_ZIGZAG16_DCT_DCT
-
-extern const unsigned char OD_ZIGZAG32_DCT_DCT[768][2];
-#endif
diff --git a/av1/common/zigzag16.c b/av1/common/zigzag16.c
deleted file mode 100644
index 6df6e38..0000000
--- a/av1/common/zigzag16.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/* This file is generated by gen_zigzag16.m */
-
-/* clang-format off */
-
-#include "odintrin.h"
-OD_EXTERN const unsigned char OD_ZIGZAG16_DCT_DCT[192][2] = {
- {8, 0}, {8, 1}, {8, 2}, {9, 0},
- {8, 3}, {9, 1}, {9, 2}, {10, 0},
- {9, 3}, {10, 1}, {10, 2}, {11, 0},
- {10, 3}, {11, 1}, {11, 2}, {11, 3},
- {12, 0}, {12, 1}, {13, 0}, {12, 2},
- {12, 3}, {13, 1}, {13, 2}, {14, 0},
- {13, 3}, {14, 1}, {15, 0}, {14, 2},
- {14, 3}, {15, 1}, {15, 2}, {15, 3},
- {0, 8}, {1, 8}, {0, 9}, {2, 8},
- {1, 9}, {3, 8}, {0, 10}, {2, 9},
- {1, 10}, {3, 9}, {0, 11}, {2, 10},
- {1, 11}, {3, 10}, {0, 12}, {2, 11},
- {1, 12}, {3, 11}, {0, 13}, {2, 12},
- {1, 13}, {0, 14}, {3, 12}, {2, 13},
- {1, 14}, {3, 13}, {0, 15}, {2, 14},
- {1, 15}, {3, 14}, {2, 15}, {3, 15},
- {4, 8}, {5, 8}, {4, 9}, {8, 4},
- {8, 5}, {6, 8}, {5, 9}, {4, 10},
- {9, 4}, {8, 6}, {7, 8}, {9, 5},
- {5, 10}, {8, 7}, {6, 9}, {4, 11},
- {10, 4}, {9, 6}, {7, 9}, {8, 8},
- {10, 5}, {6, 10}, {5, 11}, {9, 7},
- {8, 9}, {10, 6}, {7, 10}, {4, 12},
- {11, 4}, {9, 8}, {6, 11}, {10, 7},
- {11, 5}, {5, 12}, {8, 10}, {7, 11},
- {9, 9}, {4, 13}, {10, 8}, {11, 6},
- {11, 7}, {6, 12}, {8, 11}, {9, 10},
- {12, 4}, {5, 13}, {10, 9}, {12, 5},
- {7, 12}, {11, 8}, {4, 14}, {6, 13},
- {10, 10}, {9, 11}, {12, 6}, {13, 4},
- {11, 9}, {8, 12}, {5, 14}, {12, 7},
- {7, 13}, {4, 15}, {13, 5}, {10, 11},
- {11, 10}, {9, 12}, {13, 6}, {12, 8},
- {6, 14}, {8, 13}, {5, 15}, {13, 7},
- {14, 4}, {12, 9}, {7, 14}, {11, 11},
- {10, 12}, {9, 13}, {14, 5}, {6, 15},
- {13, 8}, {8, 14}, {12, 10}, {14, 6},
- {7, 15}, {13, 9}, {15, 4}, {10, 13},
- {11, 12}, {14, 7}, {9, 14}, {12, 11},
- {8, 15}, {15, 5}, {13, 10}, {14, 8},
- {11, 13}, {15, 6}, {9, 15}, {10, 14},
- {14, 9}, {15, 7}, {13, 11}, {12, 12},
- {10, 15}, {11, 14}, {15, 8}, {14, 10},
- {12, 13}, {13, 12}, {15, 9}, {11, 15},
- {14, 11}, {13, 13}, {15, 10}, {12, 14},
- {13, 14}, {15, 11}, {14, 12}, {12, 15},
- {14, 13}, {13, 15}, {15, 12}, {14, 14},
- {15, 13}, {14, 15}, {15, 14}, {15, 15}
- };
-
-OD_EXTERN const unsigned char OD_ZIGZAG16_ADST_DCT[192][2] = {
- {8, 0}, {9, 0}, {10, 0}, {8, 1},
- {11, 0}, {9, 1}, {8, 2}, {12, 0},
- {10, 1}, {9, 2}, {8, 3}, {13, 0},
- {11, 1}, {10, 2}, {9, 3}, {14, 0},
- {12, 1}, {10, 3}, {15, 0}, {11, 2},
- {13, 1}, {11, 3}, {12, 2}, {14, 1},
- {12, 3}, {13, 2}, {15, 1}, {13, 3},
- {14, 2}, {14, 3}, {15, 2}, {15, 3},
- {0, 8}, {1, 8}, {2, 8}, {0, 9},
- {3, 8}, {1, 9}, {2, 9}, {0, 10},
- {3, 9}, {1, 10}, {2, 10}, {0, 11},
- {3, 10}, {1, 11}, {2, 11}, {0, 12},
- {3, 11}, {1, 12}, {2, 12}, {0, 13},
- {3, 12}, {1, 13}, {0, 14}, {2, 13},
- {0, 15}, {1, 14}, {3, 13}, {2, 14},
- {1, 15}, {3, 14}, {2, 15}, {3, 15},
- {8, 4}, {9, 4}, {8, 5}, {4, 8},
- {10, 4}, {9, 5}, {5, 8}, {8, 6},
- {4, 9}, {10, 5}, {9, 6}, {6, 8},
- {8, 7}, {11, 4}, {7, 8}, {5, 9},
- {9, 7}, {11, 5}, {10, 6}, {4, 10},
- {6, 9}, {8, 8}, {5, 10}, {7, 9},
- {12, 4}, {10, 7}, {9, 8}, {11, 6},
- {8, 9}, {4, 11}, {6, 10}, {7, 10},
- {12, 5}, {5, 11}, {10, 8}, {11, 7},
- {9, 9}, {4, 12}, {13, 4}, {8, 10},
- {6, 11}, {12, 6}, {5, 12}, {10, 9},
- {7, 11}, {9, 10}, {11, 8}, {13, 5},
- {8, 11}, {4, 13}, {6, 12}, {10, 10},
- {12, 7}, {11, 9}, {7, 12}, {14, 4},
- {5, 13}, {9, 11}, {13, 6}, {8, 12},
- {4, 14}, {12, 8}, {6, 13}, {11, 10},
- {10, 11}, {12, 9}, {5, 14}, {13, 7},
- {14, 5}, {9, 12}, {4, 15}, {7, 13},
- {8, 13}, {6, 14}, {13, 8}, {11, 11},
- {10, 12}, {15, 4}, {12, 10}, {14, 6},
- {13, 9}, {5, 15}, {9, 13}, {7, 14},
- {15, 5}, {6, 15}, {8, 14}, {14, 7},
- {11, 12}, {7, 15}, {9, 14}, {13, 10},
- {10, 13}, {14, 8}, {15, 6}, {14, 9},
- {12, 11}, {8, 15}, {15, 7}, {10, 14},
- {11, 13}, {9, 15}, {13, 11}, {12, 12},
- {15, 8}, {14, 10}, {15, 9}, {10, 15},
- {11, 14}, {13, 12}, {12, 13}, {15, 10},
- {14, 11}, {11, 15}, {13, 13}, {15, 11},
- {14, 12}, {12, 14}, {15, 12}, {13, 14},
- {12, 15}, {14, 13}, {13, 15}, {15, 13},
- {14, 14}, {15, 14}, {14, 15}, {15, 15}
- };
-
-OD_EXTERN const unsigned char OD_ZIGZAG16_DCT_ADST[192][2] = {
- {8, 0}, {8, 1}, {8, 2}, {8, 3},
- {9, 0}, {9, 1}, {9, 2}, {9, 3},
- {10, 0}, {10, 1}, {10, 2}, {10, 3},
- {11, 0}, {11, 1}, {11, 2}, {11, 3},
- {12, 0}, {12, 1}, {12, 2}, {12, 3},
- {13, 0}, {13, 1}, {13, 2}, {13, 3},
- {14, 0}, {15, 0}, {14, 1}, {14, 2},
- {14, 3}, {15, 1}, {15, 2}, {15, 3},
- {0, 8}, {0, 9}, {0, 10}, {1, 8},
- {0, 11}, {1, 9}, {2, 8}, {0, 12},
- {1, 10}, {2, 9}, {0, 13}, {1, 11},
- {3, 8}, {2, 10}, {0, 14}, {1, 12},
- {3, 9}, {0, 15}, {2, 11}, {3, 10},
- {1, 13}, {2, 12}, {3, 11}, {1, 14},
- {2, 13}, {1, 15}, {3, 12}, {2, 14},
- {3, 13}, {2, 15}, {3, 14}, {3, 15},
- {4, 8}, {4, 9}, {5, 8}, {4, 10},
- {5, 9}, {4, 11}, {6, 8}, {5, 10},
- {8, 4}, {6, 9}, {4, 12}, {5, 11},
- {8, 5}, {6, 10}, {7, 8}, {8, 6},
- {4, 13}, {7, 9}, {5, 12}, {8, 7},
- {9, 4}, {6, 11}, {8, 8}, {7, 10},
- {5, 13}, {9, 5}, {4, 14}, {9, 6},
- {8, 9}, {6, 12}, {9, 7}, {7, 11},
- {4, 15}, {8, 10}, {9, 8}, {5, 14},
- {10, 4}, {6, 13}, {10, 5}, {9, 9},
- {7, 12}, {8, 11}, {10, 6}, {5, 15},
- {10, 7}, {6, 14}, {9, 10}, {7, 13},
- {8, 12}, {10, 8}, {9, 11}, {6, 15},
- {11, 4}, {11, 5}, {10, 9}, {8, 13},
- {7, 14}, {11, 6}, {9, 12}, {11, 7},
- {10, 10}, {7, 15}, {8, 14}, {12, 4},
- {11, 8}, {12, 5}, {9, 13}, {10, 11},
- {8, 15}, {11, 9}, {12, 6}, {12, 7},
- {10, 12}, {9, 14}, {11, 10}, {13, 4},
- {12, 8}, {9, 15}, {13, 5}, {11, 11},
- {12, 9}, {10, 13}, {13, 6}, {13, 7},
- {12, 10}, {14, 4}, {11, 12}, {13, 8},
- {10, 14}, {14, 5}, {12, 11}, {13, 9},
- {14, 6}, {10, 15}, {11, 13}, {15, 4},
- {14, 7}, {12, 12}, {13, 10}, {14, 8},
- {15, 5}, {13, 11}, {15, 6}, {11, 14},
- {14, 9}, {12, 13}, {11, 15}, {15, 7},
- {14, 10}, {15, 8}, {13, 12}, {12, 14},
- {15, 9}, {14, 11}, {13, 13}, {12, 15},
- {15, 10}, {14, 12}, {13, 14}, {15, 11},
- {13, 15}, {14, 13}, {14, 14}, {15, 12},
- {14, 15}, {15, 13}, {15, 14}, {15, 15}
- };
diff --git a/av1/common/zigzag32.c b/av1/common/zigzag32.c
deleted file mode 100644
index cb3b9bc..0000000
--- a/av1/common/zigzag32.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/* This file is generated by gen_zigzag32.m */
-
-/* clang-format off */
-
-#include "odintrin.h"
-OD_EXTERN const unsigned char OD_ZIGZAG32_DCT_DCT[768][2] = {
- { 16, 0 }, { 17, 0 }, { 18, 0 }, { 19, 0 },
- { 16, 1 }, { 17, 1 }, { 20, 0 }, { 16, 2 },
- { 18, 1 }, { 21, 0 }, { 17, 2 }, { 16, 3 },
- { 19, 1 }, { 22, 0 }, { 18, 2 }, { 17, 3 },
- { 20, 1 }, { 16, 4 }, { 23, 0 }, { 19, 2 },
- { 24, 0 }, { 16, 5 }, { 21, 1 }, { 17, 4 },
- { 18, 3 }, { 20, 2 }, { 17, 5 }, { 16, 6 },
- { 19, 3 }, { 18, 4 }, { 25, 0 }, { 22, 1 },
- { 16, 7 }, { 21, 2 }, { 17, 6 }, { 20, 3 },
- { 26, 0 }, { 18, 5 }, { 19, 4 }, { 17, 7 },
- { 23, 1 }, { 22, 2 }, { 18, 6 }, { 27, 0 },
- { 19, 5 }, { 24, 1 }, { 21, 3 }, { 28, 0 },
- { 20, 4 }, { 18, 7 }, { 19, 6 }, { 23, 2 },
- { 29, 0 }, { 25, 1 }, { 21, 4 }, { 30, 0 },
- { 20, 5 }, { 22, 3 }, { 31, 0 }, { 19, 7 },
- { 24, 2 }, { 26, 1 }, { 20, 6 }, { 21, 5 },
- { 22, 4 }, { 23, 3 }, { 27, 1 }, { 25, 2 },
- { 20, 7 }, { 28, 1 }, { 24, 3 }, { 21, 6 },
- { 22, 5 }, { 23, 4 }, { 26, 2 }, { 21, 7 },
- { 29, 1 }, { 25, 3 }, { 30, 1 }, { 27, 2 },
- { 22, 6 }, { 23, 5 }, { 31, 1 }, { 24, 4 },
- { 26, 3 }, { 28, 2 }, { 22, 7 }, { 23, 6 },
- { 25, 4 }, { 24, 5 }, { 29, 2 }, { 30, 2 },
- { 27, 3 }, { 23, 7 }, { 31, 2 }, { 24, 6 },
- { 26, 4 }, { 25, 5 }, { 28, 3 }, { 24, 7 },
- { 27, 4 }, { 29, 3 }, { 25, 6 }, { 26, 5 },
- { 30, 3 }, { 31, 3 }, { 28, 4 }, { 27, 5 },
- { 25, 7 }, { 29, 4 }, { 26, 6 }, { 28, 5 },
- { 30, 4 }, { 26, 7 }, { 27, 6 }, { 31, 4 },
- { 29, 5 }, { 27, 7 }, { 30, 5 }, { 28, 6 },
- { 31, 5 }, { 29, 6 }, { 28, 7 }, { 30, 6 },
- { 31, 6 }, { 29, 7 }, { 30, 7 }, { 31, 7 },
- { 0, 16 }, { 0, 17 }, { 1, 16 }, { 0, 18 },
- { 1, 17 }, { 0, 19 }, { 2, 16 }, { 1, 18 },
- { 0, 20 }, { 2, 17 }, { 3, 16 }, { 1, 19 },
- { 2, 18 }, { 0, 21 }, { 3, 17 }, { 4, 16 },
- { 1, 20 }, { 2, 19 }, { 0, 22 }, { 3, 18 },
- { 4, 17 }, { 5, 16 }, { 0, 23 }, { 3, 19 },
- { 2, 20 }, { 1, 21 }, { 4, 18 }, { 6, 16 },
- { 5, 17 }, { 3, 20 }, { 2, 21 }, { 1, 22 },
- { 0, 24 }, { 0, 25 }, { 4, 19 }, { 7, 16 },
- { 6, 17 }, { 5, 18 }, { 0, 26 }, { 3, 21 },
- { 2, 22 }, { 1, 23 }, { 4, 20 }, { 5, 19 },
- { 6, 18 }, { 1, 24 }, { 7, 17 }, { 0, 27 },
- { 2, 23 }, { 3, 22 }, { 4, 21 }, { 1, 25 },
- { 5, 20 }, { 7, 18 }, { 0, 28 }, { 6, 19 },
- { 2, 24 }, { 1, 26 }, { 0, 29 }, { 4, 22 },
- { 3, 23 }, { 2, 25 }, { 5, 21 }, { 0, 31 },
- { 7, 19 }, { 6, 20 }, { 0, 30 }, { 1, 27 },
- { 3, 24 }, { 2, 26 }, { 4, 23 }, { 5, 22 },
- { 7, 20 }, { 1, 28 }, { 6, 21 }, { 3, 25 },
- { 2, 27 }, { 1, 29 }, { 4, 24 }, { 2, 28 },
- { 1, 30 }, { 7, 21 }, { 5, 23 }, { 3, 26 },
- { 6, 22 }, { 1, 31 }, { 4, 25 }, { 7, 22 },
- { 3, 27 }, { 2, 29 }, { 2, 30 }, { 5, 24 },
- { 2, 31 }, { 6, 23 }, { 4, 26 }, { 3, 28 },
- { 5, 25 }, { 3, 29 }, { 6, 24 }, { 7, 23 },
- { 3, 30 }, { 4, 27 }, { 3, 31 }, { 5, 26 },
- { 6, 25 }, { 4, 28 }, { 7, 24 }, { 4, 29 },
- { 5, 27 }, { 4, 30 }, { 4, 31 }, { 6, 26 },
- { 5, 28 }, { 7, 25 }, { 6, 27 }, { 5, 29 },
- { 7, 26 }, { 5, 30 }, { 5, 31 }, { 6, 28 },
- { 7, 27 }, { 6, 29 }, { 6, 30 }, { 7, 28 },
- { 6, 31 }, { 7, 29 }, { 7, 30 }, { 7, 31 },
- { 8, 16 }, { 9, 16 }, { 8, 17 }, { 10, 16 },
- { 9, 17 }, { 16, 8 }, { 8, 18 }, { 16, 9 },
- { 10, 17 }, { 11, 16 }, { 17, 8 }, { 9, 18 },
- { 8, 19 }, { 16, 10 }, { 11, 17 }, { 12, 16 },
- { 10, 18 }, { 17, 9 }, { 9, 19 }, { 16, 11 },
- { 8, 20 }, { 18, 8 }, { 17, 10 }, { 10, 19 },
- { 12, 17 }, { 11, 18 }, { 9, 20 }, { 16, 12 },
- { 18, 9 }, { 8, 21 }, { 13, 16 }, { 17, 11 },
- { 19, 8 }, { 18, 10 }, { 13, 17 }, { 16, 13 },
- { 11, 19 }, { 12, 18 }, { 10, 20 }, { 17, 12 },
- { 9, 21 }, { 19, 9 }, { 8, 22 }, { 14, 16 },
- { 18, 11 }, { 11, 20 }, { 10, 21 }, { 20, 8 },
- { 13, 18 }, { 16, 14 }, { 12, 19 }, { 17, 13 },
- { 19, 10 }, { 14, 17 }, { 9, 22 }, { 18, 12 },
- { 8, 23 }, { 17, 14 }, { 20, 9 }, { 15, 16 },
- { 16, 15 }, { 13, 19 }, { 10, 22 }, { 19, 11 },
- { 11, 21 }, { 14, 18 }, { 12, 20 }, { 18, 13 },
- { 20, 10 }, { 21, 8 }, { 15, 17 }, { 9, 23 },
- { 19, 12 }, { 11, 22 }, { 8, 24 }, { 21, 9 },
- { 17, 15 }, { 16, 16 }, { 14, 19 }, { 18, 14 },
- { 12, 21 }, { 13, 20 }, { 20, 11 }, { 10, 23 },
- { 19, 13 }, { 15, 18 }, { 16, 17 }, { 21, 10 },
- { 22, 8 }, { 9, 24 }, { 8, 25 }, { 20, 12 },
- { 15, 19 }, { 11, 23 }, { 17, 16 }, { 18, 15 },
- { 14, 20 }, { 12, 22 }, { 10, 24 }, { 22, 9 },
- { 21, 11 }, { 19, 14 }, { 13, 21 }, { 16, 18 },
- { 9, 25 }, { 17, 17 }, { 8, 26 }, { 20, 13 },
- { 23, 8 }, { 12, 23 }, { 13, 22 }, { 22, 10 },
- { 19, 15 }, { 15, 20 }, { 16, 19 }, { 21, 12 },
- { 11, 24 }, { 14, 21 }, { 8, 27 }, { 18, 16 },
- { 10, 25 }, { 9, 26 }, { 22, 11 }, { 20, 14 },
- { 23, 9 }, { 18, 17 }, { 17, 18 }, { 17, 19 },
- { 19, 16 }, { 21, 13 }, { 10, 26 }, { 12, 24 },
- { 23, 10 }, { 24, 8 }, { 8, 28 }, { 16, 20 },
- { 9, 27 }, { 15, 21 }, { 22, 12 }, { 14, 22 },
- { 13, 23 }, { 20, 15 }, { 11, 25 }, { 24, 9 },
- { 18, 18 }, { 19, 17 }, { 23, 11 }, { 10, 27 },
- { 8, 29 }, { 12, 25 }, { 9, 28 }, { 8, 30 },
- { 21, 14 }, { 13, 24 }, { 11, 26 }, { 25, 8 },
- { 24, 10 }, { 20, 16 }, { 19, 18 }, { 14, 23 },
- { 22, 13 }, { 8, 31 }, { 17, 20 }, { 9, 29 },
- { 23, 12 }, { 15, 22 }, { 25, 9 }, { 11, 27 },
- { 10, 28 }, { 20, 17 }, { 21, 15 }, { 18, 19 },
- { 16, 21 }, { 24, 11 }, { 9, 30 }, { 12, 26 },
- { 10, 29 }, { 22, 14 }, { 14, 24 }, { 9, 31 },
- { 26, 8 }, { 13, 25 }, { 25, 10 }, { 18, 20 },
- { 19, 19 }, { 11, 28 }, { 15, 23 }, { 20, 18 },
- { 10, 30 }, { 12, 27 }, { 17, 21 }, { 23, 13 },
- { 24, 12 }, { 21, 16 }, { 16, 22 }, { 26, 9 },
- { 27, 8 }, { 13, 26 }, { 22, 15 }, { 10, 31 },
- { 14, 25 }, { 12, 28 }, { 25, 11 }, { 21, 17 },
- { 26, 10 }, { 20, 19 }, { 11, 29 }, { 15, 24 },
- { 23, 14 }, { 27, 9 }, { 11, 30 }, { 13, 27 },
- { 19, 20 }, { 24, 13 }, { 28, 8 }, { 11, 31 },
- { 22, 16 }, { 17, 22 }, { 16, 23 }, { 25, 12 },
- { 18, 21 }, { 12, 29 }, { 21, 18 }, { 28, 9 },
- { 27, 10 }, { 26, 11 }, { 29, 8 }, { 14, 26 },
- { 15, 25 }, { 13, 28 }, { 12, 30 }, { 23, 15 },
- { 30, 8 }, { 16, 24 }, { 13, 29 }, { 25, 13 },
- { 24, 14 }, { 20, 20 }, { 31, 8 }, { 12, 31 },
- { 14, 27 }, { 28, 10 }, { 26, 12 }, { 22, 17 },
- { 21, 19 }, { 17, 23 }, { 18, 22 }, { 29, 9 },
- { 27, 11 }, { 19, 21 }, { 27, 12 }, { 30, 9 },
- { 31, 9 }, { 13, 30 }, { 24, 15 }, { 23, 16 },
- { 15, 26 }, { 14, 28 }, { 29, 10 }, { 28, 11 },
- { 26, 13 }, { 17, 24 }, { 13, 31 }, { 25, 14 },
- { 22, 18 }, { 16, 25 }, { 30, 10 }, { 14, 29 },
- { 15, 27 }, { 19, 22 }, { 21, 20 }, { 20, 21 },
- { 27, 13 }, { 29, 11 }, { 18, 23 }, { 23, 17 },
- { 16, 26 }, { 31, 10 }, { 24, 16 }, { 14, 30 },
- { 22, 19 }, { 14, 31 }, { 28, 12 }, { 26, 14 },
- { 30, 11 }, { 15, 28 }, { 25, 15 }, { 17, 25 },
- { 23, 18 }, { 18, 24 }, { 15, 30 }, { 29, 12 },
- { 31, 11 }, { 16, 27 }, { 24, 17 }, { 28, 13 },
- { 19, 23 }, { 15, 29 }, { 25, 16 }, { 17, 26 },
- { 27, 14 }, { 22, 20 }, { 15, 31 }, { 20, 22 },
- { 21, 21 }, { 16, 28 }, { 17, 27 }, { 30, 12 },
- { 26, 15 }, { 19, 24 }, { 18, 25 }, { 23, 19 },
- { 29, 13 }, { 31, 12 }, { 24, 18 }, { 26, 16 },
- { 25, 17 }, { 16, 29 }, { 28, 14 }, { 20, 23 },
- { 18, 26 }, { 21, 22 }, { 19, 25 }, { 22, 21 },
- { 27, 15 }, { 17, 28 }, { 16, 30 }, { 26, 17 },
- { 23, 20 }, { 16, 31 }, { 25, 18 }, { 27, 16 },
- { 20, 24 }, { 24, 19 }, { 31, 13 }, { 30, 13 },
- { 29, 14 }, { 18, 27 }, { 28, 15 }, { 17, 29 },
- { 19, 26 }, { 17, 30 }, { 21, 23 }, { 22, 22 },
- { 30, 14 }, { 20, 25 }, { 23, 21 }, { 17, 31 },
- { 18, 28 }, { 25, 19 }, { 24, 20 }, { 28, 16 },
- { 31, 14 }, { 26, 18 }, { 19, 27 }, { 29, 15 },
- { 27, 17 }, { 30, 15 }, { 21, 24 }, { 22, 23 },
- { 26, 19 }, { 23, 22 }, { 28, 17 }, { 29, 16 },
- { 18, 30 }, { 24, 21 }, { 25, 20 }, { 18, 31 },
- { 18, 29 }, { 20, 26 }, { 19, 28 }, { 27, 18 },
- { 31, 15 }, { 20, 27 }, { 30, 16 }, { 19, 29 },
- { 29, 17 }, { 31, 16 }, { 27, 19 }, { 21, 25 },
- { 28, 18 }, { 26, 20 }, { 22, 24 }, { 25, 21 },
- { 19, 30 }, { 24, 22 }, { 30, 17 }, { 21, 26 },
- { 23, 23 }, { 19, 31 }, { 20, 28 }, { 31, 17 },
- { 28, 19 }, { 27, 20 }, { 21, 27 }, { 29, 18 },
- { 30, 18 }, { 25, 22 }, { 26, 21 }, { 20, 29 },
- { 22, 25 }, { 24, 23 }, { 29, 19 }, { 23, 24 },
- { 20, 31 }, { 20, 30 }, { 28, 20 }, { 21, 28 },
- { 22, 26 }, { 31, 18 }, { 27, 21 }, { 30, 19 },
- { 22, 27 }, { 29, 20 }, { 23, 25 }, { 24, 24 },
- { 26, 22 }, { 21, 29 }, { 25, 23 }, { 31, 19 },
- { 21, 30 }, { 23, 26 }, { 28, 21 }, { 21, 31 },
- { 22, 28 }, { 30, 20 }, { 25, 24 }, { 27, 22 },
- { 29, 21 }, { 26, 23 }, { 24, 25 }, { 31, 20 },
- { 23, 27 }, { 22, 29 }, { 30, 21 }, { 28, 22 },
- { 24, 26 }, { 25, 25 }, { 27, 23 }, { 22, 30 },
- { 23, 28 }, { 22, 31 }, { 26, 24 }, { 31, 21 },
- { 24, 27 }, { 29, 22 }, { 27, 24 }, { 30, 22 },
- { 25, 26 }, { 28, 23 }, { 23, 30 }, { 23, 29 },
- { 24, 28 }, { 25, 27 }, { 31, 22 }, { 23, 31 },
- { 26, 25 }, { 28, 24 }, { 29, 23 }, { 24, 29 },
- { 24, 30 }, { 27, 25 }, { 25, 28 }, { 26, 26 },
- { 30, 23 }, { 26, 27 }, { 31, 23 }, { 28, 25 },
- { 27, 26 }, { 25, 29 }, { 24, 31 }, { 29, 24 },
- { 30, 24 }, { 27, 27 }, { 29, 25 }, { 26, 28 },
- { 31, 24 }, { 25, 30 }, { 25, 31 }, { 28, 26 },
- { 27, 28 }, { 26, 29 }, { 30, 25 }, { 29, 26 },
- { 28, 27 }, { 26, 30 }, { 31, 25 }, { 27, 29 },
- { 26, 31 }, { 30, 26 }, { 28, 28 }, { 31, 26 },
- { 29, 27 }, { 27, 30 }, { 28, 29 }, { 27, 31 },
- { 30, 27 }, { 31, 27 }, { 28, 30 }, { 29, 28 },
- { 30, 28 }, { 29, 29 }, { 30, 29 }, { 31, 28 },
- { 28, 31 }, { 29, 30 }, { 29, 31 }, { 31, 29 },
- { 30, 30 }, { 30, 31 }, { 31, 30 }, { 31, 31 }
-};
diff --git a/av1/common/zigzag4.c b/av1/common/zigzag4.c
deleted file mode 100644
index 1fb5a32..0000000
--- a/av1/common/zigzag4.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* This file is generated by gen_zigzag4.m */
-
-/* clang-format off */
-
-#include "odintrin.h"
-OD_EXTERN const unsigned char OD_ZIGZAG4_DCT_DCT[15][2] = {
- {0, 1}, {1, 0}, {1, 1}, {0, 2},
- {2, 0}, {0, 3}, {1, 2}, {3, 0},
- {2, 1}, {1, 3}, {2, 2}, {3, 1},
- {2, 3}, {3, 2}, {3, 3} };
-
-OD_EXTERN const unsigned char OD_ZIGZAG4_ADST_DCT[15][2] = {
- {1, 0}, {0, 1}, {2, 0}, {1, 1},
- {3, 0}, {2, 1}, {0, 2}, {1, 2},
- {3, 1}, {0, 3}, {2, 2}, {1, 3},
- {3, 2}, {2, 3}, {3, 3} };
-
-OD_EXTERN const unsigned char OD_ZIGZAG4_DCT_ADST[15][2] = {
- {0, 1}, {0, 2}, {1, 0}, {0, 3},
- {1, 1}, {1, 2}, {2, 0}, {1, 3},
- {2, 1}, {2, 2}, {3, 0}, {3, 1},
- {2, 3}, {3, 2}, {3, 3} };
diff --git a/av1/common/zigzag8.c b/av1/common/zigzag8.c
deleted file mode 100644
index 3f11e0c..0000000
--- a/av1/common/zigzag8.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* This file is generated by gen_zigzag8.m */
-
-/* clang-format off */
-
-#include "odintrin.h"
-
-OD_EXTERN const unsigned char OD_ZIGZAG8_DCT_DCT[48][2] = {
- {4, 0}, {4, 1}, {5, 0}, {5, 1},
- {6, 0}, {7, 0}, {6, 1}, {7, 1},
- {0, 4}, {1, 4}, {0, 5}, {1, 5},
- {0, 6}, {1, 6}, {0, 7}, {1, 7},
- {2, 4}, {4, 2}, {3, 4}, {2, 5},
- {4, 3}, {5, 2}, {4, 4}, {3, 5},
- {5, 3}, {2, 6}, {4, 5}, {6, 2},
- {5, 4}, {3, 6}, {2, 7}, {6, 3},
- {5, 5}, {7, 2}, {4, 6}, {3, 7},
- {6, 4}, {7, 3}, {4, 7}, {5, 6},
- {6, 5}, {7, 4}, {5, 7}, {6, 6},
- {7, 5}, {6, 7}, {7, 6}, {7, 7}
- };
-
-OD_EXTERN const unsigned char OD_ZIGZAG8_ADST_DCT[48][2] = {
- {4, 0}, {5, 0}, {4, 1}, {6, 0},
- {5, 1}, {7, 0}, {6, 1}, {7, 1},
- {0, 4}, {1, 4}, {0, 5}, {1, 5},
- {0, 6}, {1, 6}, {0, 7}, {1, 7},
- {4, 2}, {2, 4}, {5, 2}, {4, 3},
- {3, 4}, {2, 5}, {5, 3}, {4, 4},
- {6, 2}, {3, 5}, {5, 4}, {2, 6},
- {4, 5}, {6, 3}, {7, 2}, {3, 6},
- {2, 7}, {5, 5}, {6, 4}, {4, 6},
- {7, 3}, {3, 7}, {5, 6}, {6, 5},
- {4, 7}, {7, 4}, {5, 7}, {7, 5},
- {6, 6}, {7, 6}, {6, 7}, {7, 7}
- };
-
-OD_EXTERN const unsigned char OD_ZIGZAG8_DCT_ADST[48][2] = {
- {4, 0}, {4, 1}, {5, 0}, {5, 1},
- {6, 0}, {6, 1}, {7, 0}, {7, 1},
- {0, 4}, {0, 5}, {1, 4}, {0, 6},
- {1, 5}, {0, 7}, {1, 6}, {1, 7},
- {2, 4}, {2, 5}, {3, 4}, {4, 2},
- {2, 6}, {4, 3}, {3, 5}, {4, 4},
- {2, 7}, {3, 6}, {5, 2}, {4, 5},
- {5, 3}, {3, 7}, {5, 4}, {4, 6},
- {6, 2}, {5, 5}, {4, 7}, {6, 3},
- {6, 4}, {5, 6}, {7, 2}, {6, 5},
- {7, 3}, {5, 7}, {7, 4}, {6, 6},
- {7, 5}, {6, 7}, {7, 6}, {7, 7}
- };
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
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index a37e8c3..2d1fdb4 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -53,9 +53,6 @@
#include "av1/encoder/segmentation.h"
#include "av1/encoder/subexp.h"
#include "av1/encoder/tokenize.h"
-#if CONFIG_PVQ
-#include "av1/encoder/pvq_encoder.h"
-#endif
#define ENC_MISMATCH_DEBUG 0
@@ -64,8 +61,6 @@
inter_singleref_comp_mode_encodings[INTER_SINGLEREF_COMP_MODES];
#endif // CONFIG_COMPOUND_SINGLEREF
-// TODO(anybody) : remove this flag when PVQ supports pallete coding tool
-#if !CONFIG_PVQ || CONFIG_EXT_INTRA
static INLINE void write_uniform(aom_writer *w, int n, int v) {
const int l = get_unsigned_bits(n);
const int m = (1 << l) - n;
@@ -77,7 +72,6 @@
aom_write_literal(w, (v - m) & 1, 1);
}
}
-#endif // !CONFIG_PVQ || CONFIG_EXT_INTRA
#if CONFIG_INTERINTRA
static struct av1_token interintra_mode_encodings[INTERINTRA_MODES];
@@ -553,8 +547,6 @@
}
#endif
-// TODO(anybody) : remove this flag when PVQ supports pallete coding tool
-#if !CONFIG_PVQ
static void pack_map_tokens(aom_writer *w, const TOKENEXTRA **tp, int n,
int num) {
const TOKENEXTRA *p = *tp;
@@ -567,9 +559,6 @@
}
*tp = p;
}
-#endif // !CONFIG_PVQ
-
-#if !CONFIG_PVQ
#if !CONFIG_LV_MAP
#if CONFIG_NEW_MULTISYMBOL
@@ -682,95 +671,6 @@
*tp = p;
}
#endif // !CONFIG_LV_MAP
-#else // !CONFIG_PVQ
-static PVQ_INFO *get_pvq_block(PVQ_QUEUE *pvq_q) {
- PVQ_INFO *pvq;
-
- assert(pvq_q->curr_pos <= pvq_q->last_pos);
- assert(pvq_q->curr_pos < pvq_q->buf_len);
-
- pvq = pvq_q->buf + pvq_q->curr_pos;
- ++pvq_q->curr_pos;
-
- return pvq;
-}
-
-static void pack_pvq_tokens(aom_writer *w, MACROBLOCK *const x,
- MACROBLOCKD *const xd, int plane, BLOCK_SIZE bsize,
- const TX_SIZE tx_size) {
- PVQ_INFO *pvq;
- int idx, idy;
- const struct macroblockd_plane *const pd = &xd->plane[plane];
- od_adapt_ctx *adapt;
- int max_blocks_wide;
- int max_blocks_high;
- int step = (1 << tx_size);
-
-#if CONFIG_CHROMA_SUB8X8
- const BLOCK_SIZE plane_bsize =
- AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
-#else
- const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
-#endif // CONFIG_CHROMA_SUB8X8
-
- adapt = x->daala_enc.state.adapt;
-
- max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
- max_blocks_high = max_block_high(xd, plane_bsize, plane);
-
- for (idy = 0; idy < max_blocks_high; idy += step) {
- for (idx = 0; idx < max_blocks_wide; idx += step) {
- const int is_keyframe = 0;
- const int encode_flip = 0;
- const int flip = 0;
- int i;
- const int has_dc_skip = 1;
- int *exg = &adapt->pvq.pvq_exg[plane][tx_size][0];
- int *ext = adapt->pvq.pvq_ext + tx_size * PVQ_MAX_PARTITIONS;
- generic_encoder *model = adapt->pvq.pvq_param_model;
-
- pvq = get_pvq_block(x->pvq_q);
-
- // encode block skip info
- aom_write_symbol(w, pvq->ac_dc_coded,
- adapt->skip_cdf[2 * tx_size + (plane != 0)], 4);
-
- // AC coeffs coded?
- if (pvq->ac_dc_coded & AC_CODED) {
- assert(pvq->bs == tx_size);
- for (i = 0; i < pvq->nb_bands; i++) {
- if (i == 0 ||
- (!pvq->skip_rest && !(pvq->skip_dir & (1 << ((i - 1) % 3))))) {
- pvq_encode_partition(
- w, pvq->qg[i], pvq->theta[i], pvq->y + pvq->off[i],
- pvq->size[i], pvq->k[i], model, adapt, exg + i, ext + i,
- (plane != 0) * OD_TXSIZES * PVQ_MAX_PARTITIONS +
- pvq->bs * PVQ_MAX_PARTITIONS + i,
- is_keyframe, i == 0 && (i < pvq->nb_bands - 1), pvq->skip_rest,
- encode_flip, flip);
- }
- if (i == 0 && !pvq->skip_rest && pvq->bs > 0) {
- aom_write_symbol(
- w, pvq->skip_dir,
- &adapt->pvq
- .pvq_skip_dir_cdf[(plane != 0) + 2 * (pvq->bs - 1)][0],
- 7);
- }
- }
- }
- // Encode residue of DC coeff, if exist.
- if (!has_dc_skip || (pvq->ac_dc_coded & DC_CODED)) {
- generic_encode(w, &adapt->model_dc[plane],
- abs(pvq->dq_dc_residue) - has_dc_skip,
- &adapt->ex_dc[plane][pvq->bs][0], 2);
- }
- if ((pvq->ac_dc_coded & DC_CODED)) {
- aom_write_bit(w, pvq->dq_dc_residue < 0);
- }
- }
- } // for (idy = 0;
-}
-#endif // !CONFIG_PVG
#if CONFIG_VAR_TX && !CONFIG_COEF_INTERLEAVE
#if CONFIG_LV_MAP
@@ -780,7 +680,7 @@
#endif // CONFIG_LV_MAP
const TOKENEXTRA **tp,
const TOKENEXTRA *const tok_end,
-#if CONFIG_PVQ || CONFIG_LV_MAP
+#if CONFIG_LV_MAP
MACROBLOCK *const x,
#endif
MACROBLOCKD *xd, MB_MODE_INFO *mbmi, int plane,
@@ -805,16 +705,12 @@
TOKEN_STATS tmp_token_stats;
init_token_stats(&tmp_token_stats);
-#if !CONFIG_PVQ
tran_low_t *tcoeff = BLOCK_OFFSET(x->mbmi_ext->tcoeff[plane], block);
uint16_t eob = x->mbmi_ext->eobs[plane][block];
TXB_CTX txb_ctx = { x->mbmi_ext->txb_skip_ctx[plane][block],
x->mbmi_ext->dc_sign_ctx[plane][block] };
av1_write_coeffs_txb(cm, xd, w, blk_row, blk_col, block, plane, tx_size,
tcoeff, eob, &txb_ctx);
-#else
- pack_pvq_tokens(w, x, xd, plane, bsize, tx_size);
-#endif
#if CONFIG_RD_DEBUG
token_stats->txb_coeff_cost_map[blk_row][blk_col] = tmp_token_stats.cost;
token_stats->cost += tmp_token_stats.cost;
@@ -838,7 +734,7 @@
cm,
#endif
tp, tok_end,
-#if CONFIG_PVQ || CONFIG_LV_MAP
+#if CONFIG_LV_MAP
x,
#endif
xd, mbmi, plane, plane_bsize, bit_depth, block, offsetr,
@@ -849,11 +745,8 @@
}
#else // CONFIG_LV_MAP
static void pack_txb_tokens(aom_writer *w, const TOKENEXTRA **tp,
- const TOKENEXTRA *const tok_end,
-#if CONFIG_PVQ
- MACROBLOCK *const x,
-#endif
- MACROBLOCKD *xd, MB_MODE_INFO *mbmi, int plane,
+ const TOKENEXTRA *const tok_end, MACROBLOCKD *xd,
+ MB_MODE_INFO *mbmi, int plane,
BLOCK_SIZE plane_bsize, aom_bit_depth_t bit_depth,
int block, int blk_row, int blk_col,
TX_SIZE tx_size, TOKEN_STATS *token_stats) {
@@ -878,15 +771,11 @@
if (tx_size == plane_tx_size) {
TOKEN_STATS tmp_token_stats;
init_token_stats(&tmp_token_stats);
-#if !CONFIG_PVQ
pack_mb_tokens(w, tp, tok_end, bit_depth, tx_size,
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
tx_type, is_inter_block(mbmi),
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
&tmp_token_stats);
-#else
- pack_pvq_tokens(w, x, xd, plane, bsize, tx_size);
-#endif
#if CONFIG_RD_DEBUG
token_stats->txb_coeff_cost_map[blk_row][blk_col] = tmp_token_stats.cost;
token_stats->cost += tmp_token_stats.cost;
@@ -920,12 +809,8 @@
if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) continue;
- pack_txb_tokens(w, tp, tok_end,
-#if CONFIG_PVQ
- x,
-#endif
- xd, mbmi, plane, plane_bsize, bit_depth, block, offsetr,
- offsetc, sub_txs, token_stats);
+ pack_txb_tokens(w, tp, tok_end, xd, mbmi, plane, plane_bsize, bit_depth,
+ block, offsetr, offsetc, sub_txs, token_stats);
block += step;
}
}
@@ -2265,7 +2150,7 @@
MB_MODE_INFO *const mbmi = &m->mbmi;
int plane;
int bh, bw;
-#if CONFIG_PVQ || CONFIG_LV_MAP
+#if CONFIG_LV_MAP
MACROBLOCK *const x = &cpi->td.mb;
(void)tok;
(void)tok_end;
@@ -2285,8 +2170,6 @@
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
-// TODO(anybody) : remove this flag when PVQ supports pallete coding tool
-#if !CONFIG_PVQ
for (plane = 0; plane <= 1; ++plane) {
const uint8_t palette_size_plane =
mbmi->palette_mode_info.palette_size[plane];
@@ -2305,7 +2188,6 @@
#endif // !CONFIG_LV_MAP
}
}
-#endif // !CONFIG_PVQ
#if CONFIG_COEF_INTERLEAVE
if (!mbmi->skip) {
@@ -2384,7 +2266,7 @@
}
#else // CONFIG_COEF_INTERLEAVE
if (!mbmi->skip) {
-#if !CONFIG_PVQ && !CONFIG_LV_MAP
+#if !CONFIG_LV_MAP
assert(*tok < tok_end);
#endif
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
@@ -2445,7 +2327,7 @@
cm,
#endif
tok, tok_end,
-#if CONFIG_PVQ || CONFIG_LV_MAP
+#if CONFIG_LV_MAP
x,
#endif
xd, mbmi, plane, plane_bsize, cm->bit_depth,
@@ -2479,7 +2361,6 @@
for (blk_row = row; blk_row < unit_height; blk_row += bkh) {
for (blk_col = col; blk_col < unit_width; blk_col += bkw) {
-#if !CONFIG_PVQ
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
TX_TYPE tx_type =
av1_get_tx_type(plane ? PLANE_TYPE_UV : PLANE_TYPE_Y, xd,
@@ -2490,9 +2371,6 @@
tx_type, is_inter_block(mbmi),
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
&token_stats);
-#else
- pack_pvq_tokens(w, x, xd, plane, bsize, tx);
-#endif
}
}
}
@@ -2502,7 +2380,7 @@
#else
const TX_SIZE tx = av1_get_tx_size(plane, xd);
TOKEN_STATS token_stats;
-#if !CONFIG_PVQ
+
init_token_stats(&token_stats);
#if CONFIG_LV_MAP
(void)tx;
@@ -2519,10 +2397,6 @@
&token_stats);
#endif // CONFIG_LV_MAP
-#else
- (void)token_stats;
- pack_pvq_tokens(w, x, xd, plane, mbmi->sb_type, tx);
-#endif
#if CONFIG_RD_DEBUG
if (is_inter_block(mbmi) && mbmi->sb_type >= BLOCK_8X8 &&
rd_token_stats_mismatch(&mbmi->rd_stats, &token_stats, plane)) {
@@ -2532,7 +2406,7 @@
#endif // CONFIG_RD_DEBUG
#endif // CONFIG_VAR_TX
-#if !CONFIG_PVQ && !CONFIG_LV_MAP
+#if !CONFIG_LV_MAP
assert(*tok < tok_end && (*tok)->token == EOSB_TOKEN);
(*tok)++;
#endif
@@ -2901,9 +2775,6 @@
#else
av1_zero_above_context(cm, mi_col_start, mi_col_end);
#endif
-#if CONFIG_PVQ
- assert(cpi->td.mb.pvq_q->curr_pos == 0);
-#endif
if (cpi->common.delta_q_present_flag) {
xd->prev_qindex = cpi->common.base_qindex;
#if CONFIG_EXT_DELTA_Q
@@ -2927,13 +2798,6 @@
#endif
}
}
-#if CONFIG_PVQ
- // Check that the number of PVQ blocks encoded and written to the bitstream
- // are the same
- assert(cpi->td.mb.pvq_q->curr_pos == cpi->td.mb.pvq_q->last_pos);
- // Reset curr_pos in case we repack the bitstream
- cpi->td.mb.pvq_q->curr_pos = 0;
-#endif
}
#if CONFIG_LOOP_RESTORATION
@@ -3615,10 +3479,6 @@
// Initialise tile context from the frame context
this_tile->tctx = *cm->fc;
cpi->td.mb.e_mbd.tile_ctx = &this_tile->tctx;
-#if CONFIG_PVQ
- cpi->td.mb.pvq_q = &this_tile->pvq_q;
- cpi->td.mb.daala_enc.state.adapt = &this_tile->tctx.pvq_context;
-#endif // CONFIG_PVQ
#if CONFIG_ANS
mode_bc.size = 1 << cpi->common.ans_window_size_log2;
#endif
@@ -3627,9 +3487,6 @@
assert(tok == tok_end);
aom_stop_encode(&mode_bc);
tile_size = mode_bc.pos;
-#if CONFIG_PVQ
- cpi->td.mb.pvq_q = NULL;
-#endif
buf->size = tile_size;
#if CONFIG_SIMPLE_BWD_ADAPT
@@ -3796,10 +3653,6 @@
// Initialise tile context from the frame context
this_tile->tctx = *cm->fc;
cpi->td.mb.e_mbd.tile_ctx = &this_tile->tctx;
-#if CONFIG_PVQ
- cpi->td.mb.pvq_q = &this_tile->pvq_q;
- cpi->td.mb.daala_enc.state.adapt = &this_tile->tctx.pvq_context;
-#endif // CONFIG_PVQ
#if CONFIG_ANS
mode_bc.size = 1 << cpi->common.ans_window_size_log2;
#endif // CONFIG_ANS
@@ -3813,16 +3666,10 @@
aom_start_encode(&mode_bc, dst + total_size);
write_modes(cpi, &tile_info, &mode_bc, &tok, tok_end);
#if !CONFIG_LV_MAP
-#if !CONFIG_PVQ
assert(tok == tok_end);
-#endif // !CONFIG_PVQ
#endif // !CONFIG_LV_MAP
aom_stop_encode(&mode_bc);
tile_size = mode_bc.pos;
-#if CONFIG_PVQ
- cpi->td.mb.pvq_q = NULL;
-#endif
-
assert(tile_size > 0);
curr_tg_data_size += tile_size + 4;
@@ -5218,10 +5065,6 @@
// Initialise tile context from the frame context
this_tile->tctx = *cm->fc;
cpi->td.mb.e_mbd.tile_ctx = &this_tile->tctx;
-#if CONFIG_PVQ
- cpi->td.mb.pvq_q = &this_tile->pvq_q;
- cpi->td.mb.daala_enc.state.adapt = &this_tile->tctx.pvq_context;
-#endif // CONFIG_PVQ
#if CONFIG_ANS
mode_bc.size = 1 << cpi->common.ans_window_size_log2;
#endif
@@ -5230,9 +5073,6 @@
assert(tok == tok_end);
aom_stop_encode(&mode_bc);
tile_size = mode_bc.pos;
-#if CONFIG_PVQ
- cpi->td.mb.pvq_q = NULL;
-#endif
buf->size = tile_size;
// Record the maximum tile size we see, so we can compact headers later.
@@ -5340,25 +5180,16 @@
// Initialise tile context from the frame context
this_tile->tctx = *cm->fc;
cpi->td.mb.e_mbd.tile_ctx = &this_tile->tctx;
-#if CONFIG_PVQ
- cpi->td.mb.pvq_q = &this_tile->pvq_q;
- cpi->td.mb.daala_enc.state.adapt = &this_tile->tctx.pvq_context;
-#endif // CONFIG_PVQ
#if CONFIG_ANS
mode_bc.size = 1 << cpi->common.ans_window_size_log2;
#endif // CONFIG_ANS
aom_start_encode(&mode_bc, dst + total_size);
write_modes(cpi, &tile_info, &mode_bc, &tok, tok_end);
#if !CONFIG_LV_MAP
-#if !CONFIG_PVQ
assert(tok == tok_end);
-#endif // !CONFIG_PVQ
#endif // !CONFIG_LV_MAP
aom_stop_encode(&mode_bc);
tile_size = mode_bc.pos;
-#if CONFIG_PVQ
- cpi->td.mb.pvq_q = NULL;
-#endif
assert(tile_size > 0);
curr_tg_data_size += (tile_size + (is_last_tile_in_tg ? 0 : 4));
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 4547c97..b4da70d 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -14,9 +14,6 @@
#include "av1/common/entropymv.h"
#include "av1/common/entropy.h"
-#if CONFIG_PVQ
-#include "av1/encoder/encint.h"
-#endif
#include "av1/common/mvref_common.h"
#include "av1/encoder/hash.h"
#if CONFIG_DIST_8X8
@@ -27,12 +24,6 @@
extern "C" {
#endif
-#if CONFIG_PVQ
-// Maximum possible # of tx blocks in luma plane, which is currently 256,
-// since there can be 16x16 of 4x4 tx.
-#define MAX_PVQ_BLOCKS_IN_SB (MAX_SB_SQUARE >> 2 * OD_LOG_BSIZE0)
-#endif
-
typedef struct {
unsigned int sse;
int sum;
@@ -41,9 +32,6 @@
typedef struct macroblock_plane {
DECLARE_ALIGNED(16, int16_t, src_diff[MAX_SB_SQUARE]);
-#if CONFIG_PVQ
- DECLARE_ALIGNED(16, int16_t, src_int16[MAX_SB_SQUARE]);
-#endif
tran_low_t *qcoeff;
tran_low_t *coeff;
uint16_t *eobs;
@@ -330,25 +318,6 @@
int use_default_intra_tx_type;
// use default transform and skip transform type search for inter modes
int use_default_inter_tx_type;
-#if CONFIG_PVQ
- int rate;
- // 1 if neither AC nor DC is coded. Only used during RDO.
- int pvq_skip[MAX_MB_PLANE];
- PVQ_QUEUE *pvq_q;
-
- // Storage for PVQ tx block encodings in a superblock.
- // There can be max 16x16 of 4x4 blocks (and YUV) encode by PVQ
- // 256 is the max # of 4x4 blocks in a SB (64x64), which comes from:
- // 1) Since PVQ is applied to each trasnform-ed block
- // 2) 4x4 is the smallest tx size in AV1
- // 3) AV1 allows using smaller tx size than block (i.e. partition) size
- // TODO(yushin) : The memory usage could be improved a lot, since this has
- // storage for 10 bands and 128 coefficients for every 4x4 block,
- PVQ_INFO pvq[MAX_PVQ_BLOCKS_IN_SB][MAX_MB_PLANE];
- daala_enc_ctx daala_enc;
- int pvq_speed;
- int pvq_coded; // Indicates whether pvq_info needs be stored to tokenize
-#endif
#if CONFIG_DIST_8X8
int using_dist_8x8;
aom_tune_metric tune_metric;
diff --git a/av1/encoder/context_tree.c b/av1/encoder/context_tree.c
index 7be0225..fff15d5 100644
--- a/av1/encoder/context_tree.c
+++ b/av1/encoder/context_tree.c
@@ -49,11 +49,6 @@
cm, ctx->txb_entropy_ctx[i],
aom_memalign(32, num_blk * sizeof(*ctx->txb_entropy_ctx[i])));
#endif
-
-#if CONFIG_PVQ
- CHECK_MEM_ERROR(cm, ctx->pvq_ref_coeff[i],
- aom_memalign(32, num_pix * sizeof(*ctx->pvq_ref_coeff[i])));
-#endif
}
for (i = 0; i < 2; ++i) {
@@ -80,10 +75,6 @@
ctx->qcoeff[i] = 0;
aom_free(ctx->dqcoeff[i]);
ctx->dqcoeff[i] = 0;
-#if CONFIG_PVQ
- aom_free(ctx->pvq_ref_coeff[i]);
- ctx->pvq_ref_coeff[i] = 0;
-#endif
aom_free(ctx->eobs[i]);
ctx->eobs[i] = 0;
#if CONFIG_LV_MAP
diff --git a/av1/encoder/context_tree.h b/av1/encoder/context_tree.h
index 0c956cd..06a92b9 100644
--- a/av1/encoder/context_tree.h
+++ b/av1/encoder/context_tree.h
@@ -38,9 +38,6 @@
tran_low_t *coeff[MAX_MB_PLANE];
tran_low_t *qcoeff[MAX_MB_PLANE];
tran_low_t *dqcoeff[MAX_MB_PLANE];
-#if CONFIG_PVQ
- tran_low_t *pvq_ref_coeff[MAX_MB_PLANE];
-#endif
uint16_t *eobs[MAX_MB_PLANE];
#if CONFIG_LV_MAP
uint8_t *txb_entropy_ctx[MAX_MB_PLANE];
diff --git a/av1/encoder/daala_compat_enc.c b/av1/encoder/daala_compat_enc.c
deleted file mode 100644
index c60e2d3..0000000
--- a/av1/encoder/daala_compat_enc.c
+++ /dev/null
@@ -1,30 +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.
- */
-
-#include "encint.h"
-
-void od_encode_checkpoint(const daala_enc_ctx *enc, od_rollback_buffer *rbuf) {
-#if !CONFIG_ANS
- od_ec_enc_checkpoint(&rbuf->ec, &enc->w.ec);
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- OD_COPY(&rbuf->adapt, enc->state.adapt, 1);
-}
-
-void od_encode_rollback(daala_enc_ctx *enc, const od_rollback_buffer *rbuf) {
-#if !CONFIG_ANS
- od_ec_enc_rollback(&enc->w.ec, &rbuf->ec);
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- OD_COPY(enc->state.adapt, &rbuf->adapt, 1);
-}
diff --git a/av1/encoder/encint.h b/av1/encoder/encint.h
deleted file mode 100644
index 30ea852..0000000
--- a/av1/encoder/encint.h
+++ /dev/null
@@ -1,51 +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(_encint_H)
-# define _encint_H (1)
-
-typedef struct daala_enc_ctx od_enc_ctx;
-typedef struct od_params_ctx od_params_ctx;
-typedef struct od_rollback_buffer od_rollback_buffer;
-
-# include "aom_dsp/entenc.h"
-# include "av1/common/odintrin.h"
-# include "av1/common/pvq_state.h"
-
-struct daala_enc_ctx{
- /* Stores context-adaptive CDFs for PVQ. */
- od_state state;
- /* AOM entropy encoder. */
- aom_writer w;
- int use_activity_masking;
- /* Mode of quantization matrice : FLAT (0) or HVS (1) */
- int qm;
- /*Normalized PVQ lambda for use where we've already performed
- quantization.*/
- double pvq_norm_lambda;
- double pvq_norm_lambda_dc;
-};
-
-// from daalaenc.h
-/**The encoder context.*/
-typedef struct daala_enc_ctx daala_enc_ctx;
-
-/** Holds important encoder information so we can roll back decisions */
-struct od_rollback_buffer {
- od_ec_enc ec;
- od_adapt_ctx adapt;
-};
-
-void od_encode_checkpoint(const daala_enc_ctx *enc, od_rollback_buffer *rbuf);
-void od_encode_rollback(daala_enc_ctx *enc, const od_rollback_buffer *rbuf);
-
-#endif
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index eff931a..1ed061c 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -57,10 +57,6 @@
#include "av1/encoder/rdopt.h"
#include "av1/encoder/segmentation.h"
#include "av1/encoder/tokenize.h"
-#if CONFIG_PVQ
-#include "av1/common/pvq.h"
-#include "av1/encoder/pvq_encoder.h"
-#endif
#if CONFIG_HIGHBITDEPTH
#define IF_HBD(...) __VA_ARGS__
#else
@@ -486,9 +482,6 @@
p[i].coeff = ctx->coeff[i];
p[i].qcoeff = ctx->qcoeff[i];
pd[i].dqcoeff = ctx->dqcoeff[i];
-#if CONFIG_PVQ
- pd[i].pvq_ref_coeff = ctx->pvq_ref_coeff[i];
-#endif
p[i].eobs = ctx->eobs[i];
#if CONFIG_LV_MAP
p[i].txb_entropy_ctx = ctx->txb_entropy_ctx[i];
@@ -855,11 +848,6 @@
aom_clear_system_state();
-#if CONFIG_PVQ
- x->pvq_speed = 1;
- x->pvq_coded = 0;
-#endif
-
set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize);
mbmi = &xd->mi[0]->mbmi;
mbmi->sb_type = bsize;
@@ -875,9 +863,6 @@
p[i].coeff = ctx->coeff[i];
p[i].qcoeff = ctx->qcoeff[i];
pd[i].dqcoeff = ctx->dqcoeff[i];
-#if CONFIG_PVQ
- pd[i].pvq_ref_coeff = ctx->pvq_ref_coeff[i];
-#endif
p[i].eobs = ctx->eobs[i];
#if CONFIG_LV_MAP
p[i].txb_entropy_ctx = ctx->txb_entropy_ctx[i];
@@ -1385,11 +1370,7 @@
static void restore_context(MACROBLOCK *x,
const RD_SEARCH_MACROBLOCK_CONTEXT *ctx, int mi_row,
- int mi_col,
-#if CONFIG_PVQ
- od_rollback_buffer *rdo_buf,
-#endif
- BLOCK_SIZE bsize) {
+ int mi_col, BLOCK_SIZE bsize) {
MACROBLOCKD *xd = &x->e_mbd;
int p;
const int num_4x4_blocks_wide =
@@ -1424,17 +1405,10 @@
memcpy(xd->left_txfm_context, ctx->tl,
sizeof(*xd->left_txfm_context) * (mi_height << TX_UNIT_HIGH_LOG2));
#endif
-#if CONFIG_PVQ
- od_encode_rollback(&x->daala_enc, rdo_buf);
-#endif
}
static void save_context(const MACROBLOCK *x, RD_SEARCH_MACROBLOCK_CONTEXT *ctx,
- int mi_row, int mi_col,
-#if CONFIG_PVQ
- od_rollback_buffer *rdo_buf,
-#endif
- BLOCK_SIZE bsize) {
+ int mi_row, int mi_col, BLOCK_SIZE bsize) {
const MACROBLOCKD *xd = &x->e_mbd;
int p;
const int num_4x4_blocks_wide =
@@ -1471,9 +1445,6 @@
ctx->p_ta = xd->above_txfm_context;
ctx->p_tl = xd->left_txfm_context;
#endif
-#if CONFIG_PVQ
- od_encode_checkpoint(&x->daala_enc, rdo_buf);
-#endif
}
static void encode_b(const AV1_COMP *const cpi, const TileInfo *const tile,
@@ -1857,9 +1828,7 @@
BLOCK_SIZE bs_type = mib[0]->mbmi.sb_type;
int do_partition_search = 1;
PICK_MODE_CONTEXT *ctx_none = &pc_tree->none;
-#if CONFIG_PVQ
- od_rollback_buffer pre_rdo_buf;
-#endif
+
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return;
assert(num_4x4_blocks_wide_lookup[bsize] ==
@@ -1877,11 +1846,7 @@
xd->left_txfm_context = xd->left_txfm_context_buffer +
((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2);
#endif
-#if !CONFIG_PVQ
save_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- save_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif
if (bsize == BLOCK_16X16 && cpi->vaq_refresh) {
set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize);
@@ -1920,11 +1885,7 @@
none_rdc.rdcost = RDCOST(x->rdmult, none_rdc.rate, none_rdc.dist);
}
-#if !CONFIG_PVQ
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif
mib[0]->mbmi.sb_type = bs_type;
pc_tree->partitioning = partition;
}
@@ -2045,11 +2006,8 @@
BLOCK_SIZE split_subsize = get_subsize(bsize, PARTITION_SPLIT);
chosen_rdc.rate = 0;
chosen_rdc.dist = 0;
-#if !CONFIG_PVQ
+
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif
pc_tree->partitioning = PARTITION_SPLIT;
// Split partition.
@@ -2057,17 +2015,11 @@
int x_idx = (i & 1) * hbs;
int y_idx = (i >> 1) * hbs;
RD_STATS tmp_rdc;
-#if CONFIG_PVQ
- od_rollback_buffer buf;
-#endif
+
if ((mi_row + y_idx >= cm->mi_rows) || (mi_col + x_idx >= cm->mi_cols))
continue;
-#if !CONFIG_PVQ
save_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- save_context(x, &x_ctx, mi_row, mi_col, &buf, bsize);
-#endif
pc_tree->split[i]->partitioning = PARTITION_NONE;
rd_pick_sb_modes(cpi, tile_data, x, mi_row + y_idx, mi_col + x_idx,
&tmp_rdc,
@@ -2076,11 +2028,7 @@
#endif
split_subsize, &pc_tree->split[i]->none, INT64_MAX);
-#if !CONFIG_PVQ
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &buf, bsize);
-#endif
if (tmp_rdc.rate == INT_MAX || tmp_rdc.dist == INT64_MAX) {
av1_invalid_rd_stats(&chosen_rdc);
break;
@@ -2113,11 +2061,7 @@
chosen_rdc = none_rdc;
}
-#if !CONFIG_PVQ
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif
// We must have chosen a partitioning and encoding or we'll fail later on.
// No other opportunities for success.
@@ -2651,10 +2595,6 @@
int partition_vert_allowed =
!force_horz_split && xss <= yss && bsize_at_least_8x8;
-#if CONFIG_PVQ
- od_rollback_buffer pre_rdo_buf;
-#endif
-
(void)*tp_orig;
#if !CONFIG_UNPOISON_PARTITION_CTX
@@ -2736,11 +2676,7 @@
xd->left_txfm_context = xd->left_txfm_context_buffer +
((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2);
#endif
-#if !CONFIG_PVQ
save_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- save_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif
#if CONFIG_FP_MB_STATS
if (cpi->use_fp_mb_stats) {
@@ -2887,11 +2823,9 @@
#endif
}
}
-#if !CONFIG_PVQ
+
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif
+
#if CONFIG_CFL && CONFIG_CHROMA_SUB8X8 && CONFIG_DEBUG
if (!x->skip_chroma_rd) {
cfl_clear_sub8x8_val(xd->cfl);
@@ -2967,11 +2901,8 @@
// gives better rd cost
do_rectangular_split &= !partition_none_allowed;
}
-#if !CONFIG_PVQ
+
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif
} // if (do_split)
// PARTITION_HORZ
@@ -3050,11 +2981,8 @@
pc_tree->partitioning = PARTITION_HORZ;
}
}
-#if !CONFIG_PVQ
+
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif
}
// PARTITION_VERT
@@ -3134,11 +3062,8 @@
pc_tree->partitioning = PARTITION_VERT;
}
}
-#if !CONFIG_PVQ
+
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif
}
#if CONFIG_EXT_PARTITION_TYPES
@@ -3187,11 +3112,7 @@
mi_col + mi_step, bsize2, mi_row + mi_step, mi_col,
subsize);
#endif
-#if !CONFIG_PVQ
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif // !CONFIG_PVQ
}
// PARTITION_HORZ_B
if (partition_horz_allowed && horzab_partition_allowed) {
@@ -3210,11 +3131,7 @@
mi_row + mi_step, mi_col, bsize2, mi_row + mi_step,
mi_col + mi_step, bsize2);
#endif
-#if !CONFIG_PVQ
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif // !CONFIG_PVQ
}
// PARTITION_VERT_A
if (partition_vert_allowed && vertab_partition_allowed) {
@@ -3233,11 +3150,7 @@
mi_row + mi_step, mi_col, bsize2, mi_row,
mi_col + mi_step, subsize);
#endif
-#if !CONFIG_PVQ
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif // !CONFIG_PVQ
}
// PARTITION_VERT_B
if (partition_vert_allowed && vertab_partition_allowed) {
@@ -3256,11 +3169,7 @@
mi_col + mi_step, bsize2, mi_row + mi_step,
mi_col + mi_step, bsize2);
#endif
-#if !CONFIG_PVQ
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif // !CONFIG_PVQ
}
// PARTITION_HORZ_4
@@ -3298,11 +3207,7 @@
pc_tree->partitioning = PARTITION_HORZ_4;
}
}
-#if !CONFIG_PVQ
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif
}
// PARTITION_VERT_4
if (vert4_partition_allowed && !force_vert_split &&
@@ -3335,11 +3240,7 @@
pc_tree->partitioning = PARTITION_VERT_4;
}
}
-#if !CONFIG_PVQ
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
-#else
- restore_context(x, &x_ctx, mi_row, mi_col, &pre_rdo_buf, bsize);
-#endif
}
#endif // CONFIG_EXT_PARTITION_TYPES
@@ -3381,7 +3282,7 @@
#endif // CONFIG_DIST_8X8
if (bsize == cm->sb_size) {
-#if !CONFIG_PVQ && !CONFIG_LV_MAP
+#if !CONFIG_LV_MAP
assert(tp_orig < *tp || (tp_orig == *tp && xd->mi[0]->mbmi.skip));
#endif
assert(best_rdc.rate < INT_MAX);
@@ -3655,14 +3556,6 @@
tile_data->mode_map[i][j] = j;
}
}
-#if CONFIG_PVQ
- // This will be dynamically increased as more pvq block is encoded.
- tile_data->pvq_q.buf_len = 1000;
- CHECK_MEM_ERROR(
- cm, tile_data->pvq_q.buf,
- aom_malloc(tile_data->pvq_q.buf_len * sizeof(PVQ_INFO)));
- tile_data->pvq_q.curr_pos = 0;
-#endif
}
}
@@ -3675,9 +3568,6 @@
cpi->tile_tok[tile_row][tile_col] = pre_tok + tile_tok;
pre_tok = cpi->tile_tok[tile_row][tile_col];
tile_tok = allocated_tokens(*tile_info);
-#if CONFIG_PVQ
- cpi->tile_data[tile_row * tile_cols + tile_col].pvq_q.curr_pos = 0;
-#endif
}
}
}
@@ -3705,78 +3595,6 @@
this_tile->ex_search_count = 0; // Exhaustive mesh search hits.
td->mb.m_search_count_ptr = &this_tile->m_search_count;
td->mb.ex_search_count_ptr = &this_tile->ex_search_count;
-
-#if CONFIG_PVQ
- td->mb.pvq_q = &this_tile->pvq_q;
-
- // TODO(yushin) : activity masking info needs be signaled by a bitstream
- td->mb.daala_enc.use_activity_masking = AV1_PVQ_ENABLE_ACTIVITY_MASKING;
-
- if (td->mb.daala_enc.use_activity_masking)
- td->mb.daala_enc.qm = OD_HVS_QM; // Hard coded. Enc/dec required to sync.
- else
- td->mb.daala_enc.qm = OD_FLAT_QM; // Hard coded. Enc/dec required to sync.
-
- {
- // FIXME: Multiple segments support
- int segment_id = 0;
- int rdmult = set_segment_rdmult(cpi, &td->mb, segment_id);
- int qindex = av1_get_qindex(&cm->seg, segment_id, cm->base_qindex);
-#if CONFIG_HIGHBITDEPTH
- const int quantizer_shift = td->mb.e_mbd.bd - 8;
-#else
- const int quantizer_shift = 0;
-#endif // CONFIG_HIGHBITDEPTH
- int64_t q_ac = OD_MAXI(
- 1, av1_ac_quant(qindex, 0, cpi->common.bit_depth) >> quantizer_shift);
- int64_t q_dc = OD_MAXI(
- 1, av1_dc_quant(qindex, 0, cpi->common.bit_depth) >> quantizer_shift);
- /* td->mb.daala_enc.pvq_norm_lambda = OD_PVQ_LAMBDA; */
- td->mb.daala_enc.pvq_norm_lambda =
- (double)rdmult * (64 / 16) / (q_ac * q_ac * (1 << RDDIV_BITS));
- td->mb.daala_enc.pvq_norm_lambda_dc =
- (double)rdmult * (64 / 16) / (q_dc * q_dc * (1 << RDDIV_BITS));
- // printf("%f\n", td->mb.daala_enc.pvq_norm_lambda);
- }
- od_init_qm(td->mb.daala_enc.state.qm, td->mb.daala_enc.state.qm_inv,
- td->mb.daala_enc.qm == OD_HVS_QM ? OD_QM8_Q4_HVS : OD_QM8_Q4_FLAT);
-
- if (td->mb.daala_enc.use_activity_masking) {
- int pli;
- int use_masking = td->mb.daala_enc.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(&td->mb.daala_enc.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(&td->mb.daala_enc.state.pvq_qm_q4[pli][0], q,
- &OD_DEFAULT_QMS[use_masking][i][pli],
- &OD_DEFAULT_QMS[use_masking][i + 1][pli]);
- }
- }
- }
-
-#if !CONFIG_ANS
- od_ec_enc_init(&td->mb.daala_enc.w.ec, 65025);
- od_ec_enc_reset(&td->mb.daala_enc.w.ec);
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
-#endif // #if CONFIG_PVQ
-
this_tile->tctx = *cm->fc;
td->mb.e_mbd.tile_ctx = &this_tile->tctx;
@@ -3786,10 +3604,6 @@
cfl_init(xd->cfl, cm);
#endif
-#if CONFIG_PVQ
- td->mb.daala_enc.state.adapt = &this_tile->tctx.pvq_context;
-#endif // CONFIG_PVQ
-
#if CONFIG_LOOPFILTERING_ACROSS_TILES
if (!cm->loop_filter_across_tiles_enabled)
av1_setup_across_tile_boundary_info(cm, tile_info);
@@ -3805,20 +3619,6 @@
cpi->tok_count[tile_row][tile_col] =
(unsigned int)(tok - cpi->tile_tok[tile_row][tile_col]);
assert(cpi->tok_count[tile_row][tile_col] <= allocated_tokens(*tile_info));
-#if CONFIG_PVQ
-#if !CONFIG_ANS
- od_ec_enc_clear(&td->mb.daala_enc.w.ec);
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
-
- td->mb.pvq_q->last_pos = td->mb.pvq_q->curr_pos;
- // rewind current position so that bitstream can be written
- // from the 1st pvq block
- td->mb.pvq_q->curr_pos = 0;
-
- td->mb.pvq_q = NULL;
-#endif
}
static void encode_tiles(AV1_COMP *cpi) {
@@ -3929,8 +3729,6 @@
}
#endif // CONFIG_GLOBAL_MOTION
-// TODO(anybody) : remove this flag when PVQ supports pallete coding tool
-#if !CONFIG_PVQ
// Estimate if the source frame is screen content, based on the portion of
// blocks that have no more than 4 (experimentally selected) luma colors.
static int is_screen_content(const uint8_t *src,
@@ -3958,7 +3756,6 @@
// The threshold is 10%.
return counts * blk_h * blk_w * 10 > width * height;
}
-#endif // !CONFIG_PVQ
static void encode_frame_internal(AV1_COMP *cpi) {
ThreadData *const td = &cpi->td;
@@ -3988,8 +3785,6 @@
av1_zero(rdc->comp_pred_diff);
if (frame_is_intra_only(cm)) {
-// TODO(anybody) : remove this flag when PVQ supports pallete coding tool
-#if !CONFIG_PVQ
cm->allow_screen_content_tools =
cpi->oxcf.content == AOM_CONTENT_SCREEN ||
is_screen_content(cpi->source->y_buffer,
@@ -3998,9 +3793,6 @@
#endif // CONFIG_HIGHBITDEPTH
cpi->source->y_stride, cpi->source->y_width,
cpi->source->y_height);
-#else
- cm->allow_screen_content_tools = 0;
-#endif // !CONFIG_PVQ
}
#if CONFIG_HASH_ME
@@ -5009,11 +4801,6 @@
const int is_inter = is_inter_block(mbmi);
const BLOCK_SIZE block_size = bsize;
-#if CONFIG_PVQ
- x->pvq_speed = 0;
- x->pvq_coded = (dry_run == OUTPUT_ENABLED) ? 1 : 0;
-#endif
-
if (!is_inter) {
#if CONFIG_CFL
xd->cfl->store_y = 1;
@@ -5043,8 +4830,6 @@
#endif
}
-// TODO(anybody) : remove this flag when PVQ supports pallete coding tool
-#if !CONFIG_PVQ
if (bsize >= BLOCK_8X8) {
for (plane = 0; plane <= 1; ++plane) {
if (mbmi->palette_mode_info.palette_size[plane] > 0) {
@@ -5057,7 +4842,6 @@
}
}
}
-#endif // !CONFIG_PVQ
#if CONFIG_VAR_TX
mbmi->min_tx_size = get_min_tx_size(mbmi->tx_size);
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c
index 6a88714..f060c48 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -32,12 +32,6 @@
#include "av1/encoder/rd.h"
#include "av1/encoder/tokenize.h"
-#if CONFIG_PVQ
-#include "av1/encoder/encint.h"
-#include "av1/common/partition.h"
-#include "av1/encoder/pvq_encoder.h"
-#endif
-
#if CONFIG_CFL
#include "av1/common/cfl.h"
#endif
@@ -400,14 +394,6 @@
if (eob == 0) return eob;
if (xd->lossless[xd->mi[0]->mbmi.segment_id]) return eob;
-#if CONFIG_PVQ
- (void)cm;
- (void)tx_size;
- (void)a;
- (void)l;
- return eob;
-#endif
-
#if !CONFIG_LV_MAP
(void)plane_bsize;
(void)blk_row;
@@ -428,7 +414,6 @@
#endif // !CONFIG_LV_MAP
}
-#if !CONFIG_PVQ
typedef enum QUANT_FUNC {
QUANT_FUNC_LOWBD = 0,
QUANT_FUNC_HIGHBD = 1,
@@ -448,9 +433,8 @@
#endif // !CONFIG_NEW_QUANT
{ NULL, NULL }
};
-#endif // !CONFIG_PVQ
-#if !CONFIG_TXMG && !CONFIG_PVQ
+#if !CONFIG_TXMG
typedef void (*fwdTxfmFunc)(const int16_t *diff, tran_low_t *coeff, int stride,
TxfmParam *txfm_param);
static const fwdTxfmFunc fwd_txfm_func[2] = { av1_fwd_txfm,
@@ -463,7 +447,7 @@
AV1_XFORM_QUANT xform_quant_idx) {
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
-#if !(CONFIG_PVQ || CONFIG_DIST_8X8)
+#if !CONFIG_DIST_8X8
const struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &xd->plane[plane];
#else
@@ -474,7 +458,7 @@
TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
-#if (CONFIG_AOM_QM || CONFIG_NEW_QUANT) && !CONFIG_PVQ
+#if CONFIG_AOM_QM || CONFIG_NEW_QUANT
const int is_inter = is_inter_block(mbmi);
#endif
@@ -484,7 +468,7 @@
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
uint16_t *const eob = &p->eobs[block];
const int diff_stride = block_size_wide[plane_bsize];
-#if CONFIG_AOM_QM && !CONFIG_PVQ
+#if CONFIG_AOM_QM
int seg_id = mbmi->segment_id;
// Use a flat matrix (i.e. no weighting) for 1D and Identity transforms
const qm_val_t *qmatrix =
@@ -498,10 +482,10 @@
TxfmParam txfm_param;
-#if CONFIG_PVQ || CONFIG_DIST_8X8 || CONFIG_LGT_FROM_PRED || CONFIG_MRC_TX
+#if CONFIG_DIST_8X8 || CONFIG_LGT_FROM_PRED || CONFIG_MRC_TX
uint8_t *dst;
const int dst_stride = pd->dst.stride;
-#if CONFIG_PVQ || CONFIG_DIST_8X8
+#if CONFIG_DIST_8X8
int16_t *pred;
const int txw = tx_size_wide[tx_size];
const int txh = tx_size_high[tx_size];
@@ -509,7 +493,6 @@
#endif
#endif
-#if !CONFIG_PVQ
const int tx2d_size = tx_size_2d[tx_size];
QUANT_PARAM qparam;
const int16_t *src_diff;
@@ -525,53 +508,14 @@
qparam.qmatrix = qmatrix;
qparam.iqmatrix = iqmatrix;
#endif // CONFIG_AOM_QM
-#else
- tran_low_t *ref_coeff = BLOCK_OFFSET(pd->pvq_ref_coeff, block);
- int skip = 1;
- PVQ_INFO *pvq_info = NULL;
- uint8_t *src;
- int16_t *src_int16;
- const int src_stride = p->src.stride;
- (void)ctx;
- (void)scan_order;
- (void)qcoeff;
-
- if (x->pvq_coded) {
- assert(block < MAX_PVQ_BLOCKS_IN_SB);
- pvq_info = &x->pvq[block][plane];
- }
- src = &p->src.buf[(blk_row * src_stride + blk_col) << tx_size_wide_log2[0]];
- src_int16 =
- &p->src_int16[(blk_row * diff_stride + blk_col) << tx_size_wide_log2[0]];
-
-#if CONFIG_HIGHBITDEPTH
- if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
- for (j = 0; j < txh; j++)
- for (i = 0; i < txw; i++)
- src_int16[diff_stride * j + i] =
- CONVERT_TO_SHORTPTR(src)[src_stride * j + i];
- } else {
-#endif // CONFIG_HIGHBITDEPTH
- for (j = 0; j < txh; j++)
- for (i = 0; i < txw; i++)
- src_int16[diff_stride * j + i] = src[src_stride * j + i];
-#if CONFIG_HIGHBITDEPTH
- }
-#endif // CONFIG_HIGHBITDEPTH
-#endif
-
-#if CONFIG_PVQ || CONFIG_DIST_8X8 || CONFIG_LGT_FROM_PRED || CONFIG_MRC_TX
+#if CONFIG_DIST_8X8 || CONFIG_LGT_FROM_PRED || CONFIG_MRC_TX
dst = &pd->dst.buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]];
-#endif // CONFIG_PVQ || CONFIG_DIST_8X8 || CONFIG_LGT_FROM_PRED ||
+#endif // CONFIG_DIST_8X8 || CONFIG_LGT_FROM_PRED ||
// CONFIG_MRC_TX
-#if CONFIG_PVQ || CONFIG_DIST_8X8
- if (CONFIG_PVQ
#if CONFIG_DIST_8X8
- || x->using_dist_8x8
-#endif // CONFIG_DIST_8X8
- ) {
+ if (x->using_dist_8x8) {
pred = &pd->pred[(blk_row * diff_stride + blk_col) << tx_size_wide_log2[0]];
// copy uint8 orig and predicted block to int16 buffer
@@ -591,7 +535,7 @@
}
#endif // CONFIG_HIGHBITDEPTH
}
-#endif // CONFIG_PVQ || CONFIG_DIST_8X8
+#endif // CONFIG_DIST_8X8
(void)ctx;
@@ -616,7 +560,6 @@
#endif // CONFIG_LGT_FROM_PRED
#endif // CONFIG_MRC_TX || CONFIG_LGT_FROM_PRED
-#if !CONFIG_PVQ
txfm_param.bd = xd->bd;
const int is_hbd = get_bitdepth_data_path_index(xd);
@@ -639,42 +582,6 @@
(uint8_t)av1_get_txb_entropy_context(qcoeff, scan_order, *eob);
#endif // CONFIG_LV_MAP
return;
-#else // CONFIG_PVQ
- (void)xform_quant_idx;
-#if CONFIG_HIGHBITDEPTH
- txfm_param.bd = xd->bd;
- if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
- av1_highbd_fwd_txfm(src_int16, coeff, diff_stride, &txfm_param);
- av1_highbd_fwd_txfm(pred, ref_coeff, diff_stride, &txfm_param);
- } else {
-#endif
- av1_fwd_txfm(src_int16, coeff, diff_stride, &txfm_param);
- av1_fwd_txfm(pred, ref_coeff, diff_stride, &txfm_param);
-#if CONFIG_HIGHBITDEPTH
- }
-#endif
-
- // PVQ for inter mode block
- if (!x->skip_block) {
- PVQ_SKIP_TYPE ac_dc_coded =
- av1_pvq_encode_helper(x,
- coeff, // target original vector
- ref_coeff, // reference vector
- dqcoeff, // de-quantized vector
- eob, // End of Block marker
- pd->dequant, // aom's quantizers
- plane, // image plane
- tx_size, // block size in log_2 - 2
- tx_type,
- &x->rate, // rate measured
- x->pvq_speed,
- pvq_info); // PVQ info for a block
- skip = ac_dc_coded == PVQ_SKIP;
- }
- x->pvq_skip[plane] = skip;
-
- if (!skip) mbmi->skip = 0;
-#endif // #if !CONFIG_PVQ
}
static void encode_block(int plane, int block, int blk_row, int blk_col,
@@ -691,16 +598,14 @@
uint8_t *mrc_mask = BLOCK_OFFSET(xd->mrc_mask, block);
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
uint8_t *dst;
-#if !CONFIG_PVQ
ENTROPY_CONTEXT *a, *l;
-#endif
+
#if CONFIG_VAR_TX
int bw = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
#endif
dst = &pd->dst
.buf[(blk_row * pd->dst.stride + blk_col) << tx_size_wide_log2[0]];
-#if !CONFIG_PVQ
a = &args->ta[blk_col];
l = &args->tl[blk_row];
#if CONFIG_VAR_TX
@@ -708,9 +613,6 @@
#else
ctx = combine_entropy_contexts(*a, *l);
#endif
-#else
- ctx = 0;
-#endif // CONFIG_PVQ
#if CONFIG_VAR_TX
// Assert not magic number (uninitialized).
@@ -728,7 +630,6 @@
}
#endif
-#if !CONFIG_PVQ
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size, a,
l, 0);
@@ -737,12 +638,7 @@
if (p->eobs[block]) *(args->skip) = 0;
if (p->eobs[block] != 0)
-#else
- (void)ctx;
- if (!x->pvq_skip[plane]) *(args->skip) = 0;
- if (!x->pvq_skip[plane])
-#endif
{
#if CONFIG_LGT_FROM_PRED
PREDICTION_MODE mode = xd->mi[0]->mbmi.mode;
@@ -849,36 +745,8 @@
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
ctx, AV1_XFORM_QUANT_B);
-#if CONFIG_PVQ
- if (!x->pvq_skip[plane]) {
- int tx_blk_size;
- int i, j;
- // transform block size in pixels
- tx_blk_size = tx_size_wide[tx_size];
-// Since av1 does not have separate function which does inverse transform
-// but av1_inv_txfm_add_*x*() also does addition of predicted image to
-// inverse transformed image,
-// pass blank dummy image to av1_inv_txfm_add_*x*(), i.e. set dst as zeros
-#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++)
- CONVERT_TO_SHORTPTR(dst)[j * pd->dst.stride + i] = 0;
- } else {
-#endif // CONFIG_HIGHBITDEPTH
- for (j = 0; j < tx_blk_size; j++)
- for (i = 0; i < tx_blk_size; i++) dst[j * pd->dst.stride + i] = 0;
-#if CONFIG_HIGHBITDEPTH
- }
-#endif // CONFIG_HIGHBITDEPTH
- }
-#endif // CONFIG_PVQ
-
-#if !CONFIG_PVQ
- if (p->eobs[block] > 0)
-#endif
- {
+ if (p->eobs[block] > 0) {
txfm_param.bd = xd->bd;
txfm_param.tx_type = DCT_DCT;
txfm_param.eob = p->eobs[block];
@@ -947,9 +815,8 @@
av1_get_entropy_contexts(bsize, tx_size, pd, ctx.ta[plane], ctx.tl[plane]);
#endif
-#if !CONFIG_PVQ
av1_subtract_plane(x, bsize, plane);
-#endif
+
arg.ta = ctx.ta[plane];
arg.tl = ctx.tl[plane];
@@ -984,7 +851,6 @@
}
}
-#if !CONFIG_PVQ
void av1_set_txb_context(MACROBLOCK *x, int plane, int block, TX_SIZE tx_size,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
(void)tx_size;
@@ -1003,7 +869,6 @@
for (i = 0; i < tx_size_high_unit[tx_size]; ++i) l[i] = l[0];
#endif
}
-#endif
static void encode_block_intra_and_set_context(int plane, int block,
int blk_row, int blk_col,
@@ -1011,13 +876,12 @@
TX_SIZE tx_size, void *arg) {
av1_encode_block_intra(plane, block, blk_row, blk_col, plane_bsize, tx_size,
arg);
-#if !CONFIG_PVQ
+
struct encode_b_args *const args = arg;
MACROBLOCK *x = args->x;
ENTROPY_CONTEXT *a = &args->ta[blk_col];
ENTROPY_CONTEXT *l = &args->tl[blk_row];
av1_set_txb_context(x, plane, block, tx_size, a, l);
-#endif
}
void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
@@ -1059,12 +923,6 @@
ctx, AV1_XFORM_QUANT_B);
}
-#if CONFIG_PVQ
- // *(args->skip) == mbmi->skip
- if (!x->pvq_skip[plane]) *(args->skip) = 0;
-
- if (x->pvq_skip[plane]) return;
-#endif // CONFIG_PVQ
av1_inverse_transform_block(xd, dqcoeff,
#if CONFIG_LGT_FROM_PRED
xd->mi[0]->mbmi.mode,
@@ -1073,11 +931,9 @@
mrc_mask,
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
tx_type, tx_size, dst, dst_stride, *eob);
-#if !CONFIG_PVQ
+
if (*eob) *(args->skip) = 0;
-#else
-// Note : *(args->skip) == mbmi->skip
-#endif
+
#if CONFIG_CFL
if (plane == AOM_PLANE_Y && xd->cfl->store_y) {
cfl_store_tx(xd, blk_row, blk_col, tx_size, plane_bsize);
@@ -1110,156 +966,3 @@
av1_foreach_transformed_block_in_plane(
xd, bsize, plane, encode_block_intra_and_set_context, &arg);
}
-
-#if CONFIG_PVQ
-PVQ_SKIP_TYPE av1_pvq_encode_helper(MACROBLOCK *x, tran_low_t *const coeff,
- tran_low_t *ref_coeff,
- tran_low_t *const dqcoeff, uint16_t *eob,
- const int16_t *quant, int plane,
- TX_SIZE tx_size, TX_TYPE tx_type, int *rate,
- int speed, PVQ_INFO *pvq_info) {
- const int tx_blk_size = tx_size_wide[tx_size];
- daala_enc_ctx *daala_enc = &x->daala_enc;
- PVQ_SKIP_TYPE ac_dc_coded;
- int coeff_shift = 3 - av1_get_tx_scale(tx_size);
- int hbd_downshift = 0;
- int rounding_mask;
- int pvq_dc_quant;
- int use_activity_masking = daala_enc->use_activity_masking;
- int tell;
- int has_dc_skip = 1;
- int i;
- int off = od_qm_offset(tx_size, plane ? 1 : 0);
-
- DECLARE_ALIGNED(16, tran_low_t, coeff_pvq[OD_TXSIZE_MAX * OD_TXSIZE_MAX]);
- DECLARE_ALIGNED(16, tran_low_t, ref_coeff_pvq[OD_TXSIZE_MAX * OD_TXSIZE_MAX]);
- DECLARE_ALIGNED(16, tran_low_t, dqcoeff_pvq[OD_TXSIZE_MAX * OD_TXSIZE_MAX]);
-
- DECLARE_ALIGNED(16, int32_t, in_int32[OD_TXSIZE_MAX * OD_TXSIZE_MAX]);
- DECLARE_ALIGNED(16, int32_t, ref_int32[OD_TXSIZE_MAX * OD_TXSIZE_MAX]);
- DECLARE_ALIGNED(16, int32_t, out_int32[OD_TXSIZE_MAX * OD_TXSIZE_MAX]);
-
- hbd_downshift = x->e_mbd.bd - 8;
-
- assert(OD_COEFF_SHIFT >= 4);
- // DC quantizer for PVQ
- if (use_activity_masking)
- pvq_dc_quant =
- OD_MAXI(1,
- (quant[0] << (OD_COEFF_SHIFT - 3) >> hbd_downshift) *
- daala_enc->state
- .pvq_qm_q4[plane][od_qm_get_index(tx_size, 0)] >>
- 4);
- else
- pvq_dc_quant =
- OD_MAXI(1, quant[0] << (OD_COEFF_SHIFT - 3) >> hbd_downshift);
-
- *eob = 0;
-
-#if !CONFIG_ANS
- tell = od_ec_enc_tell_frac(&daala_enc->w.ec);
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
-
- // Change coefficient ordering for pvq encoding.
- od_raster_to_coding_order(coeff_pvq, tx_blk_size, tx_type, coeff,
- tx_blk_size);
- od_raster_to_coding_order(ref_coeff_pvq, tx_blk_size, tx_type, ref_coeff,
- tx_blk_size);
-
- // copy int16 inputs to int32
- for (i = 0; i < tx_blk_size * tx_blk_size; i++) {
- ref_int32[i] =
- AOM_SIGNED_SHL(ref_coeff_pvq[i], OD_COEFF_SHIFT - coeff_shift) >>
- hbd_downshift;
- in_int32[i] = AOM_SIGNED_SHL(coeff_pvq[i], OD_COEFF_SHIFT - coeff_shift) >>
- hbd_downshift;
- }
-
- if (abs(in_int32[0] - ref_int32[0]) < pvq_dc_quant * 141 / 256) { /* 0.55 */
- out_int32[0] = 0;
- } else {
- out_int32[0] = OD_DIV_R0(in_int32[0] - ref_int32[0], pvq_dc_quant);
- }
-
- ac_dc_coded = od_pvq_encode(
- daala_enc, ref_int32, in_int32, out_int32,
- OD_MAXI(1,
- quant[0] << (OD_COEFF_SHIFT - 3) >>
- hbd_downshift), // scale/quantizer
- OD_MAXI(1,
- quant[1] << (OD_COEFF_SHIFT - 3) >>
- hbd_downshift), // scale/quantizer
- plane, tx_size, OD_PVQ_BETA[use_activity_masking][plane][tx_size],
- 0, // is_keyframe,
- daala_enc->state.qm + off, daala_enc->state.qm_inv + off,
- speed, // speed
- pvq_info);
-
- // Encode residue of DC coeff, if required.
- if (!has_dc_skip || out_int32[0]) {
- generic_encode(&daala_enc->w, &daala_enc->state.adapt->model_dc[plane],
- abs(out_int32[0]) - has_dc_skip,
- &daala_enc->state.adapt->ex_dc[plane][tx_size][0], 2);
- }
- if (out_int32[0]) {
- aom_write_bit(&daala_enc->w, out_int32[0] < 0);
- }
-
- // need to save quantized residue of DC coeff
- // so that final pvq bitstream writing can know whether DC is coded.
- if (pvq_info) pvq_info->dq_dc_residue = out_int32[0];
-
- out_int32[0] = out_int32[0] * pvq_dc_quant;
- out_int32[0] += 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 < tx_blk_size * tx_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);
- }
-
- // Back to original coefficient order
- od_coding_order_to_raster(dqcoeff, tx_blk_size, tx_type, dqcoeff_pvq,
- tx_blk_size);
-
- *eob = tx_blk_size * tx_blk_size;
-
-#if !CONFIG_ANS
- *rate = (od_ec_enc_tell_frac(&daala_enc->w.ec) - tell)
- << (AV1_PROB_COST_SHIFT - OD_BITRES);
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- assert(*rate >= 0);
-
- return ac_dc_coded;
-}
-
-void av1_store_pvq_enc_info(PVQ_INFO *pvq_info, int *qg, int *theta, int *k,
- od_coeff *y, int nb_bands, const int *off,
- int *size, int skip_rest, int skip_dir,
- int bs) { // block size in log_2 -2
- int i;
- const int tx_blk_size = tx_size_wide[bs];
-
- for (i = 0; i < nb_bands; i++) {
- pvq_info->qg[i] = qg[i];
- pvq_info->theta[i] = theta[i];
- pvq_info->k[i] = k[i];
- pvq_info->off[i] = off[i];
- pvq_info->size[i] = size[i];
- }
-
- memcpy(pvq_info->y, y, tx_blk_size * tx_blk_size * sizeof(od_coeff));
-
- pvq_info->nb_bands = nb_bands;
- pvq_info->skip_rest = skip_rest;
- pvq_info->skip_dir = skip_dir;
- pvq_info->bs = bs;
-}
-#endif
diff --git a/av1/encoder/encodemb.h b/av1/encoder/encodemb.h
index 1c0b66f..e68674a 100644
--- a/av1/encoder/encodemb.h
+++ b/av1/encoder/encodemb.h
@@ -60,10 +60,8 @@
void av1_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane);
-#if !CONFIG_PVQ
void av1_set_txb_context(MACROBLOCK *x, int plane, int block, TX_SIZE tx_size,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l);
-#endif
void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg);
@@ -73,19 +71,6 @@
int enable_optimize_b, int mi_row,
int mi_col);
-#if CONFIG_PVQ
-PVQ_SKIP_TYPE av1_pvq_encode_helper(MACROBLOCK *x, tran_low_t *const coeff,
- tran_low_t *ref_coeff,
- tran_low_t *const dqcoeff, uint16_t *eob,
- const int16_t *quant, int plane,
- TX_SIZE tx_size, TX_TYPE tx_type, int *rate,
- int speed, PVQ_INFO *pvq_info);
-
-void av1_store_pvq_enc_info(PVQ_INFO *pvq_info, int *qg, int *theta, int *k,
- od_coeff *y, int nb_bands, const int *off,
- int *size, int skip_rest, int skip_dir, int bs);
-#endif
-
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 41fc6b8..de0d05a 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -503,20 +503,6 @@
dealloc_context_buffers_ext(cpi);
-#if CONFIG_PVQ
- if (cpi->oxcf.pass != 1) {
- const int tile_cols = cm->tile_cols;
- const int tile_rows = cm->tile_rows;
- int tile_col, tile_row;
-
- for (tile_row = 0; tile_row < tile_rows; ++tile_row)
- for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
- TileDataEnc *tile_data =
- &cpi->tile_data[tile_row * tile_cols + tile_col];
- aom_free(tile_data->pvq_q.buf);
- }
- }
-#endif
aom_free(cpi->tile_data);
cpi->tile_data = NULL;
@@ -1072,9 +1058,6 @@
av1_set_mb_mi(cm, cm->width, cm->height);
av1_init_context_buffers(cm);
av1_init_macroblockd(cm, xd,
-#if CONFIG_PVQ
- NULL,
-#endif
#if CONFIG_CFL
&NULL_CFL,
#endif
@@ -5609,9 +5592,6 @@
num_bwd_ctxs);
av1_average_tile_loopfilter_cdfs(cpi->common.fc, tile_ctxs, cdf_ptrs,
num_bwd_ctxs);
-#if CONFIG_PVQ
- av1_average_tile_pvq_cdfs(cpi->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/encoder/encoder.h b/av1/encoder/encoder.h
index 919abd7..703b5ee 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -316,9 +316,6 @@
int mode_map[BLOCK_SIZES_ALL][MAX_MODES];
int m_search_count;
int ex_search_count;
-#if CONFIG_PVQ
- PVQ_QUEUE pvq_q;
-#endif
#if CONFIG_CFL
CFL_CTX cfl;
#endif
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index 1efaf26..d6cf18a 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -527,10 +527,6 @@
BufferPool *const pool = cm->buffer_pool;
const int qindex = find_fp_qindex(cm->bit_depth);
const int mb_scale = mi_size_wide[BLOCK_16X16];
-#if CONFIG_PVQ
- PVQ_QUEUE pvq_q;
- od_adapt_ctx pvq_context;
-#endif
int *raw_motion_err_list;
int raw_motion_err_counts = 0;
@@ -578,43 +574,10 @@
#endif // CONFIG_CFL
av1_frame_init_quantizer(cpi);
-#if CONFIG_PVQ
- // For pass 1 of 2-pass encoding, init here for PVQ for now.
- {
- pvq_q.buf_len = 5000;
- CHECK_MEM_ERROR(cm, pvq_q.buf,
- aom_malloc(pvq_q.buf_len * sizeof(PVQ_INFO)));
- pvq_q.curr_pos = 0;
- x->pvq_coded = 0;
-
- x->pvq_q = &pvq_q;
-
- // TODO(yushin): Since this init step is also called in 2nd pass,
- // or 1-pass encoding, consider factoring out it as a function.
- // TODO(yushin)
- // If activity masking is enabled, change below to OD_HVS_QM
- x->daala_enc.qm = OD_FLAT_QM; // Hard coded. Enc/dec required to sync.
- x->daala_enc.pvq_norm_lambda = OD_PVQ_LAMBDA;
- x->daala_enc.pvq_norm_lambda_dc = OD_PVQ_LAMBDA;
-
- od_init_qm(x->daala_enc.state.qm, x->daala_enc.state.qm_inv,
- x->daala_enc.qm == OD_HVS_QM ? OD_QM8_Q4_HVS : OD_QM8_Q4_FLAT);
-#if !CONFIG_ANS
- od_ec_enc_init(&x->daala_enc.w.ec, 65025);
- od_ec_enc_reset(&x->daala_enc.w.ec);
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- }
-#endif
-
for (i = 0; i < MAX_MB_PLANE; ++i) {
p[i].coeff = ctx->coeff[i];
p[i].qcoeff = ctx->qcoeff[i];
pd[i].dqcoeff = ctx->dqcoeff[i];
-#if CONFIG_PVQ
- pd[i].pvq_ref_coeff = ctx->pvq_ref_coeff[i];
-#endif
p[i].eobs = ctx->eobs[i];
#if CONFIG_LV_MAP
p[i].txb_entropy_ctx = ctx->txb_entropy_ctx[i];
@@ -630,10 +593,6 @@
av1_deliver_eob_threshold(cm, xd);
#endif
av1_convolve_init(cm);
-#if CONFIG_PVQ
- od_adapt_ctx_reset(&pvq_context, 0);
- x->daala_enc.state.adapt = &pvq_context;
-#endif // CONFIG_PVQ
av1_initialize_rd_consts(cpi);
// Tiling is ignored in the first pass.
@@ -1026,20 +985,6 @@
raw_motion_error_stdev(raw_motion_err_list, raw_motion_err_counts);
aom_free(raw_motion_err_list);
-#if CONFIG_PVQ
-#if !CONFIG_ANS
- od_ec_enc_clear(&x->daala_enc.w.ec);
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
-
- x->pvq_q->last_pos = x->pvq_q->curr_pos;
- x->pvq_q->curr_pos = 0;
- x->pvq_q = NULL;
-
- aom_free(pvq_q.buf);
-#endif
-
// Clamp the image start to rows/2. This number of rows is discarded top
// and bottom as dead data so rows / 2 means the frame is blank.
if ((image_data_start_row > cm->mb_rows / 2) ||
diff --git a/av1/encoder/generic_encoder.c b/av1/encoder/generic_encoder.c
deleted file mode 100644
index a31bb9e..0000000
--- a/av1/encoder/generic_encoder.c
+++ /dev/null
@@ -1,157 +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/bitwriter.h"
-#include "av1/common/generic_code.h"
-#include "av1/common/odintrin.h"
-#include "pvq_encoder.h"
-
-/** Encodes a value from 0 to N-1 (with N up to 16) based on a cdf and adapts
- * the cdf accordingly.
- *
- * @param [in,out] w multi-symbol entropy encoder
- * @param [in] val variable being encoded
- * @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)
- */
-void aom_encode_cdf_adapt_q15(aom_writer *w, int val, uint16_t *cdf, int n,
- int *count, int rate) {
- int i;
- if (*count == 0) {
- /* On the first call, we normalize the cdf to (32768 - n). This should
- eventually be moved to the state init, but for now it makes it much
- easier to experiment and convert symbols to the Q15 adaptation.*/
- int ft;
- ft = cdf[n - 1];
- for (i = 0; i < n; i++) {
- cdf[i] = AOM_ICDF(cdf[i]*32768/ft);
- }
- }
- aom_write_cdf(w, val, cdf, n);
- aom_cdf_adapt_q15(val, cdf, n, count, rate);
-}
-
-/** 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] w multi-symbol entropy encoder
- * @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)
- */
-void generic_encode(aom_writer *w, generic_encoder *model, int x,
- int *ex_q16, int integration) {
- int lg_q1;
- int shift;
- int id;
- uint16_t *cdf;
- int xs;
- lg_q1 = log_ex(*ex_q16);
- OD_LOG((OD_LOG_ENTROPY_CODER, OD_LOG_DEBUG,
- "%d %d", *ex_q16, lg_q1));
- /* 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 = (x + (1 << shift >> 1)) >> shift;
- aom_write_symbol_pvq(w, OD_MINI(15, xs), cdf, 16);
- 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)));
- /* Encode the tail of the distribution assuming exponential decay. */
- aom_laplace_encode_special(w, xs - 15, decay);
- }
- 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) {
- aom_write_literal(w, x - (xs << shift) + (!special << (shift - 1)),
- shift - special);
- }
- }
- generic_model_update(ex_q16, x, integration);
- OD_LOG((OD_LOG_ENTROPY_CODER, OD_LOG_DEBUG,
- "enc: %d %d %d %d %d %x", *ex_q16, x, shift, id, xs, enc->rng));
-}
-
-/** Estimates the cost of encoding a value with generic_encode().
- *
- * @param [in,out] model generic probability model
- * @param [in] x variable being encoded
- * @param [in,out] ExQ16 expectation of x (adapted)
- * @return number of bits (approximation)
- */
-double generic_encode_cost(generic_encoder *model, int x, int *ex_q16) {
- int lg_q1;
- int shift;
- int id;
- uint16_t *cdf;
- int xs;
- int extra;
- 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 = (x + (1 << shift >> 1)) >> shift;
- extra = 0;
- if (shift) extra = shift - (xs == 0);
- xs = OD_MINI(15, xs);
- /* Shortcut: assume it's going to cost 2 bits for the Laplace coder. */
- if (xs == 15) extra += 2;
- return
- extra - OD_LOG2((double)(cdf[xs] - (xs == 0 ? 0 : cdf[xs - 1]))/cdf[15]);
-}
-
-/*Estimates the cost of encoding a value with a given CDF.*/
-double od_encode_cdf_cost(int val, uint16_t *cdf, int n) {
- int total_prob;
- int prev_prob;
- double val_prob;
- OD_ASSERT(n > 0);
- total_prob = cdf[n - 1];
- if (val == 0) {
- prev_prob = 0;
- }
- else {
- prev_prob = cdf[val - 1];
- }
- val_prob = (cdf[val] - prev_prob) / (double)total_prob;
- return -OD_LOG2(val_prob);
-}
diff --git a/av1/encoder/laplace_encoder.c b/av1/encoder/laplace_encoder.c
deleted file mode 100644
index 54ffc88..0000000
--- a/av1/encoder/laplace_encoder.c
+++ /dev/null
@@ -1,107 +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/bitwriter.h"
-#include "av1/common/odintrin.h"
-#include "av1/common/pvq.h"
-#include "pvq_encoder.h"
-
-static void aom_encode_pvq_split(aom_writer *w, od_pvq_codeword_ctx *adapt,
- int count, int sum, int ctx) {
- int shift;
- int rest;
- int fctx;
- if (sum == 0) return;
- shift = OD_MAXI(0, OD_ILOG(sum) - 3);
- if (shift) {
- rest = count & ((1 << shift) - 1);
- count >>= shift;
- sum >>= shift;
- }
- fctx = 7*ctx + sum - 1;
- aom_write_symbol_pvq(w, count, adapt->pvq_split_cdf[fctx], sum + 1);
- if (shift) aom_write_literal(w, rest, shift);
-}
-
-void aom_encode_band_pvq_splits(aom_writer *w, od_pvq_codeword_ctx *adapt,
- const int *y, int n, int k, int level) {
- int mid;
- int i;
- int count_right;
- if (n <= 1 || k == 0) return;
- if (k == 1 && n <= 16) {
- int cdf_id;
- int pos;
- cdf_id = od_pvq_k1_ctx(n, level == 0);
- for (pos = 0; !y[pos]; pos++);
- OD_ASSERT(pos < n);
- aom_write_symbol_pvq(w, pos, adapt->pvq_k1_cdf[cdf_id], n);
- }
- else {
- mid = n >> 1;
- count_right = k;
- for (i = 0; i < mid; i++) count_right -= abs(y[i]);
- aom_encode_pvq_split(w, adapt, count_right, k, od_pvq_size_ctx(n));
- aom_encode_band_pvq_splits(w, adapt, y, mid, k - count_right, level + 1);
- aom_encode_band_pvq_splits(w, adapt, y + mid, n - mid, count_right,
- level + 1);
- }
-}
-
-/** Encodes the tail of a Laplace-distributed variable, i.e. it doesn't
- * do anything special for the zero case.
- *
- * @param [in,out] enc range encoder
- * @param [in] x variable to encode (has to be positive)
- * @param [in] decay decay factor of the distribution in Q8 format,
- * i.e. pdf ~= decay^x
- */
-void aom_laplace_encode_special(aom_writer *w, int x, unsigned decay) {
- 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);
- xs = x >> shift;
- cdf = EXP_CDF_TABLE[(decay + 1) >> 1];
- OD_LOG((OD_LOG_PVQ, OD_LOG_DEBUG, "decay = %d", decay));
- do {
- sym = OD_MINI(xs, 15);
- {
- int i;
- OD_LOG((OD_LOG_PVQ, OD_LOG_DEBUG, "%d %d %d %d %d\n", x, xs, shift,
- sym, max));
- 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"));
- }
- aom_write_cdf(w, sym, cdf, 16);
- xs -= 15;
- } while (sym >= 15);
- if (shift) aom_write_literal(w, x & ((1 << shift) - 1), shift);
-}
diff --git a/av1/encoder/pvq_encoder.c b/av1/encoder/pvq_encoder.c
deleted file mode 100644
index 9d51330..0000000
--- a/av1/encoder/pvq_encoder.c
+++ /dev/null
@@ -1,988 +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 <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "aom_dsp/entcode.h"
-#include "aom_dsp/entenc.h"
-#include "av1/common/blockd.h"
-#include "av1/common/odintrin.h"
-#include "av1/common/partition.h"
-#include "av1/common/pvq_state.h"
-#include "av1/encoder/encodemb.h"
-#include "av1/encoder/pvq_encoder.h"
-#include "aom_ports/system_state.h"
-
-/*Shift to ensure that the upper bound (i.e. for the max blocksize) of the
- dot-product of the 1st band of chroma with the luma ref doesn't overflow.*/
-#define OD_CFL_FLIP_SHIFT (OD_LIMIT_BSIZE_MAX + 0)
-
-void aom_write_symbol_pvq(aom_writer *w, int symb, aom_cdf_prob *cdf,
- int nsymbs) {
- if (cdf[0] == 0)
- aom_cdf_init_q15_1D(cdf, nsymbs, CDF_SIZE(nsymbs));
- aom_write_symbol(w, symb, cdf, nsymbs);
-}
-
-static void aom_encode_pvq_codeword(aom_writer *w, od_pvq_codeword_ctx *adapt,
- const od_coeff *in, int n, int k) {
- int i;
- aom_encode_band_pvq_splits(w, adapt, in, n, k, 0);
- for (i = 0; i < n; i++) if (in[i]) aom_write_bit(w, in[i] < 0);
-}
-
-/* Computes 1/sqrt(i) using a table for small values. */
-static double od_rsqrt_table(int i) {
- static double table[16] = {
- 1.000000, 0.707107, 0.577350, 0.500000,
- 0.447214, 0.408248, 0.377964, 0.353553,
- 0.333333, 0.316228, 0.301511, 0.288675,
- 0.277350, 0.267261, 0.258199, 0.250000};
- if (i <= 16) return table[i-1];
- else return 1./sqrt(i);
-}
-
-/*Computes 1/sqrt(start+2*i+1) using a lookup table containing the results
- where 0 <= i < table_size.*/
-static double od_custom_rsqrt_dynamic_table(const double* table,
- const int table_size, const double start, const int i) {
- if (i < table_size) return table[i];
- else return od_rsqrt_table((int)(start + 2*i + 1));
-}
-
-/*Fills tables used in od_custom_rsqrt_dynamic_table for a given start.*/
-static void od_fill_dynamic_rsqrt_table(double *table, const int table_size,
- const double start) {
- int i;
- for (i = 0; i < table_size; i++)
- table[i] = od_rsqrt_table((int)(start + 2*i + 1));
-}
-
-/** Find the codepoint on the given PSphere closest to the desired
- * vector. Double-precision PVQ search just to make sure our tests
- * aren't limited by numerical accuracy.
- *
- * @param [in] xcoeff input vector to quantize (x in the math doc)
- * @param [in] n number of dimensions
- * @param [in] k number of pulses
- * @param [out] ypulse optimal codevector found (y in the math doc)
- * @param [out] g2 multiplier for the distortion (typically squared
- * gain units)
- * @param [in] pvq_norm_lambda enc->pvq_norm_lambda for quantized RDO
- * @param [in] prev_k number of pulses already in ypulse that we should
- * reuse for the search (or 0 for a new search)
- * @return cosine distance between x and y (between 0 and 1)
- */
-double pvq_search_rdo_double_c(const od_val16 *xcoeff, int n, int k,
- od_coeff *ypulse, double g2, double pvq_norm_lambda, int prev_k) {
- int i, j;
- double xy;
- double yy;
- /* TODO - This blows our 8kB stack space budget and should be fixed when
- converting PVQ to fixed point. */
- double x[MAXN];
- double xx;
- double lambda;
- double norm_1;
- int rdo_pulses;
- double delta_rate;
- xx = xy = yy = 0;
- for (j = 0; j < n; j++) {
- x[j] = fabs((float)xcoeff[j]);
- xx += x[j]*x[j];
- }
- norm_1 = 1./sqrt(1e-30 + xx);
- lambda = pvq_norm_lambda/(1e-30 + g2);
- i = 0;
- if (prev_k > 0 && prev_k <= k) {
- /* We reuse pulses from a previous search so we don't have to search them
- again. */
- for (j = 0; j < n; j++) {
- ypulse[j] = abs(ypulse[j]);
- xy += x[j]*ypulse[j];
- yy += ypulse[j]*ypulse[j];
- i += ypulse[j];
- }
- }
- else if (k > 2) {
- double l1_norm;
- double l1_inv;
- l1_norm = 0;
- for (j = 0; j < n; j++) l1_norm += x[j];
- l1_inv = 1./OD_MAXF(l1_norm, 1e-100);
- for (j = 0; j < n; j++) {
- double tmp;
- tmp = k*x[j]*l1_inv;
- ypulse[j] = OD_MAXI(0, (int)floor(tmp));
- xy += x[j]*ypulse[j];
- yy += ypulse[j]*ypulse[j];
- i += ypulse[j];
- }
- }
- else OD_CLEAR(ypulse, n);
-
- /* Only use RDO on the last few pulses. This not only saves CPU, but using
- RDO on all pulses actually makes the results worse for reasons I don't
- fully understand. */
- rdo_pulses = 1 + k/4;
- /* Rough assumption for now, the last position costs about 3 bits more than
- the first. */
- delta_rate = 3./n;
- /* Search one pulse at a time */
- for (; i < k - rdo_pulses; i++) {
- int pos;
- double best_xy;
- double best_yy;
- pos = 0;
- best_xy = -10;
- best_yy = 1;
- for (j = 0; j < n; j++) {
- double tmp_xy;
- double tmp_yy;
- tmp_xy = xy + x[j];
- tmp_yy = yy + 2*ypulse[j] + 1;
- tmp_xy *= tmp_xy;
- if (j == 0 || tmp_xy*best_yy > best_xy*tmp_yy) {
- best_xy = tmp_xy;
- best_yy = tmp_yy;
- pos = j;
- }
- }
- xy = xy + x[pos];
- yy = yy + 2*ypulse[pos] + 1;
- ypulse[pos]++;
- }
- /* Search last pulses with RDO. Distortion is D = (x-y)^2 = x^2 - 2*x*y + y^2
- and since x^2 and y^2 are constant, we just maximize x*y, plus a
- lambda*rate term. Note that since x and y aren't normalized here,
- we need to divide by sqrt(x^2)*sqrt(y^2). */
- for (; i < k; i++) {
- double rsqrt_table[4];
- int rsqrt_table_size = 4;
- int pos;
- double best_cost;
- pos = 0;
- best_cost = -1e5;
- /*Fill the small rsqrt lookup table with inputs relative to yy.
- Specifically, the table of n values is filled with
- rsqrt(yy + 1), rsqrt(yy + 2 + 1) .. rsqrt(yy + 2*(n-1) + 1).*/
- od_fill_dynamic_rsqrt_table(rsqrt_table, rsqrt_table_size, yy);
- for (j = 0; j < n; j++) {
- double tmp_xy;
- double tmp_yy;
- tmp_xy = xy + x[j];
- /*Calculate rsqrt(yy + 2*ypulse[j] + 1) using an optimized method.*/
- tmp_yy = od_custom_rsqrt_dynamic_table(rsqrt_table, rsqrt_table_size,
- yy, ypulse[j]);
- tmp_xy = 2*tmp_xy*norm_1*tmp_yy - lambda*j*delta_rate;
- if (j == 0 || tmp_xy > best_cost) {
- best_cost = tmp_xy;
- pos = j;
- }
- }
- xy = xy + x[pos];
- yy = yy + 2*ypulse[pos] + 1;
- ypulse[pos]++;
- }
- for (i = 0; i < n; i++) {
- if (xcoeff[i] < 0) ypulse[i] = -ypulse[i];
- }
- return xy/(1e-100 + sqrt(xx*yy));
-}
-
-/** Encodes the gain so that the return value increases with the
- * distance |x-ref|, so that we can encode a zero when x=ref. The
- * value x=0 is not covered because it is only allowed in the noref
- * case.
- *
- * @param [in] x quantized gain to encode
- * @param [in] ref quantized gain of the reference
- * @return interleave-encoded quantized gain value
- */
-static int neg_interleave(int x, int ref) {
- if (x < ref) return -2*(x - ref) - 1;
- else if (x < 2*ref) return 2*(x - ref);
- else return x-1;
-}
-
-int od_vector_is_null(const od_coeff *x, int len) {
- int i;
- for (i = 0; i < len; i++) if (x[i]) return 0;
- return 1;
-}
-
-static double od_pvq_rate(int qg, int icgr, int theta, int ts,
- const od_adapt_ctx *adapt, const od_coeff *y0, int k, int n, int speed) {
- double rate;
- if (k == 0) rate = 0;
- else if (speed > 0) {
- int i;
- int sum;
- double f;
- /* Compute "center of mass" of the pulse vector. */
- sum = 0;
- for (i = 0; i < n - (theta != -1); i++) sum += i*abs(y0[i]);
- f = sum/(double)(k*n);
- /* Estimates the number of bits it will cost to encode K pulses in
- N dimensions based on hand-tuned fit for bitrate vs K, N and
- "center of mass". */
- rate = (1 + .4*f)*n*OD_LOG2(1 + OD_MAXF(0, log(n*2*(1*f + .025))*k/n)) + 3;
- }
- else {
- aom_writer w;
- od_pvq_codeword_ctx cd;
- int tell;
-#if !CONFIG_ANS
- od_ec_enc_init(&w.ec, 1000);
-#else
-# error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- OD_COPY(&cd, &adapt->pvq.pvq_codeword_ctx, 1);
-#if !CONFIG_ANS
- tell = od_ec_enc_tell_frac(&w.ec);
-#else
-# error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- aom_encode_pvq_codeword(&w, &cd, y0, n - (theta != -1), k);
-#if !CONFIG_ANS
- rate = (od_ec_enc_tell_frac(&w.ec)-tell)/8.;
- od_ec_enc_clear(&w.ec);
-#else
-# error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- }
- if (qg > 0 && theta >= 0) {
- /* Approximate cost of entropy-coding theta */
- rate += .9*OD_LOG2(ts);
- if (qg == icgr) rate -= .5;
- }
- return rate;
-}
-
-#define MAX_PVQ_ITEMS (20)
-/* This stores the information about a PVQ search candidate, so we can sort
- based on K. */
-typedef struct {
- int gain;
- int k;
- od_val32 qtheta;
- int theta;
- int ts;
- od_val32 qcg;
-} pvq_search_item;
-
-int items_compare(pvq_search_item *a, pvq_search_item *b) {
- /* Break ties in K with gain to ensure a stable sort.
- Otherwise, the order depends on qsort implementation. */
- return a->k == b->k ? a->gain - b->gain : a->k - b->k;
-}
-
-/** Perform PVQ quantization with prediction, trying several
- * possible gains and angles. See draft-valin-videocodec-pvq and
- * http://jmvalin.ca/slides/pvq.pdf for more details.
- *
- * @param [out] out coefficients after quantization
- * @param [in] x0 coefficients before quantization
- * @param [in] r0 reference, aka predicted coefficients
- * @param [in] n number of dimensions
- * @param [in] q0 quantization step size
- * @param [out] y pulse vector (i.e. selected PVQ codevector)
- * @param [out] itheta angle between input and reference (-1 if noref)
- * @param [out] vk total number of pulses
- * @param [in] beta per-band activity masking beta param
- * @param [out] skip_diff distortion cost of skipping this block
- * (accumulated)
- * @param [in] is_keyframe whether we're encoding a keyframe
- * @param [in] pli plane index
- * @param [in] adapt probability adaptation context
- * @param [in] qm QM with magnitude compensation
- * @param [in] qm_inv Inverse of QM with magnitude compensation
- * @param [in] pvq_norm_lambda enc->pvq_norm_lambda for quantized RDO
- * @param [in] speed Make search faster by making approximations
- * @return gain index of the quatized gain
-*/
-static int pvq_theta(od_coeff *out, const od_coeff *x0, const od_coeff *r0,
- int n, int q0, od_coeff *y, int *itheta, int *vk,
- od_val16 beta, double *skip_diff, int is_keyframe, int pli,
- const od_adapt_ctx *adapt, const int16_t *qm, const int16_t *qm_inv,
- double pvq_norm_lambda, int speed) {
- od_val32 g;
- od_val32 gr;
- od_coeff y_tmp[MAXN + 3];
- int i;
- /* Number of pulses. */
- int k;
- /* Companded gain of x and reference, normalized to q. */
- od_val32 cg;
- od_val32 cgr;
- int icgr;
- int qg;
- /* Best RDO cost (D + lamdba*R) so far. */
- double best_cost;
- double dist0;
- /* Distortion (D) that corresponds to the best RDO cost. */
- double best_dist;
- double dist;
- /* Sign of Householder reflection. */
- int s;
- /* Dimension on which Householder reflects. */
- int m;
- od_val32 theta;
- double corr;
- int best_k;
- od_val32 best_qtheta;
- od_val32 gain_offset;
- int noref;
- double skip_dist;
- int cfl_enabled;
- int skip;
- double gain_weight;
- od_val16 x16[MAXN];
- od_val16 r16[MAXN];
- int xshift;
- int rshift;
- /* Give more weight to gain error when calculating the total distortion. */
- gain_weight = 1.0;
- OD_ASSERT(n > 1);
- corr = 0;
-#if !defined(OD_FLOAT_PVQ)
- /* Shift needed to make x fit in 16 bits even after rotation.
- This shift value is not normative (it can be changed without breaking
- the bitstream) */
- xshift = OD_MAXI(0, od_vector_log_mag(x0, n) - 15);
- /* Shift needed to make the reference fit in 15 bits, so that the Householder
- vector can fit in 16 bits.
- This shift value *is* normative, and has to match the decoder. */
- rshift = OD_MAXI(0, od_vector_log_mag(r0, n) - 14);
-#else
- xshift = 0;
- rshift = 0;
-#endif
- for (i = 0; i < n; i++) {
-#if defined(OD_FLOAT_PVQ)
- /*This is slightly different from the original float PVQ code,
- where the qm was applied in the accumulation in od_pvq_compute_gain and
- the vectors were od_coeffs, not od_val16 (i.e. double).*/
- x16[i] = x0[i]*(double)qm[i]*OD_QM_SCALE_1;
- r16[i] = r0[i]*(double)qm[i]*OD_QM_SCALE_1;
-#else
- x16[i] = OD_SHR_ROUND(x0[i]*qm[i], OD_QM_SHIFT + xshift);
- r16[i] = OD_SHR_ROUND(r0[i]*qm[i], OD_QM_SHIFT + rshift);
-#endif
- corr += OD_MULT16_16(x16[i], r16[i]);
- }
- cfl_enabled = is_keyframe && pli != 0 && !OD_DISABLE_CFL;
- cg = od_pvq_compute_gain(x16, n, q0, &g, beta, xshift);
- cgr = od_pvq_compute_gain(r16, n, q0, &gr, beta, rshift);
- if (cfl_enabled) cgr = OD_CGAIN_SCALE;
- /* gain_offset is meant to make sure one of the quantized gains has
- exactly the same gain as the reference. */
-#if defined(OD_FLOAT_PVQ)
- icgr = (int)floor(.5 + cgr);
-#else
- icgr = OD_SHR_ROUND(cgr, OD_CGAIN_SHIFT);
-#endif
- gain_offset = cgr - OD_SHL(icgr, OD_CGAIN_SHIFT);
- /* Start search with null case: gain=0, no pulse. */
- qg = 0;
- dist = gain_weight*cg*cg*OD_CGAIN_SCALE_2;
- best_dist = dist;
- best_cost = dist + pvq_norm_lambda*od_pvq_rate(0, 0, -1, 0, adapt, NULL, 0,
- n, speed);
- noref = 1;
- best_k = 0;
- *itheta = -1;
- OD_CLEAR(y, n);
- best_qtheta = 0;
- m = 0;
- s = 1;
- corr = corr/(1e-100 + g*(double)gr/OD_SHL(1, xshift + rshift));
- corr = OD_MAXF(OD_MINF(corr, 1.), -1.);
- if (is_keyframe) skip_dist = gain_weight*cg*cg*OD_CGAIN_SCALE_2;
- else {
- skip_dist = gain_weight*(cg - cgr)*(cg - cgr)
- + cgr*(double)cg*(2 - 2*corr);
- skip_dist *= OD_CGAIN_SCALE_2;
- }
- if (!is_keyframe) {
- /* noref, gain=0 isn't allowed, but skip is allowed. */
- od_val32 scgr;
- scgr = OD_MAXF(0,gain_offset);
- if (icgr == 0) {
- best_dist = gain_weight*(cg - scgr)*(cg - scgr)
- + scgr*(double)cg*(2 - 2*corr);
- best_dist *= OD_CGAIN_SCALE_2;
- }
- best_cost = best_dist + pvq_norm_lambda*od_pvq_rate(0, icgr, 0, 0, adapt,
- NULL, 0, n, speed);
- best_qtheta = 0;
- *itheta = 0;
- noref = 0;
- }
- dist0 = best_dist;
- if (n <= OD_MAX_PVQ_SIZE && !od_vector_is_null(r0, n) && corr > 0) {
- od_val16 xr[MAXN];
- int gain_bound;
- int prev_k;
- pvq_search_item items[MAX_PVQ_ITEMS];
- int idx;
- int nitems;
- double cos_dist;
- idx = 0;
- gain_bound = OD_SHR(cg - gain_offset, OD_CGAIN_SHIFT);
- /* Perform theta search only if prediction is useful. */
- theta = OD_ROUND32(OD_THETA_SCALE*acos(corr));
- m = od_compute_householder(r16, n, gr, &s, rshift);
- od_apply_householder(xr, x16, r16, n);
- prev_k = 0;
- for (i = m; i < n - 1; i++) xr[i] = xr[i + 1];
- /* Compute all candidate PVQ searches within a reasonable range of gain
- and theta. */
- for (i = OD_MAXI(1, gain_bound - 1); i <= gain_bound + 1; i++) {
- int j;
- od_val32 qcg;
- int ts;
- int theta_lower;
- int theta_upper;
- /* Quantized companded gain */
- qcg = OD_SHL(i, OD_CGAIN_SHIFT) + gain_offset;
- /* Set angular resolution (in ra) to match the encoded gain */
- ts = od_pvq_compute_max_theta(qcg, beta);
- theta_lower = OD_MAXI(0, (int)floor(.5 +
- theta*OD_THETA_SCALE_1*2/M_PI*ts) - 2);
- theta_upper = OD_MINI(ts - 1, (int)ceil(theta*OD_THETA_SCALE_1*2/M_PI*ts));
- /* Include the angles within a reasonable range. */
- for (j = theta_lower; j <= theta_upper; j++) {
- od_val32 qtheta;
- qtheta = od_pvq_compute_theta(j, ts);
- k = od_pvq_compute_k(qcg, j, 0, n, beta);
- items[idx].gain = i;
- items[idx].theta = j;
- items[idx].k = k;
- items[idx].qcg = qcg;
- items[idx].qtheta = qtheta;
- items[idx].ts = ts;
- idx++;
- OD_ASSERT(idx < MAX_PVQ_ITEMS);
- }
- }
- nitems = idx;
- cos_dist = 0;
- /* Sort PVQ search candidates in ascending order of pulses K so that
- we can reuse all the previously searched pulses across searches. */
- qsort(items, nitems, sizeof(items[0]),
- (int (*)(const void *, const void *))items_compare);
- /* Search for the best gain/theta in order. */
- for (idx = 0; idx < nitems; idx++) {
- int j;
- od_val32 qcg;
- int ts;
- double cost;
- double dist_theta;
- double sin_prod;
- od_val32 qtheta;
- /* Quantized companded gain */
- qcg = items[idx].qcg;
- i = items[idx].gain;
- j = items[idx].theta;
- /* Set angular resolution (in ra) to match the encoded gain */
- ts = items[idx].ts;
- /* Search for the best angle within a reasonable range. */
- qtheta = items[idx].qtheta;
- k = items[idx].k;
- /* Compute the minimal possible distortion by not taking the PVQ
- cos_dist into account. */
- dist_theta = 2 - 2.*od_pvq_cos(theta - qtheta)*OD_TRIG_SCALE_1;
- dist = gain_weight*(qcg - cg)*(qcg - cg) + qcg*(double)cg*dist_theta;
- dist *= OD_CGAIN_SCALE_2;
- /* If we have no hope of beating skip (including a 1-bit worst-case
- penalty), stop now. */
- if (dist > dist0 + 1.0*pvq_norm_lambda && k != 0) continue;
- sin_prod = od_pvq_sin(theta)*OD_TRIG_SCALE_1*od_pvq_sin(qtheta)*
- OD_TRIG_SCALE_1;
- /* PVQ search, using a gain of qcg*cg*sin(theta)*sin(qtheta) since
- that's the factor by which cos_dist is multiplied to get the
- distortion metric. */
- if (k == 0) {
- cos_dist = 0;
- OD_CLEAR(y_tmp, n-1);
- }
- else if (k != prev_k) {
- cos_dist = pvq_search_rdo_double(xr, n - 1, k, y_tmp,
- qcg*(double)cg*sin_prod*OD_CGAIN_SCALE_2, pvq_norm_lambda, prev_k);
- }
- prev_k = k;
- /* See Jmspeex' Journal of Dubious Theoretical Results. */
- dist_theta = 2 - 2.*od_pvq_cos(theta - qtheta)*OD_TRIG_SCALE_1
- + sin_prod*(2 - 2*cos_dist);
- dist = gain_weight*(qcg - cg)*(qcg - cg) + qcg*(double)cg*dist_theta;
- dist *= OD_CGAIN_SCALE_2;
- /* Do approximate RDO. */
- cost = dist + pvq_norm_lambda*od_pvq_rate(i, icgr, j, ts, adapt, y_tmp,
- k, n, speed);
- if (cost < best_cost) {
- best_cost = cost;
- best_dist = dist;
- qg = i;
- best_k = k;
- best_qtheta = qtheta;
- *itheta = j;
- noref = 0;
- OD_COPY(y, y_tmp, n - 1);
- }
- }
- }
- /* Don't bother with no-reference version if there's a reasonable
- correlation. */
- if (n <= OD_MAX_PVQ_SIZE && (corr < .5
- || cg < (od_val32)(OD_SHL(2, OD_CGAIN_SHIFT)))) {
- int gain_bound;
- int prev_k;
- gain_bound = OD_SHR(cg, OD_CGAIN_SHIFT);
- prev_k = 0;
- /* Search for the best gain (haven't determined reasonable range yet). */
- for (i = OD_MAXI(1, gain_bound); i <= gain_bound + 1; i++) {
- double cos_dist;
- double cost;
- od_val32 qcg;
- qcg = OD_SHL(i, OD_CGAIN_SHIFT);
- k = od_pvq_compute_k(qcg, -1, 1, n, beta);
- /* Compute the minimal possible distortion by not taking the PVQ
- cos_dist into account. */
- dist = gain_weight*(qcg - cg)*(qcg - cg);
- dist *= OD_CGAIN_SCALE_2;
- if (dist > dist0 && k != 0) continue;
- cos_dist = pvq_search_rdo_double(x16, n, k, y_tmp,
- qcg*(double)cg*OD_CGAIN_SCALE_2, pvq_norm_lambda, prev_k);
- prev_k = k;
- /* See Jmspeex' Journal of Dubious Theoretical Results. */
- dist = gain_weight*(qcg - cg)*(qcg - cg)
- + qcg*(double)cg*(2 - 2*cos_dist);
- dist *= OD_CGAIN_SCALE_2;
- /* Do approximate RDO. */
- cost = dist + pvq_norm_lambda*od_pvq_rate(i, 0, -1, 0, adapt, y_tmp, k,
- n, speed);
- if (cost <= best_cost) {
- best_cost = cost;
- best_dist = dist;
- qg = i;
- noref = 1;
- best_k = k;
- *itheta = -1;
- OD_COPY(y, y_tmp, n);
- }
- }
- }
- k = best_k;
- theta = best_qtheta;
- skip = 0;
- if (noref) {
- if (qg == 0) skip = OD_PVQ_SKIP_ZERO;
- }
- else {
- if (!is_keyframe && qg == 0) {
- skip = (icgr ? OD_PVQ_SKIP_ZERO : OD_PVQ_SKIP_COPY);
- }
- if (qg == icgr && *itheta == 0 && !cfl_enabled) skip = OD_PVQ_SKIP_COPY;
- }
- /* Synthesize like the decoder would. */
- if (skip) {
- if (skip == OD_PVQ_SKIP_COPY) OD_COPY(out, r0, n);
- else OD_CLEAR(out, n);
- }
- else {
- if (noref) gain_offset = 0;
- g = od_gain_expand(OD_SHL(qg, OD_CGAIN_SHIFT) + gain_offset, q0, beta);
- od_pvq_synthesis_partial(out, y, r16, n, noref, g, theta, m, s,
- qm_inv);
- }
- *vk = k;
- *skip_diff += skip_dist - best_dist;
- /* Encode gain differently depending on whether we use prediction or not.
- Special encoding on inter frames where qg=0 is allowed for noref=0
- but not noref=1.*/
- if (is_keyframe) return noref ? qg : neg_interleave(qg, icgr);
- else return noref ? qg - 1 : neg_interleave(qg + 1, icgr + 1);
-}
-
-/** Encodes a single vector of integers (eg, a partition within a
- * coefficient block) using PVQ
- *
- * @param [in,out] w multi-symbol entropy encoder
- * @param [in] qg quantized gain
- * @param [in] theta quantized post-prediction theta
- * @param [in] in coefficient vector to code
- * @param [in] n number of coefficients in partition
- * @param [in] k number of pulses in partition
- * @param [in,out] model entropy encoder state
- * @param [in,out] adapt adaptation context
- * @param [in,out] exg ExQ16 expectation of gain value
- * @param [in,out] ext ExQ16 expectation of theta value
- * @param [in] cdf_ctx selects which cdf context to use
- * @param [in] is_keyframe whether we're encoding a keyframe
- * @param [in] code_skip whether the "skip rest" flag is allowed
- * @param [in] skip_rest when set, we skip all higher bands
- * @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(aom_writer *w,
- int qg,
- int theta,
- const od_coeff *in,
- int n,
- int k,
- generic_encoder model[3],
- od_adapt_ctx *adapt,
- int *exg,
- int *ext,
- int cdf_ctx,
- int is_keyframe,
- int code_skip,
- int skip_rest,
- int encode_flip,
- int flip) {
- int noref;
- int id;
- noref = (theta == -1);
- id = (qg > 0) + 2*OD_MINI(theta + 1,3) + 8*code_skip*skip_rest;
- if (is_keyframe) {
- OD_ASSERT(id != 8);
- if (id >= 8) id--;
- }
- else {
- OD_ASSERT(id != 10);
- if (id >= 10) id--;
- }
- /* Jointly code gain, theta and noref for small values. Then we handle
- larger gain and theta values. For noref, theta = -1. */
- aom_write_symbol_pvq(w, id, &adapt->pvq.pvq_gaintheta_cdf[cdf_ctx][0],
- 8 + 7*code_skip);
- 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. */
- aom_write_bit(w, flip);
- }
- if (qg > 0) {
- int tmp;
- tmp = *exg;
- generic_encode(w, &model[!noref], qg - 1, &tmp, 2);
- OD_IIR_DIADIC(*exg, qg << 16, 2);
- }
- if (theta > 1) {
- int tmp;
- tmp = *ext;
- generic_encode(w, &model[2], theta - 2, &tmp, 2);
- OD_IIR_DIADIC(*ext, theta << 16, 2);
- }
- aom_encode_pvq_codeword(w, &adapt->pvq.pvq_codeword_ctx, in,
- n - (theta != -1), k);
-}
-
-/** Quantizes a scalar with rate-distortion optimization (RDO)
- * @param [in] x unquantized value
- * @param [in] q quantization step size
- * @param [in] delta0 rate increase for encoding a 1 instead of a 0
- * @param [in] pvq_norm_lambda enc->pvq_norm_lambda for quantized RDO
- * @retval quantized value
- */
-int od_rdo_quant(od_coeff x, int q, double delta0, double pvq_norm_lambda) {
- int n;
- /* Optimal quantization threshold is 1/2 + lambda*delta_rate/2. See
- Jmspeex' Journal of Dubious Theoretical Results for details. */
- n = OD_DIV_R0(abs(x), q);
- if ((double)abs(x)/q < (double)n/2 + pvq_norm_lambda*delta0/(2*n)) {
- return 0;
- }
- else {
- return OD_DIV_R0(x, q);
- }
-}
-
-/** Encode a coefficient block (excepting DC) using PVQ
- *
- * @param [in,out] enc daala encoder context
- * @param [in] ref 'reference' (prediction) vector
- * @param [in] in coefficient block to quantize and encode
- * @param [out] out quantized coefficient block
- * @param [in] q0 scale/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 [in] qm QM with magnitude compensation
- * @param [in] qm_inv Inverse of QM with magnitude compensation
- * @param [in] speed Make search faster by making approximations
- * @param [in] pvq_info If null, conisdered as RDO search mode
- * @return Returns block skip info indicating whether DC/AC are coded.
- * bit0: DC is coded, bit1: AC is coded (1 means coded)
- *
- */
-PVQ_SKIP_TYPE od_pvq_encode(daala_enc_ctx *enc,
- od_coeff *ref,
- const od_coeff *in,
- od_coeff *out,
- int q_dc,
- int q_ac,
- int pli,
- int bs,
- const od_val16 *beta,
- int is_keyframe,
- const int16_t *qm,
- const int16_t *qm_inv,
- int speed,
- PVQ_INFO *pvq_info){
- int theta[PVQ_MAX_PARTITIONS];
- int qg[PVQ_MAX_PARTITIONS];
- int k[PVQ_MAX_PARTITIONS];
- od_coeff y[OD_TXSIZE_MAX*OD_TXSIZE_MAX];
- int *exg;
- int *ext;
- int nb_bands;
- int i;
- const int *off;
- int size[PVQ_MAX_PARTITIONS];
- generic_encoder *model;
- double skip_diff;
- int tell;
- uint16_t *skip_cdf;
- od_rollback_buffer buf;
- int dc_quant;
- int flip;
- int cfl_encoded;
- int skip_rest;
- int skip_dir;
- int skip_theta_value;
- const unsigned char *pvq_qm;
- double dc_rate;
- int use_masking;
- PVQ_SKIP_TYPE ac_dc_coded;
-
- aom_clear_system_state();
-
- use_masking = enc->use_activity_masking;
-
- if (use_masking)
- pvq_qm = &enc->state.pvq_qm_q4[pli][0];
- else
- pvq_qm = 0;
-
- exg = &enc->state.adapt->pvq.pvq_exg[pli][bs][0];
- ext = enc->state.adapt->pvq.pvq_ext + bs*PVQ_MAX_PARTITIONS;
- skip_cdf = enc->state.adapt->skip_cdf[2*bs + (pli != 0)];
- model = enc->state.adapt->pvq.pvq_param_model;
- nb_bands = OD_BAND_OFFSETS[bs][0];
- off = &OD_BAND_OFFSETS[bs][1];
-
- if (use_masking)
- dc_quant = OD_MAXI(1, q_dc * pvq_qm[od_qm_get_index(bs, 0)] >> 4);
- else
- dc_quant = OD_MAXI(1, q_dc);
-
- tell = 0;
- for (i = 0; i < nb_bands; i++) size[i] = off[i+1] - off[i];
- skip_diff = 0;
- flip = 0;
- /*If we are coding a chroma block of a keyframe, we are doing CfL.*/
- if (pli != 0 && is_keyframe) {
- od_val32 xy;
- xy = 0;
- /*Compute the dot-product of the first band of chroma with the luma ref.*/
- for (i = off[0]; i < off[1]; i++) {
-#if defined(OD_FLOAT_PVQ)
- xy += ref[i]*(double)qm[i]*OD_QM_SCALE_1*
- (double)in[i]*(double)qm[i]*OD_QM_SCALE_1;
-#else
- od_val32 rq;
- od_val32 inq;
- rq = ref[i]*qm[i];
- inq = in[i]*qm[i];
- xy += OD_SHR(rq*(int64_t)inq, OD_SHL(OD_QM_SHIFT + OD_CFL_FLIP_SHIFT,
- 1));
-#endif
- }
- /*If cos(theta) < 0, then |theta| > pi/2 and we should negate the ref.*/
- if (xy < 0) {
- flip = 1;
- for(i = off[0]; i < off[nb_bands]; i++) ref[i] = -ref[i];
- }
- }
- for (i = 0; i < nb_bands; i++) {
- int q;
-
- if (use_masking)
- q = OD_MAXI(1, q_ac * pvq_qm[od_qm_get_index(bs, i + 1)] >> 4);
- else
- q = OD_MAXI(1, q_ac);
-
- qg[i] = pvq_theta(out + off[i], in + off[i], ref + off[i], size[i],
- q, y + off[i], &theta[i], &k[i], beta[i], &skip_diff, is_keyframe,
- pli, enc->state.adapt, qm + off[i], qm_inv + off[i],
- enc->pvq_norm_lambda, speed);
- }
- od_encode_checkpoint(enc, &buf);
- if (is_keyframe) out[0] = 0;
- else {
- int n;
- n = OD_DIV_R0(abs(in[0] - ref[0]), dc_quant);
- if (n == 0) {
- out[0] = 0;
- } else {
- int tell2;
- od_rollback_buffer dc_buf;
-
- dc_rate = -OD_LOG2((double)(OD_ICDF(skip_cdf[3]) - OD_ICDF(skip_cdf[2]))/
- (double)(OD_ICDF(skip_cdf[2]) - OD_ICDF(skip_cdf[1])));
- dc_rate += 1;
-
-#if !CONFIG_ANS
- tell2 = od_ec_enc_tell_frac(&enc->w.ec);
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- od_encode_checkpoint(enc, &dc_buf);
- generic_encode(&enc->w, &enc->state.adapt->model_dc[pli],
- n - 1, &enc->state.adapt->ex_dc[pli][bs][0], 2);
-#if !CONFIG_ANS
- tell2 = od_ec_enc_tell_frac(&enc->w.ec) - tell2;
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- dc_rate += tell2/8.0;
- od_encode_rollback(enc, &dc_buf);
-
- out[0] = od_rdo_quant(in[0] - ref[0], dc_quant, dc_rate,
- enc->pvq_norm_lambda);
- }
- }
-#if !CONFIG_ANS
- tell = od_ec_enc_tell_frac(&enc->w.ec);
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- /* Code as if we're not skipping. */
- aom_write_symbol(&enc->w, 2 + (out[0] != 0), skip_cdf, 4);
- ac_dc_coded = AC_CODED + (out[0] != 0);
- cfl_encoded = 0;
- skip_rest = 1;
- skip_theta_value = is_keyframe ? -1 : 0;
- for (i = 1; i < nb_bands; i++) {
- if (theta[i] != skip_theta_value || qg[i]) skip_rest = 0;
- }
- skip_dir = 0;
- if (nb_bands > 1) {
- for (i = 0; i < 3; i++) {
- int j;
- int tmp;
- tmp = 1;
- // ToDo(yaowu): figure out better stop condition without gcc warning.
- for (j = i + 1; j < nb_bands && j < PVQ_MAX_PARTITIONS; j += 3) {
- if (theta[j] != skip_theta_value || qg[j]) tmp = 0;
- }
- skip_dir |= tmp << i;
- }
- }
- if (theta[0] == skip_theta_value && qg[0] == 0 && skip_rest) nb_bands = 0;
-
- /* NOTE: There was no other better place to put this function. */
- if (pvq_info)
- av1_store_pvq_enc_info(pvq_info, qg, theta, k, y, nb_bands, off, size,
- skip_rest, skip_dir, bs);
-
- for (i = 0; i < nb_bands; i++) {
- int encode_flip;
- /* 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))))) {
- pvq_encode_partition(&enc->w, qg[i], theta[i], y + off[i],
- size[i], k[i], model, enc->state.adapt, exg + i, ext + i,
- (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);
- }
- if (i == 0 && !skip_rest && bs > 0) {
- aom_write_symbol(&enc->w, skip_dir,
- &enc->state.adapt->pvq.pvq_skip_dir_cdf[(pli != 0) + 2*(bs - 1)][0], 7);
- }
- if (encode_flip) cfl_encoded = 1;
- }
-#if !CONFIG_ANS
- tell = od_ec_enc_tell_frac(&enc->w.ec) - tell;
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- /* Account for the rate of skipping the AC, based on the same DC decision
- we made when trying to not skip AC. */
- {
- double skip_rate;
- if (out[0] != 0) {
- skip_rate = -OD_LOG2((OD_ICDF(skip_cdf[1]) - OD_ICDF(skip_cdf[0]))/
- (double)OD_ICDF(skip_cdf[3]));
- }
- else {
- skip_rate = -OD_LOG2(OD_ICDF(skip_cdf[0])/
- (double)OD_ICDF(skip_cdf[3]));
- }
- tell -= (int)floor(.5+8*skip_rate);
- }
- if (nb_bands == 0 || skip_diff <= enc->pvq_norm_lambda/8*tell) {
- if (is_keyframe) out[0] = 0;
- else {
- int n;
- n = OD_DIV_R0(abs(in[0] - ref[0]), dc_quant);
- if (n == 0) {
- out[0] = 0;
- } else {
- int tell2;
- od_rollback_buffer dc_buf;
-
- dc_rate = -OD_LOG2((double)(OD_ICDF(skip_cdf[1]) - OD_ICDF(skip_cdf[0]))/
- (double)OD_ICDF(skip_cdf[0]));
- dc_rate += 1;
-
-#if !CONFIG_ANS
- tell2 = od_ec_enc_tell_frac(&enc->w.ec);
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- od_encode_checkpoint(enc, &dc_buf);
- generic_encode(&enc->w, &enc->state.adapt->model_dc[pli],
- n - 1, &enc->state.adapt->ex_dc[pli][bs][0], 2);
-#if !CONFIG_ANS
- tell2 = od_ec_enc_tell_frac(&enc->w.ec) - tell2;
-#else
-#error "CONFIG_PVQ currently requires !CONFIG_ANS."
-#endif
- dc_rate += tell2/8.0;
- od_encode_rollback(enc, &dc_buf);
-
- out[0] = od_rdo_quant(in[0] - ref[0], dc_quant, dc_rate,
- enc->pvq_norm_lambda);
- }
- }
- /* We decide to skip, roll back everything as it was before. */
- od_encode_rollback(enc, &buf);
- aom_write_symbol(&enc->w, out[0] != 0, skip_cdf, 4);
- ac_dc_coded = (out[0] != 0);
- 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];
- }
- if (pvq_info)
- pvq_info->ac_dc_coded = ac_dc_coded;
- return ac_dc_coded;
-}
diff --git a/av1/encoder/pvq_encoder.h b/av1/encoder/pvq_encoder.h
deleted file mode 100644
index b84c896..0000000
--- a/av1/encoder/pvq_encoder.h
+++ /dev/null
@@ -1,53 +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_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"
-# include "av1/encoder/encint.h"
-
-void aom_write_symbol_pvq(aom_writer *w, int symb, aom_cdf_prob *cdf,
- int nsymbs);
-
-void aom_encode_band_pvq_splits(aom_writer *w, od_pvq_codeword_ctx *adapt,
- const int *y, int n, int k, int level);
-
-void aom_laplace_encode_special(aom_writer *w, int x, unsigned decay);
-
-void pvq_encode_partition(aom_writer *w,
- int qg,
- int theta,
- const od_coeff *in,
- int n,
- int k,
- generic_encoder model[3],
- od_adapt_ctx *adapt,
- int *exg,
- int *ext,
- int cdf_ctx,
- int is_keyframe,
- int code_skip,
- int skip_rest,
- int encode_flip,
- int flip);
-
-PVQ_SKIP_TYPE od_pvq_encode(daala_enc_ctx *enc, od_coeff *ref,
- const od_coeff *in, od_coeff *out, int q_dc, int q_ac, int pli, int bs,
- const od_val16 *beta, int is_keyframe,
- const int16_t *qm, const int16_t *qm_inv, int speed,
- PVQ_INFO *pvq_info);
-
-#endif
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index a439f29..99a9bf3 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -65,10 +65,7 @@
#if CONFIG_EXT_TX
#include "av1/encoder/tx_prune_model_weights.h"
#endif // CONFIG_EXT_TX
-#if CONFIG_PVQ
-#include "av1/encoder/pvq_encoder.h"
-#include "av1/common/pvq.h"
-#endif // CONFIG_PVQ
+
#if CONFIG_DUAL_FILTER
#define DUAL_FILTER_SET_SIZE (SWITCHABLE_FILTERS * SWITCHABLE_FILTERS)
#if USE_EXTRA_FILTER
@@ -687,11 +684,9 @@
static double od_compute_dist(uint16_t *x, uint16_t *y, int bsize_w,
int bsize_h, int qindex) {
assert(bsize_w >= 8 && bsize_h >= 8);
-#if CONFIG_PVQ
- int activity_masking = 1;
-#else
+
int activity_masking = 0;
-#endif
+
int i, j;
DECLARE_ALIGNED(16, od_coeff, e[MAX_TX_SQUARE]);
DECLARE_ALIGNED(16, od_coeff, tmp[MAX_TX_SQUARE]);
@@ -718,11 +713,9 @@
static double od_compute_dist_diff(uint16_t *x, int16_t *e, int bsize_w,
int bsize_h, int qindex) {
assert(bsize_w >= 8 && bsize_h >= 8);
-#if CONFIG_PVQ
- int activity_masking = 1;
-#else
+
int activity_masking = 0;
-#endif
+
DECLARE_ALIGNED(16, uint16_t, y[MAX_TX_SQUARE]);
DECLARE_ALIGNED(16, od_coeff, tmp[MAX_TX_SQUARE]);
DECLARE_ALIGNED(16, od_coeff, e_lp[MAX_TX_SQUARE]);
@@ -1596,59 +1589,6 @@
}
#endif // CONFIG_HIGHBITDEPTH
-#if CONFIG_PVQ
-// Without PVQ, av1_block_error_c() return two kind of errors,
-// 1) reconstruction (i.e. decoded) error and
-// 2) Squared sum of transformed residue (i.e. 'coeff')
-// However, if PVQ is enabled, coeff does not keep the transformed residue
-// but instead a transformed original is kept.
-// Hence, new parameter ref vector (i.e. transformed predicted signal)
-// is required to derive the residue signal,
-// i.e. coeff - ref = residue (all transformed).
-
-#if CONFIG_HIGHBITDEPTH
-static int64_t av1_highbd_block_error2_c(const tran_low_t *coeff,
- const tran_low_t *dqcoeff,
- const tran_low_t *ref,
- intptr_t block_size, int64_t *ssz,
- int bd) {
- int64_t error;
- int64_t sqcoeff;
- int shift = 2 * (bd - 8);
- int rounding = shift > 0 ? 1 << (shift - 1) : 0;
- // Use the existing sse codes for calculating distortion of decoded signal:
- // i.e. (orig - decoded)^2
- // For high bit depth, throw away ssz until a 32-bit version of
- // av1_block_error_fp is written.
- int64_t ssz_trash;
- error = av1_block_error(coeff, dqcoeff, block_size, &ssz_trash);
- // prediction residue^2 = (orig - ref)^2
- sqcoeff = av1_block_error(coeff, ref, block_size, &ssz_trash);
- error = (error + rounding) >> shift;
- sqcoeff = (sqcoeff + rounding) >> shift;
- *ssz = sqcoeff;
- return error;
-}
-#else
-// TODO(yushin) : Since 4x4 case does not need ssz, better to refactor into
-// a separate function that does not do the extra computations for ssz.
-static int64_t av1_block_error2_c(const tran_low_t *coeff,
- const tran_low_t *dqcoeff,
- const tran_low_t *ref, intptr_t block_size,
- int64_t *ssz) {
- int64_t error;
- int64_t ssz_trash;
- // Use the existing sse codes for calculating distortion of decoded signal:
- // i.e. (orig - decoded)^2
- error = av1_block_error(coeff, dqcoeff, block_size, &ssz_trash);
- // prediction residue^2 = (orig - ref)^2
- *ssz = av1_block_error(coeff, ref, block_size, &ssz_trash);
- return error;
-}
-#endif // CONFIG_HIGHBITDEPTH
-#endif // CONFIG_PVQ
-
-#if !CONFIG_PVQ || CONFIG_VAR_TX
#if !CONFIG_LV_MAP
static int cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
int block, TX_SIZE tx_size, const SCAN_ORDER *scan_order,
@@ -1811,7 +1751,6 @@
&txb_ctx);
#endif // !CONFIG_LV_MAP
}
-#endif // !CONFIG_PVQ || CONFIG_VAR_TX
// Get transform block visible dimensions cropped to the MI units.
static void get_txb_dimensions(const MACROBLOCKD *xd, int plane,
@@ -1964,34 +1903,21 @@
int shift = (MAX_TX_SCALE - av1_get_tx_scale(tx_size)) * 2;
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
-#if CONFIG_PVQ
- tran_low_t *ref_coeff = BLOCK_OFFSET(pd->pvq_ref_coeff, block);
#if CONFIG_HIGHBITDEPTH
- const int bd = (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) ? xd->bd : 8;
- *out_dist = av1_highbd_block_error2_c(coeff, dqcoeff, ref_coeff,
- buffer_length, &this_sse, bd);
-#else
- *out_dist =
- av1_block_error2_c(coeff, dqcoeff, ref_coeff, buffer_length, &this_sse);
-#endif // CONFIG_HIGHBITDEPTH
-#else // !CONFIG_PVQ
-#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
*out_dist = av1_highbd_block_error(coeff, dqcoeff, buffer_length,
&this_sse, xd->bd);
else
#endif
*out_dist = av1_block_error(coeff, dqcoeff, buffer_length, &this_sse);
-#endif // CONFIG_PVQ
+
*out_dist = RIGHT_SIGNED_SHIFT(*out_dist, shift);
*out_sse = RIGHT_SIGNED_SHIFT(this_sse, shift);
} else {
const BLOCK_SIZE tx_bsize = txsize_to_bsize[tx_size];
-#if !CONFIG_PVQ || CONFIG_DIST_8X8
const int bsw = block_size_wide[tx_bsize];
const int bsh = block_size_high[tx_bsize];
-#endif
const int src_stride = x->plane[plane].src.stride;
const int dst_stride = xd->plane[plane].dst.stride;
// Scale the transform block index to pixel unit.
@@ -2038,7 +1964,6 @@
DECLARE_ALIGNED(16, uint8_t, recon[MAX_TX_SQUARE]);
#endif // CONFIG_HIGHBITDEPTH
-#if !CONFIG_PVQ
#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
aom_highbd_convolve_copy(dst, dst_stride, recon, MAX_TX_SIZE, NULL, 0,
@@ -2050,9 +1975,6 @@
#if CONFIG_HIGHBITDEPTH
}
#endif // CONFIG_HIGHBITDEPTH
-#else
- (void)dst;
-#endif // !CONFIG_PVQ
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
uint8_t *mrc_mask = BLOCK_OFFSET(xd->mrc_mask, block);
@@ -2221,7 +2143,7 @@
args->exit_early = 1;
return;
}
-#if !CONFIG_PVQ
+
const PLANE_TYPE plane_type = get_plane_type(plane);
const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
@@ -2229,22 +2151,17 @@
this_rd_stats.rate =
av1_cost_coeffs(cpi, x, plane, blk_row, blk_col, block, tx_size,
scan_order, a, l, args->use_fast_coef_costing);
-#else // !CONFIG_PVQ
- this_rd_stats.rate = x->rate;
-#endif // !CONFIG_PVQ
#else // !CONFIG_TXK_SEL
av1_search_txk_type(cpi, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, a, l, args->use_fast_coef_costing,
&this_rd_stats);
#endif // !CONFIG_TXK_SEL
-#if !CONFIG_PVQ
#if CONFIG_RD_DEBUG
av1_update_txb_coeff_cost(&this_rd_stats, plane, tx_size, blk_row, blk_col,
this_rd_stats.rate);
#endif // CONFIG_RD_DEBUG
av1_set_txb_context(x, plane, block, tx_size, a, l);
-#endif // !CONFIG_PVQ
rd1 = RDCOST(x->rdmult, this_rd_stats.rate, this_rd_stats.dist);
rd2 = RDCOST(x->rdmult, 0, this_rd_stats.sse);
@@ -2252,11 +2169,8 @@
// TODO(jingning): temporarily enabled only for luma component
rd = AOMMIN(rd1, rd2);
-#if !CONFIG_PVQ
this_rd_stats.skip &= !x->plane[plane].eobs[block];
-#else
- this_rd_stats.skip &= x->pvq_skip[plane];
-#endif // !CONFIG_PVQ
+
av1_merge_rd_stats(&args->rd_stats, &this_rd_stats);
args->this_rd += rd;
@@ -2502,9 +2416,6 @@
const int r_tx_size = tx_size_cost(cm, x, bs, tx_size);
-#if CONFIG_PVQ
- assert(tx_size >= TX_4X4);
-#endif // CONFIG_PVQ
#if CONFIG_EXT_TX && CONFIG_RECT_TX
assert(IMPLIES(is_rect_tx(tx_size), is_rect_tx_allowed_bsize(bs)));
#endif // CONFIG_EXT_TX && CONFIG_RECT_TX
@@ -2662,13 +2573,6 @@
if (get_ext_tx_types(mbmi->tx_size, bs, is_inter, cm->reduced_tx_set_used) >
1 &&
!xd->lossless[mbmi->segment_id]) {
-#if CONFIG_PVQ
- od_rollback_buffer pre_buf, post_buf;
-
- od_encode_checkpoint(&x->daala_enc, &pre_buf);
- od_encode_checkpoint(&x->daala_enc, &post_buf);
-#endif // CONFIG_PVQ
-
for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
if (!av1_ext_tx_used[tx_set_type][tx_type]) continue;
RD_STATS this_rd_stats;
@@ -2694,9 +2598,7 @@
txfm_rd_in_plane(x, cpi, &this_rd_stats, ref_best_rd, 0, bs,
mbmi->tx_size, cpi->sf.use_fast_coef_costing);
-#if CONFIG_PVQ
- od_encode_rollback(&x->daala_enc, &pre_buf);
-#endif // CONFIG_PVQ
+
if (this_rd_stats.rate == INT_MAX) continue;
av1_tx_type_cost(cm, x, xd, bs, plane, mbmi->tx_size, tx_type);
@@ -2713,14 +2615,9 @@
best_rd = this_rd;
best_tx_type = mbmi->tx_type;
*rd_stats = this_rd_stats;
-#if CONFIG_PVQ
- od_encode_checkpoint(&x->daala_enc, &post_buf);
-#endif // CONFIG_PVQ
}
}
-#if CONFIG_PVQ
- od_encode_rollback(&x->daala_enc, &post_buf);
-#endif // CONFIG_PVQ
+
#if CONFIG_LGT_FROM_PRED
// search LGT
if (search_lgt && is_lgt_allowed(mbmi->mode, mbmi->tx_size) &&
@@ -2847,10 +2744,6 @@
#endif // CONFIG_TXK_SEL
const int tx_select = cm->tx_mode == TX_MODE_SELECT;
const int is_inter = is_inter_block(mbmi);
-#if CONFIG_PVQ
- od_rollback_buffer buf;
- od_encode_checkpoint(&x->daala_enc, &buf);
-#endif // CONFIG_PVQ
av1_invalid_rd_stats(rd_stats);
@@ -3020,9 +2913,7 @@
RD_STATS this_rd_stats;
if (skip_txfm_search(cpi, x, bs, tx_type, n, prune)) continue;
rd = txfm_yrd(cpi, x, &this_rd_stats, ref_best_rd, bs, tx_type, n);
-#if CONFIG_PVQ
- od_encode_rollback(&x->daala_enc, &buf);
-#endif // CONFIG_PVQ
+
// Early termination in transform size search.
if (cpi->sf.tx_size_search_breakout &&
(rd == INT64_MAX ||
@@ -3086,11 +2977,6 @@
#if !CONFIG_EXT_TX
if (mbmi->tx_size >= TX_32X32) assert(mbmi->tx_type == DCT_DCT);
#endif // !CONFIG_EXT_TX
-#if CONFIG_PVQ
- if (best_rd != INT64_MAX) {
- txfm_yrd(cpi, x, rd_stats, ref_best_rd, bs, best_tx_type, best_tx_size);
- }
-#endif // CONFIG_PVQ
}
static void super_block_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
@@ -3780,12 +3666,6 @@
const PREDICTION_MODE A = av1_above_block_mode(mic, above_mi, 0);
const PREDICTION_MODE L = av1_left_block_mode(mic, left_mi, 0);
const PREDICTION_MODE FINAL_MODE_SEARCH = PAETH_PRED + 1;
-#if CONFIG_PVQ
- od_rollback_buffer pre_buf, post_buf;
-
- od_encode_checkpoint(&x->daala_enc, &pre_buf);
- od_encode_checkpoint(&x->daala_enc, &post_buf);
-#endif // CONFIG_PVQ
#if CONFIG_KF_CTX
const int above_ctx = intra_mode_context[A];
@@ -3839,9 +3719,7 @@
assert(mode_idx < INTRA_MODES);
mbmi->mode = intra_rd_search_mode_order[mode_idx];
}
-#if CONFIG_PVQ
- od_encode_rollback(&x->daala_enc, &pre_buf);
-#endif // CONFIG_PVQ
+
#if CONFIG_EXT_INTRA
mbmi->angle_delta[0] = 0;
#endif // CONFIG_EXT_INTRA
@@ -3917,16 +3795,9 @@
*rate_tokenonly = this_rate_tokenonly;
*distortion = this_distortion;
*skippable = s;
-#if CONFIG_PVQ
- od_encode_checkpoint(&x->daala_enc, &post_buf);
-#endif // CONFIG_PVQ
}
}
-#if CONFIG_PVQ
- od_encode_rollback(&x->daala_enc, &post_buf);
-#endif // CONFIG_PVQ
-
if (try_palette) {
rd_pick_palette_intra_sby(cpi, x, bsize, palette_y_mode_ctx,
bmode_costs[DC_PRED], &best_mbmi,
@@ -3968,12 +3839,10 @@
bsize = scale_chroma_bsize(bsize, xd->plane[1].subsampling_x,
xd->plane[1].subsampling_y);
-#if !CONFIG_PVQ
if (is_inter_block(mbmi) && is_cost_valid) {
for (plane = 1; plane < MAX_MB_PLANE; ++plane)
av1_subtract_plane(x, bsize, plane);
}
-#endif // !CONFIG_PVQ
if (is_cost_valid) {
for (plane = 1; plane < MAX_MB_PLANE; ++plane) {
@@ -4366,9 +4235,8 @@
if (rd_stats->rate == INT_MAX) return;
-#if !CONFIG_PVQ
av1_set_txb_context(x, plane, 0, quarter_txsize, pta, ptl);
-#endif // !CONFIG_PVQ
+
coeff_ctx = get_entropy_context(quarter_txsize, pta + blk_col_offset,
ptl + blk_row_offset);
zero_blk_rate =
@@ -4593,14 +4461,12 @@
}
#endif
-#if !CONFIG_PVQ
av1_set_txb_context(x, plane, block, tx_size_selected, pta, ptl);
#if CONFIG_RECT_TX_EXT
if (is_qttx_picked)
av1_set_txb_context(x, plane, block_offset_qttx, tx_size_selected,
pta + blk_col_offset, ptl + blk_row_offset);
#endif // CONFIG_RECT_TX_EXT
-#endif // !CONFIG_PVQ
txfm_partition_update(tx_above + blk_col, tx_left + blk_row, tx_size,
tx_size);
@@ -5149,9 +5015,7 @@
ENTROPY_CONTEXT *tl = left_ctx + blk_row;
av1_tx_block_rd_b(cpi, x, tx_size, blk_row, blk_col, plane, block,
plane_bsize, ta, tl, rd_stats);
-#if !CONFIG_PVQ
av1_set_txb_context(x, plane, block, tx_size, ta, tl);
-#endif // !CONFIG_PVQ
} else {
const TX_SIZE sub_txs = sub_tx_size_map[tx_size];
const int bsl = tx_size_wide_unit[sub_txs];
@@ -5780,10 +5644,6 @@
assert(!is_inter_block(mbmi));
MB_MODE_INFO best_mbmi = *mbmi;
int64_t best_rd = INT64_MAX, this_rd;
-#if CONFIG_PVQ
- od_rollback_buffer buf;
- od_encode_checkpoint(&x->daala_enc, &buf);
-#endif // CONFIG_PVQ
PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
const int try_palette =
av1_allow_palette(cpi->common.allow_screen_content_tools, mbmi->sb_type);
@@ -5820,9 +5680,6 @@
} else {
#endif // CONFIG_EXT_INTRA
if (!super_block_uvrd(cpi, x, &tokenonly_rd_stats, bsize, best_rd)) {
-#if CONFIG_PVQ
- od_encode_rollback(&x->daala_enc, &buf);
-#endif // CONFIG_PVQ
continue;
}
#if CONFIG_EXT_INTRA
@@ -5849,9 +5706,6 @@
if (try_palette && mode == UV_DC_PRED)
this_rate += x->palette_uv_mode_cost[pmi->palette_size[0] > 0][0];
-#if CONFIG_PVQ
- od_encode_rollback(&x->daala_enc, &buf);
-#endif // CONFIG_PVQ
this_rd = RDCOST(x->rdmult, this_rate, tokenonly_rd_stats.dist);
if (this_rd < best_rd) {
@@ -9857,9 +9711,6 @@
int64_t mode_threshold[MAX_MODES];
int *mode_map = tile_data->mode_map[bsize];
const int mode_search_skip_flags = sf->mode_search_skip_flags;
-#if CONFIG_PVQ
- od_rollback_buffer pre_buf;
-#endif // CONFIG_PVQ
HandleInterModeArgs args = {
#if CONFIG_MOTION_VAR
@@ -10149,9 +10000,7 @@
x->use_default_inter_tx_type = 1;
else
x->use_default_inter_tx_type = 0;
-#if CONFIG_PVQ
- od_encode_checkpoint(&x->daala_enc, &pre_buf);
-#endif // CONFIG_PVQ
+
for (i = 0; i < MB_MODE_COUNT; ++i)
for (ref_frame = 0; ref_frame < TOTAL_REFS_PER_FRAME; ++ref_frame)
modelled_rd[i][ref_frame] = INT64_MAX;
@@ -10168,9 +10017,7 @@
int this_skip2 = 0;
int64_t total_sse = INT64_MAX;
uint8_t ref_frame_type;
-#if CONFIG_PVQ
- od_encode_rollback(&x->daala_enc, &pre_buf);
-#endif // CONFIG_PVQ
+
mode_index = mode_map[midx];
this_mode = av1_mode_order[mode_index].mode;
ref_frame = av1_mode_order[mode_index].ref_frame[0];
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h
index 7795352..87b004f 100644
--- a/av1/encoder/rdopt.h
+++ b/av1/encoder/rdopt.h
@@ -77,12 +77,11 @@
int bsh, int visible_w, int visible_h, int qindex);
#endif
-#if !CONFIG_PVQ || CONFIG_VAR_TX
int av1_cost_coeffs(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
int blk_row, int blk_col, int block, TX_SIZE tx_size,
const SCAN_ORDER *scan_order, const ENTROPY_CONTEXT *a,
const ENTROPY_CONTEXT *l, int use_fast_coef_costing);
-#endif
+
void av1_rd_pick_intra_mode_sb(const struct AV1_COMP *cpi, struct macroblock *x,
struct RD_STATS *rd_cost, BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx, int64_t best_rd);
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index ff28a2f..a5226e6 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -264,7 +264,6 @@
};
#endif
-#if !CONFIG_PVQ || CONFIG_VAR_TX
static void cost_coeffs_b(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
struct tokenize_b_args *const args = arg;
@@ -327,7 +326,6 @@
update_cdf(*tail_cdf, token - TWO_TOKEN, TAIL_TOKENS);
}
}
-#endif // !CONFIG_PVQ || CONFIG_VAR_TX
static int cost_and_tokenize_map(Av1ColorMapParam *param, TOKENEXTRA **t,
int calc_rate) {
@@ -448,50 +446,8 @@
cost_and_tokenize_map(&color_map_params, t, 0);
}
-#if CONFIG_PVQ
-static void add_pvq_block(AV1_COMMON *const cm, MACROBLOCK *const x,
- PVQ_INFO *pvq) {
- PVQ_QUEUE *q = x->pvq_q;
- if (q->curr_pos >= q->buf_len) {
- int new_buf_len = 2 * q->buf_len + 1;
- PVQ_INFO *new_buf;
- CHECK_MEM_ERROR(cm, new_buf, aom_malloc(new_buf_len * sizeof(PVQ_INFO)));
- memcpy(new_buf, q->buf, q->buf_len * sizeof(PVQ_INFO));
- aom_free(q->buf);
- q->buf = new_buf;
- q->buf_len = new_buf_len;
- }
- OD_COPY(q->buf + q->curr_pos, pvq, 1);
- ++q->curr_pos;
-}
-
-// NOTE: This does not actually generate tokens, instead we store the encoding
-// decisions made for PVQ in a queue that we will read from when
-// actually writing the bitstream in write_modes_b
-static void tokenize_pvq(int plane, int block, int blk_row, int blk_col,
- BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
- struct tokenize_b_args *const args = arg;
- const AV1_COMP *cpi = args->cpi;
- const AV1_COMMON *const cm = &cpi->common;
- ThreadData *const td = args->td;
- MACROBLOCK *const x = &td->mb;
- PVQ_INFO *pvq_info;
-
- (void)block;
- (void)blk_row;
- (void)blk_col;
- (void)plane_bsize;
- (void)tx_size;
-
- assert(block < MAX_PVQ_BLOCKS_IN_SB);
- pvq_info = &x->pvq[block][plane];
- add_pvq_block((AV1_COMMON * const) cm, x, pvq_info);
-}
-#endif // CONFIG_PVQ
-
static void tokenize_b(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
-#if !CONFIG_PVQ
struct tokenize_b_args *const args = arg;
const AV1_COMP *cpi = args->cpi;
const AV1_COMMON *const cm = &cpi->common;
@@ -581,9 +537,6 @@
#endif
av1_set_contexts(xd, pd, plane, tx_size, c > 0, blk_col, blk_row);
-#else // !CONFIG_PVQ
- tokenize_pvq(plane, block, blk_row, blk_col, plane_bsize, tx_size, arg);
-#endif // !CONFIG_PVQ
}
struct is_skippable_args {
@@ -725,7 +678,7 @@
if (!is_chroma_reference(mi_row, mi_col, bsize,
xd->plane[plane].subsampling_x,
xd->plane[plane].subsampling_y)) {
-#if !CONFIG_PVQ && !CONFIG_LV_MAP
+#if !CONFIG_LV_MAP
if (!dry_run) {
(*t)->token = EOSB_TOKEN;
(*t)++;
@@ -807,23 +760,18 @@
if (!is_chroma_reference(mi_row, mi_col, bsize,
xd->plane[plane].subsampling_x,
xd->plane[plane].subsampling_y)) {
-#if !CONFIG_PVQ
(*t)->token = EOSB_TOKEN;
(*t)++;
-#endif
+
continue;
}
av1_foreach_transformed_block_in_plane(xd, bsize, plane, tokenize_b,
&arg);
-#if !CONFIG_PVQ
(*t)->token = EOSB_TOKEN;
(*t)++;
-#endif // !CONFIG_PVQ
}
#endif
- }
-#if !CONFIG_PVQ
- else if (dry_run == DRY_RUN_NORMAL) {
+ } else if (dry_run == DRY_RUN_NORMAL) {
int plane;
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
if (!is_chroma_reference(mi_row, mi_col, bsize,
@@ -844,7 +792,6 @@
&arg);
}
}
-#endif // !CONFIG_PVQ
if (rate) *rate += arg.this_rate;
}
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 09c9168..a037a01 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -184,7 +184,6 @@
set(CONFIG_PALETTE_DELTA_ENCODING 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_PALETTE_THROUGHPUT 1 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_PARALLEL_DEBLOCKING 1 CACHE NUMBER "AV1 experiment flag.")
-set(CONFIG_PVQ 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_Q_ADAPT_PROBS 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_RAWBITS 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_RD_DEBUG 0 CACHE NUMBER "AV1 experiment flag.")
diff --git a/build/cmake/aom_experiment_deps.cmake b/build/cmake/aom_experiment_deps.cmake
index 576bed1..df34206 100644
--- a/build/cmake/aom_experiment_deps.cmake
+++ b/build/cmake/aom_experiment_deps.cmake
@@ -33,9 +33,6 @@
if (NOT CONFIG_LV_MAP)
change_config_and_warn(CONFIG_LV_MAP 1 CONFIG_CTX1D)
endif ()
- if (CONFIG_PVQ)
- change_config_and_warn(CONFIG_PVQ 0 CONFIG_CTX1D)
- endif ()
endif ()
if (CONFIG_DAALA_TX)
@@ -110,21 +107,6 @@
endif ()
endif ()
- if (CONFIG_PVQ)
- if (CONFIG_EXT_TX)
- change_config_and_warn(CONFIG_EXT_TX 0 CONFIG_PVQ)
- endif ()
- if (CONFIG_PALETTE_THROUGHPUT)
- change_config_and_warn(CONFIG_PALETTE_THROUGHPUT 0 CONFIG_PVQ)
- endif ()
- if (CONFIG_VAR_TX)
- change_config_and_warn(CONFIG_VAR_TX 0 CONFIG_PVQ)
- endif ()
- if (CONFIG_VAR_TX_NO_TX_MODE)
- change_config_and_warn(CONFIG_VAR_TX_NO_TX_MODE 0 CONFIG_PVQ)
- endif ()
- endif ()
-
if (CONFIG_STRIPED_LOOP_RESTORATION)
if (NOT CONFIG_LOOP_RESTORATION)
change_config_and_warn(CONFIG_LOOP_RESTORATION 1
diff --git a/configure b/configure
index 6a9e401..52a92e2 100755
--- a/configure
+++ b/configure
@@ -283,7 +283,6 @@
palette_delta_encoding
rawbits
kf_ctx
- pvq
cfl
xiphrc
dct_only
@@ -552,15 +551,8 @@
soft_enable txmg
# Fix up experiment dependencies
- enabled pvq && disable_feature rect_tx
- enabled pvq && disable_feature ext_tx
- enabled pvq && disable_feature var_tx
- enabled pvq && disable_feature highbitdepth
- enabled pvq && disable_feature lgt
- enabled pvq && disable_feature mrc_tx
enabled lv_map && disable_feature mrc_tx
enabled coef_interleave && disable_feature mrc_tx
- enabled pvq && disable_feature palette_throughput
enabled mrc_tx && enable_feature ext_tx
enabled mrc_tx && enable_feature var_tx
enabled txk_sel && soft_enable lv_map