| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 int VideoProcessorImpl::NumberSpatialResizes() { | 239 int VideoProcessorImpl::NumberSpatialResizes() { |
| 240 return num_spatial_resizes_; | 240 return num_spatial_resizes_; |
| 241 } | 241 } |
| 242 | 242 |
| 243 bool VideoProcessorImpl::ProcessFrame(int frame_number) { | 243 bool VideoProcessorImpl::ProcessFrame(int frame_number) { |
| 244 RTC_DCHECK_GE(frame_number, 0); | 244 RTC_DCHECK_GE(frame_number, 0); |
| 245 RTC_DCHECK_LE(frame_number, frame_infos_.size()) | 245 RTC_DCHECK_LE(frame_number, frame_infos_.size()) |
| 246 << "Must process frames without gaps."; | 246 << "Must process frames without gaps."; |
| 247 RTC_DCHECK(initialized_) << "Attempting to use uninitialized VideoProcessor"; | 247 RTC_DCHECK(initialized_) << "Attempting to use uninitialized VideoProcessor"; |
| 248 | 248 |
| 249 rtc::scoped_refptr<VideoFrameBuffer> buffer( | 249 rtc::scoped_refptr<I420BufferInterface> buffer( |
| 250 analysis_frame_reader_->ReadFrame()); | 250 analysis_frame_reader_->ReadFrame()); |
| 251 | 251 |
| 252 if (!buffer) { | 252 if (!buffer) { |
| 253 // Last frame has been reached. | 253 // Last frame has been reached. |
| 254 return false; | 254 return false; |
| 255 } | 255 } |
| 256 | 256 |
| 257 if (source_frame_writer_) { | 257 if (source_frame_writer_) { |
| 258 size_t length = | 258 size_t length = |
| 259 CalcBufferSize(VideoType::kI420, buffer->width(), buffer->height()); | 259 CalcBufferSize(VideoType::kI420, buffer->width(), buffer->height()); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 // Check if codec size is different from the original size, and if so, | 458 // Check if codec size is different from the original size, and if so, |
| 459 // scale back to original size. This is needed for the PSNR and SSIM | 459 // scale back to original size. This is needed for the PSNR and SSIM |
| 460 // calculations. | 460 // calculations. |
| 461 size_t extracted_length; | 461 size_t extracted_length; |
| 462 rtc::Buffer extracted_buffer; | 462 rtc::Buffer extracted_buffer; |
| 463 if (image.width() != config_.codec_settings->width || | 463 if (image.width() != config_.codec_settings->width || |
| 464 image.height() != config_.codec_settings->height) { | 464 image.height() != config_.codec_settings->height) { |
| 465 rtc::scoped_refptr<I420Buffer> scaled_buffer(I420Buffer::Create( | 465 rtc::scoped_refptr<I420Buffer> scaled_buffer(I420Buffer::Create( |
| 466 config_.codec_settings->width, config_.codec_settings->height)); | 466 config_.codec_settings->width, config_.codec_settings->height)); |
| 467 // Should be the same aspect ratio, no cropping needed. | 467 // Should be the same aspect ratio, no cropping needed. |
| 468 if (image.video_frame_buffer()->native_handle()) { | 468 scaled_buffer->ScaleFrom(*image.video_frame_buffer()->ToI420()); |
| 469 scaled_buffer->ScaleFrom( | |
| 470 *image.video_frame_buffer()->NativeToI420Buffer()); | |
| 471 } else { | |
| 472 scaled_buffer->ScaleFrom(*image.video_frame_buffer()); | |
| 473 } | |
| 474 | 469 |
| 475 size_t length = CalcBufferSize(VideoType::kI420, scaled_buffer->width(), | 470 size_t length = CalcBufferSize(VideoType::kI420, scaled_buffer->width(), |
| 476 scaled_buffer->height()); | 471 scaled_buffer->height()); |
| 477 extracted_buffer.SetSize(length); | 472 extracted_buffer.SetSize(length); |
| 478 extracted_length = | 473 extracted_length = |
| 479 ExtractBuffer(scaled_buffer, length, extracted_buffer.data()); | 474 ExtractBuffer(scaled_buffer, length, extracted_buffer.data()); |
| 480 } else { | 475 } else { |
| 481 // No resize. | 476 // No resize. |
| 482 size_t length = | 477 size_t length = |
| 483 CalcBufferSize(VideoType::kI420, image.width(), image.height()); | 478 CalcBufferSize(VideoType::kI420, image.width(), image.height()); |
| 484 extracted_buffer.SetSize(length); | 479 extracted_buffer.SetSize(length); |
| 485 if (image.video_frame_buffer()->native_handle()) { | 480 extracted_length = ExtractBuffer(image.video_frame_buffer()->ToI420(), |
| 486 extracted_length = | 481 length, extracted_buffer.data()); |
| 487 ExtractBuffer(image.video_frame_buffer()->NativeToI420Buffer(), | |
| 488 length, extracted_buffer.data()); | |
| 489 } else { | |
| 490 extracted_length = ExtractBuffer(image.video_frame_buffer(), length, | |
| 491 extracted_buffer.data()); | |
| 492 } | |
| 493 } | 482 } |
| 494 | 483 |
| 495 RTC_DCHECK_EQ(extracted_length, analysis_frame_writer_->FrameLength()); | 484 RTC_DCHECK_EQ(extracted_length, analysis_frame_writer_->FrameLength()); |
| 496 RTC_CHECK(analysis_frame_writer_->WriteFrame(extracted_buffer.data())); | 485 RTC_CHECK(analysis_frame_writer_->WriteFrame(extracted_buffer.data())); |
| 497 if (decoded_frame_writer_) { | 486 if (decoded_frame_writer_) { |
| 498 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); | 487 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); |
| 499 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); | 488 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); |
| 500 } | 489 } |
| 501 | 490 |
| 502 last_decoded_frame_buffer_ = std::move(extracted_buffer); | 491 last_decoded_frame_buffer_ = std::move(extracted_buffer); |
| 503 } | 492 } |
| 504 | 493 |
| 505 } // namespace test | 494 } // namespace test |
| 506 } // namespace webrtc | 495 } // namespace webrtc |
| OLD | NEW |