| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2006 } | 2006 } |
| 2007 } | 2007 } |
| 2008 | 2008 |
| 2009 static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, | 2009 static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, |
| 2010 BLOCK_SIZE bsize, | 2010 BLOCK_SIZE bsize, |
| 2011 int64_t txfm_cache[], | 2011 int64_t txfm_cache[], |
| 2012 int *rate2, int64_t *distortion, | 2012 int *rate2, int64_t *distortion, |
| 2013 int *skippable, | 2013 int *skippable, |
| 2014 int *rate_y, int64_t *distortion_y, | 2014 int *rate_y, int64_t *distortion_y, |
| 2015 int *rate_uv, int64_t *distortion_uv, | 2015 int *rate_uv, int64_t *distortion_uv, |
| 2016 int *mode_excluded, int *disable_skip, | 2016 int *disable_skip, |
| 2017 INTERP_FILTER *best_filter, | |
| 2018 int_mv (*mode_mv)[MAX_REF_FRAMES], | 2017 int_mv (*mode_mv)[MAX_REF_FRAMES], |
| 2019 int mi_row, int mi_col, | 2018 int mi_row, int mi_col, |
| 2020 int_mv single_newmv[MAX_REF_FRAMES], | 2019 int_mv single_newmv[MAX_REF_FRAMES], |
| 2021 int64_t *psse, | 2020 int64_t *psse, |
| 2022 const int64_t ref_best_rd) { | 2021 const int64_t ref_best_rd) { |
| 2023 VP9_COMMON *cm = &cpi->common; | 2022 VP9_COMMON *cm = &cpi->common; |
| 2024 RD_OPT *rd_opt = &cpi->rd; | 2023 RD_OPT *rd_opt = &cpi->rd; |
| 2025 MACROBLOCKD *xd = &x->e_mbd; | 2024 MACROBLOCKD *xd = &x->e_mbd; |
| 2026 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; | 2025 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; |
| 2027 const int is_comp_pred = has_second_ref(mbmi); | 2026 const int is_comp_pred = has_second_ref(mbmi); |
| 2028 const int num_refs = is_comp_pred ? 2 : 1; | |
| 2029 const int this_mode = mbmi->mode; | 2027 const int this_mode = mbmi->mode; |
| 2030 int_mv *frame_mv = mode_mv[this_mode]; | 2028 int_mv *frame_mv = mode_mv[this_mode]; |
| 2031 int i; | 2029 int i; |
| 2032 int refs[2] = { mbmi->ref_frame[0], | 2030 int refs[2] = { mbmi->ref_frame[0], |
| 2033 (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) }; | 2031 (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) }; |
| 2034 int_mv cur_mv[2]; | 2032 int_mv cur_mv[2]; |
| 2035 int64_t this_rd = 0; | 2033 int64_t this_rd = 0; |
| 2036 DECLARE_ALIGNED_ARRAY(16, uint8_t, tmp_buf, MAX_MB_PLANE * 64 * 64); | 2034 DECLARE_ALIGNED_ARRAY(16, uint8_t, tmp_buf, MAX_MB_PLANE * 64 * 64); |
| 2037 int pred_exists = 0; | 2035 int pred_exists = 0; |
| 2038 int intpel_mv; | 2036 int intpel_mv; |
| 2039 int64_t rd, best_rd = INT64_MAX; | 2037 int64_t rd, best_rd = INT64_MAX; |
| 2040 int best_needs_copy = 0; | 2038 int best_needs_copy = 0; |
| 2041 uint8_t *orig_dst[MAX_MB_PLANE]; | 2039 uint8_t *orig_dst[MAX_MB_PLANE]; |
| 2042 int orig_dst_stride[MAX_MB_PLANE]; | 2040 int orig_dst_stride[MAX_MB_PLANE]; |
| 2043 int rs = 0; | 2041 int rs = 0; |
| 2042 INTERP_FILTER best_filter = SWITCHABLE; |
| 2043 |
| 2044 int bsl = mi_width_log2_lookup[bsize]; |
| 2045 int pred_filter_search = cpi->sf.cb_pred_filter_search ? |
| 2046 (((mi_row + mi_col) >> bsl)) & 0x01 : 0; |
| 2047 |
| 2048 if (pred_filter_search) { |
| 2049 INTERP_FILTER af = SWITCHABLE, lf = SWITCHABLE; |
| 2050 if (xd->up_available) |
| 2051 af = xd->mi[-xd->mi_stride]->mbmi.interp_filter; |
| 2052 if (xd->left_available) |
| 2053 lf = xd->mi[-1]->mbmi.interp_filter; |
| 2054 |
| 2055 if ((this_mode != NEWMV) || (af == lf)) |
| 2056 best_filter = af; |
| 2057 } |
| 2044 | 2058 |
| 2045 if (is_comp_pred) { | 2059 if (is_comp_pred) { |
| 2046 if (frame_mv[refs[0]].as_int == INVALID_MV || | 2060 if (frame_mv[refs[0]].as_int == INVALID_MV || |
| 2047 frame_mv[refs[1]].as_int == INVALID_MV) | 2061 frame_mv[refs[1]].as_int == INVALID_MV) |
| 2048 return INT64_MAX; | 2062 return INT64_MAX; |
| 2049 } | 2063 } |
| 2050 | 2064 |
| 2051 if (this_mode == NEWMV) { | 2065 if (this_mode == NEWMV) { |
| 2052 int rate_mv; | 2066 int rate_mv; |
| 2053 if (is_comp_pred) { | 2067 if (is_comp_pred) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2073 &tmp_mv, &rate_mv); | 2087 &tmp_mv, &rate_mv); |
| 2074 if (tmp_mv.as_int == INVALID_MV) | 2088 if (tmp_mv.as_int == INVALID_MV) |
| 2075 return INT64_MAX; | 2089 return INT64_MAX; |
| 2076 *rate2 += rate_mv; | 2090 *rate2 += rate_mv; |
| 2077 frame_mv[refs[0]].as_int = | 2091 frame_mv[refs[0]].as_int = |
| 2078 xd->mi[0]->bmi[0].as_mv[0].as_int = tmp_mv.as_int; | 2092 xd->mi[0]->bmi[0].as_mv[0].as_int = tmp_mv.as_int; |
| 2079 single_newmv[refs[0]].as_int = tmp_mv.as_int; | 2093 single_newmv[refs[0]].as_int = tmp_mv.as_int; |
| 2080 } | 2094 } |
| 2081 } | 2095 } |
| 2082 | 2096 |
| 2083 for (i = 0; i < num_refs; ++i) { | 2097 for (i = 0; i < is_comp_pred + 1; ++i) { |
| 2084 cur_mv[i] = frame_mv[refs[i]]; | 2098 cur_mv[i] = frame_mv[refs[i]]; |
| 2085 // Clip "next_nearest" so that it does not extend to far out of image | 2099 // Clip "next_nearest" so that it does not extend to far out of image |
| 2086 if (this_mode != NEWMV) | 2100 if (this_mode != NEWMV) |
| 2087 clamp_mv2(&cur_mv[i].as_mv, xd); | 2101 clamp_mv2(&cur_mv[i].as_mv, xd); |
| 2088 | 2102 |
| 2089 if (mv_check_bounds(x, &cur_mv[i].as_mv)) | 2103 if (mv_check_bounds(x, &cur_mv[i].as_mv)) |
| 2090 return INT64_MAX; | 2104 return INT64_MAX; |
| 2091 mbmi->mv[i].as_int = cur_mv[i].as_int; | 2105 mbmi->mv[i].as_int = cur_mv[i].as_int; |
| 2092 } | 2106 } |
| 2093 | 2107 |
| 2094 // do first prediction into the destination buffer. Do the next | 2108 // do first prediction into the destination buffer. Do the next |
| 2095 // prediction into a temporary buffer. Then keep track of which one | 2109 // prediction into a temporary buffer. Then keep track of which one |
| 2096 // of these currently holds the best predictor, and use the other | 2110 // of these currently holds the best predictor, and use the other |
| 2097 // one for future predictions. In the end, copy from tmp_buf to | 2111 // one for future predictions. In the end, copy from tmp_buf to |
| 2098 // dst if necessary. | 2112 // dst if necessary. |
| 2099 for (i = 0; i < MAX_MB_PLANE; i++) { | 2113 for (i = 0; i < MAX_MB_PLANE; i++) { |
| 2100 orig_dst[i] = xd->plane[i].dst.buf; | 2114 orig_dst[i] = xd->plane[i].dst.buf; |
| 2101 orig_dst_stride[i] = xd->plane[i].dst.stride; | 2115 orig_dst_stride[i] = xd->plane[i].dst.stride; |
| 2102 } | 2116 } |
| 2103 | 2117 |
| 2104 /* We don't include the cost of the second reference here, because there | 2118 /* We don't include the cost of the second reference here, because there |
| 2105 * are only three options: Last/Golden, ARF/Last or Golden/ARF, or in other | 2119 * are only three options: Last/Golden, ARF/Last or Golden/ARF, or in other |
| 2106 * words if you present them in that order, the second one is always known | 2120 * words if you present them in that order, the second one is always known |
| 2107 * if the first is known */ | 2121 * if the first is known */ |
| 2108 *rate2 += cost_mv_ref(cpi, this_mode, mbmi->mode_context[refs[0]]); | 2122 *rate2 += cost_mv_ref(cpi, this_mode, mbmi->mode_context[refs[0]]); |
| 2109 | 2123 |
| 2110 if (!(*mode_excluded)) | |
| 2111 *mode_excluded = is_comp_pred ? cm->reference_mode == SINGLE_REFERENCE | |
| 2112 : cm->reference_mode == COMPOUND_REFERENCE; | |
| 2113 | |
| 2114 pred_exists = 0; | 2124 pred_exists = 0; |
| 2115 // Are all MVs integer pel for Y and UV | 2125 // Are all MVs integer pel for Y and UV |
| 2116 intpel_mv = !mv_has_subpel(&mbmi->mv[0].as_mv); | 2126 intpel_mv = !mv_has_subpel(&mbmi->mv[0].as_mv); |
| 2117 if (is_comp_pred) | 2127 if (is_comp_pred) |
| 2118 intpel_mv &= !mv_has_subpel(&mbmi->mv[1].as_mv); | 2128 intpel_mv &= !mv_has_subpel(&mbmi->mv[1].as_mv); |
| 2119 | 2129 |
| 2120 // Search for best switchable filter by checking the variance of | 2130 // Search for best switchable filter by checking the variance of |
| 2121 // pred error irrespective of whether the filter will be used | 2131 // pred error irrespective of whether the filter will be used |
| 2122 rd_opt->mask_filter = 0; | 2132 rd_opt->mask_filter = 0; |
| 2123 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) | 2133 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) |
| 2124 rd_opt->filter_cache[i] = INT64_MAX; | 2134 rd_opt->filter_cache[i] = INT64_MAX; |
| 2125 | 2135 |
| 2126 if (cm->interp_filter != BILINEAR) { | 2136 if (cm->interp_filter != BILINEAR) { |
| 2127 *best_filter = EIGHTTAP; | |
| 2128 if (x->source_variance < cpi->sf.disable_filter_search_var_thresh) { | 2137 if (x->source_variance < cpi->sf.disable_filter_search_var_thresh) { |
| 2129 *best_filter = EIGHTTAP; | 2138 best_filter = EIGHTTAP; |
| 2130 } else { | 2139 } else if (best_filter == SWITCHABLE) { |
| 2131 int newbest; | 2140 int newbest; |
| 2132 int tmp_rate_sum = 0; | 2141 int tmp_rate_sum = 0; |
| 2133 int64_t tmp_dist_sum = 0; | 2142 int64_t tmp_dist_sum = 0; |
| 2134 | 2143 |
| 2135 for (i = 0; i < SWITCHABLE_FILTERS; ++i) { | 2144 for (i = 0; i < SWITCHABLE_FILTERS; ++i) { |
| 2136 int j; | 2145 int j; |
| 2137 int64_t rs_rd; | 2146 int64_t rs_rd; |
| 2138 mbmi->interp_filter = i; | 2147 mbmi->interp_filter = i; |
| 2139 rs = vp9_get_switchable_rate(cpi); | 2148 rs = vp9_get_switchable_rate(cpi); |
| 2140 rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0); | 2149 rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2182 if (i == 0 && cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) { | 2191 if (i == 0 && cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) { |
| 2183 if (rd / 2 > ref_best_rd) { | 2192 if (rd / 2 > ref_best_rd) { |
| 2184 restore_dst_buf(xd, orig_dst, orig_dst_stride); | 2193 restore_dst_buf(xd, orig_dst, orig_dst_stride); |
| 2185 return INT64_MAX; | 2194 return INT64_MAX; |
| 2186 } | 2195 } |
| 2187 } | 2196 } |
| 2188 newbest = i == 0 || rd < best_rd; | 2197 newbest = i == 0 || rd < best_rd; |
| 2189 | 2198 |
| 2190 if (newbest) { | 2199 if (newbest) { |
| 2191 best_rd = rd; | 2200 best_rd = rd; |
| 2192 *best_filter = mbmi->interp_filter; | 2201 best_filter = mbmi->interp_filter; |
| 2193 if (cm->interp_filter == SWITCHABLE && i && !intpel_mv) | 2202 if (cm->interp_filter == SWITCHABLE && i && !intpel_mv) |
| 2194 best_needs_copy = !best_needs_copy; | 2203 best_needs_copy = !best_needs_copy; |
| 2195 } | 2204 } |
| 2196 | 2205 |
| 2197 if ((cm->interp_filter == SWITCHABLE && newbest) || | 2206 if ((cm->interp_filter == SWITCHABLE && newbest) || |
| 2198 (cm->interp_filter != SWITCHABLE && | 2207 (cm->interp_filter != SWITCHABLE && |
| 2199 cm->interp_filter == mbmi->interp_filter)) { | 2208 cm->interp_filter == mbmi->interp_filter)) { |
| 2200 pred_exists = 1; | 2209 pred_exists = 1; |
| 2201 } | 2210 } |
| 2202 } | 2211 } |
| 2203 restore_dst_buf(xd, orig_dst, orig_dst_stride); | 2212 restore_dst_buf(xd, orig_dst, orig_dst_stride); |
| 2204 } | 2213 } |
| 2205 } | 2214 } |
| 2206 // Set the appropriate filter | 2215 // Set the appropriate filter |
| 2207 mbmi->interp_filter = cm->interp_filter != SWITCHABLE ? | 2216 mbmi->interp_filter = cm->interp_filter != SWITCHABLE ? |
| 2208 cm->interp_filter : *best_filter; | 2217 cm->interp_filter : best_filter; |
| 2209 rs = cm->interp_filter == SWITCHABLE ? vp9_get_switchable_rate(cpi) : 0; | 2218 rs = cm->interp_filter == SWITCHABLE ? vp9_get_switchable_rate(cpi) : 0; |
| 2210 | 2219 |
| 2211 if (pred_exists) { | 2220 if (pred_exists) { |
| 2212 if (best_needs_copy) { | 2221 if (best_needs_copy) { |
| 2213 // again temporarily set the buffers to local memory to prevent a memcpy | 2222 // again temporarily set the buffers to local memory to prevent a memcpy |
| 2214 for (i = 0; i < MAX_MB_PLANE; i++) { | 2223 for (i = 0; i < MAX_MB_PLANE; i++) { |
| 2215 xd->plane[i].dst.buf = tmp_buf + i * 64 * 64; | 2224 xd->plane[i].dst.buf = tmp_buf + i * 64 * 64; |
| 2216 xd->plane[i].dst.stride = 64; | 2225 xd->plane[i].dst.stride = 64; |
| 2217 } | 2226 } |
| 2218 } | 2227 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2473 int64_t best_filter_rd[SWITCHABLE_FILTER_CONTEXTS]; | 2482 int64_t best_filter_rd[SWITCHABLE_FILTER_CONTEXTS]; |
| 2474 int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; | 2483 int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; |
| 2475 MB_MODE_INFO best_mbmode; | 2484 MB_MODE_INFO best_mbmode; |
| 2476 int mode_index, best_mode_index = -1; | 2485 int mode_index, best_mode_index = -1; |
| 2477 unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES]; | 2486 unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES]; |
| 2478 vp9_prob comp_mode_p; | 2487 vp9_prob comp_mode_p; |
| 2479 int64_t best_intra_rd = INT64_MAX; | 2488 int64_t best_intra_rd = INT64_MAX; |
| 2480 int64_t best_inter_rd = INT64_MAX; | 2489 int64_t best_inter_rd = INT64_MAX; |
| 2481 PREDICTION_MODE best_intra_mode = DC_PRED; | 2490 PREDICTION_MODE best_intra_mode = DC_PRED; |
| 2482 MV_REFERENCE_FRAME best_inter_ref_frame = LAST_FRAME; | 2491 MV_REFERENCE_FRAME best_inter_ref_frame = LAST_FRAME; |
| 2483 INTERP_FILTER tmp_best_filter = SWITCHABLE; | |
| 2484 int rate_uv_intra[TX_SIZES], rate_uv_tokenonly[TX_SIZES]; | 2492 int rate_uv_intra[TX_SIZES], rate_uv_tokenonly[TX_SIZES]; |
| 2485 int64_t dist_uv[TX_SIZES]; | 2493 int64_t dist_uv[TX_SIZES]; |
| 2486 int skip_uv[TX_SIZES]; | 2494 int skip_uv[TX_SIZES]; |
| 2487 PREDICTION_MODE mode_uv[TX_SIZES]; | 2495 PREDICTION_MODE mode_uv[TX_SIZES]; |
| 2488 int64_t mode_distortions[MB_MODE_COUNT] = {-1}; | 2496 int64_t mode_distortions[MB_MODE_COUNT] = {-1}; |
| 2489 int intra_cost_penalty = 20 * vp9_dc_quant(cm->base_qindex, cm->y_dc_delta_q); | 2497 int intra_cost_penalty = 20 * vp9_dc_quant(cm->base_qindex, cm->y_dc_delta_q); |
| 2490 const int bws = num_8x8_blocks_wide_lookup[bsize] / 2; | 2498 const int bws = num_8x8_blocks_wide_lookup[bsize] / 2; |
| 2491 const int bhs = num_8x8_blocks_high_lookup[bsize] / 2; | 2499 const int bhs = num_8x8_blocks_high_lookup[bsize] / 2; |
| 2492 int best_skip2 = 0; | 2500 int best_skip2 = 0; |
| 2493 int mode_skip_mask = 0; | 2501 int mode_skip_mask = 0; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2736 rate2 = rate_y + cpi->mbmode_cost[mbmi->mode] + rate_uv_intra[uv_tx]; | 2744 rate2 = rate_y + cpi->mbmode_cost[mbmi->mode] + rate_uv_intra[uv_tx]; |
| 2737 if (this_mode != DC_PRED && this_mode != TM_PRED) | 2745 if (this_mode != DC_PRED && this_mode != TM_PRED) |
| 2738 rate2 += intra_cost_penalty; | 2746 rate2 += intra_cost_penalty; |
| 2739 distortion2 = distortion_y + distortion_uv; | 2747 distortion2 = distortion_y + distortion_uv; |
| 2740 } else { | 2748 } else { |
| 2741 this_rd = handle_inter_mode(cpi, x, bsize, | 2749 this_rd = handle_inter_mode(cpi, x, bsize, |
| 2742 tx_cache, | 2750 tx_cache, |
| 2743 &rate2, &distortion2, &skippable, | 2751 &rate2, &distortion2, &skippable, |
| 2744 &rate_y, &distortion_y, | 2752 &rate_y, &distortion_y, |
| 2745 &rate_uv, &distortion_uv, | 2753 &rate_uv, &distortion_uv, |
| 2746 &mode_excluded, &disable_skip, | 2754 &disable_skip, frame_mv, |
| 2747 &tmp_best_filter, frame_mv, | |
| 2748 mi_row, mi_col, | 2755 mi_row, mi_col, |
| 2749 single_newmv, &total_sse, best_rd); | 2756 single_newmv, &total_sse, best_rd); |
| 2750 if (this_rd == INT64_MAX) | 2757 if (this_rd == INT64_MAX) |
| 2751 continue; | 2758 continue; |
| 2752 | 2759 |
| 2753 compmode_cost = vp9_cost_bit(comp_mode_p, comp_pred); | 2760 compmode_cost = vp9_cost_bit(comp_mode_p, comp_pred); |
| 2754 | 2761 |
| 2755 if (cm->reference_mode == REFERENCE_MODE_SELECT) | 2762 if (cm->reference_mode == REFERENCE_MODE_SELECT) |
| 2756 rate2 += compmode_cost; | 2763 rate2 += compmode_cost; |
| 2757 } | 2764 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3012 int64_t vp9_rd_pick_inter_mode_sb_seg_skip(VP9_COMP *cpi, MACROBLOCK *x, | 3019 int64_t vp9_rd_pick_inter_mode_sb_seg_skip(VP9_COMP *cpi, MACROBLOCK *x, |
| 3013 int *returnrate, | 3020 int *returnrate, |
| 3014 int64_t *returndistortion, | 3021 int64_t *returndistortion, |
| 3015 BLOCK_SIZE bsize, | 3022 BLOCK_SIZE bsize, |
| 3016 PICK_MODE_CONTEXT *ctx, | 3023 PICK_MODE_CONTEXT *ctx, |
| 3017 int64_t best_rd_so_far) { | 3024 int64_t best_rd_so_far) { |
| 3018 VP9_COMMON *const cm = &cpi->common; | 3025 VP9_COMMON *const cm = &cpi->common; |
| 3019 RD_OPT *const rd_opt = &cpi->rd; | 3026 RD_OPT *const rd_opt = &cpi->rd; |
| 3020 MACROBLOCKD *const xd = &x->e_mbd; | 3027 MACROBLOCKD *const xd = &x->e_mbd; |
| 3021 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; | 3028 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; |
| 3022 const struct segmentation *const seg = &cm->seg; | |
| 3023 unsigned char segment_id = mbmi->segment_id; | 3029 unsigned char segment_id = mbmi->segment_id; |
| 3024 const int comp_pred = 0; | 3030 const int comp_pred = 0; |
| 3025 int i; | 3031 int i; |
| 3026 int64_t best_tx_diff[TX_MODES]; | 3032 int64_t best_tx_diff[TX_MODES]; |
| 3027 int64_t best_pred_diff[REFERENCE_MODES]; | 3033 int64_t best_pred_diff[REFERENCE_MODES]; |
| 3028 int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; | 3034 int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; |
| 3029 unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES]; | 3035 unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES]; |
| 3030 vp9_prob comp_mode_p; | 3036 vp9_prob comp_mode_p; |
| 3031 INTERP_FILTER best_filter = SWITCHABLE; | 3037 INTERP_FILTER best_filter = SWITCHABLE; |
| 3032 int64_t this_rd = INT64_MAX; | 3038 int64_t this_rd = INT64_MAX; |
| 3033 int rate2 = 0; | 3039 int rate2 = 0; |
| 3034 const int64_t distortion2 = 0; | 3040 const int64_t distortion2 = 0; |
| 3035 | 3041 |
| 3036 x->skip_encode = cpi->sf.skip_encode_frame && x->q_index < QIDX_SKIP_THRESH; | 3042 x->skip_encode = cpi->sf.skip_encode_frame && x->q_index < QIDX_SKIP_THRESH; |
| 3037 | 3043 |
| 3038 estimate_ref_frame_costs(cm, xd, segment_id, ref_costs_single, ref_costs_comp, | 3044 estimate_ref_frame_costs(cm, xd, segment_id, ref_costs_single, ref_costs_comp, |
| 3039 &comp_mode_p); | 3045 &comp_mode_p); |
| 3040 | 3046 |
| 3041 for (i = 0; i < MAX_REF_FRAMES; ++i) | 3047 for (i = 0; i < MAX_REF_FRAMES; ++i) |
| 3042 x->pred_sse[i] = INT_MAX; | 3048 x->pred_sse[i] = INT_MAX; |
| 3043 for (i = LAST_FRAME; i < MAX_REF_FRAMES; ++i) | 3049 for (i = LAST_FRAME; i < MAX_REF_FRAMES; ++i) |
| 3044 x->pred_mv_sad[i] = INT_MAX; | 3050 x->pred_mv_sad[i] = INT_MAX; |
| 3045 | 3051 |
| 3046 *returnrate = INT_MAX; | 3052 *returnrate = INT_MAX; |
| 3047 | 3053 |
| 3048 assert(vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)); | 3054 assert(vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)); |
| 3049 | 3055 |
| 3050 mbmi->mode = ZEROMV; | 3056 mbmi->mode = ZEROMV; |
| 3051 mbmi->uv_mode = DC_PRED; | 3057 mbmi->uv_mode = DC_PRED; |
| 3052 mbmi->ref_frame[0] = LAST_FRAME; | 3058 mbmi->ref_frame[0] = LAST_FRAME; |
| 3053 mbmi->ref_frame[1] = NONE; | 3059 mbmi->ref_frame[1] = NONE; |
| 3054 mbmi->mv[0].as_int = 0; | 3060 mbmi->mv[0].as_int = 0; |
| 3055 x->skip = 1; | 3061 x->skip = 1; |
| 3056 | 3062 |
| 3057 // Search for best switchable filter by checking the variance of | 3063 // Search for best switchable filter by checking the variance of |
| 3058 // pred error irrespective of whether the filter will be used | 3064 // pred error irrespective of whether the filter will be used |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3714 } else { | 3720 } else { |
| 3715 vp9_zero(best_filter_diff); | 3721 vp9_zero(best_filter_diff); |
| 3716 } | 3722 } |
| 3717 | 3723 |
| 3718 set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]); | 3724 set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]); |
| 3719 store_coding_context(x, ctx, best_ref_index, | 3725 store_coding_context(x, ctx, best_ref_index, |
| 3720 best_pred_diff, best_tx_diff, best_filter_diff); | 3726 best_pred_diff, best_tx_diff, best_filter_diff); |
| 3721 | 3727 |
| 3722 return best_rd; | 3728 return best_rd; |
| 3723 } | 3729 } |
| OLD | NEW |