Commit | Line | Data |
---|---|---|
c6f4bc34 YK |
1 | /* |
2 | * | |
3 | * Copyright 2012 Samsung Electronics S.LSI Co. LTD | |
4 | * | |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | */ | |
17 | ||
18 | /* | |
19 | * @file Exynos_OMX_Mpeg4dec.c | |
20 | * @brief | |
21 | * @author Yunji Kim (yunji.kim@samsung.com) | |
22 | * @author SeungBeom Kim (sbcrux.kim@samsung.com) | |
23 | * @version 2.0.0 | |
24 | * @history | |
25 | * 2012.02.20 : Create | |
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" | |
42 | #include "Exynos_OSAL_SharedMemory.h" | |
43 | #include "Exynos_OSAL_Event.h" | |
44 | ||
45 | #ifdef USE_ANB | |
46 | #include "Exynos_OSAL_Android.h" | |
47 | #endif | |
48 | ||
49 | /* To use CSC_METHOD_HW in EXYNOS OMX, gralloc should allocate physical memory using FIMC */ | |
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 | |
56 | //#define EXYNOS_TRACE_ON | |
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 | ||
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 | ||
158 | static OMX_BOOL gbFIMV1 = OMX_FALSE; | |
159 | ||
160 | static int Check_Mpeg4_Frame( | |
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 | ||
233 | static int Check_H263_Frame( | |
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 | ||
299 | static OMX_BOOL Check_Stream_StartCode( | |
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: | |
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 { | |
347 | return OMX_FALSE; | |
348 | } | |
349 | default: | |
350 | Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "%s: undefined codec type (%d)", __FUNCTION__, codecType); | |
351 | return OMX_FALSE; | |
352 | } | |
353 | } | |
354 | ||
355 | OMX_ERRORTYPE Mpeg4CodecOpen(EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec) | |
356 | { | |
357 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
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 | ||
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); | |
391 | ||
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 */ | |
faa0e22c | 413 | #ifdef USE_DMA_BUF |
c6f4bc34 | 414 | pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.pDecOps->Init(V4L2_MEMORY_DMABUF); |
faa0e22c SKR |
415 | #else |
416 | pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.pDecOps->Init(V4L2_MEMORY_USERPTR); | |
417 | #endif | |
c6f4bc34 YK |
418 | if (pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle == NULL) { |
419 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate context buffer"); | |
420 | ret = OMX_ErrorInsufficientResources; | |
421 | goto EXIT; | |
422 | } | |
423 | ||
424 | ret = OMX_ErrorNone; | |
425 | ||
426 | EXIT: | |
427 | if (ret != OMX_ErrorNone) { | |
428 | if (pDecOps != NULL) { | |
429 | Exynos_OSAL_Free(pDecOps); | |
430 | pMpeg4Dec->hMFCMpeg4Handle.pDecOps = NULL; | |
431 | } | |
432 | if (pInbufOps != NULL) { | |
433 | Exynos_OSAL_Free(pInbufOps); | |
434 | pMpeg4Dec->hMFCMpeg4Handle.pInbufOps = NULL; | |
435 | } | |
436 | if (pOutbufOps != NULL) { | |
437 | Exynos_OSAL_Free(pOutbufOps); | |
438 | pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps = NULL; | |
439 | } | |
440 | } | |
441 | ||
442 | FunctionOut(); | |
443 | ||
444 | return ret; | |
445 | } | |
446 | ||
447 | OMX_ERRORTYPE Mpeg4CodecClose(EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec) | |
448 | { | |
449 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
450 | void *hMFCHandle = NULL; | |
451 | ExynosVideoDecOps *pDecOps = NULL; | |
452 | ExynosVideoDecBufferOps *pInbufOps = NULL; | |
453 | ExynosVideoDecBufferOps *pOutbufOps = NULL; | |
454 | ||
455 | FunctionIn(); | |
456 | ||
457 | if (pMpeg4Dec == NULL) { | |
458 | ret = OMX_ErrorBadParameter; | |
459 | goto EXIT; | |
460 | } | |
461 | ||
462 | hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
463 | pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; | |
464 | pInbufOps = pMpeg4Dec->hMFCMpeg4Handle.pInbufOps; | |
465 | pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps; | |
466 | ||
467 | if (hMFCHandle != NULL) { | |
468 | pDecOps->Finalize(hMFCHandle); | |
469 | pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = NULL; | |
470 | } | |
471 | if (pOutbufOps != NULL) { | |
472 | Exynos_OSAL_Free(pOutbufOps); | |
473 | pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps = NULL; | |
474 | } | |
475 | if (pInbufOps != NULL) { | |
476 | Exynos_OSAL_Free(pInbufOps); | |
477 | pMpeg4Dec->hMFCMpeg4Handle.pInbufOps = NULL; | |
478 | } | |
479 | if (pDecOps != NULL) { | |
480 | Exynos_OSAL_Free(pDecOps); | |
481 | pMpeg4Dec->hMFCMpeg4Handle.pDecOps = NULL; | |
482 | } | |
483 | ||
484 | ret = OMX_ErrorNone; | |
485 | ||
486 | EXIT: | |
487 | FunctionOut(); | |
488 | ||
489 | return ret; | |
490 | } | |
491 | ||
492 | OMX_ERRORTYPE Mpeg4CodecStart(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
493 | { | |
494 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
495 | void *hMFCHandle = NULL; | |
496 | ExynosVideoDecOps *pDecOps = NULL; | |
497 | ExynosVideoDecBufferOps *pInbufOps = NULL; | |
498 | ExynosVideoDecBufferOps *pOutbufOps = NULL; | |
499 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL; | |
500 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
501 | ||
502 | FunctionIn(); | |
503 | ||
504 | if (pOMXComponent == NULL) { | |
505 | ret = OMX_ErrorBadParameter; | |
506 | goto EXIT; | |
507 | } | |
508 | ||
509 | pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle; | |
510 | if (pVideoDec == NULL) { | |
511 | ret = OMX_ErrorBadParameter; | |
512 | goto EXIT; | |
513 | } | |
514 | ||
515 | pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)pVideoDec->hCodecHandle; | |
516 | if (pMpeg4Dec == NULL) { | |
517 | ret = OMX_ErrorBadParameter; | |
518 | goto EXIT; | |
519 | } | |
520 | ||
521 | hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
522 | pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; | |
523 | pInbufOps = pMpeg4Dec->hMFCMpeg4Handle.pInbufOps; | |
524 | pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps; | |
525 | ||
526 | if (nPortIndex == INPUT_PORT_INDEX) | |
527 | pInbufOps->Run(hMFCHandle); | |
528 | else if (nPortIndex == OUTPUT_PORT_INDEX) | |
529 | pOutbufOps->Run(hMFCHandle); | |
530 | ||
531 | ret = OMX_ErrorNone; | |
532 | ||
533 | EXIT: | |
534 | FunctionOut(); | |
535 | ||
536 | return ret; | |
537 | } | |
538 | ||
539 | OMX_ERRORTYPE Mpeg4CodecStop(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
540 | { | |
541 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
542 | void *hMFCHandle = NULL; | |
543 | ExynosVideoDecOps *pDecOps = NULL; | |
544 | ExynosVideoDecBufferOps *pInbufOps = NULL; | |
545 | ExynosVideoDecBufferOps *pOutbufOps = NULL; | |
546 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL; | |
547 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
548 | ||
549 | FunctionIn(); | |
550 | ||
551 | if (pOMXComponent == NULL) { | |
552 | ret = OMX_ErrorBadParameter; | |
553 | goto EXIT; | |
554 | } | |
555 | ||
556 | pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle; | |
557 | if (pVideoDec == NULL) { | |
558 | ret = OMX_ErrorBadParameter; | |
559 | goto EXIT; | |
560 | } | |
561 | pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)pVideoDec->hCodecHandle; | |
562 | if (pMpeg4Dec == NULL) { | |
563 | ret = OMX_ErrorBadParameter; | |
564 | goto EXIT; | |
565 | } | |
566 | ||
567 | hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
568 | pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; | |
569 | pInbufOps = pMpeg4Dec->hMFCMpeg4Handle.pInbufOps; | |
570 | pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps; | |
571 | ||
572 | if ((nPortIndex == INPUT_PORT_INDEX) && (pInbufOps != NULL)) | |
573 | pInbufOps->Stop(hMFCHandle); | |
574 | else if ((nPortIndex == OUTPUT_PORT_INDEX) && (pOutbufOps != NULL)) | |
575 | pOutbufOps->Stop(hMFCHandle); | |
576 | ||
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 | ||
595 | FunctionIn(); | |
596 | ||
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 | ||
0641ae29 TK |
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 | ||
c6f4bc34 YK |
701 | OMX_ERRORTYPE Mpeg4CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) |
702 | { | |
703 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
704 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
705 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
706 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)pVideoDec->hCodecHandle; | |
707 | void *hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
708 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
709 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
710 | int i, nOutbufs; | |
711 | ||
712 | ExynosVideoDecOps *pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; | |
713 | ExynosVideoDecBufferOps *pInbufOps = pMpeg4Dec->hMFCMpeg4Handle.pInbufOps; | |
714 | ExynosVideoDecBufferOps *pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps; | |
715 | ||
716 | FunctionIn(); | |
717 | ||
17c96630 TK |
718 | if ((nPortIndex != INPUT_PORT_INDEX) && (nPortIndex != OUTPUT_PORT_INDEX)) { |
719 | ret = OMX_ErrorBadPortIndex; | |
720 | goto EXIT; | |
721 | } | |
722 | ||
c6f4bc34 YK |
723 | if ((nPortIndex == INPUT_PORT_INDEX) && |
724 | (pMpeg4Dec->bSourceStart == OMX_TRUE)) { | |
725 | Exynos_CodecBufferReset(pExynosComponent, INPUT_PORT_INDEX); | |
726 | ||
727 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { | |
728 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]); | |
729 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0]); | |
730 | ||
731 | Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]); | |
732 | } | |
733 | ||
734 | pInbufOps->Clear_Queue(hMFCHandle); | |
735 | } else if ((nPortIndex == OUTPUT_PORT_INDEX) && | |
736 | (pMpeg4Dec->bDestinationStart == OMX_TRUE)) { | |
c6f4bc34 YK |
737 | Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX); |
738 | ||
e90eb9e8 TK |
739 | for (i = 0; i < pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum; i++) { |
740 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]); | |
741 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]); | |
742 | ||
743 | Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, pVideoDec->pMFCDecOutputBuffer[i]); | |
c6f4bc34 YK |
744 | } |
745 | pOutbufOps->Clear_Queue(hMFCHandle); | |
c6f4bc34 YK |
746 | } |
747 | ||
748 | EXIT: | |
749 | FunctionOut(); | |
750 | ||
751 | return ret; | |
752 | } | |
753 | ||
754 | OMX_ERRORTYPE Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) | |
755 | { | |
756 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
757 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
758 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
759 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
760 | void *hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
761 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
762 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
763 | OMX_U32 oneFrameSize = pSrcInputData->dataLen; | |
764 | ||
765 | ExynosVideoDecOps *pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; | |
766 | ExynosVideoDecBufferOps *pInbufOps = pMpeg4Dec->hMFCMpeg4Handle.pInbufOps; | |
767 | ExynosVideoDecBufferOps *pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps; | |
768 | ExynosVideoGeometry bufferConf; | |
769 | OMX_U32 inputBufferNumber = 0; | |
770 | int i; | |
771 | ||
772 | FunctionIn(); | |
773 | ||
774 | if ((oneFrameSize <= 0) && (pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS)) { | |
775 | OMX_BUFFERHEADERTYPE *OMXBuffer = NULL; | |
776 | OMXBuffer = Exynos_OutputBufferGetQueue_Direct(pExynosComponent); | |
777 | if (OMXBuffer == NULL) { | |
778 | ret = OMX_ErrorUndefined; | |
779 | goto EXIT; | |
780 | } | |
781 | ||
782 | OMXBuffer->nTimeStamp = pSrcInputData->timeStamp; | |
783 | OMXBuffer->nFlags = pSrcInputData->nFlags; | |
784 | Exynos_OMX_OutputBufferReturn(pOMXComponent, OMXBuffer); | |
785 | ||
786 | ret = OMX_ErrorNone; | |
787 | goto EXIT; | |
788 | } | |
789 | ||
790 | if (pVideoDec->bThumbnailMode == OMX_TRUE) | |
791 | pDecOps->Set_DisplayDelay(hMFCHandle, 0); | |
792 | ||
c70316c7 JY |
793 | if ((pDecOps->Enable_DTSMode != NULL) && |
794 | (pVideoDec->bDTSMode == OMX_TRUE)) | |
795 | pDecOps->Enable_DTSMode(hMFCHandle); | |
796 | ||
c6f4bc34 YK |
797 | /* input buffer info */ |
798 | Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf)); | |
799 | if (pMpeg4Dec->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) | |
800 | bufferConf.eCompressionFormat = VIDEO_CODING_MPEG4; | |
801 | else | |
802 | bufferConf.eCompressionFormat = VIDEO_CODING_H263; | |
803 | ||
804 | pInbufOps->Set_Shareable(hMFCHandle); | |
24ec2c82 | 805 | if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
806 | bufferConf.nSizeImage = pExynosInputPort->portDefinition.format.video.nFrameWidth |
807 | * pExynosInputPort->portDefinition.format.video.nFrameHeight * 3 / 2; | |
808 | inputBufferNumber = MAX_VIDEO_INPUTBUFFER_NUM; | |
24ec2c82 | 809 | } else if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
810 | bufferConf.nSizeImage = DEFAULT_MFC_INPUT_BUFFER_SIZE; |
811 | inputBufferNumber = MFC_INPUT_BUFFER_NUM_MAX; | |
812 | } | |
813 | ||
814 | /* should be done before prepare input buffer */ | |
815 | if (pInbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) { | |
816 | ret = OMX_ErrorInsufficientResources; | |
817 | goto EXIT; | |
818 | } | |
819 | ||
820 | /* set input buffer geometry */ | |
821 | if (pInbufOps->Set_Geometry(hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) { | |
822 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for input buffer"); | |
823 | ret = OMX_ErrorInsufficientResources; | |
824 | goto EXIT; | |
825 | } | |
826 | ||
827 | /* setup input buffer */ | |
828 | if (pInbufOps->Setup(hMFCHandle, inputBufferNumber) != VIDEO_ERROR_NONE) { | |
829 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup input buffer"); | |
830 | ret = OMX_ErrorInsufficientResources; | |
831 | goto EXIT; | |
832 | } | |
833 | ||
24ec2c82 | 834 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
0641ae29 TK |
835 | ret = Mpeg4CodecRegistCodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX); |
836 | if (ret != OMX_ErrorNone) | |
837 | goto EXIT; | |
24ec2c82 | 838 | } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
839 | /* Register input buffer */ |
840 | for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) { | |
841 | ExynosVideoPlane plane; | |
842 | plane.addr = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer; | |
843 | plane.allocSize = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->nAllocLen; | |
844 | plane.fd = pExynosInputPort->extendBufferHeader[i].buf_fd[0]; | |
845 | if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
846 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer"); | |
847 | ret = OMX_ErrorInsufficientResources; | |
848 | goto EXIT; | |
849 | } | |
850 | } | |
851 | } | |
852 | ||
853 | /* set output geometry */ | |
854 | Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf)); | |
855 | pMpeg4Dec->hMFCMpeg4Handle.MFCOutputColorType = bufferConf.eColorFormat = VIDEO_COLORFORMAT_NV12_TILED; | |
856 | if (pOutbufOps->Set_Geometry(hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) { | |
857 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for output buffer"); | |
858 | ret = OMX_ErrorInsufficientResources; | |
859 | goto EXIT; | |
860 | } | |
861 | ||
862 | /* input buffer enqueue for header parsing */ | |
863 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "oneFrameSize: %d", oneFrameSize); | |
864 | if (pInbufOps->Enqueue(hMFCHandle, (unsigned char **)&pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, | |
865 | (unsigned int *)&oneFrameSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader) != VIDEO_ERROR_NONE) { | |
866 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to enqueue input buffer for header parsing"); | |
867 | // ret = OMX_ErrorInsufficientResources; | |
868 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecInit; | |
869 | goto EXIT; | |
870 | } | |
871 | ||
872 | /* start header parsing */ | |
873 | if (pInbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) { | |
874 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run input buffer for header parsing"); | |
875 | ret = OMX_ErrorCodecInit; | |
876 | goto EXIT; | |
877 | } | |
878 | ||
879 | /* get geometry for output */ | |
880 | Exynos_OSAL_Memset(&pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf, 0, sizeof(ExynosVideoGeometry)); | |
881 | if (pOutbufOps->Get_Geometry(hMFCHandle, &pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf) != VIDEO_ERROR_NONE) { | |
882 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to get geometry for parsed header info"); | |
883 | ret = OMX_ErrorInsufficientResources; | |
884 | goto EXIT; | |
885 | } | |
886 | ||
887 | /* get dpb count */ | |
888 | pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle); | |
889 | if (pVideoDec->bThumbnailMode == OMX_FALSE) | |
890 | pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum += EXTRA_DPB_NUM; | |
891 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Mpeg4CodecSetup nOutbufs: %d", pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum); | |
892 | ||
893 | pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFCSrc = OMX_TRUE; | |
894 | ||
24ec2c82 | 895 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
896 | if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameWidth) || |
897 | (pExynosInputPort->portDefinition.format.video.nFrameHeight != pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameHeight)) { | |
a947bcc1 TK |
898 | pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE; |
899 | ||
c6f4bc34 YK |
900 | pExynosInputPort->portDefinition.format.video.nFrameWidth = pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameWidth; |
901 | pExynosInputPort->portDefinition.format.video.nFrameHeight = pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameHeight; | |
902 | pExynosInputPort->portDefinition.format.video.nStride = ((pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameWidth + 15) & (~15)); | |
903 | pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameHeight + 15) & (~15)); | |
904 | ||
905 | Exynos_UpdateFrameSize(pOMXComponent); | |
c6f4bc34 YK |
906 | |
907 | /** Send Port Settings changed call back **/ | |
908 | (*(pExynosComponent->pCallbacks->EventHandler)) | |
909 | (pOMXComponent, | |
910 | pExynosComponent->callbackData, | |
911 | OMX_EventPortSettingsChanged, /* The command was completed */ | |
912 | OMX_DirOutput, /* This is the port index */ | |
913 | 0, | |
914 | NULL); | |
915 | } | |
24ec2c82 | 916 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
917 | if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameWidth) || |
918 | (pExynosInputPort->portDefinition.format.video.nFrameHeight != pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameHeight) || | |
919 | (pExynosOutputPort->portDefinition.nBufferCountActual != pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum)) { | |
a947bcc1 TK |
920 | pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE; |
921 | ||
c6f4bc34 YK |
922 | pExynosInputPort->portDefinition.format.video.nFrameWidth = pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameWidth; |
923 | pExynosInputPort->portDefinition.format.video.nFrameHeight = pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameHeight; | |
924 | pExynosInputPort->portDefinition.format.video.nStride = ((pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameWidth + 15) & (~15)); | |
925 | pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameHeight + 15) & (~15)); | |
926 | ||
927 | pExynosOutputPort->portDefinition.nBufferCountActual = pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum - 2; | |
928 | pExynosOutputPort->portDefinition.nBufferCountMin = pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum - 2; | |
929 | ||
930 | Exynos_UpdateFrameSize(pOMXComponent); | |
c6f4bc34 YK |
931 | |
932 | /** Send Port Settings changed call back **/ | |
933 | (*(pExynosComponent->pCallbacks->EventHandler)) | |
934 | (pOMXComponent, | |
935 | pExynosComponent->callbackData, | |
936 | OMX_EventPortSettingsChanged, /* The command was completed */ | |
937 | OMX_DirOutput, /* This is the port index */ | |
938 | 0, | |
939 | NULL); | |
940 | } | |
941 | } | |
942 | Exynos_OSAL_SleepMillisec(0); | |
943 | ret = OMX_ErrorInputDataDecodeYet; | |
944 | Mpeg4CodecStop(pOMXComponent, INPUT_PORT_INDEX); | |
945 | ||
946 | EXIT: | |
947 | FunctionOut(); | |
948 | ||
949 | return ret; | |
950 | } | |
951 | ||
952 | OMX_ERRORTYPE Mpeg4CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent) | |
953 | { | |
954 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
955 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
956 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
957 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
958 | void *hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
959 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
960 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
961 | ||
962 | ExynosVideoDecOps *pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; | |
963 | ExynosVideoDecBufferOps *pInbufOps = pMpeg4Dec->hMFCMpeg4Handle.pInbufOps; | |
964 | ExynosVideoDecBufferOps *pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps; | |
965 | ||
966 | int i, nOutbufs; | |
967 | ||
e02ebaac TK |
968 | OMX_U32 nAllocLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0}; |
969 | OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0}; | |
970 | ||
c6f4bc34 YK |
971 | FunctionIn(); |
972 | ||
e02ebaac TK |
973 | nAllocLen[0] = pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nAlignPlaneSize[0]; |
974 | nAllocLen[1] = pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nAlignPlaneSize[1]; | |
975 | ||
976 | pOutbufOps->Set_Shareable(hMFCHandle); | |
977 | ||
24ec2c82 | 978 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
979 | /* should be done before prepare output buffer */ |
980 | if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) { | |
981 | ret = OMX_ErrorInsufficientResources; | |
982 | goto EXIT; | |
983 | } | |
c6f4bc34 | 984 | |
a38b0597 TK |
985 | /* get dpb count */ |
986 | nOutbufs = pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum; | |
987 | if (pOutbufOps->Setup(hMFCHandle, nOutbufs) != VIDEO_ERROR_NONE) { | |
988 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer"); | |
989 | ret = OMX_ErrorInsufficientResources; | |
990 | goto EXIT; | |
991 | } | |
992 | ||
0641ae29 TK |
993 | ret = Exynos_Allocate_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs, nAllocLen); |
994 | if (ret != OMX_ErrorNone) | |
995 | goto EXIT; | |
c6f4bc34 | 996 | |
0641ae29 TK |
997 | ret = Mpeg4CodecRegistCodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs); |
998 | if (ret != OMX_ErrorNone) | |
999 | goto EXIT; | |
1000 | ||
1001 | /* Enqueue output buffer */ | |
1002 | for (i = 0; i < nOutbufs; i++) { | |
c6f4bc34 YK |
1003 | pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr, |
1004 | (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL); | |
1005 | } | |
98034ac0 SK |
1006 | |
1007 | if (pOutbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) { | |
1008 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run output buffer"); | |
1009 | ret = OMX_ErrorInsufficientResources; | |
1010 | goto EXIT; | |
1011 | } | |
24ec2c82 | 1012 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
e02ebaac TK |
1013 | ExynosVideoPlane planes[MFC_OUTPUT_BUFFER_PLANE]; |
1014 | int plane; | |
1015 | ||
a38b0597 TK |
1016 | /* get dpb count */ |
1017 | nOutbufs = pExynosOutputPort->portDefinition.nBufferCountActual; | |
1018 | if (pOutbufOps->Setup(hMFCHandle, nOutbufs) != VIDEO_ERROR_NONE) { | |
1019 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer"); | |
1020 | ret = OMX_ErrorInsufficientResources; | |
1021 | goto EXIT; | |
1022 | } | |
1023 | ||
c6f4bc34 YK |
1024 | /* Register output buffer */ |
1025 | /*************/ | |
1026 | /* TBD */ | |
1027 | /*************/ | |
1028 | #ifdef USE_ANB | |
1029 | if (pExynosOutputPort->bIsANBEnabled == OMX_TRUE) { | |
1030 | for (i = 0; i < pExynosOutputPort->assignedBufferNum; i++) { | |
1031 | for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) { | |
1032 | planes[plane].fd = pExynosOutputPort->extendBufferHeader[i].buf_fd[plane]; | |
1033 | planes[plane].addr = pExynosOutputPort->extendBufferHeader[i].pYUVBuf[plane]; | |
1034 | planes[plane].allocSize = nAllocLen[plane]; | |
1035 | } | |
1036 | ||
1037 | if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
1038 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer"); | |
1039 | ret = OMX_ErrorInsufficientResources; | |
1040 | goto EXIT; | |
1041 | } | |
1042 | pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pExynosOutputPort->extendBufferHeader[i].pYUVBuf, | |
1043 | (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL); | |
1044 | } | |
98034ac0 SK |
1045 | |
1046 | if (pOutbufOps->Apply_RegisteredBuffer(hMFCHandle) != VIDEO_ERROR_NONE) { | |
1047 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Apply output buffer"); | |
1048 | ret = OMX_ErrorHardware; | |
1049 | goto EXIT; | |
1050 | } | |
c6f4bc34 YK |
1051 | } else { |
1052 | ret = OMX_ErrorNotImplemented; | |
1053 | goto EXIT; | |
1054 | } | |
1055 | #else | |
1056 | ret = OMX_ErrorNotImplemented; | |
1057 | goto EXIT; | |
1058 | #endif | |
1059 | } | |
1060 | ||
c6f4bc34 YK |
1061 | pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFCDst = OMX_TRUE; |
1062 | ||
1063 | ret = OMX_ErrorNone; | |
1064 | ||
1065 | EXIT: | |
1066 | FunctionOut(); | |
1067 | ||
1068 | return ret; | |
1069 | } | |
1070 | ||
1071 | OMX_ERRORTYPE Exynos_Mpeg4Dec_GetParameter( | |
1072 | OMX_IN OMX_HANDLETYPE hComponent, | |
1073 | OMX_IN OMX_INDEXTYPE nParamIndex, | |
1074 | OMX_INOUT OMX_PTR pComponentParameterStructure) | |
1075 | { | |
1076 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1077 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1078 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1079 | ||
1080 | FunctionIn(); | |
1081 | ||
1082 | if (hComponent == NULL || pComponentParameterStructure == NULL) { | |
1083 | ret = OMX_ErrorBadParameter; | |
1084 | goto EXIT; | |
1085 | } | |
1086 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1087 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1088 | if (ret != OMX_ErrorNone) { | |
1089 | goto EXIT; | |
1090 | } | |
1091 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1092 | ret = OMX_ErrorBadParameter; | |
1093 | goto EXIT; | |
1094 | } | |
1095 | ||
1096 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1097 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1098 | ret = OMX_ErrorInvalidState; | |
1099 | goto EXIT; | |
1100 | } | |
1101 | ||
1102 | switch (nParamIndex) { | |
1103 | case OMX_IndexParamVideoMpeg4: | |
1104 | { | |
1105 | OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; | |
1106 | OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL; | |
1107 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
1108 | ||
1109 | ret = Exynos_OMX_Check_SizeVersion(pDstMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); | |
1110 | if (ret != OMX_ErrorNone) { | |
1111 | goto EXIT; | |
1112 | } | |
1113 | ||
1114 | if (pDstMpeg4Param->nPortIndex >= ALL_PORT_NUM) { | |
1115 | ret = OMX_ErrorBadPortIndex; | |
1116 | goto EXIT; | |
1117 | } | |
1118 | ||
1119 | pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1120 | pSrcMpeg4Param = &pMpeg4Dec->mpeg4Component[pDstMpeg4Param->nPortIndex]; | |
1121 | ||
1122 | Exynos_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); | |
1123 | } | |
1124 | break; | |
1125 | case OMX_IndexParamVideoH263: | |
1126 | { | |
1127 | OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; | |
1128 | OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL; | |
1129 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
1130 | ||
1131 | ret = Exynos_OMX_Check_SizeVersion(pDstH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); | |
1132 | if (ret != OMX_ErrorNone) { | |
1133 | goto EXIT; | |
1134 | } | |
1135 | ||
1136 | if (pDstH263Param->nPortIndex >= ALL_PORT_NUM) { | |
1137 | ret = OMX_ErrorBadPortIndex; | |
1138 | goto EXIT; | |
1139 | } | |
1140 | ||
1141 | pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1142 | pSrcH263Param = &pMpeg4Dec->h263Component[pDstH263Param->nPortIndex]; | |
1143 | ||
1144 | Exynos_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); | |
1145 | } | |
1146 | break; | |
1147 | case OMX_IndexParamStandardComponentRole: | |
1148 | { | |
1149 | OMX_S32 codecType; | |
1150 | OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; | |
1151 | ||
1152 | ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); | |
1153 | if (ret != OMX_ErrorNone) { | |
1154 | goto EXIT; | |
1155 | } | |
1156 | ||
1157 | codecType = ((EXYNOS_MPEG4DEC_HANDLE *)(((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType; | |
1158 | if (codecType == CODEC_TYPE_MPEG4) | |
1159 | Exynos_OSAL_Strcpy((char *)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE); | |
1160 | else | |
1161 | Exynos_OSAL_Strcpy((char *)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE); | |
1162 | } | |
1163 | break; | |
1164 | case OMX_IndexParamVideoProfileLevelQuerySupported: | |
1165 | { | |
1166 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; | |
1167 | EXYNOS_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; | |
1168 | OMX_U32 maxProfileLevelNum = 0; | |
1169 | OMX_S32 codecType; | |
1170 | ||
1171 | ret = Exynos_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
1172 | if (ret != OMX_ErrorNone) { | |
1173 | goto EXIT; | |
1174 | } | |
1175 | ||
1176 | if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1177 | ret = OMX_ErrorBadPortIndex; | |
1178 | goto EXIT; | |
1179 | } | |
1180 | ||
1181 | codecType = ((EXYNOS_MPEG4DEC_HANDLE *)(((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType; | |
1182 | if (codecType == CODEC_TYPE_MPEG4) { | |
1183 | pProfileLevel = supportedMPEG4ProfileLevels; | |
1184 | maxProfileLevelNum = sizeof(supportedMPEG4ProfileLevels) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL); | |
1185 | } else { | |
1186 | pProfileLevel = supportedH263ProfileLevels; | |
1187 | maxProfileLevelNum = sizeof(supportedH263ProfileLevels) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL); | |
1188 | } | |
1189 | ||
1190 | if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { | |
1191 | ret = OMX_ErrorNoMore; | |
1192 | goto EXIT; | |
1193 | } | |
1194 | ||
1195 | pProfileLevel += pDstProfileLevel->nProfileIndex; | |
1196 | pDstProfileLevel->eProfile = pProfileLevel->profile; | |
1197 | pDstProfileLevel->eLevel = pProfileLevel->level; | |
1198 | } | |
1199 | break; | |
1200 | case OMX_IndexParamVideoProfileLevelCurrent: | |
1201 | { | |
1202 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; | |
1203 | OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL; | |
1204 | OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL; | |
1205 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
1206 | OMX_S32 codecType; | |
1207 | ||
1208 | ret = Exynos_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
1209 | if (ret != OMX_ErrorNone) { | |
1210 | goto EXIT; | |
1211 | } | |
1212 | ||
1213 | if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1214 | ret = OMX_ErrorBadPortIndex; | |
1215 | goto EXIT; | |
1216 | } | |
1217 | ||
1218 | pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1219 | codecType = pMpeg4Dec->hMFCMpeg4Handle.codecType; | |
1220 | if (codecType == CODEC_TYPE_MPEG4) { | |
1221 | pSrcMpeg4Param = &pMpeg4Dec->mpeg4Component[pDstProfileLevel->nPortIndex]; | |
1222 | pDstProfileLevel->eProfile = pSrcMpeg4Param->eProfile; | |
1223 | pDstProfileLevel->eLevel = pSrcMpeg4Param->eLevel; | |
1224 | } else { | |
1225 | pSrcH263Param = &pMpeg4Dec->h263Component[pDstProfileLevel->nPortIndex]; | |
1226 | pDstProfileLevel->eProfile = pSrcH263Param->eProfile; | |
1227 | pDstProfileLevel->eLevel = pSrcH263Param->eLevel; | |
1228 | } | |
1229 | } | |
1230 | break; | |
1231 | case OMX_IndexParamVideoErrorCorrection: | |
1232 | { | |
1233 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; | |
1234 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; | |
1235 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
1236 | ||
1237 | ret = Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); | |
1238 | if (ret != OMX_ErrorNone) { | |
1239 | goto EXIT; | |
1240 | } | |
1241 | ||
1242 | if (pDstErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { | |
1243 | ret = OMX_ErrorBadPortIndex; | |
1244 | goto EXIT; | |
1245 | } | |
1246 | ||
1247 | pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1248 | pSrcErrorCorrectionType = &pMpeg4Dec->errorCorrectionType[INPUT_PORT_INDEX]; | |
1249 | ||
1250 | pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; | |
1251 | pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; | |
1252 | pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; | |
1253 | pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; | |
1254 | pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; | |
1255 | } | |
1256 | break; | |
1257 | default: | |
1258 | ret = Exynos_OMX_VideoDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); | |
1259 | break; | |
1260 | } | |
1261 | EXIT: | |
1262 | FunctionOut(); | |
1263 | ||
1264 | return ret; | |
1265 | } | |
1266 | ||
1267 | OMX_ERRORTYPE Exynos_Mpeg4Dec_SetParameter( | |
1268 | OMX_IN OMX_HANDLETYPE hComponent, | |
1269 | OMX_IN OMX_INDEXTYPE nIndex, | |
1270 | OMX_IN OMX_PTR pComponentParameterStructure) | |
1271 | { | |
1272 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1273 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1274 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1275 | ||
1276 | FunctionIn(); | |
1277 | ||
1278 | if (hComponent == NULL || pComponentParameterStructure == NULL) { | |
1279 | ret = OMX_ErrorBadParameter; | |
1280 | goto EXIT; | |
1281 | } | |
1282 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1283 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1284 | if (ret != OMX_ErrorNone) { | |
1285 | goto EXIT; | |
1286 | } | |
1287 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1288 | ret = OMX_ErrorBadParameter; | |
1289 | goto EXIT; | |
1290 | } | |
1291 | ||
1292 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1293 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1294 | ret = OMX_ErrorInvalidState; | |
1295 | goto EXIT; | |
1296 | } | |
1297 | ||
1298 | switch (nIndex) { | |
1299 | case OMX_IndexParamVideoMpeg4: | |
1300 | { | |
1301 | OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL; | |
1302 | OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; | |
1303 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
1304 | ||
1305 | ret = Exynos_OMX_Check_SizeVersion(pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); | |
1306 | if (ret != OMX_ErrorNone) { | |
1307 | goto EXIT; | |
1308 | } | |
1309 | ||
1310 | if (pSrcMpeg4Param->nPortIndex >= ALL_PORT_NUM) { | |
1311 | ret = OMX_ErrorBadPortIndex; | |
1312 | goto EXIT; | |
1313 | } | |
1314 | ||
1315 | pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1316 | pDstMpeg4Param = &pMpeg4Dec->mpeg4Component[pSrcMpeg4Param->nPortIndex]; | |
1317 | ||
1318 | Exynos_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); | |
1319 | } | |
1320 | break; | |
1321 | case OMX_IndexParamVideoH263: | |
1322 | { | |
1323 | OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL; | |
1324 | OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; | |
1325 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
1326 | ||
1327 | ret = Exynos_OMX_Check_SizeVersion(pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); | |
1328 | if (ret != OMX_ErrorNone) { | |
1329 | goto EXIT; | |
1330 | } | |
1331 | ||
1332 | if (pSrcH263Param->nPortIndex >= ALL_PORT_NUM) { | |
1333 | ret = OMX_ErrorBadPortIndex; | |
1334 | goto EXIT; | |
1335 | } | |
1336 | ||
1337 | pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1338 | pDstH263Param = &pMpeg4Dec->h263Component[pSrcH263Param->nPortIndex]; | |
1339 | ||
1340 | Exynos_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); | |
1341 | } | |
1342 | break; | |
1343 | case OMX_IndexParamStandardComponentRole: | |
1344 | { | |
1345 | OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; | |
1346 | ||
1347 | ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); | |
1348 | if (ret != OMX_ErrorNone) { | |
1349 | goto EXIT; | |
1350 | } | |
1351 | ||
1352 | if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) { | |
1353 | ret = OMX_ErrorIncorrectStateOperation; | |
1354 | goto EXIT; | |
1355 | } | |
1356 | ||
1357 | if (!Exynos_OSAL_Strcmp((char*)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE)) { | |
1358 | pExynosComponent->pExynosPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; | |
1359 | } else if (!Exynos_OSAL_Strcmp((char*)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE)) { | |
1360 | pExynosComponent->pExynosPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; | |
1361 | } else { | |
1362 | ret = OMX_ErrorBadParameter; | |
1363 | goto EXIT; | |
1364 | } | |
1365 | } | |
1366 | break; | |
1367 | case OMX_IndexParamVideoProfileLevelCurrent: | |
1368 | { | |
1369 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; | |
1370 | OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL; | |
1371 | OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL; | |
1372 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
1373 | OMX_S32 codecType; | |
1374 | ||
1375 | ret = Exynos_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
1376 | if (ret != OMX_ErrorNone) | |
1377 | goto EXIT; | |
1378 | ||
1379 | if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1380 | ret = OMX_ErrorBadPortIndex; | |
1381 | goto EXIT; | |
1382 | } | |
1383 | ||
1384 | pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1385 | codecType = pMpeg4Dec->hMFCMpeg4Handle.codecType; | |
1386 | if (codecType == CODEC_TYPE_MPEG4) { | |
1387 | /* | |
1388 | * To do: Check validity of profile & level parameters | |
1389 | */ | |
1390 | ||
1391 | pDstMpeg4Param = &pMpeg4Dec->mpeg4Component[pSrcProfileLevel->nPortIndex]; | |
1392 | pDstMpeg4Param->eProfile = pSrcProfileLevel->eProfile; | |
1393 | pDstMpeg4Param->eLevel = pSrcProfileLevel->eLevel; | |
1394 | } else { | |
1395 | /* | |
1396 | * To do: Check validity of profile & level parameters | |
1397 | */ | |
1398 | ||
1399 | pDstH263Param = &pMpeg4Dec->h263Component[pSrcProfileLevel->nPortIndex]; | |
1400 | pDstH263Param->eProfile = pSrcProfileLevel->eProfile; | |
1401 | pDstH263Param->eLevel = pSrcProfileLevel->eLevel; | |
1402 | } | |
1403 | } | |
1404 | break; | |
1405 | case OMX_IndexParamVideoErrorCorrection: | |
1406 | { | |
1407 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; | |
1408 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; | |
1409 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
1410 | ||
1411 | ret = Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); | |
1412 | if (ret != OMX_ErrorNone) { | |
1413 | goto EXIT; | |
1414 | } | |
1415 | ||
1416 | if (pSrcErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { | |
1417 | ret = OMX_ErrorBadPortIndex; | |
1418 | goto EXIT; | |
1419 | } | |
1420 | ||
1421 | pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1422 | pDstErrorCorrectionType = &pMpeg4Dec->errorCorrectionType[INPUT_PORT_INDEX]; | |
1423 | ||
1424 | pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; | |
1425 | pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; | |
1426 | pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; | |
1427 | pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; | |
1428 | pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; | |
1429 | } | |
1430 | break; | |
1431 | default: | |
1432 | ret = Exynos_OMX_VideoDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure); | |
1433 | break; | |
1434 | } | |
1435 | EXIT: | |
1436 | FunctionOut(); | |
1437 | ||
1438 | return ret; | |
1439 | } | |
1440 | ||
1441 | OMX_ERRORTYPE Exynos_Mpeg4Dec_GetConfig( | |
1442 | OMX_IN OMX_HANDLETYPE hComponent, | |
1443 | OMX_IN OMX_INDEXTYPE nIndex, | |
1444 | OMX_IN OMX_PTR pComponentConfigStructure) | |
1445 | { | |
1446 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1447 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1448 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1449 | ||
1450 | FunctionIn(); | |
1451 | ||
1452 | if (hComponent == NULL || pComponentConfigStructure == NULL) { | |
1453 | ret = OMX_ErrorBadParameter; | |
1454 | goto EXIT; | |
1455 | } | |
1456 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1457 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1458 | if (ret != OMX_ErrorNone) { | |
1459 | goto EXIT; | |
1460 | } | |
1461 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1462 | ret = OMX_ErrorBadParameter; | |
1463 | goto EXIT; | |
1464 | } | |
1465 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1466 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1467 | ret = OMX_ErrorInvalidState; | |
1468 | goto EXIT; | |
1469 | } | |
1470 | ||
1471 | switch (nIndex) { | |
1472 | default: | |
1473 | ret = Exynos_OMX_VideoDecodeGetConfig(hComponent, nIndex, pComponentConfigStructure); | |
1474 | break; | |
1475 | } | |
1476 | ||
1477 | EXIT: | |
1478 | FunctionOut(); | |
1479 | ||
1480 | return ret; | |
1481 | } | |
1482 | ||
1483 | OMX_ERRORTYPE Exynos_Mpeg4Dec_SetConfig( | |
1484 | OMX_IN OMX_HANDLETYPE hComponent, | |
1485 | OMX_IN OMX_INDEXTYPE nIndex, | |
1486 | OMX_IN OMX_PTR pComponentConfigStructure) | |
1487 | { | |
1488 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1489 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1490 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1491 | ||
1492 | FunctionIn(); | |
1493 | ||
1494 | if (hComponent == NULL || pComponentConfigStructure == NULL) { | |
1495 | ret = OMX_ErrorBadParameter; | |
1496 | goto EXIT; | |
1497 | } | |
1498 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1499 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1500 | if (ret != OMX_ErrorNone) { | |
1501 | goto EXIT; | |
1502 | } | |
1503 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1504 | ret = OMX_ErrorBadParameter; | |
1505 | goto EXIT; | |
1506 | } | |
1507 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1508 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1509 | ret = OMX_ErrorInvalidState; | |
1510 | goto EXIT; | |
1511 | } | |
1512 | ||
1513 | switch (nIndex) { | |
1514 | default: | |
1515 | ret = Exynos_OMX_VideoDecodeSetConfig(hComponent, nIndex, pComponentConfigStructure); | |
1516 | break; | |
1517 | } | |
1518 | ||
1519 | EXIT: | |
1520 | FunctionOut(); | |
1521 | ||
1522 | return ret; | |
1523 | } | |
1524 | ||
1525 | OMX_ERRORTYPE Exynos_Mpeg4Dec_GetExtensionIndex( | |
1526 | OMX_IN OMX_HANDLETYPE hComponent, | |
1527 | OMX_IN OMX_STRING cParameterName, | |
1528 | OMX_OUT OMX_INDEXTYPE *pIndexType) | |
1529 | { | |
1530 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1531 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1532 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1533 | ||
1534 | FunctionIn(); | |
1535 | ||
1536 | if (hComponent == NULL) { | |
1537 | ret = OMX_ErrorBadParameter; | |
1538 | goto EXIT; | |
1539 | } | |
1540 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1541 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1542 | if (ret != OMX_ErrorNone) { | |
1543 | goto EXIT; | |
1544 | } | |
1545 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1546 | ret = OMX_ErrorBadParameter; | |
1547 | goto EXIT; | |
1548 | } | |
1549 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1550 | if ((cParameterName == NULL) || (pIndexType == NULL)) { | |
1551 | ret = OMX_ErrorBadParameter; | |
1552 | goto EXIT; | |
1553 | } | |
1554 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1555 | ret = OMX_ErrorInvalidState; | |
1556 | goto EXIT; | |
1557 | } | |
1558 | ||
1559 | if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) { | |
1560 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1561 | *pIndexType = OMX_IndexVendorThumbnailMode; | |
1562 | ret = OMX_ErrorNone; | |
1563 | } else { | |
1564 | ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType); | |
1565 | } | |
1566 | ||
1567 | EXIT: | |
1568 | FunctionOut(); | |
1569 | ||
1570 | return ret; | |
1571 | } | |
1572 | ||
1573 | OMX_ERRORTYPE Exynos_Mpeg4Dec_ComponentRoleEnum( | |
1574 | OMX_IN OMX_HANDLETYPE hComponent, | |
1575 | OMX_OUT OMX_U8 *cRole, | |
1576 | OMX_IN OMX_U32 nIndex) | |
1577 | { | |
1578 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1579 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1580 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1581 | OMX_S32 codecType; | |
1582 | ||
1583 | FunctionIn(); | |
1584 | ||
1585 | if ((hComponent == NULL) || (cRole == NULL)) { | |
1586 | ret = OMX_ErrorBadParameter; | |
1587 | goto EXIT; | |
1588 | } | |
1589 | if (nIndex != (MAX_COMPONENT_ROLE_NUM - 1)) { | |
1590 | ret = OMX_ErrorNoMore; | |
1591 | goto EXIT; | |
1592 | } | |
1593 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1594 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1595 | if (ret != OMX_ErrorNone) { | |
1596 | goto EXIT; | |
1597 | } | |
1598 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1599 | ret = OMX_ErrorBadParameter; | |
1600 | goto EXIT; | |
1601 | } | |
1602 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1603 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1604 | ret = OMX_ErrorInvalidState; | |
1605 | goto EXIT; | |
1606 | } | |
1607 | ||
1608 | codecType = ((EXYNOS_MPEG4DEC_HANDLE *)(((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType; | |
1609 | if (codecType == CODEC_TYPE_MPEG4) | |
1610 | Exynos_OSAL_Strcpy((char *)cRole, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE); | |
1611 | else | |
1612 | Exynos_OSAL_Strcpy((char *)cRole, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE); | |
1613 | ||
1614 | EXIT: | |
1615 | FunctionOut(); | |
1616 | ||
1617 | return ret; | |
1618 | } | |
1619 | ||
1620 | /* MFC Init */ | |
1621 | OMX_ERRORTYPE Exynos_Mpeg4Dec_Init(OMX_COMPONENTTYPE *pOMXComponent) | |
1622 | { | |
1623 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1624 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1625 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1626 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1627 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1628 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)pVideoDec->hCodecHandle; | |
1629 | OMX_PTR hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
1630 | ||
1631 | ExynosVideoDecOps *pDecOps = NULL; | |
1632 | ExynosVideoDecBufferOps *pInbufOps = NULL; | |
1633 | ExynosVideoDecBufferOps *pOutbufOps = NULL; | |
1634 | ||
1635 | CSC_METHOD csc_method = CSC_METHOD_SW; | |
1636 | int i, plane; | |
1637 | ||
1638 | FunctionIn(); | |
1639 | ||
1640 | pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFCSrc = OMX_FALSE; | |
1641 | pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFCDst = OMX_FALSE; | |
1642 | pExynosComponent->bUseFlagEOF = OMX_TRUE; | |
1643 | pExynosComponent->bSaveFlagEOS = OMX_FALSE; | |
e100a12d | 1644 | pExynosComponent->bBehaviorEOS = OMX_FALSE; |
c6f4bc34 | 1645 | |
e4e150b8 | 1646 | /* Mpeg4 Codec Open */ |
c6f4bc34 YK |
1647 | ret = Mpeg4CodecOpen(pMpeg4Dec); |
1648 | if (ret != OMX_ErrorNone) { | |
1649 | goto EXIT; | |
1650 | } | |
1651 | ||
1652 | pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; | |
1653 | pInbufOps = pMpeg4Dec->hMFCMpeg4Handle.pInbufOps; | |
1654 | pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps; | |
1655 | ||
24ec2c82 | 1656 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
0641ae29 | 1657 | OMX_U32 nPlaneSize[MFC_INPUT_BUFFER_PLANE] = {DEFAULT_MFC_INPUT_BUFFER_SIZE}; |
c6f4bc34 YK |
1658 | Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID); |
1659 | Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); | |
0641ae29 TK |
1660 | ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize); |
1661 | if (ret != OMX_ErrorNone) | |
1662 | goto EXIT; | |
c6f4bc34 | 1663 | |
0641ae29 | 1664 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) |
c6f4bc34 | 1665 | Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]); |
24ec2c82 | 1666 | } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
1667 | /*************/ |
1668 | /* TBD */ | |
1669 | /*************/ | |
1670 | /* Does not require any actions. */ | |
1671 | } | |
1672 | ||
24ec2c82 | 1673 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
1674 | Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort->codecSemID); |
1675 | Exynos_OSAL_QueueCreate(&pExynosOutputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); | |
24ec2c82 | 1676 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
1677 | /*************/ |
1678 | /* TBD */ | |
1679 | /*************/ | |
1680 | /* Does not require any actions. */ | |
1681 | } | |
1682 | ||
1683 | pMpeg4Dec->bSourceStart = OMX_FALSE; | |
1684 | Exynos_OSAL_SignalCreate(&pMpeg4Dec->hSourceStartEvent); | |
1685 | pMpeg4Dec->bDestinationStart = OMX_FALSE; | |
1686 | Exynos_OSAL_SignalCreate(&pMpeg4Dec->hDestinationStartEvent); | |
1687 | ||
1688 | Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); | |
1689 | Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); | |
1690 | pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp = 0; | |
1691 | pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp = 0; | |
1692 | ||
1693 | pExynosComponent->getAllDelayBuffer = OMX_FALSE; | |
1694 | ||
a80c3bc5 TK |
1695 | #ifdef USE_CSC_HW |
1696 | csc_method = CSC_METHOD_HW; | |
c6f4bc34 YK |
1697 | #endif |
1698 | pVideoDec->csc_handle = csc_init(csc_method); | |
1699 | if (pVideoDec->csc_handle == NULL) { | |
1700 | ret = OMX_ErrorInsufficientResources; | |
1701 | goto EXIT; | |
1702 | } | |
1703 | pVideoDec->csc_set_format = OMX_FALSE; | |
1704 | ||
1705 | EXIT: | |
1706 | FunctionOut(); | |
1707 | ||
1708 | return ret; | |
1709 | } | |
1710 | ||
1711 | /* MFC Terminate */ | |
1712 | OMX_ERRORTYPE Exynos_Mpeg4Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent) | |
1713 | { | |
1714 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1715 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1716 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1717 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1718 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1719 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1720 | OMX_PTR hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
1721 | ||
1722 | ExynosVideoDecOps *pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; | |
1723 | ExynosVideoDecBufferOps *pInbufOps = pMpeg4Dec->hMFCMpeg4Handle.pInbufOps; | |
1724 | ExynosVideoDecBufferOps *pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps; | |
1725 | ||
1726 | int i, plane; | |
1727 | ||
1728 | FunctionIn(); | |
1729 | ||
1730 | if (pVideoDec->csc_handle != NULL) { | |
1731 | csc_deinit(pVideoDec->csc_handle); | |
1732 | pVideoDec->csc_handle = NULL; | |
1733 | } | |
1734 | ||
1735 | Exynos_OSAL_SignalTerminate(pMpeg4Dec->hDestinationStartEvent); | |
1736 | pMpeg4Dec->hDestinationStartEvent = NULL; | |
1737 | pMpeg4Dec->bDestinationStart = OMX_FALSE; | |
1738 | Exynos_OSAL_SignalTerminate(pMpeg4Dec->hSourceStartEvent); | |
1739 | pMpeg4Dec->hSourceStartEvent = NULL; | |
1740 | pMpeg4Dec->bSourceStart = OMX_FALSE; | |
1741 | ||
24ec2c82 | 1742 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
0641ae29 | 1743 | Exynos_Free_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX); |
c6f4bc34 YK |
1744 | Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ); |
1745 | Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID); | |
24ec2c82 | 1746 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
1747 | /*************/ |
1748 | /* TBD */ | |
1749 | /*************/ | |
1750 | /* Does not require any actions. */ | |
1751 | } | |
1752 | ||
24ec2c82 | 1753 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
0641ae29 | 1754 | Exynos_Free_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX); |
c6f4bc34 YK |
1755 | Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ); |
1756 | Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID); | |
24ec2c82 | 1757 | } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
1758 | /*************/ |
1759 | /* TBD */ | |
1760 | /*************/ | |
1761 | /* Does not require any actions. */ | |
1762 | } | |
1763 | Mpeg4CodecClose(pMpeg4Dec); | |
1764 | ||
e100a12d SK |
1765 | Exynos_ResetAllPortConfig(pOMXComponent); |
1766 | ||
c6f4bc34 YK |
1767 | EXIT: |
1768 | FunctionOut(); | |
1769 | ||
1770 | return ret; | |
1771 | } | |
1772 | ||
1773 | OMX_ERRORTYPE Exynos_Mpeg4Dec_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) | |
1774 | { | |
1775 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1776 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1777 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1778 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1779 | void *hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
1780 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1781 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1782 | OMX_U32 oneFrameSize = pSrcInputData->dataLen; | |
b907369f | 1783 | OMX_BOOL bInStartCode = OMX_FALSE; |
c6f4bc34 YK |
1784 | ExynosVideoDecOps *pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; |
1785 | ExynosVideoDecBufferOps *pInbufOps = pMpeg4Dec->hMFCMpeg4Handle.pInbufOps; | |
1786 | ExynosVideoDecBufferOps *pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps; | |
1787 | ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; | |
1788 | int i; | |
1789 | ||
1790 | FunctionIn(); | |
1791 | ||
1792 | if (pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFCSrc == OMX_FALSE) { | |
1793 | ret = Mpeg4CodecSrcSetup(pOMXComponent, pSrcInputData); | |
1794 | goto EXIT; | |
1795 | } | |
1796 | if (pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFCDst == OMX_FALSE) { | |
1797 | ret = Mpeg4CodecDstSetup(pOMXComponent); | |
1798 | } | |
1799 | ||
b907369f | 1800 | if (((bInStartCode = Check_Stream_StartCode(pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, oneFrameSize, pMpeg4Dec->hMFCMpeg4Handle.codecType)) == OMX_TRUE) || |
c6f4bc34 YK |
1801 | ((pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { |
1802 | pExynosComponent->timeStamp[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pSrcInputData->timeStamp; | |
1803 | pExynosComponent->nFlags[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pSrcInputData->nFlags; | |
1804 | 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); | |
1805 | pDecOps->Set_FrameTag(hMFCHandle, pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp); | |
1806 | pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp++; | |
1807 | pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp %= MAX_TIMESTAMP; | |
1808 | ||
1809 | /* queue work for input buffer */ | |
1810 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "oneFrameSize: %d, bufferHeader: 0x%x, dataBuffer: 0x%x", oneFrameSize, pSrcInputData->bufferHeader, pSrcInputData->buffer.singlePlaneBuffer.dataBuffer); | |
1811 | codecReturn = pInbufOps->Enqueue(hMFCHandle, (unsigned char **)&pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, | |
1812 | (unsigned int *)&oneFrameSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader); | |
1813 | if (codecReturn != VIDEO_ERROR_NONE) { | |
1814 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1815 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__); | |
1816 | goto EXIT; | |
1817 | } | |
1818 | Mpeg4CodecStart(pOMXComponent, INPUT_PORT_INDEX); | |
1819 | if (pMpeg4Dec->bSourceStart == OMX_FALSE) { | |
1820 | pMpeg4Dec->bSourceStart = OMX_TRUE; | |
1821 | Exynos_OSAL_SignalSet(pMpeg4Dec->hSourceStartEvent); | |
1822 | Exynos_OSAL_SleepMillisec(0); | |
1823 | } | |
1824 | if (pMpeg4Dec->bDestinationStart == OMX_FALSE) { | |
1825 | pMpeg4Dec->bDestinationStart = OMX_TRUE; | |
1826 | Exynos_OSAL_SignalSet(pMpeg4Dec->hDestinationStartEvent); | |
1827 | Exynos_OSAL_SleepMillisec(0); | |
1828 | } | |
b907369f TK |
1829 | } else if (bInStartCode == OMX_FALSE) { |
1830 | ret = OMX_ErrorCorruptedFrame; | |
1831 | goto EXIT; | |
c6f4bc34 YK |
1832 | } |
1833 | ||
1834 | ret = OMX_ErrorNone; | |
1835 | ||
1836 | EXIT: | |
1837 | FunctionOut(); | |
1838 | ||
1839 | return ret; | |
1840 | } | |
1841 | ||
1842 | OMX_ERRORTYPE Exynos_Mpeg4Dec_SrcOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData) | |
1843 | { | |
1844 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1845 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1846 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1847 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1848 | void *hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
1849 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1850 | ExynosVideoDecOps *pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; | |
1851 | ExynosVideoDecBufferOps *pInbufOps = pMpeg4Dec->hMFCMpeg4Handle.pInbufOps; | |
1852 | ExynosVideoBuffer *pVideoBuffer; | |
1853 | ||
1854 | FunctionIn(); | |
1855 | ||
1856 | pVideoBuffer = pInbufOps->Dequeue(hMFCHandle); | |
1857 | ||
1858 | pSrcOutputData->dataLen = 0; | |
1859 | pSrcOutputData->usedDataLen = 0; | |
1860 | pSrcOutputData->remainDataLen = 0; | |
1861 | pSrcOutputData->nFlags = 0; | |
1862 | pSrcOutputData->timeStamp = 0; | |
1863 | ||
1864 | if (pVideoBuffer == NULL) { | |
1865 | pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = NULL; | |
1866 | pSrcOutputData->allocSize = 0; | |
1867 | pSrcOutputData->pPrivate = NULL; | |
1868 | pSrcOutputData->bufferHeader = NULL; | |
1869 | } else { | |
1870 | pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = pVideoBuffer->planes[0].addr; | |
1871 | pSrcOutputData->buffer.singlePlaneBuffer.fd = pVideoBuffer->planes[0].fd; | |
1872 | pSrcOutputData->allocSize = pVideoBuffer->planes[0].allocSize; | |
1873 | ||
24ec2c82 | 1874 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
9c39c5ff TK |
1875 | int i; |
1876 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { | |
1877 | if (pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer == | |
1878 | pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0]) { | |
1879 | pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0; | |
1880 | pSrcOutputData->pPrivate = pVideoDec->pMFCDecInputBuffer[i]; | |
1881 | break; | |
c6f4bc34 | 1882 | } |
c6f4bc34 | 1883 | } |
9c39c5ff TK |
1884 | |
1885 | if (i >= MFC_INPUT_BUFFER_NUM_MAX) { | |
1886 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer"); | |
1887 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1888 | goto EXIT; | |
1889 | } | |
c6f4bc34 YK |
1890 | } |
1891 | ||
1892 | /* For Share Buffer */ | |
1893 | pSrcOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE*)pVideoBuffer->pPrivate; | |
1894 | } | |
1895 | ||
1896 | ret = OMX_ErrorNone; | |
1897 | ||
1898 | EXIT: | |
1899 | FunctionOut(); | |
1900 | ||
1901 | return ret; | |
1902 | } | |
1903 | ||
1904 | OMX_ERRORTYPE Exynos_Mpeg4Dec_DstIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData) | |
1905 | { | |
1906 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1907 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1908 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1909 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1910 | void *hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
1911 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1912 | ExynosVideoDecOps *pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; | |
1913 | ExynosVideoDecBufferOps *pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps; | |
1914 | OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0,}; | |
1915 | ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; | |
1916 | ||
1917 | FunctionIn(); | |
1918 | ||
1919 | if (pDstInputData->buffer.multiPlaneBuffer.dataBuffer[0] == NULL) { | |
1920 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to find input buffer"); | |
1921 | ret = OMX_ErrorBadParameter; | |
1922 | goto EXIT; | |
1923 | } | |
1924 | ||
1925 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x", __FUNCTION__, __LINE__, | |
1926 | pDstInputData->buffer.multiPlaneBuffer.dataBuffer[0], | |
1927 | pDstInputData->buffer.multiPlaneBuffer.dataBuffer[1]); | |
1928 | ||
1929 | codecReturn = pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pDstInputData->buffer.multiPlaneBuffer.dataBuffer, | |
1930 | (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, pDstInputData->bufferHeader); | |
1931 | ||
1932 | if (codecReturn != VIDEO_ERROR_NONE) { | |
1933 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__); | |
1934 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1935 | goto EXIT; | |
1936 | } | |
1937 | Mpeg4CodecStart(pOMXComponent, OUTPUT_PORT_INDEX); | |
1938 | ||
1939 | ret = OMX_ErrorNone; | |
1940 | ||
1941 | EXIT: | |
1942 | FunctionOut(); | |
1943 | ||
1944 | return ret; | |
1945 | } | |
1946 | ||
1947 | OMX_ERRORTYPE Exynos_Mpeg4Dec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData) | |
1948 | { | |
1949 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1950 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1951 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1952 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1953 | void *hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; | |
1954 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1955 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1956 | ExynosVideoDecOps *pDecOps = pMpeg4Dec->hMFCMpeg4Handle.pDecOps; | |
1957 | ExynosVideoDecBufferOps *pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps; | |
ca86e5fa | 1958 | ExynosVideoBuffer *pVideoBuffer = NULL; |
c6f4bc34 YK |
1959 | ExynosVideoFrameStatusType displayStatus = VIDEO_FRAME_STATUS_UNKNOWN; |
1960 | ExynosVideoGeometry *bufferGeometry; | |
1961 | DECODE_CODEC_EXTRA_BUFFERINFO *pBufferInfo = NULL; | |
1962 | OMX_S32 indexTimestamp = 0; | |
1963 | int plane; | |
1964 | ||
1965 | FunctionIn(); | |
1966 | ||
1967 | if (pMpeg4Dec->bDestinationStart == OMX_FALSE) { | |
1968 | ret = OMX_ErrorNone; | |
1969 | goto EXIT; | |
1970 | } | |
1971 | ||
1972 | while (1) { | |
1973 | if ((pVideoBuffer = pOutbufOps->Dequeue(hMFCHandle)) == NULL) { | |
1974 | ret = OMX_ErrorNone; | |
1975 | goto EXIT; | |
1976 | } | |
1977 | displayStatus = pVideoBuffer->displayStatus; | |
1978 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "displayStatus: 0x%x", displayStatus); | |
1979 | ||
1980 | if ((displayStatus == VIDEO_FRAME_STATUS_DISPLAY_DECODING) || | |
1981 | (displayStatus == VIDEO_FRAME_STATUS_DISPLAY_ONLY) || | |
1982 | (displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) || | |
405399e5 | 1983 | (displayStatus == VIDEO_FRAME_STATUS_DECODING_FINISHED) || |
c6f4bc34 | 1984 | (CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { |
ca86e5fa TK |
1985 | ret = OMX_ErrorNone; |
1986 | break; | |
c6f4bc34 YK |
1987 | } |
1988 | } | |
1989 | ||
c6f4bc34 YK |
1990 | pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp++; |
1991 | pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp %= MAX_TIMESTAMP; | |
1992 | ||
1993 | pDstOutputData->allocSize = pDstOutputData->dataLen = 0; | |
1994 | for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) { | |
1995 | pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[plane] = pVideoBuffer->planes[plane].addr; | |
1996 | pDstOutputData->buffer.multiPlaneBuffer.fd[plane] = pVideoBuffer->planes[plane].fd; | |
1997 | pDstOutputData->allocSize += pVideoBuffer->planes[plane].allocSize; | |
1998 | pDstOutputData->dataLen += pVideoBuffer->planes[plane].dataSize; | |
1999 | } | |
2000 | pDstOutputData->usedDataLen = 0; | |
2001 | pDstOutputData->pPrivate = pVideoBuffer; | |
e90eb9e8 TK |
2002 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
2003 | int i = 0; | |
2004 | pDstOutputData->pPrivate = NULL; | |
2005 | for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { | |
2006 | if (pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[0] == | |
2007 | pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]) { | |
2008 | pDstOutputData->pPrivate = pVideoDec->pMFCDecOutputBuffer[i]; | |
2009 | break; | |
2010 | } | |
2011 | } | |
2012 | ||
2013 | if (pDstOutputData->pPrivate == NULL) { | |
2014 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer"); | |
2015 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
2016 | goto EXIT; | |
2017 | } | |
2018 | } | |
2019 | ||
c6f4bc34 YK |
2020 | /* For Share Buffer */ |
2021 | pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate; | |
2022 | ||
2023 | pBufferInfo = (DECODE_CODEC_EXTRA_BUFFERINFO *)pDstOutputData->extInfo; | |
2024 | bufferGeometry = &pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf; | |
2025 | pBufferInfo->imageWidth = bufferGeometry->nFrameWidth; | |
2026 | pBufferInfo->imageHeight = bufferGeometry->nFrameHeight; | |
2027 | switch (bufferGeometry->eColorFormat) { | |
2028 | case VIDEO_COLORFORMAT_NV12: | |
2029 | pBufferInfo->ColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; | |
2030 | break; | |
2031 | case VIDEO_COLORFORMAT_NV12_TILED: | |
2032 | default: | |
2033 | pBufferInfo->ColorFormat = OMX_SEC_COLOR_FormatNV12Tiled; | |
2034 | break; | |
2035 | } | |
2036 | ||
2037 | indexTimestamp = pDecOps->Get_FrameTag(hMFCHandle); | |
2038 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "out indexTimestamp: %d", indexTimestamp); | |
2039 | if ((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)) { | |
2040 | if ((pExynosComponent->checkTimeStamp.needSetStartTimeStamp != OMX_TRUE) && | |
2041 | (pExynosComponent->checkTimeStamp.needCheckStartTimeStamp != OMX_TRUE)) { | |
f53da333 SK |
2042 | if (indexTimestamp == INDEX_AFTER_EOS) { |
2043 | pDstOutputData->timeStamp = 0x00; | |
2044 | pDstOutputData->nFlags = 0x00; | |
2045 | } else { | |
2046 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp]; | |
2047 | pDstOutputData->nFlags = pExynosComponent->nFlags[pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp]; | |
2048 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "missing out indexTimestamp: %d", indexTimestamp); | |
2049 | } | |
c6f4bc34 YK |
2050 | } else { |
2051 | pDstOutputData->timeStamp = 0x00; | |
2052 | pDstOutputData->nFlags = 0x00; | |
2053 | } | |
2054 | } else { | |
2055 | /* For timestamp correction. if mfc support frametype detect */ | |
2056 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "disp_pic_frame_type: %d", pVideoBuffer->frameType); | |
c70316c7 JY |
2057 | |
2058 | /* NEED TIMESTAMP REORDER */ | |
2059 | if (pVideoDec->bDTSMode == OMX_TRUE) { | |
2060 | if (pVideoBuffer->frameType == VIDEO_FRAME_I) | |
2061 | pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp = indexTimestamp; | |
2062 | else | |
2063 | indexTimestamp = pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp; | |
c6f4bc34 | 2064 | } |
c70316c7 | 2065 | |
c6f4bc34 YK |
2066 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp]; |
2067 | pDstOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp]; | |
c70316c7 | 2068 | |
c6f4bc34 YK |
2069 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "timestamp %lld us (%.2f secs), indexTimestamp: %d, nFlags: 0x%x", pDstOutputData->timeStamp, pDstOutputData->timeStamp / 1E6, indexTimestamp, pDstOutputData->nFlags); |
2070 | } | |
2071 | ||
2072 | if ((displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) || | |
405399e5 | 2073 | (displayStatus == VIDEO_FRAME_STATUS_DECODING_FINISHED) || |
c6f4bc34 YK |
2074 | ((pDstOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { |
2075 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "displayStatus:%d, nFlags0x%x", displayStatus, pDstOutputData->nFlags); | |
2076 | pDstOutputData->remainDataLen = 0; | |
e100a12d SK |
2077 | |
2078 | if (((pDstOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) && | |
2079 | (pExynosComponent->bBehaviorEOS == OMX_TRUE)) { | |
2080 | pDstOutputData->remainDataLen = bufferGeometry->nFrameWidth * bufferGeometry->nFrameHeight * 3 / 2; | |
2081 | pExynosComponent->bBehaviorEOS = OMX_FALSE; | |
2082 | } | |
c6f4bc34 YK |
2083 | } else { |
2084 | pDstOutputData->remainDataLen = bufferGeometry->nFrameWidth * bufferGeometry->nFrameHeight * 3 / 2; | |
2085 | } | |
2086 | ||
2087 | ret = OMX_ErrorNone; | |
2088 | ||
2089 | EXIT: | |
2090 | FunctionOut(); | |
2091 | ||
2092 | return ret; | |
2093 | } | |
2094 | ||
2095 | OMX_ERRORTYPE Exynos_Mpeg4Dec_srcInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) | |
2096 | { | |
2097 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2098 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2099 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2100 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2101 | ||
2102 | FunctionIn(); | |
2103 | ||
2104 | if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) { | |
2105 | ret = OMX_ErrorNone; | |
2106 | goto EXIT; | |
2107 | } | |
2108 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) { | |
2109 | ret = OMX_ErrorNone; | |
2110 | goto EXIT; | |
2111 | } | |
2112 | ||
2113 | ret = Exynos_Mpeg4Dec_SrcIn(pOMXComponent, pSrcInputData); | |
b907369f TK |
2114 | if ((ret != OMX_ErrorNone) && |
2115 | (ret != OMX_ErrorInputDataDecodeYet) && | |
2116 | (ret != OMX_ErrorCorruptedFrame)) { | |
c6f4bc34 YK |
2117 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, |
2118 | pExynosComponent->callbackData, | |
2119 | OMX_EventError, ret, 0, NULL); | |
2120 | } | |
2121 | ||
2122 | EXIT: | |
2123 | FunctionOut(); | |
2124 | ||
2125 | return ret; | |
2126 | } | |
2127 | ||
2128 | OMX_ERRORTYPE Exynos_Mpeg4Dec_srcOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData) | |
2129 | { | |
2130 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2131 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2132 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2133 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2134 | ||
2135 | FunctionIn(); | |
2136 | ||
2137 | if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) { | |
2138 | ret = OMX_ErrorNone; | |
2139 | goto EXIT; | |
2140 | } | |
2141 | ||
24ec2c82 | 2142 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
2143 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) { |
2144 | ret = OMX_ErrorNone; | |
2145 | goto EXIT; | |
2146 | } | |
2147 | } | |
2148 | if ((pMpeg4Dec->bSourceStart == OMX_FALSE) && | |
2149 | (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort))) { | |
2150 | Exynos_OSAL_SignalWait(pMpeg4Dec->hSourceStartEvent, DEF_MAX_WAIT_TIME); | |
2151 | Exynos_OSAL_SignalReset(pMpeg4Dec->hSourceStartEvent); | |
2152 | } | |
2153 | ||
2154 | ret = Exynos_Mpeg4Dec_SrcOut(pOMXComponent, pSrcOutputData); | |
2155 | if ((ret != OMX_ErrorNone) && | |
2156 | (pExynosComponent->currentState == OMX_StateExecuting)) { | |
2157 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2158 | pExynosComponent->callbackData, | |
2159 | OMX_EventError, ret, 0, NULL); | |
2160 | } | |
2161 | ||
2162 | EXIT: | |
2163 | FunctionOut(); | |
2164 | ||
2165 | return ret; | |
2166 | } | |
2167 | ||
2168 | OMX_ERRORTYPE Exynos_Mpeg4Dec_dstInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData) | |
2169 | { | |
2170 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2171 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2172 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2173 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2174 | ||
2175 | FunctionIn(); | |
2176 | ||
2177 | if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) { | |
2178 | ret = OMX_ErrorNone; | |
2179 | goto EXIT; | |
2180 | } | |
2181 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) { | |
2182 | ret = OMX_ErrorNone; | |
2183 | goto EXIT; | |
2184 | } | |
24ec2c82 | 2185 | if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
2186 | if ((pMpeg4Dec->bDestinationStart == OMX_FALSE) && |
2187 | (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { | |
2188 | Exynos_OSAL_SignalWait(pMpeg4Dec->hDestinationStartEvent, DEF_MAX_WAIT_TIME); | |
2189 | Exynos_OSAL_SignalReset(pMpeg4Dec->hDestinationStartEvent); | |
2190 | } | |
2191 | } | |
2192 | if (pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFCDst == OMX_TRUE) { | |
2193 | ret = Exynos_Mpeg4Dec_DstIn(pOMXComponent, pDstInputData); | |
2194 | if (ret != OMX_ErrorNone) { | |
2195 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2196 | pExynosComponent->callbackData, | |
2197 | OMX_EventError, ret, 0, NULL); | |
2198 | } | |
2199 | } | |
2200 | ||
2201 | EXIT: | |
2202 | FunctionOut(); | |
2203 | ||
2204 | return ret; | |
2205 | } | |
2206 | ||
2207 | OMX_ERRORTYPE Exynos_Mpeg4Dec_dstOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData) | |
2208 | { | |
2209 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2210 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2211 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2212 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2213 | ||
2214 | FunctionIn(); | |
2215 | ||
2216 | if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) { | |
2217 | ret = OMX_ErrorNone; | |
2218 | goto EXIT; | |
2219 | } | |
2220 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) { | |
2221 | ret = OMX_ErrorNone; | |
2222 | goto EXIT; | |
2223 | } | |
2224 | ||
24ec2c82 | 2225 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
2226 | if ((pMpeg4Dec->bDestinationStart == OMX_FALSE) && |
2227 | (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { | |
2228 | Exynos_OSAL_SignalWait(pMpeg4Dec->hDestinationStartEvent, DEF_MAX_WAIT_TIME); | |
2229 | Exynos_OSAL_SignalReset(pMpeg4Dec->hDestinationStartEvent); | |
2230 | } | |
2231 | } | |
2232 | ret = Exynos_Mpeg4Dec_DstOut(pOMXComponent, pDstOutputData); | |
2233 | if ((ret != OMX_ErrorNone) && | |
2234 | (pExynosComponent->currentState == OMX_StateExecuting)) { | |
2235 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2236 | pExynosComponent->callbackData, | |
2237 | OMX_EventError, ret, 0, NULL); | |
2238 | } | |
2239 | ||
2240 | EXIT: | |
2241 | FunctionOut(); | |
2242 | ||
2243 | return ret; | |
2244 | } | |
2245 | ||
2246 | OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) | |
2247 | { | |
2248 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2249 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
2250 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
2251 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
2252 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL; | |
2253 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
2254 | int i = 0; | |
2255 | OMX_S32 codecType = -1; | |
2256 | ||
2257 | FunctionIn(); | |
2258 | ||
2259 | if ((hComponent == NULL) || (componentName == NULL)) { | |
2260 | ret = OMX_ErrorBadParameter; | |
2261 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); | |
2262 | goto EXIT; | |
2263 | } | |
2264 | if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_MPEG4_DEC, componentName) == 0) { | |
2265 | codecType = CODEC_TYPE_MPEG4; | |
2266 | } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H263_DEC, componentName) == 0) { | |
2267 | codecType = CODEC_TYPE_H263; | |
2268 | } else { | |
2269 | ret = OMX_ErrorBadParameter; | |
2270 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__); | |
2271 | goto EXIT; | |
2272 | } | |
2273 | ||
2274 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
2275 | ret = Exynos_OMX_VideoDecodeComponentInit(pOMXComponent); | |
2276 | if (ret != OMX_ErrorNone) { | |
2277 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); | |
2278 | goto EXIT; | |
2279 | } | |
2280 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2281 | pExynosComponent->codecType = HW_VIDEO_DEC_CODEC; | |
2282 | ||
2283 | pExynosComponent->componentName = (OMX_STRING)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); | |
2284 | if (pExynosComponent->componentName == NULL) { | |
2285 | Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2286 | ret = OMX_ErrorInsufficientResources; | |
2287 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); | |
2288 | goto EXIT; | |
2289 | } | |
2290 | Exynos_OSAL_Memset(pExynosComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); | |
2291 | ||
2292 | pMpeg4Dec = Exynos_OSAL_Malloc(sizeof(EXYNOS_MPEG4DEC_HANDLE)); | |
2293 | if (pMpeg4Dec == NULL) { | |
2294 | Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2295 | ret = OMX_ErrorInsufficientResources; | |
2296 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); | |
2297 | goto EXIT; | |
2298 | } | |
2299 | Exynos_OSAL_Memset(pMpeg4Dec, 0, sizeof(EXYNOS_MPEG4DEC_HANDLE)); | |
2300 | pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2301 | pVideoDec->hCodecHandle = (OMX_HANDLETYPE)pMpeg4Dec; | |
2302 | pMpeg4Dec->hMFCMpeg4Handle.codecType = codecType; | |
2303 | ||
2304 | if (codecType == CODEC_TYPE_MPEG4) | |
2305 | Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_MPEG4_DEC); | |
2306 | else | |
2307 | Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_H263_DEC); | |
2308 | ||
2309 | /* Set componentVersion */ | |
2310 | pExynosComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; | |
2311 | pExynosComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; | |
2312 | pExynosComponent->componentVersion.s.nRevision = REVISION_NUMBER; | |
2313 | pExynosComponent->componentVersion.s.nStep = STEP_NUMBER; | |
2314 | /* Set specVersion */ | |
2315 | pExynosComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; | |
2316 | pExynosComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; | |
2317 | pExynosComponent->specVersion.s.nRevision = REVISION_NUMBER; | |
2318 | pExynosComponent->specVersion.s.nStep = STEP_NUMBER; | |
2319 | ||
2320 | /* Input port */ | |
2321 | pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2322 | pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; | |
2323 | pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; | |
2324 | pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ | |
2325 | pExynosPort->portDefinition.format.video.nSliceHeight = 0; | |
2326 | pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; | |
2327 | if (codecType == CODEC_TYPE_MPEG4) { | |
2328 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; | |
2329 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2330 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "video/mpeg4"); | |
2331 | } else { | |
2332 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; | |
2333 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2334 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "video/h263"); | |
2335 | } | |
2336 | pExynosPort->portDefinition.format.video.pNativeRender = 0; | |
2337 | pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; | |
2338 | pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; | |
2339 | pExynosPort->portDefinition.bEnabled = OMX_TRUE; | |
2340 | pExynosPort->bufferProcessType = BUFFER_SHARE; | |
2341 | pExynosPort->portWayType = WAY2_PORT; | |
2342 | ||
2343 | /* Output port */ | |
2344 | pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2345 | pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; | |
2346 | pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; | |
2347 | pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ | |
2348 | pExynosPort->portDefinition.format.video.nSliceHeight = 0; | |
2349 | pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; | |
2350 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; | |
2351 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2352 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video"); | |
2353 | pExynosPort->portDefinition.format.video.pNativeRender = 0; | |
2354 | pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; | |
2355 | pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar; | |
2356 | pExynosPort->portDefinition.bEnabled = OMX_TRUE; | |
2357 | pExynosPort->bufferProcessType = BUFFER_COPY | BUFFER_ANBSHARE; | |
2358 | pExynosPort->portWayType = WAY2_PORT; | |
2359 | ||
2360 | if (codecType == CODEC_TYPE_MPEG4) { | |
2361 | for(i = 0; i < ALL_PORT_NUM; i++) { | |
2362 | INIT_SET_SIZE_VERSION(&pMpeg4Dec->mpeg4Component[i], OMX_VIDEO_PARAM_MPEG4TYPE); | |
2363 | pMpeg4Dec->mpeg4Component[i].nPortIndex = i; | |
2364 | pMpeg4Dec->mpeg4Component[i].eProfile = OMX_VIDEO_MPEG4ProfileSimple; | |
2365 | pMpeg4Dec->mpeg4Component[i].eLevel = OMX_VIDEO_MPEG4Level3; | |
2366 | } | |
2367 | } else { | |
2368 | for(i = 0; i < ALL_PORT_NUM; i++) { | |
2369 | INIT_SET_SIZE_VERSION(&pMpeg4Dec->h263Component[i], OMX_VIDEO_PARAM_H263TYPE); | |
2370 | pMpeg4Dec->h263Component[i].nPortIndex = i; | |
2371 | pMpeg4Dec->h263Component[i].eProfile = OMX_VIDEO_H263ProfileBaseline | OMX_VIDEO_H263ProfileISWV2; | |
2372 | pMpeg4Dec->h263Component[i].eLevel = OMX_VIDEO_H263Level45; | |
2373 | } | |
2374 | } | |
2375 | ||
2376 | pOMXComponent->GetParameter = &Exynos_Mpeg4Dec_GetParameter; | |
2377 | pOMXComponent->SetParameter = &Exynos_Mpeg4Dec_SetParameter; | |
2378 | pOMXComponent->GetConfig = &Exynos_Mpeg4Dec_GetConfig; | |
2379 | pOMXComponent->SetConfig = &Exynos_Mpeg4Dec_SetConfig; | |
2380 | pOMXComponent->GetExtensionIndex = &Exynos_Mpeg4Dec_GetExtensionIndex; | |
2381 | pOMXComponent->ComponentRoleEnum = &Exynos_Mpeg4Dec_ComponentRoleEnum; | |
2382 | pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit; | |
2383 | ||
2384 | pExynosComponent->exynos_codec_componentInit = &Exynos_Mpeg4Dec_Init; | |
2385 | pExynosComponent->exynos_codec_componentTerminate = &Exynos_Mpeg4Dec_Terminate; | |
2386 | ||
2387 | pVideoDec->exynos_codec_srcInputProcess = &Exynos_Mpeg4Dec_srcInputBufferProcess; | |
2388 | pVideoDec->exynos_codec_srcOutputProcess = &Exynos_Mpeg4Dec_srcOutputBufferProcess; | |
2389 | pVideoDec->exynos_codec_dstInputProcess = &Exynos_Mpeg4Dec_dstInputBufferProcess; | |
2390 | pVideoDec->exynos_codec_dstOutputProcess = &Exynos_Mpeg4Dec_dstOutputBufferProcess; | |
2391 | ||
2392 | pVideoDec->exynos_codec_start = &Mpeg4CodecStart; | |
2393 | pVideoDec->exynos_codec_stop = &Mpeg4CodecStop; | |
2394 | pVideoDec->exynos_codec_bufferProcessRun = &Mpeg4CodecOutputBufferProcessRun; | |
2395 | pVideoDec->exynos_codec_enqueueAllBuffer = &Mpeg4CodecEnQueueAllBuffer; | |
2396 | ||
2397 | if (codecType == CODEC_TYPE_MPEG4) | |
2398 | pVideoDec->exynos_checkInputFrame = &Check_Mpeg4_Frame; | |
2399 | else | |
2400 | pVideoDec->exynos_checkInputFrame = &Check_H263_Frame; | |
2401 | ||
2402 | pVideoDec->exynos_codec_getCodecInputPrivateData = &GetCodecInputPrivateData; | |
2403 | pVideoDec->exynos_codec_getCodecOutputPrivateData = &GetCodecOutputPrivateData; | |
2404 | ||
2405 | pVideoDec->hSharedMemory = Exynos_OSAL_SharedMemory_Open(); | |
2406 | if (pVideoDec->hSharedMemory == NULL) { | |
2407 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); | |
2408 | Exynos_OSAL_Free(pMpeg4Dec); | |
2409 | pMpeg4Dec = ((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle = NULL; | |
2410 | Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2411 | ret = OMX_ErrorInsufficientResources; | |
2412 | goto EXIT; | |
2413 | } | |
2414 | ||
2415 | pExynosComponent->currentState = OMX_StateLoaded; | |
2416 | ||
2417 | ret = OMX_ErrorNone; | |
2418 | ||
2419 | EXIT: | |
2420 | FunctionOut(); | |
2421 | ||
2422 | return ret; | |
2423 | } | |
2424 | ||
2425 | OMX_ERRORTYPE Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) | |
2426 | { | |
2427 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2428 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
2429 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
2430 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL; | |
2431 | EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = NULL; | |
2432 | ||
2433 | FunctionIn(); | |
2434 | ||
2435 | if (hComponent == NULL) { | |
2436 | ret = OMX_ErrorBadParameter; | |
2437 | goto EXIT; | |
2438 | } | |
2439 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
2440 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2441 | pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2442 | ||
2443 | Exynos_OSAL_SharedMemory_Close(pVideoDec->hSharedMemory); | |
2444 | ||
2445 | Exynos_OSAL_Free(pExynosComponent->componentName); | |
2446 | pExynosComponent->componentName = NULL; | |
2447 | ||
2448 | pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)pVideoDec->hCodecHandle; | |
2449 | if (pMpeg4Dec != NULL) { | |
2450 | Exynos_OSAL_Free(pMpeg4Dec); | |
2451 | pMpeg4Dec = pVideoDec->hCodecHandle = NULL; | |
2452 | } | |
2453 | ||
2454 | ret = Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2455 | if (ret != OMX_ErrorNone) { | |
2456 | goto EXIT; | |
2457 | } | |
2458 | ||
2459 | ret = OMX_ErrorNone; | |
2460 | ||
2461 | EXIT: | |
2462 | FunctionOut(); | |
2463 | ||
2464 | return ret; | |
2465 | } |