/* * Copyright (c) 2010 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// Intra only frames, golden frames (except alt ref overlays) and // alt ref frames tend to be coded at a higher than ambient quality staticint frame_is_boosted(const VP9_COMP *cpi) { return frame_is_kf_gf_arf(cpi);
}
// Sets a partition size down to which the auto partition code will always // search (can go lower), based on the image dimensions. The logic here // is that the extent to which ringing artefacts are offensive, depends // partly on the screen area that over which they propagate. Propagation is // limited by transform block size but the screen area take up by a given block // size will be larger for a small image format stretched to full screen. static BLOCK_SIZE set_partition_min_limit(VP9_COMMON *const cm) { unsignedint screen_area = (cm->width * cm->height);
// Select block size based on image format size. if (screen_area < 1280 * 720) { // Formats smaller in area than 720P return BLOCK_4X4;
} elseif (screen_area < 1920 * 1080) { // Format >= 720P and < 1080P return BLOCK_8X8;
} else { // Formats 1080P and up return BLOCK_16X16;
}
}
if (is_480p_or_larger) { // Currently, the machine-learning based partition search early termination // is only used while VPXMIN(cm->width, cm->height) >= 480 and speed = 0.
sf->rd_ml_partition.search_early_termination = 1;
sf->recode_tolerance_high = 45;
} else {
sf->use_square_only_thresh_high = BLOCK_32X32;
} if (is_720p_or_larger) {
sf->alt_ref_search_fp = 1;
}
// If this is a two pass clip that fits the criteria for animated or // graphics content then reset disable_split_mask for speeds 1-4. // Also if the image edge is internal to the coded area. if ((speed >= 1) && (cpi->oxcf.pass == 2) &&
((cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) ||
(vp9_internal_image_edge(cpi)))) {
sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
}
if (speed >= 7) {
sf->adapt_partition_source_sad = 0;
sf->adaptive_rd_thresh = 3;
sf->mv.search_method = FAST_DIAMOND;
sf->mv.fullpel_search_step_param = 10; // For SVC: use better mv search on base temporal layer, and only // on base spatial layer if highest resolution is above 640x360. if (svc->number_temporal_layers > 2 && svc->temporal_layer_id == 0 &&
(svc->spatial_layer_id == 0 ||
cpi->oxcf.width * cpi->oxcf.height <= 640 * 360)) {
sf->mv.search_method = NSTEP;
sf->mv.fullpel_search_step_param = 6;
} if (svc->temporal_layer_id > 0 || svc->spatial_layer_id > 1) {
sf->use_simple_block_yrd = 1; if (svc->non_reference_frame)
sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED_EVENMORE;
} if (cpi->use_svc && cpi->row_mt && cpi->oxcf.max_threads > 1)
sf->adaptive_rd_thresh_row_mt = 1; // Enable partition copy. For SVC only enabled for top spatial resolution // layer.
cpi->max_copied_frame = 0; if (!cpi->last_frame_dropped && cpi->resize_state == ORIG &&
!cpi->external_resize &&
(!cpi->use_svc ||
(svc->spatial_layer_id == svc->number_spatial_layers - 1 &&
!svc->last_layer_dropped[svc->number_spatial_layers - 1]))) {
sf->copy_partition_flag = 1;
cpi->max_copied_frame = 2; // The top temporal enhancement layer (for number of temporal layers > 1) // are non-reference frames, so use large/max value for max_copied_frame. if (svc->number_temporal_layers > 1 &&
svc->temporal_layer_id == svc->number_temporal_layers - 1)
cpi->max_copied_frame = 255;
} // For SVC: enable use of lower resolution partition for higher resolution, // only for 3 spatial layers and when config/top resolution is above VGA. // Enable only for non-base temporal layer frames. if (cpi->use_svc && svc->use_partition_reuse &&
svc->number_spatial_layers == 3 && svc->temporal_layer_id > 0 &&
cpi->oxcf.width * cpi->oxcf.height > 640 * 480)
sf->svc_use_lowres_part = 1; // For SVC when golden is used as second temporal reference: to avoid // encode time increase only use this feature on base temporal layer. // (i.e remove golden flag from frame_flags for temporal_layer_id > 0). if (cpi->use_svc && svc->use_gf_temporal_ref_current_layer &&
svc->temporal_layer_id > 0)
cpi->ref_frame_flags &= (~VP9_GOLD_FLAG); if (cm->width * cm->height > 640 * 480) sf->cb_pred_filter_search = 2;
}
if (speed >= 8) {
sf->adaptive_rd_thresh = 4;
sf->skip_encode_sb = 1; if (cpi->svc.number_spatial_layers > 1 && !cpi->svc.simulcast_mode)
sf->nonrd_keyframe = 0; else
sf->nonrd_keyframe = 1; if (!cpi->use_svc) cpi->max_copied_frame = 4; if (cpi->row_mt && cpi->oxcf.max_threads > 1)
sf->adaptive_rd_thresh_row_mt = 1; // Enable ML based partition for low res. if (!frame_is_intra_only(cm) && cm->width * cm->height <= 352 * 288) {
sf->nonrd_use_ml_partition = 1;
} #if CONFIG_VP9_HIGHBITDEPTH if (cpi->Source->flags & YV12_FLAG_HIGHBITDEPTH)
sf->nonrd_use_ml_partition = 0; #endif if (content == VP9E_CONTENT_SCREEN) sf->mv.subpel_force_stop = HALF_PEL;
sf->rt_intra_dc_only_low_content = 1; if (!cpi->use_svc && cpi->oxcf.rc_mode == VPX_CBR &&
content != VP9E_CONTENT_SCREEN) { // More aggressive short circuit for speed 8.
sf->short_circuit_low_temp_var = 3; // Use level 2 for noisey cases as there is a regression in some // noisy clips with level 3. if (cpi->noise_estimate.enabled && cm->width >= 1280 &&
cm->height >= 720) {
NOISE_LEVEL noise_level =
vp9_noise_estimate_extract_level(&cpi->noise_estimate); if (noise_level >= kMedium) sf->short_circuit_low_temp_var = 2;
} // Since the short_circuit_low_temp_var is used, reduce the // adaptive_rd_thresh level. if (cm->width * cm->height > 352 * 288)
sf->adaptive_rd_thresh = 1; else
sf->adaptive_rd_thresh = 2;
}
sf->limit_newmv_early_exit = 0;
sf->use_simple_block_yrd = 1; if (cm->width * cm->height > 352 * 288) sf->cb_pred_filter_search = 2;
}
if (speed >= 9) { // Only keep INTRA_DC mode for speed 9. if (!is_keyframe) { int i = 0; for (i = 0; i < BLOCK_SIZES; ++i)
sf->intra_y_mode_bsize_mask[i] = INTRA_DC;
}
sf->cb_pred_filter_search = 2;
sf->mv.enable_adaptive_subpel_force_stop = 1;
sf->mv.adapt_subpel_force_stop.mv_thresh = 1;
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; // Allow for disabling GOLDEN reference, for CBR mode. if (cpi->oxcf.rc_mode == VPX_CBR) sf->disable_golden_ref = 1; if (cpi->rc.avg_frame_low_motion < 70) sf->default_interp_filter = BILINEAR; if (cm->width * cm->height >= 640 * 360) sf->variance_part_thresh_mult = 2;
}
// Disable split to 8x8 for low-resolution at very high Q. // For variance partition (speed >= 6). Ignore the first few frames // as avg_frame_qindex starts at max_q (worst_quality). if (cm->frame_type != KEY_FRAME && cm->width * cm->height <= 320 * 240 &&
sf->partition_search_type == VAR_BASED_PARTITION &&
cpi->rc.avg_frame_qindex[INTER_FRAME] > 208 &&
cpi->common.current_video_frame > 8)
sf->disable_16x16part_nonkey = 1;
if (sf->nonrd_use_ml_partition)
sf->partition_search_type = ML_BASED_PARTITION;
if (sf->use_altref_onepass) { if (cpi->rc.is_src_frame_alt_ref && cm->frame_type != KEY_FRAME) {
sf->partition_search_type = FIXED_PARTITION;
sf->always_this_block_size = BLOCK_64X64;
} if (cpi->count_arf_frame_usage == NULL) {
CHECK_MEM_ERROR(
&cm->error, cpi->count_arf_frame_usage,
(uint8_t *)vpx_calloc((cm->mi_stride >> 3) * ((cm->mi_rows >> 3) + 1), sizeof(*cpi->count_arf_frame_usage)));
} if (cpi->count_lastgolden_frame_usage == NULL)
CHECK_MEM_ERROR(
&cm->error, cpi->count_lastgolden_frame_usage,
(uint8_t *)vpx_calloc((cm->mi_stride >> 3) * ((cm->mi_rows >> 3) + 1), sizeof(*cpi->count_lastgolden_frame_usage)));
} if (svc->previous_frame_is_intra_only) {
sf->partition_search_type = FIXED_PARTITION;
sf->always_this_block_size = BLOCK_64X64;
} // Special case for screen content: increase motion search on base spatial // layer when high motion is detected or previous SL0 frame was dropped. if (cpi->oxcf.content == VP9E_CONTENT_SCREEN && cpi->oxcf.speed >= 5 &&
(svc->high_num_blocks_with_motion || svc->last_layer_dropped[0])) {
sf->mv.search_method = NSTEP; // TODO(marpan/jianj): Tune this setting for screensharing. For now use // small step_param for all spatial layers.
sf->mv.fullpel_search_step_param = 2;
} // TODO(marpan): There is regression for aq-mode=3 speed <= 4, force it // off for now. if (speed <= 3 && cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ)
cpi->oxcf.aq_mode = 0; // For all speeds for rt mode: if the deadline mode changed (was good/best // quality on previous frame and now is realtime) set nonrd_keyframe to 1 to // avoid entering rd pickmode. This causes issues, such as: b/310663186. if (cpi->oxcf.mode != cpi->deadline_mode_previous_frame)
sf->nonrd_keyframe = 1;
// TODO(marpan): Force this feature off always, for the issue: 366146260 // Remove this disabling when underlying issue is resolved.
sf->svc_use_lowres_part = 0;
}
void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi, int speed) {
SPEED_FEATURES *const sf = &cpi->sf; const VP9EncoderConfig *const oxcf = &cpi->oxcf;
RD_OPT *const rd = &cpi->rd; int i;
// best quality defaults // Some speed-up features even for best quality as minimal impact on quality.
sf->partition_search_breakout_thr.dist = (1 << 19);
sf->partition_search_breakout_thr.rate = 80;
sf->rd_ml_partition.search_early_termination = 0;
sf->rd_ml_partition.search_breakout = 0;
// Check for masked out split cases. for (i = 0; i < MAX_REFS; ++i) { if (sf->disable_split_mask & (1 << i)) {
rd->thresh_mult_sub8x8[i] = INT_MAX;
}
}
// With row based multi-threading, the following speed features // have to be disabled to guarantee that bitstreams encoded with single thread // and multiple threads match. // It can be used in realtime when adaptive_rd_thresh_row_mt is enabled since // adaptive_rd_thresh is defined per-row for non-rd pickmode. if (!sf->adaptive_rd_thresh_row_mt && cpi->row_mt_bit_exact &&
oxcf->max_threads > 1)
sf->adaptive_rd_thresh = 0;
}
void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi, int speed) {
SPEED_FEATURES *const sf = &cpi->sf; #if !CONFIG_REALTIME_ONLY
VP9_COMMON *const cm = &cpi->common; #endif
MACROBLOCK *const x = &cpi->td.mb; const VP9EncoderConfig *const oxcf = &cpi->oxcf; int i;
for (i = 0; i < TX_SIZES; i++) {
sf->intra_y_mode_mask[i] = INTRA_ALL;
sf->intra_uv_mode_mask[i] = INTRA_ALL;
}
sf->use_rd_breakout = 0;
sf->skip_encode_sb = 0;
sf->use_uv_intra_rd_estimate = 0;
sf->allow_skip_recode = 0;
sf->lpf_pick = LPF_PICK_FROM_FULL_IMAGE;
sf->use_fast_coef_updates = TWO_LOOP;
sf->use_fast_coef_costing = 0;
sf->mode_skip_start = MAX_MODES; // Mode index at which mode skip mask set
sf->schedule_mode_search = 0;
sf->use_nonrd_pick_mode = 0; for (i = 0; i < BLOCK_SIZES; ++i) sf->inter_mode_mask[i] = INTER_ALL;
sf->max_intra_bsize = BLOCK_64X64;
sf->reuse_inter_pred_sby = 0; // This setting only takes effect when partition_search_type is set // to FIXED_PARTITION.
sf->always_this_block_size = BLOCK_16X16;
sf->search_type_check_frequency = 50;
sf->encode_breakout_thresh = 0; // Recode loop tolerance %.
sf->recode_tolerance_low = 12;
sf->recode_tolerance_high = 25;
sf->default_interp_filter = SWITCHABLE;
sf->simple_model_rd_from_var = 0;
sf->short_circuit_flat_blocks = 0;
sf->short_circuit_low_temp_var = 0;
sf->limit_newmv_early_exit = 0;
sf->bias_golden = 0;
sf->base_mv_aggressive = 0;
sf->rd_ml_partition.prune_rect_thresh[0] = -1;
sf->rd_ml_partition.prune_rect_thresh[1] = -1;
sf->rd_ml_partition.prune_rect_thresh[2] = -1;
sf->rd_ml_partition.prune_rect_thresh[3] = -1;
sf->rd_ml_partition.var_pruning = 0;
sf->use_accurate_subpel_search = USE_8_TAPS;
// Some speed-up features even for best quality as minimal impact on quality.
sf->adaptive_rd_thresh = 1;
sf->tx_size_search_breakout = 1;
sf->tx_size_search_depth = 2;
if (oxcf->mode == REALTIME)
set_rt_speed_feature_framesize_independent(cpi, sf, speed, oxcf->content); #if !CONFIG_REALTIME_ONLY elseif (oxcf->mode == GOOD)
set_good_speed_feature_framesize_independent(cpi, cm, sf, speed); #endif
cpi->diamond_search_sad = vp9_diamond_search_sad;
// Slow quant, dct and trellis not worthwhile for first pass // so make sure they are always turned off. if (oxcf->pass == 1) sf->optimize_coefficients = 0;
// No recode for 1 pass. if (oxcf->pass == 0) {
sf->recode_loop = DISALLOW_RECODE;
sf->optimize_coefficients = 0;
}
// This is only used in motion vector unit test. if (cpi->oxcf.motion_vector_unit_test == 1)
cpi->find_fractional_mv_step = vp9_return_max_sub_pixel_mv; elseif (cpi->oxcf.motion_vector_unit_test == 2)
cpi->find_fractional_mv_step = vp9_return_min_sub_pixel_mv;
if (!cpi->oxcf.frame_periodic_boost) {
sf->max_delta_qindex = 0;
}
// With row based multi-threading, the following speed features // have to be disabled to guarantee that bitstreams encoded with single thread // and multiple threads match. // It can be used in realtime when adaptive_rd_thresh_row_mt is enabled since // adaptive_rd_thresh is defined per-row for non-rd pickmode. if (!sf->adaptive_rd_thresh_row_mt && cpi->row_mt_bit_exact &&
oxcf->max_threads > 1)
sf->adaptive_rd_thresh = 0;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.