CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / gfx / ycbcr / yuv_convert.h
blobe43fccfb199af1b6dba329e7c589ecc5dafd0060
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.
5 #ifndef MEDIA_BASE_YUV_CONVERT_H_
6 #define MEDIA_BASE_YUV_CONVERT_H_
8 #include "chromium_types.h"
9 #include "gfxCore.h"
11 #ifdef HAVE_ARM_NEON
12 #define HAVE_YCBCR_TO_RGB565 1
13 #endif
15 namespace mozilla {
17 namespace gfx {
19 // Type of YUV surface.
20 // The value of these enums matter as they are used to shift vertical indices.
21 enum YUVType {
22 YV12 = 0, // YV12 is half width and half height chroma channels.
23 YV16 = 1, // YV16 is half width and full height chroma channels.
24 YV24 = 2 // YV24 is full width and full height chroma channels.
27 // Mirror means flip the image horizontally, as in looking in a mirror.
28 // Rotate happens after mirroring.
29 enum Rotate {
30 ROTATE_0, // Rotation off.
31 ROTATE_90, // Rotate clockwise.
32 ROTATE_180, // Rotate upside down.
33 ROTATE_270, // Rotate counter clockwise.
34 MIRROR_ROTATE_0, // Mirror horizontally.
35 MIRROR_ROTATE_90, // Mirror then Rotate clockwise.
36 MIRROR_ROTATE_180, // Mirror vertically.
37 MIRROR_ROTATE_270 // Transpose.
40 // Filter affects how scaling looks.
41 enum ScaleFilter {
42 FILTER_NONE = 0, // No filter (point sampled).
43 FILTER_BILINEAR_H = 1, // Bilinear horizontal filter.
44 FILTER_BILINEAR_V = 2, // Bilinear vertical filter.
45 FILTER_BILINEAR = 3 // Bilinear filter.
48 // Convert a frame of YUV to 16 bit RGB565.
49 // Pass in YV12 formats
50 NS_GFX_(void) ConvertYCbCrToRGB565(const uint8* yplane,
51 const uint8* uplane,
52 const uint8* vplane,
53 uint8* rgbframe,
54 int pic_x,
55 int pic_y,
56 int pic_width,
57 int pic_height,
58 int ystride,
59 int uvstride,
60 int rgbstride,
61 YUVType yuv_type);
63 // Convert a frame of YUV to 32 bit ARGB.
64 // Pass in YV16/YV12 depending on source format
65 NS_GFX_(void) ConvertYCbCrToRGB32(const uint8* yplane,
66 const uint8* uplane,
67 const uint8* vplane,
68 uint8* rgbframe,
69 int pic_x,
70 int pic_y,
71 int pic_width,
72 int pic_height,
73 int ystride,
74 int uvstride,
75 int rgbstride,
76 YUVType yuv_type);
78 // Scale a frame of YUV to 32 bit ARGB.
79 // Supports rotation and mirroring.
80 NS_GFX_(void) ScaleYCbCrToRGB32(const uint8* yplane,
81 const uint8* uplane,
82 const uint8* vplane,
83 uint8* rgbframe,
84 int source_width,
85 int source_height,
86 int width,
87 int height,
88 int ystride,
89 int uvstride,
90 int rgbstride,
91 YUVType yuv_type,
92 Rotate view_rotate,
93 ScaleFilter filter);
95 } // namespace gfx
96 } // namespace mozilla
98 #endif // MEDIA_BASE_YUV_CONVERT_H_