#include "test/video_codec_tester.h"
#include <algorithm>
#include <numeric>
#include <set>
#include <tuple>
#include <utility>
#include "absl/strings/match.h"
#include "api/array_view.h"
#include "api/environment/environment.h"
#include "api/environment/environment_factory.h"
#include "api/test/create_frame_generator.h"
#include "api/test/frame_generator_interface.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "api/video/builtin_video_bitrate_allocator_factory.h"
#include "api/video/i420_buffer.h"
#include "api/video/video_bitrate_allocator.h"
#include "api/video/video_codec_type.h"
#include "api/video/video_frame.h"
#include "api/video_codecs/h264_profile_level_id.h"
#include "api/video_codecs/simulcast_stream.h"
#include "api/video_codecs/video_decoder.h"
#include "api/video_codecs/video_encoder.h"
#include "media/base/media_constants.h"
#include "modules/video_coding/codecs/av1/av1_svc_config.h"
#include "modules/video_coding/codecs/h264/include/h264.h"
#include "modules/video_coding/codecs/vp9/svc_config.h"
#include "modules/video_coding/include/video_codec_interface.h"
#include "modules/video_coding/include/video_error_codes.h"
#include "modules/video_coding/svc/scalability_mode_util.h"
#include "modules/video_coding/utility/ivf_file_writer.h"
#include "rtc_base/event.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/task_queue_for_test.h"
#include "rtc_base/time_utils.h"
#include "system_wrappers/include/sleep.h"
#include "test/testsupport/file_utils.h"
#include "test/testsupport/frame_reader.h"
#include "test/testsupport/video_frame_writer.h"
#include "third_party/libyuv/include/libyuv/compare.h"
#include "video/config/encoder_stream_factory.h"
namespace webrtc {
namespace test {
namespace {
CodedVideoSource;
VideoSourceSettings;
EncodingSettings;
LayerSettings;
LayerId;
EncoderSettings;
DecoderSettings;
PacingSettings;
PacingMode;
VideoCodecStats;
DecodeCallback;
ImprovementDirection;
constexpr Frequency k90kHz = …;
const std::set<ScalabilityMode> kFullSvcScalabilityModes{ … };
const std::set<ScalabilityMode> kKeySvcScalabilityModes{ … };
rtc::scoped_refptr<VideoFrameBuffer> ScaleFrame(
rtc::scoped_refptr<VideoFrameBuffer> buffer,
int scaled_width,
int scaled_height) { … }
class VideoSource { … };
class Pacer { … };
class LimitedTaskQueue { … };
class TesterY4mWriter { … };
class TesterIvfWriter { … };
class LeakyBucket { … };
class VideoCodecAnalyzer : public VideoCodecTester::VideoCodecStats { … };
class Decoder : public DecodedImageCallback { … };
class Encoder : public EncodedImageCallback { … };
void ConfigureSimulcast(const FieldTrialsView& field_trials, VideoCodec* vc) { … }
void SetDefaultCodecSpecificSettings(VideoCodec* vc, int num_temporal_layers) { … }
std::tuple<std::vector<DataRate>, ScalabilityMode>
SplitBitrateAndUpdateScalabilityMode(const Environment& env,
std::string codec_type,
ScalabilityMode scalability_mode,
int width,
int height,
std::vector<DataRate> layer_bitrate,
Frequency framerate,
VideoCodecMode content_type) { … }
}
void VideoCodecStats::Stream::LogMetrics(
MetricsLogger* logger,
std::string test_case_name,
std::string prefix,
std::map<std::string, std::string> metadata) const { … }
EncodingSettings VideoCodecTester::CreateEncodingSettings(
const Environment& env,
std::string codec_type,
std::string scalability_name,
int width,
int height,
std::vector<DataRate> bitrate,
Frequency framerate,
bool screencast,
bool frame_drop) { … }
std::map<uint32_t, EncodingSettings> VideoCodecTester::CreateFrameSettings(
const EncodingSettings& encoding_settings,
int num_frames,
uint32_t timestamp_rtp) { … }
std::unique_ptr<VideoCodecTester::VideoCodecStats>
VideoCodecTester::RunDecodeTest(const Environment& env,
CodedVideoSource* video_source,
VideoDecoderFactory* decoder_factory,
const DecoderSettings& decoder_settings,
const SdpVideoFormat& sdp_video_format) { … }
std::unique_ptr<VideoCodecTester::VideoCodecStats>
VideoCodecTester::RunEncodeTest(
const Environment& env,
const VideoSourceSettings& source_settings,
VideoEncoderFactory* encoder_factory,
const EncoderSettings& encoder_settings,
const std::map<uint32_t, EncodingSettings>& encoding_settings) { … }
std::unique_ptr<VideoCodecTester::VideoCodecStats>
VideoCodecTester::RunEncodeDecodeTest(
const Environment& env,
const VideoSourceSettings& source_settings,
VideoEncoderFactory* encoder_factory,
VideoDecoderFactory* decoder_factory,
const EncoderSettings& encoder_settings,
const DecoderSettings& decoder_settings,
const std::map<uint32_t, EncodingSettings>& encoding_settings) { … }
}
}