Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: webrtc/common_video/interface/video_frame_buffer.h

Issue 1158273010: Re-land "Convert native handles to buffers before encoding." (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/common_video/i420_video_frame_unittest.cc ('k') | webrtc/common_video/video_frame.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // Non-const data access is only allowed if |HasOneRef| is true. 45 // Non-const data access is only allowed if |HasOneRef| is true.
46 virtual uint8_t* data(PlaneType type) = 0; 46 virtual uint8_t* data(PlaneType type) = 0;
47 47
48 // Returns the number of bytes between successive rows for a given plane. 48 // Returns the number of bytes between successive rows for a given plane.
49 virtual int stride(PlaneType type) const = 0; 49 virtual int stride(PlaneType type) const = 0;
50 50
51 // Return the handle of the underlying video frame. This is used when the 51 // Return the handle of the underlying video frame. This is used when the
52 // frame is backed by a texture. 52 // frame is backed by a texture.
53 virtual void* native_handle() const = 0; 53 virtual void* native_handle() const = 0;
54 54
55 // Returns a new memory-backed frame buffer converted from this buffer's
56 // native handle.
57 virtual rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() = 0;
58
55 protected: 59 protected:
56 virtual ~VideoFrameBuffer(); 60 virtual ~VideoFrameBuffer();
57 }; 61 };
58 62
59 // Plain I420 buffer in standard memory. 63 // Plain I420 buffer in standard memory.
60 class I420Buffer : public VideoFrameBuffer { 64 class I420Buffer : public VideoFrameBuffer {
61 public: 65 public:
62 I420Buffer(int width, int height); 66 I420Buffer(int width, int height);
63 I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v); 67 I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v);
64 68
65 int width() const override; 69 int width() const override;
66 int height() const override; 70 int height() const override;
67 const uint8_t* data(PlaneType type) const override; 71 const uint8_t* data(PlaneType type) const override;
68 uint8_t* data(PlaneType type) override; 72 uint8_t* data(PlaneType type) override;
69 int stride(PlaneType type) const override; 73 int stride(PlaneType type) const override;
70 void* native_handle() const override; 74 void* native_handle() const override;
75 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override;
71 76
72 protected: 77 protected:
73 ~I420Buffer() override; 78 ~I420Buffer() override;
74 79
75 private: 80 private:
76 const int width_; 81 const int width_;
77 const int height_; 82 const int height_;
78 const int stride_y_; 83 const int stride_y_;
79 const int stride_u_; 84 const int stride_u_;
80 const int stride_v_; 85 const int stride_v_;
81 const rtc::scoped_ptr<uint8_t, AlignedFreeDeleter> data_; 86 const rtc::scoped_ptr<uint8_t, AlignedFreeDeleter> data_;
82 }; 87 };
83 88
84 // Texture buffer is a VideoFrameBuffer wrapper around a |native_handle|. 89 // Base class for native-handle buffer is a wrapper around a |native_handle|.
85 // |native_handle| must be valid for the lifetime of an instance of this object. 90 // This is used for convenience as most native-handle implementations can share
86 // |no_longer_used| can be used to manage the lifetime of |native_handle|. 91 // many VideoFrame implementations, but need to implement a few others (such
87 class TextureBuffer : public VideoFrameBuffer { 92 // as their own destructors or conversion methods back to software I420).
93 class NativeHandleBuffer : public VideoFrameBuffer {
88 public: 94 public:
89 TextureBuffer(void* native_handle, 95 NativeHandleBuffer(void* native_handle, int width, int height);
90 int width, 96
91 int height,
92 const rtc::Callback0<void>& no_longer_used);
93 int width() const override; 97 int width() const override;
94 int height() const override; 98 int height() const override;
95 const uint8_t* data(PlaneType type) const override; 99 const uint8_t* data(PlaneType type) const override;
96 uint8_t* data(PlaneType type) override; 100 uint8_t* data(PlaneType type) override;
97 int stride(PlaneType type) const override; 101 int stride(PlaneType type) const override;
98 void* native_handle() const override; 102 void* native_handle() const override;
99 103
100 private: 104 protected:
101 friend class rtc::RefCountedObject<TextureBuffer>;
102 ~TextureBuffer() override;
103
104 // |native_handle_| is a raw pointer and not owned by TextureBuffer.
105 void* native_handle_; 105 void* native_handle_;
106 const int width_; 106 const int width_;
107 const int height_; 107 const int height_;
108 rtc::Callback0<void> no_longer_used_cb_;
109 }; 108 };
110 109
111 class WrappedI420Buffer : public webrtc::VideoFrameBuffer { 110 class WrappedI420Buffer : public webrtc::VideoFrameBuffer {
112 public: 111 public:
113 WrappedI420Buffer(int desired_width, 112 WrappedI420Buffer(int desired_width,
114 int desired_height, 113 int desired_height,
115 int width, 114 int width,
116 int height, 115 int height,
117 const uint8_t* y_plane, 116 const uint8_t* y_plane,
118 int y_stride, 117 int y_stride,
119 const uint8_t* u_plane, 118 const uint8_t* u_plane,
120 int u_stride, 119 int u_stride,
121 const uint8_t* v_plane, 120 const uint8_t* v_plane,
122 int v_stride, 121 int v_stride,
123 const rtc::Callback0<void>& no_longer_used); 122 const rtc::Callback0<void>& no_longer_used);
124 int width() const override; 123 int width() const override;
125 int height() const override; 124 int height() const override;
126 125
127 const uint8_t* data(PlaneType type) const override; 126 const uint8_t* data(PlaneType type) const override;
128 uint8_t* data(PlaneType type) override; 127 uint8_t* data(PlaneType type) override;
129 128
130 int stride(PlaneType type) const override; 129 int stride(PlaneType type) const override;
131 void* native_handle() const override; 130 void* native_handle() const override;
132 131
132 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override;
133
133 private: 134 private:
134 friend class rtc::RefCountedObject<WrappedI420Buffer>; 135 friend class rtc::RefCountedObject<WrappedI420Buffer>;
135 ~WrappedI420Buffer() override; 136 ~WrappedI420Buffer() override;
136 137
137 int width_; 138 int width_;
138 int height_; 139 int height_;
139 const uint8_t* y_plane_; 140 const uint8_t* y_plane_;
140 const uint8_t* u_plane_; 141 const uint8_t* u_plane_;
141 const uint8_t* v_plane_; 142 const uint8_t* v_plane_;
142 const int y_stride_; 143 const int y_stride_;
143 const int u_stride_; 144 const int u_stride_;
144 const int v_stride_; 145 const int v_stride_;
145 rtc::Callback0<void> no_longer_used_cb_; 146 rtc::Callback0<void> no_longer_used_cb_;
146 }; 147 };
147 148
148 } // namespace webrtc 149 } // namespace webrtc
149 150
150 #endif // WEBRTC_VIDEO_FRAME_BUFFER_H_ 151 #endif // WEBRTC_VIDEO_FRAME_BUFFER_H_
OLDNEW
« no previous file with comments | « webrtc/common_video/i420_video_frame_unittest.cc ('k') | webrtc/common_video/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698