Commit 5b4a7264 authored by Timothy B. Terriberry's avatar Timothy B. Terriberry Committed by Tim Terriberry
Browse files

pvq: Remove non-dyadic CDF initialization.

This was still being used for CDFs whose size might not match the
declared array size. We replace it with an intialization macro
intended explicitly for this purpose.

Change-Id: I65d9a3c871e1d1bdd906f20ff3a264f58d8e5620
parent d5b89d0d
......@@ -17,16 +17,6 @@
#include "generic_code.h"
void aom_cdf_init(uint16_t *cdf, int ncdfs, int nsyms, int val, int first) {
int i;
int j;
for (i = 0; i < ncdfs; i++) {
for (j = 0; j < nsyms; j++) {
cdf[i*nsyms + j] = val*j + first;
}
}
}
void aom_cdf_init_q15_1D(uint16_t *cdf, int nsyms, int cdf_size) {
int i;
for (i = 0; i < nsyms; i++)
......
......@@ -35,14 +35,12 @@ typedef struct {
void generic_model_init(generic_encoder *model);
#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)
#define OD_SINGLE_CDF_INIT(cdf, val) aom_cdf_init(cdf, \
1, sizeof(cdf)/sizeof(cdf[0]), val, val)
#define OD_SINGLE_CDF_INIT_FIRST(cdf, val, first) aom_cdf_init(cdf, \
1, sizeof(cdf)/sizeof(cdf[0]), val, first)
/* 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.
......
......@@ -187,16 +187,16 @@ void od_adapt_pvq_ctx_reset(od_pvq_adapt_ctx *state, int is_keyframe) {
int pli;
int bs;
ctx = &state->pvq_codeword_ctx;
OD_CDFS_INIT(state->pvq_param_model[0].cdf, 0);
OD_CDFS_INIT(state->pvq_param_model[1].cdf, 0);
OD_CDFS_INIT(state->pvq_param_model[2].cdf, 0);
OD_CDFS_INIT_DYNAMIC(state->pvq_param_model[0].cdf);
OD_CDFS_INIT_DYNAMIC(state->pvq_param_model[1].cdf);
OD_CDFS_INIT_DYNAMIC(state->pvq_param_model[2].cdf);
for (i = 0; i < 2*OD_TXSIZES; i++) {
ctx->pvq_adapt[4*i + OD_ADAPT_K_Q8] = 384;
ctx->pvq_adapt[4*i + OD_ADAPT_SUM_EX_Q8] = 256;
ctx->pvq_adapt[4*i + OD_ADAPT_COUNT_Q8] = 104;
ctx->pvq_adapt[4*i + OD_ADAPT_COUNT_EX_Q8] = 128;
}
OD_CDFS_INIT(ctx->pvq_k1_cdf, 0);
OD_CDFS_INIT_DYNAMIC(ctx->pvq_k1_cdf);
for (pli = 0; pli < OD_NPLANES_MAX; pli++) {
for (bs = 0; bs < OD_TXSIZES; bs++)
for (i = 0; i < PVQ_MAX_PARTITIONS; i++) {
......@@ -206,9 +206,9 @@ void od_adapt_pvq_ctx_reset(od_pvq_adapt_ctx *state, int is_keyframe) {
for (i = 0; i < OD_TXSIZES*PVQ_MAX_PARTITIONS; i++) {
state->pvq_ext[i] = is_keyframe ? 24576 : 2 << 16;
}
OD_CDFS_INIT(state->pvq_gaintheta_cdf, 0);
OD_CDFS_INIT_DYNAMIC(state->pvq_gaintheta_cdf);
OD_CDFS_INIT_Q15(state->pvq_skip_dir_cdf);
OD_CDFS_INIT(ctx->pvq_split_cdf, 0);
OD_CDFS_INIT_DYNAMIC(ctx->pvq_split_cdf);
}
/* QMs are arranged from smallest to largest blocksizes, first for
......
......@@ -18,7 +18,7 @@ void od_adapt_ctx_reset(od_adapt_ctx *adapt, int is_keyframe) {
OD_CDFS_INIT_Q15(adapt->skip_cdf);
for (pli = 0; pli < OD_NPLANES_MAX; pli++) {
int i;
OD_CDFS_INIT(adapt->model_dc[pli].cdf, 0);
OD_CDFS_INIT_DYNAMIC(adapt->model_dc[pli].cdf);
for (i = 0; i < OD_TXSIZES; i++) {
int j;
adapt->ex_g[pli][i] = 8;
......
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