| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 int64_t render_time_ms, | 44 int64_t render_time_ms, |
| 45 VideoRotation rotation) | 45 VideoRotation rotation) |
| 46 : video_frame_buffer_(buffer), | 46 : video_frame_buffer_(buffer), |
| 47 timestamp_rtp_(timestamp), | 47 timestamp_rtp_(timestamp), |
| 48 ntp_time_ms_(0), | 48 ntp_time_ms_(0), |
| 49 timestamp_us_(render_time_ms * rtc::kNumMicrosecsPerMillisec), | 49 timestamp_us_(render_time_ms * rtc::kNumMicrosecsPerMillisec), |
| 50 rotation_(rotation) { | 50 rotation_(rotation) { |
| 51 RTC_DCHECK(buffer); | 51 RTC_DCHECK(buffer); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void VideoFrame::CreateFrame(const uint8_t* buffer_y, | |
| 55 const uint8_t* buffer_u, | |
| 56 const uint8_t* buffer_v, | |
| 57 int width, | |
| 58 int height, | |
| 59 int stride_y, | |
| 60 int stride_u, | |
| 61 int stride_v, | |
| 62 VideoRotation rotation) { | |
| 63 const int half_height = (height + 1) / 2; | |
| 64 const int expected_size_y = height * stride_y; | |
| 65 const int expected_size_u = half_height * stride_u; | |
| 66 const int expected_size_v = half_height * stride_v; | |
| 67 // Allocate a new buffer. | |
| 68 rtc::scoped_refptr<I420Buffer> buffer_ = | |
| 69 I420Buffer::Create(width, height, stride_y, stride_u, stride_v); | |
| 70 | |
| 71 memcpy(buffer_->MutableDataY(), buffer_y, expected_size_y); | |
| 72 memcpy(buffer_->MutableDataU(), buffer_u, expected_size_u); | |
| 73 memcpy(buffer_->MutableDataV(), buffer_v, expected_size_v); | |
| 74 | |
| 75 video_frame_buffer_ = buffer_; | |
| 76 timestamp_rtp_ = 0; | |
| 77 ntp_time_ms_ = 0; | |
| 78 timestamp_us_ = 0; | |
| 79 rotation_ = rotation; | |
| 80 } | |
| 81 | |
| 82 void VideoFrame::CreateFrame(const uint8_t* buffer, | |
| 83 int width, | |
| 84 int height, | |
| 85 VideoRotation rotation) { | |
| 86 const int stride_y = width; | |
| 87 const int stride_uv = (width + 1) / 2; | |
| 88 | |
| 89 const uint8_t* buffer_y = buffer; | |
| 90 const uint8_t* buffer_u = buffer_y + stride_y * height; | |
| 91 const uint8_t* buffer_v = buffer_u + stride_uv * ((height + 1) / 2); | |
| 92 CreateFrame(buffer_y, buffer_u, buffer_v, width, height, stride_y, | |
| 93 stride_uv, stride_uv, rotation); | |
| 94 } | |
| 95 | |
| 96 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) { | 54 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) { |
| 97 video_frame_buffer_ = videoFrame.video_frame_buffer(); | 55 video_frame_buffer_ = videoFrame.video_frame_buffer(); |
| 98 timestamp_rtp_ = videoFrame.timestamp_rtp_; | 56 timestamp_rtp_ = videoFrame.timestamp_rtp_; |
| 99 ntp_time_ms_ = videoFrame.ntp_time_ms_; | 57 ntp_time_ms_ = videoFrame.ntp_time_ms_; |
| 100 timestamp_us_ = videoFrame.timestamp_us_; | 58 timestamp_us_ = videoFrame.timestamp_us_; |
| 101 rotation_ = videoFrame.rotation_; | 59 rotation_ = videoFrame.rotation_; |
| 102 } | 60 } |
| 103 | 61 |
| 104 int VideoFrame::width() const { | 62 int VideoFrame::width() const { |
| 105 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; | 63 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 130 case kVideoCodecULPFEC: | 88 case kVideoCodecULPFEC: |
| 131 case kVideoCodecGeneric: | 89 case kVideoCodecGeneric: |
| 132 case kVideoCodecUnknown: | 90 case kVideoCodecUnknown: |
| 133 return 0; | 91 return 0; |
| 134 } | 92 } |
| 135 RTC_NOTREACHED(); | 93 RTC_NOTREACHED(); |
| 136 return 0; | 94 return 0; |
| 137 } | 95 } |
| 138 | 96 |
| 139 } // namespace webrtc | 97 } // namespace webrtc |
| OLD | NEW |