From: Yunqing Wang Date: Thu, 20 Nov 2014 17:24:50 +0000 (-0800) Subject: vp9_ethread: move max/min partition size to mb struct X-Git-Tag: v1.4.0~485^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad7586a9e1e6d7b9f8d7289934b433581ae3882a;p=platform%2Fupstream%2Flibvpx.git vp9_ethread: move max/min partition size to mb struct The max_partition_size and max_partition_size are set at the beginning while setting speed features, and then adjusted at SB level. Moving them to mb struct ensures there is a local copy for each thread. Change-Id: I7dd08dc918d9f772fcd718bbd6533e0787720ad4 --- diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h index 12fb886..2ffc7ea 100644 --- a/vp9/encoder/vp9_block.h +++ b/vp9/encoder/vp9_block.h @@ -67,6 +67,11 @@ struct macroblock { int rdmult; int mb_energy; + // These are set to their default values at the beginning, and then adjusted + // further in the encoding process. + BLOCK_SIZE min_partition_size; + BLOCK_SIZE max_partition_size; + int mv_best_ref_index[MAX_REF_FRAMES]; unsigned int max_mv_context[MAX_REF_FRAMES]; unsigned int source_variance; diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index a6e1a5c..dbdb6a3 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -2058,8 +2058,8 @@ static void rd_pick_partition(VP9_COMP *cpi, const int xss = x->e_mbd.plane[1].subsampling_x; const int yss = x->e_mbd.plane[1].subsampling_y; - BLOCK_SIZE min_size = cpi->sf.min_partition_size; - BLOCK_SIZE max_size = cpi->sf.max_partition_size; + BLOCK_SIZE min_size = x->min_partition_size; + BLOCK_SIZE max_size = x->max_partition_size; #if CONFIG_FP_MB_STATS unsigned int src_diff_var = UINT_MAX; @@ -2456,7 +2456,8 @@ static void encode_rd_sb_row(VP9_COMP *cpi, TOKENEXTRA **tp) { VP9_COMMON *const cm = &cpi->common; TileInfo *const tile_info = &tile_data->tile_info; - MACROBLOCKD *const xd = &cpi->mb.e_mbd; + MACROBLOCK *const x = &cpi->mb; + MACROBLOCKD *const xd = &x->e_mbd; SPEED_FEATURES *const sf = &cpi->sf; int mi_col; @@ -2514,8 +2515,8 @@ static void encode_rd_sb_row(VP9_COMP *cpi, if (sf->auto_min_max_partition_size) { set_offsets(cpi, tile_info, mi_row, mi_col, BLOCK_64X64); rd_auto_partition_range(cpi, tile_info, mi_row, mi_col, - &sf->min_partition_size, - &sf->max_partition_size); + &x->min_partition_size, + &x->max_partition_size); } rd_pick_partition(cpi, tile_data, tp, mi_row, mi_col, BLOCK_64X64, &dummy_rdc, INT64_MAX, cpi->pc_root); @@ -2738,15 +2739,15 @@ static void nonrd_pick_partition(VP9_COMP *cpi, // Determine partition types in search according to the speed features. // The threshold set here has to be of square block size. if (sf->auto_min_max_partition_size) { - partition_none_allowed &= (bsize <= sf->max_partition_size && - bsize >= sf->min_partition_size); - partition_horz_allowed &= ((bsize <= sf->max_partition_size && - bsize > sf->min_partition_size) || + partition_none_allowed &= (bsize <= x->max_partition_size && + bsize >= x->min_partition_size); + partition_horz_allowed &= ((bsize <= x->max_partition_size && + bsize > x->min_partition_size) || force_horz_split); - partition_vert_allowed &= ((bsize <= sf->max_partition_size && - bsize > sf->min_partition_size) || + partition_vert_allowed &= ((bsize <= x->max_partition_size && + bsize > x->min_partition_size) || force_vert_split); - do_split &= bsize > sf->min_partition_size; + do_split &= bsize > x->min_partition_size; } if (sf->use_square_partition_only) { partition_horz_allowed &= force_horz_split; @@ -2981,13 +2982,13 @@ static void nonrd_select_partition(VP9_COMP *cpi, if (bsize == BLOCK_32X32 && partition != PARTITION_NONE && subsize >= BLOCK_16X16) { - cpi->sf.max_partition_size = BLOCK_32X32; - cpi->sf.min_partition_size = BLOCK_8X8; + x->max_partition_size = BLOCK_32X32; + x->min_partition_size = BLOCK_8X8; nonrd_pick_partition(cpi, tile_data, tp, mi_row, mi_col, bsize, rd_cost, 0, INT64_MAX, pc_tree); } else if (bsize == BLOCK_16X16 && partition != PARTITION_NONE) { - cpi->sf.max_partition_size = BLOCK_16X16; - cpi->sf.min_partition_size = BLOCK_8X8; + x->max_partition_size = BLOCK_16X16; + x->min_partition_size = BLOCK_8X8; nonrd_pick_partition(cpi, tile_data, tp, mi_row, mi_col, bsize, rd_cost, 0, INT64_MAX, pc_tree); } else { @@ -3266,8 +3267,8 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled && xd->mi[0].src_mi->mbmi.segment_id) { auto_partition_range(cpi, tile_info, mi_row, mi_col, - &sf->min_partition_size, - &sf->max_partition_size); + &x->min_partition_size, + &x->max_partition_size); nonrd_pick_partition(cpi, tile_data, tp, mi_row, mi_col, BLOCK_64X64, &dummy_rdc, 1, INT64_MAX, cpi->pc_root); diff --git a/vp9/encoder/vp9_rd.c b/vp9/encoder/vp9_rd.c index 4ed324a..4023255 100644 --- a/vp9/encoder/vp9_rd.c +++ b/vp9/encoder/vp9_rd.c @@ -458,7 +458,7 @@ void vp9_mv_pred(VP9_COMP *cpi, MACROBLOCK *x, uint8_t *ref_y_ptr; const int num_mv_refs = MAX_MV_REF_CANDIDATES + (cpi->sf.adaptive_motion_search && - block_size < cpi->sf.max_partition_size); + block_size < x->max_partition_size); MV pred_mv[3]; pred_mv[0] = mbmi->ref_mvs[ref_frame][0].as_mv; diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index a1fa8b5..05cbfc4 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -288,8 +288,8 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf, sf->use_quant_fp = !is_keyframe; sf->auto_min_max_partition_size = is_keyframe ? RELAXED_NEIGHBORING_MIN_MAX : STRICT_NEIGHBORING_MIN_MAX; - sf->max_partition_size = BLOCK_32X32; - sf->min_partition_size = BLOCK_8X8; + sf->default_max_partition_size = BLOCK_32X32; + sf->default_min_partition_size = BLOCK_8X8; sf->force_frame_boost = is_keyframe || (frames_since_key % (sf->last_partitioning_redo_frequency << 1) == 1); sf->max_delta_qindex = is_keyframe ? 20 : 15; @@ -376,6 +376,7 @@ void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi) { void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi) { SPEED_FEATURES *const sf = &cpi->sf; VP9_COMMON *const cm = &cpi->common; + MACROBLOCK *const x = &cpi->mb; const VP9EncoderConfig *const oxcf = &cpi->oxcf; int i; @@ -407,8 +408,8 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi) { sf->less_rectangular_check = 0; sf->use_square_partition_only = 0; sf->auto_min_max_partition_size = NOT_IN_USE; - sf->max_partition_size = BLOCK_64X64; - sf->min_partition_size = BLOCK_4X4; + sf->default_max_partition_size = BLOCK_64X64; + sf->default_min_partition_size = BLOCK_4X4; sf->adjust_partitioning_from_last_frame = 0; sf->last_partitioning_redo_frequency = 4; sf->disable_split_mask = 0; @@ -482,7 +483,10 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi) { cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree_pruned_evenmore; } - cpi->mb.optimize = sf->optimize_coefficients == 1 && oxcf->pass != 1; + x->optimize = sf->optimize_coefficients == 1 && oxcf->pass != 1; + + x->min_partition_size = sf->default_min_partition_size; + x->max_partition_size = sf->default_max_partition_size; if (!cpi->oxcf.frame_periodic_boost) { sf->max_delta_qindex = 0; diff --git a/vp9/encoder/vp9_speed_features.h b/vp9/encoder/vp9_speed_features.h index 53b5041..efea503 100644 --- a/vp9/encoder/vp9_speed_features.h +++ b/vp9/encoder/vp9_speed_features.h @@ -275,8 +275,8 @@ typedef struct SPEED_FEATURES { // Min and max partition size we enable (block_size) as per auto // min max, but also used by adjust partitioning, and pick_partitioning. - BLOCK_SIZE min_partition_size; - BLOCK_SIZE max_partition_size; + BLOCK_SIZE default_min_partition_size; + BLOCK_SIZE default_max_partition_size; // Whether or not we allow partitions one smaller or one greater than the last // frame's partitioning. Only used if use_lastframe_partitioning is set.