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