| 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 |
| 11 #include <limits.h> | 11 #include <limits.h> |
| 12 | 12 |
| 13 #include "vp9/encoder/vp9_encoder.h" | 13 #include "vp9/encoder/vp9_encoder.h" |
| 14 #include "vp9/encoder/vp9_speed_features.h" | 14 #include "vp9/encoder/vp9_speed_features.h" |
| 15 | 15 |
| 16 // Intra only frames, golden frames (except alt ref overlays) and | 16 // Intra only frames, golden frames (except alt ref overlays) and |
| 17 // alt ref frames tend to be coded at a higher than ambient quality | 17 // alt ref frames tend to be coded at a higher than ambient quality |
| 18 static int frame_is_boosted(const VP9_COMP *cpi) { | 18 static int frame_is_boosted(const VP9_COMP *cpi) { |
| 19 return frame_is_kf_gf_arf(cpi) || vp9_is_upper_layer_key_frame(cpi); | 19 return frame_is_kf_gf_arf(cpi) || vp9_is_upper_layer_key_frame(cpi); |
| 20 } | 20 } |
| 21 | 21 |
| 22 static void set_good_speed_feature_framesize_dependent(VP9_COMMON *cm, | 22 // Sets a partition size down to which the auto partition code will always |
| 23 // search (can go lower), based on the image dimensions. The logic here |
| 24 // is that the extent to which ringing artefacts are offensive, depends |
| 25 // partly on the screen area that over which they propogate. Propogation is |
| 26 // limited by transform block size but the screen area take up by a given block |
| 27 // size will be larger for a small image format stretched to full screen. |
| 28 static BLOCK_SIZE set_partition_min_limit(VP9_COMMON *const cm) { |
| 29 unsigned int screen_area = (cm->width * cm->height); |
| 30 |
| 31 // Select block size based on image format size. |
| 32 if (screen_area < 1280 * 720) { |
| 33 // Formats smaller in area than 720P |
| 34 return BLOCK_4X4; |
| 35 } else if (screen_area < 1920 * 1080) { |
| 36 // Format >= 720P and < 1080P |
| 37 return BLOCK_8X8; |
| 38 } else { |
| 39 // Formats 1080P and up |
| 40 return BLOCK_16X16; |
| 41 } |
| 42 } |
| 43 |
| 44 static void set_good_speed_feature_framesize_dependent(VP9_COMP *cpi, |
| 23 SPEED_FEATURES *sf, | 45 SPEED_FEATURES *sf, |
| 24 int speed) { | 46 int speed) { |
| 47 VP9_COMMON *const cm = &cpi->common; |
| 48 |
| 25 if (speed >= 1) { | 49 if (speed >= 1) { |
| 26 if (MIN(cm->width, cm->height) >= 720) { | 50 if (MIN(cm->width, cm->height) >= 720) { |
| 27 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT | 51 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT |
| 28 : DISABLE_ALL_INTER_SPLIT; | 52 : DISABLE_ALL_INTER_SPLIT; |
| 29 sf->partition_search_breakout_dist_thr = (1 << 23); | 53 sf->partition_search_breakout_dist_thr = (1 << 23); |
| 30 } else { | 54 } else { |
| 31 sf->disable_split_mask = DISABLE_COMPOUND_SPLIT; | 55 sf->disable_split_mask = DISABLE_COMPOUND_SPLIT; |
| 32 sf->partition_search_breakout_dist_thr = (1 << 21); | 56 sf->partition_search_breakout_dist_thr = (1 << 21); |
| 33 } | 57 } |
| 34 } | 58 } |
| 35 | 59 |
| 36 if (speed >= 2) { | 60 if (speed >= 2) { |
| 37 if (MIN(cm->width, cm->height) >= 720) { | 61 if (MIN(cm->width, cm->height) >= 720) { |
| 38 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT | 62 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT |
| 39 : DISABLE_ALL_INTER_SPLIT; | 63 : DISABLE_ALL_INTER_SPLIT; |
| 40 sf->adaptive_pred_interp_filter = 0; | 64 sf->adaptive_pred_interp_filter = 0; |
| 41 sf->partition_search_breakout_dist_thr = (1 << 24); | 65 sf->partition_search_breakout_dist_thr = (1 << 24); |
| 42 sf->partition_search_breakout_rate_thr = 120; | 66 sf->partition_search_breakout_rate_thr = 120; |
| 43 } else { | 67 } else { |
| 44 sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY; | 68 sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY; |
| 45 sf->partition_search_breakout_dist_thr = (1 << 22); | 69 sf->partition_search_breakout_dist_thr = (1 << 22); |
| 46 sf->partition_search_breakout_rate_thr = 100; | 70 sf->partition_search_breakout_rate_thr = 100; |
| 47 } | 71 } |
| 72 sf->rd_auto_partition_min_limit = set_partition_min_limit(cm); |
| 48 } | 73 } |
| 49 | 74 |
| 50 if (speed >= 3) { | 75 if (speed >= 3) { |
| 51 if (MIN(cm->width, cm->height) >= 720) { | 76 if (MIN(cm->width, cm->height) >= 720) { |
| 52 sf->disable_split_mask = DISABLE_ALL_SPLIT; | 77 sf->disable_split_mask = DISABLE_ALL_SPLIT; |
| 53 sf->schedule_mode_search = cm->base_qindex < 220 ? 1 : 0; | 78 sf->schedule_mode_search = cm->base_qindex < 220 ? 1 : 0; |
| 54 sf->partition_search_breakout_dist_thr = (1 << 25); | 79 sf->partition_search_breakout_dist_thr = (1 << 25); |
| 55 sf->partition_search_breakout_rate_thr = 200; | 80 sf->partition_search_breakout_rate_thr = 200; |
| 56 } else { | 81 } else { |
| 57 sf->max_intra_bsize = BLOCK_32X32; | 82 sf->max_intra_bsize = BLOCK_32X32; |
| 58 sf->disable_split_mask = DISABLE_ALL_INTER_SPLIT; | 83 sf->disable_split_mask = DISABLE_ALL_INTER_SPLIT; |
| 59 sf->schedule_mode_search = cm->base_qindex < 175 ? 1 : 0; | 84 sf->schedule_mode_search = cm->base_qindex < 175 ? 1 : 0; |
| 60 sf->partition_search_breakout_dist_thr = (1 << 23); | 85 sf->partition_search_breakout_dist_thr = (1 << 23); |
| 61 sf->partition_search_breakout_rate_thr = 120; | 86 sf->partition_search_breakout_rate_thr = 120; |
| 62 } | 87 } |
| 63 } | 88 } |
| 64 | 89 |
| 90 // If this is a two pass clip that fits the criteria for animated or |
| 91 // graphics content then reset disable_split_mask for speeds 1-4. |
| 92 if ((speed >= 1) && (cpi->oxcf.pass == 2) && |
| 93 (cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION)) { |
| 94 sf->disable_split_mask = DISABLE_COMPOUND_SPLIT; |
| 95 } |
| 96 |
| 65 if (speed >= 4) { | 97 if (speed >= 4) { |
| 66 if (MIN(cm->width, cm->height) >= 720) { | 98 if (MIN(cm->width, cm->height) >= 720) { |
| 67 sf->partition_search_breakout_dist_thr = (1 << 26); | 99 sf->partition_search_breakout_dist_thr = (1 << 26); |
| 68 } else { | 100 } else { |
| 69 sf->partition_search_breakout_dist_thr = (1 << 24); | 101 sf->partition_search_breakout_dist_thr = (1 << 24); |
| 70 } | 102 } |
| 71 sf->disable_split_mask = DISABLE_ALL_SPLIT; | 103 sf->disable_split_mask = DISABLE_ALL_SPLIT; |
| 72 } | 104 } |
| 73 } | 105 } |
| 74 | 106 |
| 75 // Sets a partition size down to which the auto partition code will always | |
| 76 // search (can go lower), based on the image dimensions. The logic here | |
| 77 // is that the extent to which ringing artefacts are offensive, depends | |
| 78 // partly on the screen area that over which they propogate. Propogation is | |
| 79 // limited by transform block size but the screen area take up by a given block | |
| 80 // size will be larger for a small image format stretched to full screen. | |
| 81 static BLOCK_SIZE set_partition_min_limit(VP9_COMP *cpi) { | |
| 82 VP9_COMMON *const cm = &cpi->common; | |
| 83 unsigned int screen_area = (cm->width * cm->height); | |
| 84 | |
| 85 // Select block size based on image format size. | |
| 86 if (screen_area < 1280 * 720) { | |
| 87 // Formats smaller in area than 720P | |
| 88 return BLOCK_4X4; | |
| 89 } else if (screen_area < 1920 * 1080) { | |
| 90 // Format >= 720P and < 1080P | |
| 91 return BLOCK_8X8; | |
| 92 } else { | |
| 93 // Formats 1080P and up | |
| 94 return BLOCK_16X16; | |
| 95 } | |
| 96 } | |
| 97 | |
| 98 static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm, | 107 static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm, |
| 99 SPEED_FEATURES *sf, int speed) { | 108 SPEED_FEATURES *sf, int speed) { |
| 100 const int boosted = frame_is_boosted(cpi); | 109 const int boosted = frame_is_boosted(cpi); |
| 101 | 110 |
| 102 sf->adaptive_rd_thresh = 1; | 111 sf->adaptive_rd_thresh = 1; |
| 103 sf->allow_skip_recode = 1; | 112 sf->allow_skip_recode = 1; |
| 104 | 113 |
| 105 if (speed >= 1) { | 114 if (speed >= 1) { |
| 106 sf->use_square_partition_only = !frame_is_intra_only(cm); | 115 sf->use_square_partition_only = !frame_is_intra_only(cm); |
| 107 sf->less_rectangular_check = 1; | 116 sf->less_rectangular_check = 1; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 132 sf->reference_masking = cpi->oxcf.resize_mode != RESIZE_DYNAMIC ? 1 : 0; | 141 sf->reference_masking = cpi->oxcf.resize_mode != RESIZE_DYNAMIC ? 1 : 0; |
| 133 | 142 |
| 134 sf->mode_search_skip_flags = (cm->frame_type == KEY_FRAME) ? 0 : | 143 sf->mode_search_skip_flags = (cm->frame_type == KEY_FRAME) ? 0 : |
| 135 FLAG_SKIP_INTRA_DIRMISMATCH | | 144 FLAG_SKIP_INTRA_DIRMISMATCH | |
| 136 FLAG_SKIP_INTRA_BESTINTER | | 145 FLAG_SKIP_INTRA_BESTINTER | |
| 137 FLAG_SKIP_COMP_BESTINTRA | | 146 FLAG_SKIP_COMP_BESTINTRA | |
| 138 FLAG_SKIP_INTRA_LOWVAR; | 147 FLAG_SKIP_INTRA_LOWVAR; |
| 139 sf->disable_filter_search_var_thresh = 100; | 148 sf->disable_filter_search_var_thresh = 100; |
| 140 sf->comp_inter_joint_search_thresh = BLOCK_SIZES; | 149 sf->comp_inter_joint_search_thresh = BLOCK_SIZES; |
| 141 sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX; | 150 sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX; |
| 142 sf->rd_auto_partition_min_limit = set_partition_min_limit(cpi); | |
| 143 sf->allow_partition_search_skip = 1; | 151 sf->allow_partition_search_skip = 1; |
| 144 } | 152 } |
| 145 | 153 |
| 146 if (speed >= 3) { | 154 if (speed >= 3) { |
| 147 sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD | 155 sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD |
| 148 : USE_LARGESTALL; | 156 : USE_LARGESTALL; |
| 149 sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED; | 157 sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED; |
| 150 sf->adaptive_pred_interp_filter = 0; | 158 sf->adaptive_pred_interp_filter = 0; |
| 151 sf->adaptive_mode_search = 1; | 159 sf->adaptive_mode_search = 1; |
| 152 sf->cb_partition_search = !boosted; | 160 sf->cb_partition_search = !boosted; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 } | 384 } |
| 377 if (speed >= 8) { | 385 if (speed >= 8) { |
| 378 sf->adaptive_rd_thresh = 4; | 386 sf->adaptive_rd_thresh = 4; |
| 379 sf->mv.subpel_force_stop = 2; | 387 sf->mv.subpel_force_stop = 2; |
| 380 sf->lpf_pick = LPF_PICK_MINIMAL_LPF; | 388 sf->lpf_pick = LPF_PICK_MINIMAL_LPF; |
| 381 } | 389 } |
| 382 } | 390 } |
| 383 | 391 |
| 384 void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi) { | 392 void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi) { |
| 385 SPEED_FEATURES *const sf = &cpi->sf; | 393 SPEED_FEATURES *const sf = &cpi->sf; |
| 386 VP9_COMMON *const cm = &cpi->common; | |
| 387 const VP9EncoderConfig *const oxcf = &cpi->oxcf; | 394 const VP9EncoderConfig *const oxcf = &cpi->oxcf; |
| 388 RD_OPT *const rd = &cpi->rd; | 395 RD_OPT *const rd = &cpi->rd; |
| 389 int i; | 396 int i; |
| 390 | 397 |
| 391 if (oxcf->mode == REALTIME) { | 398 if (oxcf->mode == REALTIME) { |
| 392 set_rt_speed_feature_framesize_dependent(cpi, sf, oxcf->speed); | 399 set_rt_speed_feature_framesize_dependent(cpi, sf, oxcf->speed); |
| 393 } else if (oxcf->mode == GOOD) { | 400 } else if (oxcf->mode == GOOD) { |
| 394 set_good_speed_feature_framesize_dependent(cm, sf, oxcf->speed); | 401 set_good_speed_feature_framesize_dependent(cpi, sf, oxcf->speed); |
| 395 } | 402 } |
| 396 | 403 |
| 397 if (sf->disable_split_mask == DISABLE_ALL_SPLIT) { | 404 if (sf->disable_split_mask == DISABLE_ALL_SPLIT) { |
| 398 sf->adaptive_pred_interp_filter = 0; | 405 sf->adaptive_pred_interp_filter = 0; |
| 399 } | 406 } |
| 400 | 407 |
| 401 if (cpi->encode_breakout && oxcf->mode == REALTIME && | 408 if (cpi->encode_breakout && oxcf->mode == REALTIME && |
| 402 sf->encode_breakout_thresh > cpi->encode_breakout) { | 409 sf->encode_breakout_thresh > cpi->encode_breakout) { |
| 403 cpi->encode_breakout = sf->encode_breakout_thresh; | 410 cpi->encode_breakout = sf->encode_breakout_thresh; |
| 404 } | 411 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 | 529 |
| 523 x->optimize = sf->optimize_coefficients == 1 && oxcf->pass != 1; | 530 x->optimize = sf->optimize_coefficients == 1 && oxcf->pass != 1; |
| 524 | 531 |
| 525 x->min_partition_size = sf->default_min_partition_size; | 532 x->min_partition_size = sf->default_min_partition_size; |
| 526 x->max_partition_size = sf->default_max_partition_size; | 533 x->max_partition_size = sf->default_max_partition_size; |
| 527 | 534 |
| 528 if (!cpi->oxcf.frame_periodic_boost) { | 535 if (!cpi->oxcf.frame_periodic_boost) { |
| 529 sf->max_delta_qindex = 0; | 536 sf->max_delta_qindex = 0; |
| 530 } | 537 } |
| 531 } | 538 } |
| OLD | NEW |