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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 244 |
245 rtc::scoped_refptr<VideoFrameBuffer> buffer( | 245 rtc::scoped_refptr<VideoFrameBuffer> buffer( |
246 analysis_frame_reader_->ReadFrame()); | 246 analysis_frame_reader_->ReadFrame()); |
247 | 247 |
248 if (!buffer) { | 248 if (!buffer) { |
249 // Last frame has been reached. | 249 // Last frame has been reached. |
250 return false; | 250 return false; |
251 } | 251 } |
252 | 252 |
253 if (source_frame_writer_) { | 253 if (source_frame_writer_) { |
254 size_t length = CalcBufferSize(kI420, buffer->width(), buffer->height()); | 254 size_t length = |
| 255 CalcBufferSize(VideoType::kI420, buffer->width(), buffer->height()); |
255 rtc::Buffer extracted_buffer(length); | 256 rtc::Buffer extracted_buffer(length); |
256 int extracted_length = | 257 int extracted_length = |
257 ExtractBuffer(buffer, length, extracted_buffer.data()); | 258 ExtractBuffer(buffer, length, extracted_buffer.data()); |
258 RTC_DCHECK_EQ(extracted_length, source_frame_writer_->FrameLength()); | 259 RTC_DCHECK_EQ(extracted_length, source_frame_writer_->FrameLength()); |
259 RTC_CHECK(source_frame_writer_->WriteFrame(extracted_buffer.data())); | 260 RTC_CHECK(source_frame_writer_->WriteFrame(extracted_buffer.data())); |
260 } | 261 } |
261 | 262 |
262 uint32_t timestamp = FrameNumberToTimestamp(frame_number); | 263 uint32_t timestamp = FrameNumberToTimestamp(frame_number); |
263 VideoFrame source_frame(buffer, timestamp, 0, webrtc::kVideoRotation_0); | 264 VideoFrame source_frame(buffer, timestamp, 0, webrtc::kVideoRotation_0); |
264 | 265 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 rtc::scoped_refptr<I420Buffer> scaled_buffer(I420Buffer::Create( | 461 rtc::scoped_refptr<I420Buffer> scaled_buffer(I420Buffer::Create( |
461 config_.codec_settings->width, config_.codec_settings->height)); | 462 config_.codec_settings->width, config_.codec_settings->height)); |
462 // Should be the same aspect ratio, no cropping needed. | 463 // Should be the same aspect ratio, no cropping needed. |
463 if (image.video_frame_buffer()->native_handle()) { | 464 if (image.video_frame_buffer()->native_handle()) { |
464 scaled_buffer->ScaleFrom( | 465 scaled_buffer->ScaleFrom( |
465 *image.video_frame_buffer()->NativeToI420Buffer()); | 466 *image.video_frame_buffer()->NativeToI420Buffer()); |
466 } else { | 467 } else { |
467 scaled_buffer->ScaleFrom(*image.video_frame_buffer()); | 468 scaled_buffer->ScaleFrom(*image.video_frame_buffer()); |
468 } | 469 } |
469 | 470 |
470 size_t length = | 471 size_t length = CalcBufferSize(VideoType::kI420, scaled_buffer->width(), |
471 CalcBufferSize(kI420, scaled_buffer->width(), scaled_buffer->height()); | 472 scaled_buffer->height()); |
472 extracted_buffer.SetSize(length); | 473 extracted_buffer.SetSize(length); |
473 extracted_length = | 474 extracted_length = |
474 ExtractBuffer(scaled_buffer, length, extracted_buffer.data()); | 475 ExtractBuffer(scaled_buffer, length, extracted_buffer.data()); |
475 } else { | 476 } else { |
476 // No resize. | 477 // No resize. |
477 size_t length = CalcBufferSize(kI420, image.width(), image.height()); | 478 size_t length = |
| 479 CalcBufferSize(VideoType::kI420, image.width(), image.height()); |
478 extracted_buffer.SetSize(length); | 480 extracted_buffer.SetSize(length); |
479 if (image.video_frame_buffer()->native_handle()) { | 481 if (image.video_frame_buffer()->native_handle()) { |
480 extracted_length = | 482 extracted_length = |
481 ExtractBuffer(image.video_frame_buffer()->NativeToI420Buffer(), | 483 ExtractBuffer(image.video_frame_buffer()->NativeToI420Buffer(), |
482 length, extracted_buffer.data()); | 484 length, extracted_buffer.data()); |
483 } else { | 485 } else { |
484 extracted_length = ExtractBuffer(image.video_frame_buffer(), length, | 486 extracted_length = ExtractBuffer(image.video_frame_buffer(), length, |
485 extracted_buffer.data()); | 487 extracted_buffer.data()); |
486 } | 488 } |
487 } | 489 } |
488 | 490 |
489 RTC_DCHECK_EQ(extracted_length, analysis_frame_writer_->FrameLength()); | 491 RTC_DCHECK_EQ(extracted_length, analysis_frame_writer_->FrameLength()); |
490 RTC_CHECK(analysis_frame_writer_->WriteFrame(extracted_buffer.data())); | 492 RTC_CHECK(analysis_frame_writer_->WriteFrame(extracted_buffer.data())); |
491 if (decoded_frame_writer_) { | 493 if (decoded_frame_writer_) { |
492 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); | 494 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); |
493 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); | 495 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); |
494 } | 496 } |
495 | 497 |
496 last_decoded_frame_buffer_ = std::move(extracted_buffer); | 498 last_decoded_frame_buffer_ = std::move(extracted_buffer); |
497 } | 499 } |
498 | 500 |
499 } // namespace test | 501 } // namespace test |
500 } // namespace webrtc | 502 } // namespace webrtc |
OLD | NEW |