| 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 12 matching lines...) Expand all Loading... |
| 23 class I420Buffer : public PlanarYuvBuffer { | 23 class I420Buffer : public PlanarYuvBuffer { |
| 24 public: | 24 public: |
| 25 static rtc::scoped_refptr<I420Buffer> Create(int width, int height); | 25 static rtc::scoped_refptr<I420Buffer> Create(int width, int height); |
| 26 static rtc::scoped_refptr<I420Buffer> Create(int width, | 26 static rtc::scoped_refptr<I420Buffer> Create(int width, |
| 27 int height, | 27 int height, |
| 28 int stride_y, | 28 int stride_y, |
| 29 int stride_u, | 29 int stride_u, |
| 30 int stride_v); | 30 int stride_v); |
| 31 | 31 |
| 32 // Create a new buffer and copy the pixel data. | 32 // Create a new buffer and copy the pixel data. |
| 33 static rtc::scoped_refptr<I420Buffer> Copy(const VideoFrameBuffer& buffer); | 33 static rtc::scoped_refptr<I420Buffer> Copy(const PlanarYuvBuffer& buffer); |
| 34 | 34 |
| 35 static rtc::scoped_refptr<I420Buffer> Copy( | 35 static rtc::scoped_refptr<I420Buffer> Copy( |
| 36 int width, int height, | 36 int width, int height, |
| 37 const uint8_t* data_y, int stride_y, | 37 const uint8_t* data_y, int stride_y, |
| 38 const uint8_t* data_u, int stride_u, | 38 const uint8_t* data_u, int stride_u, |
| 39 const uint8_t* data_v, int stride_v); | 39 const uint8_t* data_v, int stride_v); |
| 40 | 40 |
| 41 // Returns a rotated copy of |src|. | 41 // Returns a rotated copy of |src|. |
| 42 static rtc::scoped_refptr<I420Buffer> Rotate(const VideoFrameBuffer& src, | 42 static rtc::scoped_refptr<I420Buffer> Rotate(const PlanarYuvBuffer& src, |
| 43 VideoRotation rotation); | 43 VideoRotation rotation); |
| 44 | 44 |
| 45 // Sets the buffer to all black. | 45 // Sets the buffer to all black. |
| 46 static void SetBlack(I420Buffer* buffer); | 46 static void SetBlack(I420Buffer* buffer); |
| 47 | 47 |
| 48 // Sets all three planes to all zeros. Used to work around for | 48 // Sets all three planes to all zeros. Used to work around for |
| 49 // quirks in memory checkers | 49 // quirks in memory checkers |
| 50 // (https://bugs.chromium.org/p/libyuv/issues/detail?id=377) and | 50 // (https://bugs.chromium.org/p/libyuv/issues/detail?id=377) and |
| 51 // ffmpeg (http://crbug.com/390941). | 51 // ffmpeg (http://crbug.com/390941). |
| 52 // TODO(nisse): Deprecated. Should be deleted if/when those issues | 52 // TODO(nisse): Deprecated. Should be deleted if/when those issues |
| (...skipping 10 matching lines...) Expand all Loading... |
| 63 int StrideY() const override; | 63 int StrideY() const override; |
| 64 int StrideU() const override; | 64 int StrideU() const override; |
| 65 int StrideV() const override; | 65 int StrideV() const override; |
| 66 | 66 |
| 67 uint8_t* MutableDataY(); | 67 uint8_t* MutableDataY(); |
| 68 uint8_t* MutableDataU(); | 68 uint8_t* MutableDataU(); |
| 69 uint8_t* MutableDataV(); | 69 uint8_t* MutableDataV(); |
| 70 | 70 |
| 71 // Scale the cropped area of |src| to the size of |this| buffer, and | 71 // Scale the cropped area of |src| to the size of |this| buffer, and |
| 72 // write the result into |this|. | 72 // write the result into |this|. |
| 73 void CropAndScaleFrom(const VideoFrameBuffer& src, | 73 void CropAndScaleFrom(const PlanarYuvBuffer& src, |
| 74 int offset_x, | 74 int offset_x, |
| 75 int offset_y, | 75 int offset_y, |
| 76 int crop_width, | 76 int crop_width, |
| 77 int crop_height); | 77 int crop_height); |
| 78 | 78 |
| 79 // The common case of a center crop, when needed to adjust the | 79 // The common case of a center crop, when needed to adjust the |
| 80 // aspect ratio without distorting the image. | 80 // aspect ratio without distorting the image. |
| 81 void CropAndScaleFrom(const VideoFrameBuffer& src); | 81 void CropAndScaleFrom(const PlanarYuvBuffer& src); |
| 82 | 82 |
| 83 // Scale all of |src| to the size of |this| buffer, with no cropping. | 83 // Scale all of |src| to the size of |this| buffer, with no cropping. |
| 84 void ScaleFrom(const VideoFrameBuffer& src); | 84 void ScaleFrom(const PlanarYuvBuffer& src); |
| 85 | 85 |
| 86 protected: | 86 protected: |
| 87 I420Buffer(int width, int height); | 87 I420Buffer(int width, int height); |
| 88 I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v); | 88 I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v); |
| 89 | 89 |
| 90 ~I420Buffer() override; | 90 ~I420Buffer() override; |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 const int width_; | 93 const int width_; |
| 94 const int height_; | 94 const int height_; |
| 95 const int stride_y_; | 95 const int stride_y_; |
| 96 const int stride_u_; | 96 const int stride_u_; |
| 97 const int stride_v_; | 97 const int stride_v_; |
| 98 const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_; | 98 const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_; |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace webrtc | 101 } // namespace webrtc |
| 102 | 102 |
| 103 #endif // WEBRTC_API_VIDEO_I420_BUFFER_H_ | 103 #endif // WEBRTC_API_VIDEO_I420_BUFFER_H_ |
| OLD | NEW |