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 20 matching lines...) Expand all Loading... |
31 #include "vp9/encoder/vp9_encodemb.h" | 31 #include "vp9/encoder/vp9_encodemb.h" |
32 #include "vp9/encoder/vp9_encodemv.h" | 32 #include "vp9/encoder/vp9_encodemv.h" |
33 #include "vp9/encoder/vp9_encoder.h" | 33 #include "vp9/encoder/vp9_encoder.h" |
34 #include "vp9/encoder/vp9_mcomp.h" | 34 #include "vp9/encoder/vp9_mcomp.h" |
35 #include "vp9/encoder/vp9_quantize.h" | 35 #include "vp9/encoder/vp9_quantize.h" |
36 #include "vp9/encoder/vp9_ratectrl.h" | 36 #include "vp9/encoder/vp9_ratectrl.h" |
37 #include "vp9/encoder/vp9_rd.h" | 37 #include "vp9/encoder/vp9_rd.h" |
38 #include "vp9/encoder/vp9_rdopt.h" | 38 #include "vp9/encoder/vp9_rdopt.h" |
39 #include "vp9/encoder/vp9_variance.h" | 39 #include "vp9/encoder/vp9_variance.h" |
40 | 40 |
41 #define RD_THRESH_MAX_FACT 64 | |
42 #define RD_THRESH_INC 1 | |
43 | |
44 #define LAST_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \ | 41 #define LAST_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \ |
45 (1 << INTRA_FRAME)) | 42 (1 << INTRA_FRAME)) |
46 #define GOLDEN_FRAME_MODE_MASK ((1 << LAST_FRAME) | (1 << ALTREF_FRAME) | \ | 43 #define GOLDEN_FRAME_MODE_MASK ((1 << LAST_FRAME) | (1 << ALTREF_FRAME) | \ |
47 (1 << INTRA_FRAME)) | 44 (1 << INTRA_FRAME)) |
48 #define ALT_REF_MODE_MASK ((1 << LAST_FRAME) | (1 << GOLDEN_FRAME) | \ | 45 #define ALT_REF_MODE_MASK ((1 << LAST_FRAME) | (1 << GOLDEN_FRAME) | \ |
49 (1 << INTRA_FRAME)) | 46 (1 << INTRA_FRAME)) |
50 | 47 |
51 #define SECOND_REF_FRAME_MASK ((1 << ALTREF_FRAME) | 0x01) | 48 #define SECOND_REF_FRAME_MASK ((1 << ALTREF_FRAME) | 0x01) |
52 | 49 |
53 #define MIN_EARLY_TERM_INDEX 3 | 50 #define MIN_EARLY_TERM_INDEX 3 |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 struct rdcost_block_args *args = arg; | 468 struct rdcost_block_args *args = arg; |
472 MACROBLOCK *const x = args->x; | 469 MACROBLOCK *const x = args->x; |
473 MACROBLOCKD *const xd = &x->e_mbd; | 470 MACROBLOCKD *const xd = &x->e_mbd; |
474 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; | 471 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; |
475 int64_t rd1, rd2, rd; | 472 int64_t rd1, rd2, rd; |
476 | 473 |
477 if (args->skip) | 474 if (args->skip) |
478 return; | 475 return; |
479 | 476 |
480 if (!is_inter_block(mbmi)) { | 477 if (!is_inter_block(mbmi)) { |
481 vp9_encode_block_intra(x, plane, block, plane_bsize, tx_size, &mbmi->skip); | 478 struct encode_b_args arg = {x, NULL, &mbmi->skip}; |
| 479 vp9_encode_block_intra(plane, block, plane_bsize, tx_size, &arg); |
482 #if CONFIG_VP9_HIGHBITDEPTH | 480 #if CONFIG_VP9_HIGHBITDEPTH |
483 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { | 481 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
484 dist_block(plane, block, tx_size, args, xd->bd); | 482 dist_block(plane, block, tx_size, args, xd->bd); |
485 } else { | 483 } else { |
486 dist_block(plane, block, tx_size, args, 8); | 484 dist_block(plane, block, tx_size, args, 8); |
487 } | 485 } |
488 #else | 486 #else |
489 dist_block(plane, block, tx_size, args); | 487 dist_block(plane, block, tx_size, args); |
490 #endif // CONFIG_VP9_HIGHBITDEPTH | 488 #endif // CONFIG_VP9_HIGHBITDEPTH |
491 } else if (max_txsize_lookup[plane_bsize] == tx_size) { | 489 } else if (max_txsize_lookup[plane_bsize] == tx_size) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 int64_t rd[TX_SIZES][2] = {{INT64_MAX, INT64_MAX}, | 630 int64_t rd[TX_SIZES][2] = {{INT64_MAX, INT64_MAX}, |
633 {INT64_MAX, INT64_MAX}, | 631 {INT64_MAX, INT64_MAX}, |
634 {INT64_MAX, INT64_MAX}, | 632 {INT64_MAX, INT64_MAX}, |
635 {INT64_MAX, INT64_MAX}}; | 633 {INT64_MAX, INT64_MAX}}; |
636 int n, m; | 634 int n, m; |
637 int s0, s1; | 635 int s0, s1; |
638 const TX_SIZE max_mode_tx_size = tx_mode_to_biggest_tx_size[cm->tx_mode]; | 636 const TX_SIZE max_mode_tx_size = tx_mode_to_biggest_tx_size[cm->tx_mode]; |
639 int64_t best_rd = INT64_MAX; | 637 int64_t best_rd = INT64_MAX; |
640 TX_SIZE best_tx = max_tx_size; | 638 TX_SIZE best_tx = max_tx_size; |
641 | 639 |
642 const vp9_prob *tx_probs = get_tx_probs2(max_tx_size, xd, &cm->fc.tx_probs); | 640 const vp9_prob *tx_probs = get_tx_probs2(max_tx_size, xd, &cm->fc->tx_probs); |
643 assert(skip_prob > 0); | 641 assert(skip_prob > 0); |
644 s0 = vp9_cost_bit(skip_prob, 0); | 642 s0 = vp9_cost_bit(skip_prob, 0); |
645 s1 = vp9_cost_bit(skip_prob, 1); | 643 s1 = vp9_cost_bit(skip_prob, 1); |
646 | 644 |
647 for (n = max_tx_size; n >= 0; n--) { | 645 for (n = max_tx_size; n >= 0; n--) { |
648 txfm_rd_in_plane(x, &r[n][0], &d[n], &s[n], | 646 txfm_rd_in_plane(x, &r[n][0], &d[n], &s[n], |
649 &sse[n], ref_best_rd, 0, bs, n, | 647 &sse[n], ref_best_rd, 0, bs, n, |
650 cpi->sf.use_fast_coef_costing); | 648 cpi->sf.use_fast_coef_costing); |
651 r[n][1] = r[n][0]; | 649 r[n][1] = r[n][0]; |
652 if (r[n][0] < INT_MAX) { | 650 if (r[n][0] < INT_MAX) { |
(...skipping 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2354 int *rate2, int64_t *distortion, | 2352 int *rate2, int64_t *distortion, |
2355 int *skippable, | 2353 int *skippable, |
2356 int *rate_y, int *rate_uv, | 2354 int *rate_y, int *rate_uv, |
2357 int *disable_skip, | 2355 int *disable_skip, |
2358 int_mv (*mode_mv)[MAX_REF_FRAMES], | 2356 int_mv (*mode_mv)[MAX_REF_FRAMES], |
2359 int mi_row, int mi_col, | 2357 int mi_row, int mi_col, |
2360 int_mv single_newmv[MAX_REF_FRAMES], | 2358 int_mv single_newmv[MAX_REF_FRAMES], |
2361 INTERP_FILTER (*single_filter)[MAX_REF_FRAMES], | 2359 INTERP_FILTER (*single_filter)[MAX_REF_FRAMES], |
2362 int (*single_skippable)[MAX_REF_FRAMES], | 2360 int (*single_skippable)[MAX_REF_FRAMES], |
2363 int64_t *psse, | 2361 int64_t *psse, |
2364 const int64_t ref_best_rd) { | 2362 const int64_t ref_best_rd, |
| 2363 int64_t *mask_filter, |
| 2364 int64_t filter_cache[]) { |
2365 VP9_COMMON *cm = &cpi->common; | 2365 VP9_COMMON *cm = &cpi->common; |
2366 RD_OPT *rd_opt = &cpi->rd; | |
2367 MACROBLOCKD *xd = &x->e_mbd; | 2366 MACROBLOCKD *xd = &x->e_mbd; |
2368 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; | 2367 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; |
2369 const int is_comp_pred = has_second_ref(mbmi); | 2368 const int is_comp_pred = has_second_ref(mbmi); |
2370 const int this_mode = mbmi->mode; | 2369 const int this_mode = mbmi->mode; |
2371 int_mv *frame_mv = mode_mv[this_mode]; | 2370 int_mv *frame_mv = mode_mv[this_mode]; |
2372 int i; | 2371 int i; |
2373 int refs[2] = { mbmi->ref_frame[0], | 2372 int refs[2] = { mbmi->ref_frame[0], |
2374 (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) }; | 2373 (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) }; |
2375 int_mv cur_mv[2]; | 2374 int_mv cur_mv[2]; |
2376 #if CONFIG_VP9_HIGHBITDEPTH | 2375 #if CONFIG_VP9_HIGHBITDEPTH |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2495 return INT64_MAX; | 2494 return INT64_MAX; |
2496 | 2495 |
2497 pred_exists = 0; | 2496 pred_exists = 0; |
2498 // Are all MVs integer pel for Y and UV | 2497 // Are all MVs integer pel for Y and UV |
2499 intpel_mv = !mv_has_subpel(&mbmi->mv[0].as_mv); | 2498 intpel_mv = !mv_has_subpel(&mbmi->mv[0].as_mv); |
2500 if (is_comp_pred) | 2499 if (is_comp_pred) |
2501 intpel_mv &= !mv_has_subpel(&mbmi->mv[1].as_mv); | 2500 intpel_mv &= !mv_has_subpel(&mbmi->mv[1].as_mv); |
2502 | 2501 |
2503 // Search for best switchable filter by checking the variance of | 2502 // Search for best switchable filter by checking the variance of |
2504 // pred error irrespective of whether the filter will be used | 2503 // pred error irrespective of whether the filter will be used |
2505 rd_opt->mask_filter = 0; | |
2506 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) | 2504 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) |
2507 rd_opt->filter_cache[i] = INT64_MAX; | 2505 filter_cache[i] = INT64_MAX; |
2508 | 2506 |
2509 if (cm->interp_filter != BILINEAR) { | 2507 if (cm->interp_filter != BILINEAR) { |
2510 if (x->source_variance < cpi->sf.disable_filter_search_var_thresh) { | 2508 if (x->source_variance < cpi->sf.disable_filter_search_var_thresh) { |
2511 best_filter = EIGHTTAP; | 2509 best_filter = EIGHTTAP; |
2512 } else if (best_filter == SWITCHABLE) { | 2510 } else if (best_filter == SWITCHABLE) { |
2513 int newbest; | 2511 int newbest; |
2514 int tmp_rate_sum = 0; | 2512 int tmp_rate_sum = 0; |
2515 int64_t tmp_dist_sum = 0; | 2513 int64_t tmp_dist_sum = 0; |
2516 | 2514 |
2517 for (i = 0; i < SWITCHABLE_FILTERS; ++i) { | 2515 for (i = 0; i < SWITCHABLE_FILTERS; ++i) { |
2518 int j; | 2516 int j; |
2519 int64_t rs_rd; | 2517 int64_t rs_rd; |
2520 int tmp_skip_sb = 0; | 2518 int tmp_skip_sb = 0; |
2521 int64_t tmp_skip_sse = INT64_MAX; | 2519 int64_t tmp_skip_sse = INT64_MAX; |
2522 | 2520 |
2523 mbmi->interp_filter = i; | 2521 mbmi->interp_filter = i; |
2524 rs = vp9_get_switchable_rate(cpi); | 2522 rs = vp9_get_switchable_rate(cpi); |
2525 rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0); | 2523 rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0); |
2526 | 2524 |
2527 if (i > 0 && intpel_mv) { | 2525 if (i > 0 && intpel_mv) { |
2528 rd = RDCOST(x->rdmult, x->rddiv, tmp_rate_sum, tmp_dist_sum); | 2526 rd = RDCOST(x->rdmult, x->rddiv, tmp_rate_sum, tmp_dist_sum); |
2529 rd_opt->filter_cache[i] = rd; | 2527 filter_cache[i] = rd; |
2530 rd_opt->filter_cache[SWITCHABLE_FILTERS] = | 2528 filter_cache[SWITCHABLE_FILTERS] = |
2531 MIN(rd_opt->filter_cache[SWITCHABLE_FILTERS], rd + rs_rd); | 2529 MIN(filter_cache[SWITCHABLE_FILTERS], rd + rs_rd); |
2532 if (cm->interp_filter == SWITCHABLE) | 2530 if (cm->interp_filter == SWITCHABLE) |
2533 rd += rs_rd; | 2531 rd += rs_rd; |
2534 rd_opt->mask_filter = MAX(rd_opt->mask_filter, rd); | 2532 *mask_filter = MAX(*mask_filter, rd); |
2535 } else { | 2533 } else { |
2536 int rate_sum = 0; | 2534 int rate_sum = 0; |
2537 int64_t dist_sum = 0; | 2535 int64_t dist_sum = 0; |
2538 if (i > 0 && cpi->sf.adaptive_interp_filter_search && | 2536 if (i > 0 && cpi->sf.adaptive_interp_filter_search && |
2539 (cpi->sf.interp_filter_search_mask & (1 << i))) { | 2537 (cpi->sf.interp_filter_search_mask & (1 << i))) { |
2540 rate_sum = INT_MAX; | 2538 rate_sum = INT_MAX; |
2541 dist_sum = INT64_MAX; | 2539 dist_sum = INT64_MAX; |
2542 continue; | 2540 continue; |
2543 } | 2541 } |
2544 | 2542 |
2545 if ((cm->interp_filter == SWITCHABLE && | 2543 if ((cm->interp_filter == SWITCHABLE && |
2546 (!i || best_needs_copy)) || | 2544 (!i || best_needs_copy)) || |
2547 (cm->interp_filter != SWITCHABLE && | 2545 (cm->interp_filter != SWITCHABLE && |
2548 (cm->interp_filter == mbmi->interp_filter || | 2546 (cm->interp_filter == mbmi->interp_filter || |
2549 (i == 0 && intpel_mv)))) { | 2547 (i == 0 && intpel_mv)))) { |
2550 restore_dst_buf(xd, orig_dst, orig_dst_stride); | 2548 restore_dst_buf(xd, orig_dst, orig_dst_stride); |
2551 } else { | 2549 } else { |
2552 for (j = 0; j < MAX_MB_PLANE; j++) { | 2550 for (j = 0; j < MAX_MB_PLANE; j++) { |
2553 xd->plane[j].dst.buf = tmp_buf + j * 64 * 64; | 2551 xd->plane[j].dst.buf = tmp_buf + j * 64 * 64; |
2554 xd->plane[j].dst.stride = 64; | 2552 xd->plane[j].dst.stride = 64; |
2555 } | 2553 } |
2556 } | 2554 } |
2557 vp9_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); | 2555 vp9_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); |
2558 model_rd_for_sb(cpi, bsize, x, xd, &rate_sum, &dist_sum, | 2556 model_rd_for_sb(cpi, bsize, x, xd, &rate_sum, &dist_sum, |
2559 &tmp_skip_sb, &tmp_skip_sse); | 2557 &tmp_skip_sb, &tmp_skip_sse); |
2560 | 2558 |
2561 rd = RDCOST(x->rdmult, x->rddiv, rate_sum, dist_sum); | 2559 rd = RDCOST(x->rdmult, x->rddiv, rate_sum, dist_sum); |
2562 rd_opt->filter_cache[i] = rd; | 2560 filter_cache[i] = rd; |
2563 rd_opt->filter_cache[SWITCHABLE_FILTERS] = | 2561 filter_cache[SWITCHABLE_FILTERS] = |
2564 MIN(rd_opt->filter_cache[SWITCHABLE_FILTERS], rd + rs_rd); | 2562 MIN(filter_cache[SWITCHABLE_FILTERS], rd + rs_rd); |
2565 if (cm->interp_filter == SWITCHABLE) | 2563 if (cm->interp_filter == SWITCHABLE) |
2566 rd += rs_rd; | 2564 rd += rs_rd; |
2567 rd_opt->mask_filter = MAX(rd_opt->mask_filter, rd); | 2565 *mask_filter = MAX(*mask_filter, rd); |
2568 | 2566 |
2569 if (i == 0 && intpel_mv) { | 2567 if (i == 0 && intpel_mv) { |
2570 tmp_rate_sum = rate_sum; | 2568 tmp_rate_sum = rate_sum; |
2571 tmp_dist_sum = dist_sum; | 2569 tmp_dist_sum = dist_sum; |
2572 } | 2570 } |
2573 } | 2571 } |
2574 | 2572 |
2575 if (i == 0 && cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) { | 2573 if (i == 0 && cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) { |
2576 if (rd / 2 > ref_best_rd) { | 2574 if (rd / 2 > ref_best_rd) { |
2577 restore_dst_buf(xd, orig_dst, orig_dst_stride); | 2575 restore_dst_buf(xd, orig_dst, orig_dst_stride); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2758 ctx->tx_rd_diff[i] = tx_cache[i] - tx_cache[cm->tx_mode]; | 2756 ctx->tx_rd_diff[i] = tx_cache[i] - tx_cache[cm->tx_mode]; |
2759 else | 2757 else |
2760 ctx->tx_rd_diff[i] = 0; | 2758 ctx->tx_rd_diff[i] = 0; |
2761 } | 2759 } |
2762 } | 2760 } |
2763 | 2761 |
2764 ctx->mic = *xd->mi[0].src_mi; | 2762 ctx->mic = *xd->mi[0].src_mi; |
2765 rd_cost->rdcost = RDCOST(x->rdmult, x->rddiv, rd_cost->rate, rd_cost->dist); | 2763 rd_cost->rdcost = RDCOST(x->rdmult, x->rddiv, rd_cost->rate, rd_cost->dist); |
2766 } | 2764 } |
2767 | 2765 |
2768 static void update_rd_thresh_fact(VP9_COMP *cpi, int bsize, | 2766 void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, |
2769 int best_mode_index) { | 2767 TileDataEnc *tile_data, |
2770 if (cpi->sf.adaptive_rd_thresh > 0) { | 2768 MACROBLOCK *x, |
2771 const int top_mode = bsize < BLOCK_8X8 ? MAX_REFS : MAX_MODES; | |
2772 int mode; | |
2773 for (mode = 0; mode < top_mode; ++mode) { | |
2774 const BLOCK_SIZE min_size = MAX(bsize - 1, BLOCK_4X4); | |
2775 const BLOCK_SIZE max_size = MIN(bsize + 2, BLOCK_64X64); | |
2776 BLOCK_SIZE bs; | |
2777 for (bs = min_size; bs <= max_size; ++bs) { | |
2778 int *const fact = &cpi->rd.thresh_freq_fact[bs][mode]; | |
2779 if (mode == best_mode_index) { | |
2780 *fact -= (*fact >> 4); | |
2781 } else { | |
2782 *fact = MIN(*fact + RD_THRESH_INC, | |
2783 cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT); | |
2784 } | |
2785 } | |
2786 } | |
2787 } | |
2788 } | |
2789 | |
2790 void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, | |
2791 const TileInfo *const tile, | |
2792 int mi_row, int mi_col, | 2769 int mi_row, int mi_col, |
2793 RD_COST *rd_cost, BLOCK_SIZE bsize, | 2770 RD_COST *rd_cost, BLOCK_SIZE bsize, |
2794 PICK_MODE_CONTEXT *ctx, | 2771 PICK_MODE_CONTEXT *ctx, |
2795 int64_t best_rd_so_far) { | 2772 int64_t best_rd_so_far) { |
2796 VP9_COMMON *const cm = &cpi->common; | 2773 VP9_COMMON *const cm = &cpi->common; |
| 2774 TileInfo *const tile_info = &tile_data->tile_info; |
2797 RD_OPT *const rd_opt = &cpi->rd; | 2775 RD_OPT *const rd_opt = &cpi->rd; |
2798 SPEED_FEATURES *const sf = &cpi->sf; | 2776 SPEED_FEATURES *const sf = &cpi->sf; |
2799 MACROBLOCKD *const xd = &x->e_mbd; | 2777 MACROBLOCKD *const xd = &x->e_mbd; |
2800 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; | 2778 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; |
2801 const struct segmentation *const seg = &cm->seg; | 2779 const struct segmentation *const seg = &cm->seg; |
2802 PREDICTION_MODE this_mode; | 2780 PREDICTION_MODE this_mode; |
2803 MV_REFERENCE_FRAME ref_frame, second_ref_frame; | 2781 MV_REFERENCE_FRAME ref_frame, second_ref_frame; |
2804 unsigned char segment_id = mbmi->segment_id; | 2782 unsigned char segment_id = mbmi->segment_id; |
2805 int comp_pred, i, k; | 2783 int comp_pred, i, k; |
2806 int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES]; | 2784 int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES]; |
(...skipping 22 matching lines...) Expand all Loading... |
2829 int64_t dist_uv[TX_SIZES]; | 2807 int64_t dist_uv[TX_SIZES]; |
2830 int skip_uv[TX_SIZES]; | 2808 int skip_uv[TX_SIZES]; |
2831 PREDICTION_MODE mode_uv[TX_SIZES]; | 2809 PREDICTION_MODE mode_uv[TX_SIZES]; |
2832 const int intra_cost_penalty = vp9_get_intra_cost_penalty( | 2810 const int intra_cost_penalty = vp9_get_intra_cost_penalty( |
2833 cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth); | 2811 cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth); |
2834 int best_skip2 = 0; | 2812 int best_skip2 = 0; |
2835 uint8_t ref_frame_skip_mask[2] = { 0 }; | 2813 uint8_t ref_frame_skip_mask[2] = { 0 }; |
2836 uint16_t mode_skip_mask[MAX_REF_FRAMES] = { 0 }; | 2814 uint16_t mode_skip_mask[MAX_REF_FRAMES] = { 0 }; |
2837 int mode_skip_start = sf->mode_skip_start + 1; | 2815 int mode_skip_start = sf->mode_skip_start + 1; |
2838 const int *const rd_threshes = rd_opt->threshes[segment_id][bsize]; | 2816 const int *const rd_threshes = rd_opt->threshes[segment_id][bsize]; |
2839 const int *const rd_thresh_freq_fact = rd_opt->thresh_freq_fact[bsize]; | 2817 const int *const rd_thresh_freq_fact = tile_data->thresh_freq_fact[bsize]; |
2840 int64_t mode_threshold[MAX_MODES]; | 2818 int64_t mode_threshold[MAX_MODES]; |
2841 int *mode_map = rd_opt->mode_map[bsize]; | 2819 int *mode_map = tile_data->mode_map[bsize]; |
2842 const int mode_search_skip_flags = sf->mode_search_skip_flags; | 2820 const int mode_search_skip_flags = sf->mode_search_skip_flags; |
| 2821 int64_t mask_filter = 0; |
| 2822 int64_t filter_cache[SWITCHABLE_FILTER_CONTEXTS]; |
| 2823 |
2843 vp9_zero(best_mbmode); | 2824 vp9_zero(best_mbmode); |
2844 | 2825 |
2845 x->skip_encode = sf->skip_encode_frame && x->q_index < QIDX_SKIP_THRESH; | 2826 x->skip_encode = sf->skip_encode_frame && x->q_index < QIDX_SKIP_THRESH; |
2846 | 2827 |
| 2828 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) |
| 2829 filter_cache[i] = INT64_MAX; |
| 2830 |
2847 estimate_ref_frame_costs(cm, xd, segment_id, ref_costs_single, ref_costs_comp, | 2831 estimate_ref_frame_costs(cm, xd, segment_id, ref_costs_single, ref_costs_comp, |
2848 &comp_mode_p); | 2832 &comp_mode_p); |
2849 | 2833 |
2850 for (i = 0; i < REFERENCE_MODES; ++i) | 2834 for (i = 0; i < REFERENCE_MODES; ++i) |
2851 best_pred_rd[i] = INT64_MAX; | 2835 best_pred_rd[i] = INT64_MAX; |
2852 for (i = 0; i < TX_MODES; i++) | 2836 for (i = 0; i < TX_MODES; i++) |
2853 best_tx_rd[i] = INT64_MAX; | 2837 best_tx_rd[i] = INT64_MAX; |
2854 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) | 2838 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) |
2855 best_filter_rd[i] = INT64_MAX; | 2839 best_filter_rd[i] = INT64_MAX; |
2856 for (i = 0; i < TX_SIZES; i++) | 2840 for (i = 0; i < TX_SIZES; i++) |
2857 rate_uv_intra[i] = INT_MAX; | 2841 rate_uv_intra[i] = INT_MAX; |
2858 for (i = 0; i < MAX_REF_FRAMES; ++i) | 2842 for (i = 0; i < MAX_REF_FRAMES; ++i) |
2859 x->pred_sse[i] = INT_MAX; | 2843 x->pred_sse[i] = INT_MAX; |
2860 for (i = 0; i < MB_MODE_COUNT; ++i) { | 2844 for (i = 0; i < MB_MODE_COUNT; ++i) { |
2861 for (k = 0; k < MAX_REF_FRAMES; ++k) { | 2845 for (k = 0; k < MAX_REF_FRAMES; ++k) { |
2862 single_inter_filter[i][k] = SWITCHABLE; | 2846 single_inter_filter[i][k] = SWITCHABLE; |
2863 single_skippable[i][k] = 0; | 2847 single_skippable[i][k] = 0; |
2864 } | 2848 } |
2865 } | 2849 } |
2866 | 2850 |
2867 rd_cost->rate = INT_MAX; | 2851 rd_cost->rate = INT_MAX; |
2868 | 2852 |
2869 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { | 2853 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { |
2870 x->pred_mv_sad[ref_frame] = INT_MAX; | 2854 x->pred_mv_sad[ref_frame] = INT_MAX; |
2871 if (cpi->ref_frame_flags & flag_list[ref_frame]) { | 2855 if (cpi->ref_frame_flags & flag_list[ref_frame]) { |
2872 setup_buffer_inter(cpi, x, tile, ref_frame, bsize, mi_row, mi_col, | 2856 setup_buffer_inter(cpi, x, tile_info, ref_frame, bsize, mi_row, mi_col, |
2873 frame_mv[NEARESTMV], frame_mv[NEARMV], yv12_mb); | 2857 frame_mv[NEARESTMV], frame_mv[NEARMV], yv12_mb); |
2874 } | 2858 } |
2875 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; | 2859 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; |
2876 frame_mv[ZEROMV][ref_frame].as_int = 0; | 2860 frame_mv[ZEROMV][ref_frame].as_int = 0; |
2877 } | 2861 } |
2878 | 2862 |
2879 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { | 2863 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { |
2880 if (!(cpi->ref_frame_flags & flag_list[ref_frame])) { | 2864 if (!(cpi->ref_frame_flags & flag_list[ref_frame])) { |
2881 // Skip checking missing references in both single and compound reference | 2865 // Skip checking missing references in both single and compound reference |
2882 // modes. Note that a mode will be skipped iff both reference frames | 2866 // modes. Note that a mode will be skipped iff both reference frames |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3016 | 3000 |
3017 // Test best rd so far against threshold for trying this mode. | 3001 // Test best rd so far against threshold for trying this mode. |
3018 if (best_mode_skippable && sf->schedule_mode_search) | 3002 if (best_mode_skippable && sf->schedule_mode_search) |
3019 mode_threshold[mode_index] <<= 1; | 3003 mode_threshold[mode_index] <<= 1; |
3020 | 3004 |
3021 if (best_rd < mode_threshold[mode_index]) | 3005 if (best_rd < mode_threshold[mode_index]) |
3022 continue; | 3006 continue; |
3023 | 3007 |
3024 if (sf->motion_field_mode_search) { | 3008 if (sf->motion_field_mode_search) { |
3025 const int mi_width = MIN(num_8x8_blocks_wide_lookup[bsize], | 3009 const int mi_width = MIN(num_8x8_blocks_wide_lookup[bsize], |
3026 tile->mi_col_end - mi_col); | 3010 tile_info->mi_col_end - mi_col); |
3027 const int mi_height = MIN(num_8x8_blocks_high_lookup[bsize], | 3011 const int mi_height = MIN(num_8x8_blocks_high_lookup[bsize], |
3028 tile->mi_row_end - mi_row); | 3012 tile_info->mi_row_end - mi_row); |
3029 const int bsl = mi_width_log2_lookup[bsize]; | 3013 const int bsl = mi_width_log2_lookup[bsize]; |
3030 int cb_partition_search_ctrl = (((mi_row + mi_col) >> bsl) | 3014 int cb_partition_search_ctrl = (((mi_row + mi_col) >> bsl) |
3031 + get_chessboard_index(cm->current_video_frame)) & 0x1; | 3015 + get_chessboard_index(cm->current_video_frame)) & 0x1; |
3032 MB_MODE_INFO *ref_mbmi; | 3016 MB_MODE_INFO *ref_mbmi; |
3033 int const_motion = 1; | 3017 int const_motion = 1; |
3034 int skip_ref_frame = !cb_partition_search_ctrl; | 3018 int skip_ref_frame = !cb_partition_search_ctrl; |
3035 MV_REFERENCE_FRAME rf = NONE; | 3019 MV_REFERENCE_FRAME rf = NONE; |
3036 int_mv ref_mv; | 3020 int_mv ref_mv; |
3037 ref_mv.as_int = INVALID_MV; | 3021 ref_mv.as_int = INVALID_MV; |
3038 | 3022 |
3039 if ((mi_row - 1) >= tile->mi_row_start) { | 3023 if ((mi_row - 1) >= tile_info->mi_row_start) { |
3040 ref_mv = xd->mi[-xd->mi_stride].src_mi->mbmi.mv[0]; | 3024 ref_mv = xd->mi[-xd->mi_stride].src_mi->mbmi.mv[0]; |
3041 rf = xd->mi[-xd->mi_stride].src_mi->mbmi.ref_frame[0]; | 3025 rf = xd->mi[-xd->mi_stride].src_mi->mbmi.ref_frame[0]; |
3042 for (i = 0; i < mi_width; ++i) { | 3026 for (i = 0; i < mi_width; ++i) { |
3043 ref_mbmi = &xd->mi[-xd->mi_stride + i].src_mi->mbmi; | 3027 ref_mbmi = &xd->mi[-xd->mi_stride + i].src_mi->mbmi; |
3044 const_motion &= (ref_mv.as_int == ref_mbmi->mv[0].as_int) && | 3028 const_motion &= (ref_mv.as_int == ref_mbmi->mv[0].as_int) && |
3045 (ref_frame == ref_mbmi->ref_frame[0]); | 3029 (ref_frame == ref_mbmi->ref_frame[0]); |
3046 skip_ref_frame &= (rf == ref_mbmi->ref_frame[0]); | 3030 skip_ref_frame &= (rf == ref_mbmi->ref_frame[0]); |
3047 } | 3031 } |
3048 } | 3032 } |
3049 | 3033 |
3050 if ((mi_col - 1) >= tile->mi_col_start) { | 3034 if ((mi_col - 1) >= tile_info->mi_col_start) { |
3051 if (ref_mv.as_int == INVALID_MV) | 3035 if (ref_mv.as_int == INVALID_MV) |
3052 ref_mv = xd->mi[-1].src_mi->mbmi.mv[0]; | 3036 ref_mv = xd->mi[-1].src_mi->mbmi.mv[0]; |
3053 if (rf == NONE) | 3037 if (rf == NONE) |
3054 rf = xd->mi[-1].src_mi->mbmi.ref_frame[0]; | 3038 rf = xd->mi[-1].src_mi->mbmi.ref_frame[0]; |
3055 for (i = 0; i < mi_height; ++i) { | 3039 for (i = 0; i < mi_height; ++i) { |
3056 ref_mbmi = &xd->mi[i * xd->mi_stride - 1].src_mi->mbmi; | 3040 ref_mbmi = &xd->mi[i * xd->mi_stride - 1].src_mi->mbmi; |
3057 const_motion &= (ref_mv.as_int == ref_mbmi->mv[0].as_int) && | 3041 const_motion &= (ref_mv.as_int == ref_mbmi->mv[0].as_int) && |
3058 (ref_frame == ref_mbmi->ref_frame[0]); | 3042 (ref_frame == ref_mbmi->ref_frame[0]); |
3059 skip_ref_frame &= (rf == ref_mbmi->ref_frame[0]); | 3043 skip_ref_frame &= (rf == ref_mbmi->ref_frame[0]); |
3060 } | 3044 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3177 rate2 += intra_cost_penalty; | 3161 rate2 += intra_cost_penalty; |
3178 distortion2 = distortion_y + distortion_uv; | 3162 distortion2 = distortion_y + distortion_uv; |
3179 } else { | 3163 } else { |
3180 this_rd = handle_inter_mode(cpi, x, bsize, | 3164 this_rd = handle_inter_mode(cpi, x, bsize, |
3181 tx_cache, | 3165 tx_cache, |
3182 &rate2, &distortion2, &skippable, | 3166 &rate2, &distortion2, &skippable, |
3183 &rate_y, &rate_uv, | 3167 &rate_y, &rate_uv, |
3184 &disable_skip, frame_mv, | 3168 &disable_skip, frame_mv, |
3185 mi_row, mi_col, | 3169 mi_row, mi_col, |
3186 single_newmv, single_inter_filter, | 3170 single_newmv, single_inter_filter, |
3187 single_skippable, &total_sse, best_rd); | 3171 single_skippable, &total_sse, best_rd, |
| 3172 &mask_filter, filter_cache); |
3188 if (this_rd == INT64_MAX) | 3173 if (this_rd == INT64_MAX) |
3189 continue; | 3174 continue; |
3190 | 3175 |
3191 compmode_cost = vp9_cost_bit(comp_mode_p, comp_pred); | 3176 compmode_cost = vp9_cost_bit(comp_mode_p, comp_pred); |
3192 | 3177 |
3193 if (cm->reference_mode == REFERENCE_MODE_SELECT) | 3178 if (cm->reference_mode == REFERENCE_MODE_SELECT) |
3194 rate2 += compmode_cost; | 3179 rate2 += compmode_cost; |
3195 } | 3180 } |
3196 | 3181 |
3197 // Estimate the reference frame signaling cost and add it | 3182 // Estimate the reference frame signaling cost and add it |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3318 best_pred_rd[SINGLE_REFERENCE] = single_rd; | 3303 best_pred_rd[SINGLE_REFERENCE] = single_rd; |
3319 } else { | 3304 } else { |
3320 if (single_rd < best_pred_rd[COMPOUND_REFERENCE]) | 3305 if (single_rd < best_pred_rd[COMPOUND_REFERENCE]) |
3321 best_pred_rd[COMPOUND_REFERENCE] = single_rd; | 3306 best_pred_rd[COMPOUND_REFERENCE] = single_rd; |
3322 } | 3307 } |
3323 if (hybrid_rd < best_pred_rd[REFERENCE_MODE_SELECT]) | 3308 if (hybrid_rd < best_pred_rd[REFERENCE_MODE_SELECT]) |
3324 best_pred_rd[REFERENCE_MODE_SELECT] = hybrid_rd; | 3309 best_pred_rd[REFERENCE_MODE_SELECT] = hybrid_rd; |
3325 | 3310 |
3326 /* keep record of best filter type */ | 3311 /* keep record of best filter type */ |
3327 if (!mode_excluded && cm->interp_filter != BILINEAR) { | 3312 if (!mode_excluded && cm->interp_filter != BILINEAR) { |
3328 int64_t ref = rd_opt->filter_cache[cm->interp_filter == SWITCHABLE ? | 3313 int64_t ref = filter_cache[cm->interp_filter == SWITCHABLE ? |
3329 SWITCHABLE_FILTERS : cm->interp_filter]; | 3314 SWITCHABLE_FILTERS : cm->interp_filter]; |
3330 | 3315 |
3331 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) { | 3316 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) { |
3332 int64_t adj_rd; | 3317 int64_t adj_rd; |
3333 if (ref == INT64_MAX) | 3318 if (ref == INT64_MAX) |
3334 adj_rd = 0; | 3319 adj_rd = 0; |
3335 else if (rd_opt->filter_cache[i] == INT64_MAX) | 3320 else if (filter_cache[i] == INT64_MAX) |
3336 // when early termination is triggered, the encoder does not have | 3321 // when early termination is triggered, the encoder does not have |
3337 // access to the rate-distortion cost. it only knows that the cost | 3322 // access to the rate-distortion cost. it only knows that the cost |
3338 // should be above the maximum valid value. hence it takes the known | 3323 // should be above the maximum valid value. hence it takes the known |
3339 // maximum plus an arbitrary constant as the rate-distortion cost. | 3324 // maximum plus an arbitrary constant as the rate-distortion cost. |
3340 adj_rd = rd_opt->mask_filter - ref + 10; | 3325 adj_rd = mask_filter - ref + 10; |
3341 else | 3326 else |
3342 adj_rd = rd_opt->filter_cache[i] - ref; | 3327 adj_rd = filter_cache[i] - ref; |
3343 | 3328 |
3344 adj_rd += this_rd; | 3329 adj_rd += this_rd; |
3345 best_filter_rd[i] = MIN(best_filter_rd[i], adj_rd); | 3330 best_filter_rd[i] = MIN(best_filter_rd[i], adj_rd); |
3346 } | 3331 } |
3347 } | 3332 } |
3348 } | 3333 } |
3349 | 3334 |
3350 /* keep record of best txfm size */ | 3335 /* keep record of best txfm size */ |
3351 if (bsize < BLOCK_32X32) { | 3336 if (bsize < BLOCK_32X32) { |
3352 if (bsize < BLOCK_16X16) | 3337 if (bsize < BLOCK_16X16) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3413 bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize, | 3398 bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize, |
3414 uv_tx_size); | 3399 uv_tx_size); |
3415 } | 3400 } |
3416 } | 3401 } |
3417 | 3402 |
3418 assert((cm->interp_filter == SWITCHABLE) || | 3403 assert((cm->interp_filter == SWITCHABLE) || |
3419 (cm->interp_filter == best_mbmode.interp_filter) || | 3404 (cm->interp_filter == best_mbmode.interp_filter) || |
3420 !is_inter_block(&best_mbmode)); | 3405 !is_inter_block(&best_mbmode)); |
3421 | 3406 |
3422 if (!cpi->rc.is_src_frame_alt_ref) | 3407 if (!cpi->rc.is_src_frame_alt_ref) |
3423 update_rd_thresh_fact(cpi, bsize, best_mode_index); | 3408 vp9_update_rd_thresh_fact(tile_data->thresh_freq_fact, |
| 3409 sf->adaptive_rd_thresh, bsize, best_mode_index); |
3424 | 3410 |
3425 // macroblock modes | 3411 // macroblock modes |
3426 *mbmi = best_mbmode; | 3412 *mbmi = best_mbmode; |
3427 x->skip |= best_skip2; | 3413 x->skip |= best_skip2; |
3428 | 3414 |
3429 for (i = 0; i < REFERENCE_MODES; ++i) { | 3415 for (i = 0; i < REFERENCE_MODES; ++i) { |
3430 if (best_pred_rd[i] == INT64_MAX) | 3416 if (best_pred_rd[i] == INT64_MAX) |
3431 best_pred_diff[i] = INT_MIN; | 3417 best_pred_diff[i] = INT_MIN; |
3432 else | 3418 else |
3433 best_pred_diff[i] = best_rd - best_pred_rd[i]; | 3419 best_pred_diff[i] = best_rd - best_pred_rd[i]; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3472 has_high_freq_coeff |= vp9_has_high_freq_in_plane(x, bsize, plane); | 3458 has_high_freq_coeff |= vp9_has_high_freq_in_plane(x, bsize, plane); |
3473 } | 3459 } |
3474 | 3460 |
3475 best_mode_skippable |= !has_high_freq_coeff; | 3461 best_mode_skippable |= !has_high_freq_coeff; |
3476 } | 3462 } |
3477 | 3463 |
3478 store_coding_context(x, ctx, best_mode_index, best_pred_diff, | 3464 store_coding_context(x, ctx, best_mode_index, best_pred_diff, |
3479 best_tx_diff, best_filter_diff, best_mode_skippable); | 3465 best_tx_diff, best_filter_diff, best_mode_skippable); |
3480 } | 3466 } |
3481 | 3467 |
3482 void vp9_rd_pick_inter_mode_sb_seg_skip(VP9_COMP *cpi, MACROBLOCK *x, | 3468 void vp9_rd_pick_inter_mode_sb_seg_skip(VP9_COMP *cpi, |
| 3469 TileDataEnc *tile_data, |
| 3470 MACROBLOCK *x, |
3483 RD_COST *rd_cost, | 3471 RD_COST *rd_cost, |
3484 BLOCK_SIZE bsize, | 3472 BLOCK_SIZE bsize, |
3485 PICK_MODE_CONTEXT *ctx, | 3473 PICK_MODE_CONTEXT *ctx, |
3486 int64_t best_rd_so_far) { | 3474 int64_t best_rd_so_far) { |
3487 VP9_COMMON *const cm = &cpi->common; | 3475 VP9_COMMON *const cm = &cpi->common; |
3488 RD_OPT *const rd_opt = &cpi->rd; | |
3489 MACROBLOCKD *const xd = &x->e_mbd; | 3476 MACROBLOCKD *const xd = &x->e_mbd; |
3490 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; | 3477 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; |
3491 unsigned char segment_id = mbmi->segment_id; | 3478 unsigned char segment_id = mbmi->segment_id; |
3492 const int comp_pred = 0; | 3479 const int comp_pred = 0; |
3493 int i; | 3480 int i; |
3494 int64_t best_tx_diff[TX_MODES]; | 3481 int64_t best_tx_diff[TX_MODES]; |
3495 int64_t best_pred_diff[REFERENCE_MODES]; | 3482 int64_t best_pred_diff[REFERENCE_MODES]; |
3496 int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; | 3483 int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; |
3497 unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES]; | 3484 unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES]; |
3498 vp9_prob comp_mode_p; | 3485 vp9_prob comp_mode_p; |
(...skipping 16 matching lines...) Expand all Loading... |
3515 | 3502 |
3516 assert(vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)); | 3503 assert(vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)); |
3517 | 3504 |
3518 mbmi->mode = ZEROMV; | 3505 mbmi->mode = ZEROMV; |
3519 mbmi->uv_mode = DC_PRED; | 3506 mbmi->uv_mode = DC_PRED; |
3520 mbmi->ref_frame[0] = LAST_FRAME; | 3507 mbmi->ref_frame[0] = LAST_FRAME; |
3521 mbmi->ref_frame[1] = NONE; | 3508 mbmi->ref_frame[1] = NONE; |
3522 mbmi->mv[0].as_int = 0; | 3509 mbmi->mv[0].as_int = 0; |
3523 x->skip = 1; | 3510 x->skip = 1; |
3524 | 3511 |
3525 // Search for best switchable filter by checking the variance of | |
3526 // pred error irrespective of whether the filter will be used | |
3527 rd_opt->mask_filter = 0; | |
3528 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) | |
3529 rd_opt->filter_cache[i] = INT64_MAX; | |
3530 | |
3531 if (cm->interp_filter != BILINEAR) { | 3512 if (cm->interp_filter != BILINEAR) { |
3532 best_filter = EIGHTTAP; | 3513 best_filter = EIGHTTAP; |
3533 if (cm->interp_filter == SWITCHABLE && | 3514 if (cm->interp_filter == SWITCHABLE && |
3534 x->source_variance >= cpi->sf.disable_filter_search_var_thresh) { | 3515 x->source_variance >= cpi->sf.disable_filter_search_var_thresh) { |
3535 int rs; | 3516 int rs; |
3536 int best_rs = INT_MAX; | 3517 int best_rs = INT_MAX; |
3537 for (i = 0; i < SWITCHABLE_FILTERS; ++i) { | 3518 for (i = 0; i < SWITCHABLE_FILTERS; ++i) { |
3538 mbmi->interp_filter = i; | 3519 mbmi->interp_filter = i; |
3539 rs = vp9_get_switchable_rate(cpi); | 3520 rs = vp9_get_switchable_rate(cpi); |
3540 if (rs < best_rs) { | 3521 if (rs < best_rs) { |
(...skipping 25 matching lines...) Expand all Loading... |
3566 | 3547 |
3567 if (this_rd >= best_rd_so_far) { | 3548 if (this_rd >= best_rd_so_far) { |
3568 rd_cost->rate = INT_MAX; | 3549 rd_cost->rate = INT_MAX; |
3569 rd_cost->rdcost = INT64_MAX; | 3550 rd_cost->rdcost = INT64_MAX; |
3570 return; | 3551 return; |
3571 } | 3552 } |
3572 | 3553 |
3573 assert((cm->interp_filter == SWITCHABLE) || | 3554 assert((cm->interp_filter == SWITCHABLE) || |
3574 (cm->interp_filter == mbmi->interp_filter)); | 3555 (cm->interp_filter == mbmi->interp_filter)); |
3575 | 3556 |
3576 update_rd_thresh_fact(cpi, bsize, THR_ZEROMV); | 3557 vp9_update_rd_thresh_fact(tile_data->thresh_freq_fact, |
| 3558 cpi->sf.adaptive_rd_thresh, bsize, THR_ZEROMV); |
3577 | 3559 |
3578 vp9_zero(best_pred_diff); | 3560 vp9_zero(best_pred_diff); |
3579 vp9_zero(best_filter_diff); | 3561 vp9_zero(best_filter_diff); |
3580 vp9_zero(best_tx_diff); | 3562 vp9_zero(best_tx_diff); |
3581 | 3563 |
3582 if (!x->select_tx_size) | 3564 if (!x->select_tx_size) |
3583 swap_block_ptr(x, ctx, 1, 0, 0, MAX_MB_PLANE); | 3565 swap_block_ptr(x, ctx, 1, 0, 0, MAX_MB_PLANE); |
3584 store_coding_context(x, ctx, THR_ZEROMV, | 3566 store_coding_context(x, ctx, THR_ZEROMV, |
3585 best_pred_diff, best_tx_diff, best_filter_diff, 0); | 3567 best_pred_diff, best_tx_diff, best_filter_diff, 0); |
3586 } | 3568 } |
3587 | 3569 |
3588 void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, | 3570 void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, |
3589 const TileInfo *const tile, | 3571 TileDataEnc *tile_data, |
| 3572 MACROBLOCK *x, |
3590 int mi_row, int mi_col, | 3573 int mi_row, int mi_col, |
3591 RD_COST *rd_cost, | 3574 RD_COST *rd_cost, |
3592 BLOCK_SIZE bsize, | 3575 BLOCK_SIZE bsize, |
3593 PICK_MODE_CONTEXT *ctx, | 3576 PICK_MODE_CONTEXT *ctx, |
3594 int64_t best_rd_so_far) { | 3577 int64_t best_rd_so_far) { |
3595 VP9_COMMON *const cm = &cpi->common; | 3578 VP9_COMMON *const cm = &cpi->common; |
| 3579 TileInfo *const tile_info = &tile_data->tile_info; |
3596 RD_OPT *const rd_opt = &cpi->rd; | 3580 RD_OPT *const rd_opt = &cpi->rd; |
3597 SPEED_FEATURES *const sf = &cpi->sf; | 3581 SPEED_FEATURES *const sf = &cpi->sf; |
3598 MACROBLOCKD *const xd = &x->e_mbd; | 3582 MACROBLOCKD *const xd = &x->e_mbd; |
3599 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; | 3583 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; |
3600 const struct segmentation *const seg = &cm->seg; | 3584 const struct segmentation *const seg = &cm->seg; |
3601 MV_REFERENCE_FRAME ref_frame, second_ref_frame; | 3585 MV_REFERENCE_FRAME ref_frame, second_ref_frame; |
3602 unsigned char segment_id = mbmi->segment_id; | 3586 unsigned char segment_id = mbmi->segment_id; |
3603 int comp_pred, i; | 3587 int comp_pred, i; |
3604 int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES]; | 3588 int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES]; |
3605 struct buf_2d yv12_mb[4][MAX_MB_PLANE]; | 3589 struct buf_2d yv12_mb[4][MAX_MB_PLANE]; |
(...skipping 14 matching lines...) Expand all Loading... |
3620 int rate_uv_intra, rate_uv_tokenonly; | 3604 int rate_uv_intra, rate_uv_tokenonly; |
3621 int64_t dist_uv; | 3605 int64_t dist_uv; |
3622 int skip_uv; | 3606 int skip_uv; |
3623 PREDICTION_MODE mode_uv = DC_PRED; | 3607 PREDICTION_MODE mode_uv = DC_PRED; |
3624 const int intra_cost_penalty = vp9_get_intra_cost_penalty( | 3608 const int intra_cost_penalty = vp9_get_intra_cost_penalty( |
3625 cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth); | 3609 cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth); |
3626 int_mv seg_mvs[4][MAX_REF_FRAMES]; | 3610 int_mv seg_mvs[4][MAX_REF_FRAMES]; |
3627 b_mode_info best_bmodes[4]; | 3611 b_mode_info best_bmodes[4]; |
3628 int best_skip2 = 0; | 3612 int best_skip2 = 0; |
3629 int ref_frame_skip_mask[2] = { 0 }; | 3613 int ref_frame_skip_mask[2] = { 0 }; |
| 3614 int64_t mask_filter = 0; |
| 3615 int64_t filter_cache[SWITCHABLE_FILTER_CONTEXTS]; |
3630 | 3616 |
3631 x->skip_encode = sf->skip_encode_frame && x->q_index < QIDX_SKIP_THRESH; | 3617 x->skip_encode = sf->skip_encode_frame && x->q_index < QIDX_SKIP_THRESH; |
3632 vpx_memset(x->zcoeff_blk[TX_4X4], 0, 4); | 3618 vpx_memset(x->zcoeff_blk[TX_4X4], 0, 4); |
3633 vp9_zero(best_mbmode); | 3619 vp9_zero(best_mbmode); |
3634 | 3620 |
| 3621 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) |
| 3622 filter_cache[i] = INT64_MAX; |
| 3623 |
3635 for (i = 0; i < 4; i++) { | 3624 for (i = 0; i < 4; i++) { |
3636 int j; | 3625 int j; |
3637 for (j = 0; j < MAX_REF_FRAMES; j++) | 3626 for (j = 0; j < MAX_REF_FRAMES; j++) |
3638 seg_mvs[i][j].as_int = INVALID_MV; | 3627 seg_mvs[i][j].as_int = INVALID_MV; |
3639 } | 3628 } |
3640 | 3629 |
3641 estimate_ref_frame_costs(cm, xd, segment_id, ref_costs_single, ref_costs_comp, | 3630 estimate_ref_frame_costs(cm, xd, segment_id, ref_costs_single, ref_costs_comp, |
3642 &comp_mode_p); | 3631 &comp_mode_p); |
3643 | 3632 |
3644 for (i = 0; i < REFERENCE_MODES; ++i) | 3633 for (i = 0; i < REFERENCE_MODES; ++i) |
3645 best_pred_rd[i] = INT64_MAX; | 3634 best_pred_rd[i] = INT64_MAX; |
3646 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) | 3635 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) |
3647 best_filter_rd[i] = INT64_MAX; | 3636 best_filter_rd[i] = INT64_MAX; |
3648 rate_uv_intra = INT_MAX; | 3637 rate_uv_intra = INT_MAX; |
3649 | 3638 |
3650 rd_cost->rate = INT_MAX; | 3639 rd_cost->rate = INT_MAX; |
3651 | 3640 |
3652 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) { | 3641 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) { |
3653 if (cpi->ref_frame_flags & flag_list[ref_frame]) { | 3642 if (cpi->ref_frame_flags & flag_list[ref_frame]) { |
3654 setup_buffer_inter(cpi, x, tile, | 3643 setup_buffer_inter(cpi, x, tile_info, |
3655 ref_frame, bsize, mi_row, mi_col, | 3644 ref_frame, bsize, mi_row, mi_col, |
3656 frame_mv[NEARESTMV], frame_mv[NEARMV], | 3645 frame_mv[NEARESTMV], frame_mv[NEARMV], |
3657 yv12_mb); | 3646 yv12_mb); |
3658 } else { | 3647 } else { |
3659 ref_frame_skip_mask[0] |= (1 << ref_frame); | 3648 ref_frame_skip_mask[0] |= (1 << ref_frame); |
3660 ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK; | 3649 ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK; |
3661 } | 3650 } |
3662 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; | 3651 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; |
3663 frame_mv[ZEROMV][ref_frame].as_int = 0; | 3652 frame_mv[ZEROMV][ref_frame].as_int = 0; |
3664 } | 3653 } |
3665 | 3654 |
3666 for (ref_index = 0; ref_index < MAX_REFS; ++ref_index) { | 3655 for (ref_index = 0; ref_index < MAX_REFS; ++ref_index) { |
3667 int mode_excluded = 0; | 3656 int mode_excluded = 0; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3705 } | 3694 } |
3706 } | 3695 } |
3707 | 3696 |
3708 if (ref_frame_skip_mask[0] & (1 << ref_frame) && | 3697 if (ref_frame_skip_mask[0] & (1 << ref_frame) && |
3709 ref_frame_skip_mask[1] & (1 << MAX(0, second_ref_frame))) | 3698 ref_frame_skip_mask[1] & (1 << MAX(0, second_ref_frame))) |
3710 continue; | 3699 continue; |
3711 | 3700 |
3712 // Test best rd so far against threshold for trying this mode. | 3701 // Test best rd so far against threshold for trying this mode. |
3713 if (rd_less_than_thresh(best_rd, | 3702 if (rd_less_than_thresh(best_rd, |
3714 rd_opt->threshes[segment_id][bsize][ref_index], | 3703 rd_opt->threshes[segment_id][bsize][ref_index], |
3715 rd_opt->thresh_freq_fact[bsize][ref_index])) | 3704 tile_data->thresh_freq_fact[bsize][ref_index])) |
3716 continue; | 3705 continue; |
3717 | 3706 |
3718 comp_pred = second_ref_frame > INTRA_FRAME; | 3707 comp_pred = second_ref_frame > INTRA_FRAME; |
3719 if (comp_pred) { | 3708 if (comp_pred) { |
3720 if (!cm->allow_comp_inter_inter) | 3709 if (!cm->allow_comp_inter_inter) |
3721 continue; | 3710 continue; |
3722 if (!(cpi->ref_frame_flags & flag_list[second_ref_frame])) | 3711 if (!(cpi->ref_frame_flags & flag_list[second_ref_frame])) |
3723 continue; | 3712 continue; |
3724 // Do not allow compound prediction if the segment level reference frame | 3713 // Do not allow compound prediction if the segment level reference frame |
3725 // feature is in use as in this case there can only be one reference. | 3714 // feature is in use as in this case there can only be one reference. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3817 MB_MODE_INFO tmp_best_mbmode; | 3806 MB_MODE_INFO tmp_best_mbmode; |
3818 BEST_SEG_INFO bsi[SWITCHABLE_FILTERS]; | 3807 BEST_SEG_INFO bsi[SWITCHABLE_FILTERS]; |
3819 int pred_exists = 0; | 3808 int pred_exists = 0; |
3820 int uv_skippable; | 3809 int uv_skippable; |
3821 | 3810 |
3822 this_rd_thresh = (ref_frame == LAST_FRAME) ? | 3811 this_rd_thresh = (ref_frame == LAST_FRAME) ? |
3823 rd_opt->threshes[segment_id][bsize][THR_LAST] : | 3812 rd_opt->threshes[segment_id][bsize][THR_LAST] : |
3824 rd_opt->threshes[segment_id][bsize][THR_ALTR]; | 3813 rd_opt->threshes[segment_id][bsize][THR_ALTR]; |
3825 this_rd_thresh = (ref_frame == GOLDEN_FRAME) ? | 3814 this_rd_thresh = (ref_frame == GOLDEN_FRAME) ? |
3826 rd_opt->threshes[segment_id][bsize][THR_GOLD] : this_rd_thresh; | 3815 rd_opt->threshes[segment_id][bsize][THR_GOLD] : this_rd_thresh; |
3827 rd_opt->mask_filter = 0; | |
3828 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) | 3816 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) |
3829 rd_opt->filter_cache[i] = INT64_MAX; | 3817 filter_cache[i] = INT64_MAX; |
3830 | 3818 |
3831 if (cm->interp_filter != BILINEAR) { | 3819 if (cm->interp_filter != BILINEAR) { |
3832 tmp_best_filter = EIGHTTAP; | 3820 tmp_best_filter = EIGHTTAP; |
3833 if (x->source_variance < sf->disable_filter_search_var_thresh) { | 3821 if (x->source_variance < sf->disable_filter_search_var_thresh) { |
3834 tmp_best_filter = EIGHTTAP; | 3822 tmp_best_filter = EIGHTTAP; |
3835 } else if (sf->adaptive_pred_interp_filter == 1 && | 3823 } else if (sf->adaptive_pred_interp_filter == 1 && |
3836 ctx->pred_interp_filter < SWITCHABLE) { | 3824 ctx->pred_interp_filter < SWITCHABLE) { |
3837 tmp_best_filter = ctx->pred_interp_filter; | 3825 tmp_best_filter = ctx->pred_interp_filter; |
3838 } else if (sf->adaptive_pred_interp_filter == 2) { | 3826 } else if (sf->adaptive_pred_interp_filter == 2) { |
3839 tmp_best_filter = ctx->pred_interp_filter < SWITCHABLE ? | 3827 tmp_best_filter = ctx->pred_interp_filter < SWITCHABLE ? |
3840 ctx->pred_interp_filter : 0; | 3828 ctx->pred_interp_filter : 0; |
3841 } else { | 3829 } else { |
3842 for (switchable_filter_index = 0; | 3830 for (switchable_filter_index = 0; |
3843 switchable_filter_index < SWITCHABLE_FILTERS; | 3831 switchable_filter_index < SWITCHABLE_FILTERS; |
3844 ++switchable_filter_index) { | 3832 ++switchable_filter_index) { |
3845 int newbest, rs; | 3833 int newbest, rs; |
3846 int64_t rs_rd; | 3834 int64_t rs_rd; |
3847 mbmi->interp_filter = switchable_filter_index; | 3835 mbmi->interp_filter = switchable_filter_index; |
3848 tmp_rd = rd_pick_best_sub8x8_mode(cpi, x, tile, | 3836 tmp_rd = rd_pick_best_sub8x8_mode(cpi, x, tile_info, |
3849 &mbmi->ref_mvs[ref_frame][0], | 3837 &mbmi->ref_mvs[ref_frame][0], |
3850 second_ref, best_yrd, &rate, | 3838 second_ref, best_yrd, &rate, |
3851 &rate_y, &distortion, | 3839 &rate_y, &distortion, |
3852 &skippable, &total_sse, | 3840 &skippable, &total_sse, |
3853 (int) this_rd_thresh, seg_mvs, | 3841 (int) this_rd_thresh, seg_mvs, |
3854 bsi, switchable_filter_index, | 3842 bsi, switchable_filter_index, |
3855 mi_row, mi_col); | 3843 mi_row, mi_col); |
3856 | 3844 |
3857 if (tmp_rd == INT64_MAX) | 3845 if (tmp_rd == INT64_MAX) |
3858 continue; | 3846 continue; |
3859 rs = vp9_get_switchable_rate(cpi); | 3847 rs = vp9_get_switchable_rate(cpi); |
3860 rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0); | 3848 rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0); |
3861 rd_opt->filter_cache[switchable_filter_index] = tmp_rd; | 3849 filter_cache[switchable_filter_index] = tmp_rd; |
3862 rd_opt->filter_cache[SWITCHABLE_FILTERS] = | 3850 filter_cache[SWITCHABLE_FILTERS] = |
3863 MIN(rd_opt->filter_cache[SWITCHABLE_FILTERS], | 3851 MIN(filter_cache[SWITCHABLE_FILTERS], |
3864 tmp_rd + rs_rd); | 3852 tmp_rd + rs_rd); |
3865 if (cm->interp_filter == SWITCHABLE) | 3853 if (cm->interp_filter == SWITCHABLE) |
3866 tmp_rd += rs_rd; | 3854 tmp_rd += rs_rd; |
3867 | 3855 |
3868 rd_opt->mask_filter = MAX(rd_opt->mask_filter, tmp_rd); | 3856 mask_filter = MAX(mask_filter, tmp_rd); |
3869 | 3857 |
3870 newbest = (tmp_rd < tmp_best_rd); | 3858 newbest = (tmp_rd < tmp_best_rd); |
3871 if (newbest) { | 3859 if (newbest) { |
3872 tmp_best_filter = mbmi->interp_filter; | 3860 tmp_best_filter = mbmi->interp_filter; |
3873 tmp_best_rd = tmp_rd; | 3861 tmp_best_rd = tmp_rd; |
3874 } | 3862 } |
3875 if ((newbest && cm->interp_filter == SWITCHABLE) || | 3863 if ((newbest && cm->interp_filter == SWITCHABLE) || |
3876 (mbmi->interp_filter == cm->interp_filter && | 3864 (mbmi->interp_filter == cm->interp_filter && |
3877 cm->interp_filter != SWITCHABLE)) { | 3865 cm->interp_filter != SWITCHABLE)) { |
3878 tmp_best_rdu = tmp_rd; | 3866 tmp_best_rdu = tmp_rd; |
(...skipping 25 matching lines...) Expand all Loading... |
3904 } | 3892 } |
3905 | 3893 |
3906 if (tmp_best_rdu == INT64_MAX && pred_exists) | 3894 if (tmp_best_rdu == INT64_MAX && pred_exists) |
3907 continue; | 3895 continue; |
3908 | 3896 |
3909 mbmi->interp_filter = (cm->interp_filter == SWITCHABLE ? | 3897 mbmi->interp_filter = (cm->interp_filter == SWITCHABLE ? |
3910 tmp_best_filter : cm->interp_filter); | 3898 tmp_best_filter : cm->interp_filter); |
3911 if (!pred_exists) { | 3899 if (!pred_exists) { |
3912 // Handles the special case when a filter that is not in the | 3900 // Handles the special case when a filter that is not in the |
3913 // switchable list (bilinear, 6-tap) is indicated at the frame level | 3901 // switchable list (bilinear, 6-tap) is indicated at the frame level |
3914 tmp_rd = rd_pick_best_sub8x8_mode(cpi, x, tile, | 3902 tmp_rd = rd_pick_best_sub8x8_mode(cpi, x, tile_info, |
3915 &mbmi->ref_mvs[ref_frame][0], | 3903 &mbmi->ref_mvs[ref_frame][0], |
3916 second_ref, best_yrd, &rate, &rate_y, | 3904 second_ref, best_yrd, &rate, &rate_y, |
3917 &distortion, &skippable, &total_sse, | 3905 &distortion, &skippable, &total_sse, |
3918 (int) this_rd_thresh, seg_mvs, bsi, 0, | 3906 (int) this_rd_thresh, seg_mvs, bsi, 0, |
3919 mi_row, mi_col); | 3907 mi_row, mi_col); |
3920 if (tmp_rd == INT64_MAX) | 3908 if (tmp_rd == INT64_MAX) |
3921 continue; | 3909 continue; |
3922 } else { | 3910 } else { |
3923 total_sse = tmp_best_sse; | 3911 total_sse = tmp_best_sse; |
3924 rate = tmp_best_rate; | 3912 rate = tmp_best_rate; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4082 else if (comp_pred && single_rd < best_pred_rd[COMPOUND_REFERENCE]) | 4070 else if (comp_pred && single_rd < best_pred_rd[COMPOUND_REFERENCE]) |
4083 best_pred_rd[COMPOUND_REFERENCE] = single_rd; | 4071 best_pred_rd[COMPOUND_REFERENCE] = single_rd; |
4084 | 4072 |
4085 if (hybrid_rd < best_pred_rd[REFERENCE_MODE_SELECT]) | 4073 if (hybrid_rd < best_pred_rd[REFERENCE_MODE_SELECT]) |
4086 best_pred_rd[REFERENCE_MODE_SELECT] = hybrid_rd; | 4074 best_pred_rd[REFERENCE_MODE_SELECT] = hybrid_rd; |
4087 } | 4075 } |
4088 | 4076 |
4089 /* keep record of best filter type */ | 4077 /* keep record of best filter type */ |
4090 if (!mode_excluded && !disable_skip && ref_frame != INTRA_FRAME && | 4078 if (!mode_excluded && !disable_skip && ref_frame != INTRA_FRAME && |
4091 cm->interp_filter != BILINEAR) { | 4079 cm->interp_filter != BILINEAR) { |
4092 int64_t ref = rd_opt->filter_cache[cm->interp_filter == SWITCHABLE ? | 4080 int64_t ref = filter_cache[cm->interp_filter == SWITCHABLE ? |
4093 SWITCHABLE_FILTERS : cm->interp_filter]; | 4081 SWITCHABLE_FILTERS : cm->interp_filter]; |
4094 int64_t adj_rd; | 4082 int64_t adj_rd; |
4095 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) { | 4083 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) { |
4096 if (ref == INT64_MAX) | 4084 if (ref == INT64_MAX) |
4097 adj_rd = 0; | 4085 adj_rd = 0; |
4098 else if (rd_opt->filter_cache[i] == INT64_MAX) | 4086 else if (filter_cache[i] == INT64_MAX) |
4099 // when early termination is triggered, the encoder does not have | 4087 // when early termination is triggered, the encoder does not have |
4100 // access to the rate-distortion cost. it only knows that the cost | 4088 // access to the rate-distortion cost. it only knows that the cost |
4101 // should be above the maximum valid value. hence it takes the known | 4089 // should be above the maximum valid value. hence it takes the known |
4102 // maximum plus an arbitrary constant as the rate-distortion cost. | 4090 // maximum plus an arbitrary constant as the rate-distortion cost. |
4103 adj_rd = rd_opt->mask_filter - ref + 10; | 4091 adj_rd = mask_filter - ref + 10; |
4104 else | 4092 else |
4105 adj_rd = rd_opt->filter_cache[i] - ref; | 4093 adj_rd = filter_cache[i] - ref; |
4106 | 4094 |
4107 adj_rd += this_rd; | 4095 adj_rd += this_rd; |
4108 best_filter_rd[i] = MIN(best_filter_rd[i], adj_rd); | 4096 best_filter_rd[i] = MIN(best_filter_rd[i], adj_rd); |
4109 } | 4097 } |
4110 } | 4098 } |
4111 | 4099 |
4112 if (early_term) | 4100 if (early_term) |
4113 break; | 4101 break; |
4114 | 4102 |
4115 if (x->skip && !comp_pred) | 4103 if (x->skip && !comp_pred) |
(...skipping 23 matching lines...) Expand all Loading... |
4139 rd_cost->rate = INT_MAX; | 4127 rd_cost->rate = INT_MAX; |
4140 rd_cost->dist = INT64_MAX; | 4128 rd_cost->dist = INT64_MAX; |
4141 rd_cost->rdcost = INT64_MAX; | 4129 rd_cost->rdcost = INT64_MAX; |
4142 return; | 4130 return; |
4143 } | 4131 } |
4144 | 4132 |
4145 assert((cm->interp_filter == SWITCHABLE) || | 4133 assert((cm->interp_filter == SWITCHABLE) || |
4146 (cm->interp_filter == best_mbmode.interp_filter) || | 4134 (cm->interp_filter == best_mbmode.interp_filter) || |
4147 !is_inter_block(&best_mbmode)); | 4135 !is_inter_block(&best_mbmode)); |
4148 | 4136 |
4149 update_rd_thresh_fact(cpi, bsize, best_ref_index); | 4137 vp9_update_rd_thresh_fact(tile_data->thresh_freq_fact, |
| 4138 sf->adaptive_rd_thresh, bsize, best_ref_index); |
4150 | 4139 |
4151 // macroblock modes | 4140 // macroblock modes |
4152 *mbmi = best_mbmode; | 4141 *mbmi = best_mbmode; |
4153 x->skip |= best_skip2; | 4142 x->skip |= best_skip2; |
4154 if (!is_inter_block(&best_mbmode)) { | 4143 if (!is_inter_block(&best_mbmode)) { |
4155 for (i = 0; i < 4; i++) | 4144 for (i = 0; i < 4; i++) |
4156 xd->mi[0].src_mi->bmi[i].as_mode = best_bmodes[i].as_mode; | 4145 xd->mi[0].src_mi->bmi[i].as_mode = best_bmodes[i].as_mode; |
4157 } else { | 4146 } else { |
4158 for (i = 0; i < 4; ++i) | 4147 for (i = 0; i < 4; ++i) |
4159 vpx_memcpy(&xd->mi[0].src_mi->bmi[i], &best_bmodes[i], | 4148 vpx_memcpy(&xd->mi[0].src_mi->bmi[i], &best_bmodes[i], |
(...skipping 20 matching lines...) Expand all Loading... |
4180 if (cm->interp_filter == SWITCHABLE) | 4169 if (cm->interp_filter == SWITCHABLE) |
4181 assert(best_filter_diff[SWITCHABLE_FILTERS] == 0); | 4170 assert(best_filter_diff[SWITCHABLE_FILTERS] == 0); |
4182 } else { | 4171 } else { |
4183 vp9_zero(best_filter_diff); | 4172 vp9_zero(best_filter_diff); |
4184 } | 4173 } |
4185 | 4174 |
4186 store_coding_context(x, ctx, best_ref_index, | 4175 store_coding_context(x, ctx, best_ref_index, |
4187 best_pred_diff, best_tx_diff, best_filter_diff, 0); | 4176 best_pred_diff, best_tx_diff, best_filter_diff, 0); |
4188 } | 4177 } |
4189 | 4178 |
OLD | NEW |