1 /* 2 * 3 * Copyright 2010 Samsung Electronics S.LSI Co. LTD 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* 19 * @file SEC_OMX_Venc.h 20 * @brief 21 * @author SeungBeom Kim (sbcrux.kim (at) samsung.com) 22 * Yunji Kim (yunji.kim (at) samsung.com) 23 * @version 1.0 24 * @history 25 * 2010.7.15 : Create 26 */ 27 28 #ifndef SEC_OMX_VIDEO_ENCODE 29 #define SEC_OMX_VIDEO_ENCODE 30 31 #include "OMX_Component.h" 32 #include "SEC_OMX_Def.h" 33 #include "SEC_OSAL_Queue.h" 34 #include "SEC_OMX_Baseport.h" 35 36 #define MAX_VIDEO_INPUTBUFFER_NUM 5 37 #define MAX_VIDEO_OUTPUTBUFFER_NUM 4 38 39 #define DEFAULT_FRAME_WIDTH 176 40 #define DEFAULT_FRAME_HEIGHT 144 41 42 #define DEFAULT_VIDEO_INPUT_BUFFER_SIZE ALIGN_TO_8KB(ALIGN_TO_128B(DEFAULT_FRAME_WIDTH) * ALIGN_TO_32B(DEFAULT_FRAME_HEIGHT)) \ 43 + ALIGN_TO_8KB(ALIGN_TO_128B(DEFAULT_FRAME_WIDTH) * ALIGN_TO_32B(DEFAULT_FRAME_HEIGHT / 2)) 44 /* (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2 */ 45 #define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE DEFAULT_VIDEO_INPUT_BUFFER_SIZE 46 47 #define MFC_INPUT_BUFFER_NUM_MAX 2 48 49 #ifdef USE_ANDROID_EXTENSION 50 #define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 4 51 #else 52 #define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 3 53 #endif 54 #define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 1 55 56 #ifdef USE_ANDROID_EXTENSION 57 // The largest metadata buffer size advertised 58 // when metadata buffer mode is used for video encoding 59 #define MAX_INPUT_METADATA_BUFFER_SIZE (64) 60 #endif 61 62 typedef struct 63 { 64 void *pAddrY; 65 void *pAddrC; 66 } MFC_ENC_ADDR_INFO; 67 68 typedef struct _SEC_MFC_NBENC_THREAD 69 { 70 OMX_HANDLETYPE hNBEncodeThread; 71 OMX_HANDLETYPE hEncFrameStart; 72 OMX_HANDLETYPE hEncFrameEnd; 73 OMX_BOOL bExitEncodeThread; 74 OMX_BOOL bEncoderRun; 75 } SEC_MFC_NBENC_THREAD; 76 77 typedef struct _MFC_ENC_INPUT_BUFFER 78 { 79 void *YPhyAddr; // physical address of Y 80 void *CPhyAddr; // physical address of CbCr 81 void *YVirAddr; // virtual address of Y 82 void *CVirAddr; // virtual address of CbCr 83 int YBufferSize; // input buffer alloc size of Y 84 int CBufferSize; // input buffer alloc size of CbCr 85 int YDataSize; // input size of Y data 86 int CDataSize; // input size of CbCr data 87 } MFC_ENC_INPUT_BUFFER; 88 89 #ifdef __cplusplus 90 extern "C" { 91 #endif 92 93 OMX_ERRORTYPE SEC_OMX_UseBuffer( 94 OMX_IN OMX_HANDLETYPE hComponent, 95 OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr, 96 OMX_IN OMX_U32 nPortIndex, 97 OMX_IN OMX_PTR pAppPrivate, 98 OMX_IN OMX_U32 nSizeBytes, 99 OMX_IN OMX_U8 *pBuffer); 100 OMX_ERRORTYPE SEC_OMX_AllocateBuffer( 101 OMX_IN OMX_HANDLETYPE hComponent, 102 OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer, 103 OMX_IN OMX_U32 nPortIndex, 104 OMX_IN OMX_PTR pAppPrivate, 105 OMX_IN OMX_U32 nSizeBytes); 106 OMX_ERRORTYPE SEC_OMX_FreeBuffer( 107 OMX_IN OMX_HANDLETYPE hComponent, 108 OMX_IN OMX_U32 nPortIndex, 109 OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr); 110 OMX_ERRORTYPE SEC_OMX_AllocateTunnelBuffer( 111 SEC_OMX_BASEPORT *pOMXBasePort, 112 OMX_U32 nPortIndex); 113 OMX_ERRORTYPE SEC_OMX_FreeTunnelBuffer( 114 SEC_OMX_BASEPORT *pOMXBasePort, 115 OMX_U32 nPortIndex); 116 OMX_ERRORTYPE SEC_OMX_ComponentTunnelRequest( 117 OMX_IN OMX_HANDLETYPE hComp, 118 OMX_IN OMX_U32 nPort, 119 OMX_IN OMX_HANDLETYPE hTunneledComp, 120 OMX_IN OMX_U32 nTunneledPort, 121 OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup); 122 OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent); 123 OMX_ERRORTYPE SEC_OMX_VideoEncodeGetParameter( 124 OMX_IN OMX_HANDLETYPE hComponent, 125 OMX_IN OMX_INDEXTYPE nParamIndex, 126 OMX_INOUT OMX_PTR ComponentParameterStructure); 127 OMX_ERRORTYPE SEC_OMX_VideoEncodeSetParameter( 128 OMX_IN OMX_HANDLETYPE hComponent, 129 OMX_IN OMX_INDEXTYPE nIndex, 130 OMX_IN OMX_PTR ComponentParameterStructure); 131 OMX_ERRORTYPE SEC_OMX_VideoEncodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent); 132 133 #ifdef __cplusplus 134 } 135 #endif 136 137 #endif 138