Commit 9e96f79a authored by Nathan E. Egge's avatar Nathan E. Egge
Browse files

Use aom_writer with od_encode_band_pvq_splits().

Change the od_encode_band_pvq_splits() and od_encode_pvq_split()
 functions to take an aom_writer struct instead of an od_ec_enc struct.
Rename od_encode_band_pvq_splits() to aom_encode_band_pvq_splits() and
 od_encode_pvq_split() to aom_encode_pvq_split().

Change-Id: I72e6684e032f4c8f9f9133c6102f870830001712
parent 13e44fb4
......@@ -23,7 +23,7 @@
#include "av1/common/pvq.h"
#include "pvq_encoder.h"
static void od_encode_pvq_split(od_ec_enc *ec, od_pvq_codeword_ctx *adapt,
static void aom_encode_pvq_split(aom_writer *w, od_pvq_codeword_ctx *adapt,
int count, int sum, int ctx) {
int shift;
int rest;
......@@ -36,12 +36,16 @@ static void od_encode_pvq_split(od_ec_enc *ec, od_pvq_codeword_ctx *adapt,
sum >>= shift;
}
fctx = 7*ctx + sum - 1;
od_encode_cdf_adapt(ec, count, adapt->pvq_split_cdf[fctx],
#if CONFIG_DAALA_EC
od_encode_cdf_adapt(&w->ec, count, adapt->pvq_split_cdf[fctx],
sum + 1, adapt->pvq_split_increment);
if (shift) od_ec_enc_bits(ec, rest, shift);
if (shift) od_ec_enc_bits(&w->ec, rest, shift);
#else
# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
}
void od_encode_band_pvq_splits(od_ec_enc *ec, od_pvq_codeword_ctx *adapt,
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;
......@@ -53,16 +57,20 @@ void od_encode_band_pvq_splits(od_ec_enc *ec, od_pvq_codeword_ctx *adapt,
cdf_id = od_pvq_k1_ctx(n, level == 0);
for (pos = 0; !y[pos]; pos++);
OD_ASSERT(pos < n);
od_encode_cdf_adapt(ec, pos, adapt->pvq_k1_cdf[cdf_id], n,
#if CONFIG_DAALA_EC
od_encode_cdf_adapt(&w->ec, pos, adapt->pvq_k1_cdf[cdf_id], n,
adapt->pvq_k1_increment);
#else
# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
}
else {
mid = n >> 1;
count_right = k;
for (i = 0; i < mid; i++) count_right -= abs(y[i]);
od_encode_pvq_split(ec, adapt, count_right, k, od_pvq_size_ctx(n));
od_encode_band_pvq_splits(ec, adapt, y, mid, k - count_right, level + 1);
od_encode_band_pvq_splits(ec, adapt, y + mid, n - mid, count_right,
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);
}
}
......
......@@ -35,11 +35,7 @@
static void aom_encode_pvq_codeword(aom_writer *w, od_pvq_codeword_ctx *adapt,
const od_coeff *in, int n, int k) {
int i;
#if CONFIG_DAALA_EC
od_encode_band_pvq_splits(&w->ec, adapt, in, n, k, 0);
#else
# error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
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);
}
......
......@@ -21,7 +21,7 @@
#define PVQ_CHROMA_RD 1
void od_encode_band_pvq_splits(od_ec_enc *ec, od_pvq_codeword_ctx *adapt,
void aom_encode_band_pvq_splits(aom_writer *w, od_pvq_codeword_ctx *adapt,
const int *y, int n, int k, int level);
void od_laplace_encode_special(od_ec_enc *enc, int x, unsigned decay, int max);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment