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

Side by Side Diff: media/base/simd/convert_rgb_to_yuv_c.cc

Issue 2694113002: Delete media/base/yuv_convert and dependents. Prefer libyuv. (Closed)
Patch Set: Fix media_unittests. Created 3 years, 10 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 | « media/base/simd/convert_rgb_to_yuv.h ('k') | media/base/simd/convert_rgb_to_yuv_sse2.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stdint.h>
6
7 #include "build/build_config.h"
8 #include "media/base/simd/convert_rgb_to_yuv.h"
9
10 namespace media {
11
12 static int clip_byte(int x) {
13 if (x > 255)
14 return 255;
15 else if (x < 0)
16 return 0;
17 else
18 return x;
19 }
20
21 void ConvertRGB32ToYUV_C(const uint8_t* rgbframe,
22 uint8_t* yplane,
23 uint8_t* uplane,
24 uint8_t* vplane,
25 int width,
26 int height,
27 int rgbstride,
28 int ystride,
29 int uvstride) {
30 #if defined(OS_ANDROID)
31 const int r = 0;
32 const int g = 1;
33 const int b = 2;
34 #else
35 const int r = 2;
36 const int g = 1;
37 const int b = 0;
38 #endif
39
40 for (int i = 0; i < height; ++i) {
41 for (int j = 0; j < width; ++j) {
42 // Since the input pixel format is RGB32, there are 4 bytes per pixel.
43 const uint8_t* pixel = rgbframe + 4 * j;
44 yplane[j] = clip_byte(((pixel[r] * 66 + pixel[g] * 129 +
45 pixel[b] * 25 + 128) >> 8) + 16);
46 if (i % 2 == 0 && j % 2 == 0) {
47 uplane[j / 2] = clip_byte(((pixel[r] * -38 + pixel[g] * -74 +
48 pixel[b] * 112 + 128) >> 8) + 128);
49 vplane[j / 2] = clip_byte(((pixel[r] * 112 + pixel[g] * -94 +
50 pixel[b] * -18 + 128) >> 8) + 128);
51 }
52 }
53 rgbframe += rgbstride;
54 yplane += ystride;
55 if (i % 2 == 0) {
56 uplane += uvstride;
57 vplane += uvstride;
58 }
59 }
60 }
61
62 void ConvertRGB24ToYUV_C(const uint8_t* rgbframe,
63 uint8_t* yplane,
64 uint8_t* uplane,
65 uint8_t* vplane,
66 int width,
67 int height,
68 int rgbstride,
69 int ystride,
70 int uvstride) {
71 for (int i = 0; i < height; ++i) {
72 for (int j = 0; j < width; ++j) {
73 // Since the input pixel format is RGB24, there are 3 bytes per pixel.
74 const uint8_t* pixel = rgbframe + 3 * j;
75 yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 +
76 pixel[0] * 25 + 128) >> 8) + 16);
77 if (i % 2 == 0 && j % 2 == 0) {
78 uplane[j / 2] = clip_byte(((pixel[2] * -38 + pixel[1] * -74 +
79 pixel[0] * 112 + 128) >> 8) + 128);
80 vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 +
81 pixel[0] * -18 + 128) >> 8) + 128);
82 }
83 }
84
85 rgbframe += rgbstride;
86 yplane += ystride;
87 if (i % 2 == 0) {
88 uplane += uvstride;
89 vplane += uvstride;
90 }
91 }
92 }
93
94 } // namespace media
OLDNEW
« no previous file with comments | « media/base/simd/convert_rgb_to_yuv.h ('k') | media/base/simd/convert_rgb_to_yuv_sse2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698