2011-10-06 06:44:54 +00:00
|
|
|
/*
|
2012-04-12 06:59:14 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-10-06 06:44:54 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2011-12-08 07:42:18 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/codecs/test/videoprocessor.h"
|
2011-10-06 06:44:54 +00:00
|
|
|
|
2017-09-28 09:23:17 -07:00
|
|
|
#include <algorithm>
|
2011-10-06 06:44:54 +00:00
|
|
|
#include <limits>
|
2016-11-16 16:41:30 +01:00
|
|
|
#include <utility>
|
2011-10-06 06:44:54 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/video/i420_buffer.h"
|
2017-09-15 13:58:09 +02:00
|
|
|
#include "common_types.h" // NOLINT(build/include)
|
2017-09-28 09:23:17 -07:00
|
|
|
#include "common_video/h264/h264_common.h"
|
2018-01-17 15:11:44 +01:00
|
|
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/codecs/vp8/simulcast_rate_allocator.h"
|
|
|
|
|
#include "modules/video_coding/include/video_codec_initializer.h"
|
|
|
|
|
#include "modules/video_coding/utility/default_video_bitrate_allocator.h"
|
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "rtc_base/timeutils.h"
|
|
|
|
|
#include "test/gtest.h"
|
2011-10-06 06:44:54 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace test {
|
|
|
|
|
|
2017-02-22 01:26:59 -08:00
|
|
|
namespace {
|
2017-03-07 01:41:43 -08:00
|
|
|
|
2017-02-28 07:13:47 -08:00
|
|
|
std::unique_ptr<VideoBitrateAllocator> CreateBitrateAllocator(
|
2017-08-08 08:35:53 -07:00
|
|
|
TestConfig* config) {
|
2017-02-28 07:13:47 -08:00
|
|
|
std::unique_ptr<TemporalLayersFactory> tl_factory;
|
2017-08-08 08:35:53 -07:00
|
|
|
if (config->codec_settings.codecType == VideoCodecType::kVideoCodecVP8) {
|
2017-02-28 07:13:47 -08:00
|
|
|
tl_factory.reset(new TemporalLayersFactory());
|
2017-08-08 08:35:53 -07:00
|
|
|
config->codec_settings.VP8()->tl_factory = tl_factory.get();
|
2017-02-28 07:13:47 -08:00
|
|
|
}
|
|
|
|
|
return std::unique_ptr<VideoBitrateAllocator>(
|
2017-08-08 08:35:53 -07:00
|
|
|
VideoCodecInitializer::CreateBitrateAllocator(config->codec_settings,
|
2017-02-28 07:13:47 -08:00
|
|
|
std::move(tl_factory)));
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-17 15:11:44 +01:00
|
|
|
size_t GetMaxNaluSizeBytes(const EncodedImage& encoded_frame,
|
|
|
|
|
const TestConfig& config) {
|
2017-09-28 09:23:17 -07:00
|
|
|
if (config.codec_settings.codecType != kVideoCodecH264)
|
2018-01-17 15:11:44 +01:00
|
|
|
return 0;
|
2017-09-28 09:23:17 -07:00
|
|
|
|
|
|
|
|
std::vector<webrtc::H264::NaluIndex> nalu_indices =
|
|
|
|
|
webrtc::H264::FindNaluIndices(encoded_frame._buffer,
|
|
|
|
|
encoded_frame._length);
|
|
|
|
|
|
|
|
|
|
RTC_CHECK(!nalu_indices.empty());
|
|
|
|
|
|
2018-01-17 15:11:44 +01:00
|
|
|
size_t max_size = 0;
|
2017-09-28 09:23:17 -07:00
|
|
|
for (const webrtc::H264::NaluIndex& index : nalu_indices)
|
2018-01-17 15:11:44 +01:00
|
|
|
max_size = std::max(max_size, index.payload_size);
|
2017-09-28 09:23:17 -07:00
|
|
|
|
2018-01-17 15:11:44 +01:00
|
|
|
return max_size;
|
2017-09-28 09:23:17 -07:00
|
|
|
}
|
|
|
|
|
|
2017-03-07 00:25:38 -08:00
|
|
|
int GetElapsedTimeMicroseconds(int64_t start_ns, int64_t stop_ns) {
|
|
|
|
|
int64_t diff_us = (stop_ns - start_ns) / rtc::kNumNanosecsPerMicrosec;
|
|
|
|
|
RTC_DCHECK_GE(diff_us, std::numeric_limits<int>::min());
|
|
|
|
|
RTC_DCHECK_LE(diff_us, std::numeric_limits<int>::max());
|
|
|
|
|
return static_cast<int>(diff_us);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-24 16:03:39 +02:00
|
|
|
void ExtractBufferWithSize(const VideoFrame& image,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
rtc::Buffer* buffer) {
|
|
|
|
|
if (image.width() != width || image.height() != height) {
|
|
|
|
|
EXPECT_DOUBLE_EQ(static_cast<double>(width) / height,
|
|
|
|
|
static_cast<double>(image.width()) / image.height());
|
|
|
|
|
// Same aspect ratio, no cropping needed.
|
|
|
|
|
rtc::scoped_refptr<I420Buffer> scaled(I420Buffer::Create(width, height));
|
|
|
|
|
scaled->ScaleFrom(*image.video_frame_buffer()->ToI420());
|
|
|
|
|
|
|
|
|
|
size_t length =
|
|
|
|
|
CalcBufferSize(VideoType::kI420, scaled->width(), scaled->height());
|
|
|
|
|
buffer->SetSize(length);
|
|
|
|
|
RTC_CHECK_NE(ExtractBuffer(scaled, length, buffer->data()), -1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// No resize.
|
|
|
|
|
size_t length =
|
|
|
|
|
CalcBufferSize(VideoType::kI420, image.width(), image.height());
|
|
|
|
|
buffer->SetSize(length);
|
|
|
|
|
RTC_CHECK_NE(ExtractBuffer(image, length, buffer->data()), -1);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-22 01:26:59 -08:00
|
|
|
} // namespace
|
|
|
|
|
|
2017-08-07 08:12:33 -07:00
|
|
|
VideoProcessor::VideoProcessor(webrtc::VideoEncoder* encoder,
|
|
|
|
|
webrtc::VideoDecoder* decoder,
|
|
|
|
|
FrameReader* analysis_frame_reader,
|
|
|
|
|
const TestConfig& config,
|
|
|
|
|
Stats* stats,
|
|
|
|
|
IvfFileWriter* encoded_frame_writer,
|
|
|
|
|
FrameWriter* decoded_frame_writer)
|
2017-10-24 16:03:39 +02:00
|
|
|
: config_(config),
|
2017-08-08 08:35:53 -07:00
|
|
|
encoder_(encoder),
|
2011-10-06 06:44:54 +00:00
|
|
|
decoder_(decoder),
|
2017-08-08 08:35:53 -07:00
|
|
|
bitrate_allocator_(CreateBitrateAllocator(&config_)),
|
2017-08-21 01:34:04 -07:00
|
|
|
encode_callback_(this),
|
|
|
|
|
decode_callback_(this),
|
2017-02-28 07:13:47 -08:00
|
|
|
analysis_frame_reader_(analysis_frame_reader),
|
2017-02-22 01:26:59 -08:00
|
|
|
encoded_frame_writer_(encoded_frame_writer),
|
|
|
|
|
decoded_frame_writer_(decoded_frame_writer),
|
2018-01-17 15:11:44 +01:00
|
|
|
last_inputed_frame_num_(0),
|
|
|
|
|
last_encoded_frame_num_(0),
|
|
|
|
|
last_decoded_frame_num_(0),
|
|
|
|
|
num_encoded_frames_(0),
|
|
|
|
|
num_decoded_frames_(0),
|
2017-08-21 01:34:04 -07:00
|
|
|
last_decoded_frame_buffer_(analysis_frame_reader->FrameLength()),
|
2018-01-17 15:11:44 +01:00
|
|
|
stats_(stats) {
|
2016-11-16 16:41:30 +01:00
|
|
|
RTC_DCHECK(encoder);
|
|
|
|
|
RTC_DCHECK(decoder);
|
2017-02-22 01:26:59 -08:00
|
|
|
RTC_DCHECK(analysis_frame_reader);
|
2016-11-16 16:41:30 +01:00
|
|
|
RTC_DCHECK(stats);
|
2017-03-07 01:41:43 -08:00
|
|
|
|
2017-08-07 03:36:54 -07:00
|
|
|
// Setup required callbacks for the encoder and decoder.
|
2017-08-21 01:34:04 -07:00
|
|
|
RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(&encode_callback_),
|
2017-10-24 16:03:39 +02:00
|
|
|
WEBRTC_VIDEO_CODEC_OK);
|
2017-08-21 01:34:04 -07:00
|
|
|
RTC_CHECK_EQ(decoder_->RegisterDecodeCompleteCallback(&decode_callback_),
|
2017-10-24 16:03:39 +02:00
|
|
|
WEBRTC_VIDEO_CODEC_OK);
|
2017-02-10 00:16:07 -08:00
|
|
|
|
2017-02-28 07:13:47 -08:00
|
|
|
// Initialize the encoder and decoder.
|
2018-01-22 15:49:55 +01:00
|
|
|
RTC_CHECK_EQ(encoder_->InitEncode(&config_.codec_settings,
|
|
|
|
|
static_cast<int>(config_.NumberOfCores()),
|
|
|
|
|
config_.max_payload_size_bytes),
|
|
|
|
|
WEBRTC_VIDEO_CODEC_OK);
|
2018-01-17 15:11:44 +01:00
|
|
|
RTC_CHECK_EQ(decoder_->InitDecode(&config_.codec_settings,
|
|
|
|
|
static_cast<int>(config_.NumberOfCores())),
|
|
|
|
|
WEBRTC_VIDEO_CODEC_OK);
|
2011-10-06 06:44:54 +00:00
|
|
|
}
|
|
|
|
|
|
2017-10-24 16:03:39 +02:00
|
|
|
VideoProcessor::~VideoProcessor() {
|
2017-08-21 06:44:16 -07:00
|
|
|
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
|
|
|
|
|
|
2017-08-11 07:48:15 -07:00
|
|
|
RTC_CHECK_EQ(encoder_->Release(), WEBRTC_VIDEO_CODEC_OK);
|
|
|
|
|
RTC_CHECK_EQ(decoder_->Release(), WEBRTC_VIDEO_CODEC_OK);
|
|
|
|
|
|
2017-08-21 01:34:04 -07:00
|
|
|
encoder_->RegisterEncodeCompleteCallback(nullptr);
|
|
|
|
|
decoder_->RegisterDecodeCompleteCallback(nullptr);
|
2017-08-11 07:48:15 -07:00
|
|
|
}
|
|
|
|
|
|
2017-09-06 01:53:22 -07:00
|
|
|
void VideoProcessor::ProcessFrame() {
|
2017-08-21 06:44:16 -07:00
|
|
|
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
|
2018-01-17 15:11:44 +01:00
|
|
|
const size_t frame_number = last_inputed_frame_num_++;
|
2017-02-10 00:16:07 -08:00
|
|
|
|
2017-08-21 01:34:04 -07:00
|
|
|
// Get frame from file.
|
2017-06-01 10:02:26 -07:00
|
|
|
rtc::scoped_refptr<I420BufferInterface> buffer(
|
2017-02-22 01:26:59 -08:00
|
|
|
analysis_frame_reader_->ReadFrame());
|
2017-08-21 01:34:04 -07:00
|
|
|
RTC_CHECK(buffer) << "Tried to read too many frames from the file.";
|
2017-08-30 06:29:51 -07:00
|
|
|
// Use the frame number as the basis for timestamp to identify frames. Let the
|
|
|
|
|
// first timestamp be non-zero, to not make the IvfFileWriter believe that we
|
|
|
|
|
// want to use capture timestamps in the IVF files.
|
2018-01-19 14:57:10 +01:00
|
|
|
// TODO(asapersson): Time stamps jump back if framerate increases.
|
2018-01-17 15:11:44 +01:00
|
|
|
const size_t rtp_timestamp = (frame_number + 1) * kVideoPayloadTypeFrequency /
|
|
|
|
|
config_.codec_settings.maxFramerate;
|
2017-12-12 16:37:16 +01:00
|
|
|
const int64_t render_time_ms = (frame_number + 1) * rtc::kNumMillisecsPerSec /
|
|
|
|
|
config_.codec_settings.maxFramerate;
|
2018-01-17 15:11:44 +01:00
|
|
|
input_frames_[frame_number] =
|
|
|
|
|
rtc::MakeUnique<VideoFrame>(buffer, static_cast<uint32_t>(rtp_timestamp),
|
|
|
|
|
render_time_ms, webrtc::kVideoRotation_0);
|
2017-02-15 05:19:51 -08:00
|
|
|
|
2017-11-17 14:47:32 +01:00
|
|
|
std::vector<FrameType> frame_types = config_.FrameTypeForFrame(frame_number);
|
2017-03-07 01:41:43 -08:00
|
|
|
|
|
|
|
|
// Create frame statistics object used for aggregation at end of test run.
|
2018-01-19 14:57:10 +01:00
|
|
|
FrameStatistic* frame_stat = stats_->AddFrame(rtp_timestamp);
|
2017-03-07 01:41:43 -08:00
|
|
|
|
|
|
|
|
// For the highest measurement accuracy of the encode time, the start/stop
|
|
|
|
|
// time recordings should wrap the Encode call as tightly as possible.
|
2017-09-06 01:53:22 -07:00
|
|
|
frame_stat->encode_start_ns = rtc::TimeNanos();
|
2017-03-07 01:41:43 -08:00
|
|
|
frame_stat->encode_return_code =
|
2017-11-17 14:47:32 +01:00
|
|
|
encoder_->Encode(*input_frames_[frame_number], nullptr, &frame_types);
|
2011-10-06 06:44:54 +00:00
|
|
|
}
|
|
|
|
|
|
2018-01-17 15:11:44 +01:00
|
|
|
void VideoProcessor::SetRates(size_t bitrate_kbps, size_t framerate_fps) {
|
2017-08-21 06:44:16 -07:00
|
|
|
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
|
2018-01-17 15:11:44 +01:00
|
|
|
config_.codec_settings.maxFramerate = static_cast<uint32_t>(framerate_fps);
|
|
|
|
|
bitrate_allocation_ = bitrate_allocator_->GetAllocation(
|
|
|
|
|
static_cast<uint32_t>(bitrate_kbps * 1000),
|
|
|
|
|
static_cast<uint32_t>(framerate_fps));
|
|
|
|
|
const int set_rates_result = encoder_->SetRateAllocation(
|
|
|
|
|
bitrate_allocation_, static_cast<uint32_t>(framerate_fps));
|
2017-08-07 03:36:54 -07:00
|
|
|
RTC_DCHECK_GE(set_rates_result, 0)
|
2017-08-21 01:34:04 -07:00
|
|
|
<< "Failed to update encoder with new rate " << bitrate_kbps << ".";
|
2017-08-07 03:36:54 -07:00
|
|
|
}
|
|
|
|
|
|
2017-08-22 03:33:11 -07:00
|
|
|
void VideoProcessor::FrameEncoded(webrtc::VideoCodecType codec,
|
|
|
|
|
const EncodedImage& encoded_image) {
|
2017-08-21 06:44:16 -07:00
|
|
|
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
|
|
|
|
|
|
2017-02-15 05:29:38 -08:00
|
|
|
// For the highest measurement accuracy of the encode time, the start/stop
|
|
|
|
|
// time recordings should wrap the Encode call as tightly as possible.
|
|
|
|
|
int64_t encode_stop_ns = rtc::TimeNanos();
|
|
|
|
|
|
2017-10-24 10:16:33 +02:00
|
|
|
if (config_.encoded_frame_checker) {
|
|
|
|
|
config_.encoded_frame_checker->CheckEncodedFrame(codec, encoded_image);
|
|
|
|
|
}
|
2017-02-22 01:26:59 -08:00
|
|
|
|
2018-01-19 14:57:10 +01:00
|
|
|
FrameStatistic* frame_stat =
|
|
|
|
|
stats_->GetFrameWithTimestamp(encoded_image._timeStamp);
|
2017-11-17 14:47:32 +01:00
|
|
|
|
|
|
|
|
// Ensure strict monotonicity.
|
2018-01-19 14:57:10 +01:00
|
|
|
const size_t frame_number = frame_stat->frame_number;
|
2018-01-17 15:11:44 +01:00
|
|
|
if (num_encoded_frames_ > 0) {
|
|
|
|
|
RTC_CHECK_GT(frame_number, last_encoded_frame_num_);
|
|
|
|
|
}
|
2017-11-17 14:47:32 +01:00
|
|
|
|
2017-03-07 01:41:43 -08:00
|
|
|
last_encoded_frame_num_ = frame_number;
|
|
|
|
|
|
2017-09-06 01:53:22 -07:00
|
|
|
// Update frame statistics.
|
|
|
|
|
frame_stat->encode_time_us =
|
|
|
|
|
GetElapsedTimeMicroseconds(frame_stat->encode_start_ns, encode_stop_ns);
|
2017-03-07 01:41:43 -08:00
|
|
|
frame_stat->encoding_successful = true;
|
2017-09-06 01:53:22 -07:00
|
|
|
frame_stat->encoded_frame_size_bytes = encoded_image._length;
|
2017-03-07 01:41:43 -08:00
|
|
|
frame_stat->frame_type = encoded_image._frameType;
|
2018-01-17 15:11:44 +01:00
|
|
|
frame_stat->temporal_layer_idx = config_.TemporalLayerForFrame(frame_number);
|
2017-03-07 01:41:43 -08:00
|
|
|
frame_stat->qp = encoded_image.qp_;
|
2018-01-17 15:11:44 +01:00
|
|
|
frame_stat->target_bitrate_kbps =
|
|
|
|
|
bitrate_allocation_.GetSpatialLayerSum(0) / 1000;
|
|
|
|
|
frame_stat->max_nalu_size_bytes = GetMaxNaluSizeBytes(encoded_image, config_);
|
2017-09-28 09:23:17 -07:00
|
|
|
|
2017-02-15 05:29:38 -08:00
|
|
|
// For the highest measurement accuracy of the decode time, the start/stop
|
|
|
|
|
// time recordings should wrap the Decode call as tightly as possible.
|
2017-09-06 01:53:22 -07:00
|
|
|
frame_stat->decode_start_ns = rtc::TimeNanos();
|
2017-03-07 01:41:43 -08:00
|
|
|
frame_stat->decode_return_code =
|
2018-01-22 15:49:55 +01:00
|
|
|
decoder_->Decode(encoded_image, false, nullptr);
|
2017-02-15 05:19:51 -08:00
|
|
|
|
2017-09-06 01:53:22 -07:00
|
|
|
if (encoded_frame_writer_) {
|
|
|
|
|
RTC_CHECK(encoded_frame_writer_->WriteFrame(encoded_image, codec));
|
|
|
|
|
}
|
2018-01-17 15:11:44 +01:00
|
|
|
|
|
|
|
|
++num_encoded_frames_;
|
2011-10-06 06:44:54 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-17 14:47:32 +01:00
|
|
|
void VideoProcessor::FrameDecoded(const VideoFrame& decoded_frame) {
|
2017-08-21 06:44:16 -07:00
|
|
|
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
|
|
|
|
|
|
2017-02-15 05:29:38 -08:00
|
|
|
// For the highest measurement accuracy of the decode time, the start/stop
|
|
|
|
|
// time recordings should wrap the Decode call as tightly as possible.
|
2016-05-10 16:31:47 +02:00
|
|
|
int64_t decode_stop_ns = rtc::TimeNanos();
|
2017-02-15 05:19:51 -08:00
|
|
|
|
2017-09-06 01:53:22 -07:00
|
|
|
// Update frame statistics.
|
2018-01-19 14:57:10 +01:00
|
|
|
FrameStatistic* frame_stat =
|
|
|
|
|
stats_->GetFrameWithTimestamp(decoded_frame.timestamp());
|
2017-11-17 14:47:32 +01:00
|
|
|
frame_stat->decoded_width = decoded_frame.width();
|
|
|
|
|
frame_stat->decoded_height = decoded_frame.height();
|
2017-09-06 01:53:22 -07:00
|
|
|
frame_stat->decode_time_us =
|
|
|
|
|
GetElapsedTimeMicroseconds(frame_stat->decode_start_ns, decode_stop_ns);
|
2017-03-07 01:41:43 -08:00
|
|
|
frame_stat->decoding_successful = true;
|
|
|
|
|
|
2017-11-17 14:47:32 +01:00
|
|
|
// Ensure strict monotonicity.
|
2018-01-19 14:57:10 +01:00
|
|
|
const size_t frame_number = frame_stat->frame_number;
|
2018-01-17 15:11:44 +01:00
|
|
|
if (num_decoded_frames_ > 0) {
|
|
|
|
|
RTC_CHECK_GT(frame_number, last_decoded_frame_num_);
|
|
|
|
|
}
|
2017-11-17 14:47:32 +01:00
|
|
|
|
2017-03-07 01:41:43 -08:00
|
|
|
// Check if the codecs have resized the frame since previously decoded frame.
|
|
|
|
|
if (frame_number > 0) {
|
2018-01-17 15:11:44 +01:00
|
|
|
if (decoded_frame_writer_ && num_decoded_frames_ > 0) {
|
2017-11-17 14:47:32 +01:00
|
|
|
// For dropped/lost frames, write out the last decoded frame to make it
|
|
|
|
|
// look like a freeze at playback.
|
2018-01-17 15:11:44 +01:00
|
|
|
const size_t num_dropped_frames =
|
|
|
|
|
frame_number - last_decoded_frame_num_ - 1;
|
|
|
|
|
for (size_t i = 0; i < num_dropped_frames; i++) {
|
2017-11-17 14:47:32 +01:00
|
|
|
WriteDecodedFrameToFile(&last_decoded_frame_buffer_);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-05 21:07:28 +00:00
|
|
|
}
|
2017-03-07 01:41:43 -08:00
|
|
|
last_decoded_frame_num_ = frame_number;
|
|
|
|
|
|
2017-11-17 14:47:32 +01:00
|
|
|
// Skip quality metrics calculation to not affect CPU usage.
|
|
|
|
|
if (!config_.measure_cpu) {
|
|
|
|
|
frame_stat->psnr =
|
|
|
|
|
I420PSNR(input_frames_[frame_number].get(), &decoded_frame);
|
|
|
|
|
frame_stat->ssim =
|
|
|
|
|
I420SSIM(input_frames_[frame_number].get(), &decoded_frame);
|
|
|
|
|
}
|
2012-10-24 18:33:04 +00:00
|
|
|
|
2017-11-17 14:47:32 +01:00
|
|
|
// Delay erasing of input frames by one frame. The current frame might
|
|
|
|
|
// still be needed for other simulcast stream or spatial layer.
|
2018-01-17 15:11:44 +01:00
|
|
|
if (frame_number > 0) {
|
|
|
|
|
auto input_frame_erase_to = input_frames_.lower_bound(frame_number - 1);
|
2017-11-17 14:47:32 +01:00
|
|
|
input_frames_.erase(input_frames_.begin(), input_frame_erase_to);
|
|
|
|
|
}
|
2017-10-24 16:03:39 +02:00
|
|
|
|
2017-03-07 01:41:43 -08:00
|
|
|
if (decoded_frame_writer_) {
|
2017-11-17 14:47:32 +01:00
|
|
|
ExtractBufferWithSize(decoded_frame, config_.codec_settings.width,
|
|
|
|
|
config_.codec_settings.height,
|
|
|
|
|
&last_decoded_frame_buffer_);
|
|
|
|
|
WriteDecodedFrameToFile(&last_decoded_frame_buffer_);
|
2011-10-06 06:44:54 +00:00
|
|
|
}
|
2018-01-17 15:11:44 +01:00
|
|
|
|
|
|
|
|
++num_decoded_frames_;
|
2017-10-24 16:03:39 +02:00
|
|
|
}
|
2017-03-07 01:41:43 -08:00
|
|
|
|
2017-11-17 14:47:32 +01:00
|
|
|
void VideoProcessor::WriteDecodedFrameToFile(rtc::Buffer* buffer) {
|
|
|
|
|
RTC_DCHECK_EQ(buffer->size(), decoded_frame_writer_->FrameLength());
|
|
|
|
|
RTC_CHECK(decoded_frame_writer_->WriteFrame(buffer->data()));
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-06 06:44:54 +00:00
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|