Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(946)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_encodeframe.c

Issue 998593002: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/test/vp9_ethread_test.cc ('k') | source/libvpx/vp9/encoder/vp9_mcomp.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 if (mi_row + 4 < cm->mi_rows && mi_col + 4 < cm->mi_cols) 581 if (mi_row + 4 < cm->mi_rows && mi_col + 4 < cm->mi_cols)
582 bsize = BLOCK_64X64; 582 bsize = BLOCK_64X64;
583 else if (mi_row + 4 < cm->mi_rows && mi_col + 4 >= cm->mi_cols) 583 else if (mi_row + 4 < cm->mi_rows && mi_col + 4 >= cm->mi_cols)
584 bsize = BLOCK_32X64; 584 bsize = BLOCK_32X64;
585 else if (mi_row + 4 >= cm->mi_rows && mi_col + 4 < cm->mi_cols) 585 else if (mi_row + 4 >= cm->mi_rows && mi_col + 4 < cm->mi_cols)
586 bsize = BLOCK_64X32; 586 bsize = BLOCK_64X32;
587 else 587 else
588 bsize = BLOCK_32X32; 588 bsize = BLOCK_32X32;
589 589
590 y_sad = vp9_int_pro_motion_estimation(cpi, x, bsize); 590 y_sad = vp9_int_pro_motion_estimation(cpi, x, bsize);
591 x->pred_mv[LAST_FRAME] = mbmi->mv[0].as_mv;
591 #endif 592 #endif
592 593
593 vp9_build_inter_predictors_sb(xd, mi_row, mi_col, BLOCK_64X64); 594 vp9_build_inter_predictors_sb(xd, mi_row, mi_col, BLOCK_64X64);
594 595
595 for (i = 1; i <= 2; ++i) { 596 for (i = 1; i <= 2; ++i) {
596 struct macroblock_plane *p = &x->plane[i]; 597 struct macroblock_plane *p = &x->plane[i];
597 struct macroblockd_plane *pd = &xd->plane[i]; 598 struct macroblockd_plane *pd = &xd->plane[i];
598 #if GLOBAL_MOTION 599 #if GLOBAL_MOTION
599 const BLOCK_SIZE bs = get_plane_block_size(bsize, pd); 600 const BLOCK_SIZE bs = get_plane_block_size(bsize, pd);
600 #else 601 #else
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after
2689 SPEED_FEATURES *const sf = &cpi->sf; 2690 SPEED_FEATURES *const sf = &cpi->sf;
2690 int mi_col; 2691 int mi_col;
2691 2692
2692 // Initialize the left context for the new SB row 2693 // Initialize the left context for the new SB row
2693 vpx_memset(&xd->left_context, 0, sizeof(xd->left_context)); 2694 vpx_memset(&xd->left_context, 0, sizeof(xd->left_context));
2694 vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context)); 2695 vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context));
2695 2696
2696 // Code each SB in the row 2697 // Code each SB in the row
2697 for (mi_col = tile_info->mi_col_start; mi_col < tile_info->mi_col_end; 2698 for (mi_col = tile_info->mi_col_start; mi_col < tile_info->mi_col_end;
2698 mi_col += MI_BLOCK_SIZE) { 2699 mi_col += MI_BLOCK_SIZE) {
2700 const struct segmentation *const seg = &cm->seg;
2699 int dummy_rate; 2701 int dummy_rate;
2700 int64_t dummy_dist; 2702 int64_t dummy_dist;
2701 RD_COST dummy_rdc; 2703 RD_COST dummy_rdc;
2702 int i; 2704 int i;
2705 int seg_skip = 0;
2703 2706
2704 const int idx_str = cm->mi_stride * mi_row + mi_col; 2707 const int idx_str = cm->mi_stride * mi_row + mi_col;
2705 MODE_INFO *mi = cm->mi + idx_str; 2708 MODE_INFO *mi = cm->mi + idx_str;
2706 2709
2707 if (sf->adaptive_pred_interp_filter) { 2710 if (sf->adaptive_pred_interp_filter) {
2708 for (i = 0; i < 64; ++i) 2711 for (i = 0; i < 64; ++i)
2709 td->leaf_tree[i].pred_interp_filter = SWITCHABLE; 2712 td->leaf_tree[i].pred_interp_filter = SWITCHABLE;
2710 2713
2711 for (i = 0; i < 64; ++i) { 2714 for (i = 0; i < 64; ++i) {
2712 td->pc_tree[i].vertical[0].pred_interp_filter = SWITCHABLE; 2715 td->pc_tree[i].vertical[0].pred_interp_filter = SWITCHABLE;
2713 td->pc_tree[i].vertical[1].pred_interp_filter = SWITCHABLE; 2716 td->pc_tree[i].vertical[1].pred_interp_filter = SWITCHABLE;
2714 td->pc_tree[i].horizontal[0].pred_interp_filter = SWITCHABLE; 2717 td->pc_tree[i].horizontal[0].pred_interp_filter = SWITCHABLE;
2715 td->pc_tree[i].horizontal[1].pred_interp_filter = SWITCHABLE; 2718 td->pc_tree[i].horizontal[1].pred_interp_filter = SWITCHABLE;
2716 } 2719 }
2717 } 2720 }
2718 2721
2719 vp9_zero(x->pred_mv); 2722 vp9_zero(x->pred_mv);
2720 td->pc_root->index = 0; 2723 td->pc_root->index = 0;
2721 2724
2725 if (seg->enabled) {
2726 const uint8_t *const map = seg->update_map ? cpi->segmentation_map
2727 : cm->last_frame_seg_map;
2728 int segment_id = vp9_get_segment_id(cm, map, BLOCK_64X64, mi_row, mi_col);
2729 seg_skip = vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP);
2730 }
2731
2722 x->source_variance = UINT_MAX; 2732 x->source_variance = UINT_MAX;
2723 if (sf->partition_search_type == FIXED_PARTITION) { 2733 if (sf->partition_search_type == FIXED_PARTITION || seg_skip) {
2734 const BLOCK_SIZE bsize =
2735 seg_skip ? BLOCK_64X64 : sf->always_this_block_size;
2724 set_offsets(cpi, tile_info, x, mi_row, mi_col, BLOCK_64X64); 2736 set_offsets(cpi, tile_info, x, mi_row, mi_col, BLOCK_64X64);
2725 set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, 2737 set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize);
2726 sf->always_this_block_size);
2727 rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, 2738 rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col,
2728 BLOCK_64X64, &dummy_rate, &dummy_dist, 1, td->pc_root); 2739 BLOCK_64X64, &dummy_rate, &dummy_dist, 1, td->pc_root);
2729 } else if (cpi->partition_search_skippable_frame) { 2740 } else if (cpi->partition_search_skippable_frame) {
2730 BLOCK_SIZE bsize; 2741 BLOCK_SIZE bsize;
2731 set_offsets(cpi, tile_info, x, mi_row, mi_col, BLOCK_64X64); 2742 set_offsets(cpi, tile_info, x, mi_row, mi_col, BLOCK_64X64);
2732 bsize = get_rd_var_based_fixed_partition(cpi, x, mi_row, mi_col); 2743 bsize = get_rd_var_based_fixed_partition(cpi, x, mi_row, mi_col);
2733 set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize); 2744 set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize);
2734 rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, 2745 rd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col,
2735 BLOCK_64X64, &dummy_rate, &dummy_dist, 1, td->pc_root); 2746 BLOCK_64X64, &dummy_rate, &dummy_dist, 1, td->pc_root);
2736 } else if (sf->partition_search_type == VAR_BASED_PARTITION && 2747 } else if (sf->partition_search_type == VAR_BASED_PARTITION &&
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
3441 MACROBLOCKD *const xd = &x->e_mbd; 3452 MACROBLOCKD *const xd = &x->e_mbd;
3442 int mi_col; 3453 int mi_col;
3443 3454
3444 // Initialize the left context for the new SB row 3455 // Initialize the left context for the new SB row
3445 vpx_memset(&xd->left_context, 0, sizeof(xd->left_context)); 3456 vpx_memset(&xd->left_context, 0, sizeof(xd->left_context));
3446 vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context)); 3457 vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context));
3447 3458
3448 // Code each SB in the row 3459 // Code each SB in the row
3449 for (mi_col = tile_info->mi_col_start; mi_col < tile_info->mi_col_end; 3460 for (mi_col = tile_info->mi_col_start; mi_col < tile_info->mi_col_end;
3450 mi_col += MI_BLOCK_SIZE) { 3461 mi_col += MI_BLOCK_SIZE) {
3462 const struct segmentation *const seg = &cm->seg;
3451 RD_COST dummy_rdc; 3463 RD_COST dummy_rdc;
3452 const int idx_str = cm->mi_stride * mi_row + mi_col; 3464 const int idx_str = cm->mi_stride * mi_row + mi_col;
3453 MODE_INFO *mi = cm->mi + idx_str; 3465 MODE_INFO *mi = cm->mi + idx_str;
3454 BLOCK_SIZE bsize; 3466 PARTITION_SEARCH_TYPE partition_search_type = sf->partition_search_type;
3467 BLOCK_SIZE bsize = BLOCK_64X64;
3468 int seg_skip = 0;
3455 x->source_variance = UINT_MAX; 3469 x->source_variance = UINT_MAX;
3456 vp9_zero(x->pred_mv); 3470 vp9_zero(x->pred_mv);
3457 vp9_rd_cost_init(&dummy_rdc); 3471 vp9_rd_cost_init(&dummy_rdc);
3458 x->color_sensitivity[0] = 0; 3472 x->color_sensitivity[0] = 0;
3459 x->color_sensitivity[1] = 0; 3473 x->color_sensitivity[1] = 0;
3460 3474
3475 if (seg->enabled) {
3476 const uint8_t *const map = seg->update_map ? cpi->segmentation_map
3477 : cm->last_frame_seg_map;
3478 int segment_id = vp9_get_segment_id(cm, map, BLOCK_64X64, mi_row, mi_col);
3479 seg_skip = vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP);
3480 if (seg_skip) {
3481 partition_search_type = FIXED_PARTITION;
3482 }
3483 }
3484
3461 // Set the partition type of the 64X64 block 3485 // Set the partition type of the 64X64 block
3462 switch (sf->partition_search_type) { 3486 switch (partition_search_type) {
3463 case VAR_BASED_PARTITION: 3487 case VAR_BASED_PARTITION:
3464 // TODO(jingning, marpan): The mode decision and encoding process 3488 // TODO(jingning, marpan): The mode decision and encoding process
3465 // support both intra and inter sub8x8 block coding for RTC mode. 3489 // support both intra and inter sub8x8 block coding for RTC mode.
3466 // Tune the thresholds accordingly to use sub8x8 block coding for 3490 // Tune the thresholds accordingly to use sub8x8 block coding for
3467 // coding performance improvement. 3491 // coding performance improvement.
3468 choose_partitioning(cpi, tile_info, x, mi_row, mi_col); 3492 choose_partitioning(cpi, tile_info, x, mi_row, mi_col);
3469 nonrd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, 3493 nonrd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col,
3470 BLOCK_64X64, 1, &dummy_rdc, td->pc_root); 3494 BLOCK_64X64, 1, &dummy_rdc, td->pc_root);
3471 break; 3495 break;
3472 case SOURCE_VAR_BASED_PARTITION: 3496 case SOURCE_VAR_BASED_PARTITION:
3473 set_source_var_based_partition(cpi, tile_info, x, mi, mi_row, mi_col); 3497 set_source_var_based_partition(cpi, tile_info, x, mi, mi_row, mi_col);
3474 nonrd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, 3498 nonrd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col,
3475 BLOCK_64X64, 1, &dummy_rdc, td->pc_root); 3499 BLOCK_64X64, 1, &dummy_rdc, td->pc_root);
3476 break; 3500 break;
3477 case FIXED_PARTITION: 3501 case FIXED_PARTITION:
3478 bsize = sf->partition_search_type == FIXED_PARTITION ? 3502 if (!seg_skip)
3479 sf->always_this_block_size : 3503 bsize = sf->always_this_block_size;
3480 get_nonrd_var_based_fixed_partition(cpi, x, mi_row, mi_col);
3481 set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize); 3504 set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize);
3482 nonrd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col, 3505 nonrd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col,
3483 BLOCK_64X64, 1, &dummy_rdc, td->pc_root); 3506 BLOCK_64X64, 1, &dummy_rdc, td->pc_root);
3484 break; 3507 break;
3485 case REFERENCE_PARTITION: 3508 case REFERENCE_PARTITION:
3486 set_offsets(cpi, tile_info, x, mi_row, mi_col, BLOCK_64X64); 3509 set_offsets(cpi, tile_info, x, mi_row, mi_col, BLOCK_64X64);
3487 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled && 3510 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled &&
3488 xd->mi[0].src_mi->mbmi.segment_id) { 3511 xd->mi[0].src_mi->mbmi.segment_id) {
3489 auto_partition_range(cpi, tile_info, xd, mi_row, mi_col, 3512 auto_partition_range(cpi, tile_info, xd, mi_row, mi_col,
3490 &x->min_partition_size, 3513 &x->min_partition_size,
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
3759 x->itxm_add = xd->lossless ? vp9_iwht4x4_add : vp9_idct4x4_add; 3782 x->itxm_add = xd->lossless ? vp9_iwht4x4_add : vp9_idct4x4_add;
3760 3783
3761 if (xd->lossless) 3784 if (xd->lossless)
3762 x->optimize = 0; 3785 x->optimize = 0;
3763 3786
3764 cm->tx_mode = select_tx_mode(cpi, xd); 3787 cm->tx_mode = select_tx_mode(cpi, xd);
3765 3788
3766 vp9_frame_init_quantizer(cpi); 3789 vp9_frame_init_quantizer(cpi);
3767 3790
3768 vp9_initialize_rd_consts(cpi); 3791 vp9_initialize_rd_consts(cpi);
3769 vp9_initialize_me_consts(cpi, cm->base_qindex); 3792 vp9_initialize_me_consts(cpi, x, cm->base_qindex);
3770 init_encode_frame_mb_context(cpi); 3793 init_encode_frame_mb_context(cpi);
3771 cm->use_prev_frame_mvs = !cm->error_resilient_mode && 3794 cm->use_prev_frame_mvs = !cm->error_resilient_mode &&
3772 cm->width == cm->last_width && 3795 cm->width == cm->last_width &&
3773 cm->height == cm->last_height && 3796 cm->height == cm->last_height &&
3774 !cm->intra_only && 3797 !cm->intra_only &&
3775 cm->last_show_frame; 3798 cm->last_show_frame;
3776 // Special case: set prev_mi to NULL when the previous mode info 3799 // Special case: set prev_mi to NULL when the previous mode info
3777 // context cannot be used. 3800 // context cannot be used.
3778 cm->prev_mi = cm->use_prev_frame_mvs ? 3801 cm->prev_mi = cm->use_prev_frame_mvs ?
3779 cm->prev_mip + cm->mi_stride + 1 : NULL; 3802 cm->prev_mip + cm->mi_stride + 1 : NULL;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
4080 4103
4081 for (y = 0; y < mi_height; y++) 4104 for (y = 0; y < mi_height; y++)
4082 for (x = 0; x < mi_width; x++) 4105 for (x = 0; x < mi_width; x++)
4083 if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows) 4106 if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows)
4084 mi_8x8[mis * y + x].src_mi->mbmi.tx_size = tx_size; 4107 mi_8x8[mis * y + x].src_mi->mbmi.tx_size = tx_size;
4085 } 4108 }
4086 ++td->counts->tx.tx_totals[mbmi->tx_size]; 4109 ++td->counts->tx.tx_totals[mbmi->tx_size];
4087 ++td->counts->tx.tx_totals[get_uv_tx_size(mbmi, &xd->plane[1])]; 4110 ++td->counts->tx.tx_totals[get_uv_tx_size(mbmi, &xd->plane[1])];
4088 } 4111 }
4089 } 4112 }
OLDNEW
« no previous file with comments | « source/libvpx/test/vp9_ethread_test.cc ('k') | source/libvpx/vp9/encoder/vp9_mcomp.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698