|
1 // Copyright (c) 2010 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 #ifndef MEDIA_BASE_YUV_CONVERT_H_ |
|
6 #define MEDIA_BASE_YUV_CONVERT_H_ |
|
7 |
|
8 #include "chromium_types.h" |
|
9 #include "gfxCore.h" |
|
10 |
|
11 namespace mozilla { |
|
12 |
|
13 namespace gfx { |
|
14 |
|
15 // Type of YUV surface. |
|
16 // The value of these enums matter as they are used to shift vertical indices. |
|
17 enum YUVType { |
|
18 YV12 = 0, // YV12 is half width and half height chroma channels. |
|
19 YV16 = 1, // YV16 is half width and full height chroma channels. |
|
20 YV24 = 2 // YV24 is full width and full height chroma channels. |
|
21 }; |
|
22 |
|
23 // Mirror means flip the image horizontally, as in looking in a mirror. |
|
24 // Rotate happens after mirroring. |
|
25 enum Rotate { |
|
26 ROTATE_0, // Rotation off. |
|
27 ROTATE_90, // Rotate clockwise. |
|
28 ROTATE_180, // Rotate upside down. |
|
29 ROTATE_270, // Rotate counter clockwise. |
|
30 MIRROR_ROTATE_0, // Mirror horizontally. |
|
31 MIRROR_ROTATE_90, // Mirror then Rotate clockwise. |
|
32 MIRROR_ROTATE_180, // Mirror vertically. |
|
33 MIRROR_ROTATE_270 // Transpose. |
|
34 }; |
|
35 |
|
36 // Filter affects how scaling looks. |
|
37 enum ScaleFilter { |
|
38 FILTER_NONE = 0, // No filter (point sampled). |
|
39 FILTER_BILINEAR_H = 1, // Bilinear horizontal filter. |
|
40 FILTER_BILINEAR_V = 2, // Bilinear vertical filter. |
|
41 FILTER_BILINEAR = 3 // Bilinear filter. |
|
42 }; |
|
43 |
|
44 NS_GFX_(YUVType) TypeFromSize(int ywidth, int yheight, int cbcrwidth, int cbcrheight); |
|
45 |
|
46 // Convert a frame of YUV to 32 bit ARGB. |
|
47 // Pass in YV16/YV12 depending on source format |
|
48 NS_GFX_(void) ConvertYCbCrToRGB32(const uint8* yplane, |
|
49 const uint8* uplane, |
|
50 const uint8* vplane, |
|
51 uint8* rgbframe, |
|
52 int pic_x, |
|
53 int pic_y, |
|
54 int pic_width, |
|
55 int pic_height, |
|
56 int ystride, |
|
57 int uvstride, |
|
58 int rgbstride, |
|
59 YUVType yuv_type); |
|
60 |
|
61 // Scale a frame of YUV to 32 bit ARGB. |
|
62 // Supports rotation and mirroring. |
|
63 NS_GFX_(void) ScaleYCbCrToRGB32(const uint8* yplane, |
|
64 const uint8* uplane, |
|
65 const uint8* vplane, |
|
66 uint8* rgbframe, |
|
67 int source_width, |
|
68 int source_height, |
|
69 int width, |
|
70 int height, |
|
71 int ystride, |
|
72 int uvstride, |
|
73 int rgbstride, |
|
74 YUVType yuv_type, |
|
75 Rotate view_rotate, |
|
76 ScaleFilter filter); |
|
77 |
|
78 } // namespace gfx |
|
79 } // namespace mozilla |
|
80 |
|
81 #endif // MEDIA_BASE_YUV_CONVERT_H_ |