From d9f9a34bb145dad322650caa53e07810c406080b Mon Sep 17 00:00:00 2001 From: clang-format Date: Thu, 11 Aug 2016 20:13:14 -0700 Subject: [PATCH] vp10/encoder: apply clang-format Change-Id: I58a42ced5b8a4338524434ff3356850b89aa705a --- vp10/encoder/aq_complexity.c | 56 +- vp10/encoder/aq_complexity.h | 5 +- vp10/encoder/aq_cyclicrefresh.c | 136 +- vp10/encoder/aq_cyclicrefresh.h | 17 +- vp10/encoder/aq_variance.c | 68 +- vp10/encoder/aq_variance.h | 1 - vp10/encoder/arm/neon/dct_neon.c | 19 +- vp10/encoder/arm/neon/error_neon.c | 2 +- vp10/encoder/arm/neon/quantize_neon.c | 41 +- vp10/encoder/bitstream.c | 1051 ++-- vp10/encoder/bitstream.h | 1 - vp10/encoder/block.h | 6 +- vp10/encoder/blockiness.c | 20 +- vp10/encoder/buf_ans.h | 12 +- vp10/encoder/context_tree.c | 90 +- vp10/encoder/cost.c | 216 +- vp10/encoder/cost.h | 7 +- vp10/encoder/dct.c | 328 +- vp10/encoder/encodeframe.c | 2495 ++++----- vp10/encoder/encodeframe.h | 7 +- vp10/encoder/encodemb.c | 348 +- vp10/encoder/encodemb.h | 17 +- vp10/encoder/encodemv.c | 114 +- vp10/encoder/encodemv.h | 7 +- vp10/encoder/encoder.c | 2154 ++++---- vp10/encoder/encoder.h | 126 +- vp10/encoder/ethread.c | 21 +- vp10/encoder/extend.c | 78 +- vp10/encoder/extend.h | 8 +- vp10/encoder/firstpass.c | 784 ++- vp10/encoder/firstpass.h | 11 +- vp10/encoder/global_motion.c | 12 +- vp10/encoder/global_motion.h | 2 - vp10/encoder/hybrid_fwd_txfm.c | 93 +- vp10/encoder/lookahead.c | 79 +- vp10/encoder/lookahead.h | 33 +- vp10/encoder/mbgraph.c | 140 +- vp10/encoder/mbgraph.h | 4 +- vp10/encoder/mcomp.c | 1997 ++++---- vp10/encoder/mcomp.h | 166 +- vp10/encoder/mips/msa/error_msa.c | 165 +- vp10/encoder/mips/msa/fdct16x16_msa.c | 133 +- vp10/encoder/mips/msa/fdct4x4_msa.c | 8 +- vp10/encoder/mips/msa/fdct8x8_msa.c | 58 +- vp10/encoder/mips/msa/fdct_msa.h | 197 +- vp10/encoder/mips/msa/temporal_filter_msa.c | 88 +- vp10/encoder/palette.c | 11 +- vp10/encoder/picklpf.c | 31 +- vp10/encoder/picklpf.h | 1 - vp10/encoder/pickrst.c | 155 +- vp10/encoder/pickrst.h | 5 +- vp10/encoder/quantize.c | 702 +-- vp10/encoder/quantize.h | 130 +- vp10/encoder/ratectrl.c | 526 +- vp10/encoder/ratectrl.h | 63 +- vp10/encoder/rd.c | 264 +- vp10/encoder/rd.h | 38 +- vp10/encoder/rdopt.c | 4513 ++++++++--------- vp10/encoder/rdopt.h | 48 +- vp10/encoder/resize.c | 538 +- vp10/encoder/resize.h | 147 +- vp10/encoder/segmentation.c | 134 +- vp10/encoder/segmentation.h | 13 +- vp10/encoder/speed_features.c | 113 +- vp10/encoder/speed_features.h | 64 +- vp10/encoder/subexp.c | 127 +- vp10/encoder/subexp.h | 35 +- vp10/encoder/temporal_filter.c | 338 +- vp10/encoder/tokenize.c | 658 ++- vp10/encoder/tokenize.h | 42 +- vp10/encoder/treewriter.c | 6 +- vp10/encoder/treewriter.h | 14 +- vp10/encoder/variance_tree.c | 11 +- vp10/encoder/variance_tree.h | 21 +- vp10/encoder/wedge_utils.c | 29 +- vp10/encoder/x86/dct_intrin_sse2.c | 191 +- vp10/encoder/x86/dct_ssse3.c | 80 +- vp10/encoder/x86/error_intrin_avx2.c | 12 +- .../x86/highbd_block_error_intrin_sse2.c | 34 +- vp10/encoder/x86/highbd_fwd_txfm_sse4.c | 97 +- vp10/encoder/x86/quantize_sse2.c | 71 +- vp10/encoder/x86/vp10_highbd_quantize_sse4.c | 32 +- vp10/encoder/x86/wedge_utils_sse2.c | 29 +- 83 files changed, 9018 insertions(+), 11726 deletions(-) diff --git a/vp10/encoder/aq_complexity.c b/vp10/encoder/aq_complexity.c index a4c38d1c2..317b2b3af 100644 --- a/vp10/encoder/aq_complexity.c +++ b/vp10/encoder/aq_complexity.c @@ -19,25 +19,27 @@ #include "vpx_dsp/vpx_dsp_common.h" #include "vpx_ports/system_state.h" -#define AQ_C_SEGMENTS 5 -#define DEFAULT_AQ2_SEG 3 // Neutral Q segment +#define AQ_C_SEGMENTS 5 +#define DEFAULT_AQ2_SEG 3 // Neutral Q segment #define AQ_C_STRENGTHS 3 -static const double aq_c_q_adj_factor[AQ_C_STRENGTHS][AQ_C_SEGMENTS] = - { {1.75, 1.25, 1.05, 1.00, 0.90}, - {2.00, 1.50, 1.15, 1.00, 0.85}, - {2.50, 1.75, 1.25, 1.00, 0.80} }; -static const double aq_c_transitions[AQ_C_STRENGTHS][AQ_C_SEGMENTS] = - { {0.15, 0.30, 0.55, 2.00, 100.0}, - {0.20, 0.40, 0.65, 2.00, 100.0}, - {0.25, 0.50, 0.75, 2.00, 100.0} }; -static const double aq_c_var_thresholds[AQ_C_STRENGTHS][AQ_C_SEGMENTS] = - { {-4.0, -3.0, -2.0, 100.00, 100.0}, - {-3.5, -2.5, -1.5, 100.00, 100.0}, - {-3.0, -2.0, -1.0, 100.00, 100.0} }; +static const double aq_c_q_adj_factor[AQ_C_STRENGTHS][AQ_C_SEGMENTS] = { + { 1.75, 1.25, 1.05, 1.00, 0.90 }, + { 2.00, 1.50, 1.15, 1.00, 0.85 }, + { 2.50, 1.75, 1.25, 1.00, 0.80 } +}; +static const double aq_c_transitions[AQ_C_STRENGTHS][AQ_C_SEGMENTS] = { + { 0.15, 0.30, 0.55, 2.00, 100.0 }, + { 0.20, 0.40, 0.65, 2.00, 100.0 }, + { 0.25, 0.50, 0.75, 2.00, 100.0 } +}; +static const double aq_c_var_thresholds[AQ_C_STRENGTHS][AQ_C_SEGMENTS] = { + { -4.0, -3.0, -2.0, 100.00, 100.0 }, + { -3.5, -2.5, -1.5, 100.00, 100.0 }, + { -3.0, -2.0, -1.0, 100.00, 100.0 } +}; #define DEFAULT_COMPLEXITY 64 - static int get_aq_c_strength(int q_index, vpx_bit_depth_t bit_depth) { // Approximate base quatizer (truncated to int) const int base_quant = vp10_ac_quant(q_index, 0, bit_depth) / 4; @@ -81,14 +83,11 @@ void vp10_setup_in_frame_q_adj(VP10_COMP *cpi) { for (segment = 0; segment < AQ_C_SEGMENTS; ++segment) { int qindex_delta; - if (segment == DEFAULT_AQ2_SEG) - continue; - - qindex_delta = - vp10_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex, - aq_c_q_adj_factor[aq_strength][segment], - cm->bit_depth); + if (segment == DEFAULT_AQ2_SEG) continue; + qindex_delta = vp10_compute_qdelta_by_rate( + &cpi->rc, cm->frame_type, cm->base_qindex, + aq_c_q_adj_factor[aq_strength][segment], cm->bit_depth); // For AQ complexity mode, we dont allow Q0 in a segment if the base // Q is not 0. Q0 (lossless) implies 4x4 only and in AQ mode 2 a segment @@ -112,7 +111,7 @@ void vp10_setup_in_frame_q_adj(VP10_COMP *cpi) { // The choice of segment for a block depends on the ratio of the projected // bits for the block vs a target average and its spatial complexity. void vp10_caq_select_segment(VP10_COMP *cpi, MACROBLOCK *mb, BLOCK_SIZE bs, - int mi_row, int mi_col, int projected_rate) { + int mi_row, int mi_col, int projected_rate) { VP10_COMMON *const cm = &cpi->common; const int mi_offset = mi_row * cm->mi_cols + mi_col; @@ -134,19 +133,18 @@ void vp10_caq_select_segment(VP10_COMP *cpi, MACROBLOCK *mb, BLOCK_SIZE bs, const int aq_strength = get_aq_c_strength(cm->base_qindex, cm->bit_depth); vpx_clear_system_state(); - low_var_thresh = (cpi->oxcf.pass == 2) - ? VPXMAX(cpi->twopass.mb_av_energy, MIN_DEFAULT_LV_THRESH) - : DEFAULT_LV_THRESH; + low_var_thresh = (cpi->oxcf.pass == 2) ? VPXMAX(cpi->twopass.mb_av_energy, + MIN_DEFAULT_LV_THRESH) + : DEFAULT_LV_THRESH; vp10_setup_src_planes(mb, cpi->Source, mi_row, mi_col); logvar = vp10_log_block_var(cpi, mb, bs); - segment = AQ_C_SEGMENTS - 1; // Just in case no break out below. + segment = AQ_C_SEGMENTS - 1; // Just in case no break out below. for (i = 0; i < AQ_C_SEGMENTS; ++i) { // Test rate against a threshold value and variance against a threshold. // Increasing segment number (higher variance and complexity) = higher Q. - if ((projected_rate < - target_rate * aq_c_transitions[aq_strength][i]) && + if ((projected_rate < target_rate * aq_c_transitions[aq_strength][i]) && (logvar < (low_var_thresh + aq_c_var_thresholds[aq_strength][i]))) { segment = i; break; diff --git a/vp10/encoder/aq_complexity.h b/vp10/encoder/aq_complexity.h index f9de2ada3..5ed461bc6 100644 --- a/vp10/encoder/aq_complexity.h +++ b/vp10/encoder/aq_complexity.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_AQ_COMPLEXITY_H_ #define VP10_ENCODER_AQ_COMPLEXITY_H_ @@ -23,8 +22,8 @@ struct macroblock; // Select a segment for the current Block. void vp10_caq_select_segment(struct VP10_COMP *cpi, struct macroblock *, - BLOCK_SIZE bs, - int mi_row, int mi_col, int projected_rate); + BLOCK_SIZE bs, int mi_row, int mi_col, + int projected_rate); // This function sets up a set of segments with delta Q values around // the baseline frame quantizer. diff --git a/vp10/encoder/aq_cyclicrefresh.c b/vp10/encoder/aq_cyclicrefresh.c index a0df7864f..362a71f25 100644 --- a/vp10/encoder/aq_cyclicrefresh.c +++ b/vp10/encoder/aq_cyclicrefresh.c @@ -59,8 +59,7 @@ struct CYCLIC_REFRESH { CYCLIC_REFRESH *vp10_cyclic_refresh_alloc(int mi_rows, int mi_cols) { size_t last_coded_q_map_size; CYCLIC_REFRESH *const cr = vpx_calloc(1, sizeof(*cr)); - if (cr == NULL) - return NULL; + if (cr == NULL) return NULL; cr->map = vpx_calloc(mi_rows * mi_cols, sizeof(*cr->map)); if (cr->map == NULL) { @@ -94,7 +93,7 @@ static int apply_cyclic_refresh_bitrate(const VP10_COMMON *cm, // Average bits available per frame = avg_frame_bandwidth // Number of (8x8) blocks in frame = mi_rows * mi_cols; const float factor = 0.25; - const int number_blocks = cm->mi_rows * cm->mi_cols; + const int number_blocks = cm->mi_rows * cm->mi_cols; // The condition below corresponds to turning off at target bitrates: // (at 30fps), ~12kbps for CIF, 36kbps for VGA, 100kps for HD/720p. // Also turn off at very small frame sizes, to avoid too large fraction of @@ -111,10 +110,8 @@ static int apply_cyclic_refresh_bitrate(const VP10_COMMON *cm, // size of the coding block (i.e., below min_block size rejected), coding // mode, and rate/distortion. static int candidate_refresh_aq(const CYCLIC_REFRESH *cr, - const MB_MODE_INFO *mbmi, - int64_t rate, - int64_t dist, - int bsize) { + const MB_MODE_INFO *mbmi, int64_t rate, + int64_t dist, int bsize) { MV mv = mbmi->mv[0].as_mv; // Reject the block for lower-qp coding if projected distortion // is above the threshold, and any of the following is true: @@ -126,11 +123,9 @@ static int candidate_refresh_aq(const CYCLIC_REFRESH *cr, mv.col > cr->motion_thresh || mv.col < -cr->motion_thresh || !is_inter_block(mbmi))) return CR_SEGMENT_ID_BASE; - else if (bsize >= BLOCK_16X16 && - rate < cr->thresh_rate_sb && - is_inter_block(mbmi) && - mbmi->mv[0].as_int == 0 && - cr->rate_boost_fac > 10) + else if (bsize >= BLOCK_16X16 && rate < cr->thresh_rate_sb && + is_inter_block(mbmi) && mbmi->mv[0].as_int == 0 && + cr->rate_boost_fac > 10) // More aggressive delta-q for bigger blocks with zero motion. return CR_SEGMENT_ID_BOOST2; else @@ -141,9 +136,8 @@ static int candidate_refresh_aq(const CYCLIC_REFRESH *cr, static int compute_deltaq(const VP10_COMP *cpi, int q, double rate_factor) { const CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; const RATE_CONTROL *const rc = &cpi->rc; - int deltaq = vp10_compute_qdelta_by_rate(rc, cpi->common.frame_type, - q, rate_factor, - cpi->common.bit_depth); + int deltaq = vp10_compute_qdelta_by_rate(rc, cpi->common.frame_type, q, + rate_factor, cpi->common.bit_depth); if ((-deltaq) > cr->max_qdelta_perc * q / 100) { deltaq = -cr->max_qdelta_perc * q / 100; } @@ -155,7 +149,7 @@ static int compute_deltaq(const VP10_COMP *cpi, int q, double rate_factor) { // (with different delta-q). Note this function is called in the postencode // (called from rc_update_rate_correction_factors()). int vp10_cyclic_refresh_estimate_bits_at_q(const VP10_COMP *cpi, - double correction_factor) { + double correction_factor) { const VP10_COMMON *const cm = &cpi->common; const CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; int estimated_bits; @@ -166,17 +160,18 @@ int vp10_cyclic_refresh_estimate_bits_at_q(const VP10_COMP *cpi, double weight_segment1 = (double)cr->actual_num_seg1_blocks / num8x8bl; double weight_segment2 = (double)cr->actual_num_seg2_blocks / num8x8bl; // Take segment weighted average for estimated bits. - estimated_bits = (int)((1.0 - weight_segment1 - weight_segment2) * - vp10_estimate_bits_at_q(cm->frame_type, cm->base_qindex, mbs, - correction_factor, cm->bit_depth) + - weight_segment1 * - vp10_estimate_bits_at_q(cm->frame_type, - cm->base_qindex + cr->qindex_delta[1], mbs, - correction_factor, cm->bit_depth) + - weight_segment2 * - vp10_estimate_bits_at_q(cm->frame_type, - cm->base_qindex + cr->qindex_delta[2], mbs, - correction_factor, cm->bit_depth)); + estimated_bits = + (int)((1.0 - weight_segment1 - weight_segment2) * + vp10_estimate_bits_at_q(cm->frame_type, cm->base_qindex, mbs, + correction_factor, cm->bit_depth) + + weight_segment1 * + vp10_estimate_bits_at_q(cm->frame_type, + cm->base_qindex + cr->qindex_delta[1], + mbs, correction_factor, cm->bit_depth) + + weight_segment2 * + vp10_estimate_bits_at_q(cm->frame_type, + cm->base_qindex + cr->qindex_delta[2], + mbs, correction_factor, cm->bit_depth)); return estimated_bits; } @@ -186,24 +181,28 @@ int vp10_cyclic_refresh_estimate_bits_at_q(const VP10_COMP *cpi, // Note: the segment map is set to either 0/CR_SEGMENT_ID_BASE (no refresh) or // to 1/CR_SEGMENT_ID_BOOST1 (refresh) for each superblock, prior to encoding. int vp10_cyclic_refresh_rc_bits_per_mb(const VP10_COMP *cpi, int i, - double correction_factor) { + double correction_factor) { const VP10_COMMON *const cm = &cpi->common; CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; int bits_per_mb; int num8x8bl = cm->MBs << 2; // Weight for segment prior to encoding: take the average of the target // number for the frame to be encoded and the actual from the previous frame. - double weight_segment = (double)((cr->target_num_seg_blocks + - cr->actual_num_seg1_blocks + cr->actual_num_seg2_blocks) >> 1) / + double weight_segment = + (double)((cr->target_num_seg_blocks + cr->actual_num_seg1_blocks + + cr->actual_num_seg2_blocks) >> + 1) / num8x8bl; // Compute delta-q corresponding to qindex i. int deltaq = compute_deltaq(cpi, i, cr->rate_ratio_qdelta); // Take segment weighted average for bits per mb. - bits_per_mb = (int)((1.0 - weight_segment) * - vp10_rc_bits_per_mb(cm->frame_type, i, correction_factor, cm->bit_depth) + - weight_segment * - vp10_rc_bits_per_mb(cm->frame_type, i + deltaq, correction_factor, - cm->bit_depth)); + bits_per_mb = + (int)((1.0 - weight_segment) * vp10_rc_bits_per_mb(cm->frame_type, i, + correction_factor, + cm->bit_depth) + + weight_segment * vp10_rc_bits_per_mb(cm->frame_type, i + deltaq, + correction_factor, + cm->bit_depth)); return bits_per_mb; } @@ -211,12 +210,9 @@ int vp10_cyclic_refresh_rc_bits_per_mb(const VP10_COMP *cpi, int i, // check if we should reset the segment_id, and update the cyclic_refresh map // and segmentation map. void vp10_cyclic_refresh_update_segment(VP10_COMP *const cpi, - MB_MODE_INFO *const mbmi, - int mi_row, int mi_col, - BLOCK_SIZE bsize, - int64_t rate, - int64_t dist, - int skip) { + MB_MODE_INFO *const mbmi, int mi_row, + int mi_col, BLOCK_SIZE bsize, + int64_t rate, int64_t dist, int skip) { const VP10_COMMON *const cm = &cpi->common; CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; const int bw = num_8x8_blocks_wide_lookup[bsize]; @@ -224,19 +220,19 @@ void vp10_cyclic_refresh_update_segment(VP10_COMP *const cpi, const int xmis = VPXMIN(cm->mi_cols - mi_col, bw); const int ymis = VPXMIN(cm->mi_rows - mi_row, bh); const int block_index = mi_row * cm->mi_cols + mi_col; - const int refresh_this_block = candidate_refresh_aq(cr, mbmi, rate, dist, - bsize); + const int refresh_this_block = + candidate_refresh_aq(cr, mbmi, rate, dist, bsize); // Default is to not update the refresh map. int new_map_value = cr->map[block_index]; - int x = 0; int y = 0; + int x = 0; + int y = 0; // If this block is labeled for refresh, check if we should reset the // segment_id. if (cyclic_refresh_segment_id_boosted(mbmi->segment_id)) { mbmi->segment_id = refresh_this_block; // Reset segment_id if will be skipped. - if (skip) - mbmi->segment_id = CR_SEGMENT_ID_BASE; + if (skip) mbmi->segment_id = CR_SEGMENT_ID_BASE; } // Update the cyclic refresh map, to be used for setting segmentation map @@ -249,8 +245,7 @@ void vp10_cyclic_refresh_update_segment(VP10_COMP *const cpi, // Else if it is accepted as candidate for refresh, and has not already // been refreshed (marked as 1) then mark it as a candidate for cleanup // for future time (marked as 0), otherwise don't update it. - if (cr->map[block_index] == 1) - new_map_value = 0; + if (cr->map[block_index] == 1) new_map_value = 0; } else { // Leave it marked as block that is not candidate for refresh. new_map_value = 1; @@ -291,11 +286,12 @@ void vp10_cyclic_refresh_postencode(VP10_COMP *const cpi) { cr->actual_num_seg2_blocks = 0; for (mi_row = 0; mi_row < cm->mi_rows; mi_row++) for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) { - if (cyclic_refresh_segment_id( - seg_map[mi_row * cm->mi_cols + mi_col]) == CR_SEGMENT_ID_BOOST1) + if (cyclic_refresh_segment_id(seg_map[mi_row * cm->mi_cols + mi_col]) == + CR_SEGMENT_ID_BOOST1) cr->actual_num_seg1_blocks++; else if (cyclic_refresh_segment_id( - seg_map[mi_row * cm->mi_cols + mi_col]) == CR_SEGMENT_ID_BOOST2) + seg_map[mi_row * cm->mi_cols + mi_col]) == + CR_SEGMENT_ID_BOOST2) cr->actual_num_seg2_blocks++; } } @@ -334,22 +330,22 @@ void vp10_cyclic_refresh_check_golden_update(VP10_COMP *const cpi) { mi = cm->mi_grid_visible + mi_row * cm->mi_stride; for (mi_col = 0; mi_col < cols; mi_col++) { - int16_t abs_mvr = mi[0]->mbmi.mv[0].as_mv.row >= 0 ? - mi[0]->mbmi.mv[0].as_mv.row : -1 * mi[0]->mbmi.mv[0].as_mv.row; - int16_t abs_mvc = mi[0]->mbmi.mv[0].as_mv.col >= 0 ? - mi[0]->mbmi.mv[0].as_mv.col : -1 * mi[0]->mbmi.mv[0].as_mv.col; + int16_t abs_mvr = mi[0]->mbmi.mv[0].as_mv.row >= 0 + ? mi[0]->mbmi.mv[0].as_mv.row + : -1 * mi[0]->mbmi.mv[0].as_mv.row; + int16_t abs_mvc = mi[0]->mbmi.mv[0].as_mv.col >= 0 + ? mi[0]->mbmi.mv[0].as_mv.col + : -1 * mi[0]->mbmi.mv[0].as_mv.col; // Calculate the motion of the background. if (abs_mvr <= 16 && abs_mvc <= 16) { cnt1++; - if (abs_mvr == 0 && abs_mvc == 0) - cnt2++; + if (abs_mvr == 0 && abs_mvc == 0) cnt2++; } mi++; // Accumulate low_content_frame. - if (cr->map[mi_row * cols + mi_col] < 1) - low_content_frame++; + if (cr->map[mi_row * cols + mi_col] < 1) low_content_frame++; } } @@ -359,7 +355,7 @@ void vp10_cyclic_refresh_check_golden_update(VP10_COMP *const cpi) { // Also, force this frame as a golden update frame if this frame will change // the resolution (resize_pending != 0). if (cpi->resize_pending != 0 || - (cnt1 * 10 > (70 * rows * cols) && cnt2 * 20 < cnt1)) { + (cnt1 * 10 > (70 * rows * cols) && cnt2 * 20 < cnt1)) { vp10_cyclic_refresh_set_golden_update(cpi); rc->frames_till_gf_update_due = rc->baseline_gf_interval; @@ -369,8 +365,7 @@ void vp10_cyclic_refresh_check_golden_update(VP10_COMP *const cpi) { force_gf_refresh = 1; } - fraction_low = - (double)low_content_frame / (rows * cols); + fraction_low = (double)low_content_frame / (rows * cols); // Update average. cr->low_content_avg = (fraction_low + 3 * cr->low_content_avg) / 4; if (!force_gf_refresh && cpi->refresh_golden_frame == 1) { @@ -432,8 +427,7 @@ static void cyclic_refresh_update_map(VP10_COMP *const cpi) { // for possible boost/refresh (segment 1). The segment id may get // reset to 0 later if block gets coded anything other than ZEROMV. if (cr->map[bl_index2] == 0) { - if (cr->last_coded_q_map[bl_index2] > qindex_thresh) - sum_map++; + if (cr->last_coded_q_map[bl_index2] > qindex_thresh) sum_map++; } else if (cr->map[bl_index2] < 0) { cr->map[bl_index2]++; } @@ -466,14 +460,12 @@ void vp10_cyclic_refresh_update_parameters(VP10_COMP *const cpi) { cr->time_for_refresh = 0; // Use larger delta-qp (increase rate_ratio_qdelta) for first few (~4) // periods of the refresh cycle, after a key frame. - if (rc->frames_since_key < 4 * cr->percent_refresh) + if (rc->frames_since_key < 4 * cr->percent_refresh) cr->rate_ratio_qdelta = 3.0; else cr->rate_ratio_qdelta = 2.0; // Adjust some parameters for low resolutions at low bitrates. - if (cm->width <= 352 && - cm->height <= 288 && - rc->avg_frame_bandwidth < 3400) { + if (cm->width <= 352 && cm->height <= 288 && rc->avg_frame_bandwidth < 3400) { cr->motion_thresh = 4; cr->rate_boost_fac = 10; } else { @@ -488,9 +480,8 @@ void vp10_cyclic_refresh_setup(VP10_COMP *const cpi) { const RATE_CONTROL *const rc = &cpi->rc; CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; struct segmentation *const seg = &cm->seg; - const int apply_cyclic_refresh = apply_cyclic_refresh_bitrate(cm, rc); - if (cm->current_video_frame == 0) - cr->low_content_avg = 0.0; + const int apply_cyclic_refresh = apply_cyclic_refresh_bitrate(cm, rc); + if (cm->current_video_frame == 0) cr->low_content_avg = 0.0; // Don't apply refresh on key frame or enhancement layer frames. if (!apply_cyclic_refresh || cm->frame_type == KEY_FRAME) { // Set segmentation map to 0 and disable. @@ -524,7 +515,8 @@ void vp10_cyclic_refresh_setup(VP10_COMP *const cpi) { seg->abs_delta = SEGMENT_DELTADATA; // Note: setting temporal_update has no effect, as the seg-map coding method - // (temporal or spatial) is determined in vp10_choose_segmap_coding_method(), + // (temporal or spatial) is determined in + // vp10_choose_segmap_coding_method(), // based on the coding cost of each method. For error_resilient mode on the // last_frame_seg_map is set to 0, so if temporal coding is used, it is // relative to 0 previous map. diff --git a/vp10/encoder/aq_cyclicrefresh.h b/vp10/encoder/aq_cyclicrefresh.h index f6714c5c8..649d71488 100644 --- a/vp10/encoder/aq_cyclicrefresh.h +++ b/vp10/encoder/aq_cyclicrefresh.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_AQ_CYCLICREFRESH_H_ #define VP10_ENCODER_AQ_CYCLICREFRESH_H_ @@ -20,9 +19,9 @@ extern "C" { // The segment ids used in cyclic refresh: from base (no boost) to increasing // boost (higher delta-qp). -#define CR_SEGMENT_ID_BASE 0 -#define CR_SEGMENT_ID_BOOST1 1 -#define CR_SEGMENT_ID_BOOST2 2 +#define CR_SEGMENT_ID_BASE 0 +#define CR_SEGMENT_ID_BOOST1 1 +#define CR_SEGMENT_ID_BOOST2 2 // Maximum rate target ratio for setting segment delta-qp. #define CR_MAX_RATE_TARGET_RATIO 4.0 @@ -39,20 +38,20 @@ void vp10_cyclic_refresh_free(CYCLIC_REFRESH *cr); // Estimate the bits, incorporating the delta-q from segment 1, after encoding // the frame. int vp10_cyclic_refresh_estimate_bits_at_q(const struct VP10_COMP *cpi, - double correction_factor); + double correction_factor); // Estimate the bits per mb, for a given q = i and a corresponding delta-q // (for segment 1), prior to encoding the frame. int vp10_cyclic_refresh_rc_bits_per_mb(const struct VP10_COMP *cpi, int i, - double correction_factor); + double correction_factor); // Prior to coding a given prediction block, of size bsize at (mi_row, mi_col), // check if we should reset the segment_id, and update the cyclic_refresh map // and segmentation map. void vp10_cyclic_refresh_update_segment(struct VP10_COMP *const cpi, - MB_MODE_INFO *const mbmi, - int mi_row, int mi_col, BLOCK_SIZE bsize, - int64_t rate, int64_t dist, int skip); + MB_MODE_INFO *const mbmi, int mi_row, + int mi_col, BLOCK_SIZE bsize, + int64_t rate, int64_t dist, int skip); // Update the segmentation map, and related quantities: cyclic refresh map, // refresh sb_index, and target number of blocks to be refreshed. diff --git a/vp10/encoder/aq_variance.c b/vp10/encoder/aq_variance.c index e99310f79..026da7057 100644 --- a/vp10/encoder/aq_variance.c +++ b/vp10/encoder/aq_variance.c @@ -22,21 +22,20 @@ #define ENERGY_MIN (-4) #define ENERGY_MAX (1) -#define ENERGY_SPAN (ENERGY_MAX - ENERGY_MIN + 1) -#define ENERGY_IN_BOUNDS(energy)\ +#define ENERGY_SPAN (ENERGY_MAX - ENERGY_MIN + 1) +#define ENERGY_IN_BOUNDS(energy) \ assert((energy) >= ENERGY_MIN && (energy) <= ENERGY_MAX) -static const double rate_ratio[MAX_SEGMENTS] = - {2.5, 2.0, 1.5, 1.0, 0.75, 1.0, 1.0, 1.0}; -static const int segment_id[ENERGY_SPAN] = {0, 1, 1, 2, 3, 4}; +static const double rate_ratio[MAX_SEGMENTS] = { 2.5, 2.0, 1.5, 1.0, + 0.75, 1.0, 1.0, 1.0 }; +static const int segment_id[ENERGY_SPAN] = { 0, 1, 1, 2, 3, 4 }; -#define SEGMENT_ID(i) segment_id[(i) - ENERGY_MIN] +#define SEGMENT_ID(i) segment_id[(i)-ENERGY_MIN] -DECLARE_ALIGNED(16, static const uint8_t, - vp10_all_zeros[MAX_SB_SIZE]) = {0}; +DECLARE_ALIGNED(16, static const uint8_t, vp10_all_zeros[MAX_SB_SIZE]) = { 0 }; #if CONFIG_VP9_HIGHBITDEPTH DECLARE_ALIGNED(16, static const uint16_t, - vp10_highbd_all_zeros[MAX_SB_SIZE]) = {0}; + vp10_highbd_all_zeros[MAX_SB_SIZE]) = { 0 }; #endif unsigned int vp10_vaq_segment_id(int energy) { @@ -64,7 +63,7 @@ void vp10_vaq_frame_setup(VP10_COMP *cpi) { for (i = 0; i < MAX_SEGMENTS; ++i) { int qindex_delta = vp10_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex, - rate_ratio[i], cm->bit_depth); + rate_ratio[i], cm->bit_depth); // We don't allow qindex 0 in a segment if the base value is not 0. // Q index 0 (lossless) implies 4x4 encoding only and in AQ mode a segment @@ -88,9 +87,9 @@ void vp10_vaq_frame_setup(VP10_COMP *cpi) { /* TODO(agrange, paulwilkins): The block_variance calls the unoptimized versions * of variance() and highbd_8_variance(). It should not. */ -static void aq_variance(const uint8_t *a, int a_stride, - const uint8_t *b, int b_stride, - int w, int h, unsigned int *sse, int *sum) { +static void aq_variance(const uint8_t *a, int a_stride, const uint8_t *b, + int b_stride, int w, int h, unsigned int *sse, + int *sum) { int i, j; *sum = 0; @@ -109,9 +108,9 @@ static void aq_variance(const uint8_t *a, int a_stride, } #if CONFIG_VP9_HIGHBITDEPTH -static void aq_highbd_variance64(const uint8_t *a8, int a_stride, - const uint8_t *b8, int b_stride, - int w, int h, uint64_t *sse, uint64_t *sum) { +static void aq_highbd_variance64(const uint8_t *a8, int a_stride, + const uint8_t *b8, int b_stride, int w, int h, + uint64_t *sse, uint64_t *sum) { int i, j; uint16_t *a = CONVERT_TO_SHORTPTR(a8); @@ -130,9 +129,9 @@ static void aq_highbd_variance64(const uint8_t *a8, int a_stride, } } -static void aq_highbd_8_variance(const uint8_t *a8, int a_stride, - const uint8_t *b8, int b_stride, - int w, int h, unsigned int *sse, int *sum) { +static void aq_highbd_8_variance(const uint8_t *a8, int a_stride, + const uint8_t *b8, int b_stride, int w, int h, + unsigned int *sse, int *sum) { uint64_t sse_long = 0; uint64_t sum_long = 0; aq_highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, &sum_long); @@ -145,10 +144,10 @@ static unsigned int block_variance(VP10_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { MACROBLOCKD *xd = &x->e_mbd; unsigned int var, sse; - int right_overflow = (xd->mb_to_right_edge < 0) ? - ((-xd->mb_to_right_edge) >> 3) : 0; - int bottom_overflow = (xd->mb_to_bottom_edge < 0) ? - ((-xd->mb_to_bottom_edge) >> 3) : 0; + int right_overflow = + (xd->mb_to_right_edge < 0) ? ((-xd->mb_to_right_edge) >> 3) : 0; + int bottom_overflow = + (xd->mb_to_bottom_edge < 0) ? ((-xd->mb_to_bottom_edge) >> 3) : 0; if (right_overflow || bottom_overflow) { const int bw = 8 * num_8x8_blocks_wide_lookup[bs] - right_overflow; @@ -162,30 +161,27 @@ static unsigned int block_variance(VP10_COMP *cpi, MACROBLOCK *x, sse >>= 2 * (xd->bd - 8); avg >>= (xd->bd - 8); } else { - aq_variance(x->plane[0].src.buf, x->plane[0].src.stride, - vp10_all_zeros, 0, bw, bh, &sse, &avg); + aq_variance(x->plane[0].src.buf, x->plane[0].src.stride, vp10_all_zeros, + 0, bw, bh, &sse, &avg); } #else - aq_variance(x->plane[0].src.buf, x->plane[0].src.stride, - vp10_all_zeros, 0, bw, bh, &sse, &avg); + aq_variance(x->plane[0].src.buf, x->plane[0].src.stride, vp10_all_zeros, 0, + bw, bh, &sse, &avg); #endif // CONFIG_VP9_HIGHBITDEPTH var = sse - (((int64_t)avg * avg) / (bw * bh)); return (256 * var) / (bw * bh); } else { #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { - var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, - x->plane[0].src.stride, - CONVERT_TO_BYTEPTR(vp10_highbd_all_zeros), - 0, &sse); + var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride, + CONVERT_TO_BYTEPTR(vp10_highbd_all_zeros), 0, + &sse); } else { - var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, - x->plane[0].src.stride, + var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride, vp10_all_zeros, 0, &sse); } #else - var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, - x->plane[0].src.stride, + var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride, vp10_all_zeros, 0, &sse); #endif // CONFIG_VP9_HIGHBITDEPTH return (256 * var) >> num_pels_log2_lookup[bs]; @@ -204,7 +200,7 @@ int vp10_block_energy(VP10_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { double energy_midpoint; vpx_clear_system_state(); energy_midpoint = - (cpi->oxcf.pass == 2) ? cpi->twopass.mb_av_energy : DEFAULT_E_MIDPOINT; + (cpi->oxcf.pass == 2) ? cpi->twopass.mb_av_energy : DEFAULT_E_MIDPOINT; energy = vp10_log_block_var(cpi, x, bs) - energy_midpoint; return clamp((int)round(energy), ENERGY_MIN, ENERGY_MAX); } diff --git a/vp10/encoder/aq_variance.h b/vp10/encoder/aq_variance.h index 318f5f27f..cfb5b86a2 100644 --- a/vp10/encoder/aq_variance.h +++ b/vp10/encoder/aq_variance.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_AQ_VARIANCE_H_ #define VP10_ENCODER_AQ_VARIANCE_H_ diff --git a/vp10/encoder/arm/neon/dct_neon.c b/vp10/encoder/arm/neon/dct_neon.c index b37a2ff3a..8d066b349 100644 --- a/vp10/encoder/arm/neon/dct_neon.c +++ b/vp10/encoder/arm/neon/dct_neon.c @@ -17,20 +17,17 @@ #include "vp10/common/blockd.h" #include "vpx_dsp/txfm_common.h" -void vp10_fdct8x8_quant_neon(const int16_t *input, int stride, - int16_t* coeff_ptr, intptr_t n_coeffs, - int skip_block, const int16_t* zbin_ptr, - const int16_t* round_ptr, const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - int16_t* qcoeff_ptr, int16_t* dqcoeff_ptr, - const int16_t* dequant_ptr, uint16_t* eob_ptr, - const int16_t* scan_ptr, - const int16_t* iscan_ptr) { +void vp10_fdct8x8_quant_neon( + const int16_t *input, int stride, int16_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, + const int16_t *quant_ptr, const int16_t *quant_shift_ptr, + int16_t *qcoeff_ptr, int16_t *dqcoeff_ptr, const int16_t *dequant_ptr, + uint16_t *eob_ptr, const int16_t *scan_ptr, const int16_t *iscan_ptr) { int16_t temp_buffer[64]; (void)coeff_ptr; vpx_fdct8x8_neon(input, temp_buffer, stride); vp10_quantize_fp_neon(temp_buffer, n_coeffs, skip_block, zbin_ptr, round_ptr, - quant_ptr, quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, - dequant_ptr, eob_ptr, scan_ptr, iscan_ptr); + quant_ptr, quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, + dequant_ptr, eob_ptr, scan_ptr, iscan_ptr); } diff --git a/vp10/encoder/arm/neon/error_neon.c b/vp10/encoder/arm/neon/error_neon.c index 009520aee..34805d316 100644 --- a/vp10/encoder/arm/neon/error_neon.c +++ b/vp10/encoder/arm/neon/error_neon.c @@ -14,7 +14,7 @@ #include "./vp10_rtcd.h" int64_t vp10_block_error_fp_neon(const int16_t *coeff, const int16_t *dqcoeff, - int block_size) { + int block_size) { int64x2_t error = vdupq_n_s64(0); assert(block_size >= 8); diff --git a/vp10/encoder/arm/neon/quantize_neon.c b/vp10/encoder/arm/neon/quantize_neon.c index 9354ced69..7b8e447c0 100644 --- a/vp10/encoder/arm/neon/quantize_neon.c +++ b/vp10/encoder/arm/neon/quantize_neon.c @@ -22,12 +22,12 @@ #include "vp10/encoder/rd.h" void vp10_quantize_fp_neon(const int16_t *coeff_ptr, intptr_t count, - int skip_block, const int16_t *zbin_ptr, - const int16_t *round_ptr, const int16_t *quant_ptr, - const int16_t *quant_shift_ptr, int16_t *qcoeff_ptr, - int16_t *dqcoeff_ptr, const int16_t *dequant_ptr, - uint16_t *eob_ptr, - const int16_t *scan, const int16_t *iscan) { + int skip_block, const int16_t *zbin_ptr, + const int16_t *round_ptr, const int16_t *quant_ptr, + const int16_t *quant_shift_ptr, int16_t *qcoeff_ptr, + int16_t *dqcoeff_ptr, const int16_t *dequant_ptr, + uint16_t *eob_ptr, const int16_t *scan, + const int16_t *iscan) { // TODO(jingning) Decide the need of these arguments after the // quantization process is completed. (void)zbin_ptr; @@ -54,12 +54,12 @@ void vp10_quantize_fp_neon(const int16_t *coeff_ptr, intptr_t count, const int16x8_t v_coeff = vld1q_s16(&coeff_ptr[0]); const int16x8_t v_coeff_sign = vshrq_n_s16(v_coeff, 15); const int16x8_t v_tmp = vabaq_s16(v_round, v_coeff, v_zero); - const int32x4_t v_tmp_lo = vmull_s16(vget_low_s16(v_tmp), - vget_low_s16(v_quant)); - const int32x4_t v_tmp_hi = vmull_s16(vget_high_s16(v_tmp), - vget_high_s16(v_quant)); - const int16x8_t v_tmp2 = vcombine_s16(vshrn_n_s32(v_tmp_lo, 16), - vshrn_n_s32(v_tmp_hi, 16)); + const int32x4_t v_tmp_lo = + vmull_s16(vget_low_s16(v_tmp), vget_low_s16(v_quant)); + const int32x4_t v_tmp_hi = + vmull_s16(vget_high_s16(v_tmp), vget_high_s16(v_quant)); + const int16x8_t v_tmp2 = + vcombine_s16(vshrn_n_s32(v_tmp_lo, 16), vshrn_n_s32(v_tmp_hi, 16)); const uint16x8_t v_nz_mask = vceqq_s16(v_tmp2, v_zero); const int16x8_t v_iscan_plus1 = vaddq_s16(v_iscan, v_one); const int16x8_t v_nz_iscan = vbslq_s16(v_nz_mask, v_zero, v_iscan_plus1); @@ -79,12 +79,12 @@ void vp10_quantize_fp_neon(const int16_t *coeff_ptr, intptr_t count, const int16x8_t v_coeff = vld1q_s16(&coeff_ptr[i]); const int16x8_t v_coeff_sign = vshrq_n_s16(v_coeff, 15); const int16x8_t v_tmp = vabaq_s16(v_round, v_coeff, v_zero); - const int32x4_t v_tmp_lo = vmull_s16(vget_low_s16(v_tmp), - vget_low_s16(v_quant)); - const int32x4_t v_tmp_hi = vmull_s16(vget_high_s16(v_tmp), - vget_high_s16(v_quant)); - const int16x8_t v_tmp2 = vcombine_s16(vshrn_n_s32(v_tmp_lo, 16), - vshrn_n_s32(v_tmp_hi, 16)); + const int32x4_t v_tmp_lo = + vmull_s16(vget_low_s16(v_tmp), vget_low_s16(v_quant)); + const int32x4_t v_tmp_hi = + vmull_s16(vget_high_s16(v_tmp), vget_high_s16(v_quant)); + const int16x8_t v_tmp2 = + vcombine_s16(vshrn_n_s32(v_tmp_lo, 16), vshrn_n_s32(v_tmp_hi, 16)); const uint16x8_t v_nz_mask = vceqq_s16(v_tmp2, v_zero); const int16x8_t v_iscan_plus1 = vaddq_s16(v_iscan, v_one); const int16x8_t v_nz_iscan = vbslq_s16(v_nz_mask, v_zero, v_iscan_plus1); @@ -96,9 +96,8 @@ void vp10_quantize_fp_neon(const int16_t *coeff_ptr, intptr_t count, vst1q_s16(&dqcoeff_ptr[i], v_dqcoeff); } { - const int16x4_t v_eobmax_3210 = - vmax_s16(vget_low_s16(v_eobmax_76543210), - vget_high_s16(v_eobmax_76543210)); + const int16x4_t v_eobmax_3210 = vmax_s16( + vget_low_s16(v_eobmax_76543210), vget_high_s16(v_eobmax_76543210)); const int64x1_t v_eobmax_xx32 = vshr_n_s64(vreinterpret_s64_s16(v_eobmax_3210), 32); const int16x4_t v_eobmax_tmp = diff --git a/vp10/encoder/bitstream.c b/vp10/encoder/bitstream.c index a5f7030db..5fbeb0c06 100644 --- a/vp10/encoder/bitstream.c +++ b/vp10/encoder/bitstream.c @@ -41,63 +41,82 @@ #include "vp10/encoder/tokenize.h" static const struct vp10_token intra_mode_encodings[INTRA_MODES] = { - {0, 1}, {6, 3}, {28, 5}, {30, 5}, {58, 6}, {59, 6}, {126, 7}, {127, 7}, - {62, 6}, {2, 2}}; + { 0, 1 }, { 6, 3 }, { 28, 5 }, { 30, 5 }, { 58, 6 }, + { 59, 6 }, { 126, 7 }, { 127, 7 }, { 62, 6 }, { 2, 2 } +}; #if CONFIG_EXT_INTERP static const struct vp10_token switchable_interp_encodings[SWITCHABLE_FILTERS] = - {{0, 1}, {4, 3}, {6, 3}, {5, 3}, {7, 3}}; + { { 0, 1 }, { 4, 3 }, { 6, 3 }, { 5, 3 }, { 7, 3 } }; #else static const struct vp10_token switchable_interp_encodings[SWITCHABLE_FILTERS] = - {{0, 1}, {2, 2}, {3, 2}}; + { { 0, 1 }, { 2, 2 }, { 3, 2 } }; #endif // CONFIG_EXT_INTERP #if CONFIG_EXT_PARTITION_TYPES -static const struct vp10_token ext_partition_encodings[EXT_PARTITION_TYPES] = - {{0, 1}, {4, 3}, {12, 4}, {7, 3}, {10, 4}, {11, 4}, {26, 5}, {27, 5}}; +static const struct vp10_token ext_partition_encodings[EXT_PARTITION_TYPES] = { + { 0, 1 }, { 4, 3 }, { 12, 4 }, { 7, 3 }, + { 10, 4 }, { 11, 4 }, { 26, 5 }, { 27, 5 } +}; #endif -static const struct vp10_token partition_encodings[PARTITION_TYPES] = - {{0, 1}, {2, 2}, {6, 3}, {7, 3}}; +static const struct vp10_token partition_encodings[PARTITION_TYPES] = { + { 0, 1 }, { 2, 2 }, { 6, 3 }, { 7, 3 } +}; #if !CONFIG_REF_MV static const struct vp10_token inter_mode_encodings[INTER_MODES] = #if CONFIG_EXT_INTER - {{2, 2}, {6, 3}, {0, 1}, {14, 4}, {15, 4}}; + { { 2, 2 }, { 6, 3 }, { 0, 1 }, { 14, 4 }, { 15, 4 } }; #else - {{2, 2}, {6, 3}, {0, 1}, {7, 3}}; + { { 2, 2 }, { 6, 3 }, { 0, 1 }, { 7, 3 } }; #endif // CONFIG_EXT_INTER #endif #if CONFIG_EXT_INTER -static const struct vp10_token inter_compound_mode_encodings - [INTER_COMPOUND_MODES] = { - {2, 2}, {50, 6}, {51, 6}, {24, 5}, {52, 6}, {53, 6}, - {54, 6}, {55, 6}, {0, 1}, {7, 3} -}; +static const struct vp10_token + inter_compound_mode_encodings[INTER_COMPOUND_MODES] = { + { 2, 2 }, { 50, 6 }, { 51, 6 }, { 24, 5 }, { 52, 6 }, + { 53, 6 }, { 54, 6 }, { 55, 6 }, { 0, 1 }, { 7, 3 } + }; #endif // CONFIG_EXT_INTER static const struct vp10_token palette_size_encodings[] = { - {0, 1}, {2, 2}, {6, 3}, {14, 4}, {30, 5}, {62, 6}, {63, 6}, + { 0, 1 }, { 2, 2 }, { 6, 3 }, { 14, 4 }, { 30, 5 }, { 62, 6 }, { 63, 6 }, }; static const struct vp10_token -palette_color_encodings[PALETTE_MAX_SIZE - 1][PALETTE_MAX_SIZE] = { - {{0, 1}, {1, 1}}, // 2 colors - {{0, 1}, {2, 2}, {3, 2}}, // 3 colors - {{0, 1}, {2, 2}, {6, 3}, {7, 3}}, // 4 colors - {{0, 1}, {2, 2}, {6, 3}, {14, 4}, {15, 4}}, // 5 colors - {{0, 1}, {2, 2}, {6, 3}, {14, 4}, {30, 5}, {31, 5}}, // 6 colors - {{0, 1}, {2, 2}, {6, 3}, {14, 4}, {30, 5}, {62, 6}, {63, 6}}, // 7 colors - {{0, 1}, {2, 2}, {6, 3}, {14, 4}, - {30, 5}, {62, 6}, {126, 7}, {127, 7}}, // 8 colors -}; + palette_color_encodings[PALETTE_MAX_SIZE - 1][PALETTE_MAX_SIZE] = { + { { 0, 1 }, { 1, 1 } }, // 2 colors + { { 0, 1 }, { 2, 2 }, { 3, 2 } }, // 3 colors + { { 0, 1 }, { 2, 2 }, { 6, 3 }, { 7, 3 } }, // 4 colors + { { 0, 1 }, { 2, 2 }, { 6, 3 }, { 14, 4 }, { 15, 4 } }, // 5 colors + { { 0, 1 }, + { 2, 2 }, + { 6, 3 }, + { 14, 4 }, + { 30, 5 }, + { 31, 5 } }, // 6 colors + { { 0, 1 }, + { 2, 2 }, + { 6, 3 }, + { 14, 4 }, + { 30, 5 }, + { 62, 6 }, + { 63, 6 } }, // 7 colors + { { 0, 1 }, + { 2, 2 }, + { 6, 3 }, + { 14, 4 }, + { 30, 5 }, + { 62, 6 }, + { 126, 7 }, + { 127, 7 } }, // 8 colors + }; -static const struct vp10_token -tx_size_encodings[TX_SIZES - 1][TX_SIZES] = { - {{0, 1}, {1, 1}}, // Max tx_size is 8X8 - {{0, 1}, {2, 2}, {3, 2}}, // Max tx_size is 16X16 - {{0, 1}, {2, 2}, {6, 3}, {7, 3}}, // Max tx_size is 32X32 +static const struct vp10_token tx_size_encodings[TX_SIZES - 1][TX_SIZES] = { + { { 0, 1 }, { 1, 1 } }, // Max tx_size is 8X8 + { { 0, 1 }, { 2, 2 }, { 3, 2 } }, // Max tx_size is 16X16 + { { 0, 1 }, { 2, 2 }, { 6, 3 }, { 7, 3 } }, // Max tx_size is 32X32 }; static INLINE void write_uniform(vp10_writer *w, int n, int v) { int l = get_unsigned_bits(n); int m = (1 << l) - n; - if (l == 0) - return; + if (l == 0) return; if (v < m) { vp10_write_literal(w, v, l - 1); } else { @@ -148,7 +167,7 @@ void vp10_encode_token_init(void) { #endif // CONFIG_OBMC || CONFIG_WARPED_MOTION #if CONFIG_GLOBAL_MOTION vp10_tokens_from_tree(global_motion_types_encodings, - vp10_global_motion_types_tree); + vp10_global_motion_types_tree); #endif // CONFIG_GLOBAL_MOTION } @@ -165,8 +184,8 @@ static void write_interintra_mode(vp10_writer *w, INTERINTRA_MODE mode, } #endif // CONFIG_EXT_INTER -static void write_inter_mode(VP10_COMMON *cm, - vp10_writer *w, PREDICTION_MODE mode, +static void write_inter_mode(VP10_COMMON *cm, vp10_writer *w, + PREDICTION_MODE mode, #if CONFIG_REF_MV && CONFIG_EXT_INTER int is_compound, #endif // CONFIG_REF_MV && CONFIG_EXT_INTER @@ -200,12 +219,9 @@ static void write_inter_mode(VP10_COMMON *cm, int16_t refmv_ctx = (mode_ctx >> REFMV_OFFSET) & REFMV_CTX_MASK; vpx_prob refmv_prob; - if (mode_ctx & (1 << SKIP_NEARESTMV_OFFSET)) - refmv_ctx = 6; - if (mode_ctx & (1 << SKIP_NEARMV_OFFSET)) - refmv_ctx = 7; - if (mode_ctx & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) - refmv_ctx = 8; + if (mode_ctx & (1 << SKIP_NEARESTMV_OFFSET)) refmv_ctx = 6; + if (mode_ctx & (1 << SKIP_NEARMV_OFFSET)) refmv_ctx = 7; + if (mode_ctx & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) refmv_ctx = 8; refmv_prob = cm->fc->refmv_prob[refmv_ctx]; vp10_write(w, mode != NEARESTMV, refmv_prob); @@ -215,15 +231,13 @@ static void write_inter_mode(VP10_COMMON *cm, const vpx_prob *const inter_probs = cm->fc->inter_mode_probs[mode_ctx]; assert(is_inter_mode(mode)); vp10_write_token(w, vp10_inter_mode_tree, inter_probs, - &inter_mode_encodings[INTER_OFFSET(mode)]); + &inter_mode_encodings[INTER_OFFSET(mode)]); #endif } #if CONFIG_REF_MV -static void write_drl_idx(const VP10_COMMON *cm, - const MB_MODE_INFO *mbmi, - const MB_MODE_INFO_EXT *mbmi_ext, - vp10_writer *w) { +static void write_drl_idx(const VP10_COMMON *cm, const MB_MODE_INFO *mbmi, + const MB_MODE_INFO_EXT *mbmi_ext, vp10_writer *w) { uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame); assert(mbmi->ref_mv_idx < 3); @@ -237,8 +251,7 @@ static void write_drl_idx(const VP10_COMMON *cm, vpx_prob drl_prob = cm->fc->drl_prob[drl_ctx]; vp10_write(w, mbmi->ref_mv_idx != idx, drl_prob); - if (mbmi->ref_mv_idx == idx) - return; + if (mbmi->ref_mv_idx == idx) return; } } return; @@ -254,8 +267,7 @@ static void write_drl_idx(const VP10_COMMON *cm, vpx_prob drl_prob = cm->fc->drl_prob[drl_ctx]; vp10_write(w, mbmi->ref_mv_idx != (idx - 1), drl_prob); - if (mbmi->ref_mv_idx == (idx - 1)) - return; + if (mbmi->ref_mv_idx == (idx - 1)) return; } } return; @@ -268,23 +280,23 @@ static void write_inter_compound_mode(VP10_COMMON *cm, vp10_writer *w, PREDICTION_MODE mode, const int16_t mode_ctx) { const vpx_prob *const inter_compound_probs = - cm->fc->inter_compound_mode_probs[mode_ctx]; + cm->fc->inter_compound_mode_probs[mode_ctx]; assert(is_inter_compound_mode(mode)); vp10_write_token(w, vp10_inter_compound_mode_tree, inter_compound_probs, - &inter_compound_mode_encodings[INTER_COMPOUND_OFFSET(mode)]); + &inter_compound_mode_encodings[INTER_COMPOUND_OFFSET(mode)]); } #endif // CONFIG_EXT_INTER -static void encode_unsigned_max(struct vpx_write_bit_buffer *wb, - int data, int max) { +static void encode_unsigned_max(struct vpx_write_bit_buffer *wb, int data, + int max) { vpx_wb_write_literal(wb, data, get_unsigned_bits(max)); } static void prob_diff_update(const vpx_tree_index *tree, vpx_prob probs[/*n - 1*/], - const unsigned int counts[/*n - 1*/], - int n, vp10_writer *w) { + const unsigned int counts[/*n - 1*/], int n, + vp10_writer *w) { int i; unsigned int branch_ct[32][2]; @@ -308,33 +320,26 @@ static int prob_diff_update_savings(const vpx_tree_index *tree, assert(n <= 32); vp10_tree_probs_from_distribution(tree, branch_ct, counts); for (i = 0; i < n - 1; ++i) { - savings += vp10_cond_prob_diff_update_savings(&probs[i], - branch_ct[i]); + savings += vp10_cond_prob_diff_update_savings(&probs[i], branch_ct[i]); } return savings; } #if CONFIG_VAR_TX -static void write_tx_size_inter(const VP10_COMMON *cm, - const MACROBLOCKD *xd, - const MB_MODE_INFO *mbmi, - TX_SIZE tx_size, int blk_row, int blk_col, - vp10_writer *w) { +static void write_tx_size_inter(const VP10_COMMON *cm, const MACROBLOCKD *xd, + const MB_MODE_INFO *mbmi, TX_SIZE tx_size, + int blk_row, int blk_col, vp10_writer *w) { const int tx_row = blk_row >> 1; const int tx_col = blk_col >> 1; int max_blocks_high = num_4x4_blocks_high_lookup[mbmi->sb_type]; int max_blocks_wide = num_4x4_blocks_wide_lookup[mbmi->sb_type]; int ctx = txfm_partition_context(xd->above_txfm_context + tx_col, - xd->left_txfm_context + tx_row, - tx_size); + xd->left_txfm_context + tx_row, tx_size); - if (xd->mb_to_bottom_edge < 0) - max_blocks_high += xd->mb_to_bottom_edge >> 5; - if (xd->mb_to_right_edge < 0) - max_blocks_wide += xd->mb_to_right_edge >> 5; + if (xd->mb_to_bottom_edge < 0) max_blocks_high += xd->mb_to_bottom_edge >> 5; + if (xd->mb_to_right_edge < 0) max_blocks_wide += xd->mb_to_right_edge >> 5; - if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) - return; + if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (tx_size == mbmi->inter_tx_size[tx_row][tx_col]) { vp10_write(w, 0, cm->fc->txfm_partition_prob[ctx]); @@ -371,17 +376,17 @@ static void update_txfm_partition_probs(VP10_COMMON *cm, vp10_writer *w, } #endif -static void write_selected_tx_size(const VP10_COMMON *cm, - const MACROBLOCKD *xd, vp10_writer *w) { +static void write_selected_tx_size(const VP10_COMMON *cm, const MACROBLOCKD *xd, + vp10_writer *w) { TX_SIZE tx_size = xd->mi[0]->mbmi.tx_size; BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; const TX_SIZE max_tx_size = max_txsize_lookup[bsize]; // For sub8x8 blocks the tx_size symbol does not need to be sent if (bsize >= BLOCK_8X8) { - vp10_write_token(w, vp10_tx_size_tree[max_tx_size - TX_8X8], - cm->fc->tx_size_probs[max_tx_size - TX_8X8] - [get_tx_size_context(xd)], - &tx_size_encodings[max_tx_size - TX_8X8][tx_size]); + vp10_write_token( + w, vp10_tx_size_tree[max_tx_size - TX_8X8], + cm->fc->tx_size_probs[max_tx_size - TX_8X8][get_tx_size_context(xd)], + &tx_size_encodings[max_tx_size - TX_8X8][tx_size]); } } @@ -399,8 +404,7 @@ static void update_inter_mode_probs(VP10_COMMON *cm, vp10_writer *w, vp10_cond_prob_diff_update(w, &cm->fc->refmv_prob[i], counts->refmv_mode[i]); for (i = 0; i < DRL_MODE_CONTEXTS; ++i) - vp10_cond_prob_diff_update(w, &cm->fc->drl_prob[i], - counts->drl_mode[i]); + vp10_cond_prob_diff_update(w, &cm->fc->drl_prob[i], counts->drl_mode[i]); #if CONFIG_EXT_INTER vp10_cond_prob_diff_update(w, &cm->fc->new2mv_prob, counts->new2mv_mode); #endif // CONFIG_EXT_INTER @@ -415,19 +419,17 @@ static void update_inter_compound_mode_probs(VP10_COMMON *cm, vp10_writer *w) { int savings = 0; int do_update = 0; for (i = 0; i < INTER_MODE_CONTEXTS; ++i) { - savings += prob_diff_update_savings(vp10_inter_compound_mode_tree, - cm->fc->inter_compound_mode_probs[i], - cm->counts.inter_compound_mode[i], - INTER_COMPOUND_MODES); + savings += prob_diff_update_savings( + vp10_inter_compound_mode_tree, cm->fc->inter_compound_mode_probs[i], + cm->counts.inter_compound_mode[i], INTER_COMPOUND_MODES); } do_update = savings > savings_thresh; vp10_write(w, do_update, GROUP_DIFF_UPDATE_PROB); if (do_update) { for (i = 0; i < INTER_MODE_CONTEXTS; ++i) { - prob_diff_update(vp10_inter_compound_mode_tree, - cm->fc->inter_compound_mode_probs[i], - cm->counts.inter_compound_mode[i], - INTER_COMPOUND_MODES, w); + prob_diff_update( + vp10_inter_compound_mode_tree, cm->fc->inter_compound_mode_probs[i], + cm->counts.inter_compound_mode[i], INTER_COMPOUND_MODES, w); } } } @@ -461,7 +463,6 @@ static void update_switchable_interp_probs(VP10_COMMON *cm, vp10_writer *w, counts->switchable_interp[j], SWITCHABLE_FILTERS, w); } - #if CONFIG_EXT_TX static void update_ext_tx_probs(VP10_COMMON *cm, vp10_writer *w) { const int savings_thresh = vp10_cost_one(GROUP_DIFF_UPDATE_PROB) - @@ -482,10 +483,9 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vp10_writer *w) { if (do_update) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { if (!use_inter_ext_tx_for_txsize[s][i]) continue; - prob_diff_update(vp10_ext_tx_inter_tree[s], - cm->fc->inter_ext_tx_prob[s][i], - cm->counts.inter_ext_tx[s][i], - num_ext_tx_set_inter[s], w); + prob_diff_update( + vp10_ext_tx_inter_tree[s], cm->fc->inter_ext_tx_prob[s][i], + cm->counts.inter_ext_tx[s][i], num_ext_tx_set_inter[s], w); } } } @@ -506,10 +506,9 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vp10_writer *w) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { if (!use_intra_ext_tx_for_txsize[s][i]) continue; for (j = 0; j < INTRA_MODES; ++j) - prob_diff_update(vp10_ext_tx_intra_tree[s], - cm->fc->intra_ext_tx_prob[s][i][j], - cm->counts.intra_ext_tx[s][i][j], - num_ext_tx_set_intra[s], w); + prob_diff_update( + vp10_ext_tx_intra_tree[s], cm->fc->intra_ext_tx_prob[s][i][j], + cm->counts.intra_ext_tx[s][i][j], num_ext_tx_set_intra[s], w); } } } @@ -535,33 +534,29 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vp10_writer *w) { if (do_update) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { for (j = 0; j < TX_TYPES; ++j) - prob_diff_update(vp10_ext_tx_tree, - cm->fc->intra_ext_tx_prob[i][j], - cm->counts.intra_ext_tx[i][j], - TX_TYPES, w); + prob_diff_update(vp10_ext_tx_tree, cm->fc->intra_ext_tx_prob[i][j], + cm->counts.intra_ext_tx[i][j], TX_TYPES, w); } } savings = 0; for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { - savings += prob_diff_update_savings( - vp10_ext_tx_tree, cm->fc->inter_ext_tx_prob[i], - cm->counts.inter_ext_tx[i], TX_TYPES); + savings += + prob_diff_update_savings(vp10_ext_tx_tree, cm->fc->inter_ext_tx_prob[i], + cm->counts.inter_ext_tx[i], TX_TYPES); } do_update = savings > savings_thresh; vp10_write(w, do_update, GROUP_DIFF_UPDATE_PROB); if (do_update) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { - prob_diff_update(vp10_ext_tx_tree, - cm->fc->inter_ext_tx_prob[i], - cm->counts.inter_ext_tx[i], - TX_TYPES, w); + prob_diff_update(vp10_ext_tx_tree, cm->fc->inter_ext_tx_prob[i], + cm->counts.inter_ext_tx[i], TX_TYPES, w); } } } #endif // CONFIG_EXT_TX -static void pack_palette_tokens(vp10_writer *w, const TOKENEXTRA **tp, - int n, int num) { +static void pack_palette_tokens(vp10_writer *w, const TOKENEXTRA **tp, int n, + int num) { int i; const TOKENEXTRA *p = *tp; @@ -601,8 +596,8 @@ static void update_supertx_probs(VP10_COMMON *cm, vp10_writer *w) { #endif // CONFIG_SUPERTX #if !CONFIG_ANS -static void pack_mb_tokens(vp10_writer *w, - const TOKENEXTRA **tp, const TOKENEXTRA *const stop, +static void pack_mb_tokens(vp10_writer *w, const TOKENEXTRA **tp, + const TOKENEXTRA *const stop, vpx_bit_depth_t bit_depth, const TX_SIZE tx) { const TOKENEXTRA *p = *tp; #if CONFIG_VAR_TX @@ -625,7 +620,7 @@ static void pack_mb_tokens(vp10_writer *w, b = &vp10_extra_bits[t]; #else const vp10_extra_bit *const b = &vp10_extra_bits[t]; - (void) bit_depth; + (void)bit_depth; #endif // CONFIG_VP9_HIGHBITDEPTH /* skip one or two nodes */ @@ -643,21 +638,20 @@ static void pack_mb_tokens(vp10_writer *w, if (t != ONE_TOKEN) { int len = UNCONSTRAINED_NODES - p->skip_eob_node; vp10_write_tree(w, vp10_coef_con_tree, - vp10_pareto8_full[p->context_tree[PIVOT_NODE] - 1], - v, n - len, 0); + vp10_pareto8_full[p->context_tree[PIVOT_NODE] - 1], v, + n - len, 0); } } } if (b->base_val) { const int e = p->extra, l = b->len; - int skip_bits = - (b->base_val == CAT6_MIN_VAL) ? TX_SIZES - 1 - tx : 0; + int skip_bits = (b->base_val == CAT6_MIN_VAL) ? TX_SIZES - 1 - tx : 0; if (l) { const unsigned char *pb = b->prob; int v = e >> 1; - int n = l; /* number of bits in v, assumed nonzero */ + int n = l; /* number of bits in v, assumed nonzero */ int i = 0; do { @@ -678,8 +672,7 @@ static void pack_mb_tokens(vp10_writer *w, #if CONFIG_VAR_TX ++count; - if (t == EOB_TOKEN || count == seg_eob) - break; + if (t == EOB_TOKEN || count == seg_eob) break; #endif } @@ -688,11 +681,9 @@ static void pack_mb_tokens(vp10_writer *w, #else // This function serializes the tokens in forward order using a buffered ans // coder. -static void pack_mb_tokens(struct BufAnsCoder *ans, - const TOKENEXTRA **tp, +static void pack_mb_tokens(struct BufAnsCoder *ans, const TOKENEXTRA **tp, const TOKENEXTRA *const stop, - vpx_bit_depth_t bit_depth, - const TX_SIZE tx) { + vpx_bit_depth_t bit_depth, const TX_SIZE tx) { const TOKENEXTRA *p = *tp; #if CONFIG_VAR_TX int count = 0; @@ -764,21 +755,20 @@ static void pack_mb_tokens(struct BufAnsCoder *ans, #endif // !CONFIG_ANS #if CONFIG_VAR_TX -static void pack_txb_tokens(vp10_writer *w, - const TOKENEXTRA **tp, - const TOKENEXTRA *const tok_end, - MACROBLOCKD *xd, MB_MODE_INFO *mbmi, int plane, - BLOCK_SIZE plane_bsize, - vpx_bit_depth_t bit_depth, - int block, - int blk_row, int blk_col, TX_SIZE tx_size) { +static void pack_txb_tokens(vp10_writer *w, const TOKENEXTRA **tp, + const TOKENEXTRA *const tok_end, MACROBLOCKD *xd, + MB_MODE_INFO *mbmi, int plane, + BLOCK_SIZE plane_bsize, vpx_bit_depth_t bit_depth, + int block, int blk_row, int blk_col, + TX_SIZE tx_size) { const struct macroblockd_plane *const pd = &xd->plane[plane]; const BLOCK_SIZE bsize = txsize_to_bsize[tx_size]; const int tx_row = blk_row >> (1 - pd->subsampling_y); const int tx_col = blk_col >> (1 - pd->subsampling_x); - const TX_SIZE plane_tx_size = plane ? - get_uv_tx_size_impl(mbmi->inter_tx_size[tx_row][tx_col], bsize, 0, 0) : - mbmi->inter_tx_size[tx_row][tx_col]; + const TX_SIZE plane_tx_size = + plane ? get_uv_tx_size_impl(mbmi->inter_tx_size[tx_row][tx_col], bsize, 0, + 0) + : mbmi->inter_tx_size[tx_row][tx_col]; int max_blocks_high = num_4x4_blocks_high_lookup[plane_bsize]; int max_blocks_wide = num_4x4_blocks_wide_lookup[plane_bsize]; @@ -787,8 +777,7 @@ static void pack_txb_tokens(vp10_writer *w, if (xd->mb_to_right_edge < 0) max_blocks_wide += xd->mb_to_right_edge >> (5 + pd->subsampling_x); - if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) - return; + if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (tx_size == plane_tx_size) { pack_mb_tokens(w, tp, tok_end, bit_depth, tx_size); @@ -804,12 +793,10 @@ static void pack_txb_tokens(vp10_writer *w, const int offsetc = blk_col + ((i & 0x01) << bsl); int step = num_4x4_blocks_txsize_lookup[tx_size - 1]; - if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) - continue; + if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) continue; - pack_txb_tokens(w, tp, tok_end, xd, mbmi, plane, - plane_bsize, bit_depth, block + i * step, - offsetr, offsetc, tx_size - 1); + pack_txb_tokens(w, tp, tok_end, xd, mbmi, plane, plane_bsize, bit_depth, + block + i * step, offsetr, offsetc, tx_size - 1); } } } @@ -834,7 +821,7 @@ static void write_ref_frames(const VP10_COMMON *cm, const MACROBLOCKD *xd, if (segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) { assert(!is_compound); assert(mbmi->ref_frame[0] == - get_segdata(&cm->seg, segment_id, SEG_LVL_REF_FRAME)); + get_segdata(&cm->seg, segment_id, SEG_LVL_REF_FRAME)); } else { // does the feature use compound prediction or not // (if not specified at the frame/segment level) @@ -887,7 +874,7 @@ static void write_ref_frames(const VP10_COMMON *cm, const MACROBLOCKD *xd, vp10_write(w, bit4, vp10_get_pred_prob_single_ref_p5(cm, xd)); } } -#else // CONFIG_EXT_REFS +#else // CONFIG_EXT_REFS const int bit0 = mbmi->ref_frame[0] != LAST_FRAME; vp10_write(w, bit0, vp10_get_pred_prob_single_ref_p1(cm, xd)); @@ -907,10 +894,9 @@ static void write_ext_intra_mode_info(const VP10_COMMON *const cm, #if !ALLOW_FILTER_INTRA_MODES return; #endif - if (mbmi->mode == DC_PRED && - mbmi->palette_mode_info.palette_size[0] == 0) { + if (mbmi->mode == DC_PRED && mbmi->palette_mode_info.palette_size[0] == 0) { vp10_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[0], - cm->fc->ext_intra_probs[0]); + cm->fc->ext_intra_probs[0]); if (mbmi->ext_intra_mode_info.use_ext_intra_mode[0]) { EXT_INTRA_MODE mode = mbmi->ext_intra_mode_info.ext_intra_mode[0]; write_uniform(w, FILTER_INTRA_MODES, mode); @@ -920,7 +906,7 @@ static void write_ext_intra_mode_info(const VP10_COMMON *const cm, if (mbmi->uv_mode == DC_PRED && mbmi->palette_mode_info.palette_size[1] == 0) { vp10_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[1], - cm->fc->ext_intra_probs[1]); + cm->fc->ext_intra_probs[1]); if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) { EXT_INTRA_MODE mode = mbmi->ext_intra_mode_info.ext_intra_mode[1]; write_uniform(w, FILTER_INTRA_MODES, mode); @@ -935,8 +921,7 @@ static void write_intra_angle_info(const VP10_COMMON *cm, const MACROBLOCKD *xd, const int intra_filter_ctx = vp10_get_pred_context_intra_interp(xd); int p_angle; - if (bsize < BLOCK_8X8) - return; + if (bsize < BLOCK_8X8) return; if (mbmi->mode != DC_PRED && mbmi->mode != TM_PRED) { write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1, @@ -989,9 +974,9 @@ static void write_switchable_interp_filter(VP10_COMP *cpi, (mbmi->ref_frame[1] > INTRA_FRAME && has_subpel_mv_component(xd->mi[0], xd, dir + 2))) { const int ctx = vp10_get_pred_context_switchable_interp(xd, dir); - vp10_write_token(w, vp10_switchable_interp_tree, - cm->fc->switchable_interp_prob[ctx], - &switchable_interp_encodings[mbmi->interp_filter[dir]]); + vp10_write_token( + w, vp10_switchable_interp_tree, cm->fc->switchable_interp_prob[ctx], + &switchable_interp_encodings[mbmi->interp_filter[dir]]); ++cpi->interp_filter_selected[0][mbmi->interp_filter[dir]]; } } @@ -1009,8 +994,7 @@ static void write_switchable_interp_filter(VP10_COMP *cpi, static void write_palette_mode_info(const VP10_COMMON *cm, const MACROBLOCKD *xd, - const MODE_INFO *const mi, - vp10_writer *w) { + const MODE_INFO *const mi, vp10_writer *w) { const MB_MODE_INFO *const mbmi = &mi->mbmi; const MODE_INFO *const above_mi = xd->above_mi; const MODE_INFO *const left_mi = xd->left_mi; @@ -1025,8 +1009,9 @@ static void write_palette_mode_info(const VP10_COMMON *cm, palette_ctx += (above_mi->mbmi.palette_mode_info.palette_size[0] > 0); if (left_mi) palette_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0); - vp10_write(w, n > 0, - vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx]); + vp10_write( + w, n > 0, + vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx]); if (n > 0) { vp10_write_token(w, vp10_palette_size_tree, vp10_default_palette_y_size_prob[bsize - BLOCK_8X8], @@ -1040,16 +1025,16 @@ static void write_palette_mode_info(const VP10_COMMON *cm, if (mbmi->uv_mode == DC_PRED) { n = pmi->palette_size[1]; vp10_write(w, n > 0, - vp10_default_palette_uv_mode_prob[pmi->palette_size[0] > 0]); + vp10_default_palette_uv_mode_prob[pmi->palette_size[0] > 0]); if (n > 0) { vp10_write_token(w, vp10_palette_size_tree, vp10_default_palette_uv_size_prob[bsize - BLOCK_8X8], &palette_size_encodings[n - 2]); for (i = 0; i < n; ++i) { vp10_write_literal(w, pmi->palette_colors[PALETTE_MAX_SIZE + i], - cm->bit_depth); + cm->bit_depth); vp10_write_literal(w, pmi->palette_colors[2 * PALETTE_MAX_SIZE + i], - cm->bit_depth); + cm->bit_depth); } write_uniform(w, n, pmi->palette_first_color_idx[1]); } @@ -1084,8 +1069,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, const int pred_flag = mbmi->seg_id_predicted; vpx_prob pred_prob = vp10_get_pred_prob_seg_id(segp, xd); vp10_write(w, pred_flag, pred_prob); - if (!pred_flag) - write_segment_id(w, seg, segp, segment_id); + if (!pred_flag) write_segment_id(w, seg, segp, segment_id); } else { write_segment_id(w, seg, segp, segment_id); } @@ -1116,7 +1100,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, const TX_SIZE max_tx_size = max_txsize_lookup[bsize]; const int txb_size = txsize_to_bsize[max_tx_size]; const int bs = num_4x4_blocks_wide_lookup[txb_size]; - const int width = num_4x4_blocks_wide_lookup[bsize]; + const int width = num_4x4_blocks_wide_lookup[bsize]; const int height = num_4x4_blocks_high_lookup[bsize]; int idx, idy; for (idy = 0; idy < height; idy += bs) @@ -1132,7 +1116,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, set_txfm_ctx(xd->left_txfm_context, mbmi->tx_size, xd->n8_h); set_txfm_ctx(xd->above_txfm_context, mbmi->tx_size, xd->n8_w); #else - write_selected_tx_size(cm, xd, w); + write_selected_tx_size(cm, xd, w); #endif } @@ -1157,8 +1141,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools) write_palette_mode_info(cm, xd, mi, w); #if CONFIG_EXT_INTRA - if (bsize >= BLOCK_8X8) - write_ext_intra_mode_info(cm, mbmi, w); + if (bsize >= BLOCK_8X8) write_ext_intra_mode_info(cm, mbmi, w); #endif // CONFIG_EXT_INTRA } else { int16_t mode_ctx = mbmi_ext->mode_context[mbmi->ref_frame[0]]; @@ -1170,8 +1153,8 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, mode_ctx = mbmi_ext->compound_mode_context[mbmi->ref_frame[0]]; else #endif // CONFIG_EXT_INTER - mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context, - mbmi->ref_frame, bsize, -1); + mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context, + mbmi->ref_frame, bsize, -1); #endif // If segment skip is not enabled code the mode. @@ -1182,11 +1165,11 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, write_inter_compound_mode(cm, w, mode, mode_ctx); else if (is_inter_singleref_mode(mode)) #endif // CONFIG_EXT_INTER - write_inter_mode(cm, w, mode, + write_inter_mode(cm, w, mode, #if CONFIG_REF_MV && CONFIG_EXT_INTER - is_compound, + is_compound, #endif // CONFIG_REF_MV && CONFIG_EXT_INTER - mode_ctx); + mode_ctx); #if CONFIG_REF_MV if (mode == NEARMV || mode == NEWMV) @@ -1219,11 +1202,11 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, write_inter_compound_mode(cm, w, b_mode, mode_ctx); else if (is_inter_singleref_mode(b_mode)) #endif // CONFIG_EXT_INTER - write_inter_mode(cm, w, b_mode, + write_inter_mode(cm, w, b_mode, #if CONFIG_REF_MV && CONFIG_EXT_INTER - has_second_ref(mbmi), + has_second_ref(mbmi), #endif // CONFIG_REF_MV && CONFIG_EXT_INTER - mode_ctx); + mode_ctx); #if CONFIG_EXT_INTER if (b_mode == NEWMV || b_mode == NEWFROMNEARMV || @@ -1246,8 +1229,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, #endif #else #if CONFIG_REF_MV - &mi->bmi[j].pred_mv_s8[ref].as_mv, - is_compound, + &mi->bmi[j].pred_mv_s8[ref].as_mv, is_compound, #else &mbmi_ext->ref_mvs[mbmi->ref_frame[ref]][0].as_mv, #endif // CONFIG_REF_MV @@ -1311,20 +1293,18 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, nmvc, allow_hp); else #endif // CONFIG_EXT_INTER - vp10_encode_mv(cpi, w, &mbmi->mv[ref].as_mv, - &ref_mv.as_mv, + vp10_encode_mv(cpi, w, &mbmi->mv[ref].as_mv, &ref_mv.as_mv, #if CONFIG_REF_MV - is_compound, + is_compound, #endif - nmvc, allow_hp); + nmvc, allow_hp); } #if CONFIG_EXT_INTER } else if (mode == NEAREST_NEWMV || mode == NEAR_NEWMV) { #if CONFIG_REF_MV - int nmv_ctx = - vp10_nmv_ctx(mbmi_ext->ref_mv_count[mbmi->ref_frame[1]], - mbmi_ext->ref_mv_stack[mbmi->ref_frame[1]]); - const nmv_context *nmvc = &cm->fc->nmvc[nmv_ctx]; + int nmv_ctx = vp10_nmv_ctx(mbmi_ext->ref_mv_count[mbmi->ref_frame[1]], + mbmi_ext->ref_mv_stack[mbmi->ref_frame[1]]); + const nmv_context *nmvc = &cm->fc->nmvc[nmv_ctx]; #endif vp10_encode_mv(cpi, w, &mbmi->mv[1].as_mv, &mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0].as_mv, @@ -1334,10 +1314,9 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, nmvc, allow_hp); } else if (mode == NEW_NEARESTMV || mode == NEW_NEARMV) { #if CONFIG_REF_MV - int nmv_ctx = - vp10_nmv_ctx(mbmi_ext->ref_mv_count[mbmi->ref_frame[0]], - mbmi_ext->ref_mv_stack[mbmi->ref_frame[0]]); - const nmv_context *nmvc = &cm->fc->nmvc[nmv_ctx]; + int nmv_ctx = vp10_nmv_ctx(mbmi_ext->ref_mv_count[mbmi->ref_frame[0]], + mbmi_ext->ref_mv_stack[mbmi->ref_frame[0]]); + const nmv_context *nmvc = &cm->fc->nmvc[nmv_ctx]; #endif vp10_encode_mv(cpi, w, &mbmi->mv[0].as_mv, &mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0].as_mv, @@ -1359,15 +1338,14 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, const int bsize_group = size_group_lookup[bsize]; vp10_write(w, interintra, cm->fc->interintra_prob[bsize_group]); if (interintra) { - write_interintra_mode( - w, mbmi->interintra_mode, - cm->fc->interintra_mode_prob[bsize_group]); + write_interintra_mode(w, mbmi->interintra_mode, + cm->fc->interintra_mode_prob[bsize_group]); if (is_interintra_wedge_used(bsize)) { vp10_write(w, mbmi->use_wedge_interintra, cm->fc->wedge_interintra_prob[bsize]); if (mbmi->use_wedge_interintra) { vp10_write_literal(w, mbmi->interintra_wedge_index, - get_wedge_bits_lookup(bsize)); + get_wedge_bits_lookup(bsize)); assert(mbmi->interintra_wedge_sign == 0); } } @@ -1382,14 +1360,14 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, #if CONFIG_EXT_INTER if (mbmi->ref_frame[1] != INTRA_FRAME) #endif // CONFIG_EXT_INTER - if (is_motvar_allowed(mbmi)) { - // TODO(debargha): Might want to only emit this if SEG_LVL_SKIP - // is not active, and assume SIMPLE_TRANSLATION in the decoder if - // it is active. - assert(mbmi->motion_variation < MOTION_VARIATIONS); - vp10_write_token(w, vp10_motvar_tree, cm->fc->motvar_prob[bsize], - &motvar_encodings[mbmi->motion_variation]); - } + if (is_motvar_allowed(mbmi)) { + // TODO(debargha): Might want to only emit this if SEG_LVL_SKIP + // is not active, and assume SIMPLE_TRANSLATION in the decoder if + // it is active. + assert(mbmi->motion_variation < MOTION_VARIATIONS); + vp10_write_token(w, vp10_motvar_tree, cm->fc->motvar_prob[bsize], + &motvar_encodings[mbmi->motion_variation]); + } #endif // CONFIG_OBMC || CONFIG_WARPED_MOTION #if CONFIG_EXT_INTER @@ -1415,57 +1393,55 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, #endif // CONFIG_EXT_INTERP } - if (!FIXED_TX_TYPE) { + if (!FIXED_TX_TYPE) { #if CONFIG_EXT_TX - if (get_ext_tx_types(mbmi->tx_size, bsize, is_inter) > 1 && - cm->base_qindex > 0 && !mbmi->skip && + if (get_ext_tx_types(mbmi->tx_size, bsize, is_inter) > 1 && + cm->base_qindex > 0 && !mbmi->skip && #if CONFIG_SUPERTX - !supertx_enabled && + !supertx_enabled && #endif // CONFIG_SUPERTX - !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { - int eset = get_ext_tx_set(mbmi->tx_size, bsize, is_inter); - if (is_inter) { - if (eset > 0) - vp10_write_token(w, vp10_ext_tx_inter_tree[eset], - cm->fc->inter_ext_tx_prob[eset][mbmi->tx_size], - &ext_tx_inter_encodings[eset][mbmi->tx_type]); - } else if (ALLOW_INTRA_EXT_TX) { - if (eset > 0) - vp10_write_token( - w, vp10_ext_tx_intra_tree[eset], - cm->fc->intra_ext_tx_prob[eset][mbmi->tx_size][mbmi->mode], - &ext_tx_intra_encodings[eset][mbmi->tx_type]); - } - } -#else - if (mbmi->tx_size < TX_32X32 && - cm->base_qindex > 0 && !mbmi->skip && -#if CONFIG_SUPERTX - !supertx_enabled && -#endif // CONFIG_SUPERTX - !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { - if (is_inter) { + !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { + int eset = get_ext_tx_set(mbmi->tx_size, bsize, is_inter); + if (is_inter) { + if (eset > 0) + vp10_write_token(w, vp10_ext_tx_inter_tree[eset], + cm->fc->inter_ext_tx_prob[eset][mbmi->tx_size], + &ext_tx_inter_encodings[eset][mbmi->tx_type]); + } else if (ALLOW_INTRA_EXT_TX) { + if (eset > 0) vp10_write_token( - w, vp10_ext_tx_tree, - cm->fc->inter_ext_tx_prob[mbmi->tx_size], - &ext_tx_encodings[mbmi->tx_type]); - } else { - vp10_write_token( - w, vp10_ext_tx_tree, - cm->fc->intra_ext_tx_prob[mbmi->tx_size] - [intra_mode_to_tx_type_context[mbmi->mode]], - &ext_tx_encodings[mbmi->tx_type]); - } - } else { - if (!mbmi->skip) { -#if CONFIG_SUPERTX - if (!supertx_enabled) -#endif // CONFIG_SUPERTX - assert(mbmi->tx_type == DCT_DCT); - } + w, vp10_ext_tx_intra_tree[eset], + cm->fc->intra_ext_tx_prob[eset][mbmi->tx_size][mbmi->mode], + &ext_tx_intra_encodings[eset][mbmi->tx_type]); } -#endif // CONFIG_EXT_TX } +#else + if (mbmi->tx_size < TX_32X32 && cm->base_qindex > 0 && !mbmi->skip && +#if CONFIG_SUPERTX + !supertx_enabled && +#endif // CONFIG_SUPERTX + !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { + if (is_inter) { + vp10_write_token(w, vp10_ext_tx_tree, + cm->fc->inter_ext_tx_prob[mbmi->tx_size], + &ext_tx_encodings[mbmi->tx_type]); + } else { + vp10_write_token( + w, vp10_ext_tx_tree, + cm->fc->intra_ext_tx_prob + [mbmi->tx_size][intra_mode_to_tx_type_context[mbmi->mode]], + &ext_tx_encodings[mbmi->tx_type]); + } + } else { + if (!mbmi->skip) { +#if CONFIG_SUPERTX + if (!supertx_enabled) +#endif // CONFIG_SUPERTX + assert(mbmi->tx_type == DCT_DCT); + } + } +#endif // CONFIG_EXT_TX + } } static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd, @@ -1478,8 +1454,7 @@ static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd, const MB_MODE_INFO *const mbmi = &mi->mbmi; const BLOCK_SIZE bsize = mbmi->sb_type; - if (seg->update_map) - write_segment_id(w, seg, segp, mbmi->segment_id); + if (seg->update_map) write_segment_id(w, seg, segp, mbmi->segment_id); write_skip(cm, xd, mbmi->segment_id, mi, w); @@ -1511,14 +1486,13 @@ static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd, if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools) write_palette_mode_info(cm, xd, mi, w); #if CONFIG_EXT_INTRA - if (bsize >= BLOCK_8X8) - write_ext_intra_mode_info(cm, mbmi, w); + if (bsize >= BLOCK_8X8) write_ext_intra_mode_info(cm, mbmi, w); #endif // CONFIG_EXT_INTRA if (!FIXED_TX_TYPE) { #if CONFIG_EXT_TX - if (get_ext_tx_types(mbmi->tx_size, bsize, 0) > 1 && - cm->base_qindex > 0 && !mbmi->skip && + if (get_ext_tx_types(mbmi->tx_size, bsize, 0) > 1 && cm->base_qindex > 0 && + !mbmi->skip && !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP) && ALLOW_INTRA_EXT_TX) { int eset = get_ext_tx_set(mbmi->tx_size, bsize, 0); @@ -1529,32 +1503,30 @@ static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd, &ext_tx_intra_encodings[eset][mbmi->tx_type]); } #else - if (mbmi->tx_size < TX_32X32 && - cm->base_qindex > 0 && !mbmi->skip && + if (mbmi->tx_size < TX_32X32 && cm->base_qindex > 0 && !mbmi->skip && !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { vp10_write_token( w, vp10_ext_tx_tree, cm->fc->intra_ext_tx_prob[mbmi->tx_size] - [intra_mode_to_tx_type_context[mbmi->mode]], - &ext_tx_encodings[mbmi->tx_type]); + [intra_mode_to_tx_type_context[mbmi->mode]], + &ext_tx_encodings[mbmi->tx_type]); } #endif // CONFIG_EXT_TX } } #if CONFIG_SUPERTX -#define write_modes_b_wrapper(cpi, tile, w, tok, tok_end, \ - supertx_enabled, mi_row, mi_col) \ +#define write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, \ + mi_row, mi_col) \ write_modes_b(cpi, tile, w, tok, tok_end, supertx_enabled, mi_row, mi_col) #else -#define write_modes_b_wrapper(cpi, tile, w, tok, tok_end, \ - supertx_enabled, mi_row, mi_col) \ +#define write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, \ + mi_row, mi_col) \ write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col) #endif // CONFIG_ANS && CONFIG_SUPERTX static void write_modes_b(VP10_COMP *cpi, const TileInfo *const tile, - vp10_writer *w, - const TOKENEXTRA **tok, + vp10_writer *w, const TOKENEXTRA **tok, const TOKENEXTRA *const tok_end, #if CONFIG_SUPERTX int supertx_enabled, @@ -1566,9 +1538,9 @@ static void write_modes_b(VP10_COMP *cpi, const TileInfo *const tile, int plane; int bh, bw; #if CONFIG_ANS - (void) tok; - (void) tok_end; - (void) plane; + (void)tok; + (void)tok_end; + (void)plane; #endif // !CONFIG_ANS xd->mi = cm->mi_grid_visible + (mi_row * cm->mi_stride + mi_col); @@ -1588,7 +1560,7 @@ static void write_modes_b(VP10_COMP *cpi, const TileInfo *const tile, #if CONFIG_VAR_TX xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); #endif #if CONFIG_EXT_INTERP // vp10_is_interp_needed needs the ref frame buffers set up to look @@ -1630,9 +1602,9 @@ static void write_modes_b(VP10_COMP *cpi, const TileInfo *const tile, for (plane = 0; plane <= 1; ++plane) { if (m->mbmi.palette_mode_info.palette_size[plane] > 0) { const int rows = (4 * num_4x4_blocks_high_lookup[m->mbmi.sb_type]) >> - (xd->plane[plane].subsampling_y); + (xd->plane[plane].subsampling_y); const int cols = (4 * num_4x4_blocks_wide_lookup[m->mbmi.sb_type]) >> - (xd->plane[plane].subsampling_x); + (xd->plane[plane].subsampling_x); assert(*tok < tok_end); pack_palette_tokens(w, tok, m->mbmi.palette_mode_info.palette_size[plane], rows * cols - 1); @@ -1682,8 +1654,8 @@ static void write_modes_b(VP10_COMP *cpi, const TileInfo *const tile, pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx); } #else - TX_SIZE tx = plane ? get_uv_tx_size(&m->mbmi, &xd->plane[plane]) - : m->mbmi.tx_size; + TX_SIZE tx = + plane ? get_uv_tx_size(&m->mbmi, &xd->plane[plane]) : m->mbmi.tx_size; pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx); #endif // CONFIG_VAR_TX assert(*tok < tok_end && (*tok)->token == EOSB_TOKEN); @@ -1693,9 +1665,8 @@ static void write_modes_b(VP10_COMP *cpi, const TileInfo *const tile, } static void write_partition(const VP10_COMMON *const cm, - const MACROBLOCKD *const xd, - int hbs, int mi_row, int mi_col, - PARTITION_TYPE p, BLOCK_SIZE bsize, + const MACROBLOCKD *const xd, int hbs, int mi_row, + int mi_col, PARTITION_TYPE p, BLOCK_SIZE bsize, vp10_writer *w) { const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize); const vpx_prob *const probs = cm->fc->partition_prob[ctx]; @@ -1708,7 +1679,7 @@ static void write_partition(const VP10_COMMON *const cm, vp10_write_token(w, vp10_partition_tree, probs, &partition_encodings[p]); else vp10_write_token(w, vp10_ext_partition_tree, probs, - &ext_partition_encodings[p]); + &ext_partition_encodings[p]); #else vp10_write_token(w, vp10_partition_tree, probs, &partition_encodings[p]); #endif // CONFIG_EXT_PARTITION_TYPES @@ -1724,20 +1695,18 @@ static void write_partition(const VP10_COMMON *const cm, } #if CONFIG_SUPERTX -#define write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, \ - supertx_enabled, mi_row, mi_col, bsize) \ +#define write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, \ + mi_row, mi_col, bsize) \ write_modes_sb(cpi, tile, w, tok, tok_end, supertx_enabled, mi_row, mi_col, \ bsize) #else -#define write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, \ - supertx_enabled, mi_row, mi_col, bsize) \ +#define write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, \ + mi_row, mi_col, bsize) \ write_modes_sb(cpi, tile, w, tok, tok_end, mi_row, mi_col, bsize) #endif // CONFIG_ANS && CONFIG_SUPERTX -static void write_modes_sb(VP10_COMP *const cpi, - const TileInfo *const tile, - vp10_writer *const w, - const TOKENEXTRA **tok, +static void write_modes_sb(VP10_COMP *const cpi, const TileInfo *const tile, + vp10_writer *const w, const TOKENEXTRA **tok, const TOKENEXTRA *const tok_end, #if CONFIG_SUPERTX int supertx_enabled, @@ -1747,7 +1716,7 @@ static void write_modes_sb(VP10_COMP *const cpi, MACROBLOCKD *const xd = &cpi->td.mb.e_mbd; const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2; const PARTITION_TYPE partition = get_partition(cm, mi_row, mi_col, bsize); - const BLOCK_SIZE subsize = get_subsize(bsize, partition); + const BLOCK_SIZE subsize = get_subsize(bsize, partition); #if CONFIG_SUPERTX const int mi_offset = mi_row * cm->mi_stride + mi_col; MB_MODE_INFO *mbmi; @@ -1756,19 +1725,15 @@ static void write_modes_sb(VP10_COMP *const cpi, int plane; #endif - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return; + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; write_partition(cm, xd, hbs, mi_row, mi_col, partition, bsize, w); #if CONFIG_SUPERTX mbmi = &cm->mi_grid_visible[mi_offset]->mbmi; xd->mi = cm->mi_grid_visible + mi_offset; - set_mi_row_col(xd, tile, - mi_row, num_8x8_blocks_high_lookup[bsize], - mi_col, num_8x8_blocks_wide_lookup[bsize], - cm->mi_rows, cm->mi_cols); - if (!supertx_enabled && - !frame_is_intra_only(cm) && + set_mi_row_col(xd, tile, mi_row, num_8x8_blocks_high_lookup[bsize], mi_col, + num_8x8_blocks_wide_lookup[bsize], cm->mi_rows, cm->mi_cols); + if (!supertx_enabled && !frame_is_intra_only(cm) && partition != PARTITION_NONE && bsize <= MAX_SUPERTX_BLOCK_SIZE && !xd->lossless[0]) { vpx_prob prob; @@ -1780,8 +1745,8 @@ static void write_modes_sb(VP10_COMP *const cpi, } #endif // CONFIG_SUPERTX if (subsize < BLOCK_8X8) { - write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row, mi_col); + write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, mi_row, + mi_col); } else { switch (partition) { case PARTITION_NONE: @@ -1792,15 +1757,15 @@ static void write_modes_sb(VP10_COMP *const cpi, write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, mi_row, mi_col); if (mi_row + hbs < cm->mi_rows) - write_modes_b_wrapper(cpi, tile, w, tok, tok_end, - supertx_enabled, mi_row + hbs, mi_col); + write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, + mi_row + hbs, mi_col); break; case PARTITION_VERT: write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, mi_row, mi_col); if (mi_col + hbs < cm->mi_cols) - write_modes_b_wrapper(cpi, tile, w, tok, tok_end, - supertx_enabled, mi_row, mi_col + hbs); + write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, + mi_row, mi_col + hbs); break; case PARTITION_SPLIT: write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, @@ -1815,39 +1780,38 @@ static void write_modes_sb(VP10_COMP *const cpi, #if CONFIG_EXT_PARTITION_TYPES case PARTITION_HORZ_A: write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row, mi_col); + mi_row, mi_col); write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row, mi_col + hbs); + mi_row, mi_col + hbs); write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row + hbs, mi_col); + mi_row + hbs, mi_col); break; case PARTITION_HORZ_B: write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row, mi_col); + mi_row, mi_col); write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row + hbs, mi_col); + mi_row + hbs, mi_col); write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row + hbs, mi_col + hbs); + mi_row + hbs, mi_col + hbs); break; case PARTITION_VERT_A: write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row, mi_col); + mi_row, mi_col); write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row + hbs, mi_col); + mi_row + hbs, mi_col); write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row, mi_col + hbs); + mi_row, mi_col + hbs); break; case PARTITION_VERT_B: write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row, mi_col); + mi_row, mi_col); write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row, mi_col + hbs); + mi_row, mi_col + hbs); write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled, - mi_row + hbs, mi_col + hbs); + mi_row + hbs, mi_col + hbs); break; #endif // CONFIG_EXT_PARTITION_TYPES - default: - assert(0); + default: assert(0); } } #if CONFIG_SUPERTX @@ -1855,10 +1819,8 @@ static void write_modes_sb(VP10_COMP *const cpi, int skip; xd->mi = cm->mi_grid_visible + mi_offset; supertx_size = mbmi->tx_size; - set_mi_row_col(xd, tile, - mi_row, num_8x8_blocks_high_lookup[bsize], - mi_col, num_8x8_blocks_wide_lookup[bsize], - cm->mi_rows, cm->mi_cols); + set_mi_row_col(xd, tile, mi_row, num_8x8_blocks_high_lookup[bsize], mi_col, + num_8x8_blocks_wide_lookup[bsize], cm->mi_rows, cm->mi_cols); assert(IMPLIES(!cm->seg.enabled, mbmi->segment_id_supertx == 0)); assert(mbmi->segment_id_supertx < MAX_SEGMENTS); @@ -1868,18 +1830,16 @@ static void write_modes_sb(VP10_COMP *const cpi, if (get_ext_tx_types(supertx_size, bsize, 1) > 1 && !skip) { int eset = get_ext_tx_set(supertx_size, bsize, 1); if (eset > 0) { - vp10_write_token( - w, vp10_ext_tx_inter_tree[eset], - cm->fc->inter_ext_tx_prob[eset][supertx_size], - &ext_tx_inter_encodings[eset][mbmi->tx_type]); + vp10_write_token(w, vp10_ext_tx_inter_tree[eset], + cm->fc->inter_ext_tx_prob[eset][supertx_size], + &ext_tx_inter_encodings[eset][mbmi->tx_type]); } } #else if (supertx_size < TX_32X32 && !skip) { - vp10_write_token( - w, vp10_ext_tx_tree, - cm->fc->inter_ext_tx_prob[supertx_size], - &ext_tx_encodings[mbmi->tx_type]); + vp10_write_token(w, vp10_ext_tx_tree, + cm->fc->inter_ext_tx_prob[supertx_size], + &ext_tx_encodings[mbmi->tx_type]); } #endif // CONFIG_EXT_TX @@ -1890,8 +1850,8 @@ static void write_modes_sb(VP10_COMP *const cpi, const int num_4x4_w = num_4x4_blocks_wide_lookup[mbmi_txb_size]; const int num_4x4_h = num_4x4_blocks_high_lookup[mbmi_txb_size]; int row, col; - TX_SIZE tx = plane ? get_uv_tx_size(mbmi, &xd->plane[plane]) - : mbmi->tx_size; + TX_SIZE tx = + plane ? get_uv_tx_size(mbmi, &xd->plane[plane]) : mbmi->tx_size; BLOCK_SIZE txb_size = txsize_to_bsize[tx]; int bw = num_4x4_blocks_wide_lookup[txb_size]; @@ -1905,7 +1865,7 @@ static void write_modes_sb(VP10_COMP *const cpi, } #endif // CONFIG_SUPERTX - // update partition context +// update partition context #if CONFIG_EXT_PARTITION_TYPES update_ext_partition_context(xd, mi_row, mi_col, subsize, bsize, partition); #else @@ -1915,10 +1875,8 @@ static void write_modes_sb(VP10_COMP *const cpi, #endif // CONFIG_EXT_PARTITION_TYPES } -static void write_modes(VP10_COMP *const cpi, - const TileInfo *const tile, - vp10_writer *const w, - const TOKENEXTRA **tok, +static void write_modes(VP10_COMP *const cpi, const TileInfo *const tile, + vp10_writer *const w, const TOKENEXTRA **tok, const TOKENEXTRA *const tok_end) { VP10_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &cpi->td.mb.e_mbd; @@ -1934,8 +1892,8 @@ static void write_modes(VP10_COMP *const cpi, vp10_zero_left_context(xd); for (mi_col = mi_col_start; mi_col < mi_col_end; mi_col += cm->mib_size) { - write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, 0, - mi_row, mi_col, cm->sb_size); + write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, 0, mi_row, mi_col, + cm->sb_size); } } } @@ -1944,7 +1902,7 @@ static void build_tree_distribution(VP10_COMP *cpi, TX_SIZE tx_size, vp10_coeff_stats *coef_branch_ct, vp10_coeff_probs_model *coef_probs) { vp10_coeff_count *coef_counts = cpi->td.rd_counts.coef_counts[tx_size]; - unsigned int (*eob_branch_ct)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] = + unsigned int(*eob_branch_ct)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] = cpi->common.counts.eob_branch[tx_size]; int i, j, k, l, m; @@ -1953,21 +1911,21 @@ static void build_tree_distribution(VP10_COMP *cpi, TX_SIZE tx_size, for (k = 0; k < COEF_BANDS; ++k) { for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) { vp10_tree_probs_from_distribution(vp10_coef_tree, - coef_branch_ct[i][j][k][l], - coef_counts[i][j][k][l]); - coef_branch_ct[i][j][k][l][0][1] = eob_branch_ct[i][j][k][l] - - coef_branch_ct[i][j][k][l][0][0]; + coef_branch_ct[i][j][k][l], + coef_counts[i][j][k][l]); + coef_branch_ct[i][j][k][l][0][1] = + eob_branch_ct[i][j][k][l] - coef_branch_ct[i][j][k][l][0][0]; for (m = 0; m < UNCONSTRAINED_NODES; ++m) - coef_probs[i][j][k][l][m] = get_binary_prob( - coef_branch_ct[i][j][k][l][m][0], - coef_branch_ct[i][j][k][l][m][1]); + coef_probs[i][j][k][l][m] = + get_binary_prob(coef_branch_ct[i][j][k][l][m][0], + coef_branch_ct[i][j][k][l][m][1]); } } } } } -static void update_coef_probs_common(vp10_writer* const bc, VP10_COMP *cpi, +static void update_coef_probs_common(vp10_writer *const bc, VP10_COMP *cpi, TX_SIZE tx_size, vp10_coeff_stats *frame_branch_ct, vp10_coeff_probs_model *new_coef_probs) { @@ -1981,7 +1939,7 @@ static void update_coef_probs_common(vp10_writer* const bc, VP10_COMP *cpi, case TWO_LOOP: { /* dry run to see if there is any update at all needed */ int savings = 0; - int update[2] = {0, 0}; + int update[2] = { 0, 0 }; for (i = 0; i < PLANE_TYPES; ++i) { for (j = 0; j < REF_TYPES; ++j) { for (k = 0; k < COEF_BANDS; ++k) { @@ -1998,8 +1956,7 @@ static void update_coef_probs_common(vp10_writer* const bc, VP10_COMP *cpi, else s = vp10_prob_diff_update_savings_search( frame_branch_ct[i][j][k][l][t], oldp, &newp, upd); - if (s > 0 && newp != oldp) - u = 1; + if (s > 0 && newp != oldp) u = 1; if (u) savings += s - (int)(vp10_cost_zero(upd)); else @@ -2034,10 +1991,8 @@ static void update_coef_probs_common(vp10_writer* const bc, VP10_COMP *cpi, old_coef_probs[i][j][k][l], &newp, upd, stepsize); else s = vp10_prob_diff_update_savings_search( - frame_branch_ct[i][j][k][l][t], - *oldp, &newp, upd); - if (s > 0 && newp != *oldp) - u = 1; + frame_branch_ct[i][j][k][l][t], *oldp, &newp, upd); + if (s > 0 && newp != *oldp) u = 1; vp10_write(bc, u, upd); if (u) { /* send/use new probability */ @@ -2072,12 +2027,10 @@ static void update_coef_probs_common(vp10_writer* const bc, VP10_COMP *cpi, old_coef_probs[i][j][k][l], &newp, upd, stepsize); } else { s = vp10_prob_diff_update_savings_search( - frame_branch_ct[i][j][k][l][t], - *oldp, &newp, upd); + frame_branch_ct[i][j][k][l][t], *oldp, &newp, upd); } - if (s > 0 && newp != *oldp) - u = 1; + if (s > 0 && newp != *oldp) u = 1; updates += u; if (u == 0 && updates == 0) { noupdates_before_first++; @@ -2106,19 +2059,17 @@ static void update_coef_probs_common(vp10_writer* const bc, VP10_COMP *cpi, } return; } - default: - assert(0); + default: assert(0); } } #if CONFIG_ENTROPY // Calculate the token counts between subsequent subframe updates. -static void get_coef_counts_diff(VP10_COMP *cpi, int index, - vp10_coeff_count - coef_counts[TX_SIZES][PLANE_TYPES], - unsigned int eob_counts[TX_SIZES] - [PLANE_TYPES][REF_TYPES][COEF_BANDS] - [COEFF_CONTEXTS]) { +static void get_coef_counts_diff( + VP10_COMP *cpi, int index, + vp10_coeff_count coef_counts[TX_SIZES][PLANE_TYPES], + unsigned int eob_counts[TX_SIZES][PLANE_TYPES][REF_TYPES][COEF_BANDS] + [COEFF_CONTEXTS]) { int i, j, k, l, m, tx_size, val; const int max_idx = cpi->common.coef_probs_update_idx; const TX_MODE tx_mode = cpi->common.tx_mode; @@ -2133,12 +2084,13 @@ static void get_coef_counts_diff(VP10_COMP *cpi, int index, for (k = 0; k < COEF_BANDS; ++k) for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) { if (index == max_idx) { - val = cpi->common.counts.eob_branch[tx_size][i][j][k][l] - + val = + cpi->common.counts.eob_branch[tx_size][i][j][k][l] - subframe_stats->eob_counts_buf[max_idx][tx_size][i][j][k][l]; } else { - val = subframe_stats->eob_counts_buf[index + 1][tx_size] - [i][j][k][l] - - subframe_stats->eob_counts_buf[index][tx_size][i][j][k][l]; + val = subframe_stats + ->eob_counts_buf[index + 1][tx_size][i][j][k][l] - + subframe_stats->eob_counts_buf[index][tx_size][i][j][k][l]; } assert(val >= 0); eob_counts[tx_size][i][j][k][l] = val; @@ -2146,13 +2098,13 @@ static void get_coef_counts_diff(VP10_COMP *cpi, int index, for (m = 0; m < ENTROPY_TOKENS; ++m) { if (index == max_idx) { val = cpi->td.rd_counts.coef_counts[tx_size][i][j][k][l][m] - - subframe_stats->coef_counts_buf[max_idx][tx_size] - [i][j][k][l][m]; + subframe_stats + ->coef_counts_buf[max_idx][tx_size][i][j][k][l][m]; } else { - val = subframe_stats->coef_counts_buf[index + 1] - [tx_size][i][j][k][l][m] - - subframe_stats->coef_counts_buf[index][tx_size] - [i][j][k][l][m]; + val = subframe_stats + ->coef_counts_buf[index + 1][tx_size][i][j][k][l][m] - + subframe_stats + ->coef_counts_buf[index][tx_size][i][j][k][l][m]; } assert(val >= 0); coef_counts[tx_size][i][j][k][l][m] = val; @@ -2160,12 +2112,10 @@ static void get_coef_counts_diff(VP10_COMP *cpi, int index, } } -static void update_coef_probs_subframe(vp10_writer* const bc, VP10_COMP *cpi, - TX_SIZE tx_size, - vp10_coeff_stats - branch_ct[COEF_PROBS_BUFS][TX_SIZES] - [PLANE_TYPES], - vp10_coeff_probs_model *new_coef_probs) { +static void update_coef_probs_subframe( + vp10_writer *const bc, VP10_COMP *cpi, TX_SIZE tx_size, + vp10_coeff_stats branch_ct[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES], + vp10_coeff_probs_model *new_coef_probs) { vp10_coeff_probs_model *old_coef_probs = cpi->common.fc->coef_probs[tx_size]; const vpx_prob upd = DIFF_UPDATE_PROB; const int entropy_nodes_update = UNCONSTRAINED_NODES; @@ -2179,7 +2129,7 @@ static void update_coef_probs_subframe(vp10_writer* const bc, VP10_COMP *cpi, case TWO_LOOP: { /* dry run to see if there is any update at all needed */ int savings = 0; - int update[2] = {0, 0}; + int update[2] = { 0, 0 }; for (i = 0; i < PLANE_TYPES; ++i) { for (j = 0; j < REF_TYPES; ++j) { for (k = 0; k < COEF_BANDS; ++k) { @@ -2197,15 +2147,13 @@ static void update_coef_probs_subframe(vp10_writer* const bc, VP10_COMP *cpi, int s, u = 0; if (t == PIVOT_NODE) - s = vp10_prob_update_search_model_subframe(this_branch_ct, - old_coef_probs[i][j][k][l], &newp, upd, - stepsize, max_idx); + s = vp10_prob_update_search_model_subframe( + this_branch_ct, old_coef_probs[i][j][k][l], &newp, upd, + stepsize, max_idx); else - s = vp10_prob_update_search_subframe(this_branch_ct[t], - oldp, &newp, upd, - max_idx); - if (s > 0 && newp != oldp) - u = 1; + s = vp10_prob_update_search_subframe(this_branch_ct[t], oldp, + &newp, upd, max_idx); + if (s > 0 && newp != oldp) u = 1; if (u) savings += s - (int)(vp10_cost_zero(upd)); else @@ -2242,15 +2190,13 @@ static void update_coef_probs_subframe(vp10_writer* const bc, VP10_COMP *cpi, int u = 0; if (t == PIVOT_NODE) - s = vp10_prob_update_search_model_subframe(this_branch_ct, - old_coef_probs[i][j][k][l], &newp, upd, - stepsize, max_idx); + s = vp10_prob_update_search_model_subframe( + this_branch_ct, old_coef_probs[i][j][k][l], &newp, upd, + stepsize, max_idx); else - s = vp10_prob_update_search_subframe(this_branch_ct[t], - *oldp, &newp, upd, - max_idx); - if (s > 0 && newp != *oldp) - u = 1; + s = vp10_prob_update_search_subframe(this_branch_ct[t], *oldp, + &newp, upd, max_idx); + if (s > 0 && newp != *oldp) u = 1; vp10_write(bc, u, upd); if (u) { /* send/use new probability */ @@ -2286,15 +2232,13 @@ static void update_coef_probs_subframe(vp10_writer* const bc, VP10_COMP *cpi, int u = 0; if (t == PIVOT_NODE) - s = vp10_prob_update_search_model_subframe(this_branch_ct, - old_coef_probs[i][j][k][l], &newp, upd, - stepsize, max_idx); + s = vp10_prob_update_search_model_subframe( + this_branch_ct, old_coef_probs[i][j][k][l], &newp, upd, + stepsize, max_idx); else - s = vp10_prob_update_search_subframe(this_branch_ct[t], - *oldp, &newp, upd, - max_idx); - if (s > 0 && newp != *oldp) - u = 1; + s = vp10_prob_update_search_subframe(this_branch_ct[t], *oldp, + &newp, upd, max_idx); + if (s > 0 && newp != *oldp) u = 1; updates += u; if (u == 0 && updates == 0) { noupdates_before_first++; @@ -2323,13 +2267,12 @@ static void update_coef_probs_subframe(vp10_writer* const bc, VP10_COMP *cpi, } return; } - default: - assert(0); + default: assert(0); } } #endif // CONFIG_ENTROPY -static void update_coef_probs(VP10_COMP *cpi, vp10_writer* w) { +static void update_coef_probs(VP10_COMP *cpi, vp10_writer *w) { const TX_MODE tx_mode = cpi->common.tx_mode; const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode]; TX_SIZE tx_size; @@ -2339,8 +2282,8 @@ static void update_coef_probs(VP10_COMP *cpi, vp10_writer* w) { #if CONFIG_ENTROPY VP10_COMMON *cm = &cpi->common; SUBFRAME_STATS *subframe_stats = &cpi->subframe_stats; - unsigned int eob_counts_copy[TX_SIZES][PLANE_TYPES][REF_TYPES] - [COEF_BANDS][COEFF_CONTEXTS]; + unsigned int eob_counts_copy[TX_SIZES][PLANE_TYPES][REF_TYPES][COEF_BANDS] + [COEFF_CONTEXTS]; int i; vp10_coeff_probs_model dummy_frame_coef_probs[PLANE_TYPES]; @@ -2349,8 +2292,7 @@ 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, - cpi->wholeframe_stats.coef_counts_buf[i], + get_coef_counts_diff(cpi, i, cpi->wholeframe_stats.coef_counts_buf[i], cpi->wholeframe_stats.eob_counts_buf[i]); } } @@ -2366,8 +2308,8 @@ static void update_coef_probs(VP10_COMP *cpi, vp10_writer* w) { #if CONFIG_ENTROPY if (cm->do_subframe_update && cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) { - unsigned int eob_counts_copy[PLANE_TYPES][REF_TYPES] - [COEF_BANDS][COEFF_CONTEXTS]; + unsigned int + eob_counts_copy[PLANE_TYPES][REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]; vp10_coeff_count coef_counts_copy[PLANE_TYPES]; vp10_copy(eob_counts_copy, cpi->common.counts.eob_branch[tx_size]); vp10_copy(coef_counts_copy, cpi->td.rd_counts.coef_counts[tx_size]); @@ -2378,8 +2320,7 @@ static void update_coef_probs(VP10_COMP *cpi, vp10_writer* w) { cpi->wholeframe_stats.eob_counts_buf[i][tx_size]); vp10_copy(cpi->td.rd_counts.coef_counts[tx_size], cpi->wholeframe_stats.coef_counts_buf[i][tx_size]); - build_tree_distribution(cpi, tx_size, - cpi->branch_ct_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); @@ -2440,18 +2381,18 @@ static void encode_restoration(VP10_COMMON *cm, vp10_restoration_level_bits(cm)); } else { vpx_wb_write_bit(wb, 0); - vpx_wb_write_literal( - wb, rst->vfilter[0] - WIENER_FILT_TAP0_MINV, WIENER_FILT_TAP0_BITS); - vpx_wb_write_literal( - wb, rst->vfilter[1] - WIENER_FILT_TAP1_MINV, WIENER_FILT_TAP1_BITS); - vpx_wb_write_literal( - wb, rst->vfilter[2] - WIENER_FILT_TAP2_MINV, WIENER_FILT_TAP2_BITS); - vpx_wb_write_literal( - wb, rst->hfilter[0] - WIENER_FILT_TAP0_MINV, WIENER_FILT_TAP0_BITS); - vpx_wb_write_literal( - wb, rst->hfilter[1] - WIENER_FILT_TAP1_MINV, WIENER_FILT_TAP1_BITS); - vpx_wb_write_literal( - wb, rst->hfilter[2] - WIENER_FILT_TAP2_MINV, WIENER_FILT_TAP2_BITS); + vpx_wb_write_literal(wb, rst->vfilter[0] - WIENER_FILT_TAP0_MINV, + WIENER_FILT_TAP0_BITS); + vpx_wb_write_literal(wb, rst->vfilter[1] - WIENER_FILT_TAP1_MINV, + WIENER_FILT_TAP1_BITS); + vpx_wb_write_literal(wb, rst->vfilter[2] - WIENER_FILT_TAP2_MINV, + WIENER_FILT_TAP2_BITS); + vpx_wb_write_literal(wb, rst->hfilter[0] - WIENER_FILT_TAP0_MINV, + WIENER_FILT_TAP0_BITS); + vpx_wb_write_literal(wb, rst->hfilter[1] - WIENER_FILT_TAP1_MINV, + WIENER_FILT_TAP1_BITS); + vpx_wb_write_literal(wb, rst->hfilter[2] - WIENER_FILT_TAP2_MINV, + WIENER_FILT_TAP2_BITS); } } } @@ -2519,8 +2460,7 @@ static void encode_segmentation(VP10_COMMON *cm, MACROBLOCKD *xd, const struct segmentation *seg = &cm->seg; vpx_wb_write_bit(wb, seg->enabled); - if (!seg->enabled) - return; + if (!seg->enabled) return; // Segmentation map if (!frame_is_intra_only(cm) && !cm->error_resilient_mode) { @@ -2568,39 +2508,35 @@ static void encode_segmentation(VP10_COMMON *cm, MACROBLOCKD *xd, static void update_seg_probs(VP10_COMP *cpi, vp10_writer *w) { VP10_COMMON *cm = &cpi->common; - if (!cpi->common.seg.enabled) - return; + if (!cpi->common.seg.enabled) return; if (cpi->common.seg.temporal_update) { int i; for (i = 0; i < PREDICTION_PROBS; i++) vp10_cond_prob_diff_update(w, &cm->fc->seg.pred_probs[i], - cm->counts.seg.pred[i]); + cm->counts.seg.pred[i]); prob_diff_update(vp10_segment_tree, cm->fc->seg.tree_probs, - cm->counts.seg.tree_mispred, MAX_SEGMENTS, w); + cm->counts.seg.tree_mispred, MAX_SEGMENTS, w); } else { prob_diff_update(vp10_segment_tree, cm->fc->seg.tree_probs, - cm->counts.seg.tree_total, MAX_SEGMENTS, w); + cm->counts.seg.tree_total, MAX_SEGMENTS, w); } } static void write_txfm_mode(TX_MODE mode, struct vpx_write_bit_buffer *wb) { vpx_wb_write_bit(wb, mode == TX_MODE_SELECT); - if (mode != TX_MODE_SELECT) - vpx_wb_write_literal(wb, mode, 2); + if (mode != TX_MODE_SELECT) vpx_wb_write_literal(wb, mode, 2); } - static void update_txfm_probs(VP10_COMMON *cm, vp10_writer *w, FRAME_COUNTS *counts) { if (cm->tx_mode == TX_MODE_SELECT) { int i, j; for (i = 0; i < TX_SIZES - 1; ++i) for (j = 0; j < TX_SIZE_CONTEXTS; ++j) - prob_diff_update(vp10_tx_size_tree[i], - cm->fc->tx_size_probs[i][j], + prob_diff_update(vp10_tx_size_tree[i], cm->fc->tx_size_probs[i][j], counts->tx_size[i][j], i + 2, w); } } @@ -2638,15 +2574,17 @@ static void fix_interp_filter(VP10_COMMON *cm, FRAME_COUNTS *counts) { static void write_tile_info(const VP10_COMMON *const cm, struct vpx_write_bit_buffer *wb) { #if CONFIG_EXT_TILE - const int tile_width = - ALIGN_POWER_OF_TWO(cm->tile_width, cm->mib_size_log2) >> cm->mib_size_log2; + const int tile_width = + ALIGN_POWER_OF_TWO(cm->tile_width, cm->mib_size_log2) >> + cm->mib_size_log2; const int tile_height = - ALIGN_POWER_OF_TWO(cm->tile_height, cm->mib_size_log2) >> cm->mib_size_log2; + ALIGN_POWER_OF_TWO(cm->tile_height, cm->mib_size_log2) >> + cm->mib_size_log2; assert(tile_width > 0); assert(tile_height > 0); - // Write the tile sizes +// Write the tile sizes #if CONFIG_EXT_PARTITION if (cm->sb_size == BLOCK_128X128) { assert(tile_width <= 32); @@ -2667,16 +2605,13 @@ static void write_tile_info(const VP10_COMMON *const cm, // columns ones = cm->log2_tile_cols - min_log2_tile_cols; - while (ones--) - vpx_wb_write_bit(wb, 1); + while (ones--) vpx_wb_write_bit(wb, 1); - if (cm->log2_tile_cols < max_log2_tile_cols) - vpx_wb_write_bit(wb, 0); + if (cm->log2_tile_cols < max_log2_tile_cols) vpx_wb_write_bit(wb, 0); // rows vpx_wb_write_bit(wb, cm->log2_tile_rows != 0); - if (cm->log2_tile_rows != 0) - vpx_wb_write_bit(wb, cm->log2_tile_rows != 1); + if (cm->log2_tile_rows != 0) vpx_wb_write_bit(wb, cm->log2_tile_rows != 1); #endif // CONFIG_EXT_TILE } static int get_refresh_mask(VP10_COMP *cpi) { @@ -2717,8 +2652,7 @@ static int get_refresh_mask(VP10_COMP *cpi) { const GF_GROUP *const gf_group = &cpi->twopass.gf_group; arf_idx = gf_group->arf_update_idx[gf_group->index]; } - return refresh_mask | - (cpi->refresh_golden_frame << cpi->gld_fb_idx) | + return refresh_mask | (cpi->refresh_golden_frame << cpi->gld_fb_idx) | (cpi->refresh_alt_ref_frame << arf_idx); } } @@ -2727,15 +2661,14 @@ static int get_refresh_mask(VP10_COMP *cpi) { static INLINE int find_identical_tile( const int tile_row, const int tile_col, TileBufferEnc (*const tile_buffers)[1024]) { - const MV32 candidate_offset[1] = {{1, 0}}; + const MV32 candidate_offset[1] = { { 1, 0 } }; const uint8_t *const cur_tile_data = tile_buffers[tile_row][tile_col].data + 4; const unsigned int cur_tile_size = tile_buffers[tile_row][tile_col].size; int i; - if (tile_row == 0) - return 0; + if (tile_row == 0) return 0; // (TODO: yunqingwang) For now, only above tile is checked and used. // More candidates such as left tile can be added later. @@ -2748,8 +2681,7 @@ static INLINE int find_identical_tile( const uint8_t *tile_data; TileBufferEnc *candidate; - if (row < 0 || col < 0) - continue; + if (row < 0 || col < 0) continue; tile_hdr = *(tile_buffers[row][col].data); @@ -2762,13 +2694,11 @@ static INLINE int find_identical_tile( candidate = &tile_buffers[row][col]; - if (row_offset >= 128 || candidate->size != cur_tile_size) - continue; + if (row_offset >= 128 || candidate->size != cur_tile_size) continue; tile_data = candidate->data + 4; - if (memcmp(tile_data, cur_tile_data, cur_tile_size) != 0) - continue; + if (memcmp(tile_data, cur_tile_data, cur_tile_size) != 0) continue; // Identical tile found assert(row_offset > 0); @@ -2780,10 +2710,9 @@ static INLINE int find_identical_tile( } #endif // CONFIG_EXT_TILE -static uint32_t write_tiles(VP10_COMP *const cpi, - uint8_t *const dst, - unsigned int *max_tile_size, - unsigned int *max_tile_col_size) { +static uint32_t write_tiles(VP10_COMP *const cpi, uint8_t *const dst, + unsigned int *max_tile_size, + unsigned int *max_tile_col_size) { const VP10_COMMON *const cm = &cpi->common; #if CONFIG_ANS struct AnsCoder token_ans; @@ -2806,8 +2735,8 @@ static uint32_t write_tiles(VP10_COMP *const cpi, *max_tile_size = 0; *max_tile_col_size = 0; - // All tile size fields are output on 4 bytes. A call to remux_tiles will - // later compact the data if smaller headers are adequate. +// All tile size fields are output on 4 bytes. A call to remux_tiles will +// later compact the data if smaller headers are adequate. #if CONFIG_EXT_TILE for (tile_col = 0; tile_col < tile_cols; tile_col++) { @@ -2818,11 +2747,10 @@ static uint32_t write_tiles(VP10_COMP *const cpi, vp10_tile_set_col(&tile_info, cm, tile_col); // The last column does not have a column header - if (!is_last_col) - total_size += 4; + if (!is_last_col) total_size += 4; for (tile_row = 0; tile_row < tile_rows; tile_row++) { - TileBufferEnc *const buf = &tile_buffers[tile_row][tile_col]; + TileBufferEnc *const buf = &tile_buffers[tile_row][tile_col]; unsigned int tile_size; const TOKENEXTRA *tok = tok_buffers[tile_row][tile_col]; const TOKENEXTRA *tok_end = tok + cpi->tok_count[tile_row][tile_col]; @@ -2857,7 +2785,7 @@ static uint32_t write_tiles(VP10_COMP *const cpi, if (have_tiles) { // tile header: size of this tile, or copy offset - uint32_t tile_header = tile_size; + uint32_t tile_header = tile_size; // Check if this tile is a copy tile. // Very low chances to have copy tiles on the key frames, so don't @@ -2908,8 +2836,7 @@ static uint32_t write_tiles(VP10_COMP *const cpi, buf->data = dst + total_size; // The last tile does not have a header. - if (!is_last_tile) - total_size += 4; + if (!is_last_tile) total_size += 4; #if !CONFIG_ANS vpx_start_encode(&mode_bc, dst + total_size); @@ -2945,8 +2872,8 @@ static uint32_t write_tiles(VP10_COMP *const cpi, static void write_render_size(const VP10_COMMON *cm, struct vpx_write_bit_buffer *wb) { - const int scaling_active = cm->width != cm->render_width || - cm->height != cm->render_height; + const int scaling_active = + cm->width != cm->render_width || cm->height != cm->render_height; vpx_wb_write_bit(wb, scaling_active); if (scaling_active) { vpx_wb_write_literal(wb, cm->render_width - 1, 16); @@ -2972,8 +2899,8 @@ static void write_frame_size_with_refs(VP10_COMP *cpi, YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, ref_frame); if (cfg != NULL) { - found = cm->width == cfg->y_crop_width && - cm->height == cfg->y_crop_height; + found = + cm->width == cfg->y_crop_width && cm->height == cfg->y_crop_height; found &= cm->render_width == cfg->render_width && cm->render_height == cfg->render_height; } @@ -2999,20 +2926,11 @@ static void write_sync_code(struct vpx_write_bit_buffer *wb) { static void write_profile(BITSTREAM_PROFILE profile, struct vpx_write_bit_buffer *wb) { switch (profile) { - case PROFILE_0: - vpx_wb_write_literal(wb, 0, 2); - break; - case PROFILE_1: - vpx_wb_write_literal(wb, 2, 2); - break; - case PROFILE_2: - vpx_wb_write_literal(wb, 1, 2); - break; - case PROFILE_3: - vpx_wb_write_literal(wb, 6, 3); - break; - default: - assert(0); + case PROFILE_0: vpx_wb_write_literal(wb, 0, 2); break; + case PROFILE_1: vpx_wb_write_literal(wb, 2, 2); break; + case PROFILE_2: vpx_wb_write_literal(wb, 1, 2); break; + case PROFILE_3: vpx_wb_write_literal(wb, 6, 3); break; + default: assert(0); } } @@ -3055,8 +2973,7 @@ static void write_uncompressed_header(VP10_COMP *cpi, if (cm->show_existing_frame) { RefCntBuffer *const frame_bufs = cm->buffer_pool->frame_bufs; - const int frame_to_show = - cm->ref_frame_map[cpi->existing_fb_idx_to_show]; + const int frame_to_show = cm->ref_frame_map[cpi->existing_fb_idx_to_show]; if (frame_to_show < 0 || frame_bufs[frame_to_show].ref_count < 1) { vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM, @@ -3070,7 +2987,7 @@ static void write_uncompressed_header(VP10_COMP *cpi, return; } else { -#endif // CONFIG_EXT_REFS +#endif // CONFIG_EXT_REFS vpx_wb_write_bit(wb, 0); // show_existing_frame #if CONFIG_EXT_REFS } @@ -3087,8 +3004,7 @@ static void write_uncompressed_header(VP10_COMP *cpi, if (frame_is_intra_only(cm)) vpx_wb_write_bit(wb, cm->allow_screen_content_tools); } else { - if (!cm->show_frame) - vpx_wb_write_bit(wb, cm->intra_only); + if (!cm->show_frame) vpx_wb_write_bit(wb, cm->intra_only); if (!cm->error_resilient_mode) { if (cm->intra_only) { @@ -3151,8 +3067,8 @@ static void write_uncompressed_header(VP10_COMP *cpi, } if (!cm->error_resilient_mode) { - vpx_wb_write_bit(wb, - cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_FORWARD); + vpx_wb_write_bit( + wb, cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_FORWARD); } vpx_wb_write_literal(wb, cm->frame_context_idx, FRAME_CONTEXTS_LOG2); @@ -3182,8 +3098,7 @@ static void write_uncompressed_header(VP10_COMP *cpi, const int use_compound_pred = cm->reference_mode != SINGLE_REFERENCE; vpx_wb_write_bit(wb, use_hybrid_pred); - if (!use_hybrid_pred) - vpx_wb_write_bit(wb, use_compound_pred); + if (!use_hybrid_pred) vpx_wb_write_bit(wb, use_compound_pred); } write_tile_info(cm, wb); @@ -3191,42 +3106,39 @@ static void write_uncompressed_header(VP10_COMP *cpi, #if CONFIG_GLOBAL_MOTION static void write_global_motion_params(Global_Motion_Params *params, - vpx_prob *probs, - vp10_writer *w) { + vpx_prob *probs, vp10_writer *w) { GLOBAL_MOTION_TYPE gmtype = get_gmtype(params); vp10_write_token(w, vp10_global_motion_types_tree, probs, - &global_motion_types_encodings[gmtype]); + &global_motion_types_encodings[gmtype]); switch (gmtype) { - case GLOBAL_ZERO: - break; + case GLOBAL_ZERO: break; case GLOBAL_AFFINE: - vp10_write_primitive_symmetric(w, (params->motion_params.wmmat[4] * - GM_ALPHA_ENCODE_FACTOR) - - (1 << GM_ALPHA_PREC_BITS), - GM_ABS_ALPHA_BITS); - vp10_write_primitive_symmetric(w, params->motion_params.wmmat[5] * - GM_ALPHA_ENCODE_FACTOR, - GM_ABS_ALPHA_BITS); - // fallthrough intended + vp10_write_primitive_symmetric( + w, (params->motion_params.wmmat[4] * GM_ALPHA_ENCODE_FACTOR) - + (1 << GM_ALPHA_PREC_BITS), + GM_ABS_ALPHA_BITS); + vp10_write_primitive_symmetric( + w, params->motion_params.wmmat[5] * GM_ALPHA_ENCODE_FACTOR, + GM_ABS_ALPHA_BITS); + // fallthrough intended case GLOBAL_ROTZOOM: - vp10_write_primitive_symmetric(w, (params->motion_params.wmmat[2] * - GM_ALPHA_ENCODE_FACTOR) - - (1 << GM_ALPHA_PREC_BITS), - GM_ABS_ALPHA_BITS); - vp10_write_primitive_symmetric(w, params->motion_params.wmmat[3] * - GM_ALPHA_ENCODE_FACTOR, - GM_ABS_ALPHA_BITS); - // fallthrough intended + vp10_write_primitive_symmetric( + w, (params->motion_params.wmmat[2] * GM_ALPHA_ENCODE_FACTOR) - + (1 << GM_ALPHA_PREC_BITS), + GM_ABS_ALPHA_BITS); + vp10_write_primitive_symmetric( + w, params->motion_params.wmmat[3] * GM_ALPHA_ENCODE_FACTOR, + GM_ABS_ALPHA_BITS); + // fallthrough intended case GLOBAL_TRANSLATION: - vp10_write_primitive_symmetric(w, params->motion_params.wmmat[0] * - GM_TRANS_ENCODE_FACTOR, - GM_ABS_TRANS_BITS); - vp10_write_primitive_symmetric(w, params->motion_params.wmmat[1] * - GM_TRANS_ENCODE_FACTOR, - GM_ABS_TRANS_BITS); + vp10_write_primitive_symmetric( + w, params->motion_params.wmmat[0] * GM_TRANS_ENCODE_FACTOR, + GM_ABS_TRANS_BITS); + vp10_write_primitive_symmetric( + w, params->motion_params.wmmat[1] * GM_TRANS_ENCODE_FACTOR, + GM_ABS_TRANS_BITS); break; - default: - assert(0); + default: assert(0); } } @@ -3235,11 +3147,10 @@ static void write_global_motion(VP10_COMP *cpi, vp10_writer *w) { int frame; for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) { if (!cpi->global_motion_used[frame]) { - memset(&cm->global_motion[frame], 0, - sizeof(*cm->global_motion)); + memset(&cm->global_motion[frame], 0, sizeof(*cm->global_motion)); } - write_global_motion_params( - &cm->global_motion[frame], cm->fc->global_motion_types_prob, w); + write_global_motion_params(&cm->global_motion[frame], + cm->fc->global_motion_types_prob, w); } } #endif @@ -3283,8 +3194,7 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) { counts->partition[0], PARTITION_TYPES, header_bc); for (i = 1; i < PARTITION_CONTEXTS; ++i) prob_diff_update(vp10_ext_partition_tree, fc->partition_prob[i], - counts->partition[i], EXT_PARTITION_TYPES, - header_bc); + counts->partition[i], EXT_PARTITION_TYPES, header_bc); #else for (i = 0; i < PARTITION_CONTEXTS; ++i) prob_diff_update(vp10_partition_tree, fc->partition_prob[i], @@ -3318,37 +3228,33 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) { if (cm->reference_mode != COMPOUND_REFERENCE) { for (i = 0; i < BLOCK_SIZE_GROUPS; i++) { if (is_interintra_allowed_bsize_group(i)) { - vp10_cond_prob_diff_update(header_bc, - &fc->interintra_prob[i], + vp10_cond_prob_diff_update(header_bc, &fc->interintra_prob[i], cm->counts.interintra[i]); } } for (i = 0; i < BLOCK_SIZE_GROUPS; i++) { - prob_diff_update(vp10_interintra_mode_tree, - cm->fc->interintra_mode_prob[i], - counts->interintra_mode[i], - INTERINTRA_MODES, header_bc); + prob_diff_update( + vp10_interintra_mode_tree, cm->fc->interintra_mode_prob[i], + counts->interintra_mode[i], INTERINTRA_MODES, header_bc); } for (i = 0; i < BLOCK_SIZES; i++) { if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i)) - vp10_cond_prob_diff_update(header_bc, - &fc->wedge_interintra_prob[i], + vp10_cond_prob_diff_update(header_bc, &fc->wedge_interintra_prob[i], cm->counts.wedge_interintra[i]); } } if (cm->reference_mode != SINGLE_REFERENCE) { for (i = 0; i < BLOCK_SIZES; i++) if (is_interinter_wedge_used(i)) - vp10_cond_prob_diff_update(header_bc, - &fc->wedge_interinter_prob[i], + vp10_cond_prob_diff_update(header_bc, &fc->wedge_interinter_prob[i], cm->counts.wedge_interinter[i]); } #endif // CONFIG_EXT_INTER #if CONFIG_OBMC || CONFIG_WARPED_MOTION for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i) - prob_diff_update(vp10_motvar_tree, fc->motvar_prob[i], - counts->motvar[i], MOTION_VARIATIONS, header_bc); + prob_diff_update(vp10_motvar_tree, fc->motvar_prob[i], counts->motvar[i], + MOTION_VARIATIONS, header_bc); #endif // CONFIG_OBMC || CONFIG_WARPED_MOTION if (cm->interp_filter == SWITCHABLE) @@ -3356,7 +3262,7 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) { for (i = 0; i < INTRA_INTER_CONTEXTS; i++) vp10_cond_prob_diff_update(header_bc, &fc->intra_inter_prob[i], - counts->intra_inter[i]); + counts->intra_inter[i]); if (cpi->allow_comp_inter_inter) { const int use_hybrid_pred = cm->reference_mode == REFERENCE_MODE_SELECT; @@ -3368,7 +3274,7 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) { if (cm->reference_mode != COMPOUND_REFERENCE) { for (i = 0; i < REF_CONTEXTS; i++) { - for (j = 0; j < (SINGLE_REFS - 1); j ++) { + for (j = 0; j < (SINGLE_REFS - 1); j++) { vp10_cond_prob_diff_update(header_bc, &fc->single_ref_prob[i][j], counts->single_ref[i][j]); } @@ -3407,8 +3313,7 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) { #endif update_ext_tx_probs(cm, header_bc); #if CONFIG_SUPERTX - if (!xd->lossless[0]) - update_supertx_probs(cm, header_bc); + if (!xd->lossless[0]) update_supertx_probs(cm, header_bc); #endif // CONFIG_SUPERTX } #if CONFIG_GLOBAL_MOTION @@ -3432,8 +3337,7 @@ static int choose_size_bytes(uint32_t size, int spare_msbs) { // using the 'spare_msbs' number of most significant bits. // Make sure we will fit in 4 bytes to start with.. - if (spare_msbs > 0 && size >> (32 - spare_msbs) != 0) - return -1; + if (spare_msbs > 0 && size >> (32 - spare_msbs) != 0) return -1; // Normalise to 32 bits size <<= spare_msbs; @@ -3450,32 +3354,20 @@ static int choose_size_bytes(uint32_t size, int spare_msbs) { static void mem_put_varsize(uint8_t *const dst, const int sz, const int val) { switch (sz) { - case 1: - dst[0] = (uint8_t)(val & 0xff); - break; - case 2: - mem_put_le16(dst, val); - break; - case 3: - mem_put_le24(dst, val); - break; - case 4: - mem_put_le32(dst, val); - break; - default: - assert("Invalid size" && 0); - break; + case 1: dst[0] = (uint8_t)(val & 0xff); break; + case 2: mem_put_le16(dst, val); break; + case 3: mem_put_le24(dst, val); break; + case 4: mem_put_le32(dst, val); break; + default: assert("Invalid size" && 0); break; } } -static int remux_tiles(const VP10_COMMON *const cm, - uint8_t *dst, - const uint32_t data_size, - const uint32_t max_tile_size, +static int remux_tiles(const VP10_COMMON *const cm, uint8_t *dst, + const uint32_t data_size, const uint32_t max_tile_size, const uint32_t max_tile_col_size, int *const tile_size_bytes, int *const tile_col_size_bytes) { - // Choose the tile size bytes (tsb) and tile column size bytes (tcsb) +// Choose the tile size bytes (tsb) and tile column size bytes (tcsb) #if CONFIG_EXT_TILE // The top bit in the tile size field indicates tile copy mode, so we // have 1 less bit to code the tile size @@ -3484,7 +3376,7 @@ static int remux_tiles(const VP10_COMMON *const cm, #else const int tsb = choose_size_bytes(max_tile_size, 0); const int tcsb = 4; // This is ignored - (void) max_tile_col_size; + (void)max_tile_col_size; #endif // CONFIG_EXT_TILE assert(tsb > 0); @@ -3503,7 +3395,7 @@ static int remux_tiles(const VP10_COMMON *const cm, int tile_row; int tile_col; - for (tile_col = 0 ; tile_col < cm->tile_cols ; tile_col++) { + for (tile_col = 0; tile_col < cm->tile_cols; tile_col++) { // All but the last column has a column header if (tile_col < cm->tile_cols - 1) { uint32_t tile_col_size = mem_get_le32(dst + rpos); @@ -3511,13 +3403,13 @@ static int remux_tiles(const VP10_COMMON *const cm, // Adjust the tile column size by the number of bytes removed // from the tile size fields. - tile_col_size -= (4-tsb) * cm->tile_rows; + tile_col_size -= (4 - tsb) * cm->tile_rows; mem_put_varsize(dst + wpos, tcsb, tile_col_size); wpos += tcsb; } - for (tile_row = 0 ; tile_row < cm->tile_rows ; tile_row++) { + for (tile_row = 0; tile_row < cm->tile_rows; tile_row++) { // All, including the last row has a header uint32_t tile_header = mem_get_le32(dst + rpos); rpos += 4; @@ -3525,8 +3417,7 @@ static int remux_tiles(const VP10_COMMON *const cm, // If this is a copy tile, we need to shift the MSB to the // top bit of the new width, and there is no data to copy. if (tile_header >> 31 != 0) { - if (tsb < 4) - tile_header >>= 32 - 8 * tsb; + if (tsb < 4) tile_header >>= 32 - 8 * tsb; mem_put_varsize(dst + wpos, tsb, tile_header); wpos += tsb; } else { @@ -3574,7 +3465,7 @@ void vp10_pack_bitstream(VP10_COMP *const cpi, uint8_t *dst, size_t *size) { uint32_t compressed_header_size; uint32_t uncompressed_header_size; uint32_t data_size; - struct vpx_write_bit_buffer wb = {data, 0}; + struct vpx_write_bit_buffer wb = { data, 0 }; struct vpx_write_bit_buffer saved_wb; unsigned int max_tile_size; unsigned int max_tile_col_size; @@ -3602,8 +3493,8 @@ void vp10_pack_bitstream(VP10_COMP *const cpi, uint8_t *dst, size_t *size) { saved_wb = wb; // Write tile size magnitudes if (have_tiles) { - // Note that the last item in the uncompressed header is the data - // describing tile configuration. +// Note that the last item in the uncompressed header is the data +// describing tile configuration. #if CONFIG_EXT_TILE // Number of bytes in tile column size - 1 vpx_wb_write_literal(&wb, 0, 2); @@ -3627,9 +3518,9 @@ void vp10_pack_bitstream(VP10_COMP *const cpi, uint8_t *dst, size_t *size) { data_size = write_tiles(cpi, data, &max_tile_size, &max_tile_col_size); if (have_tiles) { - data_size = remux_tiles(cm, data, data_size, - max_tile_size, max_tile_col_size, - &tile_size_bytes, &tile_col_size_bytes); + data_size = + remux_tiles(cm, data, data_size, max_tile_size, max_tile_col_size, + &tile_size_bytes, &tile_col_size_bytes); } data += data_size; diff --git a/vp10/encoder/bitstream.h b/vp10/encoder/bitstream.h index 24934fe6b..615c4e482 100644 --- a/vp10/encoder/bitstream.h +++ b/vp10/encoder/bitstream.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_BITSTREAM_H_ #define VP10_ENCODER_BITSTREAM_H_ diff --git a/vp10/encoder/block.h b/vp10/encoder/block.h index 7da76cccd..c123f2664 100644 --- a/vp10/encoder/block.h +++ b/vp10/encoder/block.h @@ -51,7 +51,7 @@ typedef struct macroblock_plane { /* The [2] dimension is for whether we skip the EOB node (i.e. if previous * coefficient in this block was zero) or not. */ typedef unsigned int vp10_coeff_cost[PLANE_TYPES][REF_TYPES][COEF_BANDS][2] - [COEFF_CONTEXTS][ENTROPY_TOKENS]; + [COEFF_CONTEXTS][ENTROPY_TOKENS]; typedef struct { int_mv ref_mvs[MODE_CTX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; @@ -93,8 +93,8 @@ struct macroblock { int rddiv; int rdmult; int mb_energy; - int * m_search_count_ptr; - int * ex_search_count_ptr; + int *m_search_count_ptr; + int *ex_search_count_ptr; // These are set to their default values at the beginning, and then adjusted // further in the encoding process. diff --git a/vp10/encoder/blockiness.c b/vp10/encoder/blockiness.c index ede13e0e5..c57e4efea 100644 --- a/vp10/encoder/blockiness.c +++ b/vp10/encoder/blockiness.c @@ -70,9 +70,9 @@ static int blockiness_vertical(const uint8_t *s, int sp, const uint8_t *r, s_blockiness += horizontal_filter(s); r_blockiness += horizontal_filter(r); sum_0 += s[0]; - sum_sq_0 += s[0]*s[0]; + sum_sq_0 += s[0] * s[0]; sum_1 += s[-1]; - sum_sq_1 += s[-1]*s[-1]; + sum_sq_1 += s[-1] * s[-1]; } var_0 = variance(sum_0, sum_sq_0, size); var_1 = variance(sum_1, sum_sq_1, size); @@ -120,19 +120,19 @@ static int blockiness_horizontal(const uint8_t *s, int sp, const uint8_t *r, // This function returns the blockiness for the entire frame currently by // looking at all borders in steps of 4. double vp10_get_blockiness(const unsigned char *img1, int img1_pitch, - const unsigned char *img2, int img2_pitch, - int width, int height ) { + const unsigned char *img2, int img2_pitch, int width, + int height) { double blockiness = 0; int i, j; vpx_clear_system_state(); - for (i = 0; i < height; i += 4, img1 += img1_pitch * 4, - img2 += img2_pitch * 4) { + for (i = 0; i < height; + i += 4, img1 += img1_pitch * 4, img2 += img2_pitch * 4) { for (j = 0; j < width; j += 4) { if (i > 0 && i < height && j > 0 && j < width) { - blockiness += blockiness_vertical(img1 + j, img1_pitch, - img2 + j, img2_pitch, 4); - blockiness += blockiness_horizontal(img1 + j, img1_pitch, - img2 + j, img2_pitch, 4); + blockiness += + blockiness_vertical(img1 + j, img1_pitch, img2 + j, img2_pitch, 4); + blockiness += blockiness_horizontal(img1 + j, img1_pitch, img2 + j, + img2_pitch, 4); } } } diff --git a/vp10/encoder/buf_ans.h b/vp10/encoder/buf_ans.h index 8697ee4dc..021777701 100644 --- a/vp10/encoder/buf_ans.h +++ b/vp10/encoder/buf_ans.h @@ -27,10 +27,10 @@ extern "C" { #define ANS_METHOD_RANS 1 struct buffered_ans_symbol { - uint8_t method; // one of ANS_METHOD_UABS or ANS_METHOD_RANS + uint8_t method; // one of ANS_METHOD_UABS or ANS_METHOD_RANS // TODO(aconverse): Should be possible to write this interms of start for ABS AnsP10 val_start; // Boolean value for ABS, start in symbol cycle for Rans - AnsP10 prob; // Probability of this symbol + AnsP10 prob; // Probability of this symbol }; struct BufAnsCoder { @@ -51,8 +51,8 @@ static INLINE void buf_ans_write_reset(struct BufAnsCoder *const c) { c->offset = 0; } -static INLINE void buf_uabs_write(struct BufAnsCoder *const c, - uint8_t val, AnsP8 prob) { +static INLINE void buf_uabs_write(struct BufAnsCoder *const c, uint8_t val, + AnsP8 prob) { assert(c->offset <= c->size); if (c->offset == c->size) { vp10_buf_ans_grow(c); @@ -95,8 +95,8 @@ static INLINE void buf_uabs_write_bit(struct BufAnsCoder *c, int bit) { buf_uabs_write(c, bit, 128); } -static INLINE void buf_uabs_write_literal(struct BufAnsCoder *c, - int literal, int bits) { +static INLINE void buf_uabs_write_literal(struct BufAnsCoder *c, int literal, + int bits) { int bit; assert(bits < 31); diff --git a/vp10/encoder/context_tree.c b/vp10/encoder/context_tree.c index 8555cdb19..0c356e1ad 100644 --- a/vp10/encoder/context_tree.c +++ b/vp10/encoder/context_tree.c @@ -12,10 +12,7 @@ #include "vp10/encoder/encoder.h" static const BLOCK_SIZE square[MAX_SB_SIZE_LOG2 - 2] = { - BLOCK_8X8, - BLOCK_16X16, - BLOCK_32X32, - BLOCK_64X64, + BLOCK_8X8, BLOCK_16X16, BLOCK_32X32, BLOCK_64X64, #if CONFIG_EXT_PARTITION BLOCK_128X128, #endif // CONFIG_EXT_PARTITION @@ -36,8 +33,7 @@ static void alloc_mode_context(VP10_COMMON *cm, int num_4x4_blk, for (i = 0; i < MAX_MB_PLANE; ++i) { #if CONFIG_VAR_TX - CHECK_MEM_ERROR(cm, ctx->blk_skip[i], - vpx_calloc(num_blk, sizeof(uint8_t))); + CHECK_MEM_ERROR(cm, ctx->blk_skip[i], vpx_calloc(num_blk, sizeof(uint8_t))); #endif for (k = 0; k < 3; ++k) { CHECK_MEM_ERROR(cm, ctx->coeff[i][k], @@ -48,18 +44,18 @@ static void alloc_mode_context(VP10_COMMON *cm, int num_4x4_blk, vpx_memalign(32, num_pix * sizeof(*ctx->dqcoeff[i][k]))); CHECK_MEM_ERROR(cm, ctx->eobs[i][k], vpx_memalign(32, num_blk * sizeof(*ctx->eobs[i][k]))); - ctx->coeff_pbuf[i][k] = ctx->coeff[i][k]; - ctx->qcoeff_pbuf[i][k] = ctx->qcoeff[i][k]; + ctx->coeff_pbuf[i][k] = ctx->coeff[i][k]; + ctx->qcoeff_pbuf[i][k] = ctx->qcoeff[i][k]; ctx->dqcoeff_pbuf[i][k] = ctx->dqcoeff[i][k]; - ctx->eobs_pbuf[i][k] = ctx->eobs[i][k]; + ctx->eobs_pbuf[i][k] = ctx->eobs[i][k]; } } if (cm->allow_screen_content_tools) { - for (i = 0; i < 2; ++i) { - CHECK_MEM_ERROR(cm, ctx->color_index_map[i], - vpx_memalign(32, - num_pix * sizeof(*ctx->color_index_map[i]))); + for (i = 0; i < 2; ++i) { + CHECK_MEM_ERROR( + cm, ctx->color_index_map[i], + vpx_memalign(32, num_pix * sizeof(*ctx->color_index_map[i]))); } } } @@ -93,29 +89,35 @@ static void alloc_tree_contexts(VP10_COMMON *cm, PC_TREE *tree, int num_4x4_blk) { #if CONFIG_EXT_PARTITION_TYPES alloc_mode_context(cm, num_4x4_blk, PARTITION_NONE, &tree->none); - alloc_mode_context(cm, num_4x4_blk/2, PARTITION_HORZ, &tree->horizontal[0]); - alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT, &tree->vertical[0]); - alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT, &tree->horizontal[1]); - alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT, &tree->vertical[1]); + alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_HORZ, &tree->horizontal[0]); + alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT, &tree->vertical[0]); + alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT, &tree->horizontal[1]); + alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT, &tree->vertical[1]); - alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_A, + alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_HORZ_A, &tree->horizontala[0]); - alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_A, + alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_HORZ_A, &tree->horizontala[1]); - alloc_mode_context(cm, num_4x4_blk/2, PARTITION_HORZ_A, + alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_HORZ_A, &tree->horizontala[2]); - alloc_mode_context(cm, num_4x4_blk/2, PARTITION_HORZ_B, + alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_HORZ_B, &tree->horizontalb[0]); - alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_B, + alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_HORZ_B, &tree->horizontalb[1]); - alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_B, + alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_HORZ_B, &tree->horizontalb[2]); - alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_A, &tree->verticala[0]); - alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_A, &tree->verticala[1]); - alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT_A, &tree->verticala[2]); - alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT_B, &tree->verticalb[0]); - alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_B, &tree->verticalb[1]); - alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_B, &tree->verticalb[2]); + alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_VERT_A, + &tree->verticala[0]); + alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_VERT_A, + &tree->verticala[1]); + alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT_A, + &tree->verticala[2]); + alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT_B, + &tree->verticalb[0]); + alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_VERT_B, + &tree->verticalb[1]); + alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_VERT_B, + &tree->verticalb[2]); #ifdef CONFIG_SUPERTX alloc_mode_context(cm, num_4x4_blk, PARTITION_HORZ, &tree->horizontal_supertx); @@ -132,8 +134,8 @@ static void alloc_tree_contexts(VP10_COMMON *cm, PC_TREE *tree, #endif // CONFIG_SUPERTX #else alloc_mode_context(cm, num_4x4_blk, &tree->none); - alloc_mode_context(cm, num_4x4_blk/2, &tree->horizontal[0]); - alloc_mode_context(cm, num_4x4_blk/2, &tree->vertical[0]); + alloc_mode_context(cm, num_4x4_blk / 2, &tree->horizontal[0]); + alloc_mode_context(cm, num_4x4_blk / 2, &tree->vertical[0]); #ifdef CONFIG_SUPERTX alloc_mode_context(cm, num_4x4_blk, &tree->horizontal_supertx); alloc_mode_context(cm, num_4x4_blk, &tree->vertical_supertx); @@ -141,8 +143,8 @@ static void alloc_tree_contexts(VP10_COMMON *cm, PC_TREE *tree, #endif if (num_4x4_blk > 4) { - alloc_mode_context(cm, num_4x4_blk/2, &tree->horizontal[1]); - alloc_mode_context(cm, num_4x4_blk/2, &tree->vertical[1]); + alloc_mode_context(cm, num_4x4_blk / 2, &tree->horizontal[1]); + alloc_mode_context(cm, num_4x4_blk / 2, &tree->vertical[1]); } else { memset(&tree->horizontal[1], 0, sizeof(tree->horizontal[1])); memset(&tree->vertical[1], 0, sizeof(tree->vertical[1])); @@ -198,11 +200,11 @@ void vp10_setup_pc_tree(VP10_COMMON *cm, ThreadData *td) { int nodes; vpx_free(td->leaf_tree); - CHECK_MEM_ERROR(cm, td->leaf_tree, vpx_calloc(leaf_nodes, - sizeof(*td->leaf_tree))); + CHECK_MEM_ERROR(cm, td->leaf_tree, + vpx_calloc(leaf_nodes, sizeof(*td->leaf_tree))); vpx_free(td->pc_tree); - CHECK_MEM_ERROR(cm, td->pc_tree, vpx_calloc(tree_nodes, - sizeof(*td->pc_tree))); + CHECK_MEM_ERROR(cm, td->pc_tree, + vpx_calloc(tree_nodes, sizeof(*td->pc_tree))); this_pc = &td->pc_tree[0]; this_leaf = &td->leaf_tree[0]; @@ -223,8 +225,7 @@ void vp10_setup_pc_tree(VP10_COMMON *cm, ThreadData *td) { tree->block_size = square[0]; alloc_tree_contexts(cm, tree, 4); tree->leaf_split[0] = this_leaf++; - for (j = 1; j < 4; j++) - tree->leaf_split[j] = tree->leaf_split[0]; + for (j = 1; j < 4; j++) tree->leaf_split[j] = tree->leaf_split[0]; } // Each node has 4 leaf nodes, fill each block_size level of the tree @@ -234,8 +235,7 @@ void vp10_setup_pc_tree(VP10_COMMON *cm, ThreadData *td) { PC_TREE *const tree = &td->pc_tree[pc_tree_index]; alloc_tree_contexts(cm, tree, 4 << (2 * square_index)); tree->block_size = square[square_index]; - for (j = 0; j < 4; j++) - tree->split[j] = this_pc++; + for (j = 0; j < 4; j++) tree->split[j] = this_pc++; ++pc_tree_index; } ++square_index; @@ -247,7 +247,7 @@ void vp10_setup_pc_tree(VP10_COMMON *cm, ThreadData *td) { td->pc_root[i]->none.best_mode_index = 2; // Set up the root nodes for the rest of the possible superblock sizes while (--i >= 0) { - td->pc_root[i] = td->pc_root[i+1]->split[0]; + td->pc_root[i] = td->pc_root[i + 1]->split[0]; td->pc_root[i]->none.best_mode_index = 2; } } @@ -263,12 +263,10 @@ void vp10_free_pc_tree(ThreadData *td) { int i; // Set up all 4x4 mode contexts - for (i = 0; i < leaf_nodes; ++i) - free_mode_context(&td->leaf_tree[i]); + for (i = 0; i < leaf_nodes; ++i) free_mode_context(&td->leaf_tree[i]); // Sets up all the leaf nodes in the tree. - for (i = 0; i < tree_nodes; ++i) - free_tree_contexts(&td->pc_tree[i]); + for (i = 0; i < tree_nodes; ++i) free_tree_contexts(&td->pc_tree[i]); vpx_free(td->pc_tree); td->pc_tree = NULL; diff --git a/vp10/encoder/cost.c b/vp10/encoder/cost.c index 6053d2eeb..a7941fb39 100644 --- a/vp10/encoder/cost.c +++ b/vp10/encoder/cost.c @@ -18,122 +18,115 @@ /* round(-log2(i/256.) * (1 << VP9_PROB_COST_SHIFT)) Begins with a bogus entry for simpler addressing. */ const uint16_t vp10_prob_cost[256] = { - 4096, 4096, 3584, 3284, 3072, 2907, 2772, 2659, 2560, 2473, 2395, 2325, - 2260, 2201, 2147, 2096, 2048, 2003, 1961, 1921, 1883, 1847, 1813, 1780, - 1748, 1718, 1689, 1661, 1635, 1609, 1584, 1559, 1536, 1513, 1491, 1470, - 1449, 1429, 1409, 1390, 1371, 1353, 1335, 1318, 1301, 1284, 1268, 1252, - 1236, 1221, 1206, 1192, 1177, 1163, 1149, 1136, 1123, 1110, 1097, 1084, - 1072, 1059, 1047, 1036, 1024, 1013, 1001, 990, 979, 968, 958, 947, - 937, 927, 917, 907, 897, 887, 878, 868, 859, 850, 841, 832, - 823, 814, 806, 797, 789, 780, 772, 764, 756, 748, 740, 732, - 724, 717, 709, 702, 694, 687, 680, 673, 665, 658, 651, 644, - 637, 631, 624, 617, 611, 604, 598, 591, 585, 578, 572, 566, - 560, 554, 547, 541, 535, 530, 524, 518, 512, 506, 501, 495, - 489, 484, 478, 473, 467, 462, 456, 451, 446, 441, 435, 430, - 425, 420, 415, 410, 405, 400, 395, 390, 385, 380, 375, 371, - 366, 361, 356, 352, 347, 343, 338, 333, 329, 324, 320, 316, - 311, 307, 302, 298, 294, 289, 285, 281, 277, 273, 268, 264, - 260, 256, 252, 248, 244, 240, 236, 232, 228, 224, 220, 216, - 212, 209, 205, 201, 197, 194, 190, 186, 182, 179, 175, 171, - 168, 164, 161, 157, 153, 150, 146, 143, 139, 136, 132, 129, - 125, 122, 119, 115, 112, 109, 105, 102, 99, 95, 92, 89, - 86, 82, 79, 76, 73, 70, 66, 63, 60, 57, 54, 51, - 48, 45, 42, 38, 35, 32, 29, 26, 23, 20, 18, 15, - 12, 9, 6, 3}; + 4096, 4096, 3584, 3284, 3072, 2907, 2772, 2659, 2560, 2473, 2395, 2325, 2260, + 2201, 2147, 2096, 2048, 2003, 1961, 1921, 1883, 1847, 1813, 1780, 1748, 1718, + 1689, 1661, 1635, 1609, 1584, 1559, 1536, 1513, 1491, 1470, 1449, 1429, 1409, + 1390, 1371, 1353, 1335, 1318, 1301, 1284, 1268, 1252, 1236, 1221, 1206, 1192, + 1177, 1163, 1149, 1136, 1123, 1110, 1097, 1084, 1072, 1059, 1047, 1036, 1024, + 1013, 1001, 990, 979, 968, 958, 947, 937, 927, 917, 907, 897, 887, + 878, 868, 859, 850, 841, 832, 823, 814, 806, 797, 789, 780, 772, + 764, 756, 748, 740, 732, 724, 717, 709, 702, 694, 687, 680, 673, + 665, 658, 651, 644, 637, 631, 624, 617, 611, 604, 598, 591, 585, + 578, 572, 566, 560, 554, 547, 541, 535, 530, 524, 518, 512, 506, + 501, 495, 489, 484, 478, 473, 467, 462, 456, 451, 446, 441, 435, + 430, 425, 420, 415, 410, 405, 400, 395, 390, 385, 380, 375, 371, + 366, 361, 356, 352, 347, 343, 338, 333, 329, 324, 320, 316, 311, + 307, 302, 298, 294, 289, 285, 281, 277, 273, 268, 264, 260, 256, + 252, 248, 244, 240, 236, 232, 228, 224, 220, 216, 212, 209, 205, + 201, 197, 194, 190, 186, 182, 179, 175, 171, 168, 164, 161, 157, + 153, 150, 146, 143, 139, 136, 132, 129, 125, 122, 119, 115, 112, + 109, 105, 102, 99, 95, 92, 89, 86, 82, 79, 76, 73, 70, + 66, 63, 60, 57, 54, 51, 48, 45, 42, 38, 35, 32, 29, + 26, 23, 20, 18, 15, 12, 9, 6, 3 +}; #if CONFIG_ANS // round(-log2(i/1024.) * (1 << VP9_PROB_COST_SHIFT)) static const uint16_t vp10_prob_cost10[1024] = { - 5120, 5120, 4608, 4308, 4096, 3931, 3796, 3683, 3584, 3497, 3419, 3349, - 3284, 3225, 3171, 3120, 3072, 3027, 2985, 2945, 2907, 2871, 2837, 2804, - 2772, 2742, 2713, 2685, 2659, 2633, 2608, 2583, 2560, 2537, 2515, 2494, - 2473, 2453, 2433, 2414, 2395, 2377, 2359, 2342, 2325, 2308, 2292, 2276, - 2260, 2245, 2230, 2216, 2201, 2187, 2173, 2160, 2147, 2134, 2121, 2108, - 2096, 2083, 2071, 2060, 2048, 2037, 2025, 2014, 2003, 1992, 1982, 1971, - 1961, 1951, 1941, 1931, 1921, 1911, 1902, 1892, 1883, 1874, 1865, 1856, - 1847, 1838, 1830, 1821, 1813, 1804, 1796, 1788, 1780, 1772, 1764, 1756, - 1748, 1741, 1733, 1726, 1718, 1711, 1704, 1697, 1689, 1682, 1675, 1668, - 1661, 1655, 1648, 1641, 1635, 1628, 1622, 1615, 1609, 1602, 1596, 1590, - 1584, 1578, 1571, 1565, 1559, 1554, 1548, 1542, 1536, 1530, 1525, 1519, - 1513, 1508, 1502, 1497, 1491, 1486, 1480, 1475, 1470, 1465, 1459, 1454, - 1449, 1444, 1439, 1434, 1429, 1424, 1419, 1414, 1409, 1404, 1399, 1395, - 1390, 1385, 1380, 1376, 1371, 1367, 1362, 1357, 1353, 1348, 1344, 1340, - 1335, 1331, 1326, 1322, 1318, 1313, 1309, 1305, 1301, 1297, 1292, 1288, - 1284, 1280, 1276, 1272, 1268, 1264, 1260, 1256, 1252, 1248, 1244, 1240, - 1236, 1233, 1229, 1225, 1221, 1218, 1214, 1210, 1206, 1203, 1199, 1195, - 1192, 1188, 1185, 1181, 1177, 1174, 1170, 1167, 1163, 1160, 1156, 1153, - 1149, 1146, 1143, 1139, 1136, 1133, 1129, 1126, 1123, 1119, 1116, 1113, - 1110, 1106, 1103, 1100, 1097, 1094, 1090, 1087, 1084, 1081, 1078, 1075, - 1072, 1069, 1066, 1062, 1059, 1056, 1053, 1050, 1047, 1044, 1042, 1039, - 1036, 1033, 1030, 1027, 1024, 1021, 1018, 1015, 1013, 1010, 1007, 1004, - 1001, 998, 996, 993, 990, 987, 985, 982, 979, 977, 974, 971, - 968, 966, 963, 960, 958, 955, 953, 950, 947, 945, 942, 940, - 937, 934, 932, 929, 927, 924, 922, 919, 917, 914, 912, 909, - 907, 904, 902, 899, 897, 895, 892, 890, 887, 885, 883, 880, - 878, 876, 873, 871, 868, 866, 864, 861, 859, 857, 855, 852, - 850, 848, 845, 843, 841, 839, 836, 834, 832, 830, 828, 825, - 823, 821, 819, 817, 814, 812, 810, 808, 806, 804, 801, 799, - 797, 795, 793, 791, 789, 787, 785, 783, 780, 778, 776, 774, - 772, 770, 768, 766, 764, 762, 760, 758, 756, 754, 752, 750, - 748, 746, 744, 742, 740, 738, 736, 734, 732, 730, 728, 726, - 724, 723, 721, 719, 717, 715, 713, 711, 709, 707, 706, 704, - 702, 700, 698, 696, 694, 693, 691, 689, 687, 685, 683, 682, - 680, 678, 676, 674, 673, 671, 669, 667, 665, 664, 662, 660, - 658, 657, 655, 653, 651, 650, 648, 646, 644, 643, 641, 639, - 637, 636, 634, 632, 631, 629, 627, 626, 624, 622, 621, 619, - 617, 616, 614, 612, 611, 609, 607, 606, 604, 602, 601, 599, - 598, 596, 594, 593, 591, 590, 588, 586, 585, 583, 582, 580, - 578, 577, 575, 574, 572, 571, 569, 567, 566, 564, 563, 561, - 560, 558, 557, 555, 554, 552, 550, 549, 547, 546, 544, 543, - 541, 540, 538, 537, 535, 534, 532, 531, 530, 528, 527, 525, - 524, 522, 521, 519, 518, 516, 515, 513, 512, 511, 509, 508, - 506, 505, 503, 502, 501, 499, 498, 496, 495, 493, 492, 491, - 489, 488, 486, 485, 484, 482, 481, 480, 478, 477, 475, 474, - 473, 471, 470, 469, 467, 466, 465, 463, 462, 460, 459, 458, - 456, 455, 454, 452, 451, 450, 448, 447, 446, 444, 443, 442, - 441, 439, 438, 437, 435, 434, 433, 431, 430, 429, 428, 426, - 425, 424, 422, 421, 420, 419, 417, 416, 415, 414, 412, 411, - 410, 409, 407, 406, 405, 404, 402, 401, 400, 399, 397, 396, - 395, 394, 392, 391, 390, 389, 387, 386, 385, 384, 383, 381, - 380, 379, 378, 377, 375, 374, 373, 372, 371, 369, 368, 367, - 366, 365, 364, 362, 361, 360, 359, 358, 356, 355, 354, 353, - 352, 351, 349, 348, 347, 346, 345, 344, 343, 341, 340, 339, - 338, 337, 336, 335, 333, 332, 331, 330, 329, 328, 327, 326, - 324, 323, 322, 321, 320, 319, 318, 317, 316, 314, 313, 312, - 311, 310, 309, 308, 307, 306, 305, 303, 302, 301, 300, 299, - 298, 297, 296, 295, 294, 293, 292, 291, 289, 288, 287, 286, - 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, - 273, 272, 271, 269, 268, 267, 266, 265, 264, 263, 262, 261, - 260, 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, 249, - 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, - 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, - 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, - 212, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, - 201, 200, 199, 198, 197, 196, 195, 194, 194, 193, 192, 191, - 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 181, 180, - 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 170, 169, - 168, 167, 166, 165, 164, 163, 162, 161, 161, 160, 159, 158, - 157, 156, 155, 154, 153, 152, 152, 151, 150, 149, 148, 147, - 146, 145, 145, 144, 143, 142, 141, 140, 139, 138, 138, 137, - 136, 135, 134, 133, 132, 132, 131, 130, 129, 128, 127, 126, - 125, 125, 124, 123, 122, 121, 120, 120, 119, 118, 117, 116, - 115, 114, 114, 113, 112, 111, 110, 109, 109, 108, 107, 106, - 105, 104, 104, 103, 102, 101, 100, 99, 99, 98, 97, 96, - 95, 95, 94, 93, 92, 91, 90, 90, 89, 88, 87, 86, - 86, 85, 84, 83, 82, 82, 81, 80, 79, 78, 78, 77, - 76, 75, 74, 74, 73, 72, 71, 70, 70, 69, 68, 67, - 66, 66, 65, 64, 63, 62, 62, 61, 60, 59, 59, 58, - 57, 56, 55, 55, 54, 53, 52, 52, 51, 50, 49, 48, - 48, 47, 46, 45, 45, 44, 43, 42, 42, 41, 40, 39, - 38, 38, 37, 36, 35, 35, 34, 33, 32, 32, 31, 30, - 29, 29, 28, 27, 26, 26, 25, 24, 23, 23, 22, 21, - 20, 20, 19, 18, 18, 17, 16, 15, 15, 14, 13, 12, - 12, 11, 10, 9, 9, 8, 7, 7, 6, 5, 4, 4, - 3, 2, 1, 1}; + 5120, 5120, 4608, 4308, 4096, 3931, 3796, 3683, 3584, 3497, 3419, 3349, 3284, + 3225, 3171, 3120, 3072, 3027, 2985, 2945, 2907, 2871, 2837, 2804, 2772, 2742, + 2713, 2685, 2659, 2633, 2608, 2583, 2560, 2537, 2515, 2494, 2473, 2453, 2433, + 2414, 2395, 2377, 2359, 2342, 2325, 2308, 2292, 2276, 2260, 2245, 2230, 2216, + 2201, 2187, 2173, 2160, 2147, 2134, 2121, 2108, 2096, 2083, 2071, 2060, 2048, + 2037, 2025, 2014, 2003, 1992, 1982, 1971, 1961, 1951, 1941, 1931, 1921, 1911, + 1902, 1892, 1883, 1874, 1865, 1856, 1847, 1838, 1830, 1821, 1813, 1804, 1796, + 1788, 1780, 1772, 1764, 1756, 1748, 1741, 1733, 1726, 1718, 1711, 1704, 1697, + 1689, 1682, 1675, 1668, 1661, 1655, 1648, 1641, 1635, 1628, 1622, 1615, 1609, + 1602, 1596, 1590, 1584, 1578, 1571, 1565, 1559, 1554, 1548, 1542, 1536, 1530, + 1525, 1519, 1513, 1508, 1502, 1497, 1491, 1486, 1480, 1475, 1470, 1465, 1459, + 1454, 1449, 1444, 1439, 1434, 1429, 1424, 1419, 1414, 1409, 1404, 1399, 1395, + 1390, 1385, 1380, 1376, 1371, 1367, 1362, 1357, 1353, 1348, 1344, 1340, 1335, + 1331, 1326, 1322, 1318, 1313, 1309, 1305, 1301, 1297, 1292, 1288, 1284, 1280, + 1276, 1272, 1268, 1264, 1260, 1256, 1252, 1248, 1244, 1240, 1236, 1233, 1229, + 1225, 1221, 1218, 1214, 1210, 1206, 1203, 1199, 1195, 1192, 1188, 1185, 1181, + 1177, 1174, 1170, 1167, 1163, 1160, 1156, 1153, 1149, 1146, 1143, 1139, 1136, + 1133, 1129, 1126, 1123, 1119, 1116, 1113, 1110, 1106, 1103, 1100, 1097, 1094, + 1090, 1087, 1084, 1081, 1078, 1075, 1072, 1069, 1066, 1062, 1059, 1056, 1053, + 1050, 1047, 1044, 1042, 1039, 1036, 1033, 1030, 1027, 1024, 1021, 1018, 1015, + 1013, 1010, 1007, 1004, 1001, 998, 996, 993, 990, 987, 985, 982, 979, + 977, 974, 971, 968, 966, 963, 960, 958, 955, 953, 950, 947, 945, + 942, 940, 937, 934, 932, 929, 927, 924, 922, 919, 917, 914, 912, + 909, 907, 904, 902, 899, 897, 895, 892, 890, 887, 885, 883, 880, + 878, 876, 873, 871, 868, 866, 864, 861, 859, 857, 855, 852, 850, + 848, 845, 843, 841, 839, 836, 834, 832, 830, 828, 825, 823, 821, + 819, 817, 814, 812, 810, 808, 806, 804, 801, 799, 797, 795, 793, + 791, 789, 787, 785, 783, 780, 778, 776, 774, 772, 770, 768, 766, + 764, 762, 760, 758, 756, 754, 752, 750, 748, 746, 744, 742, 740, + 738, 736, 734, 732, 730, 728, 726, 724, 723, 721, 719, 717, 715, + 713, 711, 709, 707, 706, 704, 702, 700, 698, 696, 694, 693, 691, + 689, 687, 685, 683, 682, 680, 678, 676, 674, 673, 671, 669, 667, + 665, 664, 662, 660, 658, 657, 655, 653, 651, 650, 648, 646, 644, + 643, 641, 639, 637, 636, 634, 632, 631, 629, 627, 626, 624, 622, + 621, 619, 617, 616, 614, 612, 611, 609, 607, 606, 604, 602, 601, + 599, 598, 596, 594, 593, 591, 590, 588, 586, 585, 583, 582, 580, + 578, 577, 575, 574, 572, 571, 569, 567, 566, 564, 563, 561, 560, + 558, 557, 555, 554, 552, 550, 549, 547, 546, 544, 543, 541, 540, + 538, 537, 535, 534, 532, 531, 530, 528, 527, 525, 524, 522, 521, + 519, 518, 516, 515, 513, 512, 511, 509, 508, 506, 505, 503, 502, + 501, 499, 498, 496, 495, 493, 492, 491, 489, 488, 486, 485, 484, + 482, 481, 480, 478, 477, 475, 474, 473, 471, 470, 469, 467, 466, + 465, 463, 462, 460, 459, 458, 456, 455, 454, 452, 451, 450, 448, + 447, 446, 444, 443, 442, 441, 439, 438, 437, 435, 434, 433, 431, + 430, 429, 428, 426, 425, 424, 422, 421, 420, 419, 417, 416, 415, + 414, 412, 411, 410, 409, 407, 406, 405, 404, 402, 401, 400, 399, + 397, 396, 395, 394, 392, 391, 390, 389, 387, 386, 385, 384, 383, + 381, 380, 379, 378, 377, 375, 374, 373, 372, 371, 369, 368, 367, + 366, 365, 364, 362, 361, 360, 359, 358, 356, 355, 354, 353, 352, + 351, 349, 348, 347, 346, 345, 344, 343, 341, 340, 339, 338, 337, + 336, 335, 333, 332, 331, 330, 329, 328, 327, 326, 324, 323, 322, + 321, 320, 319, 318, 317, 316, 314, 313, 312, 311, 310, 309, 308, + 307, 306, 305, 303, 302, 301, 300, 299, 298, 297, 296, 295, 294, + 293, 292, 291, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, + 279, 278, 277, 276, 275, 274, 273, 272, 271, 269, 268, 267, 266, + 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 255, 254, 253, + 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, + 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, + 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, + 213, 212, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, + 201, 200, 199, 198, 197, 196, 195, 194, 194, 193, 192, 191, 190, + 189, 188, 187, 186, 185, 184, 183, 182, 181, 181, 180, 179, 178, + 177, 176, 175, 174, 173, 172, 171, 170, 170, 169, 168, 167, 166, + 165, 164, 163, 162, 161, 161, 160, 159, 158, 157, 156, 155, 154, + 153, 152, 152, 151, 150, 149, 148, 147, 146, 145, 145, 144, 143, + 142, 141, 140, 139, 138, 138, 137, 136, 135, 134, 133, 132, 132, + 131, 130, 129, 128, 127, 126, 125, 125, 124, 123, 122, 121, 120, + 120, 119, 118, 117, 116, 115, 114, 114, 113, 112, 111, 110, 109, + 109, 108, 107, 106, 105, 104, 104, 103, 102, 101, 100, 99, 99, + 98, 97, 96, 95, 95, 94, 93, 92, 91, 90, 90, 89, 88, + 87, 86, 86, 85, 84, 83, 82, 82, 81, 80, 79, 78, 78, + 77, 76, 75, 74, 74, 73, 72, 71, 70, 70, 69, 68, 67, + 66, 66, 65, 64, 63, 62, 62, 61, 60, 59, 59, 58, 57, + 56, 55, 55, 54, 53, 52, 52, 51, 50, 49, 48, 48, 47, + 46, 45, 45, 44, 43, 42, 42, 41, 40, 39, 38, 38, 37, + 36, 35, 35, 34, 33, 32, 32, 31, 30, 29, 29, 28, 27, + 26, 26, 25, 24, 23, 23, 22, 21, 20, 20, 19, 18, 18, + 17, 16, 15, 15, 14, 13, 12, 12, 11, 10, 9, 9, 8, + 7, 7, 6, 5, 4, 4, 3, 2, 1, 1 +}; #endif // CONFIG_ANS -static void cost(int *costs, vpx_tree tree, const vpx_prob *probs, - int i, int c) { +static void cost(int *costs, vpx_tree tree, const vpx_prob *probs, int i, + int c) { const vpx_prob prob = probs[i / 2]; int b; @@ -155,8 +148,7 @@ void vp10_cost_tokens_ans(int *costs, const vpx_prob *tree_probs, int c_tree = 0; // Cost of the "tree" nodes EOB and ZERO. int i; costs[EOB_TOKEN] = vp10_cost_bit(tree_probs[0], 0); - if (!skip_eob) - c_tree = vp10_cost_bit(tree_probs[0], 1); + if (!skip_eob) c_tree = vp10_cost_bit(tree_probs[0], 1); for (i = ZERO_TOKEN; i <= CATEGORY6_TOKEN; ++i) { const int p = token_cdf[i + 1] - token_cdf[i]; costs[i] = c_tree + vp10_prob_cost10[p]; diff --git a/vp10/encoder/cost.h b/vp10/encoder/cost.h index bfd0be08d..dd383a9da 100644 --- a/vp10/encoder/cost.h +++ b/vp10/encoder/cost.h @@ -30,8 +30,7 @@ extern const uint16_t vp10_prob_cost[256]; #define vp10_cost_one(prob) vp10_cost_zero(256 - (prob)) -#define vp10_cost_bit(prob, bit) vp10_cost_zero((bit) ? 256 - (prob) \ - : (prob)) +#define vp10_cost_bit(prob, bit) vp10_cost_zero((bit) ? 256 - (prob) : (prob)) // Cost of coding an n bit literal, using 128 (i.e. 50%) probability // for each bit. @@ -42,8 +41,8 @@ static INLINE unsigned int cost_branch256(const unsigned int ct[2], return ct[0] * vp10_cost_zero(p) + ct[1] * vp10_cost_one(p); } -static INLINE int treed_cost(vpx_tree tree, const vpx_prob *probs, - int bits, int len) { +static INLINE int treed_cost(vpx_tree tree, const vpx_prob *probs, int bits, + int len) { int cost = 0; vpx_tree_index i = 0; diff --git a/vp10/encoder/dct.c b/vp10/encoder/dct.c index 46bcd0bab..022a77f58 100644 --- a/vp10/encoder/dct.c +++ b/vp10/encoder/dct.c @@ -777,14 +777,14 @@ static void fadst8(const tran_low_t *input, tran_low_t *output) { tran_high_t x7 = input[6]; // stage 1 - s0 = cospi_2_64 * x0 + cospi_30_64 * x1; - s1 = cospi_30_64 * x0 - cospi_2_64 * x1; + s0 = cospi_2_64 * x0 + cospi_30_64 * x1; + s1 = cospi_30_64 * x0 - cospi_2_64 * x1; s2 = cospi_10_64 * x2 + cospi_22_64 * x3; s3 = cospi_22_64 * x2 - cospi_10_64 * x3; s4 = cospi_18_64 * x4 + cospi_14_64 * x5; s5 = cospi_14_64 * x4 - cospi_18_64 * x5; - s6 = cospi_26_64 * x6 + cospi_6_64 * x7; - s7 = cospi_6_64 * x6 - cospi_26_64 * x7; + s6 = cospi_26_64 * x6 + cospi_6_64 * x7; + s7 = cospi_6_64 * x6 - cospi_26_64 * x7; x0 = fdct_round_shift(s0 + s4); x1 = fdct_round_shift(s1 + s5); @@ -800,10 +800,10 @@ static void fadst8(const tran_low_t *input, tran_low_t *output) { s1 = x1; s2 = x2; s3 = x3; - s4 = cospi_8_64 * x4 + cospi_24_64 * x5; - s5 = cospi_24_64 * x4 - cospi_8_64 * x5; - s6 = - cospi_24_64 * x6 + cospi_8_64 * x7; - s7 = cospi_8_64 * x6 + cospi_24_64 * x7; + s4 = cospi_8_64 * x4 + cospi_24_64 * x5; + s5 = cospi_24_64 * x4 - cospi_8_64 * x5; + s6 = -cospi_24_64 * x6 + cospi_8_64 * x7; + s7 = cospi_8_64 * x6 + cospi_24_64 * x7; x0 = s0 + s2; x1 = s1 + s3; @@ -857,11 +857,11 @@ static void fadst16(const tran_low_t *input, tran_low_t *output) { tran_high_t x15 = input[14]; // stage 1 - s0 = x0 * cospi_1_64 + x1 * cospi_31_64; + s0 = x0 * cospi_1_64 + x1 * cospi_31_64; s1 = x0 * cospi_31_64 - x1 * cospi_1_64; - s2 = x2 * cospi_5_64 + x3 * cospi_27_64; + s2 = x2 * cospi_5_64 + x3 * cospi_27_64; s3 = x2 * cospi_27_64 - x3 * cospi_5_64; - s4 = x4 * cospi_9_64 + x5 * cospi_23_64; + s4 = x4 * cospi_9_64 + x5 * cospi_23_64; s5 = x4 * cospi_23_64 - x5 * cospi_9_64; s6 = x6 * cospi_13_64 + x7 * cospi_19_64; s7 = x6 * cospi_19_64 - x7 * cospi_13_64; @@ -870,9 +870,9 @@ static void fadst16(const tran_low_t *input, tran_low_t *output) { s10 = x10 * cospi_21_64 + x11 * cospi_11_64; s11 = x10 * cospi_11_64 - x11 * cospi_21_64; s12 = x12 * cospi_25_64 + x13 * cospi_7_64; - s13 = x12 * cospi_7_64 - x13 * cospi_25_64; + s13 = x12 * cospi_7_64 - x13 * cospi_25_64; s14 = x14 * cospi_29_64 + x15 * cospi_3_64; - s15 = x14 * cospi_3_64 - x15 * cospi_29_64; + s15 = x14 * cospi_3_64 - x15 * cospi_29_64; x0 = fdct_round_shift(s0 + s8); x1 = fdct_round_shift(s1 + s9); @@ -882,8 +882,8 @@ static void fadst16(const tran_low_t *input, tran_low_t *output) { x5 = fdct_round_shift(s5 + s13); x6 = fdct_round_shift(s6 + s14); x7 = fdct_round_shift(s7 + s15); - x8 = fdct_round_shift(s0 - s8); - x9 = fdct_round_shift(s1 - s9); + x8 = fdct_round_shift(s0 - s8); + x9 = fdct_round_shift(s1 - s9); x10 = fdct_round_shift(s2 - s10); x11 = fdct_round_shift(s3 - s11); x12 = fdct_round_shift(s4 - s12); @@ -900,14 +900,14 @@ static void fadst16(const tran_low_t *input, tran_low_t *output) { s5 = x5; s6 = x6; s7 = x7; - s8 = x8 * cospi_4_64 + x9 * cospi_28_64; - s9 = x8 * cospi_28_64 - x9 * cospi_4_64; - s10 = x10 * cospi_20_64 + x11 * cospi_12_64; - s11 = x10 * cospi_12_64 - x11 * cospi_20_64; - s12 = - x12 * cospi_28_64 + x13 * cospi_4_64; - s13 = x12 * cospi_4_64 + x13 * cospi_28_64; - s14 = - x14 * cospi_12_64 + x15 * cospi_20_64; - s15 = x14 * cospi_20_64 + x15 * cospi_12_64; + s8 = x8 * cospi_4_64 + x9 * cospi_28_64; + s9 = x8 * cospi_28_64 - x9 * cospi_4_64; + s10 = x10 * cospi_20_64 + x11 * cospi_12_64; + s11 = x10 * cospi_12_64 - x11 * cospi_20_64; + s12 = -x12 * cospi_28_64 + x13 * cospi_4_64; + s13 = x12 * cospi_4_64 + x13 * cospi_28_64; + s14 = -x14 * cospi_12_64 + x15 * cospi_20_64; + s15 = x14 * cospi_20_64 + x15 * cospi_12_64; x0 = s0 + s4; x1 = s1 + s5; @@ -931,18 +931,18 @@ static void fadst16(const tran_low_t *input, tran_low_t *output) { s1 = x1; s2 = x2; s3 = x3; - s4 = x4 * cospi_8_64 + x5 * cospi_24_64; + s4 = x4 * cospi_8_64 + x5 * cospi_24_64; s5 = x4 * cospi_24_64 - x5 * cospi_8_64; - s6 = - x6 * cospi_24_64 + x7 * cospi_8_64; - s7 = x6 * cospi_8_64 + x7 * cospi_24_64; + s6 = -x6 * cospi_24_64 + x7 * cospi_8_64; + s7 = x6 * cospi_8_64 + x7 * cospi_24_64; s8 = x8; s9 = x9; s10 = x10; s11 = x11; - s12 = x12 * cospi_8_64 + x13 * cospi_24_64; + s12 = x12 * cospi_8_64 + x13 * cospi_24_64; s13 = x12 * cospi_24_64 - x13 * cospi_8_64; - s14 = - x14 * cospi_24_64 + x15 * cospi_8_64; - s15 = x14 * cospi_8_64 + x15 * cospi_24_64; + s14 = -x14 * cospi_24_64 + x15 * cospi_8_64; + s15 = x14 * cospi_8_64 + x15 * cospi_24_64; x0 = s0 + s2; x1 = s1 + s3; @@ -962,13 +962,13 @@ static void fadst16(const tran_low_t *input, tran_low_t *output) { x15 = fdct_round_shift(s13 - s15); // stage 4 - s2 = (- cospi_16_64) * (x2 + x3); + s2 = (-cospi_16_64) * (x2 + x3); s3 = cospi_16_64 * (x2 - x3); s6 = cospi_16_64 * (x6 + x7); - s7 = cospi_16_64 * (- x6 + x7); + s7 = cospi_16_64 * (-x6 + x7); s10 = cospi_16_64 * (x10 + x11); - s11 = cospi_16_64 * (- x10 + x11); - s14 = (- cospi_16_64) * (x14 + x15); + s11 = cospi_16_64 * (-x10 + x11); + s14 = (-cospi_16_64) * (x14 + x15); s15 = cospi_16_64 * (x14 - x15); x2 = fdct_round_shift(s2); @@ -1007,8 +1007,7 @@ static void fidtx4(const tran_low_t *input, tran_low_t *output) { static void fidtx8(const tran_low_t *input, tran_low_t *output) { int i; - for (i = 0; i < 8; ++i) - output[i] = input[i] * 2; + for (i = 0; i < 8; ++i) output[i] = input[i] * 2; } static void fidtx16(const tran_low_t *input, tran_low_t *output) { @@ -1019,8 +1018,7 @@ static void fidtx16(const tran_low_t *input, tran_low_t *output) { static void fidtx32(const tran_low_t *input, tran_low_t *output) { int i; - for (i = 0; i < 32; ++i) - output[i] = input[i] * 4; + for (i = 0; i < 32; ++i) output[i] = input[i] * 4; } // For use in lieu of ADST @@ -1042,8 +1040,7 @@ static void copy_block(const int16_t *src, int src_stride, int l, int w, int16_t *dest, int dest_stride) { int i; for (i = 0; i < l; ++i) { - memcpy(dest + dest_stride * i, src + src_stride * i, - w * sizeof(int16_t)); + memcpy(dest + dest_stride * i, src + src_stride * i, w * sizeof(int16_t)); } } @@ -1080,29 +1077,25 @@ static void fliplrud(int16_t *dest, int stride, int l, int w) { } } -static void copy_fliplr(const int16_t *src, int src_stride, - int l, int w, +static void copy_fliplr(const int16_t *src, int src_stride, int l, int w, int16_t *dest, int dest_stride) { copy_block(src, src_stride, l, w, dest, dest_stride); fliplr(dest, dest_stride, l, w); } -static void copy_flipud(const int16_t *src, int src_stride, - int l, int w, +static void copy_flipud(const int16_t *src, int src_stride, int l, int w, int16_t *dest, int dest_stride) { copy_block(src, src_stride, l, w, dest, dest_stride); flipud(dest, dest_stride, l, w); } -static void copy_fliplrud(const int16_t *src, int src_stride, - int l, int w, +static void copy_fliplrud(const int16_t *src, int src_stride, int l, int w, int16_t *dest, int dest_stride) { copy_block(src, src_stride, l, w, dest, dest_stride); fliplrud(dest, dest_stride, l, w); } -static void maybe_flip_input(const int16_t **src, int *src_stride, - int l, int w, +static void maybe_flip_input(const int16_t **src, int *src_stride, int l, int w, int16_t *buff, int tx_type) { switch (tx_type) { case DCT_DCT: @@ -1113,8 +1106,7 @@ static void maybe_flip_input(const int16_t **src, int *src_stride, case V_DCT: case H_DCT: case V_ADST: - case H_ADST: - break; + case H_ADST: break; case FLIPADST_DCT: case FLIPADST_ADST: case V_FLIPADST: @@ -1134,109 +1126,107 @@ static void maybe_flip_input(const int16_t **src, int *src_stride, *src = buff; *src_stride = w; break; - default: - assert(0); - break; + default: assert(0); break; } } #endif // CONFIG_EXT_TX static const transform_2d FHT_4[] = { - { fdct4, fdct4 }, // DCT_DCT - { fadst4, fdct4 }, // ADST_DCT - { fdct4, fadst4 }, // DCT_ADST + { fdct4, fdct4 }, // DCT_DCT + { fadst4, fdct4 }, // ADST_DCT + { fdct4, fadst4 }, // DCT_ADST { fadst4, fadst4 }, // ADST_ADST #if CONFIG_EXT_TX - { fadst4, fdct4 }, // FLIPADST_DCT - { fdct4, fadst4 }, // DCT_FLIPADST + { fadst4, fdct4 }, // FLIPADST_DCT + { fdct4, fadst4 }, // DCT_FLIPADST { fadst4, fadst4 }, // FLIPADST_FLIPADST { fadst4, fadst4 }, // ADST_FLIPADST { fadst4, fadst4 }, // FLIPADST_ADST { fidtx4, fidtx4 }, // IDTX - { fdct4, fidtx4 }, // V_DCT - { fidtx4, fdct4 }, // H_DCT + { fdct4, fidtx4 }, // V_DCT + { fidtx4, fdct4 }, // H_DCT { fadst4, fidtx4 }, // V_ADST { fidtx4, fadst4 }, // H_ADST { fadst4, fidtx4 }, // V_FLIPADST { fidtx4, fadst4 }, // H_FLIPADST -#endif // CONFIG_EXT_TX +#endif // CONFIG_EXT_TX }; static const transform_2d FHT_8[] = { - { fdct8, fdct8 }, // DCT_DCT - { fadst8, fdct8 }, // ADST_DCT - { fdct8, fadst8 }, // DCT_ADST + { fdct8, fdct8 }, // DCT_DCT + { fadst8, fdct8 }, // ADST_DCT + { fdct8, fadst8 }, // DCT_ADST { fadst8, fadst8 }, // ADST_ADST #if CONFIG_EXT_TX - { fadst8, fdct8 }, // FLIPADST_DCT - { fdct8, fadst8 }, // DCT_FLIPADST + { fadst8, fdct8 }, // FLIPADST_DCT + { fdct8, fadst8 }, // DCT_FLIPADST { fadst8, fadst8 }, // FLIPADST_FLIPADST { fadst8, fadst8 }, // ADST_FLIPADST { fadst8, fadst8 }, // FLIPADST_ADST { fidtx8, fidtx8 }, // IDTX - { fdct8, fidtx8 }, // V_DCT - { fidtx8, fdct8 }, // H_DCT + { fdct8, fidtx8 }, // V_DCT + { fidtx8, fdct8 }, // H_DCT { fadst8, fidtx8 }, // V_ADST { fidtx8, fadst8 }, // H_ADST { fadst8, fidtx8 }, // V_FLIPADST { fidtx8, fadst8 }, // H_FLIPADST -#endif // CONFIG_EXT_TX +#endif // CONFIG_EXT_TX }; static const transform_2d FHT_16[] = { - { fdct16, fdct16 }, // DCT_DCT - { fadst16, fdct16 }, // ADST_DCT - { fdct16, fadst16 }, // DCT_ADST + { fdct16, fdct16 }, // DCT_DCT + { fadst16, fdct16 }, // ADST_DCT + { fdct16, fadst16 }, // DCT_ADST { fadst16, fadst16 }, // ADST_ADST #if CONFIG_EXT_TX - { fadst16, fdct16 }, // FLIPADST_DCT - { fdct16, fadst16 }, // DCT_FLIPADST + { fadst16, fdct16 }, // FLIPADST_DCT + { fdct16, fadst16 }, // DCT_FLIPADST { fadst16, fadst16 }, // FLIPADST_FLIPADST { fadst16, fadst16 }, // ADST_FLIPADST { fadst16, fadst16 }, // FLIPADST_ADST { fidtx16, fidtx16 }, // IDTX - { fdct16, fidtx16 }, // V_DCT - { fidtx16, fdct16 }, // H_DCT + { fdct16, fidtx16 }, // V_DCT + { fidtx16, fdct16 }, // H_DCT { fadst16, fidtx16 }, // V_ADST { fidtx16, fadst16 }, // H_ADST { fadst16, fidtx16 }, // V_FLIPADST { fidtx16, fadst16 }, // H_FLIPADST -#endif // CONFIG_EXT_TX +#endif // CONFIG_EXT_TX }; #if CONFIG_EXT_TX static const transform_2d FHT_32[] = { - { fdct32, fdct32 }, // DCT_DCT - { fhalfright32, fdct32 }, // ADST_DCT - { fdct32, fhalfright32 }, // DCT_ADST - { fhalfright32, fhalfright32 }, // ADST_ADST - { fhalfright32, fdct32 }, // FLIPADST_DCT - { fdct32, fhalfright32 }, // DCT_FLIPADST - { fhalfright32, fhalfright32 }, // FLIPADST_FLIPADST - { fhalfright32, fhalfright32 }, // ADST_FLIPADST - { fhalfright32, fhalfright32 }, // FLIPADST_ADST - { fidtx32, fidtx32 }, // IDTX - { fdct32, fidtx32 }, // V_DCT - { fidtx32, fdct32 }, // H_DCT - { fhalfright32, fidtx32 }, // V_ADST - { fidtx32, fhalfright32 }, // H_ADST - { fhalfright32, fidtx32 }, // V_FLIPADST - { fidtx32, fhalfright32 }, // H_FLIPADST + { fdct32, fdct32 }, // DCT_DCT + { fhalfright32, fdct32 }, // ADST_DCT + { fdct32, fhalfright32 }, // DCT_ADST + { fhalfright32, fhalfright32 }, // ADST_ADST + { fhalfright32, fdct32 }, // FLIPADST_DCT + { fdct32, fhalfright32 }, // DCT_FLIPADST + { fhalfright32, fhalfright32 }, // FLIPADST_FLIPADST + { fhalfright32, fhalfright32 }, // ADST_FLIPADST + { fhalfright32, fhalfright32 }, // FLIPADST_ADST + { fidtx32, fidtx32 }, // IDTX + { fdct32, fidtx32 }, // V_DCT + { fidtx32, fdct32 }, // H_DCT + { fhalfright32, fidtx32 }, // V_ADST + { fidtx32, fhalfright32 }, // H_ADST + { fhalfright32, fidtx32 }, // V_FLIPADST + { fidtx32, fhalfright32 }, // H_FLIPADST }; static const transform_2d FHT_4x8[] = { - { fdct8, fdct4 }, // DCT_DCT - { fadst8, fdct4 }, // ADST_DCT - { fdct8, fadst4 }, // DCT_ADST + { fdct8, fdct4 }, // DCT_DCT + { fadst8, fdct4 }, // ADST_DCT + { fdct8, fadst4 }, // DCT_ADST { fadst8, fadst4 }, // ADST_ADST - { fadst8, fdct4 }, // FLIPADST_DCT - { fdct8, fadst4 }, // DCT_FLIPADST + { fadst8, fdct4 }, // FLIPADST_DCT + { fdct8, fadst4 }, // DCT_FLIPADST { fadst8, fadst4 }, // FLIPADST_FLIPADST { fadst8, fadst4 }, // ADST_FLIPADST { fadst8, fadst4 }, // FLIPADST_ADST { fidtx8, fidtx4 }, // IDTX - { fdct8, fidtx4 }, // V_DCT - { fidtx8, fdct4 }, // H_DCT + { fdct8, fidtx4 }, // V_DCT + { fidtx8, fdct4 }, // H_DCT { fadst8, fidtx4 }, // V_ADST { fidtx8, fadst4 }, // H_ADST { fadst8, fidtx4 }, // V_FLIPADST @@ -1244,18 +1234,18 @@ static const transform_2d FHT_4x8[] = { }; static const transform_2d FHT_8x4[] = { - { fdct4, fdct8 }, // DCT_DCT - { fadst4, fdct8 }, // ADST_DCT - { fdct4, fadst8 }, // DCT_ADST + { fdct4, fdct8 }, // DCT_DCT + { fadst4, fdct8 }, // ADST_DCT + { fdct4, fadst8 }, // DCT_ADST { fadst4, fadst8 }, // ADST_ADST - { fadst4, fdct8 }, // FLIPADST_DCT - { fdct4, fadst8 }, // DCT_FLIPADST + { fadst4, fdct8 }, // FLIPADST_DCT + { fdct4, fadst8 }, // DCT_FLIPADST { fadst4, fadst8 }, // FLIPADST_FLIPADST { fadst4, fadst8 }, // ADST_FLIPADST { fadst4, fadst8 }, // FLIPADST_ADST { fidtx4, fidtx8 }, // IDTX - { fdct4, fidtx8 }, // V_DCT - { fidtx4, fdct8 }, // H_DCT + { fdct4, fidtx8 }, // V_DCT + { fidtx4, fdct8 }, // H_DCT { fadst4, fidtx8 }, // V_ADST { fidtx4, fadst8 }, // H_ADST { fadst4, fidtx8 }, // V_FLIPADST @@ -1263,8 +1253,8 @@ static const transform_2d FHT_8x4[] = { }; #endif // CONFIG_EXT_TX -void vp10_fht4x4_c(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { if (tx_type == DCT_DCT) { vpx_fdct4x4_c(input, output, stride); } else { @@ -1280,29 +1270,24 @@ void vp10_fht4x4_c(const int16_t *input, tran_low_t *output, // Columns for (i = 0; i < 4; ++i) { - for (j = 0; j < 4; ++j) - temp_in[j] = input[j * stride + i] * 16; - if (i == 0 && temp_in[0]) - temp_in[0] += 1; + for (j = 0; j < 4; ++j) temp_in[j] = input[j * stride + i] * 16; + if (i == 0 && temp_in[0]) temp_in[0] += 1; ht.cols(temp_in, temp_out); - for (j = 0; j < 4; ++j) - out[j * 4 + i] = temp_out[j]; + for (j = 0; j < 4; ++j) out[j * 4 + i] = temp_out[j]; } // Rows for (i = 0; i < 4; ++i) { - for (j = 0; j < 4; ++j) - temp_in[j] = out[j + i * 4]; + for (j = 0; j < 4; ++j) temp_in[j] = out[j + i * 4]; ht.rows(temp_in, temp_out); - for (j = 0; j < 4; ++j) - output[j + i * 4] = (temp_out[j] + 1) >> 2; + for (j = 0; j < 4; ++j) output[j + i * 4] = (temp_out[j] + 1) >> 2; } } } #if CONFIG_EXT_TX -void vp10_fht4x8_c(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { const int n = 4; const int n2 = 8; tran_low_t out[8 * 4]; @@ -1314,8 +1299,7 @@ void vp10_fht4x8_c(const int16_t *input, tran_low_t *output, // Columns for (i = 0; i < n; ++i) { - for (j = 0; j < n2; ++j) - temp_in[j] = input[j * stride + i] * 8; + for (j = 0; j < n2; ++j) temp_in[j] = input[j * stride + i] * 8; ht.cols(temp_in, temp_out); for (j = 0; j < n2; ++j) out[j * n + i] = (tran_low_t)fdct_round_shift(temp_out[j] * Sqrt2); @@ -1323,17 +1307,15 @@ void vp10_fht4x8_c(const int16_t *input, tran_low_t *output, // Rows for (i = 0; i < n2; ++i) { - for (j = 0; j < n; ++j) - temp_in[j] = out[j + i * n]; + for (j = 0; j < n; ++j) temp_in[j] = out[j + i * n]; ht.rows(temp_in, temp_out); - for (j = 0; j < n; ++j) - output[j + i * n] = (temp_out[j] + 1) >> 2; + for (j = 0; j < n; ++j) output[j + i * n] = (temp_out[j] + 1) >> 2; } // Note: overall scale factor of transform is 8 times unitary } -void vp10_fht8x4_c(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { const int n = 4; const int n2 = 8; tran_low_t out[8 * 4]; @@ -1345,8 +1327,7 @@ void vp10_fht8x4_c(const int16_t *input, tran_low_t *output, // Columns for (i = 0; i < n2; ++i) { - for (j = 0; j < n; ++j) - temp_in[j] = input[j * stride + i] * 8; + for (j = 0; j < n; ++j) temp_in[j] = input[j * stride + i] * 8; ht.cols(temp_in, temp_out); for (j = 0; j < n; ++j) out[j * n2 + i] = (tran_low_t)fdct_round_shift(temp_out[j] * Sqrt2); @@ -1354,11 +1335,9 @@ void vp10_fht8x4_c(const int16_t *input, tran_low_t *output, // Rows for (i = 0; i < n; ++i) { - for (j = 0; j < n2; ++j) - temp_in[j] = out[j + i * n2]; + for (j = 0; j < n2; ++j) temp_in[j] = out[j + i * n2]; ht.rows(temp_in, temp_out); - for (j = 0; j < n2; ++j) - output[j + i * n2] = (temp_out[j] + 1) >> 2; + for (j = 0; j < n2; ++j) output[j + i * n2] = (temp_out[j] + 1) >> 2; } // Note: overall scale factor of transform is 8 times unitary } @@ -1366,13 +1345,11 @@ void vp10_fht8x4_c(const int16_t *input, tran_low_t *output, void vp10_fdct8x8_quant_c(const int16_t *input, int stride, tran_low_t *coeff_ptr, intptr_t n_coeffs, - int skip_block, - const int16_t *zbin_ptr, const int16_t *round_ptr, - const int16_t *quant_ptr, + int skip_block, const int16_t *zbin_ptr, + const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, - const int16_t *dequant_ptr, - uint16_t *eob_ptr, + const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan) { int eob = -1; @@ -1405,8 +1382,8 @@ void vp10_fdct8x8_quant_c(const int16_t *input, int stride, x3 = s0 - s3; t0 = (x0 + x1) * cospi_16_64; t1 = (x0 - x1) * cospi_16_64; - t2 = x2 * cospi_24_64 + x3 * cospi_8_64; - t3 = -x2 * cospi_8_64 + x3 * cospi_24_64; + t2 = x2 * cospi_24_64 + x3 * cospi_8_64; + t3 = -x2 * cospi_8_64 + x3 * cospi_24_64; output[0 * 8] = (tran_low_t)fdct_round_shift(t0); output[2 * 8] = (tran_low_t)fdct_round_shift(t2); output[4 * 8] = (tran_low_t)fdct_round_shift(t1); @@ -1425,10 +1402,10 @@ void vp10_fdct8x8_quant_c(const int16_t *input, int stride, x3 = s7 + t3; // stage 4 - t0 = x0 * cospi_28_64 + x3 * cospi_4_64; - t1 = x1 * cospi_12_64 + x2 * cospi_20_64; + t0 = x0 * cospi_28_64 + x3 * cospi_4_64; + t1 = x1 * cospi_12_64 + x2 * cospi_20_64; t2 = x2 * cospi_12_64 + x1 * -cospi_20_64; - t3 = x3 * cospi_28_64 + x0 * -cospi_4_64; + t3 = x3 * cospi_28_64 + x0 * -cospi_4_64; output[1 * 8] = (tran_low_t)fdct_round_shift(t0); output[3 * 8] = (tran_low_t)fdct_round_shift(t2); output[5 * 8] = (tran_low_t)fdct_round_shift(t1); @@ -1441,8 +1418,7 @@ void vp10_fdct8x8_quant_c(const int16_t *input, int stride, // Rows for (i = 0; i < 8; ++i) { fdct8(&intermediate[i * 8], &coeff_ptr[i * 8]); - for (j = 0; j < 8; ++j) - coeff_ptr[j + i * 8] /= 2; + for (j = 0; j < 8; ++j) coeff_ptr[j + i * 8] /= 2; } // TODO(jingning) Decide the need of these arguments after the @@ -1469,15 +1445,14 @@ void vp10_fdct8x8_quant_c(const int16_t *input, int stride, qcoeff_ptr[rc] = (tmp ^ coeff_sign) - coeff_sign; dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0]; - if (tmp) - eob = i; + if (tmp) eob = i; } } *eob_ptr = eob + 1; } -void vp10_fht8x8_c(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { if (tx_type == DCT_DCT) { vpx_fdct8x8_c(input, output, stride); } else { @@ -1493,17 +1468,14 @@ void vp10_fht8x8_c(const int16_t *input, tran_low_t *output, // Columns for (i = 0; i < 8; ++i) { - for (j = 0; j < 8; ++j) - temp_in[j] = input[j * stride + i] * 4; + for (j = 0; j < 8; ++j) temp_in[j] = input[j * stride + i] * 4; ht.cols(temp_in, temp_out); - for (j = 0; j < 8; ++j) - out[j * 8 + i] = temp_out[j]; + for (j = 0; j < 8; ++j) out[j * 8 + i] = temp_out[j]; } // Rows for (i = 0; i < 8; ++i) { - for (j = 0; j < 8; ++j) - temp_in[j] = out[j + i * 8]; + for (j = 0; j < 8; ++j) temp_in[j] = out[j + i * 8]; ht.rows(temp_in, temp_out); for (j = 0; j < 8; ++j) output[j + i * 8] = (temp_out[j] + (temp_out[j] < 0)) >> 1; @@ -1567,8 +1539,8 @@ void vp10_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride) { } } -void vp10_fht16x16_c(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_fht16x16_c(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { if (tx_type == DCT_DCT) { vpx_fdct16x16_c(input, output, stride); } else { @@ -1584,8 +1556,7 @@ void vp10_fht16x16_c(const int16_t *input, tran_low_t *output, // Columns for (i = 0; i < 16; ++i) { - for (j = 0; j < 16; ++j) - temp_in[j] = input[j * stride + i] * 4; + for (j = 0; j < 16; ++j) temp_in[j] = input[j * stride + i] * 4; ht.cols(temp_in, temp_out); for (j = 0; j < 16; ++j) out[j * 16 + i] = (temp_out[j] + 1 + (temp_out[j] < 0)) >> 2; @@ -1593,35 +1564,33 @@ void vp10_fht16x16_c(const int16_t *input, tran_low_t *output, // Rows for (i = 0; i < 16; ++i) { - for (j = 0; j < 16; ++j) - temp_in[j] = out[j + i * 16]; + for (j = 0; j < 16; ++j) temp_in[j] = out[j + i * 16]; ht.rows(temp_in, temp_out); - for (j = 0; j < 16; ++j) - output[j + i * 16] = temp_out[j]; + for (j = 0; j < 16; ++j) output[j + i * 16] = temp_out[j]; } } } #if CONFIG_VP9_HIGHBITDEPTH -void vp10_highbd_fht4x4_c(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_highbd_fht4x4_c(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { vp10_fht4x4_c(input, output, stride, tx_type); } #if CONFIG_EXT_TX -void vp10_highbd_fht8x4_c(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_highbd_fht8x4_c(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { vp10_fht8x4_c(input, output, stride, tx_type); } -void vp10_highbd_fht4x8_c(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_highbd_fht4x8_c(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { vp10_fht4x8_c(input, output, stride, tx_type); } #endif // CONFIG_EXT_TX -void vp10_highbd_fht8x8_c(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_highbd_fht8x8_c(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { vp10_fht8x8_c(input, output, stride, tx_type); } @@ -1631,14 +1600,14 @@ void vp10_highbd_fwht4x4_c(const int16_t *input, tran_low_t *output, } void vp10_highbd_fht16x16_c(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { + int stride, int tx_type) { vp10_fht16x16_c(input, output, stride, tx_type); } #endif // CONFIG_VP9_HIGHBITDEPTH #if CONFIG_EXT_TX -void vp10_fht32x32_c(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_fht32x32_c(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { if (tx_type == DCT_DCT) { vpx_fdct32x32_c(input, output, stride); } else { @@ -1652,8 +1621,7 @@ void vp10_fht32x32_c(const int16_t *input, tran_low_t *output, // Columns for (i = 0; i < 32; ++i) { - for (j = 0; j < 32; ++j) - temp_in[j] = input[j * stride + i] * 4; + for (j = 0; j < 32; ++j) temp_in[j] = input[j * stride + i] * 4; ht.cols(temp_in, temp_out); for (j = 0; j < 32; ++j) out[j * 32 + i] = (temp_out[j] + 1 + (temp_out[j] > 0)) >> 2; @@ -1661,8 +1629,7 @@ void vp10_fht32x32_c(const int16_t *input, tran_low_t *output, // Rows for (i = 0; i < 32; ++i) { - for (j = 0; j < 32; ++j) - temp_in[j] = out[j + i * 32]; + for (j = 0; j < 32; ++j) temp_in[j] = out[j + i * 32]; ht.rows(temp_in, temp_out); for (j = 0; j < 32; ++j) output[j + i * 32] = @@ -1672,8 +1639,7 @@ void vp10_fht32x32_c(const int16_t *input, tran_low_t *output, } // Forward identity transform. -void vp10_fwd_idtx_c(const int16_t *src_diff, - tran_low_t *coeff, int stride, +void vp10_fwd_idtx_c(const int16_t *src_diff, tran_low_t *coeff, int stride, int bs, int tx_type) { int r, c; const int shift = bs < 32 ? 3 : 2; diff --git a/vp10/encoder/encodeframe.c b/vp10/encoder/encodeframe.c index 88200c863..25e8ac516 100644 --- a/vp10/encoder/encodeframe.c +++ b/vp10/encoder/encodeframe.c @@ -53,15 +53,14 @@ #include "vp10/encoder/tokenize.h" #if CONFIG_VP9_HIGHBITDEPTH -# define IF_HBD(...) __VA_ARGS__ +#define IF_HBD(...) __VA_ARGS__ #else -# define IF_HBD(...) +#define IF_HBD(...) #endif // CONFIG_VP9_HIGHBITDEPTH -static void encode_superblock(VP10_COMP *cpi, ThreadData * td, - TOKENEXTRA **t, int output_enabled, - int mi_row, int mi_col, BLOCK_SIZE bsize, - PICK_MODE_CONTEXT *ctx); +static void encode_superblock(VP10_COMP *cpi, ThreadData *td, TOKENEXTRA **t, + int output_enabled, int mi_row, int mi_col, + BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx); #if CONFIG_SUPERTX static int check_intra_b(PICK_MODE_CONTEXT *ctx); @@ -78,24 +77,19 @@ static void predict_superblock(VP10_COMP *cpi, ThreadData *td, static int check_supertx_sb(BLOCK_SIZE bsize, TX_SIZE supertx_size, PC_TREE *pc_tree); static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - int mi_row, int mi_col, - int mi_row_ori, int mi_col_ori, + const TileInfo *const tile, int mi_row, + int mi_col, int mi_row_ori, int mi_col_ori, int output_enabled, BLOCK_SIZE bsize, - BLOCK_SIZE top_bsize, - uint8_t *dst_buf[3], int dst_stride[3], - PC_TREE *pc_tree); + BLOCK_SIZE top_bsize, uint8_t *dst_buf[3], + int dst_stride[3], PC_TREE *pc_tree); static void update_state_sb_supertx(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - int mi_row, int mi_col, - BLOCK_SIZE bsize, + const TileInfo *const tile, int mi_row, + int mi_col, BLOCK_SIZE bsize, int output_enabled, PC_TREE *pc_tree); static void rd_supertx_sb(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - int mi_row, int mi_col, BLOCK_SIZE bsize, - int *tmp_rate, int64_t *tmp_dist, - TX_TYPE *best_tx, - PC_TREE *pc_tree); + const TileInfo *const tile, int mi_row, int mi_col, + BLOCK_SIZE bsize, int *tmp_rate, int64_t *tmp_dist, + TX_TYPE *best_tx, PC_TREE *pc_tree); #endif // CONFIG_SUPERTX // This is used as a reference when computing the source variance for the @@ -103,120 +97,113 @@ static void rd_supertx_sb(VP10_COMP *cpi, ThreadData *td, // Eventually this should be replaced by custom no-reference routines, // which will be faster. static const uint8_t VP10_VAR_OFFS[MAX_SB_SIZE] = { - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, #if CONFIG_EXT_PARTITION - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128 + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 #endif // CONFIG_EXT_PARTITION }; #if CONFIG_VP9_HIGHBITDEPTH static const uint16_t VP10_HIGH_VAR_OFFS_8[MAX_SB_SIZE] = { - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, #if CONFIG_EXT_PARTITION - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128 + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 #endif // CONFIG_EXT_PARTITION }; static const uint16_t VP10_HIGH_VAR_OFFS_10[MAX_SB_SIZE] = { - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, #if CONFIG_EXT_PARTITION - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, - 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4, 128*4 + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, + 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4, 128 * 4 #endif // CONFIG_EXT_PARTITION }; static const uint16_t VP10_HIGH_VAR_OFFS_12[MAX_SB_SIZE] = { - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, #if CONFIG_EXT_PARTITION - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, - 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16, 128*16 + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, 128 * 16, + 128 * 16 #endif // CONFIG_EXT_PARTITION }; #endif // CONFIG_VP9_HIGHBITDEPTH unsigned int vp10_get_sby_perpixel_variance(VP10_COMP *cpi, - const struct buf_2d *ref, - BLOCK_SIZE bs) { + const struct buf_2d *ref, + BLOCK_SIZE bs) { unsigned int sse; - const unsigned int var = cpi->fn_ptr[bs].vf(ref->buf, ref->stride, - VP10_VAR_OFFS, 0, &sse); + const unsigned int var = + cpi->fn_ptr[bs].vf(ref->buf, ref->stride, VP10_VAR_OFFS, 0, &sse); return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]); } #if CONFIG_VP9_HIGHBITDEPTH -unsigned int vp10_high_get_sby_perpixel_variance( - VP10_COMP *cpi, const struct buf_2d *ref, BLOCK_SIZE bs, int bd) { +unsigned int vp10_high_get_sby_perpixel_variance(VP10_COMP *cpi, + const struct buf_2d *ref, + BLOCK_SIZE bs, int bd) { unsigned int var, sse; switch (bd) { case 10: var = cpi->fn_ptr[bs].vf(ref->buf, ref->stride, - CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_10), - 0, &sse); + CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_10), 0, + &sse); break; case 12: var = cpi->fn_ptr[bs].vf(ref->buf, ref->stride, - CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_12), - 0, &sse); + CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_12), 0, + &sse); break; case 8: default: - var = cpi->fn_ptr[bs].vf(ref->buf, ref->stride, - CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_8), - 0, &sse); + var = + cpi->fn_ptr[bs].vf(ref->buf, ref->stride, + CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_8), 0, &sse); break; } return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]); @@ -239,12 +226,10 @@ static unsigned int get_sby_perpixel_diff_variance(VP10_COMP *cpi, } static BLOCK_SIZE get_rd_var_based_fixed_partition(VP10_COMP *cpi, - MACROBLOCK *x, - int mi_row, + MACROBLOCK *x, int mi_row, int mi_col) { - unsigned int var = get_sby_perpixel_diff_variance(cpi, &x->plane[0].src, - mi_row, mi_col, - BLOCK_64X64); + unsigned int var = get_sby_perpixel_diff_variance( + cpi, &x->plane[0].src, mi_row, mi_col, BLOCK_64X64); if (var < 8) return BLOCK_64X64; else if (var < 128) @@ -257,10 +242,8 @@ static BLOCK_SIZE get_rd_var_based_fixed_partition(VP10_COMP *cpi, // Lighter version of set_offsets that only sets the mode info // pointers. -static void set_mode_info_offsets(VP10_COMP *const cpi, - MACROBLOCK *const x, - MACROBLOCKD *const xd, - int mi_row, +static void set_mode_info_offsets(VP10_COMP *const cpi, MACROBLOCK *const x, + MACROBLOCKD *const xd, int mi_row, int mi_col) { VP10_COMMON *const cm = &cpi->common; const int idx_str = xd->mi_stride * mi_row + mi_col; @@ -271,9 +254,8 @@ static void set_mode_info_offsets(VP10_COMP *const cpi, static void set_offsets_without_segment_id(VP10_COMP *cpi, const TileInfo *const tile, - MACROBLOCK *const x, - int mi_row, int mi_col, - BLOCK_SIZE bsize) { + MACROBLOCK *const x, int mi_row, + int mi_col, BLOCK_SIZE bsize) { VP10_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; const int mi_width = num_8x8_blocks_wide_lookup[bsize]; @@ -286,7 +268,7 @@ static void set_offsets_without_segment_id(VP10_COMP *cpi, #if CONFIG_VAR_TX xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); xd->max_tx_size = max_txsize_lookup[bsize]; #endif @@ -302,8 +284,8 @@ static void set_offsets_without_segment_id(VP10_COMP *cpi, // Set up distance of MB to edge of frame in 1/8th pel units. assert(!(mi_col & (mi_width - 1)) && !(mi_row & (mi_height - 1))); - set_mi_row_col(xd, tile, mi_row, mi_height, mi_col, mi_width, - cm->mi_rows, cm->mi_cols); + set_mi_row_col(xd, tile, mi_row, mi_height, mi_col, mi_width, cm->mi_rows, + cm->mi_cols); // Set up source buffers. vp10_setup_src_planes(x, cpi->Source, mi_row, mi_col); @@ -331,8 +313,8 @@ static void set_offsets(VP10_COMP *cpi, const TileInfo *const tile, // Setup segment ID. if (seg->enabled) { if (!cpi->vaq_refresh) { - const uint8_t *const map = seg->update_map ? cpi->segmentation_map - : cm->last_frame_seg_map; + const uint8_t *const map = + seg->update_map ? cpi->segmentation_map : cm->last_frame_seg_map; mbmi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col); } vp10_init_plane_quantizers(cpi, x, mbmi->segment_id); @@ -350,8 +332,8 @@ static void set_offsets(VP10_COMP *cpi, const TileInfo *const tile, #if CONFIG_SUPERTX static void set_offsets_supertx(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - int mi_row, int mi_col, BLOCK_SIZE bsize) { + const TileInfo *const tile, int mi_row, + int mi_col, BLOCK_SIZE bsize) { MACROBLOCK *const x = &td->mb; VP10_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; @@ -362,14 +344,13 @@ static void set_offsets_supertx(VP10_COMP *cpi, ThreadData *td, // Set up distance of MB to edge of frame in 1/8th pel units. assert(!(mi_col & (mi_width - 1)) && !(mi_row & (mi_height - 1))); - set_mi_row_col(xd, tile, mi_row, mi_height, mi_col, mi_width, - cm->mi_rows, cm->mi_cols); + set_mi_row_col(xd, tile, mi_row, mi_height, mi_col, mi_width, cm->mi_rows, + cm->mi_cols); } static void set_offsets_extend(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - int mi_row_pred, int mi_col_pred, - int mi_row_ori, int mi_col_ori, + const TileInfo *const tile, int mi_row_pred, + int mi_col_pred, int mi_row_ori, int mi_col_ori, BLOCK_SIZE bsize_pred) { // Used in supertx // (mi_row_ori, mi_col_ori, bsize_ori): region for mv @@ -393,8 +374,8 @@ static void set_offsets_extend(VP10_COMP *cpi, ThreadData *td, assert(!(mi_col_pred & (mi_width - 1)) && !(mi_row_pred & (mi_height - 1))); set_mi_row_col(xd, tile, mi_row_pred, mi_height, mi_col_pred, mi_width, cm->mi_rows, cm->mi_cols); - xd->up_available = (mi_row_ori > tile->mi_row_start); - xd->left_available = (mi_col_ori > tile->mi_col_start); + xd->up_available = (mi_row_ori > tile->mi_row_start); + xd->left_available = (mi_col_ori > tile->mi_col_start); // R/D setup. x->rddiv = cpi->rd.RDDIV; @@ -402,9 +383,8 @@ static void set_offsets_extend(VP10_COMP *cpi, ThreadData *td, } static void set_segment_id_supertx(const VP10_COMP *const cpi, - MACROBLOCK *const x, - const int mi_row, const int mi_col, - const BLOCK_SIZE bsize) { + MACROBLOCK *const x, const int mi_row, + const int mi_col, const BLOCK_SIZE bsize) { const VP10_COMMON *cm = &cpi->common; const struct segmentation *seg = &cm->seg; const int miw = @@ -421,10 +401,10 @@ static void set_segment_id_supertx(const VP10_COMP *const cpi, x->encode_breakout = cpi->encode_breakout; } else { // Find the minimum segment_id - for (r = 0 ; r < mih ; r++) - for (c = 0 ; c < miw ; c++) - seg_id_supertx = VPXMIN(mip[r * cm->mi_stride + c]->mbmi.segment_id, - seg_id_supertx); + for (r = 0; r < mih; r++) + for (c = 0; c < miw; c++) + seg_id_supertx = + VPXMIN(mip[r * cm->mi_stride + c]->mbmi.segment_id, seg_id_supertx); assert(0 <= seg_id_supertx && seg_id_supertx < MAX_SEGMENTS); // Initialize plane quantisers @@ -433,16 +413,14 @@ static void set_segment_id_supertx(const VP10_COMP *const cpi, } // Assign the the segment_id back to segment_id_supertx - for (r = 0 ; r < mih ; r++) - for (c = 0 ; c < miw ; c++) + for (r = 0; r < mih; r++) + for (c = 0; c < miw; c++) mip[r * cm->mi_stride + c]->mbmi.segment_id_supertx = seg_id_supertx; } #endif // CONFIG_SUPERTX -static void set_block_size(VP10_COMP * const cpi, - MACROBLOCK *const x, - MACROBLOCKD *const xd, - int mi_row, int mi_col, +static void set_block_size(VP10_COMP *const cpi, MACROBLOCK *const x, + MACROBLOCKD *const xd, int mi_row, int mi_col, BLOCK_SIZE bsize) { if (cpi->common.mi_cols > mi_col && cpi->common.mi_rows > mi_row) { set_mode_info_offsets(cpi, x, xd, mi_row, mi_col); @@ -450,22 +428,17 @@ static void set_block_size(VP10_COMP * const cpi, } } -static void set_vt_partitioning(VP10_COMP *cpi, - MACROBLOCK *const x, - MACROBLOCKD *const xd, - VAR_TREE *vt, - int mi_row, - int mi_col, - const int64_t *const threshold, - const BLOCK_SIZE *const bsize_min) { - VP10_COMMON * const cm = &cpi->common; +static void set_vt_partitioning(VP10_COMP *cpi, MACROBLOCK *const x, + MACROBLOCKD *const xd, VAR_TREE *vt, int mi_row, + int mi_col, const int64_t *const threshold, + const BLOCK_SIZE *const bsize_min) { + VP10_COMMON *const cm = &cpi->common; const int hbw = num_8x8_blocks_wide_lookup[vt->bsize] / 2; const int hbh = num_8x8_blocks_high_lookup[vt->bsize] / 2; const int has_cols = mi_col + hbw < cm->mi_cols; const int has_rows = mi_row + hbh < cm->mi_rows; - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return; + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; assert(vt->bsize >= BLOCK_8X8); @@ -476,15 +449,13 @@ static void set_vt_partitioning(VP10_COMP *cpi, return; } - if (vt->force_split || (!has_cols && !has_rows)) - goto split; + if (vt->force_split || (!has_cols && !has_rows)) goto split; // For bsize=bsize_min (16x16/8x8 for 8x8/4x4 downsampling), select if // variance is below threshold, otherwise split will be selected. // No check for vert/horiz split as too few samples for variance. if (vt->bsize == bsize_min[0]) { - if (has_cols && has_rows && - vt->variances.none.variance < threshold[0]) { + if (has_cols && has_rows && vt->variances.none.variance < threshold[0]) { set_block_size(cpi, x, xd, mi_row, mi_col, vt->bsize); return; } else { @@ -501,12 +472,11 @@ static void set_vt_partitioning(VP10_COMP *cpi, // For key frame: take split for bsize above 32X32 or very high variance. if (cm->frame_type == KEY_FRAME && (vt->bsize > BLOCK_32X32 || - vt->variances.none.variance > (threshold[0] << 4))) { + vt->variances.none.variance > (threshold[0] << 4))) { goto split; } // If variance is low, take the bsize (no split). - if (has_cols && has_rows && - vt->variances.none.variance < threshold[0]) { + if (has_cols && has_rows && vt->variances.none.variance < threshold[0]) { set_block_size(cpi, x, xd, mi_row, mi_col, vt->bsize); return; } @@ -535,22 +505,17 @@ static void set_vt_partitioning(VP10_COMP *cpi, } } -split: - { - set_vt_partitioning(cpi, x, xd, vt->split[0], - mi_row, mi_col, - threshold + 1, bsize_min + 1); - set_vt_partitioning(cpi, x, xd, vt->split[1], - mi_row, mi_col + hbw, - threshold + 1, bsize_min + 1); - set_vt_partitioning(cpi, x, xd, vt->split[2], - mi_row + hbh, mi_col, - threshold + 1, bsize_min + 1); - set_vt_partitioning(cpi, x, xd, vt->split[3], - mi_row + hbh, mi_col + hbw, - threshold + 1, bsize_min + 1); - return; - } +split : { + set_vt_partitioning(cpi, x, xd, vt->split[0], mi_row, mi_col, threshold + 1, + bsize_min + 1); + set_vt_partitioning(cpi, x, xd, vt->split[1], mi_row, mi_col + hbw, + threshold + 1, bsize_min + 1); + set_vt_partitioning(cpi, x, xd, vt->split[2], mi_row + hbh, mi_col, + threshold + 1, bsize_min + 1); + set_vt_partitioning(cpi, x, xd, vt->split[3], mi_row + hbh, mi_col + hbw, + threshold + 1, bsize_min + 1); + return; +} } // Set the variance split thresholds for following the block sizes: @@ -561,8 +526,8 @@ static void set_vbp_thresholds(VP10_COMP *cpi, int64_t thresholds[], int q) { VP10_COMMON *const cm = &cpi->common; const int is_key_frame = (cm->frame_type == KEY_FRAME); const int threshold_multiplier = is_key_frame ? 20 : 1; - const int64_t threshold_base = (int64_t)(threshold_multiplier * - cpi->y_dequant[q][1]); + const int64_t threshold_base = + (int64_t)(threshold_multiplier * cpi->y_dequant[q][1]); if (is_key_frame) { thresholds[1] = threshold_base; thresholds[2] = threshold_base >> 2; @@ -601,8 +566,9 @@ void vp10_set_variance_partition_thresholds(VP10_COMP *cpi, int q) { if (cm->width <= 352 && cm->height <= 288) cpi->vbp_threshold_sad = 100; else - cpi->vbp_threshold_sad = (cpi->y_dequant[q][1] << 1) > 1000 ? - (cpi->y_dequant[q][1] << 1) : 1000; + cpi->vbp_threshold_sad = (cpi->y_dequant[q][1] << 1) > 1000 + ? (cpi->y_dequant[q][1] << 1) + : 1000; cpi->vbp_bsize_min = BLOCK_16X16; } cpi->vbp_threshold_minmax = 15 + (q >> 3); @@ -615,8 +581,7 @@ static int compute_minmax_8x8(const uint8_t *src, int src_stride, #if CONFIG_VP9_HIGHBITDEPTH int highbd, #endif - int pixels_wide, - int pixels_high) { + int pixels_wide, int pixels_high) { int k; int minmax_max = 0; int minmax_min = 255; @@ -631,23 +596,18 @@ static int compute_minmax_8x8(const uint8_t *src, int src_stride, const int ref_offset = y8_idx * ref_stride + x8_idx; #if CONFIG_VP9_HIGHBITDEPTH if (highbd) { - vpx_highbd_minmax_8x8(src + src_offset, src_stride, - ref + ref_offset, ref_stride, - &min, &max); + vpx_highbd_minmax_8x8(src + src_offset, src_stride, ref + ref_offset, + ref_stride, &min, &max); } else { - vpx_minmax_8x8(src + src_offset, src_stride, - ref + ref_offset, ref_stride, - &min, &max); + vpx_minmax_8x8(src + src_offset, src_stride, ref + ref_offset, + ref_stride, &min, &max); } #else - vpx_minmax_8x8(src + src_offset, src_stride, - ref + ref_offset, ref_stride, + vpx_minmax_8x8(src + src_offset, src_stride, ref + ref_offset, ref_stride, &min, &max); #endif - if ((max - min) > minmax_max) - minmax_max = (max - min); - if ((max - min) < minmax_min) - minmax_min = (max - min); + if ((max - min) > minmax_max) minmax_max = (max - min); + if ((max - min) < minmax_min) minmax_min = (max - min); } } return (minmax_max - minmax_min); @@ -687,8 +647,7 @@ static void init_variance_tree(VAR_TREE *const vt, #if CONFIG_VP9_HIGHBITDEPTH const int highbd, #endif - BLOCK_SIZE bsize, - BLOCK_SIZE leaf_size, + BLOCK_SIZE bsize, BLOCK_SIZE leaf_size, const int width, const int height, const uint8_t *const src, const int src_stride, const uint8_t *const ref, const int ref_stride) { @@ -718,42 +677,34 @@ static void init_variance_tree(VAR_TREE *const vt, #if CONFIG_VP9_HIGHBITDEPTH highbd, #endif // CONFIG_VP9_HIGHBITDEPTH - subsize, leaf_size, - VPXMIN(px, width), VPXMIN(px, height), - src, src_stride, - ref, ref_stride); + subsize, leaf_size, VPXMIN(px, width), + VPXMIN(px, height), src, src_stride, ref, ref_stride); init_variance_tree(vt->split[1], #if CONFIG_VP9_HIGHBITDEPTH highbd, #endif // CONFIG_VP9_HIGHBITDEPTH - subsize, leaf_size, - width - px, VPXMIN(px, height), - src + px, src_stride, - ref + px, ref_stride); + subsize, leaf_size, width - px, VPXMIN(px, height), + src + px, src_stride, ref + px, ref_stride); init_variance_tree(vt->split[2], #if CONFIG_VP9_HIGHBITDEPTH highbd, #endif // CONFIG_VP9_HIGHBITDEPTH - subsize, leaf_size, - VPXMIN(px, width), height - px, - src + px * src_stride, src_stride, - ref + px * ref_stride, ref_stride); + subsize, leaf_size, VPXMIN(px, width), height - px, + src + px * src_stride, src_stride, ref + px * ref_stride, + ref_stride); init_variance_tree(vt->split[3], #if CONFIG_VP9_HIGHBITDEPTH highbd, #endif // CONFIG_VP9_HIGHBITDEPTH - subsize, leaf_size, - width - px, height - px, + subsize, leaf_size, width - px, height - px, src + px * src_stride + px, src_stride, ref + px * ref_stride + px, ref_stride); } } - // Fill the variance tree based on averaging pixel values (sub-sampling), at // the leaf node size. -static void fill_variance_tree(VAR_TREE *const vt, - const BLOCK_SIZE leaf_size) { +static void fill_variance_tree(VAR_TREE *const vt, const BLOCK_SIZE leaf_size) { if (vt->bsize > leaf_size) { fill_variance_tree(vt->split[0], leaf_size); fill_variance_tree(vt->split[1], leaf_size); @@ -795,22 +746,20 @@ static void refine_variance_tree(VAR_TREE *const vt, const int64_t threshold) { refine_variance_tree(vt->split[2], threshold); refine_variance_tree(vt->split[3], threshold); - if (vt->bsize <= BLOCK_16X16) - fill_variance_node(vt); + if (vt->bsize <= BLOCK_16X16) fill_variance_node(vt); } else if (vt->width <= 0 || vt->height <= 0) { fill_variance(0, 0, 0, &vt->variances.none); } else { const int src_avg = avg_4x4(vt->src, vt->src_stride IF_HBD(, vt->highbd)); const int ref_avg = avg_4x4(vt->ref, vt->ref_stride IF_HBD(, vt->highbd)); const int sum = src_avg - ref_avg; - const unsigned int sse = sum * sum; + const unsigned int sse = sum * sum; assert(vt->bsize == BLOCK_4X4); fill_variance(sse, sum, 0, &vt->variances.none); } } -static int check_split_key_frame(VAR_TREE *const vt, - const int64_t threshold) { +static int check_split_key_frame(VAR_TREE *const vt, const int64_t threshold) { if (vt->bsize == BLOCK_32X32) { vt->force_split = vt->variances.none.variance > threshold; } else { @@ -822,36 +771,32 @@ static int check_split_key_frame(VAR_TREE *const vt, return vt->force_split; } -static int check_split(VP10_COMP *const cpi, - VAR_TREE *const vt, - const int segment_id, - const int64_t *const thresholds - ) { +static int check_split(VP10_COMP *const cpi, VAR_TREE *const vt, + const int segment_id, const int64_t *const thresholds) { if (vt->bsize == BLOCK_16X16) { vt->force_split = vt->variances.none.variance > thresholds[0]; - if (!vt->force_split && - vt->variances.none.variance > thresholds[-1] && - !cyclic_refresh_segment_id_boosted(segment_id)) { + if (!vt->force_split && vt->variances.none.variance > thresholds[-1] && + !cyclic_refresh_segment_id_boosted(segment_id)) { // We have some nominal amount of 16x16 variance (based on average), // compute the minmax over the 8x8 sub-blocks, and if above threshold, // force split to 8x8 block for this 16x16 block. - int minmax = compute_minmax_8x8(vt->src, vt->src_stride, - vt->ref, vt->ref_stride, + int minmax = + compute_minmax_8x8(vt->src, vt->src_stride, vt->ref, vt->ref_stride, #if CONFIG_VP9_HIGHBITDEPTH - vt->highbd, + vt->highbd, #endif - vt->width, vt->height); + vt->width, vt->height); vt->force_split = minmax > cpi->vbp_threshold_minmax; } } else { - vt->force_split |= check_split(cpi, vt->split[0], - segment_id, thresholds + 1); - vt->force_split |= check_split(cpi, vt->split[1], - segment_id, thresholds + 1); - vt->force_split |= check_split(cpi, vt->split[2], - segment_id, thresholds + 1); - vt->force_split |= check_split(cpi, vt->split[3], - segment_id, thresholds + 1); + vt->force_split |= + check_split(cpi, vt->split[0], segment_id, thresholds + 1); + vt->force_split |= + check_split(cpi, vt->split[1], segment_id, thresholds + 1); + vt->force_split |= + check_split(cpi, vt->split[2], segment_id, thresholds + 1); + vt->force_split |= + check_split(cpi, vt->split[3], segment_id, thresholds + 1); if (vt->bsize == BLOCK_32X32 && !vt->force_split) { vt->force_split = vt->variances.none.variance > thresholds[0]; @@ -864,10 +809,8 @@ static int check_split(VP10_COMP *const cpi, // This function chooses partitioning based on the variance between source and // reconstructed last (or golden), where variance is computed for down-sampled // inputs. -static void choose_partitioning(VP10_COMP *const cpi, - ThreadData *const td, - const TileInfo *const tile, - MACROBLOCK *const x, +static void choose_partitioning(VP10_COMP *const cpi, ThreadData *const td, + const TileInfo *const tile, MACROBLOCK *const x, const int mi_row, const int mi_col) { VP10_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; @@ -880,19 +823,11 @@ static void choose_partitioning(VP10_COMP *const cpi, int pixels_wide = 8 * num_8x8_blocks_wide_lookup[cm->sb_size]; int pixels_high = 8 * num_8x8_blocks_high_lookup[cm->sb_size]; int64_t thresholds[5] = { - cpi->vbp_thresholds[0], - cpi->vbp_thresholds[1], - cpi->vbp_thresholds[2], - cpi->vbp_thresholds[3], - cpi->vbp_thresholds[4], - }; - BLOCK_SIZE bsize_min[5] = { - BLOCK_16X16, - BLOCK_16X16, - BLOCK_16X16, - cpi->vbp_bsize_min, - BLOCK_8X8 + cpi->vbp_thresholds[0], cpi->vbp_thresholds[1], cpi->vbp_thresholds[2], + cpi->vbp_thresholds[3], cpi->vbp_thresholds[4], }; + BLOCK_SIZE bsize_min[5] = { BLOCK_16X16, BLOCK_16X16, BLOCK_16X16, + cpi->vbp_bsize_min, BLOCK_8X8 }; const int start_level = cm->sb_size == BLOCK_64X64 ? 1 : 0; const int64_t *const thre = thresholds + start_level; const BLOCK_SIZE *const bmin = bsize_min + start_level; @@ -903,8 +838,8 @@ static void choose_partitioning(VP10_COMP *const cpi, int segment_id = CR_SEGMENT_ID_BASE; if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled) { - const uint8_t *const map = cm->seg.update_map ? cpi->segmentation_map : - cm->last_frame_seg_map; + const uint8_t *const map = + cm->seg.update_map ? cpi->segmentation_map : cm->last_frame_seg_map; segment_id = get_segment_id(cm, map, cm->sb_size, mi_row, mi_col); if (cyclic_refresh_segment_id_boosted(segment_id)) { @@ -915,10 +850,8 @@ static void choose_partitioning(VP10_COMP *const cpi, set_offsets(cpi, tile, x, mi_row, mi_col, cm->sb_size); - if (xd->mb_to_right_edge < 0) - pixels_wide += (xd->mb_to_right_edge >> 3); - if (xd->mb_to_bottom_edge < 0) - pixels_high += (xd->mb_to_bottom_edge >> 3); + if (xd->mb_to_right_edge < 0) pixels_wide += (xd->mb_to_right_edge >> 3); + if (xd->mb_to_bottom_edge < 0) pixels_high += (xd->mb_to_bottom_edge >> 3); src = x->plane[0].src.buf; src_stride = x->plane[0].src.stride; @@ -948,24 +881,22 @@ static void choose_partitioning(VP10_COMP *const cpi, if (yv12_g && yv12_g != yv12) { vp10_setup_pre_planes(xd, 0, yv12_g, mi_row, mi_col, - &cm->frame_refs[GOLDEN_FRAME - 1].sf); - y_sad_g = cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf, - x->plane[0].src.stride, - xd->plane[0].pre[0].buf, - xd->plane[0].pre[0].stride); + &cm->frame_refs[GOLDEN_FRAME - 1].sf); + y_sad_g = cpi->fn_ptr[bsize].sdf( + x->plane[0].src.buf, x->plane[0].src.stride, xd->plane[0].pre[0].buf, + xd->plane[0].pre[0].stride); } else { y_sad_g = UINT_MAX; } vp10_setup_pre_planes(xd, 0, yv12, mi_row, mi_col, - &cm->frame_refs[LAST_FRAME - 1].sf); + &cm->frame_refs[LAST_FRAME - 1].sf); mbmi->ref_frame[0] = LAST_FRAME; mbmi->ref_frame[1] = NONE; mbmi->sb_type = cm->sb_size; mbmi->mv[0].as_int = 0; #if CONFIG_DUAL_FILTER - for (i = 0; i < 4; ++i) - mbmi->interp_filter[i] = BILINEAR; + for (i = 0; i < 4; ++i) mbmi->interp_filter[i] = BILINEAR; #else mbmi->interp_filter = BILINEAR; #endif @@ -974,7 +905,7 @@ static void choose_partitioning(VP10_COMP *const cpi, if (y_sad_g < y_sad) { vp10_setup_pre_planes(xd, 0, yv12_g, mi_row, mi_col, - &cm->frame_refs[GOLDEN_FRAME - 1].sf); + &cm->frame_refs[GOLDEN_FRAME - 1].sf); mbmi->ref_frame[0] = GOLDEN_FRAME; mbmi->mv[0].as_int = 0; y_sad = y_sad_g; @@ -985,15 +916,15 @@ static void choose_partitioning(VP10_COMP *const cpi, vp10_build_inter_predictors_sb(xd, mi_row, mi_col, cm->sb_size); for (i = 1; i < MAX_MB_PLANE; ++i) { - struct macroblock_plane *p = &x->plane[i]; + struct macroblock_plane *p = &x->plane[i]; struct macroblockd_plane *pd = &xd->plane[i]; const BLOCK_SIZE bs = get_plane_block_size(bsize, pd); if (bs == BLOCK_INVALID) uv_sad = UINT_MAX; else - uv_sad = cpi->fn_ptr[bs].sdf(p->src.buf, p->src.stride, - pd->dst.buf, pd->dst.stride); + uv_sad = cpi->fn_ptr[bs].sdf(p->src.buf, p->src.stride, pd->dst.buf, + pd->dst.stride); x->color_sensitivity[i - 1] = uv_sad > (y_sad >> 2); } @@ -1015,32 +946,25 @@ static void choose_partitioning(VP10_COMP *const cpi, #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { switch (xd->bd) { - case 10: - ref = CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_10); - break; - case 12: - ref = CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_12); - break; + case 10: ref = CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_10); break; + case 12: ref = CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_12); break; case 8: - default: - ref = CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_8); - break; + default: ref = CONVERT_TO_BYTEPTR(VP10_HIGH_VAR_OFFS_8); break; } } #endif // CONFIG_VP9_HIGHBITDEPTH } - init_variance_tree(vt, + init_variance_tree( + vt, #if CONFIG_VP9_HIGHBITDEPTH - xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, + xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, #endif // CONFIG_VP9_HIGHBITDEPTH - cm->sb_size, - (is_key_frame || low_res) ? BLOCK_4X4 : BLOCK_8X8, - pixels_wide, pixels_high, - src, src_stride, ref, ref_stride); + cm->sb_size, (is_key_frame || low_res) ? BLOCK_4X4 : BLOCK_8X8, + pixels_wide, pixels_high, src, src_stride, ref, ref_stride); // Fill in the entire tree of variances and compute splits. - if (is_key_frame) { + if (is_key_frame) { fill_variance_tree(vt, BLOCK_4X4); check_split_key_frame(vt, thre[1]); } else { @@ -1060,15 +984,16 @@ static void choose_partitioning(VP10_COMP *const cpi, } #if CONFIG_DUAL_FILTER -static void reset_intmv_filter_type(VP10_COMMON *cm, - MACROBLOCKD *xd, MB_MODE_INFO *mbmi) { +static void reset_intmv_filter_type(VP10_COMMON *cm, MACROBLOCKD *xd, + MB_MODE_INFO *mbmi) { int dir; for (dir = 0; dir < 2; ++dir) { if (!has_subpel_mv_component(xd->mi[0], xd, dir) && (mbmi->ref_frame[1] == NONE || !has_subpel_mv_component(xd->mi[0], xd, dir + 2))) - mbmi->interp_filter[dir] = (cm->interp_filter == SWITCHABLE) ? - EIGHTTAP_REGULAR : cm->interp_filter; + mbmi->interp_filter[dir] = (cm->interp_filter == SWITCHABLE) + ? EIGHTTAP_REGULAR + : cm->interp_filter; mbmi->interp_filter[dir + 2] = mbmi->interp_filter[dir]; } } @@ -1093,14 +1018,12 @@ static void update_global_motion_used(PREDICTION_MODE mode, VP10_COMP *cpi) { if (mode == ZEROMV) { ++cpi->global_motion_used[mbmi->ref_frame[0]]; - if (has_second_ref(mbmi)) - ++cpi->global_motion_used[mbmi->ref_frame[1]]; + if (has_second_ref(mbmi)) ++cpi->global_motion_used[mbmi->ref_frame[1]]; } } #endif // CONFIG_GLOBAL_MOTION -static void update_state(VP10_COMP *cpi, ThreadData *td, - PICK_MODE_CONTEXT *ctx, +static void update_state(VP10_COMP *cpi, ThreadData *td, PICK_MODE_CONTEXT *ctx, int mi_row, int mi_col, BLOCK_SIZE bsize, int output_enabled) { int i, x_idx, y; @@ -1118,8 +1041,7 @@ static void update_state(VP10_COMP *cpi, ThreadData *td, const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type]; const int x_mis = VPXMIN(bw, cm->mi_cols - mi_col); const int y_mis = VPXMIN(bh, cm->mi_rows - mi_row); - MV_REF *const frame_mvs = - cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col; + MV_REF *const frame_mvs = cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col; int w, h; const int mis = cm->mi_stride; @@ -1144,13 +1066,13 @@ static void update_state(VP10_COMP *cpi, ThreadData *td, #if CONFIG_REF_MV rf_type = vp10_ref_frame_type(mbmi->ref_frame); - if (x->mbmi_ext->ref_mv_count[rf_type] > 1 && - mbmi->sb_type >= BLOCK_8X8 && + if (x->mbmi_ext->ref_mv_count[rf_type] > 1 && mbmi->sb_type >= BLOCK_8X8 && mbmi->mode == NEWMV) { for (i = 0; i < 1 + has_second_ref(mbmi); ++i) { - int_mv this_mv = (i == 0) ? - x->mbmi_ext->ref_mv_stack[rf_type][mbmi->ref_mv_idx].this_mv : - x->mbmi_ext->ref_mv_stack[rf_type][mbmi->ref_mv_idx].comp_mv; + int_mv this_mv = + (i == 0) + ? x->mbmi_ext->ref_mv_stack[rf_type][mbmi->ref_mv_idx].this_mv + : x->mbmi_ext->ref_mv_stack[rf_type][mbmi->ref_mv_idx].comp_mv; clamp_mv_ref(&this_mv.as_mv, xd->n8_w << 3, xd->n8_h << 3, xd); x->mbmi_ext->ref_mvs[mbmi->ref_frame[i]][0] = this_mv; mbmi->pred_mv[i] = this_mv; @@ -1162,17 +1084,15 @@ static void update_state(VP10_COMP *cpi, ThreadData *td, if (seg->enabled) { // For in frame complexity AQ copy the segment id from the segment map. if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { - const uint8_t *const map = seg->update_map ? cpi->segmentation_map - : cm->last_frame_seg_map; - mi_addr->mbmi.segment_id = - get_segment_id(cm, map, bsize, mi_row, mi_col); + const uint8_t *const map = + seg->update_map ? cpi->segmentation_map : cm->last_frame_seg_map; + mi_addr->mbmi.segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col); } // Else for cyclic refresh mode update the segment map, set the segment id // and then update the quantizer. if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) { - vp10_cyclic_refresh_update_segment(cpi, &xd->mi[0]->mbmi, mi_row, - mi_col, bsize, ctx->rate, ctx->dist, - x->skip); + vp10_cyclic_refresh_update_segment(cpi, &xd->mi[0]->mbmi, mi_row, mi_col, + bsize, ctx->rate, ctx->dist, x->skip); } } @@ -1191,15 +1111,14 @@ static void update_state(VP10_COMP *cpi, ThreadData *td, p[i].eobs = ctx->eobs_pbuf[i][2]; } - for (i = 0; i < 2; ++i) - pd[i].color_index_map = ctx->color_index_map[i]; + for (i = 0; i < 2; ++i) pd[i].color_index_map = ctx->color_index_map[i]; // Restore the coding context of the MB to that that was in place // when the mode was picked for it for (y = 0; y < mi_height; y++) for (x_idx = 0; x_idx < mi_width; x_idx++) - if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx - && (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) { + if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx && + (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) { xd->mi[x_idx + y * mis] = mi_addr; } @@ -1219,22 +1138,16 @@ static void update_state(VP10_COMP *cpi, ThreadData *td, sizeof(uint8_t) * ctx->num_4x4_blk); #endif - if (!output_enabled) - return; + if (!output_enabled) return; #if CONFIG_INTERNAL_STATS if (frame_is_intra_only(cm)) { static const int kf_mode_index[] = { - THR_DC /*DC_PRED*/, - THR_V_PRED /*V_PRED*/, - THR_H_PRED /*H_PRED*/, - THR_D45_PRED /*D45_PRED*/, - THR_D135_PRED /*D135_PRED*/, - THR_D117_PRED /*D117_PRED*/, - THR_D153_PRED /*D153_PRED*/, - THR_D207_PRED /*D207_PRED*/, - THR_D63_PRED /*D63_PRED*/, - THR_TM /*TM_PRED*/, + THR_DC /*DC_PRED*/, THR_V_PRED /*V_PRED*/, + THR_H_PRED /*H_PRED*/, THR_D45_PRED /*D45_PRED*/, + THR_D135_PRED /*D135_PRED*/, THR_D117_PRED /*D117_PRED*/, + THR_D153_PRED /*D153_PRED*/, THR_D207_PRED /*D207_PRED*/, + THR_D63_PRED /*D63_PRED*/, THR_TM /*TM_PRED*/, }; ++cpi->mode_chosen_counts[kf_mode_index[mbmi->mode]]; } else { @@ -1264,7 +1177,7 @@ static void update_state(VP10_COMP *cpi, ThreadData *td, #if CONFIG_EXT_INTERP && vp10_is_interp_needed(xd) #endif - ) { + ) { #if CONFIG_DUAL_FILTER update_filter_type_count(td->counts, xd, mbmi); #else @@ -1293,9 +1206,8 @@ static void update_state(VP10_COMP *cpi, ThreadData *td, #if CONFIG_SUPERTX static void update_state_supertx(VP10_COMP *cpi, ThreadData *td, - PICK_MODE_CONTEXT *ctx, - int mi_row, int mi_col, BLOCK_SIZE bsize, - int output_enabled) { + PICK_MODE_CONTEXT *ctx, int mi_row, int mi_col, + BLOCK_SIZE bsize, int output_enabled) { int y, x_idx; #if CONFIG_VAR_TX || CONFIG_REF_MV int i; @@ -1313,8 +1225,7 @@ static void update_state_supertx(VP10_COMP *cpi, ThreadData *td, const int mi_height = num_8x8_blocks_high_lookup[bsize]; const int x_mis = VPXMIN(mi_width, cm->mi_cols - mi_col); const int y_mis = VPXMIN(mi_height, cm->mi_rows - mi_row); - MV_REF *const frame_mvs = - cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col; + MV_REF *const frame_mvs = cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col; int w, h; #if CONFIG_REF_MV @@ -1332,13 +1243,13 @@ static void update_state_supertx(VP10_COMP *cpi, ThreadData *td, #if CONFIG_REF_MV rf_type = vp10_ref_frame_type(mbmi->ref_frame); - if (x->mbmi_ext->ref_mv_count[rf_type] > 1 && - mbmi->sb_type >= BLOCK_8X8 && + if (x->mbmi_ext->ref_mv_count[rf_type] > 1 && mbmi->sb_type >= BLOCK_8X8 && mbmi->mode == NEWMV) { for (i = 0; i < 1 + has_second_ref(mbmi); ++i) { - int_mv this_mv = (i == 0) ? - x->mbmi_ext->ref_mv_stack[rf_type][mbmi->ref_mv_idx].this_mv : - x->mbmi_ext->ref_mv_stack[rf_type][mbmi->ref_mv_idx].comp_mv; + int_mv this_mv = + (i == 0) + ? x->mbmi_ext->ref_mv_stack[rf_type][mbmi->ref_mv_idx].this_mv + : x->mbmi_ext->ref_mv_stack[rf_type][mbmi->ref_mv_idx].comp_mv; clamp_mv_ref(&this_mv.as_mv, xd->n8_w << 3, xd->n8_h << 3, xd); lower_mv_precision(&this_mv.as_mv, cm->allow_high_precision_mv); x->mbmi_ext->ref_mvs[mbmi->ref_frame[i]][0] = this_mv; @@ -1350,19 +1261,19 @@ static void update_state_supertx(VP10_COMP *cpi, ThreadData *td, // If segmentation in use if (seg->enabled) { if (cpi->vaq_refresh) { - const int energy = bsize <= BLOCK_16X16 ? - x->mb_energy : vp10_block_energy(cpi, x, bsize); + const int energy = bsize <= BLOCK_16X16 + ? x->mb_energy + : vp10_block_energy(cpi, x, bsize); mi_addr->mbmi.segment_id = vp10_vaq_segment_id(energy); } else if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) { // For cyclic refresh mode, now update the segment map // and set the segment id. - vp10_cyclic_refresh_update_segment(cpi, &xd->mi[0]->mbmi, - mi_row, mi_col, bsize, - ctx->rate, ctx->dist, 1); + vp10_cyclic_refresh_update_segment(cpi, &xd->mi[0]->mbmi, mi_row, mi_col, + bsize, ctx->rate, ctx->dist, 1); } else { // Otherwise just set the segment id based on the current segment map - const uint8_t *const map = seg->update_map ? cpi->segmentation_map - : cm->last_frame_seg_map; + const uint8_t *const map = + seg->update_map ? cpi->segmentation_map : cm->last_frame_seg_map; mi_addr->mbmi.segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col); } mi_addr->mbmi.segment_id_supertx = MAX_SEGMENTS; @@ -1372,8 +1283,8 @@ static void update_state_supertx(VP10_COMP *cpi, ThreadData *td, // when the mode was picked for it for (y = 0; y < mi_height; y++) for (x_idx = 0; x_idx < mi_width; x_idx++) - if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx - && (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) { + if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx && + (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) { xd->mi[x_idx + y * mis] = mi_addr; } @@ -1402,8 +1313,7 @@ static void update_state_supertx(VP10_COMP *cpi, ThreadData *td, // Turn motion variation off for supertx mbmi->motion_variation = SIMPLE_TRANSLATION; - if (!output_enabled) - return; + if (!output_enabled) return; if (!frame_is_intra_only(cm)) { vp10_update_mv_count(td); @@ -1412,7 +1322,7 @@ static void update_state_supertx(VP10_COMP *cpi, ThreadData *td, #if CONFIG_EXT_INTERP && vp10_is_interp_needed(xd) #endif - ) { + ) { #if CONFIG_DUAL_FILTER update_filter_type_count(td->counts, xd, mbmi); #else @@ -1439,9 +1349,8 @@ static void update_state_supertx(VP10_COMP *cpi, ThreadData *td, } static void update_state_sb_supertx(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - int mi_row, int mi_col, - BLOCK_SIZE bsize, + const TileInfo *const tile, int mi_row, + int mi_col, BLOCK_SIZE bsize, int output_enabled, PC_TREE *pc_tree) { VP10_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &td->mb; @@ -1457,8 +1366,7 @@ static void update_state_sb_supertx(VP10_COMP *cpi, ThreadData *td, #endif PICK_MODE_CONTEXT *pmc = NULL; - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return; + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; if (bsize == BLOCK_16X16 && cpi->vaq_refresh) x->mb_energy = vp10_block_energy(cpi, x, bsize); @@ -1466,8 +1374,8 @@ static void update_state_sb_supertx(VP10_COMP *cpi, ThreadData *td, switch (partition) { case PARTITION_NONE: set_offsets_supertx(cpi, td, tile, mi_row, mi_col, subsize); - update_state_supertx(cpi, td, &pc_tree->none, mi_row, mi_col, - subsize, output_enabled); + update_state_supertx(cpi, td, &pc_tree->none, mi_row, mi_col, subsize, + output_enabled); break; case PARTITION_VERT: set_offsets_supertx(cpi, td, tile, mi_row, mi_col, subsize); @@ -1475,8 +1383,8 @@ static void update_state_sb_supertx(VP10_COMP *cpi, ThreadData *td, subsize, output_enabled); if (mi_col + hbs < cm->mi_cols && bsize > BLOCK_8X8) { set_offsets_supertx(cpi, td, tile, mi_row, mi_col + hbs, subsize); - update_state_supertx(cpi, td, &pc_tree->vertical[1], - mi_row, mi_col + hbs, subsize, output_enabled); + update_state_supertx(cpi, td, &pc_tree->vertical[1], mi_row, + mi_col + hbs, subsize, output_enabled); } pmc = &pc_tree->vertical_supertx; break; @@ -1562,8 +1470,7 @@ static void update_state_sb_supertx(VP10_COMP *cpi, ThreadData *td, pmc = &pc_tree->verticalb_supertx; break; #endif // CONFIG_EXT_PARTITION_TYPES - default: - assert(0); + default: assert(0); } for (i = 0; i < MAX_MB_PLANE; ++i) { @@ -1582,10 +1489,8 @@ static void update_state_sb_supertx(VP10_COMP *cpi, ThreadData *td, } } -static void update_supertx_param(ThreadData *td, - PICK_MODE_CONTEXT *ctx, - int best_tx, - TX_SIZE supertx_size) { +static void update_supertx_param(ThreadData *td, PICK_MODE_CONTEXT *ctx, + int best_tx, TX_SIZE supertx_size) { MACROBLOCK *const x = &td->mb; #if CONFIG_VAR_TX int i; @@ -1599,10 +1504,8 @@ static void update_supertx_param(ThreadData *td, ctx->mic.mbmi.tx_type = best_tx; } -static void update_supertx_param_sb(VP10_COMP *cpi, ThreadData *td, - int mi_row, int mi_col, - BLOCK_SIZE bsize, - int best_tx, +static void update_supertx_param_sb(VP10_COMP *cpi, ThreadData *td, int mi_row, + int mi_col, BLOCK_SIZE bsize, int best_tx, TX_SIZE supertx_size, PC_TREE *pc_tree) { VP10_COMMON *const cm = &cpi->common; int bsl = b_width_log2_lookup[bsize], hbs = (1 << bsl) / 4; @@ -1612,117 +1515,95 @@ static void update_supertx_param_sb(VP10_COMP *cpi, ThreadData *td, int i; #endif - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return; + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; switch (partition) { case PARTITION_NONE: - update_supertx_param(td, &pc_tree->none, - best_tx, - supertx_size); + update_supertx_param(td, &pc_tree->none, best_tx, supertx_size); break; case PARTITION_VERT: - update_supertx_param(td, &pc_tree->vertical[0], - best_tx, - supertx_size); + update_supertx_param(td, &pc_tree->vertical[0], best_tx, supertx_size); if (mi_col + hbs < cm->mi_cols && bsize > BLOCK_8X8) - update_supertx_param(td, &pc_tree->vertical[1], - best_tx, - supertx_size); + update_supertx_param(td, &pc_tree->vertical[1], best_tx, supertx_size); break; case PARTITION_HORZ: - update_supertx_param(td, &pc_tree->horizontal[0], - best_tx, - supertx_size); + update_supertx_param(td, &pc_tree->horizontal[0], best_tx, supertx_size); if (mi_row + hbs < cm->mi_rows && bsize > BLOCK_8X8) - update_supertx_param(td, &pc_tree->horizontal[1], - best_tx, + update_supertx_param(td, &pc_tree->horizontal[1], best_tx, supertx_size); break; case PARTITION_SPLIT: if (bsize == BLOCK_8X8) { - update_supertx_param(td, pc_tree->leaf_split[0], - best_tx, - supertx_size); + update_supertx_param(td, pc_tree->leaf_split[0], best_tx, supertx_size); } else { - update_supertx_param_sb(cpi, td, mi_row, mi_col, subsize, - best_tx, + update_supertx_param_sb(cpi, td, mi_row, mi_col, subsize, best_tx, supertx_size, pc_tree->split[0]); - update_supertx_param_sb(cpi, td, mi_row, mi_col + hbs, subsize, - best_tx, + update_supertx_param_sb(cpi, td, mi_row, mi_col + hbs, subsize, best_tx, supertx_size, pc_tree->split[1]); - update_supertx_param_sb(cpi, td, mi_row + hbs, mi_col, subsize, - best_tx, + update_supertx_param_sb(cpi, td, mi_row + hbs, mi_col, subsize, best_tx, supertx_size, pc_tree->split[2]); update_supertx_param_sb(cpi, td, mi_row + hbs, mi_col + hbs, subsize, - best_tx, - supertx_size, pc_tree->split[3]); + best_tx, supertx_size, pc_tree->split[3]); } break; #if CONFIG_EXT_PARTITION_TYPES case PARTITION_HORZ_A: - for ( i = 0; i < 3; i++) + for (i = 0; i < 3; i++) update_supertx_param(td, &pc_tree->horizontala[i], best_tx, - supertx_size); + supertx_size); break; case PARTITION_HORZ_B: - for ( i = 0; i < 3; i++) + for (i = 0; i < 3; i++) update_supertx_param(td, &pc_tree->horizontalb[i], best_tx, - supertx_size); + supertx_size); break; case PARTITION_VERT_A: - for ( i = 0; i < 3; i++) - update_supertx_param(td, &pc_tree->verticala[i], best_tx, - supertx_size); + for (i = 0; i < 3; i++) + update_supertx_param(td, &pc_tree->verticala[i], best_tx, supertx_size); break; case PARTITION_VERT_B: - for ( i = 0; i < 3; i++) - update_supertx_param(td, &pc_tree->verticalb[i], best_tx, - supertx_size); + for (i = 0; i < 3; i++) + update_supertx_param(td, &pc_tree->verticalb[i], best_tx, supertx_size); break; #endif // CONFIG_EXT_PARTITION_TYPES - default: - assert(0); + default: assert(0); } } #endif // CONFIG_SUPERTX void vp10_setup_src_planes(MACROBLOCK *x, const YV12_BUFFER_CONFIG *src, - int mi_row, int mi_col) { - uint8_t *const buffers[3] = {src->y_buffer, src->u_buffer, src->v_buffer }; - const int widths[3] = {src->y_crop_width, src->uv_crop_width, - src->uv_crop_width}; - const int heights[3] = {src->y_crop_height, src->uv_crop_height, - src->uv_crop_height}; - const int strides[3] = {src->y_stride, src->uv_stride, src->uv_stride }; + int mi_row, int mi_col) { + uint8_t *const buffers[3] = { src->y_buffer, src->u_buffer, src->v_buffer }; + const int widths[3] = { src->y_crop_width, src->uv_crop_width, + src->uv_crop_width }; + const int heights[3] = { src->y_crop_height, src->uv_crop_height, + src->uv_crop_height }; + const int strides[3] = { src->y_stride, src->uv_stride, src->uv_stride }; int i; // Set current frame pointer. x->e_mbd.cur_buf = src; for (i = 0; i < MAX_MB_PLANE; i++) - setup_pred_plane(&x->plane[i].src, buffers[i], widths[i], - heights[i], strides[i], mi_row, mi_col, - NULL, x->e_mbd.plane[i].subsampling_x, + setup_pred_plane(&x->plane[i].src, buffers[i], widths[i], heights[i], + strides[i], mi_row, mi_col, NULL, + x->e_mbd.plane[i].subsampling_x, x->e_mbd.plane[i].subsampling_y); } -static int set_segment_rdmult(VP10_COMP *const cpi, - MACROBLOCK *const x, - int8_t segment_id) { +static int set_segment_rdmult(VP10_COMP *const cpi, MACROBLOCK *const x, + int8_t segment_id) { int segment_qindex; VP10_COMMON *const cm = &cpi->common; vp10_init_plane_quantizers(cpi, x, segment_id); vpx_clear_system_state(); - segment_qindex = vp10_get_qindex(&cm->seg, segment_id, - cm->base_qindex); + segment_qindex = vp10_get_qindex(&cm->seg, segment_id, cm->base_qindex); return vp10_compute_rd_mult(cpi, segment_qindex + cm->y_dc_delta_q); } -static void rd_pick_sb_modes(VP10_COMP *cpi, - TileDataEnc *tile_data, - MACROBLOCK *const x, - int mi_row, int mi_col, RD_COST *rd_cost, +static void rd_pick_sb_modes(VP10_COMP *cpi, TileDataEnc *tile_data, + MACROBLOCK *const x, int mi_row, int mi_col, + RD_COST *rd_cost, #if CONFIG_SUPERTX int *totalrate_nocoef, #endif @@ -1767,8 +1648,7 @@ static void rd_pick_sb_modes(VP10_COMP *cpi, p[i].eobs = ctx->eobs_pbuf[i][0]; } - for (i = 0; i < 2; ++i) - pd[i].color_index_map = ctx->color_index_map[i]; + for (i = 0; i < 2; ++i) pd[i].color_index_map = ctx->color_index_map[i]; ctx->is_coded = 0; ctx->skippable = 0; @@ -1779,16 +1659,15 @@ static void rd_pick_sb_modes(VP10_COMP *cpi, #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { - x->source_variance = - vp10_high_get_sby_perpixel_variance(cpi, &x->plane[0].src, - bsize, xd->bd); + x->source_variance = vp10_high_get_sby_perpixel_variance( + cpi, &x->plane[0].src, bsize, xd->bd); } else { x->source_variance = - vp10_get_sby_perpixel_variance(cpi, &x->plane[0].src, bsize); + vp10_get_sby_perpixel_variance(cpi, &x->plane[0].src, bsize); } #else x->source_variance = - vp10_get_sby_perpixel_variance(cpi, &x->plane[0].src, bsize); + vp10_get_sby_perpixel_variance(cpi, &x->plane[0].src, bsize); #endif // CONFIG_VP9_HIGHBITDEPTH // Save rdmult before it might be changed, so it can be restored later. @@ -1796,8 +1675,9 @@ static void rd_pick_sb_modes(VP10_COMP *cpi, if (aq_mode == VARIANCE_AQ) { if (cpi->vaq_refresh) { - const int energy = bsize <= BLOCK_16X16 ? - x->mb_energy : vp10_block_energy(cpi, x, bsize); + const int energy = bsize <= BLOCK_16X16 + ? x->mb_energy + : vp10_block_energy(cpi, x, bsize); mbmi->segment_id = vp10_vaq_segment_id(energy); // Re-initialise quantiser vp10_init_plane_quantizers(cpi, x, mbmi->segment_id); @@ -1823,7 +1703,7 @@ static void rd_pick_sb_modes(VP10_COMP *cpi, if (bsize >= BLOCK_8X8) { if (segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { vp10_rd_pick_inter_mode_sb_seg_skip(cpi, tile_data, x, rd_cost, bsize, - ctx, best_rd); + ctx, best_rd); #if CONFIG_SUPERTX *totalrate_nocoef = rd_cost->rate; #endif // CONFIG_SUPERTX @@ -1849,18 +1729,16 @@ static void rd_pick_sb_modes(VP10_COMP *cpi, #endif // CONFIG_SUPERTX bsize, ctx, best_rd); #if CONFIG_SUPERTX - assert(*totalrate_nocoef >= 0); + assert(*totalrate_nocoef >= 0); #endif // CONFIG_SUPERTX } } } - // Examine the resulting rate and for AQ mode 2 make a segment choice. - if ((rd_cost->rate != INT_MAX) && - (aq_mode == COMPLEXITY_AQ) && (bsize >= BLOCK_16X16) && - (cm->frame_type == KEY_FRAME || - cpi->refresh_alt_ref_frame || + if ((rd_cost->rate != INT_MAX) && (aq_mode == COMPLEXITY_AQ) && + (bsize >= BLOCK_16X16) && + (cm->frame_type == KEY_FRAME || cpi->refresh_alt_ref_frame || (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref))) { vp10_caq_select_segment(cpi, x, bsize, mi_row, mi_col, rd_cost->rate); } @@ -1869,16 +1747,14 @@ static void rd_pick_sb_modes(VP10_COMP *cpi, // TODO(jingning) The rate-distortion optimization flow needs to be // refactored to provide proper exit/return handle. - if (rd_cost->rate == INT_MAX) - rd_cost->rdcost = INT64_MAX; + if (rd_cost->rate == INT_MAX) rd_cost->rdcost = INT64_MAX; ctx->rate = rd_cost->rate; ctx->dist = rd_cost->dist; } #if CONFIG_REF_MV -static void update_inter_mode_stats(FRAME_COUNTS *counts, - PREDICTION_MODE mode, +static void update_inter_mode_stats(FRAME_COUNTS *counts, PREDICTION_MODE mode, #if CONFIG_EXT_INTER int is_compound, #endif // CONFIG_EXT_INTER @@ -1886,8 +1762,7 @@ static void update_inter_mode_stats(FRAME_COUNTS *counts, int16_t mode_ctx = mode_context & NEWMV_CTX_MASK; #if CONFIG_EXT_INTER if (mode == NEWMV || mode == NEWFROMNEARMV) { - if (!is_compound) - ++counts->new2mv_mode[mode == NEWFROMNEARMV]; + if (!is_compound) ++counts->new2mv_mode[mode == NEWFROMNEARMV]; #else if (mode == NEWMV) { #endif // CONFIG_EXT_INTER @@ -1908,12 +1783,9 @@ static void update_inter_mode_stats(FRAME_COUNTS *counts, ++counts->zeromv_mode[mode_ctx][1]; mode_ctx = (mode_context >> REFMV_OFFSET) & REFMV_CTX_MASK; - if (mode_context & (1 << SKIP_NEARESTMV_OFFSET)) - mode_ctx = 6; - if (mode_context & (1 << SKIP_NEARMV_OFFSET)) - mode_ctx = 7; - if (mode_context & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) - mode_ctx = 8; + if (mode_context & (1 << SKIP_NEARESTMV_OFFSET)) mode_ctx = 6; + if (mode_context & (1 << SKIP_NEARMV_OFFSET)) mode_ctx = 7; + if (mode_context & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) mode_ctx = 8; ++counts->refmv_mode[mode_ctx][mode != NEARESTMV]; } @@ -1923,7 +1795,8 @@ static void update_inter_mode_stats(FRAME_COUNTS *counts, static void update_stats(VP10_COMMON *cm, ThreadData *td #if CONFIG_SUPERTX - , int supertx_enabled + , + int supertx_enabled #endif ) { const MACROBLOCK *x = &td->mb; @@ -1936,13 +1809,13 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td if (!frame_is_intra_only(cm)) { FRAME_COUNTS *const counts = td->counts; const int inter_block = is_inter_block(mbmi); - const int seg_ref_active = segfeature_active(&cm->seg, mbmi->segment_id, - SEG_LVL_REF_FRAME); + const int seg_ref_active = + segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_REF_FRAME); if (!seg_ref_active) { #if CONFIG_SUPERTX if (!supertx_enabled) #endif - counts->intra_inter[vp10_get_intra_inter_context(xd)][inter_block]++; + counts->intra_inter[vp10_get_intra_inter_context(xd)][inter_block]++; // If the segment reference feature is enabled we have only a single // reference frame allowed for the segment so exclude it from // the reference frame counts used to work out probabilities. @@ -1953,8 +1826,8 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td #endif // CONFIG_EXT_REFS if (cm->reference_mode == REFERENCE_MODE_SELECT) - counts->comp_inter[vp10_get_reference_mode_context(cm, xd)] - [has_second_ref(mbmi)]++; + counts->comp_inter[vp10_get_reference_mode_context( + cm, xd)][has_second_ref(mbmi)]++; if (has_second_ref(mbmi)) { #if CONFIG_EXT_REFS @@ -1962,18 +1835,18 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td counts->comp_ref[vp10_get_pred_context_comp_ref_p(cm, xd)][0][bit]++; if (!bit) { - counts->comp_ref[vp10_get_pred_context_comp_ref_p1(cm, xd)][1] - [ref0 == LAST_FRAME]++; + counts->comp_ref[vp10_get_pred_context_comp_ref_p1( + cm, xd)][1][ref0 == LAST_FRAME]++; } else { - counts->comp_ref[vp10_get_pred_context_comp_ref_p2(cm, xd)][2] - [ref0 == GOLDEN_FRAME]++; + counts->comp_ref[vp10_get_pred_context_comp_ref_p2( + cm, xd)][2][ref0 == GOLDEN_FRAME]++; } - counts->comp_bwdref[vp10_get_pred_context_comp_bwdref_p(cm, xd)][0] - [ref1 == ALTREF_FRAME]++; + counts->comp_bwdref[vp10_get_pred_context_comp_bwdref_p( + cm, xd)][0][ref1 == ALTREF_FRAME]++; #else - counts->comp_ref[vp10_get_pred_context_comp_ref_p(cm, xd)][0] - [ref0 == GOLDEN_FRAME]++; + counts->comp_ref[vp10_get_pred_context_comp_ref_p( + cm, xd)][0][ref0 == GOLDEN_FRAME]++; #endif // CONFIG_EXT_REFS } else { #if CONFIG_EXT_REFS @@ -1981,46 +1854,46 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td counts->single_ref[vp10_get_pred_context_single_ref_p1(xd)][0][bit]++; if (bit) { - counts->single_ref[vp10_get_pred_context_single_ref_p2(xd)][1] - [ref0 != BWDREF_FRAME]++; + counts->single_ref[vp10_get_pred_context_single_ref_p2( + xd)][1][ref0 != BWDREF_FRAME]++; } else { const int bit1 = !(ref0 == LAST2_FRAME || ref0 == LAST_FRAME); - counts->single_ref[vp10_get_pred_context_single_ref_p3(xd)][2] - [bit1]++; + counts->single_ref[vp10_get_pred_context_single_ref_p3( + xd)][2][bit1]++; if (!bit1) { - counts->single_ref[vp10_get_pred_context_single_ref_p4(xd)][3] - [ref0 != LAST_FRAME]++; + counts->single_ref[vp10_get_pred_context_single_ref_p4( + xd)][3][ref0 != LAST_FRAME]++; } else { - counts->single_ref[vp10_get_pred_context_single_ref_p5(xd)][4] - [ref0 != LAST3_FRAME]++; + counts->single_ref[vp10_get_pred_context_single_ref_p5( + xd)][4][ref0 != LAST3_FRAME]++; } } #else - counts->single_ref[vp10_get_pred_context_single_ref_p1(xd)][0] - [ref0 != LAST_FRAME]++; + counts->single_ref[vp10_get_pred_context_single_ref_p1( + xd)][0][ref0 != LAST_FRAME]++; if (ref0 != LAST_FRAME) { - counts->single_ref[vp10_get_pred_context_single_ref_p2(xd)][1] - [ref0 != GOLDEN_FRAME]++; + counts->single_ref[vp10_get_pred_context_single_ref_p2( + xd)][1][ref0 != GOLDEN_FRAME]++; } #endif // CONFIG_EXT_REFS } #if CONFIG_EXT_INTER - if (cm->reference_mode != COMPOUND_REFERENCE && + if (cm->reference_mode != COMPOUND_REFERENCE && #if CONFIG_SUPERTX - !supertx_enabled && + !supertx_enabled && #endif - is_interintra_allowed(mbmi)) { - const int bsize_group = size_group_lookup[bsize]; - if (mbmi->ref_frame[1] == INTRA_FRAME) { - counts->interintra[bsize_group][1]++; - counts->interintra_mode[bsize_group][mbmi->interintra_mode]++; - if (is_interintra_wedge_used(bsize)) - counts->wedge_interintra[bsize][mbmi->use_wedge_interintra]++; - } else { - counts->interintra[bsize_group][0]++; - } - } + is_interintra_allowed(mbmi)) { + const int bsize_group = size_group_lookup[bsize]; + if (mbmi->ref_frame[1] == INTRA_FRAME) { + counts->interintra[bsize_group][1]++; + counts->interintra_mode[bsize_group][mbmi->interintra_mode]++; + if (is_interintra_wedge_used(bsize)) + counts->wedge_interintra[bsize][mbmi->use_wedge_interintra]++; + } else { + counts->interintra[bsize_group][0]++; + } + } #endif // CONFIG_EXT_INTER #if CONFIG_OBMC || CONFIG_WARPED_MOTION @@ -2028,10 +1901,10 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td if (!supertx_enabled) #endif // CONFIG_SUPERTX #if CONFIG_EXT_INTER - if (mbmi->ref_frame[1] != INTRA_FRAME) + if (mbmi->ref_frame[1] != INTRA_FRAME) #endif // CONFIG_EXT_INTER - if (is_motvar_allowed(mbmi)) - counts->motvar[mbmi->sb_type][mbmi->motion_variation]++; + if (is_motvar_allowed(mbmi)) + counts->motvar[mbmi->sb_type][mbmi->motion_variation]++; #endif // CONFIG_OBMC || CONFIG_WARPED_MOTION #if CONFIG_EXT_INTER @@ -2060,45 +1933,43 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td ++counts->inter_compound_mode[mode_ctx][INTER_COMPOUND_OFFSET(mode)]; } else { #endif // CONFIG_EXT_INTER - mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context, - mbmi->ref_frame, bsize, -1); - update_inter_mode_stats(counts, mode, + mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context, + mbmi->ref_frame, bsize, -1); + update_inter_mode_stats(counts, mode, #if CONFIG_EXT_INTER - has_second_ref(mbmi), + has_second_ref(mbmi), #endif // CONFIG_EXT_INTER - mode_ctx); + mode_ctx); - if (mode == NEWMV) { - uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame); - int idx; + if (mode == NEWMV) { + uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame); + int idx; - for (idx = 0; idx < 2; ++idx) { - if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1) { - uint8_t drl_ctx = - vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx); - ++counts->drl_mode[drl_ctx][mbmi->ref_mv_idx != idx]; + for (idx = 0; idx < 2; ++idx) { + if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1) { + uint8_t drl_ctx = + vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx); + ++counts->drl_mode[drl_ctx][mbmi->ref_mv_idx != idx]; - if (mbmi->ref_mv_idx == idx) - break; + if (mbmi->ref_mv_idx == idx) break; + } } } - } - if (mode == NEARMV) { - uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame); - int idx; + if (mode == NEARMV) { + uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame); + int idx; - for (idx = 1; idx < 3; ++idx) { - if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1) { - uint8_t drl_ctx = - vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx); - ++counts->drl_mode[drl_ctx][mbmi->ref_mv_idx != idx - 1]; + for (idx = 1; idx < 3; ++idx) { + if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1) { + uint8_t drl_ctx = + vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx); + ++counts->drl_mode[drl_ctx][mbmi->ref_mv_idx != idx - 1]; - if (mbmi->ref_mv_idx == idx - 1) - break; + if (mbmi->ref_mv_idx == idx - 1) break; + } } } - } #if CONFIG_EXT_INTER } #endif // CONFIG_EXT_INTER @@ -2108,7 +1979,7 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td ++counts->inter_compound_mode[mode_ctx][INTER_COMPOUND_OFFSET(mode)]; else #endif // CONFIG_EXT_INTER - ++counts->inter_mode[mode_ctx][INTER_OFFSET(mode)]; + ++counts->inter_mode[mode_ctx][INTER_OFFSET(mode)]; #endif } else { const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize]; @@ -2120,30 +1991,30 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td const PREDICTION_MODE b_mode = mi->bmi[j].as_mode; #if CONFIG_REF_MV #if CONFIG_EXT_INTER - if (has_second_ref(mbmi)) { - mode_ctx = mbmi_ext->compound_mode_context[mbmi->ref_frame[0]]; - ++counts->inter_compound_mode[mode_ctx] - [INTER_COMPOUND_OFFSET(b_mode)]; - } else { + if (has_second_ref(mbmi)) { + mode_ctx = mbmi_ext->compound_mode_context[mbmi->ref_frame[0]]; + ++counts->inter_compound_mode[mode_ctx][INTER_COMPOUND_OFFSET( + b_mode)]; + } else { #endif // CONFIG_EXT_INTER - mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context, - mbmi->ref_frame, bsize, j); - update_inter_mode_stats(counts, b_mode, + mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context, + mbmi->ref_frame, bsize, j); + update_inter_mode_stats(counts, b_mode, #if CONFIG_EXT_INTER - has_second_ref(mbmi), + has_second_ref(mbmi), #endif // CONFIG_EXT_INTER - mode_ctx); + mode_ctx); #if CONFIG_EXT_INTER } #endif // CONFIG_EXT_INTER #else #if CONFIG_EXT_INTER if (is_inter_compound_mode(b_mode)) - ++counts->inter_compound_mode[mode_ctx] - [INTER_COMPOUND_OFFSET(b_mode)]; + ++counts->inter_compound_mode[mode_ctx][INTER_COMPOUND_OFFSET( + b_mode)]; else #endif // CONFIG_EXT_INTER - ++counts->inter_mode[mode_ctx][INTER_OFFSET(b_mode)]; + ++counts->inter_mode[mode_ctx][INTER_OFFSET(b_mode)]; #endif } } @@ -2166,8 +2037,8 @@ typedef struct { } RD_SEARCH_MACROBLOCK_CONTEXT; static void restore_context(MACROBLOCK *x, - const RD_SEARCH_MACROBLOCK_CONTEXT *ctx, - int mi_row, int mi_col, BLOCK_SIZE bsize) { + const RD_SEARCH_MACROBLOCK_CONTEXT *ctx, int mi_row, + int mi_col, BLOCK_SIZE bsize) { MACROBLOCKD *xd = &x->e_mbd; int p; const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize]; @@ -2175,17 +2046,15 @@ static void restore_context(MACROBLOCK *x, int mi_width = num_8x8_blocks_wide_lookup[bsize]; int mi_height = num_8x8_blocks_high_lookup[bsize]; for (p = 0; p < MAX_MB_PLANE; p++) { - memcpy( - xd->above_context[p] + ((mi_col * 2) >> xd->plane[p].subsampling_x), - ctx->a + num_4x4_blocks_wide * p, - (sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide) >> - xd->plane[p].subsampling_x); - memcpy( - xd->left_context[p] - + ((mi_row & MAX_MIB_MASK) * 2 >> xd->plane[p].subsampling_y), - ctx->l + num_4x4_blocks_high * p, - (sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >> - xd->plane[p].subsampling_y); + memcpy(xd->above_context[p] + ((mi_col * 2) >> xd->plane[p].subsampling_x), + ctx->a + num_4x4_blocks_wide * p, + (sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide) >> + xd->plane[p].subsampling_x); + memcpy(xd->left_context[p] + + ((mi_row & MAX_MIB_MASK) * 2 >> xd->plane[p].subsampling_y), + ctx->l + num_4x4_blocks_high * p, + (sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >> + xd->plane[p].subsampling_y); } memcpy(xd->above_seg_context + mi_col, ctx->sa, sizeof(*xd->above_seg_context) * mi_width); @@ -2201,8 +2070,7 @@ static void restore_context(MACROBLOCK *x, #endif } -static void save_context(const MACROBLOCK *x, - RD_SEARCH_MACROBLOCK_CONTEXT *ctx, +static void save_context(const MACROBLOCK *x, RD_SEARCH_MACROBLOCK_CONTEXT *ctx, int mi_row, int mi_col, BLOCK_SIZE bsize) { const MACROBLOCKD *xd = &x->e_mbd; int p; @@ -2213,17 +2081,15 @@ static void save_context(const MACROBLOCK *x, // buffer the above/left context information of the block in search. for (p = 0; p < MAX_MB_PLANE; ++p) { - memcpy( - ctx->a + num_4x4_blocks_wide * p, - xd->above_context[p] + (mi_col * 2 >> xd->plane[p].subsampling_x), - (sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide) >> - xd->plane[p].subsampling_x); - memcpy( - ctx->l + num_4x4_blocks_high * p, - xd->left_context[p] - + ((mi_row & MAX_MIB_MASK) * 2 >> xd->plane[p].subsampling_y), - (sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >> - xd->plane[p].subsampling_y); + memcpy(ctx->a + num_4x4_blocks_wide * p, + xd->above_context[p] + (mi_col * 2 >> xd->plane[p].subsampling_x), + (sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide) >> + xd->plane[p].subsampling_x); + memcpy(ctx->l + num_4x4_blocks_high * p, + xd->left_context[p] + + ((mi_row & MAX_MIB_MASK) * 2 >> xd->plane[p].subsampling_y), + (sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >> + xd->plane[p].subsampling_y); } memcpy(ctx->sa, xd->above_seg_context + mi_col, sizeof(*xd->above_seg_context) * mi_width); @@ -2239,8 +2105,7 @@ static void save_context(const MACROBLOCK *x, #endif } -static void encode_b(VP10_COMP *cpi, const TileInfo *const tile, - ThreadData *td, +static void encode_b(VP10_COMP *cpi, const TileInfo *const tile, ThreadData *td, TOKENEXTRA **tp, int mi_row, int mi_col, int output_enabled, BLOCK_SIZE bsize, #if CONFIG_EXT_PARTITION_TYPES @@ -2265,9 +2130,8 @@ static void encode_b(VP10_COMP *cpi, const TileInfo *const tile, } static void encode_sb(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - TOKENEXTRA **tp, int mi_row, int mi_col, - int output_enabled, BLOCK_SIZE bsize, + const TileInfo *const tile, TOKENEXTRA **tp, int mi_row, + int mi_col, int output_enabled, BLOCK_SIZE bsize, PC_TREE *pc_tree) { const VP10_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &td->mb; @@ -2276,24 +2140,20 @@ static void encode_sb(VP10_COMP *cpi, ThreadData *td, const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize); const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2; const PARTITION_TYPE partition = pc_tree->partitioning; - const BLOCK_SIZE subsize = get_subsize(bsize, partition); + const BLOCK_SIZE subsize = get_subsize(bsize, partition); #if CONFIG_EXT_PARTITION_TYPES const BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT); #endif assert(bsize >= BLOCK_8X8); - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return; + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; - if (output_enabled) - td->counts->partition[ctx][partition]++; + if (output_enabled) td->counts->partition[ctx][partition]++; #if CONFIG_SUPERTX - if (!frame_is_intra_only(cm) && - bsize <= MAX_SUPERTX_BLOCK_SIZE && - partition != PARTITION_NONE && - !xd->lossless[0]) { + if (!frame_is_intra_only(cm) && bsize <= MAX_SUPERTX_BLOCK_SIZE && + partition != PARTITION_NONE && !xd->lossless[0]) { int supertx_enabled; TX_SIZE supertx_size = max_txsize_lookup[bsize]; supertx_enabled = check_supertx_sb(bsize, supertx_size, pc_tree); @@ -2308,15 +2168,15 @@ static void encode_sb(VP10_COMP *cpi, ThreadData *td, update_state_sb_supertx(cpi, td, tile, mi_row, mi_col, bsize, output_enabled, pc_tree); - vp10_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), - mi_row, mi_col); + vp10_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, + mi_col); for (i = 0; i < MAX_MB_PLANE; i++) { dst_buf[i] = xd->plane[i].dst.buf; dst_stride[i] = xd->plane[i].dst.stride; } predict_sb_complex(cpi, td, tile, mi_row, mi_col, mi_row, mi_col, - output_enabled, bsize, bsize, - dst_buf, dst_stride, pc_tree); + output_enabled, bsize, bsize, dst_buf, dst_stride, + pc_tree); set_offsets_without_segment_id(cpi, tile, x, mi_row, mi_col, bsize); set_segment_id_supertx(cpi, x, mi_row, mi_col, bsize); @@ -2329,35 +2189,34 @@ static void encode_sb(VP10_COMP *cpi, ThreadData *td, vp10_tokenize_sb_supertx(cpi, td, tp, !output_enabled, bsize); } else { xd->mi[0]->mbmi.skip = 1; - if (output_enabled) - td->counts->skip[vp10_get_skip_context(xd)][1]++; + if (output_enabled) td->counts->skip[vp10_get_skip_context(xd)][1]++; reset_skip_context(xd, bsize); } if (output_enabled) { for (y_idx = 0; y_idx < mi_height; y_idx++) for (x_idx = 0; x_idx < mi_width; x_idx++) { - if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx - && (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height - > y_idx) { + if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > + x_idx && + (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > + y_idx) { xd->mi[x_idx + y_idx * cm->mi_stride]->mbmi.skip = xd->mi[0]->mbmi.skip; } } - td->counts->supertx - [partition_supertx_context_lookup[partition]][supertx_size][1]++; + td->counts->supertx[partition_supertx_context_lookup[partition]] + [supertx_size][1]++; td->counts->supertx_size[supertx_size]++; #if CONFIG_EXT_TX if (get_ext_tx_types(supertx_size, bsize, 1) > 1 && !xd->mi[0]->mbmi.skip) { int eset = get_ext_tx_set(supertx_size, bsize, 1); if (eset > 0) { - ++td->counts->inter_ext_tx[eset][supertx_size] - [xd->mi[0]->mbmi.tx_type]; + ++td->counts + ->inter_ext_tx[eset][supertx_size][xd->mi[0]->mbmi.tx_type]; } } #else - if (supertx_size < TX_32X32 && - !xd->mi[0]->mbmi.skip) { + if (supertx_size < TX_32X32 && !xd->mi[0]->mbmi.skip) { ++td->counts->inter_ext_tx[supertx_size][xd->mi[0]->mbmi.tx_type]; } #endif // CONFIG_EXT_TX @@ -2376,8 +2235,8 @@ static void encode_sb(VP10_COMP *cpi, ThreadData *td, return; } else { if (output_enabled) { - td->counts->supertx - [partition_supertx_context_lookup[partition]][supertx_size][0]++; + td->counts->supertx[partition_supertx_context_lookup[partition]] + [supertx_size][0]++; } } } @@ -2474,9 +2333,7 @@ static void encode_sb(VP10_COMP *cpi, ThreadData *td, bsize2, partition, &pc_tree->verticalb[2]); break; #endif // CONFIG_EXT_PARTITION_TYPES - default: - assert(0 && "Invalid partition type."); - break; + default: assert(0 && "Invalid partition type."); break; } #if CONFIG_EXT_PARTITION_TYPES @@ -2490,9 +2347,8 @@ static void encode_sb(VP10_COMP *cpi, ThreadData *td, // Check to see if the given partition size is allowed for a specified number // of mi block rows and columns remaining in the image. // If not then return the largest allowed partition size -static BLOCK_SIZE find_partition_size(BLOCK_SIZE bsize, - int rows_left, int cols_left, - int *bh, int *bw) { +static BLOCK_SIZE find_partition_size(BLOCK_SIZE bsize, int rows_left, + int cols_left, int *bh, int *bw) { if (rows_left <= 0 || cols_left <= 0) { return VPXMIN(bsize, BLOCK_8X8); } else { @@ -2507,12 +2363,11 @@ static BLOCK_SIZE find_partition_size(BLOCK_SIZE bsize, return bsize; } -static void set_partial_sb_partition(const VP10_COMMON *const cm, - MODE_INFO *mi, +static void set_partial_sb_partition(const VP10_COMMON *const cm, MODE_INFO *mi, int bh_in, int bw_in, int mi_rows_remaining, - int mi_cols_remaining, - BLOCK_SIZE bsize, MODE_INFO **mib) { + int mi_cols_remaining, BLOCK_SIZE bsize, + MODE_INFO **mib) { int bh = bh_in; int r, c; for (r = 0; r < cm->mib_size; r += bh) { @@ -2520,8 +2375,8 @@ static void set_partial_sb_partition(const VP10_COMMON *const cm, for (c = 0; c < cm->mib_size; c += bw) { const int index = r * cm->mi_stride + c; mib[index] = mi + index; - mib[index]->mbmi.sb_type = find_partition_size(bsize, - mi_rows_remaining - r, mi_cols_remaining - c, &bh, &bw); + mib[index]->mbmi.sb_type = find_partition_size( + bsize, mi_rows_remaining - r, mi_cols_remaining - c, &bh, &bw); } } } @@ -2556,18 +2411,15 @@ static void set_fixed_partitioning(VP10_COMP *cpi, const TileInfo *const tile, } } else { // Else this is a partial SB. - set_partial_sb_partition(cm, mi_upper_left, bh, bw, - mi_rows_remaining, mi_cols_remaining, bsize, mib); + set_partial_sb_partition(cm, mi_upper_left, bh, bw, mi_rows_remaining, + mi_cols_remaining, bsize, mib); } } -static void rd_use_partition(VP10_COMP *cpi, - ThreadData *td, - TileDataEnc *tile_data, - MODE_INFO **mib, TOKENEXTRA **tp, - int mi_row, int mi_col, - BLOCK_SIZE bsize, - int *rate, int64_t *dist, +static void rd_use_partition(VP10_COMP *cpi, ThreadData *td, + TileDataEnc *tile_data, MODE_INFO **mib, + TOKENEXTRA **tp, int mi_row, int mi_col, + BLOCK_SIZE bsize, int *rate, int64_t *dist, #if CONFIG_SUPERTX int *rate_nocoef, #endif @@ -2581,7 +2433,7 @@ static void rd_use_partition(VP10_COMP *cpi, int i; const int pl = partition_plane_context(xd, mi_row, mi_col, bsize); const PARTITION_TYPE partition = get_partition(cm, mi_row, mi_col, bsize); - const BLOCK_SIZE subsize = get_subsize(bsize, partition); + const BLOCK_SIZE subsize = get_subsize(bsize, partition); RD_SEARCH_MACROBLOCK_CONTEXT x_ctx; RD_COST last_part_rdc, none_rdc, chosen_rdc; BLOCK_SIZE sub_subsize = BLOCK_4X4; @@ -2595,8 +2447,7 @@ static void rd_use_partition(VP10_COMP *cpi, int chosen_rate_nocoef = INT_MAX; #endif - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return; + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; assert(num_4x4_blocks_wide_lookup[bsize] == num_4x4_blocks_high_lookup[bsize]); @@ -2610,7 +2461,7 @@ static void rd_use_partition(VP10_COMP *cpi, #if CONFIG_VAR_TX xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); #endif save_context(x, &x_ctx, mi_row, mi_col, bsize); @@ -2639,8 +2490,7 @@ static void rd_use_partition(VP10_COMP *cpi, // If partition is not none try none unless each of the 4 splits are split // even further.. if (partition != PARTITION_NONE && !splits_below && - mi_row + hbs < cm->mi_rows && - mi_col + hbs < cm->mi_cols) { + mi_row + hbs < cm->mi_rows && mi_col + hbs < cm->mi_cols) { pc_tree->partitioning = PARTITION_NONE; rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &none_rdc, #if CONFIG_SUPERTX @@ -2653,8 +2503,8 @@ static void rd_use_partition(VP10_COMP *cpi, if (none_rdc.rate < INT_MAX) { none_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE]; - none_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, none_rdc.rate, - none_rdc.dist); + none_rdc.rdcost = + RDCOST(x->rdmult, x->rddiv, none_rdc.rate, none_rdc.dist); #if CONFIG_SUPERTX none_rate_nocoef += cpi->partition_cost[pl][PARTITION_NONE]; #endif @@ -2686,10 +2536,9 @@ static void rd_use_partition(VP10_COMP *cpi, #if CONFIG_EXT_PARTITION_TYPES PARTITION_HORZ, #endif - subsize, &pc_tree->horizontal[0], - INT64_MAX); - if (last_part_rdc.rate != INT_MAX && - bsize >= BLOCK_8X8 && mi_row + hbs < cm->mi_rows) { + subsize, &pc_tree->horizontal[0], INT64_MAX); + if (last_part_rdc.rate != INT_MAX && bsize >= BLOCK_8X8 && + mi_row + hbs < cm->mi_rows) { RD_COST tmp_rdc; #if CONFIG_SUPERTX int rt_nocoef = 0; @@ -2698,8 +2547,7 @@ static void rd_use_partition(VP10_COMP *cpi, vp10_rd_cost_init(&tmp_rdc); update_state(cpi, td, ctx, mi_row, mi_col, subsize, 0); encode_superblock(cpi, td, tp, 0, mi_row, mi_col, subsize, ctx); - rd_pick_sb_modes(cpi, tile_data, x, - mi_row + hbs, mi_col, &tmp_rdc, + rd_pick_sb_modes(cpi, tile_data, x, mi_row + hbs, mi_col, &tmp_rdc, #if CONFIG_SUPERTX &rt_nocoef, #endif @@ -2731,8 +2579,8 @@ static void rd_use_partition(VP10_COMP *cpi, PARTITION_VERT, #endif subsize, &pc_tree->vertical[0], INT64_MAX); - if (last_part_rdc.rate != INT_MAX && - bsize >= BLOCK_8X8 && mi_col + hbs < cm->mi_cols) { + if (last_part_rdc.rate != INT_MAX && bsize >= BLOCK_8X8 && + mi_col + hbs < cm->mi_cols) { RD_COST tmp_rdc; #if CONFIG_SUPERTX int rt_nocoef = 0; @@ -2741,8 +2589,7 @@ static void rd_use_partition(VP10_COMP *cpi, vp10_rd_cost_init(&tmp_rdc); update_state(cpi, td, ctx, mi_row, mi_col, subsize, 0); encode_superblock(cpi, td, tp, 0, mi_row, mi_col, subsize, ctx); - rd_pick_sb_modes(cpi, tile_data, x, - mi_row, mi_col + hbs, &tmp_rdc, + rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + hbs, &tmp_rdc, #if CONFIG_SUPERTX &rt_nocoef, #endif @@ -2798,8 +2645,8 @@ static void rd_use_partition(VP10_COMP *cpi, vp10_rd_cost_init(&tmp_rdc); rd_use_partition(cpi, td, tile_data, mib + jj * hbs * cm->mi_stride + ii * hbs, tp, - mi_row + y_idx, mi_col + x_idx, subsize, - &tmp_rdc.rate, &tmp_rdc.dist, + mi_row + y_idx, mi_col + x_idx, subsize, &tmp_rdc.rate, + &tmp_rdc.dist, #if CONFIG_SUPERTX &rt_nocoef, #endif @@ -2822,31 +2669,25 @@ static void rd_use_partition(VP10_COMP *cpi, case PARTITION_VERT_A: case PARTITION_VERT_B: case PARTITION_HORZ_A: - case PARTITION_HORZ_B: - assert(0 && "Cannot handle extended partiton types"); + case PARTITION_HORZ_B: assert(0 && "Cannot handle extended partiton types"); #endif // CONFIG_EXT_PARTITION_TYPES - default: - assert(0); - break; + default: assert(0); break; } if (last_part_rdc.rate < INT_MAX) { last_part_rdc.rate += cpi->partition_cost[pl][partition]; - last_part_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, - last_part_rdc.rate, last_part_rdc.dist); + last_part_rdc.rdcost = + RDCOST(x->rdmult, x->rddiv, last_part_rdc.rate, last_part_rdc.dist); #if CONFIG_SUPERTX last_part_rate_nocoef += cpi->partition_cost[pl][partition]; #endif } - if (do_partition_search - && cpi->sf.adjust_partitioning_from_last_frame - && cpi->sf.partition_search_type == SEARCH_PARTITION - && partition != PARTITION_SPLIT && bsize > BLOCK_8X8 - && (mi_row + bs < cm->mi_rows || - mi_row + hbs == cm->mi_rows) - && (mi_col + bs < cm->mi_cols || - mi_col + hbs == cm->mi_cols)) { + if (do_partition_search && cpi->sf.adjust_partitioning_from_last_frame && + cpi->sf.partition_search_type == SEARCH_PARTITION && + partition != PARTITION_SPLIT && bsize > BLOCK_8X8 && + (mi_row + bs < cm->mi_rows || mi_row + hbs == cm->mi_rows) && + (mi_col + bs < cm->mi_cols || mi_col + hbs == cm->mi_cols)) { BLOCK_SIZE split_subsize = get_subsize(bsize, PARTITION_SPLIT); chosen_rdc.rate = 0; chosen_rdc.dist = 0; @@ -2873,8 +2714,8 @@ static void rd_use_partition(VP10_COMP *cpi, save_context(x, &x_ctx, mi_row, mi_col, bsize); pc_tree->split[i]->partitioning = PARTITION_NONE; - rd_pick_sb_modes(cpi, tile_data, x, - mi_row + y_idx, mi_col + x_idx, &tmp_rdc, + rd_pick_sb_modes(cpi, tile_data, x, mi_row + y_idx, mi_col + x_idx, + &tmp_rdc, #if CONFIG_SUPERTX &rt_nocoef, #endif @@ -2900,7 +2741,7 @@ static void rd_use_partition(VP10_COMP *cpi, #endif if (i != 3) - encode_sb(cpi, td, tile_info, tp, mi_row + y_idx, mi_col + x_idx, 0, + encode_sb(cpi, td, tile_info, tp, mi_row + y_idx, mi_col + x_idx, 0, split_subsize, pc_tree->split[i]); chosen_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE]; @@ -2910,8 +2751,8 @@ static void rd_use_partition(VP10_COMP *cpi, } if (chosen_rdc.rate < INT_MAX) { chosen_rdc.rate += cpi->partition_cost[pl][PARTITION_SPLIT]; - chosen_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, - chosen_rdc.rate, chosen_rdc.dist); + chosen_rdc.rdcost = + RDCOST(x->rdmult, x->rddiv, chosen_rdc.rate, chosen_rdc.dist); #if CONFIG_SUPERTX chosen_rate_nocoef += cpi->partition_cost[pl][PARTITION_NONE]; #endif @@ -2921,8 +2762,7 @@ static void rd_use_partition(VP10_COMP *cpi, // If last_part is better set the partitioning to that. if (last_part_rdc.rdcost < chosen_rdc.rdcost) { mib[0]->mbmi.sb_type = bsize; - if (bsize >= BLOCK_8X8) - pc_tree->partitioning = partition; + if (bsize >= BLOCK_8X8) pc_tree->partitioning = partition; chosen_rdc = last_part_rdc; #if CONFIG_SUPERTX chosen_rate_nocoef = last_part_rate_nocoef; @@ -2930,8 +2770,7 @@ static void rd_use_partition(VP10_COMP *cpi, } // If none was better set the partitioning to that. if (none_rdc.rdcost < chosen_rdc.rdcost) { - if (bsize >= BLOCK_8X8) - pc_tree->partitioning = PARTITION_NONE; + if (bsize >= BLOCK_8X8) pc_tree->partitioning = PARTITION_NONE; chosen_rdc = none_rdc; #if CONFIG_SUPERTX chosen_rate_nocoef = none_rate_nocoef; @@ -2958,22 +2797,23 @@ static void rd_use_partition(VP10_COMP *cpi, #endif } +/* clang-format off */ static const BLOCK_SIZE min_partition_size[BLOCK_SIZES] = { - BLOCK_4X4, // 4x4 - BLOCK_4X4, BLOCK_4X4, BLOCK_4X4, // 4x8, 8x4, 8x8 - BLOCK_4X4, BLOCK_4X4, BLOCK_8X8, // 8x16, 16x8, 16x16 - BLOCK_8X8, BLOCK_8X8, BLOCK_16X16, // 16x32, 32x16, 32x32 - BLOCK_16X16, BLOCK_16X16, BLOCK_16X16, // 32x64, 64x32, 64x64 + BLOCK_4X4, // 4x4 + BLOCK_4X4, BLOCK_4X4, BLOCK_4X4, // 4x8, 8x4, 8x8 + BLOCK_4X4, BLOCK_4X4, BLOCK_8X8, // 8x16, 16x8, 16x16 + BLOCK_8X8, BLOCK_8X8, BLOCK_16X16, // 16x32, 32x16, 32x32 + BLOCK_16X16, BLOCK_16X16, BLOCK_16X16, // 32x64, 64x32, 64x64 #if CONFIG_EXT_PARTITION - BLOCK_16X16, BLOCK_16X16, BLOCK_16X16 // 64x128, 128x64, 128x128 + BLOCK_16X16, BLOCK_16X16, BLOCK_16X16 // 64x128, 128x64, 128x128 #endif // CONFIG_EXT_PARTITION }; static const BLOCK_SIZE max_partition_size[BLOCK_SIZES] = { - BLOCK_8X8, // 4x4 - BLOCK_16X16, BLOCK_16X16, BLOCK_16X16, // 4x8, 8x4, 8x8 - BLOCK_32X32, BLOCK_32X32, BLOCK_32X32, // 8x16, 16x8, 16x16 - BLOCK_64X64, BLOCK_64X64, BLOCK_64X64, // 16x32, 32x16, 32x32 + BLOCK_8X8, // 4x4 + BLOCK_16X16, BLOCK_16X16, BLOCK_16X16, // 4x8, 8x4, 8x8 + BLOCK_32X32, BLOCK_32X32, BLOCK_32X32, // 8x16, 16x8, 16x16 + BLOCK_64X64, BLOCK_64X64, BLOCK_64X64, // 16x32, 32x16, 32x32 BLOCK_LARGEST, BLOCK_LARGEST, BLOCK_LARGEST, // 32x64, 64x32, 64x64 #if CONFIG_EXT_PARTITION BLOCK_LARGEST, BLOCK_LARGEST, BLOCK_LARGEST // 64x128, 128x64, 128x128 @@ -2982,15 +2822,16 @@ static const BLOCK_SIZE max_partition_size[BLOCK_SIZES] = { // Next square block size less or equal than current block size. static const BLOCK_SIZE next_square_size[BLOCK_SIZES] = { - BLOCK_4X4, // 4x4 - BLOCK_4X4, BLOCK_4X4, BLOCK_8X8, // 4x8, 8x4, 8x8 - BLOCK_8X8, BLOCK_8X8, BLOCK_16X16, // 8x16, 16x8, 16x16 + BLOCK_4X4, // 4x4 + BLOCK_4X4, BLOCK_4X4, BLOCK_8X8, // 4x8, 8x4, 8x8 + BLOCK_8X8, BLOCK_8X8, BLOCK_16X16, // 8x16, 16x8, 16x16 BLOCK_16X16, BLOCK_16X16, BLOCK_32X32, // 16x32, 32x16, 32x32 BLOCK_32X32, BLOCK_32X32, BLOCK_64X64, // 32x64, 64x32, 64x64 #if CONFIG_EXT_PARTITION BLOCK_64X64, BLOCK_64X64, BLOCK_128X128 // 64x128, 128x64, 128x128 #endif // CONFIG_EXT_PARTITION }; +/* clang-format on */ // Look at all the mode_info entries for blocks that are part of this // partition and find the min and max values for sb_type. @@ -3010,7 +2851,7 @@ static void get_sb_partition_size_range(const VP10_COMMON *const cm, // Check the sb_type for each block that belongs to this region. for (i = 0; i < cm->mib_size; ++i) { for (j = 0; j < cm->mib_size; ++j) { - MODE_INFO *mi = mib[index+j]; + MODE_INFO *mi = mib[index + j]; BLOCK_SIZE sb_type = mi ? mi->mbmi.sb_type : BLOCK_4X4; *min_block_size = VPXMIN(*min_block_size, sb_type); *max_block_size = VPXMAX(*max_block_size, sb_type); @@ -3022,9 +2863,8 @@ static void get_sb_partition_size_range(const VP10_COMMON *const cm, // Look at neighboring blocks and set a min and max partition size based on // what they chose. static void rd_auto_partition_range(VP10_COMP *cpi, const TileInfo *const tile, - MACROBLOCKD *const xd, - int mi_row, int mi_col, - BLOCK_SIZE *min_block_size, + MACROBLOCKD *const xd, int mi_row, + int mi_col, BLOCK_SIZE *min_block_size, BLOCK_SIZE *max_block_size) { VP10_COMMON *const cm = &cpi->common; MODE_INFO **mi = xd->mi; @@ -3094,10 +2934,10 @@ static void rd_auto_partition_range(VP10_COMP *cpi, const TileInfo *const tile, } // TODO(jingning) refactor functions setting partition search range -static void set_partition_range(VP10_COMMON *cm, MACROBLOCKD *xd, - int mi_row, int mi_col, BLOCK_SIZE bsize, +static void set_partition_range(VP10_COMMON *cm, MACROBLOCKD *xd, int mi_row, + int mi_col, BLOCK_SIZE bsize, BLOCK_SIZE *min_bs, BLOCK_SIZE *max_bs) { - int mi_width = num_8x8_blocks_wide_lookup[bsize]; + int mi_width = num_8x8_blocks_wide_lookup[bsize]; int mi_height = num_8x8_blocks_high_lookup[bsize]; int idx, idy; @@ -3156,27 +2996,69 @@ static INLINE void load_pred_mv(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx) { } #if CONFIG_FP_MB_STATS -const int qindex_skip_threshold_lookup[BLOCK_SIZES] = - {0, 10, 10, 30, 40, 40, 60, 80, 80, 90, 100, 100, 120, +const int qindex_skip_threshold_lookup[BLOCK_SIZES] = { + 0, + 10, + 10, + 30, + 40, + 40, + 60, + 80, + 80, + 90, + 100, + 100, + 120, #if CONFIG_EXT_PARTITION // TODO(debargha): What are the correct numbers here? - 130, 130, 150 + 130, + 130, + 150 #endif // CONFIG_EXT_PARTITION - }; -const int qindex_split_threshold_lookup[BLOCK_SIZES] = - {0, 3, 3, 7, 15, 15, 30, 40, 40, 60, 80, 80, 120, +}; +const int qindex_split_threshold_lookup[BLOCK_SIZES] = { + 0, + 3, + 3, + 7, + 15, + 15, + 30, + 40, + 40, + 60, + 80, + 80, + 120, #if CONFIG_EXT_PARTITION // TODO(debargha): What are the correct numbers here? - 160, 160, 240 + 160, + 160, + 240 #endif // CONFIG_EXT_PARTITION - }; -const int complexity_16x16_blocks_threshold[BLOCK_SIZES] = - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 6 +}; +const int complexity_16x16_blocks_threshold[BLOCK_SIZES] = { + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 4, + 4, + 6 #if CONFIG_EXT_PARTITION // TODO(debargha): What are the correct numbers here? - 8, 8, 10 + 8, + 8, + 10 #endif // CONFIG_EXT_PARTITION - }; +}; typedef enum { MV_ZERO = 0, @@ -3212,20 +3094,16 @@ static INLINE int get_motion_inconsistency(MOTION_DIRECTION this_mv, #endif #if CONFIG_EXT_PARTITION_TYPES -static void rd_test_partition3(VP10_COMP *cpi, ThreadData *td, - TileDataEnc *tile_data, - TOKENEXTRA **tp, PC_TREE *pc_tree, - RD_COST *best_rdc, PICK_MODE_CONTEXT ctxs[3], - PICK_MODE_CONTEXT *ctx, - int mi_row, int mi_col, BLOCK_SIZE bsize, - PARTITION_TYPE partition, +static void rd_test_partition3( + VP10_COMP *cpi, ThreadData *td, TileDataEnc *tile_data, TOKENEXTRA **tp, + PC_TREE *pc_tree, RD_COST *best_rdc, PICK_MODE_CONTEXT ctxs[3], + PICK_MODE_CONTEXT *ctx, int mi_row, int mi_col, BLOCK_SIZE bsize, + PARTITION_TYPE partition, #if CONFIG_SUPERTX - int64_t best_rd, int *best_rate_nocoef, - RD_SEARCH_MACROBLOCK_CONTEXT* x_ctx, + int64_t best_rd, int *best_rate_nocoef, RD_SEARCH_MACROBLOCK_CONTEXT *x_ctx, #endif - int mi_row0, int mi_col0, BLOCK_SIZE subsize0, - int mi_row1, int mi_col1, BLOCK_SIZE subsize1, - int mi_row2, int mi_col2, BLOCK_SIZE subsize2) { + int mi_row0, int mi_col0, BLOCK_SIZE subsize0, int mi_row1, int mi_col1, + BLOCK_SIZE subsize1, int mi_row2, int mi_col2, BLOCK_SIZE subsize2) { MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; RD_COST this_rdc, sum_rdc; @@ -3234,13 +3112,11 @@ static void rd_test_partition3(VP10_COMP *cpi, ThreadData *td, TileInfo *const tile_info = &tile_data->tile_info; int this_rate_nocoef, sum_rate_nocoef; int abort_flag; - const int supertx_allowed = - !frame_is_intra_only(cm) && - bsize <= MAX_SUPERTX_BLOCK_SIZE && - !xd->lossless[0]; + const int supertx_allowed = !frame_is_intra_only(cm) && + bsize <= MAX_SUPERTX_BLOCK_SIZE && + !xd->lossless[0]; #endif - if (cpi->sf.adaptive_motion_search) - load_pred_mv(x, ctx); + if (cpi->sf.adaptive_motion_search) load_pred_mv(x, ctx); rd_pick_sb_modes(cpi, tile_data, x, mi_row0, mi_col0, &sum_rdc, #if CONFIG_SUPERTX @@ -3263,8 +3139,7 @@ static void rd_test_partition3(VP10_COMP *cpi, ThreadData *td, update_state(cpi, td, ctx, mi_row0, mi_col0, subsize0, 0); encode_superblock(cpi, td, tp, 0, mi_row0, mi_col0, subsize0, ctx); - if (cpi->sf.adaptive_motion_search) - load_pred_mv(x, ctx); + if (cpi->sf.adaptive_motion_search) load_pred_mv(x, ctx); #if CONFIG_SUPERTX rd_pick_sb_modes(cpi, tile_data, x, mi_row1, mi_col1, &this_rdc, @@ -3304,8 +3179,7 @@ static void rd_test_partition3(VP10_COMP *cpi, ThreadData *td, update_state(cpi, td, ctx, mi_row1, mi_col1, subsize1, 0); encode_superblock(cpi, td, tp, 0, mi_row1, mi_col1, subsize1, ctx); - if (cpi->sf.adaptive_motion_search) - load_pred_mv(x, ctx); + if (cpi->sf.adaptive_motion_search) load_pred_mv(x, ctx); #if CONFIG_SUPERTX rd_pick_sb_modes(cpi, tile_data, x, mi_row2, mi_col2, &this_rdc, @@ -3342,15 +3216,15 @@ static void rd_test_partition3(VP10_COMP *cpi, ThreadData *td, const PARTITION_TYPE best_partition = pc_tree->partitioning; pc_tree->partitioning = partition; sum_rdc.rate += vp10_cost_bit( - cm->fc->supertx_prob - [partition_supertx_context_lookup[partition]][supertx_size], + cm->fc->supertx_prob[partition_supertx_context_lookup[partition]] + [supertx_size], 0); - sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, - sum_rdc.dist); + sum_rdc.rdcost = + RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist); if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) { TX_TYPE best_tx = DCT_DCT; - RD_COST tmp_rdc = {sum_rate_nocoef, 0, 0}; + RD_COST tmp_rdc = { sum_rate_nocoef, 0, 0 }; restore_context(x, x_ctx, mi_row, mi_col, bsize); @@ -3358,8 +3232,8 @@ static void rd_test_partition3(VP10_COMP *cpi, ThreadData *td, &tmp_rdc.rate, &tmp_rdc.dist, &best_tx, pc_tree); tmp_rdc.rate += vp10_cost_bit( - cm->fc->supertx_prob - [partition_supertx_context_lookup[partition]][supertx_size], + cm->fc->supertx_prob[partition_supertx_context_lookup[partition]] + [supertx_size], 1); tmp_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist); @@ -3377,8 +3251,8 @@ static void rd_test_partition3(VP10_COMP *cpi, ThreadData *td, if (sum_rdc.rdcost < best_rdc->rdcost) { int pl = partition_plane_context(xd, mi_row, mi_col, bsize); sum_rdc.rate += cpi->partition_cost[pl][partition]; - sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, - sum_rdc.dist); + sum_rdc.rdcost = + RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist); #if CONFIG_SUPERTX sum_rate_nocoef += cpi->partition_cost[pl][partition]; #endif @@ -3400,9 +3274,9 @@ static void rd_test_partition3(VP10_COMP *cpi, ThreadData *td, // unlikely to be selected depending on previous rate-distortion optimization // results, for encoding speed-up. static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, - TileDataEnc *tile_data, - TOKENEXTRA **tp, int mi_row, int mi_col, - BLOCK_SIZE bsize, RD_COST *rd_cost, + TileDataEnc *tile_data, TOKENEXTRA **tp, + int mi_row, int mi_col, BLOCK_SIZE bsize, + RD_COST *rd_cost, #if CONFIG_SUPERTX int *rate_nocoef, #endif @@ -3424,10 +3298,9 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, #if CONFIG_SUPERTX int this_rate_nocoef, sum_rate_nocoef = 0, best_rate_nocoef = INT_MAX; int abort_flag; - const int supertx_allowed = - !frame_is_intra_only(cm) && - bsize <= MAX_SUPERTX_BLOCK_SIZE && - !xd->lossless[0]; + const int supertx_allowed = !frame_is_intra_only(cm) && + bsize <= MAX_SUPERTX_BLOCK_SIZE && + !xd->lossless[0]; #endif // CONFIG_SUPERTX int do_split = bsize >= BLOCK_8X8; int do_rect = 1; @@ -3450,11 +3323,11 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, #endif int partition_none_allowed = !force_horz_split && !force_vert_split; - int partition_horz_allowed = !force_vert_split && yss <= xss && - bsize >= BLOCK_8X8; - int partition_vert_allowed = !force_horz_split && xss <= yss && - bsize >= BLOCK_8X8; - (void) *tp_orig; + int partition_horz_allowed = + !force_vert_split && yss <= xss && bsize >= BLOCK_8X8; + int partition_vert_allowed = + !force_horz_split && xss <= yss && bsize >= BLOCK_8X8; + (void)*tp_orig; if (force_horz_split || force_vert_split) { tmp_partition_cost[PARTITION_NONE] = INT_MAX; @@ -3490,7 +3363,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, #endif // CONFIG_VAR_TX assert(num_8x8_blocks_wide_lookup[bsize] == - num_8x8_blocks_high_lookup[bsize]); + num_8x8_blocks_high_lookup[bsize]); vp10_rd_cost_init(&this_rdc); vp10_rd_cost_init(&sum_rdc); @@ -3503,8 +3376,10 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, x->mb_energy = vp10_block_energy(cpi, x, bsize); if (cpi->sf.cb_partition_search && bsize == BLOCK_16X16) { - int cb_partition_search_ctrl = ((pc_tree->index == 0 || pc_tree->index == 3) - + get_chessboard_index(cm->current_video_frame)) & 0x1; + int cb_partition_search_ctrl = + ((pc_tree->index == 0 || pc_tree->index == 3) + + get_chessboard_index(cm->current_video_frame)) & + 0x1; if (cb_partition_search_ctrl && bsize > min_size && bsize < max_size) set_partition_range(cm, xd, mi_row, mi_col, bsize, &min_size, &max_size); @@ -3514,10 +3389,10 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, // The threshold set here has to be of square block size. if (cpi->sf.auto_min_max_partition_size) { partition_none_allowed &= (bsize <= max_size && bsize >= min_size); - partition_horz_allowed &= ((bsize <= max_size && bsize > min_size) || - force_horz_split); - partition_vert_allowed &= ((bsize <= max_size && bsize > min_size) || - force_vert_split); + partition_horz_allowed &= + ((bsize <= max_size && bsize > min_size) || force_horz_split); + partition_vert_allowed &= + ((bsize <= max_size && bsize > min_size) || force_vert_split); do_split &= bsize > min_size; } if (cpi->sf.use_square_partition_only) { @@ -3528,7 +3403,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, #if CONFIG_VAR_TX xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); #endif save_context(x, &x_ctx, mi_row, mi_col, bsize); @@ -3536,8 +3411,8 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, #if CONFIG_FP_MB_STATS if (cpi->use_fp_mb_stats) { set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize); - src_diff_var = get_sby_perpixel_diff_variance(cpi, &x->plane[0].src, - mi_row, mi_col, bsize); + src_diff_var = get_sby_perpixel_diff_variance(cpi, &x->plane[0].src, mi_row, + mi_col, bsize); } #endif @@ -3557,7 +3432,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, // compute a complexity measure, basically measure inconsistency of motion // vectors obtained from the first pass in the current block - for (r = mb_row; r < mb_row_end ; r++) { + for (r = mb_row; r < mb_row_end; r++) { for (c = mb_col; c < mb_col_end; c++) { const int mb_index = r * cm->mb_cols + c; @@ -3605,8 +3480,8 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, if (this_rdc.rate != INT_MAX) { if (bsize >= BLOCK_8X8) { this_rdc.rate += partition_cost[PARTITION_NONE]; - this_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, - this_rdc.rate, this_rdc.dist); + this_rdc.rdcost = + RDCOST(x->rdmult, x->rddiv, this_rdc.rate, this_rdc.dist); #if CONFIG_SUPERTX this_rate_nocoef += partition_cost[PARTITION_NONE]; #endif @@ -3621,12 +3496,12 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, best_rate_nocoef = this_rate_nocoef; assert(best_rate_nocoef >= 0); #endif - if (bsize >= BLOCK_8X8) - pc_tree->partitioning = PARTITION_NONE; + if (bsize >= BLOCK_8X8) pc_tree->partitioning = PARTITION_NONE; // Adjust dist breakout threshold according to the partition size. - dist_breakout_thr >>= (2 * (MAX_SB_SIZE_LOG2 - 2)) - - (b_width_log2_lookup[bsize] + b_height_log2_lookup[bsize]); + dist_breakout_thr >>= + (2 * (MAX_SB_SIZE_LOG2 - 2)) - + (b_width_log2_lookup[bsize] + b_height_log2_lookup[bsize]); rate_breakout_thr *= num_pels_log2_lookup[bsize]; @@ -3637,7 +3512,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, // early termination at that speed. if (!x->e_mbd.lossless[xd->mi[0]->mbmi.segment_id] && (ctx->skippable && best_rdc.dist < dist_breakout_thr && - best_rdc.rate < rate_breakout_thr)) { + best_rdc.rate < rate_breakout_thr)) { do_split = 0; do_rect = 0; } @@ -3694,8 +3569,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, } // store estimated motion vector - if (cpi->sf.adaptive_motion_search) - store_pred_mv(x, ctx); + if (cpi->sf.adaptive_motion_search) store_pred_mv(x, ctx); // PARTITION_SPLIT // TODO(jingning): use the motion vectors given by the above search as @@ -3741,33 +3615,30 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, pc_tree->partitioning = PARTITION_SPLIT; sum_rdc.rate += vp10_cost_bit( - cm->fc->supertx_prob - [partition_supertx_context_lookup[PARTITION_SPLIT]][supertx_size], + cm->fc->supertx_prob[partition_supertx_context_lookup + [PARTITION_SPLIT]][supertx_size], 0); sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist); if (is_inter_mode(pc_tree->leaf_split[0]->mic.mbmi.mode)) { TX_TYPE best_tx = DCT_DCT; - RD_COST tmp_rdc = {sum_rate_nocoef, 0, 0}; + RD_COST tmp_rdc = { sum_rate_nocoef, 0, 0 }; restore_context(x, &x_ctx, mi_row, mi_col, bsize); rd_supertx_sb(cpi, td, tile_info, mi_row, mi_col, bsize, - &tmp_rdc.rate, &tmp_rdc.dist, - &best_tx, - pc_tree); + &tmp_rdc.rate, &tmp_rdc.dist, &best_tx, pc_tree); tmp_rdc.rate += vp10_cost_bit( - cm->fc->supertx_prob - [partition_supertx_context_lookup[PARTITION_SPLIT]][supertx_size], + cm->fc->supertx_prob[partition_supertx_context_lookup + [PARTITION_SPLIT]][supertx_size], 1); tmp_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist); if (tmp_rdc.rdcost < sum_rdc.rdcost) { sum_rdc = tmp_rdc; - update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, - best_tx, + update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx, supertx_size, pc_tree); } } @@ -3787,19 +3658,16 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, if (mi_row + y_idx >= cm->mi_rows || mi_col + x_idx >= cm->mi_cols) continue; - if (cpi->sf.adaptive_motion_search) - load_pred_mv(x, ctx); + if (cpi->sf.adaptive_motion_search) load_pred_mv(x, ctx); pc_tree->split[i]->index = i; #if CONFIG_SUPERTX - rd_pick_partition(cpi, td, tile_data, tp, - mi_row + y_idx, mi_col + x_idx, - subsize, &this_rdc, &this_rate_nocoef, + rd_pick_partition(cpi, td, tile_data, tp, mi_row + y_idx, + mi_col + x_idx, subsize, &this_rdc, &this_rate_nocoef, INT64_MAX - sum_rdc.rdcost, pc_tree->split[i]); #else - rd_pick_partition(cpi, td, tile_data, tp, - mi_row + y_idx, mi_col + x_idx, - subsize, &this_rdc, + rd_pick_partition(cpi, td, tile_data, tp, mi_row + y_idx, + mi_col + x_idx, subsize, &this_rdc, best_rdc.rdcost - sum_rdc.rdcost, pc_tree->split[i]); #endif // CONFIG_SUPERTX @@ -3826,33 +3694,30 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, pc_tree->partitioning = PARTITION_SPLIT; sum_rdc.rate += vp10_cost_bit( - cm->fc->supertx_prob - [partition_supertx_context_lookup[PARTITION_SPLIT]][supertx_size], + cm->fc->supertx_prob[partition_supertx_context_lookup + [PARTITION_SPLIT]][supertx_size], 0); sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist); if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) { TX_TYPE best_tx = DCT_DCT; - RD_COST tmp_rdc = {sum_rate_nocoef, 0, 0}; + RD_COST tmp_rdc = { sum_rate_nocoef, 0, 0 }; restore_context(x, &x_ctx, mi_row, mi_col, bsize); rd_supertx_sb(cpi, td, tile_info, mi_row, mi_col, bsize, - &tmp_rdc.rate, &tmp_rdc.dist, - &best_tx, - pc_tree); + &tmp_rdc.rate, &tmp_rdc.dist, &best_tx, pc_tree); tmp_rdc.rate += vp10_cost_bit( - cm->fc->supertx_prob - [partition_supertx_context_lookup[PARTITION_SPLIT]][supertx_size], + cm->fc->supertx_prob[partition_supertx_context_lookup + [PARTITION_SPLIT]][supertx_size], 1); tmp_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist); if (tmp_rdc.rdcost < sum_rdc.rdcost) { sum_rdc = tmp_rdc; - update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, - best_tx, + update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx, supertx_size, pc_tree); } } @@ -3864,8 +3729,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, if (sum_rdc.rdcost < best_rdc.rdcost && i == 4) { sum_rdc.rate += partition_cost[PARTITION_SPLIT]; - sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, - sum_rdc.rate, sum_rdc.dist); + sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist); #if CONFIG_SUPERTX sum_rate_nocoef += partition_cost[PARTITION_SPLIT]; #endif // CONFIG_SUPERTX @@ -3881,8 +3745,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, } else { // skip rectangular partition test when larger block size // gives better rd cost - if (cpi->sf.less_rectangular_check) - do_rect &= !partition_none_allowed; + if (cpi->sf.less_rectangular_check) do_rect &= !partition_none_allowed; } restore_context(x, &x_ctx, mi_row, mi_col, bsize); @@ -3892,8 +3755,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, if (partition_horz_allowed && (do_rect || vp10_active_h_edge(cpi, mi_row, mi_step))) { subsize = get_subsize(bsize, PARTITION_HORZ); - if (cpi->sf.adaptive_motion_search) - load_pred_mv(x, ctx); + if (cpi->sf.adaptive_motion_search) load_pred_mv(x, ctx); #if CONFIG_DUAL_FILTER if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 && partition_none_allowed) @@ -3902,8 +3764,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, #else if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 && partition_none_allowed) - pc_tree->horizontal[0].pred_interp_filter = - ctx->mic.mbmi.interp_filter; + pc_tree->horizontal[0].pred_interp_filter = ctx->mic.mbmi.interp_filter; #endif rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, #if CONFIG_SUPERTX @@ -3916,19 +3777,17 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, #if CONFIG_SUPERTX abort_flag = (sum_rdc.rdcost >= best_rd && bsize > BLOCK_8X8) || - (sum_rdc.rate == INT_MAX && bsize == BLOCK_8X8); + (sum_rdc.rate == INT_MAX && bsize == BLOCK_8X8); if (sum_rdc.rdcost < INT64_MAX && #else if (sum_rdc.rdcost < best_rdc.rdcost && #endif // CONFIG_SUPERTX - mi_row + mi_step < cm->mi_rows && - bsize > BLOCK_8X8) { + mi_row + mi_step < cm->mi_rows && bsize > BLOCK_8X8) { PICK_MODE_CONTEXT *ctx = &pc_tree->horizontal[0]; update_state(cpi, td, ctx, mi_row, mi_col, subsize, 0); encode_superblock(cpi, td, tp, 0, mi_row, mi_col, subsize, ctx); - if (cpi->sf.adaptive_motion_search) - load_pred_mv(x, ctx); + if (cpi->sf.adaptive_motion_search) load_pred_mv(x, ctx); #if CONFIG_DUAL_FILTER if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 && @@ -3938,20 +3797,17 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, #else if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 && partition_none_allowed) - pc_tree->horizontal[1].pred_interp_filter = - ctx->mic.mbmi.interp_filter; + pc_tree->horizontal[1].pred_interp_filter = ctx->mic.mbmi.interp_filter; #endif #if CONFIG_SUPERTX - rd_pick_sb_modes(cpi, tile_data, x, mi_row + mi_step, mi_col, - &this_rdc, &this_rate_nocoef, + rd_pick_sb_modes(cpi, tile_data, x, mi_row + mi_step, mi_col, &this_rdc, + &this_rate_nocoef, #if CONFIG_EXT_PARTITION_TYPES PARTITION_HORZ, #endif - subsize, &pc_tree->horizontal[1], - INT64_MAX); + subsize, &pc_tree->horizontal[1], INT64_MAX); #else - rd_pick_sb_modes(cpi, tile_data, x, mi_row + mi_step, mi_col, - &this_rdc, + rd_pick_sb_modes(cpi, tile_data, x, mi_row + mi_step, mi_col, &this_rdc, #if CONFIG_EXT_PARTITION_TYPES PARTITION_HORZ, #endif @@ -3982,30 +3838,29 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, sum_rdc.rate += vp10_cost_bit( cm->fc->supertx_prob[partition_supertx_context_lookup[PARTITION_HORZ]] - [supertx_size], 0); + [supertx_size], + 0); sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist); if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) { TX_TYPE best_tx = DCT_DCT; - RD_COST tmp_rdc = {sum_rate_nocoef, 0, 0}; + RD_COST tmp_rdc = { sum_rate_nocoef, 0, 0 }; restore_context(x, &x_ctx, mi_row, mi_col, bsize); - rd_supertx_sb(cpi, td, tile_info, mi_row, mi_col, bsize, - &tmp_rdc.rate, &tmp_rdc.dist, - &best_tx, - pc_tree); + rd_supertx_sb(cpi, td, tile_info, mi_row, mi_col, bsize, &tmp_rdc.rate, + &tmp_rdc.dist, &best_tx, pc_tree); tmp_rdc.rate += vp10_cost_bit( - cm->fc->supertx_prob - [partition_supertx_context_lookup[PARTITION_HORZ]][supertx_size], + cm->fc + ->supertx_prob[partition_supertx_context_lookup[PARTITION_HORZ]] + [supertx_size], 1); tmp_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist); if (tmp_rdc.rdcost < sum_rdc.rdcost) { sum_rdc = tmp_rdc; - update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, - best_tx, + update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx, supertx_size, pc_tree); } } @@ -4038,19 +3893,16 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, (do_rect || vp10_active_v_edge(cpi, mi_col, mi_step))) { subsize = get_subsize(bsize, PARTITION_VERT); - if (cpi->sf.adaptive_motion_search) - load_pred_mv(x, ctx); + if (cpi->sf.adaptive_motion_search) load_pred_mv(x, ctx); #if CONFIG_DUAL_FILTER if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 && partition_none_allowed) - pc_tree->vertical[0].pred_interp_filter = - ctx->mic.mbmi.interp_filter[0]; + pc_tree->vertical[0].pred_interp_filter = ctx->mic.mbmi.interp_filter[0]; #else if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 && partition_none_allowed) - pc_tree->vertical[0].pred_interp_filter = - ctx->mic.mbmi.interp_filter; + pc_tree->vertical[0].pred_interp_filter = ctx->mic.mbmi.interp_filter; #endif rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, #if CONFIG_SUPERTX @@ -4067,14 +3919,12 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, #else if (sum_rdc.rdcost < best_rdc.rdcost && #endif // CONFIG_SUPERTX - mi_col + mi_step < cm->mi_cols && - bsize > BLOCK_8X8) { + mi_col + mi_step < cm->mi_cols && bsize > BLOCK_8X8) { update_state(cpi, td, &pc_tree->vertical[0], mi_row, mi_col, subsize, 0); encode_superblock(cpi, td, tp, 0, mi_row, mi_col, subsize, &pc_tree->vertical[0]); - if (cpi->sf.adaptive_motion_search) - load_pred_mv(x, ctx); + if (cpi->sf.adaptive_motion_search) load_pred_mv(x, ctx); #if CONFIG_DUAL_FILTER if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 && @@ -4084,8 +3934,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, #else if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 && partition_none_allowed) - pc_tree->vertical[1].pred_interp_filter = - ctx->mic.mbmi.interp_filter; + pc_tree->vertical[1].pred_interp_filter = ctx->mic.mbmi.interp_filter; #endif #if CONFIG_SUPERTX rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + mi_step, &this_rdc, @@ -4096,13 +3945,12 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, subsize, &pc_tree->vertical[1], INT64_MAX - sum_rdc.rdcost); #else - rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + mi_step, - &this_rdc, + rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + mi_step, &this_rdc, #if CONFIG_EXT_PARTITION_TYPES PARTITION_VERT, #endif - subsize, - &pc_tree->vertical[1], best_rdc.rdcost - sum_rdc.rdcost); + subsize, &pc_tree->vertical[1], + best_rdc.rdcost - sum_rdc.rdcost); #endif // CONFIG_SUPERTX if (this_rdc.rate == INT_MAX) { sum_rdc.rdcost = INT64_MAX; @@ -4127,30 +3975,29 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, sum_rdc.rate += vp10_cost_bit( cm->fc->supertx_prob[partition_supertx_context_lookup[PARTITION_VERT]] - [supertx_size], 0); + [supertx_size], + 0); sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist); if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) { TX_TYPE best_tx = DCT_DCT; - RD_COST tmp_rdc = {sum_rate_nocoef, 0, 0}; + RD_COST tmp_rdc = { sum_rate_nocoef, 0, 0 }; restore_context(x, &x_ctx, mi_row, mi_col, bsize); - rd_supertx_sb(cpi, td, tile_info, mi_row, mi_col, bsize, - &tmp_rdc.rate, &tmp_rdc.dist, - &best_tx, - pc_tree); + rd_supertx_sb(cpi, td, tile_info, mi_row, mi_col, bsize, &tmp_rdc.rate, + &tmp_rdc.dist, &best_tx, pc_tree); tmp_rdc.rate += vp10_cost_bit( - cm->fc->supertx_prob - [partition_supertx_context_lookup[PARTITION_VERT]][supertx_size], + cm->fc + ->supertx_prob[partition_supertx_context_lookup[PARTITION_VERT]] + [supertx_size], 1); tmp_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist); if (tmp_rdc.rdcost < sum_rdc.rdcost) { sum_rdc = tmp_rdc; - update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, - best_tx, + update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx, supertx_size, pc_tree); } } @@ -4161,8 +4008,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, if (sum_rdc.rdcost < best_rdc.rdcost) { sum_rdc.rate += partition_cost[PARTITION_VERT]; - sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, - sum_rdc.rate, sum_rdc.dist); + sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist); #if CONFIG_SUPERTX sum_rate_nocoef += partition_cost[PARTITION_VERT]; #endif // CONFIG_SUPERTX @@ -4184,13 +4030,12 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, partition_none_allowed) { subsize = get_subsize(bsize, PARTITION_HORZ_A); rd_test_partition3(cpi, td, tile_data, tp, pc_tree, &best_rdc, - pc_tree->horizontala, - ctx, mi_row, mi_col, bsize, PARTITION_HORZ_A, + pc_tree->horizontala, ctx, mi_row, mi_col, bsize, + PARTITION_HORZ_A, #if CONFIG_SUPERTX best_rd, &best_rate_nocoef, &x_ctx, #endif - mi_row, mi_col, bsize2, - mi_row, mi_col + mi_step, bsize2, + mi_row, mi_col, bsize2, mi_row, mi_col + mi_step, bsize2, mi_row + mi_step, mi_col, subsize); restore_context(x, &x_ctx, mi_row, mi_col, bsize); } @@ -4199,14 +4044,13 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, partition_none_allowed) { subsize = get_subsize(bsize, PARTITION_HORZ_B); rd_test_partition3(cpi, td, tile_data, tp, pc_tree, &best_rdc, - pc_tree->horizontalb, - ctx, mi_row, mi_col, bsize, PARTITION_HORZ_B, + pc_tree->horizontalb, ctx, mi_row, mi_col, bsize, + PARTITION_HORZ_B, #if CONFIG_SUPERTX best_rd, &best_rate_nocoef, &x_ctx, #endif - mi_row, mi_col, subsize, - mi_row + mi_step, mi_col, bsize2, - mi_row + mi_step, mi_col + mi_step, bsize2); + mi_row, mi_col, subsize, mi_row + mi_step, mi_col, + bsize2, mi_row + mi_step, mi_col + mi_step, bsize2); restore_context(x, &x_ctx, mi_row, mi_col, bsize); } // PARTITION_VERT_A @@ -4214,13 +4058,12 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, partition_none_allowed) { subsize = get_subsize(bsize, PARTITION_VERT_A); rd_test_partition3(cpi, td, tile_data, tp, pc_tree, &best_rdc, - pc_tree->verticala, - ctx, mi_row, mi_col, bsize, PARTITION_VERT_A, + pc_tree->verticala, ctx, mi_row, mi_col, bsize, + PARTITION_VERT_A, #if CONFIG_SUPERTX best_rd, &best_rate_nocoef, &x_ctx, #endif - mi_row, mi_col, bsize2, - mi_row + mi_step, mi_col, bsize2, + mi_row, mi_col, bsize2, mi_row + mi_step, mi_col, bsize2, mi_row, mi_col + mi_step, subsize); restore_context(x, &x_ctx, mi_row, mi_col, bsize); } @@ -4229,14 +4072,13 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, partition_none_allowed) { subsize = get_subsize(bsize, PARTITION_VERT_B); rd_test_partition3(cpi, td, tile_data, tp, pc_tree, &best_rdc, - pc_tree->verticalb, - ctx, mi_row, mi_col, bsize, PARTITION_VERT_B, + pc_tree->verticalb, ctx, mi_row, mi_col, bsize, + PARTITION_VERT_B, #if CONFIG_SUPERTX best_rd, &best_rate_nocoef, &x_ctx, #endif - mi_row, mi_col, subsize, - mi_row, mi_col + mi_step, bsize2, - mi_row + mi_step, mi_col + mi_step, bsize2); + mi_row, mi_col, subsize, mi_row, mi_col + mi_step, + bsize2, mi_row + mi_step, mi_col + mi_step, bsize2); restore_context(x, &x_ctx, mi_row, mi_col, bsize); } #endif // CONFIG_EXT_PARTITION_TYPES @@ -4245,7 +4087,7 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, // warning related to the fact that best_rd isn't used after this // point. This code should be refactored so that the duplicate // checks occur in some sub function and thus are used... - (void) best_rd; + (void)best_rd; *rd_cost = best_rdc; #if CONFIG_SUPERTX *rate_nocoef = best_rate_nocoef; @@ -4254,8 +4096,8 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, if (best_rdc.rate < INT_MAX && best_rdc.dist < INT64_MAX && pc_tree->index != 3) { int output_enabled = (bsize == cm->sb_size); - encode_sb(cpi, td, tile_info, tp, mi_row, mi_col, output_enabled, - bsize, pc_tree); + encode_sb(cpi, td, tile_info, tp, mi_row, mi_col, output_enabled, bsize, + pc_tree); } if (bsize == cm->sb_size) { @@ -4267,10 +4109,8 @@ static void rd_pick_partition(VP10_COMP *cpi, ThreadData *td, } } -static void encode_rd_sb_row(VP10_COMP *cpi, - ThreadData *td, - TileDataEnc *tile_data, - int mi_row, +static void encode_rd_sb_row(VP10_COMP *cpi, ThreadData *td, + TileDataEnc *tile_data, int mi_row, TOKENEXTRA **tp) { VP10_COMMON *const cm = &cpi->common; const TileInfo *const tile_info = &tile_data->tile_info; @@ -4320,8 +4160,8 @@ static void encode_rd_sb_row(VP10_COMP *cpi, pc_root->index = 0; if (seg->enabled) { - const uint8_t *const map = seg->update_map ? cpi->segmentation_map - : cm->last_frame_seg_map; + const uint8_t *const map = + seg->update_map ? cpi->segmentation_map : cm->last_frame_seg_map; int segment_id = get_segment_id(cm, map, cm->sb_size, mi_row, mi_col); seg_skip = segfeature_active(seg, segment_id, SEG_LVL_SKIP); } @@ -4332,8 +4172,8 @@ static void encode_rd_sb_row(VP10_COMP *cpi, set_offsets(cpi, tile_info, x, mi_row, mi_col, cm->sb_size); bsize = seg_skip ? cm->sb_size : sf->always_this_block_size; set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize); - rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, - cm->sb_size, &dummy_rate, &dummy_dist, + rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, cm->sb_size, + &dummy_rate, &dummy_dist, #if CONFIG_SUPERTX &dummy_rate_nocoef, #endif // CONFIG_SUPERTX @@ -4343,16 +4183,16 @@ static void encode_rd_sb_row(VP10_COMP *cpi, set_offsets(cpi, tile_info, x, mi_row, mi_col, cm->sb_size); bsize = get_rd_var_based_fixed_partition(cpi, x, mi_row, mi_col); set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize); - rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, - cm->sb_size, &dummy_rate, &dummy_dist, + rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, cm->sb_size, + &dummy_rate, &dummy_dist, #if CONFIG_SUPERTX &dummy_rate_nocoef, #endif // CONFIG_SUPERTX 1, pc_root); } else if (sf->partition_search_type == VAR_BASED_PARTITION) { choose_partitioning(cpi, td, tile_info, x, mi_row, mi_col); - rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, - cm->sb_size, &dummy_rate, &dummy_dist, + rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, cm->sb_size, + &dummy_rate, &dummy_dist, #if CONFIG_SUPERTX &dummy_rate_nocoef, #endif // CONFIG_SUPERTX @@ -4362,8 +4202,7 @@ static void encode_rd_sb_row(VP10_COMP *cpi, if (sf->auto_min_max_partition_size) { set_offsets(cpi, tile_info, x, mi_row, mi_col, cm->sb_size); rd_auto_partition_range(cpi, tile_info, xd, mi_row, mi_col, - &x->min_partition_size, - &x->max_partition_size); + &x->min_partition_size, &x->max_partition_size); } rd_pick_partition(cpi, td, tile_data, tp, mi_row, mi_col, cm->sb_size, &dummy_rdc, @@ -4376,8 +4215,10 @@ static void encode_rd_sb_row(VP10_COMP *cpi, #if CONFIG_ENTROPY if (cm->do_subframe_update && cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) { - if ((mi_row + MI_SIZE) % (MI_SIZE * - VPXMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1)) == 0 && + if ((mi_row + MI_SIZE) % + (MI_SIZE * + VPXMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1)) == + 0 && mi_row + MI_SIZE < cm->mi_rows && cm->coef_probs_update_idx < COEF_PROBS_BUFS - 1) { TX_SIZE t; @@ -4421,11 +4262,9 @@ static int check_dual_ref_flags(VP10_COMP *cpi) { if (segfeature_active(&cpi->common.seg, 1, SEG_LVL_REF_FRAME)) { return 0; } else { - return (!!(ref_flags & VPX_GOLD_FLAG) + - !!(ref_flags & VPX_LAST_FLAG) + + return (!!(ref_flags & VPX_GOLD_FLAG) + !!(ref_flags & VPX_LAST_FLAG) + #if CONFIG_EXT_REFS - !!(ref_flags & VPX_LAST2_FLAG) + - !!(ref_flags & VPX_LAST3_FLAG) + + !!(ref_flags & VPX_LAST2_FLAG) + !!(ref_flags & VPX_LAST3_FLAG) + !!(ref_flags & VPX_BWD_FLAG) + #endif // CONFIG_EXT_REFS !!(ref_flags & VPX_ALT_FLAG)) >= 2; @@ -4461,11 +4300,10 @@ static MV_REFERENCE_FRAME get_frame_type(const VP10_COMP *cpi) { } static TX_MODE select_tx_mode(const VP10_COMP *cpi, MACROBLOCKD *const xd) { - if (xd->lossless[0]) - return ONLY_4X4; + if (xd->lossless[0]) return ONLY_4X4; if (cpi->sf.tx_size_search_method == USE_LARGESTALL) return ALLOW_32X32; - else if (cpi->sf.tx_size_search_method == USE_FULL_RD|| + else if (cpi->sf.tx_size_search_method == USE_FULL_RD || cpi->sf.tx_size_search_method == USE_TX_8X8) return TX_MODE_SELECT; else @@ -4481,10 +4319,9 @@ void vp10_init_tile_data(VP10_COMP *cpi) { unsigned int tile_tok = 0; if (cpi->tile_data == NULL || cpi->allocated_tiles < tile_cols * tile_rows) { - if (cpi->tile_data != NULL) - vpx_free(cpi->tile_data); - CHECK_MEM_ERROR(cm, cpi->tile_data, - vpx_malloc(tile_cols * tile_rows * sizeof(*cpi->tile_data))); + if (cpi->tile_data != NULL) vpx_free(cpi->tile_data); + CHECK_MEM_ERROR(cm, cpi->tile_data, vpx_malloc(tile_cols * tile_rows * + sizeof(*cpi->tile_data))); cpi->allocated_tiles = tile_cols * tile_rows; for (tile_row = 0; tile_row < tile_rows; ++tile_row) @@ -4514,12 +4351,12 @@ void vp10_init_tile_data(VP10_COMP *cpi) { } } -void vp10_encode_tile(VP10_COMP *cpi, ThreadData *td, - int tile_row, int tile_col) { +void vp10_encode_tile(VP10_COMP *cpi, ThreadData *td, int tile_row, + int tile_col) { VP10_COMMON *const cm = &cpi->common; TileDataEnc *const this_tile = &cpi->tile_data[tile_row * cm->tile_cols + tile_col]; - const TileInfo * const tile_info = &this_tile->tile_info; + const TileInfo *const tile_info = &this_tile->tile_info; TOKENEXTRA *tok = cpi->tile_tok[tile_row][tile_col]; int mi_row; @@ -4554,10 +4391,9 @@ static void encode_tiles(VP10_COMP *cpi) { static int input_fpmb_stats(FIRSTPASS_MB_STATS *firstpass_mb_stats, VP10_COMMON *cm, uint8_t **this_frame_mb_stats) { uint8_t *mb_stats_in = firstpass_mb_stats->mb_stats_start + - cm->current_video_frame * cm->MBs * sizeof(uint8_t); + cm->current_video_frame * cm->MBs * sizeof(uint8_t); - if (mb_stats_in > firstpass_mb_stats->mb_stats_end) - return EOF; + if (mb_stats_in > firstpass_mb_stats->mb_stats_end) return EOF; *this_frame_mb_stats = mb_stats_in; @@ -4567,32 +4403,29 @@ static int input_fpmb_stats(FIRSTPASS_MB_STATS *firstpass_mb_stats, #if CONFIG_GLOBAL_MOTION #define MIN_TRANS_THRESH 8 -#define GLOBAL_MOTION_MODEL ROTZOOM +#define GLOBAL_MOTION_MODEL ROTZOOM static void convert_to_params(double *H, TransformationType type, Global_Motion_Params *model) { int i; int alpha_present = 0; int n_params = n_trans_model_params[type]; - model->motion_params.wmmat[0] = (int) floor(H[0] * - (1 << GM_TRANS_PREC_BITS) + 0.5); - model->motion_params.wmmat[1] = (int) floor(H[1] * - (1 << GM_TRANS_PREC_BITS) + 0.5); model->motion_params.wmmat[0] = - clamp(model->motion_params.wmmat[0], - GM_TRANS_MIN, GM_TRANS_MAX) * - GM_TRANS_DECODE_FACTOR; + (int)floor(H[0] * (1 << GM_TRANS_PREC_BITS) + 0.5); model->motion_params.wmmat[1] = - clamp(model->motion_params.wmmat[1], - GM_TRANS_MIN, GM_TRANS_MAX) * - GM_TRANS_DECODE_FACTOR; + (int)floor(H[1] * (1 << GM_TRANS_PREC_BITS) + 0.5); + model->motion_params.wmmat[0] = + clamp(model->motion_params.wmmat[0], GM_TRANS_MIN, GM_TRANS_MAX) * + GM_TRANS_DECODE_FACTOR; + model->motion_params.wmmat[1] = + clamp(model->motion_params.wmmat[1], GM_TRANS_MIN, GM_TRANS_MAX) * + GM_TRANS_DECODE_FACTOR; for (i = 2; i < n_params; ++i) { model->motion_params.wmmat[i] = - (int) floor(H[i] * - (1 << GM_ALPHA_PREC_BITS) + 0.5); - model->motion_params.wmmat[i] = clamp(model->motion_params.wmmat[i], - GM_ALPHA_MIN, GM_ALPHA_MAX) * - GM_ALPHA_DECODE_FACTOR; + (int)floor(H[i] * (1 << GM_ALPHA_PREC_BITS) + 0.5); + model->motion_params.wmmat[i] = + clamp(model->motion_params.wmmat[i], GM_ALPHA_MIN, GM_ALPHA_MAX) * + GM_ALPHA_DECODE_FACTOR; alpha_present |= (model->motion_params.wmmat[i] != 0); } @@ -4608,8 +4441,7 @@ static void convert_to_params(double *H, TransformationType type, static void convert_model_to_params(double *H, TransformationType type, Global_Motion_Params *model) { // TODO(sarahparker) implement for homography - if (type > HOMOGRAPHY) - convert_to_params(H, type, model); + if (type > HOMOGRAPHY) convert_to_params(H, type, model); model->gmtype = get_gmtype(model); model->motion_params.wmtype = gm_to_trans_type(model->gmtype); } @@ -4642,13 +4474,12 @@ static void encode_frame_internal(VP10_COMP *cpi) { if (cpi->common.frame_type == INTER_FRAME && cpi->Source) { YV12_BUFFER_CONFIG *ref_buf; int frame; - double H[9] = {0, 0, 0, 0, 0, 0, 0, 0, 1}; + double H[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) { ref_buf = get_ref_frame_buffer(cpi, frame); if (ref_buf) { - if (compute_global_motion_feature_based( - cpi, GLOBAL_MOTION_MODEL, cpi->Source, ref_buf, - 0.5, H)) + if (compute_global_motion_feature_based(cpi, GLOBAL_MOTION_MODEL, + cpi->Source, ref_buf, 0.5, H)) convert_model_to_params(H, GLOBAL_MOTION_MODEL, &cm->global_motion[frame]); } @@ -4657,16 +4488,14 @@ static void encode_frame_internal(VP10_COMP *cpi) { #endif // CONFIG_GLOBAL_MOTION for (i = 0; i < MAX_SEGMENTS; ++i) { - const int qindex = cm->seg.enabled ? - vp10_get_qindex(&cm->seg, i, cm->base_qindex) : cm->base_qindex; - xd->lossless[i] = qindex == 0 && - cm->y_dc_delta_q == 0 && - cm->uv_dc_delta_q == 0 && - cm->uv_ac_delta_q == 0; + const int qindex = cm->seg.enabled + ? vp10_get_qindex(&cm->seg, i, cm->base_qindex) + : cm->base_qindex; + xd->lossless[i] = qindex == 0 && cm->y_dc_delta_q == 0 && + cm->uv_dc_delta_q == 0 && cm->uv_ac_delta_q == 0; } - if (!cm->seg.enabled && xd->lossless[0]) - x->optimize = 0; + if (!cm->seg.enabled && xd->lossless[0]) x->optimize = 0; cm->tx_mode = select_tx_mode(cpi, xd); vp10_frame_init_quantizer(cpi); @@ -4675,11 +4504,9 @@ static void encode_frame_internal(VP10_COMP *cpi) { vp10_initialize_me_consts(cpi, x, cm->base_qindex); init_encode_frame_mb_context(cpi); - cm->use_prev_frame_mvs = !cm->error_resilient_mode && - cm->width == cm->last_width && - cm->height == cm->last_height && - !cm->intra_only && - cm->last_show_frame; + cm->use_prev_frame_mvs = + !cm->error_resilient_mode && cm->width == cm->last_width && + cm->height == cm->last_height && !cm->intra_only && cm->last_show_frame; #if CONFIG_EXT_REFS // NOTE(zoeliu): As cm->prev_frame can take neither a frame of // show_exisiting_frame=1, nor can it take a frame not used as @@ -4700,8 +4527,8 @@ static void encode_frame_internal(VP10_COMP *cpi) { // Special case: set prev_mi to NULL when the previous mode info // context cannot be used. - cm->prev_mi = cm->use_prev_frame_mvs ? - cm->prev_mip + cm->mi_stride + 1 : NULL; + cm->prev_mi = + cm->use_prev_frame_mvs ? cm->prev_mip + cm->mi_stride + 1 : NULL; #if CONFIG_VAR_TX #if CONFIG_REF_MV @@ -4718,10 +4545,10 @@ static void encode_frame_internal(VP10_COMP *cpi) { vpx_usec_timer_start(&emr_timer); #if CONFIG_FP_MB_STATS - if (cpi->use_fp_mb_stats) { - input_fpmb_stats(&cpi->twopass.firstpass_mb_stats, cm, - &cpi->twopass.this_frame_mb_stats); - } + if (cpi->use_fp_mb_stats) { + input_fpmb_stats(&cpi->twopass.firstpass_mb_stats, cm, + &cpi->twopass.this_frame_mb_stats); + } #endif // If allowed, encoding tiles in parallel with one thread handling one tile. @@ -4754,9 +4581,9 @@ void vp10_encode_frame(VP10_COMP *cpi) { // the other two. if (!frame_is_intra_only(cm)) { if ((cm->ref_frame_sign_bias[ALTREF_FRAME] == - cm->ref_frame_sign_bias[GOLDEN_FRAME]) || + cm->ref_frame_sign_bias[GOLDEN_FRAME]) || (cm->ref_frame_sign_bias[ALTREF_FRAME] == - cm->ref_frame_sign_bias[LAST_FRAME])) { + cm->ref_frame_sign_bias[LAST_FRAME])) { cpi->allow_comp_inter_inter = 0; } else { cpi->allow_comp_inter_inter = 1; @@ -4802,10 +4629,8 @@ void vp10_encode_frame(VP10_COMP *cpi) { if (is_alt_ref || !cpi->allow_comp_inter_inter) cm->reference_mode = SINGLE_REFERENCE; else if (mode_thrs[COMPOUND_REFERENCE] > mode_thrs[SINGLE_REFERENCE] && - mode_thrs[COMPOUND_REFERENCE] > - mode_thrs[REFERENCE_MODE_SELECT] && - check_dual_ref_flags(cpi) && - cpi->static_mb_pct == 100) + mode_thrs[COMPOUND_REFERENCE] > mode_thrs[REFERENCE_MODE_SELECT] && + check_dual_ref_flags(cpi) && cpi->static_mb_pct == 100) cm->reference_mode = COMPOUND_REFERENCE; else if (mode_thrs[SINGLE_REFERENCE] > mode_thrs[REFERENCE_MODE_SELECT]) cm->reference_mode = SINGLE_REFERENCE; @@ -4876,8 +4701,7 @@ void vp10_encode_frame(VP10_COMP *cpi) { count32x32 == 0) { cm->tx_mode = ONLY_4X4; reset_skip_tx_size(cm, TX_4X4); - } else if (count8x8_lp == 0 && count16x16_lp == 0 && - count4x4 == 0) { + } else if (count8x8_lp == 0 && count16x16_lp == 0 && count4x4 == 0) { cm->tx_mode = ALLOW_32X32; } else if (count32x32 == 0 && count8x8_lp == 0 && #if CONFIG_SUPERTX @@ -4931,8 +4755,7 @@ static void sum_intra_stats(FRAME_COUNTS *counts, const MODE_INFO *mi, } #if CONFIG_VAR_TX -static void update_txfm_count(MACROBLOCKD *xd, - FRAME_COUNTS *counts, +static void update_txfm_count(MACROBLOCKD *xd, FRAME_COUNTS *counts, TX_SIZE tx_size, int blk_row, int blk_col) { MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; const int tx_row = blk_row >> 1; @@ -4940,17 +4763,13 @@ static void update_txfm_count(MACROBLOCKD *xd, int max_blocks_high = num_4x4_blocks_high_lookup[mbmi->sb_type]; int max_blocks_wide = num_4x4_blocks_wide_lookup[mbmi->sb_type]; int ctx = txfm_partition_context(xd->above_txfm_context + tx_col, - xd->left_txfm_context + tx_row, - tx_size); + xd->left_txfm_context + tx_row, tx_size); const TX_SIZE plane_tx_size = mbmi->inter_tx_size[tx_row][tx_col]; - if (xd->mb_to_bottom_edge < 0) - max_blocks_high += xd->mb_to_bottom_edge >> 5; - if (xd->mb_to_right_edge < 0) - max_blocks_wide += xd->mb_to_right_edge >> 5; + if (xd->mb_to_bottom_edge < 0) max_blocks_high += xd->mb_to_bottom_edge >> 5; + if (xd->mb_to_right_edge < 0) max_blocks_wide += xd->mb_to_right_edge >> 5; - if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) - return; + if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (tx_size == plane_tx_size) { ++counts->txfm_partition[ctx][0]; @@ -4974,17 +4793,15 @@ static void update_txfm_count(MACROBLOCKD *xd, for (i = 0; i < 4; ++i) { int offsetr = (i >> 1) * bh / 2; int offsetc = (i & 0x01) * bh / 2; - update_txfm_count(xd, counts, tx_size - 1, - blk_row + offsetr, blk_col + offsetc); + update_txfm_count(xd, counts, tx_size - 1, blk_row + offsetr, + blk_col + offsetc); } } } -static void tx_partition_count_update(VP10_COMMON *cm, - MACROBLOCKD *xd, - BLOCK_SIZE plane_bsize, - int mi_row, int mi_col, - FRAME_COUNTS *td_counts) { +static void tx_partition_count_update(VP10_COMMON *cm, MACROBLOCKD *xd, + BLOCK_SIZE plane_bsize, int mi_row, + int mi_col, FRAME_COUNTS *td_counts) { const int mi_width = num_4x4_blocks_wide_lookup[plane_bsize]; const int mi_height = num_4x4_blocks_high_lookup[plane_bsize]; TX_SIZE max_tx_size = max_txsize_lookup[plane_bsize]; @@ -4994,15 +4811,15 @@ static void tx_partition_count_update(VP10_COMMON *cm, xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); for (idy = 0; idy < mi_height; idy += bh) for (idx = 0; idx < mi_width; idx += bh) update_txfm_count(xd, td_counts, max_tx_size, idy, idx); } -static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, - int blk_row, int blk_col) { +static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, int blk_row, + int blk_col) { MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; const int tx_row = blk_row >> 1; const int tx_col = blk_col >> 1; @@ -5010,13 +4827,10 @@ static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, int max_blocks_wide = num_4x4_blocks_wide_lookup[mbmi->sb_type]; const TX_SIZE plane_tx_size = mbmi->inter_tx_size[tx_row][tx_col]; - if (xd->mb_to_bottom_edge < 0) - max_blocks_high += xd->mb_to_bottom_edge >> 5; - if (xd->mb_to_right_edge < 0) - max_blocks_wide += xd->mb_to_right_edge >> 5; + if (xd->mb_to_bottom_edge < 0) max_blocks_high += xd->mb_to_bottom_edge >> 5; + if (xd->mb_to_right_edge < 0) max_blocks_wide += xd->mb_to_right_edge >> 5; - if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) - return; + if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (tx_size == plane_tx_size) { mbmi->tx_size = tx_size; @@ -5041,16 +4855,14 @@ static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, for (i = 0; i < 4; ++i) { int offsetr = (i >> 1) << bsl; int offsetc = (i & 0x01) << bsl; - set_txfm_context(xd, tx_size - 1, - blk_row + offsetr, blk_col + offsetc); + set_txfm_context(xd, tx_size - 1, blk_row + offsetr, blk_col + offsetc); } } } -static void tx_partition_set_contexts(VP10_COMMON *cm, - MACROBLOCKD *xd, - BLOCK_SIZE plane_bsize, - int mi_row, int mi_col) { +static void tx_partition_set_contexts(VP10_COMMON *cm, MACROBLOCKD *xd, + BLOCK_SIZE plane_bsize, int mi_row, + int mi_col) { const int mi_width = num_4x4_blocks_wide_lookup[plane_bsize]; const int mi_height = num_4x4_blocks_high_lookup[plane_bsize]; TX_SIZE max_tx_size = max_txsize_lookup[plane_bsize]; @@ -5060,7 +4872,7 @@ static void tx_partition_set_contexts(VP10_COMMON *cm, xd->above_txfm_context = cm->above_txfm_context + mi_col; xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); for (idy = 0; idy < mi_height; idy += bh) for (idx = 0; idx < mi_width; idx += bh) @@ -5068,18 +4880,17 @@ static void tx_partition_set_contexts(VP10_COMMON *cm, } #endif -static void encode_superblock(VP10_COMP *cpi, ThreadData *td, - TOKENEXTRA **t, int output_enabled, - int mi_row, int mi_col, BLOCK_SIZE bsize, - PICK_MODE_CONTEXT *ctx) { +static void encode_superblock(VP10_COMP *cpi, ThreadData *td, TOKENEXTRA **t, + int output_enabled, int mi_row, int mi_col, + BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx) { VP10_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; MODE_INFO **mi_8x8 = xd->mi; MODE_INFO *mi = mi_8x8[0]; MB_MODE_INFO *mbmi = &mi->mbmi; - const int seg_skip = segfeature_active(&cm->seg, mbmi->segment_id, - SEG_LVL_SKIP); + const int seg_skip = + segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP); const int mis = cm->mi_stride; const int mi_width = num_8x8_blocks_wide_lookup[bsize]; const int mi_height = num_8x8_blocks_high_lookup[bsize]; @@ -5100,8 +4911,7 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td, #if CONFIG_EXT_INTRA if (output_enabled && bsize >= BLOCK_8X8) { FRAME_COUNTS *counts = td->counts; - if (mbmi->mode == DC_PRED && - mbmi->palette_mode_info.palette_size[0] == 0) + if (mbmi->mode == DC_PRED && mbmi->palette_mode_info.palette_size[0] == 0) ++counts->ext_intra[0][mbmi->ext_intra_mode_info.use_ext_intra_mode[0]]; if (mbmi->uv_mode == DC_PRED && mbmi->palette_mode_info.palette_size[1] == 0) @@ -5109,8 +4919,8 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td, if (mbmi->mode != DC_PRED && mbmi->mode != TM_PRED) { int p_angle; const int intra_filter_ctx = vp10_get_pred_context_intra_interp(xd); - p_angle = mode_to_angle_map[mbmi->mode] + - mbmi->angle_delta[0] * ANGLE_STEP; + p_angle = + mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP; if (vp10_is_intra_filter_switchable(p_angle)) ++counts->intra_filter[intra_filter_ctx][mbmi->intra_filter]; } @@ -5135,11 +4945,10 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td, set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]); for (ref = 0; ref < 1 + is_compound; ++ref) { - YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, - mbmi->ref_frame[ref]); + YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, mbmi->ref_frame[ref]); assert(cfg != NULL); vp10_setup_pre_planes(xd, ref, cfg, mi_row, mi_col, - &xd->block_refs[ref]->sf); + &xd->block_refs[ref]->sf); } if (!(cpi->sf.reuse_inter_pred_sby && ctx->pred_pixel_ready) || seg_skip) vp10_build_inter_predictors_sby(xd, mi_row, mi_col, @@ -5158,12 +4967,12 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td, DECLARE_ALIGNED(16, uint8_t, tmp_buf2[MAX_MB_PLANE * MAX_SB_SQUARE]); #endif // CONFIG_VP9_HIGHBITDEPTH uint8_t *dst_buf1[MAX_MB_PLANE], *dst_buf2[MAX_MB_PLANE]; - int dst_stride1[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; - int dst_stride2[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; - int dst_width1[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; - int dst_width2[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; - int dst_height1[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; - int dst_height2[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; + int dst_stride1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; + int dst_stride2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; + int dst_width1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; + int dst_width2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; + int dst_height1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; + int dst_height2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; assert(mbmi->sb_type >= BLOCK_8X8); @@ -5178,12 +4987,12 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td, dst_buf2[2] = CONVERT_TO_BYTEPTR(tmp_buf2 + MAX_SB_SQUARE * 2 * len); } else { #endif // CONFIG_VP9_HIGHBITDEPTH - dst_buf1[0] = tmp_buf1; - dst_buf1[1] = tmp_buf1 + MAX_SB_SQUARE; - dst_buf1[2] = tmp_buf1 + MAX_SB_SQUARE * 2; - dst_buf2[0] = tmp_buf2; - dst_buf2[1] = tmp_buf2 + MAX_SB_SQUARE; - dst_buf2[2] = tmp_buf2 + MAX_SB_SQUARE * 2; + dst_buf1[0] = tmp_buf1; + dst_buf1[1] = tmp_buf1 + MAX_SB_SQUARE; + dst_buf1[2] = tmp_buf1 + MAX_SB_SQUARE * 2; + dst_buf2[0] = tmp_buf2; + dst_buf2[1] = tmp_buf2 + MAX_SB_SQUARE; + dst_buf2[2] = tmp_buf2 + MAX_SB_SQUARE * 2; #if CONFIG_VP9_HIGHBITDEPTH } #endif // CONFIG_VP9_HIGHBITDEPTH @@ -5192,33 +5001,31 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td, dst_stride1); vp10_build_prediction_by_left_preds(cm, xd, mi_row, mi_col, dst_buf2, dst_width2, dst_height2, dst_stride2); - vp10_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), - mi_row, mi_col); - vp10_build_obmc_inter_prediction(cm, xd, mi_row, mi_col, - dst_buf1, dst_stride1, - dst_buf2, dst_stride2); + vp10_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, + mi_col); + vp10_build_obmc_inter_prediction(cm, xd, mi_row, mi_col, dst_buf1, + dst_stride1, dst_buf2, dst_stride2); } #endif // CONFIG_OBMC vp10_encode_sb(x, VPXMAX(bsize, BLOCK_8X8)); #if CONFIG_VAR_TX - vp10_tokenize_sb_inter(cpi, td, t, !output_enabled, - mi_row, mi_col, VPXMAX(bsize, BLOCK_8X8)); + vp10_tokenize_sb_inter(cpi, td, t, !output_enabled, mi_row, mi_col, + VPXMAX(bsize, BLOCK_8X8)); #else vp10_tokenize_sb(cpi, td, t, !output_enabled, VPXMAX(bsize, BLOCK_8X8)); #endif } if (output_enabled) { - if (cm->tx_mode == TX_MODE_SELECT && - mbmi->sb_type >= BLOCK_8X8 && + if (cm->tx_mode == TX_MODE_SELECT && mbmi->sb_type >= BLOCK_8X8 && !(is_inter_block(mbmi) && (mbmi->skip || seg_skip))) { #if CONFIG_VAR_TX if (is_inter_block(mbmi)) tx_partition_count_update(cm, xd, bsize, mi_row, mi_col, td->counts); #endif - ++td->counts->tx_size[max_txsize_lookup[bsize] - TX_8X8] - [get_tx_size_context(xd)][mbmi->tx_size]; + ++td->counts->tx_size[max_txsize_lookup[bsize] - + TX_8X8][get_tx_size_context(xd)][mbmi->tx_size]; } else { int x, y; TX_SIZE tx_size; @@ -5240,27 +5047,25 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td, if (get_ext_tx_types(mbmi->tx_size, bsize, is_inter_block(mbmi)) > 1 && cm->base_qindex > 0 && !mbmi->skip && !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { - int eset = get_ext_tx_set(mbmi->tx_size, bsize, - is_inter_block(mbmi)); + int eset = get_ext_tx_set(mbmi->tx_size, bsize, is_inter_block(mbmi)); if (eset > 0) { if (is_inter_block(mbmi)) { ++td->counts->inter_ext_tx[eset][mbmi->tx_size][mbmi->tx_type]; } else { - ++td->counts->intra_ext_tx[eset][mbmi->tx_size][mbmi->mode] - [mbmi->tx_type]; + ++td->counts + ->intra_ext_tx[eset][mbmi->tx_size][mbmi->mode][mbmi->tx_type]; } } } #else - if (mbmi->tx_size < TX_32X32 && - cm->base_qindex > 0 && !mbmi->skip && + if (mbmi->tx_size < TX_32X32 && cm->base_qindex > 0 && !mbmi->skip && !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { if (is_inter_block(mbmi)) { ++td->counts->inter_ext_tx[mbmi->tx_size][mbmi->tx_type]; } else { - ++td->counts->intra_ext_tx[mbmi->tx_size] - [intra_mode_to_tx_type_context[mbmi->mode]] - [mbmi->tx_type]; + ++td->counts + ->intra_ext_tx[mbmi->tx_size][intra_mode_to_tx_type_context + [mbmi->mode]][mbmi->tx_type]; } } #endif // CONFIG_EXT_TX @@ -5288,11 +5093,9 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td, #if CONFIG_SUPERTX static int check_intra_b(PICK_MODE_CONTEXT *ctx) { - if (!is_inter_mode((&ctx->mic)->mbmi.mode)) - return 1; + if (!is_inter_mode((&ctx->mic)->mbmi.mode)) return 1; #if CONFIG_EXT_INTER - if (ctx->mic.mbmi.ref_frame[1] == INTRA_FRAME) - return 1; + if (ctx->mic.mbmi.ref_frame[1] == INTRA_FRAME) return 1; #endif // CONFIG_EXT_INTER return 0; } @@ -5311,33 +5114,25 @@ static int check_intra_sb(VP10_COMP *cpi, const TileInfo *const tile, assert(bsize >= BLOCK_8X8); - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return 1; + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return 1; switch (partition) { - case PARTITION_NONE: - return check_intra_b(&pc_tree->none); - break; + case PARTITION_NONE: return check_intra_b(&pc_tree->none); break; case PARTITION_VERT: - if (check_intra_b(&pc_tree->vertical[0])) - return 1; + if (check_intra_b(&pc_tree->vertical[0])) return 1; if (mi_col + hbs < cm->mi_cols && bsize > BLOCK_8X8) { - if (check_intra_b(&pc_tree->vertical[1])) - return 1; + if (check_intra_b(&pc_tree->vertical[1])) return 1; } break; case PARTITION_HORZ: - if (check_intra_b(&pc_tree->horizontal[0])) - return 1; + if (check_intra_b(&pc_tree->horizontal[0])) return 1; if (mi_row + hbs < cm->mi_rows && bsize > BLOCK_8X8) { - if (check_intra_b(&pc_tree->horizontal[1])) - return 1; + if (check_intra_b(&pc_tree->horizontal[1])) return 1; } break; case PARTITION_SPLIT: if (bsize == BLOCK_8X8) { - if (check_intra_b(pc_tree->leaf_split[0])) - return 1; + if (check_intra_b(pc_tree->leaf_split[0])) return 1; } else { if (check_intra_sb(cpi, tile, mi_row, mi_col, subsize, pc_tree->split[0])) @@ -5356,31 +5151,26 @@ static int check_intra_sb(VP10_COMP *cpi, const TileInfo *const tile, #if CONFIG_EXT_PARTITION_TYPES case PARTITION_HORZ_A: for (i = 0; i < 3; i++) { - if (check_intra_b(&pc_tree->horizontala[i])) - return 1; + if (check_intra_b(&pc_tree->horizontala[i])) return 1; } break; case PARTITION_HORZ_B: for (i = 0; i < 3; i++) { - if (check_intra_b(&pc_tree->horizontalb[i])) - return 1; + if (check_intra_b(&pc_tree->horizontalb[i])) return 1; } break; case PARTITION_VERT_A: for (i = 0; i < 3; i++) { - if (check_intra_b(&pc_tree->verticala[i])) - return 1; + if (check_intra_b(&pc_tree->verticala[i])) return 1; } break; case PARTITION_VERT_B: for (i = 0; i < 3; i++) { - if (check_intra_b(&pc_tree->verticalb[i])) - return 1; + if (check_intra_b(&pc_tree->verticalb[i])) return 1; } break; #endif // CONFIG_EXT_PARTITION_TYPES - default: - assert(0); + default: assert(0); } return 0; } @@ -5397,8 +5187,7 @@ static int check_supertx_sb(BLOCK_SIZE bsize, TX_SIZE supertx_size, partition = pc_tree->partitioning; subsize = get_subsize(bsize, partition); switch (partition) { - case PARTITION_NONE: - return check_supertx_b(supertx_size, &pc_tree->none); + case PARTITION_NONE: return check_supertx_b(supertx_size, &pc_tree->none); case PARTITION_VERT: return check_supertx_b(supertx_size, &pc_tree->vertical[0]); case PARTITION_HORZ: @@ -5418,9 +5207,7 @@ static int check_supertx_sb(BLOCK_SIZE bsize, TX_SIZE supertx_size, case PARTITION_VERT_B: return check_supertx_b(supertx_size, &pc_tree->verticalb[0]); #endif // CONFIG_EXT_PARTITION_TYPES - default: - assert(0); - return 0; + default: assert(0); return 0; } } @@ -5445,35 +5232,31 @@ static void predict_superblock(VP10_COMP *cpi, ThreadData *td, set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]); for (ref = 0; ref < 1 + is_compound; ++ref) { - YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, - mbmi->ref_frame[ref]); + YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, mbmi->ref_frame[ref]); vp10_setup_pre_planes(xd, ref, cfg, mi_row_pred, mi_col_pred, - &xd->block_refs[ref]->sf); + &xd->block_refs[ref]->sf); } if (!b_sub8x8) - vp10_build_inter_predictors_sb_extend( - xd, + vp10_build_inter_predictors_sb_extend(xd, #if CONFIG_EXT_INTER - mi_row_ori, mi_col_ori, + mi_row_ori, mi_col_ori, #endif // CONFIG_EXT_INTER - mi_row_pred, mi_col_pred, bsize_pred); + mi_row_pred, mi_col_pred, bsize_pred); else - vp10_build_inter_predictors_sb_sub8x8_extend( - xd, + vp10_build_inter_predictors_sb_sub8x8_extend(xd, #if CONFIG_EXT_INTER - mi_row_ori, mi_col_ori, + mi_row_ori, mi_col_ori, #endif // CONFIG_EXT_INTER - mi_row_pred, mi_col_pred, bsize_pred, block); + mi_row_pred, mi_col_pred, + bsize_pred, block); } static void predict_b_extend(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - int block, - int mi_row_ori, int mi_col_ori, - int mi_row_pred, int mi_col_pred, - int mi_row_top, int mi_col_top, - uint8_t * dst_buf[3], int dst_stride[3], + const TileInfo *const tile, int block, + int mi_row_ori, int mi_col_ori, int mi_row_pred, + int mi_col_pred, int mi_row_top, int mi_col_top, + uint8_t *dst_buf[3], int dst_stride[3], BLOCK_SIZE bsize_top, BLOCK_SIZE bsize_pred, int output_enabled, int b_sub8x8, int bextend) { // Used in supertx @@ -5494,12 +5277,12 @@ static void predict_b_extend(VP10_COMP *cpi, ThreadData *td, if (mi_row_pred < mi_row_top || mi_col_pred < mi_col_top || mi_row_pred >= mi_row_top + mi_height_top || - mi_col_pred >= mi_col_top + mi_width_top || - mi_row_pred >= cm->mi_rows || mi_col_pred >= cm->mi_cols) + mi_col_pred >= mi_col_top + mi_width_top || mi_row_pred >= cm->mi_rows || + mi_col_pred >= cm->mi_cols) return; - set_offsets_extend(cpi, td, tile, mi_row_pred, mi_col_pred, - mi_row_ori, mi_col_ori, bsize_pred); + set_offsets_extend(cpi, td, tile, mi_row_pred, mi_col_pred, mi_row_ori, + mi_col_ori, bsize_pred); xd->plane[0].dst.stride = dst_stride[0]; xd->plane[1].dst.stride = dst_stride[1]; xd->plane[2].dst.stride = dst_stride[2]; @@ -5517,20 +5300,16 @@ static void predict_b_extend(VP10_COMP *cpi, ThreadData *td, #if CONFIG_EXT_INTER mi_row_ori, mi_col_ori, #endif // CONFIG_EXT_INTER - mi_row_pred, mi_col_pred, bsize_pred, - b_sub8x8, block); + mi_row_pred, mi_col_pred, bsize_pred, b_sub8x8, block); - if (output_enabled && !bextend) - update_stats(&cpi->common, td, 1); + if (output_enabled && !bextend) update_stats(&cpi->common, td, 1); } static void extend_dir(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - int block, BLOCK_SIZE bsize, BLOCK_SIZE top_bsize, - int mi_row, int mi_col, - int mi_row_top, int mi_col_top, - int output_enabled, - uint8_t * dst_buf[3], int dst_stride[3], int dir) { + const TileInfo *const tile, int block, BLOCK_SIZE bsize, + BLOCK_SIZE top_bsize, int mi_row, int mi_col, + int mi_row_top, int mi_col_top, int output_enabled, + uint8_t *dst_buf[3], int dst_stride[3], int dir) { // dir: 0-lower, 1-upper, 2-left, 3-right // 4-lowerleft, 5-upperleft, 6-lowerright, 7-upperright MACROBLOCKD *xd = &td->mb.e_mbd; @@ -5544,48 +5323,47 @@ static void extend_dir(VP10_COMP *cpi, ThreadData *td, int unit, mi_row_pred, mi_col_pred; if (dir == 0 || dir == 1) { // lower and upper - extend_bsize = (mi_width == 1 || bsize < BLOCK_8X8 || xss < yss) ? - BLOCK_8X8 : BLOCK_16X8; + extend_bsize = (mi_width == 1 || bsize < BLOCK_8X8 || xss < yss) + ? BLOCK_8X8 + : BLOCK_16X8; unit = num_8x8_blocks_wide_lookup[extend_bsize]; mi_row_pred = mi_row + ((dir == 0) ? mi_height : -1); mi_col_pred = mi_col; - predict_b_extend(cpi, td, tile, block, mi_row, mi_col, - mi_row_pred, mi_col_pred, - mi_row_top, mi_col_top, dst_buf, dst_stride, - top_bsize, extend_bsize, - output_enabled, b_sub8x8, 1); + predict_b_extend(cpi, td, tile, block, mi_row, mi_col, mi_row_pred, + mi_col_pred, mi_row_top, mi_col_top, dst_buf, dst_stride, + top_bsize, extend_bsize, output_enabled, b_sub8x8, 1); if (mi_width > unit) { int i; - for (i = 0; i < mi_width/unit - 1; i++) { + for (i = 0; i < mi_width / unit - 1; i++) { mi_col_pred += unit; - predict_b_extend(cpi, td, tile, block, mi_row, mi_col, - mi_row_pred, mi_col_pred, mi_row_top, mi_col_top, - dst_buf, dst_stride, top_bsize, extend_bsize, - output_enabled, b_sub8x8, 1); + predict_b_extend(cpi, td, tile, block, mi_row, mi_col, mi_row_pred, + mi_col_pred, mi_row_top, mi_col_top, dst_buf, + dst_stride, top_bsize, extend_bsize, output_enabled, + b_sub8x8, 1); } } } else if (dir == 2 || dir == 3) { // left and right - extend_bsize = (mi_height == 1 || bsize < BLOCK_8X8 || yss < xss) ? - BLOCK_8X8 : BLOCK_8X16; + extend_bsize = (mi_height == 1 || bsize < BLOCK_8X8 || yss < xss) + ? BLOCK_8X8 + : BLOCK_8X16; unit = num_8x8_blocks_high_lookup[extend_bsize]; mi_row_pred = mi_row; mi_col_pred = mi_col + ((dir == 3) ? mi_width : -1); - predict_b_extend(cpi, td, tile, block, mi_row, mi_col, - mi_row_pred, mi_col_pred, mi_row_top, mi_col_top, - dst_buf, dst_stride, top_bsize, extend_bsize, - output_enabled, b_sub8x8, 1); + predict_b_extend(cpi, td, tile, block, mi_row, mi_col, mi_row_pred, + mi_col_pred, mi_row_top, mi_col_top, dst_buf, dst_stride, + top_bsize, extend_bsize, output_enabled, b_sub8x8, 1); if (mi_height > unit) { int i; - for (i = 0; i < mi_height/unit - 1; i++) { + for (i = 0; i < mi_height / unit - 1; i++) { mi_row_pred += unit; - predict_b_extend(cpi, td, tile, block, mi_row, mi_col, - mi_row_pred, mi_col_pred, mi_row_top, mi_col_top, - dst_buf, dst_stride, top_bsize, extend_bsize, - output_enabled, b_sub8x8, 1); + predict_b_extend(cpi, td, tile, block, mi_row, mi_col, mi_row_pred, + mi_col_pred, mi_row_top, mi_col_top, dst_buf, + dst_stride, top_bsize, extend_bsize, output_enabled, + b_sub8x8, 1); } } } else { @@ -5593,41 +5371,36 @@ static void extend_dir(VP10_COMP *cpi, ThreadData *td, mi_row_pred = mi_row + ((dir == 4 || dir == 6) ? mi_height : -1); mi_col_pred = mi_col + ((dir == 6 || dir == 7) ? mi_width : -1); - predict_b_extend(cpi, td, tile, block, mi_row, mi_col, - mi_row_pred, mi_col_pred, mi_row_top, mi_col_top, - dst_buf, dst_stride, top_bsize, extend_bsize, - output_enabled, b_sub8x8, 1); + predict_b_extend(cpi, td, tile, block, mi_row, mi_col, mi_row_pred, + mi_col_pred, mi_row_top, mi_col_top, dst_buf, dst_stride, + top_bsize, extend_bsize, output_enabled, b_sub8x8, 1); } } static void extend_all(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - int block, - BLOCK_SIZE bsize, BLOCK_SIZE top_bsize, - int mi_row, int mi_col, - int mi_row_top, int mi_col_top, - int output_enabled, - uint8_t * dst_buf[3], int dst_stride[3]) { + const TileInfo *const tile, int block, BLOCK_SIZE bsize, + BLOCK_SIZE top_bsize, int mi_row, int mi_col, + int mi_row_top, int mi_col_top, int output_enabled, + uint8_t *dst_buf[3], int dst_stride[3]) { assert(block >= 0 && block < 4); - extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride, 0); - extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride, 1); - extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride, 2); - extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride, 3); - extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride, 4); - extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride, 5); - extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride, 6); - extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride, 7); + extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top, + mi_col_top, output_enabled, dst_buf, dst_stride, 0); + extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top, + mi_col_top, output_enabled, dst_buf, dst_stride, 1); + extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top, + mi_col_top, output_enabled, dst_buf, dst_stride, 2); + extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top, + mi_col_top, output_enabled, dst_buf, dst_stride, 3); + extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top, + mi_col_top, output_enabled, dst_buf, dst_stride, 4); + extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top, + mi_col_top, output_enabled, dst_buf, dst_stride, 5); + extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top, + mi_col_top, output_enabled, dst_buf, dst_stride, 6); + extend_dir(cpi, td, tile, block, bsize, top_bsize, mi_row, mi_col, mi_row_top, + mi_col_top, output_enabled, dst_buf, dst_stride, 7); } - // This function generates prediction for multiple blocks, between which // discontinuity around boundary is reduced by smoothing masks. The basic // smoothing mask is a soft step function along horz/vert direction. In more @@ -5637,18 +5410,16 @@ static void extend_all(VP10_COMP *cpi, ThreadData *td, // If the block is split into more than one level, at every stage, masked // prediction is stored in dst_buf[] passed from higher level. static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - int mi_row, int mi_col, - int mi_row_top, int mi_col_top, + const TileInfo *const tile, int mi_row, + int mi_col, int mi_row_top, int mi_col_top, int output_enabled, BLOCK_SIZE bsize, - BLOCK_SIZE top_bsize, - uint8_t *dst_buf[3], int dst_stride[3], - PC_TREE *pc_tree) { + BLOCK_SIZE top_bsize, uint8_t *dst_buf[3], + int dst_stride[3], PC_TREE *pc_tree) { VP10_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; - const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize); + const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize); const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2; const PARTITION_TYPE partition = pc_tree->partitioning; const BLOCK_SIZE subsize = get_subsize(bsize, partition); @@ -5661,14 +5432,13 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, DECLARE_ALIGNED(16, uint8_t, tmp_buf1[MAX_MB_PLANE * MAX_TX_SQUARE * 2]); DECLARE_ALIGNED(16, uint8_t, tmp_buf2[MAX_MB_PLANE * MAX_TX_SQUARE * 2]); DECLARE_ALIGNED(16, uint8_t, tmp_buf3[MAX_MB_PLANE * MAX_TX_SQUARE * 2]); - int dst_stride1[3] = {MAX_TX_SIZE, MAX_TX_SIZE, MAX_TX_SIZE}; - int dst_stride2[3] = {MAX_TX_SIZE, MAX_TX_SIZE, MAX_TX_SIZE}; - int dst_stride3[3] = {MAX_TX_SIZE, MAX_TX_SIZE, MAX_TX_SIZE}; + int dst_stride1[3] = { MAX_TX_SIZE, MAX_TX_SIZE, MAX_TX_SIZE }; + int dst_stride2[3] = { MAX_TX_SIZE, MAX_TX_SIZE, MAX_TX_SIZE }; + int dst_stride3[3] = { MAX_TX_SIZE, MAX_TX_SIZE, MAX_TX_SIZE }; assert(bsize >= BLOCK_8X8); - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return; + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { @@ -5709,21 +5479,21 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, case PARTITION_NONE: assert(bsize < top_bsize); predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col, - mi_row_top, mi_col_top, dst_buf, dst_stride, - top_bsize, bsize, output_enabled, 0, 0); - extend_all(cpi, td, tile, 0, bsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride); + mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize, + bsize, output_enabled, 0, 0); + extend_all(cpi, td, tile, 0, bsize, top_bsize, mi_row, mi_col, mi_row_top, + mi_col_top, output_enabled, dst_buf, dst_stride); break; case PARTITION_HORZ: if (bsize == BLOCK_8X8) { // Fisrt half predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col, - mi_row_top, mi_col_top, dst_buf, dst_stride, - top_bsize, BLOCK_8X8, output_enabled, 1, 0); + mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize, + BLOCK_8X8, output_enabled, 1, 0); if (bsize < top_bsize) extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf, dst_stride); + mi_row_top, mi_col_top, output_enabled, dst_buf, + dst_stride); // Second half predict_b_extend(cpi, td, tile, 2, mi_row, mi_col, mi_row, mi_col, @@ -5731,47 +5501,44 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, top_bsize, BLOCK_8X8, output_enabled, 1, 1); if (bsize < top_bsize) extend_all(cpi, td, tile, 2, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf1, dst_stride1); + mi_row_top, mi_col_top, output_enabled, dst_buf1, + dst_stride1); // Smooth xd->plane[0].dst.buf = dst_buf[0]; xd->plane[0].dst.stride = dst_stride[0]; - vp10_build_masked_inter_predictor_complex(xd, - dst_buf[0], dst_stride[0], - dst_buf1[0], dst_stride1[0], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_HORZ, 0); - } else { + vp10_build_masked_inter_predictor_complex( + xd, dst_buf[0], dst_stride[0], dst_buf1[0], dst_stride1[0], mi_row, + mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_HORZ, + 0); + } else { // First half predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col, - mi_row_top, mi_col_top, dst_buf, dst_stride, - top_bsize, subsize, output_enabled, 0, 0); + mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize, + subsize, output_enabled, 0, 0); if (bsize < top_bsize) extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf, dst_stride); + mi_row_top, mi_col_top, output_enabled, dst_buf, + dst_stride); else extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf, dst_stride, 0); + mi_row_top, mi_col_top, output_enabled, dst_buf, + dst_stride, 0); if (mi_row + hbs < cm->mi_rows) { // Second half - predict_b_extend(cpi, td, tile, 0, mi_row + hbs, mi_col, - mi_row + hbs, mi_col, mi_row_top, mi_col_top, - dst_buf1, dst_stride1, top_bsize, subsize, - output_enabled, 0, 0); + predict_b_extend(cpi, td, tile, 0, mi_row + hbs, mi_col, mi_row + hbs, + mi_col, mi_row_top, mi_col_top, dst_buf1, + dst_stride1, top_bsize, subsize, output_enabled, 0, + 0); if (bsize < top_bsize) extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row + hbs, - mi_col, mi_row_top, mi_col_top, output_enabled, - dst_buf1, dst_stride1); + mi_col, mi_row_top, mi_col_top, output_enabled, dst_buf1, + dst_stride1); else extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row + hbs, - mi_col, mi_row_top, mi_col_top, output_enabled, - dst_buf1, dst_stride1, 1); + mi_col, mi_row_top, mi_col_top, output_enabled, dst_buf1, + dst_stride1, 1); // Smooth for (i = 0; i < MAX_MB_PLANE; i++) { @@ -5779,8 +5546,8 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, xd->plane[i].dst.stride = dst_stride[i]; vp10_build_masked_inter_predictor_complex( xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i], - mi_row, mi_col, mi_row_top, mi_col_top, - bsize, top_bsize, PARTITION_HORZ, i); + mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize, + PARTITION_HORZ, i); } } } @@ -5789,12 +5556,12 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, if (bsize == BLOCK_8X8) { // First half predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col, - mi_row_top, mi_col_top, dst_buf, dst_stride, - top_bsize, BLOCK_8X8, output_enabled, 1, 0); + mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize, + BLOCK_8X8, output_enabled, 1, 0); if (bsize < top_bsize) extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf, dst_stride); + mi_row_top, mi_col_top, output_enabled, dst_buf, + dst_stride); // Second half predict_b_extend(cpi, td, tile, 1, mi_row, mi_col, mi_row, mi_col, @@ -5802,39 +5569,35 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, top_bsize, BLOCK_8X8, output_enabled, 1, 1); if (bsize < top_bsize) extend_all(cpi, td, tile, 1, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf1, dst_stride1); + mi_row_top, mi_col_top, output_enabled, dst_buf1, + dst_stride1); // Smooth xd->plane[0].dst.buf = dst_buf[0]; xd->plane[0].dst.stride = dst_stride[0]; - vp10_build_masked_inter_predictor_complex(xd, - dst_buf[0], dst_stride[0], - dst_buf1[0], dst_stride1[0], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_VERT, 0); + vp10_build_masked_inter_predictor_complex( + xd, dst_buf[0], dst_stride[0], dst_buf1[0], dst_stride1[0], mi_row, + mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_VERT, + 0); } else { // bsize: not important, not useful predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col, - mi_row_top, mi_col_top, dst_buf, dst_stride, - top_bsize, subsize, output_enabled, 0, 0); + mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize, + subsize, output_enabled, 0, 0); if (bsize < top_bsize) extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf, dst_stride); + mi_row_top, mi_col_top, output_enabled, dst_buf, + dst_stride); else extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf, dst_stride, 3); - + mi_row_top, mi_col_top, output_enabled, dst_buf, + dst_stride, 3); if (mi_col + hbs < cm->mi_cols) { - predict_b_extend(cpi, td, tile, 0, mi_row, mi_col + hbs, - mi_row, mi_col + hbs, mi_row_top, mi_col_top, - dst_buf1, dst_stride1, top_bsize, subsize, - output_enabled, 0, 0); + predict_b_extend(cpi, td, tile, 0, mi_row, mi_col + hbs, mi_row, + mi_col + hbs, mi_row_top, mi_col_top, dst_buf1, + dst_stride1, top_bsize, subsize, output_enabled, 0, + 0); if (bsize < top_bsize) extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col + hbs, mi_row_top, mi_col_top, output_enabled, @@ -5849,8 +5612,8 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, xd->plane[i].dst.stride = dst_stride[i]; vp10_build_masked_inter_predictor_complex( xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i], - mi_row, mi_col, mi_row_top, mi_col_top, - bsize, top_bsize, PARTITION_VERT, i); + mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize, + PARTITION_VERT, i); } } } @@ -5858,8 +5621,8 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, case PARTITION_SPLIT: if (bsize == BLOCK_8X8) { predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col, - mi_row_top, mi_col_top, dst_buf, dst_stride, - top_bsize, BLOCK_8X8, output_enabled, 1, 0); + mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize, + BLOCK_8X8, output_enabled, 1, 0); predict_b_extend(cpi, td, tile, 1, mi_row, mi_col, mi_row, mi_col, mi_row_top, mi_col_top, dst_buf1, dst_stride1, top_bsize, BLOCK_8X8, output_enabled, 1, 1); @@ -5872,97 +5635,73 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, if (bsize < top_bsize) { extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf, dst_stride); + mi_row_top, mi_col_top, output_enabled, dst_buf, + dst_stride); extend_all(cpi, td, tile, 1, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf1, dst_stride1); + mi_row_top, mi_col_top, output_enabled, dst_buf1, + dst_stride1); extend_all(cpi, td, tile, 2, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf2, dst_stride2); + mi_row_top, mi_col_top, output_enabled, dst_buf2, + dst_stride2); extend_all(cpi, td, tile, 3, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf3, dst_stride3); + mi_row_top, mi_col_top, output_enabled, dst_buf3, + dst_stride3); } } else { - predict_sb_complex(cpi, td, tile, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, subsize, - top_bsize, dst_buf, dst_stride, - pc_tree->split[0]); + predict_sb_complex(cpi, td, tile, mi_row, mi_col, mi_row_top, + mi_col_top, output_enabled, subsize, top_bsize, + dst_buf, dst_stride, pc_tree->split[0]); if (mi_row < cm->mi_rows && mi_col + hbs < cm->mi_cols) - predict_sb_complex(cpi, td, tile, mi_row, mi_col + hbs, - mi_row_top, mi_col_top, output_enabled, subsize, - top_bsize, dst_buf1, dst_stride1, - pc_tree->split[1]); + predict_sb_complex(cpi, td, tile, mi_row, mi_col + hbs, mi_row_top, + mi_col_top, output_enabled, subsize, top_bsize, + dst_buf1, dst_stride1, pc_tree->split[1]); if (mi_row + hbs < cm->mi_rows && mi_col < cm->mi_cols) - predict_sb_complex(cpi, td, tile, mi_row + hbs, mi_col, - mi_row_top, mi_col_top, output_enabled, subsize, - top_bsize, dst_buf2, dst_stride2, - pc_tree->split[2]); + predict_sb_complex(cpi, td, tile, mi_row + hbs, mi_col, mi_row_top, + mi_col_top, output_enabled, subsize, top_bsize, + dst_buf2, dst_stride2, pc_tree->split[2]); if (mi_row + hbs < cm->mi_rows && mi_col + hbs < cm->mi_cols) predict_sb_complex(cpi, td, tile, mi_row + hbs, mi_col + hbs, mi_row_top, mi_col_top, output_enabled, subsize, top_bsize, dst_buf3, dst_stride3, pc_tree->split[3]); } - for (i = 0; i < MAX_MB_PLANE; i++) { - if (bsize == BLOCK_8X8 && i != 0) - continue; // Skip <4x4 chroma smoothing - if (mi_row < cm->mi_rows && mi_col + hbs < cm->mi_cols) { - vp10_build_masked_inter_predictor_complex(xd, - dst_buf[i], - dst_stride[i], - dst_buf1[i], - dst_stride1[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_VERT, i); - if (mi_row + hbs < cm->mi_rows) { - vp10_build_masked_inter_predictor_complex(xd, - dst_buf2[i], - dst_stride2[i], - dst_buf3[i], - dst_stride3[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_VERT, i); - vp10_build_masked_inter_predictor_complex(xd, - dst_buf[i], - dst_stride[i], - dst_buf2[i], - dst_stride2[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_HORZ, i); - } - } else if (mi_row + hbs < cm->mi_rows && mi_col < cm->mi_cols) { - vp10_build_masked_inter_predictor_complex(xd, - dst_buf[i], - dst_stride[i], - dst_buf2[i], - dst_stride2[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_HORZ, i); + for (i = 0; i < MAX_MB_PLANE; i++) { + if (bsize == BLOCK_8X8 && i != 0) + continue; // Skip <4x4 chroma smoothing + if (mi_row < cm->mi_rows && mi_col + hbs < cm->mi_cols) { + vp10_build_masked_inter_predictor_complex( + xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i], + mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize, + PARTITION_VERT, i); + if (mi_row + hbs < cm->mi_rows) { + vp10_build_masked_inter_predictor_complex( + xd, dst_buf2[i], dst_stride2[i], dst_buf3[i], dst_stride3[i], + mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize, + PARTITION_VERT, i); + vp10_build_masked_inter_predictor_complex( + xd, dst_buf[i], dst_stride[i], dst_buf2[i], dst_stride2[i], + mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize, + PARTITION_HORZ, i); } + } else if (mi_row + hbs < cm->mi_rows && mi_col < cm->mi_cols) { + vp10_build_masked_inter_predictor_complex( + xd, dst_buf[i], dst_stride[i], dst_buf2[i], dst_stride2[i], + mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize, + PARTITION_HORZ, i); } - break; + } + break; #if CONFIG_EXT_PARTITION_TYPES case PARTITION_HORZ_A: predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col, - mi_row_top, mi_col_top, dst_buf, dst_stride, - top_bsize, bsize2, output_enabled, 0, 0); + mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize, + bsize2, output_enabled, 0, 0); extend_all(cpi, td, tile, 0, bsize2, top_bsize, mi_row, mi_col, mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride); - predict_b_extend(cpi, td, tile, 0, mi_row, mi_col + hbs, - mi_row, mi_col + hbs, mi_row_top, mi_col_top, - dst_buf1, dst_stride1, top_bsize, bsize2, - output_enabled, 0, 0); + predict_b_extend(cpi, td, tile, 0, mi_row, mi_col + hbs, mi_row, + mi_col + hbs, mi_row_top, mi_col_top, dst_buf1, + dst_stride1, top_bsize, bsize2, output_enabled, 0, 0); extend_all(cpi, td, tile, 0, bsize2, top_bsize, mi_row, mi_col + hbs, mi_row_top, mi_col_top, output_enabled, dst_buf1, dst_stride1); @@ -5971,40 +5710,34 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, top_bsize, subsize, output_enabled, 0, 0); if (bsize < top_bsize) extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row + hbs, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf2, dst_stride2); + mi_row_top, mi_col_top, output_enabled, dst_buf2, + dst_stride2); else extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row + hbs, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf2, dst_stride2, 1); + mi_row_top, mi_col_top, output_enabled, dst_buf2, + dst_stride2, 1); for (i = 0; i < MAX_MB_PLANE; i++) { xd->plane[i].dst.buf = dst_buf[i]; xd->plane[i].dst.stride = dst_stride[i]; - vp10_build_masked_inter_predictor_complex(xd, - dst_buf[i], dst_stride[i], - dst_buf1[i], dst_stride1[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_VERT, i); + vp10_build_masked_inter_predictor_complex( + xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i], mi_row, + mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_VERT, + i); } for (i = 0; i < MAX_MB_PLANE; i++) { - vp10_build_masked_inter_predictor_complex(xd, - dst_buf[i], dst_stride[i], - dst_buf2[i], dst_stride2[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_HORZ, i); + vp10_build_masked_inter_predictor_complex( + xd, dst_buf[i], dst_stride[i], dst_buf2[i], dst_stride2[i], mi_row, + mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_HORZ, + i); } break; case PARTITION_VERT_A: predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col, - mi_row_top, mi_col_top, dst_buf, dst_stride, - top_bsize, bsize2, output_enabled, 0, 0); + mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize, + bsize2, output_enabled, 0, 0); extend_all(cpi, td, tile, 0, bsize2, top_bsize, mi_row, mi_col, mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride); @@ -6016,50 +5749,43 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, predict_b_extend(cpi, td, tile, 0, mi_row, mi_col + hbs, mi_row, mi_col + hbs, mi_row_top, mi_col_top, dst_buf2, - dst_stride2, top_bsize, subsize, output_enabled, - 0, 0); + dst_stride2, top_bsize, subsize, output_enabled, 0, 0); if (bsize < top_bsize) extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col + hbs, - mi_row_top, mi_col_top, output_enabled, - dst_buf2, dst_stride2); + mi_row_top, mi_col_top, output_enabled, dst_buf2, + dst_stride2); else extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col + hbs, - mi_row_top, mi_col_top, output_enabled, - dst_buf2, dst_stride2, 2); + mi_row_top, mi_col_top, output_enabled, dst_buf2, + dst_stride2, 2); for (i = 0; i < MAX_MB_PLANE; i++) { xd->plane[i].dst.buf = dst_buf[i]; xd->plane[i].dst.stride = dst_stride[i]; - vp10_build_masked_inter_predictor_complex(xd, - dst_buf[i], dst_stride[i], - dst_buf1[i], dst_stride1[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_HORZ, i); + vp10_build_masked_inter_predictor_complex( + xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i], mi_row, + mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_HORZ, + i); } for (i = 0; i < MAX_MB_PLANE; i++) { - vp10_build_masked_inter_predictor_complex(xd, - dst_buf[i], dst_stride[i], - dst_buf2[i], dst_stride2[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_VERT, i); + vp10_build_masked_inter_predictor_complex( + xd, dst_buf[i], dst_stride[i], dst_buf2[i], dst_stride2[i], mi_row, + mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_VERT, + i); } break; case PARTITION_HORZ_B: predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col, - mi_row_top, mi_col_top, dst_buf, dst_stride, - top_bsize, subsize, output_enabled, 0, 0); + mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize, + subsize, output_enabled, 0, 0); if (bsize < top_bsize) extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col, mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride); else extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf, dst_stride, 0); + mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride, + 0); predict_b_extend(cpi, td, tile, 0, mi_row + hbs, mi_col, mi_row + hbs, mi_col, mi_row_top, mi_col_top, dst_buf1, dst_stride1, @@ -6069,8 +5795,8 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, predict_b_extend(cpi, td, tile, 0, mi_row + hbs, mi_col + hbs, mi_row + hbs, mi_col + hbs, mi_row_top, mi_col_top, - dst_buf2, dst_stride2, top_bsize, bsize2, - output_enabled, 0, 0); + dst_buf2, dst_stride2, top_bsize, bsize2, output_enabled, + 0, 0); extend_all(cpi, td, tile, 0, bsize2, top_bsize, mi_row + hbs, mi_col + hbs, mi_row_top, mi_col_top, output_enabled, dst_buf2, dst_stride2); @@ -6078,50 +5804,43 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, for (i = 0; i < MAX_MB_PLANE; i++) { xd->plane[i].dst.buf = dst_buf1[i]; xd->plane[i].dst.stride = dst_stride1[i]; - vp10_build_masked_inter_predictor_complex(xd, - dst_buf1[i], dst_stride1[i], - dst_buf2[i], dst_stride2[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_VERT, i); + vp10_build_masked_inter_predictor_complex( + xd, dst_buf1[i], dst_stride1[i], dst_buf2[i], dst_stride2[i], + mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize, + PARTITION_VERT, i); } for (i = 0; i < MAX_MB_PLANE; i++) { xd->plane[i].dst.buf = dst_buf[i]; xd->plane[i].dst.stride = dst_stride[i]; - vp10_build_masked_inter_predictor_complex(xd, - dst_buf[i], dst_stride[i], - dst_buf1[i], dst_stride1[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_HORZ, i); + vp10_build_masked_inter_predictor_complex( + xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i], mi_row, + mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_HORZ, + i); } break; case PARTITION_VERT_B: predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col, - mi_row_top, mi_col_top, dst_buf, dst_stride, - top_bsize, subsize, output_enabled, 0, 0); + mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize, + subsize, output_enabled, 0, 0); if (bsize < top_bsize) extend_all(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col, mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride); else extend_dir(cpi, td, tile, 0, subsize, top_bsize, mi_row, mi_col, - mi_row_top, mi_col_top, output_enabled, - dst_buf, dst_stride, 3); + mi_row_top, mi_col_top, output_enabled, dst_buf, dst_stride, + 3); predict_b_extend(cpi, td, tile, 0, mi_row, mi_col + hbs, mi_row, mi_col + hbs, mi_row_top, mi_col_top, dst_buf1, - dst_stride1, top_bsize, bsize2, output_enabled, - 0, 0); + dst_stride1, top_bsize, bsize2, output_enabled, 0, 0); extend_all(cpi, td, tile, 0, bsize2, top_bsize, mi_row, mi_col + hbs, mi_row_top, mi_col_top, output_enabled, dst_buf1, dst_stride1); predict_b_extend(cpi, td, tile, 0, mi_row + hbs, mi_col + hbs, mi_row + hbs, mi_col + hbs, mi_row_top, mi_col_top, - dst_buf2, dst_stride2, top_bsize, bsize2, - output_enabled, 0, 0); + dst_buf2, dst_stride2, top_bsize, bsize2, output_enabled, + 0, 0); extend_all(cpi, td, tile, 0, bsize2, top_bsize, mi_row + hbs, mi_col + hbs, mi_row_top, mi_col_top, output_enabled, dst_buf2, dst_stride2); @@ -6129,32 +5848,24 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, for (i = 0; i < MAX_MB_PLANE; i++) { xd->plane[i].dst.buf = dst_buf1[i]; xd->plane[i].dst.stride = dst_stride1[i]; - vp10_build_masked_inter_predictor_complex(xd, - dst_buf1[i], dst_stride1[i], - dst_buf2[i], dst_stride2[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_HORZ, i); + vp10_build_masked_inter_predictor_complex( + xd, dst_buf1[i], dst_stride1[i], dst_buf2[i], dst_stride2[i], + mi_row, mi_col, mi_row_top, mi_col_top, bsize, top_bsize, + PARTITION_HORZ, i); } for (i = 0; i < MAX_MB_PLANE; i++) { xd->plane[i].dst.buf = dst_buf[i]; xd->plane[i].dst.stride = dst_stride[i]; - vp10_build_masked_inter_predictor_complex(xd, - dst_buf[i], dst_stride[i], - dst_buf1[i], dst_stride1[i], - mi_row, mi_col, - mi_row_top, mi_col_top, - bsize, top_bsize, - PARTITION_VERT, i); + vp10_build_masked_inter_predictor_complex( + xd, dst_buf[i], dst_stride[i], dst_buf1[i], dst_stride1[i], mi_row, + mi_col, mi_row_top, mi_col_top, bsize, top_bsize, PARTITION_VERT, + i); } break; #endif // CONFIG_EXT_PARTITION_TYPES - default: - assert(0); + default: assert(0); } - #if CONFIG_EXT_PARTITION_TYPES if (bsize < top_bsize) update_ext_partition_context(xd, mi_row, mi_col, subsize, bsize, partition); @@ -6165,11 +5876,9 @@ static void predict_sb_complex(VP10_COMP *cpi, ThreadData *td, } static void rd_supertx_sb(VP10_COMP *cpi, ThreadData *td, - const TileInfo *const tile, - int mi_row, int mi_col, BLOCK_SIZE bsize, - int *tmp_rate, int64_t *tmp_dist, - TX_TYPE *best_tx, - PC_TREE *pc_tree) { + const TileInfo *const tile, int mi_row, int mi_col, + BLOCK_SIZE bsize, int *tmp_rate, int64_t *tmp_dist, + TX_TYPE *best_tx, PC_TREE *pc_tree) { VP10_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; @@ -6189,16 +5898,14 @@ static void rd_supertx_sb(VP10_COMP *cpi, ThreadData *td, set_skip_context(xd, mi_row, mi_col); set_mode_info_offsets(cpi, x, xd, mi_row, mi_col); - update_state_sb_supertx(cpi, td, tile, mi_row, mi_col, bsize, - 0, pc_tree); - vp10_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), - mi_row, mi_col); + update_state_sb_supertx(cpi, td, tile, mi_row, mi_col, bsize, 0, pc_tree); + vp10_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col); for (plane = 0; plane < MAX_MB_PLANE; plane++) { dst_buf[plane] = xd->plane[plane].dst.buf; dst_stride[plane] = xd->plane[plane].dst.stride; } - predict_sb_complex(cpi, td, tile, mi_row, mi_col, mi_row, mi_col, - 0, bsize, bsize, dst_buf, dst_stride, pc_tree); + predict_sb_complex(cpi, td, tile, mi_row, mi_col, mi_row, mi_col, 0, bsize, + bsize, dst_buf, dst_stride, pc_tree); set_offsets_without_segment_id(cpi, tile, x, mi_row, mi_col, bsize); set_segment_id_supertx(cpi, x, mi_row, mi_col, bsize); @@ -6226,24 +5933,22 @@ static void rd_supertx_sb(VP10_COMP *cpi, ThreadData *td, pnskip = 1; tx_size = max_txsize_lookup[bsize]; - tx_size = get_uv_tx_size_impl(tx_size, bsize, - cm->subsampling_x, cm->subsampling_y); + tx_size = get_uv_tx_size_impl(tx_size, bsize, cm->subsampling_x, + cm->subsampling_y); vp10_get_entropy_contexts(bsize, tx_size, pd, ctxa, ctxl); coeff_ctx = combine_entropy_contexts(ctxa[0], ctxl[0]); vp10_subtract_plane(x, bsize, plane); - vp10_tx_block_rd_b(cpi, x, tx_size, - 0, 0, plane, 0, - get_plane_block_size(bsize, pd), coeff_ctx, - &this_rate, &this_dist, &pnsse, &pnskip); + vp10_tx_block_rd_b(cpi, x, tx_size, 0, 0, plane, 0, + get_plane_block_size(bsize, pd), coeff_ctx, &this_rate, + &this_dist, &pnsse, &pnskip); #else tx_size = max_txsize_lookup[bsize]; - tx_size = get_uv_tx_size_impl(tx_size, bsize, - cm->subsampling_x, cm->subsampling_y); + tx_size = get_uv_tx_size_impl(tx_size, bsize, cm->subsampling_x, + cm->subsampling_y); vp10_subtract_plane(x, bsize, plane); - vp10_txfm_rd_in_plane_supertx(x, cpi, &this_rate, &this_dist, - &pnskip, &pnsse, - INT64_MAX, plane, bsize, tx_size, 0); + vp10_txfm_rd_in_plane_supertx(x, cpi, &this_rate, &this_dist, &pnskip, + &pnsse, INT64_MAX, plane, bsize, tx_size, 0); #endif // CONFIG_VAR_TX rate_uv += this_rate; @@ -6266,11 +5971,9 @@ static void rd_supertx_sb(VP10_COMP *cpi, ThreadData *td, int coeff_ctx = 1; #endif // CONFIG_VAR_TX #if CONFIG_EXT_TX - if (!ext_tx_used_inter[ext_tx_set][tx_type]) - continue; + if (!ext_tx_used_inter[ext_tx_set][tx_type]) continue; #else - if (tx_size >= TX_32X32 && tx_type != DCT_DCT) - continue; + if (tx_size >= TX_32X32 && tx_type != DCT_DCT) continue; #endif // CONFIG_EXT_TX mbmi->tx_type = tx_type; @@ -6282,9 +5985,7 @@ static void rd_supertx_sb(VP10_COMP *cpi, ThreadData *td, vp10_get_entropy_contexts(bsize, tx_size, pd, ctxa, ctxl); coeff_ctx = combine_entropy_contexts(ctxa[0], ctxl[0]); - vp10_tx_block_rd_b(cpi, x, tx_size, - 0, 0, 0, 0, - bsize, coeff_ctx, + vp10_tx_block_rd_b(cpi, x, tx_size, 0, 0, 0, 0, bsize, coeff_ctx, &this_rate, &this_dist, &pnsse, &pnskip); #else vp10_txfm_rd_in_plane_supertx(x, cpi, &this_rate, &this_dist, &pnskip, @@ -6293,15 +5994,13 @@ static void rd_supertx_sb(VP10_COMP *cpi, ThreadData *td, #if CONFIG_EXT_TX if (get_ext_tx_types(tx_size, bsize, 1) > 1 && - !xd->lossless[xd->mi[0]->mbmi.segment_id] && - this_rate != INT_MAX) { + !xd->lossless[xd->mi[0]->mbmi.segment_id] && this_rate != INT_MAX) { if (ext_tx_set > 0) - this_rate += cpi->inter_tx_type_costs[ext_tx_set] - [mbmi->tx_size][mbmi->tx_type]; + this_rate += + cpi->inter_tx_type_costs[ext_tx_set][mbmi->tx_size][mbmi->tx_type]; } #else - if (tx_size < TX_32X32 && - !xd->lossless[xd->mi[0]->mbmi.segment_id] && + if (tx_size < TX_32X32 && !xd->lossless[xd->mi[0]->mbmi.segment_id] && this_rate != INT_MAX) { this_rate += cpi->inter_tx_type_costs[tx_size][mbmi->tx_type]; } @@ -6314,8 +6013,8 @@ static void rd_supertx_sb(VP10_COMP *cpi, ThreadData *td, *tmp_rate = vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1); x->skip = 1; } else { - if (RDCOST(x->rdmult, x->rddiv, *tmp_rate, *tmp_dist) - < RDCOST(x->rdmult, x->rddiv, 0, sse)) { + if (RDCOST(x->rdmult, x->rddiv, *tmp_rate, *tmp_dist) < + RDCOST(x->rdmult, x->rddiv, 0, sse)) { *tmp_rate += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0); x->skip = 0; } else { diff --git a/vp10/encoder/encodeframe.h b/vp10/encoder/encodeframe.h index fbb81f8b1..f24a572a5 100644 --- a/vp10/encoder/encodeframe.h +++ b/vp10/encoder/encodeframe.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_ENCODEFRAME_H_ #define VP10_ENCODER_ENCODEFRAME_H_ @@ -31,14 +30,14 @@ struct ThreadData; #define VAR_HIST_SMALL_CUT_OFF 45 void vp10_setup_src_planes(struct macroblock *x, - const struct yv12_buffer_config *src, - int mi_row, int mi_col); + const struct yv12_buffer_config *src, int mi_row, + int mi_col); void vp10_encode_frame(struct VP10_COMP *cpi); void vp10_init_tile_data(struct VP10_COMP *cpi); void vp10_encode_tile(struct VP10_COMP *cpi, struct ThreadData *td, - int tile_row, int tile_col); + int tile_row, int tile_col); void vp10_set_variance_partition_thresholds(struct VP10_COMP *cpi, int q); diff --git a/vp10/encoder/encodemb.c b/vp10/encoder/encodemb.c index 2cc8575f9..38353153d 100644 --- a/vp10/encoder/encodemb.c +++ b/vp10/encoder/encodemb.c @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include "./vp10_rtcd.h" #include "./vpx_config.h" #include "./vpx_dsp_rtcd.h" @@ -48,27 +47,27 @@ void vp10_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { } typedef struct vp10_token_state { - int rate; - int64_t error; - int next; - int16_t token; - tran_low_t qc; - tran_low_t dqc; + int rate; + int64_t error; + int next; + int16_t token; + tran_low_t qc; + tran_low_t dqc; } vp10_token_state; // These numbers are empirically obtained. static const int plane_rd_mult[REF_TYPES][PLANE_TYPES] = { - {10, 6}, {8, 5}, + { 10, 6 }, { 8, 5 }, }; -#define UPDATE_RD_COST()\ -{\ - rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0);\ - rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1);\ -} +#define UPDATE_RD_COST() \ + { \ + rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0); \ + rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1); \ + } -int vp10_optimize_b(MACROBLOCK *mb, int plane, int block, - TX_SIZE tx_size, int ctx) { +int vp10_optimize_b(MACROBLOCK *mb, int plane, int block, TX_SIZE tx_size, + int ctx) { MACROBLOCKD *const xd = &mb->e_mbd; struct macroblock_plane *const p = &mb->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane]; @@ -82,13 +81,13 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block, const int eob = p->eobs[block]; const PLANE_TYPE type = pd->plane_type; const int default_eob = get_tx2d_size(tx_size); - const int16_t* const dequant_ptr = pd->dequant; - const uint8_t* const band_translate = get_band_translate(tx_size); + const int16_t *const dequant_ptr = pd->dequant; + const uint8_t *const band_translate = get_band_translate(tx_size); TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size); - const scan_order* const so = + const scan_order *const so = get_scan(tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi)); - const int16_t* const scan = so->scan; - const int16_t* const nb = so->neighbors; + const int16_t *const scan = so->scan; + const int16_t *const nb = so->neighbors; const int shift = get_tx_scale(xd, tx_type, tx_size); #if CONFIG_NEW_QUANT int dq = get_dq_profile_from_ctx(ctx); @@ -103,16 +102,16 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block, int rate0, rate1; int64_t error0, error1; int16_t t0, t1; - int best, band = (eob < default_eob) ? - band_translate[eob] : band_translate[eob - 1]; + int best, band = (eob < default_eob) ? band_translate[eob] + : band_translate[eob - 1]; int pt, i, final_eob; #if CONFIG_VP9_HIGHBITDEPTH const int *cat6_high_cost = vp10_get_high_cost_table(xd->bd); #else const int *cat6_high_cost = vp10_get_high_cost_table(8); #endif - unsigned int (*token_costs)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] = - mb->token_costs[txsize_sqr_map[tx_size]][type][ref]; + unsigned int(*token_costs)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] = + mb->token_costs[txsize_sqr_map[tx_size]][type][ref]; const uint16_t *band_counts = &band_count_table[tx_size][band]; uint16_t band_left = eob - band_cum_count_table[tx_size][band] + 1; int shortcut = 0; @@ -195,21 +194,20 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block, shortcut = 0; } else { #if CONFIG_NEW_QUANT - shortcut = ( - (vp10_dequant_abscoeff_nuq( - abs(x), dequant_ptr[rc != 0], - dequant_val[band_translate[i]]) > (abs(coeff[rc]) << shift)) && - (vp10_dequant_abscoeff_nuq( - abs(x) - 1, dequant_ptr[rc != 0], - dequant_val[band_translate[i]]) < (abs(coeff[rc]) << shift))); + shortcut = ((vp10_dequant_abscoeff_nuq(abs(x), dequant_ptr[rc != 0], + dequant_val[band_translate[i]]) > + (abs(coeff[rc]) << shift)) && + (vp10_dequant_abscoeff_nuq(abs(x) - 1, dequant_ptr[rc != 0], + dequant_val[band_translate[i]]) < + (abs(coeff[rc]) << shift))); #else // CONFIG_NEW_QUANT if ((abs(x) * dequant_ptr[rc != 0] > (abs(coeff[rc]) << shift)) && - (abs(x) * dequant_ptr[rc != 0] < (abs(coeff[rc]) << shift) + - dequant_ptr[rc != 0])) + (abs(x) * dequant_ptr[rc != 0] < + (abs(coeff[rc]) << shift) + dequant_ptr[rc != 0])) shortcut = 1; else shortcut = 0; -#endif // CONFIG_NEW_QUANT +#endif // CONFIG_NEW_QUANT } if (shortcut) { @@ -269,9 +267,9 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block, } #if CONFIG_NEW_QUANT - dx = vp10_dequant_coeff_nuq( - x, dequant_ptr[rc != 0], - dequant_val[band_translate[i]]) - (coeff[rc] << shift); + dx = vp10_dequant_coeff_nuq(x, dequant_ptr[rc != 0], + dequant_val[band_translate[i]]) - + (coeff[rc] << shift); #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { dx >>= xd->bd - 8; @@ -300,18 +298,16 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block, #if CONFIG_NEW_QUANT tokens[i][1].dqc = vp10_dequant_abscoeff_nuq( abs(x), dequant_ptr[rc != 0], dequant_val[band_translate[i]]); - tokens[i][1].dqc = shift ? - ROUND_POWER_OF_TWO(tokens[i][1].dqc, shift) : tokens[i][1].dqc; - if (sz) - tokens[i][1].dqc = -tokens[i][1].dqc; + tokens[i][1].dqc = shift ? ROUND_POWER_OF_TWO(tokens[i][1].dqc, shift) + : tokens[i][1].dqc; + if (sz) tokens[i][1].dqc = -tokens[i][1].dqc; #else tran_low_t offset = dq_step[rc != 0]; // The 32x32 transform coefficient uses half quantization step size. // Account for the rounding difference in the dequantized coefficeint // value when the quantization index is dropped from an even number // to an odd number. - if (shift & x) - offset += (dequant_ptr[rc != 0] & 0x01); + if (shift & x) offset += (dequant_ptr[rc != 0] & 0x01); if (sz == 0) tokens[i][1].dqc = dqcoeff[rc] - offset; @@ -394,10 +390,11 @@ typedef enum QUANT_FUNC { static VP10_QUANT_FACADE quant_func_list[VP10_XFORM_QUANT_LAST][QUANT_FUNC_LAST] = { - {vp10_quantize_fp_facade, vp10_highbd_quantize_fp_facade}, - {vp10_quantize_b_facade, vp10_highbd_quantize_b_facade}, - {vp10_quantize_dc_facade, vp10_highbd_quantize_dc_facade}, - {NULL, NULL}}; + { vp10_quantize_fp_facade, vp10_highbd_quantize_fp_facade }, + { vp10_quantize_b_facade, vp10_highbd_quantize_b_facade }, + { vp10_quantize_dc_facade, vp10_highbd_quantize_dc_facade }, + { NULL, NULL } + }; #else typedef enum QUANT_FUNC { @@ -407,15 +404,16 @@ typedef enum QUANT_FUNC { static VP10_QUANT_FACADE quant_func_list[VP10_XFORM_QUANT_LAST][QUANT_FUNC_LAST] = { - {vp10_quantize_fp_facade}, - {vp10_quantize_b_facade}, - {vp10_quantize_dc_facade}, - {NULL}}; + { vp10_quantize_fp_facade }, + { vp10_quantize_b_facade }, + { vp10_quantize_dc_facade }, + { NULL } + }; #endif static FWD_TXFM_OPT fwd_txfm_opt_list[VP10_XFORM_QUANT_LAST] = { - FWD_TXFM_OPT_NORMAL, FWD_TXFM_OPT_NORMAL, FWD_TXFM_OPT_DC, - FWD_TXFM_OPT_NORMAL}; + FWD_TXFM_OPT_NORMAL, FWD_TXFM_OPT_NORMAL, FWD_TXFM_OPT_DC, FWD_TXFM_OPT_NORMAL +}; void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row, int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, @@ -454,8 +452,7 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row, if (xform_quant_idx != VP10_XFORM_QUANT_SKIP_QUANT) { if (LIKELY(!x->skip_block)) { quant_func_list[xform_quant_idx][QUANT_FUNC_HIGHBD]( - coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, - scan_order, &qparam); + coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order, &qparam); } else { vp10_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob); } @@ -468,8 +465,7 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row, if (xform_quant_idx != VP10_XFORM_QUANT_SKIP_QUANT) { if (LIKELY(!x->skip_block)) { quant_func_list[xform_quant_idx][QUANT_FUNC_LOWBD]( - coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, - scan_order, &qparam); + coeff, tx2d_size, p, qcoeff, pd, dqcoeff, eob, scan_order, &qparam); } else { vp10_quantize_skip(tx2d_size, qcoeff, dqcoeff, eob); } @@ -478,8 +474,8 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row, #if CONFIG_NEW_QUANT void vp10_xform_quant_nuq(MACROBLOCK *x, int plane, int block, int blk_row, - int blk_col, BLOCK_SIZE plane_bsize, - TX_SIZE tx_size, int ctx) { + int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, + int ctx) { MACROBLOCKD *const xd = &x->e_mbd; const struct macroblock_plane *const p = &x->plane[plane]; const struct macroblockd_plane *const pd = &xd->plane[plane]; @@ -494,7 +490,7 @@ void vp10_xform_quant_nuq(MACROBLOCK *x, int plane, int block, int blk_row, uint16_t *const eob = &p->eobs[block]; const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; const int16_t *src_diff; - const uint8_t* band = get_band_translate(tx_size); + const uint8_t *band = get_band_translate(tx_size); FWD_TXFM_PARAM fwd_txfm_param; @@ -513,22 +509,18 @@ void vp10_xform_quant_nuq(MACROBLOCK *x, int plane, int block, int blk_row, if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { highbd_fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param); if (tx_size == TX_32X32) { - highbd_quantize_32x32_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, - p->quant, p->quant_shift, pd->dequant, - (const cuml_bins_type_nuq *) - p->cuml_bins_nuq[dq], - (const dequant_val_type_nuq *) - pd->dequant_val_nuq[dq], - qcoeff, dqcoeff, eob, - scan_order->scan, band); + highbd_quantize_32x32_nuq( + coeff, get_tx2d_size(tx_size), x->skip_block, p->quant, + p->quant_shift, pd->dequant, + (const cuml_bins_type_nuq *)p->cuml_bins_nuq[dq], + (const dequant_val_type_nuq *)pd->dequant_val_nuq[dq], qcoeff, + dqcoeff, eob, scan_order->scan, band); } else { highbd_quantize_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, p->quant, p->quant_shift, pd->dequant, (const cuml_bins_type_nuq *)p->cuml_bins_nuq[dq], - (const dequant_val_type_nuq *) - pd->dequant_val_nuq[dq], - qcoeff, dqcoeff, eob, - scan_order->scan, band); + (const dequant_val_type_nuq *)pd->dequant_val_nuq[dq], + qcoeff, dqcoeff, eob, scan_order->scan, band); } return; } @@ -536,20 +528,17 @@ void vp10_xform_quant_nuq(MACROBLOCK *x, int plane, int block, int blk_row, fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param); if (tx_size == TX_32X32) { - quantize_32x32_nuq(coeff, 1024, x->skip_block, - p->quant, p->quant_shift, pd->dequant, + quantize_32x32_nuq(coeff, 1024, x->skip_block, p->quant, p->quant_shift, + pd->dequant, (const cuml_bins_type_nuq *)p->cuml_bins_nuq[dq], - (const dequant_val_type_nuq *) - pd->dequant_val_nuq[dq], - qcoeff, dqcoeff, eob, - scan_order->scan, band); + (const dequant_val_type_nuq *)pd->dequant_val_nuq[dq], + qcoeff, dqcoeff, eob, scan_order->scan, band); } else { - quantize_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, - p->quant, p->quant_shift, pd->dequant, + quantize_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, p->quant, + p->quant_shift, pd->dequant, (const cuml_bins_type_nuq *)p->cuml_bins_nuq[dq], - (const dequant_val_type_nuq *)pd->dequant_val_nuq[dq], - qcoeff, dqcoeff, eob, - scan_order->scan, band); + (const dequant_val_type_nuq *)pd->dequant_val_nuq[dq], qcoeff, + dqcoeff, eob, scan_order->scan, band); } } @@ -570,7 +559,7 @@ void vp10_xform_quant_fp_nuq(MACROBLOCK *x, int plane, int block, int blk_row, uint16_t *const eob = &p->eobs[block]; const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; const int16_t *src_diff; - const uint8_t* band = get_band_translate(tx_size); + const uint8_t *band = get_band_translate(tx_size); FWD_TXFM_PARAM fwd_txfm_param; @@ -589,23 +578,17 @@ void vp10_xform_quant_fp_nuq(MACROBLOCK *x, int plane, int block, int blk_row, if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { highbd_fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param); if (tx_size == TX_32X32) { - highbd_quantize_32x32_fp_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, - p->quant_fp, pd->dequant, - (const cuml_bins_type_nuq *) - p->cuml_bins_nuq[dq], - (const dequant_val_type_nuq *) - pd->dequant_val_nuq[dq], - qcoeff, dqcoeff, eob, - scan_order->scan, band); + highbd_quantize_32x32_fp_nuq( + coeff, get_tx2d_size(tx_size), x->skip_block, p->quant_fp, + pd->dequant, (const cuml_bins_type_nuq *)p->cuml_bins_nuq[dq], + (const dequant_val_type_nuq *)pd->dequant_val_nuq[dq], qcoeff, + dqcoeff, eob, scan_order->scan, band); } else { - highbd_quantize_fp_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, - p->quant_fp, pd->dequant, - (const cuml_bins_type_nuq *) - p->cuml_bins_nuq[dq], - (const dequant_val_type_nuq *) - pd->dequant_val_nuq[dq], - qcoeff, dqcoeff, eob, - scan_order->scan, band); + highbd_quantize_fp_nuq( + coeff, get_tx2d_size(tx_size), x->skip_block, p->quant_fp, + pd->dequant, (const cuml_bins_type_nuq *)p->cuml_bins_nuq[dq], + (const dequant_val_type_nuq *)pd->dequant_val_nuq[dq], qcoeff, + dqcoeff, eob, scan_order->scan, band); } return; } @@ -615,21 +598,15 @@ void vp10_xform_quant_fp_nuq(MACROBLOCK *x, int plane, int block, int blk_row, if (tx_size == TX_32X32) { quantize_32x32_fp_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, p->quant_fp, pd->dequant, - (const cuml_bins_type_nuq *) - p->cuml_bins_nuq[dq], - (const dequant_val_type_nuq *) - pd->dequant_val_nuq[dq], - qcoeff, dqcoeff, eob, - scan_order->scan, band); + (const cuml_bins_type_nuq *)p->cuml_bins_nuq[dq], + (const dequant_val_type_nuq *)pd->dequant_val_nuq[dq], + qcoeff, dqcoeff, eob, scan_order->scan, band); } else { - quantize_fp_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, - p->quant_fp, pd->dequant, - (const cuml_bins_type_nuq *) - p->cuml_bins_nuq[dq], - (const dequant_val_type_nuq *) - pd->dequant_val_nuq[dq], - qcoeff, dqcoeff, eob, - scan_order->scan, band); + quantize_fp_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, p->quant_fp, + pd->dequant, + (const cuml_bins_type_nuq *)p->cuml_bins_nuq[dq], + (const dequant_val_type_nuq *)pd->dequant_val_nuq[dq], + qcoeff, dqcoeff, eob, scan_order->scan, band); } } @@ -666,19 +643,15 @@ void vp10_xform_quant_dc_nuq(MACROBLOCK *x, int plane, int block, int blk_row, if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { highbd_fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param); if (tx_size == TX_32X32) { - highbd_quantize_dc_32x32_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, - p->quant[0], p->quant_shift[0], - pd->dequant[0], - p->cuml_bins_nuq[dq][0], - pd->dequant_val_nuq[dq][0], - qcoeff, dqcoeff, eob); + highbd_quantize_dc_32x32_nuq( + coeff, get_tx2d_size(tx_size), x->skip_block, p->quant[0], + p->quant_shift[0], pd->dequant[0], p->cuml_bins_nuq[dq][0], + pd->dequant_val_nuq[dq][0], qcoeff, dqcoeff, eob); } else { highbd_quantize_dc_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, - p->quant[0], p->quant_shift[0], - pd->dequant[0], + p->quant[0], p->quant_shift[0], pd->dequant[0], p->cuml_bins_nuq[dq][0], - pd->dequant_val_nuq[dq][0], - qcoeff, dqcoeff, eob); + pd->dequant_val_nuq[dq][0], qcoeff, dqcoeff, eob); } return; } @@ -688,15 +661,12 @@ void vp10_xform_quant_dc_nuq(MACROBLOCK *x, int plane, int block, int blk_row, if (tx_size == TX_32X32) { quantize_dc_32x32_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, p->quant[0], p->quant_shift[0], pd->dequant[0], - p->cuml_bins_nuq[dq][0], - pd->dequant_val_nuq[dq][0], + p->cuml_bins_nuq[dq][0], pd->dequant_val_nuq[dq][0], qcoeff, dqcoeff, eob); } else { - quantize_dc_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, - p->quant[0], p->quant_shift[0], pd->dequant[0], - p->cuml_bins_nuq[dq][0], - pd->dequant_val_nuq[dq][0], - qcoeff, dqcoeff, eob); + quantize_dc_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, p->quant[0], + p->quant_shift[0], pd->dequant[0], p->cuml_bins_nuq[dq][0], + pd->dequant_val_nuq[dq][0], qcoeff, dqcoeff, eob); } } @@ -734,18 +704,15 @@ void vp10_xform_quant_dc_fp_nuq(MACROBLOCK *x, int plane, int block, if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { highbd_fwd_txfm(src_diff, coeff, diff_stride, &fwd_txfm_param); if (tx_size == TX_32X32) { - highbd_quantize_dc_32x32_fp_nuq(coeff, get_tx2d_size(tx_size), - x->skip_block, - p->quant_fp[0], pd->dequant[0], - p->cuml_bins_nuq[dq][0], - pd->dequant_val_nuq[dq][0], - qcoeff, dqcoeff, eob); + highbd_quantize_dc_32x32_fp_nuq( + coeff, get_tx2d_size(tx_size), x->skip_block, p->quant_fp[0], + pd->dequant[0], p->cuml_bins_nuq[dq][0], pd->dequant_val_nuq[dq][0], + qcoeff, dqcoeff, eob); } else { - highbd_quantize_dc_fp_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, - p->quant_fp[0], pd->dequant[0], - p->cuml_bins_nuq[dq][0], - pd->dequant_val_nuq[dq][0], - qcoeff, dqcoeff, eob); + highbd_quantize_dc_fp_nuq( + coeff, get_tx2d_size(tx_size), x->skip_block, p->quant_fp[0], + pd->dequant[0], p->cuml_bins_nuq[dq][0], pd->dequant_val_nuq[dq][0], + qcoeff, dqcoeff, eob); } return; } @@ -756,21 +723,17 @@ void vp10_xform_quant_dc_fp_nuq(MACROBLOCK *x, int plane, int block, quantize_dc_32x32_fp_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, p->quant_fp[0], pd->dequant[0], p->cuml_bins_nuq[dq][0], - pd->dequant_val_nuq[dq][0], - qcoeff, dqcoeff, eob); + pd->dequant_val_nuq[dq][0], qcoeff, dqcoeff, eob); } else { quantize_dc_fp_nuq(coeff, get_tx2d_size(tx_size), x->skip_block, - p->quant_fp[0], pd->dequant[0], - p->cuml_bins_nuq[dq][0], - pd->dequant_val_nuq[dq][0], - qcoeff, dqcoeff, eob); + p->quant_fp[0], pd->dequant[0], p->cuml_bins_nuq[dq][0], + pd->dequant_val_nuq[dq][0], qcoeff, dqcoeff, eob); } } #endif // CONFIG_NEW_QUANT static void encode_block(int plane, int block, int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, - TX_SIZE tx_size, void *arg) { + BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) { struct encode_b_args *const args = arg; MACROBLOCK *const x = args->x; MACROBLOCKD *const xd = &x->e_mbd; @@ -806,8 +769,8 @@ static void encode_block(int plane, int block, int blk_row, int blk_col, vp10_xform_quant_fp_nuq(x, plane, block, blk_row, blk_col, plane_bsize, tx_size, ctx); #else - vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, - tx_size, VP10_XFORM_QUANT_FP); + vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size, + VP10_XFORM_QUANT_FP); #endif // CONFIG_NEW_QUANT } #if CONFIG_VAR_TX @@ -831,11 +794,9 @@ static void encode_block(int plane, int block, int blk_row, int blk_col, } #endif - if (p->eobs[block]) - *(args->skip) = 0; + if (p->eobs[block]) *(args->skip) = 0; - if (p->eobs[block] == 0) - return; + if (p->eobs[block] == 0) return; // inverse transform parameters inv_txfm_param.tx_type = get_tx_type(pd->plane_type, xd, block, tx_size); @@ -865,9 +826,10 @@ static void encode_block_inter(int plane, int block, int blk_row, int blk_col, const struct macroblockd_plane *const pd = &xd->plane[plane]; const int tx_row = blk_row >> (1 - pd->subsampling_y); const int tx_col = blk_col >> (1 - pd->subsampling_x); - const TX_SIZE plane_tx_size = plane ? - get_uv_tx_size_impl(mbmi->inter_tx_size[tx_row][tx_col], bsize, 0, 0) : - mbmi->inter_tx_size[tx_row][tx_col]; + const TX_SIZE plane_tx_size = + plane ? get_uv_tx_size_impl(mbmi->inter_tx_size[tx_row][tx_col], bsize, 0, + 0) + : mbmi->inter_tx_size[tx_row][tx_col]; int max_blocks_high = num_4x4_blocks_high_lookup[plane_bsize]; int max_blocks_wide = num_4x4_blocks_wide_lookup[plane_bsize]; @@ -877,12 +839,10 @@ static void encode_block_inter(int plane, int block, int blk_row, int blk_col, if (xd->mb_to_right_edge < 0) max_blocks_wide += xd->mb_to_right_edge >> (5 + pd->subsampling_x); - if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) - return; + if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (tx_size == plane_tx_size) { - encode_block(plane, block, blk_row, blk_col, plane_bsize, - tx_size, arg); + encode_block(plane, block, blk_row, blk_col, plane_bsize, tx_size, arg); } else { int bsl = b_width_log2_lookup[bsize]; int i; @@ -899,19 +859,18 @@ static void encode_block_inter(int plane, int block, int blk_row, int blk_col, const int offsetc = blk_col + ((i & 0x01) << bsl); int step = num_4x4_blocks_txsize_lookup[tx_size - 1]; - if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) - continue; + if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) continue; - encode_block_inter(plane, block + i * step, offsetr, offsetc, - plane_bsize, tx_size - 1, arg); + encode_block_inter(plane, block + i * step, offsetr, offsetc, plane_bsize, + tx_size - 1, arg); } } } #endif static void encode_block_pass1(int plane, int block, int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, - TX_SIZE tx_size, void *arg) { + BLOCK_SIZE plane_bsize, TX_SIZE tx_size, + void *arg) { MACROBLOCK *const x = (MACROBLOCK *)arg; MACROBLOCKD *const xd = &x->e_mbd; struct macroblock_plane *const p = &x->plane[plane]; @@ -928,19 +887,19 @@ static void encode_block_pass1(int plane, int block, int blk_row, int blk_col, vp10_xform_quant_fp_nuq(x, plane, block, blk_row, blk_col, plane_bsize, tx_size, ctx); #else - vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, - tx_size, VP10_XFORM_QUANT_B); + vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size, + VP10_XFORM_QUANT_B); #endif // CONFIG_NEW_QUANT if (p->eobs[block] > 0) { #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { if (xd->lossless[xd->mi[0]->mbmi.segment_id]) { - vp10_highbd_iwht4x4_add(dqcoeff, dst, pd->dst.stride, - p->eobs[block], xd->bd); + vp10_highbd_iwht4x4_add(dqcoeff, dst, pd->dst.stride, p->eobs[block], + xd->bd); } else { - vp10_highbd_idct4x4_add(dqcoeff, dst, pd->dst.stride, - p->eobs[block], xd->bd); + vp10_highbd_idct4x4_add(dqcoeff, dst, pd->dst.stride, p->eobs[block], + xd->bd); } return; } @@ -963,13 +922,12 @@ void vp10_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { MACROBLOCKD *const xd = &x->e_mbd; struct optimize_ctx ctx; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; - struct encode_b_args arg = {x, &ctx, &mbmi->skip, NULL, NULL, 1}; + struct encode_b_args arg = { x, &ctx, &mbmi->skip, NULL, NULL, 1 }; int plane; mbmi->skip = 1; - if (x->skip) - return; + if (x->skip) return; for (plane = 0; plane < MAX_MB_PLANE; ++plane) { #if CONFIG_VAR_TX @@ -986,7 +944,7 @@ void vp10_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { int step = num_4x4_blocks_txsize_lookup[max_tx_size]; vp10_get_entropy_contexts(bsize, TX_4X4, pd, ctx.ta[plane], ctx.tl[plane]); #else - const struct macroblockd_plane* const pd = &xd->plane[plane]; + const struct macroblockd_plane *const pd = &xd->plane[plane]; const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi, pd) : mbmi->tx_size; vp10_get_entropy_contexts(bsize, tx_size, pd, ctx.ta[plane], ctx.tl[plane]); #endif @@ -997,8 +955,8 @@ void vp10_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { #if CONFIG_VAR_TX for (idy = 0; idy < mi_height; idy += bh) { for (idx = 0; idx < mi_width; idx += bh) { - encode_block_inter(plane, block, idy, idx, plane_bsize, - max_tx_size, &arg); + encode_block_inter(plane, block, idy, idx, plane_bsize, max_tx_size, + &arg); block += step; } } @@ -1014,23 +972,21 @@ void vp10_encode_sb_supertx(MACROBLOCK *x, BLOCK_SIZE bsize) { MACROBLOCKD *const xd = &x->e_mbd; struct optimize_ctx ctx; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; - struct encode_b_args arg = {x, &ctx, &mbmi->skip, NULL, NULL, 1}; + struct encode_b_args arg = { x, &ctx, &mbmi->skip, NULL, NULL, 1 }; int plane; mbmi->skip = 1; - if (x->skip) - return; + if (x->skip) return; for (plane = 0; plane < MAX_MB_PLANE; ++plane) { - const struct macroblockd_plane* const pd = &xd->plane[plane]; + const struct macroblockd_plane *const pd = &xd->plane[plane]; #if CONFIG_VAR_TX const TX_SIZE tx_size = TX_4X4; #else const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi, pd) : mbmi->tx_size; #endif vp10_subtract_plane(x, bsize, plane); - vp10_get_entropy_contexts(bsize, tx_size, pd, - ctx.ta[plane], ctx.tl[plane]); + vp10_get_entropy_contexts(bsize, tx_size, pd, ctx.ta[plane], ctx.tl[plane]); arg.ta = ctx.ta[plane]; arg.tl = ctx.tl[plane]; vp10_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block, @@ -1040,9 +996,9 @@ void vp10_encode_sb_supertx(MACROBLOCK *x, BLOCK_SIZE bsize) { #endif // CONFIG_SUPERTX void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, - TX_SIZE tx_size, void *arg) { - struct encode_b_args* const args = arg; + BLOCK_SIZE plane_bsize, TX_SIZE tx_size, + void *arg) { + struct encode_b_args *const args = arg; MACROBLOCK *const x = args->x; MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; @@ -1097,7 +1053,7 @@ void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col, #if CONFIG_NEW_QUANT vp10_xform_quant_fp_nuq(x, plane, block, blk_row, blk_col, plane_bsize, tx_size, ctx); -#else // CONFIG_NEW_QUANT +#else // CONFIG_NEW_QUANT vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size, VP10_XFORM_QUANT_FP); #endif // CONFIG_NEW_QUANT @@ -1139,12 +1095,12 @@ void vp10_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane, ENTROPY_CONTEXT ta[2 * MAX_MIB_SIZE]; ENTROPY_CONTEXT tl[2 * MAX_MIB_SIZE]; - struct encode_b_args arg = {x, NULL, &xd->mi[0]->mbmi.skip, - ta, tl, enable_optimize_b}; + struct encode_b_args arg = { x, NULL, &xd->mi[0]->mbmi.skip, + ta, tl, enable_optimize_b }; if (enable_optimize_b) { - const struct macroblockd_plane* const pd = &xd->plane[plane]; - const TX_SIZE tx_size = plane ? get_uv_tx_size(&xd->mi[0]->mbmi, pd) : - xd->mi[0]->mbmi.tx_size; + const struct macroblockd_plane *const pd = &xd->plane[plane]; + const TX_SIZE tx_size = + plane ? get_uv_tx_size(&xd->mi[0]->mbmi, pd) : xd->mi[0]->mbmi.tx_size; vp10_get_entropy_contexts(bsize, tx_size, pd, ta, tl); } vp10_foreach_transformed_block_in_plane(xd, bsize, plane, diff --git a/vp10/encoder/encodemb.h b/vp10/encoder/encodemb.h index 8beb57838..974af8009 100644 --- a/vp10/encoder/encodemb.h +++ b/vp10/encoder/encodemb.h @@ -45,14 +45,13 @@ void vp10_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize); void vp10_encode_sb_supertx(MACROBLOCK *x, BLOCK_SIZE bsize); #endif // CONFIG_SUPERTX void vp10_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize); -void vp10_xform_quant(MACROBLOCK *x, int plane, int block, - int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, TX_SIZE tx_size, +void vp10_xform_quant(MACROBLOCK *x, int plane, int block, int blk_row, + int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, VP10_XFORM_QUANT xform_quant_idx); #if CONFIG_NEW_QUANT void vp10_xform_quant_nuq(MACROBLOCK *x, int plane, int block, int blk_row, - int blk_col, BLOCK_SIZE plane_bsize, - TX_SIZE tx_size, int ctx); + int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, + int ctx); void vp10_xform_quant_dc_nuq(MACROBLOCK *x, int plane, int block, int blk_row, int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int ctx); @@ -65,14 +64,14 @@ void vp10_xform_quant_dc_fp_nuq(MACROBLOCK *x, int plane, int block, int ctx); #endif -int vp10_optimize_b(MACROBLOCK *mb, int plane, int block, - TX_SIZE tx_size, int ctx); +int vp10_optimize_b(MACROBLOCK *mb, int plane, int block, TX_SIZE tx_size, + int ctx); void vp10_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane); void vp10_encode_block_intra(int plane, int block, int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, - TX_SIZE tx_size, void *arg); + BLOCK_SIZE plane_bsize, TX_SIZE tx_size, + void *arg); void vp10_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane, int enable_optimize_b); diff --git a/vp10/encoder/encodemv.c b/vp10/encoder/encodemv.c index 727d6b532..340cb46e9 100644 --- a/vp10/encoder/encodemv.c +++ b/vp10/encoder/encodemv.c @@ -31,15 +31,15 @@ void vp10_entropy_mv_init(void) { vp10_tokens_from_tree(mv_fp_encodings, vp10_mv_fp_tree); } -static void encode_mv_component(vp10_writer* w, int comp, - const nmv_component* mvcomp, int usehp) { +static void encode_mv_component(vp10_writer *w, int comp, + const nmv_component *mvcomp, int usehp) { int offset; const int sign = comp < 0; const int mag = sign ? -comp : comp; const int mv_class = vp10_get_mv_class(mag - 1, &offset); - const int d = offset >> 3; // int mv data - const int fr = (offset >> 1) & 3; // fractional mv data - const int hp = offset & 1; // high precision mv data + const int d = offset >> 3; // int mv data + const int fr = (offset >> 1) & 3; // fractional mv data + const int hp = offset & 1; // high precision mv data assert(comp != 0); @@ -48,33 +48,30 @@ static void encode_mv_component(vp10_writer* w, int comp, // Class vp10_write_token(w, vp10_mv_class_tree, mvcomp->classes, - &mv_class_encodings[mv_class]); + &mv_class_encodings[mv_class]); // Integer bits if (mv_class == MV_CLASS_0) { vp10_write_token(w, vp10_mv_class0_tree, mvcomp->class0, - &mv_class0_encodings[d]); + &mv_class0_encodings[d]); } else { int i; const int n = mv_class + CLASS0_BITS - 1; // number of bits - for (i = 0; i < n; ++i) - vp10_write(w, (d >> i) & 1, mvcomp->bits[i]); + for (i = 0; i < n; ++i) vp10_write(w, (d >> i) & 1, mvcomp->bits[i]); } // Fractional bits vp10_write_token(w, vp10_mv_fp_tree, - mv_class == MV_CLASS_0 ? mvcomp->class0_fp[d] : mvcomp->fp, - &mv_fp_encodings[fr]); + mv_class == MV_CLASS_0 ? mvcomp->class0_fp[d] : mvcomp->fp, + &mv_fp_encodings[fr]); // High precision bit if (usehp) - vp10_write(w, hp, - mv_class == MV_CLASS_0 ? mvcomp->class0_hp : mvcomp->hp); + vp10_write(w, hp, mv_class == MV_CLASS_0 ? mvcomp->class0_hp : mvcomp->hp); } - static void build_nmv_component_cost_table(int *mvcost, - const nmv_component* const mvcomp, + const nmv_component *const mvcomp, int usehp) { int i, v; int sign_cost[2], class_cost[MV_CLASSES], class0_cost[CLASS0_SIZE]; @@ -107,16 +104,15 @@ static void build_nmv_component_cost_table(int *mvcost, z = v - 1; c = vp10_get_mv_class(z, &o); cost += class_cost[c]; - d = (o >> 3); /* int mv data */ - f = (o >> 1) & 3; /* fractional pel mv data */ - e = (o & 1); /* high precision mv data */ + d = (o >> 3); /* int mv data */ + f = (o >> 1) & 3; /* fractional pel mv data */ + e = (o & 1); /* high precision mv data */ if (c == MV_CLASS_0) { cost += class0_cost[d]; } else { int i, b; - b = c + CLASS0_BITS - 1; /* number of bits */ - for (i = 0; i < b; ++i) - cost += bits_cost[i][((d >> i) & 1)]; + b = c + CLASS0_BITS - 1; /* number of bits */ + for (i = 0; i < b; ++i) cost += bits_cost[i][((d >> i) & 1)]; } if (c == MV_CLASS_0) { cost += class0_fp_cost[d][f]; @@ -137,14 +133,14 @@ static void build_nmv_component_cost_table(int *mvcost, static void update_mv(vp10_writer *w, const unsigned int ct[2], vpx_prob *cur_p, vpx_prob upd_p) { - (void) upd_p; + (void)upd_p; vp10_cond_prob_diff_update(w, cur_p, ct); } static void write_mv_update(const vpx_tree_index *tree, vpx_prob probs[/*n - 1*/], - const unsigned int counts[/*n - 1*/], - int n, vp10_writer *w) { + const unsigned int counts[/*n - 1*/], int n, + vp10_writer *w) { int i; unsigned int branch_ct[32][2]; @@ -164,8 +160,8 @@ void vp10_write_nmv_probs(VP10_COMMON *cm, int usehp, vp10_writer *w, for (nmv_ctx = 0; nmv_ctx < NMV_CONTEXTS; ++nmv_ctx) { nmv_context *const mvc = &cm->fc->nmvc[nmv_ctx]; nmv_context_counts *const counts = &nmv_counts[nmv_ctx]; - write_mv_update(vp10_mv_joint_tree, mvc->joints, counts->joints, - MV_JOINTS, w); + write_mv_update(vp10_mv_joint_tree, mvc->joints, counts->joints, MV_JOINTS, + w); vp10_cond_prob_diff_update(w, &mvc->zero_rmv, counts->zero_rmv); @@ -203,7 +199,8 @@ void vp10_write_nmv_probs(VP10_COMMON *cm, int usehp, vp10_writer *w, nmv_context *const mvc = &cm->fc->nmvc; nmv_context_counts *const counts = nmv_counts; - write_mv_update(vp10_mv_joint_tree, mvc->joints, counts->joints, MV_JOINTS, w); + write_mv_update(vp10_mv_joint_tree, mvc->joints, counts->joints, MV_JOINTS, + w); for (i = 0; i < 2; ++i) { nmv_component *comp = &mvc->comps[i]; @@ -237,25 +234,21 @@ void vp10_write_nmv_probs(VP10_COMMON *cm, int usehp, vp10_writer *w, #endif } -void vp10_encode_mv(VP10_COMP* cpi, vp10_writer* w, - const MV* mv, const MV* ref, +void vp10_encode_mv(VP10_COMP *cpi, vp10_writer *w, const MV *mv, const MV *ref, #if CONFIG_REF_MV - int is_compound, + int is_compound, #endif - const nmv_context* mvctx, int usehp) { - const MV diff = {mv->row - ref->row, - mv->col - ref->col}; + const nmv_context *mvctx, int usehp) { + const MV diff = { mv->row - ref->row, mv->col - ref->col }; const MV_JOINT_TYPE j = vp10_get_mv_joint(&diff); usehp = usehp && vp10_use_mv_hp(ref); #if CONFIG_REF_MV && !CONFIG_EXT_INTER if (is_compound) { vp10_write(w, (j == MV_JOINT_ZERO), mvctx->zero_rmv); - if (j == MV_JOINT_ZERO) - return; + if (j == MV_JOINT_ZERO) return; } else { - if (j == MV_JOINT_ZERO) - assert(0); + if (j == MV_JOINT_ZERO) assert(0); } #endif @@ -263,7 +256,8 @@ void vp10_encode_mv(VP10_COMP* cpi, vp10_writer* w, (void)is_compound; #endif - vp10_write_token(w, vp10_mv_joint_tree, mvctx->joints, &mv_joint_encodings[j]); + vp10_write_token(w, vp10_mv_joint_tree, mvctx->joints, + &mv_joint_encodings[j]); if (mv_joint_vertical(j)) encode_mv_component(w, diff.row, &mvctx->comps[0], usehp); @@ -279,7 +273,7 @@ void vp10_encode_mv(VP10_COMP* cpi, vp10_writer* w, } void vp10_build_nmv_cost_table(int *mvjoint, int *mvcost[2], - const nmv_context* ctx, int usehp) { + const nmv_context *ctx, int usehp) { vp10_cost_tokens(mvjoint, ctx->joints, vp10_mv_joint_tree); build_nmv_component_cost_table(mvcost[0], &ctx->comps[0], usehp); build_nmv_component_cost_table(mvcost[1], &ctx->comps[1], usehp); @@ -302,8 +296,8 @@ static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, if (mode == NEWMV || mode == NEWFROMNEARMV || mode == NEW_NEWMV) { for (i = 0; i < 1 + has_second_ref(mbmi); ++i) { const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[i]][mv_idx].as_mv; - const MV diff = {mvs[i].as_mv.row - ref->row, - mvs[i].as_mv.col - ref->col}; + const MV diff = { mvs[i].as_mv.row - ref->row, + mvs[i].as_mv.col - ref->col }; #if CONFIG_REF_MV int nmv_ctx = vp10_nmv_ctx(mbmi_ext->ref_mv_count[mbmi->ref_frame[i]], mbmi_ext->ref_mv_stack[mbmi->ref_frame[i]]); @@ -314,8 +308,8 @@ static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, } } else if (mode == NEAREST_NEWMV || mode == NEAR_NEWMV) { const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0].as_mv; - const MV diff = {mvs[1].as_mv.row - ref->row, - mvs[1].as_mv.col - ref->col}; + const MV diff = { mvs[1].as_mv.row - ref->row, + mvs[1].as_mv.col - ref->col }; #if CONFIG_REF_MV int nmv_ctx = vp10_nmv_ctx(mbmi_ext->ref_mv_count[mbmi->ref_frame[1]], mbmi_ext->ref_mv_stack[mbmi->ref_frame[1]]); @@ -324,8 +318,8 @@ static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, vp10_inc_mv(&diff, counts, vp10_use_mv_hp(ref)); } else if (mode == NEW_NEARESTMV || mode == NEW_NEARMV) { const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0].as_mv; - const MV diff = {mvs[0].as_mv.row - ref->row, - mvs[0].as_mv.col - ref->col}; + const MV diff = { mvs[0].as_mv.row - ref->row, + mvs[0].as_mv.col - ref->col }; #if CONFIG_REF_MV int nmv_ctx = vp10_nmv_ctx(mbmi_ext->ref_mv_count[mbmi->ref_frame[0]], mbmi_ext->ref_mv_stack[mbmi->ref_frame[0]]); @@ -335,9 +329,7 @@ static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, } } -static void inc_mvs_sub8x8(const MODE_INFO *mi, - int block, - const int_mv mvs[2], +static void inc_mvs_sub8x8(const MODE_INFO *mi, int block, const int_mv mvs[2], #if CONFIG_REF_MV const MB_MODE_INFO_EXT *mbmi_ext, #endif @@ -353,8 +345,8 @@ static void inc_mvs_sub8x8(const MODE_INFO *mi, if (mode == NEWMV || mode == NEWFROMNEARMV || mode == NEW_NEWMV) { for (i = 0; i < 1 + has_second_ref(&mi->mbmi); ++i) { const MV *ref = &mi->bmi[block].ref_mv[i].as_mv; - const MV diff = {mvs[i].as_mv.row - ref->row, - mvs[i].as_mv.col - ref->col}; + const MV diff = { mvs[i].as_mv.row - ref->row, + mvs[i].as_mv.col - ref->col }; #if CONFIG_REF_MV int nmv_ctx = vp10_nmv_ctx(mbmi_ext->ref_mv_count[mbmi->ref_frame[i]], mbmi_ext->ref_mv_stack[mbmi->ref_frame[i]]); @@ -364,8 +356,8 @@ static void inc_mvs_sub8x8(const MODE_INFO *mi, } } else if (mode == NEAREST_NEWMV || mode == NEAR_NEWMV) { const MV *ref = &mi->bmi[block].ref_mv[1].as_mv; - const MV diff = {mvs[1].as_mv.row - ref->row, - mvs[1].as_mv.col - ref->col}; + const MV diff = { mvs[1].as_mv.row - ref->row, + mvs[1].as_mv.col - ref->col }; #if CONFIG_REF_MV int nmv_ctx = vp10_nmv_ctx(mbmi_ext->ref_mv_count[mbmi->ref_frame[1]], mbmi_ext->ref_mv_stack[mbmi->ref_frame[1]]); @@ -374,8 +366,8 @@ static void inc_mvs_sub8x8(const MODE_INFO *mi, vp10_inc_mv(&diff, counts, vp10_use_mv_hp(ref)); } else if (mode == NEW_NEARESTMV || mode == NEW_NEARMV) { const MV *ref = &mi->bmi[block].ref_mv[0].as_mv; - const MV diff = {mvs[0].as_mv.row - ref->row, - mvs[0].as_mv.col - ref->col}; + const MV diff = { mvs[0].as_mv.row - ref->row, + mvs[0].as_mv.col - ref->col }; #if CONFIG_REF_MV int nmv_ctx = vp10_nmv_ctx(mbmi_ext->ref_mv_count[mbmi->ref_frame[0]], mbmi_ext->ref_mv_stack[mbmi->ref_frame[0]]); @@ -405,8 +397,8 @@ static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, #else const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[i]][0].as_mv; #endif - const MV diff = {mvs[i].as_mv.row - ref->row, - mvs[i].as_mv.col - ref->col}; + const MV diff = { mvs[i].as_mv.row - ref->row, + mvs[i].as_mv.col - ref->col }; vp10_inc_mv(&diff, counts, vp10_use_mv_hp(ref)); } } @@ -431,8 +423,7 @@ void vp10_update_mv_count(ThreadData *td) { if (have_newmv_in_inter_mode(mi->bmi[i].as_mode)) inc_mvs_sub8x8(mi, i, mi->bmi[i].as_mv, #if CONFIG_REF_MV - mbmi_ext, - td->counts->mv); + mbmi_ext, td->counts->mv); #else &td->counts->mv); #endif @@ -440,8 +431,7 @@ void vp10_update_mv_count(ThreadData *td) { if (mi->bmi[i].as_mode == NEWMV) inc_mvs(mbmi, mbmi_ext, mi->bmi[i].as_mv, #if CONFIG_REF_MV - mi->bmi[i].pred_mv_s8, - td->counts->mv); + mi->bmi[i].pred_mv_s8, td->counts->mv); #else &td->counts->mv); #endif @@ -456,11 +446,9 @@ void vp10_update_mv_count(ThreadData *td) { #endif // CONFIG_EXT_INTER inc_mvs(mbmi, mbmi_ext, mbmi->mv, #if CONFIG_REF_MV - mbmi->pred_mv, - td->counts->mv); + mbmi->pred_mv, td->counts->mv); #else &td->counts->mv); #endif } } - diff --git a/vp10/encoder/encodemv.h b/vp10/encoder/encodemv.h index 406fbec2e..0e2e59b96 100644 --- a/vp10/encoder/encodemv.h +++ b/vp10/encoder/encodemv.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_ENCODEMV_H_ #define VP10_ENCODER_ENCODEMV_H_ @@ -23,14 +22,14 @@ void vp10_entropy_mv_init(void); void vp10_write_nmv_probs(VP10_COMMON *cm, int usehp, vp10_writer *w, nmv_context_counts *const counts); -void vp10_encode_mv(VP10_COMP *cpi, vp10_writer* w, const MV* mv, const MV* ref, +void vp10_encode_mv(VP10_COMP *cpi, vp10_writer *w, const MV *mv, const MV *ref, #if CONFIG_REF_MV int is_compound, #endif - const nmv_context* mvctx, int usehp); + const nmv_context *mvctx, int usehp); void vp10_build_nmv_cost_table(int *mvjoint, int *mvcost[2], - const nmv_context* mvctx, int usehp); + const nmv_context *mvctx, int usehp); void vp10_update_mv_count(ThreadData *td); diff --git a/vp10/encoder/encoder.c b/vp10/encoder/encoder.c index 1767ad197..fb83cc9a8 100644 --- a/vp10/encoder/encoder.c +++ b/vp10/encoder/encoder.c @@ -64,14 +64,14 @@ #define AM_SEGMENT_ID_INACTIVE 7 #define AM_SEGMENT_ID_ACTIVE 0 -#define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */ +#define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */ -#define ALTREF_HIGH_PRECISION_MV 1 // Whether to use high precision mv - // for altref computation. -#define HIGH_PRECISION_MV_QTHRESH 200 // Q threshold for high precision - // mv. Choose a very high value for - // now so that HIGH_PRECISION is always - // chosen. +#define ALTREF_HIGH_PRECISION_MV 1 // Whether to use high precision mv + // for altref computation. +#define HIGH_PRECISION_MV_QTHRESH 200 // Q threshold for high precision + // mv. Choose a very high value for + // now so that HIGH_PRECISION is always + // chosen. // #define OUTPUT_YUV_REC #ifdef OUTPUT_YUV_DENOISED @@ -104,15 +104,15 @@ static INLINE void Scale2Ratio(VPX_SCALING mode, int *hr, int *hs) { case THREEFIVE: *hr = 3; *hs = 5; - break; + break; case ONETWO: *hr = 1; *hs = 2; - break; + break; default: *hr = 1; *hs = 1; - assert(0); + assert(0); break; } } @@ -150,8 +150,8 @@ static void apply_active_map(VP10_COMP *cpi) { vp10_enable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF); // Setting the data to -MAX_LOOP_FILTER will result in the computed loop // filter level being zero regardless of the value of seg->abs_delta. - vp10_set_segdata(seg, AM_SEGMENT_ID_INACTIVE, - SEG_LVL_ALT_LF, -MAX_LOOP_FILTER); + vp10_set_segdata(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF, + -MAX_LOOP_FILTER); } else { vp10_disable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_SKIP); vp10_disable_segfeature(seg, AM_SEGMENT_ID_INACTIVE, SEG_LVL_ALT_LF); @@ -164,10 +164,8 @@ static void apply_active_map(VP10_COMP *cpi) { } } -int vp10_set_active_map(VP10_COMP* cpi, - unsigned char* new_map_16x16, - int rows, - int cols) { +int vp10_set_active_map(VP10_COMP *cpi, unsigned char *new_map_16x16, int rows, + int cols) { if (rows == cpi->common.mb_rows && cols == cpi->common.mb_cols) { unsigned char *const active_map_8x8 = cpi->active_map.map; const int mi_rows = cpi->common.mi_rows; @@ -193,13 +191,11 @@ int vp10_set_active_map(VP10_COMP* cpi, } } -int vp10_get_active_map(VP10_COMP* cpi, - unsigned char* new_map_16x16, - int rows, - int cols) { +int vp10_get_active_map(VP10_COMP *cpi, unsigned char *new_map_16x16, int rows, + int cols) { if (rows == cpi->common.mb_rows && cols == cpi->common.mb_cols && new_map_16x16) { - unsigned char* const seg_map_8x8 = cpi->segmentation_map; + unsigned char *const seg_map_8x8 = cpi->segmentation_map; const int mi_rows = cpi->common.mi_rows; const int mi_cols = cpi->common.mi_cols; memset(new_map_16x16, !cpi->active_map.enabled, rows * cols); @@ -330,19 +326,16 @@ static void vp10_enc_setup_mi(VP10_COMMON *cm) { static int vp10_enc_alloc_mi(VP10_COMMON *cm, int mi_size) { cm->mip = vpx_calloc(mi_size, sizeof(*cm->mip)); - if (!cm->mip) - return 1; + if (!cm->mip) return 1; cm->prev_mip = vpx_calloc(mi_size, sizeof(*cm->prev_mip)); - if (!cm->prev_mip) - return 1; + if (!cm->prev_mip) return 1; cm->mi_alloc_size = mi_size; - cm->mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO*)); - if (!cm->mi_grid_base) - return 1; - cm->prev_mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO*)); - if (!cm->prev_mi_grid_base) - return 1; + cm->mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO *)); + if (!cm->mi_grid_base) return 1; + cm->prev_mi_grid_base = + (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO *)); + if (!cm->prev_mi_grid_base) return 1; return 0; } @@ -494,10 +487,10 @@ static void save_coding_context(VP10_COMP *cpi) { int i; #endif - // Stores a snapshot of key state variables which can subsequently be - // restored with a call to vp10_restore_coding_context. These functions are - // intended for use in a re-code loop in vp10_compress_frame where the - // quantizer value is adjusted between loop iterations. +// Stores a snapshot of key state variables which can subsequently be +// restored with a call to vp10_restore_coding_context. These functions are +// intended for use in a re-code loop in vp10_compress_frame where the +// quantizer value is adjusted between loop iterations. #if CONFIG_REF_MV for (i = 0; i < NMV_CONTEXTS; ++i) { vp10_copy(cc->nmv_vec_cost[i], cpi->td.mb.nmv_vec_cost[i]); @@ -511,7 +504,7 @@ static void save_coding_context(VP10_COMP *cpi) { MV_VALS * sizeof(*cpi->nmv_costs_hp[i][1])); } #else - vp10_copy(cc->nmvjointcost, cpi->td.mb.nmvjointcost); + vp10_copy(cc->nmvjointcost, cpi->td.mb.nmvjointcost); #endif memcpy(cc->nmvcosts[0], cpi->nmvcosts[0], @@ -523,8 +516,8 @@ static void save_coding_context(VP10_COMP *cpi) { memcpy(cc->nmvcosts_hp[1], cpi->nmvcosts_hp[1], MV_VALS * sizeof(*cpi->nmvcosts_hp[1])); - memcpy(cpi->coding_context.last_frame_seg_map_copy, - cm->last_frame_seg_map, (cm->mi_rows * cm->mi_cols)); + memcpy(cpi->coding_context.last_frame_seg_map_copy, cm->last_frame_seg_map, + (cm->mi_rows * cm->mi_cols)); vp10_copy(cc->last_ref_lf_deltas, cm->lf.last_ref_deltas); vp10_copy(cc->last_mode_lf_deltas, cm->lf.last_mode_deltas); @@ -539,8 +532,8 @@ static void restore_coding_context(VP10_COMP *cpi) { int i; #endif - // Restore key state variables to the snapshot state stored in the - // previous call to vp10_save_coding_context. +// Restore key state variables to the snapshot state stored in the +// previous call to vp10_save_coding_context. #if CONFIG_REF_MV for (i = 0; i < NMV_CONTEXTS; ++i) { vp10_copy(cpi->td.mb.nmv_vec_cost[i], cc->nmv_vec_cost[i]); @@ -564,8 +557,7 @@ static void restore_coding_context(VP10_COMP *cpi) { memcpy(cpi->nmvcosts_hp[1], cc->nmvcosts_hp[1], MV_VALS * sizeof(*cc->nmvcosts_hp[1])); - memcpy(cm->last_frame_seg_map, - cpi->coding_context.last_frame_seg_map_copy, + memcpy(cm->last_frame_seg_map, cpi->coding_context.last_frame_seg_map_copy, (cm->mi_rows * cm->mi_cols)); vp10_copy(cm->lf.last_ref_deltas, cc->last_ref_lf_deltas); @@ -617,8 +609,8 @@ static void configure_static_seg_features(VP10_COMP *cpi) { seg->update_map = 1; seg->update_data = 1; - qi_delta = vp10_compute_qdelta(rc, rc->avg_q, rc->avg_q * 0.875, - cm->bit_depth); + qi_delta = + vp10_compute_qdelta(rc, rc->avg_q, rc->avg_q * 0.875, cm->bit_depth); vp10_set_segdata(seg, 1, SEG_LVL_ALT_Q, qi_delta - 2); vp10_set_segdata(seg, 1, SEG_LVL_ALT_LF, -2); @@ -640,7 +632,7 @@ static void configure_static_seg_features(VP10_COMP *cpi) { seg->abs_delta = SEGMENT_DELTADATA; qi_delta = vp10_compute_qdelta(rc, rc->avg_q, rc->avg_q * 1.125, - cm->bit_depth); + cm->bit_depth); vp10_set_segdata(seg, 1, SEG_LVL_ALT_Q, qi_delta + 2); vp10_enable_segfeature(seg, 1, SEG_LVL_ALT_Q); @@ -720,18 +712,17 @@ static void alloc_raw_frame_buffers(VP10_COMP *cpi) { if (!cpi->lookahead) cpi->lookahead = vp10_lookahead_init(oxcf->width, oxcf->height, - cm->subsampling_x, cm->subsampling_y, + cm->subsampling_x, cm->subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH - cm->use_highbitdepth, + cm->use_highbitdepth, #endif - oxcf->lag_in_frames); + oxcf->lag_in_frames); if (!cpi->lookahead) vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, "Failed to allocate lag buffers"); // TODO(agrange) Check if ARF is enabled and skip allocation if not. - if (vpx_realloc_frame_buffer(&cpi->alt_ref_buffer, - oxcf->width, oxcf->height, + if (vpx_realloc_frame_buffer(&cpi->alt_ref_buffer, oxcf->width, oxcf->height, cm->subsampling_x, cm->subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH cm->use_highbitdepth, @@ -744,8 +735,7 @@ static void alloc_raw_frame_buffers(VP10_COMP *cpi) { static void alloc_util_frame_buffers(VP10_COMP *cpi) { VP10_COMMON *const cm = &cpi->common; - if (vpx_realloc_frame_buffer(&cpi->last_frame_uf, - cm->width, cm->height, + if (vpx_realloc_frame_buffer(&cpi->last_frame_uf, cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH cm->use_highbitdepth, @@ -756,8 +746,7 @@ static void alloc_util_frame_buffers(VP10_COMP *cpi) { "Failed to allocate last frame buffer"); #if CONFIG_LOOP_RESTORATION - if (vpx_realloc_frame_buffer(&cpi->last_frame_db, - cm->width, cm->height, + if (vpx_realloc_frame_buffer(&cpi->last_frame_db, cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH cm->use_highbitdepth, @@ -768,8 +757,7 @@ static void alloc_util_frame_buffers(VP10_COMP *cpi) { "Failed to allocate last frame deblocked buffer"); #endif // CONFIG_LOOP_RESTORATION - if (vpx_realloc_frame_buffer(&cpi->scaled_source, - cm->width, cm->height, + if (vpx_realloc_frame_buffer(&cpi->scaled_source, cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH cm->use_highbitdepth, @@ -779,8 +767,7 @@ static void alloc_util_frame_buffers(VP10_COMP *cpi) { vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, "Failed to allocate scaled source buffer"); - if (vpx_realloc_frame_buffer(&cpi->scaled_last_source, - cm->width, cm->height, + if (vpx_realloc_frame_buffer(&cpi->scaled_last_source, cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH cm->use_highbitdepth, @@ -791,14 +778,12 @@ static void alloc_util_frame_buffers(VP10_COMP *cpi) { "Failed to allocate scaled last source buffer"); } - static int alloc_context_buffers_ext(VP10_COMP *cpi) { VP10_COMMON *cm = &cpi->common; int mi_size = cm->mi_cols * cm->mi_rows; cpi->mbmi_ext_base = vpx_calloc(mi_size, sizeof(*cpi->mbmi_ext_base)); - if (!cpi->mbmi_ext_base) - return 1; + if (!cpi->mbmi_ext_base) return 1; return 0; } @@ -815,7 +800,7 @@ void vp10_alloc_compressor_data(VP10_COMP *cpi) { { unsigned int tokens = get_token_alloc(cm->mb_rows, cm->mb_cols); CHECK_MEM_ERROR(cm, cpi->tile_tok[0][0], - vpx_calloc(tokens, sizeof(*cpi->tile_tok[0][0]))); + vpx_calloc(tokens, sizeof(*cpi->tile_tok[0][0]))); #if CONFIG_ANS vp10_buf_ans_alloc(&cpi->buf_ans, cm, tokens); #endif // CONFIG_ANS @@ -835,24 +820,24 @@ static void set_tile_info(VP10_COMP *cpi) { #if CONFIG_EXT_TILE #if CONFIG_EXT_PARTITION if (cpi->oxcf.superblock_size != VPX_SUPERBLOCK_SIZE_64X64) { - cm->tile_width = clamp(cpi->oxcf.tile_columns, 1, 32); + cm->tile_width = clamp(cpi->oxcf.tile_columns, 1, 32); cm->tile_height = clamp(cpi->oxcf.tile_rows, 1, 32); - cm->tile_width <<= MAX_MIB_SIZE_LOG2; + cm->tile_width <<= MAX_MIB_SIZE_LOG2; cm->tile_height <<= MAX_MIB_SIZE_LOG2; } else { - cm->tile_width = clamp(cpi->oxcf.tile_columns, 1, 64); + cm->tile_width = clamp(cpi->oxcf.tile_columns, 1, 64); cm->tile_height = clamp(cpi->oxcf.tile_rows, 1, 64); - cm->tile_width <<= MAX_MIB_SIZE_LOG2 - 1; + cm->tile_width <<= MAX_MIB_SIZE_LOG2 - 1; cm->tile_height <<= MAX_MIB_SIZE_LOG2 - 1; } #else - cm->tile_width = clamp(cpi->oxcf.tile_columns, 1, 64); + cm->tile_width = clamp(cpi->oxcf.tile_columns, 1, 64); cm->tile_height = clamp(cpi->oxcf.tile_rows, 1, 64); - cm->tile_width <<= MAX_MIB_SIZE_LOG2; + cm->tile_width <<= MAX_MIB_SIZE_LOG2; cm->tile_height <<= MAX_MIB_SIZE_LOG2; #endif // CONFIG_EXT_PARTITION - cm->tile_width = VPXMIN(cm->tile_width, cm->mi_cols); + cm->tile_width = VPXMIN(cm->tile_width, cm->mi_cols); cm->tile_height = VPXMIN(cm->tile_height, cm->mi_rows); assert(cm->tile_width >> MAX_MIB_SIZE <= 32); @@ -860,18 +845,16 @@ static void set_tile_info(VP10_COMP *cpi) { // Get the number of tiles cm->tile_cols = 1; - while (cm->tile_cols * cm->tile_width < cm->mi_cols) - ++cm->tile_cols; + while (cm->tile_cols * cm->tile_width < cm->mi_cols) ++cm->tile_cols; cm->tile_rows = 1; - while (cm->tile_rows * cm->tile_height < cm->mi_rows) - ++cm->tile_rows; + while (cm->tile_rows * cm->tile_height < cm->mi_rows) ++cm->tile_rows; #else int min_log2_tile_cols, max_log2_tile_cols; vp10_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols); - cm->log2_tile_cols = clamp(cpi->oxcf.tile_columns, - min_log2_tile_cols, max_log2_tile_cols); + cm->log2_tile_cols = + clamp(cpi->oxcf.tile_columns, min_log2_tile_cols, max_log2_tile_cols); cm->log2_tile_rows = cpi->oxcf.tile_rows; cm->tile_cols = 1 << cm->log2_tile_cols; @@ -883,7 +866,7 @@ static void set_tile_info(VP10_COMP *cpi) { cm->tile_height >>= cm->log2_tile_rows; // round to integer multiples of max superblock size - cm->tile_width = ALIGN_POWER_OF_TWO(cm->tile_width, MAX_MIB_SIZE_LOG2); + cm->tile_width = ALIGN_POWER_OF_TWO(cm->tile_width, MAX_MIB_SIZE_LOG2); cm->tile_height = ALIGN_POWER_OF_TWO(cm->tile_height, MAX_MIB_SIZE_LOG2); #endif // CONFIG_EXT_TILE } @@ -954,153 +937,120 @@ static void set_rc_buffer_sizes(RATE_CONTROL *rc, const int64_t maximum = oxcf->maximum_buffer_size_ms; rc->starting_buffer_level = starting * bandwidth / 1000; - rc->optimal_buffer_level = (optimal == 0) ? bandwidth / 8 - : optimal * bandwidth / 1000; - rc->maximum_buffer_size = (maximum == 0) ? bandwidth / 8 - : maximum * bandwidth / 1000; + rc->optimal_buffer_level = + (optimal == 0) ? bandwidth / 8 : optimal * bandwidth / 1000; + rc->maximum_buffer_size = + (maximum == 0) ? bandwidth / 8 : maximum * bandwidth / 1000; } #if CONFIG_VP9_HIGHBITDEPTH #define HIGHBD_BFP(BT, SDF, SDAF, VF, SVF, SVAF, SDX3F, SDX8F, SDX4DF) \ - cpi->fn_ptr[BT].sdf = SDF; \ - cpi->fn_ptr[BT].sdaf = SDAF; \ - cpi->fn_ptr[BT].vf = VF; \ - cpi->fn_ptr[BT].svf = SVF; \ - cpi->fn_ptr[BT].svaf = SVAF; \ - cpi->fn_ptr[BT].sdx3f = SDX3F; \ - cpi->fn_ptr[BT].sdx8f = SDX8F; \ - cpi->fn_ptr[BT].sdx4df = SDX4DF; + cpi->fn_ptr[BT].sdf = SDF; \ + cpi->fn_ptr[BT].sdaf = SDAF; \ + cpi->fn_ptr[BT].vf = VF; \ + cpi->fn_ptr[BT].svf = SVF; \ + cpi->fn_ptr[BT].svaf = SVAF; \ + cpi->fn_ptr[BT].sdx3f = SDX3F; \ + cpi->fn_ptr[BT].sdx8f = SDX8F; \ + cpi->fn_ptr[BT].sdx4df = SDX4DF; -#define MAKE_BFP_SAD_WRAPPER(fnname) \ -static unsigned int fnname##_bits8(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride) { \ - return fnname(src_ptr, source_stride, ref_ptr, ref_stride); \ -} \ -static unsigned int fnname##_bits10(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride) { \ - return fnname(src_ptr, source_stride, ref_ptr, ref_stride) >> 2; \ -} \ -static unsigned int fnname##_bits12(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride) { \ - return fnname(src_ptr, source_stride, ref_ptr, ref_stride) >> 4; \ -} +#define MAKE_BFP_SAD_WRAPPER(fnname) \ + static unsigned int fnname##_bits8(const uint8_t *src_ptr, \ + int source_stride, \ + const uint8_t *ref_ptr, int ref_stride) { \ + return fnname(src_ptr, source_stride, ref_ptr, ref_stride); \ + } \ + static unsigned int fnname##_bits10( \ + const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \ + int ref_stride) { \ + return fnname(src_ptr, source_stride, ref_ptr, ref_stride) >> 2; \ + } \ + static unsigned int fnname##_bits12( \ + const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \ + int ref_stride) { \ + return fnname(src_ptr, source_stride, ref_ptr, ref_stride) >> 4; \ + } -#define MAKE_BFP_SADAVG_WRAPPER(fnname) static unsigned int \ -fnname##_bits8(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - const uint8_t *second_pred) { \ - return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred); \ -} \ -static unsigned int fnname##_bits10(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - const uint8_t *second_pred) { \ - return fnname(src_ptr, source_stride, ref_ptr, ref_stride, \ - second_pred) >> 2; \ -} \ -static unsigned int fnname##_bits12(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - const uint8_t *second_pred) { \ - return fnname(src_ptr, source_stride, ref_ptr, ref_stride, \ - second_pred) >> 4; \ -} +#define MAKE_BFP_SADAVG_WRAPPER(fnname) \ + static unsigned int fnname##_bits8( \ + const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \ + int ref_stride, const uint8_t *second_pred) { \ + return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred); \ + } \ + static unsigned int fnname##_bits10( \ + const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \ + int ref_stride, const uint8_t *second_pred) { \ + return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred) >> \ + 2; \ + } \ + static unsigned int fnname##_bits12( \ + const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \ + int ref_stride, const uint8_t *second_pred) { \ + return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred) >> \ + 4; \ + } -#define MAKE_BFP_SAD3_WRAPPER(fnname) \ -static void fnname##_bits8(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - unsigned int *sad_array) { \ - fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ -} \ -static void fnname##_bits10(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - unsigned int *sad_array) { \ - int i; \ - fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ - for (i = 0; i < 3; i++) \ - sad_array[i] >>= 2; \ -} \ -static void fnname##_bits12(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - unsigned int *sad_array) { \ - int i; \ - fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ - for (i = 0; i < 3; i++) \ - sad_array[i] >>= 4; \ -} +#define MAKE_BFP_SAD3_WRAPPER(fnname) \ + static void fnname##_bits8(const uint8_t *src_ptr, int source_stride, \ + const uint8_t *ref_ptr, int ref_stride, \ + unsigned int *sad_array) { \ + fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ + } \ + static void fnname##_bits10(const uint8_t *src_ptr, int source_stride, \ + const uint8_t *ref_ptr, int ref_stride, \ + unsigned int *sad_array) { \ + int i; \ + fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ + for (i = 0; i < 3; i++) sad_array[i] >>= 2; \ + } \ + static void fnname##_bits12(const uint8_t *src_ptr, int source_stride, \ + const uint8_t *ref_ptr, int ref_stride, \ + unsigned int *sad_array) { \ + int i; \ + fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ + for (i = 0; i < 3; i++) sad_array[i] >>= 4; \ + } -#define MAKE_BFP_SAD8_WRAPPER(fnname) \ -static void fnname##_bits8(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - unsigned int *sad_array) { \ - fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ -} \ -static void fnname##_bits10(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - unsigned int *sad_array) { \ - int i; \ - fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ - for (i = 0; i < 8; i++) \ - sad_array[i] >>= 2; \ -} \ -static void fnname##_bits12(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - unsigned int *sad_array) { \ - int i; \ - fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ - for (i = 0; i < 8; i++) \ - sad_array[i] >>= 4; \ -} -#define MAKE_BFP_SAD4D_WRAPPER(fnname) \ -static void fnname##_bits8(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t* const ref_ptr[], \ - int ref_stride, \ - unsigned int *sad_array) { \ - fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ -} \ -static void fnname##_bits10(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t* const ref_ptr[], \ - int ref_stride, \ - unsigned int *sad_array) { \ - int i; \ - fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ - for (i = 0; i < 4; i++) \ - sad_array[i] >>= 2; \ -} \ -static void fnname##_bits12(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t* const ref_ptr[], \ - int ref_stride, \ - unsigned int *sad_array) { \ - int i; \ - fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ - for (i = 0; i < 4; i++) \ - sad_array[i] >>= 4; \ -} +#define MAKE_BFP_SAD8_WRAPPER(fnname) \ + static void fnname##_bits8(const uint8_t *src_ptr, int source_stride, \ + const uint8_t *ref_ptr, int ref_stride, \ + unsigned int *sad_array) { \ + fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ + } \ + static void fnname##_bits10(const uint8_t *src_ptr, int source_stride, \ + const uint8_t *ref_ptr, int ref_stride, \ + unsigned int *sad_array) { \ + int i; \ + fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ + for (i = 0; i < 8; i++) sad_array[i] >>= 2; \ + } \ + static void fnname##_bits12(const uint8_t *src_ptr, int source_stride, \ + const uint8_t *ref_ptr, int ref_stride, \ + unsigned int *sad_array) { \ + int i; \ + fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ + for (i = 0; i < 8; i++) sad_array[i] >>= 4; \ + } +#define MAKE_BFP_SAD4D_WRAPPER(fnname) \ + static void fnname##_bits8(const uint8_t *src_ptr, int source_stride, \ + const uint8_t *const ref_ptr[], int ref_stride, \ + unsigned int *sad_array) { \ + fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ + } \ + static void fnname##_bits10(const uint8_t *src_ptr, int source_stride, \ + const uint8_t *const ref_ptr[], int ref_stride, \ + unsigned int *sad_array) { \ + int i; \ + fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ + for (i = 0; i < 4; i++) sad_array[i] >>= 2; \ + } \ + static void fnname##_bits12(const uint8_t *src_ptr, int source_stride, \ + const uint8_t *const ref_ptr[], int ref_stride, \ + unsigned int *sad_array) { \ + int i; \ + fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \ + for (i = 0; i < 4; i++) sad_array[i] >>= 4; \ + } #if CONFIG_EXT_PARTITION MAKE_BFP_SAD_WRAPPER(vpx_highbd_sad128x128) @@ -1172,39 +1122,29 @@ MAKE_BFP_SAD8_WRAPPER(vpx_highbd_sad4x4x8) MAKE_BFP_SAD4D_WRAPPER(vpx_highbd_sad4x4x4d) #if CONFIG_EXT_INTER -#define HIGHBD_MBFP(BT, MSDF, MVF, MSVF) \ - cpi->fn_ptr[BT].msdf = MSDF; \ - cpi->fn_ptr[BT].mvf = MVF; \ - cpi->fn_ptr[BT].msvf = MSVF; +#define HIGHBD_MBFP(BT, MSDF, MVF, MSVF) \ + cpi->fn_ptr[BT].msdf = MSDF; \ + cpi->fn_ptr[BT].mvf = MVF; \ + cpi->fn_ptr[BT].msvf = MSVF; -#define MAKE_MBFP_SAD_WRAPPER(fnname) \ -static unsigned int fnname##_bits8(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - const uint8_t *m, \ - int m_stride) { \ - return fnname(src_ptr, source_stride, ref_ptr, ref_stride, \ - m, m_stride); \ -} \ -static unsigned int fnname##_bits10(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - const uint8_t *m, \ - int m_stride) { \ - return fnname(src_ptr, source_stride, ref_ptr, ref_stride, \ - m, m_stride) >> 2; \ -} \ -static unsigned int fnname##_bits12(const uint8_t *src_ptr, \ - int source_stride, \ - const uint8_t *ref_ptr, \ - int ref_stride, \ - const uint8_t *m, \ - int m_stride) { \ - return fnname(src_ptr, source_stride, ref_ptr, ref_stride, \ - m, m_stride) >> 4; \ -} +#define MAKE_MBFP_SAD_WRAPPER(fnname) \ + static unsigned int fnname##_bits8( \ + const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \ + int ref_stride, const uint8_t *m, int m_stride) { \ + return fnname(src_ptr, source_stride, ref_ptr, ref_stride, m, m_stride); \ + } \ + static unsigned int fnname##_bits10( \ + const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \ + int ref_stride, const uint8_t *m, int m_stride) { \ + return fnname(src_ptr, source_stride, ref_ptr, ref_stride, m, m_stride) >> \ + 2; \ + } \ + static unsigned int fnname##_bits12( \ + const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \ + int ref_stride, const uint8_t *m, int m_stride) { \ + return fnname(src_ptr, source_stride, ref_ptr, ref_stride, m, m_stride) >> \ + 4; \ + } #if CONFIG_EXT_PARTITION MAKE_MBFP_SAD_WRAPPER(vpx_highbd_masked_sad128x128) @@ -1227,24 +1167,27 @@ MAKE_MBFP_SAD_WRAPPER(vpx_highbd_masked_sad4x4) #endif // CONFIG_EXT_INTER #if CONFIG_OBMC -#define HIGHBD_OBFP(BT, OSDF, OVF, OSVF) \ - cpi->fn_ptr[BT].osdf = OSDF; \ - cpi->fn_ptr[BT].ovf = OVF; \ - cpi->fn_ptr[BT].osvf = OSVF; +#define HIGHBD_OBFP(BT, OSDF, OVF, OSVF) \ + cpi->fn_ptr[BT].osdf = OSDF; \ + cpi->fn_ptr[BT].ovf = OVF; \ + cpi->fn_ptr[BT].osvf = OSVF; -#define MAKE_OBFP_SAD_WRAPPER(fnname) \ -static unsigned int fnname##_bits8(const uint8_t *ref, int ref_stride, \ - const int32_t *wsrc, const int32_t *msk) { \ - return fnname(ref, ref_stride, wsrc, msk); \ -} \ -static unsigned int fnname##_bits10(const uint8_t *ref, int ref_stride, \ - const int32_t *wsrc, const int32_t *msk) { \ - return fnname(ref, ref_stride, wsrc, msk) >> 2; \ -} \ -static unsigned int fnname##_bits12(const uint8_t *ref, int ref_stride, \ - const int32_t *wsrc, const int32_t *msk) { \ - return fnname(ref, ref_stride, wsrc, msk) >> 4; \ -} +#define MAKE_OBFP_SAD_WRAPPER(fnname) \ + static unsigned int fnname##_bits8(const uint8_t *ref, int ref_stride, \ + const int32_t *wsrc, \ + const int32_t *msk) { \ + return fnname(ref, ref_stride, wsrc, msk); \ + } \ + static unsigned int fnname##_bits10(const uint8_t *ref, int ref_stride, \ + const int32_t *wsrc, \ + const int32_t *msk) { \ + return fnname(ref, ref_stride, wsrc, msk) >> 2; \ + } \ + static unsigned int fnname##_bits12(const uint8_t *ref, int ref_stride, \ + const int32_t *wsrc, \ + const int32_t *msk) { \ + return fnname(ref, ref_stride, wsrc, msk) >> 4; \ + } #if CONFIG_EXT_PARTITION MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad128x128) @@ -1266,917 +1209,653 @@ MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad4x8) MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad4x4) #endif // CONFIG_OBMC -static void highbd_set_var_fns(VP10_COMP *const cpi) { +static void highbd_set_var_fns(VP10_COMP *const cpi) { VP10_COMMON *const cm = &cpi->common; if (cm->use_highbitdepth) { switch (cm->bit_depth) { case VPX_BITS_8: - HIGHBD_BFP(BLOCK_32X16, - vpx_highbd_sad32x16_bits8, - vpx_highbd_sad32x16_avg_bits8, - vpx_highbd_8_variance32x16, + HIGHBD_BFP(BLOCK_32X16, vpx_highbd_sad32x16_bits8, + vpx_highbd_sad32x16_avg_bits8, vpx_highbd_8_variance32x16, vpx_highbd_8_sub_pixel_variance32x16, - vpx_highbd_8_sub_pixel_avg_variance32x16, - NULL, - NULL, + vpx_highbd_8_sub_pixel_avg_variance32x16, NULL, NULL, vpx_highbd_sad32x16x4d_bits8) - HIGHBD_BFP(BLOCK_16X32, - vpx_highbd_sad16x32_bits8, - vpx_highbd_sad16x32_avg_bits8, - vpx_highbd_8_variance16x32, + HIGHBD_BFP(BLOCK_16X32, vpx_highbd_sad16x32_bits8, + vpx_highbd_sad16x32_avg_bits8, vpx_highbd_8_variance16x32, vpx_highbd_8_sub_pixel_variance16x32, - vpx_highbd_8_sub_pixel_avg_variance16x32, - NULL, - NULL, + vpx_highbd_8_sub_pixel_avg_variance16x32, NULL, NULL, vpx_highbd_sad16x32x4d_bits8) - HIGHBD_BFP(BLOCK_64X32, - vpx_highbd_sad64x32_bits8, - vpx_highbd_sad64x32_avg_bits8, - vpx_highbd_8_variance64x32, + HIGHBD_BFP(BLOCK_64X32, vpx_highbd_sad64x32_bits8, + vpx_highbd_sad64x32_avg_bits8, vpx_highbd_8_variance64x32, vpx_highbd_8_sub_pixel_variance64x32, - vpx_highbd_8_sub_pixel_avg_variance64x32, - NULL, - NULL, + vpx_highbd_8_sub_pixel_avg_variance64x32, NULL, NULL, vpx_highbd_sad64x32x4d_bits8) - HIGHBD_BFP(BLOCK_32X64, - vpx_highbd_sad32x64_bits8, - vpx_highbd_sad32x64_avg_bits8, - vpx_highbd_8_variance32x64, + HIGHBD_BFP(BLOCK_32X64, vpx_highbd_sad32x64_bits8, + vpx_highbd_sad32x64_avg_bits8, vpx_highbd_8_variance32x64, vpx_highbd_8_sub_pixel_variance32x64, - vpx_highbd_8_sub_pixel_avg_variance32x64, - NULL, - NULL, + vpx_highbd_8_sub_pixel_avg_variance32x64, NULL, NULL, vpx_highbd_sad32x64x4d_bits8) - HIGHBD_BFP(BLOCK_32X32, - vpx_highbd_sad32x32_bits8, - vpx_highbd_sad32x32_avg_bits8, - vpx_highbd_8_variance32x32, + HIGHBD_BFP(BLOCK_32X32, vpx_highbd_sad32x32_bits8, + vpx_highbd_sad32x32_avg_bits8, vpx_highbd_8_variance32x32, vpx_highbd_8_sub_pixel_variance32x32, vpx_highbd_8_sub_pixel_avg_variance32x32, - vpx_highbd_sad32x32x3_bits8, - vpx_highbd_sad32x32x8_bits8, + vpx_highbd_sad32x32x3_bits8, vpx_highbd_sad32x32x8_bits8, vpx_highbd_sad32x32x4d_bits8) - HIGHBD_BFP(BLOCK_64X64, - vpx_highbd_sad64x64_bits8, - vpx_highbd_sad64x64_avg_bits8, - vpx_highbd_8_variance64x64, + HIGHBD_BFP(BLOCK_64X64, vpx_highbd_sad64x64_bits8, + vpx_highbd_sad64x64_avg_bits8, vpx_highbd_8_variance64x64, vpx_highbd_8_sub_pixel_variance64x64, vpx_highbd_8_sub_pixel_avg_variance64x64, - vpx_highbd_sad64x64x3_bits8, - vpx_highbd_sad64x64x8_bits8, + vpx_highbd_sad64x64x3_bits8, vpx_highbd_sad64x64x8_bits8, vpx_highbd_sad64x64x4d_bits8) - HIGHBD_BFP(BLOCK_16X16, - vpx_highbd_sad16x16_bits8, - vpx_highbd_sad16x16_avg_bits8, - vpx_highbd_8_variance16x16, + HIGHBD_BFP(BLOCK_16X16, vpx_highbd_sad16x16_bits8, + vpx_highbd_sad16x16_avg_bits8, vpx_highbd_8_variance16x16, vpx_highbd_8_sub_pixel_variance16x16, vpx_highbd_8_sub_pixel_avg_variance16x16, - vpx_highbd_sad16x16x3_bits8, - vpx_highbd_sad16x16x8_bits8, + vpx_highbd_sad16x16x3_bits8, vpx_highbd_sad16x16x8_bits8, vpx_highbd_sad16x16x4d_bits8) - HIGHBD_BFP(BLOCK_16X8, - vpx_highbd_sad16x8_bits8, - vpx_highbd_sad16x8_avg_bits8, - vpx_highbd_8_variance16x8, - vpx_highbd_8_sub_pixel_variance16x8, - vpx_highbd_8_sub_pixel_avg_variance16x8, - vpx_highbd_sad16x8x3_bits8, - vpx_highbd_sad16x8x8_bits8, - vpx_highbd_sad16x8x4d_bits8) + HIGHBD_BFP( + BLOCK_16X8, vpx_highbd_sad16x8_bits8, vpx_highbd_sad16x8_avg_bits8, + vpx_highbd_8_variance16x8, vpx_highbd_8_sub_pixel_variance16x8, + vpx_highbd_8_sub_pixel_avg_variance16x8, vpx_highbd_sad16x8x3_bits8, + vpx_highbd_sad16x8x8_bits8, vpx_highbd_sad16x8x4d_bits8) - HIGHBD_BFP(BLOCK_8X16, - vpx_highbd_sad8x16_bits8, - vpx_highbd_sad8x16_avg_bits8, - vpx_highbd_8_variance8x16, - vpx_highbd_8_sub_pixel_variance8x16, - vpx_highbd_8_sub_pixel_avg_variance8x16, - vpx_highbd_sad8x16x3_bits8, - vpx_highbd_sad8x16x8_bits8, - vpx_highbd_sad8x16x4d_bits8) + HIGHBD_BFP( + BLOCK_8X16, vpx_highbd_sad8x16_bits8, vpx_highbd_sad8x16_avg_bits8, + vpx_highbd_8_variance8x16, vpx_highbd_8_sub_pixel_variance8x16, + vpx_highbd_8_sub_pixel_avg_variance8x16, vpx_highbd_sad8x16x3_bits8, + vpx_highbd_sad8x16x8_bits8, vpx_highbd_sad8x16x4d_bits8) - HIGHBD_BFP(BLOCK_8X8, - vpx_highbd_sad8x8_bits8, - vpx_highbd_sad8x8_avg_bits8, - vpx_highbd_8_variance8x8, - vpx_highbd_8_sub_pixel_variance8x8, - vpx_highbd_8_sub_pixel_avg_variance8x8, - vpx_highbd_sad8x8x3_bits8, - vpx_highbd_sad8x8x8_bits8, - vpx_highbd_sad8x8x4d_bits8) + HIGHBD_BFP( + BLOCK_8X8, vpx_highbd_sad8x8_bits8, vpx_highbd_sad8x8_avg_bits8, + vpx_highbd_8_variance8x8, vpx_highbd_8_sub_pixel_variance8x8, + vpx_highbd_8_sub_pixel_avg_variance8x8, vpx_highbd_sad8x8x3_bits8, + vpx_highbd_sad8x8x8_bits8, vpx_highbd_sad8x8x4d_bits8) - HIGHBD_BFP(BLOCK_8X4, - vpx_highbd_sad8x4_bits8, - vpx_highbd_sad8x4_avg_bits8, - vpx_highbd_8_variance8x4, + HIGHBD_BFP(BLOCK_8X4, vpx_highbd_sad8x4_bits8, + vpx_highbd_sad8x4_avg_bits8, vpx_highbd_8_variance8x4, vpx_highbd_8_sub_pixel_variance8x4, - vpx_highbd_8_sub_pixel_avg_variance8x4, - NULL, - vpx_highbd_sad8x4x8_bits8, - vpx_highbd_sad8x4x4d_bits8) + vpx_highbd_8_sub_pixel_avg_variance8x4, NULL, + vpx_highbd_sad8x4x8_bits8, vpx_highbd_sad8x4x4d_bits8) - HIGHBD_BFP(BLOCK_4X8, - vpx_highbd_sad4x8_bits8, - vpx_highbd_sad4x8_avg_bits8, - vpx_highbd_8_variance4x8, + HIGHBD_BFP(BLOCK_4X8, vpx_highbd_sad4x8_bits8, + vpx_highbd_sad4x8_avg_bits8, vpx_highbd_8_variance4x8, vpx_highbd_8_sub_pixel_variance4x8, - vpx_highbd_8_sub_pixel_avg_variance4x8, - NULL, - vpx_highbd_sad4x8x8_bits8, - vpx_highbd_sad4x8x4d_bits8) + vpx_highbd_8_sub_pixel_avg_variance4x8, NULL, + vpx_highbd_sad4x8x8_bits8, vpx_highbd_sad4x8x4d_bits8) - HIGHBD_BFP(BLOCK_4X4, - vpx_highbd_sad4x4_bits8, - vpx_highbd_sad4x4_avg_bits8, - vpx_highbd_8_variance4x4, - vpx_highbd_8_sub_pixel_variance4x4, - vpx_highbd_8_sub_pixel_avg_variance4x4, - vpx_highbd_sad4x4x3_bits8, - vpx_highbd_sad4x4x8_bits8, - vpx_highbd_sad4x4x4d_bits8) + HIGHBD_BFP( + BLOCK_4X4, vpx_highbd_sad4x4_bits8, vpx_highbd_sad4x4_avg_bits8, + vpx_highbd_8_variance4x4, vpx_highbd_8_sub_pixel_variance4x4, + vpx_highbd_8_sub_pixel_avg_variance4x4, vpx_highbd_sad4x4x3_bits8, + vpx_highbd_sad4x4x8_bits8, vpx_highbd_sad4x4x4d_bits8) #if CONFIG_EXT_PARTITION - HIGHBD_BFP(BLOCK_128X128, - vpx_highbd_sad128x128_bits8, + HIGHBD_BFP(BLOCK_128X128, vpx_highbd_sad128x128_bits8, vpx_highbd_sad128x128_avg_bits8, vpx_highbd_8_variance128x128, vpx_highbd_8_sub_pixel_variance128x128, vpx_highbd_8_sub_pixel_avg_variance128x128, - vpx_highbd_sad128x128x3_bits8, - vpx_highbd_sad128x128x8_bits8, + vpx_highbd_sad128x128x3_bits8, vpx_highbd_sad128x128x8_bits8, vpx_highbd_sad128x128x4d_bits8) - HIGHBD_BFP(BLOCK_128X64, - vpx_highbd_sad128x64_bits8, - vpx_highbd_sad128x64_avg_bits8, - vpx_highbd_8_variance128x64, + HIGHBD_BFP(BLOCK_128X64, vpx_highbd_sad128x64_bits8, + vpx_highbd_sad128x64_avg_bits8, vpx_highbd_8_variance128x64, vpx_highbd_8_sub_pixel_variance128x64, - vpx_highbd_8_sub_pixel_avg_variance128x64, - NULL, - NULL, + vpx_highbd_8_sub_pixel_avg_variance128x64, NULL, NULL, vpx_highbd_sad128x64x4d_bits8) - HIGHBD_BFP(BLOCK_64X128, - vpx_highbd_sad64x128_bits8, - vpx_highbd_sad64x128_avg_bits8, - vpx_highbd_8_variance64x128, + HIGHBD_BFP(BLOCK_64X128, vpx_highbd_sad64x128_bits8, + vpx_highbd_sad64x128_avg_bits8, vpx_highbd_8_variance64x128, vpx_highbd_8_sub_pixel_variance64x128, - vpx_highbd_8_sub_pixel_avg_variance64x128, - NULL, - NULL, + vpx_highbd_8_sub_pixel_avg_variance64x128, NULL, NULL, vpx_highbd_sad64x128x4d_bits8) #endif // CONFIG_EXT_PARTITION #if CONFIG_EXT_INTER #if CONFIG_EXT_PARTITION - HIGHBD_MBFP(BLOCK_128X128, - vpx_highbd_masked_sad128x128_bits8, + HIGHBD_MBFP(BLOCK_128X128, vpx_highbd_masked_sad128x128_bits8, vpx_highbd_masked_variance128x128, vpx_highbd_masked_sub_pixel_variance128x128) - HIGHBD_MBFP(BLOCK_128X64, - vpx_highbd_masked_sad128x64_bits8, + HIGHBD_MBFP(BLOCK_128X64, vpx_highbd_masked_sad128x64_bits8, vpx_highbd_masked_variance128x64, vpx_highbd_masked_sub_pixel_variance128x64) - HIGHBD_MBFP(BLOCK_64X128, - vpx_highbd_masked_sad64x128_bits8, + HIGHBD_MBFP(BLOCK_64X128, vpx_highbd_masked_sad64x128_bits8, vpx_highbd_masked_variance64x128, vpx_highbd_masked_sub_pixel_variance64x128) #endif // CONFIG_EXT_PARTITION - HIGHBD_MBFP(BLOCK_64X64, - vpx_highbd_masked_sad64x64_bits8, + HIGHBD_MBFP(BLOCK_64X64, vpx_highbd_masked_sad64x64_bits8, vpx_highbd_masked_variance64x64, vpx_highbd_masked_sub_pixel_variance64x64) - HIGHBD_MBFP(BLOCK_64X32, - vpx_highbd_masked_sad64x32_bits8, + HIGHBD_MBFP(BLOCK_64X32, vpx_highbd_masked_sad64x32_bits8, vpx_highbd_masked_variance64x32, vpx_highbd_masked_sub_pixel_variance64x32) - HIGHBD_MBFP(BLOCK_32X64, - vpx_highbd_masked_sad32x64_bits8, + HIGHBD_MBFP(BLOCK_32X64, vpx_highbd_masked_sad32x64_bits8, vpx_highbd_masked_variance32x64, vpx_highbd_masked_sub_pixel_variance32x64) - HIGHBD_MBFP(BLOCK_32X32, - vpx_highbd_masked_sad32x32_bits8, + HIGHBD_MBFP(BLOCK_32X32, vpx_highbd_masked_sad32x32_bits8, vpx_highbd_masked_variance32x32, vpx_highbd_masked_sub_pixel_variance32x32) - HIGHBD_MBFP(BLOCK_32X16, - vpx_highbd_masked_sad32x16_bits8, + HIGHBD_MBFP(BLOCK_32X16, vpx_highbd_masked_sad32x16_bits8, vpx_highbd_masked_variance32x16, vpx_highbd_masked_sub_pixel_variance32x16) - HIGHBD_MBFP(BLOCK_16X32, - vpx_highbd_masked_sad16x32_bits8, + HIGHBD_MBFP(BLOCK_16X32, vpx_highbd_masked_sad16x32_bits8, vpx_highbd_masked_variance16x32, vpx_highbd_masked_sub_pixel_variance16x32) - HIGHBD_MBFP(BLOCK_16X16, - vpx_highbd_masked_sad16x16_bits8, + HIGHBD_MBFP(BLOCK_16X16, vpx_highbd_masked_sad16x16_bits8, vpx_highbd_masked_variance16x16, vpx_highbd_masked_sub_pixel_variance16x16) - HIGHBD_MBFP(BLOCK_8X16, - vpx_highbd_masked_sad8x16_bits8, + HIGHBD_MBFP(BLOCK_8X16, vpx_highbd_masked_sad8x16_bits8, vpx_highbd_masked_variance8x16, vpx_highbd_masked_sub_pixel_variance8x16) - HIGHBD_MBFP(BLOCK_16X8, - vpx_highbd_masked_sad16x8_bits8, + HIGHBD_MBFP(BLOCK_16X8, vpx_highbd_masked_sad16x8_bits8, vpx_highbd_masked_variance16x8, vpx_highbd_masked_sub_pixel_variance16x8) - HIGHBD_MBFP(BLOCK_8X8, - vpx_highbd_masked_sad8x8_bits8, + HIGHBD_MBFP(BLOCK_8X8, vpx_highbd_masked_sad8x8_bits8, vpx_highbd_masked_variance8x8, vpx_highbd_masked_sub_pixel_variance8x8) - HIGHBD_MBFP(BLOCK_4X8, - vpx_highbd_masked_sad4x8_bits8, + HIGHBD_MBFP(BLOCK_4X8, vpx_highbd_masked_sad4x8_bits8, vpx_highbd_masked_variance4x8, vpx_highbd_masked_sub_pixel_variance4x8) - HIGHBD_MBFP(BLOCK_8X4, - vpx_highbd_masked_sad8x4_bits8, + HIGHBD_MBFP(BLOCK_8X4, vpx_highbd_masked_sad8x4_bits8, vpx_highbd_masked_variance8x4, vpx_highbd_masked_sub_pixel_variance8x4) - HIGHBD_MBFP(BLOCK_4X4, - vpx_highbd_masked_sad4x4_bits8, + HIGHBD_MBFP(BLOCK_4X4, vpx_highbd_masked_sad4x4_bits8, vpx_highbd_masked_variance4x4, vpx_highbd_masked_sub_pixel_variance4x4) #endif // CONFIG_EXT_INTER #if CONFIG_OBMC #if CONFIG_EXT_PARTITION - HIGHBD_OBFP(BLOCK_128X128, - vpx_highbd_obmc_sad128x128_bits8, + HIGHBD_OBFP(BLOCK_128X128, vpx_highbd_obmc_sad128x128_bits8, vpx_highbd_obmc_variance128x128, vpx_highbd_obmc_sub_pixel_variance128x128) - HIGHBD_OBFP(BLOCK_128X64, - vpx_highbd_obmc_sad128x64_bits8, + HIGHBD_OBFP(BLOCK_128X64, vpx_highbd_obmc_sad128x64_bits8, vpx_highbd_obmc_variance128x64, vpx_highbd_obmc_sub_pixel_variance128x64) - HIGHBD_OBFP(BLOCK_64X128, - vpx_highbd_obmc_sad64x128_bits8, + HIGHBD_OBFP(BLOCK_64X128, vpx_highbd_obmc_sad64x128_bits8, vpx_highbd_obmc_variance64x128, vpx_highbd_obmc_sub_pixel_variance64x128) #endif // CONFIG_EXT_PARTITION - HIGHBD_OBFP(BLOCK_64X64, - vpx_highbd_obmc_sad64x64_bits8, + HIGHBD_OBFP(BLOCK_64X64, vpx_highbd_obmc_sad64x64_bits8, vpx_highbd_obmc_variance64x64, vpx_highbd_obmc_sub_pixel_variance64x64) - HIGHBD_OBFP(BLOCK_64X32, - vpx_highbd_obmc_sad64x32_bits8, + HIGHBD_OBFP(BLOCK_64X32, vpx_highbd_obmc_sad64x32_bits8, vpx_highbd_obmc_variance64x32, vpx_highbd_obmc_sub_pixel_variance64x32) - HIGHBD_OBFP(BLOCK_32X64, - vpx_highbd_obmc_sad32x64_bits8, + HIGHBD_OBFP(BLOCK_32X64, vpx_highbd_obmc_sad32x64_bits8, vpx_highbd_obmc_variance32x64, vpx_highbd_obmc_sub_pixel_variance32x64) - HIGHBD_OBFP(BLOCK_32X32, - vpx_highbd_obmc_sad32x32_bits8, + HIGHBD_OBFP(BLOCK_32X32, vpx_highbd_obmc_sad32x32_bits8, vpx_highbd_obmc_variance32x32, vpx_highbd_obmc_sub_pixel_variance32x32) - HIGHBD_OBFP(BLOCK_32X16, - vpx_highbd_obmc_sad32x16_bits8, + HIGHBD_OBFP(BLOCK_32X16, vpx_highbd_obmc_sad32x16_bits8, vpx_highbd_obmc_variance32x16, vpx_highbd_obmc_sub_pixel_variance32x16) - HIGHBD_OBFP(BLOCK_16X32, - vpx_highbd_obmc_sad16x32_bits8, + HIGHBD_OBFP(BLOCK_16X32, vpx_highbd_obmc_sad16x32_bits8, vpx_highbd_obmc_variance16x32, vpx_highbd_obmc_sub_pixel_variance16x32) - HIGHBD_OBFP(BLOCK_16X16, - vpx_highbd_obmc_sad16x16_bits8, + HIGHBD_OBFP(BLOCK_16X16, vpx_highbd_obmc_sad16x16_bits8, vpx_highbd_obmc_variance16x16, vpx_highbd_obmc_sub_pixel_variance16x16) - HIGHBD_OBFP(BLOCK_8X16, - vpx_highbd_obmc_sad8x16_bits8, + HIGHBD_OBFP(BLOCK_8X16, vpx_highbd_obmc_sad8x16_bits8, vpx_highbd_obmc_variance8x16, vpx_highbd_obmc_sub_pixel_variance8x16) - HIGHBD_OBFP(BLOCK_16X8, - vpx_highbd_obmc_sad16x8_bits8, + HIGHBD_OBFP(BLOCK_16X8, vpx_highbd_obmc_sad16x8_bits8, vpx_highbd_obmc_variance16x8, vpx_highbd_obmc_sub_pixel_variance16x8) - HIGHBD_OBFP(BLOCK_8X8, - vpx_highbd_obmc_sad8x8_bits8, + HIGHBD_OBFP(BLOCK_8X8, vpx_highbd_obmc_sad8x8_bits8, vpx_highbd_obmc_variance8x8, vpx_highbd_obmc_sub_pixel_variance8x8) - HIGHBD_OBFP(BLOCK_4X8, - vpx_highbd_obmc_sad4x8_bits8, + HIGHBD_OBFP(BLOCK_4X8, vpx_highbd_obmc_sad4x8_bits8, vpx_highbd_obmc_variance4x8, vpx_highbd_obmc_sub_pixel_variance4x8) - HIGHBD_OBFP(BLOCK_8X4, - vpx_highbd_obmc_sad8x4_bits8, + HIGHBD_OBFP(BLOCK_8X4, vpx_highbd_obmc_sad8x4_bits8, vpx_highbd_obmc_variance8x4, vpx_highbd_obmc_sub_pixel_variance8x4) - HIGHBD_OBFP(BLOCK_4X4, - vpx_highbd_obmc_sad4x4_bits8, + HIGHBD_OBFP(BLOCK_4X4, vpx_highbd_obmc_sad4x4_bits8, vpx_highbd_obmc_variance4x4, vpx_highbd_obmc_sub_pixel_variance4x4) #endif // CONFIG_OBMC break; case VPX_BITS_10: - HIGHBD_BFP(BLOCK_32X16, - vpx_highbd_sad32x16_bits10, - vpx_highbd_sad32x16_avg_bits10, - vpx_highbd_10_variance32x16, + HIGHBD_BFP(BLOCK_32X16, vpx_highbd_sad32x16_bits10, + vpx_highbd_sad32x16_avg_bits10, vpx_highbd_10_variance32x16, vpx_highbd_10_sub_pixel_variance32x16, - vpx_highbd_10_sub_pixel_avg_variance32x16, - NULL, - NULL, + vpx_highbd_10_sub_pixel_avg_variance32x16, NULL, NULL, vpx_highbd_sad32x16x4d_bits10) - HIGHBD_BFP(BLOCK_16X32, - vpx_highbd_sad16x32_bits10, - vpx_highbd_sad16x32_avg_bits10, - vpx_highbd_10_variance16x32, + HIGHBD_BFP(BLOCK_16X32, vpx_highbd_sad16x32_bits10, + vpx_highbd_sad16x32_avg_bits10, vpx_highbd_10_variance16x32, vpx_highbd_10_sub_pixel_variance16x32, - vpx_highbd_10_sub_pixel_avg_variance16x32, - NULL, - NULL, + vpx_highbd_10_sub_pixel_avg_variance16x32, NULL, NULL, vpx_highbd_sad16x32x4d_bits10) - HIGHBD_BFP(BLOCK_64X32, - vpx_highbd_sad64x32_bits10, - vpx_highbd_sad64x32_avg_bits10, - vpx_highbd_10_variance64x32, + HIGHBD_BFP(BLOCK_64X32, vpx_highbd_sad64x32_bits10, + vpx_highbd_sad64x32_avg_bits10, vpx_highbd_10_variance64x32, vpx_highbd_10_sub_pixel_variance64x32, - vpx_highbd_10_sub_pixel_avg_variance64x32, - NULL, - NULL, + vpx_highbd_10_sub_pixel_avg_variance64x32, NULL, NULL, vpx_highbd_sad64x32x4d_bits10) - HIGHBD_BFP(BLOCK_32X64, - vpx_highbd_sad32x64_bits10, - vpx_highbd_sad32x64_avg_bits10, - vpx_highbd_10_variance32x64, + HIGHBD_BFP(BLOCK_32X64, vpx_highbd_sad32x64_bits10, + vpx_highbd_sad32x64_avg_bits10, vpx_highbd_10_variance32x64, vpx_highbd_10_sub_pixel_variance32x64, - vpx_highbd_10_sub_pixel_avg_variance32x64, - NULL, - NULL, + vpx_highbd_10_sub_pixel_avg_variance32x64, NULL, NULL, vpx_highbd_sad32x64x4d_bits10) - HIGHBD_BFP(BLOCK_32X32, - vpx_highbd_sad32x32_bits10, - vpx_highbd_sad32x32_avg_bits10, - vpx_highbd_10_variance32x32, + HIGHBD_BFP(BLOCK_32X32, vpx_highbd_sad32x32_bits10, + vpx_highbd_sad32x32_avg_bits10, vpx_highbd_10_variance32x32, vpx_highbd_10_sub_pixel_variance32x32, vpx_highbd_10_sub_pixel_avg_variance32x32, - vpx_highbd_sad32x32x3_bits10, - vpx_highbd_sad32x32x8_bits10, + vpx_highbd_sad32x32x3_bits10, vpx_highbd_sad32x32x8_bits10, vpx_highbd_sad32x32x4d_bits10) - HIGHBD_BFP(BLOCK_64X64, - vpx_highbd_sad64x64_bits10, - vpx_highbd_sad64x64_avg_bits10, - vpx_highbd_10_variance64x64, + HIGHBD_BFP(BLOCK_64X64, vpx_highbd_sad64x64_bits10, + vpx_highbd_sad64x64_avg_bits10, vpx_highbd_10_variance64x64, vpx_highbd_10_sub_pixel_variance64x64, vpx_highbd_10_sub_pixel_avg_variance64x64, - vpx_highbd_sad64x64x3_bits10, - vpx_highbd_sad64x64x8_bits10, + vpx_highbd_sad64x64x3_bits10, vpx_highbd_sad64x64x8_bits10, vpx_highbd_sad64x64x4d_bits10) - HIGHBD_BFP(BLOCK_16X16, - vpx_highbd_sad16x16_bits10, - vpx_highbd_sad16x16_avg_bits10, - vpx_highbd_10_variance16x16, + HIGHBD_BFP(BLOCK_16X16, vpx_highbd_sad16x16_bits10, + vpx_highbd_sad16x16_avg_bits10, vpx_highbd_10_variance16x16, vpx_highbd_10_sub_pixel_variance16x16, vpx_highbd_10_sub_pixel_avg_variance16x16, - vpx_highbd_sad16x16x3_bits10, - vpx_highbd_sad16x16x8_bits10, + vpx_highbd_sad16x16x3_bits10, vpx_highbd_sad16x16x8_bits10, vpx_highbd_sad16x16x4d_bits10) - HIGHBD_BFP(BLOCK_16X8, - vpx_highbd_sad16x8_bits10, - vpx_highbd_sad16x8_avg_bits10, - vpx_highbd_10_variance16x8, + HIGHBD_BFP(BLOCK_16X8, vpx_highbd_sad16x8_bits10, + vpx_highbd_sad16x8_avg_bits10, vpx_highbd_10_variance16x8, vpx_highbd_10_sub_pixel_variance16x8, vpx_highbd_10_sub_pixel_avg_variance16x8, - vpx_highbd_sad16x8x3_bits10, - vpx_highbd_sad16x8x8_bits10, + vpx_highbd_sad16x8x3_bits10, vpx_highbd_sad16x8x8_bits10, vpx_highbd_sad16x8x4d_bits10) - HIGHBD_BFP(BLOCK_8X16, - vpx_highbd_sad8x16_bits10, - vpx_highbd_sad8x16_avg_bits10, - vpx_highbd_10_variance8x16, + HIGHBD_BFP(BLOCK_8X16, vpx_highbd_sad8x16_bits10, + vpx_highbd_sad8x16_avg_bits10, vpx_highbd_10_variance8x16, vpx_highbd_10_sub_pixel_variance8x16, vpx_highbd_10_sub_pixel_avg_variance8x16, - vpx_highbd_sad8x16x3_bits10, - vpx_highbd_sad8x16x8_bits10, + vpx_highbd_sad8x16x3_bits10, vpx_highbd_sad8x16x8_bits10, vpx_highbd_sad8x16x4d_bits10) - HIGHBD_BFP(BLOCK_8X8, - vpx_highbd_sad8x8_bits10, - vpx_highbd_sad8x8_avg_bits10, - vpx_highbd_10_variance8x8, - vpx_highbd_10_sub_pixel_variance8x8, - vpx_highbd_10_sub_pixel_avg_variance8x8, - vpx_highbd_sad8x8x3_bits10, - vpx_highbd_sad8x8x8_bits10, - vpx_highbd_sad8x8x4d_bits10) + HIGHBD_BFP( + BLOCK_8X8, vpx_highbd_sad8x8_bits10, vpx_highbd_sad8x8_avg_bits10, + vpx_highbd_10_variance8x8, vpx_highbd_10_sub_pixel_variance8x8, + vpx_highbd_10_sub_pixel_avg_variance8x8, vpx_highbd_sad8x8x3_bits10, + vpx_highbd_sad8x8x8_bits10, vpx_highbd_sad8x8x4d_bits10) - HIGHBD_BFP(BLOCK_8X4, - vpx_highbd_sad8x4_bits10, - vpx_highbd_sad8x4_avg_bits10, - vpx_highbd_10_variance8x4, + HIGHBD_BFP(BLOCK_8X4, vpx_highbd_sad8x4_bits10, + vpx_highbd_sad8x4_avg_bits10, vpx_highbd_10_variance8x4, vpx_highbd_10_sub_pixel_variance8x4, - vpx_highbd_10_sub_pixel_avg_variance8x4, - NULL, - vpx_highbd_sad8x4x8_bits10, - vpx_highbd_sad8x4x4d_bits10) + vpx_highbd_10_sub_pixel_avg_variance8x4, NULL, + vpx_highbd_sad8x4x8_bits10, vpx_highbd_sad8x4x4d_bits10) - HIGHBD_BFP(BLOCK_4X8, - vpx_highbd_sad4x8_bits10, - vpx_highbd_sad4x8_avg_bits10, - vpx_highbd_10_variance4x8, + HIGHBD_BFP(BLOCK_4X8, vpx_highbd_sad4x8_bits10, + vpx_highbd_sad4x8_avg_bits10, vpx_highbd_10_variance4x8, vpx_highbd_10_sub_pixel_variance4x8, - vpx_highbd_10_sub_pixel_avg_variance4x8, - NULL, - vpx_highbd_sad4x8x8_bits10, - vpx_highbd_sad4x8x4d_bits10) + vpx_highbd_10_sub_pixel_avg_variance4x8, NULL, + vpx_highbd_sad4x8x8_bits10, vpx_highbd_sad4x8x4d_bits10) - HIGHBD_BFP(BLOCK_4X4, - vpx_highbd_sad4x4_bits10, - vpx_highbd_sad4x4_avg_bits10, - vpx_highbd_10_variance4x4, - vpx_highbd_10_sub_pixel_variance4x4, - vpx_highbd_10_sub_pixel_avg_variance4x4, - vpx_highbd_sad4x4x3_bits10, - vpx_highbd_sad4x4x8_bits10, - vpx_highbd_sad4x4x4d_bits10) + HIGHBD_BFP( + BLOCK_4X4, vpx_highbd_sad4x4_bits10, vpx_highbd_sad4x4_avg_bits10, + vpx_highbd_10_variance4x4, vpx_highbd_10_sub_pixel_variance4x4, + vpx_highbd_10_sub_pixel_avg_variance4x4, vpx_highbd_sad4x4x3_bits10, + vpx_highbd_sad4x4x8_bits10, vpx_highbd_sad4x4x4d_bits10) #if CONFIG_EXT_PARTITION - HIGHBD_BFP(BLOCK_128X128, - vpx_highbd_sad128x128_bits10, - vpx_highbd_sad128x128_avg_bits10, - vpx_highbd_10_variance128x128, - vpx_highbd_10_sub_pixel_variance128x128, - vpx_highbd_10_sub_pixel_avg_variance128x128, - vpx_highbd_sad128x128x3_bits10, - vpx_highbd_sad128x128x8_bits10, - vpx_highbd_sad128x128x4d_bits10) + HIGHBD_BFP( + BLOCK_128X128, vpx_highbd_sad128x128_bits10, + vpx_highbd_sad128x128_avg_bits10, vpx_highbd_10_variance128x128, + vpx_highbd_10_sub_pixel_variance128x128, + vpx_highbd_10_sub_pixel_avg_variance128x128, + vpx_highbd_sad128x128x3_bits10, vpx_highbd_sad128x128x8_bits10, + vpx_highbd_sad128x128x4d_bits10) - HIGHBD_BFP(BLOCK_128X64, - vpx_highbd_sad128x64_bits10, + HIGHBD_BFP(BLOCK_128X64, vpx_highbd_sad128x64_bits10, vpx_highbd_sad128x64_avg_bits10, vpx_highbd_10_variance128x64, vpx_highbd_10_sub_pixel_variance128x64, - vpx_highbd_10_sub_pixel_avg_variance128x64, - NULL, - NULL, + vpx_highbd_10_sub_pixel_avg_variance128x64, NULL, NULL, vpx_highbd_sad128x64x4d_bits10) - HIGHBD_BFP(BLOCK_64X128, - vpx_highbd_sad64x128_bits10, + HIGHBD_BFP(BLOCK_64X128, vpx_highbd_sad64x128_bits10, vpx_highbd_sad64x128_avg_bits10, vpx_highbd_10_variance64x128, vpx_highbd_10_sub_pixel_variance64x128, - vpx_highbd_10_sub_pixel_avg_variance64x128, - NULL, - NULL, + vpx_highbd_10_sub_pixel_avg_variance64x128, NULL, NULL, vpx_highbd_sad64x128x4d_bits10) #endif // CONFIG_EXT_PARTITION #if CONFIG_EXT_INTER #if CONFIG_EXT_PARTITION - HIGHBD_MBFP(BLOCK_128X128, - vpx_highbd_masked_sad128x128_bits10, + HIGHBD_MBFP(BLOCK_128X128, vpx_highbd_masked_sad128x128_bits10, vpx_highbd_10_masked_variance128x128, vpx_highbd_10_masked_sub_pixel_variance128x128) - HIGHBD_MBFP(BLOCK_128X64, - vpx_highbd_masked_sad128x64_bits10, + HIGHBD_MBFP(BLOCK_128X64, vpx_highbd_masked_sad128x64_bits10, vpx_highbd_10_masked_variance128x64, vpx_highbd_10_masked_sub_pixel_variance128x64) - HIGHBD_MBFP(BLOCK_64X128, - vpx_highbd_masked_sad64x128_bits10, + HIGHBD_MBFP(BLOCK_64X128, vpx_highbd_masked_sad64x128_bits10, vpx_highbd_10_masked_variance64x128, vpx_highbd_10_masked_sub_pixel_variance64x128) #endif // CONFIG_EXT_PARTITION - HIGHBD_MBFP(BLOCK_64X64, - vpx_highbd_masked_sad64x64_bits10, + HIGHBD_MBFP(BLOCK_64X64, vpx_highbd_masked_sad64x64_bits10, vpx_highbd_10_masked_variance64x64, vpx_highbd_10_masked_sub_pixel_variance64x64) - HIGHBD_MBFP(BLOCK_64X32, - vpx_highbd_masked_sad64x32_bits10, + HIGHBD_MBFP(BLOCK_64X32, vpx_highbd_masked_sad64x32_bits10, vpx_highbd_10_masked_variance64x32, vpx_highbd_10_masked_sub_pixel_variance64x32) - HIGHBD_MBFP(BLOCK_32X64, - vpx_highbd_masked_sad32x64_bits10, + HIGHBD_MBFP(BLOCK_32X64, vpx_highbd_masked_sad32x64_bits10, vpx_highbd_10_masked_variance32x64, vpx_highbd_10_masked_sub_pixel_variance32x64) - HIGHBD_MBFP(BLOCK_32X32, - vpx_highbd_masked_sad32x32_bits10, + HIGHBD_MBFP(BLOCK_32X32, vpx_highbd_masked_sad32x32_bits10, vpx_highbd_10_masked_variance32x32, vpx_highbd_10_masked_sub_pixel_variance32x32) - HIGHBD_MBFP(BLOCK_32X16, - vpx_highbd_masked_sad32x16_bits10, + HIGHBD_MBFP(BLOCK_32X16, vpx_highbd_masked_sad32x16_bits10, vpx_highbd_10_masked_variance32x16, vpx_highbd_10_masked_sub_pixel_variance32x16) - HIGHBD_MBFP(BLOCK_16X32, - vpx_highbd_masked_sad16x32_bits10, + HIGHBD_MBFP(BLOCK_16X32, vpx_highbd_masked_sad16x32_bits10, vpx_highbd_10_masked_variance16x32, vpx_highbd_10_masked_sub_pixel_variance16x32) - HIGHBD_MBFP(BLOCK_16X16, - vpx_highbd_masked_sad16x16_bits10, + HIGHBD_MBFP(BLOCK_16X16, vpx_highbd_masked_sad16x16_bits10, vpx_highbd_10_masked_variance16x16, vpx_highbd_10_masked_sub_pixel_variance16x16) - HIGHBD_MBFP(BLOCK_8X16, - vpx_highbd_masked_sad8x16_bits10, + HIGHBD_MBFP(BLOCK_8X16, vpx_highbd_masked_sad8x16_bits10, vpx_highbd_10_masked_variance8x16, vpx_highbd_10_masked_sub_pixel_variance8x16) - HIGHBD_MBFP(BLOCK_16X8, - vpx_highbd_masked_sad16x8_bits10, + HIGHBD_MBFP(BLOCK_16X8, vpx_highbd_masked_sad16x8_bits10, vpx_highbd_10_masked_variance16x8, vpx_highbd_10_masked_sub_pixel_variance16x8) - HIGHBD_MBFP(BLOCK_8X8, - vpx_highbd_masked_sad8x8_bits10, + HIGHBD_MBFP(BLOCK_8X8, vpx_highbd_masked_sad8x8_bits10, vpx_highbd_10_masked_variance8x8, vpx_highbd_10_masked_sub_pixel_variance8x8) - HIGHBD_MBFP(BLOCK_4X8, - vpx_highbd_masked_sad4x8_bits10, + HIGHBD_MBFP(BLOCK_4X8, vpx_highbd_masked_sad4x8_bits10, vpx_highbd_10_masked_variance4x8, vpx_highbd_10_masked_sub_pixel_variance4x8) - HIGHBD_MBFP(BLOCK_8X4, - vpx_highbd_masked_sad8x4_bits10, + HIGHBD_MBFP(BLOCK_8X4, vpx_highbd_masked_sad8x4_bits10, vpx_highbd_10_masked_variance8x4, vpx_highbd_10_masked_sub_pixel_variance8x4) - HIGHBD_MBFP(BLOCK_4X4, - vpx_highbd_masked_sad4x4_bits10, + HIGHBD_MBFP(BLOCK_4X4, vpx_highbd_masked_sad4x4_bits10, vpx_highbd_10_masked_variance4x4, vpx_highbd_10_masked_sub_pixel_variance4x4) #endif // CONFIG_EXT_INTER #if CONFIG_OBMC #if CONFIG_EXT_PARTITION - HIGHBD_OBFP(BLOCK_128X128, - vpx_highbd_obmc_sad128x128_bits10, + HIGHBD_OBFP(BLOCK_128X128, vpx_highbd_obmc_sad128x128_bits10, vpx_highbd_10_obmc_variance128x128, vpx_highbd_10_obmc_sub_pixel_variance128x128) - HIGHBD_OBFP(BLOCK_128X64, - vpx_highbd_obmc_sad128x64_bits10, + HIGHBD_OBFP(BLOCK_128X64, vpx_highbd_obmc_sad128x64_bits10, vpx_highbd_10_obmc_variance128x64, vpx_highbd_10_obmc_sub_pixel_variance128x64) - HIGHBD_OBFP(BLOCK_64X128, - vpx_highbd_obmc_sad64x128_bits10, + HIGHBD_OBFP(BLOCK_64X128, vpx_highbd_obmc_sad64x128_bits10, vpx_highbd_10_obmc_variance64x128, vpx_highbd_10_obmc_sub_pixel_variance64x128) #endif // CONFIG_EXT_PARTITION - HIGHBD_OBFP(BLOCK_64X64, - vpx_highbd_obmc_sad64x64_bits10, + HIGHBD_OBFP(BLOCK_64X64, vpx_highbd_obmc_sad64x64_bits10, vpx_highbd_10_obmc_variance64x64, vpx_highbd_10_obmc_sub_pixel_variance64x64) - HIGHBD_OBFP(BLOCK_64X32, - vpx_highbd_obmc_sad64x32_bits10, + HIGHBD_OBFP(BLOCK_64X32, vpx_highbd_obmc_sad64x32_bits10, vpx_highbd_10_obmc_variance64x32, vpx_highbd_10_obmc_sub_pixel_variance64x32) - HIGHBD_OBFP(BLOCK_32X64, - vpx_highbd_obmc_sad32x64_bits10, + HIGHBD_OBFP(BLOCK_32X64, vpx_highbd_obmc_sad32x64_bits10, vpx_highbd_10_obmc_variance32x64, vpx_highbd_10_obmc_sub_pixel_variance32x64) - HIGHBD_OBFP(BLOCK_32X32, - vpx_highbd_obmc_sad32x32_bits10, + HIGHBD_OBFP(BLOCK_32X32, vpx_highbd_obmc_sad32x32_bits10, vpx_highbd_10_obmc_variance32x32, vpx_highbd_10_obmc_sub_pixel_variance32x32) - HIGHBD_OBFP(BLOCK_32X16, - vpx_highbd_obmc_sad32x16_bits10, + HIGHBD_OBFP(BLOCK_32X16, vpx_highbd_obmc_sad32x16_bits10, vpx_highbd_10_obmc_variance32x16, vpx_highbd_10_obmc_sub_pixel_variance32x16) - HIGHBD_OBFP(BLOCK_16X32, - vpx_highbd_obmc_sad16x32_bits10, + HIGHBD_OBFP(BLOCK_16X32, vpx_highbd_obmc_sad16x32_bits10, vpx_highbd_10_obmc_variance16x32, vpx_highbd_10_obmc_sub_pixel_variance16x32) - HIGHBD_OBFP(BLOCK_16X16, - vpx_highbd_obmc_sad16x16_bits10, + HIGHBD_OBFP(BLOCK_16X16, vpx_highbd_obmc_sad16x16_bits10, vpx_highbd_10_obmc_variance16x16, vpx_highbd_10_obmc_sub_pixel_variance16x16) - HIGHBD_OBFP(BLOCK_8X16, - vpx_highbd_obmc_sad8x16_bits10, + HIGHBD_OBFP(BLOCK_8X16, vpx_highbd_obmc_sad8x16_bits10, vpx_highbd_10_obmc_variance8x16, vpx_highbd_10_obmc_sub_pixel_variance8x16) - HIGHBD_OBFP(BLOCK_16X8, - vpx_highbd_obmc_sad16x8_bits10, + HIGHBD_OBFP(BLOCK_16X8, vpx_highbd_obmc_sad16x8_bits10, vpx_highbd_10_obmc_variance16x8, vpx_highbd_10_obmc_sub_pixel_variance16x8) - HIGHBD_OBFP(BLOCK_8X8, - vpx_highbd_obmc_sad8x8_bits10, + HIGHBD_OBFP(BLOCK_8X8, vpx_highbd_obmc_sad8x8_bits10, vpx_highbd_10_obmc_variance8x8, vpx_highbd_10_obmc_sub_pixel_variance8x8) - HIGHBD_OBFP(BLOCK_4X8, - vpx_highbd_obmc_sad4x8_bits10, + HIGHBD_OBFP(BLOCK_4X8, vpx_highbd_obmc_sad4x8_bits10, vpx_highbd_10_obmc_variance4x8, vpx_highbd_10_obmc_sub_pixel_variance4x8) - HIGHBD_OBFP(BLOCK_8X4, - vpx_highbd_obmc_sad8x4_bits10, + HIGHBD_OBFP(BLOCK_8X4, vpx_highbd_obmc_sad8x4_bits10, vpx_highbd_10_obmc_variance8x4, vpx_highbd_10_obmc_sub_pixel_variance8x4) - HIGHBD_OBFP(BLOCK_4X4, - vpx_highbd_obmc_sad4x4_bits10, + HIGHBD_OBFP(BLOCK_4X4, vpx_highbd_obmc_sad4x4_bits10, vpx_highbd_10_obmc_variance4x4, vpx_highbd_10_obmc_sub_pixel_variance4x4) #endif // CONFIG_OBMC break; case VPX_BITS_12: - HIGHBD_BFP(BLOCK_32X16, - vpx_highbd_sad32x16_bits12, - vpx_highbd_sad32x16_avg_bits12, - vpx_highbd_12_variance32x16, + HIGHBD_BFP(BLOCK_32X16, vpx_highbd_sad32x16_bits12, + vpx_highbd_sad32x16_avg_bits12, vpx_highbd_12_variance32x16, vpx_highbd_12_sub_pixel_variance32x16, - vpx_highbd_12_sub_pixel_avg_variance32x16, - NULL, - NULL, + vpx_highbd_12_sub_pixel_avg_variance32x16, NULL, NULL, vpx_highbd_sad32x16x4d_bits12) - HIGHBD_BFP(BLOCK_16X32, - vpx_highbd_sad16x32_bits12, - vpx_highbd_sad16x32_avg_bits12, - vpx_highbd_12_variance16x32, + HIGHBD_BFP(BLOCK_16X32, vpx_highbd_sad16x32_bits12, + vpx_highbd_sad16x32_avg_bits12, vpx_highbd_12_variance16x32, vpx_highbd_12_sub_pixel_variance16x32, - vpx_highbd_12_sub_pixel_avg_variance16x32, - NULL, - NULL, + vpx_highbd_12_sub_pixel_avg_variance16x32, NULL, NULL, vpx_highbd_sad16x32x4d_bits12) - HIGHBD_BFP(BLOCK_64X32, - vpx_highbd_sad64x32_bits12, - vpx_highbd_sad64x32_avg_bits12, - vpx_highbd_12_variance64x32, + HIGHBD_BFP(BLOCK_64X32, vpx_highbd_sad64x32_bits12, + vpx_highbd_sad64x32_avg_bits12, vpx_highbd_12_variance64x32, vpx_highbd_12_sub_pixel_variance64x32, - vpx_highbd_12_sub_pixel_avg_variance64x32, - NULL, - NULL, + vpx_highbd_12_sub_pixel_avg_variance64x32, NULL, NULL, vpx_highbd_sad64x32x4d_bits12) - HIGHBD_BFP(BLOCK_32X64, - vpx_highbd_sad32x64_bits12, - vpx_highbd_sad32x64_avg_bits12, - vpx_highbd_12_variance32x64, + HIGHBD_BFP(BLOCK_32X64, vpx_highbd_sad32x64_bits12, + vpx_highbd_sad32x64_avg_bits12, vpx_highbd_12_variance32x64, vpx_highbd_12_sub_pixel_variance32x64, - vpx_highbd_12_sub_pixel_avg_variance32x64, - NULL, - NULL, + vpx_highbd_12_sub_pixel_avg_variance32x64, NULL, NULL, vpx_highbd_sad32x64x4d_bits12) - HIGHBD_BFP(BLOCK_32X32, - vpx_highbd_sad32x32_bits12, - vpx_highbd_sad32x32_avg_bits12, - vpx_highbd_12_variance32x32, + HIGHBD_BFP(BLOCK_32X32, vpx_highbd_sad32x32_bits12, + vpx_highbd_sad32x32_avg_bits12, vpx_highbd_12_variance32x32, vpx_highbd_12_sub_pixel_variance32x32, vpx_highbd_12_sub_pixel_avg_variance32x32, - vpx_highbd_sad32x32x3_bits12, - vpx_highbd_sad32x32x8_bits12, + vpx_highbd_sad32x32x3_bits12, vpx_highbd_sad32x32x8_bits12, vpx_highbd_sad32x32x4d_bits12) - HIGHBD_BFP(BLOCK_64X64, - vpx_highbd_sad64x64_bits12, - vpx_highbd_sad64x64_avg_bits12, - vpx_highbd_12_variance64x64, + HIGHBD_BFP(BLOCK_64X64, vpx_highbd_sad64x64_bits12, + vpx_highbd_sad64x64_avg_bits12, vpx_highbd_12_variance64x64, vpx_highbd_12_sub_pixel_variance64x64, vpx_highbd_12_sub_pixel_avg_variance64x64, - vpx_highbd_sad64x64x3_bits12, - vpx_highbd_sad64x64x8_bits12, + vpx_highbd_sad64x64x3_bits12, vpx_highbd_sad64x64x8_bits12, vpx_highbd_sad64x64x4d_bits12) - HIGHBD_BFP(BLOCK_16X16, - vpx_highbd_sad16x16_bits12, - vpx_highbd_sad16x16_avg_bits12, - vpx_highbd_12_variance16x16, + HIGHBD_BFP(BLOCK_16X16, vpx_highbd_sad16x16_bits12, + vpx_highbd_sad16x16_avg_bits12, vpx_highbd_12_variance16x16, vpx_highbd_12_sub_pixel_variance16x16, vpx_highbd_12_sub_pixel_avg_variance16x16, - vpx_highbd_sad16x16x3_bits12, - vpx_highbd_sad16x16x8_bits12, + vpx_highbd_sad16x16x3_bits12, vpx_highbd_sad16x16x8_bits12, vpx_highbd_sad16x16x4d_bits12) - HIGHBD_BFP(BLOCK_16X8, - vpx_highbd_sad16x8_bits12, - vpx_highbd_sad16x8_avg_bits12, - vpx_highbd_12_variance16x8, + HIGHBD_BFP(BLOCK_16X8, vpx_highbd_sad16x8_bits12, + vpx_highbd_sad16x8_avg_bits12, vpx_highbd_12_variance16x8, vpx_highbd_12_sub_pixel_variance16x8, vpx_highbd_12_sub_pixel_avg_variance16x8, - vpx_highbd_sad16x8x3_bits12, - vpx_highbd_sad16x8x8_bits12, + vpx_highbd_sad16x8x3_bits12, vpx_highbd_sad16x8x8_bits12, vpx_highbd_sad16x8x4d_bits12) - HIGHBD_BFP(BLOCK_8X16, - vpx_highbd_sad8x16_bits12, - vpx_highbd_sad8x16_avg_bits12, - vpx_highbd_12_variance8x16, + HIGHBD_BFP(BLOCK_8X16, vpx_highbd_sad8x16_bits12, + vpx_highbd_sad8x16_avg_bits12, vpx_highbd_12_variance8x16, vpx_highbd_12_sub_pixel_variance8x16, vpx_highbd_12_sub_pixel_avg_variance8x16, - vpx_highbd_sad8x16x3_bits12, - vpx_highbd_sad8x16x8_bits12, + vpx_highbd_sad8x16x3_bits12, vpx_highbd_sad8x16x8_bits12, vpx_highbd_sad8x16x4d_bits12) - HIGHBD_BFP(BLOCK_8X8, - vpx_highbd_sad8x8_bits12, - vpx_highbd_sad8x8_avg_bits12, - vpx_highbd_12_variance8x8, - vpx_highbd_12_sub_pixel_variance8x8, - vpx_highbd_12_sub_pixel_avg_variance8x8, - vpx_highbd_sad8x8x3_bits12, - vpx_highbd_sad8x8x8_bits12, - vpx_highbd_sad8x8x4d_bits12) + HIGHBD_BFP( + BLOCK_8X8, vpx_highbd_sad8x8_bits12, vpx_highbd_sad8x8_avg_bits12, + vpx_highbd_12_variance8x8, vpx_highbd_12_sub_pixel_variance8x8, + vpx_highbd_12_sub_pixel_avg_variance8x8, vpx_highbd_sad8x8x3_bits12, + vpx_highbd_sad8x8x8_bits12, vpx_highbd_sad8x8x4d_bits12) - HIGHBD_BFP(BLOCK_8X4, - vpx_highbd_sad8x4_bits12, - vpx_highbd_sad8x4_avg_bits12, - vpx_highbd_12_variance8x4, + HIGHBD_BFP(BLOCK_8X4, vpx_highbd_sad8x4_bits12, + vpx_highbd_sad8x4_avg_bits12, vpx_highbd_12_variance8x4, vpx_highbd_12_sub_pixel_variance8x4, - vpx_highbd_12_sub_pixel_avg_variance8x4, - NULL, - vpx_highbd_sad8x4x8_bits12, - vpx_highbd_sad8x4x4d_bits12) + vpx_highbd_12_sub_pixel_avg_variance8x4, NULL, + vpx_highbd_sad8x4x8_bits12, vpx_highbd_sad8x4x4d_bits12) - HIGHBD_BFP(BLOCK_4X8, - vpx_highbd_sad4x8_bits12, - vpx_highbd_sad4x8_avg_bits12, - vpx_highbd_12_variance4x8, + HIGHBD_BFP(BLOCK_4X8, vpx_highbd_sad4x8_bits12, + vpx_highbd_sad4x8_avg_bits12, vpx_highbd_12_variance4x8, vpx_highbd_12_sub_pixel_variance4x8, - vpx_highbd_12_sub_pixel_avg_variance4x8, - NULL, - vpx_highbd_sad4x8x8_bits12, - vpx_highbd_sad4x8x4d_bits12) + vpx_highbd_12_sub_pixel_avg_variance4x8, NULL, + vpx_highbd_sad4x8x8_bits12, vpx_highbd_sad4x8x4d_bits12) - HIGHBD_BFP(BLOCK_4X4, - vpx_highbd_sad4x4_bits12, - vpx_highbd_sad4x4_avg_bits12, - vpx_highbd_12_variance4x4, - vpx_highbd_12_sub_pixel_variance4x4, - vpx_highbd_12_sub_pixel_avg_variance4x4, - vpx_highbd_sad4x4x3_bits12, - vpx_highbd_sad4x4x8_bits12, - vpx_highbd_sad4x4x4d_bits12) + HIGHBD_BFP( + BLOCK_4X4, vpx_highbd_sad4x4_bits12, vpx_highbd_sad4x4_avg_bits12, + vpx_highbd_12_variance4x4, vpx_highbd_12_sub_pixel_variance4x4, + vpx_highbd_12_sub_pixel_avg_variance4x4, vpx_highbd_sad4x4x3_bits12, + vpx_highbd_sad4x4x8_bits12, vpx_highbd_sad4x4x4d_bits12) #if CONFIG_EXT_PARTITION - HIGHBD_BFP(BLOCK_128X128, - vpx_highbd_sad128x128_bits12, - vpx_highbd_sad128x128_avg_bits12, - vpx_highbd_12_variance128x128, - vpx_highbd_12_sub_pixel_variance128x128, - vpx_highbd_12_sub_pixel_avg_variance128x128, - vpx_highbd_sad128x128x3_bits12, - vpx_highbd_sad128x128x8_bits12, - vpx_highbd_sad128x128x4d_bits12) + HIGHBD_BFP( + BLOCK_128X128, vpx_highbd_sad128x128_bits12, + vpx_highbd_sad128x128_avg_bits12, vpx_highbd_12_variance128x128, + vpx_highbd_12_sub_pixel_variance128x128, + vpx_highbd_12_sub_pixel_avg_variance128x128, + vpx_highbd_sad128x128x3_bits12, vpx_highbd_sad128x128x8_bits12, + vpx_highbd_sad128x128x4d_bits12) - HIGHBD_BFP(BLOCK_128X64, - vpx_highbd_sad128x64_bits12, + HIGHBD_BFP(BLOCK_128X64, vpx_highbd_sad128x64_bits12, vpx_highbd_sad128x64_avg_bits12, vpx_highbd_12_variance128x64, vpx_highbd_12_sub_pixel_variance128x64, - vpx_highbd_12_sub_pixel_avg_variance128x64, - NULL, - NULL, + vpx_highbd_12_sub_pixel_avg_variance128x64, NULL, NULL, vpx_highbd_sad128x64x4d_bits12) - HIGHBD_BFP(BLOCK_64X128, - vpx_highbd_sad64x128_bits12, + HIGHBD_BFP(BLOCK_64X128, vpx_highbd_sad64x128_bits12, vpx_highbd_sad64x128_avg_bits12, vpx_highbd_12_variance64x128, vpx_highbd_12_sub_pixel_variance64x128, - vpx_highbd_12_sub_pixel_avg_variance64x128, - NULL, - NULL, + vpx_highbd_12_sub_pixel_avg_variance64x128, NULL, NULL, vpx_highbd_sad64x128x4d_bits12) #endif // CONFIG_EXT_PARTITION #if CONFIG_EXT_INTER #if CONFIG_EXT_PARTITION - HIGHBD_MBFP(BLOCK_128X128, - vpx_highbd_masked_sad128x128_bits12, + HIGHBD_MBFP(BLOCK_128X128, vpx_highbd_masked_sad128x128_bits12, vpx_highbd_12_masked_variance128x128, vpx_highbd_12_masked_sub_pixel_variance128x128) - HIGHBD_MBFP(BLOCK_128X64, - vpx_highbd_masked_sad128x64_bits12, + HIGHBD_MBFP(BLOCK_128X64, vpx_highbd_masked_sad128x64_bits12, vpx_highbd_12_masked_variance128x64, vpx_highbd_12_masked_sub_pixel_variance128x64) - HIGHBD_MBFP(BLOCK_64X128, - vpx_highbd_masked_sad64x128_bits12, + HIGHBD_MBFP(BLOCK_64X128, vpx_highbd_masked_sad64x128_bits12, vpx_highbd_12_masked_variance64x128, vpx_highbd_12_masked_sub_pixel_variance64x128) #endif // CONFIG_EXT_PARTITION - HIGHBD_MBFP(BLOCK_64X64, - vpx_highbd_masked_sad64x64_bits12, + HIGHBD_MBFP(BLOCK_64X64, vpx_highbd_masked_sad64x64_bits12, vpx_highbd_12_masked_variance64x64, vpx_highbd_12_masked_sub_pixel_variance64x64) - HIGHBD_MBFP(BLOCK_64X32, - vpx_highbd_masked_sad64x32_bits12, + HIGHBD_MBFP(BLOCK_64X32, vpx_highbd_masked_sad64x32_bits12, vpx_highbd_12_masked_variance64x32, vpx_highbd_12_masked_sub_pixel_variance64x32) - HIGHBD_MBFP(BLOCK_32X64, - vpx_highbd_masked_sad32x64_bits12, + HIGHBD_MBFP(BLOCK_32X64, vpx_highbd_masked_sad32x64_bits12, vpx_highbd_12_masked_variance32x64, vpx_highbd_12_masked_sub_pixel_variance32x64) - HIGHBD_MBFP(BLOCK_32X32, - vpx_highbd_masked_sad32x32_bits12, + HIGHBD_MBFP(BLOCK_32X32, vpx_highbd_masked_sad32x32_bits12, vpx_highbd_12_masked_variance32x32, vpx_highbd_12_masked_sub_pixel_variance32x32) - HIGHBD_MBFP(BLOCK_32X16, - vpx_highbd_masked_sad32x16_bits12, + HIGHBD_MBFP(BLOCK_32X16, vpx_highbd_masked_sad32x16_bits12, vpx_highbd_12_masked_variance32x16, vpx_highbd_12_masked_sub_pixel_variance32x16) - HIGHBD_MBFP(BLOCK_16X32, - vpx_highbd_masked_sad16x32_bits12, + HIGHBD_MBFP(BLOCK_16X32, vpx_highbd_masked_sad16x32_bits12, vpx_highbd_12_masked_variance16x32, vpx_highbd_12_masked_sub_pixel_variance16x32) - HIGHBD_MBFP(BLOCK_16X16, - vpx_highbd_masked_sad16x16_bits12, + HIGHBD_MBFP(BLOCK_16X16, vpx_highbd_masked_sad16x16_bits12, vpx_highbd_12_masked_variance16x16, vpx_highbd_12_masked_sub_pixel_variance16x16) - HIGHBD_MBFP(BLOCK_8X16, - vpx_highbd_masked_sad8x16_bits12, + HIGHBD_MBFP(BLOCK_8X16, vpx_highbd_masked_sad8x16_bits12, vpx_highbd_12_masked_variance8x16, vpx_highbd_12_masked_sub_pixel_variance8x16) - HIGHBD_MBFP(BLOCK_16X8, - vpx_highbd_masked_sad16x8_bits12, + HIGHBD_MBFP(BLOCK_16X8, vpx_highbd_masked_sad16x8_bits12, vpx_highbd_12_masked_variance16x8, vpx_highbd_12_masked_sub_pixel_variance16x8) - HIGHBD_MBFP(BLOCK_8X8, - vpx_highbd_masked_sad8x8_bits12, + HIGHBD_MBFP(BLOCK_8X8, vpx_highbd_masked_sad8x8_bits12, vpx_highbd_12_masked_variance8x8, vpx_highbd_12_masked_sub_pixel_variance8x8) - HIGHBD_MBFP(BLOCK_4X8, - vpx_highbd_masked_sad4x8_bits12, + HIGHBD_MBFP(BLOCK_4X8, vpx_highbd_masked_sad4x8_bits12, vpx_highbd_12_masked_variance4x8, vpx_highbd_12_masked_sub_pixel_variance4x8) - HIGHBD_MBFP(BLOCK_8X4, - vpx_highbd_masked_sad8x4_bits12, + HIGHBD_MBFP(BLOCK_8X4, vpx_highbd_masked_sad8x4_bits12, vpx_highbd_12_masked_variance8x4, vpx_highbd_12_masked_sub_pixel_variance8x4) - HIGHBD_MBFP(BLOCK_4X4, - vpx_highbd_masked_sad4x4_bits12, + HIGHBD_MBFP(BLOCK_4X4, vpx_highbd_masked_sad4x4_bits12, vpx_highbd_12_masked_variance4x4, vpx_highbd_12_masked_sub_pixel_variance4x4) #endif // CONFIG_EXT_INTER #if CONFIG_OBMC #if CONFIG_EXT_PARTITION - HIGHBD_OBFP(BLOCK_128X128, - vpx_highbd_obmc_sad128x128_bits12, + HIGHBD_OBFP(BLOCK_128X128, vpx_highbd_obmc_sad128x128_bits12, vpx_highbd_12_obmc_variance128x128, vpx_highbd_12_obmc_sub_pixel_variance128x128) - HIGHBD_OBFP(BLOCK_128X64, - vpx_highbd_obmc_sad128x64_bits12, + HIGHBD_OBFP(BLOCK_128X64, vpx_highbd_obmc_sad128x64_bits12, vpx_highbd_12_obmc_variance128x64, vpx_highbd_12_obmc_sub_pixel_variance128x64) - HIGHBD_OBFP(BLOCK_64X128, - vpx_highbd_obmc_sad64x128_bits12, + HIGHBD_OBFP(BLOCK_64X128, vpx_highbd_obmc_sad64x128_bits12, vpx_highbd_12_obmc_variance64x128, vpx_highbd_12_obmc_sub_pixel_variance64x128) #endif // CONFIG_EXT_PARTITION - HIGHBD_OBFP(BLOCK_64X64, - vpx_highbd_obmc_sad64x64_bits12, + HIGHBD_OBFP(BLOCK_64X64, vpx_highbd_obmc_sad64x64_bits12, vpx_highbd_12_obmc_variance64x64, vpx_highbd_12_obmc_sub_pixel_variance64x64) - HIGHBD_OBFP(BLOCK_64X32, - vpx_highbd_obmc_sad64x32_bits12, + HIGHBD_OBFP(BLOCK_64X32, vpx_highbd_obmc_sad64x32_bits12, vpx_highbd_12_obmc_variance64x32, vpx_highbd_12_obmc_sub_pixel_variance64x32) - HIGHBD_OBFP(BLOCK_32X64, - vpx_highbd_obmc_sad32x64_bits12, + HIGHBD_OBFP(BLOCK_32X64, vpx_highbd_obmc_sad32x64_bits12, vpx_highbd_12_obmc_variance32x64, vpx_highbd_12_obmc_sub_pixel_variance32x64) - HIGHBD_OBFP(BLOCK_32X32, - vpx_highbd_obmc_sad32x32_bits12, + HIGHBD_OBFP(BLOCK_32X32, vpx_highbd_obmc_sad32x32_bits12, vpx_highbd_12_obmc_variance32x32, vpx_highbd_12_obmc_sub_pixel_variance32x32) - HIGHBD_OBFP(BLOCK_32X16, - vpx_highbd_obmc_sad32x16_bits12, + HIGHBD_OBFP(BLOCK_32X16, vpx_highbd_obmc_sad32x16_bits12, vpx_highbd_12_obmc_variance32x16, vpx_highbd_12_obmc_sub_pixel_variance32x16) - HIGHBD_OBFP(BLOCK_16X32, - vpx_highbd_obmc_sad16x32_bits12, + HIGHBD_OBFP(BLOCK_16X32, vpx_highbd_obmc_sad16x32_bits12, vpx_highbd_12_obmc_variance16x32, vpx_highbd_12_obmc_sub_pixel_variance16x32) - HIGHBD_OBFP(BLOCK_16X16, - vpx_highbd_obmc_sad16x16_bits12, + HIGHBD_OBFP(BLOCK_16X16, vpx_highbd_obmc_sad16x16_bits12, vpx_highbd_12_obmc_variance16x16, vpx_highbd_12_obmc_sub_pixel_variance16x16) - HIGHBD_OBFP(BLOCK_8X16, - vpx_highbd_obmc_sad8x16_bits12, + HIGHBD_OBFP(BLOCK_8X16, vpx_highbd_obmc_sad8x16_bits12, vpx_highbd_12_obmc_variance8x16, vpx_highbd_12_obmc_sub_pixel_variance8x16) - HIGHBD_OBFP(BLOCK_16X8, - vpx_highbd_obmc_sad16x8_bits12, + HIGHBD_OBFP(BLOCK_16X8, vpx_highbd_obmc_sad16x8_bits12, vpx_highbd_12_obmc_variance16x8, vpx_highbd_12_obmc_sub_pixel_variance16x8) - HIGHBD_OBFP(BLOCK_8X8, - vpx_highbd_obmc_sad8x8_bits12, + HIGHBD_OBFP(BLOCK_8X8, vpx_highbd_obmc_sad8x8_bits12, vpx_highbd_12_obmc_variance8x8, vpx_highbd_12_obmc_sub_pixel_variance8x8) - HIGHBD_OBFP(BLOCK_4X8, - vpx_highbd_obmc_sad4x8_bits12, + HIGHBD_OBFP(BLOCK_4X8, vpx_highbd_obmc_sad4x8_bits12, vpx_highbd_12_obmc_variance4x8, vpx_highbd_12_obmc_sub_pixel_variance4x8) - HIGHBD_OBFP(BLOCK_8X4, - vpx_highbd_obmc_sad8x4_bits12, + HIGHBD_OBFP(BLOCK_8X4, vpx_highbd_obmc_sad8x4_bits12, vpx_highbd_12_obmc_variance8x4, vpx_highbd_12_obmc_sub_pixel_variance8x4) - HIGHBD_OBFP(BLOCK_4X4, - vpx_highbd_obmc_sad4x4_bits12, + HIGHBD_OBFP(BLOCK_4X4, vpx_highbd_obmc_sad4x4_bits12, vpx_highbd_12_obmc_variance4x4, vpx_highbd_12_obmc_sub_pixel_variance4x4) #endif // CONFIG_OBMC break; default: - assert(0 && "cm->bit_depth should be VPX_BITS_8, " - "VPX_BITS_10 or VPX_BITS_12"); + assert(0 && + "cm->bit_depth should be VPX_BITS_8, " + "VPX_BITS_10 or VPX_BITS_12"); } } } @@ -2191,8 +1870,7 @@ static void realloc_segmentation_maps(VP10_COMP *cpi) { vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); // Create a map used for cyclic background refresh. - if (cpi->cyclic_refresh) - vp10_cyclic_refresh_free(cpi->cyclic_refresh); + if (cpi->cyclic_refresh) vp10_cyclic_refresh_free(cpi->cyclic_refresh); CHECK_MEM_ERROR(cm, cpi->cyclic_refresh, vp10_cyclic_refresh_alloc(cm->mi_rows, cm->mi_cols)); @@ -2212,8 +1890,7 @@ void vp10_change_config(struct VP10_COMP *cpi, const VP10EncoderConfig *oxcf) { VP10_COMMON *const cm = &cpi->common; RATE_CONTROL *const rc = &cpi->rc; - if (cm->profile != oxcf->profile) - cm->profile = oxcf->profile; + if (cm->profile != oxcf->profile) cm->profile = oxcf->profile; cm->bit_depth = oxcf->bit_depth; cm->color_space = oxcf->color_space; cm->color_range = oxcf->color_range; @@ -2244,8 +1921,9 @@ void vp10_change_config(struct VP10_COMP *cpi, const VP10EncoderConfig *oxcf) { #endif // CONFIG_EXT_REFS cm->refresh_frame_context = - (oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode) ? - REFRESH_FRAME_CONTEXT_FORWARD : REFRESH_FRAME_CONTEXT_BACKWARD; + (oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode) + ? REFRESH_FRAME_CONTEXT_FORWARD + : REFRESH_FRAME_CONTEXT_BACKWARD; cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE; cm->allow_screen_content_tools = (cpi->oxcf.content == VPX_CONTENT_SCREEN); @@ -2336,7 +2014,7 @@ void vp10_change_config(struct VP10_COMP *cpi, const VP10EncoderConfig *oxcf) { #ifndef M_LOG2_E #define M_LOG2_E 0.693147180559945309417 #endif -#define log2f(x) (log (x) / (float) M_LOG2_E) +#define log2f(x) (log(x) / (float)M_LOG2_E) #if !CONFIG_REF_MV static void cal_nmvjointsadcost(int *mvjointsadcost) { @@ -2387,13 +2065,12 @@ static INLINE void init_upsampled_ref_frame_bufs(VP10_COMP *cpi) { } VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf, - BufferPool *const pool) { + BufferPool *const pool) { unsigned int i; VP10_COMP *volatile const cpi = vpx_memalign(32, sizeof(VP10_COMP)); VP10_COMMON *volatile const cm = cpi != NULL ? &cpi->common : NULL; - if (!cm) - return NULL; + if (!cm) return NULL; vp10_zero(*cpi); @@ -2408,11 +2085,10 @@ VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf, cm->free_mi = vp10_enc_free_mi; cm->setup_mi = vp10_enc_setup_mi; - CHECK_MEM_ERROR(cm, cm->fc, - (FRAME_CONTEXT *)vpx_calloc(1, sizeof(*cm->fc))); - CHECK_MEM_ERROR(cm, cm->frame_contexts, - (FRAME_CONTEXT *)vpx_calloc(FRAME_CONTEXTS, - sizeof(*cm->frame_contexts))); + CHECK_MEM_ERROR(cm, cm->fc, (FRAME_CONTEXT *)vpx_calloc(1, sizeof(*cm->fc))); + CHECK_MEM_ERROR( + cm, cm->frame_contexts, + (FRAME_CONTEXT *)vpx_calloc(FRAME_CONTEXTS, sizeof(*cm->frame_contexts))); cpi->resize_state = 0; cpi->resize_avg_qp = 0; @@ -2459,11 +2135,11 @@ VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf, CHECK_MEM_ERROR(cm, cpi->nmvsadcosts_hp[1], vpx_calloc(MV_VALS, sizeof(*cpi->nmvsadcosts_hp[1]))); - for (i = 0; i < (sizeof(cpi->mbgraph_stats) / - sizeof(cpi->mbgraph_stats[0])); i++) { - CHECK_MEM_ERROR(cm, cpi->mbgraph_stats[i].mb_stats, - vpx_calloc(cm->MBs * - sizeof(*cpi->mbgraph_stats[i].mb_stats), 1)); + for (i = 0; i < (sizeof(cpi->mbgraph_stats) / sizeof(cpi->mbgraph_stats[0])); + i++) { + CHECK_MEM_ERROR( + cm, cpi->mbgraph_stats[i].mb_stats, + vpx_calloc(cm->MBs * sizeof(*cpi->mbgraph_stats[i].mb_stats), 1)); } #if CONFIG_FP_MB_STATS @@ -2585,100 +2261,91 @@ VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf, vp10_set_speed_features_framesize_dependent(cpi); // Allocate memory to store variances for a frame. - CHECK_MEM_ERROR(cm, cpi->source_diff_var, - vpx_calloc(cm->MBs, sizeof(diff))); + CHECK_MEM_ERROR(cm, cpi->source_diff_var, vpx_calloc(cm->MBs, sizeof(diff))); cpi->source_var_thresh = 0; cpi->frames_till_next_var_check = 0; -#define BFP(BT, SDF, SDAF, VF, SVF, SVAF, SDX3F, SDX8F, SDX4DF)\ - cpi->fn_ptr[BT].sdf = SDF; \ - cpi->fn_ptr[BT].sdaf = SDAF; \ - cpi->fn_ptr[BT].vf = VF; \ - cpi->fn_ptr[BT].svf = SVF; \ - cpi->fn_ptr[BT].svaf = SVAF; \ - cpi->fn_ptr[BT].sdx3f = SDX3F; \ - cpi->fn_ptr[BT].sdx8f = SDX8F; \ - cpi->fn_ptr[BT].sdx4df = SDX4DF; +#define BFP(BT, SDF, SDAF, VF, SVF, SVAF, SDX3F, SDX8F, SDX4DF) \ + cpi->fn_ptr[BT].sdf = SDF; \ + cpi->fn_ptr[BT].sdaf = SDAF; \ + cpi->fn_ptr[BT].vf = VF; \ + cpi->fn_ptr[BT].svf = SVF; \ + cpi->fn_ptr[BT].svaf = SVAF; \ + cpi->fn_ptr[BT].sdx3f = SDX3F; \ + cpi->fn_ptr[BT].sdx8f = SDX8F; \ + cpi->fn_ptr[BT].sdx4df = SDX4DF; #if CONFIG_EXT_PARTITION - BFP(BLOCK_128X128, vpx_sad128x128, vpx_sad128x128_avg, - vpx_variance128x128, vpx_sub_pixel_variance128x128, - vpx_sub_pixel_avg_variance128x128, vpx_sad128x128x3, vpx_sad128x128x8, - vpx_sad128x128x4d) + BFP(BLOCK_128X128, vpx_sad128x128, vpx_sad128x128_avg, vpx_variance128x128, + vpx_sub_pixel_variance128x128, vpx_sub_pixel_avg_variance128x128, + vpx_sad128x128x3, vpx_sad128x128x8, vpx_sad128x128x4d) - BFP(BLOCK_128X64, vpx_sad128x64, vpx_sad128x64_avg, - vpx_variance128x64, vpx_sub_pixel_variance128x64, - vpx_sub_pixel_avg_variance128x64, NULL, NULL, vpx_sad128x64x4d) + BFP(BLOCK_128X64, vpx_sad128x64, vpx_sad128x64_avg, vpx_variance128x64, + vpx_sub_pixel_variance128x64, vpx_sub_pixel_avg_variance128x64, NULL, + NULL, vpx_sad128x64x4d) - BFP(BLOCK_64X128, vpx_sad64x128, vpx_sad64x128_avg, - vpx_variance64x128, vpx_sub_pixel_variance64x128, - vpx_sub_pixel_avg_variance64x128, NULL, NULL, vpx_sad64x128x4d) + BFP(BLOCK_64X128, vpx_sad64x128, vpx_sad64x128_avg, vpx_variance64x128, + vpx_sub_pixel_variance64x128, vpx_sub_pixel_avg_variance64x128, NULL, + NULL, vpx_sad64x128x4d) #endif // CONFIG_EXT_PARTITION - BFP(BLOCK_32X16, vpx_sad32x16, vpx_sad32x16_avg, - vpx_variance32x16, vpx_sub_pixel_variance32x16, - vpx_sub_pixel_avg_variance32x16, NULL, NULL, vpx_sad32x16x4d) + BFP(BLOCK_32X16, vpx_sad32x16, vpx_sad32x16_avg, vpx_variance32x16, + vpx_sub_pixel_variance32x16, vpx_sub_pixel_avg_variance32x16, NULL, NULL, + vpx_sad32x16x4d) - BFP(BLOCK_16X32, vpx_sad16x32, vpx_sad16x32_avg, - vpx_variance16x32, vpx_sub_pixel_variance16x32, - vpx_sub_pixel_avg_variance16x32, NULL, NULL, vpx_sad16x32x4d) + BFP(BLOCK_16X32, vpx_sad16x32, vpx_sad16x32_avg, vpx_variance16x32, + vpx_sub_pixel_variance16x32, vpx_sub_pixel_avg_variance16x32, NULL, NULL, + vpx_sad16x32x4d) - BFP(BLOCK_64X32, vpx_sad64x32, vpx_sad64x32_avg, - vpx_variance64x32, vpx_sub_pixel_variance64x32, - vpx_sub_pixel_avg_variance64x32, NULL, NULL, vpx_sad64x32x4d) + BFP(BLOCK_64X32, vpx_sad64x32, vpx_sad64x32_avg, vpx_variance64x32, + vpx_sub_pixel_variance64x32, vpx_sub_pixel_avg_variance64x32, NULL, NULL, + vpx_sad64x32x4d) - BFP(BLOCK_32X64, vpx_sad32x64, vpx_sad32x64_avg, - vpx_variance32x64, vpx_sub_pixel_variance32x64, - vpx_sub_pixel_avg_variance32x64, NULL, NULL, vpx_sad32x64x4d) + BFP(BLOCK_32X64, vpx_sad32x64, vpx_sad32x64_avg, vpx_variance32x64, + vpx_sub_pixel_variance32x64, vpx_sub_pixel_avg_variance32x64, NULL, NULL, + vpx_sad32x64x4d) - BFP(BLOCK_32X32, vpx_sad32x32, vpx_sad32x32_avg, - vpx_variance32x32, vpx_sub_pixel_variance32x32, - vpx_sub_pixel_avg_variance32x32, vpx_sad32x32x3, vpx_sad32x32x8, - vpx_sad32x32x4d) + BFP(BLOCK_32X32, vpx_sad32x32, vpx_sad32x32_avg, vpx_variance32x32, + vpx_sub_pixel_variance32x32, vpx_sub_pixel_avg_variance32x32, + vpx_sad32x32x3, vpx_sad32x32x8, vpx_sad32x32x4d) - BFP(BLOCK_64X64, vpx_sad64x64, vpx_sad64x64_avg, - vpx_variance64x64, vpx_sub_pixel_variance64x64, - vpx_sub_pixel_avg_variance64x64, vpx_sad64x64x3, vpx_sad64x64x8, - vpx_sad64x64x4d) + BFP(BLOCK_64X64, vpx_sad64x64, vpx_sad64x64_avg, vpx_variance64x64, + vpx_sub_pixel_variance64x64, vpx_sub_pixel_avg_variance64x64, + vpx_sad64x64x3, vpx_sad64x64x8, vpx_sad64x64x4d) - BFP(BLOCK_16X16, vpx_sad16x16, vpx_sad16x16_avg, - vpx_variance16x16, vpx_sub_pixel_variance16x16, - vpx_sub_pixel_avg_variance16x16, vpx_sad16x16x3, vpx_sad16x16x8, - vpx_sad16x16x4d) + BFP(BLOCK_16X16, vpx_sad16x16, vpx_sad16x16_avg, vpx_variance16x16, + vpx_sub_pixel_variance16x16, vpx_sub_pixel_avg_variance16x16, + vpx_sad16x16x3, vpx_sad16x16x8, vpx_sad16x16x4d) - BFP(BLOCK_16X8, vpx_sad16x8, vpx_sad16x8_avg, - vpx_variance16x8, vpx_sub_pixel_variance16x8, - vpx_sub_pixel_avg_variance16x8, - vpx_sad16x8x3, vpx_sad16x8x8, vpx_sad16x8x4d) + BFP(BLOCK_16X8, vpx_sad16x8, vpx_sad16x8_avg, vpx_variance16x8, + vpx_sub_pixel_variance16x8, vpx_sub_pixel_avg_variance16x8, vpx_sad16x8x3, + vpx_sad16x8x8, vpx_sad16x8x4d) - BFP(BLOCK_8X16, vpx_sad8x16, vpx_sad8x16_avg, - vpx_variance8x16, vpx_sub_pixel_variance8x16, - vpx_sub_pixel_avg_variance8x16, - vpx_sad8x16x3, vpx_sad8x16x8, vpx_sad8x16x4d) + BFP(BLOCK_8X16, vpx_sad8x16, vpx_sad8x16_avg, vpx_variance8x16, + vpx_sub_pixel_variance8x16, vpx_sub_pixel_avg_variance8x16, vpx_sad8x16x3, + vpx_sad8x16x8, vpx_sad8x16x4d) - BFP(BLOCK_8X8, vpx_sad8x8, vpx_sad8x8_avg, - vpx_variance8x8, vpx_sub_pixel_variance8x8, - vpx_sub_pixel_avg_variance8x8, - vpx_sad8x8x3, vpx_sad8x8x8, vpx_sad8x8x4d) + BFP(BLOCK_8X8, vpx_sad8x8, vpx_sad8x8_avg, vpx_variance8x8, + vpx_sub_pixel_variance8x8, vpx_sub_pixel_avg_variance8x8, vpx_sad8x8x3, + vpx_sad8x8x8, vpx_sad8x8x4d) - BFP(BLOCK_8X4, vpx_sad8x4, vpx_sad8x4_avg, - vpx_variance8x4, vpx_sub_pixel_variance8x4, - vpx_sub_pixel_avg_variance8x4, NULL, vpx_sad8x4x8, vpx_sad8x4x4d) + BFP(BLOCK_8X4, vpx_sad8x4, vpx_sad8x4_avg, vpx_variance8x4, + vpx_sub_pixel_variance8x4, vpx_sub_pixel_avg_variance8x4, NULL, + vpx_sad8x4x8, vpx_sad8x4x4d) - BFP(BLOCK_4X8, vpx_sad4x8, vpx_sad4x8_avg, - vpx_variance4x8, vpx_sub_pixel_variance4x8, - vpx_sub_pixel_avg_variance4x8, NULL, vpx_sad4x8x8, vpx_sad4x8x4d) + BFP(BLOCK_4X8, vpx_sad4x8, vpx_sad4x8_avg, vpx_variance4x8, + vpx_sub_pixel_variance4x8, vpx_sub_pixel_avg_variance4x8, NULL, + vpx_sad4x8x8, vpx_sad4x8x4d) - BFP(BLOCK_4X4, vpx_sad4x4, vpx_sad4x4_avg, - vpx_variance4x4, vpx_sub_pixel_variance4x4, - vpx_sub_pixel_avg_variance4x4, - vpx_sad4x4x3, vpx_sad4x4x8, vpx_sad4x4x4d) + BFP(BLOCK_4X4, vpx_sad4x4, vpx_sad4x4_avg, vpx_variance4x4, + vpx_sub_pixel_variance4x4, vpx_sub_pixel_avg_variance4x4, vpx_sad4x4x3, + vpx_sad4x4x8, vpx_sad4x4x4d) #if CONFIG_OBMC -#define OBFP(BT, OSDF, OVF, OSVF) \ - cpi->fn_ptr[BT].osdf = OSDF; \ - cpi->fn_ptr[BT].ovf = OVF; \ - cpi->fn_ptr[BT].osvf = OSVF; +#define OBFP(BT, OSDF, OVF, OSVF) \ + cpi->fn_ptr[BT].osdf = OSDF; \ + cpi->fn_ptr[BT].ovf = OVF; \ + cpi->fn_ptr[BT].osvf = OSVF; #if CONFIG_EXT_PARTITION OBFP(BLOCK_128X128, vpx_obmc_sad128x128, vpx_obmc_variance128x128, @@ -2717,10 +2384,10 @@ VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf, #endif // CONFIG_OBMC #if CONFIG_EXT_INTER -#define MBFP(BT, MSDF, MVF, MSVF) \ - cpi->fn_ptr[BT].msdf = MSDF; \ - cpi->fn_ptr[BT].mvf = MVF; \ - cpi->fn_ptr[BT].msvf = MSVF; +#define MBFP(BT, MSDF, MVF, MSVF) \ + cpi->fn_ptr[BT].msdf = MSDF; \ + cpi->fn_ptr[BT].mvf = MVF; \ + cpi->fn_ptr[BT].msvf = MSVF; #if CONFIG_EXT_PARTITION MBFP(BLOCK_128X128, vpx_masked_sad128x128, vpx_masked_variance128x128, @@ -2779,8 +2446,7 @@ VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf, return cpi; } -#define SNPRINT(H, T) \ - snprintf((H) + strlen(H), sizeof(H) - strlen(H), (T)) +#define SNPRINT(H, T) snprintf((H) + strlen(H), sizeof(H) - strlen(H), (T)) #define SNPRINT2(H, T, V) \ snprintf((H) + strlen(H), sizeof(H) - strlen(H), (T), (V)) @@ -2790,8 +2456,7 @@ void vp10_remove_compressor(VP10_COMP *cpi) { unsigned int i; int t; - if (!cpi) - return; + if (!cpi) return; cm = &cpi->common; if (cm->current_video_frame > 0) { @@ -2799,25 +2464,25 @@ void vp10_remove_compressor(VP10_COMP *cpi) { vpx_clear_system_state(); if (cpi->oxcf.pass != 1) { - char headings[512] = {0}; - char results[512] = {0}; + char headings[512] = { 0 }; + char results[512] = { 0 }; FILE *f = fopen("opsnr.stt", "a"); - double time_encoded = (cpi->last_end_time_stamp_seen - - cpi->first_time_stamp_ever) / 10000000.000; - double total_encode_time = (cpi->time_receive_data + - cpi->time_compress_data) / 1000.000; + double time_encoded = + (cpi->last_end_time_stamp_seen - cpi->first_time_stamp_ever) / + 10000000.000; + double total_encode_time = + (cpi->time_receive_data + cpi->time_compress_data) / 1000.000; const double dr = - (double)cpi->bytes * (double) 8 / (double)1000 / time_encoded; + (double)cpi->bytes * (double)8 / (double)1000 / time_encoded; const double peak = (double)((1 << cpi->oxcf.input_bit_depth) - 1); const double target_rate = (double)cpi->oxcf.target_bandwidth / 1000; const double rate_err = ((100.0 * (dr - target_rate)) / target_rate); if (cpi->b_calculate_psnr) { - const double total_psnr = - vpx_sse_to_psnr((double)cpi->total_samples, peak, - (double)cpi->total_sq_error); - const double total_ssim = 100 * pow(cpi->summed_quality / - cpi->summed_weights, 8.0); + const double total_psnr = vpx_sse_to_psnr( + (double)cpi->total_samples, peak, (double)cpi->total_sq_error); + const double total_ssim = + 100 * pow(cpi->summed_quality / cpi->summed_weights, 8.0); snprintf(headings, sizeof(headings), "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\tGLPsnrP\t" "VPXSSIM\tVPSSIMP\tFASTSIM\tPSNRHVS\t" @@ -2827,12 +2492,10 @@ void vp10_remove_compressor(VP10_COMP *cpi) { "%7.3f\t%7.3f\t%7.3f\t%7.3f\t" "%7.3f\t%7.3f\t%7.3f\t%7.3f", dr, cpi->psnr.stat[ALL] / cpi->count, total_psnr, - cpi->psnr.stat[ALL] / cpi->count, total_psnr, - total_ssim, total_ssim, - cpi->fastssim.stat[ALL] / cpi->count, - cpi->psnrhvs.stat[ALL] / cpi->count, - cpi->psnr.worst, cpi->worst_ssim, cpi->fastssim.worst, - cpi->psnrhvs.worst); + cpi->psnr.stat[ALL] / cpi->count, total_psnr, total_ssim, + total_ssim, cpi->fastssim.stat[ALL] / cpi->count, + cpi->psnrhvs.stat[ALL] / cpi->count, cpi->psnr.worst, + cpi->worst_ssim, cpi->fastssim.worst, cpi->psnrhvs.worst); if (cpi->b_calculate_blockiness) { SNPRINT(headings, "\t Block\tWstBlck"); @@ -2851,8 +2514,8 @@ void vp10_remove_compressor(VP10_COMP *cpi) { } fprintf(f, "%s\t Time Rc-Err Abs Err\n", headings); - fprintf(f, "%s\t%8.0f %7.2f %7.2f\n", results, - total_encode_time, rate_err, fabs(rate_err)); + fprintf(f, "%s\t%8.0f %7.2f %7.2f\n", results, total_encode_time, + rate_err, fabs(rate_err)); } fclose(f); @@ -2892,13 +2555,12 @@ void vp10_remove_compressor(VP10_COMP *cpi) { vpx_free(cpi->tile_thr_data); vpx_free(cpi->workers); - if (cpi->num_workers > 1) - vp10_loop_filter_dealloc(&cpi->lf_row_sync); + if (cpi->num_workers > 1) vp10_loop_filter_dealloc(&cpi->lf_row_sync); dealloc_compressor_data(cpi); - for (i = 0; i < sizeof(cpi->mbgraph_stats) / - sizeof(cpi->mbgraph_stats[0]); ++i) { + for (i = 0; i < sizeof(cpi->mbgraph_stats) / sizeof(cpi->mbgraph_stats[0]); + ++i) { vpx_free(cpi->mbgraph_stats[i].mb_stats); } @@ -2934,7 +2596,6 @@ void vp10_remove_compressor(VP10_COMP *cpi) { #endif } - static void generate_psnr_packet(VP10_COMP *cpi) { struct vpx_codec_cx_pkt pkt; int i; @@ -2956,8 +2617,7 @@ static void generate_psnr_packet(VP10_COMP *cpi) { } int vp10_use_as_reference(VP10_COMP *cpi, int ref_frame_flags) { - if (ref_frame_flags > ((1 << INTER_REFS_PER_FRAME) - 1)) - return -1; + if (ref_frame_flags > ((1 << INTER_REFS_PER_FRAME) - 1)) return -1; cpi->ref_frame_flags = ref_frame_flags; return 0; @@ -2973,8 +2633,7 @@ void vp10_update_reference(VP10_COMP *cpi, int ref_frame_flags) { static YV12_BUFFER_CONFIG *get_vp10_ref_frame_buffer( VP10_COMP *cpi, VPX_REFFRAME ref_frame_flag) { MV_REFERENCE_FRAME ref_frame = NONE; - if (ref_frame_flag == VPX_LAST_FLAG) - ref_frame = LAST_FRAME; + if (ref_frame_flag == VPX_LAST_FLAG) ref_frame = LAST_FRAME; #if CONFIG_EXT_REFS else if (ref_frame_flag == VPX_LAST2_FLAG) ref_frame = LAST2_FRAME; @@ -2994,7 +2653,7 @@ static YV12_BUFFER_CONFIG *get_vp10_ref_frame_buffer( } int vp10_copy_reference_enc(VP10_COMP *cpi, VPX_REFFRAME ref_frame_flag, - YV12_BUFFER_CONFIG *sd) { + YV12_BUFFER_CONFIG *sd) { YV12_BUFFER_CONFIG *cfg = get_vp10_ref_frame_buffer(cpi, ref_frame_flag); if (cfg) { vpx_yv12_copy_frame(cfg, sd); @@ -3005,7 +2664,7 @@ int vp10_copy_reference_enc(VP10_COMP *cpi, VPX_REFFRAME ref_frame_flag, } int vp10_set_reference_enc(VP10_COMP *cpi, VPX_REFFRAME ref_frame_flag, - YV12_BUFFER_CONFIG *sd) { + YV12_BUFFER_CONFIG *sd) { YV12_BUFFER_CONFIG *cfg = get_vp10_ref_frame_buffer(cpi, ref_frame_flag); if (cfg) { vpx_yv12_copy_frame(sd, cfg); @@ -3015,7 +2674,7 @@ int vp10_set_reference_enc(VP10_COMP *cpi, VPX_REFFRAME ref_frame_flag, } } -int vp10_update_entropy(VP10_COMP * cpi, int update) { +int vp10_update_entropy(VP10_COMP *cpi, int update) { cpi->ext_refresh_frame_context = update; cpi->ext_refresh_frame_context_pending = 1; return 0; @@ -3068,7 +2727,7 @@ static void check_show_existing_frame(VP10_COMP *cpi) { cm->show_existing_frame = 1; cpi->existing_fb_idx_to_show = cpi->lst_fb_idxes[0]; } else if (next_frame_update_type == OVERLAY_UPDATE && - cpi->is_arf_filter_off) { + cpi->is_arf_filter_off) { // Other parameters related to OVERLAY_UPDATE will be taken care of // in vp10_rc_get_second_pass_params(cpi) cm->show_existing_frame = 1; @@ -3091,7 +2750,7 @@ void vp10_write_one_yuv_frame(VP10_COMMON *cm, YV12_BUFFER_CONFIG *s) { uint16_t *src16 = CONVERT_TO_SHORTPTR(s->y_buffer); do { - fwrite(src16, s->y_width, 2, yuv_rec_file); + fwrite(src16, s->y_width, 2, yuv_rec_file); src16 += s->y_stride; } while (--h); @@ -3099,7 +2758,7 @@ void vp10_write_one_yuv_frame(VP10_COMMON *cm, YV12_BUFFER_CONFIG *s) { h = s->uv_height; do { - fwrite(src16, s->uv_width, 2, yuv_rec_file); + fwrite(src16, s->uv_width, 2, yuv_rec_file); src16 += s->uv_stride; } while (--h); @@ -3117,7 +2776,7 @@ void vp10_write_one_yuv_frame(VP10_COMMON *cm, YV12_BUFFER_CONFIG *s) { #endif // CONFIG_VP9_HIGHBITDEPTH do { - fwrite(src, s->y_width, 1, yuv_rec_file); + fwrite(src, s->y_width, 1, yuv_rec_file); src += s->y_stride; } while (--h); @@ -3125,7 +2784,7 @@ void vp10_write_one_yuv_frame(VP10_COMMON *cm, YV12_BUFFER_CONFIG *s) { h = s->uv_height; do { - fwrite(src, s->uv_width, 1, yuv_rec_file); + fwrite(src, s->uv_width, 1, yuv_rec_file); src += s->uv_stride; } while (--h); @@ -3151,32 +2810,33 @@ static void scale_and_extend_frame_nonnormative(const YV12_BUFFER_CONFIG *src, #endif // CONFIG_VP9_HIGHBITDEPTH // TODO(dkovalev): replace YV12_BUFFER_CONFIG with vpx_image_t int i; - const uint8_t *const srcs[3] = {src->y_buffer, src->u_buffer, src->v_buffer}; - const int src_strides[3] = {src->y_stride, src->uv_stride, src->uv_stride}; - const int src_widths[3] = {src->y_crop_width, src->uv_crop_width, - src->uv_crop_width }; - const int src_heights[3] = {src->y_crop_height, src->uv_crop_height, - src->uv_crop_height}; - uint8_t *const dsts[3] = {dst->y_buffer, dst->u_buffer, dst->v_buffer}; - const int dst_strides[3] = {dst->y_stride, dst->uv_stride, dst->uv_stride}; - const int dst_widths[3] = {dst->y_crop_width, dst->uv_crop_width, - dst->uv_crop_width}; - const int dst_heights[3] = {dst->y_crop_height, dst->uv_crop_height, - dst->uv_crop_height}; + const uint8_t *const srcs[3] = { src->y_buffer, src->u_buffer, + src->v_buffer }; + const int src_strides[3] = { src->y_stride, src->uv_stride, src->uv_stride }; + const int src_widths[3] = { src->y_crop_width, src->uv_crop_width, + src->uv_crop_width }; + const int src_heights[3] = { src->y_crop_height, src->uv_crop_height, + src->uv_crop_height }; + uint8_t *const dsts[3] = { dst->y_buffer, dst->u_buffer, dst->v_buffer }; + const int dst_strides[3] = { dst->y_stride, dst->uv_stride, dst->uv_stride }; + const int dst_widths[3] = { dst->y_crop_width, dst->uv_crop_width, + dst->uv_crop_width }; + const int dst_heights[3] = { dst->y_crop_height, dst->uv_crop_height, + dst->uv_crop_height }; for (i = 0; i < MAX_MB_PLANE; ++i) { #if CONFIG_VP9_HIGHBITDEPTH if (src->flags & YV12_FLAG_HIGHBITDEPTH) { vp10_highbd_resize_plane(srcs[i], src_heights[i], src_widths[i], - src_strides[i], dsts[i], dst_heights[i], - dst_widths[i], dst_strides[i], bd); + src_strides[i], dsts[i], dst_heights[i], + dst_widths[i], dst_strides[i], bd); } else { vp10_resize_plane(srcs[i], src_heights[i], src_widths[i], src_strides[i], - dsts[i], dst_heights[i], dst_widths[i], dst_strides[i]); + dsts[i], dst_heights[i], dst_widths[i], dst_strides[i]); } #else vp10_resize_plane(srcs[i], src_heights[i], src_widths[i], src_strides[i], - dsts[i], dst_heights[i], dst_widths[i], dst_strides[i]); + dsts[i], dst_heights[i], dst_widths[i], dst_strides[i]); #endif // CONFIG_VP9_HIGHBITDEPTH } vpx_extend_frame_borders(dst); @@ -3194,10 +2854,11 @@ static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src, const int src_h = src->y_crop_height; const int dst_w = dst->y_crop_width; const int dst_h = dst->y_crop_height; - const uint8_t *const srcs[3] = {src->y_buffer, src->u_buffer, src->v_buffer}; - const int src_strides[3] = {src->y_stride, src->uv_stride, src->uv_stride}; - uint8_t *const dsts[3] = {dst->y_buffer, dst->u_buffer, dst->v_buffer}; - const int dst_strides[3] = {dst->y_stride, dst->uv_stride, dst->uv_stride}; + const uint8_t *const srcs[3] = { src->y_buffer, src->u_buffer, + src->v_buffer }; + const int src_strides[3] = { src->y_stride, src->uv_stride, src->uv_stride }; + uint8_t *const dsts[3] = { dst->y_buffer, dst->u_buffer, dst->v_buffer }; + const int dst_strides[3] = { dst->y_stride, dst->uv_stride, dst->uv_stride }; const InterpFilterParams interp_filter_params = vp10_get_interp_filter_params(EIGHTTAP_REGULAR); const int16_t *kernel = interp_filter_params.filter_ptr; @@ -3212,8 +2873,9 @@ static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src, const int y_q4 = y * (16 / factor) * src_h / dst_h; const int src_stride = src_strides[i]; const int dst_stride = dst_strides[i]; - const uint8_t *src_ptr = srcs[i] + (y / factor) * src_h / dst_h * - src_stride + (x / factor) * src_w / dst_w; + const uint8_t *src_ptr = srcs[i] + + (y / factor) * src_h / dst_h * src_stride + + (x / factor) * src_w / dst_w; uint8_t *dst_ptr = dsts[i] + (y / factor) * dst_stride + (x / factor); #if CONFIG_VP9_HIGHBITDEPTH @@ -3252,8 +2914,9 @@ static int scale_down(VP10_COMP *cpi, int q) { if (rc->frame_size_selector == UNSCALED && q >= rc->rf_level_maxq[gf_group->rf_level[gf_group->index]]) { - const int max_size_thresh = (int)(rate_thresh_mult[SCALE_STEP1] - * VPXMAX(rc->this_frame_target, rc->avg_frame_bandwidth)); + const int max_size_thresh = + (int)(rate_thresh_mult[SCALE_STEP1] * + VPXMAX(rc->this_frame_target, rc->avg_frame_bandwidth)); scale = rc->projected_frame_size > max_size_thresh ? 1 : 0; } return scale; @@ -3261,8 +2924,7 @@ static int scale_down(VP10_COMP *cpi, int q) { // Function to test for conditions that indicate we should loop // back and recode a frame. -static int recode_loop_test(VP10_COMP *cpi, - int high_limit, int low_limit, +static int recode_loop_test(VP10_COMP *cpi, int high_limit, int low_limit, int q, int maxq, int minq) { const RATE_CONTROL *const rc = &cpi->rc; const VP10EncoderConfig *const oxcf = &cpi->oxcf; @@ -3271,14 +2933,12 @@ static int recode_loop_test(VP10_COMP *cpi, if ((rc->projected_frame_size >= rc->max_frame_bandwidth) || (cpi->sf.recode_loop == ALLOW_RECODE) || - (frame_is_kfgfarf && - (cpi->sf.recode_loop == ALLOW_RECODE_KFARFGF))) { - if (frame_is_kfgfarf && - (oxcf->resize_mode == RESIZE_DYNAMIC) && + (frame_is_kfgfarf && (cpi->sf.recode_loop == ALLOW_RECODE_KFARFGF))) { + if (frame_is_kfgfarf && (oxcf->resize_mode == RESIZE_DYNAMIC) && scale_down(cpi, q)) { - // Code this group at a lower resolution. - cpi->resize_pending = 1; - return 1; + // Code this group at a lower resolution. + cpi->resize_pending = 1; + return 1; } // TODO(agrange) high_limit could be greater than the scale-down threshold. @@ -3311,7 +2971,7 @@ static INLINE int get_free_upsampled_ref_buf(EncRefCntBuffer *ubufs) { // Up-sample 1 reference frame. static INLINE int upsample_ref_frame(VP10_COMP *cpi, const YV12_BUFFER_CONFIG *const ref) { - VP10_COMMON * const cm = &cpi->common; + VP10_COMMON *const cm = &cpi->common; EncRefCntBuffer *ubufs = cpi->upsampled_ref_bufs; int new_uidx = get_free_upsampled_ref_buf(ubufs); @@ -3322,19 +2982,18 @@ static INLINE int upsample_ref_frame(VP10_COMP *cpi, // Can allocate buffer for Y plane only. if (upsampled_ref->buffer_alloc_sz < (ref->buffer_alloc_sz << 6)) - if (vpx_realloc_frame_buffer(upsampled_ref, - (cm->width << 3), (cm->height << 3), - cm->subsampling_x, cm->subsampling_y, + if (vpx_realloc_frame_buffer(upsampled_ref, (cm->width << 3), + (cm->height << 3), cm->subsampling_x, + cm->subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH cm->use_highbitdepth, #endif (VPX_ENC_BORDER_IN_PIXELS << 3), - cm->byte_alignment, - NULL, NULL, NULL)) + cm->byte_alignment, NULL, NULL, NULL)) vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, "Failed to allocate up-sampled frame buffer"); - // Currently, only Y plane is up-sampled, U, V are not used. +// Currently, only Y plane is up-sampled, U, V are not used. #if CONFIG_VP9_HIGHBITDEPTH scale_and_extend_frame(ref, upsampled_ref, 1, (int)cm->bit_depth); #else @@ -3344,7 +3003,7 @@ static INLINE int upsample_ref_frame(VP10_COMP *cpi, } } -#define DUMP_REF_FRAME_IMAGES 0 +#define DUMP_REF_FRAME_IMAGES 0 #if DUMP_REF_FRAME_IMAGES == 1 static int dump_one_image(VP10_COMMON *cm, @@ -3365,18 +3024,17 @@ static int dump_one_image(VP10_COMMON *cm, // --- Y --- for (h = 0; h < cm->height; ++h) { - fwrite(&ref_buf->y_buffer[h*ref_buf->y_stride], - 1, cm->width, f_ref); + fwrite(&ref_buf->y_buffer[h * ref_buf->y_stride], 1, cm->width, f_ref); } // --- U --- for (h = 0; h < (cm->height >> 1); ++h) { - fwrite(&ref_buf->u_buffer[h*ref_buf->uv_stride], - 1, (cm->width >> 1), f_ref); + fwrite(&ref_buf->u_buffer[h * ref_buf->uv_stride], 1, (cm->width >> 1), + f_ref); } // --- V --- for (h = 0; h < (cm->height >> 1); ++h) { - fwrite(&ref_buf->v_buffer[h*ref_buf->uv_stride], - 1, (cm->width >> 1), f_ref); + fwrite(&ref_buf->v_buffer[h * ref_buf->uv_stride], 1, (cm->width >> 1), + f_ref); } fclose(f_ref); @@ -3392,22 +3050,20 @@ static void dump_ref_frame_images(VP10_COMP *cpi) { char file_name[256] = ""; snprintf(file_name, sizeof(file_name), "/tmp/enc_F%d_ref_%d.yuv", cm->current_video_frame, ref_frame); - dump_one_image( - cm, get_ref_frame_buffer(cpi, ref_frame), file_name); + dump_one_image(cm, get_ref_frame_buffer(cpi, ref_frame), file_name); } } #endif // DUMP_REF_FRAME_IMAGES == 1 void vp10_update_reference_frames(VP10_COMP *cpi) { - VP10_COMMON * const cm = &cpi->common; + VP10_COMMON *const cm = &cpi->common; BufferPool *const pool = cm->buffer_pool; const int use_upsampled_ref = cpi->sf.use_upsampled_references; int new_uidx = 0; // NOTE: Save the new show frame buffer index for --test-code=warn, i.e., // for the purpose to verify no mismatch between encoder and decoder. - if (cm->show_frame) - cpi->last_show_frame_buf_idx = cm->new_fb_idx; + if (cm->show_frame) cpi->last_show_frame_buf_idx = cm->new_fb_idx; if (use_upsampled_ref) { #if CONFIG_EXT_REFS @@ -3430,14 +3086,14 @@ void vp10_update_reference_frames(VP10_COMP *cpi) { // At this point the new frame has been encoded. // If any buffer copy / swapping is signaled it should be done here. if (cm->frame_type == KEY_FRAME) { - ref_cnt_fb(pool->frame_bufs, - &cm->ref_frame_map[cpi->gld_fb_idx], cm->new_fb_idx); + ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->gld_fb_idx], + cm->new_fb_idx); #if CONFIG_EXT_REFS - ref_cnt_fb(pool->frame_bufs, - &cm->ref_frame_map[cpi->bwd_fb_idx], cm->new_fb_idx); + ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->bwd_fb_idx], + cm->new_fb_idx); #endif // CONFIG_EXT_REFS - ref_cnt_fb(pool->frame_bufs, - &cm->ref_frame_map[cpi->alt_fb_idx], cm->new_fb_idx); + ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->alt_fb_idx], + cm->new_fb_idx); if (use_upsampled_ref) { uref_cnt_fb(cpi->upsampled_ref_bufs, @@ -3460,8 +3116,8 @@ void vp10_update_reference_frames(VP10_COMP *cpi) { // slot and, if we're updating the GF, the current frame becomes the new GF. int tmp; - ref_cnt_fb(pool->frame_bufs, - &cm->ref_frame_map[cpi->alt_fb_idx], cm->new_fb_idx); + ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->alt_fb_idx], + cm->new_fb_idx); if (use_upsampled_ref) uref_cnt_fb(cpi->upsampled_ref_bufs, &cpi->upsampled_ref_idx[cpi->alt_fb_idx], new_uidx); @@ -3470,14 +3126,14 @@ void vp10_update_reference_frames(VP10_COMP *cpi) { cpi->alt_fb_idx = cpi->gld_fb_idx; cpi->gld_fb_idx = tmp; - // TODO(zoeliu): Do we need to copy cpi->interp_filter_selected[0] over to - // cpi->interp_filter_selected[GOLDEN_FRAME]? +// TODO(zoeliu): Do we need to copy cpi->interp_filter_selected[0] over to +// cpi->interp_filter_selected[GOLDEN_FRAME]? #if CONFIG_EXT_REFS } else if (cpi->rc.is_last_bipred_frame) { // Refresh the LAST_FRAME with the BWDREF_FRAME and retire the LAST3_FRAME // by updating the virtual indices. Note that the frame BWDREF_FRAME points // to now should be retired, and it should not be used before refreshed. - int ref_frame, tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES-1]; + int ref_frame, tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES - 1]; for (ref_frame = LAST_REF_FRAMES - 1; ref_frame > 0; --ref_frame) { cpi->lst_fb_idxes[ref_frame] = cpi->lst_fb_idxes[ref_frame - 1]; @@ -3494,7 +3150,7 @@ void vp10_update_reference_frames(VP10_COMP *cpi) { sizeof(cpi->interp_filter_selected[BWDREF_FRAME])); } cpi->bwd_fb_idx = tmp; -#endif // CONFIG_EXT_REFS +#endif // CONFIG_EXT_REFS } else { /* For non key/golden frames */ if (cpi->refresh_alt_ref_frame) { int arf_idx = cpi->alt_fb_idx; @@ -3503,11 +3159,10 @@ void vp10_update_reference_frames(VP10_COMP *cpi) { arf_idx = gf_group->arf_update_idx[gf_group->index]; } - ref_cnt_fb(pool->frame_bufs, - &cm->ref_frame_map[arf_idx], cm->new_fb_idx); + ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[arf_idx], cm->new_fb_idx); if (use_upsampled_ref) - uref_cnt_fb(cpi->upsampled_ref_bufs, - &cpi->upsampled_ref_idx[arf_idx], new_uidx); + uref_cnt_fb(cpi->upsampled_ref_bufs, &cpi->upsampled_ref_idx[arf_idx], + new_uidx); memcpy(cpi->interp_filter_selected[ALTREF_FRAME], cpi->interp_filter_selected[0], @@ -3515,8 +3170,8 @@ void vp10_update_reference_frames(VP10_COMP *cpi) { } if (cpi->refresh_golden_frame) { - ref_cnt_fb(pool->frame_bufs, - &cm->ref_frame_map[cpi->gld_fb_idx], cm->new_fb_idx); + ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->gld_fb_idx], + cm->new_fb_idx); if (use_upsampled_ref) uref_cnt_fb(cpi->upsampled_ref_bufs, &cpi->upsampled_ref_idx[cpi->gld_fb_idx], new_uidx); @@ -3533,8 +3188,8 @@ void vp10_update_reference_frames(VP10_COMP *cpi) { #if CONFIG_EXT_REFS if (cpi->refresh_bwd_ref_frame) { - ref_cnt_fb(pool->frame_bufs, - &cm->ref_frame_map[cpi->bwd_fb_idx], cm->new_fb_idx); + ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->bwd_fb_idx], + cm->new_fb_idx); if (use_upsampled_ref) uref_cnt_fb(cpi->upsampled_ref_bufs, &cpi->upsampled_ref_idx[cpi->bwd_fb_idx], new_uidx); @@ -3587,25 +3242,24 @@ void vp10_update_reference_frames(VP10_COMP *cpi) { cm->new_fb_idx); if (use_upsampled_ref) - uref_cnt_fb( - cpi->upsampled_ref_bufs, - &cpi->upsampled_ref_idx[cpi->lst_fb_idxes[ref_frame]], - new_uidx); + uref_cnt_fb(cpi->upsampled_ref_bufs, + &cpi->upsampled_ref_idx[cpi->lst_fb_idxes[ref_frame]], + new_uidx); } } else { int tmp; ref_cnt_fb(pool->frame_bufs, - &cm->ref_frame_map[cpi->lst_fb_idxes[LAST_REF_FRAMES-1]], + &cm->ref_frame_map[cpi->lst_fb_idxes[LAST_REF_FRAMES - 1]], cm->new_fb_idx); if (use_upsampled_ref) uref_cnt_fb( cpi->upsampled_ref_bufs, - &cpi->upsampled_ref_idx[cpi->lst_fb_idxes[LAST_REF_FRAMES-1]], + &cpi->upsampled_ref_idx[cpi->lst_fb_idxes[LAST_REF_FRAMES - 1]], new_uidx); - tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES-1]; + tmp = cpi->lst_fb_idxes[LAST_REF_FRAMES - 1]; for (ref_frame = LAST_REF_FRAMES - 1; ref_frame > 0; --ref_frame) { cpi->lst_fb_idxes[ref_frame] = cpi->lst_fb_idxes[ref_frame - 1]; @@ -3630,8 +3284,8 @@ void vp10_update_reference_frames(VP10_COMP *cpi) { } } #else - ref_cnt_fb(pool->frame_bufs, - &cm->ref_frame_map[cpi->lst_fb_idx], cm->new_fb_idx); + ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->lst_fb_idx], + cm->new_fb_idx); if (use_upsampled_ref) uref_cnt_fb(cpi->upsampled_ref_bufs, &cpi->upsampled_ref_idx[cpi->lst_fb_idx], new_uidx); @@ -3644,9 +3298,9 @@ void vp10_update_reference_frames(VP10_COMP *cpi) { } #if DUMP_REF_FRAME_IMAGES == 1 - // Dump out all reference frame images. - dump_ref_frame_images(cpi); -#endif // DUMP_REF_FRAME_IMAGES + // Dump out all reference frame images. + dump_ref_frame_images(cpi); +#endif // DUMP_REF_FRAME_IMAGES } static void loopfilter_frame(VP10_COMP *cpi, VP10_COMMON *cm) { @@ -3677,9 +3331,8 @@ static void loopfilter_frame(VP10_COMP *cpi, VP10_COMMON *cm) { #else if (cpi->num_workers > 1) vp10_loop_filter_frame_mt(cm->frame_to_show, cm, xd->plane, - lf->filter_level, 0, 0, - cpi->workers, cpi->num_workers, - &cpi->lf_row_sync); + lf->filter_level, 0, 0, cpi->workers, + cpi->num_workers, &cpi->lf_row_sync); else vp10_loop_filter_frame(cm->frame_to_show, cm, xd, lf->filter_level, 0, 0); #endif @@ -3695,11 +3348,9 @@ static void loopfilter_frame(VP10_COMP *cpi, VP10_COMMON *cm) { vpx_extend_frame_inner_borders(cm->frame_to_show); } -static INLINE void alloc_frame_mvs(VP10_COMMON *const cm, - int buffer_idx) { +static INLINE void alloc_frame_mvs(VP10_COMMON *const cm, int buffer_idx) { RefCntBuffer *const new_fb_ptr = &cm->buffer_pool->frame_bufs[buffer_idx]; - if (new_fb_ptr->mvs == NULL || - new_fb_ptr->mi_rows < cm->mi_rows || + if (new_fb_ptr->mvs == NULL || new_fb_ptr->mi_rows < cm->mi_rows || new_fb_ptr->mi_cols < cm->mi_cols) { vpx_free(new_fb_ptr->mvs); CHECK_MEM_ERROR(cm, new_fb_ptr->mvs, @@ -3730,8 +3381,8 @@ void vp10_scale_references(VP10_COMP *cpi) { // Need to convert from VPX_REFFRAME to index into ref_mask (subtract 1). if (cpi->ref_frame_flags & ref_mask[ref_frame - 1]) { BufferPool *const pool = cm->buffer_pool; - const YV12_BUFFER_CONFIG *const ref = get_ref_frame_buffer(cpi, - ref_frame); + const YV12_BUFFER_CONFIG *const ref = + get_ref_frame_buffer(cpi, ref_frame); if (ref == NULL) { cpi->scaled_ref_idx[ref_frame - 1] = INVALID_IDX; @@ -3747,11 +3398,9 @@ void vp10_scale_references(VP10_COMP *cpi) { new_fb = get_free_fb(cm); force_scaling = 1; } - if (new_fb == INVALID_IDX) - return; + if (new_fb == INVALID_IDX) return; new_fb_ptr = &pool->frame_bufs[new_fb]; - if (force_scaling || - new_fb_ptr->buf.y_crop_width != cm->width || + if (force_scaling || new_fb_ptr->buf.y_crop_width != cm->width || new_fb_ptr->buf.y_crop_height != cm->height) { if (vpx_realloc_frame_buffer(&new_fb_ptr->buf, cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, @@ -3774,11 +3423,9 @@ void vp10_scale_references(VP10_COMP *cpi) { new_fb = get_free_fb(cm); force_scaling = 1; } - if (new_fb == INVALID_IDX) - return; + if (new_fb == INVALID_IDX) return; new_fb_ptr = &pool->frame_bufs[new_fb]; - if (force_scaling || - new_fb_ptr->buf.y_crop_width != cm->width || + if (force_scaling || new_fb_ptr->buf.y_crop_width != cm->width || new_fb_ptr->buf.y_crop_height != cm->height) { if (vpx_realloc_frame_buffer(&new_fb_ptr->buf, cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, @@ -3792,22 +3439,21 @@ void vp10_scale_references(VP10_COMP *cpi) { } #endif // CONFIG_VP9_HIGHBITDEPTH - if (cpi->sf.use_upsampled_references && (force_scaling || - new_fb_ptr->buf.y_crop_width != cm->width || - new_fb_ptr->buf.y_crop_height != cm->height)) { + if (cpi->sf.use_upsampled_references && + (force_scaling || new_fb_ptr->buf.y_crop_width != cm->width || + new_fb_ptr->buf.y_crop_height != cm->height)) { const int map_idx = get_ref_frame_map_idx(cpi, ref_frame); EncRefCntBuffer *ubuf = &cpi->upsampled_ref_bufs[cpi->upsampled_ref_idx[map_idx]]; - if (vpx_realloc_frame_buffer(&ubuf->buf, - (cm->width << 3), (cm->height << 3), - cm->subsampling_x, cm->subsampling_y, + if (vpx_realloc_frame_buffer(&ubuf->buf, (cm->width << 3), + (cm->height << 3), cm->subsampling_x, + cm->subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH cm->use_highbitdepth, #endif (VPX_ENC_BORDER_IN_PIXELS << 3), - cm->byte_alignment, - NULL, NULL, NULL)) + cm->byte_alignment, NULL, NULL, NULL)) vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, "Failed to allocate up-sampled frame buffer"); #if CONFIG_VP9_HIGHBITDEPTH @@ -3826,8 +3472,7 @@ void vp10_scale_references(VP10_COMP *cpi) { ++buf->ref_count; } } else { - if (cpi->oxcf.pass != 0) - cpi->scaled_ref_idx[ref_frame - 1] = INVALID_IDX; + if (cpi->oxcf.pass != 0) cpi->scaled_ref_idx[ref_frame - 1] = INVALID_IDX; } } } @@ -3851,22 +3496,21 @@ static void release_scaled_references(VP10_COMP *cpi) { #endif // CONFIG_EXT_REFS for (i = LAST_FRAME; i <= ALTREF_FRAME; ++i) { const int idx = cpi->scaled_ref_idx[i - 1]; - RefCntBuffer *const buf = idx != INVALID_IDX ? - &cm->buffer_pool->frame_bufs[idx] : NULL; + RefCntBuffer *const buf = + idx != INVALID_IDX ? &cm->buffer_pool->frame_bufs[idx] : NULL; const YV12_BUFFER_CONFIG *const ref = get_ref_frame_buffer(cpi, i); if (buf != NULL && - (refresh[i - 1] || - (buf->buf.y_crop_width == ref->y_crop_width && - buf->buf.y_crop_height == ref->y_crop_height))) { + (refresh[i - 1] || (buf->buf.y_crop_width == ref->y_crop_width && + buf->buf.y_crop_height == ref->y_crop_height))) { --buf->ref_count; - cpi->scaled_ref_idx[i -1] = INVALID_IDX; + cpi->scaled_ref_idx[i - 1] = INVALID_IDX; } } } else { for (i = 0; i < TOTAL_REFS_PER_FRAME; ++i) { const int idx = cpi->scaled_ref_idx[i]; - RefCntBuffer *const buf = idx != INVALID_IDX ? - &cm->buffer_pool->frame_bufs[idx] : NULL; + RefCntBuffer *const buf = + idx != INVALID_IDX ? &cm->buffer_pool->frame_bufs[idx] : NULL; if (buf != NULL) { --buf->ref_count; cpi->scaled_ref_idx[i] = INVALID_IDX; @@ -3886,7 +3530,6 @@ static void full_to_model_count(unsigned int *model_count, model_count[EOB_MODEL_TOKEN] = full_count[EOB_TOKEN]; } - void vp10_full_to_model_counts(vp10_coeff_count_model *model_count, vp10_coeff_count *full_count) { int i, j, k, l; @@ -4001,8 +3644,8 @@ static void set_size_independent_vars(VP10_COMP *cpi) { cpi->common.interp_filter = cpi->sf.default_interp_filter; } -static void set_size_dependent_vars(VP10_COMP *cpi, int *q, - int *bottom_index, int *top_index) { +static void set_size_dependent_vars(VP10_COMP *cpi, int *q, int *bottom_index, + int *top_index) { VP10_COMMON *const cm = &cpi->common; const VP10EncoderConfig *const oxcf = &cpi->oxcf; @@ -4040,40 +3683,37 @@ static void set_frame_size(VP10_COMP *cpi) { VP10EncoderConfig *const oxcf = &cpi->oxcf; MACROBLOCKD *const xd = &cpi->td.mb.e_mbd; - if (oxcf->pass == 2 && - oxcf->rc_mode == VPX_VBR && + if (oxcf->pass == 2 && oxcf->rc_mode == VPX_VBR && ((oxcf->resize_mode == RESIZE_FIXED && cm->current_video_frame == 0) || - (oxcf->resize_mode == RESIZE_DYNAMIC && cpi->resize_pending))) { - vp10_calculate_coded_size( - cpi, &oxcf->scaled_frame_width, &oxcf->scaled_frame_height); + (oxcf->resize_mode == RESIZE_DYNAMIC && cpi->resize_pending))) { + vp10_calculate_coded_size(cpi, &oxcf->scaled_frame_width, + &oxcf->scaled_frame_height); // There has been a change in frame size. vp10_set_size_literal(cpi, oxcf->scaled_frame_width, oxcf->scaled_frame_height); } - if (oxcf->pass == 0 && - oxcf->rc_mode == VPX_CBR && + if (oxcf->pass == 0 && oxcf->rc_mode == VPX_CBR && oxcf->resize_mode == RESIZE_DYNAMIC) { - if (cpi->resize_pending == 1) { - oxcf->scaled_frame_width = - (cm->width * cpi->resize_scale_num) / cpi->resize_scale_den; - oxcf->scaled_frame_height = - (cm->height * cpi->resize_scale_num) /cpi->resize_scale_den; - } else if (cpi->resize_pending == -1) { - // Go back up to original size. - oxcf->scaled_frame_width = oxcf->width; - oxcf->scaled_frame_height = oxcf->height; - } - if (cpi->resize_pending != 0) { - // There has been a change in frame size. - vp10_set_size_literal(cpi, - oxcf->scaled_frame_width, - oxcf->scaled_frame_height); + if (cpi->resize_pending == 1) { + oxcf->scaled_frame_width = + (cm->width * cpi->resize_scale_num) / cpi->resize_scale_den; + oxcf->scaled_frame_height = + (cm->height * cpi->resize_scale_num) / cpi->resize_scale_den; + } else if (cpi->resize_pending == -1) { + // Go back up to original size. + oxcf->scaled_frame_width = oxcf->width; + oxcf->scaled_frame_height = oxcf->height; + } + if (cpi->resize_pending != 0) { + // There has been a change in frame size. + vp10_set_size_literal(cpi, oxcf->scaled_frame_width, + oxcf->scaled_frame_height); - // TODO(agrange) Scale cpi->max_mv_magnitude if frame-size has changed. - set_mv_search_params(cpi); - } + // TODO(agrange) Scale cpi->max_mv_magnitude if frame-size has changed. + set_mv_search_params(cpi); + } } if (oxcf->pass == 2) { @@ -4106,18 +3746,15 @@ static void set_frame_size(VP10_COMP *cpi) { YV12_BUFFER_CONFIG *const buf = &cm->buffer_pool->frame_bufs[buf_idx].buf; ref_buf->buf = buf; #if CONFIG_VP9_HIGHBITDEPTH - vp10_setup_scale_factors_for_frame(&ref_buf->sf, - buf->y_crop_width, buf->y_crop_height, - cm->width, cm->height, - (buf->flags & YV12_FLAG_HIGHBITDEPTH) ? - 1 : 0); + vp10_setup_scale_factors_for_frame( + &ref_buf->sf, buf->y_crop_width, buf->y_crop_height, cm->width, + cm->height, (buf->flags & YV12_FLAG_HIGHBITDEPTH) ? 1 : 0); #else - vp10_setup_scale_factors_for_frame(&ref_buf->sf, - buf->y_crop_width, buf->y_crop_height, - cm->width, cm->height); + vp10_setup_scale_factors_for_frame(&ref_buf->sf, buf->y_crop_width, + buf->y_crop_height, cm->width, + cm->height); #endif // CONFIG_VP9_HIGHBITDEPTH - if (vp10_is_scaled(&ref_buf->sf)) - vpx_extend_frame_borders(buf); + if (vp10_is_scaled(&ref_buf->sf)) vpx_extend_frame_borders(buf); } else { ref_buf->buf = NULL; } @@ -4133,13 +3770,11 @@ static void reset_use_upsampled_references(VP10_COMP *cpi) { init_upsampled_ref_frame_bufs(cpi); for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { - const YV12_BUFFER_CONFIG *const ref = get_ref_frame_buffer(cpi, - ref_frame); + const YV12_BUFFER_CONFIG *const ref = get_ref_frame_buffer(cpi, ref_frame); int new_uidx = upsample_ref_frame(cpi, ref); // Update the up-sampled reference index. - cpi->upsampled_ref_idx[get_ref_frame_map_idx(cpi, ref_frame)] = - new_uidx; + cpi->upsampled_ref_idx[get_ref_frame_map_idx(cpi, ref_frame)] = new_uidx; cpi->upsampled_ref_bufs[new_uidx].ref_count++; } } @@ -4155,24 +3790,21 @@ static void encode_without_recode_loop(VP10_COMP *cpi) { // For 1 pass CBR under dynamic resize mode: use faster scaling for source. // Only for 2x2 scaling for now. - if (cpi->oxcf.pass == 0 && - cpi->oxcf.rc_mode == VPX_CBR && + if (cpi->oxcf.pass == 0 && cpi->oxcf.rc_mode == VPX_CBR && cpi->oxcf.resize_mode == RESIZE_DYNAMIC && cpi->un_scaled_source->y_width == (cm->width << 1) && cpi->un_scaled_source->y_height == (cm->height << 1)) { - cpi->Source = vp10_scale_if_required_fast(cm, - cpi->un_scaled_source, - &cpi->scaled_source); + cpi->Source = vp10_scale_if_required_fast(cm, cpi->un_scaled_source, + &cpi->scaled_source); if (cpi->unscaled_last_source != NULL) - cpi->Last_Source = vp10_scale_if_required_fast(cm, - cpi->unscaled_last_source, - &cpi->scaled_last_source); + cpi->Last_Source = vp10_scale_if_required_fast( + cm, cpi->unscaled_last_source, &cpi->scaled_last_source); } else { - cpi->Source = vp10_scale_if_required(cm, cpi->un_scaled_source, - &cpi->scaled_source); + cpi->Source = + vp10_scale_if_required(cm, cpi->un_scaled_source, &cpi->scaled_source); if (cpi->unscaled_last_source != NULL) cpi->Last_Source = vp10_scale_if_required(cm, cpi->unscaled_last_source, - &cpi->scaled_last_source); + &cpi->scaled_last_source); } if (frame_is_intra_only(cm) == 0) { @@ -4196,8 +3828,7 @@ static void encode_without_recode_loop(VP10_COMP *cpi) { #if CONFIG_ENTROPY cm->do_subframe_update = cm->tile_cols == 1 && cm->tile_rows == 1; vp10_copy(cm->starting_coef_probs, cm->fc->coef_probs); - vp10_copy(cpi->subframe_stats.enc_starting_coef_probs, - cm->fc->coef_probs); + vp10_copy(cpi->subframe_stats.enc_starting_coef_probs, cm->fc->coef_probs); cm->coef_probs_update_idx = 0; vp10_copy(cpi->subframe_stats.coef_probs_buf[0], cm->fc->coef_probs); #endif // CONFIG_ENTROPY @@ -4219,8 +3850,7 @@ static void encode_without_recode_loop(VP10_COMP *cpi) { // Update some stats from cyclic refresh, and check if we should not update // golden reference, for 1 pass CBR. - if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && - cm->frame_type != KEY_FRAME && + if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->frame_type != KEY_FRAME && (cpi->oxcf.pass == 0 && cpi->oxcf.rc_mode == VPX_CBR)) vp10_cyclic_refresh_check_golden_update(cpi); @@ -4230,8 +3860,7 @@ static void encode_without_recode_loop(VP10_COMP *cpi) { vpx_clear_system_state(); } -static void encode_with_recode_loop(VP10_COMP *cpi, - size_t *size, +static void encode_with_recode_loop(VP10_COMP *cpi, size_t *size, uint8_t *dest) { VP10_COMMON *const cm = &cpi->common; RATE_CONTROL *const rc = &cpi->rc; @@ -4281,16 +3910,16 @@ static void encode_with_recode_loop(VP10_COMP *cpi, // Decide frame size bounds first time through. if (loop_count == 0) { vp10_rc_compute_frame_size_bounds(cpi, rc->this_frame_target, - &frame_under_shoot_limit, - &frame_over_shoot_limit); + &frame_under_shoot_limit, + &frame_over_shoot_limit); } - cpi->Source = vp10_scale_if_required(cm, cpi->un_scaled_source, - &cpi->scaled_source); + cpi->Source = + vp10_scale_if_required(cm, cpi->un_scaled_source, &cpi->scaled_source); if (cpi->unscaled_last_source != NULL) cpi->Last_Source = vp10_scale_if_required(cm, cpi->unscaled_last_source, - &cpi->scaled_last_source); + &cpi->scaled_last_source); if (frame_is_intra_only(cm) == 0) { if (loop_count > 0) { @@ -4301,8 +3930,7 @@ static void encode_with_recode_loop(VP10_COMP *cpi, vp10_set_quantizer(cm, q); - if (loop_count == 0) - setup_frame(cpi); + if (loop_count == 0) setup_frame(cpi); #if CONFIG_ENTROPY // Base q-index may have changed, so we need to assign proper default coef @@ -4312,8 +3940,7 @@ static void encode_with_recode_loop(VP10_COMP *cpi, vp10_default_coef_probs(cm); if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode || cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL) { - for (i = 0; i < FRAME_CONTEXTS; ++i) - cm->frame_contexts[i] = *cm->fc; + for (i = 0; i < FRAME_CONTEXTS; ++i) cm->frame_contexts[i] = *cm->fc; } else if (cm->reset_frame_context == RESET_FRAME_CONTEXT_CURRENT) { cm->frame_contexts[cm->frame_context_idx] = *cm->fc; } @@ -4369,16 +3996,14 @@ static void encode_with_recode_loop(VP10_COMP *cpi, rc->projected_frame_size = (int)(*size) << 3; restore_coding_context(cpi); - if (frame_over_shoot_limit == 0) - frame_over_shoot_limit = 1; + if (frame_over_shoot_limit == 0) frame_over_shoot_limit = 1; } if (cpi->oxcf.rc_mode == VPX_Q) { loop = 0; } else { - if ((cm->frame_type == KEY_FRAME) && - rc->this_key_frame_forced && - (rc->projected_frame_size < rc->max_frame_bandwidth)) { + if ((cm->frame_type == KEY_FRAME) && rc->this_key_frame_forced && + (rc->projected_frame_size < rc->max_frame_bandwidth)) { int last_q = q; int64_t kf_err; @@ -4425,9 +4050,9 @@ static void encode_with_recode_loop(VP10_COMP *cpi, q = clamp(q, q_low, q_high); loop = q != last_q; - } else if (recode_loop_test( - cpi, frame_over_shoot_limit, frame_under_shoot_limit, - q, VPXMAX(q_high, top_index), bottom_index)) { + } else if (recode_loop_test(cpi, frame_over_shoot_limit, + frame_under_shoot_limit, q, + VPXMAX(q_high, top_index), bottom_index)) { // Is the projected frame size out of range and are we allowed // to attempt to recode. int last_q = q; @@ -4468,13 +4093,13 @@ static void encode_with_recode_loop(VP10_COMP *cpi, // Update rate_correction_factor unless vp10_rc_update_rate_correction_factors(cpi); - q = vp10_rc_regulate_q(cpi, rc->this_frame_target, - bottom_index, VPXMAX(q_high, top_index)); + q = vp10_rc_regulate_q(cpi, rc->this_frame_target, bottom_index, + VPXMAX(q_high, top_index)); while (q < q_low && retries < 10) { vp10_rc_update_rate_correction_factors(cpi); - q = vp10_rc_regulate_q(cpi, rc->this_frame_target, - bottom_index, VPXMAX(q_high, top_index)); + q = vp10_rc_regulate_q(cpi, rc->this_frame_target, bottom_index, + VPXMAX(q_high, top_index)); retries++; } } @@ -4489,21 +4114,20 @@ static void encode_with_recode_loop(VP10_COMP *cpi, q = (q_high + q_low) / 2; } else { vp10_rc_update_rate_correction_factors(cpi); - q = vp10_rc_regulate_q(cpi, rc->this_frame_target, - bottom_index, top_index); + q = vp10_rc_regulate_q(cpi, rc->this_frame_target, bottom_index, + top_index); // Special case reset for qlow for constrained quality. // This should only trigger where there is very substantial // undershoot on a frame and the auto cq level is above // the user passsed in value. - if (cpi->oxcf.rc_mode == VPX_CQ && - q < q_low) { + if (cpi->oxcf.rc_mode == VPX_CQ && q < q_low) { q_low = q; } while (q > q_high && retries < 10) { vp10_rc_update_rate_correction_factors(cpi); - q = vp10_rc_regulate_q(cpi, rc->this_frame_target, - bottom_index, top_index); + q = vp10_rc_regulate_q(cpi, rc->this_frame_target, bottom_index, + top_index); retries++; } } @@ -4576,27 +4200,22 @@ static int get_ref_frame_flags(const VP10_COMP *cpi) { flags &= ~VPX_BWD_FLAG; #endif // CONFIG_EXT_REFS - if (gld_is_last || gld_is_alt) - flags &= ~VPX_GOLD_FLAG; + if (gld_is_last || gld_is_alt) flags &= ~VPX_GOLD_FLAG; - if (cpi->rc.frames_till_gf_update_due == INT_MAX) - flags &= ~VPX_GOLD_FLAG; + if (cpi->rc.frames_till_gf_update_due == INT_MAX) flags &= ~VPX_GOLD_FLAG; - if (alt_is_last) - flags &= ~VPX_ALT_FLAG; + if (alt_is_last) flags &= ~VPX_ALT_FLAG; #if CONFIG_EXT_REFS - if (last2_is_last || last2_is_alt) - flags &= ~VPX_LAST2_FLAG; + if (last2_is_last || last2_is_alt) flags &= ~VPX_LAST2_FLAG; - if (last3_is_last || last3_is_last2 || last3_is_alt) - flags &= ~VPX_LAST3_FLAG; + if (last3_is_last || last3_is_last2 || last3_is_alt) flags &= ~VPX_LAST3_FLAG; - if (gld_is_last2 || gld_is_last3) - flags &= ~VPX_GOLD_FLAG; + if (gld_is_last2 || gld_is_last3) flags &= ~VPX_GOLD_FLAG; - if ((bwd_is_last || bwd_is_last2 || bwd_is_last3 || - bwd_is_gld || bwd_is_alt) && (flags & VPX_BWD_FLAG)) + if ((bwd_is_last || bwd_is_last2 || bwd_is_last3 || bwd_is_gld || + bwd_is_alt) && + (flags & VPX_BWD_FLAG)) flags &= ~VPX_BWD_FLAG; #endif // CONFIG_EXT_REFS @@ -4621,13 +4240,12 @@ static void set_ext_overrides(VP10_COMP *cpi) { } YV12_BUFFER_CONFIG *vp10_scale_if_required_fast(VP10_COMMON *cm, - YV12_BUFFER_CONFIG *unscaled, - YV12_BUFFER_CONFIG *scaled) { + YV12_BUFFER_CONFIG *unscaled, + YV12_BUFFER_CONFIG *scaled) { if (cm->mi_cols * MI_SIZE != unscaled->y_width || cm->mi_rows * MI_SIZE != unscaled->y_height) { // For 2x2 scaling down. - vpx_scale_frame(unscaled, scaled, unscaled->y_buffer, 9, 2, 1, - 2, 1, 0); + vpx_scale_frame(unscaled, scaled, unscaled->y_buffer, 9, 2, 1, 2, 1, 0); vpx_extend_frame_borders(scaled); return scaled; } else { @@ -4636,8 +4254,8 @@ YV12_BUFFER_CONFIG *vp10_scale_if_required_fast(VP10_COMMON *cm, } YV12_BUFFER_CONFIG *vp10_scale_if_required(VP10_COMMON *cm, - YV12_BUFFER_CONFIG *unscaled, - YV12_BUFFER_CONFIG *scaled) { + YV12_BUFFER_CONFIG *unscaled, + YV12_BUFFER_CONFIG *scaled) { if (cm->mi_cols * MI_SIZE != unscaled->y_width || cm->mi_rows * MI_SIZE != unscaled->y_height) { #if CONFIG_VP9_HIGHBITDEPTH @@ -4662,7 +4280,7 @@ static void set_arf_sign_bias(VP10_COMP *cpi) { (gf_group->rf_level[gf_group->index] == GF_ARF_LOW)); } else { arf_sign_bias = - (cpi->rc.source_alt_ref_active && !cpi->refresh_alt_ref_frame); + (cpi->rc.source_alt_ref_active && !cpi->refresh_alt_ref_frame); } cm->ref_frame_sign_bias[ALTREF_FRAME] = arf_sign_bias; #if CONFIG_EXT_REFS @@ -4672,11 +4290,10 @@ static void set_arf_sign_bias(VP10_COMP *cpi) { static int setup_interp_filter_search_mask(VP10_COMP *cpi) { INTERP_FILTER ifilter; - int ref_total[TOTAL_REFS_PER_FRAME] = {0}; + int ref_total[TOTAL_REFS_PER_FRAME] = { 0 }; MV_REFERENCE_FRAME ref; int mask = 0; - if (cpi->common.last_frame_type == KEY_FRAME || - cpi->refresh_alt_ref_frame) + if (cpi->common.last_frame_type == KEY_FRAME || cpi->refresh_alt_ref_frame) return mask; for (ref = LAST_FRAME; ref <= ALTREF_FRAME; ++ref) for (ifilter = EIGHTTAP_REGULAR; ifilter < SWITCHABLE_FILTERS; ++ifilter) @@ -4684,26 +4301,26 @@ static int setup_interp_filter_search_mask(VP10_COMP *cpi) { for (ifilter = EIGHTTAP_REGULAR; ifilter < SWITCHABLE_FILTERS; ++ifilter) { if ((ref_total[LAST_FRAME] && - cpi->interp_filter_selected[LAST_FRAME][ifilter] == 0) && + cpi->interp_filter_selected[LAST_FRAME][ifilter] == 0) && #if CONFIG_EXT_REFS (ref_total[LAST2_FRAME] == 0 || - cpi->interp_filter_selected[LAST2_FRAME][ifilter] * 50 - < ref_total[LAST2_FRAME]) && + cpi->interp_filter_selected[LAST2_FRAME][ifilter] * 50 < + ref_total[LAST2_FRAME]) && (ref_total[LAST3_FRAME] == 0 || - cpi->interp_filter_selected[LAST3_FRAME][ifilter] * 50 - < ref_total[LAST3_FRAME]) && + cpi->interp_filter_selected[LAST3_FRAME][ifilter] * 50 < + ref_total[LAST3_FRAME]) && #endif // CONFIG_EXT_REFS (ref_total[GOLDEN_FRAME] == 0 || - cpi->interp_filter_selected[GOLDEN_FRAME][ifilter] * 50 - < ref_total[GOLDEN_FRAME]) && + cpi->interp_filter_selected[GOLDEN_FRAME][ifilter] * 50 < + ref_total[GOLDEN_FRAME]) && #if CONFIG_EXT_REFS (ref_total[BWDREF_FRAME] == 0 || - cpi->interp_filter_selected[BWDREF_FRAME][ifilter] * 50 - < ref_total[BWDREF_FRAME]) && + cpi->interp_filter_selected[BWDREF_FRAME][ifilter] * 50 < + ref_total[BWDREF_FRAME]) && #endif // CONFIG_EXT_REFS (ref_total[ALTREF_FRAME] == 0 || - cpi->interp_filter_selected[ALTREF_FRAME][ifilter] * 50 - < ref_total[ALTREF_FRAME])) + cpi->interp_filter_selected[ALTREF_FRAME][ifilter] * 50 < + ref_total[ALTREF_FRAME])) mask |= 1 << ifilter; } return mask; @@ -4737,35 +4354,35 @@ static void dump_filtered_recon_frames(VP10_COMP *cpi) { return; } } - printf("\nFrame=%5d, encode_update_type[%5d]=%1d, show_existing_frame=%d, " - "y_stride=%4d, uv_stride=%4d, width=%4d, height=%4d\n", - cm->current_video_frame, cpi->twopass.gf_group.index, - cpi->twopass.gf_group.update_type[cpi->twopass.gf_group.index], - cm->show_existing_frame, - recon_buf->y_stride, recon_buf->uv_stride, cm->width, cm->height); + printf( + "\nFrame=%5d, encode_update_type[%5d]=%1d, show_existing_frame=%d, " + "y_stride=%4d, uv_stride=%4d, width=%4d, height=%4d\n", + cm->current_video_frame, cpi->twopass.gf_group.index, + cpi->twopass.gf_group.update_type[cpi->twopass.gf_group.index], + cm->show_existing_frame, recon_buf->y_stride, recon_buf->uv_stride, + cm->width, cm->height); // --- Y --- for (h = 0; h < cm->height; ++h) { - fwrite(&recon_buf->y_buffer[h*recon_buf->y_stride], - 1, cm->width, f_recon); + fwrite(&recon_buf->y_buffer[h * recon_buf->y_stride], 1, cm->width, + f_recon); } // --- U --- for (h = 0; h < (cm->height >> 1); ++h) { - fwrite(&recon_buf->u_buffer[h*recon_buf->uv_stride], - 1, (cm->width >> 1), f_recon); + fwrite(&recon_buf->u_buffer[h * recon_buf->uv_stride], 1, (cm->width >> 1), + f_recon); } // --- V --- for (h = 0; h < (cm->height >> 1); ++h) { - fwrite(&recon_buf->v_buffer[h*recon_buf->uv_stride], - 1, (cm->width >> 1), f_recon); + fwrite(&recon_buf->v_buffer[h * recon_buf->uv_stride], 1, (cm->width >> 1), + f_recon); } fclose(f_recon); } #endif // DUMP_RECON_FRAMES -static void encode_frame_to_data_rate(VP10_COMP *cpi, - size_t *size, +static void encode_frame_to_data_rate(VP10_COMP *cpi, size_t *size, uint8_t *dest, unsigned int *frame_flags) { VP10_COMMON *const cm = &cpi->common; @@ -4850,10 +4467,8 @@ static void encode_frame_to_data_rate(VP10_COMP *cpi, // Set default state for segment based loop filter update flags. cm->lf.mode_ref_delta_update = 0; - if (cpi->oxcf.pass == 2 && - cpi->sf.adaptive_interp_filter_search) - cpi->sf.interp_filter_search_mask = - setup_interp_filter_search_mask(cpi); + if (cpi->oxcf.pass == 2 && cpi->sf.adaptive_interp_filter_search) + cpi->sf.interp_filter_search_mask = setup_interp_filter_search_mask(cpi); // Set various flags etc to special state if it is a key frame. if (frame_is_intra_only(cm)) { @@ -4883,8 +4498,7 @@ static void encode_frame_to_data_rate(VP10_COMP *cpi, // For 1 pass CBR, check if we are dropping this frame. // Never drop on key frame. - if (oxcf->pass == 0 && - oxcf->rc_mode == VPX_CBR && + if (oxcf->pass == 0 && oxcf->rc_mode == VPX_CBR && cm->frame_type != KEY_FRAME) { if (vp10_rc_drop_frame(cpi)) { vp10_rc_postencode_update_drop_frame(cpi); @@ -4918,8 +4532,8 @@ static void encode_frame_to_data_rate(VP10_COMP *cpi, if (cpi->rc.next_key_frame_forced && cpi->rc.frames_to_key == 1) { #if CONFIG_VP9_HIGHBITDEPTH if (cm->use_highbitdepth) { - cpi->ambient_err = vpx_highbd_get_y_sse(cpi->Source, - get_frame_new_buffer(cm)); + cpi->ambient_err = + vpx_highbd_get_y_sse(cpi->Source, get_frame_new_buffer(cm)); } else { cpi->ambient_err = vpx_get_y_sse(cpi->Source, get_frame_new_buffer(cm)); } @@ -4936,12 +4550,12 @@ static void encode_frame_to_data_rate(VP10_COMP *cpi, cm->frame_to_show = get_frame_new_buffer(cm); cm->frame_to_show->color_space = cm->color_space; cm->frame_to_show->color_range = cm->color_range; - cm->frame_to_show->render_width = cm->render_width; + cm->frame_to_show->render_width = cm->render_width; cm->frame_to_show->render_height = cm->render_height; #if CONFIG_EXT_REFS - // TODO(zoeliu): For non-ref frames, loop filtering may need to be turned - // off. +// TODO(zoeliu): For non-ref frames, loop filtering may need to be turned +// off. #endif // CONFIG_EXT_REFS // Pick the loop filter level for the frame. @@ -4952,12 +4566,10 @@ static void encode_frame_to_data_rate(VP10_COMP *cpi, #if DUMP_RECON_FRAMES == 1 // NOTE(zoeliu): For debug - Output the filtered reconstructed video. - if (cm->show_frame) - dump_filtered_recon_frames(cpi); + if (cm->show_frame) dump_filtered_recon_frames(cpi); #endif // DUMP_RECON_FRAMES - if (cm->seg.update_map) - update_reference_segmentation_map(cpi); + if (cm->seg.update_map) update_reference_segmentation_map(cpi); if (frame_is_intra_only(cm) == 0) { release_scaled_references(cpi); @@ -5035,13 +4647,12 @@ static void encode_frame_to_data_rate(VP10_COMP *cpi, cm->last_height = cm->height; // reset to normal state now that we are done. - if (!cm->show_existing_frame) - cm->last_show_frame = cm->show_frame; + if (!cm->show_existing_frame) cm->last_show_frame = cm->show_frame; if (cm->show_frame) { #if CONFIG_EXT_REFS - // TODO(zoeliu): We may only swamp mi and prev_mi for those frames that are - // being used as reference. +// TODO(zoeliu): We may only swamp mi and prev_mi for those frames that are +// being used as reference. #endif // CONFIG_EXT_REFS vp10_swap_mi_and_prev_mi(cm); // Don't increment frame counters if this was an altref buffer @@ -5066,8 +4677,8 @@ static void Pass0Encode(VP10_COMP *cpi, size_t *size, uint8_t *dest, encode_frame_to_data_rate(cpi, size, dest, frame_flags); } -static void Pass2Encode(VP10_COMP *cpi, size_t *size, - uint8_t *dest, unsigned int *frame_flags) { +static void Pass2Encode(VP10_COMP *cpi, size_t *size, uint8_t *dest, + unsigned int *frame_flags) { cpi->allow_encode_breakout = ENCODE_BREAKOUT_ENABLED; encode_frame_to_data_rate(cpi, size, dest, frame_flags); @@ -5127,8 +4738,8 @@ static void check_initial_width(VP10_COMP *cpi, } int vp10_receive_raw_frame(VP10_COMP *cpi, unsigned int frame_flags, - YV12_BUFFER_CONFIG *sd, int64_t time_stamp, - int64_t end_time) { + YV12_BUFFER_CONFIG *sd, int64_t time_stamp, + int64_t end_time) { VP10_COMMON *const cm = &cpi->common; struct vpx_usec_timer timer; int res = 0; @@ -5148,9 +4759,9 @@ int vp10_receive_raw_frame(VP10_COMP *cpi, unsigned int frame_flags, if (vp10_lookahead_push(cpi->lookahead, sd, time_stamp, end_time, #if CONFIG_VP9_HIGHBITDEPTH - use_highbitdepth, + use_highbitdepth, #endif // CONFIG_VP9_HIGHBITDEPTH - frame_flags)) + frame_flags)) res = -1; vpx_usec_timer_mark(&timer); cpi->time_receive_data += vpx_usec_timer_elapsed(&timer); @@ -5171,20 +4782,16 @@ int vp10_receive_raw_frame(VP10_COMP *cpi, unsigned int frame_flags, return res; } - static int frame_is_reference(const VP10_COMP *cpi) { const VP10_COMMON *cm = &cpi->common; - return cm->frame_type == KEY_FRAME || - cpi->refresh_last_frame || + return cm->frame_type == KEY_FRAME || cpi->refresh_last_frame || cpi->refresh_golden_frame || #if CONFIG_EXT_REFS cpi->refresh_bwd_ref_frame || #endif // CONFIG_EXT_REFS - cpi->refresh_alt_ref_frame || - !cm->error_resilient_mode || - cm->lf.mode_ref_delta_update || - cm->seg.update_map || + cpi->refresh_alt_ref_frame || !cm->error_resilient_mode || + cm->lf.mode_ref_delta_update || cm->seg.update_map || cm->seg.update_data; } @@ -5197,8 +4804,8 @@ static void adjust_frame_rate(VP10_COMP *cpi, this_duration = source->ts_end - source->ts_start; step = 1; } else { - int64_t last_duration = cpi->last_end_time_stamp_seen - - cpi->last_time_stamp_seen; + int64_t last_duration = + cpi->last_end_time_stamp_seen - cpi->last_time_stamp_seen; this_duration = source->ts_end - cpi->last_end_time_stamp_seen; @@ -5273,10 +4880,10 @@ static void check_src_altref(VP10_COMP *cpi, if (cpi->oxcf.pass == 2) { const GF_GROUP *const gf_group = &cpi->twopass.gf_group; rc->is_src_frame_alt_ref = - (gf_group->update_type[gf_group->index] == OVERLAY_UPDATE); + (gf_group->update_type[gf_group->index] == OVERLAY_UPDATE); } else { - rc->is_src_frame_alt_ref = cpi->alt_ref_source && - (source == cpi->alt_ref_source); + rc->is_src_frame_alt_ref = + cpi->alt_ref_source && (source == cpi->alt_ref_source); } if (rc->is_src_frame_alt_ref) { @@ -5291,8 +4898,8 @@ static void check_src_altref(VP10_COMP *cpi, #if CONFIG_INTERNAL_STATS extern double vp10_get_blockiness(const unsigned char *img1, int img1_pitch, - const unsigned char *img2, int img2_pitch, - int width, int height); + const unsigned char *img2, int img2_pitch, + int width, int height); static void adjust_image_stat(double y, double u, double v, double all, ImageStat *s) { @@ -5325,30 +4932,30 @@ static void compute_internal_stats(VP10_COMP *cpi) { PSNR_STATS psnr; double frame_ssim2 = 0.0, weight = 0.0; vpx_clear_system_state(); - // TODO(yaowu): unify these two versions into one. +// TODO(yaowu): unify these two versions into one. #if CONFIG_VP9_HIGHBITDEPTH vpx_calc_highbd_psnr(orig, recon, &psnr, bit_depth, in_bit_depth); #else vpx_calc_psnr(orig, recon, &psnr); #endif // CONFIG_VP9_HIGHBITDEPTH - adjust_image_stat(psnr.psnr[1], psnr.psnr[2], psnr.psnr[3], - psnr.psnr[0], &cpi->psnr); + adjust_image_stat(psnr.psnr[1], psnr.psnr[2], psnr.psnr[3], psnr.psnr[0], + &cpi->psnr); cpi->total_sq_error += psnr.sse[0]; cpi->total_samples += psnr.samples[0]; samples = psnr.samples[0]; - // TODO(yaowu): unify these two versions into one. +// TODO(yaowu): unify these two versions into one. #if CONFIG_VP9_HIGHBITDEPTH if (cm->use_highbitdepth) - frame_ssim2 = vpx_highbd_calc_ssim(orig, recon, &weight, - bit_depth, in_bit_depth); + frame_ssim2 = + vpx_highbd_calc_ssim(orig, recon, &weight, bit_depth, in_bit_depth); else frame_ssim2 = vpx_calc_ssim(orig, recon, &weight); #else frame_ssim2 = vpx_calc_ssim(orig, recon, &weight); #endif // CONFIG_VP9_HIGHBITDEPTH - cpi->worst_ssim= VPXMIN(cpi->worst_ssim, frame_ssim2); + cpi->worst_ssim = VPXMIN(cpi->worst_ssim, frame_ssim2); cpi->summed_quality += frame_ssim2 * weight; cpi->summed_weights += weight; @@ -5367,9 +4974,9 @@ static void compute_internal_stats(VP10_COMP *cpi) { if (!cm->use_highbitdepth) #endif { - const double frame_blockiness = vp10_get_blockiness( - orig->y_buffer, orig->y_stride, recon->y_buffer, recon->y_stride, - orig->y_width, orig->y_height); + const double frame_blockiness = + vp10_get_blockiness(orig->y_buffer, orig->y_stride, recon->y_buffer, + recon->y_stride, orig->y_width, orig->y_height); cpi->worst_blockiness = VPXMAX(cpi->worst_blockiness, frame_blockiness); cpi->total_blockiness += frame_blockiness; } @@ -5384,8 +4991,8 @@ static void compute_internal_stats(VP10_COMP *cpi) { orig->y_width, orig->y_height, cpi->ssim_vars, &cpi->metrics, 1); const double peak = (double)((1 << in_bit_depth) - 1); - const double consistency = vpx_sse_to_psnr( - samples, peak, cpi->total_inconsistency); + const double consistency = + vpx_sse_to_psnr(samples, peak, cpi->total_inconsistency); if (consistency > 0.0) cpi->worst_consistency = VPXMIN(cpi->worst_consistency, consistency); @@ -5394,8 +5001,8 @@ static void compute_internal_stats(VP10_COMP *cpi) { } } - frame_all = vpx_calc_fastssim(orig, recon, &y, &u, &v, - bit_depth, in_bit_depth); + frame_all = + vpx_calc_fastssim(orig, recon, &y, &u, &v, bit_depth, in_bit_depth); adjust_image_stat(y, u, v, frame_all, &cpi->fastssim); frame_all = vpx_psnrhvs(orig, recon, &y, &u, &v, bit_depth, in_bit_depth); adjust_image_stat(y, u, v, frame_all, &cpi->psnrhvs); @@ -5404,13 +5011,13 @@ static void compute_internal_stats(VP10_COMP *cpi) { #endif // CONFIG_INTERNAL_STATS int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, - size_t *size, uint8_t *dest, - int64_t *time_stamp, int64_t *time_end, int flush) { + size_t *size, uint8_t *dest, int64_t *time_stamp, + int64_t *time_end, int flush) { const VP10EncoderConfig *const oxcf = &cpi->oxcf; VP10_COMMON *const cm = &cpi->common; BufferPool *const pool = cm->buffer_pool; RATE_CONTROL *const rc = &cpi->rc; - struct vpx_usec_timer cmptimer; + struct vpx_usec_timer cmptimer; YV12_BUFFER_CONFIG *force_src_buffer = NULL; struct lookahead_entry *last_source = NULL; struct lookahead_entry *source = NULL; @@ -5440,8 +5047,9 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, // Normal defaults cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE; cm->refresh_frame_context = - (oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode) ? - REFRESH_FRAME_CONTEXT_FORWARD : REFRESH_FRAME_CONTEXT_BACKWARD; + (oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode) + ? REFRESH_FRAME_CONTEXT_FORWARD + : REFRESH_FRAME_CONTEXT_BACKWARD; cpi->refresh_last_frame = 1; cpi->refresh_golden_frame = 0; @@ -5477,8 +5085,7 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, } cm->new_fb_idx = get_free_fb(cm); - if (cm->new_fb_idx == INVALID_IDX) - return -1; + if (cm->new_fb_idx == INVALID_IDX) return -1; // Clear down mmx registers vpx_clear_system_state(); @@ -5493,8 +5100,7 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, Pass2Encode(cpi, size, dest, frame_flags); - if (cpi->b_calculate_psnr) - generate_psnr_packet(cpi); + if (cpi->b_calculate_psnr) generate_psnr_packet(cpi); #if CONFIG_INTERNAL_STATS compute_internal_stats(cpi); @@ -5588,8 +5194,8 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, } if (source) { - cpi->un_scaled_source = cpi->Source = force_src_buffer ? force_src_buffer - : &source->img; + cpi->un_scaled_source = cpi->Source = + force_src_buffer ? force_src_buffer : &source->img; cpi->unscaled_last_source = last_source != NULL ? &last_source->img : NULL; @@ -5600,7 +5206,7 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, } else { *size = 0; if (flush && oxcf->pass == 1 && !cpi->twopass.first_pass_done) { - vp10_end_first_pass(cpi); /* get last stats packet */ + vp10_end_first_pass(cpi); /* get last stats packet */ cpi->twopass.first_pass_done = 1; } return -1; @@ -5615,8 +5221,7 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, vpx_clear_system_state(); // adjust frame rates based on timestamps given - if (cm->show_frame) - adjust_frame_rate(cpi, source); + if (cm->show_frame) adjust_frame_rate(cpi, source); // Find a free buffer for the new frame, releasing the reference previously // held. @@ -5625,8 +5230,7 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, } cm->new_fb_idx = get_free_fb(cm); - if (cm->new_fb_idx == INVALID_IDX) - return -1; + if (cm->new_fb_idx == INVALID_IDX) return -1; cm->cur_frame = &pool->frame_bufs[cm->new_fb_idx]; @@ -5717,21 +5321,19 @@ int vp10_get_preview_raw_frame(VP10_COMP *cpi, YV12_BUFFER_CONFIG *dest) { } int vp10_get_last_show_frame(VP10_COMP *cpi, YV12_BUFFER_CONFIG *frame) { - if (cpi->last_show_frame_buf_idx == INVALID_IDX) - return -1; + if (cpi->last_show_frame_buf_idx == INVALID_IDX) return -1; *frame = cpi->common.buffer_pool->frame_bufs[cpi->last_show_frame_buf_idx].buf; return 0; } -int vp10_set_internal_size(VP10_COMP *cpi, - VPX_SCALING horiz_mode, VPX_SCALING vert_mode) { +int vp10_set_internal_size(VP10_COMP *cpi, VPX_SCALING horiz_mode, + VPX_SCALING vert_mode) { VP10_COMMON *cm = &cpi->common; int hr = 0, hs = 0, vr = 0, vs = 0; - if (horiz_mode > ONETWO || vert_mode > ONETWO) - return -1; + if (horiz_mode > ONETWO || vert_mode > ONETWO) return -1; Scale2Ratio(horiz_mode, &hr, &hs); Scale2Ratio(vert_mode, &vr, &vs); @@ -5748,7 +5350,7 @@ int vp10_set_internal_size(VP10_COMP *cpi, } int vp10_set_size_literal(VP10_COMP *cpi, unsigned int width, - unsigned int height) { + unsigned int height) { VP10_COMMON *cm = &cpi->common; #if CONFIG_VP9_HIGHBITDEPTH check_initial_width(cpi, cm->use_highbitdepth, 1, 1); @@ -5779,13 +5381,11 @@ int vp10_set_size_literal(VP10_COMP *cpi, unsigned int width, return 0; } -int vp10_get_quantizer(VP10_COMP *cpi) { - return cpi->common.base_qindex; -} +int vp10_get_quantizer(VP10_COMP *cpi) { return cpi->common.base_qindex; } void vp10_apply_encoding_flags(VP10_COMP *cpi, vpx_enc_frame_flags_t flags) { - if (flags & (VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF | - VP8_EFLAG_NO_REF_ARF)) { + if (flags & + (VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF)) { int ref = VPX_REFFRAME_ALL; if (flags & VP8_EFLAG_NO_REF_LAST) { @@ -5796,18 +5396,16 @@ void vp10_apply_encoding_flags(VP10_COMP *cpi, vpx_enc_frame_flags_t flags) { #endif // CONFIG_EXT_REFS } - if (flags & VP8_EFLAG_NO_REF_GF) - ref ^= VPX_GOLD_FLAG; + if (flags & VP8_EFLAG_NO_REF_GF) ref ^= VPX_GOLD_FLAG; - if (flags & VP8_EFLAG_NO_REF_ARF) - ref ^= VPX_ALT_FLAG; + if (flags & VP8_EFLAG_NO_REF_ARF) ref ^= VPX_ALT_FLAG; vp10_use_as_reference(cpi, ref); } - if (flags & (VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF | - VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_FORCE_GF | - VP8_EFLAG_FORCE_ARF)) { + if (flags & + (VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | + VP8_EFLAG_FORCE_GF | VP8_EFLAG_FORCE_ARF)) { int upd = VPX_REFFRAME_ALL; if (flags & VP8_EFLAG_NO_UPD_LAST) { @@ -5818,11 +5416,9 @@ void vp10_apply_encoding_flags(VP10_COMP *cpi, vpx_enc_frame_flags_t flags) { #endif // CONFIG_EXT_REFS } - if (flags & VP8_EFLAG_NO_UPD_GF) - upd ^= VPX_GOLD_FLAG; + if (flags & VP8_EFLAG_NO_UPD_GF) upd ^= VPX_GOLD_FLAG; - if (flags & VP8_EFLAG_NO_UPD_ARF) - upd ^= VPX_ALT_FLAG; + if (flags & VP8_EFLAG_NO_UPD_ARF) upd ^= VPX_ALT_FLAG; vp10_update_reference(cpi, upd); } diff --git a/vp10/encoder/encoder.h b/vp10/encoder/encoder.h index b5c8320b1..c64a96816 100644 --- a/vp10/encoder/encoder.h +++ b/vp10/encoder/encoder.h @@ -94,10 +94,10 @@ typedef enum { } ENCODE_BREAKOUT_TYPE; typedef enum { - NORMAL = 0, - FOURFIVE = 1, - THREEFIVE = 2, - ONETWO = 3 + NORMAL = 0, + FOURFIVE = 1, + THREEFIVE = 2, + ONETWO = 3 } VPX_SCALING; typedef enum { @@ -117,7 +117,7 @@ typedef enum { } MODE; typedef enum { - FRAMEFLAGS_KEY = 1 << 0, + FRAMEFLAGS_KEY = 1 << 0, FRAMEFLAGS_GOLDEN = 1 << 1, #if CONFIG_EXT_REFS FRAMEFLAGS_BWDREF = 1 << 2, @@ -144,14 +144,14 @@ typedef enum { typedef struct VP10EncoderConfig { BITSTREAM_PROFILE profile; vpx_bit_depth_t bit_depth; // Codec bit-depth. - int width; // width of data passed to the compressor - int height; // height of data passed to the compressor + int width; // width of data passed to the compressor + int height; // height of data passed to the compressor unsigned int input_bit_depth; // Input bit depth. - double init_framerate; // set to passed in framerate - int64_t target_bandwidth; // bandwidth to be used in bits per second + double init_framerate; // set to passed in framerate + int64_t target_bandwidth; // bandwidth to be used in bits per second int noise_sensitivity; // pre processing blur: recommendation 0 - int sharpness; // sharpening output: recommendation 0: + int sharpness; // sharpening output: recommendation 0: int speed; // maximum allowed bitrate for any intra frame in % of bitrate target. unsigned int rc_max_intra_bitrate_pct; @@ -203,7 +203,7 @@ typedef struct VP10EncoderConfig { int frame_periodic_boost; // two pass datarate control - int two_pass_vbrbias; // two pass datarate control tweaks + int two_pass_vbrbias; // two pass datarate control tweaks int two_pass_vbrmin_section; int two_pass_vbrmax_section; // END DATARATE CONTROL OPTIONS @@ -212,7 +212,7 @@ typedef struct VP10EncoderConfig { int enable_auto_arf; #if CONFIG_EXT_REFS int enable_auto_brf; // (b)ackward (r)ef (f)rame -#endif // CONFIG_EXT_REFS +#endif // CONFIG_EXT_REFS int encode_breakout; // early breakout : for video conf recommend 800 @@ -300,15 +300,10 @@ typedef struct ActiveMap { unsigned char *map; } ActiveMap; -typedef enum { - Y, - U, - V, - ALL -} STAT_TYPE; +typedef enum { Y, U, V, ALL } STAT_TYPE; typedef struct IMAGE_STAT { - double stat[ALL+1]; + double stat[ALL + 1]; double worst; } ImageStat; @@ -319,13 +314,10 @@ typedef struct { #if CONFIG_ENTROPY typedef struct SUBFRAME_STATS { - vp10_coeff_probs_model - coef_probs_buf[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES]; - vp10_coeff_count - coef_counts_buf[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES]; - unsigned int - eob_counts_buf[COEF_PROBS_BUFS] - [TX_SIZES][PLANE_TYPES][REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]; + vp10_coeff_probs_model coef_probs_buf[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES]; + vp10_coeff_count coef_counts_buf[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES]; + unsigned int eob_counts_buf[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES][REF_TYPES] + [COEF_BANDS][COEFF_CONTEXTS]; vp10_coeff_probs_model enc_starting_coef_probs[TX_SIZES][PLANE_TYPES]; } SUBFRAME_STATS; #endif // CONFIG_ENTROPY @@ -349,8 +341,8 @@ typedef struct VP10_COMP { #endif // CONFIG_NEW_QUANT VP10_COMMON common; VP10EncoderConfig oxcf; - struct lookahead_ctx *lookahead; - struct lookahead_entry *alt_ref_source; + struct lookahead_ctx *lookahead; + struct lookahead_entry *alt_ref_source; YV12_BUFFER_CONFIG *Source; YV12_BUFFER_CONFIG *Last_Source; // NULL for first frame and alt_ref frames @@ -378,7 +370,7 @@ typedef struct VP10_COMP { int gld_fb_idx; #if CONFIG_EXT_REFS int bwd_fb_idx; // BWD_REF_FRAME -#endif // CONFIG_EXT_REFS +#endif // CONFIG_EXT_REFS int alt_fb_idx; int last_show_frame_buf_idx; // last show frame buffer index @@ -432,11 +424,11 @@ typedef struct VP10_COMP { // sufficient space to the size of the maximum possible number of frames. int interp_filter_selected[REF_FRAMES + 1][SWITCHABLE]; - struct vpx_codec_pkt_list *output_pkt_list; + struct vpx_codec_pkt_list *output_pkt_list; MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS]; - int mbgraph_n_frames; // number of frames filled in the above - int static_mb_pct; // % forced skip mbs by segmentation + int mbgraph_n_frames; // number of frames filled in the above + int static_mb_pct; // % forced skip mbs by segmentation int ref_frame_flags; SPEED_FEATURES sf; @@ -456,7 +448,7 @@ typedef struct VP10_COMP { uint8_t *segmentation_map; // segment threashold for encode breakout - int segment_encode_breakout[MAX_SEGMENTS]; + int segment_encode_breakout[MAX_SEGMENTS]; CYCLIC_REFRESH *cyclic_refresh; ActiveMap active_map; @@ -481,7 +473,7 @@ typedef struct VP10_COMP { #if CONFIG_INTERNAL_STATS unsigned int mode_chosen_counts[MAX_MODES]; - int count; + int count; uint64_t total_sq_error; uint64_t total_samples; ImageStat psnr; @@ -489,7 +481,7 @@ typedef struct VP10_COMP { double total_blockiness; double worst_blockiness; - int bytes; + int bytes; double summed_quality; double summed_weights; unsigned int tot_recode_hits; @@ -540,8 +532,8 @@ typedef struct VP10_COMP { unsigned int inter_mode_cost[INTER_MODE_CONTEXTS][INTER_MODES]; #if CONFIG_EXT_INTER - unsigned int inter_compound_mode_cost[INTER_MODE_CONTEXTS] - [INTER_COMPOUND_MODES]; + unsigned int + inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES]; unsigned int interintra_mode_cost[BLOCK_SIZE_GROUPS][INTERINTRA_MODES]; #endif // CONFIG_EXT_INTER #if CONFIG_OBMC || CONFIG_WARPED_MOTION @@ -557,15 +549,15 @@ typedef struct VP10_COMP { #endif int palette_y_size_cost[PALETTE_BLOCK_SIZES][PALETTE_SIZES]; int palette_uv_size_cost[PALETTE_BLOCK_SIZES][PALETTE_SIZES]; - int palette_y_color_cost[PALETTE_MAX_SIZE - 1][PALETTE_COLOR_CONTEXTS] - [PALETTE_COLORS]; - int palette_uv_color_cost[PALETTE_MAX_SIZE - 1][PALETTE_COLOR_CONTEXTS] - [PALETTE_COLORS]; + int palette_y_color_cost[PALETTE_MAX_SIZE - + 1][PALETTE_COLOR_CONTEXTS][PALETTE_COLORS]; + int palette_uv_color_cost[PALETTE_MAX_SIZE - + 1][PALETTE_COLOR_CONTEXTS][PALETTE_COLORS]; int tx_size_cost[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES]; #if CONFIG_EXT_TX int inter_tx_type_costs[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES]; int intra_tx_type_costs[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES] - [TX_TYPES]; + [TX_TYPES]; #else int intra_tx_type_costs[EXT_TX_SIZES][TX_TYPES][TX_TYPES]; int inter_tx_type_costs[EXT_TX_SIZES][TX_TYPES]; @@ -635,20 +627,20 @@ typedef struct VP10_COMP { void vp10_initialize_enc(void); struct VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf, - BufferPool *const pool); + BufferPool *const pool); void vp10_remove_compressor(VP10_COMP *cpi); void vp10_change_config(VP10_COMP *cpi, const VP10EncoderConfig *oxcf); - // receive a frames worth of data. caller can assume that a copy of this - // frame is made and not just a copy of the pointer.. +// receive a frames worth of data. caller can assume that a copy of this +// frame is made and not just a copy of the pointer.. int vp10_receive_raw_frame(VP10_COMP *cpi, unsigned int frame_flags, - YV12_BUFFER_CONFIG *sd, int64_t time_stamp, - int64_t end_time_stamp); + YV12_BUFFER_CONFIG *sd, int64_t time_stamp, + int64_t end_time_stamp); int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, - size_t *size, uint8_t *dest, - int64_t *time_stamp, int64_t *time_end, int flush); + size_t *size, uint8_t *dest, int64_t *time_stamp, + int64_t *time_end, int flush); int vp10_get_preview_raw_frame(VP10_COMP *cpi, YV12_BUFFER_CONFIG *dest); @@ -659,10 +651,10 @@ int vp10_use_as_reference(VP10_COMP *cpi, int ref_frame_flags); void vp10_update_reference(VP10_COMP *cpi, int ref_frame_flags); int vp10_copy_reference_enc(VP10_COMP *cpi, VPX_REFFRAME ref_frame_flag, - YV12_BUFFER_CONFIG *sd); + YV12_BUFFER_CONFIG *sd); int vp10_set_reference_enc(VP10_COMP *cpi, VPX_REFFRAME ref_frame_flag, - YV12_BUFFER_CONFIG *sd); + YV12_BUFFER_CONFIG *sd); int vp10_update_entropy(VP10_COMP *cpi, int update); @@ -670,11 +662,11 @@ int vp10_set_active_map(VP10_COMP *cpi, unsigned char *map, int rows, int cols); int vp10_get_active_map(VP10_COMP *cpi, unsigned char *map, int rows, int cols); -int vp10_set_internal_size(VP10_COMP *cpi, - VPX_SCALING horiz_mode, VPX_SCALING vert_mode); +int vp10_set_internal_size(VP10_COMP *cpi, VPX_SCALING horiz_mode, + VPX_SCALING vert_mode); int vp10_set_size_literal(VP10_COMP *cpi, unsigned int width, - unsigned int height); + unsigned int height); int vp10_get_quantizer(struct VP10_COMP *cpi); @@ -682,8 +674,7 @@ void vp10_full_to_model_counts(vp10_coeff_count_model *model_count, vp10_coeff_count *full_count); static INLINE int frame_is_kf_gf_arf(const VP10_COMP *cpi) { - return frame_is_intra_only(&cpi->common) || - cpi->refresh_alt_ref_frame || + return frame_is_intra_only(&cpi->common) || cpi->refresh_alt_ref_frame || (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref); } @@ -693,8 +684,7 @@ static INLINE int get_ref_frame_map_idx(const VP10_COMP *cpi, if (ref_frame >= LAST_FRAME && ref_frame <= LAST3_FRAME) return cpi->lst_fb_idxes[ref_frame - 1]; #else - if (ref_frame == LAST_FRAME) - return cpi->lst_fb_idx; + if (ref_frame == LAST_FRAME) return cpi->lst_fb_idx; #endif // CONFIG_EXT_REFS else if (ref_frame == GOLDEN_FRAME) return cpi->gld_fb_idx; @@ -717,8 +707,8 @@ static INLINE YV12_BUFFER_CONFIG *get_ref_frame_buffer( VP10_COMP *cpi, MV_REFERENCE_FRAME ref_frame) { VP10_COMMON *const cm = &cpi->common; const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame); - return - buf_idx != INVALID_IDX ? &cm->buffer_pool->frame_bufs[buf_idx].buf : NULL; + return buf_idx != INVALID_IDX ? &cm->buffer_pool->frame_bufs[buf_idx].buf + : NULL; } static INLINE const YV12_BUFFER_CONFIG *get_upsampled_ref( @@ -770,12 +760,12 @@ void vp10_update_reference_frames(VP10_COMP *cpi); void vp10_set_high_precision_mv(VP10_COMP *cpi, int allow_high_precision_mv); YV12_BUFFER_CONFIG *vp10_scale_if_required_fast(VP10_COMMON *cm, - YV12_BUFFER_CONFIG *unscaled, - YV12_BUFFER_CONFIG *scaled); + YV12_BUFFER_CONFIG *unscaled, + YV12_BUFFER_CONFIG *scaled); YV12_BUFFER_CONFIG *vp10_scale_if_required(VP10_COMMON *cm, - YV12_BUFFER_CONFIG *unscaled, - YV12_BUFFER_CONFIG *scaled); + YV12_BUFFER_CONFIG *unscaled, + YV12_BUFFER_CONFIG *scaled); void vp10_apply_encoding_flags(VP10_COMP *cpi, vpx_enc_frame_flags_t flags); @@ -797,10 +787,10 @@ static INLINE int is_bwdref_enabled(const VP10_COMP *const cpi) { static INLINE void set_ref_ptrs(VP10_COMMON *cm, MACROBLOCKD *xd, MV_REFERENCE_FRAME ref0, MV_REFERENCE_FRAME ref1) { - xd->block_refs[0] = &cm->frame_refs[ref0 >= LAST_FRAME ? ref0 - LAST_FRAME - : 0]; - xd->block_refs[1] = &cm->frame_refs[ref1 >= LAST_FRAME ? ref1 - LAST_FRAME - : 0]; + xd->block_refs[0] = + &cm->frame_refs[ref0 >= LAST_FRAME ? ref0 - LAST_FRAME : 0]; + xd->block_refs[1] = + &cm->frame_refs[ref1 >= LAST_FRAME ? ref1 - LAST_FRAME : 0]; } static INLINE int get_chessboard_index(const int frame_index) { diff --git a/vp10/encoder/ethread.c b/vp10/encoder/ethread.c index 5434ee735..458dba475 100644 --- a/vp10/encoder/ethread.c +++ b/vp10/encoder/ethread.c @@ -28,7 +28,6 @@ static void accumulate_rd_opt(ThreadData *td, ThreadData *td_t) { td->rd_counts.coef_counts[i][j][k][l][m][n] += td_t->rd_counts.coef_counts[i][j][k][l][m][n]; - // Counts of all motion searches and exhuastive mesh searches. td->rd_counts.m_search_count += td_t->rd_counts.m_search_count; td->rd_counts.ex_search_count += td_t->rd_counts.ex_search_count; @@ -41,10 +40,10 @@ static int enc_worker_hook(EncWorkerData *const thread_data, void *unused) { const int tile_rows = cm->tile_rows; int t; - (void) unused; + (void)unused; for (t = thread_data->start; t < tile_rows * tile_cols; - t += cpi->num_workers) { + t += cpi->num_workers) { int tile_row = t / tile_cols; int tile_col = t % tile_cols; @@ -69,8 +68,7 @@ void vp10_encode_tiles_mt(VP10_COMP *cpi) { vpx_malloc(num_workers * sizeof(*cpi->workers))); CHECK_MEM_ERROR(cm, cpi->tile_thr_data, - vpx_calloc(num_workers, - sizeof(*cpi->tile_thr_data))); + vpx_calloc(num_workers, sizeof(*cpi->tile_thr_data))); for (i = 0; i < num_workers; i++) { VPxWorker *const worker = &cpi->workers[i]; @@ -82,7 +80,6 @@ void vp10_encode_tiles_mt(VP10_COMP *cpi) { thread_data->cpi = cpi; if (i < num_workers - 1) { - // Allocate thread data. CHECK_MEM_ERROR(cm, thread_data->td, vpx_memalign(32, sizeof(*thread_data->td))); @@ -121,7 +118,7 @@ void vp10_encode_tiles_mt(VP10_COMP *cpi) { worker->hook = (VPxWorkerHook)enc_worker_hook; worker->data1 = &cpi->tile_thr_data[i]; worker->data2 = NULL; - thread_data = (EncWorkerData*)worker->data1; + thread_data = (EncWorkerData *)worker->data1; // Before encoding a frame, copy the thread data from cpi. if (thread_data->td != &cpi->td) { @@ -135,16 +132,16 @@ void vp10_encode_tiles_mt(VP10_COMP *cpi) { // Allocate buffers used by palette coding mode. if (cpi->common.allow_screen_content_tools && i < num_workers - 1) { - MACROBLOCK *x = &thread_data->td->mb; - CHECK_MEM_ERROR(cm, x->palette_buffer, - vpx_memalign(16, sizeof(*x->palette_buffer))); + MACROBLOCK *x = &thread_data->td->mb; + CHECK_MEM_ERROR(cm, x->palette_buffer, + vpx_memalign(16, sizeof(*x->palette_buffer))); } } // Encode a frame for (i = 0; i < num_workers; i++) { VPxWorker *const worker = &cpi->workers[i]; - EncWorkerData *const thread_data = (EncWorkerData*)worker->data1; + EncWorkerData *const thread_data = (EncWorkerData *)worker->data1; // Set the starting tile for each thread. thread_data->start = i; @@ -163,7 +160,7 @@ void vp10_encode_tiles_mt(VP10_COMP *cpi) { for (i = 0; i < num_workers; i++) { VPxWorker *const worker = &cpi->workers[i]; - EncWorkerData *const thread_data = (EncWorkerData*)worker->data1; + EncWorkerData *const thread_data = (EncWorkerData *)worker->data1; // Accumulate counters. if (i < cpi->num_workers - 1) { diff --git a/vp10/encoder/extend.c b/vp10/encoder/extend.c index 4c8ce3b57..e3d4be318 100644 --- a/vp10/encoder/extend.c +++ b/vp10/encoder/extend.c @@ -16,8 +16,7 @@ #include "vp10/encoder/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, + uint8_t *dst, int dst_pitch, int w, int h, int extend_top, int extend_left, int extend_bottom, int extend_right) { int i, linesize; @@ -43,7 +42,7 @@ static void copy_and_extend_plane(const uint8_t *src, int src_pitch, src_ptr1 = dst - extend_left; src_ptr2 = dst + dst_pitch * (h - 1) - extend_left; dst_ptr1 = dst + dst_pitch * (-extend_top) - extend_left; - dst_ptr2 = dst + dst_pitch * (h) - extend_left; + dst_ptr2 = dst + dst_pitch * (h)-extend_left; linesize = extend_left + extend_right + w; for (i = 0; i < extend_top; i++) { @@ -59,9 +58,8 @@ static void copy_and_extend_plane(const uint8_t *src, int src_pitch, #if CONFIG_VP9_HIGHBITDEPTH static void highbd_copy_and_extend_plane(const uint8_t *src8, int src_pitch, - uint8_t *dst8, int dst_pitch, - int w, int h, - int extend_top, int extend_left, + uint8_t *dst8, int dst_pitch, int w, + int h, int extend_top, int extend_left, int extend_bottom, int extend_right) { int i, linesize; uint16_t *src = CONVERT_TO_SHORTPTR(src8); @@ -88,7 +86,7 @@ static void highbd_copy_and_extend_plane(const uint8_t *src8, int src_pitch, src_ptr1 = dst - extend_left; src_ptr2 = dst + dst_pitch * (h - 1) - extend_left; dst_ptr1 = dst + dst_pitch * (-extend_top) - extend_left; - dst_ptr2 = dst + dst_pitch * (h) - extend_left; + dst_ptr2 = dst + dst_pitch * (h)-extend_left; linesize = extend_left + extend_right + w; for (i = 0; i < extend_top; i++) { @@ -104,7 +102,7 @@ static void highbd_copy_and_extend_plane(const uint8_t *src8, int src_pitch, #endif // CONFIG_VP9_HIGHBITDEPTH void vp10_copy_and_extend_frame(const YV12_BUFFER_CONFIG *src, - YV12_BUFFER_CONFIG *dst) { + YV12_BUFFER_CONFIG *dst) { // Extend src frame in buffer // Altref filtering assumes 16 pixel extension const int et_y = 16; @@ -127,51 +125,46 @@ void vp10_copy_and_extend_frame(const YV12_BUFFER_CONFIG *src, #if CONFIG_VP9_HIGHBITDEPTH if (src->flags & YV12_FLAG_HIGHBITDEPTH) { - highbd_copy_and_extend_plane(src->y_buffer, src->y_stride, - dst->y_buffer, dst->y_stride, - src->y_crop_width, src->y_crop_height, - et_y, el_y, eb_y, er_y); + highbd_copy_and_extend_plane(src->y_buffer, src->y_stride, dst->y_buffer, + dst->y_stride, src->y_crop_width, + src->y_crop_height, et_y, el_y, eb_y, er_y); - highbd_copy_and_extend_plane(src->u_buffer, src->uv_stride, - dst->u_buffer, dst->uv_stride, - src->uv_crop_width, src->uv_crop_height, - et_uv, el_uv, eb_uv, er_uv); + highbd_copy_and_extend_plane( + src->u_buffer, src->uv_stride, dst->u_buffer, dst->uv_stride, + src->uv_crop_width, src->uv_crop_height, et_uv, el_uv, eb_uv, er_uv); - highbd_copy_and_extend_plane(src->v_buffer, src->uv_stride, - dst->v_buffer, dst->uv_stride, - src->uv_crop_width, src->uv_crop_height, - et_uv, el_uv, eb_uv, er_uv); + highbd_copy_and_extend_plane( + src->v_buffer, src->uv_stride, dst->v_buffer, dst->uv_stride, + src->uv_crop_width, src->uv_crop_height, et_uv, el_uv, eb_uv, er_uv); return; } #endif // CONFIG_VP9_HIGHBITDEPTH - copy_and_extend_plane(src->y_buffer, src->y_stride, - dst->y_buffer, dst->y_stride, - src->y_crop_width, src->y_crop_height, + copy_and_extend_plane(src->y_buffer, src->y_stride, dst->y_buffer, + dst->y_stride, src->y_crop_width, src->y_crop_height, et_y, el_y, eb_y, er_y); - copy_and_extend_plane(src->u_buffer, src->uv_stride, - dst->u_buffer, dst->uv_stride, - src->uv_crop_width, src->uv_crop_height, + copy_and_extend_plane(src->u_buffer, src->uv_stride, dst->u_buffer, + dst->uv_stride, src->uv_crop_width, src->uv_crop_height, et_uv, el_uv, eb_uv, er_uv); - copy_and_extend_plane(src->v_buffer, src->uv_stride, - dst->v_buffer, dst->uv_stride, - src->uv_crop_width, src->uv_crop_height, + copy_and_extend_plane(src->v_buffer, src->uv_stride, dst->v_buffer, + dst->uv_stride, src->uv_crop_width, src->uv_crop_height, et_uv, el_uv, eb_uv, er_uv); } void vp10_copy_and_extend_frame_with_rect(const YV12_BUFFER_CONFIG *src, - YV12_BUFFER_CONFIG *dst, - int srcy, int srcx, - int srch, int srcw) { + YV12_BUFFER_CONFIG *dst, int srcy, + int srcx, int srch, int srcw) { // If the side is not touching the bounder then don't extend. const int et_y = srcy ? 0 : dst->border; const int el_y = srcx ? 0 : dst->border; - const int eb_y = srcy + srch != src->y_height ? 0 : - dst->border + dst->y_height - src->y_height; - const int er_y = srcx + srcw != src->y_width ? 0 : - dst->border + dst->y_width - src->y_width; + const int eb_y = srcy + srch != src->y_height + ? 0 + : dst->border + dst->y_height - src->y_height; + const int er_y = srcx + srcw != src->y_width + ? 0 + : dst->border + dst->y_width - src->y_width; const int src_y_offset = srcy * src->y_stride + srcx; const int dst_y_offset = srcy * dst->y_stride + srcx; @@ -185,17 +178,14 @@ void vp10_copy_and_extend_frame_with_rect(const YV12_BUFFER_CONFIG *src, 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, - srcw, srch, + dst->y_buffer + dst_y_offset, dst->y_stride, srcw, srch, et_y, el_y, eb_y, er_y); copy_and_extend_plane(src->u_buffer + src_uv_offset, src->uv_stride, - dst->u_buffer + dst_uv_offset, dst->uv_stride, - srcw_uv, srch_uv, - et_uv, el_uv, eb_uv, er_uv); + dst->u_buffer + dst_uv_offset, dst->uv_stride, srcw_uv, + srch_uv, et_uv, el_uv, eb_uv, er_uv); copy_and_extend_plane(src->v_buffer + src_uv_offset, src->uv_stride, - dst->v_buffer + dst_uv_offset, dst->uv_stride, - srcw_uv, srch_uv, - et_uv, el_uv, eb_uv, er_uv); + dst->v_buffer + dst_uv_offset, dst->uv_stride, srcw_uv, + srch_uv, et_uv, el_uv, eb_uv, er_uv); } diff --git a/vp10/encoder/extend.h b/vp10/encoder/extend.h index 6f502ef6a..f7967fde9 100644 --- a/vp10/encoder/extend.h +++ b/vp10/encoder/extend.h @@ -18,14 +18,12 @@ extern "C" { #endif - void vp10_copy_and_extend_frame(const YV12_BUFFER_CONFIG *src, - YV12_BUFFER_CONFIG *dst); + YV12_BUFFER_CONFIG *dst); void vp10_copy_and_extend_frame_with_rect(const YV12_BUFFER_CONFIG *src, - YV12_BUFFER_CONFIG *dst, - int srcy, int srcx, - int srch, int srcw); + YV12_BUFFER_CONFIG *dst, int srcy, + int srcx, int srch, int srcw); #ifdef __cplusplus } // extern "C" #endif diff --git a/vp10/encoder/firstpass.c b/vp10/encoder/firstpass.c index d9bc96e7b..f705bf8fa 100644 --- a/vp10/encoder/firstpass.c +++ b/vp10/encoder/firstpass.c @@ -38,33 +38,33 @@ #include "vp10/encoder/rd.h" #include "vpx_dsp/variance.h" -#define OUTPUT_FPF 0 -#define ARF_STATS_OUTPUT 0 +#define OUTPUT_FPF 0 +#define ARF_STATS_OUTPUT 0 #define GROUP_ADAPTIVE_MAXQ 1 -#define BOOST_BREAKOUT 12.5 -#define BOOST_FACTOR 12.5 -#define FACTOR_PT_LOW 0.70 -#define FACTOR_PT_HIGH 0.90 -#define FIRST_PASS_Q 10.0 -#define GF_MAX_BOOST 96.0 -#define INTRA_MODE_PENALTY 1024 -#define KF_MAX_BOOST 128.0 -#define MIN_ARF_GF_BOOST 240 -#define MIN_DECAY_FACTOR 0.01 -#define MIN_KF_BOOST 300 +#define BOOST_BREAKOUT 12.5 +#define BOOST_FACTOR 12.5 +#define FACTOR_PT_LOW 0.70 +#define FACTOR_PT_HIGH 0.90 +#define FIRST_PASS_Q 10.0 +#define GF_MAX_BOOST 96.0 +#define INTRA_MODE_PENALTY 1024 +#define KF_MAX_BOOST 128.0 +#define MIN_ARF_GF_BOOST 240 +#define MIN_DECAY_FACTOR 0.01 +#define MIN_KF_BOOST 300 #define NEW_MV_MODE_PENALTY 32 -#define DARK_THRESH 64 -#define DEFAULT_GRP_WEIGHT 1.0 -#define RC_FACTOR_MIN 0.75 -#define RC_FACTOR_MAX 1.75 +#define DARK_THRESH 64 +#define DEFAULT_GRP_WEIGHT 1.0 +#define RC_FACTOR_MIN 0.75 +#define RC_FACTOR_MAX 1.75 #define NCOUNT_INTRA_THRESH 8192 #define NCOUNT_INTRA_FACTOR 3 #define NCOUNT_FRAME_II_THRESH 5.0 -#define DOUBLE_DIVIDE_CHECK(x) ((x) < 0 ? (x) - 0.000001 : (x) + 0.000001) +#define DOUBLE_DIVIDE_CHECK(x) ((x) < 0 ? (x)-0.000001 : (x) + 0.000001) #if ARF_STATS_OUTPUT unsigned int arf_count = 0; @@ -72,8 +72,7 @@ unsigned int arf_count = 0; // Resets the first pass file to the given position using a relative seek from // the current position. -static void reset_fpf_position(TWO_PASS *p, - const FIRSTPASS_STATS *position) { +static void reset_fpf_position(TWO_PASS *p, const FIRSTPASS_STATS *position) { p->stats_in = position; } @@ -88,8 +87,7 @@ static const FIRSTPASS_STATS *read_frame_stats(const TWO_PASS *p, int offset) { } static int input_stats(TWO_PASS *p, FIRSTPASS_STATS *fps) { - if (p->stats_in >= p->stats_in_end) - return EOF; + if (p->stats_in >= p->stats_in_end) return EOF; *fps = *p->stats_in; ++p->stats_in; @@ -110,39 +108,24 @@ static void output_stats(FIRSTPASS_STATS *stats, FILE *fpfile; fpfile = fopen("firstpass.stt", "a"); - fprintf(fpfile, "%12.0lf %12.4lf %12.0lf %12.0lf %12.0lf %12.4lf %12.4lf" + fprintf(fpfile, + "%12.0lf %12.4lf %12.0lf %12.0lf %12.0lf %12.4lf %12.4lf" "%12.4lf %12.4lf %12.4lf %12.4lf %12.4lf %12.4lf %12.4lf %12.4lf" "%12.4lf %12.4lf %12.0lf %12.0lf %12.0lf %12.4lf\n", - stats->frame, - stats->weight, - stats->intra_error, - stats->coded_error, - stats->sr_coded_error, - stats->pcnt_inter, - stats->pcnt_motion, - stats->pcnt_second_ref, - stats->pcnt_neutral, - stats->intra_skip_pct, - stats->inactive_zone_rows, - stats->inactive_zone_cols, - stats->MVr, - stats->mvr_abs, - stats->MVc, - stats->mvc_abs, - stats->MVrv, - stats->MVcv, - stats->mv_in_out_count, - stats->new_mv_count, - stats->count, - stats->duration); + stats->frame, stats->weight, stats->intra_error, stats->coded_error, + stats->sr_coded_error, stats->pcnt_inter, stats->pcnt_motion, + stats->pcnt_second_ref, stats->pcnt_neutral, stats->intra_skip_pct, + stats->inactive_zone_rows, stats->inactive_zone_cols, stats->MVr, + stats->mvr_abs, stats->MVc, stats->mvc_abs, stats->MVrv, + stats->MVcv, stats->mv_in_out_count, stats->new_mv_count, + stats->count, stats->duration); fclose(fpfile); } #endif } #if CONFIG_FP_MB_STATS -static void output_fpmb_stats(uint8_t *this_frame_mb_stats, - VP10_COMMON *cm, +static void output_fpmb_stats(uint8_t *this_frame_mb_stats, VP10_COMMON *cm, struct vpx_codec_pkt_list *pktlist) { struct vpx_codec_cx_pkt pkt; pkt.kind = VPX_CODEC_FPMB_STATS_PKT; @@ -158,23 +141,23 @@ static void zero_stats(FIRSTPASS_STATS *section) { section->intra_error = 0.0; section->coded_error = 0.0; section->sr_coded_error = 0.0; - section->pcnt_inter = 0.0; - section->pcnt_motion = 0.0; + section->pcnt_inter = 0.0; + section->pcnt_motion = 0.0; section->pcnt_second_ref = 0.0; section->pcnt_neutral = 0.0; section->intra_skip_pct = 0.0; section->inactive_zone_rows = 0.0; section->inactive_zone_cols = 0.0; section->MVr = 0.0; - section->mvr_abs = 0.0; - section->MVc = 0.0; - section->mvc_abs = 0.0; - section->MVrv = 0.0; - section->MVcv = 0.0; - section->mv_in_out_count = 0.0; + section->mvr_abs = 0.0; + section->MVc = 0.0; + section->mvc_abs = 0.0; + section->MVrv = 0.0; + section->MVcv = 0.0; + section->mv_in_out_count = 0.0; section->new_mv_count = 0.0; - section->count = 0.0; - section->duration = 1.0; + section->count = 0.0; + section->duration = 1.0; } static void accumulate_stats(FIRSTPASS_STATS *section, @@ -184,7 +167,7 @@ static void accumulate_stats(FIRSTPASS_STATS *section, section->intra_error += frame->intra_error; section->coded_error += frame->coded_error; section->sr_coded_error += frame->sr_coded_error; - section->pcnt_inter += frame->pcnt_inter; + section->pcnt_inter += frame->pcnt_inter; section->pcnt_motion += frame->pcnt_motion; section->pcnt_second_ref += frame->pcnt_second_ref; section->pcnt_neutral += frame->pcnt_neutral; @@ -192,15 +175,15 @@ static void accumulate_stats(FIRSTPASS_STATS *section, section->inactive_zone_rows += frame->inactive_zone_rows; section->inactive_zone_cols += frame->inactive_zone_cols; section->MVr += frame->MVr; - section->mvr_abs += frame->mvr_abs; - section->MVc += frame->MVc; - section->mvc_abs += frame->mvc_abs; - section->MVrv += frame->MVrv; - section->MVcv += frame->MVcv; - section->mv_in_out_count += frame->mv_in_out_count; + section->mvr_abs += frame->mvr_abs; + section->MVc += frame->MVc; + section->mvc_abs += frame->mvc_abs; + section->MVrv += frame->MVrv; + section->MVcv += frame->MVcv; + section->mv_in_out_count += frame->mv_in_out_count; section->new_mv_count += frame->new_mv_count; - section->count += frame->count; - section->duration += frame->duration; + section->count += frame->count; + section->duration += frame->duration; } static void subtract_stats(FIRSTPASS_STATS *section, @@ -210,7 +193,7 @@ static void subtract_stats(FIRSTPASS_STATS *section, section->intra_error -= frame->intra_error; section->coded_error -= frame->coded_error; section->sr_coded_error -= frame->sr_coded_error; - section->pcnt_inter -= frame->pcnt_inter; + section->pcnt_inter -= frame->pcnt_inter; section->pcnt_motion -= frame->pcnt_motion; section->pcnt_second_ref -= frame->pcnt_second_ref; section->pcnt_neutral -= frame->pcnt_neutral; @@ -218,15 +201,15 @@ static void subtract_stats(FIRSTPASS_STATS *section, section->inactive_zone_rows -= frame->inactive_zone_rows; section->inactive_zone_cols -= frame->inactive_zone_cols; section->MVr -= frame->MVr; - section->mvr_abs -= frame->mvr_abs; - section->MVc -= frame->MVc; - section->mvc_abs -= frame->mvc_abs; - section->MVrv -= frame->MVrv; - section->MVcv -= frame->MVcv; - section->mv_in_out_count -= frame->mv_in_out_count; + section->mvr_abs -= frame->mvr_abs; + section->MVc -= frame->MVc; + section->mvc_abs -= frame->mvc_abs; + section->MVrv -= frame->MVrv; + section->MVcv -= frame->MVcv; + section->mv_in_out_count -= frame->mv_in_out_count; section->new_mv_count -= frame->new_mv_count; - section->count -= frame->count; - section->duration -= frame->duration; + section->count -= frame->count; + section->duration -= frame->duration; } // Calculate the linear size relative to a baseline of 1080P @@ -241,13 +224,13 @@ static double get_linear_size_factor(const VP10_COMP *cpi) { #define MIN_ACTIVE_AREA 0.5 #define MAX_ACTIVE_AREA 1.0 static double calculate_active_area(const VP10_COMP *cpi, - const FIRSTPASS_STATS *this_frame) -{ + const FIRSTPASS_STATS *this_frame) { double active_pct; - active_pct = 1.0 - - ((this_frame->intra_skip_pct / 2) + - ((this_frame->inactive_zone_rows * 2) / (double)cpi->common.mb_rows)); + active_pct = + 1.0 - + ((this_frame->intra_skip_pct / 2) + + ((this_frame->inactive_zone_rows * 2) / (double)cpi->common.mb_rows)); return fclamp(active_pct, MIN_ACTIVE_AREA, MAX_ACTIVE_AREA); } @@ -262,8 +245,9 @@ static double calculate_modified_err(const VP10_COMP *cpi, const double av_weight = stats->weight / stats->count; const double av_err = (stats->coded_error * av_weight) / stats->count; double modified_error = - av_err * pow(this_frame->coded_error * this_frame->weight / - DOUBLE_DIVIDE_CHECK(av_err), oxcf->two_pass_vbrbias / 100.0); + av_err * pow(this_frame->coded_error * this_frame->weight / + DOUBLE_DIVIDE_CHECK(av_err), + oxcf->two_pass_vbrbias / 100.0); // Correction for active area. Frames with a reduced active area // (eg due to formatting bars) have a higher error per mb for the @@ -271,17 +255,18 @@ static double calculate_modified_err(const VP10_COMP *cpi, // 0.5N blocks of complexity 2X is a little easier than coding N // blocks of complexity X. modified_error *= - pow(calculate_active_area(cpi, this_frame), ACT_AREA_CORRECTION); + pow(calculate_active_area(cpi, this_frame), ACT_AREA_CORRECTION); - return fclamp(modified_error, - twopass->modified_error_min, twopass->modified_error_max); + return fclamp(modified_error, twopass->modified_error_min, + twopass->modified_error_max); } // This function returns the maximum target rate per frame. static int frame_max_bits(const RATE_CONTROL *rc, const VP10EncoderConfig *oxcf) { int64_t max_bits = ((int64_t)rc->avg_frame_bandwidth * - (int64_t)oxcf->two_pass_vbrmax_section) / 100; + (int64_t)oxcf->two_pass_vbrmax_section) / + 100; if (max_bits < 0) max_bits = 0; else if (max_bits > rc->max_frame_bandwidth) @@ -300,14 +285,10 @@ void vp10_end_first_pass(VP10_COMP *cpi) { static vpx_variance_fn_t get_block_variance_fn(BLOCK_SIZE bsize) { switch (bsize) { - case BLOCK_8X8: - return vpx_mse8x8; - case BLOCK_16X8: - return vpx_mse16x8; - case BLOCK_8X16: - return vpx_mse8x16; - default: - return vpx_mse16x16; + case BLOCK_8X8: return vpx_mse8x8; + case BLOCK_16X8: return vpx_mse16x8; + case BLOCK_8X16: return vpx_mse8x16; + default: return vpx_mse16x16; } } @@ -326,38 +307,26 @@ static vpx_variance_fn_t highbd_get_block_variance_fn(BLOCK_SIZE bsize, switch (bd) { default: switch (bsize) { - case BLOCK_8X8: - return vpx_highbd_8_mse8x8; - case BLOCK_16X8: - return vpx_highbd_8_mse16x8; - case BLOCK_8X16: - return vpx_highbd_8_mse8x16; - default: - return vpx_highbd_8_mse16x16; + case BLOCK_8X8: return vpx_highbd_8_mse8x8; + case BLOCK_16X8: return vpx_highbd_8_mse16x8; + case BLOCK_8X16: return vpx_highbd_8_mse8x16; + default: return vpx_highbd_8_mse16x16; } break; case 10: switch (bsize) { - case BLOCK_8X8: - return vpx_highbd_10_mse8x8; - case BLOCK_16X8: - return vpx_highbd_10_mse16x8; - case BLOCK_8X16: - return vpx_highbd_10_mse8x16; - default: - return vpx_highbd_10_mse16x16; + case BLOCK_8X8: return vpx_highbd_10_mse8x8; + case BLOCK_16X8: return vpx_highbd_10_mse16x8; + case BLOCK_8X16: return vpx_highbd_10_mse8x16; + default: return vpx_highbd_10_mse16x16; } break; case 12: switch (bsize) { - case BLOCK_8X8: - return vpx_highbd_12_mse8x8; - case BLOCK_16X8: - return vpx_highbd_12_mse16x8; - case BLOCK_8X16: - return vpx_highbd_12_mse8x16; - default: - return vpx_highbd_12_mse16x16; + case BLOCK_8X8: return vpx_highbd_12_mse8x8; + case BLOCK_16X8: return vpx_highbd_12_mse16x8; + case BLOCK_8X16: return vpx_highbd_12_mse8x16; + default: return vpx_highbd_12_mse16x16; } break; } @@ -380,8 +349,7 @@ static int get_search_range(const VP10_COMP *cpi) { int sr = 0; const int dim = VPXMIN(cpi->initial_width, cpi->initial_height); - while ((dim << sr) < MAX_FULL_PEL_VAL) - ++sr; + while ((dim << sr) < MAX_FULL_PEL_VAL) ++sr; return sr; } @@ -389,8 +357,8 @@ static void first_pass_motion_search(VP10_COMP *cpi, MACROBLOCK *x, const MV *ref_mv, MV *best_mv, int *best_motion_err) { MACROBLOCKD *const xd = &x->e_mbd; - MV tmp_mv = {0, 0}; - MV ref_mv_full = {ref_mv->row >> 3, ref_mv->col >> 3}; + MV tmp_mv = { 0, 0 }; + MV ref_mv_full = { ref_mv->row >> 3, ref_mv->col >> 3 }; int num00, tmp_err, n; const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; vpx_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[bsize]; @@ -412,12 +380,11 @@ static void first_pass_motion_search(VP10_COMP *cpi, MACROBLOCK *x, // Center the initial step/diamond search on best mv. tmp_err = cpi->diamond_search_sad(x, &cpi->ss_cfg, &ref_mv_full, &tmp_mv, - step_param, - x->sadperbit16, &num00, &v_fn_ptr, ref_mv); + step_param, x->sadperbit16, &num00, + &v_fn_ptr, ref_mv); if (tmp_err < INT_MAX) tmp_err = vp10_get_mvpred_var(x, &tmp_mv, ref_mv, &v_fn_ptr, 1); - if (tmp_err < INT_MAX - new_mv_mode_penalty) - tmp_err += new_mv_mode_penalty; + if (tmp_err < INT_MAX - new_mv_mode_penalty) tmp_err += new_mv_mode_penalty; if (tmp_err < *best_motion_err) { *best_motion_err = tmp_err; @@ -435,8 +402,8 @@ static void first_pass_motion_search(VP10_COMP *cpi, MACROBLOCK *x, --num00; } else { tmp_err = cpi->diamond_search_sad(x, &cpi->ss_cfg, &ref_mv_full, &tmp_mv, - step_param + n, x->sadperbit16, - &num00, &v_fn_ptr, ref_mv); + step_param + n, x->sadperbit16, &num00, + &v_fn_ptr, ref_mv); if (tmp_err < INT_MAX) tmp_err = vp10_get_mvpred_var(x, &tmp_mv, ref_mv, &v_fn_ptr, 1); if (tmp_err < INT_MAX - new_mv_mode_penalty) @@ -452,11 +419,9 @@ static void first_pass_motion_search(VP10_COMP *cpi, MACROBLOCK *x, static BLOCK_SIZE get_bsize(const VP10_COMMON *cm, int mb_row, int mb_col) { if (2 * mb_col + 1 < cm->mi_cols) { - return 2 * mb_row + 1 < cm->mi_rows ? BLOCK_16X16 - : BLOCK_16X8; + return 2 * mb_row + 1 < cm->mi_rows ? BLOCK_16X16 : BLOCK_16X8; } else { - return 2 * mb_row + 1 < cm->mi_rows ? BLOCK_8X16 - : BLOCK_8X8; + return 2 * mb_row + 1 < cm->mi_rows ? BLOCK_8X16 : BLOCK_8X8; } } @@ -464,11 +429,9 @@ static int find_fp_qindex(vpx_bit_depth_t bit_depth) { int i; for (i = 0; i < QINDEX_RANGE; ++i) - if (vp10_convert_qindex_to_q(i, bit_depth) >= FIRST_PASS_Q) - break; + if (vp10_convert_qindex_to_q(i, bit_depth) >= FIRST_PASS_Q) break; - if (i == QINDEX_RANGE) - i--; + if (i == QINDEX_RANGE) i--; return i; } @@ -476,8 +439,7 @@ static int find_fp_qindex(vpx_bit_depth_t bit_depth) { static void set_first_pass_params(VP10_COMP *cpi) { VP10_COMMON *const cm = &cpi->common; if (!cpi->refresh_alt_ref_frame && - (cm->current_video_frame == 0 || - (cpi->frame_flags & FRAMEFLAGS_KEY))) { + (cm->current_video_frame == 0 || (cpi->frame_flags & FRAMEFLAGS_KEY))) { cm->frame_type = KEY_FRAME; } else { cm->frame_type = INTER_FRAME; @@ -517,9 +479,9 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { int image_data_start_row = INVALID_ROW; int new_mv_count = 0; int sum_in_vectors = 0; - MV lastmv = {0, 0}; + MV lastmv = { 0, 0 }; TWO_PASS *twopass = &cpi->twopass; - const MV zero_mv = {0, 0}; + const MV zero_mv = { 0, 0 }; int recon_y_stride, recon_uv_stride, uv_mb_height; YV12_BUFFER_CONFIG *const lst_yv12 = get_ref_frame_buffer(cpi, LAST_FRAME); @@ -581,7 +543,7 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { uv_mb_height = 16 >> (new_yv12->y_height > new_yv12->uv_height); for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) { - MV best_ref_mv = {0, 0}; + MV best_ref_mv = { 0, 0 }; // Reset above block coeffs. xd->up_available = (mb_row != 0); @@ -591,8 +553,7 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { // Set up limit values for motion vectors to prevent them extending // outside the UMV borders. x->mv_row_min = -((mb_row * 16) + BORDER_MV_PIXELS_B16); - x->mv_row_max = ((cm->mb_rows - 1 - mb_row) * 16) - + BORDER_MV_PIXELS_B16; + x->mv_row_max = ((cm->mb_rows - 1 - mb_row) * 16) + BORDER_MV_PIXELS_B16; for (mb_col = 0; mb_col < cm->mb_cols; ++mb_col) { int this_error; @@ -613,8 +574,7 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { xd->left_available = (mb_col != 0); xd->mi[0]->mbmi.sb_type = bsize; xd->mi[0]->mbmi.ref_frame[0] = INTRA_FRAME; - set_mi_row_col(xd, &tile, - mb_row << 1, num_8x8_blocks_high_lookup[bsize], + set_mi_row_col(xd, &tile, mb_row << 1, num_8x8_blocks_high_lookup[bsize], mb_col << 1, num_8x8_blocks_wide_lookup[bsize], cm->mi_rows, cm->mi_cols); @@ -624,8 +584,8 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { xd->mi[0]->mbmi.segment_id_supertx = 0; #endif // CONFIG_SUPERTX xd->mi[0]->mbmi.mode = DC_PRED; - xd->mi[0]->mbmi.tx_size = use_dc_pred ? - (bsize >= BLOCK_16X16 ? TX_16X16 : TX_8X8) : TX_4X4; + xd->mi[0]->mbmi.tx_size = + use_dc_pred ? (bsize >= BLOCK_16X16 ? TX_16X16 : TX_8X8) : TX_4X4; vp10_encode_intra_block_plane(x, bsize, 0, 0); this_error = vpx_get_mb_ss(x->plane[0].src_diff); @@ -643,17 +603,13 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { #if CONFIG_VP9_HIGHBITDEPTH if (cm->use_highbitdepth) { switch (cm->bit_depth) { - case VPX_BITS_8: - break; - case VPX_BITS_10: - this_error >>= 4; - break; - case VPX_BITS_12: - this_error >>= 8; - break; + case VPX_BITS_8: break; + case VPX_BITS_10: this_error >>= 4; break; + case VPX_BITS_12: this_error >>= 8; break; default: - assert(0 && "cm->bit_depth should be VPX_BITS_8, " - "VPX_BITS_10 or VPX_BITS_12"); + assert(0 && + "cm->bit_depth should be VPX_BITS_8, " + "VPX_BITS_10 or VPX_BITS_12"); return; } } @@ -707,7 +663,7 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { if (cm->current_video_frame > 0) { int tmp_err, motion_error, raw_motion_error; // Assume 0,0 motion with no mv overhead. - MV mv = {0, 0} , tmp_mv = {0, 0}; + MV mv = { 0, 0 }, tmp_mv = { 0, 0 }; struct buf_2d unscaled_last_source_buf_2d; xd->plane[0].pre[0].buf = first_ref_buf->y_buffer + recon_yoffset; @@ -716,12 +672,12 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { motion_error = highbd_get_prediction_error( bsize, &x->plane[0].src, &xd->plane[0].pre[0], xd->bd); } else { - motion_error = get_prediction_error( - bsize, &x->plane[0].src, &xd->plane[0].pre[0]); + motion_error = get_prediction_error(bsize, &x->plane[0].src, + &xd->plane[0].pre[0]); } #else - motion_error = get_prediction_error( - bsize, &x->plane[0].src, &xd->plane[0].pre[0]); + motion_error = + get_prediction_error(bsize, &x->plane[0].src, &xd->plane[0].pre[0]); #endif // CONFIG_VP9_HIGHBITDEPTH // Compute the motion error of the 0,0 motion using the last source @@ -736,12 +692,12 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { raw_motion_error = highbd_get_prediction_error( bsize, &x->plane[0].src, &unscaled_last_source_buf_2d, xd->bd); } else { - raw_motion_error = get_prediction_error( - bsize, &x->plane[0].src, &unscaled_last_source_buf_2d); + raw_motion_error = get_prediction_error(bsize, &x->plane[0].src, + &unscaled_last_source_buf_2d); } #else - raw_motion_error = get_prediction_error( - bsize, &x->plane[0].src, &unscaled_last_source_buf_2d); + raw_motion_error = get_prediction_error(bsize, &x->plane[0].src, + &unscaled_last_source_buf_2d); #endif // CONFIG_VP9_HIGHBITDEPTH // TODO(pengchong): Replace the hard-coded threshold @@ -773,12 +729,12 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { gf_motion_error = highbd_get_prediction_error( bsize, &x->plane[0].src, &xd->plane[0].pre[0], xd->bd); } else { - gf_motion_error = get_prediction_error( - bsize, &x->plane[0].src, &xd->plane[0].pre[0]); + gf_motion_error = get_prediction_error(bsize, &x->plane[0].src, + &xd->plane[0].pre[0]); } #else - gf_motion_error = get_prediction_error( - bsize, &x->plane[0].src, &xd->plane[0].pre[0]); + gf_motion_error = get_prediction_error(bsize, &x->plane[0].src, + &xd->plane[0].pre[0]); #endif // CONFIG_VP9_HIGHBITDEPTH first_pass_motion_search(cpi, x, &zero_mv, &tmp_mv, @@ -834,12 +790,12 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { if (((this_error - intrapenalty) * 9 <= motion_error * 10) && (this_error < (2 * intrapenalty))) { neutral_count += 1.0; - // Also track cases where the intra is not much worse than the inter - // and use this in limiting the GF/arf group length. + // Also track cases where the intra is not much worse than the inter + // and use this in limiting the GF/arf group length. } else if ((this_error > NCOUNT_INTRA_THRESH) && (this_error < (NCOUNT_INTRA_FACTOR * motion_error))) { - neutral_count += (double)motion_error / - DOUBLE_DIVIDE_CHECK((double)this_error); + neutral_count += + (double)motion_error / DOUBLE_DIVIDE_CHECK((double)this_error); } mv.row *= 8; @@ -909,8 +865,7 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { #endif // Non-zero vector, was it different from the last non zero vector? - if (!is_equal_mv(&mv, &lastmv)) - ++new_mv_count; + if (!is_equal_mv(&mv, &lastmv)) ++new_mv_count; lastmv = mv; // Does the row vector point inwards or outwards? @@ -956,10 +911,10 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { // Adjust to the next row of MBs. x->plane[0].src.buf += 16 * x->plane[0].src.stride - 16 * cm->mb_cols; - x->plane[1].src.buf += uv_mb_height * x->plane[1].src.stride - - uv_mb_height * cm->mb_cols; - x->plane[2].src.buf += uv_mb_height * x->plane[1].src.stride - - uv_mb_height * cm->mb_cols; + x->plane[1].src.buf += + uv_mb_height * x->plane[1].src.stride - uv_mb_height * cm->mb_cols; + x->plane[2].src.buf += + uv_mb_height * x->plane[1].src.stride - uv_mb_height * cm->mb_cols; vpx_clear_system_state(); } @@ -984,7 +939,8 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { // Initial estimate here uses sqrt(mbs) to define the min_err, where the // number of mbs is proportional to the image area. const int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE) - ? cpi->initial_mbs : cpi->common.MBs; + ? cpi->initial_mbs + : cpi->common.MBs; const double min_err = 200 * sqrt(num_mbs); intra_factor = intra_factor / (double)num_mbs; @@ -1008,10 +964,10 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { fps.mvr_abs = (double)sum_mvr_abs / mvcount; fps.MVc = (double)sum_mvc / mvcount; fps.mvc_abs = (double)sum_mvc_abs / mvcount; - fps.MVrv = ((double)sum_mvrs - - ((double)sum_mvr * sum_mvr / mvcount)) / mvcount; - fps.MVcv = ((double)sum_mvcs - - ((double)sum_mvc * sum_mvc / mvcount)) / mvcount; + fps.MVrv = + ((double)sum_mvrs - ((double)sum_mvr * sum_mvr / mvcount)) / mvcount; + fps.MVcv = + ((double)sum_mvcs - ((double)sum_mvc * sum_mvc / mvcount)) / mvcount; fps.mv_in_out_count = (double)sum_in_vectors / (mvcount * 2); fps.new_mv_count = new_mv_count; fps.pcnt_motion = (double)mvcount / num_mbs; @@ -1067,7 +1023,7 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { vpx_extend_frame_borders(new_yv12); - // The frame we just compressed now becomes the last frame. +// The frame we just compressed now becomes the last frame. #if CONFIG_EXT_REFS ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->lst_fb_idxes[LAST_FRAME - LAST_FRAME]], @@ -1108,11 +1064,8 @@ void vp10_first_pass(VP10_COMP *cpi, const struct lookahead_entry *source) { ++cm->current_video_frame; } -static double calc_correction_factor(double err_per_mb, - double err_divisor, - double pt_low, - double pt_high, - int q, +static double calc_correction_factor(double err_per_mb, double err_divisor, + double pt_low, double pt_high, int q, vpx_bit_depth_t bit_depth) { const double error_term = err_per_mb / err_divisor; @@ -1121,13 +1074,12 @@ static double calc_correction_factor(double err_per_mb, VPXMIN(vp10_convert_qindex_to_q(q, bit_depth) * 0.01 + pt_low, pt_high); // Calculate correction factor. - if (power_term < 1.0) - assert(error_term >= 0.0); + if (power_term < 1.0) assert(error_term >= 0.0); return fclamp(pow(error_term, power_term), 0.05, 5.0); } -#define ERR_DIVISOR 100.0 +#define ERR_DIVISOR 100.0 static int get_twopass_worst_quality(const VP10_COMP *cpi, const double section_err, double inactive_zone, @@ -1142,13 +1094,14 @@ static int get_twopass_worst_quality(const VP10_COMP *cpi, return rc->worst_quality; // Highest value allowed } else { const int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE) - ? cpi->initial_mbs : cpi->common.MBs; + ? cpi->initial_mbs + : cpi->common.MBs; const int active_mbs = VPXMAX(1, num_mbs - (int)(num_mbs * inactive_zone)); const double av_err_per_mb = section_err / active_mbs; const double speed_term = 1.0 + 0.04 * oxcf->speed; double ediv_size_correction; - const int target_norm_bits_per_mb = ((uint64_t)section_target_bandwidth << - BPER_MB_NORMBITS) / active_mbs; + const int target_norm_bits_per_mb = + ((uint64_t)section_target_bandwidth << BPER_MB_NORMBITS) / active_mbs; int q; // Larger image formats are expected to be a little harder to code @@ -1165,22 +1118,17 @@ static int get_twopass_worst_quality(const VP10_COMP *cpi, // Try and pick a max Q that will be high enough to encode the // content at the given rate. for (q = rc->best_quality; q < rc->worst_quality; ++q) { - const double factor = - calc_correction_factor(av_err_per_mb, - ERR_DIVISOR - ediv_size_correction, - FACTOR_PT_LOW, FACTOR_PT_HIGH, q, - cpi->common.bit_depth); - const int bits_per_mb = - vp10_rc_bits_per_mb(INTER_FRAME, q, - factor * speed_term * group_weight_factor, - cpi->common.bit_depth); - if (bits_per_mb <= target_norm_bits_per_mb) - break; + const double factor = calc_correction_factor( + av_err_per_mb, ERR_DIVISOR - ediv_size_correction, FACTOR_PT_LOW, + FACTOR_PT_HIGH, q, cpi->common.bit_depth); + const int bits_per_mb = vp10_rc_bits_per_mb( + INTER_FRAME, q, factor * speed_term * group_weight_factor, + cpi->common.bit_depth); + if (bits_per_mb <= target_norm_bits_per_mb) break; } // Restriction on active max q for constrained quality mode. - if (cpi->oxcf.rc_mode == VPX_CQ) - q = VPXMAX(q, oxcf->cq_level); + if (cpi->oxcf.rc_mode == VPX_CQ) q = VPXMAX(q, oxcf->cq_level); return q; } } @@ -1210,9 +1158,8 @@ void vp10_init_subsampling(VP10_COMP *cpi) { setup_rf_level_maxq(cpi); } -void vp10_calculate_coded_size(VP10_COMP *cpi, - int *scaled_frame_width, - int *scaled_frame_height) { +void vp10_calculate_coded_size(VP10_COMP *cpi, int *scaled_frame_width, + int *scaled_frame_height) { RATE_CONTROL *const rc = &cpi->rc; *scaled_frame_width = rc->frame_width[rc->frame_size_selector]; *scaled_frame_height = rc->frame_height[rc->frame_size_selector]; @@ -1227,8 +1174,7 @@ void vp10_init_second_pass(VP10_COMP *cpi) { zero_stats(&twopass->total_stats); zero_stats(&twopass->total_left_stats); - if (!twopass->stats_in_end) - return; + if (!twopass->stats_in_end) return; stats = &twopass->total_stats; @@ -1242,8 +1188,8 @@ void vp10_init_second_pass(VP10_COMP *cpi) { // It is calculated based on the actual durations of all frames from the // first pass. vp10_new_framerate(cpi, frame_rate); - twopass->bits_left = (int64_t)(stats->duration * oxcf->target_bandwidth / - 10000000.0); + twopass->bits_left = + (int64_t)(stats->duration * oxcf->target_bandwidth / 10000000.0); // This variable monitors how far behind the second ref update is lagging. twopass->sr_update_lag = 1; @@ -1251,14 +1197,14 @@ void vp10_init_second_pass(VP10_COMP *cpi) { // Scan the first pass file and calculate a modified total error based upon // the bias/power function used to allocate bits. { - const double avg_error = stats->coded_error / - DOUBLE_DIVIDE_CHECK(stats->count); + const double avg_error = + stats->coded_error / DOUBLE_DIVIDE_CHECK(stats->count); const FIRSTPASS_STATS *s = twopass->stats_in; double modified_error_total = 0.0; - twopass->modified_error_min = (avg_error * - oxcf->two_pass_vbrmin_section) / 100; - twopass->modified_error_max = (avg_error * - oxcf->two_pass_vbrmax_section) / 100; + twopass->modified_error_min = + (avg_error * oxcf->two_pass_vbrmin_section) / 100; + twopass->modified_error_max = + (avg_error * oxcf->two_pass_vbrmax_section) / 100; while (s < twopass->stats_in_end) { modified_error_total += calculate_modified_err(cpi, twopass, oxcf, s); ++s; @@ -1290,15 +1236,14 @@ void vp10_init_second_pass(VP10_COMP *cpi) { static double get_sr_decay_rate(const VP10_COMP *cpi, const FIRSTPASS_STATS *frame) { - const int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE) - ? cpi->initial_mbs : cpi->common.MBs; - double sr_diff = - (frame->sr_coded_error - frame->coded_error) / num_mbs; + const int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE) ? cpi->initial_mbs + : cpi->common.MBs; + double sr_diff = (frame->sr_coded_error - frame->coded_error) / num_mbs; double sr_decay = 1.0; double modified_pct_inter; double modified_pcnt_intra; const double motion_amplitude_factor = - frame->pcnt_motion * ((frame->mvc_abs + frame->mvr_abs) / 2); + frame->pcnt_motion * ((frame->mvc_abs + frame->mvr_abs) / 2); modified_pct_inter = frame->pcnt_inter; if ((frame->intra_error / DOUBLE_DIVIDE_CHECK(frame->coded_error)) < @@ -1307,7 +1252,6 @@ static double get_sr_decay_rate(const VP10_COMP *cpi, } modified_pcnt_intra = 100 * (1.0 - modified_pct_inter); - if ((sr_diff > LOW_SR_DIFF_TRHESH)) { sr_diff = VPXMIN(sr_diff, SR_DIFF_MAX); sr_decay = 1.0 - (SR_DIFF_PART * sr_diff) - @@ -1321,8 +1265,7 @@ static double get_sr_decay_rate(const VP10_COMP *cpi, // quality is decaying from frame to frame. static double get_zero_motion_factor(const VP10_COMP *cpi, const FIRSTPASS_STATS *frame) { - const double zero_motion_pct = frame->pcnt_inter - - frame->pcnt_motion; + const double zero_motion_pct = frame->pcnt_inter - frame->pcnt_motion; double sr_decay = get_sr_decay_rate(cpi, frame); return VPXMIN(sr_decay, zero_motion_pct); } @@ -1333,8 +1276,8 @@ static double get_prediction_decay_rate(const VP10_COMP *cpi, const FIRSTPASS_STATS *next_frame) { const double sr_decay_rate = get_sr_decay_rate(cpi, next_frame); const double zero_motion_factor = - (0.95 * pow((next_frame->pcnt_inter - next_frame->pcnt_motion), - ZM_POWER_FACTOR)); + (0.95 * pow((next_frame->pcnt_inter - next_frame->pcnt_motion), + ZM_POWER_FACTOR)); return VPXMAX(zero_motion_factor, (sr_decay_rate + ((1.0 - sr_decay_rate) * zero_motion_factor))); @@ -1343,8 +1286,8 @@ static double get_prediction_decay_rate(const VP10_COMP *cpi, // Function to test for a condition where a complex transition is followed // by a static section. For example in slide shows where there is a fade // between slides. This is to help with more optimal kf and gf positioning. -static int detect_transition_to_still(VP10_COMP *cpi, - int frame_interval, int still_interval, +static int detect_transition_to_still(VP10_COMP *cpi, int frame_interval, + int still_interval, double loop_decay_rate, double last_decay_rate) { TWO_PASS *const twopass = &cpi->twopass; @@ -1353,19 +1296,16 @@ static int detect_transition_to_still(VP10_COMP *cpi, // Break clause to detect very still sections after motion // For example a static image after a fade or other transition // instead of a clean scene cut. - if (frame_interval > rc->min_gf_interval && - loop_decay_rate >= 0.999 && + if (frame_interval > rc->min_gf_interval && loop_decay_rate >= 0.999 && last_decay_rate < 0.9) { int j; // Look ahead a few frames to see if static condition persists... for (j = 0; j < still_interval; ++j) { const FIRSTPASS_STATS *stats = &twopass->stats_in[j]; - if (stats >= twopass->stats_in_end) - break; + if (stats >= twopass->stats_in_end) break; - if (stats->pcnt_inter - stats->pcnt_motion < 0.999) - break; + if (stats->pcnt_inter - stats->pcnt_motion < 0.999) break; } // Only if it does do we signal a transition to still. @@ -1407,30 +1347,28 @@ static void accumulate_frame_motion_stats(const FIRSTPASS_STATS *stats, // Accumulate a measure of how uniform (or conversely how random) the motion // field is (a ratio of abs(mv) / mv). if (pct > 0.05) { - const double mvr_ratio = fabs(stats->mvr_abs) / - DOUBLE_DIVIDE_CHECK(fabs(stats->MVr)); - const double mvc_ratio = fabs(stats->mvc_abs) / - DOUBLE_DIVIDE_CHECK(fabs(stats->MVc)); + const double mvr_ratio = + fabs(stats->mvr_abs) / DOUBLE_DIVIDE_CHECK(fabs(stats->MVr)); + const double mvc_ratio = + fabs(stats->mvc_abs) / DOUBLE_DIVIDE_CHECK(fabs(stats->MVc)); - *mv_ratio_accumulator += pct * (mvr_ratio < stats->mvr_abs ? - mvr_ratio : stats->mvr_abs); - *mv_ratio_accumulator += pct * (mvc_ratio < stats->mvc_abs ? - mvc_ratio : stats->mvc_abs); + *mv_ratio_accumulator += + pct * (mvr_ratio < stats->mvr_abs ? mvr_ratio : stats->mvr_abs); + *mv_ratio_accumulator += + pct * (mvc_ratio < stats->mvc_abs ? mvc_ratio : stats->mvc_abs); } } #define BASELINE_ERR_PER_MB 1000.0 static double calc_frame_boost(VP10_COMP *cpi, const FIRSTPASS_STATS *this_frame, - double this_frame_mv_in_out, - double max_boost) { + double this_frame_mv_in_out, double max_boost) { double frame_boost; - const double lq = - vp10_convert_qindex_to_q(cpi->rc.avg_frame_qindex[INTER_FRAME], - cpi->common.bit_depth); + const double lq = vp10_convert_qindex_to_q( + cpi->rc.avg_frame_qindex[INTER_FRAME], cpi->common.bit_depth); const double boost_q_correction = VPXMIN((0.5 + (lq * 0.015)), 1.5); - int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE) - ? cpi->initial_mbs : cpi->common.MBs; + int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE) ? cpi->initial_mbs + : cpi->common.MBs; // Correct for any inactive region in the image num_mbs = (int)VPXMAX(1, num_mbs * calculate_active_area(cpi, this_frame)); @@ -1452,9 +1390,8 @@ static double calc_frame_boost(VP10_COMP *cpi, return VPXMIN(frame_boost, max_boost * boost_q_correction); } -static int calc_arf_boost(VP10_COMP *cpi, int offset, - int f_frames, int b_frames, - int *f_boost, int *b_boost) { +static int calc_arf_boost(VP10_COMP *cpi, int offset, int f_frames, + int b_frames, int *f_boost, int *b_boost) { TWO_PASS *const twopass = &cpi->twopass; int i; double boost_score = 0.0; @@ -1469,14 +1406,12 @@ static int calc_arf_boost(VP10_COMP *cpi, int offset, // Search forward from the proposed arf/next gf position. for (i = 0; i < f_frames; ++i) { const FIRSTPASS_STATS *this_frame = read_frame_stats(twopass, i + offset); - if (this_frame == NULL) - break; + if (this_frame == NULL) break; // Update the motion related elements to the boost calculation. - accumulate_frame_motion_stats(this_frame, - &this_frame_mv_in_out, &mv_in_out_accumulator, - &abs_mv_in_out_accumulator, - &mv_ratio_accumulator); + accumulate_frame_motion_stats( + this_frame, &this_frame_mv_in_out, &mv_in_out_accumulator, + &abs_mv_in_out_accumulator, &mv_ratio_accumulator); // We want to discount the flash frame itself and the recovery // frame that follows as both will have poor scores. @@ -1487,12 +1422,13 @@ static int calc_arf_boost(VP10_COMP *cpi, int offset, if (!flash_detected) { decay_accumulator *= get_prediction_decay_rate(cpi, this_frame); decay_accumulator = decay_accumulator < MIN_DECAY_FACTOR - ? MIN_DECAY_FACTOR : decay_accumulator; + ? MIN_DECAY_FACTOR + : decay_accumulator; } - boost_score += decay_accumulator * calc_frame_boost(cpi, this_frame, - this_frame_mv_in_out, - GF_MAX_BOOST); + boost_score += + decay_accumulator * + calc_frame_boost(cpi, this_frame, this_frame_mv_in_out, GF_MAX_BOOST); } *f_boost = (int)boost_score; @@ -1508,14 +1444,12 @@ static int calc_arf_boost(VP10_COMP *cpi, int offset, // Search backward towards last gf position. for (i = -1; i >= -b_frames; --i) { const FIRSTPASS_STATS *this_frame = read_frame_stats(twopass, i + offset); - if (this_frame == NULL) - break; + if (this_frame == NULL) break; // Update the motion related elements to the boost calculation. - accumulate_frame_motion_stats(this_frame, - &this_frame_mv_in_out, &mv_in_out_accumulator, - &abs_mv_in_out_accumulator, - &mv_ratio_accumulator); + accumulate_frame_motion_stats( + this_frame, &this_frame_mv_in_out, &mv_in_out_accumulator, + &abs_mv_in_out_accumulator, &mv_ratio_accumulator); // We want to discount the the flash frame itself and the recovery // frame that follows as both will have poor scores. @@ -1526,12 +1460,13 @@ static int calc_arf_boost(VP10_COMP *cpi, int offset, if (!flash_detected) { decay_accumulator *= get_prediction_decay_rate(cpi, this_frame); decay_accumulator = decay_accumulator < MIN_DECAY_FACTOR - ? MIN_DECAY_FACTOR : decay_accumulator; + ? MIN_DECAY_FACTOR + : decay_accumulator; } - boost_score += decay_accumulator * calc_frame_boost(cpi, this_frame, - this_frame_mv_in_out, - GF_MAX_BOOST); + boost_score += + decay_accumulator * + calc_frame_boost(cpi, this_frame, this_frame_mv_in_out, GF_MAX_BOOST); } *b_boost = (int)boost_score; @@ -1579,9 +1514,10 @@ static int64_t calculate_total_gf_group_bits(VP10_COMP *cpi, } // Clamp odd edge cases. - total_group_bits = (total_group_bits < 0) ? - 0 : (total_group_bits > twopass->kf_group_bits) ? - twopass->kf_group_bits : total_group_bits; + total_group_bits = + (total_group_bits < 0) ? 0 : (total_group_bits > twopass->kf_group_bits) + ? twopass->kf_group_bits + : total_group_bits; // Clip based on user supplied data rate variability limit. if (total_group_bits > (int64_t)max_bits * rc->baseline_gf_interval) @@ -1591,13 +1527,12 @@ static int64_t calculate_total_gf_group_bits(VP10_COMP *cpi, } // Calculate the number bits extra to assign to boosted frames in a group. -static int calculate_boost_bits(int frame_count, - int boost, int64_t total_group_bits) { +static int calculate_boost_bits(int frame_count, int boost, + int64_t total_group_bits) { int allocation_chunks; // return 0 for invalid inputs (could arise e.g. through rounding errors) - if (!boost || (total_group_bits <= 0) || (frame_count <= 0) ) - return 0; + if (!boost || (total_group_bits <= 0) || (frame_count <= 0)) return 0; allocation_chunks = (frame_count * 100) + boost; @@ -1679,8 +1614,7 @@ static void allocate_gf_group_bits(VP10_COMP *cpi, int64_t gf_group_bits, gf_group->arf_ref_idx[frame_index] = arf_buffer_indices[0]; // Step over the golden frame / overlay frame - if (EOF == input_stats(twopass, &frame_stats)) - return; + if (EOF == input_stats(twopass, &frame_stats)) return; } #if CONFIG_EXT_REFS @@ -1690,8 +1624,7 @@ static void allocate_gf_group_bits(VP10_COMP *cpi, int64_t gf_group_bits, // Deduct the boost bits for arf (or gf if it is not a key frame) // from the group total. - if (rc->source_alt_ref_pending || !key_frame) - total_group_bits -= gf_arf_bits; + if (rc->source_alt_ref_pending || !key_frame) total_group_bits -= gf_arf_bits; frame_index++; @@ -1710,13 +1643,13 @@ static void allocate_gf_group_bits(VP10_COMP *cpi, int64_t gf_group_bits, gf_group->arf_update_idx[frame_index] = arf_buffer_indices[0]; gf_group->arf_ref_idx[frame_index] = - arf_buffer_indices[cpi->multi_arf_last_grp_enabled && - rc->source_alt_ref_active]; + arf_buffer_indices[cpi->multi_arf_last_grp_enabled && + rc->source_alt_ref_active]; #if CONFIG_EXT_REFS gf_group->bidir_pred_enabled[frame_index] = 0; gf_group->brf_src_offset[frame_index] = 0; - // NOTE: "bidir_pred_frame_index" stays unchanged for ARF_UPDATE frames. +// NOTE: "bidir_pred_frame_index" stays unchanged for ARF_UPDATE frames. #endif // CONFIG_EXT_REFS ++frame_index; @@ -1726,7 +1659,7 @@ static void allocate_gf_group_bits(VP10_COMP *cpi, int64_t gf_group_bits, gf_group->update_type[frame_index] = ARF_UPDATE; gf_group->rf_level[frame_index] = GF_ARF_LOW; gf_group->arf_src_offset[frame_index] = - (unsigned char)((rc->baseline_gf_interval >> 1) - 1); + (unsigned char)((rc->baseline_gf_interval >> 1) - 1); gf_group->arf_update_idx[frame_index] = arf_buffer_indices[1]; gf_group->arf_ref_idx[frame_index] = arf_buffer_indices[0]; ++frame_index; @@ -1739,8 +1672,7 @@ static void allocate_gf_group_bits(VP10_COMP *cpi, int64_t gf_group_bits, // Allocate bits to the other frames in the group. for (i = 0; i < rc->baseline_gf_interval - rc->source_alt_ref_pending; ++i) { int arf_idx = 0; - if (EOF == input_stats(twopass, &frame_stats)) - break; + if (EOF == input_stats(twopass, &frame_stats)) break; modified_err = calculate_modified_err(cpi, twopass, oxcf, &frame_stats); @@ -1755,14 +1687,13 @@ static void allocate_gf_group_bits(VP10_COMP *cpi, int64_t gf_group_bits, mid_boost_bits += (target_frame_size >> 4); target_frame_size -= (target_frame_size >> 4); - if (frame_index <= mid_frame_idx) - arf_idx = 1; + if (frame_index <= mid_frame_idx) arf_idx = 1; } gf_group->arf_update_idx[frame_index] = arf_buffer_indices[arf_idx]; gf_group->arf_ref_idx[frame_index] = arf_buffer_indices[arf_idx]; - target_frame_size = clamp(target_frame_size, 0, - VPXMIN(max_bits, (int)total_group_bits)); + target_frame_size = + clamp(target_frame_size, 0, VPXMIN(max_bits, (int)total_group_bits)); #if CONFIG_EXT_REFS // NOTE: BIDIR_PRED is only enabled when the length of the bi-predictive @@ -1777,14 +1708,14 @@ static void allocate_gf_group_bits(VP10_COMP *cpi, int64_t gf_group_bits, gf_group->update_type[frame_index] = BRF_UPDATE; gf_group->bidir_pred_enabled[frame_index] = 1; gf_group->brf_src_offset[frame_index] = cur_brf_src_offset; - // --- LAST_BIPRED_UPDATE --- + // --- LAST_BIPRED_UPDATE --- } else if (bipred_frame_index == rc->bipred_group_interval) { gf_group->update_type[frame_index] = LAST_BIPRED_UPDATE; gf_group->bidir_pred_enabled[frame_index] = 1; gf_group->brf_src_offset[frame_index] = 0; // Reset the bi-predictive frame index. bipred_frame_index = 0; - // --- BIPRED_UPDATE --- + // --- BIPRED_UPDATE --- } else { gf_group->update_type[frame_index] = BIPRED_UPDATE; gf_group->bidir_pred_enabled[frame_index] = 1; @@ -1794,9 +1725,10 @@ static void allocate_gf_group_bits(VP10_COMP *cpi, int64_t gf_group_bits, bipred_frame_index++; // Check whether the next bi-predictive frame group would entirely be // included within the current golden frame group. - if (bipred_frame_index == 1 && (i + 1 + cur_brf_src_offset) >= - (rc->baseline_gf_interval - rc->source_alt_ref_pending)) { - bipred_group_end = 1; + if (bipred_frame_index == 1 && + (i + 1 + cur_brf_src_offset) >= + (rc->baseline_gf_interval - rc->source_alt_ref_pending)) { + bipred_group_end = 1; } } else { #endif // CONFIG_EXT_REFS @@ -1944,12 +1876,10 @@ static void define_gf_group(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { // Set a maximum and minimum interval for the GF group. // If the image appears almost completely static we can extend beyond this. { - int int_max_q = - (int)(vp10_convert_qindex_to_q(twopass->active_worst_quality, - cpi->common.bit_depth)); - int int_lbq = - (int)(vp10_convert_qindex_to_q(rc->last_boosted_qindex, - cpi->common.bit_depth)); + int int_max_q = (int)(vp10_convert_qindex_to_q( + twopass->active_worst_quality, cpi->common.bit_depth)); + int int_lbq = (int)(vp10_convert_qindex_to_q(rc->last_boosted_qindex, + cpi->common.bit_depth)); active_min_gf_interval = rc->min_gf_interval + VPXMIN(2, int_max_q / 200); if (active_min_gf_interval > rc->max_gf_interval) @@ -1985,18 +1915,16 @@ static void define_gf_group(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { gf_group_skip_pct += this_frame->intra_skip_pct; gf_group_inactive_zone_rows += this_frame->inactive_zone_rows; - if (EOF == input_stats(twopass, &next_frame)) - break; + if (EOF == input_stats(twopass, &next_frame)) break; // Test for the case where there is a brief flash but the prediction // quality back to an earlier frame is then restored. flash_detected = detect_flash(twopass, 0); // Update the motion related elements to the boost calculation. - accumulate_frame_motion_stats(&next_frame, - &this_frame_mv_in_out, &mv_in_out_accumulator, - &abs_mv_in_out_accumulator, - &mv_ratio_accumulator); + accumulate_frame_motion_stats( + &next_frame, &this_frame_mv_in_out, &mv_in_out_accumulator, + &abs_mv_in_out_accumulator, &mv_ratio_accumulator); // Accumulate the effect of prediction quality decay. if (!flash_detected) { @@ -2019,23 +1947,23 @@ static void define_gf_group(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { } // Calculate a boost number for this frame. - boost_score += decay_accumulator * calc_frame_boost(cpi, &next_frame, - this_frame_mv_in_out, - GF_MAX_BOOST); + boost_score += + decay_accumulator * + calc_frame_boost(cpi, &next_frame, this_frame_mv_in_out, GF_MAX_BOOST); // Break out conditions. if ( - // Break at active_max_gf_interval unless almost totally static. - (i >= (active_max_gf_interval + arf_active_or_kf) && - zero_motion_accumulator < 0.995) || - ( - // Don't break out with a very short interval. - (i >= active_min_gf_interval + arf_active_or_kf) && - (!flash_detected) && - ((mv_ratio_accumulator > mv_ratio_accumulator_thresh) || - (abs_mv_in_out_accumulator > 3.0) || - (mv_in_out_accumulator < -2.0) || - ((boost_score - old_boost_score) < BOOST_BREAKOUT)))) { + // Break at active_max_gf_interval unless almost totally static. + (i >= (active_max_gf_interval + arf_active_or_kf) && + zero_motion_accumulator < 0.995) || + ( + // Don't break out with a very short interval. + (i >= active_min_gf_interval + arf_active_or_kf) && + (!flash_detected) && + ((mv_ratio_accumulator > mv_ratio_accumulator_thresh) || + (abs_mv_in_out_accumulator > 3.0) || + (mv_in_out_accumulator < -2.0) || + ((boost_score - old_boost_score) < BOOST_BREAKOUT)))) { boost_score = old_boost_score; break; } @@ -2050,18 +1978,19 @@ static void define_gf_group(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { rc->constrained_gf_group = (i >= rc->frames_to_key) ? 1 : 0; // Should we use the alternate reference frame. - if (allow_alt_ref && - (i < cpi->oxcf.lag_in_frames) && - (i >= rc->min_gf_interval)) { + if (allow_alt_ref && (i < cpi->oxcf.lag_in_frames) && + (i >= rc->min_gf_interval)) { // Calculate the boost for alt ref. - rc->gfu_boost = calc_arf_boost(cpi, 0, (i - 1), (i - 1), &f_boost, - &b_boost); + rc->gfu_boost = + calc_arf_boost(cpi, 0, (i - 1), (i - 1), &f_boost, &b_boost); rc->source_alt_ref_pending = 1; // Test to see if multi arf is appropriate. cpi->multi_arf_enabled = - (cpi->multi_arf_allowed && (rc->baseline_gf_interval >= 6) && - (zero_motion_accumulator < 0.995)) ? 1 : 0; + (cpi->multi_arf_allowed && (rc->baseline_gf_interval >= 6) && + (zero_motion_accumulator < 0.995)) + ? 1 + : 0; } else { rc->gfu_boost = VPXMAX((int)boost_score, MIN_ARF_GF_BOOST); rc->source_alt_ref_pending = 0; @@ -2075,8 +2004,7 @@ static void define_gf_group(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { #if CONFIG_EXT_REFS rc->bipred_group_interval = BFG_INTERVAL; // The minimum bi-predictive frame group interval is 2. - if (rc->bipred_group_interval < 2) - rc->bipred_group_interval = 0; + if (rc->bipred_group_interval < 2) rc->bipred_group_interval = 0; #endif // CONFIG_EXT_REFS // Reset the file position. @@ -2093,13 +2021,13 @@ static void define_gf_group(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { // of the allocated bit budget. if ((cpi->oxcf.rc_mode != VPX_Q) && (rc->baseline_gf_interval > 1)) { const int vbr_group_bits_per_frame = - (int)(gf_group_bits / rc->baseline_gf_interval); - const double group_av_err = gf_group_raw_error / rc->baseline_gf_interval; + (int)(gf_group_bits / rc->baseline_gf_interval); + const double group_av_err = gf_group_raw_error / rc->baseline_gf_interval; const double group_av_skip_pct = - gf_group_skip_pct / rc->baseline_gf_interval; + gf_group_skip_pct / rc->baseline_gf_interval; const double group_av_inactive_zone = - ((gf_group_inactive_zone_rows * 2) / - (rc->baseline_gf_interval * (double)cm->mb_rows)); + ((gf_group_inactive_zone_rows * 2) / + (rc->baseline_gf_interval * (double)cm->mb_rows)); int tmp_q; // rc factor is a weight factor that corrects for local rate control drift. @@ -2111,19 +2039,17 @@ static void define_gf_group(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { rc_factor = VPXMIN(RC_FACTOR_MAX, (double)(100 - rc->rate_error_estimate) / 100.0); } - tmp_q = - get_twopass_worst_quality(cpi, group_av_err, - (group_av_skip_pct + group_av_inactive_zone), - vbr_group_bits_per_frame, - twopass->kfgroup_inter_fraction * rc_factor); + tmp_q = get_twopass_worst_quality( + cpi, group_av_err, (group_av_skip_pct + group_av_inactive_zone), + vbr_group_bits_per_frame, twopass->kfgroup_inter_fraction * rc_factor); twopass->active_worst_quality = - VPXMAX(tmp_q, twopass->active_worst_quality >> 1); + VPXMAX(tmp_q, twopass->active_worst_quality >> 1); } #endif // Calculate the extra bits to be used for boosted frame(s) - gf_arf_bits = calculate_boost_bits(rc->baseline_gf_interval, - rc->gfu_boost, gf_group_bits); + gf_arf_bits = calculate_boost_bits(rc->baseline_gf_interval, rc->gfu_boost, + gf_group_bits); // Adjust KF group bits and error remaining. twopass->kf_group_error_left -= (int64_t)gf_group_err; @@ -2150,9 +2076,8 @@ static void define_gf_group(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { // Calculate a section intra ratio used in setting max loop filter. if (cpi->common.frame_type != KEY_FRAME) { - twopass->section_intra_rating = - calculate_section_intra_ratio(start_pos, twopass->stats_in_end, - rc->baseline_gf_interval); + twopass->section_intra_rating = calculate_section_intra_ratio( + start_pos, twopass->stats_in_end, rc->baseline_gf_interval); } if (oxcf->resize_mode == RESIZE_DYNAMIC) { @@ -2194,7 +2119,7 @@ static int test_candidate_kf(TWO_PASS *twopass, int is_viable_kf = 0; double pcnt_intra = 1.0 - this_frame->pcnt_inter; double modified_pcnt_inter = - this_frame->pcnt_inter - this_frame->pcnt_neutral; + this_frame->pcnt_inter - this_frame->pcnt_neutral; // Does the frame satisfy the primary criteria of a key frame? // See above for an explanation of the test criteria. @@ -2206,15 +2131,15 @@ static int test_candidate_kf(TWO_PASS *twopass, (pcnt_intra > (INTRA_VS_INTER_THRESH * modified_pcnt_inter)) && ((this_frame->intra_error / DOUBLE_DIVIDE_CHECK(this_frame->coded_error)) < - KF_II_ERR_THRESHOLD) && + KF_II_ERR_THRESHOLD) && ((fabs(last_frame->coded_error - this_frame->coded_error) / - DOUBLE_DIVIDE_CHECK(this_frame->coded_error) > + DOUBLE_DIVIDE_CHECK(this_frame->coded_error) > ERR_CHANGE_THRESHOLD) || (fabs(last_frame->intra_error - this_frame->intra_error) / - DOUBLE_DIVIDE_CHECK(this_frame->intra_error) > + DOUBLE_DIVIDE_CHECK(this_frame->intra_error) > ERR_CHANGE_THRESHOLD) || ((next_frame->intra_error / - DOUBLE_DIVIDE_CHECK(next_frame->coded_error)) > + DOUBLE_DIVIDE_CHECK(next_frame->coded_error)) > II_IMPROVEMENT_THRESHOLD))))) { int i; const FIRSTPASS_STATS *start_pos = twopass->stats_in; @@ -2228,8 +2153,7 @@ static int test_candidate_kf(TWO_PASS *twopass, double next_iiratio = (BOOST_FACTOR * local_next_frame.intra_error / DOUBLE_DIVIDE_CHECK(local_next_frame.coded_error)); - if (next_iiratio > KF_II_MAX) - next_iiratio = KF_II_MAX; + if (next_iiratio > KF_II_MAX) next_iiratio = KF_II_MAX; // Cumulative effect of decay in prediction quality. if (local_next_frame.pcnt_inter > 0.85) @@ -2241,10 +2165,9 @@ static int test_candidate_kf(TWO_PASS *twopass, boost_score += (decay_accumulator * next_iiratio); // Test various breakout clauses. - if ((local_next_frame.pcnt_inter < 0.05) || - (next_iiratio < 1.5) || - (((local_next_frame.pcnt_inter - - local_next_frame.pcnt_neutral) < 0.20) && + if ((local_next_frame.pcnt_inter < 0.05) || (next_iiratio < 1.5) || + (((local_next_frame.pcnt_inter - local_next_frame.pcnt_neutral) < + 0.20) && (next_iiratio < 3.0)) || ((boost_score - old_boost_score) < 3.0) || (local_next_frame.intra_error < 200)) { @@ -2254,8 +2177,7 @@ static int test_candidate_kf(TWO_PASS *twopass, old_boost_score = boost_score; // Get the next frame details - if (EOF == input_stats(twopass, &local_next_frame)) - break; + if (EOF == input_stats(twopass, &local_next_frame)) break; } // If there is tolerable prediction for at least the next 3 frames then @@ -2321,8 +2243,7 @@ static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { kf_mod_err = calculate_modified_err(cpi, twopass, oxcf, this_frame); // Initialize the decay rates for the recent frames to check - for (j = 0; j < FRAMES_TO_CHECK_DECAY; ++j) - recent_loop_decay[j] = 1.0; + for (j = 0; j < FRAMES_TO_CHECK_DECAY; ++j) recent_loop_decay[j] = 1.0; // Find the next keyframe. i = 0; @@ -2366,8 +2287,7 @@ static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { // If we don't have a real key frame within the next two // key_freq intervals then break out of the loop. - if (rc->frames_to_key >= 2 * cpi->oxcf.key_freq) - break; + if (rc->frames_to_key >= 2 * cpi->oxcf.key_freq) break; } else { ++rc->frames_to_key; } @@ -2378,8 +2298,7 @@ static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { // We already breakout of the loop above at 2x max. // This code centers the extra kf if the actual natural interval // is between 1x and 2x. - if (cpi->oxcf.auto_key && - rc->frames_to_key > cpi->oxcf.key_freq) { + if (cpi->oxcf.auto_key && rc->frames_to_key > cpi->oxcf.key_freq) { FIRSTPASS_STATS tmp_frame = first_frame; rc->frames_to_key /= 2; @@ -2418,8 +2337,8 @@ static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { // Default allocation based on bits left and relative // complexity of the section. - twopass->kf_group_bits = (int64_t)(twopass->bits_left * - (kf_group_err / twopass->modified_error_left)); + twopass->kf_group_bits = (int64_t)( + twopass->bits_left * (kf_group_err / twopass->modified_error_left)); // Clip based on maximum per frame rate defined by the user. max_grp_bits = (int64_t)max_bits * (int64_t)rc->frames_to_key; @@ -2438,23 +2357,22 @@ static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { decay_accumulator = 1.0; boost_score = 0.0; for (i = 0; i < (rc->frames_to_key - 1); ++i) { - if (EOF == input_stats(twopass, &next_frame)) - break; + if (EOF == input_stats(twopass, &next_frame)) break; // Monitor for static sections. - zero_motion_accumulator = VPXMIN( - zero_motion_accumulator, get_zero_motion_factor(cpi, &next_frame)); + zero_motion_accumulator = VPXMIN(zero_motion_accumulator, + get_zero_motion_factor(cpi, &next_frame)); // Not all frames in the group are necessarily used in calculating boost. if ((i <= rc->max_gf_interval) || ((i <= (rc->max_gf_interval * 4)) && (decay_accumulator > 0.5))) { const double frame_boost = - calc_frame_boost(cpi, this_frame, 0, KF_MAX_BOOST); + calc_frame_boost(cpi, this_frame, 0, KF_MAX_BOOST); // How fast is prediction quality decaying. if (!detect_flash(twopass, 0)) { const double loop_decay_rate = - get_prediction_decay_rate(cpi, &next_frame); + get_prediction_decay_rate(cpi, &next_frame); decay_accumulator *= loop_decay_rate; decay_accumulator = VPXMAX(decay_accumulator, MIN_DECAY_FACTOR); av_decay_accumulator += decay_accumulator; @@ -2471,9 +2389,8 @@ static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { twopass->kf_zeromotion_pct = (int)(zero_motion_accumulator * 100.0); // Calculate a section intra ratio used in setting max loop filter. - twopass->section_intra_rating = - calculate_section_intra_ratio(start_position, twopass->stats_in_end, - rc->frames_to_key); + twopass->section_intra_rating = calculate_section_intra_ratio( + start_position, twopass->stats_in_end, rc->frames_to_key); // Apply various clamps for min and max boost rc->kf_boost = (int)(av_decay_accumulator * boost_score); @@ -2481,15 +2398,15 @@ static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) { rc->kf_boost = VPXMAX(rc->kf_boost, MIN_KF_BOOST); // Work out how many bits to allocate for the key frame itself. - kf_bits = calculate_boost_bits((rc->frames_to_key - 1), - rc->kf_boost, twopass->kf_group_bits); + kf_bits = calculate_boost_bits((rc->frames_to_key - 1), rc->kf_boost, + twopass->kf_group_bits); // Work out the fraction of the kf group bits reserved for the inter frames // within the group after discounting the bits for the kf itself. if (twopass->kf_group_bits) { twopass->kfgroup_inter_fraction = - (double)(twopass->kf_group_bits - kf_bits) / - (double)twopass->kf_group_bits; + (double)(twopass->kf_group_bits - kf_bits) / + (double)twopass->kf_group_bits; } else { twopass->kfgroup_inter_fraction = 1.0; } @@ -2530,27 +2447,21 @@ static void configure_buffer_updates(VP10_COMP *cpi) { #endif // CONFIG_EXT_REFS switch (twopass->gf_group.update_type[twopass->gf_group.index]) { - case KF_UPDATE: - cpi->refresh_last_frame = 1; - cpi->refresh_golden_frame = 1; + case KF_UPDATE: cpi->refresh_last_frame = 1; cpi->refresh_golden_frame = 1; #if CONFIG_EXT_REFS cpi->refresh_bwd_ref_frame = 1; #endif // CONFIG_EXT_REFS cpi->refresh_alt_ref_frame = 1; break; - case LF_UPDATE: - cpi->refresh_last_frame = 1; - cpi->refresh_golden_frame = 0; + case LF_UPDATE: cpi->refresh_last_frame = 1; cpi->refresh_golden_frame = 0; #if CONFIG_EXT_REFS cpi->refresh_bwd_ref_frame = 0; #endif // CONFIG_EXT_REFS cpi->refresh_alt_ref_frame = 0; break; - case GF_UPDATE: - cpi->refresh_last_frame = 1; - cpi->refresh_golden_frame = 1; + case GF_UPDATE: cpi->refresh_last_frame = 1; cpi->refresh_golden_frame = 1; #if CONFIG_EXT_REFS cpi->refresh_bwd_ref_frame = 0; #endif // CONFIG_EXT_REFS @@ -2567,9 +2478,7 @@ static void configure_buffer_updates(VP10_COMP *cpi) { cpi->rc.is_src_frame_alt_ref = 1; break; - case ARF_UPDATE: - cpi->refresh_last_frame = 0; - cpi->refresh_golden_frame = 0; + case ARF_UPDATE: cpi->refresh_last_frame = 0; cpi->refresh_golden_frame = 0; #if CONFIG_EXT_REFS cpi->refresh_bwd_ref_frame = 0; #endif // CONFIG_EXT_REFS @@ -2602,9 +2511,7 @@ static void configure_buffer_updates(VP10_COMP *cpi) { break; #endif // CONFIG_EXT_REFS - default: - assert(0); - break; + default: assert(0); break; } } @@ -2616,13 +2523,15 @@ static int is_skippable_frame(const VP10_COMP *cpi) { const TWO_PASS *const twopass = &cpi->twopass; return (!frame_is_intra_only(&cpi->common) && - twopass->stats_in - 2 > twopass->stats_in_start && - twopass->stats_in < twopass->stats_in_end && - (twopass->stats_in - 1)->pcnt_inter - (twopass->stats_in - 1)->pcnt_motion - == 1 && - (twopass->stats_in - 2)->pcnt_inter - (twopass->stats_in - 2)->pcnt_motion - == 1 && - twopass->stats_in->pcnt_inter - twopass->stats_in->pcnt_motion == 1); + twopass->stats_in - 2 > twopass->stats_in_start && + twopass->stats_in < twopass->stats_in_end && + (twopass->stats_in - 1)->pcnt_inter - + (twopass->stats_in - 1)->pcnt_motion == + 1 && + (twopass->stats_in - 2)->pcnt_inter - + (twopass->stats_in - 2)->pcnt_motion == + 1 && + twopass->stats_in->pcnt_inter - twopass->stats_in->pcnt_motion == 1); } void vp10_rc_get_second_pass_params(VP10_COMP *cpi) { @@ -2635,11 +2544,9 @@ void vp10_rc_get_second_pass_params(VP10_COMP *cpi) { int target_rate; - frames_left = (int)(twopass->total_stats.count - - cm->current_video_frame); + frames_left = (int)(twopass->total_stats.count - cm->current_video_frame); - if (!twopass->stats_in) - return; + if (!twopass->stats_in) return; // If this is an arf frame then we dont want to read the stats file or // advance the input pointer as we already have what we need. @@ -2667,20 +2574,19 @@ void vp10_rc_get_second_pass_params(VP10_COMP *cpi) { twopass->active_worst_quality = cpi->oxcf.cq_level; } else if (cm->current_video_frame == 0) { // Special case code for first frame. - const int section_target_bandwidth = (int)(twopass->bits_left / - frames_left); + const int section_target_bandwidth = + (int)(twopass->bits_left / frames_left); const double section_length = twopass->total_left_stats.count; const double section_error = - twopass->total_left_stats.coded_error / section_length; + twopass->total_left_stats.coded_error / section_length; const double section_intra_skip = - twopass->total_left_stats.intra_skip_pct / section_length; + twopass->total_left_stats.intra_skip_pct / section_length; const double section_inactive_zone = - (twopass->total_left_stats.inactive_zone_rows * 2) / - ((double)cm->mb_rows * section_length); - const int tmp_q = - get_twopass_worst_quality(cpi, section_error, - section_intra_skip + section_inactive_zone, - section_target_bandwidth, DEFAULT_GRP_WEIGHT); + (twopass->total_left_stats.inactive_zone_rows * 2) / + ((double)cm->mb_rows * section_length); + const int tmp_q = get_twopass_worst_quality( + cpi, section_error, section_intra_skip + section_inactive_zone, + section_target_bandwidth, DEFAULT_GRP_WEIGHT); twopass->active_worst_quality = tmp_q; twopass->baseline_active_worst_quality = tmp_q; @@ -2693,8 +2599,7 @@ void vp10_rc_get_second_pass_params(VP10_COMP *cpi) { } vp10_zero(this_frame); - if (EOF == input_stats(twopass, &this_frame)) - return; + if (EOF == input_stats(twopass, &this_frame)) return; // Set the frame content type flag. if (this_frame.intra_skip_pct >= FC_ANIMATION_THRESH) @@ -2724,9 +2629,9 @@ void vp10_rc_get_second_pass_params(VP10_COMP *cpi) { FILE *fpfile; fpfile = fopen("arf.stt", "a"); ++arf_count; - fprintf(fpfile, "%10d %10ld %10d %10d %10ld\n", - cm->current_video_frame, rc->frames_till_gf_update_due, - rc->kf_boost, arf_count, rc->gfu_boost); + fprintf(fpfile, "%10d %10ld %10d %10d %10ld\n", cm->current_video_frame, + rc->frames_till_gf_update_due, rc->kf_boost, arf_count, + rc->gfu_boost); fclose(fpfile); } @@ -2752,11 +2657,12 @@ void vp10_rc_get_second_pass_params(VP10_COMP *cpi) { { const int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE) - ? cpi->initial_mbs : cpi->common.MBs; + ? cpi->initial_mbs + : cpi->common.MBs; // The multiplication by 256 reverses a scaling factor of (>> 8) // applied when combining MB error values for the frame. twopass->mb_av_energy = - log(((this_frame.intra_error * 256.0) / num_mbs) + 1.0); + log(((this_frame.intra_error * 256.0) / num_mbs) + 1.0); } // Update the total stats remaining structure. @@ -2782,7 +2688,7 @@ void vp10_twopass_postencode_update(VP10_COMP *cpi) { // Calculate the pct rc error. if (rc->total_actual_bits) { rc->rate_error_estimate = - (int)((rc->vbr_bits_off_target * 100) / rc->total_actual_bits); + (int)((rc->vbr_bits_off_target * 100) / rc->total_actual_bits); rc->rate_error_estimate = clamp(rc->rate_error_estimate, -100, 100); } else { rc->rate_error_estimate = 0; @@ -2802,7 +2708,7 @@ void vp10_twopass_postencode_update(VP10_COMP *cpi) { (cpi->twopass.gf_zeromotion_pct < VLOW_MOTION_THRESHOLD) && !cpi->rc.is_src_frame_alt_ref) { const int maxq_adj_limit = - rc->worst_quality - twopass->active_worst_quality; + rc->worst_quality - twopass->active_worst_quality; const int minq_adj_limit = (cpi->oxcf.rc_mode == VPX_CQ ? MINQ_ADJ_LIMIT_CQ : MINQ_ADJ_LIMIT); @@ -2811,7 +2717,7 @@ void vp10_twopass_postencode_update(VP10_COMP *cpi) { --twopass->extend_maxq; if (rc->rolling_target_bits >= rc->rolling_actual_bits) ++twopass->extend_minq; - // Overshoot. + // Overshoot. } else if (rc->rate_error_estimate < -cpi->oxcf.over_shoot_pct) { --twopass->extend_minq; if (rc->rolling_target_bits < rc->rolling_actual_bits) @@ -2840,14 +2746,14 @@ void vp10_twopass_postencode_update(VP10_COMP *cpi) { int fast_extra_thresh = rc->base_frame_target / HIGH_UNDERSHOOT_RATIO; if (rc->projected_frame_size < fast_extra_thresh) { rc->vbr_bits_off_target_fast += - fast_extra_thresh - rc->projected_frame_size; + fast_extra_thresh - rc->projected_frame_size; rc->vbr_bits_off_target_fast = - VPXMIN(rc->vbr_bits_off_target_fast, (4 * rc->avg_frame_bandwidth)); + VPXMIN(rc->vbr_bits_off_target_fast, (4 * rc->avg_frame_bandwidth)); // Fast adaptation of minQ if necessary to use up the extra bits. if (rc->avg_frame_bandwidth) { twopass->extend_minq_fast = - (int)(rc->vbr_bits_off_target_fast * 8 / rc->avg_frame_bandwidth); + (int)(rc->vbr_bits_off_target_fast * 8 / rc->avg_frame_bandwidth); } twopass->extend_minq_fast = VPXMIN( twopass->extend_minq_fast, minq_adj_limit - twopass->extend_minq); diff --git a/vp10/encoder/firstpass.h b/vp10/encoder/firstpass.h index c9f4ad360..3642cfda6 100644 --- a/vp10/encoder/firstpass.h +++ b/vp10/encoder/firstpass.h @@ -43,7 +43,7 @@ typedef struct { // Length of the bi-predictive frame group (BFG) // NOTE: Currently each BFG contains one backward ref (BWF) frame plus a certain // number of bi-predictive frames. -#define BFG_INTERVAL 2 +#define BFG_INTERVAL 2 #endif // CONFIG_EXT_REFS #define VLOW_MOTION_THRESHOLD 950 @@ -80,9 +80,9 @@ typedef enum { ARF_UPDATE = 3, OVERLAY_UPDATE = 4, #if CONFIG_EXT_REFS - BRF_UPDATE = 5, // Backward Reference Frame + BRF_UPDATE = 5, // Backward Reference Frame LAST_BIPRED_UPDATE = 6, // Last Bi-predictive Frame - BIPRED_UPDATE = 7, // Bi-predictive Frame, but not the last one + BIPRED_UPDATE = 7, // Bi-predictive Frame, but not the last one FRAME_UPDATE_TYPES = 8 #else FRAME_UPDATE_TYPES = 5 @@ -173,9 +173,8 @@ void vp10_twopass_postencode_update(struct VP10_COMP *cpi); void vp10_init_subsampling(struct VP10_COMP *cpi); -void vp10_calculate_coded_size(struct VP10_COMP *cpi, - int *scaled_frame_width, - int *scaled_frame_height); +void vp10_calculate_coded_size(struct VP10_COMP *cpi, int *scaled_frame_width, + int *scaled_frame_height); #ifdef __cplusplus } // extern "C" diff --git a/vp10/encoder/global_motion.c b/vp10/encoder/global_motion.c index 387a40b7e..88f344fb3 100644 --- a/vp10/encoder/global_motion.c +++ b/vp10/encoder/global_motion.c @@ -24,11 +24,11 @@ int compute_global_motion_feature_based(struct VP10_COMP *cpi, YV12_BUFFER_CONFIG *frm, YV12_BUFFER_CONFIG *ref, double inlier_prob, double *H) { - (void) cpi; - (void) type; - (void) frm; - (void) ref; - (void) inlier_prob; - (void) H; + (void)cpi; + (void)type; + (void)frm; + (void)ref; + (void)inlier_prob; + (void)H; return 0; } diff --git a/vp10/encoder/global_motion.h b/vp10/encoder/global_motion.h index 35deb1361..5832b6105 100644 --- a/vp10/encoder/global_motion.h +++ b/vp10/encoder/global_motion.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_GLOBAL_MOTION_H_ #define VP10_ENCODER_GLOBAL_MOTION_H_ @@ -27,4 +26,3 @@ int compute_global_motion_feature_based(struct VP10_COMP *cpi, } // extern "C" #endif #endif // VP10_ENCODER_GLOBAL_MOTION_H_ - diff --git a/vp10/encoder/hybrid_fwd_txfm.c b/vp10/encoder/hybrid_fwd_txfm.c index d5cf82706..f385262a8 100644 --- a/vp10/encoder/hybrid_fwd_txfm.c +++ b/vp10/encoder/hybrid_fwd_txfm.c @@ -35,9 +35,7 @@ static void fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff, case DCT_DCT: case ADST_DCT: case DCT_ADST: - case ADST_ADST: - vp10_fht4x4(src_diff, coeff, diff_stride, tx_type); - break; + case ADST_ADST: vp10_fht4x4(src_diff, coeff, diff_stride, tx_type); break; #if CONFIG_EXT_TX case FLIPADST_DCT: case DCT_FLIPADST: @@ -49,15 +47,10 @@ static void fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff, case V_ADST: case H_ADST: case V_FLIPADST: - case H_FLIPADST: - vp10_fht4x4(src_diff, coeff, diff_stride, tx_type); - break; - case IDTX: - vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 4, tx_type); - break; + case H_FLIPADST: vp10_fht4x4(src_diff, coeff, diff_stride, tx_type); break; + case IDTX: vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 4, tx_type); break; #endif // CONFIG_EXT_TX - default: - assert(0); + default: assert(0); } } @@ -65,14 +58,14 @@ static void fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff, static void fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff, int diff_stride, TX_TYPE tx_type, FWD_TXFM_OPT fwd_txfm_opt) { - (void) fwd_txfm_opt; + (void)fwd_txfm_opt; vp10_fht8x4(src_diff, coeff, diff_stride, tx_type); } static void fwd_txfm_4x8(const int16_t *src_diff, tran_low_t *coeff, int diff_stride, TX_TYPE tx_type, FWD_TXFM_OPT fwd_txfm_opt) { - (void) fwd_txfm_opt; + (void)fwd_txfm_opt; vp10_fht4x8(src_diff, coeff, diff_stride, tx_type); } #endif // CONFIG_EXT_TX @@ -101,15 +94,10 @@ static void fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff, case V_ADST: case H_ADST: case V_FLIPADST: - case H_FLIPADST: - vp10_fht8x8(src_diff, coeff, diff_stride, tx_type); - break; - case IDTX: - vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 8, tx_type); - break; + case H_FLIPADST: vp10_fht8x8(src_diff, coeff, diff_stride, tx_type); break; + case IDTX: vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 8, tx_type); break; #endif // CONFIG_EXT_TX - default: - assert(0); + default: assert(0); } } @@ -144,8 +132,7 @@ static void fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff, vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 16, tx_type); break; #endif // CONFIG_EXT_TX - default: - assert(0); + default: assert(0); } } @@ -182,9 +169,7 @@ static void fwd_txfm_32x32(int rd_transform, const int16_t *src_diff, vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 32, tx_type); break; #endif // CONFIG_EXT_TX - default: - assert(0); - break; + default: assert(0); break; } } @@ -221,12 +206,9 @@ static void highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff, case H_FLIPADST: vp10_highbd_fht4x4_c(src_diff, coeff, diff_stride, tx_type); break; - case IDTX: - vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 4, tx_type); - break; + case IDTX: vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 4, tx_type); break; #endif // CONFIG_EXT_TX - default: - assert(0); + default: assert(0); } } @@ -234,16 +216,16 @@ static void highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff, static void highbd_fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff, int diff_stride, TX_TYPE tx_type, FWD_TXFM_OPT fwd_txfm_opt, const int bd) { - (void) fwd_txfm_opt; - (void) bd; + (void)fwd_txfm_opt; + (void)bd; vp10_highbd_fht8x4(src_diff, coeff, diff_stride, tx_type); } static void highbd_fwd_txfm_4x8(const int16_t *src_diff, tran_low_t *coeff, int diff_stride, TX_TYPE tx_type, FWD_TXFM_OPT fwd_txfm_opt, const int bd) { - (void) fwd_txfm_opt; - (void) bd; + (void)fwd_txfm_opt; + (void)bd; vp10_highbd_fht4x8(src_diff, coeff, diff_stride, tx_type); } #endif // CONFIG_EXT_TX @@ -276,12 +258,9 @@ static void highbd_fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff, // Use C version since DST exists only in C vp10_highbd_fht8x8_c(src_diff, coeff, diff_stride, tx_type); break; - case IDTX: - vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 8, tx_type); - break; + case IDTX: vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 8, tx_type); break; #endif // CONFIG_EXT_TX - default: - assert(0); + default: assert(0); } } @@ -317,8 +296,7 @@ static void highbd_fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff, vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 16, tx_type); break; #endif // CONFIG_EXT_TX - default: - assert(0); + default: assert(0); } } @@ -353,9 +331,7 @@ static void highbd_fwd_txfm_32x32(int rd_transform, const int16_t *src_diff, vp10_fwd_idtx_c(src_diff, coeff, diff_stride, 32, tx_type); break; #endif // CONFIG_EXT_TX - default: - assert(0); - break; + default: assert(0); break; } } #endif // CONFIG_VP9_HIGHBITDEPTH @@ -389,9 +365,7 @@ void fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, int diff_stride, case TX_4X4: fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, lossless); break; - default: - assert(0); - break; + default: assert(0); break; } } @@ -410,30 +384,27 @@ void highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, fwd_txfm_opt, bd); break; case TX_16X16: - highbd_fwd_txfm_16x16(src_diff, coeff, diff_stride, tx_type, - fwd_txfm_opt, bd); + highbd_fwd_txfm_16x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt, + bd); break; case TX_8X8: - highbd_fwd_txfm_8x8(src_diff, coeff, diff_stride, tx_type, - fwd_txfm_opt, bd); + highbd_fwd_txfm_8x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt, + bd); break; #if CONFIG_EXT_TX case TX_4X8: - highbd_fwd_txfm_4x8(src_diff, coeff, diff_stride, tx_type, - fwd_txfm_opt, bd); + highbd_fwd_txfm_4x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt, + bd); break; case TX_8X4: - highbd_fwd_txfm_8x4(src_diff, coeff, diff_stride, tx_type, - fwd_txfm_opt, bd); + highbd_fwd_txfm_8x4(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt, + bd); break; #endif // CONFIG_EXT_TX case TX_4X4: - highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, - lossless, bd); - break; - default: - assert(0); + highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, lossless, bd); break; + default: assert(0); break; } } #endif // CONFIG_VP9_HIGHBITDEPTH diff --git a/vp10/encoder/lookahead.c b/vp10/encoder/lookahead.c index c2db3f0fa..6582277d4 100644 --- a/vp10/encoder/lookahead.c +++ b/vp10/encoder/lookahead.c @@ -19,33 +19,28 @@ #include "vp10/encoder/lookahead.h" /* Return the buffer at the given absolute index and increment the index */ -static struct lookahead_entry *pop(struct lookahead_ctx *ctx, - int *idx) { +static struct lookahead_entry *pop(struct lookahead_ctx *ctx, int *idx) { int index = *idx; struct lookahead_entry *buf = ctx->buf + index; assert(index < ctx->max_sz); - if (++index >= ctx->max_sz) - index -= ctx->max_sz; + if (++index >= ctx->max_sz) index -= ctx->max_sz; *idx = index; return buf; } - void vp10_lookahead_destroy(struct lookahead_ctx *ctx) { if (ctx) { if (ctx->buf) { int i; - for (i = 0; i < ctx->max_sz; i++) - vpx_free_frame_buffer(&ctx->buf[i].img); + for (i = 0; i < ctx->max_sz; i++) vpx_free_frame_buffer(&ctx->buf[i].img); free(ctx->buf); } free(ctx); } } - struct lookahead_ctx *vp10_lookahead_init(unsigned int width, unsigned int height, unsigned int subsampling_x, @@ -69,32 +64,30 @@ struct lookahead_ctx *vp10_lookahead_init(unsigned int width, unsigned int i; ctx->max_sz = depth; ctx->buf = calloc(depth, sizeof(*ctx->buf)); - if (!ctx->buf) - goto bail; + if (!ctx->buf) goto bail; for (i = 0; i < depth; i++) - if (vpx_alloc_frame_buffer(&ctx->buf[i].img, - width, height, subsampling_x, subsampling_y, + if (vpx_alloc_frame_buffer( + &ctx->buf[i].img, width, height, subsampling_x, subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH - use_highbitdepth, + use_highbitdepth, #endif - VPX_ENC_BORDER_IN_PIXELS, - legacy_byte_alignment)) + VPX_ENC_BORDER_IN_PIXELS, legacy_byte_alignment)) goto bail; } return ctx; - bail: +bail: vp10_lookahead_destroy(ctx); return NULL; } #define USE_PARTIAL_COPY 0 -int vp10_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, - int64_t ts_start, int64_t ts_end, +int vp10_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, + int64_t ts_start, int64_t ts_end, #if CONFIG_VP9_HIGHBITDEPTH - int use_highbitdepth, + int use_highbitdepth, #endif - unsigned int flags) { + unsigned int flags) { struct lookahead_entry *buf; #if USE_PARTIAL_COPY int row, col, active_end; @@ -109,8 +102,7 @@ int vp10_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, int subsampling_y = src->subsampling_y; int larger_dimensions, new_dimensions; - if (ctx->sz + 1 + MAX_PRE_FRAMES > ctx->max_sz) - return 1; + if (ctx->sz + 1 + MAX_PRE_FRAMES > ctx->max_sz) return 1; ctx->sz++; buf = pop(ctx, &ctx->write_idx); @@ -118,8 +110,7 @@ int vp10_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, height != buf->img.y_crop_height || uv_width != buf->img.uv_crop_width || uv_height != buf->img.uv_crop_height; - larger_dimensions = width > buf->img.y_width || - height > buf->img.y_height || + larger_dimensions = width > buf->img.y_width || height > buf->img.y_height || uv_width > buf->img.uv_width || uv_height > buf->img.uv_height; assert(!larger_dimensions || new_dimensions); @@ -139,27 +130,22 @@ int vp10_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, while (1) { // Find the first active macroblock in this row. for (; col < mb_cols; ++col) { - if (active_map[col]) - break; + if (active_map[col]) break; } // No more active macroblock in this row. - if (col == mb_cols) - break; + if (col == mb_cols) break; // Find the end of active region in this row. active_end = col; for (; active_end < mb_cols; ++active_end) { - if (!active_map[active_end]) - break; + if (!active_map[active_end]) break; } // Only copy this active region. - vp10_copy_and_extend_frame_with_rect(src, &buf->img, - row << 4, - col << 4, 16, - (active_end - col) << 4); + vp10_copy_and_extend_frame_with_rect(src, &buf->img, row << 4, col << 4, + 16, (active_end - col) << 4); // Start again from the end of this active region. col = active_end; @@ -172,14 +158,13 @@ int vp10_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, if (larger_dimensions) { YV12_BUFFER_CONFIG new_img; memset(&new_img, 0, sizeof(new_img)); - if (vpx_alloc_frame_buffer(&new_img, - width, height, subsampling_x, subsampling_y, + if (vpx_alloc_frame_buffer(&new_img, width, height, subsampling_x, + subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH use_highbitdepth, #endif - VPX_ENC_BORDER_IN_PIXELS, - 0)) - return 1; + VPX_ENC_BORDER_IN_PIXELS, 0)) + return 1; vpx_free_frame_buffer(&buf->img); buf->img = new_img; } else if (new_dimensions) { @@ -202,9 +187,8 @@ int vp10_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, return 0; } - struct lookahead_entry *vp10_lookahead_pop(struct lookahead_ctx *ctx, - int drain) { + int drain) { struct lookahead_entry *buf = NULL; if (ctx && ctx->sz && (drain || ctx->sz == ctx->max_sz - MAX_PRE_FRAMES)) { @@ -214,25 +198,22 @@ struct lookahead_entry *vp10_lookahead_pop(struct lookahead_ctx *ctx, return buf; } - struct lookahead_entry *vp10_lookahead_peek(struct lookahead_ctx *ctx, - int index) { + int index) { struct lookahead_entry *buf = NULL; if (index >= 0) { // Forward peek if (index < ctx->sz) { index += ctx->read_idx; - if (index >= ctx->max_sz) - index -= ctx->max_sz; + if (index >= ctx->max_sz) index -= ctx->max_sz; buf = ctx->buf + index; } } else if (index < 0) { // Backward peek if (-index <= MAX_PRE_FRAMES) { index += ctx->read_idx; - if (index < 0) - index += ctx->max_sz; + if (index < 0) index += ctx->max_sz; buf = ctx->buf + index; } } @@ -240,6 +221,4 @@ struct lookahead_entry *vp10_lookahead_peek(struct lookahead_ctx *ctx, return buf; } -unsigned int vp10_lookahead_depth(struct lookahead_ctx *ctx) { - return ctx->sz; -} +unsigned int vp10_lookahead_depth(struct lookahead_ctx *ctx) { return ctx->sz; } diff --git a/vp10/encoder/lookahead.h b/vp10/encoder/lookahead.h index f650f8028..c7a08443f 100644 --- a/vp10/encoder/lookahead.h +++ b/vp10/encoder/lookahead.h @@ -21,10 +21,10 @@ extern "C" { #define MAX_LAG_BUFFERS 25 struct lookahead_entry { - YV12_BUFFER_CONFIG img; - int64_t ts_start; - int64_t ts_end; - unsigned int flags; + YV12_BUFFER_CONFIG img; + int64_t ts_start; + int64_t ts_end; + unsigned int flags; }; // The max of past frames we want to keep in the queue. @@ -44,20 +44,18 @@ struct lookahead_ctx { * may be done when buffers are enqueued. */ struct lookahead_ctx *vp10_lookahead_init(unsigned int width, - unsigned int height, - unsigned int subsampling_x, - unsigned int subsampling_y, + unsigned int height, + unsigned int subsampling_x, + unsigned int subsampling_y, #if CONFIG_VP9_HIGHBITDEPTH - int use_highbitdepth, + int use_highbitdepth, #endif - unsigned int depth); - + unsigned int depth); /**\brief Destroys the lookahead stage */ void vp10_lookahead_destroy(struct lookahead_ctx *ctx); - /**\brief Enqueue a source buffer * * This function will copy the source image into a new framebuffer with @@ -74,12 +72,11 @@ void vp10_lookahead_destroy(struct lookahead_ctx *ctx); * \param[in] active_map Map that specifies which macroblock is active */ int vp10_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, - int64_t ts_start, int64_t ts_end, + int64_t ts_start, int64_t ts_end, #if CONFIG_VP9_HIGHBITDEPTH - int use_highbitdepth, + int use_highbitdepth, #endif - unsigned int flags); - + unsigned int flags); /**\brief Get the next source buffer to encode * @@ -92,8 +89,7 @@ int vp10_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src, * \retval NULL, if drain not set and queue not of the configured depth */ struct lookahead_entry *vp10_lookahead_pop(struct lookahead_ctx *ctx, - int drain); - + int drain); /**\brief Get a future source buffer to encode * @@ -103,8 +99,7 @@ struct lookahead_entry *vp10_lookahead_pop(struct lookahead_ctx *ctx, * \retval NULL, if no buffer exists at the specified index */ struct lookahead_entry *vp10_lookahead_peek(struct lookahead_ctx *ctx, - int index); - + int index); /**\brief Get the number of frames currently in the lookahead queue * diff --git a/vp10/encoder/mbgraph.c b/vp10/encoder/mbgraph.c index dd794e46d..a4a246825 100644 --- a/vp10/encoder/mbgraph.c +++ b/vp10/encoder/mbgraph.c @@ -22,11 +22,8 @@ #include "vp10/common/reconinter.h" #include "vp10/common/reconintra.h" - -static unsigned int do_16x16_motion_iteration(VP10_COMP *cpi, - const MV *ref_mv, - int mb_row, - int mb_col) { +static unsigned int do_16x16_motion_iteration(VP10_COMP *cpi, const MV *ref_mv, + int mb_row, int mb_col) { MACROBLOCK *const x = &cpi->td.mb; MACROBLOCKD *const xd = &x->e_mbd; const MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv; @@ -57,12 +54,11 @@ static unsigned int do_16x16_motion_iteration(VP10_COMP *cpi, { int distortion; unsigned int sse; - cpi->find_fractional_mv_step( - x, ref_mv, cpi->common.allow_high_precision_mv, x->errorperbit, - &v_fn_ptr, 0, mv_sf->subpel_iters_per_step, - cond_cost_list(cpi, cost_list), - NULL, NULL, - &distortion, &sse, NULL, 0, 0, 0); + cpi->find_fractional_mv_step(x, ref_mv, cpi->common.allow_high_precision_mv, + x->errorperbit, &v_fn_ptr, 0, + mv_sf->subpel_iters_per_step, + cond_cost_list(cpi, cost_list), NULL, NULL, + &distortion, &sse, NULL, 0, 0, 0); } #if CONFIG_EXT_INTER @@ -70,7 +66,7 @@ static unsigned int do_16x16_motion_iteration(VP10_COMP *cpi, xd->mi[0]->mbmi.mode = NEW_NEWMV; else #endif // CONFIG_EXT_INTER - xd->mi[0]->mbmi.mode = NEWMV; + xd->mi[0]->mbmi.mode = NEWMV; xd->mi[0]->mbmi.mv[0] = x->best_mv; #if CONFIG_EXT_INTER @@ -89,8 +85,8 @@ static unsigned int do_16x16_motion_iteration(VP10_COMP *cpi, xd->plane[0].dst.buf, xd->plane[0].dst.stride); } -static int do_16x16_motion_search(VP10_COMP *cpi, const MV *ref_mv, - int mb_row, int mb_col) { +static int do_16x16_motion_search(VP10_COMP *cpi, const MV *ref_mv, int mb_row, + int mb_col) { MACROBLOCK *const x = &cpi->td.mb; MACROBLOCKD *const xd = &x->e_mbd; unsigned int err, tmp_err; @@ -114,7 +110,7 @@ static int do_16x16_motion_search(VP10_COMP *cpi, const MV *ref_mv, // based search as well. if (ref_mv->row != 0 || ref_mv->col != 0) { unsigned int tmp_err; - MV zero_ref_mv = {0, 0}; + MV zero_ref_mv = { 0, 0 }; tmp_err = do_16x16_motion_iteration(cpi, &zero_ref_mv, mb_row, mb_col); if (tmp_err < err) { @@ -142,7 +138,7 @@ static int do_16x16_zerozero_search(VP10_COMP *cpi, int_mv *dst_mv) { return err; } static int find_best_16x16_intra(VP10_COMP *cpi, PREDICTION_MODE *pbest_mode) { - MACROBLOCK *const x = &cpi->td.mb; + MACROBLOCK *const x = &cpi->td.mb; MACROBLOCKD *const xd = &x->e_mbd; PREDICTION_MODE best_mode = -1, mode; unsigned int best_err = INT_MAX; @@ -153,38 +149,30 @@ static int find_best_16x16_intra(VP10_COMP *cpi, PREDICTION_MODE *pbest_mode) { unsigned int err; xd->mi[0]->mbmi.mode = mode; - vp10_predict_intra_block(xd, 2, 2, TX_16X16, mode, - x->plane[0].src.buf, x->plane[0].src.stride, - xd->plane[0].dst.buf, xd->plane[0].dst.stride, - 0, 0, 0); + vp10_predict_intra_block(xd, 2, 2, TX_16X16, mode, x->plane[0].src.buf, + x->plane[0].src.stride, xd->plane[0].dst.buf, + xd->plane[0].dst.stride, 0, 0, 0); err = vpx_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, xd->plane[0].dst.buf, xd->plane[0].dst.stride); // find best if (err < best_err) { - best_err = err; + best_err = err; best_mode = mode; } } - if (pbest_mode) - *pbest_mode = best_mode; + if (pbest_mode) *pbest_mode = best_mode; return best_err; } -static void update_mbgraph_mb_stats -( - VP10_COMP *cpi, - MBGRAPH_MB_STATS *stats, - YV12_BUFFER_CONFIG *buf, - int mb_y_offset, - YV12_BUFFER_CONFIG *golden_ref, - const MV *prev_golden_ref_mv, - YV12_BUFFER_CONFIG *alt_ref, - int mb_row, - int mb_col -) { +static void update_mbgraph_mb_stats(VP10_COMP *cpi, MBGRAPH_MB_STATS *stats, + YV12_BUFFER_CONFIG *buf, int mb_y_offset, + YV12_BUFFER_CONFIG *golden_ref, + const MV *prev_golden_ref_mv, + YV12_BUFFER_CONFIG *alt_ref, int mb_row, + int mb_col) { MACROBLOCK *const x = &cpi->td.mb; MACROBLOCKD *const xd = &x->e_mbd; int intra_error; @@ -198,10 +186,8 @@ static void update_mbgraph_mb_stats xd->plane[0].dst.stride = get_frame_new_buffer(cm)->y_stride; // do intra 16x16 prediction - intra_error = find_best_16x16_intra(cpi, - &stats->ref[INTRA_FRAME].m.mode); - if (intra_error <= 0) - intra_error = 1; + intra_error = find_best_16x16_intra(cpi, &stats->ref[INTRA_FRAME].m.mode); + if (intra_error <= 0) intra_error = 1; stats->ref[INTRA_FRAME].err = intra_error; // Golden frame MV search, if it exists and is different than last frame @@ -209,9 +195,8 @@ static void update_mbgraph_mb_stats int g_motion_error; xd->plane[0].pre[0].buf = golden_ref->y_buffer + mb_y_offset; xd->plane[0].pre[0].stride = golden_ref->y_stride; - g_motion_error = do_16x16_motion_search(cpi, - prev_golden_ref_mv, - mb_row, mb_col); + g_motion_error = + do_16x16_motion_search(cpi, prev_golden_ref_mv, mb_row, mb_col); stats->ref[GOLDEN_FRAME].m.mv = x->best_mv; stats->ref[GOLDEN_FRAME].err = g_motion_error; } else { @@ -225,8 +210,8 @@ static void update_mbgraph_mb_stats int a_motion_error; xd->plane[0].pre[0].buf = alt_ref->y_buffer + mb_y_offset; xd->plane[0].pre[0].stride = alt_ref->y_stride; - a_motion_error = do_16x16_zerozero_search(cpi, - &stats->ref[ALTREF_FRAME].m.mv); + a_motion_error = + do_16x16_zerozero_search(cpi, &stats->ref[ALTREF_FRAME].m.mv); stats->ref[ALTREF_FRAME].err = a_motion_error; } else { @@ -246,17 +231,17 @@ static void update_mbgraph_frame_stats(VP10_COMP *cpi, int mb_col, mb_row, offset = 0; int mb_y_offset = 0, arf_y_offset = 0, gld_y_offset = 0; - MV gld_top_mv = {0, 0}; + MV gld_top_mv = { 0, 0 }; MODE_INFO mi_local; vp10_zero(mi_local); // Set up limit values for motion vectors to prevent them extending outside // the UMV borders. - x->mv_row_min = -BORDER_MV_PIXELS_B16; - x->mv_row_max = (cm->mb_rows - 1) * 8 + BORDER_MV_PIXELS_B16; - xd->up_available = 0; - xd->plane[0].dst.stride = buf->y_stride; - xd->plane[0].pre[0].stride = buf->y_stride; + x->mv_row_min = -BORDER_MV_PIXELS_B16; + x->mv_row_max = (cm->mb_rows - 1) * 8 + BORDER_MV_PIXELS_B16; + xd->up_available = 0; + xd->plane[0].dst.stride = buf->y_stride; + xd->plane[0].pre[0].stride = buf->y_stride; xd->plane[1].dst.stride = buf->uv_stride; xd->mi[0] = &mi_local; mi_local.mbmi.sb_type = BLOCK_16X16; @@ -265,41 +250,39 @@ static void update_mbgraph_frame_stats(VP10_COMP *cpi, for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) { MV gld_left_mv = gld_top_mv; - int mb_y_in_offset = mb_y_offset; + int mb_y_in_offset = mb_y_offset; int arf_y_in_offset = arf_y_offset; int gld_y_in_offset = gld_y_offset; // Set up limit values for motion vectors to prevent them extending outside // the UMV borders. - x->mv_col_min = -BORDER_MV_PIXELS_B16; - x->mv_col_max = (cm->mb_cols - 1) * 8 + BORDER_MV_PIXELS_B16; + x->mv_col_min = -BORDER_MV_PIXELS_B16; + x->mv_col_max = (cm->mb_cols - 1) * 8 + BORDER_MV_PIXELS_B16; xd->left_available = 0; for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) { MBGRAPH_MB_STATS *mb_stats = &stats->mb_stats[offset + mb_col]; - update_mbgraph_mb_stats(cpi, mb_stats, buf, mb_y_in_offset, - golden_ref, &gld_left_mv, alt_ref, - mb_row, mb_col); + update_mbgraph_mb_stats(cpi, mb_stats, buf, mb_y_in_offset, golden_ref, + &gld_left_mv, alt_ref, mb_row, mb_col); gld_left_mv = mb_stats->ref[GOLDEN_FRAME].m.mv.as_mv; if (mb_col == 0) { gld_top_mv = gld_left_mv; } xd->left_available = 1; - mb_y_in_offset += 16; - gld_y_in_offset += 16; - arf_y_in_offset += 16; - x->mv_col_min -= 16; - x->mv_col_max -= 16; + mb_y_in_offset += 16; + gld_y_in_offset += 16; + arf_y_in_offset += 16; + x->mv_col_min -= 16; + x->mv_col_max -= 16; } xd->up_available = 1; - mb_y_offset += buf->y_stride * 16; - gld_y_offset += golden_ref->y_stride * 16; - if (alt_ref) - arf_y_offset += alt_ref->y_stride * 16; - x->mv_row_min -= 16; - x->mv_row_max -= 16; - offset += cm->mb_cols; + mb_y_offset += buf->y_stride * 16; + gld_y_offset += golden_ref->y_stride * 16; + if (alt_ref) arf_y_offset += alt_ref->y_stride * 16; + x->mv_row_min -= 16; + x->mv_row_max -= 16; + offset += cm->mb_cols; } } @@ -313,9 +296,9 @@ static void separate_arf_mbs(VP10_COMP *cpi) { int *arf_not_zz; - CHECK_MEM_ERROR(cm, arf_not_zz, - vpx_calloc(cm->mb_rows * cm->mb_cols * sizeof(*arf_not_zz), - 1)); + CHECK_MEM_ERROR( + cm, arf_not_zz, + vpx_calloc(cm->mb_rows * cm->mb_cols * sizeof(*arf_not_zz), 1)); // We are not interested in results beyond the alt ref itself. if (n_frames > cpi->rc.frames_till_gf_update_due) @@ -331,12 +314,11 @@ static void separate_arf_mbs(VP10_COMP *cpi) { MBGRAPH_MB_STATS *mb_stats = &frame_stats->mb_stats[offset + mb_col]; int altref_err = mb_stats->ref[ALTREF_FRAME].err; - int intra_err = mb_stats->ref[INTRA_FRAME ].err; + int intra_err = mb_stats->ref[INTRA_FRAME].err; int golden_err = mb_stats->ref[GOLDEN_FRAME].err; // Test for altref vs intra and gf and that its mv was 0,0. - if (altref_err > 1000 || - altref_err > intra_err || + if (altref_err > 1000 || altref_err > intra_err || altref_err > golden_err) { arf_not_zz[offset + mb_col]++; } @@ -391,11 +373,9 @@ void vp10_update_mbgraph_stats(VP10_COMP *cpi) { // we need to look ahead beyond where the ARF transitions into // being a GF - so exit if we don't look ahead beyond that - if (n_frames <= cpi->rc.frames_till_gf_update_due) - return; + if (n_frames <= cpi->rc.frames_till_gf_update_due) return; - if (n_frames > MAX_LAG_BUFFERS) - n_frames = MAX_LAG_BUFFERS; + if (n_frames > MAX_LAG_BUFFERS) n_frames = MAX_LAG_BUFFERS; cpi->mbgraph_n_frames = n_frames; for (i = 0; i < n_frames; i++) { @@ -414,8 +394,8 @@ void vp10_update_mbgraph_stats(VP10_COMP *cpi) { assert(q_cur != NULL); - update_mbgraph_frame_stats(cpi, frame_stats, &q_cur->img, - golden_ref, cpi->Source); + update_mbgraph_frame_stats(cpi, frame_stats, &q_cur->img, golden_ref, + cpi->Source); } vpx_clear_system_state(); diff --git a/vp10/encoder/mbgraph.h b/vp10/encoder/mbgraph.h index 2946729ae..0b056afa9 100644 --- a/vp10/encoder/mbgraph.h +++ b/vp10/encoder/mbgraph.h @@ -25,9 +25,7 @@ typedef struct { } ref[TOTAL_REFS_PER_FRAME]; } MBGRAPH_MB_STATS; -typedef struct { - MBGRAPH_MB_STATS *mb_stats; -} MBGRAPH_FRAME_STATS; +typedef struct { MBGRAPH_MB_STATS *mb_stats; } MBGRAPH_FRAME_STATS; struct VP10_COMP; diff --git a/vp10/encoder/mcomp.c b/vp10/encoder/mcomp.c index cc2ba4750..c3bf2dcb4 100644 --- a/vp10/encoder/mcomp.c +++ b/vp10/encoder/mcomp.c @@ -46,14 +46,10 @@ void vp10_set_mv_search_range(MACROBLOCK *x, const MV *mv) { // Get intersection of UMV window and valid MV window to reduce # of checks // in diamond search. - if (x->mv_col_min < col_min) - x->mv_col_min = col_min; - if (x->mv_col_max > col_max) - x->mv_col_max = col_max; - if (x->mv_row_min < row_min) - x->mv_row_min = row_min; - if (x->mv_row_max > row_max) - x->mv_row_max = row_max; + if (x->mv_col_min < col_min) x->mv_col_min = col_min; + if (x->mv_col_max > col_max) x->mv_col_max = col_max; + if (x->mv_row_min < row_min) x->mv_row_min = row_min; + if (x->mv_row_max > row_max) x->mv_row_max = row_max; } int vp10_init_search_range(int size) { @@ -61,23 +57,21 @@ int vp10_init_search_range(int size) { // Minimum search size no matter what the passed in value. size = VPXMAX(16, size); - while ((size << sr) < MAX_FULL_PEL_VAL) - sr++; + while ((size << sr) < MAX_FULL_PEL_VAL) sr++; sr = VPXMIN(sr, MAX_MVSEARCH_STEPS - 2); return sr; } -static INLINE int mv_cost(const MV *mv, - const int *joint_cost, int *const comp_cost[2]) { - return joint_cost[vp10_get_mv_joint(mv)] + - comp_cost[0][mv->row] + comp_cost[1][mv->col]; +static INLINE int mv_cost(const MV *mv, const int *joint_cost, + int *const comp_cost[2]) { + return joint_cost[vp10_get_mv_joint(mv)] + comp_cost[0][mv->row] + + comp_cost[1][mv->col]; } -int vp10_mv_bit_cost(const MV *mv, const MV *ref, - const int *mvjcost, int *mvcost[2], int weight) { - const MV diff = { mv->row - ref->row, - mv->col - ref->col }; +int vp10_mv_bit_cost(const MV *mv, const MV *ref, const int *mvjcost, + int *mvcost[2], int weight) { + const MV diff = { mv->row - ref->row, mv->col - ref->col }; return ROUND_POWER_OF_TWO(mv_cost(&diff, mvjcost, mvcost) * weight, 7); } @@ -85,7 +79,7 @@ int vp10_mv_bit_cost(const MV *mv, const MV *ref, static int mv_err_cost(const MV *mv, const MV *ref, const int *mvjcost, int *mvcost[2], int error_per_bit) { if (mvcost) { - const MV diff = {mv->row - ref->row, mv->col - ref->col}; + const MV diff = { mv->row - ref->row, mv->col - ref->col }; // This product sits at a 32-bit ceiling right now and any additional // accuracy in either bit cost or error cost will cause it to overflow. return ROUND_POWER_OF_TWO( @@ -98,11 +92,9 @@ static int mv_err_cost(const MV *mv, const MV *ref, const int *mvjcost, static int mvsad_err_cost(const MACROBLOCK *x, const MV *mv, const MV *ref, int sad_per_bit) { - const MV diff = { (mv->row - ref->row) * 8, - (mv->col - ref->col) * 8 }; + const MV diff = { (mv->row - ref->row) * 8, (mv->col - ref->col) * 8 }; return ROUND_POWER_OF_TWO( - (unsigned)mv_cost(&diff, x->nmvjointsadcost, x->mvsadcost) * - sad_per_bit, + (unsigned)mv_cost(&diff, x->nmvjointsadcost, x->mvsadcost) * sad_per_bit, VP9_PROB_COST_SHIFT); } @@ -114,7 +106,7 @@ void vp10_init_dsmotion_compensation(search_site_config *cfg, int stride) { for (len = MAX_FIRST_STEP; len > 0; len /= 2) { // Generate offsets for 4 search sites per step. - const MV ss_mvs[] = {{-len, 0}, {len, 0}, {0, -len}, {0, len}}; + const MV ss_mvs[] = { { -len, 0 }, { len, 0 }, { 0, -len }, { 0, len } }; int i; for (i = 0; i < 4; ++i) { search_site *const ss = &cfg->ss[ss_count++]; @@ -135,10 +127,9 @@ void vp10_init3smotion_compensation(search_site_config *cfg, int stride) { for (len = MAX_FIRST_STEP; len > 0; len /= 2) { // Generate offsets for 8 search sites per step. - const MV ss_mvs[8] = { - {-len, 0 }, {len, 0 }, { 0, -len}, {0, len}, - {-len, -len}, {-len, len}, {len, -len}, {len, len} - }; + const MV ss_mvs[8] = { { -len, 0 }, { len, 0 }, { 0, -len }, + { 0, len }, { -len, -len }, { -len, len }, + { len, -len }, { len, len } }; int i; for (i = 0; i < 8; ++i) { search_site *const ss = &cfg->ss[ss_count++]; @@ -162,49 +153,46 @@ void vp10_init3smotion_compensation(search_site_config *cfg, int stride) { */ // convert motion vector component to offset for sv[a]f calc -static INLINE int sp(int x) { - return x & 7; -} +static INLINE int sp(int x) { return x & 7; } static INLINE const uint8_t *pre(const uint8_t *buf, int stride, int r, int c) { return &buf[(r >> 3) * stride + (c >> 3)]; } /* checks if (r, c) has better score than previous best */ -#define CHECK_BETTER(v, r, c) \ - if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ - MV this_mv = {r, c}; \ - v = mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); \ - if (second_pred == NULL) \ - thismse = vfp->svf(pre(y, y_stride, r, c), y_stride, sp(c), \ - sp(r), src_address, src_stride, &sse); \ - else \ - thismse = vfp->svaf(pre(y, y_stride, r, c), y_stride, sp(c), \ - sp(r), src_address, src_stride, &sse, \ - second_pred); \ - v += thismse; \ - if (v < besterr) { \ - besterr = v; \ - br = r; \ - bc = c; \ - *distortion = thismse; \ - *sse1 = sse; \ - } \ - } else { \ - v = INT_MAX; \ +#define CHECK_BETTER(v, r, c) \ + if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ + MV this_mv = { r, c }; \ + v = mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); \ + if (second_pred == NULL) \ + thismse = vfp->svf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), \ + src_address, src_stride, &sse); \ + else \ + thismse = vfp->svaf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), \ + src_address, src_stride, &sse, second_pred); \ + v += thismse; \ + if (v < besterr) { \ + besterr = v; \ + br = r; \ + bc = c; \ + *distortion = thismse; \ + *sse1 = sse; \ + } \ + } else { \ + v = INT_MAX; \ } #define CHECK_BETTER0(v, r, c) CHECK_BETTER(v, r, c) -static INLINE const uint8_t *upre(const uint8_t *buf, int stride, - int r, int c) { - return &buf[(r) * stride + (c)]; +static INLINE const uint8_t *upre(const uint8_t *buf, int stride, int r, + int c) { + return &buf[(r)*stride + (c)]; } /* checks if (r, c) has better score than previous best */ -#define CHECK_BETTER1(v, r, c) \ +#define CHECK_BETTER1(v, r, c) \ if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ - MV this_mv = {r, c}; \ + MV this_mv = { r, c }; \ thismse = upsampled_pref_error(xd, vfp, src_address, src_stride, \ upre(y, y_stride, r, c), y_stride, \ second_pred, w, h, &sse); \ @@ -221,135 +209,110 @@ static INLINE const uint8_t *upre(const uint8_t *buf, int stride, v = INT_MAX; \ } -#define FIRST_LEVEL_CHECKS \ - { \ - unsigned int left, right, up, down, diag; \ - CHECK_BETTER(left, tr, tc - hstep); \ - CHECK_BETTER(right, tr, tc + hstep); \ - CHECK_BETTER(up, tr - hstep, tc); \ - CHECK_BETTER(down, tr + hstep, tc); \ - whichdir = (left < right ? 0 : 1) + \ - (up < down ? 0 : 2); \ - switch (whichdir) { \ - case 0: \ - CHECK_BETTER(diag, tr - hstep, tc - hstep); \ - break; \ - case 1: \ - CHECK_BETTER(diag, tr - hstep, tc + hstep); \ - break; \ - case 2: \ - CHECK_BETTER(diag, tr + hstep, tc - hstep); \ - break; \ - case 3: \ - CHECK_BETTER(diag, tr + hstep, tc + hstep); \ - break; \ - } \ +#define FIRST_LEVEL_CHECKS \ + { \ + unsigned int left, right, up, down, diag; \ + CHECK_BETTER(left, tr, tc - hstep); \ + CHECK_BETTER(right, tr, tc + hstep); \ + CHECK_BETTER(up, tr - hstep, tc); \ + CHECK_BETTER(down, tr + hstep, tc); \ + whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2); \ + switch (whichdir) { \ + case 0: CHECK_BETTER(diag, tr - hstep, tc - hstep); break; \ + case 1: CHECK_BETTER(diag, tr - hstep, tc + hstep); break; \ + case 2: CHECK_BETTER(diag, tr + hstep, tc - hstep); break; \ + case 3: CHECK_BETTER(diag, tr + hstep, tc + hstep); break; \ + } \ } -#define SECOND_LEVEL_CHECKS \ - { \ - int kr, kc; \ - unsigned int second; \ - if (tr != br && tc != bc) { \ - kr = br - tr; \ - kc = bc - tc; \ - CHECK_BETTER(second, tr + kr, tc + 2 * kc); \ - CHECK_BETTER(second, tr + 2 * kr, tc + kc); \ - } else if (tr == br && tc != bc) { \ - kc = bc - tc; \ - CHECK_BETTER(second, tr + hstep, tc + 2 * kc); \ - CHECK_BETTER(second, tr - hstep, tc + 2 * kc); \ - switch (whichdir) { \ - case 0: \ - case 1: \ - CHECK_BETTER(second, tr + hstep, tc + kc); \ - break; \ - case 2: \ - case 3: \ - CHECK_BETTER(second, tr - hstep, tc + kc); \ - break; \ - } \ - } else if (tr != br && tc == bc) { \ - kr = br - tr; \ - CHECK_BETTER(second, tr + 2 * kr, tc + hstep); \ - CHECK_BETTER(second, tr + 2 * kr, tc - hstep); \ - switch (whichdir) { \ - case 0: \ - case 2: \ - CHECK_BETTER(second, tr + kr, tc + hstep); \ - break; \ - case 1: \ - case 3: \ - CHECK_BETTER(second, tr + kr, tc - hstep); \ - break; \ - } \ - } \ +#define SECOND_LEVEL_CHECKS \ + { \ + int kr, kc; \ + unsigned int second; \ + if (tr != br && tc != bc) { \ + kr = br - tr; \ + kc = bc - tc; \ + CHECK_BETTER(second, tr + kr, tc + 2 * kc); \ + CHECK_BETTER(second, tr + 2 * kr, tc + kc); \ + } else if (tr == br && tc != bc) { \ + kc = bc - tc; \ + CHECK_BETTER(second, tr + hstep, tc + 2 * kc); \ + CHECK_BETTER(second, tr - hstep, tc + 2 * kc); \ + switch (whichdir) { \ + case 0: \ + case 1: CHECK_BETTER(second, tr + hstep, tc + kc); break; \ + case 2: \ + case 3: CHECK_BETTER(second, tr - hstep, tc + kc); break; \ + } \ + } else if (tr != br && tc == bc) { \ + kr = br - tr; \ + CHECK_BETTER(second, tr + 2 * kr, tc + hstep); \ + CHECK_BETTER(second, tr + 2 * kr, tc - hstep); \ + switch (whichdir) { \ + case 0: \ + case 2: CHECK_BETTER(second, tr + kr, tc + hstep); break; \ + case 1: \ + case 3: CHECK_BETTER(second, tr + kr, tc - hstep); break; \ + } \ + } \ } // TODO(yunqingwang): SECOND_LEVEL_CHECKS_BEST was a rewrote of // SECOND_LEVEL_CHECKS, and SECOND_LEVEL_CHECKS should be rewritten // later in the same way. -#define SECOND_LEVEL_CHECKS_BEST(k) \ - { \ - unsigned int second; \ - int br0 = br; \ - int bc0 = bc; \ - assert(tr == br || tc == bc); \ - if (tr == br && tc != bc) { \ - kc = bc - tc; \ - } else if (tr != br && tc == bc) { \ - kr = br - tr; \ - } \ - CHECK_BETTER##k(second, br0 + kr, bc0); \ - CHECK_BETTER##k(second, br0, bc0 + kc); \ - if (br0 != br || bc0 != bc) { \ - CHECK_BETTER##k(second, br0 + kr, bc0 + kc); \ - } \ +#define SECOND_LEVEL_CHECKS_BEST(k) \ + { \ + unsigned int second; \ + int br0 = br; \ + int bc0 = bc; \ + assert(tr == br || tc == bc); \ + if (tr == br && tc != bc) { \ + kc = bc - tc; \ + } else if (tr != br && tc == bc) { \ + kr = br - tr; \ + } \ + CHECK_BETTER##k(second, br0 + kr, bc0); \ + CHECK_BETTER##k(second, br0, bc0 + kc); \ + if (br0 != br || bc0 != bc) { \ + CHECK_BETTER##k(second, br0 + kr, bc0 + kc); \ + } \ } -#define SETUP_SUBPEL_SEARCH \ - const uint8_t *const src_address = x->plane[0].src.buf; \ - const int src_stride = x->plane[0].src.stride; \ - const MACROBLOCKD *xd = &x->e_mbd; \ - unsigned int besterr = INT_MAX; \ - unsigned int sse; \ - unsigned int whichdir; \ - int thismse; \ - MV *bestmv = &x->best_mv.as_mv; \ - const unsigned int halfiters = iters_per_step; \ - const unsigned int quarteriters = iters_per_step; \ - const unsigned int eighthiters = iters_per_step; \ - const int y_stride = xd->plane[0].pre[0].stride; \ - const int offset = bestmv->row * y_stride + bestmv->col; \ - const uint8_t *const y = xd->plane[0].pre[0].buf; \ - \ - int br = bestmv->row * 8; \ - int bc = bestmv->col * 8; \ - int hstep = 4; \ - const int minc = VPXMAX(x->mv_col_min * 8, ref_mv->col - MV_MAX); \ - const int maxc = VPXMIN(x->mv_col_max * 8, ref_mv->col + MV_MAX); \ - const int minr = VPXMAX(x->mv_row_min * 8, ref_mv->row - MV_MAX); \ - const int maxr = VPXMIN(x->mv_row_max * 8, ref_mv->row + MV_MAX); \ - int tr = br; \ - int tc = bc; \ - \ - bestmv->row *= 8; \ +#define SETUP_SUBPEL_SEARCH \ + const uint8_t *const src_address = x->plane[0].src.buf; \ + const int src_stride = x->plane[0].src.stride; \ + const MACROBLOCKD *xd = &x->e_mbd; \ + unsigned int besterr = INT_MAX; \ + unsigned int sse; \ + unsigned int whichdir; \ + int thismse; \ + MV *bestmv = &x->best_mv.as_mv; \ + const unsigned int halfiters = iters_per_step; \ + const unsigned int quarteriters = iters_per_step; \ + const unsigned int eighthiters = iters_per_step; \ + const int y_stride = xd->plane[0].pre[0].stride; \ + const int offset = bestmv->row * y_stride + bestmv->col; \ + const uint8_t *const y = xd->plane[0].pre[0].buf; \ + \ + int br = bestmv->row * 8; \ + int bc = bestmv->col * 8; \ + int hstep = 4; \ + const int minc = VPXMAX(x->mv_col_min * 8, ref_mv->col - MV_MAX); \ + const int maxc = VPXMIN(x->mv_col_max * 8, ref_mv->col + MV_MAX); \ + const int minr = VPXMAX(x->mv_row_min * 8, ref_mv->row - MV_MAX); \ + const int maxr = VPXMIN(x->mv_row_max * 8, ref_mv->row + MV_MAX); \ + int tr = br; \ + int tc = bc; \ + \ + bestmv->row *= 8; \ bestmv->col *= 8; -static unsigned int setup_center_error(const MACROBLOCKD *xd, - const MV *bestmv, - const MV *ref_mv, - int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - const uint8_t *const src, - const int src_stride, - const uint8_t *const y, - int y_stride, - const uint8_t *second_pred, - int w, int h, int offset, - int *mvjcost, int *mvcost[2], - unsigned int *sse1, - int *distortion) { +static unsigned int setup_center_error( + const MACROBLOCKD *xd, const MV *bestmv, const MV *ref_mv, + int error_per_bit, const vpx_variance_fn_ptr_t *vfp, + const uint8_t *const src, const int src_stride, const uint8_t *const y, + int y_stride, const uint8_t *second_pred, int w, int h, int offset, + int *mvjcost, int *mvcost[2], unsigned int *sse1, int *distortion) { unsigned int besterr; #if CONFIG_VP9_HIGHBITDEPTH if (second_pred != NULL) { @@ -357,8 +320,8 @@ static unsigned int setup_center_error(const MACROBLOCKD *xd, DECLARE_ALIGNED(16, uint16_t, comp_pred16[MAX_SB_SQUARE]); vpx_highbd_comp_avg_pred(comp_pred16, second_pred, w, h, y + offset, y_stride); - besterr = vfp->vf(CONVERT_TO_BYTEPTR(comp_pred16), w, src, src_stride, - sse1); + besterr = + vfp->vf(CONVERT_TO_BYTEPTR(comp_pred16), w, src, src_stride, sse1); } else { DECLARE_ALIGNED(16, uint8_t, comp_pred[MAX_SB_SQUARE]); vpx_comp_avg_pred(comp_pred, second_pred, w, h, y + offset, y_stride); @@ -370,7 +333,7 @@ static unsigned int setup_center_error(const MACROBLOCKD *xd, *distortion = besterr; besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit); #else - (void) xd; + (void)xd; if (second_pred != NULL) { DECLARE_ALIGNED(16, uint8_t, comp_pred[MAX_SB_SQUARE]); vpx_comp_avg_pred(comp_pred, second_pred, w, h, y + offset, y_stride); @@ -389,10 +352,8 @@ static INLINE int divide_and_round(const int n, const int d) { } static INLINE int is_cost_list_wellbehaved(int *cost_list) { - return cost_list[0] < cost_list[1] && - cost_list[0] < cost_list[2] && - cost_list[0] < cost_list[3] && - cost_list[0] < cost_list[4]; + return cost_list[0] < cost_list[1] && cost_list[0] < cost_list[2] && + cost_list[0] < cost_list[3] && cost_list[0] < cost_list[4]; } // Returns surface minima estimate at given precision in 1/2^n bits. @@ -403,8 +364,7 @@ static INLINE int is_cost_list_wellbehaved(int *cost_list) { // x0 = 1/2 (S1 - S3)/(S1 + S3 - 2*S0), // y0 = 1/2 (S4 - S2)/(S4 + S2 - 2*S0). // The code below is an integerized version of that. -static void get_cost_surf_min(int *cost_list, int *ir, int *ic, - int bits) { +static void get_cost_surf_min(int *cost_list, int *ir, int *ic, int bits) { *ic = divide_and_round((cost_list[1] - cost_list[3]) * (1 << (bits - 1)), (cost_list[1] - 2 * cost_list[0] + cost_list[3])); *ir = divide_and_round((cost_list[4] - cost_list[2]) * (1 << (bits - 1)), @@ -412,38 +372,27 @@ static void get_cost_surf_min(int *cost_list, int *ir, int *ic, } int vp10_find_best_sub_pixel_tree_pruned_evenmore( - MACROBLOCK *x, - const MV *ref_mv, - int allow_hp, - int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - int forced_stop, - int iters_per_step, - int *cost_list, - int *mvjcost, int *mvcost[2], - int *distortion, - unsigned int *sse1, - const uint8_t *second_pred, - int w, int h, int use_upsampled_ref) { + MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit, + const vpx_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step, + int *cost_list, int *mvjcost, int *mvcost[2], int *distortion, + unsigned int *sse1, const uint8_t *second_pred, int w, int h, + int use_upsampled_ref) { SETUP_SUBPEL_SEARCH; - besterr = setup_center_error(xd, bestmv, ref_mv, error_per_bit, vfp, - src_address, src_stride, y, y_stride, - second_pred, w, h, offset, mvjcost, mvcost, - sse1, distortion); - (void) halfiters; - (void) quarteriters; - (void) eighthiters; - (void) whichdir; - (void) allow_hp; - (void) forced_stop; - (void) hstep; - (void) use_upsampled_ref; + besterr = setup_center_error( + xd, bestmv, ref_mv, error_per_bit, vfp, src_address, src_stride, y, + y_stride, second_pred, w, h, offset, mvjcost, mvcost, sse1, distortion); + (void)halfiters; + (void)quarteriters; + (void)eighthiters; + (void)whichdir; + (void)allow_hp; + (void)forced_stop; + (void)hstep; + (void)use_upsampled_ref; - if (cost_list && - cost_list[0] != INT_MAX && cost_list[1] != INT_MAX && + if (cost_list && cost_list[0] != INT_MAX && cost_list[1] != INT_MAX && cost_list[2] != INT_MAX && cost_list[3] != INT_MAX && - cost_list[4] != INT_MAX && - is_cost_list_wellbehaved(cost_list)) { + cost_list[4] != INT_MAX && is_cost_list_wellbehaved(cost_list)) { int ir, ic; unsigned int minpt; get_cost_surf_min(cost_list, &ir, &ic, 2); @@ -492,32 +441,21 @@ int vp10_find_best_sub_pixel_tree_pruned_evenmore( return besterr; } -int vp10_find_best_sub_pixel_tree_pruned_more(MACROBLOCK *x, - const MV *ref_mv, - int allow_hp, - int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - int forced_stop, - int iters_per_step, - int *cost_list, - int *mvjcost, int *mvcost[2], - int *distortion, - unsigned int *sse1, - const uint8_t *second_pred, - int w, int h, - int use_upsampled_ref) { +int vp10_find_best_sub_pixel_tree_pruned_more( + MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit, + const vpx_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step, + int *cost_list, int *mvjcost, int *mvcost[2], int *distortion, + unsigned int *sse1, const uint8_t *second_pred, int w, int h, + int use_upsampled_ref) { SETUP_SUBPEL_SEARCH; - (void) use_upsampled_ref; + (void)use_upsampled_ref; - besterr = setup_center_error(xd, bestmv, ref_mv, error_per_bit, vfp, - src_address, src_stride, y, y_stride, - second_pred, w, h, offset, mvjcost, mvcost, - sse1, distortion); - if (cost_list && - cost_list[0] != INT_MAX && cost_list[1] != INT_MAX && + besterr = setup_center_error( + xd, bestmv, ref_mv, error_per_bit, vfp, src_address, src_stride, y, + y_stride, second_pred, w, h, offset, mvjcost, mvcost, sse1, distortion); + if (cost_list && cost_list[0] != INT_MAX && cost_list[1] != INT_MAX && cost_list[2] != INT_MAX && cost_list[3] != INT_MAX && - cost_list[4] != INT_MAX && - is_cost_list_wellbehaved(cost_list)) { + cost_list[4] != INT_MAX && is_cost_list_wellbehaved(cost_list)) { unsigned int minpt; int ir, ic; get_cost_surf_min(cost_list, &ir, &ic, 1); @@ -556,8 +494,8 @@ int vp10_find_best_sub_pixel_tree_pruned_more(MACROBLOCK *x, } // These lines insure static analysis doesn't warn that // tr and tc aren't used after the above point. - (void) tr; - (void) tc; + (void)tr; + (void)tc; bestmv->row = br; bestmv->col = bc; @@ -569,28 +507,19 @@ int vp10_find_best_sub_pixel_tree_pruned_more(MACROBLOCK *x, return besterr; } -int vp10_find_best_sub_pixel_tree_pruned(MACROBLOCK *x, - const MV *ref_mv, - int allow_hp, - int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - int forced_stop, - int iters_per_step, - int *cost_list, - int *mvjcost, int *mvcost[2], - int *distortion, - unsigned int *sse1, - const uint8_t *second_pred, - int w, int h, int use_upsampled_ref) { +int vp10_find_best_sub_pixel_tree_pruned( + MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit, + const vpx_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step, + int *cost_list, int *mvjcost, int *mvcost[2], int *distortion, + unsigned int *sse1, const uint8_t *second_pred, int w, int h, + int use_upsampled_ref) { SETUP_SUBPEL_SEARCH; - (void) use_upsampled_ref; + (void)use_upsampled_ref; - besterr = setup_center_error(xd, bestmv, ref_mv, error_per_bit, vfp, - src_address, src_stride, y, y_stride, - second_pred, w, h, offset, mvjcost, mvcost, - sse1, distortion); - if (cost_list && - cost_list[0] != INT_MAX && cost_list[1] != INT_MAX && + besterr = setup_center_error( + xd, bestmv, ref_mv, error_per_bit, vfp, src_address, src_stride, y, + y_stride, second_pred, w, h, offset, mvjcost, mvcost, sse1, distortion); + if (cost_list && cost_list[0] != INT_MAX && cost_list[1] != INT_MAX && cost_list[2] != INT_MAX && cost_list[3] != INT_MAX && cost_list[4] != INT_MAX) { unsigned int left, right, up, down, diag; @@ -653,8 +582,8 @@ int vp10_find_best_sub_pixel_tree_pruned(MACROBLOCK *x, } // These lines insure static analysis doesn't warn that // tr and tc aren't used after the above point. - (void) tr; - (void) tc; + (void)tr; + (void)tc; bestmv->row = br; bestmv->col = bc; @@ -666,19 +595,21 @@ int vp10_find_best_sub_pixel_tree_pruned(MACROBLOCK *x, return besterr; } +/* clang-format off */ static const MV search_step_table[12] = { - // left, right, up, down - {0, -4}, {0, 4}, {-4, 0}, {4, 0}, - {0, -2}, {0, 2}, {-2, 0}, {2, 0}, - {0, -1}, {0, 1}, {-1, 0}, {1, 0} + // left, right, up, down + { 0, -4 }, { 0, 4 }, { -4, 0 }, { 4, 0 }, + { 0, -2 }, { 0, 2 }, { -2, 0 }, { 2, 0 }, + { 0, -1 }, { 0, 1 }, { -1, 0 }, { 1, 0 } }; +/* clang-format on */ static int upsampled_pref_error(const MACROBLOCKD *xd, const vpx_variance_fn_ptr_t *vfp, const uint8_t *const src, const int src_stride, const uint8_t *const y, int y_stride, - const uint8_t *second_pred, - int w, int h, unsigned int *sse) { + const uint8_t *second_pred, int w, int h, + unsigned int *sse) { unsigned int besterr; #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { @@ -689,17 +620,15 @@ static int upsampled_pref_error(const MACROBLOCKD *xd, else vpx_highbd_upsampled_pred(pred16, w, h, y, y_stride); - besterr = vfp->vf(CONVERT_TO_BYTEPTR(pred16), w, src, src_stride, - sse); + besterr = vfp->vf(CONVERT_TO_BYTEPTR(pred16), w, src, src_stride, sse); } else { DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]); #else - DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]); - (void) xd; + DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]); + (void)xd; #endif // CONFIG_VP9_HIGHBITDEPTH if (second_pred != NULL) - vpx_comp_avg_upsampled_pred(pred, second_pred, w, h, y, - y_stride); + vpx_comp_avg_upsampled_pred(pred, second_pred, w, h, y, y_stride); else vpx_upsampled_pred(pred, w, h, y, y_stride); @@ -707,37 +636,30 @@ static int upsampled_pref_error(const MACROBLOCKD *xd, #if CONFIG_VP9_HIGHBITDEPTH } #endif -return besterr; + return besterr; } static unsigned int upsampled_setup_center_error( const MACROBLOCKD *xd, const MV *bestmv, const MV *ref_mv, int error_per_bit, const vpx_variance_fn_ptr_t *vfp, - const uint8_t *const src, const int src_stride, - const uint8_t *const y, int y_stride, const uint8_t *second_pred, - int w, int h, int offset, int *mvjcost, int *mvcost[2], - unsigned int *sse1, int *distortion) { - unsigned int besterr = upsampled_pref_error(xd, vfp, src, src_stride, - y + offset, y_stride, second_pred, - w, h, sse1); + const uint8_t *const src, const int src_stride, const uint8_t *const y, + int y_stride, const uint8_t *second_pred, int w, int h, int offset, + int *mvjcost, int *mvcost[2], unsigned int *sse1, int *distortion) { + unsigned int besterr = upsampled_pref_error( + xd, vfp, src, src_stride, y + offset, y_stride, second_pred, w, h, sse1); *distortion = besterr; besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit); return besterr; } -int vp10_find_best_sub_pixel_tree(MACROBLOCK *x, - const MV *ref_mv, - int allow_hp, +int vp10_find_best_sub_pixel_tree(MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit, const vpx_variance_fn_ptr_t *vfp, - int forced_stop, - int iters_per_step, - int *cost_list, - int *mvjcost, int *mvcost[2], - int *distortion, - unsigned int *sse1, - const uint8_t *second_pred, - int w, int h, int use_upsampled_ref) { + int forced_stop, int iters_per_step, + int *cost_list, int *mvjcost, int *mvcost[2], + int *distortion, unsigned int *sse1, + const uint8_t *second_pred, int w, int h, + int use_upsampled_ref) { const uint8_t *const src_address = x->plane[0].src.buf; const int src_stride = x->plane[0].src.stride; const MACROBLOCKD *xd = &x->e_mbd; @@ -765,26 +687,23 @@ int vp10_find_best_sub_pixel_tree(MACROBLOCK *x, int kr, kc; if (!(allow_hp && vp10_use_mv_hp(ref_mv))) - if (round == 3) - round = 2; + if (round == 3) round = 2; bestmv->row *= 8; bestmv->col *= 8; // use_upsampled_ref can be 0 or 1 if (use_upsampled_ref) - besterr = upsampled_setup_center_error(xd, bestmv, ref_mv, error_per_bit, - vfp, src_address, src_stride, y, - y_stride, second_pred, w, h, - (offset * 8), mvjcost, mvcost, sse1, - distortion); + besterr = upsampled_setup_center_error( + xd, bestmv, ref_mv, error_per_bit, vfp, src_address, src_stride, y, + y_stride, second_pred, w, h, (offset * 8), mvjcost, mvcost, sse1, + distortion); else - besterr = setup_center_error(xd, bestmv, ref_mv, error_per_bit, vfp, - src_address, src_stride, y, y_stride, - second_pred, w, h, offset, mvjcost, mvcost, - sse1, distortion); + besterr = setup_center_error( + xd, bestmv, ref_mv, error_per_bit, vfp, src_address, src_stride, y, + y_stride, second_pred, w, h, offset, mvjcost, mvcost, sse1, distortion); - (void) cost_list; // to silence compiler warning + (void)cost_list; // to silence compiler warning for (iter = 0; iter < round; ++iter) { // Check vertical and horizontal sub-pixel positions. @@ -792,17 +711,17 @@ int vp10_find_best_sub_pixel_tree(MACROBLOCK *x, tr = br + search_step[idx].row; tc = bc + search_step[idx].col; if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) { - MV this_mv = {tr, tc}; + MV this_mv = { tr, tc }; if (use_upsampled_ref) { const uint8_t *const pre_address = y + tr * y_stride + tc; thismse = upsampled_pref_error(xd, vfp, src_address, src_stride, - pre_address, y_stride, second_pred, - w, h, &sse); + pre_address, y_stride, second_pred, w, + h, &sse); } else { - const uint8_t *const pre_address = y + (tr >> 3) * y_stride + - (tc >> 3); + const uint8_t *const pre_address = + y + (tr >> 3) * y_stride + (tc >> 3); if (second_pred == NULL) thismse = vfp->svf(pre_address, y_stride, sp(tc), sp(tr), src_address, src_stride, &sse); @@ -811,8 +730,8 @@ int vp10_find_best_sub_pixel_tree(MACROBLOCK *x, src_address, src_stride, &sse, second_pred); } - cost_array[idx] = thismse + - mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); + cost_array[idx] = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, + mvcost, error_per_bit); if (cost_array[idx] < besterr) { best_idx = idx; @@ -832,27 +751,27 @@ int vp10_find_best_sub_pixel_tree(MACROBLOCK *x, tc = bc + kc; tr = br + kr; if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) { - MV this_mv = {tr, tc}; + MV this_mv = { tr, tc }; if (use_upsampled_ref) { const uint8_t *const pre_address = y + tr * y_stride + tc; - thismse = upsampled_pref_error(xd, vfp, src_address, src_stride, - pre_address, y_stride, second_pred, w, h, - &sse); + thismse = + upsampled_pref_error(xd, vfp, src_address, src_stride, pre_address, + y_stride, second_pred, w, h, &sse); } else { const uint8_t *const pre_address = y + (tr >> 3) * y_stride + (tc >> 3); if (second_pred == NULL) - thismse = vfp->svf(pre_address, y_stride, sp(tc), sp(tr), - src_address, src_stride, &sse); + thismse = vfp->svf(pre_address, y_stride, sp(tc), sp(tr), src_address, + src_stride, &sse); else thismse = vfp->svaf(pre_address, y_stride, sp(tc), sp(tr), src_address, src_stride, &sse, second_pred); } - cost_array[4] = thismse + - mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); + cost_array[4] = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, + error_per_bit); if (cost_array[4] < besterr) { best_idx = 4; @@ -887,8 +806,8 @@ int vp10_find_best_sub_pixel_tree(MACROBLOCK *x, // These lines insure static analysis doesn't warn that // tr and tc aren't used after the above point. - (void) tr; - (void) tc; + (void)tr; + (void)tc; bestmv->row = br; bestmv->col = bc; @@ -905,10 +824,8 @@ int vp10_find_best_sub_pixel_tree(MACROBLOCK *x, static INLINE int check_bounds(const MACROBLOCK *x, int row, int col, int range) { - return ((row - range) >= x->mv_row_min) & - ((row + range) <= x->mv_row_max) & - ((col - range) >= x->mv_col_min) & - ((col + range) <= x->mv_col_max); + return ((row - range) >= x->mv_row_min) & ((row + range) <= x->mv_row_max) & + ((col - range) >= x->mv_col_min) & ((col + range) <= x->mv_col_max); } static INLINE int is_mv_in(const MACROBLOCK *x, const MV *mv) { @@ -916,33 +833,31 @@ static INLINE int is_mv_in(const MACROBLOCK *x, const MV *mv) { (mv->row >= x->mv_row_min) && (mv->row <= x->mv_row_max); } -#define CHECK_BETTER \ - {\ - if (thissad < bestsad) {\ - if (use_mvcost) \ - thissad += mvsad_err_cost(x, &this_mv, &fcenter_mv, sad_per_bit);\ - if (thissad < bestsad) {\ - bestsad = thissad;\ - best_site = i;\ - }\ - }\ +#define CHECK_BETTER \ + { \ + if (thissad < bestsad) { \ + if (use_mvcost) \ + thissad += mvsad_err_cost(x, &this_mv, &fcenter_mv, sad_per_bit); \ + if (thissad < bestsad) { \ + bestsad = thissad; \ + best_site = i; \ + } \ + } \ } -#define MAX_PATTERN_SCALES 11 -#define MAX_PATTERN_CANDIDATES 8 // max number of canddiates per scale -#define PATTERN_CANDIDATES_REF 3 // number of refinement candidates +#define MAX_PATTERN_SCALES 11 +#define MAX_PATTERN_CANDIDATES 8 // max number of canddiates per scale +#define PATTERN_CANDIDATES_REF 3 // number of refinement candidates // Calculate and return a sad+mvcost list around an integer best pel. static INLINE void calc_int_cost_list(const MACROBLOCK *x, - const MV *const ref_mv, - int sadpb, + const MV *const ref_mv, int sadpb, const vpx_variance_fn_ptr_t *fn_ptr, - const MV *best_mv, - int *cost_list) { - static const MV neighbors[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; + const MV *best_mv, int *cost_list) { + static const MV neighbors[4] = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 } }; const struct buf_2d *const what = &x->plane[0].src; const struct buf_2d *const in_what = &x->e_mbd.plane[0].pre[0]; - const MV fcenter_mv = {ref_mv->row >> 3, ref_mv->col >> 3}; + const MV fcenter_mv = { ref_mv->row >> 3, ref_mv->col >> 3 }; const int br = best_mv->row; const int bc = best_mv->col; MV this_mv; @@ -951,49 +866,43 @@ static INLINE void calc_int_cost_list(const MACROBLOCK *x, this_mv.row = br; this_mv.col = bc; - cost_list[0] = fn_ptr->vf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride, &sse) + + cost_list[0] = + fn_ptr->vf(what->buf, what->stride, get_buf_from_mv(in_what, &this_mv), + in_what->stride, &sse) + mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb); if (check_bounds(x, br, bc, 1)) { for (i = 0; i < 4; i++) { - const MV this_mv = {br + neighbors[i].row, - bc + neighbors[i].col}; + const MV this_mv = { br + neighbors[i].row, bc + neighbors[i].col }; cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride, get_buf_from_mv(in_what, &this_mv), in_what->stride, &sse) + - mv_err_cost(&this_mv, &fcenter_mv, - x->nmvjointcost, x->mvcost, - x->errorperbit); + mv_err_cost(&this_mv, &fcenter_mv, x->nmvjointcost, + x->mvcost, x->errorperbit); } } else { for (i = 0; i < 4; i++) { - const MV this_mv = {br + neighbors[i].row, - bc + neighbors[i].col}; + const MV this_mv = { br + neighbors[i].row, bc + neighbors[i].col }; if (!is_mv_in(x, &this_mv)) cost_list[i + 1] = INT_MAX; else cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride, get_buf_from_mv(in_what, &this_mv), in_what->stride, &sse) + - mv_err_cost(&this_mv, &fcenter_mv, - x->nmvjointcost, x->mvcost, - x->errorperbit); + mv_err_cost(&this_mv, &fcenter_mv, x->nmvjointcost, + x->mvcost, x->errorperbit); } } } static INLINE void calc_int_sad_list(const MACROBLOCK *x, - const MV *const ref_mv, - int sadpb, + const MV *const ref_mv, int sadpb, const vpx_variance_fn_ptr_t *fn_ptr, const MV *best_mv, int *cost_list, - const int use_mvcost, - const int bestsad) { - static const MV neighbors[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; + const int use_mvcost, const int bestsad) { + static const MV neighbors[4] = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 } }; const struct buf_2d *const what = &x->plane[0].src; const struct buf_2d *const in_what = &x->e_mbd.plane[0].pre[0]; - const MV fcenter_mv = {ref_mv->row >> 3, ref_mv->col >> 3}; + const MV fcenter_mv = { ref_mv->row >> 3, ref_mv->col >> 3 }; int i; const int br = best_mv->row; const int bc = best_mv->col; @@ -1002,32 +911,28 @@ static INLINE void calc_int_sad_list(const MACROBLOCK *x, cost_list[0] = bestsad; if (check_bounds(x, br, bc, 1)) { for (i = 0; i < 4; i++) { - const MV this_mv = { br + neighbors[i].row, - bc + neighbors[i].col }; - cost_list[i + 1] = fn_ptr->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + const MV this_mv = { br + neighbors[i].row, bc + neighbors[i].col }; + cost_list[i + 1] = + fn_ptr->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); } } else { for (i = 0; i < 4; i++) { - const MV this_mv = {br + neighbors[i].row, - bc + neighbors[i].col}; + const MV this_mv = { br + neighbors[i].row, bc + neighbors[i].col }; if (!is_mv_in(x, &this_mv)) cost_list[i + 1] = INT_MAX; else - cost_list[i + 1] = fn_ptr->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + cost_list[i + 1] = + fn_ptr->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); } } } else { if (use_mvcost) { for (i = 0; i < 4; i++) { - const MV this_mv = {br + neighbors[i].row, - bc + neighbors[i].col}; + const MV this_mv = { br + neighbors[i].row, bc + neighbors[i].col }; if (cost_list[i + 1] != INT_MAX) { - cost_list[i + 1] += - mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb); + cost_list[i + 1] += mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb); } } } @@ -1039,18 +944,12 @@ static INLINE void calc_int_sad_list(const MACROBLOCK *x, // candidates as indicated in the num_candidates and candidates arrays // passed into this function // -static int pattern_search(MACROBLOCK *x, - MV *start_mv, - int search_param, - int sad_per_bit, - int do_init_search, - int *cost_list, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost, - const MV *center_mv, - const int num_candidates[MAX_PATTERN_SCALES], - const MV candidates[MAX_PATTERN_SCALES] - [MAX_PATTERN_CANDIDATES]) { +static int pattern_search( + MACROBLOCK *x, MV *start_mv, int search_param, int sad_per_bit, + int do_init_search, int *cost_list, const vpx_variance_fn_ptr_t *vfp, + int use_mvcost, const MV *center_mv, + const int num_candidates[MAX_PATTERN_SCALES], + const MV candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES]) { const MACROBLOCKD *const xd = &x->e_mbd; static const int search_param_to_steps[MAX_MVSEARCH_STEPS] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, @@ -1063,7 +962,7 @@ static int pattern_search(MACROBLOCK *x, int bestsad = INT_MAX; int thissad; int k = -1; - const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; + const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 }; int best_init_s = search_param_to_steps[search_param]; // adjust ref_mv to make sure it is within MV range clamp_mv(start_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, @@ -1076,10 +975,9 @@ static int pattern_search(MACROBLOCK *x, } // Work out the start point for the search - bestsad = - vfp->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, start_mv), in_what->stride) + - mvsad_err_cost(x, start_mv, &fcenter_mv, sad_per_bit); + bestsad = vfp->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, start_mv), in_what->stride) + + mvsad_err_cost(x, start_mv, &fcenter_mv, sad_per_bit); // Search all possible scales upto the search param around the center point // pick the scale of the point that is best as the starting scale of @@ -1091,22 +989,21 @@ static int pattern_search(MACROBLOCK *x, int best_site = -1; if (check_bounds(x, br, bc, 1 << t)) { for (i = 0; i < num_candidates[t]; i++) { - const MV this_mv = {br + candidates[t][i].row, - bc + candidates[t][i].col}; - thissad = vfp->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + const MV this_mv = { br + candidates[t][i].row, + bc + candidates[t][i].col }; + thissad = + vfp->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); CHECK_BETTER } } else { for (i = 0; i < num_candidates[t]; i++) { - const MV this_mv = {br + candidates[t][i].row, - bc + candidates[t][i].col}; - if (!is_mv_in(x, &this_mv)) - continue; - thissad = vfp->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + const MV this_mv = { br + candidates[t][i].row, + bc + candidates[t][i].col }; + if (!is_mv_in(x, &this_mv)) continue; + thissad = + vfp->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); CHECK_BETTER } } @@ -1135,22 +1032,21 @@ static int pattern_search(MACROBLOCK *x, if (!do_init_search || s != best_init_s) { if (check_bounds(x, br, bc, 1 << s)) { for (i = 0; i < num_candidates[s]; i++) { - const MV this_mv = {br + candidates[s][i].row, - bc + candidates[s][i].col}; - thissad = vfp->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + const MV this_mv = { br + candidates[s][i].row, + bc + candidates[s][i].col }; + thissad = + vfp->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); CHECK_BETTER } } else { for (i = 0; i < num_candidates[s]; i++) { - const MV this_mv = {br + candidates[s][i].row, - bc + candidates[s][i].col}; - if (!is_mv_in(x, &this_mv)) - continue; - thissad = vfp->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + const MV this_mv = { br + candidates[s][i].row, + bc + candidates[s][i].col }; + if (!is_mv_in(x, &this_mv)) continue; + thissad = + vfp->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); CHECK_BETTER } } @@ -1173,22 +1069,25 @@ static int pattern_search(MACROBLOCK *x, if (check_bounds(x, br, bc, 1 << s)) { for (i = 0; i < PATTERN_CANDIDATES_REF; i++) { - const MV this_mv = {br + candidates[s][next_chkpts_indices[i]].row, - bc + candidates[s][next_chkpts_indices[i]].col}; - thissad = vfp->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + const MV this_mv = { + br + candidates[s][next_chkpts_indices[i]].row, + bc + candidates[s][next_chkpts_indices[i]].col + }; + thissad = + vfp->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); CHECK_BETTER } } else { for (i = 0; i < PATTERN_CANDIDATES_REF; i++) { - const MV this_mv = {br + candidates[s][next_chkpts_indices[i]].row, - bc + candidates[s][next_chkpts_indices[i]].col}; - if (!is_mv_in(x, &this_mv)) - continue; - thissad = vfp->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + const MV this_mv = { + br + candidates[s][next_chkpts_indices[i]].row, + bc + candidates[s][next_chkpts_indices[i]].col + }; + if (!is_mv_in(x, &this_mv)) continue; + thissad = + vfp->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); CHECK_BETTER } } @@ -1207,24 +1106,21 @@ static int pattern_search(MACROBLOCK *x, if (!do_init_search || s != best_init_s) { if (check_bounds(x, br, bc, 1 << s)) { for (i = 0; i < num_candidates[s]; i++) { - const MV this_mv = {br + candidates[s][i].row, - bc + candidates[s][i].col}; - cost_list[i + 1] = - thissad = vfp->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + const MV this_mv = { br + candidates[s][i].row, + bc + candidates[s][i].col }; + cost_list[i + 1] = thissad = + vfp->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); CHECK_BETTER } } else { for (i = 0; i < num_candidates[s]; i++) { - const MV this_mv = {br + candidates[s][i].row, - bc + candidates[s][i].col}; - if (!is_mv_in(x, &this_mv)) - continue; - cost_list[i + 1] = - thissad = vfp->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + const MV this_mv = { br + candidates[s][i].row, + bc + candidates[s][i].col }; + if (!is_mv_in(x, &this_mv)) continue; + cost_list[i + 1] = thissad = + vfp->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); CHECK_BETTER } } @@ -1247,26 +1143,28 @@ static int pattern_search(MACROBLOCK *x, if (check_bounds(x, br, bc, 1 << s)) { for (i = 0; i < PATTERN_CANDIDATES_REF; i++) { - const MV this_mv = {br + candidates[s][next_chkpts_indices[i]].row, - bc + candidates[s][next_chkpts_indices[i]].col}; - cost_list[next_chkpts_indices[i] + 1] = - thissad = vfp->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + const MV this_mv = { + br + candidates[s][next_chkpts_indices[i]].row, + bc + candidates[s][next_chkpts_indices[i]].col + }; + cost_list[next_chkpts_indices[i] + 1] = thissad = + vfp->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); CHECK_BETTER } } else { for (i = 0; i < PATTERN_CANDIDATES_REF; i++) { - const MV this_mv = {br + candidates[s][next_chkpts_indices[i]].row, - bc + candidates[s][next_chkpts_indices[i]].col}; + const MV this_mv = { + br + candidates[s][next_chkpts_indices[i]].row, + bc + candidates[s][next_chkpts_indices[i]].col + }; if (!is_mv_in(x, &this_mv)) { cost_list[next_chkpts_indices[i] + 1] = INT_MAX; continue; } - cost_list[next_chkpts_indices[i] + 1] = - thissad = vfp->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &this_mv), - in_what->stride); + cost_list[next_chkpts_indices[i] + 1] = thissad = + vfp->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &this_mv), in_what->stride); CHECK_BETTER } } @@ -1300,81 +1198,77 @@ static int pattern_search(MACROBLOCK *x, return bestsad; } -int vp10_get_mvpred_var(const MACROBLOCK *x, - const MV *best_mv, const MV *center_mv, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost) { +int vp10_get_mvpred_var(const MACROBLOCK *x, const MV *best_mv, + const MV *center_mv, const vpx_variance_fn_ptr_t *vfp, + int use_mvcost) { const MACROBLOCKD *const xd = &x->e_mbd; const struct buf_2d *const what = &x->plane[0].src; const struct buf_2d *const in_what = &xd->plane[0].pre[0]; - const MV mv = {best_mv->row * 8, best_mv->col * 8}; + const MV mv = { best_mv->row * 8, best_mv->col * 8 }; unsigned int unused; - return vfp->vf(what->buf, what->stride, - get_buf_from_mv(in_what, best_mv), in_what->stride, &unused) + - (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, - x->mvcost, x->errorperbit) : 0); + return vfp->vf(what->buf, what->stride, get_buf_from_mv(in_what, best_mv), + in_what->stride, &unused) + + (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, x->mvcost, + x->errorperbit) + : 0); } -int vp10_get_mvpred_av_var(const MACROBLOCK *x, - const MV *best_mv, const MV *center_mv, - const uint8_t *second_pred, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost) { +int vp10_get_mvpred_av_var(const MACROBLOCK *x, const MV *best_mv, + const MV *center_mv, const uint8_t *second_pred, + const vpx_variance_fn_ptr_t *vfp, int use_mvcost) { const MACROBLOCKD *const xd = &x->e_mbd; const struct buf_2d *const what = &x->plane[0].src; const struct buf_2d *const in_what = &xd->plane[0].pre[0]; - const MV mv = {best_mv->row * 8, best_mv->col * 8}; + const MV mv = { best_mv->row * 8, best_mv->col * 8 }; unsigned int unused; return vfp->svaf(get_buf_from_mv(in_what, best_mv), in_what->stride, 0, 0, what->buf, what->stride, &unused, second_pred) + - (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, - x->mvcost, x->errorperbit) : 0); + (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, x->mvcost, + x->errorperbit) + : 0); } -int vp10_hex_search(MACROBLOCK *x, - MV *start_mv, - int search_param, - int sad_per_bit, - int do_init_search, - int *cost_list, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost, +int vp10_hex_search(MACROBLOCK *x, MV *start_mv, int search_param, + int sad_per_bit, int do_init_search, int *cost_list, + const vpx_variance_fn_ptr_t *vfp, int use_mvcost, const MV *center_mv) { // First scale has 8-closest points, the rest have 6 points in hex shape // at increasing scales - static const int hex_num_candidates[MAX_PATTERN_SCALES] = { - 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 - }; + static const int hex_num_candidates[MAX_PATTERN_SCALES] = { 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6 }; // Note that the largest candidate step at each scale is 2^scale + /* clang-format off */ static const MV hex_candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES] = { - {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, { 0, 1}, { -1, 1}, {-1, 0}}, - {{-1, -2}, {1, -2}, {2, 0}, {1, 2}, { -1, 2}, { -2, 0}}, - {{-2, -4}, {2, -4}, {4, 0}, {2, 4}, { -2, 4}, { -4, 0}}, - {{-4, -8}, {4, -8}, {8, 0}, {4, 8}, { -4, 8}, { -8, 0}}, - {{-8, -16}, {8, -16}, {16, 0}, {8, 16}, { -8, 16}, { -16, 0}}, - {{-16, -32}, {16, -32}, {32, 0}, {16, 32}, { -16, 32}, { -32, 0}}, - {{-32, -64}, {32, -64}, {64, 0}, {32, 64}, { -32, 64}, { -64, 0}}, - {{-64, -128}, {64, -128}, {128, 0}, {64, 128}, { -64, 128}, { -128, 0}}, - {{-128, -256}, {128, -256}, {256, 0}, {128, 256}, { -128, 256}, { -256, 0}}, - {{-256, -512}, {256, -512}, {512, 0}, {256, 512}, { -256, 512}, { -512, 0}}, - {{-512, -1024}, {512, -1024}, {1024, 0}, {512, 1024}, { -512, 1024}, - { -1024, 0}}, + { { -1, -1 }, { 0, -1 }, { 1, -1 }, { 1, 0 }, { 1, 1 }, { 0, 1 }, { -1, 1 }, + { -1, 0 } }, + { { -1, -2 }, { 1, -2 }, { 2, 0 }, { 1, 2 }, { -1, 2 }, { -2, 0 } }, + { { -2, -4 }, { 2, -4 }, { 4, 0 }, { 2, 4 }, { -2, 4 }, { -4, 0 } }, + { { -4, -8 }, { 4, -8 }, { 8, 0 }, { 4, 8 }, { -4, 8 }, { -8, 0 } }, + { { -8, -16 }, { 8, -16 }, { 16, 0 }, { 8, 16 }, { -8, 16 }, { -16, 0 } }, + { { -16, -32 }, { 16, -32 }, { 32, 0 }, { 16, 32 }, { -16, 32 }, + { -32, 0 } }, + { { -32, -64 }, { 32, -64 }, { 64, 0 }, { 32, 64 }, { -32, 64 }, + { -64, 0 } }, + { { -64, -128 }, { 64, -128 }, { 128, 0 }, { 64, 128 }, { -64, 128 }, + { -128, 0 } }, + { { -128, -256 }, { 128, -256 }, { 256, 0 }, { 128, 256 }, { -128, 256 }, + { -256, 0 } }, + { { -256, -512 }, { 256, -512 }, { 512, 0 }, { 256, 512 }, { -256, 512 }, + { -512, 0 } }, + { { -512, -1024 }, { 512, -1024 }, { 1024, 0 }, { 512, 1024 }, + { -512, 1024 }, { -1024, 0 } }, }; - return pattern_search(x, start_mv, search_param, sad_per_bit, - do_init_search, cost_list, vfp, use_mvcost, - center_mv, hex_num_candidates, hex_candidates); + /* clang-format on */ + return pattern_search(x, start_mv, search_param, sad_per_bit, do_init_search, + cost_list, vfp, use_mvcost, center_mv, + hex_num_candidates, hex_candidates); } -static int bigdia_search(MACROBLOCK *x, - MV *start_mv, - int search_param, - int sad_per_bit, - int do_init_search, - int *cost_list, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost, +static int bigdia_search(MACROBLOCK *x, MV *start_mv, int search_param, + int sad_per_bit, int do_init_search, int *cost_list, + const vpx_variance_fn_ptr_t *vfp, int use_mvcost, const MV *center_mv) { // First scale has 4-closest points, the rest have 8 points in diamond // shape at increasing scales @@ -1382,112 +1276,109 @@ static int bigdia_search(MACROBLOCK *x, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, }; // Note that the largest candidate step at each scale is 2^scale - static const MV bigdia_candidates[MAX_PATTERN_SCALES] - [MAX_PATTERN_CANDIDATES] = { - {{0, -1}, {1, 0}, { 0, 1}, {-1, 0}}, - {{-1, -1}, {0, -2}, {1, -1}, {2, 0}, {1, 1}, {0, 2}, {-1, 1}, {-2, 0}}, - {{-2, -2}, {0, -4}, {2, -2}, {4, 0}, {2, 2}, {0, 4}, {-2, 2}, {-4, 0}}, - {{-4, -4}, {0, -8}, {4, -4}, {8, 0}, {4, 4}, {0, 8}, {-4, 4}, {-8, 0}}, - {{-8, -8}, {0, -16}, {8, -8}, {16, 0}, {8, 8}, {0, 16}, {-8, 8}, {-16, 0}}, - {{-16, -16}, {0, -32}, {16, -16}, {32, 0}, {16, 16}, {0, 32}, - {-16, 16}, {-32, 0}}, - {{-32, -32}, {0, -64}, {32, -32}, {64, 0}, {32, 32}, {0, 64}, - {-32, 32}, {-64, 0}}, - {{-64, -64}, {0, -128}, {64, -64}, {128, 0}, {64, 64}, {0, 128}, - {-64, 64}, {-128, 0}}, - {{-128, -128}, {0, -256}, {128, -128}, {256, 0}, {128, 128}, {0, 256}, - {-128, 128}, {-256, 0}}, - {{-256, -256}, {0, -512}, {256, -256}, {512, 0}, {256, 256}, {0, 512}, - {-256, 256}, {-512, 0}}, - {{-512, -512}, {0, -1024}, {512, -512}, {1024, 0}, {512, 512}, {0, 1024}, - {-512, 512}, {-1024, 0}}, - }; - return pattern_search(x, start_mv, search_param, sad_per_bit, - do_init_search, cost_list, vfp, use_mvcost, - center_mv, bigdia_num_candidates, bigdia_candidates); + /* clang-format off */ + static const MV + bigdia_candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES] = { + { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 } }, + { { -1, -1 }, { 0, -2 }, { 1, -1 }, { 2, 0 }, { 1, 1 }, { 0, 2 }, + { -1, 1 }, { -2, 0 } }, + { { -2, -2 }, { 0, -4 }, { 2, -2 }, { 4, 0 }, { 2, 2 }, { 0, 4 }, + { -2, 2 }, { -4, 0 } }, + { { -4, -4 }, { 0, -8 }, { 4, -4 }, { 8, 0 }, { 4, 4 }, { 0, 8 }, + { -4, 4 }, { -8, 0 } }, + { { -8, -8 }, { 0, -16 }, { 8, -8 }, { 16, 0 }, { 8, 8 }, { 0, 16 }, + { -8, 8 }, { -16, 0 } }, + { { -16, -16 }, { 0, -32 }, { 16, -16 }, { 32, 0 }, { 16, 16 }, + { 0, 32 }, { -16, 16 }, { -32, 0 } }, + { { -32, -32 }, { 0, -64 }, { 32, -32 }, { 64, 0 }, { 32, 32 }, + { 0, 64 }, { -32, 32 }, { -64, 0 } }, + { { -64, -64 }, { 0, -128 }, { 64, -64 }, { 128, 0 }, { 64, 64 }, + { 0, 128 }, { -64, 64 }, { -128, 0 } }, + { { -128, -128 }, { 0, -256 }, { 128, -128 }, { 256, 0 }, { 128, 128 }, + { 0, 256 }, { -128, 128 }, { -256, 0 } }, + { { -256, -256 }, { 0, -512 }, { 256, -256 }, { 512, 0 }, { 256, 256 }, + { 0, 512 }, { -256, 256 }, { -512, 0 } }, + { { -512, -512 }, { 0, -1024 }, { 512, -512 }, { 1024, 0 }, + { 512, 512 }, { 0, 1024 }, { -512, 512 }, { -1024, 0 } }, + }; + /* clang-format on */ + return pattern_search(x, start_mv, search_param, sad_per_bit, do_init_search, + cost_list, vfp, use_mvcost, center_mv, + bigdia_num_candidates, bigdia_candidates); } -static int square_search(MACROBLOCK *x, - MV *start_mv, - int search_param, - int sad_per_bit, - int do_init_search, - int *cost_list, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost, +static int square_search(MACROBLOCK *x, MV *start_mv, int search_param, + int sad_per_bit, int do_init_search, int *cost_list, + const vpx_variance_fn_ptr_t *vfp, int use_mvcost, const MV *center_mv) { // All scales have 8 closest points in square shape static const int square_num_candidates[MAX_PATTERN_SCALES] = { - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, }; // Note that the largest candidate step at each scale is 2^scale - static const MV square_candidates[MAX_PATTERN_SCALES] - [MAX_PATTERN_CANDIDATES] = { - {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}}, - {{-2, -2}, {0, -2}, {2, -2}, {2, 0}, {2, 2}, {0, 2}, {-2, 2}, {-2, 0}}, - {{-4, -4}, {0, -4}, {4, -4}, {4, 0}, {4, 4}, {0, 4}, {-4, 4}, {-4, 0}}, - {{-8, -8}, {0, -8}, {8, -8}, {8, 0}, {8, 8}, {0, 8}, {-8, 8}, {-8, 0}}, - {{-16, -16}, {0, -16}, {16, -16}, {16, 0}, {16, 16}, {0, 16}, - {-16, 16}, {-16, 0}}, - {{-32, -32}, {0, -32}, {32, -32}, {32, 0}, {32, 32}, {0, 32}, - {-32, 32}, {-32, 0}}, - {{-64, -64}, {0, -64}, {64, -64}, {64, 0}, {64, 64}, {0, 64}, - {-64, 64}, {-64, 0}}, - {{-128, -128}, {0, -128}, {128, -128}, {128, 0}, {128, 128}, {0, 128}, - {-128, 128}, {-128, 0}}, - {{-256, -256}, {0, -256}, {256, -256}, {256, 0}, {256, 256}, {0, 256}, - {-256, 256}, {-256, 0}}, - {{-512, -512}, {0, -512}, {512, -512}, {512, 0}, {512, 512}, {0, 512}, - {-512, 512}, {-512, 0}}, - {{-1024, -1024}, {0, -1024}, {1024, -1024}, {1024, 0}, {1024, 1024}, - {0, 1024}, {-1024, 1024}, {-1024, 0}}, - }; - return pattern_search(x, start_mv, search_param, sad_per_bit, - do_init_search, cost_list, vfp, use_mvcost, - center_mv, square_num_candidates, square_candidates); + /* clang-format off */ + static const MV + square_candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES] = { + { { -1, -1 }, { 0, -1 }, { 1, -1 }, { 1, 0 }, { 1, 1 }, { 0, 1 }, + { -1, 1 }, { -1, 0 } }, + { { -2, -2 }, { 0, -2 }, { 2, -2 }, { 2, 0 }, { 2, 2 }, { 0, 2 }, + { -2, 2 }, { -2, 0 } }, + { { -4, -4 }, { 0, -4 }, { 4, -4 }, { 4, 0 }, { 4, 4 }, { 0, 4 }, + { -4, 4 }, { -4, 0 } }, + { { -8, -8 }, { 0, -8 }, { 8, -8 }, { 8, 0 }, { 8, 8 }, { 0, 8 }, + { -8, 8 }, { -8, 0 } }, + { { -16, -16 }, { 0, -16 }, { 16, -16 }, { 16, 0 }, { 16, 16 }, + { 0, 16 }, { -16, 16 }, { -16, 0 } }, + { { -32, -32 }, { 0, -32 }, { 32, -32 }, { 32, 0 }, { 32, 32 }, + { 0, 32 }, { -32, 32 }, { -32, 0 } }, + { { -64, -64 }, { 0, -64 }, { 64, -64 }, { 64, 0 }, { 64, 64 }, + { 0, 64 }, { -64, 64 }, { -64, 0 } }, + { { -128, -128 }, { 0, -128 }, { 128, -128 }, { 128, 0 }, { 128, 128 }, + { 0, 128 }, { -128, 128 }, { -128, 0 } }, + { { -256, -256 }, { 0, -256 }, { 256, -256 }, { 256, 0 }, { 256, 256 }, + { 0, 256 }, { -256, 256 }, { -256, 0 } }, + { { -512, -512 }, { 0, -512 }, { 512, -512 }, { 512, 0 }, { 512, 512 }, + { 0, 512 }, { -512, 512 }, { -512, 0 } }, + { { -1024, -1024 }, { 0, -1024 }, { 1024, -1024 }, { 1024, 0 }, + { 1024, 1024 }, { 0, 1024 }, { -1024, 1024 }, { -1024, 0 } }, + }; + /* clang-format on */ + return pattern_search(x, start_mv, search_param, sad_per_bit, do_init_search, + cost_list, vfp, use_mvcost, center_mv, + square_num_candidates, square_candidates); } -static int fast_hex_search(MACROBLOCK *x, - MV *ref_mv, - int search_param, +static int fast_hex_search(MACROBLOCK *x, MV *ref_mv, int search_param, int sad_per_bit, int do_init_search, // must be zero for fast_hex - int *cost_list, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost, - const MV *center_mv) { + int *cost_list, const vpx_variance_fn_ptr_t *vfp, + int use_mvcost, const MV *center_mv) { return vp10_hex_search( x, ref_mv, VPXMAX(MAX_MVSEARCH_STEPS - 2, search_param), sad_per_bit, do_init_search, cost_list, vfp, use_mvcost, center_mv); } -static int fast_dia_search(MACROBLOCK *x, - MV *ref_mv, - int search_param, - int sad_per_bit, - int do_init_search, - int *cost_list, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost, +static int fast_dia_search(MACROBLOCK *x, MV *ref_mv, int search_param, + int sad_per_bit, int do_init_search, int *cost_list, + const vpx_variance_fn_ptr_t *vfp, int use_mvcost, const MV *center_mv) { - return bigdia_search( - x, ref_mv, VPXMAX(MAX_MVSEARCH_STEPS - 2, search_param), sad_per_bit, - do_init_search, cost_list, vfp, use_mvcost, center_mv); + return bigdia_search(x, ref_mv, VPXMAX(MAX_MVSEARCH_STEPS - 2, search_param), + sad_per_bit, do_init_search, cost_list, vfp, use_mvcost, + center_mv); } #undef CHECK_BETTER // Exhuastive motion search around a given centre position with a given // step size. -static int exhuastive_mesh_search(MACROBLOCK *x, - MV *ref_mv, MV *best_mv, +static int exhuastive_mesh_search(MACROBLOCK *x, MV *ref_mv, MV *best_mv, int range, int step, int sad_per_bit, const vpx_variance_fn_ptr_t *fn_ptr, const MV *center_mv) { const MACROBLOCKD *const xd = &x->e_mbd; const struct buf_2d *const what = &x->plane[0].src; const struct buf_2d *const in_what = &xd->plane[0].pre[0]; - MV fcenter_mv = {center_mv->row, center_mv->col}; + MV fcenter_mv = { center_mv->row, center_mv->col }; unsigned int best_sad = INT_MAX; int r, c, i; int start_col, end_col, start_row, end_row; @@ -1495,12 +1386,13 @@ static int exhuastive_mesh_search(MACROBLOCK *x, assert(step >= 1); - clamp_mv(&fcenter_mv, x->mv_col_min, x->mv_col_max, - x->mv_row_min, x->mv_row_max); + clamp_mv(&fcenter_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, + x->mv_row_max); *best_mv = fcenter_mv; - best_sad = fn_ptr->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &fcenter_mv), in_what->stride) + - mvsad_err_cost(x, &fcenter_mv, ref_mv, sad_per_bit); + best_sad = + fn_ptr->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &fcenter_mv), in_what->stride) + + mvsad_err_cost(x, &fcenter_mv, ref_mv, sad_per_bit); start_row = VPXMAX(-range, x->mv_row_min - fcenter_mv.row); start_col = VPXMAX(-range, x->mv_col_min - fcenter_mv.col); end_row = VPXMIN(range, x->mv_row_max - fcenter_mv.row); @@ -1510,9 +1402,10 @@ static int exhuastive_mesh_search(MACROBLOCK *x, for (c = start_col; c <= end_col; c += col_step) { // Step > 1 means we are not checking every location in this pass. if (step > 1) { - const MV mv = {fcenter_mv.row + r, fcenter_mv.col + c}; - unsigned int sad = fn_ptr->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &mv), in_what->stride); + const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c }; + unsigned int sad = + fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, &mv), + in_what->stride); if (sad < best_sad) { sad += mvsad_err_cost(x, &mv, ref_mv, sad_per_bit); if (sad < best_sad) { @@ -1527,17 +1420,16 @@ static int exhuastive_mesh_search(MACROBLOCK *x, unsigned int sads[4]; const uint8_t *addrs[4]; for (i = 0; i < 4; ++i) { - const MV mv = {fcenter_mv.row + r, fcenter_mv.col + c + i}; + const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c + i }; addrs[i] = get_buf_from_mv(in_what, &mv); } - fn_ptr->sdx4df(what->buf, what->stride, addrs, - in_what->stride, sads); + fn_ptr->sdx4df(what->buf, what->stride, addrs, in_what->stride, sads); for (i = 0; i < 4; ++i) { if (sads[i] < best_sad) { - const MV mv = {fcenter_mv.row + r, fcenter_mv.col + c + i}; - const unsigned int sad = sads[i] + - mvsad_err_cost(x, &mv, ref_mv, sad_per_bit); + const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c + i }; + const unsigned int sad = + sads[i] + mvsad_err_cost(x, &mv, ref_mv, sad_per_bit); if (sad < best_sad) { best_sad = sad; x->second_best_mv.as_mv = *best_mv; @@ -1547,9 +1439,10 @@ static int exhuastive_mesh_search(MACROBLOCK *x, } } else { for (i = 0; i < end_col - c; ++i) { - const MV mv = {fcenter_mv.row + r, fcenter_mv.col + c + i}; - unsigned int sad = fn_ptr->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &mv), in_what->stride); + const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c + i }; + unsigned int sad = + fn_ptr->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &mv), in_what->stride); if (sad < best_sad) { sad += mvsad_err_cost(x, &mv, ref_mv, sad_per_bit); if (sad < best_sad) { @@ -1567,8 +1460,7 @@ static int exhuastive_mesh_search(MACROBLOCK *x, return best_sad; } -int vp10_diamond_search_sad_c(MACROBLOCK *x, - const search_site_config *cfg, +int vp10_diamond_search_sad_c(MACROBLOCK *x, const search_site_config *cfg, MV *ref_mv, MV *best_mv, int search_param, int sad_per_bit, int *num00, const vpx_variance_fn_ptr_t *fn_ptr, @@ -1597,7 +1489,7 @@ int vp10_diamond_search_sad_c(MACROBLOCK *x, const search_site *ss = &cfg->ss[search_param * cfg->searches_per_step]; const int tot_steps = (cfg->ss_count / cfg->searches_per_step) - search_param; - const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; + const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 }; clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max); ref_row = ref_mv->row; ref_col = ref_mv->col; @@ -1610,8 +1502,8 @@ int vp10_diamond_search_sad_c(MACROBLOCK *x, best_address = in_what; // Check the starting position - bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride) - + mvsad_err_cost(x, best_mv, &fcenter_mv, sad_per_bit); + bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride) + + mvsad_err_cost(x, best_mv, &fcenter_mv, sad_per_bit); i = 1; @@ -1642,10 +1534,10 @@ int vp10_diamond_search_sad_c(MACROBLOCK *x, for (t = 0; t < 4; t++, i++) { if (sad_array[t] < bestsad) { - const MV this_mv = {best_mv->row + ss[i].mv.row, - best_mv->col + ss[i].mv.col}; - sad_array[t] += mvsad_err_cost(x, &this_mv, &fcenter_mv, - sad_per_bit); + const MV this_mv = { best_mv->row + ss[i].mv.row, + best_mv->col + ss[i].mv.col }; + sad_array[t] += + mvsad_err_cost(x, &this_mv, &fcenter_mv, sad_per_bit); if (sad_array[t] < bestsad) { bestsad = sad_array[t]; best_site = i; @@ -1656,13 +1548,13 @@ int vp10_diamond_search_sad_c(MACROBLOCK *x, } else { for (j = 0; j < cfg->searches_per_step; j++) { // Trap illegal vectors - const MV this_mv = {best_mv->row + ss[i].mv.row, - best_mv->col + ss[i].mv.col}; + const MV this_mv = { best_mv->row + ss[i].mv.row, + best_mv->col + ss[i].mv.col }; if (is_mv_in(x, &this_mv)) { const uint8_t *const check_here = ss[i].offset + best_address; - unsigned int thissad = fn_ptr->sdf(what, what_stride, check_here, - in_what_stride); + unsigned int thissad = + fn_ptr->sdf(what, what_stride, check_here, in_what_stride); if (thissad < bestsad) { thissad += mvsad_err_cost(x, &this_mv, &fcenter_mv, sad_per_bit); @@ -1683,12 +1575,12 @@ int vp10_diamond_search_sad_c(MACROBLOCK *x, last_site = best_site; #if defined(NEW_DIAMOND_SEARCH) while (1) { - const MV this_mv = {best_mv->row + ss[best_site].mv.row, - best_mv->col + ss[best_site].mv.col}; + const MV this_mv = { best_mv->row + ss[best_site].mv.row, + best_mv->col + ss[best_site].mv.col }; if (is_mv_in(x, &this_mv)) { const uint8_t *const check_here = ss[best_site].offset + best_address; - unsigned int thissad = fn_ptr->sdf(what, what_stride, check_here, - in_what_stride); + unsigned int thissad = + fn_ptr->sdf(what, what_stride, check_here, in_what_stride); if (thissad < bestsad) { thissad += mvsad_err_cost(x, &this_mv, &fcenter_mv, sad_per_bit); if (thissad < bestsad) { @@ -1728,8 +1620,7 @@ static int vector_match(int16_t *ref, int16_t *src, int bwl) { for (d = -8; d <= 8; d += 16) { int this_pos = offset + d; // check limit - if (this_pos < 0 || this_pos > bw) - continue; + if (this_pos < 0 || this_pos > bw) continue; this_sad = vpx_vector_var(&ref[this_pos], src, bwl); if (this_sad < best_sad) { best_sad = this_sad; @@ -1741,8 +1632,7 @@ static int vector_match(int16_t *ref, int16_t *src, int bwl) { for (d = -4; d <= 4; d += 8) { int this_pos = offset + d; // check limit - if (this_pos < 0 || this_pos > bw) - continue; + if (this_pos < 0 || this_pos > bw) continue; this_sad = vpx_vector_var(&ref[this_pos], src, bwl); if (this_sad < best_sad) { best_sad = this_sad; @@ -1754,8 +1644,7 @@ static int vector_match(int16_t *ref, int16_t *src, int bwl) { for (d = -2; d <= 2; d += 4) { int this_pos = offset + d; // check limit - if (this_pos < 0 || this_pos > bw) - continue; + if (this_pos < 0 || this_pos > bw) continue; this_sad = vpx_vector_var(&ref[this_pos], src, bwl); if (this_sad < best_sad) { best_sad = this_sad; @@ -1767,8 +1656,7 @@ static int vector_match(int16_t *ref, int16_t *src, int bwl) { for (d = -1; d <= 1; d += 2) { int this_pos = offset + d; // check limit - if (this_pos < 0 || this_pos > bw) - continue; + if (this_pos < 0 || this_pos > bw) continue; this_sad = vpx_vector_var(&ref[this_pos], src, bwl); if (this_sad < best_sad) { best_sad = this_sad; @@ -1780,15 +1668,15 @@ static int vector_match(int16_t *ref, int16_t *src, int bwl) { } static const MV search_pos[4] = { - {-1, 0}, {0, -1}, {0, 1}, {1, 0}, + { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 }, }; unsigned int vp10_int_pro_motion_estimation(const VP10_COMP *cpi, MACROBLOCK *x, - BLOCK_SIZE bsize, - int mi_row, int mi_col) { + BLOCK_SIZE bsize, int mi_row, + int mi_col) { MACROBLOCKD *xd = &x->e_mbd; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; - struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0, 0, 0, 0}}; + struct buf_2d backup_yv12[MAX_MB_PLANE] = { { 0, 0, 0, 0, 0 } }; DECLARE_ALIGNED(16, int16_t, hbuf[2 * MAX_SB_SIZE]); DECLARE_ALIGNED(16, int16_t, vbuf[2 * MAX_SB_SIZE]); DECLARE_ALIGNED(16, int16_t, src_hbuf[MAX_SB_SQUARE]); @@ -1813,8 +1701,7 @@ unsigned int vp10_int_pro_motion_estimation(const VP10_COMP *cpi, MACROBLOCK *x, // Swap out the reference frame for a version that's been scaled to // match the resolution of the current frame, allowing the existing // motion search code to be used without additional modifications. - for (i = 0; i < MAX_MB_PLANE; i++) - backup_yv12[i] = xd->plane[i].pre[0]; + for (i = 0; i < MAX_MB_PLANE; i++) backup_yv12[i] = xd->plane[i].pre[0]; vp10_setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL); } @@ -1828,8 +1715,7 @@ unsigned int vp10_int_pro_motion_estimation(const VP10_COMP *cpi, MACROBLOCK *x, if (scaled_ref_frame) { int i; - for (i = 0; i < MAX_MB_PLANE; i++) - xd->plane[i].pre[0] = backup_yv12[i]; + for (i = 0; i < MAX_MB_PLANE; i++) xd->plane[i].pre[0] = backup_yv12[i]; } return this_sad; } @@ -1870,11 +1756,8 @@ unsigned int vp10_int_pro_motion_estimation(const VP10_COMP *cpi, MACROBLOCK *x, best_sad = cpi->fn_ptr[bsize].sdf(src_buf, src_stride, ref_buf, ref_stride); { - const uint8_t * const pos[4] = { - ref_buf - ref_stride, - ref_buf - 1, - ref_buf + 1, - ref_buf + ref_stride, + const uint8_t *const pos[4] = { + ref_buf - ref_stride, ref_buf - 1, ref_buf + 1, ref_buf + ref_stride, }; cpi->fn_ptr[bsize].sdx4df(src_buf, src_stride, pos, ref_stride, this_sad); @@ -1900,8 +1783,7 @@ unsigned int vp10_int_pro_motion_estimation(const VP10_COMP *cpi, MACROBLOCK *x, ref_buf = xd->plane[0].pre[0].buf + this_mv.row * ref_stride + this_mv.col; - tmp_sad = cpi->fn_ptr[bsize].sdf(src_buf, src_stride, - ref_buf, ref_stride); + tmp_sad = cpi->fn_ptr[bsize].sdf(src_buf, src_stride, ref_buf, ref_stride); if (best_sad > tmp_sad) { *tmp_mv = this_mv; best_sad = tmp_sad; @@ -1912,8 +1794,7 @@ unsigned int vp10_int_pro_motion_estimation(const VP10_COMP *cpi, MACROBLOCK *x, if (scaled_ref_frame) { int i; - for (i = 0; i < MAX_MB_PLANE; i++) - xd->plane[i].pre[0] = backup_yv12[i]; + for (i = 0; i < MAX_MB_PLANE; i++) xd->plane[i].pre[0] = backup_yv12[i]; } return best_sad; @@ -1922,25 +1803,22 @@ unsigned int vp10_int_pro_motion_estimation(const VP10_COMP *cpi, MACROBLOCK *x, /* do_refine: If last step (1-away) of n-step search doesn't pick the center point as the best match, we will do a final 1-away diamond refining search */ -static int full_pixel_diamond(VP10_COMP *cpi, MACROBLOCK *x, - MV *mvp_full, int step_param, - int sadpb, int further_steps, int do_refine, - int *cost_list, +static int full_pixel_diamond(VP10_COMP *cpi, MACROBLOCK *x, MV *mvp_full, + int step_param, int sadpb, int further_steps, + int do_refine, int *cost_list, const vpx_variance_fn_ptr_t *fn_ptr, const MV *ref_mv) { MV temp_mv; int thissme, n, num00 = 0; int bestsme = cpi->diamond_search_sad(x, &cpi->ss_cfg, mvp_full, &temp_mv, - step_param, sadpb, &n, - fn_ptr, ref_mv); + step_param, sadpb, &n, fn_ptr, ref_mv); if (bestsme < INT_MAX) bestsme = vp10_get_mvpred_var(x, &temp_mv, ref_mv, fn_ptr, 1); x->best_mv.as_mv = temp_mv; // If there won't be more n-step search, check to see if refining search is // needed. - if (n > further_steps) - do_refine = 0; + if (n > further_steps) do_refine = 0; while (n < further_steps) { ++n; @@ -1949,14 +1827,13 @@ static int full_pixel_diamond(VP10_COMP *cpi, MACROBLOCK *x, num00--; } else { thissme = cpi->diamond_search_sad(x, &cpi->ss_cfg, mvp_full, &temp_mv, - step_param + n, sadpb, &num00, - fn_ptr, ref_mv); + step_param + n, sadpb, &num00, fn_ptr, + ref_mv); if (thissme < INT_MAX) thissme = vp10_get_mvpred_var(x, &temp_mv, ref_mv, fn_ptr, 1); // check to see if refining search is needed. - if (num00 > further_steps - n) - do_refine = 0; + if (num00 > further_steps - n) do_refine = 0; if (thissme < bestsme) { bestsme = thissme; @@ -1969,8 +1846,8 @@ static int full_pixel_diamond(VP10_COMP *cpi, MACROBLOCK *x, if (do_refine) { const int search_range = 8; MV best_mv = x->best_mv.as_mv; - thissme = vp10_refining_search_sad(x, &best_mv, sadpb, search_range, - fn_ptr, ref_mv); + thissme = vp10_refining_search_sad(x, &best_mv, sadpb, search_range, fn_ptr, + ref_mv); if (thissme < INT_MAX) thissme = vp10_get_mvpred_var(x, &best_mv, ref_mv, fn_ptr, 1); if (thissme < bestsme) { @@ -1997,8 +1874,8 @@ static int full_pixel_exhaustive(VP10_COMP *cpi, MACROBLOCK *x, const vpx_variance_fn_ptr_t *fn_ptr, const MV *ref_mv, MV *dst_mv) { const SPEED_FEATURES *const sf = &cpi->sf; - MV temp_mv = {centre_mv_full->row, centre_mv_full->col}; - MV f_ref_mv = {ref_mv->row >> 3, ref_mv->col >> 3}; + MV temp_mv = { centre_mv_full->row, centre_mv_full->col }; + MV f_ref_mv = { ref_mv->row >> 3, ref_mv->col >> 3 }; int bestsme; int i; int interval = sf->mesh_patterns[0].interval; @@ -2009,8 +1886,8 @@ static int full_pixel_exhaustive(VP10_COMP *cpi, MACROBLOCK *x, ++(*x->ex_search_count_ptr); // Trap illegal values for interval and range for this function. - if ((range < MIN_RANGE) || (range > MAX_RANGE) || - (interval < MIN_INTERVAL) || (interval > range)) + if ((range < MIN_RANGE) || (range > MAX_RANGE) || (interval < MIN_INTERVAL) || + (interval > range)) return INT_MAX; baseline_interval_divisor = range / interval; @@ -2022,21 +1899,19 @@ static int full_pixel_exhaustive(VP10_COMP *cpi, MACROBLOCK *x, interval = VPXMAX(interval, range / baseline_interval_divisor); // initial search - bestsme = exhuastive_mesh_search(x, &f_ref_mv, &temp_mv, range, - interval, sadpb, fn_ptr, &temp_mv); + bestsme = exhuastive_mesh_search(x, &f_ref_mv, &temp_mv, range, interval, + sadpb, fn_ptr, &temp_mv); if ((interval > MIN_INTERVAL) && (range > MIN_RANGE)) { // Progressive searches with range and step size decreasing each time // till we reach a step size of 1. Then break out. for (i = 1; i < MAX_MESH_STEP; ++i) { // First pass with coarser step and longer range - bestsme = exhuastive_mesh_search(x, &f_ref_mv, &temp_mv, - sf->mesh_patterns[i].range, - sf->mesh_patterns[i].interval, - sadpb, fn_ptr, &temp_mv); + bestsme = exhuastive_mesh_search( + x, &f_ref_mv, &temp_mv, sf->mesh_patterns[i].range, + sf->mesh_patterns[i].interval, sadpb, fn_ptr, &temp_mv); - if (sf->mesh_patterns[i].interval == 1) - break; + if (sf->mesh_patterns[i].interval == 1) break; } } @@ -2063,18 +1938,20 @@ int vp10_full_search_sad_c(const MACROBLOCK *x, const MV *ref_mv, const int row_max = VPXMIN(ref_mv->row + distance, x->mv_row_max); const int col_min = VPXMAX(ref_mv->col - distance, x->mv_col_min); const int col_max = VPXMIN(ref_mv->col + distance, x->mv_col_max); - const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; - int best_sad = fn_ptr->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, ref_mv), in_what->stride) + + const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 }; + int best_sad = + fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, ref_mv), + in_what->stride) + mvsad_err_cost(x, ref_mv, &fcenter_mv, sad_per_bit); *best_mv = *ref_mv; for (r = row_min; r < row_max; ++r) { for (c = col_min; c < col_max; ++c) { - const MV mv = {r, c}; - const int sad = fn_ptr->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &mv), in_what->stride) + - mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit); + const MV mv = { r, c }; + const int sad = + fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, &mv), + in_what->stride) + + mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit); if (sad < best_sad) { best_sad = sad; *best_mv = mv; @@ -2096,9 +1973,10 @@ int vp10_full_search_sadx3(const MACROBLOCK *x, const MV *ref_mv, const int row_max = VPXMIN(ref_mv->row + distance, x->mv_row_max); const int col_min = VPXMAX(ref_mv->col - distance, x->mv_col_min); const int col_max = VPXMIN(ref_mv->col + distance, x->mv_col_max); - const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; - unsigned int best_sad = fn_ptr->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, ref_mv), in_what->stride) + + const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 }; + unsigned int best_sad = + fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, ref_mv), + in_what->stride) + mvsad_err_cost(x, ref_mv, &fcenter_mv, sad_per_bit); *best_mv = *ref_mv; @@ -2117,7 +1995,7 @@ int vp10_full_search_sadx3(const MACROBLOCK *x, const MV *ref_mv, for (i = 0; i < 3; ++i) { unsigned int sad = sads[i]; if (sad < best_sad) { - const MV mv = {r, c}; + const MV mv = { r, c }; sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit); if (sad < best_sad) { best_sad = sad; @@ -2131,10 +2009,10 @@ int vp10_full_search_sadx3(const MACROBLOCK *x, const MV *ref_mv, } while (c < col_max) { - unsigned int sad = fn_ptr->sdf(what->buf, what->stride, - check_here, in_what->stride); + unsigned int sad = + fn_ptr->sdf(what->buf, what->stride, check_here, in_what->stride); if (sad < best_sad) { - const MV mv = {r, c}; + const MV mv = { r, c }; sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit); if (sad < best_sad) { best_sad = sad; @@ -2161,9 +2039,10 @@ int vp10_full_search_sadx8(const MACROBLOCK *x, const MV *ref_mv, const int row_max = VPXMIN(ref_mv->row + distance, x->mv_row_max); const int col_min = VPXMAX(ref_mv->col - distance, x->mv_col_min); const int col_max = VPXMIN(ref_mv->col + distance, x->mv_col_max); - const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; - unsigned int best_sad = fn_ptr->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, ref_mv), in_what->stride) + + const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 }; + unsigned int best_sad = + fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, ref_mv), + in_what->stride) + mvsad_err_cost(x, ref_mv, &fcenter_mv, sad_per_bit); *best_mv = *ref_mv; @@ -2182,7 +2061,7 @@ int vp10_full_search_sadx8(const MACROBLOCK *x, const MV *ref_mv, for (i = 0; i < 8; ++i) { unsigned int sad = sads[i]; if (sad < best_sad) { - const MV mv = {r, c}; + const MV mv = { r, c }; sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit); if (sad < best_sad) { best_sad = sad; @@ -2206,7 +2085,7 @@ int vp10_full_search_sadx8(const MACROBLOCK *x, const MV *ref_mv, for (i = 0; i < 3; ++i) { unsigned int sad = sads[i]; if (sad < best_sad) { - const MV mv = {r, c}; + const MV mv = { r, c }; sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit); if (sad < best_sad) { best_sad = sad; @@ -2220,10 +2099,10 @@ int vp10_full_search_sadx8(const MACROBLOCK *x, const MV *ref_mv, } while (c < col_max) { - unsigned int sad = fn_ptr->sdf(what->buf, what->stride, - check_here, in_what->stride); + unsigned int sad = + fn_ptr->sdf(what->buf, what->stride, check_here, in_what->stride); if (sad < best_sad) { - const MV mv = {r, c}; + const MV mv = { r, c }; sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit); if (sad < best_sad) { best_sad = sad; @@ -2238,19 +2117,18 @@ int vp10_full_search_sadx8(const MACROBLOCK *x, const MV *ref_mv, return best_sad; } -int vp10_refining_search_sad(MACROBLOCK *x, - MV *ref_mv, int error_per_bit, +int vp10_refining_search_sad(MACROBLOCK *x, MV *ref_mv, int error_per_bit, int search_range, const vpx_variance_fn_ptr_t *fn_ptr, const MV *center_mv) { const MACROBLOCKD *const xd = &x->e_mbd; - const MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; + const MV neighbors[4] = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } }; const struct buf_2d *const what = &x->plane[0].src; const struct buf_2d *const in_what = &xd->plane[0].pre[0]; - const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; + const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 }; const uint8_t *best_address = get_buf_from_mv(in_what, ref_mv); - unsigned int best_sad = fn_ptr->sdf(what->buf, what->stride, best_address, - in_what->stride) + + unsigned int best_sad = + fn_ptr->sdf(what->buf, what->stride, best_address, in_what->stride) + mvsad_err_cost(x, ref_mv, &fcenter_mv, error_per_bit); int i, j; @@ -2263,19 +2141,16 @@ int vp10_refining_search_sad(MACROBLOCK *x, if (all_in) { unsigned int sads[4]; - const uint8_t *const positions[4] = { - best_address - in_what->stride, - best_address - 1, - best_address + 1, - best_address + in_what->stride - }; + const uint8_t *const positions[4] = { best_address - in_what->stride, + best_address - 1, best_address + 1, + best_address + in_what->stride }; fn_ptr->sdx4df(what->buf, what->stride, positions, in_what->stride, sads); for (j = 0; j < 4; ++j) { if (sads[j] < best_sad) { - const MV mv = {ref_mv->row + neighbors[j].row, - ref_mv->col + neighbors[j].col}; + const MV mv = { ref_mv->row + neighbors[j].row, + ref_mv->col + neighbors[j].col }; sads[j] += mvsad_err_cost(x, &mv, &fcenter_mv, error_per_bit); if (sads[j] < best_sad) { best_sad = sads[j]; @@ -2285,13 +2160,13 @@ int vp10_refining_search_sad(MACROBLOCK *x, } } else { for (j = 0; j < 4; ++j) { - const MV mv = {ref_mv->row + neighbors[j].row, - ref_mv->col + neighbors[j].col}; + const MV mv = { ref_mv->row + neighbors[j].row, + ref_mv->col + neighbors[j].col }; if (is_mv_in(x, &mv)) { - unsigned int sad = fn_ptr->sdf(what->buf, what->stride, - get_buf_from_mv(in_what, &mv), - in_what->stride); + unsigned int sad = + fn_ptr->sdf(what->buf, what->stride, + get_buf_from_mv(in_what, &mv), in_what->stride); if (sad < best_sad) { sad += mvsad_err_cost(x, &mv, &fcenter_mv, error_per_bit); if (sad < best_sad) { @@ -2318,21 +2193,20 @@ int vp10_refining_search_sad(MACROBLOCK *x, // This function is called when we do joint motion search in comp_inter_inter // mode. -int vp10_refining_search_8p_c(MACROBLOCK *x, - int error_per_bit, +int vp10_refining_search_8p_c(MACROBLOCK *x, int error_per_bit, int search_range, const vpx_variance_fn_ptr_t *fn_ptr, - const MV *center_mv, - const uint8_t *second_pred) { - const MV neighbors[8] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}, - {-1, -1}, {1, -1}, {-1, 1}, {1, 1}}; + const MV *center_mv, const uint8_t *second_pred) { + const MV neighbors[8] = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 }, + { -1, -1 }, { 1, -1 }, { -1, 1 }, { 1, 1 } }; const MACROBLOCKD *const xd = &x->e_mbd; const struct buf_2d *const what = &x->plane[0].src; const struct buf_2d *const in_what = &xd->plane[0].pre[0]; - const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; + const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 }; MV *best_mv = &x->best_mv.as_mv; - unsigned int best_sad = fn_ptr->sdaf(what->buf, what->stride, - get_buf_from_mv(in_what, best_mv), in_what->stride, second_pred) + + unsigned int best_sad = + fn_ptr->sdaf(what->buf, what->stride, get_buf_from_mv(in_what, best_mv), + in_what->stride, second_pred) + mvsad_err_cost(x, best_mv, &fcenter_mv, error_per_bit); int i, j; @@ -2340,12 +2214,13 @@ int vp10_refining_search_8p_c(MACROBLOCK *x, int best_site = -1; for (j = 0; j < 8; ++j) { - const MV mv = {best_mv->row + neighbors[j].row, - best_mv->col + neighbors[j].col}; + const MV mv = { best_mv->row + neighbors[j].row, + best_mv->col + neighbors[j].col }; if (is_mv_in(x, &mv)) { - unsigned int sad = fn_ptr->sdaf(what->buf, what->stride, - get_buf_from_mv(in_what, &mv), in_what->stride, second_pred); + unsigned int sad = + fn_ptr->sdaf(what->buf, what->stride, get_buf_from_mv(in_what, &mv), + in_what->stride, second_pred); if (sad < best_sad) { sad += mvsad_err_cost(x, &mv, &fcenter_mv, error_per_bit); if (sad < best_sad) { @@ -2369,20 +2244,19 @@ int vp10_refining_search_8p_c(MACROBLOCK *x, #define MIN_EX_SEARCH_LIMIT 128 static int is_exhaustive_allowed(VP10_COMP *cpi, MACROBLOCK *x) { const SPEED_FEATURES *const sf = &cpi->sf; - const int max_ex = VPXMAX(MIN_EX_SEARCH_LIMIT, - (*x->m_search_count_ptr * sf->max_exaustive_pct) / 100); + const int max_ex = + VPXMAX(MIN_EX_SEARCH_LIMIT, + (*x->m_search_count_ptr * sf->max_exaustive_pct) / 100); return sf->allow_exhaustive_searches && - (sf->exhaustive_searches_thresh < INT_MAX) && - (*x->ex_search_count_ptr <= max_ex) && - !cpi->rc.is_src_frame_alt_ref; + (sf->exhaustive_searches_thresh < INT_MAX) && + (*x->ex_search_count_ptr <= max_ex) && !cpi->rc.is_src_frame_alt_ref; } -int vp10_full_pixel_search(VP10_COMP *cpi, MACROBLOCK *x, - BLOCK_SIZE bsize, MV *mvp_full, - int step_param, int error_per_bit, - int *cost_list, const MV *ref_mv, - int var_max, int rd) { +int vp10_full_pixel_search(VP10_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, + MV *mvp_full, int step_param, int error_per_bit, + int *cost_list, const MV *ref_mv, int var_max, + int rd) { const SPEED_FEATURES *const sf = &cpi->sf; const SEARCH_METHODS method = sf->mv.search_method; vpx_variance_fn_ptr_t *fn_ptr = &cpi->fn_ptr[bsize]; @@ -2413,31 +2287,31 @@ int vp10_full_pixel_search(VP10_COMP *cpi, MACROBLOCK *x, cost_list, fn_ptr, 1, ref_mv); break; case SQUARE: - var = square_search(x, mvp_full, step_param, error_per_bit, 1, - cost_list, fn_ptr, 1, ref_mv); + var = square_search(x, mvp_full, step_param, error_per_bit, 1, cost_list, + fn_ptr, 1, ref_mv); break; case BIGDIA: - var = bigdia_search(x, mvp_full, step_param, error_per_bit, 1, - cost_list, fn_ptr, 1, ref_mv); + var = bigdia_search(x, mvp_full, step_param, error_per_bit, 1, cost_list, + fn_ptr, 1, ref_mv); break; case NSTEP: var = full_pixel_diamond(cpi, x, mvp_full, step_param, error_per_bit, - MAX_MVSEARCH_STEPS - 1 - step_param, - 1, cost_list, fn_ptr, ref_mv); + MAX_MVSEARCH_STEPS - 1 - step_param, 1, + cost_list, fn_ptr, ref_mv); // Should we allow a follow on exhaustive search? if (is_exhaustive_allowed(cpi, x)) { int64_t exhuastive_thr = sf->exhaustive_searches_thresh; - exhuastive_thr >>= 8 - (b_width_log2_lookup[bsize] + - b_height_log2_lookup[bsize]); + exhuastive_thr >>= + 8 - (b_width_log2_lookup[bsize] + b_height_log2_lookup[bsize]); // Threshold variance for an exhaustive full search. if (var > exhuastive_thr) { - int var_ex; + int var_ex; MV tmp_mv_ex; - var_ex = full_pixel_exhaustive(cpi, x, &x->best_mv.as_mv, - error_per_bit, cost_list, fn_ptr, - ref_mv, &tmp_mv_ex); + var_ex = + full_pixel_exhaustive(cpi, x, &x->best_mv.as_mv, error_per_bit, + cost_list, fn_ptr, ref_mv, &tmp_mv_ex); if (var_ex < var) { var = var_ex; @@ -2448,8 +2322,7 @@ int vp10_full_pixel_search(VP10_COMP *cpi, MACROBLOCK *x, break; break; - default: - assert(0 && "Invalid search method."); + default: assert(0 && "Invalid search method."); } if (method != NSTEP && rd && var < var_max) @@ -2460,66 +2333,61 @@ int vp10_full_pixel_search(VP10_COMP *cpi, MACROBLOCK *x, #if CONFIG_EXT_INTER /* returns subpixel variance error function */ -#define DIST(r, c) \ - vfp->msvf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), z, \ - src_stride, mask, mask_stride, &sse) +#define DIST(r, c) \ + vfp->msvf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), z, src_stride, \ + mask, mask_stride, &sse) /* checks if (r, c) has better score than previous best */ -#define MVC(r, c) \ - (mvcost ? \ - ((mvjcost[((r) != rr) * 2 + ((c) != rc)] + \ - mvcost[0][((r) - rr)] + mvcost[1][((c) - rc)]) * \ - error_per_bit + 4096) >> 13 : 0) +#define MVC(r, c) \ + (mvcost \ + ? ((mvjcost[((r) != rr) * 2 + ((c) != rc)] + mvcost[0][((r)-rr)] + \ + mvcost[1][((c)-rc)]) * \ + error_per_bit + \ + 4096) >> \ + 13 \ + : 0) -#define CHECK_BETTER(v, r, c) \ - if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ - thismse = (DIST(r, c)); \ - if ((v = MVC(r, c) + thismse) < besterr) { \ - besterr = v; \ - br = r; \ - bc = c; \ - *distortion = thismse; \ - *sse1 = sse; \ - } \ - } else { \ - v = INT_MAX; \ +#define CHECK_BETTER(v, r, c) \ + if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ + thismse = (DIST(r, c)); \ + if ((v = MVC(r, c) + thismse) < besterr) { \ + besterr = v; \ + br = r; \ + bc = c; \ + *distortion = thismse; \ + *sse1 = sse; \ + } \ + } else { \ + v = INT_MAX; \ } #undef CHECK_BETTER0 #define CHECK_BETTER0(v, r, c) CHECK_BETTER(v, r, c) #undef CHECK_BETTER1 -#define CHECK_BETTER1(v, r, c) \ - if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ - thismse = upsampled_masked_pref_error(xd, \ - mask, mask_stride, \ - vfp, z, src_stride, \ - upre(y, y_stride, r, c), \ - y_stride, \ - w, h, &sse); \ - if ((v = MVC(r, c) + thismse) < besterr) { \ - besterr = v; \ - br = r; \ - bc = c; \ - *distortion = thismse; \ - *sse1 = sse; \ - } \ - } else { \ - v = INT_MAX; \ +#define CHECK_BETTER1(v, r, c) \ + if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ + thismse = upsampled_masked_pref_error(xd, mask, mask_stride, vfp, z, \ + src_stride, upre(y, y_stride, r, c), \ + y_stride, w, h, &sse); \ + if ((v = MVC(r, c) + thismse) < besterr) { \ + besterr = v; \ + br = r; \ + bc = c; \ + *distortion = thismse; \ + *sse1 = sse; \ + } \ + } else { \ + v = INT_MAX; \ } -int vp10_find_best_masked_sub_pixel_tree(const MACROBLOCK *x, - const uint8_t *mask, int mask_stride, - MV *bestmv, const MV *ref_mv, - int allow_hp, - int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - int forced_stop, - int iters_per_step, - int *mvjcost, int *mvcost[2], - int *distortion, - unsigned int *sse1, int is_second) { +int vp10_find_best_masked_sub_pixel_tree( + const MACROBLOCK *x, const uint8_t *mask, int mask_stride, MV *bestmv, + const MV *ref_mv, int allow_hp, int error_per_bit, + const vpx_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step, + int *mvjcost, int *mvcost[2], int *distortion, unsigned int *sse1, + int is_second) { const uint8_t *const z = x->plane[0].src.buf; const int src_stride = x->plane[0].src.stride; const MACROBLOCKD *xd = &x->e_mbd; @@ -2553,8 +2421,8 @@ int vp10_find_best_masked_sub_pixel_tree(const MACROBLOCK *x, bestmv->col *= 8; // calculate central point error - besterr = vfp->mvf(y + offset, y_stride, z, src_stride, mask, mask_stride, - sse1); + besterr = + vfp->mvf(y + offset, y_stride, z, src_stride, mask, mask_stride, sse1); *distortion = besterr; besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit); @@ -2588,8 +2456,8 @@ int vp10_find_best_masked_sub_pixel_tree(const MACROBLOCK *x, } // These lines insure static analysis doesn't warn that // tr and tc aren't used after the above point. - (void) tr; - (void) tc; + (void)tr; + (void)tc; bestmv->row = br; bestmv->col = bc; @@ -2601,31 +2469,22 @@ int vp10_find_best_masked_sub_pixel_tree(const MACROBLOCK *x, return besterr; } -static unsigned int setup_masked_center_error(const uint8_t *mask, - int mask_stride, - const MV *bestmv, - const MV *ref_mv, - int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - const uint8_t *const src, - const int src_stride, - const uint8_t *const y, - int y_stride, - int offset, - int *mvjcost, int *mvcost[2], - unsigned int *sse1, - int *distortion) { +static unsigned int setup_masked_center_error( + const uint8_t *mask, int mask_stride, const MV *bestmv, const MV *ref_mv, + int error_per_bit, const vpx_variance_fn_ptr_t *vfp, + const uint8_t *const src, const int src_stride, const uint8_t *const y, + int y_stride, int offset, int *mvjcost, int *mvcost[2], unsigned int *sse1, + int *distortion) { unsigned int besterr; - besterr = vfp->mvf(y + offset, y_stride, src, src_stride, - mask, mask_stride, sse1); + besterr = + vfp->mvf(y + offset, y_stride, src, src_stride, mask, mask_stride, sse1); *distortion = besterr; besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit); return besterr; } static int upsampled_masked_pref_error(const MACROBLOCKD *xd, - const uint8_t *mask, - int mask_stride, + const uint8_t *mask, int mask_stride, const vpx_variance_fn_ptr_t *vfp, const uint8_t *const src, const int src_stride, @@ -2637,18 +2496,17 @@ static int upsampled_masked_pref_error(const MACROBLOCKD *xd, DECLARE_ALIGNED(16, uint16_t, pred16[MAX_SB_SQUARE]); vpx_highbd_upsampled_pred(pred16, w, h, y, y_stride); - besterr = vfp->mvf(CONVERT_TO_BYTEPTR(pred16), w, src, src_stride, - mask, mask_stride, sse); + besterr = vfp->mvf(CONVERT_TO_BYTEPTR(pred16), w, src, src_stride, mask, + mask_stride, sse); } else { DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]); #else - DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]); - (void) xd; + DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]); + (void)xd; #endif // CONFIG_VP9_HIGHBITDEPTH vpx_upsampled_pred(pred, w, h, y, y_stride); - besterr = vfp->mvf(pred, w, src, src_stride, - mask, mask_stride, sse); + besterr = vfp->mvf(pred, w, src, src_stride, mask, mask_stride, sse); #if CONFIG_VP9_HIGHBITDEPTH } #endif @@ -2656,38 +2514,26 @@ static int upsampled_masked_pref_error(const MACROBLOCKD *xd, } static unsigned int upsampled_setup_masked_center_error( - const MACROBLOCKD *xd, - const uint8_t *mask, int mask_stride, - const MV *bestmv, const MV *ref_mv, - int error_per_bit, const vpx_variance_fn_ptr_t *vfp, - const uint8_t *const src, const int src_stride, - const uint8_t *const y, int y_stride, - int w, int h, int offset, int *mvjcost, int *mvcost[2], - unsigned int *sse1, int *distortion) { - unsigned int besterr = upsampled_masked_pref_error( - xd, mask, mask_stride, vfp, src, src_stride, - y + offset, y_stride, w, h, sse1); + const MACROBLOCKD *xd, const uint8_t *mask, int mask_stride, + const MV *bestmv, const MV *ref_mv, int error_per_bit, + const vpx_variance_fn_ptr_t *vfp, const uint8_t *const src, + const int src_stride, const uint8_t *const y, int y_stride, int w, int h, + int offset, int *mvjcost, int *mvcost[2], unsigned int *sse1, + int *distortion) { + unsigned int besterr = + upsampled_masked_pref_error(xd, mask, mask_stride, vfp, src, src_stride, + y + offset, y_stride, w, h, sse1); *distortion = besterr; besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit); return besterr; } -int vp10_find_best_masked_sub_pixel_tree_up(VP10_COMP *cpi, - MACROBLOCK *x, - const uint8_t *mask, - int mask_stride, - int mi_row, int mi_col, - MV *bestmv, const MV *ref_mv, - int allow_hp, - int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - int forced_stop, - int iters_per_step, - int *mvjcost, int *mvcost[2], - int *distortion, - unsigned int *sse1, - int is_second, - int use_upsampled_ref) { +int vp10_find_best_masked_sub_pixel_tree_up( + VP10_COMP *cpi, MACROBLOCK *x, const uint8_t *mask, int mask_stride, + int mi_row, int mi_col, MV *bestmv, const MV *ref_mv, int allow_hp, + int error_per_bit, const vpx_variance_fn_ptr_t *vfp, int forced_stop, + int iters_per_step, int *mvjcost, int *mvcost[2], int *distortion, + unsigned int *sse1, int is_second, int use_upsampled_ref) { const uint8_t *const z = x->plane[0].src.buf; const uint8_t *const src_address = z; const int src_stride = x->plane[0].src.stride; @@ -2735,8 +2581,7 @@ int vp10_find_best_masked_sub_pixel_tree_up(VP10_COMP *cpi, offset = bestmv->row * y_stride + bestmv->col; if (!(allow_hp && vp10_use_mv_hp(ref_mv))) - if (round == 3) - round = 2; + if (round == 3) round = 2; bestmv->row *= 8; bestmv->col *= 8; @@ -2744,15 +2589,13 @@ int vp10_find_best_masked_sub_pixel_tree_up(VP10_COMP *cpi, // use_upsampled_ref can be 0 or 1 if (use_upsampled_ref) besterr = upsampled_setup_masked_center_error( - xd, mask, mask_stride, bestmv, ref_mv, error_per_bit, - vfp, z, src_stride, y, y_stride, - w, h, (offset << 3), - mvjcost, mvcost, sse1, distortion); + xd, mask, mask_stride, bestmv, ref_mv, error_per_bit, vfp, z, + src_stride, y, y_stride, w, h, (offset << 3), mvjcost, mvcost, sse1, + distortion); else besterr = setup_masked_center_error( - mask, mask_stride, bestmv, ref_mv, error_per_bit, - vfp, z, src_stride, y, y_stride, - offset, mvjcost, mvcost, sse1, distortion); + mask, mask_stride, bestmv, ref_mv, error_per_bit, vfp, z, src_stride, y, + y_stride, offset, mvjcost, mvcost, sse1, distortion); for (iter = 0; iter < round; ++iter) { // Check vertical and horizontal sub-pixel positions. @@ -2760,26 +2603,23 @@ int vp10_find_best_masked_sub_pixel_tree_up(VP10_COMP *cpi, tr = br + search_step[idx].row; tc = bc + search_step[idx].col; if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) { - MV this_mv = {tr, tc}; + MV this_mv = { tr, tc }; if (use_upsampled_ref) { const uint8_t *const pre_address = y + tr * y_stride + tc; - thismse = upsampled_masked_pref_error(xd, - mask, mask_stride, - vfp, src_address, src_stride, - pre_address, y_stride, - w, h, &sse); + thismse = upsampled_masked_pref_error( + xd, mask, mask_stride, vfp, src_address, src_stride, pre_address, + y_stride, w, h, &sse); } else { - const uint8_t *const pre_address = y + (tr >> 3) * y_stride + - (tc >> 3); + const uint8_t *const pre_address = + y + (tr >> 3) * y_stride + (tc >> 3); thismse = vfp->msvf(pre_address, y_stride, sp(tc), sp(tr), - src_address, src_stride, - mask, mask_stride, &sse); + src_address, src_stride, mask, mask_stride, &sse); } - cost_array[idx] = thismse + - mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); + cost_array[idx] = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, + mvcost, error_per_bit); if (cost_array[idx] < besterr) { best_idx = idx; @@ -2799,25 +2639,23 @@ int vp10_find_best_masked_sub_pixel_tree_up(VP10_COMP *cpi, tc = bc + kc; tr = br + kr; if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) { - MV this_mv = {tr, tc}; + MV this_mv = { tr, tc }; if (use_upsampled_ref) { const uint8_t *const pre_address = y + tr * y_stride + tc; - thismse = upsampled_masked_pref_error(xd, - mask, mask_stride, - vfp, src_address, src_stride, - pre_address, y_stride, - w, h, &sse); + thismse = upsampled_masked_pref_error( + xd, mask, mask_stride, vfp, src_address, src_stride, pre_address, + y_stride, w, h, &sse); } else { const uint8_t *const pre_address = y + (tr >> 3) * y_stride + (tc >> 3); - thismse = vfp->msvf(pre_address, y_stride, sp(tc), sp(tr), - src_address, src_stride, mask, mask_stride, &sse); + thismse = vfp->msvf(pre_address, y_stride, sp(tc), sp(tr), src_address, + src_stride, mask, mask_stride, &sse); } - cost_array[4] = thismse + - mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); + cost_array[4] = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, + error_per_bit); if (cost_array[4] < besterr) { best_idx = 4; @@ -2855,8 +2693,8 @@ int vp10_find_best_masked_sub_pixel_tree_up(VP10_COMP *cpi, // These lines insure static analysis doesn't warn that // tr and tc aren't used after the above point. - (void) tr; - (void) tc; + (void)tr; + (void)tc; bestmv->row = br; bestmv->col = bc; @@ -2876,38 +2714,37 @@ int vp10_find_best_masked_sub_pixel_tree_up(VP10_COMP *cpi, #undef MVC #undef CHECK_BETTER -static int get_masked_mvpred_var(const MACROBLOCK *x, - const uint8_t *mask, int mask_stride, - const MV *best_mv, const MV *center_mv, +static int get_masked_mvpred_var(const MACROBLOCK *x, const uint8_t *mask, + int mask_stride, const MV *best_mv, + const MV *center_mv, const vpx_variance_fn_ptr_t *vfp, int use_mvcost, int is_second) { const MACROBLOCKD *const xd = &x->e_mbd; const struct buf_2d *const what = &x->plane[0].src; const struct buf_2d *const in_what = &xd->plane[0].pre[is_second]; - const MV mv = {best_mv->row * 8, best_mv->col * 8}; + const MV mv = { best_mv->row * 8, best_mv->col * 8 }; unsigned int unused; - return vfp->mvf(what->buf, what->stride, - get_buf_from_mv(in_what, best_mv), in_what->stride, - mask, mask_stride, &unused) + - (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, - x->mvcost, x->errorperbit) : 0); + return vfp->mvf(what->buf, what->stride, get_buf_from_mv(in_what, best_mv), + in_what->stride, mask, mask_stride, &unused) + + (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, x->mvcost, + x->errorperbit) + : 0); } -int masked_refining_search_sad(const MACROBLOCK *x, - const uint8_t *mask, int mask_stride, - MV *ref_mv, int error_per_bit, +int masked_refining_search_sad(const MACROBLOCK *x, const uint8_t *mask, + int mask_stride, MV *ref_mv, int error_per_bit, int search_range, const vpx_variance_fn_ptr_t *fn_ptr, const MV *center_mv, int is_second) { - const MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; + const MV neighbors[4] = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } }; const MACROBLOCKD *const xd = &x->e_mbd; const struct buf_2d *const what = &x->plane[0].src; const struct buf_2d *const in_what = &xd->plane[0].pre[is_second]; - const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; - unsigned int best_sad = fn_ptr->msdf(what->buf, what->stride, - get_buf_from_mv(in_what, ref_mv), - in_what->stride, mask, mask_stride) + + const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 }; + unsigned int best_sad = + fn_ptr->msdf(what->buf, what->stride, get_buf_from_mv(in_what, ref_mv), + in_what->stride, mask, mask_stride) + mvsad_err_cost(x, ref_mv, &fcenter_mv, error_per_bit); int i, j; @@ -2915,11 +2752,12 @@ int masked_refining_search_sad(const MACROBLOCK *x, int best_site = -1; for (j = 0; j < 4; j++) { - const MV mv = {ref_mv->row + neighbors[j].row, - ref_mv->col + neighbors[j].col}; + const MV mv = { ref_mv->row + neighbors[j].row, + ref_mv->col + neighbors[j].col }; if (is_mv_in(x, &mv)) { - unsigned int sad = fn_ptr->msdf(what->buf, what->stride, - get_buf_from_mv(in_what, &mv), in_what->stride, mask, mask_stride); + unsigned int sad = + fn_ptr->msdf(what->buf, what->stride, get_buf_from_mv(in_what, &mv), + in_what->stride, mask, mask_stride); if (sad < best_sad) { sad += mvsad_err_cost(x, &mv, &fcenter_mv, error_per_bit); if (sad < best_sad) { @@ -2942,11 +2780,9 @@ int masked_refining_search_sad(const MACROBLOCK *x, int masked_diamond_search_sad(const MACROBLOCK *x, const search_site_config *cfg, - const uint8_t *mask, int mask_stride, - MV *ref_mv, MV *best_mv, - int search_param, - int sad_per_bit, int *num00, - const vpx_variance_fn_ptr_t *fn_ptr, + const uint8_t *mask, int mask_stride, MV *ref_mv, + MV *best_mv, int search_param, int sad_per_bit, + int *num00, const vpx_variance_fn_ptr_t *fn_ptr, const MV *center_mv, int is_second) { const MACROBLOCKD *const xd = &x->e_mbd; const struct buf_2d *const what = &x->plane[0].src; @@ -2957,7 +2793,7 @@ int masked_diamond_search_sad(const MACROBLOCK *x, // (MAX_FIRST_STEP/4) pel... etc. const search_site *const ss = &cfg->ss[search_param * cfg->searches_per_step]; const int tot_steps = (cfg->ss_count / cfg->searches_per_step) - search_param; - const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; + const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 }; const uint8_t *best_address, *in_what_ref; int best_sad = INT_MAX; int best_site = 0; @@ -2971,21 +2807,20 @@ int masked_diamond_search_sad(const MACROBLOCK *x, *best_mv = *ref_mv; // Check the starting position - best_sad = fn_ptr->msdf(what->buf, what->stride, - best_address, in_what->stride, - mask, mask_stride) + - mvsad_err_cost(x, best_mv, &fcenter_mv, sad_per_bit); + best_sad = fn_ptr->msdf(what->buf, what->stride, best_address, + in_what->stride, mask, mask_stride) + + mvsad_err_cost(x, best_mv, &fcenter_mv, sad_per_bit); i = 1; for (step = 0; step < tot_steps; step++) { for (j = 0; j < cfg->searches_per_step; j++) { - const MV mv = {best_mv->row + ss[i].mv.row, - best_mv->col + ss[i].mv.col}; + const MV mv = { best_mv->row + ss[i].mv.row, + best_mv->col + ss[i].mv.col }; if (is_mv_in(x, &mv)) { - int sad = fn_ptr->msdf(what->buf, what->stride, - best_address + ss[i].offset, in_what->stride, - mask, mask_stride); + int sad = + fn_ptr->msdf(what->buf, what->stride, best_address + ss[i].offset, + in_what->stride, mask, mask_stride); if (sad < best_sad) { sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit); if (sad < best_sad) { @@ -3005,8 +2840,8 @@ int masked_diamond_search_sad(const MACROBLOCK *x, last_site = best_site; #if defined(NEW_DIAMOND_SEARCH) while (1) { - const MV this_mv = {best_mv->row + ss[best_site].mv.row, - best_mv->col + ss[best_site].mv.col}; + const MV this_mv = { best_mv->row + ss[best_site].mv.row, + best_mv->col + ss[best_site].mv.col }; if (is_mv_in(x, &this_mv)) { int sad = fn_ptr->msdf(what->buf, what->stride, best_address + ss[best_site].offset, @@ -3034,18 +2869,16 @@ int masked_diamond_search_sad(const MACROBLOCK *x, int vp10_masked_full_pixel_diamond(const VP10_COMP *cpi, MACROBLOCK *x, const uint8_t *mask, int mask_stride, - MV *mvp_full, int step_param, - int sadpb, int further_steps, int do_refine, + MV *mvp_full, int step_param, int sadpb, + int further_steps, int do_refine, const vpx_variance_fn_ptr_t *fn_ptr, const MV *ref_mv, MV *dst_mv, int is_second) { MV temp_mv; int thissme, n, num00 = 0; - int bestsme = masked_diamond_search_sad(x, &cpi->ss_cfg, - mask, mask_stride, - mvp_full, &temp_mv, - step_param, sadpb, &n, - fn_ptr, ref_mv, is_second); + int bestsme = masked_diamond_search_sad(x, &cpi->ss_cfg, mask, mask_stride, + mvp_full, &temp_mv, step_param, sadpb, + &n, fn_ptr, ref_mv, is_second); if (bestsme < INT_MAX) bestsme = get_masked_mvpred_var(x, mask, mask_stride, &temp_mv, ref_mv, fn_ptr, 1, is_second); @@ -3053,8 +2886,7 @@ int vp10_masked_full_pixel_diamond(const VP10_COMP *cpi, MACROBLOCK *x, // If there won't be more n-step search, check to see if refining search is // needed. - if (n > further_steps) - do_refine = 0; + if (n > further_steps) do_refine = 0; while (n < further_steps) { ++n; @@ -3062,19 +2894,15 @@ int vp10_masked_full_pixel_diamond(const VP10_COMP *cpi, MACROBLOCK *x, if (num00) { num00--; } else { - thissme = masked_diamond_search_sad(x, &cpi->ss_cfg, - mask, mask_stride, - mvp_full, &temp_mv, - step_param + n, sadpb, &num00, - fn_ptr, ref_mv, is_second); + thissme = masked_diamond_search_sad( + x, &cpi->ss_cfg, mask, mask_stride, mvp_full, &temp_mv, + step_param + n, sadpb, &num00, fn_ptr, ref_mv, is_second); if (thissme < INT_MAX) - thissme = get_masked_mvpred_var(x, mask, mask_stride, - &temp_mv, ref_mv, fn_ptr, 1, - is_second); + thissme = get_masked_mvpred_var(x, mask, mask_stride, &temp_mv, ref_mv, + fn_ptr, 1, is_second); // check to see if refining search is needed. - if (num00 > further_steps - n) - do_refine = 0; + if (num00 > further_steps - n) do_refine = 0; if (thissme < bestsme) { bestsme = thissme; @@ -3087,13 +2915,12 @@ int vp10_masked_full_pixel_diamond(const VP10_COMP *cpi, MACROBLOCK *x, if (do_refine) { const int search_range = 8; MV best_mv = *dst_mv; - thissme = masked_refining_search_sad(x, mask, mask_stride, - &best_mv, sadpb, search_range, - fn_ptr, ref_mv, is_second); + thissme = + masked_refining_search_sad(x, mask, mask_stride, &best_mv, sadpb, + search_range, fn_ptr, ref_mv, is_second); if (thissme < INT_MAX) - thissme = get_masked_mvpred_var(x, mask, mask_stride, - &best_mv, ref_mv, fn_ptr, 1, - is_second); + thissme = get_masked_mvpred_var(x, mask, mask_stride, &best_mv, ref_mv, + fn_ptr, 1, is_second); if (thissme < bestsme) { bestsme = thissme; *dst_mv = best_mv; @@ -3105,65 +2932,57 @@ int vp10_masked_full_pixel_diamond(const VP10_COMP *cpi, MACROBLOCK *x, #if CONFIG_OBMC /* returns subpixel variance error function */ -#define DIST(r, c) \ +#define DIST(r, c) \ vfp->osvf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), z, mask, &sse) /* checks if (r, c) has better score than previous best */ -#define MVC(r, c) \ - (mvcost ? \ - ((mvjcost[((r) != rr) * 2 + ((c) != rc)] + \ - mvcost[0][((r) - rr)] + mvcost[1][((c) - rc)]) * \ - error_per_bit + 4096) >> 13 : 0) +#define MVC(r, c) \ + (mvcost \ + ? ((mvjcost[((r) != rr) * 2 + ((c) != rc)] + mvcost[0][((r)-rr)] + \ + mvcost[1][((c)-rc)]) * \ + error_per_bit + \ + 4096) >> \ + 13 \ + : 0) -#define CHECK_BETTER(v, r, c) \ - if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ - thismse = (DIST(r, c)); \ - if ((v = MVC(r, c) + thismse) < besterr) { \ - besterr = v; \ - br = r; \ - bc = c; \ - *distortion = thismse; \ - *sse1 = sse; \ - } \ - } else { \ - v = INT_MAX; \ +#define CHECK_BETTER(v, r, c) \ + if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ + thismse = (DIST(r, c)); \ + if ((v = MVC(r, c) + thismse) < besterr) { \ + besterr = v; \ + br = r; \ + bc = c; \ + *distortion = thismse; \ + *sse1 = sse; \ + } \ + } else { \ + v = INT_MAX; \ } #undef CHECK_BETTER0 #define CHECK_BETTER0(v, r, c) CHECK_BETTER(v, r, c) #undef CHECK_BETTER1 -#define CHECK_BETTER1(v, r, c) \ - if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ - thismse = upsampled_obmc_pref_error(xd, \ - mask, \ - vfp, z, \ - upre(y, y_stride, r, c), \ - y_stride, \ - w, h, &sse); \ - if ((v = MVC(r, c) + thismse) < besterr) { \ - besterr = v; \ - br = r; \ - bc = c; \ - *distortion = thismse; \ - *sse1 = sse; \ - } \ - } else { \ - v = INT_MAX; \ +#define CHECK_BETTER1(v, r, c) \ + if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ + thismse = upsampled_obmc_pref_error( \ + xd, mask, vfp, z, upre(y, y_stride, r, c), y_stride, w, h, &sse); \ + if ((v = MVC(r, c) + thismse) < besterr) { \ + besterr = v; \ + br = r; \ + bc = c; \ + *distortion = thismse; \ + *sse1 = sse; \ + } \ + } else { \ + v = INT_MAX; \ } -static unsigned int setup_obmc_center_error(const int32_t *mask, - const MV *bestmv, - const MV *ref_mv, - int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - const int32_t *const wsrc, - const uint8_t *const y, - int y_stride, - int offset, - int *mvjcost, int *mvcost[2], - unsigned int *sse1, - int *distortion) { +static unsigned int setup_obmc_center_error( + const int32_t *mask, const MV *bestmv, const MV *ref_mv, int error_per_bit, + const vpx_variance_fn_ptr_t *vfp, const int32_t *const wsrc, + const uint8_t *const y, int y_stride, int offset, int *mvjcost, + int *mvcost[2], unsigned int *sse1, int *distortion) { unsigned int besterr; besterr = vfp->ovf(y + offset, y_stride, wsrc, mask, sse1); *distortion = besterr; @@ -3171,8 +2990,7 @@ static unsigned int setup_obmc_center_error(const int32_t *mask, return besterr; } -static int upsampled_obmc_pref_error(const MACROBLOCKD *xd, - const int32_t *mask, +static int upsampled_obmc_pref_error(const MACROBLOCKD *xd, const int32_t *mask, const vpx_variance_fn_ptr_t *vfp, const int32_t *const wsrc, const uint8_t *const y, int y_stride, @@ -3187,8 +3005,8 @@ static int upsampled_obmc_pref_error(const MACROBLOCKD *xd, } else { DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]); #else - DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]); - (void) xd; + DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]); + (void)xd; #endif // CONFIG_VP9_HIGHBITDEPTH vpx_upsampled_pred(pred, w, h, y, y_stride); @@ -3200,34 +3018,24 @@ static int upsampled_obmc_pref_error(const MACROBLOCKD *xd, } static unsigned int upsampled_setup_obmc_center_error( - const MACROBLOCKD *xd, - const int32_t *mask, - const MV *bestmv, const MV *ref_mv, - int error_per_bit, const vpx_variance_fn_ptr_t *vfp, - const int32_t *const wsrc, - const uint8_t *const y, int y_stride, - int w, int h, int offset, int *mvjcost, int *mvcost[2], - unsigned int *sse1, int *distortion) { - unsigned int besterr = upsampled_obmc_pref_error(xd, mask, vfp, wsrc, - y + offset, y_stride, - w, h, sse1); + const MACROBLOCKD *xd, const int32_t *mask, const MV *bestmv, + const MV *ref_mv, int error_per_bit, const vpx_variance_fn_ptr_t *vfp, + const int32_t *const wsrc, const uint8_t *const y, int y_stride, int w, + int h, int offset, int *mvjcost, int *mvcost[2], unsigned int *sse1, + int *distortion) { + unsigned int besterr = upsampled_obmc_pref_error( + xd, mask, vfp, wsrc, y + offset, y_stride, w, h, sse1); *distortion = besterr; besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit); return besterr; } -int vp10_find_best_obmc_sub_pixel_tree_up(VP10_COMP *cpi, MACROBLOCK *x, - const int32_t *wsrc, - const int32_t *mask, - int mi_row, int mi_col, - MV *bestmv, const MV *ref_mv, - int allow_hp, int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - int forced_stop, int iters_per_step, - int *mvjcost, int *mvcost[2], - int *distortion, unsigned int *sse1, - int is_second, - int use_upsampled_ref) { +int vp10_find_best_obmc_sub_pixel_tree_up( + VP10_COMP *cpi, MACROBLOCK *x, const int32_t *wsrc, const int32_t *mask, + int mi_row, int mi_col, MV *bestmv, const MV *ref_mv, int allow_hp, + int error_per_bit, const vpx_variance_fn_ptr_t *vfp, int forced_stop, + int iters_per_step, int *mvjcost, int *mvcost[2], int *distortion, + unsigned int *sse1, int is_second, int use_upsampled_ref) { const int *const z = wsrc; const int *const src_address = z; MACROBLOCKD *xd = &x->e_mbd; @@ -3274,23 +3082,19 @@ int vp10_find_best_obmc_sub_pixel_tree_up(VP10_COMP *cpi, MACROBLOCK *x, offset = bestmv->row * y_stride + bestmv->col; if (!(allow_hp && vp10_use_mv_hp(ref_mv))) - if (round == 3) - round = 2; + if (round == 3) round = 2; bestmv->row *= 8; bestmv->col *= 8; // use_upsampled_ref can be 0 or 1 if (use_upsampled_ref) besterr = upsampled_setup_obmc_center_error( - xd, mask, bestmv, ref_mv, error_per_bit, - vfp, z, y, y_stride, - w, h, (offset << 3), - mvjcost, mvcost, sse1, distortion); + xd, mask, bestmv, ref_mv, error_per_bit, vfp, z, y, y_stride, w, h, + (offset << 3), mvjcost, mvcost, sse1, distortion); else - besterr = setup_obmc_center_error( - mask, bestmv, ref_mv, error_per_bit, - vfp, z, y, y_stride, - offset, mvjcost, mvcost, sse1, distortion); + besterr = setup_obmc_center_error(mask, bestmv, ref_mv, error_per_bit, vfp, + z, y, y_stride, offset, mvjcost, mvcost, + sse1, distortion); for (iter = 0; iter < round; ++iter) { // Check vertical and horizontal sub-pixel positions. @@ -3298,24 +3102,22 @@ int vp10_find_best_obmc_sub_pixel_tree_up(VP10_COMP *cpi, MACROBLOCK *x, tr = br + search_step[idx].row; tc = bc + search_step[idx].col; if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) { - MV this_mv = {tr, tc}; + MV this_mv = { tr, tc }; if (use_upsampled_ref) { const uint8_t *const pre_address = y + tr * y_stride + tc; - thismse = upsampled_obmc_pref_error(xd, mask, - vfp, src_address, - pre_address, y_stride, - w, h, &sse); + thismse = upsampled_obmc_pref_error( + xd, mask, vfp, src_address, pre_address, y_stride, w, h, &sse); } else { - const uint8_t *const pre_address = y + (tr >> 3) * y_stride + - (tc >> 3); + const uint8_t *const pre_address = + y + (tr >> 3) * y_stride + (tc >> 3); thismse = vfp->osvf(pre_address, y_stride, sp(tc), sp(tr), src_address, mask, &sse); } - cost_array[idx] = thismse + - mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); + cost_array[idx] = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, + mvcost, error_per_bit); if (cost_array[idx] < besterr) { best_idx = idx; besterr = cost_array[idx]; @@ -3334,23 +3136,22 @@ int vp10_find_best_obmc_sub_pixel_tree_up(VP10_COMP *cpi, MACROBLOCK *x, tc = bc + kc; tr = br + kr; if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) { - MV this_mv = {tr, tc}; + MV this_mv = { tr, tc }; if (use_upsampled_ref) { const uint8_t *const pre_address = y + tr * y_stride + tc; thismse = upsampled_obmc_pref_error(xd, mask, vfp, src_address, - pre_address, y_stride, - w, h, &sse); + pre_address, y_stride, w, h, &sse); } else { const uint8_t *const pre_address = y + (tr >> 3) * y_stride + (tc >> 3); - thismse = vfp->osvf(pre_address, y_stride, sp(tc), sp(tr), - src_address, mask, &sse); + thismse = vfp->osvf(pre_address, y_stride, sp(tc), sp(tr), src_address, + mask, &sse); } - cost_array[4] = thismse + - mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); + cost_array[4] = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, + error_per_bit); if (cost_array[4] < besterr) { best_idx = 4; @@ -3388,8 +3189,8 @@ int vp10_find_best_obmc_sub_pixel_tree_up(VP10_COMP *cpi, MACROBLOCK *x, // These lines insure static analysis doesn't warn that // tr and tc aren't used after the above point. - (void) tr; - (void) tc; + (void)tr; + (void)tc; bestmv->row = br; bestmv->col = bc; @@ -3409,45 +3210,43 @@ int vp10_find_best_obmc_sub_pixel_tree_up(VP10_COMP *cpi, MACROBLOCK *x, #undef MVC #undef CHECK_BETTER -static int get_obmc_mvpred_var(const MACROBLOCK *x, - const int32_t *wsrc, - const int32_t *mask, - const MV *best_mv, const MV *center_mv, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost, int is_second) { +static int get_obmc_mvpred_var(const MACROBLOCK *x, const int32_t *wsrc, + const int32_t *mask, const MV *best_mv, + const MV *center_mv, + const vpx_variance_fn_ptr_t *vfp, int use_mvcost, + int is_second) { const MACROBLOCKD *const xd = &x->e_mbd; const struct buf_2d *const in_what = &xd->plane[0].pre[is_second]; - const MV mv = {best_mv->row * 8, best_mv->col * 8}; + const MV mv = { best_mv->row * 8, best_mv->col * 8 }; unsigned int unused; - return vfp->ovf(get_buf_from_mv(in_what, best_mv), in_what->stride, - wsrc, mask, &unused) + - (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, - x->mvcost, x->errorperbit) : 0); + return vfp->ovf(get_buf_from_mv(in_what, best_mv), in_what->stride, wsrc, + mask, &unused) + + (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, x->mvcost, + x->errorperbit) + : 0); } -int obmc_refining_search_sad(const MACROBLOCK *x, - const int32_t *wsrc, - const int32_t *mask, - MV *ref_mv, int error_per_bit, +int obmc_refining_search_sad(const MACROBLOCK *x, const int32_t *wsrc, + const int32_t *mask, MV *ref_mv, int error_per_bit, int search_range, const vpx_variance_fn_ptr_t *fn_ptr, const MV *center_mv, int is_second) { - const MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; + const MV neighbors[4] = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } }; const MACROBLOCKD *const xd = &x->e_mbd; const struct buf_2d *const in_what = &xd->plane[0].pre[is_second]; - const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; + const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 }; unsigned int best_sad = fn_ptr->osdf(get_buf_from_mv(in_what, ref_mv), in_what->stride, wsrc, mask) + - mvsad_err_cost(x, ref_mv, &fcenter_mv, error_per_bit); + mvsad_err_cost(x, ref_mv, &fcenter_mv, error_per_bit); int i, j; for (i = 0; i < search_range; i++) { int best_site = -1; for (j = 0; j < 4; j++) { - const MV mv = {ref_mv->row + neighbors[j].row, - ref_mv->col + neighbors[j].col}; + const MV mv = { ref_mv->row + neighbors[j].row, + ref_mv->col + neighbors[j].col }; if (is_mv_in(x, &mv)) { unsigned int sad = fn_ptr->osdf(get_buf_from_mv(in_what, &mv), in_what->stride, wsrc, mask); @@ -3471,11 +3270,9 @@ int obmc_refining_search_sad(const MACROBLOCK *x, return best_sad; } -int obmc_diamond_search_sad(const MACROBLOCK *x, - const search_site_config *cfg, +int obmc_diamond_search_sad(const MACROBLOCK *x, const search_site_config *cfg, const int32_t *wsrc, const int32_t *mask, - MV *ref_mv, MV *best_mv, - int search_param, + MV *ref_mv, MV *best_mv, int search_param, int sad_per_bit, int *num00, const vpx_variance_fn_ptr_t *fn_ptr, const MV *center_mv, int is_second) { @@ -3487,7 +3284,7 @@ int obmc_diamond_search_sad(const MACROBLOCK *x, // (MAX_FIRST_STEP/4) pel... etc. const search_site *const ss = &cfg->ss[search_param * cfg->searches_per_step]; const int tot_steps = (cfg->ss_count / cfg->searches_per_step) - search_param; - const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; + const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 }; const uint8_t *best_address, *in_what_ref; int best_sad = INT_MAX; int best_site = 0; @@ -3508,11 +3305,11 @@ int obmc_diamond_search_sad(const MACROBLOCK *x, for (step = 0; step < tot_steps; step++) { for (j = 0; j < cfg->searches_per_step; j++) { - const MV mv = {best_mv->row + ss[i].mv.row, - best_mv->col + ss[i].mv.col}; + const MV mv = { best_mv->row + ss[i].mv.row, + best_mv->col + ss[i].mv.col }; if (is_mv_in(x, &mv)) { - int sad = fn_ptr->osdf(best_address + ss[i].offset, in_what->stride, - wsrc, mask); + int sad = fn_ptr->osdf(best_address + ss[i].offset, in_what->stride, + wsrc, mask); if (sad < best_sad) { sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit); if (sad < best_sad) { @@ -3532,8 +3329,8 @@ int obmc_diamond_search_sad(const MACROBLOCK *x, last_site = best_site; #if defined(NEW_DIAMOND_SEARCH) while (1) { - const MV this_mv = {best_mv->row + ss[best_site].mv.row, - best_mv->col + ss[best_site].mv.col}; + const MV this_mv = { best_mv->row + ss[best_site].mv.row, + best_mv->col + ss[best_site].mv.col }; if (is_mv_in(x, &this_mv)) { int sad = fn_ptr->osdf(best_address + ss[best_site].offset, in_what->stride, wsrc, mask); @@ -3560,27 +3357,23 @@ int obmc_diamond_search_sad(const MACROBLOCK *x, int vp10_obmc_full_pixel_diamond(const VP10_COMP *cpi, MACROBLOCK *x, const int32_t *wsrc, const int32_t *mask, - MV *mvp_full, int step_param, - int sadpb, int further_steps, int do_refine, + MV *mvp_full, int step_param, int sadpb, + int further_steps, int do_refine, const vpx_variance_fn_ptr_t *fn_ptr, - const MV *ref_mv, MV *dst_mv, - int is_second) { + const MV *ref_mv, MV *dst_mv, int is_second) { MV temp_mv; int thissme, n, num00 = 0; - int bestsme = obmc_diamond_search_sad(x, &cpi->ss_cfg, - wsrc, mask, - mvp_full, &temp_mv, - step_param, sadpb, &n, - fn_ptr, ref_mv, is_second); + int bestsme = + obmc_diamond_search_sad(x, &cpi->ss_cfg, wsrc, mask, mvp_full, &temp_mv, + step_param, sadpb, &n, fn_ptr, ref_mv, is_second); if (bestsme < INT_MAX) - bestsme = get_obmc_mvpred_var(x, wsrc, mask, - &temp_mv, ref_mv, fn_ptr, 1, is_second); + bestsme = get_obmc_mvpred_var(x, wsrc, mask, &temp_mv, ref_mv, fn_ptr, 1, + is_second); *dst_mv = temp_mv; // If there won't be more n-step search, check to see if refining search is // needed. - if (n > further_steps) - do_refine = 0; + if (n > further_steps) do_refine = 0; while (n < further_steps) { ++n; @@ -3588,18 +3381,15 @@ int vp10_obmc_full_pixel_diamond(const VP10_COMP *cpi, MACROBLOCK *x, if (num00) { num00--; } else { - thissme = obmc_diamond_search_sad(x, &cpi->ss_cfg, - wsrc, mask, - mvp_full, &temp_mv, - step_param + n, sadpb, &num00, + thissme = obmc_diamond_search_sad(x, &cpi->ss_cfg, wsrc, mask, mvp_full, + &temp_mv, step_param + n, sadpb, &num00, fn_ptr, ref_mv, is_second); if (thissme < INT_MAX) - thissme = get_obmc_mvpred_var(x, wsrc, mask, - &temp_mv, ref_mv, fn_ptr, 1, is_second); + thissme = get_obmc_mvpred_var(x, wsrc, mask, &temp_mv, ref_mv, fn_ptr, + 1, is_second); // check to see if refining search is needed. - if (num00 > further_steps - n) - do_refine = 0; + if (num00 > further_steps - n) do_refine = 0; if (thissme < bestsme) { bestsme = thissme; @@ -3612,12 +3402,11 @@ int vp10_obmc_full_pixel_diamond(const VP10_COMP *cpi, MACROBLOCK *x, if (do_refine) { const int search_range = 8; MV best_mv = *dst_mv; - thissme = obmc_refining_search_sad(x, wsrc, mask, - &best_mv, sadpb, search_range, - fn_ptr, ref_mv, is_second); + thissme = obmc_refining_search_sad(x, wsrc, mask, &best_mv, sadpb, + search_range, fn_ptr, ref_mv, is_second); if (thissme < INT_MAX) - thissme = get_obmc_mvpred_var(x, wsrc, mask, - &best_mv, ref_mv, fn_ptr, 1, is_second); + thissme = get_obmc_mvpred_var(x, wsrc, mask, &best_mv, ref_mv, fn_ptr, 1, + is_second); if (thissme < bestsme) { bestsme = thissme; *dst_mv = best_mv; diff --git a/vp10/encoder/mcomp.h b/vp10/encoder/mcomp.h index c2e906a52..0af81f510 100644 --- a/vp10/encoder/mcomp.h +++ b/vp10/encoder/mcomp.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_MCOMP_H_ #define VP10_ENCODER_MCOMP_H_ @@ -26,7 +25,7 @@ extern "C" { // Enable the use of motion vector in range [-1023, 1023]. #define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS - 1)) - 1) // Maximum size of the first step in full pel units -#define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1)) +#define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS - 1)) // Allowed motion vector pixel distance outside image border // for Block_16x16 #define BORDER_MV_PIXELS_B16 (16 + VPX_INTERP_EXTEND) @@ -44,94 +43,71 @@ typedef struct search_site_config { } search_site_config; void vp10_init_dsmotion_compensation(search_site_config *cfg, int stride); -void vp10_init3smotion_compensation(search_site_config *cfg, int stride); +void vp10_init3smotion_compensation(search_site_config *cfg, int stride); void vp10_set_mv_search_range(MACROBLOCK *x, const MV *mv); -int vp10_mv_bit_cost(const MV *mv, const MV *ref, - const int *mvjcost, int *mvcost[2], int weight); +int vp10_mv_bit_cost(const MV *mv, const MV *ref, const int *mvjcost, + int *mvcost[2], int weight); // Utility to compute variance + MV rate cost for a given MV -int vp10_get_mvpred_var(const MACROBLOCK *x, - const MV *best_mv, const MV *center_mv, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost); -int vp10_get_mvpred_av_var(const MACROBLOCK *x, - const MV *best_mv, const MV *center_mv, - const uint8_t *second_pred, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost); +int vp10_get_mvpred_var(const MACROBLOCK *x, const MV *best_mv, + const MV *center_mv, const vpx_variance_fn_ptr_t *vfp, + int use_mvcost); +int vp10_get_mvpred_av_var(const MACROBLOCK *x, const MV *best_mv, + const MV *center_mv, const uint8_t *second_pred, + const vpx_variance_fn_ptr_t *vfp, int use_mvcost); struct VP10_COMP; struct SPEED_FEATURES; int vp10_init_search_range(int size); -int vp10_refining_search_sad(struct macroblock *x, - struct mv *ref_mv, +int vp10_refining_search_sad(struct macroblock *x, struct mv *ref_mv, int sad_per_bit, int distance, const vpx_variance_fn_ptr_t *fn_ptr, const struct mv *center_mv); // Runs sequence of diamond searches in smaller steps for RD. int vp10_full_pixel_diamond(const struct VP10_COMP *cpi, MACROBLOCK *x, - MV *mvp_full, int step_param, - int sadpb, int further_steps, int do_refine, - int *cost_list, - const vpx_variance_fn_ptr_t *fn_ptr, - const MV *ref_mv, MV *dst_mv); + MV *mvp_full, int step_param, int sadpb, + int further_steps, int do_refine, int *cost_list, + const vpx_variance_fn_ptr_t *fn_ptr, + const MV *ref_mv, MV *dst_mv); // Perform integral projection based motion estimation. unsigned int vp10_int_pro_motion_estimation(const struct VP10_COMP *cpi, - MACROBLOCK *x, - BLOCK_SIZE bsize, + MACROBLOCK *x, BLOCK_SIZE bsize, int mi_row, int mi_col); - -int vp10_hex_search(MACROBLOCK *x, - MV *start_mv, - int search_param, - int sad_per_bit, - int do_init_search, - int *cost_list, - const vpx_variance_fn_ptr_t *vfp, - int use_mvcost, +int vp10_hex_search(MACROBLOCK *x, MV *start_mv, int search_param, + int sad_per_bit, int do_init_search, int *cost_list, + const vpx_variance_fn_ptr_t *vfp, int use_mvcost, const MV *center_mv); -typedef int (fractional_mv_step_fp) ( - MACROBLOCK *x, - const MV *ref_mv, - int allow_hp, - int error_per_bit, +typedef int(fractional_mv_step_fp)( + MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit, const vpx_variance_fn_ptr_t *vfp, int forced_stop, // 0 - full, 1 - qtr only, 2 - half only - int iters_per_step, - int *cost_list, - int *mvjcost, int *mvcost[2], - int *distortion, unsigned int *sse1, - const uint8_t *second_pred, - int w, int h, int use_upsampled_ref); + int iters_per_step, int *cost_list, int *mvjcost, int *mvcost[2], + int *distortion, unsigned int *sse1, const uint8_t *second_pred, int w, + int h, int use_upsampled_ref); extern fractional_mv_step_fp vp10_find_best_sub_pixel_tree; extern fractional_mv_step_fp vp10_find_best_sub_pixel_tree_pruned; extern fractional_mv_step_fp vp10_find_best_sub_pixel_tree_pruned_more; extern fractional_mv_step_fp vp10_find_best_sub_pixel_tree_pruned_evenmore; -typedef int (*vp10_full_search_fn_t)(const MACROBLOCK *x, - const MV *ref_mv, int sad_per_bit, - int distance, +typedef int (*vp10_full_search_fn_t)(const MACROBLOCK *x, const MV *ref_mv, + int sad_per_bit, int distance, const vpx_variance_fn_ptr_t *fn_ptr, const MV *center_mv, MV *best_mv); -typedef int (*vp10_diamond_search_fn_t)(MACROBLOCK *x, - const search_site_config *cfg, - MV *ref_mv, MV *best_mv, - int search_param, int sad_per_bit, - int *num00, - const vpx_variance_fn_ptr_t *fn_ptr, - const MV *center_mv); +typedef int (*vp10_diamond_search_fn_t)( + MACROBLOCK *x, const search_site_config *cfg, MV *ref_mv, MV *best_mv, + int search_param, int sad_per_bit, int *num00, + const vpx_variance_fn_ptr_t *fn_ptr, const MV *center_mv); -int vp10_refining_search_8p_c(MACROBLOCK *x, - int error_per_bit, +int vp10_refining_search_8p_c(MACROBLOCK *x, int error_per_bit, int search_range, const vpx_variance_fn_ptr_t *fn_ptr, const MV *center_mv, const uint8_t *second_pred); @@ -139,70 +115,44 @@ int vp10_refining_search_8p_c(MACROBLOCK *x, struct VP10_COMP; int vp10_full_pixel_search(struct VP10_COMP *cpi, MACROBLOCK *x, - BLOCK_SIZE bsize, MV *mvp_full, - int step_param, int error_per_bit, - int *cost_list, const MV *ref_mv, + BLOCK_SIZE bsize, MV *mvp_full, int step_param, + int error_per_bit, int *cost_list, const MV *ref_mv, int var_max, int rd); #if CONFIG_EXT_INTER -int vp10_find_best_masked_sub_pixel_tree(const MACROBLOCK *x, - const uint8_t *mask, int mask_stride, - MV *bestmv, const MV *ref_mv, - int allow_hp, - int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - int forced_stop, - int iters_per_step, - int *mvjcost, int *mvcost[2], - int *distortion, - unsigned int *sse1, - int is_second); -int vp10_find_best_masked_sub_pixel_tree_up(struct VP10_COMP *cpi, - MACROBLOCK *x, - const uint8_t *mask, - int mask_stride, - int mi_row, int mi_col, - MV *bestmv, const MV *ref_mv, - int allow_hp, - int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - int forced_stop, - int iters_per_step, - int *mvjcost, int *mvcost[2], - int *distortion, - unsigned int *sse1, - int is_second, - int use_upsampled_ref); +int vp10_find_best_masked_sub_pixel_tree( + const MACROBLOCK *x, const uint8_t *mask, int mask_stride, MV *bestmv, + const MV *ref_mv, int allow_hp, int error_per_bit, + const vpx_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step, + int *mvjcost, int *mvcost[2], int *distortion, unsigned int *sse1, + int is_second); +int vp10_find_best_masked_sub_pixel_tree_up( + struct VP10_COMP *cpi, MACROBLOCK *x, const uint8_t *mask, int mask_stride, + int mi_row, int mi_col, MV *bestmv, const MV *ref_mv, int allow_hp, + int error_per_bit, const vpx_variance_fn_ptr_t *vfp, int forced_stop, + int iters_per_step, int *mvjcost, int *mvcost[2], int *distortion, + unsigned int *sse1, int is_second, int use_upsampled_ref); int vp10_masked_full_pixel_diamond(const struct VP10_COMP *cpi, MACROBLOCK *x, const uint8_t *mask, int mask_stride, - MV *mvp_full, int step_param, - int sadpb, int further_steps, int do_refine, + MV *mvp_full, int step_param, int sadpb, + int further_steps, int do_refine, const vpx_variance_fn_ptr_t *fn_ptr, - const MV *ref_mv, MV *dst_mv, - int is_second); + const MV *ref_mv, MV *dst_mv, int is_second); #endif // CONFIG_EXT_INTER #if CONFIG_OBMC int vp10_obmc_full_pixel_diamond(const struct VP10_COMP *cpi, MACROBLOCK *x, - const int32_t *wsrc, - const int32_t *mask, - MV *mvp_full, int step_param, - int sadpb, int further_steps, int do_refine, + const int32_t *wsrc, const int32_t *mask, + MV *mvp_full, int step_param, int sadpb, + int further_steps, int do_refine, const vpx_variance_fn_ptr_t *fn_ptr, - const MV *ref_mv, MV *dst_mv, - int is_second); -int vp10_find_best_obmc_sub_pixel_tree_up(struct VP10_COMP *cpi, MACROBLOCK *x, - const int32_t *wsrc, - const int32_t *mask, - int mi_row, int mi_col, - MV *bestmv, const MV *ref_mv, - int allow_hp, int error_per_bit, - const vpx_variance_fn_ptr_t *vfp, - int forced_stop, int iters_per_step, - int *mvjcost, int *mvcost[2], - int *distortion, unsigned int *sse1, - int is_second, - int use_upsampled_ref); + const MV *ref_mv, MV *dst_mv, int is_second); +int vp10_find_best_obmc_sub_pixel_tree_up( + struct VP10_COMP *cpi, MACROBLOCK *x, const int32_t *wsrc, + const int32_t *mask, int mi_row, int mi_col, MV *bestmv, const MV *ref_mv, + int allow_hp, int error_per_bit, const vpx_variance_fn_ptr_t *vfp, + int forced_stop, int iters_per_step, int *mvjcost, int *mvcost[2], + int *distortion, unsigned int *sse1, int is_second, int use_upsampled_ref); #endif // CONFIG_OBMC #ifdef __cplusplus } // extern "C" diff --git a/vp10/encoder/mips/msa/error_msa.c b/vp10/encoder/mips/msa/error_msa.c index dacca32c0..9a098eaea 100644 --- a/vp10/encoder/mips/msa/error_msa.c +++ b/vp10/encoder/mips/msa/error_msa.c @@ -11,100 +11,93 @@ #include "./vp10_rtcd.h" #include "vpx_dsp/mips/macros_msa.h" -#define BLOCK_ERROR_BLOCKSIZE_MSA(BSize) \ -static int64_t block_error_##BSize##size_msa(const int16_t *coeff_ptr, \ - const int16_t *dq_coeff_ptr, \ - int64_t *ssz) { \ - int64_t err = 0; \ - uint32_t loop_cnt; \ - v8i16 coeff, dq_coeff, coeff_r_h, coeff_l_h; \ - v4i32 diff_r, diff_l, coeff_r_w, coeff_l_w; \ - v2i64 sq_coeff_r, sq_coeff_l; \ - v2i64 err0, err_dup0, err1, err_dup1; \ - \ - coeff = LD_SH(coeff_ptr); \ - dq_coeff = LD_SH(dq_coeff_ptr); \ - UNPCK_SH_SW(coeff, coeff_r_w, coeff_l_w); \ - ILVRL_H2_SH(coeff, dq_coeff, coeff_r_h, coeff_l_h); \ - HSUB_UH2_SW(coeff_r_h, coeff_l_h, diff_r, diff_l); \ - DOTP_SW2_SD(coeff_r_w, coeff_l_w, coeff_r_w, coeff_l_w, \ - sq_coeff_r, sq_coeff_l); \ - DOTP_SW2_SD(diff_r, diff_l, diff_r, diff_l, err0, err1); \ - \ - coeff = LD_SH(coeff_ptr + 8); \ - dq_coeff = LD_SH(dq_coeff_ptr + 8); \ - UNPCK_SH_SW(coeff, coeff_r_w, coeff_l_w); \ - ILVRL_H2_SH(coeff, dq_coeff, coeff_r_h, coeff_l_h); \ - HSUB_UH2_SW(coeff_r_h, coeff_l_h, diff_r, diff_l); \ - DPADD_SD2_SD(coeff_r_w, coeff_l_w, sq_coeff_r, sq_coeff_l); \ - DPADD_SD2_SD(diff_r, diff_l, err0, err1); \ - \ - coeff_ptr += 16; \ - dq_coeff_ptr += 16; \ - \ - for (loop_cnt = ((BSize >> 4) - 1); loop_cnt--;) { \ - coeff = LD_SH(coeff_ptr); \ - dq_coeff = LD_SH(dq_coeff_ptr); \ - UNPCK_SH_SW(coeff, coeff_r_w, coeff_l_w); \ - ILVRL_H2_SH(coeff, dq_coeff, coeff_r_h, coeff_l_h); \ - HSUB_UH2_SW(coeff_r_h, coeff_l_h, diff_r, diff_l); \ - DPADD_SD2_SD(coeff_r_w, coeff_l_w, sq_coeff_r, sq_coeff_l); \ - DPADD_SD2_SD(diff_r, diff_l, err0, err1); \ - \ - coeff = LD_SH(coeff_ptr + 8); \ - dq_coeff = LD_SH(dq_coeff_ptr + 8); \ - UNPCK_SH_SW(coeff, coeff_r_w, coeff_l_w); \ - ILVRL_H2_SH(coeff, dq_coeff, coeff_r_h, coeff_l_h); \ - HSUB_UH2_SW(coeff_r_h, coeff_l_h, diff_r, diff_l); \ - DPADD_SD2_SD(coeff_r_w, coeff_l_w, sq_coeff_r, sq_coeff_l); \ - DPADD_SD2_SD(diff_r, diff_l, err0, err1); \ - \ - coeff_ptr += 16; \ - dq_coeff_ptr += 16; \ - } \ - \ - err_dup0 = __msa_splati_d(sq_coeff_r, 1); \ - err_dup1 = __msa_splati_d(sq_coeff_l, 1); \ - sq_coeff_r += err_dup0; \ - sq_coeff_l += err_dup1; \ - *ssz = __msa_copy_s_d(sq_coeff_r, 0); \ - *ssz += __msa_copy_s_d(sq_coeff_l, 0); \ - \ - err_dup0 = __msa_splati_d(err0, 1); \ - err_dup1 = __msa_splati_d(err1, 1); \ - err0 += err_dup0; \ - err1 += err_dup1; \ - err = __msa_copy_s_d(err0, 0); \ - err += __msa_copy_s_d(err1, 0); \ - \ - return err; \ -} +#define BLOCK_ERROR_BLOCKSIZE_MSA(BSize) \ + static int64_t block_error_##BSize##size_msa( \ + const int16_t *coeff_ptr, const int16_t *dq_coeff_ptr, int64_t *ssz) { \ + int64_t err = 0; \ + uint32_t loop_cnt; \ + v8i16 coeff, dq_coeff, coeff_r_h, coeff_l_h; \ + v4i32 diff_r, diff_l, coeff_r_w, coeff_l_w; \ + v2i64 sq_coeff_r, sq_coeff_l; \ + v2i64 err0, err_dup0, err1, err_dup1; \ + \ + coeff = LD_SH(coeff_ptr); \ + dq_coeff = LD_SH(dq_coeff_ptr); \ + UNPCK_SH_SW(coeff, coeff_r_w, coeff_l_w); \ + ILVRL_H2_SH(coeff, dq_coeff, coeff_r_h, coeff_l_h); \ + HSUB_UH2_SW(coeff_r_h, coeff_l_h, diff_r, diff_l); \ + DOTP_SW2_SD(coeff_r_w, coeff_l_w, coeff_r_w, coeff_l_w, sq_coeff_r, \ + sq_coeff_l); \ + DOTP_SW2_SD(diff_r, diff_l, diff_r, diff_l, err0, err1); \ + \ + coeff = LD_SH(coeff_ptr + 8); \ + dq_coeff = LD_SH(dq_coeff_ptr + 8); \ + UNPCK_SH_SW(coeff, coeff_r_w, coeff_l_w); \ + ILVRL_H2_SH(coeff, dq_coeff, coeff_r_h, coeff_l_h); \ + HSUB_UH2_SW(coeff_r_h, coeff_l_h, diff_r, diff_l); \ + DPADD_SD2_SD(coeff_r_w, coeff_l_w, sq_coeff_r, sq_coeff_l); \ + DPADD_SD2_SD(diff_r, diff_l, err0, err1); \ + \ + coeff_ptr += 16; \ + dq_coeff_ptr += 16; \ + \ + for (loop_cnt = ((BSize >> 4) - 1); loop_cnt--;) { \ + coeff = LD_SH(coeff_ptr); \ + dq_coeff = LD_SH(dq_coeff_ptr); \ + UNPCK_SH_SW(coeff, coeff_r_w, coeff_l_w); \ + ILVRL_H2_SH(coeff, dq_coeff, coeff_r_h, coeff_l_h); \ + HSUB_UH2_SW(coeff_r_h, coeff_l_h, diff_r, diff_l); \ + DPADD_SD2_SD(coeff_r_w, coeff_l_w, sq_coeff_r, sq_coeff_l); \ + DPADD_SD2_SD(diff_r, diff_l, err0, err1); \ + \ + coeff = LD_SH(coeff_ptr + 8); \ + dq_coeff = LD_SH(dq_coeff_ptr + 8); \ + UNPCK_SH_SW(coeff, coeff_r_w, coeff_l_w); \ + ILVRL_H2_SH(coeff, dq_coeff, coeff_r_h, coeff_l_h); \ + HSUB_UH2_SW(coeff_r_h, coeff_l_h, diff_r, diff_l); \ + DPADD_SD2_SD(coeff_r_w, coeff_l_w, sq_coeff_r, sq_coeff_l); \ + DPADD_SD2_SD(diff_r, diff_l, err0, err1); \ + \ + coeff_ptr += 16; \ + dq_coeff_ptr += 16; \ + } \ + \ + err_dup0 = __msa_splati_d(sq_coeff_r, 1); \ + err_dup1 = __msa_splati_d(sq_coeff_l, 1); \ + sq_coeff_r += err_dup0; \ + sq_coeff_l += err_dup1; \ + *ssz = __msa_copy_s_d(sq_coeff_r, 0); \ + *ssz += __msa_copy_s_d(sq_coeff_l, 0); \ + \ + err_dup0 = __msa_splati_d(err0, 1); \ + err_dup1 = __msa_splati_d(err1, 1); \ + err0 += err_dup0; \ + err1 += err_dup1; \ + err = __msa_copy_s_d(err0, 0); \ + err += __msa_copy_s_d(err1, 0); \ + \ + return err; \ + } -BLOCK_ERROR_BLOCKSIZE_MSA(16); -BLOCK_ERROR_BLOCKSIZE_MSA(64); -BLOCK_ERROR_BLOCKSIZE_MSA(256); -BLOCK_ERROR_BLOCKSIZE_MSA(1024); +/* clang-format off */ +BLOCK_ERROR_BLOCKSIZE_MSA(16) +BLOCK_ERROR_BLOCKSIZE_MSA(64) +BLOCK_ERROR_BLOCKSIZE_MSA(256) +BLOCK_ERROR_BLOCKSIZE_MSA(1024) +/* clang-format on */ int64_t vp10_block_error_msa(const tran_low_t *coeff_ptr, - const tran_low_t *dq_coeff_ptr, - intptr_t blk_size, int64_t *ssz) { + const tran_low_t *dq_coeff_ptr, intptr_t blk_size, + int64_t *ssz) { int64_t err; const int16_t *coeff = (const int16_t *)coeff_ptr; const int16_t *dq_coeff = (const int16_t *)dq_coeff_ptr; switch (blk_size) { - case 16: - err = block_error_16size_msa(coeff, dq_coeff, ssz); - break; - case 64: - err = block_error_64size_msa(coeff, dq_coeff, ssz); - break; - case 256: - err = block_error_256size_msa(coeff, dq_coeff, ssz); - break; - case 1024: - err = block_error_1024size_msa(coeff, dq_coeff, ssz); - break; + case 16: err = block_error_16size_msa(coeff, dq_coeff, ssz); break; + case 64: err = block_error_64size_msa(coeff, dq_coeff, ssz); break; + case 256: err = block_error_256size_msa(coeff, dq_coeff, ssz); break; + case 1024: err = block_error_1024size_msa(coeff, dq_coeff, ssz); break; default: err = vp10_block_error_c(coeff_ptr, dq_coeff_ptr, blk_size, ssz); break; diff --git a/vp10/encoder/mips/msa/fdct16x16_msa.c b/vp10/encoder/mips/msa/fdct16x16_msa.c index d78fc6473..c39a292f8 100644 --- a/vp10/encoder/mips/msa/fdct16x16_msa.c +++ b/vp10/encoder/mips/msa/fdct16x16_msa.c @@ -159,8 +159,8 @@ static void fadst16_transpose_postproc_msa(int16_t *input, int16_t *out) { /* load input data */ LD_SH8(input, 16, l0, l1, l2, l3, l4, l5, l6, l7); - TRANSPOSE8x8_SH_SH(l0, l1, l2, l3, l4, l5, l6, l7, - r0, r1, r2, r3, r4, r5, r6, r7); + TRANSPOSE8x8_SH_SH(l0, l1, l2, l3, l4, l5, l6, l7, r0, r1, r2, r3, r4, r5, r6, + r7); FDCT_POSTPROC_2V_NEG_H(r0, r1); FDCT_POSTPROC_2V_NEG_H(r2, r3); FDCT_POSTPROC_2V_NEG_H(r4, r5); @@ -169,8 +169,8 @@ static void fadst16_transpose_postproc_msa(int16_t *input, int16_t *out) { out += 64; LD_SH8(input + 8, 16, l8, l9, l10, l11, l12, l13, l14, l15); - TRANSPOSE8x8_SH_SH(l8, l9, l10, l11, l12, l13, l14, l15, - r8, r9, r10, r11, r12, r13, r14, r15); + TRANSPOSE8x8_SH_SH(l8, l9, l10, l11, l12, l13, l14, l15, r8, r9, r10, r11, + r12, r13, r14, r15); FDCT_POSTPROC_2V_NEG_H(r8, r9); FDCT_POSTPROC_2V_NEG_H(r10, r11); FDCT_POSTPROC_2V_NEG_H(r12, r13); @@ -181,8 +181,8 @@ static void fadst16_transpose_postproc_msa(int16_t *input, int16_t *out) { /* load input data */ input += 128; LD_SH8(input, 16, l0, l1, l2, l3, l4, l5, l6, l7); - TRANSPOSE8x8_SH_SH(l0, l1, l2, l3, l4, l5, l6, l7, - r0, r1, r2, r3, r4, r5, r6, r7); + TRANSPOSE8x8_SH_SH(l0, l1, l2, l3, l4, l5, l6, l7, r0, r1, r2, r3, r4, r5, r6, + r7); FDCT_POSTPROC_2V_NEG_H(r0, r1); FDCT_POSTPROC_2V_NEG_H(r2, r3); FDCT_POSTPROC_2V_NEG_H(r4, r5); @@ -191,8 +191,8 @@ static void fadst16_transpose_postproc_msa(int16_t *input, int16_t *out) { out += 64; LD_SH8(input + 8, 16, l8, l9, l10, l11, l12, l13, l14, l15); - TRANSPOSE8x8_SH_SH(l8, l9, l10, l11, l12, l13, l14, l15, - r8, r9, r10, r11, r12, r13, r14, r15); + TRANSPOSE8x8_SH_SH(l8, l9, l10, l11, l12, l13, l14, l15, r8, r9, r10, r11, + r12, r13, r14, r15); FDCT_POSTPROC_2V_NEG_H(r8, r9); FDCT_POSTPROC_2V_NEG_H(r10, r11); FDCT_POSTPROC_2V_NEG_H(r12, r13); @@ -339,24 +339,24 @@ static void fadst16_transpose_msa(int16_t *input, int16_t *out) { v8i16 l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15; /* load input data */ - LD_SH16(input, 8, l0, l8, l1, l9, l2, l10, l3, l11, - l4, l12, l5, l13, l6, l14, l7, l15); - TRANSPOSE8x8_SH_SH(l0, l1, l2, l3, l4, l5, l6, l7, - r0, r1, r2, r3, r4, r5, r6, r7); - TRANSPOSE8x8_SH_SH(l8, l9, l10, l11, l12, l13, l14, l15, - r8, r9, r10, r11, r12, r13, r14, r15); + LD_SH16(input, 8, l0, l8, l1, l9, l2, l10, l3, l11, l4, l12, l5, l13, l6, l14, + l7, l15); + TRANSPOSE8x8_SH_SH(l0, l1, l2, l3, l4, l5, l6, l7, r0, r1, r2, r3, r4, r5, r6, + r7); + TRANSPOSE8x8_SH_SH(l8, l9, l10, l11, l12, l13, l14, l15, r8, r9, r10, r11, + r12, r13, r14, r15); ST_SH8(r0, r8, r1, r9, r2, r10, r3, r11, out, 8); ST_SH8(r4, r12, r5, r13, r6, r14, r7, r15, (out + 64), 8); out += 16 * 8; /* load input data */ input += 128; - LD_SH16(input, 8, l0, l8, l1, l9, l2, l10, l3, l11, - l4, l12, l5, l13, l6, l14, l7, l15); - TRANSPOSE8x8_SH_SH(l0, l1, l2, l3, l4, l5, l6, l7, - r0, r1, r2, r3, r4, r5, r6, r7); - TRANSPOSE8x8_SH_SH(l8, l9, l10, l11, l12, l13, l14, l15, - r8, r9, r10, r11, r12, r13, r14, r15); + LD_SH16(input, 8, l0, l8, l1, l9, l2, l10, l3, l11, l4, l12, l5, l13, l6, l14, + l7, l15); + TRANSPOSE8x8_SH_SH(l0, l1, l2, l3, l4, l5, l6, l7, r0, r1, r2, r3, r4, r5, r6, + r7); + TRANSPOSE8x8_SH_SH(l8, l9, l10, l11, l12, l13, l14, l15, r8, r9, r10, r11, + r12, r13, r14, r15); ST_SH8(r0, r8, r1, r9, r2, r10, r3, r11, out, 8); ST_SH8(r4, r12, r5, r13, r6, r14, r7, r15, (out + 64), 8); } @@ -371,10 +371,10 @@ static void postproc_fdct16x8_1d_row(int16_t *intermediate, int16_t *output) { LD_SH8(temp, 16, in0, in1, in2, in3, in4, in5, in6, in7); temp = intermediate + 8; LD_SH8(temp, 16, in8, in9, in10, in11, in12, in13, in14, in15); - TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); - TRANSPOSE8x8_SH_SH(in8, in9, in10, in11, in12, in13, in14, in15, - in8, in9, in10, in11, in12, in13, in14, in15); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, + in4, in5, in6, in7); + TRANSPOSE8x8_SH_SH(in8, in9, in10, in11, in12, in13, in14, in15, in8, in9, + in10, in11, in12, in13, in14, in15); FDCT_POSTPROC_2V_NEG_H(in0, in1); FDCT_POSTPROC_2V_NEG_H(in2, in3); FDCT_POSTPROC_2V_NEG_H(in4, in5); @@ -383,29 +383,28 @@ static void postproc_fdct16x8_1d_row(int16_t *intermediate, int16_t *output) { FDCT_POSTPROC_2V_NEG_H(in10, in11); FDCT_POSTPROC_2V_NEG_H(in12, in13); FDCT_POSTPROC_2V_NEG_H(in14, in15); - BUTTERFLY_16(in0, in1, in2, in3, in4, in5, in6, in7, - in8, in9, in10, in11, in12, in13, in14, in15, - tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, - in8, in9, in10, in11, in12, in13, in14, in15); + BUTTERFLY_16(in0, in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, + in12, in13, in14, in15, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, + tmp7, in8, in9, in10, in11, in12, in13, in14, in15); temp = intermediate; ST_SH8(in8, in9, in10, in11, in12, in13, in14, in15, temp, 16); - FDCT8x16_EVEN(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, - tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7); + FDCT8x16_EVEN(tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp0, tmp1, + tmp2, tmp3, tmp4, tmp5, tmp6, tmp7); temp = intermediate; LD_SH8(temp, 16, in8, in9, in10, in11, in12, in13, in14, in15); - FDCT8x16_ODD(in8, in9, in10, in11, in12, in13, in14, in15, - in0, in1, in2, in3, in4, in5, in6, in7); - TRANSPOSE8x8_SH_SH(tmp0, in0, tmp1, in1, tmp2, in2, tmp3, in3, - tmp0, in0, tmp1, in1, tmp2, in2, tmp3, in3); + FDCT8x16_ODD(in8, in9, in10, in11, in12, in13, in14, in15, in0, in1, in2, in3, + in4, in5, in6, in7); + TRANSPOSE8x8_SH_SH(tmp0, in0, tmp1, in1, tmp2, in2, tmp3, in3, tmp0, in0, + tmp1, in1, tmp2, in2, tmp3, in3); ST_SH8(tmp0, in0, tmp1, in1, tmp2, in2, tmp3, in3, out, 16); - TRANSPOSE8x8_SH_SH(tmp4, in4, tmp5, in5, tmp6, in6, tmp7, in7, - tmp4, in4, tmp5, in5, tmp6, in6, tmp7, in7); + TRANSPOSE8x8_SH_SH(tmp4, in4, tmp5, in5, tmp6, in6, tmp7, in7, tmp4, in4, + tmp5, in5, tmp6, in6, tmp7, in7); out = output + 8; ST_SH8(tmp4, in4, tmp5, in5, tmp6, in6, tmp7, in7, out, 16); } -void vp10_fht16x16_msa(const int16_t *input, int16_t *output, - int32_t stride, int32_t tx_type) { +void vp10_fht16x16_msa(const int16_t *input, int16_t *output, int32_t stride, + int32_t tx_type) { DECLARE_ALIGNED(32, int16_t, tmp[256]); DECLARE_ALIGNED(32, int16_t, trans_buf[256]); DECLARE_ALIGNED(32, int16_t, tmp_buf[128]); @@ -413,35 +412,31 @@ void vp10_fht16x16_msa(const int16_t *input, int16_t *output, int16_t *ptmpbuf = &tmp_buf[0]; int16_t *trans = &trans_buf[0]; const int32_t const_arr[29 * 4] = { - 52707308, 52707308, 52707308, 52707308, - -1072430300, -1072430300, -1072430300, -1072430300, - 795618043, 795618043, 795618043, 795618043, - -721080468, -721080468, -721080468, -721080468, - 459094491, 459094491, 459094491, 459094491, - -970646691, -970646691, -970646691, -970646691, - 1010963856, 1010963856, 1010963856, 1010963856, - -361743294, -361743294, -361743294, -361743294, - 209469125, 209469125, 209469125, 209469125, - -1053094788, -1053094788, -1053094788, -1053094788, - 1053160324, 1053160324, 1053160324, 1053160324, - 639644520, 639644520, 639644520, 639644520, - -862444000, -862444000, -862444000, -862444000, - 1062144356, 1062144356, 1062144356, 1062144356, - -157532337, -157532337, -157532337, -157532337, - 260914709, 260914709, 260914709, 260914709, - -1041559667, -1041559667, -1041559667, -1041559667, - 920985831, 920985831, 920985831, 920985831, - -551995675, -551995675, -551995675, -551995675, - 596522295, 596522295, 596522295, 596522295, - 892853362, 892853362, 892853362, 892853362, - -892787826, -892787826, -892787826, -892787826, - 410925857, 410925857, 410925857, 410925857, - -992012162, -992012162, -992012162, -992012162, - 992077698, 992077698, 992077698, 992077698, - 759246145, 759246145, 759246145, 759246145, - -759180609, -759180609, -759180609, -759180609, - -759222975, -759222975, -759222975, -759222975, - 759288511, 759288511, 759288511, 759288511 }; + 52707308, 52707308, 52707308, 52707308, -1072430300, + -1072430300, -1072430300, -1072430300, 795618043, 795618043, + 795618043, 795618043, -721080468, -721080468, -721080468, + -721080468, 459094491, 459094491, 459094491, 459094491, + -970646691, -970646691, -970646691, -970646691, 1010963856, + 1010963856, 1010963856, 1010963856, -361743294, -361743294, + -361743294, -361743294, 209469125, 209469125, 209469125, + 209469125, -1053094788, -1053094788, -1053094788, -1053094788, + 1053160324, 1053160324, 1053160324, 1053160324, 639644520, + 639644520, 639644520, 639644520, -862444000, -862444000, + -862444000, -862444000, 1062144356, 1062144356, 1062144356, + 1062144356, -157532337, -157532337, -157532337, -157532337, + 260914709, 260914709, 260914709, 260914709, -1041559667, + -1041559667, -1041559667, -1041559667, 920985831, 920985831, + 920985831, 920985831, -551995675, -551995675, -551995675, + -551995675, 596522295, 596522295, 596522295, 596522295, + 892853362, 892853362, 892853362, 892853362, -892787826, + -892787826, -892787826, -892787826, 410925857, 410925857, + 410925857, 410925857, -992012162, -992012162, -992012162, + -992012162, 992077698, 992077698, 992077698, 992077698, + 759246145, 759246145, 759246145, 759246145, -759180609, + -759180609, -759180609, -759180609, -759222975, -759222975, + -759222975, -759222975, 759288511, 759288511, 759288511, + 759288511 + }; switch (tx_type) { case DCT_DCT: @@ -500,8 +495,6 @@ void vp10_fht16x16_msa(const int16_t *input, int16_t *output, fadst16_transpose_msa(tmp, output); break; - default: - assert(0); - break; + default: assert(0); break; } } diff --git a/vp10/encoder/mips/msa/fdct4x4_msa.c b/vp10/encoder/mips/msa/fdct4x4_msa.c index f9028f096..def9b45f9 100644 --- a/vp10/encoder/mips/msa/fdct4x4_msa.c +++ b/vp10/encoder/mips/msa/fdct4x4_msa.c @@ -14,7 +14,7 @@ #include "vp10/encoder/mips/msa/fdct_msa.h" void vp10_fwht4x4_msa(const int16_t *input, int16_t *output, - int32_t src_stride) { + int32_t src_stride) { v8i16 in0, in1, in2, in3, in4; LD_SH4(input, src_stride, in0, in1, in2, in3); @@ -46,7 +46,7 @@ void vp10_fwht4x4_msa(const int16_t *input, int16_t *output, } void vp10_fht4x4_msa(const int16_t *input, int16_t *output, int32_t stride, - int32_t tx_type) { + int32_t tx_type) { v8i16 in0, in1, in2, in3; LD_SH4(input, stride, in0, in1, in2, in3); @@ -86,9 +86,7 @@ void vp10_fht4x4_msa(const int16_t *input, int16_t *output, int32_t stride, TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3); VPX_FADST4(in0, in1, in2, in3, in0, in1, in2, in3); break; - default: - assert(0); - break; + default: assert(0); break; } TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3); diff --git a/vp10/encoder/mips/msa/fdct8x8_msa.c b/vp10/encoder/mips/msa/fdct8x8_msa.c index 8e1e111b3..7843a624c 100644 --- a/vp10/encoder/mips/msa/fdct8x8_msa.c +++ b/vp10/encoder/mips/msa/fdct8x8_msa.c @@ -14,7 +14,7 @@ #include "vp10/encoder/mips/msa/fdct_msa.h" void vp10_fht8x8_msa(const int16_t *input, int16_t *output, int32_t stride, - int32_t tx_type) { + int32_t tx_type) { v8i16 in0, in1, in2, in3, in4, in5, in6, in7; LD_SH8(input, stride, in0, in1, in2, in3, in4, in5, in6, in7); @@ -23,44 +23,42 @@ void vp10_fht8x8_msa(const int16_t *input, int16_t *output, int32_t stride, switch (tx_type) { case DCT_DCT: - VPX_FDCT8(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); - TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); - VPX_FDCT8(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); + VPX_FDCT8(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, in4, + in5, in6, in7); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, + in3, in4, in5, in6, in7); + VPX_FDCT8(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, in4, + in5, in6, in7); break; case ADST_DCT: - VPX_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); - TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); - VPX_FDCT8(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); + VPX_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, in4, + in5, in6, in7); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, + in3, in4, in5, in6, in7); + VPX_FDCT8(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, in4, + in5, in6, in7); break; case DCT_ADST: - VPX_FDCT8(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); - TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); - VPX_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); + VPX_FDCT8(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, in4, + in5, in6, in7); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, + in3, in4, in5, in6, in7); + VPX_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, in4, + in5, in6, in7); break; case ADST_ADST: - VPX_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); - TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); - VPX_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); - break; - default: - assert(0); + VPX_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, in4, + in5, in6, in7); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, + in3, in4, in5, in6, in7); + VPX_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, in4, + in5, in6, in7); break; + default: assert(0); break; } - TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, - in0, in1, in2, in3, in4, in5, in6, in7); + TRANSPOSE8x8_SH_SH(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, + in4, in5, in6, in7); SRLI_AVE_S_4V_H(in0, in1, in2, in3, in4, in5, in6, in7); ST_SH8(in0, in1, in2, in3, in4, in5, in6, in7, output, 8); } diff --git a/vp10/encoder/mips/msa/fdct_msa.h b/vp10/encoder/mips/msa/fdct_msa.h index ce4e9074c..9a1462597 100644 --- a/vp10/encoder/mips/msa/fdct_msa.h +++ b/vp10/encoder/mips/msa/fdct_msa.h @@ -15,103 +15,102 @@ #include "vpx_dsp/mips/txfm_macros_msa.h" #include "vpx_ports/mem.h" -#define VPX_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, \ - out0, out1, out2, out3, out4, out5, out6, out7) { \ - v8i16 cnst0_m, cnst1_m, cnst2_m, cnst3_m, cnst4_m; \ - v8i16 vec0_m, vec1_m, vec2_m, vec3_m, s0_m, s1_m; \ - v8i16 coeff0_m = { cospi_2_64, cospi_6_64, cospi_10_64, cospi_14_64, \ - cospi_18_64, cospi_22_64, cospi_26_64, cospi_30_64 }; \ - v8i16 coeff1_m = { cospi_8_64, -cospi_8_64, cospi_16_64, -cospi_16_64, \ - cospi_24_64, -cospi_24_64, 0, 0 }; \ - \ - SPLATI_H2_SH(coeff0_m, 0, 7, cnst0_m, cnst1_m); \ - cnst2_m = -cnst0_m; \ - ILVEV_H2_SH(cnst0_m, cnst1_m, cnst1_m, cnst2_m, cnst0_m, cnst1_m); \ - SPLATI_H2_SH(coeff0_m, 4, 3, cnst2_m, cnst3_m); \ - cnst4_m = -cnst2_m; \ - ILVEV_H2_SH(cnst2_m, cnst3_m, cnst3_m, cnst4_m, cnst2_m, cnst3_m); \ - \ - ILVRL_H2_SH(in0, in7, vec1_m, vec0_m); \ - ILVRL_H2_SH(in4, in3, vec3_m, vec2_m); \ - DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, \ - cnst1_m, cnst2_m, cnst3_m, in7, in0, \ - in4, in3); \ - \ - SPLATI_H2_SH(coeff0_m, 2, 5, cnst0_m, cnst1_m); \ - cnst2_m = -cnst0_m; \ - ILVEV_H2_SH(cnst0_m, cnst1_m, cnst1_m, cnst2_m, cnst0_m, cnst1_m); \ - SPLATI_H2_SH(coeff0_m, 6, 1, cnst2_m, cnst3_m); \ - cnst4_m = -cnst2_m; \ - ILVEV_H2_SH(cnst2_m, cnst3_m, cnst3_m, cnst4_m, cnst2_m, cnst3_m); \ - \ - ILVRL_H2_SH(in2, in5, vec1_m, vec0_m); \ - ILVRL_H2_SH(in6, in1, vec3_m, vec2_m); \ - \ - DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, \ - cnst1_m, cnst2_m, cnst3_m, in5, in2, \ - in6, in1); \ - BUTTERFLY_4(in7, in0, in2, in5, s1_m, s0_m, in2, in5); \ - out7 = -s0_m; \ - out0 = s1_m; \ - \ - SPLATI_H4_SH(coeff1_m, 0, 4, 1, 5, cnst0_m, cnst1_m, cnst2_m, cnst3_m); \ - \ - ILVEV_H2_SH(cnst3_m, cnst0_m, cnst1_m, cnst2_m, cnst3_m, cnst2_m); \ - cnst0_m = __msa_ilvev_h(cnst1_m, cnst0_m); \ - cnst1_m = cnst0_m; \ - \ - ILVRL_H2_SH(in4, in3, vec1_m, vec0_m); \ - ILVRL_H2_SH(in6, in1, vec3_m, vec2_m); \ - DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, \ - cnst2_m, cnst3_m, cnst1_m, out1, out6, \ - s0_m, s1_m); \ - \ - SPLATI_H2_SH(coeff1_m, 2, 3, cnst0_m, cnst1_m); \ - cnst1_m = __msa_ilvev_h(cnst1_m, cnst0_m); \ - \ - ILVRL_H2_SH(in2, in5, vec1_m, vec0_m); \ - ILVRL_H2_SH(s0_m, s1_m, vec3_m, vec2_m); \ - out3 = DOT_SHIFT_RIGHT_PCK_H(vec0_m, vec1_m, cnst0_m); \ - out4 = DOT_SHIFT_RIGHT_PCK_H(vec0_m, vec1_m, cnst1_m); \ - out2 = DOT_SHIFT_RIGHT_PCK_H(vec2_m, vec3_m, cnst0_m); \ - out5 = DOT_SHIFT_RIGHT_PCK_H(vec2_m, vec3_m, cnst1_m); \ - \ - out1 = -out1; \ - out3 = -out3; \ - out5 = -out5; \ -} +#define VPX_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, out2, \ + out3, out4, out5, out6, out7) \ + { \ + v8i16 cnst0_m, cnst1_m, cnst2_m, cnst3_m, cnst4_m; \ + v8i16 vec0_m, vec1_m, vec2_m, vec3_m, s0_m, s1_m; \ + v8i16 coeff0_m = { cospi_2_64, cospi_6_64, cospi_10_64, cospi_14_64, \ + cospi_18_64, cospi_22_64, cospi_26_64, cospi_30_64 }; \ + v8i16 coeff1_m = { cospi_8_64, -cospi_8_64, cospi_16_64, -cospi_16_64, \ + cospi_24_64, -cospi_24_64, 0, 0 }; \ + \ + SPLATI_H2_SH(coeff0_m, 0, 7, cnst0_m, cnst1_m); \ + cnst2_m = -cnst0_m; \ + ILVEV_H2_SH(cnst0_m, cnst1_m, cnst1_m, cnst2_m, cnst0_m, cnst1_m); \ + SPLATI_H2_SH(coeff0_m, 4, 3, cnst2_m, cnst3_m); \ + cnst4_m = -cnst2_m; \ + ILVEV_H2_SH(cnst2_m, cnst3_m, cnst3_m, cnst4_m, cnst2_m, cnst3_m); \ + \ + ILVRL_H2_SH(in0, in7, vec1_m, vec0_m); \ + ILVRL_H2_SH(in4, in3, vec3_m, vec2_m); \ + DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, cnst1_m, \ + cnst2_m, cnst3_m, in7, in0, in4, in3); \ + \ + SPLATI_H2_SH(coeff0_m, 2, 5, cnst0_m, cnst1_m); \ + cnst2_m = -cnst0_m; \ + ILVEV_H2_SH(cnst0_m, cnst1_m, cnst1_m, cnst2_m, cnst0_m, cnst1_m); \ + SPLATI_H2_SH(coeff0_m, 6, 1, cnst2_m, cnst3_m); \ + cnst4_m = -cnst2_m; \ + ILVEV_H2_SH(cnst2_m, cnst3_m, cnst3_m, cnst4_m, cnst2_m, cnst3_m); \ + \ + ILVRL_H2_SH(in2, in5, vec1_m, vec0_m); \ + ILVRL_H2_SH(in6, in1, vec3_m, vec2_m); \ + \ + DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, cnst1_m, \ + cnst2_m, cnst3_m, in5, in2, in6, in1); \ + BUTTERFLY_4(in7, in0, in2, in5, s1_m, s0_m, in2, in5); \ + out7 = -s0_m; \ + out0 = s1_m; \ + \ + SPLATI_H4_SH(coeff1_m, 0, 4, 1, 5, cnst0_m, cnst1_m, cnst2_m, cnst3_m); \ + \ + ILVEV_H2_SH(cnst3_m, cnst0_m, cnst1_m, cnst2_m, cnst3_m, cnst2_m); \ + cnst0_m = __msa_ilvev_h(cnst1_m, cnst0_m); \ + cnst1_m = cnst0_m; \ + \ + ILVRL_H2_SH(in4, in3, vec1_m, vec0_m); \ + ILVRL_H2_SH(in6, in1, vec3_m, vec2_m); \ + DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, cnst2_m, \ + cnst3_m, cnst1_m, out1, out6, s0_m, s1_m); \ + \ + SPLATI_H2_SH(coeff1_m, 2, 3, cnst0_m, cnst1_m); \ + cnst1_m = __msa_ilvev_h(cnst1_m, cnst0_m); \ + \ + ILVRL_H2_SH(in2, in5, vec1_m, vec0_m); \ + ILVRL_H2_SH(s0_m, s1_m, vec3_m, vec2_m); \ + out3 = DOT_SHIFT_RIGHT_PCK_H(vec0_m, vec1_m, cnst0_m); \ + out4 = DOT_SHIFT_RIGHT_PCK_H(vec0_m, vec1_m, cnst1_m); \ + out2 = DOT_SHIFT_RIGHT_PCK_H(vec2_m, vec3_m, cnst0_m); \ + out5 = DOT_SHIFT_RIGHT_PCK_H(vec2_m, vec3_m, cnst1_m); \ + \ + out1 = -out1; \ + out3 = -out3; \ + out5 = -out5; \ + } -#define VPX_FADST4(in0, in1, in2, in3, out0, out1, out2, out3) { \ - v4i32 s0_m, s1_m, s2_m, s3_m, constant_m; \ - v4i32 in0_r_m, in1_r_m, in2_r_m, in3_r_m; \ - \ - UNPCK_R_SH_SW(in0, in0_r_m); \ - UNPCK_R_SH_SW(in1, in1_r_m); \ - UNPCK_R_SH_SW(in2, in2_r_m); \ - UNPCK_R_SH_SW(in3, in3_r_m); \ - \ - constant_m = __msa_fill_w(sinpi_4_9); \ - MUL2(in0_r_m, constant_m, in3_r_m, constant_m, s1_m, s0_m); \ - \ - constant_m = __msa_fill_w(sinpi_1_9); \ - s0_m += in0_r_m * constant_m; \ - s1_m -= in1_r_m * constant_m; \ - \ - constant_m = __msa_fill_w(sinpi_2_9); \ - s0_m += in1_r_m * constant_m; \ - s1_m += in3_r_m * constant_m; \ - \ - s2_m = in0_r_m + in1_r_m - in3_r_m; \ - \ - constant_m = __msa_fill_w(sinpi_3_9); \ - MUL2(in2_r_m, constant_m, s2_m, constant_m, s3_m, in1_r_m); \ - \ - in0_r_m = s0_m + s3_m; \ - s2_m = s1_m - s3_m; \ - s3_m = s1_m - s0_m + s3_m; \ - \ - SRARI_W4_SW(in0_r_m, in1_r_m, s2_m, s3_m, DCT_CONST_BITS); \ - PCKEV_H4_SH(in0_r_m, in0_r_m, in1_r_m, in1_r_m, s2_m, s2_m, \ - s3_m, s3_m, out0, out1, out2, out3); \ -} -#endif /* VP10_ENCODER_MIPS_MSA_VP10_FDCT_MSA_H_ */ +#define VPX_FADST4(in0, in1, in2, in3, out0, out1, out2, out3) \ + { \ + v4i32 s0_m, s1_m, s2_m, s3_m, constant_m; \ + v4i32 in0_r_m, in1_r_m, in2_r_m, in3_r_m; \ + \ + UNPCK_R_SH_SW(in0, in0_r_m); \ + UNPCK_R_SH_SW(in1, in1_r_m); \ + UNPCK_R_SH_SW(in2, in2_r_m); \ + UNPCK_R_SH_SW(in3, in3_r_m); \ + \ + constant_m = __msa_fill_w(sinpi_4_9); \ + MUL2(in0_r_m, constant_m, in3_r_m, constant_m, s1_m, s0_m); \ + \ + constant_m = __msa_fill_w(sinpi_1_9); \ + s0_m += in0_r_m * constant_m; \ + s1_m -= in1_r_m * constant_m; \ + \ + constant_m = __msa_fill_w(sinpi_2_9); \ + s0_m += in1_r_m * constant_m; \ + s1_m += in3_r_m * constant_m; \ + \ + s2_m = in0_r_m + in1_r_m - in3_r_m; \ + \ + constant_m = __msa_fill_w(sinpi_3_9); \ + MUL2(in2_r_m, constant_m, s2_m, constant_m, s3_m, in1_r_m); \ + \ + in0_r_m = s0_m + s3_m; \ + s2_m = s1_m - s3_m; \ + s3_m = s1_m - s0_m + s3_m; \ + \ + SRARI_W4_SW(in0_r_m, in1_r_m, s2_m, s3_m, DCT_CONST_BITS); \ + PCKEV_H4_SH(in0_r_m, in0_r_m, in1_r_m, in1_r_m, s2_m, s2_m, s3_m, s3_m, \ + out0, out1, out2, out3); \ + } +#endif // VP10_ENCODER_MIPS_MSA_VP10_FDCT_MSA_H_ diff --git a/vp10/encoder/mips/msa/temporal_filter_msa.c b/vp10/encoder/mips/msa/temporal_filter_msa.c index 5d4558b94..5feeab3e7 100644 --- a/vp10/encoder/mips/msa/temporal_filter_msa.c +++ b/vp10/encoder/mips/msa/temporal_filter_msa.c @@ -11,12 +11,9 @@ #include "./vp10_rtcd.h" #include "vpx_dsp/mips/macros_msa.h" -static void temporal_filter_apply_8size_msa(uint8_t *frm1_ptr, - uint32_t stride, - uint8_t *frm2_ptr, - int32_t filt_sth, - int32_t filt_wgt, - uint32_t *acc, +static void temporal_filter_apply_8size_msa(uint8_t *frm1_ptr, uint32_t stride, + uint8_t *frm2_ptr, int32_t filt_sth, + int32_t filt_wgt, uint32_t *acc, uint16_t *cnt) { uint32_t row; uint64_t f0, f1, f2, f3; @@ -54,10 +51,10 @@ static void temporal_filter_apply_8size_msa(uint8_t *frm1_ptr, HSUB_UB2_SH(frm_r, frm_l, diff0, diff1); UNPCK_SH_SW(diff0, diff0_r, diff0_l); UNPCK_SH_SW(diff1, diff1_r, diff1_l); - MUL4(diff0_r, diff0_r, diff0_l, diff0_l, diff1_r, diff1_r, diff1_l, - diff1_l, mod0_w, mod1_w, mod2_w, mod3_w); - MUL4(mod0_w, cnst3, mod1_w, cnst3, mod2_w, cnst3, mod3_w, cnst3, + MUL4(diff0_r, diff0_r, diff0_l, diff0_l, diff1_r, diff1_r, diff1_l, diff1_l, mod0_w, mod1_w, mod2_w, mod3_w); + MUL4(mod0_w, cnst3, mod1_w, cnst3, mod2_w, cnst3, mod3_w, cnst3, mod0_w, + mod1_w, mod2_w, mod3_w); SRAR_W4_SW(mod0_w, mod1_w, mod2_w, mod3_w, strength); diff0_r = (mod0_w < cnst16); @@ -65,8 +62,8 @@ static void temporal_filter_apply_8size_msa(uint8_t *frm1_ptr, diff1_r = (mod2_w < cnst16); diff1_l = (mod3_w < cnst16); - SUB4(cnst16, mod0_w, cnst16, mod1_w, cnst16, mod2_w, cnst16, mod3_w, - mod0_w, mod1_w, mod2_w, mod3_w); + SUB4(cnst16, mod0_w, cnst16, mod1_w, cnst16, mod2_w, cnst16, mod3_w, mod0_w, + mod1_w, mod2_w, mod3_w); mod0_w = diff0_r & mod0_w; mod1_w = diff0_l & mod1_w; @@ -85,8 +82,8 @@ static void temporal_filter_apply_8size_msa(uint8_t *frm1_ptr, UNPCK_SH_SW(frm2_l, frm2_lr, frm2_ll); MUL4(mod0_w, frm2_rr, mod1_w, frm2_rl, mod2_w, frm2_lr, mod3_w, frm2_ll, mod0_w, mod1_w, mod2_w, mod3_w); - ADD4(mod0_w, acc0, mod1_w, acc1, mod2_w, acc2, mod3_w, acc3, - mod0_w, mod1_w, mod2_w, mod3_w); + ADD4(mod0_w, acc0, mod1_w, acc1, mod2_w, acc2, mod3_w, acc3, mod0_w, mod1_w, + mod2_w, mod3_w); ST_SW2(mod0_w, mod1_w, acc, 4); acc += 8; @@ -101,10 +98,10 @@ static void temporal_filter_apply_8size_msa(uint8_t *frm1_ptr, HSUB_UB2_SH(frm_r, frm_l, diff0, diff1); UNPCK_SH_SW(diff0, diff0_r, diff0_l); UNPCK_SH_SW(diff1, diff1_r, diff1_l); - MUL4(diff0_r, diff0_r, diff0_l, diff0_l, diff1_r, diff1_r, diff1_l, - diff1_l, mod0_w, mod1_w, mod2_w, mod3_w); - MUL4(mod0_w, cnst3, mod1_w, cnst3, mod2_w, cnst3, mod3_w, cnst3, + MUL4(diff0_r, diff0_r, diff0_l, diff0_l, diff1_r, diff1_r, diff1_l, diff1_l, mod0_w, mod1_w, mod2_w, mod3_w); + MUL4(mod0_w, cnst3, mod1_w, cnst3, mod2_w, cnst3, mod3_w, cnst3, mod0_w, + mod1_w, mod2_w, mod3_w); SRAR_W4_SW(mod0_w, mod1_w, mod2_w, mod3_w, strength); diff0_r = (mod0_w < cnst16); @@ -112,8 +109,8 @@ static void temporal_filter_apply_8size_msa(uint8_t *frm1_ptr, diff1_r = (mod2_w < cnst16); diff1_l = (mod3_w < cnst16); - SUB4(cnst16, mod0_w, cnst16, mod1_w, cnst16, mod2_w, cnst16, mod3_w, - mod0_w, mod1_w, mod2_w, mod3_w); + SUB4(cnst16, mod0_w, cnst16, mod1_w, cnst16, mod2_w, cnst16, mod3_w, mod0_w, + mod1_w, mod2_w, mod3_w); mod0_w = diff0_r & mod0_w; mod1_w = diff0_l & mod1_w; @@ -131,8 +128,8 @@ static void temporal_filter_apply_8size_msa(uint8_t *frm1_ptr, UNPCK_SH_SW(frm2_l, frm2_lr, frm2_ll); MUL4(mod0_w, frm2_rr, mod1_w, frm2_rl, mod2_w, frm2_lr, mod3_w, frm2_ll, mod0_w, mod1_w, mod2_w, mod3_w); - ADD4(mod0_w, acc0, mod1_w, acc1, mod2_w, acc2, mod3_w, acc3, - mod0_w, mod1_w, mod2_w, mod3_w); + ADD4(mod0_w, acc0, mod1_w, acc1, mod2_w, acc2, mod3_w, acc3, mod0_w, mod1_w, + mod2_w, mod3_w); ST_SW2(mod0_w, mod1_w, acc, 4); acc += 8; @@ -141,13 +138,10 @@ static void temporal_filter_apply_8size_msa(uint8_t *frm1_ptr, } } -static void temporal_filter_apply_16size_msa(uint8_t *frm1_ptr, - uint32_t stride, +static void temporal_filter_apply_16size_msa(uint8_t *frm1_ptr, uint32_t stride, uint8_t *frm2_ptr, - int32_t filt_sth, - int32_t filt_wgt, - uint32_t *acc, - uint16_t *cnt) { + int32_t filt_sth, int32_t filt_wgt, + uint32_t *acc, uint16_t *cnt) { uint32_t row; v16i8 frm1, frm2, frm3, frm4; v16u8 frm_r, frm_l; @@ -183,8 +177,8 @@ static void temporal_filter_apply_16size_msa(uint8_t *frm1_ptr, UNPCK_SH_SW(diff1, diff1_r, diff1_l); MUL4(diff0_r, diff0_r, diff0_l, diff0_l, diff1_r, diff1_r, diff1_l, diff1_l, mod0_w, mod1_w, mod2_w, mod3_w); - MUL4(mod0_w, cnst3, mod1_w, cnst3, mod2_w, cnst3, mod3_w, cnst3, - mod0_w, mod1_w, mod2_w, mod3_w); + MUL4(mod0_w, cnst3, mod1_w, cnst3, mod2_w, cnst3, mod3_w, cnst3, mod0_w, + mod1_w, mod2_w, mod3_w); SRAR_W4_SW(mod0_w, mod1_w, mod2_w, mod3_w, strength); diff0_r = (mod0_w < cnst16); @@ -192,8 +186,8 @@ static void temporal_filter_apply_16size_msa(uint8_t *frm1_ptr, diff1_r = (mod2_w < cnst16); diff1_l = (mod3_w < cnst16); - SUB4(cnst16, mod0_w, cnst16, mod1_w, cnst16, mod2_w, cnst16, mod3_w, - mod0_w, mod1_w, mod2_w, mod3_w); + SUB4(cnst16, mod0_w, cnst16, mod1_w, cnst16, mod2_w, cnst16, mod3_w, mod0_w, + mod1_w, mod2_w, mod3_w); mod0_w = diff0_r & mod0_w; mod1_w = diff0_l & mod1_w; @@ -212,8 +206,8 @@ static void temporal_filter_apply_16size_msa(uint8_t *frm1_ptr, UNPCK_SH_SW(frm2_l, frm2_lr, frm2_ll); MUL4(mod0_w, frm2_rr, mod1_w, frm2_rl, mod2_w, frm2_lr, mod3_w, frm2_ll, mod0_w, mod1_w, mod2_w, mod3_w); - ADD4(mod0_w, acc0, mod1_w, acc1, mod2_w, acc2, mod3_w, acc3, - mod0_w, mod1_w, mod2_w, mod3_w); + ADD4(mod0_w, acc0, mod1_w, acc1, mod2_w, acc2, mod3_w, acc3, mod0_w, mod1_w, + mod2_w, mod3_w); ST_SW2(mod0_w, mod1_w, acc, 4); acc += 8; @@ -230,8 +224,8 @@ static void temporal_filter_apply_16size_msa(uint8_t *frm1_ptr, UNPCK_SH_SW(diff1, diff1_r, diff1_l); MUL4(diff0_r, diff0_r, diff0_l, diff0_l, diff1_r, diff1_r, diff1_l, diff1_l, mod0_w, mod1_w, mod2_w, mod3_w); - MUL4(mod0_w, cnst3, mod1_w, cnst3, mod2_w, cnst3, mod3_w, cnst3, - mod0_w, mod1_w, mod2_w, mod3_w); + MUL4(mod0_w, cnst3, mod1_w, cnst3, mod2_w, cnst3, mod3_w, cnst3, mod0_w, + mod1_w, mod2_w, mod3_w); SRAR_W4_SW(mod0_w, mod1_w, mod2_w, mod3_w, strength); diff0_r = (mod0_w < cnst16); @@ -239,8 +233,8 @@ static void temporal_filter_apply_16size_msa(uint8_t *frm1_ptr, diff1_r = (mod2_w < cnst16); diff1_l = (mod3_w < cnst16); - SUB4(cnst16, mod0_w, cnst16, mod1_w, cnst16, mod2_w, cnst16, mod3_w, - mod0_w, mod1_w, mod2_w, mod3_w); + SUB4(cnst16, mod0_w, cnst16, mod1_w, cnst16, mod2_w, cnst16, mod3_w, mod0_w, + mod1_w, mod2_w, mod3_w); mod0_w = diff0_r & mod0_w; mod1_w = diff0_l & mod1_w; @@ -259,8 +253,8 @@ static void temporal_filter_apply_16size_msa(uint8_t *frm1_ptr, UNPCK_SH_SW(frm2_l, frm2_lr, frm2_ll); MUL4(mod0_w, frm2_rr, mod1_w, frm2_rl, mod2_w, frm2_lr, mod3_w, frm2_ll, mod0_w, mod1_w, mod2_w, mod3_w); - ADD4(mod0_w, acc0, mod1_w, acc1, mod2_w, acc2, mod3_w, acc3, - mod0_w, mod1_w, mod2_w, mod3_w); + ADD4(mod0_w, acc0, mod1_w, acc1, mod2_w, acc2, mod3_w, acc3, mod0_w, mod1_w, + mod2_w, mod3_w); ST_SW2(mod0_w, mod1_w, acc, 4); acc += 8; ST_SW2(mod2_w, mod3_w, acc, 4); @@ -272,18 +266,18 @@ static void temporal_filter_apply_16size_msa(uint8_t *frm1_ptr, } void vp10_temporal_filter_apply_msa(uint8_t *frame1_ptr, uint32_t stride, - uint8_t *frame2_ptr, uint32_t blk_w, - uint32_t blk_h, int32_t strength, - int32_t filt_wgt, uint32_t *accu, - uint16_t *cnt) { + uint8_t *frame2_ptr, uint32_t blk_w, + uint32_t blk_h, int32_t strength, + int32_t filt_wgt, uint32_t *accu, + uint16_t *cnt) { if (8 == (blk_w * blk_h)) { - temporal_filter_apply_8size_msa(frame1_ptr, stride, frame2_ptr, - strength, filt_wgt, accu, cnt); + temporal_filter_apply_8size_msa(frame1_ptr, stride, frame2_ptr, strength, + filt_wgt, accu, cnt); } else if (16 == (blk_w * blk_h)) { - temporal_filter_apply_16size_msa(frame1_ptr, stride, frame2_ptr, - strength, filt_wgt, accu, cnt); + temporal_filter_apply_16size_msa(frame1_ptr, stride, frame2_ptr, strength, + filt_wgt, accu, cnt); } else { vp10_temporal_filter_apply_c(frame1_ptr, stride, frame2_ptr, blk_w, blk_h, - strength, filt_wgt, accu, cnt); + strength, filt_wgt, accu, cnt); } } diff --git a/vp10/encoder/palette.c b/vp10/encoder/palette.c index d52e5fe9d..97cf14c88 100644 --- a/vp10/encoder/palette.c +++ b/vp10/encoder/palette.c @@ -68,20 +68,19 @@ static void calc_centroids(const float *data, float *centroids, for (i = 0; i < k; ++i) { if (count[i] == 0) { memcpy(centroids + i * dim, data + (lcg_rand16(&rand_state) % n) * dim, - sizeof(centroids[0]) * dim); + sizeof(centroids[0]) * dim); } else { const float norm = 1.0f / count[i]; - for (j = 0; j < dim; ++j) - centroids[i * dim + j] *= norm; + for (j = 0; j < dim; ++j) centroids[i * dim + j] *= norm; } } } static float calc_total_dist(const float *data, const float *centroids, - const uint8_t *indices, int n, int k, int dim) { + const uint8_t *indices, int n, int k, int dim) { float dist = 0; int i; - (void) k; + (void)k; for (i = 0; i < n; ++i) dist += calc_dist(data + i * dim, centroids + indices[i] * dim, dim); @@ -188,5 +187,3 @@ int vp10_count_colors_highbd(const uint8_t *src8, int stride, int rows, return n; } #endif // CONFIG_VP9_HIGHBITDEPTH - - diff --git a/vp10/encoder/picklpf.c b/vp10/encoder/picklpf.c index 9e0e72a85..9fd7713c3 100644 --- a/vp10/encoder/picklpf.c +++ b/vp10/encoder/picklpf.c @@ -36,8 +36,8 @@ int vp10_get_max_filter_level(const VP10_COMP *cpi) { } static int64_t try_filter_frame(const YV12_BUFFER_CONFIG *sd, - VP10_COMP *const cpi, - int filt_level, int partial_frame) { + VP10_COMP *const cpi, int filt_level, + int partial_frame) { VP10_COMMON *const cm = &cpi->common; int64_t filt_err; @@ -47,9 +47,8 @@ static int64_t try_filter_frame(const YV12_BUFFER_CONFIG *sd, #else if (cpi->num_workers > 1) vp10_loop_filter_frame_mt(cm->frame_to_show, cm, cpi->td.mb.e_mbd.plane, - filt_level, 1, partial_frame, - cpi->workers, cpi->num_workers, - &cpi->lf_row_sync); + filt_level, 1, partial_frame, cpi->workers, + cpi->num_workers, &cpi->lf_row_sync); else vp10_loop_filter_frame(cm->frame_to_show, cm, &cpi->td.mb.e_mbd, filt_level, 1, partial_frame); @@ -110,8 +109,7 @@ int vp10_search_filter_level(const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, bias = (bias * cpi->twopass.section_intra_rating) / 20; // yx, bias less for large block size - if (cm->tx_mode != ONLY_4X4) - bias >>= 1; + if (cm->tx_mode != ONLY_4X4) bias >>= 1; if (filt_direction <= 0 && filt_low != filt_mid) { // Get Low filter error score @@ -162,21 +160,20 @@ int vp10_search_filter_level(const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, #if !CONFIG_LOOP_RESTORATION void vp10_pick_filter_level(const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, - LPF_PICK_METHOD method) { + LPF_PICK_METHOD method) { VP10_COMMON *const cm = &cpi->common; struct loopfilter *const lf = &cm->lf; - lf->sharpness_level = cm->frame_type == KEY_FRAME ? 0 - : cpi->oxcf.sharpness; + lf->sharpness_level = cm->frame_type == KEY_FRAME ? 0 : cpi->oxcf.sharpness; if (method == LPF_PICK_MINIMAL_LPF && lf->filter_level) { - lf->filter_level = 0; + lf->filter_level = 0; } else if (method >= LPF_PICK_FROM_Q) { const int min_filter_level = 0; const int max_filter_level = vp10_get_max_filter_level(cpi); const int q = vp10_ac_quant(cm->base_qindex, 0, cm->bit_depth); - // These values were determined by linear fitting the result of the - // searched level, filt_guess = q * 0.316206 + 3.87252 +// These values were determined by linear fitting the result of the +// searched level, filt_guess = q * 0.316206 + 3.87252 #if CONFIG_VP9_HIGHBITDEPTH int filt_guess; switch (cm->bit_depth) { @@ -190,15 +187,15 @@ void vp10_pick_filter_level(const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 16242526, 22); break; default: - assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 " - "or VPX_BITS_12"); + assert(0 && + "bit_depth should be VPX_BITS_8, VPX_BITS_10 " + "or VPX_BITS_12"); return; } #else int filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 1015158, 18); #endif // CONFIG_VP9_HIGHBITDEPTH - if (cm->frame_type == KEY_FRAME) - filt_guess -= 4; + if (cm->frame_type == KEY_FRAME) filt_guess -= 4; lf->filter_level = clamp(filt_guess, min_filter_level, max_filter_level); } else { lf->filter_level = vp10_search_filter_level( diff --git a/vp10/encoder/picklpf.h b/vp10/encoder/picklpf.h index 29ec97609..994dde571 100644 --- a/vp10/encoder/picklpf.h +++ b/vp10/encoder/picklpf.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_PICKLPF_H_ #define VP10_ENCODER_PICKLPF_H_ diff --git a/vp10/encoder/pickrst.c b/vp10/encoder/pickrst.c index fa0106245..02fd273ec 100644 --- a/vp10/encoder/pickrst.c +++ b/vp10/encoder/pickrst.c @@ -29,13 +29,11 @@ #include "vp10/encoder/pickrst.h" static int64_t try_restoration_frame(const YV12_BUFFER_CONFIG *sd, - VP10_COMP *const cpi, - RestorationInfo *rsi, + VP10_COMP *const cpi, RestorationInfo *rsi, int partial_frame) { VP10_COMMON *const cm = &cpi->common; int64_t filt_err; - vp10_loop_restoration_frame(cm->frame_to_show, cm, - rsi, 1, partial_frame); + vp10_loop_restoration_frame(cm->frame_to_show, cm, rsi, 1, partial_frame); #if CONFIG_VP9_HIGHBITDEPTH if (cm->use_highbitdepth) { filt_err = vpx_highbd_get_y_sse(sd, cm->frame_to_show); @@ -51,8 +49,7 @@ static int64_t try_restoration_frame(const YV12_BUFFER_CONFIG *sd, return filt_err; } -static int search_bilateral_level(const YV12_BUFFER_CONFIG *sd, - VP10_COMP *cpi, +static int search_bilateral_level(const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, int filter_level, int partial_frame, double *best_cost_ret) { VP10_COMMON *const cm = &cpi->common; @@ -76,8 +73,8 @@ static int search_bilateral_level(const YV12_BUFFER_CONFIG *sd, rsi.restoration_type = RESTORE_NONE; err = try_restoration_frame(sd, cpi, &rsi, partial_frame); bits = 0; - best_cost = RDCOST_DBL(x->rdmult, x->rddiv, - (bits << (VP9_PROB_COST_SHIFT - 4)), err); + best_cost = + RDCOST_DBL(x->rdmult, x->rddiv, (bits << (VP9_PROB_COST_SHIFT - 4)), err); for (i = 0; i < restoration_levels; ++i) { rsi.restoration_type = RESTORE_BILATERAL; rsi.restoration_level = i; @@ -86,8 +83,8 @@ static int search_bilateral_level(const YV12_BUFFER_CONFIG *sd, // when RDCOST is used. However below we just scale both in the correct // ratios appropriately but not exactly by these values. bits = restoration_level_bits; - cost = RDCOST_DBL(x->rdmult, x->rddiv, - (bits << (VP9_PROB_COST_SHIFT - 4)), err); + cost = RDCOST_DBL(x->rdmult, x->rddiv, (bits << (VP9_PROB_COST_SHIFT - 4)), + err); if (cost < best_cost) { restoration_best = i; best_cost = cost; @@ -99,8 +96,7 @@ static int search_bilateral_level(const YV12_BUFFER_CONFIG *sd, } static int search_filter_bilateral_level(const YV12_BUFFER_CONFIG *sd, - VP10_COMP *cpi, - int partial_frame, + VP10_COMP *cpi, int partial_frame, int *restoration_level, double *best_cost_ret) { const VP10_COMMON *const cm = &cpi->common; @@ -120,11 +116,10 @@ static int search_filter_bilateral_level(const YV12_BUFFER_CONFIG *sd, double ss_err[MAX_LOOP_FILTER + 1]; // Set each entry to -1 - for (i = 0; i <= MAX_LOOP_FILTER; ++i) - ss_err[i] = -1.0; + for (i = 0; i <= MAX_LOOP_FILTER; ++i) ss_err[i] = -1.0; - bilateral_lev = search_bilateral_level(sd, cpi, filt_mid, - partial_frame, &best_err); + bilateral_lev = + search_bilateral_level(sd, cpi, filt_mid, partial_frame, &best_err); filt_best = filt_mid; restoration_best = bilateral_lev; ss_err[filt_mid] = best_err; @@ -140,14 +135,13 @@ static int search_filter_bilateral_level(const YV12_BUFFER_CONFIG *sd, bias = (bias * cpi->twopass.section_intra_rating) / 20; // yx, bias less for large block size - if (cm->tx_mode != ONLY_4X4) - bias /= 2; + if (cm->tx_mode != ONLY_4X4) bias /= 2; if (filt_direction <= 0 && filt_low != filt_mid) { // Get Low filter error score if (ss_err[filt_low] < 0) { - bilateral_lev = search_bilateral_level( - sd, cpi, filt_low, partial_frame, &ss_err[filt_low]); + bilateral_lev = search_bilateral_level(sd, cpi, filt_low, partial_frame, + &ss_err[filt_low]); } // If value is close to the best so far then bias towards a lower loop // filter value. @@ -199,15 +193,14 @@ static double find_average(uint8_t *src, int width, int height, int stride) { double avg = 0; int i, j; for (i = 0; i < height; i++) - for (j = 0; j < width; j++) - sum += src[i * stride + j]; + for (j = 0; j < width; j++) sum += src[i * stride + j]; avg = (double)sum / (height * width); return avg; } static void compute_stats(uint8_t *dgd, uint8_t *src, int width, int height, - int dgd_stride, int src_stride, - double *M, double *H) { + int dgd_stride, int src_stride, double *M, + double *H) { int i, j, k, l; double Y[RESTORATION_WIN2]; const double avg = find_average(dgd, width, height, dgd_stride); @@ -238,21 +231,20 @@ static void compute_stats(uint8_t *dgd, uint8_t *src, int width, int height, } #if CONFIG_VP9_HIGHBITDEPTH -static double find_average_highbd(uint16_t *src, - int width, int height, int stride) { +static double find_average_highbd(uint16_t *src, int width, int height, + int stride) { uint64_t sum = 0; double avg = 0; int i, j; for (i = 0; i < height; i++) - for (j = 0; j < width; j++) - sum += src[i * stride + j]; + for (j = 0; j < width; j++) sum += src[i * stride + j]; avg = (double)sum / (height * width); return avg; } -static void compute_stats_highbd( - uint8_t *dgd8, uint8_t *src8, int width, int height, - int dgd_stride, int src_stride, double *M, double *H) { +static void compute_stats_highbd(uint8_t *dgd8, uint8_t *src8, int width, + int height, int dgd_stride, int src_stride, + double *M, double *H) { int i, j, k, l; double Y[RESTORATION_WIN2]; uint16_t *src = CONVERT_TO_SHORTPTR(src8); @@ -306,18 +298,15 @@ static int linsolve(int n, double *A, int stride, double *b, double *x) { for (k = 0; k < n - 1; k++) { for (i = k; i < n - 1; i++) { c = A[(i + 1) * stride + k] / A[k * stride + k]; - for (j = 0; j < n; j++) - A[(i + 1) * stride + j] -= c * A[k * stride + j]; + for (j = 0; j < n; j++) A[(i + 1) * stride + j] -= c * A[k * stride + j]; b[i + 1] -= c * b[k]; } } // Backward substitution for (i = n - 1; i >= 0; i--) { - if (fabs(A[i * stride + i]) < 1e-10) - return 0; + if (fabs(A[i * stride + i]) < 1e-10) return 0; c = 0; - for (j = i + 1; j <= n - 1; j++) - c += A[i * stride + j] * x[j]; + for (j = i + 1; j <= n - 1; j++) c += A[i * stride + j] * x[j]; x[i] = (b[i] - c) / A[i * stride + i]; } return 1; @@ -335,23 +324,23 @@ static void update_a_sep_sym(double **Mc, double **Hc, double *a, double *b) { int w, w2; memset(A, 0, sizeof(A)); memset(B, 0, sizeof(B)); - for (i = 0; i < RESTORATION_WIN; i ++) { + for (i = 0; i < RESTORATION_WIN; i++) { int j; for (j = 0; j < RESTORATION_WIN; ++j) { const int jj = wrap_index(j); A[jj] += Mc[i][j] * b[i]; } } - for (i = 0; i < RESTORATION_WIN; i ++) { - for (j = 0; j < RESTORATION_WIN; j ++) { + for (i = 0; i < RESTORATION_WIN; i++) { + for (j = 0; j < RESTORATION_WIN; j++) { int k, l; for (k = 0; k < RESTORATION_WIN; ++k) for (l = 0; l < RESTORATION_WIN; ++l) { const int kk = wrap_index(k); const int ll = wrap_index(l); B[ll * RESTORATION_HALFWIN1 + kk] += - Hc[j * RESTORATION_WIN + i][k * RESTORATION_WIN2 + l] * - b[i] * b[j]; + Hc[j * RESTORATION_WIN + i][k * RESTORATION_WIN2 + l] * b[i] * + b[j]; } } } @@ -359,8 +348,8 @@ static void update_a_sep_sym(double **Mc, double **Hc, double *a, double *b) { w = RESTORATION_WIN; w2 = (w >> 1) + 1; for (i = 0; i < w2 - 1; ++i) - A[i] -= A[w2 - 1] * 2 + B[i * w2 + w2 - 1] - - 2 * B[(w2 - 1) * w2 + (w2 - 1)]; + A[i] -= + A[w2 - 1] * 2 + B[i * w2 + w2 - 1] - 2 * B[(w2 - 1) * w2 + (w2 - 1)]; for (i = 0; i < w2 - 1; ++i) for (j = 0; j < w2 - 1; ++j) B[i * w2 + j] -= 2 * (B[i * w2 + (w2 - 1)] + B[(w2 - 1) * w2 + j] - @@ -383,11 +372,10 @@ static void update_b_sep_sym(double **Mc, double **Hc, double *a, double *b) { int w, w2; memset(A, 0, sizeof(A)); memset(B, 0, sizeof(B)); - for (i = 0; i < RESTORATION_WIN; i ++) { + for (i = 0; i < RESTORATION_WIN; i++) { int j; const int ii = wrap_index(i); - for (j = 0; j < RESTORATION_WIN; j ++) - A[ii] += Mc[i][j] * a[j]; + for (j = 0; j < RESTORATION_WIN; j++) A[ii] += Mc[i][j] * a[j]; } for (i = 0; i < RESTORATION_WIN; i++) { @@ -398,16 +386,16 @@ static void update_b_sep_sym(double **Mc, double **Hc, double *a, double *b) { for (k = 0; k < RESTORATION_WIN; ++k) for (l = 0; l < RESTORATION_WIN; ++l) B[jj * RESTORATION_HALFWIN1 + ii] += - Hc[i * RESTORATION_WIN + j][k * RESTORATION_WIN2 + l] * - a[k] * a[l]; + Hc[i * RESTORATION_WIN + j][k * RESTORATION_WIN2 + l] * a[k] * + a[l]; } } // Normalization enforcement in the system of equations itself w = RESTORATION_WIN; w2 = RESTORATION_HALFWIN1; for (i = 0; i < w2 - 1; ++i) - A[i] -= A[w2 - 1] * 2 + B[i * w2 + w2 - 1] - - 2 * B[(w2 - 1) * w2 + (w2 - 1)]; + A[i] -= + A[w2 - 1] * 2 + B[i * w2 + w2 - 1] - 2 * B[(w2 - 1) * w2 + (w2 - 1)]; for (i = 0; i < w2 - 1; ++i) for (j = 0; j < w2 - 1; ++j) B[i * w2 + j] -= 2 * (B[i * w2 + (w2 - 1)] + B[(w2 - 1) * w2 + j] - @@ -422,10 +410,10 @@ static void update_b_sep_sym(double **Mc, double **Hc, double *a, double *b) { } } -static int wiener_decompose_sep_sym(double *M, double *H, - double *a, double *b) { +static int wiener_decompose_sep_sym(double *M, double *H, double *a, + double *b) { static const double init_filt[RESTORATION_WIN] = { - 0.035623, -0.127154, 0.211436, 0.760190, 0.211436, -0.127154, 0.035623, + 0.035623, -0.127154, 0.211436, 0.760190, 0.211436, -0.127154, 0.035623, }; int i, j, iter; double *Hc[RESTORATION_WIN2]; @@ -452,7 +440,7 @@ static int wiener_decompose_sep_sym(double *M, double *H, // Computes the function x'*A*x - x'*b for the learned filters, and compares // against identity filters; Final score is defined as the difference between // the function values - static double compute_score(double *M, double *H, int *vfilt, int *hfilt) { +static double compute_score(double *M, double *H, int *vfilt, int *hfilt) { double ab[RESTORATION_WIN * RESTORATION_WIN]; int i, k, l; double P = 0, Q = 0; @@ -463,10 +451,10 @@ static int wiener_decompose_sep_sym(double *M, double *H, w = RESTORATION_WIN; a[RESTORATION_HALFWIN] = b[RESTORATION_HALFWIN] = 1.0; for (i = 0; i < RESTORATION_HALFWIN; ++i) { - a[i] = a[RESTORATION_WIN - i - 1 ] = - (double) vfilt[i] / RESTORATION_FILT_STEP; - b[i] = b[RESTORATION_WIN - i - 1 ] = - (double) hfilt[i] / RESTORATION_FILT_STEP; + a[i] = a[RESTORATION_WIN - i - 1] = + (double)vfilt[i] / RESTORATION_FILT_STEP; + b[i] = b[RESTORATION_WIN - i - 1] = + (double)hfilt[i] / RESTORATION_FILT_STEP; a[RESTORATION_HALFWIN] -= 2 * a[i]; b[RESTORATION_HALFWIN] -= 2 * b[i]; } @@ -477,8 +465,7 @@ static int wiener_decompose_sep_sym(double *M, double *H, } for (k = 0; k < w * w; ++k) { P += ab[k] * M[k]; - for (l = 0; l < w * w; ++l) - Q += ab[k] * H[k * w * w + l] * ab[l]; + for (l = 0; l < w * w; ++l) Q += ab[k] * H[k * w * w + l] * ab[l]; } Score = Q - 2 * P; @@ -490,7 +477,7 @@ static int wiener_decompose_sep_sym(double *M, double *H, } #define CLIP(x, lo, hi) ((x) < (lo) ? (lo) : (x) > (hi) ? (hi) : (x)) -#define RINT(x) ((x) < 0 ? (int)((x) - 0.5) : (int)((x) + 0.5)) +#define RINT(x) ((x) < 0 ? (int)((x)-0.5) : (int)((x) + 0.5)) static void quantize_sym_filter(double *f, int *fi) { int i; @@ -503,10 +490,8 @@ static void quantize_sym_filter(double *f, int *fi) { fi[2] = CLIP(fi[2], WIENER_FILT_TAP2_MINV, WIENER_FILT_TAP2_MAXV); } -static int search_wiener_filter(const YV12_BUFFER_CONFIG *src, - VP10_COMP *cpi, - int filter_level, - int partial_frame, +static int search_wiener_filter(const YV12_BUFFER_CONFIG *src, VP10_COMP *cpi, + int filter_level, int partial_frame, int *vfilter, int *hfilter, double *best_cost_ret) { VP10_COMMON *const cm = &cpi->common; @@ -539,8 +524,8 @@ static int search_wiener_filter(const YV12_BUFFER_CONFIG *src, rsi.restoration_type = RESTORE_NONE; err = try_restoration_frame(src, cpi, &rsi, partial_frame); bits = 0; - cost_norestore = RDCOST_DBL(x->rdmult, x->rddiv, - (bits << (VP9_PROB_COST_SHIFT - 4)), err); + cost_norestore = + RDCOST_DBL(x->rdmult, x->rddiv, (bits << (VP9_PROB_COST_SHIFT - 4)), err); #if CONFIG_VP9_HIGHBITDEPTH if (cm->use_highbitdepth) @@ -548,8 +533,8 @@ static int search_wiener_filter(const YV12_BUFFER_CONFIG *src, dgd_stride, src_stride, M, H); else #endif // CONFIG_VP9_HIGHBITDEPTH - compute_stats(dgd->y_buffer, src->y_buffer, width, height, - dgd_stride, src_stride, M, H); + compute_stats(dgd->y_buffer, src->y_buffer, width, height, dgd_stride, + src_stride, M, H); if (!wiener_decompose_sep_sym(M, H, vfilterd, hfilterd)) { *best_cost_ret = DBL_MAX; @@ -564,8 +549,7 @@ static int search_wiener_filter(const YV12_BUFFER_CONFIG *src, score = compute_score(M, H, vfilter, hfilter); if (score > 0.0) { int i; - for (i = 0; i < RESTORATION_HALFWIN; ++i) - vfilter[i] = hfilter[i] = 0; + for (i = 0; i < RESTORATION_HALFWIN; ++i) vfilter[i] = hfilter[i] = 0; rsi.restoration_type = RESTORE_NONE; if (best_cost_ret) *best_cost_ret = cost_norestore; vpx_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show); @@ -577,8 +561,8 @@ static int search_wiener_filter(const YV12_BUFFER_CONFIG *src, memcpy(rsi.hfilter, hfilter, sizeof(rsi.hfilter)); err = try_restoration_frame(src, cpi, &rsi, partial_frame); bits = WIENER_FILT_BITS; - cost_wiener = RDCOST_DBL(x->rdmult, x->rddiv, - (bits << (VP9_PROB_COST_SHIFT - 4)), err); + cost_wiener = + RDCOST_DBL(x->rdmult, x->rddiv, (bits << (VP9_PROB_COST_SHIFT - 4)), err); vpx_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show); @@ -591,8 +575,8 @@ static int search_wiener_filter(const YV12_BUFFER_CONFIG *src, } } -void vp10_pick_filter_restoration( - const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, LPF_PICK_METHOD method) { +void vp10_pick_filter_restoration(const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, + LPF_PICK_METHOD method) { VP10_COMMON *const cm = &cpi->common; struct loopfilter *const lf = &cm->lf; int wiener_success = 0; @@ -600,18 +584,17 @@ void vp10_pick_filter_restoration( double cost_wiener = DBL_MAX; double cost_norestore = DBL_MAX; - lf->sharpness_level = - cm->frame_type == KEY_FRAME ? 0 : cpi->oxcf.sharpness; + lf->sharpness_level = cm->frame_type == KEY_FRAME ? 0 : cpi->oxcf.sharpness; if (method == LPF_PICK_MINIMAL_LPF && lf->filter_level) { - lf->filter_level = 0; - cm->rst_info.restoration_type = RESTORE_NONE; + lf->filter_level = 0; + cm->rst_info.restoration_type = RESTORE_NONE; } else if (method >= LPF_PICK_FROM_Q) { const int min_filter_level = 0; const int max_filter_level = vp10_get_max_filter_level(cpi); const int q = vp10_ac_quant(cm->base_qindex, 0, cm->bit_depth); - // These values were determined by linear fitting the result of the - // searched level, filt_guess = q * 0.316206 + 3.87252 +// These values were determined by linear fitting the result of the +// searched level, filt_guess = q * 0.316206 + 3.87252 #if CONFIG_VP9_HIGHBITDEPTH int filt_guess; switch (cm->bit_depth) { @@ -625,15 +608,15 @@ void vp10_pick_filter_restoration( filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 16242526, 22); break; default: - assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 " - "or VPX_BITS_12"); + assert(0 && + "bit_depth should be VPX_BITS_8, VPX_BITS_10 " + "or VPX_BITS_12"); return; } #else int filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 1015158, 18); #endif // CONFIG_VP9_HIGHBITDEPTH - if (cm->frame_type == KEY_FRAME) - filt_guess -= 4; + if (cm->frame_type == KEY_FRAME) filt_guess -= 4; lf->filter_level = clamp(filt_guess, min_filter_level, max_filter_level); cm->rst_info.restoration_level = search_bilateral_level( sd, cpi, lf->filter_level, method == LPF_PICK_FROM_SUBIMAGE, diff --git a/vp10/encoder/pickrst.h b/vp10/encoder/pickrst.h index 8e2340dfc..01e7cba98 100644 --- a/vp10/encoder/pickrst.h +++ b/vp10/encoder/pickrst.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_PICKRST_H_ #define VP10_ENCODER_PICKRST_H_ @@ -21,8 +20,8 @@ extern "C" { struct yv12_buffer_config; struct VP10_COMP; -void vp10_pick_filter_restoration( - const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, LPF_PICK_METHOD method); +void vp10_pick_filter_restoration(const YV12_BUFFER_CONFIG *sd, VP10_COMP *cpi, + LPF_PICK_METHOD method); #ifdef __cplusplus } // extern "C" diff --git a/vp10/encoder/quantize.c b/vp10/encoder/quantize.c index 22863e2e2..75958a4ab 100644 --- a/vp10/encoder/quantize.c +++ b/vp10/encoder/quantize.c @@ -23,14 +23,11 @@ #include "vp10/encoder/rd.h" #if CONFIG_NEW_QUANT -static INLINE int quantize_coeff_nuq(const tran_low_t coeffv, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr) { +static INLINE int quantize_coeff_nuq( + const tran_low_t coeffv, const int16_t quant, const int16_t quant_shift, + const int16_t dequant, const tran_low_t *cuml_bins_ptr, + const tran_low_t *dequant_val, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr) { const int coeff = coeffv; const int coeff_sign = (coeff >> 31); const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign; @@ -47,9 +44,8 @@ static INLINE int quantize_coeff_nuq(const tran_low_t coeffv, q = NUQ_KNOTS + (((((tmp * quant) >> 16) + tmp) * quant_shift) >> 16); } if (q) { - *dqcoeff_ptr = - vp10_dequant_abscoeff_nuq(q, dequant, dequant_val); - *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; + *dqcoeff_ptr = vp10_dequant_abscoeff_nuq(q, dequant, dequant_val); + *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; *dqcoeff_ptr = *qcoeff_ptr < 0 ? -*dqcoeff_ptr : *dqcoeff_ptr; } else { *qcoeff_ptr = 0; @@ -58,15 +54,11 @@ static INLINE int quantize_coeff_nuq(const tran_low_t coeffv, return (q != 0); } -static INLINE int quantize_coeff_bigtx_nuq(const tran_low_t coeffv, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - int logsizeby32) { +static INLINE int quantize_coeff_bigtx_nuq( + const tran_low_t coeffv, const int16_t quant, const int16_t quant_shift, + const int16_t dequant, const tran_low_t *cuml_bins_ptr, + const tran_low_t *dequant_val, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, int logsizeby32) { const int coeff = coeffv; const int coeff_sign = (coeff >> 31); const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign; @@ -84,12 +76,11 @@ static INLINE int quantize_coeff_bigtx_nuq(const tran_low_t coeffv, (((((tmp * quant) >> 16) + tmp) * quant_shift) >> (15 - logsizeby32)); } if (q) { - *dqcoeff_ptr = - ROUND_POWER_OF_TWO(vp10_dequant_abscoeff_nuq(q, dequant, dequant_val), - 1 + logsizeby32); + *dqcoeff_ptr = ROUND_POWER_OF_TWO( + vp10_dequant_abscoeff_nuq(q, dequant, dequant_val), 1 + logsizeby32); // *dqcoeff_ptr = vp10_dequant_abscoeff_nuq(q, dequant, dequant_val) >> // (1 + logsizeby32); - *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; + *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; *dqcoeff_ptr = *qcoeff_ptr < 0 ? -*dqcoeff_ptr : *dqcoeff_ptr; } else { *qcoeff_ptr = 0; @@ -98,13 +89,10 @@ static INLINE int quantize_coeff_bigtx_nuq(const tran_low_t coeffv, return (q != 0); } -static INLINE int quantize_coeff_fp_nuq(const tran_low_t coeffv, - const int16_t quant, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr) { +static INLINE int quantize_coeff_fp_nuq( + const tran_low_t coeffv, const int16_t quant, const int16_t dequant, + const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr) { const int coeff = coeffv; const int coeff_sign = (coeff >> 31); const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign; @@ -121,9 +109,8 @@ static INLINE int quantize_coeff_fp_nuq(const tran_low_t coeffv, ((((int64_t)tmp - cuml_bins_ptr[NUQ_KNOTS - 1]) * quant) >> 16); } if (q) { - *dqcoeff_ptr = - vp10_dequant_abscoeff_nuq(q, dequant, dequant_val); - *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; + *dqcoeff_ptr = vp10_dequant_abscoeff_nuq(q, dequant, dequant_val); + *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; *dqcoeff_ptr = *qcoeff_ptr < 0 ? -*dqcoeff_ptr : *dqcoeff_ptr; } else { *qcoeff_ptr = 0; @@ -132,14 +119,10 @@ static INLINE int quantize_coeff_fp_nuq(const tran_low_t coeffv, return (q != 0); } -static INLINE int quantize_coeff_bigtx_fp_nuq(const tran_low_t coeffv, - const int16_t quant, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - int logsizeby32) { +static INLINE int quantize_coeff_bigtx_fp_nuq( + const tran_low_t coeffv, const int16_t quant, const int16_t dequant, + const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, int logsizeby32) { const int coeff = coeffv; const int coeff_sign = (coeff >> 31); const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign; @@ -153,17 +136,17 @@ static INLINE int quantize_coeff_bigtx_fp_nuq(const tran_low_t coeffv, } if (i == NUQ_KNOTS) { q = NUQ_KNOTS + - ((((int64_t)tmp - ROUND_POWER_OF_TWO(cuml_bins_ptr[NUQ_KNOTS - 1], - 1 + logsizeby32)) * quant) >> + ((((int64_t)tmp - + ROUND_POWER_OF_TWO(cuml_bins_ptr[NUQ_KNOTS - 1], 1 + logsizeby32)) * + quant) >> (15 - logsizeby32)); } if (q) { - *dqcoeff_ptr = - ROUND_POWER_OF_TWO(vp10_dequant_abscoeff_nuq(q, dequant, dequant_val), - 1 + logsizeby32); + *dqcoeff_ptr = ROUND_POWER_OF_TWO( + vp10_dequant_abscoeff_nuq(q, dequant, dequant_val), 1 + logsizeby32); // *dqcoeff_ptr = vp10_dequant_abscoeff_nuq(q, dequant, dequant_val) >> // (1 + logsizeby32); - *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; + *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; *dqcoeff_ptr = *qcoeff_ptr < 0 ? -*dqcoeff_ptr : *dqcoeff_ptr; } else { *qcoeff_ptr = 0; @@ -172,132 +155,88 @@ static INLINE int quantize_coeff_bigtx_fp_nuq(const tran_low_t coeffv, return (q != 0); } -void quantize_dc_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, +void quantize_dc_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, + const int16_t quant_shift, const int16_t dequant, const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr) { + const tran_low_t *dequant_val, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); if (!skip_block) { const int rc = 0; - if (quantize_coeff_nuq(coeff_ptr[rc], - quant, - quant_shift, - dequant, - cuml_bins_ptr, - dequant_val, - qcoeff_ptr, - dqcoeff_ptr)) + if (quantize_coeff_nuq(coeff_ptr[rc], quant, quant_shift, dequant, + cuml_bins_ptr, dequant_val, qcoeff_ptr, dqcoeff_ptr)) eob = 0; } *eob_ptr = eob + 1; } -void quantize_dc_fp_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr) { +void quantize_dc_fp_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, + const int16_t dequant, const tran_low_t *cuml_bins_ptr, + const tran_low_t *dequant_val, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); if (!skip_block) { const int rc = 0; - if (quantize_coeff_fp_nuq(coeff_ptr[rc], - quant, - dequant, - cuml_bins_ptr, - dequant_val, - qcoeff_ptr, - dqcoeff_ptr)) + if (quantize_coeff_fp_nuq(coeff_ptr[rc], quant, dequant, cuml_bins_ptr, + dequant_val, qcoeff_ptr, dqcoeff_ptr)) eob = 0; } *eob_ptr = eob + 1; } -void quantize_dc_32x32_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, +void quantize_dc_32x32_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, + const int16_t quant_shift, const int16_t dequant, const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); if (!skip_block) { const int rc = 0; - if (quantize_coeff_bigtx_nuq(coeff_ptr[rc], - quant, - quant_shift, - dequant, - cuml_bins_ptr, - dequant_val, - qcoeff_ptr, - dqcoeff_ptr, - 0)) + if (quantize_coeff_bigtx_nuq(coeff_ptr[rc], quant, quant_shift, dequant, + cuml_bins_ptr, dequant_val, qcoeff_ptr, + dqcoeff_ptr, 0)) eob = 0; } *eob_ptr = eob + 1; } -void quantize_dc_32x32_fp_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, +void quantize_dc_32x32_fp_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, const int16_t dequant, const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); if (!skip_block) { const int rc = 0; - if (quantize_coeff_bigtx_fp_nuq(coeff_ptr[rc], - quant, - dequant, - cuml_bins_ptr, - dequant_val, - qcoeff_ptr, - dqcoeff_ptr, - 0)) + if (quantize_coeff_bigtx_fp_nuq(coeff_ptr[rc], quant, dequant, + cuml_bins_ptr, dequant_val, qcoeff_ptr, + dqcoeff_ptr, 0)) eob = 0; } *eob_ptr = eob + 1; } -void quantize_nuq_c(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t *quant_ptr, - const int16_t *quant_shift_ptr, - const int16_t *dequant_ptr, +void quantize_nuq_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t *quant_ptr, + const int16_t *quant_shift_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr, - const int16_t *scan, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, + uint16_t *eob_ptr, const int16_t *scan, const uint8_t *band) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); @@ -306,31 +245,23 @@ void quantize_nuq_c(const tran_low_t *coeff_ptr, int i; for (i = 0; i < n_coeffs; i++) { const int rc = scan[i]; - if (quantize_coeff_nuq(coeff_ptr[rc], - quant_ptr[rc != 0], - quant_shift_ptr[rc != 0], - dequant_ptr[rc != 0], - cuml_bins_ptr[band[i]], - dequant_val[band[i]], - &qcoeff_ptr[rc], - &dqcoeff_ptr[rc])) + if (quantize_coeff_nuq(coeff_ptr[rc], quant_ptr[rc != 0], + quant_shift_ptr[rc != 0], dequant_ptr[rc != 0], + cuml_bins_ptr[band[i]], dequant_val[band[i]], + &qcoeff_ptr[rc], &dqcoeff_ptr[rc])) eob = i; } } *eob_ptr = eob + 1; } -void quantize_fp_nuq_c(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t *quant_ptr, +void quantize_fp_nuq_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t *quant_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr, - const int16_t *scan, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, + uint16_t *eob_ptr, const int16_t *scan, const uint8_t *band) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); @@ -339,12 +270,9 @@ void quantize_fp_nuq_c(const tran_low_t *coeff_ptr, int i; for (i = 0; i < n_coeffs; i++) { const int rc = scan[i]; - if (quantize_coeff_fp_nuq(coeff_ptr[rc], - quant_ptr[rc != 0], - dequant_ptr[rc != 0], - cuml_bins_ptr[band[i]], - dequant_val[band[i]], - &qcoeff_ptr[rc], + if (quantize_coeff_fp_nuq(coeff_ptr[rc], quant_ptr[rc != 0], + dequant_ptr[rc != 0], cuml_bins_ptr[band[i]], + dequant_val[band[i]], &qcoeff_ptr[rc], &dqcoeff_ptr[rc])) eob = i; } @@ -352,18 +280,14 @@ void quantize_fp_nuq_c(const tran_low_t *coeff_ptr, *eob_ptr = eob + 1; } -void quantize_32x32_nuq_c(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t *quant_ptr, +void quantize_32x32_nuq_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr, - const int16_t *scan, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, + uint16_t *eob_ptr, const int16_t *scan, const uint8_t *band) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); @@ -372,32 +296,23 @@ void quantize_32x32_nuq_c(const tran_low_t *coeff_ptr, int i; for (i = 0; i < n_coeffs; i++) { const int rc = scan[i]; - if (quantize_coeff_bigtx_nuq(coeff_ptr[rc], - quant_ptr[rc != 0], - quant_shift_ptr[rc != 0], - dequant_ptr[rc != 0], - cuml_bins_ptr[band[i]], - dequant_val[band[i]], - &qcoeff_ptr[rc], - &dqcoeff_ptr[rc], - 0)) + if (quantize_coeff_bigtx_nuq( + coeff_ptr[rc], quant_ptr[rc != 0], quant_shift_ptr[rc != 0], + dequant_ptr[rc != 0], cuml_bins_ptr[band[i]], + dequant_val[band[i]], &qcoeff_ptr[rc], &dqcoeff_ptr[rc], 0)) eob = i; } } *eob_ptr = eob + 1; } -void quantize_32x32_fp_nuq_c(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t *quant_ptr, +void quantize_32x32_fp_nuq_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t *quant_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr, - const int16_t *scan, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, + uint16_t *eob_ptr, const int16_t *scan, const uint8_t *band) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); @@ -406,14 +321,10 @@ void quantize_32x32_fp_nuq_c(const tran_low_t *coeff_ptr, int i; for (i = 0; i < n_coeffs; i++) { const int rc = scan[i]; - if (quantize_coeff_bigtx_fp_nuq(coeff_ptr[rc], - quant_ptr[rc != 0], - dequant_ptr[rc != 0], - cuml_bins_ptr[band[i]], - dequant_val[band[i]], - &qcoeff_ptr[rc], - &dqcoeff_ptr[rc], - 0)) + if (quantize_coeff_bigtx_fp_nuq( + coeff_ptr[rc], quant_ptr[rc != 0], dequant_ptr[rc != 0], + cuml_bins_ptr[band[i]], dequant_val[band[i]], &qcoeff_ptr[rc], + &dqcoeff_ptr[rc], 0)) eob = i; } } @@ -494,10 +405,10 @@ void vp10_highbd_quantize_fp_facade( // obsolete skip_block const int skip_block = 0; - vp10_highbd_quantize_fp(coeff_ptr, n_coeffs, skip_block, p->zbin, - p->round_fp, p->quant_fp, p->quant_shift, - qcoeff_ptr, dqcoeff_ptr, pd->dequant, eob_ptr, - sc->scan, sc->iscan, qparam->log_scale); + vp10_highbd_quantize_fp(coeff_ptr, n_coeffs, skip_block, p->zbin, p->round_fp, + p->quant_fp, p->quant_shift, qcoeff_ptr, dqcoeff_ptr, + pd->dequant, eob_ptr, sc->scan, sc->iscan, + qparam->log_scale); } void vp10_highbd_quantize_b_facade(const tran_low_t *coeff_ptr, @@ -527,19 +438,16 @@ void vp10_highbd_quantize_dc_facade( (void)sc; vp10_highbd_quantize_dc(coeff_ptr, (int)n_coeffs, skip_block, p->round, - p->quant_fp[0], qcoeff_ptr, dqcoeff_ptr, - pd->dequant[0], eob_ptr, qparam->log_scale); + p->quant_fp[0], qcoeff_ptr, dqcoeff_ptr, + pd->dequant[0], eob_ptr, qparam->log_scale); } #if CONFIG_NEW_QUANT -static INLINE int highbd_quantize_coeff_nuq(const tran_low_t coeffv, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr) { +static INLINE int highbd_quantize_coeff_nuq( + const tran_low_t coeffv, const int16_t quant, const int16_t quant_shift, + const int16_t dequant, const tran_low_t *cuml_bins_ptr, + const tran_low_t *dequant_val, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr) { const int coeff = coeffv; const int coeff_sign = (coeff >> 31); const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign; @@ -556,9 +464,8 @@ static INLINE int highbd_quantize_coeff_nuq(const tran_low_t coeffv, q = NUQ_KNOTS + (((((tmp * quant) >> 16) + tmp) * quant_shift) >> 16); } if (q) { - *dqcoeff_ptr = - vp10_dequant_abscoeff_nuq(q, dequant, dequant_val); - *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; + *dqcoeff_ptr = vp10_dequant_abscoeff_nuq(q, dequant, dequant_val); + *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; *dqcoeff_ptr = *qcoeff_ptr < 0 ? -*dqcoeff_ptr : *dqcoeff_ptr; } else { *qcoeff_ptr = 0; @@ -567,13 +474,10 @@ static INLINE int highbd_quantize_coeff_nuq(const tran_low_t coeffv, return (q != 0); } -static INLINE int highbd_quantize_coeff_fp_nuq(const tran_low_t coeffv, - const int16_t quant, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr) { +static INLINE int highbd_quantize_coeff_fp_nuq( + const tran_low_t coeffv, const int16_t quant, const int16_t dequant, + const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr) { const int coeff = coeffv; const int coeff_sign = (coeff >> 31); const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign; @@ -586,13 +490,11 @@ static INLINE int highbd_quantize_coeff_fp_nuq(const tran_low_t coeffv, } } if (i == NUQ_KNOTS) { - q = NUQ_KNOTS + - (((tmp - cuml_bins_ptr[NUQ_KNOTS - 1]) * quant) >> 16); + q = NUQ_KNOTS + (((tmp - cuml_bins_ptr[NUQ_KNOTS - 1]) * quant) >> 16); } if (q) { - *dqcoeff_ptr = - vp10_dequant_abscoeff_nuq(q, dequant, dequant_val); - *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; + *dqcoeff_ptr = vp10_dequant_abscoeff_nuq(q, dequant, dequant_val); + *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; *dqcoeff_ptr = *qcoeff_ptr < 0 ? -*dqcoeff_ptr : *dqcoeff_ptr; } else { *qcoeff_ptr = 0; @@ -602,14 +504,9 @@ static INLINE int highbd_quantize_coeff_fp_nuq(const tran_low_t coeffv, } static INLINE int highbd_quantize_coeff_bigtx_fp_nuq( - const tran_low_t coeffv, - const int16_t quant, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - int logsizeby32) { + const tran_low_t coeffv, const int16_t quant, const int16_t dequant, + const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, int logsizeby32) { const int coeff = coeffv; const int coeff_sign = (coeff >> 31); const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign; @@ -622,16 +519,15 @@ static INLINE int highbd_quantize_coeff_bigtx_fp_nuq( } } if (i == NUQ_KNOTS) { - q = NUQ_KNOTS + - (((tmp - ROUND_POWER_OF_TWO(cuml_bins_ptr[NUQ_KNOTS - 1], - 1 + logsizeby32)) * quant) >> - (15 - logsizeby32)); + q = NUQ_KNOTS + (((tmp - ROUND_POWER_OF_TWO(cuml_bins_ptr[NUQ_KNOTS - 1], + 1 + logsizeby32)) * + quant) >> + (15 - logsizeby32)); } if (q) { - *dqcoeff_ptr = - ROUND_POWER_OF_TWO(vp10_dequant_abscoeff_nuq(q, dequant, dequant_val), - 1 + logsizeby32); - *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; + *dqcoeff_ptr = ROUND_POWER_OF_TWO( + vp10_dequant_abscoeff_nuq(q, dequant, dequant_val), 1 + logsizeby32); + *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; *dqcoeff_ptr = *qcoeff_ptr < 0 ? -*dqcoeff_ptr : *dqcoeff_ptr; } else { *qcoeff_ptr = 0; @@ -640,16 +536,11 @@ static INLINE int highbd_quantize_coeff_bigtx_fp_nuq( return (q != 0); } -static INLINE int highbd_quantize_coeff_bigtx_nuq(const tran_low_t coeffv, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, - const tran_low_t - *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - int logsizeby32) { +static INLINE int highbd_quantize_coeff_bigtx_nuq( + const tran_low_t coeffv, const int16_t quant, const int16_t quant_shift, + const int16_t dequant, const tran_low_t *cuml_bins_ptr, + const tran_low_t *dequant_val, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, int logsizeby32) { const int coeff = coeffv; const int coeff_sign = (coeff >> 31); const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign; @@ -667,10 +558,9 @@ static INLINE int highbd_quantize_coeff_bigtx_nuq(const tran_low_t coeffv, (((((tmp * quant) >> 16) + tmp) * quant_shift) >> (15 - logsizeby32)); } if (q) { - *dqcoeff_ptr = - ROUND_POWER_OF_TWO(vp10_dequant_abscoeff_nuq(q, dequant, dequant_val), - 1 + logsizeby32); - *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; + *dqcoeff_ptr = ROUND_POWER_OF_TWO( + vp10_dequant_abscoeff_nuq(q, dequant, dequant_val), 1 + logsizeby32); + *qcoeff_ptr = (q ^ coeff_sign) - coeff_sign; *dqcoeff_ptr = *qcoeff_ptr < 0 ? -*dqcoeff_ptr : *dqcoeff_ptr; } else { *qcoeff_ptr = 0; @@ -679,74 +569,54 @@ static INLINE int highbd_quantize_coeff_bigtx_nuq(const tran_low_t coeffv, return (q != 0); } -void highbd_quantize_dc_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, +void highbd_quantize_dc_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, + const int16_t quant_shift, const int16_t dequant, const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); if (!skip_block) { const int rc = 0; - if (highbd_quantize_coeff_nuq(coeff_ptr[rc], - quant, - quant_shift, - dequant, - cuml_bins_ptr, - dequant_val, - qcoeff_ptr, + if (highbd_quantize_coeff_nuq(coeff_ptr[rc], quant, quant_shift, dequant, + cuml_bins_ptr, dequant_val, qcoeff_ptr, dqcoeff_ptr)) eob = 0; } *eob_ptr = eob + 1; } -void highbd_quantize_dc_fp_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, +void highbd_quantize_dc_fp_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, const int16_t dequant, const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); if (!skip_block) { const int rc = 0; - if (highbd_quantize_coeff_fp_nuq(coeff_ptr[rc], - quant, - dequant, - cuml_bins_ptr, - dequant_val, - qcoeff_ptr, + if (highbd_quantize_coeff_fp_nuq(coeff_ptr[rc], quant, dequant, + cuml_bins_ptr, dequant_val, qcoeff_ptr, dqcoeff_ptr)) eob = 0; } *eob_ptr = eob + 1; } -void highbd_quantize_nuq_c(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t *quant_ptr, +void highbd_quantize_nuq_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr, - const int16_t *scan, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, + uint16_t *eob_ptr, const int16_t *scan, const uint8_t *band) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); @@ -755,33 +625,25 @@ void highbd_quantize_nuq_c(const tran_low_t *coeff_ptr, int i; for (i = 0; i < n_coeffs; i++) { const int rc = scan[i]; - if (highbd_quantize_coeff_nuq(coeff_ptr[rc], - quant_ptr[rc != 0], - quant_shift_ptr[rc != 0], - dequant_ptr[rc != 0], - cuml_bins_ptr[band[i]], - dequant_val[band[i]], - &qcoeff_ptr[rc], - &dqcoeff_ptr[rc])) + if (highbd_quantize_coeff_nuq( + coeff_ptr[rc], quant_ptr[rc != 0], quant_shift_ptr[rc != 0], + dequant_ptr[rc != 0], cuml_bins_ptr[band[i]], + dequant_val[band[i]], &qcoeff_ptr[rc], &dqcoeff_ptr[rc])) eob = i; } } *eob_ptr = eob + 1; } -void highbd_quantize_32x32_nuq_c(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t *quant_ptr, +void highbd_quantize_32x32_nuq_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr, - const int16_t *scan, - const uint8_t *band) { + tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, + const int16_t *scan, const uint8_t *band) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); @@ -789,15 +651,10 @@ void highbd_quantize_32x32_nuq_c(const tran_low_t *coeff_ptr, int i; for (i = 0; i < n_coeffs; i++) { const int rc = scan[i]; - if (highbd_quantize_coeff_bigtx_nuq(coeff_ptr[rc], - quant_ptr[rc != 0], - quant_shift_ptr[rc != 0], - dequant_ptr[rc != 0], - cuml_bins_ptr[band[i]], - dequant_val[band[i]], - &qcoeff_ptr[rc], - &dqcoeff_ptr[rc], - 0)) + if (highbd_quantize_coeff_bigtx_nuq( + coeff_ptr[rc], quant_ptr[rc != 0], quant_shift_ptr[rc != 0], + dequant_ptr[rc != 0], cuml_bins_ptr[band[i]], + dequant_val[band[i]], &qcoeff_ptr[rc], &dqcoeff_ptr[rc], 0)) eob = i; } } @@ -805,17 +662,14 @@ void highbd_quantize_32x32_nuq_c(const tran_low_t *coeff_ptr, } void highbd_quantize_32x32_fp_nuq_c(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, + intptr_t n_coeffs, int skip_block, const int16_t *quant_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr, - const int16_t *scan, - const uint8_t *band) { + tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, + const int16_t *scan, const uint8_t *band) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); @@ -823,31 +677,23 @@ void highbd_quantize_32x32_fp_nuq_c(const tran_low_t *coeff_ptr, int i; for (i = 0; i < n_coeffs; i++) { const int rc = scan[i]; - if (highbd_quantize_coeff_bigtx_fp_nuq(coeff_ptr[rc], - quant_ptr[rc != 0], - dequant_ptr[rc != 0], - cuml_bins_ptr[band[i]], - dequant_val[band[i]], - &qcoeff_ptr[rc], - &dqcoeff_ptr[rc], - 0)) + if (highbd_quantize_coeff_bigtx_fp_nuq( + coeff_ptr[rc], quant_ptr[rc != 0], dequant_ptr[rc != 0], + cuml_bins_ptr[band[i]], dequant_val[band[i]], &qcoeff_ptr[rc], + &dqcoeff_ptr[rc], 0)) eob = i; } } *eob_ptr = eob + 1; } -void highbd_quantize_fp_nuq_c(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t *quant_ptr, +void highbd_quantize_fp_nuq_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t *quant_ptr, const int16_t *dequant_ptr, const cuml_bins_type_nuq *cuml_bins_ptr, const dequant_val_type_nuq *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr, - const int16_t *scan, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, + uint16_t *eob_ptr, const int16_t *scan, const uint8_t *band) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); @@ -856,72 +702,47 @@ void highbd_quantize_fp_nuq_c(const tran_low_t *coeff_ptr, int i; for (i = 0; i < n_coeffs; i++) { const int rc = scan[i]; - if (highbd_quantize_coeff_fp_nuq(coeff_ptr[rc], - quant_ptr[rc != 0], - dequant_ptr[rc != 0], - cuml_bins_ptr[band[i]], - dequant_val[band[i]], - &qcoeff_ptr[rc], - &dqcoeff_ptr[rc])) + if (highbd_quantize_coeff_fp_nuq( + coeff_ptr[rc], quant_ptr[rc != 0], dequant_ptr[rc != 0], + cuml_bins_ptr[band[i]], dequant_val[band[i]], &qcoeff_ptr[rc], + &dqcoeff_ptr[rc])) eob = i; } } *eob_ptr = eob + 1; } -void highbd_quantize_dc_32x32_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr) { +void highbd_quantize_dc_32x32_nuq( + const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, + const int16_t quant, const int16_t quant_shift, const int16_t dequant, + const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); if (!skip_block) { const int rc = 0; - if (highbd_quantize_coeff_bigtx_nuq(coeff_ptr[rc], - quant, - quant_shift, - dequant, - cuml_bins_ptr, - dequant_val, - qcoeff_ptr, - dqcoeff_ptr, - 0)) + if (highbd_quantize_coeff_bigtx_nuq(coeff_ptr[rc], quant, quant_shift, + dequant, cuml_bins_ptr, dequant_val, + qcoeff_ptr, dqcoeff_ptr, 0)) eob = 0; } *eob_ptr = eob + 1; } -void highbd_quantize_dc_32x32_fp_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr) { +void highbd_quantize_dc_32x32_fp_nuq( + const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, + const int16_t quant, const int16_t dequant, const tran_low_t *cuml_bins_ptr, + const tran_low_t *dequant_val, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); if (!skip_block) { const int rc = 0; - if (highbd_quantize_coeff_bigtx_fp_nuq(coeff_ptr[rc], - quant, - dequant, - cuml_bins_ptr, - dequant_val, - qcoeff_ptr, - dqcoeff_ptr, - 0)) + if (highbd_quantize_coeff_bigtx_fp_nuq(coeff_ptr[rc], quant, dequant, + cuml_bins_ptr, dequant_val, + qcoeff_ptr, dqcoeff_ptr, 0)) eob = 0; } *eob_ptr = eob + 1; @@ -930,13 +751,12 @@ void highbd_quantize_dc_32x32_fp_nuq(const tran_low_t *coeff_ptr, #endif // CONFIG_VP9_HIGHBITDEPTH void vp10_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, - int skip_block, - const int16_t *zbin_ptr, const int16_t *round_ptr, - const int16_t *quant_ptr, const int16_t *quant_shift_ptr, - tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, - const int16_t *dequant_ptr, - uint16_t *eob_ptr, - const int16_t *scan, const int16_t *iscan) { + int skip_block, const int16_t *zbin_ptr, + const int16_t *round_ptr, const int16_t *quant_ptr, + const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, + uint16_t *eob_ptr, const int16_t *scan, + const int16_t *iscan) { int i, eob = -1; // TODO(jingning) Decide the need of these arguments after the // quantization process is completed. @@ -962,27 +782,19 @@ void vp10_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, qcoeff_ptr[rc] = (tmp ^ coeff_sign) - coeff_sign; dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0]; - if (tmp) - eob = i; + if (tmp) eob = i; } } *eob_ptr = eob + 1; } #if CONFIG_VP9_HIGHBITDEPTH -void vp10_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, - intptr_t count, - int skip_block, - const int16_t *zbin_ptr, - const int16_t *round_ptr, - const int16_t *quant_ptr, - const int16_t *quant_shift_ptr, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - const int16_t *dequant_ptr, - uint16_t *eob_ptr, - const int16_t *scan, - const int16_t *iscan, int log_scale) { +void vp10_highbd_quantize_fp_c( + const tran_low_t *coeff_ptr, intptr_t count, int skip_block, + const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, + const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, + const int16_t *scan, const int16_t *iscan, int log_scale) { int i; int eob = -1; const int scale = 1 << log_scale; @@ -1008,9 +820,8 @@ void vp10_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, const uint32_t abs_qcoeff = (uint32_t)((tmp * quant_ptr[rc != 0]) >> shift); qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign); - dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / scale; - if (abs_qcoeff) - eob = i; + dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / scale; + if (abs_qcoeff) eob = i; } } *eob_ptr = eob + 1; @@ -1021,14 +832,13 @@ void vp10_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, // TODO(jingning) Refactor this file and combine functions with similar // operations. void vp10_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, - int skip_block, - const int16_t *zbin_ptr, const int16_t *round_ptr, - const int16_t *quant_ptr, - const int16_t *quant_shift_ptr, - tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, - const int16_t *dequant_ptr, - uint16_t *eob_ptr, - const int16_t *scan, const int16_t *iscan) { + int skip_block, const int16_t *zbin_ptr, + const int16_t *round_ptr, + const int16_t *quant_ptr, + const int16_t *quant_shift_ptr, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, + const int16_t *dequant_ptr, uint16_t *eob_ptr, + const int16_t *scan, const int16_t *iscan) { int i, eob = -1; (void)zbin_ptr; (void)quant_shift_ptr; @@ -1053,26 +863,22 @@ void vp10_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / 2; } - if (tmp) - eob = i; + if (tmp) eob = i; } } *eob_ptr = eob + 1; } #if CONFIG_VP9_HIGHBITDEPTH -void vp10_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, - int skip_block, const int16_t *zbin_ptr, - const int16_t *round_ptr, - const int16_t *quant_ptr, - const int16_t *quant_shift_ptr, - tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, - const int16_t *dequant_ptr, - uint16_t *eob_ptr, const int16_t *scan, - const int16_t *iscan, int log_scale) { +void vp10_highbd_quantize_b_c( + const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, + const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, + const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, + const int16_t *scan, const int16_t *iscan, int log_scale) { int i, non_zero_count = (int)n_coeffs, eob = -1; - int zbins[2] = {zbin_ptr[0], zbin_ptr[1]}; - int round[2] = {round_ptr[0], round_ptr[1]}; + int zbins[2] = { zbin_ptr[0], zbin_ptr[1] }; + int round[2] = { round_ptr[0], round_ptr[1] }; int nzbins[2]; int scale = 1; int shift = 16; @@ -1120,8 +926,7 @@ void vp10_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, (uint32_t)((tmp2 * quant_shift_ptr[rc != 0]) >> shift); qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign); dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / scale; - if (abs_qcoeff) - eob = i; + if (abs_qcoeff) eob = i; } } } @@ -1130,12 +935,11 @@ void vp10_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, #endif #if CONFIG_VP9_HIGHBITDEPTH -void vp10_highbd_quantize_dc(const tran_low_t *coeff_ptr, - int n_coeffs, int skip_block, - const int16_t *round_ptr, const int16_t quant, - tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, - const int16_t dequant_ptr, uint16_t *eob_ptr, - const int log_scale) { +void vp10_highbd_quantize_dc(const tran_low_t *coeff_ptr, int n_coeffs, + int skip_block, const int16_t *round_ptr, + const int16_t quant, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, const int16_t dequant_ptr, + uint16_t *eob_ptr, const int log_scale) { int eob = -1; memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); @@ -1149,8 +953,7 @@ void vp10_highbd_quantize_dc(const tran_low_t *coeff_ptr, const uint32_t abs_qcoeff = (uint32_t)((tmp * quant) >> (16 - log_scale)); qcoeff_ptr[0] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign); dqcoeff_ptr[0] = qcoeff_ptr[0] * dequant_ptr / (1 << log_scale); - if (abs_qcoeff) - eob = 0; + if (abs_qcoeff) eob = 0; } *eob_ptr = eob + 1; } @@ -1160,8 +963,7 @@ static void invert_quant(int16_t *quant, int16_t *shift, int d) { unsigned t; int l, m; t = d; - for (l = 0; t > 1; l++) - t >>= 1; + for (l = 0; t > 1; l++) t >>= 1; m = 1 + (1 << (16 + l)) / d; *quant = (int16_t)(m - (1 << 16)); *shift = 1 << (16 - l); @@ -1171,18 +973,15 @@ static int get_qzbin_factor(int q, vpx_bit_depth_t bit_depth) { const int quant = vp10_dc_quant(q, 0, bit_depth); #if CONFIG_VP9_HIGHBITDEPTH switch (bit_depth) { - case VPX_BITS_8: - return q == 0 ? 64 : (quant < 148 ? 84 : 80); - case VPX_BITS_10: - return q == 0 ? 64 : (quant < 592 ? 84 : 80); - case VPX_BITS_12: - return q == 0 ? 64 : (quant < 2368 ? 84 : 80); + case VPX_BITS_8: return q == 0 ? 64 : (quant < 148 ? 84 : 80); + case VPX_BITS_10: return q == 0 ? 64 : (quant < 592 ? 84 : 80); + case VPX_BITS_12: return q == 0 ? 64 : (quant < 2368 ? 84 : 80); default: assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12"); return -1; } #else - (void) bit_depth; + (void)bit_depth; return q == 0 ? 64 : (quant < 148 ? 84 : 80); #endif } @@ -1214,8 +1013,8 @@ void vp10_init_quantizer(VP10_COMP *cpi) { // uv quant = i == 0 ? vp10_dc_quant(q, cm->uv_dc_delta_q, cm->bit_depth) : vp10_ac_quant(q, cm->uv_ac_delta_q, cm->bit_depth); - invert_quant(&quants->uv_quant[q][i], - &quants->uv_quant_shift[q][i], quant); + invert_quant(&quants->uv_quant[q][i], &quants->uv_quant_shift[q][i], + quant); quants->uv_quant_fp[q][i] = (1 << 16) / quant; quants->uv_round_fp[q][i] = (qrounding_factor_fp * quant) >> 7; quants->uv_zbin[q][i] = ROUND_POWER_OF_TWO(qzbin_factor * quant, 7); @@ -1228,8 +1027,7 @@ void vp10_init_quantizer(VP10_COMP *cpi) { for (i = 0; i < COEF_BANDS; i++) { const int quant = cpi->y_dequant[q][i != 0]; const int uvquant = cpi->uv_dequant[q][i != 0]; - vp10_get_dequant_val_nuq(quant, q, i, - cpi->y_dequant_val_nuq[dq][q][i], + vp10_get_dequant_val_nuq(quant, q, i, cpi->y_dequant_val_nuq[dq][q][i], quants->y_cuml_bins_nuq[dq][q][i], dq); vp10_get_dequant_val_nuq(uvquant, q, i, cpi->uv_dequant_val_nuq[dq][q][i], @@ -1279,11 +1077,11 @@ void vp10_init_plane_quantizers(const VP10_COMP *cpi, MACROBLOCK *x, x->plane[0].round = quants->y_round[qindex]; xd->plane[0].dequant = cpi->y_dequant[qindex]; #if CONFIG_NEW_QUANT - for (dq = 0; dq < QUANT_PROFILES; dq ++) { - x->plane[0].cuml_bins_nuq[dq] = (cuml_bins_type_nuq*) - quants->y_cuml_bins_nuq[dq][qindex]; - xd->plane[0].dequant_val_nuq[dq] = (const dequant_val_type_nuq*) - cpi->y_dequant_val_nuq[dq][qindex]; + for (dq = 0; dq < QUANT_PROFILES; dq++) { + x->plane[0].cuml_bins_nuq[dq] = + (cuml_bins_type_nuq *)quants->y_cuml_bins_nuq[dq][qindex]; + xd->plane[0].dequant_val_nuq[dq] = + (const dequant_val_type_nuq *)cpi->y_dequant_val_nuq[dq][qindex]; } #endif // CONFIG_NEW_QUANT @@ -1300,11 +1098,11 @@ void vp10_init_plane_quantizers(const VP10_COMP *cpi, MACROBLOCK *x, x->plane[i].round = quants->uv_round[qindex]; xd->plane[i].dequant = cpi->uv_dequant[qindex]; #if CONFIG_NEW_QUANT - for (dq = 0; dq < QUANT_PROFILES; dq ++) { - x->plane[i].cuml_bins_nuq[dq] = (cuml_bins_type_nuq*) - quants->uv_cuml_bins_nuq[dq][qindex]; - xd->plane[i].dequant_val_nuq[dq] = (const dequant_val_type_nuq*) - cpi->uv_dequant_val_nuq[dq][qindex]; + for (dq = 0; dq < QUANT_PROFILES; dq++) { + x->plane[i].cuml_bins_nuq[dq] = + (cuml_bins_type_nuq *)quants->uv_cuml_bins_nuq[dq][qindex]; + xd->plane[i].dequant_val_nuq[dq] = + (const dequant_val_type_nuq *)cpi->uv_dequant_val_nuq[dq][qindex]; } #endif // CONFIG_NEW_QUANT @@ -1338,14 +1136,11 @@ void vp10_set_quantizer(VP10_COMMON *cm, int q) { // Table that converts 0-63 Q-range values passed in outside to the Qindex // range used internally. static const int quantizer_to_qindex[] = { - 0, 4, 8, 12, 16, 20, 24, 28, - 32, 36, 40, 44, 48, 52, 56, 60, - 64, 68, 72, 76, 80, 84, 88, 92, - 96, 100, 104, 108, 112, 116, 120, 124, - 128, 132, 136, 140, 144, 148, 152, 156, - 160, 164, 168, 172, 176, 180, 184, 188, - 192, 196, 200, 204, 208, 212, 216, 220, - 224, 228, 232, 236, 240, 244, 249, 255, + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, + 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, + 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, + 156, 160, 164, 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, + 208, 212, 216, 220, 224, 228, 232, 236, 240, 244, 249, 255, }; int vp10_quantizer_to_qindex(int quantizer) { @@ -1356,8 +1151,7 @@ int vp10_qindex_to_quantizer(int qindex) { int quantizer; for (quantizer = 0; quantizer < 64; ++quantizer) - if (quantizer_to_qindex[quantizer] >= qindex) - return quantizer; + if (quantizer_to_qindex[quantizer] >= qindex) return quantizer; return 63; } diff --git a/vp10/encoder/quantize.h b/vp10/encoder/quantize.h index ca57c7ea2..6b7f07da1 100644 --- a/vp10/encoder/quantize.h +++ b/vp10/encoder/quantize.h @@ -19,9 +19,7 @@ extern "C" { #endif -typedef struct QUANT_PARAM { - int log_scale; -} QUANT_PARAM; +typedef struct QUANT_PARAM { int log_scale; } QUANT_PARAM; typedef void (*VP10_QUANT_FACADE)(const tran_low_t *coeff_ptr, intptr_t n_coeffs, const MACROBLOCK_PLANE *p, @@ -33,12 +31,12 @@ typedef void (*VP10_QUANT_FACADE)(const tran_low_t *coeff_ptr, typedef struct { #if CONFIG_NEW_QUANT - DECLARE_ALIGNED(16, tran_low_t, - y_cuml_bins_nuq[QUANT_PROFILES][QINDEX_RANGE][COEF_BANDS] - [NUQ_KNOTS]); - DECLARE_ALIGNED(16, tran_low_t, - uv_cuml_bins_nuq[QUANT_PROFILES][QINDEX_RANGE][COEF_BANDS] - [NUQ_KNOTS]); + DECLARE_ALIGNED( + 16, tran_low_t, + y_cuml_bins_nuq[QUANT_PROFILES][QINDEX_RANGE][COEF_BANDS][NUQ_KNOTS]); + DECLARE_ALIGNED( + 16, tran_low_t, + uv_cuml_bins_nuq[QUANT_PROFILES][QINDEX_RANGE][COEF_BANDS][NUQ_KNOTS]); #endif // CONFIG_NEW_QUANT // 0: dc 1: ac 2-8: ac repeated to SIMD width DECLARE_ALIGNED(16, int16_t, y_quant[QINDEX_RANGE][8]); @@ -97,47 +95,30 @@ void vp10_quantize_dc_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs, const scan_order *sc, const QUANT_PARAM *qparam); #if CONFIG_NEW_QUANT -void quantize_dc_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, +void quantize_dc_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, + const int16_t quant_shift, const int16_t dequant, const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr); -void quantize_dc_32x32_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, + const tran_low_t *dequant_val, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr); +void quantize_dc_32x32_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, + const int16_t quant_shift, const int16_t dequant, const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr); -void quantize_dc_fp_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr); -void quantize_dc_32x32_fp_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, +void quantize_dc_fp_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, + const int16_t dequant, const tran_low_t *cuml_bins_ptr, + const tran_low_t *dequant_val, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr); +void quantize_dc_32x32_fp_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, const int16_t dequant, const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr); #endif // CONFIG_NEW_QUANT @@ -162,55 +143,36 @@ void vp10_highbd_quantize_dc_facade( tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr, const scan_order *sc, const QUANT_PARAM *qparam); -void vp10_highbd_quantize_dc(const tran_low_t *coeff_ptr, - int n_coeffs, int skip_block, - const int16_t *round_ptr, const int16_t quant, - tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, - const int16_t dequant_ptr, uint16_t *eob_ptr, - const int log_scale); +void vp10_highbd_quantize_dc(const tran_low_t *coeff_ptr, int n_coeffs, + int skip_block, const int16_t *round_ptr, + const int16_t quant, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, const int16_t dequant_ptr, + uint16_t *eob_ptr, const int log_scale); #if CONFIG_NEW_QUANT -void highbd_quantize_dc_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, +void highbd_quantize_dc_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, + const int16_t quant_shift, const int16_t dequant, const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr); -void highbd_quantize_dc_32x32_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t quant_shift, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr); -void highbd_quantize_dc_fp_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, +void highbd_quantize_dc_32x32_nuq( + const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, + const int16_t quant, const int16_t quant_shift, const int16_t dequant, + const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr); +void highbd_quantize_dc_fp_nuq(const tran_low_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t quant, const int16_t dequant, const tran_low_t *cuml_bins_ptr, const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, + tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr); -void highbd_quantize_dc_32x32_fp_nuq(const tran_low_t *coeff_ptr, - intptr_t n_coeffs, - int skip_block, - const int16_t quant, - const int16_t dequant, - const tran_low_t *cuml_bins_ptr, - const tran_low_t *dequant_val, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - uint16_t *eob_ptr); +void highbd_quantize_dc_32x32_fp_nuq( + const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, + const int16_t quant, const int16_t dequant, const tran_low_t *cuml_bins_ptr, + const tran_low_t *dequant_val, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr); #endif // CONFIG_NEW_QUANT #endif // CONFIG_VP9_HIGHBITDEPTH diff --git a/vp10/encoder/ratectrl.c b/vp10/encoder/ratectrl.c index c35b7ce66..6b077c788 100644 --- a/vp10/encoder/ratectrl.c +++ b/vp10/encoder/ratectrl.c @@ -44,29 +44,24 @@ #define FRAME_OVERHEAD_BITS 200 #if CONFIG_VP9_HIGHBITDEPTH -#define ASSIGN_MINQ_TABLE(bit_depth, name) \ - do { \ - switch (bit_depth) { \ - case VPX_BITS_8: \ - name = name##_8; \ - break; \ - case VPX_BITS_10: \ - name = name##_10; \ - break; \ - case VPX_BITS_12: \ - name = name##_12; \ - break; \ - default: \ - assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10" \ - " or VPX_BITS_12"); \ - name = NULL; \ - } \ +#define ASSIGN_MINQ_TABLE(bit_depth, name) \ + do { \ + switch (bit_depth) { \ + case VPX_BITS_8: name = name##_8; break; \ + case VPX_BITS_10: name = name##_10; break; \ + case VPX_BITS_12: name = name##_12; break; \ + default: \ + assert(0 && \ + "bit_depth should be VPX_BITS_8, VPX_BITS_10" \ + " or VPX_BITS_12"); \ + name = NULL; \ + } \ } while (0) #else #define ASSIGN_MINQ_TABLE(bit_depth, name) \ - do { \ - (void) bit_depth; \ - name = name##_8; \ + do { \ + (void) bit_depth; \ + name = name##_8; \ } while (0) #endif @@ -109,20 +104,18 @@ static int get_minq_index(double maxq, double x3, double x2, double x1, // Special case handling to deal with the step from q2.0 // down to lossless mode represented by q 1.0. - if (minqtarget <= 2.0) - return 0; + if (minqtarget <= 2.0) return 0; for (i = 0; i < QINDEX_RANGE; i++) { - if (minqtarget <= vp10_convert_qindex_to_q(i, bit_depth)) - return i; + if (minqtarget <= vp10_convert_qindex_to_q(i, bit_depth)) return i; } return QINDEX_RANGE - 1; } -static void init_minq_luts(int *kf_low_m, int *kf_high_m, - int *arfgf_low, int *arfgf_high, - int *inter, int *rtc, vpx_bit_depth_t bit_depth) { +static void init_minq_luts(int *kf_low_m, int *kf_high_m, int *arfgf_low, + int *arfgf_high, int *inter, int *rtc, + vpx_bit_depth_t bit_depth) { int i; for (i = 0; i < QINDEX_RANGE; i++) { const double maxq = vp10_convert_qindex_to_q(i, bit_depth); @@ -153,15 +146,12 @@ void vp10_rc_init_minq_luts(void) { // quantizer tables easier. If necessary they can be replaced by lookup // tables if and when things settle down in the experimental bitstream double vp10_convert_qindex_to_q(int qindex, vpx_bit_depth_t bit_depth) { - // Convert the index to a real Q value (scaled down to match old Q values) +// Convert the index to a real Q value (scaled down to match old Q values) #if CONFIG_VP9_HIGHBITDEPTH switch (bit_depth) { - case VPX_BITS_8: - return vp10_ac_quant(qindex, 0, bit_depth) / 4.0; - case VPX_BITS_10: - return vp10_ac_quant(qindex, 0, bit_depth) / 16.0; - case VPX_BITS_12: - return vp10_ac_quant(qindex, 0, bit_depth) / 64.0; + case VPX_BITS_8: return vp10_ac_quant(qindex, 0, bit_depth) / 4.0; + case VPX_BITS_10: return vp10_ac_quant(qindex, 0, bit_depth) / 16.0; + case VPX_BITS_12: return vp10_ac_quant(qindex, 0, bit_depth) / 64.0; default: assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12"); return -1.0; @@ -172,8 +162,7 @@ double vp10_convert_qindex_to_q(int qindex, vpx_bit_depth_t bit_depth) { } int vp10_rc_bits_per_mb(FRAME_TYPE frame_type, int qindex, - double correction_factor, - vpx_bit_depth_t bit_depth) { + double correction_factor, vpx_bit_depth_t bit_depth) { const double q = vp10_convert_qindex_to_q(qindex, bit_depth); int enumerator = frame_type == KEY_FRAME ? 2700000 : 1800000; @@ -186,10 +175,10 @@ int vp10_rc_bits_per_mb(FRAME_TYPE frame_type, int qindex, } int vp10_estimate_bits_at_q(FRAME_TYPE frame_type, int q, int mbs, - double correction_factor, - vpx_bit_depth_t bit_depth) { - const int bpm = (int)(vp10_rc_bits_per_mb(frame_type, q, correction_factor, - bit_depth)); + double correction_factor, + vpx_bit_depth_t bit_depth) { + const int bpm = + (int)(vp10_rc_bits_per_mb(frame_type, q, correction_factor, bit_depth)); return VPXMAX(FRAME_OVERHEAD_BITS, (int)((uint64_t)bpm * mbs) >> BPER_MB_NORMBITS); } @@ -197,9 +186,9 @@ int vp10_estimate_bits_at_q(FRAME_TYPE frame_type, int q, int mbs, int vp10_rc_clamp_pframe_target_size(const VP10_COMP *const cpi, int target) { const RATE_CONTROL *rc = &cpi->rc; const VP10EncoderConfig *oxcf = &cpi->oxcf; - const int min_frame_target = VPXMAX(rc->min_frame_bandwidth, - rc->avg_frame_bandwidth >> 5); - // Clip the frame target to the minimum setup value. + const int min_frame_target = + VPXMAX(rc->min_frame_bandwidth, rc->avg_frame_bandwidth >> 5); +// Clip the frame target to the minimum setup value. #if CONFIG_EXT_REFS if (cpi->rc.is_src_frame_alt_ref) { #else @@ -215,11 +204,10 @@ int vp10_rc_clamp_pframe_target_size(const VP10_COMP *const cpi, int target) { } // Clip the frame target to the maximum allowed value. - if (target > rc->max_frame_bandwidth) - target = rc->max_frame_bandwidth; + if (target > rc->max_frame_bandwidth) target = rc->max_frame_bandwidth; if (oxcf->rc_max_inter_bitrate_pct) { - const int max_rate = rc->avg_frame_bandwidth * - oxcf->rc_max_inter_bitrate_pct / 100; + const int max_rate = + rc->avg_frame_bandwidth * oxcf->rc_max_inter_bitrate_pct / 100; target = VPXMIN(target, max_rate); } @@ -230,12 +218,11 @@ int vp10_rc_clamp_iframe_target_size(const VP10_COMP *const cpi, int target) { const RATE_CONTROL *rc = &cpi->rc; const VP10EncoderConfig *oxcf = &cpi->oxcf; if (oxcf->rc_max_intra_bitrate_pct) { - const int max_rate = rc->avg_frame_bandwidth * - oxcf->rc_max_intra_bitrate_pct / 100; + const int max_rate = + rc->avg_frame_bandwidth * oxcf->rc_max_intra_bitrate_pct / 100; target = VPXMIN(target, max_rate); } - if (target > rc->max_frame_bandwidth) - target = rc->max_frame_bandwidth; + if (target > rc->max_frame_bandwidth) target = rc->max_frame_bandwidth; return target; } @@ -244,7 +231,7 @@ static void update_buffer_level(VP10_COMP *cpi, int encoded_frame_size) { const VP10_COMMON *const cm = &cpi->common; RATE_CONTROL *const rc = &cpi->rc; - // Non-viewable frames are a special case and are treated as pure overhead. +// Non-viewable frames are a special case and are treated as pure overhead. #if CONFIG_EXT_REFS // TODO(zoeliu): To further explore whether we should treat BWDREF_FRAME // differently, since it is a no-show frame. @@ -261,8 +248,8 @@ static void update_buffer_level(VP10_COMP *cpi, int encoded_frame_size) { rc->buffer_level = rc->bits_off_target; } -int vp10_rc_get_default_min_gf_interval( - int width, int height, double framerate) { +int vp10_rc_get_default_min_gf_interval(int width, int height, + double framerate) { // Assume we do not need any constraint lower than 4K 20 fps static const double factor_safe = 3840 * 2160 * 20.0; const double factor = width * height * framerate; @@ -293,20 +280,20 @@ void vp10_rc_init(const VP10EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) { rc->avg_frame_qindex[KEY_FRAME] = oxcf->worst_allowed_q; rc->avg_frame_qindex[INTER_FRAME] = oxcf->worst_allowed_q; } else { - rc->avg_frame_qindex[KEY_FRAME] = (oxcf->worst_allowed_q + - oxcf->best_allowed_q) / 2; - rc->avg_frame_qindex[INTER_FRAME] = (oxcf->worst_allowed_q + - oxcf->best_allowed_q) / 2; + rc->avg_frame_qindex[KEY_FRAME] = + (oxcf->worst_allowed_q + oxcf->best_allowed_q) / 2; + rc->avg_frame_qindex[INTER_FRAME] = + (oxcf->worst_allowed_q + oxcf->best_allowed_q) / 2; } rc->last_q[KEY_FRAME] = oxcf->best_allowed_q; rc->last_q[INTER_FRAME] = oxcf->worst_allowed_q; - rc->buffer_level = rc->starting_buffer_level; + rc->buffer_level = rc->starting_buffer_level; rc->bits_off_target = rc->starting_buffer_level; - rc->rolling_target_bits = rc->avg_frame_bandwidth; - rc->rolling_actual_bits = rc->avg_frame_bandwidth; + rc->rolling_target_bits = rc->avg_frame_bandwidth; + rc->rolling_actual_bits = rc->avg_frame_bandwidth; rc->long_rolling_target_bits = rc->avg_frame_bandwidth; rc->long_rolling_actual_bits = rc->avg_frame_bandwidth; @@ -356,13 +343,11 @@ int vp10_rc_drop_frame(VP10_COMP *cpi) { } else { // If buffer is below drop_mark, for now just drop every other frame // (starting with the next frame) until it increases back over drop_mark. - int drop_mark = (int)(oxcf->drop_frames_water_mark * - rc->optimal_buffer_level / 100); - if ((rc->buffer_level > drop_mark) && - (rc->decimation_factor > 0)) { + int drop_mark = + (int)(oxcf->drop_frames_water_mark * rc->optimal_buffer_level / 100); + if ((rc->buffer_level > drop_mark) && (rc->decimation_factor > 0)) { --rc->decimation_factor; - } else if (rc->buffer_level <= drop_mark && - rc->decimation_factor == 0) { + } else if (rc->buffer_level <= drop_mark && rc->decimation_factor == 0) { rc->decimation_factor = 1; } if (rc->decimation_factor > 0) { @@ -389,7 +374,7 @@ static double get_rate_correction_factor(const VP10_COMP *cpi) { rcf = rc->rate_correction_factors[KF_STD]; } else if (cpi->oxcf.pass == 2) { RATE_FACTOR_LEVEL rf_lvl = - cpi->twopass.gf_group.rf_level[cpi->twopass.gf_group.index]; + cpi->twopass.gf_group.rf_level[cpi->twopass.gf_group.index]; rcf = rc->rate_correction_factors[rf_lvl]; } else { if ((cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame) && @@ -415,7 +400,7 @@ static void set_rate_correction_factor(VP10_COMP *cpi, double factor) { rc->rate_correction_factors[KF_STD] = factor; } else if (cpi->oxcf.pass == 2) { RATE_FACTOR_LEVEL rf_lvl = - cpi->twopass.gf_group.rf_level[cpi->twopass.gf_group.index]; + cpi->twopass.gf_group.rf_level[cpi->twopass.gf_group.index]; rc->rate_correction_factors[rf_lvl] = factor; } else { if ((cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame) && @@ -436,8 +421,7 @@ void vp10_rc_update_rate_correction_factors(VP10_COMP *cpi) { int projected_size_based_on_q = 0; // Do not update the rate factors for arf overlay frames. - if (cpi->rc.is_src_frame_alt_ref) - return; + if (cpi->rc.is_src_frame_alt_ref) return; // Clear down mmx registers to allow floating point in what follows vpx_clear_system_state(); @@ -449,21 +433,19 @@ void vp10_rc_update_rate_correction_factors(VP10_COMP *cpi) { projected_size_based_on_q = vp10_cyclic_refresh_estimate_bits_at_q(cpi, rate_correction_factor); } else { - projected_size_based_on_q = vp10_estimate_bits_at_q(cpi->common.frame_type, - cm->base_qindex, - cm->MBs, - rate_correction_factor, - cm->bit_depth); + projected_size_based_on_q = + vp10_estimate_bits_at_q(cpi->common.frame_type, cm->base_qindex, + cm->MBs, rate_correction_factor, cm->bit_depth); } // Work out a size correction factor. if (projected_size_based_on_q > FRAME_OVERHEAD_BITS) correction_factor = (int)((100 * (int64_t)cpi->rc.projected_frame_size) / - projected_size_based_on_q); + projected_size_based_on_q); // More heavily damped adjustment used if we have been oscillating either side // of target. - adjustment_limit = 0.25 + - 0.5 * VPXMIN(1, fabs(log10(0.01 * correction_factor))); + adjustment_limit = + 0.25 + 0.5 * VPXMIN(1, fabs(log10(0.01 * correction_factor))); cpi->rc.q_2_frame = cpi->rc.q_1_frame; cpi->rc.q_1_frame = cm->base_qindex; @@ -477,16 +459,16 @@ void vp10_rc_update_rate_correction_factors(VP10_COMP *cpi) { if (correction_factor > 102) { // We are not already at the worst allowable quality - correction_factor = (int)(100 + ((correction_factor - 100) * - adjustment_limit)); + correction_factor = + (int)(100 + ((correction_factor - 100) * adjustment_limit)); rate_correction_factor = (rate_correction_factor * correction_factor) / 100; // Keep rate_correction_factor within limits if (rate_correction_factor > MAX_BPB_FACTOR) rate_correction_factor = MAX_BPB_FACTOR; } else if (correction_factor < 99) { // We are not already at the best allowable quality - correction_factor = (int)(100 - ((100 - correction_factor) * - adjustment_limit)); + correction_factor = + (int)(100 - ((100 - correction_factor) * adjustment_limit)); rate_correction_factor = (rate_correction_factor * correction_factor) / 100; // Keep rate_correction_factor within limits @@ -497,9 +479,8 @@ void vp10_rc_update_rate_correction_factors(VP10_COMP *cpi) { set_rate_correction_factor(cpi, rate_correction_factor); } - int vp10_rc_regulate_q(const VP10_COMP *cpi, int target_bits_per_frame, - int active_best_quality, int active_worst_quality) { + int active_best_quality, int active_worst_quality) { const VP10_COMMON *const cm = &cpi->common; int q = active_worst_quality; int last_error = INT_MAX; @@ -518,9 +499,8 @@ int vp10_rc_regulate_q(const VP10_COMP *cpi, int target_bits_per_frame, bits_per_mb_at_this_q = (int)vp10_cyclic_refresh_rc_bits_per_mb(cpi, i, correction_factor); } else { - bits_per_mb_at_this_q = (int)vp10_rc_bits_per_mb(cm->frame_type, i, - correction_factor, - cm->bit_depth); + bits_per_mb_at_this_q = (int)vp10_rc_bits_per_mb( + cm->frame_type, i, correction_factor, cm->bit_depth); } if (bits_per_mb_at_this_q <= target_bits_per_mb) { @@ -587,13 +567,13 @@ static int calc_active_worst_quality_one_pass_vbr(const VP10_COMP *cpi) { int active_worst_quality; if (cpi->common.frame_type == KEY_FRAME) { - active_worst_quality = curr_frame == 0 ? rc->worst_quality - : rc->last_q[KEY_FRAME] * 2; + active_worst_quality = + curr_frame == 0 ? rc->worst_quality : rc->last_q[KEY_FRAME] * 2; } else { if (!rc->is_src_frame_alt_ref && (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) { - active_worst_quality = curr_frame == 1 ? rc->last_q[KEY_FRAME] * 5 / 4 - : rc->last_q[INTER_FRAME]; + active_worst_quality = curr_frame == 1 ? rc->last_q[KEY_FRAME] * 5 / 4 + : rc->last_q[INTER_FRAME]; } else { active_worst_quality = curr_frame == 1 ? rc->last_q[KEY_FRAME] * 2 : rc->last_q[INTER_FRAME] * 2; @@ -617,28 +597,27 @@ static int calc_active_worst_quality_one_pass_cbr(const VP10_COMP *cpi) { int adjustment = 0; int active_worst_quality; int ambient_qp; - if (cm->frame_type == KEY_FRAME) - return rc->worst_quality; + if (cm->frame_type == KEY_FRAME) return rc->worst_quality; // For ambient_qp we use minimum of avg_frame_qindex[KEY_FRAME/INTER_FRAME] // for the first few frames following key frame. These are both initialized // to worst_quality and updated with (3/4, 1/4) average in postencode_update. // So for first few frames following key, the qp of that key frame is weighted // into the active_worst_quality setting. - ambient_qp = (cm->current_video_frame < 5) ? - VPXMIN(rc->avg_frame_qindex[INTER_FRAME], - rc->avg_frame_qindex[KEY_FRAME]) : - rc->avg_frame_qindex[INTER_FRAME]; + ambient_qp = (cm->current_video_frame < 5) + ? VPXMIN(rc->avg_frame_qindex[INTER_FRAME], + rc->avg_frame_qindex[KEY_FRAME]) + : rc->avg_frame_qindex[INTER_FRAME]; active_worst_quality = VPXMIN(rc->worst_quality, ambient_qp * 5 / 4); if (rc->buffer_level > rc->optimal_buffer_level) { // Adjust down. // Maximum limit for down adjustment, ~30%. int max_adjustment_down = active_worst_quality / 3; if (max_adjustment_down) { - buff_lvl_step = ((rc->maximum_buffer_size - - rc->optimal_buffer_level) / max_adjustment_down); + buff_lvl_step = ((rc->maximum_buffer_size - rc->optimal_buffer_level) / + max_adjustment_down); if (buff_lvl_step) adjustment = (int)((rc->buffer_level - rc->optimal_buffer_level) / - buff_lvl_step); + buff_lvl_step); active_worst_quality -= adjustment; } } else if (rc->buffer_level > critical_level) { @@ -678,18 +657,16 @@ static int rc_pick_q_and_bounds_one_pass_cbr(const VP10_COMP *cpi, if (rc->this_key_frame_forced) { int qindex = rc->last_boosted_qindex; double last_boosted_q = vp10_convert_qindex_to_q(qindex, cm->bit_depth); - int delta_qindex = vp10_compute_qdelta(rc, last_boosted_q, - (last_boosted_q * 0.75), - cm->bit_depth); + int delta_qindex = vp10_compute_qdelta( + rc, last_boosted_q, (last_boosted_q * 0.75), cm->bit_depth); active_best_quality = VPXMAX(qindex + delta_qindex, rc->best_quality); } else if (cm->current_video_frame > 0) { // not first frame of one pass and kf_boost is set double q_adj_factor = 1.0; double q_val; - active_best_quality = - get_kf_active_quality(rc, rc->avg_frame_qindex[KEY_FRAME], - cm->bit_depth); + active_best_quality = get_kf_active_quality( + rc, rc->avg_frame_qindex[KEY_FRAME], cm->bit_depth); // Allow somewhat lower kf minq with small image formats. if ((cm->width * cm->height) <= (352 * 288)) { @@ -699,9 +676,8 @@ static int rc_pick_q_and_bounds_one_pass_cbr(const VP10_COMP *cpi, // Convert the adjustment factor to a qindex delta // on active_best_quality. q_val = vp10_convert_qindex_to_q(active_best_quality, cm->bit_depth); - active_best_quality += vp10_compute_qdelta(rc, q_val, - q_val * q_adj_factor, - cm->bit_depth); + active_best_quality += + vp10_compute_qdelta(rc, q_val, q_val * q_adj_factor, cm->bit_depth); } } else if (!rc->is_src_frame_alt_ref && (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) { @@ -731,23 +707,21 @@ static int rc_pick_q_and_bounds_one_pass_cbr(const VP10_COMP *cpi, } // Clip the active best and worst quality values to limits - active_best_quality = clamp(active_best_quality, - rc->best_quality, rc->worst_quality); - active_worst_quality = clamp(active_worst_quality, - active_best_quality, rc->worst_quality); + active_best_quality = + clamp(active_best_quality, rc->best_quality, rc->worst_quality); + active_worst_quality = + clamp(active_worst_quality, active_best_quality, rc->worst_quality); *top_index = active_worst_quality; *bottom_index = active_best_quality; // Limit Q range for the adaptive loop. - if (cm->frame_type == KEY_FRAME && - !rc->this_key_frame_forced && + if (cm->frame_type == KEY_FRAME && !rc->this_key_frame_forced && !(cm->current_video_frame == 0)) { int qdelta = 0; vpx_clear_system_state(); - qdelta = vp10_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, - active_worst_quality, 2.0, - cm->bit_depth); + qdelta = vp10_compute_qdelta_by_rate( + &cpi->rc, cm->frame_type, active_worst_quality, 2.0, cm->bit_depth); *top_index = active_worst_quality + qdelta; *top_index = VPXMAX(*top_index, *bottom_index); } @@ -756,8 +730,8 @@ static int rc_pick_q_and_bounds_one_pass_cbr(const VP10_COMP *cpi, if (cm->frame_type == KEY_FRAME && rc->this_key_frame_forced) { q = rc->last_boosted_qindex; } else { - q = vp10_rc_regulate_q(cpi, rc->this_frame_target, - active_best_quality, active_worst_quality); + q = vp10_rc_regulate_q(cpi, rc->this_frame_target, active_best_quality, + active_worst_quality); if (q > *top_index) { // Special case when we are targeting the max allowed rate if (rc->this_frame_target >= rc->max_frame_bandwidth) @@ -767,8 +741,7 @@ static int rc_pick_q_and_bounds_one_pass_cbr(const VP10_COMP *cpi, } } - assert(*top_index <= rc->worst_quality && - *top_index >= rc->best_quality); + assert(*top_index <= rc->worst_quality && *top_index >= rc->best_quality); assert(*bottom_index <= rc->worst_quality && *bottom_index >= rc->best_quality); assert(q <= rc->worst_quality && q >= rc->best_quality); @@ -779,8 +752,7 @@ static int get_active_cq_level(const RATE_CONTROL *rc, const VP10EncoderConfig *const oxcf) { static const double cq_adjust_threshold = 0.1; int active_cq_level = oxcf->cq_level; - if (oxcf->rc_mode == VPX_CQ && - rc->total_target_bits > 0) { + if (oxcf->rc_mode == VPX_CQ && rc->total_target_bits > 0) { const double x = (double)rc->total_actual_bits / rc->total_target_bits; if (x < cq_adjust_threshold) { active_cq_level = (int)(active_cq_level * x / cq_adjust_threshold); @@ -806,24 +778,21 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP10_COMP *cpi, if (oxcf->rc_mode == VPX_Q) { int qindex = cq_level; double q = vp10_convert_qindex_to_q(qindex, cm->bit_depth); - int delta_qindex = vp10_compute_qdelta(rc, q, q * 0.25, - cm->bit_depth); + int delta_qindex = vp10_compute_qdelta(rc, q, q * 0.25, cm->bit_depth); active_best_quality = VPXMAX(qindex + delta_qindex, rc->best_quality); } else if (rc->this_key_frame_forced) { int qindex = rc->last_boosted_qindex; double last_boosted_q = vp10_convert_qindex_to_q(qindex, cm->bit_depth); - int delta_qindex = vp10_compute_qdelta(rc, last_boosted_q, - last_boosted_q * 0.75, - cm->bit_depth); + int delta_qindex = vp10_compute_qdelta( + rc, last_boosted_q, last_boosted_q * 0.75, cm->bit_depth); active_best_quality = VPXMAX(qindex + delta_qindex, rc->best_quality); } else { // not first frame of one pass and kf_boost is set double q_adj_factor = 1.0; double q_val; - active_best_quality = - get_kf_active_quality(rc, rc->avg_frame_qindex[KEY_FRAME], - cm->bit_depth); + active_best_quality = get_kf_active_quality( + rc, rc->avg_frame_qindex[KEY_FRAME], cm->bit_depth); // Allow somewhat lower kf minq with small image formats. if ((cm->width * cm->height) <= (352 * 288)) { @@ -833,9 +802,8 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP10_COMP *cpi, // Convert the adjustment factor to a qindex delta // on active_best_quality. q_val = vp10_convert_qindex_to_q(active_best_quality, cm->bit_depth); - active_best_quality += vp10_compute_qdelta(rc, q_val, - q_val * q_adj_factor, - cm->bit_depth); + active_best_quality += + vp10_compute_qdelta(rc, q_val, q_val * q_adj_factor, cm->bit_depth); } } else if (!rc->is_src_frame_alt_ref && (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) { @@ -850,8 +818,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP10_COMP *cpi, } // For constrained quality dont allow Q less than the cq level if (oxcf->rc_mode == VPX_CQ) { - if (q < cq_level) - q = cq_level; + if (q < cq_level) q = cq_level; active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth); @@ -874,12 +841,11 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP10_COMP *cpi, if (oxcf->rc_mode == VPX_Q) { int qindex = cq_level; double q = vp10_convert_qindex_to_q(qindex, cm->bit_depth); - double delta_rate[FIXED_GF_INTERVAL] = - {0.50, 1.0, 0.85, 1.0, 0.70, 1.0, 0.85, 1.0}; - int delta_qindex = - vp10_compute_qdelta(rc, q, - q * delta_rate[cm->current_video_frame % - FIXED_GF_INTERVAL], cm->bit_depth); + double delta_rate[FIXED_GF_INTERVAL] = { 0.50, 1.0, 0.85, 1.0, + 0.70, 1.0, 0.85, 1.0 }; + int delta_qindex = vp10_compute_qdelta( + rc, q, q * delta_rate[cm->current_video_frame % FIXED_GF_INTERVAL], + cm->bit_depth); active_best_quality = VPXMAX(qindex + delta_qindex, rc->best_quality); } else { // Use the lower of active_worst_quality and recent/average Q. @@ -889,18 +855,17 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP10_COMP *cpi, active_best_quality = inter_minq[rc->avg_frame_qindex[KEY_FRAME]]; // For the constrained quality mode we don't want // q to fall below the cq level. - if ((oxcf->rc_mode == VPX_CQ) && - (active_best_quality < cq_level)) { + if ((oxcf->rc_mode == VPX_CQ) && (active_best_quality < cq_level)) { active_best_quality = cq_level; } } } // Clip the active best and worst quality values to limits - active_best_quality = clamp(active_best_quality, - rc->best_quality, rc->worst_quality); - active_worst_quality = clamp(active_worst_quality, - active_best_quality, rc->worst_quality); + active_best_quality = + clamp(active_best_quality, rc->best_quality, rc->worst_quality); + active_worst_quality = + clamp(active_worst_quality, active_best_quality, rc->worst_quality); *top_index = active_worst_quality; *bottom_index = active_best_quality; @@ -909,17 +874,14 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP10_COMP *cpi, { int qdelta = 0; vpx_clear_system_state(); - if (cm->frame_type == KEY_FRAME && - !rc->this_key_frame_forced && + if (cm->frame_type == KEY_FRAME && !rc->this_key_frame_forced && !(cm->current_video_frame == 0)) { - qdelta = vp10_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, - active_worst_quality, 2.0, - cm->bit_depth); + qdelta = vp10_compute_qdelta_by_rate( + &cpi->rc, cm->frame_type, active_worst_quality, 2.0, cm->bit_depth); } else if (!rc->is_src_frame_alt_ref && (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) { - qdelta = vp10_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, - active_worst_quality, 1.75, - cm->bit_depth); + qdelta = vp10_compute_qdelta_by_rate( + &cpi->rc, cm->frame_type, active_worst_quality, 1.75, cm->bit_depth); } *top_index = active_worst_quality + qdelta; *top_index = VPXMAX(*top_index, *bottom_index); @@ -927,12 +889,12 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP10_COMP *cpi, if (oxcf->rc_mode == VPX_Q) { q = active_best_quality; - // Special case code to try and match quality with forced key frames + // Special case code to try and match quality with forced key frames } else if ((cm->frame_type == KEY_FRAME) && rc->this_key_frame_forced) { q = rc->last_boosted_qindex; } else { - q = vp10_rc_regulate_q(cpi, rc->this_frame_target, - active_best_quality, active_worst_quality); + q = vp10_rc_regulate_q(cpi, rc->this_frame_target, active_best_quality, + active_worst_quality); if (q > *top_index) { // Special case when we are targeting the max allowed rate if (rc->this_frame_target >= rc->max_frame_bandwidth) @@ -942,8 +904,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP10_COMP *cpi, } } - assert(*top_index <= rc->worst_quality && - *top_index >= rc->best_quality); + assert(*top_index <= rc->worst_quality && *top_index >= rc->best_quality); assert(*bottom_index <= rc->worst_quality && *bottom_index >= rc->best_quality); assert(q <= rc->worst_quality && q >= rc->best_quality); @@ -958,7 +919,7 @@ int vp10_frame_type_qdelta(const VP10_COMP *cpi, int rf_level, int q) { 1.50, // INTER_HIGH #else 1.00, // INTER_HIGH -#endif // CONFIG_EXT_REFS +#endif // CONFIG_EXT_REFS 1.50, // GF_ARF_LOW 2.00, // GF_ARF_STD 2.00, // KF_STD @@ -968,19 +929,18 @@ int vp10_frame_type_qdelta(const VP10_COMP *cpi, int rf_level, int q) { { INTER_FRAME, INTER_FRAME, INTER_FRAME, INTER_FRAME, INTER_FRAME, KEY_FRAME }; #else - {INTER_FRAME, INTER_FRAME, INTER_FRAME, INTER_FRAME, KEY_FRAME}; + { INTER_FRAME, INTER_FRAME, INTER_FRAME, INTER_FRAME, KEY_FRAME }; #endif // CONFIG_EXT_REFS const VP10_COMMON *const cm = &cpi->common; - int qdelta = vp10_compute_qdelta_by_rate(&cpi->rc, frame_type[rf_level], - q, rate_factor_deltas[rf_level], - cm->bit_depth); + int qdelta = + vp10_compute_qdelta_by_rate(&cpi->rc, frame_type[rf_level], q, + rate_factor_deltas[rf_level], cm->bit_depth); return qdelta; } #define STATIC_MOTION_THRESH 95 static int rc_pick_q_and_bounds_two_pass(const VP10_COMP *cpi, - int *bottom_index, - int *top_index) { + int *bottom_index, int *top_index) { const VP10_COMMON *const cm = &cpi->common; const RATE_CONTROL *const rc = &cpi->rc; const VP10EncoderConfig *const oxcf = &cpi->oxcf; @@ -1005,17 +965,15 @@ static int rc_pick_q_and_bounds_two_pass(const VP10_COMP *cpi, qindex = VPXMIN(rc->last_kf_qindex, rc->last_boosted_qindex); active_best_quality = qindex; last_boosted_q = vp10_convert_qindex_to_q(qindex, cm->bit_depth); - delta_qindex = vp10_compute_qdelta(rc, last_boosted_q, - last_boosted_q * 1.25, - cm->bit_depth); + delta_qindex = vp10_compute_qdelta( + rc, last_boosted_q, last_boosted_q * 1.25, cm->bit_depth); active_worst_quality = VPXMIN(qindex + delta_qindex, active_worst_quality); } else { qindex = rc->last_boosted_qindex; last_boosted_q = vp10_convert_qindex_to_q(qindex, cm->bit_depth); - delta_qindex = vp10_compute_qdelta(rc, last_boosted_q, - last_boosted_q * 0.75, - cm->bit_depth); + delta_qindex = vp10_compute_qdelta( + rc, last_boosted_q, last_boosted_q * 0.75, cm->bit_depth); active_best_quality = VPXMAX(qindex + delta_qindex, rc->best_quality); } } else { @@ -1024,8 +982,8 @@ static int rc_pick_q_and_bounds_two_pass(const VP10_COMP *cpi, double q_val; // Baseline value derived from cpi->active_worst_quality and kf boost. - active_best_quality = get_kf_active_quality(rc, active_worst_quality, - cm->bit_depth); + active_best_quality = + get_kf_active_quality(rc, active_worst_quality, cm->bit_depth); // Allow somewhat lower kf minq with small image formats. if ((cm->width * cm->height) <= (352 * 288)) { @@ -1038,9 +996,8 @@ static int rc_pick_q_and_bounds_two_pass(const VP10_COMP *cpi, // Convert the adjustment factor to a qindex delta // on active_best_quality. q_val = vp10_convert_qindex_to_q(active_best_quality, cm->bit_depth); - active_best_quality += vp10_compute_qdelta(rc, q_val, - q_val * q_adj_factor, - cm->bit_depth); + active_best_quality += + vp10_compute_qdelta(rc, q_val, q_val * q_adj_factor, cm->bit_depth); } } else if (!rc->is_src_frame_alt_ref && (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) { @@ -1055,8 +1012,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP10_COMP *cpi, } // For constrained quality dont allow Q less than the cq level if (oxcf->rc_mode == VPX_CQ) { - if (q < cq_level) - q = cq_level; + if (q < cq_level) q = cq_level; active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth); @@ -1067,7 +1023,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP10_COMP *cpi, if (!cpi->refresh_alt_ref_frame) { active_best_quality = cq_level; } else { - active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth); + active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth); // Modify best quality for second level arfs. For mode VPX_Q this // becomes the baseline frame q. @@ -1099,43 +1055,41 @@ static int rc_pick_q_and_bounds_two_pass(const VP10_COMP *cpi, (!rc->is_src_frame_alt_ref && (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame))) { active_best_quality -= - (cpi->twopass.extend_minq + cpi->twopass.extend_minq_fast); + (cpi->twopass.extend_minq + cpi->twopass.extend_minq_fast); active_worst_quality += (cpi->twopass.extend_maxq / 2); } else { active_best_quality -= - (cpi->twopass.extend_minq + cpi->twopass.extend_minq_fast) / 2; + (cpi->twopass.extend_minq + cpi->twopass.extend_minq_fast) / 2; active_worst_quality += cpi->twopass.extend_maxq; } } vpx_clear_system_state(); // Static forced key frames Q restrictions dealt with elsewhere. - if (!(frame_is_intra_only(cm)) || - !rc->this_key_frame_forced || + if (!(frame_is_intra_only(cm)) || !rc->this_key_frame_forced || (cpi->twopass.last_kfgroup_zeromotion_pct < STATIC_MOTION_THRESH)) { - int qdelta = vp10_frame_type_qdelta(cpi, gf_group->rf_level[gf_group->index], - active_worst_quality); - active_worst_quality = VPXMAX(active_worst_quality + qdelta, - active_best_quality); + int qdelta = vp10_frame_type_qdelta( + cpi, gf_group->rf_level[gf_group->index], active_worst_quality); + active_worst_quality = + VPXMAX(active_worst_quality + qdelta, active_best_quality); } // Modify active_best_quality for downscaled normal frames. if (rc->frame_size_selector != UNSCALED && !frame_is_kf_gf_arf(cpi)) { - int qdelta = vp10_compute_qdelta_by_rate(rc, cm->frame_type, - active_best_quality, 2.0, - cm->bit_depth); + int qdelta = vp10_compute_qdelta_by_rate( + rc, cm->frame_type, active_best_quality, 2.0, cm->bit_depth); active_best_quality = VPXMAX(active_best_quality + qdelta, rc->best_quality); } - active_best_quality = clamp(active_best_quality, - rc->best_quality, rc->worst_quality); - active_worst_quality = clamp(active_worst_quality, - active_best_quality, rc->worst_quality); + active_best_quality = + clamp(active_best_quality, rc->best_quality, rc->worst_quality); + active_worst_quality = + clamp(active_worst_quality, active_best_quality, rc->worst_quality); if (oxcf->rc_mode == VPX_Q) { q = active_best_quality; - // Special case code to try and match quality with forced key frames. + // Special case code to try and match quality with forced key frames. } else if (frame_is_intra_only(cm) && rc->this_key_frame_forced) { // If static since last kf use better of last boosted and last kf q. if (cpi->twopass.last_kfgroup_zeromotion_pct >= STATIC_MOTION_THRESH) { @@ -1144,8 +1098,8 @@ static int rc_pick_q_and_bounds_two_pass(const VP10_COMP *cpi, q = rc->last_boosted_qindex; } } else { - q = vp10_rc_regulate_q(cpi, rc->this_frame_target, - active_best_quality, active_worst_quality); + q = vp10_rc_regulate_q(cpi, rc->this_frame_target, active_best_quality, + active_worst_quality); if (q > active_worst_quality) { // Special case when we are targeting the max allowed rate. if (rc->this_frame_target >= rc->max_frame_bandwidth) @@ -1159,16 +1113,15 @@ static int rc_pick_q_and_bounds_two_pass(const VP10_COMP *cpi, *top_index = active_worst_quality; *bottom_index = active_best_quality; - assert(*top_index <= rc->worst_quality && - *top_index >= rc->best_quality); + assert(*top_index <= rc->worst_quality && *top_index >= rc->best_quality); assert(*bottom_index <= rc->worst_quality && *bottom_index >= rc->best_quality); assert(q <= rc->worst_quality && q >= rc->best_quality); return q; } -int vp10_rc_pick_q_and_bounds(const VP10_COMP *cpi, - int *bottom_index, int *top_index) { +int vp10_rc_pick_q_and_bounds(const VP10_COMP *cpi, int *bottom_index, + int *top_index) { int q; if (cpi->oxcf.pass == 0) { if (cpi->oxcf.rc_mode == VPX_CBR) @@ -1182,20 +1135,19 @@ int vp10_rc_pick_q_and_bounds(const VP10_COMP *cpi, return q; } -void vp10_rc_compute_frame_size_bounds(const VP10_COMP *cpi, - int frame_target, - int *frame_under_shoot_limit, - int *frame_over_shoot_limit) { +void vp10_rc_compute_frame_size_bounds(const VP10_COMP *cpi, int frame_target, + int *frame_under_shoot_limit, + int *frame_over_shoot_limit) { if (cpi->oxcf.rc_mode == VPX_Q) { *frame_under_shoot_limit = 0; - *frame_over_shoot_limit = INT_MAX; + *frame_over_shoot_limit = INT_MAX; } else { // For very small rate targets where the fractional adjustment // may be tiny make sure there is at least a minimum range. const int tolerance = (cpi->sf.recode_tolerance * frame_target) / 100; *frame_under_shoot_limit = VPXMAX(frame_target - tolerance - 200, 0); - *frame_over_shoot_limit = VPXMIN(frame_target + tolerance + 200, - cpi->rc.max_frame_bandwidth); + *frame_over_shoot_limit = + VPXMIN(frame_target + tolerance + 200, cpi->rc.max_frame_bandwidth); } } @@ -1208,12 +1160,12 @@ void vp10_rc_set_frame_target(VP10_COMP *cpi, int target) { // Modify frame size target when down-scaling. if (cpi->oxcf.resize_mode == RESIZE_DYNAMIC && rc->frame_size_selector != UNSCALED) - rc->this_frame_target = (int)(rc->this_frame_target - * rate_thresh_mult[rc->frame_size_selector]); + rc->this_frame_target = (int)(rc->this_frame_target * + rate_thresh_mult[rc->frame_size_selector]); // Target rate per SB64 (including partial SB64s. - rc->sb64_target_rate = ((int64_t)rc->this_frame_target * 64 * 64) / - (cm->width * cm->height); + rc->sb64_target_rate = + ((int64_t)rc->this_frame_target * 64 * 64) / (cm->width * cm->height); } static void update_alt_ref_frame_stats(VP10_COMP *cpi) { @@ -1238,7 +1190,7 @@ static void update_golden_frame_stats(VP10_COMP *cpi) { // cpi->refresh_golden_frame will still be zero. if (cpi->refresh_golden_frame || rc->is_src_frame_alt_ref) { #else - // Update the Golden frame usage counts. + // Update the Golden frame usage counts. if (cpi->refresh_golden_frame) { #endif // this frame refreshes means next frames don't unless specified by user @@ -1255,13 +1207,11 @@ static void update_golden_frame_stats(VP10_COMP *cpi) { } // Decrement count down till next gf - if (rc->frames_till_gf_update_due > 0) - rc->frames_till_gf_update_due--; + if (rc->frames_till_gf_update_due > 0) rc->frames_till_gf_update_due--; } else if (!cpi->refresh_alt_ref_frame) { // Decrement count down till next gf - if (rc->frames_till_gf_update_due > 0) - rc->frames_till_gf_update_due--; + if (rc->frames_till_gf_update_due > 0) rc->frames_till_gf_update_due--; rc->frames_since_golden++; } @@ -1293,7 +1243,7 @@ void vp10_rc_postencode_update(VP10_COMP *cpi, uint64_t bytes_used) { !(cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) { rc->last_q[INTER_FRAME] = qindex; rc->avg_frame_qindex[INTER_FRAME] = - ROUND_POWER_OF_TWO(3 * rc->avg_frame_qindex[INTER_FRAME] + qindex, 2); + ROUND_POWER_OF_TWO(3 * rc->avg_frame_qindex[INTER_FRAME] + qindex, 2); rc->ni_frames++; rc->tot_q += vp10_convert_qindex_to_q(qindex, cm->bit_depth); rc->avg_q = rc->tot_q / rc->ni_frames; @@ -1309,15 +1259,13 @@ void vp10_rc_postencode_update(VP10_COMP *cpi, uint64_t bytes_used) { // If all mbs in this group are skipped only update if the Q value is // better than that already stored. // This is used to help set quality in forced key frames to reduce popping - if ((qindex < rc->last_boosted_qindex) || - (cm->frame_type == KEY_FRAME) || + if ((qindex < rc->last_boosted_qindex) || (cm->frame_type == KEY_FRAME) || (!rc->constrained_gf_group && (cpi->refresh_alt_ref_frame || (cpi->refresh_golden_frame && !rc->is_src_frame_alt_ref)))) { rc->last_boosted_qindex = qindex; } - if (cm->frame_type == KEY_FRAME) - rc->last_kf_qindex = qindex; + if (cm->frame_type == KEY_FRAME) rc->last_kf_qindex = qindex; update_buffer_level(cpi, rc->projected_frame_size); @@ -1337,8 +1285,8 @@ void vp10_rc_postencode_update(VP10_COMP *cpi, uint64_t bytes_used) { // Actual bits spent rc->total_actual_bits += rc->projected_frame_size; #if CONFIG_EXT_REFS - rc->total_target_bits += (cm->show_frame || rc->is_bwd_ref_frame) ? - rc->avg_frame_bandwidth : 0; + rc->total_target_bits += + (cm->show_frame || rc->is_bwd_ref_frame) ? rc->avg_frame_bandwidth : 0; #else rc->total_target_bits += cm->show_frame ? rc->avg_frame_bandwidth : 0; #endif // CONFIG_EXT_REFS @@ -1353,8 +1301,7 @@ void vp10_rc_postencode_update(VP10_COMP *cpi, uint64_t bytes_used) { // Update the Golden frame stats as appropriate. update_golden_frame_stats(cpi); - if (cm->frame_type == KEY_FRAME) - rc->frames_since_key = 0; + if (cm->frame_type == KEY_FRAME) rc->frames_since_key = 0; #if CONFIG_EXT_REFS if (cm->show_frame || rc->is_bwd_ref_frame) { @@ -1383,19 +1330,20 @@ void vp10_rc_postencode_update_drop_frame(VP10_COMP *cpi) { } // Use this macro to turn on/off use of alt-refs in one-pass mode. -#define USE_ALTREF_FOR_ONE_PASS 1 +#define USE_ALTREF_FOR_ONE_PASS 1 static int calc_pframe_target_size_one_pass_vbr(const VP10_COMP *const cpi) { static const int af_ratio = 10; const RATE_CONTROL *const rc = &cpi->rc; int target; #if USE_ALTREF_FOR_ONE_PASS - target = (!rc->is_src_frame_alt_ref && - (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) ? - (rc->avg_frame_bandwidth * rc->baseline_gf_interval * af_ratio) / - (rc->baseline_gf_interval + af_ratio - 1) : - (rc->avg_frame_bandwidth * rc->baseline_gf_interval) / - (rc->baseline_gf_interval + af_ratio - 1); + target = + (!rc->is_src_frame_alt_ref && + (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) + ? (rc->avg_frame_bandwidth * rc->baseline_gf_interval * af_ratio) / + (rc->baseline_gf_interval + af_ratio - 1) + : (rc->avg_frame_bandwidth * rc->baseline_gf_interval) / + (rc->baseline_gf_interval + af_ratio - 1); #else target = rc->avg_frame_bandwidth; #endif @@ -1415,13 +1363,11 @@ void vp10_rc_get_one_pass_vbr_params(VP10_COMP *cpi) { int target; // TODO(yaowu): replace the "auto_key && 0" below with proper decision logic. if (!cpi->refresh_alt_ref_frame && - (cm->current_video_frame == 0 || - (cpi->frame_flags & FRAMEFLAGS_KEY) || - rc->frames_to_key == 0 || - (cpi->oxcf.auto_key && 0))) { + (cm->current_video_frame == 0 || (cpi->frame_flags & FRAMEFLAGS_KEY) || + rc->frames_to_key == 0 || (cpi->oxcf.auto_key && 0))) { cm->frame_type = KEY_FRAME; - rc->this_key_frame_forced = cm->current_video_frame != 0 && - rc->frames_to_key == 0; + rc->this_key_frame_forced = + cm->current_video_frame != 0 && rc->frames_to_key == 0; rc->frames_to_key = cpi->oxcf.key_freq; rc->kf_boost = DEFAULT_KF_BOOST; rc->source_alt_ref_active = 0; @@ -1460,11 +1406,12 @@ static int calc_pframe_target_size_one_pass_cbr(const VP10_COMP *cpi) { if (oxcf->gf_cbr_boost_pct) { const int af_ratio_pct = oxcf->gf_cbr_boost_pct + 100; - target = cpi->refresh_golden_frame ? - (rc->avg_frame_bandwidth * rc->baseline_gf_interval * af_ratio_pct) / - (rc->baseline_gf_interval * 100 + af_ratio_pct - 100) : - (rc->avg_frame_bandwidth * rc->baseline_gf_interval * 100) / - (rc->baseline_gf_interval * 100 + af_ratio_pct - 100); + target = cpi->refresh_golden_frame + ? (rc->avg_frame_bandwidth * rc->baseline_gf_interval * + af_ratio_pct) / + (rc->baseline_gf_interval * 100 + af_ratio_pct - 100) + : (rc->avg_frame_bandwidth * rc->baseline_gf_interval * 100) / + (rc->baseline_gf_interval * 100 + af_ratio_pct - 100); } else { target = rc->avg_frame_bandwidth; } @@ -1480,8 +1427,8 @@ static int calc_pframe_target_size_one_pass_cbr(const VP10_COMP *cpi) { target += (target * pct_high) / 200; } if (oxcf->rc_max_inter_bitrate_pct) { - const int max_rate = rc->avg_frame_bandwidth * - oxcf->rc_max_inter_bitrate_pct / 100; + const int max_rate = + rc->avg_frame_bandwidth * oxcf->rc_max_inter_bitrate_pct / 100; target = VPXMIN(target, max_rate); } return VPXMAX(min_frame_target, target); @@ -1492,15 +1439,15 @@ static int calc_iframe_target_size_one_pass_cbr(const VP10_COMP *cpi) { int target; if (cpi->common.current_video_frame == 0) { target = ((rc->starting_buffer_level / 2) > INT_MAX) - ? INT_MAX : (int)(rc->starting_buffer_level / 2); + ? INT_MAX + : (int)(rc->starting_buffer_level / 2); } else { int kf_boost = 32; double framerate = cpi->framerate; kf_boost = VPXMAX(kf_boost, (int)(2 * framerate - 16)); - if (rc->frames_since_key < framerate / 2) { - kf_boost = (int)(kf_boost * rc->frames_since_key / - (framerate / 2)); + if (rc->frames_since_key < framerate / 2) { + kf_boost = (int)(kf_boost * rc->frames_since_key / (framerate / 2)); } target = ((16 + kf_boost) * rc->avg_frame_bandwidth) >> 4; } @@ -1512,13 +1459,11 @@ void vp10_rc_get_one_pass_cbr_params(VP10_COMP *cpi) { RATE_CONTROL *const rc = &cpi->rc; int target; // TODO(yaowu): replace the "auto_key && 0" below with proper decision logic. - if ((cm->current_video_frame == 0 || - (cpi->frame_flags & FRAMEFLAGS_KEY) || - rc->frames_to_key == 0 || - (cpi->oxcf.auto_key && 0))) { + if ((cm->current_video_frame == 0 || (cpi->frame_flags & FRAMEFLAGS_KEY) || + rc->frames_to_key == 0 || (cpi->oxcf.auto_key && 0))) { cm->frame_type = KEY_FRAME; - rc->this_key_frame_forced = cm->current_video_frame != 0 && - rc->frames_to_key == 0; + rc->this_key_frame_forced = + cm->current_video_frame != 0 && rc->frames_to_key == 0; rc->frames_to_key = cpi->oxcf.key_freq; rc->kf_boost = DEFAULT_KF_BOOST; rc->source_alt_ref_active = 0; @@ -1557,7 +1502,7 @@ void vp10_rc_get_one_pass_cbr_params(VP10_COMP *cpi) { } int vp10_compute_qdelta(const RATE_CONTROL *rc, double qstart, double qtarget, - vpx_bit_depth_t bit_depth) { + vpx_bit_depth_t bit_depth) { int start_index = rc->worst_quality; int target_index = rc->worst_quality; int i; @@ -1565,29 +1510,27 @@ int vp10_compute_qdelta(const RATE_CONTROL *rc, double qstart, double qtarget, // Convert the average q value to an index. for (i = rc->best_quality; i < rc->worst_quality; ++i) { start_index = i; - if (vp10_convert_qindex_to_q(i, bit_depth) >= qstart) - break; + if (vp10_convert_qindex_to_q(i, bit_depth) >= qstart) break; } // Convert the q target to an index for (i = rc->best_quality; i < rc->worst_quality; ++i) { target_index = i; - if (vp10_convert_qindex_to_q(i, bit_depth) >= qtarget) - break; + if (vp10_convert_qindex_to_q(i, bit_depth) >= qtarget) break; } return target_index - start_index; } int vp10_compute_qdelta_by_rate(const RATE_CONTROL *rc, FRAME_TYPE frame_type, - int qindex, double rate_target_ratio, - vpx_bit_depth_t bit_depth) { + int qindex, double rate_target_ratio, + vpx_bit_depth_t bit_depth) { int target_index = rc->worst_quality; int i; // Look up the current projected bits per block for the base index - const int base_bits_per_mb = vp10_rc_bits_per_mb(frame_type, qindex, 1.0, - bit_depth); + const int base_bits_per_mb = + vp10_rc_bits_per_mb(frame_type, qindex, 1.0, bit_depth); // Find the target bits per mb based on the base value and given ratio. const int target_bits_per_mb = (int)(rate_target_ratio * base_bits_per_mb); @@ -1604,7 +1547,7 @@ int vp10_compute_qdelta_by_rate(const RATE_CONTROL *rc, FRAME_TYPE frame_type, } void vp10_rc_set_gf_interval_range(const VP10_COMP *const cpi, - RATE_CONTROL *const rc) { + RATE_CONTROL *const rc) { const VP10EncoderConfig *const oxcf = &cpi->oxcf; // Special case code for 1 pass fixed Q mode tests @@ -1646,8 +1589,8 @@ void vp10_rc_update_framerate(VP10_COMP *cpi) { int vbr_max_bits; rc->avg_frame_bandwidth = (int)(oxcf->target_bandwidth / cpi->framerate); - rc->min_frame_bandwidth = (int)(rc->avg_frame_bandwidth * - oxcf->two_pass_vbrmin_section / 100); + rc->min_frame_bandwidth = + (int)(rc->avg_frame_bandwidth * oxcf->two_pass_vbrmin_section / 100); rc->min_frame_bandwidth = VPXMAX(rc->min_frame_bandwidth, FRAME_OVERHEAD_BITS); @@ -1659,8 +1602,9 @@ void vp10_rc_update_framerate(VP10_COMP *cpi) { // a very high rate is given on the command line or the the rate cannnot // be acheived because of a user specificed max q (e.g. when the user // specifies lossless encode. - vbr_max_bits = (int)(((int64_t)rc->avg_frame_bandwidth * - oxcf->two_pass_vbrmax_section) / 100); + vbr_max_bits = + (int)(((int64_t)rc->avg_frame_bandwidth * oxcf->two_pass_vbrmax_section) / + 100); rc->max_frame_bandwidth = VPXMAX(VPXMAX((cm->MBs * MAX_MB_RATE), MAXRATE_1080P), vbr_max_bits); @@ -1687,13 +1631,13 @@ static void vbr_rate_correction(VP10_COMP *cpi, int *this_frame_target) { // vbr_bits_off_target > 0 means we have extra bits to spend if (vbr_bits_off_target > 0) { - *this_frame_target += - (vbr_bits_off_target > max_delta) ? max_delta - : (int)vbr_bits_off_target; + *this_frame_target += (vbr_bits_off_target > max_delta) + ? max_delta + : (int)vbr_bits_off_target; } else { - *this_frame_target -= - (vbr_bits_off_target < -max_delta) ? max_delta - : (int)-vbr_bits_off_target; + *this_frame_target -= (vbr_bits_off_target < -max_delta) + ? max_delta + : (int)-vbr_bits_off_target; } // Fast redistribution of bits arising from massive local undershoot. @@ -1776,7 +1720,7 @@ int vp10_resize_one_pass_cbr(VP10_COMP *cpi) { cpi->resize_scale_num = 1; cpi->resize_scale_den = 2; tot_scale_change = (cpi->resize_scale_den * cpi->resize_scale_den) / - (cpi->resize_scale_num * cpi->resize_scale_num); + (cpi->resize_scale_num * cpi->resize_scale_num); // Reset buffer level to optimal, update target size. rc->buffer_level = rc->optimal_buffer_level; rc->bits_off_target = rc->optimal_buffer_level; @@ -1786,26 +1730,22 @@ int vp10_resize_one_pass_cbr(VP10_COMP *cpi) { vp10_cyclic_refresh_reset_resize(cpi); // Get the projected qindex, based on the scaled target frame size (scaled // so target_bits_per_mb in vp10_rc_regulate_q will be correct target). - target_bits_per_frame = (resize_now == 1) ? - rc->this_frame_target * tot_scale_change : - rc->this_frame_target / tot_scale_change; + target_bits_per_frame = (resize_now == 1) + ? rc->this_frame_target * tot_scale_change + : rc->this_frame_target / tot_scale_change; active_worst_quality = calc_active_worst_quality_one_pass_cbr(cpi); - qindex = vp10_rc_regulate_q(cpi, - target_bits_per_frame, - rc->best_quality, - active_worst_quality); + qindex = vp10_rc_regulate_q(cpi, target_bits_per_frame, rc->best_quality, + active_worst_quality); // If resize is down, check if projected q index is close to worst_quality, // and if so, reduce the rate correction factor (since likely can afford // lower q for resized frame). - if (resize_now == 1 && - qindex > 90 * cpi->rc.worst_quality / 100) { + if (resize_now == 1 && qindex > 90 * cpi->rc.worst_quality / 100) { rc->rate_correction_factors[INTER_NORMAL] *= 0.85; } // If resize is back up, check if projected q index is too much above the // current base_qindex, and if so, reduce the rate correction factor // (since prefer to keep q for resized frame at least close to previous q). - if (resize_now == -1 && - qindex > 130 * cm->base_qindex / 100) { + if (resize_now == -1 && qindex > 130 * cm->base_qindex / 100) { rc->rate_correction_factors[INTER_NORMAL] *= 0.9; } } diff --git a/vp10/encoder/ratectrl.h b/vp10/encoder/ratectrl.h index 520dbeb9c..ed9d6fbf9 100644 --- a/vp10/encoder/ratectrl.h +++ b/vp10/encoder/ratectrl.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_RATECTRL_H_ #define VP10_ENCODER_RATECTRL_H_ @@ -22,11 +21,11 @@ extern "C" { #endif // Bits Per MB at different Q (Multiplied by 512) -#define BPER_MB_NORMBITS 9 +#define BPER_MB_NORMBITS 9 -#define MIN_GF_INTERVAL 4 -#define MAX_GF_INTERVAL 16 -#define FIXED_GF_INTERVAL 8 // Used in some testing modes only +#define MIN_GF_INTERVAL 4 +#define MAX_GF_INTERVAL 16 +#define FIXED_GF_INTERVAL 8 // Used in some testing modes only #if CONFIG_EXT_REFS typedef enum { @@ -61,25 +60,25 @@ typedef enum { // e.g. 24 => 16/24 = 2/3 of native size. The restriction to 1/16th is // intended to match the capabilities of the normative scaling filters, // giving precedence to the up-scaling accuracy. -static const int frame_scale_factor[FRAME_SCALE_STEPS] = {16, 24}; +static const int frame_scale_factor[FRAME_SCALE_STEPS] = { 16, 24 }; // Multiplier of the target rate to be used as threshold for triggering scaling. -static const double rate_thresh_mult[FRAME_SCALE_STEPS] = {1.0, 2.0}; +static const double rate_thresh_mult[FRAME_SCALE_STEPS] = { 1.0, 2.0 }; // Scale dependent Rate Correction Factor multipliers. Compensates for the // greater number of bits per pixel generated in down-scaled frames. -static const double rcf_mult[FRAME_SCALE_STEPS] = {1.0, 2.0}; +static const double rcf_mult[FRAME_SCALE_STEPS] = { 1.0, 2.0 }; typedef struct { // Rate targetting variables - int base_frame_target; // A baseline frame target before adjustment - // for previous under or over shoot. - int this_frame_target; // Actual frame target after rc adjustment. + int base_frame_target; // A baseline frame target before adjustment + // for previous under or over shoot. + int this_frame_target; // Actual frame target after rc adjustment. int projected_frame_size; int sb64_target_rate; - int last_q[FRAME_TYPES]; // Separate values for Intra/Inter - int last_boosted_qindex; // Last boosted GF/KF/ARF q - int last_kf_qindex; // Q index of the last key frame coded. + int last_q[FRAME_TYPES]; // Separate values for Intra/Inter + int last_boosted_qindex; // Last boosted GF/KF/ARF q + int last_kf_qindex; // Q index of the last key frame coded. int gfu_boost; int last_boost; @@ -172,17 +171,18 @@ struct VP10_COMP; struct VP10EncoderConfig; void vp10_rc_init(const struct VP10EncoderConfig *oxcf, int pass, - RATE_CONTROL *rc); + RATE_CONTROL *rc); int vp10_estimate_bits_at_q(FRAME_TYPE frame_kind, int q, int mbs, - double correction_factor, - vpx_bit_depth_t bit_depth); + double correction_factor, + vpx_bit_depth_t bit_depth); double vp10_convert_qindex_to_q(int qindex, vpx_bit_depth_t bit_depth); void vp10_rc_init_minq_luts(void); -int vp10_rc_get_default_min_gf_interval(int width, int height, double framerate); +int vp10_rc_get_default_min_gf_interval(int width, int height, + double framerate); // Note vp10_rc_get_default_max_gf_interval() requires the min_gf_interval to // be passed in to ensure that the max_gf_interval returned is at least as bis // as that. @@ -230,28 +230,27 @@ int vp10_rc_drop_frame(struct VP10_COMP *cpi); // Computes frame size bounds. void vp10_rc_compute_frame_size_bounds(const struct VP10_COMP *cpi, - int this_frame_target, - int *frame_under_shoot_limit, - int *frame_over_shoot_limit); + int this_frame_target, + int *frame_under_shoot_limit, + int *frame_over_shoot_limit); // Picks q and q bounds given the target for bits -int vp10_rc_pick_q_and_bounds(const struct VP10_COMP *cpi, - int *bottom_index, - int *top_index); +int vp10_rc_pick_q_and_bounds(const struct VP10_COMP *cpi, int *bottom_index, + int *top_index); // Estimates q to achieve a target bits per frame int vp10_rc_regulate_q(const struct VP10_COMP *cpi, int target_bits_per_frame, - int active_best_quality, int active_worst_quality); + int active_best_quality, int active_worst_quality); // Estimates bits per mb for a given qindex and correction factor. int vp10_rc_bits_per_mb(FRAME_TYPE frame_type, int qindex, - double correction_factor, vpx_bit_depth_t bit_depth); + double correction_factor, vpx_bit_depth_t bit_depth); // Clamping utilities for bitrate targets for iframes and pframes. int vp10_rc_clamp_iframe_target_size(const struct VP10_COMP *const cpi, - int target); + int target); int vp10_rc_clamp_pframe_target_size(const struct VP10_COMP *const cpi, - int target); + int target); // Utility to set frame_target into the RATE_CONTROL structure // This function is called only from the vp10_rc_get_..._params() functions. void vp10_rc_set_frame_target(struct VP10_COMP *cpi, int target); @@ -259,20 +258,20 @@ void vp10_rc_set_frame_target(struct VP10_COMP *cpi, int target); // Computes a q delta (in "q index" terms) to get from a starting q value // to a target q value int vp10_compute_qdelta(const RATE_CONTROL *rc, double qstart, double qtarget, - vpx_bit_depth_t bit_depth); + vpx_bit_depth_t bit_depth); // Computes a q delta (in "q index" terms) to get from a starting q value // to a value that should equate to the given rate ratio. int vp10_compute_qdelta_by_rate(const RATE_CONTROL *rc, FRAME_TYPE frame_type, - int qindex, double rate_target_ratio, - vpx_bit_depth_t bit_depth); + int qindex, double rate_target_ratio, + vpx_bit_depth_t bit_depth); int vp10_frame_type_qdelta(const struct VP10_COMP *cpi, int rf_level, int q); void vp10_rc_update_framerate(struct VP10_COMP *cpi); void vp10_rc_set_gf_interval_range(const struct VP10_COMP *const cpi, - RATE_CONTROL *const rc); + RATE_CONTROL *const rc); void vp10_set_target_rate(struct VP10_COMP *cpi); diff --git a/vp10/encoder/rd.c b/vp10/encoder/rd.c index 4d2380be4..c03a6ef5e 100644 --- a/vp10/encoder/rd.c +++ b/vp10/encoder/rd.c @@ -40,7 +40,7 @@ #include "vp10/encoder/rd.h" #include "vp10/encoder/tokenize.h" -#define RD_THRESH_POW 1.25 +#define RD_THRESH_POW 1.25 // Factor to weigh the rate for switchable interp filters. #define SWITCHABLE_INTERP_RATE_FACTOR 1 @@ -62,7 +62,7 @@ void vp10_rd_cost_init(RD_COST *rd_cost) { // This table is used to correct for block size. // The factors here are << 2 (2 = x0.5, 32 = x8 etc). static const uint8_t rd_thresh_block_size_factor[BLOCK_SIZES] = { - 2, 3, 3, 4, 6, 6, 8, 12, 12, 16, 24, 24, 32, + 2, 3, 3, 4, 6, 6, 8, 12, 12, 16, 24, 24, 32, #if CONFIG_EXT_PARTITION 48, 48, 64 #endif // CONFIG_EXT_PARTITION @@ -75,19 +75,20 @@ static void fill_mode_costs(VP10_COMP *cpi) { for (i = 0; i < INTRA_MODES; ++i) for (j = 0; j < INTRA_MODES; ++j) vp10_cost_tokens(cpi->y_mode_costs[i][j], vp10_kf_y_mode_prob[i][j], - vp10_intra_mode_tree); + vp10_intra_mode_tree); for (i = 0; i < BLOCK_SIZE_GROUPS; ++i) vp10_cost_tokens(cpi->mbmode_cost[i], fc->y_mode_prob[i], vp10_intra_mode_tree); for (i = 0; i < INTRA_MODES; ++i) - vp10_cost_tokens(cpi->intra_uv_mode_cost[i], - fc->uv_mode_prob[i], vp10_intra_mode_tree); + vp10_cost_tokens(cpi->intra_uv_mode_cost[i], fc->uv_mode_prob[i], + vp10_intra_mode_tree); for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) vp10_cost_tokens(cpi->switchable_interp_costs[i], - fc->switchable_interp_prob[i], vp10_switchable_interp_tree); + fc->switchable_interp_prob[i], + vp10_switchable_interp_tree); for (i = 0; i < PALETTE_BLOCK_SIZES; ++i) { vp10_cost_tokens(cpi->palette_y_size_cost[i], @@ -136,12 +137,10 @@ static void fill_mode_costs(VP10_COMP *cpi) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { for (j = 0; j < TX_TYPES; ++j) vp10_cost_tokens(cpi->intra_tx_type_costs[i][j], - fc->intra_ext_tx_prob[i][j], - vp10_ext_tx_tree); + fc->intra_ext_tx_prob[i][j], vp10_ext_tx_tree); } for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { - vp10_cost_tokens(cpi->inter_tx_type_costs[i], - fc->inter_ext_tx_prob[i], + vp10_cost_tokens(cpi->inter_tx_type_costs[i], fc->inter_ext_tx_prob[i], vp10_ext_tx_tree); } #endif // CONFIG_EXT_TX @@ -173,10 +172,9 @@ void vp10_fill_token_costs(vp10_coeff_cost *c, #else vpx_prob probs[ENTROPY_NODES]; vp10_model_to_full_probs(p[t][i][j][k][l], probs); - vp10_cost_tokens((int *)c[t][i][j][k][0][l], probs, - vp10_coef_tree); + vp10_cost_tokens((int *)c[t][i][j][k][0][l], probs, vp10_coef_tree); vp10_cost_tokens_skip((int *)c[t][i][j][k][1][l], probs, - vp10_coef_tree); + vp10_coef_tree); #endif // CONFIG_ANS assert(c[t][i][j][k][0][l][EOB_TOKEN] == c[t][i][j][k][1][l][EOB_TOKEN]); @@ -218,10 +216,8 @@ void vp10_init_me_luts(void) { #endif } -static const int rd_boost_factor[16] = { - 64, 32, 32, 32, 24, 16, 12, 12, - 8, 8, 4, 4, 2, 2, 1, 0 -}; +static const int rd_boost_factor[16] = { 64, 32, 32, 32, 24, 16, 12, 12, + 8, 8, 4, 4, 2, 2, 1, 0 }; static const int rd_frame_type_factor[FRAME_UPDATE_TYPES] = { 128, 144, 128, 128, 144, #if CONFIG_EXT_REFS @@ -235,15 +231,9 @@ int vp10_compute_rd_mult(const VP10_COMP *cpi, int qindex) { #if CONFIG_VP9_HIGHBITDEPTH int64_t rdmult = 0; switch (cpi->common.bit_depth) { - case VPX_BITS_8: - rdmult = 88 * q * q / 24; - break; - case VPX_BITS_10: - rdmult = ROUND_POWER_OF_TWO(88 * q * q / 24, 4); - break; - case VPX_BITS_12: - rdmult = ROUND_POWER_OF_TWO(88 * q * q / 24, 8); - break; + case VPX_BITS_8: rdmult = 88 * q * q / 24; break; + case VPX_BITS_10: rdmult = ROUND_POWER_OF_TWO(88 * q * q / 24, 4); break; + case VPX_BITS_12: rdmult = ROUND_POWER_OF_TWO(88 * q * q / 24, 8); break; default: assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12"); return -1; @@ -259,8 +249,7 @@ int vp10_compute_rd_mult(const VP10_COMP *cpi, int qindex) { rdmult = (rdmult * rd_frame_type_factor[frame_type]) >> 7; rdmult += ((rdmult * rd_boost_factor[boost_index]) >> 7); } - if (rdmult < 1) - rdmult = 1; + if (rdmult < 1) rdmult = 1; return (int)rdmult; } @@ -268,21 +257,15 @@ static int compute_rd_thresh_factor(int qindex, vpx_bit_depth_t bit_depth) { double q; #if CONFIG_VP9_HIGHBITDEPTH switch (bit_depth) { - case VPX_BITS_8: - q = vp10_dc_quant(qindex, 0, VPX_BITS_8) / 4.0; - break; - case VPX_BITS_10: - q = vp10_dc_quant(qindex, 0, VPX_BITS_10) / 16.0; - break; - case VPX_BITS_12: - q = vp10_dc_quant(qindex, 0, VPX_BITS_12) / 64.0; - break; + case VPX_BITS_8: q = vp10_dc_quant(qindex, 0, VPX_BITS_8) / 4.0; break; + case VPX_BITS_10: q = vp10_dc_quant(qindex, 0, VPX_BITS_10) / 16.0; break; + case VPX_BITS_12: q = vp10_dc_quant(qindex, 0, VPX_BITS_12) / 64.0; break; default: assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12"); return -1; } #else - (void) bit_depth; + (void)bit_depth; q = vp10_dc_quant(qindex, 0, VPX_BITS_8) / 4.0; #endif // CONFIG_VP9_HIGHBITDEPTH // TODO(debargha): Adjust the function below. @@ -321,7 +304,8 @@ static void set_block_thresholds(const VP10_COMMON *cm, RD_OPT *rd) { for (segment_id = 0; segment_id < MAX_SEGMENTS; ++segment_id) { const int qindex = clamp(vp10_get_qindex(&cm->seg, segment_id, cm->base_qindex) + - cm->y_dc_delta_q, 0, MAXQ); + cm->y_dc_delta_q, + 0, MAXQ); const int q = compute_rd_thresh_factor(qindex, cm->bit_depth); for (bsize = 0; bsize < BLOCK_SIZES; ++bsize) { @@ -332,10 +316,9 @@ static void set_block_thresholds(const VP10_COMMON *cm, RD_OPT *rd) { if (bsize >= BLOCK_8X8) { for (i = 0; i < MAX_MODES; ++i) - rd->threshes[segment_id][bsize][i] = - rd->thresh_mult[i] < thresh_max - ? rd->thresh_mult[i] * t / 4 - : INT_MAX; + rd->threshes[segment_id][bsize][i] = rd->thresh_mult[i] < thresh_max + ? rd->thresh_mult[i] * t / 4 + : INT_MAX; } else { for (i = 0; i < MAX_REFS; ++i) rd->threshes[segment_id][bsize][i] = @@ -357,8 +340,8 @@ void vp10_set_mvcost(MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame) { x->mvsadcost = x->mvcost; x->nmvjointsadcost = x->nmvjointcost; - x->nmv_vec_cost[nmv_ctx][MV_JOINT_ZERO] = - x->zero_rmv_cost[nmv_ctx][1] - x->zero_rmv_cost[nmv_ctx][0]; + x->nmv_vec_cost[nmv_ctx][MV_JOINT_ZERO] = + x->zero_rmv_cost[nmv_ctx][1] - x->zero_rmv_cost[nmv_ctx][0]; } #endif @@ -475,8 +458,8 @@ void vp10_initialize_rd_consts(VP10_COMP *cpi) { #endif // CONFIG_EXT_INTER #if CONFIG_OBMC || CONFIG_WARPED_MOTION for (i = BLOCK_8X8; i < BLOCK_SIZES; i++) { - vp10_cost_tokens((int *)cpi->motvar_cost[i], - cm->fc->motvar_prob[i], vp10_motvar_tree); + vp10_cost_tokens((int *)cpi->motvar_cost[i], cm->fc->motvar_prob[i], + vp10_motvar_tree); } #endif // CONFIG_OBMC || CONFIG_WARPED_MOTION } @@ -497,19 +480,15 @@ static void model_rd_norm(int xsq_q10, int *r_q10, int *d_q10) { // where r = exp(-sqrt(2) * x) and x = qpstep / sqrt(variance), // and H(x) is the binary entropy function. static const int rate_tab_q10[] = { - 65536, 6086, 5574, 5275, 5063, 4899, 4764, 4651, - 4553, 4389, 4255, 4142, 4044, 3958, 3881, 3811, - 3748, 3635, 3538, 3453, 3376, 3307, 3244, 3186, - 3133, 3037, 2952, 2877, 2809, 2747, 2690, 2638, - 2589, 2501, 2423, 2353, 2290, 2232, 2179, 2130, - 2084, 2001, 1928, 1862, 1802, 1748, 1698, 1651, - 1608, 1530, 1460, 1398, 1342, 1290, 1243, 1199, - 1159, 1086, 1021, 963, 911, 864, 821, 781, - 745, 680, 623, 574, 530, 490, 455, 424, - 395, 345, 304, 269, 239, 213, 190, 171, - 154, 126, 104, 87, 73, 61, 52, 44, - 38, 28, 21, 16, 12, 10, 8, 6, - 5, 3, 2, 1, 1, 1, 0, 0, + 65536, 6086, 5574, 5275, 5063, 4899, 4764, 4651, 4553, 4389, 4255, 4142, + 4044, 3958, 3881, 3811, 3748, 3635, 3538, 3453, 3376, 3307, 3244, 3186, + 3133, 3037, 2952, 2877, 2809, 2747, 2690, 2638, 2589, 2501, 2423, 2353, + 2290, 2232, 2179, 2130, 2084, 2001, 1928, 1862, 1802, 1748, 1698, 1651, + 1608, 1530, 1460, 1398, 1342, 1290, 1243, 1199, 1159, 1086, 1021, 963, + 911, 864, 821, 781, 745, 680, 623, 574, 530, 490, 455, 424, + 395, 345, 304, 269, 239, 213, 190, 171, 154, 126, 104, 87, + 73, 61, 52, 44, 38, 28, 21, 16, 12, 10, 8, 6, + 5, 3, 2, 1, 1, 1, 0, 0, }; // Normalized distortion: // This table models the normalized distortion for a Laplacian source @@ -519,34 +498,29 @@ static void model_rd_norm(int xsq_q10, int *r_q10, int *d_q10) { // where x = qpstep / sqrt(variance). // Note the actual distortion is Dn * variance. static const int dist_tab_q10[] = { - 0, 0, 1, 1, 1, 2, 2, 2, - 3, 3, 4, 5, 5, 6, 7, 7, - 8, 9, 11, 12, 13, 15, 16, 17, - 18, 21, 24, 26, 29, 31, 34, 36, - 39, 44, 49, 54, 59, 64, 69, 73, - 78, 88, 97, 106, 115, 124, 133, 142, - 151, 167, 184, 200, 215, 231, 245, 260, - 274, 301, 327, 351, 375, 397, 418, 439, - 458, 495, 528, 559, 587, 613, 637, 659, - 680, 717, 749, 777, 801, 823, 842, 859, - 874, 899, 919, 936, 949, 960, 969, 977, - 983, 994, 1001, 1006, 1010, 1013, 1015, 1017, - 1018, 1020, 1022, 1022, 1023, 1023, 1023, 1024, + 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, + 5, 6, 7, 7, 8, 9, 11, 12, 13, 15, 16, 17, + 18, 21, 24, 26, 29, 31, 34, 36, 39, 44, 49, 54, + 59, 64, 69, 73, 78, 88, 97, 106, 115, 124, 133, 142, + 151, 167, 184, 200, 215, 231, 245, 260, 274, 301, 327, 351, + 375, 397, 418, 439, 458, 495, 528, 559, 587, 613, 637, 659, + 680, 717, 749, 777, 801, 823, 842, 859, 874, 899, 919, 936, + 949, 960, 969, 977, 983, 994, 1001, 1006, 1010, 1013, 1015, 1017, + 1018, 1020, 1022, 1022, 1023, 1023, 1023, 1024, }; static const int xsq_iq_q10[] = { - 0, 4, 8, 12, 16, 20, 24, 28, - 32, 40, 48, 56, 64, 72, 80, 88, - 96, 112, 128, 144, 160, 176, 192, 208, - 224, 256, 288, 320, 352, 384, 416, 448, - 480, 544, 608, 672, 736, 800, 864, 928, - 992, 1120, 1248, 1376, 1504, 1632, 1760, 1888, - 2016, 2272, 2528, 2784, 3040, 3296, 3552, 3808, - 4064, 4576, 5088, 5600, 6112, 6624, 7136, 7648, - 8160, 9184, 10208, 11232, 12256, 13280, 14304, 15328, - 16352, 18400, 20448, 22496, 24544, 26592, 28640, 30688, - 32736, 36832, 40928, 45024, 49120, 53216, 57312, 61408, - 65504, 73696, 81888, 90080, 98272, 106464, 114656, 122848, - 131040, 147424, 163808, 180192, 196576, 212960, 229344, 245728, + 0, 4, 8, 12, 16, 20, 24, 28, 32, + 40, 48, 56, 64, 72, 80, 88, 96, 112, + 128, 144, 160, 176, 192, 208, 224, 256, 288, + 320, 352, 384, 416, 448, 480, 544, 608, 672, + 736, 800, 864, 928, 992, 1120, 1248, 1376, 1504, + 1632, 1760, 1888, 2016, 2272, 2528, 2784, 3040, 3296, + 3552, 3808, 4064, 4576, 5088, 5600, 6112, 6624, 7136, + 7648, 8160, 9184, 10208, 11232, 12256, 13280, 14304, 15328, + 16352, 18400, 20448, 22496, 24544, 26592, 28640, 30688, 32736, + 36832, 40928, 45024, 49120, 53216, 57312, 61408, 65504, 73696, + 81888, 90080, 98272, 106464, 114656, 122848, 131040, 147424, 163808, + 180192, 196576, 212960, 229344, 245728, }; const int tmp = (xsq_q10 >> 2) + 8; const int k = get_msb(tmp) - 3; @@ -627,9 +601,7 @@ static void get_entropy_contexts_plane( for (i = 0; i < num_4x4_h; i += 8) t_left[i] = !!*(const uint64_t *)&left[i]; break; - default: - assert(0 && "Invalid transform size."); - break; + default: assert(0 && "Invalid transform size."); break; } } @@ -641,9 +613,8 @@ void vp10_get_entropy_contexts(BLOCK_SIZE bsize, TX_SIZE tx_size, get_entropy_contexts_plane(plane_bsize, tx_size, pd, t_above, t_left); } -void vp10_mv_pred(VP10_COMP *cpi, MACROBLOCK *x, - uint8_t *ref_y_buffer, int ref_y_stride, - int ref_frame, BLOCK_SIZE block_size) { +void vp10_mv_pred(VP10_COMP *cpi, MACROBLOCK *x, uint8_t *ref_y_buffer, + int ref_y_stride, int ref_frame, BLOCK_SIZE block_size) { int i; int zero_seen = 0; int best_index = 0; @@ -653,9 +624,9 @@ void vp10_mv_pred(VP10_COMP *cpi, MACROBLOCK *x, int near_same_nearest; uint8_t *src_y_ptr = x->plane[0].src.buf; uint8_t *ref_y_ptr; - const int num_mv_refs = MAX_MV_REF_CANDIDATES + - (cpi->sf.adaptive_motion_search && - block_size < x->max_partition_size); + const int num_mv_refs = + MAX_MV_REF_CANDIDATES + + (cpi->sf.adaptive_motion_search && block_size < x->max_partition_size); MV pred_mv[3]; pred_mv[0] = x->mbmi_ext->ref_mvs[ref_frame][0].as_mv; @@ -663,25 +634,22 @@ void vp10_mv_pred(VP10_COMP *cpi, MACROBLOCK *x, pred_mv[2] = x->pred_mv[ref_frame]; assert(num_mv_refs <= (int)(sizeof(pred_mv) / sizeof(pred_mv[0]))); - near_same_nearest = - x->mbmi_ext->ref_mvs[ref_frame][0].as_int == - x->mbmi_ext->ref_mvs[ref_frame][1].as_int; + near_same_nearest = x->mbmi_ext->ref_mvs[ref_frame][0].as_int == + x->mbmi_ext->ref_mvs[ref_frame][1].as_int; // Get the sad for each candidate reference mv. for (i = 0; i < num_mv_refs; ++i) { const MV *this_mv = &pred_mv[i]; int fp_row, fp_col; - if (i == 1 && near_same_nearest) - continue; + if (i == 1 && near_same_nearest) continue; fp_row = (this_mv->row + 3 + (this_mv->row >= 0)) >> 3; fp_col = (this_mv->col + 3 + (this_mv->col >= 0)) >> 3; max_mv = VPXMAX(max_mv, VPXMAX(abs(this_mv->row), abs(this_mv->col)) >> 3); - if (fp_row ==0 && fp_col == 0 && zero_seen) - continue; - zero_seen |= (fp_row ==0 && fp_col == 0); + if (fp_row == 0 && fp_col == 0 && zero_seen) continue; + zero_seen |= (fp_row == 0 && fp_col == 0); - ref_y_ptr =&ref_y_buffer[ref_y_stride * fp_row + fp_col]; + ref_y_ptr = &ref_y_buffer[ref_y_stride * fp_row + fp_col]; // Find sad for current vector. this_sad = cpi->fn_ptr[block_size].sdf(src_y_ptr, x->plane[0].src.stride, ref_y_ptr, ref_y_stride); @@ -699,11 +667,10 @@ void vp10_mv_pred(VP10_COMP *cpi, MACROBLOCK *x, } void vp10_setup_pred_block(const MACROBLOCKD *xd, - struct buf_2d dst[MAX_MB_PLANE], - const YV12_BUFFER_CONFIG *src, - int mi_row, int mi_col, - const struct scale_factors *scale, - const struct scale_factors *scale_uv) { + struct buf_2d dst[MAX_MB_PLANE], + const YV12_BUFFER_CONFIG *src, int mi_row, + int mi_col, const struct scale_factors *scale, + const struct scale_factors *scale_uv) { int i; dst[0].buf = src->y_buffer; @@ -716,34 +683,33 @@ void vp10_setup_pred_block(const MACROBLOCKD *xd, setup_pred_plane(dst + i, dst[i].buf, i ? src->uv_crop_width : src->y_crop_width, i ? src->uv_crop_height : src->y_crop_height, - dst[i].stride, mi_row, mi_col, - i ? scale_uv : scale, + dst[i].stride, mi_row, mi_col, i ? scale_uv : scale, xd->plane[i].subsampling_x, xd->plane[i].subsampling_y); } } -int vp10_raster_block_offset(BLOCK_SIZE plane_bsize, - int raster_block, int stride) { +int vp10_raster_block_offset(BLOCK_SIZE plane_bsize, int raster_block, + int stride) { const int bw = b_width_log2_lookup[plane_bsize]; const int y = 4 * (raster_block >> bw); const int x = 4 * (raster_block & ((1 << bw) - 1)); return y * stride + x; } -int16_t* vp10_raster_block_offset_int16(BLOCK_SIZE plane_bsize, - int raster_block, int16_t *base) { +int16_t *vp10_raster_block_offset_int16(BLOCK_SIZE plane_bsize, + int raster_block, int16_t *base) { const int stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; return base + vp10_raster_block_offset(plane_bsize, raster_block, stride); } YV12_BUFFER_CONFIG *vp10_get_scaled_ref_frame(const VP10_COMP *cpi, - int ref_frame) { + int ref_frame) { const VP10_COMMON *const cm = &cpi->common; const int scaled_idx = cpi->scaled_ref_idx[ref_frame - 1]; const int ref_idx = get_ref_frame_buf_idx(cpi, ref_frame); - return - (scaled_idx != ref_idx && scaled_idx != INVALID_IDX) ? - &cm->buffer_pool->frame_bufs[scaled_idx].buf : NULL; + return (scaled_idx != ref_idx && scaled_idx != INVALID_IDX) + ? &cm->buffer_pool->frame_bufs[scaled_idx].buf + : NULL; } #if CONFIG_DUAL_FILTER @@ -773,7 +739,7 @@ int vp10_get_switchable_rate(const VP10_COMP *cpi, if (!vp10_is_interp_needed(xd)) return 0; #endif // CONFIG_EXT_INTERP return SWITCHABLE_INTERP_RATE_FACTOR * - cpi->switchable_interp_costs[ctx][mbmi->interp_filter]; + cpi->switchable_interp_costs[ctx][mbmi->interp_filter]; } #endif @@ -1013,52 +979,52 @@ void vp10_set_rd_speed_thresholds(VP10_COMP *cpi) { rd->thresh_mult[THR_D153_PRED] += 2500; rd->thresh_mult[THR_D63_PRED] += 2500; rd->thresh_mult[THR_D117_PRED] += 2500; - rd->thresh_mult[THR_D45_PRED ] += 2500; + rd->thresh_mult[THR_D45_PRED] += 2500; #if CONFIG_EXT_INTER - rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL ] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEARL ] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEWL ] += 2000; + rd->thresh_mult[THR_COMP_INTERINTRA_NEARL] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_NEWL] += 2000; #if CONFIG_EXT_REFS - rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL2 ] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL2] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL2] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEARL2 ] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEWL2 ] += 2000; + rd->thresh_mult[THR_COMP_INTERINTRA_NEARL2] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_NEWL2] += 2000; - rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL3 ] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL3] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL3] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEARL3 ] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEWL3 ] += 2000; + rd->thresh_mult[THR_COMP_INTERINTRA_NEARL3] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_NEWL3] += 2000; #endif // CONFIG_EXT_REFS - rd->thresh_mult[THR_COMP_INTERINTRA_ZEROG ] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_ZEROG] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTG] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEARG ] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEWG ] += 2000; + rd->thresh_mult[THR_COMP_INTERINTRA_NEARG] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_NEWG] += 2000; #if CONFIG_EXT_REFS - rd->thresh_mult[THR_COMP_INTERINTRA_ZEROB ] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_ZEROB] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTB] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEARB ] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEWB ] += 2000; + rd->thresh_mult[THR_COMP_INTERINTRA_NEARB] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_NEWB] += 2000; #endif // CONFIG_EXT_REFS - rd->thresh_mult[THR_COMP_INTERINTRA_ZEROA ] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_ZEROA] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTA] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEARA ] += 1500; - rd->thresh_mult[THR_COMP_INTERINTRA_NEWA ] += 2000; + rd->thresh_mult[THR_COMP_INTERINTRA_NEARA] += 1500; + rd->thresh_mult[THR_COMP_INTERINTRA_NEWA] += 2000; #endif // CONFIG_EXT_INTER } void vp10_set_rd_speed_thresholds_sub8x8(VP10_COMP *cpi) { static const int thresh_mult[2][MAX_REFS] = { #if CONFIG_EXT_REFS - { 2500, 2500, 2500, 2500, 2500, 2500, 4500, 4500, - 4500, 4500, 4500, 4500, 4500, 4500, 2500 }, - { 2000, 2000, 2000, 2000, 2000, 2000, 4000, 4000, - 4000, 4000, 4000, 4000, 4000, 4000, 2000 } + { 2500, 2500, 2500, 2500, 2500, 2500, 4500, 4500, 4500, 4500, 4500, 4500, + 4500, 4500, 2500 }, + { 2000, 2000, 2000, 2000, 2000, 2000, 4000, 4000, 4000, 4000, 4000, 4000, + 4000, 4000, 2000 } #else { 2500, 2500, 2500, 4500, 4500, 2500 }, { 2000, 2000, 2000, 4000, 4000, 2000 } @@ -1092,16 +1058,13 @@ void vp10_update_rd_thresh_fact(const VP10_COMMON *const cm, } int vp10_get_intra_cost_penalty(int qindex, int qdelta, - vpx_bit_depth_t bit_depth) { + vpx_bit_depth_t bit_depth) { const int q = vp10_dc_quant(qindex, qdelta, bit_depth); #if CONFIG_VP9_HIGHBITDEPTH switch (bit_depth) { - case VPX_BITS_8: - return 20 * q; - case VPX_BITS_10: - return 5 * q; - case VPX_BITS_12: - return ROUND_POWER_OF_TWO(5 * q, 2); + case VPX_BITS_8: return 20 * q; + case VPX_BITS_10: return 5 * q; + case VPX_BITS_12: return ROUND_POWER_OF_TWO(5 * q, 2); default: assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12"); return -1; @@ -1110,4 +1073,3 @@ int vp10_get_intra_cost_penalty(int qindex, int qdelta, return 20 * q; #endif // CONFIG_VP9_HIGHBITDEPTH } - diff --git a/vp10/encoder/rd.h b/vp10/encoder/rd.h index b668f1063..bda10fb59 100644 --- a/vp10/encoder/rd.h +++ b/vp10/encoder/rd.h @@ -26,8 +26,8 @@ extern "C" { #endif -#define RDDIV_BITS 7 -#define RD_EPB_SHIFT 6 +#define RDDIV_BITS 7 +#define RD_EPB_SHIFT 6 #define RDCOST(RM, DM, R, D) \ (ROUND_POWER_OF_TWO(((int64_t)R) * (RM), VP9_PROB_COST_SHIFT) + (D << DM)) @@ -36,10 +36,10 @@ extern "C" { (((((double)(R)) * (RM)) / (double)(1 << VP9_PROB_COST_SHIFT)) + \ ((double)(D) * (1 << (DM)))) -#define QIDX_SKIP_THRESH 115 +#define QIDX_SKIP_THRESH 115 -#define MV_COST_WEIGHT 108 -#define MV_COST_WEIGHT_SUB 120 +#define MV_COST_WEIGHT 108 +#define MV_COST_WEIGHT_SUB 120 #define INVALID_MV 0x80008000 @@ -62,13 +62,13 @@ extern "C" { #endif // CONFIG_EXT_REFS #if CONFIG_EXT_REFS -#define MAX_REFS 15 +#define MAX_REFS 15 #else -#define MAX_REFS 6 +#define MAX_REFS 6 #endif // CONFIG_EXT_REFS #define RD_THRESH_MAX_FACT 64 -#define RD_THRESH_INC 1 +#define RD_THRESH_INC 1 // This enumerator type needs to be kept aligned with the mode order in // const MODE_DEFINITION vp10_mode_order[MAX_MODES] used in the rd code. @@ -391,8 +391,8 @@ int vp10_compute_rd_mult(const struct VP10_COMP *cpi, int qindex); void vp10_initialize_rd_consts(struct VP10_COMP *cpi); -void vp10_initialize_me_consts(const struct VP10_COMP *cpi, - MACROBLOCK *x, int qindex); +void vp10_initialize_me_consts(const struct VP10_COMP *cpi, MACROBLOCK *x, + int qindex); void vp10_model_rd_from_var_lapndz(int64_t var, unsigned int n, unsigned int qstep, int *rate, @@ -401,10 +401,10 @@ void vp10_model_rd_from_var_lapndz(int64_t var, unsigned int n, int vp10_get_switchable_rate(const struct VP10_COMP *cpi, const MACROBLOCKD *const xd); -int vp10_raster_block_offset(BLOCK_SIZE plane_bsize, - int raster_block, int stride); +int vp10_raster_block_offset(BLOCK_SIZE plane_bsize, int raster_block, + int stride); -int16_t* vp10_raster_block_offset_int16(BLOCK_SIZE plane_bsize, +int16_t *vp10_raster_block_offset_int16(BLOCK_SIZE plane_bsize, int raster_block, int16_t *base); YV12_BUFFER_CONFIG *vp10_get_scaled_ref_frame(const struct VP10_COMP *cpi, @@ -437,12 +437,11 @@ void vp10_fill_token_costs(vp10_coeff_cost *c, static INLINE int rd_less_than_thresh(int64_t best_rd, int thresh, int thresh_fact) { - return best_rd < ((int64_t)thresh * thresh_fact >> 5) || thresh == INT_MAX; + return best_rd < ((int64_t)thresh * thresh_fact >> 5) || thresh == INT_MAX; } -void vp10_mv_pred(struct VP10_COMP *cpi, MACROBLOCK *x, - uint8_t *ref_y_buffer, int ref_y_stride, - int ref_frame, BLOCK_SIZE block_size); +void vp10_mv_pred(struct VP10_COMP *cpi, MACROBLOCK *x, uint8_t *ref_y_buffer, + int ref_y_stride, int ref_frame, BLOCK_SIZE block_size); static INLINE void set_error_per_bit(MACROBLOCK *x, int rdmult) { x->errorperbit = rdmult >> RD_EPB_SHIFT; @@ -451,9 +450,8 @@ static INLINE void set_error_per_bit(MACROBLOCK *x, int rdmult) { void vp10_setup_pred_block(const MACROBLOCKD *xd, struct buf_2d dst[MAX_MB_PLANE], - const YV12_BUFFER_CONFIG *src, - int mi_row, int mi_col, - const struct scale_factors *scale, + const YV12_BUFFER_CONFIG *src, int mi_row, + int mi_col, const struct scale_factors *scale, const struct scale_factors *scale_uv); int vp10_get_intra_cost_penalty(int qindex, int qdelta, diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c index a0660de47..5591d9a15 100644 --- a/vp10/encoder/rdopt.c +++ b/vp10/encoder/rdopt.c @@ -49,62 +49,59 @@ #if CONFIG_DUAL_FILTER #if CONFIG_EXT_INTERP static const int filter_sets[25][2] = { - {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, - {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, - {2, 0}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, - {3, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, - {4, 0}, {4, 1}, {4, 2}, {4, 3}, {4, 4}, + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 1, 0 }, { 1, 1 }, + { 1, 2 }, { 1, 3 }, { 1, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, + { 2, 4 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, { 4, 0 }, + { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, }; #else static const int filter_sets[9][2] = { - {0, 0}, {0, 1}, {0, 2}, - {1, 0}, {1, 1}, {1, 2}, - {2, 0}, {2, 1}, {2, 2}, + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 1, 0 }, { 1, 1 }, + { 1, 2 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, }; #endif #endif #if CONFIG_EXT_REFS -#define LAST_FRAME_MODE_MASK ((1 << INTRA_FRAME) | (1 << LAST2_FRAME) | \ - (1 << LAST3_FRAME) | (1 << GOLDEN_FRAME) | \ - (1 << BWDREF_FRAME) | (1 << ALTREF_FRAME)) -#define LAST2_FRAME_MODE_MASK ((1 << INTRA_FRAME) | (1 << LAST_FRAME) | \ - (1 << LAST3_FRAME) | (1 << GOLDEN_FRAME) | \ - (1 << BWDREF_FRAME) | (1 << ALTREF_FRAME)) -#define LAST3_FRAME_MODE_MASK ((1 << INTRA_FRAME) | (1 << LAST_FRAME) | \ - (1 << LAST2_FRAME) | (1 << GOLDEN_FRAME) | \ - (1 << BWDREF_FRAME) | (1 << ALTREF_FRAME)) -#define GOLDEN_FRAME_MODE_MASK ((1 << INTRA_FRAME) | (1 << LAST_FRAME) | \ - (1 << LAST2_FRAME) | (1 << LAST3_FRAME) | \ - (1 << BWDREF_FRAME) | (1 << ALTREF_FRAME)) -#define BWDREF_FRAME_MODE_MASK ((1 << INTRA_FRAME) | (1 << LAST_FRAME) | \ - (1 << LAST2_FRAME) | (1 << LAST3_FRAME) | \ - (1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME)) -#define ALTREF_FRAME_MODE_MASK ((1 << INTRA_FRAME) | (1 << LAST_FRAME) | \ - (1 << LAST2_FRAME) | (1 << LAST3_FRAME) | \ - (1 << GOLDEN_FRAME) | (1 << BWDREF_FRAME)) +#define LAST_FRAME_MODE_MASK \ + ((1 << INTRA_FRAME) | (1 << LAST2_FRAME) | (1 << LAST3_FRAME) | \ + (1 << GOLDEN_FRAME) | (1 << BWDREF_FRAME) | (1 << ALTREF_FRAME)) +#define LAST2_FRAME_MODE_MASK \ + ((1 << INTRA_FRAME) | (1 << LAST_FRAME) | (1 << LAST3_FRAME) | \ + (1 << GOLDEN_FRAME) | (1 << BWDREF_FRAME) | (1 << ALTREF_FRAME)) +#define LAST3_FRAME_MODE_MASK \ + ((1 << INTRA_FRAME) | (1 << LAST_FRAME) | (1 << LAST2_FRAME) | \ + (1 << GOLDEN_FRAME) | (1 << BWDREF_FRAME) | (1 << ALTREF_FRAME)) +#define GOLDEN_FRAME_MODE_MASK \ + ((1 << INTRA_FRAME) | (1 << LAST_FRAME) | (1 << LAST2_FRAME) | \ + (1 << LAST3_FRAME) | (1 << BWDREF_FRAME) | (1 << ALTREF_FRAME)) +#define BWDREF_FRAME_MODE_MASK \ + ((1 << INTRA_FRAME) | (1 << LAST_FRAME) | (1 << LAST2_FRAME) | \ + (1 << LAST3_FRAME) | (1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME)) +#define ALTREF_FRAME_MODE_MASK \ + ((1 << INTRA_FRAME) | (1 << LAST_FRAME) | (1 << LAST2_FRAME) | \ + (1 << LAST3_FRAME) | (1 << GOLDEN_FRAME) | (1 << BWDREF_FRAME)) #else -#define LAST_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \ - (1 << INTRA_FRAME)) -#define GOLDEN_FRAME_MODE_MASK ((1 << LAST_FRAME) | (1 << ALTREF_FRAME) | \ - (1 << INTRA_FRAME)) -#define ALTREF_FRAME_MODE_MASK ((1 << LAST_FRAME) | (1 << GOLDEN_FRAME) | \ - (1 << INTRA_FRAME)) +#define LAST_FRAME_MODE_MASK \ + ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | (1 << INTRA_FRAME)) +#define GOLDEN_FRAME_MODE_MASK \ + ((1 << LAST_FRAME) | (1 << ALTREF_FRAME) | (1 << INTRA_FRAME)) +#define ALTREF_FRAME_MODE_MASK \ + ((1 << LAST_FRAME) | (1 << GOLDEN_FRAME) | (1 << INTRA_FRAME)) #endif // CONFIG_EXT_REFS #if CONFIG_EXT_REFS -#define SECOND_REF_FRAME_MASK ((1 << ALTREF_FRAME) | (1 << BWDREF_FRAME) | \ - 0x01) +#define SECOND_REF_FRAME_MASK ((1 << ALTREF_FRAME) | (1 << BWDREF_FRAME) | 0x01) #else -#define SECOND_REF_FRAME_MASK ((1 << ALTREF_FRAME) | 0x01) +#define SECOND_REF_FRAME_MASK ((1 << ALTREF_FRAME) | 0x01) #endif // CONFIG_EXT_REFS -#define MIN_EARLY_TERM_INDEX 3 -#define NEW_MV_DISCOUNT_FACTOR 8 +#define MIN_EARLY_TERM_INDEX 3 +#define NEW_MV_DISCOUNT_FACTOR 8 #if CONFIG_EXT_INTRA #define ANGLE_FAST_SEARCH 1 @@ -112,17 +109,15 @@ static const int filter_sets[9][2] = { #define FILTER_FAST_SEARCH 1 #endif // CONFIG_EXT_INTRA -const double ADST_FLIP_SVM[8] = {-6.6623, -2.8062, -3.2531, 3.1671, // vert - -7.7051, -3.2234, -3.6193, 3.4533}; // horz +const double ADST_FLIP_SVM[8] = { -6.6623, -2.8062, -3.2531, 3.1671, // vert + -7.7051, -3.2234, -3.6193, 3.4533 }; // horz typedef struct { PREDICTION_MODE mode; MV_REFERENCE_FRAME ref_frame[2]; } MODE_DEFINITION; -typedef struct { - MV_REFERENCE_FRAME ref_frame[2]; -} REF_DEFINITION; +typedef struct { MV_REFERENCE_FRAME ref_frame[2]; } REF_DEFINITION; struct rdcost_block_args { const VP10_COMP *cpi; @@ -142,291 +137,285 @@ struct rdcost_block_args { #define LAST_NEW_MV_INDEX 6 static const MODE_DEFINITION vp10_mode_order[MAX_MODES] = { - {NEARESTMV, {LAST_FRAME, NONE}}, + { NEARESTMV, { LAST_FRAME, NONE } }, #if CONFIG_EXT_REFS - {NEARESTMV, {LAST2_FRAME, NONE}}, - {NEARESTMV, {LAST3_FRAME, NONE}}, - {NEARESTMV, {BWDREF_FRAME, NONE}}, + { NEARESTMV, { LAST2_FRAME, NONE } }, + { NEARESTMV, { LAST3_FRAME, NONE } }, + { NEARESTMV, { BWDREF_FRAME, NONE } }, #endif // CONFIG_EXT_REFS - {NEARESTMV, {ALTREF_FRAME, NONE}}, - {NEARESTMV, {GOLDEN_FRAME, NONE}}, + { NEARESTMV, { ALTREF_FRAME, NONE } }, + { NEARESTMV, { GOLDEN_FRAME, NONE } }, - {DC_PRED, {INTRA_FRAME, NONE}}, + { DC_PRED, { INTRA_FRAME, NONE } }, - {NEWMV, {LAST_FRAME, NONE}}, + { NEWMV, { LAST_FRAME, NONE } }, #if CONFIG_EXT_REFS - {NEWMV, {LAST2_FRAME, NONE}}, - {NEWMV, {LAST3_FRAME, NONE}}, - {NEWMV, {BWDREF_FRAME, NONE}}, + { NEWMV, { LAST2_FRAME, NONE } }, + { NEWMV, { LAST3_FRAME, NONE } }, + { NEWMV, { BWDREF_FRAME, NONE } }, #endif // CONFIG_EXT_REFS - {NEWMV, {ALTREF_FRAME, NONE}}, - {NEWMV, {GOLDEN_FRAME, NONE}}, + { NEWMV, { ALTREF_FRAME, NONE } }, + { NEWMV, { GOLDEN_FRAME, NONE } }, - {NEARMV, {LAST_FRAME, NONE}}, + { NEARMV, { LAST_FRAME, NONE } }, #if CONFIG_EXT_REFS - {NEARMV, {LAST2_FRAME, NONE}}, - {NEARMV, {LAST3_FRAME, NONE}}, - {NEARMV, {BWDREF_FRAME, NONE}}, + { NEARMV, { LAST2_FRAME, NONE } }, + { NEARMV, { LAST3_FRAME, NONE } }, + { NEARMV, { BWDREF_FRAME, NONE } }, #endif // CONFIG_EXT_REFS - {NEARMV, {ALTREF_FRAME, NONE}}, - {NEARMV, {GOLDEN_FRAME, NONE}}, + { NEARMV, { ALTREF_FRAME, NONE } }, + { NEARMV, { GOLDEN_FRAME, NONE } }, #if CONFIG_EXT_INTER - {NEWFROMNEARMV, {LAST_FRAME, NONE}}, + { NEWFROMNEARMV, { LAST_FRAME, NONE } }, #if CONFIG_EXT_REFS - {NEWFROMNEARMV, {LAST2_FRAME, NONE}}, - {NEWFROMNEARMV, {LAST3_FRAME, NONE}}, - {NEWFROMNEARMV, {BWDREF_FRAME, NONE}}, + { NEWFROMNEARMV, { LAST2_FRAME, NONE } }, + { NEWFROMNEARMV, { LAST3_FRAME, NONE } }, + { NEWFROMNEARMV, { BWDREF_FRAME, NONE } }, #endif // CONFIG_EXT_REFS - {NEWFROMNEARMV, {ALTREF_FRAME, NONE}}, - {NEWFROMNEARMV, {GOLDEN_FRAME, NONE}}, + { NEWFROMNEARMV, { ALTREF_FRAME, NONE } }, + { NEWFROMNEARMV, { GOLDEN_FRAME, NONE } }, #endif // CONFIG_EXT_INTER - {ZEROMV, {LAST_FRAME, NONE}}, + { ZEROMV, { LAST_FRAME, NONE } }, #if CONFIG_EXT_REFS - {ZEROMV, {LAST2_FRAME, NONE}}, - {ZEROMV, {LAST3_FRAME, NONE}}, - {ZEROMV, {BWDREF_FRAME, NONE}}, + { ZEROMV, { LAST2_FRAME, NONE } }, + { ZEROMV, { LAST3_FRAME, NONE } }, + { ZEROMV, { BWDREF_FRAME, NONE } }, #endif // CONFIG_EXT_REFS - {ZEROMV, {GOLDEN_FRAME, NONE}}, - {ZEROMV, {ALTREF_FRAME, NONE}}, + { ZEROMV, { GOLDEN_FRAME, NONE } }, + { ZEROMV, { ALTREF_FRAME, NONE } }, - // TODO(zoeliu): May need to reconsider the order on the modes to check +// TODO(zoeliu): May need to reconsider the order on the modes to check #if CONFIG_EXT_INTER - {NEAREST_NEARESTMV, {LAST_FRAME, ALTREF_FRAME}}, + { NEAREST_NEARESTMV, { LAST_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {NEAREST_NEARESTMV, {LAST2_FRAME, ALTREF_FRAME}}, - {NEAREST_NEARESTMV, {LAST3_FRAME, ALTREF_FRAME}}, + { NEAREST_NEARESTMV, { LAST2_FRAME, ALTREF_FRAME } }, + { NEAREST_NEARESTMV, { LAST3_FRAME, ALTREF_FRAME } }, #endif // CONFIG_EXT_REFS - {NEAREST_NEARESTMV, {GOLDEN_FRAME, ALTREF_FRAME}}, + { NEAREST_NEARESTMV, { GOLDEN_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {NEAREST_NEARESTMV, {LAST_FRAME, BWDREF_FRAME}}, - {NEAREST_NEARESTMV, {LAST2_FRAME, BWDREF_FRAME}}, - {NEAREST_NEARESTMV, {LAST3_FRAME, BWDREF_FRAME}}, - {NEAREST_NEARESTMV, {GOLDEN_FRAME, BWDREF_FRAME}}, + { NEAREST_NEARESTMV, { LAST_FRAME, BWDREF_FRAME } }, + { NEAREST_NEARESTMV, { LAST2_FRAME, BWDREF_FRAME } }, + { NEAREST_NEARESTMV, { LAST3_FRAME, BWDREF_FRAME } }, + { NEAREST_NEARESTMV, { GOLDEN_FRAME, BWDREF_FRAME } }, #endif // CONFIG_EXT_REFS #else // CONFIG_EXT_INTER - {NEARESTMV, {LAST_FRAME, ALTREF_FRAME}}, + { NEARESTMV, { LAST_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {NEARESTMV, {LAST2_FRAME, ALTREF_FRAME}}, - {NEARESTMV, {LAST3_FRAME, ALTREF_FRAME}}, + { NEARESTMV, { LAST2_FRAME, ALTREF_FRAME } }, + { NEARESTMV, { LAST3_FRAME, ALTREF_FRAME } }, #endif // CONFIG_EXT_REFS - {NEARESTMV, {GOLDEN_FRAME, ALTREF_FRAME}}, + { NEARESTMV, { GOLDEN_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {NEARESTMV, {LAST_FRAME, BWDREF_FRAME}}, - {NEARESTMV, {LAST2_FRAME, BWDREF_FRAME}}, - {NEARESTMV, {LAST3_FRAME, BWDREF_FRAME}}, - {NEARESTMV, {GOLDEN_FRAME, BWDREF_FRAME}}, + { NEARESTMV, { LAST_FRAME, BWDREF_FRAME } }, + { NEARESTMV, { LAST2_FRAME, BWDREF_FRAME } }, + { NEARESTMV, { LAST3_FRAME, BWDREF_FRAME } }, + { NEARESTMV, { GOLDEN_FRAME, BWDREF_FRAME } }, #endif // CONFIG_EXT_REFS #endif // CONFIG_EXT_INTER - {TM_PRED, {INTRA_FRAME, NONE}}, + { TM_PRED, { INTRA_FRAME, NONE } }, #if CONFIG_EXT_INTER - {NEAR_NEARESTMV, {LAST_FRAME, ALTREF_FRAME}}, - {NEAREST_NEARMV, {LAST_FRAME, ALTREF_FRAME}}, - {NEAR_NEARMV, {LAST_FRAME, ALTREF_FRAME}}, - {NEW_NEARESTMV, {LAST_FRAME, ALTREF_FRAME}}, - {NEAREST_NEWMV, {LAST_FRAME, ALTREF_FRAME}}, - {NEW_NEARMV, {LAST_FRAME, ALTREF_FRAME}}, - {NEAR_NEWMV, {LAST_FRAME, ALTREF_FRAME}}, - {NEW_NEWMV, {LAST_FRAME, ALTREF_FRAME}}, - {ZERO_ZEROMV, {LAST_FRAME, ALTREF_FRAME}}, + { NEAR_NEARESTMV, { LAST_FRAME, ALTREF_FRAME } }, + { NEAREST_NEARMV, { LAST_FRAME, ALTREF_FRAME } }, + { NEAR_NEARMV, { LAST_FRAME, ALTREF_FRAME } }, + { NEW_NEARESTMV, { LAST_FRAME, ALTREF_FRAME } }, + { NEAREST_NEWMV, { LAST_FRAME, ALTREF_FRAME } }, + { NEW_NEARMV, { LAST_FRAME, ALTREF_FRAME } }, + { NEAR_NEWMV, { LAST_FRAME, ALTREF_FRAME } }, + { NEW_NEWMV, { LAST_FRAME, ALTREF_FRAME } }, + { ZERO_ZEROMV, { LAST_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {NEAR_NEARESTMV, {LAST2_FRAME, ALTREF_FRAME}}, - {NEAREST_NEARMV, {LAST2_FRAME, ALTREF_FRAME}}, - {NEAR_NEARMV, {LAST2_FRAME, ALTREF_FRAME}}, - {NEW_NEARESTMV, {LAST2_FRAME, ALTREF_FRAME}}, - {NEAREST_NEWMV, {LAST2_FRAME, ALTREF_FRAME}}, - {NEW_NEARMV, {LAST2_FRAME, ALTREF_FRAME}}, - {NEAR_NEWMV, {LAST2_FRAME, ALTREF_FRAME}}, - {NEW_NEWMV, {LAST2_FRAME, ALTREF_FRAME}}, - {ZERO_ZEROMV, {LAST2_FRAME, ALTREF_FRAME}}, + { NEAR_NEARESTMV, { LAST2_FRAME, ALTREF_FRAME } }, + { NEAREST_NEARMV, { LAST2_FRAME, ALTREF_FRAME } }, + { NEAR_NEARMV, { LAST2_FRAME, ALTREF_FRAME } }, + { NEW_NEARESTMV, { LAST2_FRAME, ALTREF_FRAME } }, + { NEAREST_NEWMV, { LAST2_FRAME, ALTREF_FRAME } }, + { NEW_NEARMV, { LAST2_FRAME, ALTREF_FRAME } }, + { NEAR_NEWMV, { LAST2_FRAME, ALTREF_FRAME } }, + { NEW_NEWMV, { LAST2_FRAME, ALTREF_FRAME } }, + { ZERO_ZEROMV, { LAST2_FRAME, ALTREF_FRAME } }, - {NEAR_NEARESTMV, {LAST3_FRAME, ALTREF_FRAME}}, - {NEAREST_NEARMV, {LAST3_FRAME, ALTREF_FRAME}}, - {NEAR_NEARMV, {LAST3_FRAME, ALTREF_FRAME}}, - {NEW_NEARESTMV, {LAST3_FRAME, ALTREF_FRAME}}, - {NEAREST_NEWMV, {LAST3_FRAME, ALTREF_FRAME}}, - {NEW_NEARMV, {LAST3_FRAME, ALTREF_FRAME}}, - {NEAR_NEWMV, {LAST3_FRAME, ALTREF_FRAME}}, - {NEW_NEWMV, {LAST3_FRAME, ALTREF_FRAME}}, - {ZERO_ZEROMV, {LAST3_FRAME, ALTREF_FRAME}}, + { NEAR_NEARESTMV, { LAST3_FRAME, ALTREF_FRAME } }, + { NEAREST_NEARMV, { LAST3_FRAME, ALTREF_FRAME } }, + { NEAR_NEARMV, { LAST3_FRAME, ALTREF_FRAME } }, + { NEW_NEARESTMV, { LAST3_FRAME, ALTREF_FRAME } }, + { NEAREST_NEWMV, { LAST3_FRAME, ALTREF_FRAME } }, + { NEW_NEARMV, { LAST3_FRAME, ALTREF_FRAME } }, + { NEAR_NEWMV, { LAST3_FRAME, ALTREF_FRAME } }, + { NEW_NEWMV, { LAST3_FRAME, ALTREF_FRAME } }, + { ZERO_ZEROMV, { LAST3_FRAME, ALTREF_FRAME } }, #endif // CONFIG_EXT_REFS - {NEAR_NEARESTMV, {GOLDEN_FRAME, ALTREF_FRAME}}, - {NEAREST_NEARMV, {GOLDEN_FRAME, ALTREF_FRAME}}, - {NEAR_NEARMV, {GOLDEN_FRAME, ALTREF_FRAME}}, - {NEW_NEARESTMV, {GOLDEN_FRAME, ALTREF_FRAME}}, - {NEAREST_NEWMV, {GOLDEN_FRAME, ALTREF_FRAME}}, - {NEW_NEARMV, {GOLDEN_FRAME, ALTREF_FRAME}}, - {NEAR_NEWMV, {GOLDEN_FRAME, ALTREF_FRAME}}, - {NEW_NEWMV, {GOLDEN_FRAME, ALTREF_FRAME}}, - {ZERO_ZEROMV, {GOLDEN_FRAME, ALTREF_FRAME}}, + { NEAR_NEARESTMV, { GOLDEN_FRAME, ALTREF_FRAME } }, + { NEAREST_NEARMV, { GOLDEN_FRAME, ALTREF_FRAME } }, + { NEAR_NEARMV, { GOLDEN_FRAME, ALTREF_FRAME } }, + { NEW_NEARESTMV, { GOLDEN_FRAME, ALTREF_FRAME } }, + { NEAREST_NEWMV, { GOLDEN_FRAME, ALTREF_FRAME } }, + { NEW_NEARMV, { GOLDEN_FRAME, ALTREF_FRAME } }, + { NEAR_NEWMV, { GOLDEN_FRAME, ALTREF_FRAME } }, + { NEW_NEWMV, { GOLDEN_FRAME, ALTREF_FRAME } }, + { ZERO_ZEROMV, { GOLDEN_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {NEAR_NEARESTMV, {LAST_FRAME, BWDREF_FRAME}}, - {NEAREST_NEARMV, {LAST_FRAME, BWDREF_FRAME}}, - {NEAR_NEARMV, {LAST_FRAME, BWDREF_FRAME}}, - {NEW_NEARESTMV, {LAST_FRAME, BWDREF_FRAME}}, - {NEAREST_NEWMV, {LAST_FRAME, BWDREF_FRAME}}, - {NEW_NEARMV, {LAST_FRAME, BWDREF_FRAME}}, - {NEAR_NEWMV, {LAST_FRAME, BWDREF_FRAME}}, - {NEW_NEWMV, {LAST_FRAME, BWDREF_FRAME}}, - {ZERO_ZEROMV, {LAST_FRAME, BWDREF_FRAME}}, + { NEAR_NEARESTMV, { LAST_FRAME, BWDREF_FRAME } }, + { NEAREST_NEARMV, { LAST_FRAME, BWDREF_FRAME } }, + { NEAR_NEARMV, { LAST_FRAME, BWDREF_FRAME } }, + { NEW_NEARESTMV, { LAST_FRAME, BWDREF_FRAME } }, + { NEAREST_NEWMV, { LAST_FRAME, BWDREF_FRAME } }, + { NEW_NEARMV, { LAST_FRAME, BWDREF_FRAME } }, + { NEAR_NEWMV, { LAST_FRAME, BWDREF_FRAME } }, + { NEW_NEWMV, { LAST_FRAME, BWDREF_FRAME } }, + { ZERO_ZEROMV, { LAST_FRAME, BWDREF_FRAME } }, - {NEAR_NEARESTMV, {LAST2_FRAME, BWDREF_FRAME}}, - {NEAREST_NEARMV, {LAST2_FRAME, BWDREF_FRAME}}, - {NEAR_NEARMV, {LAST2_FRAME, BWDREF_FRAME}}, - {NEW_NEARESTMV, {LAST2_FRAME, BWDREF_FRAME}}, - {NEAREST_NEWMV, {LAST2_FRAME, BWDREF_FRAME}}, - {NEW_NEARMV, {LAST2_FRAME, BWDREF_FRAME}}, - {NEAR_NEWMV, {LAST2_FRAME, BWDREF_FRAME}}, - {NEW_NEWMV, {LAST2_FRAME, BWDREF_FRAME}}, - {ZERO_ZEROMV, {LAST2_FRAME, BWDREF_FRAME}}, + { NEAR_NEARESTMV, { LAST2_FRAME, BWDREF_FRAME } }, + { NEAREST_NEARMV, { LAST2_FRAME, BWDREF_FRAME } }, + { NEAR_NEARMV, { LAST2_FRAME, BWDREF_FRAME } }, + { NEW_NEARESTMV, { LAST2_FRAME, BWDREF_FRAME } }, + { NEAREST_NEWMV, { LAST2_FRAME, BWDREF_FRAME } }, + { NEW_NEARMV, { LAST2_FRAME, BWDREF_FRAME } }, + { NEAR_NEWMV, { LAST2_FRAME, BWDREF_FRAME } }, + { NEW_NEWMV, { LAST2_FRAME, BWDREF_FRAME } }, + { ZERO_ZEROMV, { LAST2_FRAME, BWDREF_FRAME } }, - {NEAR_NEARESTMV, {LAST3_FRAME, BWDREF_FRAME}}, - {NEAREST_NEARMV, {LAST3_FRAME, BWDREF_FRAME}}, - {NEAR_NEARMV, {LAST3_FRAME, BWDREF_FRAME}}, - {NEW_NEARESTMV, {LAST3_FRAME, BWDREF_FRAME}}, - {NEAREST_NEWMV, {LAST3_FRAME, BWDREF_FRAME}}, - {NEW_NEARMV, {LAST3_FRAME, BWDREF_FRAME}}, - {NEAR_NEWMV, {LAST3_FRAME, BWDREF_FRAME}}, - {NEW_NEWMV, {LAST3_FRAME, BWDREF_FRAME}}, - {ZERO_ZEROMV, {LAST3_FRAME, BWDREF_FRAME}}, + { NEAR_NEARESTMV, { LAST3_FRAME, BWDREF_FRAME } }, + { NEAREST_NEARMV, { LAST3_FRAME, BWDREF_FRAME } }, + { NEAR_NEARMV, { LAST3_FRAME, BWDREF_FRAME } }, + { NEW_NEARESTMV, { LAST3_FRAME, BWDREF_FRAME } }, + { NEAREST_NEWMV, { LAST3_FRAME, BWDREF_FRAME } }, + { NEW_NEARMV, { LAST3_FRAME, BWDREF_FRAME } }, + { NEAR_NEWMV, { LAST3_FRAME, BWDREF_FRAME } }, + { NEW_NEWMV, { LAST3_FRAME, BWDREF_FRAME } }, + { ZERO_ZEROMV, { LAST3_FRAME, BWDREF_FRAME } }, - {NEAR_NEARESTMV, {GOLDEN_FRAME, BWDREF_FRAME}}, - {NEAREST_NEARMV, {GOLDEN_FRAME, BWDREF_FRAME}}, - {NEAR_NEARMV, {GOLDEN_FRAME, BWDREF_FRAME}}, - {NEW_NEARESTMV, {GOLDEN_FRAME, BWDREF_FRAME}}, - {NEAREST_NEWMV, {GOLDEN_FRAME, BWDREF_FRAME}}, - {NEW_NEARMV, {GOLDEN_FRAME, BWDREF_FRAME}}, - {NEAR_NEWMV, {GOLDEN_FRAME, BWDREF_FRAME}}, - {NEW_NEWMV, {GOLDEN_FRAME, BWDREF_FRAME}}, - {ZERO_ZEROMV, {GOLDEN_FRAME, BWDREF_FRAME}}, + { NEAR_NEARESTMV, { GOLDEN_FRAME, BWDREF_FRAME } }, + { NEAREST_NEARMV, { GOLDEN_FRAME, BWDREF_FRAME } }, + { NEAR_NEARMV, { GOLDEN_FRAME, BWDREF_FRAME } }, + { NEW_NEARESTMV, { GOLDEN_FRAME, BWDREF_FRAME } }, + { NEAREST_NEWMV, { GOLDEN_FRAME, BWDREF_FRAME } }, + { NEW_NEARMV, { GOLDEN_FRAME, BWDREF_FRAME } }, + { NEAR_NEWMV, { GOLDEN_FRAME, BWDREF_FRAME } }, + { NEW_NEWMV, { GOLDEN_FRAME, BWDREF_FRAME } }, + { ZERO_ZEROMV, { GOLDEN_FRAME, BWDREF_FRAME } }, #endif // CONFIG_EXT_REFS #else // CONFIG_EXT_INTER - {NEARMV, {LAST_FRAME, ALTREF_FRAME}}, - {NEWMV, {LAST_FRAME, ALTREF_FRAME}}, + { NEARMV, { LAST_FRAME, ALTREF_FRAME } }, + { NEWMV, { LAST_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {NEARMV, {LAST2_FRAME, ALTREF_FRAME}}, - {NEWMV, {LAST2_FRAME, ALTREF_FRAME}}, - {NEARMV, {LAST3_FRAME, ALTREF_FRAME}}, - {NEWMV, {LAST3_FRAME, ALTREF_FRAME}}, + { NEARMV, { LAST2_FRAME, ALTREF_FRAME } }, + { NEWMV, { LAST2_FRAME, ALTREF_FRAME } }, + { NEARMV, { LAST3_FRAME, ALTREF_FRAME } }, + { NEWMV, { LAST3_FRAME, ALTREF_FRAME } }, #endif // CONFIG_EXT_REFS - {NEARMV, {GOLDEN_FRAME, ALTREF_FRAME}}, - {NEWMV, {GOLDEN_FRAME, ALTREF_FRAME}}, + { NEARMV, { GOLDEN_FRAME, ALTREF_FRAME } }, + { NEWMV, { GOLDEN_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {NEARMV, {LAST_FRAME, BWDREF_FRAME}}, - {NEWMV, {LAST_FRAME, BWDREF_FRAME}}, - {NEARMV, {LAST2_FRAME, BWDREF_FRAME}}, - {NEWMV, {LAST2_FRAME, BWDREF_FRAME}}, - {NEARMV, {LAST3_FRAME, BWDREF_FRAME}}, - {NEWMV, {LAST3_FRAME, BWDREF_FRAME}}, - {NEARMV, {GOLDEN_FRAME, BWDREF_FRAME}}, - {NEWMV, {GOLDEN_FRAME, BWDREF_FRAME}}, + { NEARMV, { LAST_FRAME, BWDREF_FRAME } }, + { NEWMV, { LAST_FRAME, BWDREF_FRAME } }, + { NEARMV, { LAST2_FRAME, BWDREF_FRAME } }, + { NEWMV, { LAST2_FRAME, BWDREF_FRAME } }, + { NEARMV, { LAST3_FRAME, BWDREF_FRAME } }, + { NEWMV, { LAST3_FRAME, BWDREF_FRAME } }, + { NEARMV, { GOLDEN_FRAME, BWDREF_FRAME } }, + { NEWMV, { GOLDEN_FRAME, BWDREF_FRAME } }, #endif // CONFIG_EXT_REFS - {ZEROMV, {LAST_FRAME, ALTREF_FRAME}}, + { ZEROMV, { LAST_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {ZEROMV, {LAST2_FRAME, ALTREF_FRAME}}, - {ZEROMV, {LAST3_FRAME, ALTREF_FRAME}}, + { ZEROMV, { LAST2_FRAME, ALTREF_FRAME } }, + { ZEROMV, { LAST3_FRAME, ALTREF_FRAME } }, #endif // CONFIG_EXT_REFS - {ZEROMV, {GOLDEN_FRAME, ALTREF_FRAME}}, + { ZEROMV, { GOLDEN_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {ZEROMV, {LAST_FRAME, BWDREF_FRAME}}, - {ZEROMV, {LAST2_FRAME, BWDREF_FRAME}}, - {ZEROMV, {LAST3_FRAME, BWDREF_FRAME}}, - {ZEROMV, {GOLDEN_FRAME, BWDREF_FRAME}}, + { ZEROMV, { LAST_FRAME, BWDREF_FRAME } }, + { ZEROMV, { LAST2_FRAME, BWDREF_FRAME } }, + { ZEROMV, { LAST3_FRAME, BWDREF_FRAME } }, + { ZEROMV, { GOLDEN_FRAME, BWDREF_FRAME } }, #endif // CONFIG_EXT_REFS #endif // CONFIG_EXT_INTER - {H_PRED, {INTRA_FRAME, NONE}}, - {V_PRED, {INTRA_FRAME, NONE}}, - {D135_PRED, {INTRA_FRAME, NONE}}, - {D207_PRED, {INTRA_FRAME, NONE}}, - {D153_PRED, {INTRA_FRAME, NONE}}, - {D63_PRED, {INTRA_FRAME, NONE}}, - {D117_PRED, {INTRA_FRAME, NONE}}, - {D45_PRED, {INTRA_FRAME, NONE}}, + { H_PRED, { INTRA_FRAME, NONE } }, + { V_PRED, { INTRA_FRAME, NONE } }, + { D135_PRED, { INTRA_FRAME, NONE } }, + { D207_PRED, { INTRA_FRAME, NONE } }, + { D153_PRED, { INTRA_FRAME, NONE } }, + { D63_PRED, { INTRA_FRAME, NONE } }, + { D117_PRED, { INTRA_FRAME, NONE } }, + { D45_PRED, { INTRA_FRAME, NONE } }, #if CONFIG_EXT_INTER - {ZEROMV, {LAST_FRAME, INTRA_FRAME}}, - {NEARESTMV, {LAST_FRAME, INTRA_FRAME}}, - {NEARMV, {LAST_FRAME, INTRA_FRAME}}, - {NEWMV, {LAST_FRAME, INTRA_FRAME}}, + { ZEROMV, { LAST_FRAME, INTRA_FRAME } }, + { NEARESTMV, { LAST_FRAME, INTRA_FRAME } }, + { NEARMV, { LAST_FRAME, INTRA_FRAME } }, + { NEWMV, { LAST_FRAME, INTRA_FRAME } }, #if CONFIG_EXT_REFS - {ZEROMV, {LAST2_FRAME, INTRA_FRAME}}, - {NEARESTMV, {LAST2_FRAME, INTRA_FRAME}}, - {NEARMV, {LAST2_FRAME, INTRA_FRAME}}, - {NEWMV, {LAST2_FRAME, INTRA_FRAME}}, + { ZEROMV, { LAST2_FRAME, INTRA_FRAME } }, + { NEARESTMV, { LAST2_FRAME, INTRA_FRAME } }, + { NEARMV, { LAST2_FRAME, INTRA_FRAME } }, + { NEWMV, { LAST2_FRAME, INTRA_FRAME } }, - {ZEROMV, {LAST3_FRAME, INTRA_FRAME}}, - {NEARESTMV, {LAST3_FRAME, INTRA_FRAME}}, - {NEARMV, {LAST3_FRAME, INTRA_FRAME}}, - {NEWMV, {LAST3_FRAME, INTRA_FRAME}}, + { ZEROMV, { LAST3_FRAME, INTRA_FRAME } }, + { NEARESTMV, { LAST3_FRAME, INTRA_FRAME } }, + { NEARMV, { LAST3_FRAME, INTRA_FRAME } }, + { NEWMV, { LAST3_FRAME, INTRA_FRAME } }, #endif // CONFIG_EXT_REFS - {ZEROMV, {GOLDEN_FRAME, INTRA_FRAME}}, - {NEARESTMV, {GOLDEN_FRAME, INTRA_FRAME}}, - {NEARMV, {GOLDEN_FRAME, INTRA_FRAME}}, - {NEWMV, {GOLDEN_FRAME, INTRA_FRAME}}, + { ZEROMV, { GOLDEN_FRAME, INTRA_FRAME } }, + { NEARESTMV, { GOLDEN_FRAME, INTRA_FRAME } }, + { NEARMV, { GOLDEN_FRAME, INTRA_FRAME } }, + { NEWMV, { GOLDEN_FRAME, INTRA_FRAME } }, #if CONFIG_EXT_REFS - {ZEROMV, {BWDREF_FRAME, INTRA_FRAME}}, - {NEARESTMV, {BWDREF_FRAME, INTRA_FRAME}}, - {NEARMV, {BWDREF_FRAME, INTRA_FRAME}}, - {NEWMV, {BWDREF_FRAME, INTRA_FRAME}}, + { ZEROMV, { BWDREF_FRAME, INTRA_FRAME } }, + { NEARESTMV, { BWDREF_FRAME, INTRA_FRAME } }, + { NEARMV, { BWDREF_FRAME, INTRA_FRAME } }, + { NEWMV, { BWDREF_FRAME, INTRA_FRAME } }, #endif // CONFIG_EXT_REFS - {ZEROMV, {ALTREF_FRAME, INTRA_FRAME}}, - {NEARESTMV, {ALTREF_FRAME, INTRA_FRAME}}, - {NEARMV, {ALTREF_FRAME, INTRA_FRAME}}, - {NEWMV, {ALTREF_FRAME, INTRA_FRAME}}, + { ZEROMV, { ALTREF_FRAME, INTRA_FRAME } }, + { NEARESTMV, { ALTREF_FRAME, INTRA_FRAME } }, + { NEARMV, { ALTREF_FRAME, INTRA_FRAME } }, + { NEWMV, { ALTREF_FRAME, INTRA_FRAME } }, #endif // CONFIG_EXT_INTER }; static const REF_DEFINITION vp10_ref_order[MAX_REFS] = { - {{LAST_FRAME, NONE}}, + { { LAST_FRAME, NONE } }, #if CONFIG_EXT_REFS - {{LAST2_FRAME, NONE}}, - {{LAST3_FRAME, NONE}}, - {{BWDREF_FRAME, NONE}}, + { { LAST2_FRAME, NONE } }, { { LAST3_FRAME, NONE } }, + { { BWDREF_FRAME, NONE } }, #endif // CONFIG_EXT_REFS - {{GOLDEN_FRAME, NONE}}, - {{ALTREF_FRAME, NONE}}, + { { GOLDEN_FRAME, NONE } }, { { ALTREF_FRAME, NONE } }, - {{LAST_FRAME, ALTREF_FRAME}}, + { { LAST_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {{LAST2_FRAME, ALTREF_FRAME}}, - {{LAST3_FRAME, ALTREF_FRAME}}, + { { LAST2_FRAME, ALTREF_FRAME } }, { { LAST3_FRAME, ALTREF_FRAME } }, #endif // CONFIG_EXT_REFS - {{GOLDEN_FRAME, ALTREF_FRAME}}, + { { GOLDEN_FRAME, ALTREF_FRAME } }, #if CONFIG_EXT_REFS - {{LAST_FRAME, BWDREF_FRAME}}, - {{LAST2_FRAME, BWDREF_FRAME}}, - {{LAST3_FRAME, BWDREF_FRAME}}, - {{GOLDEN_FRAME, BWDREF_FRAME}}, + { { LAST_FRAME, BWDREF_FRAME } }, { { LAST2_FRAME, BWDREF_FRAME } }, + { { LAST3_FRAME, BWDREF_FRAME } }, { { GOLDEN_FRAME, BWDREF_FRAME } }, #endif // CONFIG_EXT_REFS - {{INTRA_FRAME, NONE}}, + { { INTRA_FRAME, NONE } }, }; static INLINE int write_uniform_cost(int n, int v) { int l = get_unsigned_bits(n), m = (1 << l) - n; - if (l == 0) - return 0; + if (l == 0) return 0; if (v < m) return (l - 1) * vp10_cost_bit(128, 0); else @@ -440,55 +429,28 @@ static INLINE int write_uniform_cost(int n, int v) { #define FAST_EXT_TX_EDST_MARGIN 0.3 static const TX_TYPE_1D vtx_tab[TX_TYPES] = { - DCT_1D, - ADST_1D, - DCT_1D, - ADST_1D, + DCT_1D, ADST_1D, DCT_1D, ADST_1D, #if CONFIG_EXT_TX - FLIPADST_1D, - DCT_1D, - FLIPADST_1D, - ADST_1D, - FLIPADST_1D, - IDTX_1D, - DCT_1D, - IDTX_1D, - ADST_1D, - IDTX_1D, - FLIPADST_1D, - IDTX_1D, + FLIPADST_1D, DCT_1D, FLIPADST_1D, ADST_1D, FLIPADST_1D, IDTX_1D, + DCT_1D, IDTX_1D, ADST_1D, IDTX_1D, FLIPADST_1D, IDTX_1D, #endif // CONFIG_EXT_TX }; static const TX_TYPE_1D htx_tab[TX_TYPES] = { - DCT_1D, - DCT_1D, - ADST_1D, - ADST_1D, + DCT_1D, DCT_1D, ADST_1D, ADST_1D, #if CONFIG_EXT_TX - DCT_1D, - FLIPADST_1D, - FLIPADST_1D, - FLIPADST_1D, - ADST_1D, - IDTX_1D, - IDTX_1D, - DCT_1D, - IDTX_1D, - ADST_1D, - IDTX_1D, - FLIPADST_1D, + DCT_1D, FLIPADST_1D, FLIPADST_1D, FLIPADST_1D, ADST_1D, IDTX_1D, + IDTX_1D, DCT_1D, IDTX_1D, ADST_1D, IDTX_1D, FLIPADST_1D, #endif // CONFIG_EXT_TX }; -static void get_energy_distribution_fine(const VP10_COMP *cpi, - BLOCK_SIZE bsize, +static void get_energy_distribution_fine(const VP10_COMP *cpi, BLOCK_SIZE bsize, uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, double *hordist, double *verdist) { int bw = 4 << (b_width_log2_lookup[bsize]); int bh = 4 << (b_height_log2_lookup[bsize]); - unsigned int esq[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + unsigned int esq[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; unsigned int var[16]; double total = 0; @@ -504,10 +466,9 @@ static void get_energy_distribution_fine(const VP10_COMP *cpi, for (i = 0; i < bh; ++i) for (j = 0; j < bw; ++j) { index = (j >> w_shift) + ((i >> h_shift) << 2); - esq[index] += (src16[j + i * src_stride] - - dst16[j + i * dst_stride]) * - (src16[j + i * src_stride] - - dst16[j + i * dst_stride]); + esq[index] += + (src16[j + i * src_stride] - dst16[j + i * dst_stride]) * + (src16[j + i * src_stride] - dst16[j + i * dst_stride]); } } else { #endif // CONFIG_VP9_HIGHBITDEPTH @@ -522,104 +483,103 @@ static void get_energy_distribution_fine(const VP10_COMP *cpi, } #endif // CONFIG_VP9_HIGHBITDEPTH } else { - var[0] = cpi->fn_ptr[f_index].vf(src, src_stride, - dst, dst_stride, &esq[0]); - var[1] = cpi->fn_ptr[f_index].vf(src + bw / 4, src_stride, - dst + bw / 4, dst_stride, &esq[1]); - var[2] = cpi->fn_ptr[f_index].vf(src + bw / 2, src_stride, - dst + bw / 2, dst_stride, &esq[2]); + var[0] = cpi->fn_ptr[f_index].vf(src, src_stride, dst, dst_stride, &esq[0]); + var[1] = cpi->fn_ptr[f_index].vf(src + bw / 4, src_stride, dst + bw / 4, + dst_stride, &esq[1]); + var[2] = cpi->fn_ptr[f_index].vf(src + bw / 2, src_stride, dst + bw / 2, + dst_stride, &esq[2]); var[3] = cpi->fn_ptr[f_index].vf(src + 3 * bw / 4, src_stride, dst + 3 * bw / 4, dst_stride, &esq[3]); src += bh / 4 * src_stride; dst += bh / 4 * dst_stride; - var[4] = cpi->fn_ptr[f_index].vf(src, src_stride, - dst, dst_stride, &esq[4]); - var[5] = cpi->fn_ptr[f_index].vf(src + bw / 4, src_stride, - dst + bw / 4, dst_stride, &esq[5]); - var[6] = cpi->fn_ptr[f_index].vf(src + bw / 2, src_stride, - dst + bw / 2, dst_stride, &esq[6]); + var[4] = cpi->fn_ptr[f_index].vf(src, src_stride, dst, dst_stride, &esq[4]); + var[5] = cpi->fn_ptr[f_index].vf(src + bw / 4, src_stride, dst + bw / 4, + dst_stride, &esq[5]); + var[6] = cpi->fn_ptr[f_index].vf(src + bw / 2, src_stride, dst + bw / 2, + dst_stride, &esq[6]); var[7] = cpi->fn_ptr[f_index].vf(src + 3 * bw / 4, src_stride, dst + 3 * bw / 4, dst_stride, &esq[7]); src += bh / 4 * src_stride; dst += bh / 4 * dst_stride; - var[8] = cpi->fn_ptr[f_index].vf(src, src_stride, - dst, dst_stride, &esq[8]); - var[9] = cpi->fn_ptr[f_index].vf(src + bw / 4, src_stride, - dst + bw / 4, dst_stride, &esq[9]); - var[10] = cpi->fn_ptr[f_index].vf(src + bw / 2, src_stride, - dst + bw / 2, dst_stride, &esq[10]); + var[8] = cpi->fn_ptr[f_index].vf(src, src_stride, dst, dst_stride, &esq[8]); + var[9] = cpi->fn_ptr[f_index].vf(src + bw / 4, src_stride, dst + bw / 4, + dst_stride, &esq[9]); + var[10] = cpi->fn_ptr[f_index].vf(src + bw / 2, src_stride, dst + bw / 2, + dst_stride, &esq[10]); var[11] = cpi->fn_ptr[f_index].vf(src + 3 * bw / 4, src_stride, dst + 3 * bw / 4, dst_stride, &esq[11]); src += bh / 4 * src_stride; dst += bh / 4 * dst_stride; - var[12] = cpi->fn_ptr[f_index].vf(src, src_stride, - dst, dst_stride, &esq[12]); - var[13] = cpi->fn_ptr[f_index].vf(src + bw / 4, src_stride, - dst + bw / 4, dst_stride, &esq[13]); - var[14] = cpi->fn_ptr[f_index].vf(src + bw / 2, src_stride, - dst + bw / 2, dst_stride, &esq[14]); + var[12] = + cpi->fn_ptr[f_index].vf(src, src_stride, dst, dst_stride, &esq[12]); + var[13] = cpi->fn_ptr[f_index].vf(src + bw / 4, src_stride, dst + bw / 4, + dst_stride, &esq[13]); + var[14] = cpi->fn_ptr[f_index].vf(src + bw / 2, src_stride, dst + bw / 2, + dst_stride, &esq[14]); var[15] = cpi->fn_ptr[f_index].vf(src + 3 * bw / 4, src_stride, dst + 3 * bw / 4, dst_stride, &esq[15]); } - total = esq[0] + esq[1] + esq[2] + esq[3] + - esq[4] + esq[5] + esq[6] + esq[7] + - esq[8] + esq[9] + esq[10] + esq[11] + - esq[12] + esq[13] + esq[14] + esq[15]; + total = esq[0] + esq[1] + esq[2] + esq[3] + esq[4] + esq[5] + esq[6] + + esq[7] + esq[8] + esq[9] + esq[10] + esq[11] + esq[12] + esq[13] + + esq[14] + esq[15]; if (total > 0) { const double e_recip = 1.0 / total; - hordist[0] = ((double)esq[0] + (double)esq[4] + (double)esq[8] + - (double)esq[12]) * e_recip; - hordist[1] = ((double)esq[1] + (double)esq[5] + (double)esq[9] + - (double)esq[13]) * e_recip; - hordist[2] = ((double)esq[2] + (double)esq[6] + (double)esq[10] + - (double)esq[14]) * e_recip; - verdist[0] = ((double)esq[0] + (double)esq[1] + (double)esq[2] + - (double)esq[3]) * e_recip; - verdist[1] = ((double)esq[4] + (double)esq[5] + (double)esq[6] + - (double)esq[7]) * e_recip; - verdist[2] = ((double)esq[8] + (double)esq[9] + (double)esq[10] + - (double)esq[11]) * e_recip; + hordist[0] = + ((double)esq[0] + (double)esq[4] + (double)esq[8] + (double)esq[12]) * + e_recip; + hordist[1] = + ((double)esq[1] + (double)esq[5] + (double)esq[9] + (double)esq[13]) * + e_recip; + hordist[2] = + ((double)esq[2] + (double)esq[6] + (double)esq[10] + (double)esq[14]) * + e_recip; + verdist[0] = + ((double)esq[0] + (double)esq[1] + (double)esq[2] + (double)esq[3]) * + e_recip; + verdist[1] = + ((double)esq[4] + (double)esq[5] + (double)esq[6] + (double)esq[7]) * + e_recip; + verdist[2] = + ((double)esq[8] + (double)esq[9] + (double)esq[10] + (double)esq[11]) * + e_recip; } else { hordist[0] = verdist[0] = 0.25; hordist[1] = verdist[1] = 0.25; hordist[2] = verdist[2] = 0.25; } - (void) var[0]; - (void) var[1]; - (void) var[2]; - (void) var[3]; - (void) var[4]; - (void) var[5]; - (void) var[6]; - (void) var[7]; - (void) var[8]; - (void) var[9]; - (void) var[10]; - (void) var[11]; - (void) var[12]; - (void) var[13]; - (void) var[14]; - (void) var[15]; + (void)var[0]; + (void)var[1]; + (void)var[2]; + (void)var[3]; + (void)var[4]; + (void)var[5]; + (void)var[6]; + (void)var[7]; + (void)var[8]; + (void)var[9]; + (void)var[10]; + (void)var[11]; + (void)var[12]; + (void)var[13]; + (void)var[14]; + (void)var[15]; } static int adst_vs_flipadst(const VP10_COMP *cpi, BLOCK_SIZE bsize, - uint8_t *src, int src_stride, - uint8_t *dst, int dst_stride, - double *hdist, double *vdist) { + uint8_t *src, int src_stride, uint8_t *dst, + int dst_stride, double *hdist, double *vdist) { int prune_bitmask = 0; double svm_proj_h = 0, svm_proj_v = 0; - get_energy_distribution_fine(cpi, bsize, src, src_stride, - dst, dst_stride, hdist, vdist); + get_energy_distribution_fine(cpi, bsize, src, src_stride, dst, dst_stride, + hdist, vdist); - svm_proj_v = vdist[0] * ADST_FLIP_SVM[0] + - vdist[1] * ADST_FLIP_SVM[1] + + svm_proj_v = vdist[0] * ADST_FLIP_SVM[0] + vdist[1] * ADST_FLIP_SVM[1] + vdist[2] * ADST_FLIP_SVM[2] + ADST_FLIP_SVM[3]; - svm_proj_h = hdist[0] * ADST_FLIP_SVM[4] + - hdist[1] * ADST_FLIP_SVM[5] + + svm_proj_h = hdist[0] * ADST_FLIP_SVM[4] + hdist[1] * ADST_FLIP_SVM[5] + hdist[2] * ADST_FLIP_SVM[6] + ADST_FLIP_SVM[7]; if (svm_proj_v > FAST_EXT_TX_EDST_MID + FAST_EXT_TX_EDST_MARGIN) prune_bitmask |= 1 << FLIPADST_1D; @@ -635,8 +595,7 @@ static int adst_vs_flipadst(const VP10_COMP *cpi, BLOCK_SIZE bsize, } #if CONFIG_EXT_TX -static void get_horver_correlation(int16_t *diff, int stride, - int w, int h, +static void get_horver_correlation(int16_t *diff, int stride, int w, int h, double *hcorr, double *vcorr) { // Returns hor/ver correlation coefficient const int num = (h - 1) * (w - 1); @@ -665,9 +624,9 @@ static void get_horver_correlation(int16_t *diff, int stride, z2_sum += z * z; } } - x_var_n = x2_sum - (x_sum * x_sum) * num_r; - y_var_n = y2_sum - (y_sum * y_sum) * num_r; - z_var_n = z2_sum - (z_sum * z_sum) * num_r; + x_var_n = x2_sum - (x_sum * x_sum) * num_r; + y_var_n = y2_sum - (y_sum * y_sum) * num_r; + z_var_n = z2_sum - (z_sum * z_sum) * num_r; xy_var_n = xy_sum - (x_sum * y_sum) * num_r; xz_var_n = xz_sum - (x_sum * z_sum) * num_r; if (x_var_n > 0 && y_var_n > 0) { @@ -680,8 +639,8 @@ static void get_horver_correlation(int16_t *diff, int stride, } } -int dct_vs_idtx(int16_t *diff, int stride, int w, int h, - double *hcorr, double *vcorr) { +int dct_vs_idtx(int16_t *diff, int stride, int w, int h, double *hcorr, + double *vcorr) { int prune_bitmask = 0; get_horver_correlation(diff, stride, w, h, hcorr, vcorr); @@ -698,17 +657,15 @@ int dct_vs_idtx(int16_t *diff, int stride, int w, int h, } // Performance drop: 0.5%, Speed improvement: 24% -static int prune_two_for_sby(const VP10_COMP *cpi, - BLOCK_SIZE bsize, - MACROBLOCK *x, - MACROBLOCKD *xd, int adst_flipadst, +static int prune_two_for_sby(const VP10_COMP *cpi, BLOCK_SIZE bsize, + MACROBLOCK *x, MACROBLOCKD *xd, int adst_flipadst, int dct_idtx) { struct macroblock_plane *const p = &x->plane[0]; struct macroblockd_plane *const pd = &xd->plane[0]; const BLOCK_SIZE bs = get_plane_block_size(bsize, pd); const int bw = 4 << (b_width_log2_lookup[bs]); const int bh = 4 << (b_height_log2_lookup[bs]); - double hdist[3] = {0, 0, 0}, vdist[3] = {0, 0, 0}; + double hdist[3] = { 0, 0, 0 }, vdist[3] = { 0, 0, 0 }; double hcorr, vcorr; int prune = 0; vp10_subtract_plane(x, bsize, 0); @@ -716,92 +673,79 @@ static int prune_two_for_sby(const VP10_COMP *cpi, if (adst_flipadst) prune |= adst_vs_flipadst(cpi, bsize, p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, hdist, vdist); - if (dct_idtx) - prune |= dct_vs_idtx(p->src_diff, bw, bw, bh, &hcorr, &vcorr); + if (dct_idtx) prune |= dct_vs_idtx(p->src_diff, bw, bw, bh, &hcorr, &vcorr); return prune; } #endif // CONFIG_EXT_TX // Performance drop: 0.3%, Speed improvement: 5% -static int prune_one_for_sby(const VP10_COMP *cpi, - BLOCK_SIZE bsize, - MACROBLOCK *x, - MACROBLOCKD *xd) { +static int prune_one_for_sby(const VP10_COMP *cpi, BLOCK_SIZE bsize, + MACROBLOCK *x, MACROBLOCKD *xd) { struct macroblock_plane *const p = &x->plane[0]; struct macroblockd_plane *const pd = &xd->plane[0]; - double hdist[3] = {0, 0, 0}, vdist[3] = {0, 0, 0}; + double hdist[3] = { 0, 0, 0 }, vdist[3] = { 0, 0, 0 }; vp10_subtract_plane(x, bsize, 0); return adst_vs_flipadst(cpi, bsize, p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, hdist, vdist); } -static int prune_tx_types(const VP10_COMP *cpi, - BLOCK_SIZE bsize, - MACROBLOCK *x, +static int prune_tx_types(const VP10_COMP *cpi, BLOCK_SIZE bsize, MACROBLOCK *x, MACROBLOCKD *xd, int tx_set) { #if CONFIG_EXT_TX const int *tx_set_1D = ext_tx_used_inter_1D[tx_set]; #else - const int tx_set_1D[TX_TYPES_1D] = {0}; + const int tx_set_1D[TX_TYPES_1D] = { 0 }; #endif switch (cpi->sf.tx_type_search.prune_mode) { - case NO_PRUNE: - return 0; - break; - case PRUNE_ONE : + case NO_PRUNE: return 0; break; + case PRUNE_ONE: if ((tx_set >= 0) & !(tx_set_1D[FLIPADST_1D] & tx_set_1D[ADST_1D])) return 0; return prune_one_for_sby(cpi, bsize, x, xd); break; - #if CONFIG_EXT_TX - case PRUNE_TWO : +#if CONFIG_EXT_TX + case PRUNE_TWO: if ((tx_set >= 0) & !(tx_set_1D[FLIPADST_1D] & tx_set_1D[ADST_1D])) { - if (!(tx_set_1D[DCT_1D] & tx_set_1D[IDTX_1D])) - return 0; + if (!(tx_set_1D[DCT_1D] & tx_set_1D[IDTX_1D])) return 0; return prune_two_for_sby(cpi, bsize, x, xd, 0, 1); } if ((tx_set >= 0) & !(tx_set_1D[DCT_1D] & tx_set_1D[IDTX_1D])) return prune_two_for_sby(cpi, bsize, x, xd, 1, 0); return prune_two_for_sby(cpi, bsize, x, xd, 1, 1); break; - #endif +#endif } assert(0); return 0; } -static int do_tx_type_search(TX_TYPE tx_type, - int prune) { +static int do_tx_type_search(TX_TYPE tx_type, int prune) { // TODO(sarahparker) implement for non ext tx #if CONFIG_EXT_TX return !(((prune >> vtx_tab[tx_type]) & 1) | - ((prune >> (htx_tab[tx_type] + 8)) & 1)); + ((prune >> (htx_tab[tx_type] + 8)) & 1)); #else // temporary to avoid compiler warnings - (void) vtx_tab; - (void) htx_tab; - (void) tx_type; - (void) prune; + (void)vtx_tab; + (void)htx_tab; + (void)tx_type; + (void)prune; return 1; #endif } static void model_rd_from_sse(const VP10_COMP *const cpi, - const MACROBLOCKD *const xd, - BLOCK_SIZE bsize, - int plane, - int64_t sse, - int *rate, + const MACROBLOCKD *const xd, BLOCK_SIZE bsize, + int plane, int64_t sse, int *rate, int64_t *dist) { const struct macroblockd_plane *const pd = &xd->plane[plane]; const int dequant_shift = #if CONFIG_VP9_HIGHBITDEPTH - (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) ? - xd->bd - 5 : + (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) ? xd->bd - 5 : #endif // CONFIG_VP9_HIGHBITDEPTH - 3; + 3; // Fast approximate the modelling function. if (cpi->sf.simple_model_rd_from_var) { @@ -816,19 +760,17 @@ static void model_rd_from_sse(const VP10_COMP *const cpi, *dist = (square_error * quantizer) >> 8; } else { vp10_model_rd_from_var_lapndz(sse, num_pels_log2_lookup[bsize], - pd->dequant[1] >> dequant_shift, - rate, dist); + pd->dequant[1] >> dequant_shift, rate, dist); } *dist <<= 4; } - static void model_rd_for_sb(const VP10_COMP *const cpi, BLOCK_SIZE bsize, - MACROBLOCK *x, MACROBLOCKD *xd, - int plane_from, int plane_to, - int *out_rate_sum, int64_t *out_dist_sum, - int *skip_txfm_sb, int64_t *skip_sse_sb) { + MACROBLOCK *x, MACROBLOCKD *xd, int plane_from, + int plane_to, int *out_rate_sum, + int64_t *out_dist_sum, int *skip_txfm_sb, + int64_t *skip_sse_sb) { // Note our transform coeffs are 8 times an orthogonal transform. // Hence quantizer step is also 8 times. To get effective quantizer // we need to divide by 8 before sending to modeling function. @@ -852,11 +794,10 @@ static void model_rd_for_sb(const VP10_COMP *const cpi, BLOCK_SIZE bsize, // TODO(geza): Write direct sse functions that do not compute // variance as well. - cpi->fn_ptr[bs].vf(p->src.buf, p->src.stride, - pd->dst.buf, pd->dst.stride, &sse); + cpi->fn_ptr[bs].vf(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, + &sse); - if (plane == 0) - x->pred_sse[ref] = sse; + if (plane == 0) x->pred_sse[ref] = sse; total_sse += sse; @@ -873,13 +814,13 @@ static void model_rd_for_sb(const VP10_COMP *const cpi, BLOCK_SIZE bsize, } int64_t vp10_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, - intptr_t block_size, int64_t *ssz) { + intptr_t block_size, int64_t *ssz) { int i; int64_t error = 0, sqcoeff = 0; for (i = 0; i < block_size; i++) { const int diff = coeff[i] - dqcoeff[i]; - error += diff * diff; + error += diff * diff; sqcoeff += coeff[i] * coeff[i]; } @@ -888,13 +829,13 @@ int64_t vp10_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff, } int64_t vp10_block_error_fp_c(const int16_t *coeff, const int16_t *dqcoeff, - int block_size) { + int block_size) { int i; int64_t error = 0; for (i = 0; i < block_size; i++) { const int diff = coeff[i] - dqcoeff[i]; - error += diff * diff; + error += diff * diff; } return error; @@ -902,9 +843,8 @@ int64_t vp10_block_error_fp_c(const int16_t *coeff, const int16_t *dqcoeff, #if CONFIG_VP9_HIGHBITDEPTH int64_t vp10_highbd_block_error_c(const tran_low_t *coeff, - const tran_low_t *dqcoeff, - intptr_t block_size, - int64_t *ssz, int bd) { + const tran_low_t *dqcoeff, + intptr_t block_size, int64_t *ssz, int bd) { int i; int64_t error = 0, sqcoeff = 0; int shift = 2 * (bd - 8); @@ -912,7 +852,7 @@ int64_t vp10_highbd_block_error_c(const tran_low_t *coeff, for (i = 0; i < block_size; i++) { const int64_t diff = coeff[i] - dqcoeff[i]; - error += diff * diff; + error += diff * diff; sqcoeff += (int64_t)coeff[i] * (int64_t)coeff[i]; } assert(error >= 0 && sqcoeff >= 0); @@ -929,15 +869,13 @@ int64_t vp10_highbd_block_error_c(const tran_low_t *coeff, * can skip this if the last coefficient in this transform block, e.g. the * 16th coefficient in a 4x4 block or the 64th coefficient in a 8x8 block, * were non-zero). */ -static int cost_coeffs(MACROBLOCK *x, - int plane, int block, +static int cost_coeffs(MACROBLOCK *x, int plane, int block, #if CONFIG_VAR_TX int coeff_ctx, #else ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L, #endif - TX_SIZE tx_size, - const int16_t *scan, const int16_t *nb, + TX_SIZE tx_size, const int16_t *scan, const int16_t *nb, int use_fast_coef_costing) { MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; @@ -948,8 +886,8 @@ static int cost_coeffs(MACROBLOCK *x, const int eob = p->eobs[block]; const tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); const int tx_size_ctx = txsize_sqr_map[tx_size]; - unsigned int (*token_costs)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] = - x->token_costs[tx_size_ctx][type][is_inter_block(mbmi)]; + unsigned int(*token_costs)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] = + x->token_costs[tx_size_ctx][type][is_inter_block(mbmi)]; uint8_t token_cache[MAX_TX_SQUARE]; #if CONFIG_VAR_TX int pt = coeff_ctx; @@ -1002,8 +940,7 @@ static int cost_coeffs(MACROBLOCK *x, } // eob token - if (band_left) - cost += (*token_costs)[0][!prev_t][EOB_TOKEN]; + if (band_left) cost += (*token_costs)[0][!prev_t][EOB_TOKEN]; } else { // !use_fast_coef_costing int band_left = *band_count++; @@ -1011,7 +948,7 @@ static int cost_coeffs(MACROBLOCK *x, // dc token int v = qcoeff[0]; int16_t tok; - unsigned int (*tok_cost_ptr)[COEFF_CONTEXTS][ENTROPY_TOKENS]; + unsigned int(*tok_cost_ptr)[COEFF_CONTEXTS][ENTROPY_TOKENS]; cost = vp10_get_token_cost(v, &tok, cat6_high_cost); cost += (*token_costs)[0][pt][tok]; @@ -1055,7 +992,7 @@ static int cost_coeffs(MACROBLOCK *x, static void dist_block(const VP10_COMP *cpi, MACROBLOCK *x, int plane, int block, int blk_row, int blk_col, TX_SIZE tx_size, int64_t *out_dist, int64_t *out_sse) { - MACROBLOCKD* const xd = &x->e_mbd; + MACROBLOCKD *const xd = &x->e_mbd; const struct macroblock_plane *const p = &x->plane[plane]; const struct macroblockd_plane *const pd = &xd->plane[plane]; if (cpi->sf.use_transform_domain_distortion) { @@ -1070,10 +1007,12 @@ static void dist_block(const VP10_COMP *cpi, MACROBLOCK *x, int plane, #if CONFIG_VP9_HIGHBITDEPTH const int bd = (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) ? xd->bd : 8; *out_dist = vp10_highbd_block_error(coeff, dqcoeff, 16 << ss_txfrm_size, - &this_sse, bd) >> shift; + &this_sse, bd) >> + shift; #else - *out_dist = vp10_block_error(coeff, dqcoeff, 16 << ss_txfrm_size, - &this_sse) >> shift; + *out_dist = + vp10_block_error(coeff, dqcoeff, 16 << ss_txfrm_size, &this_sse) >> + shift; #endif // CONFIG_VP9_HIGHBITDEPTH *out_sse = this_sse >> shift; } else { @@ -1100,7 +1039,7 @@ static void dist_block(const VP10_COMP *cpi, MACROBLOCK *x, int plane, const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; #if CONFIG_VP9_HIGHBITDEPTH DECLARE_ALIGNED(16, uint16_t, recon16[MAX_TX_SQUARE]); - uint8_t *recon = (uint8_t*)recon16; + uint8_t *recon = (uint8_t *)recon16; #else DECLARE_ALIGNED(16, uint8_t, recon[MAX_TX_SQUARE]); #endif // CONFIG_VP9_HIGHBITDEPTH @@ -1118,14 +1057,14 @@ static void dist_block(const VP10_COMP *cpi, MACROBLOCK *x, int plane, if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { recon = CONVERT_TO_BYTEPTR(recon); inv_txfm_param.bd = xd->bd; - vpx_highbd_convolve_copy(dst, dst_stride, recon, MAX_TX_SIZE, - NULL, 0, NULL, 0, bsw, bsh, xd->bd); + vpx_highbd_convolve_copy(dst, dst_stride, recon, MAX_TX_SIZE, NULL, 0, + NULL, 0, bsw, bsh, xd->bd); highbd_inv_txfm_add(dqcoeff, recon, MAX_TX_SIZE, &inv_txfm_param); } else #endif // CONFIG_VP9_HIGHBITDEPTH { - vpx_convolve_copy(dst, dst_stride, recon, MAX_TX_SIZE, - NULL, 0, NULL, 0, bsw, bsh); + vpx_convolve_copy(dst, dst_stride, recon, MAX_TX_SIZE, NULL, 0, NULL, 0, + bsw, bsh); inv_txfm_add(dqcoeff, recon, MAX_TX_SIZE, &inv_txfm_param); } @@ -1137,23 +1076,21 @@ static void dist_block(const VP10_COMP *cpi, MACROBLOCK *x, int plane, } static int rate_block(int plane, int block, int blk_row, int blk_col, - TX_SIZE tx_size, struct rdcost_block_args* args) { + TX_SIZE tx_size, struct rdcost_block_args *args) { #if CONFIG_VAR_TX int coeff_ctx = combine_entropy_contexts(*(args->t_above + blk_col), *(args->t_left + blk_row)); - int coeff_cost = cost_coeffs(args->x, plane, block, coeff_ctx, - tx_size, args->so->scan, args->so->neighbors, - args->use_fast_coef_costing); + int coeff_cost = + cost_coeffs(args->x, plane, block, coeff_ctx, tx_size, args->so->scan, + args->so->neighbors, args->use_fast_coef_costing); const struct macroblock_plane *p = &args->x->plane[plane]; *(args->t_above + blk_col) = !(p->eobs[block] == 0); - *(args->t_left + blk_row) = !(p->eobs[block] == 0); + *(args->t_left + blk_row) = !(p->eobs[block] == 0); return coeff_cost; #else - return cost_coeffs(args->x, plane, block, - args->t_above + blk_col, - args->t_left + blk_row, - tx_size, args->so->scan, args->so->neighbors, - args->use_fast_coef_costing); + return cost_coeffs(args->x, plane, block, args->t_above + blk_col, + args->t_left + blk_row, tx_size, args->so->scan, + args->so->neighbors, args->use_fast_coef_costing); #endif // CONFIG_VAR_TX } @@ -1164,11 +1101,11 @@ static uint64_t sum_squares_2d(const int16_t *diff, int diff_stride, #if CONFIG_EXT_TX case TX_4X8: sse = vpx_sum_squares_2d_i16(diff, diff_stride, 4) + - vpx_sum_squares_2d_i16(diff + 4 * diff_stride, diff_stride, 4); + vpx_sum_squares_2d_i16(diff + 4 * diff_stride, diff_stride, 4); break; case TX_8X4: sse = vpx_sum_squares_2d_i16(diff, diff_stride, 4) + - vpx_sum_squares_2d_i16(diff + 4, diff_stride, 4);; + vpx_sum_squares_2d_i16(diff + 4, diff_stride, 4); break; #endif // CONFIG_EXT_TX default: @@ -1181,8 +1118,7 @@ static uint64_t sum_squares_2d(const int16_t *diff, int diff_stride, } static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, - TX_SIZE tx_size, void *arg) { + BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) { struct rdcost_block_args *args = arg; MACROBLOCK *const x = args->x; MACROBLOCKD *const xd = &x->e_mbd; @@ -1191,21 +1127,21 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, int rate; int64_t dist; int64_t sse; - int coeff_ctx = combine_entropy_contexts( - *(args->t_above + blk_col), *(args->t_left + blk_row)); + int coeff_ctx = combine_entropy_contexts(*(args->t_above + blk_col), + *(args->t_left + blk_row)); - if (args->exit_early) - return; + if (args->exit_early) return; if (!is_inter_block(mbmi)) { struct encode_b_args intra_arg = { - x, NULL, &mbmi->skip, args->t_above, args->t_left, 1}; - vp10_encode_block_intra(plane, block, blk_row, blk_col, - plane_bsize, tx_size, &intra_arg); + x, NULL, &mbmi->skip, args->t_above, args->t_left, 1 + }; + vp10_encode_block_intra(plane, block, blk_row, blk_col, plane_bsize, + tx_size, &intra_arg); if (args->cpi->sf.use_transform_domain_distortion) { - dist_block(args->cpi, x, plane, block, blk_row, blk_col, - tx_size, &dist, &sse); + dist_block(args->cpi, x, plane, block, blk_row, blk_col, tx_size, &dist, + &sse); } else { // Note that the encode block_intra call above already calls // inv_txfm_add, so we can't just call dist_block here. @@ -1236,7 +1172,7 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, dist = (int64_t)tmp * 16; } } else { - // full forward transform and quantization +// full forward transform and quantization #if CONFIG_NEW_QUANT vp10_xform_quant_fp_nuq(x, plane, block, blk_row, blk_col, plane_bsize, tx_size, coeff_ctx); @@ -1246,8 +1182,8 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, #endif // CONFIG_NEW_QUANT if (x->plane[plane].eobs[block]) vp10_optimize_b(x, plane, block, tx_size, coeff_ctx); - dist_block(args->cpi, x, plane, block, blk_row, blk_col, - tx_size, &dist, &sse); + dist_block(args->cpi, x, plane, block, blk_row, blk_col, tx_size, &dist, + &sse); } rd = RDCOST(x->rdmult, x->rddiv, 0, dist); @@ -1276,13 +1212,10 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, args->skippable &= !x->plane[plane].eobs[block]; } -static void txfm_rd_in_plane(MACROBLOCK *x, - const VP10_COMP *cpi, - int *rate, int64_t *distortion, - int *skippable, int64_t *sse, - int64_t ref_best_rd, int plane, - BLOCK_SIZE bsize, TX_SIZE tx_size, - int use_fast_coef_casting) { +static void txfm_rd_in_plane(MACROBLOCK *x, const VP10_COMP *cpi, int *rate, + int64_t *distortion, int *skippable, int64_t *sse, + int64_t ref_best_rd, int plane, BLOCK_SIZE bsize, + TX_SIZE tx_size, int use_fast_coef_casting) { MACROBLOCKD *const xd = &x->e_mbd; const struct macroblockd_plane *const pd = &xd->plane[plane]; TX_TYPE tx_type; @@ -1294,32 +1227,30 @@ static void txfm_rd_in_plane(MACROBLOCK *x, args.use_fast_coef_costing = use_fast_coef_casting; args.skippable = 1; - if (plane == 0) - xd->mi[0]->mbmi.tx_size = tx_size; + if (plane == 0) xd->mi[0]->mbmi.tx_size = tx_size; vp10_get_entropy_contexts(bsize, tx_size, pd, args.t_above, args.t_left); tx_type = get_tx_type(pd->plane_type, xd, 0, tx_size); args.so = get_scan(tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi)); - vp10_foreach_transformed_block_in_plane(xd, bsize, plane, - block_rd_txfm, &args); + vp10_foreach_transformed_block_in_plane(xd, bsize, plane, block_rd_txfm, + &args); if (args.exit_early) { - *rate = INT_MAX; + *rate = INT_MAX; *distortion = INT64_MAX; - *sse = INT64_MAX; - *skippable = 0; + *sse = INT64_MAX; + *skippable = 0; } else { *distortion = args.this_dist; - *rate = args.this_rate; - *sse = args.this_sse; - *skippable = args.skippable; + *rate = args.this_rate; + *sse = args.this_sse; + *skippable = args.skippable; } } #if CONFIG_SUPERTX -void vp10_txfm_rd_in_plane_supertx(MACROBLOCK *x, - const VP10_COMP *cpi, +void vp10_txfm_rd_in_plane_supertx(MACROBLOCK *x, const VP10_COMP *cpi, int *rate, int64_t *distortion, int *skippable, int64_t *sse, int64_t ref_best_rd, int plane, @@ -1340,34 +1271,32 @@ void vp10_txfm_rd_in_plane_supertx(MACROBLOCK *x, assert(tx_size < TX_SIZES); #endif // CONFIG_EXT_TX - if (plane == 0) - xd->mi[0]->mbmi.tx_size = tx_size; + if (plane == 0) xd->mi[0]->mbmi.tx_size = tx_size; vp10_get_entropy_contexts(bsize, tx_size, pd, args.t_above, args.t_left); tx_type = get_tx_type(pd->plane_type, xd, 0, tx_size); args.so = get_scan(tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi)); - block_rd_txfm(plane, 0, 0, 0, get_plane_block_size(bsize, pd), - tx_size, &args); + block_rd_txfm(plane, 0, 0, 0, get_plane_block_size(bsize, pd), tx_size, + &args); if (args.exit_early) { - *rate = INT_MAX; + *rate = INT_MAX; *distortion = INT64_MAX; - *sse = INT64_MAX; - *skippable = 0; + *sse = INT64_MAX; + *skippable = 0; } else { *distortion = args.this_dist; - *rate = args.this_rate; - *sse = args.this_sse; - *skippable = !x->plane[plane].eobs[0]; + *rate = args.this_rate; + *sse = args.this_sse; + *skippable = !x->plane[plane].eobs[0]; } } #endif // CONFIG_SUPERTX -static int64_t txfm_yrd(VP10_COMP *cpi, MACROBLOCK *x, - int *r, int64_t *d, int *s, int64_t *sse, - int64_t ref_best_rd, +static int64_t txfm_yrd(VP10_COMP *cpi, MACROBLOCK *x, int *r, int64_t *d, + int *s, int64_t *sse, int64_t ref_best_rd, BLOCK_SIZE bs, TX_TYPE tx_type, int tx_size) { VP10_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; @@ -1391,37 +1320,33 @@ static int64_t txfm_yrd(VP10_COMP *cpi, MACROBLOCK *x, mbmi->tx_type = tx_type; mbmi->tx_size = tx_size; - txfm_rd_in_plane(x, - cpi, - r, d, s, - sse, ref_best_rd, 0, bs, tx_size, + txfm_rd_in_plane(x, cpi, r, d, s, sse, ref_best_rd, 0, bs, tx_size, cpi->sf.use_fast_coef_costing); - if (*r == INT_MAX) - return INT64_MAX; + if (*r == INT_MAX) return INT64_MAX; #if CONFIG_EXT_TX ext_tx_set = get_ext_tx_set(tx_size, bs, is_inter); if (get_ext_tx_types(tx_size, bs, is_inter) > 1 && !xd->lossless[xd->mi[0]->mbmi.segment_id]) { if (is_inter) { if (ext_tx_set > 0) - *r += cpi->inter_tx_type_costs[ext_tx_set] - [mbmi->tx_size][mbmi->tx_type]; + *r += + cpi->inter_tx_type_costs[ext_tx_set][mbmi->tx_size][mbmi->tx_type]; } else { if (ext_tx_set > 0 && ALLOW_INTRA_EXT_TX) - *r += cpi->intra_tx_type_costs[ext_tx_set][mbmi->tx_size] - [mbmi->mode][mbmi->tx_type]; + *r += cpi->intra_tx_type_costs[ext_tx_set][mbmi->tx_size][mbmi->mode] + [mbmi->tx_type]; } } #else - if (tx_size < TX_32X32 && - !xd->lossless[xd->mi[0]->mbmi.segment_id] && !FIXED_TX_TYPE) { + if (tx_size < TX_32X32 && !xd->lossless[xd->mi[0]->mbmi.segment_id] && + !FIXED_TX_TYPE) { if (is_inter) { *r += cpi->inter_tx_type_costs[mbmi->tx_size][mbmi->tx_type]; } else { *r += cpi->intra_tx_type_costs[mbmi->tx_size] - [intra_mode_to_tx_type_context[mbmi->mode]] - [mbmi->tx_type]; + [intra_mode_to_tx_type_context[mbmi->mode]] + [mbmi->tx_type]; } } #endif // CONFIG_EXT_TX @@ -1430,14 +1355,13 @@ static int64_t txfm_yrd(VP10_COMP *cpi, MACROBLOCK *x, if (is_inter) { rd = RDCOST(x->rdmult, x->rddiv, s1, *sse); } else { - rd = RDCOST(x->rdmult, x->rddiv, s1 + r_tx_size * tx_select, *sse); + rd = RDCOST(x->rdmult, x->rddiv, s1 + r_tx_size * tx_select, *sse); } } else { rd = RDCOST(x->rdmult, x->rddiv, *r + s0 + r_tx_size * tx_select, *d); } - if (tx_select) - *r += r_tx_size; + if (tx_select) *r += r_tx_size; if (is_inter && !xd->lossless[xd->mi[0]->mbmi.segment_id] && !(*s)) rd = VPXMIN(rd, RDCOST(x->rdmult, x->rddiv, s1, *sse)); @@ -1445,16 +1369,11 @@ static int64_t txfm_yrd(VP10_COMP *cpi, MACROBLOCK *x, return rd; } -static int64_t choose_tx_size_fix_type(VP10_COMP *cpi, - BLOCK_SIZE bs, - MACROBLOCK *x, - int *rate, - int64_t *distortion, - int *skip, - int64_t *psse, - int64_t ref_best_rd, - TX_TYPE tx_type, - int prune) { +static int64_t choose_tx_size_fix_type(VP10_COMP *cpi, BLOCK_SIZE bs, + MACROBLOCK *x, int *rate, + int64_t *distortion, int *skip, + int64_t *psse, int64_t ref_best_rd, + TX_TYPE tx_type, int prune) { VP10_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; @@ -1483,55 +1402,47 @@ static int64_t choose_tx_size_fix_type(VP10_COMP *cpi, } *distortion = INT64_MAX; - *rate = INT_MAX; - *skip = 0; - *psse = INT64_MAX; + *rate = INT_MAX; + *skip = 0; + *psse = INT64_MAX; mbmi->tx_type = tx_type; last_rd = INT64_MAX; for (n = start_tx; n >= end_tx; --n) { - if (FIXED_TX_TYPE && tx_type != get_default_tx_type(0, xd, 0, n)) - continue; + if (FIXED_TX_TYPE && tx_type != get_default_tx_type(0, xd, 0, n)) continue; if (!is_inter && x->use_default_intra_tx_type && tx_type != get_default_tx_type(0, xd, 0, n)) continue; if (is_inter && x->use_default_inter_tx_type && tx_type != get_default_tx_type(0, xd, 0, n)) continue; - if (max_tx_size == TX_32X32 && n == TX_4X4) - continue; + if (max_tx_size == TX_32X32 && n == TX_4X4) continue; #if CONFIG_EXT_TX ext_tx_set = get_ext_tx_set(n, bs, is_inter); if (is_inter) { - if (!ext_tx_used_inter[ext_tx_set][tx_type]) - continue; + if (!ext_tx_used_inter[ext_tx_set][tx_type]) continue; if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE) { - if (!do_tx_type_search(tx_type, prune)) - continue; + if (!do_tx_type_search(tx_type, prune)) continue; } } else { if (!ALLOW_INTRA_EXT_TX && bs >= BLOCK_8X8) { - if (tx_type != intra_mode_to_tx_type_context[mbmi->mode]) - continue; + if (tx_type != intra_mode_to_tx_type_context[mbmi->mode]) continue; } - if (!ext_tx_used_intra[ext_tx_set][tx_type]) - continue; + if (!ext_tx_used_intra[ext_tx_set][tx_type]) continue; } -#else // CONFIG_EXT_TX - if (n >= TX_32X32 && tx_type != DCT_DCT) - continue; +#else // CONFIG_EXT_TX + if (n >= TX_32X32 && tx_type != DCT_DCT) continue; if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE && !do_tx_type_search(tx_type, prune)) - continue; + continue; #endif // CONFIG_EXT_TX rd = txfm_yrd(cpi, x, &r, &d, &s, &sse, ref_best_rd, bs, tx_type, n); // Early termination in transform size search. if (cpi->sf.tx_size_search_breakout && - (rd == INT64_MAX || - (s == 1 && tx_type != DCT_DCT && n < start_tx) || - (n < (int) max_tx_size && rd > last_rd))) + (rd == INT64_MAX || (s == 1 && tx_type != DCT_DCT && n < start_tx) || + (n < (int)max_tx_size && rd > last_rd))) break; last_rd = rd; @@ -1539,9 +1450,9 @@ static int64_t choose_tx_size_fix_type(VP10_COMP *cpi, best_tx = n; best_rd = rd; *distortion = d; - *rate = r; - *skip = s; - *psse = sse; + *rate = r; + *skip = s; + *psse = sse; } } mbmi->tx_size = best_tx; @@ -1550,22 +1461,17 @@ static int64_t choose_tx_size_fix_type(VP10_COMP *cpi, } #if CONFIG_EXT_INTER -static int64_t estimate_yrd_for_sb(VP10_COMP *cpi, - BLOCK_SIZE bs, - MACROBLOCK *x, - int *r, int64_t *d, - int *s, int64_t *sse, +static int64_t estimate_yrd_for_sb(VP10_COMP *cpi, BLOCK_SIZE bs, MACROBLOCK *x, + int *r, int64_t *d, int *s, int64_t *sse, int64_t ref_best_rd) { - return txfm_yrd(cpi, x, r, d, s, sse, ref_best_rd, bs, - DCT_DCT, max_txsize_lookup[bs]); + return txfm_yrd(cpi, x, r, d, s, sse, ref_best_rd, bs, DCT_DCT, + max_txsize_lookup[bs]); } #endif // CONFIG_EXT_INTER -static void choose_largest_tx_size(VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int64_t *distortion, - int *skip, int64_t *sse, - int64_t ref_best_rd, - BLOCK_SIZE bs) { +static void choose_largest_tx_size(VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int64_t *distortion, int *skip, int64_t *sse, + int64_t ref_best_rd, BLOCK_SIZE bs) { const TX_SIZE max_tx_size = max_txsize_lookup[bs]; VP10_COMMON *const cm = &cpi->common; const TX_SIZE largest_tx_size = tx_mode_to_biggest_tx_size[cm->tx_mode]; @@ -1575,8 +1481,8 @@ static void choose_largest_tx_size(VP10_COMP *cpi, MACROBLOCK *x, int r, s; int64_t d, psse, this_rd, best_rd = INT64_MAX; vpx_prob skip_prob = vp10_get_skip_prob(cm, xd); - int s0 = vp10_cost_bit(skip_prob, 0); - int s1 = vp10_cost_bit(skip_prob, 1); + int s0 = vp10_cost_bit(skip_prob, 0); + int s1 = vp10_cost_bit(skip_prob, 1); const int is_inter = is_inter_block(mbmi); int prune = 0; #if CONFIG_EXT_TX @@ -1603,43 +1509,35 @@ static void choose_largest_tx_size(VP10_COMP *cpi, MACROBLOCK *x, if (x->use_default_inter_tx_type && tx_type != get_default_tx_type(0, xd, 0, mbmi->tx_size)) continue; - if (!ext_tx_used_inter[ext_tx_set][tx_type]) - continue; + if (!ext_tx_used_inter[ext_tx_set][tx_type]) continue; if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE) { - if (!do_tx_type_search(tx_type, prune)) - continue; + if (!do_tx_type_search(tx_type, prune)) continue; } } else { if (x->use_default_intra_tx_type && tx_type != get_default_tx_type(0, xd, 0, mbmi->tx_size)) continue; if (!ALLOW_INTRA_EXT_TX && bs >= BLOCK_8X8) { - if (tx_type != intra_mode_to_tx_type_context[mbmi->mode]) - continue; + if (tx_type != intra_mode_to_tx_type_context[mbmi->mode]) continue; } - if (!ext_tx_used_intra[ext_tx_set][tx_type]) - continue; + if (!ext_tx_used_intra[ext_tx_set][tx_type]) continue; } mbmi->tx_type = tx_type; - txfm_rd_in_plane(x, - cpi, - &r, &d, &s, - &psse, ref_best_rd, 0, bs, mbmi->tx_size, - cpi->sf.use_fast_coef_costing); + txfm_rd_in_plane(x, cpi, &r, &d, &s, &psse, ref_best_rd, 0, bs, + mbmi->tx_size, cpi->sf.use_fast_coef_costing); - if (r == INT_MAX) - continue; + if (r == INT_MAX) continue; if (get_ext_tx_types(mbmi->tx_size, bs, is_inter) > 1) { if (is_inter) { if (ext_tx_set > 0) - r += cpi->inter_tx_type_costs[ext_tx_set] - [mbmi->tx_size][mbmi->tx_type]; + r += cpi->inter_tx_type_costs[ext_tx_set][mbmi->tx_size] + [mbmi->tx_type]; } else { if (ext_tx_set > 0 && ALLOW_INTRA_EXT_TX) - r += cpi->intra_tx_type_costs[ext_tx_set][mbmi->tx_size] - [mbmi->mode][mbmi->tx_type]; + r += cpi->intra_tx_type_costs[ext_tx_set][mbmi->tx_size][mbmi->mode] + [mbmi->tx_type]; } } @@ -1657,9 +1555,8 @@ static void choose_largest_tx_size(VP10_COMP *cpi, MACROBLOCK *x, } } -#else // CONFIG_EXT_TX - if (mbmi->tx_size < TX_32X32 && - !xd->lossless[mbmi->segment_id]) { +#else // CONFIG_EXT_TX + if (mbmi->tx_size < TX_32X32 && !xd->lossless[mbmi->segment_id]) { for (tx_type = 0; tx_type < TX_TYPES; ++tx_type) { if (!is_inter && x->use_default_intra_tx_type && tx_type != get_default_tx_type(0, xd, 0, mbmi->tx_size)) @@ -1668,18 +1565,14 @@ static void choose_largest_tx_size(VP10_COMP *cpi, MACROBLOCK *x, tx_type != get_default_tx_type(0, xd, 0, mbmi->tx_size)) continue; mbmi->tx_type = tx_type; - txfm_rd_in_plane(x, - cpi, - &r, &d, &s, - &psse, ref_best_rd, 0, bs, mbmi->tx_size, - cpi->sf.use_fast_coef_costing); - if (r == INT_MAX) - continue; + txfm_rd_in_plane(x, cpi, &r, &d, &s, &psse, ref_best_rd, 0, bs, + mbmi->tx_size, cpi->sf.use_fast_coef_costing); + if (r == INT_MAX) continue; if (is_inter) { r += cpi->inter_tx_type_costs[mbmi->tx_size][mbmi->tx_type]; if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE && !do_tx_type_search(tx_type, prune)) - continue; + continue; } else { r += cpi->intra_tx_type_costs[mbmi->tx_size] [intra_mode_to_tx_type_context[mbmi->mode]] @@ -1701,17 +1594,13 @@ static void choose_largest_tx_size(VP10_COMP *cpi, MACROBLOCK *x, #endif // CONFIG_EXT_TX mbmi->tx_type = best_tx_type; - txfm_rd_in_plane(x, - cpi, - rate, distortion, skip, - sse, ref_best_rd, 0, bs, + txfm_rd_in_plane(x, cpi, rate, distortion, skip, sse, ref_best_rd, 0, bs, mbmi->tx_size, cpi->sf.use_fast_coef_costing); } -static void choose_smallest_tx_size(VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int64_t *distortion, - int *skip, int64_t *sse, - int64_t ref_best_rd, +static void choose_smallest_tx_size(VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int64_t *distortion, int *skip, + int64_t *sse, int64_t ref_best_rd, BLOCK_SIZE bs) { MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; @@ -1719,20 +1608,14 @@ static void choose_smallest_tx_size(VP10_COMP *cpi, MACROBLOCK *x, mbmi->tx_size = TX_4X4; mbmi->tx_type = DCT_DCT; - txfm_rd_in_plane(x, - cpi, - rate, distortion, skip, - sse, ref_best_rd, 0, bs, + txfm_rd_in_plane(x, cpi, rate, distortion, skip, sse, ref_best_rd, 0, bs, mbmi->tx_size, cpi->sf.use_fast_coef_costing); } static void choose_tx_size_type_from_rd(VP10_COMP *cpi, MACROBLOCK *x, - int *rate, - int64_t *distortion, - int *skip, - int64_t *psse, - int64_t ref_best_rd, - BLOCK_SIZE bs) { + int *rate, int64_t *distortion, + int *skip, int64_t *psse, + int64_t ref_best_rd, BLOCK_SIZE bs) { MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; int r, s; @@ -1750,23 +1633,22 @@ static void choose_tx_size_type_from_rd(VP10_COMP *cpi, MACROBLOCK *x, prune = prune_tx_types(cpi, bs, x, xd, -1); *distortion = INT64_MAX; - *rate = INT_MAX; - *skip = 0; - *psse = INT64_MAX; + *rate = INT_MAX; + *skip = 0; + *psse = INT64_MAX; for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) { #if CONFIG_REF_MV - if (tx_type != DCT_DCT && is_inter && mbmi->ref_mv_idx > 0) - continue; + if (tx_type != DCT_DCT && is_inter && mbmi->ref_mv_idx > 0) continue; #endif rd = choose_tx_size_fix_type(cpi, bs, x, &r, &d, &s, &sse, ref_best_rd, tx_type, prune); if (rd < best_rd) { best_rd = rd; *distortion = d; - *rate = r; - *skip = s; - *psse = sse; + *rate = r; + *skip = s; + *psse = sse; best_tx_type = tx_type; best_tx = mbmi->tx_size; } @@ -1776,15 +1658,13 @@ static void choose_tx_size_type_from_rd(VP10_COMP *cpi, MACROBLOCK *x, mbmi->tx_type = best_tx_type; #if !CONFIG_EXT_TX - if (mbmi->tx_size >= TX_32X32) - assert(mbmi->tx_type == DCT_DCT); + if (mbmi->tx_size >= TX_32X32) assert(mbmi->tx_type == DCT_DCT); #endif } static void super_block_yrd(VP10_COMP *cpi, MACROBLOCK *x, int *rate, - int64_t *distortion, int *skip, - int64_t *psse, BLOCK_SIZE bs, - int64_t ref_best_rd) { + int64_t *distortion, int *skip, int64_t *psse, + BLOCK_SIZE bs, int64_t ref_best_rd) { MACROBLOCKD *xd = &x->e_mbd; int64_t sse; int64_t *ret_sse = psse ? psse : &sse; @@ -1805,33 +1685,26 @@ static void super_block_yrd(VP10_COMP *cpi, MACROBLOCK *x, int *rate, static int conditional_skipintra(PREDICTION_MODE mode, PREDICTION_MODE best_intra_mode) { - if (mode == D117_PRED && - best_intra_mode != V_PRED && + if (mode == D117_PRED && best_intra_mode != V_PRED && best_intra_mode != D135_PRED) return 1; - if (mode == D63_PRED && - best_intra_mode != V_PRED && + if (mode == D63_PRED && best_intra_mode != V_PRED && best_intra_mode != D45_PRED) return 1; - if (mode == D207_PRED && - best_intra_mode != H_PRED && + if (mode == D207_PRED && best_intra_mode != H_PRED && best_intra_mode != D45_PRED) return 1; - if (mode == D153_PRED && - best_intra_mode != H_PRED && + if (mode == D153_PRED && best_intra_mode != H_PRED && best_intra_mode != D135_PRED) return 1; return 0; } -static int rd_pick_palette_intra_sby(VP10_COMP *cpi, MACROBLOCK *x, - BLOCK_SIZE bsize, - int palette_ctx, int dc_mode_cost, - PALETTE_MODE_INFO *palette_mode_info, - uint8_t *best_palette_color_map, - TX_SIZE *best_tx, TX_TYPE *best_tx_type, - PREDICTION_MODE *mode_selected, - int64_t *best_rd) { +static int rd_pick_palette_intra_sby( + VP10_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int palette_ctx, + int dc_mode_cost, PALETTE_MODE_INFO *palette_mode_info, + uint8_t *best_palette_color_map, TX_SIZE *best_tx, TX_TYPE *best_tx_type, + PREDICTION_MODE *mode_selected, int64_t *best_rd) { MACROBLOCKD *const xd = &x->e_mbd; MODE_INFO *const mic = xd->mi[0]; const int rows = 4 * num_4x4_blocks_high_lookup[bsize]; @@ -1906,11 +1779,10 @@ static int rd_pick_palette_intra_sby(VP10_COMP *cpi, MACROBLOCK *x, mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = 0; #endif // CONFIG_EXT_INTRA - if (rows * cols > PALETTE_MAX_BLOCK_SIZE) - return 0; + if (rows * cols > PALETTE_MAX_BLOCK_SIZE) return 0; - for (n = colors > PALETTE_MAX_SIZE ? PALETTE_MAX_SIZE : colors; - n >= 2; --n) { + for (n = colors > PALETTE_MAX_SIZE ? PALETTE_MAX_SIZE : colors; n >= 2; + --n) { for (i = 0; i < n; ++i) centroids[i] = lb + (2 * i + 1) * (ub - lb) / n / 2; vp10_k_means(data, centroids, color_map, rows * cols, n, 1, max_itr); @@ -1929,29 +1801,29 @@ static int rd_pick_palette_intra_sby(VP10_COMP *cpi, MACROBLOCK *x, vp10_calc_indices(data, centroids, color_map, rows * cols, k, 1); - super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, - &s, NULL, bsize, *best_rd); - if (this_rate_tokenonly == INT_MAX) - continue; + super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, NULL, + bsize, *best_rd); + if (this_rate_tokenonly == INT_MAX) continue; - this_rate = this_rate_tokenonly + dc_mode_cost + + this_rate = + this_rate_tokenonly + dc_mode_cost + cpi->common.bit_depth * k * vp10_cost_bit(128, 0) + cpi->palette_y_size_cost[bsize - BLOCK_8X8][k - 2] + write_uniform_cost(k, color_map[0]) + - vp10_cost_bit(vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8] - [palette_ctx], 1); + vp10_cost_bit( + vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx], + 1); for (i = 0; i < rows; ++i) { for (j = (i == 0 ? 1 : 0); j < cols; ++j) { - color_ctx = vp10_get_palette_color_context(color_map, cols, i, j, - k, color_order); + color_ctx = vp10_get_palette_color_context(color_map, cols, i, j, k, + color_order); for (r = 0; r < k; ++r) if (color_map[i * cols + j] == color_order[r]) { color_idx = r; break; } assert(color_idx >= 0 && color_idx < k); - this_rate += - cpi->palette_y_color_cost[k - 2][color_ctx][color_idx]; + this_rate += cpi->palette_y_color_cost[k - 2][color_ctx][color_idx]; } } this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); @@ -1972,13 +1844,11 @@ static int rd_pick_palette_intra_sby(VP10_COMP *cpi, MACROBLOCK *x, return rate_overhead; } -static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x, - int row, int col, - PREDICTION_MODE *best_mode, - const int *bmode_costs, - ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, - int *bestrate, int *bestratey, - int64_t *bestdistortion, +static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x, int row, + int col, PREDICTION_MODE *best_mode, + const int *bmode_costs, ENTROPY_CONTEXT *a, + ENTROPY_CONTEXT *l, int *bestrate, + int *bestratey, int64_t *bestdistortion, BLOCK_SIZE bsize, int64_t rd_thresh) { PREDICTION_MODE mode; MACROBLOCKD *const xd = &x->e_mbd; @@ -2012,14 +1882,12 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x, int64_t distortion = 0; int rate = bmode_costs[mode]; - if (!(cpi->sf.intra_y_mode_mask[TX_4X4] & (1 << mode))) - continue; + if (!(cpi->sf.intra_y_mode_mask[TX_4X4] & (1 << mode))) continue; // Only do the oblique modes if the best so far is // one of the neighboring directional modes if (cpi->sf.mode_search_skip_flags & FLAG_SKIP_INTRA_DIRMISMATCH) { - if (conditional_skipintra(mode, *best_mode)) - continue; + if (conditional_skipintra(mode, *best_mode)) continue; } memcpy(tempa, ta, num_4x4_blocks_wide * sizeof(ta[0])); @@ -2030,21 +1898,19 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x, const int block = (row + idy) * 2 + (col + idx); const uint8_t *const src = &src_init[idx * 4 + idy * 4 * src_stride]; uint8_t *const dst = &dst_init[idx * 4 + idy * 4 * dst_stride]; - int16_t *const src_diff = vp10_raster_block_offset_int16(BLOCK_8X8, - block, - p->src_diff); + int16_t *const src_diff = + vp10_raster_block_offset_int16(BLOCK_8X8, block, p->src_diff); xd->mi[0]->bmi[block].as_mode = mode; - vp10_predict_intra_block(xd, 1, 1, TX_4X4, mode, dst, dst_stride, - dst, dst_stride, - col + idx, row + idy, 0); - vpx_highbd_subtract_block(4, 4, src_diff, 8, src, src_stride, - dst, dst_stride, xd->bd); + vp10_predict_intra_block(xd, 1, 1, TX_4X4, mode, dst, dst_stride, dst, + dst_stride, col + idx, row + idy, 0); + vpx_highbd_subtract_block(4, 4, src_diff, 8, src, src_stride, dst, + dst_stride, xd->bd); if (xd->lossless[xd->mi[0]->mbmi.segment_id]) { TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4); const scan_order *so = get_scan(TX_4X4, tx_type, 0); #if CONFIG_VAR_TX | CONFIG_NEW_QUANT - const int coeff_ctx = combine_entropy_contexts(*(tempa + idx), - *(templ + idy)); + const int coeff_ctx = + combine_entropy_contexts(*(tempa + idx), *(templ + idy)); #endif // CONFIG_VAR_TX | CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT vp10_xform_quant_fp_nuq(x, 0, block, row + idy, col + idx, @@ -2059,23 +1925,22 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x, *(tempa + idx) = !(p->eobs[block] == 0); *(templ + idy) = !(p->eobs[block] == 0); #else - ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, - TX_4X4, + ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4, so->scan, so->neighbors, cpi->sf.use_fast_coef_costing); #endif // CONFIG_VAR_TX if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd) goto next_highbd; - vp10_highbd_inv_txfm_add_4x4(BLOCK_OFFSET(pd->dqcoeff, block), - dst, dst_stride, p->eobs[block], - xd->bd, DCT_DCT, 1); + vp10_highbd_inv_txfm_add_4x4(BLOCK_OFFSET(pd->dqcoeff, block), dst, + dst_stride, p->eobs[block], xd->bd, + DCT_DCT, 1); } else { int64_t dist; unsigned int tmp; TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4); const scan_order *so = get_scan(TX_4X4, tx_type, 0); - const int coeff_ctx = combine_entropy_contexts(*(tempa + idx), - *(templ + idy)); + const int coeff_ctx = + combine_entropy_contexts(*(tempa + idx), *(templ + idy)); #if CONFIG_NEW_QUANT vp10_xform_quant_fp_nuq(x, 0, block, row + idy, col + idx, BLOCK_8X8, TX_4X4, coeff_ctx); @@ -2090,13 +1955,13 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x, *(tempa + idx) = !(p->eobs[block] == 0); *(templ + idy) = !(p->eobs[block] == 0); #else - ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, - TX_4X4, so->scan, so->neighbors, + ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4, + so->scan, so->neighbors, cpi->sf.use_fast_coef_costing); #endif // CONFIG_VAR_TX - vp10_highbd_inv_txfm_add_4x4(BLOCK_OFFSET(pd->dqcoeff, block), - dst, dst_stride, p->eobs[block], - xd->bd, tx_type, 0); + vp10_highbd_inv_txfm_add_4x4(BLOCK_OFFSET(pd->dqcoeff, block), dst, + dst_stride, p->eobs[block], xd->bd, + tx_type, 0); cpi->fn_ptr[BLOCK_4X4].vf(src, src_stride, dst, dst_stride, &tmp); dist = (int64_t)tmp << 4; distortion += dist; @@ -2123,17 +1988,14 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x, num_4x4_blocks_wide * 4 * sizeof(uint16_t)); } } -next_highbd: - {} + next_highbd : {} } - if (best_rd >= rd_thresh) - return best_rd; + if (best_rd >= rd_thresh) return best_rd; for (idy = 0; idy < num_4x4_blocks_high * 4; ++idy) { memcpy(CONVERT_TO_SHORTPTR(dst_init + idy * dst_stride), - best_dst16 + idy * 8, - num_4x4_blocks_wide * 4 * sizeof(uint16_t)); + best_dst16 + idy * 8, num_4x4_blocks_wide * 4 * sizeof(uint16_t)); } return best_rd; @@ -2146,14 +2008,12 @@ next_highbd: int64_t distortion = 0; int rate = bmode_costs[mode]; - if (!(cpi->sf.intra_y_mode_mask[TX_4X4] & (1 << mode))) - continue; + if (!(cpi->sf.intra_y_mode_mask[TX_4X4] & (1 << mode))) continue; // Only do the oblique modes if the best so far is // one of the neighboring directional modes if (cpi->sf.mode_search_skip_flags & FLAG_SKIP_INTRA_DIRMISMATCH) { - if (conditional_skipintra(mode, *best_mode)) - continue; + if (conditional_skipintra(mode, *best_mode)) continue; } memcpy(tempa, ta, num_4x4_blocks_wide * sizeof(ta[0])); @@ -2167,23 +2027,23 @@ next_highbd: int16_t *const src_diff = vp10_raster_block_offset_int16(BLOCK_8X8, block, p->src_diff); xd->mi[0]->bmi[block].as_mode = mode; - vp10_predict_intra_block(xd, 1, 1, TX_4X4, mode, dst, dst_stride, - dst, dst_stride, col + idx, row + idy, 0); + vp10_predict_intra_block(xd, 1, 1, TX_4X4, mode, dst, dst_stride, dst, + dst_stride, col + idx, row + idy, 0); vpx_subtract_block(4, 4, src_diff, 8, src, src_stride, dst, dst_stride); if (xd->lossless[xd->mi[0]->mbmi.segment_id]) { TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4); const scan_order *so = get_scan(TX_4X4, tx_type, 0); #if CONFIG_VAR_TX | CONFIG_NEW_QUANT - const int coeff_ctx = combine_entropy_contexts(*(tempa + idx), - *(templ + idy)); + const int coeff_ctx = + combine_entropy_contexts(*(tempa + idx), *(templ + idy)); #endif // CONFIG_VAR_TX | CONFIG_NEW_QUANT #if CONFIG_NEW_QUANT vp10_xform_quant_fp_nuq(x, 0, block, row + idy, col + idx, BLOCK_8X8, TX_4X4, coeff_ctx); #else - vp10_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8, - TX_4X4, VP10_XFORM_QUANT_B); + vp10_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8, TX_4X4, + VP10_XFORM_QUANT_B); #endif // CONFIG_NEW_QUANT #if CONFIG_VAR_TX ratey += cost_coeffs(x, 0, block, coeff_ctx, TX_4X4, so->scan, @@ -2191,28 +2051,27 @@ next_highbd: *(tempa + idx) = !(p->eobs[block] == 0); *(templ + idy) = !(p->eobs[block] == 0); #else - ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, - TX_4X4, + ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4, so->scan, so->neighbors, cpi->sf.use_fast_coef_costing); #endif if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd) goto next; - vp10_inv_txfm_add_4x4(BLOCK_OFFSET(pd->dqcoeff, block), - dst, dst_stride, p->eobs[block], DCT_DCT, 1); + vp10_inv_txfm_add_4x4(BLOCK_OFFSET(pd->dqcoeff, block), dst, + dst_stride, p->eobs[block], DCT_DCT, 1); } else { int64_t dist; unsigned int tmp; TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4); const scan_order *so = get_scan(TX_4X4, tx_type, 0); - const int coeff_ctx = combine_entropy_contexts(*(tempa + idx), - *(templ + idy)); + const int coeff_ctx = + combine_entropy_contexts(*(tempa + idx), *(templ + idy)); #if CONFIG_NEW_QUANT vp10_xform_quant_fp_nuq(x, 0, block, row + idy, col + idx, BLOCK_8X8, TX_4X4, coeff_ctx); #else - vp10_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8, - TX_4X4, VP10_XFORM_QUANT_FP); + vp10_xform_quant(x, 0, block, row + idy, col + idx, BLOCK_8X8, TX_4X4, + VP10_XFORM_QUANT_FP); #endif // CONFIG_NEW_QUANT vp10_optimize_b(x, 0, block, TX_4X4, coeff_ctx); #if CONFIG_VAR_TX @@ -2221,12 +2080,12 @@ next_highbd: *(tempa + idx) = !(p->eobs[block] == 0); *(templ + idy) = !(p->eobs[block] == 0); #else - ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, - TX_4X4, so->scan, so->neighbors, + ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4, + so->scan, so->neighbors, cpi->sf.use_fast_coef_costing); #endif - vp10_inv_txfm_add_4x4(BLOCK_OFFSET(pd->dqcoeff, block), - dst, dst_stride, p->eobs[block], tx_type, 0); + vp10_inv_txfm_add_4x4(BLOCK_OFFSET(pd->dqcoeff, block), dst, + dst_stride, p->eobs[block], tx_type, 0); cpi->fn_ptr[BLOCK_4X4].vf(src, src_stride, dst, dst_stride, &tmp); dist = (int64_t)tmp << 4; distortion += dist; @@ -2254,12 +2113,10 @@ next_highbd: memcpy(best_dst + idy * 8, dst_init + idy * dst_stride, num_4x4_blocks_wide * 4); } - next: - {} + next : {} } - if (best_rd >= rd_thresh) - return best_rd; + if (best_rd >= rd_thresh) return best_rd; for (idy = 0; idy < num_4x4_blocks_high * 4; ++idy) memcpy(dst_init + idy * dst_stride, best_dst + idy * 8, @@ -2308,16 +2165,14 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(VP10_COMP *cpi, MACROBLOCK *mb, const PREDICTION_MODE A = vp10_above_block_mode(mic, above_mi, i); const PREDICTION_MODE L = vp10_left_block_mode(mic, left_mi, i); - bmode_costs = cpi->y_mode_costs[A][L]; + bmode_costs = cpi->y_mode_costs[A][L]; } - this_rd = rd_pick_intra4x4block(cpi, mb, idy, idx, &best_mode, - bmode_costs, - xd->plane[0].above_context + idx, - xd->plane[0].left_context + idy, - &r, &ry, &d, bsize, best_rd - total_rd); - if (this_rd >= best_rd - total_rd) - return INT64_MAX; + this_rd = rd_pick_intra4x4block( + cpi, mb, idy, idx, &best_mode, bmode_costs, + xd->plane[0].above_context + idx, xd->plane[0].left_context + idy, &r, + &ry, &d, bsize, best_rd - total_rd); + if (this_rd >= best_rd - total_rd) return INT64_MAX; total_rd += this_rd; cost += r; @@ -2330,8 +2185,7 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(VP10_COMP *cpi, MACROBLOCK *mb, for (j = 1; j < num_4x4_blocks_wide; ++j) mic->bmi[i + j].as_mode = best_mode; - if (total_rd >= best_rd) - return INT64_MAX; + if (total_rd >= best_rd) return INT64_MAX; } } mic->mbmi.mode = mic->bmi[3].as_mode; @@ -2343,14 +2197,13 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(VP10_COMP *cpi, MACROBLOCK *mb, if (get_ext_tx_types(TX_4X4, bsize, 0) > 1) { const int eset = get_ext_tx_set(TX_4X4, bsize, 0); rate_tx_type = - cpi->intra_tx_type_costs[eset][TX_4X4] - [mic->mbmi.mode][mic->mbmi.tx_type]; + cpi->intra_tx_type_costs[eset][TX_4X4][mic->mbmi.mode][mic->mbmi + .tx_type]; } #else - rate_tx_type = - cpi->intra_tx_type_costs[TX_4X4] - [intra_mode_to_tx_type_context[mic->mbmi.mode]] - [mic->mbmi.tx_type]; + rate_tx_type = cpi->intra_tx_type_costs + [TX_4X4][intra_mode_to_tx_type_context[mic->mbmi.mode]] + [mic->mbmi.tx_type]; #endif assert(mic->mbmi.tx_size == TX_4X4); cost += rate_tx_type; @@ -2366,11 +2219,11 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(VP10_COMP *cpi, MACROBLOCK *mb, #if CONFIG_EXT_INTRA // Return 1 if an ext intra mode is selected; return 0 otherwise. -static int rd_pick_ext_intra_sby(VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int *rate_tokenonly, - int64_t *distortion, int *skippable, - BLOCK_SIZE bsize, int mode_cost, - int64_t *best_rd, uint16_t skip_mask) { +static int rd_pick_ext_intra_sby(VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int *rate_tokenonly, int64_t *distortion, + int *skippable, BLOCK_SIZE bsize, + int mode_cost, int64_t *best_rd, + uint16_t skip_mask) { MACROBLOCKD *const xd = &x->e_mbd; MODE_INFO *const mic = xd->mi[0]; MB_MODE_INFO *mbmi = &mic->mbmi; @@ -2388,28 +2241,26 @@ static int rd_pick_ext_intra_sby(VP10_COMP *cpi, MACROBLOCK *x, mbmi->palette_mode_info.palette_size[0] = 0; for (mode = 0; mode < FILTER_INTRA_MODES; ++mode) { - if (skip_mask & (1 << mode)) - continue; + if (skip_mask & (1 << mode)) continue; mbmi->ext_intra_mode_info.ext_intra_mode[0] = mode; - super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, - &s, NULL, bsize, *best_rd); - if (this_rate_tokenonly == INT_MAX) - continue; + super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, NULL, + bsize, *best_rd); + if (this_rate_tokenonly == INT_MAX) continue; this_rate = this_rate_tokenonly + - vp10_cost_bit(cpi->common.fc->ext_intra_probs[0], 1) + - write_uniform_cost(FILTER_INTRA_MODES, mode) + mode_cost; + vp10_cost_bit(cpi->common.fc->ext_intra_probs[0], 1) + + write_uniform_cost(FILTER_INTRA_MODES, mode) + mode_cost; this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); if (this_rd < *best_rd) { - *best_rd = this_rd; - best_tx_size = mic->mbmi.tx_size; + *best_rd = this_rd; + best_tx_size = mic->mbmi.tx_size; ext_intra_mode_info = mbmi->ext_intra_mode_info; - best_tx_type = mic->mbmi.tx_type; - *rate = this_rate; - *rate_tokenonly = this_rate_tokenonly; - *distortion = this_distortion; - *skippable = s; + best_tx_type = mic->mbmi.tx_type; + *rate = this_rate; + *rate_tokenonly = this_rate_tokenonly; + *distortion = this_distortion; + *skippable = s; ext_intra_selected_flag = 1; } } @@ -2428,44 +2279,38 @@ static int rd_pick_ext_intra_sby(VP10_COMP *cpi, MACROBLOCK *x, } } -static void pick_intra_angle_routine_sby(VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int *rate_tokenonly, - int64_t *distortion, int *skippable, - int *best_angle_delta, - TX_SIZE *best_tx_size, - TX_TYPE *best_tx_type, - INTRA_FILTER *best_filter, - BLOCK_SIZE bsize, int rate_overhead, - int64_t *best_rd) { +static void pick_intra_angle_routine_sby( + VP10_COMP *cpi, MACROBLOCK *x, int *rate, int *rate_tokenonly, + int64_t *distortion, int *skippable, int *best_angle_delta, + TX_SIZE *best_tx_size, TX_TYPE *best_tx_type, INTRA_FILTER *best_filter, + BLOCK_SIZE bsize, int rate_overhead, int64_t *best_rd) { int this_rate, this_rate_tokenonly, s; int64_t this_distortion, this_rd; MB_MODE_INFO *mbmi = &x->e_mbd.mi[0]->mbmi; - super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, - &s, NULL, bsize, *best_rd); - if (this_rate_tokenonly == INT_MAX) - return; + super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, NULL, + bsize, *best_rd); + if (this_rate_tokenonly == INT_MAX) return; this_rate = this_rate_tokenonly + rate_overhead; this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); if (this_rd < *best_rd) { - *best_rd = this_rd; - *best_angle_delta = mbmi->angle_delta[0]; - *best_tx_size = mbmi->tx_size; - *best_filter = mbmi->intra_filter; - *best_tx_type = mbmi->tx_type; - *rate = this_rate; - *rate_tokenonly = this_rate_tokenonly; - *distortion = this_distortion; - *skippable = s; + *best_rd = this_rd; + *best_angle_delta = mbmi->angle_delta[0]; + *best_tx_size = mbmi->tx_size; + *best_filter = mbmi->intra_filter; + *best_tx_type = mbmi->tx_type; + *rate = this_rate; + *rate_tokenonly = this_rate_tokenonly; + *distortion = this_distortion; + *skippable = s; } } -static int64_t rd_pick_intra_angle_sby(VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int *rate_tokenonly, - int64_t *distortion, int *skippable, - BLOCK_SIZE bsize, int rate_overhead, - int64_t best_rd) { +static int64_t rd_pick_intra_angle_sby(VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int *rate_tokenonly, int64_t *distortion, + int *skippable, BLOCK_SIZE bsize, + int rate_overhead, int64_t best_rd) { MACROBLOCKD *const xd = &x->e_mbd; MODE_INFO *const mic = xd->mi[0]; MB_MODE_INFO *mbmi = &mic->mbmi; @@ -2479,27 +2324,29 @@ static int64_t rd_pick_intra_angle_sby(VP10_COMP *cpi, MACROBLOCK *x, TX_TYPE best_tx_type = mbmi->tx_type; if (ANGLE_FAST_SEARCH) { - int deltas_level1[3] = {0, -2, 2}; + int deltas_level1[3] = { 0, -2, 2 }; int deltas_level2[3][2] = { - {-1, 1}, {-3, -1}, {1, 3}, + { -1, 1 }, { -3, -1 }, { 1, 3 }, }; const int level1 = 3, level2 = 2; int i, j, best_i = -1; for (i = 0; i < level1; ++i) { mic->mbmi.angle_delta[0] = deltas_level1[i]; - p_angle = mode_to_angle_map[mbmi->mode] + - mbmi->angle_delta[0] * ANGLE_STEP; + p_angle = + mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP; for (filter = INTRA_FILTER_LINEAR; filter < INTRA_FILTERS; ++filter) { int64_t tmp_best_rd; if ((FILTER_FAST_SEARCH || !vp10_is_intra_filter_switchable(p_angle)) && filter != INTRA_FILTER_LINEAR) continue; mic->mbmi.intra_filter = filter; - tmp_best_rd = (i == 0 && filter == INTRA_FILTER_LINEAR && - best_rd < INT64_MAX) ? (int64_t)(best_rd * rd_adjust) : best_rd; - super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, - &s, NULL, bsize, tmp_best_rd); + tmp_best_rd = + (i == 0 && filter == INTRA_FILTER_LINEAR && best_rd < INT64_MAX) + ? (int64_t)(best_rd * rd_adjust) + : best_rd; + super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, + NULL, bsize, tmp_best_rd); if (this_rate_tokenonly == INT_MAX) { if (i == 0 && filter == INTRA_FILTER_LINEAR) return best_rd; @@ -2507,22 +2354,22 @@ static int64_t rd_pick_intra_angle_sby(VP10_COMP *cpi, MACROBLOCK *x, continue; } this_rate = this_rate_tokenonly + rate_overhead + - cpi->intra_filter_cost[intra_filter_ctx][filter]; + cpi->intra_filter_cost[intra_filter_ctx][filter]; this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); - if (i == 0 && filter == INTRA_FILTER_LINEAR && - best_rd < INT64_MAX && this_rd > best_rd * rd_adjust) + if (i == 0 && filter == INTRA_FILTER_LINEAR && best_rd < INT64_MAX && + this_rd > best_rd * rd_adjust) return best_rd; if (this_rd < best_rd) { - best_i = i; - best_rd = this_rd; - best_angle_delta = mbmi->angle_delta[0]; - best_tx_size = mbmi->tx_size; - best_filter = mbmi->intra_filter; - best_tx_type = mbmi->tx_type; - *rate = this_rate; - *rate_tokenonly = this_rate_tokenonly; - *distortion = this_distortion; - *skippable = s; + best_i = i; + best_rd = this_rd; + best_angle_delta = mbmi->angle_delta[0]; + best_tx_size = mbmi->tx_size; + best_filter = mbmi->intra_filter; + best_tx_type = mbmi->tx_type; + *rate = this_rate; + *rate_tokenonly = this_rate_tokenonly; + *distortion = this_distortion; + *skippable = s; } } } @@ -2530,60 +2377,56 @@ static int64_t rd_pick_intra_angle_sby(VP10_COMP *cpi, MACROBLOCK *x, if (best_i >= 0) { for (j = 0; j < level2; ++j) { mic->mbmi.angle_delta[0] = deltas_level2[best_i][j]; - p_angle = mode_to_angle_map[mbmi->mode] + - mbmi->angle_delta[0] * ANGLE_STEP; + p_angle = + mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP; for (filter = INTRA_FILTER_LINEAR; filter < INTRA_FILTERS; ++filter) { mic->mbmi.intra_filter = filter; - if ((FILTER_FAST_SEARCH || !vp10_is_intra_filter_switchable(p_angle)) - && filter != INTRA_FILTER_LINEAR) + if ((FILTER_FAST_SEARCH || + !vp10_is_intra_filter_switchable(p_angle)) && + filter != INTRA_FILTER_LINEAR) continue; - pick_intra_angle_routine_sby(cpi, x, rate, rate_tokenonly, - distortion, skippable, - &best_angle_delta, &best_tx_size, - &best_tx_type, &best_filter, bsize, - rate_overhead + - cpi->intra_filter_cost - [intra_filter_ctx][filter], - &best_rd); + pick_intra_angle_routine_sby( + cpi, x, rate, rate_tokenonly, distortion, skippable, + &best_angle_delta, &best_tx_size, &best_tx_type, &best_filter, + bsize, + rate_overhead + cpi->intra_filter_cost[intra_filter_ctx][filter], + &best_rd); } } } } else { for (angle_delta = -MAX_ANGLE_DELTAS; angle_delta <= MAX_ANGLE_DELTAS; - ++angle_delta) { + ++angle_delta) { mbmi->angle_delta[0] = angle_delta; - p_angle = mode_to_angle_map[mbmi->mode] + - mbmi->angle_delta[0] * ANGLE_STEP; + p_angle = + mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP; for (filter = INTRA_FILTER_LINEAR; filter < INTRA_FILTERS; ++filter) { mic->mbmi.intra_filter = filter; if ((FILTER_FAST_SEARCH || !vp10_is_intra_filter_switchable(p_angle)) && filter != INTRA_FILTER_LINEAR) continue; - pick_intra_angle_routine_sby(cpi, x, rate, rate_tokenonly, - distortion, skippable, - &best_angle_delta, &best_tx_size, - &best_tx_type, &best_filter, bsize, - rate_overhead + - cpi->intra_filter_cost - [intra_filter_ctx][filter], - &best_rd); + pick_intra_angle_routine_sby( + cpi, x, rate, rate_tokenonly, distortion, skippable, + &best_angle_delta, &best_tx_size, &best_tx_type, &best_filter, + bsize, + rate_overhead + cpi->intra_filter_cost[intra_filter_ctx][filter], + &best_rd); } } } if (FILTER_FAST_SEARCH && *rate_tokenonly < INT_MAX) { mbmi->angle_delta[0] = best_angle_delta; - p_angle = mode_to_angle_map[mbmi->mode] + - mbmi->angle_delta[0] * ANGLE_STEP; + p_angle = mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP; if (vp10_is_intra_filter_switchable(p_angle)) { for (filter = INTRA_FILTER_LINEAR + 1; filter < INTRA_FILTERS; ++filter) { mic->mbmi.intra_filter = filter; - pick_intra_angle_routine_sby(cpi, x, rate, rate_tokenonly, - distortion, skippable, - &best_angle_delta, &best_tx_size, - &best_tx_type, &best_filter, bsize, - rate_overhead + cpi->intra_filter_cost - [intra_filter_ctx][filter], &best_rd); + pick_intra_angle_routine_sby( + cpi, x, rate, rate_tokenonly, distortion, skippable, + &best_angle_delta, &best_tx_size, &best_tx_type, &best_filter, + bsize, + rate_overhead + cpi->intra_filter_cost[intra_filter_ctx][filter], + &best_rd); } } } @@ -2597,33 +2440,32 @@ static int64_t rd_pick_intra_angle_sby(VP10_COMP *cpi, MACROBLOCK *x, // Indices are sign, integer, and fractional part of the gradient value static const uint8_t gradient_to_angle_bin[2][7][16] = { - { - {6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, }, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, }, - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }, - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }, - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }, - {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }, - {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }, - }, - { - {6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, }, - {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, }, - {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, }, - {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, }, - {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, }, - {3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, }, - {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }, - }, + { + { 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, + { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, + }, + { + { 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4 }, + { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3 }, + { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, + { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, + }, }; static const uint8_t mode_to_angle_bin[INTRA_MODES] = { - 0, 2, 6, 0, 4, 3, 5, 7, 1, 0, + 0, 2, 6, 0, 4, 3, 5, 7, 1, 0, }; -static void angle_estimation(const uint8_t *src, int src_stride, - int rows, int cols, - uint8_t *directional_mode_skip_mask) { +static void angle_estimation(const uint8_t *src, int src_stride, int rows, + int cols, uint8_t *directional_mode_skip_mask) { int i, r, c, index, dx, dy, temp, sn, remd, quot; uint64_t hist[DIRECTIONAL_MODES]; uint64_t hist_sum = 0; @@ -2651,8 +2493,7 @@ static void angle_estimation(const uint8_t *src, int src_stride, src += src_stride; } - for (i = 0; i < DIRECTIONAL_MODES; ++i) - hist_sum += hist[i]; + for (i = 0; i < DIRECTIONAL_MODES; ++i) hist_sum += hist[i]; for (i = 0; i < INTRA_MODES; ++i) { if (i != DC_PRED && i != TM_PRED) { int index = mode_to_angle_bin[i]; @@ -2666,7 +2507,7 @@ static void angle_estimation(const uint8_t *src, int src_stride, score += hist[index + 1]; weight += 1; } - if (score * ANGLE_SKIP_THRESH < hist_sum * weight) + if (score * ANGLE_SKIP_THRESH < hist_sum * weight) directional_mode_skip_mask[i] = 1; } } @@ -2704,8 +2545,7 @@ static void highbd_angle_estimation(const uint8_t *src8, int src_stride, src += src_stride; } - for (i = 0; i < DIRECTIONAL_MODES; ++i) - hist_sum += hist[i]; + for (i = 0; i < DIRECTIONAL_MODES; ++i) hist_sum += hist[i]; for (i = 0; i < INTRA_MODES; ++i) { if (i != DC_PRED && i != TM_PRED) { int index = mode_to_angle_bin[i]; @@ -2719,7 +2559,7 @@ static void highbd_angle_estimation(const uint8_t *src8, int src_stride, score += hist[index + 1]; weight += 1; } - if (score * ANGLE_SKIP_THRESH < hist_sum * weight) + if (score * ANGLE_SKIP_THRESH < hist_sum * weight) directional_mode_skip_mask[i] = 1; } } @@ -2728,10 +2568,9 @@ static void highbd_angle_estimation(const uint8_t *src8, int src_stride, #endif // CONFIG_EXT_INTRA // This function is used only for intra_only frames -static int64_t rd_pick_intra_sby_mode(VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int *rate_tokenonly, - int64_t *distortion, int *skippable, - BLOCK_SIZE bsize, +static int64_t rd_pick_intra_sby_mode(VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int *rate_tokenonly, int64_t *distortion, + int *skippable, BLOCK_SIZE bsize, int64_t best_rd) { uint8_t mode_idx; PREDICTION_MODE mode_selected = DC_PRED; @@ -2755,8 +2594,10 @@ static int64_t rd_pick_intra_sby_mode(VP10_COMP *cpi, MACROBLOCK *x, int *bmode_costs; PALETTE_MODE_INFO palette_mode_info; PALETTE_MODE_INFO *const pmi = &mic->mbmi.palette_mode_info; - uint8_t *best_palette_color_map = cpi->common.allow_screen_content_tools ? - x->palette_buffer->best_palette_color_map : NULL; + uint8_t *best_palette_color_map = + cpi->common.allow_screen_content_tools + ? x->palette_buffer->best_palette_color_map + : NULL; const int rows = 4 * num_4x4_blocks_high_lookup[bsize]; const int cols = 4 * num_4x4_blocks_wide_lookup[bsize]; int palette_ctx = 0; @@ -2797,8 +2638,7 @@ static int64_t rd_pick_intra_sby_mode(VP10_COMP *cpi, MACROBLOCK *x, /* Y Search for intra prediction mode */ for (mode_idx = DC_PRED; mode_idx <= FINAL_MODE_SEARCH; ++mode_idx) { if (mode_idx == FINAL_MODE_SEARCH) { - if (x->use_default_intra_tx_type == 0) - break; + if (x->use_default_intra_tx_type == 0) break; mic->mbmi.mode = mode_selected; x->use_default_intra_tx_type = 0; } else { @@ -2811,24 +2651,22 @@ static int64_t rd_pick_intra_sby_mode(VP10_COMP *cpi, MACROBLOCK *x, continue; if (is_directional_mode) { rate_overhead = bmode_costs[mic->mbmi.mode] + - write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, 0); + write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, 0); this_rate_tokenonly = INT_MAX; - this_rd = - rd_pick_intra_angle_sby(cpi, x, &this_rate, &this_rate_tokenonly, - &this_distortion, &s, bsize, rate_overhead, - best_rd); + this_rd = rd_pick_intra_angle_sby(cpi, x, &this_rate, + &this_rate_tokenonly, &this_distortion, + &s, bsize, rate_overhead, best_rd); } else { mic->mbmi.angle_delta[0] = 0; - super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, - &s, NULL, bsize, best_rd); + super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, NULL, + bsize, best_rd); } #else - super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, - &s, NULL, bsize, best_rd); + super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, NULL, + bsize, best_rd); #endif // CONFIG_EXT_INTRA - if (this_rate_tokenonly == INT_MAX) - continue; + if (this_rate_tokenonly == INT_MAX) continue; this_rate = this_rate_tokenonly + bmode_costs[mic->mbmi.mode]; @@ -2838,23 +2676,22 @@ static int64_t rd_pick_intra_sby_mode(VP10_COMP *cpi, MACROBLOCK *x, // (prediction granularity), so we account for it in the full rate, // not the tokenonly rate. this_rate_tokenonly -= - cpi->tx_size_cost[max_tx_size - TX_8X8][get_tx_size_context(xd)] - [mic->mbmi.tx_size]; + cpi->tx_size_cost[max_tx_size - + TX_8X8][get_tx_size_context(xd)][mic->mbmi.tx_size]; } if (cpi->common.allow_screen_content_tools && mic->mbmi.mode == DC_PRED) - this_rate += - vp10_cost_bit(vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8] - [palette_ctx], 0); + this_rate += vp10_cost_bit( + vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx], 0); #if CONFIG_EXT_INTRA if (mic->mbmi.mode == DC_PRED && ALLOW_FILTER_INTRA_MODES) this_rate += vp10_cost_bit(cpi->common.fc->ext_intra_probs[0], 0); if (is_directional_mode) { int p_angle; - this_rate += write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, - MAX_ANGLE_DELTAS + - mic->mbmi.angle_delta[0]); + this_rate += + write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, + MAX_ANGLE_DELTAS + mic->mbmi.angle_delta[0]); p_angle = mode_to_angle_map[mic->mbmi.mode] + - mic->mbmi.angle_delta[0] * ANGLE_STEP; + mic->mbmi.angle_delta[0] * ANGLE_STEP; if (vp10_is_intra_filter_switchable(p_angle)) this_rate += cpi->intra_filter_cost[intra_filter_ctx][mic->mbmi.intra_filter]; @@ -2868,19 +2705,19 @@ static int64_t rd_pick_intra_sby_mode(VP10_COMP *cpi, MACROBLOCK *x, #endif // CONFIG_EXT_INTRA if (this_rd < best_rd) { - mode_selected = mic->mbmi.mode; - best_rd = this_rd; - best_tx = mic->mbmi.tx_size; + mode_selected = mic->mbmi.mode; + best_rd = this_rd; + best_tx = mic->mbmi.tx_size; #if CONFIG_EXT_INTRA best_angle_delta = mic->mbmi.angle_delta[0]; - best_filter = mic->mbmi.intra_filter; - beat_best_rd = 1; + best_filter = mic->mbmi.intra_filter; + beat_best_rd = 1; #endif // CONFIG_EXT_INTRA - best_tx_type = mic->mbmi.tx_type; - *rate = this_rate; + best_tx_type = mic->mbmi.tx_type; + *rate = this_rate; *rate_tokenonly = this_rate_tokenonly; - *distortion = this_distortion; - *skippable = s; + *distortion = this_distortion; + *skippable = s; } } @@ -2893,12 +2730,12 @@ static int64_t rd_pick_intra_sby_mode(VP10_COMP *cpi, MACROBLOCK *x, #if CONFIG_EXT_INTRA if (ALLOW_FILTER_INTRA_MODES && beat_best_rd) { if (rd_pick_ext_intra_sby(cpi, x, rate, rate_tokenonly, distortion, - skippable, bsize, bmode_costs[DC_PRED], - &best_rd, filter_intra_mode_skip_mask)) { - mode_selected = mic->mbmi.mode; - best_tx = mic->mbmi.tx_size; + skippable, bsize, bmode_costs[DC_PRED], &best_rd, + filter_intra_mode_skip_mask)) { + mode_selected = mic->mbmi.mode; + best_tx = mic->mbmi.tx_size; ext_intra_mode_info = mic->mbmi.ext_intra_mode_info; - best_tx_type = mic->mbmi.tx_type; + best_tx_type = mic->mbmi.tx_type; } } @@ -2932,8 +2769,8 @@ static int64_t rd_pick_intra_sby_mode(VP10_COMP *cpi, MACROBLOCK *x, #if CONFIG_VAR_TX void vp10_tx_block_rd_b(const VP10_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, int blk_row, int blk_col, int plane, int block, - int plane_bsize, int coeff_ctx, - int *rate, int64_t *dist, int64_t *bsse, int *skip) { + int plane_bsize, int coeff_ctx, int *rate, + int64_t *dist, int64_t *bsse, int *skip) { MACROBLOCKD *xd = &x->e_mbd; const struct macroblock_plane *const p = &x->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane]; @@ -2971,36 +2808,36 @@ void vp10_tx_block_rd_b(const VP10_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, max_blocks_wide += xd->mb_to_right_edge >> (5 + pd->subsampling_x); #if CONFIG_NEW_QUANT - vp10_xform_quant_fp_nuq(x, plane, block, blk_row, blk_col, - plane_bsize, tx_size, coeff_ctx); + vp10_xform_quant_fp_nuq(x, plane, block, blk_row, blk_col, plane_bsize, + tx_size, coeff_ctx); #else - vp10_xform_quant(x, plane, block, blk_row, blk_col, - plane_bsize, tx_size, VP10_XFORM_QUANT_FP); + vp10_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size, + VP10_XFORM_QUANT_FP); #endif // CONFIG_NEW_QUANT vp10_optimize_b(x, plane, block, tx_size, coeff_ctx); - // TODO(any): Use dist_block to compute distortion +// TODO(any): Use dist_block to compute distortion #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { rec_buffer = CONVERT_TO_BYTEPTR(rec_buffer16); - vpx_highbd_convolve_copy(dst, pd->dst.stride, rec_buffer, MAX_TX_SIZE, - NULL, 0, NULL, 0, bh, bh, xd->bd); + vpx_highbd_convolve_copy(dst, pd->dst.stride, rec_buffer, MAX_TX_SIZE, NULL, + 0, NULL, 0, bh, bh, xd->bd); } else { rec_buffer = (uint8_t *)rec_buffer16; - vpx_convolve_copy(dst, pd->dst.stride, rec_buffer, MAX_TX_SIZE, - NULL, 0, NULL, 0, bh, bh); + vpx_convolve_copy(dst, pd->dst.stride, rec_buffer, MAX_TX_SIZE, NULL, 0, + NULL, 0, bh, bh); } #else - vpx_convolve_copy(dst, pd->dst.stride, rec_buffer, MAX_TX_SIZE, - NULL, 0, NULL, 0, bh, bh); + vpx_convolve_copy(dst, pd->dst.stride, rec_buffer, MAX_TX_SIZE, NULL, 0, NULL, + 0, bh, bh); #endif // CONFIG_VP9_HIGHBITDEPTH if (blk_row + (bh >> 2) > max_blocks_high || blk_col + (bh >> 2) > max_blocks_wide) { int idx, idy; int blocks_height = VPXMIN(bh >> 2, max_blocks_high - blk_row); - int blocks_width = VPXMIN(bh >> 2, max_blocks_wide - blk_col); + int blocks_width = VPXMIN(bh >> 2, max_blocks_wide - blk_col); tmp = 0; for (idy = 0; idy < blocks_height; idy += 2) { for (idx = 0; idx < blocks_width; idx += 2) { @@ -3031,7 +2868,7 @@ void vp10_tx_block_rd_b(const VP10_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, } else { inv_txfm_add(dqcoeff, rec_buffer, MAX_TX_SIZE, &inv_txfm_param); } -#else // CONFIG_VP9_HIGHBITDEPTH +#else // CONFIG_VP9_HIGHBITDEPTH inv_txfm_add(dqcoeff, rec_buffer, MAX_TX_SIZE, &inv_txfm_param); #endif // CONFIG_VP9_HIGHBITDEPTH @@ -3040,7 +2877,7 @@ void vp10_tx_block_rd_b(const VP10_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, int idx, idy; unsigned int this_dist; int blocks_height = VPXMIN(bh >> 2, max_blocks_high - blk_row); - int blocks_width = VPXMIN(bh >> 2, max_blocks_wide - blk_col); + int blocks_width = VPXMIN(bh >> 2, max_blocks_wide - blk_col); tmp = 0; for (idy = 0; idy < blocks_height; idy += 2) { for (idx = 0; idx < blocks_width; idx += 2) { @@ -3058,27 +2895,27 @@ void vp10_tx_block_rd_b(const VP10_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, } } *dist += tmp * 16; - *rate += cost_coeffs(x, plane, block, coeff_ctx, tx_size, - scan_order->scan, scan_order->neighbors, 0); + *rate += cost_coeffs(x, plane, block, coeff_ctx, tx_size, scan_order->scan, + scan_order->neighbors, 0); *skip &= (p->eobs[block] == 0); } -static void select_tx_block(const VP10_COMP *cpi, MACROBLOCK *x, - int blk_row, int blk_col, int plane, int block, - TX_SIZE tx_size, BLOCK_SIZE plane_bsize, - ENTROPY_CONTEXT *ta, ENTROPY_CONTEXT *tl, - TXFM_CONTEXT *tx_above, TXFM_CONTEXT *tx_left, - int *rate, int64_t *dist, - int64_t *bsse, int *skip, - int64_t ref_best_rd, int *is_cost_valid) { +static void select_tx_block(const VP10_COMP *cpi, MACROBLOCK *x, int blk_row, + int blk_col, int plane, int block, TX_SIZE tx_size, + BLOCK_SIZE plane_bsize, ENTROPY_CONTEXT *ta, + ENTROPY_CONTEXT *tl, TXFM_CONTEXT *tx_above, + TXFM_CONTEXT *tx_left, int *rate, int64_t *dist, + int64_t *bsse, int *skip, int64_t ref_best_rd, + int *is_cost_valid) { MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; struct macroblock_plane *const p = &x->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane]; const int tx_row = blk_row >> (1 - pd->subsampling_y); const int tx_col = blk_col >> (1 - pd->subsampling_x); - TX_SIZE (*const inter_tx_size)[MAX_MIB_SIZE] = - (TX_SIZE (*)[MAX_MIB_SIZE])&mbmi->inter_tx_size[tx_row][tx_col]; + TX_SIZE (*const inter_tx_size) + [MAX_MIB_SIZE] = + (TX_SIZE(*)[MAX_MIB_SIZE]) & mbmi->inter_tx_size[tx_row][tx_col]; const int bw = num_4x4_blocks_wide_lookup[plane_bsize]; int max_blocks_high = num_4x4_blocks_high_lookup[plane_bsize]; int max_blocks_wide = bw; @@ -3123,9 +2960,7 @@ static void select_tx_block(const VP10_COMP *cpi, MACROBLOCK *x, stxa = !!*(const uint64_t *)&pta[0]; stxl = !!*(const uint64_t *)&ptl[0]; break; - default: - assert(0 && "Invalid transform size."); - break; + default: assert(0 && "Invalid transform size."); break; } coeff_ctx = combine_entropy_contexts(stxa, stxl); @@ -3139,8 +2974,7 @@ static void select_tx_block(const VP10_COMP *cpi, MACROBLOCK *x, *bsse = 0; *skip = 1; - if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) - return; + if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; zero_blk_rate = x->token_costs[tx_size][pd->plane_type][1][0][0][coeff_ctx][EOB_TOKEN]; @@ -3151,7 +2985,8 @@ static void select_tx_block(const VP10_COMP *cpi, MACROBLOCK *x, plane_bsize, coeff_ctx, rate, dist, bsse, skip); if ((RDCOST(x->rdmult, x->rddiv, *rate, *dist) >= - RDCOST(x->rdmult, x->rddiv, zero_blk_rate, *bsse) || *skip == 1) && + RDCOST(x->rdmult, x->rddiv, zero_blk_rate, *bsse) || + *skip == 1) && !xd->lossless[mbmi->segment_id]) { *rate = zero_blk_rate; *dist = *bsse; @@ -3188,22 +3023,18 @@ static void select_tx_block(const VP10_COMP *cpi, MACROBLOCK *x, for (i = 0; i < 4 && this_cost_valid; ++i) { int offsetr = (i >> 1) << bsl; int offsetc = (i & 0x01) << bsl; - select_tx_block(cpi, x, blk_row + offsetr, blk_col + offsetc, - plane, block + i * sub_step, tx_size - 1, - plane_bsize, ta, tl, tx_above, tx_left, - &this_rate, &this_dist, - &this_bsse, &this_skip, - ref_best_rd - tmp_rd, &this_cost_valid); + select_tx_block(cpi, x, blk_row + offsetr, blk_col + offsetc, plane, + block + i * sub_step, tx_size - 1, plane_bsize, ta, tl, + tx_above, tx_left, &this_rate, &this_dist, &this_bsse, + &this_skip, ref_best_rd - tmp_rd, &this_cost_valid); sum_rate += this_rate; sum_dist += this_dist; sum_bsse += this_bsse; all_skip &= this_skip; tmp_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); - if (this_rd < tmp_rd) - break; + if (this_rd < tmp_rd) break; } - if (this_cost_valid) - sum_rd = tmp_rd; + if (this_cost_valid) sum_rd = tmp_rd; } if (this_rd < sum_rd) { @@ -3212,36 +3043,32 @@ static void select_tx_block(const VP10_COMP *cpi, MACROBLOCK *x, pta[i] = !(tmp_eob == 0); for (i = 0; i < num_4x4_blocks_high_txsize_lookup[tx_size]; ++i) ptl[i] = !(tmp_eob == 0); - txfm_partition_update(tx_above + (blk_col >> 1), - tx_left + (blk_row >> 1), tx_size); + txfm_partition_update(tx_above + (blk_col >> 1), tx_left + (blk_row >> 1), + tx_size); inter_tx_size[0][0] = tx_size; for (idy = 0; idy < num_4x4_blocks_high_txsize_lookup[tx_size] / 2; ++idy) for (idx = 0; idx < num_4x4_blocks_wide_txsize_lookup[tx_size] / 2; ++idx) inter_tx_size[idy][idx] = tx_size; mbmi->tx_size = tx_size; - if (this_rd == INT64_MAX) - *is_cost_valid = 0; + if (this_rd == INT64_MAX) *is_cost_valid = 0; x->blk_skip[plane][blk_row * bw + blk_col] = *skip; } else { *rate = sum_rate; *dist = sum_dist; *bsse = sum_bsse; *skip = all_skip; - if (sum_rd == INT64_MAX) - *is_cost_valid = 0; + if (sum_rd == INT64_MAX) *is_cost_valid = 0; } } -static void inter_block_yrd(const VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int64_t *distortion, int *skippable, - int64_t *sse, BLOCK_SIZE bsize, - int64_t ref_best_rd) { +static void inter_block_yrd(const VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int64_t *distortion, int *skippable, int64_t *sse, + BLOCK_SIZE bsize, int64_t ref_best_rd) { MACROBLOCKD *const xd = &x->e_mbd; int is_cost_valid = 1; int64_t this_rd = 0; - if (ref_best_rd < 0) - is_cost_valid = 0; + if (ref_best_rd < 0) is_cost_valid = 0; *rate = 0; *distortion = 0; @@ -3275,9 +3102,8 @@ static void inter_block_yrd(const VP10_COMP *cpi, MACROBLOCK *x, for (idy = 0; idy < mi_height; idy += bh) { for (idx = 0; idx < mi_width; idx += bh) { select_tx_block(cpi, x, idy, idx, 0, block, - max_txsize_lookup[plane_bsize], plane_bsize, - ctxa, ctxl, tx_above, tx_left, - &pnrate, &pndist, &pnsse, &pnskip, + max_txsize_lookup[plane_bsize], plane_bsize, ctxa, ctxl, + tx_above, tx_left, &pnrate, &pndist, &pnsse, &pnskip, ref_best_rd - this_rd, &is_cost_valid); *rate += pnrate; *distortion += pndist; @@ -3292,8 +3118,7 @@ static void inter_block_yrd(const VP10_COMP *cpi, MACROBLOCK *x, this_rd = VPXMIN(RDCOST(x->rdmult, x->rddiv, *rate, *distortion), RDCOST(x->rdmult, x->rddiv, 0, *sse)); - if (this_rd > ref_best_rd) - is_cost_valid = 0; + if (this_rd > ref_best_rd) is_cost_valid = 0; if (!is_cost_valid) { // reset cost value @@ -3305,8 +3130,7 @@ static void inter_block_yrd(const VP10_COMP *cpi, MACROBLOCK *x, } static int64_t select_tx_size_fix_type(const VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int64_t *dist, - int *skippable, + int *rate, int64_t *dist, int *skippable, int64_t *sse, BLOCK_SIZE bsize, int64_t ref_best_rd, TX_TYPE tx_type) { const VP10_COMMON *const cm = &cpi->common; @@ -3325,29 +3149,29 @@ static int64_t select_tx_size_fix_type(const VP10_COMP *cpi, MACROBLOCK *x, mbmi->tx_type = tx_type; inter_block_yrd(cpi, x, rate, dist, skippable, sse, bsize, ref_best_rd); - if (*rate == INT_MAX) - return INT64_MAX; + if (*rate == INT_MAX) return INT64_MAX; #if CONFIG_EXT_TX if (get_ext_tx_types(max_tx_size, bsize, is_inter) > 1 && !xd->lossless[xd->mi[0]->mbmi.segment_id]) { if (is_inter) { if (ext_tx_set > 0) - *rate += cpi->inter_tx_type_costs[ext_tx_set] - [max_tx_size][mbmi->tx_type]; + *rate += + cpi->inter_tx_type_costs[ext_tx_set][max_tx_size][mbmi->tx_type]; } else { if (ext_tx_set > 0 && ALLOW_INTRA_EXT_TX) - *rate += cpi->intra_tx_type_costs[ext_tx_set][max_tx_size] - [mbmi->mode][mbmi->tx_type]; + *rate += cpi->intra_tx_type_costs[ext_tx_set][max_tx_size][mbmi->mode] + [mbmi->tx_type]; } } -#else // CONFIG_EXT_TX +#else // CONFIG_EXT_TX if (max_tx_size < TX_32X32 && !xd->lossless[xd->mi[0]->mbmi.segment_id]) { if (is_inter) *rate += cpi->inter_tx_type_costs[max_tx_size][mbmi->tx_type]; else - *rate += cpi->intra_tx_type_costs[max_tx_size] - [intra_mode_to_tx_type_context[mbmi->mode]][mbmi->tx_type]; + *rate += cpi->intra_tx_type_costs + [max_tx_size][intra_mode_to_tx_type_context[mbmi->mode]] + [mbmi->tx_type]; } #endif // CONFIG_EXT_TX @@ -3362,8 +3186,8 @@ static int64_t select_tx_size_fix_type(const VP10_COMP *cpi, MACROBLOCK *x, return rd; } -static void select_tx_type_yrd(const VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int64_t *distortion, int *skippable, +static void select_tx_type_yrd(const VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int64_t *distortion, int *skippable, int64_t *sse, BLOCK_SIZE bsize, int64_t ref_best_rd) { const TX_SIZE max_tx_size = max_txsize_lookup[bsize]; @@ -3391,34 +3215,29 @@ static void select_tx_type_yrd(const VP10_COMP *cpi, MACROBLOCK *x, #endif *distortion = INT64_MAX; - *rate = INT_MAX; - *skippable = 0; - *sse = INT64_MAX; + *rate = INT_MAX; + *skippable = 0; + *sse = INT64_MAX; for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) { int this_rate = 0; int this_skip = 1; int64_t this_dist = 0; - int64_t this_sse = 0; + int64_t this_sse = 0; #if CONFIG_EXT_TX if (is_inter) { - if (!ext_tx_used_inter[ext_tx_set][tx_type]) - continue; + if (!ext_tx_used_inter[ext_tx_set][tx_type]) continue; if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE) { - if (!do_tx_type_search(tx_type, prune)) - continue; + if (!do_tx_type_search(tx_type, prune)) continue; } } else { if (!ALLOW_INTRA_EXT_TX && bsize >= BLOCK_8X8) { - if (tx_type != intra_mode_to_tx_type_context[mbmi->mode]) - continue; + if (tx_type != intra_mode_to_tx_type_context[mbmi->mode]) continue; } - if (!ext_tx_used_intra[ext_tx_set][tx_type]) - continue; + if (!ext_tx_used_intra[ext_tx_set][tx_type]) continue; } -#else // CONFIG_EXT_TX - if (max_tx_size >= TX_32X32 && tx_type != DCT_DCT) - continue; +#else // CONFIG_EXT_TX + if (max_tx_size >= TX_32X32 && tx_type != DCT_DCT) continue; if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE && !do_tx_type_search(tx_type, prune)) continue; @@ -3433,9 +3252,9 @@ static void select_tx_type_yrd(const VP10_COMP *cpi, MACROBLOCK *x, if (rd < best_rd) { best_rd = rd; *distortion = this_dist; - *rate = this_rate; - *skippable = this_skip; - *sse = this_sse; + *rate = this_rate; + *skippable = this_skip; + *sse = this_sse; best_tx_type = mbmi->tx_type; best_tx = mbmi->tx_size; memcpy(best_blk_skip, x->blk_skip[0], sizeof(best_blk_skip[0]) * n4); @@ -3453,11 +3272,11 @@ static void select_tx_type_yrd(const VP10_COMP *cpi, MACROBLOCK *x, memcpy(x->blk_skip[0], best_blk_skip, sizeof(best_blk_skip[0]) * n4); } -static void tx_block_rd(const VP10_COMP *cpi, MACROBLOCK *x, - int blk_row, int blk_col, int plane, int block, - TX_SIZE tx_size, BLOCK_SIZE plane_bsize, - ENTROPY_CONTEXT *above_ctx, ENTROPY_CONTEXT *left_ctx, - int *rate, int64_t *dist, int64_t *bsse, int *skip) { +static void tx_block_rd(const VP10_COMP *cpi, MACROBLOCK *x, int blk_row, + int blk_col, int plane, int block, TX_SIZE tx_size, + BLOCK_SIZE plane_bsize, ENTROPY_CONTEXT *above_ctx, + ENTROPY_CONTEXT *left_ctx, int *rate, int64_t *dist, + int64_t *bsse, int *skip) { MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; struct macroblock_plane *const p = &x->plane[plane]; @@ -3465,9 +3284,10 @@ static void tx_block_rd(const VP10_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize = txsize_to_bsize[tx_size]; const int tx_row = blk_row >> (1 - pd->subsampling_y); const int tx_col = blk_col >> (1 - pd->subsampling_x); - const TX_SIZE plane_tx_size = plane ? - get_uv_tx_size_impl(mbmi->inter_tx_size[tx_row][tx_col], bsize, 0, 0) : - mbmi->inter_tx_size[tx_row][tx_col]; + const TX_SIZE plane_tx_size = + plane ? get_uv_tx_size_impl(mbmi->inter_tx_size[tx_row][tx_col], bsize, 0, + 0) + : mbmi->inter_tx_size[tx_row][tx_col]; int max_blocks_high = num_4x4_blocks_high_lookup[plane_bsize]; int max_blocks_wide = num_4x4_blocks_wide_lookup[plane_bsize]; @@ -3481,16 +3301,14 @@ static void tx_block_rd(const VP10_COMP *cpi, MACROBLOCK *x, if (xd->mb_to_right_edge < 0) max_blocks_wide += xd->mb_to_right_edge >> (5 + pd->subsampling_x); - if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) - return; + if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (tx_size == plane_tx_size) { int coeff_ctx, i; ENTROPY_CONTEXT *ta = above_ctx + blk_col; - ENTROPY_CONTEXT *tl = left_ctx + blk_row; + ENTROPY_CONTEXT *tl = left_ctx + blk_row; switch (tx_size) { - case TX_4X4: - break; + case TX_4X4: break; case TX_8X8: ta[0] = !!*(const uint16_t *)&ta[0]; tl[0] = !!*(const uint16_t *)&tl[0]; @@ -3503,9 +3321,7 @@ static void tx_block_rd(const VP10_COMP *cpi, MACROBLOCK *x, ta[0] = !!*(const uint64_t *)&ta[0]; tl[0] = !!*(const uint64_t *)&tl[0]; break; - default: - assert(0 && "Invalid transform size."); - break; + default: assert(0 && "Invalid transform size."); break; } coeff_ctx = combine_entropy_contexts(ta[0], tl[0]); vp10_tx_block_rd_b(cpi, x, tx_size, blk_row, blk_col, plane, block, @@ -3526,26 +3342,24 @@ static void tx_block_rd(const VP10_COMP *cpi, MACROBLOCK *x, int offsetr = (i >> 1) << bsl; int offsetc = (i & 0x01) << bsl; tx_block_rd(cpi, x, blk_row + offsetr, blk_col + offsetc, plane, - block + i * step, tx_size - 1, plane_bsize, - above_ctx, left_ctx, rate, dist, bsse, skip); + block + i * step, tx_size - 1, plane_bsize, above_ctx, + left_ctx, rate, dist, bsse, skip); } } } // Return value 0: early termination triggered, no valid rd cost available; // 1: rd cost values are valid. -static int inter_block_uvrd(const VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int64_t *distortion, int *skippable, - int64_t *sse, BLOCK_SIZE bsize, - int64_t ref_best_rd) { +static int inter_block_uvrd(const VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int64_t *distortion, int *skippable, int64_t *sse, + BLOCK_SIZE bsize, int64_t ref_best_rd) { MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; int plane; int is_cost_valid = 1; int64_t this_rd; - if (ref_best_rd < 0) - is_cost_valid = 0; + if (ref_best_rd < 0) is_cost_valid = 0; if (is_inter_block(mbmi) && is_cost_valid) { int plane; @@ -3617,10 +3431,9 @@ static int inter_block_uvrd(const VP10_COMP *cpi, MACROBLOCK *x, // Return value 0: early termination triggered, no valid rd cost available; // 1: rd cost values are valid. -static int super_block_uvrd(const VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int64_t *distortion, int *skippable, - int64_t *sse, BLOCK_SIZE bsize, - int64_t ref_best_rd) { +static int super_block_uvrd(const VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int64_t *distortion, int *skippable, int64_t *sse, + BLOCK_SIZE bsize, int64_t ref_best_rd) { MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const TX_SIZE uv_tx_size = get_uv_tx_size(mbmi, &xd->plane[1]); @@ -3629,8 +3442,7 @@ static int super_block_uvrd(const VP10_COMP *cpi, MACROBLOCK *x, int64_t pndist = 0, pnsse = 0; int is_cost_valid = 1; - if (ref_best_rd < 0) - is_cost_valid = 0; + if (ref_best_rd < 0) is_cost_valid = 0; if (is_inter_block(mbmi) && is_cost_valid) { int plane; @@ -3644,11 +3456,8 @@ static int super_block_uvrd(const VP10_COMP *cpi, MACROBLOCK *x, *skippable = 1; for (plane = 1; plane < MAX_MB_PLANE; ++plane) { - txfm_rd_in_plane(x, - cpi, - &pnrate, &pndist, &pnskip, &pnsse, - ref_best_rd, plane, bsize, uv_tx_size, - cpi->sf.use_fast_coef_costing); + txfm_rd_in_plane(x, cpi, &pnrate, &pndist, &pnskip, &pnsse, ref_best_rd, + plane, bsize, uv_tx_size, cpi->sf.use_fast_coef_costing); if (pnrate == INT_MAX) { is_cost_valid = 0; break; @@ -3675,21 +3484,18 @@ static int super_block_uvrd(const VP10_COMP *cpi, MACROBLOCK *x, return is_cost_valid; } -static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, - int dc_mode_cost, - PALETTE_MODE_INFO *palette_mode_info, - uint8_t *best_palette_color_map, - PREDICTION_MODE *mode_selected, - int64_t *best_rd, int *rate, - int *rate_tokenonly, - int64_t *distortion, int *skippable) { +static void rd_pick_palette_intra_sbuv( + VP10_COMP *cpi, MACROBLOCK *x, int dc_mode_cost, + PALETTE_MODE_INFO *palette_mode_info, uint8_t *best_palette_color_map, + PREDICTION_MODE *mode_selected, int64_t *best_rd, int *rate, + int *rate_tokenonly, int64_t *distortion, int *skippable) { MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const BLOCK_SIZE bsize = mbmi->sb_type; - const int rows = (4 * num_4x4_blocks_high_lookup[bsize]) >> - (xd->plane[1].subsampling_y); - const int cols = (4 * num_4x4_blocks_wide_lookup[bsize]) >> - (xd->plane[1].subsampling_x); + const int rows = + (4 * num_4x4_blocks_high_lookup[bsize]) >> (xd->plane[1].subsampling_y); + const int cols = + (4 * num_4x4_blocks_wide_lookup[bsize]) >> (xd->plane[1].subsampling_x); int this_rate, this_rate_tokenonly, s; int64_t this_distortion, this_rd; int colors_u, colors_v, colors; @@ -3697,8 +3503,7 @@ static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, const uint8_t *const src_u = x->plane[1].src.buf; const uint8_t *const src_v = x->plane[2].src.buf; - if (rows * cols > PALETTE_MAX_BLOCK_SIZE) - return; + if (rows * cols > PALETTE_MAX_BLOCK_SIZE) return; #if CONFIG_EXT_INTRA mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = 0; @@ -3760,13 +3565,13 @@ static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, if (cpi->common.use_highbitdepth) { val_u = src_u16[r * src_stride + c]; val_v = src_v16[r * src_stride + c]; - data[(r * cols + c) * 2 ] = val_u; + data[(r * cols + c) * 2] = val_u; data[(r * cols + c) * 2 + 1] = val_v; } else { #endif // CONFIG_VP9_HIGHBITDEPTH val_u = src_u[r * src_stride + c]; val_v = src_v[r * src_stride + c]; - data[(r * cols + c) * 2 ] = val_u; + data[(r * cols + c) * 2] = val_u; data[(r * cols + c) * 2 + 1] = val_v; #if CONFIG_VP9_HIGHBITDEPTH } @@ -3782,12 +3587,11 @@ static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, } } - for (n = colors > PALETTE_MAX_SIZE ? PALETTE_MAX_SIZE : colors; - n >= 2; --n) { + for (n = colors > PALETTE_MAX_SIZE ? PALETTE_MAX_SIZE : colors; n >= 2; + --n) { for (i = 0; i < n; ++i) { centroids[i * 2] = lb_u + (2 * i + 1) * (ub_u - lb_u) / n / 2; - centroids[i * 2 + 1] = - lb_v + (2 * i + 1) * (ub_v - lb_v) / n / 2;; + centroids[i * 2 + 1] = lb_v + (2 * i + 1) * (ub_v - lb_v) / n / 2; } vp10_k_means(data, centroids, color_map, rows * cols, n, 2, max_itr); pmi->palette_size[1] = n; @@ -3795,9 +3599,8 @@ static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, for (j = 0; j < n; ++j) { #if CONFIG_VP9_HIGHBITDEPTH if (cpi->common.use_highbitdepth) - pmi->palette_colors[i * PALETTE_MAX_SIZE + j] = - clip_pixel_highbd((int)lroundf(centroids[j * 2 + i - 1]), - cpi->common.bit_depth); + pmi->palette_colors[i * PALETTE_MAX_SIZE + j] = clip_pixel_highbd( + (int)lroundf(centroids[j * 2 + i - 1]), cpi->common.bit_depth); else #endif // CONFIG_VP9_HIGHBITDEPTH pmi->palette_colors[i * PALETTE_MAX_SIZE + j] = @@ -3805,16 +3608,16 @@ static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, } } - super_block_uvrd(cpi, x, &this_rate_tokenonly, - &this_distortion, &s, &this_sse, bsize, *best_rd); - if (this_rate_tokenonly == INT_MAX) - continue; - this_rate = this_rate_tokenonly + dc_mode_cost + + super_block_uvrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, + &this_sse, bsize, *best_rd); + if (this_rate_tokenonly == INT_MAX) continue; + this_rate = + this_rate_tokenonly + dc_mode_cost + 2 * cpi->common.bit_depth * n * vp10_cost_bit(128, 0) + cpi->palette_uv_size_cost[bsize - BLOCK_8X8][n - 2] + write_uniform_cost(n, color_map[0]) + - vp10_cost_bit(vp10_default_palette_uv_mode_prob - [pmi->palette_size[0] > 0], 1); + vp10_cost_bit( + vp10_default_palette_uv_mode_prob[pmi->palette_size[0] > 0], 1); for (i = 0; i < rows; ++i) { for (j = (i == 0 ? 1 : 0); j < cols; ++j) { @@ -3826,8 +3629,7 @@ static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, break; } assert(color_idx >= 0 && color_idx < n); - this_rate += - cpi->palette_uv_color_cost[n - 2][color_ctx][color_idx]; + this_rate += cpi->palette_uv_color_cost[n - 2][color_ctx][color_idx]; } } @@ -3849,10 +3651,10 @@ static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, #if CONFIG_EXT_INTRA // Return 1 if an ext intra mode is selected; return 0 otherwise. -static int rd_pick_ext_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int *rate_tokenonly, - int64_t *distortion, int *skippable, - BLOCK_SIZE bsize, int64_t *best_rd) { +static int rd_pick_ext_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int *rate_tokenonly, int64_t *distortion, + int *skippable, BLOCK_SIZE bsize, + int64_t *best_rd) { MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; int ext_intra_selected_flag = 0; @@ -3868,27 +3670,26 @@ static int rd_pick_ext_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, for (mode = 0; mode < FILTER_INTRA_MODES; ++mode) { mbmi->ext_intra_mode_info.ext_intra_mode[1] = mode; - if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, - &this_distortion, &s, &this_sse, bsize, *best_rd)) + if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, + &this_sse, bsize, *best_rd)) continue; this_rate = this_rate_tokenonly + - vp10_cost_bit(cpi->common.fc->ext_intra_probs[1], 1) + - cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode] + - write_uniform_cost(FILTER_INTRA_MODES, mode); + vp10_cost_bit(cpi->common.fc->ext_intra_probs[1], 1) + + cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode] + + write_uniform_cost(FILTER_INTRA_MODES, mode); this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); if (this_rd < *best_rd) { - *best_rd = this_rd; - *rate = this_rate; + *best_rd = this_rd; + *rate = this_rate; *rate_tokenonly = this_rate_tokenonly; - *distortion = this_distortion; - *skippable = s; + *distortion = this_distortion; + *skippable = s; ext_intra_mode_info = mbmi->ext_intra_mode_info; ext_intra_selected_flag = 1; } } - if (ext_intra_selected_flag) { mbmi->uv_mode = DC_PRED; mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = @@ -3911,27 +3712,26 @@ static void pick_intra_angle_routine_sbuv(VP10_COMP *cpi, MACROBLOCK *x, int this_rate_tokenonly, this_rate, s; int64_t this_distortion, this_sse, this_rd; - if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, - &this_distortion, &s, &this_sse, bsize, *best_rd)) + if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, + &this_sse, bsize, *best_rd)) return; this_rate = this_rate_tokenonly + rate_overhead; this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); if (this_rd < *best_rd) { - *best_rd = this_rd; + *best_rd = this_rd; *best_angle_delta = mbmi->angle_delta[1]; - *rate = this_rate; - *rate_tokenonly = this_rate_tokenonly; - *distortion = this_distortion; - *skippable = s; + *rate = this_rate; + *rate_tokenonly = this_rate_tokenonly; + *distortion = this_distortion; + *skippable = s; } } -static int rd_pick_intra_angle_sbuv(VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int *rate_tokenonly, - int64_t *distortion, int *skippable, - BLOCK_SIZE bsize, int rate_overhead, - int64_t best_rd) { +static int rd_pick_intra_angle_sbuv(VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int *rate_tokenonly, int64_t *distortion, + int *skippable, BLOCK_SIZE bsize, + int rate_overhead, int64_t best_rd) { MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; int this_rate_tokenonly, this_rate, s; @@ -3941,9 +3741,9 @@ static int rd_pick_intra_angle_sbuv(VP10_COMP *cpi, MACROBLOCK *x, *rate_tokenonly = INT_MAX; if (ANGLE_FAST_SEARCH) { - int deltas_level1[3] = {0, -2, 2}; + int deltas_level1[3] = { 0, -2, 2 }; int deltas_level2[3][2] = { - {-1, 1}, {-3, -1}, {1, 3}, + { -1, 1 }, { -3, -1 }, { 1, 3 }, }; const int level1 = 3, level2 = 2; int i, j, best_i = -1; @@ -3951,10 +3751,11 @@ static int rd_pick_intra_angle_sbuv(VP10_COMP *cpi, MACROBLOCK *x, for (i = 0; i < level1; ++i) { int64_t tmp_best_rd; mbmi->angle_delta[1] = deltas_level1[i]; - tmp_best_rd = (i == 0 && best_rd < INT64_MAX) ? - (int64_t)(best_rd * rd_adjust) : best_rd; - if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, &this_distortion, - &s, &this_sse, bsize, tmp_best_rd)) { + tmp_best_rd = (i == 0 && best_rd < INT64_MAX) + ? (int64_t)(best_rd * rd_adjust) + : best_rd; + if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, + &this_sse, bsize, tmp_best_rd)) { if (i == 0) break; else @@ -3962,35 +3763,32 @@ static int rd_pick_intra_angle_sbuv(VP10_COMP *cpi, MACROBLOCK *x, } this_rate = this_rate_tokenonly + rate_overhead; this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); - if (i == 0 && best_rd < INT64_MAX && this_rd > best_rd * rd_adjust) - break; + if (i == 0 && best_rd < INT64_MAX && this_rd > best_rd * rd_adjust) break; if (this_rd < best_rd) { - best_i = i; - best_rd = this_rd; + best_i = i; + best_rd = this_rd; best_angle_delta = mbmi->angle_delta[1]; - *rate = this_rate; - *rate_tokenonly = this_rate_tokenonly; - *distortion = this_distortion; - *skippable = s; + *rate = this_rate; + *rate_tokenonly = this_rate_tokenonly; + *distortion = this_distortion; + *skippable = s; } } if (best_i >= 0) { for (j = 0; j < level2; ++j) { mbmi->angle_delta[1] = deltas_level2[best_i][j]; - pick_intra_angle_routine_sbuv(cpi, x, rate, rate_tokenonly, - distortion, skippable, - &best_angle_delta, bsize, + pick_intra_angle_routine_sbuv(cpi, x, rate, rate_tokenonly, distortion, + skippable, &best_angle_delta, bsize, rate_overhead, &best_rd); } } } else { for (angle_delta = -MAX_ANGLE_DELTAS; angle_delta <= MAX_ANGLE_DELTAS; - ++angle_delta) { + ++angle_delta) { mbmi->angle_delta[1] = angle_delta; - pick_intra_angle_routine_sbuv(cpi, x, rate, rate_tokenonly, - distortion, skippable, - &best_angle_delta, bsize, + pick_intra_angle_routine_sbuv(cpi, x, rate, rate_tokenonly, distortion, + skippable, &best_angle_delta, bsize, rate_overhead, &best_rd); } } @@ -4000,10 +3798,10 @@ static int rd_pick_intra_angle_sbuv(VP10_COMP *cpi, MACROBLOCK *x, } #endif // CONFIG_EXT_INTRA -static int64_t rd_pick_intra_sbuv_mode(VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int *rate_tokenonly, - int64_t *distortion, int *skippable, - BLOCK_SIZE bsize, TX_SIZE max_tx_size) { +static int64_t rd_pick_intra_sbuv_mode(VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int *rate_tokenonly, int64_t *distortion, + int *skippable, BLOCK_SIZE bsize, + TX_SIZE max_tx_size) { MACROBLOCKD *xd = &x->e_mbd; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; PREDICTION_MODE mode; @@ -4011,10 +3809,10 @@ static int64_t rd_pick_intra_sbuv_mode(VP10_COMP *cpi, MACROBLOCK *x, int64_t best_rd = INT64_MAX, this_rd; int this_rate_tokenonly, this_rate, s; int64_t this_distortion, this_sse; - const int rows = (4 * num_4x4_blocks_high_lookup[bsize]) >> - (xd->plane[1].subsampling_y); - const int cols = (4 * num_4x4_blocks_wide_lookup[bsize]) >> - (xd->plane[1].subsampling_x); + const int rows = + (4 * num_4x4_blocks_high_lookup[bsize]) >> (xd->plane[1].subsampling_y); + const int cols = + (4 * num_4x4_blocks_wide_lookup[bsize]) >> (xd->plane[1].subsampling_x); PALETTE_MODE_INFO palette_mode_info; PALETTE_MODE_INFO *const pmi = &xd->mi[0]->mbmi.palette_mode_info; uint8_t *best_palette_color_map = NULL; @@ -4028,75 +3826,70 @@ static int64_t rd_pick_intra_sbuv_mode(VP10_COMP *cpi, MACROBLOCK *x, palette_mode_info.palette_size[1] = 0; pmi->palette_size[1] = 0; for (mode = DC_PRED; mode <= TM_PRED; ++mode) { - if (!(cpi->sf.intra_uv_mode_mask[max_tx_size] & (1 << mode))) - continue; + if (!(cpi->sf.intra_uv_mode_mask[max_tx_size] & (1 << mode))) continue; mbmi->uv_mode = mode; #if CONFIG_EXT_INTRA is_directional_mode = (mode != DC_PRED && mode != TM_PRED); rate_overhead = cpi->intra_uv_mode_cost[mbmi->mode][mode] + - write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, 0); + write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, 0); mbmi->angle_delta[1] = 0; if (mbmi->sb_type >= BLOCK_8X8 && is_directional_mode) { - if (!rd_pick_intra_angle_sbuv(cpi, x, &this_rate, - &this_rate_tokenonly, &this_distortion, &s, - bsize, rate_overhead, best_rd)) + if (!rd_pick_intra_angle_sbuv(cpi, x, &this_rate, &this_rate_tokenonly, + &this_distortion, &s, bsize, rate_overhead, + best_rd)) continue; } else { - if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, - &this_distortion, &s, &this_sse, bsize, best_rd)) + if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, + &this_sse, bsize, best_rd)) continue; } - this_rate = this_rate_tokenonly + - cpi->intra_uv_mode_cost[mbmi->mode][mode]; + this_rate = this_rate_tokenonly + cpi->intra_uv_mode_cost[mbmi->mode][mode]; if (mbmi->sb_type >= BLOCK_8X8 && is_directional_mode) this_rate += write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, - MAX_ANGLE_DELTAS + - mbmi->angle_delta[1]); + MAX_ANGLE_DELTAS + mbmi->angle_delta[1]); if (mbmi->sb_type >= BLOCK_8X8 && mode == DC_PRED && ALLOW_FILTER_INTRA_MODES) this_rate += vp10_cost_bit(cpi->common.fc->ext_intra_probs[1], 0); #else - if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, - &this_distortion, &s, &this_sse, bsize, best_rd)) + if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, + &this_sse, bsize, best_rd)) continue; - this_rate = this_rate_tokenonly + - cpi->intra_uv_mode_cost[mbmi->mode][mode]; + this_rate = this_rate_tokenonly + cpi->intra_uv_mode_cost[mbmi->mode][mode]; #endif // CONFIG_EXT_INTRA if (cpi->common.allow_screen_content_tools && mbmi->sb_type >= BLOCK_8X8 && mode == DC_PRED) - this_rate += vp10_cost_bit(vp10_default_palette_uv_mode_prob - [pmi->palette_size[0] > 0], 0); + this_rate += vp10_cost_bit( + vp10_default_palette_uv_mode_prob[pmi->palette_size[0] > 0], 0); this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); if (this_rd < best_rd) { - mode_selected = mode; + mode_selected = mode; #if CONFIG_EXT_INTRA best_angle_delta = mbmi->angle_delta[1]; #endif // CONFIG_EXT_INTRA - best_rd = this_rd; - *rate = this_rate; + best_rd = this_rd; + *rate = this_rate; *rate_tokenonly = this_rate_tokenonly; - *distortion = this_distortion; - *skippable = s; + *distortion = this_distortion; + *skippable = s; } } if (cpi->common.allow_screen_content_tools && mbmi->sb_type >= BLOCK_8X8) { best_palette_color_map = x->palette_buffer->best_palette_color_map; - rd_pick_palette_intra_sbuv(cpi, x, - cpi->intra_uv_mode_cost[mbmi->mode][DC_PRED], - &palette_mode_info, best_palette_color_map, - &mode_selected, &best_rd, rate, rate_tokenonly, - distortion, skippable); + rd_pick_palette_intra_sbuv( + cpi, x, cpi->intra_uv_mode_cost[mbmi->mode][DC_PRED], + &palette_mode_info, best_palette_color_map, &mode_selected, &best_rd, + rate, rate_tokenonly, distortion, skippable); } #if CONFIG_EXT_INTRA if (mbmi->sb_type >= BLOCK_8X8 && ALLOW_FILTER_INTRA_MODES) { if (rd_pick_ext_intra_sbuv(cpi, x, rate, rate_tokenonly, distortion, skippable, bsize, &best_rd)) { - mode_selected = mbmi->uv_mode; + mode_selected = mbmi->uv_mode; ext_intra_mode_info = mbmi->ext_intra_mode_info; } } @@ -4123,38 +3916,36 @@ static int64_t rd_pick_intra_sbuv_mode(VP10_COMP *cpi, MACROBLOCK *x, return best_rd; } -static int64_t rd_sbuv_dcpred(const VP10_COMP *cpi, MACROBLOCK *x, - int *rate, int *rate_tokenonly, - int64_t *distortion, int *skippable, - BLOCK_SIZE bsize) { +static int64_t rd_sbuv_dcpred(const VP10_COMP *cpi, MACROBLOCK *x, int *rate, + int *rate_tokenonly, int64_t *distortion, + int *skippable, BLOCK_SIZE bsize) { int64_t unused; x->e_mbd.mi[0]->mbmi.uv_mode = DC_PRED; - super_block_uvrd(cpi, x, rate_tokenonly, distortion, - skippable, &unused, bsize, INT64_MAX); + super_block_uvrd(cpi, x, rate_tokenonly, distortion, skippable, &unused, + bsize, INT64_MAX); *rate = *rate_tokenonly + - cpi->intra_uv_mode_cost[x->e_mbd.mi[0]->mbmi.mode][DC_PRED]; + cpi->intra_uv_mode_cost[x->e_mbd.mi[0]->mbmi.mode][DC_PRED]; return RDCOST(x->rdmult, x->rddiv, *rate, *distortion); } static void choose_intra_uv_mode(VP10_COMP *cpi, MACROBLOCK *const x, - PICK_MODE_CONTEXT *ctx, - BLOCK_SIZE bsize, TX_SIZE max_tx_size, - int *rate_uv, int *rate_uv_tokenonly, - int64_t *dist_uv, int *skip_uv, - PREDICTION_MODE *mode_uv) { + PICK_MODE_CONTEXT *ctx, BLOCK_SIZE bsize, + TX_SIZE max_tx_size, int *rate_uv, + int *rate_uv_tokenonly, int64_t *dist_uv, + int *skip_uv, PREDICTION_MODE *mode_uv) { // Use an estimated rd for uv_intra based on DC_PRED if the // appropriate speed flag is set. if (cpi->sf.use_uv_intra_rd_estimate) { - rd_sbuv_dcpred(cpi, x, rate_uv, rate_uv_tokenonly, dist_uv, - skip_uv, bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize); - // Else do a proper rd search for each possible transform size that may - // be considered in the main rd loop. + rd_sbuv_dcpred(cpi, x, rate_uv, rate_uv_tokenonly, dist_uv, skip_uv, + bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize); + // Else do a proper rd search for each possible transform size that may + // be considered in the main rd loop. } else { (void)ctx; - rd_pick_intra_sbuv_mode(cpi, x, - rate_uv, rate_uv_tokenonly, dist_uv, skip_uv, - bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize, max_tx_size); + rd_pick_intra_sbuv_mode(cpi, x, rate_uv, rate_uv_tokenonly, dist_uv, + skip_uv, bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize, + max_tx_size); } *mode_uv = x->e_mbd.mi[0]->mbmi.uv_mode; } @@ -4167,8 +3958,8 @@ static int cost_mv_ref(const VP10_COMP *cpi, PREDICTION_MODE mode, #if CONFIG_REF_MV int mode_cost = 0; #if CONFIG_EXT_INTER - int16_t mode_ctx = is_compound ? mode_context : - (mode_context & NEWMV_CTX_MASK); + int16_t mode_ctx = + is_compound ? mode_context : (mode_context & NEWMV_CTX_MASK); #else int16_t mode_ctx = mode_context & NEWMV_CTX_MASK; #endif // CONFIG_EXT_INTER @@ -4178,44 +3969,40 @@ static int cost_mv_ref(const VP10_COMP *cpi, PREDICTION_MODE mode, #if CONFIG_EXT_INTER if (is_compound) { - return cpi->inter_compound_mode_cost[mode_context] - [INTER_COMPOUND_OFFSET(mode)]; + return cpi + ->inter_compound_mode_cost[mode_context][INTER_COMPOUND_OFFSET(mode)]; } else { if (mode == NEWMV || mode == NEWFROMNEARMV) { #else if (mode == NEWMV) { #endif // CONFIG_EXT_INTER - mode_cost = cpi->newmv_mode_cost[mode_ctx][0]; + mode_cost = cpi->newmv_mode_cost[mode_ctx][0]; #if CONFIG_EXT_INTER - if (!is_compound) - mode_cost += cpi->new2mv_mode_cost[mode == NEWFROMNEARMV]; + if (!is_compound) + mode_cost += cpi->new2mv_mode_cost[mode == NEWFROMNEARMV]; #endif // CONFIG_EXT_INTER - return mode_cost; - } else { - mode_cost = cpi->newmv_mode_cost[mode_ctx][1]; - mode_ctx = (mode_context >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK; - - if (is_all_zero_mv) - return mode_cost; - - if (mode == ZEROMV) { - mode_cost += cpi->zeromv_mode_cost[mode_ctx][0]; return mode_cost; } else { - mode_cost += cpi->zeromv_mode_cost[mode_ctx][1]; - mode_ctx = (mode_context >> REFMV_OFFSET) & REFMV_CTX_MASK; + mode_cost = cpi->newmv_mode_cost[mode_ctx][1]; + mode_ctx = (mode_context >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK; - if (mode_context & (1 << SKIP_NEARESTMV_OFFSET)) - mode_ctx = 6; - if (mode_context & (1 << SKIP_NEARMV_OFFSET)) - mode_ctx = 7; - if (mode_context & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) - mode_ctx = 8; + if (is_all_zero_mv) return mode_cost; - mode_cost += cpi->refmv_mode_cost[mode_ctx][mode != NEARESTMV]; - return mode_cost; + if (mode == ZEROMV) { + mode_cost += cpi->zeromv_mode_cost[mode_ctx][0]; + return mode_cost; + } else { + mode_cost += cpi->zeromv_mode_cost[mode_ctx][1]; + mode_ctx = (mode_context >> REFMV_OFFSET) & REFMV_CTX_MASK; + + if (mode_context & (1 << SKIP_NEARESTMV_OFFSET)) mode_ctx = 6; + if (mode_context & (1 << SKIP_NEARMV_OFFSET)) mode_ctx = 7; + if (mode_context & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) mode_ctx = 8; + + mode_cost += cpi->refmv_mode_cost[mode_ctx][mode != NEARESTMV]; + return mode_cost; + } } - } #if CONFIG_EXT_INTER } #endif // CONFIG_EXT_INTER @@ -4223,11 +4010,11 @@ static int cost_mv_ref(const VP10_COMP *cpi, PREDICTION_MODE mode, assert(is_inter_mode(mode)); #if CONFIG_EXT_INTER if (is_inter_compound_mode(mode)) { - return cpi->inter_compound_mode_cost[mode_context] - [INTER_COMPOUND_OFFSET(mode)]; + return cpi + ->inter_compound_mode_cost[mode_context][INTER_COMPOUND_OFFSET(mode)]; } else { #endif // CONFIG_EXT_INTER - return cpi->inter_mode_cost[mode_context][INTER_OFFSET(mode)]; + return cpi->inter_mode_cost[mode_context][INTER_OFFSET(mode)]; #if CONFIG_EXT_INTER } #endif // CONFIG_EXT_INTER @@ -4235,9 +4022,8 @@ static int cost_mv_ref(const VP10_COMP *cpi, PREDICTION_MODE mode, } static int set_and_cost_bmi_mvs( - VP10_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd, int i, - PREDICTION_MODE mode, int_mv this_mv[2], - int_mv frame_mv[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME], + VP10_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd, int i, PREDICTION_MODE mode, + int_mv this_mv[2], int_mv frame_mv[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME], int_mv seg_mvs[TOTAL_REFS_PER_FRAME], #if CONFIG_EXT_INTER int_mv compound_seg_newmvs[2], @@ -4269,10 +4055,9 @@ static int set_and_cost_bmi_mvs( for (idx = 0; idx < 1 + is_compound; ++idx) { this_mv[idx] = seg_mvs[mbmi->ref_frame[idx]]; vp10_set_mvcost(x, mbmi->ref_frame[idx]); - thismvcost += vp10_mv_bit_cost(&this_mv[idx].as_mv, - &best_ref_mv[idx]->as_mv, - x->nmvjointcost, x->mvcost, - MV_COST_WEIGHT_SUB); + thismvcost += + vp10_mv_bit_cost(&this_mv[idx].as_mv, &best_ref_mv[idx]->as_mv, + x->nmvjointcost, x->mvcost, MV_COST_WEIGHT_SUB); } (void)mvjcost; (void)mvcost; @@ -4282,9 +4067,9 @@ static int set_and_cost_bmi_mvs( #if !CONFIG_EXT_INTER if (is_compound) { this_mv[1].as_int = seg_mvs[mbmi->ref_frame[1]].as_int; - thismvcost += vp10_mv_bit_cost(&this_mv[1].as_mv, - &best_ref_mv[1]->as_mv, - mvjcost, mvcost, MV_COST_WEIGHT_SUB); + thismvcost += + vp10_mv_bit_cost(&this_mv[1].as_mv, &best_ref_mv[1]->as_mv, mvjcost, + mvcost, MV_COST_WEIGHT_SUB); } #endif // !CONFIG_EXT_INTER #endif @@ -4297,8 +4082,7 @@ static int set_and_cost_bmi_mvs( break; case ZEROMV: this_mv[0].as_int = 0; - if (is_compound) - this_mv[1].as_int = 0; + if (is_compound) this_mv[1].as_int = 0; break; #if CONFIG_EXT_INTER case NEW_NEWMV: @@ -4316,11 +4100,9 @@ static int set_and_cost_bmi_mvs( if (!cpi->common.allow_high_precision_mv || !vp10_use_mv_hp(&best_ref_mv[1]->as_mv)) lower_mv_precision(&this_mv[1].as_mv, 0); - thismvcost += vp10_mv_bit_cost(&this_mv[0].as_mv, - &best_ref_mv[0]->as_mv, + thismvcost += vp10_mv_bit_cost(&this_mv[0].as_mv, &best_ref_mv[0]->as_mv, mvjcost, mvcost, MV_COST_WEIGHT_SUB); - thismvcost += vp10_mv_bit_cost(&this_mv[1].as_mv, - &best_ref_mv[1]->as_mv, + thismvcost += vp10_mv_bit_cost(&this_mv[1].as_mv, &best_ref_mv[1]->as_mv, mvjcost, mvcost, MV_COST_WEIGHT_SUB); break; case NEW_NEARMV: @@ -4349,31 +4131,27 @@ static int set_and_cost_bmi_mvs( case NEAR_NEARMV: this_mv[0].as_int = frame_mv[mode][mbmi->ref_frame[0]].as_int; this_mv[1].as_int = frame_mv[mode][mbmi->ref_frame[1]].as_int; - break; + break; case ZERO_ZEROMV: this_mv[0].as_int = 0; this_mv[1].as_int = 0; break; #endif // CONFIG_EXT_INTER - default: - break; + default: break; } mic->bmi[i].as_mv[0].as_int = this_mv[0].as_int; - if (is_compound) - mic->bmi[i].as_mv[1].as_int = this_mv[1].as_int; + if (is_compound) mic->bmi[i].as_mv[1].as_int = this_mv[1].as_int; mic->bmi[i].as_mode = mode; #if CONFIG_REF_MV if (mode == NEWMV) { mic->bmi[i].pred_mv_s8[0].as_int = best_ref_mv[0]->as_int; - if (is_compound) - mic->bmi[i].pred_mv_s8[1].as_int = best_ref_mv[1]->as_int; + if (is_compound) mic->bmi[i].pred_mv_s8[1].as_int = best_ref_mv[1]->as_int; } else { mic->bmi[i].pred_mv_s8[0].as_int = this_mv[0].as_int; - if (is_compound) - mic->bmi[i].pred_mv_s8[1].as_int = this_mv[1].as_int; + if (is_compound) mic->bmi[i].pred_mv_s8[1].as_int = this_mv[1].as_int; } #endif @@ -4387,8 +4165,8 @@ static int set_and_cost_bmi_mvs( mode_ctx = mbmi_ext->compound_mode_context[mbmi->ref_frame[0]]; else #endif // CONFIG_EXT_INTER - mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context, - mbmi->ref_frame, mbmi->sb_type, i); + mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context, + mbmi->ref_frame, mbmi->sb_type, i); #endif #if CONFIG_REF_MV && CONFIG_EXT_INTER return cost_mv_ref(cpi, mode, is_compound, mode_ctx) + thismvcost; @@ -4397,16 +4175,11 @@ static int set_and_cost_bmi_mvs( #endif // CONFIG_REF_MV && CONFIG_EXT_INTER } -static int64_t encode_inter_mb_segment(VP10_COMP *cpi, - MACROBLOCK *x, - int64_t best_yrd, - int i, - int *labelyrate, +static int64_t encode_inter_mb_segment(VP10_COMP *cpi, MACROBLOCK *x, + int64_t best_yrd, int i, int *labelyrate, int64_t *distortion, int64_t *sse, - ENTROPY_CONTEXT *ta, - ENTROPY_CONTEXT *tl, - int ir, int ic, - int mi_row, int mi_col) { + ENTROPY_CONTEXT *ta, ENTROPY_CONTEXT *tl, + int ir, int ic, int mi_row, int mi_col) { int k; MACROBLOCKD *xd = &x->e_mbd; struct macroblockd_plane *const pd = &xd->plane[0]; @@ -4418,8 +4191,8 @@ static int64_t encode_inter_mb_segment(VP10_COMP *cpi, int idx, idy; const uint8_t *const src = &p->src.buf[vp10_raster_block_offset(BLOCK_8X8, i, p->src.stride)]; - uint8_t *const dst = &pd->dst.buf[vp10_raster_block_offset(BLOCK_8X8, i, - pd->dst.stride)]; + uint8_t *const dst = + &pd->dst.buf[vp10_raster_block_offset(BLOCK_8X8, i, pd->dst.stride)]; int64_t thisdistortion = 0, thissse = 0; int thisrate = 0; TX_SIZE tx_size = mi->mbmi.tx_size; @@ -4443,12 +4216,13 @@ static int64_t encode_inter_mb_segment(VP10_COMP *cpi, #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { vpx_highbd_subtract_block( - height, width, vp10_raster_block_offset_int16(BLOCK_8X8, i, p->src_diff), - 8, src, p->src.stride, dst, pd->dst.stride, xd->bd); + height, width, + vp10_raster_block_offset_int16(BLOCK_8X8, i, p->src_diff), 8, src, + p->src.stride, dst, pd->dst.stride, xd->bd); } else { - vpx_subtract_block( - height, width, vp10_raster_block_offset_int16(BLOCK_8X8, i, p->src_diff), - 8, src, p->src.stride, dst, pd->dst.stride); + vpx_subtract_block(height, width, vp10_raster_block_offset_int16( + BLOCK_8X8, i, p->src_diff), + 8, src, p->src.stride, dst, pd->dst.stride); } #else vpx_subtract_block(height, width, @@ -4467,8 +4241,7 @@ static int64_t encode_inter_mb_segment(VP10_COMP *cpi, block = k; else block = (i ? 2 : 0); - coeff_ctx = combine_entropy_contexts(*(ta + (k & 1)), - *(tl + (k >> 1))); + coeff_ctx = combine_entropy_contexts(*(ta + (k & 1)), *(tl + (k >> 1))); #if CONFIG_NEW_QUANT vp10_xform_quant_fp_nuq(x, 0, block, idy + (i >> 1), idx + (i & 0x01), BLOCK_8X8, tx_size, coeff_ctx); @@ -4483,17 +4256,14 @@ static int64_t encode_inter_mb_segment(VP10_COMP *cpi, thisdistortion += dist; thissse += ssz; #if CONFIG_VAR_TX - thisrate += cost_coeffs(x, 0, block, coeff_ctx, - tx_size, - so->scan, so->neighbors, - cpi->sf.use_fast_coef_costing); + thisrate += cost_coeffs(x, 0, block, coeff_ctx, tx_size, so->scan, + so->neighbors, cpi->sf.use_fast_coef_costing); *(ta + (k & 1)) = !(p->eobs[block] == 0); *(tl + (k >> 1)) = !(p->eobs[block] == 0); #else - thisrate += cost_coeffs(x, 0, block, ta + (k & 1), tl + (k >> 1), - tx_size, - so->scan, so->neighbors, - cpi->sf.use_fast_coef_costing); + thisrate += + cost_coeffs(x, 0, block, ta + (k & 1), tl + (k >> 1), tx_size, + so->scan, so->neighbors, cpi->sf.use_fast_coef_costing); #if CONFIG_EXT_TX if (tx_size == TX_8X4) { *(ta + (k & 1) + 1) = *(ta + (k & 1)); @@ -4506,8 +4276,7 @@ static int64_t encode_inter_mb_segment(VP10_COMP *cpi, rd1 = RDCOST(x->rdmult, x->rddiv, thisrate, thisdistortion); rd2 = RDCOST(x->rdmult, x->rddiv, 0, thissse); rd = VPXMIN(rd1, rd2); - if (rd >= best_yrd) - return INT64_MAX; + if (rd >= best_yrd) return INT64_MAX; } } @@ -4555,10 +4324,8 @@ typedef struct { } BEST_SEG_INFO; static INLINE int mv_check_bounds(const MACROBLOCK *x, const MV *mv) { - return (mv->row >> 3) < x->mv_row_min || - (mv->row >> 3) > x->mv_row_max || - (mv->col >> 3) < x->mv_col_min || - (mv->col >> 3) > x->mv_col_max; + return (mv->row >> 3) < x->mv_row_min || (mv->row >> 3) > x->mv_row_max || + (mv->col >> 3) < x->mv_col_min || (mv->col >> 3) > x->mv_col_max; } static INLINE void mi_buf_shift(MACROBLOCK *x, int i) { @@ -4566,14 +4333,16 @@ static INLINE void mi_buf_shift(MACROBLOCK *x, int i) { struct macroblock_plane *const p = &x->plane[0]; struct macroblockd_plane *const pd = &x->e_mbd.plane[0]; - p->src.buf = &p->src.buf[vp10_raster_block_offset(BLOCK_8X8, i, - p->src.stride)]; + p->src.buf = + &p->src.buf[vp10_raster_block_offset(BLOCK_8X8, i, p->src.stride)]; assert(((intptr_t)pd->pre[0].buf & 0x7) == 0); - pd->pre[0].buf = &pd->pre[0].buf[vp10_raster_block_offset(BLOCK_8X8, i, - pd->pre[0].stride)]; + pd->pre[0].buf = + &pd->pre[0] + .buf[vp10_raster_block_offset(BLOCK_8X8, i, pd->pre[0].stride)]; if (has_second_ref(mbmi)) - pd->pre[1].buf = &pd->pre[1].buf[vp10_raster_block_offset(BLOCK_8X8, i, - pd->pre[1].stride)]; + pd->pre[1].buf = + &pd->pre[1] + .buf[vp10_raster_block_offset(BLOCK_8X8, i, pd->pre[1].stride)]; } static INLINE void mi_buf_restore(MACROBLOCK *x, struct buf_2d orig_src, @@ -4581,8 +4350,7 @@ static INLINE void mi_buf_restore(MACROBLOCK *x, struct buf_2d orig_src, MB_MODE_INFO *mbmi = &x->e_mbd.mi[0]->mbmi; x->plane[0].src = orig_src; x->e_mbd.plane[0].pre[0] = orig_pre[0]; - if (has_second_ref(mbmi)) - x->e_mbd.plane[0].pre[1] = orig_pre[1]; + if (has_second_ref(mbmi)) x->e_mbd.plane[0].pre[1] = orig_pre[1]; } // Check if NEARESTMV/NEARMV/ZEROMV is the cheapest way encode zero motion. @@ -4593,8 +4361,7 @@ static int check_best_zero_mv( const int16_t compound_mode_context[TOTAL_REFS_PER_FRAME], #endif // CONFIG_REF_MV && CONFIG_EXT_INTER int_mv frame_mv[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME], int this_mode, - const MV_REFERENCE_FRAME ref_frames[2], - const BLOCK_SIZE bsize, int block) { + const MV_REFERENCE_FRAME ref_frames[2], const BLOCK_SIZE bsize, int block) { #if !CONFIG_EXT_INTER assert(ref_frames[1] != INTRA_FRAME); // Just sanity check @@ -4605,8 +4372,8 @@ static int check_best_zero_mv( (ref_frames[1] <= INTRA_FRAME || frame_mv[this_mode][ref_frames[1]].as_int == 0)) { #if CONFIG_REF_MV - int16_t rfc = vp10_mode_context_analyzer(mode_context, - ref_frames, bsize, block); + int16_t rfc = + vp10_mode_context_analyzer(mode_context, ref_frames, bsize, block); #else int16_t rfc = mode_context[ref_frames[0]]; #endif @@ -4648,8 +4415,8 @@ static int check_best_zero_mv( else if ((this_mode == NEAREST_NEARESTMV || this_mode == NEAREST_NEARMV || this_mode == NEAR_NEARESTMV || this_mode == NEAR_NEARMV || this_mode == ZERO_ZEROMV) && - frame_mv[this_mode][ref_frames[0]].as_int == 0 && - frame_mv[this_mode][ref_frames[1]].as_int == 0) { + frame_mv[this_mode][ref_frames[0]].as_int == 0 && + frame_mv[this_mode][ref_frames[1]].as_int == 0) { #if CONFIG_REF_MV int16_t rfc = compound_mode_context[ref_frames[0]]; int c1 = cost_mv_ref(cpi, NEAREST_NEARMV, 1, rfc); @@ -4676,17 +4443,13 @@ static int check_best_zero_mv( if (c5 > c3) return 0; } else { assert(this_mode == ZERO_ZEROMV); - if ((c3 >= c2 && - frame_mv[NEAREST_NEARESTMV][ref_frames[0]].as_int == 0 && + if ((c3 >= c2 && frame_mv[NEAREST_NEARESTMV][ref_frames[0]].as_int == 0 && frame_mv[NEAREST_NEARESTMV][ref_frames[1]].as_int == 0) || - (c3 >= c1 && - frame_mv[NEAREST_NEARMV][ref_frames[0]].as_int == 0 && + (c3 >= c1 && frame_mv[NEAREST_NEARMV][ref_frames[0]].as_int == 0 && frame_mv[NEAREST_NEARMV][ref_frames[1]].as_int == 0) || - (c3 >= c5 && - frame_mv[NEAR_NEARMV][ref_frames[0]].as_int == 0 && + (c3 >= c5 && frame_mv[NEAR_NEARMV][ref_frames[0]].as_int == 0 && frame_mv[NEAR_NEARMV][ref_frames[1]].as_int == 0) || - (c3 >= c4 && - frame_mv[NEAR_NEARESTMV][ref_frames[0]].as_int == 0 && + (c3 >= c4 && frame_mv[NEAR_NEARESTMV][ref_frames[0]].as_int == 0 && frame_mv[NEAR_NEARESTMV][ref_frames[1]].as_int == 0)) return 0; } @@ -4695,29 +4458,26 @@ static int check_best_zero_mv( return 1; } -static void joint_motion_search(VP10_COMP *cpi, MACROBLOCK *x, - BLOCK_SIZE bsize, - int_mv *frame_mv, - int mi_row, int mi_col, +static void joint_motion_search(VP10_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, + int_mv *frame_mv, int mi_row, int mi_col, #if CONFIG_EXT_INTER - int_mv* ref_mv_sub8x8[2], + int_mv *ref_mv_sub8x8[2], #endif int_mv single_newmv[TOTAL_REFS_PER_FRAME], - int *rate_mv, - const int block) { + int *rate_mv, const int block) { const VP10_COMMON *const cm = &cpi->common; const int pw = 4 * num_4x4_blocks_wide_lookup[bsize]; const int ph = 4 * num_4x4_blocks_high_lookup[bsize]; MACROBLOCKD *xd = &x->e_mbd; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; - const int refs[2] = {mbmi->ref_frame[0], - mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]}; + const int refs[2] = { mbmi->ref_frame[0], + mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1] }; int_mv ref_mv[2]; int ite, ref; #if CONFIG_DUAL_FILTER INTERP_FILTER interp_filter[4] = { - mbmi->interp_filter[0], mbmi->interp_filter[1], - mbmi->interp_filter[2], mbmi->interp_filter[3], + mbmi->interp_filter[0], mbmi->interp_filter[1], mbmi->interp_filter[2], + mbmi->interp_filter[3], }; #else const INTERP_FILTER interp_filter = mbmi->interp_filter; @@ -4726,13 +4486,13 @@ static void joint_motion_search(VP10_COMP *cpi, MACROBLOCK *x, // Do joint motion search in compound mode to get more accurate mv. struct buf_2d backup_yv12[2][MAX_MB_PLANE]; - int last_besterr[2] = {INT_MAX, INT_MAX}; + int last_besterr[2] = { INT_MAX, INT_MAX }; const YV12_BUFFER_CONFIG *const scaled_ref_frame[2] = { vp10_get_scaled_ref_frame(cpi, mbmi->ref_frame[0]), vp10_get_scaled_ref_frame(cpi, mbmi->ref_frame[1]) }; - // Prediction buffer from second frame. +// Prediction buffer from second frame. #if CONFIG_VP9_HIGHBITDEPTH DECLARE_ALIGNED(16, uint16_t, second_pred_alloc_16[MAX_SB_SQUARE]); uint8_t *second_pred; @@ -4746,7 +4506,7 @@ static void joint_motion_search(VP10_COMP *cpi, MACROBLOCK *x, ref_mv[ref].as_int = ref_mv_sub8x8[ref]->as_int; else #endif // CONFIG_EXT_INTER - ref_mv[ref] = x->mbmi_ext->ref_mvs[refs[ref]][0]; + ref_mv[ref] = x->mbmi_ext->ref_mvs[refs[ref]][0]; if (scaled_ref_frame[ref]) { int i; @@ -4756,21 +4516,20 @@ static void joint_motion_search(VP10_COMP *cpi, MACROBLOCK *x, for (i = 0; i < MAX_MB_PLANE; i++) backup_yv12[ref][i] = xd->plane[i].pre[ref]; vp10_setup_pre_planes(xd, ref, scaled_ref_frame[ref], mi_row, mi_col, - NULL); + NULL); } frame_mv[refs[ref]].as_int = single_newmv[refs[ref]].as_int; } - // Since we have scaled the reference frames to match the size of the current - // frame we must use a unit scaling factor during mode selection. +// Since we have scaled the reference frames to match the size of the current +// frame we must use a unit scaling factor during mode selection. #if CONFIG_VP9_HIGHBITDEPTH - vp10_setup_scale_factors_for_frame(&sf, cm->width, cm->height, - cm->width, cm->height, - cm->use_highbitdepth); + vp10_setup_scale_factors_for_frame(&sf, cm->width, cm->height, cm->width, + cm->height, cm->use_highbitdepth); #else - vp10_setup_scale_factors_for_frame(&sf, cm->width, cm->height, - cm->width, cm->height); + vp10_setup_scale_factors_for_frame(&sf, cm->width, cm->height, cm->width, + cm->height); #endif // CONFIG_VP9_HIGHBITDEPTH // Allow joint search multiple times iteratively for each reference frame @@ -4796,47 +4555,36 @@ static void joint_motion_search(VP10_COMP *cpi, MACROBLOCK *x, #if CONFIG_DUAL_FILTER // reload the filter types - interp_filter[0] = (id == 0) ? - mbmi->interp_filter[2] : mbmi->interp_filter[0]; - interp_filter[1] = (id == 0) ? - mbmi->interp_filter[3] : mbmi->interp_filter[1]; + interp_filter[0] = + (id == 0) ? mbmi->interp_filter[2] : mbmi->interp_filter[0]; + interp_filter[1] = + (id == 0) ? mbmi->interp_filter[3] : mbmi->interp_filter[1]; #endif - // Get the prediction block from the 'other' reference frame. +// Get the prediction block from the 'other' reference frame. #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { second_pred = CONVERT_TO_BYTEPTR(second_pred_alloc_16); - vp10_highbd_build_inter_predictor(ref_yv12[!id].buf, - ref_yv12[!id].stride, - second_pred, pw, - &frame_mv[refs[!id]].as_mv, - &sf, pw, ph, 0, - interp_filter, MV_PRECISION_Q3, - mi_col * MI_SIZE, mi_row * MI_SIZE, - xd->bd); + vp10_highbd_build_inter_predictor( + ref_yv12[!id].buf, ref_yv12[!id].stride, second_pred, pw, + &frame_mv[refs[!id]].as_mv, &sf, pw, ph, 0, interp_filter, + MV_PRECISION_Q3, mi_col * MI_SIZE, mi_row * MI_SIZE, xd->bd); } else { second_pred = (uint8_t *)second_pred_alloc_16; - vp10_build_inter_predictor(ref_yv12[!id].buf, - ref_yv12[!id].stride, - second_pred, pw, - &frame_mv[refs[!id]].as_mv, - &sf, pw, ph, 0, - interp_filter, MV_PRECISION_Q3, - mi_col * MI_SIZE, mi_row * MI_SIZE); + vp10_build_inter_predictor(ref_yv12[!id].buf, ref_yv12[!id].stride, + second_pred, pw, &frame_mv[refs[!id]].as_mv, + &sf, pw, ph, 0, interp_filter, MV_PRECISION_Q3, + mi_col * MI_SIZE, mi_row * MI_SIZE); } #else - vp10_build_inter_predictor(ref_yv12[!id].buf, - ref_yv12[!id].stride, - second_pred, pw, - &frame_mv[refs[!id]].as_mv, - &sf, pw, ph, 0, - interp_filter, MV_PRECISION_Q3, - mi_col * MI_SIZE, mi_row * MI_SIZE); + vp10_build_inter_predictor(ref_yv12[!id].buf, ref_yv12[!id].stride, + second_pred, pw, &frame_mv[refs[!id]].as_mv, &sf, + pw, ph, 0, interp_filter, MV_PRECISION_Q3, + mi_col * MI_SIZE, mi_row * MI_SIZE); #endif // CONFIG_VP9_HIGHBITDEPTH // Do compound motion search on the current reference frame. - if (id) - xd->plane[0].pre[0] = ref_yv12[id]; + if (id) xd->plane[0].pre[0] = ref_yv12[id]; vp10_set_mv_search_range(x, &ref_mv[id].as_mv); // Use the mv result from the single mode as mv predictor. @@ -4850,9 +4598,9 @@ static void joint_motion_search(VP10_COMP *cpi, MACROBLOCK *x, #endif // Small-range full-pixel motion search. - bestsme = vp10_refining_search_8p_c(x, sadpb, search_range, - &cpi->fn_ptr[bsize], - &ref_mv[id].as_mv, second_pred); + bestsme = + vp10_refining_search_8p_c(x, sadpb, search_range, &cpi->fn_ptr[bsize], + &ref_mv[id].as_mv, second_pred); if (bestsme < INT_MAX) bestsme = vp10_get_mvpred_av_var(x, best_mv, &ref_mv[id].as_mv, second_pred, &cpi->fn_ptr[bsize], 1); @@ -4875,47 +4623,37 @@ static void joint_motion_search(VP10_COMP *cpi, MACROBLOCK *x, // Set pred for Y plane setup_pred_plane(&pd->pre[0], upsampled_ref->y_buffer, upsampled_ref->y_crop_width, - upsampled_ref->y_crop_height, - upsampled_ref->y_stride, (mi_row << 3), (mi_col << 3), - NULL, pd->subsampling_x, pd->subsampling_y); + upsampled_ref->y_crop_height, upsampled_ref->y_stride, + (mi_row << 3), (mi_col << 3), NULL, pd->subsampling_x, + pd->subsampling_y); // If bsize < BLOCK_8X8, adjust pred pointer for this block if (bsize < BLOCK_8X8) pd->pre[0].buf = &pd->pre[0].buf[(vp10_raster_block_offset(BLOCK_8X8, block, - pd->pre[0].stride)) << 3]; + pd->pre[0].stride)) + << 3]; bestsme = cpi->find_fractional_mv_step( - x, &ref_mv[id].as_mv, - cpi->common.allow_high_precision_mv, - x->errorperbit, - &cpi->fn_ptr[bsize], - 0, cpi->sf.mv.subpel_iters_per_step, - NULL, - x->nmvjointcost, x->mvcost, - &dis, &sse, second_pred, - pw, ph, 1); + x, &ref_mv[id].as_mv, cpi->common.allow_high_precision_mv, + x->errorperbit, &cpi->fn_ptr[bsize], 0, + cpi->sf.mv.subpel_iters_per_step, NULL, x->nmvjointcost, x->mvcost, + &dis, &sse, second_pred, pw, ph, 1); // Restore the reference frames. pd->pre[0] = backup_pred; } else { - (void) block; + (void)block; bestsme = cpi->find_fractional_mv_step( - x, &ref_mv[id].as_mv, - cpi->common.allow_high_precision_mv, - x->errorperbit, - &cpi->fn_ptr[bsize], - 0, cpi->sf.mv.subpel_iters_per_step, - NULL, - x->nmvjointcost, x->mvcost, - &dis, &sse, second_pred, - pw, ph, 0); - } + x, &ref_mv[id].as_mv, cpi->common.allow_high_precision_mv, + x->errorperbit, &cpi->fn_ptr[bsize], 0, + cpi->sf.mv.subpel_iters_per_step, NULL, x->nmvjointcost, x->mvcost, + &dis, &sse, second_pred, pw, ph, 0); + } } // Restore the pointer to the first (possibly scaled) prediction buffer. - if (id) - xd->plane[0].pre[0] = ref_yv12[0]; + if (id) xd->plane[0].pre[0] = ref_yv12[0]; if (bestsme < last_besterr[id]) { frame_mv[refs[id]].as_mv = *best_mv; @@ -4940,23 +4678,23 @@ static void joint_motion_search(VP10_COMP *cpi, MACROBLOCK *x, #if CONFIG_EXT_INTER if (bsize >= BLOCK_8X8) #endif // CONFIG_EXT_INTER - *rate_mv += vp10_mv_bit_cost(&frame_mv[refs[ref]].as_mv, - &x->mbmi_ext->ref_mvs[refs[ref]][0].as_mv, - x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); + *rate_mv += vp10_mv_bit_cost(&frame_mv[refs[ref]].as_mv, + &x->mbmi_ext->ref_mvs[refs[ref]][0].as_mv, + x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); #if CONFIG_EXT_INTER else *rate_mv += vp10_mv_bit_cost(&frame_mv[refs[ref]].as_mv, - &ref_mv_sub8x8[ref]->as_mv, - x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); + &ref_mv_sub8x8[ref]->as_mv, x->nmvjointcost, + x->mvcost, MV_COST_WEIGHT); #endif // CONFIG_EXT_INTER } } static int64_t rd_pick_best_sub8x8_mode( - VP10_COMP *cpi, MACROBLOCK *x, - int_mv *best_ref_mv, int_mv *second_best_ref_mv, - int64_t best_rd, int *returntotrate, int *returnyrate, - int64_t *returndistortion, int *skippable, int64_t *psse, int mvthresh, + VP10_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv, + int_mv *second_best_ref_mv, int64_t best_rd, int *returntotrate, + int *returnyrate, int64_t *returndistortion, int *skippable, int64_t *psse, + int mvthresh, #if CONFIG_EXT_INTER int_mv seg_mvs[4][2][TOTAL_REFS_PER_FRAME], int_mv compound_seg_newmvs[4][2], @@ -4992,7 +4730,7 @@ static int64_t rd_pick_best_sub8x8_mode( MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext; #if CONFIG_EXT_TX && CONFIG_RECT_TX && !CONFIG_VAR_TX mbmi->tx_size = - xd->lossless[mbmi->segment_id] ? TX_4X4 : max_txsize_rect_lookup[bsize]; + xd->lossless[mbmi->segment_id] ? TX_4X4 : max_txsize_rect_lookup[bsize]; #else mbmi->tx_size = TX_4X4; #endif // CONFIG_EXT_TX && CONFIG_RECT_TX && !CONFIG_VAR_TX @@ -5005,8 +4743,7 @@ static int64_t rd_pick_best_sub8x8_mode( bsi->mvp.as_int = best_ref_mv->as_int; bsi->mvthresh = mvthresh; - for (idx = 0; idx < 4; ++idx) - bsi->modes[idx] = ZEROMV; + for (idx = 0; idx < 4; ++idx) bsi->modes[idx] = ZEROMV; #if CONFIG_REFMV for (idx = 0; idx < 4; ++idx) { @@ -5041,8 +4778,8 @@ static int64_t rd_pick_best_sub8x8_mode( const int i = idy * 2 + idx; int ref; #if CONFIG_REF_MV - CANDIDATE_MV ref_mv_stack[2][MAX_REF_MV_STACK_SIZE]; - uint8_t ref_mv_count[2]; + CANDIDATE_MV ref_mv_stack[2][MAX_REF_MV_STACK_SIZE]; + uint8_t ref_mv_count[2]; #endif #if CONFIG_EXT_INTER int mv_idx; @@ -5053,14 +4790,13 @@ static int64_t rd_pick_best_sub8x8_mode( const MV_REFERENCE_FRAME frame = mbmi->ref_frame[ref]; #if CONFIG_EXT_INTER int_mv mv_ref_list[MAX_MV_REF_CANDIDATES]; - vp10_update_mv_context(xd, mi, frame, mv_ref_list, i, - mi_row, mi_col, NULL); + vp10_update_mv_context(xd, mi, frame, mv_ref_list, i, mi_row, mi_col, + NULL); #endif // CONFIG_EXT_INTER frame_mv[ZEROMV][frame].as_int = 0; vp10_append_sub8x8_mvs_for_idx(cm, xd, i, ref, mi_row, mi_col, #if CONFIG_REF_MV - ref_mv_stack[ref], - &ref_mv_count[ref], + ref_mv_stack[ref], &ref_mv_count[ref], #endif #if CONFIG_EXT_INTER mv_ref_list, @@ -5079,41 +4815,40 @@ static int64_t rd_pick_best_sub8x8_mode( mv_ref_list[0].as_int = frame_mv[NEARESTMV][frame].as_int; mv_ref_list[1].as_int = frame_mv[NEARMV][frame].as_int; vp10_find_best_ref_mvs(cm->allow_high_precision_mv, mv_ref_list, - &ref_mvs_sub8x8[0][ref], &ref_mvs_sub8x8[1][ref]); + &ref_mvs_sub8x8[0][ref], + &ref_mvs_sub8x8[1][ref]); if (has_second_rf) { frame_mv[ZERO_ZEROMV][frame].as_int = 0; frame_mv[NEAREST_NEARESTMV][frame].as_int = - frame_mv[NEARESTMV][frame].as_int; + frame_mv[NEARESTMV][frame].as_int; if (ref == 0) { frame_mv[NEAREST_NEARMV][frame].as_int = - frame_mv[NEARESTMV][frame].as_int; + frame_mv[NEARESTMV][frame].as_int; frame_mv[NEAR_NEARESTMV][frame].as_int = - frame_mv[NEARMV][frame].as_int; + frame_mv[NEARMV][frame].as_int; frame_mv[NEAREST_NEWMV][frame].as_int = - frame_mv[NEARESTMV][frame].as_int; - frame_mv[NEAR_NEWMV][frame].as_int = - frame_mv[NEARMV][frame].as_int; + frame_mv[NEARESTMV][frame].as_int; + frame_mv[NEAR_NEWMV][frame].as_int = frame_mv[NEARMV][frame].as_int; frame_mv[NEAR_NEARMV][frame].as_int = - frame_mv[NEARMV][frame].as_int; + frame_mv[NEARMV][frame].as_int; } else if (ref == 1) { frame_mv[NEAREST_NEARMV][frame].as_int = - frame_mv[NEARMV][frame].as_int; + frame_mv[NEARMV][frame].as_int; frame_mv[NEAR_NEARESTMV][frame].as_int = - frame_mv[NEARESTMV][frame].as_int; + frame_mv[NEARESTMV][frame].as_int; frame_mv[NEW_NEARESTMV][frame].as_int = - frame_mv[NEARESTMV][frame].as_int; - frame_mv[NEW_NEARMV][frame].as_int = - frame_mv[NEARMV][frame].as_int; + frame_mv[NEARESTMV][frame].as_int; + frame_mv[NEW_NEARMV][frame].as_int = frame_mv[NEARMV][frame].as_int; frame_mv[NEAR_NEARMV][frame].as_int = - frame_mv[NEARMV][frame].as_int; + frame_mv[NEARMV][frame].as_int; } } #endif // CONFIG_EXT_INTER } - // search for the best motion vector on this segment +// search for the best motion vector on this segment #if CONFIG_EXT_INTER for (this_mode = (has_second_rf ? NEAREST_NEARESTMV : NEARESTMV); this_mode <= (has_second_rf ? NEW_NEWMV : NEWFROMNEARMV); @@ -5136,14 +4871,13 @@ static int64_t rd_pick_best_sub8x8_mode( bsi->ref_mv[ref]->as_int = ref_mvs_sub8x8[mv_idx][ref].as_int; #endif // CONFIG_EXT_INTER bsi->rdstat[i][mode_idx].brdcost = INT64_MAX; - if (!(inter_mode_mask & (1 << this_mode))) - continue; + if (!(inter_mode_mask & (1 << this_mode))) continue; #if CONFIG_REF_MV run_mv_search = 2; #if !CONFIG_EXT_INTER if (filter_idx > 0 && this_mode == NEWMV) { - BEST_SEG_INFO* ref_bsi = bsi_buf; + BEST_SEG_INFO *ref_bsi = bsi_buf; SEG_RDSTAT *ref_rdstat = &ref_bsi->rdstat[i][mode_idx]; if (has_second_rf) { @@ -5162,8 +4896,7 @@ static int64_t rd_pick_best_sub8x8_mode( if (bsi->ref_mv[0]->as_int == ref_rdstat->pred_mv[0].as_int && ref_rdstat->mvs[0].as_int != INVALID_MV) { run_mv_search = 0; - seg_mvs[i][mbmi->ref_frame[0]].as_int = - ref_rdstat->mvs[0].as_int; + seg_mvs[i][mbmi->ref_frame[0]].as_int = ref_rdstat->mvs[0].as_int; } } @@ -5185,8 +4918,7 @@ static int64_t rd_pick_best_sub8x8_mode( if (bsi->ref_mv[1]->as_int == ref_rdstat->pred_mv[1].as_int) --run_mv_search; } else { - if (bsi->ref_mv[0]->as_int == - ref_rdstat->pred_mv[0].as_int && + if (bsi->ref_mv[0]->as_int == ref_rdstat->pred_mv[0].as_int && ref_rdstat->mvs[0].as_int != INVALID_MV) { run_mv_search = 0; seg_mvs[i][mbmi->ref_frame[0]].as_int = @@ -5202,8 +4934,7 @@ static int64_t rd_pick_best_sub8x8_mode( #if CONFIG_REF_MV && CONFIG_EXT_INTER mbmi_ext->compound_mode_context, #endif // CONFIG_REF_MV && CONFIG_EXT_INTER - frame_mv, - this_mode, mbmi->ref_frame, bsize, i)) + frame_mv, this_mode, mbmi->ref_frame, bsize, i)) continue; memcpy(orig_pre, pd->pre, sizeof(orig_pre)); @@ -5221,9 +4952,9 @@ static int64_t rd_pick_best_sub8x8_mode( #else this_mode == NEWMV && (seg_mvs[i][mbmi->ref_frame[0]].as_int == INVALID_MV || - run_mv_search) + run_mv_search) #endif // CONFIG_EXT_INTER - ) { + ) { int step_param = 0; int bestsme = INT_MAX; int sadpb = x->sadperbit4; @@ -5233,19 +4964,17 @@ static int64_t rd_pick_best_sub8x8_mode( /* Is the best so far sufficiently good that we cant justify doing * and new motion search. */ - if (best_rd < label_mv_thresh) - break; + if (best_rd < label_mv_thresh) break; if (cpi->oxcf.mode != BEST) { #if CONFIG_EXT_INTER bsi->mvp.as_int = bsi->ref_mv[0]->as_int; #else - // use previous block's result as next block's MV predictor. +// use previous block's result as next block's MV predictor. #if !CONFIG_REF_MV if (i > 0) { bsi->mvp.as_int = mi->bmi[i - 1].as_mv[0].as_int; - if (i == 2) - bsi->mvp.as_int = mi->bmi[i - 2].as_mv[0].as_int; + if (i == 2) bsi->mvp.as_int = mi->bmi[i - 2].as_mv[0].as_int; } #endif #endif // CONFIG_EXT_INTER @@ -5260,8 +4989,8 @@ static int64_t rd_pick_best_sub8x8_mode( // Take wtd average of the step_params based on the last frame's // max mv magnitude and the best ref mvs of the current block for // the given reference. - step_param = (vp10_init_search_range(max_mv) + - cpi->mv_step_param) / 2; + step_param = + (vp10_init_search_range(max_mv) + cpi->mv_step_param) / 2; } else { step_param = cpi->mv_step_param; } @@ -5311,30 +5040,26 @@ static int64_t rd_pick_best_sub8x8_mode( get_upsampled_ref(cpi, mbmi->ref_frame[0]); // Set pred for Y plane - setup_pred_plane(&pd->pre[0], upsampled_ref->y_buffer, - upsampled_ref->y_crop_width, - upsampled_ref->y_crop_height, - upsampled_ref->y_stride, - (mi_row << 3), (mi_col << 3), - NULL, pd->subsampling_x, pd->subsampling_y); + setup_pred_plane( + &pd->pre[0], upsampled_ref->y_buffer, + upsampled_ref->y_crop_width, upsampled_ref->y_crop_height, + upsampled_ref->y_stride, (mi_row << 3), (mi_col << 3), NULL, + pd->subsampling_x, pd->subsampling_y); // adjust pred pointer for this block pd->pre[0].buf = &pd->pre[0].buf[(vp10_raster_block_offset(BLOCK_8X8, i, - pd->pre[0].stride)) << 3]; + pd->pre[0].stride)) + << 3]; - best_mv_var = - cpi->find_fractional_mv_step(x, &bsi->ref_mv[0]->as_mv, - cm->allow_high_precision_mv, - x->errorperbit, - &cpi->fn_ptr[bsize], - cpi->sf.mv.subpel_force_stop, - cpi->sf.mv.subpel_iters_per_step, - cond_cost_list(cpi, cost_list), - x->nmvjointcost, x->mvcost, - &distortion, - &x->pred_sse[mbmi->ref_frame[0]], - NULL, pw, ph, 1); + best_mv_var = cpi->find_fractional_mv_step( + x, &bsi->ref_mv[0]->as_mv, cm->allow_high_precision_mv, + x->errorperbit, &cpi->fn_ptr[bsize], + cpi->sf.mv.subpel_force_stop, + cpi->sf.mv.subpel_iters_per_step, + cond_cost_list(cpi, cost_list), x->nmvjointcost, x->mvcost, + &distortion, &x->pred_sse[mbmi->ref_frame[0]], NULL, pw, ph, + 1); if (try_second) { int this_var; @@ -5350,21 +5075,14 @@ static int64_t rd_pick_best_sub8x8_mode( x->best_mv.as_mv.row * 8 >= minr && x->best_mv.as_mv.col * 8 <= maxc && x->best_mv.as_mv.col * 8 >= minc) { - this_var = - cpi->find_fractional_mv_step(x, &bsi->ref_mv[0]->as_mv, - cm->allow_high_precision_mv, - x->errorperbit, - &cpi->fn_ptr[bsize], - cpi->sf.mv.subpel_force_stop, - cpi-> - sf.mv.subpel_iters_per_step, - cond_cost_list(cpi, - cost_list), - x->nmvjointcost, x->mvcost, - &distortion, - &x->pred_sse[mbmi-> - ref_frame[0]], - NULL, pw, ph, 1); + this_var = cpi->find_fractional_mv_step( + x, &bsi->ref_mv[0]->as_mv, cm->allow_high_precision_mv, + x->errorperbit, &cpi->fn_ptr[bsize], + cpi->sf.mv.subpel_force_stop, + cpi->sf.mv.subpel_iters_per_step, + cond_cost_list(cpi, cost_list), x->nmvjointcost, + x->mvcost, &distortion, &x->pred_sse[mbmi->ref_frame[0]], + NULL, pw, ph, 1); if (this_var < best_mv_var) best_mv = x->best_mv.as_mv; x->best_mv.as_mv = best_mv; } @@ -5374,19 +5092,15 @@ static int64_t rd_pick_best_sub8x8_mode( pd->pre[0] = backup_pred; } else { cpi->find_fractional_mv_step( - x, &bsi->ref_mv[0]->as_mv, - cm->allow_high_precision_mv, + x, &bsi->ref_mv[0]->as_mv, cm->allow_high_precision_mv, x->errorperbit, &cpi->fn_ptr[bsize], cpi->sf.mv.subpel_force_stop, cpi->sf.mv.subpel_iters_per_step, - cond_cost_list(cpi, cost_list), - x->nmvjointcost, x->mvcost, - &distortion, - &x->pred_sse[mbmi->ref_frame[0]], - NULL, 0, 0, 0); + cond_cost_list(cpi, cost_list), x->nmvjointcost, x->mvcost, + &distortion, &x->pred_sse[mbmi->ref_frame[0]], NULL, 0, 0, 0); } - // save motion search result for use in compound prediction +// save motion search result for use in compound prediction #if CONFIG_EXT_INTER seg_mvs[i][mv_idx][mbmi->ref_frame[0]].as_mv = x->best_mv.as_mv; #else @@ -5433,16 +5147,15 @@ static int64_t rd_pick_best_sub8x8_mode( #else (mbmi->interp_filter == EIGHTTAP_REGULAR || run_mv_search)) #endif - { + { // adjust src pointers mi_buf_shift(x, i); if (cpi->sf.comp_inter_joint_search_thresh <= bsize) { int rate_mv; - joint_motion_search(cpi, x, bsize, frame_mv[this_mode], - mi_row, mi_col, + joint_motion_search(cpi, x, bsize, frame_mv[this_mode], mi_row, + mi_col, #if CONFIG_EXT_INTER - bsi->ref_mv, - seg_mvs[i][mv_idx], + bsi->ref_mv, seg_mvs[i][mv_idx], #else seg_mvs[i], #endif // CONFIG_EXT_INTER @@ -5463,17 +5176,14 @@ static int64_t rd_pick_best_sub8x8_mode( mi_buf_restore(x, orig_src, orig_pre); } - bsi->rdstat[i][mode_idx].brate = - set_and_cost_bmi_mvs(cpi, x, xd, i, this_mode, mode_mv[this_mode], - frame_mv, + bsi->rdstat[i][mode_idx].brate = set_and_cost_bmi_mvs( + cpi, x, xd, i, this_mode, mode_mv[this_mode], frame_mv, #if CONFIG_EXT_INTER - seg_mvs[i][mv_idx], - compound_seg_newmvs[i], + seg_mvs[i][mv_idx], compound_seg_newmvs[i], #else - seg_mvs[i], + seg_mvs[i], #endif // CONFIG_EXT_INTER - bsi->ref_mv, - x->nmvjointcost, x->mvcost); + bsi->ref_mv, x->nmvjointcost, x->mvcost); for (ref = 0; ref < 1 + has_second_rf; ++ref) { bsi->rdstat[i][mode_idx].mvs[ref].as_int = @@ -5496,20 +5206,19 @@ static int64_t rd_pick_best_sub8x8_mode( #endif #if CONFIG_EXT_INTER bsi->rdstat[i][mode_idx].ref_mv[ref].as_int = - bsi->ref_mv[ref]->as_int; + bsi->ref_mv[ref]->as_int; if (num_4x4_blocks_wide > 1) bsi->rdstat[i + 1][mode_idx].ref_mv[ref].as_int = - bsi->ref_mv[ref]->as_int; + bsi->ref_mv[ref]->as_int; if (num_4x4_blocks_high > 1) bsi->rdstat[i + 2][mode_idx].ref_mv[ref].as_int = - bsi->ref_mv[ref]->as_int; + bsi->ref_mv[ref]->as_int; #endif // CONFIG_EXT_INTER } // Trap vectors that reach beyond the UMV borders if (mv_check_bounds(x, &mode_mv[this_mode][0].as_mv) || - (has_second_rf && - mv_check_bounds(x, &mode_mv[this_mode][1].as_mv))) + (has_second_rf && mv_check_bounds(x, &mode_mv[this_mode][1].as_mv))) continue; if (filter_idx > 0) { @@ -5521,15 +5230,14 @@ static int64_t rd_pick_best_sub8x8_mode( subpelmv |= mv_has_subpel(&mode_mv[this_mode][ref].as_mv); #if CONFIG_EXT_INTER if (have_newmv_in_inter_mode(this_mode)) - have_ref &= ( - (mode_mv[this_mode][ref].as_int == - ref_bsi->rdstat[i][mode_idx].mvs[ref].as_int) && - (bsi->ref_mv[ref]->as_int == - ref_bsi->rdstat[i][mode_idx].ref_mv[ref].as_int)); + have_ref &= ((mode_mv[this_mode][ref].as_int == + ref_bsi->rdstat[i][mode_idx].mvs[ref].as_int) && + (bsi->ref_mv[ref]->as_int == + ref_bsi->rdstat[i][mode_idx].ref_mv[ref].as_int)); else #endif // CONFIG_EXT_INTER - have_ref &= mode_mv[this_mode][ref].as_int == - ref_bsi->rdstat[i][mode_idx].mvs[ref].as_int; + have_ref &= mode_mv[this_mode][ref].as_int == + ref_bsi->rdstat[i][mode_idx].mvs[ref].as_int; } have_ref &= ref_bsi->rdstat[i][mode_idx].brate > 0; @@ -5540,15 +5248,14 @@ static int64_t rd_pick_best_sub8x8_mode( for (ref = 0; ref < 1 + has_second_rf; ++ref) #if CONFIG_EXT_INTER if (have_newmv_in_inter_mode(this_mode)) - have_ref &= ( - (mode_mv[this_mode][ref].as_int == - ref_bsi->rdstat[i][mode_idx].mvs[ref].as_int) && - (bsi->ref_mv[ref]->as_int == - ref_bsi->rdstat[i][mode_idx].ref_mv[ref].as_int)); + have_ref &= ((mode_mv[this_mode][ref].as_int == + ref_bsi->rdstat[i][mode_idx].mvs[ref].as_int) && + (bsi->ref_mv[ref]->as_int == + ref_bsi->rdstat[i][mode_idx].ref_mv[ref].as_int)); else #endif // CONFIG_EXT_INTER - have_ref &= mode_mv[this_mode][ref].as_int == - ref_bsi->rdstat[i][mode_idx].mvs[ref].as_int; + have_ref &= mode_mv[this_mode][ref].as_int == + ref_bsi->rdstat[i][mode_idx].mvs[ref].as_int; have_ref &= ref_bsi->rdstat[i][mode_idx].brate > 0; } @@ -5558,24 +5265,19 @@ static int64_t rd_pick_best_sub8x8_mode( #if CONFIG_REF_MV bsi->rdstat[i][mode_idx].byrate = ref_bsi->rdstat[i][mode_idx].byrate; - bsi->rdstat[i][mode_idx].bdist = - ref_bsi->rdstat[i][mode_idx].bdist; - bsi->rdstat[i][mode_idx].bsse = - ref_bsi->rdstat[i][mode_idx].bsse; + bsi->rdstat[i][mode_idx].bdist = ref_bsi->rdstat[i][mode_idx].bdist; + bsi->rdstat[i][mode_idx].bsse = ref_bsi->rdstat[i][mode_idx].bsse; bsi->rdstat[i][mode_idx].brate += ref_bsi->rdstat[i][mode_idx].byrate; - bsi->rdstat[i][mode_idx].eobs = - ref_bsi->rdstat[i][mode_idx].eobs; + bsi->rdstat[i][mode_idx].eobs = ref_bsi->rdstat[i][mode_idx].eobs; bsi->rdstat[i][mode_idx].brdcost = RDCOST(x->rdmult, x->rddiv, bsi->rdstat[i][mode_idx].brate, bsi->rdstat[i][mode_idx].bdist); - memcpy(bsi->rdstat[i][mode_idx].ta, - ref_bsi->rdstat[i][mode_idx].ta, + memcpy(bsi->rdstat[i][mode_idx].ta, ref_bsi->rdstat[i][mode_idx].ta, sizeof(bsi->rdstat[i][mode_idx].ta)); - memcpy(bsi->rdstat[i][mode_idx].tl, - ref_bsi->rdstat[i][mode_idx].tl, + memcpy(bsi->rdstat[i][mode_idx].tl, ref_bsi->rdstat[i][mode_idx].tl, sizeof(bsi->rdstat[i][mode_idx].tl)); #else memcpy(&bsi->rdstat[i][mode_idx], &ref_bsi->rdstat[i][mode_idx], @@ -5614,20 +5316,15 @@ static int64_t rd_pick_best_sub8x8_mode( } } - bsi->rdstat[i][mode_idx].brdcost = - encode_inter_mb_segment(cpi, x, - bsi->segment_rd - this_segment_rd, i, - &bsi->rdstat[i][mode_idx].byrate, - &bsi->rdstat[i][mode_idx].bdist, - &bsi->rdstat[i][mode_idx].bsse, - bsi->rdstat[i][mode_idx].ta, - bsi->rdstat[i][mode_idx].tl, - idy, idx, - mi_row, mi_col); + bsi->rdstat[i][mode_idx].brdcost = encode_inter_mb_segment( + cpi, x, bsi->segment_rd - this_segment_rd, i, + &bsi->rdstat[i][mode_idx].byrate, &bsi->rdstat[i][mode_idx].bdist, + &bsi->rdstat[i][mode_idx].bsse, bsi->rdstat[i][mode_idx].ta, + bsi->rdstat[i][mode_idx].tl, idy, idx, mi_row, mi_col); if (bsi->rdstat[i][mode_idx].brdcost < INT64_MAX) { - bsi->rdstat[i][mode_idx].brdcost += RDCOST(x->rdmult, x->rddiv, - bsi->rdstat[i][mode_idx].brate, 0); + bsi->rdstat[i][mode_idx].brdcost += + RDCOST(x->rdmult, x->rddiv, bsi->rdstat[i][mode_idx].brate, 0); bsi->rdstat[i][mode_idx].brate += bsi->rdstat[i][mode_idx].byrate; bsi->rdstat[i][mode_idx].eobs = p->eobs[i]; if (num_4x4_blocks_wide > 1) @@ -5686,8 +5383,7 @@ static int64_t rd_pick_best_sub8x8_mode( set_and_cost_bmi_mvs(cpi, x, xd, i, mode_selected, mode_mv[mode_selected], frame_mv, #if CONFIG_EXT_INTER - seg_mvs[i][mv_idx], - compound_seg_newmvs[i], + seg_mvs[i][mv_idx], compound_seg_newmvs[i], #else seg_mvs[i], #endif // CONFIG_EXT_INTER @@ -5721,11 +5417,9 @@ static int64_t rd_pick_best_sub8x8_mode( bsi->sse = block_sse; // update the coding decisions - for (k = 0; k < 4; ++k) - bsi->modes[k] = mi->bmi[k].as_mode; + for (k = 0; k < 4; ++k) bsi->modes[k] = mi->bmi[k].as_mode; - if (bsi->segment_rd > best_rd) - return INT64_MAX; + if (bsi->segment_rd > best_rd) return INT64_MAX; /* set it to the best */ for (idx = 0; idx < 4; idx++) { mode_idx = INTER_OFFSET(bsi->modes[idx]); @@ -5761,17 +5455,16 @@ static int64_t rd_pick_best_sub8x8_mode( } static void estimate_ref_frame_costs(const VP10_COMMON *cm, - const MACROBLOCKD *xd, - int segment_id, + const MACROBLOCKD *xd, int segment_id, unsigned int *ref_costs_single, unsigned int *ref_costs_comp, vpx_prob *comp_mode_p) { - int seg_ref_active = segfeature_active(&cm->seg, segment_id, - SEG_LVL_REF_FRAME); + int seg_ref_active = + segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME); if (seg_ref_active) { memset(ref_costs_single, 0, TOTAL_REFS_PER_FRAME * sizeof(*ref_costs_single)); - memset(ref_costs_comp, 0, TOTAL_REFS_PER_FRAME * sizeof(*ref_costs_comp)); + memset(ref_costs_comp, 0, TOTAL_REFS_PER_FRAME * sizeof(*ref_costs_comp)); *comp_mode_p = 128; } else { vpx_prob intra_inter_p = vp10_get_intra_inter_prob(cm, xd); @@ -5799,36 +5492,35 @@ static void estimate_ref_frame_costs(const VP10_COMMON *cm, ref_costs_single[LAST_FRAME] = #if CONFIG_EXT_REFS - ref_costs_single[LAST2_FRAME] = - ref_costs_single[LAST3_FRAME] = - ref_costs_single[BWDREF_FRAME] = + ref_costs_single[LAST2_FRAME] = ref_costs_single[LAST3_FRAME] = + ref_costs_single[BWDREF_FRAME] = #endif // CONFIG_EXT_REFS - ref_costs_single[GOLDEN_FRAME] = - ref_costs_single[ALTREF_FRAME] = base_cost; + ref_costs_single[GOLDEN_FRAME] = + ref_costs_single[ALTREF_FRAME] = base_cost; #if CONFIG_EXT_REFS - ref_costs_single[LAST_FRAME] += vp10_cost_bit(ref_single_p1, 0); - ref_costs_single[LAST2_FRAME] += vp10_cost_bit(ref_single_p1, 0); - ref_costs_single[LAST3_FRAME] += vp10_cost_bit(ref_single_p1, 0); + ref_costs_single[LAST_FRAME] += vp10_cost_bit(ref_single_p1, 0); + ref_costs_single[LAST2_FRAME] += vp10_cost_bit(ref_single_p1, 0); + ref_costs_single[LAST3_FRAME] += vp10_cost_bit(ref_single_p1, 0); ref_costs_single[GOLDEN_FRAME] += vp10_cost_bit(ref_single_p1, 0); ref_costs_single[BWDREF_FRAME] += vp10_cost_bit(ref_single_p1, 1); ref_costs_single[ALTREF_FRAME] += vp10_cost_bit(ref_single_p1, 1); - ref_costs_single[LAST_FRAME] += vp10_cost_bit(ref_single_p3, 0); - ref_costs_single[LAST2_FRAME] += vp10_cost_bit(ref_single_p3, 0); - ref_costs_single[LAST3_FRAME] += vp10_cost_bit(ref_single_p3, 1); + ref_costs_single[LAST_FRAME] += vp10_cost_bit(ref_single_p3, 0); + ref_costs_single[LAST2_FRAME] += vp10_cost_bit(ref_single_p3, 0); + ref_costs_single[LAST3_FRAME] += vp10_cost_bit(ref_single_p3, 1); ref_costs_single[GOLDEN_FRAME] += vp10_cost_bit(ref_single_p3, 1); ref_costs_single[BWDREF_FRAME] += vp10_cost_bit(ref_single_p2, 0); ref_costs_single[ALTREF_FRAME] += vp10_cost_bit(ref_single_p2, 1); - ref_costs_single[LAST_FRAME] += vp10_cost_bit(ref_single_p4, 0); - ref_costs_single[LAST2_FRAME] += vp10_cost_bit(ref_single_p4, 1); + ref_costs_single[LAST_FRAME] += vp10_cost_bit(ref_single_p4, 0); + ref_costs_single[LAST2_FRAME] += vp10_cost_bit(ref_single_p4, 1); - ref_costs_single[LAST3_FRAME] += vp10_cost_bit(ref_single_p5, 0); + ref_costs_single[LAST3_FRAME] += vp10_cost_bit(ref_single_p5, 0); ref_costs_single[GOLDEN_FRAME] += vp10_cost_bit(ref_single_p5, 1); #else - ref_costs_single[LAST_FRAME] += vp10_cost_bit(ref_single_p1, 0); + ref_costs_single[LAST_FRAME] += vp10_cost_bit(ref_single_p1, 0); ref_costs_single[GOLDEN_FRAME] += vp10_cost_bit(ref_single_p1, 1); ref_costs_single[ALTREF_FRAME] += vp10_cost_bit(ref_single_p1, 1); @@ -5836,10 +5528,10 @@ static void estimate_ref_frame_costs(const VP10_COMMON *cm, ref_costs_single[ALTREF_FRAME] += vp10_cost_bit(ref_single_p2, 1); #endif // CONFIG_EXT_REFS } else { - ref_costs_single[LAST_FRAME] = 512; + ref_costs_single[LAST_FRAME] = 512; #if CONFIG_EXT_REFS - ref_costs_single[LAST2_FRAME] = 512; - ref_costs_single[LAST3_FRAME] = 512; + ref_costs_single[LAST2_FRAME] = 512; + ref_costs_single[LAST3_FRAME] = 512; ref_costs_single[BWDREF_FRAME] = 512; #endif // CONFIG_EXT_REFS ref_costs_single[GOLDEN_FRAME] = 512; @@ -5858,25 +5550,24 @@ static void estimate_ref_frame_costs(const VP10_COMMON *cm, ref_costs_comp[LAST_FRAME] = #if CONFIG_EXT_REFS - ref_costs_comp[LAST2_FRAME] = - ref_costs_comp[LAST3_FRAME] = + ref_costs_comp[LAST2_FRAME] = ref_costs_comp[LAST3_FRAME] = #endif // CONFIG_EXT_REFS - ref_costs_comp[GOLDEN_FRAME] = base_cost; + ref_costs_comp[GOLDEN_FRAME] = base_cost; #if CONFIG_EXT_REFS ref_costs_comp[BWDREF_FRAME] = ref_costs_comp[ALTREF_FRAME] = 0; #endif // CONFIG_EXT_REFS #if CONFIG_EXT_REFS - ref_costs_comp[LAST_FRAME] += vp10_cost_bit(ref_comp_p, 0); - ref_costs_comp[LAST2_FRAME] += vp10_cost_bit(ref_comp_p, 0); - ref_costs_comp[LAST3_FRAME] += vp10_cost_bit(ref_comp_p, 1); + ref_costs_comp[LAST_FRAME] += vp10_cost_bit(ref_comp_p, 0); + ref_costs_comp[LAST2_FRAME] += vp10_cost_bit(ref_comp_p, 0); + ref_costs_comp[LAST3_FRAME] += vp10_cost_bit(ref_comp_p, 1); ref_costs_comp[GOLDEN_FRAME] += vp10_cost_bit(ref_comp_p, 1); - ref_costs_comp[LAST_FRAME] += vp10_cost_bit(ref_comp_p1, 1); - ref_costs_comp[LAST2_FRAME] += vp10_cost_bit(ref_comp_p1, 0); + ref_costs_comp[LAST_FRAME] += vp10_cost_bit(ref_comp_p1, 1); + ref_costs_comp[LAST2_FRAME] += vp10_cost_bit(ref_comp_p1, 0); - ref_costs_comp[LAST3_FRAME] += vp10_cost_bit(ref_comp_p2, 0); + ref_costs_comp[LAST3_FRAME] += vp10_cost_bit(ref_comp_p2, 0); ref_costs_comp[GOLDEN_FRAME] += vp10_cost_bit(ref_comp_p2, 1); // NOTE(zoeliu): BWDREF and ALTREF each add an extra cost by coding 1 @@ -5884,14 +5575,14 @@ static void estimate_ref_frame_costs(const VP10_COMMON *cm, ref_costs_comp[BWDREF_FRAME] += vp10_cost_bit(bwdref_comp_p, 0); ref_costs_comp[ALTREF_FRAME] += vp10_cost_bit(bwdref_comp_p, 1); #else - ref_costs_comp[LAST_FRAME] += vp10_cost_bit(ref_comp_p, 0); + ref_costs_comp[LAST_FRAME] += vp10_cost_bit(ref_comp_p, 0); ref_costs_comp[GOLDEN_FRAME] += vp10_cost_bit(ref_comp_p, 1); #endif // CONFIG_EXT_REFS } else { - ref_costs_comp[LAST_FRAME] = 512; + ref_costs_comp[LAST_FRAME] = 512; #if CONFIG_EXT_REFS - ref_costs_comp[LAST2_FRAME] = 512; - ref_costs_comp[LAST3_FRAME] = 512; + ref_costs_comp[LAST2_FRAME] = 512; + ref_costs_comp[LAST3_FRAME] = 512; ref_costs_comp[BWDREF_FRAME] = 512; ref_costs_comp[ALTREF_FRAME] = 512; #endif // CONFIG_EXT_REFS @@ -5901,9 +5592,9 @@ static void estimate_ref_frame_costs(const VP10_COMMON *cm, } static void store_coding_context(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx, - int mode_index, - int64_t comp_pred_diff[REFERENCE_MODES], - int skippable) { + int mode_index, + int64_t comp_pred_diff[REFERENCE_MODES], + int skippable) { MACROBLOCKD *const xd = &x->e_mbd; // Take a snapshot of the coding context so it can be @@ -5914,15 +5605,13 @@ static void store_coding_context(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx, ctx->mic = *xd->mi[0]; ctx->mbmi_ext = *x->mbmi_ext; ctx->single_pred_diff = (int)comp_pred_diff[SINGLE_REFERENCE]; - ctx->comp_pred_diff = (int)comp_pred_diff[COMPOUND_REFERENCE]; + ctx->comp_pred_diff = (int)comp_pred_diff[COMPOUND_REFERENCE]; ctx->hybrid_pred_diff = (int)comp_pred_diff[REFERENCE_MODE_SELECT]; } static void setup_buffer_inter( - VP10_COMP *cpi, MACROBLOCK *x, - MV_REFERENCE_FRAME ref_frame, - BLOCK_SIZE block_size, - int mi_row, int mi_col, + VP10_COMP *cpi, MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, + BLOCK_SIZE block_size, int mi_row, int mi_col, int_mv frame_nearest_mv[TOTAL_REFS_PER_FRAME], int_mv frame_near_mv[TOTAL_REFS_PER_FRAME], struct buf_2d yv12_mb[TOTAL_REFS_PER_FRAME][MAX_MB_PLANE]) { @@ -5941,16 +5630,15 @@ static void setup_buffer_inter( vp10_setup_pred_block(xd, yv12_mb[ref_frame], yv12, mi_row, mi_col, sf, sf); // Gets an initial list of candidate vectors from neighbours and orders them - vp10_find_mv_refs(cm, xd, mi, ref_frame, + vp10_find_mv_refs( + cm, xd, mi, ref_frame, #if CONFIG_REF_MV - &mbmi_ext->ref_mv_count[ref_frame], - mbmi_ext->ref_mv_stack[ref_frame], + &mbmi_ext->ref_mv_count[ref_frame], mbmi_ext->ref_mv_stack[ref_frame], #if CONFIG_EXT_INTER - mbmi_ext->compound_mode_context, + mbmi_ext->compound_mode_context, #endif // CONFIG_EXT_INTER #endif - candidates, mi_row, mi_col, - NULL, NULL, mbmi_ext->mode_context); + candidates, mi_row, mi_col, NULL, NULL, mbmi_ext->mode_context); // Candidate refinement carried out at encoder and decoder vp10_find_best_ref_mvs(cm->allow_high_precision_mv, candidates, @@ -5961,22 +5649,20 @@ static void setup_buffer_inter( // in full and choose the best as the centre point for subsequent searches. // The current implementation doesn't support scaling. if (!vp10_is_scaled(sf) && block_size >= BLOCK_8X8) - vp10_mv_pred(cpi, x, yv12_mb[ref_frame][0].buf, yv12->y_stride, - ref_frame, block_size); + vp10_mv_pred(cpi, x, yv12_mb[ref_frame][0].buf, yv12->y_stride, ref_frame, + block_size); } static void single_motion_search(VP10_COMP *cpi, MACROBLOCK *x, - BLOCK_SIZE bsize, - int mi_row, int mi_col, + BLOCK_SIZE bsize, int mi_row, int mi_col, #if CONFIG_EXT_INTER - int ref_idx, - int mv_idx, + int ref_idx, int mv_idx, #endif // CONFIG_EXT_INTER int *rate_mv) { MACROBLOCKD *xd = &x->e_mbd; const VP10_COMMON *cm = &cpi->common; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; - struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0, 0, 0, 0}}; + struct buf_2d backup_yv12[MAX_MB_PLANE] = { { 0, 0, 0, 0, 0 } }; int bestsme = INT_MAX; int step_param; int sadpb = x->sadperbit16; @@ -5996,8 +5682,8 @@ static void single_motion_search(VP10_COMP *cpi, MACROBLOCK *x, int tmp_row_max = x->mv_row_max; int cost_list[5]; - const YV12_BUFFER_CONFIG *scaled_ref_frame = vp10_get_scaled_ref_frame(cpi, - ref); + const YV12_BUFFER_CONFIG *scaled_ref_frame = + vp10_get_scaled_ref_frame(cpi, ref); MV pred_mv[3]; pred_mv[0] = x->mbmi_ext->ref_mvs[ref][0].as_mv; @@ -6027,15 +5713,17 @@ static void single_motion_search(VP10_COMP *cpi, MACROBLOCK *x, // Take wtd average of the step_params based on the last frame's // max mv magnitude and that based on the best ref mvs of the current // block for the given reference. - step_param = (vp10_init_search_range(x->max_mv_context[ref]) + - cpi->mv_step_param) / 2; + step_param = + (vp10_init_search_range(x->max_mv_context[ref]) + cpi->mv_step_param) / + 2; } else { step_param = cpi->mv_step_param; } if (cpi->sf.adaptive_motion_search && bsize < cm->sb_size) { - int boffset = 2 * (b_width_log2_lookup[cm->sb_size] - - VPXMIN(b_height_log2_lookup[bsize], b_width_log2_lookup[bsize])); + int boffset = + 2 * (b_width_log2_lookup[cm->sb_size] - + VPXMIN(b_height_log2_lookup[bsize], b_width_log2_lookup[bsize])); step_param = VPXMAX(step_param, boffset); } @@ -6044,8 +5732,7 @@ static void single_motion_search(VP10_COMP *cpi, MACROBLOCK *x, int bhl = b_height_log2_lookup[bsize]; int tlevel = x->pred_mv_sad[ref] >> (bwl + bhl + 4); - if (tlevel < 5) - step_param += 2; + if (tlevel < 5) step_param += 2; // prev_mv_sad is not setup for dynamically scaled frames. if (cpi->oxcf.resize_mode != RESIZE_DYNAMIC) { @@ -6075,8 +5762,8 @@ static void single_motion_search(VP10_COMP *cpi, MACROBLOCK *x, x->best_mv.as_int = x->second_best_mv.as_int = INVALID_MV; bestsme = vp10_full_pixel_search(cpi, x, bsize, &mvp_full, step_param, sadpb, - cond_cost_list(cpi, cost_list), - &ref_mv, INT_MAX, 1); + cond_cost_list(cpi, cost_list), &ref_mv, + INT_MAX, 1); x->mv_col_min = tmp_col_min; x->mv_col_max = tmp_col_max; @@ -6084,12 +5771,11 @@ static void single_motion_search(VP10_COMP *cpi, MACROBLOCK *x, x->mv_row_max = tmp_row_max; if (bestsme < INT_MAX) { - int dis; /* TODO: use dis in distortion calculation later. */ + int dis; /* TODO: use dis in distortion calculation later. */ if (cpi->sf.use_upsampled_references) { int best_mv_var; - const int try_second = - x->second_best_mv.as_int != INVALID_MV && - x->second_best_mv.as_int != x->best_mv.as_int; + const int try_second = x->second_best_mv.as_int != INVALID_MV && + x->second_best_mv.as_int != x->best_mv.as_int; const int pw = 4 * num_4x4_blocks_wide_lookup[bsize]; const int ph = 4 * num_4x4_blocks_high_lookup[bsize]; // Use up-sampled reference frames. @@ -6100,21 +5786,15 @@ static void single_motion_search(VP10_COMP *cpi, MACROBLOCK *x, // Set pred for Y plane setup_pred_plane(&pd->pre[ref_idx], upsampled_ref->y_buffer, upsampled_ref->y_crop_width, - upsampled_ref->y_crop_height, - upsampled_ref->y_stride, (mi_row << 3), (mi_col << 3), - NULL, pd->subsampling_x, pd->subsampling_y); + upsampled_ref->y_crop_height, upsampled_ref->y_stride, + (mi_row << 3), (mi_col << 3), NULL, pd->subsampling_x, + pd->subsampling_y); - best_mv_var = - cpi->find_fractional_mv_step(x, &ref_mv, - cm->allow_high_precision_mv, - x->errorperbit, - &cpi->fn_ptr[bsize], - cpi->sf.mv.subpel_force_stop, - cpi->sf.mv.subpel_iters_per_step, - cond_cost_list(cpi, cost_list), - x->nmvjointcost, x->mvcost, - &dis, &x->pred_sse[ref], NULL, - pw, ph, 1); + best_mv_var = cpi->find_fractional_mv_step( + x, &ref_mv, cm->allow_high_precision_mv, x->errorperbit, + &cpi->fn_ptr[bsize], cpi->sf.mv.subpel_force_stop, + cpi->sf.mv.subpel_iters_per_step, cond_cost_list(cpi, cost_list), + x->nmvjointcost, x->mvcost, &dis, &x->pred_sse[ref], NULL, pw, ph, 1); if (try_second) { const int minc = VPXMAX(x->mv_col_min * 8, ref_mv.col - MV_MAX); @@ -6129,17 +5809,12 @@ static void single_motion_search(VP10_COMP *cpi, MACROBLOCK *x, x->best_mv.as_mv.row * 8 >= minr && x->best_mv.as_mv.col * 8 <= maxc && x->best_mv.as_mv.col * 8 >= minc) { - this_var = - cpi->find_fractional_mv_step(x, &ref_mv, - cm->allow_high_precision_mv, - x->errorperbit, - &cpi->fn_ptr[bsize], - cpi->sf.mv.subpel_force_stop, - cpi->sf.mv.subpel_iters_per_step, - cond_cost_list(cpi, cost_list), - x->nmvjointcost, x->mvcost, - &dis, &x->pred_sse[ref], NULL, - pw, ph, 1); + this_var = cpi->find_fractional_mv_step( + x, &ref_mv, cm->allow_high_precision_mv, x->errorperbit, + &cpi->fn_ptr[bsize], cpi->sf.mv.subpel_force_stop, + cpi->sf.mv.subpel_iters_per_step, cond_cost_list(cpi, cost_list), + x->nmvjointcost, x->mvcost, &dis, &x->pred_sse[ref], NULL, pw, ph, + 1); if (this_var < best_mv_var) best_mv = x->best_mv.as_mv; x->best_mv.as_mv = best_mv; } @@ -6148,22 +5823,17 @@ static void single_motion_search(VP10_COMP *cpi, MACROBLOCK *x, // Restore the reference frames. pd->pre[ref_idx] = backup_pred; } else { - cpi->find_fractional_mv_step(x, &ref_mv, - cm->allow_high_precision_mv, - x->errorperbit, - &cpi->fn_ptr[bsize], - cpi->sf.mv.subpel_force_stop, - cpi->sf.mv.subpel_iters_per_step, - cond_cost_list(cpi, cost_list), - x->nmvjointcost, x->mvcost, - &dis, &x->pred_sse[ref], NULL, 0, 0, 0); + cpi->find_fractional_mv_step( + x, &ref_mv, cm->allow_high_precision_mv, x->errorperbit, + &cpi->fn_ptr[bsize], cpi->sf.mv.subpel_force_stop, + cpi->sf.mv.subpel_iters_per_step, cond_cost_list(cpi, cost_list), + x->nmvjointcost, x->mvcost, &dis, &x->pred_sse[ref], NULL, 0, 0, 0); } } - *rate_mv = vp10_mv_bit_cost(&x->best_mv.as_mv, &ref_mv, - x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); + *rate_mv = vp10_mv_bit_cost(&x->best_mv.as_mv, &ref_mv, x->nmvjointcost, + x->mvcost, MV_COST_WEIGHT); - if (cpi->sf.adaptive_motion_search) - x->pred_mv[ref] = x->best_mv.as_mv; + if (cpi->sf.adaptive_motion_search) x->pred_mv[ref] = x->best_mv.as_mv; if (scaled_ref_frame) { int i; @@ -6185,17 +5855,16 @@ static INLINE void restore_dst_buf(MACROBLOCKD *xd, #if CONFIG_OBMC static void single_motion_search_obmc(VP10_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int mi_row, int mi_col, - const int32_t* wsrc, const int32_t* mask, + const int32_t *wsrc, const int32_t *mask, #if CONFIG_EXT_INTER - int ref_idx, - int mv_idx, + int ref_idx, int mv_idx, #endif // CONFIG_EXT_INTER int_mv *tmp_mv, int_mv pred_mv, int *rate_mv) { MACROBLOCKD *xd = &x->e_mbd; const VP10_COMMON *cm = &cpi->common; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; - struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0, 0, 0, 0}}; + struct buf_2d backup_yv12[MAX_MB_PLANE] = { { 0, 0, 0, 0, 0 } }; int bestsme = INT_MAX; int step_param; int sadpb = x->sadperbit16; @@ -6214,8 +5883,8 @@ static void single_motion_search_obmc(VP10_COMP *cpi, MACROBLOCK *x, int tmp_row_min = x->mv_row_min; int tmp_row_max = x->mv_row_max; - const YV12_BUFFER_CONFIG *scaled_ref_frame = vp10_get_scaled_ref_frame(cpi, - ref); + const YV12_BUFFER_CONFIG *scaled_ref_frame = + vp10_get_scaled_ref_frame(cpi, ref); #if CONFIG_REF_MV vp10_set_mvcost(x, ref); @@ -6240,15 +5909,17 @@ static void single_motion_search_obmc(VP10_COMP *cpi, MACROBLOCK *x, // Take wtd average of the step_params based on the last frame's // max mv magnitude and that based on the best ref mvs of the current // block for the given reference. - step_param = (vp10_init_search_range(x->max_mv_context[ref]) + - cpi->mv_step_param) / 2; + step_param = + (vp10_init_search_range(x->max_mv_context[ref]) + cpi->mv_step_param) / + 2; } else { step_param = cpi->mv_step_param; } if (cpi->sf.adaptive_motion_search && bsize < cm->sb_size) { - int boffset = 2 * (b_width_log2_lookup[cm->sb_size] - - VPXMIN(b_height_log2_lookup[bsize], b_width_log2_lookup[bsize])); + int boffset = + 2 * (b_width_log2_lookup[cm->sb_size] - + VPXMIN(b_height_log2_lookup[bsize], b_width_log2_lookup[bsize])); step_param = VPXMAX(step_param, boffset); } @@ -6257,8 +5928,7 @@ static void single_motion_search_obmc(VP10_COMP *cpi, MACROBLOCK *x, int bhl = b_height_log2_lookup[bsize]; int tlevel = x->pred_mv_sad[ref] >> (bwl + bhl + 4); - if (tlevel < 5) - step_param += 2; + if (tlevel < 5) step_param += 2; // prev_mv_sad is not setup for dynamically scaled frames. if (cpi->oxcf.resize_mode != RESIZE_DYNAMIC) { @@ -6284,11 +5954,10 @@ static void single_motion_search_obmc(VP10_COMP *cpi, MACROBLOCK *x, mvp_full.col >>= 3; mvp_full.row >>= 3; - bestsme = vp10_obmc_full_pixel_diamond(cpi, x, wsrc, mask, - &mvp_full, step_param, sadpb, - MAX_MVSEARCH_STEPS - 1 - step_param, - 1, &cpi->fn_ptr[bsize], - &ref_mv, &tmp_mv->as_mv, ref_idx); + bestsme = vp10_obmc_full_pixel_diamond( + cpi, x, wsrc, mask, &mvp_full, step_param, sadpb, + MAX_MVSEARCH_STEPS - 1 - step_param, 1, &cpi->fn_ptr[bsize], &ref_mv, + &tmp_mv->as_mv, ref_idx); x->mv_col_min = tmp_col_min; x->mv_col_max = tmp_col_max; @@ -6297,22 +5966,15 @@ static void single_motion_search_obmc(VP10_COMP *cpi, MACROBLOCK *x, if (bestsme < INT_MAX) { int dis; - vp10_find_best_obmc_sub_pixel_tree_up(cpi, x, - wsrc, mask, - mi_row, mi_col, - &tmp_mv->as_mv, &ref_mv, - cm->allow_high_precision_mv, - x->errorperbit, - &cpi->fn_ptr[bsize], - cpi->sf.mv.subpel_force_stop, - cpi->sf.mv.subpel_iters_per_step, - x->nmvjointcost, x->mvcost, - &dis, &x->pred_sse[ref], - ref_idx, - cpi->sf.use_upsampled_references); + vp10_find_best_obmc_sub_pixel_tree_up( + cpi, x, wsrc, mask, mi_row, mi_col, &tmp_mv->as_mv, &ref_mv, + cm->allow_high_precision_mv, x->errorperbit, &cpi->fn_ptr[bsize], + cpi->sf.mv.subpel_force_stop, cpi->sf.mv.subpel_iters_per_step, + x->nmvjointcost, x->mvcost, &dis, &x->pred_sse[ref], ref_idx, + cpi->sf.use_upsampled_references); } - *rate_mv = vp10_mv_bit_cost(&tmp_mv->as_mv, &ref_mv, - x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); + *rate_mv = vp10_mv_bit_cost(&tmp_mv->as_mv, &ref_mv, x->nmvjointcost, + x->mvcost, MV_COST_WEIGHT); if (scaled_ref_frame) { int i; @@ -6325,15 +5987,13 @@ static void single_motion_search_obmc(VP10_COMP *cpi, MACROBLOCK *x, #if CONFIG_EXT_INTER static void do_masked_motion_search(VP10_COMP *cpi, MACROBLOCK *x, const uint8_t *mask, int mask_stride, - BLOCK_SIZE bsize, - int mi_row, int mi_col, - int_mv *tmp_mv, int *rate_mv, - int ref_idx, + BLOCK_SIZE bsize, int mi_row, int mi_col, + int_mv *tmp_mv, int *rate_mv, int ref_idx, int mv_idx) { MACROBLOCKD *xd = &x->e_mbd; const VP10_COMMON *cm = &cpi->common; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; - struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0, 0, 0, 0}}; + struct buf_2d backup_yv12[MAX_MB_PLANE] = { { 0, 0, 0, 0, 0 } }; int bestsme = INT_MAX; int step_param; int sadpb = x->sadperbit16; @@ -6377,17 +6037,18 @@ static void do_masked_motion_search(VP10_COMP *cpi, MACROBLOCK *x, // Take wtd average of the step_params based on the last frame's // max mv magnitude and that based on the best ref mvs of the current // block for the given reference. - step_param = (vp10_init_search_range(x->max_mv_context[ref]) + - cpi->mv_step_param) / 2; + step_param = + (vp10_init_search_range(x->max_mv_context[ref]) + cpi->mv_step_param) / + 2; } else { step_param = cpi->mv_step_param; } // TODO(debargha): is show_frame needed here? - if (cpi->sf.adaptive_motion_search && bsize < cm->sb_size && - cm->show_frame) { - int boffset = 2 * (b_width_log2_lookup[cm->sb_size] - - VPXMIN(b_height_log2_lookup[bsize], b_width_log2_lookup[bsize])); + if (cpi->sf.adaptive_motion_search && bsize < cm->sb_size && cm->show_frame) { + int boffset = + 2 * (b_width_log2_lookup[cm->sb_size] - + VPXMIN(b_height_log2_lookup[bsize], b_width_log2_lookup[bsize])); step_param = VPXMAX(step_param, boffset); } @@ -6396,8 +6057,7 @@ static void do_masked_motion_search(VP10_COMP *cpi, MACROBLOCK *x, int bhl = b_height_log2_lookup[bsize]; int tlevel = x->pred_mv_sad[ref] >> (bwl + bhl + 4); - if (tlevel < 5) - step_param += 2; + if (tlevel < 5) step_param += 2; // prev_mv_sad is not setup for dynamically scaled frames. if (cpi->oxcf.resize_mode != RESIZE_DYNAMIC) { @@ -6424,11 +6084,10 @@ static void do_masked_motion_search(VP10_COMP *cpi, MACROBLOCK *x, mvp_full.col >>= 3; mvp_full.row >>= 3; - bestsme = vp10_masked_full_pixel_diamond(cpi, x, mask, mask_stride, - &mvp_full, step_param, sadpb, - MAX_MVSEARCH_STEPS - 1 - step_param, - 1, &cpi->fn_ptr[bsize], - &ref_mv, &tmp_mv->as_mv, ref_idx); + bestsme = vp10_masked_full_pixel_diamond( + cpi, x, mask, mask_stride, &mvp_full, step_param, sadpb, + MAX_MVSEARCH_STEPS - 1 - step_param, 1, &cpi->fn_ptr[bsize], &ref_mv, + &tmp_mv->as_mv, ref_idx); x->mv_col_min = tmp_col_min; x->mv_col_max = tmp_col_max; @@ -6436,22 +6095,16 @@ static void do_masked_motion_search(VP10_COMP *cpi, MACROBLOCK *x, x->mv_row_max = tmp_row_max; if (bestsme < INT_MAX) { - int dis; /* TODO: use dis in distortion calculation later. */ - vp10_find_best_masked_sub_pixel_tree_up(cpi, x, mask, mask_stride, - mi_row, mi_col, - &tmp_mv->as_mv, &ref_mv, - cm->allow_high_precision_mv, - x->errorperbit, - &cpi->fn_ptr[bsize], - cpi->sf.mv.subpel_force_stop, - cpi->sf.mv.subpel_iters_per_step, - x->nmvjointcost, x->mvcost, - &dis, &x->pred_sse[ref], - ref_idx, - cpi->sf.use_upsampled_references); + int dis; /* TODO: use dis in distortion calculation later. */ + vp10_find_best_masked_sub_pixel_tree_up( + cpi, x, mask, mask_stride, mi_row, mi_col, &tmp_mv->as_mv, &ref_mv, + cm->allow_high_precision_mv, x->errorperbit, &cpi->fn_ptr[bsize], + cpi->sf.mv.subpel_force_stop, cpi->sf.mv.subpel_iters_per_step, + x->nmvjointcost, x->mvcost, &dis, &x->pred_sse[ref], ref_idx, + cpi->sf.use_upsampled_references); } - *rate_mv = vp10_mv_bit_cost(&tmp_mv->as_mv, &ref_mv, - x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); + *rate_mv = vp10_mv_bit_cost(&tmp_mv->as_mv, &ref_mv, x->nmvjointcost, + x->mvcost, MV_COST_WEIGHT); if (cpi->sf.adaptive_motion_search && cm->show_frame) x->pred_mv[ref] = tmp_mv->as_mv; @@ -6464,12 +6117,10 @@ static void do_masked_motion_search(VP10_COMP *cpi, MACROBLOCK *x, } static void do_masked_motion_search_indexed(VP10_COMP *cpi, MACROBLOCK *x, - int wedge_index, - int wedge_sign, - BLOCK_SIZE bsize, - int mi_row, int mi_col, - int_mv *tmp_mv, int *rate_mv, - int mv_idx[2], + int wedge_index, int wedge_sign, + BLOCK_SIZE bsize, int mi_row, + int mi_col, int_mv *tmp_mv, + int *rate_mv, int mv_idx[2], int which) { // NOTE: which values: 0 - 0 only, 1 - 1 only, 2 - both MACROBLOCKD *xd = &x->e_mbd; @@ -6480,16 +6131,14 @@ static void do_masked_motion_search_indexed(VP10_COMP *cpi, MACROBLOCK *x, mask = vp10_get_contiguous_soft_mask(wedge_index, wedge_sign, sb_type); if (which == 0 || which == 2) - do_masked_motion_search(cpi, x, mask, mask_stride, bsize, - mi_row, mi_col, &tmp_mv[0], &rate_mv[0], - 0, mv_idx[0]); + do_masked_motion_search(cpi, x, mask, mask_stride, bsize, mi_row, mi_col, + &tmp_mv[0], &rate_mv[0], 0, mv_idx[0]); if (which == 1 || which == 2) { // get the negative mask mask = vp10_get_contiguous_soft_mask(wedge_index, !wedge_sign, sb_type); - do_masked_motion_search(cpi, x, mask, mask_stride, bsize, - mi_row, mi_col, &tmp_mv[1], &rate_mv[1], - 1, mv_idx[1]); + do_masked_motion_search(cpi, x, mask, mask_stride, bsize, mi_row, mi_col, + &tmp_mv[1], &rate_mv[1], 1, mv_idx[1]); } } #endif // CONFIG_EXT_INTER @@ -6501,13 +6150,11 @@ static void do_masked_motion_search_indexed(VP10_COMP *cpi, MACROBLOCK *x, // However, once established that vector may be usable through the nearest and // near mv modes to reduce distortion in subsequent blocks and also improve // visual quality. -static int discount_newmv_test(const VP10_COMP *cpi, - int this_mode, +static int discount_newmv_test(const VP10_COMP *cpi, int this_mode, int_mv this_mv, int_mv (*mode_mv)[TOTAL_REFS_PER_FRAME], int ref_frame) { - return (!cpi->rc.is_src_frame_alt_ref && - (this_mode == NEWMV) && + return (!cpi->rc.is_src_frame_alt_ref && (this_mode == NEWMV) && (this_mv.as_int != 0) && ((mode_mv[NEARESTMV][ref_frame].as_int == 0) || (mode_mv[NEARESTMV][ref_frame].as_int == INVALID_MV)) && @@ -6516,23 +6163,21 @@ static int discount_newmv_test(const VP10_COMP *cpi, } #define LEFT_TOP_MARGIN ((VPX_ENC_BORDER_IN_PIXELS - VPX_INTERP_EXTEND) << 3) -#define RIGHT_BOTTOM_MARGIN ((VPX_ENC_BORDER_IN_PIXELS -\ - VPX_INTERP_EXTEND) << 3) +#define RIGHT_BOTTOM_MARGIN \ + ((VPX_ENC_BORDER_IN_PIXELS - VPX_INTERP_EXTEND) << 3) // TODO(jingning): this mv clamping function should be block size dependent. static INLINE void clamp_mv2(MV *mv, const MACROBLOCKD *xd) { clamp_mv(mv, xd->mb_to_left_edge - LEFT_TOP_MARGIN, - xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN, - xd->mb_to_top_edge - LEFT_TOP_MARGIN, - xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN); + xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN, + xd->mb_to_top_edge - LEFT_TOP_MARGIN, + xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN); } #if CONFIG_EXT_INTER -static int estimate_wedge_sign(const VP10_COMP *cpi, - const MACROBLOCK *x, - const BLOCK_SIZE bsize, - const uint8_t *pred0, int stride0, - const uint8_t *pred1, int stride1) { +static int estimate_wedge_sign(const VP10_COMP *cpi, const MACROBLOCK *x, + const BLOCK_SIZE bsize, const uint8_t *pred0, + int stride0, const uint8_t *pred1, int stride1) { const struct macroblock_plane *const p = &x->plane[0]; const uint8_t *src = p->src.buf; int src_stride = p->src.stride; @@ -6549,31 +6194,23 @@ static int estimate_wedge_sign(const VP10_COMP *cpi, } #endif // CONFIG_VP9_HIGHBITDEPTH - var = cpi->fn_ptr[f_index].vf( - src, src_stride, - pred0, stride0, &esq[0][0]); - var = cpi->fn_ptr[f_index].vf( - src + bw / 2, src_stride, - pred0 + bw / 2, stride0, &esq[0][1]); - var = cpi->fn_ptr[f_index].vf( - src + bh / 2 * src_stride, src_stride, - pred0 + bh / 2 * stride0, stride0, &esq[0][2]); - var = cpi->fn_ptr[f_index].vf( - src + bh / 2 * src_stride + bw / 2, src_stride, - pred0 + bh / 2 * stride0 + bw / 2, stride0, &esq[0][3]); - var = cpi->fn_ptr[f_index].vf( - src, src_stride, - pred1, stride1, &esq[1][0]); - var = cpi->fn_ptr[f_index].vf( - src + bw / 2, src_stride, - pred1 + bw / 2, stride1, &esq[1][1]); - var = cpi->fn_ptr[f_index].vf( - src + bh / 2 * src_stride, src_stride, - pred1 + bh / 2 * stride1, stride0, &esq[1][2]); - var = cpi->fn_ptr[f_index].vf( - src + bh / 2 * src_stride + bw / 2, src_stride, - pred1 + bh / 2 * stride1 + bw / 2, stride0, &esq[1][3]); - (void) var; + var = cpi->fn_ptr[f_index].vf(src, src_stride, pred0, stride0, &esq[0][0]); + var = cpi->fn_ptr[f_index].vf(src + bw / 2, src_stride, pred0 + bw / 2, + stride0, &esq[0][1]); + var = cpi->fn_ptr[f_index].vf(src + bh / 2 * src_stride, src_stride, + pred0 + bh / 2 * stride0, stride0, &esq[0][2]); + var = cpi->fn_ptr[f_index].vf(src + bh / 2 * src_stride + bw / 2, src_stride, + pred0 + bh / 2 * stride0 + bw / 2, stride0, + &esq[0][3]); + var = cpi->fn_ptr[f_index].vf(src, src_stride, pred1, stride1, &esq[1][0]); + var = cpi->fn_ptr[f_index].vf(src + bw / 2, src_stride, pred1 + bw / 2, + stride1, &esq[1][1]); + var = cpi->fn_ptr[f_index].vf(src + bh / 2 * src_stride, src_stride, + pred1 + bh / 2 * stride1, stride0, &esq[1][2]); + var = cpi->fn_ptr[f_index].vf(src + bh / 2 * src_stride + bw / 2, src_stride, + pred1 + bh / 2 * stride1 + bw / 2, stride0, + &esq[1][3]); + (void)var; tl = (int64_t)(esq[0][0] + esq[0][1] + esq[0][2]) - (int64_t)(esq[1][0] + esq[1][1] + esq[1][2]); @@ -6592,28 +6229,30 @@ static INTERP_FILTER predict_interp_filter( const VP10_COMMON *cm = &cpi->common; const MACROBLOCKD *xd = &x->e_mbd; int bsl = mi_width_log2_lookup[bsize]; - int pred_filter_search = cpi->sf.cb_pred_filter_search ? - (((mi_row + mi_col) >> bsl) + - get_chessboard_index(cm->current_video_frame)) & 0x1 : 0; + int pred_filter_search = + cpi->sf.cb_pred_filter_search + ? (((mi_row + mi_col) >> bsl) + + get_chessboard_index(cm->current_video_frame)) & + 0x1 + : 0; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; const int is_comp_pred = has_second_ref(mbmi); const int this_mode = mbmi->mode; int refs[2] = { mbmi->ref_frame[0], - (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) }; + (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) }; #if CONFIG_DUAL_FILTER (void)pred_filter_search; return SWITCHABLE; #else if (pred_filter_search) { INTERP_FILTER af = SWITCHABLE, lf = SWITCHABLE; - if (xd->up_available) - af = xd->mi[-xd->mi_stride]->mbmi.interp_filter; - if (xd->left_available) - lf = xd->mi[-1]->mbmi.interp_filter; + if (xd->up_available) af = xd->mi[-xd->mi_stride]->mbmi.interp_filter; + if (xd->left_available) lf = xd->mi[-1]->mbmi.interp_filter; #if CONFIG_EXT_INTER if ((this_mode != NEWMV && this_mode != NEWFROMNEARMV && - this_mode != NEW_NEWMV) || (af == lf)) + this_mode != NEW_NEWMV) || + (af == lf)) #else if ((this_mode != NEWMV) || (af == lf)) #endif // CONFIG_EXT_INTER @@ -6640,18 +6279,15 @@ static INTERP_FILTER predict_interp_filter( best_filter = single_filter[NEARMV][refs[0]]; break; case NEAR_NEARMV: - if (single_filter[NEARMV][refs[0]] == - single_filter[NEARMV][refs[1]]) + if (single_filter[NEARMV][refs[0]] == single_filter[NEARMV][refs[1]]) best_filter = single_filter[NEARMV][refs[0]]; break; case ZERO_ZEROMV: - if (single_filter[ZEROMV][refs[0]] == - single_filter[ZEROMV][refs[1]]) + if (single_filter[ZEROMV][refs[0]] == single_filter[ZEROMV][refs[1]]) best_filter = single_filter[ZEROMV][refs[0]]; break; case NEW_NEWMV: - if (single_filter[NEWMV][refs[0]] == - single_filter[NEWMV][refs[1]]) + if (single_filter[NEWMV][refs[0]] == single_filter[NEWMV][refs[1]]) best_filter = single_filter[NEWMV][refs[0]]; break; case NEAREST_NEWMV: @@ -6660,8 +6296,7 @@ static INTERP_FILTER predict_interp_filter( best_filter = single_filter[NEARESTMV][refs[0]]; break; case NEAR_NEWMV: - if (single_filter[NEARMV][refs[0]] == - single_filter[NEWMV][refs[1]]) + if (single_filter[NEARMV][refs[0]] == single_filter[NEWMV][refs[1]]) best_filter = single_filter[NEARMV][refs[0]]; break; case NEW_NEARESTMV: @@ -6670,8 +6305,7 @@ static INTERP_FILTER predict_interp_filter( best_filter = single_filter[NEWMV][refs[0]]; break; case NEW_NEARMV: - if (single_filter[NEWMV][refs[0]] == - single_filter[NEARMV][refs[1]]) + if (single_filter[NEWMV][refs[0]] == single_filter[NEARMV][refs[1]]) best_filter = single_filter[NEWMV][refs[0]]; break; default: @@ -6703,12 +6337,9 @@ static INTERP_FILTER predict_interp_filter( #if CONFIG_EXT_INTER // Choose the best wedge index and sign -static int64_t pick_wedge(const VP10_COMP *const cpi, - const MACROBLOCK *const x, - const BLOCK_SIZE bsize, - const uint8_t *const p0, - const uint8_t *const p1, - int *const best_wedge_sign, +static int64_t pick_wedge(const VP10_COMP *const cpi, const MACROBLOCK *const x, + const BLOCK_SIZE bsize, const uint8_t *const p0, + const uint8_t *const p1, int *const best_wedge_sign, int *const best_wedge_index) { const MACROBLOCKD *const xd = &x->e_mbd; const struct buf_2d *const src = &x->plane[0].src; @@ -6743,20 +6374,19 @@ static int64_t pick_wedge(const VP10_COMP *const cpi, CONVERT_TO_BYTEPTR(p0), bw, xd->bd); vpx_highbd_subtract_block(bh, bw, r1, bw, src->buf, src->stride, CONVERT_TO_BYTEPTR(p1), bw, xd->bd); - vpx_highbd_subtract_block(bh, bw, d10, bw, - CONVERT_TO_BYTEPTR(p1), bw, + vpx_highbd_subtract_block(bh, bw, d10, bw, CONVERT_TO_BYTEPTR(p1), bw, CONVERT_TO_BYTEPTR(p0), bw, xd->bd); } else // NOLINT -#endif // CONFIG_VP9_HIGHBITDEPTH +#endif // CONFIG_VP9_HIGHBITDEPTH { vpx_subtract_block(bh, bw, r0, bw, src->buf, src->stride, p0, bw); vpx_subtract_block(bh, bw, r1, bw, src->buf, src->stride, p1, bw); vpx_subtract_block(bh, bw, d10, bw, p1, bw, p0, bw); } - sign_limit = ((int64_t)vpx_sum_squares_i16(r0, N) - - (int64_t)vpx_sum_squares_i16(r1, N)) - * (1 << WEDGE_WEIGHT_BITS) / 2; + sign_limit = ((int64_t)vpx_sum_squares_i16(r0, N) - + (int64_t)vpx_sum_squares_i16(r1, N)) * + (1 << WEDGE_WEIGHT_BITS) / 2; vp10_wedge_compute_delta_squares(ds, r0, r1, N); @@ -6769,7 +6399,7 @@ static int64_t pick_wedge(const VP10_COMP *const cpi, sse = ROUND_POWER_OF_TWO(sse, bd_round); model_rd_from_sse(cpi, xd, bsize, 0, sse, &rate, &dist); - rd = RDCOST(x->rdmult, x->rddiv, rate, dist); + rd = RDCOST(x->rdmult, x->rddiv, rate, dist); if (rd < best_rd) { *best_wedge_index = wedge_index; @@ -6782,13 +6412,10 @@ static int64_t pick_wedge(const VP10_COMP *const cpi, } // Choose the best wedge index the specified sign -static int64_t pick_wedge_fixed_sign(const VP10_COMP *const cpi, - const MACROBLOCK *const x, - const BLOCK_SIZE bsize, - const uint8_t *const p0, - const uint8_t *const p1, - const int wedge_sign, - int *const best_wedge_index) { +static int64_t pick_wedge_fixed_sign( + const VP10_COMP *const cpi, const MACROBLOCK *const x, + const BLOCK_SIZE bsize, const uint8_t *const p0, const uint8_t *const p1, + const int wedge_sign, int *const best_wedge_index) { const MACROBLOCKD *const xd = &x->e_mbd; const struct buf_2d *const src = &x->plane[0].src; const int bw = 4 * num_4x4_blocks_wide_lookup[bsize]; @@ -6815,11 +6442,10 @@ static int64_t pick_wedge_fixed_sign(const VP10_COMP *const cpi, if (hbd) { vpx_highbd_subtract_block(bh, bw, r1, bw, src->buf, src->stride, CONVERT_TO_BYTEPTR(p1), bw, xd->bd); - vpx_highbd_subtract_block(bh, bw, d10, bw, - CONVERT_TO_BYTEPTR(p1), bw, + vpx_highbd_subtract_block(bh, bw, d10, bw, CONVERT_TO_BYTEPTR(p1), bw, CONVERT_TO_BYTEPTR(p0), bw, xd->bd); } else // NOLINT -#endif // CONFIG_VP9_HIGHBITDEPTH +#endif // CONFIG_VP9_HIGHBITDEPTH { vpx_subtract_block(bh, bw, r1, bw, src->buf, src->stride, p1, bw); vpx_subtract_block(bh, bw, d10, bw, p1, bw, p0, bw); @@ -6831,7 +6457,7 @@ static int64_t pick_wedge_fixed_sign(const VP10_COMP *const cpi, sse = ROUND_POWER_OF_TWO(sse, bd_round); model_rd_from_sse(cpi, xd, bsize, 0, sse, &rate, &dist); - rd = RDCOST(x->rdmult, x->rddiv, rate, dist); + rd = RDCOST(x->rdmult, x->rddiv, rate, dist); if (rd < best_rd) { *best_wedge_index = wedge_index; @@ -6893,12 +6519,11 @@ static int64_t pick_interintra_wedge(const VP10_COMP *const cpi, static int64_t handle_inter_mode( VP10_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int *rate2, int64_t *distortion, int *skippable, int *rate_y, int *rate_uv, - int *disable_skip, int_mv (*mode_mv)[TOTAL_REFS_PER_FRAME], - int mi_row, int mi_col, + int *disable_skip, int_mv (*mode_mv)[TOTAL_REFS_PER_FRAME], int mi_row, + int mi_col, #if CONFIG_OBMC - uint8_t *dst_buf1[3], int dst_stride1[3], - uint8_t *dst_buf2[3], int dst_stride2[3], - const int32_t *const wsrc, const int32_t *const mask2d, + uint8_t *dst_buf1[3], int dst_stride1[3], uint8_t *dst_buf2[3], + int dst_stride2[3], const int32_t *const wsrc, const int32_t *const mask2d, #endif // CONFIG_OBMC #if CONFIG_EXT_INTER int_mv single_newmvs[2][TOTAL_REFS_PER_FRAME], @@ -6909,8 +6534,8 @@ static int64_t handle_inter_mode( int_mv single_newmv[TOTAL_REFS_PER_FRAME], #endif // CONFIG_EXT_INTER INTERP_FILTER (*single_filter)[TOTAL_REFS_PER_FRAME], - int (*single_skippable)[TOTAL_REFS_PER_FRAME], - int64_t *psse, const int64_t ref_best_rd) { + int (*single_skippable)[TOTAL_REFS_PER_FRAME], int64_t *psse, + const int64_t ref_best_rd) { VP10_COMMON *cm = &cpi->common; MACROBLOCKD *xd = &x->e_mbd; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; @@ -6920,7 +6545,7 @@ static int64_t handle_inter_mode( int_mv *frame_mv = mode_mv[this_mode]; int i; int refs[2] = { mbmi->ref_frame[0], - (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) }; + (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) }; int_mv cur_mv[2]; int rate_mv = 0; #if CONFIG_EXT_INTER @@ -6928,7 +6553,7 @@ static int64_t handle_inter_mode( int mv_idx = (this_mode == NEWFROMNEARMV) ? 1 : 0; int_mv single_newmv[TOTAL_REFS_PER_FRAME]; const unsigned int *const interintra_mode_cost = - cpi->interintra_mode_cost[size_group_lookup[bsize]]; + cpi->interintra_mode_cost[size_group_lookup[bsize]]; const int is_comp_interintra_pred = (mbmi->ref_frame[1] == INTRA_FRAME); #if CONFIG_REF_MV uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame); @@ -6947,8 +6572,8 @@ static int64_t handle_inter_mode( !is_comp_interintra_pred && #endif // CONFIG_EXT_INTER is_motvar_allowed(mbmi); - int rate2_nocoeff, best_rate2 = INT_MAX, - best_skippable, best_xskip, best_disable_skip = 0; + int rate2_nocoeff, best_rate2 = INT_MAX, best_skippable, best_xskip, + best_disable_skip = 0; int best_rate_y, best_rate_uv; #if CONFIG_VAR_TX uint8_t best_blk_skip[MAX_MB_PLANE][MAX_MIB_SIZE * MAX_MIB_SIZE * 4]; @@ -6973,8 +6598,8 @@ static int64_t handle_inter_mode( // Index use case: // {0, 1} -> (vertical, horizontal) filter types for the first ref frame // {2, 3} -> (vertical, horizontal) filter types for the second ref frame - INTERP_FILTER best_filter[4] = {SWITCHABLE, SWITCHABLE, - SWITCHABLE, SWITCHABLE, + INTERP_FILTER best_filter[4] = { + SWITCHABLE, SWITCHABLE, SWITCHABLE, SWITCHABLE, }; #else INTERP_FILTER best_filter = SWITCHABLE; @@ -7003,8 +6628,8 @@ static int64_t handle_inter_mode( mode_ctx = mbmi_ext->compound_mode_context[refs[0]]; else #endif // CONFIG_EXT_INTER - mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context, - mbmi->ref_frame, bsize, -1); + mode_ctx = vp10_mode_context_analyzer(mbmi_ext->mode_context, + mbmi->ref_frame, bsize, -1); #endif #if CONFIG_VP9_HIGHBITDEPTH @@ -7024,8 +6649,7 @@ static int64_t handle_inter_mode( if (is_comp_pred) { #if CONFIG_EXT_INTER for (i = 0; i < 2; ++i) { - single_newmv[refs[i]].as_int = - single_newmvs[mv_idx][refs[i]].as_int; + single_newmv[refs[i]].as_int = single_newmvs[mv_idx][refs[i]].as_int; } if (this_mode == NEW_NEWMV) { @@ -7033,23 +6657,21 @@ static int64_t handle_inter_mode( frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int; if (cpi->sf.comp_inter_joint_search_thresh <= bsize) { - joint_motion_search(cpi, x, bsize, frame_mv, - mi_row, mi_col, NULL, single_newmv, &rate_mv, 0); + joint_motion_search(cpi, x, bsize, frame_mv, mi_row, mi_col, NULL, + single_newmv, &rate_mv, 0); } else { #if CONFIG_REF_MV vp10_set_mvcost(x, mbmi->ref_frame[0]); #endif // CONFIG_REF_MV - rate_mv = vp10_mv_bit_cost(&frame_mv[refs[0]].as_mv, - &x->mbmi_ext->ref_mvs[refs[0]][0].as_mv, - x->nmvjointcost, x->mvcost, - MV_COST_WEIGHT); + rate_mv = vp10_mv_bit_cost( + &frame_mv[refs[0]].as_mv, &x->mbmi_ext->ref_mvs[refs[0]][0].as_mv, + x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); #if CONFIG_REF_MV vp10_set_mvcost(x, mbmi->ref_frame[1]); #endif // CONFIG_REF_MV - rate_mv += vp10_mv_bit_cost(&frame_mv[refs[1]].as_mv, - &x->mbmi_ext->ref_mvs[refs[1]][0].as_mv, - x->nmvjointcost, x->mvcost, - MV_COST_WEIGHT); + rate_mv += vp10_mv_bit_cost( + &frame_mv[refs[1]].as_mv, &x->mbmi_ext->ref_mvs[refs[1]][0].as_mv, + x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); } } else if (this_mode == NEAREST_NEWMV || this_mode == NEAR_NEWMV) { frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int; @@ -7068,22 +6690,21 @@ static int64_t handle_inter_mode( frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int; if (cpi->sf.comp_inter_joint_search_thresh <= bsize) { - joint_motion_search(cpi, x, bsize, frame_mv, - mi_row, mi_col, + joint_motion_search(cpi, x, bsize, frame_mv, mi_row, mi_col, single_newmv, &rate_mv, 0); } else { #if CONFIG_REF_MV vp10_set_mvcost(x, mbmi->ref_frame[0]); #endif // CONFIG_REF_MV - rate_mv = vp10_mv_bit_cost(&frame_mv[refs[0]].as_mv, + rate_mv = vp10_mv_bit_cost(&frame_mv[refs[0]].as_mv, &x->mbmi_ext->ref_mvs[refs[0]][0].as_mv, x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); #if CONFIG_REF_MV vp10_set_mvcost(x, mbmi->ref_frame[1]); #endif // CONFIG_REF_MV rate_mv += vp10_mv_bit_cost(&frame_mv[refs[1]].as_mv, - &x->mbmi_ext->ref_mvs[refs[1]][0].as_mv, - x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); + &x->mbmi_ext->ref_mvs[refs[1]][0].as_mv, + x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); } #endif // CONFIG_EXT_INTER } else { @@ -7092,8 +6713,8 @@ static int64_t handle_inter_mode( x->best_mv = single_newmvs[mv_idx][refs[0]]; rate_mv = single_newmvs_rate[mv_idx][refs[0]]; } else { - single_motion_search(cpi, x, bsize, mi_row, mi_col, - 0, mv_idx, &rate_mv); + single_motion_search(cpi, x, bsize, mi_row, mi_col, 0, mv_idx, + &rate_mv); single_newmvs[mv_idx][refs[0]] = x->best_mv; single_newmvs_rate[mv_idx][refs[0]] = rate_mv; } @@ -7102,8 +6723,7 @@ static int64_t handle_inter_mode( single_newmv[refs[0]] = x->best_mv; #endif // CONFIG_EXT_INTER - if (x->best_mv.as_int == INVALID_MV) - return INT64_MAX; + if (x->best_mv.as_int == INVALID_MV) return INT64_MAX; frame_mv[refs[0]] = x->best_mv; xd->mi[0]->bmi[0].as_mv[0] = x->best_mv; @@ -7121,7 +6741,7 @@ static int64_t handle_inter_mode( for (i = 0; i < is_comp_pred + 1; ++i) { cur_mv[i] = frame_mv[refs[i]]; - // Clip "next_nearest" so that it does not extend to far out of image +// Clip "next_nearest" so that it does not extend to far out of image #if CONFIG_EXT_INTER if (this_mode != NEWMV && this_mode != NEWFROMNEARMV) #else @@ -7129,8 +6749,7 @@ static int64_t handle_inter_mode( #endif // CONFIG_EXT_INTER clamp_mv2(&cur_mv[i].as_mv, xd); - if (mv_check_bounds(x, &cur_mv[i].as_mv)) - return INT64_MAX; + if (mv_check_bounds(x, &cur_mv[i].as_mv)) return INT64_MAX; mbmi->mv[i].as_int = cur_mv[i].as_int; } @@ -7147,8 +6766,7 @@ static int64_t handle_inter_mode( for (i = 0; i < 2; ++i) { clamp_mv2(&cur_mv[i].as_mv, xd); - if (mv_check_bounds(x, &cur_mv[i].as_mv)) - return INT64_MAX; + if (mv_check_bounds(x, &cur_mv[i].as_mv)) return INT64_MAX; mbmi->mv[i].as_int = cur_mv[i].as_int; } } @@ -7161,8 +6779,7 @@ static int64_t handle_inter_mode( lower_mv_precision(&cur_mv[0].as_mv, cm->allow_high_precision_mv); clamp_mv2(&cur_mv[0].as_mv, xd); - if (mv_check_bounds(x, &cur_mv[0].as_mv)) - return INT64_MAX; + if (mv_check_bounds(x, &cur_mv[0].as_mv)) return INT64_MAX; mbmi->mv[0].as_int = cur_mv[0].as_int; } @@ -7171,34 +6788,29 @@ static int64_t handle_inter_mode( lower_mv_precision(&cur_mv[1].as_mv, cm->allow_high_precision_mv); clamp_mv2(&cur_mv[1].as_mv, xd); - if (mv_check_bounds(x, &cur_mv[1].as_mv)) - return INT64_MAX; + if (mv_check_bounds(x, &cur_mv[1].as_mv)) return INT64_MAX; mbmi->mv[1].as_int = cur_mv[1].as_int; } } if (mbmi_ext->ref_mv_count[ref_frame_type] > 1) { - if (this_mode == NEAR_NEWMV || - this_mode == NEAR_NEARESTMV || + if (this_mode == NEAR_NEWMV || this_mode == NEAR_NEARESTMV || this_mode == NEAR_NEARMV) { cur_mv[0] = mbmi_ext->ref_mv_stack[ref_frame_type][1].this_mv; lower_mv_precision(&cur_mv[0].as_mv, cm->allow_high_precision_mv); clamp_mv2(&cur_mv[0].as_mv, xd); - if (mv_check_bounds(x, &cur_mv[0].as_mv)) - return INT64_MAX; + if (mv_check_bounds(x, &cur_mv[0].as_mv)) return INT64_MAX; mbmi->mv[0].as_int = cur_mv[0].as_int; } - if (this_mode == NEW_NEARMV || - this_mode == NEAREST_NEARMV || + if (this_mode == NEW_NEARMV || this_mode == NEAREST_NEARMV || this_mode == NEAR_NEARMV) { cur_mv[1] = mbmi_ext->ref_mv_stack[ref_frame_type][1].comp_mv; lower_mv_precision(&cur_mv[1].as_mv, cm->allow_high_precision_mv); clamp_mv2(&cur_mv[1].as_mv, xd); - if (mv_check_bounds(x, &cur_mv[1].as_mv)) - return INT64_MAX; + if (mv_check_bounds(x, &cur_mv[1].as_mv)) return INT64_MAX; mbmi->mv[1].as_int = cur_mv[1].as_int; } } @@ -7212,8 +6824,7 @@ static int64_t handle_inter_mode( for (i = 0; i < 2; ++i) { clamp_mv2(&cur_mv[i].as_mv, xd); - if (mv_check_bounds(x, &cur_mv[i].as_mv)) - return INT64_MAX; + if (mv_check_bounds(x, &cur_mv[i].as_mv)) return INT64_MAX; mbmi->mv[i].as_int = cur_mv[i].as_int; } } @@ -7238,8 +6849,8 @@ static int64_t handle_inter_mode( // // Under some circumstances we discount the cost of new mv mode to encourage // initiation of a motion field. - if (discount_newmv_test(cpi, this_mode, frame_mv[refs[0]], - mode_mv, refs[0])) { + if (discount_newmv_test(cpi, this_mode, frame_mv[refs[0]], mode_mv, + refs[0])) { #if CONFIG_REF_MV && CONFIG_EXT_INTER *rate2 += VPXMIN(cost_mv_ref(cpi, this_mode, is_comp_pred, mode_ctx), cost_mv_ref(cpi, NEARESTMV, is_comp_pred, mode_ctx)); @@ -7261,18 +6872,17 @@ static int64_t handle_inter_mode( #else mbmi->mode != NEARESTMV #endif // CONFIG_EXT_INTER - ) + ) return INT64_MAX; pred_exists = 0; // Are all MVs integer pel for Y and UV intpel_mv = !mv_has_subpel(&mbmi->mv[0].as_mv); - if (is_comp_pred) - intpel_mv &= !mv_has_subpel(&mbmi->mv[1].as_mv); + if (is_comp_pred) intpel_mv &= !mv_has_subpel(&mbmi->mv[1].as_mv); #if !CONFIG_DUAL_FILTER - best_filter = predict_interp_filter(cpi, x, bsize, mi_row, mi_col, - single_filter); + best_filter = + predict_interp_filter(cpi, x, bsize, mi_row, mi_col, single_filter); #endif if (cm->interp_filter != BILINEAR) { @@ -7307,8 +6917,7 @@ static int64_t handle_inter_mode( if (i > 0 && intpel_mv && IsInterpolatingFilter(i)) { rd = RDCOST(x->rdmult, x->rddiv, tmp_rate_sum, tmp_dist_sum); - if (cm->interp_filter == SWITCHABLE) - rd += rs_rd; + if (cm->interp_filter == SWITCHABLE) rd += rs_rd; } else { int rate_sum = 0; int64_t dist_sum = 0; @@ -7320,20 +6929,18 @@ static int64_t handle_inter_mode( continue; } - if ((cm->interp_filter == SWITCHABLE && - (!i || best_needs_copy)) || + if ((cm->interp_filter == SWITCHABLE && (!i || best_needs_copy)) || #if CONFIG_EXT_INTER is_comp_interintra_pred || #endif // CONFIG_EXT_INTER (cm->interp_filter != SWITCHABLE && ( #if CONFIG_DUAL_FILTER - cm->interp_filter == mbmi->interp_filter[0] + cm->interp_filter == mbmi->interp_filter[0] #else - cm->interp_filter == mbmi->interp_filter + cm->interp_filter == mbmi->interp_filter #endif - || - (i == 0 && intpel_mv && IsInterpolatingFilter(i))))) { + || (i == 0 && intpel_mv && IsInterpolatingFilter(i))))) { restore_dst_buf(xd, orig_dst, orig_dst_stride); } else { for (j = 0; j < MAX_MB_PLANE; j++) { @@ -7342,12 +6949,11 @@ static int64_t handle_inter_mode( } } vp10_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); - model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, - &rate_sum, &dist_sum, &tmp_skip_sb, &tmp_skip_sse); + model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, &rate_sum, + &dist_sum, &tmp_skip_sb, &tmp_skip_sse); rd = RDCOST(x->rdmult, x->rddiv, rate_sum, dist_sum); - if (cm->interp_filter == SWITCHABLE) - rd += rs_rd; + if (cm->interp_filter == SWITCHABLE) rd += rs_rd; if (i == 0 && intpel_mv && IsInterpolatingFilter(i)) { tmp_rate_sum = rate_sum; @@ -7397,21 +7003,21 @@ static int64_t handle_inter_mode( restore_dst_buf(xd, orig_dst, orig_dst_stride); } - // Set the appropriate filter +// Set the appropriate filter #if CONFIG_DUAL_FILTER - mbmi->interp_filter[0] = cm->interp_filter != SWITCHABLE ? - cm->interp_filter : best_filter[0]; - mbmi->interp_filter[1] = cm->interp_filter != SWITCHABLE ? - cm->interp_filter : best_filter[1]; + mbmi->interp_filter[0] = + cm->interp_filter != SWITCHABLE ? cm->interp_filter : best_filter[0]; + mbmi->interp_filter[1] = + cm->interp_filter != SWITCHABLE ? cm->interp_filter : best_filter[1]; if (mbmi->ref_frame[1] > INTRA_FRAME) { - mbmi->interp_filter[2] = cm->interp_filter != SWITCHABLE ? - cm->interp_filter : best_filter[2]; - mbmi->interp_filter[3] = cm->interp_filter != SWITCHABLE ? - cm->interp_filter : best_filter[3]; + mbmi->interp_filter[2] = + cm->interp_filter != SWITCHABLE ? cm->interp_filter : best_filter[2]; + mbmi->interp_filter[3] = + cm->interp_filter != SWITCHABLE ? cm->interp_filter : best_filter[3]; } #else - mbmi->interp_filter = cm->interp_filter != SWITCHABLE ? - cm->interp_filter : best_filter; + mbmi->interp_filter = + cm->interp_filter != SWITCHABLE ? cm->interp_filter : best_filter; #endif rs = cm->interp_filter == SWITCHABLE ? vp10_get_switchable_rate(cpi, xd) : 0; @@ -7420,8 +7026,7 @@ static int64_t handle_inter_mode( best_bmc_mbmi = *mbmi; rate_mv_bmc = rate_mv; rate2_bmc_nocoeff = *rate2; - if (cm->interp_filter == SWITCHABLE) - rate2_bmc_nocoeff += rs; + if (cm->interp_filter == SWITCHABLE) rate2_bmc_nocoeff += rs; #endif // CONFIG_OBMC if (is_comp_pred && is_interinter_wedge_used(bsize)) { @@ -7437,8 +7042,7 @@ static int64_t handle_inter_mode( vp10_build_inter_predictors_sby(xd, mi_row, mi_col, bsize); vp10_subtract_plane(x, bsize, 0); rd = estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum, - &tmp_skip_txfm_sb, &tmp_skip_sse_sb, - INT64_MAX); + &tmp_skip_txfm_sb, &tmp_skip_sse_sb, INT64_MAX); if (rd != INT64_MAX) rd = RDCOST(x->rdmult, x->rddiv, rs + rate_mv + rate_sum, dist_sum); best_rd_nowedge = rd; @@ -7448,16 +7052,16 @@ static int64_t handle_inter_mode( best_rd_nowedge / 3 < ref_best_rd) { uint8_t pred0[2 * MAX_SB_SQUARE]; uint8_t pred1[2 * MAX_SB_SQUARE]; - uint8_t *preds0[1] = {pred0}; - uint8_t *preds1[1] = {pred1}; - int strides[1] = {bw}; + uint8_t *preds0[1] = { pred0 }; + uint8_t *preds1[1] = { pred1 }; + int strides[1] = { bw }; mbmi->use_wedge_interinter = 1; rs = vp10_cost_literal(get_interinter_wedge_bits(bsize)) + - vp10_cost_bit(cm->fc->wedge_interinter_prob[bsize], 1); + vp10_cost_bit(cm->fc->wedge_interinter_prob[bsize], 1); vp10_build_inter_predictors_for_planes_single_buf( - xd, bsize, 0, 0, mi_row, mi_col, 0, preds0, strides); + xd, bsize, 0, 0, mi_row, mi_col, 0, preds0, strides); vp10_build_inter_predictors_for_planes_single_buf( xd, bsize, 0, 0, mi_row, mi_col, 1, preds1, strides); @@ -7469,31 +7073,25 @@ static int64_t handle_inter_mode( int_mv tmp_mv[2]; int rate_mvs[2], tmp_rate_mv = 0; if (this_mode == NEW_NEWMV) { - int mv_idxs[2] = {0, 0}; - do_masked_motion_search_indexed(cpi, x, - mbmi->interinter_wedge_index, - mbmi->interinter_wedge_sign, - bsize, mi_row, mi_col, tmp_mv, rate_mvs, - mv_idxs, 2); + int mv_idxs[2] = { 0, 0 }; + do_masked_motion_search_indexed( + cpi, x, mbmi->interinter_wedge_index, mbmi->interinter_wedge_sign, + bsize, mi_row, mi_col, tmp_mv, rate_mvs, mv_idxs, 2); tmp_rate_mv = rate_mvs[0] + rate_mvs[1]; mbmi->mv[0].as_int = tmp_mv[0].as_int; mbmi->mv[1].as_int = tmp_mv[1].as_int; } else if (this_mode == NEW_NEARESTMV || this_mode == NEW_NEARMV) { - int mv_idxs[2] = {0, 0}; - do_masked_motion_search_indexed(cpi, x, - mbmi->interinter_wedge_index, - mbmi->interinter_wedge_sign, - bsize, mi_row, mi_col, tmp_mv, rate_mvs, - mv_idxs, 0); + int mv_idxs[2] = { 0, 0 }; + do_masked_motion_search_indexed( + cpi, x, mbmi->interinter_wedge_index, mbmi->interinter_wedge_sign, + bsize, mi_row, mi_col, tmp_mv, rate_mvs, mv_idxs, 0); tmp_rate_mv = rate_mvs[0]; mbmi->mv[0].as_int = tmp_mv[0].as_int; } else if (this_mode == NEAREST_NEWMV || this_mode == NEAR_NEWMV) { - int mv_idxs[2] = {0, 0}; - do_masked_motion_search_indexed(cpi, x, - mbmi->interinter_wedge_index, - mbmi->interinter_wedge_sign, - bsize, mi_row, mi_col, tmp_mv, rate_mvs, - mv_idxs, 1); + int mv_idxs[2] = { 0, 0 }; + do_masked_motion_search_indexed( + cpi, x, mbmi->interinter_wedge_index, mbmi->interinter_wedge_sign, + bsize, mi_row, mi_col, tmp_mv, rate_mvs, mv_idxs, 1); tmp_rate_mv = rate_mvs[1]; mbmi->mv[1].as_int = tmp_mv[1].as_int; } @@ -7507,17 +7105,16 @@ static int64_t handle_inter_mode( mbmi->mv[0].as_int = cur_mv[0].as_int; mbmi->mv[1].as_int = cur_mv[1].as_int; tmp_rate_mv = rate_mv; - vp10_build_wedge_inter_predictor_from_buf(xd, bsize, 0, 0, - preds0, strides, - preds1, strides); + vp10_build_wedge_inter_predictor_from_buf(xd, bsize, 0, 0, preds0, + strides, preds1, strides); } vp10_subtract_plane(x, bsize, 0); - rd = estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum, - &tmp_skip_txfm_sb, &tmp_skip_sse_sb, - INT64_MAX); + rd = + estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum, + &tmp_skip_txfm_sb, &tmp_skip_sse_sb, INT64_MAX); if (rd != INT64_MAX) - rd = RDCOST(x->rdmult, x->rddiv, - rs + tmp_rate_mv + rate_sum, dist_sum); + rd = RDCOST(x->rdmult, x->rddiv, rs + tmp_rate_mv + rate_sum, + dist_sum); best_rd_wedge = rd; if (best_rd_wedge < best_rd_nowedge) { @@ -7534,17 +7131,15 @@ static int64_t handle_inter_mode( xd->mi[0]->bmi[0].as_mv[1].as_int = mbmi->mv[1].as_int; } } else { - vp10_build_wedge_inter_predictor_from_buf(xd, bsize, - 0, 0, - preds0, strides, - preds1, strides); + vp10_build_wedge_inter_predictor_from_buf(xd, bsize, 0, 0, preds0, + strides, preds1, strides); vp10_subtract_plane(x, bsize, 0); - rd = estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum, - &tmp_skip_txfm_sb, &tmp_skip_sse_sb, - INT64_MAX); + rd = + estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum, + &tmp_skip_txfm_sb, &tmp_skip_sse_sb, INT64_MAX); if (rd != INT64_MAX) - rd = RDCOST(x->rdmult, x->rddiv, rs + rate_mv + rate_sum, dist_sum); - best_rd_wedge = rd; + rd = RDCOST(x->rdmult, x->rddiv, rs + rate_mv + rate_sum, dist_sum); + best_rd_wedge = rd; if (best_rd_wedge < best_rd_nowedge) { mbmi->use_wedge_interinter = 1; } else { @@ -7604,10 +7199,8 @@ static int64_t handle_inter_mode( for (j = 0; j < INTERINTRA_MODES; ++j) { mbmi->interintra_mode = (INTERINTRA_MODE)j; rmode = interintra_mode_cost[mbmi->interintra_mode]; - vp10_build_intra_predictors_for_interintra( - xd, bsize, 0, intrapred, bw); - vp10_combine_interintra(xd, bsize, 0, tmp_buf, bw, - intrapred, bw); + vp10_build_intra_predictors_for_interintra(xd, bsize, 0, intrapred, bw); + vp10_combine_interintra(xd, bsize, 0, tmp_buf, bw, intrapred, bw); model_rd_for_sb(cpi, bsize, x, xd, 0, 0, &rate_sum, &dist_sum, &tmp_skip_txfm_sb, &tmp_skip_sse_sb); rd = RDCOST(x->rdmult, x->rddiv, rs + tmp_rate_mv + rate_sum, dist_sum); @@ -7618,27 +7211,23 @@ static int64_t handle_inter_mode( } mbmi->interintra_mode = best_interintra_mode; rmode = interintra_mode_cost[mbmi->interintra_mode]; - vp10_build_intra_predictors_for_interintra( - xd, bsize, 0, intrapred, bw); - vp10_combine_interintra(xd, bsize, 0, tmp_buf, bw, - intrapred, bw); + vp10_build_intra_predictors_for_interintra(xd, bsize, 0, intrapred, bw); + vp10_combine_interintra(xd, bsize, 0, tmp_buf, bw, intrapred, bw); vp10_subtract_plane(x, bsize, 0); rd = estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum, - &tmp_skip_txfm_sb, &tmp_skip_sse_sb, - INT64_MAX); + &tmp_skip_txfm_sb, &tmp_skip_sse_sb, INT64_MAX); if (rd != INT64_MAX) rd = RDCOST(x->rdmult, x->rddiv, rate_mv + rmode + rate_sum, dist_sum); best_interintra_rd = rd; - if (ref_best_rd < INT64_MAX && - best_interintra_rd > 2 * ref_best_rd) { + if (ref_best_rd < INT64_MAX && best_interintra_rd > 2 * ref_best_rd) { return INT64_MAX; } if (is_interintra_wedge_used(bsize)) { rwedge = vp10_cost_bit(cm->fc->wedge_interintra_prob[bsize], 0); if (rd != INT64_MAX) - rd = RDCOST(x->rdmult, x->rddiv, - rmode + rate_mv + rwedge + rate_sum, dist_sum); + rd = RDCOST(x->rdmult, x->rddiv, rmode + rate_mv + rwedge + rate_sum, + dist_sum); best_interintra_rd_nowedge = rd; // Disbale wedge search if source variance is small @@ -7646,21 +7235,20 @@ static int64_t handle_inter_mode( mbmi->use_wedge_interintra = 1; rwedge = vp10_cost_literal(get_interintra_wedge_bits(bsize)) + - vp10_cost_bit(cm->fc->wedge_interintra_prob[bsize], 1); + vp10_cost_bit(cm->fc->wedge_interintra_prob[bsize], 1); - best_interintra_rd_wedge = pick_interintra_wedge(cpi, x, bsize, - intrapred_, tmp_buf_); + best_interintra_rd_wedge = + pick_interintra_wedge(cpi, x, bsize, intrapred_, tmp_buf_); - best_interintra_rd_wedge += RDCOST(x->rdmult, x->rddiv, - rmode + rate_mv + rwedge, 0); + best_interintra_rd_wedge += + RDCOST(x->rdmult, x->rddiv, rmode + rate_mv + rwedge, 0); // Refine motion vector. if (have_newmv_in_inter_mode(this_mode)) { // get negative of mask - const uint8_t* mask = vp10_get_contiguous_soft_mask( + const uint8_t *mask = vp10_get_contiguous_soft_mask( mbmi->interintra_wedge_index, 1, bsize); - do_masked_motion_search(cpi, x, mask, bw, bsize, - mi_row, mi_col, &tmp_mv, &tmp_rate_mv, - 0, mv_idx); + do_masked_motion_search(cpi, x, mask, bw, bsize, mi_row, mi_col, + &tmp_mv, &tmp_rate_mv, 0, mv_idx); mbmi->mv[0].as_int = tmp_mv.as_int; vp10_build_inter_predictors_sby(xd, mi_row, mi_col, bsize); model_rd_for_sb(cpi, bsize, x, xd, 0, 0, &rate_sum, &dist_sum, @@ -7676,15 +7264,13 @@ static int64_t handle_inter_mode( } else { tmp_mv.as_int = cur_mv[0].as_int; tmp_rate_mv = rate_mv; - vp10_combine_interintra(xd, bsize, 0, - tmp_buf, bw, - intrapred, bw); + vp10_combine_interintra(xd, bsize, 0, tmp_buf, bw, intrapred, bw); } // Evaluate closer to true rd vp10_subtract_plane(x, bsize, 0); - rd = estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum, - &tmp_skip_txfm_sb, &tmp_skip_sse_sb, - INT64_MAX); + rd = + estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum, + &tmp_skip_txfm_sb, &tmp_skip_sse_sb, INT64_MAX); if (rd != INT64_MAX) rd = RDCOST(x->rdmult, x->rddiv, rmode + tmp_rate_mv + rwedge + rate_sum, dist_sum); @@ -7727,8 +7313,7 @@ static int64_t handle_inter_mode( #if CONFIG_EXT_INTERP if (!vp10_is_interp_needed(xd) && cm->interp_filter == SWITCHABLE) { #if CONFIG_DUAL_FILTER - for (i = 0; i < 4; ++i) - mbmi->interp_filter[i] = EIGHTTAP_REGULAR; + for (i = 0; i < 4; ++i) mbmi->interp_filter[i] = EIGHTTAP_REGULAR; #else mbmi->interp_filter = EIGHTTAP_REGULAR; #endif @@ -7754,17 +7339,15 @@ static int64_t handle_inter_mode( // switchable list (ex. bilinear) is indicated at the frame level, or // skip condition holds. vp10_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); - model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, - &tmp_rate, &tmp_dist, &skip_txfm_sb, &skip_sse_sb); + model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, &tmp_rate, + &tmp_dist, &skip_txfm_sb, &skip_sse_sb); rd = RDCOST(x->rdmult, x->rddiv, rs + tmp_rate, tmp_dist); } #if CONFIG_DUAL_FILTER - if (!is_comp_pred) - single_filter[this_mode][refs[0]] = mbmi->interp_filter[0]; + if (!is_comp_pred) single_filter[this_mode][refs[0]] = mbmi->interp_filter[0]; #else - if (!is_comp_pred) - single_filter[this_mode][refs[0]] = mbmi->interp_filter; + if (!is_comp_pred) single_filter[this_mode][refs[0]] = mbmi->interp_filter; #endif #if CONFIG_EXT_INTER @@ -7772,8 +7355,8 @@ static int64_t handle_inter_mode( if (is_comp_pred) { const int mode0 = compound_ref0_mode(this_mode); const int mode1 = compound_ref1_mode(this_mode); - int64_t mrd = VPXMIN(modelled_rd[mode0][refs[0]], - modelled_rd[mode1][refs[1]]); + int64_t mrd = + VPXMIN(modelled_rd[mode0][refs[0]], modelled_rd[mode1][refs[1]]); if (rd / 4 * 3 > mrd && ref_best_rd < INT64_MAX) { restore_dst_buf(xd, orig_dst, orig_dst_stride); return INT64_MAX; @@ -7793,8 +7376,7 @@ static int64_t handle_inter_mode( } } - if (cm->interp_filter == SWITCHABLE) - *rate2 += rs; + if (cm->interp_filter == SWITCHABLE) *rate2 += rs; #if CONFIG_OBMC rate2_nocoeff = *rate2; #endif // CONFIG_OBMC @@ -7807,22 +7389,22 @@ static int64_t handle_inter_mode( int64_t tmp_rd, tmp_dist; int tmp_rate; #if CONFIG_EXT_INTER - int tmp_rate2 = - mbmi->motion_variation != SIMPLE_TRANSLATION ? - rate2_bmc_nocoeff : rate2_nocoeff; + int tmp_rate2 = mbmi->motion_variation != SIMPLE_TRANSLATION + ? rate2_bmc_nocoeff + : rate2_nocoeff; #else int tmp_rate2 = rate2_nocoeff; #endif // CONFIG_EXT_INTER #if CONFIG_EXT_INTERP #if CONFIG_DUAL_FILTER INTERP_FILTER obmc_interp_filter[2][2] = { - {mbmi->interp_filter[0], mbmi->interp_filter[1]}, // obmc == 0 - {mbmi->interp_filter[0], mbmi->interp_filter[1]} // obmc == 1 + { mbmi->interp_filter[0], mbmi->interp_filter[1] }, // obmc == 0 + { mbmi->interp_filter[0], mbmi->interp_filter[1] } // obmc == 1 }; #else INTERP_FILTER obmc_interp_filter[2] = { - mbmi->interp_filter, // obmc == 0 - mbmi->interp_filter // obmc == 1 + mbmi->interp_filter, // obmc == 0 + mbmi->interp_filter // obmc == 1 }; #endif // CONFIG_DUAL_FILTER #endif // CONFIG_EXT_INTERP @@ -7839,8 +7421,7 @@ static int64_t handle_inter_mode( int tmp_rate_mv = 0; pred_mv.as_int = mbmi->mv[0].as_int; - single_motion_search_obmc(cpi, x, bsize, mi_row, mi_col, - wsrc, mask2d, + single_motion_search_obmc(cpi, x, bsize, mi_row, mi_col, wsrc, mask2d, #if CONFIG_EXT_INTER 0, mv_idx, #endif // CONFIG_EXT_INTER @@ -7866,8 +7447,7 @@ static int64_t handle_inter_mode( #endif // CONFIG_DUAL_FILTER // This is not quite correct with CONFIG_DUAL_FILTER when a filter // is needed in only one direction - if (!vp10_is_interp_needed(xd)) - tmp_rate2 -= rs; + if (!vp10_is_interp_needed(xd)) tmp_rate2 -= rs; #endif // CONFIG_EXT_INTERP vp10_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); #if CONFIG_EXT_INTER @@ -7875,11 +7455,10 @@ static int64_t handle_inter_mode( vp10_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); #endif // CONFIG_EXT_INTER } - vp10_build_obmc_inter_prediction(cm, xd, mi_row, mi_col, - dst_buf1, dst_stride1, - dst_buf2, dst_stride2); - model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, - &tmp_rate, &tmp_dist, &skip_txfm_sb, &skip_sse_sb); + vp10_build_obmc_inter_prediction(cm, xd, mi_row, mi_col, dst_buf1, + dst_stride1, dst_buf2, dst_stride2); + model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1, &tmp_rate, + &tmp_dist, &skip_txfm_sb, &skip_sse_sb); } #endif // CONFIG_OBMC @@ -7891,8 +7470,7 @@ static int64_t handle_inter_mode( x->skip = 0; *rate2 = tmp_rate2; - if (allow_motvar) - *rate2 += cpi->motvar_cost[bsize][mbmi->motion_variation]; + if (allow_motvar) *rate2 += cpi->motvar_cost[bsize][mbmi->motion_variation]; *distortion = 0; #endif // CONFIG_OBMC || CONFIG_WARPED_MOTION if (!skip_txfm_sb) { @@ -7917,8 +7495,8 @@ static int64_t handle_inter_mode( sizeof(uint8_t) * xd->n8_h * xd->n8_w * 4); } #else - super_block_yrd(cpi, x, rate_y, &distortion_y, &skippable_y, psse, - bsize, ref_best_rd); + super_block_yrd(cpi, x, rate_y, &distortion_y, &skippable_y, psse, bsize, + ref_best_rd); #endif // CONFIG_VAR_TX if (*rate_y == INT_MAX) { @@ -7946,8 +7524,8 @@ static int64_t handle_inter_mode( if (!inter_block_uvrd(cpi, x, rate_uv, &distortion_uv, &skippable_uv, &sseuv, bsize, ref_best_rd - rdcosty)) #else - if (!super_block_uvrd(cpi, x, rate_uv, &distortion_uv, &skippable_uv, - &sseuv, bsize, ref_best_rd - rdcosty)) + if (!super_block_uvrd(cpi, x, rate_uv, &distortion_uv, &skippable_uv, + &sseuv, bsize, ref_best_rd - rdcosty)) #endif // CONFIG_VAR_TX { *rate2 = INT_MAX; @@ -7955,8 +7533,8 @@ static int64_t handle_inter_mode( #if CONFIG_OBMC || CONFIG_WARPED_MOTION continue; #else - restore_dst_buf(xd, orig_dst, orig_dst_stride); - return INT64_MAX; + restore_dst_buf(xd, orig_dst, orig_dst_stride); + return INT64_MAX; #endif // CONFIG_OBMC || CONFIG_WARPED_MOTION } @@ -7973,8 +7551,9 @@ static int64_t handle_inter_mode( mbmi->skip = 0; // here mbmi->skip temporarily plays a role as what this_skip2 does } else if (!xd->lossless[mbmi->segment_id] && - (RDCOST(x->rdmult, x->rddiv, *rate_y + *rate_uv + - vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0), + (RDCOST(x->rdmult, x->rddiv, + *rate_y + *rate_uv + + vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0), *distortion) >= RDCOST(x->rdmult, x->rddiv, vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1), @@ -7995,7 +7574,7 @@ static int64_t handle_inter_mode( x->skip = 1; *disable_skip = 1; - // The cost of skip bit needs to be added. +// The cost of skip bit needs to be added. #if CONFIG_OBMC || CONFIG_WARPED_MOTION mbmi->skip = 0; #endif // CONFIG_OBMC || CONFIG_WARPED_MOTION @@ -8035,9 +7614,8 @@ static int64_t handle_inter_mode( best_disable_skip = *disable_skip; #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { - x->recon_variance = - vp10_high_get_sby_perpixel_variance( - cpi, &xd->plane[0].dst, bsize, xd->bd); + x->recon_variance = vp10_high_get_sby_perpixel_variance( + cpi, &xd->plane[0].dst, bsize, xd->bd); } else { x->recon_variance = vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize); @@ -8070,22 +7648,20 @@ static int64_t handle_inter_mode( *disable_skip = best_disable_skip; #endif // CONFIG_OBMC || CONFIG_WARPED_MOTION - if (!is_comp_pred) - single_skippable[this_mode][refs[0]] = *skippable; + if (!is_comp_pred) single_skippable[this_mode][refs[0]] = *skippable; #if !(CONFIG_OBMC || CONFIG_WARPED_MOTION) #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { - x->recon_variance = - vp10_high_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, - bsize, xd->bd); + x->recon_variance = vp10_high_get_sby_perpixel_variance( + cpi, &xd->plane[0].dst, bsize, xd->bd); } else { x->recon_variance = - vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize); + vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize); } #else x->recon_variance = - vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize); + vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize); #endif // CONFIG_VP9_HIGHBITDEPTH #endif // !(CONFIG_OBMC || CONFIG_WARPED_MOTION) @@ -8093,9 +7669,9 @@ static int64_t handle_inter_mode( return 0; // The rate-distortion cost will be re-calculated by caller. } -void vp10_rd_pick_intra_mode_sb(VP10_COMP *cpi, MACROBLOCK *x, - RD_COST *rd_cost, BLOCK_SIZE bsize, - PICK_MODE_CONTEXT *ctx, int64_t best_rd) { +void vp10_rd_pick_intra_mode_sb(VP10_COMP *cpi, MACROBLOCK *x, RD_COST *rd_cost, + BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, + int64_t best_rd) { VP10_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; struct macroblockd_plane *const pd = xd->plane; @@ -8108,9 +7684,8 @@ void vp10_rd_pick_intra_mode_sb(VP10_COMP *cpi, MACROBLOCK *x, xd->mi[0]->mbmi.ref_frame[1] = NONE; if (bsize >= BLOCK_8X8) { - if (rd_pick_intra_sby_mode(cpi, x, &rate_y, &rate_y_tokenonly, - &dist_y, &y_skip, bsize, - best_rd) >= best_rd) { + if (rd_pick_intra_sby_mode(cpi, x, &rate_y, &rate_y_tokenonly, &dist_y, + &y_skip, bsize, best_rd) >= best_rd) { rd_cost->rate = INT_MAX; return; } @@ -8122,20 +7697,18 @@ void vp10_rd_pick_intra_mode_sb(VP10_COMP *cpi, MACROBLOCK *x, return; } } - max_uv_tx_size = get_uv_tx_size_impl(xd->mi[0]->mbmi.tx_size, bsize, - pd[1].subsampling_x, - pd[1].subsampling_y); - rd_pick_intra_sbuv_mode(cpi, x, &rate_uv, &rate_uv_tokenonly, - &dist_uv, &uv_skip, VPXMAX(BLOCK_8X8, bsize), - max_uv_tx_size); + max_uv_tx_size = get_uv_tx_size_impl( + xd->mi[0]->mbmi.tx_size, bsize, pd[1].subsampling_x, pd[1].subsampling_y); + rd_pick_intra_sbuv_mode(cpi, x, &rate_uv, &rate_uv_tokenonly, &dist_uv, + &uv_skip, VPXMAX(BLOCK_8X8, bsize), max_uv_tx_size); if (y_skip && uv_skip) { rd_cost->rate = rate_y + rate_uv - rate_y_tokenonly - rate_uv_tokenonly + vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1); rd_cost->dist = dist_y + dist_uv; } else { - rd_cost->rate = rate_y + rate_uv + - vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0); + rd_cost->rate = + rate_y + rate_uv + vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0); rd_cost->dist = dist_y + dist_uv; } @@ -8149,8 +7722,7 @@ void vp10_rd_pick_intra_mode_sb(VP10_COMP *cpi, MACROBLOCK *x, #define LOW_VAR_THRESH 16 #define VLOW_ADJ_MAX 25 #define VHIGH_ADJ_MAX 8 -static void rd_variance_adjustment(MACROBLOCK *x, - int64_t *this_rd, +static void rd_variance_adjustment(MACROBLOCK *x, int64_t *this_rd, MV_REFERENCE_FRAME ref_frame, unsigned int source_variance) { unsigned int recon_variance = x->recon_variance; @@ -8158,17 +7730,16 @@ static void rd_variance_adjustment(MACROBLOCK *x, int64_t var_error = 0; int64_t var_factor = 0; - if (*this_rd == INT64_MAX) - return; + if (*this_rd == INT64_MAX) return; if ((source_variance + recon_variance) > LOW_VAR_THRESH) { absvar_diff = (source_variance > recon_variance) - ? (source_variance - recon_variance) - : (recon_variance - source_variance); + ? (source_variance - recon_variance) + : (recon_variance - source_variance); var_error = ((int64_t)200 * source_variance * recon_variance) / - (((int64_t)source_variance * source_variance) + - ((int64_t)recon_variance * recon_variance)); + (((int64_t)source_variance * source_variance) + + ((int64_t)recon_variance * recon_variance)); var_error = 100 - var_error; } @@ -8178,8 +7749,8 @@ static void rd_variance_adjustment(MACROBLOCK *x, if ((source_variance > LOW_VAR_THRESH) && (ref_frame == INTRA_FRAME) && (source_variance > recon_variance)) { var_factor = VPXMIN(absvar_diff, VPXMIN(VLOW_ADJ_MAX, var_error)); - // A second possible case of interest is where the source variance - // is very low and we wish to discourage false texture or motion trails. + // A second possible case of interest is where the source variance + // is very low and we wish to discourage false texture or motion trails. } else if ((source_variance < (LOW_VAR_THRESH >> 1)) && (recon_variance > source_variance)) { var_factor = VPXMIN(absvar_diff, VPXMIN(VHIGH_ADJ_MAX, var_error)); @@ -8187,12 +7758,11 @@ static void rd_variance_adjustment(MACROBLOCK *x, *this_rd += (*this_rd * var_factor) / 100; } - // Do we have an internal image edge (e.g. formatting bars). int vp10_internal_image_edge(VP10_COMP *cpi) { return (cpi->oxcf.pass == 2) && - ((cpi->twopass.this_frame_stats.inactive_zone_rows > 0) || - (cpi->twopass.this_frame_stats.inactive_zone_cols > 0)); + ((cpi->twopass.this_frame_stats.inactive_zone_rows > 0) || + (cpi->twopass.this_frame_stats.inactive_zone_cols > 0)); } // Checks to see if a super block is on a horizontal image edge. @@ -8252,8 +7822,7 @@ int vp10_active_v_edge(VP10_COMP *cpi, int mi_col, int mi_step) { // Checks to see if a super block is at the edge of the active image. // In most cases this is the "real" edge unless there are formatting // bars embedded in the stream. -int vp10_active_edge_sb(VP10_COMP *cpi, - int mi_row, int mi_col) { +int vp10_active_edge_sb(VP10_COMP *cpi, int mi_row, int mi_col) { return vp10_active_h_edge(cpi, mi_row, cpi->common.mib_size) || vp10_active_v_edge(cpi, mi_col, cpi->common.mib_size); } @@ -8263,10 +7832,10 @@ static void restore_uv_color_map(VP10_COMP *cpi, MACROBLOCK *x) { MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info; const BLOCK_SIZE bsize = mbmi->sb_type; - const int rows = (4 * num_4x4_blocks_high_lookup[bsize]) >> - (xd->plane[1].subsampling_y); - const int cols = (4 * num_4x4_blocks_wide_lookup[bsize]) >> - (xd->plane[1].subsampling_x); + const int rows = + (4 * num_4x4_blocks_high_lookup[bsize]) >> (xd->plane[1].subsampling_y); + const int cols = + (4 * num_4x4_blocks_wide_lookup[bsize]) >> (xd->plane[1].subsampling_x); int src_stride = x->plane[1].src.stride; const uint8_t *const src_u = x->plane[1].src.buf; const uint8_t *const src_v = x->plane[2].src.buf; @@ -8284,16 +7853,12 @@ static void restore_uv_color_map(VP10_COMP *cpi, MACROBLOCK *x) { for (c = 0; c < cols; ++c) { #if CONFIG_VP9_HIGHBITDEPTH if (cpi->common.use_highbitdepth) { - data[(r * cols + c) * 2 ] = - src_u16[r * src_stride + c]; - data[(r * cols + c) * 2 + 1] = - src_v16[r * src_stride + c]; + data[(r * cols + c) * 2] = src_u16[r * src_stride + c]; + data[(r * cols + c) * 2 + 1] = src_v16[r * src_stride + c]; } else { #endif // CONFIG_VP9_HIGHBITDEPTH - data[(r * cols + c) * 2 ] = - src_u[r * src_stride + c]; - data[(r * cols + c) * 2 + 1] = - src_v[r * src_stride + c]; + data[(r * cols + c) * 2] = src_u[r * src_stride + c]; + data[(r * cols + c) * 2 + 1] = src_v[r * src_stride + c]; #if CONFIG_VP9_HIGHBITDEPTH } #endif // CONFIG_VP9_HIGHBITDEPTH @@ -8330,8 +7895,7 @@ static void pick_ext_intra_interframe( const TX_SIZE max_tx_size = max_txsize_lookup[bsize]; int rate2 = 0, rate_y = INT_MAX, skippable = 0, rate_uv, rate_dummy, i; int dc_mode_index; - const int * const intra_mode_cost = - cpi->mbmode_cost[size_group_lookup[bsize]]; + const int *const intra_mode_cost = cpi->mbmode_cost[size_group_lookup[bsize]]; int64_t distortion2 = 0, distortion_y = 0, this_rd = *best_rd, distortion_uv; TX_SIZE uv_tx; @@ -8349,21 +7913,18 @@ static void pick_ext_intra_interframe( mbmi->ref_frame[0] = INTRA_FRAME; mbmi->ref_frame[1] = NONE; if (!rd_pick_ext_intra_sby(cpi, x, &rate_dummy, &rate_y, &distortion_y, - &skippable, bsize, - intra_mode_cost[mbmi->mode], &this_rd, 0)) - return; - if (rate_y == INT_MAX) + &skippable, bsize, intra_mode_cost[mbmi->mode], + &this_rd, 0)) return; + if (rate_y == INT_MAX) return; - uv_tx = get_uv_tx_size_impl(mbmi->tx_size, bsize, - xd->plane[1].subsampling_x, + uv_tx = get_uv_tx_size_impl(mbmi->tx_size, bsize, xd->plane[1].subsampling_x, xd->plane[1].subsampling_y); if (rate_uv_intra[uv_tx] == INT_MAX) { - choose_intra_uv_mode(cpi, x, ctx, bsize, uv_tx, - &rate_uv_intra[uv_tx], &rate_uv_tokenonly[uv_tx], - &dist_uv[uv_tx], &skip_uv[uv_tx], &mode_uv[uv_tx]); - if (cm->allow_screen_content_tools) - pmi_uv[uv_tx] = *pmi; + choose_intra_uv_mode(cpi, x, ctx, bsize, uv_tx, &rate_uv_intra[uv_tx], + &rate_uv_tokenonly[uv_tx], &dist_uv[uv_tx], + &skip_uv[uv_tx], &mode_uv[uv_tx]); + if (cm->allow_screen_content_tools) pmi_uv[uv_tx] = *pmi; ext_intra_mode_info_uv[uv_tx] = mbmi->ext_intra_mode_info; uv_angle_delta[uv_tx] = mbmi->angle_delta[1]; } @@ -8387,20 +7948,18 @@ static void pick_ext_intra_interframe( } rate2 = rate_y + intra_mode_cost[mbmi->mode] + rate_uv + - cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode]; + cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode]; if (cpi->common.allow_screen_content_tools && mbmi->mode == DC_PRED) - rate2 += - vp10_cost_bit(vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8] - [palette_ctx], 0); + rate2 += vp10_cost_bit( + vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx], 0); if (!xd->lossless[mbmi->segment_id]) { // super_block_yrd above includes the cost of the tx_size in the // tokenonly rate, but for intra blocks, tx_size is always coded // (prediction granularity), so we account for it in the full rate, // not the tokenonly rate. - rate_y -= - cpi->tx_size_cost[max_tx_size - TX_8X8][get_tx_size_context(xd)] - [mbmi->tx_size]; + rate_y -= cpi->tx_size_cost[max_tx_size - + TX_8X8][get_tx_size_context(xd)][mbmi->tx_size]; } rate2 += vp10_cost_bit(cm->fc->ext_intra_probs[0], @@ -8409,24 +7968,21 @@ static void pick_ext_intra_interframe( mbmi->ext_intra_mode_info.ext_intra_mode[0]); if (mbmi->uv_mode != DC_PRED && mbmi->uv_mode != TM_PRED) { rate2 += write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, - MAX_ANGLE_DELTAS + - mbmi->angle_delta[1]); + MAX_ANGLE_DELTAS + mbmi->angle_delta[1]); } if (mbmi->mode == DC_PRED) { rate2 += vp10_cost_bit(cpi->common.fc->ext_intra_probs[1], mbmi->ext_intra_mode_info.use_ext_intra_mode[1]); if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) - rate2 += - write_uniform_cost(FILTER_INTRA_MODES, - mbmi->ext_intra_mode_info.ext_intra_mode[1]); + rate2 += write_uniform_cost(FILTER_INTRA_MODES, + mbmi->ext_intra_mode_info.ext_intra_mode[1]); } distortion2 = distortion_y + distortion_uv; vp10_encode_intra_block_plane(x, bsize, 0, 0); #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { - x->recon_variance = - vp10_high_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, - bsize, xd->bd); + x->recon_variance = vp10_high_get_sby_perpixel_variance( + cpi, &xd->plane[0].dst, bsize, xd->bd); } else { x->recon_variance = vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize); @@ -8481,26 +8037,18 @@ static void pick_ext_intra_interframe( #if CONFIG_OBMC static void calc_target_weighted_pred( - const VP10_COMMON *cm, - const MACROBLOCK *x, - const MACROBLOCKD *xd, - int mi_row, int mi_col, - const uint8_t *above, int above_stride, - const uint8_t *left, int left_stride, - int32_t *mask_buf, - int32_t *wsrc_buf); + const VP10_COMMON *cm, const MACROBLOCK *x, const MACROBLOCKD *xd, + int mi_row, int mi_col, const uint8_t *above, int above_stride, + const uint8_t *left, int left_stride, int32_t *mask_buf, int32_t *wsrc_buf); #endif // CONFIG_OBMC -void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, - TileDataEnc *tile_data, - MACROBLOCK *x, - int mi_row, int mi_col, +void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, TileDataEnc *tile_data, + MACROBLOCK *x, int mi_row, int mi_col, RD_COST *rd_cost, #if CONFIG_SUPERTX int *returnrate_nocoef, #endif // CONFIG_SUPERTX - BLOCK_SIZE bsize, - PICK_MODE_CONTEXT *ctx, + BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, int64_t best_rd_so_far) { VP10_COMMON *const cm = &cpi->common; RD_OPT *const rd_opt = &cpi->rd; @@ -8517,7 +8065,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, int_mv frame_mv[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME]; struct buf_2d yv12_mb[TOTAL_REFS_PER_FRAME][MAX_MB_PLANE]; #if CONFIG_EXT_INTER - int_mv single_newmvs[2][TOTAL_REFS_PER_FRAME] = { { { 0 } }, { { 0 } } }; + int_mv single_newmvs[2][TOTAL_REFS_PER_FRAME] = { { { 0 } }, { { 0 } } }; int single_newmvs_rate[2][TOTAL_REFS_PER_FRAME] = { { 0 }, { 0 } }; int64_t modelled_rd[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME]; #else @@ -8565,8 +8113,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, #endif // CONFIG_EXT_INTRA const int intra_cost_penalty = vp10_get_intra_cost_penalty( cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth); - const int * const intra_mode_cost = - cpi->mbmode_cost[size_group_lookup[bsize]]; + const int *const intra_mode_cost = cpi->mbmode_cost[size_group_lookup[bsize]]; int best_skip2 = 0; uint8_t ref_frame_skip_mask[2] = { 0 }; #if CONFIG_EXT_INTER @@ -8599,12 +8146,12 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, DECLARE_ALIGNED(16, int32_t, weighted_src_buf[MAX_SB_SQUARE]); DECLARE_ALIGNED(16, int32_t, mask2d_buf[MAX_SB_SQUARE]); uint8_t *dst_buf1[MAX_MB_PLANE], *dst_buf2[MAX_MB_PLANE]; - int dst_width1[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; - int dst_width2[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; - int dst_height1[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; - int dst_height2[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; - int dst_stride1[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; - int dst_stride2[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE}; + int dst_width1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; + int dst_width2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; + int dst_height1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; + int dst_height2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; + int dst_stride1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; + int dst_stride2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE }; #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { @@ -8617,12 +8164,12 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, dst_buf2[2] = CONVERT_TO_BYTEPTR(tmp_buf2 + 2 * MAX_SB_SQUARE * len); } else { #endif // CONFIG_VP9_HIGHBITDEPTH - dst_buf1[0] = tmp_buf1; - dst_buf1[1] = tmp_buf1 + MAX_SB_SQUARE; - dst_buf1[2] = tmp_buf1 + 2 * MAX_SB_SQUARE; - dst_buf2[0] = tmp_buf2; - dst_buf2[1] = tmp_buf2 + MAX_SB_SQUARE; - dst_buf2[2] = tmp_buf2 + 2 * MAX_SB_SQUARE; + dst_buf1[0] = tmp_buf1; + dst_buf1[1] = tmp_buf1 + MAX_SB_SQUARE; + dst_buf1[2] = tmp_buf1 + 2 * MAX_SB_SQUARE; + dst_buf2[0] = tmp_buf2; + dst_buf2[1] = tmp_buf2 + MAX_SB_SQUARE; + dst_buf2[2] = tmp_buf2 + 2 * MAX_SB_SQUARE; #if CONFIG_VP9_HIGHBITDEPTH } #endif // CONFIG_VP9_HIGHBITDEPTH @@ -8646,12 +8193,9 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, estimate_ref_frame_costs(cm, xd, segment_id, ref_costs_single, ref_costs_comp, &comp_mode_p); - for (i = 0; i < REFERENCE_MODES; ++i) - best_pred_rd[i] = INT64_MAX; - for (i = 0; i < TX_SIZES; i++) - rate_uv_intra[i] = INT_MAX; - for (i = 0; i < TOTAL_REFS_PER_FRAME; ++i) - x->pred_sse[i] = INT_MAX; + for (i = 0; i < REFERENCE_MODES; ++i) best_pred_rd[i] = INT64_MAX; + for (i = 0; i < TX_SIZES; i++) rate_uv_intra[i] = INT_MAX; + for (i = 0; i < TOTAL_REFS_PER_FRAME; ++i) x->pred_sse[i] = INT_MAX; for (i = 0; i < MB_MODE_COUNT; ++i) { for (k = 0; k < TOTAL_REFS_PER_FRAME; ++k) { single_inter_filter[i][k] = SWITCHABLE; @@ -8689,14 +8233,13 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, MODE_INFO *const mi = xd->mi[0]; int_mv *const candidates = x->mbmi_ext->ref_mvs[ref_frame]; x->mbmi_ext->mode_context[ref_frame] = 0; - vp10_find_mv_refs(cm, xd, mi, ref_frame, - &mbmi_ext->ref_mv_count[ref_frame], + vp10_find_mv_refs(cm, xd, mi, ref_frame, &mbmi_ext->ref_mv_count[ref_frame], mbmi_ext->ref_mv_stack[ref_frame], #if CONFIG_EXT_INTER mbmi_ext->compound_mode_context, #endif // CONFIG_EXT_INTER - candidates, mi_row, mi_col, - NULL, NULL, mbmi_ext->mode_context); + candidates, mi_row, mi_col, NULL, NULL, + mbmi_ext->mode_context); } #endif // CONFIG_REF_MV @@ -8706,17 +8249,16 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, vp10_build_prediction_by_left_preds(cm, xd, mi_row, mi_col, dst_buf2, dst_width2, dst_height2, dst_stride2); vp10_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col); - calc_target_weighted_pred(cm, x, xd, mi_row, mi_col, - dst_buf1[0], dst_stride1[0], - dst_buf2[0], dst_stride2[0], + calc_target_weighted_pred(cm, x, xd, mi_row, mi_col, dst_buf1[0], + dst_stride1[0], dst_buf2[0], dst_stride2[0], mask2d_buf, weighted_src_buf); #endif // CONFIG_OBMC for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { if (!(cpi->ref_frame_flags & flag_list[ref_frame])) { - // Skip checking missing references in both single and compound reference - // modes. Note that a mode will be skipped iff both reference frames - // are masked out. +// Skip checking missing references in both single and compound reference +// modes. Note that a mode will be skipped iff both reference frames +// are masked out. #if CONFIG_EXT_REFS if (ref_frame == BWDREF_FRAME || ref_frame == ALTREF_FRAME) { ref_frame_skip_mask[0] |= (1 << ref_frame); @@ -8755,14 +8297,12 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, // an unfiltered alternative. We allow near/nearest as well // because they may result in zero-zero MVs but be cheaper. if (cpi->rc.is_src_frame_alt_ref && (cpi->oxcf.arnr_max_frames == 0)) { - ref_frame_skip_mask[0] = - (1 << LAST_FRAME) | + ref_frame_skip_mask[0] = (1 << LAST_FRAME) | #if CONFIG_EXT_REFS - (1 << LAST2_FRAME) | - (1 << LAST3_FRAME) | - (1 << BWDREF_FRAME) | + (1 << LAST2_FRAME) | (1 << LAST3_FRAME) | + (1 << BWDREF_FRAME) | #endif // CONFIG_EXT_REFS - (1 << GOLDEN_FRAME); + (1 << GOLDEN_FRAME); ref_frame_skip_mask[1] = SECOND_REF_FRAME_MASK; // TODO(zoeliu): To further explore whether following needs to be done for // BWDREF_FRAME as well. @@ -8813,12 +8353,11 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, mode_skip_mask[INTRA_FRAME] |= ~(sf->intra_y_mode_mask[max_txsize_lookup[bsize]]); - for (i = 0; i <= LAST_NEW_MV_INDEX; ++i) - mode_threshold[i] = 0; + for (i = 0; i <= LAST_NEW_MV_INDEX; ++i) mode_threshold[i] = 0; for (i = LAST_NEW_MV_INDEX + 1; i < MAX_MODES; ++i) mode_threshold[i] = ((int64_t)rd_threshes[i] * rd_thresh_freq_fact[i]) >> 5; - midx = sf->schedule_mode_search ? mode_skip_start : 0; + midx = sf->schedule_mode_search ? mode_skip_start : 0; while (midx > 4) { uint8_t end_pos = 0; for (i = 5; i < midx; ++i) { @@ -8843,7 +8382,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, x->use_default_inter_tx_type = 0; #if CONFIG_EXT_INTER - for (i = 0 ; i < MB_MODE_COUNT ; ++i) + for (i = 0; i < MB_MODE_COUNT; ++i) for (ref_frame = 0; ref_frame < TOTAL_REFS_PER_FRAME; ++ref_frame) modelled_rd[i][ref_frame] = INT64_MAX; #endif // CONFIG_EXT_INTER @@ -8878,8 +8417,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, // Mode must by compatible assert(is_interintra_allowed_mode(this_mode)); - if (!is_interintra_allowed_bsize(bsize)) - continue; + if (!is_interintra_allowed_bsize(bsize)) continue; } if (is_inter_compound_mode(this_mode)) { @@ -8894,8 +8432,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, // skip mask to look at a subset of the remaining modes. if (midx == mode_skip_start && best_mode_index >= 0) { switch (best_mbmode.ref_frame[0]) { - case INTRA_FRAME: - break; + case INTRA_FRAME: break; case LAST_FRAME: ref_frame_skip_mask[0] |= LAST_FRAME_MODE_MASK; ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK; @@ -8920,8 +8457,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK; break; #endif // CONFIG_EXT_REFS - case ALTREF_FRAME: - ref_frame_skip_mask[0] |= ALTREF_FRAME_MODE_MASK; + case ALTREF_FRAME: ref_frame_skip_mask[0] |= ALTREF_FRAME_MODE_MASK; #if CONFIG_EXT_REFS ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK; #endif // CONFIG_EXT_REFS @@ -8937,29 +8473,24 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, (ref_frame_skip_mask[1] & (1 << VPXMAX(0, second_ref_frame)))) continue; - if (mode_skip_mask[ref_frame] & (1 << this_mode)) - continue; + if (mode_skip_mask[ref_frame] & (1 << this_mode)) continue; // Test best rd so far against threshold for trying this mode. if (best_mode_skippable && sf->schedule_mode_search) mode_threshold[mode_index] <<= 1; - if (best_rd < mode_threshold[mode_index]) - continue; + if (best_rd < mode_threshold[mode_index]) continue; comp_pred = second_ref_frame > INTRA_FRAME; if (comp_pred) { - if (!cpi->allow_comp_inter_inter) - continue; + if (!cpi->allow_comp_inter_inter) continue; // Skip compound inter modes if ARF is not available. - if (!(cpi->ref_frame_flags & flag_list[second_ref_frame])) - continue; + if (!(cpi->ref_frame_flags & flag_list[second_ref_frame])) continue; // Do not allow compound prediction if the segment level reference frame // feature is in use as in this case there can only be one reference. - if (segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) - continue; + if (segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) continue; if ((mode_search_skip_flags & FLAG_SKIP_COMP_BESTINTRA) && best_mode_index >= 0 && best_mbmode.ref_frame[0] == INTRA_FRAME) @@ -8988,23 +8519,20 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, // one of the neighboring directional modes if ((mode_search_skip_flags & FLAG_SKIP_INTRA_BESTINTER) && (this_mode >= D45_PRED && this_mode <= TM_PRED)) { - if (best_mode_index >= 0 && - best_mbmode.ref_frame[0] > INTRA_FRAME) + if (best_mode_index >= 0 && best_mbmode.ref_frame[0] > INTRA_FRAME) continue; } if (mode_search_skip_flags & FLAG_SKIP_INTRA_DIRMISMATCH) { - if (conditional_skipintra(this_mode, best_intra_mode)) - continue; + if (conditional_skipintra(this_mode, best_intra_mode)) continue; } } } else { - const MV_REFERENCE_FRAME ref_frames[2] = {ref_frame, second_ref_frame}; + const MV_REFERENCE_FRAME ref_frames[2] = { ref_frame, second_ref_frame }; if (!check_best_zero_mv(cpi, mbmi_ext->mode_context, #if CONFIG_REF_MV && CONFIG_EXT_INTER mbmi_ext->compound_mode_context, #endif // CONFIG_REF_MV && CONFIG_EXT_INTER - frame_mv, - this_mode, ref_frames, bsize, -1)) + frame_mv, this_mode, ref_frames, bsize, -1)) continue; } @@ -9018,16 +8546,17 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = 0; mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = 0; #endif // CONFIG_EXT_INTRA - // Evaluate all sub-pel filters irrespective of whether we can use - // them for this frame. + // Evaluate all sub-pel filters irrespective of whether we can use + // them for this frame. #if CONFIG_DUAL_FILTER for (i = 0; i < 4; ++i) { - mbmi->interp_filter[i] = cm->interp_filter == SWITCHABLE ? - EIGHTTAP_REGULAR : cm->interp_filter; + mbmi->interp_filter[i] = cm->interp_filter == SWITCHABLE + ? EIGHTTAP_REGULAR + : cm->interp_filter; } #else - mbmi->interp_filter = cm->interp_filter == SWITCHABLE ? EIGHTTAP_REGULAR - : cm->interp_filter; + mbmi->interp_filter = + cm->interp_filter == SWITCHABLE ? EIGHTTAP_REGULAR : cm->interp_filter; #endif mbmi->mv[0].as_int = mbmi->mv[1].as_int = 0; mbmi->motion_variation = SIMPLE_TRANSLATION; @@ -9038,8 +8567,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, // Select prediction reference frames. for (i = 0; i < MAX_MB_PLANE; i++) { xd->plane[i].pre[0] = yv12_mb[ref_frame][i]; - if (comp_pred) - xd->plane[i].pre[1] = yv12_mb[second_ref_frame][i]; + if (comp_pred) xd->plane[i].pre[1] = yv12_mb[second_ref_frame][i]; } #if CONFIG_EXT_INTER @@ -9067,40 +8595,36 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, directional_mode_skip_mask); angle_stats_ready = 1; } - if (directional_mode_skip_mask[mbmi->mode]) - continue; + if (directional_mode_skip_mask[mbmi->mode]) continue; rate_overhead = write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, 0) + - intra_mode_cost[mbmi->mode]; + intra_mode_cost[mbmi->mode]; rate_y = INT_MAX; this_rd = rd_pick_intra_angle_sby(cpi, x, &rate_dummy, &rate_y, &distortion_y, &skippable, bsize, rate_overhead, best_rd); } else { mbmi->angle_delta[0] = 0; - super_block_yrd(cpi, x, &rate_y, &distortion_y, &skippable, - NULL, bsize, best_rd); + super_block_yrd(cpi, x, &rate_y, &distortion_y, &skippable, NULL, bsize, + best_rd); } #else - super_block_yrd(cpi, x, &rate_y, &distortion_y, &skippable, - NULL, bsize, best_rd); + super_block_yrd(cpi, x, &rate_y, &distortion_y, &skippable, NULL, bsize, + best_rd); #endif // CONFIG_EXT_INTRA - if (rate_y == INT_MAX) - continue; + if (rate_y == INT_MAX) continue; #if CONFIG_EXT_INTRA - if (mbmi->mode == DC_PRED) - dc_skipped = 0; + if (mbmi->mode == DC_PRED) dc_skipped = 0; #endif // CONFIG_EXT_INTRA uv_tx = get_uv_tx_size_impl(mbmi->tx_size, bsize, pd->subsampling_x, pd->subsampling_y); if (rate_uv_intra[uv_tx] == INT_MAX) { - choose_intra_uv_mode(cpi, x, ctx, bsize, uv_tx, - &rate_uv_intra[uv_tx], &rate_uv_tokenonly[uv_tx], - &dist_uv[uv_tx], &skip_uv[uv_tx], &mode_uv[uv_tx]); - if (cm->allow_screen_content_tools) - pmi_uv[uv_tx] = *pmi; + choose_intra_uv_mode(cpi, x, ctx, bsize, uv_tx, &rate_uv_intra[uv_tx], + &rate_uv_tokenonly[uv_tx], &dist_uv[uv_tx], + &skip_uv[uv_tx], &mode_uv[uv_tx]); + if (cm->allow_screen_content_tools) pmi_uv[uv_tx] = *pmi; #if CONFIG_EXT_INTRA ext_intra_mode_info_uv[uv_tx] = mbmi->ext_intra_mode_info; uv_angle_delta[uv_tx] = mbmi->angle_delta[1]; @@ -9127,31 +8651,29 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, } #endif // CONFIG_EXT_INTRA - rate2 = rate_y + intra_mode_cost[mbmi->mode] + - rate_uv + cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode]; + rate2 = rate_y + intra_mode_cost[mbmi->mode] + rate_uv + + cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode]; if (cpi->common.allow_screen_content_tools && mbmi->mode == DC_PRED) - rate2 += - vp10_cost_bit(vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8] - [palette_ctx], 0); + rate2 += vp10_cost_bit( + vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx], + 0); if (!xd->lossless[mbmi->segment_id]) { // super_block_yrd above includes the cost of the tx_size in the // tokenonly rate, but for intra blocks, tx_size is always coded // (prediction granularity), so we account for it in the full rate, // not the tokenonly rate. - rate_y -= - cpi->tx_size_cost[max_tx_size - TX_8X8][get_tx_size_context(xd)] - [mbmi->tx_size]; + rate_y -= cpi->tx_size_cost[max_tx_size - TX_8X8][get_tx_size_context( + xd)][mbmi->tx_size]; } #if CONFIG_EXT_INTRA if (is_directional_mode) { int p_angle; const int intra_filter_ctx = vp10_get_pred_context_intra_interp(xd); rate2 += write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, - MAX_ANGLE_DELTAS + - mbmi->angle_delta[0]); - p_angle = mode_to_angle_map[mbmi->mode] + - mbmi->angle_delta[0] * ANGLE_STEP; + MAX_ANGLE_DELTAS + mbmi->angle_delta[0]); + p_angle = + mode_to_angle_map[mbmi->mode] + mbmi->angle_delta[0] * ANGLE_STEP; if (vp10_is_intra_filter_switchable(p_angle)) rate2 += cpi->intra_filter_cost[intra_filter_ctx][mbmi->intra_filter]; } @@ -9160,25 +8682,22 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, rate2 += vp10_cost_bit(cm->fc->ext_intra_probs[0], mbmi->ext_intra_mode_info.use_ext_intra_mode[0]); if (mbmi->ext_intra_mode_info.use_ext_intra_mode[0]) { - rate2 += - write_uniform_cost(FILTER_INTRA_MODES, - mbmi->ext_intra_mode_info.ext_intra_mode[0]); + rate2 += write_uniform_cost( + FILTER_INTRA_MODES, mbmi->ext_intra_mode_info.ext_intra_mode[0]); } } if (mbmi->uv_mode != DC_PRED && mbmi->uv_mode != TM_PRED) { rate2 += write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, - MAX_ANGLE_DELTAS + - mbmi->angle_delta[1]); + MAX_ANGLE_DELTAS + mbmi->angle_delta[1]); } if (ALLOW_FILTER_INTRA_MODES && mbmi->mode == DC_PRED) { rate2 += vp10_cost_bit(cpi->common.fc->ext_intra_probs[1], mbmi->ext_intra_mode_info.use_ext_intra_mode[1]); if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) - rate2 += - write_uniform_cost(FILTER_INTRA_MODES, - mbmi->ext_intra_mode_info.ext_intra_mode[1]); + rate2 += write_uniform_cost( + FILTER_INTRA_MODES, mbmi->ext_intra_mode_info.ext_intra_mode[1]); } #endif // CONFIG_EXT_INTRA if (this_mode != DC_PRED && this_mode != TM_PRED) @@ -9187,29 +8706,26 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, vp10_encode_intra_block_plane(x, bsize, 0, 1); #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { - x->recon_variance = - vp10_high_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, - bsize, xd->bd); + x->recon_variance = vp10_high_get_sby_perpixel_variance( + cpi, &xd->plane[0].dst, bsize, xd->bd); } else { x->recon_variance = - vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize); + vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize); } #else x->recon_variance = - vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize); + vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize); #endif // CONFIG_VP9_HIGHBITDEPTH } else { #if CONFIG_REF_MV int_mv backup_ref_mv[2]; backup_ref_mv[0] = mbmi_ext->ref_mvs[ref_frame][0]; - if (comp_pred) - backup_ref_mv[1] = mbmi_ext->ref_mvs[second_ref_frame][0]; + if (comp_pred) backup_ref_mv[1] = mbmi_ext->ref_mvs[second_ref_frame][0]; #endif #if CONFIG_EXT_INTER if (second_ref_frame == INTRA_FRAME) { - if (best_single_inter_ref != ref_frame) - continue; + if (best_single_inter_ref != ref_frame) continue; mbmi->interintra_mode = best_intra_mode; #if CONFIG_EXT_INTRA // TODO(debargha|geza.lore): @@ -9226,49 +8742,38 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, mbmi->ref_mv_idx = 0; ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame); - if (this_mode == NEWMV && - mbmi_ext->ref_mv_count[ref_frame_type] > 1) { + if (this_mode == NEWMV && mbmi_ext->ref_mv_count[ref_frame_type] > 1) { int ref; for (ref = 0; ref < 1 + comp_pred; ++ref) { - int_mv this_mv = (ref == 0) ? - mbmi_ext->ref_mv_stack[ref_frame_type][0].this_mv : - mbmi_ext->ref_mv_stack[ref_frame_type][0].comp_mv; + int_mv this_mv = + (ref == 0) ? mbmi_ext->ref_mv_stack[ref_frame_type][0].this_mv + : mbmi_ext->ref_mv_stack[ref_frame_type][0].comp_mv; clamp_mv_ref(&this_mv.as_mv, xd->n8_w << 3, xd->n8_h << 3, xd); mbmi_ext->ref_mvs[mbmi->ref_frame[ref]][0] = this_mv; } } #endif - this_rd = handle_inter_mode(cpi, x, bsize, - &rate2, &distortion2, &skippable, - &rate_y, &rate_uv, - &disable_skip, frame_mv, - mi_row, mi_col, + this_rd = handle_inter_mode( + cpi, x, bsize, &rate2, &distortion2, &skippable, &rate_y, &rate_uv, + &disable_skip, frame_mv, mi_row, mi_col, #if CONFIG_OBMC - dst_buf1, dst_stride1, - dst_buf2, dst_stride2, - weighted_src_buf, - mask2d_buf, + dst_buf1, dst_stride1, dst_buf2, dst_stride2, weighted_src_buf, + mask2d_buf, #endif // CONFIG_OBMC #if CONFIG_EXT_INTER - single_newmvs, - single_newmvs_rate, - &compmode_interintra_cost, - &compmode_wedge_cost, - modelled_rd, + single_newmvs, single_newmvs_rate, &compmode_interintra_cost, + &compmode_wedge_cost, modelled_rd, #else - single_newmv, + single_newmv, #endif // CONFIG_EXT_INTER - single_inter_filter, - single_skippable, - &total_sse, best_rd); + single_inter_filter, single_skippable, &total_sse, best_rd); #if CONFIG_REF_MV // TODO(jingning): This needs some refactoring to improve code quality // and reduce redundant steps. if ((mbmi->mode == NEARMV && mbmi_ext->ref_mv_count[ref_frame_type] > 2) || - (mbmi->mode == NEWMV && - mbmi_ext->ref_mv_count[ref_frame_type] > 1)) { + (mbmi->mode == NEWMV && mbmi_ext->ref_mv_count[ref_frame_type] > 1)) { int_mv backup_mv = frame_mv[NEARMV][ref_frame]; MB_MODE_INFO backup_mbmi = *mbmi; int backup_skip = x->skip; @@ -9280,27 +8785,28 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, int ref_set = VPXMIN(2, mbmi_ext->ref_mv_count[ref_frame_type] - 1 - idx_offset); - uint8_t drl_ctx = vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], - idx_offset); + uint8_t drl_ctx = + vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx_offset); // Dummy int_mv backup_fmv[2]; backup_fmv[0] = frame_mv[NEWMV][ref_frame]; - if (comp_pred) - backup_fmv[1] = frame_mv[NEWMV][second_ref_frame]; + if (comp_pred) backup_fmv[1] = frame_mv[NEWMV][second_ref_frame]; rate2 += cpi->drl_mode_cost0[drl_ctx][0]; if (this_rd < INT64_MAX) { if (RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv, distortion2) < RDCOST(x->rdmult, x->rddiv, 0, total_sse)) - tmp_ref_rd = RDCOST(x->rdmult, x->rddiv, - rate2 + vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0), - distortion2); + tmp_ref_rd = + RDCOST(x->rdmult, x->rddiv, + rate2 + vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0), + distortion2); else - tmp_ref_rd = RDCOST(x->rdmult, x->rddiv, - rate2 + vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1) - - rate_y - rate_uv, - total_sse); + tmp_ref_rd = + RDCOST(x->rdmult, x->rddiv, + rate2 + vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1) - + rate_y - rate_uv, + total_sse); } #if CONFIG_VAR_TX for (i = 0; i < MAX_MB_PLANE; ++i) @@ -9320,31 +8826,35 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, mbmi->ref_mv_idx = 1 + ref_idx; for (ref = 0; ref < 1 + comp_pred; ++ref) { - int_mv this_mv = (ref == 0) ? - mbmi_ext->ref_mv_stack[ref_frame_type] - [mbmi->ref_mv_idx].this_mv : - mbmi_ext->ref_mv_stack[ref_frame_type] - [mbmi->ref_mv_idx].comp_mv; + int_mv this_mv = + (ref == 0) + ? mbmi_ext->ref_mv_stack[ref_frame_type][mbmi->ref_mv_idx] + .this_mv + : mbmi_ext->ref_mv_stack[ref_frame_type][mbmi->ref_mv_idx] + .comp_mv; clamp_mv_ref(&this_mv.as_mv, xd->n8_w << 3, xd->n8_h << 3, xd); mbmi_ext->ref_mvs[mbmi->ref_frame[ref]][0] = this_mv; } - cur_mv = mbmi_ext->ref_mv_stack[ref_frame] - [mbmi->ref_mv_idx + idx_offset].this_mv; + cur_mv = + mbmi_ext->ref_mv_stack[ref_frame][mbmi->ref_mv_idx + idx_offset] + .this_mv; clamp_mv2(&cur_mv.as_mv, xd); if (!mv_check_bounds(x, &cur_mv.as_mv)) { - INTERP_FILTER dummy_single_inter_filter[MB_MODE_COUNT] - [TOTAL_REFS_PER_FRAME] = - { { 0 } }; - int dummy_single_skippable[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME] = - { { 0 } }; + INTERP_FILTER + dummy_single_inter_filter[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME] = { + { 0 } + }; + int dummy_single_skippable[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME] = { + { 0 } + }; int dummy_disable_skip = 0; #if CONFIG_EXT_INTER - int_mv dummy_single_newmvs[2][TOTAL_REFS_PER_FRAME] = - { { { 0 } }, { { 0 } } }; - int dummy_single_newmvs_rate[2][TOTAL_REFS_PER_FRAME] = - { { 0 }, { 0 } }; + int_mv dummy_single_newmvs[2][TOTAL_REFS_PER_FRAME] = { { { 0 } }, + { { 0 } } }; + int dummy_single_newmvs_rate[2][TOTAL_REFS_PER_FRAME] = { { 0 }, + { 0 } }; int dummy_compmode_interintra_cost = 0; int dummy_compmode_wedge_cost = 0; #else @@ -9352,29 +8862,22 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, #endif frame_mv[NEARMV][ref_frame] = cur_mv; - tmp_alt_rd = handle_inter_mode(cpi, x, bsize, - &tmp_rate, &tmp_dist, &tmp_skip, - &tmp_rate_y, &tmp_rate_uv, - &dummy_disable_skip, frame_mv, - mi_row, mi_col, + tmp_alt_rd = handle_inter_mode( + cpi, x, bsize, &tmp_rate, &tmp_dist, &tmp_skip, &tmp_rate_y, + &tmp_rate_uv, &dummy_disable_skip, frame_mv, mi_row, mi_col, #if CONFIG_OBMC - dst_buf1, dst_stride1, - dst_buf2, dst_stride2, - weighted_src_buf, - mask2d_buf, + dst_buf1, dst_stride1, dst_buf2, dst_stride2, weighted_src_buf, + mask2d_buf, #endif // CONFIG_OBMC #if CONFIG_EXT_INTER - dummy_single_newmvs, - dummy_single_newmvs_rate, - &dummy_compmode_interintra_cost, - &dummy_compmode_wedge_cost, - NULL, + dummy_single_newmvs, dummy_single_newmvs_rate, + &dummy_compmode_interintra_cost, &dummy_compmode_wedge_cost, + NULL, #else - dummy_single_newmv, + dummy_single_newmv, #endif - dummy_single_inter_filter, - dummy_single_skippable, - &tmp_sse, best_rd); + dummy_single_inter_filter, dummy_single_skippable, &tmp_sse, + best_rd); } for (i = 0; i < mbmi->ref_mv_idx; ++i) { @@ -9385,7 +8888,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, } if (mbmi_ext->ref_mv_count[ref_frame_type] > - mbmi->ref_mv_idx + idx_offset + 1 && + mbmi->ref_mv_idx + idx_offset + 1 && ref_idx < ref_set - 1) { uint8_t drl1_ctx = vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], @@ -9397,16 +8900,17 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, #if CONFIG_OBMC tmp_alt_rd = RDCOST(x->rdmult, x->rddiv, tmp_rate, tmp_dist); #else - if (RDCOST(x->rdmult, x->rddiv, - tmp_rate_y + tmp_rate_uv, tmp_dist) < - RDCOST(x->rdmult, x->rddiv, 0, tmp_sse)) - tmp_alt_rd = RDCOST(x->rdmult, x->rddiv, + if (RDCOST(x->rdmult, x->rddiv, tmp_rate_y + tmp_rate_uv, + tmp_dist) < RDCOST(x->rdmult, x->rddiv, 0, tmp_sse)) + tmp_alt_rd = RDCOST( + x->rdmult, x->rddiv, tmp_rate + vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0), tmp_dist); else - tmp_alt_rd = RDCOST(x->rdmult, x->rddiv, + tmp_alt_rd = RDCOST( + x->rdmult, x->rddiv, tmp_rate + vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1) - - tmp_rate_y - tmp_rate_uv, + tmp_rate_y - tmp_rate_uv, tmp_sse); #endif // CONFIG_OBMC } @@ -9436,8 +8940,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, frame_mv[NEARMV][ref_frame] = backup_mv; frame_mv[NEWMV][ref_frame] = backup_fmv[0]; - if (comp_pred) - frame_mv[NEWMV][second_ref_frame] = backup_fmv[1]; + if (comp_pred) frame_mv[NEWMV][second_ref_frame] = backup_fmv[1]; #if CONFIG_VAR_TX for (i = 0; i < MAX_MB_PLANE; ++i) memcpy(x->blk_skip[i], x->blk_skip_drl[i], @@ -9445,17 +8948,14 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, #endif } mbmi_ext->ref_mvs[ref_frame][0] = backup_ref_mv[0]; - if (comp_pred) - mbmi_ext->ref_mvs[second_ref_frame][0] = backup_ref_mv[1]; + if (comp_pred) mbmi_ext->ref_mvs[second_ref_frame][0] = backup_ref_mv[1]; #endif // CONFIG_REF_MV - if (this_rd == INT64_MAX) - continue; + if (this_rd == INT64_MAX) continue; compmode_cost = vp10_cost_bit(comp_mode_p, comp_pred); - if (cm->reference_mode == REFERENCE_MODE_SELECT) - rate2 += compmode_cost; + if (cm->reference_mode == REFERENCE_MODE_SELECT) rate2 += compmode_cost; } #if CONFIG_EXT_INTER @@ -9563,8 +9063,9 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, *returnrate_nocoef = rate2; else *returnrate_nocoef = rate2 - rate_y - rate_uv; - *returnrate_nocoef -= vp10_cost_bit(vp10_get_skip_prob(cm, xd), - disable_skip || skippable || this_skip2); + *returnrate_nocoef -= + vp10_cost_bit(vp10_get_skip_prob(cm, xd), + disable_skip || skippable || this_skip2); *returnrate_nocoef -= vp10_cost_bit(vp10_get_intra_inter_prob(cm, xd), mbmi->ref_frame[0] != INTRA_FRAME); #if CONFIG_OBMC || CONFIG_WARPED_MOTION @@ -9578,8 +9079,8 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, best_mbmode = *mbmi; best_skip2 = this_skip2; best_mode_skippable = skippable; - best_rate_y = rate_y + - vp10_cost_bit(vp10_get_skip_prob(cm, xd), this_skip2 || skippable); + best_rate_y = rate_y + vp10_cost_bit(vp10_get_skip_prob(cm, xd), + this_skip2 || skippable); best_rate_uv = rate_uv; #if CONFIG_VAR_TX @@ -9604,8 +9105,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, const int var_adjust = (x->source_variance < 16); scale -= var_adjust; } - if (ref_frame > INTRA_FRAME && - distortion2 * scale < qstep * qstep) { + if (ref_frame > INTRA_FRAME && distortion2 * scale < qstep * qstep) { early_term = 1; } } @@ -9638,11 +9138,9 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, best_pred_rd[REFERENCE_MODE_SELECT] = hybrid_rd; } - if (early_term) - break; + if (early_term) break; - if (x->skip && !comp_pred) - break; + if (x->skip && !comp_pred) break; } if (xd->lossless[mbmi->segment_id] == 0 && best_mode_index >= 0 && @@ -9673,19 +9171,18 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, vp10_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); #if CONFIG_OBMC if (mbmi->motion_variation == OBMC_CAUSAL) - vp10_build_obmc_inter_prediction(cm, xd, mi_row, mi_col, - dst_buf1, dst_stride1, - dst_buf2, dst_stride2); + vp10_build_obmc_inter_prediction(cm, xd, mi_row, mi_col, dst_buf1, + dst_stride1, dst_buf2, dst_stride2); #endif // CONFIG_OBMC vp10_subtract_plane(x, bsize, 0); #if CONFIG_VAR_TX if (cm->tx_mode == TX_MODE_SELECT || xd->lossless[mbmi->segment_id]) { - select_tx_type_yrd(cpi, x, &rate_y, &dist_y, &skip_y, &sse_y, - bsize, INT64_MAX); + select_tx_type_yrd(cpi, x, &rate_y, &dist_y, &skip_y, &sse_y, bsize, + INT64_MAX); } else { int idx, idy; - super_block_yrd(cpi, x, &rate_y, &dist_y, &skip_y, &sse_y, - bsize, INT64_MAX); + super_block_yrd(cpi, x, &rate_y, &dist_y, &skip_y, &sse_y, bsize, + INT64_MAX); for (idy = 0; idy < xd->n8_h; ++idy) for (idx = 0; idx < xd->n8_w; ++idx) mbmi->inter_tx_size[idy][idx] = mbmi->tx_size; @@ -9693,19 +9190,19 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, sizeof(uint8_t) * xd->n8_h * xd->n8_w * 4); } - inter_block_uvrd(cpi, x, &rate_uv, &dist_uv, &skip_uv, - &sse_uv, bsize, INT64_MAX); + inter_block_uvrd(cpi, x, &rate_uv, &dist_uv, &skip_uv, &sse_uv, bsize, + INT64_MAX); #else - super_block_yrd(cpi, x, &rate_y, &dist_y, &skip_y, &sse_y, - bsize, INT64_MAX); - super_block_uvrd(cpi, x, &rate_uv, &dist_uv, &skip_uv, - &sse_uv, bsize, INT64_MAX); + super_block_yrd(cpi, x, &rate_y, &dist_y, &skip_y, &sse_y, bsize, + INT64_MAX); + super_block_uvrd(cpi, x, &rate_uv, &dist_uv, &skip_uv, &sse_uv, bsize, + INT64_MAX); #endif // CONFIG_VAR_TX } else { - super_block_yrd(cpi, x, &rate_y, &dist_y, &skip_y, &sse_y, - bsize, INT64_MAX); - super_block_uvrd(cpi, x, &rate_uv, &dist_uv, &skip_uv, - &sse_uv, bsize, INT64_MAX); + super_block_yrd(cpi, x, &rate_y, &dist_y, &skip_y, &sse_y, bsize, + INT64_MAX); + super_block_uvrd(cpi, x, &rate_uv, &dist_uv, &skip_uv, &sse_uv, bsize, + INT64_MAX); } if (RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv, (dist_y + dist_uv)) > @@ -9720,10 +9217,8 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, rate_y += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0); } - if (RDCOST(x->rdmult, x->rddiv, - best_rate_y + best_rate_uv, rd_cost->dist) > - RDCOST(x->rdmult, x->rddiv, - rate_y + rate_uv, (dist_y + dist_uv))) { + if (RDCOST(x->rdmult, x->rddiv, best_rate_y + best_rate_uv, rd_cost->dist) > + RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv, (dist_y + dist_uv))) { #if CONFIG_VAR_TX int idx, idy; #endif @@ -9740,8 +9235,8 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, #endif rd_cost->rate += (rate_y + rate_uv - best_rate_y - best_rate_uv); rd_cost->dist = dist_y + dist_uv; - rd_cost->rdcost = RDCOST(x->rdmult, x->rddiv, - rd_cost->rate, rd_cost->dist); + rd_cost->rdcost = + RDCOST(x->rdmult, x->rddiv, rd_cost->rate, rd_cost->dist); best_skip2 = skip_blk; } } @@ -9767,34 +9262,29 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, mbmi->ref_frame[0] = INTRA_FRAME; mbmi->ref_frame[1] = NONE; palette_mode_info.palette_size[0] = 0; - rate_overhead = - rd_pick_palette_intra_sby(cpi, x, bsize, palette_ctx, - intra_mode_cost[DC_PRED], - &palette_mode_info, best_palette_color_map, - &best_tx_size, &best_tx_type, &mode_selected, - &dummy_rd); - if (palette_mode_info.palette_size[0] == 0) - goto PALETTE_EXIT; + rate_overhead = rd_pick_palette_intra_sby( + cpi, x, bsize, palette_ctx, intra_mode_cost[DC_PRED], + &palette_mode_info, best_palette_color_map, &best_tx_size, + &best_tx_type, &mode_selected, &dummy_rd); + if (palette_mode_info.palette_size[0] == 0) goto PALETTE_EXIT; - pmi->palette_size[0] = - palette_mode_info.palette_size[0]; + pmi->palette_size[0] = palette_mode_info.palette_size[0]; if (palette_mode_info.palette_size[0] > 0) { memcpy(pmi->palette_colors, palette_mode_info.palette_colors, PALETTE_MAX_SIZE * sizeof(palette_mode_info.palette_colors[0])); memcpy(color_map, best_palette_color_map, rows * cols * sizeof(best_palette_color_map[0])); } - super_block_yrd(cpi, x, &rate_y, &distortion_y, &skippable, - NULL, bsize, best_rd); - if (rate_y == INT_MAX) - goto PALETTE_EXIT; - uv_tx = get_uv_tx_size_impl(mbmi->tx_size, bsize, - xd->plane[1].subsampling_x, - xd->plane[1].subsampling_y); + super_block_yrd(cpi, x, &rate_y, &distortion_y, &skippable, NULL, bsize, + best_rd); + if (rate_y == INT_MAX) goto PALETTE_EXIT; + uv_tx = + get_uv_tx_size_impl(mbmi->tx_size, bsize, xd->plane[1].subsampling_x, + xd->plane[1].subsampling_y); if (rate_uv_intra[uv_tx] == INT_MAX) { - choose_intra_uv_mode(cpi, x, ctx, bsize, uv_tx, - &rate_uv_intra[uv_tx], &rate_uv_tokenonly[uv_tx], - &dist_uv[uv_tx], &skip_uv[uv_tx], &mode_uv[uv_tx]); + choose_intra_uv_mode(cpi, x, ctx, bsize, uv_tx, &rate_uv_intra[uv_tx], + &rate_uv_tokenonly[uv_tx], &dist_uv[uv_tx], + &skip_uv[uv_tx], &mode_uv[uv_tx]); pmi_uv[uv_tx] = *pmi; #if CONFIG_EXT_INTRA ext_intra_mode_info_uv[uv_tx] = mbmi->ext_intra_mode_info; @@ -9849,27 +9339,23 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, best_mode_skippable = skippable; } } - PALETTE_EXIT: +PALETTE_EXIT: #if CONFIG_EXT_INTRA // TODO(huisu): ext-intra is turned off in lossless mode for now to // avoid a unit test failure - if (!xd->lossless[mbmi->segment_id] && - ALLOW_FILTER_INTRA_MODES && + if (!xd->lossless[mbmi->segment_id] && ALLOW_FILTER_INTRA_MODES && mbmi->palette_mode_info.palette_size[0] == 0 && !dc_skipped && - best_mode_index >= 0 && - best_intra_rd < (best_rd + (best_rd >> 3))) { - pick_ext_intra_interframe(cpi, x, ctx, bsize, rate_uv_intra, - rate_uv_tokenonly, dist_uv, skip_uv, - mode_uv, ext_intra_mode_info_uv, - pmi_uv, uv_angle_delta, palette_ctx, 0, - ref_costs_single, &best_rd, &best_intra_rd, - &best_intra_mode, &best_mode_index, - &best_skip2, &best_mode_skippable, + best_mode_index >= 0 && best_intra_rd < (best_rd + (best_rd >> 3))) { + pick_ext_intra_interframe( + cpi, x, ctx, bsize, rate_uv_intra, rate_uv_tokenonly, dist_uv, skip_uv, + mode_uv, ext_intra_mode_info_uv, pmi_uv, uv_angle_delta, palette_ctx, 0, + ref_costs_single, &best_rd, &best_intra_rd, &best_intra_mode, + &best_mode_index, &best_skip2, &best_mode_skippable, #if CONFIG_SUPERTX - returnrate_nocoef, + returnrate_nocoef, #endif // CONFIG_SUPERTX - best_pred_rd, &best_mbmode, rd_cost); + best_pred_rd, &best_mbmode, rd_cost); } #endif // CONFIG_EXT_INTRA @@ -9879,19 +9365,19 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, // are corrected. if (best_mbmode.mode == NEWMV #if CONFIG_EXT_INTER - || best_mbmode.mode == NEWFROMNEARMV - || best_mbmode.mode == NEW_NEWMV + || best_mbmode.mode == NEWFROMNEARMV || best_mbmode.mode == NEW_NEWMV #endif // CONFIG_EXT_INTER - ) { - const MV_REFERENCE_FRAME refs[2] = {best_mbmode.ref_frame[0], - best_mbmode.ref_frame[1]}; + ) { + const MV_REFERENCE_FRAME refs[2] = { best_mbmode.ref_frame[0], + best_mbmode.ref_frame[1] }; int comp_pred_mode = refs[1] > INTRA_FRAME; #if CONFIG_REF_MV const uint8_t rf_type = vp10_ref_frame_type(best_mbmode.ref_frame); if (!comp_pred_mode) { int i; - int ref_set = (mbmi_ext->ref_mv_count[rf_type] >= 2) ? - VPXMIN(2, mbmi_ext->ref_mv_count[rf_type] - 2) : INT_MAX; + int ref_set = (mbmi_ext->ref_mv_count[rf_type] >= 2) + ? VPXMIN(2, mbmi_ext->ref_mv_count[rf_type] - 2) + : INT_MAX; for (i = 0; i <= ref_set && ref_set != INT_MAX; ++i) { int_mv cur_mv = mbmi_ext->ref_mv_stack[rf_type][i + 1].this_mv; @@ -9919,8 +9405,9 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, } #else int i; - int ref_set = (mbmi_ext->ref_mv_count[rf_type] >= 2) ? - VPXMIN(2, mbmi_ext->ref_mv_count[rf_type] - 2) : INT_MAX; + int ref_set = (mbmi_ext->ref_mv_count[rf_type] >= 2) + ? VPXMIN(2, mbmi_ext->ref_mv_count[rf_type] - 2) + : INT_MAX; for (i = 0; i <= ref_set && ref_set != INT_MAX; ++i) { nearmv[0] = mbmi_ext->ref_mv_stack[rf_type][i + 1].this_mv; @@ -9966,41 +9453,45 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, #if CONFIG_EXT_INTER if (!comp_pred_mode) { #endif // CONFIG_EXT_INTER - if (frame_mv[NEARESTMV][refs[0]].as_int == best_mbmode.mv[0].as_int && - ((comp_pred_mode && frame_mv[NEARESTMV][refs[1]].as_int == - best_mbmode.mv[1].as_int) || !comp_pred_mode)) - best_mbmode.mode = NEARESTMV; - else if (frame_mv[NEARMV][refs[0]].as_int == best_mbmode.mv[0].as_int && - ((comp_pred_mode && frame_mv[NEARMV][refs[1]].as_int == - best_mbmode.mv[1].as_int) || !comp_pred_mode)) - best_mbmode.mode = NEARMV; - else if (best_mbmode.mv[0].as_int == 0 && - ((comp_pred_mode && best_mbmode.mv[1].as_int == 0) || !comp_pred_mode)) - best_mbmode.mode = ZEROMV; + if (frame_mv[NEARESTMV][refs[0]].as_int == best_mbmode.mv[0].as_int && + ((comp_pred_mode && + frame_mv[NEARESTMV][refs[1]].as_int == best_mbmode.mv[1].as_int) || + !comp_pred_mode)) + best_mbmode.mode = NEARESTMV; + else if (frame_mv[NEARMV][refs[0]].as_int == best_mbmode.mv[0].as_int && + ((comp_pred_mode && + frame_mv[NEARMV][refs[1]].as_int == + best_mbmode.mv[1].as_int) || + !comp_pred_mode)) + best_mbmode.mode = NEARMV; + else if (best_mbmode.mv[0].as_int == 0 && + ((comp_pred_mode && best_mbmode.mv[1].as_int == 0) || + !comp_pred_mode)) + best_mbmode.mode = ZEROMV; #if CONFIG_EXT_INTER } else { - const MV_REFERENCE_FRAME refs[2] = {best_mbmode.ref_frame[0], - best_mbmode.ref_frame[1]}; + const MV_REFERENCE_FRAME refs[2] = { best_mbmode.ref_frame[0], + best_mbmode.ref_frame[1] }; if (frame_mv[NEAREST_NEARESTMV][refs[0]].as_int == - best_mbmode.mv[0].as_int && + best_mbmode.mv[0].as_int && frame_mv[NEAREST_NEARESTMV][refs[1]].as_int == - best_mbmode.mv[1].as_int) + best_mbmode.mv[1].as_int) best_mbmode.mode = NEAREST_NEARESTMV; else if (frame_mv[NEAREST_NEARMV][refs[0]].as_int == - best_mbmode.mv[0].as_int && + best_mbmode.mv[0].as_int && frame_mv[NEAREST_NEARMV][refs[1]].as_int == - best_mbmode.mv[1].as_int) + best_mbmode.mv[1].as_int) best_mbmode.mode = NEAREST_NEARMV; else if (frame_mv[NEAR_NEARESTMV][refs[0]].as_int == - best_mbmode.mv[0].as_int && + best_mbmode.mv[0].as_int && frame_mv[NEAR_NEARESTMV][refs[1]].as_int == - best_mbmode.mv[1].as_int) + best_mbmode.mv[1].as_int) best_mbmode.mode = NEAR_NEARESTMV; else if (frame_mv[NEAR_NEARMV][refs[0]].as_int == - best_mbmode.mv[0].as_int && + best_mbmode.mv[0].as_int && frame_mv[NEAR_NEARMV][refs[1]].as_int == - best_mbmode.mv[1].as_int) + best_mbmode.mv[1].as_int) best_mbmode.mode = NEAR_NEARMV; else if (best_mbmode.mv[0].as_int == 0 && best_mbmode.mv[1].as_int == 0) best_mbmode.mode = ZERO_ZEROMV; @@ -10010,22 +9501,20 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, } #if CONFIG_REF_MV - if (best_mbmode.ref_frame[0] > INTRA_FRAME && - best_mbmode.mv[0].as_int == 0 && + if (best_mbmode.ref_frame[0] > INTRA_FRAME && best_mbmode.mv[0].as_int == 0 && #if CONFIG_EXT_INTER (best_mbmode.ref_frame[1] <= INTRA_FRAME) #else (best_mbmode.ref_frame[1] == NONE || best_mbmode.mv[1].as_int == 0) #endif // CONFIG_EXT_INTER - ) { + ) { int16_t mode_ctx = mbmi_ext->mode_context[best_mbmode.ref_frame[0]]; #if !CONFIG_EXT_INTER if (best_mbmode.ref_frame[1] > NONE) mode_ctx &= (mbmi_ext->mode_context[best_mbmode.ref_frame[1]] | 0x00ff); #endif // !CONFIG_EXT_INTER - if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET)) - best_mbmode.mode = ZEROMV; + if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET)) best_mbmode.mode = ZEROMV; } #endif @@ -10042,12 +9531,10 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, TX_SIZE uv_tx_size; *mbmi = best_mbmode; uv_tx_size = get_uv_tx_size(mbmi, &xd->plane[1]); - rd_pick_intra_sbuv_mode(cpi, x, &rate_uv_intra[uv_tx_size], - &rate_uv_tokenonly[uv_tx_size], - &dist_uv[uv_tx_size], - &skip_uv[uv_tx_size], - bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize, - uv_tx_size); + rd_pick_intra_sbuv_mode( + cpi, x, &rate_uv_intra[uv_tx_size], &rate_uv_tokenonly[uv_tx_size], + &dist_uv[uv_tx_size], &skip_uv[uv_tx_size], + bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize, uv_tx_size); } } @@ -10108,13 +9595,11 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, } } -void vp10_rd_pick_inter_mode_sb_seg_skip(VP10_COMP *cpi, - TileDataEnc *tile_data, - MACROBLOCK *x, - RD_COST *rd_cost, - BLOCK_SIZE bsize, - PICK_MODE_CONTEXT *ctx, - int64_t best_rd_so_far) { +void vp10_rd_pick_inter_mode_sb_seg_skip(VP10_COMP *cpi, TileDataEnc *tile_data, + MACROBLOCK *x, RD_COST *rd_cost, + BLOCK_SIZE bsize, + PICK_MODE_CONTEXT *ctx, + int64_t best_rd_so_far) { VP10_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; @@ -10133,8 +9618,7 @@ void vp10_rd_pick_inter_mode_sb_seg_skip(VP10_COMP *cpi, estimate_ref_frame_costs(cm, xd, segment_id, ref_costs_single, ref_costs_comp, &comp_mode_p); - for (i = 0; i < TOTAL_REFS_PER_FRAME; ++i) - x->pred_sse[i] = INT_MAX; + for (i = 0; i < TOTAL_REFS_PER_FRAME; ++i) x->pred_sse[i] = INT_MAX; for (i = LAST_FRAME; i < TOTAL_REFS_PER_FRAME; ++i) x->pred_mv_sad[i] = INT_MAX; @@ -10172,8 +9656,7 @@ void vp10_rd_pick_inter_mode_sb_seg_skip(VP10_COMP *cpi, for (i = 0; i < SWITCHABLE_FILTERS; ++i) { #if CONFIG_DUAL_FILTER int k; - for (k = 0; k < 4; ++k) - mbmi->interp_filter[k] = i; + for (k = 0; k < 4; ++k) mbmi->interp_filter[k] = i; #else mbmi->interp_filter = i; #endif @@ -10192,16 +9675,14 @@ void vp10_rd_pick_inter_mode_sb_seg_skip(VP10_COMP *cpi, // Set the appropriate filter if (cm->interp_filter == SWITCHABLE) { #if CONFIG_DUAL_FILTER - for (i = 0; i < 4; ++i) - mbmi->interp_filter[i] = best_filter; + for (i = 0; i < 4; ++i) mbmi->interp_filter[i] = best_filter; #else mbmi->interp_filter = best_filter; #endif rate2 += vp10_get_switchable_rate(cpi, xd); } else { #if CONFIG_DUAL_FILTER - for (i = 0; i < 4; ++i) - mbmi->interp_filter[0] = cm->interp_filter; + for (i = 0; i < 4; ++i) mbmi->interp_filter[0] = cm->interp_filter; #else mbmi->interp_filter = cm->interp_filter; #endif @@ -10238,20 +9719,17 @@ void vp10_rd_pick_inter_mode_sb_seg_skip(VP10_COMP *cpi, vp10_zero(best_pred_diff); - store_coding_context(x, ctx, THR_ZEROMV, - best_pred_diff, 0); + store_coding_context(x, ctx, THR_ZEROMV, best_pred_diff, 0); } void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, TileDataEnc *tile_data, - struct macroblock *x, - int mi_row, int mi_col, - struct RD_COST *rd_cost, + struct macroblock *x, int mi_row, + int mi_col, struct RD_COST *rd_cost, #if CONFIG_SUPERTX int *returnrate_nocoef, #endif // CONFIG_SUPERTX - BLOCK_SIZE bsize, - PICK_MODE_CONTEXT *ctx, + BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, int64_t best_rd_so_far) { VP10_COMMON *const cm = &cpi->common; RD_OPT *const rd_opt = &cpi->rd; @@ -10296,7 +9774,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, int skip_uv; PREDICTION_MODE mode_uv = DC_PRED; const int intra_cost_penalty = vp10_get_intra_cost_penalty( - cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth); + cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth); #if CONFIG_EXT_INTER int_mv seg_mvs[4][2][TOTAL_REFS_PER_FRAME]; #else @@ -10306,7 +9784,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, int best_skip2 = 0; int ref_frame_skip_mask[2] = { 0 }; int internal_active_edge = - vp10_active_edge_sb(cpi, mi_row, mi_col) && vp10_internal_image_edge(cpi); + vp10_active_edge_sb(cpi, mi_row, mi_col) && vp10_internal_image_edge(cpi); #if CONFIG_SUPERTX best_rd_so_far = INT64_MAX; @@ -10342,8 +9820,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, estimate_ref_frame_costs(cm, xd, segment_id, ref_costs_single, ref_costs_comp, &comp_mode_p); - for (i = 0; i < REFERENCE_MODES; ++i) - best_pred_rd[i] = INT64_MAX; + for (i = 0; i < REFERENCE_MODES; ++i) best_pred_rd[i] = INT64_MAX; rate_uv_intra = INT_MAX; rd_cost->rate = INT_MAX; @@ -10358,8 +9835,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, #endif // CONFIG_REF_MV && CONFIG_EXT_INTER if (cpi->ref_frame_flags & flag_list[ref_frame]) { setup_buffer_inter(cpi, x, ref_frame, bsize, mi_row, mi_col, - frame_mv[NEARESTMV], frame_mv[NEARMV], - yv12_mb); + frame_mv[NEARESTMV], frame_mv[NEARMV], yv12_mb); } else { ref_frame_skip_mask[0] |= (1 << ref_frame); ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK; @@ -10395,13 +9871,11 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, if (ref_index > 2 && sf->mode_skip_start < MAX_MODES) { if (ref_index == 3) { switch (best_mbmode.ref_frame[0]) { - case INTRA_FRAME: - break; + case INTRA_FRAME: break; case LAST_FRAME: ref_frame_skip_mask[0] |= (1 << GOLDEN_FRAME) | #if CONFIG_EXT_REFS - (1 << LAST2_FRAME) | - (1 << LAST3_FRAME) | + (1 << LAST2_FRAME) | (1 << LAST3_FRAME) | (1 << BWDREF_FRAME) | #endif // CONFIG_EXT_REFS (1 << ALTREF_FRAME); @@ -10409,27 +9883,22 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, break; #if CONFIG_EXT_REFS case LAST2_FRAME: - ref_frame_skip_mask[0] |= (1 << LAST_FRAME) | - (1 << LAST3_FRAME) | + ref_frame_skip_mask[0] |= (1 << LAST_FRAME) | (1 << LAST3_FRAME) | (1 << GOLDEN_FRAME) | - (1 << BWDREF_FRAME) | - (1 << ALTREF_FRAME); + (1 << BWDREF_FRAME) | (1 << ALTREF_FRAME); ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK; break; case LAST3_FRAME: - ref_frame_skip_mask[0] |= (1 << LAST_FRAME) | - (1 << LAST2_FRAME) | + ref_frame_skip_mask[0] |= (1 << LAST_FRAME) | (1 << LAST2_FRAME) | (1 << GOLDEN_FRAME) | - (1 << BWDREF_FRAME) | - (1 << ALTREF_FRAME); + (1 << BWDREF_FRAME) | (1 << ALTREF_FRAME); ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK; break; #endif // CONFIG_EXT_REFS case GOLDEN_FRAME: ref_frame_skip_mask[0] |= (1 << LAST_FRAME) | #if CONFIG_EXT_REFS - (1 << LAST2_FRAME) | - (1 << LAST3_FRAME) | + (1 << LAST2_FRAME) | (1 << LAST3_FRAME) | (1 << BWDREF_FRAME) | #endif // CONFIG_EXT_REFS (1 << ALTREF_FRAME); @@ -10437,10 +9906,8 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, break; #if CONFIG_EXT_REFS case BWDREF_FRAME: - ref_frame_skip_mask[0] |= (1 << LAST_FRAME) | - (1 << LAST2_FRAME) | - (1 << LAST3_FRAME) | - (1 << GOLDEN_FRAME) | + ref_frame_skip_mask[0] |= (1 << LAST_FRAME) | (1 << LAST2_FRAME) | + (1 << LAST3_FRAME) | (1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME); ref_frame_skip_mask[1] |= (1 << ALTREF_FRAME) | 0x01; break; @@ -10448,8 +9915,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, case ALTREF_FRAME: ref_frame_skip_mask[0] |= (1 << LAST_FRAME) | #if CONFIG_EXT_REFS - (1 << LAST2_FRAME) | - (1 << LAST3_FRAME) | + (1 << LAST2_FRAME) | (1 << LAST3_FRAME) | (1 << BWDREF_FRAME) | #endif // CONFIG_EXT_REFS (1 << GOLDEN_FRAME); @@ -10478,14 +9944,11 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, comp_pred = second_ref_frame > INTRA_FRAME; if (comp_pred) { - if (!cpi->allow_comp_inter_inter) - continue; - if (!(cpi->ref_frame_flags & flag_list[second_ref_frame])) - continue; + if (!cpi->allow_comp_inter_inter) continue; + if (!(cpi->ref_frame_flags & flag_list[second_ref_frame])) continue; // Do not allow compound prediction if the segment level reference frame // feature is in use as in this case there can only be one reference. - if (segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) - continue; + if (segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) continue; if ((sf->mode_search_skip_flags & FLAG_SKIP_COMP_BESTINTRA) && best_mbmode.ref_frame[0] == INTRA_FRAME) @@ -10512,9 +9975,9 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, if (segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME) && get_segdata(seg, segment_id, SEG_LVL_REF_FRAME) != (int)ref_frame) { continue; - // Disable this drop out case if the ref frame - // segment level feature is enabled for this segment. This is to - // prevent the possibility that we end up unable to pick any mode. + // Disable this drop out case if the ref frame + // segment level feature is enabled for this segment. This is to + // prevent the possibility that we end up unable to pick any mode. } else if (!segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) { // Only consider ZEROMV/ALTREF_FRAME for alt ref frame, // unless ARNR filtering is enabled in which case we want @@ -10528,15 +9991,16 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, mbmi->uv_mode = DC_PRED; mbmi->ref_frame[0] = ref_frame; mbmi->ref_frame[1] = second_ref_frame; - // Evaluate all sub-pel filters irrespective of whether we can use - // them for this frame. +// Evaluate all sub-pel filters irrespective of whether we can use +// them for this frame. #if CONFIG_DUAL_FILTER for (i = 0; i < 4; ++i) - mbmi->interp_filter[i] = cm->interp_filter == SWITCHABLE ? - EIGHTTAP_REGULAR : cm->interp_filter; + mbmi->interp_filter[i] = cm->interp_filter == SWITCHABLE + ? EIGHTTAP_REGULAR + : cm->interp_filter; #else - mbmi->interp_filter = cm->interp_filter == SWITCHABLE ? EIGHTTAP_REGULAR - : cm->interp_filter; + mbmi->interp_filter = + cm->interp_filter == SWITCHABLE ? EIGHTTAP_REGULAR : cm->interp_filter; #endif x->skip = 0; set_ref_ptrs(cm, xd, ref_frame, second_ref_frame); @@ -10544,8 +10008,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, // Select prediction reference frames. for (i = 0; i < MAX_MB_PLANE; i++) { xd->plane[i].pre[0] = yv12_mb[ref_frame][i]; - if (comp_pred) - xd->plane[i].pre[1] = yv12_mb[second_ref_frame][i]; + if (comp_pred) xd->plane[i].pre[1] = yv12_mb[second_ref_frame][i]; } #if CONFIG_VAR_TX @@ -10554,19 +10017,16 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, if (ref_frame == INTRA_FRAME) { int rate; - if (rd_pick_intra_sub_8x8_y_mode(cpi, x, &rate, &rate_y, - &distortion_y, best_rd) >= best_rd) + if (rd_pick_intra_sub_8x8_y_mode(cpi, x, &rate, &rate_y, &distortion_y, + best_rd) >= best_rd) continue; rate2 += rate; rate2 += intra_cost_penalty; distortion2 += distortion_y; if (rate_uv_intra == INT_MAX) { - choose_intra_uv_mode(cpi, x, ctx, bsize, TX_4X4, - &rate_uv_intra, - &rate_uv_tokenonly, - &dist_uv, &skip_uv, - &mode_uv); + choose_intra_uv_mode(cpi, x, ctx, bsize, TX_4X4, &rate_uv_intra, + &rate_uv_tokenonly, &dist_uv, &skip_uv, &mode_uv); } rate2 += rate_uv_intra; rate_uv = rate_uv_tokenonly; @@ -10582,8 +10042,8 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, int64_t tmp_best_distortion = INT_MAX, tmp_best_sse, uv_sse; int tmp_best_skippable = 0; int switchable_filter_index; - int_mv *second_ref = comp_pred ? - &x->mbmi_ext->ref_mvs[second_ref_frame][0] : NULL; + int_mv *second_ref = + comp_pred ? &x->mbmi_ext->ref_mvs[second_ref_frame][0] : NULL; b_mode_info tmp_best_bmodes[16]; // Should this be 4 ? MB_MODE_INFO tmp_best_mbmode; #if CONFIG_DUAL_FILTER @@ -10605,20 +10065,23 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, } #endif // CONFIG_EXT_INTER - this_rd_thresh = (ref_frame == LAST_FRAME) ? - rd_opt->threshes[segment_id][bsize][THR_LAST] : - rd_opt->threshes[segment_id][bsize][THR_ALTR]; + this_rd_thresh = (ref_frame == LAST_FRAME) + ? rd_opt->threshes[segment_id][bsize][THR_LAST] + : rd_opt->threshes[segment_id][bsize][THR_ALTR]; #if CONFIG_EXT_REFS - this_rd_thresh = (ref_frame == LAST2_FRAME) ? - rd_opt->threshes[segment_id][bsize][THR_LAST2] : this_rd_thresh; - this_rd_thresh = (ref_frame == LAST3_FRAME) ? - rd_opt->threshes[segment_id][bsize][THR_LAST3] : this_rd_thresh; + this_rd_thresh = (ref_frame == LAST2_FRAME) + ? rd_opt->threshes[segment_id][bsize][THR_LAST2] + : this_rd_thresh; + this_rd_thresh = (ref_frame == LAST3_FRAME) + ? rd_opt->threshes[segment_id][bsize][THR_LAST3] + : this_rd_thresh; #endif // CONFIG_EXT_REFS - this_rd_thresh = (ref_frame == GOLDEN_FRAME) ? - rd_opt->threshes[segment_id][bsize][THR_GOLD] : this_rd_thresh; + this_rd_thresh = (ref_frame == GOLDEN_FRAME) + ? rd_opt->threshes[segment_id][bsize][THR_GOLD] + : this_rd_thresh; #if CONFIG_EXT_REFS - // TODO(zoeliu): To explore whether this_rd_thresh should consider - // BWDREF_FRAME and ALTREF_FRAME +// TODO(zoeliu): To explore whether this_rd_thresh should consider +// BWDREF_FRAME and ALTREF_FRAME #endif // CONFIG_EXT_REFS // TODO(any): Add search of the tx_type to improve rd performance at the @@ -10649,11 +10112,13 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, #endif } else if (sf->adaptive_pred_interp_filter == 2) { #if CONFIG_DUAL_FILTER - tmp_best_filter[0] = ctx->pred_interp_filter < SWITCHABLE ? - ctx->pred_interp_filter : 0; + tmp_best_filter[0] = ctx->pred_interp_filter < SWITCHABLE + ? ctx->pred_interp_filter + : 0; #else - tmp_best_filter = ctx->pred_interp_filter < SWITCHABLE ? - ctx->pred_interp_filter : 0; + tmp_best_filter = ctx->pred_interp_filter < SWITCHABLE + ? ctx->pred_interp_filter + : 0; #endif } else { #if CONFIG_DUAL_FILTER @@ -10680,17 +10145,14 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, #else mbmi->interp_filter = switchable_filter_index; #endif - tmp_rd = rd_pick_best_sub8x8_mode(cpi, x, - &mbmi_ext->ref_mvs[ref_frame][0], - second_ref, best_yrd, &rate, - &rate_y, &distortion, - &skippable, &total_sse, - (int) this_rd_thresh, seg_mvs, + tmp_rd = rd_pick_best_sub8x8_mode( + cpi, x, &mbmi_ext->ref_mvs[ref_frame][0], second_ref, best_yrd, + &rate, &rate_y, &distortion, &skippable, &total_sse, + (int)this_rd_thresh, seg_mvs, #if CONFIG_EXT_INTER - compound_seg_newmvs, + compound_seg_newmvs, #endif // CONFIG_EXT_INTER - bsi, switchable_filter_index, - mi_row, mi_col); + bsi, switchable_filter_index, mi_row, mi_col); #if CONFIG_EXT_INTERP #if CONFIG_DUAL_FILTER if (!vp10_is_interp_needed(xd) && cm->interp_filter == SWITCHABLE && @@ -10703,12 +10165,10 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, continue; #endif #endif // CONFIG_EXT_INTERP - if (tmp_rd == INT64_MAX) - continue; + if (tmp_rd == INT64_MAX) continue; rs = vp10_get_switchable_rate(cpi, xd); rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0); - if (cm->interp_filter == SWITCHABLE) - tmp_rd += rs_rd; + if (cm->interp_filter == SWITCHABLE) tmp_rd += rs_rd; newbest = (tmp_rd < tmp_best_rd); if (newbest) { @@ -10725,12 +10185,11 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, if ((newbest && cm->interp_filter == SWITCHABLE) || ( #if CONFIG_DUAL_FILTER - mbmi->interp_filter[0] == cm->interp_filter + mbmi->interp_filter[0] == cm->interp_filter #else - mbmi->interp_filter == cm->interp_filter + mbmi->interp_filter == cm->interp_filter #endif - && - cm->interp_filter != SWITCHABLE)) { + && cm->interp_filter != SWITCHABLE)) { tmp_best_rdu = tmp_rd; tmp_best_rate = rate; tmp_best_ratey = rate_y; @@ -10747,36 +10206,38 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, } } - if (tmp_best_rdu == INT64_MAX && pred_exists) - continue; + if (tmp_best_rdu == INT64_MAX && pred_exists) continue; #if CONFIG_DUAL_FILTER - mbmi->interp_filter[0] = (cm->interp_filter == SWITCHABLE ? - tmp_best_filter[0] : cm->interp_filter); - mbmi->interp_filter[1] = (cm->interp_filter == SWITCHABLE ? - tmp_best_filter[1] : cm->interp_filter); - mbmi->interp_filter[2] = (cm->interp_filter == SWITCHABLE ? - tmp_best_filter[2] : cm->interp_filter); - mbmi->interp_filter[3] = (cm->interp_filter == SWITCHABLE ? - tmp_best_filter[3] : cm->interp_filter); + mbmi->interp_filter[0] = + (cm->interp_filter == SWITCHABLE ? tmp_best_filter[0] + : cm->interp_filter); + mbmi->interp_filter[1] = + (cm->interp_filter == SWITCHABLE ? tmp_best_filter[1] + : cm->interp_filter); + mbmi->interp_filter[2] = + (cm->interp_filter == SWITCHABLE ? tmp_best_filter[2] + : cm->interp_filter); + mbmi->interp_filter[3] = + (cm->interp_filter == SWITCHABLE ? tmp_best_filter[3] + : cm->interp_filter); #else - mbmi->interp_filter = (cm->interp_filter == SWITCHABLE ? - tmp_best_filter : cm->interp_filter); + mbmi->interp_filter = + (cm->interp_filter == SWITCHABLE ? tmp_best_filter + : cm->interp_filter); #endif if (!pred_exists) { // Handles the special case when a filter that is not in the // switchable list (bilinear) is indicated at the frame level - tmp_rd = rd_pick_best_sub8x8_mode(cpi, x, - &x->mbmi_ext->ref_mvs[ref_frame][0], - second_ref, best_yrd, &rate, &rate_y, - &distortion, &skippable, &total_sse, - (int) this_rd_thresh, seg_mvs, + tmp_rd = rd_pick_best_sub8x8_mode( + cpi, x, &x->mbmi_ext->ref_mvs[ref_frame][0], second_ref, best_yrd, + &rate, &rate_y, &distortion, &skippable, &total_sse, + (int)this_rd_thresh, seg_mvs, #if CONFIG_EXT_INTER - compound_seg_newmvs, + compound_seg_newmvs, #endif // CONFIG_EXT_INTER - bsi, 0, - mi_row, mi_col); + bsi, 0, mi_row, mi_col); #if CONFIG_EXT_INTERP #if CONFIG_DUAL_FILTER if (!vp10_is_interp_needed(xd) && cm->interp_filter == SWITCHABLE && @@ -10791,8 +10252,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, mbmi->interp_filter = EIGHTTAP_REGULAR; #endif // CONFIG_DUAL_FILTER #endif // CONFIG_EXT_INTERP - if (tmp_rd == INT64_MAX) - continue; + if (tmp_rd == INT64_MAX) continue; } else { total_sse = tmp_best_sse; rate = tmp_best_rate; @@ -10800,8 +10260,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, distortion = tmp_best_distortion; skippable = tmp_best_skippable; *mbmi = tmp_best_mbmode; - for (i = 0; i < 4; i++) - xd->mi[0]->bmi[i] = tmp_best_bmodes[i]; + for (i = 0; i < 4; i++) xd->mi[0]->bmi[i] = tmp_best_bmodes[i]; } // Add in the cost of the transform type if (!xd->lossless[mbmi->segment_id]) { @@ -10833,15 +10292,14 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, compmode_cost = vp10_cost_bit(comp_mode_p, comp_pred); - tmp_best_rdu = best_rd - - VPXMIN(RDCOST(x->rdmult, x->rddiv, rate2, distortion2), - RDCOST(x->rdmult, x->rddiv, 0, total_sse)); + tmp_best_rdu = + best_rd - VPXMIN(RDCOST(x->rdmult, x->rddiv, rate2, distortion2), + RDCOST(x->rdmult, x->rddiv, 0, total_sse)); if (tmp_best_rdu > 0) { // If even the 'Y' rd value of split is higher than best so far // then dont bother looking at UV - vp10_build_inter_predictors_sbuv(&x->e_mbd, mi_row, mi_col, - BLOCK_8X8); + vp10_build_inter_predictors_sbuv(&x->e_mbd, mi_row, mi_col, BLOCK_8X8); #if CONFIG_VAR_TX if (!inter_block_uvrd(cpi, x, &rate_uv, &distortion_uv, &uv_skippable, &uv_sse, BLOCK_8X8, tmp_best_rdu)) @@ -10860,8 +10318,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, } } - if (cm->reference_mode == REFERENCE_MODE_SELECT) - rate2 += compmode_cost; + if (cm->reference_mode == REFERENCE_MODE_SELECT) rate2 += compmode_cost; // Estimate the reference frame signaling cost and add it // to the rolling cost variable. @@ -10919,8 +10376,8 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, #if CONFIG_SUPERTX *returnrate_nocoef = rate2 - rate_y - rate_uv; if (!disable_skip) - *returnrate_nocoef -= vp10_cost_bit(vp10_get_skip_prob(cm, xd), - this_skip2); + *returnrate_nocoef -= + vp10_cost_bit(vp10_get_skip_prob(cm, xd), this_skip2); *returnrate_nocoef -= vp10_cost_bit(vp10_get_intra_inter_prob(cm, xd), mbmi->ref_frame[0] != INTRA_FRAME); assert(*returnrate_nocoef > 0); @@ -10928,8 +10385,8 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, rd_cost->dist = distortion2; rd_cost->rdcost = this_rd; best_rd = this_rd; - best_yrd = best_rd - - RDCOST(x->rdmult, x->rddiv, rate_uv, distortion_uv); + best_yrd = + best_rd - RDCOST(x->rdmult, x->rddiv, rate_uv, distortion_uv); best_mbmode = *mbmi; best_skip2 = this_skip2; @@ -10938,8 +10395,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, memset(ctx->blk_skip[i], 0, sizeof(uint8_t) * ctx->num_4x4_blk); #endif - for (i = 0; i < 4; i++) - best_bmodes[i] = xd->mi[0]->bmi[i]; + for (i = 0; i < 4; i++) best_bmodes[i] = xd->mi[0]->bmi[i]; // TODO(debargha): enhance this test with a better distortion prediction // based on qp, activity mask and history @@ -10957,8 +10413,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, const int var_adjust = (x->source_variance < 16); scale -= var_adjust; } - if (ref_frame > INTRA_FRAME && - distortion2 * scale < qstep * qstep) { + if (ref_frame > INTRA_FRAME && distortion2 * scale < qstep * qstep) { early_term = 1; } } @@ -10989,11 +10444,9 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, best_pred_rd[REFERENCE_MODE_SELECT] = hybrid_rd; } - if (early_term) - break; + if (early_term) break; - if (x->skip && !comp_pred) - break; + if (x->skip && !comp_pred) break; } if (best_rd >= best_rd_so_far) { @@ -11010,11 +10463,8 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, // Do Intra UV best rd mode selection if best mode choice above was intra. if (best_mbmode.ref_frame[0] == INTRA_FRAME) { *mbmi = best_mbmode; - rd_pick_intra_sbuv_mode(cpi, x, &rate_uv_intra, - &rate_uv_tokenonly, - &dist_uv, - &skip_uv, - BLOCK_8X8, TX_4X4); + rd_pick_intra_sbuv_mode(cpi, x, &rate_uv_intra, &rate_uv_tokenonly, + &dist_uv, &skip_uv, BLOCK_8X8, TX_4X4); } } @@ -11045,8 +10495,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, *mbmi = best_mbmode; x->skip |= best_skip2; if (!is_inter_block(&best_mbmode)) { - for (i = 0; i < 4; i++) - xd->mi[0]->bmi[i].as_mode = best_bmodes[i].as_mode; + for (i = 0; i < 4; i++) xd->mi[0]->bmi[i].as_mode = best_bmodes[i].as_mode; } else { for (i = 0; i < 4; ++i) memcpy(&xd->mi[0]->bmi[i], &best_bmodes[i], sizeof(b_mode_info)); @@ -11066,8 +10515,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, best_pred_diff[i] = best_rd - best_pred_rd[i]; } - store_coding_context(x, ctx, best_ref_index, - best_pred_diff, 0); + store_coding_context(x, ctx, best_ref_index, best_pred_diff, 0); } #if CONFIG_OBMC @@ -11109,15 +10557,13 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, // error(x, y) = // wsrc(x, y) - mask(x, y) * P(x, y) / (VPX_BLEND_A64_MAX_ALPHA ** 2) // -static void calc_target_weighted_pred( - const VP10_COMMON *cm, - const MACROBLOCK *x, - const MACROBLOCKD *xd, - int mi_row, int mi_col, - const uint8_t *above, int above_stride, - const uint8_t *left, int left_stride, - int32_t *mask_buf, - int32_t *wsrc_buf) { +static void calc_target_weighted_pred(const VP10_COMMON *cm, + const MACROBLOCK *x, + const MACROBLOCKD *xd, int mi_row, + int mi_col, const uint8_t *above, + int above_stride, const uint8_t *left, + int left_stride, int32_t *mask_buf, + int32_t *wsrc_buf) { const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; int row, col, i; const int bw = 8 * xd->n8_w; @@ -11136,8 +10582,7 @@ static void calc_target_weighted_pred( assert(xd->plane[0].subsampling_y == 0); vp10_zero_array(wsrc_buf, bw * bh); - for (i = 0; i < bw * bh; ++i) - mask_buf[i] = VPX_BLEND_A64_MAX_ALPHA; + for (i = 0; i < bw * bh; ++i) mask_buf[i] = VPX_BLEND_A64_MAX_ALPHA; // handle above row if (xd->up_available) { diff --git a/vp10/encoder/rdopt.h b/vp10/encoder/rdopt.h index da70a2252..2ff9c2490 100644 --- a/vp10/encoder/rdopt.h +++ b/vp10/encoder/rdopt.h @@ -26,36 +26,32 @@ struct macroblock; struct RD_COST; void vp10_rd_pick_intra_mode_sb(struct VP10_COMP *cpi, struct macroblock *x, - struct RD_COST *rd_cost, BLOCK_SIZE bsize, - PICK_MODE_CONTEXT *ctx, int64_t best_rd); + struct RD_COST *rd_cost, BLOCK_SIZE bsize, + PICK_MODE_CONTEXT *ctx, int64_t best_rd); unsigned int vp10_get_sby_perpixel_variance(VP10_COMP *cpi, - const struct buf_2d *ref, - BLOCK_SIZE bs); + const struct buf_2d *ref, + BLOCK_SIZE bs); #if CONFIG_VP9_HIGHBITDEPTH unsigned int vp10_high_get_sby_perpixel_variance(VP10_COMP *cpi, - const struct buf_2d *ref, - BLOCK_SIZE bs, int bd); + const struct buf_2d *ref, + BLOCK_SIZE bs, int bd); #endif void vp10_rd_pick_inter_mode_sb(struct VP10_COMP *cpi, - struct TileDataEnc *tile_data, - struct macroblock *x, - int mi_row, int mi_col, - struct RD_COST *rd_cost, + struct TileDataEnc *tile_data, + struct macroblock *x, int mi_row, int mi_col, + struct RD_COST *rd_cost, #if CONFIG_SUPERTX - int *returnrate_nocoef, + int *returnrate_nocoef, #endif // CONFIG_SUPERTX - BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, - int64_t best_rd_so_far); + BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, + int64_t best_rd_so_far); -void vp10_rd_pick_inter_mode_sb_seg_skip(struct VP10_COMP *cpi, - struct TileDataEnc *tile_data, - struct macroblock *x, - struct RD_COST *rd_cost, - BLOCK_SIZE bsize, - PICK_MODE_CONTEXT *ctx, - int64_t best_rd_so_far); +void vp10_rd_pick_inter_mode_sb_seg_skip( + struct VP10_COMP *cpi, struct TileDataEnc *tile_data, struct macroblock *x, + struct RD_COST *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, + int64_t best_rd_so_far); int vp10_internal_image_edge(struct VP10_COMP *cpi); int vp10_active_h_edge(struct VP10_COMP *cpi, int mi_row, int mi_step); @@ -64,9 +60,8 @@ int vp10_active_edge_sb(struct VP10_COMP *cpi, int mi_row, int mi_col); void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, struct TileDataEnc *tile_data, - struct macroblock *x, - int mi_row, int mi_col, - struct RD_COST *rd_cost, + struct macroblock *x, int mi_row, + int mi_col, struct RD_COST *rd_cost, #if CONFIG_SUPERTX int *returnrate_nocoef, #endif // CONFIG_SUPERTX @@ -77,12 +72,11 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, #if CONFIG_VAR_TX void vp10_tx_block_rd_b(const VP10_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, int blk_row, int blk_col, int plane, int block, - int plane_bsize, int coeff_ctx, - int *rate, int64_t *dist, int64_t *bsse, int *skip); + int plane_bsize, int coeff_ctx, int *rate, + int64_t *dist, int64_t *bsse, int *skip); #endif -void vp10_txfm_rd_in_plane_supertx(MACROBLOCK *x, - const VP10_COMP *cpi, +void vp10_txfm_rd_in_plane_supertx(MACROBLOCK *x, const VP10_COMP *cpi, int *rate, int64_t *distortion, int *skippable, int64_t *sse, int64_t ref_best_rd, int plane, diff --git a/vp10/encoder/resize.c b/vp10/encoder/resize.c index 353e513f3..e922e0aa2 100644 --- a/vp10/encoder/resize.c +++ b/vp10/encoder/resize.c @@ -22,198 +22,118 @@ #include "vp10/common/common.h" #include "vp10/encoder/resize.h" -#define FILTER_BITS 7 +#define FILTER_BITS 7 -#define INTERP_TAPS 8 -#define SUBPEL_BITS 5 -#define SUBPEL_MASK ((1 << SUBPEL_BITS) - 1) -#define INTERP_PRECISION_BITS 32 +#define INTERP_TAPS 8 +#define SUBPEL_BITS 5 +#define SUBPEL_MASK ((1 << SUBPEL_BITS) - 1) +#define INTERP_PRECISION_BITS 32 typedef int16_t interp_kernel[INTERP_TAPS]; // Filters for interpolation (0.5-band) - note this also filters integer pels. static const interp_kernel filteredinterp_filters500[(1 << SUBPEL_BITS)] = { - {-3, 0, 35, 64, 35, 0, -3, 0}, - {-3, -1, 34, 64, 36, 1, -3, 0}, - {-3, -1, 32, 64, 38, 1, -3, 0}, - {-2, -2, 31, 63, 39, 2, -3, 0}, - {-2, -2, 29, 63, 41, 2, -3, 0}, - {-2, -2, 28, 63, 42, 3, -4, 0}, - {-2, -3, 27, 63, 43, 4, -4, 0}, - {-2, -3, 25, 62, 45, 5, -4, 0}, - {-2, -3, 24, 62, 46, 5, -4, 0}, - {-2, -3, 23, 61, 47, 6, -4, 0}, - {-2, -3, 21, 60, 49, 7, -4, 0}, - {-1, -4, 20, 60, 50, 8, -4, -1}, - {-1, -4, 19, 59, 51, 9, -4, -1}, - {-1, -4, 17, 58, 52, 10, -4, 0}, - {-1, -4, 16, 57, 53, 12, -4, -1}, - {-1, -4, 15, 56, 54, 13, -4, -1}, - {-1, -4, 14, 55, 55, 14, -4, -1}, - {-1, -4, 13, 54, 56, 15, -4, -1}, - {-1, -4, 12, 53, 57, 16, -4, -1}, - {0, -4, 10, 52, 58, 17, -4, -1}, - {-1, -4, 9, 51, 59, 19, -4, -1}, - {-1, -4, 8, 50, 60, 20, -4, -1}, - {0, -4, 7, 49, 60, 21, -3, -2}, - {0, -4, 6, 47, 61, 23, -3, -2}, - {0, -4, 5, 46, 62, 24, -3, -2}, - {0, -4, 5, 45, 62, 25, -3, -2}, - {0, -4, 4, 43, 63, 27, -3, -2}, - {0, -4, 3, 42, 63, 28, -2, -2}, - {0, -3, 2, 41, 63, 29, -2, -2}, - {0, -3, 2, 39, 63, 31, -2, -2}, - {0, -3, 1, 38, 64, 32, -1, -3}, - {0, -3, 1, 36, 64, 34, -1, -3} + { -3, 0, 35, 64, 35, 0, -3, 0 }, { -3, -1, 34, 64, 36, 1, -3, 0 }, + { -3, -1, 32, 64, 38, 1, -3, 0 }, { -2, -2, 31, 63, 39, 2, -3, 0 }, + { -2, -2, 29, 63, 41, 2, -3, 0 }, { -2, -2, 28, 63, 42, 3, -4, 0 }, + { -2, -3, 27, 63, 43, 4, -4, 0 }, { -2, -3, 25, 62, 45, 5, -4, 0 }, + { -2, -3, 24, 62, 46, 5, -4, 0 }, { -2, -3, 23, 61, 47, 6, -4, 0 }, + { -2, -3, 21, 60, 49, 7, -4, 0 }, { -1, -4, 20, 60, 50, 8, -4, -1 }, + { -1, -4, 19, 59, 51, 9, -4, -1 }, { -1, -4, 17, 58, 52, 10, -4, 0 }, + { -1, -4, 16, 57, 53, 12, -4, -1 }, { -1, -4, 15, 56, 54, 13, -4, -1 }, + { -1, -4, 14, 55, 55, 14, -4, -1 }, { -1, -4, 13, 54, 56, 15, -4, -1 }, + { -1, -4, 12, 53, 57, 16, -4, -1 }, { 0, -4, 10, 52, 58, 17, -4, -1 }, + { -1, -4, 9, 51, 59, 19, -4, -1 }, { -1, -4, 8, 50, 60, 20, -4, -1 }, + { 0, -4, 7, 49, 60, 21, -3, -2 }, { 0, -4, 6, 47, 61, 23, -3, -2 }, + { 0, -4, 5, 46, 62, 24, -3, -2 }, { 0, -4, 5, 45, 62, 25, -3, -2 }, + { 0, -4, 4, 43, 63, 27, -3, -2 }, { 0, -4, 3, 42, 63, 28, -2, -2 }, + { 0, -3, 2, 41, 63, 29, -2, -2 }, { 0, -3, 2, 39, 63, 31, -2, -2 }, + { 0, -3, 1, 38, 64, 32, -1, -3 }, { 0, -3, 1, 36, 64, 34, -1, -3 } }; // Filters for interpolation (0.625-band) - note this also filters integer pels. static const interp_kernel filteredinterp_filters625[(1 << SUBPEL_BITS)] = { - {-1, -8, 33, 80, 33, -8, -1, 0}, - {-1, -8, 30, 80, 35, -8, -1, 1}, - {-1, -8, 28, 80, 37, -7, -2, 1}, - {0, -8, 26, 79, 39, -7, -2, 1}, - {0, -8, 24, 79, 41, -7, -2, 1}, - {0, -8, 22, 78, 43, -6, -2, 1}, - {0, -8, 20, 78, 45, -5, -3, 1}, - {0, -8, 18, 77, 48, -5, -3, 1}, - {0, -8, 16, 76, 50, -4, -3, 1}, - {0, -8, 15, 75, 52, -3, -4, 1}, - {0, -7, 13, 74, 54, -3, -4, 1}, - {0, -7, 11, 73, 56, -2, -4, 1}, - {0, -7, 10, 71, 58, -1, -4, 1}, - {1, -7, 8, 70, 60, 0, -5, 1}, - {1, -6, 6, 68, 62, 1, -5, 1}, - {1, -6, 5, 67, 63, 2, -5, 1}, - {1, -6, 4, 65, 65, 4, -6, 1}, - {1, -5, 2, 63, 67, 5, -6, 1}, - {1, -5, 1, 62, 68, 6, -6, 1}, - {1, -5, 0, 60, 70, 8, -7, 1}, - {1, -4, -1, 58, 71, 10, -7, 0}, - {1, -4, -2, 56, 73, 11, -7, 0}, - {1, -4, -3, 54, 74, 13, -7, 0}, - {1, -4, -3, 52, 75, 15, -8, 0}, - {1, -3, -4, 50, 76, 16, -8, 0}, - {1, -3, -5, 48, 77, 18, -8, 0}, - {1, -3, -5, 45, 78, 20, -8, 0}, - {1, -2, -6, 43, 78, 22, -8, 0}, - {1, -2, -7, 41, 79, 24, -8, 0}, - {1, -2, -7, 39, 79, 26, -8, 0}, - {1, -2, -7, 37, 80, 28, -8, -1}, - {1, -1, -8, 35, 80, 30, -8, -1}, + { -1, -8, 33, 80, 33, -8, -1, 0 }, { -1, -8, 30, 80, 35, -8, -1, 1 }, + { -1, -8, 28, 80, 37, -7, -2, 1 }, { 0, -8, 26, 79, 39, -7, -2, 1 }, + { 0, -8, 24, 79, 41, -7, -2, 1 }, { 0, -8, 22, 78, 43, -6, -2, 1 }, + { 0, -8, 20, 78, 45, -5, -3, 1 }, { 0, -8, 18, 77, 48, -5, -3, 1 }, + { 0, -8, 16, 76, 50, -4, -3, 1 }, { 0, -8, 15, 75, 52, -3, -4, 1 }, + { 0, -7, 13, 74, 54, -3, -4, 1 }, { 0, -7, 11, 73, 56, -2, -4, 1 }, + { 0, -7, 10, 71, 58, -1, -4, 1 }, { 1, -7, 8, 70, 60, 0, -5, 1 }, + { 1, -6, 6, 68, 62, 1, -5, 1 }, { 1, -6, 5, 67, 63, 2, -5, 1 }, + { 1, -6, 4, 65, 65, 4, -6, 1 }, { 1, -5, 2, 63, 67, 5, -6, 1 }, + { 1, -5, 1, 62, 68, 6, -6, 1 }, { 1, -5, 0, 60, 70, 8, -7, 1 }, + { 1, -4, -1, 58, 71, 10, -7, 0 }, { 1, -4, -2, 56, 73, 11, -7, 0 }, + { 1, -4, -3, 54, 74, 13, -7, 0 }, { 1, -4, -3, 52, 75, 15, -8, 0 }, + { 1, -3, -4, 50, 76, 16, -8, 0 }, { 1, -3, -5, 48, 77, 18, -8, 0 }, + { 1, -3, -5, 45, 78, 20, -8, 0 }, { 1, -2, -6, 43, 78, 22, -8, 0 }, + { 1, -2, -7, 41, 79, 24, -8, 0 }, { 1, -2, -7, 39, 79, 26, -8, 0 }, + { 1, -2, -7, 37, 80, 28, -8, -1 }, { 1, -1, -8, 35, 80, 30, -8, -1 }, }; // Filters for interpolation (0.75-band) - note this also filters integer pels. static const interp_kernel filteredinterp_filters750[(1 << SUBPEL_BITS)] = { - {2, -11, 25, 96, 25, -11, 2, 0}, - {2, -11, 22, 96, 28, -11, 2, 0}, - {2, -10, 19, 95, 31, -11, 2, 0}, - {2, -10, 17, 95, 34, -12, 2, 0}, - {2, -9, 14, 94, 37, -12, 2, 0}, - {2, -8, 12, 93, 40, -12, 1, 0}, - {2, -8, 9, 92, 43, -12, 1, 1}, - {2, -7, 7, 91, 46, -12, 1, 0}, - {2, -7, 5, 90, 49, -12, 1, 0}, - {2, -6, 3, 88, 52, -12, 0, 1}, - {2, -5, 1, 86, 55, -12, 0, 1}, - {2, -5, -1, 84, 58, -11, 0, 1}, - {2, -4, -2, 82, 61, -11, -1, 1}, - {2, -4, -4, 80, 64, -10, -1, 1}, - {1, -3, -5, 77, 67, -9, -1, 1}, - {1, -3, -6, 75, 70, -8, -2, 1}, - {1, -2, -7, 72, 72, -7, -2, 1}, - {1, -2, -8, 70, 75, -6, -3, 1}, - {1, -1, -9, 67, 77, -5, -3, 1}, - {1, -1, -10, 64, 80, -4, -4, 2}, - {1, -1, -11, 61, 82, -2, -4, 2}, - {1, 0, -11, 58, 84, -1, -5, 2}, - {1, 0, -12, 55, 86, 1, -5, 2}, - {1, 0, -12, 52, 88, 3, -6, 2}, - {0, 1, -12, 49, 90, 5, -7, 2}, - {0, 1, -12, 46, 91, 7, -7, 2}, - {1, 1, -12, 43, 92, 9, -8, 2}, - {0, 1, -12, 40, 93, 12, -8, 2}, - {0, 2, -12, 37, 94, 14, -9, 2}, - {0, 2, -12, 34, 95, 17, -10, 2}, - {0, 2, -11, 31, 95, 19, -10, 2}, - {0, 2, -11, 28, 96, 22, -11, 2} + { 2, -11, 25, 96, 25, -11, 2, 0 }, { 2, -11, 22, 96, 28, -11, 2, 0 }, + { 2, -10, 19, 95, 31, -11, 2, 0 }, { 2, -10, 17, 95, 34, -12, 2, 0 }, + { 2, -9, 14, 94, 37, -12, 2, 0 }, { 2, -8, 12, 93, 40, -12, 1, 0 }, + { 2, -8, 9, 92, 43, -12, 1, 1 }, { 2, -7, 7, 91, 46, -12, 1, 0 }, + { 2, -7, 5, 90, 49, -12, 1, 0 }, { 2, -6, 3, 88, 52, -12, 0, 1 }, + { 2, -5, 1, 86, 55, -12, 0, 1 }, { 2, -5, -1, 84, 58, -11, 0, 1 }, + { 2, -4, -2, 82, 61, -11, -1, 1 }, { 2, -4, -4, 80, 64, -10, -1, 1 }, + { 1, -3, -5, 77, 67, -9, -1, 1 }, { 1, -3, -6, 75, 70, -8, -2, 1 }, + { 1, -2, -7, 72, 72, -7, -2, 1 }, { 1, -2, -8, 70, 75, -6, -3, 1 }, + { 1, -1, -9, 67, 77, -5, -3, 1 }, { 1, -1, -10, 64, 80, -4, -4, 2 }, + { 1, -1, -11, 61, 82, -2, -4, 2 }, { 1, 0, -11, 58, 84, -1, -5, 2 }, + { 1, 0, -12, 55, 86, 1, -5, 2 }, { 1, 0, -12, 52, 88, 3, -6, 2 }, + { 0, 1, -12, 49, 90, 5, -7, 2 }, { 0, 1, -12, 46, 91, 7, -7, 2 }, + { 1, 1, -12, 43, 92, 9, -8, 2 }, { 0, 1, -12, 40, 93, 12, -8, 2 }, + { 0, 2, -12, 37, 94, 14, -9, 2 }, { 0, 2, -12, 34, 95, 17, -10, 2 }, + { 0, 2, -11, 31, 95, 19, -10, 2 }, { 0, 2, -11, 28, 96, 22, -11, 2 } }; // Filters for interpolation (0.875-band) - note this also filters integer pels. static const interp_kernel filteredinterp_filters875[(1 << SUBPEL_BITS)] = { - {3, -8, 13, 112, 13, -8, 3, 0}, - {3, -7, 10, 112, 17, -9, 3, -1}, - {2, -6, 7, 111, 21, -9, 3, -1}, - {2, -5, 4, 111, 24, -10, 3, -1}, - {2, -4, 1, 110, 28, -11, 3, -1}, - {1, -3, -1, 108, 32, -12, 4, -1}, - {1, -2, -3, 106, 36, -13, 4, -1}, - {1, -1, -6, 105, 40, -14, 4, -1}, - {1, -1, -7, 102, 44, -14, 4, -1}, - {1, 0, -9, 100, 48, -15, 4, -1}, - {1, 1, -11, 97, 53, -16, 4, -1}, - {0, 1, -12, 95, 57, -16, 4, -1}, - {0, 2, -13, 91, 61, -16, 4, -1}, - {0, 2, -14, 88, 65, -16, 4, -1}, - {0, 3, -15, 84, 69, -17, 4, 0}, - {0, 3, -16, 81, 73, -16, 3, 0}, - {0, 3, -16, 77, 77, -16, 3, 0}, - {0, 3, -16, 73, 81, -16, 3, 0}, - {0, 4, -17, 69, 84, -15, 3, 0}, - {-1, 4, -16, 65, 88, -14, 2, 0}, - {-1, 4, -16, 61, 91, -13, 2, 0}, - {-1, 4, -16, 57, 95, -12, 1, 0}, - {-1, 4, -16, 53, 97, -11, 1, 1}, - {-1, 4, -15, 48, 100, -9, 0, 1}, - {-1, 4, -14, 44, 102, -7, -1, 1}, - {-1, 4, -14, 40, 105, -6, -1, 1}, - {-1, 4, -13, 36, 106, -3, -2, 1}, - {-1, 4, -12, 32, 108, -1, -3, 1}, - {-1, 3, -11, 28, 110, 1, -4, 2}, - {-1, 3, -10, 24, 111, 4, -5, 2}, - {-1, 3, -9, 21, 111, 7, -6, 2}, - {-1, 3, -9, 17, 112, 10, -7, 3} + { 3, -8, 13, 112, 13, -8, 3, 0 }, { 3, -7, 10, 112, 17, -9, 3, -1 }, + { 2, -6, 7, 111, 21, -9, 3, -1 }, { 2, -5, 4, 111, 24, -10, 3, -1 }, + { 2, -4, 1, 110, 28, -11, 3, -1 }, { 1, -3, -1, 108, 32, -12, 4, -1 }, + { 1, -2, -3, 106, 36, -13, 4, -1 }, { 1, -1, -6, 105, 40, -14, 4, -1 }, + { 1, -1, -7, 102, 44, -14, 4, -1 }, { 1, 0, -9, 100, 48, -15, 4, -1 }, + { 1, 1, -11, 97, 53, -16, 4, -1 }, { 0, 1, -12, 95, 57, -16, 4, -1 }, + { 0, 2, -13, 91, 61, -16, 4, -1 }, { 0, 2, -14, 88, 65, -16, 4, -1 }, + { 0, 3, -15, 84, 69, -17, 4, 0 }, { 0, 3, -16, 81, 73, -16, 3, 0 }, + { 0, 3, -16, 77, 77, -16, 3, 0 }, { 0, 3, -16, 73, 81, -16, 3, 0 }, + { 0, 4, -17, 69, 84, -15, 3, 0 }, { -1, 4, -16, 65, 88, -14, 2, 0 }, + { -1, 4, -16, 61, 91, -13, 2, 0 }, { -1, 4, -16, 57, 95, -12, 1, 0 }, + { -1, 4, -16, 53, 97, -11, 1, 1 }, { -1, 4, -15, 48, 100, -9, 0, 1 }, + { -1, 4, -14, 44, 102, -7, -1, 1 }, { -1, 4, -14, 40, 105, -6, -1, 1 }, + { -1, 4, -13, 36, 106, -3, -2, 1 }, { -1, 4, -12, 32, 108, -1, -3, 1 }, + { -1, 3, -11, 28, 110, 1, -4, 2 }, { -1, 3, -10, 24, 111, 4, -5, 2 }, + { -1, 3, -9, 21, 111, 7, -6, 2 }, { -1, 3, -9, 17, 112, 10, -7, 3 } }; // Filters for interpolation (full-band) - no filtering for integer pixels static const interp_kernel filteredinterp_filters1000[(1 << SUBPEL_BITS)] = { - {0, 0, 0, 128, 0, 0, 0, 0}, - {0, 1, -3, 128, 3, -1, 0, 0}, - {-1, 2, -6, 127, 7, -2, 1, 0}, - {-1, 3, -9, 126, 12, -4, 1, 0}, - {-1, 4, -12, 125, 16, -5, 1, 0}, - {-1, 4, -14, 123, 20, -6, 2, 0}, - {-1, 5, -15, 120, 25, -8, 2, 0}, - {-1, 5, -17, 118, 30, -9, 3, -1}, - {-1, 6, -18, 114, 35, -10, 3, -1}, - {-1, 6, -19, 111, 41, -12, 3, -1}, - {-1, 6, -20, 107, 46, -13, 4, -1}, - {-1, 6, -21, 103, 52, -14, 4, -1}, - {-1, 6, -21, 99, 57, -16, 5, -1}, - {-1, 6, -21, 94, 63, -17, 5, -1}, - {-1, 6, -20, 89, 68, -18, 5, -1}, - {-1, 6, -20, 84, 73, -19, 6, -1}, - {-1, 6, -20, 79, 79, -20, 6, -1}, - {-1, 6, -19, 73, 84, -20, 6, -1}, - {-1, 5, -18, 68, 89, -20, 6, -1}, - {-1, 5, -17, 63, 94, -21, 6, -1}, - {-1, 5, -16, 57, 99, -21, 6, -1}, - {-1, 4, -14, 52, 103, -21, 6, -1}, - {-1, 4, -13, 46, 107, -20, 6, -1}, - {-1, 3, -12, 41, 111, -19, 6, -1}, - {-1, 3, -10, 35, 114, -18, 6, -1}, - {-1, 3, -9, 30, 118, -17, 5, -1}, - {0, 2, -8, 25, 120, -15, 5, -1}, - {0, 2, -6, 20, 123, -14, 4, -1}, - {0, 1, -5, 16, 125, -12, 4, -1}, - {0, 1, -4, 12, 126, -9, 3, -1}, - {0, 1, -2, 7, 127, -6, 2, -1}, - {0, 0, -1, 3, 128, -3, 1, 0} + { 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 1, -3, 128, 3, -1, 0, 0 }, + { -1, 2, -6, 127, 7, -2, 1, 0 }, { -1, 3, -9, 126, 12, -4, 1, 0 }, + { -1, 4, -12, 125, 16, -5, 1, 0 }, { -1, 4, -14, 123, 20, -6, 2, 0 }, + { -1, 5, -15, 120, 25, -8, 2, 0 }, { -1, 5, -17, 118, 30, -9, 3, -1 }, + { -1, 6, -18, 114, 35, -10, 3, -1 }, { -1, 6, -19, 111, 41, -12, 3, -1 }, + { -1, 6, -20, 107, 46, -13, 4, -1 }, { -1, 6, -21, 103, 52, -14, 4, -1 }, + { -1, 6, -21, 99, 57, -16, 5, -1 }, { -1, 6, -21, 94, 63, -17, 5, -1 }, + { -1, 6, -20, 89, 68, -18, 5, -1 }, { -1, 6, -20, 84, 73, -19, 6, -1 }, + { -1, 6, -20, 79, 79, -20, 6, -1 }, { -1, 6, -19, 73, 84, -20, 6, -1 }, + { -1, 5, -18, 68, 89, -20, 6, -1 }, { -1, 5, -17, 63, 94, -21, 6, -1 }, + { -1, 5, -16, 57, 99, -21, 6, -1 }, { -1, 4, -14, 52, 103, -21, 6, -1 }, + { -1, 4, -13, 46, 107, -20, 6, -1 }, { -1, 3, -12, 41, 111, -19, 6, -1 }, + { -1, 3, -10, 35, 114, -18, 6, -1 }, { -1, 3, -9, 30, 118, -17, 5, -1 }, + { 0, 2, -8, 25, 120, -15, 5, -1 }, { 0, 2, -6, 20, 123, -14, 4, -1 }, + { 0, 1, -5, 16, 125, -12, 4, -1 }, { 0, 1, -4, 12, 126, -9, 3, -1 }, + { 0, 1, -2, 7, 127, -6, 2, -1 }, { 0, 0, -1, 3, 128, -3, 1, 0 } }; // Filters for factor of 2 downsampling. -static const int16_t vp10_down2_symeven_half_filter[] = {56, 12, -3, -1}; -static const int16_t vp10_down2_symodd_half_filter[] = {64, 35, 0, -3}; +static const int16_t vp10_down2_symeven_half_filter[] = { 56, 12, -3, -1 }; +static const int16_t vp10_down2_symodd_half_filter[] = { 64, 35, 0, -3 }; static const interp_kernel *choose_interp_filter(int inlength, int outlength) { int outlength16 = outlength * 16; @@ -231,11 +151,14 @@ static const interp_kernel *choose_interp_filter(int inlength, int outlength) { static void interpolate(const uint8_t *const input, int inlength, uint8_t *output, int outlength) { - const int64_t delta = (((uint64_t)inlength << 32) + outlength / 2) / - outlength; - const int64_t offset = inlength > outlength ? - (((int64_t)(inlength - outlength) << 31) + outlength / 2) / outlength : - -(((int64_t)(outlength - inlength) << 31) + outlength / 2) / outlength; + const int64_t delta = + (((uint64_t)inlength << 32) + outlength / 2) / outlength; + const int64_t offset = + inlength > outlength + ? (((int64_t)(inlength - outlength) << 31) + outlength / 2) / + outlength + : -(((int64_t)(outlength - inlength) << 31) + outlength / 2) / + outlength; uint8_t *optr = output; int x, x1, x2, sum, k, int_pel, sub_pel; int64_t y; @@ -252,8 +175,8 @@ static void interpolate(const uint8_t *const input, int inlength, x1 = x; x = outlength - 1; y = delta * x + offset; - while ((y >> INTERP_PRECISION_BITS) + - (int64_t)(INTERP_TAPS / 2) >= inlength) { + while ((y >> INTERP_PRECISION_BITS) + (int64_t)(INTERP_TAPS / 2) >= + inlength) { x--; y -= delta; } @@ -267,8 +190,8 @@ static void interpolate(const uint8_t *const input, int inlength, sum = 0; for (k = 0; k < INTERP_TAPS; ++k) { const int pk = int_pel - INTERP_TAPS / 2 + 1 + k; - sum += filter[k] * input[(pk < 0 ? 0 : - (pk >= inlength ? inlength - 1 : pk))]; + sum += filter[k] * + input[(pk < 0 ? 0 : (pk >= inlength ? inlength - 1 : pk))]; } *optr++ = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS)); } @@ -281,9 +204,9 @@ static void interpolate(const uint8_t *const input, int inlength, filter = interp_filters[sub_pel]; sum = 0; for (k = 0; k < INTERP_TAPS; ++k) - sum += filter[k] * input[(int_pel - INTERP_TAPS / 2 + 1 + k < 0 ? - 0 : - int_pel - INTERP_TAPS / 2 + 1 + k)]; + sum += filter[k] * input[(int_pel - INTERP_TAPS / 2 + 1 + k < 0 + ? 0 + : int_pel - INTERP_TAPS / 2 + 1 + k)]; *optr++ = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS)); } // Middle part. @@ -305,9 +228,9 @@ static void interpolate(const uint8_t *const input, int inlength, filter = interp_filters[sub_pel]; sum = 0; for (k = 0; k < INTERP_TAPS; ++k) - sum += filter[k] * input[(int_pel - INTERP_TAPS / 2 + 1 + k >= - inlength ? inlength - 1 : - int_pel - INTERP_TAPS / 2 + 1 + k)]; + sum += filter[k] * input[(int_pel - INTERP_TAPS / 2 + 1 + k >= inlength + ? inlength - 1 + : int_pel - INTERP_TAPS / 2 + 1 + k)]; *optr++ = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS)); } } @@ -331,7 +254,7 @@ static void down2_symeven(const uint8_t *const input, int length, for (j = 0; j < filter_len_half; ++j) { sum += (input[(i - j < 0 ? 0 : i - j)] + input[(i + 1 + j >= length ? length - 1 : i + 1 + j)]) * - filter[j]; + filter[j]; } sum >>= FILTER_BITS; *optr++ = clip_pixel(sum); @@ -361,7 +284,7 @@ static void down2_symeven(const uint8_t *const input, int length, for (j = 0; j < filter_len_half; ++j) { sum += (input[i - j] + input[(i + 1 + j >= length ? length - 1 : i + 1 + j)]) * - filter[j]; + filter[j]; } sum >>= FILTER_BITS; *optr++ = clip_pixel(sum); @@ -387,7 +310,7 @@ static void down2_symodd(const uint8_t *const input, int length, for (j = 1; j < filter_len_half; ++j) { sum += (input[(i - j < 0 ? 0 : i - j)] + input[(i + j >= length ? length - 1 : i + j)]) * - filter[j]; + filter[j]; } sum >>= FILTER_BITS; *optr++ = clip_pixel(sum); @@ -416,7 +339,7 @@ static void down2_symodd(const uint8_t *const input, int length, int sum = (1 << (FILTER_BITS - 1)) + input[i] * filter[0]; for (j = 1; j < filter_len_half; ++j) { sum += (input[i - j] + input[(i + j >= length ? length - 1 : i + j)]) * - filter[j]; + filter[j]; } sum >>= FILTER_BITS; *optr++ = clip_pixel(sum); @@ -426,8 +349,7 @@ static void down2_symodd(const uint8_t *const input, int length, static int get_down2_length(int length, int steps) { int s; - for (s = 0; s < steps; ++s) - length = (length + 1) >> 1; + for (s = 0; s < steps; ++s) length = (length + 1) >> 1; return length; } @@ -441,11 +363,8 @@ static int get_down2_steps(int in_length, int out_length) { return steps; } -static void resize_multistep(const uint8_t *const input, - int length, - uint8_t *output, - int olength, - uint8_t *otmp) { +static void resize_multistep(const uint8_t *const input, int length, + uint8_t *output, int olength, uint8_t *otmp) { int steps; if (length == olength) { memcpy(output, input, sizeof(output[0]) * length); @@ -500,37 +419,31 @@ static void fill_arr_to_col(uint8_t *img, int stride, int len, uint8_t *arr) { } } -void vp10_resize_plane(const uint8_t *const input, - int height, - int width, - int in_stride, - uint8_t *output, - int height2, - int width2, - int out_stride) { +void vp10_resize_plane(const uint8_t *const input, int height, int width, + int in_stride, uint8_t *output, int height2, int width2, + int out_stride) { int i; uint8_t *intbuf = (uint8_t *)malloc(sizeof(uint8_t) * width2 * height); - uint8_t *tmpbuf = (uint8_t *)malloc(sizeof(uint8_t) * - (width < height ? height : width)); + uint8_t *tmpbuf = + (uint8_t *)malloc(sizeof(uint8_t) * (width < height ? height : width)); uint8_t *arrbuf = (uint8_t *)malloc(sizeof(uint8_t) * height); uint8_t *arrbuf2 = (uint8_t *)malloc(sizeof(uint8_t) * height2); - if (intbuf == NULL || tmpbuf == NULL || - arrbuf == NULL || arrbuf2 == NULL) + if (intbuf == NULL || tmpbuf == NULL || arrbuf == NULL || arrbuf2 == NULL) goto Error; assert(width > 0); assert(height > 0); assert(width2 > 0); assert(height2 > 0); for (i = 0; i < height; ++i) - resize_multistep(input + in_stride * i, width, - intbuf + width2 * i, width2, tmpbuf); + resize_multistep(input + in_stride * i, width, intbuf + width2 * i, width2, + tmpbuf); for (i = 0; i < width2; ++i) { fill_col_to_arr(intbuf + i, width2, height, arrbuf); resize_multistep(arrbuf, height, arrbuf2, height2, tmpbuf); fill_arr_to_col(output + i, out_stride, height2, arrbuf2); } - Error: +Error: free(intbuf); free(tmpbuf); free(arrbuf); @@ -542,9 +455,12 @@ static void highbd_interpolate(const uint16_t *const input, int inlength, uint16_t *output, int outlength, int bd) { const int64_t delta = (((uint64_t)inlength << 32) + outlength / 2) / outlength; - const int64_t offset = inlength > outlength ? - (((int64_t)(inlength - outlength) << 31) + outlength / 2) / outlength : - -(((int64_t)(outlength - inlength) << 31) + outlength / 2) / outlength; + const int64_t offset = + inlength > outlength + ? (((int64_t)(inlength - outlength) << 31) + outlength / 2) / + outlength + : -(((int64_t)(outlength - inlength) << 31) + outlength / 2) / + outlength; uint16_t *optr = output; int x, x1, x2, sum, k, int_pel, sub_pel; int64_t y; @@ -561,8 +477,8 @@ static void highbd_interpolate(const uint16_t *const input, int inlength, x1 = x; x = outlength - 1; y = delta * x + offset; - while ((y >> INTERP_PRECISION_BITS) + - (int64_t)(INTERP_TAPS / 2) >= inlength) { + while ((y >> INTERP_PRECISION_BITS) + (int64_t)(INTERP_TAPS / 2) >= + inlength) { x--; y -= delta; } @@ -577,7 +493,7 @@ static void highbd_interpolate(const uint16_t *const input, int inlength, for (k = 0; k < INTERP_TAPS; ++k) { const int pk = int_pel - INTERP_TAPS / 2 + 1 + k; sum += filter[k] * - input[(pk < 0 ? 0 : (pk >= inlength ? inlength - 1 : pk))]; + input[(pk < 0 ? 0 : (pk >= inlength ? inlength - 1 : pk))]; } *optr++ = clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd); } @@ -590,9 +506,9 @@ static void highbd_interpolate(const uint16_t *const input, int inlength, filter = interp_filters[sub_pel]; sum = 0; for (k = 0; k < INTERP_TAPS; ++k) - sum += filter[k] * - input[(int_pel - INTERP_TAPS / 2 + 1 + k < 0 ? - 0 : int_pel - INTERP_TAPS / 2 + 1 + k)]; + sum += filter[k] * input[(int_pel - INTERP_TAPS / 2 + 1 + k < 0 + ? 0 + : int_pel - INTERP_TAPS / 2 + 1 + k)]; *optr++ = clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd); } // Middle part. @@ -614,9 +530,9 @@ static void highbd_interpolate(const uint16_t *const input, int inlength, filter = interp_filters[sub_pel]; sum = 0; for (k = 0; k < INTERP_TAPS; ++k) - sum += filter[k] * input[(int_pel - INTERP_TAPS / 2 + 1 + k >= - inlength ? inlength - 1 : - int_pel - INTERP_TAPS / 2 + 1 + k)]; + sum += filter[k] * input[(int_pel - INTERP_TAPS / 2 + 1 + k >= inlength + ? inlength - 1 + : int_pel - INTERP_TAPS / 2 + 1 + k)]; *optr++ = clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd); } } @@ -640,7 +556,7 @@ static void highbd_down2_symeven(const uint16_t *const input, int length, for (j = 0; j < filter_len_half; ++j) { sum += (input[(i - j < 0 ? 0 : i - j)] + input[(i + 1 + j >= length ? length - 1 : i + 1 + j)]) * - filter[j]; + filter[j]; } sum >>= FILTER_BITS; *optr++ = clip_pixel_highbd(sum, bd); @@ -670,7 +586,7 @@ static void highbd_down2_symeven(const uint16_t *const input, int length, for (j = 0; j < filter_len_half; ++j) { sum += (input[i - j] + input[(i + 1 + j >= length ? length - 1 : i + 1 + j)]) * - filter[j]; + filter[j]; } sum >>= FILTER_BITS; *optr++ = clip_pixel_highbd(sum, bd); @@ -679,7 +595,7 @@ static void highbd_down2_symeven(const uint16_t *const input, int length, } static void highbd_down2_symodd(const uint16_t *const input, int length, - uint16_t *output, int bd) { + uint16_t *output, int bd) { // Actual filter len = 2 * filter_len_half - 1. static const int16_t *filter = vp10_down2_symodd_half_filter; const int filter_len_half = sizeof(vp10_down2_symodd_half_filter) / 2; @@ -696,7 +612,7 @@ static void highbd_down2_symodd(const uint16_t *const input, int length, for (j = 1; j < filter_len_half; ++j) { sum += (input[(i - j < 0 ? 0 : i - j)] + input[(i + j >= length ? length - 1 : i + j)]) * - filter[j]; + filter[j]; } sum >>= FILTER_BITS; *optr++ = clip_pixel_highbd(sum, bd); @@ -725,7 +641,7 @@ static void highbd_down2_symodd(const uint16_t *const input, int length, int sum = (1 << (FILTER_BITS - 1)) + input[i] * filter[0]; for (j = 1; j < filter_len_half; ++j) { sum += (input[i - j] + input[(i + j >= length ? length - 1 : i + j)]) * - filter[j]; + filter[j]; } sum >>= FILTER_BITS; *optr++ = clip_pixel_highbd(sum, bd); @@ -733,12 +649,9 @@ static void highbd_down2_symodd(const uint16_t *const input, int length, } } -static void highbd_resize_multistep(const uint16_t *const input, - int length, - uint16_t *output, - int olength, - uint16_t *otmp, - int bd) { +static void highbd_resize_multistep(const uint16_t *const input, int length, + uint16_t *output, int olength, + uint16_t *otmp, int bd) { int steps; if (length == olength) { memcpy(output, input, sizeof(output[0]) * length); @@ -795,36 +708,29 @@ static void highbd_fill_arr_to_col(uint16_t *img, int stride, int len, } } -void vp10_highbd_resize_plane(const uint8_t *const input, - int height, - int width, - int in_stride, - uint8_t *output, - int height2, - int width2, - int out_stride, - int bd) { +void vp10_highbd_resize_plane(const uint8_t *const input, int height, int width, + int in_stride, uint8_t *output, int height2, + int width2, int out_stride, int bd) { int i; uint16_t *intbuf = (uint16_t *)malloc(sizeof(uint16_t) * width2 * height); - uint16_t *tmpbuf = (uint16_t *)malloc(sizeof(uint16_t) * - (width < height ? height : width)); + uint16_t *tmpbuf = + (uint16_t *)malloc(sizeof(uint16_t) * (width < height ? height : width)); uint16_t *arrbuf = (uint16_t *)malloc(sizeof(uint16_t) * height); uint16_t *arrbuf2 = (uint16_t *)malloc(sizeof(uint16_t) * height2); - if (intbuf == NULL || tmpbuf == NULL || - arrbuf == NULL || arrbuf2 == NULL) goto Error; + if (intbuf == NULL || tmpbuf == NULL || arrbuf == NULL || arrbuf2 == NULL) + goto Error; for (i = 0; i < height; ++i) { highbd_resize_multistep(CONVERT_TO_SHORTPTR(input + in_stride * i), width, intbuf + width2 * i, width2, tmpbuf, bd); } for (i = 0; i < width2; ++i) { highbd_fill_col_to_arr(intbuf + i, width2, height, arrbuf); - highbd_resize_multistep(arrbuf, height, arrbuf2, height2, tmpbuf, - bd); + highbd_resize_multistep(arrbuf, height, arrbuf2, height2, tmpbuf, bd); highbd_fill_arr_to_col(CONVERT_TO_SHORTPTR(output + i), out_stride, height2, arrbuf2); } - Error: +Error: free(intbuf); free(tmpbuf); free(arrbuf); @@ -832,96 +738,82 @@ void vp10_highbd_resize_plane(const uint8_t *const input, } #endif // CONFIG_VP9_HIGHBITDEPTH -void vp10_resize_frame420(const uint8_t *const y, - int y_stride, - const uint8_t *const u, const uint8_t *const v, - int uv_stride, - int height, int width, - uint8_t *oy, int oy_stride, - uint8_t *ou, uint8_t *ov, int ouv_stride, - int oheight, int owidth) { - vp10_resize_plane(y, height, width, y_stride, - oy, oheight, owidth, oy_stride); - vp10_resize_plane(u, height / 2, width / 2, uv_stride, - ou, oheight / 2, owidth / 2, ouv_stride); - vp10_resize_plane(v, height / 2, width / 2, uv_stride, - ov, oheight / 2, owidth / 2, ouv_stride); +void vp10_resize_frame420(const uint8_t *const y, int y_stride, + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, uint8_t *oy, + int oy_stride, uint8_t *ou, uint8_t *ov, + int ouv_stride, int oheight, int owidth) { + vp10_resize_plane(y, height, width, y_stride, oy, oheight, owidth, oy_stride); + vp10_resize_plane(u, height / 2, width / 2, uv_stride, ou, oheight / 2, + owidth / 2, ouv_stride); + vp10_resize_plane(v, height / 2, width / 2, uv_stride, ov, oheight / 2, + owidth / 2, ouv_stride); } void vp10_resize_frame422(const uint8_t *const y, int y_stride, - const uint8_t *const u, const uint8_t *const v, - int uv_stride, - int height, int width, - uint8_t *oy, int oy_stride, - uint8_t *ou, uint8_t *ov, int ouv_stride, - int oheight, int owidth) { - vp10_resize_plane(y, height, width, y_stride, - oy, oheight, owidth, oy_stride); - vp10_resize_plane(u, height, width / 2, uv_stride, - ou, oheight, owidth / 2, ouv_stride); - vp10_resize_plane(v, height, width / 2, uv_stride, - ov, oheight, owidth / 2, ouv_stride); + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, uint8_t *oy, + int oy_stride, uint8_t *ou, uint8_t *ov, + int ouv_stride, int oheight, int owidth) { + vp10_resize_plane(y, height, width, y_stride, oy, oheight, owidth, oy_stride); + vp10_resize_plane(u, height, width / 2, uv_stride, ou, oheight, owidth / 2, + ouv_stride); + vp10_resize_plane(v, height, width / 2, uv_stride, ov, oheight, owidth / 2, + ouv_stride); } void vp10_resize_frame444(const uint8_t *const y, int y_stride, - const uint8_t *const u, const uint8_t *const v, - int uv_stride, - int height, int width, - uint8_t *oy, int oy_stride, - uint8_t *ou, uint8_t *ov, int ouv_stride, - int oheight, int owidth) { - vp10_resize_plane(y, height, width, y_stride, - oy, oheight, owidth, oy_stride); - vp10_resize_plane(u, height, width, uv_stride, - ou, oheight, owidth, ouv_stride); - vp10_resize_plane(v, height, width, uv_stride, - ov, oheight, owidth, ouv_stride); + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, uint8_t *oy, + int oy_stride, uint8_t *ou, uint8_t *ov, + int ouv_stride, int oheight, int owidth) { + vp10_resize_plane(y, height, width, y_stride, oy, oheight, owidth, oy_stride); + vp10_resize_plane(u, height, width, uv_stride, ou, oheight, owidth, + ouv_stride); + vp10_resize_plane(v, height, width, uv_stride, ov, oheight, owidth, + ouv_stride); } #if CONFIG_VP9_HIGHBITDEPTH -void vp10_highbd_resize_frame420(const uint8_t *const y, - int y_stride, - const uint8_t *const u, const uint8_t *const v, - int uv_stride, - int height, int width, - uint8_t *oy, int oy_stride, - uint8_t *ou, uint8_t *ov, int ouv_stride, - int oheight, int owidth, int bd) { - vp10_highbd_resize_plane(y, height, width, y_stride, - oy, oheight, owidth, oy_stride, bd); - vp10_highbd_resize_plane(u, height / 2, width / 2, uv_stride, - ou, oheight / 2, owidth / 2, ouv_stride, bd); - vp10_highbd_resize_plane(v, height / 2, width / 2, uv_stride, - ov, oheight / 2, owidth / 2, ouv_stride, bd); +void vp10_highbd_resize_frame420(const uint8_t *const y, int y_stride, + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, + uint8_t *oy, int oy_stride, uint8_t *ou, + uint8_t *ov, int ouv_stride, int oheight, + int owidth, int bd) { + vp10_highbd_resize_plane(y, height, width, y_stride, oy, oheight, owidth, + oy_stride, bd); + vp10_highbd_resize_plane(u, height / 2, width / 2, uv_stride, ou, oheight / 2, + owidth / 2, ouv_stride, bd); + vp10_highbd_resize_plane(v, height / 2, width / 2, uv_stride, ov, oheight / 2, + owidth / 2, ouv_stride, bd); } void vp10_highbd_resize_frame422(const uint8_t *const y, int y_stride, - const uint8_t *const u, const uint8_t *const v, - int uv_stride, - int height, int width, - uint8_t *oy, int oy_stride, - uint8_t *ou, uint8_t *ov, int ouv_stride, - int oheight, int owidth, int bd) { - vp10_highbd_resize_plane(y, height, width, y_stride, - oy, oheight, owidth, oy_stride, bd); - vp10_highbd_resize_plane(u, height, width / 2, uv_stride, - ou, oheight, owidth / 2, ouv_stride, bd); - vp10_highbd_resize_plane(v, height, width / 2, uv_stride, - ov, oheight, owidth / 2, ouv_stride, bd); + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, + uint8_t *oy, int oy_stride, uint8_t *ou, + uint8_t *ov, int ouv_stride, int oheight, + int owidth, int bd) { + vp10_highbd_resize_plane(y, height, width, y_stride, oy, oheight, owidth, + oy_stride, bd); + vp10_highbd_resize_plane(u, height, width / 2, uv_stride, ou, oheight, + owidth / 2, ouv_stride, bd); + vp10_highbd_resize_plane(v, height, width / 2, uv_stride, ov, oheight, + owidth / 2, ouv_stride, bd); } void vp10_highbd_resize_frame444(const uint8_t *const y, int y_stride, - const uint8_t *const u, const uint8_t *const v, - int uv_stride, - int height, int width, - uint8_t *oy, int oy_stride, - uint8_t *ou, uint8_t *ov, int ouv_stride, - int oheight, int owidth, int bd) { - vp10_highbd_resize_plane(y, height, width, y_stride, - oy, oheight, owidth, oy_stride, bd); - vp10_highbd_resize_plane(u, height, width, uv_stride, - ou, oheight, owidth, ouv_stride, bd); - vp10_highbd_resize_plane(v, height, width, uv_stride, - ov, oheight, owidth, ouv_stride, bd); + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, + uint8_t *oy, int oy_stride, uint8_t *ou, + uint8_t *ov, int ouv_stride, int oheight, + int owidth, int bd) { + vp10_highbd_resize_plane(y, height, width, y_stride, oy, oheight, owidth, + oy_stride, bd); + vp10_highbd_resize_plane(u, height, width, uv_stride, ou, oheight, owidth, + ouv_stride, bd); + vp10_highbd_resize_plane(v, height, width, uv_stride, ov, oheight, owidth, + ouv_stride, bd); } #endif // CONFIG_VP9_HIGHBITDEPTH diff --git a/vp10/encoder/resize.h b/vp10/encoder/resize.h index bf6377097..cb3ee01a8 100644 --- a/vp10/encoder/resize.h +++ b/vp10/encoder/resize.h @@ -18,116 +18,51 @@ extern "C" { #endif -void vp10_resize_plane(const uint8_t *const input, - int height, - int width, - int in_stride, - uint8_t *output, - int height2, - int width2, - int out_stride); -void vp10_resize_frame420(const uint8_t *const y, - int y_stride, - const uint8_t *const u, - const uint8_t *const v, - int uv_stride, - int height, - int width, - uint8_t *oy, - int oy_stride, - uint8_t *ou, - uint8_t *ov, - int ouv_stride, - int oheight, - int owidth); -void vp10_resize_frame422(const uint8_t *const y, - int y_stride, - const uint8_t *const u, - const uint8_t *const v, - int uv_stride, - int height, - int width, - uint8_t *oy, - int oy_stride, - uint8_t *ou, - uint8_t *ov, - int ouv_stride, - int oheight, - int owidth); -void vp10_resize_frame444(const uint8_t *const y, - int y_stride, - const uint8_t *const u, - const uint8_t *const v, - int uv_stride, - int height, - int width, - uint8_t *oy, - int oy_stride, - uint8_t *ou, - uint8_t *ov, - int ouv_stride, - int oheight, - int owidth); +void vp10_resize_plane(const uint8_t *const input, int height, int width, + int in_stride, uint8_t *output, int height2, int width2, + int out_stride); +void vp10_resize_frame420(const uint8_t *const y, int y_stride, + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, uint8_t *oy, + int oy_stride, uint8_t *ou, uint8_t *ov, + int ouv_stride, int oheight, int owidth); +void vp10_resize_frame422(const uint8_t *const y, int y_stride, + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, uint8_t *oy, + int oy_stride, uint8_t *ou, uint8_t *ov, + int ouv_stride, int oheight, int owidth); +void vp10_resize_frame444(const uint8_t *const y, int y_stride, + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, uint8_t *oy, + int oy_stride, uint8_t *ou, uint8_t *ov, + int ouv_stride, int oheight, int owidth); #if CONFIG_VP9_HIGHBITDEPTH -void vp10_highbd_resize_plane(const uint8_t *const input, - int height, - int width, - int in_stride, - uint8_t *output, - int height2, - int width2, - int out_stride, - int bd); -void vp10_highbd_resize_frame420(const uint8_t *const y, - int y_stride, - const uint8_t *const u, - const uint8_t *const v, - int uv_stride, - int height, - int width, - uint8_t *oy, - int oy_stride, - uint8_t *ou, - uint8_t *ov, - int ouv_stride, - int oheight, - int owidth, - int bd); -void vp10_highbd_resize_frame422(const uint8_t *const y, - int y_stride, - const uint8_t *const u, - const uint8_t *const v, - int uv_stride, - int height, - int width, - uint8_t *oy, - int oy_stride, - uint8_t *ou, - uint8_t *ov, - int ouv_stride, - int oheight, - int owidth, - int bd); -void vp10_highbd_resize_frame444(const uint8_t *const y, - int y_stride, - const uint8_t *const u, - const uint8_t *const v, - int uv_stride, - int height, - int width, - uint8_t *oy, - int oy_stride, - uint8_t *ou, - uint8_t *ov, - int ouv_stride, - int oheight, - int owidth, - int bd); -#endif // CONFIG_VP9_HIGHBITDEPTH +void vp10_highbd_resize_plane(const uint8_t *const input, int height, int width, + int in_stride, uint8_t *output, int height2, + int width2, int out_stride, int bd); +void vp10_highbd_resize_frame420(const uint8_t *const y, int y_stride, + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, + uint8_t *oy, int oy_stride, uint8_t *ou, + uint8_t *ov, int ouv_stride, int oheight, + int owidth, int bd); +void vp10_highbd_resize_frame422(const uint8_t *const y, int y_stride, + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, + uint8_t *oy, int oy_stride, uint8_t *ou, + uint8_t *ov, int ouv_stride, int oheight, + int owidth, int bd); +void vp10_highbd_resize_frame444(const uint8_t *const y, int y_stride, + const uint8_t *const u, const uint8_t *const v, + int uv_stride, int height, int width, + uint8_t *oy, int oy_stride, uint8_t *ou, + uint8_t *ov, int ouv_stride, int oheight, + int owidth, int bd); +#endif // CONFIG_VP9_HIGHBITDEPTH #ifdef __cplusplus } // extern "C" #endif -#endif // VP10_ENCODER_RESIZE_H_ +#endif // VP10_ENCODER_RESIZE_H_ diff --git a/vp10/encoder/segmentation.c b/vp10/encoder/segmentation.c index bb6e4c4a3..7f889f5a6 100644 --- a/vp10/encoder/segmentation.c +++ b/vp10/encoder/segmentation.c @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include #include "vpx_mem/vpx_mem.h" @@ -32,31 +31,31 @@ void vp10_disable_segmentation(struct segmentation *seg) { seg->update_data = 0; } -void vp10_set_segment_data(struct segmentation *seg, - signed char *feature_data, - unsigned char abs_delta) { +void vp10_set_segment_data(struct segmentation *seg, signed char *feature_data, + unsigned char abs_delta) { seg->abs_delta = abs_delta; memcpy(seg->feature_data, feature_data, sizeof(seg->feature_data)); } void vp10_disable_segfeature(struct segmentation *seg, int segment_id, - SEG_LVL_FEATURES feature_id) { + SEG_LVL_FEATURES feature_id) { seg->feature_mask[segment_id] &= ~(1 << feature_id); } void vp10_clear_segdata(struct segmentation *seg, int segment_id, - SEG_LVL_FEATURES feature_id) { + SEG_LVL_FEATURES feature_id) { seg->feature_data[segment_id][feature_id] = 0; } // Based on set of segment counts calculate a probability tree static void calc_segtree_probs(unsigned *segcounts, - vpx_prob *segment_tree_probs, const vpx_prob *cur_tree_probs) { + vpx_prob *segment_tree_probs, + const vpx_prob *cur_tree_probs) { // Work out probabilities of each segment - const unsigned cc[4] = { - segcounts[0] + segcounts[1], segcounts[2] + segcounts[3], - segcounts[4] + segcounts[5], segcounts[6] + segcounts[7] - }; + const unsigned cc[4] = { segcounts[0] + segcounts[1], + segcounts[2] + segcounts[3], + segcounts[4] + segcounts[5], + segcounts[6] + segcounts[7] }; const unsigned ccc[2] = { cc[0] + cc[1], cc[2] + cc[3] }; int i; @@ -69,10 +68,10 @@ static void calc_segtree_probs(unsigned *segcounts, segment_tree_probs[6] = get_binary_prob(segcounts[6], segcounts[7]); for (i = 0; i < 7; i++) { - const unsigned *ct = i == 0 ? ccc : i < 3 ? cc + (i & 2) - : segcounts + (i - 3) * 2; - vp10_prob_diff_update_savings_search(ct, - cur_tree_probs[i], &segment_tree_probs[i], DIFF_UPDATE_PROB); + const unsigned *ct = + i == 0 ? ccc : i < 3 ? cc + (i & 2) : segcounts + (i - 3) * 2; + vp10_prob_diff_update_savings_search( + ct, cur_tree_probs[i], &segment_tree_probs[i], DIFF_UPDATE_PROB); } } @@ -86,13 +85,11 @@ static int cost_segmap(unsigned *segcounts, vpx_prob *probs) { const int c4567 = c45 + c67; // Cost the top node of the tree - int cost = c0123 * vp10_cost_zero(probs[0]) + - c4567 * vp10_cost_one(probs[0]); + int cost = c0123 * vp10_cost_zero(probs[0]) + c4567 * vp10_cost_one(probs[0]); // Cost subsequent levels if (c0123 > 0) { - cost += c01 * vp10_cost_zero(probs[1]) + - c23 * vp10_cost_one(probs[1]); + cost += c01 * vp10_cost_zero(probs[1]) + c23 * vp10_cost_one(probs[1]); if (c01 > 0) cost += segcounts[0] * vp10_cost_zero(probs[3]) + @@ -103,8 +100,7 @@ static int cost_segmap(unsigned *segcounts, vpx_prob *probs) { } if (c4567 > 0) { - cost += c45 * vp10_cost_zero(probs[2]) + - c67 * vp10_cost_one(probs[2]); + cost += c45 * vp10_cost_zero(probs[2]) + c67 * vp10_cost_one(probs[2]); if (c45 > 0) cost += segcounts[4] * vp10_cost_zero(probs[5]) + @@ -121,12 +117,11 @@ static void count_segs(const VP10_COMMON *cm, MACROBLOCKD *xd, const TileInfo *tile, MODE_INFO **mi, unsigned *no_pred_segcounts, unsigned (*temporal_predictor_count)[2], - unsigned *t_unpred_seg_counts, - int bw, int bh, int mi_row, int mi_col) { + unsigned *t_unpred_seg_counts, int bw, int bh, + int mi_row, int mi_col) { int segment_id; - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return; + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; xd->mi = mi; segment_id = xd->mi[0]->mbmi.segment_id; @@ -140,8 +135,8 @@ static void count_segs(const VP10_COMMON *cm, MACROBLOCKD *xd, if (cm->frame_type != KEY_FRAME) { const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; // Test to see if the segment id matches the predicted value. - const int pred_segment_id = get_segment_id(cm, cm->last_frame_seg_map, - bsize, mi_row, mi_col); + const int pred_segment_id = + get_segment_id(cm, cm->last_frame_seg_map, bsize, mi_row, mi_col); const int pred_flag = pred_segment_id == segment_id; const int pred_context = vp10_get_pred_context_seg_id(xd); @@ -151,8 +146,7 @@ static void count_segs(const VP10_COMMON *cm, MACROBLOCKD *xd, temporal_predictor_count[pred_context][pred_flag]++; // Update the "unpredicted" segment count - if (!pred_flag) - t_unpred_seg_counts[segment_id]++; + if (!pred_flag) t_unpred_seg_counts[segment_id]++; } } @@ -160,8 +154,7 @@ static void count_segs_sb(const VP10_COMMON *cm, MACROBLOCKD *xd, const TileInfo *tile, MODE_INFO **mi, unsigned *no_pred_segcounts, unsigned (*temporal_predictor_count)[2], - unsigned *t_unpred_seg_counts, - int mi_row, int mi_col, + unsigned *t_unpred_seg_counts, int mi_row, int mi_col, BLOCK_SIZE bsize) { const int mis = cm->mi_stride; const int bs = num_8x8_blocks_wide_lookup[bsize], hbs = bs / 2; @@ -171,8 +164,7 @@ static void count_segs_sb(const VP10_COMMON *cm, MACROBLOCKD *xd, int bw, bh; #endif // CONFIG_EXT_PARTITION_TYPES - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return; + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; #if CONFIG_EXT_PARTITION_TYPES if (bsize == BLOCK_8X8) @@ -194,9 +186,9 @@ static void count_segs_sb(const VP10_COMMON *cm, MACROBLOCKD *xd, case PARTITION_VERT: count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count, t_unpred_seg_counts, hbs, bs, mi_row, mi_col); - count_segs(cm, xd, tile, mi + hbs, - no_pred_segcounts, temporal_predictor_count, - t_unpred_seg_counts, hbs, bs, mi_row, mi_col + hbs); + count_segs(cm, xd, tile, mi + hbs, no_pred_segcounts, + temporal_predictor_count, t_unpred_seg_counts, hbs, bs, mi_row, + mi_col + hbs); break; case PARTITION_HORZ_A: count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count, @@ -224,41 +216,37 @@ static void count_segs_sb(const VP10_COMMON *cm, MACROBLOCKD *xd, count_segs(cm, xd, tile, mi + hbs * mis, no_pred_segcounts, temporal_predictor_count, t_unpred_seg_counts, hbs, hbs, mi_row + hbs, mi_col); - count_segs(cm, xd, tile, mi + hbs, - no_pred_segcounts, temporal_predictor_count, - t_unpred_seg_counts, hbs, bs, mi_row, mi_col + hbs); + count_segs(cm, xd, tile, mi + hbs, no_pred_segcounts, + temporal_predictor_count, t_unpred_seg_counts, hbs, bs, mi_row, + mi_col + hbs); break; case PARTITION_VERT_B: count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count, t_unpred_seg_counts, hbs, bs, mi_row, mi_col); - count_segs(cm, xd, tile, mi + hbs, - no_pred_segcounts, temporal_predictor_count, - t_unpred_seg_counts, hbs, hbs, mi_row, mi_col + hbs); - count_segs(cm, xd, tile, mi + hbs + hbs * mis, - no_pred_segcounts, temporal_predictor_count, - t_unpred_seg_counts, hbs, hbs, mi_row + hbs, mi_col + hbs); + count_segs(cm, xd, tile, mi + hbs, no_pred_segcounts, + temporal_predictor_count, t_unpred_seg_counts, hbs, hbs, + mi_row, mi_col + hbs); + count_segs(cm, xd, tile, mi + hbs + hbs * mis, no_pred_segcounts, + temporal_predictor_count, t_unpred_seg_counts, hbs, hbs, + mi_row + hbs, mi_col + hbs); break; - case PARTITION_SPLIT: - { - const BLOCK_SIZE subsize = subsize_lookup[PARTITION_SPLIT][bsize]; - int n; + case PARTITION_SPLIT: { + const BLOCK_SIZE subsize = subsize_lookup[PARTITION_SPLIT][bsize]; + int n; - assert(num_8x8_blocks_wide_lookup[mi[0]->mbmi.sb_type] < bs && - num_8x8_blocks_high_lookup[mi[0]->mbmi.sb_type] < bs); + assert(num_8x8_blocks_wide_lookup[mi[0]->mbmi.sb_type] < bs && + num_8x8_blocks_high_lookup[mi[0]->mbmi.sb_type] < bs); - for (n = 0; n < 4; n++) { - const int mi_dc = hbs * (n & 1); - const int mi_dr = hbs * (n >> 1); + for (n = 0; n < 4; n++) { + const int mi_dc = hbs * (n & 1); + const int mi_dr = hbs * (n >> 1); - count_segs_sb(cm, xd, tile, &mi[mi_dr * mis + mi_dc], - no_pred_segcounts, temporal_predictor_count, - t_unpred_seg_counts, - mi_row + mi_dr, mi_col + mi_dc, subsize); - } + count_segs_sb(cm, xd, tile, &mi[mi_dr * mis + mi_dc], no_pred_segcounts, + temporal_predictor_count, t_unpred_seg_counts, + mi_row + mi_dr, mi_col + mi_dc, subsize); } - break; - default: - assert(0); + } break; + default: assert(0); } #else bw = num_8x8_blocks_wide_lookup[mi[0]->mbmi.sb_type]; @@ -276,9 +264,9 @@ static void count_segs_sb(const VP10_COMMON *cm, MACROBLOCKD *xd, } else if (bw < bs && bh == bs) { count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count, t_unpred_seg_counts, hbs, bs, mi_row, mi_col); - count_segs(cm, xd, tile, mi + hbs, - no_pred_segcounts, temporal_predictor_count, t_unpred_seg_counts, - hbs, bs, mi_row, mi_col + hbs); + count_segs(cm, xd, tile, mi + hbs, no_pred_segcounts, + temporal_predictor_count, t_unpred_seg_counts, hbs, bs, mi_row, + mi_col + hbs); } else { const BLOCK_SIZE subsize = subsize_lookup[PARTITION_SPLIT][bsize]; int n; @@ -289,9 +277,8 @@ static void count_segs_sb(const VP10_COMMON *cm, MACROBLOCKD *xd, const int mi_dc = hbs * (n & 1); const int mi_dr = hbs * (n >> 1); - count_segs_sb(cm, xd, tile, &mi[mi_dr * mis + mi_dc], - no_pred_segcounts, temporal_predictor_count, - t_unpred_seg_counts, + count_segs_sb(cm, xd, tile, &mi[mi_dr * mis + mi_dc], no_pred_segcounts, + temporal_predictor_count, t_unpred_seg_counts, mi_row + mi_dr, mi_col + mi_dc, subsize); } } @@ -307,7 +294,7 @@ void vp10_choose_segmap_coding_method(VP10_COMMON *cm, MACROBLOCKD *xd) { int i, tile_col, tile_row, mi_row, mi_col; - unsigned (*temporal_predictor_count)[2] = cm->counts.seg.pred; + unsigned(*temporal_predictor_count)[2] = cm->counts.seg.pred; unsigned *no_pred_segcounts = cm->counts.seg.tree_total; unsigned *t_unpred_seg_counts = cm->counts.seg.tree_mispred; @@ -315,7 +302,7 @@ void vp10_choose_segmap_coding_method(VP10_COMMON *cm, MACROBLOCKD *xd) { vpx_prob t_pred_tree[SEG_TREE_PROBS]; vpx_prob t_nopred_prob[PREDICTION_PROBS]; - (void) xd; + (void)xd; // We are about to recompute all the segment counts, so zero the accumulators. vp10_zero(cm->counts.seg); @@ -329,21 +316,20 @@ void vp10_choose_segmap_coding_method(VP10_COMMON *cm, MACROBLOCKD *xd) { MODE_INFO **mi_ptr; vp10_tile_set_col(&tile_info, cm, tile_col); mi_ptr = cm->mi_grid_visible + tile_info.mi_row_start * cm->mi_stride + - tile_info.mi_col_start; + tile_info.mi_col_start; for (mi_row = tile_info.mi_row_start; mi_row < tile_info.mi_row_end; mi_row += cm->mib_size, mi_ptr += cm->mib_size * cm->mi_stride) { MODE_INFO **mi = mi_ptr; for (mi_col = tile_info.mi_col_start; mi_col < tile_info.mi_col_end; mi_col += cm->mib_size, mi += cm->mib_size) { count_segs_sb(cm, xd, &tile_info, mi, no_pred_segcounts, - temporal_predictor_count, t_unpred_seg_counts, - mi_row, mi_col, cm->sb_size); + temporal_predictor_count, t_unpred_seg_counts, mi_row, + mi_col, cm->sb_size); } } } } - // Work out probability tree for coding segments without prediction // and the cost. calc_segtree_probs(no_pred_segcounts, no_pred_tree, segp->tree_probs); diff --git a/vp10/encoder/segmentation.h b/vp10/encoder/segmentation.h index b8e6c06c6..c07f37ff7 100644 --- a/vp10/encoder/segmentation.h +++ b/vp10/encoder/segmentation.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_SEGMENTATION_H_ #define VP10_ENCODER_SEGMENTATION_H_ @@ -22,12 +21,10 @@ extern "C" { void vp10_enable_segmentation(struct segmentation *seg); void vp10_disable_segmentation(struct segmentation *seg); -void vp10_disable_segfeature(struct segmentation *seg, - int segment_id, - SEG_LVL_FEATURES feature_id); -void vp10_clear_segdata(struct segmentation *seg, - int segment_id, - SEG_LVL_FEATURES feature_id); +void vp10_disable_segfeature(struct segmentation *seg, int segment_id, + SEG_LVL_FEATURES feature_id); +void vp10_clear_segdata(struct segmentation *seg, int segment_id, + SEG_LVL_FEATURES feature_id); // The values given for each segment can be either deltas (from the default // value chosen for the frame) or absolute values. @@ -40,7 +37,7 @@ void vp10_clear_segdata(struct segmentation *seg, // abs_delta = SEGMENT_DELTADATA (deltas) abs_delta = SEGMENT_ABSDATA (use // the absolute values given). void vp10_set_segment_data(struct segmentation *seg, signed char *feature_data, - unsigned char abs_delta); + unsigned char abs_delta); void vp10_choose_segmap_coding_method(VP10_COMMON *cm, MACROBLOCKD *xd); diff --git a/vp10/encoder/speed_features.c b/vp10/encoder/speed_features.c index 4a236af97..de90702a9 100644 --- a/vp10/encoder/speed_features.c +++ b/vp10/encoder/speed_features.c @@ -17,21 +17,23 @@ #include "vpx_dsp/vpx_dsp_common.h" // Mesh search patters for various speed settings -static MESH_PATTERN best_quality_mesh_pattern[MAX_MESH_STEP] = - {{64, 4}, {28, 2}, {15, 1}, {7, 1}}; +static MESH_PATTERN best_quality_mesh_pattern[MAX_MESH_STEP] = { + { 64, 4 }, { 28, 2 }, { 15, 1 }, { 7, 1 } +}; #define MAX_MESH_SPEED 5 // Max speed setting for mesh motion method -static MESH_PATTERN good_quality_mesh_patterns[MAX_MESH_SPEED + 1] - [MAX_MESH_STEP] = - {{{64, 8}, {28, 4}, {15, 1}, {7, 1}}, - {{64, 8}, {28, 4}, {15, 1}, {7, 1}}, - {{64, 8}, {14, 2}, {7, 1}, {7, 1}}, - {{64, 16}, {24, 8}, {12, 4}, {7, 1}}, - {{64, 16}, {24, 8}, {12, 4}, {7, 1}}, - {{64, 16}, {24, 8}, {12, 4}, {7, 1}}, +static MESH_PATTERN + good_quality_mesh_patterns[MAX_MESH_SPEED + 1][MAX_MESH_STEP] = { + { { 64, 8 }, { 28, 4 }, { 15, 1 }, { 7, 1 } }, + { { 64, 8 }, { 28, 4 }, { 15, 1 }, { 7, 1 } }, + { { 64, 8 }, { 14, 2 }, { 7, 1 }, { 7, 1 } }, + { { 64, 16 }, { 24, 8 }, { 12, 4 }, { 7, 1 } }, + { { 64, 16 }, { 24, 8 }, { 12, 4 }, { 7, 1 } }, + { { 64, 16 }, { 24, 8 }, { 12, 4 }, { 7, 1 } }, }; -static unsigned char good_quality_max_mesh_pct[MAX_MESH_SPEED + 1] = - {50, 25, 15, 5, 1, 1}; +static unsigned char good_quality_max_mesh_pct[MAX_MESH_SPEED + 1] = { + 50, 25, 15, 5, 1, 1 +}; // Intra only frames, golden frames (except alt ref overlays) and // alt ref frames tend to be coded at a higher than ambient quality @@ -68,8 +70,8 @@ static void set_good_speed_feature_framesize_dependent(VP10_COMP *cpi, if (speed >= 1) { if (VPXMIN(cm->width, cm->height) >= 720) { - sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT - : DISABLE_ALL_INTER_SPLIT; + sf->disable_split_mask = + cm->show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT; sf->partition_search_breakout_dist_thr = (1 << 23); } else { sf->disable_split_mask = DISABLE_COMPOUND_SPLIT; @@ -79,8 +81,8 @@ static void set_good_speed_feature_framesize_dependent(VP10_COMP *cpi, if (speed >= 2) { if (VPXMIN(cm->width, cm->height) >= 720) { - sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT - : DISABLE_ALL_INTER_SPLIT; + sf->disable_split_mask = + cm->show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT; sf->adaptive_pred_interp_filter = 0; sf->partition_search_breakout_dist_thr = (1 << 24); sf->partition_search_breakout_rate_thr = 120; @@ -138,7 +140,7 @@ static void set_good_speed_feature(VP10_COMP *cpi, VP10_COMMON *cm, sf->use_square_partition_only = !frame_is_intra_only(cm); } - sf->less_rectangular_check = 1; + sf->less_rectangular_check = 1; sf->use_rd_breakout = 1; sf->adaptive_motion_search = 1; @@ -169,13 +171,13 @@ static void set_good_speed_feature(VP10_COMP *cpi, VP10_COMMON *cm, } if (speed >= 2) { - sf->tx_size_search_method = frame_is_boosted(cpi) ? USE_FULL_RD - : USE_LARGESTALL; - sf->mode_search_skip_flags = (cm->frame_type == KEY_FRAME) ? 0 : - FLAG_SKIP_INTRA_DIRMISMATCH | - FLAG_SKIP_INTRA_BESTINTER | - FLAG_SKIP_COMP_BESTINTRA | - FLAG_SKIP_INTRA_LOWVAR; + sf->tx_size_search_method = + frame_is_boosted(cpi) ? USE_FULL_RD : USE_LARGESTALL; + sf->mode_search_skip_flags = + (cm->frame_type == KEY_FRAME) ? 0 : FLAG_SKIP_INTRA_DIRMISMATCH | + FLAG_SKIP_INTRA_BESTINTER | + FLAG_SKIP_COMP_BESTINTRA | + FLAG_SKIP_INTRA_LOWVAR; sf->disable_filter_search_var_thresh = 100; sf->comp_inter_joint_search_thresh = BLOCK_SIZES; sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX; @@ -189,8 +191,8 @@ static void set_good_speed_feature(VP10_COMP *cpi, VP10_COMMON *cm, if (speed >= 3) { sf->use_square_partition_only = !frame_is_intra_only(cm); - sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD - : USE_LARGESTALL; + sf->tx_size_search_method = + frame_is_intra_only(cm) ? USE_FULL_RD : USE_LARGESTALL; sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED; sf->adaptive_pred_interp_filter = 0; sf->adaptive_mode_search = 1; @@ -236,12 +238,13 @@ static void set_good_speed_feature(VP10_COMP *cpi, VP10_COMMON *cm, } static void set_rt_speed_feature_framesize_dependent(VP10_COMP *cpi, - SPEED_FEATURES *sf, int speed) { + SPEED_FEATURES *sf, + int speed) { VP10_COMMON *const cm = &cpi->common; if (speed >= 1) { if (VPXMIN(cm->width, cm->height) >= 720) { - sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT - : DISABLE_ALL_INTER_SPLIT; + sf->disable_split_mask = + cm->show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT; } else { sf->disable_split_mask = DISABLE_COMPOUND_SPLIT; } @@ -249,8 +252,8 @@ static void set_rt_speed_feature_framesize_dependent(VP10_COMP *cpi, if (speed >= 2) { if (VPXMIN(cm->width, cm->height) >= 720) { - sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT - : DISABLE_ALL_INTER_SPLIT; + sf->disable_split_mask = + cm->show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT; } else { sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY; } @@ -265,13 +268,13 @@ static void set_rt_speed_feature_framesize_dependent(VP10_COMP *cpi, } if (speed >= 7) { - sf->encode_breakout_thresh = (VPXMIN(cm->width, cm->height) >= 720) ? - 800 : 300; + sf->encode_breakout_thresh = + (VPXMIN(cm->width, cm->height) >= 720) ? 800 : 300; } } -static void set_rt_speed_feature(VP10_COMP *cpi, SPEED_FEATURES *sf, - int speed, vpx_tune_content content) { +static void set_rt_speed_feature(VP10_COMP *cpi, SPEED_FEATURES *sf, int speed, + vpx_tune_content content) { VP10_COMMON *const cm = &cpi->common; const int is_keyframe = cm->frame_type == KEY_FRAME; const int frames_since_key = is_keyframe ? 0 : cpi->rc.frames_since_key; @@ -293,8 +296,8 @@ static void set_rt_speed_feature(VP10_COMP *cpi, SPEED_FEATURES *sf, if (speed >= 1) { sf->use_square_partition_only = !frame_is_intra_only(cm); sf->less_rectangular_check = 1; - sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD - : USE_LARGESTALL; + sf->tx_size_search_method = + frame_is_intra_only(cm) ? USE_FULL_RD : USE_LARGESTALL; sf->use_rd_breakout = 1; @@ -307,13 +310,12 @@ static void set_rt_speed_feature(VP10_COMP *cpi, SPEED_FEATURES *sf, sf->intra_uv_mode_mask[TX_16X16] = INTRA_DC_H_V; } - if (speed >= 2) { - sf->mode_search_skip_flags = (cm->frame_type == KEY_FRAME) ? 0 : - FLAG_SKIP_INTRA_DIRMISMATCH | - FLAG_SKIP_INTRA_BESTINTER | - FLAG_SKIP_COMP_BESTINTRA | - FLAG_SKIP_INTRA_LOWVAR; + sf->mode_search_skip_flags = + (cm->frame_type == KEY_FRAME) ? 0 : FLAG_SKIP_INTRA_DIRMISMATCH | + FLAG_SKIP_INTRA_BESTINTER | + FLAG_SKIP_COMP_BESTINTRA | + FLAG_SKIP_INTRA_LOWVAR; sf->adaptive_pred_interp_filter = 2; sf->disable_filter_search_var_thresh = 50; sf->comp_inter_joint_search_thresh = BLOCK_SIZES; @@ -345,8 +347,8 @@ static void set_rt_speed_feature(VP10_COMP *cpi, SPEED_FEATURES *sf, sf->use_fast_coef_costing = 0; sf->auto_min_max_partition_size = STRICT_NEIGHBORING_MIN_MAX; sf->adjust_partitioning_from_last_frame = - cm->last_frame_type != cm->frame_type || (0 == - (frames_since_key + 1) % sf->last_partitioning_redo_frequency); + cm->last_frame_type != cm->frame_type || + (0 == (frames_since_key + 1) % sf->last_partitioning_redo_frequency); sf->mv.subpel_force_stop = 1; for (i = 0; i < TX_SIZES; i++) { sf->intra_y_mode_mask[i] = INTRA_DC_H_V; @@ -369,11 +371,12 @@ static void set_rt_speed_feature(VP10_COMP *cpi, SPEED_FEATURES *sf, } if (speed >= 5) { - sf->auto_min_max_partition_size = is_keyframe ? RELAXED_NEIGHBORING_MIN_MAX - : STRICT_NEIGHBORING_MIN_MAX; + sf->auto_min_max_partition_size = + is_keyframe ? RELAXED_NEIGHBORING_MIN_MAX : STRICT_NEIGHBORING_MIN_MAX; sf->default_max_partition_size = BLOCK_32X32; sf->default_min_partition_size = BLOCK_8X8; - sf->force_frame_boost = is_keyframe || + sf->force_frame_boost = + is_keyframe || (frames_since_key % (sf->last_partitioning_redo_frequency << 1) == 1); sf->max_delta_qindex = is_keyframe ? 20 : 15; sf->partition_search_type = REFERENCE_PARTITION; @@ -530,8 +533,7 @@ void vp10_set_speed_features_framesize_independent(VP10_COMP *cpi) { sf->use_fast_coef_costing = 0; sf->mode_skip_start = MAX_MODES; // Mode index at which mode skip mask set sf->schedule_mode_search = 0; - for (i = 0; i < BLOCK_SIZES; ++i) - sf->inter_mode_mask[i] = INTER_ALL; + for (i = 0; i < BLOCK_SIZES; ++i) sf->inter_mode_mask[i] = INTER_ALL; sf->max_intra_bsize = BLOCK_LARGEST; sf->reuse_inter_pred_sby = 0; // This setting only takes effect when partition_search_type is set @@ -547,7 +549,7 @@ void vp10_set_speed_features_framesize_independent(VP10_COMP *cpi) { sf->partition_search_breakout_rate_thr = 0; sf->simple_model_rd_from_var = 0; - // Set this at the appropriate speed levels +// Set this at the appropriate speed levels #if CONFIG_EXT_TILE sf->use_transform_domain_distortion = 1; #else @@ -590,8 +592,7 @@ void vp10_set_speed_features_framesize_independent(VP10_COMP *cpi) { sf->exhaustive_searches_thresh = sf->exhaustive_searches_thresh << 1; for (i = 0; i < MAX_MESH_STEP; ++i) { - sf->mesh_patterns[i].range = - good_quality_mesh_patterns[speed][i].range; + sf->mesh_patterns[i].range = good_quality_mesh_patterns[speed][i].range; sf->mesh_patterns[i].interval = good_quality_mesh_patterns[speed][i].interval; } @@ -599,8 +600,7 @@ void vp10_set_speed_features_framesize_independent(VP10_COMP *cpi) { // Slow quant, dct and trellis not worthwhile for first pass // so make sure they are always turned off. - if (oxcf->pass == 1) - sf->optimize_coefficients = 0; + if (oxcf->pass == 1) sf->optimize_coefficients = 0; // No recode for 1 pass. if (oxcf->pass == 0) { @@ -615,7 +615,8 @@ void vp10_set_speed_features_framesize_independent(VP10_COMP *cpi) { } else if (sf->mv.subpel_search_method == SUBPEL_TREE_PRUNED_MORE) { cpi->find_fractional_mv_step = vp10_find_best_sub_pixel_tree_pruned_more; } else if (sf->mv.subpel_search_method == SUBPEL_TREE_PRUNED_EVENMORE) { - cpi->find_fractional_mv_step = vp10_find_best_sub_pixel_tree_pruned_evenmore; + cpi->find_fractional_mv_step = + vp10_find_best_sub_pixel_tree_pruned_evenmore; } x->optimize = sf->optimize_coefficients == 1 && oxcf->pass != 1; diff --git a/vp10/encoder/speed_features.h b/vp10/encoder/speed_features.h index c1d1f8148..a0e5c637f 100644 --- a/vp10/encoder/speed_features.h +++ b/vp10/encoder/speed_features.h @@ -18,28 +18,24 @@ extern "C" { #endif enum { - INTRA_ALL = (1 << DC_PRED) | - (1 << V_PRED) | (1 << H_PRED) | - (1 << D45_PRED) | (1 << D135_PRED) | - (1 << D117_PRED) | (1 << D153_PRED) | - (1 << D207_PRED) | (1 << D63_PRED) | - (1 << TM_PRED), - INTRA_DC = (1 << DC_PRED), - INTRA_DC_TM = (1 << DC_PRED) | (1 << TM_PRED), - INTRA_DC_H_V = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED), - INTRA_DC_TM_H_V = (1 << DC_PRED) | (1 << TM_PRED) | (1 << V_PRED) | - (1 << H_PRED) + INTRA_ALL = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED) | (1 << D45_PRED) | + (1 << D135_PRED) | (1 << D117_PRED) | (1 << D153_PRED) | + (1 << D207_PRED) | (1 << D63_PRED) | (1 << TM_PRED), + INTRA_DC = (1 << DC_PRED), + INTRA_DC_TM = (1 << DC_PRED) | (1 << TM_PRED), + INTRA_DC_H_V = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED), + INTRA_DC_TM_H_V = + (1 << DC_PRED) | (1 << TM_PRED) | (1 << V_PRED) | (1 << H_PRED) }; #if CONFIG_EXT_INTER enum { - INTER_ALL = - (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) | - (1 << NEWMV) | (1 << NEWFROMNEARMV) | - (1 << NEAREST_NEARESTMV) | (1 << NEAR_NEARMV) | (1 << NEAREST_NEARMV) | - (1 << NEAR_NEARESTMV) | (1 << NEW_NEWMV) | (1 << NEAREST_NEWMV) | - (1 << NEAR_NEWMV) | (1 << NEW_NEARMV) | (1 << NEW_NEARESTMV) | - (1 << ZERO_ZEROMV), + INTER_ALL = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) | (1 << NEWMV) | + (1 << NEWFROMNEARMV) | (1 << NEAREST_NEARESTMV) | + (1 << NEAR_NEARMV) | (1 << NEAREST_NEARMV) | + (1 << NEAR_NEARESTMV) | (1 << NEW_NEWMV) | (1 << NEAREST_NEWMV) | + (1 << NEAR_NEWMV) | (1 << NEW_NEARMV) | (1 << NEW_NEARESTMV) | + (1 << ZERO_ZEROMV), INTER_NEAREST = (1 << NEARESTMV) | (1 << NEAREST_NEARESTMV) | (1 << NEAREST_NEARMV) | (1 << NEAR_NEARESTMV) | (1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV), @@ -55,20 +51,17 @@ enum { INTER_NEAREST_NEW_ZERO = (1 << NEARESTMV) | (1 << ZEROMV) | (1 << NEWMV) | (1 << NEWFROMNEARMV) | (1 << NEAREST_NEARESTMV) | (1 << ZERO_ZEROMV) | (1 << NEW_NEWMV) | - (1 << NEAREST_NEARMV) | (1 << NEAR_NEARESTMV) | - (1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV) | - (1 << NEW_NEARMV) | (1 << NEAR_NEWMV), + (1 << NEAREST_NEARMV) | (1 << NEAR_NEARESTMV) | (1 << NEW_NEARESTMV) | + (1 << NEAREST_NEWMV) | (1 << NEW_NEARMV) | (1 << NEAR_NEWMV), INTER_NEAREST_NEAR_NEW = (1 << NEARESTMV) | (1 << NEARMV) | (1 << NEWMV) | (1 << NEWFROMNEARMV) | - (1 << NEAREST_NEARESTMV) | (1 << NEW_NEWMV) | - (1 << NEAREST_NEARMV) | (1 << NEAR_NEARESTMV) | - (1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV) | + (1 << NEAREST_NEARESTMV) | (1 << NEW_NEWMV) | (1 << NEAREST_NEARMV) | + (1 << NEAR_NEARESTMV) | (1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV) | (1 << NEW_NEARMV) | (1 << NEAR_NEWMV) | (1 << NEAR_NEARMV), INTER_NEAREST_NEAR_ZERO = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) | - (1 << NEAREST_NEARESTMV) | (1 << ZERO_ZEROMV) | - (1 << NEAREST_NEARMV) | (1 << NEAR_NEARESTMV) | - (1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV) | + (1 << NEAREST_NEARESTMV) | (1 << ZERO_ZEROMV) | (1 << NEAREST_NEARMV) | + (1 << NEAR_NEARESTMV) | (1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV) | (1 << NEW_NEARMV) | (1 << NEAR_NEWMV) | (1 << NEAR_NEARMV), }; #else @@ -84,20 +77,15 @@ enum { #endif // CONFIG_EXT_INTER enum { - DISABLE_ALL_INTER_SPLIT = (1 << THR_COMP_GA) | - (1 << THR_COMP_LA) | - (1 << THR_ALTR) | - (1 << THR_GOLD) | - (1 << THR_LAST), + DISABLE_ALL_INTER_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) | + (1 << THR_ALTR) | (1 << THR_GOLD) | (1 << THR_LAST), - DISABLE_ALL_SPLIT = (1 << THR_INTRA) | DISABLE_ALL_INTER_SPLIT, + DISABLE_ALL_SPLIT = (1 << THR_INTRA) | DISABLE_ALL_INTER_SPLIT, - DISABLE_COMPOUND_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA), + DISABLE_COMPOUND_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA), - LAST_AND_INTRA_SPLIT_ONLY = (1 << THR_COMP_GA) | - (1 << THR_COMP_LA) | - (1 << THR_ALTR) | - (1 << THR_GOLD) + LAST_AND_INTRA_SPLIT_ONLY = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) | + (1 << THR_ALTR) | (1 << THR_GOLD) }; typedef enum { diff --git a/vp10/encoder/subexp.c b/vp10/encoder/subexp.c index 3a2e09f2f..4a1462392 100644 --- a/vp10/encoder/subexp.c +++ b/vp10/encoder/subexp.c @@ -14,25 +14,23 @@ #include "vp10/encoder/cost.h" #include "vp10/encoder/subexp.h" -#define vp10_cost_upd256 ((int)(vp10_cost_one(upd) - vp10_cost_zero(upd))) +#define vp10_cost_upd256 ((int)(vp10_cost_one(upd) - vp10_cost_zero(upd))) static const uint8_t update_bits[255] = { - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 0, }; static int recenter_nonneg(int v, int m) { @@ -49,23 +47,23 @@ static int remap_prob(int v, int m) { static const uint8_t map_table[MAX_PROB - 1] = { // generated by: // map_table[j] = split_index(j, MAX_PROB - 1, MODULUS_PARAM); - 20, 21, 22, 23, 24, 25, 0, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 2, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 3, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 4, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 5, 86, 87, 88, - 89, 90, 91, 92, 93, 94, 95, 96, 97, 6, 98, 99, 100, 101, 102, - 103, 104, 105, 106, 107, 108, 109, 7, 110, 111, 112, 113, 114, 115, 116, - 117, 118, 119, 120, 121, 8, 122, 123, 124, 125, 126, 127, 128, 129, 130, - 131, 132, 133, 9, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 10, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 11, - 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 12, 170, 171, - 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 13, 182, 183, 184, 185, - 186, 187, 188, 189, 190, 191, 192, 193, 14, 194, 195, 196, 197, 198, 199, - 200, 201, 202, 203, 204, 205, 15, 206, 207, 208, 209, 210, 211, 212, 213, - 214, 215, 216, 217, 16, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, - 228, 229, 17, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, - 18, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 19, + 20, 21, 22, 23, 24, 25, 0, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 2, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 3, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 4, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 5, 86, 87, 88, + 89, 90, 91, 92, 93, 94, 95, 96, 97, 6, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 7, 110, 111, 112, 113, 114, 115, 116, + 117, 118, 119, 120, 121, 8, 122, 123, 124, 125, 126, 127, 128, 129, 130, + 131, 132, 133, 9, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 10, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 11, + 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 12, 170, 171, + 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 13, 182, 183, 184, 185, + 186, 187, 188, 189, 190, 191, 192, 193, 14, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 205, 15, 206, 207, 208, 209, 210, 211, 212, 213, + 214, 215, 216, 217, 16, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, + 228, 229, 17, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, + 18, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 19, }; v--; m--; @@ -116,9 +114,8 @@ void vp10_write_prob_diff_update(vp10_writer *w, vpx_prob newp, vpx_prob oldp) { encode_term_subexp(w, delp); } -int vp10_prob_diff_update_savings_search(const unsigned int *ct, - vpx_prob oldp, vpx_prob *bestp, - vpx_prob upd) { +int vp10_prob_diff_update_savings_search(const unsigned int *ct, vpx_prob oldp, + vpx_prob *bestp, vpx_prob upd) { const int old_b = cost_branch256(ct, oldp); int bestsavings = 0; vpx_prob newp, bestnewp = oldp; @@ -138,10 +135,9 @@ int vp10_prob_diff_update_savings_search(const unsigned int *ct, } int vp10_prob_diff_update_savings_search_model(const unsigned int *ct, - const vpx_prob *oldp, - vpx_prob *bestp, - vpx_prob upd, - int stepsize) { + const vpx_prob *oldp, + vpx_prob *bestp, vpx_prob upd, + int stepsize) { int i, old_b, new_b, update_b, savings, bestsavings; int newp; const int step_sign = *bestp > oldp[PIVOT_NODE] ? -1 : 1; @@ -158,17 +154,14 @@ int vp10_prob_diff_update_savings_search_model(const unsigned int *ct, assert(stepsize > 0); - for (newp = *bestp; (newp - oldp[PIVOT_NODE]) * step_sign < 0; - newp += step) { - if (newp < 1 || newp > 255) - continue; + for (newp = *bestp; (newp - oldp[PIVOT_NODE]) * step_sign < 0; newp += step) { + if (newp < 1 || newp > 255) continue; newplist[PIVOT_NODE] = newp; vp10_model_to_full_probs(newplist, newplist); for (i = UNCONSTRAINED_NODES, new_b = 0; i < ENTROPY_NODES; ++i) new_b += cost_branch256(ct + 2 * i, newplist[i]); new_b += cost_branch256(ct + 2 * PIVOT_NODE, newplist[PIVOT_NODE]); - update_b = prob_diff_update_cost(newp, oldp[PIVOT_NODE]) + - vp10_cost_upd256; + update_b = prob_diff_update_cost(newp, oldp[PIVOT_NODE]) + vp10_cost_upd256; savings = old_b - new_b - update_b; if (savings > bestsavings) { bestsavings = savings; @@ -183,7 +176,7 @@ int vp10_prob_diff_update_savings_search_model(const unsigned int *ct, #if CONFIG_ENTROPY static int get_cost(unsigned int ct[][2], vpx_prob p, int n) { int i, p0 = p; - unsigned int total_ct[2] = {0 , 0}; + unsigned int total_ct[2] = { 0, 0 }; int cost = 0; for (i = 0; i <= n; ++i) { @@ -191,15 +184,14 @@ static int get_cost(unsigned int ct[][2], vpx_prob p, int n) { total_ct[0] += ct[i][0]; total_ct[1] += ct[i][1]; if (i < n) - p = vp10_merge_probs(p0, total_ct, - COEF_COUNT_SAT_BITS, COEF_MAX_UPDATE_FACTOR_BITS); + p = vp10_merge_probs(p0, total_ct, COEF_COUNT_SAT_BITS, + COEF_MAX_UPDATE_FACTOR_BITS); } return cost; } -int vp10_prob_update_search_subframe(unsigned int ct[][2], - vpx_prob oldp, vpx_prob *bestp, - vpx_prob upd, int n) { +int vp10_prob_update_search_subframe(unsigned int ct[][2], vpx_prob oldp, + vpx_prob *bestp, vpx_prob upd, int n) { const int old_b = get_cost(ct, oldp, n); int bestsavings = 0; vpx_prob newp, bestnewp = oldp; @@ -218,11 +210,9 @@ int vp10_prob_update_search_subframe(unsigned int ct[][2], return bestsavings; } -int vp10_prob_update_search_model_subframe(unsigned int ct[ENTROPY_NODES] - [COEF_PROBS_BUFS][2], - const vpx_prob *oldp, - vpx_prob *bestp, vpx_prob upd, - int stepsize, int n) { +int vp10_prob_update_search_model_subframe( + unsigned int ct[ENTROPY_NODES][COEF_PROBS_BUFS][2], const vpx_prob *oldp, + vpx_prob *bestp, vpx_prob upd, int stepsize, int n) { int i, old_b, new_b, update_b, savings, bestsavings; int newp; const int step_sign = *bestp > oldp[PIVOT_NODE] ? -1 : 1; @@ -239,17 +229,14 @@ int vp10_prob_update_search_model_subframe(unsigned int ct[ENTROPY_NODES] assert(stepsize > 0); - for (newp = *bestp; (newp - oldp[PIVOT_NODE]) * step_sign < 0; - newp += step) { - if (newp < 1 || newp > 255) - continue; + for (newp = *bestp; (newp - oldp[PIVOT_NODE]) * step_sign < 0; newp += step) { + if (newp < 1 || newp > 255) continue; newplist[PIVOT_NODE] = newp; vp10_model_to_full_probs(newplist, newplist); for (i = UNCONSTRAINED_NODES, new_b = 0; i < ENTROPY_NODES; ++i) new_b += get_cost(ct[i], newplist[i], n); new_b += get_cost(ct[PIVOT_NODE], newplist[PIVOT_NODE], n); - update_b = prob_diff_update_cost(newp, oldp[PIVOT_NODE]) + - vp10_cost_upd256; + update_b = prob_diff_update_cost(newp, oldp[PIVOT_NODE]) + vp10_cost_upd256; savings = old_b - new_b - update_b; if (savings > bestsavings) { bestsavings = savings; @@ -263,11 +250,11 @@ int vp10_prob_update_search_model_subframe(unsigned int ct[ENTROPY_NODES] #endif // CONFIG_ENTROPY void vp10_cond_prob_diff_update(vp10_writer *w, vpx_prob *oldp, - const unsigned int ct[2]) { + const unsigned int ct[2]) { const vpx_prob upd = DIFF_UPDATE_PROB; vpx_prob newp = get_binary_prob(ct[0], ct[1]); - const int savings = vp10_prob_diff_update_savings_search(ct, *oldp, &newp, - upd); + const int savings = + vp10_prob_diff_update_savings_search(ct, *oldp, &newp, upd); assert(newp >= 1); if (savings > 0) { vp10_write(w, 1, upd); @@ -282,13 +269,13 @@ int vp10_cond_prob_diff_update_savings(vpx_prob *oldp, const unsigned int ct[2]) { const vpx_prob upd = DIFF_UPDATE_PROB; vpx_prob newp = get_binary_prob(ct[0], ct[1]); - const int savings = vp10_prob_diff_update_savings_search(ct, *oldp, &newp, - upd); + const int savings = + vp10_prob_diff_update_savings_search(ct, *oldp, &newp, upd); return savings; } void vp10_write_primitive_symmetric(vp10_writer *w, int word, - unsigned int abs_bits) { + unsigned int abs_bits) { if (word == 0) { vp10_write_bit(w, 0); } else { diff --git a/vp10/encoder/subexp.h b/vp10/encoder/subexp.h index dbd48ff62..1648d7426 100644 --- a/vp10/encoder/subexp.h +++ b/vp10/encoder/subexp.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #ifndef VP10_ENCODER_SUBEXP_H_ #define VP10_ENCODER_SUBEXP_H_ @@ -20,34 +19,28 @@ extern "C" { struct vp10_writer; -void vp10_write_prob_diff_update(struct vp10_writer *w, - vpx_prob newp, vpx_prob oldp); +void vp10_write_prob_diff_update(struct vp10_writer *w, vpx_prob newp, + vpx_prob oldp); void vp10_cond_prob_diff_update(struct vp10_writer *w, vpx_prob *oldp, - const unsigned int ct[2]); - -int vp10_prob_diff_update_savings_search(const unsigned int *ct, - vpx_prob oldp, vpx_prob *bestp, - vpx_prob upd); + const unsigned int ct[2]); +int vp10_prob_diff_update_savings_search(const unsigned int *ct, vpx_prob oldp, + vpx_prob *bestp, vpx_prob upd); int vp10_prob_diff_update_savings_search_model(const unsigned int *ct, - const vpx_prob *oldp, - vpx_prob *bestp, - vpx_prob upd, - int stepsize); + const vpx_prob *oldp, + vpx_prob *bestp, vpx_prob upd, + int stepsize); int vp10_cond_prob_diff_update_savings(vpx_prob *oldp, const unsigned int ct[2]); #if CONFIG_ENTROPY -int vp10_prob_update_search_subframe(unsigned int ct[][2], - vpx_prob oldp, vpx_prob *bestp, - vpx_prob upd, int n); -int vp10_prob_update_search_model_subframe(unsigned int ct[ENTROPY_NODES] - [COEF_PROBS_BUFS][2], - const vpx_prob *oldp, - vpx_prob *bestp, vpx_prob upd, - int stepsize, int n); +int vp10_prob_update_search_subframe(unsigned int ct[][2], vpx_prob oldp, + vpx_prob *bestp, vpx_prob upd, int n); +int vp10_prob_update_search_model_subframe( + unsigned int ct[ENTROPY_NODES][COEF_PROBS_BUFS][2], const vpx_prob *oldp, + vpx_prob *bestp, vpx_prob upd, int stepsize, int n); #endif // CONFIG_ENTROPY // @@ -56,7 +49,7 @@ int vp10_prob_update_search_model_subframe(unsigned int ct[ENTROPY_NODES] // indicate 0 or non-zero, mag_bits bits are used to indicate magnitide // and 1 more bit for the sign if non-zero. void vp10_write_primitive_symmetric(vp10_writer *w, int word, - unsigned int mag_bits); + unsigned int mag_bits); #ifdef __cplusplus } // extern "C" #endif diff --git a/vp10/encoder/temporal_filter.c b/vp10/encoder/temporal_filter.c index 8217e09de..a22f3b536 100644 --- a/vp10/encoder/temporal_filter.c +++ b/vp10/encoder/temporal_filter.c @@ -31,18 +31,10 @@ static int fixed_divide[512]; -static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd, - uint8_t *y_mb_ptr, - uint8_t *u_mb_ptr, - uint8_t *v_mb_ptr, - int stride, - int uv_block_width, - int uv_block_height, - int mv_row, - int mv_col, - uint8_t *pred, - struct scale_factors *scale, - int x, int y) { +static void temporal_filter_predictors_mb_c( + MACROBLOCKD *xd, uint8_t *y_mb_ptr, uint8_t *u_mb_ptr, uint8_t *v_mb_ptr, + int stride, int uv_block_width, int uv_block_height, int mv_row, int mv_col, + uint8_t *pred, struct scale_factors *scale, int x, int y) { const int which_mv = 0; const MV mv = { mv_row, mv_col }; enum mv_precision mv_precision_uv; @@ -50,10 +42,10 @@ static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd, #if USE_TEMPORALFILTER_12TAP #if CONFIG_DUAL_FILTER - const INTERP_FILTER interp_filter[4] = { - TEMPORALFILTER_12TAP, TEMPORALFILTER_12TAP, - TEMPORALFILTER_12TAP, TEMPORALFILTER_12TAP - }; + const INTERP_FILTER interp_filter[4] = { TEMPORALFILTER_12TAP, + TEMPORALFILTER_12TAP, + TEMPORALFILTER_12TAP, + TEMPORALFILTER_12TAP }; #else const INTERP_FILTER interp_filter = TEMPORALFILTER_12TAP; #endif @@ -72,76 +64,45 @@ static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd, #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { - vp10_highbd_build_inter_predictor(y_mb_ptr, stride, - &pred[0], 16, - &mv, - scale, - 16, 16, - which_mv, - interp_filter, - MV_PRECISION_Q3, x, y, xd->bd); + vp10_highbd_build_inter_predictor(y_mb_ptr, stride, &pred[0], 16, &mv, + scale, 16, 16, which_mv, interp_filter, + MV_PRECISION_Q3, x, y, xd->bd); - vp10_highbd_build_inter_predictor(u_mb_ptr, uv_stride, - &pred[256], uv_block_width, - &mv, - scale, - uv_block_width, uv_block_height, - which_mv, - interp_filter, - mv_precision_uv, x, y, xd->bd); + vp10_highbd_build_inter_predictor( + u_mb_ptr, uv_stride, &pred[256], uv_block_width, &mv, scale, + uv_block_width, uv_block_height, which_mv, interp_filter, + mv_precision_uv, x, y, xd->bd); - vp10_highbd_build_inter_predictor(v_mb_ptr, uv_stride, - &pred[512], uv_block_width, - &mv, - scale, - uv_block_width, uv_block_height, - which_mv, - interp_filter, - mv_precision_uv, x, y, xd->bd); + vp10_highbd_build_inter_predictor( + v_mb_ptr, uv_stride, &pred[512], uv_block_width, &mv, scale, + uv_block_width, uv_block_height, which_mv, interp_filter, + mv_precision_uv, x, y, xd->bd); return; } #endif // CONFIG_VP9_HIGHBITDEPTH - vp10_build_inter_predictor(y_mb_ptr, stride, - &pred[0], 16, - &mv, - scale, - 16, 16, - which_mv, - interp_filter, MV_PRECISION_Q3, x, y); + vp10_build_inter_predictor(y_mb_ptr, stride, &pred[0], 16, &mv, scale, 16, 16, + which_mv, interp_filter, MV_PRECISION_Q3, x, y); - vp10_build_inter_predictor(u_mb_ptr, uv_stride, - &pred[256], uv_block_width, - &mv, - scale, - uv_block_width, uv_block_height, - which_mv, - interp_filter, mv_precision_uv, x, y); + vp10_build_inter_predictor(u_mb_ptr, uv_stride, &pred[256], uv_block_width, + &mv, scale, uv_block_width, uv_block_height, + which_mv, interp_filter, mv_precision_uv, x, y); - vp10_build_inter_predictor(v_mb_ptr, uv_stride, - &pred[512], uv_block_width, - &mv, - scale, - uv_block_width, uv_block_height, - which_mv, - interp_filter, mv_precision_uv, x, y); + vp10_build_inter_predictor(v_mb_ptr, uv_stride, &pred[512], uv_block_width, + &mv, scale, uv_block_width, uv_block_height, + which_mv, interp_filter, mv_precision_uv, x, y); } void vp10_temporal_filter_init(void) { int i; fixed_divide[0] = 0; - for (i = 1; i < 512; ++i) - fixed_divide[i] = 0x80000 / i; + for (i = 1; i < 512; ++i) fixed_divide[i] = 0x80000 / i; } -void vp10_temporal_filter_apply_c(uint8_t *frame1, - unsigned int stride, - uint8_t *frame2, - unsigned int block_width, - unsigned int block_height, - int strength, - int filter_weight, - unsigned int *accumulator, +void vp10_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride, + uint8_t *frame2, unsigned int block_width, + unsigned int block_height, int strength, + int filter_weight, unsigned int *accumulator, uint16_t *count) { unsigned int i, j, k; int modifier; @@ -161,10 +122,10 @@ void vp10_temporal_filter_apply_c(uint8_t *frame1, int row = i + idy; int col = j + idx; - if (row >= 0 && row < (int)block_height && - col >= 0 && col < (int)block_width) { + if (row >= 0 && row < (int)block_height && col >= 0 && + col < (int)block_width) { int diff = frame1[byte + idy * (int)stride + idx] - - frame2[idy * (int)block_width + idx]; + frame2[idy * (int)block_width + idx]; diff_sse[index] = diff * diff; ++index; } @@ -174,19 +135,17 @@ void vp10_temporal_filter_apply_c(uint8_t *frame1, assert(index > 0); modifier = 0; - for (idx = 0; idx < 9; ++idx) - modifier += diff_sse[idx]; + for (idx = 0; idx < 9; ++idx) modifier += diff_sse[idx]; modifier *= 3; modifier /= index; ++frame2; - modifier += rounding; + modifier += rounding; modifier >>= strength; - if (modifier > 16) - modifier = 16; + if (modifier > 16) modifier = 16; modifier = 16 - modifier; modifier *= filter_weight; @@ -202,15 +161,10 @@ void vp10_temporal_filter_apply_c(uint8_t *frame1, } #if CONFIG_VP9_HIGHBITDEPTH -void vp10_highbd_temporal_filter_apply_c(uint8_t *frame1_8, - unsigned int stride, - uint8_t *frame2_8, - unsigned int block_width, - unsigned int block_height, - int strength, - int filter_weight, - unsigned int *accumulator, - uint16_t *count) { +void vp10_highbd_temporal_filter_apply_c( + uint8_t *frame1_8, unsigned int stride, uint8_t *frame2_8, + unsigned int block_width, unsigned int block_height, int strength, + int filter_weight, unsigned int *accumulator, uint16_t *count) { uint16_t *frame1 = CONVERT_TO_SHORTPTR(frame1_8); uint16_t *frame2 = CONVERT_TO_SHORTPTR(frame2_8); unsigned int i, j, k; @@ -231,10 +185,10 @@ void vp10_highbd_temporal_filter_apply_c(uint8_t *frame1_8, int row = i + idy; int col = j + idx; - if (row >= 0 && row < (int)block_height && - col >= 0 && col < (int)block_width) { + if (row >= 0 && row < (int)block_height && col >= 0 && + col < (int)block_width) { int diff = frame1[byte + idy * (int)stride + idx] - - frame2[idy * (int)block_width + idx]; + frame2[idy * (int)block_width + idx]; diff_sse[index] = diff * diff; ++index; } @@ -244,8 +198,7 @@ void vp10_highbd_temporal_filter_apply_c(uint8_t *frame1_8, assert(index > 0); modifier = 0; - for (idx = 0; idx < 9; ++idx) - modifier += diff_sse[idx]; + for (idx = 0; idx < 9; ++idx) modifier += diff_sse[idx]; modifier *= 3; modifier /= index; @@ -255,8 +208,7 @@ void vp10_highbd_temporal_filter_apply_c(uint8_t *frame1_8, modifier += rounding; modifier >>= strength; - if (modifier > 16) - modifier = 16; + if (modifier > 16) modifier = 16; modifier = 16 - modifier; modifier *= filter_weight; @@ -286,7 +238,7 @@ static int temporal_filter_find_matching_mb_c(VP10_COMP *cpi, unsigned int sse; int cost_list[5]; - MV best_ref_mv1 = {0, 0}; + MV best_ref_mv1 = { 0, 0 }; MV best_ref_mv1_full; /* full-pixel value of best_ref_mv1 */ // Save input state @@ -314,18 +266,15 @@ static int temporal_filter_find_matching_mb_c(VP10_COMP *cpi, // Ignore mv costing by sending NULL pointer instead of cost arrays vp10_hex_search(x, &best_ref_mv1_full, step_param, sadpb, 1, - cond_cost_list(cpi, cost_list), - &cpi->fn_ptr[BLOCK_16X16], 0, &best_ref_mv1); + cond_cost_list(cpi, cost_list), &cpi->fn_ptr[BLOCK_16X16], 0, + &best_ref_mv1); // Ignore mv costing by sending NULL pointer instead of cost array - bestsme = cpi->find_fractional_mv_step(x, &best_ref_mv1, - cpi->common.allow_high_precision_mv, - x->errorperbit, - &cpi->fn_ptr[BLOCK_16X16], - 0, mv_sf->subpel_iters_per_step, - cond_cost_list(cpi, cost_list), - NULL, NULL, - &distortion, &sse, NULL, 0, 0, 0); + bestsme = cpi->find_fractional_mv_step( + x, &best_ref_mv1, cpi->common.allow_high_precision_mv, x->errorperbit, + &cpi->fn_ptr[BLOCK_16X16], 0, mv_sf->subpel_iters_per_step, + cond_cost_list(cpi, cost_list), NULL, NULL, &distortion, &sse, NULL, 0, 0, + 0); x->e_mbd.mi[0]->bmi[0].as_mv[0] = x->best_mv; @@ -338,8 +287,7 @@ static int temporal_filter_find_matching_mb_c(VP10_COMP *cpi, static void temporal_filter_iterate_c(VP10_COMP *cpi, YV12_BUFFER_CONFIG **frames, - int frame_count, - int alt_ref_index, + int frame_count, int alt_ref_index, int strength, struct scale_factors *scale) { int byte; @@ -356,17 +304,17 @@ static void temporal_filter_iterate_c(VP10_COMP *cpi, YV12_BUFFER_CONFIG *f = frames[alt_ref_index]; uint8_t *dst1, *dst2; #if CONFIG_VP9_HIGHBITDEPTH - DECLARE_ALIGNED(16, uint16_t, predictor16[16 * 16 * 3]); - DECLARE_ALIGNED(16, uint8_t, predictor8[16 * 16 * 3]); + DECLARE_ALIGNED(16, uint16_t, predictor16[16 * 16 * 3]); + DECLARE_ALIGNED(16, uint8_t, predictor8[16 * 16 * 3]); uint8_t *predictor; #else - DECLARE_ALIGNED(16, uint8_t, predictor[16 * 16 * 3]); + DECLARE_ALIGNED(16, uint8_t, predictor[16 * 16 * 3]); #endif const int mb_uv_height = 16 >> mbd->plane[1].subsampling_y; - const int mb_uv_width = 16 >> mbd->plane[1].subsampling_x; + const int mb_uv_width = 16 >> mbd->plane[1].subsampling_x; // Save input state - uint8_t* input_buffer[MAX_MB_PLANE]; + uint8_t *input_buffer[MAX_MB_PLANE]; int i; #if CONFIG_VP9_HIGHBITDEPTH if (mbd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { @@ -376,8 +324,7 @@ static void temporal_filter_iterate_c(VP10_COMP *cpi, } #endif - for (i = 0; i < MAX_MB_PLANE; i++) - input_buffer[i] = mbd->plane[i].pre[0].buf; + for (i = 0; i < MAX_MB_PLANE; i++) input_buffer[i] = mbd->plane[i].pre[0].buf; for (mb_row = 0; mb_row < mb_rows; mb_row++) { // Source frames are extended to 16 pixels. This is different than @@ -392,8 +339,8 @@ static void temporal_filter_iterate_c(VP10_COMP *cpi, // To keep the mv in play for both Y and UV planes the max that it // can be on a border is therefore 16 - (2*VPX_INTERP_EXTEND+1). cpi->td.mb.mv_row_min = -((mb_row * 16) + (17 - 2 * VPX_INTERP_EXTEND)); - cpi->td.mb.mv_row_max = ((mb_rows - 1 - mb_row) * 16) - + (17 - 2 * VPX_INTERP_EXTEND); + cpi->td.mb.mv_row_max = + ((mb_rows - 1 - mb_row) * 16) + (17 - 2 * VPX_INTERP_EXTEND); for (mb_col = 0; mb_col < mb_cols; mb_col++) { int i, j, k; @@ -403,15 +350,14 @@ static void temporal_filter_iterate_c(VP10_COMP *cpi, memset(count, 0, 16 * 16 * 3 * sizeof(count[0])); cpi->td.mb.mv_col_min = -((mb_col * 16) + (17 - 2 * VPX_INTERP_EXTEND)); - cpi->td.mb.mv_col_max = ((mb_cols - 1 - mb_col) * 16) - + (17 - 2 * VPX_INTERP_EXTEND); + cpi->td.mb.mv_col_max = + ((mb_cols - 1 - mb_col) * 16) + (17 - 2 * VPX_INTERP_EXTEND); for (frame = 0; frame < frame_count; frame++) { - const int thresh_low = 10000; + const int thresh_low = 10000; const int thresh_high = 20000; - if (frames[frame] == NULL) - continue; + if (frames[frame] == NULL) continue; mbd->mi[0]->bmi[0].as_mv[0].as_mv.row = 0; mbd->mi[0]->bmi[0].as_mv[0].as_mv.col = 0; @@ -420,84 +366,68 @@ static void temporal_filter_iterate_c(VP10_COMP *cpi, filter_weight = 2; } else { // Find best match in this frame by MC - int err = temporal_filter_find_matching_mb_c(cpi, - frames[alt_ref_index]->y_buffer + mb_y_offset, - frames[frame]->y_buffer + mb_y_offset, - frames[frame]->y_stride); + int err = temporal_filter_find_matching_mb_c( + cpi, frames[alt_ref_index]->y_buffer + mb_y_offset, + frames[frame]->y_buffer + mb_y_offset, frames[frame]->y_stride); // Assign higher weight to matching MB if it's error // score is lower. If not applying MC default behavior // is to weight all MBs equal. - filter_weight = err < thresh_low - ? 2 : err < thresh_high ? 1 : 0; + filter_weight = err < thresh_low ? 2 : err < thresh_high ? 1 : 0; } if (filter_weight != 0) { // Construct the predictors - temporal_filter_predictors_mb_c(mbd, - frames[frame]->y_buffer + mb_y_offset, + temporal_filter_predictors_mb_c( + mbd, frames[frame]->y_buffer + mb_y_offset, frames[frame]->u_buffer + mb_uv_offset, - frames[frame]->v_buffer + mb_uv_offset, - frames[frame]->y_stride, - mb_uv_width, mb_uv_height, - mbd->mi[0]->bmi[0].as_mv[0].as_mv.row, - mbd->mi[0]->bmi[0].as_mv[0].as_mv.col, - predictor, scale, + frames[frame]->v_buffer + mb_uv_offset, frames[frame]->y_stride, + mb_uv_width, mb_uv_height, mbd->mi[0]->bmi[0].as_mv[0].as_mv.row, + mbd->mi[0]->bmi[0].as_mv[0].as_mv.col, predictor, scale, mb_col * 16, mb_row * 16); #if CONFIG_VP9_HIGHBITDEPTH if (mbd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { int adj_strength = strength + 2 * (mbd->bd - 8); // Apply the filter (YUV) - vp10_highbd_temporal_filter_apply(f->y_buffer + mb_y_offset, - f->y_stride, - predictor, 16, 16, adj_strength, - filter_weight, - accumulator, count); - vp10_highbd_temporal_filter_apply(f->u_buffer + mb_uv_offset, - f->uv_stride, predictor + 256, - mb_uv_width, mb_uv_height, - adj_strength, - filter_weight, accumulator + 256, - count + 256); - vp10_highbd_temporal_filter_apply(f->v_buffer + mb_uv_offset, - f->uv_stride, predictor + 512, - mb_uv_width, mb_uv_height, - adj_strength, filter_weight, - accumulator + 512, count + 512); + vp10_highbd_temporal_filter_apply( + f->y_buffer + mb_y_offset, f->y_stride, predictor, 16, 16, + adj_strength, filter_weight, accumulator, count); + vp10_highbd_temporal_filter_apply( + f->u_buffer + mb_uv_offset, f->uv_stride, predictor + 256, + mb_uv_width, mb_uv_height, adj_strength, filter_weight, + accumulator + 256, count + 256); + vp10_highbd_temporal_filter_apply( + f->v_buffer + mb_uv_offset, f->uv_stride, predictor + 512, + mb_uv_width, mb_uv_height, adj_strength, filter_weight, + accumulator + 512, count + 512); } else { // Apply the filter (YUV) vp10_temporal_filter_apply_c(f->y_buffer + mb_y_offset, f->y_stride, - predictor, 16, 16, - strength, filter_weight, - accumulator, count); - vp10_temporal_filter_apply_c(f->u_buffer + mb_uv_offset, - f->uv_stride, predictor + 256, - mb_uv_width, mb_uv_height, strength, - filter_weight, accumulator + 256, - count + 256); - vp10_temporal_filter_apply_c(f->v_buffer + mb_uv_offset, - f->uv_stride, predictor + 512, - mb_uv_width, mb_uv_height, strength, - filter_weight, accumulator + 512, - count + 512); + predictor, 16, 16, strength, + filter_weight, accumulator, count); + vp10_temporal_filter_apply_c( + f->u_buffer + mb_uv_offset, f->uv_stride, predictor + 256, + mb_uv_width, mb_uv_height, strength, filter_weight, + accumulator + 256, count + 256); + vp10_temporal_filter_apply_c( + f->v_buffer + mb_uv_offset, f->uv_stride, predictor + 512, + mb_uv_width, mb_uv_height, strength, filter_weight, + accumulator + 512, count + 512); } #else // Apply the filter (YUV) vp10_temporal_filter_apply_c(f->y_buffer + mb_y_offset, f->y_stride, - predictor, 16, 16, - strength, filter_weight, - accumulator, count); + predictor, 16, 16, strength, + filter_weight, accumulator, count); vp10_temporal_filter_apply_c(f->u_buffer + mb_uv_offset, f->uv_stride, - predictor + 256, - mb_uv_width, mb_uv_height, strength, - filter_weight, accumulator + 256, - count + 256); + predictor + 256, mb_uv_width, + mb_uv_height, strength, filter_weight, + accumulator + 256, count + 256); vp10_temporal_filter_apply_c(f->v_buffer + mb_uv_offset, f->uv_stride, - predictor + 512, - mb_uv_width, mb_uv_height, strength, - filter_weight, accumulator + 512, - count + 512); + predictor + 512, mb_uv_width, + mb_uv_height, strength, filter_weight, + accumulator + 512, count + 512); #endif // CONFIG_VP9_HIGHBITDEPTH } } @@ -652,13 +582,11 @@ static void temporal_filter_iterate_c(VP10_COMP *cpi, } // Restore input state - for (i = 0; i < MAX_MB_PLANE; i++) - mbd->plane[i].pre[0].buf = input_buffer[i]; + for (i = 0; i < MAX_MB_PLANE; i++) mbd->plane[i].pre[0].buf = input_buffer[i]; } // Apply buffer limits and context specific adjustments to arnr filter. -static void adjust_arnr_filter(VP10_COMP *cpi, - int distance, int group_boost, +static void adjust_arnr_filter(VP10_COMP *cpi, int distance, int group_boost, int *arnr_frames, int *arnr_strength) { const VP10EncoderConfig *const oxcf = &cpi->oxcf; const int frames_after_arf = @@ -668,34 +596,30 @@ static void adjust_arnr_filter(VP10_COMP *cpi, int q, frames, strength; // Define the forward and backwards filter limits for this arnr group. - if (frames_fwd > frames_after_arf) - frames_fwd = frames_after_arf; - if (frames_fwd > distance) - frames_fwd = distance; + if (frames_fwd > frames_after_arf) frames_fwd = frames_after_arf; + if (frames_fwd > distance) frames_fwd = distance; frames_bwd = frames_fwd; // For even length filter there is one more frame backward // than forward: e.g. len=6 ==> bbbAff, len=7 ==> bbbAfff. - if (frames_bwd < distance) - frames_bwd += (oxcf->arnr_max_frames + 1) & 0x1; + if (frames_bwd < distance) frames_bwd += (oxcf->arnr_max_frames + 1) & 0x1; // Set the baseline active filter size. frames = frames_bwd + 1 + frames_fwd; // Adjust the strength based on active max q. if (cpi->common.current_video_frame > 1) - q = ((int)vp10_convert_qindex_to_q( - cpi->rc.avg_frame_qindex[INTER_FRAME], cpi->common.bit_depth)); + q = ((int)vp10_convert_qindex_to_q(cpi->rc.avg_frame_qindex[INTER_FRAME], + cpi->common.bit_depth)); else - q = ((int)vp10_convert_qindex_to_q( - cpi->rc.avg_frame_qindex[KEY_FRAME], cpi->common.bit_depth)); + q = ((int)vp10_convert_qindex_to_q(cpi->rc.avg_frame_qindex[KEY_FRAME], + cpi->common.bit_depth)); if (q > 16) { strength = oxcf->arnr_strength; } else { strength = oxcf->arnr_strength - ((16 - q) / 2); - if (strength < 0) - strength = 0; + if (strength < 0) strength = 0; } // Adjust number of frames in filter and strength based on gf boost level. @@ -729,7 +653,7 @@ void vp10_temporal_filter(VP10_COMP *cpi, int distance) { int frames_to_blur_backward; int frames_to_blur_forward; struct scale_factors sf; - YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS] = {NULL}; + YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS] = { NULL }; // Apply context specific adjustments to the arnr filter parameters. adjust_arnr_filter(cpi, distance, rc->gfu_boost, &frames_to_blur, &strength); @@ -746,28 +670,24 @@ void vp10_temporal_filter(VP10_COMP *cpi, int distance) { // Setup frame pointers, NULL indicates frame not included in filter. for (frame = 0; frame < frames_to_blur; ++frame) { const int which_buffer = start_frame - frame; - struct lookahead_entry *buf = vp10_lookahead_peek(cpi->lookahead, - which_buffer); + struct lookahead_entry *buf = + vp10_lookahead_peek(cpi->lookahead, which_buffer); frames[frames_to_blur - 1 - frame] = &buf->img; } if (frames_to_blur > 0) { - // Setup scaling factors. Scaling on each of the arnr frames is not - // supported. - // ARF is produced at the native frame size and resized when coded. +// Setup scaling factors. Scaling on each of the arnr frames is not +// supported. +// ARF is produced at the native frame size and resized when coded. #if CONFIG_VP9_HIGHBITDEPTH - vp10_setup_scale_factors_for_frame(&sf, - frames[0]->y_crop_width, - frames[0]->y_crop_height, - frames[0]->y_crop_width, - frames[0]->y_crop_height, - cpi->common.use_highbitdepth); + vp10_setup_scale_factors_for_frame( + &sf, frames[0]->y_crop_width, frames[0]->y_crop_height, + frames[0]->y_crop_width, frames[0]->y_crop_height, + cpi->common.use_highbitdepth); #else - vp10_setup_scale_factors_for_frame(&sf, - frames[0]->y_crop_width, - frames[0]->y_crop_height, - frames[0]->y_crop_width, - frames[0]->y_crop_height); + vp10_setup_scale_factors_for_frame( + &sf, frames[0]->y_crop_width, frames[0]->y_crop_height, + frames[0]->y_crop_width, frames[0]->y_crop_height); #endif // CONFIG_VP9_HIGHBITDEPTH } diff --git a/vp10/encoder/tokenize.c b/vp10/encoder/tokenize.c index 734ae8be0..c79d84e64 100644 --- a/vp10/encoder/tokenize.c +++ b/vp10/encoder/tokenize.c @@ -25,62 +25,54 @@ #include "vp10/encoder/tokenize.h" static const TOKENVALUE dct_cat_lt_10_value_tokens[] = { - {9, 63}, {9, 61}, {9, 59}, {9, 57}, {9, 55}, {9, 53}, {9, 51}, {9, 49}, - {9, 47}, {9, 45}, {9, 43}, {9, 41}, {9, 39}, {9, 37}, {9, 35}, {9, 33}, - {9, 31}, {9, 29}, {9, 27}, {9, 25}, {9, 23}, {9, 21}, {9, 19}, {9, 17}, - {9, 15}, {9, 13}, {9, 11}, {9, 9}, {9, 7}, {9, 5}, {9, 3}, {9, 1}, - {8, 31}, {8, 29}, {8, 27}, {8, 25}, {8, 23}, {8, 21}, - {8, 19}, {8, 17}, {8, 15}, {8, 13}, {8, 11}, {8, 9}, - {8, 7}, {8, 5}, {8, 3}, {8, 1}, - {7, 15}, {7, 13}, {7, 11}, {7, 9}, {7, 7}, {7, 5}, {7, 3}, {7, 1}, - {6, 7}, {6, 5}, {6, 3}, {6, 1}, {5, 3}, {5, 1}, - {4, 1}, {3, 1}, {2, 1}, {1, 1}, {0, 0}, - {1, 0}, {2, 0}, {3, 0}, {4, 0}, - {5, 0}, {5, 2}, {6, 0}, {6, 2}, {6, 4}, {6, 6}, - {7, 0}, {7, 2}, {7, 4}, {7, 6}, {7, 8}, {7, 10}, {7, 12}, {7, 14}, - {8, 0}, {8, 2}, {8, 4}, {8, 6}, {8, 8}, {8, 10}, {8, 12}, - {8, 14}, {8, 16}, {8, 18}, {8, 20}, {8, 22}, {8, 24}, - {8, 26}, {8, 28}, {8, 30}, {9, 0}, {9, 2}, - {9, 4}, {9, 6}, {9, 8}, {9, 10}, {9, 12}, {9, 14}, {9, 16}, - {9, 18}, {9, 20}, {9, 22}, {9, 24}, {9, 26}, {9, 28}, - {9, 30}, {9, 32}, {9, 34}, {9, 36}, {9, 38}, {9, 40}, - {9, 42}, {9, 44}, {9, 46}, {9, 48}, {9, 50}, {9, 52}, - {9, 54}, {9, 56}, {9, 58}, {9, 60}, {9, 62} + { 9, 63 }, { 9, 61 }, { 9, 59 }, { 9, 57 }, { 9, 55 }, { 9, 53 }, { 9, 51 }, + { 9, 49 }, { 9, 47 }, { 9, 45 }, { 9, 43 }, { 9, 41 }, { 9, 39 }, { 9, 37 }, + { 9, 35 }, { 9, 33 }, { 9, 31 }, { 9, 29 }, { 9, 27 }, { 9, 25 }, { 9, 23 }, + { 9, 21 }, { 9, 19 }, { 9, 17 }, { 9, 15 }, { 9, 13 }, { 9, 11 }, { 9, 9 }, + { 9, 7 }, { 9, 5 }, { 9, 3 }, { 9, 1 }, { 8, 31 }, { 8, 29 }, { 8, 27 }, + { 8, 25 }, { 8, 23 }, { 8, 21 }, { 8, 19 }, { 8, 17 }, { 8, 15 }, { 8, 13 }, + { 8, 11 }, { 8, 9 }, { 8, 7 }, { 8, 5 }, { 8, 3 }, { 8, 1 }, { 7, 15 }, + { 7, 13 }, { 7, 11 }, { 7, 9 }, { 7, 7 }, { 7, 5 }, { 7, 3 }, { 7, 1 }, + { 6, 7 }, { 6, 5 }, { 6, 3 }, { 6, 1 }, { 5, 3 }, { 5, 1 }, { 4, 1 }, + { 3, 1 }, { 2, 1 }, { 1, 1 }, { 0, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 }, + { 4, 0 }, { 5, 0 }, { 5, 2 }, { 6, 0 }, { 6, 2 }, { 6, 4 }, { 6, 6 }, + { 7, 0 }, { 7, 2 }, { 7, 4 }, { 7, 6 }, { 7, 8 }, { 7, 10 }, { 7, 12 }, + { 7, 14 }, { 8, 0 }, { 8, 2 }, { 8, 4 }, { 8, 6 }, { 8, 8 }, { 8, 10 }, + { 8, 12 }, { 8, 14 }, { 8, 16 }, { 8, 18 }, { 8, 20 }, { 8, 22 }, { 8, 24 }, + { 8, 26 }, { 8, 28 }, { 8, 30 }, { 9, 0 }, { 9, 2 }, { 9, 4 }, { 9, 6 }, + { 9, 8 }, { 9, 10 }, { 9, 12 }, { 9, 14 }, { 9, 16 }, { 9, 18 }, { 9, 20 }, + { 9, 22 }, { 9, 24 }, { 9, 26 }, { 9, 28 }, { 9, 30 }, { 9, 32 }, { 9, 34 }, + { 9, 36 }, { 9, 38 }, { 9, 40 }, { 9, 42 }, { 9, 44 }, { 9, 46 }, { 9, 48 }, + { 9, 50 }, { 9, 52 }, { 9, 54 }, { 9, 56 }, { 9, 58 }, { 9, 60 }, { 9, 62 } }; -const TOKENVALUE *vp10_dct_cat_lt_10_value_tokens = dct_cat_lt_10_value_tokens + - (sizeof(dct_cat_lt_10_value_tokens) / sizeof(*dct_cat_lt_10_value_tokens)) - / 2; +const TOKENVALUE *vp10_dct_cat_lt_10_value_tokens = + dct_cat_lt_10_value_tokens + + (sizeof(dct_cat_lt_10_value_tokens) / sizeof(*dct_cat_lt_10_value_tokens)) / + 2; // The corresponding costs of the extrabits for the tokens in the above table // are stored in the table below. The values are obtained from looking up the // entry for the specified extrabits in the table corresponding to the token // (as defined in cost element vp10_extra_bits) // e.g. {9, 63} maps to cat5_cost[63 >> 1], {1, 1} maps to sign_cost[1 >> 1] static const int dct_cat_lt_10_value_cost[] = { - 3773, 3750, 3704, 3681, 3623, 3600, 3554, 3531, - 3432, 3409, 3363, 3340, 3282, 3259, 3213, 3190, - 3136, 3113, 3067, 3044, 2986, 2963, 2917, 2894, - 2795, 2772, 2726, 2703, 2645, 2622, 2576, 2553, - 3197, 3116, 3058, 2977, 2881, 2800, - 2742, 2661, 2615, 2534, 2476, 2395, - 2299, 2218, 2160, 2079, - 2566, 2427, 2334, 2195, 2023, 1884, 1791, 1652, - 1893, 1696, 1453, 1256, 1229, 864, - 512, 512, 512, 512, 0, - 512, 512, 512, 512, - 864, 1229, 1256, 1453, 1696, 1893, - 1652, 1791, 1884, 2023, 2195, 2334, 2427, 2566, - 2079, 2160, 2218, 2299, 2395, 2476, 2534, 2615, - 2661, 2742, 2800, 2881, 2977, 3058, 3116, 3197, - 2553, 2576, 2622, 2645, 2703, 2726, 2772, 2795, - 2894, 2917, 2963, 2986, 3044, 3067, 3113, 3136, - 3190, 3213, 3259, 3282, 3340, 3363, 3409, 3432, - 3531, 3554, 3600, 3623, 3681, 3704, 3750, 3773, + 3773, 3750, 3704, 3681, 3623, 3600, 3554, 3531, 3432, 3409, 3363, 3340, 3282, + 3259, 3213, 3190, 3136, 3113, 3067, 3044, 2986, 2963, 2917, 2894, 2795, 2772, + 2726, 2703, 2645, 2622, 2576, 2553, 3197, 3116, 3058, 2977, 2881, 2800, 2742, + 2661, 2615, 2534, 2476, 2395, 2299, 2218, 2160, 2079, 2566, 2427, 2334, 2195, + 2023, 1884, 1791, 1652, 1893, 1696, 1453, 1256, 1229, 864, 512, 512, 512, + 512, 0, 512, 512, 512, 512, 864, 1229, 1256, 1453, 1696, 1893, 1652, + 1791, 1884, 2023, 2195, 2334, 2427, 2566, 2079, 2160, 2218, 2299, 2395, 2476, + 2534, 2615, 2661, 2742, 2800, 2881, 2977, 3058, 3116, 3197, 2553, 2576, 2622, + 2645, 2703, 2726, 2772, 2795, 2894, 2917, 2963, 2986, 3044, 3067, 3113, 3136, + 3190, 3213, 3259, 3282, 3340, 3363, 3409, 3432, 3531, 3554, 3600, 3623, 3681, + 3704, 3750, 3773, }; -const int *vp10_dct_cat_lt_10_value_cost = dct_cat_lt_10_value_cost + - (sizeof(dct_cat_lt_10_value_cost) / sizeof(*dct_cat_lt_10_value_cost)) - / 2; +const int *vp10_dct_cat_lt_10_value_cost = + dct_cat_lt_10_value_cost + + (sizeof(dct_cat_lt_10_value_cost) / sizeof(*dct_cat_lt_10_value_cost)) / 2; // Array indices are identical to previously-existing CONTEXT_NODE indices +/* clang-format off */ const vpx_tree_index vp10_coef_tree[TREE_SIZE(ENTROPY_TOKENS)] = { -EOB_TOKEN, 2, // 0 = EOB -ZERO_TOKEN, 4, // 1 = ZERO @@ -94,251 +86,258 @@ const vpx_tree_index vp10_coef_tree[TREE_SIZE(ENTROPY_TOKENS)] = { -CATEGORY3_TOKEN, -CATEGORY4_TOKEN, // 9 = CAT_THREE -CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 10 = CAT_FIVE }; +/* clang-format on */ -static const vpx_tree_index cat1[2] = {0, 0}; -static const vpx_tree_index cat2[4] = {2, 2, 0, 0}; -static const vpx_tree_index cat3[6] = {2, 2, 4, 4, 0, 0}; -static const vpx_tree_index cat4[8] = {2, 2, 4, 4, 6, 6, 0, 0}; -static const vpx_tree_index cat5[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0}; -static const vpx_tree_index cat6[28] = {2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, - 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 0, 0}; +static const vpx_tree_index cat1[2] = { 0, 0 }; +static const vpx_tree_index cat2[4] = { 2, 2, 0, 0 }; +static const vpx_tree_index cat3[6] = { 2, 2, 4, 4, 0, 0 }; +static const vpx_tree_index cat4[8] = { 2, 2, 4, 4, 6, 6, 0, 0 }; +static const vpx_tree_index cat5[10] = { 2, 2, 4, 4, 6, 6, 8, 8, 0, 0 }; +static const vpx_tree_index cat6[28] = { 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, + 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, + 22, 22, 24, 24, 26, 26, 0, 0 }; -static const int16_t zero_cost[] = {0}; -static const int16_t sign_cost[1] = {512}; -static const int16_t cat1_cost[1 << 1] = {864, 1229}; -static const int16_t cat2_cost[1 << 2] = {1256, 1453, 1696, 1893}; -static const int16_t cat3_cost[1 << 3] = {1652, 1791, 1884, 2023, - 2195, 2334, 2427, 2566}; -static const int16_t cat4_cost[1 << 4] = {2079, 2160, 2218, 2299, 2395, 2476, - 2534, 2615, 2661, 2742, 2800, 2881, - 2977, 3058, 3116, 3197}; +static const int16_t zero_cost[] = { 0 }; +static const int16_t sign_cost[1] = { 512 }; +static const int16_t cat1_cost[1 << 1] = { 864, 1229 }; +static const int16_t cat2_cost[1 << 2] = { 1256, 1453, 1696, 1893 }; +static const int16_t cat3_cost[1 << 3] = { 1652, 1791, 1884, 2023, + 2195, 2334, 2427, 2566 }; +static const int16_t cat4_cost[1 << 4] = { 2079, 2160, 2218, 2299, 2395, 2476, + 2534, 2615, 2661, 2742, 2800, 2881, + 2977, 3058, 3116, 3197 }; static const int16_t cat5_cost[1 << 5] = { - 2553, 2576, 2622, 2645, 2703, 2726, 2772, 2795, 2894, 2917, 2963, - 2986, 3044, 3067, 3113, 3136, 3190, 3213, 3259, 3282, 3340, 3363, - 3409, 3432, 3531, 3554, 3600, 3623, 3681, 3704, 3750, 3773}; + 2553, 2576, 2622, 2645, 2703, 2726, 2772, 2795, 2894, 2917, 2963, + 2986, 3044, 3067, 3113, 3136, 3190, 3213, 3259, 3282, 3340, 3363, + 3409, 3432, 3531, 3554, 3600, 3623, 3681, 3704, 3750, 3773 +}; const int16_t vp10_cat6_low_cost[256] = { - 3378, 3390, 3401, 3413, 3435, 3447, 3458, 3470, 3517, 3529, 3540, 3552, - 3574, 3586, 3597, 3609, 3671, 3683, 3694, 3706, 3728, 3740, 3751, 3763, - 3810, 3822, 3833, 3845, 3867, 3879, 3890, 3902, 3973, 3985, 3996, 4008, - 4030, 4042, 4053, 4065, 4112, 4124, 4135, 4147, 4169, 4181, 4192, 4204, - 4266, 4278, 4289, 4301, 4323, 4335, 4346, 4358, 4405, 4417, 4428, 4440, - 4462, 4474, 4485, 4497, 4253, 4265, 4276, 4288, 4310, 4322, 4333, 4345, - 4392, 4404, 4415, 4427, 4449, 4461, 4472, 4484, 4546, 4558, 4569, 4581, - 4603, 4615, 4626, 4638, 4685, 4697, 4708, 4720, 4742, 4754, 4765, 4777, - 4848, 4860, 4871, 4883, 4905, 4917, 4928, 4940, 4987, 4999, 5010, 5022, - 5044, 5056, 5067, 5079, 5141, 5153, 5164, 5176, 5198, 5210, 5221, 5233, - 5280, 5292, 5303, 5315, 5337, 5349, 5360, 5372, 4988, 5000, 5011, 5023, - 5045, 5057, 5068, 5080, 5127, 5139, 5150, 5162, 5184, 5196, 5207, 5219, - 5281, 5293, 5304, 5316, 5338, 5350, 5361, 5373, 5420, 5432, 5443, 5455, - 5477, 5489, 5500, 5512, 5583, 5595, 5606, 5618, 5640, 5652, 5663, 5675, - 5722, 5734, 5745, 5757, 5779, 5791, 5802, 5814, 5876, 5888, 5899, 5911, - 5933, 5945, 5956, 5968, 6015, 6027, 6038, 6050, 6072, 6084, 6095, 6107, - 5863, 5875, 5886, 5898, 5920, 5932, 5943, 5955, 6002, 6014, 6025, 6037, - 6059, 6071, 6082, 6094, 6156, 6168, 6179, 6191, 6213, 6225, 6236, 6248, - 6295, 6307, 6318, 6330, 6352, 6364, 6375, 6387, 6458, 6470, 6481, 6493, - 6515, 6527, 6538, 6550, 6597, 6609, 6620, 6632, 6654, 6666, 6677, 6689, - 6751, 6763, 6774, 6786, 6808, 6820, 6831, 6843, 6890, 6902, 6913, 6925, - 6947, 6959, 6970, 6982}; + 3378, 3390, 3401, 3413, 3435, 3447, 3458, 3470, 3517, 3529, 3540, 3552, 3574, + 3586, 3597, 3609, 3671, 3683, 3694, 3706, 3728, 3740, 3751, 3763, 3810, 3822, + 3833, 3845, 3867, 3879, 3890, 3902, 3973, 3985, 3996, 4008, 4030, 4042, 4053, + 4065, 4112, 4124, 4135, 4147, 4169, 4181, 4192, 4204, 4266, 4278, 4289, 4301, + 4323, 4335, 4346, 4358, 4405, 4417, 4428, 4440, 4462, 4474, 4485, 4497, 4253, + 4265, 4276, 4288, 4310, 4322, 4333, 4345, 4392, 4404, 4415, 4427, 4449, 4461, + 4472, 4484, 4546, 4558, 4569, 4581, 4603, 4615, 4626, 4638, 4685, 4697, 4708, + 4720, 4742, 4754, 4765, 4777, 4848, 4860, 4871, 4883, 4905, 4917, 4928, 4940, + 4987, 4999, 5010, 5022, 5044, 5056, 5067, 5079, 5141, 5153, 5164, 5176, 5198, + 5210, 5221, 5233, 5280, 5292, 5303, 5315, 5337, 5349, 5360, 5372, 4988, 5000, + 5011, 5023, 5045, 5057, 5068, 5080, 5127, 5139, 5150, 5162, 5184, 5196, 5207, + 5219, 5281, 5293, 5304, 5316, 5338, 5350, 5361, 5373, 5420, 5432, 5443, 5455, + 5477, 5489, 5500, 5512, 5583, 5595, 5606, 5618, 5640, 5652, 5663, 5675, 5722, + 5734, 5745, 5757, 5779, 5791, 5802, 5814, 5876, 5888, 5899, 5911, 5933, 5945, + 5956, 5968, 6015, 6027, 6038, 6050, 6072, 6084, 6095, 6107, 5863, 5875, 5886, + 5898, 5920, 5932, 5943, 5955, 6002, 6014, 6025, 6037, 6059, 6071, 6082, 6094, + 6156, 6168, 6179, 6191, 6213, 6225, 6236, 6248, 6295, 6307, 6318, 6330, 6352, + 6364, 6375, 6387, 6458, 6470, 6481, 6493, 6515, 6527, 6538, 6550, 6597, 6609, + 6620, 6632, 6654, 6666, 6677, 6689, 6751, 6763, 6774, 6786, 6808, 6820, 6831, + 6843, 6890, 6902, 6913, 6925, 6947, 6959, 6970, 6982 +}; const int vp10_cat6_high_cost[64] = { - 88, 2251, 2727, 4890, 3148, 5311, 5787, 7950, 3666, 5829, 6305, - 8468, 6726, 8889, 9365, 11528, 3666, 5829, 6305, 8468, 6726, 8889, - 9365, 11528, 7244, 9407, 9883, 12046, 10304, 12467, 12943, 15106, 3666, - 5829, 6305, 8468, 6726, 8889, 9365, 11528, 7244, 9407, 9883, 12046, - 10304, 12467, 12943, 15106, 7244, 9407, 9883, 12046, 10304, 12467, 12943, - 15106, 10822, 12985, 13461, 15624, 13882, 16045, 16521, 18684}; + 88, 2251, 2727, 4890, 3148, 5311, 5787, 7950, 3666, 5829, 6305, + 8468, 6726, 8889, 9365, 11528, 3666, 5829, 6305, 8468, 6726, 8889, + 9365, 11528, 7244, 9407, 9883, 12046, 10304, 12467, 12943, 15106, 3666, + 5829, 6305, 8468, 6726, 8889, 9365, 11528, 7244, 9407, 9883, 12046, + 10304, 12467, 12943, 15106, 7244, 9407, 9883, 12046, 10304, 12467, 12943, + 15106, 10822, 12985, 13461, 15624, 13882, 16045, 16521, 18684 +}; #if CONFIG_VP9_HIGHBITDEPTH const int vp10_cat6_high10_high_cost[256] = { - 94, 2257, 2733, 4896, 3154, 5317, 5793, 7956, 3672, 5835, 6311, - 8474, 6732, 8895, 9371, 11534, 3672, 5835, 6311, 8474, 6732, 8895, - 9371, 11534, 7250, 9413, 9889, 12052, 10310, 12473, 12949, 15112, 3672, - 5835, 6311, 8474, 6732, 8895, 9371, 11534, 7250, 9413, 9889, 12052, - 10310, 12473, 12949, 15112, 7250, 9413, 9889, 12052, 10310, 12473, 12949, - 15112, 10828, 12991, 13467, 15630, 13888, 16051, 16527, 18690, 4187, 6350, - 6826, 8989, 7247, 9410, 9886, 12049, 7765, 9928, 10404, 12567, 10825, - 12988, 13464, 15627, 7765, 9928, 10404, 12567, 10825, 12988, 13464, 15627, - 11343, 13506, 13982, 16145, 14403, 16566, 17042, 19205, 7765, 9928, 10404, - 12567, 10825, 12988, 13464, 15627, 11343, 13506, 13982, 16145, 14403, 16566, - 17042, 19205, 11343, 13506, 13982, 16145, 14403, 16566, 17042, 19205, 14921, - 17084, 17560, 19723, 17981, 20144, 20620, 22783, 4187, 6350, 6826, 8989, - 7247, 9410, 9886, 12049, 7765, 9928, 10404, 12567, 10825, 12988, 13464, - 15627, 7765, 9928, 10404, 12567, 10825, 12988, 13464, 15627, 11343, 13506, - 13982, 16145, 14403, 16566, 17042, 19205, 7765, 9928, 10404, 12567, 10825, - 12988, 13464, 15627, 11343, 13506, 13982, 16145, 14403, 16566, 17042, 19205, - 11343, 13506, 13982, 16145, 14403, 16566, 17042, 19205, 14921, 17084, 17560, - 19723, 17981, 20144, 20620, 22783, 8280, 10443, 10919, 13082, 11340, 13503, - 13979, 16142, 11858, 14021, 14497, 16660, 14918, 17081, 17557, 19720, 11858, - 14021, 14497, 16660, 14918, 17081, 17557, 19720, 15436, 17599, 18075, 20238, - 18496, 20659, 21135, 23298, 11858, 14021, 14497, 16660, 14918, 17081, 17557, - 19720, 15436, 17599, 18075, 20238, 18496, 20659, 21135, 23298, 15436, 17599, - 18075, 20238, 18496, 20659, 21135, 23298, 19014, 21177, 21653, 23816, 22074, - 24237, 24713, 26876}; + 94, 2257, 2733, 4896, 3154, 5317, 5793, 7956, 3672, 5835, 6311, + 8474, 6732, 8895, 9371, 11534, 3672, 5835, 6311, 8474, 6732, 8895, + 9371, 11534, 7250, 9413, 9889, 12052, 10310, 12473, 12949, 15112, 3672, + 5835, 6311, 8474, 6732, 8895, 9371, 11534, 7250, 9413, 9889, 12052, + 10310, 12473, 12949, 15112, 7250, 9413, 9889, 12052, 10310, 12473, 12949, + 15112, 10828, 12991, 13467, 15630, 13888, 16051, 16527, 18690, 4187, 6350, + 6826, 8989, 7247, 9410, 9886, 12049, 7765, 9928, 10404, 12567, 10825, + 12988, 13464, 15627, 7765, 9928, 10404, 12567, 10825, 12988, 13464, 15627, + 11343, 13506, 13982, 16145, 14403, 16566, 17042, 19205, 7765, 9928, 10404, + 12567, 10825, 12988, 13464, 15627, 11343, 13506, 13982, 16145, 14403, 16566, + 17042, 19205, 11343, 13506, 13982, 16145, 14403, 16566, 17042, 19205, 14921, + 17084, 17560, 19723, 17981, 20144, 20620, 22783, 4187, 6350, 6826, 8989, + 7247, 9410, 9886, 12049, 7765, 9928, 10404, 12567, 10825, 12988, 13464, + 15627, 7765, 9928, 10404, 12567, 10825, 12988, 13464, 15627, 11343, 13506, + 13982, 16145, 14403, 16566, 17042, 19205, 7765, 9928, 10404, 12567, 10825, + 12988, 13464, 15627, 11343, 13506, 13982, 16145, 14403, 16566, 17042, 19205, + 11343, 13506, 13982, 16145, 14403, 16566, 17042, 19205, 14921, 17084, 17560, + 19723, 17981, 20144, 20620, 22783, 8280, 10443, 10919, 13082, 11340, 13503, + 13979, 16142, 11858, 14021, 14497, 16660, 14918, 17081, 17557, 19720, 11858, + 14021, 14497, 16660, 14918, 17081, 17557, 19720, 15436, 17599, 18075, 20238, + 18496, 20659, 21135, 23298, 11858, 14021, 14497, 16660, 14918, 17081, 17557, + 19720, 15436, 17599, 18075, 20238, 18496, 20659, 21135, 23298, 15436, 17599, + 18075, 20238, 18496, 20659, 21135, 23298, 19014, 21177, 21653, 23816, 22074, + 24237, 24713, 26876 +}; const int vp10_cat6_high12_high_cost[1024] = { - 100, 2263, 2739, 4902, 3160, 5323, 5799, 7962, 3678, 5841, 6317, - 8480, 6738, 8901, 9377, 11540, 3678, 5841, 6317, 8480, 6738, 8901, - 9377, 11540, 7256, 9419, 9895, 12058, 10316, 12479, 12955, 15118, 3678, - 5841, 6317, 8480, 6738, 8901, 9377, 11540, 7256, 9419, 9895, 12058, - 10316, 12479, 12955, 15118, 7256, 9419, 9895, 12058, 10316, 12479, 12955, - 15118, 10834, 12997, 13473, 15636, 13894, 16057, 16533, 18696, 4193, 6356, - 6832, 8995, 7253, 9416, 9892, 12055, 7771, 9934, 10410, 12573, 10831, - 12994, 13470, 15633, 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, - 11349, 13512, 13988, 16151, 14409, 16572, 17048, 19211, 7771, 9934, 10410, - 12573, 10831, 12994, 13470, 15633, 11349, 13512, 13988, 16151, 14409, 16572, - 17048, 19211, 11349, 13512, 13988, 16151, 14409, 16572, 17048, 19211, 14927, - 17090, 17566, 19729, 17987, 20150, 20626, 22789, 4193, 6356, 6832, 8995, - 7253, 9416, 9892, 12055, 7771, 9934, 10410, 12573, 10831, 12994, 13470, - 15633, 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, 11349, 13512, - 13988, 16151, 14409, 16572, 17048, 19211, 7771, 9934, 10410, 12573, 10831, - 12994, 13470, 15633, 11349, 13512, 13988, 16151, 14409, 16572, 17048, 19211, - 11349, 13512, 13988, 16151, 14409, 16572, 17048, 19211, 14927, 17090, 17566, - 19729, 17987, 20150, 20626, 22789, 8286, 10449, 10925, 13088, 11346, 13509, - 13985, 16148, 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, 11864, - 14027, 14503, 16666, 14924, 17087, 17563, 19726, 15442, 17605, 18081, 20244, - 18502, 20665, 21141, 23304, 11864, 14027, 14503, 16666, 14924, 17087, 17563, - 19726, 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, 15442, 17605, - 18081, 20244, 18502, 20665, 21141, 23304, 19020, 21183, 21659, 23822, 22080, - 24243, 24719, 26882, 4193, 6356, 6832, 8995, 7253, 9416, 9892, 12055, - 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, 7771, 9934, 10410, - 12573, 10831, 12994, 13470, 15633, 11349, 13512, 13988, 16151, 14409, 16572, - 17048, 19211, 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, 11349, - 13512, 13988, 16151, 14409, 16572, 17048, 19211, 11349, 13512, 13988, 16151, - 14409, 16572, 17048, 19211, 14927, 17090, 17566, 19729, 17987, 20150, 20626, - 22789, 8286, 10449, 10925, 13088, 11346, 13509, 13985, 16148, 11864, 14027, - 14503, 16666, 14924, 17087, 17563, 19726, 11864, 14027, 14503, 16666, 14924, - 17087, 17563, 19726, 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, - 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, 15442, 17605, 18081, - 20244, 18502, 20665, 21141, 23304, 15442, 17605, 18081, 20244, 18502, 20665, - 21141, 23304, 19020, 21183, 21659, 23822, 22080, 24243, 24719, 26882, 8286, - 10449, 10925, 13088, 11346, 13509, 13985, 16148, 11864, 14027, 14503, 16666, - 14924, 17087, 17563, 19726, 11864, 14027, 14503, 16666, 14924, 17087, 17563, - 19726, 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, 11864, 14027, - 14503, 16666, 14924, 17087, 17563, 19726, 15442, 17605, 18081, 20244, 18502, - 20665, 21141, 23304, 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, - 19020, 21183, 21659, 23822, 22080, 24243, 24719, 26882, 12379, 14542, 15018, - 17181, 15439, 17602, 18078, 20241, 15957, 18120, 18596, 20759, 19017, 21180, - 21656, 23819, 15957, 18120, 18596, 20759, 19017, 21180, 21656, 23819, 19535, - 21698, 22174, 24337, 22595, 24758, 25234, 27397, 15957, 18120, 18596, 20759, - 19017, 21180, 21656, 23819, 19535, 21698, 22174, 24337, 22595, 24758, 25234, - 27397, 19535, 21698, 22174, 24337, 22595, 24758, 25234, 27397, 23113, 25276, - 25752, 27915, 26173, 28336, 28812, 30975, 4193, 6356, 6832, 8995, 7253, - 9416, 9892, 12055, 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, - 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, 11349, 13512, 13988, - 16151, 14409, 16572, 17048, 19211, 7771, 9934, 10410, 12573, 10831, 12994, - 13470, 15633, 11349, 13512, 13988, 16151, 14409, 16572, 17048, 19211, 11349, - 13512, 13988, 16151, 14409, 16572, 17048, 19211, 14927, 17090, 17566, 19729, - 17987, 20150, 20626, 22789, 8286, 10449, 10925, 13088, 11346, 13509, 13985, - 16148, 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, 11864, 14027, - 14503, 16666, 14924, 17087, 17563, 19726, 15442, 17605, 18081, 20244, 18502, - 20665, 21141, 23304, 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, - 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, 15442, 17605, 18081, - 20244, 18502, 20665, 21141, 23304, 19020, 21183, 21659, 23822, 22080, 24243, - 24719, 26882, 8286, 10449, 10925, 13088, 11346, 13509, 13985, 16148, 11864, - 14027, 14503, 16666, 14924, 17087, 17563, 19726, 11864, 14027, 14503, 16666, - 14924, 17087, 17563, 19726, 15442, 17605, 18081, 20244, 18502, 20665, 21141, - 23304, 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, 15442, 17605, - 18081, 20244, 18502, 20665, 21141, 23304, 15442, 17605, 18081, 20244, 18502, - 20665, 21141, 23304, 19020, 21183, 21659, 23822, 22080, 24243, 24719, 26882, - 12379, 14542, 15018, 17181, 15439, 17602, 18078, 20241, 15957, 18120, 18596, - 20759, 19017, 21180, 21656, 23819, 15957, 18120, 18596, 20759, 19017, 21180, - 21656, 23819, 19535, 21698, 22174, 24337, 22595, 24758, 25234, 27397, 15957, - 18120, 18596, 20759, 19017, 21180, 21656, 23819, 19535, 21698, 22174, 24337, - 22595, 24758, 25234, 27397, 19535, 21698, 22174, 24337, 22595, 24758, 25234, - 27397, 23113, 25276, 25752, 27915, 26173, 28336, 28812, 30975, 8286, 10449, - 10925, 13088, 11346, 13509, 13985, 16148, 11864, 14027, 14503, 16666, 14924, - 17087, 17563, 19726, 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, - 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, 11864, 14027, 14503, - 16666, 14924, 17087, 17563, 19726, 15442, 17605, 18081, 20244, 18502, 20665, - 21141, 23304, 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, 19020, - 21183, 21659, 23822, 22080, 24243, 24719, 26882, 12379, 14542, 15018, 17181, - 15439, 17602, 18078, 20241, 15957, 18120, 18596, 20759, 19017, 21180, 21656, - 23819, 15957, 18120, 18596, 20759, 19017, 21180, 21656, 23819, 19535, 21698, - 22174, 24337, 22595, 24758, 25234, 27397, 15957, 18120, 18596, 20759, 19017, - 21180, 21656, 23819, 19535, 21698, 22174, 24337, 22595, 24758, 25234, 27397, - 19535, 21698, 22174, 24337, 22595, 24758, 25234, 27397, 23113, 25276, 25752, - 27915, 26173, 28336, 28812, 30975, 12379, 14542, 15018, 17181, 15439, 17602, - 18078, 20241, 15957, 18120, 18596, 20759, 19017, 21180, 21656, 23819, 15957, - 18120, 18596, 20759, 19017, 21180, 21656, 23819, 19535, 21698, 22174, 24337, - 22595, 24758, 25234, 27397, 15957, 18120, 18596, 20759, 19017, 21180, 21656, - 23819, 19535, 21698, 22174, 24337, 22595, 24758, 25234, 27397, 19535, 21698, - 22174, 24337, 22595, 24758, 25234, 27397, 23113, 25276, 25752, 27915, 26173, - 28336, 28812, 30975, 16472, 18635, 19111, 21274, 19532, 21695, 22171, 24334, - 20050, 22213, 22689, 24852, 23110, 25273, 25749, 27912, 20050, 22213, 22689, - 24852, 23110, 25273, 25749, 27912, 23628, 25791, 26267, 28430, 26688, 28851, - 29327, 31490, 20050, 22213, 22689, 24852, 23110, 25273, 25749, 27912, 23628, - 25791, 26267, 28430, 26688, 28851, 29327, 31490, 23628, 25791, 26267, 28430, - 26688, 28851, 29327, 31490, 27206, 29369, 29845, 32008, 30266, 32429, 32905, - 35068}; + 100, 2263, 2739, 4902, 3160, 5323, 5799, 7962, 3678, 5841, 6317, + 8480, 6738, 8901, 9377, 11540, 3678, 5841, 6317, 8480, 6738, 8901, + 9377, 11540, 7256, 9419, 9895, 12058, 10316, 12479, 12955, 15118, 3678, + 5841, 6317, 8480, 6738, 8901, 9377, 11540, 7256, 9419, 9895, 12058, + 10316, 12479, 12955, 15118, 7256, 9419, 9895, 12058, 10316, 12479, 12955, + 15118, 10834, 12997, 13473, 15636, 13894, 16057, 16533, 18696, 4193, 6356, + 6832, 8995, 7253, 9416, 9892, 12055, 7771, 9934, 10410, 12573, 10831, + 12994, 13470, 15633, 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, + 11349, 13512, 13988, 16151, 14409, 16572, 17048, 19211, 7771, 9934, 10410, + 12573, 10831, 12994, 13470, 15633, 11349, 13512, 13988, 16151, 14409, 16572, + 17048, 19211, 11349, 13512, 13988, 16151, 14409, 16572, 17048, 19211, 14927, + 17090, 17566, 19729, 17987, 20150, 20626, 22789, 4193, 6356, 6832, 8995, + 7253, 9416, 9892, 12055, 7771, 9934, 10410, 12573, 10831, 12994, 13470, + 15633, 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, 11349, 13512, + 13988, 16151, 14409, 16572, 17048, 19211, 7771, 9934, 10410, 12573, 10831, + 12994, 13470, 15633, 11349, 13512, 13988, 16151, 14409, 16572, 17048, 19211, + 11349, 13512, 13988, 16151, 14409, 16572, 17048, 19211, 14927, 17090, 17566, + 19729, 17987, 20150, 20626, 22789, 8286, 10449, 10925, 13088, 11346, 13509, + 13985, 16148, 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, 11864, + 14027, 14503, 16666, 14924, 17087, 17563, 19726, 15442, 17605, 18081, 20244, + 18502, 20665, 21141, 23304, 11864, 14027, 14503, 16666, 14924, 17087, 17563, + 19726, 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, 15442, 17605, + 18081, 20244, 18502, 20665, 21141, 23304, 19020, 21183, 21659, 23822, 22080, + 24243, 24719, 26882, 4193, 6356, 6832, 8995, 7253, 9416, 9892, 12055, + 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, 7771, 9934, 10410, + 12573, 10831, 12994, 13470, 15633, 11349, 13512, 13988, 16151, 14409, 16572, + 17048, 19211, 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, 11349, + 13512, 13988, 16151, 14409, 16572, 17048, 19211, 11349, 13512, 13988, 16151, + 14409, 16572, 17048, 19211, 14927, 17090, 17566, 19729, 17987, 20150, 20626, + 22789, 8286, 10449, 10925, 13088, 11346, 13509, 13985, 16148, 11864, 14027, + 14503, 16666, 14924, 17087, 17563, 19726, 11864, 14027, 14503, 16666, 14924, + 17087, 17563, 19726, 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, + 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, 15442, 17605, 18081, + 20244, 18502, 20665, 21141, 23304, 15442, 17605, 18081, 20244, 18502, 20665, + 21141, 23304, 19020, 21183, 21659, 23822, 22080, 24243, 24719, 26882, 8286, + 10449, 10925, 13088, 11346, 13509, 13985, 16148, 11864, 14027, 14503, 16666, + 14924, 17087, 17563, 19726, 11864, 14027, 14503, 16666, 14924, 17087, 17563, + 19726, 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, 11864, 14027, + 14503, 16666, 14924, 17087, 17563, 19726, 15442, 17605, 18081, 20244, 18502, + 20665, 21141, 23304, 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, + 19020, 21183, 21659, 23822, 22080, 24243, 24719, 26882, 12379, 14542, 15018, + 17181, 15439, 17602, 18078, 20241, 15957, 18120, 18596, 20759, 19017, 21180, + 21656, 23819, 15957, 18120, 18596, 20759, 19017, 21180, 21656, 23819, 19535, + 21698, 22174, 24337, 22595, 24758, 25234, 27397, 15957, 18120, 18596, 20759, + 19017, 21180, 21656, 23819, 19535, 21698, 22174, 24337, 22595, 24758, 25234, + 27397, 19535, 21698, 22174, 24337, 22595, 24758, 25234, 27397, 23113, 25276, + 25752, 27915, 26173, 28336, 28812, 30975, 4193, 6356, 6832, 8995, 7253, + 9416, 9892, 12055, 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, + 7771, 9934, 10410, 12573, 10831, 12994, 13470, 15633, 11349, 13512, 13988, + 16151, 14409, 16572, 17048, 19211, 7771, 9934, 10410, 12573, 10831, 12994, + 13470, 15633, 11349, 13512, 13988, 16151, 14409, 16572, 17048, 19211, 11349, + 13512, 13988, 16151, 14409, 16572, 17048, 19211, 14927, 17090, 17566, 19729, + 17987, 20150, 20626, 22789, 8286, 10449, 10925, 13088, 11346, 13509, 13985, + 16148, 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, 11864, 14027, + 14503, 16666, 14924, 17087, 17563, 19726, 15442, 17605, 18081, 20244, 18502, + 20665, 21141, 23304, 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, + 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, 15442, 17605, 18081, + 20244, 18502, 20665, 21141, 23304, 19020, 21183, 21659, 23822, 22080, 24243, + 24719, 26882, 8286, 10449, 10925, 13088, 11346, 13509, 13985, 16148, 11864, + 14027, 14503, 16666, 14924, 17087, 17563, 19726, 11864, 14027, 14503, 16666, + 14924, 17087, 17563, 19726, 15442, 17605, 18081, 20244, 18502, 20665, 21141, + 23304, 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, 15442, 17605, + 18081, 20244, 18502, 20665, 21141, 23304, 15442, 17605, 18081, 20244, 18502, + 20665, 21141, 23304, 19020, 21183, 21659, 23822, 22080, 24243, 24719, 26882, + 12379, 14542, 15018, 17181, 15439, 17602, 18078, 20241, 15957, 18120, 18596, + 20759, 19017, 21180, 21656, 23819, 15957, 18120, 18596, 20759, 19017, 21180, + 21656, 23819, 19535, 21698, 22174, 24337, 22595, 24758, 25234, 27397, 15957, + 18120, 18596, 20759, 19017, 21180, 21656, 23819, 19535, 21698, 22174, 24337, + 22595, 24758, 25234, 27397, 19535, 21698, 22174, 24337, 22595, 24758, 25234, + 27397, 23113, 25276, 25752, 27915, 26173, 28336, 28812, 30975, 8286, 10449, + 10925, 13088, 11346, 13509, 13985, 16148, 11864, 14027, 14503, 16666, 14924, + 17087, 17563, 19726, 11864, 14027, 14503, 16666, 14924, 17087, 17563, 19726, + 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, 11864, 14027, 14503, + 16666, 14924, 17087, 17563, 19726, 15442, 17605, 18081, 20244, 18502, 20665, + 21141, 23304, 15442, 17605, 18081, 20244, 18502, 20665, 21141, 23304, 19020, + 21183, 21659, 23822, 22080, 24243, 24719, 26882, 12379, 14542, 15018, 17181, + 15439, 17602, 18078, 20241, 15957, 18120, 18596, 20759, 19017, 21180, 21656, + 23819, 15957, 18120, 18596, 20759, 19017, 21180, 21656, 23819, 19535, 21698, + 22174, 24337, 22595, 24758, 25234, 27397, 15957, 18120, 18596, 20759, 19017, + 21180, 21656, 23819, 19535, 21698, 22174, 24337, 22595, 24758, 25234, 27397, + 19535, 21698, 22174, 24337, 22595, 24758, 25234, 27397, 23113, 25276, 25752, + 27915, 26173, 28336, 28812, 30975, 12379, 14542, 15018, 17181, 15439, 17602, + 18078, 20241, 15957, 18120, 18596, 20759, 19017, 21180, 21656, 23819, 15957, + 18120, 18596, 20759, 19017, 21180, 21656, 23819, 19535, 21698, 22174, 24337, + 22595, 24758, 25234, 27397, 15957, 18120, 18596, 20759, 19017, 21180, 21656, + 23819, 19535, 21698, 22174, 24337, 22595, 24758, 25234, 27397, 19535, 21698, + 22174, 24337, 22595, 24758, 25234, 27397, 23113, 25276, 25752, 27915, 26173, + 28336, 28812, 30975, 16472, 18635, 19111, 21274, 19532, 21695, 22171, 24334, + 20050, 22213, 22689, 24852, 23110, 25273, 25749, 27912, 20050, 22213, 22689, + 24852, 23110, 25273, 25749, 27912, 23628, 25791, 26267, 28430, 26688, 28851, + 29327, 31490, 20050, 22213, 22689, 24852, 23110, 25273, 25749, 27912, 23628, + 25791, 26267, 28430, 26688, 28851, 29327, 31490, 23628, 25791, 26267, 28430, + 26688, 28851, 29327, 31490, 27206, 29369, 29845, 32008, 30266, 32429, 32905, + 35068 +}; #endif #if CONFIG_VP9_HIGHBITDEPTH -static const vpx_tree_index cat1_high10[2] = {0, 0}; -static const vpx_tree_index cat2_high10[4] = {2, 2, 0, 0}; -static const vpx_tree_index cat3_high10[6] = {2, 2, 4, 4, 0, 0}; -static const vpx_tree_index cat4_high10[8] = {2, 2, 4, 4, 6, 6, 0, 0}; -static const vpx_tree_index cat5_high10[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0}; -static const vpx_tree_index cat6_high10[32] = {2, 2, 4, 4, 6, 6, 8, 8, 10, 10, - 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, - 30, 30, 0, 0}; -static const vpx_tree_index cat1_high12[2] = {0, 0}; -static const vpx_tree_index cat2_high12[4] = {2, 2, 0, 0}; -static const vpx_tree_index cat3_high12[6] = {2, 2, 4, 4, 0, 0}; -static const vpx_tree_index cat4_high12[8] = {2, 2, 4, 4, 6, 6, 0, 0}; -static const vpx_tree_index cat5_high12[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0}; -static const vpx_tree_index cat6_high12[36] = {2, 2, 4, 4, 6, 6, 8, 8, 10, 10, - 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, - 30, 30, 32, 32, 34, 34, 0, 0}; +static const vpx_tree_index cat1_high10[2] = { 0, 0 }; +static const vpx_tree_index cat2_high10[4] = { 2, 2, 0, 0 }; +static const vpx_tree_index cat3_high10[6] = { 2, 2, 4, 4, 0, 0 }; +static const vpx_tree_index cat4_high10[8] = { 2, 2, 4, 4, 6, 6, 0, 0 }; +static const vpx_tree_index cat5_high10[10] = { 2, 2, 4, 4, 6, 6, 8, 8, 0, 0 }; +static const vpx_tree_index cat6_high10[32] = { 2, 2, 4, 4, 6, 6, 8, 8, + 10, 10, 12, 12, 14, 14, 16, 16, + 18, 18, 20, 20, 22, 22, 24, 24, + 26, 26, 28, 28, 30, 30, 0, 0 }; +static const vpx_tree_index cat1_high12[2] = { 0, 0 }; +static const vpx_tree_index cat2_high12[4] = { 2, 2, 0, 0 }; +static const vpx_tree_index cat3_high12[6] = { 2, 2, 4, 4, 0, 0 }; +static const vpx_tree_index cat4_high12[8] = { 2, 2, 4, 4, 6, 6, 0, 0 }; +static const vpx_tree_index cat5_high12[10] = { 2, 2, 4, 4, 6, 6, 8, 8, 0, 0 }; +static const vpx_tree_index cat6_high12[36] = { + 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, + 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32, 34, 34, 0, 0 +}; #endif const vp10_extra_bit vp10_extra_bits[ENTROPY_TOKENS] = { - {0, 0, 0, 0, zero_cost}, // ZERO_TOKEN - {0, 0, 0, 1, sign_cost}, // ONE_TOKEN - {0, 0, 0, 2, sign_cost}, // TWO_TOKEN - {0, 0, 0, 3, sign_cost}, // THREE_TOKEN - {0, 0, 0, 4, sign_cost}, // FOUR_TOKEN - {cat1, vp10_cat1_prob, 1, CAT1_MIN_VAL, cat1_cost}, // CATEGORY1_TOKEN - {cat2, vp10_cat2_prob, 2, CAT2_MIN_VAL, cat2_cost}, // CATEGORY2_TOKEN - {cat3, vp10_cat3_prob, 3, CAT3_MIN_VAL, cat3_cost}, // CATEGORY3_TOKEN - {cat4, vp10_cat4_prob, 4, CAT4_MIN_VAL, cat4_cost}, // CATEGORY4_TOKEN - {cat5, vp10_cat5_prob, 5, CAT5_MIN_VAL, cat5_cost}, // CATEGORY5_TOKEN - {cat6, vp10_cat6_prob, 14, CAT6_MIN_VAL, 0}, // CATEGORY6_TOKEN - {0, 0, 0, 0, zero_cost} // EOB_TOKEN + { 0, 0, 0, 0, zero_cost }, // ZERO_TOKEN + { 0, 0, 0, 1, sign_cost }, // ONE_TOKEN + { 0, 0, 0, 2, sign_cost }, // TWO_TOKEN + { 0, 0, 0, 3, sign_cost }, // THREE_TOKEN + { 0, 0, 0, 4, sign_cost }, // FOUR_TOKEN + { cat1, vp10_cat1_prob, 1, CAT1_MIN_VAL, cat1_cost }, // CATEGORY1_TOKEN + { cat2, vp10_cat2_prob, 2, CAT2_MIN_VAL, cat2_cost }, // CATEGORY2_TOKEN + { cat3, vp10_cat3_prob, 3, CAT3_MIN_VAL, cat3_cost }, // CATEGORY3_TOKEN + { cat4, vp10_cat4_prob, 4, CAT4_MIN_VAL, cat4_cost }, // CATEGORY4_TOKEN + { cat5, vp10_cat5_prob, 5, CAT5_MIN_VAL, cat5_cost }, // CATEGORY5_TOKEN + { cat6, vp10_cat6_prob, 14, CAT6_MIN_VAL, 0 }, // CATEGORY6_TOKEN + { 0, 0, 0, 0, zero_cost } // EOB_TOKEN }; #if CONFIG_VP9_HIGHBITDEPTH const vp10_extra_bit vp10_extra_bits_high10[ENTROPY_TOKENS] = { - {0, 0, 0, 0, zero_cost}, // ZERO - {0, 0, 0, 1, sign_cost}, // ONE - {0, 0, 0, 2, sign_cost}, // TWO - {0, 0, 0, 3, sign_cost}, // THREE - {0, 0, 0, 4, sign_cost}, // FOUR - {cat1_high10, vp10_cat1_prob_high10, 1, CAT1_MIN_VAL, cat1_cost}, // CAT1 - {cat2_high10, vp10_cat2_prob_high10, 2, CAT2_MIN_VAL, cat2_cost}, // CAT2 - {cat3_high10, vp10_cat3_prob_high10, 3, CAT3_MIN_VAL, cat3_cost}, // CAT3 - {cat4_high10, vp10_cat4_prob_high10, 4, CAT4_MIN_VAL, cat4_cost}, // CAT4 - {cat5_high10, vp10_cat5_prob_high10, 5, CAT5_MIN_VAL, cat5_cost}, // CAT5 - {cat6_high10, vp10_cat6_prob_high10, 16, CAT6_MIN_VAL, 0}, // CAT6 - {0, 0, 0, 0, zero_cost} // EOB + { 0, 0, 0, 0, zero_cost }, // ZERO + { 0, 0, 0, 1, sign_cost }, // ONE + { 0, 0, 0, 2, sign_cost }, // TWO + { 0, 0, 0, 3, sign_cost }, // THREE + { 0, 0, 0, 4, sign_cost }, // FOUR + { cat1_high10, vp10_cat1_prob_high10, 1, CAT1_MIN_VAL, cat1_cost }, // CAT1 + { cat2_high10, vp10_cat2_prob_high10, 2, CAT2_MIN_VAL, cat2_cost }, // CAT2 + { cat3_high10, vp10_cat3_prob_high10, 3, CAT3_MIN_VAL, cat3_cost }, // CAT3 + { cat4_high10, vp10_cat4_prob_high10, 4, CAT4_MIN_VAL, cat4_cost }, // CAT4 + { cat5_high10, vp10_cat5_prob_high10, 5, CAT5_MIN_VAL, cat5_cost }, // CAT5 + { cat6_high10, vp10_cat6_prob_high10, 16, CAT6_MIN_VAL, 0 }, // CAT6 + { 0, 0, 0, 0, zero_cost } // EOB }; const vp10_extra_bit vp10_extra_bits_high12[ENTROPY_TOKENS] = { - {0, 0, 0, 0, zero_cost}, // ZERO - {0, 0, 0, 1, sign_cost}, // ONE - {0, 0, 0, 2, sign_cost}, // TWO - {0, 0, 0, 3, sign_cost}, // THREE - {0, 0, 0, 4, sign_cost}, // FOUR - {cat1_high12, vp10_cat1_prob_high12, 1, CAT1_MIN_VAL, cat1_cost}, // CAT1 - {cat2_high12, vp10_cat2_prob_high12, 2, CAT2_MIN_VAL, cat2_cost}, // CAT2 - {cat3_high12, vp10_cat3_prob_high12, 3, CAT3_MIN_VAL, cat3_cost}, // CAT3 - {cat4_high12, vp10_cat4_prob_high12, 4, CAT4_MIN_VAL, cat4_cost}, // CAT4 - {cat5_high12, vp10_cat5_prob_high12, 5, CAT5_MIN_VAL, cat5_cost}, // CAT5 - {cat6_high12, vp10_cat6_prob_high12, 18, CAT6_MIN_VAL, 0}, // CAT6 - {0, 0, 0, 0, zero_cost} // EOB + { 0, 0, 0, 0, zero_cost }, // ZERO + { 0, 0, 0, 1, sign_cost }, // ONE + { 0, 0, 0, 2, sign_cost }, // TWO + { 0, 0, 0, 3, sign_cost }, // THREE + { 0, 0, 0, 4, sign_cost }, // FOUR + { cat1_high12, vp10_cat1_prob_high12, 1, CAT1_MIN_VAL, cat1_cost }, // CAT1 + { cat2_high12, vp10_cat2_prob_high12, 2, CAT2_MIN_VAL, cat2_cost }, // CAT2 + { cat3_high12, vp10_cat3_prob_high12, 3, CAT3_MIN_VAL, cat3_cost }, // CAT3 + { cat4_high12, vp10_cat4_prob_high12, 4, CAT4_MIN_VAL, cat4_cost }, // CAT4 + { cat5_high12, vp10_cat5_prob_high12, 5, CAT5_MIN_VAL, cat5_cost }, // CAT5 + { cat6_high12, vp10_cat6_prob_high12, 18, CAT6_MIN_VAL, 0 }, // CAT6 + { 0, 0, 0, 0, zero_cost } // EOB }; #endif #if !CONFIG_ANS const struct vp10_token vp10_coef_encodings[ENTROPY_TOKENS] = { - {2, 2}, {6, 3}, {28, 5}, {58, 6}, {59, 6}, {60, 6}, {61, 6}, {124, 7}, - {125, 7}, {126, 7}, {127, 7}, {0, 1} + { 2, 2 }, { 6, 3 }, { 28, 5 }, { 58, 6 }, { 59, 6 }, { 60, 6 }, + { 61, 6 }, { 124, 7 }, { 125, 7 }, { 126, 7 }, { 127, 7 }, { 0, 1 } }; #endif // !CONFIG_ANS @@ -348,18 +347,17 @@ struct tokenize_b_args { TOKENEXTRA **tp; }; -static void set_entropy_context_b(int plane, int block, - int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, +static void set_entropy_context_b(int plane, int block, int blk_row, + int blk_col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) { - struct tokenize_b_args* const args = arg; + struct tokenize_b_args *const args = arg; ThreadData *const td = args->td; MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; struct macroblock_plane *p = &x->plane[plane]; struct macroblockd_plane *pd = &xd->plane[plane]; - vp10_set_contexts(xd, pd, plane_bsize, tx_size, p->eobs[block] > 0, - blk_col, blk_row); + vp10_set_contexts(xd, pd, plane_bsize, tx_size, p->eobs[block] > 0, blk_col, + blk_row); } static INLINE void add_token(TOKENEXTRA **t, const vpx_prob *context_tree, @@ -381,8 +379,7 @@ static INLINE void add_token(TOKENEXTRA **t, const vpx_prob *context_tree, static INLINE void add_token_no_extra(TOKENEXTRA **t, const vpx_prob *context_tree, - uint8_t token, - uint8_t skip_eob_node, + uint8_t token, uint8_t skip_eob_node, unsigned int *counts) { (*t)->token = token; (*t)->context_tree = context_tree; @@ -397,9 +394,8 @@ static INLINE int get_tx_eob(const struct segmentation *seg, int segment_id, return segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max; } -void vp10_tokenize_palette_sb(struct ThreadData *const td, - BLOCK_SIZE bsize, int plane, - TOKENEXTRA **t) { +void vp10_tokenize_palette_sb(struct ThreadData *const td, BLOCK_SIZE bsize, + int plane, TOKENEXTRA **t) { MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; @@ -409,17 +405,17 @@ void vp10_tokenize_palette_sb(struct ThreadData *const td, int i, j, k; int color_new_idx = -1, color_ctx, color_order[PALETTE_MAX_SIZE]; const int rows = (4 * num_4x4_blocks_high_lookup[bsize]) >> - (xd->plane[plane != 0].subsampling_y); + (xd->plane[plane != 0].subsampling_y); const int cols = (4 * num_4x4_blocks_wide_lookup[bsize]) >> - (xd->plane[plane != 0].subsampling_x); - const vpx_prob (* const probs)[PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] = - plane == 0 ? vp10_default_palette_y_color_prob : - vp10_default_palette_uv_color_prob; + (xd->plane[plane != 0].subsampling_x); + const vpx_prob (*const probs)[PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] = + plane == 0 ? vp10_default_palette_y_color_prob + : vp10_default_palette_uv_color_prob; for (i = 0; i < rows; ++i) { for (j = (i == 0 ? 1 : 0); j < cols; ++j) { - color_ctx = vp10_get_palette_color_context(color_map, cols, i, j, n, - color_order); + color_ctx = + vp10_get_palette_color_context(color_map, cols, i, j, n, color_order); for (k = 0; k < n; ++k) if (color_map[i * cols + j] == color_order[k]) { color_new_idx = k; @@ -435,9 +431,8 @@ void vp10_tokenize_palette_sb(struct ThreadData *const td, } static void tokenize_b(int plane, int block, int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, - TX_SIZE tx_size, void *arg) { - struct tokenize_b_args* const args = arg; + BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) { + struct tokenize_b_args *const args = arg; VP10_COMP *cpi = args->cpi; ThreadData *const td = args->td; MACROBLOCK *const x = &td->mb; @@ -449,7 +444,7 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col, MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; int pt; /* near block/prev token context index */ int c; - TOKENEXTRA *t = *tp; /* store tokens starting here */ + TOKENEXTRA *t = *tp; /* store tokens starting here */ int eob = p->eobs[block]; const PLANE_TYPE type = pd->plane_type; const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); @@ -465,7 +460,7 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col, unsigned int (*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] = td->rd_counts.coef_counts[txsize_sqr_map[tx_size]][type][ref]; #if CONFIG_ENTROPY - vpx_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] = + vpx_prob(*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] = cpi->subframe_stats.coef_probs_buf[cpi->common.coef_probs_update_idx] [txsize_sqr_map[tx_size]][type][ref]; #else @@ -497,7 +492,7 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col, add_token(&t, coef_probs[band[c]][pt], #if CONFIG_ANS - (const rans_dec_lut*)&coef_cdfs[band[c]][pt], + (const rans_dec_lut *)&coef_cdfs[band[c]][pt], #endif // CONFIG_ANS extra, (uint8_t)token, (uint8_t)skip_eob, counts[band[c]][pt]); @@ -522,8 +517,7 @@ struct is_skippable_args { int *skippable; }; static void is_skippable(int plane, int block, int blk_row, int blk_col, - BLOCK_SIZE plane_bsize, TX_SIZE tx_size, - void *argv) { + BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *argv) { struct is_skippable_args *args = argv; (void)plane; (void)plane_bsize; @@ -537,7 +531,7 @@ static void is_skippable(int plane, int block, int blk_row, int blk_col, // vp10_foreach_transform_block() and simplify is_skippable(). int vp10_is_skippable_in_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { int result = 1; - struct is_skippable_args args = {x->plane[plane].eobs, &result}; + struct is_skippable_args args = { x->plane[plane].eobs, &result }; vp10_foreach_transformed_block_in_plane(&x->e_mbd, bsize, plane, is_skippable, &args); return result; @@ -548,27 +542,26 @@ static void has_high_freq_coeff(int plane, int block, int blk_row, int blk_col, void *argv) { struct is_skippable_args *args = argv; int eobs = (tx_size == TX_4X4) ? 3 : 10; - (void) plane; - (void) plane_bsize; - (void) blk_row; - (void) blk_col; + (void)plane; + (void)plane_bsize; + (void)blk_row; + (void)blk_col; *(args->skippable) |= (args->eobs[block] > eobs); } int vp10_has_high_freq_in_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { int result = 0; - struct is_skippable_args args = {x->plane[plane].eobs, &result}; + struct is_skippable_args args = { x->plane[plane].eobs, &result }; vp10_foreach_transformed_block_in_plane(&x->e_mbd, bsize, plane, has_high_freq_coeff, &args); return result; } #if CONFIG_VAR_TX -void tokenize_tx(ThreadData *td, TOKENEXTRA **t, - int dry_run, TX_SIZE tx_size, BLOCK_SIZE plane_bsize, - int blk_row, int blk_col, int block, int plane, - void *arg) { +void tokenize_tx(ThreadData *td, TOKENEXTRA **t, int dry_run, TX_SIZE tx_size, + BLOCK_SIZE plane_bsize, int blk_row, int blk_col, int block, + int plane, void *arg) { MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; @@ -576,9 +569,10 @@ void tokenize_tx(ThreadData *td, TOKENEXTRA **t, const BLOCK_SIZE bsize = txsize_to_bsize[tx_size]; const int tx_row = blk_row >> (1 - pd->subsampling_y); const int tx_col = blk_col >> (1 - pd->subsampling_x); - const TX_SIZE plane_tx_size = plane ? - get_uv_tx_size_impl(mbmi->inter_tx_size[tx_row][tx_col], bsize, 0, 0) : - mbmi->inter_tx_size[tx_row][tx_col]; + const TX_SIZE plane_tx_size = + plane ? get_uv_tx_size_impl(mbmi->inter_tx_size[tx_row][tx_col], bsize, 0, + 0) + : mbmi->inter_tx_size[tx_row][tx_col]; int max_blocks_high = num_4x4_blocks_high_lookup[plane_bsize]; int max_blocks_wide = num_4x4_blocks_wide_lookup[plane_bsize]; @@ -590,8 +584,7 @@ void tokenize_tx(ThreadData *td, TOKENEXTRA **t, if (xd->mb_to_right_edge < 0) max_blocks_wide += xd->mb_to_right_edge >> (5 + pd->subsampling_x); - if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) - return; + if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (tx_size == plane_tx_size) { const struct macroblockd_plane *const pd = &xd->plane[plane]; @@ -599,8 +592,8 @@ void tokenize_tx(ThreadData *td, TOKENEXTRA **t, if (!dry_run) tokenize_b(plane, block, blk_row, blk_col, plane_bsize, tx_size, arg); else - set_entropy_context_b(plane, block, blk_row, blk_col, - plane_bsize, tx_size, arg); + set_entropy_context_b(plane, block, blk_row, blk_col, plane_bsize, + tx_size, arg); } else { int bsl = b_width_log2_lookup[bsize]; int i; @@ -613,11 +606,10 @@ void tokenize_tx(ThreadData *td, TOKENEXTRA **t, const int offsetc = blk_col + ((i & 0x01) << bsl); int step = num_4x4_blocks_txsize_lookup[tx_size - 1]; - if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) - continue; + if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) continue; - tokenize_tx(td, t, dry_run, tx_size - 1, plane_bsize, - offsetr, offsetc, block + i * step, plane, arg); + tokenize_tx(td, t, dry_run, tx_size - 1, plane_bsize, offsetr, offsetc, + block + i * step, plane, arg); } } } @@ -631,19 +623,16 @@ void vp10_tokenize_sb_inter(VP10_COMP *cpi, ThreadData *td, TOKENEXTRA **t, MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; TOKENEXTRA *t_backup = *t; const int ctx = vp10_get_skip_context(xd); - const int skip_inc = !segfeature_active(&cm->seg, mbmi->segment_id, - SEG_LVL_SKIP); - struct tokenize_b_args arg = {cpi, td, t}; + const int skip_inc = + !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP); + struct tokenize_b_args arg = { cpi, td, t }; int plane; - if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) - return; + if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; if (mbmi->skip) { - if (!dry_run) - td->counts->skip[ctx][1] += skip_inc; + if (!dry_run) td->counts->skip[ctx][1] += skip_inc; reset_skip_context(xd, bsize); - if (dry_run) - *t = t_backup; + if (dry_run) *t = t_backup; return; } @@ -665,8 +654,8 @@ void vp10_tokenize_sb_inter(VP10_COMP *cpi, ThreadData *td, TOKENEXTRA **t, int step = num_4x4_blocks_txsize_lookup[max_tx_size]; for (idy = 0; idy < mi_height; idy += bh) { for (idx = 0; idx < mi_width; idx += bh) { - tokenize_tx(td, t, dry_run, max_tx_size, plane_bsize, idy, idx, - block, plane, &arg); + tokenize_tx(td, t, dry_run, max_tx_size, plane_bsize, idy, idx, block, + plane, &arg); block += step; } } @@ -680,18 +669,17 @@ void vp10_tokenize_sb_inter(VP10_COMP *cpi, ThreadData *td, TOKENEXTRA **t, #endif // CONFIG_VAR_TX void vp10_tokenize_sb(VP10_COMP *cpi, ThreadData *td, TOKENEXTRA **t, - int dry_run, BLOCK_SIZE bsize) { + int dry_run, BLOCK_SIZE bsize) { VP10_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const int ctx = vp10_get_skip_context(xd); - const int skip_inc = !segfeature_active(&cm->seg, mbmi->segment_id, - SEG_LVL_SKIP); - struct tokenize_b_args arg = {cpi, td, t}; + const int skip_inc = + !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP); + struct tokenize_b_args arg = { cpi, td, t }; if (mbmi->skip) { - if (!dry_run) - td->counts->skip[ctx][1] += skip_inc; + if (!dry_run) td->counts->skip[ctx][1] += skip_inc; reset_skip_context(xd, bsize); return; } @@ -720,15 +708,13 @@ void vp10_tokenize_sb_supertx(VP10_COMP *cpi, ThreadData *td, TOKENEXTRA **t, MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; TOKENEXTRA *t_backup = *t; const int ctx = vp10_get_skip_context(xd); - const int skip_inc = !segfeature_active(&cm->seg, mbmi->segment_id_supertx, - SEG_LVL_SKIP); - struct tokenize_b_args arg = {cpi, td, t}; + const int skip_inc = + !segfeature_active(&cm->seg, mbmi->segment_id_supertx, SEG_LVL_SKIP); + struct tokenize_b_args arg = { cpi, td, t }; if (mbmi->skip) { - if (!dry_run) - td->counts->skip[ctx][1] += skip_inc; + if (!dry_run) td->counts->skip[ctx][1] += skip_inc; reset_skip_context(xd, bsize); - if (dry_run) - *t = t_backup; + if (dry_run) *t = t_backup; return; } diff --git a/vp10/encoder/tokenize.h b/vp10/encoder/tokenize.h index c9b20df52..1623c9fcf 100644 --- a/vp10/encoder/tokenize.h +++ b/vp10/encoder/tokenize.h @@ -20,15 +20,14 @@ extern "C" { #endif -#define EOSB_TOKEN 127 // Not signalled, encoder only +#define EOSB_TOKEN 127 // Not signalled, encoder only #if CONFIG_VP9_HIGHBITDEPTH - typedef int32_t EXTRABIT; +typedef int32_t EXTRABIT; #else - typedef int16_t EXTRABIT; +typedef int16_t EXTRABIT; #endif - typedef struct { int16_t token; EXTRABIT extra; @@ -62,11 +61,10 @@ void vp10_tokenize_sb_inter(struct VP10_COMP *cpi, struct ThreadData *td, BLOCK_SIZE bsize); #endif -void vp10_tokenize_palette_sb(struct ThreadData *const td, - BLOCK_SIZE bsize, int plane, - TOKENEXTRA **t); +void vp10_tokenize_palette_sb(struct ThreadData *const td, BLOCK_SIZE bsize, + int plane, TOKENEXTRA **t); void vp10_tokenize_sb(struct VP10_COMP *cpi, struct ThreadData *td, - TOKENEXTRA **t, int dry_run, BLOCK_SIZE bsize); + TOKENEXTRA **t, int dry_run, BLOCK_SIZE bsize); #if CONFIG_SUPERTX void vp10_tokenize_sb_supertx(struct VP10_COMP *cpi, struct ThreadData *td, TOKENEXTRA **t, int dry_run, BLOCK_SIZE bsize); @@ -85,27 +83,28 @@ extern const int vp10_cat6_high_cost[64]; extern const int vp10_cat6_high10_high_cost[256]; extern const int vp10_cat6_high12_high_cost[1024]; static INLINE int vp10_get_cost(int16_t token, EXTRABIT extrabits, - const int *cat6_high_table) { + const int *cat6_high_table) { if (token != CATEGORY6_TOKEN) return vp10_extra_bits[token].cost[extrabits >> 1]; - return vp10_cat6_low_cost[(extrabits >> 1) & 0xff] - + cat6_high_table[extrabits >> 9]; + return vp10_cat6_low_cost[(extrabits >> 1) & 0xff] + + cat6_high_table[extrabits >> 9]; } #if CONFIG_VP9_HIGHBITDEPTH -static INLINE const int* vp10_get_high_cost_table(int bit_depth) { +static INLINE const int *vp10_get_high_cost_table(int bit_depth) { return bit_depth == 8 ? vp10_cat6_high_cost - : (bit_depth == 10 ? vp10_cat6_high10_high_cost : - vp10_cat6_high12_high_cost); + : (bit_depth == 10 ? vp10_cat6_high10_high_cost + : vp10_cat6_high12_high_cost); } #else -static INLINE const int* vp10_get_high_cost_table(int bit_depth) { - (void) bit_depth; +static INLINE const int *vp10_get_high_cost_table(int bit_depth) { + (void)bit_depth; return vp10_cat6_high_cost; } #endif // CONFIG_VP9_HIGHBITDEPTH -static INLINE void vp10_get_token_extra(int v, int16_t *token, EXTRABIT *extra) { +static INLINE void vp10_get_token_extra(int v, int16_t *token, + EXTRABIT *extra) { if (v >= CAT6_MIN_VAL || v <= -CAT6_MIN_VAL) { *token = CATEGORY6_TOKEN; if (v >= CAT6_MIN_VAL) @@ -118,19 +117,18 @@ static INLINE void vp10_get_token_extra(int v, int16_t *token, EXTRABIT *extra) *extra = vp10_dct_cat_lt_10_value_tokens[v].extra; } static INLINE int16_t vp10_get_token(int v) { - if (v >= CAT6_MIN_VAL || v <= -CAT6_MIN_VAL) - return 10; + if (v >= CAT6_MIN_VAL || v <= -CAT6_MIN_VAL) return 10; return vp10_dct_cat_lt_10_value_tokens[v].token; } static INLINE int vp10_get_token_cost(int v, int16_t *token, - const int *cat6_high_table) { + const int *cat6_high_table) { if (v >= CAT6_MIN_VAL || v <= -CAT6_MIN_VAL) { EXTRABIT extrabits; *token = CATEGORY6_TOKEN; extrabits = abs(v) - CAT6_MIN_VAL; - return vp10_cat6_low_cost[extrabits & 0xff] - + cat6_high_table[extrabits >> 8]; + return vp10_cat6_low_cost[extrabits & 0xff] + + cat6_high_table[extrabits >> 8]; } *token = vp10_dct_cat_lt_10_value_tokens[v].token; return vp10_dct_cat_lt_10_value_cost[v]; diff --git a/vp10/encoder/treewriter.c b/vp10/encoder/treewriter.c index 1f42f32a1..152bf40f3 100644 --- a/vp10/encoder/treewriter.c +++ b/vp10/encoder/treewriter.c @@ -27,7 +27,7 @@ static void tree2tok(struct vp10_token *tokens, const vpx_tree_index *tree, } void vp10_tokens_from_tree(struct vp10_token *tokens, - const vpx_tree_index *tree) { + const vpx_tree_index *tree) { tree2tok(tokens, tree, 0, 0, 0); } @@ -52,7 +52,7 @@ static unsigned int convert_distribution(unsigned int i, vpx_tree tree, } void vp10_tree_probs_from_distribution(vpx_tree tree, - unsigned int branch_ct[/* n-1 */][2], - const unsigned int num_events[/* n */]) { + unsigned int branch_ct[/* n-1 */][2], + const unsigned int num_events[/* n */]) { convert_distribution(0, tree, branch_ct, num_events); } diff --git a/vp10/encoder/treewriter.h b/vp10/encoder/treewriter.h index eeb5a6d58..fdbaadd44 100644 --- a/vp10/encoder/treewriter.h +++ b/vp10/encoder/treewriter.h @@ -26,19 +26,19 @@ extern "C" { #endif void vp10_tree_probs_from_distribution(vpx_tree tree, - unsigned int branch_ct[ /* n - 1 */ ][2], - const unsigned int num_events[ /* n */ ]); + unsigned int branch_ct[/* n - 1 */][2], + const unsigned int num_events[/* n */]); struct vp10_token { int value; int len; }; -void vp10_tokens_from_tree(struct vp10_token*, const vpx_tree_index *); +void vp10_tokens_from_tree(struct vp10_token *, const vpx_tree_index *); static INLINE void vp10_write_tree(tree_writer *w, const vpx_tree_index *tree, - const vpx_prob *probs, int bits, int len, - vpx_tree_index i) { + const vpx_prob *probs, int bits, int len, + vpx_tree_index i) { do { const int bit = (bits >> --len) & 1; tree_bit_write(w, bit, probs[i >> 1]); @@ -47,8 +47,8 @@ static INLINE void vp10_write_tree(tree_writer *w, const vpx_tree_index *tree, } static INLINE void vp10_write_token(tree_writer *w, const vpx_tree_index *tree, - const vpx_prob *probs, - const struct vp10_token *token) { + const vpx_prob *probs, + const struct vp10_token *token) { vp10_write_tree(w, tree, probs, token->value, token->len, 0); } diff --git a/vp10/encoder/variance_tree.c b/vp10/encoder/variance_tree.c index d11ef2df6..03d316d18 100644 --- a/vp10/encoder/variance_tree.c +++ b/vp10/encoder/variance_tree.c @@ -11,8 +11,6 @@ #include "vp10/encoder/variance_tree.h" #include "vp10/encoder/encoder.h" - - void vp10_setup_var_tree(struct VP10Common *cm, ThreadData *td) { int i, j; #if CONFIG_EXT_PARTITION @@ -27,8 +25,8 @@ void vp10_setup_var_tree(struct VP10Common *cm, ThreadData *td) { int nodes; vpx_free(td->var_tree); - CHECK_MEM_ERROR(cm, td->var_tree, vpx_calloc(tree_nodes, - sizeof(*td->var_tree))); + CHECK_MEM_ERROR(cm, td->var_tree, + vpx_calloc(tree_nodes, sizeof(*td->var_tree))); this_var = &td->var_tree[0]; @@ -43,8 +41,7 @@ void vp10_setup_var_tree(struct VP10Common *cm, ThreadData *td) { for (nodes = leaf_nodes >> 2; nodes > 0; nodes >>= 2) { for (i = 0; i < nodes; ++i, ++index) { VAR_TREE *const node = &td->var_tree[index]; - for (j = 0; j < 4; j++) - node->split[j] = this_var++; + for (j = 0; j < 4; j++) node->split[j] = this_var++; } } @@ -53,7 +50,7 @@ void vp10_setup_var_tree(struct VP10Common *cm, ThreadData *td) { td->var_root[i] = &td->var_tree[tree_nodes - 1]; // Set up the root nodes for the rest of the possible superblock sizes while (--i >= 0) { - td->var_root[i] = td->var_root[i+1]->split[0]; + td->var_root[i] = td->var_root[i + 1]->split[0]; } } diff --git a/vp10/encoder/variance_tree.h b/vp10/encoder/variance_tree.h index a10f7e779..70d5cb8c6 100644 --- a/vp10/encoder/variance_tree.h +++ b/vp10/encoder/variance_tree.h @@ -63,8 +63,10 @@ static INLINE void fill_variance(int64_t s2, int64_t s, int c, var *v) { v->sum_square_error = s2; v->sum_error = s; v->log2_count = c; - v->variance = (int)(256 * (v->sum_square_error - - ((v->sum_error * v->sum_error) >> v->log2_count)) >> v->log2_count); + v->variance = + (int)(256 * (v->sum_square_error - + ((v->sum_error * v->sum_error) >> v->log2_count)) >> + v->log2_count); } static INLINE void sum_2_variances(const var *a, const var *b, var *r) { @@ -74,20 +76,15 @@ static INLINE void sum_2_variances(const var *a, const var *b, var *r) { } static INLINE void fill_variance_node(VAR_TREE *vt) { - sum_2_variances(&vt->split[0]->variances.none, - &vt->split[1]->variances.none, + sum_2_variances(&vt->split[0]->variances.none, &vt->split[1]->variances.none, &vt->variances.horz[0]); - sum_2_variances(&vt->split[2]->variances.none, - &vt->split[3]->variances.none, + sum_2_variances(&vt->split[2]->variances.none, &vt->split[3]->variances.none, &vt->variances.horz[1]); - sum_2_variances(&vt->split[0]->variances.none, - &vt->split[2]->variances.none, + sum_2_variances(&vt->split[0]->variances.none, &vt->split[2]->variances.none, &vt->variances.vert[0]); - sum_2_variances(&vt->split[1]->variances.none, - &vt->split[3]->variances.none, + sum_2_variances(&vt->split[1]->variances.none, &vt->split[3]->variances.none, &vt->variances.vert[1]); - sum_2_variances(&vt->variances.vert[0], - &vt->variances.vert[1], + sum_2_variances(&vt->variances.vert[0], &vt->variances.vert[1], &vt->variances.none); } diff --git a/vp10/encoder/wedge_utils.c b/vp10/encoder/wedge_utils.c index d97008d3e..cb3234c4f 100644 --- a/vp10/encoder/wedge_utils.c +++ b/vp10/encoder/wedge_utils.c @@ -18,7 +18,7 @@ #include "vp10/common/reconinter.h" -#define MAX_MASK_VALUE (1 << WEDGE_WEIGHT_BITS) +#define MAX_MASK_VALUE (1 << WEDGE_WEIGHT_BITS) /** * Computes SSE of a compound predictor constructed from 2 fundamental @@ -48,17 +48,15 @@ * holds for 8 bit input, and on real input, it should hold practically always, * as residuals are expected to be small. */ -uint64_t vp10_wedge_sse_from_residuals_c(const int16_t *r1, - const int16_t *d, - const uint8_t *m, - int N) { +uint64_t vp10_wedge_sse_from_residuals_c(const int16_t *r1, const int16_t *d, + const uint8_t *m, int N) { uint64_t csse = 0; int i; assert(N % 64 == 0); - for (i = 0 ; i < N ; i++) { - int32_t t = MAX_MASK_VALUE*r1[i] + m[i]*d[i]; + for (i = 0; i < N; i++) { + int32_t t = MAX_MASK_VALUE * r1[i] + m[i] * d[i]; t = clamp(t, INT16_MIN, INT16_MAX); - csse += t*t; + csse += t * t; } return ROUND_POWER_OF_TWO(csse, 2 * WEDGE_WEIGHT_BITS); } @@ -94,9 +92,7 @@ uint64_t vp10_wedge_sse_from_residuals_c(const int16_t *r1, * Note that for efficiency, ds is stored on 16 bits. Real input residuals * being small, this should not cause a noticeable issue. */ -int vp10_wedge_sign_from_residuals_c(const int16_t *ds, - const uint8_t *m, - int N, +int vp10_wedge_sign_from_residuals_c(const int16_t *ds, const uint8_t *m, int N, int64_t limit) { int64_t acc = 0; @@ -121,15 +117,12 @@ int vp10_wedge_sign_from_residuals_c(const int16_t *ds, * * The result is saturated to signed 16 bits. */ -void vp10_wedge_compute_delta_squares_c(int16_t *d, - const int16_t *a, - const int16_t *b, - int N) { +void vp10_wedge_compute_delta_squares_c(int16_t *d, const int16_t *a, + const int16_t *b, int N) { int i; assert(N % 64 == 0); - for (i = 0 ; i < N ; i++) - d[i] = clamp(a[i]*a[i] - b[i]*b[i], INT16_MIN, INT16_MAX); + for (i = 0; i < N; i++) + d[i] = clamp(a[i] * a[i] - b[i] * b[i], INT16_MIN, INT16_MAX); } - diff --git a/vp10/encoder/x86/dct_intrin_sse2.c b/vp10/encoder/x86/dct_intrin_sse2.c index ea0ccb87b..0e0ee44d0 100644 --- a/vp10/encoder/x86/dct_intrin_sse2.c +++ b/vp10/encoder/x86/dct_intrin_sse2.c @@ -92,8 +92,8 @@ static void fdct4_sse2(__m128i *in) { const __m128i k__DCT_CONST_ROUNDING = _mm_set1_epi32(DCT_CONST_ROUNDING); __m128i u[4], v[4]; - u[0]=_mm_unpacklo_epi16(in[0], in[1]); - u[1]=_mm_unpacklo_epi16(in[3], in[2]); + u[0] = _mm_unpacklo_epi16(in[0], in[1]); + u[1] = _mm_unpacklo_epi16(in[3], in[2]); v[0] = _mm_add_epi16(u[0], u[1]); v[1] = _mm_sub_epi16(u[0], u[1]); @@ -200,14 +200,12 @@ static void fidtx4_sse2(__m128i *in) { } #endif // CONFIG_EXT_TX -void vp10_fht4x4_sse2(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_fht4x4_sse2(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { __m128i in[4]; switch (tx_type) { - case DCT_DCT: - vpx_fdct4x4_sse2(input, output, stride); - break; + case DCT_DCT: vpx_fdct4x4_sse2(input, output, stride); break; case ADST_DCT: load_buffer_4x4(input, in, stride, 0, 0); fadst4_sse2(in); @@ -294,20 +292,16 @@ void vp10_fht4x4_sse2(const int16_t *input, tran_low_t *output, write_buffer_4x4(output, in); break; #endif // CONFIG_EXT_TX - default: - assert(0); + default: assert(0); } } -void vp10_fdct8x8_quant_sse2(const int16_t *input, int stride, - int16_t* coeff_ptr, intptr_t n_coeffs, - int skip_block, const int16_t* zbin_ptr, - const int16_t* round_ptr, const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, int16_t* qcoeff_ptr, - int16_t* dqcoeff_ptr, const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan_ptr, - const int16_t* iscan_ptr) { +void vp10_fdct8x8_quant_sse2( + const int16_t *input, int stride, int16_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, + const int16_t *quant_ptr, const int16_t *quant_shift_ptr, + int16_t *qcoeff_ptr, int16_t *dqcoeff_ptr, const int16_t *dequant_ptr, + uint16_t *eob_ptr, const int16_t *scan_ptr, const int16_t *iscan_ptr) { __m128i zero; int pass; // Constants @@ -324,14 +318,14 @@ void vp10_fdct8x8_quant_sse2(const int16_t *input, int stride, const __m128i k__cospi_m20_p12 = pair_set_epi16(-cospi_20_64, cospi_12_64); const __m128i k__DCT_CONST_ROUNDING = _mm_set1_epi32(DCT_CONST_ROUNDING); // Load input - __m128i in0 = _mm_load_si128((const __m128i *)(input + 0 * stride)); - __m128i in1 = _mm_load_si128((const __m128i *)(input + 1 * stride)); - __m128i in2 = _mm_load_si128((const __m128i *)(input + 2 * stride)); - __m128i in3 = _mm_load_si128((const __m128i *)(input + 3 * stride)); - __m128i in4 = _mm_load_si128((const __m128i *)(input + 4 * stride)); - __m128i in5 = _mm_load_si128((const __m128i *)(input + 5 * stride)); - __m128i in6 = _mm_load_si128((const __m128i *)(input + 6 * stride)); - __m128i in7 = _mm_load_si128((const __m128i *)(input + 7 * stride)); + __m128i in0 = _mm_load_si128((const __m128i *)(input + 0 * stride)); + __m128i in1 = _mm_load_si128((const __m128i *)(input + 1 * stride)); + __m128i in2 = _mm_load_si128((const __m128i *)(input + 2 * stride)); + __m128i in3 = _mm_load_si128((const __m128i *)(input + 3 * stride)); + __m128i in4 = _mm_load_si128((const __m128i *)(input + 4 * stride)); + __m128i in5 = _mm_load_si128((const __m128i *)(input + 5 * stride)); + __m128i in6 = _mm_load_si128((const __m128i *)(input + 6 * stride)); + __m128i in7 = _mm_load_si128((const __m128i *)(input + 7 * stride)); __m128i *in[8]; int index = 0; @@ -585,9 +579,9 @@ void vp10_fdct8x8_quant_sse2(const int16_t *input, int stride, // Setup global values { - round = _mm_load_si128((const __m128i*)round_ptr); - quant = _mm_load_si128((const __m128i*)quant_ptr); - dequant = _mm_load_si128((const __m128i*)dequant_ptr); + round = _mm_load_si128((const __m128i *)round_ptr); + quant = _mm_load_si128((const __m128i *)quant_ptr); + dequant = _mm_load_si128((const __m128i *)dequant_ptr); } { @@ -619,15 +613,15 @@ void vp10_fdct8x8_quant_sse2(const int16_t *input, int stride, qcoeff0 = _mm_sub_epi16(qcoeff0, coeff0_sign); qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs), qcoeff0); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs), qcoeff0); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); coeff0 = _mm_mullo_epi16(qcoeff0, dequant); dequant = _mm_unpackhi_epi64(dequant, dequant); coeff1 = _mm_mullo_epi16(qcoeff1, dequant); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs), coeff0); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs) + 1, coeff1); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs), coeff0); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs) + 1, coeff1); } { @@ -640,8 +634,8 @@ void vp10_fdct8x8_quant_sse2(const int16_t *input, int stride, zero_coeff1 = _mm_cmpeq_epi16(coeff1, zero); nzero_coeff0 = _mm_cmpeq_epi16(zero_coeff0, zero); nzero_coeff1 = _mm_cmpeq_epi16(zero_coeff1, zero); - iscan0 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs)); - iscan1 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs) + 1); + iscan0 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs)); + iscan1 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs) + 1); // Add one to convert from indices to counts iscan0 = _mm_sub_epi16(iscan0, nzero_coeff0); iscan1 = _mm_sub_epi16(iscan1, nzero_coeff1); @@ -684,14 +678,14 @@ void vp10_fdct8x8_quant_sse2(const int16_t *input, int stride, qcoeff0 = _mm_sub_epi16(qcoeff0, coeff0_sign); qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs), qcoeff0); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs), qcoeff0); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); coeff0 = _mm_mullo_epi16(qcoeff0, dequant); coeff1 = _mm_mullo_epi16(qcoeff1, dequant); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs), coeff0); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs) + 1, coeff1); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs), coeff0); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs) + 1, coeff1); } { @@ -704,8 +698,8 @@ void vp10_fdct8x8_quant_sse2(const int16_t *input, int stride, zero_coeff1 = _mm_cmpeq_epi16(coeff1, zero); nzero_coeff0 = _mm_cmpeq_epi16(zero_coeff0, zero); nzero_coeff1 = _mm_cmpeq_epi16(zero_coeff1, zero); - iscan0 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs)); - iscan1 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs) + 1); + iscan0 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs)); + iscan1 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs) + 1); // Add one to convert from indices to counts iscan0 = _mm_sub_epi16(iscan0, nzero_coeff0); iscan1 = _mm_sub_epi16(iscan1, nzero_coeff1); @@ -731,10 +725,10 @@ void vp10_fdct8x8_quant_sse2(const int16_t *input, int stride, } } else { do { - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs), zero); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs) + 1, zero); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs), zero); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs) + 1, zero); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs), zero); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs) + 1, zero); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs), zero); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs) + 1, zero); n_coeffs += 8 * 2; } while (n_coeffs < 0); *eob_ptr = 0; @@ -745,23 +739,23 @@ void vp10_fdct8x8_quant_sse2(const int16_t *input, int stride, static INLINE void load_buffer_8x8(const int16_t *input, __m128i *in, int stride, int flipud, int fliplr) { if (!flipud) { - in[0] = _mm_load_si128((const __m128i *)(input + 0 * stride)); - in[1] = _mm_load_si128((const __m128i *)(input + 1 * stride)); - in[2] = _mm_load_si128((const __m128i *)(input + 2 * stride)); - in[3] = _mm_load_si128((const __m128i *)(input + 3 * stride)); - in[4] = _mm_load_si128((const __m128i *)(input + 4 * stride)); - in[5] = _mm_load_si128((const __m128i *)(input + 5 * stride)); - in[6] = _mm_load_si128((const __m128i *)(input + 6 * stride)); - in[7] = _mm_load_si128((const __m128i *)(input + 7 * stride)); + in[0] = _mm_load_si128((const __m128i *)(input + 0 * stride)); + in[1] = _mm_load_si128((const __m128i *)(input + 1 * stride)); + in[2] = _mm_load_si128((const __m128i *)(input + 2 * stride)); + in[3] = _mm_load_si128((const __m128i *)(input + 3 * stride)); + in[4] = _mm_load_si128((const __m128i *)(input + 4 * stride)); + in[5] = _mm_load_si128((const __m128i *)(input + 5 * stride)); + in[6] = _mm_load_si128((const __m128i *)(input + 6 * stride)); + in[7] = _mm_load_si128((const __m128i *)(input + 7 * stride)); } else { - in[0] = _mm_load_si128((const __m128i *)(input + 7 * stride)); - in[1] = _mm_load_si128((const __m128i *)(input + 6 * stride)); - in[2] = _mm_load_si128((const __m128i *)(input + 5 * stride)); - in[3] = _mm_load_si128((const __m128i *)(input + 4 * stride)); - in[4] = _mm_load_si128((const __m128i *)(input + 3 * stride)); - in[5] = _mm_load_si128((const __m128i *)(input + 2 * stride)); - in[6] = _mm_load_si128((const __m128i *)(input + 1 * stride)); - in[7] = _mm_load_si128((const __m128i *)(input + 0 * stride)); + in[0] = _mm_load_si128((const __m128i *)(input + 7 * stride)); + in[1] = _mm_load_si128((const __m128i *)(input + 6 * stride)); + in[2] = _mm_load_si128((const __m128i *)(input + 5 * stride)); + in[3] = _mm_load_si128((const __m128i *)(input + 4 * stride)); + in[4] = _mm_load_si128((const __m128i *)(input + 3 * stride)); + in[5] = _mm_load_si128((const __m128i *)(input + 2 * stride)); + in[6] = _mm_load_si128((const __m128i *)(input + 1 * stride)); + in[7] = _mm_load_si128((const __m128i *)(input + 0 * stride)); } if (fliplr) { @@ -1068,14 +1062,14 @@ static void fadst8_sse2(__m128i *in) { __m128i in0, in1, in2, in3, in4, in5, in6, in7; // properly aligned for butterfly input - in0 = in[7]; - in1 = in[0]; - in2 = in[5]; - in3 = in[2]; - in4 = in[3]; - in5 = in[4]; - in6 = in[1]; - in7 = in[6]; + in0 = in[7]; + in1 = in[0]; + in2 = in[5]; + in3 = in[2]; + in4 = in[3]; + in5 = in[4]; + in6 = in[1]; + in7 = in[6]; // column transformation // stage 1 @@ -1288,14 +1282,12 @@ static void fidtx8_sse2(__m128i *in) { } #endif // CONFIG_EXT_TX -void vp10_fht8x8_sse2(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_fht8x8_sse2(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { __m128i in[8]; switch (tx_type) { - case DCT_DCT: - vpx_fdct8x8_sse2(input, output, stride); - break; + case DCT_DCT: vpx_fdct8x8_sse2(input, output, stride); break; case ADST_DCT: load_buffer_8x8(input, in, stride, 0, 0); fadst8_sse2(in); @@ -1396,14 +1388,13 @@ void vp10_fht8x8_sse2(const int16_t *input, tran_low_t *output, write_buffer_8x8(output, in, 8); break; #endif // CONFIG_EXT_TX - default: - assert(0); + default: assert(0); } } -static INLINE void load_buffer_16x16(const int16_t* input, __m128i *in0, - __m128i *in1, int stride, - int flipud, int fliplr) { +static INLINE void load_buffer_16x16(const int16_t *input, __m128i *in0, + __m128i *in1, int stride, int flipud, + int fliplr) { // Load 4 8x8 blocks const int16_t *topL = input; const int16_t *topR = input + 8; @@ -1414,24 +1405,32 @@ static INLINE void load_buffer_16x16(const int16_t* input, __m128i *in0, if (flipud) { // Swap left columns - tmp = topL; topL = botL; botL = tmp; + tmp = topL; + topL = botL; + botL = tmp; // Swap right columns - tmp = topR; topR = botR; botR = tmp; + tmp = topR; + topR = botR; + botR = tmp; } if (fliplr) { // Swap top rows - tmp = topL; topL = topR; topR = tmp; + tmp = topL; + topL = topR; + topR = tmp; // Swap bottom rows - tmp = botL; botL = botR; botR = tmp; + tmp = botL; + botL = botR; + botR = tmp; } // load first 8 columns - load_buffer_8x8(topL, in0, stride, flipud, fliplr); + load_buffer_8x8(topL, in0, stride, flipud, fliplr); load_buffer_8x8(botL, in0 + 8, stride, flipud, fliplr); // load second 8 columns - load_buffer_8x8(topR, in1, stride, flipud, fliplr); + load_buffer_8x8(topR, in1, stride, flipud, fliplr); load_buffer_8x8(botR, in1 + 8, stride, flipud, fliplr); } @@ -1783,13 +1782,13 @@ static void fdct16_8col(__m128i *in) { v[14] = _mm_srai_epi32(u[14], DCT_CONST_BITS); v[15] = _mm_srai_epi32(u[15], DCT_CONST_BITS); - in[1] = _mm_packs_epi32(v[0], v[1]); - in[9] = _mm_packs_epi32(v[2], v[3]); - in[5] = _mm_packs_epi32(v[4], v[5]); + in[1] = _mm_packs_epi32(v[0], v[1]); + in[9] = _mm_packs_epi32(v[2], v[3]); + in[5] = _mm_packs_epi32(v[4], v[5]); in[13] = _mm_packs_epi32(v[6], v[7]); - in[3] = _mm_packs_epi32(v[8], v[9]); + in[3] = _mm_packs_epi32(v[8], v[9]); in[11] = _mm_packs_epi32(v[10], v[11]); - in[7] = _mm_packs_epi32(v[12], v[13]); + in[7] = _mm_packs_epi32(v[12], v[13]); in[15] = _mm_packs_epi32(v[14], v[15]); } @@ -2473,14 +2472,12 @@ static void fidtx16_sse2(__m128i *in0, __m128i *in1) { } #endif // CONFIG_EXT_TX -void vp10_fht16x16_sse2(const int16_t *input, tran_low_t *output, - int stride, int tx_type) { +void vp10_fht16x16_sse2(const int16_t *input, tran_low_t *output, int stride, + int tx_type) { __m128i in0[16], in1[16]; switch (tx_type) { - case DCT_DCT: - vpx_fdct16x16_sse2(input, output, stride); - break; + case DCT_DCT: vpx_fdct16x16_sse2(input, output, stride); break; case ADST_DCT: load_buffer_16x16(input, in0, in1, stride, 0, 0); fadst16_sse2(in0, in1); @@ -2581,8 +2578,6 @@ void vp10_fht16x16_sse2(const int16_t *input, tran_low_t *output, write_buffer_16x16(output, in0, in1, 16); break; #endif // CONFIG_EXT_TX - default: - assert(0); - break; + default: assert(0); break; } } diff --git a/vp10/encoder/x86/dct_ssse3.c b/vp10/encoder/x86/dct_ssse3.c index df298d871..39cce1b45 100644 --- a/vp10/encoder/x86/dct_ssse3.c +++ b/vp10/encoder/x86/dct_ssse3.c @@ -20,16 +20,12 @@ #include "vpx_dsp/x86/inv_txfm_sse2.h" #include "vpx_dsp/x86/txfm_common_sse2.h" -void vp10_fdct8x8_quant_ssse3(const int16_t *input, int stride, - int16_t* coeff_ptr, intptr_t n_coeffs, - int skip_block, const int16_t* zbin_ptr, - const int16_t* round_ptr, const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, - int16_t* qcoeff_ptr, - int16_t* dqcoeff_ptr, const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan_ptr, - const int16_t* iscan_ptr) { +void vp10_fdct8x8_quant_ssse3( + const int16_t *input, int stride, int16_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, + const int16_t *quant_ptr, const int16_t *quant_shift_ptr, + int16_t *qcoeff_ptr, int16_t *dqcoeff_ptr, const int16_t *dequant_ptr, + uint16_t *eob_ptr, const int16_t *scan_ptr, const int16_t *iscan_ptr) { __m128i zero; int pass; // Constants @@ -47,14 +43,14 @@ void vp10_fdct8x8_quant_ssse3(const int16_t *input, int stride, const __m128i k__cospi_m20_p12 = pair_set_epi16(-cospi_20_64, cospi_12_64); const __m128i k__DCT_CONST_ROUNDING = _mm_set1_epi32(DCT_CONST_ROUNDING); // Load input - __m128i in0 = _mm_load_si128((const __m128i *)(input + 0 * stride)); - __m128i in1 = _mm_load_si128((const __m128i *)(input + 1 * stride)); - __m128i in2 = _mm_load_si128((const __m128i *)(input + 2 * stride)); - __m128i in3 = _mm_load_si128((const __m128i *)(input + 3 * stride)); - __m128i in4 = _mm_load_si128((const __m128i *)(input + 4 * stride)); - __m128i in5 = _mm_load_si128((const __m128i *)(input + 5 * stride)); - __m128i in6 = _mm_load_si128((const __m128i *)(input + 6 * stride)); - __m128i in7 = _mm_load_si128((const __m128i *)(input + 7 * stride)); + __m128i in0 = _mm_load_si128((const __m128i *)(input + 0 * stride)); + __m128i in1 = _mm_load_si128((const __m128i *)(input + 1 * stride)); + __m128i in2 = _mm_load_si128((const __m128i *)(input + 2 * stride)); + __m128i in3 = _mm_load_si128((const __m128i *)(input + 3 * stride)); + __m128i in4 = _mm_load_si128((const __m128i *)(input + 4 * stride)); + __m128i in5 = _mm_load_si128((const __m128i *)(input + 5 * stride)); + __m128i in6 = _mm_load_si128((const __m128i *)(input + 6 * stride)); + __m128i in7 = _mm_load_si128((const __m128i *)(input + 7 * stride)); __m128i *in[8]; int index = 0; @@ -303,9 +299,9 @@ void vp10_fdct8x8_quant_ssse3(const int16_t *input, int stride, // Setup global values { - round = _mm_load_si128((const __m128i*)round_ptr); - quant = _mm_load_si128((const __m128i*)quant_ptr); - dequant = _mm_load_si128((const __m128i*)dequant_ptr); + round = _mm_load_si128((const __m128i *)round_ptr); + quant = _mm_load_si128((const __m128i *)quant_ptr); + dequant = _mm_load_si128((const __m128i *)dequant_ptr); } { @@ -337,15 +333,15 @@ void vp10_fdct8x8_quant_ssse3(const int16_t *input, int stride, qcoeff0 = _mm_sub_epi16(qcoeff0, coeff0_sign); qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs), qcoeff0); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs), qcoeff0); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); coeff0 = _mm_mullo_epi16(qcoeff0, dequant); dequant = _mm_unpackhi_epi64(dequant, dequant); coeff1 = _mm_mullo_epi16(qcoeff1, dequant); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs), coeff0); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs) + 1, coeff1); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs), coeff0); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs) + 1, coeff1); } { @@ -358,8 +354,8 @@ void vp10_fdct8x8_quant_ssse3(const int16_t *input, int stride, zero_coeff1 = _mm_cmpeq_epi16(coeff1, zero); nzero_coeff0 = _mm_cmpeq_epi16(zero_coeff0, zero); nzero_coeff1 = _mm_cmpeq_epi16(zero_coeff1, zero); - iscan0 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs)); - iscan1 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs) + 1); + iscan0 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs)); + iscan1 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs) + 1); // Add one to convert from indices to counts iscan0 = _mm_sub_epi16(iscan0, nzero_coeff0); iscan1 = _mm_sub_epi16(iscan1, nzero_coeff1); @@ -393,7 +389,7 @@ void vp10_fdct8x8_quant_ssse3(const int16_t *input, int stride, qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign); nzflag = _mm_movemask_epi8(_mm_cmpgt_epi16(qcoeff0, thr)) | - _mm_movemask_epi8(_mm_cmpgt_epi16(qcoeff1, thr)); + _mm_movemask_epi8(_mm_cmpgt_epi16(qcoeff1, thr)); if (nzflag) { qcoeff0 = _mm_adds_epi16(qcoeff0, round); @@ -407,20 +403,20 @@ void vp10_fdct8x8_quant_ssse3(const int16_t *input, int stride, qcoeff0 = _mm_sub_epi16(qcoeff0, coeff0_sign); qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs), qcoeff0); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs), qcoeff0); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); coeff0 = _mm_mullo_epi16(qcoeff0, dequant); coeff1 = _mm_mullo_epi16(qcoeff1, dequant); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs), coeff0); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs) + 1, coeff1); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs), coeff0); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs) + 1, coeff1); } else { - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs), zero); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs) + 1, zero); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs), zero); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs) + 1, zero); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs), zero); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs) + 1, zero); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs), zero); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs) + 1, zero); } } @@ -434,8 +430,8 @@ void vp10_fdct8x8_quant_ssse3(const int16_t *input, int stride, zero_coeff1 = _mm_cmpeq_epi16(coeff1, zero); nzero_coeff0 = _mm_cmpeq_epi16(zero_coeff0, zero); nzero_coeff1 = _mm_cmpeq_epi16(zero_coeff1, zero); - iscan0 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs)); - iscan1 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs) + 1); + iscan0 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs)); + iscan1 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs) + 1); // Add one to convert from indices to counts iscan0 = _mm_sub_epi16(iscan0, nzero_coeff0); iscan1 = _mm_sub_epi16(iscan1, nzero_coeff1); @@ -461,10 +457,10 @@ void vp10_fdct8x8_quant_ssse3(const int16_t *input, int stride, } } else { do { - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs), zero); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs) + 1, zero); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs), zero); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs) + 1, zero); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs), zero); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs) + 1, zero); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs), zero); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs) + 1, zero); n_coeffs += 8 * 2; } while (n_coeffs < 0); *eob_ptr = 0; diff --git a/vp10/encoder/x86/error_intrin_avx2.c b/vp10/encoder/x86/error_intrin_avx2.c index 9766be27b..560cd4a87 100644 --- a/vp10/encoder/x86/error_intrin_avx2.c +++ b/vp10/encoder/x86/error_intrin_avx2.c @@ -13,10 +13,8 @@ #include "./vp10_rtcd.h" #include "vpx/vpx_integer.h" -int64_t vp10_block_error_avx2(const int16_t *coeff, - const int16_t *dqcoeff, - intptr_t block_size, - int64_t *ssz) { +int64_t vp10_block_error_avx2(const int16_t *coeff, const int16_t *dqcoeff, + intptr_t block_size, int64_t *ssz) { __m256i sse_reg, ssz_reg, coeff_reg, dqcoeff_reg; __m256i exp_dqcoeff_lo, exp_dqcoeff_hi, exp_coeff_lo, exp_coeff_hi; __m256i sse_reg_64hi, ssz_reg_64hi; @@ -29,7 +27,7 @@ int64_t vp10_block_error_avx2(const int16_t *coeff, sse_reg = _mm256_set1_epi16(0); ssz_reg = _mm256_set1_epi16(0); - for (i = 0 ; i < block_size ; i+= 16) { + for (i = 0; i < block_size; i += 16) { // load 32 bytes from coeff and dqcoeff coeff_reg = _mm256_loadu_si256((const __m256i *)(coeff + i)); dqcoeff_reg = _mm256_loadu_si256((const __m256i *)(dqcoeff + i)); @@ -66,8 +64,8 @@ int64_t vp10_block_error_avx2(const int16_t *coeff, _mm256_extractf128_si256(ssz_reg, 1)); // store the results - _mm_storel_epi64((__m128i*)(&sse), sse_reg128); + _mm_storel_epi64((__m128i *)(&sse), sse_reg128); - _mm_storel_epi64((__m128i*)(ssz), ssz_reg128); + _mm_storel_epi64((__m128i *)(ssz), ssz_reg128); return sse; } diff --git a/vp10/encoder/x86/highbd_block_error_intrin_sse2.c b/vp10/encoder/x86/highbd_block_error_intrin_sse2.c index 6b4cf5099..eefca1ce1 100644 --- a/vp10/encoder/x86/highbd_block_error_intrin_sse2.c +++ b/vp10/encoder/x86/highbd_block_error_intrin_sse2.c @@ -14,8 +14,8 @@ #include "vp10/common/common.h" int64_t vp10_highbd_block_error_sse2(tran_low_t *coeff, tran_low_t *dqcoeff, - intptr_t block_size, int64_t *ssz, - int bps) { + intptr_t block_size, int64_t *ssz, + int bps) { int i, j, test; uint32_t temp[4]; __m128i max, min, cmp0, cmp1, cmp2, cmp3; @@ -23,41 +23,41 @@ int64_t vp10_highbd_block_error_sse2(tran_low_t *coeff, tran_low_t *dqcoeff, const int shift = 2 * (bps - 8); const int rounding = shift > 0 ? 1 << (shift - 1) : 0; - for (i = 0; i < block_size; i+=8) { + for (i = 0; i < block_size; i += 8) { // Load the data into xmm registers - __m128i mm_coeff = _mm_load_si128((__m128i*) (coeff + i)); - __m128i mm_coeff2 = _mm_load_si128((__m128i*) (coeff + i + 4)); - __m128i mm_dqcoeff = _mm_load_si128((__m128i*) (dqcoeff + i)); - __m128i mm_dqcoeff2 = _mm_load_si128((__m128i*) (dqcoeff + i + 4)); + __m128i mm_coeff = _mm_load_si128((__m128i *)(coeff + i)); + __m128i mm_coeff2 = _mm_load_si128((__m128i *)(coeff + i + 4)); + __m128i mm_dqcoeff = _mm_load_si128((__m128i *)(dqcoeff + i)); + __m128i mm_dqcoeff2 = _mm_load_si128((__m128i *)(dqcoeff + i + 4)); // Check if any values require more than 15 bit max = _mm_set1_epi32(0x3fff); min = _mm_set1_epi32(0xffffc000); cmp0 = _mm_xor_si128(_mm_cmpgt_epi32(mm_coeff, max), - _mm_cmplt_epi32(mm_coeff, min)); + _mm_cmplt_epi32(mm_coeff, min)); cmp1 = _mm_xor_si128(_mm_cmpgt_epi32(mm_coeff2, max), - _mm_cmplt_epi32(mm_coeff2, min)); + _mm_cmplt_epi32(mm_coeff2, min)); cmp2 = _mm_xor_si128(_mm_cmpgt_epi32(mm_dqcoeff, max), - _mm_cmplt_epi32(mm_dqcoeff, min)); + _mm_cmplt_epi32(mm_dqcoeff, min)); cmp3 = _mm_xor_si128(_mm_cmpgt_epi32(mm_dqcoeff2, max), - _mm_cmplt_epi32(mm_dqcoeff2, min)); - test = _mm_movemask_epi8(_mm_or_si128(_mm_or_si128(cmp0, cmp1), - _mm_or_si128(cmp2, cmp3))); + _mm_cmplt_epi32(mm_dqcoeff2, min)); + test = _mm_movemask_epi8( + _mm_or_si128(_mm_or_si128(cmp0, cmp1), _mm_or_si128(cmp2, cmp3))); if (!test) { - __m128i mm_diff, error_sse2, sqcoeff_sse2;; + __m128i mm_diff, error_sse2, sqcoeff_sse2; mm_coeff = _mm_packs_epi32(mm_coeff, mm_coeff2); mm_dqcoeff = _mm_packs_epi32(mm_dqcoeff, mm_dqcoeff2); mm_diff = _mm_sub_epi16(mm_coeff, mm_dqcoeff); error_sse2 = _mm_madd_epi16(mm_diff, mm_diff); sqcoeff_sse2 = _mm_madd_epi16(mm_coeff, mm_coeff); - _mm_storeu_si128((__m128i*)temp, error_sse2); + _mm_storeu_si128((__m128i *)temp, error_sse2); error = error + temp[0] + temp[1] + temp[2] + temp[3]; - _mm_storeu_si128((__m128i*)temp, sqcoeff_sse2); + _mm_storeu_si128((__m128i *)temp, sqcoeff_sse2); sqcoeff += temp[0] + temp[1] + temp[2] + temp[3]; } else { for (j = 0; j < 8; j++) { const int64_t diff = coeff[i + j] - dqcoeff[i + j]; - error += diff * diff; + error += diff * diff; sqcoeff += (int64_t)coeff[i + j] * (int64_t)coeff[i + j]; } } diff --git a/vp10/encoder/x86/highbd_fwd_txfm_sse4.c b/vp10/encoder/x86/highbd_fwd_txfm_sse4.c index dffdf206b..e1643750a 100644 --- a/vp10/encoder/x86/highbd_fwd_txfm_sse4.c +++ b/vp10/encoder/x86/highbd_fwd_txfm_sse4.c @@ -277,8 +277,7 @@ void vp10_fwd_txfm2d_4x4_sse4_1(const int16_t *input, int32_t *coeff, write_buffer_4x4(in, coeff); break; #endif - default: - assert(0); + default: assert(0); } (void)bd; } @@ -288,23 +287,23 @@ static INLINE void load_buffer_8x8(const int16_t *input, __m128i *in, int shift) { __m128i u; if (!flipud) { - in[0] = _mm_load_si128((const __m128i *)(input + 0 * stride)); - in[1] = _mm_load_si128((const __m128i *)(input + 1 * stride)); - in[2] = _mm_load_si128((const __m128i *)(input + 2 * stride)); - in[3] = _mm_load_si128((const __m128i *)(input + 3 * stride)); - in[4] = _mm_load_si128((const __m128i *)(input + 4 * stride)); - in[5] = _mm_load_si128((const __m128i *)(input + 5 * stride)); - in[6] = _mm_load_si128((const __m128i *)(input + 6 * stride)); - in[7] = _mm_load_si128((const __m128i *)(input + 7 * stride)); + in[0] = _mm_load_si128((const __m128i *)(input + 0 * stride)); + in[1] = _mm_load_si128((const __m128i *)(input + 1 * stride)); + in[2] = _mm_load_si128((const __m128i *)(input + 2 * stride)); + in[3] = _mm_load_si128((const __m128i *)(input + 3 * stride)); + in[4] = _mm_load_si128((const __m128i *)(input + 4 * stride)); + in[5] = _mm_load_si128((const __m128i *)(input + 5 * stride)); + in[6] = _mm_load_si128((const __m128i *)(input + 6 * stride)); + in[7] = _mm_load_si128((const __m128i *)(input + 7 * stride)); } else { - in[0] = _mm_load_si128((const __m128i *)(input + 7 * stride)); - in[1] = _mm_load_si128((const __m128i *)(input + 6 * stride)); - in[2] = _mm_load_si128((const __m128i *)(input + 5 * stride)); - in[3] = _mm_load_si128((const __m128i *)(input + 4 * stride)); - in[4] = _mm_load_si128((const __m128i *)(input + 3 * stride)); - in[5] = _mm_load_si128((const __m128i *)(input + 2 * stride)); - in[6] = _mm_load_si128((const __m128i *)(input + 1 * stride)); - in[7] = _mm_load_si128((const __m128i *)(input + 0 * stride)); + in[0] = _mm_load_si128((const __m128i *)(input + 7 * stride)); + in[1] = _mm_load_si128((const __m128i *)(input + 6 * stride)); + in[2] = _mm_load_si128((const __m128i *)(input + 5 * stride)); + in[3] = _mm_load_si128((const __m128i *)(input + 4 * stride)); + in[4] = _mm_load_si128((const __m128i *)(input + 3 * stride)); + in[5] = _mm_load_si128((const __m128i *)(input + 2 * stride)); + in[6] = _mm_load_si128((const __m128i *)(input + 1 * stride)); + in[7] = _mm_load_si128((const __m128i *)(input + 0 * stride)); } if (fliplr) { @@ -452,7 +451,7 @@ static void fdct8x8_sse4_1(__m128i *in, __m128i *out, int bit) { u[2] = _mm_add_epi32(in[4], in[10]); u[5] = _mm_sub_epi32(in[4], in[10]); u[3] = _mm_add_epi32(in[6], in[8]); - v[4] = _mm_sub_epi32(in[6], in[8]); // v[4] + v[4] = _mm_sub_epi32(in[6], in[8]); // v[4] // stage 2 v[0] = _mm_add_epi32(u[0], u[3]); @@ -508,7 +507,7 @@ static void fdct8x8_sse4_1(__m128i *in, __m128i *out, int bit) { v[1] = _mm_mullo_epi32(u[7], cospi8); v[0] = _mm_add_epi32(v[0], v[1]); v[0] = _mm_add_epi32(v[0], rnding); - out[2] = _mm_srai_epi32(v[0], bit); // buf0[4] + out[2] = _mm_srai_epi32(v[0], bit); // buf0[4] v[0] = _mm_mullo_epi32(u[4], cospi8); v[1] = _mm_mullo_epi32(u[7], cospi56); @@ -526,7 +525,7 @@ static void fdct8x8_sse4_1(__m128i *in, __m128i *out, int bit) { v[1] = _mm_mullo_epi32(u[6], cospi24); v[0] = _mm_sub_epi32(v[1], v[0]); v[0] = _mm_add_epi32(v[0], rnding); - out[6] = _mm_srai_epi32(v[0], bit); // buf0[6] + out[6] = _mm_srai_epi32(v[0], bit); // buf0[6] out[0] = u[0]; // buf0[0] out[8] = u[1]; // buf0[1] @@ -543,7 +542,7 @@ static void fdct8x8_sse4_1(__m128i *in, __m128i *out, int bit) { u[2] = _mm_add_epi32(in[5], in[11]); u[5] = _mm_sub_epi32(in[5], in[11]); u[3] = _mm_add_epi32(in[7], in[9]); - v[4] = _mm_sub_epi32(in[7], in[9]); // v[4] + v[4] = _mm_sub_epi32(in[7], in[9]); // v[4] // stage 2 v[0] = _mm_add_epi32(u[0], u[3]); @@ -599,7 +598,7 @@ static void fdct8x8_sse4_1(__m128i *in, __m128i *out, int bit) { v[1] = _mm_mullo_epi32(u[7], cospi8); v[0] = _mm_add_epi32(v[0], v[1]); v[0] = _mm_add_epi32(v[0], rnding); - out[3] = _mm_srai_epi32(v[0], bit); // buf0[4] + out[3] = _mm_srai_epi32(v[0], bit); // buf0[4] v[0] = _mm_mullo_epi32(u[4], cospi8); v[1] = _mm_mullo_epi32(u[7], cospi56); @@ -617,7 +616,7 @@ static void fdct8x8_sse4_1(__m128i *in, __m128i *out, int bit) { v[1] = _mm_mullo_epi32(u[6], cospi24); v[0] = _mm_sub_epi32(v[1], v[0]); v[0] = _mm_add_epi32(v[0], rnding); - out[7] = _mm_srai_epi32(v[0], bit); // buf0[6] + out[7] = _mm_srai_epi32(v[0], bit); // buf0[6] out[1] = u[0]; // buf0[0] out[9] = u[1]; // buf0[1] @@ -1026,8 +1025,7 @@ void vp10_fwd_txfm2d_8x8_sse4_1(const int16_t *input, int32_t *coeff, write_buffer_8x8(in, coeff); break; #endif // CONFIG_EXT_TX - default: - assert(0); + default: assert(0); } (void)bd; } @@ -1063,7 +1061,7 @@ static INLINE void convert_8x8_to_16x16(const __m128i *in, __m128i *out) { } while (row_index < 16); } -static INLINE void load_buffer_16x16(const int16_t* input, __m128i *out, +static INLINE void load_buffer_16x16(const int16_t *input, __m128i *out, int stride, int flipud, int fliplr, int shift) { __m128i in[64]; @@ -1077,20 +1075,28 @@ static INLINE void load_buffer_16x16(const int16_t* input, __m128i *out, if (flipud) { // Swap left columns - tmp = topL; topL = botL; botL = tmp; + tmp = topL; + topL = botL; + botL = tmp; // Swap right columns - tmp = topR; topR = botR; botR = tmp; + tmp = topR; + topR = botR; + botR = tmp; } if (fliplr) { // Swap top rows - tmp = topL; topL = topR; topR = tmp; + tmp = topL; + topL = topR; + topR = tmp; // Swap bottom rows - tmp = botL; botL = botR; botR = tmp; + tmp = botL; + botL = botR; + botR = tmp; } // load first 8 columns - load_buffer_8x8(topL, &in[0], stride, flipud, fliplr, shift); + load_buffer_8x8(topL, &in[0], stride, flipud, fliplr, shift); load_buffer_8x8(botL, &in[32], stride, flipud, fliplr, shift); // load second 8 columns @@ -1129,22 +1135,22 @@ static void fdct16x16_sse4_1(__m128i *in, __m128i *out, int bit) { for (col = 0; col < col_num; ++col) { // stage 0 // stage 1 - u[0] = _mm_add_epi32(in[0 * col_num + col], in[15 * col_num + col]); + u[0] = _mm_add_epi32(in[0 * col_num + col], in[15 * col_num + col]); u[15] = _mm_sub_epi32(in[0 * col_num + col], in[15 * col_num + col]); - u[1] = _mm_add_epi32(in[1 * col_num + col], in[14 * col_num + col]); + u[1] = _mm_add_epi32(in[1 * col_num + col], in[14 * col_num + col]); u[14] = _mm_sub_epi32(in[1 * col_num + col], in[14 * col_num + col]); - u[2] = _mm_add_epi32(in[2 * col_num + col], in[13 * col_num + col]); + u[2] = _mm_add_epi32(in[2 * col_num + col], in[13 * col_num + col]); u[13] = _mm_sub_epi32(in[2 * col_num + col], in[13 * col_num + col]); - u[3] = _mm_add_epi32(in[3 * col_num + col], in[12 * col_num + col]); + u[3] = _mm_add_epi32(in[3 * col_num + col], in[12 * col_num + col]); u[12] = _mm_sub_epi32(in[3 * col_num + col], in[12 * col_num + col]); - u[4] = _mm_add_epi32(in[4 * col_num + col], in[11 * col_num + col]); + u[4] = _mm_add_epi32(in[4 * col_num + col], in[11 * col_num + col]); u[11] = _mm_sub_epi32(in[4 * col_num + col], in[11 * col_num + col]); - u[5] = _mm_add_epi32(in[5 * col_num + col], in[10 * col_num + col]); + u[5] = _mm_add_epi32(in[5 * col_num + col], in[10 * col_num + col]); u[10] = _mm_sub_epi32(in[5 * col_num + col], in[10 * col_num + col]); - u[6] = _mm_add_epi32(in[6 * col_num + col], in[9 * col_num + col]); - u[9] = _mm_sub_epi32(in[6 * col_num + col], in[9 * col_num + col]); - u[7] = _mm_add_epi32(in[7 * col_num + col], in[8 * col_num + col]); - u[8] = _mm_sub_epi32(in[7 * col_num + col], in[8 * col_num + col]); + u[6] = _mm_add_epi32(in[6 * col_num + col], in[9 * col_num + col]); + u[9] = _mm_sub_epi32(in[6 * col_num + col], in[9 * col_num + col]); + u[7] = _mm_add_epi32(in[7 * col_num + col], in[8 * col_num + col]); + u[8] = _mm_sub_epi32(in[7 * col_num + col], in[8 * col_num + col]); // stage 2 v[0] = _mm_add_epi32(u[0], u[7]); @@ -1204,9 +1210,9 @@ static void fdct16x16_sse4_1(__m128i *in, __m128i *out, int bit) { u[6] = _mm_srai_epi32(u[6], bit); u[7] = v[7]; - u[8] = _mm_add_epi32(v[8], v[11]); + u[8] = _mm_add_epi32(v[8], v[11]); u[11] = _mm_sub_epi32(v[8], v[11]); - u[9] = _mm_add_epi32(v[9], v[10]); + u[9] = _mm_add_epi32(v[9], v[10]); u[10] = _mm_sub_epi32(v[9], v[10]); u[12] = _mm_sub_epi32(v[15], v[12]); u[15] = _mm_add_epi32(v[15], v[12]); @@ -1883,8 +1889,7 @@ void vp10_fwd_txfm2d_16x16_sse4_1(const int16_t *input, int32_t *coeff, write_buffer_16x16(in, coeff); break; #endif // CONFIG_EXT_TX - default: - assert(0); + default: assert(0); } (void)bd; } diff --git a/vp10/encoder/x86/quantize_sse2.c b/vp10/encoder/x86/quantize_sse2.c index dabd3bd12..b61989411 100644 --- a/vp10/encoder/x86/quantize_sse2.c +++ b/vp10/encoder/x86/quantize_sse2.c @@ -14,14 +14,13 @@ #include "./vp10_rtcd.h" #include "vpx/vpx_integer.h" -void vp10_quantize_fp_sse2(const int16_t* coeff_ptr, intptr_t n_coeffs, - int skip_block, const int16_t* zbin_ptr, - const int16_t* round_ptr, const int16_t* quant_ptr, - const int16_t* quant_shift_ptr, int16_t* qcoeff_ptr, - int16_t* dqcoeff_ptr, const int16_t* dequant_ptr, - uint16_t* eob_ptr, - const int16_t* scan_ptr, - const int16_t* iscan_ptr) { +void vp10_quantize_fp_sse2(const int16_t *coeff_ptr, intptr_t n_coeffs, + int skip_block, const int16_t *zbin_ptr, + const int16_t *round_ptr, const int16_t *quant_ptr, + const int16_t *quant_shift_ptr, int16_t *qcoeff_ptr, + int16_t *dqcoeff_ptr, const int16_t *dequant_ptr, + uint16_t *eob_ptr, const int16_t *scan_ptr, + const int16_t *iscan_ptr) { __m128i zero; __m128i thr; int16_t nzflag; @@ -44,9 +43,9 @@ void vp10_quantize_fp_sse2(const int16_t* coeff_ptr, intptr_t n_coeffs, // Setup global values { - round = _mm_load_si128((const __m128i*)round_ptr); - quant = _mm_load_si128((const __m128i*)quant_ptr); - dequant = _mm_load_si128((const __m128i*)dequant_ptr); + round = _mm_load_si128((const __m128i *)round_ptr); + quant = _mm_load_si128((const __m128i *)quant_ptr); + dequant = _mm_load_si128((const __m128i *)dequant_ptr); } { @@ -54,8 +53,8 @@ void vp10_quantize_fp_sse2(const int16_t* coeff_ptr, intptr_t n_coeffs, __m128i qcoeff0, qcoeff1; __m128i qtmp0, qtmp1; // Do DC and first 15 AC - coeff0 = _mm_load_si128((const __m128i*)(coeff_ptr + n_coeffs)); - coeff1 = _mm_load_si128((const __m128i*)(coeff_ptr + n_coeffs) + 1); + coeff0 = _mm_load_si128((const __m128i *)(coeff_ptr + n_coeffs)); + coeff1 = _mm_load_si128((const __m128i *)(coeff_ptr + n_coeffs) + 1); // Poor man's sign extract coeff0_sign = _mm_srai_epi16(coeff0, 15); @@ -78,15 +77,15 @@ void vp10_quantize_fp_sse2(const int16_t* coeff_ptr, intptr_t n_coeffs, qcoeff0 = _mm_sub_epi16(qcoeff0, coeff0_sign); qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs), qcoeff0); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs), qcoeff0); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); coeff0 = _mm_mullo_epi16(qcoeff0, dequant); dequant = _mm_unpackhi_epi64(dequant, dequant); coeff1 = _mm_mullo_epi16(qcoeff1, dequant); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs), coeff0); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs) + 1, coeff1); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs), coeff0); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs) + 1, coeff1); } { @@ -99,8 +98,8 @@ void vp10_quantize_fp_sse2(const int16_t* coeff_ptr, intptr_t n_coeffs, zero_coeff1 = _mm_cmpeq_epi16(coeff1, zero); nzero_coeff0 = _mm_cmpeq_epi16(zero_coeff0, zero); nzero_coeff1 = _mm_cmpeq_epi16(zero_coeff1, zero); - iscan0 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs)); - iscan1 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs) + 1); + iscan0 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs)); + iscan1 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs) + 1); // Add one to convert from indices to counts iscan0 = _mm_sub_epi16(iscan0, nzero_coeff0); iscan1 = _mm_sub_epi16(iscan1, nzero_coeff1); @@ -121,8 +120,8 @@ void vp10_quantize_fp_sse2(const int16_t* coeff_ptr, intptr_t n_coeffs, __m128i qcoeff0, qcoeff1; __m128i qtmp0, qtmp1; - coeff0 = _mm_load_si128((const __m128i*)(coeff_ptr + n_coeffs)); - coeff1 = _mm_load_si128((const __m128i*)(coeff_ptr + n_coeffs) + 1); + coeff0 = _mm_load_si128((const __m128i *)(coeff_ptr + n_coeffs)); + coeff1 = _mm_load_si128((const __m128i *)(coeff_ptr + n_coeffs) + 1); // Poor man's sign extract coeff0_sign = _mm_srai_epi16(coeff0, 15); @@ -133,7 +132,7 @@ void vp10_quantize_fp_sse2(const int16_t* coeff_ptr, intptr_t n_coeffs, qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign); nzflag = _mm_movemask_epi8(_mm_cmpgt_epi16(qcoeff0, thr)) | - _mm_movemask_epi8(_mm_cmpgt_epi16(qcoeff1, thr)); + _mm_movemask_epi8(_mm_cmpgt_epi16(qcoeff1, thr)); if (nzflag) { qcoeff0 = _mm_adds_epi16(qcoeff0, round); @@ -147,20 +146,20 @@ void vp10_quantize_fp_sse2(const int16_t* coeff_ptr, intptr_t n_coeffs, qcoeff0 = _mm_sub_epi16(qcoeff0, coeff0_sign); qcoeff1 = _mm_sub_epi16(qcoeff1, coeff1_sign); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs), qcoeff0); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs), qcoeff0); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs) + 1, qcoeff1); coeff0 = _mm_mullo_epi16(qcoeff0, dequant); coeff1 = _mm_mullo_epi16(qcoeff1, dequant); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs), coeff0); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs) + 1, coeff1); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs), coeff0); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs) + 1, coeff1); } else { - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs), zero); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs) + 1, zero); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs), zero); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs) + 1, zero); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs), zero); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs) + 1, zero); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs), zero); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs) + 1, zero); } } @@ -174,8 +173,8 @@ void vp10_quantize_fp_sse2(const int16_t* coeff_ptr, intptr_t n_coeffs, zero_coeff1 = _mm_cmpeq_epi16(coeff1, zero); nzero_coeff0 = _mm_cmpeq_epi16(zero_coeff0, zero); nzero_coeff1 = _mm_cmpeq_epi16(zero_coeff1, zero); - iscan0 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs)); - iscan1 = _mm_load_si128((const __m128i*)(iscan_ptr + n_coeffs) + 1); + iscan0 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs)); + iscan1 = _mm_load_si128((const __m128i *)(iscan_ptr + n_coeffs) + 1); // Add one to convert from indices to counts iscan0 = _mm_sub_epi16(iscan0, nzero_coeff0); iscan1 = _mm_sub_epi16(iscan1, nzero_coeff1); @@ -200,10 +199,10 @@ void vp10_quantize_fp_sse2(const int16_t* coeff_ptr, intptr_t n_coeffs, } } else { do { - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs), zero); - _mm_store_si128((__m128i*)(dqcoeff_ptr + n_coeffs) + 1, zero); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs), zero); - _mm_store_si128((__m128i*)(qcoeff_ptr + n_coeffs) + 1, zero); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs), zero); + _mm_store_si128((__m128i *)(dqcoeff_ptr + n_coeffs) + 1, zero); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs), zero); + _mm_store_si128((__m128i *)(qcoeff_ptr + n_coeffs) + 1, zero); n_coeffs += 8 * 2; } while (n_coeffs < 0); *eob_ptr = 0; diff --git a/vp10/encoder/x86/vp10_highbd_quantize_sse4.c b/vp10/encoder/x86/vp10_highbd_quantize_sse4.c index c9ad5d025..c49247b9a 100644 --- a/vp10/encoder/x86/vp10_highbd_quantize_sse4.c +++ b/vp10/encoder/x86/vp10_highbd_quantize_sse4.c @@ -106,20 +106,12 @@ static INLINE uint16_t get_accumulated_eob(__m128i *eob) { return eobValue; } -void vp10_highbd_quantize_fp_sse4_1(const tran_low_t *coeff_ptr, - intptr_t count, - int skip_block, - const int16_t *zbin_ptr, - const int16_t *round_ptr, - const int16_t *quant_ptr, - const int16_t *quant_shift_ptr, - tran_low_t *qcoeff_ptr, - tran_low_t *dqcoeff_ptr, - const int16_t *dequant_ptr, - uint16_t *eob_ptr, - const int16_t *scan, - const int16_t *iscan, - int log_scale) { +void vp10_highbd_quantize_fp_sse4_1( + const tran_low_t *coeff_ptr, intptr_t count, int skip_block, + const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, + const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, + tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, + const int16_t *scan, const int16_t *iscan, int log_scale) { __m128i coeff[2], qcoeff[2], dequant[2], qparam[3], coeff_sign; __m128i eob = _mm_setzero_si128(); const tran_low_t *src = coeff_ptr; @@ -139,14 +131,14 @@ void vp10_highbd_quantize_fp_sse4_1(const tran_low_t *coeff_ptr, if (!skip_block) { coeff[0] = _mm_loadu_si128((__m128i const *)src); - qparam[0] = _mm_set_epi32(round_ptr[1], round_ptr[1], round_ptr[1], - round_ptr[0]); + qparam[0] = + _mm_set_epi32(round_ptr[1], round_ptr[1], round_ptr[1], round_ptr[0]); qparam[1] = _mm_set_epi64x(quant_ptr[1], quant_ptr[0]); qparam[2] = _mm_set_epi64x(dequant_ptr[1], dequant_ptr[0]); // DC and first 3 AC - quantize_coeff_phase1(&coeff[0], qparam, shift, log_scale, - qcoeff, dequant, &coeff_sign); + quantize_coeff_phase1(&coeff[0], qparam, shift, log_scale, qcoeff, dequant, + &coeff_sign); // update round/quan/dquan for AC qparam[0] = _mm_unpackhi_epi64(qparam[0], qparam[0]); @@ -158,8 +150,8 @@ void vp10_highbd_quantize_fp_sse4_1(const tran_low_t *coeff_ptr, // next 4 AC coeff[1] = _mm_loadu_si128((__m128i const *)(src + coeff_stride)); - quantize_coeff_phase1(&coeff[1], qparam, shift, log_scale, - qcoeff, dequant, &coeff_sign); + quantize_coeff_phase1(&coeff[1], qparam, shift, log_scale, qcoeff, dequant, + &coeff_sign); quantize_coeff_phase2(qcoeff, dequant, &coeff_sign, qparam, shift, log_scale, quanAddr + quan_stride, dquanAddr + quan_stride); diff --git a/vp10/encoder/x86/wedge_utils_sse2.c b/vp10/encoder/x86/wedge_utils_sse2.c index b881d5832..19bef91a3 100644 --- a/vp10/encoder/x86/wedge_utils_sse2.c +++ b/vp10/encoder/x86/wedge_utils_sse2.c @@ -17,15 +17,13 @@ #include "vp10/common/reconinter.h" -#define MAX_MASK_VALUE (1 << WEDGE_WEIGHT_BITS) +#define MAX_MASK_VALUE (1 << WEDGE_WEIGHT_BITS) /** * See vp10_wedge_sse_from_residuals_c */ -uint64_t vp10_wedge_sse_from_residuals_sse2(const int16_t *r1, - const int16_t *d, - const uint8_t *m, - int N) { +uint64_t vp10_wedge_sse_from_residuals_sse2(const int16_t *r1, const int16_t *d, + const uint8_t *m, int N) { int n = -N; int n8 = n + 8; @@ -98,10 +96,8 @@ uint64_t vp10_wedge_sse_from_residuals_sse2(const int16_t *r1, /** * See vp10_wedge_sign_from_residuals_c */ -int vp10_wedge_sign_from_residuals_sse2(const int16_t *ds, - const uint8_t *m, - int N, - int64_t limit) { +int vp10_wedge_sign_from_residuals_sse2(const int16_t *ds, const uint8_t *m, + int N, int64_t limit) { int64_t acc; __m128i v_sign_d; @@ -167,11 +163,11 @@ int vp10_wedge_sign_from_residuals_sse2(const int16_t *ds, v_sign_d = _mm_cmplt_epi32(v_acc0_d, _mm_setzero_si128()); v_acc0_d = _mm_add_epi64(_mm_unpacklo_epi32(v_acc0_d, v_sign_d), - _mm_unpackhi_epi32(v_acc0_d, v_sign_d)); + _mm_unpackhi_epi32(v_acc0_d, v_sign_d)); v_sign_d = _mm_cmplt_epi32(v_acc1_d, _mm_setzero_si128()); v_acc1_d = _mm_add_epi64(_mm_unpacklo_epi32(v_acc1_d, v_sign_d), - _mm_unpackhi_epi32(v_acc1_d, v_sign_d)); + _mm_unpackhi_epi32(v_acc1_d, v_sign_d)); v_acc_q = _mm_add_epi64(v_acc0_d, v_acc1_d); @@ -194,12 +190,10 @@ static INLINE __m128i negm_epi16(__m128i v_v_w, __m128i v_mask_w) { /** * vp10_wedge_compute_delta_squares_c */ -void vp10_wedge_compute_delta_squares_sse2(int16_t *d, - const int16_t *a, - const int16_t *b, - int N) { - const __m128i v_neg_w = _mm_set_epi16(0xffff, 0, 0xffff, 0, - 0xffff, 0, 0xffff, 0); +void vp10_wedge_compute_delta_squares_sse2(int16_t *d, const int16_t *a, + const int16_t *b, int N) { + const __m128i v_neg_w = + _mm_set_epi16(0xffff, 0, 0xffff, 0, 0xffff, 0, 0xffff, 0); assert(N % 64 == 0); @@ -257,4 +251,3 @@ void vp10_wedge_compute_delta_squares_sse2(int16_t *d, N -= 32; } while (N); } -