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_H264dec.c
21 * @author SeungBeom Kim (sbcrux.kim@samsung.com)
31 #include "Exynos_OMX_Macros.h"
32 #include "Exynos_OMX_Basecomponent.h"
33 #include "Exynos_OMX_Baseport.h"
34 #include "Exynos_OMX_Vdec.h"
35 #include "Exynos_OSAL_ETC.h"
36 #include "Exynos_OSAL_Semaphore.h"
37 #include "Exynos_OSAL_Thread.h"
38 #include "library_register.h"
39 #include "Exynos_OMX_H264dec.h"
40 #include "ExynosVideoApi.h"
41 #include "Exynos_OSAL_SharedMemory.h"
42 #include "Exynos_OSAL_Event.h"
44 #include <mm_ta/mm_ta.h>
47 #include "Exynos_OSAL_Platform_Specific.h"
50 /* To use CSC_METHOD_HW in EXYNOS OMX, gralloc should allocate physical memory using FIMC */
51 /* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */
55 #define EXYNOS_LOG_TAG "EXYNOS_H264_DEC"
56 #define EXYNOS_LOG_OFF
57 //#define EXYNOS_TRACE_ON
58 #include "Exynos_OSAL_Log.h"
60 #define H264_DEC_NUM_OF_EXTRA_BUFFERS 7
62 //#define ADD_SPS_PPS_I_FRAME
63 //#define FULL_FRAME_SEARCH
65 /* H.264 Decoder Supported Levels & profiles */
66 EXYNOS_OMX_VIDEO_PROFILELEVEL supportedAVCProfileLevels[] ={
67 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1},
68 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1b},
69 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel11},
70 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel12},
71 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13},
72 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel2},
73 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel21},
74 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel22},
75 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel3},
76 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31},
77 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel32},
78 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4},
79 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel41},
80 {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel42},
82 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1},
83 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1b},
84 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel11},
85 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel12},
86 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel13},
87 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel2},
88 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel21},
89 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel22},
90 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel3},
91 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel31},
92 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel32},
93 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4},
94 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel41},
95 {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel42},
97 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1},
98 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1b},
99 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel11},
100 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel12},
101 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel13},
102 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel2},
103 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel21},
104 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel22},
105 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel3},
106 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31},
107 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32},
108 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4},
109 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel41},
110 {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel42}};
112 static OMX_ERRORTYPE GetCodecInputPrivateData(OMX_PTR codecBuffer, void *pVirtAddr, OMX_U32 *dataSize)
114 OMX_ERRORTYPE ret = OMX_ErrorNone;
120 static OMX_ERRORTYPE GetCodecOutputPrivateData(OMX_PTR codecBuffer, void *addr[], int size[])
122 OMX_ERRORTYPE ret = OMX_ErrorNone;
123 ExynosVideoBuffer *pCodecBuffer;
125 if (codecBuffer == NULL) {
126 ret = OMX_ErrorBadParameter;
130 pCodecBuffer = (ExynosVideoBuffer *)codecBuffer;
133 addr[0] = pCodecBuffer->planes[0].addr;
134 addr[1] = pCodecBuffer->planes[1].addr;
135 addr[2] = pCodecBuffer->planes[2].addr;
139 size[0] = pCodecBuffer->planes[0].allocSize;
140 size[1] = pCodecBuffer->planes[1].allocSize;
141 size[2] = pCodecBuffer->planes[2].allocSize;
148 int Check_H264_Frame(
149 OMX_U8 *pInputStream,
152 OMX_BOOL bPreviousFrameEOF,
153 OMX_BOOL *pbEndOfFrame)
155 OMX_U32 preFourByte = (OMX_U32)-1;
156 int accessUnitSize = 0;
157 int frameTypeBoundary = 0;
158 int nextNaluSize = 0;
161 if (bPreviousFrameEOF == OMX_TRUE)
167 int inputOneByte = 0;
169 if (accessUnitSize == (int)buffSize)
172 inputOneByte = *(pInputStream++);
175 if (preFourByte == 0x00000001 || (preFourByte << 8) == 0x00000100) {
176 int naluType = inputOneByte & 0x1F;
178 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "NaluType : %d", naluType);
179 if (naluStart == 0) {
180 #ifdef ADD_SPS_PPS_I_FRAME
181 if (naluType == 1 || naluType == 5)
183 if (naluType == 1 || naluType == 5 || naluType == 7 || naluType == 8)
188 frameTypeBoundary = (8 - naluType) & (naluType - 10); //AUD(9)
191 frameTypeBoundary = -2;
193 if (naluType == 1 || naluType == 5) {
194 if (accessUnitSize == (int)buffSize) {
198 inputOneByte = *pInputStream++;
201 if (inputOneByte >= 0x80)
202 frameTypeBoundary = -1;
204 if (frameTypeBoundary < 0) {
210 preFourByte = (preFourByte << 8) + inputOneByte;
213 *pbEndOfFrame = OMX_TRUE;
215 if (frameTypeBoundary == -1)
217 if (preFourByte != 0x00000001)
219 return (accessUnitSize + nextNaluSize);
222 *pbEndOfFrame = OMX_FALSE;
224 return accessUnitSize;
227 static OMX_BOOL Check_H264_StartCode(
228 OMX_U8 *pInputStream,
231 if (streamSize < 4) {
235 if ((pInputStream[0] == 0x00) &&
236 (pInputStream[1] == 0x00) &&
237 (pInputStream[2] == 0x00) &&
238 (pInputStream[3] != 0x00) &&
239 ((pInputStream[3] >> 3) == 0x00)) {
240 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "NaluType : %d, 0x%x, 0x%x, 0x%x", (pInputStream[4] & 0x1F), pInputStream[3], pInputStream[4], pInputStream[5]);
242 } else if ((pInputStream[0] == 0x00) &&
243 (pInputStream[1] == 0x00) &&
244 (pInputStream[2] != 0x00) &&
245 ((pInputStream[2] >> 3) == 0x00)) {
246 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "NaluType : %d, 0x%x, 0x%x, 0x%x", (pInputStream[3] & 0x1F), pInputStream[2], pInputStream[3], pInputStream[4]);
253 OMX_ERRORTYPE H264CodecOpen(EXYNOS_H264DEC_HANDLE *pH264Dec)
255 OMX_ERRORTYPE ret = OMX_ErrorNone;
256 ExynosVideoDecOps *pDecOps = NULL;
257 ExynosVideoDecBufferOps *pInbufOps = NULL;
258 ExynosVideoDecBufferOps *pOutbufOps = NULL;
262 if (pH264Dec == NULL) {
263 ret = OMX_ErrorBadParameter;
264 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
268 /* alloc ops structure */
269 pDecOps = (ExynosVideoDecOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecOps));
270 pInbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecBufferOps));
271 pOutbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecBufferOps));
273 if ((pDecOps == NULL) || (pInbufOps == NULL) || (pOutbufOps == NULL)) {
274 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate decoder ops buffer");
275 ret = OMX_ErrorInsufficientResources;
279 pH264Dec->hMFCH264Handle.pDecOps = pDecOps;
280 pH264Dec->hMFCH264Handle.pInbufOps = pInbufOps;
281 pH264Dec->hMFCH264Handle.pOutbufOps = pOutbufOps;
283 /* function pointer mapping */
284 pDecOps->nSize = sizeof(ExynosVideoDecOps);
285 pInbufOps->nSize = sizeof(ExynosVideoDecBufferOps);
286 pOutbufOps->nSize = sizeof(ExynosVideoDecBufferOps);
288 Exynos_Video_Register_Decoder(pDecOps, pInbufOps, pOutbufOps);
290 /* check mandatory functions for decoder ops */
291 if ((pDecOps->Init == NULL) || (pDecOps->Finalize == NULL) ||
292 (pDecOps->Get_ActualBufferCount == NULL) || (pDecOps->Set_FrameTag == NULL) ||
293 #ifdef USE_S3D_SUPPORT
294 (pDecOps->Enable_SEIParsing == NULL) || (pDecOps->Get_FramePackingInfo == NULL) ||
296 (pDecOps->Get_FrameTag == NULL)) {
297 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
298 ret = OMX_ErrorInsufficientResources;
302 /* check mandatory functions for buffer ops */
303 if ((pInbufOps->Setup == NULL) || (pOutbufOps->Setup == NULL) ||
304 (pInbufOps->Run == NULL) || (pOutbufOps->Run == NULL) ||
305 (pInbufOps->Stop == NULL) || (pOutbufOps->Stop == NULL) ||
306 (pInbufOps->Enqueue == NULL) || (pOutbufOps->Enqueue == NULL) ||
307 (pInbufOps->Dequeue == NULL) || (pOutbufOps->Dequeue == NULL)) {
308 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
309 ret = OMX_ErrorInsufficientResources;
313 /* alloc context, open, querycap */
314 if (pH264Dec->hMFCH264Handle.bShareableBuf == OMX_TRUE) {
316 pH264Dec->hMFCH264Handle.hMFCHandle = pH264Dec->hMFCH264Handle.pDecOps->Init(V4L2_MEMORY_DMABUF);
318 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s :%d V4L2_MEMORY_USERPTR", __FUNCTION__, __LINE__);
319 pH264Dec->hMFCH264Handle.hMFCHandle = pH264Dec->hMFCH264Handle.pDecOps->Init(V4L2_MEMORY_USERPTR);
322 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s :%d V4L2_MEMORY_DMABUF", __FUNCTION__, __LINE__);
323 pH264Dec->hMFCH264Handle.hMFCHandle = pH264Dec->hMFCH264Handle.pDecOps->Init(V4L2_MEMORY_DMABUF);
325 if (pH264Dec->hMFCH264Handle.hMFCHandle == NULL) {
326 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate context buffer");
327 ret = OMX_ErrorInsufficientResources;
331 #ifdef USE_S3D_SUPPORT
332 /*S3D: Enable SEI parsing to check Frame Packing */
333 if (pDecOps->Enable_SEIParsing(pH264Dec->hMFCH264Handle.hMFCHandle) != VIDEO_ERROR_NONE) {
334 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Enable SEI Parsing");
335 ret = OMX_ErrorInsufficientResources;
343 if (ret != OMX_ErrorNone) {
344 if (pDecOps != NULL) {
345 Exynos_OSAL_Free(pDecOps);
346 pH264Dec->hMFCH264Handle.pDecOps = NULL;
348 if (pInbufOps != NULL) {
349 Exynos_OSAL_Free(pInbufOps);
350 pH264Dec->hMFCH264Handle.pInbufOps = NULL;
352 if (pOutbufOps != NULL) {
353 Exynos_OSAL_Free(pOutbufOps);
354 pH264Dec->hMFCH264Handle.pOutbufOps = NULL;
363 OMX_ERRORTYPE H264CodecClose(EXYNOS_H264DEC_HANDLE *pH264Dec)
365 OMX_ERRORTYPE ret = OMX_ErrorNone;
366 void *hMFCHandle = NULL;
367 ExynosVideoDecOps *pDecOps = NULL;
368 ExynosVideoDecBufferOps *pInbufOps = NULL;
369 ExynosVideoDecBufferOps *pOutbufOps = NULL;
373 if (pH264Dec == NULL) {
374 ret = OMX_ErrorBadParameter;
378 hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
379 pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
380 pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
381 pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
383 if (hMFCHandle != NULL) {
384 pDecOps->Finalize(hMFCHandle);
385 pH264Dec->hMFCH264Handle.hMFCHandle = NULL;
387 if (pOutbufOps != NULL) {
388 Exynos_OSAL_Free(pOutbufOps);
389 pH264Dec->hMFCH264Handle.pOutbufOps = NULL;
391 if (pInbufOps != NULL) {
392 Exynos_OSAL_Free(pInbufOps);
393 pH264Dec->hMFCH264Handle.pInbufOps = NULL;
395 if (pDecOps != NULL) {
396 Exynos_OSAL_Free(pDecOps);
397 pH264Dec->hMFCH264Handle.pDecOps = NULL;
408 OMX_ERRORTYPE H264CodecStart(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
410 OMX_ERRORTYPE ret = OMX_ErrorNone;
411 void *hMFCHandle = NULL;
412 ExynosVideoDecOps *pDecOps = NULL;
413 ExynosVideoDecBufferOps *pInbufOps = NULL;
414 ExynosVideoDecBufferOps *pOutbufOps = NULL;
415 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
416 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
420 if (pOMXComponent == NULL) {
421 ret = OMX_ErrorBadParameter;
425 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle;
426 if (pVideoDec == NULL) {
427 ret = OMX_ErrorBadParameter;
431 pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
432 if (pH264Dec == NULL) {
433 ret = OMX_ErrorBadParameter;
437 hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
438 pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
439 pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
440 pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
442 if (nPortIndex == INPUT_PORT_INDEX)
443 pInbufOps->Run(hMFCHandle);
444 else if (nPortIndex == OUTPUT_PORT_INDEX)
445 pOutbufOps->Run(hMFCHandle);
455 OMX_ERRORTYPE H264CodecStop(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
457 OMX_ERRORTYPE ret = OMX_ErrorNone;
458 void *hMFCHandle = NULL;
459 ExynosVideoDecOps *pDecOps = NULL;
460 ExynosVideoDecBufferOps *pInbufOps = NULL;
461 ExynosVideoDecBufferOps *pOutbufOps = NULL;
462 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
463 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
467 if (pOMXComponent == NULL) {
468 ret = OMX_ErrorBadParameter;
472 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle;
473 if (pVideoDec == NULL) {
474 ret = OMX_ErrorBadParameter;
477 pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
478 if (pH264Dec == NULL) {
479 ret = OMX_ErrorBadParameter;
483 hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
484 pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
485 pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
486 pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
488 if ((nPortIndex == INPUT_PORT_INDEX) && (pInbufOps != NULL))
489 pInbufOps->Stop(hMFCHandle);
490 else if ((nPortIndex == OUTPUT_PORT_INDEX) && (pOutbufOps != NULL))
491 pOutbufOps->Stop(hMFCHandle);
501 OMX_ERRORTYPE H264CodecSrcInit(OMX_COMPONENTTYPE *pOMXComponent)
503 OMX_ERRORTYPE ret = OMX_ErrorNone;
504 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
505 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
506 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
507 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
508 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
509 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
511 ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
512 ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
513 ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
514 ExynosVideoGeometry bufferConf;
515 OMX_U32 inputBufferNumber = 0;
519 if (pVideoDec->bThumbnailMode == OMX_TRUE)
520 pDecOps->Set_DisplayDelay(hMFCHandle, 0);
522 /* input buffer info */
523 Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf));
524 bufferConf.eCompressionFormat = VIDEO_CODING_AVC;
526 if (pExynosInputPort->bufferProcessType & BUFFER_SHARE
527 ||pH264Dec->hMFCH264Handle.bShareableBuf == OMX_TRUE)
528 pInbufOps->Set_Shareable(hMFCHandle);
530 if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
531 bufferConf.nSizeImage = pExynosInputPort->portDefinition.format.video.nFrameWidth
532 * pExynosInputPort->portDefinition.format.video.nFrameHeight * 3 / 2;
533 inputBufferNumber = MAX_VIDEO_INPUTBUFFER_NUM;
534 } else if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
535 bufferConf.nSizeImage = DEFAULT_MFC_INPUT_BUFFER_SIZE;
536 inputBufferNumber = MFC_INPUT_BUFFER_NUM_MAX;
539 /* should be done before prepare input buffer */
540 if (pInbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) {
541 ret = OMX_ErrorInsufficientResources;
545 /* set input buffer geometry */
546 if (pInbufOps->Set_Geometry(hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) {
547 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for input buffer");
548 ret = OMX_ErrorInsufficientResources;
552 /* setup input buffer */
553 if (pInbufOps->Setup(hMFCHandle, inputBufferNumber) != VIDEO_ERROR_NONE) {
554 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup input buffer");
555 ret = OMX_ErrorInsufficientResources;
559 if ((pExynosInputPort->bufferProcessType & BUFFER_COPY) &&
560 pH264Dec->hMFCH264Handle.bShareableBuf == OMX_TRUE) {
561 /* Register input buffer */
562 for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
563 ExynosVideoPlane plane;
564 plane.addr = pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0];
565 plane.allocSize = pVideoDec->pMFCDecInputBuffer[i]->bufferSize[0];
566 plane.fd = pVideoDec->pMFCDecInputBuffer[i]->fd[0];
567 if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
568 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer");
569 ret = OMX_ErrorInsufficientResources;
573 } else if ((pExynosInputPort->bufferProcessType & BUFFER_COPY) &&
574 pH264Dec->hMFCH264Handle.bShareableBuf == OMX_FALSE) {
575 ExynosVideoBuffer *pBuffer = NULL;
577 for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
578 pVideoDec->pMFCDecInputBuffer[i] = Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
579 Exynos_OSAL_Memset(pVideoDec->pMFCDecInputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
580 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "@pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]);
581 /* get input buffer info */
582 if (pInbufOps->Get_Buffer) {
583 if (pInbufOps->Get_Buffer(pH264Dec->hMFCH264Handle.hMFCHandle, i, &pBuffer) != VIDEO_ERROR_NONE) {
584 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to get input buffer info");
585 ret = OMX_ErrorInsufficientResources;
590 for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
591 /* Use ION Allocator */
592 pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] = (void *)pBuffer->planes[plane].addr;
593 pVideoDec->pMFCDecInputBuffer[i]->fd[plane] = pBuffer->planes[plane].fd;
594 pVideoDec->pMFCDecInputBuffer[i]->bufferSize[plane] = pBuffer->planes[plane].allocSize;
595 pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0;
596 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "@pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[%d]: 0x%x", i, plane, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
600 if (pExynosInputPort == NULL || pExynosOutputPort == NULL || pOMXComponent == NULL) {
601 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "invalid param: pExynosInputPort= %p pExynosOutputPort= %p pOMXComponent= %p", pExynosInputPort, pExynosOutputPort, pOMXComponent);
604 Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]);
606 } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
607 /* Register input buffer */
608 for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) {
609 ExynosVideoPlane plane;
610 if (pVideoDec->bDRMPlayerMode == OMX_TRUE) {
612 /* IL Client assigns FD value in pBuffer */
613 plane.addr = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer;
615 plane.addr = Exynos_OSAL_SharedMemory_IONToVirt(pVideoDec->hSharedMemory, pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer);
618 plane.addr = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer;
620 plane.allocSize = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->nAllocLen;
621 plane.fd = pExynosInputPort->extendBufferHeader[i].buf_fd[0];
622 if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
623 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer");
624 ret = OMX_ErrorInsufficientResources;
637 OMX_ERRORTYPE H264CodecOutputBufferProcessRun(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
639 OMX_ERRORTYPE ret = OMX_ErrorNone;
640 void *hMFCHandle = NULL;
641 ExynosVideoDecOps *pDecOps = NULL;
642 ExynosVideoDecBufferOps *pInbufOps = NULL;
643 ExynosVideoDecBufferOps *pOutbufOps = NULL;
644 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
645 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
649 if (pOMXComponent == NULL) {
650 ret = OMX_ErrorBadParameter;
654 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle;
655 if (pVideoDec == NULL) {
656 ret = OMX_ErrorBadParameter;
659 pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
660 if (pH264Dec == NULL) {
661 ret = OMX_ErrorBadParameter;
665 hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
666 pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
667 pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
668 pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
670 if (nPortIndex == INPUT_PORT_INDEX) {
671 if (pH264Dec->bSourceStart == OMX_FALSE) {
672 Exynos_OSAL_SignalSet(pH264Dec->hSourceStartEvent);
673 Exynos_OSAL_SleepMillisec(0);
677 if (nPortIndex == OUTPUT_PORT_INDEX) {
678 if (pH264Dec->bDestinationStart == OMX_FALSE) {
679 Exynos_OSAL_SignalSet(pH264Dec->hDestinationStartEvent);
680 Exynos_OSAL_SleepMillisec(0);
692 OMX_ERRORTYPE H264CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
694 OMX_ERRORTYPE ret = OMX_ErrorNone;
695 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
696 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
697 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
698 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
699 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
700 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
703 ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
704 ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
705 ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
709 if ((nPortIndex != INPUT_PORT_INDEX) && (nPortIndex != OUTPUT_PORT_INDEX)) {
710 ret = OMX_ErrorBadPortIndex;
714 if ((nPortIndex == INPUT_PORT_INDEX) &&
715 (pH264Dec->bSourceStart == OMX_TRUE)) {
716 Exynos_CodecBufferReset(pExynosComponent, INPUT_PORT_INDEX);
718 for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
719 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]);
720 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0]);
722 Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]);
725 pInbufOps->Clear_Queue(hMFCHandle);
726 } else if ((nPortIndex == OUTPUT_PORT_INDEX) &&
727 (pH264Dec->bDestinationStart == OMX_TRUE)) {
728 OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
729 ExynosVideoBuffer *pBuffer = NULL;
731 Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX);
733 nOutbufs = pDecOps->Get_ActualBufferCount(hMFCHandle);
734 nOutbufs += EXTRA_DPB_NUM;
735 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "EXTRA_DPB_NUM = %d, nOutbufs =%d", EXTRA_DPB_NUM, nOutbufs);
736 for (i = 0; i < nOutbufs; i++) {
737 pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer);
738 Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer);
740 pOutbufOps->Clear_Queue(hMFCHandle);
749 #ifdef USE_S3D_SUPPORT
750 OMX_BOOL H264CodecCheckFramePacking(OMX_COMPONENTTYPE *pOMXComponent)
752 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
753 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
754 ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
755 ExynosVideoFramePacking framePacking;
756 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
757 OMX_BOOL ret = OMX_FALSE;
759 /* Get Frame packing information*/
760 if (pDecOps->Get_FramePackingInfo(pH264Dec->hMFCH264Handle.hMFCHandle, &framePacking) != VIDEO_ERROR_NONE) {
761 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Get Frame Packing Information");
766 if (framePacking.available) {
767 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "arrangement ID: 0x%08x", framePacking.arrangement_id);
768 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "arrangement_type: %d", framePacking.arrangement_type);
769 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "content_interpretation_type: %d", framePacking.content_interpretation_type);
770 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "current_frame_is_frame0_flag: %d", framePacking.current_frame_is_frame0_flag);
771 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "spatial_flipping_flag: %d", framePacking.spatial_flipping_flag);
772 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "fr0X:%d fr0Y:%d fr0X:%d fr0Y:%d", framePacking.frame0_grid_pos_x,
773 framePacking.frame0_grid_pos_y, framePacking.frame1_grid_pos_x, framePacking.frame1_grid_pos_y);
775 pH264Dec->hMFCH264Handle.S3DFPArgmtType = (EXYNOS_OMX_FPARGMT_TYPE) framePacking.arrangement_type;
776 /** Send Port Settings changed call back - output color format change */
777 (*(pExynosComponent->pCallbacks->EventHandler))
779 pExynosComponent->callbackData,
780 OMX_EventPortSettingsChanged, /* The command was completed */
781 OMX_DirOutput, /* This is the port index */
785 Exynos_OSAL_SleepMillisec(0);
794 OMX_ERRORTYPE H264CodecDstFreeCodecBuffers(
795 OMX_COMPONENTTYPE *pOMXComponent)
797 OMX_ERRORTYPE ret = OMX_ErrorNone;
798 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
799 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
800 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
806 for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
807 if (pVideoDec->pMFCDecOutputBuffer[i] != NULL) {
808 for (j = 0; j < MFC_OUTPUT_BUFFER_PLANE; j++) {
809 if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[j] != NULL &&
810 pH264Dec->hMFCH264Handle.bShareableBuf == OMX_TRUE)
811 Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[j]);
814 Exynos_OSAL_Free(pVideoDec->pMFCDecOutputBuffer[i]);
818 Exynos_OSAL_Memset(pVideoDec->pMFCDecOutputBuffer, 0, sizeof(pVideoDec->pMFCDecOutputBuffer));
822 return OMX_ErrorNone;
825 OMX_ERRORTYPE H264CodecDstAllocCodecBuffers(
826 OMX_COMPONENTTYPE *pOMXComponent,
829 OMX_ERRORTYPE ret = OMX_ErrorNone;
830 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
831 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
832 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
834 MEMORY_TYPE eMemoryType = NORMAL_MEMORY;
835 OMX_U32 nAllocLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
840 nAllocLen[0] = calc_plane(pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth,
841 pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight);
842 nAllocLen[1] = calc_plane(pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth,
843 pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight >> 1);
845 if (pVideoDec->bDRMPlayerMode == OMX_TRUE)
846 eMemoryType = SECURE_MEMORY;
848 for (i = 0; i < nOutbufs; i++) {
849 pVideoDec->pMFCDecOutputBuffer[i] = (CODEC_DEC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
850 if (pVideoDec->pMFCDecOutputBuffer[i] == NULL) {
851 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Alloc codec buffer");
852 ret = OMX_ErrorInsufficientResources;
855 Exynos_OSAL_Memset(pVideoDec->pMFCDecOutputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
857 for (j = 0; j < MFC_OUTPUT_BUFFER_PLANE; j++) {
858 pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[j] =
859 (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nAllocLen[j], eMemoryType);
860 if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[j] == NULL) {
861 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Alloc output buffer");
862 ret = OMX_ErrorInsufficientResources;
866 pVideoDec->pMFCDecOutputBuffer[i]->fd[j] =
867 Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory,
868 pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[j]);
869 pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[j] = nAllocLen[j];
873 return OMX_ErrorNone;
876 H264CodecDstFreeCodecBuffers(pOMXComponent);
883 OMX_ERRORTYPE H264CodecDstRegistCodecBuffers(
884 OMX_COMPONENTTYPE *pOMXComponent,
887 OMX_ERRORTYPE ret = OMX_ErrorNone;
888 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
889 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
890 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
891 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
892 ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
894 ExynosVideoPlane planes[MFC_OUTPUT_BUFFER_PLANE];
895 OMX_U32 nDataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
900 /* Register output buffer */
901 for (i = 0; i < nOutbufs; i++) {
902 for (j = 0; j < MFC_OUTPUT_BUFFER_PLANE; j++) {
903 planes[j].addr = pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[j];
904 planes[j].fd = pVideoDec->pMFCDecOutputBuffer[i]->fd[j];
905 planes[j].allocSize = pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[j];
908 if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
909 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer");
910 ret = OMX_ErrorInsufficientResources;
914 pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr,
915 (unsigned int *)nDataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
926 OMX_ERRORTYPE H264CodecResetupAllElement(
927 OMX_COMPONENTTYPE *pOMXComponent,
930 OMX_ERRORTYPE ret = OMX_ErrorNone;
931 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
932 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
933 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
934 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
935 EXYNOS_OMX_BASEPORT *pOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
936 ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
942 if ((nPortIndex == INPUT_PORT_INDEX) &&
943 (pH264Dec->bSourceStart == OMX_TRUE)) {
944 ret = OMX_ErrorNotImplemented;
946 } else if ((nPortIndex == OUTPUT_PORT_INDEX) &&
947 (pH264Dec->bDestinationStart == OMX_TRUE)) {
948 if (pOutputPort->bufferProcessType & BUFFER_COPY) {
950 /**********************************/
951 /* Codec Buffer Free & Unregister */
952 /**********************************/
953 H264CodecDstFreeCodecBuffers(pOMXComponent);
954 Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX);
956 if (pH264Dec->hMFCH264Handle.bShareableBuf == OMX_TRUE)
957 pOutbufOps->Clear_RegisteredBuffer(hMFCHandle);
959 pOutbufOps->Cleanup(hMFCHandle);
960 /******************************************************/
961 /* V4L2 Destnation Setup for DPB Buffer Number Change */
962 /******************************************************/
963 H264CodecDstSetup(pOMXComponent);
965 pVideoDec->bDRCProcessing = OMX_FALSE;
966 } else if (pOutputPort->bufferProcessType & BUFFER_SHARE) {
968 /**********************************/
969 /* Codec Buffer Unregister */
970 /**********************************/
971 pOutbufOps->Clear_RegisteredBuffer(hMFCHandle);
972 pOutbufOps->Cleanup(hMFCHandle);
975 ret = OMX_ErrorBadParameter;
985 OMX_ERRORTYPE H264CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData)
987 OMX_ERRORTYPE ret = OMX_ErrorNone;
988 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
989 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
990 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
991 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
992 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
993 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
994 OMX_U32 oneFrameSize = pSrcInputData->dataLen;
996 ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
997 ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
998 ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
999 ExynosVideoGeometry bufferConf;
1000 OMX_U32 inputBufferNumber = 0;
1005 if ((oneFrameSize <= 0) && (pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
1006 OMX_BUFFERHEADERTYPE *OMXBuffer = NULL;
1007 OMXBuffer = Exynos_OutputBufferGetQueue_Direct(pExynosComponent);
1008 if (OMXBuffer == NULL) {
1009 ret = OMX_ErrorUndefined;
1013 OMXBuffer->nTimeStamp = pSrcInputData->timeStamp;
1014 OMXBuffer->nFlags = pSrcInputData->nFlags;
1015 Exynos_OMX_OutputBufferReturn(pOMXComponent, OMXBuffer);
1017 ret = OMX_ErrorNone;
1021 if (!((pExynosInputPort->bufferProcessType & BUFFER_COPY) &&
1022 pH264Dec->hMFCH264Handle.bShareableBuf == OMX_FALSE)) {
1023 ret = H264CodecSrcInit(pOMXComponent);
1024 if (ret != OMX_ErrorNone)
1028 /* set output geometry */
1029 Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf));
1030 pH264Dec->hMFCH264Handle.MFCOutputColorType = bufferConf.eColorFormat = VIDEO_COLORFORMAT_NV12_TILED;
1031 if (pOutbufOps->Set_Geometry(hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) {
1032 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for output buffer");
1033 ret = OMX_ErrorInsufficientResources;
1037 /* input buffer enqueue for header parsing */
1038 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "oneFrameSize: %d", oneFrameSize);
1039 if (pInbufOps->Enqueue(hMFCHandle, (unsigned char **)&pSrcInputData->buffer.singlePlaneBuffer.dataBuffer,
1040 (unsigned int *)&oneFrameSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader) != VIDEO_ERROR_NONE) {
1041 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to enqueue input buffer for header parsing");
1042 // ret = OMX_ErrorInsufficientResources;
1043 ret = (OMX_ERRORTYPE)OMX_ErrorCodecInit;
1047 /* start header parsing */
1048 if (pInbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) {
1049 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run input buffer for header parsing");
1050 ret = OMX_ErrorCodecInit;
1054 ret = H264CodecCheckResolutionChange(pOMXComponent);
1055 if (ret != OMX_ErrorNone) {
1056 ret = OMX_ErrorCodecInit;
1060 Exynos_OSAL_SleepMillisec(0);
1061 ret = OMX_ErrorInputDataDecodeYet;
1063 #ifdef USE_IMMEDIATE_DISPLAY
1064 /* Set Immediately display for I Frame*/
1065 pDecOps->Set_ImmediateDisplay(hMFCHandle);
1069 H264CodecStop(pOMXComponent, INPUT_PORT_INDEX);
1075 OMX_ERRORTYPE H264CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent)
1077 OMX_ERRORTYPE ret = OMX_ErrorNone;
1078 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1079 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1080 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
1081 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
1082 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1083 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1085 ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
1086 ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
1087 ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
1094 nOutbufs = pH264Dec->hMFCH264Handle.maxDPBNum;
1096 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
1097 /* should be done before prepare output buffer */
1098 if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) {
1099 ret = OMX_ErrorInsufficientResources;
1104 if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE
1105 ||pH264Dec->hMFCH264Handle.bShareableBuf == OMX_TRUE)
1106 pOutbufOps->Set_Shareable(hMFCHandle);
1108 if (pOutbufOps->Setup(hMFCHandle, nOutbufs) != VIDEO_ERROR_NONE) {
1109 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer");
1110 ret = OMX_ErrorInsufficientResources;
1114 ExynosVideoPlane planes[MFC_OUTPUT_BUFFER_PLANE];
1115 OMX_U32 nAllocLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
1116 OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
1119 nAllocLen[0] = calc_plane(pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth,
1120 pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight);
1121 nAllocLen[1] = calc_plane(pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth,
1122 pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight >> 1);
1124 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY &&
1125 pH264Dec->hMFCH264Handle.bShareableBuf == OMX_TRUE) {
1126 H264CodecDstAllocCodecBuffers(pOMXComponent, nOutbufs);
1127 H264CodecDstRegistCodecBuffers(pOMXComponent, nOutbufs);
1128 } else if (pExynosOutputPort->bufferProcessType & BUFFER_COPY &&
1129 pH264Dec->hMFCH264Handle.bShareableBuf == OMX_FALSE) {
1131 /* Register output buffer */
1132 for (i = 0; i < nOutbufs; i++) {
1134 OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
1135 ExynosVideoBuffer *pBuffer = NULL;
1136 pVideoDec->pMFCDecOutputBuffer[i] = (CODEC_DEC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
1137 Exynos_OSAL_Memset(pVideoDec->pMFCDecOutputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
1139 if (pOutbufOps->Get_Buffer) {
1140 if (pOutbufOps->Get_Buffer(pH264Dec->hMFCH264Handle.hMFCHandle, i, &pBuffer) != VIDEO_ERROR_NONE) {
1141 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to get Output buffer info");
1142 ret = OMX_ErrorInsufficientResources;
1147 for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
1148 pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] = (void *)pBuffer->planes[plane].addr;
1149 pVideoDec->pMFCDecOutputBuffer[i]->fd[plane] = pBuffer->planes[plane].fd;
1150 pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane] = pBuffer->planes[plane].allocSize;
1153 pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr,
1154 (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
1156 } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
1158 if (pExynosOutputPort->bIsPBEnabled == OMX_TRUE) {
1159 for (i = 0; i < pExynosOutputPort->assignedBufferNum; i++) {
1160 for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
1161 planes[plane].fd = pExynosOutputPort->extendBufferHeader[i].buf_fd[plane];
1162 planes[plane].addr = pExynosOutputPort->extendBufferHeader[i].pYUVBuf[plane];
1163 planes[plane].allocSize = nAllocLen[plane];
1166 if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
1167 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer");
1168 ret = OMX_ErrorInsufficientResources;
1171 pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pExynosOutputPort->extendBufferHeader[i].pYUVBuf,
1172 (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
1175 ret = OMX_ErrorNotImplemented;
1179 ret = OMX_ErrorNotImplemented;
1182 /* Waiting for DPB buffer setup to be completed,
1183 * valid only for share mode
1185 if (pDecOps->Enable_DecodeWait != NULL)
1186 pDecOps->Enable_DecodeWait(hMFCHandle);
1190 if (pOutbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) {
1191 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run output buffer");
1192 ret = OMX_ErrorInsufficientResources;
1196 if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
1197 H264CodecStop(pOMXComponent, OUTPUT_PORT_INDEX);
1199 pH264Dec->hMFCH264Handle.bConfiguredMFCDst = OMX_TRUE;
1201 ret = OMX_ErrorNone;
1209 OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent)
1211 OMX_ERRORTYPE ret = OMX_ErrorNone;
1212 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1213 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1214 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1215 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
1216 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1217 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1219 ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
1220 ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
1221 ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
1222 ExynosVideoGeometry bufferConf;
1227 /* get geometry for output */
1228 Exynos_OSAL_Memset(&pH264Dec->hMFCH264Handle.codecOutbufConf, 0, sizeof(ExynosVideoGeometry));
1229 if (pOutbufOps->Get_Geometry(hMFCHandle, &pH264Dec->hMFCH264Handle.codecOutbufConf) != VIDEO_ERROR_NONE) {
1230 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to get geometry for parsed header info");
1231 ret = OMX_ErrorInsufficientResources;
1236 pH264Dec->hMFCH264Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle);
1237 if (pVideoDec->bThumbnailMode == OMX_FALSE)
1238 pH264Dec->hMFCH264Handle.maxDPBNum += EXTRA_DPB_NUM;
1239 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "H264CodecCheckResolutionChange H264CodecSetup nOutbufs: %d", pH264Dec->hMFCH264Handle.maxDPBNum);
1241 pH264Dec->hMFCH264Handle.bConfiguredMFCSrc = OMX_TRUE;
1243 pExynosOutputPort->cropRectangle.nTop = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nTop;
1244 pExynosOutputPort->cropRectangle.nLeft = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nLeft;
1245 pExynosOutputPort->cropRectangle.nWidth = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nWidth;
1246 pExynosOutputPort->cropRectangle.nHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nHeight;
1248 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
1249 if ((pVideoDec->bDRCProcessing) ||
1250 (pExynosInputPort->portDefinition.format.video.nFrameWidth != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth) ||
1251 (pExynosInputPort->portDefinition.format.video.nFrameHeight != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight)) {
1252 pExynosInputPort->portDefinition.format.video.nFrameWidth = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth;
1253 pExynosInputPort->portDefinition.format.video.nFrameHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight;
1254 pExynosInputPort->portDefinition.format.video.nStride = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
1255 pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
1257 if (pVideoDec->bDRCProcessing == OMX_TRUE) {
1258 pVideoDec->nDRCSavedBufferCount = pExynosOutputPort->portDefinition.nBufferCountActual;
1260 Exynos_UpdateFrameSize(pOMXComponent);
1261 pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE;
1263 /** Send Port Settings changed call back **/
1264 (*(pExynosComponent->pCallbacks->EventHandler))
1266 pExynosComponent->callbackData,
1267 OMX_EventPortSettingsChanged, /* The command was completed */
1268 OMX_DirOutput, /* This is the port index */
1272 } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
1273 if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth) ||
1274 (pExynosInputPort->portDefinition.format.video.nFrameHeight != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight) ||
1275 (pExynosOutputPort->portDefinition.nBufferCountActual != pH264Dec->hMFCH264Handle.maxDPBNum)) {
1276 pExynosInputPort->portDefinition.format.video.nFrameWidth = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth;
1277 pExynosInputPort->portDefinition.format.video.nFrameHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight;
1278 pExynosInputPort->portDefinition.format.video.nStride = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
1279 pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
1281 if (pVideoDec->bDRCProcessing == OMX_TRUE) {
1282 pVideoDec->nDRCSavedBufferCount = pExynosOutputPort->portDefinition.nBufferCountActual;
1285 pExynosOutputPort->portDefinition.nBufferCountActual = pH264Dec->hMFCH264Handle.maxDPBNum;
1286 pExynosOutputPort->portDefinition.nBufferCountMin = pH264Dec->hMFCH264Handle.maxDPBNum;
1288 pExynosOutputPort->portDefinition.nBufferCountActual = pH264Dec->hMFCH264Handle.maxDPBNum - 4;
1289 pExynosOutputPort->portDefinition.nBufferCountMin = pH264Dec->hMFCH264Handle.maxDPBNum - 4;
1291 Exynos_UpdateFrameSize(pOMXComponent);
1292 pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE;
1294 /** Send Port Settings changed call back **/
1295 (*(pExynosComponent->pCallbacks->EventHandler))
1297 pExynosComponent->callbackData,
1298 OMX_EventPortSettingsChanged, /* The command was completed */
1299 OMX_DirOutput, /* This is the port index */
1305 if (((pVideoDec->bDRCProcessing) && (pExynosOutputPort->bufferProcessType & BUFFER_COPY)) ||
1306 (pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth != pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nWidth) ||
1307 (pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight != pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nHeight)) {
1309 pExynosInputPort->portDefinition.format.video.nFrameWidth = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth;
1310 pExynosInputPort->portDefinition.format.video.nFrameHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight;
1311 pExynosInputPort->portDefinition.format.video.nStride = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
1312 pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
1313 Exynos_UpdateFrameSize(pOMXComponent);
1315 /** Send crop info call back **/
1316 (*(pExynosComponent->pCallbacks->EventHandler))
1318 pExynosComponent->callbackData,
1319 OMX_EventPortSettingsChanged, /* The command was completed */
1320 OMX_DirOutput, /* This is the port index */
1321 OMX_IndexConfigCommonOutputCrop,
1325 ret = OMX_ErrorNone;
1333 OMX_ERRORTYPE Exynos_H264Dec_GetParameter(
1334 OMX_IN OMX_HANDLETYPE hComponent,
1335 OMX_IN OMX_INDEXTYPE nParamIndex,
1336 OMX_INOUT OMX_PTR pComponentParameterStructure)
1338 OMX_ERRORTYPE ret = OMX_ErrorNone;
1339 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1340 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1344 if (hComponent == NULL || pComponentParameterStructure == NULL) {
1345 ret = OMX_ErrorBadParameter;
1348 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1349 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1350 if (ret != OMX_ErrorNone) {
1353 if (pOMXComponent->pComponentPrivate == NULL) {
1354 ret = OMX_ErrorBadParameter;
1358 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1359 if (pExynosComponent->currentState == OMX_StateInvalid ) {
1360 ret = OMX_ErrorInvalidState;
1364 switch (nParamIndex) {
1365 case OMX_IndexParamVideoAvc:
1367 OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure;
1368 OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL;
1369 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
1371 ret = Exynos_OMX_Check_SizeVersion(pDstAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
1372 if (ret != OMX_ErrorNone) {
1376 if (pDstAVCComponent->nPortIndex >= ALL_PORT_NUM) {
1377 ret = OMX_ErrorBadPortIndex;
1381 pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1382 pSrcAVCComponent = &pH264Dec->AVCComponent[pDstAVCComponent->nPortIndex];
1384 Exynos_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
1387 case OMX_IndexParamStandardComponentRole:
1389 OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure;
1390 ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
1391 if (ret != OMX_ErrorNone) {
1395 Exynos_OSAL_Strcpy((char *)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_H264_DEC_ROLE);
1398 case OMX_IndexParamVideoProfileLevelQuerySupported:
1400 OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure;
1401 EXYNOS_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL;
1402 OMX_U32 maxProfileLevelNum = 0;
1404 ret = Exynos_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
1405 if (ret != OMX_ErrorNone) {
1409 if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) {
1410 ret = OMX_ErrorBadPortIndex;
1414 pProfileLevel = supportedAVCProfileLevels;
1415 maxProfileLevelNum = sizeof(supportedAVCProfileLevels) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL);
1417 if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) {
1418 ret = OMX_ErrorNoMore;
1422 pProfileLevel += pDstProfileLevel->nProfileIndex;
1423 pDstProfileLevel->eProfile = pProfileLevel->profile;
1424 pDstProfileLevel->eLevel = pProfileLevel->level;
1427 case OMX_IndexParamVideoProfileLevelCurrent:
1429 OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure;
1430 OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL;
1431 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
1433 ret = Exynos_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
1434 if (ret != OMX_ErrorNone) {
1438 if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) {
1439 ret = OMX_ErrorBadPortIndex;
1443 pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1444 pSrcAVCComponent = &pH264Dec->AVCComponent[pDstProfileLevel->nPortIndex];
1446 pDstProfileLevel->eProfile = pSrcAVCComponent->eProfile;
1447 pDstProfileLevel->eLevel = pSrcAVCComponent->eLevel;
1450 case OMX_IndexParamVideoErrorCorrection:
1452 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
1453 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL;
1454 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
1456 ret = Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
1457 if (ret != OMX_ErrorNone) {
1461 if (pDstErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) {
1462 ret = OMX_ErrorBadPortIndex;
1466 pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1467 pSrcErrorCorrectionType = &pH264Dec->errorCorrectionType[INPUT_PORT_INDEX];
1469 pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC;
1470 pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync;
1471 pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing;
1472 pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning;
1473 pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC;
1477 ret = Exynos_OMX_VideoDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure);
1486 OMX_ERRORTYPE Exynos_H264Dec_SetParameter(
1487 OMX_IN OMX_HANDLETYPE hComponent,
1488 OMX_IN OMX_INDEXTYPE nIndex,
1489 OMX_IN OMX_PTR pComponentParameterStructure)
1491 OMX_ERRORTYPE ret = OMX_ErrorNone;
1492 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1493 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1497 if (hComponent == NULL || pComponentParameterStructure == NULL) {
1498 ret = OMX_ErrorBadParameter;
1501 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1502 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1503 if (ret != OMX_ErrorNone) {
1506 if (pOMXComponent->pComponentPrivate == NULL) {
1507 ret = OMX_ErrorBadParameter;
1511 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1512 if (pExynosComponent->currentState == OMX_StateInvalid ) {
1513 ret = OMX_ErrorInvalidState;
1518 case OMX_IndexParamVideoAvc:
1520 OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL;
1521 OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure;
1522 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
1524 ret = Exynos_OMX_Check_SizeVersion(pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
1525 if (ret != OMX_ErrorNone) {
1529 if (pSrcAVCComponent->nPortIndex >= ALL_PORT_NUM) {
1530 ret = OMX_ErrorBadPortIndex;
1534 pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1535 pDstAVCComponent = &pH264Dec->AVCComponent[pSrcAVCComponent->nPortIndex];
1537 Exynos_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
1540 case OMX_IndexParamStandardComponentRole:
1542 OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure;
1544 ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
1545 if (ret != OMX_ErrorNone) {
1549 if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) {
1550 ret = OMX_ErrorIncorrectStateOperation;
1554 if (!Exynos_OSAL_Strcmp((char*)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_H264_DEC_ROLE)) {
1555 pExynosComponent->pExynosPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
1557 ret = OMX_ErrorBadParameter;
1562 case OMX_IndexParamPortDefinition:
1564 OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)pComponentParameterStructure;
1565 OMX_U32 portIndex = pPortDefinition->nPortIndex;
1566 EXYNOS_OMX_BASEPORT *pExynosPort;
1567 OMX_U32 width, height, size;
1568 OMX_U32 realWidth, realHeight;
1569 OMX_PARAM_PORTDEFINITIONTYPE portDefinition_backup;
1571 if (portIndex >= pExynosComponent->portParam.nPorts) {
1572 ret = OMX_ErrorBadPortIndex;
1575 ret = Exynos_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
1576 if (ret != OMX_ErrorNone) {
1580 pExynosPort = &pExynosComponent->pExynosPort[portIndex];
1582 if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) {
1583 if (pExynosPort->portDefinition.bEnabled == OMX_TRUE) {
1584 ret = OMX_ErrorIncorrectStateOperation;
1588 if (pPortDefinition->nBufferCountActual < pExynosPort->portDefinition.nBufferCountMin) {
1589 ret = OMX_ErrorBadParameter;
1593 Exynos_OSAL_Memcpy(&portDefinition_backup, &pExynosPort->portDefinition, pPortDefinition->nSize);
1594 Exynos_OSAL_Memcpy(&pExynosPort->portDefinition, pPortDefinition, pPortDefinition->nSize);
1595 RESTORE_READONLYPARAMETERS_OMX_PARAM_PORTDEFINITIONTYPE(&pExynosPort->portDefinition,&portDefinition_backup);
1597 realWidth = pExynosPort->portDefinition.format.video.nFrameWidth;
1598 realHeight = pExynosPort->portDefinition.format.video.nFrameHeight;
1599 width = ((realWidth + 15) & (~15));
1600 height = ((realHeight + 15) & (~15));
1601 size = (width * height * 3) / 2;
1602 pExynosPort->portDefinition.format.video.nStride = width;
1603 pExynosPort->portDefinition.format.video.nSliceHeight = height;
1604 pExynosPort->portDefinition.nBufferSize = (size > pExynosPort->portDefinition.nBufferSize) ? size : pExynosPort->portDefinition.nBufferSize;
1606 if (portIndex == INPUT_PORT_INDEX) {
1607 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1608 pExynosOutputPort->portDefinition.format.video.nFrameWidth = pExynosPort->portDefinition.format.video.nFrameWidth;
1609 pExynosOutputPort->portDefinition.format.video.nFrameHeight = pExynosPort->portDefinition.format.video.nFrameHeight;
1610 pExynosOutputPort->portDefinition.format.video.nStride = width;
1611 pExynosOutputPort->portDefinition.format.video.nSliceHeight = height;
1613 switch (pExynosOutputPort->portDefinition.format.video.eColorFormat) {
1614 case OMX_COLOR_FormatYUV420Planar:
1615 case OMX_COLOR_FormatYUV420SemiPlanar:
1616 pExynosOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
1618 #ifdef SLP_PLATFORM /* NV12T fd */
1619 case OMX_SEC_COLOR_FormatNV12T_DmaBuf_Fd:
1620 pExynosOutputPort->portDefinition.nBufferSize = sizeof(SCMN_IMGB);
1623 case OMX_SEC_COLOR_FormatNV12Tiled:
1624 pExynosOutputPort->portDefinition.nBufferSize =
1625 calc_plane(pExynosPort->portDefinition.format.video.nFrameWidth, pExynosOutputPort->portDefinition.format.video.nFrameHeight) +
1626 calc_plane(pExynosPort->portDefinition.format.video.nFrameWidth, pExynosOutputPort->portDefinition.format.video.nFrameHeight >> 1);
1629 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Color format is not support!! use default YUV size!!");
1630 ret = OMX_ErrorUnsupportedSetting;
1634 if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
1635 pExynosOutputPort->portDefinition.nBufferSize =
1636 calc_plane(pExynosPort->portDefinition.format.video.nFrameWidth, pExynosOutputPort->portDefinition.format.video.nFrameHeight) +
1637 calc_plane(pExynosPort->portDefinition.format.video.nFrameWidth, pExynosOutputPort->portDefinition.format.video.nFrameHeight >> 1);
1642 case OMX_IndexParamVideoProfileLevelCurrent:
1644 OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure;
1645 OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL;
1646 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
1648 ret = Exynos_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
1649 if (ret != OMX_ErrorNone)
1652 if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) {
1653 ret = OMX_ErrorBadPortIndex;
1657 pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1659 pDstAVCComponent = &pH264Dec->AVCComponent[pSrcProfileLevel->nPortIndex];
1660 pDstAVCComponent->eProfile = pSrcProfileLevel->eProfile;
1661 pDstAVCComponent->eLevel = pSrcProfileLevel->eLevel;
1664 case OMX_IndexParamVideoErrorCorrection:
1666 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
1667 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL;
1668 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
1670 ret = Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
1671 if (ret != OMX_ErrorNone) {
1675 if (pSrcErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) {
1676 ret = OMX_ErrorBadPortIndex;
1680 pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1681 pDstErrorCorrectionType = &pH264Dec->errorCorrectionType[INPUT_PORT_INDEX];
1683 pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC;
1684 pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync;
1685 pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing;
1686 pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning;
1687 pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC;
1691 ret = Exynos_OMX_VideoDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure);
1700 OMX_ERRORTYPE Exynos_H264Dec_GetConfig(
1701 OMX_HANDLETYPE hComponent,
1702 OMX_INDEXTYPE nIndex,
1703 OMX_PTR pComponentConfigStructure)
1705 OMX_ERRORTYPE ret = OMX_ErrorNone;
1706 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1707 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1711 if (hComponent == NULL) {
1712 ret = OMX_ErrorBadParameter;
1715 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1716 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1717 if (ret != OMX_ErrorNone) {
1720 if (pOMXComponent->pComponentPrivate == NULL) {
1721 ret = OMX_ErrorBadParameter;
1724 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1725 if (pComponentConfigStructure == NULL) {
1726 ret = OMX_ErrorBadParameter;
1729 if (pExynosComponent->currentState == OMX_StateInvalid) {
1730 ret = OMX_ErrorInvalidState;
1735 case OMX_IndexConfigCommonOutputCrop:
1737 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
1738 OMX_CONFIG_RECTTYPE *pSrcRectType = NULL;
1739 OMX_CONFIG_RECTTYPE *pDstRectType = NULL;
1740 pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1742 if (pH264Dec->hMFCH264Handle.bConfiguredMFCSrc == OMX_FALSE) {
1743 ret = OMX_ErrorNotReady;
1747 pDstRectType = (OMX_CONFIG_RECTTYPE *)pComponentConfigStructure;
1749 if ((pDstRectType->nPortIndex != INPUT_PORT_INDEX) &&
1750 (pDstRectType->nPortIndex != OUTPUT_PORT_INDEX)) {
1751 ret = OMX_ErrorBadPortIndex;
1755 EXYNOS_OMX_BASEPORT *pExynosPort = &pExynosComponent->pExynosPort[pDstRectType->nPortIndex];
1757 pSrcRectType = &(pExynosPort->cropRectangle);
1759 pDstRectType->nTop = pSrcRectType->nTop;
1760 pDstRectType->nLeft = pSrcRectType->nLeft;
1761 pDstRectType->nHeight = pSrcRectType->nHeight;
1762 pDstRectType->nWidth = pSrcRectType->nWidth;
1765 #ifdef USE_S3D_SUPPORT
1766 case OMX_IndexVendorS3DMode:
1768 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
1769 OMX_U32 *pS3DMode = NULL;
1770 pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1772 pS3DMode = (OMX_U32 *)pComponentConfigStructure;
1773 *pS3DMode = (OMX_U32) pH264Dec->hMFCH264Handle.S3DFPArgmtType;
1778 ret = Exynos_OMX_VideoDecodeGetConfig(hComponent, nIndex, pComponentConfigStructure);
1788 OMX_ERRORTYPE Exynos_H264Dec_SetConfig(
1789 OMX_HANDLETYPE hComponent,
1790 OMX_INDEXTYPE nIndex,
1791 OMX_PTR pComponentConfigStructure)
1793 OMX_ERRORTYPE ret = OMX_ErrorNone;
1794 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1795 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1799 if (hComponent == NULL) {
1800 ret = OMX_ErrorBadParameter;
1803 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1804 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1805 if (ret != OMX_ErrorNone) {
1808 if (pOMXComponent->pComponentPrivate == NULL) {
1809 ret = OMX_ErrorBadParameter;
1812 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1813 if (pComponentConfigStructure == NULL) {
1814 ret = OMX_ErrorBadParameter;
1817 if (pExynosComponent->currentState == OMX_StateInvalid) {
1818 ret = OMX_ErrorInvalidState;
1824 ret = Exynos_OMX_VideoDecodeSetConfig(hComponent, nIndex, pComponentConfigStructure);
1834 OMX_ERRORTYPE Exynos_H264Dec_GetExtensionIndex(
1835 OMX_IN OMX_HANDLETYPE hComponent,
1836 OMX_IN OMX_STRING cParameterName,
1837 OMX_OUT OMX_INDEXTYPE *pIndexType)
1839 OMX_ERRORTYPE ret = OMX_ErrorNone;
1840 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1841 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1845 if (hComponent == NULL) {
1846 ret = OMX_ErrorBadParameter;
1849 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1850 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1851 if (ret != OMX_ErrorNone) {
1854 if (pOMXComponent->pComponentPrivate == NULL) {
1855 ret = OMX_ErrorBadParameter;
1858 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1859 if ((cParameterName == NULL) || (pIndexType == NULL)) {
1860 ret = OMX_ErrorBadParameter;
1863 if (pExynosComponent->currentState == OMX_StateInvalid) {
1864 ret = OMX_ErrorInvalidState;
1868 if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
1869 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1870 *pIndexType = OMX_IndexVendorThumbnailMode;
1871 ret = OMX_ErrorNone;
1873 #ifdef USE_S3D_SUPPORT
1874 else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_S3D) == 0) {
1875 *pIndexType = OMX_IndexVendorS3DMode;
1876 ret = OMX_ErrorNone;
1880 ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
1889 OMX_ERRORTYPE Exynos_H264Dec_ComponentRoleEnum(
1890 OMX_HANDLETYPE hComponent,
1894 OMX_ERRORTYPE ret = OMX_ErrorNone;
1895 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1896 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1900 if ((hComponent == NULL) || (cRole == NULL)) {
1901 ret = OMX_ErrorBadParameter;
1904 if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) {
1905 Exynos_OSAL_Strcpy((char *)cRole, EXYNOS_OMX_COMPONENT_H264_DEC_ROLE);
1906 ret = OMX_ErrorNone;
1908 ret = OMX_ErrorNoMore;
1918 OMX_ERRORTYPE Exynos_H264Dec_Init(OMX_COMPONENTTYPE *pOMXComponent)
1920 OMX_ERRORTYPE ret = OMX_ErrorNone;
1921 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1922 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1923 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1924 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1925 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
1926 OMX_PTR hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
1928 ExynosVideoDecOps *pDecOps = NULL;
1929 ExynosVideoDecBufferOps *pInbufOps = NULL;
1930 ExynosVideoDecBufferOps *pOutbufOps = NULL;
1932 CSC_METHOD csc_method = CSC_METHOD_SW;
1937 pH264Dec->hMFCH264Handle.bConfiguredMFCSrc = OMX_FALSE;
1938 pH264Dec->hMFCH264Handle.bConfiguredMFCDst = OMX_FALSE;
1939 pExynosComponent->bUseFlagEOF = OMX_TRUE;
1940 pExynosComponent->bSaveFlagEOS = OMX_FALSE;
1942 /* H.264 Codec Open */
1943 ret = H264CodecOpen(pH264Dec);
1944 if (ret != OMX_ErrorNone) {
1948 pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
1949 pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
1950 pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
1952 if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
1953 Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID);
1954 Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS);
1956 if (pH264Dec->hMFCH264Handle.bShareableBuf == OMX_TRUE) {
1957 for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
1958 pVideoDec->pMFCDecInputBuffer[i] = Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
1959 Exynos_OSAL_Memset(pVideoDec->pMFCDecInputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
1960 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]);
1962 for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
1963 /* Use ION Allocator */
1964 pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, DEFAULT_MFC_INPUT_BUFFER_SIZE, NORMAL_MEMORY);
1965 pVideoDec->pMFCDecInputBuffer[i]->fd[plane] = Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
1966 pVideoDec->pMFCDecInputBuffer[i]->bufferSize[plane] = DEFAULT_MFC_INPUT_BUFFER_SIZE;
1967 pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0;
1968 if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] == NULL) {
1969 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Fail input buffer");
1970 ret = OMX_ErrorInsufficientResources;
1973 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[%d]: 0x%x", i, plane, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
1976 Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]);
1980 if (pOMXComponent == NULL) {
1981 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d: invalid parm: pOMXComponent = %p", __FUNCTION__, __LINE__, pOMXComponent);
1984 ret = H264CodecSrcInit(pOMXComponent);
1985 if (ret != OMX_ErrorNone)
1988 } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
1992 /* Does not require any actions. */
1995 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
1996 Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort->codecSemID);
1997 Exynos_OSAL_QueueCreate(&pExynosOutputPort->codecBufferQ, MAX_QUEUE_ELEMENTS);
1998 } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
2002 /* Does not require any actions. */
2005 pH264Dec->bSourceStart = OMX_FALSE;
2006 Exynos_OSAL_SignalCreate(&pH264Dec->hSourceStartEvent);
2007 pH264Dec->bDestinationStart = OMX_FALSE;
2008 Exynos_OSAL_SignalCreate(&pH264Dec->hDestinationStartEvent);
2010 Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
2011 Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
2012 pH264Dec->hMFCH264Handle.indexTimestamp = 0;
2013 pH264Dec->hMFCH264Handle.outputIndexTimestamp = 0;
2015 pExynosComponent->getAllDelayBuffer = OMX_FALSE;
2017 #if 0//defined(USE_CSC_GSCALER)
2018 csc_method = CSC_METHOD_HW; //in case of Use ION buffer.
2020 if (pVideoDec->bDRMPlayerMode == OMX_TRUE) {
2021 pVideoDec->csc_handle = csc_init(CSC_METHOD_HW);
2022 csc_set_hw_property(pVideoDec->csc_handle, CSC_HW_PROPERTY_FIXED_NODE, 2);
2023 csc_set_hw_property(pVideoDec->csc_handle, CSC_HW_PROPERTY_MODE_DRM, pVideoDec->bDRMPlayerMode);
2025 pVideoDec->csc_handle = csc_init(csc_method);
2028 if (pVideoDec->csc_handle == NULL) {
2029 ret = OMX_ErrorInsufficientResources;
2032 pVideoDec->csc_set_format = OMX_FALSE;
2041 OMX_ERRORTYPE Exynos_H264Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
2043 OMX_ERRORTYPE ret = OMX_ErrorNone;
2044 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2045 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
2046 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
2047 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
2048 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
2049 OMX_PTR hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
2051 ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
2052 ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
2053 ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
2059 if (pVideoDec->csc_handle != NULL) {
2060 csc_deinit(pVideoDec->csc_handle);
2061 pVideoDec->csc_handle = NULL;
2064 Exynos_OSAL_SignalTerminate(pH264Dec->hDestinationStartEvent);
2065 pH264Dec->hDestinationStartEvent = NULL;
2066 pH264Dec->bDestinationStart = OMX_FALSE;
2067 Exynos_OSAL_SignalTerminate(pH264Dec->hSourceStartEvent);
2068 pH264Dec->hSourceStartEvent = NULL;
2069 pH264Dec->bSourceStart = OMX_FALSE;
2071 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
2072 H264CodecDstFreeCodecBuffers(pOMXComponent);
2074 Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ);
2075 Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID);
2076 } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
2080 /* Does not require any actions. */
2083 if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
2084 for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
2085 if (pVideoDec->pMFCDecInputBuffer[i] != NULL) {
2086 #ifndef SLP_PLATFORM /* do not use ion */
2087 for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
2088 if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] != NULL)
2089 Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
2092 Exynos_OSAL_Free(pVideoDec->pMFCDecInputBuffer[i]);
2093 pVideoDec->pMFCDecInputBuffer[i] = NULL;
2097 Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ);
2098 Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID);
2099 } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
2103 /* Does not require any actions. */
2105 H264CodecClose(pH264Dec);
2113 OMX_ERRORTYPE Exynos_H264Dec_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData)
2115 OMX_ERRORTYPE ret = OMX_ErrorNone;
2116 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2117 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
2118 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
2119 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
2120 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
2121 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
2122 OMX_U32 oneFrameSize = pSrcInputData->dataLen;
2123 OMX_BOOL bInStartCode = OMX_FALSE;
2124 ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
2125 ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
2126 ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
2127 ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE;
2132 if (pH264Dec->hMFCH264Handle.bConfiguredMFCSrc == OMX_FALSE) {
2133 ret = H264CodecSrcSetup(pOMXComponent, pSrcInputData);
2136 if (pH264Dec->hMFCH264Handle.bConfiguredMFCDst == OMX_FALSE) {
2137 ret = H264CodecDstSetup(pOMXComponent);
2140 if (((pVideoDec->bDRMPlayerMode == OMX_TRUE) ||
2141 ((bInStartCode = Check_H264_StartCode(pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, oneFrameSize)) == OMX_TRUE)) ||
2142 ((pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) {
2143 pExynosComponent->timeStamp[pH264Dec->hMFCH264Handle.indexTimestamp] = pSrcInputData->timeStamp;
2144 pExynosComponent->nFlags[pH264Dec->hMFCH264Handle.indexTimestamp] = pSrcInputData->nFlags;
2145 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "input timestamp %lld us (%.2f secs), Tag: %d, nFlags: 0x%x", pSrcInputData->timeStamp, pSrcInputData->timeStamp / 1E6, pH264Dec->hMFCH264Handle.indexTimestamp, pSrcInputData->nFlags);
2146 pDecOps->Set_FrameTag(hMFCHandle, pH264Dec->hMFCH264Handle.indexTimestamp);
2147 pH264Dec->hMFCH264Handle.indexTimestamp++;
2148 pH264Dec->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP;
2150 #ifdef USE_IMMEDIATE_DISPLAY
2151 /* Set Immediately display for I Frame*/
2153 if (pExynosComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE) {
2154 if ( pExynosComponent->checkTimeStamp.bImmediateDisplay == OMX_FALSE) {
2155 /* Enable Immediately display After seek*/
2156 pDecOps->Set_ImmediateDisplay(hMFCHandle);
2157 pExynosComponent->checkTimeStamp.bImmediateDisplay = OMX_TRUE;
2162 /*Add First Frame check : */
2163 if((pSrcInputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG) == OMX_BUFFERFLAG_CODECCONFIG)
2165 MMTA_ACUM_ITEM_END("Video First Frame Coming", 0);
2168 /* queue work for input buffer */
2169 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "oneFrameSize: %d, bufferHeader: 0x%x, dataBuffer: 0x%x", oneFrameSize, pSrcInputData->bufferHeader, pSrcInputData->buffer.singlePlaneBuffer.dataBuffer);
2170 codecReturn = pInbufOps->Enqueue(hMFCHandle, (unsigned char **)&pSrcInputData->buffer.singlePlaneBuffer.dataBuffer,
2171 (unsigned int *)&oneFrameSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader);
2172 if (codecReturn != VIDEO_ERROR_NONE) {
2173 ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
2174 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
2177 H264CodecStart(pOMXComponent, INPUT_PORT_INDEX);
2178 if (pH264Dec->bSourceStart == OMX_FALSE) {
2179 pH264Dec->bSourceStart = OMX_TRUE;
2180 Exynos_OSAL_SignalSet(pH264Dec->hSourceStartEvent);
2181 Exynos_OSAL_SleepMillisec(0);
2183 if (pH264Dec->bDestinationStart == OMX_FALSE) {
2184 pH264Dec->bDestinationStart = OMX_TRUE;
2185 Exynos_OSAL_SignalSet(pH264Dec->hDestinationStartEvent);
2186 Exynos_OSAL_SleepMillisec(0);
2188 } else if (bInStartCode == OMX_FALSE) {
2189 ret = OMX_ErrorCorruptedFrame;
2193 ret = OMX_ErrorNone;
2201 OMX_ERRORTYPE Exynos_H264Dec_SrcOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData)
2203 OMX_ERRORTYPE ret = OMX_ErrorNone;
2204 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2205 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
2206 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
2207 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
2208 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
2209 ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
2210 ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps;
2211 ExynosVideoBuffer *pVideoBuffer;
2215 pVideoBuffer = pInbufOps->Dequeue(hMFCHandle);
2217 pSrcOutputData->dataLen = 0;
2218 pSrcOutputData->usedDataLen = 0;
2219 pSrcOutputData->remainDataLen = 0;
2220 pSrcOutputData->nFlags = 0;
2221 pSrcOutputData->timeStamp = 0;
2223 if (pVideoBuffer == NULL) {
2224 pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = NULL;
2225 pSrcOutputData->allocSize = 0;
2226 pSrcOutputData->pPrivate = NULL;
2227 pSrcOutputData->bufferHeader = NULL;
2229 pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = pVideoBuffer->planes[0].addr;
2230 pSrcOutputData->buffer.singlePlaneBuffer.fd = pVideoBuffer->planes[0].fd;
2231 pSrcOutputData->allocSize = pVideoBuffer->planes[0].allocSize;
2233 if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
2235 while (pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer != pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0]) {
2236 if (i >= MFC_INPUT_BUFFER_NUM_MAX) {
2237 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer");
2238 ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
2243 pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0;
2244 pSrcOutputData->pPrivate = pVideoDec->pMFCDecInputBuffer[i];
2247 /* For Share Buffer */
2248 pSrcOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE*)pVideoBuffer->pPrivate;
2251 ret = OMX_ErrorNone;
2259 OMX_ERRORTYPE Exynos_H264Dec_DstIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData)
2261 OMX_ERRORTYPE ret = OMX_ErrorNone;
2262 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2263 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
2264 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
2265 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
2266 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
2267 ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
2268 ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
2269 OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0,};
2270 ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE;
2274 if (pDstInputData->buffer.multiPlaneBuffer.dataBuffer[0] == NULL) {
2275 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to find input buffer");
2276 ret = OMX_ErrorBadParameter;
2280 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x", __FUNCTION__, __LINE__,
2281 pDstInputData->buffer.multiPlaneBuffer.dataBuffer[0],
2282 pDstInputData->buffer.multiPlaneBuffer.dataBuffer[1]);
2284 if ((pVideoDec->bDRCProcessing == OMX_TRUE) &&
2285 (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) &&
2286 (pExynosOutputPort->exceptionFlag == GENERAL_STATE)) {
2287 ret = H264CodecDstSetup(pOMXComponent);
2288 if (ret != OMX_ErrorNone) {
2289 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "DRC Reconfig H264CodecDstSetup Failed");
2292 pVideoDec->bDRCProcessing = OMX_FALSE;
2295 codecReturn = pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pDstInputData->buffer.multiPlaneBuffer.dataBuffer,
2296 (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, pDstInputData->bufferHeader);
2298 if (codecReturn != VIDEO_ERROR_NONE) {
2299 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
2300 ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
2303 H264CodecStart(pOMXComponent, OUTPUT_PORT_INDEX);
2305 ret = OMX_ErrorNone;
2313 OMX_ERRORTYPE Exynos_H264Dec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData)
2315 OMX_ERRORTYPE ret = OMX_ErrorNone;
2316 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2317 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
2318 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
2319 void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
2320 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
2321 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
2322 ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps;
2323 ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
2324 ExynosVideoBuffer *pVideoBuffer;
2325 ExynosVideoFrameStatusType displayStatus = VIDEO_FRAME_STATUS_UNKNOWN;
2326 ExynosVideoGeometry *bufferGeometry;
2327 DECODE_CODEC_EXTRA_BUFFERINFO *pBufferInfo = NULL;
2328 OMX_S32 indexTimestamp = 0;
2333 if (pH264Dec->bDestinationStart == OMX_FALSE) {
2334 ret = OMX_ErrorNone;
2339 pVideoBuffer = pOutbufOps->Dequeue(hMFCHandle);
2340 if (pVideoBuffer == (ExynosVideoBuffer *)VIDEO_ERROR_DQBUF_EIO) {
2341 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "HW is not available");
2342 ret = OMX_ErrorHardware;
2346 if (pVideoBuffer == NULL) {
2347 ret = OMX_ErrorNone;
2350 displayStatus = pVideoBuffer->displayStatus;
2351 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "displayStatus: 0x%x", displayStatus);
2353 if ((displayStatus == VIDEO_FRAME_STATUS_DISPLAY_DECODING) ||
2354 (displayStatus == VIDEO_FRAME_STATUS_DISPLAY_ONLY) ||
2355 (displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) ||
2356 (displayStatus == VIDEO_FRAME_STATUS_DECODING_FINISHED) ||
2357 (CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) {
2358 if (pVideoBuffer != NULL) {
2359 ret = OMX_ErrorNone;
2362 ret = OMX_ErrorUndefined;
2368 if (displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) {
2369 if (pVideoDec->bDRCProcessing != OMX_TRUE) {
2370 pExynosOutputPort->exceptionFlag = NEED_PORT_FLUSH;
2371 pVideoDec->bDRCProcessing = OMX_TRUE;
2372 H264CodecCheckResolutionChange(pOMXComponent);
2373 pVideoDec->csc_set_format = OMX_FALSE;
2375 ret = OMX_ErrorNone;
2379 pH264Dec->hMFCH264Handle.outputIndexTimestamp++;
2380 pH264Dec->hMFCH264Handle.outputIndexTimestamp %= MAX_TIMESTAMP;
2382 pDstOutputData->allocSize = pDstOutputData->dataLen = 0;
2383 for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
2384 pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[plane] = pVideoBuffer->planes[plane].addr;
2385 pDstOutputData->buffer.multiPlaneBuffer.fd[plane] = pVideoBuffer->planes[plane].fd;
2386 pDstOutputData->allocSize += pVideoBuffer->planes[plane].allocSize;
2387 pDstOutputData->dataLen += pVideoBuffer->planes[plane].dataSize;
2389 pDstOutputData->usedDataLen = 0;
2390 pDstOutputData->pPrivate = pVideoBuffer;
2391 /* For Share Buffer */
2392 pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate;
2394 pBufferInfo = (DECODE_CODEC_EXTRA_BUFFERINFO *)pDstOutputData->extInfo;
2395 bufferGeometry = &pH264Dec->hMFCH264Handle.codecOutbufConf;
2396 pBufferInfo->imageWidth = bufferGeometry->nFrameWidth;
2397 pBufferInfo->imageHeight = bufferGeometry->nFrameHeight;
2398 switch (bufferGeometry->eColorFormat) {
2399 case VIDEO_COLORFORMAT_NV12:
2400 #ifdef SLP_PLATFORM /* NV12T fd */
2401 pBufferInfo->ColorFormat = OMX_SEC_COLOR_FormatNV12T_DmaBuf_Fd;
2403 pBufferInfo->ColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
2406 case VIDEO_COLORFORMAT_NV12_TILED:
2408 pBufferInfo->ColorFormat = OMX_SEC_COLOR_FormatNV12Tiled;
2412 #ifdef USE_S3D_SUPPORT
2413 /* Check Whether frame packing information is available */
2414 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY &&
2415 pVideoDec->bThumbnailMode == OMX_FALSE &&
2416 pH264Dec->hMFCH264Handle.S3DFPArgmtType == OMX_SEC_FPARGMT_NONE) {
2417 H264CodecCheckFramePacking(pOMXComponent);
2421 indexTimestamp = pDecOps->Get_FrameTag(hMFCHandle);
2422 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "out indexTimestamp: %d", indexTimestamp);
2423 if ((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)) {
2424 if ((pExynosComponent->checkTimeStamp.needSetStartTimeStamp != OMX_TRUE) &&
2425 (pExynosComponent->checkTimeStamp.needCheckStartTimeStamp != OMX_TRUE)) {
2426 pDstOutputData->timeStamp = pExynosComponent->timeStamp[pH264Dec->hMFCH264Handle.outputIndexTimestamp];
2427 pDstOutputData->nFlags = pExynosComponent->nFlags[pH264Dec->hMFCH264Handle.outputIndexTimestamp];
2428 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "missing out indexTimestamp: %d", indexTimestamp);
2430 pDstOutputData->timeStamp = 0x00;
2431 pDstOutputData->nFlags = 0x00;
2434 /* For timestamp correction. if mfc support frametype detect */
2435 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "disp_pic_frame_type: %d", pVideoBuffer->frameType);
2436 //#ifdef NEED_TIMESTAMP_REORDER
2438 if (pVideoDec->bNeedTimestampReorder == OMX_TRUE) {
2439 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "NEED_TIMESTAMP_REORDER ON");
2440 if ((pVideoBuffer->frameType == VIDEO_FRAME_I)) {
2441 pDstOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp];
2442 pDstOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp];
2443 pH264Dec->hMFCH264Handle.outputIndexTimestamp = indexTimestamp;
2445 pDstOutputData->timeStamp = pExynosComponent->timeStamp[pH264Dec->hMFCH264Handle.outputIndexTimestamp];
2446 pDstOutputData->nFlags = pExynosComponent->nFlags[pH264Dec->hMFCH264Handle.outputIndexTimestamp];
2450 pDstOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp];
2451 pDstOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp];
2454 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "timestamp %lld us (%.2f secs), indexTimestamp: %d, nFlags: 0x%x", pDstOutputData->timeStamp, pDstOutputData->timeStamp / 1E6, indexTimestamp, pDstOutputData->nFlags);
2457 if ((displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) ||
2458 (displayStatus == VIDEO_FRAME_STATUS_DECODING_FINISHED) ||
2459 ((pDstOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) {
2460 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "displayStatus:%d, nFlags0x%x", displayStatus, pDstOutputData->nFlags);
2461 pDstOutputData->remainDataLen = 0;
2463 pDstOutputData->remainDataLen = bufferGeometry->nFrameWidth * bufferGeometry->nFrameHeight * 3 / 2;
2466 ret = OMX_ErrorNone;
2474 OMX_ERRORTYPE Exynos_H264Dec_srcInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData)
2476 OMX_ERRORTYPE ret = OMX_ErrorNone;
2477 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2478 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
2479 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
2483 if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) {
2484 ret = OMX_ErrorNone;
2487 if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) {
2488 ret = OMX_ErrorNone;
2492 ret = Exynos_H264Dec_SrcIn(pOMXComponent, pSrcInputData);
2493 if ((ret != OMX_ErrorNone) &&
2494 (ret != OMX_ErrorInputDataDecodeYet) &&
2495 (ret != OMX_ErrorCorruptedFrame)) {
2496 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
2497 pExynosComponent->callbackData,
2498 OMX_EventError, ret, 0, NULL);
2507 OMX_ERRORTYPE Exynos_H264Dec_srcOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData)
2509 OMX_ERRORTYPE ret = OMX_ErrorNone;
2510 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2511 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
2512 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
2516 if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) {
2517 ret = OMX_ErrorNone;
2521 if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
2522 if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) {
2523 ret = OMX_ErrorNone;
2527 if ((pH264Dec->bSourceStart == OMX_FALSE) &&
2528 (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort))) {
2529 Exynos_OSAL_SignalWait(pH264Dec->hSourceStartEvent, DEF_MAX_WAIT_TIME);
2530 Exynos_OSAL_SignalReset(pH264Dec->hSourceStartEvent);
2533 ret = Exynos_H264Dec_SrcOut(pOMXComponent, pSrcOutputData);
2534 if ((ret != OMX_ErrorNone) && (pExynosComponent->currentState == OMX_StateExecuting)) {
2535 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
2536 pExynosComponent->callbackData,
2537 OMX_EventError, ret, 0, NULL);
2546 OMX_ERRORTYPE Exynos_H264Dec_dstInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData)
2548 OMX_ERRORTYPE ret = OMX_ErrorNone;
2549 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2550 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
2551 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
2555 if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) {
2556 ret = OMX_ErrorNone;
2559 if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) {
2560 ret = OMX_ErrorNone;
2563 if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
2564 if ((pH264Dec->bDestinationStart == OMX_FALSE) &&
2565 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) {
2566 Exynos_OSAL_SignalWait(pH264Dec->hDestinationStartEvent, DEF_MAX_WAIT_TIME);
2567 Exynos_OSAL_SignalReset(pH264Dec->hDestinationStartEvent);
2570 if (pH264Dec->hMFCH264Handle.bConfiguredMFCDst == OMX_TRUE) {
2571 ret = Exynos_H264Dec_DstIn(pOMXComponent, pDstInputData);
2572 if (ret != OMX_ErrorNone) {
2573 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
2574 pExynosComponent->callbackData,
2575 OMX_EventError, ret, 0, NULL);
2585 OMX_ERRORTYPE Exynos_H264Dec_dstOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData)
2587 OMX_ERRORTYPE ret = OMX_ErrorNone;
2588 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2589 EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
2590 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
2594 if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) {
2595 ret = OMX_ErrorNone;
2598 if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) {
2599 ret = OMX_ErrorNone;
2603 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
2604 if ((pH264Dec->bDestinationStart == OMX_FALSE) &&
2605 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) {
2606 Exynos_OSAL_SignalWait(pH264Dec->hDestinationStartEvent, DEF_MAX_WAIT_TIME);
2607 Exynos_OSAL_SignalReset(pH264Dec->hDestinationStartEvent);
2610 ret = Exynos_H264Dec_DstOut(pOMXComponent, pDstOutputData);
2611 if ((ret != OMX_ErrorNone) && (pExynosComponent->currentState == OMX_StateExecuting)) {
2612 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
2613 pExynosComponent->callbackData,
2614 OMX_EventError, ret, 0, NULL);
2623 OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName)
2625 OMX_ERRORTYPE ret = OMX_ErrorNone;
2626 OMX_COMPONENTTYPE *pOMXComponent = NULL;
2627 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
2628 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
2629 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
2630 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
2631 OMX_BOOL bDRMPlayerMode = OMX_FALSE;
2636 if ((hComponent == NULL) || (componentName == NULL)) {
2637 ret = OMX_ErrorBadParameter;
2638 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
2641 if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_DEC, componentName) == 0) {
2642 bDRMPlayerMode = OMX_FALSE;
2643 } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_DRM_DEC, componentName) == 0) {
2644 bDRMPlayerMode = OMX_TRUE;
2646 ret = OMX_ErrorBadParameter;
2647 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__);
2651 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
2652 ret = Exynos_OMX_VideoDecodeComponentInit(pOMXComponent);
2653 if (ret != OMX_ErrorNone) {
2654 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
2657 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2658 pExynosComponent->codecType = HW_VIDEO_DEC_CODEC;
2660 pExynosComponent->componentName = (OMX_STRING)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE);
2661 if (pExynosComponent->componentName == NULL) {
2662 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent);
2663 ret = OMX_ErrorInsufficientResources;
2664 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
2667 Exynos_OSAL_Memset(pExynosComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE);
2669 pH264Dec = Exynos_OSAL_Malloc(sizeof(EXYNOS_H264DEC_HANDLE));
2670 if (pH264Dec == NULL) {
2671 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent);
2672 ret = OMX_ErrorInsufficientResources;
2673 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
2676 Exynos_OSAL_Memset(pH264Dec, 0, sizeof(EXYNOS_H264DEC_HANDLE));
2677 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
2678 pVideoDec->hCodecHandle = (OMX_HANDLETYPE)pH264Dec;
2680 if (bDRMPlayerMode == OMX_TRUE)
2681 Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_H264_DRM_DEC);
2683 Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_H264_DEC);
2685 pVideoDec->bDRMPlayerMode = bDRMPlayerMode;
2686 /* In case of BUFFER_COPY mode
2687 bShareableBuf = TRUE means MemoryType is V4L2_MEMORY_USERPTR
2688 bShareableBuf = FALSE means MemoryType is V4L2_MEMORY_MMAP
2689 In case of BUFFER_SHARE
2690 bShareableBuf should be TRUE, FALSE is ignored
2692 pH264Dec->hMFCH264Handle.bShareableBuf = OMX_FALSE;
2693 #ifdef USE_S3D_SUPPORT
2694 pH264Dec->hMFCH264Handle.S3DFPArgmtType = OMX_SEC_FPARGMT_NONE;
2697 /* Set componentVersion */
2698 pExynosComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
2699 pExynosComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
2700 pExynosComponent->componentVersion.s.nRevision = REVISION_NUMBER;
2701 pExynosComponent->componentVersion.s.nStep = STEP_NUMBER;
2702 /* Set specVersion */
2703 pExynosComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
2704 pExynosComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
2705 pExynosComponent->specVersion.s.nRevision = REVISION_NUMBER;
2706 pExynosComponent->specVersion.s.nStep = STEP_NUMBER;
2709 pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
2710 pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
2711 pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT;
2712 pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/
2713 pExynosPort->portDefinition.format.video.nSliceHeight = 0;
2714 pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE;
2715 pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
2716 Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
2717 Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "video/avc");
2718 pExynosPort->portDefinition.format.video.pNativeRender = 0;
2719 pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
2720 pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
2721 pExynosPort->portDefinition.bEnabled = OMX_TRUE;
2722 pExynosPort->bufferProcessType = BUFFER_COPY;
2723 if (bDRMPlayerMode == OMX_TRUE)
2724 pExynosPort->bufferProcessType = BUFFER_SHARE;
2725 pExynosPort->portWayType = WAY2_PORT;
2728 pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
2729 pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
2730 pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT;
2731 pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/
2732 pExynosPort->portDefinition.format.video.nSliceHeight = 0;
2733 pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
2734 pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
2735 Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
2736 Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video");
2737 pExynosPort->portDefinition.format.video.pNativeRender = 0;
2738 pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
2740 pExynosPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatNV12T_DmaBuf_Fd;
2742 pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
2744 pExynosPort->portDefinition.bEnabled = OMX_TRUE;
2746 pExynosPort->bufferProcessType = BUFFER_SHARE;
2748 pExynosPort->bufferProcessType = BUFFER_COPY;
2750 pExynosPort->portWayType = WAY2_PORT;
2752 for(i = 0; i < ALL_PORT_NUM; i++) {
2753 INIT_SET_SIZE_VERSION(&pH264Dec->AVCComponent[i], OMX_VIDEO_PARAM_AVCTYPE);
2754 pH264Dec->AVCComponent[i].nPortIndex = i;
2755 pH264Dec->AVCComponent[i].eProfile = OMX_VIDEO_AVCProfileBaseline;
2756 pH264Dec->AVCComponent[i].eLevel = OMX_VIDEO_AVCLevel4;
2759 pOMXComponent->GetParameter = &Exynos_H264Dec_GetParameter;
2760 pOMXComponent->SetParameter = &Exynos_H264Dec_SetParameter;
2761 pOMXComponent->GetConfig = &Exynos_H264Dec_GetConfig;
2762 pOMXComponent->SetConfig = &Exynos_H264Dec_SetConfig;
2763 pOMXComponent->GetExtensionIndex = &Exynos_H264Dec_GetExtensionIndex;
2764 pOMXComponent->ComponentRoleEnum = &Exynos_H264Dec_ComponentRoleEnum;
2765 pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit;
2767 pExynosComponent->exynos_codec_componentInit = &Exynos_H264Dec_Init;
2768 pExynosComponent->exynos_codec_componentTerminate = &Exynos_H264Dec_Terminate;
2770 pVideoDec->exynos_codec_srcInputProcess = &Exynos_H264Dec_srcInputBufferProcess;
2771 pVideoDec->exynos_codec_srcOutputProcess = &Exynos_H264Dec_srcOutputBufferProcess;
2772 pVideoDec->exynos_codec_dstInputProcess = &Exynos_H264Dec_dstInputBufferProcess;
2773 pVideoDec->exynos_codec_dstOutputProcess = &Exynos_H264Dec_dstOutputBufferProcess;
2775 pVideoDec->exynos_codec_start = &H264CodecStart;
2776 pVideoDec->exynos_codec_stop = &H264CodecStop;
2777 pVideoDec->exynos_codec_bufferProcessRun = &H264CodecOutputBufferProcessRun;
2778 pVideoDec->exynos_codec_enqueueAllBuffer = &H264CodecEnQueueAllBuffer;
2779 pVideoDec->exynos_codec_resetupAllElement = &H264CodecResetupAllElement;
2781 pVideoDec->exynos_checkInputFrame = &Check_H264_Frame;
2782 pVideoDec->exynos_codec_getCodecInputPrivateData = &GetCodecInputPrivateData;
2783 pVideoDec->exynos_codec_getCodecOutputPrivateData = &GetCodecOutputPrivateData;
2785 #ifndef SLP_PLATFORM /* do not use ion */
2786 pVideoDec->hSharedMemory = Exynos_OSAL_SharedMemory_Open();
2787 if (pVideoDec->hSharedMemory == NULL) {
2788 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
2789 Exynos_OSAL_Free(pH264Dec);
2790 pH264Dec = ((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle = NULL;
2791 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent);
2792 ret = OMX_ErrorInsufficientResources;
2796 pExynosComponent->currentState = OMX_StateLoaded;
2798 ret = OMX_ErrorNone;
2806 OMX_ERRORTYPE Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent)
2808 OMX_ERRORTYPE ret = OMX_ErrorNone;
2809 OMX_COMPONENTTYPE *pOMXComponent = NULL;
2810 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
2811 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
2812 EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
2816 if (hComponent == NULL) {
2817 ret = OMX_ErrorBadParameter;
2820 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
2821 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2822 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
2824 #ifndef SLP_PLATFORM /* do not use ion */
2825 Exynos_OSAL_SharedMemory_Close(pVideoDec->hSharedMemory);
2827 Exynos_OSAL_Free(pExynosComponent->componentName);
2828 pExynosComponent->componentName = NULL;
2830 pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
2831 if (pH264Dec != NULL) {
2832 Exynos_OSAL_Free(pH264Dec);
2833 pH264Dec = pVideoDec->hCodecHandle = NULL;
2836 ret = Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent);
2837 if (ret != OMX_ErrorNone) {
2841 ret = OMX_ErrorNone;