1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 #ifndef CCYUV420SEMITOYUV420_H_INCLUDED 19 #define CCYUV420SEMITOYUV420_H_INCLUDED 20 21 #ifndef OSCL_BASE_H_INCLUDED 22 #include "oscl_base.h" 23 #endif 24 25 #ifndef OSCL_MEM_H_INCLUDED 26 #include "oscl_mem.h" 27 #endif 28 29 #ifndef CCZOOMROTATIONBASE_H_INCLUDED 30 #include "cczoomrotationbase.h" 31 #endif 32 33 #ifndef COLORCONV_CONFIG_H_INCLUDED 34 #include " colorconv_config.h" 35 #endif 36 37 #define SWAP_4(x) ((x<<24) | ((x&0xFF00)<<8) | ((x>>8)&0xFF00) | (x>>24)) 38 39 40 class CCYUV420SEMItoYUV420 : public ColorConvertBase 41 { 42 43 public: 44 45 OSCL_IMPORT_REF static ColorConvertBase* New(); 46 OSCL_IMPORT_REF ~CCYUV420SEMItoYUV420(); 47 48 /** 49 * @brief The function initializes necessary lookup tables and verify the capability of the library before starting the operation. 50 51 * @param Src_width specifies the width in pixel from the source to be color converted. 52 * @param Src_height specifies the height in pixel from the source to be color converted. 53 * @param Src_pitch is the actual memory width or stride of the source. 54 * @param Dst_width specifies the width in pixel of the output. 55 * @param Dst_height specifies the height in pixel of the output. 56 * @param Dst_pitch is the stride size of the destination memory. 57 * @param nRotation specifies whether rotation is to be applied. The value can be one of the followings 58 * Rotation0, Rotation90,Rotation180, Rotation270 59 * When rotation is chosen, the Dst_width and Dst_height is still relative to the source coordinate, 60 * i.e., to rotate a QCIF image, the output width will be 144 and height will be 176. 61 * @return Returns 1 if success, 0 if fail, i.e.,if output dimensions are different from the input dimensions,hence no scaling. 62 */ 63 64 int32 Init(int32 Src_width, 65 int32 Src_height, 66 int32 Src_pitch, 67 int32 Dst_width, 68 int32 Dst_height, 69 int32 Dst_pitch, 70 int32 nRotation = 0); 71 72 /** 73 * @brief As opposed to the definition defined in cczoomrotationbase.h, this function 74 sets the memory height of the YUV buffer which is the output instead of the input. 75 */ 76 SetMemHeight(int32 a_mHeight)77 void SetMemHeight(int32 a_mHeight) 78 { 79 _mDst_mheight = a_mHeight; 80 }; 81 82 83 /** 84 * @brief This function specifies whether the output will use the attribute specified 85 * in the Init(.) function or perform regular color conversion without scaling or rotation. 86 * @param nMode When set to 0, 1-to-1 color conversion only is done. When NMode is 1, 87 * the output is be of the size and orientation specified in Init(). 88 * @return 0 if fails (capability not supported or not initialized), 1 if success. 89 */ 90 int32 SetMode(int32 nMode); 91 92 /** 93 * @brief These functions convert input YUV420SEMI into corresponding YUV420 output. 94 * @param inyuv is a pointer to an input buffer. 95 * @param outyuv is a pointer to an output buffer of Y plane assuming that the U and V planes are contiguous to the Y plane. 96 * @return This function return 1 if success, 0 if fail. 97 */ 98 int32 Convert(uint8 *inyuv, uint8 *outyuv); 99 100 /** 101 * @brief These functions convert input YUV420SEMI into corresponding YUV420 output. 102 * @param yuvBuf is an array of pointers to Y,U and V plane in increasing order. 103 * @param outyuvBuf is a pointer to an output buffer. 104 * @return This function return 1 if success, 0 if fail in the case of the rgbBuf 105 * and/or yuvBuf[0] address are not word-aligned (multiple of 4). 106 */ 107 int32 Convert(uint8 *inyuvBuf, uint8 **outyuvBuf); 108 109 110 /** 111 * @brief This function gives the size of the output YUV420 buffer 112 * @return buffer size in bytes 113 **/ 114 int32 GetOutputBufferSize(void); 115 116 /** 117 * * @brief This function specifies the range of the YCbCr input such that the 118 * * conversion to RGB is done accordingly (see ISO/IEC 14496-2:2004/FPDAM 3).. 119 * * @param range a boolean, false or zero means the range of the Y is 16-235, 120 * * true or one means the full range of 0-255 is used. The default range is false. 121 * */ 122 123 virtual int32 SetYuvFullRange(bool range); 124 125 private: 126 CCYUV420SEMItoYUV420(); 127 128 int32 _mSrc_width, _mSrc_height, _mSrc_pitch, _mDst_width, _mDst_height, _mDst_pitch; 129 int32 _mRotation; 130 int32 _mDst_mheight; 131 132 }; 133 134 #endif // CCYUV420SEMITOYUV420_H_INCLUDED 135 136