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

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

Issue 17043007: Fix the WebRTC color bug. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing Andrew's comments. Created 7 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
« no previous file with comments | « no previous file | media/base/simd/convert_yuv_to_rgb_c.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) 2011 The Chromium Authors. All rights reserved. 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 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 "media/base/simd/convert_rgb_to_yuv.h" 5 #include "media/base/simd/convert_rgb_to_yuv.h"
6 6
7 namespace media { 7 namespace media {
8 8
9 static int clip_byte(int x) { 9 static int clip_byte(int x) {
10 if (x > 255) 10 if (x > 255)
11 return 255; 11 return 255;
12 else if (x < 0) 12 else if (x < 0)
13 return 0; 13 return 0;
14 else 14 else
15 return x; 15 return x;
16 } 16 }
17 17
18 void ConvertRGB32ToYUV_C(const uint8* rgbframe, 18 void ConvertRGB32ToYUV_C(const uint8* rgbframe,
19 uint8* yplane, 19 uint8* yplane,
20 uint8* uplane, 20 uint8* uplane,
21 uint8* vplane, 21 uint8* vplane,
22 int width, 22 int width,
23 int height, 23 int height,
24 int rgbstride, 24 int rgbstride,
25 int ystride, 25 int ystride,
26 int uvstride) { 26 int uvstride) {
27 #if defined(OS_ANDROID)
28 const int r = 0;
29 const int g = 1;
30 const int b = 2;
31 #else
32 const int r = 2;
33 const int g = 1;
34 const int b = 0;
35 #endif
36
27 for (int i = 0; i < height; ++i) { 37 for (int i = 0; i < height; ++i) {
28 for (int j = 0; j < width; ++j) { 38 for (int j = 0; j < width; ++j) {
29 // Since the input pixel format is RGB32, there are 4 bytes per pixel. 39 // Since the input pixel format is RGB32, there are 4 bytes per pixel.
30 const uint8* pixel = rgbframe + 4 * j; 40 const uint8* pixel = rgbframe + 4 * j;
31 yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 + 41 yplane[j] = clip_byte(((pixel[r] * 66 + pixel[g] * 129 +
32 pixel[0] * 25 + 128) >> 8) + 16); 42 pixel[b] * 25 + 128) >> 8) + 16);
33 if (i % 2 == 0 && j % 2 == 0) { 43 if (i % 2 == 0 && j % 2 == 0) {
34 uplane[j / 2] = clip_byte(((pixel[2] * -38 + pixel[1] * -74 + 44 uplane[j / 2] = clip_byte(((pixel[r] * -38 + pixel[g] * -74 +
35 pixel[0] * 112 + 128) >> 8) + 128); 45 pixel[b] * 112 + 128) >> 8) + 128);
36 vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 + 46 vplane[j / 2] = clip_byte(((pixel[r] * 112 + pixel[g] * -94 +
37 pixel[0] * -18 + 128) >> 8) + 128); 47 pixel[b] * -18 + 128) >> 8) + 128);
38 } 48 }
39 } 49 }
40
41 rgbframe += rgbstride; 50 rgbframe += rgbstride;
42 yplane += ystride; 51 yplane += ystride;
43 if (i % 2 == 0) { 52 if (i % 2 == 0) {
44 uplane += uvstride; 53 uplane += uvstride;
45 vplane += uvstride; 54 vplane += uvstride;
46 } 55 }
47 } 56 }
48 } 57 }
49 58
50 void ConvertRGB24ToYUV_C(const uint8* rgbframe, 59 void ConvertRGB24ToYUV_C(const uint8* rgbframe,
(...skipping 22 matching lines...) Expand all
73 rgbframe += rgbstride; 82 rgbframe += rgbstride;
74 yplane += ystride; 83 yplane += ystride;
75 if (i % 2 == 0) { 84 if (i % 2 == 0) {
76 uplane += uvstride; 85 uplane += uvstride;
77 vplane += uvstride; 86 vplane += uvstride;
78 } 87 }
79 } 88 }
80 } 89 }
81 90
82 } // namespace media 91 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/base/simd/convert_yuv_to_rgb_c.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698