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_Venc.c
21 * @author SeungBeom Kim (sbcrux.kim@samsung.com)
22 * Yunji Kim (yunji.kim@samsung.com)
32 #include "Exynos_OMX_Macros.h"
33 #include "Exynos_OSAL_Event.h"
34 #include "Exynos_OMX_Venc.h"
35 #include "Exynos_OMX_VencControl.h"
36 #include "Exynos_OMX_Basecomponent.h"
37 #include "Exynos_OSAL_Thread.h"
38 #include "Exynos_OSAL_Semaphore.h"
39 #include "Exynos_OSAL_Mutex.h"
40 #include "Exynos_OSAL_ETC.h"
41 #include "ExynosVideoApi.h"
43 #include "Exynos_OSAL_SharedMemory.h"
46 #define EXYNOS_LOG_TAG "EXYNOS_VIDEO_ENC"
47 #define EXYNOS_LOG_OFF
48 //#define EXYNOS_TRACE_ON
49 #include "Exynos_OSAL_Log.h"
52 void Exynos_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent)
54 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
55 EXYNOS_OMX_BASEPORT *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
56 EXYNOS_OMX_BASEPORT *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
58 if ((exynosOutputPort->portDefinition.format.video.nFrameWidth !=
59 exynosInputPort->portDefinition.format.video.nFrameWidth) ||
60 (exynosOutputPort->portDefinition.format.video.nFrameHeight !=
61 exynosInputPort->portDefinition.format.video.nFrameHeight)) {
62 OMX_U32 width = 0, height = 0;
64 exynosOutputPort->portDefinition.format.video.nFrameWidth =
65 exynosInputPort->portDefinition.format.video.nFrameWidth;
66 exynosOutputPort->portDefinition.format.video.nFrameHeight =
67 exynosInputPort->portDefinition.format.video.nFrameHeight;
68 width = exynosOutputPort->portDefinition.format.video.nStride =
69 exynosInputPort->portDefinition.format.video.nStride;
70 height = exynosOutputPort->portDefinition.format.video.nSliceHeight =
71 exynosInputPort->portDefinition.format.video.nSliceHeight;
74 exynosOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
80 OMX_BOOL Exynos_Check_BufferProcess_State(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 nPortIndex)
82 OMX_BOOL ret = OMX_FALSE;
84 if ((pExynosComponent->currentState == OMX_StateExecuting) &&
85 (pExynosComponent->pExynosPort[nPortIndex].portState == OMX_StateIdle) &&
86 (pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
87 (pExynosComponent->transientState != EXYNOS_OMX_TransStateIdleToExecuting)) {
96 OMX_ERRORTYPE Exynos_Input_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR codecBuffer, EXYNOS_OMX_DATA *pData)
98 OMX_ERRORTYPE ret = OMX_ErrorNone;
99 CODEC_ENC_BUFFER *pInputCodecBuffer = (CODEC_ENC_BUFFER*)codecBuffer;
101 pData->buffer.multiPlaneBuffer.dataBuffer[0] = pInputCodecBuffer->pVirAddr[0];
102 pData->buffer.multiPlaneBuffer.dataBuffer[1] = pInputCodecBuffer->pVirAddr[1];
103 pData->allocSize = pInputCodecBuffer->bufferSize[0] + pInputCodecBuffer->bufferSize[1];
104 pData->dataLen = pInputCodecBuffer->dataSize;
105 pData->usedDataLen = 0;
106 pData->remainDataLen = pInputCodecBuffer->dataSize;
109 pData->timeStamp = 0;
110 pData->pPrivate = codecBuffer;
111 pData->bufferHeader = NULL;
116 OMX_ERRORTYPE Exynos_Output_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR codecBuffer, EXYNOS_OMX_DATA *pData)
118 OMX_ERRORTYPE ret = OMX_ErrorNone;
119 EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
123 pVideoEnc->exynos_codec_getCodecOutputPrivateData(codecBuffer, &pSrcBuf, &allocSize);
124 pData->buffer.singlePlaneBuffer.dataBuffer = pSrcBuf;
125 pData->allocSize = allocSize;
127 pData->usedDataLen = 0;
128 pData->remainDataLen = 0;
131 pData->timeStamp = 0;
132 pData->pPrivate = codecBuffer;
133 pData->bufferHeader = NULL;
138 void Exynos_Wait_ProcessPause(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 nPortIndex)
140 EXYNOS_OMX_BASEPORT *exynosOMXPort = NULL;
144 exynosOMXPort = &pExynosComponent->pExynosPort[nPortIndex];
146 if (((pExynosComponent->currentState == OMX_StatePause) ||
147 (pExynosComponent->currentState == OMX_StateIdle) ||
148 (pExynosComponent->transientState == EXYNOS_OMX_TransStateLoadedToIdle) ||
149 (pExynosComponent->transientState == EXYNOS_OMX_TransStateExecutingToIdle)) &&
150 (pExynosComponent->transientState != EXYNOS_OMX_TransStateIdleToLoaded) &&
151 (!CHECK_PORT_BEING_FLUSHED(exynosOMXPort))) {
152 Exynos_OSAL_SignalWait(pExynosComponent->pExynosPort[nPortIndex].pauseEvent, DEF_MAX_WAIT_TIME);
153 Exynos_OSAL_SignalReset(pExynosComponent->pExynosPort[nPortIndex].pauseEvent);
161 OMX_BOOL Exynos_CSC_InputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *srcInputData)
163 OMX_BOOL ret = OMX_FALSE;
164 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
165 EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
166 EXYNOS_OMX_BASEPORT *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
167 EXYNOS_OMX_DATABUFFER *inputUseBuffer = &exynosInputPort->way.port2WayDataBuffer.inputDataBuffer;
168 OMX_U32 nFrameWidth = exynosInputPort->portDefinition.format.video.nFrameWidth;
169 OMX_U32 nFrameHeight = exynosInputPort->portDefinition.format.video.nFrameHeight;
170 OMX_COLOR_FORMATTYPE eColorFormat = exynosInputPort->portDefinition.format.video.eColorFormat;
171 OMX_BYTE checkInputStream = NULL;
175 checkInputStream = inputUseBuffer->bufferHeader->pBuffer;
177 CODEC_ENC_BUFFER *codecInputBuffer = (CODEC_ENC_BUFFER *)srcInputData->pPrivate;
178 codecInputBuffer->dataSize = ((nFrameWidth * nFrameHeight) * 3) / 2;
180 unsigned int csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420SemiPlanar);
181 unsigned int csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420SemiPlanar);
182 CSC_METHOD csc_method = CSC_METHOD_SW;
183 unsigned int cacheable = 1;
185 unsigned char *pSrcBuf[3] = {NULL, };
186 unsigned char *pDstBuf[3] = {NULL, };
188 CSC_ERRORCODE cscRet = CSC_ErrorNone;
190 pSrcBuf[0] = checkInputStream;
191 pSrcBuf[1] = checkInputStream + (nFrameWidth * nFrameHeight);
192 pSrcBuf[2] = checkInputStream + (((nFrameWidth * nFrameHeight) * 5) / 4);
194 pDstBuf[0] = srcInputData->buffer.multiPlaneBuffer.dataBuffer[0];
195 pDstBuf[1] = srcInputData->buffer.multiPlaneBuffer.dataBuffer[1];
196 pDstBuf[2] = srcInputData->buffer.multiPlaneBuffer.dataBuffer[2];
198 csc_get_method(pVideoEnc->csc_handle, &csc_method);
199 if (csc_method == CSC_METHOD_HW) {
200 pDstBuf[0] = (unsigned char*)(&srcInputData->buffer.multiPlaneBuffer.fd[0]);
201 pDstBuf[1] = (unsigned char*)(&srcInputData->buffer.multiPlaneBuffer.fd[1]);
202 pDstBuf[2] = (unsigned char*)(&srcInputData->buffer.multiPlaneBuffer.fd[2]);
205 #ifdef USE_METADATABUFFERTYPE
206 OMX_PTR ppBuf[MAX_BUFFER_PLANE];
208 /* kMetadataBufferTypeGrallocSource */
209 if (exynosInputPort->bStoreMetaData == OMX_TRUE) {
210 /* ARGB8888 converted to YUV420SemiPlanar */
211 csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_Format32bitARGB8888);
212 csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420SemiPlanar);
214 Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)inputUseBuffer->bufferHeader->pBuffer, ppBuf);
215 if (eColorFormat == OMX_COLOR_FormatAndroidOpaque) {
216 ExynosVideoPlane planes[MAX_BUFFER_PLANE];
220 Exynos_OSAL_LockPB((OMX_U32)ppBuf[0], nFrameWidth, nFrameHeight, OMX_COLOR_FormatAndroidOpaque, &stride, planes);
221 imageSize = nFrameWidth * nFrameHeight * 3; /* RGB888 */
223 if (csc_method == CSC_METHOD_HW)
224 pSrcBuf[0] = (unsigned char *)planes[0].fd;
227 pSrcBuf[0] = planes[0].addr;
235 if (csc_method == CSC_METHOD_HW) {
236 pSrcBuf[0] = Exynos_OSAL_SharedMemory_VirtToION(pVideoEnc->hSharedMemory, checkInputStream);
242 switch (eColorFormat) {
243 case OMX_COLOR_FormatYUV420Planar:
244 /* YUV420Planar converted to YUV420Semiplanar (interleaved UV plane) as per MFC spec.*/
245 csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420Planar);
246 csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420SemiPlanar);
248 case OMX_COLOR_FormatYUV420SemiPlanar:
249 case OMX_SEC_COLOR_FormatNV12Tiled:
250 case OMX_SEC_COLOR_FormatNV21Linear:
251 /* Just copied to MFC input buffer */
252 csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420SemiPlanar);
253 csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420SemiPlanar);
261 pVideoEnc->csc_handle, /* handle */
262 nFrameWidth, /* width */
263 nFrameHeight, /* height */
266 nFrameWidth, /* crop_width */
267 nFrameHeight, /* crop_height */
268 csc_src_color_format, /* color_format */
269 cacheable); /* cacheable */
271 pVideoEnc->csc_handle, /* handle */
272 nFrameWidth, /* width */
273 nFrameHeight, /* height */
276 nFrameWidth, /* crop_width */
277 nFrameHeight, /* crop_height */
278 csc_dst_color_format, /* color_format */
279 cacheable); /* cacheable */
281 pVideoEnc->csc_handle, /* handle */
282 pSrcBuf[0], /* y addr */
283 pSrcBuf[1], /* u addr or uv addr */
284 pSrcBuf[2], /* v addr or none */
287 pVideoEnc->csc_handle, /* handle */
288 pDstBuf[0], /* y addr */
289 pDstBuf[1], /* u addr or uv addr */
290 pDstBuf[2], /* v addr or none */
292 cscRet = csc_convert(pVideoEnc->csc_handle);
293 if (cscRet != CSC_ErrorNone)
298 #ifdef USE_METADATABUFFERTYPE
299 if (exynosInputPort->bStoreMetaData == OMX_TRUE) {
300 Exynos_OSAL_UnlockANBHandle((OMX_U32)ppBuf[0]);
311 OMX_BOOL Exynos_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *srcInputData)
313 OMX_BOOL ret = OMX_FALSE;
314 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
315 EXYNOS_OMX_BASEPORT *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
316 EXYNOS_OMX_DATABUFFER *inputUseBuffer = &exynosInputPort->way.port2WayDataBuffer.inputDataBuffer;
317 OMX_U32 copySize = 0;
318 OMX_U32 checkInputStreamLen = 0;
322 if (exynosInputPort->bufferProcessType & BUFFER_COPY) {
323 if ((srcInputData->buffer.multiPlaneBuffer.dataBuffer[0] == NULL) ||
324 (srcInputData->pPrivate == NULL)) {
330 if (inputUseBuffer->dataValid == OMX_TRUE) {
331 if (exynosInputPort->bufferProcessType & BUFFER_SHARE) {
332 Exynos_Shared_BufferToData(inputUseBuffer, srcInputData, ONE_PLANE);
333 #ifdef USE_METADATABUFFERTYPE
334 if (exynosInputPort->bStoreMetaData == OMX_TRUE) {
335 OMX_PTR ppBuf[MAX_BUFFER_PLANE];
336 OMX_PTR allocSize[MAX_BUFFER_PLANE];
339 /* kMetadataBufferTypeCameraSource */
340 Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)inputUseBuffer->bufferHeader->pBuffer, ppBuf);
342 EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
344 srcInputData->buffer.multiPlaneBuffer.fd[0] = ppBuf[0];
345 srcInputData->buffer.multiPlaneBuffer.fd[1] = ppBuf[1];
346 allocSize[0] = nFrameWidth * nFrameHeight;
347 allocSize[1] = nFrameWidth * nFrameHeight >> 1;
349 for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
350 srcInputData->buffer.multiPlaneBuffer.dataBuffer[plane] =
351 Exynos_OSAL_SharedMemory_IONToVirt(pVideoEnc->hSharedMemory, srcInputData->buffer.multiPlaneBuffer.fd[plane]);
352 if(srcInputData->buffer.multiPlaneBuffer.dataBuffer[plane] == NULL) {
353 srcInputData->buffer.multiPlaneBuffer.dataBuffer[plane] =
354 Exynos_OSAL_SharedMemory_Map(pVideoEnc->hSharedMemory, allocSize[plane], srcInputData->buffer.multiPlaneBuffer.fd[plane]);
357 /* input buffers are 2 plane. */
358 srcInputData->buffer.multiPlaneBuffer.dataBuffer[2] = NULL;
359 srcInputData->buffer.multiPlaneBuffer.fd[2] = -1;
361 for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
362 srcInputData->buffer.multiPlaneBuffer.dataBuffer[plane] = ppBuf[plane];
364 srcInputData->buffer.multiPlaneBuffer.dataBuffer[2] = NULL;
366 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s:%d YAddr: 0x%x CbCrAddr: 0x%x", __FUNCTION__, __LINE__, (unsigned int)ppBuf[0], (unsigned int)ppBuf[1]);
368 #else // for Tizen Camera scenario
369 MMVideoBuffer *mm_buf = (MMVideoBuffer*)inputUseBuffer->bufferHeader->pBuffer;
372 for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
373 srcInputData->buffer.multiPlaneBuffer.dataBuffer[plane] = mm_buf->data[plane];//handle.paddr[plane];
374 srcInputData->buffer.multiPlaneBuffer.fd[plane] = mm_buf->handle.dmabuf_fd[plane];
375 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "[ENC] get fd[%d] %d , a[%d] %x "
376 , plane, srcInputData->buffer.multiPlaneBuffer.fd[plane], plane, srcInputData->buffer.multiPlaneBuffer.dataBuffer[plane] );
381 /* input buffers are 2 plane. */
382 srcInputData->buffer.multiPlaneBuffer.dataBuffer[2] = NULL;
383 srcInputData->buffer.multiPlaneBuffer.fd[2] = -1;
385 /* reset dataBuffer */
386 Exynos_ResetDataBuffer(inputUseBuffer);
387 } else if (exynosInputPort->bufferProcessType & BUFFER_COPY) {
388 checkInputStreamLen = inputUseBuffer->remainDataLen;
390 pExynosComponent->bUseFlagEOF = OMX_TRUE;
392 if (checkInputStreamLen == 0) {
393 inputUseBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
396 copySize = checkInputStreamLen;
397 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "exynos_checkInputFrame : OMX_TRUE");
399 if (((srcInputData->allocSize) - (srcInputData->dataLen)) >= copySize) {
400 Exynos_CSC_InputData(pOMXComponent, srcInputData);
402 inputUseBuffer->dataLen -= copySize;
403 inputUseBuffer->remainDataLen -= copySize;
404 inputUseBuffer->usedDataLen += copySize;
406 srcInputData->dataLen += copySize;
407 srcInputData->remainDataLen += copySize;
409 srcInputData->timeStamp = inputUseBuffer->timeStamp;
410 srcInputData->nFlags = inputUseBuffer->nFlags;
411 srcInputData->bufferHeader = inputUseBuffer->bufferHeader;
413 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "input codec buffer is smaller than decoded input data size Out Length");
414 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
415 pExynosComponent->callbackData,
416 OMX_EventError, OMX_ErrorUndefined, 0, NULL);
420 #ifndef TIZEN_FEATURE_E3250
421 if (((exynosInputPort->bStoreMetaData == OMX_TRUE) && (eColorFormat == OMX_COLOR_FormatAndroidOpaque)) ||
422 (exynosInputPort->bStoreMetaData == OMX_FALSE))
424 if (exynosInputPort->bStoreMetaData == OMX_FALSE)
427 Exynos_InputBufferReturn(pOMXComponent);
429 inputUseBuffer->dataValid = OMX_TRUE;
433 if ((srcInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
434 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "bSaveFlagEOS : OMX_TRUE");
435 srcInputData->dataLen = 0;
436 srcInputData->remainDataLen = 0;
437 pExynosComponent->bSaveFlagEOS = OMX_TRUE;
440 if (pExynosComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) {
441 pExynosComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_TRUE;
442 pExynosComponent->checkTimeStamp.startTimeStamp = srcInputData->timeStamp;
443 pExynosComponent->checkTimeStamp.nStartFlags = srcInputData->nFlags;
444 pExynosComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
445 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "first frame timestamp after seeking %lld us (%.2f secs)",
446 srcInputData->timeStamp, srcInputData->timeStamp / 1E6);
459 OMX_BOOL Exynos_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *dstOutputData)
461 OMX_BOOL ret = OMX_FALSE;
462 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
463 EXYNOS_OMX_BASEPORT *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
464 EXYNOS_OMX_DATABUFFER *outputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.outputDataBuffer;
465 OMX_U32 copySize = 0;
469 if (exynosOutputPort->bufferProcessType & BUFFER_SHARE) {
470 if (Exynos_Shared_DataToBuffer(dstOutputData, outputUseBuffer) == OMX_ErrorNone)
471 outputUseBuffer->dataValid = OMX_TRUE;
474 if (outputUseBuffer->dataValid == OMX_TRUE) {
475 if (pExynosComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE) {
476 if (pExynosComponent->checkTimeStamp.startTimeStamp == dstOutputData->timeStamp){
477 pExynosComponent->checkTimeStamp.startTimeStamp = -19761123;
478 pExynosComponent->checkTimeStamp.nStartFlags = 0x0;
479 pExynosComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
480 pExynosComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
482 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "drop frame after seeking");
486 } else if (pExynosComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) {
488 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "not set check timestamp after seeking");
492 if (exynosOutputPort->bufferProcessType & BUFFER_COPY) {
493 if (dstOutputData->remainDataLen <= (outputUseBuffer->allocSize - outputUseBuffer->dataLen)) {
494 copySize = dstOutputData->remainDataLen;
496 Exynos_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen),
497 (dstOutputData->buffer.singlePlaneBuffer.dataBuffer + dstOutputData->usedDataLen),
499 outputUseBuffer->dataLen += copySize;
500 outputUseBuffer->remainDataLen += copySize;
501 outputUseBuffer->nFlags = dstOutputData->nFlags;
502 outputUseBuffer->timeStamp = dstOutputData->timeStamp;
506 if ((outputUseBuffer->remainDataLen > 0) ||
507 (outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)) {
508 Exynos_OutputBufferReturn(pOMXComponent);
511 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "output buffer is smaller than encoded data size Out Length");
512 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
513 pExynosComponent->callbackData,
514 OMX_EventError, OMX_ErrorUndefined, 0, NULL);
517 } else if (exynosOutputPort->bufferProcessType & BUFFER_SHARE) {
518 if ((outputUseBuffer->remainDataLen > 0) ||
519 ((outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) ||
520 (CHECK_PORT_BEING_FLUSHED(exynosOutputPort)))
521 Exynos_OutputBufferReturn(pOMXComponent);
533 OMX_ERRORTYPE Exynos_OMX_SrcInputBufferProcess(OMX_HANDLETYPE hComponent)
535 OMX_ERRORTYPE ret = OMX_ErrorNone;
536 OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
537 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
538 EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
539 EXYNOS_OMX_BASEPORT *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
540 EXYNOS_OMX_DATABUFFER *srcInputUseBuffer = &exynosInputPort->way.port2WayDataBuffer.inputDataBuffer;
541 EXYNOS_OMX_DATA *pSrcInputData = &exynosInputPort->processData;
542 OMX_BOOL bCheckInputData = OMX_FALSE;
546 while (!pVideoEnc->bExitBufferProcessThread) {
547 Exynos_OSAL_SleepMillisec(0);
548 Exynos_Wait_ProcessPause(pExynosComponent, INPUT_PORT_INDEX);
550 while ((Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) &&
551 (!pVideoEnc->bExitBufferProcessThread)) {
552 Exynos_OSAL_SleepMillisec(0);
554 if (CHECK_PORT_BEING_FLUSHED(exynosInputPort))
556 if (exynosInputPort->portState != OMX_StateIdle)
559 Exynos_OSAL_MutexLock(srcInputUseBuffer->bufferMutex);
560 if (exynosInputPort->bufferProcessType & BUFFER_COPY) {
562 if ((pSrcInputData->buffer.multiPlaneBuffer.dataBuffer[0] == NULL) || (pSrcInputData->pPrivate == NULL)) {
563 Exynos_CodecBufferDequeue(pExynosComponent, INPUT_PORT_INDEX, &codecBuffer);
564 if (codecBuffer != NULL) {
565 Exynos_Input_CodecBufferToData(pExynosComponent, codecBuffer, pSrcInputData);
567 Exynos_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
572 if (srcInputUseBuffer->dataValid == OMX_TRUE) {
573 bCheckInputData = Exynos_Preprocessor_InputData(pOMXComponent, pSrcInputData);
575 bCheckInputData = OMX_FALSE;
578 if ((bCheckInputData == OMX_FALSE) &&
579 (!CHECK_PORT_BEING_FLUSHED(exynosInputPort))) {
580 ret = Exynos_InputBufferGetQueue(pExynosComponent);
581 Exynos_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
585 if (CHECK_PORT_BEING_FLUSHED(exynosInputPort)) {
586 Exynos_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
590 ret = pVideoEnc->exynos_codec_srcInputProcess(pOMXComponent, pSrcInputData);
591 Exynos_ResetCodecData(pSrcInputData);
592 Exynos_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
593 if (ret == (OMX_ERRORTYPE)OMX_ErrorCodecInit)
594 pVideoEnc->bExitBufferProcessThread = OMX_TRUE;
603 OMX_ERRORTYPE Exynos_OMX_SrcOutputBufferProcess(OMX_HANDLETYPE hComponent)
605 OMX_ERRORTYPE ret = OMX_ErrorNone;
606 OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
607 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
608 EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
609 EXYNOS_OMX_BASEPORT *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
610 EXYNOS_OMX_DATABUFFER *srcOutputUseBuffer = &exynosInputPort->way.port2WayDataBuffer.outputDataBuffer;
611 EXYNOS_OMX_DATA srcOutputData;
615 while (!pVideoEnc->bExitBufferProcessThread) {
616 Exynos_OSAL_SleepMillisec(0);
618 while (!pVideoEnc->bExitBufferProcessThread) {
619 if (exynosInputPort->bufferProcessType & BUFFER_COPY) {
620 if (Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX) == OMX_FALSE)
623 Exynos_OSAL_SleepMillisec(0);
625 if (CHECK_PORT_BEING_FLUSHED(exynosInputPort))
628 Exynos_OSAL_MutexLock(srcOutputUseBuffer->bufferMutex);
629 ret = pVideoEnc->exynos_codec_srcOutputProcess(pOMXComponent, &srcOutputData);
631 if (ret == OMX_ErrorNone) {
632 if (exynosInputPort->bufferProcessType & BUFFER_COPY) {
634 codecBuffer = srcOutputData.pPrivate;
635 if (codecBuffer != NULL)
636 Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, codecBuffer);
638 if (exynosInputPort->bufferProcessType & BUFFER_SHARE) {
639 Exynos_Shared_DataToBuffer(&srcOutputData, srcOutputUseBuffer);
640 Exynos_InputBufferReturn(pOMXComponent);
642 Exynos_ResetCodecData(&srcOutputData);
644 Exynos_OSAL_MutexUnlock(srcOutputUseBuffer->bufferMutex);
653 OMX_ERRORTYPE Exynos_OMX_DstInputBufferProcess(OMX_HANDLETYPE hComponent)
655 OMX_ERRORTYPE ret = OMX_ErrorNone;
656 OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
657 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
658 EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
659 EXYNOS_OMX_BASEPORT *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
660 EXYNOS_OMX_DATABUFFER *dstInputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.inputDataBuffer;
661 EXYNOS_OMX_DATA dstInputData;
665 while (!pVideoEnc->bExitBufferProcessThread) {
666 Exynos_OSAL_SleepMillisec(0);
668 while ((Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) &&
669 (!pVideoEnc->bExitBufferProcessThread)) {
670 Exynos_OSAL_SleepMillisec(0);
672 if ((CHECK_PORT_BEING_FLUSHED(exynosOutputPort)) ||
673 (!CHECK_PORT_POPULATED(exynosOutputPort)))
675 if (exynosOutputPort->portState != OMX_StateIdle)
678 Exynos_OSAL_MutexLock(dstInputUseBuffer->bufferMutex);
679 if (exynosOutputPort->bufferProcessType & BUFFER_COPY) {
681 ret = Exynos_CodecBufferDequeue(pExynosComponent, OUTPUT_PORT_INDEX, &codecBuffer);
682 if (ret != OMX_ErrorNone) {
683 Exynos_OSAL_MutexUnlock(dstInputUseBuffer->bufferMutex);
686 Exynos_Output_CodecBufferToData(pExynosComponent, codecBuffer, &dstInputData);
689 if (exynosOutputPort->bufferProcessType & BUFFER_SHARE) {
690 if ((dstInputUseBuffer->dataValid != OMX_TRUE) &&
691 (!CHECK_PORT_BEING_FLUSHED(exynosOutputPort))) {
692 ret = Exynos_OutputBufferGetQueue(pExynosComponent);
693 if (ret != OMX_ErrorNone) {
694 Exynos_OSAL_MutexUnlock(dstInputUseBuffer->bufferMutex);
697 Exynos_Shared_BufferToData(dstInputUseBuffer, &dstInputData, ONE_PLANE);
698 Exynos_ResetDataBuffer(dstInputUseBuffer);
702 if (CHECK_PORT_BEING_FLUSHED(exynosOutputPort)) {
703 Exynos_OSAL_MutexUnlock(dstInputUseBuffer->bufferMutex);
706 ret = pVideoEnc->exynos_codec_dstInputProcess(pOMXComponent, &dstInputData);
708 Exynos_ResetCodecData(&dstInputData);
709 Exynos_OSAL_MutexUnlock(dstInputUseBuffer->bufferMutex);
718 OMX_ERRORTYPE Exynos_OMX_DstOutputBufferProcess(OMX_HANDLETYPE hComponent)
720 OMX_ERRORTYPE ret = OMX_ErrorNone;
721 OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
722 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
723 EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
724 EXYNOS_OMX_BASEPORT *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
725 EXYNOS_OMX_DATABUFFER *dstOutputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.outputDataBuffer;
726 EXYNOS_OMX_DATA *pDstOutputData = &exynosOutputPort->processData;
730 while (!pVideoEnc->bExitBufferProcessThread) {
731 Exynos_OSAL_SleepMillisec(0);
732 Exynos_Wait_ProcessPause(pExynosComponent, OUTPUT_PORT_INDEX);
734 while ((Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) &&
735 (!pVideoEnc->bExitBufferProcessThread)) {
736 Exynos_OSAL_SleepMillisec(0);
738 if (CHECK_PORT_BEING_FLUSHED(exynosOutputPort))
741 Exynos_OSAL_MutexLock(dstOutputUseBuffer->bufferMutex);
742 if (exynosOutputPort->bufferProcessType & BUFFER_COPY) {
743 if ((dstOutputUseBuffer->dataValid != OMX_TRUE) &&
744 (!CHECK_PORT_BEING_FLUSHED(exynosOutputPort))) {
745 ret = Exynos_OutputBufferGetQueue(pExynosComponent);
746 if (ret != OMX_ErrorNone) {
747 Exynos_OSAL_MutexUnlock(dstOutputUseBuffer->bufferMutex);
753 if ((dstOutputUseBuffer->dataValid == OMX_TRUE) ||
754 (exynosOutputPort->bufferProcessType & BUFFER_SHARE))
755 ret = pVideoEnc->exynos_codec_dstOutputProcess(pOMXComponent, pDstOutputData);
757 if (((ret == OMX_ErrorNone) && (dstOutputUseBuffer->dataValid == OMX_TRUE)) ||
758 (exynosOutputPort->bufferProcessType & BUFFER_SHARE)) {
759 Exynos_Postprocess_OutputData(pOMXComponent, pDstOutputData);
762 if (exynosOutputPort->bufferProcessType & BUFFER_COPY) {
764 codecBuffer = pDstOutputData->pPrivate;
765 if (codecBuffer != NULL) {
766 Exynos_CodecBufferEnqueue(pExynosComponent, OUTPUT_PORT_INDEX, codecBuffer);
767 pDstOutputData->pPrivate = NULL;
771 /* reset outputData */
772 Exynos_ResetCodecData(pDstOutputData);
773 Exynos_OSAL_MutexUnlock(dstOutputUseBuffer->bufferMutex);
782 static OMX_ERRORTYPE Exynos_OMX_SrcInputProcessThread(OMX_PTR threadData)
784 OMX_ERRORTYPE ret = OMX_ErrorNone;
785 OMX_COMPONENTTYPE *pOMXComponent = NULL;
789 if (threadData == NULL) {
790 ret = OMX_ErrorBadParameter;
793 pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
794 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
795 if (ret != OMX_ErrorNone) {
798 Exynos_OMX_SrcInputBufferProcess(pOMXComponent);
800 Exynos_OSAL_ThreadExit(NULL);
808 static OMX_ERRORTYPE Exynos_OMX_SrcOutputProcessThread(OMX_PTR threadData)
810 OMX_ERRORTYPE ret = OMX_ErrorNone;
811 OMX_COMPONENTTYPE *pOMXComponent = NULL;
815 if (threadData == NULL) {
816 ret = OMX_ErrorBadParameter;
819 pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
820 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
821 if (ret != OMX_ErrorNone) {
824 Exynos_OMX_SrcOutputBufferProcess(pOMXComponent);
826 Exynos_OSAL_ThreadExit(NULL);
834 static OMX_ERRORTYPE Exynos_OMX_DstInputProcessThread(OMX_PTR threadData)
836 OMX_ERRORTYPE ret = OMX_ErrorNone;
837 OMX_COMPONENTTYPE *pOMXComponent = NULL;
841 if (threadData == NULL) {
842 ret = OMX_ErrorBadParameter;
845 pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
846 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
847 if (ret != OMX_ErrorNone) {
850 Exynos_OMX_DstInputBufferProcess(pOMXComponent);
852 Exynos_OSAL_ThreadExit(NULL);
860 static OMX_ERRORTYPE Exynos_OMX_DstOutputProcessThread(OMX_PTR threadData)
862 OMX_ERRORTYPE ret = OMX_ErrorNone;
863 OMX_COMPONENTTYPE *pOMXComponent = NULL;
867 if (threadData == NULL) {
868 ret = OMX_ErrorBadParameter;
871 pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
872 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
873 if (ret != OMX_ErrorNone) {
876 Exynos_OMX_DstOutputBufferProcess(pOMXComponent);
878 Exynos_OSAL_ThreadExit(NULL);
886 OMX_ERRORTYPE Exynos_OMX_BufferProcess_Create(OMX_HANDLETYPE hComponent)
888 OMX_ERRORTYPE ret = OMX_ErrorNone;
889 OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
890 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
891 EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
895 pVideoEnc->bExitBufferProcessThread = OMX_FALSE;
897 ret = Exynos_OSAL_ThreadCreate(&pVideoEnc->hDstOutputThread,
898 Exynos_OMX_DstOutputProcessThread,
900 if (ret == OMX_ErrorNone)
901 ret = Exynos_OSAL_ThreadCreate(&pVideoEnc->hSrcOutputThread,
902 Exynos_OMX_SrcOutputProcessThread,
904 if (ret == OMX_ErrorNone)
905 ret = Exynos_OSAL_ThreadCreate(&pVideoEnc->hDstInputThread,
906 Exynos_OMX_DstInputProcessThread,
908 if (ret == OMX_ErrorNone)
909 ret = Exynos_OSAL_ThreadCreate(&pVideoEnc->hSrcInputThread,
910 Exynos_OMX_SrcInputProcessThread,
918 OMX_ERRORTYPE Exynos_OMX_BufferProcess_Terminate(OMX_HANDLETYPE hComponent)
920 OMX_ERRORTYPE ret = OMX_ErrorNone;
921 OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
922 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
923 EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
924 OMX_S32 countValue = 0;
928 pVideoEnc->bExitBufferProcessThread = OMX_TRUE;
930 Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].bufferSemID, &countValue);
932 Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].bufferSemID);
933 Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].codecSemID, &countValue);
935 Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].codecSemID);
936 Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].pauseEvent);
937 Exynos_OSAL_ThreadTerminate(pVideoEnc->hSrcInputThread);
938 pVideoEnc->hSrcInputThread = NULL;
940 Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].bufferSemID, &countValue);
942 Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].bufferSemID);
943 Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].codecSemID, &countValue);
945 Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].codecSemID);
946 Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].pauseEvent);
947 Exynos_OSAL_ThreadTerminate(pVideoEnc->hDstInputThread);
948 pVideoEnc->hDstInputThread = NULL;
950 pVideoEnc->exynos_codec_stop(pOMXComponent, INPUT_PORT_INDEX);
951 pVideoEnc->exynos_codec_bufferProcessRun(pOMXComponent, INPUT_PORT_INDEX);
952 Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].pauseEvent);
953 Exynos_OSAL_ThreadTerminate(pVideoEnc->hSrcOutputThread);
954 pVideoEnc->hSrcOutputThread = NULL;
956 pVideoEnc->exynos_codec_stop(pOMXComponent, OUTPUT_PORT_INDEX);
957 pVideoEnc->exynos_codec_bufferProcessRun(pOMXComponent, INPUT_PORT_INDEX);
958 Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].pauseEvent);
959 Exynos_OSAL_ThreadTerminate(pVideoEnc->hDstOutputThread);
960 pVideoEnc->hDstOutputThread = NULL;
967 OMX_ERRORTYPE Exynos_OMX_VideoEncodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent)
969 OMX_ERRORTYPE ret = OMX_ErrorNone;
970 OMX_COMPONENTTYPE *pOMXComponent = NULL;
971 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
972 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
973 EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
977 if (hComponent == NULL) {
978 ret = OMX_ErrorBadParameter;
981 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
982 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
983 if (ret != OMX_ErrorNone) {
984 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
988 ret = Exynos_OMX_BaseComponent_Constructor(pOMXComponent);
989 if (ret != OMX_ErrorNone) {
990 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
994 ret = Exynos_OMX_Port_Constructor(pOMXComponent);
995 if (ret != OMX_ErrorNone) {
996 Exynos_OMX_BaseComponent_Destructor(pOMXComponent);
997 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
1001 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1003 pVideoEnc = Exynos_OSAL_Malloc(sizeof(EXYNOS_OMX_VIDEOENC_COMPONENT));
1004 if (pVideoEnc == NULL) {
1005 Exynos_OMX_BaseComponent_Destructor(pOMXComponent);
1006 ret = OMX_ErrorInsufficientResources;
1007 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
1011 Exynos_OSAL_Memset(pVideoEnc, 0, sizeof(EXYNOS_OMX_VIDEOENC_COMPONENT));
1012 pExynosComponent->hComponentHandle = (OMX_HANDLETYPE)pVideoEnc;
1014 pExynosComponent->bSaveFlagEOS = OMX_FALSE;
1016 pVideoEnc->configChange = OMX_FALSE;
1017 pVideoEnc->quantization.nQpI = 4; // I frame quantization parameter
1018 pVideoEnc->quantization.nQpP = 5; // P frame quantization parameter
1019 pVideoEnc->quantization.nQpB = 5; // B frame quantization parameter
1021 pExynosComponent->bMultiThreadProcess = OMX_TRUE;
1024 pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1025 pExynosPort->portDefinition.nBufferCountActual = MAX_VIDEO_INPUTBUFFER_NUM;
1026 pExynosPort->portDefinition.nBufferCountMin = MAX_VIDEO_INPUTBUFFER_NUM;
1027 pExynosPort->portDefinition.nBufferSize = 0;
1028 pExynosPort->portDefinition.eDomain = OMX_PortDomainVideo;
1030 pExynosPort->portDefinition.format.video.cMIMEType = Exynos_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
1031 Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video");
1032 pExynosPort->portDefinition.format.video.pNativeRender = 0;
1033 pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
1034 pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
1036 pExynosPort->portDefinition.format.video.nFrameWidth = 0;
1037 pExynosPort->portDefinition.format.video.nFrameHeight= 0;
1038 pExynosPort->portDefinition.format.video.nStride = 0;
1039 pExynosPort->portDefinition.format.video.nSliceHeight = 0;
1040 pExynosPort->portDefinition.format.video.nBitrate = 64000;
1041 pExynosPort->portDefinition.format.video.xFramerate = (15 << 16);
1042 pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
1043 pExynosPort->portDefinition.format.video.pNativeWindow = NULL;
1044 pVideoEnc->eControlRate[INPUT_PORT_INDEX] = OMX_Video_ControlRateDisable;
1046 pExynosPort->bStoreMetaData = OMX_FALSE;
1049 pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1050 pExynosPort->portDefinition.nBufferCountActual = MAX_VIDEO_OUTPUTBUFFER_NUM;
1051 pExynosPort->portDefinition.nBufferCountMin = MAX_VIDEO_OUTPUTBUFFER_NUM;
1052 pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
1053 pExynosPort->portDefinition.eDomain = OMX_PortDomainVideo;
1055 pExynosPort->portDefinition.format.video.cMIMEType = Exynos_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
1056 Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video");
1057 pExynosPort->portDefinition.format.video.pNativeRender = 0;
1058 pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
1059 pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
1061 pExynosPort->portDefinition.format.video.nFrameWidth = 0;
1062 pExynosPort->portDefinition.format.video.nFrameHeight= 0;
1063 pExynosPort->portDefinition.format.video.nStride = 0;
1064 pExynosPort->portDefinition.format.video.nSliceHeight = 0;
1065 pExynosPort->portDefinition.format.video.nBitrate = 64000;
1066 pExynosPort->portDefinition.format.video.xFramerate = (15 << 16);
1067 pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
1068 pExynosPort->portDefinition.format.video.pNativeWindow = NULL;
1069 pVideoEnc->eControlRate[OUTPUT_PORT_INDEX] = OMX_Video_ControlRateDisable;
1071 pOMXComponent->UseBuffer = &Exynos_OMX_UseBuffer;
1072 pOMXComponent->AllocateBuffer = &Exynos_OMX_AllocateBuffer;
1073 pOMXComponent->FreeBuffer = &Exynos_OMX_FreeBuffer;
1074 pOMXComponent->ComponentTunnelRequest = &Exynos_OMX_ComponentTunnelRequest;
1076 pExynosComponent->exynos_AllocateTunnelBuffer = &Exynos_OMX_AllocateTunnelBuffer;
1077 pExynosComponent->exynos_FreeTunnelBuffer = &Exynos_OMX_FreeTunnelBuffer;
1078 pExynosComponent->exynos_BufferProcessCreate = &Exynos_OMX_BufferProcess_Create;
1079 pExynosComponent->exynos_BufferProcessTerminate = &Exynos_OMX_BufferProcess_Terminate;
1080 pExynosComponent->exynos_BufferFlush = &Exynos_OMX_BufferFlush;
1088 OMX_ERRORTYPE Exynos_OMX_VideoEncodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent)
1090 OMX_ERRORTYPE ret = OMX_ErrorNone;
1091 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1092 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1093 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
1094 EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
1099 if (hComponent == NULL) {
1100 ret = OMX_ErrorBadParameter;
1103 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1104 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1105 if (ret != OMX_ErrorNone) {
1109 if (pOMXComponent->pComponentPrivate == NULL) {
1110 ret = OMX_ErrorBadParameter;
1113 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1115 pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
1117 Exynos_OSAL_Free(pVideoEnc);
1118 pExynosComponent->hComponentHandle = pVideoEnc = NULL;
1120 for(i = 0; i < ALL_PORT_NUM; i++) {
1121 pExynosPort = &pExynosComponent->pExynosPort[i];
1122 Exynos_OSAL_Free(pExynosPort->portDefinition.format.video.cMIMEType);
1123 pExynosPort->portDefinition.format.video.cMIMEType = NULL;
1126 ret = Exynos_OMX_Port_Destructor(pOMXComponent);
1128 ret = Exynos_OMX_BaseComponent_Destructor(hComponent);