Commit a0d6f117 authored by Yushin Cho's avatar Yushin Cho
Browse files

Change PVQ's partition split symbols to use dyadic and ec_adapt adaptation

Change-Id: I2fd1d6f32b1b395dfdbe556b96dddf65f3cabbbe
parent 0077927b
...@@ -40,9 +40,6 @@ void generic_model_init(generic_encoder *model); ...@@ -40,9 +40,6 @@ void generic_model_init(generic_encoder *model);
#define OD_CDFS_INIT(cdf, val) aom_cdf_init(&cdf[0][0], \ #define OD_CDFS_INIT(cdf, val) aom_cdf_init(&cdf[0][0], \
sizeof(cdf)/sizeof(cdf[0]), sizeof(cdf[0])/sizeof(cdf[0][0]), val, val) sizeof(cdf)/sizeof(cdf[0]), sizeof(cdf[0])/sizeof(cdf[0][0]), val, val)
#define OD_CDFS_INIT_FIRST(cdf, val, first) aom_cdf_init(&cdf[0][0], \
sizeof(cdf)/sizeof(cdf[0]), sizeof(cdf[0])/sizeof(cdf[0][0]), val, first)
#define OD_SINGLE_CDF_INIT(cdf, val) aom_cdf_init(cdf, \ #define OD_SINGLE_CDF_INIT(cdf, val) aom_cdf_init(cdf, \
1, sizeof(cdf)/sizeof(cdf[0]), val, val) 1, sizeof(cdf)/sizeof(cdf[0]), val, val)
......
...@@ -211,8 +211,7 @@ void od_adapt_pvq_ctx_reset(od_pvq_adapt_ctx *state, int is_keyframe) { ...@@ -211,8 +211,7 @@ void od_adapt_pvq_ctx_reset(od_pvq_adapt_ctx *state, int is_keyframe) {
OD_CDFS_INIT(state->pvq_gaintheta_cdf, state->pvq_gaintheta_increment >> 2); OD_CDFS_INIT(state->pvq_gaintheta_cdf, state->pvq_gaintheta_increment >> 2);
state->pvq_skip_dir_increment = 128; state->pvq_skip_dir_increment = 128;
OD_CDFS_INIT(state->pvq_skip_dir_cdf, state->pvq_skip_dir_increment >> 2); OD_CDFS_INIT(state->pvq_skip_dir_cdf, state->pvq_skip_dir_increment >> 2);
ctx->pvq_split_increment = 128; OD_CDFS_INIT(ctx->pvq_split_cdf, 0);
OD_CDFS_INIT(ctx->pvq_split_cdf, ctx->pvq_split_increment >> 1);
} }
/* QMs are arranged from smallest to largest blocksizes, first for /* QMs are arranged from smallest to largest blocksizes, first for
......
...@@ -124,8 +124,7 @@ struct od_pvq_codeword_ctx { ...@@ -124,8 +124,7 @@ struct od_pvq_codeword_ctx {
int pvq_k1_increment; int pvq_k1_increment;
/* CDFs are size 16 despite the fact that we're using less than that. */ /* CDFs are size 16 despite the fact that we're using less than that. */
uint16_t pvq_k1_cdf[12][16]; uint16_t pvq_k1_cdf[12][16];
uint16_t pvq_split_cdf[22*7][8]; uint16_t pvq_split_cdf[22*7][CDF_SIZE(8)];
int pvq_split_increment;
}; };
struct od_pvq_adapt_ctx { struct od_pvq_adapt_ctx {
......
...@@ -33,8 +33,8 @@ static int aom_decode_pvq_split_(aom_reader *r, od_pvq_codeword_ctx *adapt, ...@@ -33,8 +33,8 @@ static int aom_decode_pvq_split_(aom_reader *r, od_pvq_codeword_ctx *adapt,
if (sum == 0) return 0; if (sum == 0) return 0;
shift = OD_MAXI(0, OD_ILOG(sum) - 3); shift = OD_MAXI(0, OD_ILOG(sum) - 3);
fctx = 7*ctx + (sum >> shift) - 1; fctx = 7*ctx + (sum >> shift) - 1;
msbs = aom_decode_cdf_adapt(r, adapt->pvq_split_cdf[fctx], msbs = aom_read_symbol_pvq(r, adapt->pvq_split_cdf[fctx], (sum >> shift) + 1,
(sum >> shift) + 1, adapt->pvq_split_increment, ACCT_STR_NAME); ACCT_STR_NAME);
if (shift) count = aom_read_literal(r, shift, ACCT_STR_NAME); if (shift) count = aom_read_literal(r, shift, ACCT_STR_NAME);
count += msbs << shift; count += msbs << shift;
if (count > sum) { if (count > sum) {
......
...@@ -28,6 +28,13 @@ ...@@ -28,6 +28,13 @@
#include "av1/decoder/pvq_decoder.h" #include "av1/decoder/pvq_decoder.h"
#include "aom_ports/system_state.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, static void aom_decode_pvq_codeword(aom_reader *r, od_pvq_codeword_ctx *ctx,
od_coeff *y, int n, int k) { od_coeff *y, int n, int k) {
int i; int i;
......
...@@ -18,6 +18,12 @@ ...@@ -18,6 +18,12 @@
# include "av1/common/pvq.h" # include "av1/common/pvq.h"
# include "av1/decoder/decint.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, 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);
......
...@@ -35,8 +35,7 @@ static void aom_encode_pvq_split(aom_writer *w, od_pvq_codeword_ctx *adapt, ...@@ -35,8 +35,7 @@ static void aom_encode_pvq_split(aom_writer *w, od_pvq_codeword_ctx *adapt,
sum >>= shift; sum >>= shift;
} }
fctx = 7*ctx + sum - 1; fctx = 7*ctx + sum - 1;
aom_encode_cdf_adapt(w, count, adapt->pvq_split_cdf[fctx], sum + 1, aom_write_symbol_pvq(w, count, adapt->pvq_split_cdf[fctx], sum + 1);
adapt->pvq_split_increment);
if (shift) aom_write_literal(w, rest, shift); if (shift) aom_write_literal(w, rest, shift);
} }
......
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
dot-product of the 1st band of chroma with the luma ref doesn't overflow.*/ 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) #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, static void aom_encode_pvq_codeword(aom_writer *w, od_pvq_codeword_ctx *adapt,
const od_coeff *in, int n, int k) { const od_coeff *in, int n, int k) {
int i; int i;
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
# include "av1/common/pvq.h" # include "av1/common/pvq.h"
# include "av1/encoder/encint.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, void aom_encode_band_pvq_splits(aom_writer *w, od_pvq_codeword_ctx *adapt,
const int *y, int n, int k, int level); const int *y, int n, int k, int level);
......
Markdown is supported
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