From: Yaowu Xu Date: Tue, 10 May 2016 21:42:27 +0000 (-0700) Subject: Move count buffers from stack to heap X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=102cdf94ed6f4984c62db5579eb69e3a22ead398;p=libvpx Move count buffers from stack to heap This fixes the stack overflow issue on MSVC build. Change-Id: Icb0a78e5992a097d2192979ec2432546eaa452dd --- diff --git a/vp10/encoder/bitstream.c b/vp10/encoder/bitstream.c index a7f81625f..4f8e89c56 100644 --- a/vp10/encoder/bitstream.c +++ b/vp10/encoder/bitstream.c @@ -2291,10 +2291,6 @@ static void update_coef_probs(VP10_COMP *cpi, vp10_writer* w) { unsigned int eob_counts_copy[TX_SIZES][PLANE_TYPES][REF_TYPES] [COEF_BANDS][COEFF_CONTEXTS]; int i; - vp10_coeff_count coef_counts[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES]; - unsigned int eob_counts[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES] - [REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]; - vp10_coeff_stats branch_ct[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES]; vp10_coeff_probs_model dummy_frame_coef_probs[PLANE_TYPES]; if (cm->do_subframe_update && @@ -2302,7 +2298,9 @@ static void update_coef_probs(VP10_COMP *cpi, vp10_writer* w) { vp10_copy(cpi->common.fc->coef_probs, subframe_stats->enc_starting_coef_probs); for (i = 0; i <= cpi->common.coef_probs_update_idx; ++i) { - get_coef_counts_diff(cpi, i, coef_counts[i], eob_counts[i]); + get_coef_counts_diff(cpi, i, + cpi->wholeframe_stats.coef_counts_buf[i], + cpi->wholeframe_stats.eob_counts_buf[i]); } } #endif // CONFIG_ENTROPY @@ -2326,16 +2324,17 @@ static void update_coef_probs(VP10_COMP *cpi, vp10_writer* w) { frame_coef_probs); for (i = 0; i <= cpi->common.coef_probs_update_idx; ++i) { vp10_copy(cpi->common.counts.eob_branch[tx_size], - eob_counts[i][tx_size]); + cpi->wholeframe_stats.eob_counts_buf[i][tx_size]); vp10_copy(cpi->td.rd_counts.coef_counts[tx_size], - coef_counts[i][tx_size]); - build_tree_distribution(cpi, tx_size, branch_ct[i][tx_size], + cpi->wholeframe_stats.coef_counts_buf[i][tx_size]); + build_tree_distribution(cpi, tx_size, + cpi->branch_ct_buf[i][tx_size], dummy_frame_coef_probs); } vp10_copy(cpi->common.counts.eob_branch[tx_size], eob_counts_copy); vp10_copy(cpi->td.rd_counts.coef_counts[tx_size], coef_counts_copy); - update_coef_probs_subframe(w, cpi, tx_size, branch_ct, + update_coef_probs_subframe(w, cpi, tx_size, cpi->branch_ct_buf, frame_coef_probs); #if CONFIG_ANS update = 1; diff --git a/vp10/encoder/encoder.h b/vp10/encoder/encoder.h index 93f274db4..67ebe6d3f 100644 --- a/vp10/encoder/encoder.h +++ b/vp10/encoder/encoder.h @@ -580,6 +580,9 @@ typedef struct VP10_COMP { VP9LfSync lf_row_sync; #if CONFIG_ENTROPY SUBFRAME_STATS subframe_stats; + // TODO(yaowu): minimize the size of count buffers + SUBFRAME_STATS wholeframe_stats; + vp10_coeff_stats branch_ct_buf[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES]; #endif // CONFIG_ENTROPY #if CONFIG_ANS struct BufAnsCoder buf_ans;