diff options
-rw-r--r-- | vp9/encoder/vp9_onyx_if.c | 53 | ||||
-rw-r--r-- | vp9/encoder/vp9_onyx_int.h | 12 | ||||
-rw-r--r-- | vp9/encoder/vp9_rdopt.c | 8 | ||||
-rw-r--r-- | vp9/encoder/vp9_speed_features.c | 14 | ||||
-rw-r--r-- | vp9/vp9_cx_iface.c | 16 |
5 files changed, 49 insertions, 54 deletions
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 03f3c87a2..f51c90d59 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -376,7 +376,7 @@ static void update_reference_segmentation_map(VP9_COMP *cpi) { } } static int is_slowest_mode(int mode) { - return (mode == MODE_SECONDPASS_BEST || mode == MODE_BESTQUALITY); + return (mode == TWO_PASS_SECOND_BEST || mode == ONE_PASS_BEST); } static void set_rd_speed_thresholds(VP9_COMP *cpi) { @@ -670,7 +670,7 @@ static void init_config(struct VP9_COMP *cpi, VP9_CONFIG *oxcf) { if ((cpi->svc.number_temporal_layers > 1 && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) || (cpi->svc.number_spatial_layers > 1 && - cpi->oxcf.mode == MODE_SECONDPASS_BEST)) { + cpi->oxcf.mode == TWO_PASS_SECOND_BEST)) { vp9_init_layer_context(cpi); } @@ -710,29 +710,29 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9_CONFIG *oxcf) { switch (cpi->oxcf.mode) { // Real time and one pass deprecated in test code base - case MODE_GOODQUALITY: + case ONE_PASS_GOOD: cpi->pass = 0; cpi->oxcf.cpu_used = clamp(cpi->oxcf.cpu_used, -5, 5); break; - case MODE_BESTQUALITY: + case ONE_PASS_BEST: cpi->pass = 0; break; - case MODE_FIRSTPASS: + case TWO_PASS_FIRST: cpi->pass = 1; break; - case MODE_SECONDPASS: + case TWO_PASS_SECOND_GOOD: cpi->pass = 2; cpi->oxcf.cpu_used = clamp(cpi->oxcf.cpu_used, -5, 5); break; - case MODE_SECONDPASS_BEST: + case TWO_PASS_SECOND_BEST: cpi->pass = 2; break; - case MODE_REALTIME: + case REALTIME: cpi->pass = 0; break; } @@ -2364,6 +2364,17 @@ static void set_ext_overrides(VP9_COMP *cpi) { } } +static YV12_BUFFER_CONFIG *scale_if_required(VP9_COMMON *cm, + YV12_BUFFER_CONFIG *unscaled, YV12_BUFFER_CONFIG *scaled) { + if (cm->mi_cols * MI_SIZE != unscaled->y_width || + cm->mi_rows * MI_SIZE != unscaled->y_height) { + scale_and_extend_frame_nonnormative(unscaled, scaled); + return scaled; + } else { + return unscaled; + } +} + static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size, uint8_t *dest, @@ -2377,30 +2388,14 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, const SPEED_FEATURES *const sf = &cpi->sf; const unsigned int max_mv_def = MIN(cm->width, cm->height); struct segmentation *const seg = &cm->seg; - set_ext_overrides(cpi); - /* Scale the source buffer, if required. */ - if (cm->mi_cols * MI_SIZE != cpi->un_scaled_source->y_width || - cm->mi_rows * MI_SIZE != cpi->un_scaled_source->y_height) { - scale_and_extend_frame_nonnormative(cpi->un_scaled_source, - &cpi->scaled_source); - cpi->Source = &cpi->scaled_source; - } else { - cpi->Source = cpi->un_scaled_source; - } + cpi->Source = scale_if_required(cm, cpi->un_scaled_source, + &cpi->scaled_source); - // Scale the last source buffer, if required. - if (cpi->unscaled_last_source != NULL) { - if (cm->mi_cols * MI_SIZE != cpi->unscaled_last_source->y_width || - cm->mi_rows * MI_SIZE != cpi->unscaled_last_source->y_height) { - scale_and_extend_frame_nonnormative(cpi->unscaled_last_source, - &cpi->scaled_last_source); - cpi->Last_Source = &cpi->scaled_last_source; - } else { - cpi->Last_Source = cpi->unscaled_last_source; - } - } + if (cpi->unscaled_last_source != NULL) + cpi->Last_Source = scale_if_required(cm, cpi->unscaled_last_source, + &cpi->scaled_last_source); vp9_scale_references(cpi); diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h index 7a110ac4c..f85516170 100644 --- a/vp9/encoder/vp9_onyx_int.h +++ b/vp9/encoder/vp9_onyx_int.h @@ -142,33 +142,33 @@ typedef enum { // Good Quality Fast Encoding. The encoder balances quality with the // amount of time it takes to encode the output. (speed setting // controls how fast) - MODE_GOODQUALITY = 1, + ONE_PASS_GOOD = 1, // One Pass - Best Quality. The encoder places priority on the // quality of the output over encoding speed. The output is compressed // at the highest possible quality. This option takes the longest // amount of time to encode. (speed setting ignored) - MODE_BESTQUALITY = 2, + ONE_PASS_BEST = 2, // Two Pass - First Pass. The encoder generates a file of statistics // for use in the second encoding pass. (speed setting controls how fast) - MODE_FIRSTPASS = 3, + TWO_PASS_FIRST = 3, // Two Pass - Second Pass. The encoder uses the statistics that were // generated in the first encoding pass to create the compressed // output. (speed setting controls how fast) - MODE_SECONDPASS = 4, + TWO_PASS_SECOND_GOOD = 4, // Two Pass - Second Pass Best. The encoder uses the statistics that // were generated in the first encoding pass to create the compressed // output using the highest possible quality, and taking a // longer amount of time to encode. (speed setting ignored) - MODE_SECONDPASS_BEST = 5, + TWO_PASS_SECOND_BEST = 5, // Realtime/Live Encoding. This mode is optimized for realtime // encoding (for example, capturing a television signal or feed from // a live camera). (speed setting controls how fast) - MODE_REALTIME = 6, + REALTIME = 6, } MODE; typedef enum { diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 7ef21fa5d..caa8008ba 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -1806,8 +1806,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, if (best_rd < label_mv_thresh) break; - if (cpi->oxcf.mode != MODE_SECONDPASS_BEST && - cpi->oxcf.mode != MODE_BESTQUALITY) { + if (cpi->oxcf.mode != TWO_PASS_SECOND_BEST && + cpi->oxcf.mode != ONE_PASS_BEST) { // use previous block's result as next block's MV predictor. if (i > 0) { bsi->mvp.as_int = mi->bmi[i - 1].as_mv[0].as_int; @@ -1883,8 +1883,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, } // Should we do a full search (best quality only) - if (cpi->oxcf.mode == MODE_BESTQUALITY || - cpi->oxcf.mode == MODE_SECONDPASS_BEST) { + if (cpi->oxcf.mode == ONE_PASS_BEST || + cpi->oxcf.mode == TWO_PASS_SECOND_BEST) { int_mv *const best_mv = &mi->bmi[i].as_mv[0]; /* Check if mvp_full is within the range. */ clamp_mv(&mvp_full, x->mv_col_min, x->mv_col_max, diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index f0bd8a147..6e0effae3 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -353,16 +353,16 @@ void vp9_set_speed_features(VP9_COMP *cpi) { sf->recode_tolerance = 25; switch (oxcf->mode) { - case MODE_BESTQUALITY: - case MODE_SECONDPASS_BEST: // This is the best quality mode. + case ONE_PASS_BEST: + case TWO_PASS_SECOND_BEST: // This is the best quality mode. cpi->diamond_search_sad = vp9_full_range_search; break; - case MODE_FIRSTPASS: - case MODE_GOODQUALITY: - case MODE_SECONDPASS: + case TWO_PASS_FIRST: + case ONE_PASS_GOOD: + case TWO_PASS_SECOND_GOOD: set_good_speed_feature(cpi, cm, sf, speed); break; - case MODE_REALTIME: + case REALTIME: set_rt_speed_feature(cm, sf, speed); break; } @@ -385,7 +385,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) { cpi->mb.optimize = sf->optimize_coefficients == 1 && cpi->pass != 1; - if (cpi->encode_breakout && oxcf->mode == MODE_REALTIME && + if (cpi->encode_breakout && oxcf->mode == REALTIME && sf->encode_breakout_thresh > cpi->encode_breakout) cpi->encode_breakout = sf->encode_breakout_thresh; diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 967431c0f..95b3500c7 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -305,13 +305,13 @@ static vpx_codec_err_t set_encoder_config( switch (cfg->g_pass) { case VPX_RC_ONE_PASS: - oxcf->mode = MODE_GOODQUALITY; + oxcf->mode = ONE_PASS_GOOD; break; case VPX_RC_FIRST_PASS: - oxcf->mode = MODE_FIRSTPASS; + oxcf->mode = TWO_PASS_FIRST; break; case VPX_RC_LAST_PASS: - oxcf->mode = MODE_SECONDPASS_BEST; + oxcf->mode = TWO_PASS_SECOND_BEST; break; } @@ -603,7 +603,7 @@ static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, unsigned long duration, unsigned long deadline) { // Use best quality mode if no deadline is given. - MODE new_qc = MODE_BESTQUALITY; + MODE new_qc = ONE_PASS_BEST; if (deadline) { // Convert duration parameter from stream timebase to microseconds @@ -613,14 +613,14 @@ static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, // If the deadline is more that the duration this frame is to be shown, // use good quality mode. Otherwise use realtime mode. - new_qc = (deadline > duration_us) ? MODE_GOODQUALITY : MODE_REALTIME; + new_qc = (deadline > duration_us) ? ONE_PASS_GOOD : REALTIME; } if (ctx->cfg.g_pass == VPX_RC_FIRST_PASS) - new_qc = MODE_FIRSTPASS; + new_qc = TWO_PASS_FIRST; else if (ctx->cfg.g_pass == VPX_RC_LAST_PASS) - new_qc = (new_qc == MODE_BESTQUALITY) ? MODE_SECONDPASS_BEST - : MODE_SECONDPASS; + new_qc = (new_qc == ONE_PASS_BEST) ? TWO_PASS_SECOND_BEST + : TWO_PASS_SECOND_GOOD; if (ctx->oxcf.mode != new_qc) { ctx->oxcf.mode = new_qc; |