Commit 44bb6d06 authored by Timothy B. Terriberry's avatar Timothy B. Terriberry Committed by Tim Terriberry

pvq: Remove support for disabling nodesync.

This was broken by commit 1238137c.

When calling the generic coder with a max, it truncates the CDF, but
then tries to encode/decode with the Q15 entropy coder functions
with built-in adaptation. That causes assertion failures, because the
total probability isn't 32768.

We could fix it by re-scaling the CDF, and then doing adaptation
assuming there was no max, but that requires several special-case
code paths.

Instead, since non-robust streams were the only thing that still
required calling the generic coder with a max, and since the gain
from them is very small (and they require doing more DSP just to be
able to parse the stream), we simply remove the option and force
the use of robust streams all the time.

With robust streams enabled, encoder output should not change, and
all streams should remain decodable without decoder changes.

Thanks to Nathan Egge for reporting the problem.

Change-Id: I6c81481abb796688bf703d68f164d208e6a69f20
parent 281def73
...@@ -87,7 +87,6 @@ static INLINE int is_inter_mode(PREDICTION_MODE mode) { ...@@ -87,7 +87,6 @@ static INLINE int is_inter_mode(PREDICTION_MODE mode) {
#if CONFIG_PVQ #if CONFIG_PVQ
typedef struct PVQ_INFO { typedef struct PVQ_INFO {
int theta[PVQ_MAX_PARTITIONS]; int theta[PVQ_MAX_PARTITIONS];
int max_theta[PVQ_MAX_PARTITIONS];
int qg[PVQ_MAX_PARTITIONS]; int qg[PVQ_MAX_PARTITIONS];
int k[PVQ_MAX_PARTITIONS]; int k[PVQ_MAX_PARTITIONS];
od_coeff y[OD_TXSIZE_MAX * OD_TXSIZE_MAX]; od_coeff y[OD_TXSIZE_MAX * OD_TXSIZE_MAX];
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
# define GENERIC_TABLES 12 # define GENERIC_TABLES 12
#define generic_decode(r, model, max, ex_q16, integration, ACCT_STR_NAME) \ #define generic_decode(r, model, ex_q16, integration, ACCT_STR_NAME) \
generic_decode_(r, model, max, ex_q16, integration ACCT_STR_ARG(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) \ #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)) 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) \ #define aom_decode_cdf_adapt(r, cdf, n, increment, ACCT_STR_NAME) \
...@@ -70,17 +70,16 @@ void aom_encode_cdf_adapt(aom_writer *w, int val, uint16_t *cdf, int n, ...@@ -70,17 +70,16 @@ void aom_encode_cdf_adapt(aom_writer *w, int val, uint16_t *cdf, int n,
int aom_decode_cdf_adapt_(aom_reader *r, uint16_t *cdf, int n, int aom_decode_cdf_adapt_(aom_reader *r, uint16_t *cdf, int n,
int increment ACCT_STR_PARAM); int increment ACCT_STR_PARAM);
void generic_encode(aom_writer *w, generic_encoder *model, int x, int max, void generic_encode(aom_writer *w, generic_encoder *model, int x,
int *ex_q16, int integration); int *ex_q16, int integration);
double generic_encode_cost(generic_encoder *model, int x, int max, double generic_encode_cost(generic_encoder *model, int x, int *ex_q16);
int *ex_q16);
double od_encode_cdf_cost(int val, uint16_t *cdf, int n); 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 aom_decode_cdf_adapt_q15_(aom_reader *r, uint16_t *cdf, int n,
int *count, int rate ACCT_STR_PARAM); int *count, int rate ACCT_STR_PARAM);
int generic_decode_(aom_reader *r, generic_encoder *model, int max, int generic_decode_(aom_reader *r, generic_encoder *model,
int *ex_q16, int integration ACCT_STR_PARAM); int *ex_q16, int integration ACCT_STR_PARAM);
int log_ex(int ex_q16); int log_ex(int ex_q16);
......
...@@ -84,8 +84,6 @@ extern "C" { ...@@ -84,8 +84,6 @@ extern "C" {
# define OD_LIMIT_BSIZE_MIN (OD_BLOCK_4X4) # define OD_LIMIT_BSIZE_MIN (OD_BLOCK_4X4)
# define OD_LIMIT_BSIZE_MAX (OD_BLOCK_32X32) # define OD_LIMIT_BSIZE_MAX (OD_BLOCK_32X32)
# define OD_ROBUST_STREAM (1)
typedef int od_coeff; typedef int od_coeff;
#define OD_DIVU_DMAX (1024) #define OD_DIVU_DMAX (1024)
......
...@@ -792,16 +792,14 @@ od_val32 od_pvq_compute_theta(int t, int max_theta) { ...@@ -792,16 +792,14 @@ od_val32 od_pvq_compute_theta(int t, int max_theta) {
* *
* @param [in] qcg quantized companded gain value * @param [in] qcg quantized companded gain value
* @param [in] itheta quantized PVQ error angle theta * @param [in] itheta quantized PVQ error angle theta
* @param [in] theta PVQ error angle theta
* @param [in] noref indicates present or lack of reference * @param [in] noref indicates present or lack of reference
* (prediction) * (prediction)
* @param [in] n number of elements to be coded * @param [in] n number of elements to be coded
* @param [in] beta activity masking beta param * @param [in] beta activity masking beta param
* @param [in] nodesync do not use info that depends on the reference
* @return number of pulses to use for coding * @return number of pulses to use for coding
*/ */
int od_pvq_compute_k(od_val32 qcg, int itheta, od_val32 theta, int noref, int n, int od_pvq_compute_k(od_val32 qcg, int itheta, int noref, int n,
od_val16 beta, int nodesync) { od_val16 beta) {
#if !defined(OD_FLOAT_PVQ) #if !defined(OD_FLOAT_PVQ)
/*Lookup table for sqrt(n+3/2) and sqrt(n+2/2) in Q10. /*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. Real max values are 32792 and 32784, but clamped to stay within 16 bits.
...@@ -839,24 +837,17 @@ int od_pvq_compute_k(od_val32 qcg, int itheta, od_val32 theta, int noref, int n, ...@@ -839,24 +837,17 @@ int od_pvq_compute_k(od_val32 qcg, int itheta, od_val32 theta, int noref, int n,
approximation for the fact that the coefficients aren't identically approximation for the fact that the coefficients aren't identically
distributed within a band so at low gain the number of dimensions that distributed within a band so at low gain the number of dimensions that
are likely to have a pulse is less than n. */ are likely to have a pulse is less than n. */
if (nodesync) {
#if defined(OD_FLOAT_PVQ) #if defined(OD_FLOAT_PVQ)
return OD_MAXI(1, (int)floor(.5 + (itheta - .2)*sqrt((n + 2)/2))); return OD_MAXI(1, (int)floor(.5 + (itheta - .2)*sqrt((n + 2)/2)));
#else #else
od_val16 rt; od_val16 rt;
OD_ASSERT(OD_ILOG(n + 1) < 13); OD_ASSERT(OD_ILOG(n + 1) < 13);
rt = od_sqrt_table[0][OD_ILOG(n + 1)]; rt = od_sqrt_table[0][OD_ILOG(n + 1)];
/*FIXME: get rid of 64-bit mul.*/ /*FIXME: get rid of 64-bit mul.*/
return OD_MAXI(1, OD_VSHR_ROUND(((OD_SHL(itheta, OD_ITHETA_SHIFT) return OD_MAXI(1, OD_VSHR_ROUND(((OD_SHL(itheta, OD_ITHETA_SHIFT)
- OD_QCONST32(.2, OD_ITHETA_SHIFT)))*(int64_t)rt, - OD_QCONST32(.2, OD_ITHETA_SHIFT)))*(int64_t)rt,
OD_SQRT_TBL_SHIFT + OD_ITHETA_SHIFT)); OD_SQRT_TBL_SHIFT + OD_ITHETA_SHIFT));
#endif #endif
}
else {
return OD_MAXI(1, (int)floor(.5 + (qcg*OD_CGAIN_SCALE_1*
od_pvq_sin(theta)*OD_TRIG_SCALE_1 - .2)*sqrt((n
+ 2)/2)/(beta*OD_BETA_SCALE_1)));
}
} }
} }
......
...@@ -175,8 +175,7 @@ od_val32 od_pvq_compute_gain(const od_val16 *x, int n, int q0, od_val32 *g, ...@@ -175,8 +175,7 @@ od_val32 od_pvq_compute_gain(const od_val16 *x, int n, int q0, od_val32 *g,
od_val16 beta, int bshift); od_val16 beta, int bshift);
int od_pvq_compute_max_theta(od_val32 qcg, od_val16 beta); int od_pvq_compute_max_theta(od_val32 qcg, od_val16 beta);
od_val32 od_pvq_compute_theta(int t, int max_theta); od_val32 od_pvq_compute_theta(int t, int max_theta);
int od_pvq_compute_k(od_val32 qcg, int itheta, od_val32 theta, int noref, int od_pvq_compute_k(od_val32 qcg, int itheta, int noref, int n, od_val16 beta);
int n, od_val16 beta, int nodesync);
int od_vector_is_null(const od_coeff *x, int len); int od_vector_is_null(const od_coeff *x, int len);
int od_qm_offset(int bs, int xydec); int od_qm_offset(int bs, int xydec);
......
...@@ -388,14 +388,14 @@ static int av1_pvq_decode_helper(MACROBLOCKD *xd, tran_low_t *ref_coeff, ...@@ -388,14 +388,14 @@ static int av1_pvq_decode_helper(MACROBLOCKD *xd, tran_low_t *ref_coeff,
od_pvq_decode(dec, ref_int32, out_int32, od_pvq_decode(dec, ref_int32, out_int32,
OD_MAXI(1, quant[1] << (OD_COEFF_SHIFT - 3) >> hbd_downshift), OD_MAXI(1, quant[1] << (OD_COEFF_SHIFT - 3) >> hbd_downshift),
pli, bs, OD_PVQ_BETA[use_activity_masking][pli][bs], pli, bs, OD_PVQ_BETA[use_activity_masking][pli][bs],
OD_ROBUST_STREAM, is_keyframe, &flags, ac_dc_coded, is_keyframe, &flags, ac_dc_coded, dec->state.qm + off,
dec->state.qm + off, dec->state.qm_inv + off); dec->state.qm_inv + off);
if (!has_dc_skip || out_int32[0]) { if (!has_dc_skip || out_int32[0]) {
out_int32[0] = out_int32[0] =
has_dc_skip + generic_decode(dec->r, &dec->state.adapt->model_dc[pli], has_dc_skip + generic_decode(dec->r, &dec->state.adapt->model_dc[pli],
-1, &dec->state.adapt->ex_dc[pli][bs][0], &dec->state.adapt->ex_dc[pli][bs][0], 2,
2, "dc:mag"); "dc:mag");
if (out_int32[0]) out_int32[0] *= aom_read_bit(dec->r, "dc:sign") ? -1 : 1; 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]; out_int32[0] = out_int32[0] * pvq_dc_quant + ref_int32[0];
......
...@@ -86,7 +86,7 @@ int aom_decode_cdf_adapt_(aom_reader *r, uint16_t *cdf, int n, ...@@ -86,7 +86,7 @@ int aom_decode_cdf_adapt_(aom_reader *r, uint16_t *cdf, int n,
* *
* @retval decoded variable x * @retval decoded variable x
*/ */
int generic_decode_(aom_reader *r, generic_encoder *model, int max, int generic_decode_(aom_reader *r, generic_encoder *model,
int *ex_q16, int integration ACCT_STR_PARAM) { int *ex_q16, int integration ACCT_STR_PARAM) {
int lg_q1; int lg_q1;
int shift; int shift;
...@@ -95,9 +95,7 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max, ...@@ -95,9 +95,7 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max,
int xs; int xs;
int lsb; int lsb;
int x; int x;
int ms;
lsb = 0; lsb = 0;
if (max == 0) return 0;
lg_q1 = log_ex(*ex_q16); lg_q1 = log_ex(*ex_q16);
/* If expectation is too large, shift x to ensure that /* If expectation is too large, shift x to ensure that
all we have past xs=15 is the exponentially decaying tail all we have past xs=15 is the exponentially decaying tail
...@@ -106,9 +104,7 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max, ...@@ -106,9 +104,7 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max,
/* Choose the cdf to use: we have two per "octave" of ExQ16. */ /* Choose the cdf to use: we have two per "octave" of ExQ16. */
id = OD_MINI(GENERIC_TABLES - 1, lg_q1); id = OD_MINI(GENERIC_TABLES - 1, lg_q1);
cdf = model->cdf[id]; cdf = model->cdf[id];
ms = (max + (1 << shift >> 1)) >> shift; xs = aom_read_symbol_pvq(r, cdf, 16, ACCT_STR_NAME);
if (max == -1) xs = aom_read_symbol_pvq(r, cdf, 16, ACCT_STR_NAME);
else xs = aom_read_symbol_pvq(r, cdf, OD_MINI(ms + 1, 16), ACCT_STR_NAME);
if (xs == 15) { if (xs == 15) {
int e; int e;
unsigned decay; unsigned decay;
...@@ -119,7 +115,7 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max, ...@@ -119,7 +115,7 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max,
OD_ASSERT(*ex_q16 < INT_MAX >> 1); OD_ASSERT(*ex_q16 < INT_MAX >> 1);
e = ((2**ex_q16 >> 8) + (1 << shift >> 1)) >> shift; e = ((2**ex_q16 >> 8) + (1 << shift >> 1)) >> shift;
decay = OD_MAXI(2, OD_MINI(254, 256*e/(e + 256))); decay = OD_MAXI(2, OD_MINI(254, 256*e/(e + 256)));
xs += aom_laplace_decode_special(r, decay, (max == -1) ? -1 : ms - 15, ACCT_STR_NAME); xs += aom_laplace_decode_special(r, decay, ACCT_STR_NAME);
} }
if (shift != 0) { if (shift != 0) {
int special; int special;
......
...@@ -81,29 +81,24 @@ void aom_decode_band_pvq_splits(aom_reader *r, od_pvq_codeword_ctx *adapt, ...@@ -81,29 +81,24 @@ void aom_decode_band_pvq_splits(aom_reader *r, od_pvq_codeword_ctx *adapt,
* *
* @param [dec] range decoder * @param [dec] range decoder
* @param [decay] decay factor of the distribution, i.e. pdf ~= decay^x * @param [decay] decay factor of the distribution, i.e. pdf ~= decay^x
* @param [max] maximum possible value of x (used to truncate the pdf)
* *
* @retval decoded variable x * @retval decoded variable x
*/ */
int aom_laplace_decode_special_(aom_reader *r, unsigned decay, int aom_laplace_decode_special_(aom_reader *r, unsigned decay ACCT_STR_PARAM) {
int max ACCT_STR_PARAM) {
int pos; int pos;
int shift; int shift;
int xs; int xs;
int ms;
int sym; int sym;
const uint16_t *cdf; const uint16_t *cdf;
shift = 0; shift = 0;
if (max == 0) return 0;
/* We don't want a large decay value because that would require too many /* We don't want a large decay value because that would require too many
symbols. However, it's OK if the max is below 15. */ symbols. */
while (((max >> shift) >= 15 || max == -1) && decay > 235) { while (decay > 235) {
decay = (decay*decay + 128) >> 8; decay = (decay*decay + 128) >> 8;
shift++; shift++;
} }
decay = OD_MINI(decay, 254); decay = OD_MINI(decay, 254);
decay = OD_MAXI(decay, 2); decay = OD_MAXI(decay, 2);
ms = max >> shift;
cdf = EXP_CDF_TABLE[(decay + 1) >> 1]; cdf = EXP_CDF_TABLE[(decay + 1) >> 1];
OD_LOG((OD_LOG_PVQ, OD_LOG_DEBUG, "decay = %d\n", decay)); OD_LOG((OD_LOG_PVQ, OD_LOG_DEBUG, "decay = %d\n", decay));
xs = 0; xs = 0;
...@@ -111,32 +106,16 @@ int aom_laplace_decode_special_(aom_reader *r, unsigned decay, ...@@ -111,32 +106,16 @@ int aom_laplace_decode_special_(aom_reader *r, unsigned decay,
sym = OD_MINI(xs, 15); sym = OD_MINI(xs, 15);
{ {
int i; int i;
OD_LOG((OD_LOG_PVQ, OD_LOG_DEBUG, "%d %d %d %d", xs, shift, sym, max)); OD_LOG((OD_LOG_PVQ, OD_LOG_DEBUG, "%d %d %d", xs, shift, sym));
for (i = 0; i < 16; i++) { 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, "%d ", cdf[i]));
} }
OD_LOG_PARTIAL((OD_LOG_PVQ, OD_LOG_DEBUG, "\n")); OD_LOG_PARTIAL((OD_LOG_PVQ, OD_LOG_DEBUG, "\n"));
} }
if (ms > 0 && ms < 15) { sym = aom_read_cdf(r, cdf, 16, ACCT_STR_NAME);
/* Simple way of truncating the pdf when we have a bound. */
sym = aom_read_cdf_unscaled(r, cdf, ms + 1, ACCT_STR_NAME);
}
else sym = aom_read_cdf(r, cdf, 16, ACCT_STR_NAME);
xs += sym; xs += sym;
ms -= 15; } while (sym >= 15);
}
while (sym >= 15 && ms != 0);
if (shift) pos = (xs << shift) + aom_read_literal(r, shift, ACCT_STR_NAME); if (shift) pos = (xs << shift) + aom_read_literal(r, shift, ACCT_STR_NAME);
else pos = xs; else pos = xs;
OD_ASSERT(pos >> shift <= max >> shift || max == -1);
if (max != -1 && pos > max) {
pos = max;
#if CONFIG_DAALA_EC
r->ec.error = 1;
#else
# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
}
OD_ASSERT(pos <= max || max == -1);
return pos; return pos;
} }
...@@ -108,7 +108,6 @@ typedef struct { ...@@ -108,7 +108,6 @@ typedef struct {
* @param [out] out decoded partition * @param [out] out decoded partition
* @param [out] noref boolean indicating absence of reference * @param [out] noref boolean indicating absence of reference
* @param [in] beta per-band activity masking beta param * @param [in] beta per-band activity masking beta param
* @param [in] nodesync stream is robust to error in the reference
* @param [in] is_keyframe whether we're encoding a keyframe * @param [in] is_keyframe whether we're encoding a keyframe
* @param [in] pli plane index * @param [in] pli plane index
* @param [in] cdf_ctx selects which cdf context to use * @param [in] cdf_ctx selects which cdf context to use
...@@ -130,7 +129,6 @@ static void pvq_decode_partition(aom_reader *r, ...@@ -130,7 +129,6 @@ static void pvq_decode_partition(aom_reader *r,
od_coeff *out, od_coeff *out,
int *noref, int *noref,
od_val16 beta, od_val16 beta,
int nodesync,
int is_keyframe, int is_keyframe,
int pli, int pli,
int cdf_ctx, int cdf_ctx,
...@@ -143,7 +141,6 @@ static void pvq_decode_partition(aom_reader *r, ...@@ -143,7 +141,6 @@ static void pvq_decode_partition(aom_reader *r,
const int16_t *qm_inv) { const int16_t *qm_inv) {
int k; int k;
od_val32 qcg; od_val32 qcg;
int max_theta;
int itheta; int itheta;
od_val32 theta; od_val32 theta;
od_val32 gr; od_val32 gr;
...@@ -171,8 +168,7 @@ static void pvq_decode_partition(aom_reader *r, ...@@ -171,8 +168,7 @@ static void pvq_decode_partition(aom_reader *r,
} }
else { else {
/* Jointly decode gain, itheta and noref for small values. Then we handle /* Jointly decode gain, itheta and noref for small values. Then we handle
larger gain. We need to wait for itheta because in the !nodesync case larger gain. */
it depends on max_theta, which depends on the gain. */
id = aom_read_symbol_pvq(r, &adapt->pvq.pvq_gaintheta_cdf[cdf_ctx][0], id = aom_read_symbol_pvq(r, &adapt->pvq.pvq_gaintheta_cdf[cdf_ctx][0],
8 + 7*has_skip, "pvq:gaintheta"); 8 + 7*has_skip, "pvq:gaintheta");
if (!is_keyframe && id >= 10) id++; if (!is_keyframe && id >= 10) id++;
...@@ -197,7 +193,7 @@ static void pvq_decode_partition(aom_reader *r, ...@@ -197,7 +193,7 @@ static void pvq_decode_partition(aom_reader *r,
if (qg > 0) { if (qg > 0) {
int tmp; int tmp;
tmp = *exg; tmp = *exg;
qg = 1 + generic_decode(r, &model[!*noref], -1, &tmp, 2, "pvq:gain"); qg = 1 + generic_decode(r, &model[!*noref], &tmp, 2, "pvq:gain");
OD_IIR_DIADIC(*exg, qg << 16, 2); OD_IIR_DIADIC(*exg, qg << 16, 2);
} }
*skip = 0; *skip = 0;
...@@ -239,15 +235,13 @@ static void pvq_decode_partition(aom_reader *r, ...@@ -239,15 +235,13 @@ static void pvq_decode_partition(aom_reader *r,
gain_offset = cgr - OD_SHL(icgr, OD_CGAIN_SHIFT); gain_offset = cgr - OD_SHL(icgr, OD_CGAIN_SHIFT);
qcg = OD_SHL(qg, OD_CGAIN_SHIFT) + gain_offset; qcg = OD_SHL(qg, OD_CGAIN_SHIFT) + gain_offset;
/* read and decode first-stage PVQ error theta */ /* read and decode first-stage PVQ error theta */
max_theta = od_pvq_compute_max_theta(qcg, beta); if (itheta > 1) {
if (itheta > 1 && (nodesync || max_theta > 3)) {
int tmp; int tmp;
tmp = *ext; tmp = *ext;
itheta = 2 + generic_decode(r, &model[2], itheta = 2 + generic_decode(r, &model[2], &tmp, 2, "pvq:theta");
nodesync ? -1 : max_theta - 3, &tmp, 2, "pvq:theta");
OD_IIR_DIADIC(*ext, itheta << 16, 2); OD_IIR_DIADIC(*ext, itheta << 16, 2);
} }
theta = od_pvq_compute_theta(itheta, max_theta); theta = od_pvq_compute_theta(itheta, od_pvq_compute_max_theta(qcg, beta));
} }
else{ else{
itheta = 0; itheta = 0;
...@@ -256,7 +250,7 @@ static void pvq_decode_partition(aom_reader *r, ...@@ -256,7 +250,7 @@ static void pvq_decode_partition(aom_reader *r,
if (qg == 0) *skip = OD_PVQ_SKIP_ZERO; if (qg == 0) *skip = OD_PVQ_SKIP_ZERO;
} }
k = od_pvq_compute_k(qcg, itheta, theta, *noref, n, beta, nodesync); k = od_pvq_compute_k(qcg, itheta, *noref, n, beta);
if (k != 0) { if (k != 0) {
/* when noref==0, y is actually size n-1 */ /* when noref==0, y is actually size n-1 */
aom_decode_pvq_codeword(r, &adapt->pvq.pvq_codeword_ctx, y, aom_decode_pvq_codeword(r, &adapt->pvq.pvq_codeword_ctx, y,
...@@ -287,7 +281,6 @@ static void pvq_decode_partition(aom_reader *r, ...@@ -287,7 +281,6 @@ static void pvq_decode_partition(aom_reader *r,
* @param [in] pli plane index * @param [in] pli plane index
* @param [in] bs log of the block size minus two * @param [in] bs log of the block size minus two
* @param [in] beta per-band activity masking beta param * @param [in] beta per-band activity masking beta param
* @param [in] nodesync stream is robust to error in the reference
* @param [in] is_keyframe whether we're encoding a keyframe * @param [in] is_keyframe whether we're encoding a keyframe
* @param [out] flags bitmask of the per band skip and noref flags * @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] ac_dc_coded skip flag for the block (range 0-3)
...@@ -301,7 +294,6 @@ void od_pvq_decode(daala_dec_ctx *dec, ...@@ -301,7 +294,6 @@ void od_pvq_decode(daala_dec_ctx *dec,
int pli, int pli,
int bs, int bs,
const od_val16 *beta, const od_val16 *beta,
int nodesync,
int is_keyframe, int is_keyframe,
unsigned int *flags, unsigned int *flags,
PVQ_SKIP_TYPE ac_dc_coded, PVQ_SKIP_TYPE ac_dc_coded,
...@@ -362,7 +354,7 @@ void od_pvq_decode(daala_dec_ctx *dec, ...@@ -362,7 +354,7 @@ void od_pvq_decode(daala_dec_ctx *dec,
pvq_decode_partition(dec->r, q, size[i], pvq_decode_partition(dec->r, q, size[i],
model, dec->state.adapt, exg + i, ext + i, ref + off[i], out + off[i], model, dec->state.adapt, exg + i, ext + i, ref + off[i], out + off[i],
&noref[i], beta[i], nodesync, is_keyframe, pli, &noref[i], beta[i], is_keyframe, pli,
(pli != 0)*OD_TXSIZES*PVQ_MAX_PARTITIONS + bs*PVQ_MAX_PARTITIONS + i, (pli != 0)*OD_TXSIZES*PVQ_MAX_PARTITIONS + bs*PVQ_MAX_PARTITIONS + i,
&cfl, i == 0 && (i < nb_bands - 1), skip_rest, i, &skip[i], &cfl, i == 0 && (i < nb_bands - 1), skip_rest, i, &skip[i],
qm + off[i], qm_inv + off[i]); qm + off[i], qm_inv + off[i]);
......
...@@ -27,14 +27,13 @@ int aom_read_symbol_pvq_(aom_reader *r, aom_cdf_prob *cdf, int nsymbs ...@@ -27,14 +27,13 @@ int aom_read_symbol_pvq_(aom_reader *r, aom_cdf_prob *cdf, int nsymbs
void aom_decode_band_pvq_splits(aom_reader *r, od_pvq_codeword_ctx *adapt, void aom_decode_band_pvq_splits(aom_reader *r, od_pvq_codeword_ctx *adapt,
od_coeff *y, int n, int k, int level); od_coeff *y, int n, int k, int level);
#define aom_laplace_decode_special(r, decay, max, ACCT_STR_NAME) \ #define aom_laplace_decode_special(r, decay, ACCT_STR_NAME) \
aom_laplace_decode_special_(r, decay, max ACCT_STR_ARG(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, int aom_laplace_decode_special_(aom_reader *r, unsigned decay ACCT_STR_PARAM);
int max ACCT_STR_PARAM);
void od_pvq_decode(daala_dec_ctx *dec, od_coeff *ref, od_coeff *out, int q0, 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 nodesync, int is_keyframe, int pli, int bs, const od_val16 *beta, int is_keyframe,
unsigned int *flags, PVQ_SKIP_TYPE ac_dc_coded, const int16_t *qm, unsigned int *flags, PVQ_SKIP_TYPE ac_dc_coded, const int16_t *qm,
const int16_t *qm_inv); const int16_t *qm_inv);
......
...@@ -1035,7 +1035,6 @@ static void pack_pvq_tokens(aom_writer *w, MACROBLOCK *const x, ...@@ -1035,7 +1035,6 @@ static void pack_pvq_tokens(aom_writer *w, MACROBLOCK *const x,
const int is_keyframe = 0; const int is_keyframe = 0;
const int encode_flip = 0; const int encode_flip = 0;
const int flip = 0; const int flip = 0;
const int nodesync = 1;
int i; int i;
const int has_dc_skip = 1; const int has_dc_skip = 1;
int *exg = &adapt->pvq.pvq_exg[plane][tx_size][0]; int *exg = &adapt->pvq.pvq_exg[plane][tx_size][0];
...@@ -1055,9 +1054,8 @@ static void pack_pvq_tokens(aom_writer *w, MACROBLOCK *const x, ...@@ -1055,9 +1054,8 @@ static void pack_pvq_tokens(aom_writer *w, MACROBLOCK *const x,
if (i == 0 || if (i == 0 ||
(!pvq->skip_rest && !(pvq->skip_dir & (1 << ((i - 1) % 3))))) { (!pvq->skip_rest && !(pvq->skip_dir & (1 << ((i - 1) % 3))))) {
pvq_encode_partition( pvq_encode_partition(
w, pvq->qg[i], pvq->theta[i], pvq->max_theta[i], w, pvq->qg[i], pvq->theta[i], pvq->y + pvq->off[i],
pvq->y + pvq->off[i], pvq->size[i], pvq->k[i], model, adapt, pvq->size[i], pvq->k[i], model, adapt, exg + i, ext + i,
exg + i, ext + i, nodesync || is_keyframe,
(plane != 0) * OD_TXSIZES * PVQ_MAX_PARTITIONS + (plane != 0) * OD_TXSIZES * PVQ_MAX_PARTITIONS +
pvq->bs * PVQ_MAX_PARTITIONS + i, pvq->bs * PVQ_MAX_PARTITIONS + i,
is_keyframe, i == 0 && (i < pvq->nb_bands - 1), pvq->skip_rest, is_keyframe, i == 0 && (i < pvq->nb_bands - 1), pvq->skip_rest,
...@@ -1075,7 +1073,7 @@ static void pack_pvq_tokens(aom_writer *w, MACROBLOCK *const x, ...@@ -1075,7 +1073,7 @@ static void pack_pvq_tokens(aom_writer *w, MACROBLOCK *const x,
// Encode residue of DC coeff, if exist. // Encode residue of DC coeff, if exist.
if (!has_dc_skip || (pvq->ac_dc_coded & DC_CODED)) { if (!has_dc_skip || (pvq->ac_dc_coded & DC_CODED)) {
generic_encode(w, &adapt->model_dc[plane], generic_encode(w, &adapt->model_dc[plane],
abs(pvq->dq_dc_residue) - has_dc_skip, -1, abs(pvq->dq_dc_residue) - has_dc_skip,
&adapt->ex_dc[plane][pvq->bs][0], 2); &adapt->ex_dc[plane][pvq->bs][0], 2);
} }
if ((pvq->ac_dc_coded & DC_CODED)) { if ((pvq->ac_dc_coded & DC_CODED)) {
......
...@@ -1218,7 +1218,6 @@ PVQ_SKIP_TYPE av1_pvq_encode_helper(MACROBLOCK *x, tran_low_t *const coeff, ...@@ -1218,7 +1218,6 @@ PVQ_SKIP_TYPE av1_pvq_encode_helper(MACROBLOCK *x, tran_low_t *const coeff,
hbd_downshift), // scale/quantizer hbd_downshift), // scale/quantizer
plane, plane,
tx_size, OD_PVQ_BETA[use_activity_masking][plane][tx_size], tx_size, OD_PVQ_BETA[use_activity_masking][plane][tx_size],
OD_ROBUST_STREAM,
0, // is_keyframe, 0, // is_keyframe,
daala_enc->state.qm + off, daala_enc->state.qm_inv + off, daala_enc->state.qm + off, daala_enc->state.qm_inv + off,
speed, // speed speed, // speed
...@@ -1227,7 +1226,7 @@ PVQ_SKIP_TYPE av1_pvq_encode_helper(MACROBLOCK *x, tran_low_t *const coeff, ...@@ -1227,7 +1226,7 @@ PVQ_SKIP_TYPE av1_pvq_encode_helper(MACROBLOCK *x, tran_low_t *const coeff,
// Encode residue of DC coeff, if required. // Encode residue of DC coeff, if required.
if (!has_dc_skip || out_int32[0]) { if (!has_dc_skip || out_int32[0]) {
generic_encode(&daala_enc->w, &daala_enc->state.adapt->model_dc[plane], generic_encode(&daala_enc->w, &daala_enc->state.adapt->model_dc[plane],
abs(out_int32[0]) - has_dc_skip, -1, abs(out_int32[0]) - has_dc_skip,
&daala_enc->state.adapt->ex_dc[plane][tx_size][0], 2); &daala_enc->state.adapt->ex_dc[plane][tx_size][0], 2);
} }
if (out_int32[0]) { if (out_int32[0]) {
...@@ -1267,10 +1266,9 @@ PVQ_SKIP_TYPE av1_pvq_encode_helper(MACROBLOCK *x, tran_low_t *const coeff, ...@@ -1267,10 +1266,9 @@ PVQ_SKIP_TYPE av1_pvq_encode_helper(MACROBLOCK *x, tran_low_t *const coeff,
return ac_dc_coded; return ac_dc_coded;
} }
void av1_store_pvq_enc_info(PVQ_INFO *pvq_info, int *qg, int *theta, void av1_store_pvq_enc_info(PVQ_INFO *pvq_info, int *qg, int *theta, int *k,
int *max_theta, int *k, od_coeff *y, int nb_bands, od_coeff *y, int nb_bands, const int *off,
const int *off, int *size, int skip_rest, int *size, int skip_rest, int skip_dir,
int skip_dir,
int bs) { // block size in log_2 -2 int bs) { // block size in log_2 -2
int i; int i;
const int tx_blk_size = tx_size_wide[bs]; const int tx_blk_size = tx_size_wide[bs];
...@@ -1278,7 +1276,6 @@ void av1_store_pvq_enc_info(PVQ_INFO *pvq_info, int *qg, int *theta, ...@@ -1278,7 +1276,6 @@ void av1_store_pvq_enc_info(PVQ_INFO *pvq_info, int *qg, int *theta,
for (i = 0; i < nb_bands; i++) { for (i = 0; i < nb_bands; i++) {
pvq_info->qg[i] = qg[i]; pvq_info->qg[i] = qg[i];
pvq_info->theta[i] = theta[i]; pvq_info->theta[i] = theta[i];
pvq_info->max_theta[i] = max_theta[i];
pvq_info->k[i] = k[i]; pvq_info->k[i] = k[i];
pvq_info->off[i] = off[i]; pvq_info->off[i] = off[i];
pvq_info->size[i] = size[i]; pvq_info->size[i] = size[i];
......
...@@ -80,10 +80,9 @@ PVQ_SKIP_TYPE av1_pvq_encode_helper(MACROBLOCK *x, tran_low_t *const coeff, ...@@ -80,10 +80,9 @@ PVQ_SKIP_TYPE av1_pvq_encode_helper(MACROBLOCK *x, tran_low_t *const coeff,
int tx_size, TX_TYPE tx_type, int *rate, int tx_size, TX_TYPE tx_type, int *rate,
int speed, PVQ_INFO *pvq_info); int speed, PVQ_INFO *pvq_info);
void av1_store_pvq_enc_info(PVQ_INFO *pvq_info, int *qg, int *theta, void av1_store_pvq_enc_info(PVQ_INFO *pvq_info, int *qg, int *theta, int *k,
int *max_theta, int *k, od_coeff *y, int nb_bands, od_coeff *y, int nb_bands, const int *off,
const int *off, int *size, int skip_rest, int *size, int skip_rest, int skip_dir, int bs);
int skip_dir, int bs);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -78,20 +78,17 @@ void aom_encode_cdf_adapt(aom_writer *w, int val, uint16_t *cdf, int n, ...@@ -78,20 +78,17 @@ void aom_encode_cdf_adapt(aom_writer *w, int val, uint16_t *cdf, int n,
* @param [in,out] w multi-symbol entropy encoder * @param [in,out] w multi-symbol entropy encoder
* @param [in,out] model generic probability model * @param [in,out] model generic probability model
* @param [in] x variable being encoded * @param [in] x variable being encoded
* @param [in] max largest value possible
* @param [in,out] ExQ16 expectation of x (adapted) * @param [in,out] ExQ16 expectation of x (adapted)
* @param [in] integration integration period of ExQ16 (leaky average over * @param [in] integration integration period of ExQ16 (leaky average over
* 1<<integration samples) * 1<<integration samples)
*/ */
void generic_encode(aom_writer *w, generic_encoder *model, int x, int max, void generic_encode(aom_writer *w, generic_encoder *model, int x,
int *ex_q16, int integration) { int *ex_q16, int integration) {
int lg_q1; int lg_q1;
int shift; int shift;
int id; int id;
uint16_t *cdf; uint16_t *cdf;
int xs; int xs;