OLD | NEW |
---|---|
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 source_buffer_(NULL), | 59 source_buffer_(NULL), |
60 first_key_frame_has_been_excluded_(false), | 60 first_key_frame_has_been_excluded_(false), |
61 last_frame_missing_(false), | 61 last_frame_missing_(false), |
62 initialized_(false), | 62 initialized_(false), |
63 encoded_frame_size_(0), | 63 encoded_frame_size_(0), |
64 encoded_frame_type_(kVideoFrameKey), | 64 encoded_frame_type_(kVideoFrameKey), |
65 prev_time_stamp_(0), | 65 prev_time_stamp_(0), |
66 num_dropped_frames_(0), | 66 num_dropped_frames_(0), |
67 num_spatial_resizes_(0), | 67 num_spatial_resizes_(0), |
68 last_encoder_frame_width_(0), | 68 last_encoder_frame_width_(0), |
69 last_encoder_frame_height_(0), | 69 last_encoder_frame_height_(0) { |
70 scaler_() { | |
71 assert(encoder); | 70 assert(encoder); |
72 assert(decoder); | 71 assert(decoder); |
73 assert(frame_reader); | 72 assert(frame_reader); |
74 assert(frame_writer); | 73 assert(frame_writer); |
75 assert(packet_manipulator); | 74 assert(packet_manipulator); |
76 assert(stats); | 75 assert(stats); |
77 } | 76 } |
78 | 77 |
79 bool VideoProcessorImpl::Init() { | 78 bool VideoProcessorImpl::Init() { |
80 // Calculate a factor used for bit rate calculations: | 79 // Calculate a factor used for bit rate calculations: |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 if (static_cast<int>(image.width()) != last_encoder_frame_width_ || | 327 if (static_cast<int>(image.width()) != last_encoder_frame_width_ || |
329 static_cast<int>(image.height()) != last_encoder_frame_height_) { | 328 static_cast<int>(image.height()) != last_encoder_frame_height_) { |
330 ++num_spatial_resizes_; | 329 ++num_spatial_resizes_; |
331 last_encoder_frame_width_ = image.width(); | 330 last_encoder_frame_width_ = image.width(); |
332 last_encoder_frame_height_ = image.height(); | 331 last_encoder_frame_height_ = image.height(); |
333 } | 332 } |
334 // Check if codec size is different from native/original size, and if so, | 333 // Check if codec size is different from native/original size, and if so, |
335 // upsample back to original size: needed for PSNR and SSIM computations. | 334 // upsample back to original size: needed for PSNR and SSIM computations. |
336 if (image.width() != config_.codec_settings->width || | 335 if (image.width() != config_.codec_settings->width || |
337 image.height() != config_.codec_settings->height) { | 336 image.height() != config_.codec_settings->height) { |
338 VideoFrame up_image; | 337 rtc::scoped_refptr<I420Buffer> up_image( |
339 int ret_val = scaler_.Set( | 338 new rtc::RefCountedObject<I420Buffer>(config_.codec_settings->width, |
340 image.width(), image.height(), config_.codec_settings->width, | 339 config_.codec_settings->height)); |
341 config_.codec_settings->height, kI420, kI420, kScaleBilinear); | 340 |
342 assert(ret_val >= 0); | 341 // Should be the same aspect ratio, no cropping needed. |
pbos-webrtc
2016/06/03 14:53:23
I still think the DCHECKs are good here.
nisse-webrtc
2016/06/09 08:10:05
Hmm. I'm afraid the DCHECKs in the earlier patchse
| |
343 if (ret_val < 0) { | 342 up_image->Scale(image.video_frame_buffer()); |
344 fprintf(stderr, "Failed to set scalar for frame: %d, return code: %d\n", | 343 |
345 frame_number, ret_val); | |
346 } | |
347 ret_val = scaler_.Scale(image, &up_image); | |
348 assert(ret_val >= 0); | |
349 if (ret_val < 0) { | |
350 fprintf(stderr, "Failed to scale frame: %d, return code: %d\n", | |
351 frame_number, ret_val); | |
352 } | |
353 // TODO(mikhal): Extracting the buffer for now - need to update test. | 344 // TODO(mikhal): Extracting the buffer for now - need to update test. |
354 size_t length = CalcBufferSize(kI420, up_image.width(), up_image.height()); | 345 size_t length = |
346 CalcBufferSize(kI420, up_image->width(), up_image->height()); | |
355 std::unique_ptr<uint8_t[]> image_buffer(new uint8_t[length]); | 347 std::unique_ptr<uint8_t[]> image_buffer(new uint8_t[length]); |
356 int extracted_length = ExtractBuffer(up_image, length, image_buffer.get()); | 348 int extracted_length = ExtractBuffer(up_image, length, image_buffer.get()); |
357 assert(extracted_length > 0); | 349 assert(extracted_length > 0); |
358 // Update our copy of the last successful frame: | 350 // Update our copy of the last successful frame: |
359 memcpy(last_successful_frame_buffer_, image_buffer.get(), extracted_length); | 351 memcpy(last_successful_frame_buffer_, image_buffer.get(), extracted_length); |
360 bool write_success = frame_writer_->WriteFrame(image_buffer.get()); | 352 bool write_success = frame_writer_->WriteFrame(image_buffer.get()); |
361 assert(write_success); | 353 assert(write_success); |
362 if (!write_success) { | 354 if (!write_success) { |
363 fprintf(stderr, "Failed to write frame %d to disk!", frame_number); | 355 fprintf(stderr, "Failed to write frame %d to disk!", frame_number); |
364 } | 356 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 } | 423 } |
432 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded( | 424 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded( |
433 VideoFrame& image) { | 425 VideoFrame& image) { |
434 // Forward to parent class. | 426 // Forward to parent class. |
435 video_processor_->FrameDecoded(image); | 427 video_processor_->FrameDecoded(image); |
436 return 0; | 428 return 0; |
437 } | 429 } |
438 | 430 |
439 } // namespace test | 431 } // namespace test |
440 } // namespace webrtc | 432 } // namespace webrtc |
OLD | NEW |