From f16776280f754d5be97d1db8b64398072d3f7115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1ri=20Tristan=20Helgason?= Date: Fri, 24 Aug 2018 13:21:26 +0200 Subject: [PATCH] Add config option to run VideoCodecTest in real time. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's reasonable to allow clients implementing their own VideoCodecTests to decide wether they should run in real-time. Removes the IsAsyncCodec helper, as the assumptions it made are outdated, and it is no longer useful. Bug: None Change-Id: If766935d4947555af54f499a30cfe553bde4c1ab Reviewed-on: https://webrtc-review.googlesource.com/95722 Commit-Queue: Kári Helgason Reviewed-by: Fredrik Solenberg Reviewed-by: Rasmus Brandt Cr-Commit-Position: refs/heads/master@{#24478} --- api/test/videocodec_test_fixture.h | 4 +++- .../codecs/test/videocodec_test_fixture_impl.cc | 16 ++-------------- .../codecs/test/videocodec_test_mediacodec.cc | 2 ++ .../video_coding/codecs/test/videoprocessor.cc | 2 +- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/api/test/videocodec_test_fixture.h b/api/test/videocodec_test_fixture.h index ec69e50ae1..a0b8083d72 100644 --- a/api/test/videocodec_test_fixture.h +++ b/api/test/videocodec_test_fixture.h @@ -81,7 +81,6 @@ class VideoCodecTestFixture { std::string ToString() const; std::string CodecName() const; - bool IsAsyncCodec() const; // Plain name of YUV file to process without file extension. std::string filename; @@ -105,6 +104,9 @@ class VideoCodecTestFixture { // If set to true, the encoding will run in real-time. bool measure_cpu = false; + // Simulate frames arriving in real-time by adding delays between frames. + bool encode_in_real_time = false; + // If > 0: forces the encoder to create a keyframe every Nth frame. size_t keyframe_interval = 0; diff --git a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc index 2958a9af50..6be4ce3a4a 100644 --- a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc +++ b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc @@ -121,15 +121,10 @@ std::string CodecSpecificToString(const VideoCodec& codec) { } bool RunEncodeInRealTime(const VideoCodecTestFixtureImpl::Config& config) { - if (config.measure_cpu) { + if (config.measure_cpu || config.encode_in_real_time) { return true; } -#if defined(WEBRTC_ANDROID) - // In order to not overwhelm the OpenMAX buffers in the Android MediaCodec. - return (config.hw_encoder || config.hw_decoder); -#else return false; -#endif } std::string FilenameWithParams( @@ -303,10 +298,6 @@ std::string VideoCodecTestFixtureImpl::Config::CodecName() const { return name; } -bool VideoCodecTestFixtureImpl::Config::IsAsyncCodec() const { - return hw_encoder || hw_decoder; -} - // TODO(kthelgason): Move this out of the test fixture impl and // make available as a shared utility class. void VideoCodecTestFixtureImpl::H264KeyframeChecker::CheckEncodedFrame( @@ -460,10 +451,7 @@ void VideoCodecTestFixtureImpl::ProcessAllFrames( // Give the VideoProcessor pipeline some time to process the last frame, // and then release the codecs. - if (config_.IsAsyncCodec()) { - SleepMs(1 * rtc::kNumMillisecsPerSec); - } - + SleepMs(1 * rtc::kNumMillisecsPerSec); cpu_process_time_->Stop(); } diff --git a/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc b/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc index 4fc4c3a8de..99b1aed8c0 100644 --- a/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc +++ b/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc @@ -35,6 +35,8 @@ VideoCodecTestFixture::Config CreateConfig() { config.num_frames = kForemanNumFrames; config.hw_encoder = true; config.hw_decoder = true; + // In order to not overwhelm the OpenMAX buffers in the Android MediaCodec. + config.encode_in_real_time = true; return config; } diff --git a/modules/video_coding/codecs/test/videoprocessor.cc b/modules/video_coding/codecs/test/videoprocessor.cc index a60ddf436e..ccf7053b41 100644 --- a/modules/video_coding/codecs/test/videoprocessor.cc +++ b/modules/video_coding/codecs/test/videoprocessor.cc @@ -444,7 +444,7 @@ void VideoProcessor::FrameEncoded( config_.codec_settings.codecType)); } - if (!config_.IsAsyncCodec()) { + if (!config_.encode_in_real_time) { // To get pure encode time for next layers, measure time spent in encode // callback and subtract it from encode time of next layers. post_encode_time_ns_ += rtc::TimeNanos() - encode_stop_ns;