3 * Copyright 2012 Samsung Electronics S.LSI Co. LTD
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file Exynos_OMX_Mpeg4dec.c
21 * @author Yunji Kim (yunji.kim@samsung.com)
22 * @author SeungBeom Kim (sbcrux.kim@samsung.com)
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"
46 #include "Exynos_OSAL_Android.h"
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 */
54 #define EXYNOS_LOG_TAG "EXYNOS_MPEG4_DEC"
55 #define EXYNOS_LOG_OFF
56 //#define EXYNOS_TRACE_ON
57 #include "Exynos_OSAL_Log.h"
59 #define MPEG4_DEC_NUM_OF_EXTRA_BUFFERS 7
61 //#define FULL_FRAME_SEARCH
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
}};
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
},
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
},
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
}};
122 static OMX_ERRORTYPE
GetCodecInputPrivateData(OMX_PTR codecBuffer
, void *pVirtAddr
, OMX_U32
*dataSize
)
124 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
130 static OMX_ERRORTYPE
GetCodecOutputPrivateData(OMX_PTR codecBuffer
, void *addr
[], int size
[])
132 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
133 ExynosVideoBuffer
*pCodecBuffer
;
135 if (codecBuffer
== NULL
) {
136 ret
= OMX_ErrorBadParameter
;
140 pCodecBuffer
= (ExynosVideoBuffer
*)codecBuffer
;
143 addr
[0] = pCodecBuffer
->planes
[0].addr
;
144 addr
[1] = pCodecBuffer
->planes
[1].addr
;
145 addr
[2] = pCodecBuffer
->planes
[2].addr
;
149 size
[0] = pCodecBuffer
->planes
[0].allocSize
;
150 size
[1] = pCodecBuffer
->planes
[1].allocSize
;
151 size
[2] = pCodecBuffer
->planes
[2].allocSize
;
158 static OMX_BOOL gbFIMV1
= OMX_FALSE
;
160 static int Check_Mpeg4_Frame(
161 OMX_U8
*pInputStream
,
164 OMX_BOOL bPreviousFrameEOF
,
165 OMX_BOOL
*pbEndOfFrame
)
170 OMX_BOOL bFrameStart
;
173 bFrameStart
= OMX_FALSE
;
175 if (flag
& OMX_BUFFERFLAG_CODECCONFIG
) {
176 if (*pInputStream
== 0x03) { /* FIMV1 */
177 BitmapInfoHhr
*pInfoHeader
;
179 pInfoHeader
= (BitmapInfoHhr
*)(pInputStream
+ 1);
181 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "############## NOT SUPPORTED #################");
182 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "width(%d), height(%d)", pInfoHeader
->BiWidth
, pInfoHeader
->BiHeight
);
184 *pbEndOfFrame
= OMX_TRUE
;
190 *pbEndOfFrame
= OMX_TRUE
;
194 if (bPreviousFrameEOF
== OMX_FALSE
)
195 bFrameStart
= OMX_TRUE
;
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
;
209 /* find next VOP start code */
210 startCode
= 0xFFFFFFFF;
211 while ((startCode
!= 0x1B6)) {
212 readStream
= *(pInputStream
+ len
);
213 startCode
= (startCode
<< 8) | readStream
;
219 *pbEndOfFrame
= OMX_TRUE
;
221 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "1. Check_Mpeg4_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame
, len
- 4, buffSize
);
226 *pbEndOfFrame
= OMX_FALSE
;
228 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "2. Check_Mpeg4_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame
, len
- 1, buffSize
);
233 static int Check_H263_Frame(
234 OMX_U8
*pInputStream
,
237 OMX_BOOL bPreviousFrameEOF
,
238 OMX_BOOL
*pbEndOfFrame
)
243 OMX_BOOL bFrameStart
= 0;
244 unsigned pTypeMask
= 0x03;
248 bFrameStart
= OMX_FALSE
;
250 if (bPreviousFrameEOF
== OMX_FALSE
)
251 bFrameStart
= OMX_TRUE
;
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
;
260 readStream
= *(pInputStream
+ len
+ 1);
261 pType
= readStream
& pTypeMask
;
270 startCode
= 0xFFFFFFFF;
272 while (((startCode
<< 8 >> 10) != 0x20) || (pType
!= 0x02)) {
273 readStream
= *(pInputStream
+ len
);
274 startCode
= (startCode
<< 8) | readStream
;
276 readStream
= *(pInputStream
+ len
+ 1);
277 pType
= readStream
& pTypeMask
;
284 *pbEndOfFrame
= OMX_TRUE
;
286 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "1. Check_H263_Frame returned EOF = %d, len = %d, iBuffSize = %d", *pbEndOfFrame
, len
- 3, buffSize
);
292 *pbEndOfFrame
= OMX_FALSE
;
294 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "2. Check_H263_Frame returned EOF = %d, len = %d, iBuffSize = %d", *pbEndOfFrame
, len
- 1, buffSize
);
299 static OMX_BOOL
Check_Stream_StartCode(
300 OMX_U8
*pInputStream
,
302 CODEC_TYPE codecType
)
305 case CODEC_TYPE_MPEG4
:
309 if (streamSize
< 3) {
311 } else if ((pInputStream
[0] == 0x00) &&
312 (pInputStream
[1] == 0x00) &&
313 (pInputStream
[2] == 0x01)) {
320 case CODEC_TYPE_H263
:
321 if (streamSize
> 0) {
322 unsigned startCode
= 0xFFFFFFFF;
323 unsigned pTypeMask
= 0x03;
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
;
332 readStream
= *(pInputStream
+ len
+ 1);
333 pType
= readStream
& pTypeMask
;
341 Exynos_OSAL_Log(EXYNOS_LOG_WARNING
, "[%s] Picture Start Code Missing", __FUNCTION__
);
350 Exynos_OSAL_Log(EXYNOS_LOG_WARNING
, "%s: undefined codec type (%d)", __FUNCTION__
, codecType
);
355 OMX_ERRORTYPE
Mpeg4CodecOpen(EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
)
357 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
358 ExynosVideoDecOps
*pDecOps
= NULL
;
359 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
360 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
364 if (pMpeg4Dec
== NULL
) {
365 ret
= OMX_ErrorBadParameter
;
366 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, Line:%d", __LINE__
);
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
));
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
;
381 pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
= pDecOps
;
382 pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
= pInbufOps
;
383 pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
= pOutbufOps
;
385 /* function pointer mapping */
386 pDecOps
->nSize
= sizeof(ExynosVideoDecOps
);
387 pInbufOps
->nSize
= sizeof(ExynosVideoDecBufferOps
);
388 pOutbufOps
->nSize
= sizeof(ExynosVideoDecBufferOps
);
390 Exynos_Video_Register_Decoder(pDecOps
, pInbufOps
, pOutbufOps
);
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
;
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
;
412 /* alloc context, open, querycap */
413 pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
->Init(V4L2_MEMORY_DMABUF
);
414 if (pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
== NULL
) {
415 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to allocate context buffer");
416 ret
= OMX_ErrorInsufficientResources
;
423 if (ret
!= OMX_ErrorNone
) {
424 if (pDecOps
!= NULL
) {
425 Exynos_OSAL_Free(pDecOps
);
426 pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
= NULL
;
428 if (pInbufOps
!= NULL
) {
429 Exynos_OSAL_Free(pInbufOps
);
430 pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
= NULL
;
432 if (pOutbufOps
!= NULL
) {
433 Exynos_OSAL_Free(pOutbufOps
);
434 pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
= NULL
;
443 OMX_ERRORTYPE
Mpeg4CodecClose(EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
)
445 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
446 void *hMFCHandle
= NULL
;
447 ExynosVideoDecOps
*pDecOps
= NULL
;
448 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
449 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
453 if (pMpeg4Dec
== NULL
) {
454 ret
= OMX_ErrorBadParameter
;
458 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
459 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
460 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
461 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
463 if (hMFCHandle
!= NULL
) {
464 pDecOps
->Finalize(hMFCHandle
);
465 pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
= NULL
;
467 if (pOutbufOps
!= NULL
) {
468 Exynos_OSAL_Free(pOutbufOps
);
469 pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
= NULL
;
471 if (pInbufOps
!= NULL
) {
472 Exynos_OSAL_Free(pInbufOps
);
473 pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
= NULL
;
475 if (pDecOps
!= NULL
) {
476 Exynos_OSAL_Free(pDecOps
);
477 pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
= NULL
;
488 OMX_ERRORTYPE
Mpeg4CodecStart(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
490 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
491 void *hMFCHandle
= NULL
;
492 ExynosVideoDecOps
*pDecOps
= NULL
;
493 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
494 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
495 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
496 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
500 if (pOMXComponent
== NULL
) {
501 ret
= OMX_ErrorBadParameter
;
505 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
506 if (pVideoDec
== NULL
) {
507 ret
= OMX_ErrorBadParameter
;
511 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
512 if (pMpeg4Dec
== NULL
) {
513 ret
= OMX_ErrorBadParameter
;
517 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
518 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
519 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
520 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
522 if (nPortIndex
== INPUT_PORT_INDEX
)
523 pInbufOps
->Run(hMFCHandle
);
524 else if (nPortIndex
== OUTPUT_PORT_INDEX
)
525 pOutbufOps
->Run(hMFCHandle
);
535 OMX_ERRORTYPE
Mpeg4CodecStop(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
537 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
538 void *hMFCHandle
= NULL
;
539 ExynosVideoDecOps
*pDecOps
= NULL
;
540 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
541 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
542 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
543 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
547 if (pOMXComponent
== NULL
) {
548 ret
= OMX_ErrorBadParameter
;
552 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
553 if (pVideoDec
== NULL
) {
554 ret
= OMX_ErrorBadParameter
;
557 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
558 if (pMpeg4Dec
== NULL
) {
559 ret
= OMX_ErrorBadParameter
;
563 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
564 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
565 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
566 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
568 if ((nPortIndex
== INPUT_PORT_INDEX
) && (pInbufOps
!= NULL
)) {
569 pInbufOps
->Stop(hMFCHandle
);
570 } else if ((nPortIndex
== OUTPUT_PORT_INDEX
) && (pOutbufOps
!= NULL
)) {
571 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
572 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
573 pOutbufOps
->Stop(hMFCHandle
);
574 if (pExynosOutputPort
->bufferProcessType
== BUFFER_SHARE
)
575 pOutbufOps
->Clear_RegisteredBuffer(hMFCHandle
);
585 OMX_ERRORTYPE
Mpeg4CodecOutputBufferProcessRun(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
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
;
597 if (pOMXComponent
== NULL
) {
598 ret
= OMX_ErrorBadParameter
;
602 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
603 if (pVideoDec
== NULL
) {
604 ret
= OMX_ErrorBadParameter
;
607 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
608 if (pMpeg4Dec
== NULL
) {
609 ret
= OMX_ErrorBadParameter
;
613 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
614 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
615 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
616 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
618 if (nPortIndex
== INPUT_PORT_INDEX
) {
619 if (pMpeg4Dec
->bSourceStart
== OMX_FALSE
) {
620 Exynos_OSAL_SignalSet(pMpeg4Dec
->hSourceStartEvent
);
621 Exynos_OSAL_SleepMillisec(0);
625 if (nPortIndex
== OUTPUT_PORT_INDEX
) {
626 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
627 Exynos_OSAL_SignalSet(pMpeg4Dec
->hDestinationStartEvent
);
628 Exynos_OSAL_SleepMillisec(0);
640 OMX_ERRORTYPE
Mpeg4CodecRegistCodecBuffers(
641 OMX_COMPONENTTYPE
*pOMXComponent
,
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
;
654 OMX_U32 nPlaneCnt
= 0;
659 if (nPortIndex
== INPUT_PORT_INDEX
) {
660 ppCodecBuffer
= &(pVideoDec
->pMFCDecInputBuffer
[0]);
661 nPlaneCnt
= MFC_INPUT_BUFFER_PLANE
;
662 pBufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
664 ppCodecBuffer
= &(pVideoDec
->pMFCDecOutputBuffer
[0]);
665 nPlaneCnt
= MFC_OUTPUT_BUFFER_PLANE
;
666 pBufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
669 pPlanes
= (ExynosVideoPlane
*)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane
) * nPlaneCnt
);
670 if (pPlanes
== NULL
) {
671 ret
= OMX_ErrorInsufficientResources
;
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
];
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
);
691 Exynos_OSAL_Free(pPlanes
);
701 OMX_ERRORTYPE
Mpeg4CodecReconfigAllBuffers(
702 OMX_COMPONENTTYPE
*pOMXComponent
,
705 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
706 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
707 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
708 EXYNOS_OMX_BASEPORT
*pExynosPort
= &pExynosComponent
->pExynosPort
[nPortIndex
];
709 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
710 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
711 ExynosVideoDecBufferOps
*pBufferOps
= NULL
;
715 if ((nPortIndex
== INPUT_PORT_INDEX
) &&
716 (pMpeg4Dec
->bSourceStart
== OMX_TRUE
)) {
717 ret
= OMX_ErrorNotImplemented
;
719 } else if ((nPortIndex
== OUTPUT_PORT_INDEX
) &&
720 (pMpeg4Dec
->bDestinationStart
== OMX_TRUE
)) {
721 pBufferOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
723 if (pExynosPort
->bufferProcessType
& BUFFER_COPY
) {
724 /**********************************/
725 /* Codec Buffer Free & Unregister */
726 /**********************************/
727 Exynos_Free_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
);
728 Exynos_CodecBufferReset(pExynosComponent
, OUTPUT_PORT_INDEX
);
729 pBufferOps
->Clear_RegisteredBuffer(hMFCHandle
);
730 pBufferOps
->Cleanup_Buffer(hMFCHandle
);
731 } else if (pExynosPort
->bufferProcessType
& BUFFER_SHARE
) {
732 /**********************************/
733 /* Codec Buffer Unregister */
734 /**********************************/
735 pBufferOps
->Clear_RegisteredBuffer(hMFCHandle
);
736 pBufferOps
->Cleanup_Buffer(hMFCHandle
);
738 /******************************************************/
739 /* V4L2 Destnation Setup for DPB Buffer Number Change */
740 /******************************************************/
741 Mpeg4CodecDstSetup(pOMXComponent
);
742 pVideoDec
->bReconfigDPB
= OMX_FALSE
;
744 Exynos_ResolutionUpdate(pOMXComponent
);
746 ret
= OMX_ErrorBadParameter
;
756 OMX_ERRORTYPE
Mpeg4CodecEnQueueAllBuffer(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
758 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
759 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
760 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
761 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
762 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
763 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
764 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
767 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
768 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
769 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
773 if ((nPortIndex
!= INPUT_PORT_INDEX
) && (nPortIndex
!= OUTPUT_PORT_INDEX
)) {
774 ret
= OMX_ErrorBadPortIndex
;
778 if ((nPortIndex
== INPUT_PORT_INDEX
) &&
779 (pMpeg4Dec
->bSourceStart
== OMX_TRUE
)) {
780 Exynos_CodecBufferReset(pExynosComponent
, INPUT_PORT_INDEX
);
782 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++) {
783 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i
, pVideoDec
->pMFCDecInputBuffer
[i
]);
784 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[0]: 0x%x", i
, pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[0]);
786 Exynos_CodecBufferEnQueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoDec
->pMFCDecInputBuffer
[i
]);
789 pInbufOps
->Clear_Queue(hMFCHandle
);
790 } else if ((nPortIndex
== OUTPUT_PORT_INDEX
) &&
791 (pMpeg4Dec
->bDestinationStart
== OMX_TRUE
)) {
792 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
793 ExynosVideoBuffer
*pBuffer
= NULL
;
795 Exynos_CodecBufferReset(pExynosComponent
, OUTPUT_PORT_INDEX
);
797 nOutbufs
= pDecOps
->Get_ActualBufferCount(hMFCHandle
);
798 nOutbufs
+= EXTRA_DPB_NUM
;
799 for (i
= 0; i
< nOutbufs
; i
++) {
800 Exynos_CodecBufferEnQueue(pExynosComponent
, OUTPUT_PORT_INDEX
, pVideoDec
->pMFCDecOutputBuffer
[i
]);
802 pOutbufOps
->Clear_Queue(hMFCHandle
);
804 ret
= OMX_ErrorBadParameter
;
814 OMX_ERRORTYPE
Mpeg4CodecCheckResolutionChange(OMX_COMPONENTTYPE
*pOMXComponent
)
816 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
817 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
818 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
819 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
820 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
821 EXYNOS_OMX_BASEPORT
*pInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
822 EXYNOS_OMX_BASEPORT
*pOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
823 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
824 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
826 OMX_CONFIG_RECTTYPE
*pCropRectangle
= NULL
;
827 OMX_PARAM_PORTDEFINITIONTYPE
*pInputPortDefinition
= NULL
;
828 OMX_PARAM_PORTDEFINITIONTYPE
*pOutputPortDefinition
= NULL
;
831 /* get geometry for output */
832 Exynos_OSAL_Memset(&pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
, 0, sizeof(ExynosVideoGeometry
));
833 if (pOutbufOps
->Get_Geometry(hMFCHandle
, &pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
) != VIDEO_ERROR_NONE
) {
834 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to get geometry for parsed header info");
835 ret
= OMX_ErrorInsufficientResources
;
840 pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
= pDecOps
->Get_ActualBufferCount(hMFCHandle
);
841 if (pVideoDec
->bThumbnailMode
== OMX_FALSE
)
842 pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
+= EXTRA_DPB_NUM
;
843 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "H264CodecSetup nOutbufs: %d", pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
);
845 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
= OMX_TRUE
;
847 if (pVideoDec
->bReconfigDPB
!= OMX_TRUE
) {
848 pCropRectangle
= &(pOutputPort
->cropRectangle
);
849 pInputPortDefinition
= &(pInputPort
->portDefinition
);
850 pOutputPortDefinition
= &(pOutputPort
->portDefinition
);
852 pCropRectangle
= &(pOutputPort
->newCropRectangle
);
853 pInputPortDefinition
= &(pInputPort
->newPortDefinition
);
854 pOutputPortDefinition
= &(pOutputPort
->newPortDefinition
);
857 pCropRectangle
->nTop
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.cropRect
.nTop
;
858 pCropRectangle
->nLeft
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.cropRect
.nLeft
;
859 pCropRectangle
->nWidth
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.cropRect
.nWidth
;
860 pCropRectangle
->nHeight
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.cropRect
.nHeight
;
862 if (pOutputPort
->bufferProcessType
& BUFFER_COPY
) {
863 if ((pVideoDec
->bReconfigDPB
) ||
864 (pInputPort
->portDefinition
.format
.video
.nFrameWidth
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
) ||
865 (pInputPort
->portDefinition
.format
.video
.nFrameHeight
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
)) {
866 pInputPortDefinition
->format
.video
.nFrameWidth
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
;
867 pInputPortDefinition
->format
.video
.nFrameHeight
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
;
868 pInputPortDefinition
->format
.video
.nStride
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
+ 15) & (~15));
869 pInputPortDefinition
->format
.video
.nSliceHeight
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
+ 15) & (~15));
870 pOutputPortDefinition
->nBufferCountActual
= pOutputPort
->portDefinition
.nBufferCountActual
;
871 pOutputPortDefinition
->nBufferCountMin
= pOutputPort
->portDefinition
.nBufferCountMin
;
872 if (pVideoDec
->bReconfigDPB
!= OMX_TRUE
)
873 Exynos_UpdateFrameSize(pOMXComponent
);
874 pOutputPort
->exceptionFlag
= NEED_PORT_DISABLE
;
876 /** Send Port Settings changed call back **/
877 (*(pExynosComponent
->pCallbacks
->EventHandler
))
879 pExynosComponent
->callbackData
,
880 OMX_EventPortSettingsChanged
, /* The command was completed */
881 OMX_DirOutput
, /* This is the port index */
885 } else if (pOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
886 if ((pVideoDec
->bReconfigDPB
) ||
887 (pInputPort
->portDefinition
.format
.video
.nFrameWidth
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
) ||
888 (pInputPort
->portDefinition
.format
.video
.nFrameHeight
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
) ||
889 (pOutputPort
->portDefinition
.nBufferCountActual
!= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
)) {
890 pInputPortDefinition
->format
.video
.nFrameWidth
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
;
891 pInputPortDefinition
->format
.video
.nFrameHeight
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
;
892 pInputPortDefinition
->format
.video
.nStride
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
+ 15) & (~15));
893 pInputPortDefinition
->format
.video
.nSliceHeight
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
+ 15) & (~15));
894 pOutputPortDefinition
->nBufferCountActual
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
;
895 pOutputPortDefinition
->nBufferCountMin
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
;
896 if (pVideoDec
->bReconfigDPB
!= OMX_TRUE
)
897 Exynos_UpdateFrameSize(pOMXComponent
);
898 pOutputPort
->exceptionFlag
= NEED_PORT_DISABLE
;
900 /** Send Port Settings changed call back **/
901 (*(pExynosComponent
->pCallbacks
->EventHandler
))
903 pExynosComponent
->callbackData
,
904 OMX_EventPortSettingsChanged
, /* The command was completed */
905 OMX_DirOutput
, /* This is the port index */
910 if ((pVideoDec
->bReconfigDPB
== OMX_TRUE
) ||
911 (pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.cropRect
.nWidth
) ||
912 (pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.cropRect
.nHeight
)) {
914 pInputPortDefinition
->format
.video
.nFrameWidth
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
;
915 pInputPortDefinition
->format
.video
.nFrameHeight
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
;
916 pInputPortDefinition
->format
.video
.nStride
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
+ 15) & (~15));
917 pInputPortDefinition
->format
.video
.nSliceHeight
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
+ 15) & (~15));
918 if (pVideoDec
->bReconfigDPB
!= OMX_TRUE
)
919 Exynos_UpdateFrameSize(pOMXComponent
);
921 /** Send crop info call back **/
922 (*(pExynosComponent
->pCallbacks
->EventHandler
))
924 pExynosComponent
->callbackData
,
925 OMX_EventPortSettingsChanged
, /* The command was completed */
926 OMX_DirOutput
, /* This is the port index */
927 OMX_IndexConfigCommonOutputCrop
,
939 OMX_ERRORTYPE
Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
941 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
942 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
943 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
944 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
945 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
946 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
947 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
948 OMX_U32 oneFrameSize
= pSrcInputData
->dataLen
;
950 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
951 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
952 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
953 ExynosVideoGeometry bufferConf
;
954 OMX_U32 inputBufferNumber
= 0;
959 if ((oneFrameSize
<= 0) && (pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
)) {
960 OMX_BUFFERHEADERTYPE
*OMXBuffer
= NULL
;
961 OMXBuffer
= Exynos_OutputBufferGetQueue_Direct(pExynosComponent
);
962 if (OMXBuffer
== NULL
) {
963 ret
= OMX_ErrorUndefined
;
967 OMXBuffer
->nTimeStamp
= pSrcInputData
->timeStamp
;
968 OMXBuffer
->nFlags
= pSrcInputData
->nFlags
;
969 Exynos_OMX_OutputBufferReturn(pOMXComponent
, OMXBuffer
);
975 if (pVideoDec
->bThumbnailMode
== OMX_TRUE
)
976 pDecOps
->Set_IFrameDecoding(hMFCHandle
);
978 /* input buffer info */
979 Exynos_OSAL_Memset(&bufferConf
, 0, sizeof(bufferConf
));
980 if (pMpeg4Dec
->hMFCMpeg4Handle
.codecType
== CODEC_TYPE_MPEG4
)
981 bufferConf
.eCompressionFormat
= VIDEO_CODING_MPEG4
;
983 bufferConf
.eCompressionFormat
= VIDEO_CODING_H263
;
985 pInbufOps
->Set_Shareable(hMFCHandle
);
986 if (pExynosInputPort
->bufferProcessType
== BUFFER_SHARE
) {
987 bufferConf
.nSizeImage
= pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
988 * pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
* 3 / 2;
989 inputBufferNumber
= MAX_VIDEO_INPUTBUFFER_NUM
;
990 } else if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
991 bufferConf
.nSizeImage
= DEFAULT_MFC_INPUT_BUFFER_SIZE
;
992 inputBufferNumber
= MFC_INPUT_BUFFER_NUM_MAX
;
995 /* should be done before prepare input buffer */
996 if (pInbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
997 ret
= OMX_ErrorInsufficientResources
;
1001 /* set input buffer geometry */
1002 if (pInbufOps
->Set_Geometry(hMFCHandle
, &bufferConf
) != VIDEO_ERROR_NONE
) {
1003 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to set geometry for input buffer");
1004 ret
= OMX_ErrorInsufficientResources
;
1008 /* setup input buffer */
1009 if (pInbufOps
->Setup(hMFCHandle
, inputBufferNumber
) != VIDEO_ERROR_NONE
) {
1010 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup input buffer");
1011 ret
= OMX_ErrorInsufficientResources
;
1015 if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1016 ret
= Mpeg4CodecRegistCodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
, MFC_INPUT_BUFFER_NUM_MAX
);
1017 if (ret
!= OMX_ErrorNone
)
1019 } else if (pExynosInputPort
->bufferProcessType
== BUFFER_SHARE
) {
1020 /* Register input buffer */
1021 for (i
= 0; i
< pExynosInputPort
->portDefinition
.nBufferCountActual
; i
++) {
1022 ExynosVideoPlane plane
;
1023 plane
.addr
= pExynosInputPort
->extendBufferHeader
[i
].OMXBufferHeader
->pBuffer
;
1024 plane
.allocSize
= pExynosInputPort
->extendBufferHeader
[i
].OMXBufferHeader
->nAllocLen
;
1025 plane
.fd
= pExynosInputPort
->extendBufferHeader
[i
].buf_fd
[0];
1026 if (pInbufOps
->Register(hMFCHandle
, &plane
, MFC_INPUT_BUFFER_PLANE
) != VIDEO_ERROR_NONE
) {
1027 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to Register input buffer");
1028 ret
= OMX_ErrorInsufficientResources
;
1034 /* set output geometry */
1035 Exynos_OSAL_Memset(&bufferConf
, 0, sizeof(bufferConf
));
1036 pMpeg4Dec
->hMFCMpeg4Handle
.MFCOutputColorType
= bufferConf
.eColorFormat
= VIDEO_COLORFORMAT_NV12_TILED
;
1037 if (pOutbufOps
->Set_Geometry(hMFCHandle
, &bufferConf
) != VIDEO_ERROR_NONE
) {
1038 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to set geometry for output buffer");
1039 ret
= OMX_ErrorInsufficientResources
;
1043 /* input buffer enqueue for header parsing */
1044 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "oneFrameSize: %d", oneFrameSize
);
1045 if (pInbufOps
->Enqueue(hMFCHandle
, (unsigned char **)&pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
,
1046 (unsigned int *)&oneFrameSize
, MFC_INPUT_BUFFER_PLANE
, pSrcInputData
->bufferHeader
) != VIDEO_ERROR_NONE
) {
1047 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to enqueue input buffer for header parsing");
1048 // ret = OMX_ErrorInsufficientResources;
1049 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecInit
;
1053 /* start header parsing */
1054 if (pInbufOps
->Run(hMFCHandle
) != VIDEO_ERROR_NONE
) {
1055 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to run input buffer for header parsing");
1056 ret
= OMX_ErrorCodecInit
;
1060 Mpeg4CodecCheckResolutionChange(pOMXComponent
);
1062 Exynos_OSAL_SleepMillisec(0);
1063 ret
= OMX_ErrorInputDataDecodeYet
;
1064 Mpeg4CodecStop(pOMXComponent
, INPUT_PORT_INDEX
);
1072 OMX_ERRORTYPE
Mpeg4CodecDstSetup(OMX_COMPONENTTYPE
*pOMXComponent
)
1074 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1075 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1076 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1077 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1078 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1079 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1080 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1082 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1083 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1084 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1090 if ((pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1091 /* BUFFER_COPY case, get dpb count */
1092 nOutbufs
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
;
1094 /* should be done before prepare output buffer */
1095 if (pOutbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
1096 ret
= OMX_ErrorInsufficientResources
;
1100 /*BUFFER_SHERE case, get dpb count */
1101 nOutbufs
= pExynosOutputPort
->portDefinition
.nBufferCountActual
;
1104 if (pOutbufOps
->Enable_DynamicDPB(hMFCHandle
) != VIDEO_ERROR_NONE
) {
1105 ret
= OMX_ErrorUndefined
;
1109 pOutbufOps
->Set_Shareable(hMFCHandle
);
1110 if (pOutbufOps
->Setup(hMFCHandle
, MAX_OUTPUTBUFFER_NUM_DYNAMIC
) != VIDEO_ERROR_NONE
) {
1111 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup output buffer");
1112 ret
= OMX_ErrorInsufficientResources
;
1116 ExynosVideoPlane planes
[MFC_OUTPUT_BUFFER_PLANE
];
1117 OMX_U32 nAllocLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
1118 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
1121 nAllocLen
[0] = calc_plane(pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
,
1122 pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
);
1123 nAllocLen
[1] = calc_plane(pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
,
1124 pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
>> 1);
1126 if ((pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1127 ret
= Exynos_Allocate_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
, nOutbufs
, nAllocLen
);
1128 if (ret
!= OMX_ErrorNone
)
1131 for (i
= 0; i
< nOutbufs
; i
++) {
1132 /* Enqueue output buffer */
1133 pOutbufOps
->ExtensionEnqueue(hMFCHandle
,
1134 (unsigned char **)pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
,
1135 (unsigned char **)pVideoDec
->pMFCDecOutputBuffer
[i
]->fd
,
1136 (unsigned int *)pVideoDec
->pMFCDecOutputBuffer
[i
]->bufferSize
,
1137 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, NULL
);
1140 if (pOutbufOps
->Run(hMFCHandle
) != VIDEO_ERROR_NONE
) {
1141 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to run output buffer");
1142 ret
= OMX_ErrorInsufficientResources
;
1145 } else if (pExynosOutputPort
->bufferProcessType
== BUFFER_SHARE
) {
1150 if ((pExynosOutputPort
->bIsANBEnabled
== OMX_FALSE
) &&
1151 (pExynosOutputPort
->bStoreMetaData
== OMX_FALSE
)) {
1152 ret
= OMX_ErrorNotImplemented
;
1156 ret
= OMX_ErrorNotImplemented
;
1161 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
= OMX_TRUE
;
1163 ret
= OMX_ErrorNone
;
1171 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetParameter(
1172 OMX_IN OMX_HANDLETYPE hComponent
,
1173 OMX_IN OMX_INDEXTYPE nParamIndex
,
1174 OMX_INOUT OMX_PTR pComponentParameterStructure
)
1176 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1177 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1178 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1182 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1183 ret
= OMX_ErrorBadParameter
;
1186 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1187 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1188 if (ret
!= OMX_ErrorNone
) {
1191 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1192 ret
= OMX_ErrorBadParameter
;
1196 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1197 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1198 ret
= OMX_ErrorInvalidState
;
1202 switch (nParamIndex
) {
1203 case OMX_IndexParamVideoMpeg4
:
1205 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= (OMX_VIDEO_PARAM_MPEG4TYPE
*)pComponentParameterStructure
;
1206 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= NULL
;
1207 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1209 ret
= Exynos_OMX_Check_SizeVersion(pDstMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1210 if (ret
!= OMX_ErrorNone
) {
1214 if (pDstMpeg4Param
->nPortIndex
>= ALL_PORT_NUM
) {
1215 ret
= OMX_ErrorBadPortIndex
;
1219 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1220 pSrcMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pDstMpeg4Param
->nPortIndex
];
1222 Exynos_OSAL_Memcpy(pDstMpeg4Param
, pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1225 case OMX_IndexParamVideoH263
:
1227 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= (OMX_VIDEO_PARAM_H263TYPE
*)pComponentParameterStructure
;
1228 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= NULL
;
1229 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1231 ret
= Exynos_OMX_Check_SizeVersion(pDstH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1232 if (ret
!= OMX_ErrorNone
) {
1236 if (pDstH263Param
->nPortIndex
>= ALL_PORT_NUM
) {
1237 ret
= OMX_ErrorBadPortIndex
;
1241 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1242 pSrcH263Param
= &pMpeg4Dec
->h263Component
[pDstH263Param
->nPortIndex
];
1244 Exynos_OSAL_Memcpy(pDstH263Param
, pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1247 case OMX_IndexParamStandardComponentRole
:
1250 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1252 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1253 if (ret
!= OMX_ErrorNone
) {
1257 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1258 if (codecType
== CODEC_TYPE_MPEG4
)
1259 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
);
1261 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
);
1264 case OMX_IndexParamVideoProfileLevelQuerySupported
:
1266 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1267 EXYNOS_OMX_VIDEO_PROFILELEVEL
*pProfileLevel
= NULL
;
1268 OMX_U32 maxProfileLevelNum
= 0;
1271 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1272 if (ret
!= OMX_ErrorNone
) {
1276 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1277 ret
= OMX_ErrorBadPortIndex
;
1281 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1282 if (codecType
== CODEC_TYPE_MPEG4
) {
1283 pProfileLevel
= supportedMPEG4ProfileLevels
;
1284 maxProfileLevelNum
= sizeof(supportedMPEG4ProfileLevels
) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL
);
1286 pProfileLevel
= supportedH263ProfileLevels
;
1287 maxProfileLevelNum
= sizeof(supportedH263ProfileLevels
) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL
);
1290 if (pDstProfileLevel
->nProfileIndex
>= maxProfileLevelNum
) {
1291 ret
= OMX_ErrorNoMore
;
1295 pProfileLevel
+= pDstProfileLevel
->nProfileIndex
;
1296 pDstProfileLevel
->eProfile
= pProfileLevel
->profile
;
1297 pDstProfileLevel
->eLevel
= pProfileLevel
->level
;
1300 case OMX_IndexParamVideoProfileLevelCurrent
:
1302 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1303 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= NULL
;
1304 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= NULL
;
1305 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1308 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1309 if (ret
!= OMX_ErrorNone
) {
1313 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1314 ret
= OMX_ErrorBadPortIndex
;
1318 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1319 codecType
= pMpeg4Dec
->hMFCMpeg4Handle
.codecType
;
1320 if (codecType
== CODEC_TYPE_MPEG4
) {
1321 pSrcMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pDstProfileLevel
->nPortIndex
];
1322 pDstProfileLevel
->eProfile
= pSrcMpeg4Param
->eProfile
;
1323 pDstProfileLevel
->eLevel
= pSrcMpeg4Param
->eLevel
;
1325 pSrcH263Param
= &pMpeg4Dec
->h263Component
[pDstProfileLevel
->nPortIndex
];
1326 pDstProfileLevel
->eProfile
= pSrcH263Param
->eProfile
;
1327 pDstProfileLevel
->eLevel
= pSrcH263Param
->eLevel
;
1331 case OMX_IndexParamVideoErrorCorrection
:
1333 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1334 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= NULL
;
1335 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1337 ret
= Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1338 if (ret
!= OMX_ErrorNone
) {
1342 if (pDstErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
1343 ret
= OMX_ErrorBadPortIndex
;
1347 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1348 pSrcErrorCorrectionType
= &pMpeg4Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
1350 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1351 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1352 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1353 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1354 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1358 ret
= Exynos_OMX_VideoDecodeGetParameter(hComponent
, nParamIndex
, pComponentParameterStructure
);
1367 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SetParameter(
1368 OMX_IN OMX_HANDLETYPE hComponent
,
1369 OMX_IN OMX_INDEXTYPE nIndex
,
1370 OMX_IN OMX_PTR pComponentParameterStructure
)
1372 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1373 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1374 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1378 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1379 ret
= OMX_ErrorBadParameter
;
1382 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1383 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1384 if (ret
!= OMX_ErrorNone
) {
1387 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1388 ret
= OMX_ErrorBadParameter
;
1392 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1393 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1394 ret
= OMX_ErrorInvalidState
;
1399 case OMX_IndexParamVideoMpeg4
:
1401 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= NULL
;
1402 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= (OMX_VIDEO_PARAM_MPEG4TYPE
*)pComponentParameterStructure
;
1403 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1405 ret
= Exynos_OMX_Check_SizeVersion(pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1406 if (ret
!= OMX_ErrorNone
) {
1410 if (pSrcMpeg4Param
->nPortIndex
>= ALL_PORT_NUM
) {
1411 ret
= OMX_ErrorBadPortIndex
;
1415 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1416 pDstMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pSrcMpeg4Param
->nPortIndex
];
1418 Exynos_OSAL_Memcpy(pDstMpeg4Param
, pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1421 case OMX_IndexParamVideoH263
:
1423 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= NULL
;
1424 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= (OMX_VIDEO_PARAM_H263TYPE
*)pComponentParameterStructure
;
1425 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1427 ret
= Exynos_OMX_Check_SizeVersion(pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1428 if (ret
!= OMX_ErrorNone
) {
1432 if (pSrcH263Param
->nPortIndex
>= ALL_PORT_NUM
) {
1433 ret
= OMX_ErrorBadPortIndex
;
1437 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1438 pDstH263Param
= &pMpeg4Dec
->h263Component
[pSrcH263Param
->nPortIndex
];
1440 Exynos_OSAL_Memcpy(pDstH263Param
, pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1443 case OMX_IndexParamStandardComponentRole
:
1445 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1447 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1448 if (ret
!= OMX_ErrorNone
) {
1452 if ((pExynosComponent
->currentState
!= OMX_StateLoaded
) && (pExynosComponent
->currentState
!= OMX_StateWaitForResources
)) {
1453 ret
= OMX_ErrorIncorrectStateOperation
;
1457 if (!Exynos_OSAL_Strcmp((char*)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
)) {
1458 pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingMPEG4
;
1459 } else if (!Exynos_OSAL_Strcmp((char*)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
)) {
1460 pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingH263
;
1462 ret
= OMX_ErrorBadParameter
;
1467 case OMX_IndexParamVideoProfileLevelCurrent
:
1469 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pSrcProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1470 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= NULL
;
1471 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= NULL
;
1472 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1475 ret
= Exynos_OMX_Check_SizeVersion(pSrcProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1476 if (ret
!= OMX_ErrorNone
)
1479 if (pSrcProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1480 ret
= OMX_ErrorBadPortIndex
;
1484 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1485 codecType
= pMpeg4Dec
->hMFCMpeg4Handle
.codecType
;
1486 if (codecType
== CODEC_TYPE_MPEG4
) {
1488 * To do: Check validity of profile & level parameters
1491 pDstMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pSrcProfileLevel
->nPortIndex
];
1492 pDstMpeg4Param
->eProfile
= pSrcProfileLevel
->eProfile
;
1493 pDstMpeg4Param
->eLevel
= pSrcProfileLevel
->eLevel
;
1496 * To do: Check validity of profile & level parameters
1499 pDstH263Param
= &pMpeg4Dec
->h263Component
[pSrcProfileLevel
->nPortIndex
];
1500 pDstH263Param
->eProfile
= pSrcProfileLevel
->eProfile
;
1501 pDstH263Param
->eLevel
= pSrcProfileLevel
->eLevel
;
1505 case OMX_IndexParamVideoErrorCorrection
:
1507 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1508 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= NULL
;
1509 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1511 ret
= Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1512 if (ret
!= OMX_ErrorNone
) {
1516 if (pSrcErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
1517 ret
= OMX_ErrorBadPortIndex
;
1521 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1522 pDstErrorCorrectionType
= &pMpeg4Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
1524 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1525 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1526 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1527 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1528 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1532 ret
= Exynos_OMX_VideoDecodeSetParameter(hComponent
, nIndex
, pComponentParameterStructure
);
1541 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetConfig(
1542 OMX_IN OMX_HANDLETYPE hComponent
,
1543 OMX_IN OMX_INDEXTYPE nIndex
,
1544 OMX_IN OMX_PTR pComponentConfigStructure
)
1546 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1547 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1548 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1552 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1553 ret
= OMX_ErrorBadParameter
;
1556 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1557 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1558 if (ret
!= OMX_ErrorNone
) {
1561 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1562 ret
= OMX_ErrorBadParameter
;
1565 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1566 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1567 ret
= OMX_ErrorInvalidState
;
1573 ret
= Exynos_OMX_VideoDecodeGetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1583 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SetConfig(
1584 OMX_IN OMX_HANDLETYPE hComponent
,
1585 OMX_IN OMX_INDEXTYPE nIndex
,
1586 OMX_IN OMX_PTR pComponentConfigStructure
)
1588 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1589 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1590 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1594 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1595 ret
= OMX_ErrorBadParameter
;
1598 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1599 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1600 if (ret
!= OMX_ErrorNone
) {
1603 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1604 ret
= OMX_ErrorBadParameter
;
1607 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1608 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1609 ret
= OMX_ErrorInvalidState
;
1615 ret
= Exynos_OMX_VideoDecodeSetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1625 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetExtensionIndex(
1626 OMX_IN OMX_HANDLETYPE hComponent
,
1627 OMX_IN OMX_STRING cParameterName
,
1628 OMX_OUT OMX_INDEXTYPE
*pIndexType
)
1630 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1631 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1632 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1636 if (hComponent
== NULL
) {
1637 ret
= OMX_ErrorBadParameter
;
1640 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1641 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1642 if (ret
!= OMX_ErrorNone
) {
1645 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1646 ret
= OMX_ErrorBadParameter
;
1649 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1650 if ((cParameterName
== NULL
) || (pIndexType
== NULL
)) {
1651 ret
= OMX_ErrorBadParameter
;
1654 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1655 ret
= OMX_ErrorInvalidState
;
1659 ret
= Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent
, cParameterName
, pIndexType
);
1667 OMX_ERRORTYPE
Exynos_Mpeg4Dec_ComponentRoleEnum(
1668 OMX_IN OMX_HANDLETYPE hComponent
,
1669 OMX_OUT OMX_U8
*cRole
,
1670 OMX_IN OMX_U32 nIndex
)
1672 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1673 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1674 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1679 if ((hComponent
== NULL
) || (cRole
== NULL
)) {
1680 ret
= OMX_ErrorBadParameter
;
1683 if (nIndex
!= (MAX_COMPONENT_ROLE_NUM
- 1)) {
1684 ret
= OMX_ErrorNoMore
;
1687 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1688 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1689 if (ret
!= OMX_ErrorNone
) {
1692 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1693 ret
= OMX_ErrorBadParameter
;
1696 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1697 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1698 ret
= OMX_ErrorInvalidState
;
1702 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1703 if (codecType
== CODEC_TYPE_MPEG4
)
1704 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
);
1706 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
);
1715 OMX_ERRORTYPE
Exynos_Mpeg4Dec_Init(OMX_COMPONENTTYPE
*pOMXComponent
)
1717 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1718 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1719 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1720 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1721 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1722 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
1723 OMX_PTR hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1725 ExynosVideoDecOps
*pDecOps
= NULL
;
1726 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
1727 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
1729 CSC_METHOD csc_method
= CSC_METHOD_SW
;
1734 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
= OMX_FALSE
;
1735 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
= OMX_FALSE
;
1736 pExynosComponent
->bUseFlagEOF
= OMX_TRUE
;
1737 pExynosComponent
->bSaveFlagEOS
= OMX_FALSE
;
1738 pExynosComponent
->bBehaviorEOS
= OMX_FALSE
;
1740 /* H.264 Codec Open */
1741 ret
= Mpeg4CodecOpen(pMpeg4Dec
);
1742 if (ret
!= OMX_ErrorNone
) {
1746 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1747 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1748 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1750 if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1751 OMX_U32 nPlaneSize
[MFC_INPUT_BUFFER_PLANE
] = {DEFAULT_MFC_INPUT_BUFFER_SIZE
};
1752 Exynos_OSAL_SemaphoreCreate(&pExynosInputPort
->codecSemID
);
1753 Exynos_OSAL_QueueCreate(&pExynosInputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1754 ret
= Exynos_Allocate_CodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
, MFC_INPUT_BUFFER_NUM_MAX
, nPlaneSize
);
1755 if (ret
!= OMX_ErrorNone
)
1758 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++)
1759 Exynos_CodecBufferEnQueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoDec
->pMFCDecInputBuffer
[i
]);
1760 } else if (pExynosInputPort
->bufferProcessType
== BUFFER_SHARE
) {
1764 /* Does not require any actions. */
1767 if ((pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1768 Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort
->codecSemID
);
1769 Exynos_OSAL_QueueCreate(&pExynosOutputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1770 } else if (pExynosOutputPort
->bufferProcessType
== BUFFER_SHARE
) {
1774 /* Does not require any actions. */
1777 pMpeg4Dec
->bSourceStart
= OMX_FALSE
;
1778 Exynos_OSAL_SignalCreate(&pMpeg4Dec
->hSourceStartEvent
);
1779 pMpeg4Dec
->bDestinationStart
= OMX_FALSE
;
1780 Exynos_OSAL_SignalCreate(&pMpeg4Dec
->hDestinationStartEvent
);
1782 Exynos_OSAL_Memset(pExynosComponent
->timeStamp
, -19771003, sizeof(OMX_TICKS
) * MAX_TIMESTAMP
);
1783 Exynos_OSAL_Memset(pExynosComponent
->nFlags
, 0, sizeof(OMX_U32
) * MAX_FLAGS
);
1784 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
= 0;
1785 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
= 0;
1787 pExynosComponent
->getAllDelayBuffer
= OMX_FALSE
;
1789 #if 0//defined(USE_CSC_GSCALER)
1790 csc_method
= CSC_METHOD_HW
; //in case of Use ION buffer.
1792 pVideoDec
->csc_handle
= csc_init(csc_method
);
1793 if (pVideoDec
->csc_handle
== NULL
) {
1794 ret
= OMX_ErrorInsufficientResources
;
1797 pVideoDec
->csc_set_format
= OMX_FALSE
;
1806 OMX_ERRORTYPE
Exynos_Mpeg4Dec_Terminate(OMX_COMPONENTTYPE
*pOMXComponent
)
1808 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1809 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1810 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1811 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1812 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1813 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1814 OMX_PTR hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1816 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1817 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1818 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1824 if (pVideoDec
->csc_handle
!= NULL
) {
1825 csc_deinit(pVideoDec
->csc_handle
);
1826 pVideoDec
->csc_handle
= NULL
;
1829 Exynos_OSAL_SignalTerminate(pMpeg4Dec
->hDestinationStartEvent
);
1830 pMpeg4Dec
->hDestinationStartEvent
= NULL
;
1831 pMpeg4Dec
->bDestinationStart
= OMX_FALSE
;
1832 Exynos_OSAL_SignalTerminate(pMpeg4Dec
->hSourceStartEvent
);
1833 pMpeg4Dec
->hSourceStartEvent
= NULL
;
1834 pMpeg4Dec
->bSourceStart
= OMX_FALSE
;
1836 if ((pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1837 Exynos_Free_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
);
1838 Exynos_OSAL_QueueTerminate(&pExynosOutputPort
->codecBufferQ
);
1839 Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort
->codecSemID
);
1840 } else if (pExynosOutputPort
->bufferProcessType
== BUFFER_SHARE
) {
1844 /* Does not require any actions. */
1847 if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1848 Exynos_Free_CodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
);
1849 Exynos_OSAL_QueueTerminate(&pExynosInputPort
->codecBufferQ
);
1850 Exynos_OSAL_SemaphoreTerminate(pExynosInputPort
->codecSemID
);
1851 } else if (pExynosInputPort
->bufferProcessType
== BUFFER_SHARE
) {
1855 /* Does not require any actions. */
1857 Mpeg4CodecClose(pMpeg4Dec
);
1859 Exynos_ResetAllPortConfig(pOMXComponent
);
1867 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SrcIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
1869 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1870 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1871 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1872 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1873 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1874 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1875 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1876 OMX_U32 oneFrameSize
= pSrcInputData
->dataLen
;
1877 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1878 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1879 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1880 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
1885 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
== OMX_FALSE
) {
1886 ret
= Mpeg4CodecSrcSetup(pOMXComponent
, pSrcInputData
);
1889 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
== OMX_FALSE
) {
1890 ret
= Mpeg4CodecDstSetup(pOMXComponent
);
1893 if ((Check_Stream_StartCode(pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
, oneFrameSize
, pMpeg4Dec
->hMFCMpeg4Handle
.codecType
) == OMX_TRUE
) ||
1894 ((pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)) {
1895 pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
] = pSrcInputData
->timeStamp
;
1896 pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
] = pSrcInputData
->nFlags
;
1897 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "input timestamp %lld us (%.2f secs), Tag: %d, nFlags: 0x%x", pSrcInputData
->timeStamp
, pSrcInputData
->timeStamp
/ 1E6
, pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
, pSrcInputData
->nFlags
);
1898 pDecOps
->Set_FrameTag(hMFCHandle
, pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
);
1899 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
++;
1900 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
%= MAX_TIMESTAMP
;
1902 /* queue work for input buffer */
1903 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "oneFrameSize: %d, bufferHeader: 0x%x, dataBuffer: 0x%x", oneFrameSize
, pSrcInputData
->bufferHeader
, pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
);
1904 codecReturn
= pInbufOps
->Enqueue(hMFCHandle
, (unsigned char **)&pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
,
1905 (unsigned int *)&oneFrameSize
, MFC_INPUT_BUFFER_PLANE
, pSrcInputData
->bufferHeader
);
1906 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1907 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1908 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
1911 Mpeg4CodecStart(pOMXComponent
, INPUT_PORT_INDEX
);
1912 if (pMpeg4Dec
->bSourceStart
== OMX_FALSE
) {
1913 pMpeg4Dec
->bSourceStart
= OMX_TRUE
;
1914 Exynos_OSAL_SignalSet(pMpeg4Dec
->hSourceStartEvent
);
1915 Exynos_OSAL_SleepMillisec(0);
1917 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
1918 pMpeg4Dec
->bDestinationStart
= OMX_TRUE
;
1919 Exynos_OSAL_SignalSet(pMpeg4Dec
->hDestinationStartEvent
);
1920 Exynos_OSAL_SleepMillisec(0);
1924 ret
= OMX_ErrorNone
;
1932 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SrcOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
1934 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1935 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1936 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1937 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1938 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1939 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1940 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1941 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1942 ExynosVideoBuffer
*pVideoBuffer
;
1946 pVideoBuffer
= pInbufOps
->Dequeue(hMFCHandle
);
1948 pSrcOutputData
->dataLen
= 0;
1949 pSrcOutputData
->usedDataLen
= 0;
1950 pSrcOutputData
->remainDataLen
= 0;
1951 pSrcOutputData
->nFlags
= 0;
1952 pSrcOutputData
->timeStamp
= 0;
1954 if (pVideoBuffer
== NULL
) {
1955 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= NULL
;
1956 pSrcOutputData
->allocSize
= 0;
1957 pSrcOutputData
->pPrivate
= NULL
;
1958 pSrcOutputData
->bufferHeader
= NULL
;
1960 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= pVideoBuffer
->planes
[0].addr
;
1961 pSrcOutputData
->buffer
.singlePlaneBuffer
.fd
= pVideoBuffer
->planes
[0].fd
;
1962 pSrcOutputData
->allocSize
= pVideoBuffer
->planes
[0].allocSize
;
1964 if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1966 while (pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
!= pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[0]) {
1967 if (i
>= MFC_INPUT_BUFFER_NUM_MAX
) {
1968 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Can not find buffer");
1969 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1974 pVideoDec
->pMFCDecInputBuffer
[i
]->dataSize
= 0;
1975 pSrcOutputData
->pPrivate
= pVideoDec
->pMFCDecInputBuffer
[i
];
1978 /* For Share Buffer */
1979 pSrcOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
1982 ret
= OMX_ErrorNone
;
1990 OMX_ERRORTYPE
Exynos_Mpeg4Dec_DstIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
1992 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1993 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1994 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1995 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1996 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1997 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1998 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1999 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
2000 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0,};
2001 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
2005 if (pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0] == NULL
) {
2006 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to find input buffer");
2007 ret
= OMX_ErrorBadParameter
;
2011 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x, FD[0]:%d, FD[1]:%d", __FUNCTION__
, __LINE__
,
2012 pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0],
2013 pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[1],
2014 pDstInputData
->buffer
.multiPlaneBuffer
.fd
[0],
2015 pDstInputData
->buffer
.multiPlaneBuffer
.fd
[1]);
2017 OMX_U32 nAllocLen
[VIDEO_BUFFER_MAX_PLANES
] = {0, 0, 0};
2018 nAllocLen
[0] = pExynosOutputPort
->portDefinition
.format
.video
.nFrameWidth
* pExynosOutputPort
->portDefinition
.format
.video
.nFrameHeight
;
2019 nAllocLen
[1] = pExynosOutputPort
->portDefinition
.format
.video
.nFrameWidth
* pExynosOutputPort
->portDefinition
.format
.video
.nFrameHeight
/ 2;
2021 codecReturn
= pOutbufOps
->ExtensionEnqueue(hMFCHandle
,
2022 (unsigned char **)pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
,
2023 (unsigned int **)pDstInputData
->buffer
.multiPlaneBuffer
.fd
,
2024 (unsigned int *)nAllocLen
, (unsigned int *)dataLen
,
2025 MFC_OUTPUT_BUFFER_PLANE
, pDstInputData
->bufferHeader
);
2026 if (codecReturn
!= VIDEO_ERROR_NONE
) {
2027 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
2028 if (codecReturn
!= VIDEO_ERROR_WRONGBUFFERSIZE
) {
2029 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
2030 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
2034 Mpeg4CodecStart(pOMXComponent
, OUTPUT_PORT_INDEX
);
2036 ret
= OMX_ErrorNone
;
2044 OMX_ERRORTYPE
Exynos_Mpeg4Dec_DstOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
2046 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2047 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2048 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2049 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2050 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
2051 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2052 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2053 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
2054 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
2055 ExynosVideoBuffer
*pVideoBuffer
;
2056 ExynosVideoBuffer videoBuffer
;
2057 ExynosVideoFrameStatusType displayStatus
= VIDEO_FRAME_STATUS_UNKNOWN
;
2058 ExynosVideoGeometry
*bufferGeometry
;
2059 DECODE_CODEC_EXTRA_BUFFERINFO
*pBufferInfo
= NULL
;
2060 OMX_S32 indexTimestamp
= 0;
2065 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
2066 ret
= OMX_ErrorNone
;
2071 Exynos_OSAL_Memset(&videoBuffer
, 0, sizeof(ExynosVideoBuffer
));
2072 if (pOutbufOps
->ExtensionDequeue(hMFCHandle
, &videoBuffer
) == VIDEO_ERROR_NONE
) {
2073 pVideoBuffer
= &videoBuffer
;
2075 pVideoBuffer
= NULL
;
2076 ret
= OMX_ErrorNone
;
2079 displayStatus
= pVideoBuffer
->displayStatus
;
2080 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "displayStatus: 0x%x", displayStatus
);
2082 if ((displayStatus
== VIDEO_FRAME_STATUS_DISPLAY_DECODING
) ||
2083 (displayStatus
== VIDEO_FRAME_STATUS_DISPLAY_ONLY
) ||
2084 (displayStatus
== VIDEO_FRAME_STATUS_CHANGE_RESOL
) ||
2085 (displayStatus
== VIDEO_FRAME_STATUS_DECODING_FINISHED
) ||
2086 (CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2087 if (pVideoBuffer
!= NULL
) {
2088 ret
= OMX_ErrorNone
;
2091 ret
= OMX_ErrorUndefined
;
2097 if ((pVideoDec
->bThumbnailMode
== OMX_FALSE
) &&
2098 (displayStatus
== VIDEO_FRAME_STATUS_CHANGE_RESOL
)) {
2099 if (pVideoDec
->bReconfigDPB
!= OMX_TRUE
) {
2100 pExynosOutputPort
->exceptionFlag
= NEED_PORT_FLUSH
;
2101 pVideoDec
->bReconfigDPB
= OMX_TRUE
;
2102 Mpeg4CodecCheckResolutionChange(pOMXComponent
);
2103 pVideoDec
->csc_set_format
= OMX_FALSE
;
2105 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "VIDEO_FRAME_STATUS_CHANGE_RESOL");
2106 ret
= OMX_ErrorNone
;
2110 if (ret
!= OMX_ErrorNone
)
2113 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
++;
2114 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
%= MAX_TIMESTAMP
;
2116 pDstOutputData
->allocSize
= pDstOutputData
->dataLen
= 0;
2117 for (plane
= 0; plane
< MFC_OUTPUT_BUFFER_PLANE
; plane
++) {
2118 pDstOutputData
->buffer
.multiPlaneBuffer
.dataBuffer
[plane
] = pVideoBuffer
->planes
[plane
].addr
;
2119 pDstOutputData
->buffer
.multiPlaneBuffer
.fd
[plane
] = pVideoBuffer
->planes
[plane
].fd
;
2120 pDstOutputData
->allocSize
+= pVideoBuffer
->planes
[plane
].allocSize
;
2121 pDstOutputData
->dataLen
+= pVideoBuffer
->planes
[plane
].dataSize
;
2123 pDstOutputData
->usedDataLen
= 0;
2124 pDstOutputData
->pPrivate
= pVideoBuffer
;
2125 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
2127 pDstOutputData
->pPrivate
= NULL
;
2128 for (i
= 0; i
< MFC_OUTPUT_BUFFER_NUM_MAX
; i
++) {
2129 if (pDstOutputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0] ==
2130 pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[0]) {
2131 pDstOutputData
->pPrivate
= pVideoDec
->pMFCDecOutputBuffer
[i
];
2132 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x, FD[0]:%d, FD[1]:%d", __FUNCTION__
, __LINE__
,
2133 pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[0],
2134 pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[1],
2135 pVideoDec
->pMFCDecOutputBuffer
[i
]->fd
[0],
2136 pVideoDec
->pMFCDecOutputBuffer
[i
]->fd
[1]);
2141 if (pDstOutputData
->pPrivate
== NULL
) {
2142 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Can not find buffer");
2143 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
2147 /* For Share Buffer */
2148 pDstOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
2150 pBufferInfo
= (DECODE_CODEC_EXTRA_BUFFERINFO
*)pDstOutputData
->extInfo
;
2151 bufferGeometry
= &pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
;
2152 pBufferInfo
->imageWidth
= bufferGeometry
->nFrameWidth
;
2153 pBufferInfo
->imageHeight
= bufferGeometry
->nFrameHeight
;
2154 Exynos_OSAL_Memcpy(&pBufferInfo
->PDSB
, &pVideoBuffer
->PDSB
, sizeof(PrivateDataShareBuffer
));
2155 switch (bufferGeometry
->eColorFormat
) {
2156 case VIDEO_COLORFORMAT_NV12
:
2157 pBufferInfo
->ColorFormat
= OMX_COLOR_FormatYUV420SemiPlanar
;
2159 case VIDEO_COLORFORMAT_NV12_TILED
:
2161 pBufferInfo
->ColorFormat
= OMX_SEC_COLOR_FormatNV12Tiled
;
2165 indexTimestamp
= pDecOps
->Get_FrameTag(hMFCHandle
);
2166 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "out indexTimestamp: %d", indexTimestamp
);
2167 if ((indexTimestamp
< 0) || (indexTimestamp
>= MAX_TIMESTAMP
)) {
2168 if ((pExynosComponent
->checkTimeStamp
.needSetStartTimeStamp
!= OMX_TRUE
) &&
2169 (pExynosComponent
->checkTimeStamp
.needCheckStartTimeStamp
!= OMX_TRUE
)) {
2170 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2171 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2172 pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
] = 0x00;
2173 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "missing out indexTimestamp: %d", indexTimestamp
);
2175 pDstOutputData
->timeStamp
= 0x00;
2176 pDstOutputData
->nFlags
= 0x00;
2179 /* For timestamp correction. if mfc support frametype detect */
2180 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "disp_pic_frame_type: %d", pVideoBuffer
->frameType
);
2181 #ifdef NEED_TIMESTAMP_REORDER
2182 if ((pVideoBuffer
->frameType
== VIDEO_FRAME_I
)) {
2183 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
2184 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
2185 pExynosComponent
->nFlags
[indexTimestamp
] = 0x00;
2186 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
= indexTimestamp
;
2188 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2189 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2190 pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
] = 0x00;
2193 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
2194 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
2195 pExynosComponent
->nFlags
[indexTimestamp
] = 0x00;
2197 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "timestamp %lld us (%.2f secs), indexTimestamp: %d, nFlags: 0x%x", pDstOutputData
->timeStamp
, pDstOutputData
->timeStamp
/ 1E6
, indexTimestamp
, pDstOutputData
->nFlags
);
2200 if ((displayStatus
== VIDEO_FRAME_STATUS_DECODING_FINISHED
) ||
2201 ((pDstOutputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)) {
2202 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "displayStatus:%d, nFlags0x%x", displayStatus
, pDstOutputData
->nFlags
);
2203 pDstOutputData
->remainDataLen
= 0;
2204 if (((pDstOutputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
) &&
2205 (pExynosComponent
->bBehaviorEOS
== OMX_TRUE
)) {
2206 pDstOutputData
->remainDataLen
= bufferGeometry
->nFrameWidth
* bufferGeometry
->nFrameHeight
* 3 / 2;
2207 pExynosComponent
->bBehaviorEOS
= OMX_FALSE
;
2210 pDstOutputData
->remainDataLen
= bufferGeometry
->nFrameWidth
* bufferGeometry
->nFrameHeight
* 3 / 2;
2213 ret
= OMX_ErrorNone
;
2221 OMX_ERRORTYPE
Exynos_Mpeg4Dec_srcInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
2223 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2224 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2225 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2226 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2230 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2231 ret
= OMX_ErrorNone
;
2234 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2235 ret
= OMX_ErrorNone
;
2239 ret
= Exynos_Mpeg4Dec_SrcIn(pOMXComponent
, pSrcInputData
);
2240 if ((ret
!= OMX_ErrorNone
) && (ret
!= OMX_ErrorInputDataDecodeYet
)) {
2241 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2242 pExynosComponent
->callbackData
,
2243 OMX_EventError
, ret
, 0, NULL
);
2252 OMX_ERRORTYPE
Exynos_Mpeg4Dec_srcOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
2254 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2255 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2256 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2257 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2261 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2262 ret
= OMX_ErrorNone
;
2266 if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
2267 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2268 ret
= OMX_ErrorNone
;
2272 if ((pMpeg4Dec
->bSourceStart
== OMX_FALSE
) &&
2273 (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort
))) {
2274 Exynos_OSAL_SignalWait(pMpeg4Dec
->hSourceStartEvent
, DEF_MAX_WAIT_TIME
);
2275 Exynos_OSAL_SignalReset(pMpeg4Dec
->hSourceStartEvent
);
2278 ret
= Exynos_Mpeg4Dec_SrcOut(pOMXComponent
, pSrcOutputData
);
2279 if ((ret
!= OMX_ErrorNone
) &&
2280 (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2281 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2282 pExynosComponent
->callbackData
,
2283 OMX_EventError
, ret
, 0, NULL
);
2292 OMX_ERRORTYPE
Exynos_Mpeg4Dec_dstInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
2294 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2295 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2296 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2297 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2301 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2302 ret
= OMX_ErrorNone
;
2305 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2306 ret
= OMX_ErrorNone
;
2309 if (pExynosOutputPort
->bufferProcessType
== BUFFER_SHARE
) {
2310 if ((pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) &&
2311 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2312 Exynos_OSAL_SignalWait(pMpeg4Dec
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2313 Exynos_OSAL_SignalReset(pMpeg4Dec
->hDestinationStartEvent
);
2316 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
== OMX_TRUE
) {
2317 ret
= Exynos_Mpeg4Dec_DstIn(pOMXComponent
, pDstInputData
);
2318 if (ret
!= OMX_ErrorNone
) {
2319 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2320 pExynosComponent
->callbackData
,
2321 OMX_EventError
, ret
, 0, NULL
);
2331 OMX_ERRORTYPE
Exynos_Mpeg4Dec_dstOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
2333 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2334 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2335 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2336 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2340 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2341 ret
= OMX_ErrorNone
;
2344 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2345 ret
= OMX_ErrorNone
;
2349 if ((pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
2350 if ((pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) &&
2351 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2352 Exynos_OSAL_SignalWait(pMpeg4Dec
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2353 Exynos_OSAL_SignalReset(pMpeg4Dec
->hDestinationStartEvent
);
2356 ret
= Exynos_Mpeg4Dec_DstOut(pOMXComponent
, pDstOutputData
);
2357 if ((ret
!= OMX_ErrorNone
) &&
2358 (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2359 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2360 pExynosComponent
->callbackData
,
2361 OMX_EventError
, ret
, 0, NULL
);
2370 OSCL_EXPORT_REF OMX_ERRORTYPE
Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent
, OMX_STRING componentName
)
2372 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2373 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2374 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2375 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
2376 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
2377 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
2379 OMX_S32 codecType
= -1;
2383 if ((hComponent
== NULL
) || (componentName
== NULL
)) {
2384 ret
= OMX_ErrorBadParameter
;
2385 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, Line:%d", __LINE__
);
2388 if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_MPEG4_DEC
, componentName
) == 0) {
2389 codecType
= CODEC_TYPE_MPEG4
;
2390 } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H263_DEC
, componentName
) == 0) {
2391 codecType
= CODEC_TYPE_H263
;
2393 ret
= OMX_ErrorBadParameter
;
2394 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName
, __LINE__
);
2398 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2399 ret
= Exynos_OMX_VideoDecodeComponentInit(pOMXComponent
);
2400 if (ret
!= OMX_ErrorNone
) {
2401 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_Error, Line:%d", __LINE__
);
2404 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2405 pExynosComponent
->codecType
= HW_VIDEO_DEC_CODEC
;
2407 pExynosComponent
->componentName
= (OMX_STRING
)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE
);
2408 if (pExynosComponent
->componentName
== NULL
) {
2409 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2410 ret
= OMX_ErrorInsufficientResources
;
2411 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2414 Exynos_OSAL_Memset(pExynosComponent
->componentName
, 0, MAX_OMX_COMPONENT_NAME_SIZE
);
2416 pMpeg4Dec
= Exynos_OSAL_Malloc(sizeof(EXYNOS_MPEG4DEC_HANDLE
));
2417 if (pMpeg4Dec
== NULL
) {
2418 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2419 ret
= OMX_ErrorInsufficientResources
;
2420 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2423 Exynos_OSAL_Memset(pMpeg4Dec
, 0, sizeof(EXYNOS_MPEG4DEC_HANDLE
));
2424 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2425 pVideoDec
->hCodecHandle
= (OMX_HANDLETYPE
)pMpeg4Dec
;
2426 pMpeg4Dec
->hMFCMpeg4Handle
.codecType
= codecType
;
2428 if (codecType
== CODEC_TYPE_MPEG4
)
2429 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_MPEG4_DEC
);
2431 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_H263_DEC
);
2433 /* Set componentVersion */
2434 pExynosComponent
->componentVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2435 pExynosComponent
->componentVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2436 pExynosComponent
->componentVersion
.s
.nRevision
= REVISION_NUMBER
;
2437 pExynosComponent
->componentVersion
.s
.nStep
= STEP_NUMBER
;
2438 /* Set specVersion */
2439 pExynosComponent
->specVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2440 pExynosComponent
->specVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2441 pExynosComponent
->specVersion
.s
.nRevision
= REVISION_NUMBER
;
2442 pExynosComponent
->specVersion
.s
.nStep
= STEP_NUMBER
;
2445 pExynosPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2446 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2447 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2448 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2449 pExynosPort
->portDefinition
.format
.video
.nSliceHeight
= 0;
2450 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_INPUT_BUFFER_SIZE
;
2451 if (codecType
== CODEC_TYPE_MPEG4
) {
2452 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingMPEG4
;
2453 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2454 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "video/mpeg4");
2456 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingH263
;
2457 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2458 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "video/h263");
2460 pExynosPort
->portDefinition
.format
.video
.pNativeRender
= 0;
2461 pExynosPort
->portDefinition
.format
.video
.bFlagErrorConcealment
= OMX_FALSE
;
2462 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatUnused
;
2463 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2464 pExynosPort
->bufferProcessType
= BUFFER_SHARE
;
2465 pExynosPort
->portWayType
= WAY2_PORT
;
2468 pExynosPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2469 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2470 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2471 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2472 pExynosPort
->portDefinition
.format
.video
.nSliceHeight
= 0;
2473 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE
;
2474 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingUnused
;
2475 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2476 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "raw/video");
2477 pExynosPort
->portDefinition
.format
.video
.pNativeRender
= 0;
2478 pExynosPort
->portDefinition
.format
.video
.bFlagErrorConcealment
= OMX_FALSE
;
2479 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatYUV420Planar
;
2480 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2481 pExynosPort
->bufferProcessType
= BUFFER_COPY
| BUFFER_ANBSHARE
;
2482 pExynosPort
->portWayType
= WAY2_PORT
;
2484 if (codecType
== CODEC_TYPE_MPEG4
) {
2485 for(i
= 0; i
< ALL_PORT_NUM
; i
++) {
2486 INIT_SET_SIZE_VERSION(&pMpeg4Dec
->mpeg4Component
[i
], OMX_VIDEO_PARAM_MPEG4TYPE
);
2487 pMpeg4Dec
->mpeg4Component
[i
].nPortIndex
= i
;
2488 pMpeg4Dec
->mpeg4Component
[i
].eProfile
= OMX_VIDEO_MPEG4ProfileSimple
;
2489 pMpeg4Dec
->mpeg4Component
[i
].eLevel
= OMX_VIDEO_MPEG4Level3
;
2492 for(i
= 0; i
< ALL_PORT_NUM
; i
++) {
2493 INIT_SET_SIZE_VERSION(&pMpeg4Dec
->h263Component
[i
], OMX_VIDEO_PARAM_H263TYPE
);
2494 pMpeg4Dec
->h263Component
[i
].nPortIndex
= i
;
2495 pMpeg4Dec
->h263Component
[i
].eProfile
= OMX_VIDEO_H263ProfileBaseline
| OMX_VIDEO_H263ProfileISWV2
;
2496 pMpeg4Dec
->h263Component
[i
].eLevel
= OMX_VIDEO_H263Level45
;
2500 pOMXComponent
->GetParameter
= &Exynos_Mpeg4Dec_GetParameter
;
2501 pOMXComponent
->SetParameter
= &Exynos_Mpeg4Dec_SetParameter
;
2502 pOMXComponent
->GetConfig
= &Exynos_Mpeg4Dec_GetConfig
;
2503 pOMXComponent
->SetConfig
= &Exynos_Mpeg4Dec_SetConfig
;
2504 pOMXComponent
->GetExtensionIndex
= &Exynos_Mpeg4Dec_GetExtensionIndex
;
2505 pOMXComponent
->ComponentRoleEnum
= &Exynos_Mpeg4Dec_ComponentRoleEnum
;
2506 pOMXComponent
->ComponentDeInit
= &Exynos_OMX_ComponentDeinit
;
2508 pExynosComponent
->exynos_codec_componentInit
= &Exynos_Mpeg4Dec_Init
;
2509 pExynosComponent
->exynos_codec_componentTerminate
= &Exynos_Mpeg4Dec_Terminate
;
2511 pVideoDec
->exynos_codec_srcInputProcess
= &Exynos_Mpeg4Dec_srcInputBufferProcess
;
2512 pVideoDec
->exynos_codec_srcOutputProcess
= &Exynos_Mpeg4Dec_srcOutputBufferProcess
;
2513 pVideoDec
->exynos_codec_dstInputProcess
= &Exynos_Mpeg4Dec_dstInputBufferProcess
;
2514 pVideoDec
->exynos_codec_dstOutputProcess
= &Exynos_Mpeg4Dec_dstOutputBufferProcess
;
2516 pVideoDec
->exynos_codec_start
= &Mpeg4CodecStart
;
2517 pVideoDec
->exynos_codec_stop
= &Mpeg4CodecStop
;
2518 pVideoDec
->exynos_codec_bufferProcessRun
= &Mpeg4CodecOutputBufferProcessRun
;
2519 pVideoDec
->exynos_codec_enqueueAllBuffer
= &Mpeg4CodecEnQueueAllBuffer
;
2521 if (codecType
== CODEC_TYPE_MPEG4
)
2522 pVideoDec
->exynos_checkInputFrame
= &Check_Mpeg4_Frame
;
2524 pVideoDec
->exynos_checkInputFrame
= &Check_H263_Frame
;
2526 pVideoDec
->exynos_codec_getCodecInputPrivateData
= &GetCodecInputPrivateData
;
2527 pVideoDec
->exynos_codec_getCodecOutputPrivateData
= &GetCodecOutputPrivateData
;
2528 pVideoDec
->exynos_codec_reconfigAllBuffers
= &Mpeg4CodecReconfigAllBuffers
;
2530 pVideoDec
->hSharedMemory
= Exynos_OSAL_SharedMemory_Open();
2531 if (pVideoDec
->hSharedMemory
== NULL
) {
2532 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2533 Exynos_OSAL_Free(pMpeg4Dec
);
2534 pMpeg4Dec
= ((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
= NULL
;
2535 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2536 ret
= OMX_ErrorInsufficientResources
;
2540 pExynosComponent
->currentState
= OMX_StateLoaded
;
2542 ret
= OMX_ErrorNone
;
2550 OMX_ERRORTYPE
Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent
)
2552 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2553 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2554 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2555 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
2556 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
2560 if (hComponent
== NULL
) {
2561 ret
= OMX_ErrorBadParameter
;
2564 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2565 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2566 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2568 Exynos_OSAL_SharedMemory_Close(pVideoDec
->hSharedMemory
);
2570 Exynos_OSAL_Free(pExynosComponent
->componentName
);
2571 pExynosComponent
->componentName
= NULL
;
2573 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
2574 if (pMpeg4Dec
!= NULL
) {
2575 Exynos_OSAL_Free(pMpeg4Dec
);
2576 pMpeg4Dec
= pVideoDec
->hCodecHandle
= NULL
;
2579 ret
= Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2580 if (ret
!= OMX_ErrorNone
) {
2584 ret
= OMX_ErrorNone
;