Add config option to run VideoCodecTest in real time.

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 <kthelgason@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24478}
This commit is contained in:
Kári Tristan Helgason 2018-08-24 13:21:26 +02:00 committed by Commit Bot
parent e5892c014a
commit f16776280f
4 changed files with 8 additions and 16 deletions

View File

@ -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;

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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;