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