Remove unused method PacketLossModeToStr.
Add method FrameType for frame to TestConfig. Bug: none Change-Id: Icfeb12fcb961559c9b36a3aedb081a840b9d8556 Reviewed-on: https://webrtc-review.googlesource.com/16120 Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Commit-Queue: Åsa Persson <asapersson@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20458}
This commit is contained in:
@ -10,9 +10,9 @@
|
||||
|
||||
#include "modules/video_coding/codecs/test/packet_manipulator.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/format_macros.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -23,10 +23,10 @@ PacketManipulatorImpl::PacketManipulatorImpl(PacketReader* packet_reader,
|
||||
bool verbose)
|
||||
: packet_reader_(packet_reader),
|
||||
config_(config),
|
||||
verbose_(verbose),
|
||||
active_burst_packets_(0),
|
||||
random_seed_(1),
|
||||
verbose_(verbose) {
|
||||
assert(packet_reader);
|
||||
random_seed_(1) {
|
||||
RTC_DCHECK(packet_reader);
|
||||
}
|
||||
|
||||
int PacketManipulatorImpl::ManipulatePackets(
|
||||
@ -41,7 +41,7 @@ int PacketManipulatorImpl::ManipulatePackets(
|
||||
packet_reader_->InitializeReading(encoded_image->_buffer,
|
||||
encoded_image->_length,
|
||||
config_.packet_size_in_bytes);
|
||||
uint8_t* packet = NULL;
|
||||
uint8_t* packet = nullptr;
|
||||
int nbr_bytes_to_read;
|
||||
// keep track of if we've lost any packets, since then we shall loose
|
||||
// the remains of the current frame:
|
||||
@ -91,17 +91,5 @@ inline double PacketManipulatorImpl::RandomUniform() {
|
||||
return (random_seed_ + 1.0) / (RAND_MAX + 1.0);
|
||||
}
|
||||
|
||||
const char* PacketLossModeToStr(PacketLossMode e) {
|
||||
switch (e) {
|
||||
case kUniform:
|
||||
return "Uniform";
|
||||
case kBurst:
|
||||
return "Burst";
|
||||
default:
|
||||
assert(false);
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
@ -24,13 +24,10 @@ namespace test {
|
||||
enum PacketLossMode {
|
||||
// Drops packets with a configured probability independently for each packet
|
||||
kUniform,
|
||||
// Drops packets similar to uniform but when a packet is being dropped,
|
||||
// the number of lost packets in a row is equal to the configured burst
|
||||
// length.
|
||||
// Drops packets similar to uniform but when a packet is being dropped, the
|
||||
// number of lost packets in a row is equal to the configured burst length.
|
||||
kBurst
|
||||
};
|
||||
// Returns a string representation of the enum value.
|
||||
const char* PacketLossModeToStr(PacketLossMode e);
|
||||
|
||||
// Contains configurations related to networking and simulation of
|
||||
// scenarios caused by network interference.
|
||||
@ -100,13 +97,13 @@ class PacketManipulatorImpl : public PacketManipulator {
|
||||
virtual double RandomUniform();
|
||||
|
||||
private:
|
||||
PacketReader* packet_reader_;
|
||||
PacketReader* const packet_reader_;
|
||||
const NetworkingConfig& config_;
|
||||
const bool verbose_;
|
||||
// Used to simulate a burst over several frames.
|
||||
int active_burst_packets_;
|
||||
rtc::CriticalSection critsect_;
|
||||
unsigned int random_seed_;
|
||||
bool verbose_;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
|
@ -153,6 +153,13 @@ int TestConfig::TemporalLayerForFrame(int frame_idx) const {
|
||||
return tl;
|
||||
}
|
||||
|
||||
std::vector<FrameType> TestConfig::FrameTypeForFrame(int frame_idx) const {
|
||||
if (keyframe_interval > 0 && (frame_idx % keyframe_interval == 0)) {
|
||||
return {kVideoFrameKey};
|
||||
}
|
||||
return {kVideoFrameDelta};
|
||||
}
|
||||
|
||||
std::string TestConfig::ToString() const {
|
||||
std::stringstream ss;
|
||||
ss << "Video config:";
|
||||
|
@ -12,6 +12,7 @@
|
||||
#define MODULES_VIDEO_CODING_CODECS_TEST_TEST_CONFIG_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
|
||||
@ -53,6 +54,7 @@ struct TestConfig {
|
||||
int NumberOfCores() const;
|
||||
int NumberOfTemporalLayers() const;
|
||||
int TemporalLayerForFrame(int frame_idx) const;
|
||||
std::vector<FrameType> FrameTypeForFrame(int frame_idx) const;
|
||||
std::string ToString() const;
|
||||
|
||||
// Plain name of YUV file to process without file extension.
|
||||
|
@ -9,9 +9,12 @@
|
||||
*/
|
||||
|
||||
#include "modules/video_coding/codecs/test/test_config.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/video_codec_settings.h"
|
||||
|
||||
using ::testing::ElementsAre;
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
@ -84,6 +87,25 @@ TEST(TestConfig, TemporalLayersForFrame_ThreeLayers) {
|
||||
EXPECT_EQ(2, config.TemporalLayerForFrame(7));
|
||||
}
|
||||
|
||||
TEST(TestConfig, ForcedKeyFrameIntervalOff) {
|
||||
TestConfig config;
|
||||
config.keyframe_interval = 0;
|
||||
EXPECT_THAT(config.FrameTypeForFrame(0), ElementsAre(kVideoFrameDelta));
|
||||
EXPECT_THAT(config.FrameTypeForFrame(1), ElementsAre(kVideoFrameDelta));
|
||||
EXPECT_THAT(config.FrameTypeForFrame(2), ElementsAre(kVideoFrameDelta));
|
||||
}
|
||||
|
||||
TEST(TestConfig, ForcedKeyFrameIntervalOn) {
|
||||
TestConfig config;
|
||||
config.keyframe_interval = 3;
|
||||
EXPECT_THAT(config.FrameTypeForFrame(0), ElementsAre(kVideoFrameKey));
|
||||
EXPECT_THAT(config.FrameTypeForFrame(1), ElementsAre(kVideoFrameDelta));
|
||||
EXPECT_THAT(config.FrameTypeForFrame(2), ElementsAre(kVideoFrameDelta));
|
||||
EXPECT_THAT(config.FrameTypeForFrame(3), ElementsAre(kVideoFrameKey));
|
||||
EXPECT_THAT(config.FrameTypeForFrame(4), ElementsAre(kVideoFrameDelta));
|
||||
EXPECT_THAT(config.FrameTypeForFrame(5), ElementsAre(kVideoFrameDelta));
|
||||
}
|
||||
|
||||
TEST(TestConfig, ToString_Vp8) {
|
||||
TestConfig config;
|
||||
config.filename = "yuvfile";
|
||||
|
@ -30,6 +30,7 @@ namespace test {
|
||||
namespace {
|
||||
|
||||
const int kRtpClockRateHz = 90000;
|
||||
const int64_t kNoRenderTime = 0;
|
||||
|
||||
std::unique_ptr<VideoBitrateAllocator> CreateBitrateAllocator(
|
||||
TestConfig* config) {
|
||||
@ -170,16 +171,11 @@ void VideoProcessor::ProcessFrame() {
|
||||
kRtpClockRateHz /
|
||||
config_.codec_settings.maxFramerate;
|
||||
rtp_timestamp_to_frame_num_[rtp_timestamp] = last_inputed_frame_num_;
|
||||
const int64_t kNoRenderTime = 0;
|
||||
VideoFrame source_frame(buffer, rtp_timestamp, kNoRenderTime,
|
||||
webrtc::kVideoRotation_0);
|
||||
|
||||
// Decide if we are going to force a keyframe.
|
||||
std::vector<FrameType> frame_types(1, kVideoFrameDelta);
|
||||
if (config_.keyframe_interval > 0 &&
|
||||
last_inputed_frame_num_ % config_.keyframe_interval == 0) {
|
||||
frame_types[0] = kVideoFrameKey;
|
||||
}
|
||||
std::vector<FrameType> frame_types =
|
||||
config_.FrameTypeForFrame(last_inputed_frame_num_);
|
||||
|
||||
// Create frame statistics object used for aggregation at end of test run.
|
||||
FrameStatistic* frame_stat = stats_->AddFrame();
|
||||
@ -321,10 +317,8 @@ void VideoProcessor::FrameDecoded(const VideoFrame& image) {
|
||||
RTC_CHECK_GE(last_decoded_frame_num_, 0);
|
||||
const FrameStatistic* last_decoded_frame_stat =
|
||||
stats_->GetFrame(last_decoded_frame_num_);
|
||||
if (static_cast<int>(image.width()) !=
|
||||
last_decoded_frame_stat->decoded_width ||
|
||||
static_cast<int>(image.height()) !=
|
||||
last_decoded_frame_stat->decoded_height) {
|
||||
if (image.width() != last_decoded_frame_stat->decoded_width ||
|
||||
image.height() != last_decoded_frame_stat->decoded_height) {
|
||||
RTC_CHECK_GE(rate_update_index_, 0);
|
||||
++num_spatial_resizes_[rate_update_index_];
|
||||
}
|
||||
|
Reference in New Issue
Block a user