Commit | Line | Data |
---|---|---|
20d3e6e3 JC |
1 | /* |
2 | * | |
38ef2572 | 3 | * Copyright 2012 Samsung Electronics S.LSI Co. LTD |
20d3e6e3 JC |
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_Mpeg4enc.c | |
20 | * @brief | |
21 | * @author Yunji Kim (yunji.kim@samsung.com) | |
38ef2572 | 22 | * @version 2.0.0 |
20d3e6e3 | 23 | * @history |
38ef2572 | 24 | * 2012.02.20 : Create |
20d3e6e3 JC |
25 | */ |
26 | ||
20d3e6e3 JC |
27 | #include <stdio.h> |
28 | #include <stdlib.h> | |
29 | #include <string.h> | |
30 | ||
31 | #include "Exynos_OMX_Macros.h" | |
32 | #include "Exynos_OMX_Basecomponent.h" | |
33 | #include "Exynos_OMX_Baseport.h" | |
34 | #include "Exynos_OMX_Venc.h" | |
38ef2572 | 35 | #include "Exynos_OSAL_ETC.h" |
20d3e6e3 JC |
36 | #include "Exynos_OSAL_Semaphore.h" |
37 | #include "Exynos_OSAL_Thread.h" | |
20d3e6e3 JC |
38 | #include "Exynos_OSAL_Android.h" |
39 | #include "library_register.h" | |
40 | #include "Exynos_OMX_Mpeg4enc.h" | |
800a8d75 | 41 | #include "ExynosVideoApi.h" |
38ef2572 JC |
42 | #include "Exynos_OSAL_SharedMemory.h" |
43 | #include "Exynos_OSAL_Event.h" | |
44 | ||
45 | /* To use CSC_METHOD_HW in EXYNOS OMX, gralloc should allocate physical memory using FIMC */ | |
46 | /* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */ | |
800a8d75 | 47 | #include "csc.h" |
20d3e6e3 JC |
48 | |
49 | #undef EXYNOS_LOG_TAG | |
50 | #define EXYNOS_LOG_TAG "EXYNOS_MPEG4_ENC" | |
51 | #define EXYNOS_LOG_OFF | |
38ef2572 | 52 | //#define EXYNOS_TRACE_ON |
20d3e6e3 JC |
53 | #include "Exynos_OSAL_Log.h" |
54 | ||
20d3e6e3 JC |
55 | /* MPEG4 Encoder Supported Levels & profiles */ |
56 | EXYNOS_OMX_VIDEO_PROFILELEVEL supportedMPEG4ProfileLevels[] ={ | |
57 | {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0}, | |
58 | {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0b}, | |
59 | {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1}, | |
60 | {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level2}, | |
61 | {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level3}, | |
62 | {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4}, | |
63 | {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4a}, | |
64 | {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level5}, | |
65 | {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0}, | |
66 | {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0b}, | |
67 | {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level1}, | |
68 | {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level2}, | |
69 | {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level3}, | |
70 | {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4}, | |
71 | {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4a}, | |
72 | {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level5}}; | |
73 | ||
74 | /* H.263 Encoder Supported Levels & profiles */ | |
75 | EXYNOS_OMX_VIDEO_PROFILELEVEL supportedH263ProfileLevels[] = { | |
76 | {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10}, | |
77 | {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level20}, | |
78 | {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level30}, | |
79 | {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level40}, | |
80 | {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level45}, | |
81 | {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level50}, | |
82 | {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level60}, | |
83 | {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level70}}; | |
84 | ||
800a8d75 | 85 | static OMX_U32 OMXMpeg4ProfileToMFCProfile(OMX_VIDEO_MPEG4PROFILETYPE profile) |
20d3e6e3 JC |
86 | { |
87 | OMX_U32 ret; | |
88 | ||
89 | switch (profile) { | |
90 | case OMX_VIDEO_MPEG4ProfileSimple: | |
91 | ret = 0; | |
92 | break; | |
93 | case OMX_VIDEO_MPEG4ProfileAdvancedSimple: | |
94 | ret = 1; | |
95 | break; | |
96 | default: | |
97 | ret = 0; | |
98 | }; | |
99 | ||
100 | return ret; | |
101 | } | |
800a8d75 JC |
102 | |
103 | static OMX_U32 OMXMpeg4LevelToMFCLevel(OMX_VIDEO_MPEG4LEVELTYPE level) | |
20d3e6e3 JC |
104 | { |
105 | OMX_U32 ret; | |
106 | ||
107 | switch (level) { | |
108 | case OMX_VIDEO_MPEG4Level0: | |
109 | ret = 0; | |
110 | break; | |
111 | case OMX_VIDEO_MPEG4Level0b: | |
800a8d75 | 112 | ret = 1; |
20d3e6e3 JC |
113 | break; |
114 | case OMX_VIDEO_MPEG4Level1: | |
800a8d75 | 115 | ret = 2; |
20d3e6e3 JC |
116 | break; |
117 | case OMX_VIDEO_MPEG4Level2: | |
800a8d75 | 118 | ret = 3; |
20d3e6e3 JC |
119 | break; |
120 | case OMX_VIDEO_MPEG4Level3: | |
800a8d75 | 121 | ret = 4; |
20d3e6e3 JC |
122 | break; |
123 | case OMX_VIDEO_MPEG4Level4: | |
124 | case OMX_VIDEO_MPEG4Level4a: | |
800a8d75 | 125 | ret = 6; |
20d3e6e3 JC |
126 | break; |
127 | case OMX_VIDEO_MPEG4Level5: | |
800a8d75 | 128 | ret = 7; |
20d3e6e3 JC |
129 | break; |
130 | default: | |
131 | ret = 0; | |
132 | }; | |
133 | ||
134 | return ret; | |
135 | } | |
136 | ||
800a8d75 | 137 | static void Print_Mpeg4Enc_Param(ExynosVideoEncParam *pEncParam) |
20d3e6e3 | 138 | { |
800a8d75 JC |
139 | ExynosVideoEncCommonParam *pCommonParam = &pEncParam->commonParam; |
140 | ExynosVideoEncMpeg4Param *pMpeg4Param = &pEncParam->codecParam.mpeg4; | |
141 | ||
142 | /* common parameters */ | |
143 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceWidth : %d", pCommonParam->SourceWidth); | |
144 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceHeight : %d", pCommonParam->SourceHeight); | |
145 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "IDRPeriod : %d", pCommonParam->IDRPeriod); | |
146 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SliceMode : %d", pCommonParam->SliceMode); | |
147 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "RandomIntraMBRefresh : %d", pCommonParam->RandomIntraMBRefresh); | |
148 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Bitrate : %d", pCommonParam->Bitrate); | |
149 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp : %d", pCommonParam->FrameQp); | |
150 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp_P : %d", pCommonParam->FrameQp_P); | |
151 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMax : %d", pCommonParam->QSCodeMax); | |
152 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMin : %d", pCommonParam->QSCodeMin); | |
153 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "PadControlOn : %d", pCommonParam->PadControlOn); | |
154 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "LumaPadVal : %d", pCommonParam->LumaPadVal); | |
155 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CbPadVal : %d", pCommonParam->CbPadVal); | |
156 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CrPadVal : %d", pCommonParam->CrPadVal); | |
157 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameMap : %d", pCommonParam->FrameMap); | |
158 | ||
159 | /* Mpeg4 specific parameters */ | |
160 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "ProfileIDC : %d", pMpeg4Param->ProfileIDC); | |
161 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "LevelIDC : %d", pMpeg4Param->LevelIDC); | |
162 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp_B : %d", pMpeg4Param->FrameQp_B); | |
163 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "TimeIncreamentRes : %d", pMpeg4Param->TimeIncreamentRes); | |
164 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "VopTimeIncreament : %d", pMpeg4Param->VopTimeIncreament); | |
165 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SliceArgument : %d", pMpeg4Param->SliceArgument); | |
166 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "NumberBFrames : %d", pMpeg4Param->NumberBFrames); | |
167 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "DisableQpelME : %d", pMpeg4Param->DisableQpelME); | |
168 | ||
169 | /* rate control related parameters */ | |
170 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableFRMRateControl : %d", pCommonParam->EnableFRMRateControl); | |
171 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableMBRateControl : %d", pCommonParam->EnableMBRateControl); | |
172 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CBRPeriodRf : %d", pCommonParam->CBRPeriodRf); | |
20d3e6e3 JC |
173 | } |
174 | ||
800a8d75 | 175 | static void Print_H263Enc_Param(ExynosVideoEncParam *pEncParam) |
20d3e6e3 | 176 | { |
800a8d75 JC |
177 | ExynosVideoEncCommonParam *pCommonParam = &pEncParam->commonParam; |
178 | ExynosVideoEncH263Param *pH263Param = &pEncParam->codecParam.h263; | |
179 | ||
180 | /* common parameters */ | |
181 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceWidth : %d", pCommonParam->SourceWidth); | |
182 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceHeight : %d", pCommonParam->SourceHeight); | |
183 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "IDRPeriod : %d", pCommonParam->IDRPeriod); | |
184 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SliceMode : %d", pCommonParam->SliceMode); | |
185 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "RandomIntraMBRefresh : %d", pCommonParam->RandomIntraMBRefresh); | |
186 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Bitrate : %d", pCommonParam->Bitrate); | |
187 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp : %d", pCommonParam->FrameQp); | |
188 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp_P : %d", pCommonParam->FrameQp_P); | |
189 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMax : %d", pCommonParam->QSCodeMax); | |
190 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMin : %d", pCommonParam->QSCodeMin); | |
191 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "PadControlOn : %d", pCommonParam->PadControlOn); | |
192 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "LumaPadVal : %d", pCommonParam->LumaPadVal); | |
193 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CbPadVal : %d", pCommonParam->CbPadVal); | |
194 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CrPadVal : %d", pCommonParam->CrPadVal); | |
195 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameMap : %d", pCommonParam->FrameMap); | |
196 | ||
197 | /* H263 specific parameters */ | |
198 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameRate : %d", pH263Param->FrameRate); | |
199 | ||
200 | /* rate control related parameters */ | |
201 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableFRMRateControl : %d", pCommonParam->EnableFRMRateControl); | |
202 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableMBRateControl : %d", pCommonParam->EnableMBRateControl); | |
203 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CBRPeriodRf : %d", pCommonParam->CBRPeriodRf); | |
20d3e6e3 JC |
204 | } |
205 | ||
800a8d75 | 206 | static void Set_Mpeg4Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent) |
20d3e6e3 | 207 | { |
800a8d75 | 208 | EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL; |
20d3e6e3 | 209 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL; |
800a8d75 JC |
210 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; |
211 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
38ef2572 | 212 | EXYNOS_MFC_MPEG4ENC_HANDLE *pMFCMpeg4Handle; |
800a8d75 JC |
213 | |
214 | ExynosVideoEncParam *pEncParam = NULL; | |
215 | ExynosVideoEncCommonParam *pCommonParam = NULL; | |
216 | ExynosVideoEncMpeg4Param *pMpeg4Param = NULL; | |
20d3e6e3 JC |
217 | |
218 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
800a8d75 | 219 | pMpeg4Enc = pVideoEnc->hCodecHandle; |
38ef2572 | 220 | pMFCMpeg4Handle = &pMpeg4Enc->hMFCMpeg4Handle; |
800a8d75 | 221 | pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; |
20d3e6e3 JC |
222 | pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; |
223 | ||
38ef2572 | 224 | pEncParam = &pMFCMpeg4Handle->encParam; |
800a8d75 JC |
225 | pCommonParam = &pEncParam->commonParam; |
226 | pMpeg4Param = &pEncParam->codecParam.mpeg4; | |
227 | pEncParam->eCompressionFormat = VIDEO_CODING_MPEG4; | |
228 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "eCompressionFormat: %d", pEncParam->eCompressionFormat); | |
229 | ||
230 | /* common parameters */ | |
231 | pCommonParam->SourceWidth = pExynosOutputPort->portDefinition.format.video.nFrameWidth; | |
232 | pCommonParam->SourceHeight = pExynosOutputPort->portDefinition.format.video.nFrameHeight; | |
233 | pCommonParam->IDRPeriod = pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1; | |
234 | pCommonParam->SliceMode = 0; | |
235 | pCommonParam->RandomIntraMBRefresh = 0; | |
236 | pCommonParam->Bitrate = pExynosOutputPort->portDefinition.format.video.nBitrate; | |
237 | pCommonParam->FrameQp = pVideoEnc->quantization.nQpI; | |
238 | pCommonParam->FrameQp_P = pVideoEnc->quantization.nQpP; | |
239 | pCommonParam->QSCodeMax = 30; | |
240 | pCommonParam->QSCodeMin = 10; | |
241 | pCommonParam->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */ | |
242 | pCommonParam->LumaPadVal = 0; | |
243 | pCommonParam->CbPadVal = 0; | |
244 | pCommonParam->CrPadVal = 0; | |
245 | ||
33d6044e SK |
246 | if (pExynosInputPort->bufferProcessType == BUFFER_SHARE) { |
247 | if (pVideoEnc->ANBColorFormat == OMX_SEC_COLOR_FormatNV21Linear) | |
248 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12; | |
249 | if (pVideoEnc->ANBColorFormat == OMX_SEC_COLOR_FormatNV12Tiled) | |
250 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12_TILED; | |
251 | } else { | |
252 | switch ((EXYNOS_OMX_COLOR_FORMATTYPE)pExynosInputPort->portDefinition.format.video.eColorFormat) { | |
253 | case OMX_COLOR_FormatYUV420SemiPlanar: | |
254 | case OMX_COLOR_FormatYUV420Planar: /* Converted to NV12 in Exynos_CSC_InputData */ | |
800a8d75 | 255 | #ifdef USE_METADATABUFFERTYPE |
33d6044e | 256 | case OMX_COLOR_FormatAndroidOpaque: |
800a8d75 | 257 | #endif |
33d6044e SK |
258 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12; |
259 | break; | |
260 | case OMX_SEC_COLOR_FormatNV21Linear: | |
261 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV21; | |
262 | break; | |
263 | case OMX_SEC_COLOR_FormatNV12Tiled: | |
264 | default: | |
265 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12_TILED; | |
266 | break; | |
267 | } | |
800a8d75 JC |
268 | } |
269 | ||
270 | /* Mpeg4 specific parameters */ | |
271 | pMpeg4Param->ProfileIDC = OMXMpeg4ProfileToMFCProfile(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eProfile); | |
272 | pMpeg4Param->LevelIDC = OMXMpeg4LevelToMFCLevel(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eLevel); | |
273 | pMpeg4Param->FrameQp_B = pVideoEnc->quantization.nQpB; | |
274 | pMpeg4Param->TimeIncreamentRes = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16; | |
275 | pMpeg4Param->VopTimeIncreament = 1; | |
276 | pMpeg4Param->SliceArgument = 0; /* MB number or byte number */ | |
277 | pMpeg4Param->NumberBFrames = 0; /* 0(not used) ~ 2 */ | |
278 | pMpeg4Param->DisableQpelME = 1; | |
20d3e6e3 JC |
279 | |
280 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]: 0x%x", pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]); | |
800a8d75 | 281 | /* rate control related parameters */ |
20d3e6e3 JC |
282 | switch (pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]) { |
283 | case OMX_Video_ControlRateVariable: | |
284 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR"); | |
800a8d75 JC |
285 | pCommonParam->EnableFRMRateControl = 0; /* 0: Disable, 1: Frame level RC */ |
286 | pCommonParam->EnableMBRateControl = 0; /* 0: Disable, 1:MB level RC */ | |
287 | pCommonParam->CBRPeriodRf = 100; | |
20d3e6e3 JC |
288 | break; |
289 | case OMX_Video_ControlRateConstant: | |
290 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode CBR"); | |
800a8d75 JC |
291 | pCommonParam->EnableFRMRateControl = 1; /* 0: Disable, 1: Frame level RC */ |
292 | pCommonParam->EnableMBRateControl = 1; /* 0: Disable, 1:MB level RC */ | |
293 | pCommonParam->CBRPeriodRf = 10; | |
20d3e6e3 JC |
294 | break; |
295 | case OMX_Video_ControlRateDisable: | |
800a8d75 | 296 | default: /*Android default */ |
20d3e6e3 | 297 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR"); |
800a8d75 JC |
298 | pCommonParam->EnableFRMRateControl = 0; |
299 | pCommonParam->EnableMBRateControl = 0; | |
300 | pCommonParam->CBRPeriodRf = 100; | |
20d3e6e3 JC |
301 | break; |
302 | } | |
303 | ||
800a8d75 JC |
304 | Print_Mpeg4Enc_Param(pEncParam); |
305 | } | |
306 | ||
307 | static void Set_H263Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent) | |
308 | { | |
309 | EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL; | |
310 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL; | |
311 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
312 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
38ef2572 | 313 | EXYNOS_MFC_MPEG4ENC_HANDLE *pMFCMpeg4Handle; |
800a8d75 JC |
314 | |
315 | ExynosVideoEncParam *pEncParam = NULL; | |
316 | ExynosVideoEncCommonParam *pCommonParam = NULL; | |
317 | ExynosVideoEncH263Param *pH263Param = NULL; | |
318 | ||
319 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
320 | pMpeg4Enc = pVideoEnc->hCodecHandle; | |
38ef2572 | 321 | pMFCMpeg4Handle = &pMpeg4Enc->hMFCMpeg4Handle; |
800a8d75 JC |
322 | pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; |
323 | pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
324 | ||
38ef2572 | 325 | pEncParam = &pMFCMpeg4Handle->encParam; |
800a8d75 JC |
326 | pCommonParam = &pEncParam->commonParam; |
327 | pH263Param = &pEncParam->codecParam.h263; | |
328 | pEncParam->eCompressionFormat = VIDEO_CODING_H263; | |
329 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "eCompressionFormat: %d", pEncParam->eCompressionFormat); | |
330 | ||
331 | /* common parameters */ | |
332 | pCommonParam->SourceWidth = pExynosOutputPort->portDefinition.format.video.nFrameWidth; | |
333 | pCommonParam->SourceHeight = pExynosOutputPort->portDefinition.format.video.nFrameHeight; | |
334 | pCommonParam->IDRPeriod = pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1; | |
335 | pCommonParam->SliceMode = 0; | |
336 | pCommonParam->RandomIntraMBRefresh = 0; | |
337 | pCommonParam->Bitrate = pExynosOutputPort->portDefinition.format.video.nBitrate; | |
338 | pCommonParam->FrameQp = pVideoEnc->quantization.nQpI; | |
339 | pCommonParam->FrameQp_P = pVideoEnc->quantization.nQpP; | |
340 | pCommonParam->QSCodeMax = 30; | |
341 | pCommonParam->QSCodeMin = 10; | |
342 | pCommonParam->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */ | |
343 | pCommonParam->LumaPadVal = 0; | |
344 | pCommonParam->CbPadVal = 0; | |
345 | pCommonParam->CrPadVal = 0; | |
346 | ||
33d6044e SK |
347 | if (pExynosInputPort->bufferProcessType == BUFFER_SHARE) { |
348 | if (pVideoEnc->ANBColorFormat == OMX_SEC_COLOR_FormatNV21Linear) | |
349 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12; | |
350 | if (pVideoEnc->ANBColorFormat == OMX_SEC_COLOR_FormatNV12Tiled) | |
351 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12_TILED; | |
352 | } else { | |
353 | switch ((EXYNOS_OMX_COLOR_FORMATTYPE)pExynosInputPort->portDefinition.format.video.eColorFormat) { | |
354 | case OMX_COLOR_FormatYUV420SemiPlanar: | |
355 | case OMX_COLOR_FormatYUV420Planar: /* Converted to NV12 in Exynos_CSC_InputData */ | |
800a8d75 | 356 | #ifdef USE_METADATABUFFERTYPE |
33d6044e | 357 | case OMX_COLOR_FormatAndroidOpaque: |
20d3e6e3 | 358 | #endif |
33d6044e SK |
359 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12; |
360 | break; | |
361 | case OMX_SEC_COLOR_FormatNV21Linear: | |
362 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV21; | |
363 | break; | |
364 | case OMX_SEC_COLOR_FormatNV12Tiled: | |
365 | default: | |
366 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12_TILED; | |
367 | break; | |
368 | } | |
800a8d75 JC |
369 | } |
370 | ||
371 | /* H263 specific parameters */ | |
372 | pH263Param->FrameRate = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16; | |
373 | ||
374 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]: 0x%x", pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]); | |
375 | /* rate control related parameters */ | |
376 | switch (pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]) { | |
377 | case OMX_Video_ControlRateVariable: | |
378 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR"); | |
379 | pCommonParam->EnableFRMRateControl = 0; /* 0: Disable, 1: Frame level RC */ | |
380 | pCommonParam->EnableMBRateControl = 0; /* 0: Disable, 1:MB level RC */ | |
381 | pCommonParam->CBRPeriodRf = 100; | |
382 | break; | |
383 | case OMX_Video_ControlRateConstant: | |
384 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode CBR"); | |
385 | pCommonParam->EnableFRMRateControl = 1; /* 0: Disable, 1: Frame level RC */ | |
386 | pCommonParam->EnableMBRateControl = 1; /* 0: Disable, 1:MB level RC */ | |
387 | pCommonParam->CBRPeriodRf = 10; | |
388 | break; | |
389 | case OMX_Video_ControlRateDisable: | |
390 | default: /*Android default */ | |
391 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR"); | |
392 | pCommonParam->EnableFRMRateControl = 0; | |
393 | pCommonParam->EnableMBRateControl = 0; | |
394 | pCommonParam->CBRPeriodRf = 100; | |
20d3e6e3 JC |
395 | break; |
396 | } | |
397 | ||
800a8d75 | 398 | Print_H263Enc_Param(pEncParam); |
20d3e6e3 JC |
399 | } |
400 | ||
800a8d75 | 401 | static void Change_Mpeg4Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent) |
20d3e6e3 | 402 | { |
800a8d75 | 403 | EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL; |
20d3e6e3 | 404 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL; |
800a8d75 JC |
405 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; |
406 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
38ef2572 | 407 | EXYNOS_MFC_MPEG4ENC_HANDLE *pMFCMpeg4Handle; |
800a8d75 JC |
408 | |
409 | ExynosVideoEncOps *pEncOps = NULL; | |
410 | ExynosVideoEncParam *pEncParam = NULL; | |
411 | ExynosVideoEncCommonParam *pCommonParam = NULL; | |
412 | ExynosVideoEncMpeg4Param *pMpeg4Param = NULL; | |
413 | ||
414 | int setParam = 0; | |
20d3e6e3 JC |
415 | |
416 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
800a8d75 | 417 | pMpeg4Enc = pVideoEnc->hCodecHandle; |
38ef2572 | 418 | pMFCMpeg4Handle = &pMpeg4Enc->hMFCMpeg4Handle; |
800a8d75 | 419 | pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; |
20d3e6e3 | 420 | pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; |
38ef2572 | 421 | pEncOps = pMFCMpeg4Handle->pEncOps; |
800a8d75 | 422 | |
38ef2572 | 423 | pEncParam = &pMFCMpeg4Handle->encParam; |
800a8d75 JC |
424 | pCommonParam = &pEncParam->commonParam; |
425 | pMpeg4Param = &pEncParam->codecParam.mpeg4; | |
20d3e6e3 JC |
426 | |
427 | if (pVideoEnc->IntraRefreshVOP == OMX_TRUE) { | |
800a8d75 JC |
428 | setParam = VIDEO_FRAME_I; |
429 | pEncOps->Set_FrameType(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam); | |
20d3e6e3 JC |
430 | pVideoEnc->IntraRefreshVOP = OMX_FALSE; |
431 | } | |
800a8d75 JC |
432 | if (pCommonParam->IDRPeriod != (int)pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1) { |
433 | setParam = pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1; | |
434 | pEncOps->Set_IDRPeriod(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam); | |
20d3e6e3 | 435 | } |
800a8d75 JC |
436 | if (pCommonParam->Bitrate != (int)pExynosOutputPort->portDefinition.format.video.nBitrate) { |
437 | setParam = pExynosOutputPort->portDefinition.format.video.nBitrate; | |
438 | pEncOps->Set_BitRate(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam); | |
20d3e6e3 JC |
439 | } |
440 | if (pMpeg4Param->TimeIncreamentRes != (int)((pExynosOutputPort->portDefinition.format.video.xFramerate) >> 16)) { | |
800a8d75 JC |
441 | setParam = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16; |
442 | pEncOps->Set_FrameRate(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam); | |
20d3e6e3 JC |
443 | } |
444 | ||
800a8d75 | 445 | Set_Mpeg4Enc_Param(pExynosComponent); |
20d3e6e3 JC |
446 | } |
447 | ||
800a8d75 | 448 | static void Change_H263Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent) |
20d3e6e3 | 449 | { |
800a8d75 | 450 | EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL; |
20d3e6e3 | 451 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL; |
800a8d75 JC |
452 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; |
453 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
38ef2572 | 454 | EXYNOS_MFC_MPEG4ENC_HANDLE *pMFCMpeg4Handle; |
20d3e6e3 | 455 | |
800a8d75 JC |
456 | ExynosVideoEncOps *pEncOps = NULL; |
457 | ExynosVideoEncParam *pEncParam = NULL; | |
458 | ExynosVideoEncCommonParam *pCommonParam = NULL; | |
459 | ExynosVideoEncH263Param *pH263Param = NULL; | |
20d3e6e3 | 460 | |
800a8d75 | 461 | int setParam = 0; |
20d3e6e3 JC |
462 | |
463 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
800a8d75 | 464 | pMpeg4Enc = pVideoEnc->hCodecHandle; |
38ef2572 | 465 | pMFCMpeg4Handle = &pMpeg4Enc->hMFCMpeg4Handle; |
800a8d75 | 466 | pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; |
20d3e6e3 | 467 | pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; |
38ef2572 | 468 | pEncOps = pMFCMpeg4Handle->pEncOps; |
800a8d75 | 469 | |
38ef2572 | 470 | pEncParam = &pMFCMpeg4Handle->encParam; |
800a8d75 JC |
471 | pCommonParam = &pEncParam->commonParam; |
472 | pH263Param = &pEncParam->codecParam.h263; | |
20d3e6e3 JC |
473 | |
474 | if (pVideoEnc->IntraRefreshVOP == OMX_TRUE) { | |
800a8d75 JC |
475 | setParam = VIDEO_FRAME_I; |
476 | pEncOps->Set_FrameType(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam); | |
20d3e6e3 JC |
477 | pVideoEnc->IntraRefreshVOP = OMX_FALSE; |
478 | } | |
800a8d75 JC |
479 | if (pCommonParam->IDRPeriod != (int)pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1) { |
480 | setParam = pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1; | |
481 | pEncOps->Set_IDRPeriod(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam); | |
20d3e6e3 | 482 | } |
800a8d75 JC |
483 | if (pCommonParam->Bitrate != (int)pExynosOutputPort->portDefinition.format.video.nBitrate) { |
484 | setParam = pExynosOutputPort->portDefinition.format.video.nBitrate; | |
485 | pEncOps->Set_BitRate(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam); | |
20d3e6e3 JC |
486 | } |
487 | if (pH263Param->FrameRate != (int)((pExynosOutputPort->portDefinition.format.video.xFramerate) >> 16)) { | |
800a8d75 JC |
488 | setParam = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16; |
489 | pEncOps->Set_FrameRate(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam); | |
20d3e6e3 JC |
490 | } |
491 | ||
800a8d75 | 492 | Set_H263Enc_Param(pExynosComponent); |
20d3e6e3 JC |
493 | } |
494 | ||
38ef2572 | 495 | OMX_ERRORTYPE GetCodecInputPrivateData(OMX_PTR codecBuffer, OMX_PTR addr[], OMX_U32 size[]) |
20d3e6e3 | 496 | { |
38ef2572 | 497 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
20d3e6e3 | 498 | |
38ef2572 JC |
499 | EXIT: |
500 | return ret; | |
501 | } | |
20d3e6e3 | 502 | |
38ef2572 JC |
503 | OMX_ERRORTYPE GetCodecOutputPrivateData(OMX_PTR codecBuffer, OMX_PTR *pVirtAddr, OMX_U32 *dataSize) |
504 | { | |
505 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
506 | ExynosVideoBuffer *pCodecBuffer; | |
507 | ||
508 | if (codecBuffer == NULL) { | |
509 | ret = OMX_ErrorBadParameter; | |
20d3e6e3 JC |
510 | goto EXIT; |
511 | } | |
512 | ||
38ef2572 | 513 | pCodecBuffer = (ExynosVideoBuffer *)codecBuffer; |
20d3e6e3 | 514 | |
38ef2572 JC |
515 | if (pVirtAddr != NULL) |
516 | *pVirtAddr = pCodecBuffer->planes[0].addr; | |
20d3e6e3 | 517 | |
38ef2572 JC |
518 | if (dataSize != NULL) |
519 | *dataSize = pCodecBuffer->planes[0].allocSize; | |
20d3e6e3 | 520 | |
38ef2572 | 521 | pCodecBuffer = (ExynosVideoBuffer *)codecBuffer; |
20d3e6e3 | 522 | |
38ef2572 JC |
523 | EXIT: |
524 | return ret; | |
525 | } | |
20d3e6e3 | 526 | |
38ef2572 JC |
527 | OMX_ERRORTYPE Mpeg4CodecOpen(EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc) |
528 | { | |
529 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
20d3e6e3 | 530 | |
38ef2572 JC |
531 | ExynosVideoEncOps *pEncOps = NULL; |
532 | ExynosVideoEncBufferOps *pInbufOps = NULL; | |
533 | ExynosVideoEncBufferOps *pOutbufOps = NULL; | |
20d3e6e3 | 534 | |
38ef2572 | 535 | FunctionIn(); |
20d3e6e3 | 536 | |
38ef2572 JC |
537 | if (pMpeg4Enc == NULL) { |
538 | ret = OMX_ErrorBadParameter; | |
539 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); | |
540 | goto EXIT; | |
20d3e6e3 | 541 | } |
20d3e6e3 | 542 | |
38ef2572 JC |
543 | /* alloc ops structure */ |
544 | pEncOps = (ExynosVideoEncOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoEncOps)); | |
545 | pInbufOps = (ExynosVideoEncBufferOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoEncBufferOps)); | |
546 | pOutbufOps = (ExynosVideoEncBufferOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoEncBufferOps)); | |
20d3e6e3 | 547 | |
38ef2572 JC |
548 | if ((pEncOps == NULL) || (pInbufOps == NULL) || (pOutbufOps == NULL)) { |
549 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate encoder ops buffer"); | |
550 | ret = OMX_ErrorInsufficientResources; | |
551 | goto EXIT; | |
20d3e6e3 | 552 | } |
20d3e6e3 | 553 | |
38ef2572 JC |
554 | pMpeg4Enc->hMFCMpeg4Handle.pEncOps = pEncOps; |
555 | pMpeg4Enc->hMFCMpeg4Handle.pInbufOps = pInbufOps; | |
556 | pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps = pOutbufOps; | |
20d3e6e3 | 557 | |
38ef2572 JC |
558 | /* function pointer mapping */ |
559 | pEncOps->nSize = sizeof(ExynosVideoEncOps); | |
560 | pInbufOps->nSize = sizeof(ExynosVideoEncBufferOps); | |
561 | pOutbufOps->nSize = sizeof(ExynosVideoEncBufferOps); | |
20d3e6e3 | 562 | |
38ef2572 | 563 | Exynos_Video_Register_Encoder(pEncOps, pInbufOps, pOutbufOps); |
20d3e6e3 | 564 | |
38ef2572 JC |
565 | /* check mandatory functions for encoder ops */ |
566 | if ((pEncOps->Init == NULL) || (pEncOps->Finalize == NULL) || | |
567 | (pEncOps->Set_FrameTag == NULL) || (pEncOps->Get_FrameTag == NULL)) { | |
568 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied"); | |
569 | ret = OMX_ErrorInsufficientResources; | |
570 | goto EXIT; | |
571 | } | |
20d3e6e3 | 572 | |
38ef2572 JC |
573 | /* check mandatory functions for buffer ops */ |
574 | if ((pInbufOps->Setup == NULL) || (pOutbufOps->Setup == NULL) || | |
575 | (pInbufOps->Run == NULL) || (pOutbufOps->Run == NULL) || | |
576 | (pInbufOps->Stop == NULL) || (pOutbufOps->Stop == NULL) || | |
577 | (pInbufOps->Enqueue == NULL) || (pOutbufOps->Enqueue == NULL) || | |
578 | (pInbufOps->Dequeue == NULL) || (pOutbufOps->Dequeue == NULL)) { | |
579 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied"); | |
580 | ret = OMX_ErrorInsufficientResources; | |
581 | goto EXIT; | |
20d3e6e3 | 582 | } |
20d3e6e3 | 583 | |
38ef2572 | 584 | /* alloc context, open, querycap */ |
c94beaeb | 585 | pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.pEncOps->Init(V4L2_MEMORY_DMABUF); |
38ef2572 JC |
586 | if (pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle == NULL) { |
587 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate context buffer"); | |
588 | ret = OMX_ErrorInsufficientResources; | |
589 | goto EXIT; | |
590 | } | |
20d3e6e3 | 591 | |
38ef2572 | 592 | ret = OMX_ErrorNone; |
20d3e6e3 | 593 | |
38ef2572 | 594 | EXIT: |
44025235 SK |
595 | if (ret != OMX_ErrorNone) { |
596 | if (pEncOps != NULL) { | |
597 | Exynos_OSAL_Free(pEncOps); | |
598 | pMpeg4Enc->hMFCMpeg4Handle.pEncOps = NULL; | |
599 | } | |
600 | if (pInbufOps != NULL) { | |
601 | Exynos_OSAL_Free(pInbufOps); | |
602 | pMpeg4Enc->hMFCMpeg4Handle.pInbufOps = NULL; | |
603 | } | |
604 | if (pOutbufOps != NULL) { | |
605 | Exynos_OSAL_Free(pOutbufOps); | |
606 | pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps = NULL; | |
607 | } | |
608 | } | |
609 | ||
38ef2572 | 610 | FunctionOut(); |
20d3e6e3 | 611 | |
38ef2572 JC |
612 | return ret; |
613 | } | |
20d3e6e3 | 614 | |
38ef2572 JC |
615 | OMX_ERRORTYPE Mpeg4CodecClose(EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc) |
616 | { | |
617 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
618 | void *hMFCHandle = NULL; | |
619 | ExynosVideoEncOps *pEncOps = NULL; | |
620 | ExynosVideoEncBufferOps *pInbufOps = NULL; | |
621 | ExynosVideoEncBufferOps *pOutbufOps = NULL; | |
20d3e6e3 | 622 | |
3e79a27e SK |
623 | FunctionIn(); |
624 | ||
38ef2572 JC |
625 | if (pMpeg4Enc == NULL) { |
626 | ret = OMX_ErrorBadParameter; | |
627 | goto EXIT; | |
628 | } | |
20d3e6e3 | 629 | |
38ef2572 JC |
630 | hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; |
631 | pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; | |
632 | pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps; | |
633 | pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
634 | ||
635 | if (hMFCHandle != NULL) { | |
636 | pEncOps->Finalize(hMFCHandle); | |
637 | hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = NULL; | |
20d3e6e3 | 638 | } |
38ef2572 JC |
639 | if (pOutbufOps != NULL) { |
640 | Exynos_OSAL_Free(pOutbufOps); | |
641 | pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps = NULL; | |
642 | } | |
643 | if (pInbufOps != NULL) { | |
644 | Exynos_OSAL_Free(pInbufOps); | |
645 | pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps = NULL; | |
646 | } | |
647 | if (pEncOps != NULL) { | |
648 | Exynos_OSAL_Free(pEncOps); | |
649 | pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps = NULL; | |
20d3e6e3 | 650 | } |
38ef2572 JC |
651 | |
652 | ret = OMX_ErrorNone; | |
653 | ||
20d3e6e3 JC |
654 | EXIT: |
655 | FunctionOut(); | |
656 | ||
657 | return ret; | |
658 | } | |
659 | ||
38ef2572 | 660 | OMX_ERRORTYPE Mpeg4CodecStart(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) |
20d3e6e3 | 661 | { |
38ef2572 JC |
662 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
663 | void *hMFCHandle = NULL; | |
664 | ExynosVideoEncOps *pEncOps = NULL; | |
665 | ExynosVideoEncBufferOps *pInbufOps = NULL; | |
666 | ExynosVideoEncBufferOps *pOutbufOps = NULL; | |
667 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
668 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
20d3e6e3 JC |
669 | |
670 | FunctionIn(); | |
671 | ||
38ef2572 | 672 | if (pOMXComponent == NULL) { |
20d3e6e3 JC |
673 | ret = OMX_ErrorBadParameter; |
674 | goto EXIT; | |
675 | } | |
38ef2572 JC |
676 | |
677 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle; | |
678 | if (pVideoEnc == NULL) { | |
20d3e6e3 JC |
679 | ret = OMX_ErrorBadParameter; |
680 | goto EXIT; | |
681 | } | |
682 | ||
38ef2572 JC |
683 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)pVideoEnc->hCodecHandle; |
684 | if (pMpeg4Enc == NULL) { | |
685 | ret = OMX_ErrorBadParameter; | |
20d3e6e3 JC |
686 | goto EXIT; |
687 | } | |
688 | ||
38ef2572 JC |
689 | hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; |
690 | pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; | |
691 | pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps; | |
692 | pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
20d3e6e3 | 693 | |
38ef2572 JC |
694 | if (nPortIndex == INPUT_PORT_INDEX) |
695 | pInbufOps->Run(hMFCHandle); | |
696 | else if (nPortIndex == OUTPUT_PORT_INDEX) | |
697 | pOutbufOps->Run(hMFCHandle); | |
698 | ||
699 | ret = OMX_ErrorNone; | |
700 | ||
701 | EXIT: | |
702 | FunctionOut(); | |
703 | ||
704 | return ret; | |
705 | } | |
706 | ||
707 | OMX_ERRORTYPE Mpeg4CodecStop(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
708 | { | |
709 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
710 | void *hMFCHandle = NULL; | |
711 | ExynosVideoEncOps *pEncOps = NULL; | |
712 | ExynosVideoEncBufferOps *pInbufOps = NULL; | |
713 | ExynosVideoEncBufferOps *pOutbufOps = NULL; | |
714 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
715 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
716 | ||
717 | FunctionIn(); | |
718 | ||
719 | if (pOMXComponent == NULL) { | |
720 | ret = OMX_ErrorBadParameter; | |
721 | goto EXIT; | |
722 | } | |
723 | ||
724 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle; | |
725 | if (pVideoEnc == NULL) { | |
726 | ret = OMX_ErrorBadParameter; | |
727 | goto EXIT; | |
728 | } | |
729 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)pVideoEnc->hCodecHandle; | |
730 | if (pMpeg4Enc == NULL) { | |
731 | ret = OMX_ErrorBadParameter; | |
732 | goto EXIT; | |
733 | } | |
734 | ||
735 | hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; | |
736 | pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; | |
737 | pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps; | |
738 | pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
739 | ||
740 | if ((nPortIndex == INPUT_PORT_INDEX) && (pInbufOps != NULL)) | |
741 | pInbufOps->Stop(hMFCHandle); | |
742 | else if ((nPortIndex == OUTPUT_PORT_INDEX) && (pOutbufOps != NULL)) | |
743 | pOutbufOps->Stop(hMFCHandle); | |
744 | ||
745 | ret = OMX_ErrorNone; | |
746 | ||
747 | EXIT: | |
748 | FunctionOut(); | |
749 | ||
750 | return ret; | |
751 | } | |
752 | ||
753 | OMX_ERRORTYPE Mpeg4CodecOutputBufferProcessRun(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
754 | { | |
755 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
756 | void *hMFCHandle = NULL; | |
757 | ExynosVideoEncOps *pEncOps = NULL; | |
758 | ExynosVideoEncBufferOps *pInbufOps = NULL; | |
759 | ExynosVideoEncBufferOps *pOutbufOps = NULL; | |
760 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
761 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
762 | ||
763 | FunctionIn(); | |
764 | ||
765 | if (pOMXComponent == NULL) { | |
766 | ret = OMX_ErrorBadParameter; | |
767 | goto EXIT; | |
768 | } | |
769 | ||
770 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle; | |
771 | if (pVideoEnc == NULL) { | |
772 | ret = OMX_ErrorBadParameter; | |
773 | goto EXIT; | |
774 | } | |
775 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)pVideoEnc->hCodecHandle; | |
776 | if (pMpeg4Enc == NULL) { | |
777 | ret = OMX_ErrorBadParameter; | |
778 | goto EXIT; | |
779 | } | |
780 | ||
781 | hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; | |
782 | pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; | |
783 | pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps; | |
784 | pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
785 | ||
786 | if (nPortIndex == INPUT_PORT_INDEX) { | |
787 | if (pMpeg4Enc->bSourceStart == OMX_FALSE) { | |
788 | Exynos_OSAL_SignalSet(pMpeg4Enc->hSourceStartEvent); | |
789 | Exynos_OSAL_SleepMillisec(0); | |
790 | } | |
791 | } | |
792 | ||
793 | if (nPortIndex == OUTPUT_PORT_INDEX) { | |
794 | if (pMpeg4Enc->bDestinationStart == OMX_FALSE) { | |
795 | Exynos_OSAL_SignalSet(pMpeg4Enc->hDestinationStartEvent); | |
796 | Exynos_OSAL_SleepMillisec(0); | |
797 | } | |
798 | } | |
799 | ||
800 | ret = OMX_ErrorNone; | |
801 | ||
802 | EXIT: | |
803 | FunctionOut(); | |
804 | ||
805 | return ret; | |
806 | } | |
807 | ||
808 | OMX_ERRORTYPE Mpeg4CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
809 | { | |
810 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
811 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
812 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
813 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
814 | void *hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; | |
815 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
816 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
817 | int i, nOutbufs; | |
38ef2572 JC |
818 | |
819 | ExynosVideoEncOps *pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; | |
820 | ExynosVideoEncBufferOps *pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps; | |
821 | ExynosVideoEncBufferOps *pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
822 | ||
823 | FunctionIn(); | |
824 | ||
825 | if ((nPortIndex == INPUT_PORT_INDEX) && | |
826 | (pMpeg4Enc->bSourceStart == OMX_TRUE)) { | |
38ef2572 | 827 | Exynos_CodecBufferReset(pExynosComponent, INPUT_PORT_INDEX); |
38ef2572 JC |
828 | |
829 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { | |
830 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]); | |
91f44a5d SK |
831 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); |
832 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); | |
38ef2572 JC |
833 | |
834 | Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); | |
835 | } | |
836 | ||
837 | pInbufOps->Clear_Queue(hMFCHandle); | |
838 | } else if ((nPortIndex == OUTPUT_PORT_INDEX) && | |
839 | (pMpeg4Enc->bDestinationStart == OMX_TRUE)) { | |
840 | OMX_U32 dataLen[2] = {0, 0}; | |
841 | ExynosVideoBuffer *pBuffer = NULL; | |
38ef2572 | 842 | |
3e79a27e | 843 | Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX); |
38ef2572 JC |
844 | |
845 | for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { | |
846 | pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer); | |
847 | Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer); | |
848 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncOutputBuffer[%d]: 0x%x", i, pVideoEnc->pMFCEncOutputBuffer[i]); | |
91f44a5d SK |
849 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); |
850 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); | |
38ef2572 JC |
851 | } |
852 | pOutbufOps->Clear_Queue(hMFCHandle); | |
853 | } else { | |
854 | ret = OMX_ErrorBadParameter; | |
855 | goto EXIT; | |
856 | } | |
857 | ||
858 | EXIT: | |
859 | FunctionOut(); | |
860 | ||
861 | return ret; | |
862 | } | |
863 | ||
864 | OMX_ERRORTYPE Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) | |
865 | { | |
866 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
867 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
868 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
869 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
870 | EXYNOS_MFC_MPEG4ENC_HANDLE *pMFCMpeg4Handle = &pMpeg4Enc->hMFCMpeg4Handle; | |
871 | void *hMFCHandle = pMFCMpeg4Handle->hMFCHandle; | |
872 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
873 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
874 | OMX_U32 oneFrameSize = pSrcInputData->dataLen; | |
875 | ||
876 | ExynosVideoEncOps *pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; | |
877 | ExynosVideoEncBufferOps *pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps; | |
878 | ExynosVideoEncBufferOps *pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
833233fa SK |
879 | ExynosVideoEncParam *pEncParam = NULL; |
880 | ||
881 | ExynosVideoGeometry bufferConf; | |
882 | OMX_U32 inputBufferNumber = 0; | |
883 | int i, nOutbufs; | |
38ef2572 JC |
884 | |
885 | FunctionIn(); | |
886 | ||
887 | if ((oneFrameSize <= 0) && (pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS)) { | |
54cbf397 SK |
888 | OMX_BUFFERHEADERTYPE *OMXBuffer = NULL; |
889 | OMXBuffer = Exynos_OutputBufferGetQueue_Direct(pExynosComponent); | |
890 | if (OMXBuffer == NULL) { | |
38ef2572 JC |
891 | ret = OMX_ErrorUndefined; |
892 | goto EXIT; | |
893 | } | |
38ef2572 | 894 | |
54cbf397 SK |
895 | OMXBuffer->nTimeStamp = pSrcInputData->timeStamp; |
896 | OMXBuffer->nFlags = pSrcInputData->nFlags; | |
897 | Exynos_OMX_OutputBufferReturn(pOMXComponent, OMXBuffer); | |
38ef2572 JC |
898 | |
899 | ret = OMX_ErrorNone; | |
900 | goto EXIT; | |
901 | } | |
902 | ||
833233fa SK |
903 | if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) |
904 | Set_Mpeg4Enc_Param(pExynosComponent); | |
905 | else | |
906 | Set_H263Enc_Param(pExynosComponent); | |
38ef2572 | 907 | |
833233fa SK |
908 | pEncParam = &pMFCMpeg4Handle->encParam; |
909 | if (pEncOps->Set_EncParam) { | |
910 | if(pEncOps->Set_EncParam(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, pEncParam) != VIDEO_ERROR_NONE) { | |
911 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for input buffer"); | |
912 | ret = OMX_ErrorInsufficientResources; | |
913 | goto EXIT; | |
914 | } | |
38ef2572 JC |
915 | } |
916 | ||
833233fa SK |
917 | /* input buffer info: only 3 config values needed */ |
918 | Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf)); | |
33d6044e | 919 | bufferConf.eColorFormat = pEncParam->commonParam.FrameMap;//VIDEO_COLORFORMAT_NV12; |
833233fa SK |
920 | bufferConf.nFrameWidth = pExynosInputPort->portDefinition.format.video.nFrameWidth; |
921 | bufferConf.nFrameHeight = pExynosInputPort->portDefinition.format.video.nFrameHeight; | |
922 | pInbufOps->Set_Shareable(hMFCHandle); | |
923 | if (pExynosInputPort->bufferProcessType == BUFFER_SHARE) { | |
4bd72215 | 924 | inputBufferNumber = MAX_CAMERA_INPUTBUFFER_NUM; /* Need change to number of camera buffer */ |
833233fa SK |
925 | } else if ((pExynosInputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { |
926 | inputBufferNumber = MFC_INPUT_BUFFER_NUM_MAX; | |
927 | } | |
38ef2572 | 928 | |
fa894814 SK |
929 | if ((pExynosInputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { |
930 | /* should be done before prepare input buffer */ | |
931 | if (pInbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) { | |
932 | ret = OMX_ErrorInsufficientResources; | |
933 | goto EXIT; | |
934 | } | |
38ef2572 | 935 | } |
833233fa SK |
936 | |
937 | /* set input buffer geometry */ | |
938 | if (pInbufOps->Set_Geometry) { | |
939 | if (pInbufOps->Set_Geometry(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) { | |
940 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for input buffer"); | |
941 | ret = OMX_ErrorInsufficientResources; | |
942 | goto EXIT; | |
943 | } | |
944 | } | |
945 | ||
946 | /* setup input buffer */ | |
947 | if (pInbufOps->Setup(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, inputBufferNumber) != VIDEO_ERROR_NONE) { | |
948 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup input buffer"); | |
949 | ret = OMX_ErrorInsufficientResources; | |
38ef2572 JC |
950 | goto EXIT; |
951 | } | |
952 | ||
91f44a5d SK |
953 | ExynosVideoPlane planes[MFC_INPUT_BUFFER_PLANE]; |
954 | int plane; | |
955 | ||
833233fa SK |
956 | if ((pExynosInputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { |
957 | /* Register input buffer */ | |
958 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { | |
91f44a5d SK |
959 | for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) { |
960 | planes[plane].addr = pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[plane]; | |
961 | planes[plane].allocSize = pVideoEnc->pMFCEncInputBuffer[i]->bufferSize[plane]; | |
962 | planes[plane].fd = pVideoEnc->pMFCEncInputBuffer[i]->fd[plane]; | |
963 | } | |
964 | if (pInbufOps->Register(hMFCHandle, planes, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
833233fa SK |
965 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer"); |
966 | ret = OMX_ErrorInsufficientResources; | |
967 | goto EXIT; | |
968 | } | |
969 | } | |
970 | } else if (pExynosInputPort->bufferProcessType == BUFFER_SHARE) { | |
971 | if (pExynosInputPort->bStoreMetaData == OMX_TRUE) { | |
91f44a5d SK |
972 | /*************/ |
973 | /* TBD */ | |
974 | /*************/ | |
975 | /* Does not require any actions. */ | |
976 | } else { | |
977 | ret = OMX_ErrorNotImplemented; | |
978 | goto EXIT; | |
833233fa SK |
979 | } |
980 | } | |
38ef2572 JC |
981 | |
982 | pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFCSrc = OMX_TRUE; | |
983 | ret = OMX_ErrorNone; | |
984 | ||
985 | EXIT: | |
986 | FunctionOut(); | |
987 | ||
988 | return ret; | |
989 | } | |
990 | ||
991 | OMX_ERRORTYPE Mpeg4CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent) | |
992 | { | |
993 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
994 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
995 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
996 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
997 | EXYNOS_MFC_MPEG4ENC_HANDLE *pMFCMpeg4Handle = &pMpeg4Enc->hMFCMpeg4Handle; | |
998 | void *hMFCHandle = pMFCMpeg4Handle->hMFCHandle; | |
833233fa SK |
999 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; |
1000 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
38ef2572 JC |
1001 | |
1002 | ExynosVideoEncOps *pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; | |
1003 | ExynosVideoEncBufferOps *pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps; | |
1004 | ExynosVideoEncBufferOps *pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
833233fa | 1005 | ExynosVideoGeometry bufferConf; |
833233fa | 1006 | int i, nOutbufs; |
38ef2572 JC |
1007 | |
1008 | FunctionIn(); | |
1009 | ||
833233fa SK |
1010 | int OutBufferSize = pExynosOutputPort->portDefinition.format.video.nFrameWidth * pExynosOutputPort->portDefinition.format.video.nFrameHeight * 3 / 2; |
1011 | /* set geometry for output (dst) */ | |
1012 | if (pOutbufOps->Set_Geometry) { | |
1013 | /* only 2 config values needed */ | |
1014 | if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) | |
1015 | bufferConf.eCompressionFormat = VIDEO_CODING_MPEG4; | |
1016 | else | |
1245032e | 1017 | bufferConf.eCompressionFormat = VIDEO_CODING_H263; |
833233fa SK |
1018 | bufferConf.nSizeImage = OutBufferSize; |
1019 | ||
1020 | if (pOutbufOps->Set_Geometry(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) { | |
1021 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for output buffer"); | |
1022 | ret = OMX_ErrorInsufficientResources; | |
1023 | goto EXIT; | |
1024 | } | |
1025 | } | |
1026 | ||
1027 | /* should be done before prepare output buffer */ | |
1028 | if (pOutbufOps->Enable_Cacheable) { | |
1029 | if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) { | |
1030 | ret = OMX_ErrorInsufficientResources; | |
1031 | goto EXIT; | |
1032 | } | |
1033 | } | |
1034 | ||
1035 | if (pOutbufOps->Set_Shareable) { | |
1036 | pOutbufOps->Set_Shareable(hMFCHandle); | |
1037 | } | |
1038 | int SetupBufferNumber = 0; | |
1039 | if ((pExynosOutputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) | |
1040 | SetupBufferNumber = MFC_OUTPUT_BUFFER_NUM_MAX; | |
1041 | else | |
1042 | SetupBufferNumber = pExynosOutputPort->portDefinition.nBufferCountActual; | |
1043 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "SetupBufferNumber:%d", SetupBufferNumber); | |
1044 | ||
1045 | if (pOutbufOps->Setup(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, SetupBufferNumber) != VIDEO_ERROR_NONE) { | |
1046 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer"); | |
1047 | ret = OMX_ErrorInsufficientResources; | |
1048 | goto EXIT; | |
1049 | } | |
1050 | ||
1051 | OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0}; | |
833233fa SK |
1052 | if ((pExynosOutputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { |
1053 | /* Register input buffer */ | |
1054 | for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { | |
91f44a5d SK |
1055 | ExynosVideoPlane plane; |
1056 | pVideoEnc->pMFCEncOutputBuffer[i] = (CODEC_ENC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_ENC_BUFFER)); | |
1057 | pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr[0] = | |
833233fa | 1058 | (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoEnc->hSharedMemory, OutBufferSize, NORMAL_MEMORY); |
91f44a5d | 1059 | if (pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr[0] == NULL) { |
833233fa SK |
1060 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Alloc output buffer"); |
1061 | ret = OMX_ErrorInsufficientResources; | |
1062 | goto EXIT; | |
1063 | } | |
91f44a5d SK |
1064 | pVideoEnc->pMFCEncOutputBuffer[i]->fd[0] = |
1065 | Exynos_OSAL_SharedMemory_VirtToION(pVideoEnc->hSharedMemory, pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr[0]); | |
1066 | pVideoEnc->pMFCEncOutputBuffer[i]->bufferSize[0] = OutBufferSize; | |
1067 | ||
1068 | plane.addr = pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr[0]; | |
1069 | plane.fd = pVideoEnc->pMFCEncOutputBuffer[i]->fd[0]; | |
1070 | plane.allocSize = pVideoEnc->pMFCEncOutputBuffer[i]->bufferSize[0]; | |
1071 | ||
1072 | if (pOutbufOps->Register(hMFCHandle, &plane, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
833233fa SK |
1073 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer"); |
1074 | ret = OMX_ErrorInsufficientResources; | |
1075 | goto EXIT; | |
1076 | } | |
91f44a5d SK |
1077 | pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr, |
1078 | (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL); | |
833233fa SK |
1079 | } |
1080 | } else if ((pExynosOutputPort->bufferProcessType & BUFFER_SHARE) == BUFFER_SHARE) { | |
1081 | /* Register input buffer */ | |
1082 | /*************/ | |
1083 | /* TBD */ | |
1084 | /*************/ | |
91f44a5d | 1085 | ExynosVideoPlane plane; |
833233fa | 1086 | for (i = 0; i < pExynosOutputPort->portDefinition.nBufferCountActual; i++) { |
91f44a5d SK |
1087 | plane.addr = pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer; |
1088 | plane.fd = pExynosOutputPort->extendBufferHeader[i].buf_fd[0]; | |
1089 | plane.allocSize = OutBufferSize; | |
1090 | if (pOutbufOps->Register(hMFCHandle, &plane, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
833233fa SK |
1091 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer"); |
1092 | ret = OMX_ErrorInsufficientResources; | |
1093 | goto EXIT; | |
1094 | } | |
91f44a5d SK |
1095 | pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)&pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer, |
1096 | (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL); | |
833233fa SK |
1097 | } |
1098 | } | |
1099 | ||
38ef2572 JC |
1100 | /* start header encoding */ |
1101 | if (pOutbufOps->Run) { | |
833233fa SK |
1102 | if (pOutbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) { |
1103 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run output buffer"); | |
38ef2572 JC |
1104 | ret = OMX_ErrorInsufficientResources; |
1105 | goto EXIT; | |
1106 | } | |
1107 | } | |
1108 | ||
833233fa SK |
1109 | if (pExynosOutputPort->bufferProcessType == BUFFER_SHARE) { |
1110 | OMX_BUFFERHEADERTYPE *OMXBuffer = NULL; | |
1111 | ExynosVideoBuffer *pVideoBuffer = NULL; | |
38ef2572 | 1112 | |
833233fa SK |
1113 | OMXBuffer = Exynos_OutputBufferGetQueue_Direct(pExynosComponent); |
1114 | if (OMXBuffer == OMX_ErrorNone) { | |
1115 | ret = OMX_ErrorUndefined; | |
1116 | goto EXIT; | |
1117 | } | |
1118 | ||
1119 | if ((pVideoBuffer = pOutbufOps->Dequeue(hMFCHandle)) == NULL) { | |
1120 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - pOutbufOps->Dequeue", __FUNCTION__, __LINE__); | |
1121 | ret = OMX_ErrorUndefined; | |
1122 | goto EXIT; | |
1123 | } | |
1124 | ||
1125 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "dst:0x%x, src:0x%x, dataSize:%d", | |
1126 | OMXBuffer->pBuffer, | |
1127 | pVideoBuffer->planes[0].addr, | |
1128 | pVideoBuffer->planes[0].dataSize); | |
91f44a5d | 1129 | Exynos_OSAL_Memcpy(OMXBuffer->pBuffer, pVideoBuffer->planes[0].addr, pVideoBuffer->planes[0].dataSize); |
833233fa SK |
1130 | OMXBuffer->nFilledLen = pVideoBuffer->planes[0].dataSize; |
1131 | OMXBuffer->nOffset = 0; | |
1132 | OMXBuffer->nTimeStamp = 0; | |
1133 | OMXBuffer->nFlags |= OMX_BUFFERFLAG_CODECCONFIG; | |
1134 | OMXBuffer->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; | |
1135 | Exynos_OMX_OutputBufferReturn(pOMXComponent, OMXBuffer); | |
38ef2572 | 1136 | |
833233fa SK |
1137 | pVideoEnc->bFirstOutput = OMX_TRUE; |
1138 | ret = OMX_ErrorNone; | |
1139 | ||
1140 | Mpeg4CodecStop(pOMXComponent, OUTPUT_PORT_INDEX); | |
1141 | } | |
1142 | pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFCDst = OMX_TRUE; | |
38ef2572 JC |
1143 | |
1144 | ret = OMX_ErrorNone; | |
1145 | ||
1146 | EXIT: | |
1147 | FunctionOut(); | |
1148 | ||
1149 | return ret; | |
1150 | } | |
1151 | ||
1152 | OMX_ERRORTYPE Exynos_Mpeg4Enc_GetParameter( | |
1153 | OMX_IN OMX_HANDLETYPE hComponent, | |
1154 | OMX_IN OMX_INDEXTYPE nParamIndex, | |
1155 | OMX_INOUT OMX_PTR pComponentParameterStructure) | |
1156 | { | |
1157 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1158 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1159 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1160 | ||
1161 | FunctionIn(); | |
1162 | ||
1163 | if (hComponent == NULL || pComponentParameterStructure == NULL) { | |
1164 | ret = OMX_ErrorBadParameter; | |
1165 | goto EXIT; | |
1166 | } | |
1167 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1168 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1169 | if (ret != OMX_ErrorNone) { | |
1170 | goto EXIT; | |
1171 | } | |
1172 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1173 | ret = OMX_ErrorBadParameter; | |
1174 | goto EXIT; | |
1175 | } | |
1176 | ||
1177 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1178 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1179 | ret = OMX_ErrorInvalidState; | |
1180 | goto EXIT; | |
1181 | } | |
1182 | ||
1183 | switch (nParamIndex) { | |
1184 | case OMX_IndexParamVideoMpeg4: | |
1185 | { | |
1186 | OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Component = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; | |
1187 | OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Component = NULL; | |
1188 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
1189 | ||
1190 | ret = Exynos_OMX_Check_SizeVersion(pDstMpeg4Component, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); | |
1191 | if (ret != OMX_ErrorNone) { | |
1192 | goto EXIT; | |
1193 | } | |
1194 | ||
1195 | if (pDstMpeg4Component->nPortIndex >= ALL_PORT_NUM) { | |
1196 | ret = OMX_ErrorBadPortIndex; | |
1197 | goto EXIT; | |
1198 | } | |
1199 | ||
1200 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1201 | pSrcMpeg4Component = &pMpeg4Enc->mpeg4Component[pDstMpeg4Component->nPortIndex]; | |
1202 | ||
1203 | Exynos_OSAL_Memcpy(pDstMpeg4Component, pSrcMpeg4Component, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); | |
1204 | } | |
1205 | break; | |
1206 | case OMX_IndexParamVideoH263: | |
1207 | { | |
1208 | OMX_VIDEO_PARAM_H263TYPE *pDstH263Component = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; | |
1209 | OMX_VIDEO_PARAM_H263TYPE *pSrcH263Component = NULL; | |
1210 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
1211 | ||
1212 | ret = Exynos_OMX_Check_SizeVersion(pDstH263Component, sizeof(OMX_VIDEO_PARAM_H263TYPE)); | |
1213 | if (ret != OMX_ErrorNone) { | |
1214 | goto EXIT; | |
1215 | } | |
1216 | ||
1217 | if (pDstH263Component->nPortIndex >= ALL_PORT_NUM) { | |
1218 | ret = OMX_ErrorBadPortIndex; | |
1219 | goto EXIT; | |
1220 | } | |
1221 | ||
1222 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1223 | pSrcH263Component = &pMpeg4Enc->h263Component[pDstH263Component->nPortIndex]; | |
1224 | ||
1225 | Exynos_OSAL_Memcpy(pDstH263Component, pSrcH263Component, sizeof(OMX_VIDEO_PARAM_H263TYPE)); | |
1226 | } | |
1227 | break; | |
1228 | case OMX_IndexParamStandardComponentRole: | |
1229 | { | |
1230 | OMX_S32 codecType; | |
1231 | OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; | |
38ef2572 JC |
1232 | ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); |
1233 | if (ret != OMX_ErrorNone) { | |
1234 | goto EXIT; | |
1235 | } | |
1236 | ||
1237 | codecType = ((EXYNOS_MPEG4ENC_HANDLE *)(((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType; | |
1238 | if (codecType == CODEC_TYPE_MPEG4) | |
1239 | Exynos_OSAL_Strcpy((char *)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_MPEG4_ENC_ROLE); | |
1240 | else | |
1241 | Exynos_OSAL_Strcpy((char *)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_H263_ENC_ROLE); | |
1242 | } | |
1243 | break; | |
1244 | case OMX_IndexParamVideoProfileLevelQuerySupported: | |
1245 | { | |
1246 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; | |
1247 | EXYNOS_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; | |
1248 | OMX_U32 maxProfileLevelNum = 0; | |
1249 | OMX_S32 codecType; | |
1250 | ||
1251 | ret = Exynos_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
1252 | if (ret != OMX_ErrorNone) { | |
1253 | goto EXIT; | |
1254 | } | |
1255 | ||
1256 | if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1257 | ret = OMX_ErrorBadPortIndex; | |
1258 | goto EXIT; | |
1259 | } | |
1260 | ||
1261 | codecType = ((EXYNOS_MPEG4ENC_HANDLE *)(((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType; | |
1262 | if (codecType == CODEC_TYPE_MPEG4) { | |
1263 | pProfileLevel = supportedMPEG4ProfileLevels; | |
1264 | maxProfileLevelNum = sizeof(supportedMPEG4ProfileLevels) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL); | |
1265 | } else { | |
1266 | pProfileLevel = supportedH263ProfileLevels; | |
1267 | maxProfileLevelNum = sizeof(supportedH263ProfileLevels) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL); | |
1268 | } | |
1269 | ||
1270 | if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { | |
1271 | ret = OMX_ErrorNoMore; | |
1272 | goto EXIT; | |
1273 | } | |
1274 | ||
1275 | pProfileLevel += pDstProfileLevel->nProfileIndex; | |
1276 | pDstProfileLevel->eProfile = pProfileLevel->profile; | |
1277 | pDstProfileLevel->eLevel = pProfileLevel->level; | |
1278 | } | |
1279 | break; | |
1280 | case OMX_IndexParamVideoProfileLevelCurrent: | |
1281 | { | |
1282 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; | |
1283 | OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Component = NULL; | |
1284 | OMX_VIDEO_PARAM_H263TYPE *pSrcH263Component = NULL; | |
1285 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
1286 | OMX_S32 codecType; | |
1287 | ||
1288 | ret = Exynos_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
1289 | if (ret != OMX_ErrorNone) { | |
1290 | goto EXIT; | |
1291 | } | |
1292 | ||
1293 | if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1294 | ret = OMX_ErrorBadPortIndex; | |
1295 | goto EXIT; | |
1296 | } | |
1297 | ||
1298 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1299 | codecType = pMpeg4Enc->hMFCMpeg4Handle.codecType; | |
1300 | if (codecType == CODEC_TYPE_MPEG4) { | |
1301 | pSrcMpeg4Component = &pMpeg4Enc->mpeg4Component[pDstProfileLevel->nPortIndex]; | |
1302 | pDstProfileLevel->eProfile = pSrcMpeg4Component->eProfile; | |
1303 | pDstProfileLevel->eLevel = pSrcMpeg4Component->eLevel; | |
1304 | } else { | |
1305 | pSrcH263Component = &pMpeg4Enc->h263Component[pDstProfileLevel->nPortIndex]; | |
1306 | pDstProfileLevel->eProfile = pSrcH263Component->eProfile; | |
1307 | pDstProfileLevel->eLevel = pSrcH263Component->eLevel; | |
1308 | } | |
1309 | } | |
1310 | break; | |
1311 | case OMX_IndexParamVideoErrorCorrection: | |
1312 | { | |
1313 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; | |
1314 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; | |
1315 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
1316 | ||
1317 | ret = Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); | |
1318 | if (ret != OMX_ErrorNone) { | |
1319 | goto EXIT; | |
1320 | } | |
1321 | ||
1322 | if (pDstErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { | |
1323 | ret = OMX_ErrorBadPortIndex; | |
1324 | goto EXIT; | |
1325 | } | |
1326 | ||
1327 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1328 | pSrcErrorCorrectionType = &pMpeg4Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; | |
1329 | ||
1330 | pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; | |
1331 | pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; | |
1332 | pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; | |
1333 | pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; | |
1334 | pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; | |
1335 | } | |
1336 | break; | |
1337 | default: | |
1338 | ret = Exynos_OMX_VideoEncodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); | |
1339 | break; | |
1340 | } | |
1341 | EXIT: | |
1342 | FunctionOut(); | |
1343 | ||
1344 | return ret; | |
1345 | } | |
1346 | ||
1347 | OMX_ERRORTYPE Exynos_Mpeg4Enc_SetParameter( | |
1348 | OMX_IN OMX_HANDLETYPE hComponent, | |
1349 | OMX_IN OMX_INDEXTYPE nIndex, | |
1350 | OMX_IN OMX_PTR pComponentParameterStructure) | |
1351 | { | |
1352 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1353 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1354 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1355 | ||
1356 | FunctionIn(); | |
1357 | ||
1358 | if (hComponent == NULL || pComponentParameterStructure == NULL) { | |
1359 | ret = OMX_ErrorBadParameter; | |
1360 | goto EXIT; | |
1361 | } | |
1362 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1363 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1364 | if (ret != OMX_ErrorNone) { | |
1365 | goto EXIT; | |
1366 | } | |
1367 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1368 | ret = OMX_ErrorBadParameter; | |
1369 | goto EXIT; | |
1370 | } | |
1371 | ||
1372 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1373 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1374 | ret = OMX_ErrorInvalidState; | |
1375 | goto EXIT; | |
1376 | } | |
1377 | ||
1378 | switch (nIndex) { | |
1379 | case OMX_IndexParamVideoMpeg4: | |
1380 | { | |
1381 | OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Component = NULL; | |
1382 | OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Component = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; | |
1383 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
1384 | ||
1385 | ret = Exynos_OMX_Check_SizeVersion(pSrcMpeg4Component, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); | |
1386 | if (ret != OMX_ErrorNone) { | |
20d3e6e3 JC |
1387 | goto EXIT; |
1388 | } | |
1389 | ||
800a8d75 | 1390 | if (pSrcMpeg4Component->nPortIndex >= ALL_PORT_NUM) { |
20d3e6e3 JC |
1391 | ret = OMX_ErrorBadPortIndex; |
1392 | goto EXIT; | |
1393 | } | |
1394 | ||
1395 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
800a8d75 | 1396 | pDstMpeg4Component = &pMpeg4Enc->mpeg4Component[pSrcMpeg4Component->nPortIndex]; |
20d3e6e3 | 1397 | |
800a8d75 | 1398 | Exynos_OSAL_Memcpy(pDstMpeg4Component, pSrcMpeg4Component, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); |
20d3e6e3 JC |
1399 | } |
1400 | break; | |
1401 | case OMX_IndexParamVideoH263: | |
1402 | { | |
800a8d75 JC |
1403 | OMX_VIDEO_PARAM_H263TYPE *pDstH263Component = NULL; |
1404 | OMX_VIDEO_PARAM_H263TYPE *pSrcH263Component = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; | |
20d3e6e3 JC |
1405 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; |
1406 | ||
800a8d75 | 1407 | ret = Exynos_OMX_Check_SizeVersion(pSrcH263Component, sizeof(OMX_VIDEO_PARAM_H263TYPE)); |
20d3e6e3 JC |
1408 | if (ret != OMX_ErrorNone) { |
1409 | goto EXIT; | |
1410 | } | |
1411 | ||
800a8d75 | 1412 | if (pSrcH263Component->nPortIndex >= ALL_PORT_NUM) { |
20d3e6e3 JC |
1413 | ret = OMX_ErrorBadPortIndex; |
1414 | goto EXIT; | |
1415 | } | |
1416 | ||
1417 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
800a8d75 | 1418 | pDstH263Component = &pMpeg4Enc->h263Component[pSrcH263Component->nPortIndex]; |
20d3e6e3 | 1419 | |
800a8d75 | 1420 | Exynos_OSAL_Memcpy(pDstH263Component, pSrcH263Component, sizeof(OMX_VIDEO_PARAM_H263TYPE)); |
20d3e6e3 JC |
1421 | } |
1422 | break; | |
1423 | case OMX_IndexParamStandardComponentRole: | |
1424 | { | |
1425 | OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; | |
1426 | ||
1427 | ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); | |
1428 | if (ret != OMX_ErrorNone) { | |
1429 | goto EXIT; | |
1430 | } | |
1431 | ||
1432 | if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) { | |
1433 | ret = OMX_ErrorIncorrectStateOperation; | |
1434 | goto EXIT; | |
1435 | } | |
1436 | ||
1437 | if (!Exynos_OSAL_Strcmp((char*)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_MPEG4_ENC_ROLE)) { | |
1438 | pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; | |
1439 | //((EXYNOS_MPEG4ENC_HANDLE *)(((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_MPEG4; | |
1440 | } else if (!Exynos_OSAL_Strcmp((char*)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_H263_ENC_ROLE)) { | |
1441 | pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; | |
1442 | //((EXYNOS_MPEG4ENC_HANDLE *)(((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_H263; | |
1443 | } else { | |
1444 | ret = OMX_ErrorBadParameter; | |
1445 | goto EXIT; | |
1446 | } | |
1447 | } | |
1448 | break; | |
1449 | case OMX_IndexParamVideoProfileLevelCurrent: | |
1450 | { | |
1451 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; | |
800a8d75 JC |
1452 | OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Component = NULL; |
1453 | OMX_VIDEO_PARAM_H263TYPE *pDstH263Component = NULL; | |
20d3e6e3 JC |
1454 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; |
1455 | OMX_S32 codecType; | |
1456 | ||
1457 | ret = Exynos_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
3e79a27e | 1458 | if (ret != OMX_ErrorNone) |
20d3e6e3 | 1459 | goto EXIT; |
20d3e6e3 JC |
1460 | |
1461 | if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1462 | ret = OMX_ErrorBadPortIndex; | |
1463 | goto EXIT; | |
1464 | } | |
1465 | ||
1466 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1467 | codecType = pMpeg4Enc->hMFCMpeg4Handle.codecType; | |
1468 | if (codecType == CODEC_TYPE_MPEG4) { | |
1469 | /* | |
1470 | * To do: Check validity of profile & level parameters | |
1471 | */ | |
1472 | ||
800a8d75 JC |
1473 | pDstMpeg4Component = &pMpeg4Enc->mpeg4Component[pSrcProfileLevel->nPortIndex]; |
1474 | pDstMpeg4Component->eProfile = pSrcProfileLevel->eProfile; | |
1475 | pDstMpeg4Component->eLevel = pSrcProfileLevel->eLevel; | |
20d3e6e3 JC |
1476 | } else { |
1477 | /* | |
1478 | * To do: Check validity of profile & level parameters | |
1479 | */ | |
1480 | ||
800a8d75 JC |
1481 | pDstH263Component = &pMpeg4Enc->h263Component[pSrcProfileLevel->nPortIndex]; |
1482 | pDstH263Component->eProfile = pSrcProfileLevel->eProfile; | |
1483 | pDstH263Component->eLevel = pSrcProfileLevel->eLevel; | |
20d3e6e3 JC |
1484 | } |
1485 | } | |
1486 | break; | |
1487 | case OMX_IndexParamVideoErrorCorrection: | |
1488 | { | |
1489 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; | |
1490 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; | |
800a8d75 | 1491 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; |
20d3e6e3 JC |
1492 | |
1493 | ret = Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); | |
1494 | if (ret != OMX_ErrorNone) { | |
1495 | goto EXIT; | |
1496 | } | |
1497 | ||
1498 | if (pSrcErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { | |
1499 | ret = OMX_ErrorBadPortIndex; | |
1500 | goto EXIT; | |
1501 | } | |
1502 | ||
1503 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1504 | pDstErrorCorrectionType = &pMpeg4Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; | |
1505 | ||
1506 | pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; | |
1507 | pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; | |
1508 | pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; | |
1509 | pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; | |
1510 | pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; | |
1511 | } | |
1512 | break; | |
1513 | default: | |
1514 | ret = Exynos_OMX_VideoEncodeSetParameter(hComponent, nIndex, pComponentParameterStructure); | |
1515 | break; | |
1516 | } | |
1517 | EXIT: | |
1518 | FunctionOut(); | |
1519 | ||
1520 | return ret; | |
1521 | } | |
1522 | ||
800a8d75 | 1523 | OMX_ERRORTYPE Exynos_Mpeg4Enc_GetConfig( |
20d3e6e3 JC |
1524 | OMX_IN OMX_HANDLETYPE hComponent, |
1525 | OMX_IN OMX_INDEXTYPE nIndex, | |
1526 | OMX_IN OMX_PTR pComponentConfigStructure) | |
1527 | { | |
800a8d75 JC |
1528 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1529 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
20d3e6e3 JC |
1530 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; |
1531 | ||
1532 | FunctionIn(); | |
1533 | ||
1534 | if (hComponent == NULL || pComponentConfigStructure == NULL) { | |
1535 | ret = OMX_ErrorBadParameter; | |
1536 | goto EXIT; | |
1537 | } | |
1538 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1539 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1540 | if (ret != OMX_ErrorNone) { | |
1541 | goto EXIT; | |
1542 | } | |
1543 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1544 | ret = OMX_ErrorBadParameter; | |
1545 | goto EXIT; | |
1546 | } | |
20d3e6e3 JC |
1547 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; |
1548 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1549 | ret = OMX_ErrorInvalidState; | |
1550 | goto EXIT; | |
1551 | } | |
1552 | ||
1553 | switch (nIndex) { | |
1554 | default: | |
1555 | ret = Exynos_OMX_VideoEncodeGetConfig(hComponent, nIndex, pComponentConfigStructure); | |
1556 | break; | |
1557 | } | |
1558 | ||
1559 | EXIT: | |
1560 | FunctionOut(); | |
1561 | ||
1562 | return ret; | |
1563 | } | |
1564 | ||
800a8d75 | 1565 | OMX_ERRORTYPE Exynos_Mpeg4Enc_SetConfig( |
20d3e6e3 JC |
1566 | OMX_IN OMX_HANDLETYPE hComponent, |
1567 | OMX_IN OMX_INDEXTYPE nIndex, | |
1568 | OMX_IN OMX_PTR pComponentConfigStructure) | |
1569 | { | |
800a8d75 JC |
1570 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1571 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
20d3e6e3 | 1572 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; |
800a8d75 JC |
1573 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; |
1574 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
20d3e6e3 JC |
1575 | |
1576 | FunctionIn(); | |
1577 | ||
1578 | if (hComponent == NULL || pComponentConfigStructure == NULL) { | |
1579 | ret = OMX_ErrorBadParameter; | |
1580 | goto EXIT; | |
1581 | } | |
1582 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1583 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1584 | if (ret != OMX_ErrorNone) { | |
1585 | goto EXIT; | |
1586 | } | |
1587 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1588 | ret = OMX_ErrorBadParameter; | |
1589 | goto EXIT; | |
1590 | } | |
20d3e6e3 JC |
1591 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; |
1592 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1593 | ret = OMX_ErrorInvalidState; | |
1594 | goto EXIT; | |
1595 | } | |
1596 | ||
800a8d75 JC |
1597 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; |
1598 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)pVideoEnc->hCodecHandle; | |
20d3e6e3 JC |
1599 | |
1600 | switch (nIndex) { | |
1601 | case OMX_IndexConfigVideoIntraPeriod: | |
1602 | { | |
20d3e6e3 JC |
1603 | OMX_U32 nPFrames = (*((OMX_U32 *)pComponentConfigStructure)) - 1; |
1604 | ||
1605 | if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) | |
1606 | pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames = nPFrames; | |
1607 | else | |
1608 | pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames = nPFrames; | |
1609 | ||
1610 | ret = OMX_ErrorNone; | |
1611 | } | |
1612 | break; | |
1613 | default: | |
1614 | ret = Exynos_OMX_VideoEncodeSetConfig(hComponent, nIndex, pComponentConfigStructure); | |
1615 | break; | |
1616 | } | |
1617 | ||
1618 | EXIT: | |
1619 | if (ret == OMX_ErrorNone) | |
1620 | pVideoEnc->configChange = OMX_TRUE; | |
1621 | ||
1622 | FunctionOut(); | |
1623 | ||
1624 | return ret; | |
1625 | } | |
1626 | ||
800a8d75 JC |
1627 | OMX_ERRORTYPE Exynos_Mpeg4Enc_GetExtensionIndex( |
1628 | OMX_IN OMX_HANDLETYPE hComponent, | |
1629 | OMX_IN OMX_STRING cParameterName, | |
1630 | OMX_OUT OMX_INDEXTYPE *pIndexType) | |
20d3e6e3 | 1631 | { |
800a8d75 JC |
1632 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1633 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
20d3e6e3 JC |
1634 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; |
1635 | ||
1636 | FunctionIn(); | |
1637 | ||
1638 | if (hComponent == NULL) { | |
1639 | ret = OMX_ErrorBadParameter; | |
1640 | goto EXIT; | |
1641 | } | |
1642 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1643 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1644 | if (ret != OMX_ErrorNone) { | |
1645 | goto EXIT; | |
1646 | } | |
20d3e6e3 JC |
1647 | if (pOMXComponent->pComponentPrivate == NULL) { |
1648 | ret = OMX_ErrorBadParameter; | |
1649 | goto EXIT; | |
1650 | } | |
1651 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
20d3e6e3 JC |
1652 | if ((cParameterName == NULL) || (pIndexType == NULL)) { |
1653 | ret = OMX_ErrorBadParameter; | |
1654 | goto EXIT; | |
1655 | } | |
1656 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1657 | ret = OMX_ErrorInvalidState; | |
1658 | goto EXIT; | |
1659 | } | |
1660 | if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_CONFIG_VIDEO_INTRAPERIOD) == 0) { | |
1661 | *pIndexType = OMX_IndexConfigVideoIntraPeriod; | |
1662 | ret = OMX_ErrorNone; | |
1663 | } else { | |
1664 | ret = Exynos_OMX_VideoEncodeGetExtensionIndex(hComponent, cParameterName, pIndexType); | |
1665 | } | |
800a8d75 | 1666 | |
20d3e6e3 JC |
1667 | EXIT: |
1668 | FunctionOut(); | |
1669 | ||
1670 | return ret; | |
1671 | } | |
1672 | ||
800a8d75 | 1673 | OMX_ERRORTYPE Exynos_Mpeg4Enc_ComponentRoleEnum( |
20d3e6e3 JC |
1674 | OMX_IN OMX_HANDLETYPE hComponent, |
1675 | OMX_OUT OMX_U8 *cRole, | |
1676 | OMX_IN OMX_U32 nIndex) | |
1677 | { | |
800a8d75 JC |
1678 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1679 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
20d3e6e3 JC |
1680 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; |
1681 | OMX_S32 codecType; | |
1682 | ||
1683 | FunctionIn(); | |
1684 | ||
1685 | if ((hComponent == NULL) || (cRole == NULL)) { | |
1686 | ret = OMX_ErrorBadParameter; | |
1687 | goto EXIT; | |
1688 | } | |
800a8d75 | 1689 | if (nIndex != (MAX_COMPONENT_ROLE_NUM - 1)) { /* supports only one role */ |
20d3e6e3 JC |
1690 | ret = OMX_ErrorNoMore; |
1691 | goto EXIT; | |
1692 | } | |
1693 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1694 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1695 | if (ret != OMX_ErrorNone) { | |
1696 | goto EXIT; | |
1697 | } | |
1698 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1699 | ret = OMX_ErrorBadParameter; | |
1700 | goto EXIT; | |
1701 | } | |
1702 | ||
1703 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1704 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1705 | ret = OMX_ErrorInvalidState; | |
1706 | goto EXIT; | |
1707 | } | |
1708 | ||
1709 | codecType = ((EXYNOS_MPEG4ENC_HANDLE *)(((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType; | |
1710 | if (codecType == CODEC_TYPE_MPEG4) | |
1711 | Exynos_OSAL_Strcpy((char *)cRole, EXYNOS_OMX_COMPONENT_MPEG4_ENC_ROLE); | |
1712 | else | |
1713 | Exynos_OSAL_Strcpy((char *)cRole, EXYNOS_OMX_COMPONENT_H263_ENC_ROLE); | |
1714 | ||
1715 | EXIT: | |
1716 | FunctionOut(); | |
1717 | ||
1718 | return ret; | |
1719 | } | |
1720 | ||
38ef2572 JC |
1721 | /* MFC Init */ |
1722 | OMX_ERRORTYPE Exynos_Mpeg4Enc_Init(OMX_COMPONENTTYPE *pOMXComponent) | |
20d3e6e3 | 1723 | { |
38ef2572 | 1724 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
20d3e6e3 | 1725 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; |
38ef2572 JC |
1726 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; |
1727 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1728 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1729 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;; | |
1730 | EXYNOS_MFC_MPEG4ENC_HANDLE *pMFCMpeg4Handle = &pMpeg4Enc->hMFCMpeg4Handle; | |
1731 | OMX_PTR hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; | |
1732 | OMX_COLOR_FORMATTYPE eColorFormat; | |
1733 | ||
1734 | ExynosVideoEncOps *pEncOps = NULL; | |
1735 | ExynosVideoEncBufferOps *pInbufOps = NULL; | |
1736 | ExynosVideoEncBufferOps *pOutbufOps = NULL; | |
20d3e6e3 | 1737 | |
38ef2572 | 1738 | CSC_METHOD csc_method = CSC_METHOD_SW; |
38ef2572 | 1739 | int i = 0; |
20d3e6e3 | 1740 | |
38ef2572 | 1741 | FunctionIn(); |
800a8d75 | 1742 | |
38ef2572 JC |
1743 | pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFCSrc = OMX_FALSE; |
1744 | pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFCDst = OMX_FALSE; | |
38ef2572 JC |
1745 | pExynosComponent->bUseFlagEOF = OMX_TRUE; |
1746 | pExynosComponent->bSaveFlagEOS = OMX_FALSE; | |
800a8d75 | 1747 | |
38ef2572 | 1748 | eColorFormat = pExynosInputPort->portDefinition.format.video.eColorFormat; |
38ef2572 JC |
1749 | if (pExynosInputPort->bStoreMetaData == OMX_TRUE) { |
1750 | if (eColorFormat == OMX_COLOR_FormatAndroidOpaque) { | |
1751 | pExynosInputPort->bufferProcessType = BUFFER_COPY; | |
3e79a27e | 1752 | } else { |
38ef2572 | 1753 | pExynosInputPort->bufferProcessType = BUFFER_SHARE; |
20d3e6e3 | 1754 | } |
833233fa SK |
1755 | } else { |
1756 | pExynosInputPort->bufferProcessType = BUFFER_COPY; | |
20d3e6e3 JC |
1757 | } |
1758 | ||
38ef2572 JC |
1759 | /* Mpeg4/H.263 Codec Open */ |
1760 | ret = Mpeg4CodecOpen(pMpeg4Enc); | |
1761 | if (ret != OMX_ErrorNone) { | |
1762 | goto EXIT; | |
1763 | } | |
20d3e6e3 | 1764 | |
38ef2572 JC |
1765 | pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; |
1766 | pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps; | |
1767 | pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
800a8d75 | 1768 | |
33d6044e SK |
1769 | if ((pExynosInputPort->bStoreMetaData != OMX_TRUE) && |
1770 | (eColorFormat != OMX_COLOR_FormatAndroidOpaque)) { | |
1771 | if ((pExynosInputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { | |
1772 | Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID); | |
1773 | Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); | |
1774 | ||
1775 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { | |
1776 | pVideoEnc->pMFCEncInputBuffer[i] = Exynos_OSAL_Malloc(sizeof(CODEC_ENC_BUFFER)); | |
1777 | /* Use ION Allocator */ | |
1778 | /*Alloc Y-Buffer */ | |
1779 | pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoEnc->hSharedMemory, DEFAULT_MFC_INPUT_YBUFFER_SIZE, NORMAL_MEMORY); | |
1780 | pVideoEnc->pMFCEncInputBuffer[i]->fd[0] = Exynos_OSAL_SharedMemory_VirtToION(pVideoEnc->hSharedMemory, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); | |
1781 | pVideoEnc->pMFCEncInputBuffer[i]->bufferSize[0] = DEFAULT_MFC_INPUT_YBUFFER_SIZE; | |
1782 | /*Alloc C-Buffer */ | |
1783 | pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoEnc->hSharedMemory, DEFAULT_MFC_INPUT_CBUFFER_SIZE, NORMAL_MEMORY); | |
1784 | pVideoEnc->pMFCEncInputBuffer[i]->fd[1] = Exynos_OSAL_SharedMemory_VirtToION(pVideoEnc->hSharedMemory, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); | |
1785 | pVideoEnc->pMFCEncInputBuffer[i]->bufferSize[1] = DEFAULT_MFC_INPUT_CBUFFER_SIZE; | |
1786 | ||
1787 | pVideoEnc->pMFCEncInputBuffer[i]->dataSize = 0; | |
1788 | ||
1789 | if ((pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0] == NULL) || | |
1790 | (pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1] == NULL)) { | |
1791 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Fail input buffer"); | |
1792 | ret = OMX_ErrorInsufficientResources; | |
1793 | goto EXIT; | |
1794 | } | |
1795 | ||
1796 | /* MFC input buffers are 1 plane. */ | |
1797 | pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[2] = NULL; | |
1798 | pVideoEnc->pMFCEncInputBuffer[i]->fd[2] = -1; | |
1799 | pVideoEnc->pMFCEncInputBuffer[i]->bufferSize[2] = 0; | |
1800 | ||
1801 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "pVideoEnc->pMFCEncInputBuffer[%d]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]); | |
1802 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); | |
1803 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); | |
1804 | ||
1805 | Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); | |
38ef2572 | 1806 | } |
33d6044e SK |
1807 | } else if (pExynosInputPort->bufferProcessType == BUFFER_SHARE) { |
1808 | /*************/ | |
1809 | /* TBD */ | |
1810 | /*************/ | |
1811 | /* Does not require any actions. */ | |
38ef2572 | 1812 | } |
38ef2572 | 1813 | } |
800a8d75 | 1814 | |
38ef2572 | 1815 | if ((pExynosOutputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { |
833233fa SK |
1816 | Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort->codecSemID); |
1817 | Exynos_OSAL_QueueCreate(&pExynosOutputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); | |
38ef2572 | 1818 | } else if (pExynosOutputPort->bufferProcessType == BUFFER_SHARE) { |
38ef2572 JC |
1819 | /*************/ |
1820 | /* TBD */ | |
1821 | /*************/ | |
833233fa | 1822 | /* Does not require any actions. */ |
800a8d75 | 1823 | } |
20d3e6e3 | 1824 | |
38ef2572 JC |
1825 | pMpeg4Enc->bSourceStart = OMX_FALSE; |
1826 | Exynos_OSAL_SignalCreate(&pMpeg4Enc->hSourceStartEvent); | |
38ef2572 JC |
1827 | pMpeg4Enc->bDestinationStart = OMX_FALSE; |
1828 | Exynos_OSAL_SignalCreate(&pMpeg4Enc->hDestinationStartEvent); | |
800a8d75 | 1829 | |
20d3e6e3 JC |
1830 | Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); |
1831 | Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); | |
1832 | pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp = 0; | |
38ef2572 | 1833 | pMpeg4Enc->hMFCMpeg4Handle.outputIndexTimestamp = 0; |
20d3e6e3 | 1834 | |
38ef2572 JC |
1835 | pExynosComponent->getAllDelayBuffer = OMX_FALSE; |
1836 | ||
1837 | #if 0//defined(USE_CSC_GSCALER) | |
3e79a27e | 1838 | csc_method = CSC_METHOD_HW; //in case of Use ION buffer. |
38ef2572 | 1839 | #endif |
800a8d75 | 1840 | pVideoEnc->csc_handle = csc_init(csc_method); |
38ef2572 JC |
1841 | if (pVideoEnc->csc_handle == NULL) { |
1842 | ret = OMX_ErrorInsufficientResources; | |
1843 | goto EXIT; | |
1844 | } | |
1845 | pVideoEnc->csc_set_format = OMX_FALSE; | |
800a8d75 | 1846 | |
20d3e6e3 JC |
1847 | EXIT: |
1848 | FunctionOut(); | |
1849 | ||
1850 | return ret; | |
1851 | } | |
1852 | ||
1853 | /* MFC Terminate */ | |
800a8d75 | 1854 | OMX_ERRORTYPE Exynos_Mpeg4Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent) |
20d3e6e3 | 1855 | { |
800a8d75 | 1856 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
20d3e6e3 | 1857 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; |
38ef2572 JC |
1858 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle); |
1859 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1860 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1861 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1862 | OMX_PTR hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; | |
1863 | ||
1864 | ExynosVideoEncOps *pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; | |
1865 | ExynosVideoEncBufferOps *pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps; | |
1866 | ExynosVideoEncBufferOps *pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
1867 | ||
91f44a5d | 1868 | int i = 0, plane = 0; |
20d3e6e3 JC |
1869 | |
1870 | FunctionIn(); | |
1871 | ||
38ef2572 JC |
1872 | if (pVideoEnc->csc_handle != NULL) { |
1873 | csc_deinit(pVideoEnc->csc_handle); | |
1874 | pVideoEnc->csc_handle = NULL; | |
20d3e6e3 JC |
1875 | } |
1876 | ||
38ef2572 JC |
1877 | Exynos_OSAL_SignalTerminate(pMpeg4Enc->hDestinationStartEvent); |
1878 | pMpeg4Enc->hDestinationStartEvent = NULL; | |
1879 | pMpeg4Enc->bDestinationStart = OMX_FALSE; | |
1880 | Exynos_OSAL_SignalTerminate(pMpeg4Enc->hSourceStartEvent); | |
1881 | pMpeg4Enc->hSourceStartEvent = NULL; | |
1882 | pMpeg4Enc->bSourceStart = OMX_FALSE; | |
1883 | ||
833233fa SK |
1884 | if ((pExynosOutputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { |
1885 | for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { | |
1886 | if (pVideoEnc->pMFCEncOutputBuffer[i] != NULL) { | |
91f44a5d SK |
1887 | if (pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr[0] != NULL) |
1888 | Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr[0]); | |
833233fa SK |
1889 | Exynos_OSAL_Free(pVideoEnc->pMFCEncOutputBuffer[i]); |
1890 | pVideoEnc->pMFCEncOutputBuffer[i] = NULL; | |
1891 | } | |
1892 | } | |
1893 | ||
1894 | Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ); | |
1895 | Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID); | |
1896 | } else if (pExynosOutputPort->bufferProcessType == BUFFER_SHARE) { | |
1897 | /*************/ | |
1898 | /* TBD */ | |
1899 | /*************/ | |
1900 | /* Does not require any actions. */ | |
1901 | } | |
1902 | ||
38ef2572 JC |
1903 | if ((pExynosInputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { |
1904 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { | |
1905 | if (pVideoEnc->pMFCEncInputBuffer[i] != NULL) { | |
91f44a5d SK |
1906 | for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) { |
1907 | if (pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[plane] != NULL) | |
1908 | Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[plane]); | |
1909 | } | |
38ef2572 JC |
1910 | Exynos_OSAL_Free(pVideoEnc->pMFCEncInputBuffer[i]); |
1911 | pVideoEnc->pMFCEncInputBuffer[i] = NULL; | |
1912 | } | |
1913 | } | |
1914 | ||
1915 | Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ); | |
1916 | Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID); | |
1917 | } else if (pExynosInputPort->bufferProcessType == BUFFER_SHARE) { | |
38ef2572 JC |
1918 | /*************/ |
1919 | /* TBD */ | |
1920 | /*************/ | |
1921 | /* Does not require any actions. */ | |
20d3e6e3 | 1922 | } |
38ef2572 | 1923 | Mpeg4CodecClose(pMpeg4Enc); |
20d3e6e3 JC |
1924 | |
1925 | EXIT: | |
1926 | FunctionOut(); | |
1927 | ||
1928 | return ret; | |
1929 | } | |
1930 | ||
38ef2572 | 1931 | OMX_ERRORTYPE Exynos_Mpeg4Enc_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) |
20d3e6e3 | 1932 | { |
38ef2572 JC |
1933 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1934 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1935 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1936 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1937 | void *hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; | |
1938 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1939 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1940 | OMX_U32 oneFrameSize = pSrcInputData->dataLen; | |
38ef2572 JC |
1941 | ExynosVideoEncOps *pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; |
1942 | ExynosVideoEncBufferOps *pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps; | |
1943 | ExynosVideoEncBufferOps *pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
1944 | ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; | |
800a8d75 JC |
1945 | int i; |
1946 | ||
38ef2572 | 1947 | FunctionIn(); |
800a8d75 | 1948 | |
38ef2572 JC |
1949 | if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFCSrc == OMX_FALSE) { |
1950 | ret = Mpeg4CodecSrcSetup(pOMXComponent, pSrcInputData); | |
833233fa SK |
1951 | if ((pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) |
1952 | goto EXIT; | |
1953 | } | |
1954 | if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFCDst == OMX_FALSE) { | |
1955 | ret = Mpeg4CodecDstSetup(pOMXComponent); | |
800a8d75 JC |
1956 | } |
1957 | ||
38ef2572 JC |
1958 | if ((pSrcInputData->dataLen >= 0) || |
1959 | ((pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { | |
833233fa | 1960 | OMX_U32 pMFCYUVDataSize[MFC_INPUT_BUFFER_PLANE] = {NULL, NULL}; |
91f44a5d SK |
1961 | ExynosVideoPlane planes[MFC_INPUT_BUFFER_PLANE]; |
1962 | int plane; | |
38ef2572 JC |
1963 | |
1964 | pExynosComponent->timeStamp[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pSrcInputData->timeStamp; | |
1965 | pExynosComponent->nFlags[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pSrcInputData->nFlags; | |
1966 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "input timestamp %lld us (%.2f secs), Tag: %d, nFlags: 0x%x", pSrcInputData->timeStamp, pSrcInputData->timeStamp / 1E6, pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp, pSrcInputData->nFlags); | |
1967 | pEncOps->Set_FrameTag(hMFCHandle, pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp); | |
1968 | pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp++; | |
1969 | pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp %= MAX_TIMESTAMP; | |
1970 | ||
1971 | /* queue work for input buffer */ | |
b8d6caa5 | 1972 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Exynos_Mpeg4Enc_SrcIn(): oneFrameSize: %d, bufferHeader: 0x%x", oneFrameSize, pSrcInputData->bufferHeader); |
91f44a5d SK |
1973 | pMFCYUVDataSize[0] = pExynosInputPort->portDefinition.format.video.nFrameWidth * pExynosInputPort->portDefinition.format.video.nFrameHeight; |
1974 | pMFCYUVDataSize[1] = pMFCYUVDataSize[0] / 2; | |
833233fa | 1975 | |
91f44a5d SK |
1976 | codecReturn = pInbufOps->Enqueue(hMFCHandle, (unsigned char **)pSrcInputData->buffer.multiPlaneBuffer.dataBuffer, |
1977 | (unsigned int *)pMFCYUVDataSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader); | |
1978 | #ifdef USE_METADATABUFFERTYPE | |
1979 | if ((codecReturn == VIDEO_ERROR_NOBUFFERS) && | |
1980 | (pExynosInputPort->bStoreMetaData == OMX_TRUE) && | |
1981 | (pExynosInputPort->bufferProcessType == BUFFER_SHARE)) { | |
1982 | OMX_U32 nAllocLen[MFC_INPUT_BUFFER_PLANE] = {0, 0}; | |
1983 | nAllocLen[0] = ALIGN_TO_16B(pExynosInputPort->portDefinition.format.video.nFrameWidth) * | |
1984 | ALIGN_TO_16B(pExynosInputPort->portDefinition.format.video.nFrameHeight); | |
1985 | nAllocLen[1] = ALIGN(nAllocLen[0]/2,256); | |
1986 | for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) { | |
1987 | planes[plane].addr = pSrcInputData->buffer.multiPlaneBuffer.dataBuffer[plane]; | |
1988 | planes[plane].allocSize = nAllocLen[plane]; | |
1989 | planes[plane].fd = pSrcInputData->buffer.multiPlaneBuffer.fd[plane]; | |
1990 | } | |
833233fa | 1991 | |
91f44a5d | 1992 | /* Register input buffer */ |
2f26183e SK |
1993 | if (pInbufOps->Register(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, |
1994 | planes, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
1995 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer"); | |
1996 | ret = OMX_ErrorInsufficientResources; | |
1997 | goto EXIT; | |
91f44a5d SK |
1998 | } |
1999 | codecReturn = pInbufOps->Enqueue(hMFCHandle, (unsigned char **)pSrcInputData->buffer.multiPlaneBuffer.dataBuffer, | |
2000 | (unsigned int *)pMFCYUVDataSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader); | |
800a8d75 | 2001 | |
91f44a5d SK |
2002 | } |
2003 | #endif | |
38ef2572 JC |
2004 | if (codecReturn != VIDEO_ERROR_NONE) { |
2005 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - pInbufOps->Enqueue", __FUNCTION__, __LINE__); | |
2006 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecEncode; | |
2007 | goto EXIT; | |
2008 | } | |
833233fa SK |
2009 | Mpeg4CodecStart(pOMXComponent, INPUT_PORT_INDEX); |
2010 | if (pMpeg4Enc->bSourceStart == OMX_FALSE) { | |
2011 | pMpeg4Enc->bSourceStart = OMX_TRUE; | |
2012 | Exynos_OSAL_SignalSet(pMpeg4Enc->hSourceStartEvent); | |
2013 | Exynos_OSAL_SleepMillisec(0); | |
2014 | } | |
2015 | if (pMpeg4Enc->bDestinationStart == OMX_FALSE) { | |
2016 | pMpeg4Enc->bDestinationStart = OMX_TRUE; | |
2017 | Exynos_OSAL_SignalSet(pMpeg4Enc->hDestinationStartEvent); | |
2018 | Exynos_OSAL_SleepMillisec(0); | |
2019 | } | |
800a8d75 JC |
2020 | } |
2021 | ||
800a8d75 JC |
2022 | ret = OMX_ErrorNone; |
2023 | ||
800a8d75 | 2024 | EXIT: |
38ef2572 JC |
2025 | FunctionOut(); |
2026 | ||
800a8d75 JC |
2027 | return ret; |
2028 | } | |
2029 | ||
38ef2572 | 2030 | OMX_ERRORTYPE Exynos_Mpeg4Enc_SrcOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData) |
800a8d75 | 2031 | { |
38ef2572 JC |
2032 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
2033 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2034 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2035 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2036 | void *hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; | |
2037 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2038 | ExynosVideoEncOps *pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; | |
2039 | ExynosVideoEncBufferOps *pInbufOps = pMpeg4Enc->hMFCMpeg4Handle.pInbufOps; | |
2040 | ExynosVideoBuffer *pVideoBuffer; | |
20d3e6e3 JC |
2041 | |
2042 | FunctionIn(); | |
2043 | ||
38ef2572 JC |
2044 | pVideoBuffer = pInbufOps->Dequeue(hMFCHandle); |
2045 | ||
2046 | pSrcOutputData->dataLen = 0; | |
2047 | pSrcOutputData->usedDataLen = 0; | |
2048 | pSrcOutputData->remainDataLen = 0; | |
2049 | pSrcOutputData->nFlags = 0; | |
2050 | pSrcOutputData->timeStamp = 0; | |
2051 | ||
2052 | if (pVideoBuffer == NULL) { | |
2053 | pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = NULL; | |
2054 | pSrcOutputData->allocSize = 0; | |
2055 | pSrcOutputData->pPrivate = NULL; | |
2056 | pSrcOutputData->bufferHeader = NULL; | |
2057 | } else { | |
91f44a5d SK |
2058 | int plane = 0; |
2059 | for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) { | |
2060 | pSrcOutputData->buffer.multiPlaneBuffer.dataBuffer[plane] = pVideoBuffer->planes[plane].addr; | |
2061 | pSrcOutputData->buffer.multiPlaneBuffer.fd[plane] = pVideoBuffer->planes[plane].fd; | |
2062 | } | |
833233fa | 2063 | pSrcOutputData->allocSize = pVideoBuffer->planes[0].allocSize + |
38ef2572 JC |
2064 | pVideoBuffer->planes[1].allocSize + |
2065 | pVideoBuffer->planes[2].allocSize; | |
2066 | ||
2067 | if ((pExynosInputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { | |
2068 | int i = 0; | |
91f44a5d | 2069 | while (pSrcOutputData->buffer.multiPlaneBuffer.dataBuffer[0] != pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]) { |
38ef2572 JC |
2070 | if (i >= MFC_INPUT_BUFFER_NUM_MAX) { |
2071 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - Lost buffer", __FUNCTION__, __LINE__); | |
2072 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecEncode; | |
2073 | goto EXIT; | |
2074 | } | |
2075 | i++; | |
2076 | } | |
91f44a5d | 2077 | pVideoEnc->pMFCEncInputBuffer[i]->dataSize = 0; |
38ef2572 | 2078 | pSrcOutputData->pPrivate = pVideoEnc->pMFCEncInputBuffer[i]; |
20d3e6e3 JC |
2079 | } |
2080 | ||
38ef2572 JC |
2081 | /* For Share Buffer */ |
2082 | pSrcOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE*)pVideoBuffer->pPrivate; | |
2083 | } | |
2084 | ||
2085 | ret = OMX_ErrorNone; | |
2086 | ||
2087 | EXIT: | |
2088 | FunctionOut(); | |
2089 | ||
2090 | return ret; | |
2091 | } | |
2092 | ||
2093 | OMX_ERRORTYPE Exynos_Mpeg4Enc_DstIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData) | |
2094 | { | |
2095 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2096 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2097 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2098 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2099 | void *hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; | |
2100 | ExynosVideoEncOps *pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; | |
2101 | ExynosVideoEncBufferOps *pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
2102 | OMX_U32 dataLen = 0; | |
2103 | ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; | |
2104 | ||
2105 | FunctionIn(); | |
2106 | ||
2107 | if (pDstInputData->buffer.singlePlaneBuffer.dataBuffer == NULL) { | |
2108 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to find input buffer"); | |
2109 | ret = OMX_ErrorBadParameter; | |
2110 | goto EXIT; | |
2111 | } | |
20d3e6e3 | 2112 | |
91f44a5d | 2113 | codecReturn = pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)&pDstInputData->buffer.singlePlaneBuffer.dataBuffer, |
833233fa | 2114 | (unsigned int *)&dataLen, MFC_OUTPUT_BUFFER_PLANE, pDstInputData->bufferHeader); |
20d3e6e3 | 2115 | |
38ef2572 JC |
2116 | if (codecReturn != VIDEO_ERROR_NONE) { |
2117 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - pOutbufOps->Enqueue", __FUNCTION__, __LINE__); | |
2118 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecEncode; | |
20d3e6e3 JC |
2119 | goto EXIT; |
2120 | } | |
833233fa | 2121 | Mpeg4CodecStart(pOMXComponent, OUTPUT_PORT_INDEX); |
20d3e6e3 | 2122 | |
38ef2572 JC |
2123 | ret = OMX_ErrorNone; |
2124 | ||
2125 | EXIT: | |
2126 | FunctionOut(); | |
2127 | ||
2128 | return ret; | |
2129 | } | |
2130 | ||
2131 | OMX_ERRORTYPE Exynos_Mpeg4Enc_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData) | |
2132 | { | |
2133 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2134 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2135 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2136 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2137 | void *hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; | |
2138 | ExynosVideoEncOps *pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; | |
2139 | ExynosVideoEncBufferOps *pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; | |
2140 | ExynosVideoBuffer *pVideoBuffer; | |
2141 | ExynosVideoFrameStatusType displayStatus = VIDEO_FRAME_STATUS_UNKNOWN; | |
2142 | ExynosVideoGeometry bufferGeometry; | |
2143 | OMX_S32 indexTimestamp = 0; | |
20d3e6e3 | 2144 | |
38ef2572 | 2145 | FunctionIn(); |
20d3e6e3 | 2146 | |
38ef2572 | 2147 | if (pMpeg4Enc->bDestinationStart == OMX_FALSE) { |
20d3e6e3 JC |
2148 | ret = OMX_ErrorNone; |
2149 | goto EXIT; | |
2150 | } | |
2151 | ||
38ef2572 JC |
2152 | if ((pVideoBuffer = pOutbufOps->Dequeue(hMFCHandle)) == NULL) { |
2153 | ret = OMX_ErrorNone; | |
2154 | goto EXIT; | |
2155 | } | |
800a8d75 | 2156 | |
38ef2572 JC |
2157 | pMpeg4Enc->hMFCMpeg4Handle.outputIndexTimestamp++; |
2158 | pMpeg4Enc->hMFCMpeg4Handle.outputIndexTimestamp %= MAX_TIMESTAMP; | |
20d3e6e3 | 2159 | |
38ef2572 | 2160 | pDstOutputData->buffer.singlePlaneBuffer.dataBuffer = pVideoBuffer->planes[0].addr; |
91f44a5d | 2161 | pDstOutputData->buffer.singlePlaneBuffer.fd = pVideoBuffer->planes[0].fd; |
38ef2572 JC |
2162 | pDstOutputData->allocSize = pVideoBuffer->planes[0].allocSize; |
2163 | pDstOutputData->dataLen = pVideoBuffer->planes[0].dataSize; | |
2164 | pDstOutputData->remainDataLen = pVideoBuffer->planes[0].dataSize; | |
2165 | pDstOutputData->usedDataLen = 0; | |
2166 | pDstOutputData->pPrivate = pVideoBuffer; | |
2167 | /* For Share Buffer */ | |
2168 | pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate; | |
2169 | ||
2170 | if (pVideoEnc->bFirstOutput == OMX_FALSE) { | |
2171 | OMX_U8 *p = NULL; | |
2172 | ||
2173 | pDstOutputData->timeStamp = 0; | |
2174 | pDstOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG; | |
2175 | pDstOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; | |
833233fa | 2176 | pVideoEnc->bFirstOutput = OMX_TRUE; |
38ef2572 JC |
2177 | } else { |
2178 | indexTimestamp = pEncOps->Get_FrameTag(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle); | |
2179 | if ((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)) { | |
2180 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[pMpeg4Enc->hMFCMpeg4Handle.outputIndexTimestamp]; | |
2181 | pDstOutputData->nFlags = pExynosComponent->nFlags[pMpeg4Enc->hMFCMpeg4Handle.outputIndexTimestamp]; | |
2182 | } else { | |
2183 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp]; | |
2184 | pDstOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp]; | |
20d3e6e3 | 2185 | } |
38ef2572 JC |
2186 | |
2187 | pDstOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; | |
2188 | if (pVideoBuffer->frameType == VIDEO_FRAME_I) | |
2189 | pDstOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; | |
20d3e6e3 JC |
2190 | } |
2191 | ||
38ef2572 JC |
2192 | if ((displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) || |
2193 | ((pDstOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { | |
91f44a5d | 2194 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%x displayStatus:%d, nFlags0x%x", pExynosComponent, displayStatus, pDstOutputData->nFlags); |
38ef2572 JC |
2195 | pDstOutputData->remainDataLen = 0; |
2196 | } | |
800a8d75 | 2197 | |
38ef2572 | 2198 | ret = OMX_ErrorNone; |
20d3e6e3 | 2199 | |
38ef2572 JC |
2200 | EXIT: |
2201 | FunctionOut(); | |
20d3e6e3 | 2202 | |
38ef2572 JC |
2203 | return ret; |
2204 | } | |
20d3e6e3 | 2205 | |
38ef2572 JC |
2206 | OMX_ERRORTYPE Exynos_Mpeg4Enc_srcInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) |
2207 | { | |
2208 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2209 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2210 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2211 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
800a8d75 | 2212 | |
38ef2572 | 2213 | FunctionIn(); |
20d3e6e3 | 2214 | |
38ef2572 JC |
2215 | if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) { |
2216 | ret = OMX_ErrorNone; | |
2217 | goto EXIT; | |
2218 | } | |
2219 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) { | |
2220 | ret = OMX_ErrorNone; | |
2221 | goto EXIT; | |
2222 | } | |
20d3e6e3 | 2223 | |
38ef2572 JC |
2224 | ret = Exynos_Mpeg4Enc_SrcIn(pOMXComponent, pSrcInputData); |
2225 | if (ret != OMX_ErrorNone) { | |
2226 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - SrcIn -> event is thrown to client", __FUNCTION__, __LINE__); | |
2227 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2228 | pExynosComponent->callbackData, | |
2229 | OMX_EventError, ret, 0, NULL); | |
2230 | } | |
20d3e6e3 | 2231 | |
38ef2572 JC |
2232 | EXIT: |
2233 | FunctionOut(); | |
20d3e6e3 | 2234 | |
38ef2572 JC |
2235 | return ret; |
2236 | } | |
20d3e6e3 | 2237 | |
38ef2572 JC |
2238 | OMX_ERRORTYPE Exynos_Mpeg4Enc_srcOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData) |
2239 | { | |
2240 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2241 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2242 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2243 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
800a8d75 | 2244 | |
38ef2572 JC |
2245 | FunctionIn(); |
2246 | ||
2247 | if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) { | |
2248 | ret = OMX_ErrorNone; | |
2249 | goto EXIT; | |
2250 | } | |
800a8d75 | 2251 | |
38ef2572 JC |
2252 | if ((pExynosInputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { |
2253 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) { | |
20d3e6e3 | 2254 | ret = OMX_ErrorNone; |
38ef2572 | 2255 | goto EXIT; |
20d3e6e3 JC |
2256 | } |
2257 | } | |
38ef2572 JC |
2258 | if ((pMpeg4Enc->bSourceStart == OMX_FALSE) && |
2259 | (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort))) { | |
2260 | Exynos_OSAL_SignalWait(pMpeg4Enc->hSourceStartEvent, DEF_MAX_WAIT_TIME); | |
2261 | Exynos_OSAL_SignalReset(pMpeg4Enc->hSourceStartEvent); | |
20d3e6e3 JC |
2262 | } |
2263 | ||
38ef2572 JC |
2264 | ret = Exynos_Mpeg4Enc_SrcOut(pOMXComponent, pSrcOutputData); |
2265 | if ((ret != OMX_ErrorNone) && (pExynosComponent->currentState == OMX_StateExecuting)) { | |
2266 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - SrcOut -> event is thrown to client", __FUNCTION__, __LINE__); | |
2267 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2268 | pExynosComponent->callbackData, | |
2269 | OMX_EventError, ret, 0, NULL); | |
20d3e6e3 JC |
2270 | } |
2271 | ||
38ef2572 JC |
2272 | EXIT: |
2273 | FunctionOut(); | |
2274 | ||
2275 | return ret; | |
2276 | } | |
2277 | ||
2278 | OMX_ERRORTYPE Exynos_Mpeg4Enc_dstInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData) | |
2279 | { | |
2280 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2281 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2282 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2283 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2284 | ||
2285 | FunctionIn(); | |
2286 | ||
2287 | if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) { | |
2288 | ret = OMX_ErrorNone; | |
20d3e6e3 JC |
2289 | goto EXIT; |
2290 | } | |
38ef2572 JC |
2291 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) { |
2292 | ret = OMX_ErrorNone; | |
800a8d75 | 2293 | goto EXIT; |
20d3e6e3 | 2294 | } |
38ef2572 JC |
2295 | if (pExynosOutputPort->bufferProcessType == BUFFER_SHARE) { |
2296 | if ((pMpeg4Enc->bDestinationStart == OMX_FALSE) && | |
2297 | (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { | |
2298 | Exynos_OSAL_SignalWait(pMpeg4Enc->hDestinationStartEvent, DEF_MAX_WAIT_TIME); | |
2299 | Exynos_OSAL_SignalReset(pMpeg4Enc->hDestinationStartEvent); | |
2300 | } | |
2301 | } | |
38ef2572 JC |
2302 | if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFCDst == OMX_TRUE) { |
2303 | ret = Exynos_Mpeg4Enc_DstIn(pOMXComponent, pDstInputData); | |
2304 | if (ret != OMX_ErrorNone) { | |
2305 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - DstIn -> event is thrown to client", __FUNCTION__, __LINE__); | |
2306 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2307 | pExynosComponent->callbackData, | |
2308 | OMX_EventError, ret, 0, NULL); | |
2309 | } | |
2310 | } | |
20d3e6e3 JC |
2311 | |
2312 | EXIT: | |
2313 | FunctionOut(); | |
2314 | ||
2315 | return ret; | |
2316 | } | |
2317 | ||
38ef2572 | 2318 | OMX_ERRORTYPE Exynos_Mpeg4Enc_dstOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData) |
20d3e6e3 | 2319 | { |
38ef2572 JC |
2320 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
2321 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2322 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2323 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
20d3e6e3 JC |
2324 | |
2325 | FunctionIn(); | |
2326 | ||
38ef2572 | 2327 | if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) { |
800a8d75 | 2328 | ret = OMX_ErrorNone; |
20d3e6e3 JC |
2329 | goto EXIT; |
2330 | } | |
38ef2572 | 2331 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) { |
800a8d75 | 2332 | ret = OMX_ErrorNone; |
20d3e6e3 JC |
2333 | goto EXIT; |
2334 | } | |
2335 | ||
38ef2572 JC |
2336 | if ((pExynosOutputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { |
2337 | if ((pMpeg4Enc->bDestinationStart == OMX_FALSE) && | |
2338 | (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { | |
2339 | Exynos_OSAL_SignalWait(pMpeg4Enc->hDestinationStartEvent, DEF_MAX_WAIT_TIME); | |
2340 | Exynos_OSAL_SignalReset(pMpeg4Enc->hDestinationStartEvent); | |
20d3e6e3 | 2341 | } |
38ef2572 | 2342 | } |
38ef2572 JC |
2343 | ret = Exynos_Mpeg4Enc_DstOut(pOMXComponent, pDstOutputData); |
2344 | if ((ret != OMX_ErrorNone) && (pExynosComponent->currentState == OMX_StateExecuting)) { | |
2345 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - DstOut -> event is thrown to client", __FUNCTION__, __LINE__); | |
2346 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2347 | pExynosComponent->callbackData, | |
2348 | OMX_EventError, ret, 0, NULL); | |
20d3e6e3 JC |
2349 | } |
2350 | ||
2351 | EXIT: | |
2352 | FunctionOut(); | |
2353 | ||
2354 | return ret; | |
2355 | } | |
2356 | ||
3e79a27e | 2357 | OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) |
20d3e6e3 | 2358 | { |
800a8d75 JC |
2359 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
2360 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
20d3e6e3 | 2361 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; |
800a8d75 JC |
2362 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; |
2363 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
2364 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; | |
2365 | OMX_S32 codecType = -1; | |
20d3e6e3 JC |
2366 | int i = 0; |
2367 | ||
2368 | FunctionIn(); | |
2369 | ||
2370 | if ((hComponent == NULL) || (componentName == NULL)) { | |
2371 | ret = OMX_ErrorBadParameter; | |
2372 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: parameters are null, ret: %X", __FUNCTION__, ret); | |
2373 | goto EXIT; | |
2374 | } | |
2375 | if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_MPEG4_ENC, componentName) == 0) { | |
2376 | codecType = CODEC_TYPE_MPEG4; | |
2377 | } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H263_ENC, componentName) == 0) { | |
2378 | codecType = CODEC_TYPE_H263; | |
2379 | } else { | |
2380 | ret = OMX_ErrorBadParameter; | |
2381 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: componentName(%s) error, ret: %X", __FUNCTION__, componentName, ret); | |
2382 | goto EXIT; | |
2383 | } | |
2384 | ||
2385 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
2386 | ret = Exynos_OMX_VideoEncodeComponentInit(pOMXComponent); | |
2387 | if (ret != OMX_ErrorNone) { | |
2388 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: Exynos_OMX_VideoDecodeComponentInit error, ret: %X", __FUNCTION__, ret); | |
2389 | goto EXIT; | |
2390 | } | |
2391 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2392 | pExynosComponent->codecType = HW_VIDEO_ENC_CODEC; | |
2393 | ||
2394 | pExynosComponent->componentName = (OMX_STRING)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); | |
2395 | if (pExynosComponent->componentName == NULL) { | |
2396 | Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent); | |
2397 | ret = OMX_ErrorInsufficientResources; | |
2398 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: componentName alloc error, ret: %X", __FUNCTION__, ret); | |
2399 | goto EXIT; | |
2400 | } | |
2401 | Exynos_OSAL_Memset(pExynosComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); | |
2402 | ||
2403 | pMpeg4Enc = Exynos_OSAL_Malloc(sizeof(EXYNOS_MPEG4ENC_HANDLE)); | |
2404 | if (pMpeg4Enc == NULL) { | |
2405 | Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent); | |
2406 | ret = OMX_ErrorInsufficientResources; | |
2407 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: EXYNOS_MPEG4ENC_HANDLE alloc error, ret: %X", __FUNCTION__, ret); | |
2408 | goto EXIT; | |
2409 | } | |
2410 | Exynos_OSAL_Memset(pMpeg4Enc, 0, sizeof(EXYNOS_MPEG4ENC_HANDLE)); | |
2411 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2412 | pVideoEnc->hCodecHandle = (OMX_HANDLETYPE)pMpeg4Enc; | |
2413 | pMpeg4Enc->hMFCMpeg4Handle.codecType = codecType; | |
2414 | ||
2415 | if (codecType == CODEC_TYPE_MPEG4) | |
2416 | Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_MPEG4_ENC); | |
2417 | else | |
2418 | Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_H263_ENC); | |
2419 | ||
2420 | /* Set componentVersion */ | |
2421 | pExynosComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; | |
2422 | pExynosComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; | |
2423 | pExynosComponent->componentVersion.s.nRevision = REVISION_NUMBER; | |
2424 | pExynosComponent->componentVersion.s.nStep = STEP_NUMBER; | |
2425 | /* Set specVersion */ | |
2426 | pExynosComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; | |
2427 | pExynosComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; | |
2428 | pExynosComponent->specVersion.s.nRevision = REVISION_NUMBER; | |
2429 | pExynosComponent->specVersion.s.nStep = STEP_NUMBER; | |
2430 | ||
20d3e6e3 JC |
2431 | /* Input port */ |
2432 | pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2433 | pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; | |
2434 | pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; | |
2435 | pExynosPort->portDefinition.format.video.nBitrate = 64000; | |
2436 | pExynosPort->portDefinition.format.video.xFramerate= (15 << 16); | |
38ef2572 | 2437 | pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; |
20d3e6e3 JC |
2438 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; |
2439 | pExynosPort->portDefinition.format.video.pNativeRender = 0; | |
2440 | pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; | |
2441 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2442 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video"); | |
2443 | pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; | |
20d3e6e3 | 2444 | pExynosPort->portDefinition.bEnabled = OMX_TRUE; |
38ef2572 JC |
2445 | pExynosPort->bufferProcessType = BUFFER_COPY; |
2446 | pExynosPort->portWayType = WAY2_PORT; | |
20d3e6e3 JC |
2447 | |
2448 | /* Output port */ | |
2449 | pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2450 | pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; | |
2451 | pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; | |
2452 | pExynosPort->portDefinition.format.video.nBitrate = 64000; | |
2453 | pExynosPort->portDefinition.format.video.xFramerate= (15 << 16); | |
38ef2572 | 2454 | pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; |
20d3e6e3 JC |
2455 | if (codecType == CODEC_TYPE_MPEG4) { |
2456 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; | |
2457 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2458 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "video/mpeg4"); | |
2459 | } else { | |
2460 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; | |
2461 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2462 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "video/h263"); | |
2463 | } | |
2464 | pExynosPort->portDefinition.format.video.pNativeRender = 0; | |
2465 | pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; | |
2466 | pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; | |
20d3e6e3 | 2467 | pExynosPort->portDefinition.bEnabled = OMX_TRUE; |
833233fa | 2468 | pExynosPort->bufferProcessType = BUFFER_SHARE; |
38ef2572 | 2469 | pExynosPort->portWayType = WAY2_PORT; |
20d3e6e3 JC |
2470 | |
2471 | if (codecType == CODEC_TYPE_MPEG4) { | |
2472 | for(i = 0; i < ALL_PORT_NUM; i++) { | |
2473 | INIT_SET_SIZE_VERSION(&pMpeg4Enc->mpeg4Component[i], OMX_VIDEO_PARAM_MPEG4TYPE); | |
2474 | pMpeg4Enc->mpeg4Component[i].nPortIndex = i; | |
2475 | pMpeg4Enc->mpeg4Component[i].eProfile = OMX_VIDEO_MPEG4ProfileSimple; | |
2476 | pMpeg4Enc->mpeg4Component[i].eLevel = OMX_VIDEO_MPEG4Level4; | |
2477 | ||
2478 | pMpeg4Enc->mpeg4Component[i].nPFrames = 10; | |
2479 | pMpeg4Enc->mpeg4Component[i].nBFrames = 0; /* No support for B frames */ | |
2480 | pMpeg4Enc->mpeg4Component[i].nMaxPacketSize = 256; /* Default value */ | |
2481 | pMpeg4Enc->mpeg4Component[i].nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP; | |
2482 | pMpeg4Enc->mpeg4Component[i].bGov = OMX_FALSE; | |
2483 | ||
2484 | } | |
2485 | } else { | |
2486 | for(i = 0; i < ALL_PORT_NUM; i++) { | |
2487 | INIT_SET_SIZE_VERSION(&pMpeg4Enc->h263Component[i], OMX_VIDEO_PARAM_H263TYPE); | |
2488 | pMpeg4Enc->h263Component[i].nPortIndex = i; | |
2489 | pMpeg4Enc->h263Component[i].eProfile = OMX_VIDEO_H263ProfileBaseline; | |
2490 | pMpeg4Enc->h263Component[i].eLevel = OMX_VIDEO_H263Level45; | |
2491 | ||
2492 | pMpeg4Enc->h263Component[i].nPFrames = 20; | |
2493 | pMpeg4Enc->h263Component[i].nBFrames = 0; /* No support for B frames */ | |
2494 | pMpeg4Enc->h263Component[i].bPLUSPTYPEAllowed = OMX_FALSE; | |
2495 | pMpeg4Enc->h263Component[i].nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP; | |
2496 | pMpeg4Enc->h263Component[i].bForceRoundingTypeToZero = OMX_TRUE; | |
2497 | pMpeg4Enc->h263Component[i].nPictureHeaderRepetition = 0; | |
2498 | pMpeg4Enc->h263Component[i].nGOBHeaderInterval = 0; | |
2499 | } | |
2500 | } | |
2501 | ||
800a8d75 JC |
2502 | pOMXComponent->GetParameter = &Exynos_Mpeg4Enc_GetParameter; |
2503 | pOMXComponent->SetParameter = &Exynos_Mpeg4Enc_SetParameter; | |
2504 | pOMXComponent->GetConfig = &Exynos_Mpeg4Enc_GetConfig; | |
2505 | pOMXComponent->SetConfig = &Exynos_Mpeg4Enc_SetConfig; | |
2506 | pOMXComponent->GetExtensionIndex = &Exynos_Mpeg4Enc_GetExtensionIndex; | |
2507 | pOMXComponent->ComponentRoleEnum = &Exynos_Mpeg4Enc_ComponentRoleEnum; | |
20d3e6e3 JC |
2508 | pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit; |
2509 | ||
38ef2572 JC |
2510 | pExynosComponent->exynos_codec_componentInit = &Exynos_Mpeg4Enc_Init; |
2511 | pExynosComponent->exynos_codec_componentTerminate = &Exynos_Mpeg4Enc_Terminate; | |
2512 | ||
2513 | pVideoEnc->exynos_codec_srcInputProcess = &Exynos_Mpeg4Enc_srcInputBufferProcess; | |
2514 | pVideoEnc->exynos_codec_srcOutputProcess = &Exynos_Mpeg4Enc_srcOutputBufferProcess; | |
2515 | pVideoEnc->exynos_codec_dstInputProcess = &Exynos_Mpeg4Enc_dstInputBufferProcess; | |
2516 | pVideoEnc->exynos_codec_dstOutputProcess = &Exynos_Mpeg4Enc_dstOutputBufferProcess; | |
2517 | ||
2518 | pVideoEnc->exynos_codec_start = &Mpeg4CodecStart; | |
2519 | pVideoEnc->exynos_codec_stop = &Mpeg4CodecStop; | |
2520 | pVideoEnc->exynos_codec_bufferProcessRun = &Mpeg4CodecOutputBufferProcessRun; | |
2521 | pVideoEnc->exynos_codec_enqueueAllBuffer = &Mpeg4CodecEnQueueAllBuffer; | |
2522 | ||
2523 | pVideoEnc->exynos_checkInputFrame = NULL; | |
2524 | pVideoEnc->exynos_codec_getCodecInputPrivateData = &GetCodecInputPrivateData; | |
2525 | pVideoEnc->exynos_codec_getCodecOutputPrivateData = &GetCodecOutputPrivateData; | |
38ef2572 JC |
2526 | |
2527 | pVideoEnc->hSharedMemory = Exynos_OSAL_SharedMemory_Open(); | |
2528 | if (pVideoEnc->hSharedMemory == NULL) { | |
2529 | Exynos_OSAL_Free(pMpeg4Enc); | |
2530 | pMpeg4Enc = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle = NULL; | |
2531 | Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent); | |
2532 | ret = OMX_ErrorInsufficientResources; | |
2533 | goto EXIT; | |
2534 | } | |
20d3e6e3 JC |
2535 | |
2536 | pExynosComponent->currentState = OMX_StateLoaded; | |
2537 | ||
2538 | ret = OMX_ErrorNone; | |
2539 | ||
2540 | EXIT: | |
2541 | FunctionOut(); | |
2542 | ||
2543 | return ret; | |
2544 | } | |
2545 | ||
2546 | OMX_ERRORTYPE Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) | |
2547 | { | |
800a8d75 JC |
2548 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
2549 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
20d3e6e3 | 2550 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; |
38ef2572 | 2551 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; |
800a8d75 | 2552 | EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; |
20d3e6e3 JC |
2553 | |
2554 | FunctionIn(); | |
2555 | ||
2556 | if (hComponent == NULL) { | |
2557 | ret = OMX_ErrorBadParameter; | |
2558 | goto EXIT; | |
2559 | } | |
2560 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
2561 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
38ef2572 JC |
2562 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; |
2563 | ||
2564 | Exynos_OSAL_SharedMemory_Close(pVideoEnc->hSharedMemory); | |
20d3e6e3 JC |
2565 | |
2566 | Exynos_OSAL_Free(pExynosComponent->componentName); | |
2567 | pExynosComponent->componentName = NULL; | |
2568 | ||
2569 | pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2570 | if (pMpeg4Enc != NULL) { | |
2571 | Exynos_OSAL_Free(pMpeg4Enc); | |
2572 | pMpeg4Enc = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle = NULL; | |
2573 | } | |
2574 | ||
2575 | ret = Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent); | |
2576 | if (ret != OMX_ErrorNone) { | |
2577 | goto EXIT; | |
2578 | } | |
2579 | ||
2580 | ret = OMX_ErrorNone; | |
2581 | ||
2582 | EXIT: | |
2583 | FunctionOut(); | |
2584 | ||
2585 | return ret; | |
2586 | } |