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

Side by Side Diff: remoting/base/util.cc

Issue 13474013: Use libyuv for non-scaling RGB<->YUV conversions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Increase Gradient test thresholds. Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « remoting/DEPS ('k') | remoting/codec/video_decoder_vp8_unittest.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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/base/util.h" 5 #include "remoting/base/util.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "media/base/video_frame.h" 12 #include "media/base/video_frame.h"
13 #include "media/base/yuv_convert.h" 13 #include "media/base/yuv_convert.h"
14 #include "third_party/libyuv/include/libyuv/convert.h"
14 #include "third_party/skia/include/core/SkRegion.h" 15 #include "third_party/skia/include/core/SkRegion.h"
15 16
16 #if defined(OS_POSIX) 17 #if defined(OS_POSIX)
17 #include <pwd.h> 18 #include <pwd.h>
18 #include <sys/types.h> 19 #include <sys/types.h>
19 #include <unistd.h> 20 #include <unistd.h>
20 #endif // defined(OS_POSIX) 21 #endif // defined(OS_POSIX)
21 22
22 using media::VideoFrame; 23 using media::VideoFrame;
23 24
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 int y, 59 int y,
59 int width, 60 int width,
60 int height, 61 int height,
61 int rgb_stride, 62 int rgb_stride,
62 int y_stride, 63 int y_stride,
63 int uv_stride) { 64 int uv_stride) {
64 int rgb_offset = CalculateRGBOffset(x, y, rgb_stride); 65 int rgb_offset = CalculateRGBOffset(x, y, rgb_stride);
65 int y_offset = CalculateYOffset(x, y, y_stride); 66 int y_offset = CalculateYOffset(x, y, y_stride);
66 int uv_offset = CalculateUVOffset(x, y, uv_stride);; 67 int uv_offset = CalculateUVOffset(x, y, uv_stride);;
67 68
68 media::ConvertRGB32ToYUV(rgb_plane + rgb_offset, 69 libyuv::ARGBToI420(rgb_plane + rgb_offset, rgb_stride,
69 y_plane + y_offset, 70 y_plane + y_offset, y_stride,
70 u_plane + uv_offset, 71 u_plane + uv_offset, uv_stride,
71 v_plane + uv_offset, 72 v_plane + uv_offset, uv_stride,
72 width, 73 width, height);
73 height,
74 rgb_stride,
75 y_stride,
76 uv_stride);
77 } 74 }
78 75
79 void ConvertAndScaleYUVToRGB32Rect(const uint8* source_yplane, 76 void ConvertAndScaleYUVToRGB32Rect(const uint8* source_yplane,
80 const uint8* source_uplane, 77 const uint8* source_uplane,
81 const uint8* source_vplane, 78 const uint8* source_vplane,
82 int source_ystride, 79 int source_ystride,
83 int source_uvstride, 80 int source_uvstride,
84 const SkISize& source_size, 81 const SkISize& source_size,
85 const SkIRect& source_buffer_rect, 82 const SkIRect& source_buffer_rect,
86 uint8* dest_buffer, 83 uint8* dest_buffer,
(...skipping 17 matching lines...) Expand all
104 int uv_offset = - CalculateUVOffset(source_buffer_rect.x(), 101 int uv_offset = - CalculateUVOffset(source_buffer_rect.x(),
105 source_buffer_rect.y(), 102 source_buffer_rect.y(),
106 source_uvstride); 103 source_uvstride);
107 int rgb_offset = - CalculateRGBOffset(dest_buffer_rect.x(), 104 int rgb_offset = - CalculateRGBOffset(dest_buffer_rect.x(),
108 dest_buffer_rect.y(), 105 dest_buffer_rect.y(),
109 dest_stride); 106 dest_stride);
110 107
111 // See if scaling is needed. 108 // See if scaling is needed.
112 if (source_size == dest_size) { 109 if (source_size == dest_size) {
113 // Calculate the inner rectangle that can be copied by the optimized 110 // Calculate the inner rectangle that can be copied by the optimized
114 // ConvertYUVToRGB32(). 111 // libyuv::I420ToARGB().
115 SkIRect inner_rect = 112 SkIRect inner_rect =
116 SkIRect::MakeLTRB(RoundToTwosMultiple(dest_rect.left() + 1), 113 SkIRect::MakeLTRB(RoundToTwosMultiple(dest_rect.left() + 1),
117 RoundToTwosMultiple(dest_rect.top() + 1), 114 RoundToTwosMultiple(dest_rect.top() + 1),
118 dest_rect.right(), 115 dest_rect.right(),
119 dest_rect.bottom()); 116 dest_rect.bottom());
120 117
121 // Offset pointers to point to the top left corner of the inner rectangle. 118 // Offset pointers to point to the top left corner of the inner rectangle.
122 y_offset += CalculateYOffset(inner_rect.x(), inner_rect.y(), 119 y_offset += CalculateYOffset(inner_rect.x(), inner_rect.y(),
123 source_ystride); 120 source_ystride);
124 uv_offset += CalculateUVOffset(inner_rect.x(), inner_rect.y(), 121 uv_offset += CalculateUVOffset(inner_rect.x(), inner_rect.y(),
125 source_uvstride); 122 source_uvstride);
126 rgb_offset += CalculateRGBOffset(inner_rect.x(), inner_rect.y(), 123 rgb_offset += CalculateRGBOffset(inner_rect.x(), inner_rect.y(),
127 dest_stride); 124 dest_stride);
128 125
129 media::ConvertYUVToRGB32(source_yplane + y_offset, 126 libyuv::I420ToARGB(source_yplane + y_offset, source_ystride,
130 source_uplane + uv_offset, 127 source_uplane + uv_offset, source_uvstride,
131 source_vplane + uv_offset, 128 source_vplane + uv_offset, source_uvstride,
132 dest_buffer + rgb_offset, 129 dest_buffer + rgb_offset, dest_stride,
133 inner_rect.width(), 130 inner_rect.width(), inner_rect.height());
134 inner_rect.height(),
135 source_ystride,
136 source_uvstride,
137 dest_stride,
138 media::YV12);
139 131
140 // Now see if some pixels weren't copied due to alignment. 132 // Now see if some pixels weren't copied due to alignment.
141 if (dest_rect != inner_rect) { 133 if (dest_rect != inner_rect) {
142 SkIRect outer_rect = 134 SkIRect outer_rect =
143 SkIRect::MakeLTRB(RoundToTwosMultiple(dest_rect.left()), 135 SkIRect::MakeLTRB(RoundToTwosMultiple(dest_rect.left()),
144 RoundToTwosMultiple(dest_rect.top()), 136 RoundToTwosMultiple(dest_rect.top()),
145 dest_rect.right(), 137 dest_rect.right(),
146 dest_rect.bottom()); 138 dest_rect.bottom());
147 139
148 SkIPoint offset = SkIPoint::Make(outer_rect.x() - inner_rect.x(), 140 SkIPoint offset = SkIPoint::Make(outer_rect.x() - inner_rect.x(),
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 getpwuid_r(getuid(), &passwd, buf.get(), buf_size, &passwd_result); 320 getpwuid_r(getuid(), &passwd, buf.get(), buf_size, &passwd_result);
329 if (!passwd_result) 321 if (!passwd_result)
330 return std::string(); 322 return std::string();
331 return std::string(passwd_result->pw_name); 323 return std::string(passwd_result->pw_name);
332 #else // !defined(OS_POSIX) 324 #else // !defined(OS_POSIX)
333 return std::string(); 325 return std::string();
334 #endif // defined(OS_POSIX) 326 #endif // defined(OS_POSIX)
335 } 327 }
336 328
337 } // namespace remoting 329 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/DEPS ('k') | remoting/codec/video_decoder_vp8_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698