Chromium Code Reviews| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 int StrideU() const override; | 115 int StrideU() const override; |
| 116 int StrideV() const override; | 116 int StrideV() const override; |
| 117 | 117 |
| 118 void* native_handle() const override; | 118 void* native_handle() const override; |
| 119 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; | 119 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; |
| 120 | 120 |
| 121 // Create a new buffer and copy the pixel data. | 121 // Create a new buffer and copy the pixel data. |
| 122 static rtc::scoped_refptr<I420Buffer> Copy( | 122 static rtc::scoped_refptr<I420Buffer> Copy( |
| 123 const rtc::scoped_refptr<VideoFrameBuffer>& buffer); | 123 const rtc::scoped_refptr<VideoFrameBuffer>& buffer); |
| 124 | 124 |
| 125 static rtc::scoped_refptr<I420Buffer> Scale( | |
| 126 const rtc::scoped_refptr<VideoFrameBuffer>& buffer, | |
| 127 int dst_width, | |
| 128 int dst_height); | |
| 129 | |
| 130 // Extracts a rectangle of size |crop_width| x |crop_height|, with | |
| 131 // lower left corner at |crop_x|, |crop_y|, and returns a new frame | |
|
perkj_webrtc
2016/05/16 06:48:47
lower left? -really ? isn't this upper left?
| |
| 132 // buffer with the rectangle scaled to size |dst_width| x | |
| 133 // |dst_height|. Note that this function doesn't care about aspect | |
| 134 // ration; typically, callers select |crop_width| and |crop_height| | |
| 135 // so that the aspect ratio is preserved. | |
| 136 static rtc::scoped_refptr<I420Buffer> CropAndScale( | |
| 137 const rtc::scoped_refptr<VideoFrameBuffer>& buffer, | |
| 138 int crop_x, | |
| 139 int crop_y, | |
| 140 int crop_width, | |
| 141 int crop_height, | |
| 142 int dst_width, | |
| 143 int dst_height); | |
| 144 | |
| 125 protected: | 145 protected: |
| 126 ~I420Buffer() override; | 146 ~I420Buffer() override; |
| 127 | 147 |
| 128 private: | 148 private: |
| 129 const int width_; | 149 const int width_; |
| 130 const int height_; | 150 const int height_; |
| 131 const int stride_y_; | 151 const int stride_y_; |
| 132 const int stride_u_; | 152 const int stride_u_; |
| 133 const int stride_v_; | 153 const int stride_v_; |
| 134 const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_; | 154 const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 const uint8_t* DataU() const override; | 200 const uint8_t* DataU() const override; |
| 181 const uint8_t* DataV() const override; | 201 const uint8_t* DataV() const override; |
| 182 int StrideY() const override; | 202 int StrideY() const override; |
| 183 int StrideU() const override; | 203 int StrideU() const override; |
| 184 int StrideV() const override; | 204 int StrideV() const override; |
| 185 | 205 |
| 186 void* native_handle() const override; | 206 void* native_handle() const override; |
| 187 | 207 |
| 188 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; | 208 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; |
| 189 | 209 |
| 210 // Helper function to crop |buffer| without making a deep copy. May | |
| 211 // only be used for non-native frames. | |
| 212 static rtc::scoped_refptr<WrappedI420Buffer> ShallowCrop( | |
| 213 const rtc::scoped_refptr<VideoFrameBuffer>& buffer, | |
| 214 int crop_x, | |
| 215 int crop_y, | |
| 216 int cropped_width, | |
| 217 int cropped_height); | |
| 218 | |
| 190 private: | 219 private: |
| 191 friend class rtc::RefCountedObject<WrappedI420Buffer>; | 220 friend class rtc::RefCountedObject<WrappedI420Buffer>; |
| 192 ~WrappedI420Buffer() override; | 221 ~WrappedI420Buffer() override; |
| 193 | 222 |
| 194 const int width_; | 223 const int width_; |
| 195 const int height_; | 224 const int height_; |
| 196 const uint8_t* const y_plane_; | 225 const uint8_t* const y_plane_; |
| 197 const uint8_t* const u_plane_; | 226 const uint8_t* const u_plane_; |
| 198 const uint8_t* const v_plane_; | 227 const uint8_t* const v_plane_; |
| 199 const int y_stride_; | 228 const int y_stride_; |
| 200 const int u_stride_; | 229 const int u_stride_; |
| 201 const int v_stride_; | 230 const int v_stride_; |
| 202 rtc::Callback0<void> no_longer_used_cb_; | 231 rtc::Callback0<void> no_longer_used_cb_; |
| 203 }; | 232 }; |
| 204 | 233 |
| 205 // Helper function to crop |buffer| without making a deep copy. May only be used | 234 // Helper function to crop |buffer| without making a deep copy. May only be used |
| 206 // for non-native frames. | 235 // for non-native frames. |
| 207 rtc::scoped_refptr<VideoFrameBuffer> ShallowCenterCrop( | 236 rtc::scoped_refptr<VideoFrameBuffer> ShallowCenterCrop( |
| 208 const rtc::scoped_refptr<VideoFrameBuffer>& buffer, | 237 const rtc::scoped_refptr<VideoFrameBuffer>& buffer, |
| 209 int cropped_width, | 238 int cropped_width, |
| 210 int cropped_height); | 239 int cropped_height); |
| 211 | 240 |
| 212 } // namespace webrtc | 241 } // namespace webrtc |
| 213 | 242 |
| 214 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ | 243 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ |
| OLD | NEW |