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

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

Issue 1618853002: VideoProcessorImpl using EncodedImage::GetBufferPaddingBytes. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Setting copied_image._size properly Created 4 years, 11 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 | « webrtc/modules/video_coding/codecs/test/videoprocessor.h ('k') | no next file » | 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 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(const EncodedImage& encoded_image) { 228 void VideoProcessorImpl::FrameEncoded(webrtc::VideoCodecType codec,
229 const EncodedImage& encoded_image) {
229 // Timestamp is frame number, so this gives us #dropped frames. 230 // Timestamp is frame number, so this gives us #dropped frames.
230 int num_dropped_from_prev_encode = 231 int num_dropped_from_prev_encode =
231 encoded_image._timeStamp - prev_time_stamp_ - 1; 232 encoded_image._timeStamp - prev_time_stamp_ - 1;
232 num_dropped_frames_ += num_dropped_from_prev_encode; 233 num_dropped_frames_ += num_dropped_from_prev_encode;
233 prev_time_stamp_ = encoded_image._timeStamp; 234 prev_time_stamp_ = encoded_image._timeStamp;
234 if (num_dropped_from_prev_encode > 0) { 235 if (num_dropped_from_prev_encode > 0) {
235 // 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
236 // out of sync for the computation of PSNR and SSIM. 237 // out of sync for the computation of PSNR and SSIM.
237 for (int i = 0; i < num_dropped_from_prev_encode; i++) { 238 for (int i = 0; i < num_dropped_from_prev_encode; i++) {
238 frame_writer_->WriteFrame(last_successful_frame_buffer_); 239 frame_writer_->WriteFrame(last_successful_frame_buffer_);
(...skipping 30 matching lines...) Expand all
269 exclude_this_frame = true; 270 exclude_this_frame = true;
270 } 271 }
271 break; 272 break;
272 case kExcludeAllKeyFrames: 273 case kExcludeAllKeyFrames:
273 exclude_this_frame = true; 274 exclude_this_frame = true;
274 break; 275 break;
275 default: 276 default:
276 assert(false); 277 assert(false);
277 } 278 }
278 } 279 }
279 rtc::scoped_ptr<uint8_t[]> copied_buffer(new uint8_t[encoded_image._length]); 280 size_t copied_buffer_size = encoded_image._length +
281 EncodedImage::GetBufferPaddingBytes(codec);
282 rtc::scoped_ptr<uint8_t[]> copied_buffer(new uint8_t[copied_buffer_size]);
280 memcpy(copied_buffer.get(), encoded_image._buffer, encoded_image._length); 283 memcpy(copied_buffer.get(), encoded_image._buffer, encoded_image._length);
281 EncodedImage copied_image; 284 EncodedImage copied_image;
282 memcpy(&copied_image, &encoded_image, sizeof(copied_image)); 285 memcpy(&copied_image, &encoded_image, sizeof(copied_image));
283 copied_image._size = copied_image._length; 286 copied_image._size = copied_buffer_size;
284 copied_image._buffer = copied_buffer.get(); 287 copied_image._buffer = copied_buffer.get();
285 if (!exclude_this_frame) { 288 if (!exclude_this_frame) {
286 stat.packets_dropped = 289 stat.packets_dropped =
287 packet_manipulator_->ManipulatePackets(&copied_image); 290 packet_manipulator_->ManipulatePackets(&copied_image);
288 } 291 }
289 292
290 // Keep track of if frames are lost due to packet loss so we can tell 293 // Keep track of if frames are lost due to packet loss so we can tell
291 // this to the encoder (this is handled by the RTP logic in the full stack) 294 // this to the encoder (this is handled by the RTP logic in the full stack)
292 decode_start_ = TickTime::Now(); 295 decode_start_ = TickTime::Now();
293 // TODO(kjellander): Pass fragmentation header to the decoder when 296 // TODO(kjellander): Pass fragmentation header to the decoder when
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 assert(false); 408 assert(false);
406 return "Unknown"; 409 return "Unknown";
407 } 410 }
408 } 411 }
409 412
410 // Callbacks 413 // Callbacks
411 int32_t VideoProcessorImpl::VideoProcessorEncodeCompleteCallback::Encoded( 414 int32_t VideoProcessorImpl::VideoProcessorEncodeCompleteCallback::Encoded(
412 const EncodedImage& encoded_image, 415 const EncodedImage& encoded_image,
413 const webrtc::CodecSpecificInfo* codec_specific_info, 416 const webrtc::CodecSpecificInfo* codec_specific_info,
414 const webrtc::RTPFragmentationHeader* fragmentation) { 417 const webrtc::RTPFragmentationHeader* fragmentation) {
415 video_processor_->FrameEncoded(encoded_image); // Forward to parent class. 418 RTC_CHECK(codec_specific_info);
419 video_processor_->FrameEncoded(codec_specific_info->codecType,
420 encoded_image); // Forward to parent class.
416 return 0; 421 return 0;
417 } 422 }
418 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded( 423 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded(
419 VideoFrame& image) { 424 VideoFrame& image) {
420 video_processor_->FrameDecoded(image); // forward to parent class 425 video_processor_->FrameDecoded(image); // Forward to parent class.
421 return 0; 426 return 0;
422 } 427 }
423 428
424 } // namespace test 429 } // namespace test
425 } // namespace webrtc 430 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/test/videoprocessor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698