From ffb3c50da1d7ac24e6ae7858cb62abb348552b6a Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 7 Mar 2017 14:32:30 -0800 Subject: [PATCH] vp9: Enable row multithreading for SVC in real-time mode. Enable row-mt for SVC for real-time mode, speed >=5. Add the controls to the sample encoders, but keep it off for now. Add the control and enable it for the 1 pass CBR unittests. For speed 7, 3 layer SVC, 2 threads, row-mt enabled gives about ~5% speedup. Change-Id: Ie8e77323c17263e3e7a7b9858aec12a3a93ec0c1 --- examples/vp9_spatial_svc_encoder.c | 4 +++- test/datarate_test.cc | 1 + vp9/encoder/vp9_encoder.c | 3 +-- vp9/encoder/vp9_ethread.c | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/vp9_spatial_svc_encoder.c b/examples/vp9_spatial_svc_encoder.c index 0e40938..1f5078a 100644 --- a/examples/vp9_spatial_svc_encoder.c +++ b/examples/vp9_spatial_svc_encoder.c @@ -697,8 +697,10 @@ int main(int argc, const char **argv) { if (svc_ctx.speed != -1) vpx_codec_control(&codec, VP8E_SET_CPUUSED, svc_ctx.speed); - if (svc_ctx.threads) + if (svc_ctx.threads) { vpx_codec_control(&codec, VP9E_SET_TILE_COLUMNS, (svc_ctx.threads >> 1)); + vpx_codec_control(&codec, VP9E_SET_ROW_MT, 0); + } if (svc_ctx.speed >= 5 && svc_ctx.aqmode == 1) vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3); if (svc_ctx.speed >= 5) diff --git a/test/datarate_test.cc b/test/datarate_test.cc index e66761f..e339030 100644 --- a/test/datarate_test.cc +++ b/test/datarate_test.cc @@ -1096,6 +1096,7 @@ class DatarateOnePassCbrSvc encoder->Control(VP9E_SET_TILE_COLUMNS, 0); encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 300); encoder->Control(VP9E_SET_TILE_COLUMNS, (cfg_.g_threads >> 1)); + encoder->Control(VP9E_SET_ROW_MT, 1); encoder->Control(VP8E_SET_STATIC_THRESHOLD, 1); } const vpx_rational_t tb = video->timebase(); diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 03bf385..9ff97ea 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -5201,8 +5201,7 @@ void vp9_set_row_mt(VP9_COMP *cpi) { // In realtime mode, enable row based multi-threading for all the speed levels // where non-rd path is used. - if (cpi->oxcf.mode == REALTIME && cpi->oxcf.speed >= 5 && cpi->oxcf.row_mt && - !cpi->use_svc) { + if (cpi->oxcf.mode == REALTIME && cpi->oxcf.speed >= 5 && cpi->oxcf.row_mt) { cpi->row_mt = 1; } } diff --git a/vp9/encoder/vp9_ethread.c b/vp9/encoder/vp9_ethread.c index b618b42..2b2a556 100644 --- a/vp9/encoder/vp9_ethread.c +++ b/vp9/encoder/vp9_ethread.c @@ -77,8 +77,9 @@ static void create_enc_workers(VP9_COMP *cpi, int num_workers) { int allocated_workers = num_workers; // While using SVC, we need to allocate threads according to the highest - // resolution. - if (cpi->use_svc) { + // resolution. When row based multithreading is enabled, it is OK to + // allocate more threads than the number of max tile columns. + if (cpi->use_svc && !cpi->row_mt) { int max_tile_cols = get_max_tile_cols(cpi); allocated_workers = VPXMIN(cpi->oxcf.max_threads, max_tile_cols); } @@ -615,7 +616,6 @@ void vp9_encode_tiles_row_mt(VP9_COMP *cpi) { for (i = 0; i < num_workers; i++) { EncWorkerData *thread_data; thread_data = &cpi->tile_thr_data[i]; - // Before encoding a frame, copy the thread data from cpi. if (thread_data->td != &cpi->td) { thread_data->td->mb = cpi->td.mb; -- 2.7.4