diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c index 6c2b6e5cf4c39bdc8cf67b389e9e4349e6491947..9d46a96782cbf4067c6a183f0d0b5a8c3befef96 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 4ea727ff40eddc878c12af204804da40c20e7e88..b2a941b685fc9ebbeb2cd4f0a2b8e6c020446628 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 1094e82b12c3ee5798d32f5ee95b92f34f096bb7..f000b964f0fa8a85b470caaee2323879a9a95f9a 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 f819d683954d10c0b550c934296b85db565fb322..4080f8c3442aaa654a2b37060972aae2873df9a8 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 95ec59061f5f6fb315cbf6db68988635eb90ee7f..d8496c4f289fde2092a973d886349b17a56e016e 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 63e5646ad2a419a56d193152983a8bb3ed70d4ba..2e42fd057779489e416f3114529f600a039b5f72 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 4073d9e047a89fc0735448ef94c1009d3cb4b342..462d2e398e0c227042a186743a6cec8ee2cc387d 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 f5086d66897f06f11477e0a61c16306f546bf9ac..93fecf23e7beff788196a6dc74b796441b493592 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 01c1db0b7c88c16fe3acdbbf69ea74cb0c3e4553..b393aa0c7563c35c74df722f6404a7feaca1df6b 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 d46b596353026b4bfc08cc7551b4f4ebb2336c21..f98fe8d4cc01aa0c0acc1d5c9dd6e9c7440964cf 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 cb72920062c085fa9460c1d526e4b400b0b47004..aefb56f9aae22de9f0c141bbcbfecde4da8c0433 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 47600661603fa6475dc8fe59699f6f7f2342a658..607d14c13f9c29bc9e5f5b547f34232c6bafacbb 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 4535688ea3c0169a5d8b55ccb9eb87117b982ee5..710cc4cd05292feb2f0b7e7d87b83025f9d1e34e 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 1894ea1661ecfb67742e0fe9065fef9e1c7d11e5..ab3f47e60c74fc3c6a6010b0e1df2e9e6de7a1b7 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -1069,8 +1069,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 ec2e361ee883b599ec815ef4fe52fafc1956b0f2..ff336d7dca4b1543638c22f53a0d0a9a4b04caa1 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 7d6db071d9184ebe883262485b14d39ef7cd4aaf..c6736fe68a512f792865d99334ac98ae8dfa0efb 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 5b9d231a7334f65391826cfc024fe98929ab850b..969e58175991b6c913e16a70c7c59dc5e0041c29 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -1391,7 +1391,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; @@ -2826,7 +2826,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 619f3e44ab056de1592d7e2151055d340d0f8e8d..7fb3d7f469d6aa86a5316185b8dbbeea76adb2c3 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;