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

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

Issue 2994613002: Remove VideoProcessor interface. (Closed)
Patch Set: asapersson comments 1. 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
« no previous file with comments | « no previous file | webrtc/modules/video_coding/codecs/test/videoprocessor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
141 class VideoProcessor { 139 class VideoProcessor {
142 public: 140 public:
143 virtual ~VideoProcessor() {} 141 VideoProcessor(webrtc::VideoEncoder* encoder,
142 webrtc::VideoDecoder* decoder,
143 FrameReader* analysis_frame_reader,
144 FrameWriter* analysis_frame_writer,
145 PacketManipulator* packet_manipulator,
146 const TestConfig& config,
147 Stats* stats,
148 FrameWriter* source_frame_writer,
149 IvfFileWriter* encoded_frame_writer,
150 FrameWriter* decoded_frame_writer);
151 ~VideoProcessor();
144 152
145 // Sets up callbacks and initializes the encoder and decoder. 153 // Sets up callbacks and initializes the encoder and decoder.
146 virtual void Init() = 0; 154 void Init();
147 155
148 // Processes a single frame. Returns true as long as there's more frames 156 // Processes a single frame. Returns true as long as there's more frames
149 // available in the source clip. 157 // available in the source clip.
150 // |frame_number| must be an integer >= 0. 158 // |frame_number| must be an integer >= 0.
151 virtual bool ProcessFrame(int frame_number) = 0; 159 bool ProcessFrame(int frame_number);
152 160
153 // Updates the encoder with the target |bit_rate| and the |frame_rate|. 161 // Updates the encoder with the target |bit_rate| and the |frame_rate|.
154 virtual void SetRates(int bit_rate, int frame_rate) = 0; 162 void SetRates(int bit_rate, int frame_rate);
155 163
156 // Return the size of the encoded frame in bytes. Dropped frames by the 164 // Return the size of the encoded frame in bytes. Dropped frames by the
157 // encoder are regarded as zero size. 165 // encoder are regarded as zero size.
158 virtual size_t EncodedFrameSize(int frame_number) = 0; 166 size_t EncodedFrameSize(int frame_number);
159 167
160 // Return the encoded frame type (key or delta). 168 // Return the encoded frame type (key or delta).
161 virtual FrameType EncodedFrameType(int frame_number) = 0; 169 FrameType EncodedFrameType(int frame_number);
162 170
163 // Return the qp used by encoder. 171 // Return the qp used by encoder.
164 virtual int GetQpFromEncoder(int frame_number) = 0; 172 int GetQpFromEncoder(int frame_number);
165 173
166 // Return the qp from the qp parser. 174 // Return the qp from the qp parser.
167 virtual int GetQpFromBitstream(int frame_number) = 0; 175 int GetQpFromBitstream(int frame_number);
168 176
169 // Return the number of dropped frames. 177 // Return the number of dropped frames.
170 virtual int NumberDroppedFrames() = 0; 178 int NumberDroppedFrames();
171 179
172 // Return the number of spatial resizes. 180 // Return the number of spatial resizes.
173 virtual int NumberSpatialResizes() = 0; 181 int NumberSpatialResizes();
174 };
175
176 class VideoProcessorImpl : public VideoProcessor {
177 public:
178 VideoProcessorImpl(webrtc::VideoEncoder* encoder,
179 webrtc::VideoDecoder* decoder,
180 FrameReader* analysis_frame_reader,
181 FrameWriter* analysis_frame_writer,
182 PacketManipulator* packet_manipulator,
183 const TestConfig& config,
184 Stats* stats,
185 FrameWriter* source_frame_writer,
186 IvfFileWriter* encoded_frame_writer,
187 FrameWriter* decoded_frame_writer);
188 ~VideoProcessorImpl() override;
189
190 // Implements VideoProcessor.
191 void Init() 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;
200 182
201 private: 183 private:
202 // Container that holds per-frame information that needs to be stored between 184 // Container that holds per-frame information that needs to be stored between
203 // calls to Encode and Decode, as well as the corresponding callbacks. It is 185 // calls to Encode and Decode, as well as the corresponding callbacks. It is
204 // not directly used for statistics -- for that, test::FrameStatistic is used. 186 // not directly used for statistics -- for that, test::FrameStatistic is used.
205 struct FrameInfo { 187 struct FrameInfo {
206 FrameInfo() 188 FrameInfo()
207 : timestamp(0), 189 : timestamp(0),
208 encode_start_ns(0), 190 encode_start_ns(0),
209 decode_start_ns(0), 191 decode_start_ns(0),
(...skipping 14 matching lines...) Expand all
224 int decoded_height; 206 int decoded_height;
225 size_t manipulated_length; 207 size_t manipulated_length;
226 int qp_encoder; 208 int qp_encoder;
227 int qp_bitstream; 209 int qp_bitstream;
228 }; 210 };
229 211
230 // Callback class required to implement according to the VideoEncoder API. 212 // Callback class required to implement according to the VideoEncoder API.
231 class VideoProcessorEncodeCompleteCallback 213 class VideoProcessorEncodeCompleteCallback
232 : public webrtc::EncodedImageCallback { 214 : public webrtc::EncodedImageCallback {
233 public: 215 public:
234 explicit VideoProcessorEncodeCompleteCallback(VideoProcessorImpl* vp) 216 explicit VideoProcessorEncodeCompleteCallback(
235 : video_processor_(vp) {} 217 VideoProcessor* video_processor)
218 : video_processor_(video_processor) {}
236 Result OnEncodedImage( 219 Result OnEncodedImage(
237 const webrtc::EncodedImage& encoded_image, 220 const webrtc::EncodedImage& encoded_image,
238 const webrtc::CodecSpecificInfo* codec_specific_info, 221 const webrtc::CodecSpecificInfo* codec_specific_info,
239 const webrtc::RTPFragmentationHeader* fragmentation) override { 222 const webrtc::RTPFragmentationHeader* fragmentation) override {
240 // Forward to parent class. 223 // Forward to parent class.
241 RTC_CHECK(codec_specific_info); 224 RTC_CHECK(codec_specific_info);
242 video_processor_->FrameEncoded(codec_specific_info->codecType, 225 video_processor_->FrameEncoded(codec_specific_info->codecType,
243 encoded_image, fragmentation); 226 encoded_image, fragmentation);
244 return Result(Result::OK, 0); 227 return Result(Result::OK, 0);
245 } 228 }
246 229
247 private: 230 private:
248 VideoProcessorImpl* const video_processor_; 231 VideoProcessor* const video_processor_;
249 }; 232 };
250 233
251 // Callback class required to implement according to the VideoDecoder API. 234 // Callback class required to implement according to the VideoDecoder API.
252 class VideoProcessorDecodeCompleteCallback 235 class VideoProcessorDecodeCompleteCallback
253 : public webrtc::DecodedImageCallback { 236 : public webrtc::DecodedImageCallback {
254 public: 237 public:
255 explicit VideoProcessorDecodeCompleteCallback(VideoProcessorImpl* vp) 238 explicit VideoProcessorDecodeCompleteCallback(
256 : video_processor_(vp) {} 239 VideoProcessor* video_processor)
240 : video_processor_(video_processor) {}
257 int32_t Decoded(webrtc::VideoFrame& image) override { 241 int32_t Decoded(webrtc::VideoFrame& image) override {
258 // Forward to parent class. 242 // Forward to parent class.
259 video_processor_->FrameDecoded(image); 243 video_processor_->FrameDecoded(image);
260 return 0; 244 return 0;
261 } 245 }
262 int32_t Decoded(webrtc::VideoFrame& image, 246 int32_t Decoded(webrtc::VideoFrame& image,
263 int64_t decode_time_ms) override { 247 int64_t decode_time_ms) override {
264 return Decoded(image); 248 return Decoded(image);
265 } 249 }
266 void Decoded(webrtc::VideoFrame& image, 250 void Decoded(webrtc::VideoFrame& image,
267 rtc::Optional<int32_t> decode_time_ms, 251 rtc::Optional<int32_t> decode_time_ms,
268 rtc::Optional<uint8_t> qp) override { 252 rtc::Optional<uint8_t> qp) override {
269 Decoded(image); 253 Decoded(image);
270 } 254 }
271 255
272 private: 256 private:
273 VideoProcessorImpl* const video_processor_; 257 VideoProcessor* const video_processor_;
274 }; 258 };
275 259
276 // Invoked by the callback when a frame has completed encoding. 260 // Invoked by the callback when a frame has completed encoding.
277 void FrameEncoded(webrtc::VideoCodecType codec, 261 void FrameEncoded(webrtc::VideoCodecType codec,
278 const webrtc::EncodedImage& encodedImage, 262 const webrtc::EncodedImage& encodedImage,
279 const webrtc::RTPFragmentationHeader* fragmentation); 263 const webrtc::RTPFragmentationHeader* fragmentation);
280 264
281 // Invoked by the callback when a frame has completed decoding. 265 // Invoked by the callback when a frame has completed decoding.
282 void FrameDecoded(const webrtc::VideoFrame& image); 266 void FrameDecoded(const webrtc::VideoFrame& image);
283 267
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // Statistics. 316 // Statistics.
333 Stats* stats_; 317 Stats* stats_;
334 int num_dropped_frames_; 318 int num_dropped_frames_;
335 int num_spatial_resizes_; 319 int num_spatial_resizes_;
336 }; 320 };
337 321
338 } // namespace test 322 } // namespace test
339 } // namespace webrtc 323 } // namespace webrtc
340 324
341 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ 325 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/video_coding/codecs/test/videoprocessor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698