OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |
12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/api/video/video_frame.h" | 18 #include "webrtc/api/video/video_frame.h" |
19 #include "webrtc/base/buffer.h" | 19 #include "webrtc/base/buffer.h" |
20 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
22 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 22 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
23 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" | 23 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" |
24 #include "webrtc/modules/video_coding/codecs/test/stats.h" | 24 #include "webrtc/modules/video_coding/codecs/test/stats.h" |
25 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" | 25 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" |
26 #include "webrtc/modules/video_coding/utility/vp8_header_parser.h" | |
27 #include "webrtc/modules/video_coding/utility/vp9_uncompressed_header_parser.h" | |
26 #include "webrtc/test/testsupport/frame_reader.h" | 28 #include "webrtc/test/testsupport/frame_reader.h" |
27 #include "webrtc/test/testsupport/frame_writer.h" | 29 #include "webrtc/test/testsupport/frame_writer.h" |
28 | 30 |
29 namespace webrtc { | 31 namespace webrtc { |
30 | 32 |
31 class VideoBitrateAllocator; | 33 class VideoBitrateAllocator; |
32 | 34 |
33 namespace test { | 35 namespace test { |
34 | 36 |
35 // Defines which frame types shall be excluded from packet loss and when. | 37 // Defines which frame types shall be excluded from packet loss and when. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 | 138 |
137 // Performs initial calculations about frame size, sets up callbacks etc. | 139 // Performs initial calculations about frame size, sets up callbacks etc. |
138 // Returns false if an error has occurred, in addition to printing to stderr. | 140 // Returns false if an error has occurred, in addition to printing to stderr. |
139 virtual bool Init() = 0; | 141 virtual bool Init() = 0; |
140 | 142 |
141 // Processes a single frame. Returns true as long as there's more frames | 143 // Processes a single frame. Returns true as long as there's more frames |
142 // available in the source clip. | 144 // available in the source clip. |
143 // Frame number must be an integer >= 0. | 145 // Frame number must be an integer >= 0. |
144 virtual bool ProcessFrame(int frame_number) = 0; | 146 virtual bool ProcessFrame(int frame_number) = 0; |
145 | 147 |
148 // Return the qp used by encoder. | |
149 virtual int GetQpFromEncoder() = 0; | |
brandtr
2017/05/26 07:18:45
See comment below first.
Add parameter "int frame
jianj
2017/05/26 18:20:27
Done.
| |
150 | |
151 // Return the qp from the qp parser. | |
152 virtual int GetQpFromBitstream() = 0; | |
brandtr
2017/05/26 07:18:45
Same here.
jianj
2017/05/26 18:20:27
Done.
| |
153 | |
146 // Updates the encoder with the target bit rate and the frame rate. | 154 // Updates the encoder with the target bit rate and the frame rate. |
147 virtual void SetRates(int bit_rate, int frame_rate) = 0; | 155 virtual void SetRates(int bit_rate, int frame_rate) = 0; |
148 | 156 |
149 // Return the size of the encoded frame in bytes. Dropped frames by the | 157 // Return the size of the encoded frame in bytes. Dropped frames by the |
150 // encoder are regarded as zero size. | 158 // encoder are regarded as zero size. |
151 virtual size_t EncodedFrameSize(int frame_number) = 0; | 159 virtual size_t EncodedFrameSize(int frame_number) = 0; |
152 | 160 |
153 // Return the encoded frame type (key or delta). | 161 // Return the encoded frame type (key or delta). |
154 virtual FrameType EncodedFrameType(int frame_number) = 0; | 162 virtual FrameType EncodedFrameType(int frame_number) = 0; |
155 | 163 |
(...skipping 13 matching lines...) Expand all Loading... | |
169 PacketManipulator* packet_manipulator, | 177 PacketManipulator* packet_manipulator, |
170 const TestConfig& config, | 178 const TestConfig& config, |
171 Stats* stats, | 179 Stats* stats, |
172 FrameWriter* source_frame_writer, | 180 FrameWriter* source_frame_writer, |
173 IvfFileWriter* encoded_frame_writer, | 181 IvfFileWriter* encoded_frame_writer, |
174 FrameWriter* decoded_frame_writer); | 182 FrameWriter* decoded_frame_writer); |
175 virtual ~VideoProcessorImpl(); | 183 virtual ~VideoProcessorImpl(); |
176 bool Init() override; | 184 bool Init() override; |
177 bool ProcessFrame(int frame_number) override; | 185 bool ProcessFrame(int frame_number) override; |
178 | 186 |
187 int GetQpFromEncoder() override; | |
brandtr
2017/05/26 07:18:45
Place these two lines in the private section (*),
jianj
2017/05/26 18:20:27
Done.
| |
188 int GetQpFromBitstream() override; | |
189 | |
179 private: | 190 private: |
180 // Container that holds per-frame information that needs to be stored between | 191 // Container that holds per-frame information that needs to be stored between |
181 // calls to Encode and Decode, as well as the corresponding callbacks. It is | 192 // calls to Encode and Decode, as well as the corresponding callbacks. It is |
182 // not directly used for statistics -- for that, test::FrameStatistic is used. | 193 // not directly used for statistics -- for that, test::FrameStatistic is used. |
183 struct FrameInfo { | 194 struct FrameInfo { |
184 FrameInfo() | 195 FrameInfo() |
185 : timestamp(0), | 196 : timestamp(0), |
186 encode_start_ns(0), | 197 encode_start_ns(0), |
187 decode_start_ns(0), | 198 decode_start_ns(0), |
188 encoded_frame_size(0), | 199 encoded_frame_size(0), |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 }; | 260 }; |
250 | 261 |
251 // Invoked by the callback when a frame has completed encoding. | 262 // Invoked by the callback when a frame has completed encoding. |
252 void FrameEncoded(webrtc::VideoCodecType codec, | 263 void FrameEncoded(webrtc::VideoCodecType codec, |
253 const webrtc::EncodedImage& encodedImage, | 264 const webrtc::EncodedImage& encodedImage, |
254 const webrtc::RTPFragmentationHeader* fragmentation); | 265 const webrtc::RTPFragmentationHeader* fragmentation); |
255 | 266 |
256 // Invoked by the callback when a frame has completed decoding. | 267 // Invoked by the callback when a frame has completed decoding. |
257 void FrameDecoded(const webrtc::VideoFrame& image); | 268 void FrameDecoded(const webrtc::VideoFrame& image); |
258 | 269 |
270 | |
brandtr
2017/05/26 07:18:45
Remove.
jianj
2017/05/26 18:20:27
Done.
| |
259 // Updates the encoder with the target bit rate and the frame rate. | 271 // Updates the encoder with the target bit rate and the frame rate. |
260 void SetRates(int bit_rate, int frame_rate) override; | 272 void SetRates(int bit_rate, int frame_rate) override; |
261 | 273 |
262 // Return the size of the encoded frame in bytes. | 274 // Return the size of the encoded frame in bytes. |
263 size_t EncodedFrameSize(int frame_number) override; | 275 size_t EncodedFrameSize(int frame_number) override; |
264 | 276 |
265 // Return the encoded frame type (key or delta). | 277 // Return the encoded frame type (key or delta). |
266 FrameType EncodedFrameType(int frame_number) override; | 278 FrameType EncodedFrameType(int frame_number) override; |
267 | 279 |
268 // Return the number of dropped frames. | 280 // Return the number of dropped frames. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 bool first_key_frame_has_been_excluded_; | 326 bool first_key_frame_has_been_excluded_; |
315 | 327 |
316 // Keep track of the last successfully decoded frame, since we write that | 328 // Keep track of the last successfully decoded frame, since we write that |
317 // frame to disk when decoding fails. | 329 // frame to disk when decoding fails. |
318 rtc::Buffer last_decoded_frame_buffer_; | 330 rtc::Buffer last_decoded_frame_buffer_; |
319 | 331 |
320 // Statistics. | 332 // Statistics. |
321 Stats* stats_; | 333 Stats* stats_; |
322 int num_dropped_frames_; | 334 int num_dropped_frames_; |
323 int num_spatial_resizes_; | 335 int num_spatial_resizes_; |
336 | |
337 int qp_encoder_; | |
brandtr
2017/05/26 07:18:45
We are trying to get away from using direct member
jianj
2017/05/26 18:20:27
Done.
| |
338 int qp_bitstream_; | |
324 }; | 339 }; |
325 | 340 |
326 } // namespace test | 341 } // namespace test |
327 } // namespace webrtc | 342 } // namespace webrtc |
328 | 343 |
329 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ | 344 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |
OLD | NEW |