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

Side by Side Diff: media/base/yuv_convert.h

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 4 years, 12 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 unified diff | Download patch
« no previous file with comments | « media/base/wall_clock_time_source_unittest.cc ('k') | media/base/yuv_convert.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) 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 #ifndef MEDIA_BASE_YUV_CONVERT_H_ 5 #ifndef MEDIA_BASE_YUV_CONVERT_H_
6 #define MEDIA_BASE_YUV_CONVERT_H_ 6 #define MEDIA_BASE_YUV_CONVERT_H_
7 7
8 #include "base/basictypes.h" 8 #include <stdint.h>
9
10 #include "build/build_config.h"
9 #include "media/base/media_export.h" 11 #include "media/base/media_export.h"
10 12
11 // Visual Studio 2010 does not support MMX intrinsics on x64. 13 // Visual Studio 2010 does not support MMX intrinsics on x64.
12 // Some win64 yuv_convert code paths use SSE+MMX yasm, so without rewriting 14 // Some win64 yuv_convert code paths use SSE+MMX yasm, so without rewriting
13 // them, we use yasm EmptyRegisterState_MMX in place of _mm_empty() or 15 // them, we use yasm EmptyRegisterState_MMX in place of _mm_empty() or
14 // hide the versions implemented with heavy use of MMX intrinsics. 16 // hide the versions implemented with heavy use of MMX intrinsics.
15 // TODO(wolenetz): Use MMX intrinsics when compiling win64 with Visual 17 // TODO(wolenetz): Use MMX intrinsics when compiling win64 with Visual
16 // Studio 2012? http://crbug.com/173450 18 // Studio 2012? http://crbug.com/173450
17 #if defined(ARCH_CPU_X86_FAMILY) && \ 19 #if defined(ARCH_CPU_X86_FAMILY) && \
18 !(defined(ARCH_CPU_X86_64) && defined(COMPILER_MSVC)) 20 !(defined(ARCH_CPU_X86_64) && defined(COMPILER_MSVC))
19 #define MEDIA_MMX_INTRINSICS_AVAILABLE 21 #define MEDIA_MMX_INTRINSICS_AVAILABLE
20 #endif 22 #endif
21 23
22 namespace media { 24 namespace media {
23 25
24 // Type of YUV surface. 26 // Type of YUV surface.
25 enum YUVType { 27 enum YUVType {
26 YV16 = 0, // YV16 is half width and full height chroma channels. 28 YV16 = 0, // YV16 is half width and full height chroma channels.
27 YV12 = 1, // YV12 is half width and half height chroma channels. 29 YV12 = 1, // YV12 is half width and half height chroma channels.
28 YV12J = 2, // YV12J is the same as YV12, but in JPEG color range. 30 YV12J = 2, // YV12J is the same as YV12, but in JPEG color range.
29 YV12HD = 3, // YV12HD is the same as YV12, but in 'HD' Rec709 color space. 31 YV12HD = 3, // YV12HD is the same as YV12, but in 'HD' Rec709 color space.
30 }; 32 };
31 33
32 // Get the appropriate value to bitshift by for vertical indices. 34 // Get the appropriate value to bitshift by for vertical indices.
33 MEDIA_EXPORT int GetVerticalShift(YUVType type); 35 MEDIA_EXPORT int GetVerticalShift(YUVType type);
34 36
35 // Get the appropriate lookup table for a given YUV format. 37 // Get the appropriate lookup table for a given YUV format.
36 MEDIA_EXPORT const int16* GetLookupTable(YUVType type); 38 MEDIA_EXPORT const int16_t* GetLookupTable(YUVType type);
37 39
38 // Mirror means flip the image horizontally, as in looking in a mirror. 40 // Mirror means flip the image horizontally, as in looking in a mirror.
39 // Rotate happens after mirroring. 41 // Rotate happens after mirroring.
40 enum Rotate { 42 enum Rotate {
41 ROTATE_0, // Rotation off. 43 ROTATE_0, // Rotation off.
42 ROTATE_90, // Rotate clockwise. 44 ROTATE_90, // Rotate clockwise.
43 ROTATE_180, // Rotate upside down. 45 ROTATE_180, // Rotate upside down.
44 ROTATE_270, // Rotate counter clockwise. 46 ROTATE_270, // Rotate counter clockwise.
45 MIRROR_ROTATE_0, // Mirror horizontally. 47 MIRROR_ROTATE_0, // Mirror horizontally.
46 MIRROR_ROTATE_90, // Mirror then Rotate clockwise. 48 MIRROR_ROTATE_90, // Mirror then Rotate clockwise.
47 MIRROR_ROTATE_180, // Mirror vertically. 49 MIRROR_ROTATE_180, // Mirror vertically.
48 MIRROR_ROTATE_270, // Transpose. 50 MIRROR_ROTATE_270, // Transpose.
49 }; 51 };
50 52
51 // Filter affects how scaling looks. 53 // Filter affects how scaling looks.
52 enum ScaleFilter { 54 enum ScaleFilter {
53 FILTER_NONE = 0, // No filter (point sampled). 55 FILTER_NONE = 0, // No filter (point sampled).
54 FILTER_BILINEAR_H = 1, // Bilinear horizontal filter. 56 FILTER_BILINEAR_H = 1, // Bilinear horizontal filter.
55 FILTER_BILINEAR_V = 2, // Bilinear vertical filter. 57 FILTER_BILINEAR_V = 2, // Bilinear vertical filter.
56 FILTER_BILINEAR = 3, // Bilinear filter. 58 FILTER_BILINEAR = 3, // Bilinear filter.
57 }; 59 };
58 60
59 MEDIA_EXPORT void InitializeCPUSpecificYUVConversions(); 61 MEDIA_EXPORT void InitializeCPUSpecificYUVConversions();
60 62
61 // Convert a frame of YUV to 32 bit ARGB. 63 // Convert a frame of YUV to 32 bit ARGB.
62 // Pass in YV16/YV12 depending on source format 64 // Pass in YV16/YV12 depending on source format
63 MEDIA_EXPORT void ConvertYUVToRGB32(const uint8* yplane, 65 MEDIA_EXPORT void ConvertYUVToRGB32(const uint8_t* yplane,
64 const uint8* uplane, 66 const uint8_t* uplane,
65 const uint8* vplane, 67 const uint8_t* vplane,
66 uint8* rgbframe, 68 uint8_t* rgbframe,
67 int width, 69 int width,
68 int height, 70 int height,
69 int ystride, 71 int ystride,
70 int uvstride, 72 int uvstride,
71 int rgbstride, 73 int rgbstride,
72 YUVType yuv_type); 74 YUVType yuv_type);
73 75
74 // Convert a frame of YUVA to 32 bit ARGB. 76 // Convert a frame of YUVA to 32 bit ARGB.
75 // Pass in YV12A 77 // Pass in YV12A
76 MEDIA_EXPORT void ConvertYUVAToARGB(const uint8* yplane, 78 MEDIA_EXPORT void ConvertYUVAToARGB(const uint8_t* yplane,
77 const uint8* uplane, 79 const uint8_t* uplane,
78 const uint8* vplane, 80 const uint8_t* vplane,
79 const uint8* aplane, 81 const uint8_t* aplane,
80 uint8* rgbframe, 82 uint8_t* rgbframe,
81 int width, 83 int width,
82 int height, 84 int height,
83 int ystride, 85 int ystride,
84 int uvstride, 86 int uvstride,
85 int astride, 87 int astride,
86 int rgbstride, 88 int rgbstride,
87 YUVType yuv_type); 89 YUVType yuv_type);
88 90
89 // Scale a frame of YUV to 32 bit ARGB. 91 // Scale a frame of YUV to 32 bit ARGB.
90 // Supports rotation and mirroring. 92 // Supports rotation and mirroring.
91 MEDIA_EXPORT void ScaleYUVToRGB32(const uint8* yplane, 93 MEDIA_EXPORT void ScaleYUVToRGB32(const uint8_t* yplane,
92 const uint8* uplane, 94 const uint8_t* uplane,
93 const uint8* vplane, 95 const uint8_t* vplane,
94 uint8* rgbframe, 96 uint8_t* rgbframe,
95 int source_width, 97 int source_width,
96 int source_height, 98 int source_height,
97 int width, 99 int width,
98 int height, 100 int height,
99 int ystride, 101 int ystride,
100 int uvstride, 102 int uvstride,
101 int rgbstride, 103 int rgbstride,
102 YUVType yuv_type, 104 YUVType yuv_type,
103 Rotate view_rotate, 105 Rotate view_rotate,
104 ScaleFilter filter); 106 ScaleFilter filter);
105 107
106 // Biliner Scale a frame of YV12 to 32 bits ARGB on a specified rectangle. 108 // Biliner Scale a frame of YV12 to 32 bits ARGB on a specified rectangle.
107 // |yplane|, etc and |rgbframe| should point to the top-left pixels of the 109 // |yplane|, etc and |rgbframe| should point to the top-left pixels of the
108 // source and destination buffers. 110 // source and destination buffers.
109 MEDIA_EXPORT void ScaleYUVToRGB32WithRect(const uint8* yplane, 111 MEDIA_EXPORT void ScaleYUVToRGB32WithRect(const uint8_t* yplane,
110 const uint8* uplane, 112 const uint8_t* uplane,
111 const uint8* vplane, 113 const uint8_t* vplane,
112 uint8* rgbframe, 114 uint8_t* rgbframe,
113 int source_width, 115 int source_width,
114 int source_height, 116 int source_height,
115 int dest_width, 117 int dest_width,
116 int dest_height, 118 int dest_height,
117 int dest_rect_left, 119 int dest_rect_left,
118 int dest_rect_top, 120 int dest_rect_top,
119 int dest_rect_right, 121 int dest_rect_right,
120 int dest_rect_bottom, 122 int dest_rect_bottom,
121 int ystride, 123 int ystride,
122 int uvstride, 124 int uvstride,
123 int rgbstride); 125 int rgbstride);
124 126
125 MEDIA_EXPORT void ConvertRGB32ToYUV(const uint8* rgbframe, 127 MEDIA_EXPORT void ConvertRGB32ToYUV(const uint8_t* rgbframe,
126 uint8* yplane, 128 uint8_t* yplane,
127 uint8* uplane, 129 uint8_t* uplane,
128 uint8* vplane, 130 uint8_t* vplane,
129 int width, 131 int width,
130 int height, 132 int height,
131 int rgbstride, 133 int rgbstride,
132 int ystride, 134 int ystride,
133 int uvstride); 135 int uvstride);
134 136
135 MEDIA_EXPORT void ConvertRGB24ToYUV(const uint8* rgbframe, 137 MEDIA_EXPORT void ConvertRGB24ToYUV(const uint8_t* rgbframe,
136 uint8* yplane, 138 uint8_t* yplane,
137 uint8* uplane, 139 uint8_t* uplane,
138 uint8* vplane, 140 uint8_t* vplane,
139 int width, 141 int width,
140 int height, 142 int height,
141 int rgbstride, 143 int rgbstride,
142 int ystride, 144 int ystride,
143 int uvstride); 145 int uvstride);
144 146
145 // Empty SIMD register state after calling optimized scaler functions. 147 // Empty SIMD register state after calling optimized scaler functions.
146 MEDIA_EXPORT void EmptyRegisterState(); 148 MEDIA_EXPORT void EmptyRegisterState();
147 149
148 } // namespace media 150 } // namespace media
149 151
150 #endif // MEDIA_BASE_YUV_CONVERT_H_ 152 #endif // MEDIA_BASE_YUV_CONVERT_H_
OLDNEW
« no previous file with comments | « media/base/wall_clock_time_source_unittest.cc ('k') | media/base/yuv_convert.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698