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

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

Issue 2020593002: Refactor scaling. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Address Per's comments. Add I420Buffer::Scale helper method. Created 4 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
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 int StrideU() const override; 102 int StrideU() const override;
103 int StrideV() const override; 103 int StrideV() const override;
104 104
105 void* native_handle() const override; 105 void* native_handle() const override;
106 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; 106 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override;
107 107
108 // Create a new buffer and copy the pixel data. 108 // Create a new buffer and copy the pixel data.
109 static rtc::scoped_refptr<I420Buffer> Copy( 109 static rtc::scoped_refptr<I420Buffer> Copy(
110 const rtc::scoped_refptr<VideoFrameBuffer>& buffer); 110 const rtc::scoped_refptr<VideoFrameBuffer>& buffer);
111 111
112 // Scale the cropped area of |src| to the size of |this| buffer, and
113 // write the result into |this|.
114 void CropAndScale(const rtc::scoped_refptr<VideoFrameBuffer>& src,
pbos-webrtc 2016/06/03 14:53:23 I think ScaleFrom is a better name here and below,
nisse-webrtc 2016/06/09 08:10:05 Done.
115 int offset_x,
116 int offset_y,
117 int crop_width,
118 int crop_height);
119
120 // The common case of a center crop, when needed to adjust the
121 // aspect ratio without distorting the image.
122 void CropAndScale(const rtc::scoped_refptr<VideoFrameBuffer>& src);
123
124 // Scale all of |src| to the size of |this| buffer, with no cropping.
125 void Scale(const rtc::scoped_refptr<VideoFrameBuffer>& src);
126
112 protected: 127 protected:
113 ~I420Buffer() override; 128 ~I420Buffer() override;
114 129
115 private: 130 private:
116 const int width_; 131 const int width_;
117 const int height_; 132 const int height_;
118 const int stride_y_; 133 const int stride_y_;
119 const int stride_u_; 134 const int stride_u_;
120 const int stride_v_; 135 const int stride_v_;
121 const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_; 136 const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 const int height_; 194 const int height_;
180 const uint8_t* const y_plane_; 195 const uint8_t* const y_plane_;
181 const uint8_t* const u_plane_; 196 const uint8_t* const u_plane_;
182 const uint8_t* const v_plane_; 197 const uint8_t* const v_plane_;
183 const int y_stride_; 198 const int y_stride_;
184 const int u_stride_; 199 const int u_stride_;
185 const int v_stride_; 200 const int v_stride_;
186 rtc::Callback0<void> no_longer_used_cb_; 201 rtc::Callback0<void> no_longer_used_cb_;
187 }; 202 };
188 203
189 // Helper function to crop |buffer| without making a deep copy. May only be used
190 // for non-native frames.
191 rtc::scoped_refptr<VideoFrameBuffer> ShallowCenterCrop(
192 const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
193 int cropped_width,
194 int cropped_height);
195
196 } // namespace webrtc 204 } // namespace webrtc
197 205
198 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ 206 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698