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 |
| 11 #ifndef WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ | 11 #ifndef WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ |
|
the sun
2016/11/24 10:36:59
Change name of this file to i420_buffer.h ?
nisse-webrtc
2016/11/25 08:58:02
Since this cl is already pretty large, I'd prefer
| |
| 12 #define WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ | 12 #define WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ |
| 13 | 13 |
| 14 #include <stdint.h> | |
| 15 | |
| 16 #include <memory> | 14 #include <memory> |
| 17 | 15 |
| 16 #include "webrtc/api/video/rotation.h" | |
| 17 #include "webrtc/api/video/video_frame_buffer.h" | |
| 18 #include "webrtc/base/callback.h" | 18 #include "webrtc/base/callback.h" |
| 19 #include "webrtc/base/refcount.h" | |
| 20 #include "webrtc/base/scoped_ref_ptr.h" | 19 #include "webrtc/base/scoped_ref_ptr.h" |
| 21 #include "webrtc/common_video/rotation.h" | |
| 22 #include "webrtc/system_wrappers/include/aligned_malloc.h" | 20 #include "webrtc/system_wrappers/include/aligned_malloc.h" |
| 23 | 21 |
| 24 namespace webrtc { | 22 namespace webrtc { |
| 25 | 23 |
| 26 // Interface of a simple frame buffer containing pixel data. This interface does | |
| 27 // not contain any frame metadata such as rotation, timestamp, pixel_width, etc. | |
| 28 class VideoFrameBuffer : public rtc::RefCountInterface { | |
| 29 public: | |
| 30 // The resolution of the frame in pixels. For formats where some planes are | |
| 31 // subsampled, this is the highest-resolution plane. | |
| 32 virtual int width() const = 0; | |
| 33 virtual int height() const = 0; | |
| 34 | |
| 35 // Returns pointer to the pixel data for a given plane. The memory is owned by | |
| 36 // the VideoFrameBuffer object and must not be freed by the caller. | |
| 37 virtual const uint8_t* DataY() const = 0; | |
| 38 virtual const uint8_t* DataU() const = 0; | |
| 39 virtual const uint8_t* DataV() const = 0; | |
| 40 | |
| 41 // Returns the number of bytes between successive rows for a given plane. | |
| 42 virtual int StrideY() const = 0; | |
| 43 virtual int StrideU() const = 0; | |
| 44 virtual int StrideV() const = 0; | |
| 45 | |
| 46 // Return the handle of the underlying video frame. This is used when the | |
| 47 // frame is backed by a texture. | |
| 48 virtual void* native_handle() const = 0; | |
| 49 | |
| 50 // Returns a new memory-backed frame buffer converted from this buffer's | |
| 51 // native handle. | |
| 52 virtual rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() = 0; | |
| 53 | |
| 54 protected: | |
| 55 virtual ~VideoFrameBuffer(); | |
| 56 }; | |
| 57 | |
| 58 // Plain I420 buffer in standard memory. | 24 // Plain I420 buffer in standard memory. |
| 59 class I420Buffer : public VideoFrameBuffer { | 25 class I420Buffer : public VideoFrameBuffer { |
| 60 public: | 26 public: |
| 61 I420Buffer(int width, int height); | 27 I420Buffer(int width, int height); |
| 62 I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v); | 28 I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v); |
| 63 | 29 |
| 64 static rtc::scoped_refptr<I420Buffer> Create(int width, int height); | 30 static rtc::scoped_refptr<I420Buffer> Create(int width, int height); |
| 65 static rtc::scoped_refptr<I420Buffer> Create(int width, | 31 static rtc::scoped_refptr<I420Buffer> Create(int width, |
| 66 int height, | 32 int height, |
| 67 int stride_y, | 33 int stride_y, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 const uint8_t* const v_plane_; | 179 const uint8_t* const v_plane_; |
| 214 const int y_stride_; | 180 const int y_stride_; |
| 215 const int u_stride_; | 181 const int u_stride_; |
| 216 const int v_stride_; | 182 const int v_stride_; |
| 217 rtc::Callback0<void> no_longer_used_cb_; | 183 rtc::Callback0<void> no_longer_used_cb_; |
| 218 }; | 184 }; |
| 219 | 185 |
| 220 } // namespace webrtc | 186 } // namespace webrtc |
| 221 | 187 |
| 222 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ | 188 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ |
| OLD | NEW |