OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 // to be used in following transform skipping test. | 286 // to be used in following transform skipping test. |
287 block_variance(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, | 287 block_variance(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, |
288 4 << bw, 4 << bh, &sse, &sum, 8, sse8x8, sum8x8, var8x8); | 288 4 << bw, 4 << bh, &sse, &sum, 8, sse8x8, sum8x8, var8x8); |
289 var = sse - (((int64_t)sum * sum) >> (bw + bh + 4)); | 289 var = sse - (((int64_t)sum * sum) >> (bw + bh + 4)); |
290 | 290 |
291 *var_y = var; | 291 *var_y = var; |
292 *sse_y = sse; | 292 *sse_y = sse; |
293 | 293 |
294 if (cpi->common.tx_mode == TX_MODE_SELECT) { | 294 if (cpi->common.tx_mode == TX_MODE_SELECT) { |
295 if (sse > (var << 2)) | 295 if (sse > (var << 2)) |
296 tx_size = MIN(max_txsize_lookup[bsize], | 296 tx_size = VPXMIN(max_txsize_lookup[bsize], |
297 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); | 297 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); |
298 else | 298 else |
299 tx_size = TX_8X8; | 299 tx_size = TX_8X8; |
300 | 300 |
301 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && | 301 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && |
302 cyclic_refresh_segment_id_boosted(xd->mi[0]->mbmi.segment_id)) | 302 cyclic_refresh_segment_id_boosted(xd->mi[0]->mbmi.segment_id)) |
303 tx_size = TX_8X8; | 303 tx_size = TX_8X8; |
304 else if (tx_size > TX_16X16) | 304 else if (tx_size > TX_16X16) |
305 tx_size = TX_16X16; | 305 tx_size = TX_16X16; |
306 } else { | 306 } else { |
307 tx_size = MIN(max_txsize_lookup[bsize], | 307 tx_size = VPXMIN(max_txsize_lookup[bsize], |
308 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); | 308 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); |
309 } | 309 } |
310 | 310 |
311 assert(tx_size >= TX_8X8); | 311 assert(tx_size >= TX_8X8); |
312 xd->mi[0]->mbmi.tx_size = tx_size; | 312 xd->mi[0]->mbmi.tx_size = tx_size; |
313 | 313 |
314 // Evaluate if the partition block is a skippable block in Y plane. | 314 // Evaluate if the partition block is a skippable block in Y plane. |
315 { | 315 { |
316 unsigned int sse16x16[16] = {0}; | 316 unsigned int sse16x16[16] = {0}; |
317 int sum16x16[16] = {0}; | 317 int sum16x16[16] = {0}; |
318 unsigned int var16x16[16] = {0}; | 318 unsigned int var16x16[16] = {0}; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 unsigned int var = cpi->fn_ptr[bsize].vf(p->src.buf, p->src.stride, | 468 unsigned int var = cpi->fn_ptr[bsize].vf(p->src.buf, p->src.stride, |
469 pd->dst.buf, pd->dst.stride, &sse); | 469 pd->dst.buf, pd->dst.stride, &sse); |
470 int skip_dc = 0; | 470 int skip_dc = 0; |
471 | 471 |
472 *var_y = var; | 472 *var_y = var; |
473 *sse_y = sse; | 473 *sse_y = sse; |
474 | 474 |
475 if (cpi->common.tx_mode == TX_MODE_SELECT) { | 475 if (cpi->common.tx_mode == TX_MODE_SELECT) { |
476 if (sse > (var << 2)) | 476 if (sse > (var << 2)) |
477 xd->mi[0]->mbmi.tx_size = | 477 xd->mi[0]->mbmi.tx_size = |
478 MIN(max_txsize_lookup[bsize], | 478 VPXMIN(max_txsize_lookup[bsize], |
479 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); | 479 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); |
480 else | 480 else |
481 xd->mi[0]->mbmi.tx_size = TX_8X8; | 481 xd->mi[0]->mbmi.tx_size = TX_8X8; |
482 | 482 |
483 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && | 483 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && |
484 cyclic_refresh_segment_id_boosted(xd->mi[0]->mbmi.segment_id)) | 484 cyclic_refresh_segment_id_boosted(xd->mi[0]->mbmi.segment_id)) |
485 xd->mi[0]->mbmi.tx_size = TX_8X8; | 485 xd->mi[0]->mbmi.tx_size = TX_8X8; |
486 else if (xd->mi[0]->mbmi.tx_size > TX_16X16) | 486 else if (xd->mi[0]->mbmi.tx_size > TX_16X16) |
487 xd->mi[0]->mbmi.tx_size = TX_16X16; | 487 xd->mi[0]->mbmi.tx_size = TX_16X16; |
488 } else { | 488 } else { |
489 xd->mi[0]->mbmi.tx_size = | 489 xd->mi[0]->mbmi.tx_size = |
490 MIN(max_txsize_lookup[bsize], | 490 VPXMIN(max_txsize_lookup[bsize], |
491 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); | 491 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); |
492 } | 492 } |
493 | 493 |
494 // Evaluate if the partition block is a skippable block in Y plane. | 494 // Evaluate if the partition block is a skippable block in Y plane. |
495 { | 495 { |
496 const BLOCK_SIZE unit_size = | 496 const BLOCK_SIZE unit_size = |
497 txsize_to_bsize[xd->mi[0]->mbmi.tx_size]; | 497 txsize_to_bsize[xd->mi[0]->mbmi.tx_size]; |
498 const unsigned int num_blk_log2 = | 498 const unsigned int num_blk_log2 = |
499 (b_width_log2_lookup[bsize] - b_width_log2_lookup[unit_size]) + | 499 (b_width_log2_lookup[bsize] - b_width_log2_lookup[unit_size]) + |
500 (b_height_log2_lookup[bsize] - b_height_log2_lookup[unit_size]); | 500 (b_height_log2_lookup[bsize] - b_height_log2_lookup[unit_size]); |
501 const unsigned int sse_tx = sse >> num_blk_log2; | 501 const unsigned int sse_tx = sse >> num_blk_log2; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 unsigned int thresh_ac; | 784 unsigned int thresh_ac; |
785 // Skipping threshold for dc. | 785 // Skipping threshold for dc. |
786 unsigned int thresh_dc; | 786 unsigned int thresh_dc; |
787 if (x->encode_breakout > 0) { | 787 if (x->encode_breakout > 0) { |
788 // Set a maximum for threshold to avoid big PSNR loss in low bit rate | 788 // Set a maximum for threshold to avoid big PSNR loss in low bit rate |
789 // case. Use extreme low threshold for static frames to limit | 789 // case. Use extreme low threshold for static frames to limit |
790 // skipping. | 790 // skipping. |
791 const unsigned int max_thresh = 36000; | 791 const unsigned int max_thresh = 36000; |
792 // The encode_breakout input | 792 // The encode_breakout input |
793 const unsigned int min_thresh = | 793 const unsigned int min_thresh = |
794 MIN(((unsigned int)x->encode_breakout << 4), max_thresh); | 794 VPXMIN(((unsigned int)x->encode_breakout << 4), max_thresh); |
795 #if CONFIG_VP9_HIGHBITDEPTH | 795 #if CONFIG_VP9_HIGHBITDEPTH |
796 const int shift = (xd->bd << 1) - 16; | 796 const int shift = (xd->bd << 1) - 16; |
797 #endif | 797 #endif |
798 | 798 |
799 // Calculate threshold according to dequant value. | 799 // Calculate threshold according to dequant value. |
800 thresh_ac = (xd->plane[0].dequant[1] * xd->plane[0].dequant[1]) >> 3; | 800 thresh_ac = (xd->plane[0].dequant[1] * xd->plane[0].dequant[1]) >> 3; |
801 #if CONFIG_VP9_HIGHBITDEPTH | 801 #if CONFIG_VP9_HIGHBITDEPTH |
802 if ((xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) && shift > 0) { | 802 if ((xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) && shift > 0) { |
803 thresh_ac = ROUND_POWER_OF_TWO(thresh_ac, shift); | 803 thresh_ac = ROUND_POWER_OF_TWO(thresh_ac, shift); |
804 } | 804 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 // Use source buffer as an approximation for the fully reconstructed buffer. | 904 // Use source buffer as an approximation for the fully reconstructed buffer. |
905 vp9_predict_intra_block(xd, b_width_log2_lookup[plane_bsize], | 905 vp9_predict_intra_block(xd, b_width_log2_lookup[plane_bsize], |
906 tx_size, args->mode, | 906 tx_size, args->mode, |
907 x->skip_encode ? p->src.buf : pd->dst.buf, | 907 x->skip_encode ? p->src.buf : pd->dst.buf, |
908 x->skip_encode ? src_stride : dst_stride, | 908 x->skip_encode ? src_stride : dst_stride, |
909 pd->dst.buf, dst_stride, | 909 pd->dst.buf, dst_stride, |
910 i, j, 0); | 910 i, j, 0); |
911 | 911 |
912 // TODO(jingning): This needs further refactoring. | 912 // TODO(jingning): This needs further refactoring. |
913 block_yrd(cpi, x, &rate, &dist, &is_skippable, &this_sse, 0, | 913 block_yrd(cpi, x, &rate, &dist, &is_skippable, &this_sse, 0, |
914 bsize_tx, MIN(tx_size, TX_16X16)); | 914 bsize_tx, VPXMIN(tx_size, TX_16X16)); |
915 x->skip_txfm[0] = is_skippable; | 915 x->skip_txfm[0] = is_skippable; |
916 rate += vp9_cost_bit(vp9_get_skip_prob(&cpi->common, xd), is_skippable); | 916 rate += vp9_cost_bit(vp9_get_skip_prob(&cpi->common, xd), is_skippable); |
917 | 917 |
918 p->src.buf = src_buf_base; | 918 p->src.buf = src_buf_base; |
919 pd->dst.buf = dst_buf_base; | 919 pd->dst.buf = dst_buf_base; |
920 args->rate += rate; | 920 args->rate += rate; |
921 args->dist += dist; | 921 args->dist += dist; |
922 } | 922 } |
923 | 923 |
924 static const THR_MODES mode_idx[MAX_REF_FRAMES - 1][4] = { | 924 static const THR_MODES mode_idx[MAX_REF_FRAMES - 1][4] = { |
(...skipping 29 matching lines...) Expand all Loading... |
954 TileDataEnc *tile_data, | 954 TileDataEnc *tile_data, |
955 BLOCK_SIZE bsize, | 955 BLOCK_SIZE bsize, |
956 MV_REFERENCE_FRAME ref_frame, | 956 MV_REFERENCE_FRAME ref_frame, |
957 THR_MODES best_mode_idx, | 957 THR_MODES best_mode_idx, |
958 PREDICTION_MODE mode) { | 958 PREDICTION_MODE mode) { |
959 THR_MODES thr_mode_idx = mode_idx[ref_frame][mode_offset(mode)]; | 959 THR_MODES thr_mode_idx = mode_idx[ref_frame][mode_offset(mode)]; |
960 int *freq_fact = &tile_data->thresh_freq_fact[bsize][thr_mode_idx]; | 960 int *freq_fact = &tile_data->thresh_freq_fact[bsize][thr_mode_idx]; |
961 if (thr_mode_idx == best_mode_idx) | 961 if (thr_mode_idx == best_mode_idx) |
962 *freq_fact -= (*freq_fact >> 4); | 962 *freq_fact -= (*freq_fact >> 4); |
963 else | 963 else |
964 *freq_fact = MIN(*freq_fact + RD_THRESH_INC, | 964 *freq_fact = VPXMIN(*freq_fact + RD_THRESH_INC, |
965 cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT); | 965 cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT); |
966 } | 966 } |
967 | 967 |
968 void vp9_pick_intra_mode(VP9_COMP *cpi, MACROBLOCK *x, RD_COST *rd_cost, | 968 void vp9_pick_intra_mode(VP9_COMP *cpi, MACROBLOCK *x, RD_COST *rd_cost, |
969 BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx) { | 969 BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx) { |
970 MACROBLOCKD *const xd = &x->e_mbd; | 970 MACROBLOCKD *const xd = &x->e_mbd; |
971 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; | 971 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; |
972 RD_COST this_rdc, best_rdc; | 972 RD_COST this_rdc, best_rdc; |
973 PREDICTION_MODE this_mode; | 973 PREDICTION_MODE this_mode; |
974 struct estimate_block_intra_args args = { cpi, x, DC_PRED, 0, 0 }; | 974 struct estimate_block_intra_args args = { cpi, x, DC_PRED, 0, 0 }; |
975 const TX_SIZE intra_tx_size = | 975 const TX_SIZE intra_tx_size = |
976 MIN(max_txsize_lookup[bsize], | 976 VPXMIN(max_txsize_lookup[bsize], |
977 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); | 977 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); |
978 MODE_INFO *const mic = xd->mi[0]; | 978 MODE_INFO *const mic = xd->mi[0]; |
979 int *bmode_costs; | 979 int *bmode_costs; |
980 const MODE_INFO *above_mi = xd->mi[-xd->mi_stride]; | 980 const MODE_INFO *above_mi = xd->mi[-xd->mi_stride]; |
981 const MODE_INFO *left_mi = xd->left_available ? xd->mi[-1] : NULL; | 981 const MODE_INFO *left_mi = xd->left_available ? xd->mi[-1] : NULL; |
982 const PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, 0); | 982 const PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, 0); |
983 const PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0); | 983 const PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0); |
984 bmode_costs = cpi->y_mode_costs[A][L]; | 984 bmode_costs = cpi->y_mode_costs[A][L]; |
985 | 985 |
986 (void) ctx; | 986 (void) ctx; |
987 vp9_rd_cost_reset(&best_rdc); | 987 vp9_rd_cost_reset(&best_rdc); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 static const REF_MODE ref_mode_set[RT_INTER_MODES] = { | 1043 static const REF_MODE ref_mode_set[RT_INTER_MODES] = { |
1044 {LAST_FRAME, ZEROMV}, | 1044 {LAST_FRAME, ZEROMV}, |
1045 {LAST_FRAME, NEARESTMV}, | 1045 {LAST_FRAME, NEARESTMV}, |
1046 {GOLDEN_FRAME, ZEROMV}, | 1046 {GOLDEN_FRAME, ZEROMV}, |
1047 {LAST_FRAME, NEARMV}, | 1047 {LAST_FRAME, NEARMV}, |
1048 {LAST_FRAME, NEWMV}, | 1048 {LAST_FRAME, NEWMV}, |
1049 {GOLDEN_FRAME, NEARESTMV}, | 1049 {GOLDEN_FRAME, NEARESTMV}, |
1050 {GOLDEN_FRAME, NEARMV}, | 1050 {GOLDEN_FRAME, NEARMV}, |
1051 {GOLDEN_FRAME, NEWMV} | 1051 {GOLDEN_FRAME, NEWMV} |
1052 }; | 1052 }; |
| 1053 static const REF_MODE ref_mode_set_svc[RT_INTER_MODES] = { |
| 1054 {LAST_FRAME, ZEROMV}, |
| 1055 {GOLDEN_FRAME, ZEROMV}, |
| 1056 {LAST_FRAME, NEARESTMV}, |
| 1057 {LAST_FRAME, NEARMV}, |
| 1058 {GOLDEN_FRAME, NEARESTMV}, |
| 1059 {GOLDEN_FRAME, NEARMV}, |
| 1060 {LAST_FRAME, NEWMV}, |
| 1061 {GOLDEN_FRAME, NEWMV} |
| 1062 }; |
1053 | 1063 |
1054 // TODO(jingning) placeholder for inter-frame non-RD mode decision. | 1064 // TODO(jingning) placeholder for inter-frame non-RD mode decision. |
1055 // this needs various further optimizations. to be continued.. | 1065 // this needs various further optimizations. to be continued.. |
1056 void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, | 1066 void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, |
1057 TileDataEnc *tile_data, | 1067 TileDataEnc *tile_data, |
1058 int mi_row, int mi_col, RD_COST *rd_cost, | 1068 int mi_row, int mi_col, RD_COST *rd_cost, |
1059 BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx) { | 1069 BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx) { |
1060 VP9_COMMON *const cm = &cpi->common; | 1070 VP9_COMMON *const cm = &cpi->common; |
1061 SPEED_FEATURES *const sf = &cpi->sf; | 1071 SPEED_FEATURES *const sf = &cpi->sf; |
1062 TileInfo *const tile_info = &tile_data->tile_info; | 1072 TileInfo *const tile_info = &tile_data->tile_info; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 filter_ref = xd->mi[-1]->mbmi.interp_filter; | 1153 filter_ref = xd->mi[-1]->mbmi.interp_filter; |
1144 else | 1154 else |
1145 filter_ref = cm->interp_filter; | 1155 filter_ref = cm->interp_filter; |
1146 | 1156 |
1147 // initialize mode decisions | 1157 // initialize mode decisions |
1148 vp9_rd_cost_reset(&best_rdc); | 1158 vp9_rd_cost_reset(&best_rdc); |
1149 vp9_rd_cost_reset(rd_cost); | 1159 vp9_rd_cost_reset(rd_cost); |
1150 mbmi->sb_type = bsize; | 1160 mbmi->sb_type = bsize; |
1151 mbmi->ref_frame[0] = NONE; | 1161 mbmi->ref_frame[0] = NONE; |
1152 mbmi->ref_frame[1] = NONE; | 1162 mbmi->ref_frame[1] = NONE; |
1153 mbmi->tx_size = MIN(max_txsize_lookup[bsize], | 1163 mbmi->tx_size = VPXMIN(max_txsize_lookup[bsize], |
1154 tx_mode_to_biggest_tx_size[cm->tx_mode]); | 1164 tx_mode_to_biggest_tx_size[cm->tx_mode]); |
1155 | 1165 |
1156 #if CONFIG_VP9_TEMPORAL_DENOISING | 1166 #if CONFIG_VP9_TEMPORAL_DENOISING |
1157 vp9_denoiser_reset_frame_stats(ctx); | 1167 vp9_denoiser_reset_frame_stats(ctx); |
1158 #endif | 1168 #endif |
1159 | 1169 |
1160 if (cpi->rc.frames_since_golden == 0) { | 1170 if (cpi->rc.frames_since_golden == 0 && !cpi->use_svc) { |
1161 usable_ref_frame = LAST_FRAME; | 1171 usable_ref_frame = LAST_FRAME; |
1162 } else { | 1172 } else { |
1163 usable_ref_frame = GOLDEN_FRAME; | 1173 usable_ref_frame = GOLDEN_FRAME; |
1164 } | 1174 } |
1165 | |
1166 for (ref_frame = LAST_FRAME; ref_frame <= usable_ref_frame; ++ref_frame) { | 1175 for (ref_frame = LAST_FRAME; ref_frame <= usable_ref_frame; ++ref_frame) { |
1167 const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame); | 1176 const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame); |
1168 | 1177 |
1169 x->pred_mv_sad[ref_frame] = INT_MAX; | 1178 x->pred_mv_sad[ref_frame] = INT_MAX; |
1170 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; | 1179 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; |
1171 frame_mv[ZEROMV][ref_frame].as_int = 0; | 1180 frame_mv[ZEROMV][ref_frame].as_int = 0; |
1172 | 1181 |
1173 if ((cpi->ref_frame_flags & flag_list[ref_frame]) && (yv12 != NULL)) { | 1182 if ((cpi->ref_frame_flags & flag_list[ref_frame]) && (yv12 != NULL)) { |
1174 int_mv *const candidates = x->mbmi_ext->ref_mvs[ref_frame]; | 1183 int_mv *const candidates = x->mbmi_ext->ref_mvs[ref_frame]; |
1175 const struct scale_factors *const sf = &cm->frame_refs[ref_frame - 1].sf; | 1184 const struct scale_factors *const sf = &cm->frame_refs[ref_frame - 1].sf; |
(...skipping 21 matching lines...) Expand all Loading... |
1197 } else { | 1206 } else { |
1198 ref_frame_skip_mask |= (1 << ref_frame); | 1207 ref_frame_skip_mask |= (1 << ref_frame); |
1199 } | 1208 } |
1200 } | 1209 } |
1201 | 1210 |
1202 for (idx = 0; idx < RT_INTER_MODES; ++idx) { | 1211 for (idx = 0; idx < RT_INTER_MODES; ++idx) { |
1203 int rate_mv = 0; | 1212 int rate_mv = 0; |
1204 int mode_rd_thresh; | 1213 int mode_rd_thresh; |
1205 int mode_index; | 1214 int mode_index; |
1206 int i; | 1215 int i; |
1207 PREDICTION_MODE this_mode = ref_mode_set[idx].pred_mode; | |
1208 int64_t this_sse; | 1216 int64_t this_sse; |
1209 int is_skippable; | 1217 int is_skippable; |
1210 int this_early_term = 0; | 1218 int this_early_term = 0; |
| 1219 PREDICTION_MODE this_mode = ref_mode_set[idx].pred_mode; |
| 1220 if (cpi->use_svc) |
| 1221 this_mode = ref_mode_set_svc[idx].pred_mode; |
1211 | 1222 |
1212 if (!(cpi->sf.inter_mode_mask[bsize] & (1 << this_mode))) | 1223 if (!(cpi->sf.inter_mode_mask[bsize] & (1 << this_mode))) |
1213 continue; | 1224 continue; |
1214 | 1225 |
1215 ref_frame = ref_mode_set[idx].ref_frame; | 1226 ref_frame = ref_mode_set[idx].ref_frame; |
| 1227 if (cpi->use_svc) |
| 1228 ref_frame = ref_mode_set_svc[idx].ref_frame; |
1216 if (!(cpi->ref_frame_flags & flag_list[ref_frame])) | 1229 if (!(cpi->ref_frame_flags & flag_list[ref_frame])) |
1217 continue; | 1230 continue; |
1218 if (const_motion[ref_frame] && this_mode == NEARMV) | 1231 if (const_motion[ref_frame] && this_mode == NEARMV) |
1219 continue; | 1232 continue; |
1220 | 1233 |
1221 i = (ref_frame == LAST_FRAME) ? GOLDEN_FRAME : LAST_FRAME; | 1234 i = (ref_frame == LAST_FRAME) ? GOLDEN_FRAME : LAST_FRAME; |
1222 if ((cpi->ref_frame_flags & flag_list[i]) && sf->reference_masking) | 1235 if ((cpi->ref_frame_flags & flag_list[i]) && sf->reference_masking) |
1223 if (x->pred_mv_sad[ref_frame] > (x->pred_mv_sad[i] << 1)) | 1236 if (x->pred_mv_sad[ref_frame] > (x->pred_mv_sad[i] << 1)) |
1224 ref_frame_skip_mask |= (1 << ref_frame); | 1237 ref_frame_skip_mask |= (1 << ref_frame); |
1225 if (ref_frame_skip_mask & (1 << ref_frame)) | 1238 if (ref_frame_skip_mask & (1 << ref_frame)) |
1226 continue; | 1239 continue; |
1227 | 1240 |
1228 // Select prediction reference frames. | 1241 // Select prediction reference frames. |
1229 for (i = 0; i < MAX_MB_PLANE; i++) | 1242 for (i = 0; i < MAX_MB_PLANE; i++) |
1230 xd->plane[i].pre[0] = yv12_mb[ref_frame][i]; | 1243 xd->plane[i].pre[0] = yv12_mb[ref_frame][i]; |
1231 | 1244 |
1232 mbmi->ref_frame[0] = ref_frame; | 1245 mbmi->ref_frame[0] = ref_frame; |
1233 set_ref_ptrs(cm, xd, ref_frame, NONE); | 1246 set_ref_ptrs(cm, xd, ref_frame, NONE); |
1234 | 1247 |
1235 mode_index = mode_idx[ref_frame][INTER_OFFSET(this_mode)]; | 1248 mode_index = mode_idx[ref_frame][INTER_OFFSET(this_mode)]; |
1236 mode_rd_thresh = best_mode_skip_txfm ? | 1249 mode_rd_thresh = best_mode_skip_txfm ? |
1237 rd_threshes[mode_index] << 1 : rd_threshes[mode_index]; | 1250 rd_threshes[mode_index] << 1 : rd_threshes[mode_index]; |
1238 if (rd_less_than_thresh(best_rdc.rdcost, mode_rd_thresh, | 1251 if (rd_less_than_thresh(best_rdc.rdcost, mode_rd_thresh, |
1239 rd_thresh_freq_fact[mode_index])) | 1252 rd_thresh_freq_fact[mode_index])) |
1240 continue; | 1253 continue; |
1241 | 1254 |
1242 if (this_mode == NEWMV) { | 1255 if (this_mode == NEWMV) { |
1243 if (ref_frame > LAST_FRAME) { | 1256 if (ref_frame > LAST_FRAME && !cpi->use_svc) { |
1244 int tmp_sad; | 1257 int tmp_sad; |
1245 int dis, cost_list[5]; | 1258 int dis, cost_list[5]; |
1246 | 1259 |
1247 if (bsize < BLOCK_16X16) | 1260 if (bsize < BLOCK_16X16) |
1248 continue; | 1261 continue; |
1249 | 1262 |
1250 tmp_sad = vp9_int_pro_motion_estimation(cpi, x, bsize, mi_row, mi_col); | 1263 tmp_sad = vp9_int_pro_motion_estimation(cpi, x, bsize, mi_row, mi_col); |
1251 | 1264 |
1252 if (tmp_sad > x->pred_mv_sad[LAST_FRAME]) | 1265 if (tmp_sad > x->pred_mv_sad[LAST_FRAME]) |
1253 continue; | 1266 continue; |
(...skipping 28 matching lines...) Expand all Loading... |
1282 const int pre_stride = xd->plane[0].pre[0].stride; | 1295 const int pre_stride = xd->plane[0].pre[0].stride; |
1283 const uint8_t * const pre_buf = xd->plane[0].pre[0].buf + | 1296 const uint8_t * const pre_buf = xd->plane[0].pre[0].buf + |
1284 (frame_mv[NEWMV][LAST_FRAME].as_mv.row >> 3) * pre_stride + | 1297 (frame_mv[NEWMV][LAST_FRAME].as_mv.row >> 3) * pre_stride + |
1285 (frame_mv[NEWMV][LAST_FRAME].as_mv.col >> 3); | 1298 (frame_mv[NEWMV][LAST_FRAME].as_mv.col >> 3); |
1286 best_pred_sad = cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf, | 1299 best_pred_sad = cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf, |
1287 x->plane[0].src.stride, | 1300 x->plane[0].src.stride, |
1288 pre_buf, pre_stride); | 1301 pre_buf, pre_stride); |
1289 x->pred_mv_sad[LAST_FRAME] = best_pred_sad; | 1302 x->pred_mv_sad[LAST_FRAME] = best_pred_sad; |
1290 } | 1303 } |
1291 | 1304 |
| 1305 if (cpi->use_svc) { |
| 1306 if (this_mode == NEWMV && ref_frame == GOLDEN_FRAME && |
| 1307 frame_mv[NEWMV][GOLDEN_FRAME].as_int != INVALID_MV) { |
| 1308 const int pre_stride = xd->plane[0].pre[0].stride; |
| 1309 const uint8_t * const pre_buf = xd->plane[0].pre[0].buf + |
| 1310 (frame_mv[NEWMV][GOLDEN_FRAME].as_mv.row >> 3) * pre_stride + |
| 1311 (frame_mv[NEWMV][GOLDEN_FRAME].as_mv.col >> 3); |
| 1312 best_pred_sad = cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf, |
| 1313 x->plane[0].src.stride, |
| 1314 pre_buf, pre_stride); |
| 1315 x->pred_mv_sad[GOLDEN_FRAME] = best_pred_sad; |
| 1316 } |
| 1317 } |
| 1318 |
| 1319 |
1292 if (this_mode != NEARESTMV && | 1320 if (this_mode != NEARESTMV && |
1293 frame_mv[this_mode][ref_frame].as_int == | 1321 frame_mv[this_mode][ref_frame].as_int == |
1294 frame_mv[NEARESTMV][ref_frame].as_int) | 1322 frame_mv[NEARESTMV][ref_frame].as_int) |
1295 continue; | 1323 continue; |
1296 | 1324 |
1297 mbmi->mode = this_mode; | 1325 mbmi->mode = this_mode; |
1298 mbmi->mv[0].as_int = frame_mv[this_mode][ref_frame].as_int; | 1326 mbmi->mv[0].as_int = frame_mv[this_mode][ref_frame].as_int; |
1299 | 1327 |
1300 // Search for the best prediction filter type, when the resulting | 1328 // Search for the best prediction filter type, when the resulting |
1301 // motion vector is at sub-pixel accuracy level for luma component, i.e., | 1329 // motion vector is at sub-pixel accuracy level for luma component, i.e., |
1302 // the last three bits are all zeros. | 1330 // the last three bits are all zeros. |
1303 if (reuse_inter_pred) { | 1331 if (reuse_inter_pred) { |
1304 if (!this_mode_pred) { | 1332 if (!this_mode_pred) { |
1305 this_mode_pred = &tmp[3]; | 1333 this_mode_pred = &tmp[3]; |
1306 } else { | 1334 } else { |
1307 this_mode_pred = &tmp[get_pred_buffer(tmp, 3)]; | 1335 this_mode_pred = &tmp[get_pred_buffer(tmp, 3)]; |
1308 pd->dst.buf = this_mode_pred->data; | 1336 pd->dst.buf = this_mode_pred->data; |
1309 pd->dst.stride = bw; | 1337 pd->dst.stride = bw; |
1310 } | 1338 } |
1311 } | 1339 } |
1312 | 1340 |
1313 if ((this_mode == NEWMV || filter_ref == SWITCHABLE) && pred_filter_search | 1341 if ((this_mode == NEWMV || filter_ref == SWITCHABLE) && pred_filter_search |
1314 && (ref_frame == LAST_FRAME) | 1342 && (ref_frame == LAST_FRAME || |
| 1343 (ref_frame == GOLDEN_FRAME && cpi->use_svc)) |
1315 && (((mbmi->mv[0].as_mv.row | mbmi->mv[0].as_mv.col) & 0x07) != 0)) { | 1344 && (((mbmi->mv[0].as_mv.row | mbmi->mv[0].as_mv.col) & 0x07) != 0)) { |
1316 int pf_rate[3]; | 1345 int pf_rate[3]; |
1317 int64_t pf_dist[3]; | 1346 int64_t pf_dist[3]; |
1318 unsigned int pf_var[3]; | 1347 unsigned int pf_var[3]; |
1319 unsigned int pf_sse[3]; | 1348 unsigned int pf_sse[3]; |
1320 TX_SIZE pf_tx_size[3]; | 1349 TX_SIZE pf_tx_size[3]; |
1321 int64_t best_cost = INT64_MAX; | 1350 int64_t best_cost = INT64_MAX; |
1322 INTERP_FILTER best_filter = SWITCHABLE, filter; | 1351 INTERP_FILTER best_filter = SWITCHABLE, filter; |
1323 PRED_BUFFER *current_pred = this_mode_pred; | 1352 PRED_BUFFER *current_pred = this_mode_pred; |
1324 | 1353 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 &this_early_term); | 1407 &this_early_term); |
1379 } else { | 1408 } else { |
1380 model_rd_for_sb_y(cpi, bsize, x, xd, &this_rdc.rate, &this_rdc.dist, | 1409 model_rd_for_sb_y(cpi, bsize, x, xd, &this_rdc.rate, &this_rdc.dist, |
1381 &var_y, &sse_y); | 1410 &var_y, &sse_y); |
1382 } | 1411 } |
1383 } | 1412 } |
1384 | 1413 |
1385 if (!this_early_term) { | 1414 if (!this_early_term) { |
1386 this_sse = (int64_t)sse_y; | 1415 this_sse = (int64_t)sse_y; |
1387 block_yrd(cpi, x, &this_rdc.rate, &this_rdc.dist, &is_skippable, | 1416 block_yrd(cpi, x, &this_rdc.rate, &this_rdc.dist, &is_skippable, |
1388 &this_sse, 0, bsize, MIN(mbmi->tx_size, TX_16X16)); | 1417 &this_sse, 0, bsize, VPXMIN(mbmi->tx_size, TX_16X16)); |
1389 x->skip_txfm[0] = is_skippable; | 1418 x->skip_txfm[0] = is_skippable; |
1390 if (is_skippable) { | 1419 if (is_skippable) { |
1391 this_rdc.rate = vp9_cost_bit(vp9_get_skip_prob(cm, xd), 1); | 1420 this_rdc.rate = vp9_cost_bit(vp9_get_skip_prob(cm, xd), 1); |
1392 } else { | 1421 } else { |
1393 if (RDCOST(x->rdmult, x->rddiv, this_rdc.rate, this_rdc.dist) < | 1422 if (RDCOST(x->rdmult, x->rddiv, this_rdc.rate, this_rdc.dist) < |
1394 RDCOST(x->rdmult, x->rddiv, 0, this_sse)) { | 1423 RDCOST(x->rdmult, x->rddiv, 0, this_sse)) { |
1395 this_rdc.rate += vp9_cost_bit(vp9_get_skip_prob(cm, xd), 0); | 1424 this_rdc.rate += vp9_cost_bit(vp9_get_skip_prob(cm, xd), 0); |
1396 } else { | 1425 } else { |
1397 this_rdc.rate = vp9_cost_bit(vp9_get_skip_prob(cm, xd), 1); | 1426 this_rdc.rate = vp9_cost_bit(vp9_get_skip_prob(cm, xd), 1); |
1398 this_rdc.dist = this_sse; | 1427 this_rdc.dist = this_sse; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 xd->mi[0]->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int; | 1516 xd->mi[0]->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int; |
1488 x->skip_txfm[0] = best_mode_skip_txfm; | 1517 x->skip_txfm[0] = best_mode_skip_txfm; |
1489 | 1518 |
1490 // Perform intra prediction search, if the best SAD is above a certain | 1519 // Perform intra prediction search, if the best SAD is above a certain |
1491 // threshold. | 1520 // threshold. |
1492 if (best_rdc.rdcost == INT64_MAX || | 1521 if (best_rdc.rdcost == INT64_MAX || |
1493 (!x->skip && best_rdc.rdcost > inter_mode_thresh && | 1522 (!x->skip && best_rdc.rdcost > inter_mode_thresh && |
1494 bsize <= cpi->sf.max_intra_bsize)) { | 1523 bsize <= cpi->sf.max_intra_bsize)) { |
1495 struct estimate_block_intra_args args = { cpi, x, DC_PRED, 0, 0 }; | 1524 struct estimate_block_intra_args args = { cpi, x, DC_PRED, 0, 0 }; |
1496 const TX_SIZE intra_tx_size = | 1525 const TX_SIZE intra_tx_size = |
1497 MIN(max_txsize_lookup[bsize], | 1526 VPXMIN(max_txsize_lookup[bsize], |
1498 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); | 1527 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); |
1499 int i; | 1528 int i; |
1500 TX_SIZE best_intra_tx_size = TX_SIZES; | 1529 TX_SIZE best_intra_tx_size = TX_SIZES; |
1501 | 1530 |
1502 if (reuse_inter_pred && best_pred != NULL) { | 1531 if (reuse_inter_pred && best_pred != NULL) { |
1503 if (best_pred->data == orig_dst.buf) { | 1532 if (best_pred->data == orig_dst.buf) { |
1504 this_mode_pred = &tmp[get_pred_buffer(tmp, 3)]; | 1533 this_mode_pred = &tmp[get_pred_buffer(tmp, 3)]; |
1505 #if CONFIG_VP9_HIGHBITDEPTH | 1534 #if CONFIG_VP9_HIGHBITDEPTH |
1506 if (cm->use_highbitdepth) | 1535 if (cm->use_highbitdepth) |
1507 vpx_highbd_convolve_copy(best_pred->data, best_pred->stride, | 1536 vpx_highbd_convolve_copy(best_pred->data, best_pred->stride, |
1508 this_mode_pred->data, this_mode_pred->stride, | 1537 this_mode_pred->data, this_mode_pred->stride, |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 } | 1908 } |
1880 } | 1909 } |
1881 mbmi->mode = xd->mi[0]->bmi[3].as_mode; | 1910 mbmi->mode = xd->mi[0]->bmi[3].as_mode; |
1882 ctx->mic = *(xd->mi[0]); | 1911 ctx->mic = *(xd->mi[0]); |
1883 ctx->mbmi_ext = *x->mbmi_ext; | 1912 ctx->mbmi_ext = *x->mbmi_ext; |
1884 ctx->skip_txfm[0] = SKIP_TXFM_NONE; | 1913 ctx->skip_txfm[0] = SKIP_TXFM_NONE; |
1885 ctx->skip = 0; | 1914 ctx->skip = 0; |
1886 // Dummy assignment for speed -5. No effect in speed -6. | 1915 // Dummy assignment for speed -5. No effect in speed -6. |
1887 rd_cost->rdcost = best_rd; | 1916 rd_cost->rdcost = best_rd; |
1888 } | 1917 } |
OLD | NEW |