Chromium Code Reviews| OLD | NEW |
|---|---|
| 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) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 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 for (int i = 0; i < height; ++i) { | 27 for (int i = 0; i < height; ++i) { |
| 28 for (int j = 0; j < width; ++j) { | 28 for (int j = 0; j < width; ++j) { |
| 29 // Since the input pixel format is RGB32, there are 4 bytes per pixel. | 29 // Since the input pixel format is RGB32, there are 4 bytes per pixel. |
| 30 const uint8* pixel = rgbframe + 4 * j; | 30 const uint8* pixel = rgbframe + 4 * j; |
| 31 #if defined(OS_ANDROID) | |
| 32 yplane[j] = clip_byte(((pixel[0] * 66 + pixel[1] * 129 + | |
|
scherkus (not reviewing)
2013/06/19 19:49:50
this is mostly duplicated -- can you instead do so
hkuang1
2013/06/19 23:21:11
Done.
| |
| 33 pixel[2] * 25 + 128) >> 8) + 16); | |
| 34 if (i % 2 == 0 && j % 2 == 0) { | |
| 35 uplane[j / 2] = clip_byte(((pixel[0] * -38 + pixel[1] * -74 + | |
| 36 pixel[2] * 112 + 128) >> 8) + 128); | |
| 37 vplane[j / 2] = clip_byte(((pixel[0] * 112 + pixel[1] * -94 + | |
| 38 pixel[2] * -18 + 128) >> 8) + 128); | |
| 39 } | |
| 40 #else | |
| 31 yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 + | 41 yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 + |
| 32 pixel[0] * 25 + 128) >> 8) + 16); | 42 pixel[0] * 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[2] * -38 + pixel[1] * -74 + |
| 35 pixel[0] * 112 + 128) >> 8) + 128); | 45 pixel[0] * 112 + 128) >> 8) + 128); |
| 36 vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 + | 46 vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 + |
| 37 pixel[0] * -18 + 128) >> 8) + 128); | 47 pixel[0] * -18 + 128) >> 8) + 128); |
| 38 } | 48 } |
| 49 #endif | |
| 39 } | 50 } |
| 40 | |
| 41 rgbframe += rgbstride; | 51 rgbframe += rgbstride; |
| 42 yplane += ystride; | 52 yplane += ystride; |
| 43 if (i % 2 == 0) { | 53 if (i % 2 == 0) { |
| 44 uplane += uvstride; | 54 uplane += uvstride; |
| 45 vplane += uvstride; | 55 vplane += uvstride; |
| 46 } | 56 } |
| 47 } | 57 } |
| 48 } | 58 } |
| 49 | 59 |
| 50 void ConvertRGB24ToYUV_C(const uint8* rgbframe, | 60 void ConvertRGB24ToYUV_C(const uint8* rgbframe, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 73 rgbframe += rgbstride; | 83 rgbframe += rgbstride; |
| 74 yplane += ystride; | 84 yplane += ystride; |
| 75 if (i % 2 == 0) { | 85 if (i % 2 == 0) { |
| 76 uplane += uvstride; | 86 uplane += uvstride; |
| 77 vplane += uvstride; | 87 vplane += uvstride; |
| 78 } | 88 } |
| 79 } | 89 } |
| 80 } | 90 } |
| 81 | 91 |
| 82 } // namespace media | 92 } // namespace media |
| OLD | NEW |