• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #if defined(_MSC_VER)
6 #include <intrin.h>
7 #else
8 #include <mmintrin.h>
9 #endif
10 
11 #include "media/base/simd/convert_yuv_to_rgb.h"
12 #include "media/base/simd/yuv_to_rgb_table.h"
13 #include "media/base/yuv_convert.h"
14 
15 namespace media {
16 
ConvertYUVAToARGB_MMX(const uint8 * yplane,const uint8 * uplane,const uint8 * vplane,const uint8 * aplane,uint8 * rgbframe,int width,int height,int ystride,int uvstride,int astride,int rgbstride,YUVType yuv_type)17 void ConvertYUVAToARGB_MMX(const uint8* yplane,
18                            const uint8* uplane,
19                            const uint8* vplane,
20                            const uint8* aplane,
21                            uint8* rgbframe,
22                            int width,
23                            int height,
24                            int ystride,
25                            int uvstride,
26                            int astride,
27                            int rgbstride,
28                            YUVType yuv_type) {
29   unsigned int y_shift = GetVerticalShift(yuv_type);
30   for (int y = 0; y < height; ++y) {
31     uint8* rgb_row = rgbframe + y * rgbstride;
32     const uint8* y_ptr = yplane + y * ystride;
33     const uint8* u_ptr = uplane + (y >> y_shift) * uvstride;
34     const uint8* v_ptr = vplane + (y >> y_shift) * uvstride;
35     const uint8* a_ptr = aplane + y * astride;
36 
37     ConvertYUVAToARGBRow_MMX(y_ptr,
38                              u_ptr,
39                              v_ptr,
40                              a_ptr,
41                              rgb_row,
42                              width,
43                              GetLookupTable(yuv_type));
44   }
45 
46   EmptyRegisterState();
47 }
48 
ConvertYUVToRGB32_SSE(const uint8 * yplane,const uint8 * uplane,const uint8 * vplane,uint8 * rgbframe,int width,int height,int ystride,int uvstride,int rgbstride,YUVType yuv_type)49 void ConvertYUVToRGB32_SSE(const uint8* yplane,
50                            const uint8* uplane,
51                            const uint8* vplane,
52                            uint8* rgbframe,
53                            int width,
54                            int height,
55                            int ystride,
56                            int uvstride,
57                            int rgbstride,
58                            YUVType yuv_type) {
59   unsigned int y_shift = GetVerticalShift(yuv_type);
60   for (int y = 0; y < height; ++y) {
61     uint8* rgb_row = rgbframe + y * rgbstride;
62     const uint8* y_ptr = yplane + y * ystride;
63     const uint8* u_ptr = uplane + (y >> y_shift) * uvstride;
64     const uint8* v_ptr = vplane + (y >> y_shift) * uvstride;
65 
66     ConvertYUVToRGB32Row_SSE(y_ptr,
67                              u_ptr,
68                              v_ptr,
69                              rgb_row,
70                              width,
71                              GetLookupTable(yuv_type));
72   }
73 
74   EmptyRegisterState();
75 }
76 
77 }  // namespace media
78