Commit 7131cb0e authored by Dmitry Kovalev's avatar Dmitry Kovalev

General cleanups.

Removing unused constants, macros, and function declarations. Using
ROUND_POWER_OF_TWO macro, vp9_zero, vp9_copy where possible. Moving
#include from *.h to *.c. Merging for loops for motion vectors.

Change-Id: Ic3bf841764a2bb177128bb3a6d7aa8f68229cd13
parent d53fc9ee
......@@ -437,14 +437,10 @@ vp9_extra_bit vp9_extra_bits[12] = {
#include "vp9/common/vp9_default_coef_probs.h"
void vp9_default_coef_probs(VP9_COMMON *pc) {
vpx_memcpy(pc->fc.coef_probs[TX_4X4], default_coef_probs_4x4,
sizeof(pc->fc.coef_probs[TX_4X4]));
vpx_memcpy(pc->fc.coef_probs[TX_8X8], default_coef_probs_8x8,
sizeof(pc->fc.coef_probs[TX_8X8]));
vpx_memcpy(pc->fc.coef_probs[TX_16X16], default_coef_probs_16x16,
sizeof(pc->fc.coef_probs[TX_16X16]));
vpx_memcpy(pc->fc.coef_probs[TX_32X32], default_coef_probs_32x32,
sizeof(pc->fc.coef_probs[TX_32X32]));
vp9_copy(pc->fc.coef_probs[TX_4X4], default_coef_probs_4x4);
vp9_copy(pc->fc.coef_probs[TX_8X8], default_coef_probs_8x8);
vp9_copy(pc->fc.coef_probs[TX_16X16], default_coef_probs_16x16);
vp9_copy(pc->fc.coef_probs[TX_32X32], default_coef_probs_32x32);
}
// Neighborhood 5-tuples for various scans and blocksizes,
......
......@@ -80,7 +80,6 @@ extern vp9_extra_bit vp9_extra_bits[12]; /* indexed by token value */
coefficient band (and since zigzag positions 0, 1, and 2 are in
distinct bands). */
/*# define DC_TOKEN_CONTEXTS 3*/ /* 00, 0!0, !0!0 */
#define PREV_COEF_CONTEXTS 6
// #define ENTROPY_STATS
......
......@@ -61,8 +61,6 @@ extern struct vp9_token vp9_switchable_interp_encodings[VP9_SWITCHABLE_FILTERS];
void vp9_entropy_mode_init();
int vp9_mv_cont(const int_mv *l, const int_mv *a);
void vp9_setup_past_independence(struct VP9Common *cm, MACROBLOCKD *xd);
void vp9_init_mbmode_probs(struct VP9Common *x);
......
......@@ -16,7 +16,7 @@
#define MV_MAX_UPDATE_FACTOR 128
/* Integer pel reference mv threshold for use of high-precision 1/8 mv */
#define COMPANDED_MVREF_THRESH 8
#define COMPANDED_MVREF_THRESH 8
const vp9_tree_index vp9_mv_joint_tree[2 * MV_JOINTS - 2] = {
-MV_JOINT_ZERO, 2,
......@@ -169,8 +169,8 @@ void vp9_inc_mv(const MV *mv, nmv_context_counts *counts) {
++counts->comps[1].mvcount[MV_MAX + mv->col];
}
static void adapt_prob(vp9_prob *dest, vp9_prob prep, unsigned int ct[2]) {
*dest = merge_probs2(prep, ct, MV_COUNT_SAT, MV_MAX_UPDATE_FACTOR);
static vp9_prob adapt_prob(vp9_prob prep, const unsigned int ct[2]) {
return merge_probs2(prep, ct, MV_COUNT_SAT, MV_MAX_UPDATE_FACTOR);
}
void vp9_counts_process(nmv_context_counts *nmv_count, int usehp) {
......@@ -192,11 +192,8 @@ static unsigned int adapt_probs(unsigned int i,
const unsigned int right = tree[i + 1] <= 0
? num_events[-tree[i + 1]]
: adapt_probs(tree[i + 1], tree, this_probs, last_probs, num_events);
const unsigned int ct[2] = { left, right };
this_probs[i >> 1] = merge_probs2(last_probs[i >> 1], ct,
MV_COUNT_SAT, MV_MAX_UPDATE_FACTOR);
this_probs[i >> 1] = adapt_prob(last_probs[i >> 1], ct);
return left + right;
}
......@@ -215,31 +212,27 @@ void vp9_adapt_mv_probs(VP9_COMMON *cm, int usehp) {
adapt_probs(0, vp9_mv_joint_tree, ctx->joints, pre_ctx->joints, cts->joints);
for (i = 0; i < 2; ++i) {
adapt_prob(&ctx->comps[i].sign, pre_ctx->comps[i].sign, cts->comps[i].sign);
ctx->comps[i].sign = adapt_prob(pre_ctx->comps[i].sign, cts->comps[i].sign);
adapt_probs(0, vp9_mv_class_tree, ctx->comps[i].classes,
pre_ctx->comps[i].classes, cts->comps[i].classes);
adapt_probs(0, vp9_mv_class0_tree, ctx->comps[i].class0,
pre_ctx->comps[i].class0, cts->comps[i].class0);
for (j = 0; j < MV_OFFSET_BITS; ++j)
adapt_prob(&ctx->comps[i].bits[j], pre_ctx->comps[i].bits[j],
cts->comps[i].bits[j]);
}
ctx->comps[i].bits[j] = adapt_prob(pre_ctx->comps[i].bits[j],
cts->comps[i].bits[j]);
for (i = 0; i < 2; ++i) {
for (j = 0; j < CLASS0_SIZE; ++j)
adapt_probs(0, vp9_mv_fp_tree, ctx->comps[i].class0_fp[j],
pre_ctx->comps[i].class0_fp[j], cts->comps[i].class0_fp[j]);
adapt_probs(0, vp9_mv_fp_tree, ctx->comps[i].fp, pre_ctx->comps[i].fp,
cts->comps[i].fp);
}
if (usehp) {
for (i = 0; i < 2; ++i) {
adapt_prob(&ctx->comps[i].class0_hp, pre_ctx->comps[i].class0_hp,
cts->comps[i].class0_hp);
adapt_prob(&ctx->comps[i].hp, pre_ctx->comps[i].hp, cts->comps[i].hp);
if (usehp) {
ctx->comps[i].class0_hp = adapt_prob(pre_ctx->comps[i].class0_hp,
cts->comps[i].class0_hp);
ctx->comps[i].hp = adapt_prob(pre_ctx->comps[i].hp, cts->comps[i].hp);
}
}
}
......
......@@ -8,9 +8,11 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "vp9/common/vp9_extend.h"
#include "vpx_mem/vpx_mem.h"
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_extend.h"
static void copy_and_extend_plane(const uint8_t *src, int src_pitch,
uint8_t *dst, int dst_pitch,
int w, int h,
......@@ -107,14 +109,14 @@ void vp9_copy_and_extend_frame_with_rect(const YV12_BUFFER_CONFIG *src,
const int src_y_offset = srcy * src->y_stride + srcx;
const int dst_y_offset = srcy * dst->y_stride + srcx;
const int et_uv = (et_y + 1) >> 1;
const int el_uv = (el_y + 1) >> 1;
const int eb_uv = (eb_y + 1) >> 1;
const int er_uv = (er_y + 1) >> 1;
const int et_uv = ROUND_POWER_OF_TWO(et_y, 1);
const int el_uv = ROUND_POWER_OF_TWO(el_y, 1);
const int eb_uv = ROUND_POWER_OF_TWO(eb_y, 1);
const int er_uv = ROUND_POWER_OF_TWO(er_y, 1);
const int src_uv_offset = ((srcy * src->uv_stride) >> 1) + (srcx >> 1);
const int dst_uv_offset = ((srcy * dst->uv_stride) >> 1) + (srcx >> 1);
const int srch_uv = (srch + 1) >> 1;
const int srcw_uv = (srcw + 1) >> 1;
const int srch_uv = ROUND_POWER_OF_TWO(srch, 1);
const int srcw_uv = ROUND_POWER_OF_TWO(srcw, 1);
copy_and_extend_plane(src->y_buffer + src_y_offset, src->y_stride,
dst->y_buffer + dst_y_offset, dst->y_stride,
......
......@@ -400,7 +400,7 @@ void vp9_setup_scale_factors(VP9_COMMON *cm, int i) {
const int ref = cm->active_ref_idx[i];
struct scale_factors *const sf = &cm->active_ref_scale[i];
if (ref >= NUM_YV12_BUFFERS) {
memset(sf, 0, sizeof(*sf));
vp9_zero(*sf);
} else {
YV12_BUFFER_CONFIG *const fb = &cm->yv12_fb[ref];
vp9_setup_scale_factors_for_frame(sf,
......
......@@ -12,6 +12,7 @@
#define VP9_DECODER_VP9_DECODEMV_H_
#include "vp9/decoder/vp9_onyxd_int.h"
#include "vp9/decoder/vp9_dboolhuff.h"
void vp9_prepare_read_mode_info(VP9D_COMP* pbi, vp9_reader *r);
......
......@@ -31,8 +31,10 @@
#include "vp9/decoder/vp9_detokenize.h"
#include "vp9/decoder/vp9_decodemv.h"
#include "vp9/decoder/vp9_dsubexp.h"
#include "vp9/decoder/vp9_idct_blk.h"
#include "vp9/decoder/vp9_onyxd_int.h"
#include "vp9/decoder/vp9_read_bit_buffer.h"
#include "vp9/decoder/vp9_treereader.h"
static int read_be32(const uint8_t *p) {
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
......
......@@ -15,8 +15,10 @@
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_seg_common.h"
#include "vp9/decoder/vp9_dboolhuff.h"
#include "vp9/decoder/vp9_detokenize.h"
#include "vp9/decoder/vp9_onyxd_int.h"
#include "vp9/decoder/vp9_treereader.h"
#define EOB_CONTEXT_NODE 0
#define ZERO_CONTEXT_NODE 1
......@@ -93,27 +95,18 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
FRAME_CONTEXT *const fc = &cm->fc;
FRAME_COUNTS *const counts = &cm->counts;
ENTROPY_CONTEXT above_ec, left_ec;
int pt, c = 0;
int band;
vp9_prob (*coef_probs)[PREV_COEF_CONTEXTS][UNCONSTRAINED_NODES];
const int ref = xd->mode_info_context->mbmi.ref_frame[0] != INTRA_FRAME;
int band, pt, c = 0;
vp9_prob (*coef_probs)[PREV_COEF_CONTEXTS][UNCONSTRAINED_NODES] =
fc->coef_probs[txfm_size][type][ref];
vp9_prob coef_probs_full[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
uint8_t load_map[COEF_BANDS][PREV_COEF_CONTEXTS] = {
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
};
uint8_t load_map[COEF_BANDS][PREV_COEF_CONTEXTS] = { { 0 } };
vp9_prob *prob;
vp9_coeff_count_model *coef_counts;
const int ref = xd->mode_info_context->mbmi.ref_frame[0] != INTRA_FRAME;
vp9_coeff_count_model *coef_counts = counts->coef[txfm_size];
const int16_t *scan, *nb;
uint8_t token_cache[1024];
const uint8_t * band_translate;
coef_probs = fc->coef_probs[txfm_size][type][ref];
coef_counts = counts->coef[txfm_size];
switch (txfm_size) {
default:
case TX_4X4: {
......
......@@ -13,6 +13,7 @@
#define VP9_DECODER_VP9_DETOKENIZE_H_
#include "vp9/decoder/vp9_onyxd_int.h"
#include "vp9/decoder/vp9_dboolhuff.h"
int vp9_decode_tokens(VP9D_COMP* pbi, vp9_reader *r, BLOCK_SIZE_TYPE bsize);
......
......@@ -8,9 +8,9 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <stdio.h>
#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include "vp9/common/vp9_onyxc_int.h"
#if CONFIG_POSTPROC
......@@ -114,7 +114,7 @@ VP9D_PTR vp9_create_decompressor(VP9D_CONFIG *oxcf) {
if (!pbi)
return NULL;
vpx_memset(pbi, 0, sizeof(VP9D_COMP));
vp9_zero(*pbi);
if (setjmp(pbi->common.error.jmp)) {
pbi->common.error.setjmp = 0;
......
......@@ -15,9 +15,7 @@
#include "vp9/common/vp9_onyxc_int.h"
#include "vp9/decoder/vp9_idct_blk.h"
#include "vp9/decoder/vp9_onyxd.h"
#include "vp9/decoder/vp9_treereader.h"
typedef struct VP9Decompressor {
DECLARE_ALIGNED(16, MACROBLOCKD, mb);
......
......@@ -15,7 +15,6 @@
#include "vp9/common/vp9_treecoder.h"
#include "vp9/decoder/vp9_dboolhuff.h"
#define vp9_read_prob(r) ((vp9_prob)vp9_read_literal(r, 8))
#define vp9_read_and_apply_sign(r, value) (vp9_read_bit(r) ? -(value) : (value))
// Intent of tree data structure is to make decoding trivial.
......
......@@ -1066,8 +1066,7 @@ static void choose_partitioning(VP9_COMP *cpi, MODE_INFO *m, int mi_row,
int dp;
int pixels_wide = 64, pixels_high = 64;
vpx_memset(&vt, 0, sizeof(vt));
vp9_zero(vt);
set_offsets(cpi, mi_row, mi_col, BLOCK_SIZE_SB64X64);
if (xd->mb_to_right_edge < 0)
......
......@@ -2139,8 +2139,7 @@ void vp9_second_pass(VP9_COMP *cpi) {
adjust_active_maxq(cpi->active_worst_quality, tmp_q);
}
#endif
vpx_memset(&this_frame, 0, sizeof(FIRSTPASS_STATS));
vp9_zero(this_frame);
if (EOF == input_stats(cpi, &this_frame))
return;
......@@ -2318,7 +2317,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
double kf_group_coded_err = 0.0;
double recent_loop_decay[8] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
vpx_memset(&next_frame, 0, sizeof(next_frame)); // assure clean
vp9_zero(next_frame);
vp9_clear_system_state(); // __asm emms;
start_position = cpi->twopass.stats_in;
......
......@@ -248,8 +248,7 @@ static void update_mbgraph_frame_stats(VP9_COMP *cpi,
int_mv arf_top_mv, gld_top_mv;
MODE_INFO mi_local;
// Make sure the mi context starts in a consistent state.
memset(&mi_local, 0, sizeof(mi_local));
vp9_zero(mi_local);
// Set up limit values for motion vectors to prevent them extending outside the UMV borders
arf_top_mv.as_int = 0;
......
......@@ -1383,7 +1383,7 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
cm = &cpi->common;
vpx_memset(cpi, 0, sizeof(VP9_COMP));
vp9_zero(*cpi);
if (setjmp(cm->error.jmp)) {
VP9_PTR ptr = ctx.ptr;
......@@ -2818,7 +2818,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
}
#endif
loop_count = 0;
vpx_memset(cpi->rd_tx_select_threshes, 0, sizeof(cpi->rd_tx_select_threshes));
vp9_zero(cpi->rd_tx_select_threshes);
if (cm->frame_type != KEY_FRAME) {
/* TODO: Decide this more intelligently */
......
......@@ -2204,7 +2204,7 @@ static int64_t rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x,
MB_MODE_INFO *mbmi = &mi->mbmi;
int mode_idx;
vpx_memset(bsi, 0, sizeof(*bsi));
vp9_zero(*bsi);
bsi->segment_rd = best_rd;
bsi->ref_mv = best_ref_mv;
......
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