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 /** 19 @file omx_avcenc_component.h 20 OpenMax encoder_component component. 21 22 */ 23 24 #ifndef OMX_AVCENC_COMPONENT_H_INCLUDED 25 #define OMX_AVCENC_COMPONENT_H_INCLUDED 26 27 #ifndef PV_OMXCOMPONENT_H_INCLUDED 28 #include "pv_omxcomponent.h" 29 #endif 30 31 #ifndef AVC_ENC_H_INCLUDED 32 #include "avc_enc.h" 33 #endif 34 35 36 #define INPUT_BUFFER_SIZE_AVCENC 38016 //(176 * 144 * 1.5) for YUV 420 format. 37 38 #if (defined(TEST_FULL_AVC_FRAME_MODE) || defined(TEST_FULL_AVC_FRAME_MODE_SC)) 39 #define OUTPUT_BUFFER_SIZE_AVCENC 38581 // (20 + 4 * MAX_NAL_PER_FRAME + 20 + 6) is size of extra data 40 #else 41 #define OUTPUT_BUFFER_SIZE_AVCENC 38135 42 #endif 43 44 #define NUMBER_INPUT_BUFFER_AVCENC 5 45 #define NUMBER_OUTPUT_BUFFER_AVCENC 2 46 47 class OmxComponentAvcEncAO : public OmxComponentVideo 48 { 49 public: 50 51 OmxComponentAvcEncAO(); 52 ~OmxComponentAvcEncAO(); 53 54 OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy); 55 OMX_ERRORTYPE DestroyComponent(); 56 57 OMX_ERRORTYPE ComponentInit(); 58 OMX_ERRORTYPE ComponentDeInit(); 59 60 static void ComponentGetRolesOfComponent(OMX_STRING* aRoleString); 61 void ProcessInBufferFlag(); 62 63 void ProcessData(); 64 65 OMX_ERRORTYPE SetConfig( 66 OMX_IN OMX_HANDLETYPE hComponent, 67 OMX_IN OMX_INDEXTYPE nIndex, 68 OMX_IN OMX_PTR pComponentConfigStructure); 69 70 private: 71 72 OMX_BOOL CopyDataToOutputBuffer(); 73 OMX_BOOL AppendExtraDataToBuffer(OMX_BUFFERHEADERTYPE* aOutputBuffer, 74 OMX_EXTRADATATYPE aType, 75 OMX_U8* aExtraData, 76 OMX_U8 aDataLength); 77 void ManageFrameBoundaries(); 78 79 AvcEncoder_OMX* ipAvcEncoderObject; 80 81 OMX_BOOL iBufferOverRun; 82 OMX_U8* ipInternalOutBuffer; 83 OMX_U32 iInternalOutBufFilledLen; 84 OMX_TICKS iOutputTimeStamp; 85 OMX_BOOL iSyncFlag; 86 OMX_BOOL iEndOfOutputFrame; 87 88 OMX_U32 iNALSizeArray[MAX_NAL_PER_FRAME]; 89 OMX_U32 iNALSizeSum; 90 OMX_U32 iNALCount; 91 }; 92 93 #endif // OMX_AVCENC_COMPONENT_H_INCLUDED 94