Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

378 lines
15 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include "modules/video_coding/codecs/test/videoprocessor.h"
#include <algorithm>
#include <limits>
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
#include <utility>
#include "api/video/i420_buffer.h"
#include "common_types.h" // NOLINT(build/include)
#include "common_video/h264/h264_common.h"
#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"
namespace webrtc {
namespace test {
Reland of Add optional visualization file writers to VideoProcessor tests. (patchset #1 id:1 of https://codereview.webrtc.org/2708103002/ ) Reason for revert: Necessary calls were "protected" by RTC_DCHECKs, that were optimized away in some release builds. Replacing the RTC_DCHECKs with EXPECTs. Original issue's description: > Revert of Add optional visualization file writers to VideoProcessor tests. (patchset #4 id:220001 of https://codereview.webrtc.org/2700493006/ ) > > Reason for revert: > Breaks downstream project. > > Original issue's description: > > Add optional visualization file writers to VideoProcessor tests. > > > > The purpose of this visualization CL is to add the ability to record > > video at the source, after encode, and after decode, in the VideoProcessor > > tests. These output files can then be replayed and used as a subjective > > complement to the objective metric plots given by the existing Python > > plotting script. > > > > BUG=webrtc:6634 > > > > Review-Url: https://codereview.webrtc.org/2700493006 > > Cr-Commit-Position: refs/heads/master@{#16738} > > Committed: https://chromium.googlesource.com/external/webrtc/+/872104ac41d7764f8676c9ea55555210bea4605c > > TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6634 > > Review-Url: https://codereview.webrtc.org/2708103002 > Cr-Commit-Position: refs/heads/master@{#16745} > Committed: https://chromium.googlesource.com/external/webrtc/+/2a8135a1741761bd6de52163c0dc35f6eff7c8eb TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true BUG=webrtc:6634 Review-Url: https://codereview.webrtc.org/2706123003 Cr-Commit-Position: refs/heads/master@{#16769}
2017-02-22 01:26:59 -08:00
namespace {
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
const int kRtpClockRateHz = 90000;
std::unique_ptr<VideoBitrateAllocator> CreateBitrateAllocator(
TestConfig* config) {
std::unique_ptr<TemporalLayersFactory> tl_factory;
if (config->codec_settings.codecType == VideoCodecType::kVideoCodecVP8) {
tl_factory.reset(new TemporalLayersFactory());
config->codec_settings.VP8()->tl_factory = tl_factory.get();
}
return std::unique_ptr<VideoBitrateAllocator>(
VideoCodecInitializer::CreateBitrateAllocator(config->codec_settings,
std::move(tl_factory)));
}
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
rtc::Optional<size_t> GetMaxNaluLength(const EncodedImage& encoded_frame,
const TestConfig& config) {
if (config.codec_settings.codecType != kVideoCodecH264)
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
return rtc::nullopt;
std::vector<webrtc::H264::NaluIndex> nalu_indices =
webrtc::H264::FindNaluIndices(encoded_frame._buffer,
encoded_frame._length);
RTC_CHECK(!nalu_indices.empty());
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
size_t max_length = 0;
for (const webrtc::H264::NaluIndex& index : nalu_indices)
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
max_length = std::max(max_length, index.payload_size);
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
return max_length;
}
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);
}
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);
}
Reland of Add optional visualization file writers to VideoProcessor tests. (patchset #1 id:1 of https://codereview.webrtc.org/2708103002/ ) Reason for revert: Necessary calls were "protected" by RTC_DCHECKs, that were optimized away in some release builds. Replacing the RTC_DCHECKs with EXPECTs. Original issue's description: > Revert of Add optional visualization file writers to VideoProcessor tests. (patchset #4 id:220001 of https://codereview.webrtc.org/2700493006/ ) > > Reason for revert: > Breaks downstream project. > > Original issue's description: > > Add optional visualization file writers to VideoProcessor tests. > > > > The purpose of this visualization CL is to add the ability to record > > video at the source, after encode, and after decode, in the VideoProcessor > > tests. These output files can then be replayed and used as a subjective > > complement to the objective metric plots given by the existing Python > > plotting script. > > > > BUG=webrtc:6634 > > > > Review-Url: https://codereview.webrtc.org/2700493006 > > Cr-Commit-Position: refs/heads/master@{#16738} > > Committed: https://chromium.googlesource.com/external/webrtc/+/872104ac41d7764f8676c9ea55555210bea4605c > > TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6634 > > Review-Url: https://codereview.webrtc.org/2708103002 > Cr-Commit-Position: refs/heads/master@{#16745} > Committed: https://chromium.googlesource.com/external/webrtc/+/2a8135a1741761bd6de52163c0dc35f6eff7c8eb TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true BUG=webrtc:6634 Review-Url: https://codereview.webrtc.org/2706123003 Cr-Commit-Position: refs/heads/master@{#16769}
2017-02-22 01:26:59 -08:00
} // namespace
VideoProcessor::VideoProcessor(webrtc::VideoEncoder* encoder,
webrtc::VideoDecoder* decoder,
FrameReader* analysis_frame_reader,
PacketManipulator* packet_manipulator,
const TestConfig& config,
Stats* stats,
IvfFileWriter* encoded_frame_writer,
FrameWriter* decoded_frame_writer)
: config_(config),
encoder_(encoder),
decoder_(decoder),
bitrate_allocator_(CreateBitrateAllocator(&config_)),
encode_callback_(this),
decode_callback_(this),
packet_manipulator_(packet_manipulator),
analysis_frame_reader_(analysis_frame_reader),
Reland of Add optional visualization file writers to VideoProcessor tests. (patchset #1 id:1 of https://codereview.webrtc.org/2708103002/ ) Reason for revert: Necessary calls were "protected" by RTC_DCHECKs, that were optimized away in some release builds. Replacing the RTC_DCHECKs with EXPECTs. Original issue's description: > Revert of Add optional visualization file writers to VideoProcessor tests. (patchset #4 id:220001 of https://codereview.webrtc.org/2700493006/ ) > > Reason for revert: > Breaks downstream project. > > Original issue's description: > > Add optional visualization file writers to VideoProcessor tests. > > > > The purpose of this visualization CL is to add the ability to record > > video at the source, after encode, and after decode, in the VideoProcessor > > tests. These output files can then be replayed and used as a subjective > > complement to the objective metric plots given by the existing Python > > plotting script. > > > > BUG=webrtc:6634 > > > > Review-Url: https://codereview.webrtc.org/2700493006 > > Cr-Commit-Position: refs/heads/master@{#16738} > > Committed: https://chromium.googlesource.com/external/webrtc/+/872104ac41d7764f8676c9ea55555210bea4605c > > TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6634 > > Review-Url: https://codereview.webrtc.org/2708103002 > Cr-Commit-Position: refs/heads/master@{#16745} > Committed: https://chromium.googlesource.com/external/webrtc/+/2a8135a1741761bd6de52163c0dc35f6eff7c8eb TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true BUG=webrtc:6634 Review-Url: https://codereview.webrtc.org/2706123003 Cr-Commit-Position: refs/heads/master@{#16769}
2017-02-22 01:26:59 -08:00
encoded_frame_writer_(encoded_frame_writer),
decoded_frame_writer_(decoded_frame_writer),
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
last_inputed_frame_num_(-1),
last_encoded_frame_num_(-1),
last_decoded_frame_num_(-1),
first_key_frame_has_been_excluded_(false),
last_decoded_frame_buffer_(analysis_frame_reader->FrameLength()),
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
stats_(stats),
rate_update_index_(-1) {
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
RTC_DCHECK(encoder);
RTC_DCHECK(decoder);
RTC_DCHECK(packet_manipulator);
Reland of Add optional visualization file writers to VideoProcessor tests. (patchset #1 id:1 of https://codereview.webrtc.org/2708103002/ ) Reason for revert: Necessary calls were "protected" by RTC_DCHECKs, that were optimized away in some release builds. Replacing the RTC_DCHECKs with EXPECTs. Original issue's description: > Revert of Add optional visualization file writers to VideoProcessor tests. (patchset #4 id:220001 of https://codereview.webrtc.org/2700493006/ ) > > Reason for revert: > Breaks downstream project. > > Original issue's description: > > Add optional visualization file writers to VideoProcessor tests. > > > > The purpose of this visualization CL is to add the ability to record > > video at the source, after encode, and after decode, in the VideoProcessor > > tests. These output files can then be replayed and used as a subjective > > complement to the objective metric plots given by the existing Python > > plotting script. > > > > BUG=webrtc:6634 > > > > Review-Url: https://codereview.webrtc.org/2700493006 > > Cr-Commit-Position: refs/heads/master@{#16738} > > Committed: https://chromium.googlesource.com/external/webrtc/+/872104ac41d7764f8676c9ea55555210bea4605c > > TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6634 > > Review-Url: https://codereview.webrtc.org/2708103002 > Cr-Commit-Position: refs/heads/master@{#16745} > Committed: https://chromium.googlesource.com/external/webrtc/+/2a8135a1741761bd6de52163c0dc35f6eff7c8eb TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true BUG=webrtc:6634 Review-Url: https://codereview.webrtc.org/2706123003 Cr-Commit-Position: refs/heads/master@{#16769}
2017-02-22 01:26:59 -08:00
RTC_DCHECK(analysis_frame_reader);
Reland #2 of Issue 2434073003: Extract bitrate allocation ... This is yet another reland of https://codereview.webrtc.org/2434073003/ including two fixes: 1. SimulcastRateAllocator did not handle the screenshare settings properly for numSimulcastStreams = 1. Additional test case was added for that. 2. In VideoSender, when rate allocation is updated after setting a new VideoCodec config, only update the state of the EncoderParameters, but don't actually run SetRateAllocation on the encoder itself. This caused some problems upstreams. Please review only the changes after patch set 1. Original description: Extract bitrate allocation of spatial/temporal layers out of codec impl. This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2510583002 . Cr-Commit-Position: refs/heads/master@{#15105}
2016-11-16 16:41:30 +01:00
RTC_DCHECK(stats);
// Setup required callbacks for the encoder and decoder.
RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(&encode_callback_),
WEBRTC_VIDEO_CODEC_OK);
RTC_CHECK_EQ(decoder_->RegisterDecodeCompleteCallback(&decode_callback_),
WEBRTC_VIDEO_CODEC_OK);
// Initialize the encoder and decoder.
RTC_CHECK_EQ(
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
encoder_->InitEncode(&config_.codec_settings, config_.NumberOfCores(),
config_.networking_config.max_payload_size_in_bytes),
WEBRTC_VIDEO_CODEC_OK);
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
RTC_CHECK_EQ(
decoder_->InitDecode(&config_.codec_settings, config_.NumberOfCores()),
WEBRTC_VIDEO_CODEC_OK);
}
VideoProcessor::~VideoProcessor() {
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
RTC_CHECK_EQ(encoder_->Release(), WEBRTC_VIDEO_CODEC_OK);
RTC_CHECK_EQ(decoder_->Release(), WEBRTC_VIDEO_CODEC_OK);
encoder_->RegisterEncodeCompleteCallback(nullptr);
decoder_->RegisterDecodeCompleteCallback(nullptr);
}
void VideoProcessor::ProcessFrame() {
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
const int frame_number = ++last_inputed_frame_num_;
// Get frame from file.
rtc::scoped_refptr<I420BufferInterface> buffer(
Reland of Add optional visualization file writers to VideoProcessor tests. (patchset #1 id:1 of https://codereview.webrtc.org/2708103002/ ) Reason for revert: Necessary calls were "protected" by RTC_DCHECKs, that were optimized away in some release builds. Replacing the RTC_DCHECKs with EXPECTs. Original issue's description: > Revert of Add optional visualization file writers to VideoProcessor tests. (patchset #4 id:220001 of https://codereview.webrtc.org/2700493006/ ) > > Reason for revert: > Breaks downstream project. > > Original issue's description: > > Add optional visualization file writers to VideoProcessor tests. > > > > The purpose of this visualization CL is to add the ability to record > > video at the source, after encode, and after decode, in the VideoProcessor > > tests. These output files can then be replayed and used as a subjective > > complement to the objective metric plots given by the existing Python > > plotting script. > > > > BUG=webrtc:6634 > > > > Review-Url: https://codereview.webrtc.org/2700493006 > > Cr-Commit-Position: refs/heads/master@{#16738} > > Committed: https://chromium.googlesource.com/external/webrtc/+/872104ac41d7764f8676c9ea55555210bea4605c > > TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6634 > > Review-Url: https://codereview.webrtc.org/2708103002 > Cr-Commit-Position: refs/heads/master@{#16745} > Committed: https://chromium.googlesource.com/external/webrtc/+/2a8135a1741761bd6de52163c0dc35f6eff7c8eb TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true BUG=webrtc:6634 Review-Url: https://codereview.webrtc.org/2706123003 Cr-Commit-Position: refs/heads/master@{#16769}
2017-02-22 01:26:59 -08:00
analysis_frame_reader_->ReadFrame());
RTC_CHECK(buffer) << "Tried to read too many frames from the file.";
// 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.
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
const uint32_t rtp_timestamp = (frame_number + 1) * kRtpClockRateHz /
config_.codec_settings.maxFramerate;
const int64_t render_time_ms = (frame_number + 1) * rtc::kNumMillisecsPerSec /
config_.codec_settings.maxFramerate;
rtp_timestamp_to_frame_num_[rtp_timestamp] = frame_number;
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
input_frames_[frame_number] = rtc::MakeUnique<VideoFrame>(
buffer, rtp_timestamp, render_time_ms, webrtc::kVideoRotation_0);
std::vector<FrameType> frame_types = config_.FrameTypeForFrame(frame_number);
// Create frame statistics object used for aggregation at end of test run.
FrameStatistic* frame_stat = stats_->AddFrame();
// For the highest measurement accuracy of the encode time, the start/stop
// time recordings should wrap the Encode call as tightly as possible.
frame_stat->encode_start_ns = rtc::TimeNanos();
frame_stat->encode_return_code =
encoder_->Encode(*input_frames_[frame_number], nullptr, &frame_types);
}
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
void VideoProcessor::SetRates(int bitrate_kbps, int framerate_fps) {
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
config_.codec_settings.maxFramerate = framerate_fps;
int set_rates_result = encoder_->SetRateAllocation(
bitrate_allocator_->GetAllocation(bitrate_kbps * 1000, framerate_fps),
framerate_fps);
RTC_DCHECK_GE(set_rates_result, 0)
<< "Failed to update encoder with new rate " << bitrate_kbps << ".";
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
++rate_update_index_;
num_dropped_frames_.push_back(0);
num_spatial_resizes_.push_back(0);
}
std::vector<int> VideoProcessor::NumberDroppedFramesPerRateUpdate() const {
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
return num_dropped_frames_;
}
std::vector<int> VideoProcessor::NumberSpatialResizesPerRateUpdate() const {
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
return num_spatial_resizes_;
}
void VideoProcessor::FrameEncoded(webrtc::VideoCodecType codec,
const EncodedImage& encoded_image) {
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
// 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();
if (config_.encoded_frame_checker) {
config_.encoded_frame_checker->CheckEncodedFrame(codec, encoded_image);
}
Reland of Add optional visualization file writers to VideoProcessor tests. (patchset #1 id:1 of https://codereview.webrtc.org/2708103002/ ) Reason for revert: Necessary calls were "protected" by RTC_DCHECKs, that were optimized away in some release builds. Replacing the RTC_DCHECKs with EXPECTs. Original issue's description: > Revert of Add optional visualization file writers to VideoProcessor tests. (patchset #4 id:220001 of https://codereview.webrtc.org/2700493006/ ) > > Reason for revert: > Breaks downstream project. > > Original issue's description: > > Add optional visualization file writers to VideoProcessor tests. > > > > The purpose of this visualization CL is to add the ability to record > > video at the source, after encode, and after decode, in the VideoProcessor > > tests. These output files can then be replayed and used as a subjective > > complement to the objective metric plots given by the existing Python > > plotting script. > > > > BUG=webrtc:6634 > > > > Review-Url: https://codereview.webrtc.org/2700493006 > > Cr-Commit-Position: refs/heads/master@{#16738} > > Committed: https://chromium.googlesource.com/external/webrtc/+/872104ac41d7764f8676c9ea55555210bea4605c > > TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6634 > > Review-Url: https://codereview.webrtc.org/2708103002 > Cr-Commit-Position: refs/heads/master@{#16745} > Committed: https://chromium.googlesource.com/external/webrtc/+/2a8135a1741761bd6de52163c0dc35f6eff7c8eb TBR=asapersson@webrtc.org,sprang@webrtc.org,kjellander@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true BUG=webrtc:6634 Review-Url: https://codereview.webrtc.org/2706123003 Cr-Commit-Position: refs/heads/master@{#16769}
2017-02-22 01:26:59 -08:00
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
const int frame_number =
rtp_timestamp_to_frame_num_[encoded_image._timeStamp];
// Ensure strict monotonicity.
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
RTC_CHECK_GT(frame_number, last_encoded_frame_num_);
// Check for dropped frames.
bool last_frame_missing = false;
if (frame_number > 0) {
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
int num_dropped_from_last_encode =
frame_number - last_encoded_frame_num_ - 1;
RTC_DCHECK_GE(num_dropped_from_last_encode, 0);
RTC_CHECK_GE(rate_update_index_, 0);
num_dropped_frames_[rate_update_index_] += num_dropped_from_last_encode;
const FrameStatistic* last_encoded_frame_stat =
stats_->GetFrame(last_encoded_frame_num_);
last_frame_missing = (last_encoded_frame_stat->manipulated_length == 0);
}
last_encoded_frame_num_ = frame_number;
// Update frame statistics.
FrameStatistic* frame_stat = stats_->GetFrame(frame_number);
frame_stat->encode_time_us =
GetElapsedTimeMicroseconds(frame_stat->encode_start_ns, encode_stop_ns);
frame_stat->encoding_successful = true;
frame_stat->encoded_frame_size_bytes = encoded_image._length;
frame_stat->frame_type = encoded_image._frameType;
frame_stat->qp = encoded_image.qp_;
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
frame_stat->bitrate_kbps = static_cast<int>(
encoded_image._length * config_.codec_settings.maxFramerate * 8 / 1000);
frame_stat->total_packets =
encoded_image._length / config_.networking_config.packet_size_in_bytes +
1;
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
frame_stat->max_nalu_length = GetMaxNaluLength(encoded_image, config_);
// Make a raw copy of |encoded_image| to feed to the decoder.
size_t copied_buffer_size = encoded_image._length +
EncodedImage::GetBufferPaddingBytes(codec);
std::unique_ptr<uint8_t[]> copied_buffer(new uint8_t[copied_buffer_size]);
memcpy(copied_buffer.get(), encoded_image._buffer, encoded_image._length);
EncodedImage copied_image = encoded_image;
copied_image._size = copied_buffer_size;
copied_image._buffer = copied_buffer.get();
// Simulate packet loss.
if (!ExcludeFrame(copied_image)) {
frame_stat->packets_dropped =
packet_manipulator_->ManipulatePackets(&copied_image);
}
frame_stat->manipulated_length = copied_image._length;
// For the highest measurement accuracy of the decode time, the start/stop
// time recordings should wrap the Decode call as tightly as possible.
frame_stat->decode_start_ns = rtc::TimeNanos();
frame_stat->decode_return_code =
decoder_->Decode(copied_image, last_frame_missing, nullptr);
if (encoded_frame_writer_) {
RTC_CHECK(encoded_frame_writer_->WriteFrame(encoded_image, codec));
}
}
void VideoProcessor::FrameDecoded(const VideoFrame& decoded_frame) {
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
// For the highest measurement accuracy of the decode time, the start/stop
// time recordings should wrap the Decode call as tightly as possible.
int64_t decode_stop_ns = rtc::TimeNanos();
// Update frame statistics.
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
const int frame_number =
rtp_timestamp_to_frame_num_[decoded_frame.timestamp()];
FrameStatistic* frame_stat = stats_->GetFrame(frame_number);
frame_stat->decoded_width = decoded_frame.width();
frame_stat->decoded_height = decoded_frame.height();
frame_stat->decode_time_us =
GetElapsedTimeMicroseconds(frame_stat->decode_start_ns, decode_stop_ns);
frame_stat->decoding_successful = true;
// Ensure strict monotonicity.
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
RTC_CHECK_GT(frame_number, last_decoded_frame_num_);
// Check if the codecs have resized the frame since previously decoded frame.
if (frame_number > 0) {
if (decoded_frame_writer_ && last_decoded_frame_num_ >= 0) {
// For dropped/lost frames, write out the last decoded frame to make it
// look like a freeze at playback.
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
const int num_dropped_frames = frame_number - last_decoded_frame_num_;
for (int i = 0; i < num_dropped_frames; i++) {
WriteDecodedFrameToFile(&last_decoded_frame_buffer_);
}
}
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
// TODO(ssilkin): move to FrameEncoded when webm:1474 is implemented.
const FrameStatistic* last_decoded_frame_stat =
stats_->GetFrame(last_decoded_frame_num_);
if (decoded_frame.width() != last_decoded_frame_stat->decoded_width ||
decoded_frame.height() != last_decoded_frame_stat->decoded_height) {
RTC_CHECK_GE(rate_update_index_, 0);
++num_spatial_resizes_[rate_update_index_];
}
}
last_decoded_frame_num_ = frame_number;
// 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);
}
// Delay erasing of input frames by one frame. The current frame might
// still be needed for other simulcast stream or spatial layer.
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
const int frame_number_to_erase = frame_number - 1;
if (frame_number_to_erase >= 0) {
auto input_frame_erase_to =
input_frames_.lower_bound(frame_number_to_erase);
input_frames_.erase(input_frames_.begin(), input_frame_erase_to);
}
if (decoded_frame_writer_) {
ExtractBufferWithSize(decoded_frame, config_.codec_settings.width,
config_.codec_settings.height,
&last_decoded_frame_buffer_);
WriteDecodedFrameToFile(&last_decoded_frame_buffer_);
}
}
void VideoProcessor::WriteDecodedFrameToFile(rtc::Buffer* buffer) {
RTC_DCHECK_EQ(buffer->size(), decoded_frame_writer_->FrameLength());
RTC_CHECK(decoded_frame_writer_->WriteFrame(buffer->data()));
}
bool VideoProcessor::ExcludeFrame(const EncodedImage& encoded_image) {
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
if (encoded_image._frameType != kVideoFrameKey) {
return false;
}
bool exclude_frame = false;
switch (config_.exclude_frame_types) {
case kExcludeOnlyFirstKeyFrame:
if (!first_key_frame_has_been_excluded_) {
first_key_frame_has_been_excluded_ = true;
exclude_frame = true;
}
break;
case kExcludeAllKeyFrames:
exclude_frame = true;
break;
default:
RTC_NOTREACHED();
}
return exclude_frame;
}
} // namespace test
} // namespace webrtc