Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1050)

Side by Side Diff: webrtc/modules/video_coding/codecs/test/videoprocessor.h

Issue 2995513002: Minor improvements to VideoProcessor and corresponding test. (Closed)
Patch Set: Fix compile. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // would be altered, all the following delta frames would be pretty much 129 // would be altered, all the following delta frames would be pretty much
130 // worthless. VP8 has an error-resilience feature that makes it able to handle 130 // worthless. VP8 has an error-resilience feature that makes it able to handle
131 // packet loss in key non-first keyframes, which is why only the first is 131 // packet loss in key non-first keyframes, which is why only the first is
132 // excluded by default. 132 // excluded by default.
133 // Packet loss in such important frames is handled on a higher level in the 133 // Packet loss in such important frames is handled on a higher level in the
134 // Video Engine, where signaling would request a retransmit of the lost packets, 134 // Video Engine, where signaling would request a retransmit of the lost packets,
135 // since they're so important. 135 // since they're so important.
136 // 136 //
137 // Note this class is not thread safe in any way and is meant for simple testing 137 // Note this class is not thread safe in any way and is meant for simple testing
138 // purposes. 138 // purposes.
139 //
140 // TODO(brandtr): Remove this interface.
139 class VideoProcessor { 141 class VideoProcessor {
140 public: 142 public:
141 virtual ~VideoProcessor() {} 143 virtual ~VideoProcessor() {}
142 144
143 // Sets up callbacks and initializes the encoder and decoder. 145 // Sets up callbacks and initializes the encoder and decoder.
144 virtual void Init() = 0; 146 virtual void Init() = 0;
145 147
146 // Processes a single frame. Returns true as long as there's more frames 148 // Processes a single frame. Returns true as long as there's more frames
147 // available in the source clip. 149 // available in the source clip.
148 // |frame_number| must be an integer >= 0. 150 // |frame_number| must be an integer >= 0.
(...skipping 27 matching lines...) Expand all
176 VideoProcessorImpl(webrtc::VideoEncoder* encoder, 178 VideoProcessorImpl(webrtc::VideoEncoder* encoder,
177 webrtc::VideoDecoder* decoder, 179 webrtc::VideoDecoder* decoder,
178 FrameReader* analysis_frame_reader, 180 FrameReader* analysis_frame_reader,
179 FrameWriter* analysis_frame_writer, 181 FrameWriter* analysis_frame_writer,
180 PacketManipulator* packet_manipulator, 182 PacketManipulator* packet_manipulator,
181 const TestConfig& config, 183 const TestConfig& config,
182 Stats* stats, 184 Stats* stats,
183 FrameWriter* source_frame_writer, 185 FrameWriter* source_frame_writer,
184 IvfFileWriter* encoded_frame_writer, 186 IvfFileWriter* encoded_frame_writer,
185 FrameWriter* decoded_frame_writer); 187 FrameWriter* decoded_frame_writer);
186 virtual ~VideoProcessorImpl(); 188 ~VideoProcessorImpl() override;
189
190 // Implements VideoProcessor.
187 void Init() override; 191 void Init() override;
188 bool ProcessFrame(int frame_number) override; 192 bool ProcessFrame(int frame_number) override;
193 void SetRates(int bit_rate, int frame_rate) override;
194 size_t EncodedFrameSize(int frame_number) override;
195 FrameType EncodedFrameType(int frame_number) override;
196 int GetQpFromEncoder(int frame_number) override;
197 int GetQpFromBitstream(int frame_number) override;
198 int NumberDroppedFrames() override;
199 int NumberSpatialResizes() override;
189 200
190 private: 201 private:
191 // Container that holds per-frame information that needs to be stored between 202 // Container that holds per-frame information that needs to be stored between
192 // calls to Encode and Decode, as well as the corresponding callbacks. It is 203 // calls to Encode and Decode, as well as the corresponding callbacks. It is
193 // not directly used for statistics -- for that, test::FrameStatistic is used. 204 // not directly used for statistics -- for that, test::FrameStatistic is used.
194 struct FrameInfo { 205 struct FrameInfo {
195 FrameInfo() 206 FrameInfo()
196 : timestamp(0), 207 : timestamp(0),
197 encode_start_ns(0), 208 encode_start_ns(0),
198 decode_start_ns(0), 209 decode_start_ns(0),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 video_processor_->FrameDecoded(image); 259 video_processor_->FrameDecoded(image);
249 return 0; 260 return 0;
250 } 261 }
251 int32_t Decoded(webrtc::VideoFrame& image, 262 int32_t Decoded(webrtc::VideoFrame& image,
252 int64_t decode_time_ms) override { 263 int64_t decode_time_ms) override {
253 return Decoded(image); 264 return Decoded(image);
254 } 265 }
255 void Decoded(webrtc::VideoFrame& image, 266 void Decoded(webrtc::VideoFrame& image,
256 rtc::Optional<int32_t> decode_time_ms, 267 rtc::Optional<int32_t> decode_time_ms,
257 rtc::Optional<uint8_t> qp) override { 268 rtc::Optional<uint8_t> qp) override {
258 Decoded(image, 269 Decoded(image);
259 decode_time_ms ? static_cast<int32_t>(*decode_time_ms) : -1);
260 } 270 }
261 271
262 private: 272 private:
263 VideoProcessorImpl* const video_processor_; 273 VideoProcessorImpl* const video_processor_;
264 }; 274 };
265 275
266 // Invoked by the callback when a frame has completed encoding. 276 // Invoked by the callback when a frame has completed encoding.
267 void FrameEncoded(webrtc::VideoCodecType codec, 277 void FrameEncoded(webrtc::VideoCodecType codec,
268 const webrtc::EncodedImage& encodedImage, 278 const webrtc::EncodedImage& encodedImage,
269 const webrtc::RTPFragmentationHeader* fragmentation); 279 const webrtc::RTPFragmentationHeader* fragmentation);
270 280
271 // Invoked by the callback when a frame has completed decoding. 281 // Invoked by the callback when a frame has completed decoding.
272 void FrameDecoded(const webrtc::VideoFrame& image); 282 void FrameDecoded(const webrtc::VideoFrame& image);
273 283
274 // Updates the encoder with the target bit rate and the frame rate. 284 // Use the frame number as the basis for timestamp to identify frames. Let the
275 void SetRates(int bit_rate, int frame_rate) override; 285 // first timestamp be non-zero, to not make the IvfFileWriter believe that we
276 286 // want to use capture timestamps in the IVF files.
277 // Return the size of the encoded frame in bytes. 287 uint32_t FrameNumberToTimestamp(int frame_number);
278 size_t EncodedFrameSize(int frame_number) override; 288 int TimestampToFrameNumber(uint32_t timestamp);
279
280 // Return the encoded frame type (key or delta).
281 FrameType EncodedFrameType(int frame_number) override;
282
283 // Return the qp used by encoder.
284 int GetQpFromEncoder(int frame_number) override;
285
286 // Return the qp from the qp parser.
287 int GetQpFromBitstream(int frame_number) override;
288
289 // Return the number of dropped frames.
290 int NumberDroppedFrames() override;
291
292 // Return the number of spatial resizes.
293 int NumberSpatialResizes() override;
294 289
295 webrtc::VideoEncoder* const encoder_; 290 webrtc::VideoEncoder* const encoder_;
296 webrtc::VideoDecoder* const decoder_; 291 webrtc::VideoDecoder* const decoder_;
297 const std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_; 292 const std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_;
298 293
299 // Adapters for the codec callbacks. 294 // Adapters for the codec callbacks.
300 const std::unique_ptr<EncodedImageCallback> encode_callback_; 295 const std::unique_ptr<EncodedImageCallback> encode_callback_;
301 const std::unique_ptr<DecodedImageCallback> decode_callback_; 296 const std::unique_ptr<DecodedImageCallback> decode_callback_;
302 297
303 PacketManipulator* const packet_manipulator_; 298 PacketManipulator* const packet_manipulator_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // Statistics. 332 // Statistics.
338 Stats* stats_; 333 Stats* stats_;
339 int num_dropped_frames_; 334 int num_dropped_frames_;
340 int num_spatial_resizes_; 335 int num_spatial_resizes_;
341 }; 336 };
342 337
343 } // namespace test 338 } // namespace test
344 } // namespace webrtc 339 } // namespace webrtc
345 340
346 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ 341 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/test/stats.cc ('k') | webrtc/modules/video_coding/codecs/test/videoprocessor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698