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 AVC_ENC_H_INCLUDED 19 #define AVC_ENC_H_INCLUDED 20 21 22 #ifndef OSCL_MEM_H_INCLUDED 23 #include "oscl_mem.h" 24 #endif 25 26 #ifndef OMX_Component_h 27 #include "OMX_Component.h" 28 #endif 29 30 #ifndef AVCENC_API_H_INCLUDED 31 #include "avcenc_api.h" 32 #endif 33 34 #ifndef CCRGB24TOYUV420_H_INCLUDED 35 #include "ccrgb24toyuv420.h" 36 #endif 37 38 #ifndef CCRGB12TOYUV420_H_INCLUDED 39 #include "ccrgb12toyuv420.h" 40 #endif 41 42 #ifndef CCYUV420SEMITOYUV420_H_INCLUDED 43 #include "ccyuv420semitoyuv420.h" 44 #endif 45 46 #ifndef OSCL_INT64_UTILS_H_INCLUDED 47 #include "oscl_int64_utils.h" 48 #endif 49 50 class AvcEncoder_OMX 51 { 52 public: 53 54 AvcEncoder_OMX(); 55 ~AvcEncoder_OMX(); 56 57 OMX_ERRORTYPE AvcEncInit(OMX_VIDEO_PORTDEFINITIONTYPE aInputParam, 58 OMX_CONFIG_ROTATIONTYPE aInputOrientationType, 59 OMX_VIDEO_PORTDEFINITIONTYPE aEncodeParam, 60 OMX_VIDEO_PARAM_AVCTYPE aEncodeAvcParam, 61 OMX_VIDEO_PARAM_BITRATETYPE aRateControlType, 62 OMX_VIDEO_PARAM_QUANTIZATIONTYPE aQuantType, 63 OMX_VIDEO_PARAM_MOTIONVECTORTYPE aSearchRange, 64 OMX_VIDEO_PARAM_INTRAREFRESHTYPE aIntraRefresh, 65 OMX_VIDEO_PARAM_VBSMCTYPE aVbsmcType); 66 67 68 AVCEnc_Status AvcEncodeVideo(OMX_U8* aOutBuffer, 69 OMX_U32* aOutputLength, 70 OMX_BOOL* aBufferOverRun, 71 OMX_U8** aOverBufferPointer, 72 OMX_U8* aInBuffer, 73 OMX_U32* aInBufSize, 74 OMX_TICKS aInTimeStamp, 75 OMX_TICKS* aOutTimeStamp, 76 OMX_BOOL* aSyncFlag); 77 78 AVCEnc_Status AvcEncodeSendInput(OMX_U8* aInBuffer, 79 OMX_U32* aInBufSize, 80 OMX_TICKS aInTimeStamp); 81 82 83 OMX_ERRORTYPE AvcEncDeinit(); 84 85 OMX_ERRORTYPE AvcRequestIFrame(); 86 OMX_BOOL AvcUpdateBitRate(OMX_U32 aEncodedBitRate); 87 OMX_BOOL AvcUpdateFrameRate(OMX_U32 aEncodeFramerate); 88 OMX_BOOL GetSpsPpsHeaderFlag(); 89 90 /* for avc encoder lib callback functions */ 91 int AVC_DPBAlloc(uint frame_size_in_mbs, uint num_buffers); 92 int AVC_FrameBind(int indx, uint8** yuv); 93 void AVC_FrameUnbind(int indx); 94 95 96 97 private: 98 99 void CopyToYUVIn(uint8* YUV, int width, int height, int width_16, int height_16); 100 101 /* RGB->YUV conversion */ 102 ColorConvertBase *ccRGBtoYUV; 103 104 int iSrcWidth; 105 int iSrcHeight; 106 int iFrameOrientation; 107 108 OMX_COLOR_FORMATTYPE iVideoFormat; 109 110 /* variables needed in operation */ 111 AVCHandle iAvcHandle; 112 AVCFrameIO iVidIn; 113 uint8* iYUVIn; 114 uint8* iVideoIn; 115 uint8* iVideoOut; 116 uint32 iTimeStamp; 117 OMX_TICKS iTimeStamp64; 118 OMX_BOOL iIDR; 119 int iDispOrd; 120 121 uint8* iDPB; 122 bool* iFrameUsed; 123 uint8** iFramePtr; 124 int iNumFrames; 125 126 OMX_BOOL iInitialized; 127 OMX_BOOL iSpsPpsHeaderFlag; 128 OMX_BOOL iReadyForNextFrame; 129 130 131 }; 132 133 134 #endif ///#ifndef AVC_ENC_H_INCLUDED 135