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

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

Issue 1306813009: H.264 video codec support using OpenH264/FFmpeg (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Re-enable H264 in video_loopback and screenshare_loopback after rebase (video_quality_test) Created 5 years, 2 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
11 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h" 11 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <string.h> 14 #include <string.h>
15 15
16 #include <limits> 16 #include <limits>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/base/checks.h"
20 #include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h"
19 #include "webrtc/system_wrappers/interface/cpu_info.h" 21 #include "webrtc/system_wrappers/interface/cpu_info.h"
20 22
21 namespace webrtc { 23 namespace webrtc {
22 namespace test { 24 namespace test {
23 25
24 TestConfig::TestConfig() 26 TestConfig::TestConfig()
25 : name(""), 27 : name(""),
26 description(""), 28 description(""),
27 test_number(0), 29 test_number(0),
28 input_filename(""), 30 input_filename(""),
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 fprintf(stderr, "Failed to encode frame %d, return code: %d\n", 217 fprintf(stderr, "Failed to encode frame %d, return code: %d\n",
216 frame_number, encode_result); 218 frame_number, encode_result);
217 } 219 }
218 stat.encode_return_code = encode_result; 220 stat.encode_return_code = encode_result;
219 return true; 221 return true;
220 } else { 222 } else {
221 return false; // we've reached the last frame 223 return false; // we've reached the last frame
222 } 224 }
223 } 225 }
224 226
225 void VideoProcessorImpl::FrameEncoded(const EncodedImage& encoded_image) { 227 void VideoProcessorImpl::FrameEncoded(
228 const EncodedImage& encoded_image,
229 const webrtc::RTPFragmentationHeader* fragmentation) {
226 // Timestamp is frame number, so this gives us #dropped frames. 230 // Timestamp is frame number, so this gives us #dropped frames.
227 int num_dropped_from_prev_encode = encoded_image._timeStamp - 231 int num_dropped_from_prev_encode = encoded_image._timeStamp -
228 prev_time_stamp_ - 1; 232 prev_time_stamp_ - 1;
229 num_dropped_frames_ += num_dropped_from_prev_encode; 233 num_dropped_frames_ += num_dropped_from_prev_encode;
230 prev_time_stamp_ = encoded_image._timeStamp; 234 prev_time_stamp_ = encoded_image._timeStamp;
231 if (num_dropped_from_prev_encode > 0) { 235 if (num_dropped_from_prev_encode > 0) {
232 // For dropped frames, we write out the last decoded frame to avoid getting 236 // For dropped frames, we write out the last decoded frame to avoid getting
233 // out of sync for the computation of PSNR and SSIM. 237 // out of sync for the computation of PSNR and SSIM.
234 for (int i = 0; i < num_dropped_from_prev_encode; i++) { 238 for (int i = 0; i < num_dropped_from_prev_encode; i++) {
235 frame_writer_->WriteFrame(last_successful_frame_buffer_); 239 frame_writer_->WriteFrame(last_successful_frame_buffer_);
(...skipping 29 matching lines...) Expand all
265 exclude_this_frame = true; 269 exclude_this_frame = true;
266 } 270 }
267 break; 271 break;
268 case kExcludeAllKeyFrames: 272 case kExcludeAllKeyFrames:
269 exclude_this_frame = true; 273 exclude_this_frame = true;
270 break; 274 break;
271 default: 275 default:
272 assert(false); 276 assert(false);
273 } 277 }
274 } 278 }
279
280 // The image to feed to the decoder.
281 EncodedImage copied_image;
282 memcpy(&copied_image, &encoded_image, sizeof(copied_image));
283 // Make a raw copy of the |encoded_image| buffer.
275 rtc::scoped_ptr<uint8_t[]> copied_buffer(new uint8_t[encoded_image._length]); 284 rtc::scoped_ptr<uint8_t[]> copied_buffer(new uint8_t[encoded_image._length]);
276 memcpy(copied_buffer.get(), encoded_image._buffer, encoded_image._length); 285 memcpy(copied_buffer.get(), encoded_image._buffer, encoded_image._length);
277 EncodedImage copied_image;
278 memcpy(&copied_image, &encoded_image, sizeof(copied_image));
279 copied_image._size = copied_image._length; 286 copied_image._size = copied_image._length;
280 copied_image._buffer = copied_buffer.get(); 287 copied_image._buffer = copied_buffer.get();
288
281 if (!exclude_this_frame) { 289 if (!exclude_this_frame) {
282 stat.packets_dropped = 290 stat.packets_dropped =
283 packet_manipulator_->ManipulatePackets(&copied_image); 291 packet_manipulator_->ManipulatePackets(&copied_image);
284 } 292 }
285 293
286 // Keep track of if frames are lost due to packet loss so we can tell 294 // Keep track of if frames are lost due to packet loss so we can tell
287 // this to the encoder (this is handled by the RTP logic in the full stack) 295 // this to the encoder (this is handled by the RTP logic in the full stack)
288 decode_start_ = TickTime::Now(); 296 decode_start_ = TickTime::Now();
289 // TODO(kjellander): Pass fragmentation header to the decoder when 297 // TODO(kjellander): Pass fragmentation header to the decoder when
290 // CL 172001 has been submitted and PacketManipulator supports this. 298 // CL 172001 has been submitted and PacketManipulator supports this.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 return "Unknown"; 410 return "Unknown";
403 } 411 }
404 } 412 }
405 413
406 // Callbacks 414 // Callbacks
407 int32_t 415 int32_t
408 VideoProcessorImpl::VideoProcessorEncodeCompleteCallback::Encoded( 416 VideoProcessorImpl::VideoProcessorEncodeCompleteCallback::Encoded(
409 const EncodedImage& encoded_image, 417 const EncodedImage& encoded_image,
410 const webrtc::CodecSpecificInfo* codec_specific_info, 418 const webrtc::CodecSpecificInfo* codec_specific_info,
411 const webrtc::RTPFragmentationHeader* fragmentation) { 419 const webrtc::RTPFragmentationHeader* fragmentation) {
412 video_processor_->FrameEncoded(encoded_image); // Forward to parent class. 420 // Forward to parent class.
421 video_processor_->FrameEncoded(encoded_image, fragmentation);
413 return 0; 422 return 0;
414 } 423 }
415 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded( 424 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded(
416 VideoFrame& image) { 425 VideoFrame& image) {
417 video_processor_->FrameDecoded(image); // forward to parent class 426 // Forward to parent class.
427 video_processor_->FrameDecoded(image);
418 return 0; 428 return 0;
419 } 429 }
420 430
421 } // namespace test 431 } // namespace test
422 } // namespace webrtc 432 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698