OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 int StrideU() const override; | 112 int StrideU() const override; |
113 int StrideV() const override; | 113 int StrideV() const override; |
114 | 114 |
115 void* native_handle() const override; | 115 void* native_handle() const override; |
116 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; | 116 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; |
117 | 117 |
118 // Create a new buffer and copy the pixel data. | 118 // Create a new buffer and copy the pixel data. |
119 static rtc::scoped_refptr<I420Buffer> Copy( | 119 static rtc::scoped_refptr<I420Buffer> Copy( |
120 const rtc::scoped_refptr<VideoFrameBuffer>& buffer); | 120 const rtc::scoped_refptr<VideoFrameBuffer>& buffer); |
121 | 121 |
| 122 // Scale the cropped area of |src| to the size of |this| buffer, and |
| 123 // write the result into |this|. |
| 124 void CropAndScaleFrom(const rtc::scoped_refptr<VideoFrameBuffer>& src, |
| 125 int offset_x, |
| 126 int offset_y, |
| 127 int crop_width, |
| 128 int crop_height); |
| 129 |
| 130 // The common case of a center crop, when needed to adjust the |
| 131 // aspect ratio without distorting the image. |
| 132 void CropAndScaleFrom(const rtc::scoped_refptr<VideoFrameBuffer>& src); |
| 133 |
| 134 // Scale all of |src| to the size of |this| buffer, with no cropping. |
| 135 void ScaleFrom(const rtc::scoped_refptr<VideoFrameBuffer>& src); |
| 136 |
122 protected: | 137 protected: |
123 ~I420Buffer() override; | 138 ~I420Buffer() override; |
124 | 139 |
125 private: | 140 private: |
126 const int width_; | 141 const int width_; |
127 const int height_; | 142 const int height_; |
128 const int stride_y_; | 143 const int stride_y_; |
129 const int stride_u_; | 144 const int stride_u_; |
130 const int stride_v_; | 145 const int stride_v_; |
131 const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_; | 146 const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 const int height_; | 204 const int height_; |
190 const uint8_t* const y_plane_; | 205 const uint8_t* const y_plane_; |
191 const uint8_t* const u_plane_; | 206 const uint8_t* const u_plane_; |
192 const uint8_t* const v_plane_; | 207 const uint8_t* const v_plane_; |
193 const int y_stride_; | 208 const int y_stride_; |
194 const int u_stride_; | 209 const int u_stride_; |
195 const int v_stride_; | 210 const int v_stride_; |
196 rtc::Callback0<void> no_longer_used_cb_; | 211 rtc::Callback0<void> no_longer_used_cb_; |
197 }; | 212 }; |
198 | 213 |
199 // Helper function to crop |buffer| without making a deep copy. May only be used | |
200 // for non-native frames. | |
201 rtc::scoped_refptr<VideoFrameBuffer> ShallowCenterCrop( | |
202 const rtc::scoped_refptr<VideoFrameBuffer>& buffer, | |
203 int cropped_width, | |
204 int cropped_height); | |
205 | |
206 } // namespace webrtc | 214 } // namespace webrtc |
207 | 215 |
208 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ | 216 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ |
OLD | NEW |