summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2013-07-25 14:13:44 -0700
committerDmitry Kovalev <dkovalev@google.com>2013-07-25 14:13:48 -0700
commit7131cb0e3deddee6271ee04e47496c9b9a03da7e (patch)
tree2d7fa70c5901f7fcae6385e4c47f707e93ee53dd /vp9
parentd53fc9ee4e56212f7e42cbaa4f0c99b8d443d602 (diff)
downloadlibvpx-7131cb0e3deddee6271ee04e47496c9b9a03da7e.tar
libvpx-7131cb0e3deddee6271ee04e47496c9b9a03da7e.tar.gz
libvpx-7131cb0e3deddee6271ee04e47496c9b9a03da7e.tar.bz2
libvpx-7131cb0e3deddee6271ee04e47496c9b9a03da7e.zip
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
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_entropy.c12
-rw-r--r--vp9/common/vp9_entropy.h1
-rw-r--r--vp9/common/vp9_entropymode.h2
-rw-r--r--vp9/common/vp9_entropymv.c29
-rw-r--r--vp9/common/vp9_extend.c16
-rw-r--r--vp9/common/vp9_reconinter.c2
-rw-r--r--vp9/decoder/vp9_decodemv.h1
-rw-r--r--vp9/decoder/vp9_decodframe.c2
-rw-r--r--vp9/decoder/vp9_detokenize.c25
-rw-r--r--vp9/decoder/vp9_detokenize.h1
-rw-r--r--vp9/decoder/vp9_onyxd_if.c6
-rw-r--r--vp9/decoder/vp9_onyxd_int.h2
-rw-r--r--vp9/decoder/vp9_treereader.h1
-rw-r--r--vp9/encoder/vp9_encodeframe.c3
-rw-r--r--vp9/encoder/vp9_firstpass.c5
-rw-r--r--vp9/encoder/vp9_mbgraph.c3
-rw-r--r--vp9/encoder/vp9_onyx_if.c4
-rw-r--r--vp9/encoder/vp9_rdopt.c2
18 files changed, 48 insertions, 69 deletions
diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c
index 6c2b6e5cf..9d46a9678 100644
--- a/vp9/common/vp9_entropy.c
+++ b/vp9/common/vp9_entropy.c
@@ -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,
diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h
index 4ea727ff4..b2a941b68 100644
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -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
diff --git a/vp9/common/vp9_entropymode.h b/vp9/common/vp9_entropymode.h
index a71585a92..2e3599404 100644
--- a/vp9/common/vp9_entropymode.h
+++ b/vp9/common/vp9_entropymode.h
@@ -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);
diff --git a/vp9/common/vp9_entropymv.c b/vp9/common/vp9_entropymv.c
index f819d6839..4080f8c34 100644
--- a/vp9/common/vp9_entropymv.c
+++ b/vp9/common/vp9_entropymv.c
@@ -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);
}
}
}
diff --git a/vp9/common/vp9_extend.c b/vp9/common/vp9_extend.c
index 95ec59061..d8496c4f2 100644
--- a/vp9/common/vp9_extend.c
+++ b/vp9/common/vp9_extend.c
@@ -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,
diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c
index 63e5646ad..2e42fd057 100644
--- a/vp9/common/vp9_reconinter.c
+++ b/vp9/common/vp9_reconinter.c
@@ -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,
diff --git a/vp9/decoder/vp9_decodemv.h b/vp9/decoder/vp9_decodemv.h
index 4073d9e04..462d2e398 100644
--- a/vp9/decoder/vp9_decodemv.h
+++ b/vp9/decoder/vp9_decodemv.h
@@ -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);
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index f5086d668..93fecf23e 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -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];
diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c
index 01c1db0b7..b393aa0c7 100644
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -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: {
diff --git a/vp9/decoder/vp9_detokenize.h b/vp9/decoder/vp9_detokenize.h
index d46b59635..f98fe8d4c 100644
--- a/vp9/decoder/vp9_detokenize.h
+++ b/vp9/decoder/vp9_detokenize.h
@@ -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);
diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c
index cb7292006..aefb56f9a 100644
--- a/vp9/decoder/vp9_onyxd_if.c
+++ b/vp9/decoder/vp9_onyxd_if.c
@@ -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;
diff --git a/vp9/decoder/vp9_onyxd_int.h b/vp9/decoder/vp9_onyxd_int.h
index 476006616..607d14c13 100644
--- a/vp9/decoder/vp9_onyxd_int.h
+++ b/vp9/decoder/vp9_onyxd_int.h
@@ -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);
diff --git a/vp9/decoder/vp9_treereader.h b/vp9/decoder/vp9_treereader.h
index 4535688ea..710cc4cd0 100644
--- a/vp9/decoder/vp9_treereader.h
+++ b/vp9/decoder/vp9_treereader.h
@@ -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.
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 78a75c324..a4e389161 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -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)
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index ec2e361ee..ff336d7dc 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -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;
diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c
index 7d6db071d..c6736fe68 100644
--- a/vp9/encoder/vp9_mbgraph.c
+++ b/vp9/encoder/vp9_mbgraph.c
@@ -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;
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index fc19bd951..8e625b710 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -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 */
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index afcb45b99..b0e422e75 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -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;