added new functions to extract the most used code.
1. alloc codec buffer
2. free codec buffer
3. regist codec buffer
Change-Id: Iae4989bfa1ab0eb3b49c5017e43dde8215f30958
Signed-off-by: Taehwan Kim <t_h.kim@samsung.com>
#include "Exynos_OMX_Vdec.h"
#include "Exynos_OMX_VdecControl.h"
#include "Exynos_OMX_Basecomponent.h"
+#include "Exynos_OSAL_SharedMemory.h"
#include "Exynos_OSAL_Thread.h"
#include "Exynos_OSAL_Semaphore.h"
#include "Exynos_OSAL_Mutex.h"
return;
}
+void Exynos_Free_CodecBuffers(
+ OMX_COMPONENTTYPE *pOMXComponent,
+ OMX_U32 nPortIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+ CODEC_DEC_BUFFER **ppCodecBuffer = NULL;
+
+ OMX_U32 nPlaneCnt = 0;
+ int i, j;
+
+ FunctionIn();
+
+ if (nPortIndex == INPUT_PORT_INDEX) {
+ ppCodecBuffer = &(pVideoDec->pMFCDecInputBuffer[0]);
+ nPlaneCnt = MFC_INPUT_BUFFER_PLANE;
+ } else {
+ ppCodecBuffer = &(pVideoDec->pMFCDecOutputBuffer[0]);
+ nPlaneCnt = MFC_OUTPUT_BUFFER_PLANE;
+ }
+
+ for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
+ if (ppCodecBuffer[i] != NULL) {
+ for (j = 0; j < nPlaneCnt; j++) {
+ if (ppCodecBuffer[i]->pVirAddr[j] != NULL)
+ Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, ppCodecBuffer[i]->pVirAddr[j]);
+ }
+
+ Exynos_OSAL_Free(ppCodecBuffer[i]);
+ ppCodecBuffer[i] = NULL;
+ }
+ }
+
+ FunctionOut();
+}
+
+OMX_ERRORTYPE Exynos_Allocate_CodecBuffers(
+ OMX_COMPONENTTYPE *pOMXComponent,
+ OMX_U32 nPortIndex,
+ OMX_U32 nBufferCnt,
+ OMX_U32 nPlaneSize[MFC_OUTPUT_BUFFER_PLANE])
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+ MEMORY_TYPE eMemoryType = NORMAL_MEMORY;
+ CODEC_DEC_BUFFER **ppCodecBuffer = NULL;
+
+ OMX_U32 nPlaneCnt = 0;
+ int i, j;
+
+ FunctionIn();
+
+ if (pVideoDec->bDRMPlayerMode == OMX_TRUE)
+ eMemoryType = SECURE_MEMORY;
+
+ if (nPortIndex == INPUT_PORT_INDEX) {
+ ppCodecBuffer = &(pVideoDec->pMFCDecInputBuffer[0]);
+ nPlaneCnt = MFC_INPUT_BUFFER_PLANE;
+ } else {
+ ppCodecBuffer = &(pVideoDec->pMFCDecOutputBuffer[0]);
+ nPlaneCnt = MFC_OUTPUT_BUFFER_PLANE;
+ }
+
+ for (i = 0; i < nBufferCnt; i++) {
+ ppCodecBuffer[i] = (CODEC_DEC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
+ if (ppCodecBuffer[i] == NULL) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Alloc codec buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ Exynos_OSAL_Memset(ppCodecBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
+
+ for (j = 0; j < nPlaneCnt; j++) {
+ ppCodecBuffer[i]->pVirAddr[j] =
+ (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nPlaneSize[j], eMemoryType);
+ if (ppCodecBuffer[i]->pVirAddr[j] == NULL) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Alloc plane");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ ppCodecBuffer[i]->fd[j] =
+ Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, ppCodecBuffer[i]->pVirAddr[j]);
+ ppCodecBuffer[i]->bufferSize[j] = nPlaneSize[j];
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "PORT[%d]: pMFCCodecBuffer[%d]->pVirAddr[%d]: 0x%x", nPortIndex, i, j, ppCodecBuffer[i]->pVirAddr[j]);
+ }
+
+ ppCodecBuffer[i]->dataSize = 0;
+ }
+
+ return OMX_ErrorNone;
+
+EXIT:
+ Exynos_Free_CodecBuffers(pOMXComponent, nPortIndex);
+
+ FunctionOut();
+
+ return ret;
+}
+
OMX_BOOL Exynos_Check_BufferProcess_State(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 nPortIndex)
{
OMX_BOOL ret = OMX_FALSE;
return ret;
}
+OMX_ERRORTYPE H264CodecRegistCodecBuffers(
+ OMX_COMPONENTTYPE *pOMXComponent,
+ OMX_U32 nPortIndex,
+ OMX_U32 nBufferCnt)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
+ void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
+ CODEC_DEC_BUFFER **ppCodecBuffer = NULL;
+ ExynosVideoDecBufferOps *pBufOps = NULL;
+ ExynosVideoPlane *pPlanes = NULL;
+
+ OMX_U32 nPlaneCnt = 0;
+ int i, j;
+
+ FunctionIn();
+
+ if (nPortIndex == INPUT_PORT_INDEX) {
+ ppCodecBuffer = &(pVideoDec->pMFCDecInputBuffer[0]);
+ nPlaneCnt = MFC_INPUT_BUFFER_PLANE;
+ pBufOps = pH264Dec->hMFCH264Handle.pInbufOps;
+ } else {
+ ppCodecBuffer = &(pVideoDec->pMFCDecOutputBuffer[0]);
+ nPlaneCnt = MFC_OUTPUT_BUFFER_PLANE;
+ pBufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
+ }
+
+ pPlanes = (ExynosVideoPlane *)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane) * nPlaneCnt);
+ if (pPlanes == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ /* Register buffer */
+ for (i = 0; i < nBufferCnt; i++) {
+ for (j = 0; j < nPlaneCnt; j++) {
+ pPlanes[j].addr = ppCodecBuffer[i]->pVirAddr[j];
+ pPlanes[j].fd = ppCodecBuffer[i]->fd[j];
+ pPlanes[j].allocSize = ppCodecBuffer[i]->bufferSize[j];
+ }
+
+ if (pBufOps->Register(hMFCHandle, pPlanes, nPlaneCnt) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "PORT[%d]: Failed to Register buffer", nPortIndex);
+ ret = OMX_ErrorInsufficientResources;
+ Exynos_OSAL_Free(pPlanes);
+ goto EXIT;
+ }
+ }
+
+ Exynos_OSAL_Free(pPlanes);
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE H264CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
}
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
- /* Register input buffer */
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- ExynosVideoPlane plane;
- plane.addr = pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0];
- plane.allocSize = pVideoDec->pMFCDecInputBuffer[i]->bufferSize[0];
- plane.fd = pVideoDec->pMFCDecInputBuffer[i]->fd[0];
- if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- }
+ ret = H264CodecRegistCodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
/* Register input buffer */
for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) {
pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight >> 1);
if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
- MEMORY_TYPE memoryType;
- if (pVideoDec->bDRMPlayerMode == OMX_TRUE)
- memoryType = SECURE_MEMORY;
- else
- memoryType = NORMAL_MEMORY;
+ ret = Exynos_Allocate_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs, nAllocLen);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
- /* Register output buffer */
- for (i = 0; i < nOutbufs; i++) {
- pVideoDec->pMFCDecOutputBuffer[i] = (CODEC_DEC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Memset(pVideoDec->pMFCDecOutputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
-
- for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
- pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] =
- (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nAllocLen[plane], memoryType);
- if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] == NULL) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Alloc output buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- pVideoDec->pMFCDecOutputBuffer[i]->fd[plane] =
- Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory,
- pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]);
- pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane] = nAllocLen[plane];
-
- planes[plane].addr = pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane];
- planes[plane].fd = pVideoDec->pMFCDecOutputBuffer[i]->fd[plane];
- planes[plane].allocSize = pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane];
- }
+ ret = H264CodecRegistCodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
- if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
+ /* Enqueue output buffer */
+ for (i = 0; i < nOutbufs; i++) {
pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr,
(unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
}
pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps;
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
+ OMX_U32 nPlaneSize[MFC_INPUT_BUFFER_PLANE] = {DEFAULT_MFC_INPUT_BUFFER_SIZE};
Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID);
Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS);
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- pVideoDec->pMFCDecInputBuffer[i] = Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Memset(pVideoDec->pMFCDecInputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]);
-
- for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
- /* Use ION Allocator */
- pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, DEFAULT_MFC_INPUT_BUFFER_SIZE, NORMAL_MEMORY);
- pVideoDec->pMFCDecInputBuffer[i]->fd[plane] = Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- pVideoDec->pMFCDecInputBuffer[i]->bufferSize[plane] = DEFAULT_MFC_INPUT_BUFFER_SIZE;
- pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0;
- if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] == NULL) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Fail input buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[%d]: 0x%x", i, plane, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- }
+ ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+ for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++)
Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]);
- }
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
/*************/
/* TBD */
pH264Dec->bSourceStart = OMX_FALSE;
if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
- for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
- if (pVideoDec->pMFCDecOutputBuffer[i] != NULL) {
- for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
- if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] != NULL)
- Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]);
- }
-
- Exynos_OSAL_Free(pVideoDec->pMFCDecOutputBuffer[i]);
- pVideoDec->pMFCDecOutputBuffer[i] = NULL;
- }
- }
-
+ Exynos_Free_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX);
Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ);
Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID);
} else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
}
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- if (pVideoDec->pMFCDecInputBuffer[i] != NULL) {
- for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
- if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] != NULL)
- Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- }
- Exynos_OSAL_Free(pVideoDec->pMFCDecInputBuffer[i]);
- pVideoDec->pMFCDecInputBuffer[i] = NULL;
- }
- }
-
+ Exynos_Free_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX);
Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ);
Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID);
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
return ret;
}
+OMX_ERRORTYPE Mpeg2CodecRegistCodecBuffers(
+ OMX_COMPONENTTYPE *pOMXComponent,
+ OMX_U32 nPortIndex,
+ OMX_U32 nBufferCnt)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
+ void *hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
+ CODEC_DEC_BUFFER **ppCodecBuffer = NULL;
+ ExynosVideoDecBufferOps *pBufOps = NULL;
+ ExynosVideoPlane *pPlanes = NULL;
+
+ OMX_U32 nPlaneCnt = 0;
+ int i, j;
+
+ FunctionIn();
+
+ if (nPortIndex == INPUT_PORT_INDEX) {
+ ppCodecBuffer = &(pVideoDec->pMFCDecInputBuffer[0]);
+ nPlaneCnt = MFC_INPUT_BUFFER_PLANE;
+ pBufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
+ } else {
+ ppCodecBuffer = &(pVideoDec->pMFCDecOutputBuffer[0]);
+ nPlaneCnt = MFC_OUTPUT_BUFFER_PLANE;
+ pBufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
+ }
+
+ pPlanes = (ExynosVideoPlane *)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane) * nPlaneCnt);
+ if (pPlanes == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ /* Register buffer */
+ for (i = 0; i < nBufferCnt; i++) {
+ for (j = 0; j < nPlaneCnt; j++) {
+ pPlanes[j].addr = ppCodecBuffer[i]->pVirAddr[j];
+ pPlanes[j].fd = ppCodecBuffer[i]->fd[j];
+ pPlanes[j].allocSize = ppCodecBuffer[i]->bufferSize[j];
+ }
+
+ if (pBufOps->Register(hMFCHandle, pPlanes, nPlaneCnt) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "PORT[%d]: Failed to Register buffer", nPortIndex);
+ ret = OMX_ErrorInsufficientResources;
+ Exynos_OSAL_Free(pPlanes);
+ goto EXIT;
+ }
+ }
+
+ Exynos_OSAL_Free(pPlanes);
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE Mpeg2CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
}
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
- /* Register input buffer */
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- ExynosVideoPlane plane;
- plane.addr = pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0];
- plane.allocSize = pVideoDec->pMFCDecInputBuffer[i]->bufferSize[0];
- plane.fd = pVideoDec->pMFCDecInputBuffer[i]->fd[0];
- if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "BUFFER_COPY Failed to Register input buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- }
+ ret = Mpeg2CodecRegistCodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
/* Register input buffer */
for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) {
pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameHeight >> 1);
if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
- /* Register output buffer */
- for (i = 0; i < nOutbufs; i++) {
- pVideoDec->pMFCDecOutputBuffer[i] = (CODEC_DEC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Memset(pVideoDec->pMFCDecOutputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
-
- for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
- pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] =
- (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nAllocLen[plane], NORMAL_MEMORY);
- if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] == NULL) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Alloc output buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- pVideoDec->pMFCDecOutputBuffer[i]->fd[plane] =
- Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory,
- pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]);
- pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane] = nAllocLen[plane];
-
- planes[plane].addr = pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane];
- planes[plane].fd = pVideoDec->pMFCDecOutputBuffer[i]->fd[plane];
- planes[plane].allocSize = pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane];
- }
+ ret = Exynos_Allocate_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs, nAllocLen);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
- if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
+ ret = Mpeg2CodecRegistCodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+
+ /* Enqueue output buffer */
+ for (i = 0; i < nOutbufs; i++) {
pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr,
(unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
}
pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
+ OMX_U32 nPlaneSize[MFC_INPUT_BUFFER_PLANE] = {DEFAULT_MFC_INPUT_BUFFER_SIZE};
Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID);
Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS);
+ ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- pVideoDec->pMFCDecInputBuffer[i] = Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Memset(pVideoDec->pMFCDecInputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]);
-
- for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
- /* Use ION Allocator */
- pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, DEFAULT_MFC_INPUT_BUFFER_SIZE, NORMAL_MEMORY);
- pVideoDec->pMFCDecInputBuffer[i]->fd[plane] = Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- pVideoDec->pMFCDecInputBuffer[i]->bufferSize[plane] = DEFAULT_MFC_INPUT_BUFFER_SIZE;
- pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0;
- if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] == NULL) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Fail input buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[%d]: 0x%x", i, plane, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- }
-
+ for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++)
Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]);
- }
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
/*************/
/* TBD */
pMpeg2Dec->bSourceStart = OMX_FALSE;
if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
- for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
- if (pVideoDec->pMFCDecOutputBuffer[i] != NULL) {
- for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
- if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] != NULL)
- Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]);
- }
-
- Exynos_OSAL_Free(pVideoDec->pMFCDecOutputBuffer[i]);
- pVideoDec->pMFCDecOutputBuffer[i] = NULL;
- }
- }
-
+ Exynos_Free_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX);
Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ);
Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID);
} else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
}
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- if (pVideoDec->pMFCDecInputBuffer[i] != NULL) {
- for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
- if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] != NULL)
- Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- }
-
- Exynos_OSAL_Free(pVideoDec->pMFCDecInputBuffer[i]);
- pVideoDec->pMFCDecInputBuffer[i] = NULL;
- }
- }
-
+ Exynos_Free_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX);
Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ);
Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID);
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
return ret;
}
+OMX_ERRORTYPE Mpeg4CodecRegistCodecBuffers(
+ OMX_COMPONENTTYPE *pOMXComponent,
+ OMX_U32 nPortIndex,
+ OMX_U32 nBufferCnt)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
+ void *hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle;
+ CODEC_DEC_BUFFER **ppCodecBuffer = NULL;
+ ExynosVideoDecBufferOps *pBufOps = NULL;
+ ExynosVideoPlane *pPlanes = NULL;
+
+ OMX_U32 nPlaneCnt = 0;
+ int i, j;
+
+ FunctionIn();
+
+ if (nPortIndex == INPUT_PORT_INDEX) {
+ ppCodecBuffer = &(pVideoDec->pMFCDecInputBuffer[0]);
+ nPlaneCnt = MFC_INPUT_BUFFER_PLANE;
+ pBufOps = pMpeg4Dec->hMFCMpeg4Handle.pInbufOps;
+ } else {
+ ppCodecBuffer = &(pVideoDec->pMFCDecOutputBuffer[0]);
+ nPlaneCnt = MFC_OUTPUT_BUFFER_PLANE;
+ pBufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps;
+ }
+
+ pPlanes = (ExynosVideoPlane *)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane) * nPlaneCnt);
+ if (pPlanes == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ /* Register buffer */
+ for (i = 0; i < nBufferCnt; i++) {
+ for (j = 0; j < nPlaneCnt; j++) {
+ pPlanes[j].addr = ppCodecBuffer[i]->pVirAddr[j];
+ pPlanes[j].fd = ppCodecBuffer[i]->fd[j];
+ pPlanes[j].allocSize = ppCodecBuffer[i]->bufferSize[j];
+ }
+
+ if (pBufOps->Register(hMFCHandle, pPlanes, nPlaneCnt) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "PORT[%d]: Failed to Register buffer", nPortIndex);
+ ret = OMX_ErrorInsufficientResources;
+ Exynos_OSAL_Free(pPlanes);
+ goto EXIT;
+ }
+ }
+
+ Exynos_OSAL_Free(pPlanes);
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE Mpeg4CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
}
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
- /* Register input buffer */
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- ExynosVideoPlane plane;
- plane.addr = pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0];
- plane.allocSize = pVideoDec->pMFCDecInputBuffer[i]->bufferSize[0];
- plane.fd = pVideoDec->pMFCDecInputBuffer[i]->fd[0];
- if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- }
+ ret = Mpeg4CodecRegistCodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
/* Register input buffer */
for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) {
pMpeg4Dec->hMFCMpeg4Handle.codecOutbufConf.nFrameHeight >> 1);
if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
- /* Register output buffer */
- for (i = 0; i < nOutbufs; i++) {
- pVideoDec->pMFCDecOutputBuffer[i] = (CODEC_DEC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Memset(pVideoDec->pMFCDecOutputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
-
- for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
- pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] =
- (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nAllocLen[plane], NORMAL_MEMORY);
- if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] == NULL) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Alloc output buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- pVideoDec->pMFCDecOutputBuffer[i]->fd[plane] =
- Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory,
- pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]);
- pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane] = nAllocLen[plane];
-
- planes[plane].addr = pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane];
- planes[plane].fd = pVideoDec->pMFCDecOutputBuffer[i]->fd[plane];
- planes[plane].allocSize = pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane];
- }
+ ret = Exynos_Allocate_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs, nAllocLen);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
- if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
+ ret = Mpeg4CodecRegistCodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+
+ /* Enqueue output buffer */
+ for (i = 0; i < nOutbufs; i++) {
pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr,
(unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
}
pOutbufOps = pMpeg4Dec->hMFCMpeg4Handle.pOutbufOps;
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
+ OMX_U32 nPlaneSize[MFC_INPUT_BUFFER_PLANE] = {DEFAULT_MFC_INPUT_BUFFER_SIZE};
Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID);
Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS);
+ ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- pVideoDec->pMFCDecInputBuffer[i] = Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Memset(pVideoDec->pMFCDecInputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]);
-
- for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
- /* Use ION Allocator */
- pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, DEFAULT_MFC_INPUT_BUFFER_SIZE, NORMAL_MEMORY);
- pVideoDec->pMFCDecInputBuffer[i]->fd[plane] = Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- pVideoDec->pMFCDecInputBuffer[i]->bufferSize[plane] = DEFAULT_MFC_INPUT_BUFFER_SIZE;
- pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0;
- if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] == NULL) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Fail input buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[%d]: 0x%x", i, plane, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- }
-
+ for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++)
Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]);
- }
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
/*************/
/* TBD */
pMpeg4Dec->bSourceStart = OMX_FALSE;
if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
- for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
- if (pVideoDec->pMFCDecOutputBuffer[i] != NULL) {
- for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
- if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] != NULL)
- Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]);
- }
-
- Exynos_OSAL_Free(pVideoDec->pMFCDecOutputBuffer[i]);
- pVideoDec->pMFCDecOutputBuffer[i] = NULL;
- }
- }
-
+ Exynos_Free_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX);
Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ);
Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID);
} else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
}
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- if (pVideoDec->pMFCDecInputBuffer[i] != NULL) {
- for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
- if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] != NULL)
- Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- }
-
- Exynos_OSAL_Free(pVideoDec->pMFCDecInputBuffer[i]);
- pVideoDec->pMFCDecInputBuffer[i] = NULL;
- }
- }
-
+ Exynos_Free_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX);
Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ);
Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID);
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
return ret;
}
+OMX_ERRORTYPE WMVCodecRegistCodecBuffers(
+ OMX_COMPONENTTYPE *pOMXComponent,
+ OMX_U32 nPortIndex,
+ OMX_U32 nBufferCnt)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
+ void *hMFCHandle = pWmvDec->hMFCWmvHandle.hMFCHandle;
+ CODEC_DEC_BUFFER **ppCodecBuffer = NULL;
+ ExynosVideoDecBufferOps *pBufOps = NULL;
+ ExynosVideoPlane *pPlanes = NULL;
+
+ OMX_U32 nPlaneCnt = 0;
+ int i, j;
+
+ FunctionIn();
+
+ if (nPortIndex == INPUT_PORT_INDEX) {
+ ppCodecBuffer = &(pVideoDec->pMFCDecInputBuffer[0]);
+ nPlaneCnt = MFC_INPUT_BUFFER_PLANE;
+ pBufOps = pWmvDec->hMFCWmvHandle.pInbufOps;
+ } else {
+ ppCodecBuffer = &(pVideoDec->pMFCDecOutputBuffer[0]);
+ nPlaneCnt = MFC_OUTPUT_BUFFER_PLANE;
+ pBufOps = pWmvDec->hMFCWmvHandle.pOutbufOps;
+ }
+
+ pPlanes = (ExynosVideoPlane *)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane) * nPlaneCnt);
+ if (pPlanes == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ /* Register buffer */
+ for (i = 0; i < nBufferCnt; i++) {
+ for (j = 0; j < nPlaneCnt; j++) {
+ pPlanes[j].addr = ppCodecBuffer[i]->pVirAddr[j];
+ pPlanes[j].fd = ppCodecBuffer[i]->fd[j];
+ pPlanes[j].allocSize = ppCodecBuffer[i]->bufferSize[j];
+ }
+
+ if (pBufOps->Register(hMFCHandle, pPlanes, nPlaneCnt) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "PORT[%d]: Failed to Register buffer", nPortIndex);
+ ret = OMX_ErrorInsufficientResources;
+ Exynos_OSAL_Free(pPlanes);
+ goto EXIT;
+ }
+ }
+
+ Exynos_OSAL_Free(pPlanes);
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE WmvCodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
}
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
- /* Register input buffer */
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- ExynosVideoPlane plane;
- plane.addr = pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0];
- plane.allocSize = pVideoDec->pMFCDecInputBuffer[i]->bufferSize[0];
- plane.fd = pVideoDec->pMFCDecInputBuffer[i]->fd[0];
- if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- }
+ ret = WMVCodecRegistCodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
/* Register input buffer */
for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) {
pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameHeight >> 1);
if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
- /* Register output buffer */
- for (i = 0; i < nOutbufs; i++) {
- pVideoDec->pMFCDecOutputBuffer[i] = (CODEC_DEC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Memset(pVideoDec->pMFCDecOutputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
-
- for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
- pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] =
- (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nAllocLen[plane], NORMAL_MEMORY);
- if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] == NULL) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Alloc output buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- pVideoDec->pMFCDecOutputBuffer[i]->fd[plane] =
- Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory,
- pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]);
- pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane] = nAllocLen[plane];
-
- planes[plane].addr = pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane];
- planes[plane].fd = pVideoDec->pMFCDecOutputBuffer[i]->fd[plane];
- planes[plane].allocSize = pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane];
- }
+ ret = Exynos_Allocate_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs, nAllocLen);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
- if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
+ ret = WMVCodecRegistCodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+
+ /* Enqueue output buffer */
+ for (i = 0; i < nOutbufs; i++) {
pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr,
(unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
}
pOutbufOps = pWmvDec->hMFCWmvHandle.pOutbufOps;
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
+ OMX_U32 nPlaneSize[MFC_INPUT_BUFFER_PLANE] = {DEFAULT_MFC_INPUT_BUFFER_SIZE};
Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID);
Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS);
+ ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- pVideoDec->pMFCDecInputBuffer[i] = Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Memset(pVideoDec->pMFCDecInputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]);
-
- for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
- /* Use ION Allocator */
- pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, DEFAULT_MFC_INPUT_BUFFER_SIZE, NORMAL_MEMORY);
- pVideoDec->pMFCDecInputBuffer[i]->fd[plane] = Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- pVideoDec->pMFCDecInputBuffer[i]->bufferSize[plane] = DEFAULT_MFC_INPUT_BUFFER_SIZE;
- pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0;
- if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] == NULL) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Fail input buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[%d]: 0x%x", i, plane, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- }
-
+ for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++)
Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]);
- }
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
/*************/
/* TBD */
pWmvDec->bSourceStart = OMX_FALSE;
if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
- for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
- if (pVideoDec->pMFCDecOutputBuffer[i] != NULL) {
- for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
- if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] != NULL)
- Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]);
- }
-
- Exynos_OSAL_Free(pVideoDec->pMFCDecOutputBuffer[i]);
- pVideoDec->pMFCDecOutputBuffer[i] = NULL;
- }
- }
-
+ Exynos_Free_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX);
Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ);
Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID);
} else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
}
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- if (pVideoDec->pMFCDecInputBuffer[i] != NULL) {
- for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
- if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] != NULL)
- Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- }
-
- Exynos_OSAL_Free(pVideoDec->pMFCDecInputBuffer[i]);
- pVideoDec->pMFCDecInputBuffer[i] = NULL;
- }
- }
-
+ Exynos_Free_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX);
Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ);
Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID);
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
return ret;
}
+OMX_ERRORTYPE VP8CodecRegistCodecBuffers(
+ OMX_COMPONENTTYPE *pOMXComponent,
+ OMX_U32 nPortIndex,
+ OMX_U32 nBufferCnt)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_VP8DEC_HANDLE *pVp8Dec = (EXYNOS_VP8DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
+ void *hMFCHandle = pVp8Dec->hMFCVp8Handle.hMFCHandle;
+ CODEC_DEC_BUFFER **ppCodecBuffer = NULL;
+ ExynosVideoDecBufferOps *pBufOps = NULL;
+ ExynosVideoPlane *pPlanes = NULL;
+
+ OMX_U32 nPlaneCnt = 0;
+ int i, j;
+
+ FunctionIn();
+
+ if (nPortIndex == INPUT_PORT_INDEX) {
+ ppCodecBuffer = &(pVideoDec->pMFCDecInputBuffer[0]);
+ nPlaneCnt = MFC_INPUT_BUFFER_PLANE;
+ pBufOps = pVp8Dec->hMFCVp8Handle.pInbufOps;
+ } else {
+ ppCodecBuffer = &(pVideoDec->pMFCDecOutputBuffer[0]);
+ nPlaneCnt = MFC_OUTPUT_BUFFER_PLANE;
+ pBufOps = pVp8Dec->hMFCVp8Handle.pOutbufOps;
+ }
+
+ pPlanes = (ExynosVideoPlane *)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane) * nPlaneCnt);
+ if (pPlanes == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ /* Register buffer */
+ for (i = 0; i < nBufferCnt; i++) {
+ for (j = 0; j < nPlaneCnt; j++) {
+ pPlanes[j].addr = ppCodecBuffer[i]->pVirAddr[j];
+ pPlanes[j].fd = ppCodecBuffer[i]->fd[j];
+ pPlanes[j].allocSize = ppCodecBuffer[i]->bufferSize[j];
+ }
+
+ if (pBufOps->Register(hMFCHandle, pPlanes, nPlaneCnt) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "PORT[%d]: Failed to Register buffer", nPortIndex);
+ ret = OMX_ErrorInsufficientResources;
+ Exynos_OSAL_Free(pPlanes);
+ goto EXIT;
+ }
+ }
+
+ Exynos_OSAL_Free(pPlanes);
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE VP8CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
}
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
- /* Register input buffer */
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- ExynosVideoPlane plane;
- plane.addr = pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0];
- plane.allocSize = pVideoDec->pMFCDecInputBuffer[i]->bufferSize[0];
- plane.fd = pVideoDec->pMFCDecInputBuffer[i]->fd[0];
- if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- }
+ ret = VP8CodecRegistCodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
/* Register input buffer */
for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) {
pVp8Dec->hMFCVp8Handle.codecOutbufConf.nFrameHeight >> 1);
if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
- /* Register output buffer */
- for (i = 0; i < nOutbufs; i++) {
- pVideoDec->pMFCDecOutputBuffer[i] = (CODEC_DEC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Memset(pVideoDec->pMFCDecOutputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
-
- for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
- pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] =
- (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nAllocLen[plane], NORMAL_MEMORY);
- if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] == NULL) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Alloc output buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- pVideoDec->pMFCDecOutputBuffer[i]->fd[plane] =
- Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory,
- pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]);
- pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane] = nAllocLen[plane];
-
- planes[plane].addr = pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane];
- planes[plane].fd = pVideoDec->pMFCDecOutputBuffer[i]->fd[plane];
- planes[plane].allocSize = pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane];
- }
+ ret = Exynos_Allocate_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs, nAllocLen);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
- if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
+ ret = VP8CodecRegistCodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+
+ /* Enqueue output buffer */
+ for (i = 0; i < nOutbufs; i++) {
pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr,
(unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
}
pOutbufOps = pVp8Dec->hMFCVp8Handle.pOutbufOps;
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
+ OMX_U32 nPlaneSize[MFC_INPUT_BUFFER_PLANE] = {DEFAULT_MFC_INPUT_BUFFER_SIZE};
Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID);
Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS);
+ ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- pVideoDec->pMFCDecInputBuffer[i] = Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Memset(pVideoDec->pMFCDecInputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER));
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]);
-
- for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
- /* Use ION Allocator */
- pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, DEFAULT_MFC_INPUT_BUFFER_SIZE, NORMAL_MEMORY);
- pVideoDec->pMFCDecInputBuffer[i]->fd[plane] = Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- pVideoDec->pMFCDecInputBuffer[i]->bufferSize[plane] = DEFAULT_MFC_INPUT_BUFFER_SIZE;
- pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0;
- if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] == NULL) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Fail input buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[%d]: 0x%x", i, plane, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- }
-
+ for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++)
Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]);
- }
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
/*************/
/* TBD */
pVp8Dec->bSourceStart = OMX_FALSE;
if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
- for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
- if (pVideoDec->pMFCDecOutputBuffer[i] != NULL) {
- for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
- if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] != NULL)
- Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]);
- }
-
- Exynos_OSAL_Free(pVideoDec->pMFCDecOutputBuffer[i]);
- pVideoDec->pMFCDecOutputBuffer[i] = NULL;
- }
- }
-
+ Exynos_Free_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX);
Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ);
Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID);
} else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
}
if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
- for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
- if (pVideoDec->pMFCDecInputBuffer[i] != NULL) {
- for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
- if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] != NULL)
- Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
- }
-
- Exynos_OSAL_Free(pVideoDec->pMFCDecInputBuffer[i]);
- pVideoDec->pMFCDecInputBuffer[i] = NULL;
- }
- }
-
+ Exynos_Free_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX);
Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ);
Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID);
} else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {