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

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: (Alphabetical sorting in common_video.gyp deps) Created 4 years, 10 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 fprintf(stderr, "Failed to encode frame %d, return code: %d\n", 218 fprintf(stderr, "Failed to encode frame %d, return code: %d\n",
219 frame_number, encode_result); 219 frame_number, encode_result);
220 } 220 }
221 stat.encode_return_code = encode_result; 221 stat.encode_return_code = encode_result;
222 return true; 222 return true;
223 } else { 223 } else {
224 return false; // we've reached the last frame 224 return false; // we've reached the last frame
225 } 225 }
226 } 226 }
227 227
228 void VideoProcessorImpl::FrameEncoded(webrtc::VideoCodecType codec, 228 void VideoProcessorImpl::FrameEncoded(
229 const EncodedImage& encoded_image) { 229 webrtc::VideoCodecType codec,
230 const EncodedImage& encoded_image,
231 const webrtc::RTPFragmentationHeader* fragmentation) {
230 // Timestamp is frame number, so this gives us #dropped frames. 232 // Timestamp is frame number, so this gives us #dropped frames.
231 int num_dropped_from_prev_encode = 233 int num_dropped_from_prev_encode =
232 encoded_image._timeStamp - prev_time_stamp_ - 1; 234 encoded_image._timeStamp - prev_time_stamp_ - 1;
233 num_dropped_frames_ += num_dropped_from_prev_encode; 235 num_dropped_frames_ += num_dropped_from_prev_encode;
234 prev_time_stamp_ = encoded_image._timeStamp; 236 prev_time_stamp_ = encoded_image._timeStamp;
235 if (num_dropped_from_prev_encode > 0) { 237 if (num_dropped_from_prev_encode > 0) {
236 // For dropped frames, we write out the last decoded frame to avoid getting 238 // For dropped frames, we write out the last decoded frame to avoid getting
237 // out of sync for the computation of PSNR and SSIM. 239 // out of sync for the computation of PSNR and SSIM.
238 for (int i = 0; i < num_dropped_from_prev_encode; i++) { 240 for (int i = 0; i < num_dropped_from_prev_encode; i++) {
239 frame_writer_->WriteFrame(last_successful_frame_buffer_); 241 frame_writer_->WriteFrame(last_successful_frame_buffer_);
(...skipping 30 matching lines...) Expand all
270 exclude_this_frame = true; 272 exclude_this_frame = true;
271 } 273 }
272 break; 274 break;
273 case kExcludeAllKeyFrames: 275 case kExcludeAllKeyFrames:
274 exclude_this_frame = true; 276 exclude_this_frame = true;
275 break; 277 break;
276 default: 278 default:
277 assert(false); 279 assert(false);
278 } 280 }
279 } 281 }
282
283 // Make a raw copy of the |encoded_image| buffer.
280 size_t copied_buffer_size = encoded_image._length + 284 size_t copied_buffer_size = encoded_image._length +
281 EncodedImage::GetBufferPaddingBytes(codec); 285 EncodedImage::GetBufferPaddingBytes(codec);
282 rtc::scoped_ptr<uint8_t[]> copied_buffer(new uint8_t[copied_buffer_size]); 286 rtc::scoped_ptr<uint8_t[]> copied_buffer(new uint8_t[copied_buffer_size]);
283 memcpy(copied_buffer.get(), encoded_image._buffer, encoded_image._length); 287 memcpy(copied_buffer.get(), encoded_image._buffer, encoded_image._length);
288 // The image to feed to the decoder.
284 EncodedImage copied_image; 289 EncodedImage copied_image;
285 memcpy(&copied_image, &encoded_image, sizeof(copied_image)); 290 memcpy(&copied_image, &encoded_image, sizeof(copied_image));
286 copied_image._size = copied_buffer_size; 291 copied_image._size = copied_buffer_size;
287 copied_image._buffer = copied_buffer.get(); 292 copied_image._buffer = copied_buffer.get();
293
288 if (!exclude_this_frame) { 294 if (!exclude_this_frame) {
289 stat.packets_dropped = 295 stat.packets_dropped =
290 packet_manipulator_->ManipulatePackets(&copied_image); 296 packet_manipulator_->ManipulatePackets(&copied_image);
291 } 297 }
292 298
293 // Keep track of if frames are lost due to packet loss so we can tell 299 // Keep track of if frames are lost due to packet loss so we can tell
294 // this to the encoder (this is handled by the RTP logic in the full stack) 300 // this to the encoder (this is handled by the RTP logic in the full stack)
295 decode_start_ = TickTime::Now(); 301 decode_start_ = TickTime::Now();
296 // TODO(kjellander): Pass fragmentation header to the decoder when 302 // TODO(kjellander): Pass fragmentation header to the decoder when
297 // CL 172001 has been submitted and PacketManipulator supports this. 303 // CL 172001 has been submitted and PacketManipulator supports this.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 assert(false); 414 assert(false);
409 return "Unknown"; 415 return "Unknown";
410 } 416 }
411 } 417 }
412 418
413 // Callbacks 419 // Callbacks
414 int32_t VideoProcessorImpl::VideoProcessorEncodeCompleteCallback::Encoded( 420 int32_t VideoProcessorImpl::VideoProcessorEncodeCompleteCallback::Encoded(
415 const EncodedImage& encoded_image, 421 const EncodedImage& encoded_image,
416 const webrtc::CodecSpecificInfo* codec_specific_info, 422 const webrtc::CodecSpecificInfo* codec_specific_info,
417 const webrtc::RTPFragmentationHeader* fragmentation) { 423 const webrtc::RTPFragmentationHeader* fragmentation) {
424 // Forward to parent class.
418 RTC_CHECK(codec_specific_info); 425 RTC_CHECK(codec_specific_info);
419 video_processor_->FrameEncoded(codec_specific_info->codecType, 426 video_processor_->FrameEncoded(codec_specific_info->codecType,
420 encoded_image); // Forward to parent class. 427 encoded_image,
428 fragmentation);
421 return 0; 429 return 0;
422 } 430 }
423 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded( 431 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded(
424 VideoFrame& image) { 432 VideoFrame& image) {
425 video_processor_->FrameDecoded(image); // Forward to parent class. 433 // Forward to parent class.
434 video_processor_->FrameDecoded(image);
426 return 0; 435 return 0;
427 } 436 }
428 437
429 } // namespace test 438 } // namespace test
430 } // namespace webrtc 439 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698