Using vp9_copy and vp9_zero instead of custom code.

Change-Id: Id9b6ceeddca3f9b34bfada5c499b1e7a2f42c30b
This commit is contained in:
Dmitry Kovalev 2013-07-02 17:19:16 -07:00
parent 31403080ff
commit 429070987a
7 changed files with 32 additions and 39 deletions

View File

@ -8,11 +8,11 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "vpx_mem/vpx_mem.h"
#include "vp9/common/vp9_alloccommon.h"
#include "vp9/common/vp9_onyxc_int.h" #include "vp9/common/vp9_onyxc_int.h"
#include "vp9/common/vp9_seg_common.h" #include "vp9/common/vp9_seg_common.h"
#include "vp9/common/vp9_alloccommon.h"
#include "vpx_mem/vpx_mem.h"
static const vp9_prob default_kf_uv_probs[VP9_INTRA_MODES] static const vp9_prob default_kf_uv_probs[VP9_INTRA_MODES]
[VP9_INTRA_MODES - 1] = { [VP9_INTRA_MODES - 1] = {
@ -246,9 +246,8 @@ void vp9_entropy_mode_init() {
} }
void vp9_init_mode_contexts(VP9_COMMON *pc) { void vp9_init_mode_contexts(VP9_COMMON *pc) {
vpx_memset(pc->fc.inter_mode_counts, 0, sizeof(pc->fc.inter_mode_counts)); vp9_zero(pc->fc.inter_mode_counts);
vpx_memcpy(pc->fc.inter_mode_probs, default_inter_mode_probs, vp9_copy(pc->fc.inter_mode_probs, default_inter_mode_probs);
sizeof(default_inter_mode_probs));
} }
void vp9_accum_mv_refs(VP9_COMMON *pc, void vp9_accum_mv_refs(VP9_COMMON *pc,
@ -447,8 +446,8 @@ static void set_default_lf_deltas(MACROBLOCKD *xd) {
xd->ref_lf_deltas[GOLDEN_FRAME] = -1; xd->ref_lf_deltas[GOLDEN_FRAME] = -1;
xd->ref_lf_deltas[ALTREF_FRAME] = -1; xd->ref_lf_deltas[ALTREF_FRAME] = -1;
xd->mode_lf_deltas[0] = 0; // Zero xd->mode_lf_deltas[0] = 0;
xd->mode_lf_deltas[1] = 0; // New mv xd->mode_lf_deltas[1] = 0;
} }
void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) { void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
@ -461,14 +460,15 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
vpx_memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols)); vpx_memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
// Reset the mode ref deltas for loop filter // Reset the mode ref deltas for loop filter
vpx_memset(xd->last_ref_lf_deltas, 0, sizeof(xd->last_ref_lf_deltas)); vp9_zero(xd->last_ref_lf_deltas);
vpx_memset(xd->last_mode_lf_deltas, 0, sizeof(xd->last_mode_lf_deltas)); vp9_zero(xd->last_mode_lf_deltas);
set_default_lf_deltas(xd); set_default_lf_deltas(xd);
vp9_default_coef_probs(cm); vp9_default_coef_probs(cm);
vp9_init_mbmode_probs(cm); vp9_init_mbmode_probs(cm);
vpx_memcpy(cm->kf_y_mode_prob, vp9_kf_default_bmode_probs,
sizeof(vp9_kf_default_bmode_probs)); vp9_copy(cm->kf_y_mode_prob, vp9_kf_default_bmode_probs);
vp9_init_mv_probs(cm); vp9_init_mv_probs(cm);
// To force update of the sharpness // To force update of the sharpness
@ -476,15 +476,14 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
vp9_init_mode_contexts(cm); vp9_init_mode_contexts(cm);
if ((cm->frame_type == KEY_FRAME) || if (cm->frame_type == KEY_FRAME ||
cm->error_resilient_mode || (cm->reset_frame_context == 3)) { cm->error_resilient_mode || cm->reset_frame_context == 3) {
// Reset all frame contexts. // Reset all frame contexts.
for (i = 0; i < NUM_FRAME_CONTEXTS; ++i) for (i = 0; i < NUM_FRAME_CONTEXTS; ++i)
vpx_memcpy(&cm->frame_contexts[i], &cm->fc, sizeof(cm->fc)); cm->frame_contexts[i] = cm->fc;
} else if (cm->reset_frame_context == 2) { } else if (cm->reset_frame_context == 2) {
// Reset only the frame context specified in the frame header. // Reset only the frame context specified in the frame header.
vpx_memcpy(&cm->frame_contexts[cm->frame_context_idx], &cm->fc, cm->frame_contexts[cm->frame_context_idx] = cm->fc;
sizeof(cm->fc));
} }
vpx_memset(cm->prev_mip, 0, vpx_memset(cm->prev_mip, 0,
@ -498,7 +497,7 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
vp9_update_mode_info_border(cm, cm->prev_mip); vp9_update_mode_info_border(cm, cm->prev_mip);
vp9_update_mode_info_in_image(cm, cm->prev_mi); vp9_update_mode_info_in_image(cm, cm->prev_mi);
vpx_memset(cm->ref_frame_sign_bias, 0, sizeof(cm->ref_frame_sign_bias)); vp9_zero(cm->ref_frame_sign_bias);
cm->frame_context_idx = 0; cm->frame_context_idx = 0;
} }

View File

@ -428,12 +428,11 @@ void vp9_short_iht8x8_add_c(int16_t *input, uint8_t *dest, int dest_stride,
void vp9_short_idct10_8x8_add_c(int16_t *input, uint8_t *dest, void vp9_short_idct10_8x8_add_c(int16_t *input, uint8_t *dest,
int dest_stride) { int dest_stride) {
int16_t out[8 * 8]; int16_t out[8 * 8] = { 0 };
int16_t *outptr = out; int16_t *outptr = out;
int i, j; int i, j;
int16_t temp_in[8], temp_out[8]; int16_t temp_in[8], temp_out[8];
vpx_memset(out, 0, sizeof(out));
// First transform rows // First transform rows
// only first 4 row has non-zero coefs // only first 4 row has non-zero coefs
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
@ -852,15 +851,13 @@ void vp9_short_iht16x16_add_c(int16_t *input, uint8_t *dest, int dest_stride,
void vp9_short_idct10_16x16_add_c(int16_t *input, uint8_t *dest, void vp9_short_idct10_16x16_add_c(int16_t *input, uint8_t *dest,
int dest_stride) { int dest_stride) {
int16_t out[16 * 16]; int16_t out[16 * 16] = { 0 };
int16_t *outptr = out; int16_t *outptr = out;
int i, j; int i, j;
int16_t temp_in[16], temp_out[16]; int16_t temp_in[16], temp_out[16];
/* First transform rows. Since all non-zero dct coefficients are in // First transform rows. Since all non-zero dct coefficients are in
* upper-left 4x4 area, we only need to calculate first 4 rows here. // upper-left 4x4 area, we only need to calculate first 4 rows here.
*/
vpx_memset(out, 0, sizeof(out));
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
idct16_1d(input, outptr); idct16_1d(input, outptr);
input += 16; input += 16;
@ -1283,15 +1280,13 @@ void vp9_short_idct1_32x32_c(int16_t *input, int16_t *output) {
void vp9_short_idct10_32x32_add_c(int16_t *input, uint8_t *dest, void vp9_short_idct10_32x32_add_c(int16_t *input, uint8_t *dest,
int dest_stride) { int dest_stride) {
int16_t out[32 * 32]; int16_t out[32 * 32] = { 0 };
int16_t *outptr = out; int16_t *outptr = out;
int i, j; int i, j;
int16_t temp_in[32], temp_out[32]; int16_t temp_in[32], temp_out[32];
/* First transform rows. Since all non-zero dct coefficients are in // First transform rows. Since all non-zero dct coefficients are in
* upper-left 4x4 area, we only need to calculate first 4 rows here. // upper-left 4x4 area, we only need to calculate first 4 rows here.
*/
vpx_memset(out, 0, sizeof(out));
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
idct32_1d(input, outptr); idct32_1d(input, outptr);
input += 32; input += 32;

View File

@ -147,7 +147,7 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
int_mv c2_refmv; int_mv c2_refmv;
MV_REFERENCE_FRAME c_ref_frame; MV_REFERENCE_FRAME c_ref_frame;
MV_REFERENCE_FRAME c2_ref_frame; MV_REFERENCE_FRAME c2_ref_frame;
int candidate_scores[MAX_MV_REF_CANDIDATES]; int candidate_scores[MAX_MV_REF_CANDIDATES] = { 0 };
int refmv_count = 0; int refmv_count = 0;
int split_count = 0; int split_count = 0;
int (*mv_ref_search)[2]; int (*mv_ref_search)[2];
@ -160,7 +160,6 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
// Blank the reference vector lists and other local structures. // Blank the reference vector lists and other local structures.
vpx_memset(mv_ref_list, 0, sizeof(int_mv) * MAX_MV_REF_CANDIDATES); vpx_memset(mv_ref_list, 0, sizeof(int_mv) * MAX_MV_REF_CANDIDATES);
vpx_memset(candidate_scores, 0, sizeof(candidate_scores));
mv_ref_search = mv_ref_blocks[mbmi->sb_type]; mv_ref_search = mv_ref_blocks[mbmi->sb_type];
if (mbmi->sb_type < BLOCK_SIZE_SB8X8) { if (mbmi->sb_type < BLOCK_SIZE_SB8X8) {

View File

@ -32,8 +32,8 @@ int vp9_segfeature_active(const struct segmentation *seg, int segment_id,
} }
void vp9_clearall_segfeatures(struct segmentation *seg) { void vp9_clearall_segfeatures(struct segmentation *seg) {
vpx_memset(seg->feature_data, 0, sizeof(seg->feature_data)); vp9_zero(seg->feature_data);
vpx_memset(seg->feature_mask, 0, sizeof(seg->feature_mask)); vp9_zero(seg->feature_mask);
} }
void vp9_enable_segfeature(struct segmentation *seg, int segment_id, void vp9_enable_segfeature(struct segmentation *seg, int segment_id,

View File

@ -585,9 +585,9 @@ static void read_inter_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
mi->bmi[j].as_mv[1].as_int = secondmv.as_int; mi->bmi[j].as_mv[1].as_int = secondmv.as_int;
if (bh == 2) if (bh == 2)
vpx_memcpy(&mi->bmi[j + 2], &mi->bmi[j], sizeof(mi->bmi[j])); mi->bmi[j + 2] = mi->bmi[j];
if (bw == 2) if (bw == 2)
vpx_memcpy(&mi->bmi[j + 1], &mi->bmi[j], sizeof(mi->bmi[j])); mi->bmi[j + 1] = mi->bmi[j];
mi->mbmi.mode = blockmode; mi->mbmi.mode = blockmode;
} }
} }

View File

@ -714,7 +714,7 @@ static void write_modes(VP9_COMP *cpi, vp9_writer* const bc,
for (mi_row = c->cur_tile_mi_row_start; mi_row < c->cur_tile_mi_row_end; for (mi_row = c->cur_tile_mi_row_start; mi_row < c->cur_tile_mi_row_end;
mi_row += 8, m_ptr += 8 * mis) { mi_row += 8, m_ptr += 8 * mis) {
m = m_ptr; m = m_ptr;
vpx_memset(c->left_seg_context, 0, sizeof(c->left_seg_context)); vp9_zero(c->left_seg_context);
for (mi_col = c->cur_tile_mi_col_start; mi_col < c->cur_tile_mi_col_end; for (mi_col = c->cur_tile_mi_col_start; mi_col < c->cur_tile_mi_col_end;
mi_col += MI_BLOCK_SIZE, m += MI_BLOCK_SIZE) mi_col += MI_BLOCK_SIZE, m += MI_BLOCK_SIZE)
write_modes_sb(cpi, m, bc, tok, tok_end, mi_row, mi_col, write_modes_sb(cpi, m, bc, tok, tok_end, mi_row, mi_col,

View File

@ -1827,10 +1827,10 @@ static void encode_frame_internal(VP9_COMP *cpi) {
// re-initencode frame context. // re-initencode frame context.
init_encode_frame_mb_context(cpi); init_encode_frame_mb_context(cpi);
vpx_memset(cpi->rd_comp_pred_diff, 0, sizeof(cpi->rd_comp_pred_diff)); vp9_zero(cpi->rd_comp_pred_diff);
vp9_zero(cpi->rd_filter_diff); vp9_zero(cpi->rd_filter_diff);
vpx_memset(cpi->rd_tx_select_diff, 0, sizeof(cpi->rd_tx_select_diff)); vp9_zero(cpi->rd_tx_select_diff);
vpx_memset(cpi->rd_tx_select_threshes, 0, sizeof(cpi->rd_tx_select_threshes)); vp9_zero(cpi->rd_tx_select_threshes);
set_prev_mi(cm); set_prev_mi(cm);