OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return -1; | 135 return -1; |
136 } | 136 } |
137 if (PrintPlane(frame.video_frame_buffer()->DataV(), | 137 if (PrintPlane(frame.video_frame_buffer()->DataV(), |
138 chroma_width, chroma_height, | 138 chroma_width, chroma_height, |
139 frame.video_frame_buffer()->StrideV(), file) < 0) { | 139 frame.video_frame_buffer()->StrideV(), file) < 0) { |
140 return -1; | 140 return -1; |
141 } | 141 } |
142 return 0; | 142 return 0; |
143 } | 143 } |
144 | 144 |
145 int ExtractBuffer(const VideoFrame& input_frame, size_t size, uint8_t* buffer) { | 145 int ExtractBuffer(const rtc::scoped_refptr<VideoFrameBuffer>& input_frame, |
| 146 size_t size, |
| 147 uint8_t* buffer) { |
146 assert(buffer); | 148 assert(buffer); |
147 if (input_frame.IsZeroSize()) | 149 if (!input_frame) |
148 return -1; | 150 return -1; |
149 size_t length = | 151 int width = input_frame->width(); |
150 CalcBufferSize(kI420, input_frame.width(), input_frame.height()); | 152 int height = input_frame->height(); |
| 153 size_t length = CalcBufferSize(kI420, width, height); |
151 if (size < length) { | 154 if (size < length) { |
152 return -1; | 155 return -1; |
153 } | 156 } |
154 | 157 |
155 int width = input_frame.video_frame_buffer()->width(); | |
156 int height = input_frame.video_frame_buffer()->height(); | |
157 int chroma_width = (width + 1) / 2; | 158 int chroma_width = (width + 1) / 2; |
158 int chroma_height = (height + 1) / 2; | 159 int chroma_height = (height + 1) / 2; |
159 | 160 |
160 libyuv::I420Copy(input_frame.video_frame_buffer()->DataY(), | 161 libyuv::I420Copy(input_frame->DataY(), |
161 input_frame.video_frame_buffer()->StrideY(), | 162 input_frame->StrideY(), |
162 input_frame.video_frame_buffer()->DataU(), | 163 input_frame->DataU(), |
163 input_frame.video_frame_buffer()->StrideU(), | 164 input_frame->StrideU(), |
164 input_frame.video_frame_buffer()->DataV(), | 165 input_frame->DataV(), |
165 input_frame.video_frame_buffer()->StrideV(), | 166 input_frame->StrideV(), |
166 buffer, width, | 167 buffer, width, |
167 buffer + width*height, chroma_width, | 168 buffer + width*height, chroma_width, |
168 buffer + width*height + chroma_width*chroma_height, | 169 buffer + width*height + chroma_width*chroma_height, |
169 chroma_width, | 170 chroma_width, |
170 width, height); | 171 width, height); |
171 | 172 |
172 return static_cast<int>(length); | 173 return static_cast<int>(length); |
173 } | 174 } |
174 | 175 |
| 176 int ExtractBuffer(const VideoFrame& input_frame, size_t size, uint8_t* buffer) { |
| 177 return ExtractBuffer(input_frame.video_frame_buffer(), size, buffer); |
| 178 } |
175 | 179 |
176 int ConvertNV12ToRGB565(const uint8_t* src_frame, | 180 int ConvertNV12ToRGB565(const uint8_t* src_frame, |
177 uint8_t* dst_frame, | 181 uint8_t* dst_frame, |
178 int width, int height) { | 182 int width, int height) { |
179 int abs_height = (height < 0) ? -height : height; | 183 int abs_height = (height < 0) ? -height : height; |
180 const uint8_t* yplane = src_frame; | 184 const uint8_t* yplane = src_frame; |
181 const uint8_t* uvInterlaced = src_frame + (width * abs_height); | 185 const uint8_t* uvInterlaced = src_frame + (width * abs_height); |
182 | 186 |
183 return libyuv::NV12ToRGB565(yplane, width, | 187 return libyuv::NV12ToRGB565(yplane, width, |
184 uvInterlaced, (width + 1) >> 1, | 188 uvInterlaced, (width + 1) >> 1, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 ref_frame->video_frame_buffer()->StrideV(), | 365 ref_frame->video_frame_buffer()->StrideV(), |
362 test_frame->video_frame_buffer()->DataY(), | 366 test_frame->video_frame_buffer()->DataY(), |
363 test_frame->video_frame_buffer()->StrideY(), | 367 test_frame->video_frame_buffer()->StrideY(), |
364 test_frame->video_frame_buffer()->DataU(), | 368 test_frame->video_frame_buffer()->DataU(), |
365 test_frame->video_frame_buffer()->StrideU(), | 369 test_frame->video_frame_buffer()->StrideU(), |
366 test_frame->video_frame_buffer()->DataV(), | 370 test_frame->video_frame_buffer()->DataV(), |
367 test_frame->video_frame_buffer()->StrideV(), | 371 test_frame->video_frame_buffer()->StrideV(), |
368 test_frame->width(), test_frame->height()); | 372 test_frame->width(), test_frame->height()); |
369 } | 373 } |
370 } // namespace webrtc | 374 } // namespace webrtc |
OLD | NEW |