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

Unified Diff: media/base/simd/convert_rgb_to_yuv_sse2.cc

Issue 656663002: Fix type truncation warnings in YUV-related code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove erroneous pragma Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/base/simd/filter_yuv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/simd/convert_rgb_to_yuv_sse2.cc
diff --git a/media/base/simd/convert_rgb_to_yuv_sse2.cc b/media/base/simd/convert_rgb_to_yuv_sse2.cc
index 124671c0c0317e26fec30794756d3f46425e6d43..14778bbd58d1ac1184131314f88f594264a0c97f 100644
--- a/media/base/simd/convert_rgb_to_yuv_sse2.cc
+++ b/media/base/simd/convert_rgb_to_yuv_sse2.cc
@@ -50,15 +50,15 @@ SIMD_ALIGNED(const int16 ConvertRGBAToYUV_kTable[8 * 3]) = {
// components and 128 is added to UV components for 2 pixels.
SIMD_ALIGNED(const int32 kYOffset[4]) = {16, 16, 16, 16};
-static inline int Clamp(int value) {
+static inline uint8 Clamp(int value) {
if (value < 0)
return 0;
if (value > 255)
return 255;
- return value;
+ return static_cast<uint8>(value);
}
-static inline int RGBToY(int r, int g, int b) {
+static inline uint8 RGBToY(int r, int g, int b) {
int y = ConvertRGBAToYUV_kTable[0] * b +
ConvertRGBAToYUV_kTable[1] * g +
ConvertRGBAToYUV_kTable[2] * r;
@@ -66,7 +66,7 @@ static inline int RGBToY(int r, int g, int b) {
return Clamp(y + 16);
}
-static inline int RGBToU(int r, int g, int b, int shift) {
+static inline uint8 RGBToU(int r, int g, int b, int shift) {
int u = ConvertRGBAToYUV_kTable[8] * b +
ConvertRGBAToYUV_kTable[9] * g +
ConvertRGBAToYUV_kTable[10] * r;
@@ -74,7 +74,7 @@ static inline int RGBToU(int r, int g, int b, int shift) {
return Clamp(u + 128);
}
-static inline int RGBToV(int r, int g, int b, int shift) {
+static inline uint8 RGBToV(int r, int g, int b, int shift) {
int v = ConvertRGBAToYUV_kTable[16] * b +
ConvertRGBAToYUV_kTable[17] * g +
ConvertRGBAToYUV_kTable[18] * r;
@@ -269,7 +269,8 @@ static void ConvertRGB32ToYUVRow_SSE2(const uint8* rgb_buf_1,
u_a_b = _mm_add_epi32(u_a_b, uv_offset);
u_a_b = _mm_packs_epi32(u_a_b, u_a_b);
u_a_b = _mm_packus_epi16(u_a_b, u_a_b);
- *reinterpret_cast<uint16*>(u_buf) = _mm_extract_epi16(u_a_b, 0);
+ *reinterpret_cast<uint16*>(u_buf) =
+ static_cast<uint16>(_mm_extract_epi16(u_a_b, 0));
u_buf += 2;
__m128i v_a_b = _mm_madd_epi16(
@@ -282,7 +283,8 @@ static void ConvertRGB32ToYUVRow_SSE2(const uint8* rgb_buf_1,
v_a_b = _mm_add_epi32(v_a_b, uv_offset);
v_a_b = _mm_packs_epi32(v_a_b, v_a_b);
v_a_b = _mm_packus_epi16(v_a_b, v_a_b);
- *reinterpret_cast<uint16*>(v_buf) = _mm_extract_epi16(v_a_b, 0);
+ *reinterpret_cast<uint16*>(v_buf) =
+ static_cast<uint16>(_mm_extract_epi16(v_a_b, 0));
v_buf += 2;
rgb_buf_1 += 16;
« no previous file with comments | « no previous file | media/base/simd/filter_yuv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698