Assign spatial_idx in FrameStatistics ctor.

- Add spatial_idx to FrameStatistics ctor.
- Pass FrameStatistics object to AddFrame.

Bug: none
Change-Id: I9d6de449b45a007438f6fd3317176bf45fb23806
Reviewed-on: https://webrtc-review.googlesource.com/101781
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24856}
This commit is contained in:
Sergey Silkin
2018-09-25 13:48:19 +02:00
committed by Commit Bot
parent d8f3c17e8d
commit 02fed02c00
6 changed files with 24 additions and 27 deletions

View File

@ -31,14 +31,13 @@ const int kMaxBitrateMismatchPercent = 20;
VideoCodecTestStatsImpl::VideoCodecTestStatsImpl() = default;
VideoCodecTestStatsImpl::~VideoCodecTestStatsImpl() = default;
FrameStatistics* VideoCodecTestStatsImpl::AddFrame(size_t timestamp,
size_t layer_idx) {
void VideoCodecTestStatsImpl::AddFrame(const FrameStatistics& frame_stat) {
const size_t timestamp = frame_stat.rtp_timestamp;
const size_t layer_idx = frame_stat.spatial_idx;
RTC_DCHECK(rtp_timestamp_to_frame_num_[layer_idx].find(timestamp) ==
rtp_timestamp_to_frame_num_[layer_idx].end());
const size_t frame_num = layer_stats_[layer_idx].size();
rtp_timestamp_to_frame_num_[layer_idx][timestamp] = frame_num;
layer_stats_[layer_idx].emplace_back(frame_num, timestamp);
return &layer_stats_[layer_idx].back();
rtp_timestamp_to_frame_num_[layer_idx][timestamp] = frame_stat.frame_number;
layer_stats_[layer_idx].push_back(frame_stat);
}
FrameStatistics* VideoCodecTestStatsImpl::GetFrame(size_t frame_num,
@ -188,7 +187,7 @@ VideoStatistics VideoCodecTestStatsImpl::SliceAndCalcVideoStatistic(
size_t rtp_timestamp_first_frame = 0;
size_t rtp_timestamp_prev_frame = 0;
FrameStatistics last_successfully_decoded_frame(0, 0);
FrameStatistics last_successfully_decoded_frame(0, 0, 0);
const size_t target_bitrate_kbps =
CalcLayerTargetBitrateKbps(first_frame_num, last_frame_num, spatial_idx,

View File

@ -28,7 +28,7 @@ class VideoCodecTestStatsImpl : public VideoCodecTestStats {
~VideoCodecTestStatsImpl() override;
// Creates a FrameStatistics for the next frame to be processed.
FrameStatistics* AddFrame(size_t timestamp, size_t spatial_idx) override;
void AddFrame(const FrameStatistics& frame_stat) override;
// Returns the FrameStatistics corresponding to |frame_number| or |timestamp|.
FrameStatistics* GetFrame(size_t frame_number, size_t spatial_idx) override;

View File

@ -19,27 +19,20 @@ namespace {
const size_t kTimestamp = 12345;
} // namespace
TEST(StatsTest, AddFrame) {
TEST(StatsTest, AddAndGetFrame) {
VideoCodecTestStatsImpl stats;
FrameStatistics* frame_stat = stats.AddFrame(kTimestamp, 0);
EXPECT_EQ(0ull, frame_stat->frame_number);
EXPECT_EQ(kTimestamp, frame_stat->rtp_timestamp);
EXPECT_EQ(1u, stats.Size(0));
}
TEST(StatsTest, GetFrame) {
VideoCodecTestStatsImpl stats;
stats.AddFrame(kTimestamp, 0);
stats.AddFrame(FrameStatistics(0, kTimestamp, 0));
FrameStatistics* frame_stat = stats.GetFrame(0u, 0);
EXPECT_EQ(0u, frame_stat->frame_number);
EXPECT_EQ(kTimestamp, frame_stat->rtp_timestamp);
}
TEST(StatsTest, AddFrames) {
TEST(StatsTest, AddAndGetFrames) {
VideoCodecTestStatsImpl stats;
const size_t kNumFrames = 1000;
for (size_t i = 0; i < kNumFrames; ++i) {
FrameStatistics* frame_stat = stats.AddFrame(kTimestamp + i, 0);
stats.AddFrame(FrameStatistics(i, kTimestamp + i, 0));
FrameStatistics* frame_stat = stats.GetFrame(i, 0);
EXPECT_EQ(i, frame_stat->frame_number);
EXPECT_EQ(kTimestamp + i, frame_stat->rtp_timestamp);
}
@ -54,7 +47,7 @@ TEST(StatsTest, AddFrames) {
TEST(StatsTest, AddFrameLayering) {
VideoCodecTestStatsImpl stats;
for (size_t i = 0; i < 3; ++i) {
stats.AddFrame(kTimestamp + i, i);
stats.AddFrame(FrameStatistics(0, kTimestamp + i, i));
FrameStatistics* frame_stat = stats.GetFrame(0u, i);
EXPECT_EQ(0u, frame_stat->frame_number);
EXPECT_EQ(kTimestamp, frame_stat->rtp_timestamp - i);

View File

@ -275,7 +275,8 @@ void VideoProcessor::ProcessFrame() {
// Create frame statistics object for all simulcast/spatial layers.
for (size_t i = 0; i < num_simulcast_or_spatial_layers_; ++i) {
stats_->AddFrame(timestamp, i);
FrameStatistics frame_stat(frame_number, timestamp, i);
stats_->AddFrame(frame_stat);
}
// For the highest measurement accuracy of the encode time, the start/stop
@ -377,7 +378,6 @@ void VideoProcessor::FrameEncoded(
frame_stat->length_bytes = encoded_image._length;
frame_stat->frame_type = encoded_image._frameType;
frame_stat->temporal_idx = temporal_idx;
frame_stat->spatial_idx = spatial_idx;
frame_stat->max_nalu_size_bytes = GetMaxNaluSizeBytes(encoded_image, config_);
frame_stat->qp = encoded_image.qp_;