From b23a05422e98bc246692df1297474bb0cb78ad51 Mon Sep 17 00:00:00 2001 From: Hui Su Date: Thu, 6 Dec 2018 16:53:26 -0800 Subject: [PATCH] Add enum definition for subpel search precision To improve readability. Change-Id: Idc08b2068c7d8ba9dadc0d559a3b4d61c2a88c94 --- vp9/encoder/vp9_pickmode.c | 6 +++--- vp9/encoder/vp9_speed_features.c | 12 ++++++------ vp9/encoder/vp9_speed_features.h | 14 ++++++-------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index fe8f24444..babfe4a33 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -233,10 +233,10 @@ static int combined_motion_search(VP9_COMP *cpi, MACROBLOCK *x, } if (rv && search_subpel) { - int subpel_force_stop = cpi->sf.mv.subpel_force_stop; - if (use_base_mv && cpi->sf.base_mv_aggressive) subpel_force_stop = 2; + SUBPEL_FORCE_STOP subpel_force_stop = cpi->sf.mv.subpel_force_stop; + if (use_base_mv && cpi->sf.base_mv_aggressive) subpel_force_stop = HALF_PEL; if (cpi->sf.mv.enable_adaptive_subpel_force_stop) { - int mv_thresh = cpi->sf.mv.adapt_subpel_force_stop.mv_thresh; + const int mv_thresh = cpi->sf.mv.adapt_subpel_force_stop.mv_thresh; if (abs(tmp_mv->as_mv.row) >= mv_thresh || abs(tmp_mv->as_mv.col) >= mv_thresh) subpel_force_stop = cpi->sf.mv.adapt_subpel_force_stop.force_stop_above; diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index 9b6c69a73..e5c280746 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -533,7 +533,7 @@ static void set_rt_speed_feature_framesize_independent( sf->adjust_partitioning_from_last_frame = cm->last_frame_type != cm->frame_type || (0 == (frames_since_key + 1) % sf->last_partitioning_redo_frequency); - sf->mv.subpel_force_stop = 1; + sf->mv.subpel_force_stop = QUARTER_PEL; for (i = 0; i < TX_SIZES; i++) { sf->intra_y_mode_mask[i] = INTRA_DC_H_V; sf->intra_uv_mode_mask[i] = INTRA_DC; @@ -731,7 +731,7 @@ static void set_rt_speed_feature_framesize_independent( if (cpi->row_mt && cpi->oxcf.max_threads > 1) sf->adaptive_rd_thresh_row_mt = 1; - if (content == VP9E_CONTENT_SCREEN) sf->mv.subpel_force_stop = 3; + if (content == VP9E_CONTENT_SCREEN) sf->mv.subpel_force_stop = FULL_PEL; if (content == VP9E_CONTENT_SCREEN) sf->lpf_pick = LPF_PICK_MINIMAL_LPF; // Only keep INTRA_DC mode for speed 8. if (!is_keyframe) { @@ -767,8 +767,8 @@ static void set_rt_speed_feature_framesize_independent( sf->mv.adapt_subpel_force_stop.mv_thresh = 2; if (cpi->rc.avg_frame_low_motion < 40) sf->mv.adapt_subpel_force_stop.mv_thresh = 1; - sf->mv.adapt_subpel_force_stop.force_stop_below = 1; - sf->mv.adapt_subpel_force_stop.force_stop_above = 2; + sf->mv.adapt_subpel_force_stop.force_stop_below = QUARTER_PEL; + sf->mv.adapt_subpel_force_stop.force_stop_above = HALF_PEL; // Disable partition blocks below 16x16, except for low-resolutions. if (cm->frame_type != KEY_FRAME && cm->width >= 320 && cm->height >= 240) sf->disable_16x16part_nonkey = 1; @@ -876,7 +876,7 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi) { sf->recode_loop = ALLOW_RECODE_FIRST; sf->mv.subpel_search_method = SUBPEL_TREE; sf->mv.subpel_search_level = 2; - sf->mv.subpel_force_stop = 0; + sf->mv.subpel_force_stop = EIGHTH_PEL; sf->optimize_coefficients = !is_lossless_requested(&cpi->oxcf); sf->mv.reduce_first_step_size = 0; sf->coeff_prob_appx_step = 1; @@ -993,7 +993,7 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi) { sf->optimize_coefficients = 0; } - if (sf->mv.subpel_force_stop == 3) { + if (sf->mv.subpel_force_stop == FULL_PEL) { // Whole pel only cpi->find_fractional_mv_step = vp9_skip_sub_pixel_tree; } else if (sf->mv.subpel_search_method == SUBPEL_TREE) { diff --git a/vp9/encoder/vp9_speed_features.h b/vp9/encoder/vp9_speed_features.h index 02673e602..9b09ec474 100644 --- a/vp9/encoder/vp9_speed_features.h +++ b/vp9/encoder/vp9_speed_features.h @@ -167,15 +167,17 @@ typedef enum { ONE_LOOP_REDUCED = 1 } FAST_COEFF_UPDATE; +typedef enum { EIGHTH_PEL, QUARTER_PEL, HALF_PEL, FULL_PEL } SUBPEL_FORCE_STOP; + typedef struct ADAPT_SUBPEL_FORCE_STOP { // Threshold for full pixel motion vector; int mv_thresh; // subpel_force_stop if full pixel MV is below the threshold. - int force_stop_below; + SUBPEL_FORCE_STOP force_stop_below; // subpel_force_stop if full pixel MV is equal to or above the threshold. - int force_stop_above; + SUBPEL_FORCE_STOP force_stop_above; } ADAPT_SUBPEL_FORCE_STOP; typedef struct MV_SPEED_FEATURES { @@ -200,12 +202,8 @@ typedef struct MV_SPEED_FEATURES { // extensive subpel search. int subpel_search_level; - // Control when to stop subpel search: - // 0: Full subpel search. - // 1: Stop at quarter pixel. - // 2: Stop at half pixel. - // 3: Stop at full pixel. - int subpel_force_stop; + // When to stop subpel motion search. + SUBPEL_FORCE_STOP subpel_force_stop; // If it's enabled, different subpel_force_stop will be used for different MV. int enable_adaptive_subpel_force_stop; -- 2.40.0