Merging robust and nodesync in PVQ
The variables robust and nodesync appear to represent the same concept.
In order to simplify, they are merged into nodesync. This change does
not alter the bitstream as this value is hard coded to 1.
Change-Id: If9b2eb52f628e3f615b6270e26569815d5e79ae0
diff --git a/av1/decoder/pvq_decoder.c b/av1/decoder/pvq_decoder.c
index 4c32afd..db3f20d 100644
--- a/av1/decoder/pvq_decoder.c
+++ b/av1/decoder/pvq_decoder.c
@@ -90,27 +90,27 @@
/** 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] robust stream is robust to error in the reference
+ * @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] nodesync stream is robust to error in the reference
* @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
+ * @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,
@@ -123,7 +123,7 @@
od_coeff *out,
int *noref,
od_val16 beta,
- int robust,
+ int nodesync,
int is_keyframe,
int pli,
int cdf_ctx,
@@ -143,7 +143,6 @@
od_val32 gain_offset;
od_coeff y[MAXN];
int qg;
- int nodesync;
int id;
int i;
od_val16 ref16[MAXN];
@@ -151,9 +150,6 @@
theta = 0;
gr = 0;
gain_offset = 0;
- /* We always use the robust bitstream for keyframes to avoid having
- PVQ and entropy decoding depending on each other, hurting parallelism. */
- nodesync = robust || is_keyframe;
/* Skip is per-direction. For band=0, we can use any of the flags. */
if (skip_rest[(band + 2) % 3]) {
qg = 0;
@@ -278,19 +274,19 @@
/** 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] robust stream is robust to error in the reference
+ * @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] nodesync stream is robust to error in the reference
* @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] qm QM with magnitude compensation
- * @param [in] qm_inv Inverse of QM with magnitude compensation
+ * @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,
@@ -299,7 +295,7 @@
int pli,
int bs,
const od_val16 *beta,
- int robust,
+ int nodesync,
int is_keyframe,
unsigned int *flags,
PVQ_SKIP_TYPE ac_dc_coded,
@@ -360,7 +356,7 @@
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], robust, is_keyframe, pli,
+ &noref[i], beta[i], nodesync, 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]);
diff --git a/av1/decoder/pvq_decoder.h b/av1/decoder/pvq_decoder.h
index f4dd390..e08e034 100644
--- a/av1/decoder/pvq_decoder.h
+++ b/av1/decoder/pvq_decoder.h
@@ -28,7 +28,7 @@
int max 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 robust, int is_keyframe,
+ int pli, int bs, const od_val16 *beta, int nodesync, int is_keyframe,
unsigned int *flags, PVQ_SKIP_TYPE ac_dc_coded, const int16_t *qm,
const int16_t *qm_inv);
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index bdc2617..3198f89 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -2343,7 +2343,7 @@
const int is_keyframe = 0;
const int encode_flip = 0;
const int flip = 0;
- const int robust = 1;
+ const int nodesync = 1;
int i;
const int has_dc_skip = 1;
int *exg = &adapt->pvq.pvq_exg[plane][tx_size][0];
@@ -2366,7 +2366,7 @@
pvq_encode_partition(
w, pvq->qg[i], pvq->theta[i], pvq->max_theta[i],
pvq->y + pvq->off[i], pvq->size[i], pvq->k[i], model, adapt,
- exg + i, ext + i, robust || is_keyframe,
+ exg + i, ext + i, nodesync,
(plane != 0) * OD_TXSIZES * PVQ_MAX_PARTITIONS +
pvq->bs * PVQ_MAX_PARTITIONS + i,
is_keyframe, i == 0 && (i < pvq->nb_bands - 1),
diff --git a/av1/encoder/pvq_encoder.c b/av1/encoder/pvq_encoder.c
index edf9810..21a26b3 100644
--- a/av1/encoder/pvq_encoder.c
+++ b/av1/encoder/pvq_encoder.c
@@ -290,33 +290,33 @@
* 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] max_theta maximum value of itheta that could have been
- * @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] robust make stream robust to error in the reference
+ * @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] max_theta maximum value of itheta that could have been
+ * @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] nodesync make stream robust to error in the reference
* @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] 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
+ * @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 *max_theta, int *vk,
- od_val16 beta, double *skip_diff, int robust, 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) {
+ int n, int q0, od_coeff *y, int *itheta, int *max_theta, int *vk,
+ od_val16 beta, double *skip_diff, int nodesync, 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];
@@ -468,7 +468,7 @@
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, qtheta, 0, n, beta, robust || is_keyframe);
+ k = od_pvq_compute_k(qcg, j, qtheta, 0, n, beta, nodesync);
items[idx].gain = i;
items[idx].theta = j;
items[idx].k = k;
@@ -560,7 +560,7 @@
double cost;
od_val32 qcg;
qcg = OD_SHL(i, OD_CGAIN_SHIFT);
- k = od_pvq_compute_k(qcg, -1, -1, 1, n, beta, robust || is_keyframe);
+ k = od_pvq_compute_k(qcg, -1, -1, 1, n, beta, nodesync);
/* Compute the minimal possible distortion by not taking the PVQ
cos_dist into account. */
dist = gain_weight*(qcg - cg)*(qcg - cg);
@@ -755,7 +755,7 @@
* @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] robust make stream robust to error in the reference
+ * @param [in] nodesync make stream robust to error in the reference
* @param [in] is_keyframe whether we're encoding a keyframe
* @param [in] q_scaling scaling factor to apply to quantizer
* @param [in] bx x-coordinate of this block
@@ -777,7 +777,7 @@
int pli,
int bs,
const od_val16 *beta,
- int robust,
+ int nodesync,
int is_keyframe,
int q_scaling,
int bx,
@@ -877,7 +877,7 @@
qg[i] = pvq_theta(out + off[i], in + off[i], ref + off[i], size[i],
q, y + off[i], &theta[i], &max_theta[i],
- &k[i], beta[i], &skip_diff, robust, is_keyframe, pli, &enc->state.adapt,
+ &k[i], beta[i], &skip_diff, nodesync, is_keyframe, pli, &enc->state.adapt,
qm + off[i], qm_inv + off[i], enc->pvq_norm_lambda, speed);
}
od_encode_checkpoint(enc, &buf);
@@ -964,7 +964,7 @@
if (i == 0 || (!skip_rest && !(skip_dir & (1 << ((i - 1)%3))))) {
pvq_encode_partition(&enc->w, qg[i], theta[i], max_theta[i], y + off[i],
size[i], k[i], model, &enc->state.adapt, exg + i, ext + i,
- robust || is_keyframe, (pli != 0)*OD_TXSIZES*PVQ_MAX_PARTITIONS
+ nodesync, (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);
}
diff --git a/av1/encoder/pvq_encoder.h b/av1/encoder/pvq_encoder.h
index 9023102..50a5e8a 100644
--- a/av1/encoder/pvq_encoder.h
+++ b/av1/encoder/pvq_encoder.h
@@ -50,7 +50,7 @@
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 robust, int is_keyframe, int q_scaling, int bx,
+ const od_val16 *beta, int nodesync, int is_keyframe, int q_scaling, int bx,
int by, const int16_t *qm, const int16_t *qm_inv, int speed,
PVQ_INFO *pvq_info);