Commit d0b77ac7 authored by Yushin Cho's avatar Yushin Cho

Remove PVQ code

Change-Id: Id377c68e30031ad4697ca1ba311487b803a8af4c
parent ab68ddb3
......@@ -219,7 +219,7 @@ DSP_SRCS-$(HAVE_SSSE3) += x86/obmc_intrinsic_ssse3.h
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
......
......@@ -550,7 +550,7 @@ if (aom_config("CONFIG_HIGHBITDEPTH") eq "yes") {
#
# 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/;
......
......@@ -420,65 +420,6 @@ if (CONFIG_NCOBMC_ADAPT_WEIGHT)
"${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}
......
......@@ -128,28 +128,6 @@ ifeq ($(CONFIG_MOTION_VAR),yes)
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
......
......@@ -118,17 +118,6 @@ endif
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
......
......@@ -328,14 +328,6 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
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);
......
......@@ -44,24 +44,4 @@ AV1_DX_SRCS-yes += decoder/inspection.c
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))
......@@ -503,38 +503,6 @@ if (aom_config("CONFIG_AV1_ENCODER") eq "yes") {
}
# 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 @@ if (aom_config("CONFIG_CDEF") eq "yes") {
}
}
# 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") ||
......
......@@ -187,7 +187,6 @@ void av1_foreach_transformed_block(const MACROBLOCKD *const xd,
}
#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 @@ void av1_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd,
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;
......
......@@ -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 @@ static INLINE int is_inter_mode(PREDICTION_MODE mode) {
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 @@ typedef struct macroblockd_plane {
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 @@ typedef struct macroblockd {
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;
......
......@@ -2417,67 +2417,3 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
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
......@@ -388,11 +388,6 @@ void av1_average_tile_inter_cdfs(struct AV1Common *cm,
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
......
......@@ -6674,9 +6674,6 @@ void av1_setup_past_independence(AV1_COMMON *cm) {
#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
......
......@@ -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 @@ typedef struct frame_contexts {
#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)];
......
/*
* 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);
}
/*
* 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
......@@ -3237,19 +3237,7 @@ void av1_inverse_transform_block(const MACROBLOCKD *xd,
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
......
This diff is collapsed.
......@@ -77,16 +77,6 @@ extern "C" {
# 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 @@ void od_fatal_impl(const char *_str, const char *_file, int _line);
/** 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.*/