kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 1 | /* |
marpan@webrtc.org | f4c2de9 | 2012-06-05 21:07:28 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
kjellander@webrtc.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |
| 12 | #define MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 13 | |
brandtr | b57f426 | 2017-08-30 06:29:51 -0700 | [diff] [blame] | 14 | #include <map> |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 15 | #include <memory> |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 16 | #include <string> |
brandtr | 17b958c | 2017-03-07 01:41:43 -0800 | [diff] [blame] | 17 | #include <vector> |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 18 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "api/video/video_frame.h" |
| 20 | #include "common_video/libyuv/include/webrtc_libyuv.h" |
ssilkin | 612f858 | 2017-09-28 09:23:17 -0700 | [diff] [blame] | 21 | #include "modules/video_coding/codecs/h264/include/h264_globals.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "modules/video_coding/codecs/test/packet_manipulator.h" |
| 23 | #include "modules/video_coding/codecs/test/stats.h" |
| 24 | #include "modules/video_coding/include/video_codec_interface.h" |
| 25 | #include "modules/video_coding/utility/ivf_file_writer.h" |
| 26 | #include "modules/video_coding/utility/vp8_header_parser.h" |
| 27 | #include "modules/video_coding/utility/vp9_uncompressed_header_parser.h" |
| 28 | #include "rtc_base/buffer.h" |
| 29 | #include "rtc_base/checks.h" |
| 30 | #include "rtc_base/constructormagic.h" |
| 31 | #include "rtc_base/sequenced_task_checker.h" |
| 32 | #include "rtc_base/task_queue.h" |
| 33 | #include "test/testsupport/frame_reader.h" |
| 34 | #include "test/testsupport/frame_writer.h" |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 35 | |
| 36 | namespace webrtc { |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 37 | |
| 38 | class VideoBitrateAllocator; |
| 39 | |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 40 | namespace test { |
| 41 | |
| 42 | // Defines which frame types shall be excluded from packet loss and when. |
| 43 | enum ExcludeFrameTypes { |
| 44 | // Will exclude the first keyframe in the video sequence from packet loss. |
| 45 | // Following keyframes will be targeted for packet loss. |
| 46 | kExcludeOnlyFirstKeyFrame, |
| 47 | // Exclude all keyframes from packet loss, no matter where in the video |
| 48 | // sequence they occur. |
| 49 | kExcludeAllKeyFrames |
| 50 | }; |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 51 | |
kjellander@webrtc.org | a31b254 | 2011-10-07 06:50:22 +0000 | [diff] [blame] | 52 | // Returns a string representation of the enum value. |
| 53 | const char* ExcludeFrameTypesToStr(ExcludeFrameTypes e); |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 54 | |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 55 | // Test configuration for a test run. |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 56 | struct TestConfig { |
asapersson | 8339e1a | 2017-08-02 00:17:18 -0700 | [diff] [blame] | 57 | // Plain name of YUV file to process without file extension. |
| 58 | std::string filename; |
| 59 | |
asapersson | 8a90f87 | 2017-06-29 05:13:27 -0700 | [diff] [blame] | 60 | // File to process. This must be a video file in the YUV format. |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 61 | std::string input_filename; |
| 62 | |
| 63 | // File to write to during processing for the test. Will be a video file |
| 64 | // in the YUV format. |
| 65 | std::string output_filename; |
| 66 | |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 67 | // Configurations related to networking. |
| 68 | NetworkingConfig networking_config; |
| 69 | |
| 70 | // Decides how the packet loss simulations shall exclude certain frames |
asapersson | 8a90f87 | 2017-06-29 05:13:27 -0700 | [diff] [blame] | 71 | // from packet loss. |
| 72 | ExcludeFrameTypes exclude_frame_types = kExcludeOnlyFirstKeyFrame; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 73 | |
| 74 | // Force the encoder and decoder to use a single core for processing. |
| 75 | // Using a single core is necessary to get a deterministic behavior for the |
| 76 | // encoded frames - using multiple cores will produce different encoded frames |
| 77 | // since multiple cores are competing to consume the byte budget for each |
| 78 | // frame in parallel. |
| 79 | // If set to false, the maximum number of available cores will be used. |
asapersson | 8a90f87 | 2017-06-29 05:13:27 -0700 | [diff] [blame] | 80 | bool use_single_core = false; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 81 | |
asapersson | 8339e1a | 2017-08-02 00:17:18 -0700 | [diff] [blame] | 82 | // If > 0: forces the encoder to create a keyframe every Nth frame. |
| 83 | // Note that the encoder may create a keyframe in other locations in addition |
| 84 | // to this setting. Forcing key frames may also affect encoder planning |
| 85 | // optimizations in a negative way, since it will suddenly be forced to |
| 86 | // produce an expensive key frame. |
asapersson | 8a90f87 | 2017-06-29 05:13:27 -0700 | [diff] [blame] | 87 | int keyframe_interval = 0; |
kjellander@webrtc.org | a31b254 | 2011-10-07 06:50:22 +0000 | [diff] [blame] | 88 | |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 89 | // The codec settings to use for the test (target bitrate, video size, |
brandtr | 07734a5 | 2017-08-08 08:35:53 -0700 | [diff] [blame] | 90 | // framerate and so on). This struct should be filled in using the |
| 91 | // VideoCodingModule::Codec() method. |
| 92 | webrtc::VideoCodec codec_settings; |
kjellander@webrtc.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 93 | |
| 94 | // If printing of information to stdout shall be performed during processing. |
asapersson | 8a90f87 | 2017-06-29 05:13:27 -0700 | [diff] [blame] | 95 | bool verbose = true; |
asapersson | 8339e1a | 2017-08-02 00:17:18 -0700 | [diff] [blame] | 96 | |
brandtr | d635e5b | 2017-09-06 04:48:22 -0700 | [diff] [blame] | 97 | // Should hardware accelerated codecs be used? |
| 98 | bool hw_encoder = false; |
| 99 | bool hw_decoder = false; |
| 100 | |
| 101 | // Should the hardware codecs be wrapped in software fallbacks? |
| 102 | bool sw_fallback_encoder = false; |
Rasmus Brandt | 638200e | 2017-09-27 13:14:14 +0200 | [diff] [blame] | 103 | bool sw_fallback_decoder = false; |
ssilkin | 612f858 | 2017-09-28 09:23:17 -0700 | [diff] [blame] | 104 | |
| 105 | // RTP H264 packetization mode. |
| 106 | H264PacketizationMode packetization_mode = |
| 107 | H264PacketizationMode::NonInterleaved; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 108 | }; |
| 109 | |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 110 | // Handles encoding/decoding of video using the VideoEncoder/VideoDecoder |
| 111 | // interfaces. This is done in a sequential manner in order to be able to |
| 112 | // measure times properly. |
| 113 | // The class processes a frame at the time for the configured input file. |
| 114 | // It maintains state of where in the source input file the processing is at. |
| 115 | // |
| 116 | // Regarding packet loss: Note that keyframes are excluded (first or all |
| 117 | // depending on the ExcludeFrameTypes setting). This is because if key frames |
| 118 | // would be altered, all the following delta frames would be pretty much |
| 119 | // worthless. VP8 has an error-resilience feature that makes it able to handle |
| 120 | // packet loss in key non-first keyframes, which is why only the first is |
| 121 | // excluded by default. |
| 122 | // Packet loss in such important frames is handled on a higher level in the |
| 123 | // Video Engine, where signaling would request a retransmit of the lost packets, |
| 124 | // since they're so important. |
| 125 | // |
| 126 | // Note this class is not thread safe in any way and is meant for simple testing |
| 127 | // purposes. |
| 128 | class VideoProcessor { |
| 129 | public: |
brandtr | c409552 | 2017-08-07 08:12:33 -0700 | [diff] [blame] | 130 | VideoProcessor(webrtc::VideoEncoder* encoder, |
| 131 | webrtc::VideoDecoder* decoder, |
| 132 | FrameReader* analysis_frame_reader, |
| 133 | FrameWriter* analysis_frame_writer, |
| 134 | PacketManipulator* packet_manipulator, |
| 135 | const TestConfig& config, |
| 136 | Stats* stats, |
brandtr | c409552 | 2017-08-07 08:12:33 -0700 | [diff] [blame] | 137 | IvfFileWriter* encoded_frame_writer, |
| 138 | FrameWriter* decoded_frame_writer); |
| 139 | ~VideoProcessor(); |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 140 | |
asapersson | 1d29c86 | 2017-06-22 02:18:50 -0700 | [diff] [blame] | 141 | // Sets up callbacks and initializes the encoder and decoder. |
brandtr | c409552 | 2017-08-07 08:12:33 -0700 | [diff] [blame] | 142 | void Init(); |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 143 | |
brandtr | 77920a4 | 2017-08-11 07:48:15 -0700 | [diff] [blame] | 144 | // Tears down callbacks and releases the encoder and decoder. |
| 145 | void Release(); |
| 146 | |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 147 | // Reads a frame from the analysis frame reader and sends it to the encoder. |
| 148 | // When the encode callback is received, the encoded frame is sent to the |
| 149 | // decoder. The decoded frame is written to disk by the analysis frame writer. |
| 150 | // Objective video quality metrics can thus be calculated after the fact. |
| 151 | void ProcessFrame(); |
marpan@webrtc.org | f4c2de9 | 2012-06-05 21:07:28 +0000 | [diff] [blame] | 152 | |
brandtr | bdd555c | 2017-08-21 01:34:04 -0700 | [diff] [blame] | 153 | // Updates the encoder with target rates. Must be called at least once. |
| 154 | void SetRates(int bitrate_kbps, int framerate_fps); |
marpan@webrtc.org | f4c2de9 | 2012-06-05 21:07:28 +0000 | [diff] [blame] | 155 | |
brandtr | b57f426 | 2017-08-30 06:29:51 -0700 | [diff] [blame] | 156 | // Returns the number of dropped frames. |
| 157 | std::vector<int> NumberDroppedFramesPerRateUpdate() const; |
marpan@webrtc.org | f4c2de9 | 2012-06-05 21:07:28 +0000 | [diff] [blame] | 158 | |
brandtr | b57f426 | 2017-08-30 06:29:51 -0700 | [diff] [blame] | 159 | // Returns the number of spatial resizes. |
| 160 | std::vector<int> NumberSpatialResizesPerRateUpdate() const; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 161 | |
| 162 | private: |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 163 | class VideoProcessorEncodeCompleteCallback |
pbos@webrtc.org | 7f7162a | 2013-07-30 15:18:31 +0000 | [diff] [blame] | 164 | : public webrtc::EncodedImageCallback { |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 165 | public: |
brandtr | c409552 | 2017-08-07 08:12:33 -0700 | [diff] [blame] | 166 | explicit VideoProcessorEncodeCompleteCallback( |
| 167 | VideoProcessor* video_processor) |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 168 | : video_processor_(video_processor), |
| 169 | task_queue_(rtc::TaskQueue::Current()) {} |
| 170 | |
Sergey Ulanov | 525df3f | 2016-08-02 17:46:41 -0700 | [diff] [blame] | 171 | Result OnEncodedImage( |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 172 | const webrtc::EncodedImage& encoded_image, |
| 173 | const webrtc::CodecSpecificInfo* codec_specific_info, |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 174 | const webrtc::RTPFragmentationHeader* fragmentation) override { |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 175 | RTC_CHECK(codec_specific_info); |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 176 | |
| 177 | if (task_queue_ && !task_queue_->IsCurrent()) { |
brandtr | 4553562 | 2017-08-22 03:33:11 -0700 | [diff] [blame] | 178 | task_queue_->PostTask( |
| 179 | std::unique_ptr<rtc::QueuedTask>(new EncodeCallbackTask( |
| 180 | video_processor_, encoded_image, codec_specific_info))); |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 181 | return Result(Result::OK, 0); |
| 182 | } |
| 183 | |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 184 | video_processor_->FrameEncoded(codec_specific_info->codecType, |
brandtr | 4553562 | 2017-08-22 03:33:11 -0700 | [diff] [blame] | 185 | encoded_image); |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 186 | return Result(Result::OK, 0); |
| 187 | } |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 188 | |
| 189 | private: |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 190 | class EncodeCallbackTask : public rtc::QueuedTask { |
| 191 | public: |
| 192 | EncodeCallbackTask(VideoProcessor* video_processor, |
| 193 | const webrtc::EncodedImage& encoded_image, |
brandtr | 4553562 | 2017-08-22 03:33:11 -0700 | [diff] [blame] | 194 | const webrtc::CodecSpecificInfo* codec_specific_info) |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 195 | : video_processor_(video_processor), |
| 196 | buffer_(encoded_image._buffer, encoded_image._length), |
| 197 | encoded_image_(encoded_image), |
| 198 | codec_specific_info_(*codec_specific_info) { |
| 199 | encoded_image_._buffer = buffer_.data(); |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | bool Run() override { |
| 203 | video_processor_->FrameEncoded(codec_specific_info_.codecType, |
brandtr | 4553562 | 2017-08-22 03:33:11 -0700 | [diff] [blame] | 204 | encoded_image_); |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 205 | return true; |
| 206 | } |
| 207 | |
| 208 | private: |
| 209 | VideoProcessor* const video_processor_; |
| 210 | rtc::Buffer buffer_; |
| 211 | webrtc::EncodedImage encoded_image_; |
| 212 | const webrtc::CodecSpecificInfo codec_specific_info_; |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 213 | }; |
| 214 | |
brandtr | c409552 | 2017-08-07 08:12:33 -0700 | [diff] [blame] | 215 | VideoProcessor* const video_processor_; |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 216 | rtc::TaskQueue* const task_queue_; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 217 | }; |
| 218 | |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 219 | class VideoProcessorDecodeCompleteCallback |
philipel | cce46fc | 2015-12-21 03:04:49 -0800 | [diff] [blame] | 220 | : public webrtc::DecodedImageCallback { |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 221 | public: |
brandtr | c409552 | 2017-08-07 08:12:33 -0700 | [diff] [blame] | 222 | explicit VideoProcessorDecodeCompleteCallback( |
| 223 | VideoProcessor* video_processor) |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 224 | : video_processor_(video_processor), |
| 225 | task_queue_(rtc::TaskQueue::Current()) {} |
| 226 | |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 227 | int32_t Decoded(webrtc::VideoFrame& image) override { |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 228 | if (task_queue_ && !task_queue_->IsCurrent()) { |
| 229 | task_queue_->PostTask( |
| 230 | [this, image]() { video_processor_->FrameDecoded(image); }); |
| 231 | return 0; |
| 232 | } |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 233 | video_processor_->FrameDecoded(image); |
| 234 | return 0; |
| 235 | } |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 236 | |
philipel | cce46fc | 2015-12-21 03:04:49 -0800 | [diff] [blame] | 237 | int32_t Decoded(webrtc::VideoFrame& image, |
| 238 | int64_t decode_time_ms) override { |
brandtr | 6bb8e0e | 2017-02-20 04:35:52 -0800 | [diff] [blame] | 239 | return Decoded(image); |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 240 | } |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 241 | |
brandtr | 6bb8e0e | 2017-02-20 04:35:52 -0800 | [diff] [blame] | 242 | void Decoded(webrtc::VideoFrame& image, |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 243 | rtc::Optional<int32_t> decode_time_ms, |
| 244 | rtc::Optional<uint8_t> qp) override { |
brandtr | bea36fd | 2017-08-07 03:36:54 -0700 | [diff] [blame] | 245 | Decoded(image); |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 246 | } |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 247 | |
| 248 | private: |
brandtr | c409552 | 2017-08-07 08:12:33 -0700 | [diff] [blame] | 249 | VideoProcessor* const video_processor_; |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 250 | rtc::TaskQueue* const task_queue_; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 251 | }; |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 252 | |
brandtr | bdd555c | 2017-08-21 01:34:04 -0700 | [diff] [blame] | 253 | // Invoked by the callback adapter when a frame has completed encoding. |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 254 | void FrameEncoded(webrtc::VideoCodecType codec, |
brandtr | 4553562 | 2017-08-22 03:33:11 -0700 | [diff] [blame] | 255 | const webrtc::EncodedImage& encodedImage); |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 256 | |
brandtr | bdd555c | 2017-08-21 01:34:04 -0700 | [diff] [blame] | 257 | // Invoked by the callback adapter when a frame has completed decoding. |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 258 | void FrameDecoded(const webrtc::VideoFrame& image); |
| 259 | |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 260 | bool initialized_ RTC_GUARDED_BY(sequence_checker_); |
| 261 | TestConfig config_ RTC_GUARDED_BY(sequence_checker_); |
brandtr | 07734a5 | 2017-08-08 08:35:53 -0700 | [diff] [blame] | 262 | |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 263 | webrtc::VideoEncoder* const encoder_; |
| 264 | webrtc::VideoDecoder* const decoder_; |
brandtr | aebc61e | 2017-02-28 07:13:47 -0800 | [diff] [blame] | 265 | const std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_; |
| 266 | |
| 267 | // Adapters for the codec callbacks. |
brandtr | bdd555c | 2017-08-21 01:34:04 -0700 | [diff] [blame] | 268 | VideoProcessorEncodeCompleteCallback encode_callback_; |
| 269 | VideoProcessorDecodeCompleteCallback decode_callback_; |
brandtr | aebc61e | 2017-02-28 07:13:47 -0800 | [diff] [blame] | 270 | |
brandtr | 07734a5 | 2017-08-08 08:35:53 -0700 | [diff] [blame] | 271 | // Fake network. |
brandtr | aebc61e | 2017-02-28 07:13:47 -0800 | [diff] [blame] | 272 | PacketManipulator* const packet_manipulator_; |
brandtr | aebc61e | 2017-02-28 07:13:47 -0800 | [diff] [blame] | 273 | |
brandtr | b78bc75 | 2017-02-22 01:26:59 -0800 | [diff] [blame] | 274 | // These (mandatory) file manipulators are used for, e.g., objective PSNR and |
| 275 | // SSIM calculations at the end of a test run. |
| 276 | FrameReader* const analysis_frame_reader_; |
| 277 | FrameWriter* const analysis_frame_writer_; |
brandtr | aebc61e | 2017-02-28 07:13:47 -0800 | [diff] [blame] | 278 | |
brandtr | c287c80 | 2017-08-07 08:30:43 -0700 | [diff] [blame] | 279 | // These (optional) file writers are used to persistently store the encoded |
| 280 | // and decoded bitstreams. The purpose is to give the experimenter an option |
| 281 | // to subjectively evaluate the quality of the processing. Each frame writer |
| 282 | // is enabled by being non-null. |
brandtr | b78bc75 | 2017-02-22 01:26:59 -0800 | [diff] [blame] | 283 | IvfFileWriter* const encoded_frame_writer_; |
| 284 | FrameWriter* const decoded_frame_writer_; |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 285 | |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 286 | // Keep track of inputed/encoded/decoded frames, so we can detect frame drops. |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 287 | int last_inputed_frame_num_ RTC_GUARDED_BY(sequence_checker_); |
| 288 | int last_encoded_frame_num_ RTC_GUARDED_BY(sequence_checker_); |
| 289 | int last_decoded_frame_num_ RTC_GUARDED_BY(sequence_checker_); |
brandtr | 17b958c | 2017-03-07 01:41:43 -0800 | [diff] [blame] | 290 | |
brandtr | b57f426 | 2017-08-30 06:29:51 -0700 | [diff] [blame] | 291 | // Store an RTP timestamp -> frame number map, since the timestamps are |
| 292 | // based off of the frame rate, which can change mid-test. |
| 293 | std::map<uint32_t, int> rtp_timestamp_to_frame_num_ |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 294 | RTC_GUARDED_BY(sequence_checker_); |
brandtr | b57f426 | 2017-08-30 06:29:51 -0700 | [diff] [blame] | 295 | |
brandtr | 17b958c | 2017-03-07 01:41:43 -0800 | [diff] [blame] | 296 | // Keep track of if we have excluded the first key frame from packet loss. |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 297 | bool first_key_frame_has_been_excluded_ RTC_GUARDED_BY(sequence_checker_); |
brandtr | 17b958c | 2017-03-07 01:41:43 -0800 | [diff] [blame] | 298 | |
| 299 | // Keep track of the last successfully decoded frame, since we write that |
| 300 | // frame to disk when decoding fails. |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 301 | rtc::Buffer last_decoded_frame_buffer_ RTC_GUARDED_BY(sequence_checker_); |
brandtr | 8bc9385 | 2017-02-15 05:19:51 -0800 | [diff] [blame] | 302 | |
| 303 | // Statistics. |
brandtr | aebc61e | 2017-02-28 07:13:47 -0800 | [diff] [blame] | 304 | Stats* stats_; |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 305 | std::vector<int> num_dropped_frames_ RTC_GUARDED_BY(sequence_checker_); |
| 306 | std::vector<int> num_spatial_resizes_ RTC_GUARDED_BY(sequence_checker_); |
| 307 | int rate_update_index_ RTC_GUARDED_BY(sequence_checker_); |
brandtr | c8c5905 | 2017-08-21 06:44:16 -0700 | [diff] [blame] | 308 | |
| 309 | rtc::SequencedTaskChecker sequence_checker_; |
brandtr | bdd555c | 2017-08-21 01:34:04 -0700 | [diff] [blame] | 310 | |
| 311 | RTC_DISALLOW_COPY_AND_ASSIGN(VideoProcessor); |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 312 | }; |
| 313 | |
| 314 | } // namespace test |
| 315 | } // namespace webrtc |
| 316 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 317 | #endif // MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |