Home | History | Annotate | Download | only in enc
      1 /*
      2  *
      3  * Copyright 2012 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        Exynos_OMX_Venc.h
     20  * @brief
     21  * @author      SeungBeom Kim (sbcrux.kim (at) samsung.com)
     22  *              Yunji Kim (yunji.kim (at) samsung.com)
     23  * @version     2.0.0
     24  * @history
     25  *   2012.02.20 : Create
     26  */
     27 
     28 #ifndef EXYNOS_OMX_VIDEO_ENCODE
     29 #define EXYNOS_OMX_VIDEO_ENCODE
     30 
     31 #include "OMX_Component.h"
     32 #include "Exynos_OMX_Def.h"
     33 #include "Exynos_OSAL_Queue.h"
     34 #include "Exynos_OMX_Baseport.h"
     35 #include "Exynos_OMX_Basecomponent.h"
     36 #include "ExynosVideoApi.h"
     37 
     38 #define MAX_VIDEO_INPUTBUFFER_NUM    5
     39 #define MAX_VIDEO_OUTPUTBUFFER_NUM   4
     40 
     41 #define DEFAULT_FRAME_WIDTH          176
     42 #define DEFAULT_FRAME_HEIGHT         144
     43 
     44 #define DEFAULT_VIDEO_INPUT_BUFFER_SIZE    (ALIGN_TO_16B(DEFAULT_FRAME_WIDTH) * ALIGN_TO_16B(DEFAULT_FRAME_HEIGHT) + \
     45                                                                                 ALIGN((ALIGN_TO_16B(DEFAULT_FRAME_WIDTH) * ALIGN_TO_16B(DEFAULT_FRAME_HEIGHT))/2,256))
     46 #define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE   (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT) * 2
     47 
     48 #define MFC_INPUT_BUFFER_NUM_MAX            3
     49 #define MFC_OUTPUT_BUFFER_NUM_MAX           4
     50 
     51 #define DEFAULT_MFC_INPUT_YBUFFER_SIZE      ALIGN_TO_16B(2560) * ALIGN_TO_16B(1600)
     52 #define DEFAULT_MFC_INPUT_CBUFFER_SIZE      ALIGN((DEFAULT_MFC_INPUT_YBUFFER_SIZE / 2), 256)
     53 #define DEFAULT_MFC_OUTPUT_BUFFER_SIZE      2560 * 1600 * 3 / 2
     54 
     55 #define INPUT_PORT_SUPPORTFORMAT_NUM_MAX    5
     56 #define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX   1
     57 
     58 #define MFC_INPUT_BUFFER_PLANE              2
     59 #define MFC_OUTPUT_BUFFER_PLANE             1
     60 
     61 #define MAX_INPUTBUFFER_NUM_DYNAMIC         0 /* Dynamic number of metadata buffer */
     62 
     63 // The largest metadata buffer size advertised
     64 // when metadata buffer mode is used for video encoding
     65 #define  MAX_INPUT_METADATA_BUFFER_SIZE (64)
     66 
     67 typedef struct
     68 {
     69     void *pAddrY;
     70     void *pAddrC;
     71 } CODEC_ENC_ADDR_INFO;
     72 
     73 typedef struct _CODEC_ENC_BUFFER
     74 {
     75     void *pVirAddr[MAX_BUFFER_PLANE];   /* virtual address   */
     76     int   bufferSize[MAX_BUFFER_PLANE]; /* buffer alloc size */
     77     int   fd[MAX_BUFFER_PLANE];  /* buffer FD */
     78     int   dataSize;              /* total data length */
     79 } CODEC_ENC_BUFFER;
     80 
     81 typedef struct _EXYNOS_OMX_VIDEOENC_COMPONENT
     82 {
     83     OMX_HANDLETYPE hCodecHandle;
     84     OMX_BOOL bFirstFrame;
     85     CODEC_ENC_BUFFER *pMFCEncInputBuffer[MFC_INPUT_BUFFER_NUM_MAX];
     86     CODEC_ENC_BUFFER *pMFCEncOutputBuffer[MFC_OUTPUT_BUFFER_NUM_MAX];
     87 
     88     /* Buffer Process */
     89     OMX_BOOL       bExitBufferProcessThread;
     90     OMX_HANDLETYPE hSrcInputThread;
     91     OMX_HANDLETYPE hSrcOutputThread;
     92     OMX_HANDLETYPE hDstInputThread;
     93     OMX_HANDLETYPE hDstOutputThread;
     94 
     95     /* Shared Memory Handle */
     96     OMX_HANDLETYPE hSharedMemory;
     97 
     98     OMX_BOOL configChange;
     99     OMX_BOOL IntraRefreshVOP;
    100     OMX_VIDEO_CONTROLRATETYPE eControlRate[ALL_PORT_NUM];
    101     OMX_VIDEO_PARAM_QUANTIZATIONTYPE quantization;
    102     OMX_VIDEO_PARAM_INTRAREFRESHTYPE intraRefresh;
    103 
    104     OMX_BOOL bFirstInput;
    105     OMX_BOOL bFirstOutput;
    106 
    107     OMX_COLOR_FORMATTYPE ANBColorFormat;
    108 
    109     /* CSC handle */
    110     OMX_PTR csc_handle;
    111     OMX_U32 csc_set_format;
    112 
    113     OMX_ERRORTYPE (*exynos_codec_srcInputProcess) (OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData);
    114     OMX_ERRORTYPE (*exynos_codec_srcOutputProcess) (OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData);
    115     OMX_ERRORTYPE (*exynos_codec_dstInputProcess) (OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pOutputData);
    116     OMX_ERRORTYPE (*exynos_codec_dstOutputProcess) (OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pOutputData);
    117 
    118     OMX_ERRORTYPE (*exynos_codec_start)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex);
    119     OMX_ERRORTYPE (*exynos_codec_stop)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex);
    120     OMX_ERRORTYPE (*exynos_codec_bufferProcessRun)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex);
    121     OMX_ERRORTYPE (*exynos_codec_enqueueAllBuffer)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex);
    122 
    123     int (*exynos_checkInputFrame) (OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag,
    124                                    OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame);
    125     OMX_ERRORTYPE (*exynos_codec_getCodecInputPrivateData) (OMX_PTR codecBuffer, OMX_PTR addr[], OMX_U32 size[]);
    126     OMX_ERRORTYPE (*exynos_codec_getCodecOutputPrivateData) (OMX_PTR codecBuffer, OMX_PTR addr, OMX_U32 *size);
    127 } EXYNOS_OMX_VIDEOENC_COMPONENT;
    128 
    129 #ifdef __cplusplus
    130 extern "C" {
    131 #endif
    132 
    133 inline void Exynos_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent);
    134 OMX_BOOL Exynos_Check_BufferProcess_State(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 nPortIndex);
    135 OMX_ERRORTYPE Exynos_Input_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR codecBuffer, EXYNOS_OMX_DATA *pData);
    136 OMX_ERRORTYPE Exynos_Output_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR codecBuffer, EXYNOS_OMX_DATA *pData);
    137 
    138 
    139 OMX_ERRORTYPE Exynos_OMX_SrcInputBufferProcess(OMX_HANDLETYPE hComponent);
    140 OMX_ERRORTYPE Exynos_OMX_SrcOutputBufferProcess(OMX_HANDLETYPE hComponent);
    141 OMX_ERRORTYPE Exynos_OMX_DstInputBufferProcess(OMX_HANDLETYPE hComponent);
    142 OMX_ERRORTYPE Exynos_OMX_DstOutputBufferProcess(OMX_HANDLETYPE hComponent);
    143 OMX_ERRORTYPE Exynos_OMX_VideoEncodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent);
    144 OMX_ERRORTYPE Exynos_OMX_VideoEncodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent);
    145 
    146 #ifdef __cplusplus
    147 }
    148 #endif
    149 
    150 #endif
    151