| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #if defined(_MSC_VER) | 5 #if defined(_MSC_VER) |
| 6 #include <intrin.h> | 6 #include <intrin.h> |
| 7 #else | 7 #else |
| 8 #include <mmintrin.h> | 8 #include <mmintrin.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "media/base/simd/convert_yuv_to_rgb.h" | 11 #include "media/base/simd/convert_yuv_to_rgb.h" |
| 12 #include "media/base/simd/empty_register_state.h" |
| 12 #include "media/base/yuv_convert.h" | 13 #include "media/base/yuv_convert.h" |
| 13 | 14 |
| 14 namespace media { | 15 namespace media { |
| 15 | 16 |
| 16 void ConvertYUVToRGB32_MMX(const uint8* yplane, | 17 void ConvertYUVToRGB32_MMX(const uint8* yplane, |
| 17 const uint8* uplane, | 18 const uint8* uplane, |
| 18 const uint8* vplane, | 19 const uint8* vplane, |
| 19 uint8* rgbframe, | 20 uint8* rgbframe, |
| 20 int width, | 21 int width, |
| 21 int height, | 22 int height, |
| 22 int ystride, | 23 int ystride, |
| 23 int uvstride, | 24 int uvstride, |
| 24 int rgbstride, | 25 int rgbstride, |
| 25 YUVType yuv_type) { | 26 YUVType yuv_type) { |
| 26 unsigned int y_shift = yuv_type; | 27 unsigned int y_shift = yuv_type; |
| 27 for (int y = 0; y < height; ++y) { | 28 for (int y = 0; y < height; ++y) { |
| 28 uint8* rgb_row = rgbframe + y * rgbstride; | 29 uint8* rgb_row = rgbframe + y * rgbstride; |
| 29 const uint8* y_ptr = yplane + y * ystride; | 30 const uint8* y_ptr = yplane + y * ystride; |
| 30 const uint8* u_ptr = uplane + (y >> y_shift) * uvstride; | 31 const uint8* u_ptr = uplane + (y >> y_shift) * uvstride; |
| 31 const uint8* v_ptr = vplane + (y >> y_shift) * uvstride; | 32 const uint8* v_ptr = vplane + (y >> y_shift) * uvstride; |
| 32 | 33 |
| 33 ConvertYUVToRGB32Row_MMX(y_ptr, | 34 ConvertYUVToRGB32Row_MMX(y_ptr, |
| 34 u_ptr, | 35 u_ptr, |
| 35 v_ptr, | 36 v_ptr, |
| 36 rgb_row, | 37 rgb_row, |
| 37 width); | 38 width); |
| 38 } | 39 } |
| 39 | 40 |
| 41 #if defined(MEDIA_DO_NOT_USE_MMX_INTRINSICS) |
| 42 EmptyRegisterState_MMX(); |
| 43 #else |
| 40 _mm_empty(); | 44 _mm_empty(); |
| 45 #endif // defined(MEDIA_DO_NOT_USE_MMX_INTRINSICS) |
| 41 } | 46 } |
| 42 | 47 |
| 43 void ConvertYUVToRGB32_SSE(const uint8* yplane, | 48 void ConvertYUVToRGB32_SSE(const uint8* yplane, |
| 44 const uint8* uplane, | 49 const uint8* uplane, |
| 45 const uint8* vplane, | 50 const uint8* vplane, |
| 46 uint8* rgbframe, | 51 uint8* rgbframe, |
| 47 int width, | 52 int width, |
| 48 int height, | 53 int height, |
| 49 int ystride, | 54 int ystride, |
| 50 int uvstride, | 55 int uvstride, |
| 51 int rgbstride, | 56 int rgbstride, |
| 52 YUVType yuv_type) { | 57 YUVType yuv_type) { |
| 53 unsigned int y_shift = yuv_type; | 58 unsigned int y_shift = yuv_type; |
| 54 for (int y = 0; y < height; ++y) { | 59 for (int y = 0; y < height; ++y) { |
| 55 uint8* rgb_row = rgbframe + y * rgbstride; | 60 uint8* rgb_row = rgbframe + y * rgbstride; |
| 56 const uint8* y_ptr = yplane + y * ystride; | 61 const uint8* y_ptr = yplane + y * ystride; |
| 57 const uint8* u_ptr = uplane + (y >> y_shift) * uvstride; | 62 const uint8* u_ptr = uplane + (y >> y_shift) * uvstride; |
| 58 const uint8* v_ptr = vplane + (y >> y_shift) * uvstride; | 63 const uint8* v_ptr = vplane + (y >> y_shift) * uvstride; |
| 59 | 64 |
| 60 ConvertYUVToRGB32Row_SSE(y_ptr, | 65 ConvertYUVToRGB32Row_SSE(y_ptr, |
| 61 u_ptr, | 66 u_ptr, |
| 62 v_ptr, | 67 v_ptr, |
| 63 rgb_row, | 68 rgb_row, |
| 64 width); | 69 width); |
| 65 } | 70 } |
| 66 | 71 |
| 72 #if defined(MEDIA_DO_NOT_USE_MMX_INTRINSICS) |
| 73 EmptyRegisterState_MMX(); |
| 74 #else |
| 67 _mm_empty(); | 75 _mm_empty(); |
| 76 #endif // defined(MEDIA_DO_NOT_USE_MMX_INTRINSICS) |
| 68 } | 77 } |
| 69 | 78 |
| 70 } // namespace media | 79 } // namespace media |
| OLD | NEW |