VideoCodecTextFixture and YuvFrameReader improvements.
Adds ability to specify desired frame size separate from actual clip resolution, as well as clip and desired fps. This allows e.g. reading an HD clip but running benchmarks in VGA, and to specify e.g. 60fps for the clip but 30for encoding where frame dropping kicks in so that motion is actually correct rather than just plaing the clip slowly. Bug: webrtc:12229 Change-Id: I4ad4fcc335611a449dc2723ffafbec6731e89f55 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/195324 Commit-Queue: Erik Språng <sprang@webrtc.org> Reviewed-by: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32839}
This commit is contained in:
@ -58,7 +58,7 @@ using VideoStatistics = VideoCodecTestStats::VideoStatistics;
|
||||
namespace {
|
||||
const int kBaseKeyFrameInterval = 3000;
|
||||
const double kBitratePriority = 1.0;
|
||||
const int kMaxFramerateFps = 30;
|
||||
const int kDefaultMaxFramerateFps = 30;
|
||||
const int kMaxQp = 56;
|
||||
|
||||
void ConfigureSimulcast(VideoCodec* codec_settings) {
|
||||
@ -86,7 +86,7 @@ void ConfigureSvc(VideoCodec* codec_settings) {
|
||||
RTC_CHECK_EQ(kVideoCodecVP9, codec_settings->codecType);
|
||||
|
||||
const std::vector<SpatialLayer> layers = GetSvcConfig(
|
||||
codec_settings->width, codec_settings->height, kMaxFramerateFps,
|
||||
codec_settings->width, codec_settings->height, kDefaultMaxFramerateFps,
|
||||
/*first_active_layer=*/0, codec_settings->VP9()->numberOfSpatialLayers,
|
||||
codec_settings->VP9()->numberOfTemporalLayers,
|
||||
/* is_screen_sharing = */ false);
|
||||
@ -646,10 +646,16 @@ void VideoCodecTestFixtureImpl::SetUpAndInitObjects(
|
||||
config_.codec_settings.startBitrate = static_cast<int>(initial_bitrate_kbps);
|
||||
config_.codec_settings.maxFramerate = std::ceil(initial_framerate_fps);
|
||||
|
||||
int clip_width = config_.clip_width.value_or(config_.codec_settings.width);
|
||||
int clip_height = config_.clip_height.value_or(config_.codec_settings.height);
|
||||
|
||||
// Create file objects for quality analysis.
|
||||
source_frame_reader_.reset(
|
||||
new YuvFrameReaderImpl(config_.filepath, config_.codec_settings.width,
|
||||
config_.codec_settings.height));
|
||||
source_frame_reader_.reset(new YuvFrameReaderImpl(
|
||||
config_.filepath, clip_width, clip_height,
|
||||
config_.reference_width.value_or(clip_width),
|
||||
config_.reference_height.value_or(clip_height),
|
||||
YuvFrameReaderImpl::RepeatMode::kPingPong, config_.clip_fps,
|
||||
config_.codec_settings.maxFramerate));
|
||||
EXPECT_TRUE(source_frame_reader_->Init());
|
||||
|
||||
RTC_DCHECK(encoded_frame_writers_.empty());
|
||||
|
||||
@ -251,7 +251,27 @@ void VideoProcessor::ProcessFrame() {
|
||||
if (input_frames_.size() == kMaxBufferedInputFrames) {
|
||||
input_frames_.erase(input_frames_.begin());
|
||||
}
|
||||
input_frames_.emplace(frame_number, input_frame);
|
||||
|
||||
if (config_.reference_width != -1 && config_.reference_height != -1 &&
|
||||
(input_frame.width() != config_.reference_width ||
|
||||
input_frame.height() != config_.reference_height)) {
|
||||
rtc::scoped_refptr<I420Buffer> scaled_buffer = I420Buffer::Create(
|
||||
config_.codec_settings.width, config_.codec_settings.height);
|
||||
scaled_buffer->ScaleFrom(*input_frame.video_frame_buffer()->ToI420());
|
||||
|
||||
VideoFrame scaled_reference_frame = input_frame;
|
||||
scaled_reference_frame.set_video_frame_buffer(scaled_buffer);
|
||||
input_frames_.emplace(frame_number, scaled_reference_frame);
|
||||
|
||||
if (config_.reference_width == config_.codec_settings.width &&
|
||||
config_.reference_height == config_.codec_settings.height) {
|
||||
// Both encoding and comparison uses the same down-scale factor, reuse
|
||||
// it for encoder below.
|
||||
input_frame = scaled_reference_frame;
|
||||
}
|
||||
} else {
|
||||
input_frames_.emplace(frame_number, input_frame);
|
||||
}
|
||||
}
|
||||
last_inputed_timestamp_ = timestamp;
|
||||
|
||||
@ -271,6 +291,14 @@ void VideoProcessor::ProcessFrame() {
|
||||
frame_stat->encode_start_ns = encode_start_ns;
|
||||
}
|
||||
|
||||
if (input_frame.width() != config_.codec_settings.width ||
|
||||
input_frame.height() != config_.codec_settings.height) {
|
||||
rtc::scoped_refptr<I420Buffer> scaled_buffer = I420Buffer::Create(
|
||||
config_.codec_settings.width, config_.codec_settings.height);
|
||||
scaled_buffer->ScaleFrom(*input_frame.video_frame_buffer()->ToI420());
|
||||
input_frame.set_video_frame_buffer(scaled_buffer);
|
||||
}
|
||||
|
||||
// Encode.
|
||||
const std::vector<VideoFrameType> frame_types =
|
||||
(frame_number == 0)
|
||||
|
||||
Reference in New Issue
Block a user