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

Side by Side Diff: webrtc/media/base/videoframe.cc

Issue 2287233002: Delete cricket::VideoFrame::ConvertToRgbBuffer. (Closed)
Patch Set: Replace calls to ConvertFromI420 with more specific libyuv conversion. Created 4 years, 3 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) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 #include "webrtc/media/base/videoframe.h" 11 #include "webrtc/media/base/videoframe.h"
12 12
13 #include <string.h> 13 #include <string.h>
14 14
15 #include "libyuv/convert_from.h"
16 #include "libyuv/compare.h"
17 #include "libyuv/planar_functions.h"
18 #include "libyuv/scale.h"
19 #include "webrtc/base/arraysize.h" 15 #include "webrtc/base/arraysize.h"
20 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
21 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
22 #include "webrtc/media/base/videocommon.h" 18 #include "webrtc/media/base/videocommon.h"
23 19
24 namespace cricket { 20 namespace cricket {
25 21
26 size_t VideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc,
27 uint8_t* buffer,
28 size_t size,
29 int stride_rgb) const {
30 const size_t needed = std::abs(stride_rgb) * static_cast<size_t>(height());
31 if (size < needed) {
32 LOG(LS_WARNING) << "RGB buffer is not large enough";
33 return needed;
34 }
35
36 if (libyuv::ConvertFromI420(
37 video_frame_buffer()->DataY(), video_frame_buffer()->StrideY(),
38 video_frame_buffer()->DataU(), video_frame_buffer()->StrideU(),
39 video_frame_buffer()->DataV(), video_frame_buffer()->StrideV(),
40 buffer, stride_rgb, width(), height(), to_fourcc)) {
41 LOG(LS_ERROR) << "RGB type not supported: " << to_fourcc;
42 return 0; // 0 indicates error
43 }
44 return needed;
45 }
46
47 static const size_t kMaxSampleSize = 1000000000u; 22 static const size_t kMaxSampleSize = 1000000000u;
48 // Returns whether a sample is valid. 23 // Returns whether a sample is valid.
49 bool VideoFrame::Validate(uint32_t fourcc, 24 bool VideoFrame::Validate(uint32_t fourcc,
50 int w, 25 int w,
51 int h, 26 int h,
52 const uint8_t* sample, 27 const uint8_t* sample,
53 size_t sample_size) { 28 size_t sample_size) {
54 if (h < 0) { 29 if (h < 0) {
55 h = -h; 30 h = -h;
56 } 31 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 << " expected: " << expected_size 162 << " expected: " << expected_size
188 << " sample[0..3]: " << static_cast<int>(four_samples[0]) 163 << " sample[0..3]: " << static_cast<int>(four_samples[0])
189 << ", " << static_cast<int>(four_samples[1]) 164 << ", " << static_cast<int>(four_samples[1])
190 << ", " << static_cast<int>(four_samples[2]) 165 << ", " << static_cast<int>(four_samples[2])
191 << ", " << static_cast<int>(four_samples[3]); 166 << ", " << static_cast<int>(four_samples[3]);
192 } 167 }
193 return true; 168 return true;
194 } 169 }
195 170
196 } // namespace cricket 171 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698