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