summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_encodeframe.c80
-rw-r--r--vp9/encoder/vp9_firstpass.c4
-rw-r--r--vp9/encoder/vp9_mbgraph.c7
-rw-r--r--vp9/encoder/vp9_onyx_if.c7
-rw-r--r--vp9/encoder/vp9_onyx_int.h2
-rw-r--r--vp9/encoder/vp9_quantize.c88
-rw-r--r--vp9/encoder/vp9_rdopt.c6
-rw-r--r--vp9/encoder/vp9_segmentation.c10
-rw-r--r--vp9/vp9_dx_iface.c2
9 files changed, 116 insertions, 90 deletions
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 374d22c2a..58f5a96c9 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -74,13 +74,32 @@ static const uint8_t VP9_VAR_OFFS[64] = {
128, 128, 128, 128, 128, 128, 128, 128
};
-static unsigned int get_sb_variance(VP9_COMP *cpi, MACROBLOCK *x,
- BLOCK_SIZE_TYPE bs) {
+static unsigned int get_sby_perpixel_variance(VP9_COMP *cpi, MACROBLOCK *x,
+ BLOCK_SIZE_TYPE bs) {
unsigned int var, sse;
var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf,
x->plane[0].src.stride,
VP9_VAR_OFFS, 0, &sse);
- return var >> num_pels_log2_lookup[bs];
+ return (var + (1 << (num_pels_log2_lookup[bs] - 1))) >>
+ num_pels_log2_lookup[bs];
+}
+
+static unsigned int get_sbuv_perpixel_variance(VP9_COMP *cpi, MACROBLOCK *x,
+ BLOCK_SIZE_TYPE bs) {
+ unsigned int varu, varv, sse;
+ BLOCK_SIZE_TYPE uvbs = ss_size_lookup[bs]
+ [x->e_mbd.plane[1].subsampling_x]
+ [x->e_mbd.plane[1].subsampling_y];
+ if (uvbs == BLOCK_INVALID)
+ return 0;
+ varu = cpi->fn_ptr[uvbs].vf(x->plane[1].src.buf,
+ x->plane[1].src.stride,
+ VP9_VAR_OFFS, 0, &sse);
+ varv = cpi->fn_ptr[uvbs].vf(x->plane[2].src.buf,
+ x->plane[2].src.stride,
+ VP9_VAR_OFFS, 0, &sse);
+ return (varu + varv + (1 << num_pels_log2_lookup[uvbs])) >>
+ (1 + num_pels_log2_lookup[uvbs]);
}
// Original activity measure from Tim T's code.
@@ -574,7 +593,7 @@ static void pick_sb_modes(VP9_COMP *cpi, int mi_row, int mi_col,
set_offsets(cpi, mi_row, mi_col, bsize);
xd->mode_info_context->mbmi.sb_type = bsize;
- x->source_variance = get_sb_variance(cpi, x, bsize);
+ x->source_variance = get_sby_perpixel_variance(cpi, x, bsize);
if (cpi->oxcf.tuning == VP8_TUNE_SSIM)
vp9_activity_masking(cpi, x);
@@ -1614,10 +1633,26 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
int this_rate, sum_rate = 0, best_rate = INT_MAX;
int64_t this_dist, sum_dist = 0, best_dist = INT_MAX;
int64_t sum_rd = 0;
-
+ int do_split = 1, do_rect = 1;
// Override min_partition_size for edge blocks
int force_horz_split = mi_row + (ms >> 1) >= cm->mi_rows;
int force_vert_split = mi_col + (ms >> 1) >= cm->mi_cols;
+ const int partition_none_allowed = (bsize <= cpi->sf.max_partition_size ||
+ !cpi->sf.auto_min_max_partition_size) &&
+ !force_horz_split &&
+ !force_vert_split;
+ const int partition_horz_allowed = (bsize <= cpi->sf.max_partition_size ||
+ !cpi->sf.auto_min_max_partition_size) &&
+ !cpi->sf.use_square_partition_only &&
+ bsize >= BLOCK_8X8 &&
+ !force_vert_split;
+ const int partition_vert_allowed = (bsize <= cpi->sf.max_partition_size ||
+ !cpi->sf.auto_min_max_partition_size) &&
+ !cpi->sf.use_square_partition_only &&
+ bsize >= BLOCK_8X8 &&
+ !force_horz_split;
+ int partition_split_done = 0;
+
(void) *tp_orig;
@@ -1634,18 +1669,28 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
save_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
+ if (cpi->sf.disable_split_var_thresh && partition_none_allowed) {
+ unsigned int source_variancey;
+ vp9_setup_src_planes(x, cpi->Source, mi_row, mi_col);
+ source_variancey = get_sby_perpixel_variance(cpi, x, bsize);
+ if (source_variancey < cpi->sf.disable_split_var_thresh)
+ do_split = 0;
+ else if (source_variancey < cpi->sf.disable_split_var_thresh / 2)
+ do_rect = 0;
+ }
// PARTITION_SPLIT
- if (!cpi->sf.auto_min_max_partition_size ||
- bsize > cpi->sf.min_partition_size) {
+ if (do_split &&
+ (!cpi->sf.auto_min_max_partition_size ||
+ bsize >= cpi->sf.min_partition_size)) {
if (bsize > BLOCK_8X8) {
subsize = get_subsize(bsize, PARTITION_SPLIT);
-
for (i = 0; i < 4 && sum_rd < best_rd; ++i) {
int x_idx = (i & 1) * (ms >> 1);
int y_idx = (i >> 1) * (ms >> 1);
- if ((mi_row + y_idx >= cm->mi_rows) || (mi_col + x_idx >= cm->mi_cols))
- continue;
+ if ((mi_row + y_idx >= cm->mi_rows) ||
+ (mi_col + x_idx >= cm->mi_cols))
+ continue;
*(get_sb_index(xd, subsize)) = i;
@@ -1672,6 +1717,7 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
*(get_sb_partitioning(x, bsize)) = subsize;
}
}
+ partition_split_done = 1;
restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
}
}
@@ -1684,7 +1730,8 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
// Use 4 subblocks' motion estimation results to speed up current
// partition's checking.
- if (cpi->sf.using_small_partition_info) {
+ if (partition_split_done &&
+ cpi->sf.using_small_partition_info) {
compute_fast_motion_search_level(cpi, bsize);
}
@@ -1693,7 +1740,7 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
int larger_is_better = 0;
// PARTITION_NONE
- if (!force_horz_split && !force_vert_split) {
+ if (partition_none_allowed) {
pick_sb_modes(cpi, mi_row, mi_col, &this_rate, &this_dist, bsize,
get_block_context(x, bsize), best_rd);
if (this_rate != INT_MAX) {
@@ -1714,7 +1761,7 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
}
}
- if (bsize == BLOCK_8X8) {
+ if (bsize == BLOCK_8X8 && do_split) {
sum_rate = 0; sum_dist = 0; sum_rd = 0;
subsize = get_subsize(bsize, PARTITION_SPLIT);
@@ -1754,10 +1801,11 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
}
- if (!cpi->sf.use_square_partition_only &&
+ if (do_rect &&
+ !cpi->sf.use_square_partition_only &&
(!cpi->sf.less_rectangular_check || !larger_is_better)) {
// PARTITION_HORZ
- if (bsize >= BLOCK_8X8 && mi_col + (ms >> 1) < cm->mi_cols) {
+ if (partition_horz_allowed) {
subsize = get_subsize(bsize, PARTITION_HORZ);
if (!cpi->sf.auto_min_max_partition_size || force_horz_split ||
subsize >= cpi->sf.min_partition_size) {
@@ -1799,7 +1847,7 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
}
// PARTITION_VERT
- if (bsize >= BLOCK_8X8 && mi_row + (ms >> 1) < cm->mi_rows) {
+ if (partition_vert_allowed) {
subsize = get_subsize(bsize, PARTITION_VERT);
if (!cpi->sf.auto_min_max_partition_size || force_vert_split ||
subsize >= cpi->sf.min_partition_size) {
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 6ba2a4fc9..8eab71c26 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1580,7 +1580,7 @@ void define_fixed_arf_period(VP9_COMP *cpi) {
// Analyse and define a gf/arf group.
static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
- FIRSTPASS_STATS next_frame;
+ FIRSTPASS_STATS next_frame = { 0 };
FIRSTPASS_STATS *start_pos;
int i;
double boost_score = 0.0;
@@ -1616,8 +1616,6 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
start_pos = cpi->twopass.stats_in;
- vpx_memset(&next_frame, 0, sizeof(next_frame)); // assure clean
-
// Load stats for the current frame.
mod_frame_err = calculate_modified_err(cpi, this_frame);
diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c
index 57fa0106e..1baea643d 100644
--- a/vp9/encoder/vp9_mbgraph.c
+++ b/vp9/encoder/vp9_mbgraph.c
@@ -241,9 +241,7 @@ static void update_mbgraph_frame_stats(VP9_COMP *cpi,
int mb_col, mb_row, offset = 0;
int mb_y_offset = 0, arf_y_offset = 0, gld_y_offset = 0;
int_mv arf_top_mv, gld_top_mv;
- MODE_INFO mi_local;
-
- vp9_zero(mi_local);
+ MODE_INFO mi_local = { { 0 } };
// Set up limit values for motion vectors to prevent them extending outside the UMV borders
arf_top_mv.as_int = 0;
@@ -309,7 +307,7 @@ static void update_mbgraph_frame_stats(VP9_COMP *cpi,
static void separate_arf_mbs(VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common;
int mb_col, mb_row, offset, i;
- int ncnt[4];
+ int ncnt[4] = { 0 };
int n_frames = cpi->mbgraph_n_frames;
int *arf_not_zz;
@@ -345,7 +343,6 @@ static void separate_arf_mbs(VP9_COMP *cpi) {
}
}
- vpx_memset(ncnt, 0, sizeof(ncnt));
for (offset = 0, mb_row = 0; mb_row < cm->mb_rows;
offset += cm->mb_cols, mb_row++) {
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index fd624af47..2f91f9593 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@@ -736,6 +736,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->last_partitioning_redo_frequency = 4;
sf->disable_splitmv = 0;
sf->mode_search_skip_flags = 0;
+ sf->disable_split_var_thresh = 0;
sf->last_chroma_intra_mode = TM_PRED;
sf->use_rd_breakout = 0;
sf->skip_encode_sb = 0;
@@ -793,6 +794,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->auto_min_max_partition_size = 1;
sf->auto_min_max_partition_interval = 1;
+ sf->disable_split_var_thresh = 32;
}
if (speed == 2) {
sf->adjust_thresholds_by_speed = 1;
@@ -826,6 +828,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->search_method = SQUARE;
sf->subpel_iters_per_step = 1;
sf->use_fast_lpf_pick = 1;
+ sf->disable_split_var_thresh = 64;
}
if (speed == 3) {
sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
@@ -848,6 +851,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->auto_mv_step_size = 1;
sf->search_method = BIGDIA;
sf->subpel_iters_per_step = 1;
+ sf->disable_split_var_thresh = 64;
}
if (speed == 4) {
sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
@@ -874,6 +878,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->disable_splitmv = 1;
sf->search_method = HEX;
sf->subpel_iters_per_step = 1;
+ sf->disable_split_var_thresh = 64;
}
/*
if (speed == 2) {
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index 5a78bd9be..de6f34c58 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -284,6 +284,8 @@ typedef struct {
// The heuristics selected are based on flags
// defined in the MODE_SEARCH_SKIP_HEURISTICS enum
unsigned int mode_search_skip_flags;
+ // A source variance threshold below which the split mode is disabled
+ unsigned int disable_split_var_thresh;
MB_PREDICTION_MODE last_chroma_intra_mode;
int use_rd_breakout;
int use_uv_intra_rd_estimate;
diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c
index 5a04a4b50..fecfe0c93 100644
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -185,63 +185,43 @@ static void invert_quant(int16_t *quant, int16_t *shift, int d) {
}
void vp9_init_quantizer(VP9_COMP *cpi) {
- int i;
- int quant_val;
- int quant_uv_val;
-#if CONFIG_ALPHA
- int quant_alpha_val;
-#endif
- int q;
+ int i, q;
+ VP9_COMMON *const cm = &cpi->common;
for (q = 0; q < QINDEX_RANGE; q++) {
- int qzbin_factor = (vp9_dc_quant(q, 0) < 148) ? 84 : 80;
- int qrounding_factor = 48;
- if (q == 0) {
- qzbin_factor = 64;
- qrounding_factor = 64;
+ const int qzbin_factor = q == 0 ? 64 : (vp9_dc_quant(q, 0) < 148 ? 84 : 80);
+ const int qrounding_factor = q == 0 ? 64 : 48;
+
+ // y
+ for (i = 0; i < 2; ++i) {
+ const int quant = i == 0 ? vp9_dc_quant(q, cm->y_dc_delta_q)
+ : vp9_ac_quant(q, 0);
+ invert_quant(&cpi->y_quant[q][i], &cpi->y_quant_shift[q][i], quant);
+ cpi->y_zbin[q][i] = ROUND_POWER_OF_TWO(qzbin_factor * quant, 7);
+ cpi->y_round[q][i] = (qrounding_factor * quant) >> 7;
+ cm->y_dequant[q][i] = quant;
}
- // dc values
- quant_val = vp9_dc_quant(q, cpi->common.y_dc_delta_q);
- invert_quant(cpi->y_quant[q] + 0, cpi->y_quant_shift[q] + 0, quant_val);
- cpi->y_zbin[q][0] = ROUND_POWER_OF_TWO(qzbin_factor * quant_val, 7);
- cpi->y_round[q][0] = (qrounding_factor * quant_val) >> 7;
- cpi->common.y_dequant[q][0] = quant_val;
-
- quant_val = vp9_dc_quant(q, cpi->common.uv_dc_delta_q);
- invert_quant(cpi->uv_quant[q] + 0, cpi->uv_quant_shift[q] + 0, quant_val);
- cpi->uv_zbin[q][0] = ROUND_POWER_OF_TWO(qzbin_factor * quant_val, 7);
- cpi->uv_round[q][0] = (qrounding_factor * quant_val) >> 7;
- cpi->common.uv_dequant[q][0] = quant_val;
-
-#if CONFIG_ALPHA
- quant_val = vp9_dc_quant(q, cpi->common.a_dc_delta_q);
- invert_quant(cpi->a_quant[q] + 0, cpi->a_quant_shift[q] + 0, quant_val);
- cpi->a_zbin[q][0] = ROUND_POWER_OF_TWO(qzbin_factor * quant_val, 7);
- cpi->a_round[q][0] = (qrounding_factor * quant_val) >> 7;
- cpi->common.a_dequant[q][0] = quant_val;
-#endif
-
- quant_val = vp9_ac_quant(q, 0);
- invert_quant(cpi->y_quant[q] + 1, cpi->y_quant_shift[q] + 1, quant_val);
- cpi->y_zbin[q][1] = ROUND_POWER_OF_TWO(qzbin_factor * quant_val, 7);
- cpi->y_round[q][1] = (qrounding_factor * quant_val) >> 7;
- cpi->common.y_dequant[q][1] = quant_val;
-
- quant_uv_val = vp9_ac_quant(q, cpi->common.uv_ac_delta_q);
- invert_quant(cpi->uv_quant[q] + 1, cpi->uv_quant_shift[q] + 1,
- quant_uv_val);
- cpi->uv_zbin[q][1] = ROUND_POWER_OF_TWO(qzbin_factor * quant_uv_val, 7);
- cpi->uv_round[q][1] = (qrounding_factor * quant_uv_val) >> 7;
- cpi->common.uv_dequant[q][1] = quant_uv_val;
+ // uv
+ for (i = 0; i < 2; ++i) {
+ const int quant = i == 0 ? vp9_dc_quant(q, cm->uv_dc_delta_q)
+ : vp9_ac_quant(q, cm->uv_ac_delta_q);
+ invert_quant(&cpi->uv_quant[q][i], &cpi->uv_quant_shift[q][i], quant);
+ cpi->uv_zbin[q][i] = ROUND_POWER_OF_TWO(qzbin_factor * quant, 7);
+ cpi->uv_round[q][i] = (qrounding_factor * quant) >> 7;
+ cm->uv_dequant[q][i] = quant;
+ }
#if CONFIG_ALPHA
- quant_alpha_val = vp9_ac_quant(q, cpi->common.a_ac_delta_q);
- invert_quant(cpi->a_quant[q] + 1, cpi->a_quant_shift[q] + 1,
- quant_alpha_val);
- cpi->a_zbin[q][1] = ROUND_POWER_OF_TWO(qzbin_factor * quant_alpha_val, 7);
- cpi->a_round[q][1] = (qrounding_factor * quant_alpha_val) >> 7;
- cpi->common.a_dequant[q][1] = quant_alpha_val;
+ // alpha
+ for (i = 0; i < 2; ++i) {
+ const int quant = i == 0 ? vp9_dc_quant(q, cm->a_dc_delta_q)
+ : vp9_ac_quant(q, cm->a_ac_delta_q);
+ invert_quant(&cpi->a_quant[q][i], &cpi->a_quant_shift[q][i], quant);
+ cpi->a_zbin[q][i] = ROUND_POWER_OF_TWO(qzbin_factor * quant, 7);
+ cpi->a_round[q][i] = (qrounding_factor * quant) >> 7;
+ cm->a_dequant[q][i] = quant;
+ }
#endif
for (i = 2; i < 8; i++) {
@@ -249,20 +229,20 @@ void vp9_init_quantizer(VP9_COMP *cpi) {
cpi->y_quant_shift[q][i] = cpi->y_quant_shift[q][1];
cpi->y_zbin[q][i] = cpi->y_zbin[q][1];
cpi->y_round[q][i] = cpi->y_round[q][1];
- cpi->common.y_dequant[q][i] = cpi->common.y_dequant[q][1];
+ cm->y_dequant[q][i] = cm->y_dequant[q][1];
cpi->uv_quant[q][i] = cpi->uv_quant[q][1];
cpi->uv_quant_shift[q][i] = cpi->uv_quant_shift[q][1];
cpi->uv_zbin[q][i] = cpi->uv_zbin[q][1];
cpi->uv_round[q][i] = cpi->uv_round[q][1];
- cpi->common.uv_dequant[q][i] = cpi->common.uv_dequant[q][1];
+ cm->uv_dequant[q][i] = cm->uv_dequant[q][1];
#if CONFIG_ALPHA
cpi->a_quant[q][i] = cpi->a_quant[q][1];
cpi->a_quant_shift[q][i] = cpi->a_quant_shift[q][1];
cpi->a_zbin[q][i] = cpi->a_zbin[q][1];
cpi->a_round[q][i] = cpi->a_round[q][1];
- cpi->common.a_dequant[q][i] = cpi->common.a_dequant[q][1];
+ cm->a_dequant[q][i] = cm->a_dequant[q][1];
#endif
}
}
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 21f112138..d7ad05c84 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -3156,7 +3156,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
int comp_pred, i;
int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES];
struct buf_2d yv12_mb[4][MAX_MB_PLANE];
- int_mv single_newmv[MAX_REF_FRAMES];
+ int_mv single_newmv[MAX_REF_FRAMES] = { { 0 } };
static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
VP9_ALT_FLAG };
int idx_list[4] = {0,
@@ -3171,7 +3171,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
int64_t best_pred_rd[NB_PREDICTION_TYPES];
int64_t best_filter_rd[VP9_SWITCHABLE_FILTERS + 1];
int64_t best_filter_diff[VP9_SWITCHABLE_FILTERS + 1];
- MB_MODE_INFO best_mbmode;
+ MB_MODE_INFO best_mbmode = { 0 };
int j;
int mode_index, best_mode_index = 0;
unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES];
@@ -3216,8 +3216,6 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
estimate_ref_frame_costs(cpi, segment_id, ref_costs_single, ref_costs_comp,
&comp_mode_p);
- vpx_memset(&best_mbmode, 0, sizeof(best_mbmode));
- vpx_memset(&single_newmv, 0, sizeof(single_newmv));
for (i = 0; i < NB_PREDICTION_TYPES; ++i)
best_pred_rd[i] = INT64_MAX;
diff --git a/vp9/encoder/vp9_segmentation.c b/vp9/encoder/vp9_segmentation.c
index 9564edc84..3db91caca 100644
--- a/vp9/encoder/vp9_segmentation.c
+++ b/vp9/encoder/vp9_segmentation.c
@@ -217,9 +217,9 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi) {
int i, tile_col, mi_row, mi_col;
- int temporal_predictor_count[PREDICTION_PROBS][2];
- int no_pred_segcounts[MAX_SEGMENTS];
- int t_unpred_seg_counts[MAX_SEGMENTS];
+ int temporal_predictor_count[PREDICTION_PROBS][2] = { { 0 } };
+ int no_pred_segcounts[MAX_SEGMENTS] = { 0 };
+ int t_unpred_seg_counts[MAX_SEGMENTS] = { 0 };
vp9_prob no_pred_tree[SEG_TREE_PROBS];
vp9_prob t_pred_tree[SEG_TREE_PROBS];
@@ -233,10 +233,6 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi) {
vpx_memset(seg->tree_probs, 255, sizeof(seg->tree_probs));
vpx_memset(seg->pred_probs, 255, sizeof(seg->pred_probs));
- vpx_memset(no_pred_segcounts, 0, sizeof(no_pred_segcounts));
- vpx_memset(t_unpred_seg_counts, 0, sizeof(t_unpred_seg_counts));
- vpx_memset(temporal_predictor_count, 0, sizeof(temporal_predictor_count));
-
// First of all generate stats regarding how well the last segment map
// predicts this one
for (tile_col = 0; tile_col < 1 << cm->log2_tile_cols; tile_col++) {
diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c
index 05029b92e..66a3c2b93 100644
--- a/vp9/vp9_dx_iface.c
+++ b/vp9/vp9_dx_iface.c
@@ -368,6 +368,8 @@ static vpx_codec_err_t vp9_decode(vpx_codec_alg_priv_t *ctx,
uint32_t sizes[8];
int frames_this_pts, frame_count = 0;
+ if (data == NULL || data_sz == 0) return VPX_CODEC_INVALID_PARAM;
+
parse_superframe_index(data, data_sz, sizes, &frames_this_pts);
do {