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

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

Issue 1542013004: Switch to standard integer types in media/, take 2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more stddef Created 5 years 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
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 <stdint.h>
6
7 #include "build/build_config.h"
5 #include "media/base/simd/convert_rgb_to_yuv.h" 8 #include "media/base/simd/convert_rgb_to_yuv.h"
6 9
7 namespace media { 10 namespace media {
8 11
9 static int clip_byte(int x) { 12 static int clip_byte(int x) {
10 if (x > 255) 13 if (x > 255)
11 return 255; 14 return 255;
12 else if (x < 0) 15 else if (x < 0)
13 return 0; 16 return 0;
14 else 17 else
15 return x; 18 return x;
16 } 19 }
17 20
18 void ConvertRGB32ToYUV_C(const uint8* rgbframe, 21 void ConvertRGB32ToYUV_C(const uint8_t* rgbframe,
19 uint8* yplane, 22 uint8_t* yplane,
20 uint8* uplane, 23 uint8_t* uplane,
21 uint8* vplane, 24 uint8_t* vplane,
22 int width, 25 int width,
23 int height, 26 int height,
24 int rgbstride, 27 int rgbstride,
25 int ystride, 28 int ystride,
26 int uvstride) { 29 int uvstride) {
27 #if defined(OS_ANDROID) 30 #if defined(OS_ANDROID)
28 const int r = 0; 31 const int r = 0;
29 const int g = 1; 32 const int g = 1;
30 const int b = 2; 33 const int b = 2;
31 #else 34 #else
32 const int r = 2; 35 const int r = 2;
33 const int g = 1; 36 const int g = 1;
34 const int b = 0; 37 const int b = 0;
35 #endif 38 #endif
36 39
37 for (int i = 0; i < height; ++i) { 40 for (int i = 0; i < height; ++i) {
38 for (int j = 0; j < width; ++j) { 41 for (int j = 0; j < width; ++j) {
39 // Since the input pixel format is RGB32, there are 4 bytes per pixel. 42 // Since the input pixel format is RGB32, there are 4 bytes per pixel.
40 const uint8* pixel = rgbframe + 4 * j; 43 const uint8_t* pixel = rgbframe + 4 * j;
41 yplane[j] = clip_byte(((pixel[r] * 66 + pixel[g] * 129 + 44 yplane[j] = clip_byte(((pixel[r] * 66 + pixel[g] * 129 +
42 pixel[b] * 25 + 128) >> 8) + 16); 45 pixel[b] * 25 + 128) >> 8) + 16);
43 if (i % 2 == 0 && j % 2 == 0) { 46 if (i % 2 == 0 && j % 2 == 0) {
44 uplane[j / 2] = clip_byte(((pixel[r] * -38 + pixel[g] * -74 + 47 uplane[j / 2] = clip_byte(((pixel[r] * -38 + pixel[g] * -74 +
45 pixel[b] * 112 + 128) >> 8) + 128); 48 pixel[b] * 112 + 128) >> 8) + 128);
46 vplane[j / 2] = clip_byte(((pixel[r] * 112 + pixel[g] * -94 + 49 vplane[j / 2] = clip_byte(((pixel[r] * 112 + pixel[g] * -94 +
47 pixel[b] * -18 + 128) >> 8) + 128); 50 pixel[b] * -18 + 128) >> 8) + 128);
48 } 51 }
49 } 52 }
50 rgbframe += rgbstride; 53 rgbframe += rgbstride;
51 yplane += ystride; 54 yplane += ystride;
52 if (i % 2 == 0) { 55 if (i % 2 == 0) {
53 uplane += uvstride; 56 uplane += uvstride;
54 vplane += uvstride; 57 vplane += uvstride;
55 } 58 }
56 } 59 }
57 } 60 }
58 61
59 void ConvertRGB24ToYUV_C(const uint8* rgbframe, 62 void ConvertRGB24ToYUV_C(const uint8_t* rgbframe,
60 uint8* yplane, 63 uint8_t* yplane,
61 uint8* uplane, 64 uint8_t* uplane,
62 uint8* vplane, 65 uint8_t* vplane,
63 int width, 66 int width,
64 int height, 67 int height,
65 int rgbstride, 68 int rgbstride,
66 int ystride, 69 int ystride,
67 int uvstride) { 70 int uvstride) {
68 for (int i = 0; i < height; ++i) { 71 for (int i = 0; i < height; ++i) {
69 for (int j = 0; j < width; ++j) { 72 for (int j = 0; j < width; ++j) {
70 // Since the input pixel format is RGB24, there are 3 bytes per pixel. 73 // Since the input pixel format is RGB24, there are 3 bytes per pixel.
71 const uint8* pixel = rgbframe + 3 * j; 74 const uint8_t* pixel = rgbframe + 3 * j;
72 yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 + 75 yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 +
73 pixel[0] * 25 + 128) >> 8) + 16); 76 pixel[0] * 25 + 128) >> 8) + 16);
74 if (i % 2 == 0 && j % 2 == 0) { 77 if (i % 2 == 0 && j % 2 == 0) {
75 uplane[j / 2] = clip_byte(((pixel[2] * -38 + pixel[1] * -74 + 78 uplane[j / 2] = clip_byte(((pixel[2] * -38 + pixel[1] * -74 +
76 pixel[0] * 112 + 128) >> 8) + 128); 79 pixel[0] * 112 + 128) >> 8) + 128);
77 vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 + 80 vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 +
78 pixel[0] * -18 + 128) >> 8) + 128); 81 pixel[0] * -18 + 128) >> 8) + 128);
79 } 82 }
80 } 83 }
81 84
82 rgbframe += rgbstride; 85 rgbframe += rgbstride;
83 yplane += ystride; 86 yplane += ystride;
84 if (i % 2 == 0) { 87 if (i % 2 == 0) {
85 uplane += uvstride; 88 uplane += uvstride;
86 vplane += uvstride; 89 vplane += uvstride;
87 } 90 }
88 } 91 }
89 } 92 }
90 93
91 } // namespace media 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