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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 // Since we are extracting raw pointers from |input_image| to | 748 // Since we are extracting raw pointers from |input_image| to |
749 // |raw_images_[0]|, the resolution of these frames must match. Note that | 749 // |raw_images_[0]|, the resolution of these frames must match. Note that |
750 // |input_image| might be scaled from |frame|. In that case, the resolution of | 750 // |input_image| might be scaled from |frame|. In that case, the resolution of |
751 // |raw_images_[0]| should have been updated in UpdateCodecFrameSize. | 751 // |raw_images_[0]| should have been updated in UpdateCodecFrameSize. |
752 RTC_DCHECK_EQ(input_image.width(), static_cast<int>(raw_images_[0].d_w)); | 752 RTC_DCHECK_EQ(input_image.width(), static_cast<int>(raw_images_[0].d_w)); |
753 RTC_DCHECK_EQ(input_image.height(), static_cast<int>(raw_images_[0].d_h)); | 753 RTC_DCHECK_EQ(input_image.height(), static_cast<int>(raw_images_[0].d_h)); |
754 | 754 |
755 // Image in vpx_image_t format. | 755 // Image in vpx_image_t format. |
756 // Input image is const. VP8's raw image is not defined as const. | 756 // Input image is const. VP8's raw image is not defined as const. |
757 raw_images_[0].planes[VPX_PLANE_Y] = | 757 raw_images_[0].planes[VPX_PLANE_Y] = |
758 const_cast<uint8_t*>(input_image.buffer(kYPlane)); | 758 const_cast<uint8_t*>(input_image.video_frame_buffer()->DataY()); |
759 raw_images_[0].planes[VPX_PLANE_U] = | 759 raw_images_[0].planes[VPX_PLANE_U] = |
760 const_cast<uint8_t*>(input_image.buffer(kUPlane)); | 760 const_cast<uint8_t*>(input_image.video_frame_buffer()->DataU()); |
761 raw_images_[0].planes[VPX_PLANE_V] = | 761 raw_images_[0].planes[VPX_PLANE_V] = |
762 const_cast<uint8_t*>(input_image.buffer(kVPlane)); | 762 const_cast<uint8_t*>(input_image.video_frame_buffer()->DataV()); |
763 | 763 |
764 raw_images_[0].stride[VPX_PLANE_Y] = input_image.stride(kYPlane); | 764 raw_images_[0].stride[VPX_PLANE_Y] = |
765 raw_images_[0].stride[VPX_PLANE_U] = input_image.stride(kUPlane); | 765 input_image.video_frame_buffer()->StrideY(); |
766 raw_images_[0].stride[VPX_PLANE_V] = input_image.stride(kVPlane); | 766 raw_images_[0].stride[VPX_PLANE_U] = |
| 767 input_image.video_frame_buffer()->StrideU(); |
| 768 raw_images_[0].stride[VPX_PLANE_V] = |
| 769 input_image.video_frame_buffer()->StrideV(); |
767 | 770 |
768 for (size_t i = 1; i < encoders_.size(); ++i) { | 771 for (size_t i = 1; i < encoders_.size(); ++i) { |
769 // Scale the image down a number of times by downsampling factor | 772 // Scale the image down a number of times by downsampling factor |
770 libyuv::I420Scale( | 773 libyuv::I420Scale( |
771 raw_images_[i - 1].planes[VPX_PLANE_Y], | 774 raw_images_[i - 1].planes[VPX_PLANE_Y], |
772 raw_images_[i - 1].stride[VPX_PLANE_Y], | 775 raw_images_[i - 1].stride[VPX_PLANE_Y], |
773 raw_images_[i - 1].planes[VPX_PLANE_U], | 776 raw_images_[i - 1].planes[VPX_PLANE_U], |
774 raw_images_[i - 1].stride[VPX_PLANE_U], | 777 raw_images_[i - 1].stride[VPX_PLANE_U], |
775 raw_images_[i - 1].planes[VPX_PLANE_V], | 778 raw_images_[i - 1].planes[VPX_PLANE_V], |
776 raw_images_[i - 1].stride[VPX_PLANE_V], raw_images_[i - 1].d_w, | 779 raw_images_[i - 1].stride[VPX_PLANE_V], raw_images_[i - 1].d_w, |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 return WEBRTC_VIDEO_CODEC_NO_OUTPUT; | 1355 return WEBRTC_VIDEO_CODEC_NO_OUTPUT; |
1353 } | 1356 } |
1354 last_frame_width_ = img->d_w; | 1357 last_frame_width_ = img->d_w; |
1355 last_frame_height_ = img->d_h; | 1358 last_frame_height_ = img->d_h; |
1356 // Allocate memory for decoded image. | 1359 // Allocate memory for decoded image. |
1357 VideoFrame decoded_image(buffer_pool_.CreateBuffer(img->d_w, img->d_h), | 1360 VideoFrame decoded_image(buffer_pool_.CreateBuffer(img->d_w, img->d_h), |
1358 timestamp, 0, kVideoRotation_0); | 1361 timestamp, 0, kVideoRotation_0); |
1359 libyuv::I420Copy(img->planes[VPX_PLANE_Y], img->stride[VPX_PLANE_Y], | 1362 libyuv::I420Copy(img->planes[VPX_PLANE_Y], img->stride[VPX_PLANE_Y], |
1360 img->planes[VPX_PLANE_U], img->stride[VPX_PLANE_U], | 1363 img->planes[VPX_PLANE_U], img->stride[VPX_PLANE_U], |
1361 img->planes[VPX_PLANE_V], img->stride[VPX_PLANE_V], | 1364 img->planes[VPX_PLANE_V], img->stride[VPX_PLANE_V], |
1362 decoded_image.buffer(kYPlane), decoded_image.stride(kYPlane), | 1365 decoded_image.video_frame_buffer()->MutableDataY(), |
1363 decoded_image.buffer(kUPlane), decoded_image.stride(kUPlane), | 1366 decoded_image.video_frame_buffer()->StrideY(), |
1364 decoded_image.buffer(kVPlane), decoded_image.stride(kVPlane), | 1367 decoded_image.video_frame_buffer()->MutableDataU(), |
| 1368 decoded_image.video_frame_buffer()->StrideU(), |
| 1369 decoded_image.video_frame_buffer()->MutableDataV(), |
| 1370 decoded_image.video_frame_buffer()->StrideV(), |
1365 img->d_w, img->d_h); | 1371 img->d_w, img->d_h); |
1366 decoded_image.set_ntp_time_ms(ntp_time_ms); | 1372 decoded_image.set_ntp_time_ms(ntp_time_ms); |
1367 int ret = decode_complete_callback_->Decoded(decoded_image); | 1373 int ret = decode_complete_callback_->Decoded(decoded_image); |
1368 if (ret != 0) | 1374 if (ret != 0) |
1369 return ret; | 1375 return ret; |
1370 | 1376 |
1371 // Remember image format for later | 1377 // Remember image format for later |
1372 image_format_ = img->fmt; | 1378 image_format_ = img->fmt; |
1373 return WEBRTC_VIDEO_CODEC_OK; | 1379 return WEBRTC_VIDEO_CODEC_OK; |
1374 } | 1380 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 return -1; | 1419 return -1; |
1414 } | 1420 } |
1415 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) != | 1421 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) != |
1416 VPX_CODEC_OK) { | 1422 VPX_CODEC_OK) { |
1417 return -1; | 1423 return -1; |
1418 } | 1424 } |
1419 return 0; | 1425 return 0; |
1420 } | 1426 } |
1421 | 1427 |
1422 } // namespace webrtc | 1428 } // namespace webrtc |
OLD | NEW |