michael@0: // Copyright (c) 2010 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef MEDIA_BASE_YUV_CONVERT_H_ michael@0: #define MEDIA_BASE_YUV_CONVERT_H_ michael@0: michael@0: #include "chromium_types.h" michael@0: #include "gfxCore.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace gfx { michael@0: michael@0: // Type of YUV surface. michael@0: // The value of these enums matter as they are used to shift vertical indices. michael@0: enum YUVType { michael@0: YV12 = 0, // YV12 is half width and half height chroma channels. michael@0: YV16 = 1, // YV16 is half width and full height chroma channels. michael@0: YV24 = 2 // YV24 is full width and full height chroma channels. michael@0: }; michael@0: michael@0: // Mirror means flip the image horizontally, as in looking in a mirror. michael@0: // Rotate happens after mirroring. michael@0: enum Rotate { michael@0: ROTATE_0, // Rotation off. michael@0: ROTATE_90, // Rotate clockwise. michael@0: ROTATE_180, // Rotate upside down. michael@0: ROTATE_270, // Rotate counter clockwise. michael@0: MIRROR_ROTATE_0, // Mirror horizontally. michael@0: MIRROR_ROTATE_90, // Mirror then Rotate clockwise. michael@0: MIRROR_ROTATE_180, // Mirror vertically. michael@0: MIRROR_ROTATE_270 // Transpose. michael@0: }; michael@0: michael@0: // Filter affects how scaling looks. michael@0: enum ScaleFilter { michael@0: FILTER_NONE = 0, // No filter (point sampled). michael@0: FILTER_BILINEAR_H = 1, // Bilinear horizontal filter. michael@0: FILTER_BILINEAR_V = 2, // Bilinear vertical filter. michael@0: FILTER_BILINEAR = 3 // Bilinear filter. michael@0: }; michael@0: michael@0: NS_GFX_(YUVType) TypeFromSize(int ywidth, int yheight, int cbcrwidth, int cbcrheight); michael@0: michael@0: // Convert a frame of YUV to 32 bit ARGB. michael@0: // Pass in YV16/YV12 depending on source format michael@0: NS_GFX_(void) ConvertYCbCrToRGB32(const uint8* yplane, michael@0: const uint8* uplane, michael@0: const uint8* vplane, michael@0: uint8* rgbframe, michael@0: int pic_x, michael@0: int pic_y, michael@0: int pic_width, michael@0: int pic_height, michael@0: int ystride, michael@0: int uvstride, michael@0: int rgbstride, michael@0: YUVType yuv_type); michael@0: michael@0: // Scale a frame of YUV to 32 bit ARGB. michael@0: // Supports rotation and mirroring. michael@0: NS_GFX_(void) ScaleYCbCrToRGB32(const uint8* yplane, michael@0: const uint8* uplane, michael@0: const uint8* vplane, michael@0: uint8* rgbframe, michael@0: int source_width, michael@0: int source_height, michael@0: int width, michael@0: int height, michael@0: int ystride, michael@0: int uvstride, michael@0: int rgbstride, michael@0: YUVType yuv_type, michael@0: Rotate view_rotate, michael@0: ScaleFilter filter); michael@0: michael@0: } // namespace gfx michael@0: } // namespace mozilla michael@0: michael@0: #endif // MEDIA_BASE_YUV_CONVERT_H_