From df18412f32981edc3eb1ccc3a5869f6c26a13899 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 7 Jul 2017 21:42:44 -0700 Subject: [PATCH] remove vp9_firstpass.c w/CONFIG_REALTIME_ONLY BUG=webm:1446 Change-Id: I6e0ea9342c715d354c641109737172afa649b85b --- vp9/encoder/vp9_encoder.c | 19 +++++++++++++++++++ vp9/encoder/vp9_ethread.c | 4 ++++ vp9/encoder/vp9_svc_layercontext.c | 2 ++ vp9/vp9_cx_iface.c | 11 +++++++++++ vp9/vp9cx.mk | 3 +++ 5 files changed, 39 insertions(+) diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 235e4600b..9f6ef21db 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -2181,6 +2181,7 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf, cpi->allow_encode_breakout = ENCODE_BREAKOUT_ENABLED; +#if !CONFIG_REALTIME_ONLY if (oxcf->pass == 1) { vp9_init_first_pass(cpi); } else if (oxcf->pass == 2) { @@ -2245,6 +2246,7 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf, vp9_init_second_pass(cpi); } } +#endif // !CONFIG_REALTIME_ONLY vp9_set_speed_features_framesize_independent(cpi); vp9_set_speed_features_framesize_dependent(cpi); @@ -3338,6 +3340,7 @@ static void set_frame_size(VP9_COMP *cpi) { VP9EncoderConfig *const oxcf = &cpi->oxcf; MACROBLOCKD *const xd = &cpi->td.mb.e_mbd; +#if !CONFIG_REALTIME_ONLY if (oxcf->pass == 2 && oxcf->rc_mode == VPX_VBR && ((oxcf->resize_mode == RESIZE_FIXED && cm->current_video_frame == 0) || (oxcf->resize_mode == RESIZE_DYNAMIC && cpi->resize_pending))) { @@ -3348,6 +3351,7 @@ static void set_frame_size(VP9_COMP *cpi) { vp9_set_size_literal(cpi, oxcf->scaled_frame_width, oxcf->scaled_frame_height); } +#endif // !CONFIG_REALTIME_ONLY if (oxcf->pass == 0 && oxcf->rc_mode == VPX_CBR && !cpi->use_svc && oxcf->resize_mode == RESIZE_DYNAMIC && cpi->resize_pending != 0) { @@ -4569,6 +4573,7 @@ static void Pass0Encode(VP9_COMP *cpi, size_t *size, uint8_t *dest, encode_frame_to_data_rate(cpi, size, dest, frame_flags); } +#if !CONFIG_REALTIME_ONLY static void Pass2Encode(VP9_COMP *cpi, size_t *size, uint8_t *dest, unsigned int *frame_flags) { cpi->allow_encode_breakout = ENCODE_BREAKOUT_ENABLED; @@ -4577,6 +4582,7 @@ static void Pass2Encode(VP9_COMP *cpi, size_t *size, uint8_t *dest, if (!(is_two_pass_svc(cpi) && cpi->svc.encode_empty_frame_state == ENCODING)) vp9_twopass_postencode_update(cpi); } +#endif // !CONFIG_REALTIME_ONLY static void init_ref_frame_bufs(VP9_COMMON *cm) { int i; @@ -5152,10 +5158,12 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, } else { *size = 0; +#if !CONFIG_REALTIME_ONLY if (flush && oxcf->pass == 1 && !cpi->twopass.first_pass_done) { vp9_end_first_pass(cpi); /* get last stats packet */ cpi->twopass.first_pass_done = 1; } +#endif // !CONFIG_REALTIME_ONLY return -1; } @@ -5202,6 +5210,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, cpi->frame_flags = *frame_flags; +#if !CONFIG_REALTIME_ONLY if ((oxcf->pass == 2) && (!cpi->use_svc || (is_two_pass_svc(cpi) && cpi->svc.encode_empty_frame_state != ENCODING))) { @@ -5209,6 +5218,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, } else if (oxcf->pass == 1) { set_frame_size(cpi); } +#endif // !CONFIG_REALTIME_ONLY if (oxcf->pass != 1 && cpi->level_constraint.level_index >= 0 && cpi->level_constraint.fail_flag == 0) @@ -5219,6 +5229,14 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, } cpi->td.mb.fp_src_pred = 0; +#if CONFIG_REALTIME_ONLY + if (cpi->use_svc) { + SvcEncode(cpi, size, dest, frame_flags); + } else { + // One pass encode + Pass0Encode(cpi, size, dest, frame_flags); + } +#else // !CONFIG_REALTIME_ONLY if (oxcf->pass == 1 && (!cpi->use_svc || is_two_pass_svc(cpi))) { const int lossless = is_lossless_requested(oxcf); #if CONFIG_VP9_HIGHBITDEPTH @@ -5242,6 +5260,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, // One pass encode Pass0Encode(cpi, size, dest, frame_flags); } +#endif // CONFIG_REALTIME_ONLY if (cm->refresh_frame_context) cm->frame_contexts[cm->frame_context_idx] = *cm->fc; diff --git a/vp9/encoder/vp9_ethread.c b/vp9/encoder/vp9_ethread.c index 51664112a..5aabc2f0e 100644 --- a/vp9/encoder/vp9_ethread.c +++ b/vp9/encoder/vp9_ethread.c @@ -217,6 +217,7 @@ void vp9_encode_tiles_mt(VP9_COMP *cpi) { } } +#if !CONFIG_REALTIME_ONLY static void accumulate_fp_tile_stat(TileDataEnc *tile_data, TileDataEnc *tile_data_t) { tile_data->fp_data.intra_factor += tile_data_t->fp_data.intra_factor; @@ -251,6 +252,7 @@ static void accumulate_fp_tile_stat(TileDataEnc *tile_data, : VPXMIN(tile_data->fp_data.image_data_start_row, tile_data_t->fp_data.image_data_start_row); } +#endif // !CONFIG_REALTIME_ONLY // Allocate memory for row synchronization void vp9_row_mt_sync_mem_alloc(VP9RowMTSync *row_mt_sync, VP9_COMMON *cm, @@ -379,6 +381,7 @@ void vp9_row_mt_sync_write_dummy(VP9RowMTSync *const row_mt_sync, int r, int c, return; } +#if !CONFIG_REALTIME_ONLY static int first_pass_worker_hook(EncWorkerData *const thread_data, MultiThreadHandle *multi_thread_ctxt) { VP9_COMP *const cpi = thread_data->cpi; @@ -468,6 +471,7 @@ void vp9_encode_fp_row_mt(VP9_COMP *cpi) { accumulate_fp_tile_stat(first_tile_col, this_tile); } } +#endif // !CONFIG_REALTIME_ONLY static int temporal_filter_worker_hook(EncWorkerData *const thread_data, MultiThreadHandle *multi_thread_ctxt) { diff --git a/vp9/encoder/vp9_svc_layercontext.c b/vp9/encoder/vp9_svc_layercontext.c index 71aa82065..409744b4a 100644 --- a/vp9/encoder/vp9_svc_layercontext.c +++ b/vp9/encoder/vp9_svc_layercontext.c @@ -352,6 +352,7 @@ void vp9_save_layer_context(VP9_COMP *const cpi) { } } +#if !CONFIG_REALTIME_ONLY void vp9_init_second_pass_spatial_svc(VP9_COMP *cpi) { SVC *const svc = &cpi->svc; int i; @@ -367,6 +368,7 @@ void vp9_init_second_pass_spatial_svc(VP9_COMP *cpi) { } svc->spatial_layer_id = 0; } +#endif // !CONFIG_REALTIME_ONLY void vp9_inc_frame_in_layer(VP9_COMP *const cpi) { LAYER_CONTEXT *const lc = diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index 64ce1c0ef..876aef3e6 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -176,7 +176,11 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100); RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100); RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100); +#if CONFIG_REALTIME_ONLY + RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_ONE_PASS); +#else RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_LAST_PASS); +#endif RANGE_CHECK(extra_cfg, min_gf_interval, 0, (MAX_LAG_BUFFERS - 1)); RANGE_CHECK(extra_cfg, max_gf_interval, 0, (MAX_LAG_BUFFERS - 1)); if (extra_cfg->max_gf_interval > 0) { @@ -269,6 +273,7 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, if (extra_cfg->tuning == VP8_TUNE_SSIM) ERROR("Option --tune=ssim is not currently supported in VP9."); +#if !CONFIG_REALTIME_ONLY if (cfg->g_pass == VPX_RC_LAST_PASS) { const size_t packet_sz = sizeof(FIRSTPASS_STATS); const int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz); @@ -320,6 +325,7 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, ERROR("rc_twopass_stats_in missing EOS stats packet"); } } +#endif // !CONFIG_REALTIME_ONLY #if !CONFIG_VP9_HIGHBITDEPTH if (cfg->g_profile > (unsigned int)PROFILE_1) { @@ -939,6 +945,10 @@ static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, unsigned long deadline) { MODE new_mode = BEST; +#if CONFIG_REALTIME_ONLY + (void)duration; + deadline = VPX_DL_REALTIME; +#else switch (ctx->cfg.g_pass) { case VPX_RC_ONE_PASS: if (deadline > 0) { @@ -959,6 +969,7 @@ static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, case VPX_RC_FIRST_PASS: break; case VPX_RC_LAST_PASS: new_mode = deadline > 0 ? GOOD : BEST; break; } +#endif // CONFIG_REALTIME_ONLY if (deadline == VPX_DL_REALTIME) { ctx->oxcf.pass = 0; diff --git a/vp9/vp9cx.mk b/vp9/vp9cx.mk index 47846c941..09d8ec8ef 100644 --- a/vp9/vp9cx.mk +++ b/vp9/vp9cx.mk @@ -138,4 +138,7 @@ VP9_CX_SRCS-$(HAVE_MSA) += encoder/mips/msa/vp9_fdct8x8_msa.c VP9_CX_SRCS-$(HAVE_MSA) += encoder/mips/msa/vp9_fdct16x16_msa.c VP9_CX_SRCS-$(HAVE_MSA) += encoder/mips/msa/vp9_fdct_msa.h +# Strip unnecessary files with CONFIG_REALTIME_ONLY +VP9_CX_SRCS_REMOVE-$(CONFIG_REALTIME_ONLY) += encoder/vp9_firstpass.c + VP9_CX_SRCS-yes := $(filter-out $(VP9_CX_SRCS_REMOVE-yes),$(VP9_CX_SRCS-yes)) -- 2.40.0