summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2017-08-23 20:36:55 +0200
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2017-08-23 20:36:55 +0200
commitbd7b489f11ef647cef30aa70a3ecc976d62d5728 (patch)
tree9658203f3934a768a3b0ca56673e151eecac00c4
Import of Rockchip Android 7.1.1 SDKHEADmaster
-rw-r--r--Android.mk33
-rw-r--r--component/common/Android.mk42
-rwxr-xr-xcomponent/common/Rockchip_OMX_Basecomponent.c1624
-rw-r--r--component/common/Rockchip_OMX_Basecomponent.h155
-rw-r--r--component/common/Rockchip_OMX_Baseport.c926
-rw-r--r--component/common/Rockchip_OMX_Baseport.h208
-rwxr-xr-xcomponent/common/Rockchip_OMX_Resourcemanager.c536
-rw-r--r--component/common/Rockchip_OMX_Resourcemanager.h59
-rw-r--r--component/video/dec/Android.mk58
-rwxr-xr-xcomponent/video/dec/Rkvpu_OMX_Vdec.c1458
-rwxr-xr-xcomponent/video/dec/Rkvpu_OMX_Vdec.h168
-rwxr-xr-xcomponent/video/dec/Rkvpu_OMX_VdecControl.c1987
-rwxr-xr-xcomponent/video/dec/Rkvpu_OMX_VdecControl.h129
-rw-r--r--component/video/dec/Rockchip_OMX_Def.h316
-rw-r--r--component/video/dec/libcodec_intel_sec.sobin0 -> 13492 bytes
-rw-r--r--component/video/dec/library_register.c106
-rw-r--r--component/video/dec/library_register.h92
-rw-r--r--component/video/enc/Android.mk55
-rwxr-xr-xcomponent/video/enc/Rkvpu_OMX_Venc.c1732
-rwxr-xr-xcomponent/video/enc/Rkvpu_OMX_Venc.h160
-rwxr-xr-xcomponent/video/enc/Rkvpu_OMX_VencControl.c1850
-rwxr-xr-xcomponent/video/enc/Rkvpu_OMX_VencControl.h127
-rwxr-xr-xcomponent/video/enc/library_register.c60
-rwxr-xr-xcomponent/video/enc/library_register.h59
-rw-r--r--core/Android.mk27
-rwxr-xr-xcore/Rockchip_OMX_Component_Register.c241
-rw-r--r--core/Rockchip_OMX_Component_Register.h79
-rwxr-xr-xcore/Rockchip_OMX_Core.c384
-rw-r--r--core/Rockchip_OMX_Core.h77
-rw-r--r--include/khronos/OMX_Audio.h1310
-rw-r--r--include/khronos/OMX_Component.h569
-rw-r--r--include/khronos/OMX_ContentPipe.h193
-rw-r--r--include/khronos/OMX_Core.h1422
-rw-r--r--include/khronos/OMX_IVCommon.h920
-rw-r--r--include/khronos/OMX_Image.h328
-rwxr-xr-xinclude/khronos/OMX_Index.h260
-rw-r--r--include/khronos/OMX_IndexExt.h105
-rwxr-xr-xinclude/khronos/OMX_Other.h366
-rw-r--r--include/khronos/OMX_Types.h340
-rw-r--r--include/khronos/OMX_Video.h1063
-rw-r--r--include/khronos/OMX_VideoExt.h401
-rwxr-xr-xinclude/rockchip/Rockchip_OMX_Def.h302
-rw-r--r--include/rockchip/Rockchip_OMX_Macros.h67
-rw-r--r--include/rockchip/git_info.h1
-rw-r--r--osal/Android.mk61
-rwxr-xr-xosal/Rockchip_OSAL_Android.cpp1180
-rw-r--r--osal/Rockchip_OSAL_Android.h129
-rw-r--r--osal/Rockchip_OSAL_ETC.c237
-rw-r--r--osal/Rockchip_OSAL_ETC.h67
-rw-r--r--osal/Rockchip_OSAL_Event.c219
-rw-r--r--osal/Rockchip_OSAL_Event.h61
-rw-r--r--osal/Rockchip_OSAL_Library.c55
-rw-r--r--osal/Rockchip_OSAL_Library.h47
-rwxr-xr-xosal/Rockchip_OSAL_Log.c76
-rw-r--r--osal/Rockchip_OSAL_Log.h86
-rw-r--r--osal/Rockchip_OSAL_Memory.c72
-rw-r--r--osal/Rockchip_OSAL_Memory.h55
-rw-r--r--osal/Rockchip_OSAL_Mutex.c93
-rw-r--r--osal/Rockchip_OSAL_Mutex.h48
-rw-r--r--osal/Rockchip_OSAL_Queue.c196
-rw-r--r--osal/Rockchip_OSAL_Queue.h66
-rwxr-xr-xosal/Rockchip_OSAL_RGA_Process.c539
-rw-r--r--osal/Rockchip_OSAL_RGA_Process.h44
-rw-r--r--osal/Rockchip_OSAL_Semaphore.c140
-rw-r--r--osal/Rockchip_OSAL_Semaphore.h50
-rw-r--r--osal/Rockchip_OSAL_SharedMemory.c613
-rw-r--r--osal/Rockchip_OSAL_SharedMemory.h51
-rw-r--r--osal/Rockchip_OSAL_Thread.c157
-rw-r--r--osal/Rockchip_OSAL_Thread.h48
-rwxr-xr-xversion.sh13
70 files changed, 24798 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..043c247
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,33 @@
+LOCAL_PATH := $(call my-dir)
+BOARD_USE_ANB := true
+BOARD_USE_STOREMETADATA := true
+
+ifeq ($(filter sofia%, $(TARGET_BOARD_PLATFORM)), )
+ BOARD_CONFIG_3GR := false
+else
+ BOARD_CONFIG_3GR := true
+endif
+
+ifeq ($(strip $(BOARD_USE_DRM)), true)
+ OMX_USE_DRM := true
+else
+ OMX_USE_DRM := false
+endif
+
+include $(CLEAR_VARS)
+
+$(info $(shell ($(LOCAL_PATH)/version.sh $(LOCAL_PATH))))
+
+ROCKCHIP_OMX_TOP := $(LOCAL_PATH)
+
+ROCKCHIP_OMX_INC := $(ROCKCHIP_OMX_TOP)/include/
+ROCKCHIP_OMX_COMPONENT := $(ROCKCHIP_OMX_TOP)/component
+
+include $(ROCKCHIP_OMX_TOP)/osal/Android.mk
+include $(ROCKCHIP_OMX_TOP)/core/Android.mk
+
+include $(ROCKCHIP_OMX_COMPONENT)/common/Android.mk
+include $(ROCKCHIP_OMX_COMPONENT)/video/dec/Android.mk
+include $(ROCKCHIP_OMX_COMPONENT)/video/enc/Android.mk
+
+
diff --git a/component/common/Android.mk b/component/common/Android.mk
new file mode 100644
index 0000000..00f2a89
--- /dev/null
+++ b/component/common/Android.mk
@@ -0,0 +1,42 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ Rockchip_OMX_Basecomponent.c \
+ Rockchip_OMX_Baseport.c
+
+LOCAL_MODULE := libRkOMX_Basecomponent
+
+LOCAL_CFLAGS :=
+
+LOCAL_STATIC_LIBRARIES := libRkOMX_OSAL
+LOCAL_SHARED_LIBRARIES := libcutils libutils
+
+LOCAL_C_INCLUDES := $(ROCKCHIP_OMX_INC)/khronos \
+ $(ROCKCHIP_OMX_INC)/rockchip \
+ $(ROCKCHIP_OMX_TOP)/osal
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ Rockchip_OMX_Resourcemanager.c
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libRkOMX_Resourcemanager
+
+LOCAL_CFLAGS :=
+
+LOCAL_STATIC_LIBRARIES := libRkOMX_OSAL
+LOCAL_SHARED_LIBRARIES := libcutils libutils
+
+LOCAL_C_INCLUDES := $(ROCKCHIP_OMX_INC)/khronos \
+ $(ROCKCHIP_OMX_INC)/rockchip \
+ $(ROCKCHIP_OMX_TOP)/osal
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/component/common/Rockchip_OMX_Basecomponent.c b/component/common/Rockchip_OMX_Basecomponent.c
new file mode 100755
index 0000000..88cee7e
--- /dev/null
+++ b/component/common/Rockchip_OMX_Basecomponent.c
@@ -0,0 +1,1624 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rockchip_OMX_Basecomponent.c
+ * @brief
+ * @author csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.26 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "Rockchip_OSAL_Event.h"
+#include "Rockchip_OSAL_Thread.h"
+#include "Rockchip_OSAL_ETC.h"
+#include "Rockchip_OSAL_Semaphore.h"
+#include "Rockchip_OSAL_Mutex.h"
+#include "Rockchip_OMX_Baseport.h"
+#include "Rockchip_OMX_Basecomponent.h"
+#include "Rockchip_OMX_Resourcemanager.h"
+#include "Rockchip_OMX_Macros.h"
+#include "git_info.h"
+
+#undef ROCKCHIP_LOG_TAG
+#define ROCKCHIP_LOG_TAG "ROCKCHIP_BASE_COMP"
+#define ROCKCHIP_LOG_OFF
+//#define ROCKCHIP_TRACE_ON
+#include "Rockchip_OSAL_Log.h"
+
+
+/* Change CHECK_SIZE_VERSION Macro */
+OMX_ERRORTYPE Rockchip_OMX_Check_SizeVersion(OMX_PTR header, OMX_U32 size)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ OMX_VERSIONTYPE* version = NULL;
+ if (header == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ version = (OMX_VERSIONTYPE*)((char*)header + sizeof(OMX_U32));
+ if (*((OMX_U32*)header) != size) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (version->s.nVersionMajor != VERSIONMAJOR_NUMBER ||
+ version->s.nVersionMinor != VERSIONMINOR_NUMBER) {
+ ret = OMX_ErrorVersionMismatch;
+ goto EXIT;
+ }
+ ret = OMX_ErrorNone;
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_GetComponentVersion(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_OUT OMX_STRING pComponentName,
+ OMX_OUT OMX_VERSIONTYPE *pComponentVersion,
+ OMX_OUT OMX_VERSIONTYPE *pSpecVersion,
+ OMX_OUT OMX_UUIDTYPE *pComponentUUID)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ OMX_U32 compUUID[3];
+
+ FunctionIn();
+
+ /* check parameters */
+ if (hComponent == NULL ||
+ pComponentName == NULL || pComponentVersion == NULL ||
+ pSpecVersion == NULL || pComponentUUID == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ Rockchip_OSAL_Strcpy(pComponentName, pRockchipComponent->componentName);
+ Rockchip_OSAL_Memcpy(pComponentVersion, &(pRockchipComponent->componentVersion), sizeof(OMX_VERSIONTYPE));
+ Rockchip_OSAL_Memcpy(pSpecVersion, &(pRockchipComponent->specVersion), sizeof(OMX_VERSIONTYPE));
+
+ /* Fill UUID with handle address, PID and UID.
+ * This should guarantee uiniqness */
+ compUUID[0] = (OMX_U32)pOMXComponent;
+ compUUID[1] = getpid();
+ compUUID[2] = getuid();
+ Rockchip_OSAL_Memcpy(*pComponentUUID, compUUID, 3 * sizeof(*compUUID));
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_GetState (
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_OUT OMX_STATETYPE *pState)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL || pState == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ *pState = pRockchipComponent->currentState;
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_ComponentStateSet(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 messageParam)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_MESSAGE *message;
+ OMX_STATETYPE destState = messageParam;
+ OMX_STATETYPE currentState = pRockchipComponent->currentState;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_S32 countValue = 0;
+ unsigned int i = 0, j = 0;
+ int k = 0;
+ int timeOutCnt = 200;
+
+ FunctionIn();
+
+ /* check parameters */
+ if (currentState == destState) {
+ ret = OMX_ErrorSameState;
+ goto EXIT;
+ }
+ if (currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if ((currentState == OMX_StateLoaded) && (destState == OMX_StateIdle)) {
+ ret = Rockchip_OMX_Get_Resource(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_SignalSet(pRockchipComponent->abendStateEvent);
+ goto EXIT;
+ }
+ }
+ if (((currentState == OMX_StateIdle) && (destState == OMX_StateLoaded)) ||
+ ((currentState == OMX_StateIdle) && (destState == OMX_StateInvalid)) ||
+ ((currentState == OMX_StateExecuting) && (destState == OMX_StateInvalid)) ||
+ ((currentState == OMX_StatePause) && (destState == OMX_StateInvalid))) {
+ Rockchip_OMX_Release_Resource(pOMXComponent);
+ }
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "destState: %d currentState: %d", destState, currentState);
+ switch (destState) {
+ case OMX_StateInvalid:
+ switch (currentState) {
+ case OMX_StateWaitForResources:
+ Rockchip_OMX_Out_WaitForResource(pOMXComponent);
+ case OMX_StateIdle:
+ case OMX_StateExecuting:
+ case OMX_StatePause:
+ case OMX_StateLoaded:
+ pRockchipComponent->currentState = OMX_StateInvalid;
+ ret = pRockchipComponent->rockchip_BufferProcessTerminate(pOMXComponent);
+
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ if (pRockchipComponent->pRockchipPort[i].portWayType == WAY1_PORT) {
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].way.port1WayDataBuffer.dataBuffer.bufferMutex);
+ pRockchipComponent->pRockchipPort[i].way.port1WayDataBuffer.dataBuffer.bufferMutex = NULL;
+ } else if (pRockchipComponent->pRockchipPort[i].portWayType == WAY2_PORT) {
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.inputDataBuffer.bufferMutex);
+ pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.inputDataBuffer.bufferMutex = NULL;
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.outputDataBuffer.bufferMutex);
+ pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.outputDataBuffer.bufferMutex = NULL;
+ }
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].hPortMutex);
+ pRockchipComponent->pRockchipPort[i].hPortMutex = NULL;
+ }
+
+ if (pRockchipComponent->bMultiThreadProcess == OMX_FALSE) {
+ Rockchip_OSAL_SignalTerminate(pRockchipComponent->pauseEvent);
+ pRockchipComponent->pauseEvent = NULL;
+ } else {
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ Rockchip_OSAL_SignalTerminate(pRockchipComponent->pRockchipPort[i].pauseEvent);
+ pRockchipComponent->pRockchipPort[i].pauseEvent = NULL;
+ if (pRockchipComponent->pRockchipPort[i].bufferProcessType == BUFFER_SHARE) {
+ Rockchip_OSAL_SignalTerminate(pRockchipComponent->pRockchipPort[i].hAllCodecBufferReturnEvent);
+ pRockchipComponent->pRockchipPort[i].hAllCodecBufferReturnEvent = NULL;
+ }
+ }
+ }
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipComponent->pRockchipPort[i].bufferSemID);
+ pRockchipComponent->pRockchipPort[i].bufferSemID = NULL;
+ }
+ if (pRockchipComponent->rockchip_codec_componentTerminate != NULL)
+ pRockchipComponent->rockchip_codec_componentTerminate(pOMXComponent);
+
+ ret = OMX_ErrorInvalidState;
+ break;
+ default:
+ ret = OMX_ErrorInvalidState;
+ break;
+ }
+ break;
+ case OMX_StateLoaded:
+ switch (currentState) {
+ case OMX_StateIdle:
+ ret = pRockchipComponent->rockchip_BufferProcessTerminate(pOMXComponent);
+
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ if (pRockchipComponent->pRockchipPort[i].portWayType == WAY1_PORT) {
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].way.port1WayDataBuffer.dataBuffer.bufferMutex);
+ pRockchipComponent->pRockchipPort[i].way.port1WayDataBuffer.dataBuffer.bufferMutex = NULL;
+ } else if (pRockchipComponent->pRockchipPort[i].portWayType == WAY2_PORT) {
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.inputDataBuffer.bufferMutex);
+ pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.inputDataBuffer.bufferMutex = NULL;
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.outputDataBuffer.bufferMutex);
+ pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.outputDataBuffer.bufferMutex = NULL;
+ }
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].hPortMutex);
+ pRockchipComponent->pRockchipPort[i].hPortMutex = NULL;
+ }
+ if (pRockchipComponent->bMultiThreadProcess == OMX_FALSE) {
+ Rockchip_OSAL_SignalTerminate(pRockchipComponent->pauseEvent);
+ pRockchipComponent->pauseEvent = NULL;
+ } else {
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ Rockchip_OSAL_SignalTerminate(pRockchipComponent->pRockchipPort[i].pauseEvent);
+ pRockchipComponent->pRockchipPort[i].pauseEvent = NULL;
+ if (pRockchipComponent->pRockchipPort[i].bufferProcessType == BUFFER_SHARE) {
+ Rockchip_OSAL_SignalTerminate(pRockchipComponent->pRockchipPort[i].hAllCodecBufferReturnEvent);
+ pRockchipComponent->pRockchipPort[i].hAllCodecBufferReturnEvent = NULL;
+ }
+ }
+ }
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipComponent->pRockchipPort[i].bufferSemID);
+ pRockchipComponent->pRockchipPort[i].bufferSemID = NULL;
+ }
+
+ pRockchipComponent->rockchip_codec_componentTerminate(pOMXComponent);
+
+ for (i = 0; i < (pRockchipComponent->portParam.nPorts); i++) {
+ pRockchipPort = (pRockchipComponent->pRockchipPort + i);
+ if (CHECK_PORT_TUNNELED(pRockchipPort) && CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ while (Rockchip_OSAL_GetElemNum(&pRockchipPort->bufferQ) > 0) {
+ message = (ROCKCHIP_OMX_MESSAGE*)Rockchip_OSAL_Dequeue(&pRockchipPort->bufferQ);
+ if (message != NULL)
+ Rockchip_OSAL_Free(message);
+ }
+ ret = pRockchipComponent->rockchip_FreeTunnelBuffer(pRockchipPort, i);
+ if (OMX_ErrorNone != ret) {
+ goto EXIT;
+ }
+ } else {
+ if (CHECK_PORT_ENABLED(pRockchipPort)) {
+ Rockchip_OSAL_SemaphoreWait(pRockchipPort->unloadedResource);
+ pRockchipPort->portDefinition.bPopulated = OMX_FALSE;
+ }
+ }
+ }
+ pRockchipComponent->currentState = OMX_StateLoaded;
+ break;
+ case OMX_StateWaitForResources:
+ ret = Rockchip_OMX_Out_WaitForResource(pOMXComponent);
+ pRockchipComponent->currentState = OMX_StateLoaded;
+ break;
+ case OMX_StateExecuting:
+ case OMX_StatePause:
+ default:
+ ret = OMX_ErrorIncorrectStateTransition;
+ break;
+ }
+ break;
+ case OMX_StateIdle:
+ switch (currentState) {
+ case OMX_StateLoaded:
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "OMX_StateLoaded in loadedResource");
+ for (i = 0; i < pRockchipComponent->portParam.nPorts; i++) {
+ pRockchipPort = (pRockchipComponent->pRockchipPort + i);
+ if (pRockchipPort == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (CHECK_PORT_TUNNELED(pRockchipPort) && CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ if (CHECK_PORT_ENABLED(pRockchipPort)) {
+ ret = pRockchipComponent->rockchip_AllocateTunnelBuffer(pRockchipPort, i);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+ }
+ } else {
+ if (CHECK_PORT_ENABLED(pRockchipPort)) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rockchip_OSAL_SemaphoreWait loadedResource ");
+ Rockchip_OSAL_SemaphoreWait(pRockchipComponent->pRockchipPort[i].loadedResource);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rockchip_OSAL_SemaphoreWait loadedResource out");
+ if (pRockchipComponent->abendState == OMX_TRUE) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Rockchip_OSAL_SemaphoreWait abendState == OMX_TRUE");
+ Rockchip_OSAL_SignalSet(pRockchipComponent->abendStateEvent);
+ ret = Rockchip_OMX_Release_Resource(pOMXComponent);
+ goto EXIT;
+ }
+ pRockchipPort->portDefinition.bPopulated = OMX_TRUE;
+ }
+ }
+ }
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "rockchip_codec_componentInit");
+ ret = pRockchipComponent->rockchip_codec_componentInit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ /*
+ * if (CHECK_PORT_TUNNELED == OMX_TRUE) thenTunnel Buffer Free
+ */
+ Rockchip_OSAL_SignalSet(pRockchipComponent->abendStateEvent);
+ Rockchip_OMX_Release_Resource(pOMXComponent);
+ goto EXIT;
+ }
+ if (pRockchipComponent->bMultiThreadProcess == OMX_FALSE) {
+ Rockchip_OSAL_SignalCreate(&pRockchipComponent->pauseEvent);
+ } else {
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ Rockchip_OSAL_SignalCreate(&pRockchipComponent->pRockchipPort[i].pauseEvent);
+ if (pRockchipComponent->pRockchipPort[i].bufferProcessType == BUFFER_SHARE)
+ Rockchip_OSAL_SignalCreate(&pRockchipComponent->pRockchipPort[i].hAllCodecBufferReturnEvent);
+ }
+ }
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ ret = Rockchip_OSAL_SemaphoreCreate(&pRockchipComponent->pRockchipPort[i].bufferSemID);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ }
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ if (pRockchipComponent->pRockchipPort[i].portWayType == WAY1_PORT) {
+ ret = Rockchip_OSAL_MutexCreate(&pRockchipComponent->pRockchipPort[i].way.port1WayDataBuffer.dataBuffer.bufferMutex);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ } else if (pRockchipComponent->pRockchipPort[i].portWayType == WAY2_PORT) {
+ ret = Rockchip_OSAL_MutexCreate(&pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.inputDataBuffer.bufferMutex);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ ret = Rockchip_OSAL_MutexCreate(&pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.outputDataBuffer.bufferMutex);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ }
+ ret = Rockchip_OSAL_MutexCreate(&pRockchipComponent->pRockchipPort[i].hPortMutex);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ }
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "rockchip_BufferProcessCreate");
+
+ ret = pRockchipComponent->rockchip_BufferProcessCreate(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ /*
+ * if (CHECK_PORT_TUNNELED == OMX_TRUE) thenTunnel Buffer Free
+ */
+ if (pRockchipComponent->bMultiThreadProcess == OMX_FALSE) {
+ Rockchip_OSAL_SignalTerminate(pRockchipComponent->pauseEvent);
+ pRockchipComponent->pauseEvent = NULL;
+ } else {
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ Rockchip_OSAL_SignalTerminate(pRockchipComponent->pRockchipPort[i].pauseEvent);
+ pRockchipComponent->pRockchipPort[i].pauseEvent = NULL;
+ if (pRockchipComponent->pRockchipPort[i].bufferProcessType == BUFFER_SHARE) {
+ Rockchip_OSAL_SignalTerminate(pRockchipComponent->pRockchipPort[i].hAllCodecBufferReturnEvent);
+ pRockchipComponent->pRockchipPort[i].hAllCodecBufferReturnEvent = NULL;
+ }
+ }
+ }
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ if (pRockchipComponent->pRockchipPort[i].portWayType == WAY1_PORT) {
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].way.port1WayDataBuffer.dataBuffer.bufferMutex);
+ pRockchipComponent->pRockchipPort[i].way.port1WayDataBuffer.dataBuffer.bufferMutex = NULL;
+ } else if (pRockchipComponent->pRockchipPort[i].portWayType == WAY2_PORT) {
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.inputDataBuffer.bufferMutex);
+ pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.inputDataBuffer.bufferMutex = NULL;
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.outputDataBuffer.bufferMutex);
+ pRockchipComponent->pRockchipPort[i].way.port2WayDataBuffer.outputDataBuffer.bufferMutex = NULL;
+ }
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->pRockchipPort[i].hPortMutex);
+ pRockchipComponent->pRockchipPort[i].hPortMutex = NULL;
+ }
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipComponent->pRockchipPort[i].bufferSemID);
+ pRockchipComponent->pRockchipPort[i].bufferSemID = NULL;
+ }
+
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, " OMX_StateIdle");
+ pRockchipComponent->currentState = OMX_StateIdle;
+ break;
+ case OMX_StateExecuting:
+ case OMX_StatePause:
+ if (currentState == OMX_StateExecuting) {
+ pRockchipComponent->nRkFlags |= RK_VPU_NEED_FLUSH_ON_SEEK;
+ }
+ Rockchip_OMX_BufferFlushProcess(pOMXComponent, ALL_PORT_INDEX, OMX_FALSE);
+ pRockchipComponent->currentState = OMX_StateIdle;
+ break;
+ case OMX_StateWaitForResources:
+ pRockchipComponent->currentState = OMX_StateIdle;
+ break;
+ default:
+ ret = OMX_ErrorIncorrectStateTransition;
+ break;
+ }
+ break;
+ case OMX_StateExecuting:
+ switch (currentState) {
+ case OMX_StateLoaded:
+ ret = OMX_ErrorIncorrectStateTransition;
+ break;
+ case OMX_StateIdle:
+ for (i = 0; i < pRockchipComponent->portParam.nPorts; i++) {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[i];
+ if (CHECK_PORT_TUNNELED(pRockchipPort) && CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort) && CHECK_PORT_ENABLED(pRockchipPort)) {
+ for (j = 0; j < pRockchipPort->tunnelBufferNum; j++) {
+ Rockchip_OSAL_SemaphorePost(pRockchipComponent->pRockchipPort[i].bufferSemID);
+ }
+ }
+ }
+
+ pRockchipComponent->transientState = ROCKCHIP_OMX_TransStateMax;
+ pRockchipComponent->currentState = OMX_StateExecuting;
+ if (pRockchipComponent->bMultiThreadProcess == OMX_FALSE) {
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pauseEvent);
+ } else {
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pRockchipPort[i].pauseEvent);
+ }
+ }
+ break;
+ case OMX_StatePause:
+ for (i = 0; i < pRockchipComponent->portParam.nPorts; i++) {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[i];
+ if (CHECK_PORT_TUNNELED(pRockchipPort) && CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort) && CHECK_PORT_ENABLED(pRockchipPort)) {
+ OMX_S32 semaValue = 0, cnt = 0;
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipComponent->pRockchipPort[i].bufferSemID, &semaValue);
+ if (Rockchip_OSAL_GetElemNum(&pRockchipPort->bufferQ) > semaValue) {
+ cnt = Rockchip_OSAL_GetElemNum(&pRockchipPort->bufferQ) - semaValue;
+ for (k = 0; k < cnt; k++) {
+ Rockchip_OSAL_SemaphorePost(pRockchipComponent->pRockchipPort[i].bufferSemID);
+ }
+ }
+ }
+ }
+
+ pRockchipComponent->currentState = OMX_StateExecuting;
+ if (pRockchipComponent->bMultiThreadProcess == OMX_FALSE) {
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pauseEvent);
+ } else {
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pRockchipPort[i].pauseEvent);
+ }
+ }
+ break;
+ case OMX_StateWaitForResources:
+ ret = OMX_ErrorIncorrectStateTransition;
+ break;
+ default:
+ ret = OMX_ErrorIncorrectStateTransition;
+ break;
+ }
+ break;
+ case OMX_StatePause:
+ switch (currentState) {
+ case OMX_StateLoaded:
+ ret = OMX_ErrorIncorrectStateTransition;
+ break;
+ case OMX_StateIdle:
+ pRockchipComponent->currentState = OMX_StatePause;
+ break;
+ case OMX_StateExecuting:
+ pRockchipComponent->currentState = OMX_StatePause;
+ break;
+ case OMX_StateWaitForResources:
+ ret = OMX_ErrorIncorrectStateTransition;
+ break;
+ default:
+ ret = OMX_ErrorIncorrectStateTransition;
+ break;
+ }
+ break;
+ case OMX_StateWaitForResources:
+ switch (currentState) {
+ case OMX_StateLoaded:
+ ret = Rockchip_OMX_In_WaitForResource(pOMXComponent);
+ pRockchipComponent->currentState = OMX_StateWaitForResources;
+ break;
+ case OMX_StateIdle:
+ case OMX_StateExecuting:
+ case OMX_StatePause:
+ ret = OMX_ErrorIncorrectStateTransition;
+ break;
+ default:
+ ret = OMX_ErrorIncorrectStateTransition;
+ break;
+ }
+ break;
+ default:
+ ret = OMX_ErrorIncorrectStateTransition;
+ break;
+ }
+
+EXIT:
+ if (ret == OMX_ErrorNone) {
+ if (pRockchipComponent->pCallbacks != NULL) {
+ pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventCmdComplete, OMX_CommandStateSet,
+ destState, NULL);
+ }
+ } else {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "%s:%d", __FUNCTION__, __LINE__);
+ if (pRockchipComponent->pCallbacks != NULL) {
+ pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventError, ret, 0, NULL);
+ }
+ }
+ FunctionOut();
+
+ return ret;
+}
+
+static OMX_ERRORTYPE Rockchip_OMX_MessageHandlerThread(OMX_PTR threadData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+ OMX_U32 messageType = 0, portIndex = 0;
+
+ FunctionIn();
+
+ if (threadData == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ while (pRockchipComponent->bExitMessageHandlerThread == OMX_FALSE) {
+ Rockchip_OSAL_SemaphoreWait(pRockchipComponent->msgSemaphoreHandle);
+ message = (ROCKCHIP_OMX_MESSAGE *)Rockchip_OSAL_Dequeue(&pRockchipComponent->messageQ);
+ if (message != NULL) {
+ messageType = message->messageType;
+ switch (messageType) {
+ case OMX_CommandStateSet:
+ ret = Rockchip_OMX_ComponentStateSet(pOMXComponent, message->messageParam);
+ break;
+ case OMX_CommandFlush:
+ ret = Rockchip_OMX_BufferFlushProcess(pOMXComponent, message->messageParam, OMX_TRUE);
+ break;
+ case OMX_CommandPortDisable:
+ ret = Rockchip_OMX_PortDisableProcess(pOMXComponent, message->messageParam);
+ break;
+ case OMX_CommandPortEnable:
+ ret = Rockchip_OMX_PortEnableProcess(pOMXComponent, message->messageParam);
+ break;
+ case OMX_CommandMarkBuffer:
+ portIndex = message->messageParam;
+ pRockchipComponent->pRockchipPort[portIndex].markType.hMarkTargetComponent = ((OMX_MARKTYPE *)message->pCmdData)->hMarkTargetComponent;
+ pRockchipComponent->pRockchipPort[portIndex].markType.pMarkData = ((OMX_MARKTYPE *)message->pCmdData)->pMarkData;
+ break;
+ case (OMX_COMMANDTYPE)ROCKCHIP_OMX_CommandComponentDeInit:
+ pRockchipComponent->bExitMessageHandlerThread = OMX_TRUE;
+ break;
+ default:
+ break;
+ }
+ Rockchip_OSAL_Free(message);
+ message = NULL;
+ }
+ }
+
+ Rockchip_OSAL_ThreadExit(NULL);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+static OMX_ERRORTYPE Rockchip_StateSet(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 nParam)
+{
+ OMX_U32 destState = nParam;
+ OMX_U32 i = 0;
+
+ if ((destState == OMX_StateIdle) && (pRockchipComponent->currentState == OMX_StateLoaded)) {
+ pRockchipComponent->transientState = ROCKCHIP_OMX_TransStateLoadedToIdle;
+ for (i = 0; i < pRockchipComponent->portParam.nPorts; i++) {
+ pRockchipComponent->pRockchipPort[i].portState = OMX_StateIdle;
+ }
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "to OMX_StateIdle");
+ } else if ((destState == OMX_StateLoaded) && (pRockchipComponent->currentState == OMX_StateIdle)) {
+ pRockchipComponent->transientState = ROCKCHIP_OMX_TransStateIdleToLoaded;
+ for (i = 0; i < pRockchipComponent->portParam.nPorts; i++) {
+ pRockchipComponent->pRockchipPort[i].portState = OMX_StateLoaded;
+ }
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "to OMX_StateLoaded");
+ } else if ((destState == OMX_StateIdle) && (pRockchipComponent->currentState == OMX_StateExecuting)) {
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+
+ pRockchipPort = &(pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX]);
+ if ((pRockchipPort->portDefinition.bEnabled == OMX_FALSE) &&
+ (pRockchipPort->portState == OMX_StateIdle)) {
+ pRockchipPort->exceptionFlag = INVALID_STATE;
+ Rockchip_OSAL_SemaphorePost(pRockchipPort->loadedResource);
+ }
+
+ pRockchipPort = &(pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX]);
+ if ((pRockchipPort->portDefinition.bEnabled == OMX_FALSE) &&
+ (pRockchipPort->portState == OMX_StateIdle)) {
+ pRockchipPort->exceptionFlag = INVALID_STATE;
+ Rockchip_OSAL_SemaphorePost(pRockchipPort->loadedResource);
+ }
+
+ pRockchipComponent->transientState = ROCKCHIP_OMX_TransStateExecutingToIdle;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "to OMX_StateIdle");
+ } else if ((destState == OMX_StateExecuting) && (pRockchipComponent->currentState == OMX_StateIdle)) {
+ pRockchipComponent->transientState = ROCKCHIP_OMX_TransStateIdleToExecuting;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "to OMX_StateExecuting");
+ } else if (destState == OMX_StateInvalid) {
+ for (i = 0; i < pRockchipComponent->portParam.nPorts; i++) {
+ pRockchipComponent->pRockchipPort[i].portState = OMX_StateInvalid;
+ }
+ }
+
+ return OMX_ErrorNone;
+}
+
+static OMX_ERRORTYPE Rockchip_SetPortFlush(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 nParam)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_S32 portIndex = nParam;
+ OMX_U16 i = 0, cnt = 0, index = 0;
+
+
+ if ((pRockchipComponent->currentState == OMX_StateExecuting) ||
+ (pRockchipComponent->currentState == OMX_StatePause)) {
+ if ((portIndex != ALL_PORT_INDEX) &&
+ ((OMX_S32)portIndex >= (OMX_S32)pRockchipComponent->portParam.nPorts)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ /*********************
+ * need flush event set ?????
+ **********************/
+ cnt = (portIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1;
+ for (i = 0; i < cnt; i++) {
+ if (portIndex == ALL_PORT_INDEX)
+ index = i;
+ else
+ index = portIndex;
+ pRockchipComponent->pRockchipPort[index].bIsPortFlushed = OMX_TRUE;
+ }
+ } else {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ ret = OMX_ErrorNone;
+
+EXIT:
+ return ret;
+}
+
+static OMX_ERRORTYPE Rockchip_SetPortEnable(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 nParam)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_S32 portIndex = nParam;
+ OMX_U16 i = 0, cnt = 0;
+
+ FunctionIn();
+
+ if ((portIndex != ALL_PORT_INDEX) &&
+ ((OMX_S32)portIndex >= (OMX_S32)pRockchipComponent->portParam.nPorts)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ if (portIndex == ALL_PORT_INDEX) {
+ for (i = 0; i < pRockchipComponent->portParam.nPorts; i++) {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[i];
+ if (CHECK_PORT_ENABLED(pRockchipPort)) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ } else {
+ pRockchipPort->portState = OMX_StateIdle;
+ }
+ }
+ } else {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ if (CHECK_PORT_ENABLED(pRockchipPort)) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ } else {
+ pRockchipPort->portState = OMX_StateIdle;
+ }
+ }
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+
+}
+
+static OMX_ERRORTYPE Rockchip_SetPortDisable(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 nParam)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_S32 portIndex = nParam;
+ OMX_U16 i = 0, cnt = 0;
+
+ FunctionIn();
+
+ if ((portIndex != ALL_PORT_INDEX) &&
+ ((OMX_S32)portIndex >= (OMX_S32)pRockchipComponent->portParam.nPorts)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ if (portIndex == ALL_PORT_INDEX) {
+ for (i = 0; i < pRockchipComponent->portParam.nPorts; i++) {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[i];
+ if (!CHECK_PORT_ENABLED(pRockchipPort)) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ pRockchipPort->portState = OMX_StateLoaded;
+ pRockchipPort->bIsPortDisabled = OMX_TRUE;
+ }
+ } else {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ pRockchipPort->portState = OMX_StateLoaded;
+ pRockchipPort->bIsPortDisabled = OMX_TRUE;
+ }
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+static OMX_ERRORTYPE Rockchip_SetMarkBuffer(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 nParam)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_U32 portIndex = nParam;
+ OMX_U16 i = 0, cnt = 0;
+
+
+ if (nParam >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ if ((pRockchipComponent->currentState == OMX_StateExecuting) ||
+ (pRockchipComponent->currentState == OMX_StatePause)) {
+ ret = OMX_ErrorNone;
+ } else {
+ ret = OMX_ErrorIncorrectStateOperation;
+ }
+
+EXIT:
+ return ret;
+}
+
+static OMX_ERRORTYPE Rockchip_OMX_CommandQueue(
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent,
+ OMX_COMMANDTYPE Cmd,
+ OMX_U32 nParam,
+ OMX_PTR pCmdData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_MESSAGE *command = (ROCKCHIP_OMX_MESSAGE *)Rockchip_OSAL_Malloc(sizeof(ROCKCHIP_OMX_MESSAGE));
+
+ if (command == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ command->messageType = (OMX_U32)Cmd;
+ command->messageParam = nParam;
+ command->pCmdData = pCmdData;
+
+ ret = Rockchip_OSAL_Queue(&pRockchipComponent->messageQ, (void *)command);
+ if (ret != 0) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ ret = Rockchip_OSAL_SemaphorePost(pRockchipComponent->msgSemaphoreHandle);
+
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_SendCommand(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_COMMANDTYPE Cmd,
+ OMX_IN OMX_U32 nParam,
+ OMX_IN OMX_PTR pCmdData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (Cmd) {
+ case OMX_CommandStateSet :
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Command: OMX_CommandStateSet");
+ Rockchip_StateSet(pRockchipComponent, nParam);
+ break;
+ case OMX_CommandFlush :
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Command: OMX_CommandFlush");
+ pRockchipComponent->nRkFlags |= RK_VPU_NEED_FLUSH_ON_SEEK;
+ ret = Rockchip_SetPortFlush(pRockchipComponent, nParam);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+ break;
+ case OMX_CommandPortDisable :
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Command: OMX_CommandPortDisable");
+ ret = Rockchip_SetPortDisable(pRockchipComponent, nParam);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+ break;
+ case OMX_CommandPortEnable :
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Command: OMX_CommandPortEnable");
+ ret = Rockchip_SetPortEnable(pRockchipComponent, nParam);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+ break;
+ case OMX_CommandMarkBuffer :
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Command: OMX_CommandMarkBuffer");
+ ret = Rockchip_SetMarkBuffer(pRockchipComponent, nParam);
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+ break;
+ default:
+ break;
+ }
+
+ ret = Rockchip_OMX_CommandQueue(pRockchipComponent, Cmd, nParam, pCmdData);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_GetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (ComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nParamIndex) {
+ case OMX_IndexParamAudioInit:
+ case OMX_IndexParamVideoInit:
+ case OMX_IndexParamImageInit:
+ case OMX_IndexParamOtherInit: {
+ OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure;
+ ret = Rockchip_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ portParam->nPorts = 0;
+ portParam->nStartPortNumber = 0;
+ }
+ break;
+ case OMX_IndexParamPortDefinition: {
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = portDefinition->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort;
+
+ if (portIndex >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ Rockchip_OSAL_Memcpy(portDefinition, &pRockchipPort->portDefinition, portDefinition->nSize);
+ }
+ break;
+ case OMX_IndexParamPriorityMgmt: {
+ OMX_PRIORITYMGMTTYPE *compPriority = (OMX_PRIORITYMGMTTYPE *)ComponentParameterStructure;
+
+ ret = Rockchip_OMX_Check_SizeVersion(compPriority, sizeof(OMX_PRIORITYMGMTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ compPriority->nGroupID = pRockchipComponent->compPriority.nGroupID;
+ compPriority->nGroupPriority = pRockchipComponent->compPriority.nGroupPriority;
+ }
+ break;
+
+ case OMX_IndexParamCompBufferSupplier: {
+ OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = bufferSupplier->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort;
+
+ if ((pRockchipComponent->currentState == OMX_StateLoaded) ||
+ (pRockchipComponent->currentState == OMX_StateWaitForResources)) {
+ if (portIndex >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(bufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+
+
+ if (pRockchipPort->portDefinition.eDir == OMX_DirInput) {
+ if (CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ bufferSupplier->eBufferSupplier = OMX_BufferSupplyInput;
+ } else if (CHECK_PORT_TUNNELED(pRockchipPort)) {
+ bufferSupplier->eBufferSupplier = OMX_BufferSupplyOutput;
+ } else {
+ bufferSupplier->eBufferSupplier = OMX_BufferSupplyUnspecified;
+ }
+ } else {
+ if (CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ bufferSupplier->eBufferSupplier = OMX_BufferSupplyOutput;
+ } else if (CHECK_PORT_TUNNELED(pRockchipPort)) {
+ bufferSupplier->eBufferSupplier = OMX_BufferSupplyInput;
+ } else {
+ bufferSupplier->eBufferSupplier = OMX_BufferSupplyUnspecified;
+ }
+ }
+ } else {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ }
+ break;
+ default: {
+ ret = OMX_ErrorUnsupportedIndex;
+ goto EXIT;
+ }
+ break;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_SetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (ComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexParamAudioInit:
+ case OMX_IndexParamVideoInit:
+ case OMX_IndexParamImageInit:
+ case OMX_IndexParamOtherInit: {
+ OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure;
+ ret = Rockchip_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((pRockchipComponent->currentState != OMX_StateLoaded) &&
+ (pRockchipComponent->currentState != OMX_StateWaitForResources)) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ ret = OMX_ErrorUndefined;
+ /* Rockchip_OSAL_Memcpy(&pRockchipComponent->portParam, portParam, sizeof(OMX_PORT_PARAM_TYPE)); */
+ }
+ break;
+ case OMX_IndexParamPortDefinition: {
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = portDefinition->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort;
+
+ if (portIndex >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+
+ if ((pRockchipComponent->currentState != OMX_StateLoaded) && (pRockchipComponent->currentState != OMX_StateWaitForResources)) {
+ if (pRockchipPort->portDefinition.bEnabled == OMX_TRUE) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ }
+ if (portDefinition->nBufferCountActual < pRockchipPort->portDefinition.nBufferCountMin) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ Rockchip_OSAL_Memcpy(&pRockchipPort->portDefinition, portDefinition, portDefinition->nSize);
+ }
+ break;
+ case OMX_IndexParamPriorityMgmt: {
+ OMX_PRIORITYMGMTTYPE *compPriority = (OMX_PRIORITYMGMTTYPE *)ComponentParameterStructure;
+
+ if ((pRockchipComponent->currentState != OMX_StateLoaded) &&
+ (pRockchipComponent->currentState != OMX_StateWaitForResources)) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ ret = Rockchip_OMX_Check_SizeVersion(compPriority, sizeof(OMX_PRIORITYMGMTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pRockchipComponent->compPriority.nGroupID = compPriority->nGroupID;
+ pRockchipComponent->compPriority.nGroupPriority = compPriority->nGroupPriority;
+ }
+ break;
+ case OMX_IndexParamCompBufferSupplier: {
+ OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = bufferSupplier->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+
+
+ if (portIndex >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(bufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ if ((pRockchipComponent->currentState != OMX_StateLoaded) && (pRockchipComponent->currentState != OMX_StateWaitForResources)) {
+ if (pRockchipPort->portDefinition.bEnabled == OMX_TRUE) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ }
+
+ if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyUnspecified) {
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ if (CHECK_PORT_TUNNELED(pRockchipPort) == 0) {
+ ret = OMX_ErrorNone; /*OMX_ErrorNone ?????*/
+ goto EXIT;
+ }
+
+ if (pRockchipPort->portDefinition.eDir == OMX_DirInput) {
+ if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyInput) {
+ /*
+ if (CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ ret = OMX_ErrorNone;
+ }
+ */
+ pRockchipPort->tunnelFlags |= ROCKCHIP_TUNNEL_IS_SUPPLIER;
+ bufferSupplier->nPortIndex = pRockchipPort->tunneledPort;
+ ret = OMX_SetParameter(pRockchipPort->tunneledComponent, OMX_IndexParamCompBufferSupplier, bufferSupplier);
+ goto EXIT;
+ } else if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyOutput) {
+ ret = OMX_ErrorNone;
+ if (CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ pRockchipPort->tunnelFlags &= ~ROCKCHIP_TUNNEL_IS_SUPPLIER;
+ bufferSupplier->nPortIndex = pRockchipPort->tunneledPort;
+ ret = OMX_SetParameter(pRockchipPort->tunneledComponent, OMX_IndexParamCompBufferSupplier, bufferSupplier);
+ }
+ goto EXIT;
+ }
+ } else if (pRockchipPort->portDefinition.eDir == OMX_DirOutput) {
+ if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyInput) {
+ ret = OMX_ErrorNone;
+ if (CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ pRockchipPort->tunnelFlags &= ~ROCKCHIP_TUNNEL_IS_SUPPLIER;
+ ret = OMX_ErrorNone;
+ }
+ goto EXIT;
+ } else if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyOutput) {
+ /*
+ if (CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ ret = OMX_ErrorNone;
+ }
+ */
+ pRockchipPort->tunnelFlags |= ROCKCHIP_TUNNEL_IS_SUPPLIER;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ }
+ }
+ break;
+ default: {
+ ret = OMX_ErrorUnsupportedIndex;
+ goto EXIT;
+ }
+ break;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_GetConfig(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_INOUT OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ default:
+ ret = OMX_ErrorUnsupportedIndex;
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_SetConfig(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ default:
+ ret = OMX_ErrorUnsupportedIndex;
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_GetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if ((cParameterName == NULL) || (pIndexType == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ ret = OMX_ErrorBadParameter;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_SetCallbacks (
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_CALLBACKTYPE* pCallbacks,
+ OMX_IN OMX_PTR pAppData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorBadParameter :%d", __LINE__);
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorNone :%d", __LINE__);
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorBadParameter :%d", __LINE__);
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pCallbacks == NULL) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorBadParameter :%d", __LINE__);
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInvalidState :%d", __LINE__);
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState != OMX_StateLoaded) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_StateLoaded :%d", __LINE__);
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ pRockchipComponent->pCallbacks = pCallbacks;
+ pRockchipComponent->callbackData = pAppData;
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_UseEGLImage(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN void *eglImage)
+{
+ (void)hComponent;
+ (void)ppBufferHdr;
+ (void)nPortIndex;
+ (void)pAppPrivate;
+ (void)eglImage;
+ return OMX_ErrorNotImplemented;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_BaseComponent_Constructor(
+ OMX_IN OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ pRockchipComponent = Rockchip_OSAL_Malloc(sizeof(ROCKCHIP_OMX_BASECOMPONENT));
+ if (pRockchipComponent == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ Rockchip_OSAL_Memset(pRockchipComponent, 0, sizeof(ROCKCHIP_OMX_BASECOMPONENT));
+ pRockchipComponent->rkversion = OMX_COMPILE_INFO;
+ pOMXComponent->pComponentPrivate = (OMX_PTR)pRockchipComponent;
+
+ ret = Rockchip_OSAL_SemaphoreCreate(&pRockchipComponent->msgSemaphoreHandle);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ ret = Rockchip_OSAL_MutexCreate(&pRockchipComponent->compMutex);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ ret = Rockchip_OSAL_SignalCreate(&pRockchipComponent->abendStateEvent);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ pRockchipComponent->bExitMessageHandlerThread = OMX_FALSE;
+ Rockchip_OSAL_QueueCreate(&pRockchipComponent->messageQ, MAX_QUEUE_ELEMENTS);
+ ret = Rockchip_OSAL_ThreadCreate(&pRockchipComponent->hMessageHandler, Rockchip_OMX_MessageHandlerThread, pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ pRockchipComponent->bMultiThreadProcess = OMX_FALSE;
+
+ pOMXComponent->GetComponentVersion = &Rockchip_OMX_GetComponentVersion;
+ pOMXComponent->SendCommand = &Rockchip_OMX_SendCommand;
+ pOMXComponent->GetState = &Rockchip_OMX_GetState;
+ pOMXComponent->SetCallbacks = &Rockchip_OMX_SetCallbacks;
+ pOMXComponent->UseEGLImage = &Rockchip_OMX_UseEGLImage;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_BaseComponent_Destructor(
+ OMX_IN OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ OMX_S32 semaValue = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ Rockchip_OMX_CommandQueue(pRockchipComponent, (OMX_COMMANDTYPE)ROCKCHIP_OMX_CommandComponentDeInit, 0, NULL);
+ Rockchip_OSAL_SleepMillisec(0);
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipComponent->msgSemaphoreHandle, &semaValue);
+ if (semaValue == 0)
+ Rockchip_OSAL_SemaphorePost(pRockchipComponent->msgSemaphoreHandle);
+ Rockchip_OSAL_SemaphorePost(pRockchipComponent->msgSemaphoreHandle);
+
+ Rockchip_OSAL_ThreadTerminate(pRockchipComponent->hMessageHandler);
+ pRockchipComponent->hMessageHandler = NULL;
+
+ Rockchip_OSAL_SignalTerminate(pRockchipComponent->abendStateEvent);
+ pRockchipComponent->abendStateEvent = NULL;
+ Rockchip_OSAL_MutexTerminate(pRockchipComponent->compMutex);
+ pRockchipComponent->compMutex = NULL;
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipComponent->msgSemaphoreHandle);
+ pRockchipComponent->msgSemaphoreHandle = NULL;
+ Rockchip_OSAL_QueueTerminate(&pRockchipComponent->messageQ);
+
+ Rockchip_OSAL_Free(pRockchipComponent);
+ pRockchipComponent = NULL;
+
+ ret = OMX_ErrorNone;
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+
diff --git a/component/common/Rockchip_OMX_Basecomponent.h b/component/common/Rockchip_OMX_Basecomponent.h
new file mode 100644
index 0000000..f41b323
--- /dev/null
+++ b/component/common/Rockchip_OMX_Basecomponent.h
@@ -0,0 +1,155 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rockchip_OMX_Basecomponent.h
+ * @brief
+ * @author csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.26 : Create
+ */
+
+#ifndef ROCKCHIP_OMX_BASECOMP
+#define ROCKCHIP_OMX_BASECOMP
+
+#include "Rockchip_OMX_Def.h"
+#include "OMX_Component.h"
+#include "Rockchip_OSAL_Queue.h"
+#include "Rockchip_OMX_Baseport.h"
+
+
+typedef struct _ROCKCHIP_OMX_MESSAGE {
+ OMX_U32 messageType;
+ OMX_U32 messageParam;
+ OMX_PTR pCmdData;
+} ROCKCHIP_OMX_MESSAGE;
+
+/* for Check TimeStamp after Seek */
+typedef struct _ROCKCHIP_OMX_TIMESTAMP {
+ OMX_BOOL needSetStartTimeStamp;
+ OMX_BOOL needCheckStartTimeStamp;
+ OMX_TICKS startTimeStamp;
+ OMX_U32 nStartFlags;
+} ROCKCHIP_OMX_TIMESTAMP;
+
+typedef enum _ROCKCHIP_ON2_FLAGS_MAP {
+ RK_VPU_NEED_FLUSH_ON_SEEK = 0x01,
+} ROCKCHIP_ON2_FLAGS_MAP;
+
+typedef struct _ROCKCHIP_OMX_BASECOMPONENT {
+ OMX_STRING componentName;
+ OMX_STRING rkversion;
+ OMX_VERSIONTYPE componentVersion;
+ OMX_VERSIONTYPE specVersion;
+
+ OMX_STATETYPE currentState;
+ ROCKCHIP_OMX_TRANS_STATETYPE transientState;
+ OMX_BOOL abendState;
+ OMX_HANDLETYPE abendStateEvent;
+
+ ROCKCHIP_CODEC_TYPE codecType;
+
+ ROCKCHIP_OMX_PRIORITYMGMTTYPE compPriority;
+ OMX_MARKTYPE propagateMarkType;
+ OMX_HANDLETYPE compMutex;
+
+ OMX_HANDLETYPE hComponentHandle;
+
+ /* Message Handler */
+ OMX_BOOL bExitMessageHandlerThread;
+ OMX_HANDLETYPE hMessageHandler;
+ OMX_HANDLETYPE msgSemaphoreHandle;
+ ROCKCHIP_QUEUE messageQ;
+
+ /* Port */
+ OMX_PORT_PARAM_TYPE portParam;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort;
+
+ OMX_HANDLETYPE pauseEvent;
+
+ /* Callback function */
+ OMX_CALLBACKTYPE *pCallbacks;
+ OMX_PTR callbackData;
+
+ /* Save Timestamp */
+ OMX_TICKS timeStamp[MAX_TIMESTAMP];
+ ROCKCHIP_OMX_TIMESTAMP checkTimeStamp;
+
+ /* Save Flags */
+ OMX_U32 nFlags[MAX_FLAGS];
+
+ OMX_BOOL getAllDelayBuffer;
+ OMX_BOOL reInputData;
+
+ OMX_BOOL bUseFlagEOF;
+ OMX_BOOL bSaveFlagEOS; //bSaveFlagEOS is OMX_TRUE, if EOS flag is incoming.
+ OMX_BOOL bBehaviorEOS; //bBehaviorEOS is OMX_TRUE, if EOS flag with Data are incoming.
+ OMX_U32 nRkFlags; //used to set extension flag for control vpu.
+ /* Check for Old & New OMX Process type switch */
+ OMX_BOOL bMultiThreadProcess;
+
+ OMX_ERRORTYPE (*rockchip_codec_componentInit)(OMX_COMPONENTTYPE *pOMXComponent);
+ OMX_ERRORTYPE (*rockchip_codec_componentTerminate)(OMX_COMPONENTTYPE *pOMXComponent);
+
+ OMX_ERRORTYPE (*rockchip_AllocateTunnelBuffer)(ROCKCHIP_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex);
+ OMX_ERRORTYPE (*rockchip_FreeTunnelBuffer)(ROCKCHIP_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex);
+ OMX_ERRORTYPE (*rockchip_BufferProcessCreate)(OMX_COMPONENTTYPE *pOMXComponent);
+ OMX_ERRORTYPE (*rockchip_BufferProcessTerminate)(OMX_COMPONENTTYPE *pOMXComponent);
+ OMX_ERRORTYPE (*rockchip_BufferFlush)(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent);
+} ROCKCHIP_OMX_BASECOMPONENT;
+
+OMX_ERRORTYPE Rockchip_OMX_GetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure);
+
+OMX_ERRORTYPE Rockchip_OMX_SetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure);
+
+OMX_ERRORTYPE Rockchip_OMX_GetConfig(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_INOUT OMX_PTR pComponentConfigStructure);
+
+OMX_ERRORTYPE Rockchip_OMX_SetConfig(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR pComponentConfigStructure);
+
+OMX_ERRORTYPE Rockchip_OMX_GetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType);
+
+OMX_ERRORTYPE Rockchip_OMX_BaseComponent_Constructor(OMX_IN OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE Rockchip_OMX_BaseComponent_Destructor(OMX_IN OMX_HANDLETYPE hComponent);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE Rockchip_OMX_Check_SizeVersion(OMX_PTR header, OMX_U32 size);
+
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/component/common/Rockchip_OMX_Baseport.c b/component/common/Rockchip_OMX_Baseport.c
new file mode 100644
index 0000000..5959d3f
--- /dev/null
+++ b/component/common/Rockchip_OMX_Baseport.c
@@ -0,0 +1,926 @@
+/*
+ *
+ * Copyright 2013 rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rockchip_OMX_Baseport.c
+ * @brief
+ * @author csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.26 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "Rockchip_OMX_Macros.h"
+#include "Rockchip_OSAL_Event.h"
+#include "Rockchip_OSAL_Semaphore.h"
+#include "Rockchip_OSAL_Mutex.h"
+
+#include "Rockchip_OMX_Baseport.h"
+#include "Rockchip_OMX_Basecomponent.h"
+
+#undef ROCKCHIP_LOG_TAG
+#define ROCKCHIP_LOG_TAG "ROCKCHIP_BASE_PORT"
+#define ROCKCHIP_LOG_OFF
+//#define ROCKCHIP_TRACE_ON
+#include "Rockchip_OSAL_Log.h"
+
+
+OMX_ERRORTYPE Rkvpu_OMX_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, OMX_BUFFERHEADERTYPE* bufferHeader)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ OMX_U32 i = 0;
+
+ Rockchip_OSAL_MutexLock(pRockchipPort->hPortMutex);
+ for (i = 0; i < pRockchipPort->portDefinition.nBufferCountActual; i++) {
+ if (bufferHeader == pRockchipPort->extendBufferHeader[i].OMXBufferHeader) {
+ pRockchipPort->extendBufferHeader[i].bBufferInOMX = OMX_FALSE;
+ break;
+ }
+ }
+
+ Rockchip_OSAL_MutexUnlock(pRockchipPort->hPortMutex);
+ pRockchipComponent->pCallbacks->EmptyBufferDone(pOMXComponent, pRockchipComponent->callbackData, bufferHeader);
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, OMX_BUFFERHEADERTYPE* bufferHeader)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ OMX_U32 i = 0;
+
+ Rockchip_OSAL_MutexLock(pRockchipPort->hPortMutex);
+ for (i = 0; i < MAX_BUFFER_NUM; i++) {
+ if (bufferHeader == pRockchipPort->extendBufferHeader[i].OMXBufferHeader) {
+ pRockchipPort->extendBufferHeader[i].bBufferInOMX = OMX_FALSE;
+ break;
+ }
+ }
+
+ Rockchip_OSAL_MutexUnlock(pRockchipPort->hPortMutex);
+ pRockchipComponent->pCallbacks->FillBufferDone(pOMXComponent, pRockchipComponent->callbackData, bufferHeader);
+
+EXIT:
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "%s : %d, bufferHeader:0x%x", __FUNCTION__, __LINE__, bufferHeader);
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_BufferFlushProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_S32 portIndex = 0;
+ ROCKCHIP_OMX_DATABUFFER *flushPortBuffer[2] = {NULL, NULL};
+ OMX_U32 i = 0, cnt = 0;
+
+ FunctionIn();
+
+ if (pOMXComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ cnt = (nPortIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1;
+
+ for (i = 0; i < cnt; i++) {
+ if (nPortIndex == ALL_PORT_INDEX)
+ portIndex = i;
+ else
+ portIndex = nPortIndex;
+
+ pRockchipComponent->rockchip_BufferFlush(pOMXComponent, portIndex, bEvent);
+ }
+
+EXIT:
+ if ((ret != OMX_ErrorNone) && (pOMXComponent != NULL) && (pRockchipComponent != NULL)) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
+ pRockchipComponent->pCallbacks->EventHandler(pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventError,
+ ret, 0, NULL);
+ }
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_EnablePort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_U32 i = 0, cnt = 0;
+
+ FunctionIn();
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+
+ if ((pRockchipComponent->currentState != OMX_StateLoaded) && (pRockchipComponent->currentState != OMX_StateWaitForResources)) {
+ Rockchip_OSAL_SemaphoreWait(pRockchipPort->loadedResource);
+
+ if (pRockchipPort->exceptionFlag == INVALID_STATE) {
+ pRockchipPort->exceptionFlag = NEED_PORT_DISABLE;
+ goto EXIT;
+ }
+ pRockchipPort->portDefinition.bPopulated = OMX_TRUE;
+ }
+ pRockchipPort->exceptionFlag = GENERAL_STATE;
+ pRockchipPort->portDefinition.bEnabled = OMX_TRUE;
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_PortEnableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ OMX_S32 portIndex = 0;
+ OMX_U32 i = 0, cnt = 0;
+
+ FunctionIn();
+
+ if (pOMXComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ cnt = (nPortIndex == ALL_PORT_INDEX) ? ALL_PORT_NUM : 1;
+
+ for (i = 0; i < cnt; i++) {
+ if (nPortIndex == ALL_PORT_INDEX)
+ portIndex = i;
+ else
+ portIndex = nPortIndex;
+
+ ret = Rockchip_OMX_EnablePort(pOMXComponent, portIndex);
+ if (ret == OMX_ErrorNone) {
+ pRockchipComponent->pCallbacks->EventHandler(pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventCmdComplete,
+ OMX_CommandPortEnable, portIndex, NULL);
+ }
+ }
+
+EXIT:
+ if ((ret != OMX_ErrorNone) && (pOMXComponent != NULL) && (pRockchipComponent != NULL)) {
+ pRockchipComponent->pCallbacks->EventHandler(pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventError,
+ ret, 0, NULL);
+ }
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_DisablePort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_U32 i = 0, elemNum = 0;
+ ROCKCHIP_OMX_MESSAGE *message;
+
+ FunctionIn();
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+
+ if (!CHECK_PORT_ENABLED(pRockchipPort)) {
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ if (pRockchipComponent->currentState != OMX_StateLoaded) {
+ if (CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ while (Rockchip_OSAL_GetElemNum(&pRockchipPort->bufferQ) > 0) {
+ message = (ROCKCHIP_OMX_MESSAGE*)Rockchip_OSAL_Dequeue(&pRockchipPort->bufferQ);
+ Rockchip_OSAL_Free(message);
+ }
+ }
+ pRockchipPort->portDefinition.bPopulated = OMX_FALSE;
+ Rockchip_OSAL_SemaphoreWait(pRockchipPort->unloadedResource);
+ }
+ pRockchipPort->portDefinition.bEnabled = OMX_FALSE;
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_PortDisableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_S32 portIndex = 0;
+ OMX_U32 i = 0, cnt = 0;
+ ROCKCHIP_OMX_DATABUFFER *flushPortBuffer[2] = {NULL, NULL};
+
+ FunctionIn();
+
+ if (pOMXComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ cnt = (nPortIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1;
+
+ /* port flush*/
+ for (i = 0; i < cnt; i++) {
+ if (nPortIndex == ALL_PORT_INDEX)
+ portIndex = i;
+ else
+ portIndex = nPortIndex;
+
+ Rockchip_OMX_BufferFlushProcess(pOMXComponent, portIndex, OMX_FALSE);
+ }
+
+ for (i = 0; i < cnt; i++) {
+ if (nPortIndex == ALL_PORT_INDEX)
+ portIndex = i;
+ else
+ portIndex = nPortIndex;
+
+ ret = Rockchip_OMX_DisablePort(pOMXComponent, portIndex);
+ pRockchipComponent->pRockchipPort[portIndex].bIsPortDisabled = OMX_FALSE;
+ if (ret == OMX_ErrorNone) {
+ pRockchipComponent->pCallbacks->EventHandler(pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventCmdComplete,
+ OMX_CommandPortDisable, portIndex, NULL);
+ }
+ }
+
+EXIT:
+ if ((ret != OMX_ErrorNone) && (pOMXComponent != NULL) && (pRockchipComponent != NULL)) {
+ pRockchipComponent->pCallbacks->EventHandler(pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventError,
+ ret, 0, NULL);
+ }
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_EmptyThisBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_BUFFERHEADERTYPE *pBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_BOOL findBuffer = OMX_FALSE;
+ ROCKCHIP_OMX_MESSAGE *message;
+ OMX_U32 i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if (pBuffer == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pBuffer->nInputPortIndex != INPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ ret = Rockchip_OMX_Check_SizeVersion(pBuffer, sizeof(OMX_BUFFERHEADERTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((pRockchipComponent->currentState != OMX_StateIdle) &&
+ (pRockchipComponent->currentState != OMX_StateExecuting) &&
+ (pRockchipComponent->currentState != OMX_StatePause)) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ if ((!CHECK_PORT_ENABLED(pRockchipPort)) ||
+ (CHECK_PORT_BEING_FLUSHED(pRockchipPort) &&
+ (!CHECK_PORT_TUNNELED(pRockchipPort) || !CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort))) ||
+ ((pRockchipComponent->transientState == ROCKCHIP_OMX_TransStateExecutingToIdle) &&
+ (CHECK_PORT_TUNNELED(pRockchipPort) && !CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)))) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ Rockchip_OSAL_MutexLock(pRockchipPort->hPortMutex);
+ for (i = 0; i < pRockchipPort->portDefinition.nBufferCountActual; i++) {
+ if (pBuffer == pRockchipPort->extendBufferHeader[i].OMXBufferHeader) {
+ pRockchipPort->extendBufferHeader[i].bBufferInOMX = OMX_TRUE;
+ findBuffer = OMX_TRUE;
+ break;
+ }
+ }
+
+ if (findBuffer == OMX_FALSE) {
+ ret = OMX_ErrorBadParameter;
+ Rockchip_OSAL_MutexUnlock(pRockchipPort->hPortMutex);
+ goto EXIT;
+ }
+
+ message = Rockchip_OSAL_Malloc(sizeof(ROCKCHIP_OMX_MESSAGE));
+ if (message == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_MutexUnlock(pRockchipPort->hPortMutex);
+ goto EXIT;
+ }
+ message->messageType = ROCKCHIP_OMX_CommandEmptyBuffer;
+ message->messageParam = (OMX_U32) i;
+ message->pCmdData = (OMX_PTR)pBuffer;
+
+ ret = Rockchip_OSAL_Queue(&pRockchipPort->bufferQ, (void *)message);
+
+ if (ret != 0) {
+ ret = OMX_ErrorUndefined;
+ Rockchip_OSAL_MutexUnlock(pRockchipPort->hPortMutex);
+ goto EXIT;
+ }
+ ret = Rockchip_OSAL_SemaphorePost(pRockchipPort->bufferSemID);
+ Rockchip_OSAL_MutexUnlock(pRockchipPort->hPortMutex);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_FillThisBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_BUFFERHEADERTYPE *pBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_BOOL findBuffer = OMX_FALSE;
+ ROCKCHIP_OMX_MESSAGE *message;
+ OMX_U32 i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if (pBuffer == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pBuffer->nOutputPortIndex != OUTPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ ret = Rockchip_OMX_Check_SizeVersion(pBuffer, sizeof(OMX_BUFFERHEADERTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((pRockchipComponent->currentState != OMX_StateIdle) &&
+ (pRockchipComponent->currentState != OMX_StateExecuting) &&
+ (pRockchipComponent->currentState != OMX_StatePause)) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ if ((!CHECK_PORT_ENABLED(pRockchipPort)) ||
+ (CHECK_PORT_BEING_FLUSHED(pRockchipPort) &&
+ (!CHECK_PORT_TUNNELED(pRockchipPort) || !CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort))) ||
+ ((pRockchipComponent->transientState == ROCKCHIP_OMX_TransStateExecutingToIdle) &&
+ (CHECK_PORT_TUNNELED(pRockchipPort) && !CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)))) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ Rockchip_OSAL_MutexLock(pRockchipPort->hPortMutex);
+ for (i = 0; i < MAX_BUFFER_NUM; i++) {
+ if (pBuffer == pRockchipPort->extendBufferHeader[i].OMXBufferHeader) {
+ pRockchipPort->extendBufferHeader[i].bBufferInOMX = OMX_TRUE;
+ findBuffer = OMX_TRUE;
+ break;
+ }
+ }
+
+ if (findBuffer == OMX_FALSE) {
+ ret = OMX_ErrorBadParameter;
+ Rockchip_OSAL_MutexUnlock(pRockchipPort->hPortMutex);
+ goto EXIT;
+ }
+
+ message = Rockchip_OSAL_Malloc(sizeof(ROCKCHIP_OMX_MESSAGE));
+ if (message == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_MutexUnlock(pRockchipPort->hPortMutex);
+ goto EXIT;
+ }
+ message->messageType = ROCKCHIP_OMX_CommandFillBuffer;
+ message->messageParam = (OMX_U32) i;
+ message->pCmdData = (OMX_PTR)pBuffer;
+
+ ret = Rockchip_OSAL_Queue(&pRockchipPort->bufferQ, (void *)message);
+ if (ret != 0) {
+ ret = OMX_ErrorUndefined;
+ Rockchip_OSAL_MutexUnlock(pRockchipPort->hPortMutex);
+ goto EXIT;
+ }
+
+ ret = Rockchip_OSAL_SemaphorePost(pRockchipPort->bufferSemID);
+ Rockchip_OSAL_MutexUnlock(pRockchipPort->hPortMutex);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_Port_Constructor(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipInputPort = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutputPort = NULL;
+ int i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ INIT_SET_SIZE_VERSION(&pRockchipComponent->portParam, OMX_PORT_PARAM_TYPE);
+ pRockchipComponent->portParam.nPorts = ALL_PORT_NUM;
+ pRockchipComponent->portParam.nStartPortNumber = INPUT_PORT_INDEX;
+
+ pRockchipPort = Rockchip_OSAL_Malloc(sizeof(ROCKCHIP_OMX_BASEPORT) * ALL_PORT_NUM);
+ if (pRockchipPort == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ Rockchip_OSAL_Memset(pRockchipPort, 0, sizeof(ROCKCHIP_OMX_BASEPORT) * ALL_PORT_NUM);
+ pRockchipComponent->pRockchipPort = pRockchipPort;
+
+ /* Input Port */
+ pRockchipInputPort = &pRockchipPort[INPUT_PORT_INDEX];
+
+ Rockchip_OSAL_QueueCreate(&pRockchipInputPort->bufferQ, MAX_QUEUE_ELEMENTS);
+
+ pRockchipInputPort->extendBufferHeader = Rockchip_OSAL_Malloc(sizeof(ROCKCHIP_OMX_BUFFERHEADERTYPE) * MAX_BUFFER_NUM);
+ if (pRockchipInputPort->extendBufferHeader == NULL) {
+ Rockchip_OSAL_Free(pRockchipPort);
+ pRockchipPort = NULL;
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ Rockchip_OSAL_Memset(pRockchipInputPort->extendBufferHeader, 0, sizeof(ROCKCHIP_OMX_BUFFERHEADERTYPE) * MAX_BUFFER_NUM);
+
+ pRockchipInputPort->bufferStateAllocate = Rockchip_OSAL_Malloc(sizeof(OMX_U32) * MAX_BUFFER_NUM);
+ if (pRockchipInputPort->bufferStateAllocate == NULL) {
+ Rockchip_OSAL_Free(pRockchipInputPort->extendBufferHeader);
+ pRockchipInputPort->extendBufferHeader = NULL;
+ Rockchip_OSAL_Free(pRockchipPort);
+ pRockchipPort = NULL;
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ Rockchip_OSAL_Memset(pRockchipInputPort->bufferStateAllocate, 0, sizeof(OMX_U32) * MAX_BUFFER_NUM);
+
+ pRockchipInputPort->bufferSemID = NULL;
+ pRockchipInputPort->assignedBufferNum = 0;
+ pRockchipInputPort->portState = OMX_StateMax;
+ pRockchipInputPort->bIsPortFlushed = OMX_FALSE;
+ pRockchipInputPort->bIsPortDisabled = OMX_FALSE;
+ pRockchipInputPort->tunneledComponent = NULL;
+ pRockchipInputPort->tunneledPort = 0;
+ pRockchipInputPort->tunnelBufferNum = 0;
+ pRockchipInputPort->bufferSupplier = OMX_BufferSupplyUnspecified;
+ pRockchipInputPort->tunnelFlags = 0;
+ ret = Rockchip_OSAL_SemaphoreCreate(&pRockchipInputPort->loadedResource);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_Free(pRockchipInputPort->bufferStateAllocate);
+ pRockchipInputPort->bufferStateAllocate = NULL;
+ Rockchip_OSAL_Free(pRockchipInputPort->extendBufferHeader);
+ pRockchipInputPort->extendBufferHeader = NULL;
+ Rockchip_OSAL_Free(pRockchipPort);
+ pRockchipPort = NULL;
+ goto EXIT;
+ }
+ ret = Rockchip_OSAL_SemaphoreCreate(&pRockchipInputPort->unloadedResource);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipInputPort->loadedResource);
+ pRockchipInputPort->loadedResource = NULL;
+ Rockchip_OSAL_Free(pRockchipInputPort->bufferStateAllocate);
+ pRockchipInputPort->bufferStateAllocate = NULL;
+ Rockchip_OSAL_Free(pRockchipInputPort->extendBufferHeader);
+ pRockchipInputPort->extendBufferHeader = NULL;
+ Rockchip_OSAL_Free(pRockchipPort);
+ pRockchipPort = NULL;
+ goto EXIT;
+ }
+
+ INIT_SET_SIZE_VERSION(&pRockchipInputPort->portDefinition, OMX_PARAM_PORTDEFINITIONTYPE);
+ pRockchipInputPort->portDefinition.nPortIndex = INPUT_PORT_INDEX;
+ pRockchipInputPort->portDefinition.eDir = OMX_DirInput;
+ pRockchipInputPort->portDefinition.nBufferCountActual = 0;
+ pRockchipInputPort->portDefinition.nBufferCountMin = 0;
+ pRockchipInputPort->portDefinition.nBufferSize = 0;
+ pRockchipInputPort->portDefinition.bEnabled = OMX_FALSE;
+ pRockchipInputPort->portDefinition.bPopulated = OMX_FALSE;
+ pRockchipInputPort->portDefinition.eDomain = OMX_PortDomainMax;
+ pRockchipInputPort->portDefinition.bBuffersContiguous = OMX_FALSE;
+ pRockchipInputPort->portDefinition.nBufferAlignment = 0;
+ pRockchipInputPort->markType.hMarkTargetComponent = NULL;
+ pRockchipInputPort->markType.pMarkData = NULL;
+ pRockchipInputPort->exceptionFlag = GENERAL_STATE;
+
+ /* Output Port */
+ pRockchipOutputPort = &pRockchipPort[OUTPUT_PORT_INDEX];
+
+ Rockchip_OSAL_QueueCreate(&pRockchipOutputPort->bufferQ, MAX_QUEUE_ELEMENTS); /* For in case of "Output Buffer Share", MAX ELEMENTS(DPB + EDPB) */
+
+ pRockchipOutputPort->extendBufferHeader = Rockchip_OSAL_Malloc(sizeof(ROCKCHIP_OMX_BUFFERHEADERTYPE) * MAX_BUFFER_NUM);
+ if (pRockchipOutputPort->extendBufferHeader == NULL) {
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipInputPort->unloadedResource);
+ pRockchipInputPort->unloadedResource = NULL;
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipInputPort->loadedResource);
+ pRockchipInputPort->loadedResource = NULL;
+ Rockchip_OSAL_Free(pRockchipInputPort->bufferStateAllocate);
+ pRockchipInputPort->bufferStateAllocate = NULL;
+ Rockchip_OSAL_Free(pRockchipInputPort->extendBufferHeader);
+ pRockchipInputPort->extendBufferHeader = NULL;
+ Rockchip_OSAL_Free(pRockchipPort);
+ pRockchipPort = NULL;
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ Rockchip_OSAL_Memset(pRockchipOutputPort->extendBufferHeader, 0, sizeof(ROCKCHIP_OMX_BUFFERHEADERTYPE) * MAX_BUFFER_NUM);
+
+ pRockchipOutputPort->bufferStateAllocate = Rockchip_OSAL_Malloc(sizeof(OMX_U32) * MAX_BUFFER_NUM);
+ if (pRockchipOutputPort->bufferStateAllocate == NULL) {
+ Rockchip_OSAL_Free(pRockchipOutputPort->extendBufferHeader);
+ pRockchipOutputPort->extendBufferHeader = NULL;
+
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipInputPort->unloadedResource);
+ pRockchipInputPort->unloadedResource = NULL;
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipInputPort->loadedResource);
+ pRockchipInputPort->loadedResource = NULL;
+ Rockchip_OSAL_Free(pRockchipInputPort->bufferStateAllocate);
+ pRockchipInputPort->bufferStateAllocate = NULL;
+ Rockchip_OSAL_Free(pRockchipInputPort->extendBufferHeader);
+ pRockchipInputPort->extendBufferHeader = NULL;
+ Rockchip_OSAL_Free(pRockchipPort);
+ pRockchipPort = NULL;
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ Rockchip_OSAL_Memset(pRockchipOutputPort->bufferStateAllocate, 0, sizeof(OMX_U32) * MAX_BUFFER_NUM);
+
+ pRockchipOutputPort->bufferSemID = NULL;
+ pRockchipOutputPort->assignedBufferNum = 0;
+ pRockchipOutputPort->portState = OMX_StateMax;
+ pRockchipOutputPort->bIsPortFlushed = OMX_FALSE;
+ pRockchipOutputPort->bIsPortDisabled = OMX_FALSE;
+ pRockchipOutputPort->tunneledComponent = NULL;
+ pRockchipOutputPort->tunneledPort = 0;
+ pRockchipOutputPort->tunnelBufferNum = 0;
+ pRockchipOutputPort->bufferSupplier = OMX_BufferSupplyUnspecified;
+ pRockchipOutputPort->tunnelFlags = 0;
+ ret = Rockchip_OSAL_SemaphoreCreate(&pRockchipOutputPort->loadedResource);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_Free(pRockchipOutputPort->bufferStateAllocate);
+ pRockchipOutputPort->bufferStateAllocate = NULL;
+ Rockchip_OSAL_Free(pRockchipOutputPort->extendBufferHeader);
+ pRockchipOutputPort->extendBufferHeader = NULL;
+
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipInputPort->unloadedResource);
+ pRockchipInputPort->unloadedResource = NULL;
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipInputPort->loadedResource);
+ pRockchipInputPort->loadedResource = NULL;
+ Rockchip_OSAL_Free(pRockchipInputPort->bufferStateAllocate);
+ pRockchipInputPort->bufferStateAllocate = NULL;
+ Rockchip_OSAL_Free(pRockchipInputPort->extendBufferHeader);
+ pRockchipInputPort->extendBufferHeader = NULL;
+ Rockchip_OSAL_Free(pRockchipPort);
+ pRockchipPort = NULL;
+ goto EXIT;
+ }
+ ret = Rockchip_OSAL_SignalCreate(&pRockchipOutputPort->unloadedResource);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipOutputPort->loadedResource);
+ pRockchipOutputPort->loadedResource = NULL;
+ Rockchip_OSAL_Free(pRockchipOutputPort->bufferStateAllocate);
+ pRockchipOutputPort->bufferStateAllocate = NULL;
+ Rockchip_OSAL_Free(pRockchipOutputPort->extendBufferHeader);
+ pRockchipOutputPort->extendBufferHeader = NULL;
+
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipInputPort->unloadedResource);
+ pRockchipInputPort->unloadedResource = NULL;
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipInputPort->loadedResource);
+ pRockchipInputPort->loadedResource = NULL;
+ Rockchip_OSAL_Free(pRockchipInputPort->bufferStateAllocate);
+ pRockchipInputPort->bufferStateAllocate = NULL;
+ Rockchip_OSAL_Free(pRockchipInputPort->extendBufferHeader);
+ pRockchipInputPort->extendBufferHeader = NULL;
+ Rockchip_OSAL_Free(pRockchipPort);
+ pRockchipPort = NULL;
+ goto EXIT;
+ }
+
+ INIT_SET_SIZE_VERSION(&pRockchipOutputPort->portDefinition, OMX_PARAM_PORTDEFINITIONTYPE);
+ pRockchipOutputPort->portDefinition.nPortIndex = OUTPUT_PORT_INDEX;
+ pRockchipOutputPort->portDefinition.eDir = OMX_DirOutput;
+ pRockchipOutputPort->portDefinition.nBufferCountActual = 0;
+ pRockchipOutputPort->portDefinition.nBufferCountMin = 0;
+ pRockchipOutputPort->portDefinition.nBufferSize = 0;
+ pRockchipOutputPort->portDefinition.bEnabled = OMX_FALSE;
+ pRockchipOutputPort->portDefinition.bPopulated = OMX_FALSE;
+ pRockchipOutputPort->portDefinition.eDomain = OMX_PortDomainMax;
+ pRockchipOutputPort->portDefinition.bBuffersContiguous = OMX_FALSE;
+ pRockchipOutputPort->portDefinition.nBufferAlignment = 0;
+ pRockchipOutputPort->markType.hMarkTargetComponent = NULL;
+ pRockchipOutputPort->markType.pMarkData = NULL;
+ pRockchipOutputPort->exceptionFlag = GENERAL_STATE;
+
+ pRockchipComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
+ pRockchipComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
+ pRockchipComponent->checkTimeStamp.startTimeStamp = 0;
+ pRockchipComponent->checkTimeStamp.nStartFlags = 0x0;
+
+ pOMXComponent->EmptyThisBuffer = &Rockchip_OMX_EmptyThisBuffer;
+ pOMXComponent->FillThisBuffer = &Rockchip_OMX_FillThisBuffer;
+
+ ret = OMX_ErrorNone;
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_Port_Destructor(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+
+ OMX_S32 countValue = 0;
+ int i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pRockchipComponent->transientState == ROCKCHIP_OMX_TransStateLoadedToIdle) {
+ pRockchipComponent->abendState = OMX_TRUE;
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[i];
+ Rockchip_OSAL_SemaphorePost(pRockchipPort->loadedResource);
+ }
+ Rockchip_OSAL_SignalWait(pRockchipComponent->abendStateEvent, DEF_MAX_WAIT_TIME);
+ Rockchip_OSAL_SignalReset(pRockchipComponent->abendStateEvent);
+ }
+
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[i];
+
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipPort->loadedResource);
+ pRockchipPort->loadedResource = NULL;
+ Rockchip_OSAL_SemaphoreTerminate(pRockchipPort->unloadedResource);
+ pRockchipPort->unloadedResource = NULL;
+ Rockchip_OSAL_Free(pRockchipPort->bufferStateAllocate);
+ pRockchipPort->bufferStateAllocate = NULL;
+ Rockchip_OSAL_Free(pRockchipPort->extendBufferHeader);
+ pRockchipPort->extendBufferHeader = NULL;
+
+ Rockchip_OSAL_QueueTerminate(&pRockchipPort->bufferQ);
+ }
+ Rockchip_OSAL_Free(pRockchipComponent->pRockchipPort);
+ pRockchipComponent->pRockchipPort = NULL;
+ ret = OMX_ErrorNone;
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_ResetDataBuffer(ROCKCHIP_OMX_DATABUFFER *pDataBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ if (pDataBuffer == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pDataBuffer->dataValid = OMX_FALSE;
+ pDataBuffer->dataLen = 0;
+ pDataBuffer->remainDataLen = 0;
+ pDataBuffer->usedDataLen = 0;
+ pDataBuffer->bufferHeader = NULL;
+ pDataBuffer->nFlags = 0;
+ pDataBuffer->timeStamp = 0;
+ pDataBuffer->pPrivate = NULL;
+
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_ResetCodecData(ROCKCHIP_OMX_DATA *pData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ if (pData == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pData->dataLen = 0;
+ pData->usedDataLen = 0;
+ pData->remainDataLen = 0;
+ pData->nFlags = 0;
+ pData->timeStamp = 0;
+ pData->pPrivate = NULL;
+ pData->bufferHeader = NULL;
+ pData->allocSize = 0;
+
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_Shared_BufferToData(ROCKCHIP_OMX_DATABUFFER *pUseBuffer, ROCKCHIP_OMX_DATA *pData, ROCKCHIP_OMX_PLANE nPlane)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ if (nPlane == ONE_PLANE) {
+ /* Case of Shared Buffer, Only support singlePlaneBuffer */
+ pData->buffer.singlePlaneBuffer.dataBuffer = pUseBuffer->bufferHeader->pBuffer;
+ } else {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Can not support plane");
+ ret = OMX_ErrorNotImplemented;
+ goto EXIT;
+ }
+
+ pData->allocSize = pUseBuffer->allocSize;
+ pData->dataLen = pUseBuffer->dataLen;
+ pData->usedDataLen = pUseBuffer->usedDataLen;
+ pData->remainDataLen = pUseBuffer->remainDataLen;
+ pData->timeStamp = pUseBuffer->timeStamp;
+ pData->nFlags = pUseBuffer->nFlags;
+ pData->pPrivate = pUseBuffer->pPrivate;
+ pData->bufferHeader = pUseBuffer->bufferHeader;
+
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_Shared_DataToBuffer(ROCKCHIP_OMX_DATA *pData, ROCKCHIP_OMX_DATABUFFER *pUseBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ pUseBuffer->bufferHeader = pData->bufferHeader;
+ pUseBuffer->allocSize = pData->allocSize;
+ pUseBuffer->dataLen = pData->dataLen;
+ pUseBuffer->usedDataLen = pData->usedDataLen;
+ pUseBuffer->remainDataLen = pData->remainDataLen;
+ pUseBuffer->timeStamp = pData->timeStamp;
+ pUseBuffer->nFlags = pData->nFlags;
+ pUseBuffer->pPrivate = pData->pPrivate;
+
+ return ret;
+}
diff --git a/component/common/Rockchip_OMX_Baseport.h b/component/common/Rockchip_OMX_Baseport.h
new file mode 100644
index 0000000..dc4d081
--- /dev/null
+++ b/component/common/Rockchip_OMX_Baseport.h
@@ -0,0 +1,208 @@
+/*
+ *
+ * Copyright 2013 rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rockchip_OMX_Baseport.h
+ * @brief
+ * @author csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.26 : Create
+ */
+
+#ifndef ROCKCHIP_OMX_BASE_PORT
+#define ROCKCHIP_OMX_BASE_PORT
+
+
+#include "OMX_Component.h"
+#include "Rockchip_OMX_Def.h"
+#include "Rockchip_OSAL_Queue.h"
+
+
+#define BUFFER_STATE_ALLOCATED (1 << 0)
+#define BUFFER_STATE_ASSIGNED (1 << 1)
+#define HEADER_STATE_ALLOCATED (1 << 2)
+#define BUFFER_STATE_FREE 0
+
+#define MAX_BUFFER_NUM 40
+
+#define INPUT_PORT_INDEX 0
+#define OUTPUT_PORT_INDEX 1
+#define ALL_PORT_INDEX -1
+#define ALL_PORT_NUM 2
+
+
+typedef struct _ROCKCHIP_OMX_BUFFERHEADERTYPE {
+ OMX_BUFFERHEADERTYPE *OMXBufferHeader;
+ OMX_BOOL bBufferInOMX;
+ OMX_HANDLETYPE ANBHandle;
+ void *pYUVBuf[MAX_BUFFER_PLANE];
+ int buf_fd[MAX_BUFFER_PLANE];
+ int pRegisterFlag;
+ OMX_PTR pPrivate;
+} ROCKCHIP_OMX_BUFFERHEADERTYPE;
+
+typedef struct _ROCKCHIP_OMX_DATABUFFER {
+ OMX_HANDLETYPE bufferMutex;
+ OMX_BUFFERHEADERTYPE* bufferHeader;
+ OMX_BOOL dataValid;
+ OMX_U32 allocSize;
+ OMX_U32 dataLen;
+ OMX_U32 usedDataLen;
+ OMX_U32 remainDataLen;
+ OMX_U32 nFlags;
+ OMX_TICKS timeStamp;
+ OMX_PTR pPrivate;
+} ROCKCHIP_OMX_DATABUFFER;
+
+typedef void* CODEC_EXTRA_BUFFERINFO;
+
+typedef struct _ROCKCHIP_OMX_SINGLEPLANE_DATA {
+ OMX_PTR dataBuffer;
+ int fd;
+} ROCKCHIP_OMX_SINGLEPLANE_DATA;
+
+typedef struct _ROCKCHIP_OMX_MULTIPLANE_DATA {
+ OMX_U32 validPlaneNum;
+ OMX_PTR dataBuffer[MAX_BUFFER_PLANE];
+ int fd[MAX_BUFFER_PLANE];
+} ROCKCHIP_OMX_MULTIPLANE_DATA;
+
+typedef struct _ROCKCHIP_OMX_DATA {
+ union {
+ ROCKCHIP_OMX_SINGLEPLANE_DATA singlePlaneBuffer;
+ ROCKCHIP_OMX_MULTIPLANE_DATA multiPlaneBuffer;
+ } buffer;
+ OMX_U32 allocSize;
+ OMX_U32 dataLen;
+ OMX_U32 usedDataLen;
+ OMX_U32 remainDataLen;
+ OMX_U32 nFlags;
+ OMX_TICKS timeStamp;
+ OMX_PTR pPrivate;
+ CODEC_EXTRA_BUFFERINFO extInfo;
+
+ /* For Share Buffer */
+ OMX_BUFFERHEADERTYPE* bufferHeader;
+} ROCKCHIP_OMX_DATA;
+
+typedef struct _ROCKCHIP_OMX_WAY1_PORT_DATABUFFER {
+ ROCKCHIP_OMX_DATABUFFER dataBuffer;
+} ROCKCHIP_OMX_PORT_1WAY_DATABUFFER;
+
+typedef struct _ROCKCHIP_OMX_WAY2_PORT_DATABUFFER {
+ ROCKCHIP_OMX_DATABUFFER inputDataBuffer;
+ ROCKCHIP_OMX_DATABUFFER outputDataBuffer;
+} ROCKCHIP_OMX_PORT_2WAY_DATABUFFER;
+
+typedef enum _ROCKCHIP_OMX_PORT_WAY_TYPE {
+ WAY1_PORT = 0x00,
+ WAY2_PORT
+} ROCKCHIP_OMX_PORT_WAY_TYPE;
+
+typedef enum _ROCKCHIP_OMX_EXCEPTION_STATE {
+ GENERAL_STATE = 0x00,
+ NEED_PORT_FLUSH,
+ NEED_PORT_DISABLE,
+ INVALID_STATE,
+} ROCKCHIP_OMX_EXCEPTION_STATE;
+
+typedef enum _ROCKCHIP_OMX_PLANE {
+ ONE_PLANE = 0x01,
+ TWO_PLANE = 0x02,
+ THREE_PLANE = 0x03,
+ /*
+ ANB_START_PLANE = 0x10,
+ ANB_ONE_PLANE = 0x11,
+ ANB_TWO_PLANE = 0x12,
+ ANB_THREE_PLANE = 0x13,
+ */
+} ROCKCHIP_OMX_PLANE;
+
+typedef struct _ROCKCHIP_OMX_BASEPORT {
+ ROCKCHIP_OMX_BUFFERHEADERTYPE *extendBufferHeader;
+ OMX_U32 *bufferStateAllocate;
+ OMX_PARAM_PORTDEFINITIONTYPE portDefinition;
+ OMX_HANDLETYPE bufferSemID;
+ ROCKCHIP_QUEUE bufferQ;
+ OMX_U32 assignedBufferNum;
+ OMX_STATETYPE portState;
+ OMX_HANDLETYPE loadedResource;
+ OMX_HANDLETYPE unloadedResource;
+
+ OMX_BOOL bIsPortFlushed;
+ OMX_BOOL bIsPortDisabled;
+ OMX_MARKTYPE markType;
+
+ OMX_CONFIG_RECTTYPE cropRectangle;
+
+ /* Tunnel Info */
+ OMX_HANDLETYPE tunneledComponent;
+ OMX_U32 tunneledPort;
+ OMX_U32 tunnelBufferNum;
+ OMX_BUFFERSUPPLIERTYPE bufferSupplier;
+ OMX_U32 tunnelFlags;
+
+ OMX_BOOL bStoreMetaData;
+
+ ROCKCHIP_OMX_BUFFERPROCESS_TYPE bufferProcessType;
+ ROCKCHIP_OMX_PORT_WAY_TYPE portWayType;
+ OMX_HANDLETYPE codecSemID;
+ ROCKCHIP_QUEUE codecBufferQ;
+
+ OMX_HANDLETYPE pauseEvent;
+
+ /* Buffer */
+ union {
+ ROCKCHIP_OMX_PORT_1WAY_DATABUFFER port1WayDataBuffer;
+ ROCKCHIP_OMX_PORT_2WAY_DATABUFFER port2WayDataBuffer;
+ } way;
+
+ /* Data */
+ ROCKCHIP_OMX_DATA processData;
+
+ /* for flush of Shared buffer scheme */
+ OMX_HANDLETYPE hAllCodecBufferReturnEvent;
+ OMX_HANDLETYPE hPortMutex;
+ ROCKCHIP_OMX_EXCEPTION_STATE exceptionFlag;
+
+ OMX_PARAM_PORTDEFINITIONTYPE newPortDefinition;
+ OMX_CONFIG_RECTTYPE newCropRectangle;
+} ROCKCHIP_OMX_BASEPORT;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE Rockchip_OMX_PortEnableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex);
+OMX_ERRORTYPE Rockchip_OMX_PortDisableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex);
+OMX_ERRORTYPE Rockchip_OMX_BufferFlushProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent);
+OMX_ERRORTYPE Rockchip_OMX_Port_Constructor(OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE Rockchip_OMX_Port_Destructor(OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE Rockchip_ResetDataBuffer(ROCKCHIP_OMX_DATABUFFER *pDataBuffer);
+OMX_ERRORTYPE Rockchip_ResetCodecData(ROCKCHIP_OMX_DATA *pData);
+OMX_ERRORTYPE Rockchip_Shared_BufferToData(ROCKCHIP_OMX_DATABUFFER *pUseBuffer, ROCKCHIP_OMX_DATA *pData, ROCKCHIP_OMX_PLANE nPlane);
+OMX_ERRORTYPE Rockchip_Shared_DataToBuffer(ROCKCHIP_OMX_DATA *pData, ROCKCHIP_OMX_DATABUFFER *pUseBuffer);
+OMX_ERRORTYPE Rkvpu_OMX_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, OMX_BUFFERHEADERTYPE* bufferHeader);
+OMX_ERRORTYPE Rockchip_OMX_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, OMX_BUFFERHEADERTYPE* bufferHeader);
+#ifdef __cplusplus
+};
+#endif
+
+
+#endif
diff --git a/component/common/Rockchip_OMX_Resourcemanager.c b/component/common/Rockchip_OMX_Resourcemanager.c
new file mode 100755
index 0000000..c6aa864
--- /dev/null
+++ b/component/common/Rockchip_OMX_Resourcemanager.c
@@ -0,0 +1,536 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rockchip_OMX_Resourcemanager.c
+ * @brief
+ * @author csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.26 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "Rockchip_OMX_Resourcemanager.h"
+#include "Rockchip_OMX_Basecomponent.h"
+#include "Rockchip_OSAL_Memory.h"
+#include "Rockchip_OSAL_Mutex.h"
+#include "git_info.h"
+
+#undef ROCKCHIP_LOG_TAG
+#define ROCKCHIP_LOG_TAG "ROCKCHIP_RM"
+#define ROCKCHIP_LOG_OFF
+#include "Rockchip_OSAL_Log.h"
+
+
+#define MAX_RESOURCE_VIDEO_DEC 6 /* for Android */
+#define MAX_RESOURCE_VIDEO_ENC 4 /* for Android */
+
+/* Max allowable video scheduler component instance */
+static ROCKCHIP_OMX_RM_COMPONENT_LIST *gpVideoDecRMComponentList = NULL;
+static ROCKCHIP_OMX_RM_COMPONENT_LIST *gpVideoDecRMWaitingList = NULL;
+static ROCKCHIP_OMX_RM_COMPONENT_LIST *gpVideoEncRMComponentList = NULL;
+static ROCKCHIP_OMX_RM_COMPONENT_LIST *gpVideoEncRMWaitingList = NULL;
+static OMX_HANDLETYPE ghVideoRMComponentListMutex = NULL;
+
+
+OMX_ERRORTYPE addElementList(ROCKCHIP_OMX_RM_COMPONENT_LIST **ppList, OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pTempComp = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (*ppList != NULL) {
+ pTempComp = *ppList;
+ while (pTempComp->pNext != NULL) {
+ pTempComp = pTempComp->pNext;
+ }
+ pTempComp->pNext = (ROCKCHIP_OMX_RM_COMPONENT_LIST *)Rockchip_OSAL_Malloc(sizeof(ROCKCHIP_OMX_RM_COMPONENT_LIST));
+ if (pTempComp->pNext == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ ((ROCKCHIP_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->pNext = NULL;
+ ((ROCKCHIP_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->pOMXStandComp = pOMXComponent;
+ ((ROCKCHIP_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->groupPriority = pRockchipComponent->compPriority.nGroupPriority;
+ goto EXIT;
+ } else {
+ *ppList = (ROCKCHIP_OMX_RM_COMPONENT_LIST *)Rockchip_OSAL_Malloc(sizeof(ROCKCHIP_OMX_RM_COMPONENT_LIST));
+ if (*ppList == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pTempComp = *ppList;
+ pTempComp->pNext = NULL;
+ pTempComp->pOMXStandComp = pOMXComponent;
+ pTempComp->groupPriority = pRockchipComponent->compPriority.nGroupPriority;
+ }
+
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE removeElementList(ROCKCHIP_OMX_RM_COMPONENT_LIST **ppList, OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pCurrComp = NULL;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pPrevComp = NULL;
+ OMX_BOOL bDetectComp = OMX_FALSE;
+
+ if (*ppList == NULL) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ pCurrComp = *ppList;
+ while (pCurrComp != NULL) {
+ if (pCurrComp->pOMXStandComp == pOMXComponent) {
+ if (*ppList == pCurrComp) {
+ *ppList = pCurrComp->pNext;
+ Rockchip_OSAL_Free(pCurrComp);
+ } else {
+ if (pPrevComp != NULL)
+ pPrevComp->pNext = pCurrComp->pNext;
+
+ Rockchip_OSAL_Free(pCurrComp);
+ }
+ bDetectComp = OMX_TRUE;
+ break;
+ } else {
+ pPrevComp = pCurrComp;
+ pCurrComp = pCurrComp->pNext;
+ }
+ }
+
+ if (bDetectComp == OMX_FALSE)
+ ret = OMX_ErrorComponentNotFound;
+ else
+ ret = OMX_ErrorNone;
+
+EXIT:
+ return ret;
+}
+
+int searchLowPriority(ROCKCHIP_OMX_RM_COMPONENT_LIST *RMComp_list, OMX_U32 inComp_priority, ROCKCHIP_OMX_RM_COMPONENT_LIST **outLowComp)
+{
+ int ret = 0;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pTempComp = NULL;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pCandidateComp = NULL;
+
+ if (RMComp_list == NULL)
+ ret = -1;
+
+ pTempComp = RMComp_list;
+ *outLowComp = 0;
+
+ while (pTempComp != NULL) {
+ if (pTempComp->groupPriority > inComp_priority) {
+ if (pCandidateComp != NULL) {
+ if (pCandidateComp->groupPriority < pTempComp->groupPriority)
+ pCandidateComp = pTempComp;
+ } else {
+ pCandidateComp = pTempComp;
+ }
+ }
+
+ pTempComp = pTempComp->pNext;
+ }
+
+ *outLowComp = pCandidateComp;
+ if (pCandidateComp == NULL)
+ ret = 0;
+ else
+ ret = 1;
+
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE removeComponent(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pRockchipComponent->currentState == OMX_StateIdle) {
+ (*(pRockchipComponent->pCallbacks->EventHandler))
+ (pOMXComponent, pRockchipComponent->callbackData,
+ OMX_EventError, OMX_ErrorResourcesLost, 0, NULL);
+ ret = OMX_SendCommand(pOMXComponent, OMX_CommandStateSet, OMX_StateLoaded, NULL);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ } else if ((pRockchipComponent->currentState == OMX_StateExecuting) || (pRockchipComponent->currentState == OMX_StatePause)) {
+ /* Todo */
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ return ret;
+}
+
+
+OMX_ERRORTYPE Rockchip_OMX_ResourceManager_Init()
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ FunctionIn();
+ ret = Rockchip_OSAL_MutexCreate(&ghVideoRMComponentListMutex);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rockchip_OSAL_MutexCreate ghVideoRMComponentListMutex 0x%x", ghVideoRMComponentListMutex);
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_ResourceManager_Deinit()
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pCurrComponent;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pNextComponent;
+
+ FunctionIn();
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "ghVideoRMComponentListMutex lock in 0x%x", ghVideoRMComponentListMutex);
+ Rockchip_OSAL_MutexLock(ghVideoRMComponentListMutex);
+
+ if (gpVideoDecRMComponentList) {
+ pCurrComponent = gpVideoDecRMComponentList;
+ while (pCurrComponent != NULL) {
+ pNextComponent = pCurrComponent->pNext;
+ Rockchip_OSAL_Free(pCurrComponent);
+ pCurrComponent = pNextComponent;
+ }
+ gpVideoDecRMComponentList = NULL;
+ }
+ if (gpVideoDecRMWaitingList) {
+ pCurrComponent = gpVideoDecRMWaitingList;
+ while (pCurrComponent != NULL) {
+ pNextComponent = pCurrComponent->pNext;
+ Rockchip_OSAL_Free(pCurrComponent);
+ pCurrComponent = pNextComponent;
+ }
+ gpVideoDecRMWaitingList = NULL;
+ }
+
+ if (gpVideoEncRMComponentList) {
+ pCurrComponent = gpVideoEncRMComponentList;
+ while (pCurrComponent != NULL) {
+ pNextComponent = pCurrComponent->pNext;
+ Rockchip_OSAL_Free(pCurrComponent);
+ pCurrComponent = pNextComponent;
+ }
+ gpVideoEncRMComponentList = NULL;
+ }
+ if (gpVideoEncRMWaitingList) {
+ pCurrComponent = gpVideoEncRMWaitingList;
+ while (pCurrComponent != NULL) {
+ pNextComponent = pCurrComponent->pNext;
+ Rockchip_OSAL_Free(pCurrComponent);
+ pCurrComponent = pNextComponent;
+ }
+ gpVideoEncRMWaitingList = NULL;
+ }
+
+ Rockchip_OSAL_MutexUnlock(ghVideoRMComponentListMutex);
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rockchip_OSAL_MutexTerminate ghVideoRMComponentListMutex lock in 0x%x", ghVideoRMComponentListMutex);
+ Rockchip_OSAL_MutexTerminate(ghVideoRMComponentListMutex);
+ ghVideoRMComponentListMutex = NULL;
+
+ ret = OMX_ErrorNone;
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+OMX_ERRORTYPE Rockchip_OMX_Check_Resource(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pComponentCandidate = NULL;
+ int numElem = 0;
+ int lowCompDetect = 0;
+
+ FunctionIn();
+
+ Rockchip_OSAL_MutexLock(ghVideoRMComponentListMutex);
+
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pRockchipComponent->rkversion = OMX_COMPILE_INFO;
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "pRockchipComponent->codecType %d, Line:%d", pRockchipComponent->codecType, __LINE__);
+ if (pRockchipComponent->codecType == HW_VIDEO_DEC_CODEC) {
+ pComponentTemp = gpVideoDecRMComponentList;
+ if (pComponentTemp != NULL) {
+ while (pComponentTemp) {
+ numElem++;
+ pComponentTemp = pComponentTemp->pNext;
+ }
+ } else {
+ numElem = 0;
+ }
+ if (numElem >= MAX_RESOURCE_VIDEO_DEC) {
+ lowCompDetect = searchLowPriority(gpVideoDecRMComponentList, pRockchipComponent->compPriority.nGroupPriority, &pComponentCandidate);
+ if (lowCompDetect <= 0) {
+ ret = OMX_ErrorInsufficientResources;
+ }
+ }
+ } else if (pRockchipComponent->codecType == HW_VIDEO_ENC_CODEC) {
+ pComponentTemp = gpVideoEncRMComponentList;
+ if (pComponentTemp != NULL) {
+ while (pComponentTemp) {
+ numElem++;
+ pComponentTemp = pComponentTemp->pNext;
+ }
+ } else {
+ numElem = 0;
+ }
+ if (numElem >= MAX_RESOURCE_VIDEO_ENC) {
+ lowCompDetect = searchLowPriority(gpVideoEncRMComponentList, pRockchipComponent->compPriority.nGroupPriority, &pComponentCandidate);
+ if (lowCompDetect <= 0) {
+ ret = OMX_ErrorInsufficientResources;
+ }
+ }
+ }
+ Rockchip_OSAL_MutexUnlock(ghVideoRMComponentListMutex);
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_Get_Resource(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pComponentCandidate = NULL;
+ int numElem = 0;
+ int lowCompDetect = 0;
+
+ FunctionIn();
+
+ Rockchip_OSAL_MutexLock(ghVideoRMComponentListMutex);
+
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pRockchipComponent->rkversion = OMX_COMPILE_INFO;
+
+ if (pRockchipComponent->codecType == HW_VIDEO_DEC_CODEC) {
+ pComponentTemp = gpVideoDecRMComponentList;
+ if (pComponentTemp != NULL) {
+ while (pComponentTemp) {
+ numElem++;
+ pComponentTemp = pComponentTemp->pNext;
+ }
+ } else {
+ numElem = 0;
+ }
+ if (numElem >= MAX_RESOURCE_VIDEO_DEC) {
+ lowCompDetect = searchLowPriority(gpVideoDecRMComponentList, pRockchipComponent->compPriority.nGroupPriority, &pComponentCandidate);
+ if (lowCompDetect <= 0) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ } else {
+ ret = removeComponent(pComponentCandidate->pOMXStandComp);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ } else {
+ ret = removeElementList(&gpVideoDecRMComponentList, pComponentCandidate->pOMXStandComp);
+ ret = addElementList(&gpVideoDecRMComponentList, pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ }
+ }
+ } else {
+ ret = addElementList(&gpVideoDecRMComponentList, pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ }
+ } else if (pRockchipComponent->codecType == HW_VIDEO_ENC_CODEC) {
+ pComponentTemp = gpVideoEncRMComponentList;
+ if (pComponentTemp != NULL) {
+ while (pComponentTemp) {
+ numElem++;
+ pComponentTemp = pComponentTemp->pNext;
+ }
+ } else {
+ numElem = 0;
+ }
+ if (numElem >= MAX_RESOURCE_VIDEO_ENC) {
+ lowCompDetect = searchLowPriority(gpVideoEncRMComponentList, pRockchipComponent->compPriority.nGroupPriority, &pComponentCandidate);
+ if (lowCompDetect <= 0) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ } else {
+ ret = removeComponent(pComponentCandidate->pOMXStandComp);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ } else {
+ ret = removeElementList(&gpVideoEncRMComponentList, pComponentCandidate->pOMXStandComp);
+ ret = addElementList(&gpVideoEncRMComponentList, pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ }
+ }
+ } else {
+ ret = addElementList(&gpVideoEncRMComponentList, pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ }
+ }
+ ret = OMX_ErrorNone;
+
+EXIT:
+
+ Rockchip_OSAL_MutexUnlock(ghVideoRMComponentListMutex);
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_Release_Resource(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL;
+ OMX_COMPONENTTYPE *pOMXWaitComponent = NULL;
+ int numElem = 0;
+
+ FunctionIn();
+
+ Rockchip_OSAL_MutexLock(ghVideoRMComponentListMutex);
+
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pRockchipComponent->codecType == HW_VIDEO_DEC_CODEC) {
+ pComponentTemp = gpVideoDecRMWaitingList;
+ if (gpVideoDecRMComponentList == NULL) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ ret = removeElementList(&gpVideoDecRMComponentList, pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ while (pComponentTemp) {
+ numElem++;
+ pComponentTemp = pComponentTemp->pNext;
+ }
+ if (numElem > 0) {
+ pOMXWaitComponent = gpVideoDecRMWaitingList->pOMXStandComp;
+ removeElementList(&gpVideoDecRMWaitingList, pOMXWaitComponent);
+ ret = OMX_SendCommand(pOMXWaitComponent, OMX_CommandStateSet, OMX_StateIdle, NULL);
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ }
+ } else if (pRockchipComponent->codecType == HW_VIDEO_ENC_CODEC) {
+ pComponentTemp = gpVideoEncRMWaitingList;
+ if (gpVideoEncRMComponentList == NULL) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ ret = removeElementList(&gpVideoEncRMComponentList, pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ while (pComponentTemp) {
+ numElem++;
+ pComponentTemp = pComponentTemp->pNext;
+ }
+ if (numElem > 0) {
+ pOMXWaitComponent = gpVideoEncRMWaitingList->pOMXStandComp;
+ removeElementList(&gpVideoEncRMWaitingList, pOMXWaitComponent);
+ ret = OMX_SendCommand(pOMXWaitComponent, OMX_CommandStateSet, OMX_StateIdle, NULL);
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ }
+ }
+
+EXIT:
+
+ Rockchip_OSAL_MutexUnlock(ghVideoRMComponentListMutex);
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_In_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ Rockchip_OSAL_MutexLock(ghVideoRMComponentListMutex);
+
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pRockchipComponent->codecType == HW_VIDEO_DEC_CODEC)
+ ret = addElementList(&gpVideoDecRMWaitingList, pOMXComponent);
+ else if (pRockchipComponent->codecType == HW_VIDEO_ENC_CODEC)
+ ret = addElementList(&gpVideoEncRMWaitingList, pOMXComponent);
+
+ Rockchip_OSAL_MutexUnlock(ghVideoRMComponentListMutex);
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_Out_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ Rockchip_OSAL_MutexLock(ghVideoRMComponentListMutex);
+
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pRockchipComponent->codecType == HW_VIDEO_DEC_CODEC)
+ ret = removeElementList(&gpVideoDecRMWaitingList, pOMXComponent);
+ else if (pRockchipComponent->codecType == HW_VIDEO_ENC_CODEC)
+ ret = removeElementList(&gpVideoEncRMWaitingList, pOMXComponent);
+
+ Rockchip_OSAL_MutexUnlock(ghVideoRMComponentListMutex);
+
+ FunctionOut();
+
+ return ret;
+}
+
diff --git a/component/common/Rockchip_OMX_Resourcemanager.h b/component/common/Rockchip_OMX_Resourcemanager.h
new file mode 100644
index 0000000..187da10
--- /dev/null
+++ b/component/common/Rockchip_OMX_Resourcemanager.h
@@ -0,0 +1,59 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rockchip_OMX_Resourcemanager.h
+ * @brief
+ * @author csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.26 : Create
+ */
+
+#ifndef ROCKCHIP_OMX_RESOURCEMANAGER
+#define ROCKCHIP_OMX_RESOURCEMANAGER
+
+
+#include "Rockchip_OMX_Def.h"
+#include "OMX_Component.h"
+
+
+struct ROCKCHIP_OMX_RM_COMPONENT_LIST;
+typedef struct _ROCKCHIP_OMX_RM_COMPONENT_LIST {
+ OMX_COMPONENTTYPE *pOMXStandComp;
+ OMX_U32 groupPriority;
+ struct _ROCKCHIP_OMX_RM_COMPONENT_LIST *pNext;
+} ROCKCHIP_OMX_RM_COMPONENT_LIST;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE Rockchip_OMX_ResourceManager_Init();
+OMX_ERRORTYPE Rockchip_OMX_ResourceManager_Deinit();
+OMX_ERRORTYPE Rockchip_OMX_Get_Resource(OMX_COMPONENTTYPE *pOMXComponent);
+OMX_ERRORTYPE Rockchip_OMX_Check_Resource(OMX_COMPONENTTYPE *pOMXComponent);
+OMX_ERRORTYPE Rockchip_OMX_Release_Resource(OMX_COMPONENTTYPE *pOMXComponent);
+OMX_ERRORTYPE Rockchip_OMX_In_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent);
+OMX_ERRORTYPE Rockchip_OMX_Out_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/component/video/dec/Android.mk b/component/video/dec/Android.mk
new file mode 100644
index 0000000..7b9dd31
--- /dev/null
+++ b/component/video/dec/Android.mk
@@ -0,0 +1,58 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+ifeq ($(PLATFORM_VERSION),4.4.4)
+BOARD_VERSION_LOW := true
+endif
+LOCAL_SRC_FILES := \
+ Rkvpu_OMX_VdecControl.c \
+ Rkvpu_OMX_Vdec.c \
+ library_register.c
+
+LOCAL_MODULE := libomxvpu_dec
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_C_INCLUDES := $(ROCKCHIP_OMX_INC)/khronos \
+ $(ROCKCHIP_OMX_INC)/rockchip \
+ $(ROCKCHIP_OMX_TOP)/osal \
+ $(ROCKCHIP_OMX_TOP)/core \
+ $(ROCKCHIP_OMX_COMPONENT)/common \
+ $(ROCKCHIP_OMX_COMPONENT)/video/dec \
+ $(TOP)/hardware/rockchip/librkvpu
+
+LOCAL_STATIC_LIBRARIES := libRkOMX_OSAL \
+ libRkOMX_Basecomponent
+
+LOCAL_SHARED_LIBRARIES := libc \
+ libdl \
+ libcutils \
+ libutils \
+ liblog \
+ libui \
+ libRkOMX_Resourcemanager \
+ libhardware \
+ libvpu \
+ libgralloc_priv_omx
+
+ifeq ($(BOARD_USE_ANB), true)
+LOCAL_CFLAGS += -DUSE_ANB
+endif
+
+ifeq ($(BOARD_USE_STOREMETADATA), true)
+LOCAL_CFLAGS += -DUSE_STOREMETADATA
+endif
+
+ifeq ($(BOARD_CONFIG_3GR),true)
+LOCAL_CFLAGS += -DSOFIA_3GR \
+ -DROCKCHIP_GPU_LIB_ENABLE
+endif
+ifeq ($(BOARD_VERSION_LOW),true)
+LOCAL_CFLAGS += -DLOW_VRESION
+endif
+
+ifeq ($(OMX_USE_DRM), true)
+LOCAL_SHARED_LIBRARIES += librga
+endif
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/component/video/dec/Rkvpu_OMX_Vdec.c b/component/video/dec/Rkvpu_OMX_Vdec.c
new file mode 100755
index 0000000..db40d60
--- /dev/null
+++ b/component/video/dec/Rkvpu_OMX_Vdec.c
@@ -0,0 +1,1458 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rkon2_OMX_Vdec.c
+ * @brief
+ * @author csy (csy@rock-chips.com)
+ * @version 2.0.0
+ * @history
+ * 2013.11.28 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "Rockchip_OMX_Macros.h"
+#include "Rockchip_OSAL_Event.h"
+#include "Rkvpu_OMX_Vdec.h"
+#include "Rkvpu_OMX_VdecControl.h"
+#include "Rockchip_OMX_Basecomponent.h"
+#include "Rockchip_OSAL_Thread.h"
+#include "Rockchip_OSAL_Semaphore.h"
+#include "Rockchip_OSAL_Mutex.h"
+#include "Rockchip_OSAL_ETC.h"
+#include "Rockchip_OSAL_Android.h"
+#include "Rockchip_OSAL_RGA_Process.h"
+#include "vpu_mem_pool.h"
+#include <fcntl.h>
+#include "vpu_mem.h"
+#include <dlfcn.h>
+#include <unistd.h>
+#include <cutils/properties.h>
+#include <time.h>
+#include <sys/time.h>
+
+#undef ROCKCHIP_LOG_TAG
+#define ROCKCHIP_LOG_TAG "ROCKCHIP_VIDEO_DEC"
+#define ROCKCHIP_LOG_OFF
+//#define ROCKCHIP_TRACE_ON
+#include "Rockchip_OSAL_Log.h"
+
+#ifndef VPU_API_SET_IMMEDIATE_OUT
+#define VPU_API_SET_IMMEDIATE_OUT 0x1000
+#endif
+typedef struct {
+ OMX_RK_VIDEO_CODINGTYPE codec_id;
+ OMX_VIDEO_CODINGTYPE omx_id;
+} CodeMap;
+
+static const CodeMap kCodeMap[] = {
+ { OMX_RK_VIDEO_CodingMPEG2, OMX_VIDEO_CodingMPEG2},
+ { OMX_RK_VIDEO_CodingH263, OMX_VIDEO_CodingH263},
+ { OMX_RK_VIDEO_CodingMPEG4, OMX_VIDEO_CodingMPEG4},
+ { OMX_RK_VIDEO_CodingVC1, (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVC1},
+ // { OMX_RK_VIDEO_CodingRV, OMX_VIDEO_CodingRV},
+ { OMX_RK_VIDEO_CodingAVC, OMX_VIDEO_CodingAVC},
+ { OMX_RK_VIDEO_CodingMJPEG, OMX_VIDEO_CodingMJPEG},
+ { OMX_RK_VIDEO_CodingFLV1, (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingFLV1},
+ { OMX_RK_VIDEO_CodingVP8, OMX_VIDEO_CodingVP8},
+// { OMX_RK_VIDEO_CodingVP6, OMX_VIDEO_CodingVP6},
+ { OMX_RK_VIDEO_CodingWMV, OMX_VIDEO_CodingWMV},
+// { OMX_RK_VIDEO_CodingDIVX3, OMX_VIDEO_CodingDIVX3 },
+ { OMX_RK_VIDEO_CodingHEVC, OMX_VIDEO_CodingHEVC},
+ { OMX_RK_VIDEO_CodingVP9, OMX_VIDEO_CodingVP9},
+};
+
+int calc_plane(int width, int height)
+{
+ int mbX, mbY;
+
+ mbX = (width + 15) / 16;
+ mbY = (height + 15) / 16;
+
+ /* Alignment for interlaced processing */
+ mbY = (mbY + 1) / 2 * 2;
+
+ return (mbX * 16) * (mbY * 16);
+}
+
+static void controlFPS(OMX_BOOL isInput)
+{
+ static int inFrameCount = 0;
+ static int inLastFrameCount = 0;
+ static long inLastFpsTimeUs = 0;
+ static float inFps = 0;
+ static long inDiff = 0;
+ static long inNowUs = 0;
+ static int outFrameCount = 0;
+ static int outLastFrameCount = 0;
+ static long outLastFpsTimeUs = 0;
+ static float outFps = 0;
+ static long outDiff = 0;
+ static long outNowUs = 0;
+
+ if (isInput == OMX_TRUE) {
+ inFrameCount++;
+ if (!(inFrameCount & 0x1F)) {
+ struct timeval now;
+ gettimeofday(&now, NULL);
+ inNowUs = (long)now.tv_sec * 1000000 + (long)now.tv_usec;
+ inDiff = inNowUs - inLastFpsTimeUs;
+ inFps = ((float)(inFrameCount - inLastFrameCount) * 1.0f) * 1000.0f * 1000.0f / (float)inDiff;
+ inLastFpsTimeUs = inNowUs;
+ inLastFrameCount = inFrameCount;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "%s(%d): decode input frameCount = %d frameRate = %f HZ",
+ __FUNCTION__, __LINE__, inFrameCount, inFps);
+ }
+ } else {
+ outFrameCount++;
+ if (!(outFrameCount & 0x1F)) {
+ struct timeval now;
+ gettimeofday(&now, NULL);
+ outNowUs = (long)now.tv_sec * 1000000 + (long)now.tv_usec;
+ outDiff = outNowUs - outLastFpsTimeUs;
+ outFps = ((float)(outFrameCount - outLastFrameCount) * 1.0f) * 1000.0f * 1000.0f / (float)outDiff;
+ outLastFpsTimeUs = outNowUs;
+ outLastFrameCount = outFrameCount;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "%s(%d): decode output frameCount = %d frameRate = %f HZ",
+ __FUNCTION__, __LINE__, outFrameCount, outFps);
+ }
+ }
+ return;
+}
+
+
+void UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *rockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *rockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+
+ if ((rockchipOutputPort->portDefinition.format.video.nFrameWidth !=
+ rockchipInputPort->portDefinition.format.video.nFrameWidth) ||
+ (rockchipOutputPort->portDefinition.format.video.nFrameHeight !=
+ rockchipInputPort->portDefinition.format.video.nFrameHeight) ||
+ (rockchipOutputPort->portDefinition.format.video.nStride !=
+ rockchipInputPort->portDefinition.format.video.nStride) ||
+ (rockchipOutputPort->portDefinition.format.video.nSliceHeight !=
+ rockchipInputPort->portDefinition.format.video.nSliceHeight)) {
+ OMX_U32 width = 0, height = 0;
+
+ rockchipOutputPort->portDefinition.format.video.nFrameWidth =
+ rockchipInputPort->portDefinition.format.video.nFrameWidth;
+ rockchipOutputPort->portDefinition.format.video.nFrameHeight =
+ rockchipInputPort->portDefinition.format.video.nFrameHeight;
+ width = rockchipOutputPort->portDefinition.format.video.nStride =
+ rockchipInputPort->portDefinition.format.video.nStride;
+ height = rockchipOutputPort->portDefinition.format.video.nSliceHeight =
+ rockchipInputPort->portDefinition.format.video.nSliceHeight;
+
+ switch (rockchipOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ if (width && height)
+ rockchipOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
+ break;
+ default:
+ if (width && height)
+ rockchipOutputPort->portDefinition.nBufferSize = width * height * 2;
+ break;
+ }
+ }
+
+ return;
+}
+
+OMX_BOOL Rkvpu_Check_BufferProcess_State(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 nPortIndex)
+{
+ OMX_BOOL ret = OMX_FALSE;
+
+ if ((pRockchipComponent->currentState == OMX_StateExecuting) &&
+ (pRockchipComponent->pRockchipPort[nPortIndex].portState == OMX_StateIdle) &&
+ (pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateExecutingToIdle) &&
+ (pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateIdleToExecuting)) {
+ ret = OMX_TRUE;
+ } else {
+ ret = OMX_FALSE;
+ }
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_CheckIsNeedFastmode(
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ VpuCodecContext_t *p_vpu_ctx = pVideoDec->vpu_ctx;
+ if (pVideoDec->bFastMode == OMX_FALSE
+ && pVideoDec->codecId == OMX_VIDEO_CodingHEVC
+ && pInputPort->portDefinition.format.video.nFrameWidth > 1920
+ && pInputPort->portDefinition.format.video.nFrameHeight > 1080) {
+ pVideoDec->bFastMode = OMX_TRUE;
+ int fast_mode = 1;
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_USE_FAST_MODE, &fast_mode);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE,"used fast mode, h265decoder, width = %d, height = %d",
+ pInputPort->portDefinition.format.video.nFrameWidth,
+ pInputPort->portDefinition.format.video.nFrameHeight);
+ }
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_DebugSwitchfromPropget(
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ char value[PROPERTY_VALUE_MAX];
+ memset(value, 0, sizeof(value));
+ if (property_get("record_omx_dec_in", value, "0") && (atoi(value) > 0)) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "Start recording stream to /data/video/dec_in.bin");
+ if (pVideoDec->fp_in != NULL) {
+ fclose(pVideoDec->fp_in);
+ }
+ pVideoDec->fp_in = fopen("data/video/dec_in.bin", "wb");
+ }
+
+ memset(value, 0, sizeof(value));
+ if (property_get("dump_omx_fps", value, "0") && (atoi(value) > 0)) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "Start print framerate when frameCount = 32");
+ pVideoDec->bPrintFps = OMX_TRUE;
+ }
+
+ memset(value, 0, sizeof(value));
+ if (property_get("dump_omx_buf_position", value, "0") && (atoi(value) > 0)) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "print all buf position");
+ pVideoDec->bPrintBufferPosition = OMX_TRUE;
+ }
+
+ memset(value, 0, sizeof(value));
+ if (property_get("cts_gts.media.gts", value, NULL) && (!strcasecmp(value, "true"))) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "This is gts test.");
+ pVideoDec->bGtsTest = OMX_TRUE;
+ }
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_ResetAllPortConfig(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *pRockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+
+ /* Input port */
+ pRockchipInputPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
+ pRockchipInputPort->portDefinition.format.video.nFrameHeight = DEFAULT_FRAME_HEIGHT;
+ pRockchipInputPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/
+ pRockchipInputPort->portDefinition.format.video.nSliceHeight = 0;
+ pRockchipInputPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE;
+ pRockchipInputPort->portDefinition.format.video.pNativeRender = 0;
+ pRockchipInputPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pRockchipInputPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+ pRockchipInputPort->portDefinition.bEnabled = OMX_TRUE;
+ pRockchipInputPort->bufferProcessType = BUFFER_COPY;
+ pRockchipInputPort->portWayType = WAY2_PORT;
+
+ /* Output port */
+ pRockchipOutputPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
+ pRockchipOutputPort->portDefinition.format.video.nFrameHeight = DEFAULT_FRAME_HEIGHT;
+ pRockchipOutputPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/
+ pRockchipOutputPort->portDefinition.format.video.nSliceHeight = 0;
+ pRockchipOutputPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
+ pRockchipOutputPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+ Rockchip_OSAL_Memset(pRockchipOutputPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipOutputPort->portDefinition.format.video.cMIMEType, "raw/video");
+ pRockchipOutputPort->portDefinition.format.video.pNativeRender = 0;
+ pRockchipOutputPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pRockchipOutputPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ pRockchipOutputPort->portDefinition.nBufferCountActual = MAX_VIDEO_OUTPUTBUFFER_NUM;
+ pRockchipOutputPort->portDefinition.nBufferCountMin = MAX_VIDEO_OUTPUTBUFFER_NUM;
+ pRockchipOutputPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
+ pRockchipOutputPort->portDefinition.bEnabled = OMX_TRUE;
+ pRockchipOutputPort->bufferProcessType = BUFFER_COPY | BUFFER_ANBSHARE;
+ pRockchipOutputPort->portWayType = WAY2_PORT;
+
+ return ret;
+}
+
+void Rkvpu_Wait_ProcessPause(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 nPortIndex)
+{
+ ROCKCHIP_OMX_BASEPORT *rockchipOMXInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *rockchipOMXOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *rockchipOMXPort = NULL;
+
+ FunctionIn();
+
+ rockchipOMXPort = &pRockchipComponent->pRockchipPort[nPortIndex];
+
+ if (((pRockchipComponent->currentState == OMX_StatePause) ||
+ (pRockchipComponent->currentState == OMX_StateIdle) ||
+ (pRockchipComponent->transientState == ROCKCHIP_OMX_TransStateLoadedToIdle) ||
+ (pRockchipComponent->transientState == ROCKCHIP_OMX_TransStateExecutingToIdle)) &&
+ (pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateIdleToLoaded) &&
+ (!CHECK_PORT_BEING_FLUSHED(rockchipOMXPort))) {
+
+ Rockchip_OSAL_SignalWait(pRockchipComponent->pRockchipPort[nPortIndex].pauseEvent, DEF_MAX_WAIT_TIME);
+ Rockchip_OSAL_SignalReset(pRockchipComponent->pRockchipPort[nPortIndex].pauseEvent);
+ }
+
+ FunctionOut();
+
+ return;
+}
+
+OMX_BOOL Rkvpu_SendInputData(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_BOOL ret = OMX_FALSE;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *rockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_DATABUFFER *inputUseBuffer = &rockchipInputPort->way.port2WayDataBuffer.inputDataBuffer;
+ VpuCodecContext_t *p_vpu_ctx = pVideoDec->vpu_ctx;
+ OMX_S32 i = 0;
+ OMX_S32 numInOmxAl = 0;
+ OMX_S32 maxBufferNum = rockchipInputPort->portDefinition.nBufferCountActual;
+ FunctionIn();
+
+ for (i = 0; i < maxBufferNum; i++) {
+ if (rockchipInputPort->extendBufferHeader[i].bBufferInOMX == OMX_FALSE) {
+ numInOmxAl++;
+ }
+ }
+
+ if (pVideoDec->bPrintBufferPosition) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "in buffer position: in app and display num = %d",numInOmxAl);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "in buffer position: in omx and vpu num = %d",maxBufferNum - numInOmxAl);
+ }
+
+ if (inputUseBuffer->dataValid == OMX_TRUE) {
+ VideoPacket_t pkt;
+ if (pVideoDec->bFirstFrame == OMX_TRUE) {
+ OMX_U8 *extraData = NULL;
+ OMX_U32 extraSize = 0;
+ OMX_U32 extraFlag = 0;
+ OMX_U32 enableDinterlace = 1;
+ if (((inputUseBuffer->nFlags & OMX_BUFFERFLAG_EXTRADATA) == OMX_BUFFERFLAG_EXTRADATA)
+ || ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG) == OMX_BUFFERFLAG_CODECCONFIG)) {
+
+ extraData = (OMX_U8 *)Rockchip_OSAL_Malloc(inputUseBuffer->dataLen);
+ if (extraData == NULL) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "malloc Extra Data fail");
+ ret = OMX_FALSE;
+ goto EXIT;
+ }
+
+ Rockchip_OSAL_Memcpy(extraData, inputUseBuffer->bufferHeader->pBuffer + inputUseBuffer->usedDataLen,
+ inputUseBuffer->dataLen);
+ if (pVideoDec->fp_in != NULL) {
+ fwrite(extraData, 1, inputUseBuffer->dataLen, pVideoDec->fp_in);
+ fflush(pVideoDec->fp_in);
+ }
+ extraSize = inputUseBuffer->dataLen;
+ extraFlag = 1;
+ }
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "decode init");
+
+ p_vpu_ctx->init(p_vpu_ctx, extraData, extraSize);
+ // not use iep when thumbNail decode
+ if (!(pVideoDec->flags & RKVPU_OMX_VDEC_THUMBNAIL)) {
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENABLE_DEINTERLACE, &enableDinterlace);
+ }
+ if (pVideoDec->vpumem_handle != NULL) {
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_SET_VPUMEM_CONTEXT, pVideoDec->vpumem_handle);
+ }
+
+ if (rockchipInputPort->portDefinition.format.video.bFlagErrorConcealment) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_DEBUG, "use directly output mode for media");
+ RK_U32 flag = 1;
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_SET_IMMEDIATE_OUT, (void*)&flag);
+ }
+
+ pVideoDec->bFirstFrame = OMX_FALSE;
+ if (extraFlag) {
+ ret = OMX_TRUE;
+ if (extraData) {
+ Rockchip_OSAL_Free(extraData);
+ extraData = NULL;
+ }
+ Rkvpu_InputBufferReturn(pOMXComponent, inputUseBuffer);
+ goto EXIT;
+ }
+ }
+
+ if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "bSaveFlagEOS : OMX_TRUE");
+ pRockchipComponent->bSaveFlagEOS = OMX_TRUE;
+ // if (inputUseBuffer->dataLen != 0)
+ }
+ Rockchip_OSAL_Memset(&pkt, 0, sizeof(VideoPacket_t));
+ pkt.data = inputUseBuffer->bufferHeader->pBuffer + inputUseBuffer->usedDataLen;
+ pkt.size = inputUseBuffer->dataLen;
+
+ if (pVideoDec->fp_in != NULL) {
+ fwrite(pkt.data, 1, pkt.size, pVideoDec->fp_in);
+ fflush(pVideoDec->fp_in);
+ }
+
+ if (pVideoDec->flags & RKVPU_OMX_VDEC_USE_DTS) {
+ pkt.pts = VPU_API_NOPTS_VALUE;
+ pkt.dts = inputUseBuffer->timeStamp;
+ } else {
+ pkt.pts = pkt.dts = inputUseBuffer->timeStamp;
+ }
+ if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "send eos");
+ pkt.nFlags |= OMX_BUFFERFLAG_EOS;
+ }
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "decode_sendstream");
+ p_vpu_ctx->decode_sendstream(p_vpu_ctx, &pkt);
+ if (pkt.size != 0) {
+ // Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR,"stream list full wait");
+ goto EXIT;
+ }
+
+ if (pVideoDec->bPrintFps == OMX_TRUE) {
+ OMX_BOOL isInput = OMX_TRUE;
+ controlFPS(isInput);
+ }
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, ",pkt.size:%d, pkt.dts:%lld,pkt.pts:%lld,pkt.nFlags:%d",
+ pkt.size, pkt.dts, pkt.pts, pkt.nFlags);
+ Rkvpu_InputBufferReturn(pOMXComponent, inputUseBuffer);
+ if (pRockchipComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) {
+ pRockchipComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_TRUE;
+ pRockchipComponent->checkTimeStamp.startTimeStamp = inputUseBuffer->timeStamp;
+ pRockchipComponent->checkTimeStamp.nStartFlags = inputUseBuffer->nFlags;
+ pRockchipComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "first frame timestamp after seeking %lld us (%.2f secs)",
+ inputUseBuffer->timeStamp, inputUseBuffer->timeStamp / 1E6);
+ }
+ ret = OMX_TRUE;
+ }
+
+EXIT:
+ FunctionOut();
+ return ret;
+}
+
+OMX_BOOL Rkvpu_Post_OutputFrame(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_BOOL ret = OMX_FALSE;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *pOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_DATABUFFER *outputUseBuffer = &pOutputPort->way.port2WayDataBuffer.outputDataBuffer;
+ VpuCodecContext_t *p_vpu_ctx = pVideoDec->vpu_ctx;
+ OMX_U32 pOWnBycomponetNum = Rockchip_OSAL_GetElemNum(&pOutputPort->bufferQ);
+ OMX_S32 maxBufferNum = 0;
+ OMX_S32 i = 0, numInOmxAl = 0, limitNum = 8;
+ OMX_S32 bufferUnusedInVpu = 0;
+ FunctionIn();
+ if (p_vpu_ctx == NULL ||
+ (pVideoDec->bFirstFrame == OMX_TRUE) ||
+ (pVideoDec->bDecSendEOS == OMX_TRUE)) {
+ goto EXIT;
+ }
+ maxBufferNum = pOutputPort->portDefinition.nBufferCountActual;
+ for (i = 0; i < maxBufferNum; i++) {
+ if (pOutputPort->extendBufferHeader[i].bBufferInOMX == OMX_FALSE) {
+ numInOmxAl++;
+ }
+ }
+ if (pVideoDec->bPrintBufferPosition) {
+ struct vpu_display_mem_pool *pMem_pool = (struct vpu_display_mem_pool*)pVideoDec->vpumem_handle;
+ bufferUnusedInVpu = pMem_pool->get_unused_num(pMem_pool);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "out buffer position: in app and display num = %d",numInOmxAl);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "out buffer position: in omx and vpu num = %d",maxBufferNum - numInOmxAl);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "out buffer position: in component num = %d",pOWnBycomponetNum);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "out buffer position: in vpu unused buffer = %d",bufferUnusedInVpu);
+ }
+ if (pOutputPort->bufferProcessType == BUFFER_SHARE) {
+ OMX_U32 width = 0, height = 0;
+ int imageSize = 0;
+ OMX_S32 dec_ret = 0;
+ DecoderOut_t pOutput;
+ VPU_FRAME *pframe = (VPU_FRAME *)Rockchip_OSAL_Malloc(sizeof(VPU_FRAME));;
+ OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
+ Rockchip_OSAL_Memset(&pOutput, 0, sizeof(DecoderOut_t));
+ Rockchip_OSAL_Memset(pframe, 0, sizeof(VPU_FRAME));
+ pOutput.data = (unsigned char *)pframe;
+ if ((numInOmxAl < limitNum) ||
+ (pVideoDec->maxCount > 20)) {
+ dec_ret = p_vpu_ctx->decode_getframe(p_vpu_ctx, &pOutput);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "pOutput.size %d", pOutput.size);
+ pVideoDec->maxCount = 0;
+ } else {
+ pVideoDec->maxCount++;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "pVideoDec 0x%x numInOmxAl %d", pVideoDec, numInOmxAl);
+ }
+ if (dec_ret < 0) {
+ if (dec_ret == VPU_API_EOS_STREAM_REACHED) {
+ outputUseBuffer->dataLen = 0;
+ outputUseBuffer->remainDataLen = 0;
+ outputUseBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+ outputUseBuffer->timeStamp = 0;
+ outputUseBuffer->dataValid = OMX_FALSE;
+ ret = OMX_TRUE;
+ pVideoDec->bDecSendEOS = OMX_TRUE;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "OMX_BUFFERFLAG_EOS");
+ } else {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_DECODER ERROR");
+ pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pRockchipComponent->callbackData, OMX_EventError,
+ OUTPUT_PORT_INDEX,
+ OMX_IndexParamPortDefinition, NULL);
+ }
+ Rkvpu_OutputBufferReturn(pOMXComponent, outputUseBuffer);
+ }
+ if (outputUseBuffer->dataValid == OMX_TRUE && (pOWnBycomponetNum > 1)) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "commit fd to vpu 0x%x\n", outputUseBuffer->bufferHeader);
+ Rockchip_OSAL_Fd2VpumemPool(pRockchipComponent, outputUseBuffer->bufferHeader);
+ Rockchip_ResetDataBuffer(outputUseBuffer);
+ }
+
+ if ((pOutput.size > 0) && (!CHECK_PORT_BEING_FLUSHED(pOutputPort))) {
+ OMX_COLOR_FORMATTYPE eColorFormat = Rockchip_OSAL_CheckFormat(pRockchipComponent, pframe);
+ if ((pInputPort->portDefinition.format.video.nFrameWidth != pframe->DisplayWidth) ||
+ (pInputPort->portDefinition.format.video.nFrameHeight != pframe->DisplayHeight)
+ || (pInputPort->portDefinition.format.video.nSliceHeight != pframe->FrameHeight)
+ || (pInputPort->portDefinition.format.video.nStride != (OMX_S32)pframe->FrameWidth)
+ || pOutputPort->portDefinition.format.video.eColorFormat != eColorFormat) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "video.nFrameWidth %d video.nFrameHeight %d nSliceHeight %d",
+ pInputPort->portDefinition.format.video.nFrameWidth,
+ pInputPort->portDefinition.format.video.nFrameHeight,
+ pInputPort->portDefinition.format.video.nSliceHeight);
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "video.nFrameWidth %d video.nFrameHeight %d pframe->FrameHeight %d",
+ pframe->DisplayWidth,
+ pframe->DisplayHeight, pframe->FrameHeight);
+
+ pOutputPort->newCropRectangle.nWidth = pframe->DisplayWidth;
+ pOutputPort->newCropRectangle.nHeight = pframe->DisplayHeight;
+ pOutputPort->newPortDefinition.format.video.eColorFormat = eColorFormat;
+ pOutputPort->newPortDefinition.nBufferCountActual = pOutputPort->portDefinition.nBufferCountActual;
+ pOutputPort->newPortDefinition.nBufferCountMin = pOutputPort->portDefinition.nBufferCountMin;
+ pInputPort->newPortDefinition.format.video.nFrameWidth = pframe->DisplayWidth;
+ pInputPort->newPortDefinition.format.video.nFrameHeight = pframe->DisplayHeight;
+
+ pInputPort->newPortDefinition.format.video.nStride = Get_Video_HorAlign(pVideoDec->codecId, pframe->FrameWidth, pframe->FrameHeight);
+ pInputPort->newPortDefinition.format.video.nSliceHeight = Get_Video_VerAlign(pVideoDec->codecId, pframe->FrameHeight);
+
+ Rkvpu_ResolutionUpdate(pOMXComponent);
+ pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pRockchipComponent->callbackData, OMX_EventPortSettingsChanged,
+ OUTPUT_PORT_INDEX,
+ OMX_IndexParamPortDefinition, NULL);
+ if (pframe->vpumem.phy_addr > 0) {
+ VPUMemLink(&pframe->vpumem);
+ VPUFreeLinear(&pframe->vpumem);
+ }
+ Rockchip_OSAL_Free(pframe);
+ Rockchip_OSAL_resetVpumemPool(pRockchipComponent);
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_SET_INFO_CHANGE, NULL);
+ goto EXIT;
+ }
+
+ if (pVideoDec->bPrintFps == OMX_TRUE) {
+ OMX_BOOL isInput = OMX_FALSE;
+ controlFPS(isInput);
+ }
+
+ if (pframe->ErrorInfo && (pVideoDec->bGtsTest == OMX_FALSE)) { //drop frame when this frame mark error from dec
+ if (pframe->vpumem.phy_addr > 0) {
+ VPUMemLink(&pframe->vpumem);
+ VPUFreeLinear(&pframe->vpumem);
+ }
+ goto EXIT;
+ }
+
+ bufferHeader = Rockchip_OSAL_Fd2OmxBufferHeader(pOutputPort, VPUMemGetFD(&pframe->vpumem), pframe);
+ if (bufferHeader != NULL) {
+ if (pVideoDec->bStoreMetaData == OMX_TRUE) {
+ bufferHeader->nFilledLen = bufferHeader->nAllocLen;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "nfill len %d", bufferHeader->nFilledLen);
+ } else {
+ bufferHeader->nFilledLen = pframe->DisplayHeight * pframe->DisplayWidth * 3 / 2;
+ }
+ bufferHeader->nOffset = 0;
+ if ((VPU_API_ERR)pOutput.nFlags == VPU_API_EOS_STREAM_REACHED) {
+ bufferHeader->nFlags |= OMX_BUFFERFLAG_EOS;
+ pVideoDec->bDecSendEOS = OMX_TRUE;
+ } else {
+ bufferHeader->nFlags = 0;
+ }
+ bufferHeader->nTimeStamp = pOutput.timeUs;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_OutputBufferReturn %lld", pOutput.timeUs);
+ } else {
+ VPUMemLink(&pframe->vpumem);
+ VPUFreeLinear(&pframe->vpumem);
+ Rockchip_OSAL_Free(pframe);
+ goto EXIT;
+ }
+
+ if ((bufferHeader->nFilledLen > 0) ||
+ ((bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) ||
+ (CHECK_PORT_BEING_FLUSHED(pOutputPort))) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_OutputBufferReturn");
+ Rockchip_OMX_OutputBufferReturn(pOMXComponent, bufferHeader);
+ }
+
+ ret = OMX_TRUE;
+ } else if (CHECK_PORT_BEING_FLUSHED(pOutputPort)) {
+ if (pOutput.size && (pframe->vpumem.phy_addr > 0)) {
+ VPUMemLink(&pframe->vpumem);
+ VPUFreeLinear(&pframe->vpumem);
+ Rockchip_OSAL_Free(pframe);
+ }
+ outputUseBuffer->dataLen = 0;
+ outputUseBuffer->remainDataLen = 0;
+ outputUseBuffer->nFlags = 0;
+ outputUseBuffer->timeStamp = 0;
+ ret = OMX_TRUE;
+ Rkvpu_OutputBufferReturn(pOMXComponent, outputUseBuffer);
+ } else {
+ //Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "output buffer is smaller than decoded data size Out Length");
+ //pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ // pRockchipComponent->callbackData,
+ // OMX_EventError, OMX_ErrorUndefined, 0, NULL);
+ if (pframe != NULL) {
+ Rockchip_OSAL_Free(pframe);
+ pframe = NULL;
+ }
+ ret = OMX_FALSE;
+ }
+ } else {
+ if (outputUseBuffer->dataValid == OMX_TRUE) {
+ OMX_U32 width = 0, height = 0;
+ int imageSize = 0;
+ int ret = 0;
+ DecoderOut_t pOutput;
+ VPU_FRAME pframe;
+ Rockchip_OSAL_Memset(&pOutput, 0, sizeof(DecoderOut_t));
+ Rockchip_OSAL_Memset(&pframe, 0, sizeof(VPU_FRAME));
+ pOutput.data = (unsigned char *)&pframe;
+ ret = p_vpu_ctx->decode_getframe(p_vpu_ctx, &pOutput);
+ if (ret < 0) {
+ if (ret == VPU_API_EOS_STREAM_REACHED) {
+ outputUseBuffer->dataLen = 0;
+ outputUseBuffer->remainDataLen = 0;
+ outputUseBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+ outputUseBuffer->timeStamp = 0;
+ outputUseBuffer->dataValid = OMX_FALSE;
+ ret = OMX_TRUE;
+ pVideoDec->bDecSendEOS = OMX_TRUE;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_BUFFERFLAG_EOS");
+ } else {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_DECODER ERROR");
+ pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pRockchipComponent->callbackData, OMX_EventError,
+ OUTPUT_PORT_INDEX,
+ OMX_IndexParamPortDefinition, NULL);
+ }
+ Rkvpu_OutputBufferReturn(pOMXComponent, outputUseBuffer);
+ }
+
+ if ((pOutput.size > 0) && (!CHECK_PORT_BEING_FLUSHED(pOutputPort))) {
+ if (pInputPort->portDefinition.format.video.nFrameWidth != pframe.DisplayWidth ||
+ pInputPort->portDefinition.format.video.nFrameHeight != pframe.DisplayHeight) {
+
+ pOutputPort->newCropRectangle.nWidth = pframe.DisplayWidth;
+ pOutputPort->newCropRectangle.nHeight = pframe.DisplayHeight;
+ pOutputPort->newPortDefinition.nBufferCountActual = pOutputPort->portDefinition.nBufferCountActual;
+ pOutputPort->newPortDefinition.nBufferCountMin = pOutputPort->portDefinition.nBufferCountMin;
+ pInputPort->newPortDefinition.format.video.nFrameWidth = pframe.DisplayWidth;
+ pInputPort->newPortDefinition.format.video.nFrameHeight = pframe.DisplayHeight;
+ pInputPort->newPortDefinition.format.video.nStride = pframe.DisplayWidth;
+ pInputPort->newPortDefinition.format.video.nSliceHeight = pframe.DisplayHeight;
+
+ Rkvpu_ResolutionUpdate(pOMXComponent);
+ pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pRockchipComponent->callbackData, OMX_EventPortSettingsChanged,
+ OUTPUT_PORT_INDEX,
+ OMX_IndexParamPortDefinition, NULL);
+ if (pframe.vpumem.phy_addr > 0) {
+ VPUMemLink(&pframe.vpumem);
+ VPUFreeLinear(&pframe.vpumem);
+ }
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_SET_INFO_CHANGE, NULL);
+ goto EXIT;
+
+ }
+
+ if (!pframe.vpumem.phy_addr) { /*in mpp process may be notify a null frame for info change*/
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_SET_INFO_CHANGE, NULL);
+ goto EXIT;
+ }
+
+ Rkvpu_Frame2Outbuf(pOMXComponent, outputUseBuffer->bufferHeader, &pframe);
+ outputUseBuffer->remainDataLen = pframe.DisplayHeight * pframe.DisplayWidth * 3 / 2;
+ outputUseBuffer->timeStamp = pOutput.timeUs;
+ if (VPU_API_EOS_STREAM_REACHED == (VPU_API_ERR)pOutput.nFlags) {
+ outputUseBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+ pVideoDec->bDecSendEOS = OMX_TRUE;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_BUFFERFLAG_EOS");
+ }
+ if ((outputUseBuffer->remainDataLen > 0) ||
+ ((outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) ||
+ (CHECK_PORT_BEING_FLUSHED(pOutputPort))) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_OutputBufferReturn");
+ Rkvpu_OutputBufferReturn(pOMXComponent, outputUseBuffer);
+ }
+ ret = OMX_TRUE;
+ } else if (CHECK_PORT_BEING_FLUSHED(pOutputPort)) {
+ if (pOutput.size) {
+ VPUMemLink(&pframe.vpumem);
+ VPUFreeLinear(&pframe.vpumem);
+ }
+ outputUseBuffer->dataLen = 0;
+ outputUseBuffer->remainDataLen = 0;
+ outputUseBuffer->nFlags = 0;
+ outputUseBuffer->timeStamp = 0;
+ ret = OMX_TRUE;
+ Rkvpu_OutputBufferReturn(pOMXComponent, outputUseBuffer);
+ } else {
+ //Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "output buffer is smaller than decoded data size Out Length");
+ //pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ // pRockchipComponent->callbackData,
+ // OMX_EventError, OMX_ErrorUndefined, 0, NULL);
+ ret = OMX_FALSE;
+ }
+ } else {
+ ret = OMX_FALSE;
+ }
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_InputBufferProcess(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *rockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *rockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_DATABUFFER *srcInputUseBuffer = &rockchipInputPort->way.port2WayDataBuffer.inputDataBuffer;
+ OMX_BOOL bCheckInputData = OMX_FALSE;
+ OMX_BOOL bValidCodecData = OMX_FALSE;
+
+ FunctionIn();
+
+ while (!pVideoDec->bExitBufferProcessThread) {
+ Rockchip_OSAL_SleepMillisec(0);
+ Rkvpu_Wait_ProcessPause(pRockchipComponent, INPUT_PORT_INDEX);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_Check_BufferProcess_State in");
+ while ((Rkvpu_Check_BufferProcess_State(pRockchipComponent, INPUT_PORT_INDEX)) &&
+ (!pVideoDec->bExitBufferProcessThread)) {
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_OMX_InputBufferProcess in");
+
+ if ((CHECK_PORT_BEING_FLUSHED(rockchipInputPort)) ||
+ (((ROCKCHIP_OMX_EXCEPTION_STATE)rockchipOutputPort->exceptionFlag != GENERAL_STATE) && ((ROCKCHIP_OMX_ERRORTYPE)ret == OMX_ErrorInputDataDecodeYet)))
+ break;
+
+ if (rockchipInputPort->portState != OMX_StateIdle)
+ break;
+
+ Rockchip_OSAL_MutexLock(srcInputUseBuffer->bufferMutex);
+ if ((ROCKCHIP_OMX_ERRORTYPE)ret != OMX_ErrorInputDataDecodeYet) {
+ if ((srcInputUseBuffer->dataValid != OMX_TRUE) &&
+ (!CHECK_PORT_BEING_FLUSHED(rockchipInputPort))) {
+
+ ret = Rkvpu_InputBufferGetQueue(pRockchipComponent);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
+ break;
+ }
+ }
+
+ if (srcInputUseBuffer->dataValid == OMX_TRUE) {
+ if (Rkvpu_SendInputData(hComponent) != OMX_TRUE) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "stream list is full");
+ Rockchip_OSAL_SleepMillisec(5);
+ }
+ }
+ if (CHECK_PORT_BEING_FLUSHED(rockchipInputPort)) {
+ Rockchip_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
+ break;
+ }
+ }
+ Rockchip_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
+ if ((ROCKCHIP_OMX_ERRORTYPE)ret == OMX_ErrorCodecInit)
+ pVideoDec->bExitBufferProcessThread = OMX_TRUE;
+ }
+ }
+
+EXIT:
+
+ FunctionOut();
+
+ return ret;
+}
+
+
+OMX_ERRORTYPE Rkvpu_OMX_OutputBufferProcess(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *rockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_DATABUFFER *dstOutputUseBuffer = &rockchipOutputPort->way.port2WayDataBuffer.outputDataBuffer;
+
+ FunctionIn();
+
+ while (!pVideoDec->bExitBufferProcessThread) {
+ Rockchip_OSAL_SleepMillisec(0);
+ Rkvpu_Wait_ProcessPause(pRockchipComponent, OUTPUT_PORT_INDEX);
+
+ while ((Rkvpu_Check_BufferProcess_State(pRockchipComponent, OUTPUT_PORT_INDEX)) &&
+ (!pVideoDec->bExitBufferProcessThread)) {
+
+ if (CHECK_PORT_BEING_FLUSHED(rockchipOutputPort))
+ break;
+
+ Rockchip_OSAL_MutexLock(dstOutputUseBuffer->bufferMutex);
+ if ((dstOutputUseBuffer->dataValid != OMX_TRUE) &&
+ (!CHECK_PORT_BEING_FLUSHED(rockchipOutputPort))) {
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_OutputBufferGetQueue");
+ ret = Rkvpu_OutputBufferGetQueue(pRockchipComponent);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_MutexUnlock(dstOutputUseBuffer->bufferMutex);
+ break;
+ }
+ }
+
+ if (dstOutputUseBuffer->dataValid == OMX_TRUE) {
+ if (Rkvpu_Post_OutputFrame(pOMXComponent) != OMX_TRUE) {
+ Rockchip_OSAL_SleepMillisec(8);
+ }
+ }
+
+ /* reset outputData */
+ Rockchip_OSAL_MutexUnlock(dstOutputUseBuffer->bufferMutex);
+ }
+ }
+
+EXIT:
+
+ FunctionOut();
+
+ return ret;
+}
+
+static OMX_ERRORTYPE Rkvpu_OMX_InputProcessThread(OMX_PTR threadData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+
+ FunctionIn();
+
+ if (threadData == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ Rkvpu_OMX_InputBufferProcess(pOMXComponent);
+
+ Rockchip_OSAL_ThreadExit(NULL);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+static OMX_ERRORTYPE Rkvpu_OMX_OutputProcessThread(OMX_PTR threadData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+
+ FunctionIn();
+
+ if (threadData == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ Rkvpu_OMX_OutputBufferProcess(pOMXComponent);
+
+ Rockchip_OSAL_ThreadExit(NULL);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_BufferProcess_Create(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ FunctionIn();
+
+ pVideoDec->bExitBufferProcessThread = OMX_FALSE;
+
+ ret = Rockchip_OSAL_ThreadCreate(&pVideoDec->hOutputThread,
+ Rkvpu_OMX_OutputProcessThread,
+ pOMXComponent);
+
+ if (ret == OMX_ErrorNone)
+ ret = Rockchip_OSAL_ThreadCreate(&pVideoDec->hInputThread,
+ Rkvpu_OMX_InputProcessThread,
+ pOMXComponent);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_BufferProcess_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ OMX_S32 countValue = 0;
+ unsigned int i = 0;
+
+ FunctionIn();
+
+ pVideoDec->bExitBufferProcessThread = OMX_TRUE;
+
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].bufferSemID, &countValue);
+ if (countValue == 0)
+ Rockchip_OSAL_SemaphorePost(pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].bufferSemID);
+
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].pauseEvent);
+ Rockchip_OSAL_ThreadTerminate(pVideoDec->hInputThread);
+ pVideoDec->hInputThread = NULL;
+
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX].bufferSemID, &countValue);
+ if (countValue == 0)
+ Rockchip_OSAL_SemaphorePost(pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX].bufferSemID);
+
+
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].pauseEvent);
+
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX].pauseEvent);
+ Rockchip_OSAL_ThreadTerminate(pVideoDec->hOutputThread);
+ pVideoDec->hOutputThread = NULL;
+
+ pRockchipComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
+ pRockchipComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE omx_open_vpudec_context(RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec)
+{
+ pVideoDec->rkapi_hdl = dlopen("/system/lib/libvpu.so", RTLD_LAZY);
+ pVideoDec->bOld_api = OMX_FALSE;
+ if (pVideoDec->rkapi_hdl == NULL) {
+ return OMX_ErrorHardware;
+ }
+ pVideoDec->rkvpu_open_cxt = (OMX_S32 (*)(VpuCodecContext_t **ctx))dlsym(pVideoDec->rkapi_hdl, "vpu_open_context");
+ if (pVideoDec->rkvpu_open_cxt == NULL) {
+ dlclose(pVideoDec->rkapi_hdl);
+ pVideoDec->rkapi_hdl = NULL;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_DEBUG, "used old version lib");
+ pVideoDec->rkapi_hdl = dlopen("/system/lib/librk_vpuapi.so", RTLD_LAZY);
+ if (pVideoDec->rkapi_hdl == NULL) {
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "dll open fail system/lib/librk_vpuapi.so");
+ return OMX_ErrorHardware;
+ }
+ pVideoDec->rkvpu_open_cxt = (OMX_S32 (*)(VpuCodecContext_t **ctx))dlsym(pVideoDec->rkapi_hdl, "vpu_open_context");
+
+ if (pVideoDec->rkvpu_open_cxt == NULL) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "dlsym vpu_open_context fail");
+ dlclose( pVideoDec->rkapi_hdl);
+ return OMX_ErrorHardware;
+ }
+ pVideoDec->bOld_api = OMX_TRUE;
+ }
+ pVideoDec->rkvpu_close_cxt = (OMX_S32 (*)(VpuCodecContext_t **ctx))dlsym(pVideoDec->rkapi_hdl, "vpu_close_context");
+ return OMX_ErrorNone;
+}
+OMX_ERRORTYPE Rkvpu_Dec_ComponentInit(OMX_COMPONENTTYPE *pOMXComponent)
+{
+
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ OMX_RK_VIDEO_CODINGTYPE codecId = OMX_RK_VIDEO_CodingUnused;
+ ROCKCHIP_OMX_BASEPORT *pRockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ VpuCodecContext_t *p_vpu_ctx = (VpuCodecContext_t *)Rockchip_OSAL_Malloc(sizeof(VpuCodecContext_t));
+ if (pRockchipComponent->rkversion != NULL) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "omx decoder info : %s",pRockchipComponent->rkversion);
+ }
+ Rockchip_OSAL_Memset((void*)p_vpu_ctx, 0, sizeof(VpuCodecContext_t));
+ if (omx_open_vpudec_context(pVideoDec)) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ {
+ int32_t kNumMapEntries = sizeof(kCodeMap) / sizeof(kCodeMap[0]);
+ int i = 0;
+ for (i = 0; i < kNumMapEntries; i++) {
+ if (kCodeMap[i].omx_id == pVideoDec->codecId) {
+ codecId = kCodeMap[i].codec_id;
+ break;
+ }
+ }
+ }
+
+ if (pVideoDec->bOld_api == OMX_FALSE) {
+ p_vpu_ctx->width = pRockchipInputPort->portDefinition.format.video.nFrameWidth;
+ p_vpu_ctx->height = pRockchipInputPort->portDefinition.format.video.nFrameHeight;
+ p_vpu_ctx->codecType = CODEC_DECODER;
+
+ p_vpu_ctx->videoCoding = codecId;
+ } else {
+ Rockchip_OSAL_Free(p_vpu_ctx);
+ p_vpu_ctx = NULL;
+ }
+
+ if ( pVideoDec->rkvpu_open_cxt != NULL) {
+ pVideoDec->rkvpu_open_cxt(&p_vpu_ctx);
+ }
+
+ if (p_vpu_ctx == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ p_vpu_ctx->enableparsing = 1;
+ p_vpu_ctx->width = pRockchipInputPort->portDefinition.format.video.nFrameWidth;
+ p_vpu_ctx->height = pRockchipInputPort->portDefinition.format.video.nFrameHeight;
+ p_vpu_ctx->codecType = CODEC_DECODER;
+
+
+ p_vpu_ctx->videoCoding = codecId;
+ pVideoDec->vpu_ctx = p_vpu_ctx;
+
+ pVideoDec->bFirstFrame = OMX_TRUE;
+ pVideoDec->maxCount = 0;
+ if (rga_dev_open(&pVideoDec->rga_ctx) < 0) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "open rga device fail!");
+ }
+
+ if (Rkvpu_OMX_CheckIsNeedFastmode(pRockchipComponent) != OMX_ErrorNone) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "check fast mode failed!");
+ }
+ /*
+ ** if current stream is Div3, tell VPU_API of on2 decoder to
+ ** config hardware as Div3.
+ */
+ /* if (pVideoDec->flags & RKVPU_OMX_VDEC_IS_DIV3) {
+ p_vpu_ctx->videoCoding = OMX_RK_VIDEO_CodingDIVX3;
+ }*/
+
+ Rkvpu_OMX_DebugSwitchfromPropget(pRockchipComponent);
+
+#ifdef WRITR_FILE
+ pVideoDec->fp_out = fopen("data/video/dec_out.yuv", "wb");
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pRockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+
+ int i, plane;
+ FunctionIn();
+ if (pVideoDec && pVideoDec->vpu_ctx) {
+ if (pVideoDec->rkvpu_close_cxt) {
+ pVideoDec->rkvpu_close_cxt(&pVideoDec->vpu_ctx);
+ }
+ pVideoDec->vpu_ctx = NULL;
+ if (pVideoDec->rkapi_hdl) {
+ dlclose(pVideoDec->rkapi_hdl);
+ pVideoDec->rkapi_hdl = NULL;
+ }
+ }
+
+ if (pVideoDec->rga_ctx != NULL) {
+ rga_dev_close(pVideoDec->rga_ctx);
+ pVideoDec->rga_ctx = NULL;
+ }
+#if 1
+ Rockchip_OSAL_Closevpumempool(pRockchipComponent);
+#endif
+ Rkvpu_ResetAllPortConfig(pOMXComponent);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+
+OMX_ERRORTYPE Rockchip_OMX_ComponentConstructor(OMX_HANDLETYPE hComponent, OMX_STRING componentName)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
+
+ FunctionIn();
+
+ if ((hComponent == NULL) || (componentName == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ ret = Rockchip_OMX_BaseComponent_Constructor(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ ret = Rockchip_OMX_Port_Constructor(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OMX_BaseComponent_Destructor(pOMXComponent);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ pVideoDec = Rockchip_OSAL_Malloc(sizeof(RKVPU_OMX_VIDEODEC_COMPONENT));
+ if (pVideoDec == NULL) {
+ Rockchip_OMX_BaseComponent_Destructor(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ Rockchip_OSAL_Memset(pVideoDec, 0, sizeof(RKVPU_OMX_VIDEODEC_COMPONENT));
+
+ pRockchipComponent->componentName = (OMX_STRING)Rockchip_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE);
+ if (pRockchipComponent->componentName == NULL) {
+ Rockchip_OMX_ComponentDeInit(hComponent);
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ Rockchip_OSAL_Memset(pRockchipComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE);
+ pVideoDec->bReconfigDPB = OMX_FALSE;
+ pRockchipComponent->hComponentHandle = (OMX_HANDLETYPE)pVideoDec;
+
+ pRockchipComponent->bSaveFlagEOS = OMX_FALSE;
+ pRockchipComponent->nRkFlags = 0;
+ pRockchipComponent->bBehaviorEOS = OMX_FALSE;
+ pVideoDec->bDecSendEOS = OMX_FALSE;
+ pVideoDec->bPvr_Flag = OMX_FALSE;
+ pVideoDec->bFastMode = OMX_FALSE;
+ pVideoDec->bPrintFps = OMX_FALSE;
+ pVideoDec->bPrintBufferPosition = OMX_FALSE;
+ pVideoDec->bGtsTest = OMX_FALSE;
+ pVideoDec->fp_in = NULL;
+ pRockchipComponent->bMultiThreadProcess = OMX_TRUE;
+ pRockchipComponent->codecType = HW_VIDEO_DEC_CODEC;
+
+ pVideoDec->bFirstFrame = OMX_TRUE;
+
+ pVideoDec->vpumem_handle = NULL;
+
+ /* Set componentVersion */
+ pRockchipComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
+ pRockchipComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
+ pRockchipComponent->componentVersion.s.nRevision = REVISION_NUMBER;
+ pRockchipComponent->componentVersion.s.nStep = STEP_NUMBER;
+ /* Set specVersion */
+ pRockchipComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
+ pRockchipComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
+ pRockchipComponent->specVersion.s.nRevision = REVISION_NUMBER;
+ pRockchipComponent->specVersion.s.nStep = STEP_NUMBER;
+ /* Input port */
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ pRockchipPort->portDefinition.nBufferCountActual = MAX_VIDEO_INPUTBUFFER_NUM;
+ pRockchipPort->portDefinition.nBufferCountMin = MAX_VIDEO_INPUTBUFFER_NUM;
+ pRockchipPort->portDefinition.nBufferSize = 0;
+ pRockchipPort->portDefinition.eDomain = OMX_PortDomainVideo;
+ pRockchipPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
+ pRockchipPort->portDefinition.format.video.nFrameHeight = DEFAULT_FRAME_HEIGHT;
+ pRockchipPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/
+ pRockchipPort->portDefinition.format.video.nSliceHeight = 0;
+ pRockchipPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+
+ pRockchipPort->portDefinition.format.video.cMIMEType = Rockchip_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ pRockchipPort->portDefinition.format.video.pNativeRender = 0;
+ pRockchipPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pRockchipPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+ pRockchipPort->portDefinition.bEnabled = OMX_TRUE;
+ pRockchipPort->portWayType = WAY2_PORT;
+
+ /* Output port */
+ pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ pRockchipPort->portDefinition.nBufferCountActual = MAX_VIDEO_OUTPUTBUFFER_NUM;
+ pRockchipPort->portDefinition.nBufferCountMin = MAX_VIDEO_OUTPUTBUFFER_NUM;
+ pRockchipPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
+ pRockchipPort->portDefinition.eDomain = OMX_PortDomainVideo;
+ pRockchipPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
+ pRockchipPort->portDefinition.format.video.nFrameHeight = DEFAULT_FRAME_HEIGHT;
+ pRockchipPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/
+ pRockchipPort->portDefinition.format.video.nSliceHeight = 0;
+ pRockchipPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+
+ pRockchipPort->portDefinition.format.video.cMIMEType = Rockchip_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "raw/video");
+ pRockchipPort->portDefinition.format.video.pNativeRender = 0;
+ pRockchipPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pRockchipPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ pRockchipPort->portDefinition.bEnabled = OMX_TRUE;
+ pRockchipPort->portWayType = WAY2_PORT;
+ pRockchipPort->portDefinition.eDomain = OMX_PortDomainVideo;
+ pRockchipPort->bufferProcessType = BUFFER_COPY | BUFFER_ANBSHARE;
+
+ pRockchipPort->processData.extInfo = (OMX_PTR)Rockchip_OSAL_Malloc(sizeof(DECODE_CODEC_EXTRA_BUFFERINFO));
+ Rockchip_OSAL_Memset(((char *)pRockchipPort->processData.extInfo), 0, sizeof(DECODE_CODEC_EXTRA_BUFFERINFO));
+ {
+ int i = 0;
+ DECODE_CODEC_EXTRA_BUFFERINFO *pBufferInfo = NULL;
+ pBufferInfo = (DECODE_CODEC_EXTRA_BUFFERINFO *)(pRockchipPort->processData.extInfo);
+ }
+ pOMXComponent->UseBuffer = &Rkvpu_OMX_UseBuffer;
+ pOMXComponent->AllocateBuffer = &Rkvpu_OMX_AllocateBuffer;
+ pOMXComponent->FreeBuffer = &Rkvpu_OMX_FreeBuffer;
+ pOMXComponent->ComponentTunnelRequest = &Rkvpu_OMX_ComponentTunnelRequest;
+ pOMXComponent->GetParameter = &Rkvpu_OMX_GetParameter;
+ pOMXComponent->SetParameter = &Rkvpu_OMX_SetParameter;
+ pOMXComponent->GetConfig = &Rkvpu_OMX_GetConfig;
+ pOMXComponent->SetConfig = &Rkvpu_OMX_SetConfig;
+ pOMXComponent->GetExtensionIndex = &Rkvpu_OMX_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &Rkvpu_OMX_ComponentRoleEnum;
+ pOMXComponent->ComponentDeInit = &Rockchip_OMX_ComponentDeInit;
+
+ pRockchipComponent->rockchip_codec_componentInit = &Rkvpu_Dec_ComponentInit;
+ pRockchipComponent->rockchip_codec_componentTerminate = &Rkvpu_Dec_Terminate;
+
+ pRockchipComponent->rockchip_AllocateTunnelBuffer = &Rkvpu_OMX_AllocateTunnelBuffer;
+ pRockchipComponent->rockchip_FreeTunnelBuffer = &Rkvpu_OMX_FreeTunnelBuffer;
+ pRockchipComponent->rockchip_BufferProcessCreate = &Rkvpu_OMX_BufferProcess_Create;
+ pRockchipComponent->rockchip_BufferProcessTerminate = &Rkvpu_OMX_BufferProcess_Terminate;
+ pRockchipComponent->rockchip_BufferFlush = &Rkvpu_OMX_BufferFlush;
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ if (!strcmp(componentName, RK_OMX_COMPONENT_H264_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/avc");
+ pVideoDec->codecId = OMX_VIDEO_CodingAVC;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
+
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_H264_DRM_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/avc");
+ pVideoDec->codecId = OMX_VIDEO_CodingAVC;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
+
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_MPEG4_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/mp4v-es");
+ pVideoDec->codecId = OMX_VIDEO_CodingMPEG4;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_H263_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/3gpp");
+ pVideoDec->codecId = OMX_VIDEO_CodingH263;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_FLV_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/flv");
+ pVideoDec->codecId = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingFLV1;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingFLV1;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_MPEG2_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/mpeg2");
+ pVideoDec->codecId = OMX_VIDEO_CodingMPEG2;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG2;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_RMVB_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/vnd.rn-realvideo");
+ pVideoDec->codecId = OMX_VIDEO_CodingRV;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingRV;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_VP8_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/x-vnd.on2.vp8");
+ pVideoDec->codecId = OMX_VIDEO_CodingVP8;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = pVideoDec->codecId = OMX_VIDEO_CodingVP8;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_VC1_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/vc1");
+ pVideoDec->codecId = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVC1;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVC1;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_WMV3_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/x-ms-wmv");
+ pVideoDec->codecId = OMX_VIDEO_CodingWMV;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingWMV;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_VP6_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/vp6");
+ pVideoDec->codecId = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP6;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP6;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_HEVC_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/hevc");
+ pVideoDec->codecId = OMX_VIDEO_CodingHEVC;
+#ifndef LOW_VRESION
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingHEVC;
+#else
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_OLD_CodingHEVC;
+#endif
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_MJPEG_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/mjpeg");
+ pVideoDec->codecId = OMX_VIDEO_CodingMJPEG;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMJPEG;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_VP9_DEC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/vp9");
+ pVideoDec->codecId = OMX_VIDEO_CodingVP9;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingVP9;
+ } else {
+ // IL client specified an invalid component name
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "VPU Component Invalid Component Name\n");
+ ret = OMX_ErrorInvalidComponentName;
+ goto EXIT;
+ }
+ {
+ int gpu_fd = -1;
+ gpu_fd = open("/dev/pvrsrvkm", O_RDWR, 0);
+ if (gpu_fd > 0) {
+ pVideoDec->bPvr_Flag = OMX_TRUE;
+ close(gpu_fd);
+ }
+ }
+ pRockchipComponent->currentState = OMX_StateLoaded;
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_ComponentDeInit(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
+ int i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+// Rockchip_OSAL_RefANB_Terminate(pVideoDec->hRefHandle);
+ if (pVideoDec->fp_in != NULL) {
+ fclose(pVideoDec->fp_in);
+ }
+
+ Rockchip_OSAL_Free(pVideoDec);
+ pRockchipComponent->hComponentHandle = pVideoDec = NULL;
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ if (pRockchipPort->processData.extInfo != NULL) {
+ Rockchip_OSAL_Free(pRockchipPort->processData.extInfo);
+ pRockchipPort->processData.extInfo = NULL;
+ }
+
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[i];
+ Rockchip_OSAL_Free(pRockchipPort->portDefinition.format.video.cMIMEType);
+ pRockchipPort->portDefinition.format.video.cMIMEType = NULL;
+ }
+
+ ret = Rockchip_OMX_Port_Destructor(pOMXComponent);
+
+ ret = Rockchip_OMX_BaseComponent_Destructor(hComponent);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/component/video/dec/Rkvpu_OMX_Vdec.h b/component/video/dec/Rkvpu_OMX_Vdec.h
new file mode 100755
index 0000000..f58325b
--- /dev/null
+++ b/component/video/dec/Rkvpu_OMX_Vdec.h
@@ -0,0 +1,168 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rkvpu_OMX_Vdec.h
+ * @brief
+ * @author Csy (csy@rock-chips.com)
+
+ * @version 1.0.0
+ * @history
+ * 2013.11.28 : Create
+ */
+
+#ifndef Rkvpu_OMX_VIDEO_DECODE
+#define Rkvpu_OMX_VIDEO_DECODE
+
+#include "OMX_Component.h"
+#include "Rockchip_OMX_Def.h"
+#include "Rockchip_OSAL_Queue.h"
+#include "Rockchip_OMX_Baseport.h"
+#include "Rockchip_OMX_Basecomponent.h"
+#include "OMX_Video.h"
+#include "vpu_api.h"
+
+#define MAX_VIDEO_INPUTBUFFER_NUM 4
+#define MAX_VIDEO_OUTPUTBUFFER_NUM 2
+
+#define DEFAULT_FRAME_WIDTH 1920
+#define DEFAULT_FRAME_HEIGHT 1080
+
+#define DEFAULT_VIDEO_INPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT)/2
+#define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2
+
+#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 1
+
+//#define WRITR_FILE
+
+typedef struct {
+ void *pAddrY;
+ void *pAddrC;
+} CODEC_DEC_ADDR_INFO;
+
+typedef struct _CODEC_DEC_BUFFER {
+ void *pVirAddr[MAX_BUFFER_PLANE]; /* virtual address */
+ int bufferSize[MAX_BUFFER_PLANE]; /* buffer alloc size */
+ int fd[MAX_BUFFER_PLANE]; /* buffer FD */
+ int dataSize; /* total data length */
+} CODEC_DEC_BUFFER;
+
+typedef struct _DECODE_CODEC_EXTRA_BUFFERINFO {
+ /* For Decode Output */
+ OMX_U32 imageWidth;
+ OMX_U32 imageHeight;
+ OMX_COLOR_FORMATTYPE ColorFormat;
+ //PrivateDataShareBuffer PDSB;
+} DECODE_CODEC_EXTRA_BUFFERINFO;
+
+
+typedef enum _RKVPU_OMX_VDEC_FLAG_MAP {
+ RKVPU_OMX_VDEC_NONE = 0,
+ RKVPU_OMX_VDEC_IS_DIV3 = 0x01,
+ RKVPU_OMX_VDEC_USE_DTS = 0x02,
+ RKVPU_OMX_VDEC_THUMBNAIL = 0x04,
+ RKVPU_OMX_VDEC_BUTT,
+} RKVPU_OMX_VDEC_FLAG_MAP;
+
+typedef struct _RKVPU_OMX_VIDEODEC_COMPONENT {
+ OMX_HANDLETYPE hCodecHandle;
+ OMX_BOOL bThumbnailMode;
+ OMX_BOOL bFirstFrame;
+ OMX_VIDEO_PARAM_AVCTYPE AVCComponent[ALL_PORT_NUM];
+
+ /* Buffer Process */
+ OMX_BOOL bExitBufferProcessThread;
+ OMX_HANDLETYPE hInputThread;
+ OMX_HANDLETYPE hOutputThread;
+
+ OMX_VIDEO_CODINGTYPE codecId;
+
+ /* Shared Memory Handle */
+ OMX_HANDLETYPE hSharedMemory;
+
+ /* For DRM Play */
+ OMX_BOOL bDRMPlayerMode;
+
+ /* For Reconfiguration DPB */
+ OMX_BOOL bReconfigDPB;
+
+ /* CSC handle */
+ OMX_PTR csc_handle;
+ OMX_U32 csc_set_format;
+
+ OMX_HANDLETYPE hRefHandle;
+
+ VpuCodecContext_t *vpu_ctx;
+ OMX_U32 flags;
+
+ OMX_BOOL bIsANBEnabled;
+
+ void *rga_ctx;
+
+ OMX_BOOL bDecSendEOS;
+
+ OMX_BOOL bStoreMetaData;
+ OMX_BOOL bPvr_Flag;
+ OMX_PTR vpumem_handle;
+ OMX_U32 maxCount; // when buffer in AL big than 8,if max timeout no consume we continue send one buffer to AL
+ OMX_BOOL bOld_api;
+ /* For vpu control */
+ OMX_BOOL bFastMode;
+ OMX_RK_EXT_COLORSPACE extColorSpace;
+ OMX_RK_EXT_DYNCRANGE extDyncRange;
+
+#ifdef WRITR_FILE
+ FILE *fp_out;
+#endif
+ /* For debug */
+ FILE *fp_in;
+ OMX_BOOL bPrintFps;
+ OMX_BOOL bPrintBufferPosition;
+ OMX_BOOL bGtsTest;
+ void *rkapi_hdl;
+
+ OMX_S32 (*rkvpu_open_cxt)(VpuCodecContext_t **ctx);
+ OMX_S32 (*rkvpu_close_cxt)(VpuCodecContext_t **ctx);
+
+ OMX_ERRORTYPE (*Rkvpu_codec_srcInputProcess) (OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATA *pInputData);
+ OMX_ERRORTYPE (*Rkvpu_codec_srcOutputProcess) (OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATA *pInputData);
+ OMX_ERRORTYPE (*Rkvpu_codec_dstInputProcess) (OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATA *pOutputData);
+ OMX_ERRORTYPE (*Rkvpu_codec_dstOutputProcess) (OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATA *pOutputData);
+
+} RKVPU_OMX_VIDEODEC_COMPONENT;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int calc_plane(int width, int height);
+void UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent);
+OMX_BOOL Rkvpu_Check_BufferProcess_State(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 nPortIndex);
+
+OMX_ERRORTYPE Rkvpu_OMX_InputBufferProcess(OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE Rkvpu_OMX_OutputBufferProcess(OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE Rkvpu_Dec_ComponentInit(OMX_COMPONENTTYPE *pOMXComponent);
+OMX_ERRORTYPE Rkvpu_Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent);
+
+OMX_ERRORTYPE Rockchip_OMX_ComponentConstructor(OMX_HANDLETYPE hComponent, OMX_STRING componentName);
+OMX_ERRORTYPE Rockchip_OMX_ComponentDeInit(OMX_HANDLETYPE hComponent);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/component/video/dec/Rkvpu_OMX_VdecControl.c b/component/video/dec/Rkvpu_OMX_VdecControl.c
new file mode 100755
index 0000000..434e66d
--- /dev/null
+++ b/component/video/dec/Rkvpu_OMX_VdecControl.c
@@ -0,0 +1,1987 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rkvpu_OMX_VdecControl.c
+ * @brief
+ * @author csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.28 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <poll.h>
+#include<sys/ioctl.h>
+#include <unistd.h>
+
+#include "Rockchip_OMX_Macros.h"
+#include "Rockchip_OSAL_Event.h"
+#include "Rkvpu_OMX_Vdec.h"
+#include "Rkvpu_OMX_VdecControl.h"
+#include "Rockchip_OSAL_RGA_Process.h"
+#include "Rockchip_OMX_Basecomponent.h"
+#include "Rockchip_OSAL_Thread.h"
+#include "Rockchip_OSAL_Semaphore.h"
+#include "Rockchip_OSAL_Mutex.h"
+#include "Rockchip_OSAL_ETC.h"
+#include "Rockchip_OSAL_Queue.h"
+#include <hardware/hardware.h>
+#include "hardware/rga.h"
+#include "vpu.h"
+
+
+//#include <vpu_mem_pool.h>
+
+//#include "csc.h"
+
+#ifdef USE_ANB
+#include "Rockchip_OSAL_Android.h"
+#endif
+
+#undef ROCKCHIP_LOG_TAG
+#define ROCKCHIP_LOG_TAG "ROCKCHIP_VIDEO_DECCONTROL"
+#define ROCKCHIP_LOG_OFF
+//#define ROCKCHIP_TRACE_ON
+#include "Rockchip_OSAL_Log.h"
+
+typedef struct {
+ OMX_U32 mProfile;
+ OMX_U32 mLevel;
+} CodecProfileLevel;
+static const CodecProfileLevel kM4VProfileLevels[] = {
+ { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0 },
+ { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0b},
+ { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1 },
+ { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level2 },
+ { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level3 },
+};
+static const CodecProfileLevel kH263ProfileLevels[] = {
+ { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10 },
+ { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level20 },
+ { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level30 },
+ { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level45 },
+ { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level10 },
+ { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level20 },
+ { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level30 },
+ { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level45 },
+};
+static const CodecProfileLevel kH264ProfileLevels[] = {
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1b },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel11 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel12 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel2 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel21 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel22 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel3 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel32 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel41 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel42 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel5 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel51 },
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1b},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel11},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel12},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel13},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel2},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel21},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel22},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel3},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel31},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel32},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel41},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel42},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel5},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel51},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1b},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel11},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel12},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel13},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel2},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel21},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel22},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel3},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel41},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel42},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel5},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel51},
+};
+
+static const CodecProfileLevel kH265ProfileLevels[] = {
+ { OMX_VIDEO_HEVCProfileMain, OMX_VIDEO_HEVCMainTierLevel1 },
+ { OMX_VIDEO_HEVCProfileMain, OMX_VIDEO_HEVCMainTierLevel2 },
+ { OMX_VIDEO_HEVCProfileMain, OMX_VIDEO_HEVCMainTierLevel21 },
+ { OMX_VIDEO_HEVCProfileMain, OMX_VIDEO_HEVCMainTierLevel3 },
+ { OMX_VIDEO_HEVCProfileMain, OMX_VIDEO_HEVCMainTierLevel31 },
+ { OMX_VIDEO_HEVCProfileMain, OMX_VIDEO_HEVCMainTierLevel4 },
+ { OMX_VIDEO_HEVCProfileMain, OMX_VIDEO_HEVCMainTierLevel41 },
+ { OMX_VIDEO_HEVCProfileMain, OMX_VIDEO_HEVCMainTierLevel5 },
+ { OMX_VIDEO_HEVCProfileMain, OMX_VIDEO_HEVCMainTierLevel51 },
+};
+
+
+OMX_ERRORTYPE Rkvpu_OMX_UseBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes,
+ OMX_IN OMX_U8 *pBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ OMX_U32 i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[nPortIndex];
+ if (nPortIndex >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ if (pRockchipPort->portState != OMX_StateIdle) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ if (CHECK_PORT_TUNNELED(pRockchipPort) && CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Rockchip_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
+ if (temp_bufferHeader == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ Rockchip_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
+
+ for (i = 0; i < pRockchipPort->portDefinition.nBufferCountActual; i++) {
+ if (pRockchipPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
+ pRockchipPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader;
+ pRockchipPort->extendBufferHeader[i].pRegisterFlag = 0;
+ pRockchipPort->extendBufferHeader[i].pPrivate = NULL;
+ pRockchipPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED);
+ INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
+ temp_bufferHeader->pBuffer = pBuffer;
+ temp_bufferHeader->nAllocLen = nSizeBytes;
+ temp_bufferHeader->pAppPrivate = pAppPrivate;
+ if (nPortIndex == INPUT_PORT_INDEX)
+ temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
+ else {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "bufferHeader[%d] = 0x%x ", i, temp_bufferHeader);
+ temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
+ }
+
+ pRockchipPort->assignedBufferNum++;
+ if (pRockchipPort->assignedBufferNum == pRockchipPort->portDefinition.nBufferCountActual) {
+ pRockchipPort->portDefinition.bPopulated = OMX_TRUE;
+ /* Rockchip_OSAL_MutexLock(pRockchipPort->compMutex); */
+ Rockchip_OSAL_SemaphorePost(pRockchipPort->loadedResource);
+ /* Rockchip_OSAL_MutexUnlock(pRockchipPort->compMutex); */
+ }
+ *ppBufferHdr = temp_bufferHeader;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ }
+
+ Rockchip_OSAL_Free(temp_bufferHeader);
+ ret = OMX_ErrorInsufficientResources;
+
+EXIT:
+ FunctionOut();
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_OMX_UseBuffer in ret = 0x%x", ret);
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_AllocateBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ OMX_U8 *temp_buffer = NULL;
+ int temp_buffer_fd = -1;
+ OMX_U32 i = 0;
+ MEMORY_TYPE mem_type = NORMAL_MEMORY;
+
+ FunctionIn();
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Rkvpu_OMX_AllocateBuffer in");
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[nPortIndex];
+ if (nPortIndex >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ /*
+ if (pRockchipPort->portState != OMX_StateIdle ) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ */
+ if (CHECK_PORT_TUNNELED(pRockchipPort) && CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+#if 0
+ if ((pVideoDec->bDRMPlayerMode == OMX_TRUE) && (nPortIndex == INPUT_PORT_INDEX)) {
+ mem_type = SECURE_MEMORY;
+ } else if (pRockchipPort->bufferProcessType == BUFFER_SHARE) {
+ mem_type = NORMAL_MEMORY;
+ } else {
+ mem_type = SYSTEM_MEMORY;
+ }
+
+ temp_buffer = Rockchip_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nSizeBytes, mem_type);
+ if (temp_buffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ temp_buffer_fd = Rockchip_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, temp_buffer);
+#endif
+ temp_buffer = (OMX_U8 *)Rockchip_OSAL_Malloc(nSizeBytes);
+ if (temp_buffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Rockchip_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
+ if (temp_bufferHeader == NULL) {
+ Rockchip_OSAL_Free(temp_buffer);
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ Rockchip_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
+
+ for (i = 0; i < pRockchipPort->portDefinition.nBufferCountActual; i++) {
+ if (pRockchipPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
+ pRockchipPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader;
+ pRockchipPort->extendBufferHeader[i].buf_fd[0] = temp_buffer_fd;
+ pRockchipPort->bufferStateAllocate[i] = (BUFFER_STATE_ALLOCATED | HEADER_STATE_ALLOCATED);
+ INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
+ if (mem_type == SECURE_MEMORY)
+ ;//temp_bufferHeader->pBuffer = temp_buffer_fd;
+ else
+ temp_bufferHeader->pBuffer = temp_buffer;
+ temp_bufferHeader->nAllocLen = nSizeBytes;
+ temp_bufferHeader->pAppPrivate = pAppPrivate;
+ if (nPortIndex == INPUT_PORT_INDEX)
+ temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
+ else
+ temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
+ pRockchipPort->assignedBufferNum++;
+ if (pRockchipPort->assignedBufferNum == pRockchipPort->portDefinition.nBufferCountActual) {
+ pRockchipPort->portDefinition.bPopulated = OMX_TRUE;
+ /* Rockchip_OSAL_MutexLock(pRockchipComponent->compMutex); */
+ Rockchip_OSAL_SemaphorePost(pRockchipPort->loadedResource);
+ /* Rockchip_OSAL_MutexUnlock(pRockchipComponent->compMutex); */
+ }
+ *ppBuffer = temp_bufferHeader;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ }
+
+ Rockchip_OSAL_Free(temp_bufferHeader);
+ Rockchip_OSAL_Free(temp_buffer);
+
+ ret = OMX_ErrorInsufficientResources;
+
+EXIT:
+ FunctionOut();
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Rkvpu_OMX_AllocateBuffer in ret = 0x%x", ret);
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_FreeBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ OMX_U8 *temp_buffer = NULL;
+ OMX_U32 i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ pRockchipPort = &pRockchipComponent->pRockchipPort[nPortIndex];
+
+ if (CHECK_PORT_TUNNELED(pRockchipPort) && CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ if ((pRockchipPort->portState != OMX_StateLoaded) && (pRockchipPort->portState != OMX_StateInvalid)) {
+ (*(pRockchipComponent->pCallbacks->EventHandler)) (pOMXComponent,
+ pRockchipComponent->callbackData,
+ (OMX_U32)OMX_EventError,
+ (OMX_U32)OMX_ErrorPortUnpopulated,
+ nPortIndex, NULL);
+ }
+
+ for (i = 0; i < /*pRockchipPort->portDefinition.nBufferCountActual*/MAX_BUFFER_NUM; i++) {
+ if (((pRockchipPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pRockchipPort->extendBufferHeader[i].OMXBufferHeader != NULL)) {
+ if (pRockchipPort->extendBufferHeader[i].OMXBufferHeader->pBuffer == pBufferHdr->pBuffer) {
+ if (pRockchipPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) {
+ Rockchip_OSAL_Free(pRockchipPort->extendBufferHeader[i].OMXBufferHeader->pBuffer);
+ pRockchipPort->extendBufferHeader[i].OMXBufferHeader->pBuffer = NULL;
+ pBufferHdr->pBuffer = NULL;
+ } else if (pRockchipPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) {
+ ; /* None*/
+ }
+ pRockchipPort->assignedBufferNum--;
+ if (pRockchipPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) {
+ Rockchip_OSAL_Free(pRockchipPort->extendBufferHeader[i].OMXBufferHeader);
+ pRockchipPort->extendBufferHeader[i].OMXBufferHeader = NULL;
+ pBufferHdr = NULL;
+ }
+ pRockchipPort->bufferStateAllocate[i] = BUFFER_STATE_FREE;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ }
+ }
+
+EXIT:
+ if (ret == OMX_ErrorNone) {
+ if (pRockchipPort->assignedBufferNum == 0) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "pRockchipPort->unloadedResource signal set");
+ /* Rockchip_OSAL_MutexLock(pRockchipPort->compMutex); */
+ Rockchip_OSAL_SemaphorePost(pRockchipPort->unloadedResource);
+ /* Rockchip_OSAL_MutexUnlock(pRockchipPort->compMutex); */
+ pRockchipPort->portDefinition.bPopulated = OMX_FALSE;
+ }
+ }
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_AllocateTunnelBuffer(ROCKCHIP_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ (void) pOMXBasePort;
+ (void) nPortIndex;
+
+ ret = OMX_ErrorTunnelingUnsupported;
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_FreeTunnelBuffer(ROCKCHIP_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ (void) pOMXBasePort;
+ (void) nPortIndex;
+ ret = OMX_ErrorTunnelingUnsupported;
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_ComponentTunnelRequest(
+ OMX_IN OMX_HANDLETYPE hComp,
+ OMX_IN OMX_U32 nPort,
+ OMX_IN OMX_HANDLETYPE hTunneledComp,
+ OMX_IN OMX_U32 nTunneledPort,
+ OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ (void) hComp;
+ (void) nPort;
+ (void) hTunneledComp;
+ (void) nTunneledPort;
+ (void) pTunnelSetup;
+ ret = OMX_ErrorTunnelingUnsupported;
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_GetFlushBuffer(ROCKCHIP_OMX_BASEPORT *pRockchipPort, ROCKCHIP_OMX_DATABUFFER *pDataBuffer[])
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ FunctionIn();
+
+ *pDataBuffer = NULL;
+
+ if (pRockchipPort->portWayType == WAY1_PORT) {
+ *pDataBuffer = &pRockchipPort->way.port1WayDataBuffer.dataBuffer;
+ } else if (pRockchipPort->portWayType == WAY2_PORT) {
+ pDataBuffer[0] = &(pRockchipPort->way.port2WayDataBuffer.inputDataBuffer);
+ pDataBuffer[1] = &(pRockchipPort->way.port2WayDataBuffer.outputDataBuffer);
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
+ ROCKCHIP_OMX_DATABUFFER *pDataPortBuffer[2] = {NULL, NULL};
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+ OMX_U32 flushNum = 0;
+ OMX_S32 semValue = 0;
+ int i = 0, maxBufferNum = 0;
+ FunctionIn();
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+
+ while (Rockchip_OSAL_GetElemNum(&pRockchipPort->bufferQ) > 0) {
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipComponent->pRockchipPort[portIndex].bufferSemID, &semValue);
+ if (semValue == 0)
+ Rockchip_OSAL_SemaphorePost(pRockchipComponent->pRockchipPort[portIndex].bufferSemID);
+
+ Rockchip_OSAL_SemaphoreWait(pRockchipComponent->pRockchipPort[portIndex].bufferSemID);
+ message = (ROCKCHIP_OMX_MESSAGE *)Rockchip_OSAL_Dequeue(&pRockchipPort->bufferQ);
+ if ((message != NULL) && (message->messageType != ROCKCHIP_OMX_CommandFakeBuffer)) {
+ bufferHeader = (OMX_BUFFERHEADERTYPE *)message->pCmdData;
+ bufferHeader->nFilledLen = 0;
+
+ if (portIndex == OUTPUT_PORT_INDEX) {
+ Rockchip_OMX_OutputBufferReturn(pOMXComponent, bufferHeader);
+ } else if (portIndex == INPUT_PORT_INDEX) {
+ Rkvpu_OMX_InputBufferReturn(pOMXComponent, bufferHeader);
+ }
+ }
+ Rockchip_OSAL_Free(message);
+ message = NULL;
+ }
+
+ Rkvpu_OMX_GetFlushBuffer(pRockchipPort, pDataPortBuffer);
+ if (portIndex == INPUT_PORT_INDEX) {
+ if (pDataPortBuffer[0]->dataValid == OMX_TRUE)
+ Rkvpu_InputBufferReturn(pOMXComponent, pDataPortBuffer[0]);
+ if (pDataPortBuffer[1]->dataValid == OMX_TRUE)
+ Rkvpu_InputBufferReturn(pOMXComponent, pDataPortBuffer[1]);
+ } else if (portIndex == OUTPUT_PORT_INDEX) {
+ if (pDataPortBuffer[0]->dataValid == OMX_TRUE)
+ Rkvpu_OutputBufferReturn(pOMXComponent, pDataPortBuffer[0]);
+ if (pDataPortBuffer[1]->dataValid == OMX_TRUE)
+ Rkvpu_OutputBufferReturn(pOMXComponent, pDataPortBuffer[1]);
+ }
+
+ if (pRockchipComponent->bMultiThreadProcess == OMX_TRUE) {
+ if (pRockchipPort->bufferProcessType == BUFFER_SHARE) {
+ if (pRockchipPort->processData.bufferHeader != NULL) {
+ if (portIndex == INPUT_PORT_INDEX) {
+ Rkvpu_OMX_InputBufferReturn(pOMXComponent, pRockchipPort->processData.bufferHeader);
+ } else if (portIndex == OUTPUT_PORT_INDEX) {
+ Rockchip_OMX_OutputBufferReturn(pOMXComponent, pRockchipPort->processData.bufferHeader);
+ }
+ }
+ Rockchip_ResetCodecData(&pRockchipPort->processData);
+
+ maxBufferNum = pRockchipPort->portDefinition.nBufferCountActual;
+ for (i = 0; i < maxBufferNum; i++) {
+ pRockchipPort->extendBufferHeader[i].pRegisterFlag = 0;
+ pRockchipPort->extendBufferHeader[i].buf_fd[0] = 0;
+ if (pRockchipPort->extendBufferHeader[i].pPrivate != NULL) {
+ Rockchip_OSAL_FreeVpumem(pRockchipPort->extendBufferHeader[i].pPrivate);
+ pRockchipPort->extendBufferHeader[i].pPrivate = NULL;
+ }
+
+ if (pRockchipPort->extendBufferHeader[i].bBufferInOMX == OMX_TRUE) {
+ if (portIndex == OUTPUT_PORT_INDEX) {
+ Rockchip_OMX_OutputBufferReturn(pOMXComponent, pRockchipPort->extendBufferHeader[i].OMXBufferHeader);
+ } else if (portIndex == INPUT_PORT_INDEX) {
+ Rkvpu_OMX_InputBufferReturn(pOMXComponent, pRockchipPort->extendBufferHeader[i].OMXBufferHeader);
+ }
+ }
+ }
+ Rockchip_OSAL_resetVpumemPool(pRockchipComponent);
+ }
+ } else {
+ Rockchip_ResetCodecData(&pRockchipPort->processData);
+ }
+
+ if ((pRockchipPort->bufferProcessType == BUFFER_SHARE) &&
+ (portIndex == OUTPUT_PORT_INDEX)) {
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ }
+
+ while (1) {
+ OMX_S32 cnt = 0;
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipComponent->pRockchipPort[portIndex].bufferSemID, &cnt);
+ if (cnt <= 0)
+ break;
+ Rockchip_OSAL_SemaphoreWait(pRockchipComponent->pRockchipPort[portIndex].bufferSemID);
+ }
+ Rockchip_OSAL_ResetQueue(&pRockchipPort->bufferQ);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ ROCKCHIP_OMX_DATABUFFER *flushPortBuffer[2] = {NULL, NULL};
+ OMX_U32 i = 0, cnt = 0;
+
+ FunctionIn();
+
+ if (pOMXComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ pRockchipComponent->pRockchipPort[nPortIndex].bIsPortFlushed = OMX_TRUE;
+
+ if (pRockchipComponent->bMultiThreadProcess == OMX_FALSE) {
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pauseEvent);
+ } else {
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pRockchipPort[nPortIndex].pauseEvent);
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[nPortIndex];
+ Rkvpu_OMX_GetFlushBuffer(pRockchipPort, flushPortBuffer);
+
+
+ Rockchip_OSAL_SemaphorePost(pRockchipPort->bufferSemID);
+ Rockchip_OSAL_MutexLock(flushPortBuffer[0]->bufferMutex);
+ Rockchip_OSAL_MutexLock(flushPortBuffer[1]->bufferMutex);
+ ret = Rkvpu_OMX_FlushPort(pOMXComponent, nPortIndex);
+
+ VpuCodecContext_t *p_vpu_ctx = pVideoDec->vpu_ctx;
+ if (pRockchipComponent->nRkFlags & RK_VPU_NEED_FLUSH_ON_SEEK) {
+ p_vpu_ctx->flush(p_vpu_ctx);
+ pRockchipComponent->nRkFlags &= ~RK_VPU_NEED_FLUSH_ON_SEEK;
+ }
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "OMX_CommandFlush start, port:%d", nPortIndex);
+ Rockchip_ResetCodecData(&pRockchipPort->processData);
+
+ if (ret == OMX_ErrorNone) {
+ if (nPortIndex == INPUT_PORT_INDEX) {
+ pRockchipComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
+ pRockchipComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
+ Rockchip_OSAL_Memset(pRockchipComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
+ Rockchip_OSAL_Memset(pRockchipComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
+ pRockchipComponent->getAllDelayBuffer = OMX_FALSE;
+ pRockchipComponent->bSaveFlagEOS = OMX_FALSE;
+ pRockchipComponent->bBehaviorEOS = OMX_FALSE;
+ pVideoDec->bDecSendEOS = OMX_FALSE;
+ pRockchipComponent->reInputData = OMX_FALSE;
+ }
+
+ pRockchipComponent->pRockchipPort[nPortIndex].bIsPortFlushed = OMX_FALSE;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "OMX_CommandFlush EventCmdComplete, port:%d", nPortIndex);
+ if (bEvent == OMX_TRUE)
+ pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventCmdComplete,
+ OMX_CommandFlush, nPortIndex, NULL);
+ }
+ Rockchip_OSAL_MutexUnlock(flushPortBuffer[1]->bufferMutex);
+ Rockchip_OSAL_MutexUnlock(flushPortBuffer[0]->bufferMutex);
+
+EXIT:
+ if ((ret != OMX_ErrorNone) && (pOMXComponent != NULL) && (pRockchipComponent != NULL)) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
+ pRockchipComponent->pCallbacks->EventHandler(pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventError,
+ ret, 0, NULL);
+ }
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_ResolutionUpdate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *pOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+
+ pOutputPort->cropRectangle.nTop = pOutputPort->newCropRectangle.nTop;
+ pOutputPort->cropRectangle.nLeft = pOutputPort->newCropRectangle.nLeft;
+ pOutputPort->cropRectangle.nWidth = pOutputPort->newCropRectangle.nWidth;
+ pOutputPort->cropRectangle.nHeight = pOutputPort->newCropRectangle.nHeight;
+
+ pInputPort->portDefinition.format.video.nFrameWidth = pInputPort->newPortDefinition.format.video.nFrameWidth;
+ pInputPort->portDefinition.format.video.nFrameHeight = pInputPort->newPortDefinition.format.video.nFrameHeight;
+ pInputPort->portDefinition.format.video.nStride = pInputPort->newPortDefinition.format.video.nStride;
+ pOutputPort->portDefinition.format.video.nStride = pInputPort->newPortDefinition.format.video.nStride;
+ pInputPort->portDefinition.format.video.nSliceHeight = pInputPort->newPortDefinition.format.video.nSliceHeight;
+ pOutputPort->portDefinition.format.video.nSliceHeight = pInputPort->newPortDefinition.format.video.nSliceHeight;
+ pOutputPort->portDefinition.format.video.eColorFormat = pOutputPort->newPortDefinition.format.video.eColorFormat;
+
+ pOutputPort->portDefinition.nBufferCountActual = pOutputPort->newPortDefinition.nBufferCountActual;
+ pOutputPort->portDefinition.nBufferCountMin = pOutputPort->newPortDefinition.nBufferCountMin;
+
+ UpdateFrameSize(pOMXComponent);
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATABUFFER *dataBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *rockchipOMXInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
+
+ FunctionIn();
+
+ bufferHeader = dataBuffer->bufferHeader;
+
+ if (bufferHeader != NULL) {
+ if (rockchipOMXInputPort->markType.hMarkTargetComponent != NULL ) {
+ bufferHeader->hMarkTargetComponent = rockchipOMXInputPort->markType.hMarkTargetComponent;
+ bufferHeader->pMarkData = rockchipOMXInputPort->markType.pMarkData;
+ rockchipOMXInputPort->markType.hMarkTargetComponent = NULL;
+ rockchipOMXInputPort->markType.pMarkData = NULL;
+ }
+
+ if (bufferHeader->hMarkTargetComponent != NULL) {
+ if (bufferHeader->hMarkTargetComponent == pOMXComponent) {
+ pRockchipComponent->pCallbacks->EventHandler(pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventMark,
+ 0, 0, bufferHeader->pMarkData);
+ } else {
+ pRockchipComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent;
+ pRockchipComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData;
+ }
+ }
+
+ bufferHeader->nFilledLen = 0;
+ bufferHeader->nOffset = 0;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_OMX_InputBufferReturn in");
+ Rkvpu_OMX_InputBufferReturn(pOMXComponent, bufferHeader);
+ }
+
+ /* reset dataBuffer */
+ Rockchip_ResetDataBuffer(dataBuffer);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_Frame2Outbuf(OMX_COMPONENTTYPE *pOMXComponent, OMX_BUFFERHEADERTYPE* pOutputBuffer, VPU_FRAME *pframe)
+{
+
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+
+#ifdef USE_STOREMETADATA
+ if (pVideoDec->bStoreMetaData == OMX_TRUE) {
+ OMX_U32 mWidth = pOutputPort->portDefinition.format.video.nFrameWidth;
+ OMX_U32 mHeight = pOutputPort->portDefinition.format.video.nFrameHeight;
+ RockchipVideoPlane vplanes;
+ OMX_PTR pGrallocHandle;
+ OMX_COLOR_FORMATTYPE omx_format = 0;
+ OMX_U32 pixel_format = 0;
+ int res;
+
+ if (Rockchip_OSAL_GetInfoFromMetaData(pOutputBuffer->pBuffer, &pGrallocHandle)) {
+ return OMX_ErrorBadParameter;
+ }
+
+ if (pVideoDec->bPvr_Flag == OMX_TRUE) {
+ pixel_format = RK_FORMAT_BGRA_8888;
+ } else {
+ omx_format = Rockchip_OSAL_GetANBColorFormat(pGrallocHandle);
+ pixel_format = Rockchip_OSAL_OMX2HalPixelFormat(omx_format);
+ if (pixel_format == HAL_PIXEL_FORMAT_RGBA_8888) {
+ pixel_format = RK_FORMAT_RGBA_8888;
+ } else {
+ pixel_format = RK_FORMAT_BGRA_8888;
+ }
+ }
+ if (pVideoDec->rga_ctx != NULL) {
+ Rockchip_OSAL_LockANB(pGrallocHandle, mWidth, mHeight, omx_format, &vplanes);
+ VPUMemLink(&pframe->vpumem);
+ rga_nv122rgb(&vplanes, &pframe->vpumem, mWidth, mHeight, pixel_format, pVideoDec->rga_ctx);
+ VPUFreeLinear(&pframe->vpumem);
+ Rockchip_OSAL_UnlockANB(pGrallocHandle);
+ }
+ return ret;
+ }
+#endif
+
+#ifdef USE_ANB
+ if (pVideoDec->bIsANBEnabled == OMX_TRUE) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "enableNativeBuffer");
+ OMX_U32 mWidth = pOutputPort->portDefinition.format.video.nFrameWidth;
+ OMX_U32 mHeight = pOutputPort->portDefinition.format.video.nFrameHeight;
+ RockchipVideoPlane vplanes;
+ OMX_U32 mStride = 0;
+ OMX_U32 mSliceHeight = 0;
+ OMX_COLOR_FORMATTYPE omx_format = 0;
+ OMX_U32 pixel_format = 0;
+ mStride = Get_Video_HorAlign(pVideoDec->codecId, mWidth, mHeight);
+ mSliceHeight = Get_Video_VerAlign(pVideoDec->codecId, mHeight);
+ omx_format = Rockchip_OSAL_GetANBColorFormat(pOutputBuffer->pBuffer);
+ pixel_format = Rockchip_OSAL_OMX2HalPixelFormat(omx_format);
+ Rockchip_OSAL_LockANB(pOutputBuffer->pBuffer, mWidth, mHeight, omx_format, &vplanes);
+ {
+ VPUMemLink(&pframe->vpumem);
+ VPUMemInvalidate(&pframe->vpumem);
+ {
+ OMX_U8 * buff_vir = (OMX_U8 *)pframe->vpumem.vir_addr;
+ pOutputBuffer->nFilledLen = mWidth * mHeight * 3 / 2;
+ OMX_U32 uv_offset = mStride * mSliceHeight;
+ OMX_U32 y_size = mWidth * mHeight;
+ OMX_U32 uv_size = mWidth * mHeight / 2;
+ OMX_U8 *dst_uv = (OMX_U8 *)((OMX_U8 *)vplanes.addr + y_size);
+ OMX_U8 *src_uv = (OMX_U8 *)(buff_vir + uv_offset);
+ OMX_U32 i = 0, j = 0;
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "mWidth = %d mHeight = %d mStride = %d,mSlicHeight %d", mWidth, mHeight, mStride, mSliceHeight);
+ for (i = 0; i < mHeight; i++) {
+ Rockchip_OSAL_Memcpy((char*)vplanes.addr + i * mWidth, buff_vir + i * mStride, mWidth);
+ }
+
+ for (i = 0; i < mHeight / 2; i++) {
+ Rockchip_OSAL_Memcpy((OMX_U8*)dst_uv, (OMX_U8*)src_uv, mWidth);
+ dst_uv += mWidth;
+ src_uv += mStride;
+ }
+ }
+ VPUFreeLinear(&pframe->vpumem);
+ }
+ Rockchip_OSAL_UnlockANB(pOutputBuffer->pBuffer);
+ return ret;
+ }
+#endif
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ OMX_U32 mStride = 0;
+ OMX_U32 mSliceHeight = 0;
+ OMX_U32 mWidth = (pOutputPort->portDefinition.format.video.nFrameWidth );
+ OMX_U32 mHeight = (pOutputPort->portDefinition.format.video.nFrameHeight );
+ VPUMemLink(&pframe->vpumem);
+ VPUMemInvalidate(&pframe->vpumem);
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "width:%d,height:%d ", mWidth, mHeight);
+ mStride = Get_Video_HorAlign(pVideoDec->codecId, mWidth, mHeight);
+ mSliceHeight = Get_Video_VerAlign(pVideoDec->codecId, mHeight);
+ {
+ //csy@rock-chips.com
+ OMX_U8 *buff_vir = (OMX_U8 *)pframe->vpumem.vir_addr;
+ OMX_U32 uv_offset = mStride * mSliceHeight;
+ OMX_U32 y_size = mWidth * mHeight;
+ OMX_U32 uv_size = mWidth * mHeight / 2;
+ OMX_U8 *dst_uv = (OMX_U8 *)(pOutputBuffer->pBuffer + y_size);
+ OMX_U8 *src_uv = (OMX_U8 *)(buff_vir + uv_offset);
+ OMX_U32 i = 0, j = 0;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "mWidth = %d mHeight = %d mStride = %d,mSlicHeight %d", mWidth, mHeight, mStride, mSliceHeight);
+ pOutputBuffer->nFilledLen = mWidth * mHeight * 3 / 2;
+ for (i = 0; i < mHeight; i++) {
+ Rockchip_OSAL_Memcpy((char*)pOutputBuffer->pBuffer + i * mWidth, buff_vir + i * mStride, mWidth);
+ }
+
+ for (i = 0; i < mHeight / 2; i++) {
+ Rockchip_OSAL_Memcpy((OMX_U8*)dst_uv, (OMX_U8*)src_uv, mWidth);
+ dst_uv += mWidth;
+ src_uv += mStride;
+ }
+#if 0
+
+ if (pVideoDec->fp_out != NULL) {
+ fwrite(pOutputBuffer->pBuffer, 1, (mWidth * mHeight) * 3 / 2, pVideoDec->fp_out);
+ fflush(pVideoDec->fp_out);
+ }
+#endif
+ }
+ VPUFreeLinear(&pframe->vpumem);
+
+ return ret;
+
+}
+
+OMX_ERRORTYPE Rkvpu_InputBufferGetQueue(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent)
+{
+ OMX_U32 ret = OMX_ErrorUndefined;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+ ROCKCHIP_OMX_DATABUFFER *inputUseBuffer = NULL;
+
+ FunctionIn();
+
+ inputUseBuffer = &(pRockchipPort->way.port2WayDataBuffer.inputDataBuffer);
+
+ if (pRockchipComponent->currentState != OMX_StateExecuting) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else if ((pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateExecutingToIdle) &&
+ (!CHECK_PORT_BEING_FLUSHED(pRockchipPort))) {
+ Rockchip_OSAL_SemaphoreWait(pRockchipPort->bufferSemID);
+ if (inputUseBuffer->dataValid != OMX_TRUE) {
+ message = (ROCKCHIP_OMX_MESSAGE *)Rockchip_OSAL_Dequeue(&pRockchipPort->bufferQ);
+ if (message == NULL) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ if (message->messageType == ROCKCHIP_OMX_CommandFakeBuffer) {
+ Rockchip_OSAL_Free(message);
+ ret = OMX_ErrorCodecFlush;
+ goto EXIT;
+ }
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "input buffer count = %d",pRockchipPort->bufferQ.numElem);
+ inputUseBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
+ inputUseBuffer->allocSize = inputUseBuffer->bufferHeader->nAllocLen;
+ inputUseBuffer->dataLen = inputUseBuffer->bufferHeader->nFilledLen;
+ inputUseBuffer->remainDataLen = inputUseBuffer->dataLen;
+ inputUseBuffer->usedDataLen = 0;
+ inputUseBuffer->dataValid = OMX_TRUE;
+ inputUseBuffer->nFlags = inputUseBuffer->bufferHeader->nFlags;
+ inputUseBuffer->timeStamp = inputUseBuffer->bufferHeader->nTimeStamp;
+
+ Rockchip_OSAL_Free(message);
+
+ if (inputUseBuffer->allocSize <= inputUseBuffer->dataLen)
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_WARNING, "Input Buffer Full, Check input buffer size! allocSize:%d, dataLen:%d", inputUseBuffer->allocSize, inputUseBuffer->dataLen);
+ }
+ ret = OMX_ErrorNone;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATABUFFER *dataBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *rockchipOMXOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
+
+ FunctionIn();
+
+ bufferHeader = dataBuffer->bufferHeader;
+
+ if (bufferHeader != NULL) {
+ bufferHeader->nFilledLen = dataBuffer->remainDataLen;
+ bufferHeader->nOffset = 0;
+ bufferHeader->nFlags = dataBuffer->nFlags;
+ bufferHeader->nTimeStamp = dataBuffer->timeStamp;
+
+ if ((rockchipOMXOutputPort->bStoreMetaData == OMX_TRUE) && (bufferHeader->nFilledLen > 0))
+ bufferHeader->nFilledLen = bufferHeader->nAllocLen;
+ if (pRockchipComponent->propagateMarkType.hMarkTargetComponent != NULL) {
+ bufferHeader->hMarkTargetComponent = pRockchipComponent->propagateMarkType.hMarkTargetComponent;
+ bufferHeader->pMarkData = pRockchipComponent->propagateMarkType.pMarkData;
+ pRockchipComponent->propagateMarkType.hMarkTargetComponent = NULL;
+ pRockchipComponent->propagateMarkType.pMarkData = NULL;
+ }
+
+ if ((bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "event OMX_BUFFERFLAG_EOS!!!");
+ pRockchipComponent->pCallbacks->EventHandler(pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventBufferFlag,
+ OUTPUT_PORT_INDEX,
+ bufferHeader->nFlags, NULL);
+ }
+
+ Rockchip_OMX_OutputBufferReturn(pOMXComponent, bufferHeader);
+ }
+
+ /* reset dataBuffer */
+ Rockchip_ResetDataBuffer(dataBuffer);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OutputBufferGetQueue(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent)
+{
+ OMX_U32 ret = OMX_ErrorUndefined;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+ ROCKCHIP_OMX_DATABUFFER *outputUseBuffer = NULL;
+
+ FunctionIn();
+
+ outputUseBuffer = &(pRockchipPort->way.port2WayDataBuffer.outputDataBuffer);
+
+ if (pRockchipComponent->currentState != OMX_StateExecuting) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else if ((pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateExecutingToIdle) &&
+ (!CHECK_PORT_BEING_FLUSHED(pRockchipPort))) {
+ Rockchip_OSAL_SemaphoreWait(pRockchipPort->bufferSemID);
+ if (outputUseBuffer->dataValid != OMX_TRUE) {
+ message = (ROCKCHIP_OMX_MESSAGE *)Rockchip_OSAL_Dequeue(&pRockchipPort->bufferQ);
+ if (message == NULL) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ if (message->messageType == ROCKCHIP_OMX_CommandFakeBuffer) {
+ Rockchip_OSAL_Free(message);
+ ret = OMX_ErrorCodecFlush;
+ goto EXIT;
+ }
+
+ outputUseBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
+ outputUseBuffer->allocSize = outputUseBuffer->bufferHeader->nAllocLen;
+ outputUseBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen;
+ outputUseBuffer->remainDataLen = outputUseBuffer->dataLen;
+ outputUseBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset;
+ outputUseBuffer->dataValid = OMX_TRUE;
+ Rockchip_OSAL_Free(message);
+ }
+ ret = OMX_ErrorNone;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+
+}
+
+OMX_BUFFERHEADERTYPE *Rkvpu_OutputBufferGetQueue_Direct(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent)
+{
+ OMX_BUFFERHEADERTYPE *retBuffer = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+
+ FunctionIn();
+
+ if (pRockchipComponent->currentState != OMX_StateExecuting) {
+ retBuffer = NULL;
+ goto EXIT;
+ } else if ((pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateExecutingToIdle) &&
+ (!CHECK_PORT_BEING_FLUSHED(pRockchipPort))) {
+ Rockchip_OSAL_SemaphoreWait(pRockchipPort->bufferSemID);
+
+ message = (ROCKCHIP_OMX_MESSAGE *)Rockchip_OSAL_Dequeue(&pRockchipPort->bufferQ);
+ if (message == NULL) {
+ retBuffer = NULL;
+ goto EXIT;
+ }
+ if (message->messageType == ROCKCHIP_OMX_CommandFakeBuffer) {
+ Rockchip_OSAL_Free(message);
+ retBuffer = NULL;
+ goto EXIT;
+ }
+
+ retBuffer = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
+ Rockchip_OSAL_Free(message);
+ }
+
+EXIT:
+ FunctionOut();
+
+ return retBuffer;
+}
+
+OMX_ERRORTYPE Rkvpu_CodecBufferReset(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 PortIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+
+ FunctionIn();
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[PortIndex];
+
+ ret = Rockchip_OSAL_ResetQueue(&pRockchipPort->codecBufferQ);
+ if (ret != 0) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ while (1) {
+ OMX_S32 cnt = 0;
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipPort->codecSemID, (OMX_S32*)&cnt);
+ if (cnt > 0)
+ Rockchip_OSAL_SemaphoreWait(pRockchipPort->codecSemID);
+ else
+ break;
+ }
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_GetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pRockchipComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if (ComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ switch ((OMX_U32)nParamIndex) {
+ case OMX_IndexParamVideoInit: {
+ OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure;
+ ret = Rockchip_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ portParam->nPorts = pRockchipComponent->portParam.nPorts;
+ portParam->nStartPortNumber = pRockchipComponent->portParam.nStartPortNumber;
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamVideoPortFormat: {
+ OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = portFormat->nPortIndex;
+ OMX_U32 index = portFormat->nIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+ OMX_U32 supportFormatNum = 0; /* supportFormatNum = N-1 */
+
+ ret = Rockchip_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((portIndex >= pRockchipComponent->portParam.nPorts)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+
+ if (portIndex == INPUT_PORT_INDEX) {
+ supportFormatNum = INPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1;
+ if (index > supportFormatNum) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ portDefinition = &pRockchipPort->portDefinition;
+
+ portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat;
+ portFormat->eColorFormat = portDefinition->format.video.eColorFormat;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ } else if (portIndex == OUTPUT_PORT_INDEX) {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ portDefinition = &pRockchipPort->portDefinition;
+
+ if (pRockchipPort->bStoreMetaData == OMX_FALSE) {
+ switch (index) {
+ case supportFormat_0:
+
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_1:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ default:
+ if (index > supportFormat_0) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+ break;
+ }
+ } else {
+ switch (index) {
+ case supportFormat_0:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ default:
+ if (index > supportFormat_0) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+ break;
+ }
+ }
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+#ifdef USE_ANB
+ case OMX_IndexParamGetAndroidNativeBufferUsage:
+ case OMX_IndexParamdescribeColorFormat: {
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rockchip_OSAL_GetANBParameter!!");
+ ret = Rockchip_OSAL_GetANBParameter(hComponent, nParamIndex, ComponentParameterStructure);
+ }
+ break;
+ case OMX_IndexParamPortDefinition: {
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = portDefinition->nPortIndex;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+
+ ret = Rockchip_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ /* at this point, GetParameter has done all the verification, we
+ * just dereference things directly here
+ */
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ if ((pVideoDec->bIsANBEnabled == OMX_TRUE) ||
+ (pVideoDec->bStoreMetaData == OMX_TRUE)) {
+ portDefinition->format.video.eColorFormat = pRockchipPort->portDefinition.format.video.eColorFormat;
+ // (OMX_COLOR_FORMATTYPE)Rockchip_OSAL_OMX2HalPixelFormat(portDefinition->format.video.eColorFormat);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "portDefinition->format.video.eColorFormat:0x%x", portDefinition->format.video.eColorFormat);
+ }
+ if (portIndex == OUTPUT_PORT_INDEX &&
+ pRockchipPort->bufferProcessType != BUFFER_SHARE) {
+ portDefinition->format.video.nStride = portDefinition->format.video.nFrameWidth;
+ portDefinition->format.video.nSliceHeight = portDefinition->format.video.nFrameHeight;
+ }
+ }
+ break;
+#endif
+
+ case OMX_IndexParamStandardComponentRole: {
+ OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)ComponentParameterStructure;
+ ret = Rockchip_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pVideoDec->codecId == OMX_VIDEO_CodingAVC) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_H264_DEC_ROLE);
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingMPEG4) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_MPEG4_DEC_ROLE);
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingH263) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_H263_DEC_ROLE);
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingMPEG2) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_MPEG2_DEC_ROLE);
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingVP8) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_VP8_DEC_ROLE);
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingHEVC) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_HEVC_DEC_ROLE);
+ } else if (pVideoDec->codecId == (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingFLV1) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_FLV_DEC_ROLE);
+ } else if (pVideoDec->codecId == (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP6) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_VP6_DEC_ROLE);
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingMJPEG) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_MJPEG_DEC_ROLE);
+ } else if (pVideoDec->codecId == (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVC1) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_VC1_DEC_ROLE);
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingWMV) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_WMV3_DEC_ROLE);
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingRV) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_RMVB_DEC_ROLE);
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingVP9) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_VP9_DEC_ROLE);
+ }
+
+ }
+ break;
+ case OMX_IndexParamVideoAvc: {
+ OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)ComponentParameterStructure;
+ OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ ret = Rockchip_OMX_Check_SizeVersion(pDstAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstAVCComponent->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pSrcAVCComponent = &pVideoDec->AVCComponent[pDstAVCComponent->nPortIndex];
+ Rockchip_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ }
+ break;
+ case OMX_IndexParamVideoProfileLevelQuerySupported: {
+ OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevel =
+ (OMX_VIDEO_PARAM_PROFILELEVELTYPE *) ComponentParameterStructure;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ OMX_U32 index = profileLevel->nProfileIndex;
+ OMX_U32 nProfileLevels = 0;
+ if (profileLevel->nPortIndex != 0) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Invalid port index: %ld", profileLevel->nPortIndex);
+ return OMX_ErrorUnsupportedIndex;
+ }
+ if (pVideoDec->codecId == OMX_VIDEO_CodingAVC) {
+ nProfileLevels =
+ sizeof(kH264ProfileLevels) / sizeof(kH264ProfileLevels[0]);
+ if (index >= nProfileLevels) {
+ return OMX_ErrorNoMore;
+ }
+ profileLevel->eProfile = kH264ProfileLevels[index].mProfile;
+ profileLevel->eLevel = kH264ProfileLevels[index].mLevel;
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingHEVC) {
+ nProfileLevels =
+ sizeof(kH265ProfileLevels) / sizeof(kH265ProfileLevels[0]);
+ if (index >= nProfileLevels) {
+ return OMX_ErrorNoMore;
+ }
+ profileLevel->eProfile = kH265ProfileLevels[index].mProfile;
+ profileLevel->eLevel = kH265ProfileLevels[index].mLevel;
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingMPEG4) {
+ nProfileLevels =
+ sizeof(kM4VProfileLevels) / sizeof(kM4VProfileLevels[0]);
+ if (index >= nProfileLevels) {
+ return OMX_ErrorNoMore;
+ }
+ profileLevel->eProfile = kM4VProfileLevels[index].mProfile;
+ profileLevel->eLevel = kM4VProfileLevels[index].mLevel;
+ } else if (pVideoDec->codecId == OMX_VIDEO_CodingH263) {
+ nProfileLevels =
+ sizeof(kH263ProfileLevels) / sizeof(kH263ProfileLevels[0]);
+ if (index >= nProfileLevels) {
+ return OMX_ErrorNoMore;
+ }
+ profileLevel->eProfile = kH263ProfileLevels[index].mProfile;
+ profileLevel->eLevel = kH263ProfileLevels[index].mLevel;
+ } else {
+ return OMX_ErrorNoMore;
+ }
+ return OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamVideoHDRRockchipExtensions: {
+ OMX_EXTENSION_VIDEO_PARAM_HDR *hdrParams =
+ (OMX_EXTENSION_VIDEO_PARAM_HDR *) ComponentParameterStructure;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ ret = Rockchip_OMX_Check_SizeVersion(hdrParams, sizeof(OMX_EXTENSION_VIDEO_PARAM_HDR));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ hdrParams->eColorSpace = pVideoDec->extColorSpace;
+ hdrParams->eDyncRange = pVideoDec->extDyncRange;
+ ret = OMX_ErrorNone;
+ }
+ break;
+ default: {
+ ret = Rockchip_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+OMX_ERRORTYPE Rkvpu_OMX_SetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pRockchipComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if (ComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ switch ((OMX_U32)nIndex) {
+ case OMX_IndexParamVideoPortFormat: {
+ OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = portFormat->nPortIndex;
+ OMX_U32 index = portFormat->nIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+ OMX_U32 supportFormatNum = 0;
+
+ ret = Rockchip_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((portIndex >= pRockchipComponent->portParam.nPorts)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ portDefinition = &pRockchipPort->portDefinition;
+
+ portDefinition->format.video.eColorFormat = portFormat->eColorFormat;
+ portDefinition->format.video.eCompressionFormat = portFormat->eCompressionFormat;
+ portDefinition->format.video.xFramerate = portFormat->xFramerate;
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "portIndex:%d, portFormat->eColorFormat:0x%x", portIndex, portFormat->eColorFormat);
+ }
+ }
+ break;
+ case OMX_IndexParamPortDefinition: {
+ OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = pPortDefinition->nPortIndex;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort;
+ OMX_U32 stride, strideheight, size;
+ OMX_U32 realWidth, realHeight;
+
+ if (portIndex >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+
+ if ((pRockchipComponent->currentState != OMX_StateLoaded) && (pRockchipComponent->currentState != OMX_StateWaitForResources)) {
+ if (pRockchipPort->portDefinition.bEnabled == OMX_TRUE) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ }
+ if (pPortDefinition->nBufferCountActual < pRockchipPort->portDefinition.nBufferCountMin) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ Rockchip_OSAL_Memcpy(&pRockchipPort->portDefinition, pPortDefinition, pPortDefinition->nSize);
+
+
+ realWidth = pRockchipPort->portDefinition.format.video.nFrameWidth;
+ realHeight = pRockchipPort->portDefinition.format.video.nFrameHeight;
+
+ stride = Get_Video_HorAlign(pVideoDec->codecId, realWidth, realHeight);
+ strideheight = Get_Video_VerAlign(pVideoDec->codecId, realHeight);
+
+ size = (stride * strideheight * 3) / 2;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "decoder width %d support %d", stride, VPUCheckSupportWidth());
+ if (realWidth > VPUCheckSupportWidth()) {
+ if (access("/dev/rkvdec", 06) == 0) {
+ if (pVideoDec->codecId == OMX_VIDEO_CodingHEVC ||
+ pVideoDec->codecId == OMX_VIDEO_CodingAVC ||
+ pVideoDec->codecId == OMX_VIDEO_CodingVP9) {
+ ;
+ } else {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "decoder width %d big than support width %d return error", stride, VPUCheckSupportWidth());
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ } else {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "decoder width %d big than support width %d return error", stride, VPUCheckSupportWidth());
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+ pRockchipPort->portDefinition.format.video.nStride = stride;
+ pRockchipPort->portDefinition.format.video.nSliceHeight = strideheight;
+ pRockchipPort->portDefinition.nBufferSize = (size > pRockchipPort->portDefinition.nBufferSize) ? size : pRockchipPort->portDefinition.nBufferSize;
+
+ if (portIndex == INPUT_PORT_INDEX) {
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ pRockchipOutputPort->portDefinition.format.video.nFrameWidth = pRockchipPort->portDefinition.format.video.nFrameWidth;
+ pRockchipOutputPort->portDefinition.format.video.nFrameHeight = pRockchipPort->portDefinition.format.video.nFrameHeight;
+ pRockchipOutputPort->portDefinition.format.video.nStride = stride;
+ pRockchipOutputPort->portDefinition.format.video.nSliceHeight = strideheight;
+
+ switch ((OMX_U32)pRockchipOutputPort->portDefinition.format.video.eColorFormat) {
+
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ pRockchipOutputPort->portDefinition.nBufferSize = (stride * strideheight * 3) / 2;
+ break;
+#ifdef USE_STOREMETADATA
+ case OMX_COLOR_FormatAndroidOpaque:
+ pRockchipOutputPort->portDefinition.nBufferSize = stride * strideheight * 4;
+ if (pVideoDec->bPvr_Flag == OMX_TRUE) {
+ pRockchipOutputPort->portDefinition.format.video.eColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_BGRA_8888;
+ } else {
+ pRockchipOutputPort->portDefinition.format.video.eColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_RGBA_8888;
+ }
+ break;
+#endif
+ default:
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Color format is not support!! use default YUV size!!");
+ ret = OMX_ErrorUnsupportedSetting;
+ break;
+ }
+
+ if (pRockchipOutputPort->bufferProcessType == BUFFER_SHARE) {
+ pRockchipOutputPort->portDefinition.nBufferSize =
+ calc_plane(pRockchipPort->portDefinition.format.video.nFrameWidth, pRockchipOutputPort->portDefinition.format.video.nFrameHeight) +
+ calc_plane(pRockchipPort->portDefinition.format.video.nFrameWidth, pRockchipOutputPort->portDefinition.format.video.nFrameHeight >> 1);
+ }
+ }
+ }
+ break;
+#ifdef USE_ANB
+ case OMX_IndexParamEnableAndroidBuffers:
+ case OMX_IndexParamUseAndroidNativeBuffer:
+ case OMX_IndexParamStoreMetaDataBuffer:
+ case OMX_IndexParamprepareForAdaptivePlayback: {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rockchip_OSAL_SetANBParameter!!");
+ ret = Rockchip_OSAL_SetANBParameter(hComponent, nIndex, ComponentParameterStructure);
+ }
+ break;
+#endif
+
+ case OMX_IndexParamEnableThumbnailMode: {
+ ROCKCHIP_OMX_VIDEO_THUMBNAILMODE *pThumbnailMode = (ROCKCHIP_OMX_VIDEO_THUMBNAILMODE *)ComponentParameterStructure;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ ret = Rockchip_OMX_Check_SizeVersion(pThumbnailMode, sizeof(ROCKCHIP_OMX_VIDEO_THUMBNAILMODE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pVideoDec->bThumbnailMode = pThumbnailMode->bEnable;
+ if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ pRockchipOutputPort->portDefinition.nBufferCountMin = 1;
+ pRockchipOutputPort->portDefinition.nBufferCountActual = 1;
+ }
+
+ ret = OMX_ErrorNone;
+ }
+ break;
+
+ case OMX_IndexParamRkDecoderExtensionDiv3: {
+ OMX_BOOL *pIsDiv3 = (OMX_BOOL *)ComponentParameterStructure;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ if ((*pIsDiv3) == OMX_TRUE) {
+ pVideoDec->flags |= RKVPU_OMX_VDEC_IS_DIV3;
+ }
+
+ ret = OMX_ErrorNone;
+ }
+ break;
+
+ case OMX_IndexParamRkDecoderExtensionUseDts: {
+ OMX_BOOL *pUseDtsFlag = (OMX_BOOL *)ComponentParameterStructure;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ if ((*pUseDtsFlag) == OMX_TRUE) {
+ pVideoDec->flags |= RKVPU_OMX_VDEC_USE_DTS;
+ }
+
+ ret = OMX_ErrorNone;
+ }
+ break;
+
+ case OMX_IndexParamRkDecoderExtensionThumbNail: {
+ OMX_PARAM_U32TYPE *tmp = (OMX_PARAM_U32TYPE *)ComponentParameterStructure;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ OMX_U32 thumbFlag = tmp->nU32;
+ if (thumbFlag) {
+ pVideoDec->flags |= RKVPU_OMX_VDEC_THUMBNAIL;
+ }
+
+ ret = OMX_ErrorNone;
+ }
+ break;
+
+
+
+ case OMX_IndexParamStandardComponentRole: {
+ OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)ComponentParameterStructure;
+
+ ret = Rockchip_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((pRockchipComponent->currentState != OMX_StateLoaded) && (pRockchipComponent->currentState != OMX_StateWaitForResources)) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_H264_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_MPEG4_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_H263_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_MPEG2_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG2;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_VP8_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingVP8;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_VP9_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingVP9;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_HEVC_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingHEVC;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_FLV_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingFLV1;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_VP6_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP6;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_MJPEG_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMJPEG;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_VC1_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVC1;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_WMV3_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingWMV;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_RMVB_DEC_ROLE)) {
+ pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingRV;
+ } else {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+ break;
+ case OMX_IndexParamVideoAvc: {
+ OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL;
+ OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)ComponentParameterStructure;
+ RKVPU_OMX_VIDEODEC_COMPONENT *pVideoDec = (RKVPU_OMX_VIDEODEC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ret = Rockchip_OMX_Check_SizeVersion(pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pSrcAVCComponent->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pDstAVCComponent = &pVideoDec->AVCComponent[pSrcAVCComponent->nPortIndex];
+
+ Rockchip_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ }
+
+ break;
+ default: {
+ ret = Rockchip_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_GetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ default:
+ ret = Rockchip_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_SetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ default:
+ ret = Rockchip_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_ComponentRoleEnum(
+ OMX_HANDLETYPE hComponent,
+ OMX_U8 *cRole,
+ OMX_U32 nIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchioComponent = NULL;
+
+ FunctionIn();
+
+ if ((hComponent == NULL) || (cRole == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ if (nIndex == 0) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_H264_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 1) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_MPEG4_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 2) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_H263_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 3) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_FLV_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 4) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_MPEG2_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 5) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_RMVB_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 6) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_VP8_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 7) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_VC1_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 8) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_WMV3_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 9) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_VP6_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 10) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_HEVC_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 12) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_H264_DEC_ROLE);
+ ret = OMX_ErrorNone;
+
+ } else {
+ ret = OMX_ErrorNoMore;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+
+OMX_ERRORTYPE Rkvpu_OMX_GetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if ((cParameterName == NULL) || (pIndexType == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+#ifdef USE_ANB
+ if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PARAM_ENABLE_ANB) == 0) {
+ *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamEnableAndroidBuffers;
+ goto EXIT;
+ }
+ if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PARAM_GET_ANB_Usage) == 0) {
+ *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamGetAndroidNativeBufferUsage;
+ goto EXIT;
+ }
+ if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PARAM_USE_ANB) == 0) {
+ *pIndexType = (OMX_INDEXTYPE) NULL;//OMX_IndexParamUseAndroidNativeBuffer;
+ goto EXIT;
+ }
+
+ if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PREPARE_ADAPTIVE_PLAYBACK) == 0) {
+ *pIndexType = (OMX_INDEXTYPE)OMX_IndexParamprepareForAdaptivePlayback;
+ goto EXIT;
+ }
+ if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_DESCRIBE_COLORFORMAT) == 0) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_IndexParamdescribeColorFormat get ");
+ *pIndexType = (OMX_INDEXTYPE)OMX_IndexParamdescribeColorFormat;
+ goto EXIT;
+ }
+#endif
+
+ if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
+ *pIndexType = (OMX_INDEXTYPE)OMX_IndexParamEnableThumbnailMode;
+ goto EXIT;
+ }
+ if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PARAM_ROCKCHIP_DEC_EXTENSION_DIV3) == 0) {
+ *pIndexType = (OMX_INDEXTYPE)OMX_IndexParamRkDecoderExtensionDiv3;
+ goto EXIT;
+ }
+ if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PARAM_ROCKCHIP_DEC_EXTENSION_THUMBNAIL) == 0) {
+ *pIndexType = (OMX_INDEXTYPE)OMX_IndexParamRkDecoderExtensionThumbNail;
+ goto EXIT;
+ }
+ if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PARAM_ROCKCHIP_DEC_EXTENSION_USE_DTS) == 0) {
+ *pIndexType = (OMX_INDEXTYPE)OMX_IndexParamRkDecoderExtensionUseDts;
+ goto EXIT;
+ }
+#ifdef USE_STOREMETADATA
+ if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PARAM_STORE_METADATA_BUFFER) == 0) {
+ *pIndexType = (OMX_INDEXTYPE) NULL;
+ goto EXIT;
+ }
+#endif
+ ret = Rockchip_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
diff --git a/component/video/dec/Rkvpu_OMX_VdecControl.h b/component/video/dec/Rkvpu_OMX_VdecControl.h
new file mode 100755
index 0000000..5c1b0ea
--- /dev/null
+++ b/component/video/dec/Rkvpu_OMX_VdecControl.h
@@ -0,0 +1,129 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rkvpu_OMX_VdecControl.h
+ * @brief
+ * @author Csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.28 : Create
+ */
+
+#ifndef RKVPU_OMX_VIDEO_DECODECONTROL
+#define RKVPU_OMX_VIDEO_DECODECONTROL
+
+#include "OMX_Component.h"
+#include "Rockchip_OMX_Def.h"
+#include "Rockchip_OSAL_Queue.h"
+#include "Rockchip_OMX_Baseport.h"
+#include "Rockchip_OMX_Basecomponent.h"
+#include "library_register.h"
+#include "vpu_global.h"
+#include "OMX_VideoExt.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE Rkvpu_OMX_UseBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes,
+ OMX_IN OMX_U8 *pBuffer);
+
+OMX_ERRORTYPE Rkvpu_OMX_AllocateBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes);
+
+OMX_ERRORTYPE Rkvpu_OMX_FreeBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr);
+
+OMX_ERRORTYPE Rkvpu_OMX_AllocateTunnelBuffer(
+ ROCKCHIP_OMX_BASEPORT *pOMXBasePort,
+ OMX_U32 nPortIndex);
+
+OMX_ERRORTYPE Rkvpu_OMX_FreeTunnelBuffer(
+ ROCKCHIP_OMX_BASEPORT *pOMXBasePort,
+ OMX_U32 nPortIndex);
+
+OMX_ERRORTYPE Rkvpu_OMX_ComponentTunnelRequest(
+ OMX_IN OMX_HANDLETYPE hComp,
+ OMX_IN OMX_U32 nPort,
+ OMX_IN OMX_HANDLETYPE hTunneledComp,
+ OMX_IN OMX_U32 nTunneledPort,
+ OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup);
+
+OMX_ERRORTYPE Rkvpu_OMX_GetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure);
+
+OMX_ERRORTYPE Rkvpu_OMX_SetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure);
+
+OMX_ERRORTYPE Rkvpu_OMX_GetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure);
+
+OMX_ERRORTYPE Rkvpu_OMX_SetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure);
+
+OMX_ERRORTYPE Rkvpu_OMX_ComponentRoleEnum(
+ OMX_HANDLETYPE hComponent,
+ OMX_U8 *cRole,
+ OMX_U32 nIndex);
+
+
+OMX_ERRORTYPE Rkvpu_OMX_GetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType);
+
+OMX_ERRORTYPE Rkvpu_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATABUFFER *dataBuffer);
+OMX_ERRORTYPE Rkvpu_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATABUFFER *dataBuffer);
+OMX_ERRORTYPE Rkvpu_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent);
+OMX_ERRORTYPE Rkvpu_Frame2Outbuf(OMX_COMPONENTTYPE *pOMXComponent, OMX_BUFFERHEADERTYPE* pOutputBuffer, VPU_FRAME *pframe);
+OMX_ERRORTYPE Rkvpu_OutputBufferGetQueue(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent);
+OMX_ERRORTYPE Rkvpu_InputBufferGetQueue(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent);
+OMX_ERRORTYPE Rkvpu_ResolutionUpdate(OMX_COMPONENTTYPE *pOMXComponent);
+
+
+
+#ifdef USE_ANB
+OMX_ERRORTYPE Rkvpu_Shared_ANBBufferToData(ROCKCHIP_OMX_DATABUFFER *pUseBuffer, ROCKCHIP_OMX_DATA *pData, ROCKCHIP_OMX_BASEPORT *pRockchipPort, ROCKCHIP_OMX_PLANE nPlane);
+OMX_ERRORTYPE Rkvpu_Shared_DataToANBBuffer(ROCKCHIP_OMX_DATA *pData, ROCKCHIP_OMX_DATABUFFER *pUseBuffer, ROCKCHIP_OMX_BASEPORT *pRockchipPort);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/component/video/dec/Rockchip_OMX_Def.h b/component/video/dec/Rockchip_OMX_Def.h
new file mode 100644
index 0000000..c9a1341
--- /dev/null
+++ b/component/video/dec/Rockchip_OMX_Def.h
@@ -0,0 +1,316 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rockchip_OMX_Def.h
+ * @brief Rockchip_OMX specific define
+ * @author csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.26 : Create
+ */
+
+#ifndef ROCKCHIP_OMX_DEF
+#define ROCKCHIP_OMX_DEF
+
+#include "OMX_Types.h"
+#include "OMX_IVCommon.h"
+
+#define VERSIONMAJOR_NUMBER 1
+#define VERSIONMINOR_NUMBER 0
+#define REVISION_NUMBER 0
+#define STEP_NUMBER 0
+
+
+#define MAX_OMX_COMPONENT_NUM 20
+#define MAX_OMX_COMPONENT_ROLE_NUM 20
+#define MAX_OMX_COMPONENT_NAME_SIZE OMX_MAX_STRINGNAME_SIZE
+#define MAX_OMX_COMPONENT_ROLE_SIZE OMX_MAX_STRINGNAME_SIZE
+#define MAX_OMX_COMPONENT_LIBNAME_SIZE OMX_MAX_STRINGNAME_SIZE * 2
+#define MAX_OMX_MIMETYPE_SIZE OMX_MAX_STRINGNAME_SIZE
+
+#define MAX_TIMESTAMP 40
+#define MAX_FLAGS 40
+#define MAX_BUFFER_REF 40
+
+#define MAX_BUFFER_PLANE 1
+
+#define ROCKCHIP_OMX_INSTALL_PATH "/system/lib/"
+
+/* note: must sync with gralloc */
+typedef enum _ANB_PRIVATE_BUF_TYPE {
+ ANB_PRIVATE_BUF_NONE = 0,
+ ANB_PRIVATE_BUF_VIRTUAL = 0x01,
+ ANB_PRIVATE_BUF_BUTT,
+} ANB_PRIVATE_BUF_TYPE;
+
+typedef enum _ROCKCHIP_CODEC_TYPE {
+ SW_CODEC,
+ HW_VIDEO_DEC_CODEC,
+ HW_VIDEO_ENC_CODEC,
+} ROCKCHIP_CODEC_TYPE;
+
+typedef struct _ROCKCHIP_OMX_PRIORITYMGMTTYPE {
+ OMX_U32 nGroupPriority; /* the value 0 represents the highest priority */
+ /* for a group of components */
+ OMX_U32 nGroupID;
+} ROCKCHIP_OMX_PRIORITYMGMTTYPE;
+
+typedef enum _ROCKCHIP_OMX_INDEXTYPE {
+#define ROCKCHIP_INDEX_PARAM_ENABLE_THUMBNAIL "OMX.SEC.index.enableThumbnailMode"
+ OMX_IndexParamEnableThumbnailMode = 0x7F000001,
+#define ROCKCHIP_INDEX_CONFIG_VIDEO_INTRAPERIOD "OMX.SEC.index.VideoIntraPeriod"
+ OMX_IndexConfigVideoIntraPeriod = 0x7F000002,
+
+ /* for Android Native Window */
+#define ROCKCHIP_INDEX_PARAM_ENABLE_ANB "OMX.google.android.index.enableAndroidNativeBuffers"
+ OMX_IndexParamEnableAndroidBuffers = 0x7F000011,
+#define ROCKCHIP_INDEX_PARAM_GET_ANB_Usage "OMX.google.android.index.getAndroidNativeBufferUsage"
+ OMX_IndexParamGetAndroidNativeBufferUsage = 0x7F000012,
+#define ROCKCHIP_INDEX_PARAM_USE_ANB "OMX.google.android.index.useAndroidNativeBuffer2"
+ OMX_IndexParamUseAndroidNativeBuffer = 0x7F000013,
+ /* for Android Store Metadata Inbuffer */
+#define ROCKCHIP_INDEX_PARAM_STORE_METADATA_BUFFER "OMX.google.android.index.storeMetaDataInBuffers"
+ OMX_IndexParamStoreMetaDataBuffer = 0x7F000014,
+ /* prepend SPS/PPS to I/IDR for H.264 Encoder */
+#define ROCKCHIP_INDEX_PARAM_PREPEND_SPSPPS_TO_IDR "OMX.google.android.index.prependSPSPPSToIDRFrames"
+ OMX_IndexParamPrependSPSPPSToIDR = 0x7F000015,
+
+#define ROCKCHIP_INDEX_PREPARE_ADAPTIVE_PLAYBACK "OMX.google.android.index.prepareForAdaptivePlayback"
+ OMX_IndexParamprepareForAdaptivePlayback = 0x7F000016,
+
+#define ROCKCHIP_INDEX_DESCRIBE_COLORFORMAT "OMX.google.android.index.describeColorFormat"
+ OMX_IndexParamdescribeColorFormat = 0x7F000017,
+
+#define ROCKCHIP_INDEX_PARAM_ROCKCHIP_DEC_EXTENSION_DIV3 "OMX.rk.index.decoder.extension.div3"
+ OMX_IndexParamRkDecoderExtensionDiv3 = 0x7F050000,
+#define ROCKCHIP_INDEX_PARAM_ROCKCHIP_DEC_EXTENSION_USE_DTS "OMX.rk.index.decoder.extension.useDts"
+ OMX_IndexParamRkDecoderExtensionUseDts = 0x7F050001,
+#define ROCKCHIP_INDEX_PARAM_ROCKCHIP_DEC_EXTENSION_THUMBNAIL "OMX.rk.index.decoder.extension.thumbNail"
+ OMX_IndexParamRkDecoderExtensionThumbNail = 0x7F050002,
+
+
+
+
+ /* for Android PV OpenCore*/
+ OMX_COMPONENT_CAPABILITY_TYPE_INDEX = 0xFF7A347
+} ROCKCHIP_OMX_INDEXTYPE;
+
+typedef enum _ROCKCHIP_OMX_ERRORTYPE {
+ OMX_ErrorNoEOF = (OMX_S32) 0x90000001,
+ OMX_ErrorInputDataDecodeYet = (OMX_S32) 0x90000002,
+ OMX_ErrorInputDataEncodeYet = (OMX_S32) 0x90000003,
+ OMX_ErrorCodecInit = (OMX_S32) 0x90000004,
+ OMX_ErrorCodecDecode = (OMX_S32) 0x90000005,
+ OMX_ErrorCodecEncode = (OMX_S32) 0x90000006,
+ OMX_ErrorCodecFlush = (OMX_S32) 0x90000007,
+ OMX_ErrorOutputBufferUseYet = (OMX_S32) 0x90000008
+} ROCKCHIP_OMX_ERRORTYPE;
+
+typedef enum _ROCKCHIP_OMX_COMMANDTYPE {
+ ROCKCHIP_OMX_CommandComponentDeInit = 0x7F000001,
+ ROCKCHIP_OMX_CommandEmptyBuffer,
+ ROCKCHIP_OMX_CommandFillBuffer,
+ ROCKCHIP_OMX_CommandFakeBuffer
+} ROCKCHIP_OMX_COMMANDTYPE;
+
+typedef enum _ROCKCHIP_OMX_TRANS_STATETYPE {
+ ROCKCHIP_OMX_TransStateInvalid,
+ ROCKCHIP_OMX_TransStateLoadedToIdle,
+ ROCKCHIP_OMX_TransStateIdleToExecuting,
+ ROCKCHIP_OMX_TransStateExecutingToIdle,
+ ROCKCHIP_OMX_TransStateIdleToLoaded,
+ ROCKCHIP_OMX_TransStateMax = 0X7FFFFFFF
+} ROCKCHIP_OMX_TRANS_STATETYPE;
+
+typedef enum _ROCKCHIP_OMX_COLOR_FORMATTYPE {
+
+ /* to copy a encoded data for drm component using gsc or fimc */
+ OMX_SEC_COLOR_FormatEncodedData = OMX_COLOR_FormatYCbYCr,
+ /* for Android SurfaceMediaSource*/
+ OMX_COLOR_FormatAndroidOpaque = 0x7F000789,
+ OMX_COLOR_FormatYUV420Flexible = 0x7F420888
+} ROCKCHIP_OMX_COLOR_FORMATTYPE;
+
+typedef enum _ROCKCHIP_OMX_SUPPORTFORMAT_TYPE {
+ supportFormat_0 = 0x00,
+ supportFormat_1,
+ supportFormat_2,
+ supportFormat_3,
+ supportFormat_4,
+ supportFormat_5,
+ supportFormat_6,
+ supportFormat_7
+} ROCKCHIP_OMX_SUPPORTFORMAT_TYPE;
+
+typedef enum _ROCKCHIP_OMX_BUFFERPROCESS_TYPE {
+ BUFFER_DEFAULT = 0x00,
+ BUFFER_COPY = 0x01,
+ BUFFER_SHARE = 0x02,
+ BUFFER_METADATA = 0x04,
+ BUFFER_ANBSHARE = 0x08
+} ROCKCHIP_OMX_BUFFERPROCESS_TYPE;
+
+typedef struct _ROCKCHIP_OMX_VIDEO_PROFILELEVEL {
+ OMX_S32 profile;
+ OMX_S32 level;
+} ROCKCHIP_OMX_VIDEO_PROFILELEVEL;
+
+typedef struct _ROCKCHIP_OMX_VIDEO_THUMBNAILMODE {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_U32 nPortIndex;
+ OMX_BOOL bEnable;
+} ROCKCHIP_OMX_VIDEO_THUMBNAILMODE;
+
+typedef enum _ROCKCHIP_VIDEO_CODINGTYPE_EXT {
+ OMX_VIDEO_CodingFLV1 = 0x01000000, /**< Sorenson H.263 */
+ OMX_VIDEO_CodingDIVX3, /**< DIVX3 */
+ OMX_VIDEO_CodingVP6, /**< VP6 */
+ OMX_VIDEO_CodingVC1, /**< VP6 */
+ OMX_VIDEO_OLD_CodingHEVC,
+} ROCKCHIP_VIDEO_CODINGTYPE_EXT;
+
+typedef enum {
+ UNSUPPORT_PROFILE = -1,
+ BASELINE_PROFILE = 66,
+ MAIN_PROFILE = 77,
+ HIGHT_PROFILE = 100,
+} EncProfile;
+
+
+
+
+/** HEVC Profile enum type */
+typedef enum OMX_VIDEO_HEVCPROFILETYPE {
+ OMX_VIDEO_HEVCProfileUnknown = 0x0,
+ OMX_VIDEO_HEVCProfileMain = 0x1,
+ OMX_VIDEO_HEVCProfileMain10 = 0x2,
+ OMX_VIDEO_HEVCProfileMax = 0x7FFFFFFF
+} OMX_VIDEO_HEVCPROFILETYPE;
+
+/** HEVC Level enum type */
+typedef enum OMX_VIDEO_HEVCLEVELTYPE {
+ OMX_VIDEO_HEVCLevelUnknown = 0x0,
+ OMX_VIDEO_HEVCMainTierLevel1 = 0x1,
+ OMX_VIDEO_HEVCHighTierLevel1 = 0x2,
+ OMX_VIDEO_HEVCMainTierLevel2 = 0x4,
+ OMX_VIDEO_HEVCHighTierLevel2 = 0x8,
+ OMX_VIDEO_HEVCMainTierLevel21 = 0x10,
+ OMX_VIDEO_HEVCHighTierLevel21 = 0x20,
+ OMX_VIDEO_HEVCMainTierLevel3 = 0x40,
+ OMX_VIDEO_HEVCHighTierLevel3 = 0x80,
+ OMX_VIDEO_HEVCMainTierLevel31 = 0x100,
+ OMX_VIDEO_HEVCHighTierLevel31 = 0x200,
+ OMX_VIDEO_HEVCMainTierLevel4 = 0x400,
+ OMX_VIDEO_HEVCHighTierLevel4 = 0x800,
+ OMX_VIDEO_HEVCMainTierLevel41 = 0x1000,
+ OMX_VIDEO_HEVCHighTierLevel41 = 0x2000,
+ OMX_VIDEO_HEVCMainTierLevel5 = 0x4000,
+ OMX_VIDEO_HEVCHighTierLevel5 = 0x8000,
+ OMX_VIDEO_HEVCMainTierLevel51 = 0x10000,
+ OMX_VIDEO_HEVCHighTierLevel51 = 0x20000,
+ OMX_VIDEO_HEVCMainTierLevel52 = 0x40000,
+ OMX_VIDEO_HEVCHighTierLevel52 = 0x80000,
+ OMX_VIDEO_HEVCMainTierLevel6 = 0x100000,
+ OMX_VIDEO_HEVCHighTierLevel6 = 0x200000,
+ OMX_VIDEO_HEVCMainTierLevel61 = 0x400000,
+ OMX_VIDEO_HEVCHighTierLevel61 = 0x800000,
+ OMX_VIDEO_HEVCMainTierLevel62 = 0x1000000,
+ OMX_VIDEO_HEVCHighTierLevel62 = 0x2000000,
+ OMX_VIDEO_HEVCHighTiermax = 0x7FFFFFFF
+} OMX_VIDEO_HEVCLEVELTYPE;
+
+#if 0
+typedef struct _ROCKCHIP_PARAM_ENABLE_NATIVEBUFFER {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_U32 nPortIndex;
+ OMX_BOOL bEnable;
+} ROCKCHIP_PARAM_ENABLE_NATIVEBUFFER;
+
+typedef struct _ROCKCHIP_PARAM_NATIVEBUFFER_USAGE {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_U32 nPortIndex;
+ OMX_U32 nUsage;
+} ROCKCHIP_PARAM_NATIVEBUFFER_USAGE;
+
+typedef struct _StoreMetaDataInBuffersParams {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_U32 nPortIndex;
+ OMX_BOOL bStoreMetaData;
+} StoreMetaDataInBuffersParams;
+
+typedef struct _PrependSPSPPSToIDRFramesParams {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_BOOL bEnable;
+} PrependSPSPPSToIDRFramesParams;
+
+typedef enum {
+
+ /*
+ * kMetadataBufferTypeCameraSource is used to indicate that
+ * the source of the metadata buffer is the camera component.
+ */
+ kMetadataBufferTypeCameraSource = 0,
+
+ /*
+ * kMetadataBufferTypeGrallocSource is used to indicate that
+ * the payload of the metadata buffers can be interpreted as
+ * a buffer_handle_t.
+ * So in this case,the metadata that the encoder receives
+ * will have a byte stream that consists of two parts:
+ * 1. First, there is an integer indicating that it is a GRAlloc
+ * source (kMetadataBufferTypeGrallocSource)
+ * 2. This is followed by the buffer_handle_t that is a handle to the
+ * GRalloc buffer. The encoder needs to interpret this GRalloc handle
+ * and encode the frames.
+ * --------------------------------------------------------------
+ * | kMetadataBufferTypeGrallocSource | sizeof(buffer_handle_t) |
+ * --------------------------------------------------------------
+ */
+ kMetadataBufferTypeGrallocSource = 1,
+
+ // Add more here...
+
+} MetadataBufferType;
+
+#endif
+
+typedef struct _RockchipVideoPlane {
+ void *addr;
+ OMX_U32 allocSize;
+ OMX_U32 dataSize;
+ unsigned long offset;
+ int fd;
+ int type;
+ OMX_U32 stride;
+} RockchipVideoPlane;
+
+
+
+
+#ifndef __OMX_EXPORTS
+#define __OMX_EXPORTS
+#define ROCKCHIP_EXPORT_REF __attribute__((visibility("default")))
+#define ROCKCHIP_IMPORT_REF __attribute__((visibility("default")))
+#endif
+
+#endif
diff --git a/component/video/dec/libcodec_intel_sec.so b/component/video/dec/libcodec_intel_sec.so
new file mode 100644
index 0000000..2429a4b
--- /dev/null
+++ b/component/video/dec/libcodec_intel_sec.so
Binary files differ
diff --git a/component/video/dec/library_register.c b/component/video/dec/library_register.c
new file mode 100644
index 0000000..48f4e7c
--- /dev/null
+++ b/component/video/dec/library_register.c
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright 2013 rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file library_register.c
+ * @brief
+ * @author Csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.27 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#include "Rockchip_OSAL_Memory.h"
+#include "Rockchip_OSAL_ETC.h"
+#include "library_register.h"
+#include "Rockchip_OSAL_Log.h"
+
+
+OSCL_EXPORT_REF int Rockchip_OMX_COMPONENT_Library_Register(RockchipRegisterComponentType **rockchipComponents)
+{
+ FunctionIn();
+
+ if (rockchipComponents == NULL)
+ goto EXIT;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[0]->componentName, RK_OMX_COMPONENT_H264_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[0]->roles[0], RK_OMX_COMPONENT_H264_DEC_ROLE);
+ rockchipComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[1]->componentName, RK_OMX_COMPONENT_MPEG4_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[1]->roles[0], RK_OMX_COMPONENT_MPEG4_DEC_ROLE);
+ rockchipComponents[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[2]->componentName, RK_OMX_COMPONENT_H263_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[2]->roles[0], RK_OMX_COMPONENT_H263_DEC_ROLE);
+ rockchipComponents[2]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[3]->componentName, RK_OMX_COMPONENT_FLV_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[3]->roles[0], RK_OMX_COMPONENT_FLV_DEC_ROLE);
+ rockchipComponents[3]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[4]->componentName, RK_OMX_COMPONENT_MPEG2_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[4]->roles[0], RK_OMX_COMPONENT_MPEG2_DEC_ROLE);
+ rockchipComponents[4]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[5]->componentName, RK_OMX_COMPONENT_RMVB_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[5]->roles[0], RK_OMX_COMPONENT_RMVB_DEC_ROLE);
+ rockchipComponents[5]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[6]->componentName, RK_OMX_COMPONENT_VP8_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[6]->roles[0], RK_OMX_COMPONENT_VP8_DEC_ROLE);
+ rockchipComponents[6]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[7]->componentName, RK_OMX_COMPONENT_VC1_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[7]->roles[0], RK_OMX_COMPONENT_VC1_DEC_ROLE);
+ rockchipComponents[7]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[8]->componentName, RK_OMX_COMPONENT_WMV3_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[8]->roles[0], RK_OMX_COMPONENT_WMV3_DEC_ROLE);
+ rockchipComponents[8]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[9]->componentName, RK_OMX_COMPONENT_VP6_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[9]->roles[0], RK_OMX_COMPONENT_VP6_DEC_ROLE);
+ rockchipComponents[9]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[10]->componentName, RK_OMX_COMPONENT_HEVC_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[10]->roles[0], RK_OMX_COMPONENT_HEVC_DEC_ROLE);
+ rockchipComponents[10]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[11]->componentName, RK_OMX_COMPONENT_MJPEG_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[11]->roles[0], RK_OMX_COMPONENT_MJPEG_DEC_ROLE);
+ rockchipComponents[11]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[12]->componentName, RK_OMX_COMPONENT_H264_DRM_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[12]->roles[0], RK_OMX_COMPONENT_H264_DEC_ROLE);
+ rockchipComponents[12]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[13]->componentName, RK_OMX_COMPONENT_VP9_DEC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[13]->roles[0], RK_OMX_COMPONENT_VP9_DEC_ROLE);
+ rockchipComponents[13]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+EXIT:
+ FunctionOut();
+
+ return MAX_COMPONENT_NUM;
+}
diff --git a/component/video/dec/library_register.h b/component/video/dec/library_register.h
new file mode 100644
index 0000000..aee7b31
--- /dev/null
+++ b/component/video/dec/library_register.h
@@ -0,0 +1,92 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file library_register.h
+ * @brief
+ * @author Csy (csy@rockchip.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.27 : Create
+ */
+
+#ifndef ROCKCHIP_OMX_DEC_REG
+#define ROCKCHIP_OMX_DEC_REG
+
+#include "Rockchip_OMX_Def.h"
+#include "OMX_Component.h"
+#include "Rockchip_OMX_Component_Register.h"
+
+
+#define OSCL_EXPORT_REF __attribute__((visibility("default")))
+#define MAX_COMPONENT_NUM 14
+#define MAX_COMPONENT_ROLE_NUM 14
+
+#define RK_OMX_COMPONENT_H264_DEC "OMX.rk.video_decoder.avc"
+#define RK_OMX_COMPONENT_H264_DRM_DEC "OMX.rk.video_decoder.avc.secure"
+
+#define RK_OMX_COMPONENT_H264_DEC_ROLE "video_decoder.avc"
+
+#define RK_OMX_COMPONENT_MPEG4_DEC "OMX.rk.video_decoder.m4v"
+#define RK_OMX_COMPONENT_MPEG4_DEC_ROLE "video_decoder.mpeg4"
+
+#define RK_OMX_COMPONENT_H263_DEC "OMX.rk.video_decoder.h263"
+#define RK_OMX_COMPONENT_H263_DEC_ROLE "video_decoder.h263"
+
+#define RK_OMX_COMPONENT_FLV_DEC "OMX.rk.video_decoder.flv1"
+#define RK_OMX_COMPONENT_FLV_DEC_ROLE "video_decoder.flv1"
+
+#define RK_OMX_COMPONENT_MPEG2_DEC "OMX.rk.video_decoder.m2v"
+#define RK_OMX_COMPONENT_MPEG2_DEC_ROLE "video_decoder.mpeg2"
+
+#define RK_OMX_COMPONENT_RMVB_DEC "OMX.rk.video_decoder.rv"
+#define RK_OMX_COMPONENT_RMVB_DEC_ROLE "video_decoder.rv"
+
+#define RK_OMX_COMPONENT_VP8_DEC "OMX.rk.video_decoder.vp8"
+#define RK_OMX_COMPONENT_VP8_DEC_ROLE "video_decoder.vp8"
+
+#define RK_OMX_COMPONENT_VC1_DEC "OMX.rk.video_decoder.vc1"
+#define RK_OMX_COMPONENT_VC1_DEC_ROLE "video_decoder.vc1"
+
+#define RK_OMX_COMPONENT_WMV3_DEC "OMX.rk.video_decoder.wmv3"
+#define RK_OMX_COMPONENT_WMV3_DEC_ROLE "video_decoder.wmv3"
+
+#define RK_OMX_COMPONENT_VP6_DEC "OMX.rk.video_decoder.vp6"
+#define RK_OMX_COMPONENT_VP6_DEC_ROLE "video_decoder.vp6"
+
+#define RK_OMX_COMPONENT_HEVC_DEC "OMX.rk.video_decoder.hevc"
+#define RK_OMX_COMPONENT_HEVC_DEC_ROLE "video_decoder.hevc"
+
+#define RK_OMX_COMPONENT_MJPEG_DEC "OMX.rk.video_decoder.mjpeg"
+#define RK_OMX_COMPONENT_MJPEG_DEC_ROLE "video_decoder.mjpeg"
+
+#define RK_OMX_COMPONENT_VP9_DEC "OMX.rk.video_decoder.vp9"
+#define RK_OMX_COMPONENT_VP9_DEC_ROLE "video_decoder.vp9"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSCL_EXPORT_REF int Rockchip_OMX_COMPONENT_Library_Register(RockchipRegisterComponentType **rockchipComponents);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
+
diff --git a/component/video/enc/Android.mk b/component/video/enc/Android.mk
new file mode 100644
index 0000000..21d71e9
--- /dev/null
+++ b/component/video/enc/Android.mk
@@ -0,0 +1,55 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ Rkvpu_OMX_VencControl.c \
+ Rkvpu_OMX_Venc.c \
+ library_register.c
+
+LOCAL_MODULE := libomxvpu_enc
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_C_INCLUDES := $(ROCKCHIP_OMX_INC)/khronos \
+ $(ROCKCHIP_OMX_INC)/rockchip \
+ $(ROCKCHIP_OMX_TOP)/osal \
+ $(ROCKCHIP_OMX_TOP)/core \
+ $(ROCKCHIP_OMX_COMPONENT)/common \
+ $(ROCKCHIP_OMX_COMPONENT)/video/enc \
+ $(TOP)/hardware/rockchip/librkvpu \
+ $(TOP)/hardware/rockchip/librkvpu/omx_get_gralloc_private
+
+LOCAL_STATIC_LIBRARIES := libRkOMX_OSAL \
+ libRkOMX_Basecomponent
+
+LOCAL_SHARED_LIBRARIES := libc \
+ libdl \
+ libcutils \
+ libutils \
+ liblog \
+ libui \
+ libRkOMX_Resourcemanager \
+ libhardware \
+ libvpu \
+ libgralloc_priv_omx
+
+ifeq ($(BOARD_USE_ANB), true)
+LOCAL_CFLAGS += -DUSE_ANB
+endif
+
+ifeq ($(BOARD_USE_STOREMETADATA), true)
+LOCAL_CFLAGS += -DUSE_STOREMETADATA
+endif
+
+ifeq ($(BOARD_CONFIG_3GR),true)
+ LOCAL_CFLAGS += -DSOFIA_3GR \
+ -DROCKCHIP_GPU_LIB_ENABLE
+
+endif
+
+
+ifeq ($(OMX_USE_DRM), true)
+LOCAL_SHARED_LIBRARIES += librga
+endif
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/component/video/enc/Rkvpu_OMX_Venc.c b/component/video/enc/Rkvpu_OMX_Venc.c
new file mode 100755
index 0000000..3104851
--- /dev/null
+++ b/component/video/enc/Rkvpu_OMX_Venc.c
@@ -0,0 +1,1732 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rkvpu_OMX_Venc.c
+ * @brief
+ * @author csy (csy@rock-chips.com)
+ * @version 2.0.0
+ * @history
+ * 2013.11.28 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <dlfcn.h>
+#include <hardware/hardware.h>
+#include "Rockchip_OMX_Macros.h"
+#include "Rockchip_OSAL_Event.h"
+#include "Rkvpu_OMX_Venc.h"
+#include "Rkvpu_OMX_VencControl.h"
+#include "Rockchip_OMX_Basecomponent.h"
+#include "Rockchip_OSAL_Thread.h"
+#include "Rockchip_OSAL_Semaphore.h"
+#include "Rockchip_OSAL_Mutex.h"
+#include "Rockchip_OSAL_ETC.h"
+#include "Rockchip_OSAL_SharedMemory.h"
+#include "Rockchip_OSAL_RGA_Process.h"
+#include "hardware/rga.h"
+#include "vpu_type.h"
+#include "gralloc_priv_omx.h"
+
+#ifdef USE_ANB
+#include "Rockchip_OSAL_Android.h"
+#endif
+
+#undef ROCKCHIP_LOG_TAG
+#define ROCKCHIP_LOG_TAG "ROCKCHIP_VIDEO_ENC"
+#define ROCKCHIP_LOG_OFF
+//#define ROCKCHIP_TRACE_ON
+#include "Rockchip_OSAL_Log.h"
+
+/* Using for the encode rate statistic*/
+#ifdef ENCODE_RATE_STATISTIC
+#define STATISTIC_PER_TIME 5 // statistic once per 5s
+struct timeval nowGetTime;
+static OMX_U64 lastEncodeTime = 0;
+static OMX_U64 currentEncodeTime = 0;
+static OMX_U32 lastEncodeFrameCount = 0;
+static OMX_U32 currentEncodeFrameCount = 0;
+#endif
+
+/**
+This enumeration is for levels. The value follows the level_idc in sequence
+parameter set rbsp. See Annex A.
+@published All
+*/
+typedef enum AVCLevel {
+ AVC_LEVEL_AUTO = 0,
+ AVC_LEVEL1_B = 9,
+ AVC_LEVEL1 = 10,
+ AVC_LEVEL1_1 = 11,
+ AVC_LEVEL1_2 = 12,
+ AVC_LEVEL1_3 = 13,
+ AVC_LEVEL2 = 20,
+ AVC_LEVEL2_1 = 21,
+ AVC_LEVEL2_2 = 22,
+ AVC_LEVEL3 = 30,
+ AVC_LEVEL3_1 = 31,
+ AVC_LEVEL3_2 = 32,
+ AVC_LEVEL4 = 40,
+ AVC_LEVEL4_1 = 41,
+ AVC_LEVEL4_2 = 42,
+ AVC_LEVEL5 = 50,
+ AVC_LEVEL5_1 = 51
+} AVCLevel;
+
+typedef enum HEVCLevel {
+ HEVC_UNSUPPORT_LEVEL = -1,
+ HEVC_LEVEL4_1 = 0,
+ HEVC_LEVEL_MAX = 0x7FFFFFFF,
+} HEVCLevel;
+
+typedef struct {
+ OMX_RK_VIDEO_CODINGTYPE codec_id;
+ OMX_VIDEO_CODINGTYPE omx_id;
+} CodeMap;
+
+
+static const CodeMap kCodeMap[] = {
+ { OMX_RK_VIDEO_CodingAVC, OMX_VIDEO_CodingAVC},
+ { OMX_RK_VIDEO_CodingVP8, OMX_VIDEO_CodingVP8},
+ { OMX_RK_VIDEO_CodingHEVC, OMX_VIDEO_CodingHEVC},
+};
+
+int calc_plane(int width, int height)
+{
+ int mbX, mbY;
+
+ mbX = (width + 15) / 16;
+ mbY = (height + 15) / 16;
+
+ /* Alignment for interlaced processing */
+ mbY = (mbY + 1) / 2 * 2;
+
+ return (mbX * 16) * (mbY * 16);
+}
+
+void UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *rockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *rockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+
+ if ((rockchipOutputPort->portDefinition.format.video.nFrameWidth !=
+ rockchipInputPort->portDefinition.format.video.nFrameWidth) ||
+ (rockchipOutputPort->portDefinition.format.video.nFrameHeight !=
+ rockchipInputPort->portDefinition.format.video.nFrameHeight)) {
+ OMX_U32 width = 0, height = 0;
+
+ rockchipOutputPort->portDefinition.format.video.nFrameWidth =
+ rockchipInputPort->portDefinition.format.video.nFrameWidth;
+ rockchipOutputPort->portDefinition.format.video.nFrameHeight =
+ rockchipInputPort->portDefinition.format.video.nFrameHeight;
+ width = rockchipOutputPort->portDefinition.format.video.nStride =
+ rockchipInputPort->portDefinition.format.video.nStride;
+ height = rockchipOutputPort->portDefinition.format.video.nSliceHeight =
+ rockchipInputPort->portDefinition.format.video.nSliceHeight;
+
+ switch (rockchipOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ if (width && height)
+ rockchipOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
+ break;
+ default:
+ if (width && height)
+ rockchipOutputPort->portDefinition.nBufferSize = width * height * 2;
+ break;
+ }
+ }
+
+ return;
+}
+
+OMX_BOOL Rkvpu_Check_BufferProcess_State(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 nPortIndex)
+{
+ OMX_BOOL ret = OMX_FALSE;
+
+ if ((pRockchipComponent->currentState == OMX_StateExecuting) &&
+ (pRockchipComponent->pRockchipPort[nPortIndex].portState == OMX_StateIdle) &&
+ (pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateExecutingToIdle) &&
+ (pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateIdleToExecuting)) {
+ ret = OMX_TRUE;
+ } else {
+ ret = OMX_FALSE;
+ }
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_ResetAllPortConfig(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *pRockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+
+ /* Input port */
+ pRockchipInputPort->portDefinition.format.video.nFrameWidth = DEFAULT_ENC_FRAME_WIDTH;
+ pRockchipInputPort->portDefinition.format.video.nFrameHeight = DEFAULT_ENC_FRAME_HEIGHT;
+ pRockchipInputPort->portDefinition.format.video.nStride = 0; /*DEFAULT_ENC_FRAME_WIDTH;*/
+ pRockchipInputPort->portDefinition.format.video.nSliceHeight = 0;
+ pRockchipInputPort->portDefinition.nBufferSize = DEFAULT_VIDEOENC_INPUT_BUFFER_SIZE;
+ pRockchipInputPort->portDefinition.format.video.pNativeRender = 0;
+ pRockchipInputPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pRockchipInputPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+ pRockchipInputPort->portDefinition.bEnabled = OMX_TRUE;
+ pRockchipInputPort->bufferProcessType = BUFFER_COPY;
+ pRockchipInputPort->portWayType = WAY2_PORT;
+
+ /* Output port */
+ pRockchipOutputPort->portDefinition.format.video.nFrameWidth = DEFAULT_ENC_FRAME_WIDTH;
+ pRockchipOutputPort->portDefinition.format.video.nFrameHeight = DEFAULT_ENC_FRAME_HEIGHT;
+ pRockchipOutputPort->portDefinition.format.video.nStride = 0; /*DEFAULT_ENC_FRAME_WIDTH;*/
+ pRockchipOutputPort->portDefinition.format.video.nSliceHeight = 0;
+ pRockchipOutputPort->portDefinition.nBufferSize = DEFAULT_VIDEOENC_OUTPUT_BUFFER_SIZE;
+ pRockchipOutputPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+ Rockchip_OSAL_Memset(pRockchipOutputPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipOutputPort->portDefinition.format.video.cMIMEType, "raw/video");
+ pRockchipOutputPort->portDefinition.format.video.pNativeRender = 0;
+ pRockchipOutputPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pRockchipOutputPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
+ pRockchipOutputPort->portDefinition.nBufferCountActual = MAX_VIDEOENC_OUTPUTBUFFER_NUM;
+ pRockchipOutputPort->portDefinition.nBufferCountMin = MAX_VIDEOENC_OUTPUTBUFFER_NUM;
+ pRockchipOutputPort->portDefinition.nBufferSize = DEFAULT_VIDEOENC_OUTPUT_BUFFER_SIZE;
+ pRockchipOutputPort->portDefinition.bEnabled = OMX_TRUE;
+ pRockchipOutputPort->bufferProcessType = BUFFER_COPY | BUFFER_ANBSHARE;
+ pRockchipOutputPort->portWayType = WAY2_PORT;
+
+ return ret;
+}
+
+
+void Rkvpu_Wait_ProcessPause(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 nPortIndex)
+{
+ ROCKCHIP_OMX_BASEPORT *rockchipOMXInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *rockchipOMXOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *rockchipOMXPort = NULL;
+
+ FunctionIn();
+
+ rockchipOMXPort = &pRockchipComponent->pRockchipPort[nPortIndex];
+
+ if (((pRockchipComponent->currentState == OMX_StatePause) ||
+ (pRockchipComponent->currentState == OMX_StateIdle) ||
+ (pRockchipComponent->transientState == ROCKCHIP_OMX_TransStateLoadedToIdle) ||
+ (pRockchipComponent->transientState == ROCKCHIP_OMX_TransStateExecutingToIdle)) &&
+ (pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateIdleToLoaded) &&
+ (!CHECK_PORT_BEING_FLUSHED(rockchipOMXPort))) {
+ Rockchip_OSAL_SignalWait(pRockchipComponent->pRockchipPort[nPortIndex].pauseEvent, DEF_MAX_WAIT_TIME);
+ Rockchip_OSAL_SignalReset(pRockchipComponent->pRockchipPort[nPortIndex].pauseEvent);
+ }
+
+ FunctionOut();
+
+ return;
+}
+
+static void mpeg_rgb2yuv(unsigned char *src, unsigned char *dstY, unsigned char *dstUV, int width, int height, int src_format, int need_32align)
+{
+#define MIN(X, Y) ((X)<(Y)?(X):(Y))
+#define MAX(X, Y) ((X)>(Y)?(X):(Y))
+
+ int R, G, B;
+ int Y, U, V;
+ int i, j;
+ int stride = (width + 31) & (~31);
+
+ width = ((width + 15) & (~15));
+
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++) {
+ if (src_format == HAL_PIXEL_FORMAT_RGBA_8888) {
+ R = *src++;
+ G = *src++;
+ B = *src++;
+ src++;
+ } else {
+ B = *src++;
+ G = *src++;
+ R = *src++;
+ src++;
+ }
+
+ Y = (( 66 * R + 129 * G + 25 * B + 128) >> 8) + 16;
+
+ *dstY++ = (unsigned char)(MIN(MAX(0, Y), 0xff));
+ if ((i & 1) == 0 && (j & 1) == 0) {
+ U = ( ( -38 * R - 74 * G + 112 * B + 128) >> 8) + 128;
+ V = ( ( 112 * R - 94 * G - 18 * B + 128) >> 8) + 128;
+ *dstUV++ = (unsigned char)(MIN(MAX(0, U), 0xff));
+ *dstUV++ = (unsigned char)(MIN(MAX(0, V), 0xff));
+ }
+ }
+
+ if (need_32align) {
+ if (stride != width) {
+ src += (stride - width) * 4;
+ }
+ }
+
+ }
+}
+
+OMX_ERRORTYPE Rkvpu_Enc_ReConfig(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 new_width, OMX_U32 new_height)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ OMX_RK_VIDEO_CODINGTYPE codecId = OMX_RK_VIDEO_CodingUnused;
+ H264EncPictureType encType = VPU_H264ENC_YUV420_SEMIPLANAR;
+ VpuCodecContext_t *p_vpu_ctx = NULL;
+ EncParameter_t *EncParam;
+ EncParameter_t preEncParam;
+ Rockchip_OSAL_MutexLock(pVideoEnc->bRecofig_Mutex);
+ if (pVideoEnc->vpu_ctx) {
+ memset(&preEncParam, 0, sizeof(EncParameter_t));
+ pVideoEnc->vpu_ctx->control(pVideoEnc->vpu_ctx, VPU_API_ENC_GETCFG, &preEncParam);
+ if (pVideoEnc->rkvpu_close_cxt) {
+ pVideoEnc->rkvpu_close_cxt(&pVideoEnc->vpu_ctx);
+ }
+ }
+ if (pVideoEnc->vpu_ctx == NULL) {
+ if (pVideoEnc->rkvpu_open_cxt) {
+ pVideoEnc->rkvpu_open_cxt(&p_vpu_ctx);
+ }
+ }
+ p_vpu_ctx->width = new_width;
+ p_vpu_ctx->height = new_height;
+ p_vpu_ctx->codecType = CODEC_ENCODER;
+ {
+ int32_t kNumMapEntries = sizeof(kCodeMap) / sizeof(kCodeMap[0]);
+ int i = 0;
+ for (i = 0; i < kNumMapEntries; i++) {
+ if (kCodeMap[i].omx_id == pVideoEnc->codecId) {
+ codecId = kCodeMap[i].codec_id;
+ break;
+ }
+ }
+ }
+ p_vpu_ctx->videoCoding = codecId;
+ p_vpu_ctx->codecType = CODEC_ENCODER;
+ p_vpu_ctx->private_data = malloc(sizeof(EncParameter_t));
+ memcpy(p_vpu_ctx->private_data, &preEncParam, sizeof(EncParameter_t));
+ EncParam = (EncParameter_t*)p_vpu_ctx->private_data;
+ EncParam->height = new_height;
+ EncParam->width = new_width;
+ if (p_vpu_ctx) {
+ if (p_vpu_ctx->init(p_vpu_ctx, NULL, 0)) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_MutexUnlock(pVideoEnc->bRecofig_Mutex);
+ goto EXIT;
+
+ }
+ Rockchip_OSAL_Memcpy(pVideoEnc->bSpsPpsbuf, p_vpu_ctx->extradata, p_vpu_ctx->extradata_size);
+ pVideoEnc->bSpsPpsLen = p_vpu_ctx->extradata_size;
+ }
+ EncParam->rc_mode = 1;
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETCFG, EncParam);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_DEBUG, "set as nv12 format");
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETFORMAT, (void *)&encType);
+ pVideoEnc->vpu_ctx = p_vpu_ctx;
+ pVideoEnc->bPrependSpsPpsToIdr = OMX_TRUE;
+ Rockchip_OSAL_MutexUnlock(pVideoEnc->bRecofig_Mutex);
+EXIT:
+ FunctionOut();
+ return ret;
+}
+
+OMX_U32 Rkvpu_N12_Process(OMX_COMPONENTTYPE *pOMXComponent, RockchipVideoPlane *vplanes, OMX_U32 *aPhy_address)
+{
+
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pInPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *pOutPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ RK_U32 new_width = 0, new_height = 0, len = 0;
+ OMX_U32 Width_in = pOutPort->portDefinition.format.video.nFrameWidth;
+ OMX_U32 Height_in = pOutPort->portDefinition.format.video.nFrameHeight;
+ OMX_U32 Width = pOutPort->portDefinition.format.video.nFrameWidth;
+ OMX_U32 Height = pOutPort->portDefinition.format.video.nFrameHeight;
+
+ if (pVideoEnc->params_extend.bEnableScaling || pVideoEnc->params_extend.bEnableCropping) {
+ Rockchip_OSAL_MutexLock(pVideoEnc->bScale_Mutex);
+ if (pVideoEnc->params_extend.bEnableScaling) {
+ new_width = pVideoEnc->params_extend.ui16ScaledWidth;
+ new_height = pVideoEnc->params_extend.ui16ScaledHeight;
+ } else if (pVideoEnc->params_extend.bEnableCropping) {
+ new_width = Width_in - pVideoEnc->params_extend.ui16CropLeft - pVideoEnc->params_extend.ui16CropRight;
+ new_height = Height_in - pVideoEnc->params_extend.ui16CropTop - pVideoEnc->params_extend.ui16CropBottom;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "CropLeft = %d CropRight = %d CropTop %d CropBottom %d",
+ pVideoEnc->params_extend.ui16CropLeft, pVideoEnc->params_extend.ui16CropRight,
+ pVideoEnc->params_extend.ui16CropTop, pVideoEnc->params_extend.ui16CropBottom);
+ }
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "new_width = %d new_height = %d orign width %d orign height %d",
+ new_width, new_height, Width_in, Height_in);
+ if (new_width != pVideoEnc->bCurrent_width ||
+ new_height != pVideoEnc->bCurrent_height) {
+ pVideoEnc->bCurrent_width = new_width;
+ pVideoEnc->bCurrent_height = new_height;
+ Rkvpu_Enc_ReConfig(pOMXComponent, new_width, new_height);
+ }
+ rga_nv12_crop_scale(vplanes, pVideoEnc->enc_vpumem, &pVideoEnc->params_extend, Width, Height, pVideoEnc->rga_ctx);
+ *aPhy_address = pVideoEnc->enc_vpumem->phy_addr;
+ len = new_width * new_height * 3 / 2;
+ Rockchip_OSAL_MutexUnlock(pVideoEnc->bScale_Mutex);
+ } else {
+ Rockchip_OSAL_SharedMemory_getPhyAddress(pVideoEnc->hSharedMemory, vplanes->fd, aPhy_address);
+ len = Width * Height * 3 / 2;
+ }
+ return len;
+}
+#ifdef USE_STOREMETADATA
+OMX_ERRORTYPE Rkvpu_ProcessStoreMetaData(OMX_COMPONENTTYPE *pOMXComponent, OMX_BUFFERHEADERTYPE* pInputBuffer, OMX_U32 *aPhy_address, OMX_U32 *len)
+{
+
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pInPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *pOutPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+
+ OMX_U32 Width = pOutPort->portDefinition.format.video.nFrameWidth;
+ OMX_U32 Height = pOutPort->portDefinition.format.video.nFrameHeight;
+ OMX_PTR pGrallocHandle;
+ *len = 0;
+ *aPhy_address = 0;
+ if (!Rockchip_OSAL_GetInfoRkWfdMetaData(pInputBuffer->pBuffer, &pGrallocHandle)) {
+ if (!((ROCKCHIP_OMX_COLOR_FORMATTYPE)pInPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque)) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "Error colorformat != OMX_COLOR_FormatAndroidOpaque");
+ }
+ gralloc_private_handle_t priv_hnd_wfd;
+ Rockchip_OSAL_Memset(&priv_hnd_wfd, 0, sizeof(priv_hnd_wfd));
+ Rockchip_get_gralloc_private(pGrallocHandle, &priv_hnd_wfd);
+ if (VPUMemJudgeIommu() == 0) {
+ Rockchip_OSAL_SharedMemory_getPhyAddress(pVideoEnc->hSharedMemory, priv_hnd_wfd.share_fd, aPhy_address);
+ } else {
+ *aPhy_address = priv_hnd_wfd.share_fd;
+ }
+ *len = Width * Height * 4;
+ if ((pInputBuffer->nFilledLen == 24) || (pInputBuffer->nFilledLen == 8)){
+ if (pVideoEnc->bPixel_format < 0) {
+ pVideoEnc->bPixel_format = priv_hnd_wfd.format;
+ if (pVideoEnc->bPixel_format == HAL_PIXEL_FORMAT_RGBA_8888) {
+ H264EncPictureType encType = VPU_H264ENC_BGR888; // add by lance 2014.01.20
+ pVideoEnc->vpu_ctx->control(pVideoEnc->vpu_ctx, VPU_API_ENC_SETFORMAT, (void *)&encType);
+ } else {
+ H264EncPictureType encType = VPU_H264ENC_RGB888; // add by lance 2014.01.20
+ pVideoEnc->vpu_ctx->control(pVideoEnc->vpu_ctx, VPU_API_ENC_SETFORMAT, (void *)&encType);
+ }
+ }
+ }
+ } else {
+ RockchipVideoPlane vplanes;
+ OMX_COLOR_FORMATTYPE omx_format = 0;
+ OMX_U32 res;
+
+ if (pInputBuffer->nFilledLen != 8) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "MetaData buffer is wrong size! "
+ "(got %lu bytes, expected 8)", pInputBuffer->nFilledLen);
+ return OMX_ErrorBadParameter;
+ }
+ if (Rockchip_OSAL_GetInfoFromMetaData(pInputBuffer->pBuffer, &pGrallocHandle)) {
+ return OMX_ErrorBadParameter;
+ }
+
+ if (pVideoEnc->bPixel_format < 0) {
+ int gpu_fd = -1;
+ omx_format = Rockchip_OSAL_GetANBColorFormat(pGrallocHandle);
+ pVideoEnc->bPixel_format = Rockchip_OSAL_OMX2HalPixelFormat(omx_format);//mali_gpu
+ gpu_fd = open("/dev/pvrsrvkm", O_RDWR, 0);
+ if (gpu_fd > 0) {
+ pVideoEnc->bRgb2yuvFlag = OMX_TRUE;
+ close(gpu_fd);
+ } else {
+ if (pVideoEnc->bPixel_format == HAL_PIXEL_FORMAT_RGBA_8888) {
+ pVideoEnc->bRgb2yuvFlag = OMX_TRUE;
+ }
+ }
+ }
+ res = Rockchip_OSAL_getANBHandle(pGrallocHandle, &vplanes);
+ if (res != 0) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "%s: Unable to lock image buffer %p for access", __FUNCTION__,
+ pGrallocHandle);
+ pGrallocHandle = NULL;
+ return OMX_ErrorBadParameter;
+ }
+
+ if (pVideoEnc->bRgb2yuvFlag == OMX_TRUE) {
+ VPUMemLinear_t tmp_vpumem;
+ uint8_t *Y = (uint8_t*)pVideoEnc->enc_vpumem->vir_addr;
+ uint8_t *UV = Y + ((Width + 15) & (~15)) * Height;
+ memset(&tmp_vpumem, 0, sizeof(VPUMemLinear_t));
+ rga_rgb2nv12(&vplanes, pVideoEnc->enc_vpumem, Width, Height, pVideoEnc->rga_ctx);
+
+ VPUMemClean(pVideoEnc->enc_vpumem);
+ *aPhy_address = pVideoEnc->enc_vpumem->phy_addr;
+ *len = Width * Height * 3 / 2;
+#ifdef WRITE_FILE
+ VPUMemInvalidate(pVideoEnc->enc_vpumem);
+ fwrite(pVideoEnc->enc_vpumem->vir_addr, 1, Width * Height * 3 / 2, pVideoEnc->fp_h264);
+ fflush(pVideoEnc->fp_h264);
+#endif
+ } else if (pVideoEnc->bPixel_format == HAL_PIXEL_FORMAT_YCrCb_NV12) {
+ *len = Rkvpu_N12_Process(pOMXComponent, &vplanes, aPhy_address);
+ } else if (pVideoEnc->bPixel_format == HAL_PIXEL_FORMAT_YCbCr_420_888) {
+ EncParameter_t EncParam;
+ H264EncPictureType encType = VPU_H264ENC_YUV420_SEMIPLANAR;
+ pVideoEnc->vpu_ctx->control(pVideoEnc->vpu_ctx, VPU_API_ENC_SETFORMAT, (void *)&encType);
+ EncParam.rc_mode = 1 << 16; //set intraDeltaqp as 4 to fix encoder cts issue
+ pVideoEnc->vpu_ctx->control(pVideoEnc->vpu_ctx, VPU_API_ENC_SETCFG, (void*)&EncParam);
+
+ if (Width != vplanes.stride) {
+ rga_nv12_copy(&vplanes, pVideoEnc->enc_vpumem, Width, Height, pVideoEnc->rga_ctx);
+ *aPhy_address = pVideoEnc->enc_vpumem->phy_addr;
+#ifdef WRITE_FILE
+ fwrite(pVideoEnc->enc_vpumem->vir_addr, 1, Width * Height * 3 / 2, pVideoEnc->fp_rgb);
+ fflush(pVideoEnc->fp_rgb);
+#endif
+ } else {
+ Rockchip_OSAL_SharedMemory_getPhyAddress(pVideoEnc->hSharedMemory, vplanes.fd, aPhy_address);
+ }
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "aPhy_address = 0x%08x", *aPhy_address);
+ *len = Width * Height * 3 / 2;
+ } else {
+ rga_rgb_copy(&vplanes, pVideoEnc->enc_vpumem, Width, Height, pVideoEnc->rga_ctx);
+ *aPhy_address = pVideoEnc->enc_vpumem->phy_addr;
+ *len = Width * Height * 4;
+ }
+
+#if 0 // def WRITE_FILE
+ VPUMemInvalidate(pVideoEnc->enc_vpumem);
+ fwrite(pVideoEnc->enc_vpumem->vir_addr, 1, Width_in * Height_in * 4, pVideoEnc->fp_h264);
+ fflush(pVideoEnc->fp_h264);
+#endif
+ }
+ return OMX_ErrorNone;
+}
+#endif
+OMX_BOOL Rkvpu_SendInputData(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_U32 ret = OMX_FALSE;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *rockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_DATABUFFER *inputUseBuffer = &rockchipInputPort->way.port2WayDataBuffer.inputDataBuffer;
+ VpuCodecContext_t *p_vpu_ctx = pVideoEnc->vpu_ctx;
+ FunctionIn();
+
+ if (inputUseBuffer->dataValid == OMX_TRUE) {
+ EncInputStream_t aInput;
+
+ if (pVideoEnc->bFirstFrame) {
+ EncParameter_t vpug;
+ if ((ROCKCHIP_OMX_COLOR_FORMATTYPE)rockchipInputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque) {
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_GETCFG, (void*)&vpug);
+ vpug.rc_mode = 1;
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "set vpu_enc %d", vpug.rc_mode);
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETCFG, (void*)&vpug);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "VPU_API_ENC_SETFORMAT in");
+ H264EncPictureType encType = VPU_H264ENC_RGB888;
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETFORMAT, (void *)&encType);
+ } else if (rockchipInputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) {
+ H264EncPictureType encType = VPU_H264ENC_YUV420_PLANAR;
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETFORMAT, (void *)&encType);
+ }
+ pVideoEnc->bFirstFrame = OMX_FALSE;
+ }
+
+ if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "bSaveFlagEOS : OMX_TRUE");
+ pRockchipComponent->bSaveFlagEOS = OMX_TRUE;
+ }
+ Rockchip_OSAL_Memset(&aInput, 0, sizeof(EncInputStream_t));
+
+#ifdef USE_STOREMETADATA
+ if (pVideoEnc->bStoreMetaData && !pRockchipComponent->bSaveFlagEOS) {
+ OMX_U32 aPhy_address = 0, len = 0;
+
+ ret = Rkvpu_ProcessStoreMetaData(pOMXComponent, inputUseBuffer->bufferHeader, &aPhy_address, &len);
+ p_vpu_ctx = pVideoEnc->vpu_ctx; // may be reconfig in preprocess
+
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Rkvpu_ProcessStoreMetaData return %d ", ret);
+ Rkvpu_InputBufferReturn(pOMXComponent, inputUseBuffer);
+ pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pRockchipComponent->callbackData, OMX_EventError,
+ OUTPUT_PORT_INDEX,
+ OMX_IndexParamPortDefinition, NULL);
+ goto EXIT;
+ }
+ aInput.buf = NULL;
+ aInput.bufPhyAddr = aPhy_address;
+ aInput.size = len;
+ aInput.timeUs = inputUseBuffer->timeStamp;
+ } else {
+ OMX_BUFFERHEADERTYPE* pInputBuffer = inputUseBuffer->bufferHeader;
+ if (pInputBuffer->nFilledLen == 4) {
+ aInput.bufPhyAddr = *(int32_t*)((uint8_t*)pInputBuffer->pBuffer + pInputBuffer->nOffset);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "rk camera metadata 0x%x", aInput.bufPhyAddr);
+ aInput.buf = NULL;
+ } else {
+ aInput.buf = inputUseBuffer->bufferHeader->pBuffer + inputUseBuffer->usedDataLen;
+ aInput.bufPhyAddr = -1;
+ }
+ aInput.size = inputUseBuffer->dataLen;
+ aInput.timeUs = inputUseBuffer->timeStamp;
+ }
+#else
+ {
+ OMX_BUFFERHEADERTYPE* pInputBuffer = inputUseBuffer->bufferHeader;
+ if (pInputBuffer->nFilledLen == 4) {
+ aInput.bufPhyAddr = *(int32_t*)((uint8_t*)pInputBuffer->pBuffer + pInputBuffer->nOffset);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "rk camera metadata 0x%x", aInput.bufPhyAddr);
+ aInput.buf = NULL;
+ } else {
+ aInput.buf = inputUseBuffer->bufferHeader->pBuffer + inputUseBuffer->usedDataLen;
+ aInput.bufPhyAddr = -1;
+ }
+ aInput.size = inputUseBuffer->dataLen;
+ aInput.timeUs = inputUseBuffer->timeStamp;
+ }
+#endif
+
+ if ((ROCKCHIP_OMX_COLOR_FORMATTYPE)rockchipInputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque) {
+ if ((pVideoEnc->bRgb2yuvFlag == OMX_TRUE) || (pVideoEnc->bPixel_format == HAL_PIXEL_FORMAT_YCrCb_NV12)) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "set as nv12 format");
+ H264EncPictureType encType = VPU_H264ENC_YUV420_SEMIPLANAR;
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETFORMAT, (void *)&encType);
+ }
+ }
+
+ if (pVideoEnc->codecId == OMX_VIDEO_CodingAVC) {
+ if ((ROCKCHIP_OMX_COLOR_FORMATTYPE)rockchipInputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque) {
+ if (pVideoEnc->bFrame_num < 60 && (pVideoEnc->bFrame_num % 5 == 0)) {
+ EncParameter_t vpug;
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETIDRFRAME, NULL);
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_GETCFG, &vpug);
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETCFG, &vpug);
+ }
+ if (pVideoEnc->bFrame_num - pVideoEnc->bLast_config_frame == 60) {
+ EncParameter_t vpug;
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_GETCFG, &vpug);
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETCFG, &vpug);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "pVideoEnc->bFrame_num %d pVideoEnc->mLast_config_frame %d",
+ pVideoEnc->bFrame_num, pVideoEnc->bLast_config_frame);
+ pVideoEnc->bLast_config_frame = pVideoEnc->bFrame_num;
+
+ }
+ }
+ }
+
+ if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "send eos");
+ aInput.nFlags |= OMX_BUFFERFLAG_EOS;
+ }
+
+ p_vpu_ctx->encoder_sendframe(p_vpu_ctx, &aInput);
+
+ pVideoEnc->bFrame_num++;
+ Rkvpu_InputBufferReturn(pOMXComponent, inputUseBuffer);
+
+ if (pRockchipComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) {
+ pRockchipComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_TRUE;
+ pRockchipComponent->checkTimeStamp.startTimeStamp = inputUseBuffer->timeStamp;
+ pRockchipComponent->checkTimeStamp.nStartFlags = inputUseBuffer->nFlags;
+ pRockchipComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "first frame timestamp after seeking %lld us (%.2f secs)",
+ inputUseBuffer->timeStamp, inputUseBuffer->timeStamp / 1E6);
+ }
+ ret = OMX_TRUE;
+ }
+
+EXIT:
+ FunctionOut();
+ return ret;
+}
+
+OMX_BOOL Rkvpu_Post_OutputStream(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_BOOL ret = OMX_FALSE;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_DATABUFFER *outputUseBuffer = &pOutputPort->way.port2WayDataBuffer.outputDataBuffer;
+ VpuCodecContext_t *p_vpu_ctx = pVideoEnc->vpu_ctx;
+
+ FunctionIn();
+
+
+ if ((p_vpu_ctx == NULL) || (pVideoEnc->bEncSendEos == OMX_TRUE)) {
+ goto EXIT;
+ }
+ if (outputUseBuffer->dataValid == OMX_TRUE) {
+ OMX_U32 width = 0, height = 0;
+ int imageSize = 0;
+ EncoderOut_t pOutput;
+ OMX_U8 *aOut_buf = outputUseBuffer->bufferHeader->pBuffer;
+ Rockchip_OSAL_Memset(&pOutput, 0, sizeof(EncoderOut_t));
+ if ((OMX_FALSE == pVideoEnc->bSpsPpsHeaderFlag) && (pVideoEnc->codecId == OMX_VIDEO_CodingAVC)) {
+ if (pVideoEnc->bSpsPpsLen > 0) {
+ Rockchip_OSAL_Memcpy(aOut_buf, pVideoEnc->bSpsPpsbuf, pVideoEnc->bSpsPpsLen);
+ outputUseBuffer->remainDataLen = pVideoEnc->bSpsPpsLen;
+ outputUseBuffer->nFlags |= OMX_BUFFERFLAG_CODECCONFIG;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "set bSpsPpsLen %d", pVideoEnc->bSpsPpsLen);
+ pVideoEnc->bSpsPpsHeaderFlag = OMX_TRUE;
+ ret = OMX_TRUE;
+#if 0 //def WRITE_FILE
+ fwrite(aOut_buf, 1, pVideoEnc->bSpsPpsLen, pVideoEnc->fp_h264);
+ fflush(pVideoEnc->fp_h264);
+#endif
+ Rkvpu_OutputBufferReturn(pOMXComponent, outputUseBuffer);
+ goto EXIT;
+ }
+ }
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "encoder_getstream in ");
+ if (p_vpu_ctx->encoder_getstream(p_vpu_ctx, &pOutput) < 0) {
+ outputUseBuffer->dataLen = 0;
+ outputUseBuffer->remainDataLen = 0;
+ outputUseBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+ outputUseBuffer->timeStamp = 0;
+ ret = OMX_TRUE;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "OMX_BUFFERFLAG_EOS");
+ Rkvpu_OutputBufferReturn(pOMXComponent, outputUseBuffer);
+ pVideoEnc->bEncSendEos = OMX_TRUE;
+ goto EXIT;
+ }
+ if ((pOutput.size > 0) && (!CHECK_PORT_BEING_FLUSHED(pOutputPort))) {
+#ifdef ENCODE_RATE_STATISTIC
+ gettimeofday(&nowGetTime, NULL);
+ currentEncodeTime = nowGetTime.tv_sec * 1000000 + nowGetTime.tv_usec;
+ if (lastEncodeTime != 0) {
+ ++currentEncodeFrameCount;
+ if (currentEncodeTime - lastEncodeTime >= (STATISTIC_PER_TIME * 1000000)) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Statistic Encode Rate %d", ((currentEncodeFrameCount - lastEncodeFrameCount) / STATISTIC_PER_TIME));
+ lastEncodeTime = currentEncodeTime;
+ lastEncodeFrameCount = currentEncodeFrameCount;
+ }
+ } else
+ lastEncodeTime = currentEncodeTime;
+#endif
+ if (pVideoEnc->codecId == OMX_VIDEO_CodingAVC) {
+ if (pVideoEnc->bPrependSpsPpsToIdr && pOutput.keyFrame) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "IDR outputUseBuffer->remainDataLen %d spslen %d size %d", outputUseBuffer->remainDataLen
+ , pVideoEnc->bSpsPpsLen, outputUseBuffer->allocSize);
+ memcpy(aOut_buf, pVideoEnc->bSpsPpsbuf, pVideoEnc->bSpsPpsLen);
+ memcpy(aOut_buf + pVideoEnc->bSpsPpsLen, "\x00\x00\x00\x01", 4);
+ Rockchip_OSAL_Memcpy(aOut_buf + pVideoEnc->bSpsPpsLen + 4, pOutput.data, pOutput.size);
+ outputUseBuffer->remainDataLen = pVideoEnc->bSpsPpsLen + pOutput.size + 4;
+ outputUseBuffer->usedDataLen += pVideoEnc->bSpsPpsLen;
+ outputUseBuffer->usedDataLen += 4;
+ outputUseBuffer->usedDataLen += pOutput.size;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "IDR outputUseBuffer->remainDataLen 1 %d spslen %d size %d", outputUseBuffer->remainDataLen
+ , pVideoEnc->bSpsPpsLen, outputUseBuffer->allocSize);
+ } else {
+ memcpy(aOut_buf, "\x00\x00\x00\x01", 4);
+ Rockchip_OSAL_Memcpy(aOut_buf + 4, pOutput.data, pOutput.size);
+ outputUseBuffer->remainDataLen = pOutput.size + 4;
+ outputUseBuffer->usedDataLen += 4;
+ outputUseBuffer->usedDataLen += pOutput.size;
+ }
+#if 0 //def WRITE_FILE
+ fwrite(aOut_buf, 1, outputUseBuffer->remainDataLen , pVideoEnc->fp_h264);
+ fflush(pVideoEnc->fp_h264);
+#endif
+ } else {
+ Rockchip_OSAL_Memcpy(aOut_buf, pOutput.data, pOutput.size);
+ outputUseBuffer->remainDataLen = pOutput.size;
+ outputUseBuffer->usedDataLen = pOutput.size;
+ }
+
+ outputUseBuffer->timeStamp = pOutput.timeUs;
+ if (pOutput.keyFrame) {
+ outputUseBuffer->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+ }
+ if (pOutput.data) {
+ free(pOutput.data);
+ pOutput.data = NULL;
+ }
+ if ((outputUseBuffer->remainDataLen > 0) ||
+ ((outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) ||
+ (CHECK_PORT_BEING_FLUSHED(pOutputPort))) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_OutputBufferReturn");
+ Rkvpu_OutputBufferReturn(pOMXComponent, outputUseBuffer);
+ }
+ ret = OMX_TRUE;
+ } else if (CHECK_PORT_BEING_FLUSHED(pOutputPort)) {
+ if (pOutput.data) {
+ free(pOutput.data);
+ pOutput.data = NULL;
+ }
+ outputUseBuffer->dataLen = 0;
+ outputUseBuffer->remainDataLen = 0;
+ outputUseBuffer->nFlags = 0;
+ outputUseBuffer->timeStamp = 0;
+ ret = OMX_TRUE;
+ Rkvpu_OutputBufferReturn(pOMXComponent, outputUseBuffer);
+ } else {
+ //Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "output buffer is smaller than decoded data size Out Length");
+ // pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ // pRockchipComponent->callbackData,
+ // OMX_EventError, OMX_ErrorUndefined, 0, NULL);
+ ret = OMX_FALSE;
+ }
+ } else {
+ ret = OMX_FALSE;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_InputBufferProcess(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *rockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *rockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_DATABUFFER *srcInputUseBuffer = &rockchipInputPort->way.port2WayDataBuffer.inputDataBuffer;
+ OMX_BOOL bCheckInputData = OMX_FALSE;
+ OMX_BOOL bValidCodecData = OMX_FALSE;
+
+ FunctionIn();
+
+ while (!pVideoEnc->bExitBufferProcessThread) {
+ Rockchip_OSAL_SleepMillisec(0);
+ Rkvpu_Wait_ProcessPause(pRockchipComponent, INPUT_PORT_INDEX);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_Check_BufferProcess_State in");
+ while ((Rkvpu_Check_BufferProcess_State(pRockchipComponent, INPUT_PORT_INDEX)) &&
+ (!pVideoEnc->bExitBufferProcessThread)) {
+
+
+ if ((CHECK_PORT_BEING_FLUSHED(rockchipInputPort)) ||
+ (((ROCKCHIP_OMX_EXCEPTION_STATE)rockchipOutputPort->exceptionFlag != GENERAL_STATE) && ((ROCKCHIP_OMX_ERRORTYPE)ret == OMX_ErrorInputDataDecodeYet)))
+ break;
+
+ if (rockchipInputPort->portState != OMX_StateIdle)
+ break;
+
+ Rockchip_OSAL_MutexLock(srcInputUseBuffer->bufferMutex);
+ if ((ROCKCHIP_OMX_ERRORTYPE)ret != OMX_ErrorInputDataDecodeYet) {
+ if ((srcInputUseBuffer->dataValid != OMX_TRUE) &&
+ (!CHECK_PORT_BEING_FLUSHED(rockchipInputPort))) {
+
+ ret = Rkvpu_InputBufferGetQueue(pRockchipComponent);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
+ break;
+ }
+ }
+
+ if (srcInputUseBuffer->dataValid == OMX_TRUE) {
+ if (Rkvpu_SendInputData(hComponent) != OMX_TRUE) {
+ Rockchip_OSAL_SleepMillisec(5);
+ }
+ }
+ if (CHECK_PORT_BEING_FLUSHED(rockchipInputPort)) {
+ Rockchip_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
+ break;
+ }
+ }
+ Rockchip_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
+ if ((ROCKCHIP_OMX_ERRORTYPE)ret == OMX_ErrorCodecInit)
+ pVideoEnc->bExitBufferProcessThread = OMX_TRUE;
+ }
+ }
+
+EXIT:
+
+ FunctionOut();
+
+ return ret;
+}
+
+
+OMX_ERRORTYPE Rkvpu_OMX_OutputBufferProcess(OMX_HANDLETYPE hComponent)
+{
+ OMX_U32 ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *rockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_DATABUFFER *dstOutputUseBuffer = &rockchipOutputPort->way.port2WayDataBuffer.outputDataBuffer;
+ VpuCodecContext_t *p_vpu_ctx = pVideoEnc->vpu_ctx;
+
+ FunctionIn();
+
+ while (!pVideoEnc->bExitBufferProcessThread) {
+ Rockchip_OSAL_SleepMillisec(0);
+ Rkvpu_Wait_ProcessPause(pRockchipComponent, OUTPUT_PORT_INDEX);
+
+ while ((Rkvpu_Check_BufferProcess_State(pRockchipComponent, OUTPUT_PORT_INDEX)) &&
+ (!pVideoEnc->bExitBufferProcessThread)) {
+
+ if (CHECK_PORT_BEING_FLUSHED(rockchipOutputPort))
+ break;
+
+ Rockchip_OSAL_MutexLock(dstOutputUseBuffer->bufferMutex);
+ if ((dstOutputUseBuffer->dataValid != OMX_TRUE) &&
+ (!CHECK_PORT_BEING_FLUSHED(rockchipOutputPort))) {
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_OutputBufferGetQueue in");
+ ret = Rkvpu_OutputBufferGetQueue(pRockchipComponent);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rkvpu_OutputBufferGetQueue out");
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_MutexUnlock(dstOutputUseBuffer->bufferMutex);
+ break;
+ }
+ }
+
+ if (dstOutputUseBuffer->dataValid == OMX_TRUE) {
+ Rockchip_OSAL_MutexLock(pVideoEnc->bRecofig_Mutex);
+ ret = Rkvpu_Post_OutputStream(pOMXComponent);
+ Rockchip_OSAL_MutexUnlock(pVideoEnc->bRecofig_Mutex);
+ if ( (OMX_BOOL)ret != OMX_TRUE) {
+ Rockchip_OSAL_SleepMillisec(5);
+ }
+ }
+ Rockchip_OSAL_MutexUnlock(dstOutputUseBuffer->bufferMutex);
+ }
+ }
+
+EXIT:
+
+ FunctionOut();
+
+ return ret;
+}
+
+static OMX_ERRORTYPE Rkvpu_OMX_InputProcessThread(OMX_PTR threadData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+
+ FunctionIn();
+
+ if (threadData == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ Rkvpu_OMX_InputBufferProcess(pOMXComponent);
+
+ Rockchip_OSAL_ThreadExit(NULL);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+static OMX_ERRORTYPE Rkvpu_OMX_OutputProcessThread(OMX_PTR threadData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+
+ FunctionIn();
+
+ if (threadData == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ Rkvpu_OMX_OutputBufferProcess(pOMXComponent);
+
+ Rockchip_OSAL_ThreadExit(NULL);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_BufferProcess_Create( OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ FunctionIn();
+
+ pVideoEnc->bExitBufferProcessThread = OMX_FALSE;
+
+ ret = Rockchip_OSAL_ThreadCreate(&pVideoEnc->hOutputThread,
+ Rkvpu_OMX_OutputProcessThread,
+ pOMXComponent);
+
+ if (ret == OMX_ErrorNone)
+ ret = Rockchip_OSAL_ThreadCreate(&pVideoEnc->hInputThread,
+ Rkvpu_OMX_InputProcessThread,
+ pOMXComponent);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_BufferProcess_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ OMX_S32 countValue = 0;
+ unsigned int i = 0;
+
+ FunctionIn();
+
+ pVideoEnc->bExitBufferProcessThread = OMX_TRUE;
+
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].bufferSemID, &countValue);
+ if (countValue == 0)
+ Rockchip_OSAL_SemaphorePost(pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].bufferSemID);
+
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].pauseEvent);
+ Rockchip_OSAL_ThreadTerminate(pVideoEnc->hInputThread);
+ pVideoEnc->hInputThread = NULL;
+
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX].bufferSemID, &countValue);
+ if (countValue == 0)
+ Rockchip_OSAL_SemaphorePost(pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX].bufferSemID);
+
+
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].pauseEvent);
+
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX].pauseEvent);
+ Rockchip_OSAL_ThreadTerminate(pVideoEnc->hOutputThread);
+ pVideoEnc->hOutputThread = NULL;
+
+ pRockchipComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
+ pRockchipComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+static OMX_ERRORTYPE ConvertOmxAvcLevelToAvcSpecLevel(
+ int32_t omxLevel, AVCLevel *pvLevel)
+{
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "ConvertOmxAvcLevelToAvcSpecLevel: %d", omxLevel);
+ AVCLevel level = AVC_LEVEL5_1;
+ switch (omxLevel) {
+ case OMX_VIDEO_AVCLevel1:
+ level = AVC_LEVEL1_B;
+ break;
+ case OMX_VIDEO_AVCLevel1b:
+ level = AVC_LEVEL1;
+ break;
+ case OMX_VIDEO_AVCLevel11:
+ level = AVC_LEVEL1_1;
+ break;
+ case OMX_VIDEO_AVCLevel12:
+ level = AVC_LEVEL1_2;
+ break;
+ case OMX_VIDEO_AVCLevel13:
+ level = AVC_LEVEL1_3;
+ break;
+ case OMX_VIDEO_AVCLevel2:
+ level = AVC_LEVEL2;
+ break;
+ case OMX_VIDEO_AVCLevel21:
+ level = AVC_LEVEL2_1;
+ break;
+ case OMX_VIDEO_AVCLevel22:
+ level = AVC_LEVEL2_2;
+ break;
+ case OMX_VIDEO_AVCLevel3:
+ level = AVC_LEVEL3;
+ break;
+ case OMX_VIDEO_AVCLevel31:
+ level = AVC_LEVEL3_1;
+ break;
+ case OMX_VIDEO_AVCLevel32:
+ level = AVC_LEVEL3_2;
+ break;
+ case OMX_VIDEO_AVCLevel4:
+ level = AVC_LEVEL4;
+ break;
+ case OMX_VIDEO_AVCLevel41:
+ level = AVC_LEVEL4_1;
+ break;
+ case OMX_VIDEO_AVCLevel42:
+ level = AVC_LEVEL4_2;
+ break;
+ case OMX_VIDEO_AVCLevel5:
+ level = AVC_LEVEL5;
+ break;
+ case OMX_VIDEO_AVCLevel51:
+ level = AVC_LEVEL5_1;
+ break;
+ default:
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Unknown omx level: %d", omxLevel);
+ return -1;
+ }
+ *pvLevel = level;
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE ConvertOmxHevcProfile2HalHevcProfile(
+ OMX_VIDEO_HEVCPROFILETYPE omxHevcProfile, HEVCEncProfile *halHevcProfile)
+{
+ HEVCEncProfile hevcProfile = HEVC_MAIN_PROFILE;
+ switch (omxHevcProfile) {
+ case OMX_VIDEO_HEVCProfileMain:
+ hevcProfile = HEVC_MAIN_PROFILE;
+ break;
+ case OMX_VIDEO_HEVCProfileMain10:
+ hevcProfile = HEVC_MAIN10_PROFILE;
+ break;
+ case OMX_VIDEO_HEVCProfileMain10HDR10:
+ hevcProfile = HEVC_MAIN10HDR10_PROFILE;
+ break;
+ default:
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Unknown omx profile: %d, forced to convert HEVC_MAIN_PROFILE",
+ omxHevcProfile);
+ break;
+ }
+ *halHevcProfile = hevcProfile;
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE ConvertOmxHevcLevel2HalHevcLevel(
+ OMX_VIDEO_HEVCLEVELTYPE omxHevcLevel, HEVCLevel *halHevcLevel)
+{
+ HEVCLevel hevcLevel = HEVC_LEVEL4_1;
+ switch (omxHevcLevel) {
+ case OMX_VIDEO_HEVCMainTierLevel41:
+ hevcLevel = HEVC_LEVEL4_1;
+ break;
+ default:
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Unknown omx level: %d, forced to convert HEVC_LEVEL4_1",
+ omxHevcLevel);
+ break;
+ }
+ *halHevcLevel = hevcLevel;
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE omx_open_vpuenc_context(RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc)
+{
+ pVideoEnc->rkapi_hdl = dlopen("/system/lib/libvpu.so", RTLD_LAZY);
+ if (pVideoEnc->rkapi_hdl == NULL) {
+ return OMX_ErrorHardware;
+ }
+ pVideoEnc->rkvpu_open_cxt = (OMX_S32 (*)(VpuCodecContext_t **ctx))dlsym(pVideoEnc->rkapi_hdl, "vpu_open_context");
+ if (pVideoEnc->rkvpu_open_cxt == NULL) {
+ dlclose(pVideoEnc->rkapi_hdl);
+ pVideoEnc->rkapi_hdl = NULL;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_DEBUG,"used old version lib");
+ pVideoEnc->rkapi_hdl = dlopen("/system/lib/librk_vpuapi.so", RTLD_LAZY);
+ if (pVideoEnc->rkapi_hdl == NULL) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "dll open fail system/lib/librk_vpuapi.so");
+ return OMX_ErrorHardware;
+ }
+ pVideoEnc->rkvpu_open_cxt = (OMX_S32 (*)(VpuCodecContext_t **ctx))dlsym(pVideoEnc->rkapi_hdl, "vpu_open_context");
+ if (pVideoEnc->rkvpu_open_cxt == NULL) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "dlsym vpu_open_context fail");
+ dlclose( pVideoEnc->rkapi_hdl);
+ return OMX_ErrorHardware;
+ }
+ pVideoEnc->bIsNewVpu = OMX_FALSE;
+ } else {
+ pVideoEnc->bIsNewVpu = OMX_TRUE;
+ }
+ pVideoEnc->rkvpu_close_cxt = (OMX_S32 (*)(VpuCodecContext_t **ctx))dlsym(pVideoEnc->rkapi_hdl, "vpu_close_context");
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE Rkvpu_Enc_ComponentInit(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ OMX_RK_VIDEO_CODINGTYPE codecId = OMX_RK_VIDEO_CodingUnused;
+ ROCKCHIP_OMX_BASEPORT *pRockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ VpuCodecContext_t *p_vpu_ctx = NULL;
+ EncParameter_t *EncParam = NULL;
+ RK_U32 new_width = 0, new_height = 0;
+ if (omx_open_vpuenc_context(pVideoEnc) != OMX_ErrorNone) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ if (pVideoEnc->bIsNewVpu == OMX_TRUE) {
+ p_vpu_ctx = (VpuCodecContext_t *)Rockchip_OSAL_Malloc(sizeof(VpuCodecContext_t));
+ }
+
+ if (pVideoEnc->rkvpu_open_cxt && pVideoEnc->bIsNewVpu == OMX_FALSE) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "open vpu context FALSE");
+ pVideoEnc->rkvpu_open_cxt(&p_vpu_ctx);
+ }
+
+ int32_t kNumMapEntries = sizeof(kCodeMap) / sizeof(kCodeMap[0]);
+ int i = 0;
+ for (i = 0; i < kNumMapEntries; i++) {
+ if (kCodeMap[i].omx_id == pVideoEnc->codecId) {
+ codecId = kCodeMap[i].codec_id;
+ break;
+ }
+ }
+ if (pVideoEnc->bIsNewVpu == OMX_TRUE) {
+ memset(p_vpu_ctx, 0, sizeof(VpuCodecContext_t));
+ }
+ pVideoEnc->bCurrent_height = pRockchipInputPort->portDefinition.format.video.nFrameHeight;
+ pVideoEnc->bCurrent_width = pRockchipInputPort->portDefinition.format.video.nFrameWidth;
+ if(pVideoEnc->params_extend.bEnableScaling || pVideoEnc->params_extend.bEnableCropping){
+ if (pVideoEnc->params_extend.bEnableScaling) {
+ new_width = pVideoEnc->params_extend.ui16ScaledWidth;
+ new_height = pVideoEnc->params_extend.ui16ScaledHeight;
+ } else if (pVideoEnc->params_extend.bEnableCropping) {
+ new_width = p_vpu_ctx->width - pVideoEnc->params_extend.ui16CropLeft - pVideoEnc->params_extend.ui16CropRight;
+ new_height = p_vpu_ctx->height - pVideoEnc->params_extend.ui16CropTop - pVideoEnc->params_extend.ui16CropBottom;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "CropLeft = %d CropRight = %d CropTop %d CropBottom %d",
+ pVideoEnc->params_extend.ui16CropLeft, pVideoEnc->params_extend.ui16CropRight,
+ pVideoEnc->params_extend.ui16CropTop, pVideoEnc->params_extend.ui16CropBottom);
+ }
+ if (new_width != pVideoEnc->bCurrent_width ||
+ new_height != pVideoEnc->bCurrent_height) {
+ pVideoEnc->bCurrent_width = new_width;
+ pVideoEnc->bCurrent_height = new_height;
+ }
+ }
+
+ p_vpu_ctx->codecType = CODEC_ENCODER;
+ p_vpu_ctx->videoCoding = codecId;
+ p_vpu_ctx->width = pVideoEnc->bCurrent_width;
+ p_vpu_ctx->height = pVideoEnc->bCurrent_height;
+ if (pVideoEnc->rkvpu_open_cxt && pVideoEnc->bIsNewVpu == OMX_TRUE) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "open vpu context new");
+ pVideoEnc->rkvpu_open_cxt(&p_vpu_ctx);
+ }
+ if (p_vpu_ctx == NULL) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR,"open vpu context fail!");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ if (p_vpu_ctx->extra_cfg.reserved[0] == 1) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO,"use vpuapi.");
+ pVideoEnc->bIsUseMpp = OMX_FALSE;
+ } else {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO,"use mpp.");
+ pVideoEnc->bIsUseMpp = OMX_TRUE;
+ }
+ p_vpu_ctx->private_data = malloc(sizeof(EncParameter_t));
+ memset(p_vpu_ctx->private_data, 0, sizeof(EncParameter_t));
+ EncParam = (EncParameter_t*)p_vpu_ctx->private_data;
+ Rkvpu_Enc_GetEncParams(pOMXComponent,&EncParam);
+
+#ifdef ENCODE_RATE_STATISTIC
+ lastEncodeTime = 0;
+ currentEncodeTime = 0;
+ lastEncodeFrameCount = 0;
+ currentEncodeFrameCount = 0;
+#endif
+
+ if (p_vpu_ctx) {
+ if (p_vpu_ctx->init(p_vpu_ctx, NULL, 0)) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+
+ }
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_DEBUG, "eControlRate %d ", pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]);
+ if (pVideoEnc->eControlRate[OUTPUT_PORT_INDEX] == OMX_Video_ControlRateConstant) {
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_GETCFG, (void*)EncParam);
+ EncParam->rc_mode = 1;
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETCFG, (void*)EncParam);
+ }
+ pVideoEnc->bFrame_num = 0;
+ pVideoEnc->bLast_config_frame = 0;
+ pVideoEnc->bSpsPpsHeaderFlag = OMX_FALSE;
+ pVideoEnc->bSpsPpsbuf = NULL;
+ if (pVideoEnc->codecId == (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingHEVC) {
+ pVideoEnc->bSpsPpsbuf = NULL;
+ pVideoEnc->bSpsPpsLen = 0;
+ }else {
+ if(p_vpu_ctx->extradata == NULL) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR,"init get extradata fail!");
+ pVideoEnc->bSpsPpsbuf = NULL;
+ pVideoEnc->bSpsPpsLen = 0;
+ goto EXIT;
+ }else {
+ if((p_vpu_ctx->extradata != NULL) && p_vpu_ctx->extradata_size > 0 && p_vpu_ctx->extradata_size <= 2048){
+ pVideoEnc->bSpsPpsbuf = (OMX_U8 *)Rockchip_OSAL_Malloc(2048);
+ Rockchip_OSAL_Memcpy(pVideoEnc->bSpsPpsbuf, p_vpu_ctx->extradata, p_vpu_ctx->extradata_size);
+ pVideoEnc->bSpsPpsLen = p_vpu_ctx->extradata_size;
+ }else{
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR,"p_vpu_ctx->extradata = %p,p_vpu_ctx->extradata_size = %d",p_vpu_ctx->extradata,p_vpu_ctx->extradata_size);
+ }
+ }
+ }
+ }
+ pVideoEnc->bEncSendEos = OMX_FALSE;
+ pVideoEnc->enc_vpumem = NULL;
+ pVideoEnc->enc_vpumem = (VPUMemLinear_t*)Rockchip_OSAL_Malloc(sizeof( VPUMemLinear_t));
+ ret = VPUMallocLinear(pVideoEnc->enc_vpumem, ((EncParam->width + 15) & 0xfff0)
+ * EncParam->height * 4);
+ if (ret) {
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "err %dtemp->phy_addr %x mWidth %d mHeight %d", ret, pVideoEnc->enc_vpumem->phy_addr,
+ EncParam->width, EncParam->height);
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+
+ if (rga_dev_open(&pVideoEnc->rga_ctx) < 0) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "open rga device fail!");
+ }
+
+ pVideoEnc->bRgb2yuvFlag = OMX_FALSE;
+ pVideoEnc->bPixel_format = -1;
+#ifdef WRITE_FILE
+ pVideoEnc->fp_rgb = fopen("data/enc_in.rgb", "wb");
+ pVideoEnc->fp_h264 = fopen("data/enc_out.h264", "wb");
+#endif
+
+ pVideoEnc->vpu_ctx = p_vpu_ctx;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_Enc_GetEncParams(OMX_COMPONENTTYPE *pOMXComponent,EncParameter_t **encParams)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pRockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ FunctionIn();
+
+ (*encParams)->height = pVideoEnc->bCurrent_height;
+ (*encParams)->width = pVideoEnc->bCurrent_width;
+ (*encParams)->bitRate = pRockchipOutputPort->portDefinition.format.video.nBitrate;
+ (*encParams)->framerate = (pRockchipInputPort->portDefinition.format.video.xFramerate) >> 16;
+
+ if (pVideoEnc->codecId == OMX_VIDEO_CodingAVC) {
+ (*encParams)->enableCabac = 0;
+ (*encParams)->cabacInitIdc = 0;
+ (*encParams)->intraPicRate = pVideoEnc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames;
+ switch (pVideoEnc->AVCComponent[OUTPUT_PORT_INDEX].eProfile) {
+ case OMX_VIDEO_AVCProfileBaseline:
+ (*encParams)->profileIdc = BASELINE_PROFILE;
+ break;
+ case OMX_VIDEO_AVCProfileMain:
+ (*encParams)->profileIdc = MAIN_PROFILE;
+ break;
+ case OMX_VIDEO_AVCProfileHigh:
+ (*encParams)->profileIdc = HIGHT_PROFILE;
+ break;
+ default:
+ (*encParams)->profileIdc = BASELINE_PROFILE;
+ break;
+ }
+ ConvertOmxAvcLevelToAvcSpecLevel((int32_t)pVideoEnc->AVCComponent[OUTPUT_PORT_INDEX].eLevel, (AVCLevel *)&((*encParams)->levelIdc));
+ }else if (pVideoEnc->codecId == (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingHEVC) {
+ (*encParams)->enableCabac = 0;
+ (*encParams)->cabacInitIdc = 0;
+ (*encParams)->intraPicRate = pVideoEnc->HEVCComponent[OUTPUT_PORT_INDEX].nKeyFrameInterval;
+
+ ConvertOmxHevcProfile2HalHevcProfile(pVideoEnc->HEVCComponent[OUTPUT_PORT_INDEX].eProfile,
+ (HEVCEncProfile *)&((*encParams)->profileIdc));
+ ConvertOmxHevcLevel2HalHevcLevel(pVideoEnc->HEVCComponent[OUTPUT_PORT_INDEX].eLevel,
+ (HEVCLevel *)&((*encParams)->levelIdc));
+ switch (pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]) {
+ case OMX_Video_ControlRateDisable:
+ (*encParams)->rc_mode = Video_RC_Mode_Disable;
+ break;
+ case OMX_Video_ControlRateVariable:
+ (*encParams)->rc_mode = Video_RC_Mode_VBR;
+ break;
+ case OMX_Video_ControlRateConstant:
+ (*encParams)->rc_mode = Video_RC_Mode_CBR;
+ break;
+ default:
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "unknown rate control mode = %d, forced to VBR mode",
+ pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]);
+ (*encParams)->rc_mode = Video_RC_Mode_VBR;
+ break;
+ }
+ }
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_INFO, "encode params init settings:\n"
+ "width = %d\n"
+ "height = %d\n"
+ "bitRate = %d\n"
+ "framerate = %d\n"
+ "format = %d\n"
+ "enableCabac = %d,\n"
+ "cabacInitIdc = %d,\n"
+ "intraPicRate = %d,\n"
+ "profileIdc = %d,\n"
+ "levelIdc = %d,\n"
+ "rc_mode = %d,\n",
+ (int)(*encParams)->width,
+ (int)(*encParams)->height,
+ (int)(*encParams)->bitRate,
+ (int)(*encParams)->framerate,
+ (int)(*encParams)->format,
+ (int)(*encParams)->enableCabac,
+ (int)(*encParams)->cabacInitIdc,
+ (int)(*encParams)->profileIdc,
+ (int)(*encParams)->levelIdc,
+ (int)(*encParams)->rc_mode);
+
+ FunctionOut();
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pRockchipInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+
+ int i, plane;
+ FunctionIn();
+ if (pVideoEnc->vpu_ctx) {
+ if (pVideoEnc->rkvpu_close_cxt) {
+ pVideoEnc->rkvpu_close_cxt(&pVideoEnc->vpu_ctx);
+ }
+ pVideoEnc->vpu_ctx = NULL;
+ if (pVideoEnc->rkapi_hdl) {
+ dlclose( pVideoEnc->rkapi_hdl);
+ pVideoEnc->rkapi_hdl = NULL;
+ }
+ }
+
+ if (pVideoEnc->bSpsPpsbuf) {
+ Rockchip_OSAL_Free(pVideoEnc->bSpsPpsbuf);
+ pVideoEnc->bSpsPpsbuf = NULL;
+ }
+
+ if (pVideoEnc->enc_vpumem) {
+ VPUFreeLinear(pVideoEnc->enc_vpumem);
+ Rockchip_OSAL_Free(pVideoEnc->enc_vpumem);
+ pVideoEnc->enc_vpumem = NULL;
+ }
+
+ if (pVideoEnc->rga_ctx != NULL) {
+ rga_dev_close(pVideoEnc->rga_ctx);
+ pVideoEnc->rga_ctx = NULL;
+ }
+
+ pVideoEnc->bEncSendEos = OMX_FALSE;
+
+ Rkvpu_ResetAllPortConfig(pOMXComponent);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+
+OMX_ERRORTYPE Rockchip_OMX_ComponentConstructor(OMX_HANDLETYPE hComponent, OMX_STRING componentName)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+
+ FunctionIn();
+
+ if ((hComponent == NULL) || (componentName == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ ret = Rockchip_OMX_BaseComponent_Constructor(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ ret = Rockchip_OMX_Port_Constructor(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OMX_BaseComponent_Destructor(pOMXComponent);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ pVideoEnc = Rockchip_OSAL_Malloc(sizeof(RKVPU_OMX_VIDEOENC_COMPONENT));
+ if (pVideoEnc == NULL) {
+ Rockchip_OMX_BaseComponent_Destructor(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ Rockchip_OSAL_Memset(pVideoEnc, 0, sizeof(RKVPU_OMX_VIDEOENC_COMPONENT));
+
+ pVideoEnc->hSharedMemory = Rockchip_OSAL_SharedMemory_Open();
+ if ( pVideoEnc->hSharedMemory == NULL) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Rockchip_OSAL_SharedMemory_Open open fail");
+ }
+ pRockchipComponent->componentName = (OMX_STRING)Rockchip_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE);
+ if (pRockchipComponent->componentName == NULL) {
+ Rockchip_OMX_ComponentDeInit(hComponent);
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ /* Set componentVersion */
+ pRockchipComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
+ pRockchipComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
+ pRockchipComponent->componentVersion.s.nRevision = REVISION_NUMBER;
+ pRockchipComponent->componentVersion.s.nStep = STEP_NUMBER;
+ /* Set specVersion */
+ pRockchipComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
+ pRockchipComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
+ pRockchipComponent->specVersion.s.nRevision = REVISION_NUMBER;
+ pRockchipComponent->specVersion.s.nStep = STEP_NUMBER;
+ Rockchip_OSAL_Memset(pRockchipComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE);
+ pRockchipComponent->hComponentHandle = (OMX_HANDLETYPE)pVideoEnc;
+
+ pRockchipComponent->bSaveFlagEOS = OMX_FALSE;
+ pRockchipComponent->bBehaviorEOS = OMX_FALSE;
+ pRockchipComponent->bMultiThreadProcess = OMX_TRUE;
+ pRockchipComponent->codecType = HW_VIDEO_ENC_CODEC;
+
+ pVideoEnc->bFirstFrame = OMX_TRUE;
+ pVideoEnc->bFirstInput = OMX_TRUE;
+ pVideoEnc->bFirstOutput = OMX_TRUE;
+ pVideoEnc->configChange = OMX_FALSE;
+ pVideoEnc->bStoreMetaData = OMX_FALSE;
+ pVideoEnc->bPrependSpsPpsToIdr = OMX_FALSE;
+ pVideoEnc->quantization.nQpI = 4; // I frame quantization parameter
+ pVideoEnc->quantization.nQpP = 5; // P frame quantization parameter
+ pVideoEnc->quantization.nQpB = 5; // B frame quantization parameter
+ //add by xlm for use mpp or vpuapi
+ pVideoEnc->bIsUseMpp = OMX_FALSE;
+ pVideoEnc->bIsNewVpu = OMX_TRUE;
+
+ Rockchip_OSAL_MutexCreate(&pVideoEnc->bScale_Mutex);
+ Rockchip_OSAL_MutexCreate(&pVideoEnc->bRecofig_Mutex);
+ /* Input port */
+ pRockchipPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ pRockchipPort->portDefinition.nBufferCountActual = MAX_VIDEOENC_INPUTBUFFER_NUM;
+ pRockchipPort->portDefinition.nBufferCountMin = MAX_VIDEOENC_INPUTBUFFER_NUM;
+ pRockchipPort->portDefinition.nBufferSize = DEFAULT_VIDEOENC_INPUT_BUFFER_SIZE;
+ pRockchipPort->portDefinition.eDomain = OMX_PortDomainVideo;
+ pRockchipPort->portDefinition.format.video.nFrameWidth = DEFAULT_ENC_FRAME_WIDTH;
+ pRockchipPort->portDefinition.format.video.nFrameHeight = DEFAULT_ENC_FRAME_HEIGHT;
+ pRockchipPort->portDefinition.format.video.nStride = 0; /*DEFAULT_ENC_FRAME_WIDTH;*/
+ pRockchipPort->portDefinition.format.video.nSliceHeight = 0;
+ pRockchipPort->portDefinition.nBufferSize = DEFAULT_VIDEOENC_INPUT_BUFFER_SIZE;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+
+ pRockchipPort->portDefinition.format.video.cMIMEType = Rockchip_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "raw/video");
+ pRockchipPort->portDefinition.format.video.pNativeRender = 0;
+ pRockchipPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pRockchipPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ pRockchipPort->portDefinition.bEnabled = OMX_TRUE;
+ pRockchipPort->portWayType = WAY2_PORT;
+ pVideoEnc->eControlRate[INPUT_PORT_INDEX] = OMX_Video_ControlRateDisable;
+ pRockchipPort->bStoreMetaData = OMX_FALSE;
+
+ /* Output port */
+ pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ pRockchipPort->portDefinition.nBufferCountActual = MAX_VIDEOENC_OUTPUTBUFFER_NUM;
+ pRockchipPort->portDefinition.nBufferCountMin = MAX_VIDEOENC_OUTPUTBUFFER_NUM;
+ pRockchipPort->portDefinition.nBufferSize = DEFAULT_VIDEOENC_OUTPUT_BUFFER_SIZE;
+ pRockchipPort->portDefinition.eDomain = OMX_PortDomainVideo;
+ pRockchipPort->portDefinition.format.video.nFrameWidth = DEFAULT_ENC_FRAME_WIDTH;
+ pRockchipPort->portDefinition.format.video.nFrameHeight = DEFAULT_ENC_FRAME_HEIGHT;
+ pRockchipPort->portDefinition.format.video.nStride = 0; /*DEFAULT_ENC_FRAME_WIDTH;*/
+ pRockchipPort->portDefinition.format.video.nSliceHeight = 0;
+ pRockchipPort->portDefinition.nBufferSize = DEFAULT_VIDEOENC_OUTPUT_BUFFER_SIZE;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+
+ pRockchipPort->portDefinition.format.video.cMIMEType = Rockchip_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ pRockchipPort->portDefinition.format.video.pNativeRender = 0;
+ pRockchipPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pRockchipPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+ pRockchipPort->portDefinition.bEnabled = OMX_TRUE;
+ pRockchipPort->portWayType = WAY2_PORT;
+ pRockchipPort->portDefinition.eDomain = OMX_PortDomainVideo;
+ pVideoEnc->eControlRate[OUTPUT_PORT_INDEX] = OMX_Video_ControlRateDisable;
+
+
+ pOMXComponent->UseBuffer = &Rkvpu_OMX_UseBuffer;
+ pOMXComponent->AllocateBuffer = &Rkvpu_OMX_AllocateBuffer;
+ pOMXComponent->FreeBuffer = &Rkvpu_OMX_FreeBuffer;
+ pOMXComponent->ComponentTunnelRequest = &Rkvpu_OMX_ComponentTunnelRequest;
+ pOMXComponent->GetParameter = &Rkvpu_OMX_GetParameter;
+ pOMXComponent->SetParameter = &Rkvpu_OMX_SetParameter;
+ pOMXComponent->GetConfig = &Rkvpu_OMX_GetConfig;
+ pOMXComponent->SetConfig = &Rkvpu_OMX_SetConfig;
+ pOMXComponent->GetExtensionIndex = &Rkvpu_OMX_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &Rkvpu_OMX_ComponentRoleEnum;
+ pOMXComponent->ComponentDeInit = &Rockchip_OMX_ComponentDeInit;
+
+ pRockchipComponent->rockchip_codec_componentInit = &Rkvpu_Enc_ComponentInit;
+ pRockchipComponent->rockchip_codec_componentTerminate = &Rkvpu_Enc_Terminate;
+
+ pRockchipComponent->rockchip_AllocateTunnelBuffer = &Rkvpu_OMX_AllocateTunnelBuffer;
+ pRockchipComponent->rockchip_FreeTunnelBuffer = &Rkvpu_OMX_FreeTunnelBuffer;
+ pRockchipComponent->rockchip_BufferProcessCreate = &Rkvpu_OMX_BufferProcess_Create;
+ pRockchipComponent->rockchip_BufferProcessTerminate = &Rkvpu_OMX_BufferProcess_Terminate;
+ pRockchipComponent->rockchip_BufferFlush = &Rkvpu_OMX_BufferFlush;
+
+ if (!strcmp(componentName, RK_OMX_COMPONENT_H264_ENC)) {
+ int i = 0;
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/avc");
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ INIT_SET_SIZE_VERSION(&pVideoEnc->AVCComponent[i], OMX_VIDEO_PARAM_AVCTYPE);
+ pVideoEnc->AVCComponent[i].nPortIndex = i;
+ pVideoEnc->AVCComponent[i].eProfile = OMX_VIDEO_AVCProfileBaseline;
+ pVideoEnc->AVCComponent[i].eLevel = OMX_VIDEO_AVCLevel31;
+ pVideoEnc->AVCComponent[i].nPFrames = 20;
+ }
+ pVideoEnc->codecId = OMX_VIDEO_CodingAVC;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_VP8_ENC)) {
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/x-vnd.on2.vp8");
+ pVideoEnc->codecId = OMX_VIDEO_CodingVP8;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingVP8;
+ } else if (!strcmp(componentName, RK_OMX_COMPONENT_HEVC_ENC)) {
+ int i = 0;
+ Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/hevc");
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ INIT_SET_SIZE_VERSION(&pVideoEnc->HEVCComponent[i], OMX_VIDEO_PARAM_HEVCTYPE);
+ pVideoEnc->HEVCComponent[i].nPortIndex = i;
+ pVideoEnc->HEVCComponent[i].eProfile = OMX_VIDEO_HEVCProfileMain;
+ pVideoEnc->HEVCComponent[i].eLevel = OMX_VIDEO_HEVCMainTierLevel41;
+ pVideoEnc->HEVCComponent[i].nKeyFrameInterval = 20;
+ }
+ pVideoEnc->codecId = OMX_VIDEO_CodingHEVC;
+ pRockchipPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingHEVC;
+ } else {
+ // IL client specified an invalid component name
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "VPU Component Invalid Component Name\n");
+ ret = OMX_ErrorInvalidComponentName;
+ goto EXIT;
+ }
+ pRockchipComponent->currentState = OMX_StateLoaded;
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_ComponentDeInit(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ int i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ Rockchip_OSAL_MutexTerminate(pVideoEnc->bScale_Mutex);
+ Rockchip_OSAL_MutexTerminate(pVideoEnc->bRecofig_Mutex);
+ if (pVideoEnc->hSharedMemory != NULL) {
+ Rockchip_OSAL_SharedMemory_Close(pVideoEnc->hSharedMemory);
+ pVideoEnc->hSharedMemory = NULL;
+ }
+
+ Rockchip_OSAL_Free(pVideoEnc);
+ pRockchipComponent->hComponentHandle = pVideoEnc = NULL;
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ if (pRockchipPort->processData.extInfo != NULL) {
+ Rockchip_OSAL_Free(pRockchipPort->processData.extInfo);
+ pRockchipPort->processData.extInfo = NULL;
+ }
+
+ for (i = 0; i < ALL_PORT_NUM; i++) {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[i];
+ Rockchip_OSAL_Free(pRockchipPort->portDefinition.format.video.cMIMEType);
+ pRockchipPort->portDefinition.format.video.cMIMEType = NULL;
+ }
+
+ ret = Rockchip_OMX_Port_Destructor(pOMXComponent);
+
+ ret = Rockchip_OMX_BaseComponent_Destructor(hComponent);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/component/video/enc/Rkvpu_OMX_Venc.h b/component/video/enc/Rkvpu_OMX_Venc.h
new file mode 100755
index 0000000..426073a
--- /dev/null
+++ b/component/video/enc/Rkvpu_OMX_Venc.h
@@ -0,0 +1,160 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rkvpu_OMX_Venc.h
+ * @brief
+ * @author Csy (csy@rock-chips.com)
+
+ * @version 1.0.0
+ * @history
+ * 2013.11.28 : Create
+ */
+
+#ifndef Rkvpu_OMX_VIDEO_ENCODER
+#define Rkvpu_OMX_VIDEO_ENCODER
+
+#include "OMX_Component.h"
+#include "Rockchip_OMX_Def.h"
+#include "Rockchip_OSAL_Queue.h"
+#include "Rockchip_OMX_Baseport.h"
+#include "Rockchip_OMX_Basecomponent.h"
+#include "OMX_Video.h"
+#include "OMX_VideoExt.h"
+#include "vpu_api.h"
+
+#define MAX_VIDEOENC_INPUTBUFFER_NUM 2
+#define MAX_VIDEOENC_OUTPUTBUFFER_NUM 2
+
+#define DEFAULT_ENC_FRAME_WIDTH 1920
+#define DEFAULT_ENC_FRAME_HEIGHT 1080
+
+#define DEFAULT_VIDEOENC_INPUT_BUFFER_SIZE (DEFAULT_ENC_FRAME_WIDTH * DEFAULT_ENC_FRAME_HEIGHT * 3)/2
+#define DEFAULT_VIDEOENC_OUTPUT_BUFFER_SIZE (DEFAULT_ENC_FRAME_WIDTH * DEFAULT_ENC_FRAME_HEIGHT)
+
+
+#define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 4
+//#define WRITE_FILE
+
+typedef struct _RKVPU_OMX_VIDEOENC_COMPONENT {
+ OMX_HANDLETYPE hCodecHandle;
+
+ OMX_BOOL bFirstFrame;
+
+ OMX_VIDEO_PARAM_AVCTYPE AVCComponent[ALL_PORT_NUM];
+
+ OMX_VIDEO_PARAM_HEVCTYPE HEVCComponent[ALL_PORT_NUM];
+
+ /* Buffer Process */
+ OMX_BOOL bExitBufferProcessThread;
+ OMX_HANDLETYPE hInputThread;
+ OMX_HANDLETYPE hOutputThread;
+
+ OMX_VIDEO_CODINGTYPE codecId;
+
+ /* Shared Memory Handle */
+ OMX_HANDLETYPE hSharedMemory;
+
+ OMX_BOOL configChange;
+
+ OMX_BOOL IntraRefreshVOP;
+
+ OMX_VIDEO_CONTROLRATETYPE eControlRate[ALL_PORT_NUM];
+
+ OMX_VIDEO_PARAM_QUANTIZATIONTYPE quantization;
+
+ OMX_VIDEO_PARAM_INTRAREFRESHTYPE intraRefresh;
+
+ OMX_VIDEO_PARAMS_EXTENDED params_extend;
+ OMX_BOOL bFirstInput;
+
+ OMX_BOOL bFirstOutput;
+
+ OMX_BOOL bStoreMetaData;
+
+ OMX_BOOL bPrependSpsPpsToIdr;
+
+ VpuCodecContext_t *vpu_ctx;
+
+ void *rga_ctx;
+
+ OMX_U8 *bSpsPpsbuf;
+
+ OMX_U32 bSpsPpsLen;
+
+ OMX_BOOL bSpsPpsHeaderFlag;
+
+ OMX_BOOL bEncSendEos;
+
+ OMX_U32 bFrame_num;
+ OMX_U32 bCurrent_width;
+
+ OMX_U32 bCurrent_height;
+
+ OMX_U32 bLast_config_frame;
+
+ VPUMemLinear_t *enc_vpumem;
+
+ OMX_HANDLETYPE bScale_Mutex;
+ OMX_HANDLETYPE bRecofig_Mutex;
+ OMX_S32 bPixel_format;
+ OMX_BOOL bRgb2yuvFlag;
+
+ void *rkapi_hdl;
+#ifdef WRITE_FILE
+ FILE *fp_rgb;
+ FILE *fp_h264;
+#endif
+ //add by xlm for use mpp or vpuapi
+ OMX_BOOL bIsUseMpp;
+ OMX_BOOL bIsNewVpu;
+ OMX_S32 (*rkvpu_open_cxt)(VpuCodecContext_t **ctx);
+ OMX_S32 (*rkvpu_close_cxt)(VpuCodecContext_t **ctx);
+
+ OMX_ERRORTYPE (*Rkvpu_codec_srcInputProcess) (OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATA *pInputData);
+
+ OMX_ERRORTYPE (*Rkvpu_codec_srcOutputProcess) (OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATA *pInputData);
+
+ OMX_ERRORTYPE (*Rkvpu_codec_dstInputProcess) (OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATA *pOutputData);
+
+ OMX_ERRORTYPE (*Rkvpu_codec_dstOutputProcess) (OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATA *pOutputData);
+
+} RKVPU_OMX_VIDEOENC_COMPONENT;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int calc_plane(int width, int height);
+void UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent);
+OMX_BOOL Rkvpu_Check_BufferProcess_State(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 nPortIndex);
+
+OMX_ERRORTYPE Rkvpu_OMX_InputBufferProcess(OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE Rkvpu_OMX_OutputBufferProcess(OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE Rkvpu_Enc_ComponentInit(OMX_COMPONENTTYPE *pOMXComponent);
+OMX_ERRORTYPE Rkvpu_Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent);
+OMX_ERRORTYPE Rkvpu_Enc_GetEncParams(OMX_COMPONENTTYPE *pOMXComponent,EncParameter_t **encParams);
+
+
+OMX_ERRORTYPE Rockchip_OMX_ComponentConstructor(OMX_HANDLETYPE hComponent, OMX_STRING componentName);
+OMX_ERRORTYPE Rockchip_OMX_ComponentDeInit(OMX_HANDLETYPE hComponent);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/component/video/enc/Rkvpu_OMX_VencControl.c b/component/video/enc/Rkvpu_OMX_VencControl.c
new file mode 100755
index 0000000..edc6603
--- /dev/null
+++ b/component/video/enc/Rkvpu_OMX_VencControl.c
@@ -0,0 +1,1850 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rkon2_OMX_VdecControl.c
+ * @brief
+ * @author csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.28 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "Rockchip_OMX_Macros.h"
+#include "Rockchip_OSAL_Event.h"
+#include "Rkvpu_OMX_Venc.h"
+#include "Rkvpu_OMX_VencControl.h"
+#include "Rockchip_OMX_Basecomponent.h"
+#include "Rockchip_OSAL_Thread.h"
+#include "Rockchip_OSAL_Semaphore.h"
+#include "Rockchip_OSAL_Mutex.h"
+#include "Rockchip_OSAL_ETC.h"
+#include "Rockchip_OSAL_SharedMemory.h"
+#include "Rockchip_OSAL_Queue.h"
+#include <hardware/hardware.h>
+#include "hardware/rga.h"
+#include <fcntl.h>
+#include <poll.h>
+
+//#include "csc.h"
+
+#ifdef USE_ANB
+#include "Rockchip_OSAL_Android.h"
+#endif
+
+#undef ROCKCHIP_LOG_TAG
+#define ROCKCHIP_LOG_TAG "ROCKCHIP_VIDEO_ENCCONTROL"
+#define ROCKCHIP_LOG_OFF
+//#define ROCKCHIP_TRACE_ON
+#include "Rockchip_OSAL_Log.h"
+
+typedef struct {
+ OMX_U32 mProfile;
+ OMX_U32 mLevel;
+} CodecProfileLevel;
+static const CodecProfileLevel kM4VProfileLevels[] = {
+ { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0 },
+ { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0b},
+ { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1 },
+ { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level2 },
+ { OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level3 },
+};
+static const CodecProfileLevel kH263ProfileLevels[] = {
+ { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10 },
+ { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level20 },
+ { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level30 },
+ { OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level45 },
+ { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level10 },
+ { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level20 },
+ { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level30 },
+ { OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level45 },
+};
+static const CodecProfileLevel kProfileLevels[] = {
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1b },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel11 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel12 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel2 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel21 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel22 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel3 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel32 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel41 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel42 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel5 },
+ { OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel51 },
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1b},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel11},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel12},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel13},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel2},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel21},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel22},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel3},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel31},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel32},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel41},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel42},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel5},
+ { OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel51},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1b},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel11},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel12},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel13},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel2},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel21},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel22},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel3},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel41},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel42},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel5},
+ { OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel51},
+};
+
+OMX_ERRORTYPE Rkvpu_OMX_UseBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes,
+ OMX_IN OMX_U8 *pBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ OMX_U32 i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[nPortIndex];
+ if (nPortIndex >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ if (pRockchipPort->portState != OMX_StateIdle) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ if (CHECK_PORT_TUNNELED(pRockchipPort) && CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Rockchip_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
+ if (temp_bufferHeader == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ Rockchip_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
+
+ for (i = 0; i < pRockchipPort->portDefinition.nBufferCountActual; i++) {
+ if (pRockchipPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
+ pRockchipPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader;
+ pRockchipPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED);
+ INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
+ temp_bufferHeader->pBuffer = pBuffer;
+ temp_bufferHeader->nAllocLen = nSizeBytes;
+ temp_bufferHeader->pAppPrivate = pAppPrivate;
+ if (nPortIndex == INPUT_PORT_INDEX)
+ temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
+ else
+ temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
+
+ pRockchipPort->assignedBufferNum++;
+ if (pRockchipPort->assignedBufferNum == pRockchipPort->portDefinition.nBufferCountActual) {
+ pRockchipPort->portDefinition.bPopulated = OMX_TRUE;
+ /* Rockchip_OSAL_MutexLock(pRockchipPort->compMutex); */
+ Rockchip_OSAL_SemaphorePost(pRockchipPort->loadedResource);
+ /* Rockchip_OSAL_MutexUnlock(pRockchipPort->compMutex); */
+ }
+ *ppBufferHdr = temp_bufferHeader;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ }
+
+ Rockchip_OSAL_Free(temp_bufferHeader);
+ ret = OMX_ErrorInsufficientResources;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_AllocateBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ OMX_U8 *temp_buffer = NULL;
+ int temp_buffer_fd = -1;
+ OMX_U32 i = 0;
+ MEMORY_TYPE mem_type = NORMAL_MEMORY;
+
+ FunctionIn();
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Rkvpu_OMX_AllocateBuffer in");
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[nPortIndex];
+ if (nPortIndex >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ /*
+ if (pRockchipPort->portState != OMX_StateIdle ) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ */
+ if (CHECK_PORT_TUNNELED(pRockchipPort) && CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ temp_buffer = (OMX_U8 *)Rockchip_OSAL_Malloc(nSizeBytes);
+ if (temp_buffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Rockchip_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
+ if (temp_bufferHeader == NULL) {
+ Rockchip_OSAL_Free(temp_buffer);
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ Rockchip_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
+
+ for (i = 0; i < pRockchipPort->portDefinition.nBufferCountActual; i++) {
+ if (pRockchipPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
+ pRockchipPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader;
+ pRockchipPort->extendBufferHeader[i].buf_fd[0] = temp_buffer_fd;
+ pRockchipPort->bufferStateAllocate[i] = (BUFFER_STATE_ALLOCATED | HEADER_STATE_ALLOCATED);
+ INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
+ if (mem_type == SECURE_MEMORY)
+ ;//temp_bufferHeader->pBuffer = temp_buffer_fd;
+ else
+ temp_bufferHeader->pBuffer = temp_buffer;
+ temp_bufferHeader->nAllocLen = nSizeBytes;
+ temp_bufferHeader->pAppPrivate = pAppPrivate;
+ if (nPortIndex == INPUT_PORT_INDEX)
+ temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
+ else
+ temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
+ pRockchipPort->assignedBufferNum++;
+ if (pRockchipPort->assignedBufferNum == pRockchipPort->portDefinition.nBufferCountActual) {
+ pRockchipPort->portDefinition.bPopulated = OMX_TRUE;
+ /* Rockchip_OSAL_MutexLock(pRockchipComponent->compMutex); */
+ Rockchip_OSAL_SemaphorePost(pRockchipPort->loadedResource);
+ /* Rockchip_OSAL_MutexUnlock(pRockchipComponent->compMutex); */
+ }
+ *ppBuffer = temp_bufferHeader;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ }
+
+ Rockchip_OSAL_Free(temp_bufferHeader);
+ Rockchip_OSAL_Free(temp_buffer);
+
+ ret = OMX_ErrorInsufficientResources;
+
+EXIT:
+ FunctionOut();
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Rkvpu_OMX_AllocateBuffer in ret = 0x%x", ret);
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_FreeBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ OMX_U8 *temp_buffer = NULL;
+ OMX_U32 i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ pRockchipPort = &pRockchipComponent->pRockchipPort[nPortIndex];
+
+ if (CHECK_PORT_TUNNELED(pRockchipPort) && CHECK_PORT_BUFFER_SUPPLIER(pRockchipPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ if ((pRockchipPort->portState != OMX_StateLoaded) && (pRockchipPort->portState != OMX_StateInvalid)) {
+ (*(pRockchipComponent->pCallbacks->EventHandler)) (pOMXComponent,
+ pRockchipComponent->callbackData,
+ (OMX_U32)OMX_EventError,
+ (OMX_U32)OMX_ErrorPortUnpopulated,
+ nPortIndex, NULL);
+ }
+
+ for (i = 0; i < /*pRockchipPort->portDefinition.nBufferCountActual*/MAX_BUFFER_NUM; i++) {
+ if (((pRockchipPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pRockchipPort->extendBufferHeader[i].OMXBufferHeader != NULL)) {
+ if (pRockchipPort->extendBufferHeader[i].OMXBufferHeader->pBuffer == pBufferHdr->pBuffer) {
+ if (pRockchipPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) {
+ Rockchip_OSAL_Free(pRockchipPort->extendBufferHeader[i].OMXBufferHeader->pBuffer);
+ pRockchipPort->extendBufferHeader[i].OMXBufferHeader->pBuffer = NULL;
+ pBufferHdr->pBuffer = NULL;
+ } else if (pRockchipPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) {
+ ; /* None*/
+ }
+ pRockchipPort->assignedBufferNum--;
+ if (pRockchipPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) {
+ Rockchip_OSAL_Free(pRockchipPort->extendBufferHeader[i].OMXBufferHeader);
+ pRockchipPort->extendBufferHeader[i].OMXBufferHeader = NULL;
+ pBufferHdr = NULL;
+ }
+ pRockchipPort->bufferStateAllocate[i] = BUFFER_STATE_FREE;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ }
+ }
+
+EXIT:
+ if (ret == OMX_ErrorNone) {
+ if (pRockchipPort->assignedBufferNum == 0) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "pRockchipPort->unloadedResource signal set");
+ /* Rockchip_OSAL_MutexLock(pRockchipPort->compMutex); */
+ Rockchip_OSAL_SemaphorePost(pRockchipPort->unloadedResource);
+ /* Rockchip_OSAL_MutexUnlock(pRockchipPort->compMutex); */
+ pRockchipPort->portDefinition.bPopulated = OMX_FALSE;
+ }
+ }
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_AllocateTunnelBuffer(ROCKCHIP_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ (void)pOMXBasePort;
+ (void)nPortIndex;
+ ret = OMX_ErrorTunnelingUnsupported;
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_FreeTunnelBuffer(ROCKCHIP_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ (void)pOMXBasePort;
+ (void)nPortIndex;
+ ret = OMX_ErrorTunnelingUnsupported;
+EXIT:
+ return ret;
+}
+OMX_ERRORTYPE Rkvpu_OMX_ComponentTunnelRequest(
+ OMX_IN OMX_HANDLETYPE hComp,
+ OMX_IN OMX_U32 nPort,
+ OMX_IN OMX_HANDLETYPE hTunneledComp,
+ OMX_IN OMX_U32 nTunneledPort,
+ OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ (void)hComp;
+ (void)nPort;
+ (void)hTunneledComp;
+ (void)nTunneledPort;
+ (void)pTunnelSetup;
+ ret = OMX_ErrorTunnelingUnsupported;
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_GetFlushBuffer(ROCKCHIP_OMX_BASEPORT *pRockchipPort, ROCKCHIP_OMX_DATABUFFER *pDataBuffer[])
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ FunctionIn();
+
+ *pDataBuffer = NULL;
+
+ if (pRockchipPort->portWayType == WAY1_PORT) {
+ *pDataBuffer = &pRockchipPort->way.port1WayDataBuffer.dataBuffer;
+ } else if (pRockchipPort->portWayType == WAY2_PORT) {
+ pDataBuffer[0] = &(pRockchipPort->way.port2WayDataBuffer.inputDataBuffer);
+ pDataBuffer[1] = &(pRockchipPort->way.port2WayDataBuffer.outputDataBuffer);
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
+ ROCKCHIP_OMX_DATABUFFER *pDataPortBuffer[2] = {NULL, NULL};
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+ OMX_U32 flushNum = 0;
+ OMX_S32 semValue = 0;
+ int i = 0, maxBufferNum = 0;
+ FunctionIn();
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+
+ while (Rockchip_OSAL_GetElemNum(&pRockchipPort->bufferQ) > 0) {
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipComponent->pRockchipPort[portIndex].bufferSemID, &semValue);
+ if (semValue == 0)
+ Rockchip_OSAL_SemaphorePost(pRockchipComponent->pRockchipPort[portIndex].bufferSemID);
+
+ Rockchip_OSAL_SemaphoreWait(pRockchipComponent->pRockchipPort[portIndex].bufferSemID);
+ message = (ROCKCHIP_OMX_MESSAGE *)Rockchip_OSAL_Dequeue(&pRockchipPort->bufferQ);
+ if ((message != NULL) && (message->messageType != ROCKCHIP_OMX_CommandFakeBuffer)) {
+ bufferHeader = (OMX_BUFFERHEADERTYPE *)message->pCmdData;
+ bufferHeader->nFilledLen = 0;
+
+ if (portIndex == OUTPUT_PORT_INDEX) {
+ Rockchip_OMX_OutputBufferReturn(pOMXComponent, bufferHeader);
+ } else if (portIndex == INPUT_PORT_INDEX) {
+ Rkvpu_OMX_InputBufferReturn(pOMXComponent, bufferHeader);
+ }
+ }
+ Rockchip_OSAL_Free(message);
+ message = NULL;
+ }
+
+ Rkvpu_OMX_GetFlushBuffer(pRockchipPort, pDataPortBuffer);
+ if (portIndex == INPUT_PORT_INDEX) {
+ if (pDataPortBuffer[0]->dataValid == OMX_TRUE)
+ Rkvpu_InputBufferReturn(pOMXComponent, pDataPortBuffer[0]);
+ if (pDataPortBuffer[1]->dataValid == OMX_TRUE)
+ Rkvpu_InputBufferReturn(pOMXComponent, pDataPortBuffer[1]);
+ } else if (portIndex == OUTPUT_PORT_INDEX) {
+ if (pDataPortBuffer[0]->dataValid == OMX_TRUE)
+ Rkvpu_OutputBufferReturn(pOMXComponent, pDataPortBuffer[0]);
+ if (pDataPortBuffer[1]->dataValid == OMX_TRUE)
+ Rkvpu_OutputBufferReturn(pOMXComponent, pDataPortBuffer[1]);
+ }
+
+ if (pRockchipComponent->bMultiThreadProcess == OMX_TRUE) {
+ if (pRockchipPort->bufferProcessType == BUFFER_SHARE) {
+ if (pRockchipPort->processData.bufferHeader != NULL) {
+ if (portIndex == INPUT_PORT_INDEX) {
+ Rkvpu_OMX_InputBufferReturn(pOMXComponent, pRockchipPort->processData.bufferHeader);
+ } else if (portIndex == OUTPUT_PORT_INDEX) {
+ Rockchip_OMX_OutputBufferReturn(pOMXComponent, pRockchipPort->processData.bufferHeader);
+ }
+ }
+ Rockchip_ResetCodecData(&pRockchipPort->processData);
+
+ maxBufferNum = pRockchipPort->portDefinition.nBufferCountActual;
+ for (i = 0; i < maxBufferNum; i++) {
+ if (pRockchipPort->extendBufferHeader[i].bBufferInOMX == OMX_TRUE) {
+ if (portIndex == OUTPUT_PORT_INDEX) {
+ Rockchip_OMX_OutputBufferReturn(pOMXComponent, pRockchipPort->extendBufferHeader[i].OMXBufferHeader);
+ } else if (portIndex == INPUT_PORT_INDEX) {
+ Rkvpu_OMX_InputBufferReturn(pOMXComponent, pRockchipPort->extendBufferHeader[i].OMXBufferHeader);
+ }
+ }
+ }
+ }
+ } else {
+ Rockchip_ResetCodecData(&pRockchipPort->processData);
+ }
+
+ if ((pRockchipPort->bufferProcessType == BUFFER_SHARE) &&
+ (portIndex == OUTPUT_PORT_INDEX)) {
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ }
+
+ while (1) {
+ OMX_S32 cnt = 0;
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipComponent->pRockchipPort[portIndex].bufferSemID, &cnt);
+ if (cnt <= 0)
+ break;
+ Rockchip_OSAL_SemaphoreWait(pRockchipComponent->pRockchipPort[portIndex].bufferSemID);
+ }
+ Rockchip_OSAL_ResetQueue(&pRockchipPort->bufferQ);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ ROCKCHIP_OMX_DATABUFFER *flushPortBuffer[2] = {NULL, NULL};
+ OMX_U32 i = 0, cnt = 0;
+
+ FunctionIn();
+
+ if (pOMXComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "OMX_CommandFlush start, port:%d", nPortIndex);
+
+ pRockchipComponent->pRockchipPort[nPortIndex].bIsPortFlushed = OMX_TRUE;
+
+ if (pRockchipComponent->bMultiThreadProcess == OMX_FALSE) {
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pauseEvent);
+ } else {
+ Rockchip_OSAL_SignalSet(pRockchipComponent->pRockchipPort[nPortIndex].pauseEvent);
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[nPortIndex];
+ Rkvpu_OMX_GetFlushBuffer(pRockchipPort, flushPortBuffer);
+
+
+ Rockchip_OSAL_SemaphorePost(pRockchipPort->bufferSemID);
+
+ Rockchip_OSAL_MutexLock(flushPortBuffer[0]->bufferMutex);
+ Rockchip_OSAL_MutexLock(flushPortBuffer[1]->bufferMutex);
+
+ ret = Rkvpu_OMX_FlushPort(pOMXComponent, nPortIndex);
+
+ Rockchip_ResetCodecData(&pRockchipPort->processData);
+
+ if (ret == OMX_ErrorNone) {
+ if (nPortIndex == INPUT_PORT_INDEX) {
+ pRockchipComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
+ pRockchipComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
+ Rockchip_OSAL_Memset(pRockchipComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
+ Rockchip_OSAL_Memset(pRockchipComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
+ pRockchipComponent->getAllDelayBuffer = OMX_FALSE;
+ pRockchipComponent->bSaveFlagEOS = OMX_FALSE;
+ pRockchipComponent->bBehaviorEOS = OMX_FALSE;
+ pRockchipComponent->reInputData = OMX_FALSE;
+ }
+
+ pRockchipComponent->pRockchipPort[nPortIndex].bIsPortFlushed = OMX_FALSE;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "OMX_CommandFlush EventCmdComplete, port:%d", nPortIndex);
+ if (bEvent == OMX_TRUE)
+ pRockchipComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventCmdComplete,
+ OMX_CommandFlush, nPortIndex, NULL);
+ }
+ Rockchip_OSAL_MutexUnlock(flushPortBuffer[1]->bufferMutex);
+ Rockchip_OSAL_MutexUnlock(flushPortBuffer[0]->bufferMutex);
+
+EXIT:
+ if ((ret != OMX_ErrorNone) && (pOMXComponent != NULL) && (pRockchipComponent != NULL)) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
+ pRockchipComponent->pCallbacks->EventHandler(pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventError,
+ ret, 0, NULL);
+ }
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_ResolutionUpdate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ROCKCHIP_OMX_BASEPORT *pInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_BASEPORT *pOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+
+ pOutputPort->cropRectangle.nTop = pOutputPort->newCropRectangle.nTop;
+ pOutputPort->cropRectangle.nLeft = pOutputPort->newCropRectangle.nLeft;
+ pOutputPort->cropRectangle.nWidth = pOutputPort->newCropRectangle.nWidth;
+ pOutputPort->cropRectangle.nHeight = pOutputPort->newCropRectangle.nHeight;
+
+ pInputPort->portDefinition.format.video.nFrameWidth = pInputPort->newPortDefinition.format.video.nFrameWidth;
+ pInputPort->portDefinition.format.video.nFrameHeight = pInputPort->newPortDefinition.format.video.nFrameHeight;
+ pInputPort->portDefinition.format.video.nStride = pInputPort->newPortDefinition.format.video.nStride;
+ pInputPort->portDefinition.format.video.nSliceHeight = pInputPort->newPortDefinition.format.video.nSliceHeight;
+
+ pOutputPort->portDefinition.nBufferCountActual = pOutputPort->newPortDefinition.nBufferCountActual;
+ pOutputPort->portDefinition.nBufferCountMin = pOutputPort->newPortDefinition.nBufferCountMin;
+
+ UpdateFrameSize(pOMXComponent);
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATABUFFER *dataBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *rockchipOMXInputPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
+
+ FunctionIn();
+
+ bufferHeader = dataBuffer->bufferHeader;
+
+ if (bufferHeader != NULL) {
+ if (rockchipOMXInputPort->markType.hMarkTargetComponent != NULL ) {
+ bufferHeader->hMarkTargetComponent = rockchipOMXInputPort->markType.hMarkTargetComponent;
+ bufferHeader->pMarkData = rockchipOMXInputPort->markType.pMarkData;
+ rockchipOMXInputPort->markType.hMarkTargetComponent = NULL;
+ rockchipOMXInputPort->markType.pMarkData = NULL;
+ }
+
+ if (bufferHeader->hMarkTargetComponent != NULL) {
+ if (bufferHeader->hMarkTargetComponent == pOMXComponent) {
+ pRockchipComponent->pCallbacks->EventHandler(pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventMark,
+ 0, 0, bufferHeader->pMarkData);
+ } else {
+ pRockchipComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent;
+ pRockchipComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData;
+ }
+ }
+
+ bufferHeader->nFilledLen = 0;
+ bufferHeader->nOffset = 0;
+ Rkvpu_OMX_InputBufferReturn(pOMXComponent, bufferHeader);
+ }
+
+ /* reset dataBuffer */
+ Rockchip_ResetDataBuffer(dataBuffer);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_InputBufferGetQueue(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent)
+{
+ OMX_U32 ret = OMX_ErrorUndefined;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+ ROCKCHIP_OMX_DATABUFFER *inputUseBuffer = NULL;
+
+ FunctionIn();
+
+ inputUseBuffer = &(pRockchipPort->way.port2WayDataBuffer.inputDataBuffer);
+
+ if (pRockchipComponent->currentState != OMX_StateExecuting) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else if ((pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateExecutingToIdle) &&
+ (!CHECK_PORT_BEING_FLUSHED(pRockchipPort))) {
+ Rockchip_OSAL_SemaphoreWait(pRockchipPort->bufferSemID);
+ if (inputUseBuffer->dataValid != OMX_TRUE) {
+ message = (ROCKCHIP_OMX_MESSAGE *)Rockchip_OSAL_Dequeue(&pRockchipPort->bufferQ);
+ if (message == NULL) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ if (message->messageType == ROCKCHIP_OMX_CommandFakeBuffer) {
+ Rockchip_OSAL_Free(message);
+ ret = OMX_ErrorCodecFlush;
+ goto EXIT;
+ }
+
+ inputUseBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
+ inputUseBuffer->allocSize = inputUseBuffer->bufferHeader->nAllocLen;
+ inputUseBuffer->dataLen = inputUseBuffer->bufferHeader->nFilledLen;
+ inputUseBuffer->remainDataLen = inputUseBuffer->dataLen;
+ inputUseBuffer->usedDataLen = 0;
+ inputUseBuffer->dataValid = OMX_TRUE;
+ inputUseBuffer->nFlags = inputUseBuffer->bufferHeader->nFlags;
+ inputUseBuffer->timeStamp = inputUseBuffer->bufferHeader->nTimeStamp;
+
+ Rockchip_OSAL_Free(message);
+
+ if (inputUseBuffer->allocSize <= inputUseBuffer->dataLen)
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_WARNING, "Input Buffer Full, Check input buffer size! allocSize:%d, dataLen:%d", inputUseBuffer->allocSize, inputUseBuffer->dataLen);
+ }
+ ret = OMX_ErrorNone;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATABUFFER *dataBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ ROCKCHIP_OMX_BASEPORT *rockchipOMXOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
+
+ FunctionIn();
+
+ bufferHeader = dataBuffer->bufferHeader;
+
+ if (bufferHeader != NULL) {
+ bufferHeader->nFilledLen = dataBuffer->remainDataLen;
+ bufferHeader->nOffset = 0;
+ bufferHeader->nFlags = dataBuffer->nFlags;
+ bufferHeader->nTimeStamp = dataBuffer->timeStamp;
+
+ if ((rockchipOMXOutputPort->bStoreMetaData == OMX_TRUE) && (bufferHeader->nFilledLen > 0))
+ bufferHeader->nFilledLen = bufferHeader->nAllocLen;
+
+ if (pRockchipComponent->propagateMarkType.hMarkTargetComponent != NULL) {
+ bufferHeader->hMarkTargetComponent = pRockchipComponent->propagateMarkType.hMarkTargetComponent;
+ bufferHeader->pMarkData = pRockchipComponent->propagateMarkType.pMarkData;
+ pRockchipComponent->propagateMarkType.hMarkTargetComponent = NULL;
+ pRockchipComponent->propagateMarkType.pMarkData = NULL;
+ }
+
+ if ((bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "event OMX_BUFFERFLAG_EOS!!!");
+ pRockchipComponent->pCallbacks->EventHandler(pOMXComponent,
+ pRockchipComponent->callbackData,
+ OMX_EventBufferFlag,
+ OUTPUT_PORT_INDEX,
+ bufferHeader->nFlags, NULL);
+ }
+
+ Rockchip_OMX_OutputBufferReturn(pOMXComponent, bufferHeader);
+ }
+
+ /* reset dataBuffer */
+ Rockchip_ResetDataBuffer(dataBuffer);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OutputBufferGetQueue(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent)
+{
+ OMX_U32 ret = OMX_ErrorUndefined;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+ ROCKCHIP_OMX_DATABUFFER *outputUseBuffer = NULL;
+
+ FunctionIn();
+
+ outputUseBuffer = &(pRockchipPort->way.port2WayDataBuffer.outputDataBuffer);
+
+ if (pRockchipComponent->currentState != OMX_StateExecuting) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else if ((pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateExecutingToIdle) &&
+ (!CHECK_PORT_BEING_FLUSHED(pRockchipPort))) {
+ Rockchip_OSAL_SemaphoreWait(pRockchipPort->bufferSemID);
+ if (outputUseBuffer->dataValid != OMX_TRUE) {
+ message = (ROCKCHIP_OMX_MESSAGE *)Rockchip_OSAL_Dequeue(&pRockchipPort->bufferQ);
+ if (message == NULL) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ if (message->messageType == ROCKCHIP_OMX_CommandFakeBuffer) {
+ Rockchip_OSAL_Free(message);
+ ret = OMX_ErrorCodecFlush;
+ goto EXIT;
+ }
+
+ outputUseBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
+ outputUseBuffer->allocSize = outputUseBuffer->bufferHeader->nAllocLen;
+ outputUseBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen;
+ outputUseBuffer->remainDataLen = outputUseBuffer->dataLen;
+ outputUseBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset;
+ outputUseBuffer->dataValid = OMX_TRUE;
+ Rockchip_OSAL_Free(message);
+ }
+ ret = OMX_ErrorNone;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+
+}
+
+OMX_BUFFERHEADERTYPE *Rkvpu_OutputBufferGetQueue_Direct(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent)
+{
+ OMX_BUFFERHEADERTYPE *retBuffer = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ ROCKCHIP_OMX_MESSAGE *message = NULL;
+
+ FunctionIn();
+
+ if (pRockchipComponent->currentState != OMX_StateExecuting) {
+ retBuffer = NULL;
+ goto EXIT;
+ } else if ((pRockchipComponent->transientState != ROCKCHIP_OMX_TransStateExecutingToIdle) &&
+ (!CHECK_PORT_BEING_FLUSHED(pRockchipPort))) {
+ Rockchip_OSAL_SemaphoreWait(pRockchipPort->bufferSemID);
+
+ message = (ROCKCHIP_OMX_MESSAGE *)Rockchip_OSAL_Dequeue(&pRockchipPort->bufferQ);
+ if (message == NULL) {
+ retBuffer = NULL;
+ goto EXIT;
+ }
+ if (message->messageType == ROCKCHIP_OMX_CommandFakeBuffer) {
+ Rockchip_OSAL_Free(message);
+ retBuffer = NULL;
+ goto EXIT;
+ }
+
+ retBuffer = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
+ Rockchip_OSAL_Free(message);
+ }
+
+EXIT:
+ FunctionOut();
+
+ return retBuffer;
+}
+
+OMX_ERRORTYPE Rkvpu_CodecBufferReset(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent, OMX_U32 PortIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+
+ FunctionIn();
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[PortIndex];
+
+ ret = Rockchip_OSAL_ResetQueue(&pRockchipPort->codecBufferQ);
+ if (ret != 0) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ while (1) {
+ OMX_S32 cnt = 0;
+ Rockchip_OSAL_Get_SemaphoreCount(pRockchipPort->codecSemID, &cnt);
+ if (cnt > 0)
+ Rockchip_OSAL_SemaphoreWait(pRockchipPort->codecSemID);
+ else
+ break;
+ }
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_GetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pRockchipComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if (ComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ switch ((OMX_U32)nParamIndex) {
+ case OMX_IndexParamVideoInit: {
+ OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure;
+ ret = Rockchip_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ portParam->nPorts = pRockchipComponent->portParam.nPorts;
+ portParam->nStartPortNumber = pRockchipComponent->portParam.nStartPortNumber;
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamVideoPortFormat: {
+ OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = portFormat->nPortIndex;
+ OMX_U32 index = portFormat->nIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+ OMX_U32 supportFormatNum = 0;
+
+ ret = Rockchip_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((portIndex >= pRockchipComponent->portParam.nPorts)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+
+ if (portIndex == INPUT_PORT_INDEX) {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX];
+ portDefinition = &pRockchipPort->portDefinition;
+
+ switch (index) {
+ case supportFormat_0:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_1:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_2:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_COLOR_FormatAndroidOpaque;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ default:
+ if (index > supportFormat_0) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+ break;
+ }
+ } else if (portIndex == OUTPUT_PORT_INDEX) {
+ supportFormatNum = OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1;
+ if (index > supportFormatNum) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ portDefinition = &pRockchipPort->portDefinition;
+
+ portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat;
+ portFormat->eColorFormat = portDefinition->format.video.eColorFormat;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamVideoBitrate: {
+ OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = videoRateControl->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ portDefinition = &pRockchipPort->portDefinition;
+
+ videoRateControl->eControlRate = pVideoEnc->eControlRate[portIndex];
+ videoRateControl->nTargetBitrate = portDefinition->format.video.nBitrate;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamVideoQuantization: {
+ OMX_VIDEO_PARAM_QUANTIZATIONTYPE *videoQuantizationControl = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = videoQuantizationControl->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ portDefinition = &pRockchipPort->portDefinition;
+
+ videoQuantizationControl->nQpI = pVideoEnc->quantization.nQpI;
+ videoQuantizationControl->nQpP = pVideoEnc->quantization.nQpP;
+ videoQuantizationControl->nQpB = pVideoEnc->quantization.nQpB;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamPortDefinition: {
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = portDefinition->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort;
+
+ if (portIndex >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ Rockchip_OSAL_Memcpy(portDefinition, &pRockchipPort->portDefinition, portDefinition->nSize);
+
+ }
+ break;
+ case OMX_IndexParamVideoIntraRefresh: {
+ OMX_VIDEO_PARAM_INTRAREFRESHTYPE *pIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = pIntraRefresh->nPortIndex;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+
+ if (portIndex != OUTPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ pIntraRefresh->eRefreshMode = pVideoEnc->intraRefresh.eRefreshMode;
+ pIntraRefresh->nAirMBs = pVideoEnc->intraRefresh.nAirMBs;
+ pIntraRefresh->nAirRef = pVideoEnc->intraRefresh.nAirRef;
+ pIntraRefresh->nCirMBs = pVideoEnc->intraRefresh.nCirMBs;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+
+ case OMX_IndexParamStandardComponentRole: {
+ OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)ComponentParameterStructure;
+ ret = Rockchip_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pVideoEnc->codecId == OMX_VIDEO_CodingAVC) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_H264_ENC_ROLE);
+ } else if (pVideoEnc->codecId == OMX_VIDEO_CodingVP8) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_VP8_ENC_ROLE);
+ } else if (pVideoEnc->codecId == OMX_VIDEO_CodingHEVC) {
+ Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_HEVC_ENC_ROLE);
+ }
+ }
+ break;
+ case OMX_IndexParamVideoAvc: {
+ OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)ComponentParameterStructure;
+ OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ ret = Rockchip_OMX_Check_SizeVersion(pDstAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstAVCComponent->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pSrcAVCComponent = &pVideoEnc->AVCComponent[pDstAVCComponent->nPortIndex];
+ Rockchip_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ }
+ break;
+ case OMX_IndexParamVideoHevc: {
+ OMX_VIDEO_PARAM_HEVCTYPE *pDstHEVCComponent = (OMX_VIDEO_PARAM_HEVCTYPE *)ComponentParameterStructure;
+ OMX_VIDEO_PARAM_HEVCTYPE *pSrcHEVCComponent = NULL;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ ret = Rockchip_OMX_Check_SizeVersion(pDstHEVCComponent, sizeof(OMX_VIDEO_PARAM_HEVCTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstHEVCComponent->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pSrcHEVCComponent = &pVideoEnc->HEVCComponent[pDstHEVCComponent->nPortIndex];
+ Rockchip_OSAL_Memcpy(pDstHEVCComponent, pSrcHEVCComponent, sizeof(OMX_VIDEO_PARAM_HEVCTYPE));
+ }
+ break;
+ case OMX_IndexParamVideoProfileLevelQuerySupported: {
+ OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevel =
+ (OMX_VIDEO_PARAM_PROFILELEVELTYPE *) ComponentParameterStructure;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ OMX_U32 index = profileLevel->nProfileIndex;
+ OMX_U32 nProfileLevels = 0;
+ if (profileLevel->nPortIndex >= ALL_PORT_NUM) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Invalid port index: %ld", profileLevel->nPortIndex);
+ ret = OMX_ErrorUnsupportedIndex;
+ goto EXIT;
+ }
+ if (pVideoEnc->codecId == OMX_VIDEO_CodingAVC) {
+ nProfileLevels =
+ sizeof(kProfileLevels) / sizeof(kProfileLevels[0]);
+ if (index >= nProfileLevels) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+ profileLevel->eProfile = kProfileLevels[index].mProfile;
+ profileLevel->eLevel = kProfileLevels[index].mLevel;
+ } else {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamRkEncExtendedVideo: { // extern for huawei param setting
+ OMX_VIDEO_PARAMS_EXTENDED *params_extend = (OMX_VIDEO_PARAMS_EXTENDED *)ComponentParameterStructure;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_DEBUG, "get OMX_IndexParamRkEncExtendedVideo in ");
+ Rockchip_OSAL_MutexLock(pVideoEnc->bScale_Mutex);
+ Rockchip_OSAL_Memcpy(params_extend, &pVideoEnc->params_extend, sizeof(OMX_VIDEO_PARAMS_EXTENDED));
+ Rockchip_OSAL_MutexUnlock(pVideoEnc->bScale_Mutex);
+ }
+ break;
+
+
+ default: {
+ ret = Rockchip_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+OMX_ERRORTYPE Rkvpu_OMX_SetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pRockchipComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if (ComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ switch ((OMX_U32)nIndex) {
+ case OMX_IndexParamVideoPortFormat: {
+ OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = portFormat->nPortIndex;
+ OMX_U32 index = portFormat->nIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+ OMX_U32 supportFormatNum = 0;
+
+ ret = Rockchip_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((portIndex >= pRockchipComponent->portParam.nPorts)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ portDefinition = &pRockchipPort->portDefinition;
+
+ portDefinition->format.video.eColorFormat = portFormat->eColorFormat;
+ portDefinition->format.video.eCompressionFormat = portFormat->eCompressionFormat;
+ portDefinition->format.video.xFramerate = portFormat->xFramerate;
+ }
+ }
+ break;
+ case OMX_IndexParamVideoBitrate: {
+ OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = videoRateControl->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ portDefinition = &pRockchipPort->portDefinition;
+
+ pVideoEnc->eControlRate[portIndex] = videoRateControl->eControlRate;
+ portDefinition->format.video.nBitrate = videoRateControl->nTargetBitrate;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamVideoQuantization: {
+ OMX_VIDEO_PARAM_QUANTIZATIONTYPE *videoQuantizationControl = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = videoQuantizationControl->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ portDefinition = &pRockchipPort->portDefinition;
+
+ pVideoEnc->quantization.nQpI = videoQuantizationControl->nQpI;
+ pVideoEnc->quantization.nQpP = videoQuantizationControl->nQpP;
+ pVideoEnc->quantization.nQpB = videoQuantizationControl->nQpB;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamPortDefinition: {
+ OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = pPortDefinition->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort;
+ OMX_U32 width, height, size;
+
+ if (portIndex >= pRockchipComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = Rockchip_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+
+ if ((pRockchipComponent->currentState != OMX_StateLoaded) && (pRockchipComponent->currentState != OMX_StateWaitForResources)) {
+ if (pRockchipPort->portDefinition.bEnabled == OMX_TRUE) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ }
+ if (pPortDefinition->nBufferCountActual < pRockchipPort->portDefinition.nBufferCountMin) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ Rockchip_OSAL_Memcpy(&pRockchipPort->portDefinition, pPortDefinition, pPortDefinition->nSize);
+ if (portIndex == INPUT_PORT_INDEX) {
+ ROCKCHIP_OMX_BASEPORT *pRockchipOutputPort = &pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX];
+ UpdateFrameSize(pOMXComponent);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "pRockchipOutputPort->portDefinition.nBufferSize: %d",
+ pRockchipOutputPort->portDefinition.nBufferSize);
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamVideoIntraRefresh: {
+ OMX_VIDEO_PARAM_INTRAREFRESHTYPE *pIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = pIntraRefresh->nPortIndex;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+
+ if (portIndex != OUTPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ if (pIntraRefresh->eRefreshMode == OMX_VIDEO_IntraRefreshCyclic) {
+ pVideoEnc->intraRefresh.eRefreshMode = pIntraRefresh->eRefreshMode;
+ pVideoEnc->intraRefresh.nCirMBs = pIntraRefresh->nCirMBs;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "OMX_VIDEO_IntraRefreshCyclic Enable, nCirMBs: %d",
+ pVideoEnc->intraRefresh.nCirMBs);
+ } else {
+ ret = OMX_ErrorUnsupportedSetting;
+ goto EXIT;
+ }
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+
+#ifdef USE_STOREMETADATA
+ case OMX_IndexParamStoreMetaDataBuffer: {
+ ret = Rockchip_OSAL_SetANBParameter(hComponent, nIndex, ComponentParameterStructure);
+
+ }
+ break;
+#endif
+ case OMX_IndexParamPrependSPSPPSToIDR: {
+#if 0
+ RKON2_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ pVideoEnc = (RKON2_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ PrependSPSPPSToIDRFramesParams *PrependParams =
+ (PrependSPSPPSToIDRFramesParams*)ComponentParameterStructure;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "OMX_IndexParamPrependSPSPPSToIDR set true");
+
+ pVideoEnc->bPrependSpsPpsToIdr = PrependParams->bEnable;
+
+ return OMX_ErrorNone;
+#endif
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ret = Rockchip_OSAL_SetPrependSPSPPSToIDR(ComponentParameterStructure, &pVideoEnc->bPrependSpsPpsToIdr);
+ }
+ break;
+
+ case OMX_IndexParamStandardComponentRole: {
+ OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)ComponentParameterStructure;
+
+ ret = Rockchip_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((pRockchipComponent->currentState != OMX_StateLoaded) && (pRockchipComponent->currentState != OMX_StateWaitForResources)) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_H264_ENC_ROLE)) {
+ pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_VP8_ENC_ROLE)) {
+ pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingVP8;
+ } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_HEVC_ENC_ROLE)) {
+ pRockchipComponent->pRockchipPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingHEVC;
+ }else {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+ break;
+ case OMX_IndexParamVideoAvc: {
+ OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL;
+ OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)ComponentParameterStructure;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ret = Rockchip_OMX_Check_SizeVersion(pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pSrcAVCComponent->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pDstAVCComponent = &pVideoEnc->AVCComponent[pSrcAVCComponent->nPortIndex];
+
+ Rockchip_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ }
+
+ break;
+ case OMX_IndexParamVideoHevc: {
+ OMX_VIDEO_PARAM_HEVCTYPE *pDstHEVCComponent = NULL;
+ OMX_VIDEO_PARAM_HEVCTYPE *pSrcHEVCComponent = (OMX_VIDEO_PARAM_HEVCTYPE *)ComponentParameterStructure;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+ ret = Rockchip_OMX_Check_SizeVersion(pSrcHEVCComponent, sizeof(OMX_VIDEO_PARAM_HEVCTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pSrcHEVCComponent->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pDstHEVCComponent = &pVideoEnc->HEVCComponent[pSrcHEVCComponent->nPortIndex];
+ Rockchip_OSAL_Memcpy(pDstHEVCComponent, pSrcHEVCComponent, sizeof(OMX_VIDEO_PARAM_HEVCTYPE));
+ }
+ break;
+ case OMX_IndexParamRkEncExtendedVideo: { // extern for huawei param setting
+ OMX_VIDEO_PARAMS_EXTENDED *params_extend = (OMX_VIDEO_PARAMS_EXTENDED *)ComponentParameterStructure;
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_DEBUG, "OMX_IndexParamRkEncExtendedVideo in ");
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ Rockchip_OSAL_MutexLock(pVideoEnc->bScale_Mutex);
+ Rockchip_OSAL_Memcpy(&pVideoEnc->params_extend, params_extend, sizeof(OMX_VIDEO_PARAMS_EXTENDED));
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_DEBUG, "OMX_IndexParamRkEncExtendedVideo in flags %d bEableCrop %d,cl %d cr %d ct %d cb %d, bScaling %d ScaleW %d ScaleH %d",
+ pVideoEnc->params_extend.ui32Flags, pVideoEnc->params_extend.bEnableCropping, pVideoEnc->params_extend.ui16CropLeft, pVideoEnc->params_extend.ui16CropRight,
+ pVideoEnc->params_extend.ui16CropTop, pVideoEnc->params_extend.ui16CropBottom, pVideoEnc->params_extend.bEnableScaling,
+ pVideoEnc->params_extend.ui16ScaledWidth, pVideoEnc->params_extend.ui16ScaledHeight);
+ Rockchip_OSAL_MutexUnlock(pVideoEnc->bScale_Mutex);
+ }
+ break;
+ default: {
+ ret = Rockchip_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_GetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ switch (nIndex) {
+ case OMX_IndexConfigVideoAVCIntraPeriod: {
+
+ OMX_VIDEO_CONFIG_AVCINTRAPERIOD *pAVCIntraPeriod = (OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pComponentConfigStructure;
+ OMX_U32 portIndex = pAVCIntraPeriod->nPortIndex;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pAVCIntraPeriod->nIDRPeriod = pVideoEnc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames + 1;
+ pAVCIntraPeriod->nPFrames = pVideoEnc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames;
+ }
+ }
+ break;
+ case OMX_IndexConfigVideoBitrate: {
+ OMX_VIDEO_CONFIG_BITRATETYPE *pEncodeBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure;
+ OMX_U32 portIndex = pEncodeBitrate->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ pEncodeBitrate->nEncodeBitrate = pRockchipPort->portDefinition.format.video.nBitrate;
+ }
+ }
+ break;
+ case OMX_IndexConfigVideoFramerate: {
+ OMX_CONFIG_FRAMERATETYPE *pFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure;
+ OMX_U32 portIndex = pFramerate->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ pFramerate->xEncodeFramerate = pRockchipPort->portDefinition.format.video.xFramerate;
+ }
+ }
+ break;
+ default:
+ ret = Rockchip_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_SetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ RKVPU_OMX_VIDEOENC_COMPONENT *pVideoEnc = (RKVPU_OMX_VIDEOENC_COMPONENT *)pRockchipComponent->hComponentHandle;
+
+ switch ((OMX_U32)nIndex) {
+ case OMX_IndexConfigVideoIntraPeriod: {
+ OMX_U32 nPFrames = (*((OMX_U32 *)pComponentConfigStructure)) - 1;
+
+ pVideoEnc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames = nPFrames;
+
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexConfigVideoAVCIntraPeriod: {
+ OMX_VIDEO_CONFIG_AVCINTRAPERIOD *pAVCIntraPeriod = (OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pComponentConfigStructure;
+ OMX_U32 portIndex = pAVCIntraPeriod->nPortIndex;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ if (pAVCIntraPeriod->nIDRPeriod == (pAVCIntraPeriod->nPFrames + 1))
+ pVideoEnc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames = pAVCIntraPeriod->nPFrames;
+ else {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+ }
+ break;
+ case OMX_IndexConfigVideoBitrate: {
+ OMX_VIDEO_CONFIG_BITRATETYPE *pEncodeBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure;
+ OMX_U32 portIndex = pEncodeBitrate->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ VpuCodecContext_t *p_vpu_ctx = pVideoEnc->vpu_ctx;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ pRockchipPort->portDefinition.format.video.nBitrate = pEncodeBitrate->nEncodeBitrate;
+ if (p_vpu_ctx != NULL) {
+ EncParameter_t vpug;
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_GETCFG, (void*)&vpug);
+ vpug.bitRate = pEncodeBitrate->nEncodeBitrate;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "set bitRate %d", pEncodeBitrate->nEncodeBitrate);
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETCFG, (void*)&vpug);
+ }
+ }
+ }
+ break;
+ case OMX_IndexConfigVideoFramerate: {
+ OMX_CONFIG_FRAMERATETYPE *pFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure;
+ OMX_U32 portIndex = pFramerate->nPortIndex;
+ ROCKCHIP_OMX_BASEPORT *pRockchipPort = NULL;
+ VpuCodecContext_t *p_vpu_ctx = pVideoEnc->vpu_ctx;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex];
+ pRockchipPort->portDefinition.format.video.xFramerate = pFramerate->xEncodeFramerate;
+ }
+
+ if (p_vpu_ctx != NULL) {
+ EncParameter_t vpug;
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_GETCFG, (void*)&vpug);
+ vpug.framerate = (pFramerate->xEncodeFramerate >> 16);
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETCFG, (void*)&vpug);
+ }
+ }
+ break;
+ case OMX_IndexConfigVideoIntraVOPRefresh: {
+ OMX_CONFIG_INTRAREFRESHVOPTYPE *pIntraRefreshVOP = (OMX_CONFIG_INTRAREFRESHVOPTYPE *)pComponentConfigStructure;
+ OMX_U32 portIndex = pIntraRefreshVOP->nPortIndex;
+
+ VpuCodecContext_t *p_vpu_ctx = pVideoEnc->vpu_ctx;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVideoEnc->IntraRefreshVOP = pIntraRefreshVOP->IntraRefreshVOP;
+ }
+
+ if (p_vpu_ctx != NULL && pVideoEnc->IntraRefreshVOP) {
+ p_vpu_ctx->control(p_vpu_ctx, VPU_API_ENC_SETIDRFRAME, NULL);
+ }
+ }
+ break;
+ default:
+ ret = Rockchip_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rkvpu_OMX_ComponentRoleEnum(
+ OMX_HANDLETYPE hComponent,
+ OMX_U8 *cRole,
+ OMX_U32 nIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchioComponent = NULL;
+
+ FunctionIn();
+
+ if ((hComponent == NULL) || (cRole == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ if (nIndex == 0) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_H264_ENC_ROLE);
+ ret = OMX_ErrorNone;
+ } else if (nIndex == 1) {
+ Rockchip_OSAL_Strcpy((char *)cRole, RK_OMX_COMPONENT_VP8_ENC_ROLE);
+ ret = OMX_ErrorNone;
+ } else {
+ ret = OMX_ErrorNoMore;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+
+OMX_ERRORTYPE Rkvpu_OMX_GetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = Rockchip_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pRockchipComponent = (ROCKCHIP_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if ((cParameterName == NULL) || (pIndexType == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pRockchipComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_CONFIG_VIDEO_INTRAPERIOD) == 0) {
+ *pIndexType = (OMX_INDEXTYPE)OMX_IndexConfigVideoIntraPeriod;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ } else if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PARAM_PREPEND_SPSPPS_TO_IDR) == 0) {
+ *pIndexType = (OMX_INDEXTYPE)OMX_IndexParamPrependSPSPPSToIDR;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ } else if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PARAM_EXTENDED_VIDEO) == 0) {
+
+ *pIndexType = (OMX_INDEXTYPE)OMX_IndexParamRkEncExtendedVideo;
+ ret = OMX_ErrorNone;
+ }
+#ifdef USE_STOREMETADATA
+ else if (Rockchip_OSAL_Strcmp(cParameterName, ROCKCHIP_INDEX_PARAM_STORE_METADATA_BUFFER) == 0) {
+ *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamStoreMetaDataBuffer;
+ goto EXIT;
+ } else {
+ ret = Rockchip_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+#else
+ else {
+ ret = Rockchip_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+#endif
+
+EXIT:
+ FunctionOut();
+ return ret;
+}
diff --git a/component/video/enc/Rkvpu_OMX_VencControl.h b/component/video/enc/Rkvpu_OMX_VencControl.h
new file mode 100755
index 0000000..f1c15e7
--- /dev/null
+++ b/component/video/enc/Rkvpu_OMX_VencControl.h
@@ -0,0 +1,127 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rkvpu_OMX_VencControl.h
+ * @brief
+ * @author Csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.28 : Create
+ */
+
+#ifndef RKVPU_OMX_VIDEO_ENCODERCONTROL
+#define RKVPU_OMX_VIDEO_ENCODERCONTROL
+
+#include "OMX_Component.h"
+#include "Rockchip_OMX_Def.h"
+#include "Rockchip_OSAL_Queue.h"
+#include "Rockchip_OMX_Baseport.h"
+#include "Rockchip_OMX_Basecomponent.h"
+#include "library_register.h"
+#include "vpu_global.h"
+#include "OMX_IndexExt.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE Rkvpu_OMX_UseBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes,
+ OMX_IN OMX_U8 *pBuffer);
+
+OMX_ERRORTYPE Rkvpu_OMX_AllocateBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes);
+
+OMX_ERRORTYPE Rkvpu_OMX_FreeBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr);
+
+OMX_ERRORTYPE Rkvpu_OMX_AllocateTunnelBuffer(
+ ROCKCHIP_OMX_BASEPORT *pOMXBasePort,
+ OMX_U32 nPortIndex);
+
+OMX_ERRORTYPE Rkvpu_OMX_FreeTunnelBuffer(
+ ROCKCHIP_OMX_BASEPORT *pOMXBasePort,
+ OMX_U32 nPortIndex);
+
+OMX_ERRORTYPE Rkvpu_OMX_ComponentTunnelRequest(
+ OMX_IN OMX_HANDLETYPE hComp,
+ OMX_IN OMX_U32 nPort,
+ OMX_IN OMX_HANDLETYPE hTunneledComp,
+ OMX_IN OMX_U32 nTunneledPort,
+ OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup);
+
+OMX_ERRORTYPE Rkvpu_OMX_GetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure);
+
+OMX_ERRORTYPE Rkvpu_OMX_SetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure);
+
+OMX_ERRORTYPE Rkvpu_OMX_GetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure);
+
+OMX_ERRORTYPE Rkvpu_OMX_SetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure);
+
+OMX_ERRORTYPE Rkvpu_OMX_ComponentRoleEnum(
+ OMX_HANDLETYPE hComponent,
+ OMX_U8 *cRole,
+ OMX_U32 nIndex);
+
+
+OMX_ERRORTYPE Rkvpu_OMX_GetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType);
+
+OMX_ERRORTYPE Rkvpu_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATABUFFER *dataBuffer);
+OMX_ERRORTYPE Rkvpu_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, ROCKCHIP_OMX_DATABUFFER *dataBuffer);
+OMX_ERRORTYPE Rkvpu_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent);
+OMX_ERRORTYPE Rkvpu_OutputBufferGetQueue(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent);
+OMX_ERRORTYPE Rkvpu_InputBufferGetQueue(ROCKCHIP_OMX_BASECOMPONENT *pRockchipComponent);
+OMX_ERRORTYPE Rkvpu_ResolutionUpdate(OMX_COMPONENTTYPE *pOMXComponent);
+
+
+#ifdef USE_ANB
+OMX_ERRORTYPE Rkvpu_Shared_ANBBufferToData(ROCKCHIP_OMX_DATABUFFER *pUseBuffer, ROCKCHIP_OMX_DATA *pData, ROCKCHIP_OMX_BASEPORT *pRockchipPort, ROCKCHIP_OMX_PLANE nPlane);
+OMX_ERRORTYPE Rkvpu_Shared_DataToANBBuffer(ROCKCHIP_OMX_DATA *pData, ROCKCHIP_OMX_DATABUFFER *pUseBuffer, ROCKCHIP_OMX_BASEPORT *pRockchipPort);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/component/video/enc/library_register.c b/component/video/enc/library_register.c
new file mode 100755
index 0000000..3e540c8
--- /dev/null
+++ b/component/video/enc/library_register.c
@@ -0,0 +1,60 @@
+/*
+ *
+ * Copyright 2013 rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file library_register.c
+ * @brief
+ * @author Csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.27 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#include "Rockchip_OSAL_Memory.h"
+#include "Rockchip_OSAL_ETC.h"
+#include "library_register.h"
+#include "Rockchip_OSAL_Log.h"
+
+
+OSCL_EXPORT_REF int Rockchip_OMX_COMPONENT_Library_Register(RockchipRegisterComponentType **rockchipComponents)
+{
+ FunctionIn();
+
+ if (rockchipComponents == NULL)
+ goto EXIT;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[0]->componentName, RK_OMX_COMPONENT_H264_ENC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[0]->roles[0], RK_OMX_COMPONENT_H264_ENC_ROLE);
+ rockchipComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[1]->componentName, RK_OMX_COMPONENT_VP8_ENC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[1]->roles[0], RK_OMX_COMPONENT_VP8_ENC_ROLE);
+ rockchipComponents[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ Rockchip_OSAL_Strcpy(rockchipComponents[2]->componentName, RK_OMX_COMPONENT_HEVC_ENC);
+ Rockchip_OSAL_Strcpy(rockchipComponents[2]->roles[0], RK_OMX_COMPONENT_HEVC_ENC_ROLE);
+ rockchipComponents[2]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+EXIT:
+ FunctionOut();
+
+ return MAX_COMPONENT_NUM;
+}
diff --git a/component/video/enc/library_register.h b/component/video/enc/library_register.h
new file mode 100755
index 0000000..aeef27d
--- /dev/null
+++ b/component/video/enc/library_register.h
@@ -0,0 +1,59 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file library_register.h
+ * @brief
+ * @author Csy (csy@rockchip.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.27 : Create
+ */
+
+#ifndef ROCKCHIP_OMX_ENC_REG
+#define ROCKCHIP_OMX_ENC_REG
+
+#include "Rockchip_OMX_Def.h"
+#include "OMX_Component.h"
+#include "Rockchip_OMX_Component_Register.h"
+
+
+#define OSCL_EXPORT_REF __attribute__((visibility("default")))
+#define MAX_COMPONENT_NUM 3
+#define MAX_COMPONENT_ROLE_NUM 3
+
+#define RK_OMX_COMPONENT_H264_ENC "OMX.rk.video_encoder.avc"
+#define RK_OMX_COMPONENT_H264_ENC_ROLE "video_encoder.avc"
+
+#define RK_OMX_COMPONENT_VP8_ENC "OMX.rk.video_encoder.vp8"
+#define RK_OMX_COMPONENT_VP8_ENC_ROLE "video_encoder.vp8"
+
+#define RK_OMX_COMPONENT_HEVC_ENC "OMX.rk.video_encoder.hevc"
+#define RK_OMX_COMPONENT_HEVC_ENC_ROLE "video_encoder.hevc"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSCL_EXPORT_REF int Rockchip_OMX_COMPONENT_Library_Register(RockchipRegisterComponentType **rockchipComponents);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
+
diff --git a/core/Android.mk b/core/Android.mk
new file mode 100644
index 0000000..50498a1
--- /dev/null
+++ b/core/Android.mk
@@ -0,0 +1,27 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ Rockchip_OMX_Component_Register.c \
+ Rockchip_OMX_Core.c
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libOMX_Core
+
+LOCAL_CFLAGS :=
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := libRkOMX_OSAL libRkOMX_Basecomponent
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils liblog \
+ libRkOMX_Resourcemanager
+
+LOCAL_C_INCLUDES := $(ROCKCHIP_OMX_INC)/khronos \
+ $(ROCKCHIP_OMX_INC)/rockchip \
+ $(ROCKCHIP_OMX_TOP)/osal \
+ $(ROCKCHIP_OMX_TOP)/component/common \
+ $(TOP)/hardware/rk29/librkvpu \
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/core/Rockchip_OMX_Component_Register.c b/core/Rockchip_OMX_Component_Register.c
new file mode 100755
index 0000000..286aaab
--- /dev/null
+++ b/core/Rockchip_OMX_Component_Register.c
@@ -0,0 +1,241 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rockchip_OMX_Component_Register.c
+ * @brief Rockchip OpenMAX IL Component Register
+ * @author csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.26 : Create
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+#include <assert.h>
+#include <dirent.h>
+
+#include "OMX_Component.h"
+#include "Rockchip_OSAL_Memory.h"
+#include "Rockchip_OSAL_ETC.h"
+#include "Rockchip_OSAL_Library.h"
+#include "Rockchip_OMX_Component_Register.h"
+#include "Rockchip_OMX_Macros.h"
+#include "git_info.h"
+
+#undef ROCKCHIP_LOG_TAG
+#define ROCKCHIP_LOG_TAG "ROCKCHIP_COMP_REGS"
+#define ROCKCHIP_LOG_OFF
+#include "Rockchip_OSAL_Log.h"
+static const ROCKCHIP_COMPONENT_INFO kCompInfo[] = {
+ { "rk.omx_dec", "libomxvpu_dec.so" },
+ { "rk.omx_enc", "libomxvpu_enc.so" },
+};
+
+OMX_ERRORTYPE Rockchip_OMX_Component_Register(ROCKCHIP_OMX_COMPONENT_REGLIST **compList, OMX_U32 *compNum)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ int componentNum = 0, roleNum = 0, totalCompNum = 0;
+ int i = 0;
+ const char *errorMsg;
+ int kNumEntries = sizeof(kCompInfo) / sizeof(kCompInfo[0]);
+
+ int (*Rockchip_OMX_COMPONENT_Library_Register)(RockchipRegisterComponentType **rockchipComponents);
+ RockchipRegisterComponentType **rockchipComponentsTemp;
+ ROCKCHIP_OMX_COMPONENT_REGLIST *componentList;
+
+ FunctionIn();
+
+ componentList = (ROCKCHIP_OMX_COMPONENT_REGLIST *)Rockchip_OSAL_Malloc(sizeof(ROCKCHIP_OMX_COMPONENT_REGLIST) * MAX_OMX_COMPONENT_NUM);
+ Rockchip_OSAL_Memset(componentList, 0, sizeof(ROCKCHIP_OMX_COMPONENT_REGLIST) * MAX_OMX_COMPONENT_NUM);
+
+ for (i = 0; i < kNumEntries; i++) {
+ ROCKCHIP_COMPONENT_INFO com_inf = kCompInfo[i];
+ OMX_PTR soHandle = NULL;
+ if ((soHandle = Rockchip_OSAL_dlopen(com_inf.lib_name, RTLD_NOW)) != NULL) {
+ Rockchip_OSAL_dlerror(); /* clear error*/
+ if ((Rockchip_OMX_COMPONENT_Library_Register = Rockchip_OSAL_dlsym(soHandle, "Rockchip_OMX_COMPONENT_Library_Register")) != NULL) {
+ int i = 0;
+ unsigned int j = 0;
+ componentNum = (*Rockchip_OMX_COMPONENT_Library_Register)(NULL);
+ rockchipComponentsTemp = (RockchipRegisterComponentType **)Rockchip_OSAL_Malloc(sizeof(RockchipRegisterComponentType*) * componentNum);
+ for (i = 0; i < componentNum; i++) {
+ rockchipComponentsTemp[i] = Rockchip_OSAL_Malloc(sizeof(RockchipRegisterComponentType));
+ Rockchip_OSAL_Memset(rockchipComponentsTemp[i], 0, sizeof(RockchipRegisterComponentType));
+ }
+ (*Rockchip_OMX_COMPONENT_Library_Register)(rockchipComponentsTemp);
+
+ for (i = 0; i < componentNum; i++) {
+ Rockchip_OSAL_Strcpy(componentList[totalCompNum].component.componentName, rockchipComponentsTemp[i]->componentName);
+ for (j = 0; j < rockchipComponentsTemp[i]->totalRoleNum; j++)
+ Rockchip_OSAL_Strcpy(componentList[totalCompNum].component.roles[j], rockchipComponentsTemp[i]->roles[j]);
+ componentList[totalCompNum].component.totalRoleNum = rockchipComponentsTemp[i]->totalRoleNum;
+
+ Rockchip_OSAL_Strcpy(componentList[totalCompNum].libName, com_inf.lib_name);
+
+ totalCompNum++;
+ }
+ for (i = 0; i < componentNum; i++) {
+ Rockchip_OSAL_Free(rockchipComponentsTemp[i]);
+ }
+
+ Rockchip_OSAL_Free(rockchipComponentsTemp);
+ } else {
+ if ((errorMsg = Rockchip_OSAL_dlerror()) != NULL)
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_WARNING, "dlsym failed: %s", errorMsg);
+ }
+ Rockchip_OSAL_dlclose(soHandle);
+ }
+ }
+ *compList = componentList;
+ *compNum = totalCompNum;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_Component_Unregister(ROCKCHIP_OMX_COMPONENT_REGLIST *componentList)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ Rockchip_OSAL_Free(componentList);
+
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_ComponentAPICheck(OMX_COMPONENTTYPE *component)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ if ((NULL == component->GetComponentVersion) ||
+ (NULL == component->SendCommand) ||
+ (NULL == component->GetParameter) ||
+ (NULL == component->SetParameter) ||
+ (NULL == component->GetConfig) ||
+ (NULL == component->SetConfig) ||
+ (NULL == component->GetExtensionIndex) ||
+ (NULL == component->GetState) ||
+ (NULL == component->ComponentTunnelRequest) ||
+ (NULL == component->UseBuffer) ||
+ (NULL == component->AllocateBuffer) ||
+ (NULL == component->FreeBuffer) ||
+ (NULL == component->EmptyThisBuffer) ||
+ (NULL == component->FillThisBuffer) ||
+ (NULL == component->SetCallbacks) ||
+ (NULL == component->ComponentDeInit) ||
+ (NULL == component->UseEGLImage) ||
+ (NULL == component->ComponentRoleEnum))
+ ret = OMX_ErrorInvalidComponent;
+ else
+ ret = OMX_ErrorNone;
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_ComponentLoad(ROCKCHIP_OMX_COMPONENT *rockchip_component)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_HANDLETYPE libHandle;
+ OMX_COMPONENTTYPE *pOMXComponent;
+
+ FunctionIn();
+
+ OMX_ERRORTYPE (*Rockchip_OMX_ComponentConstructor)(OMX_HANDLETYPE hComponent, OMX_STRING componentName);
+
+ libHandle = Rockchip_OSAL_dlopen((OMX_STRING)rockchip_component->libName, RTLD_NOW);
+ if (!libHandle) {
+ ret = OMX_ErrorInvalidComponentName;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInvalidComponentName, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ Rockchip_OMX_ComponentConstructor = Rockchip_OSAL_dlsym(libHandle, "Rockchip_OMX_ComponentConstructor");
+ if (!Rockchip_OMX_ComponentConstructor) {
+ Rockchip_OSAL_dlclose(libHandle);
+ ret = OMX_ErrorInvalidComponent;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ pOMXComponent = (OMX_COMPONENTTYPE *)Rockchip_OSAL_Malloc(sizeof(OMX_COMPONENTTYPE));
+ INIT_SET_SIZE_VERSION(pOMXComponent, OMX_COMPONENTTYPE);
+ ret = (*Rockchip_OMX_ComponentConstructor)((OMX_HANDLETYPE)pOMXComponent, (OMX_STRING)rockchip_component->componentName);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_Free(pOMXComponent);
+ Rockchip_OSAL_dlclose(libHandle);
+ ret = OMX_ErrorInvalidComponent;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__);
+ goto EXIT;
+ } else {
+ if (Rockchip_OMX_ComponentAPICheck(pOMXComponent) != OMX_ErrorNone) {
+ if (NULL != pOMXComponent->ComponentDeInit)
+ pOMXComponent->ComponentDeInit(pOMXComponent);
+ Rockchip_OSAL_Free(pOMXComponent);
+ Rockchip_OSAL_dlclose(libHandle);
+ ret = OMX_ErrorInvalidComponent;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ rockchip_component->libHandle = libHandle;
+ rockchip_component->pOMXComponent = pOMXComponent;
+ rockchip_component->rkversion = OMX_COMPILE_INFO;
+ ret = OMX_ErrorNone;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE Rockchip_OMX_ComponentUnload(ROCKCHIP_OMX_COMPONENT *rockchip_component)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+
+ FunctionIn();
+
+ if (!rockchip_component) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pOMXComponent = rockchip_component->pOMXComponent;
+ if (pOMXComponent != NULL) {
+ pOMXComponent->ComponentDeInit(pOMXComponent);
+ Rockchip_OSAL_Free(pOMXComponent);
+ rockchip_component->pOMXComponent = NULL;
+ }
+
+ if (rockchip_component->libHandle != NULL) {
+ Rockchip_OSAL_dlclose(rockchip_component->libHandle);
+ rockchip_component->libHandle = NULL;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
diff --git a/core/Rockchip_OMX_Component_Register.h b/core/Rockchip_OMX_Component_Register.h
new file mode 100644
index 0000000..def36a3
--- /dev/null
+++ b/core/Rockchip_OMX_Component_Register.h
@@ -0,0 +1,79 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rockchip_OMX_Component_Register.h
+ * @brief Rockchip OpenMAX IL Component Register
+ * @author csy (csy@rock-chips.com)
+ * @version 1.0.0
+ * @history
+ * 2013.11.26 : Create
+ */
+
+#ifndef ROCKCHIP_OMX_COMPONENT_REG
+#define ROCKCHIP_OMX_COMPONENT_REG
+
+#include "Rockchip_OMX_Def.h"
+#include "OMX_Types.h"
+#include "OMX_Core.h"
+#include "OMX_Component.h"
+
+
+typedef struct _RockchipRegisterComponentType {
+ OMX_U8 componentName[MAX_OMX_COMPONENT_NAME_SIZE];
+ OMX_U8 roles[MAX_OMX_COMPONENT_ROLE_NUM][MAX_OMX_COMPONENT_ROLE_SIZE];
+ OMX_U32 totalRoleNum;
+} RockchipRegisterComponentType;
+
+typedef struct _ROCKCHIP_OMX_COMPONENT_REGLIST {
+ RockchipRegisterComponentType component;
+ OMX_U8 libName[MAX_OMX_COMPONENT_LIBNAME_SIZE];
+} ROCKCHIP_OMX_COMPONENT_REGLIST;
+
+struct ROCKCHIP_OMX_COMPONENT;
+typedef struct _ROCKCHIP_OMX_COMPONENT {
+ OMX_U8 componentName[MAX_OMX_COMPONENT_NAME_SIZE];
+ OMX_U8 libName[MAX_OMX_COMPONENT_LIBNAME_SIZE];
+ OMX_HANDLETYPE libHandle;
+ OMX_STRING rkversion;
+ OMX_COMPONENTTYPE *pOMXComponent;
+ struct _ROCKCHIP_OMX_COMPONENT *nextOMXComp;
+} ROCKCHIP_OMX_COMPONENT;
+
+typedef struct __ROCKCHIP_COMPONENT_INFO {
+ char *comp_type;
+ char *lib_name;
+} ROCKCHIP_COMPONENT_INFO;
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+OMX_ERRORTYPE Rockchip_OMX_Component_Register(ROCKCHIP_OMX_COMPONENT_REGLIST **compList, OMX_U32 *compNum);
+OMX_ERRORTYPE Rockchip_OMX_Component_Unregister(ROCKCHIP_OMX_COMPONENT_REGLIST *componentList);
+OMX_ERRORTYPE Rockchip_OMX_ComponentLoad(ROCKCHIP_OMX_COMPONENT *rockchip_component);
+OMX_ERRORTYPE Rockchip_OMX_ComponentUnload(ROCKCHIP_OMX_COMPONENT *rockchip_component);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/core/Rockchip_OMX_Core.c b/core/Rockchip_OMX_Core.c
new file mode 100755
index 0000000..968597a
--- /dev/null
+++ b/core/Rockchip_OMX_Core.c
@@ -0,0 +1,384 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rockchip_OMX_Core.c
+ * @brief Rockchip OpenMAX IL Core
+ * @author csy (csy@rock-chips.com)
+ *
+ * @version 1.0.0
+ * @history
+ * 2013.11.26 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "Rockchip_OMX_Core.h"
+#include "Rockchip_OMX_Component_Register.h"
+#include "Rockchip_OSAL_Memory.h"
+#include "Rockchip_OSAL_Mutex.h"
+#include "Rockchip_OSAL_ETC.h"
+#include "Rockchip_OMX_Resourcemanager.h"
+#include "git_info.h"
+#include <pthread.h>
+
+#undef ROCKCHIP_LOG_TAG
+#define ROCKCHIP_LOG_TAG "ROCKCHIP_OMX_CORE"
+#define ROCKCHIP_LOG_OFF
+#include "Rockchip_OSAL_Log.h"
+
+
+static int gInitialized = 0;
+static OMX_U32 gComponentNum = 0;
+static OMX_U32 gCount = 0;
+static pthread_mutex_t gMutex = PTHREAD_MUTEX_INITIALIZER;
+static ROCKCHIP_OMX_COMPONENT_REGLIST *gComponentList = NULL;
+static ROCKCHIP_OMX_COMPONENT *gLoadComponentList = NULL;
+static OMX_HANDLETYPE ghLoadComponentListMutex = NULL;
+
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_Init(void)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ FunctionIn();
+ Rockchip_OSAL_MutexLock(&gMutex);
+ gCount++;
+ if (gInitialized == 0) {
+ if (Rockchip_OMX_Component_Register(&gComponentList, &gComponentNum)) {
+ ret = OMX_ErrorInsufficientResources;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Rockchip_OMX_Init : %s", "OMX_ErrorInsufficientResources");
+ goto EXIT;
+ }
+
+ ret = Rockchip_OMX_ResourceManager_Init();
+ if (OMX_ErrorNone != ret) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Rockchip_OMX_Init : Rockchip_OMX_ResourceManager_Init failed");
+ goto EXIT;
+ }
+
+ ret = Rockchip_OSAL_MutexCreate(&ghLoadComponentListMutex);
+ if (OMX_ErrorNone != ret) {
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "Rockchip_OMX_Init : Rockchip_OSAL_MutexCreate(&ghLoadComponentListMutex) failed");
+ goto EXIT;
+ }
+
+ gInitialized = 1;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rockchip_OMX_Init : %s", "OMX_ErrorNone");
+ }
+
+EXIT:
+
+ Rockchip_OSAL_MutexUnlock(&gMutex);
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_DeInit(void)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ FunctionIn();
+ Rockchip_OSAL_MutexLock(&gMutex);
+ gCount--;
+ if (gCount == 0) {
+ Rockchip_OSAL_MutexTerminate(ghLoadComponentListMutex);
+ ghLoadComponentListMutex = NULL;
+
+ Rockchip_OMX_ResourceManager_Deinit();
+
+ if (OMX_ErrorNone != Rockchip_OMX_Component_Unregister(gComponentList)) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ gComponentList = NULL;
+ gComponentNum = 0;
+ gInitialized = 0;
+ }
+EXIT:
+ Rockchip_OSAL_MutexUnlock(&gMutex);
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_ComponentNameEnum(
+ OMX_OUT OMX_STRING cComponentName,
+ OMX_IN OMX_U32 nNameLength,
+ OMX_IN OMX_U32 nIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ FunctionIn();
+
+ if (nIndex >= gComponentNum) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+
+ snprintf(cComponentName, nNameLength, "%s", gComponentList[nIndex].component.componentName);
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_GetHandle(
+ OMX_OUT OMX_HANDLETYPE *pHandle,
+ OMX_IN OMX_STRING cComponentName,
+ OMX_IN OMX_PTR pAppData,
+ OMX_IN OMX_CALLBACKTYPE *pCallBacks)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_COMPONENT *loadComponent;
+ ROCKCHIP_OMX_COMPONENT *currentComponent;
+ unsigned int i = 0;
+
+ FunctionIn();
+
+ if (gInitialized != 1) {
+ ret = OMX_ErrorNotReady;
+ goto EXIT;
+ }
+
+ if ((pHandle == NULL) || (cComponentName == NULL) || (pCallBacks == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "ComponentName : %s", cComponentName);
+
+ for (i = 0; i < gComponentNum; i++) {
+ if (Rockchip_OSAL_Strcmp(cComponentName, gComponentList[i].component.componentName) == 0) {
+ loadComponent = Rockchip_OSAL_Malloc(sizeof(ROCKCHIP_OMX_COMPONENT));
+ Rockchip_OSAL_Memset(loadComponent, 0, sizeof(ROCKCHIP_OMX_COMPONENT));
+
+ Rockchip_OSAL_Strcpy(loadComponent->libName, gComponentList[i].libName);
+ Rockchip_OSAL_Strcpy(loadComponent->componentName, gComponentList[i].component.componentName);
+ ret = Rockchip_OMX_ComponentLoad(loadComponent);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OSAL_Free(loadComponent);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ ret = loadComponent->pOMXComponent->SetCallbacks(loadComponent->pOMXComponent, pCallBacks, pAppData);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OMX_ComponentUnload(loadComponent);
+ Rockchip_OSAL_Free(loadComponent);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_Error 0x%x, Line:%d", ret, __LINE__);
+ goto EXIT;
+ }
+
+ ret = Rockchip_OMX_Check_Resource(loadComponent->pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ Rockchip_OMX_ComponentUnload(loadComponent);
+ Rockchip_OSAL_Free(loadComponent);
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_ERROR, "OMX_Error 0x%x, Line:%d", ret, __LINE__);
+
+ goto EXIT;
+ }
+ Rockchip_OSAL_MutexLock(ghLoadComponentListMutex);
+ if (gLoadComponentList == NULL) {
+ gLoadComponentList = loadComponent;
+ } else {
+ currentComponent = gLoadComponentList;
+ while (currentComponent->nextOMXComp != NULL) {
+ currentComponent = currentComponent->nextOMXComp;
+ }
+ currentComponent->nextOMXComp = loadComponent;
+ }
+ Rockchip_OSAL_MutexUnlock(ghLoadComponentListMutex);
+
+ *pHandle = loadComponent->pOMXComponent;
+ ret = OMX_ErrorNone;
+ Rockchip_OSAL_Log(ROCKCHIP_LOG_TRACE, "Rockchip_OMX_GetHandle : %s", "OMX_ErrorNone");
+ goto EXIT;
+ }
+ }
+
+ ret = OMX_ErrorComponentNotFound;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ ROCKCHIP_OMX_COMPONENT *currentComponent = NULL;
+ ROCKCHIP_OMX_COMPONENT *deleteComponent = NULL;
+
+ FunctionIn();
+
+ if (gInitialized != 1) {
+ ret = OMX_ErrorNotReady;
+ goto EXIT;
+ }
+
+ if (!hComponent) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ Rockchip_OSAL_MutexLock(ghLoadComponentListMutex);
+ currentComponent = gLoadComponentList;
+ if (gLoadComponentList->pOMXComponent == hComponent) {
+ deleteComponent = gLoadComponentList;
+ gLoadComponentList = gLoadComponentList->nextOMXComp;
+ } else {
+ while ((currentComponent != NULL) && (((ROCKCHIP_OMX_COMPONENT *)(currentComponent->nextOMXComp))->pOMXComponent != hComponent))
+ currentComponent = currentComponent->nextOMXComp;
+
+ if (((ROCKCHIP_OMX_COMPONENT *)(currentComponent->nextOMXComp))->pOMXComponent == hComponent) {
+ deleteComponent = currentComponent->nextOMXComp;
+ currentComponent->nextOMXComp = deleteComponent->nextOMXComp;
+ } else if (currentComponent == NULL) {
+ ret = OMX_ErrorComponentNotFound;
+ Rockchip_OSAL_MutexUnlock(ghLoadComponentListMutex);
+ goto EXIT;
+ }
+ }
+ Rockchip_OSAL_MutexUnlock(ghLoadComponentListMutex);
+
+ Rockchip_OMX_ComponentUnload(deleteComponent);
+ Rockchip_OSAL_Free(deleteComponent);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_SetupTunnel(
+ OMX_IN OMX_HANDLETYPE hOutput,
+ OMX_IN OMX_U32 nPortOutput,
+ OMX_IN OMX_HANDLETYPE hInput,
+ OMX_IN OMX_U32 nPortInput)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNotImplemented;
+ (void)hOutput;
+ (void)nPortOutput;
+ (void)hInput;
+ (void)nPortInput;
+EXIT:
+ return ret;
+}
+
+OMX_API OMX_ERRORTYPE RKOMX_GetContentPipe(
+ OMX_OUT OMX_HANDLETYPE *hPipe,
+ OMX_IN OMX_STRING szURI)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNotImplemented;
+ (void)hPipe;
+ (void)szURI;
+EXIT:
+ return ret;
+}
+
+OMX_API OMX_ERRORTYPE RKOMX_GetComponentsOfRole (
+ OMX_IN OMX_STRING role,
+ OMX_INOUT OMX_U32 *pNumComps,
+ OMX_INOUT OMX_U8 **compNames)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ int max_role_num = 0;
+ OMX_STRING RoleString[MAX_OMX_COMPONENT_ROLE_SIZE];
+ int i = 0, j = 0;
+
+ FunctionIn();
+
+ if (gInitialized != 1) {
+ ret = OMX_ErrorNotReady;
+ goto EXIT;
+ }
+
+ *pNumComps = 0;
+
+ for (i = 0; i < MAX_OMX_COMPONENT_NUM; i++) {
+ max_role_num = gComponentList[i].component.totalRoleNum;
+
+ for (j = 0; j < max_role_num; j++) {
+ if (Rockchip_OSAL_Strcmp(gComponentList[i].component.roles[j], role) == 0) {
+ if (compNames != NULL) {
+ Rockchip_OSAL_Strcpy((OMX_STRING)compNames[*pNumComps], gComponentList[i].component.componentName);
+ }
+ *pNumComps = (*pNumComps + 1);
+ }
+ }
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_API OMX_ERRORTYPE RKOMX_GetRolesOfComponent (
+ OMX_IN OMX_STRING compName,
+ OMX_INOUT OMX_U32 *pNumRoles,
+ OMX_OUT OMX_U8 **roles)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_BOOL detectComp = OMX_FALSE;
+ int compNum = 0, totalRoleNum = 0;
+ int i = 0;
+
+ FunctionIn();
+
+ if (gInitialized != 1) {
+ ret = OMX_ErrorNotReady;
+ goto EXIT;
+ }
+
+ for (i = 0; i < MAX_OMX_COMPONENT_NUM; i++) {
+ if (gComponentList != NULL) {
+ if (Rockchip_OSAL_Strcmp(gComponentList[i].component.componentName, compName) == 0) {
+ *pNumRoles = totalRoleNum = gComponentList[i].component.totalRoleNum;
+ compNum = i;
+ detectComp = OMX_TRUE;
+ break;
+ }
+ } else {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ }
+
+ if (detectComp == OMX_FALSE) {
+ *pNumRoles = 0;
+ ret = OMX_ErrorComponentNotFound;
+ goto EXIT;
+ }
+
+ if (roles != NULL) {
+ for (i = 0; i < totalRoleNum; i++) {
+ Rockchip_OSAL_Strcpy(roles[i], gComponentList[compNum].component.roles[i]);
+ }
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/core/Rockchip_OMX_Core.h b/core/Rockchip_OMX_Core.h
new file mode 100644
index 0000000..07693ea
--- /dev/null
+++ b/core/Rockchip_OMX_Core.h
@@ -0,0 +1,77 @@
+/*
+ *
+ * Copyright 2013 Rockchip Electronics Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file Rockchip_OMX_Core.h
+ * @brief Rockchip OpenMAX IL Core
+ * @author csy(csy@rock-chips.com)
+ *
+ * @version 1.0.0
+ * @history
+ * 2013.11.26 : Create
+ */
+
+#ifndef ROCKCHIP_OMX_CORE
+#define ROCKCHIP_OMX_CORE
+
+#include "Rockchip_OMX_Def.h"
+#include "OMX_Types.h"
+#include "OMX_Core.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ROCKCHIP_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_Init(void);
+ROCKCHIP_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_DeInit(void);
+ROCKCHIP_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_ComponentNameEnum(
+ OMX_OUT OMX_STRING cComponentName,
+ OMX_IN OMX_U32 nNameLength,
+ OMX_IN OMX_U32 nIndex);
+ROCKCHIP_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_GetHandle(
+ OMX_OUT OMX_HANDLETYPE *pHandle,
+ OMX_IN OMX_STRING cComponentName,
+ OMX_IN OMX_PTR pAppData,
+ OMX_IN OMX_CALLBACKTYPE *pCallBacks);
+ROCKCHIP_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_FreeHandle(
+ OMX_IN OMX_HANDLETYPE hComponent);
+ROCKCHIP_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY RKOMX_SetupTunnel(
+ OMX_IN OMX_HANDLETYPE hOutput,
+ OMX_IN OMX_U32 nPortOutput,
+ OMX_IN OMX_HANDLETYPE hInput,
+ OMX_IN OMX_U32 nPortInput);
+ROCKCHIP_EXPORT_REF OMX_API OMX_ERRORTYPE RKOMX_GetContentPipe(
+ OMX_OUT OMX_HANDLETYPE *hPipe,
+ OMX_IN OMX_STRING szURI);
+ROCKCHIP_EXPORT_REF OMX_API OMX_ERRORTYPE RKOMX_GetComponentsOfRole(
+ OMX_IN OMX_STRING role,
+ OMX_INOUT OMX_U32 *pNumComps,
+ OMX_INOUT OMX_U8 **compNames);
+ROCKCHIP_EXPORT_REF OMX_API OMX_ERRORTYPE RKOMX_GetRolesOfComponent(
+ OMX_IN OMX_STRING compName,
+ OMX_INOUT OMX_U32 *pNumRoles,
+ OMX_OUT OMX_U8 **roles);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/include/khronos/OMX_Audio.h b/include/khronos/OMX_Audio.h
new file mode 100644
index 0000000..7205319
--- /dev/null
+++ b/include/khronos/OMX_Audio.h
@@ -0,0 +1,1310 @@
+/*
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** @file OMX_Audio.h - OpenMax IL version 1.1.2
+ * The structures needed by Audio components to exchange
+ * parameters and configuration data with the componenmilts.
+ */
+
+#ifndef OMX_Audio_h
+#define OMX_Audio_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Each OMX header must include all required header files to allow the
+ * header to compile without errors. The includes below are required
+ * for this header file to compile successfully
+ */
+
+#include <OMX_Core.h>
+
+/** @defgroup midi MIDI
+ * @ingroup audio
+ */
+
+/** @defgroup effects Audio effects
+ * @ingroup audio
+ */
+
+/** @defgroup audio OpenMAX IL Audio Domain
+ * Structures for OpenMAX IL Audio domain
+ * @{
+ */
+
+/** Enumeration used to define the possible audio codings.
+ * If "OMX_AUDIO_CodingUnused" is selected, the coding selection must
+ * be done in a vendor specific way. Since this is for an audio
+ * processing element this enum is relevant. However, for another
+ * type of component other enums would be in this area.
+ */
+typedef enum OMX_AUDIO_CODINGTYPE {
+ OMX_AUDIO_CodingUnused = 0, /**< Placeholder value when coding is N/A */
+ OMX_AUDIO_CodingAutoDetect, /**< auto detection of audio format */
+ OMX_AUDIO_CodingPCM, /**< Any variant of PCM coding */
+ OMX_AUDIO_CodingADPCM, /**< Any variant of ADPCM encoded data */
+ OMX_AUDIO_CodingAMR, /**< Any variant of AMR encoded data */
+ OMX_AUDIO_CodingGSMFR, /**< Any variant of GSM fullrate (i.e. GSM610) */
+ OMX_AUDIO_CodingGSMEFR, /**< Any variant of GSM Enhanced Fullrate encoded data*/
+ OMX_AUDIO_CodingGSMHR, /**< Any variant of GSM Halfrate encoded data */
+ OMX_AUDIO_CodingPDCFR, /**< Any variant of PDC Fullrate encoded data */
+ OMX_AUDIO_CodingPDCEFR, /**< Any variant of PDC Enhanced Fullrate encoded data */
+ OMX_AUDIO_CodingPDCHR, /**< Any variant of PDC Halfrate encoded data */
+ OMX_AUDIO_CodingTDMAFR, /**< Any variant of TDMA Fullrate encoded data (TIA/EIA-136-420) */
+ OMX_AUDIO_CodingTDMAEFR, /**< Any variant of TDMA Enhanced Fullrate encoded data (TIA/EIA-136-410) */
+ OMX_AUDIO_CodingQCELP8, /**< Any variant of QCELP 8kbps encoded data */
+ OMX_AUDIO_CodingQCELP13, /**< Any variant of QCELP 13kbps encoded data */
+ OMX_AUDIO_CodingEVRC, /**< Any variant of EVRC encoded data */
+ OMX_AUDIO_CodingSMV, /**< Any variant of SMV encoded data */
+ OMX_AUDIO_CodingG711, /**< Any variant of G.711 encoded data */
+ OMX_AUDIO_CodingG723, /**< Any variant of G.723 dot 1 encoded data */
+ OMX_AUDIO_CodingG726, /**< Any variant of G.726 encoded data */
+ OMX_AUDIO_CodingG729, /**< Any variant of G.729 encoded data */
+ OMX_AUDIO_CodingAAC, /**< Any variant of AAC encoded data */
+ OMX_AUDIO_CodingMP3, /**< Any variant of MP3 encoded data */
+ OMX_AUDIO_CodingSBC, /**< Any variant of SBC encoded data */
+ OMX_AUDIO_CodingVORBIS, /**< Any variant of VORBIS encoded data */
+ OMX_AUDIO_CodingWMA, /**< Any variant of WMA encoded data */
+ OMX_AUDIO_CodingRA, /**< Any variant of RA encoded data */
+ OMX_AUDIO_CodingMIDI, /**< Any variant of MIDI encoded data */
+ OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_CodingMax = 0x7FFFFFFF
+} OMX_AUDIO_CODINGTYPE;
+
+
+/** The PortDefinition structure is used to define all of the parameters
+ * necessary for the compliant component to setup an input or an output audio
+ * path. If additional information is needed to define the parameters of the
+ * port (such as frequency), additional structures must be sent such as the
+ * OMX_AUDIO_PARAM_PCMMODETYPE structure to supply the extra parameters for the port.
+ */
+typedef struct OMX_AUDIO_PORTDEFINITIONTYPE {
+ OMX_STRING cMIMEType; /**< MIME type of data for the port */
+ OMX_NATIVE_DEVICETYPE pNativeRender; /** < platform specific reference
+ for an output device,
+ otherwise this field is 0 */
+ OMX_BOOL bFlagErrorConcealment; /**< Turns on error concealment if it is
+ supported by the OMX component */
+ OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this
+ port (e.g. PCM, AMR, MP3, etc) */
+} OMX_AUDIO_PORTDEFINITIONTYPE;
+
+
+/** Port format parameter. This structure is used to enumerate
+ * the various data input/output format supported by the port.
+ */
+typedef struct OMX_AUDIO_PARAM_PORTFORMATTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< Indicates which port to set */
+ OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */
+ OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this port (e.g. PCM, AMR, MP3, etc) */
+} OMX_AUDIO_PARAM_PORTFORMATTYPE;
+
+
+/** PCM mode type */
+typedef enum OMX_AUDIO_PCMMODETYPE {
+ OMX_AUDIO_PCMModeLinear = 0, /**< Linear PCM encoded data */
+ OMX_AUDIO_PCMModeALaw, /**< A law PCM encoded data (G.711) */
+ OMX_AUDIO_PCMModeMULaw, /**< Mu law PCM encoded data (G.711) */
+ OMX_AUDIO_PCMModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_PCMModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_PCMModeMax = 0x7FFFFFFF
+} OMX_AUDIO_PCMMODETYPE;
+
+
+typedef enum OMX_AUDIO_CHANNELTYPE {
+ OMX_AUDIO_ChannelNone = 0x0, /**< Unused or empty */
+ OMX_AUDIO_ChannelLF = 0x1, /**< Left front */
+ OMX_AUDIO_ChannelRF = 0x2, /**< Right front */
+ OMX_AUDIO_ChannelCF = 0x3, /**< Center front */
+ OMX_AUDIO_ChannelLS = 0x4, /**< Left surround */
+ OMX_AUDIO_ChannelRS = 0x5, /**< Right surround */
+ OMX_AUDIO_ChannelLFE = 0x6, /**< Low frequency effects */
+ OMX_AUDIO_ChannelCS = 0x7, /**< Back surround */
+ OMX_AUDIO_ChannelLR = 0x8, /**< Left rear. */
+ OMX_AUDIO_ChannelRR = 0x9, /**< Right rear. */
+ OMX_AUDIO_ChannelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_ChannelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_ChannelMax = 0x7FFFFFFF
+} OMX_AUDIO_CHANNELTYPE;
+
+#define OMX_AUDIO_MAXCHANNELS 16 /**< maximum number distinct audio channels that a buffer may contain */
+#define OMX_MIN_PCMPAYLOAD_MSEC 5 /**< Minimum audio buffer payload size for uncompressed (PCM) audio */
+
+/** PCM format description */
+typedef struct OMX_AUDIO_PARAM_PCMMODETYPE {
+ OMX_U32 nSize; /**< Size of this structure, in Bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels (e.g. 2 for stereo) */
+ OMX_NUMERICALDATATYPE eNumData; /**< indicates PCM data as signed or unsigned */
+ OMX_ENDIANTYPE eEndian; /**< indicates PCM data as little or big endian */
+ OMX_BOOL bInterleaved; /**< True for normal interleaved data; false for
+ non-interleaved data (e.g. block data) */
+ OMX_U32 nBitPerSample; /**< Bit per sample */
+ OMX_U32 nSamplingRate; /**< Sampling rate of the source data. Use 0 for
+ variable or unknown sampling rate. */
+ OMX_AUDIO_PCMMODETYPE ePCMMode; /**< PCM mode enumeration */
+ OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMap[i] */
+
+} OMX_AUDIO_PARAM_PCMMODETYPE;
+
+
+/** Audio channel mode. This is used by both AAC and MP3, although the names are more appropriate
+ * for the MP3. For example, JointStereo for MP3 is CouplingChannels for AAC.
+ */
+typedef enum OMX_AUDIO_CHANNELMODETYPE {
+ OMX_AUDIO_ChannelModeStereo = 0, /**< 2 channels, the bitrate allocation between those
+ two channels changes accordingly to each channel information */
+ OMX_AUDIO_ChannelModeJointStereo, /**< mode that takes advantage of what is common between
+ 2 channels for higher compression gain */
+ OMX_AUDIO_ChannelModeDual, /**< 2 mono-channels, each channel is encoded with half
+ the bitrate of the overall bitrate */
+ OMX_AUDIO_ChannelModeMono, /**< Mono channel mode */
+ OMX_AUDIO_ChannelModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_ChannelModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_ChannelModeMax = 0x7FFFFFFF
+} OMX_AUDIO_CHANNELMODETYPE;
+
+
+typedef enum OMX_AUDIO_MP3STREAMFORMATTYPE {
+ OMX_AUDIO_MP3StreamFormatMP1Layer3 = 0, /**< MP3 Audio MPEG 1 Layer 3 Stream format */
+ OMX_AUDIO_MP3StreamFormatMP2Layer3, /**< MP3 Audio MPEG 2 Layer 3 Stream format */
+ OMX_AUDIO_MP3StreamFormatMP2_5Layer3, /**< MP3 Audio MPEG2.5 Layer 3 Stream format */
+ OMX_AUDIO_MP3StreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_MP3StreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_MP3StreamFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_MP3STREAMFORMATTYPE;
+
+/** MP3 params */
+typedef struct OMX_AUDIO_PARAM_MP3TYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels */
+ OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable
+ rate or unknown bit rates */
+ OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for
+ variable or unknown sampling rate. */
+ OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should
+ limit the audio signal. Use 0 to let encoder decide */
+ OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */
+ OMX_AUDIO_MP3STREAMFORMATTYPE eFormat; /**< MP3 stream format */
+} OMX_AUDIO_PARAM_MP3TYPE;
+
+
+typedef enum OMX_AUDIO_AACSTREAMFORMATTYPE {
+ OMX_AUDIO_AACStreamFormatMP2ADTS = 0, /**< AAC Audio Data Transport Stream 2 format */
+ OMX_AUDIO_AACStreamFormatMP4ADTS, /**< AAC Audio Data Transport Stream 4 format */
+ OMX_AUDIO_AACStreamFormatMP4LOAS, /**< AAC Low Overhead Audio Stream format */
+ OMX_AUDIO_AACStreamFormatMP4LATM, /**< AAC Low overhead Audio Transport Multiplex */
+ OMX_AUDIO_AACStreamFormatADIF, /**< AAC Audio Data Interchange Format */
+ OMX_AUDIO_AACStreamFormatMP4FF, /**< AAC inside MPEG-4/ISO File Format */
+ OMX_AUDIO_AACStreamFormatRAW, /**< AAC Raw Format */
+ OMX_AUDIO_AACStreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_AACStreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_AACStreamFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_AACSTREAMFORMATTYPE;
+
+
+/** AAC mode type. Note that the term profile is used with the MPEG-2
+ * standard and the term object type and profile is used with MPEG-4 */
+typedef enum OMX_AUDIO_AACPROFILETYPE {
+ OMX_AUDIO_AACObjectNull = 0, /**< Null, not used */
+ OMX_AUDIO_AACObjectMain = 1, /**< AAC Main object */
+ OMX_AUDIO_AACObjectLC, /**< AAC Low Complexity object (AAC profile) */
+ OMX_AUDIO_AACObjectSSR, /**< AAC Scalable Sample Rate object */
+ OMX_AUDIO_AACObjectLTP, /**< AAC Long Term Prediction object */
+ OMX_AUDIO_AACObjectHE, /**< AAC High Efficiency (object type SBR, HE-AAC profile) */
+ OMX_AUDIO_AACObjectScalable, /**< AAC Scalable object */
+ OMX_AUDIO_AACObjectERLC = 17, /**< ER AAC Low Complexity object (Error Resilient AAC-LC) */
+ OMX_AUDIO_AACObjectLD = 23, /**< AAC Low Delay object (Error Resilient) */
+ OMX_AUDIO_AACObjectHE_PS = 29, /**< AAC High Efficiency with Parametric Stereo coding (HE-AAC v2, object type PS) */
+ OMX_AUDIO_AACObjectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_AACObjectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_AACObjectMax = 0x7FFFFFFF
+} OMX_AUDIO_AACPROFILETYPE;
+
+
+/** AAC tool usage (for nAACtools in OMX_AUDIO_PARAM_AACPROFILETYPE).
+ * Required for encoder configuration and optional as decoder info output.
+ * For MP3, OMX_AUDIO_CHANNELMODETYPE is sufficient. */
+#define OMX_AUDIO_AACToolNone 0x00000000 /**< no AAC tools allowed (encoder config) or active (decoder info output) */
+#define OMX_AUDIO_AACToolMS 0x00000001 /**< MS: Mid/side joint coding tool allowed or active */
+#define OMX_AUDIO_AACToolIS 0x00000002 /**< IS: Intensity stereo tool allowed or active */
+#define OMX_AUDIO_AACToolTNS 0x00000004 /**< TNS: Temporal Noise Shaping tool allowed or active */
+#define OMX_AUDIO_AACToolPNS 0x00000008 /**< PNS: MPEG-4 Perceptual Noise substitution tool allowed or active */
+#define OMX_AUDIO_AACToolLTP 0x00000010 /**< LTP: MPEG-4 Long Term Prediction tool allowed or active */
+#define OMX_AUDIO_AACToolAll 0x7FFFFFFF /**< all AAC tools allowed or active (*/
+
+/** MPEG-4 AAC error resilience (ER) tool usage (for nAACERtools in OMX_AUDIO_PARAM_AACPROFILETYPE).
+ * Required for ER encoder configuration and optional as decoder info output */
+#define OMX_AUDIO_AACERNone 0x00000000 /**< no AAC ER tools allowed/used */
+#define OMX_AUDIO_AACERVCB11 0x00000001 /**< VCB11: Virtual Code Books for AAC section data */
+#define OMX_AUDIO_AACERRVLC 0x00000002 /**< RVLC: Reversible Variable Length Coding */
+#define OMX_AUDIO_AACERHCR 0x00000004 /**< HCR: Huffman Codeword Reordering */
+#define OMX_AUDIO_AACERAll 0x7FFFFFFF /**< all AAC ER tools allowed/used */
+
+
+/** AAC params */
+typedef struct OMX_AUDIO_PARAM_AACPROFILETYPE {
+ OMX_U32 nSize; /**< Size of this structure, in Bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< Port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels */
+ OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for
+ variable or unknown sampling rate. */
+ OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable
+ rate or unknown bit rates */
+ OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should
+ limit the audio signal. Use 0 to let encoder decide */
+ OMX_U32 nFrameLength; /**< Frame length (in audio samples per channel) of the codec.
+ Can be 1024 or 960 (AAC-LC), 2048 (HE-AAC), 480 or 512 (AAC-LD).
+ Use 0 to let encoder decide */
+ OMX_U32 nAACtools; /**< AAC tool usage */
+ OMX_U32 nAACERtools; /**< MPEG-4 AAC error resilience tool usage */
+ OMX_AUDIO_AACPROFILETYPE eAACProfile; /**< AAC profile enumeration */
+ OMX_AUDIO_AACSTREAMFORMATTYPE eAACStreamFormat; /**< AAC stream format enumeration */
+ OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */
+} OMX_AUDIO_PARAM_AACPROFILETYPE;
+
+
+/** VORBIS params */
+typedef struct OMX_AUDIO_PARAM_VORBISTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels */
+ OMX_U32 nBitRate; /**< Bit rate of the encoded data data. Use 0 for variable
+ rate or unknown bit rates. Encoding is set to the
+ bitrate closest to specified value (in bps) */
+ OMX_U32 nMinBitRate; /**< Sets minimum bitrate (in bps). */
+ OMX_U32 nMaxBitRate; /**< Sets maximum bitrate (in bps). */
+
+ OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for
+ variable or unknown sampling rate. */
+ OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should
+ limit the audio signal. Use 0 to let encoder decide */
+ OMX_S32 nQuality; /**< Sets encoding quality to n, between -1 (low) and 10 (high).
+ In the default mode of operation, teh quality level is 3.
+ Normal quality range is 0 - 10. */
+ OMX_BOOL bManaged; /**< Set bitrate management mode. This turns off the
+ normal VBR encoding, but allows hard or soft bitrate
+ constraints to be enforced by the encoder. This mode can
+ be slower, and may also be lower quality. It is
+ primarily useful for streaming. */
+ OMX_BOOL bDownmix; /**< Downmix input from stereo to mono (has no effect on
+ non-stereo streams). Useful for lower-bitrate encoding. */
+} OMX_AUDIO_PARAM_VORBISTYPE;
+
+
+/** WMA Version */
+typedef enum OMX_AUDIO_WMAFORMATTYPE {
+ OMX_AUDIO_WMAFormatUnused = 0, /**< format unused or unknown */
+ OMX_AUDIO_WMAFormat7, /**< Windows Media Audio format 7 */
+ OMX_AUDIO_WMAFormat8, /**< Windows Media Audio format 8 */
+ OMX_AUDIO_WMAFormat9, /**< Windows Media Audio format 9 */
+ OMX_AUDIO_WMAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_WMAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_WMAFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_WMAFORMATTYPE;
+
+
+/** WMA Profile */
+typedef enum OMX_AUDIO_WMAPROFILETYPE {
+ OMX_AUDIO_WMAProfileUnused = 0, /**< profile unused or unknown */
+ OMX_AUDIO_WMAProfileL1, /**< Windows Media audio version 9 profile L1 */
+ OMX_AUDIO_WMAProfileL2, /**< Windows Media audio version 9 profile L2 */
+ OMX_AUDIO_WMAProfileL3, /**< Windows Media audio version 9 profile L3 */
+ OMX_AUDIO_WMAProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_WMAProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_WMAProfileMax = 0x7FFFFFFF
+} OMX_AUDIO_WMAPROFILETYPE;
+
+
+/** WMA params */
+typedef struct OMX_AUDIO_PARAM_WMATYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U16 nChannels; /**< Number of channels */
+ OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable
+ rate or unknown bit rates */
+ OMX_AUDIO_WMAFORMATTYPE eFormat; /**< Version of WMA stream / data */
+ OMX_AUDIO_WMAPROFILETYPE eProfile; /**< Profile of WMA stream / data */
+ OMX_U32 nSamplingRate; /**< Sampling rate of the source data */
+ OMX_U16 nBlockAlign; /**< is the block alignment, or block size, in bytes of the audio codec */
+ OMX_U16 nEncodeOptions; /**< WMA Type-specific data */
+ OMX_U32 nSuperBlockAlign; /**< WMA Type-specific data */
+} OMX_AUDIO_PARAM_WMATYPE;
+
+/**
+ * RealAudio format
+ */
+typedef enum OMX_AUDIO_RAFORMATTYPE {
+ OMX_AUDIO_RAFormatUnused = 0, /**< Format unused or unknown */
+ OMX_AUDIO_RA8, /**< RealAudio 8 codec */
+ OMX_AUDIO_RA9, /**< RealAudio 9 codec */
+ OMX_AUDIO_RA10_AAC, /**< MPEG-4 AAC codec for bitrates of more than 128kbps */
+ OMX_AUDIO_RA10_CODEC, /**< RealAudio codec for bitrates less than 128 kbps */
+ OMX_AUDIO_RA10_LOSSLESS, /**< RealAudio Lossless */
+ OMX_AUDIO_RA10_MULTICHANNEL, /**< RealAudio Multichannel */
+ OMX_AUDIO_RA10_VOICE, /**< RealAudio Voice for bitrates below 15 kbps */
+ OMX_AUDIO_RAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_RAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_VIDEO_RAFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_RAFORMATTYPE;
+
+/** RA (Real Audio) params */
+typedef struct OMX_AUDIO_PARAM_RATYPE {
+ OMX_U32 nSize; /**< Size of this structure, in Bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< Port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels */
+ OMX_U32 nSamplingRate; /**< is the sampling rate of the source data */
+ OMX_U32 nBitsPerFrame; /**< is the value for bits per frame */
+ OMX_U32 nSamplePerFrame; /**< is the value for samples per frame */
+ OMX_U32 nCouplingQuantBits; /**< is the number of coupling quantization bits in the stream */
+ OMX_U32 nCouplingStartRegion; /**< is the coupling start region in the stream */
+ OMX_U32 nNumRegions; /**< is the number of regions value */
+ OMX_AUDIO_RAFORMATTYPE eFormat; /**< is the RealAudio audio format */
+} OMX_AUDIO_PARAM_RATYPE;
+
+
+/** SBC Allocation Method Type */
+typedef enum OMX_AUDIO_SBCALLOCMETHODTYPE {
+ OMX_AUDIO_SBCAllocMethodLoudness, /**< Loudness allocation method */
+ OMX_AUDIO_SBCAllocMethodSNR, /**< SNR allocation method */
+ OMX_AUDIO_SBCAllocMethodKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_SBCAllocMethodVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_SBCAllocMethodMax = 0x7FFFFFFF
+} OMX_AUDIO_SBCALLOCMETHODTYPE;
+
+
+/** SBC params */
+typedef struct OMX_AUDIO_PARAM_SBCTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels */
+ OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable
+ rate or unknown bit rates */
+ OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for
+ variable or unknown sampling rate. */
+ OMX_U32 nBlocks; /**< Number of blocks */
+ OMX_U32 nSubbands; /**< Number of subbands */
+ OMX_U32 nBitPool; /**< Bitpool value */
+ OMX_BOOL bEnableBitrate; /**< Use bitrate value instead of bitpool */
+ OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */
+ OMX_AUDIO_SBCALLOCMETHODTYPE eSBCAllocType; /**< SBC Allocation method type */
+} OMX_AUDIO_PARAM_SBCTYPE;
+
+
+/** ADPCM stream format parameters */
+typedef struct OMX_AUDIO_PARAM_ADPCMTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_U32 nBitsPerSample; /**< Number of bits in each sample */
+ OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for
+ variable or unknown sampling rate. */
+} OMX_AUDIO_PARAM_ADPCMTYPE;
+
+
+/** G723 rate */
+typedef enum OMX_AUDIO_G723RATE {
+ OMX_AUDIO_G723ModeUnused = 0, /**< AMRNB Mode unused / unknown */
+ OMX_AUDIO_G723ModeLow, /**< 5300 bps */
+ OMX_AUDIO_G723ModeHigh, /**< 6300 bps */
+ OMX_AUDIO_G723ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_G723ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_G723ModeMax = 0x7FFFFFFF
+} OMX_AUDIO_G723RATE;
+
+
+/** G723 - Sample rate must be 8 KHz */
+typedef struct OMX_AUDIO_PARAM_G723TYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */
+ OMX_AUDIO_G723RATE eBitRate; /**< todo: Should this be moved to a config? */
+ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */
+ OMX_BOOL bPostFilter; /**< Enable Post Filter */
+} OMX_AUDIO_PARAM_G723TYPE;
+
+
+/** ITU G726 (ADPCM) rate */
+typedef enum OMX_AUDIO_G726MODE {
+ OMX_AUDIO_G726ModeUnused = 0, /**< G726 Mode unused / unknown */
+ OMX_AUDIO_G726Mode16, /**< 16 kbps */
+ OMX_AUDIO_G726Mode24, /**< 24 kbps */
+ OMX_AUDIO_G726Mode32, /**< 32 kbps, most common rate, also G721 */
+ OMX_AUDIO_G726Mode40, /**< 40 kbps */
+ OMX_AUDIO_G726ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_G726ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_G726ModeMax = 0x7FFFFFFF
+} OMX_AUDIO_G726MODE;
+
+
+/** G.726 stream format parameters - must be at 8KHz */
+typedef struct OMX_AUDIO_PARAM_G726TYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_AUDIO_G726MODE eG726Mode;
+} OMX_AUDIO_PARAM_G726TYPE;
+
+
+/** G729 coder type */
+typedef enum OMX_AUDIO_G729TYPE {
+ OMX_AUDIO_G729 = 0, /**< ITU G.729 encoded data */
+ OMX_AUDIO_G729A, /**< ITU G.729 annex A encoded data */
+ OMX_AUDIO_G729B, /**< ITU G.729 with annex B encoded data */
+ OMX_AUDIO_G729AB, /**< ITU G.729 annexes A and B encoded data */
+ OMX_AUDIO_G729KhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_G729VendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_G729Max = 0x7FFFFFFF
+} OMX_AUDIO_G729TYPE;
+
+
+/** G729 stream format parameters - fixed 6KHz sample rate */
+typedef struct OMX_AUDIO_PARAM_G729TYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */
+ OMX_AUDIO_G729TYPE eBitType;
+} OMX_AUDIO_PARAM_G729TYPE;
+
+
+/** AMR Frame format */
+typedef enum OMX_AUDIO_AMRFRAMEFORMATTYPE {
+ OMX_AUDIO_AMRFrameFormatConformance = 0, /**< Frame Format is AMR Conformance
+ (Standard) Format */
+ OMX_AUDIO_AMRFrameFormatIF1, /**< Frame Format is AMR Interface
+ Format 1 */
+ OMX_AUDIO_AMRFrameFormatIF2, /**< Frame Format is AMR Interface
+ Format 2*/
+ OMX_AUDIO_AMRFrameFormatFSF, /**< Frame Format is AMR File Storage
+ Format */
+ OMX_AUDIO_AMRFrameFormatRTPPayload, /**< Frame Format is AMR Real-Time
+ Transport Protocol Payload Format */
+ OMX_AUDIO_AMRFrameFormatITU, /**< Frame Format is ITU Format (added at Motorola request) */
+ OMX_AUDIO_AMRFrameFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_AMRFrameFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_AMRFrameFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_AMRFRAMEFORMATTYPE;
+
+
+/** AMR band mode */
+typedef enum OMX_AUDIO_AMRBANDMODETYPE {
+ OMX_AUDIO_AMRBandModeUnused = 0, /**< AMRNB Mode unused / unknown */
+ OMX_AUDIO_AMRBandModeNB0, /**< AMRNB Mode 0 = 4750 bps */
+ OMX_AUDIO_AMRBandModeNB1, /**< AMRNB Mode 1 = 5150 bps */
+ OMX_AUDIO_AMRBandModeNB2, /**< AMRNB Mode 2 = 5900 bps */
+ OMX_AUDIO_AMRBandModeNB3, /**< AMRNB Mode 3 = 6700 bps */
+ OMX_AUDIO_AMRBandModeNB4, /**< AMRNB Mode 4 = 7400 bps */
+ OMX_AUDIO_AMRBandModeNB5, /**< AMRNB Mode 5 = 7950 bps */
+ OMX_AUDIO_AMRBandModeNB6, /**< AMRNB Mode 6 = 10200 bps */
+ OMX_AUDIO_AMRBandModeNB7, /**< AMRNB Mode 7 = 12200 bps */
+ OMX_AUDIO_AMRBandModeWB0, /**< AMRWB Mode 0 = 6600 bps */
+ OMX_AUDIO_AMRBandModeWB1, /**< AMRWB Mode 1 = 8850 bps */
+ OMX_AUDIO_AMRBandModeWB2, /**< AMRWB Mode 2 = 12650 bps */
+ OMX_AUDIO_AMRBandModeWB3, /**< AMRWB Mode 3 = 14250 bps */
+ OMX_AUDIO_AMRBandModeWB4, /**< AMRWB Mode 4 = 15850 bps */
+ OMX_AUDIO_AMRBandModeWB5, /**< AMRWB Mode 5 = 18250 bps */
+ OMX_AUDIO_AMRBandModeWB6, /**< AMRWB Mode 6 = 19850 bps */
+ OMX_AUDIO_AMRBandModeWB7, /**< AMRWB Mode 7 = 23050 bps */
+ OMX_AUDIO_AMRBandModeWB8, /**< AMRWB Mode 8 = 23850 bps */
+ OMX_AUDIO_AMRBandModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_AMRBandModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_AMRBandModeMax = 0x7FFFFFFF
+} OMX_AUDIO_AMRBANDMODETYPE;
+
+
+/** AMR Discontinuous Transmission mode */
+typedef enum OMX_AUDIO_AMRDTXMODETYPE {
+ OMX_AUDIO_AMRDTXModeOff = 0, /**< AMR Discontinuous Transmission Mode is disabled */
+ OMX_AUDIO_AMRDTXModeOnVAD1, /**< AMR Discontinuous Transmission Mode using
+ Voice Activity Detector 1 (VAD1) is enabled */
+ OMX_AUDIO_AMRDTXModeOnVAD2, /**< AMR Discontinuous Transmission Mode using
+ Voice Activity Detector 2 (VAD2) is enabled */
+ OMX_AUDIO_AMRDTXModeOnAuto, /**< The codec will automatically select between
+ Off, VAD1 or VAD2 modes */
+
+ OMX_AUDIO_AMRDTXasEFR, /**< DTX as EFR instead of AMR standard (3GPP 26.101, frame type =8,9,10) */
+
+ OMX_AUDIO_AMRDTXModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_AMRDTXModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_AMRDTXModeMax = 0x7FFFFFFF
+} OMX_AUDIO_AMRDTXMODETYPE;
+
+
+/** AMR params */
+typedef struct OMX_AUDIO_PARAM_AMRTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels */
+ OMX_U32 nBitRate; /**< Bit rate read only field */
+ OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode; /**< AMR Band Mode enumeration */
+ OMX_AUDIO_AMRDTXMODETYPE eAMRDTXMode; /**< AMR DTX Mode enumeration */
+ OMX_AUDIO_AMRFRAMEFORMATTYPE eAMRFrameFormat; /**< AMR frame format enumeration */
+} OMX_AUDIO_PARAM_AMRTYPE;
+
+
+/** GSM_FR (ETSI 06.10, 3GPP 46.010) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_GSMFRTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */
+ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_GSMFRTYPE;
+
+
+/** GSM-HR (ETSI 06.20, 3GPP 46.020) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_GSMHRTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */
+ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_GSMHRTYPE;
+
+
+/** GSM-EFR (ETSI 06.60, 3GPP 46.060) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_GSMEFRTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */
+ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_GSMEFRTYPE;
+
+
+/** TDMA FR (TIA/EIA-136-420, VSELP 7.95kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_TDMAFRTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */
+ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_TDMAFRTYPE;
+
+
+/** TDMA EFR (TIA/EIA-136-410, ACELP 7.4kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_TDMAEFRTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */
+ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_TDMAEFRTYPE;
+
+
+/** PDC FR ( RCR-27, VSELP 6.7kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_PDCFRTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */
+ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_PDCFRTYPE;
+
+
+/** PDC EFR ( RCR-27, ACELP 6.7kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_PDCEFRTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */
+ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_PDCEFRTYPE;
+
+/** PDC HR ( RCR-27, PSI-CELP 3.45kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_PDCHRTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */
+ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */
+} OMX_AUDIO_PARAM_PDCHRTYPE;
+
+
+/** CDMA Rate types */
+typedef enum OMX_AUDIO_CDMARATETYPE {
+ OMX_AUDIO_CDMARateBlank = 0, /**< CDMA encoded frame is blank */
+ OMX_AUDIO_CDMARateFull, /**< CDMA encoded frame in full rate */
+ OMX_AUDIO_CDMARateHalf, /**< CDMA encoded frame in half rate */
+ OMX_AUDIO_CDMARateQuarter, /**< CDMA encoded frame in quarter rate */
+ OMX_AUDIO_CDMARateEighth, /**< CDMA encoded frame in eighth rate (DTX)*/
+ OMX_AUDIO_CDMARateErasure, /**< CDMA erasure frame */
+ OMX_AUDIO_CDMARateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_CDMARateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_CDMARateMax = 0x7FFFFFFF
+} OMX_AUDIO_CDMARATETYPE;
+
+
+/** QCELP8 (TIA/EIA-96, up to 8kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_QCELP8TYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable
+ rate or unknown bit rates */
+ OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */
+ OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */
+ OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */
+} OMX_AUDIO_PARAM_QCELP8TYPE;
+
+
+/** QCELP13 ( CDMA, EIA/TIA-733, 13.3kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_QCELP13TYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */
+ OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */
+ OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */
+} OMX_AUDIO_PARAM_QCELP13TYPE;
+
+
+/** EVRC ( CDMA, EIA/TIA-127, RCELP up to 8.55kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_EVRCTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_AUDIO_CDMARATETYPE eCDMARate; /**< actual Frame rate */
+ OMX_BOOL bRATE_REDUCon; /**< RATE_REDUCtion is requested for this frame */
+ OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */
+ OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */
+ OMX_BOOL bHiPassFilter; /**< Enable encoder's High Pass Filter */
+ OMX_BOOL bNoiseSuppressor; /**< Enable encoder's noise suppressor pre-processing */
+ OMX_BOOL bPostFilter; /**< Enable decoder's post Filter */
+} OMX_AUDIO_PARAM_EVRCTYPE;
+
+
+/** SMV ( up to 8.55kbps coder) stream format parameters */
+typedef struct OMX_AUDIO_PARAM_SMVTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannels; /**< Number of channels in the data stream (not
+ necessarily the same as the number of channels
+ to be rendered. */
+ OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */
+ OMX_BOOL bRATE_REDUCon; /**< RATE_REDUCtion is requested for this frame */
+ OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 ??*/
+ OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 ??*/
+ OMX_BOOL bHiPassFilter; /**< Enable encoder's High Pass Filter ??*/
+ OMX_BOOL bNoiseSuppressor; /**< Enable encoder's noise suppressor pre-processing */
+ OMX_BOOL bPostFilter; /**< Enable decoder's post Filter ??*/
+} OMX_AUDIO_PARAM_SMVTYPE;
+
+
+/** MIDI Format
+ * @ingroup midi
+ */
+typedef enum OMX_AUDIO_MIDIFORMATTYPE {
+ OMX_AUDIO_MIDIFormatUnknown = 0, /**< MIDI Format unknown or don't care */
+ OMX_AUDIO_MIDIFormatSMF0, /**< Standard MIDI File Type 0 */
+ OMX_AUDIO_MIDIFormatSMF1, /**< Standard MIDI File Type 1 */
+ OMX_AUDIO_MIDIFormatSMF2, /**< Standard MIDI File Type 2 */
+ OMX_AUDIO_MIDIFormatSPMIDI, /**< SP-MIDI */
+ OMX_AUDIO_MIDIFormatXMF0, /**< eXtensible Music Format type 0 */
+ OMX_AUDIO_MIDIFormatXMF1, /**< eXtensible Music Format type 1 */
+ OMX_AUDIO_MIDIFormatMobileXMF, /**< Mobile XMF (eXtensible Music Format type 2) */
+ OMX_AUDIO_MIDIFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_MIDIFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_MIDIFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_MIDIFORMATTYPE;
+
+
+/** MIDI params
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_PARAM_MIDITYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nFileSize; /**< size of the MIDI file in bytes, where the entire
+ MIDI file passed in, otherwise if 0x0, the MIDI data
+ is merged and streamed (instead of passed as an
+ entire MIDI file) */
+ OMX_BU32 sMaxPolyphony; /**< Specifies the maximum simultaneous polyphonic
+ voices. A value of zero indicates that the default
+ polyphony of the device is used */
+ OMX_BOOL bLoadDefaultSound; /**< Whether to load default sound
+ bank at initialization */
+ OMX_AUDIO_MIDIFORMATTYPE eMidiFormat; /**< Version of the MIDI file */
+} OMX_AUDIO_PARAM_MIDITYPE;
+
+
+/** Type of the MIDI sound bank
+ * @ingroup midi
+ */
+typedef enum OMX_AUDIO_MIDISOUNDBANKTYPE {
+ OMX_AUDIO_MIDISoundBankUnused = 0, /**< unused/unknown soundbank type */
+ OMX_AUDIO_MIDISoundBankDLS1, /**< DLS version 1 */
+ OMX_AUDIO_MIDISoundBankDLS2, /**< DLS version 2 */
+ OMX_AUDIO_MIDISoundBankMobileDLSBase, /**< Mobile DLS, using the base functionality */
+ OMX_AUDIO_MIDISoundBankMobileDLSPlusOptions, /**< Mobile DLS, using the specification-defined optional feature set */
+ OMX_AUDIO_MIDISoundBankKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_MIDISoundBankVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_MIDISoundBankMax = 0x7FFFFFFF
+} OMX_AUDIO_MIDISOUNDBANKTYPE;
+
+
+/** Bank Layout describes how bank MSB & LSB are used in the DLS instrument definitions sound bank
+ * @ingroup midi
+ */
+typedef enum OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE {
+ OMX_AUDIO_MIDISoundBankLayoutUnused = 0, /**< unused/unknown soundbank type */
+ OMX_AUDIO_MIDISoundBankLayoutGM, /**< GS layout (based on bank MSB 0x00) */
+ OMX_AUDIO_MIDISoundBankLayoutGM2, /**< General MIDI 2 layout (using MSB 0x78/0x79, LSB 0x00) */
+ OMX_AUDIO_MIDISoundBankLayoutUser, /**< Does not conform to any bank numbering standards */
+ OMX_AUDIO_MIDISoundBankLayoutKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_MIDISoundBankLayoutVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_MIDISoundBankLayoutMax = 0x7FFFFFFF
+} OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE;
+
+
+/** MIDI params to load/unload user soundbank
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nDLSIndex; /**< DLS file index to be loaded */
+ OMX_U32 nDLSSize; /**< Size in bytes */
+ OMX_PTR pDLSData; /**< Pointer to DLS file data */
+ OMX_AUDIO_MIDISOUNDBANKTYPE eMidiSoundBank; /**< Midi sound bank type enumeration */
+ OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE eMidiSoundBankLayout; /**< Midi sound bank layout enumeration */
+} OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE;
+
+
+/** Structure for Live MIDI events and MIP messages.
+ * (MIP = Maximum Instantaneous Polyphony; part of the SP-MIDI standard.)
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< Port that this structure applies to */
+ OMX_U32 nMidiEventSize; /**< Size of immediate MIDI events or MIP message in bytes */
+ OMX_U8 nMidiEvents[1]; /**< MIDI event array to be rendered immediately, or an
+ array for the MIP message buffer, where the size is
+ indicated by nMidiEventSize */
+} OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE;
+
+
+/** MIDI sound bank/ program pair in a given channel
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< Port that this structure applies to */
+ OMX_U32 nChannel; /**< Valid channel values range from 1 to 16 */
+ OMX_U16 nIDProgram; /**< Valid program ID range is 1 to 128 */
+ OMX_U16 nIDSoundBank; /**< Sound bank ID */
+ OMX_U32 nUserSoundBankIndex;/**< User soundbank index, easier to access soundbanks
+ by index if multiple banks are present */
+} OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE;
+
+
+/** MIDI control
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDICONTROLTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BS32 sPitchTransposition; /**< Pitch transposition in semitones, stored as Q22.10
+ format based on JAVA MMAPI (JSR-135) requirement */
+ OMX_BU32 sPlayBackRate; /**< Relative playback rate, stored as Q14.17 fixed-point
+ number based on JSR-135 requirement */
+ OMX_BU32 sTempo ; /**< Tempo in beats per minute (BPM), stored as Q22.10
+ fixed-point number based on JSR-135 requirement */
+ OMX_U32 nMaxPolyphony; /**< Specifies the maximum simultaneous polyphonic
+ voices. A value of zero indicates that the default
+ polyphony of the device is used */
+ OMX_U32 nNumRepeat; /**< Number of times to repeat playback */
+ OMX_U32 nStopTime; /**< Time in milliseconds to indicate when playback
+ will stop automatically. Set to zero if not used */
+ OMX_U16 nChannelMuteMask; /**< 16 bit mask for channel mute status */
+ OMX_U16 nChannelSoloMask; /**< 16 bit mask for channel solo status */
+ OMX_U32 nTrack0031MuteMask; /**< 32 bit mask for track mute status. Note: This is for tracks 0-31 */
+ OMX_U32 nTrack3263MuteMask; /**< 32 bit mask for track mute status. Note: This is for tracks 32-63 */
+ OMX_U32 nTrack0031SoloMask; /**< 32 bit mask for track solo status. Note: This is for tracks 0-31 */
+ OMX_U32 nTrack3263SoloMask; /**< 32 bit mask for track solo status. Note: This is for tracks 32-63 */
+
+} OMX_AUDIO_CONFIG_MIDICONTROLTYPE;
+
+
+/** MIDI Playback States
+ * @ingroup midi
+ */
+typedef enum OMX_AUDIO_MIDIPLAYBACKSTATETYPE {
+ OMX_AUDIO_MIDIPlayBackStateUnknown = 0, /**< Unknown state or state does not map to
+ other defined states */
+ OMX_AUDIO_MIDIPlayBackStateClosedEngaged, /**< No MIDI resource is currently open.
+ The MIDI engine is currently processing
+ MIDI events. */
+ OMX_AUDIO_MIDIPlayBackStateParsing, /**< A MIDI resource is open and is being
+ primed. The MIDI engine is currently
+ processing MIDI events. */
+ OMX_AUDIO_MIDIPlayBackStateOpenEngaged, /**< A MIDI resource is open and primed but
+ not playing. The MIDI engine is currently
+ processing MIDI events. The transition to
+ this state is only possible from the
+ OMX_AUDIO_MIDIPlayBackStatePlaying state,
+ when the 'playback head' reaches the end
+ of media data or the playback stops due
+ to stop time set.*/
+ OMX_AUDIO_MIDIPlayBackStatePlaying, /**< A MIDI resource is open and currently
+ playing. The MIDI engine is currently
+ processing MIDI events.*/
+ OMX_AUDIO_MIDIPlayBackStatePlayingPartially, /**< Best-effort playback due to SP-MIDI/DLS
+ resource constraints */
+ OMX_AUDIO_MIDIPlayBackStatePlayingSilently, /**< Due to system resource constraints and
+ SP-MIDI content constraints, there is
+ no audible MIDI content during playback
+ currently. The situation may change if
+ resources are freed later.*/
+ OMX_AUDIO_MIDIPlayBackStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_MIDIPlayBackStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_MIDIPlayBackStateMax = 0x7FFFFFFF
+} OMX_AUDIO_MIDIPLAYBACKSTATETYPE;
+
+
+/** MIDI status
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDISTATUSTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U16 nNumTracks; /**< Number of MIDI tracks in the file, read only field.
+ NOTE: May not return a meaningful value until the entire
+ file is parsed and buffered. */
+ OMX_U32 nDuration; /**< The length of the currently open MIDI resource
+ in milliseconds. NOTE: May not return a meaningful value
+ until the entire file is parsed and buffered. */
+ OMX_U32 nPosition; /**< Current Position of the MIDI resource being played
+ in milliseconds */
+ OMX_BOOL bVibra; /**< Does Vibra track exist? NOTE: May not return a meaningful
+ value until the entire file is parsed and buffered. */
+ OMX_U32 nNumMetaEvents; /**< Total number of MIDI Meta Events in the currently
+ open MIDI resource. NOTE: May not return a meaningful value
+ until the entire file is parsed and buffered. */
+ OMX_U32 nNumActiveVoices; /**< Number of active voices in the currently playing
+ MIDI resource. NOTE: May not return a meaningful value until
+ the entire file is parsed and buffered. */
+ OMX_AUDIO_MIDIPLAYBACKSTATETYPE eMIDIPlayBackState; /**< MIDI playback state enumeration, read only field */
+} OMX_AUDIO_CONFIG_MIDISTATUSTYPE;
+
+
+/** MIDI Meta Event structure one per Meta Event.
+ * MIDI Meta Events are like audio metadata, except that they are interspersed
+ * with the MIDI content throughout the file and are not localized in the header.
+ * As such, it is necessary to retrieve information about these Meta Events from
+ * the engine, as it encounters these Meta Events within the MIDI content.
+ * For example, SMF files can have up to 14 types of MIDI Meta Events (copyright,
+ * author, default tempo, etc.) scattered throughout the file.
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nIndex; /**< Index of Meta Event */
+ OMX_U8 nMetaEventType; /**< Meta Event Type, 7bits (i.e. 0 - 127) */
+ OMX_U32 nMetaEventSize; /**< size of the Meta Event in bytes */
+ OMX_U32 nTrack; /**< track number for the meta event */
+ OMX_U32 nPosition; /**< Position of the meta-event in milliseconds */
+} OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE;
+
+
+/** MIDI Meta Event Data structure - one per Meta Event.
+ * @ingroup midi
+ */
+typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nIndex; /**< Index of Meta Event */
+ OMX_U32 nMetaEventSize; /**< size of the Meta Event in bytes */
+ OMX_U8 nData[1]; /**< array of one or more bytes of meta data
+ as indicated by the nMetaEventSize field */
+} OMX_AUDIO_CONFIG__MIDIMETAEVENTDATATYPE;
+
+
+/** Audio Volume adjustment for a port */
+typedef struct OMX_AUDIO_CONFIG_VOLUMETYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< Port index indicating which port to
+ set. Select the input port to set
+ just that port's volume. Select the
+ output port to adjust the master
+ volume. */
+ OMX_BOOL bLinear; /**< Is the volume to be set in linear (0.100)
+ or logarithmic scale (mB) */
+ OMX_BS32 sVolume; /**< Volume linear setting in the 0..100 range, OR
+ Volume logarithmic setting for this port. The values
+ for volume are in mB (millibels = 1/100 dB) relative
+ to a gain of 1 (e.g. the output is the same as the
+ input level). Values are in mB from nMax
+ (maximum volume) to nMin mB (typically negative).
+ Since the volume is "voltage"
+ and not a "power", it takes a setting of
+ -600 mB to decrease the volume by 1/2. If
+ a component cannot accurately set the
+ volume to the requested value, it must
+ set the volume to the closest value BELOW
+ the requested value. When getting the
+ volume setting, the current actual volume
+ must be returned. */
+} OMX_AUDIO_CONFIG_VOLUMETYPE;
+
+
+/** Audio Volume adjustment for a channel */
+typedef struct OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< Port index indicating which port to
+ set. Select the input port to set
+ just that port's volume. Select the
+ output port to adjust the master
+ volume. */
+ OMX_U32 nChannel; /**< channel to select from 0 to N-1,
+ using OMX_ALL to apply volume settings
+ to all channels */
+ OMX_BOOL bLinear; /**< Is the volume to be set in linear (0.100) or
+ logarithmic scale (mB) */
+ OMX_BS32 sVolume; /**< Volume linear setting in the 0..100 range, OR
+ Volume logarithmic setting for this port.
+ The values for volume are in mB
+ (millibels = 1/100 dB) relative to a gain
+ of 1 (e.g. the output is the same as the
+ input level). Values are in mB from nMax
+ (maximum volume) to nMin mB (typically negative).
+ Since the volume is "voltage"
+ and not a "power", it takes a setting of
+ -600 mB to decrease the volume by 1/2. If
+ a component cannot accurately set the
+ volume to the requested value, it must
+ set the volume to the closest value BELOW
+ the requested value. When getting the
+ volume setting, the current actual volume
+ must be returned. */
+ OMX_BOOL bIsMIDI; /**< TRUE if nChannel refers to a MIDI channel,
+ FALSE otherwise */
+} OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE;
+
+
+/** Audio balance setting */
+typedef struct OMX_AUDIO_CONFIG_BALANCETYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< Port index indicating which port to
+ set. Select the input port to set
+ just that port's balance. Select the
+ output port to adjust the master
+ balance. */
+ OMX_S32 nBalance; /**< balance setting for this port
+ (-100 to 100, where -100 indicates
+ all left, and no right */
+} OMX_AUDIO_CONFIG_BALANCETYPE;
+
+
+/** Audio Port mute */
+typedef struct OMX_AUDIO_CONFIG_MUTETYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< Port index indicating which port to
+ set. Select the input port to set
+ just that port's mute. Select the
+ output port to adjust the master
+ mute. */
+ OMX_BOOL bMute; /**< Mute setting for this port */
+} OMX_AUDIO_CONFIG_MUTETYPE;
+
+
+/** Audio Channel mute */
+typedef struct OMX_AUDIO_CONFIG_CHANNELMUTETYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nChannel; /**< channel to select from 0 to N-1,
+ using OMX_ALL to apply mute settings
+ to all channels */
+ OMX_BOOL bMute; /**< Mute setting for this channel */
+ OMX_BOOL bIsMIDI; /**< TRUE if nChannel refers to a MIDI channel,
+ FALSE otherwise */
+} OMX_AUDIO_CONFIG_CHANNELMUTETYPE;
+
+
+
+/** Enable / Disable for loudness control, which boosts bass and to a
+ * smaller extent high end frequencies to compensate for hearing
+ * ability at the extreme ends of the audio spectrum
+ */
+typedef struct OMX_AUDIO_CONFIG_LOUDNESSTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BOOL bLoudness; /**< Enable/disable for loudness */
+} OMX_AUDIO_CONFIG_LOUDNESSTYPE;
+
+
+/** Enable / Disable for bass, which controls low frequencies
+ */
+typedef struct OMX_AUDIO_CONFIG_BASSTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BOOL bEnable; /**< Enable/disable for bass control */
+ OMX_S32 nBass; /**< bass setting for the port, as a
+ continuous value from -100 to 100
+ (0 means no change in bass level)*/
+} OMX_AUDIO_CONFIG_BASSTYPE;
+
+
+/** Enable / Disable for treble, which controls high frequencies tones
+ */
+typedef struct OMX_AUDIO_CONFIG_TREBLETYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BOOL bEnable; /**< Enable/disable for treble control */
+ OMX_S32 nTreble; /**< treble setting for the port, as a
+ continuous value from -100 to 100
+ (0 means no change in treble level) */
+} OMX_AUDIO_CONFIG_TREBLETYPE;
+
+
+/** An equalizer is typically used for two reasons: to compensate for an
+ * sub-optimal frequency response of a system to make it sound more natural
+ * or to create intentionally some unnatural coloring to the sound to create
+ * an effect.
+ * @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_EQUALIZERTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BOOL bEnable; /**< Enable/disable for equalizer */
+ OMX_BU32 sBandIndex; /**< Band number to be set. Upper Limit is
+ N-1, where N is the number of bands, lower limit is 0 */
+ OMX_BU32 sCenterFreq; /**< Center frequecies in Hz. This is a
+ read only element and is used to determine
+ the lower, center and upper frequency of
+ this band. */
+ OMX_BS32 sBandLevel; /**< band level in millibels */
+} OMX_AUDIO_CONFIG_EQUALIZERTYPE;
+
+
+/** Stereo widening mode type
+ * @ingroup effects
+ */
+typedef enum OMX_AUDIO_STEREOWIDENINGTYPE {
+ OMX_AUDIO_StereoWideningHeadphones, /**< Stereo widening for loudspeakers */
+ OMX_AUDIO_StereoWideningLoudspeakers, /**< Stereo widening for closely spaced loudspeakers */
+ OMX_AUDIO_StereoWideningKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_StereoWideningVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_StereoWideningMax = 0x7FFFFFFF
+} OMX_AUDIO_STEREOWIDENINGTYPE;
+
+
+/** Control for stereo widening, which is a special 2-channel
+ * case of the audio virtualizer effect. For example, for 5.1-channel
+ * output, it translates to virtual surround sound.
+ * @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BOOL bEnable; /**< Enable/disable for stereo widening control */
+ OMX_AUDIO_STEREOWIDENINGTYPE eWideningType; /**< Stereo widening algorithm type */
+ OMX_U32 nStereoWidening; /**< stereo widening setting for the port,
+ as a continuous value from 0 to 100 */
+} OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE;
+
+
+/** The chorus effect (or ``choralizer'') is any signal processor which makes
+ * one sound source (such as a voice) sound like many such sources singing
+ * (or playing) in unison. Since performance in unison is never exact, chorus
+ * effects simulate this by making independently modified copies of the input
+ * signal. Modifications may include (1) delay, (2) frequency shift, and
+ * (3) amplitude modulation.
+ * @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_CHORUSTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BOOL bEnable; /**< Enable/disable for chorus */
+ OMX_BU32 sDelay; /**< average delay in milliseconds */
+ OMX_BU32 sModulationRate; /**< rate of modulation in millihertz */
+ OMX_U32 nModulationDepth; /**< depth of modulation as a percentage of
+ delay (i.e. 0 to 100) */
+ OMX_BU32 nFeedback; /**< Feedback from chorus output to input in percentage */
+} OMX_AUDIO_CONFIG_CHORUSTYPE;
+
+
+/** Reverberation is part of the reflected sound that follows the early
+ * reflections. In a typical room, this consists of a dense succession of
+ * echoes whose energy decays exponentially. The reverberation effect structure
+ * as defined here includes both (early) reflections as well as (late) reverberations.
+ * @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_REVERBERATIONTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BOOL bEnable; /**< Enable/disable for reverberation control */
+ OMX_BS32 sRoomLevel; /**< Intensity level for the whole room effect
+ (i.e. both early reflections and late
+ reverberation) in millibels */
+ OMX_BS32 sRoomHighFreqLevel; /**< Attenuation at high frequencies
+ relative to the intensity at low
+ frequencies in millibels */
+ OMX_BS32 sReflectionsLevel; /**< Intensity level of early reflections
+ (relative to room value), in millibels */
+ OMX_BU32 sReflectionsDelay; /**< Delay time of the first reflection relative
+ to the direct path, in milliseconds */
+ OMX_BS32 sReverbLevel; /**< Intensity level of late reverberation
+ relative to room level, in millibels */
+ OMX_BU32 sReverbDelay; /**< Time delay from the first early reflection
+ to the beginning of the late reverberation
+ section, in milliseconds */
+ OMX_BU32 sDecayTime; /**< Late reverberation decay time at low
+ frequencies, in milliseconds */
+ OMX_BU32 nDecayHighFreqRatio; /**< Ratio of high frequency decay time relative
+ to low frequency decay time in percent */
+ OMX_U32 nDensity; /**< Modal density in the late reverberation decay,
+ in percent (i.e. 0 - 100) */
+ OMX_U32 nDiffusion; /**< Echo density in the late reverberation decay,
+ in percent (i.e. 0 - 100) */
+ OMX_BU32 sReferenceHighFreq; /**< Reference high frequency in Hertz. This is
+ the frequency used as the reference for all
+ the high-frequency settings above */
+
+} OMX_AUDIO_CONFIG_REVERBERATIONTYPE;
+
+
+/** Possible settings for the Echo Cancelation structure to use
+ * @ingroup effects
+ */
+typedef enum OMX_AUDIO_ECHOCANTYPE {
+ OMX_AUDIO_EchoCanOff = 0, /**< Echo Cancellation is disabled */
+ OMX_AUDIO_EchoCanNormal, /**< Echo Cancellation normal operation -
+ echo from plastics and face */
+ OMX_AUDIO_EchoCanHFree, /**< Echo Cancellation optimized for
+ Hands Free operation */
+ OMX_AUDIO_EchoCanCarKit, /**< Echo Cancellation optimized for
+ Car Kit (longer echo) */
+ OMX_AUDIO_EchoCanKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_AUDIO_EchoCanVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_AUDIO_EchoCanMax = 0x7FFFFFFF
+} OMX_AUDIO_ECHOCANTYPE;
+
+
+/** Enable / Disable for echo cancelation, which removes undesired echo's
+ * from the audio
+ * @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_AUDIO_ECHOCANTYPE eEchoCancelation; /**< Echo cancelation settings */
+} OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE;
+
+
+/** Enable / Disable for noise reduction, which undesired noise from
+ * the audio
+ * @ingroup effects
+ */
+typedef struct OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_BOOL bNoiseReduction; /**< Enable/disable for noise reduction */
+} OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* File EOF */
+
diff --git a/include/khronos/OMX_Component.h b/include/khronos/OMX_Component.h
new file mode 100644
index 0000000..56fd37e
--- /dev/null
+++ b/include/khronos/OMX_Component.h
@@ -0,0 +1,569 @@
+/*
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_Component.h - OpenMax IL version 1.1.2
+ * The OMX_Component header file contains the definitions used to define
+ * the public interface of a component. This header file is intended to
+ * be used by both the application and the component.
+ */
+
+#ifndef OMX_Component_h
+#define OMX_Component_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+
+/* Each OMX header must include all required header files to allow the
+ * header to compile without errors. The includes below are required
+ * for this header file to compile successfully
+ */
+
+#include <OMX_Audio.h>
+#include <OMX_Video.h>
+#include <OMX_Image.h>
+#include <OMX_Other.h>
+
+/** @ingroup comp */
+typedef enum OMX_PORTDOMAINTYPE {
+ OMX_PortDomainAudio,
+ OMX_PortDomainVideo,
+ OMX_PortDomainImage,
+ OMX_PortDomainOther,
+ OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_PortDomainVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_PortDomainMax = 0x7ffffff
+} OMX_PORTDOMAINTYPE;
+
+/** @ingroup comp */
+typedef struct OMX_PARAM_PORTDEFINITIONTYPE {
+ OMX_U32 nSize; /**< Size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< Port number the structure applies to */
+ OMX_DIRTYPE eDir; /**< Direction (input or output) of this port */
+ OMX_U32 nBufferCountActual; /**< The actual number of buffers allocated on this port */
+ OMX_U32 nBufferCountMin; /**< The minimum number of buffers this port requires */
+ OMX_U32 nBufferSize; /**< Size, in bytes, for buffers to be used for this channel */
+ OMX_BOOL bEnabled; /**< Ports default to enabled and are enabled/disabled by
+ OMX_CommandPortEnable/OMX_CommandPortDisable.
+ When disabled a port is unpopulated. A disabled port
+ is not populated with buffers on a transition to IDLE. */
+ OMX_BOOL bPopulated; /**< Port is populated with all of its buffers as indicated by
+ nBufferCountActual. A disabled port is always unpopulated.
+ An enabled port is populated on a transition to OMX_StateIdle
+ and unpopulated on a transition to loaded. */
+ OMX_PORTDOMAINTYPE eDomain; /**< Domain of the port. Determines the contents of metadata below. */
+ union {
+ OMX_AUDIO_PORTDEFINITIONTYPE audio;
+ OMX_VIDEO_PORTDEFINITIONTYPE video;
+ OMX_IMAGE_PORTDEFINITIONTYPE image;
+ OMX_OTHER_PORTDEFINITIONTYPE other;
+ } format;
+ OMX_BOOL bBuffersContiguous;
+ OMX_U32 nBufferAlignment;
+} OMX_PARAM_PORTDEFINITIONTYPE;
+
+/** @ingroup comp */
+typedef struct OMX_PARAM_U32TYPE {
+ OMX_U32 nSize; /**< Size of this structure, in Bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nPortIndex; /**< port that this structure applies to */
+ OMX_U32 nU32; /**< U32 value */
+} OMX_PARAM_U32TYPE;
+
+/** @ingroup rpm */
+typedef enum OMX_SUSPENSIONPOLICYTYPE {
+ OMX_SuspensionDisabled, /**< No suspension; v1.0 behavior */
+ OMX_SuspensionEnabled, /**< Suspension allowed */
+ OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_SuspensionPolicyStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_SuspensionPolicyMax = 0x7fffffff
+} OMX_SUSPENSIONPOLICYTYPE;
+
+/** @ingroup rpm */
+typedef struct OMX_PARAM_SUSPENSIONPOLICYTYPE {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_SUSPENSIONPOLICYTYPE ePolicy;
+} OMX_PARAM_SUSPENSIONPOLICYTYPE;
+
+/** @ingroup rpm */
+typedef enum OMX_SUSPENSIONTYPE {
+ OMX_NotSuspended, /**< component is not suspended */
+ OMX_Suspended, /**< component is suspended */
+ OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_SuspensionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_SuspendMax = 0x7FFFFFFF
+} OMX_SUSPENSIONTYPE;
+
+/** @ingroup rpm */
+typedef struct OMX_PARAM_SUSPENSIONTYPE {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_SUSPENSIONTYPE eType;
+} OMX_PARAM_SUSPENSIONTYPE ;
+
+typedef struct OMX_CONFIG_BOOLEANTYPE {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_BOOL bEnabled;
+} OMX_CONFIG_BOOLEANTYPE;
+
+/* Parameter specifying the content uri to use. */
+/** @ingroup cp */
+typedef struct OMX_PARAM_CONTENTURITYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes, including
+ actual URI name */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U8 contentURI[1]; /**< The URI name */
+} OMX_PARAM_CONTENTURITYPE;
+
+/* Parameter specifying the pipe to use. */
+/** @ingroup cp */
+typedef struct OMX_PARAM_CONTENTPIPETYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_HANDLETYPE hPipe; /**< The pipe handle*/
+} OMX_PARAM_CONTENTPIPETYPE;
+
+/** @ingroup rpm */
+typedef struct OMX_RESOURCECONCEALMENTTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_BOOL bResourceConcealmentForbidden; /**< disallow the use of resource concealment
+ methods (like degrading algorithm quality to
+ lower resource consumption or functional bypass)
+ on a component as a resolution to resource conflicts. */
+} OMX_RESOURCECONCEALMENTTYPE;
+
+
+/** @ingroup metadata */
+typedef enum OMX_METADATACHARSETTYPE {
+ OMX_MetadataCharsetUnknown = 0,
+ OMX_MetadataCharsetASCII,
+ OMX_MetadataCharsetBinary,
+ OMX_MetadataCharsetCodePage1252,
+ OMX_MetadataCharsetUTF8,
+ OMX_MetadataCharsetJavaConformantUTF8,
+ OMX_MetadataCharsetUTF7,
+ OMX_MetadataCharsetImapUTF7,
+ OMX_MetadataCharsetUTF16LE,
+ OMX_MetadataCharsetUTF16BE,
+ OMX_MetadataCharsetGB12345,
+ OMX_MetadataCharsetHZGB2312,
+ OMX_MetadataCharsetGB2312,
+ OMX_MetadataCharsetGB18030,
+ OMX_MetadataCharsetGBK,
+ OMX_MetadataCharsetBig5,
+ OMX_MetadataCharsetISO88591,
+ OMX_MetadataCharsetISO88592,
+ OMX_MetadataCharsetISO88593,
+ OMX_MetadataCharsetISO88594,
+ OMX_MetadataCharsetISO88595,
+ OMX_MetadataCharsetISO88596,
+ OMX_MetadataCharsetISO88597,
+ OMX_MetadataCharsetISO88598,
+ OMX_MetadataCharsetISO88599,
+ OMX_MetadataCharsetISO885910,
+ OMX_MetadataCharsetISO885913,
+ OMX_MetadataCharsetISO885914,
+ OMX_MetadataCharsetISO885915,
+ OMX_MetadataCharsetShiftJIS,
+ OMX_MetadataCharsetISO2022JP,
+ OMX_MetadataCharsetISO2022JP1,
+ OMX_MetadataCharsetISOEUCJP,
+ OMX_MetadataCharsetSMS7Bit,
+ OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_MetadataCharsetVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_MetadataCharsetTypeMax = 0x7FFFFFFF
+} OMX_METADATACHARSETTYPE;
+
+/** @ingroup metadata */
+typedef enum OMX_METADATASCOPETYPE {
+ OMX_MetadataScopeAllLevels,
+ OMX_MetadataScopeTopLevel,
+ OMX_MetadataScopePortLevel,
+ OMX_MetadataScopeNodeLevel,
+ OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_MetadataScopeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_MetadataScopeTypeMax = 0x7fffffff
+} OMX_METADATASCOPETYPE;
+
+/** @ingroup metadata */
+typedef enum OMX_METADATASEARCHMODETYPE {
+ OMX_MetadataSearchValueSizeByIndex,
+ OMX_MetadataSearchItemByIndex,
+ OMX_MetadataSearchNextItemByKey,
+ OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_MetadataSearchVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_MetadataSearchTypeMax = 0x7fffffff
+} OMX_METADATASEARCHMODETYPE;
+/** @ingroup metadata */
+typedef struct OMX_CONFIG_METADATAITEMCOUNTTYPE {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_METADATASCOPETYPE eScopeMode;
+ OMX_U32 nScopeSpecifier;
+ OMX_U32 nMetadataItemCount;
+} OMX_CONFIG_METADATAITEMCOUNTTYPE;
+
+/** @ingroup metadata */
+typedef struct OMX_CONFIG_METADATAITEMTYPE {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_METADATASCOPETYPE eScopeMode;
+ OMX_U32 nScopeSpecifier;
+ OMX_U32 nMetadataItemIndex;
+ OMX_METADATASEARCHMODETYPE eSearchMode;
+ OMX_METADATACHARSETTYPE eKeyCharset;
+ OMX_U8 nKeySizeUsed;
+ OMX_U8 nKey[128];
+ OMX_METADATACHARSETTYPE eValueCharset;
+ OMX_STRING sLanguageCountry;
+ OMX_U32 nValueMaxSize;
+ OMX_U32 nValueSizeUsed;
+ OMX_U8 nValue[1];
+} OMX_CONFIG_METADATAITEMTYPE;
+
+/* @ingroup metadata */
+typedef struct OMX_CONFIG_CONTAINERNODECOUNTTYPE {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_BOOL bAllKeys;
+ OMX_U32 nParentNodeID;
+ OMX_U32 nNumNodes;
+} OMX_CONFIG_CONTAINERNODECOUNTTYPE;
+
+/** @ingroup metadata */
+typedef struct OMX_CONFIG_CONTAINERNODEIDTYPE {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_BOOL bAllKeys;
+ OMX_U32 nParentNodeID;
+ OMX_U32 nNodeIndex;
+ OMX_U32 nNodeID;
+ OMX_STRING cNodeName;
+ OMX_BOOL bIsLeafType;
+} OMX_CONFIG_CONTAINERNODEIDTYPE;
+
+/** @ingroup metadata */
+typedef struct OMX_PARAM_METADATAFILTERTYPE {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_BOOL bAllKeys; /* if true then this structure refers to all keys and
+ * the three key fields below are ignored */
+ OMX_METADATACHARSETTYPE eKeyCharset;
+ OMX_U32 nKeySizeUsed;
+ OMX_U8 nKey [128];
+ OMX_U32 nLanguageCountrySizeUsed;
+ OMX_U8 nLanguageCountry[128];
+ OMX_BOOL bEnabled; /* if true then key is part of filter (e.g.
+ * retained for query later). If false then
+ * key is not part of filter */
+} OMX_PARAM_METADATAFILTERTYPE;
+
+/** The OMX_HANDLETYPE structure defines the component handle. The component
+ * handle is used to access all of the component's public methods and also
+ * contains pointers to the component's private data area. The component
+ * handle is initialized by the OMX core (with help from the component)
+ * during the process of loading the component. After the component is
+ * successfully loaded, the application can safely access any of the
+ * component's public functions (although some may return an error because
+ * the state is inappropriate for the access).
+ *
+ * @ingroup comp
+ */
+typedef struct OMX_COMPONENTTYPE {
+ /** The size of this structure, in bytes. It is the responsibility
+ of the allocator of this structure to fill in this value. Since
+ this structure is allocated by the GetHandle function, this
+ function will fill in this value. */
+ OMX_U32 nSize;
+
+ /** nVersion is the version of the OMX specification that the structure
+ is built against. It is the responsibility of the creator of this
+ structure to initialize this value and every user of this structure
+ should verify that it knows how to use the exact version of
+ this structure found herein. */
+ OMX_VERSIONTYPE nVersion;
+
+ /** pComponentPrivate is a pointer to the component private data area.
+ This member is allocated and initialized by the component when the
+ component is first loaded. The application should not access this
+ data area. */
+ OMX_PTR pComponentPrivate;
+
+ /** pApplicationPrivate is a pointer that is a parameter to the
+ OMX_GetHandle method, and contains an application private value
+ provided by the IL client. This application private data is
+ returned to the IL Client by OMX in all callbacks */
+ OMX_PTR pApplicationPrivate;
+
+ /** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL
+ specification for details on the GetComponentVersion method.
+ */
+ OMX_ERRORTYPE (*GetComponentVersion)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_OUT OMX_STRING pComponentName,
+ OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
+ OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
+ OMX_OUT OMX_UUIDTYPE* pComponentUUID);
+
+ /** refer to OMX_SendCommand in OMX_core.h or the OMX IL
+ specification for details on the SendCommand method.
+ */
+ OMX_ERRORTYPE (*SendCommand)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_COMMANDTYPE Cmd,
+ OMX_IN OMX_U32 nParam1,
+ OMX_IN OMX_PTR pCmdData);
+
+ /** refer to OMX_GetParameter in OMX_core.h or the OMX IL
+ specification for details on the GetParameter method.
+ */
+ OMX_ERRORTYPE (*GetParameter)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR pComponentParameterStructure);
+
+
+ /** refer to OMX_SetParameter in OMX_core.h or the OMX IL
+ specification for details on the SetParameter method.
+ */
+ OMX_ERRORTYPE (*SetParameter)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR pComponentParameterStructure);
+
+
+ /** refer to OMX_GetConfig in OMX_core.h or the OMX IL
+ specification for details on the GetConfig method.
+ */
+ OMX_ERRORTYPE (*GetConfig)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_INOUT OMX_PTR pComponentConfigStructure);
+
+
+ /** refer to OMX_SetConfig in OMX_core.h or the OMX IL
+ specification for details on the SetConfig method.
+ */
+ OMX_ERRORTYPE (*SetConfig)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR pComponentConfigStructure);
+
+
+ /** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL
+ specification for details on the GetExtensionIndex method.
+ */
+ OMX_ERRORTYPE (*GetExtensionIndex)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE* pIndexType);
+
+
+ /** refer to OMX_GetState in OMX_core.h or the OMX IL
+ specification for details on the GetState method.
+ */
+ OMX_ERRORTYPE (*GetState)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_OUT OMX_STATETYPE* pState);
+
+
+ /** The ComponentTunnelRequest method will interact with another OMX
+ component to determine if tunneling is possible and to setup the
+ tunneling. The return codes for this method can be used to
+ determine if tunneling is not possible, or if tunneling is not
+ supported.
+
+ Base profile components (i.e. non-interop) do not support this
+ method and should return OMX_ErrorNotImplemented
+
+ The interop profile component MUST support tunneling to another
+ interop profile component with a compatible port parameters.
+ A component may also support proprietary communication.
+
+ If proprietary communication is supported the negotiation of
+ proprietary communication is done outside of OMX in a vendor
+ specific way. It is only required that the proper result be
+ returned and the details of how the setup is done is left
+ to the component implementation.
+
+ When this method is invoked when nPort in an output port, the
+ component will:
+ 1. Populate the pTunnelSetup structure with the output port's
+ requirements and constraints for the tunnel.
+
+ When this method is invoked when nPort in an input port, the
+ component will:
+ 1. Query the necessary parameters from the output port to
+ determine if the ports are compatible for tunneling
+ 2. If the ports are compatible, the component should store
+ the tunnel step provided by the output port
+ 3. Determine which port (either input or output) is the buffer
+ supplier, and call OMX_SetParameter on the output port to
+ indicate this selection.
+
+ The component will return from this call within 5 msec.
+
+ @param [in] hComp
+ Handle of the component to be accessed. This is the component
+ handle returned by the call to the OMX_GetHandle method.
+ @param [in] nPort
+ nPort is used to select the port on the component to be used
+ for tunneling.
+ @param [in] hTunneledComp
+ Handle of the component to tunnel with. This is the component
+ handle returned by the call to the OMX_GetHandle method. When
+ this parameter is 0x0 the component should setup the port for
+ communication with the application / IL Client.
+ @param [in] nPortOutput
+ nPortOutput is used indicate the port the component should
+ tunnel with.
+ @param [in] pTunnelSetup
+ Pointer to the tunnel setup structure. When nPort is an output port
+ the component should populate the fields of this structure. When
+ When nPort is an input port the component should review the setup
+ provided by the component with the output port.
+ @return OMX_ERRORTYPE
+ If the command successfully executes, the return code will be
+ OMX_ErrorNone. Otherwise the appropriate OMX error will be returned.
+ @ingroup tun
+ */
+
+ OMX_ERRORTYPE (*ComponentTunnelRequest)(
+ OMX_IN OMX_HANDLETYPE hComp,
+ OMX_IN OMX_U32 nPort,
+ OMX_IN OMX_HANDLETYPE hTunneledComp,
+ OMX_IN OMX_U32 nTunneledPort,
+ OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup);
+
+ /** refer to OMX_UseBuffer in OMX_core.h or the OMX IL
+ specification for details on the UseBuffer method.
+ @ingroup buf
+ */
+ OMX_ERRORTYPE (*UseBuffer)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes,
+ OMX_IN OMX_U8* pBuffer);
+
+ /** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL
+ specification for details on the AllocateBuffer method.
+ @ingroup buf
+ */
+ OMX_ERRORTYPE (*AllocateBuffer)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes);
+
+ /** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL
+ specification for details on the FreeBuffer method.
+ @ingroup buf
+ */
+ OMX_ERRORTYPE (*FreeBuffer)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
+
+ /** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL
+ specification for details on the EmptyThisBuffer method.
+ @ingroup buf
+ */
+ OMX_ERRORTYPE (*EmptyThisBuffer)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
+
+ /** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL
+ specification for details on the FillThisBuffer method.
+ @ingroup buf
+ */
+ OMX_ERRORTYPE (*FillThisBuffer)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
+
+ /** The SetCallbacks method is used by the core to specify the callback
+ structure from the application to the component. This is a blocking
+ call. The component will return from this call within 5 msec.
+ @param [in] hComponent
+ Handle of the component to be accessed. This is the component
+ handle returned by the call to the GetHandle function.
+ @param [in] pCallbacks
+ pointer to an OMX_CALLBACKTYPE structure used to provide the
+ callback information to the component
+ @param [in] pAppData
+ pointer to an application defined value. It is anticipated that
+ the application will pass a pointer to a data structure or a "this
+ pointer" in this area to allow the callback (in the application)
+ to determine the context of the call
+ @return OMX_ERRORTYPE
+ If the command successfully executes, the return code will be
+ OMX_ErrorNone. Otherwise the appropriate OMX error will be returned.
+ */
+ OMX_ERRORTYPE (*SetCallbacks)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_CALLBACKTYPE* pCallbacks,
+ OMX_IN OMX_PTR pAppData);
+
+ /** ComponentDeInit method is used to deinitialize the component
+ providing a means to free any resources allocated at component
+ initialization. NOTE: After this call the component handle is
+ not valid for further use.
+ @param [in] hComponent
+ Handle of the component to be accessed. This is the component
+ handle returned by the call to the GetHandle function.
+ @return OMX_ERRORTYPE
+ If the command successfully executes, the return code will be
+ OMX_ErrorNone. Otherwise the appropriate OMX error will be returned.
+ */
+ OMX_ERRORTYPE (*ComponentDeInit)(
+ OMX_IN OMX_HANDLETYPE hComponent);
+
+ /** @ingroup buf */
+ OMX_ERRORTYPE (*UseEGLImage)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN void* eglImage);
+
+ OMX_ERRORTYPE (*ComponentRoleEnum)(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_OUT OMX_U8 *cRole,
+ OMX_IN OMX_U32 nIndex);
+
+} OMX_COMPONENTTYPE;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* File EOF */
diff --git a/include/khronos/OMX_ContentPipe.h b/include/khronos/OMX_ContentPipe.h
new file mode 100644
index 0000000..843cb7a
--- /dev/null
+++ b/include/khronos/OMX_ContentPipe.h
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_ContentPipe.h - OpenMax IL version 1.1.2
+ * The OMX_ContentPipe header file contains the definitions used to define
+ * the public interface for content piples. This header file is intended to
+ * be used by the component.
+ */
+
+#ifndef OMX_CONTENTPIPE_H
+#define OMX_CONTENTPIPE_H
+
+#ifndef KD_EACCES
+/* OpenKODE error codes. CPResult values may be zero (indicating success
+ or one of the following values) */
+#define KD_EACCES (1)
+#define KD_EADDRINUSE (2)
+#define KD_EAGAIN (5)
+#define KD_EBADF (7)
+#define KD_EBUSY (8)
+#define KD_ECONNREFUSED (9)
+#define KD_ECONNRESET (10)
+#define KD_EDEADLK (11)
+#define KD_EDESTADDRREQ (12)
+#define KD_ERANGE (35)
+#define KD_EEXIST (13)
+#define KD_EFBIG (14)
+#define KD_EHOSTUNREACH (15)
+#define KD_EINVAL (17)
+#define KD_EIO (18)
+#define KD_EISCONN (20)
+#define KD_EISDIR (21)
+#define KD_EMFILE (22)
+#define KD_ENAMETOOLONG (23)
+#define KD_ENOENT (24)
+#define KD_ENOMEM (25)
+#define KD_ENOSPC (26)
+#define KD_ENOSYS (27)
+#define KD_ENOTCONN (28)
+#define KD_EPERM (33)
+#define KD_ETIMEDOUT (36)
+#define KD_EILSEQ (19)
+#endif
+
+/** Map types from OMX standard types only here so interface is as generic as possible. */
+typedef OMX_U32 CPresult;
+typedef char * CPstring;
+typedef void * CPhandle;
+typedef OMX_U32 CPuint;
+typedef OMX_S32 CPint;
+typedef char CPbyte;
+typedef OMX_BOOL CPbool;
+
+/** enumeration of origin types used in the CP_PIPETYPE's Seek function
+ * @ingroup cp
+ */
+typedef enum CP_ORIGINTYPE {
+ CP_OriginBegin,
+ CP_OriginCur,
+ CP_OriginEnd,
+ CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ CP_OriginMax = 0X7FFFFFFF
+} CP_ORIGINTYPE;
+
+/** enumeration of contact access types used in the CP_PIPETYPE's Open function
+ * @ingroup cp
+ */
+typedef enum CP_ACCESSTYPE {
+ CP_AccessRead,
+ CP_AccessWrite,
+ CP_AccessReadWrite ,
+ CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ CP_AccessMax = 0X7FFFFFFF
+} CP_ACCESSTYPE;
+
+/** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function
+ * @ingroup cp
+ */
+typedef enum CP_CHECKBYTESRESULTTYPE {
+ CP_CheckBytesOk, /**< There are at least the request number
+ of bytes available */
+ CP_CheckBytesNotReady, /**< The pipe is still retrieving bytes
+ and presently lacks sufficient bytes.
+ Client will be called when they are
+ sufficient bytes are available. */
+ CP_CheckBytesInsufficientBytes , /**< The pipe has retrieved all bytes
+ but those available are less than those
+ requested */
+ CP_CheckBytesAtEndOfStream, /**< The pipe has reached the end of stream
+ and no more bytes are available. */
+ CP_CheckBytesOutOfBuffers, /**< All read/write buffers are currently in use. */
+ CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ CP_CheckBytesMax = 0X7FFFFFFF
+} CP_CHECKBYTESRESULTTYPE;
+
+/** enumeration of content pipe events sent to the client callback.
+ * @ingroup cp
+ */
+typedef enum CP_EVENTTYPE {
+ CP_BytesAvailable, /** bytes requested in a CheckAvailableBytes call are now available*/
+ CP_Overflow, /** enumeration of content pipe events sent to the client callback*/
+ CP_PipeDisconnected , /** enumeration of content pipe events sent to the client callback*/
+ CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ CP_EventMax = 0X7FFFFFFF
+} CP_EVENTTYPE;
+
+/** content pipe definition
+ * @ingroup cp
+ */
+typedef struct CP_PIPETYPE {
+ /** Open a content stream for reading or writing. */
+ CPresult (*Open)( CPhandle* hContent, CPstring szURI, CP_ACCESSTYPE eAccess );
+
+ /** Close a content stream. */
+ CPresult (*Close)( CPhandle hContent );
+
+ /** Create a content source and open it for writing. */
+ CPresult (*Create)( CPhandle *hContent, CPstring szURI );
+
+ /** Check the that specified number of bytes are available for reading or writing (depending on access type).*/
+ CPresult (*CheckAvailableBytes)( CPhandle hContent, CPuint nBytesRequested, CP_CHECKBYTESRESULTTYPE *eResult );
+
+ /** Seek to certain position in the content relative to the specified origin. */
+ CPresult (*SetPosition)( CPhandle hContent, CPint nOffset, CP_ORIGINTYPE eOrigin);
+
+ /** Retrieve the current position relative to the start of the content. */
+ CPresult (*GetPosition)( CPhandle hContent, CPuint *pPosition);
+
+ /** Retrieve data of the specified size from the content stream (advance content pointer by size of data).
+ Note: pipe client provides pointer. This function is appropriate for small high frequency reads. */
+ CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize);
+
+ /** Retrieve a buffer allocated by the pipe that contains the requested number of bytes.
+ Buffer contains the next block of bytes, as specified by nSize, of the content. nSize also
+ returns the size of the block actually read. Content pointer advances the by the returned size.
+ Note: pipe provides pointer. This function is appropriate for large reads. The client must call
+ ReleaseReadBuffer when done with buffer.
+
+ In some cases the requested block may not reside in contiguous memory within the
+ pipe implementation. For instance if the pipe leverages a circular buffer then the requested
+ block may straddle the boundary of the circular buffer. By default a pipe implementation
+ performs a copy in this case to provide the block to the pipe client in one contiguous buffer.
+ If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory
+ boundary. Here the client may retrieve the data in segments over successive calls. */
+ CPresult (*ReadBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint *nSize, CPbool bForbidCopy);
+
+ /** Release a buffer obtained by ReadBuffer back to the pipe. */
+ CPresult (*ReleaseReadBuffer)(CPhandle hContent, CPbyte *pBuffer);
+
+ /** Write data of the specified size to the content (advance content pointer by size of data).
+ Note: pipe client provides pointer. This function is appropriate for small high frequency writes. */
+ CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize);
+
+ /** Retrieve a buffer allocated by the pipe used to write data to the content.
+ Client will fill buffer with output data. Note: pipe provides pointer. This function is appropriate
+ for large writes. The client must call WriteBuffer when done it has filled the buffer with data.*/
+ CPresult (*GetWriteBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint nSize);
+
+ /** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the
+ the contents of the buffer to content and advance content pointer by the size of the buffer */
+ CPresult (*WriteBuffer)( CPhandle hContent, CPbyte *pBuffer, CPuint nFilledSize);
+
+ /** Register a per-handle client callback with the content pipe. */
+ CPresult (*RegisterCallback)( CPhandle hContent, CPresult (*ClientCallback)(CP_EVENTTYPE eEvent, CPuint iParam));
+
+} CP_PIPETYPE;
+
+#endif
+
diff --git a/include/khronos/OMX_Core.h b/include/khronos/OMX_Core.h
new file mode 100644
index 0000000..c8f3c4b
--- /dev/null
+++ b/include/khronos/OMX_Core.h
@@ -0,0 +1,1422 @@
+/*
+ * Copyright (c) 2008 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_Core.h - OpenMax IL version 1.1.2
+ * The OMX_Core header file contains the definitions used by both the
+ * application and the component to access common items.
+ */
+
+#ifndef OMX_Core_h
+#define OMX_Core_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Each OMX header shall include all required header files to allow the
+ * header to compile without errors. The includes below are required
+ * for this header file to compile successfully
+ */
+
+#include <OMX_Index.h>
+
+
+/** The OMX_COMMANDTYPE enumeration is used to specify the action in the
+ * OMX_SendCommand macro.
+ * @ingroup core
+ */
+typedef enum OMX_COMMANDTYPE
+{
+ OMX_CommandStateSet, /**< Change the component state */
+ OMX_CommandFlush, /**< Flush the data queue(s) of a component */
+ OMX_CommandPortDisable, /**< Disable a port on a component. */
+ OMX_CommandPortEnable, /**< Enable a port on a component. */
+ OMX_CommandMarkBuffer, /**< Mark a component/buffer for observation */
+ OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_CommandMax = 0X7FFFFFFF
+} OMX_COMMANDTYPE;
+
+
+
+/** The OMX_STATETYPE enumeration is used to indicate or change the component
+ * state. This enumeration reflects the current state of the component when
+ * used with the OMX_GetState macro or becomes the parameter in a state change
+ * command when used with the OMX_SendCommand macro.
+ *
+ * The component will be in the Loaded state after the component is initially
+ * loaded into memory. In the Loaded state, the component is not allowed to
+ * allocate or hold resources other than to build it's internal parameter
+ * and configuration tables. The application will send one or more
+ * SetParameters/GetParameters and SetConfig/GetConfig commands to the
+ * component and the component will record each of these parameter and
+ * configuration changes for use later. When the application sends the
+ * Idle command, the component will acquire the resources needed for the
+ * specified configuration and will transition to the idle state if the
+ * allocation is successful. If the component cannot successfully
+ * transition to the idle state for any reason, the state of the component
+ * shall be fully rolled back to the Loaded state (e.g. all allocated
+ * resources shall be released). When the component receives the command
+ * to go to the Executing state, it shall begin processing buffers by
+ * sending all input buffers it holds to the application. While
+ * the component is in the Idle state, the application may also send the
+ * Pause command. If the component receives the pause command while in the
+ * Idle state, the component shall send all input buffers it holds to the
+ * application, but shall not begin processing buffers. This will allow the
+ * application to prefill buffers.
+ *
+ * @ingroup comp
+ */
+
+typedef enum OMX_STATETYPE {
+ OMX_StateInvalid, /**< component has detected that it's internal data
+ structures are corrupted to the point that
+ it cannot determine it's state properly */
+ OMX_StateLoaded, /**< component has been loaded but has not completed
+ initialization. The OMX_SetParameter macro
+ and the OMX_GetParameter macro are the only
+ valid macros allowed to be sent to the
+ component in this state. */
+ OMX_StateIdle, /**< component initialization has been completed
+ successfully and the component is ready to
+ to start. */
+ OMX_StateExecuting, /**< component has accepted the start command and
+ is processing data (if data is available) */
+ OMX_StatePause, /**< component has received pause command */
+ OMX_StateWaitForResources, /**< component is waiting for resources, either after
+ preemption or before it gets the resources requested.
+ See specification for complete details. */
+ OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_StateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_StateMax = 0X7FFFFFFF
+} OMX_STATETYPE;
+
+/** The OMX_ERRORTYPE enumeration defines the standard OMX Errors. These
+ * errors should cover most of the common failure cases. However,
+ * vendors are free to add additional error messages of their own as
+ * long as they follow these rules:
+ * 1. Vendor error messages shall be in the range of 0x90000000 to
+ * 0x9000FFFF.
+ * 2. Vendor error messages shall be defined in a header file provided
+ * with the component. No error messages are allowed that are
+ * not defined.
+ */
+typedef enum OMX_ERRORTYPE {
+ OMX_ErrorNone = 0,
+
+ /** There were insufficient resources to perform the requested operation */
+ OMX_ErrorInsufficientResources = (OMX_S32) 0x80001000,
+
+ /** There was an error, but the cause of the error could not be determined */
+ OMX_ErrorUndefined = (OMX_S32) 0x80001001,
+
+ /** The component name string was not valid */
+ OMX_ErrorInvalidComponentName = (OMX_S32) 0x80001002,
+
+ /** No component with the specified name string was found */
+ OMX_ErrorComponentNotFound = (OMX_S32) 0x80001003,
+
+ /** The component specified did not have a "OMX_ComponentInit" or
+ "OMX_ComponentDeInit entry point */
+ OMX_ErrorInvalidComponent = (OMX_S32) 0x80001004,
+
+ /** One or more parameters were not valid */
+ OMX_ErrorBadParameter = (OMX_S32) 0x80001005,
+
+ /** The requested function is not implemented */
+ OMX_ErrorNotImplemented = (OMX_S32) 0x80001006,
+
+ /** The buffer was emptied before the next buffer was ready */
+ OMX_ErrorUnderflow = (OMX_S32) 0x80001007,
+
+ /** The buffer was not available when it was needed */
+ OMX_ErrorOverflow = (OMX_S32) 0x80001008,
+
+ /** The hardware failed to respond as expected */
+ OMX_ErrorHardware = (OMX_S32) 0x80001009,
+
+ /** The component is in the state OMX_StateInvalid */
+ OMX_ErrorInvalidState = (OMX_S32) 0x8000100A,
+
+ /** Stream is found to be corrupt */
+ OMX_ErrorStreamCorrupt = (OMX_S32) 0x8000100B,
+
+ /** Ports being connected are not compatible */
+ OMX_ErrorPortsNotCompatible = (OMX_S32) 0x8000100C,
+
+ /** Resources allocated to an idle component have been
+ lost resulting in the component returning to the loaded state */
+ OMX_ErrorResourcesLost = (OMX_S32) 0x8000100D,
+
+ /** No more indicies can be enumerated */
+ OMX_ErrorNoMore = (OMX_S32) 0x8000100E,
+
+ /** The component detected a version mismatch */
+ OMX_ErrorVersionMismatch = (OMX_S32) 0x8000100F,
+
+ /** The component is not ready to return data at this time */
+ OMX_ErrorNotReady = (OMX_S32) 0x80001010,
+
+ /** There was a timeout that occurred */
+ OMX_ErrorTimeout = (OMX_S32) 0x80001011,
+
+ /** This error occurs when trying to transition into the state you are already in */
+ OMX_ErrorSameState = (OMX_S32) 0x80001012,
+
+ /** Resources allocated to an executing or paused component have been
+ preempted, causing the component to return to the idle state */
+ OMX_ErrorResourcesPreempted = (OMX_S32) 0x80001013,
+
+ /** A non-supplier port sends this error to the IL client (via the EventHandler callback)
+ during the allocation of buffers (on a transition from the LOADED to the IDLE state or
+ on a port restart) when it deems that it has waited an unusually long time for the supplier
+ to send it an allocated buffer via a UseBuffer call. */
+ OMX_ErrorPortUnresponsiveDuringAllocation = (OMX_S32) 0x80001014,
+
+ /** A non-supplier port sends this error to the IL client (via the EventHandler callback)
+ during the deallocation of buffers (on a transition from the IDLE to LOADED state or
+ on a port stop) when it deems that it has waited an unusually long time for the supplier
+ to request the deallocation of a buffer header via a FreeBuffer call. */
+ OMX_ErrorPortUnresponsiveDuringDeallocation = (OMX_S32) 0x80001015,
+
+ /** A supplier port sends this error to the IL client (via the EventHandler callback)
+ during the stopping of a port (either on a transition from the IDLE to LOADED
+ state or a port stop) when it deems that it has waited an unusually long time for
+ the non-supplier to return a buffer via an EmptyThisBuffer or FillThisBuffer call. */
+ OMX_ErrorPortUnresponsiveDuringStop = (OMX_S32) 0x80001016,
+
+ /** Attempting a state transtion that is not allowed */
+ OMX_ErrorIncorrectStateTransition = (OMX_S32) 0x80001017,
+
+ /* Attempting a command that is not allowed during the present state. */
+ OMX_ErrorIncorrectStateOperation = (OMX_S32) 0x80001018,
+
+ /** The values encapsulated in the parameter or config structure are not supported. */
+ OMX_ErrorUnsupportedSetting = (OMX_S32) 0x80001019,
+
+ /** The parameter or config indicated by the given index is not supported. */
+ OMX_ErrorUnsupportedIndex = (OMX_S32) 0x8000101A,
+
+ /** The port index supplied is incorrect. */
+ OMX_ErrorBadPortIndex = (OMX_S32) 0x8000101B,
+
+ /** The port has lost one or more of its buffers and it thus unpopulated. */
+ OMX_ErrorPortUnpopulated = (OMX_S32) 0x8000101C,
+
+ /** Component suspended due to temporary loss of resources */
+ OMX_ErrorComponentSuspended = (OMX_S32) 0x8000101D,
+
+ /** Component suspended due to an inability to acquire dynamic resources */
+ OMX_ErrorDynamicResourcesUnavailable = (OMX_S32) 0x8000101E,
+
+ /** When the macroblock error reporting is enabled the component returns new error
+ for every frame that has errors */
+ OMX_ErrorMbErrorsInFrame = (OMX_S32) 0x8000101F,
+
+ /** A component reports this error when it cannot parse or determine the format of an input stream. */
+ OMX_ErrorFormatNotDetected = (OMX_S32) 0x80001020,
+
+ /** The content open operation failed. */
+ OMX_ErrorContentPipeOpenFailed = (OMX_S32) 0x80001021,
+
+ /** The content creation operation failed. */
+ OMX_ErrorContentPipeCreationFailed = (OMX_S32) 0x80001022,
+
+ /** Separate table information is being used */
+ OMX_ErrorSeperateTablesUsed = (OMX_S32) 0x80001023,
+
+ /** Tunneling is unsupported by the component*/
+ OMX_ErrorTunnelingUnsupported = (OMX_S32) 0x80001024,
+
+ OMX_ErrorKhronosExtensions = (OMX_S32)0x8F000000, /**< Reserved region for introducing Khronos Standard Extensions */
+ OMX_ErrorVendorStartUnused = (OMX_S32)0x90000000, /**< Reserved region for introducing Vendor Extensions */
+ OMX_ErrorMax = 0x7FFFFFFF
+} OMX_ERRORTYPE;
+
+/** @ingroup core */
+typedef OMX_ERRORTYPE (* OMX_COMPONENTINITTYPE)(OMX_IN OMX_HANDLETYPE hComponent);
+
+/** @ingroup core */
+typedef struct OMX_COMPONENTREGISTERTYPE {
+ const char * pName; /* Component name, 128 byte limit (including '\0') applies */
+ OMX_COMPONENTINITTYPE pInitialize; /* Component instance initialization function */
+} OMX_COMPONENTREGISTERTYPE;
+
+/** @ingroup core */
+extern OMX_COMPONENTREGISTERTYPE OMX_ComponentRegistered[];
+
+/** @ingroup rpm */
+typedef struct OMX_PRIORITYMGMTTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U32 nGroupPriority; /**< Priority of the component group */
+ OMX_U32 nGroupID; /**< ID of the component group */
+} OMX_PRIORITYMGMTTYPE;
+
+/* Component name and Role names are limited to 128 characters including the terminating '\0'. */
+#define OMX_MAX_STRINGNAME_SIZE 128
+
+/** @ingroup comp */
+typedef struct OMX_PARAM_COMPONENTROLETYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE]; /**< name of standard component which defines component role */
+} OMX_PARAM_COMPONENTROLETYPE;
+
+/** End of Stream Buffer Flag:
+ *
+ * A component sets EOS when it has no more data to emit on a particular
+ * output port. Thus an output port shall set EOS on the last buffer it
+ * emits. A component's determination of when an output port should
+ * cease sending data is implemenation specific.
+ * @ingroup buf
+ */
+
+#define OMX_BUFFERFLAG_EOS 0x00000001
+
+/** Start Time Buffer Flag:
+ *
+ * The source of a stream (e.g. a demux component) sets the STARTTIME
+ * flag on the buffer that contains the starting timestamp for the
+ * stream. The starting timestamp corresponds to the first data that
+ * should be displayed at startup or after a seek.
+ * The first timestamp of the stream is not necessarily the start time.
+ * For instance, in the case of a seek to a particular video frame,
+ * the target frame may be an interframe. Thus the first buffer of
+ * the stream will be the intra-frame preceding the target frame and
+ * the starttime will occur with the target frame (with any other
+ * required frames required to reconstruct the target intervening).
+ *
+ * The STARTTIME flag is directly associated with the buffer's
+ * timestamp ' thus its association to buffer data and its
+ * propagation is identical to the timestamp's.
+ *
+ * When a Sync Component client receives a buffer with the
+ * STARTTIME flag it shall perform a SetConfig on its sync port
+ * using OMX_ConfigTimeClientStartTime and passing the buffer's
+ * timestamp.
+ *
+ * @ingroup buf
+ */
+
+#define OMX_BUFFERFLAG_STARTTIME 0x00000002
+
+
+
+/** Decode Only Buffer Flag:
+ *
+ * The source of a stream (e.g. a demux component) sets the DECODEONLY
+ * flag on any buffer that should shall be decoded but should not be
+ * displayed. This flag is used, for instance, when a source seeks to
+ * a target interframe that requires the decode of frames preceding the
+ * target to facilitate the target's reconstruction. In this case the
+ * source would emit the frames preceding the target downstream
+ * but mark them as decode only.
+ *
+ * The DECODEONLY is associated with buffer data and propagated in a
+ * manner identical to the buffer timestamp.
+ *
+ * A component that renders data should ignore all buffers with
+ * the DECODEONLY flag set.
+ *
+ * @ingroup buf
+ */
+
+#define OMX_BUFFERFLAG_DECODEONLY 0x00000004
+
+
+/* Data Corrupt Flag: This flag is set when the IL client believes the data in the associated buffer is corrupt
+ * @ingroup buf
+ */
+
+#define OMX_BUFFERFLAG_DATACORRUPT 0x00000008
+
+/* End of Frame: The buffer contains exactly one end of frame and no data
+ * occurs after the end of frame. This flag is an optional hint. The absence
+ * of this flag does not imply the absence of an end of frame within the buffer.
+ * @ingroup buf
+*/
+#define OMX_BUFFERFLAG_ENDOFFRAME 0x00000010
+
+/* Sync Frame Flag: This flag is set when the buffer content contains a coded sync frame '
+ * a frame that has no dependency on any other frame information
+ * @ingroup buf
+ */
+#define OMX_BUFFERFLAG_SYNCFRAME 0x00000020
+
+/* Extra data present flag: there is extra data appended to the data stream
+ * residing in the buffer
+ * @ingroup buf
+ */
+#define OMX_BUFFERFLAG_EXTRADATA 0x00000040
+
+/** Codec Config Buffer Flag:
+* OMX_BUFFERFLAG_CODECCONFIG is an optional flag that is set by an
+* output port when all bytes in the buffer form part or all of a set of
+* codec specific configuration data. Examples include SPS/PPS nal units
+* for OMX_VIDEO_CodingAVC or AudioSpecificConfig data for
+* OMX_AUDIO_CodingAAC. Any component that for a given stream sets
+* OMX_BUFFERFLAG_CODECCONFIG shall not mix codec configuration bytes
+* with frame data in the same buffer, and shall send all buffers
+* containing codec configuration bytes before any buffers containing
+* frame data that those configurations bytes describe.
+* If the stream format for a particular codec has a frame specific
+* header at the start of each frame, for example OMX_AUDIO_CodingMP3 or
+* OMX_AUDIO_CodingAAC in ADTS mode, then these shall be presented as
+* normal without setting OMX_BUFFERFLAG_CODECCONFIG.
+ * @ingroup buf
+ */
+#define OMX_BUFFERFLAG_CODECCONFIG 0x00000080
+
+
+
+/** @ingroup buf */
+typedef struct OMX_BUFFERHEADERTYPE {
+ OMX_U32 nSize; /**< size of the structure in bytes */
+ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
+ OMX_U8* pBuffer; /**< Pointer to actual block of memory
+ that is acting as the buffer */
+ OMX_U32 nAllocLen; /**< size of the buffer allocated, in bytes */
+ OMX_U32 nFilledLen; /**< number of bytes currently in the
+ buffer */
+ OMX_U32 nOffset; /**< start offset of valid data in bytes from
+ the start of the buffer */
+ OMX_PTR pAppPrivate; /**< pointer to any data the application
+ wants to associate with this buffer */
+ OMX_PTR pPlatformPrivate; /**< pointer to any data the platform
+ wants to associate with this buffer */
+ OMX_PTR pInputPortPrivate; /**< pointer to any data the input port
+ wants to associate with this buffer */
+ OMX_PTR pOutputPortPrivate; /**< pointer to any data the output port
+ wants to associate with this buffer */
+ OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will generate a
+ mark event upon processing this buffer. */
+ OMX_PTR pMarkData; /**< Application specific data associated with
+ the mark sent on a mark event to disambiguate
+ this mark from others. */
+ OMX_U32 nTickCount; /**< Optional entry that the component and
+ application can update with a tick count
+ when they access the component. This
+ value should be in microseconds. Since
+ this is a value relative to an arbitrary
+ starting point, this value cannot be used
+ to determine absolute time. This is an
+ optional entry and not all components
+ will update it.*/
+ OMX_TICKS nTimeStamp; /**< Timestamp corresponding to the sample
+ starting at the first logical sample
+ boundary in the buffer. Timestamps of
+ successive samples within the buffer may
+ be inferred by adding the duration of the
+ of the preceding buffer to the timestamp
+ of the preceding buffer.*/
+ OMX_U32 nFlags; /**< buffer specific flags */
+ OMX_U32 nOutputPortIndex; /**< The index of the output port (if any) using
+ this buffer */
+ OMX_U32 nInputPortIndex; /**< The index of the input port (if any) using
+ this buffer */
+} OMX_BUFFERHEADERTYPE;
+
+/** The OMX_EXTRADATATYPE enumeration is used to define the
+ * possible extra data payload types.
+ * NB: this enum is binary backwards compatible with the previous
+ * OMX_EXTRADATA_QUANT define. This should be replaced with
+ * OMX_ExtraDataQuantization.
+ */
+typedef enum OMX_EXTRADATATYPE {
+ OMX_ExtraDataNone = 0, /**< Indicates that no more extra data sections follow */
+ OMX_ExtraDataQuantization, /**< The data payload contains quantization data */
+ OMX_ExtraDataKh