for callback invoke when resolution is changed
[platform/adaptation/ap_samsung/libomxil-e3250-v4l2.git] / openmax / component / video / dec / Exynos_OMX_Vdec.h
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_Vdec.h
20  * @brief
21  * @author      SeungBeom Kim (sbcrux.kim@samsung.com)
22  *              HyeYeon Chung (hyeon.chung@samsung.com)
23  *              Yunji Kim (yunji.kim@samsung.com)
24  * @version     2.0.0
25  * @history
26  *   2012.02.20 : Create
27  */
28
29 #ifndef EXYNOS_OMX_VIDEO_DECODE
30 #define EXYNOS_OMX_VIDEO_DECODE
31
32 #include "OMX_Component.h"
33 #include "Exynos_OMX_Def.h"
34 #include "Exynos_OSAL_Queue.h"
35 #include "Exynos_OMX_Baseport.h"
36 #include "Exynos_OMX_Basecomponent.h"
37
38 #define MAX_VIDEO_INPUTBUFFER_NUM           5
39 #define MAX_VIDEO_OUTPUTBUFFER_NUM          2
40
41 #define DEFAULT_FRAME_WIDTH                 176
42 #define DEFAULT_FRAME_HEIGHT                144
43
44 #define DEFAULT_VIDEO_INPUT_BUFFER_SIZE    (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT) * 2
45 #define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE   (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2
46
47 #define MFC_INPUT_BUFFER_NUM_MAX            3
48  /*For memory Optimization */
49 #define DEFAULT_MFC_INPUT_BUFFER_SIZE       1024*1024*2
50 //#define DEFAULT_MFC_INPUT_BUFFER_SIZE       1920 * 1080 * 3 / 2
51
52 #define MFC_OUTPUT_BUFFER_NUM_MAX           16 * 2
53 #define DEFAULT_MFC_OUTPUT_YBUFFER_SIZE     1920 * 1080
54 #define DEFAULT_MFC_OUTPUT_CBUFFER_SIZE     1920 * 1080 / 2
55
56 #define INPUT_PORT_SUPPORTFORMAT_NUM_MAX    1
57 #define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX   4
58
59 #ifdef TIZEN_FEATURE_E3250 /* exrta dpb number */
60 #define EXTRA_DPB_NUM                       5
61 #else
62 #define EXTRA_DPB_NUM                       5
63 #endif
64
65 #define MFC_INPUT_BUFFER_PLANE              1
66 #define MFC_OUTPUT_BUFFER_PLANE             2
67
68 /*MFC Buffer alignment macros*/
69 #define S5P_FIMV_DEC_BUF_ALIGN                  (8 * 1024)
70 #define S5P_FIMV_ENC_BUF_ALIGN                  (8 * 1024)
71 #define S5P_FIMV_NV12M_HALIGN                   16
72 #define S5P_FIMV_NV12M_LVALIGN                  16
73 #define S5P_FIMV_NV12M_CVALIGN                  8
74 #define S5P_FIMV_NV12MT_HALIGN                  16 /* This value is changed on e3250, 128 to 16 */
75 #define S5P_FIMV_NV12MT_VALIGN                  16 /* This value is changed on e3250, 64 to 16 */
76 #define S5P_FIMV_NV12M_SALIGN                   2048
77 #define S5P_FIMV_NV12MT_SALIGN                  8192
78
79 typedef struct
80 {
81     void *pAddrY;
82     void *pAddrC;
83 } CODEC_DEC_ADDR_INFO;
84
85 typedef struct _CODEC_DEC_BUFFER
86 {
87     void *pVirAddr[MAX_BUFFER_PLANE];   /* virtual address   */
88     int   bufferSize[MAX_BUFFER_PLANE]; /* buffer alloc size */
89     int   fd[MAX_BUFFER_PLANE];         /* buffer FD */
90     int   dataSize;                     /* total data length */
91 } CODEC_DEC_BUFFER;
92
93 typedef struct _DECODE_CODEC_EXTRA_BUFFERINFO
94 {
95     /* For Decode Output */
96     OMX_U32 imageWidth;
97     OMX_U32 imageHeight;
98     OMX_COLOR_FORMATTYPE ColorFormat;
99 } DECODE_CODEC_EXTRA_BUFFERINFO;
100
101 typedef struct _EXYNOS_OMX_VIDEODEC_COMPONENT
102 {
103     OMX_HANDLETYPE hCodecHandle;
104     OMX_BOOL bThumbnailMode;
105     OMX_BOOL bFirstFrame;
106     CODEC_DEC_BUFFER *pMFCDecInputBuffer[MFC_INPUT_BUFFER_NUM_MAX];
107     CODEC_DEC_BUFFER *pMFCDecOutputBuffer[MFC_OUTPUT_BUFFER_NUM_MAX];
108
109     /* Buffer Process */
110     OMX_BOOL       bExitBufferProcessThread;
111     OMX_HANDLETYPE hSrcInputThread;
112     OMX_HANDLETYPE hSrcOutputThread;
113     OMX_HANDLETYPE hDstInputThread;
114     OMX_HANDLETYPE hDstOutputThread;
115
116     /* Shared Memory Handle */
117     OMX_HANDLETYPE hSharedMemory;
118
119     /* For DRM Play */
120     OMX_BOOL bDRMPlayerMode;
121
122     /* For Resolution Change */
123     OMX_BOOL bDRCProcessing;
124     OMX_U32  nDRCSavedBufferCount;
125
126     /* CSC handle */
127     OMX_PTR csc_handle;
128     OMX_U32 csc_set_format;
129
130 #ifdef TIZEN_FEATURE_E3250
131     OMX_BOOL bNeedTimestampReorder;
132 #endif
133
134     OMX_ERRORTYPE (*exynos_codec_srcInputProcess) (OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData);
135     OMX_ERRORTYPE (*exynos_codec_srcOutputProcess) (OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData);
136     OMX_ERRORTYPE (*exynos_codec_dstInputProcess) (OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pOutputData);
137     OMX_ERRORTYPE (*exynos_codec_dstOutputProcess) (OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pOutputData);
138
139     OMX_ERRORTYPE (*exynos_codec_start)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex);
140     OMX_ERRORTYPE (*exynos_codec_stop)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex);
141     OMX_ERRORTYPE (*exynos_codec_bufferProcessRun)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex);
142     OMX_ERRORTYPE (*exynos_codec_enqueueAllBuffer)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex);
143     OMX_ERRORTYPE (*exynos_codec_resetupAllElement)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex);
144
145     int (*exynos_checkInputFrame) (OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag,
146                                    OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame);
147     OMX_ERRORTYPE (*exynos_codec_getCodecInputPrivateData) (OMX_PTR codecBuffer, OMX_PTR addr, OMX_U32 *size);
148     OMX_ERRORTYPE (*exynos_codec_getCodecOutputPrivateData) (OMX_PTR codecBuffer, OMX_PTR addr[], OMX_U32 size[]);
149     OMX_ERRORTYPE (*exynos_process_codecConfigData)(OMX_COMPONENTTYPE *pOMXComponent, void *pConfig);
150 } EXYNOS_OMX_VIDEODEC_COMPONENT;
151
152 #ifdef __cplusplus
153 extern "C" {
154 #endif
155
156 int calc_plane(int width, int height);
157 int calc_yplane(int width, int height);
158 int calc_uvplane(int width, int height);
159 inline void Exynos_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent);
160 OMX_BOOL Exynos_Check_BufferProcess_State(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 nPortIndex);
161 OMX_ERRORTYPE Exynos_Input_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR codecBuffer, EXYNOS_OMX_DATA *pData);
162 OMX_ERRORTYPE Exynos_Output_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR codecBuffer, EXYNOS_OMX_DATA *pData);
163
164 OMX_ERRORTYPE Exynos_OMX_SrcInputBufferProcess(OMX_HANDLETYPE hComponent);
165 OMX_ERRORTYPE Exynos_OMX_SrcOutputBufferProcess(OMX_HANDLETYPE hComponent);
166 OMX_ERRORTYPE Exynos_OMX_DstInputBufferProcess(OMX_HANDLETYPE hComponent);
167 OMX_ERRORTYPE Exynos_OMX_DstOutputBufferProcess(OMX_HANDLETYPE hComponent);
168 OMX_ERRORTYPE Exynos_OMX_VideoDecodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent);
169 OMX_ERRORTYPE Exynos_OMX_VideoDecodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent);
170
171 #ifdef __cplusplus
172 }
173 #endif
174
175 #endif