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