summaryrefslogtreecommitdiffstats
path: root/domx/omx_proxy_component/omx_video_dec
diff options
context:
space:
mode:
authorZiyann <jaraidaniel@gmail.com>2014-11-24 21:31:16 +0100
committerZiyan <jaraidaniel@gmail.com>2014-12-13 00:39:22 +0100
commit46658da7a37c43075b66575e639872b5ecce3155 (patch)
tree14430b68b4e2f21ceeeef6a75cbf0e342fc86c55 /domx/omx_proxy_component/omx_video_dec
parentd744be2e69d3891fd9c9a83aafa857c590417e48 (diff)
downloaddevice_samsung_tuna-46658da7a37c43075b66575e639872b5ecce3155.zip
device_samsung_tuna-46658da7a37c43075b66575e639872b5ecce3155.tar.gz
device_samsung_tuna-46658da7a37c43075b66575e639872b5ecce3155.tar.bz2
tuna: add open-source domx/camera stuff
Camera is still half-broken. Credits to @MWisBest Change-Id: I87a802abfacaf36ab22676f5284f0cc1996f6b03
Diffstat (limited to 'domx/omx_proxy_component/omx_video_dec')
-rwxr-xr-xdomx/omx_proxy_component/omx_video_dec/Makefile103
-rwxr-xr-xdomx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c797
-rw-r--r--domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c157
-rwxr-xr-xdomx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c318
4 files changed, 1375 insertions, 0 deletions
diff --git a/domx/omx_proxy_component/omx_video_dec/Makefile b/domx/omx_proxy_component/omx_video_dec/Makefile
new file mode 100755
index 0000000..cbe5c56
--- /dev/null
+++ b/domx/omx_proxy_component/omx_video_dec/Makefile
@@ -0,0 +1,103 @@
+#
+# Copyright (C) Texas Instruments - http://www.ti.com/
+#
+# 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.
+#
+# ----------------------------------------------------------------------------
+# Revision History
+#
+#
+# REF=ORG
+# Original version.
+# ----------------------------------------------------------------------------
+
+
+
+include $(PROJROOT)/make/start.mk
+
+# Do not change above "include" line(s)
+
+# Arguments to tools, will move to make system once finalized.
+
+CFLAGS =
+CDEFS =
+ifeq ($(BUILD),udeb)
+CDEFS += DEBUG
+endif
+CDEFS +=
+
+EXEC_ARGS =
+ST_LIB_ARGS =
+SH_LIB_ARGS =
+
+# Define this macro if target runs in kernel mode
+#__KERNEL__ = 1
+
+# Target name and extension
+# static library (ST_LIB): filename.a
+# shared library soname (SH_LIB): filename.so.maj_ver.min_ver
+# executable (EXEC) : filename.out
+
+TARGETNAME = libOMX.TI.DUCATI1.VIDEO.DECODER.so
+
+
+# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case.
+
+TARGETTYPE = SH_LIB
+
+# install directory relative to the HOSTTARGET directory
+HOSTRELEASE = lib
+
+# install directory relative to the root filesystem
+ROOTFSRELEASE = lib
+
+# Folders in which gmake will run before building current target
+
+SUBMODULES = \
+
+# Filename must not begin with '.', '/' or '\'
+
+SOURCES = \
+src/omx_proxy_videodec.c \
+
+
+
+# Search path for include files
+
+INCLUDES = \
+ $(PROJROOT)/omx_core/inc \
+ $(PROJROOT)/mm_osal/inc \
+ $(PROJROOT)/domx \
+ $(PROJROOT)/domx/omx_rpc/inc \
+
+
+# Libraries needed for linking.
+
+ST_LIBS =
+#mm_osal domx
+SH_LIBS = domx omx_core mm_osal
+#pthread rt utils procmgr ipc rcm notify
+#SH_LIBS += sysmgr sysmemmgr
+
+
+# Search path for library (and linker command) files.
+# Current folder and target folder are included by default.
+
+LIBINCLUDES = $(PROJROOT)/mm_osal \
+ $(PROJROOT)/domx \
+ $(PROJROOT)/omx_core
+
+
+# Do not change below "include" line(s)
+
+include $(PROJROOT)/make/build.mk
diff --git a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c
new file mode 100755
index 0000000..8ac4c9d
--- /dev/null
+++ b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c
@@ -0,0 +1,797 @@
+/*
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file omx_proxy_videodecoder.c
+ * This file contains methods that provides the functionality for
+ * the OpenMAX1.1 DOMX Framework Tunnel Proxy component.
+ *********************************************************************************************
+ This is the proxy specific wrapper that passes the component name to the generic proxy init()
+ The proxy wrapper also does some runtime/static time onfig on per proxy basis
+ This is a thin wrapper that is called when componentiit() of the proxy is called
+ static OMX_ERRORTYPE PROXY_Wrapper_init(OMX_HANDLETYPE hComponent, OMX_PTR pAppData);
+ this layer gets called first whenever a proxy's get handle is called
+ ************************************************************************************************
+ * @path WTSD_DucatiMMSW\omx\omx_il_1_x\omx_proxy_component\src
+ *
+ * @rev 1.0
+ */
+
+/*==============================================================
+ *! Revision History
+ *! ============================
+ *! 20-August-2010 Sarthak Aggarwal sarthak@ti.com: Initial Version
+ *================================================================*/
+
+/******************************************************************
+ * INCLUDE FILES
+ ******************************************************************/
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include "omx_proxy_common.h"
+#include <timm_osal_interfaces.h>
+#include "OMX_TI_IVCommon.h"
+#include "OMX_TI_Video.h"
+#include "OMX_TI_Index.h"
+
+#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY
+#define LOG_TAG "OMXPROXYVIDEODEC"
+#include <fcntl.h>
+#include <cutils/properties.h>
+#include <utils/Log.h>
+#endif
+
+#define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER"
+/* needs to be specific for every configuration wrapper */
+
+#ifdef USE_ENHANCED_PORTRECONFIG
+//Define port indices in video decoder proxy
+#define OMX_VIDEODECODER_INPUT_PORT 0
+#define OMX_VIDEODECODER_OUTPUT_PORT 1
+#endif
+
+#ifdef SET_STRIDE_PADDING_FROM_PROXY
+
+#define LINUX_PAGE_SIZE (4 * 1024)
+#define TOTAL_DEC_PORTS 2
+#define HAL_NV12_PADDED_PIXEL_FORMAT (OMX_TI_COLOR_FormatYUV420PackedSemiPlanar - OMX_COLOR_FormatVendorStartUnused)
+
+static OMX_ERRORTYPE RPC_UTIL_SetStrideAndPadding(OMX_COMPONENTTYPE * hRemoteComp, PROXY_COMPONENT_PRIVATE * pCompPrv);
+
+OMX_ERRORTYPE PROXY_VIDDEC_SendCommand(OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_COMMANDTYPE eCmd,
+ OMX_IN OMX_U32 nParam, OMX_IN OMX_PTR pCmdData);
+
+OMX_ERRORTYPE PROXY_VIDDEC_EventHandler(OMX_HANDLETYPE hComponent,
+ OMX_PTR pAppData, OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2,
+ OMX_PTR pEventData);
+
+#endif //SET_STRIDE_PADDING_FROM_PROXY
+
+OMX_ERRORTYPE PROXY_VIDDEC_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE * pIndexType);
+
+#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES
+
+OMX_ERRORTYPE PROXY_VIDDEC_GetParameter(OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct);
+
+OMX_ERRORTYPE PROXY_VIDDEC_SetParameter(OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct);
+
+#endif
+
+#ifdef ANDROID_QUIRK_LOCK_BUFFER
+#include <hardware/gralloc.h>
+#include <hardware/hardware.h>
+#include "hal_public.h"
+
+OMX_ERRORTYPE PROXY_VIDDEC_FillThisBuffer(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE * pBufferHdr);
+OMX_ERRORTYPE PROXY_VIDDEC_FillBufferDone(OMX_HANDLETYPE hComponent,
+ OMX_U32 remoteBufHdr, OMX_U32 nfilledLen, OMX_U32 nOffset, OMX_U32 nFlags,
+ OMX_TICKS nTimeStamp, OMX_HANDLETYPE hMarkTargetComponent,
+ OMX_PTR pMarkData);
+
+#endif
+extern OMX_ERRORTYPE PrearrageEmptyThisBuffer(OMX_HANDLETYPE hComponent,
+ OMX_BUFFERHEADERTYPE * pBufferHdr);
+
+#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY
+extern void DumpVideoFrame(DebugFrame_Dump *frameInfo);
+#endif
+
+OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent);
+
+OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL;
+ pHandle = (OMX_COMPONENTTYPE *) hComponent;
+
+ DOMX_ENTER("");
+
+ DOMX_DEBUG("Component name provided is %s", COMPONENT_NAME);
+
+ pHandle->pComponentPrivate =
+ (PROXY_COMPONENT_PRIVATE *)
+ TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE,
+ 0, TIMMOSAL_MEM_SEGMENT_INT);
+
+ PROXY_assert(pHandle->pComponentPrivate != NULL,
+ OMX_ErrorInsufficientResources,
+ "ERROR IN ALLOCATING PROXY COMPONENT PRIVATE STRUCTURE");
+
+ pComponentPrivate =
+ (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate;
+
+ TIMM_OSAL_Memset(pComponentPrivate, 0,
+ sizeof(PROXY_COMPONENT_PRIVATE));
+
+ pComponentPrivate->cCompName =
+ TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8),
+ TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT);
+
+ PROXY_assert(pComponentPrivate->cCompName != NULL,
+ OMX_ErrorInsufficientResources,
+ " Error in Allocating space for proxy component table");
+
+ eError = OMX_ProxyViddecInit(hComponent);
+
+#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY
+ if (eError == OMX_ErrorNone)
+ {
+ char value[PROPERTY_VALUE_MAX];
+ property_get("debug.video.dumpframe", value, "0:0");
+ /* -ve value for fromFrame would disable this automatically */
+ pComponentPrivate->debugframeInfo.fromFrame = atoi(strtok(value, ":"));
+ pComponentPrivate->debugframeInfo.toFrame = atoi(strtok(NULL, ":"));
+ pComponentPrivate->debugframeInfo.runningFrame = pComponentPrivate->debugframeInfo.fromFrame;
+ }
+#endif
+ EXIT:
+ if (eError != OMX_ErrorNone)
+ {
+ DOMX_DEBUG("Error in Initializing Proxy");
+ if (pComponentPrivate->cCompName != NULL)
+ {
+ TIMM_OSAL_Free(pComponentPrivate->cCompName);
+ pComponentPrivate->cCompName = NULL;
+ }
+ if (pComponentPrivate != NULL)
+ {
+ TIMM_OSAL_Free(pComponentPrivate);
+ pComponentPrivate = NULL;
+ }
+ }
+ return eError;
+}
+
+OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL;
+ pHandle = (OMX_COMPONENTTYPE *) hComponent;
+ OMX_TI_PARAM_ENHANCEDPORTRECONFIG tParamStruct;
+
+#ifdef ANDROID_QUIRK_LOCK_BUFFER
+ OMX_U32 err;
+ hw_module_t const* module;
+#endif
+ DOMX_ENTER("");
+
+ DOMX_DEBUG("Component name provided is %s", COMPONENT_NAME);
+
+ pComponentPrivate =
+ (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate;
+
+ // Copying component Name - this will be picked up in the proxy common
+ PROXY_assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH,
+ OMX_ErrorInvalidComponentName,
+ "Length of component name is longer than the max allowed");
+ TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME,
+ strlen(COMPONENT_NAME) + 1);
+
+ eError = OMX_ProxyCommonInit(hComponent); // Calling Proxy Common Init()
+ PROXY_assert(eError == OMX_ErrorNone, eError, "Proxy common init returned error");
+#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES
+ pHandle->SetParameter = PROXY_VIDDEC_SetParameter;
+ pHandle->GetParameter = PROXY_VIDDEC_GetParameter;
+#endif
+ pHandle->GetExtensionIndex = PROXY_VIDDEC_GetExtensionIndex;
+
+#ifdef SET_STRIDE_PADDING_FROM_PROXY
+ pHandle->SendCommand = PROXY_VIDDEC_SendCommand;
+ pComponentPrivate->proxyEventHandler = PROXY_VIDDEC_EventHandler;
+ pComponentPrivate->IsLoadedState = OMX_TRUE;
+#endif
+
+#ifdef ANDROID_QUIRK_LOCK_BUFFER
+ pComponentPrivate->proxyFillBufferDone = PROXY_VIDDEC_FillBufferDone;
+ pHandle->FillThisBuffer = PROXY_VIDDEC_FillThisBuffer;
+
+ err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
+ if (err == 0)
+ {
+ pComponentPrivate->grallocModule = (gralloc_module_t const *)module;
+ }
+ else
+ {
+ DOMX_ERROR("FATAL: gralloc api hw_get_module() returned error: Can't find \
+ %s module err = %x", GRALLOC_HARDWARE_MODULE_ID, err);
+ eError = OMX_ErrorInsufficientResources;
+ return eError;
+ }
+#endif
+
+#ifdef USE_ENHANCED_PORTRECONFIG
+ /*Initializing Structure */
+ tParamStruct.nSize = sizeof(OMX_TI_PARAM_ENHANCEDPORTRECONFIG);
+ tParamStruct.nVersion.s.nVersionMajor = OMX_VER_MAJOR;
+ tParamStruct.nVersion.s.nVersionMinor = OMX_VER_MINOR;
+ tParamStruct.nVersion.s.nRevision = 0x0;
+ tParamStruct.nVersion.s.nStep = 0x0;
+ tParamStruct.nPortIndex = OMX_VIDEODECODER_OUTPUT_PORT;
+ tParamStruct.bUsePortReconfigForCrop = OMX_TRUE;
+ tParamStruct.bUsePortReconfigForPadding = OMX_TRUE;
+
+ eError = PROXY_SetParameter(hComponent,(OMX_INDEXTYPE)OMX_TI_IndexParamUseEnhancedPortReconfig,
+ &tParamStruct);
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error in Proxy SetParameter for Enhanced port reconfig usage");
+#endif
+ /* This is required to handle WMV/VC-1 content */
+ pHandle->EmptyThisBuffer = PrearrageEmptyThisBuffer;
+
+ EXIT:
+ return eError;
+}
+
+/* ===========================================================================*/
+/**
+ * @name PROXY_VIDDEC_GetExtensionIndex()
+ * @brief
+ * @param void
+ * @return OMX_ErrorNone = Successful
+ * @sa TBD
+ *
+ */
+/* ===========================================================================*/
+OMX_ERRORTYPE PROXY_VIDDEC_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE * pIndexType)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ PROXY_COMPONENT_PRIVATE *pCompPrv = NULL;
+ OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent;
+
+ PROXY_require((hComp->pComponentPrivate != NULL), OMX_ErrorBadParameter, NULL);
+ PROXY_require(cParameterName != NULL, OMX_ErrorBadParameter, NULL);
+ PROXY_require(pIndexType != NULL, OMX_ErrorBadParameter, NULL);
+
+ DOMX_ENTER("hComponent = %p, cParameterName = %p", hComponent, cParameterName);
+
+#ifdef ENABLE_GRALLOC_BUFFERS
+ // Ensure that String length is not greater than Max allowed length
+ PROXY_require(strlen(cParameterName) <= 127, OMX_ErrorBadParameter, NULL);
+
+ if (strcmp(cParameterName, "OMX.google.android.index.getAndroidNativeBufferUsage") == 0)
+ {
+ *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexAndroidNativeBufferUsage;
+ }
+ else
+ {
+ eError = PROXY_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error in PROXY_GetExtensionIndex");
+ }
+#else
+ eError = PROXY_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error in PROXY_GetExtensionIndex");
+#endif
+ EXIT:
+ DOMX_EXIT("eError: %d", eError);
+ return eError;
+}
+
+#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES
+
+/* ===========================================================================*/
+/**
+ * @name PROXY_GetParameter()
+ * @brief
+ * @param void
+ * @return OMX_ErrorNone = Successful
+ * @sa TBD
+ *
+ */
+/* ===========================================================================*/
+OMX_ERRORTYPE PROXY_VIDDEC_GetParameter(OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ PROXY_COMPONENT_PRIVATE *pCompPrv = NULL;
+ OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent;
+ OMX_PARAM_PORTDEFINITIONTYPE* pPortDef = NULL;
+ OMX_VIDEO_PARAM_PORTFORMATTYPE* pPortParam = NULL;
+ OMX_TI_PARAMNATIVEBUFFERUSAGE *pUsage = NULL;
+
+ PROXY_require((pParamStruct != NULL), OMX_ErrorBadParameter, NULL);
+ PROXY_assert((hComp->pComponentPrivate != NULL),
+ OMX_ErrorBadParameter, NULL);
+
+ pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate;
+
+ DOMX_ENTER
+ ("hComponent = %p, pCompPrv = %p, nParamIndex = %d, pParamStruct = %p",
+ hComponent, pCompPrv, nParamIndex, pParamStruct);
+
+#ifdef ENABLE_GRALLOC_BUFFERS
+ if( nParamIndex == OMX_TI_IndexAndroidNativeBufferUsage)
+ {
+ pUsage = (OMX_TI_PARAMNATIVEBUFFERUSAGE*)pParamStruct;
+ if(pCompPrv->proxyPortBuffers[pUsage->nPortIndex].proxyBufferType == GrallocPointers)
+ {
+ PROXY_CHK_VERSION(pParamStruct, OMX_TI_PARAMNATIVEBUFFERUSAGE);
+ pUsage->nUsage = GRALLOC_USAGE_HW_RENDER;
+#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY
+ pUsage->nUsage |= GRALLOC_USAGE_SW_READ_RARELY;
+#endif
+ goto EXIT;
+ }
+ }
+#endif
+ eError = PROXY_GetParameter(hComponent,nParamIndex, pParamStruct);
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error in Proxy GetParameter");
+
+ if( nParamIndex == OMX_IndexParamPortDefinition)
+ {
+ PROXY_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE);
+ pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct;
+ if(pPortDef->format.video.eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar)
+ {
+ if(pCompPrv->proxyPortBuffers[pPortDef->nPortIndex].proxyBufferType == GrallocPointers)
+ {
+ pPortDef->format.video.eColorFormat = HAL_NV12_PADDED_PIXEL_FORMAT;
+ }
+ else
+ {
+ pPortDef->format.video.eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
+ }
+ }
+ }
+ else if ( nParamIndex == OMX_IndexParamVideoPortFormat)
+ {
+ PROXY_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE);
+ pPortParam = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct;
+ if(pPortParam->eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar)
+ {
+ if(pCompPrv->proxyPortBuffers[pPortParam->nPortIndex].proxyBufferType == GrallocPointers)
+ {
+ pPortParam->eColorFormat = HAL_NV12_PADDED_PIXEL_FORMAT;
+ }
+ else
+ {
+ pPortParam->eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
+ }
+ }
+ }
+
+ EXIT:
+ DOMX_EXIT("eError: %d", eError);
+ return eError;
+}
+
+/* ===========================================================================*/
+/**
+ * @name PROXY_SetParameter()
+ * @brief
+ * @param void
+ * @return OMX_ErrorNone = Successful
+ * @sa TBD
+ *
+ */
+/* ===========================================================================*/
+OMX_ERRORTYPE PROXY_VIDDEC_SetParameter(OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR pParamStruct)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ PROXY_COMPONENT_PRIVATE *pCompPrv = NULL;
+ OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent;
+ OMX_PARAM_PORTDEFINITIONTYPE* pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct;
+ OMX_VIDEO_PARAM_PORTFORMATTYPE* pPortParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct;
+
+ PROXY_require((pParamStruct != NULL), OMX_ErrorBadParameter, NULL);
+ PROXY_require((hComp->pComponentPrivate != NULL),
+ OMX_ErrorBadParameter, NULL);
+
+ pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate;
+ DOMX_ENTER
+ ("hComponent = %p, pCompPrv = %p, nParamIndex = %d, pParamStruct = %p",
+ hComponent, pCompPrv, nParamIndex, pParamStruct);
+ if(nParamIndex == OMX_IndexParamPortDefinition)
+ {
+ if(pPortDef->format.video.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar
+ || pPortDef->format.video.eColorFormat == HAL_NV12_PADDED_PIXEL_FORMAT)
+ {
+ pPortDef->format.video.eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar;
+ }
+ }
+ else if(nParamIndex == OMX_IndexParamVideoPortFormat)
+ {
+ if(pPortParams->eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar
+ || pPortParams->eColorFormat == HAL_NV12_PADDED_PIXEL_FORMAT)
+ {
+ pPortParams->eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar;
+ }
+ }
+
+ eError = PROXY_SetParameter(hComponent, nParamIndex, pParamStruct);
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error in Proxy SetParameter");
+
+ EXIT:
+ DOMX_EXIT("eError: %d", eError);
+ return eError;
+}
+
+#endif
+
+#ifdef SET_STRIDE_PADDING_FROM_PROXY
+/* ===========================================================================*/
+/**
+ * @name PROXY_VIDDEC_SendCommand()
+ * @brief
+ * @return OMX_ErrorNone = Successful
+ * @sa TBD
+ *
+ */
+/* ===========================================================================*/
+OMX_ERRORTYPE PROXY_VIDDEC_SendCommand(OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_COMMANDTYPE eCmd,
+ OMX_IN OMX_U32 nParam, OMX_IN OMX_PTR pCmdData)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ PROXY_COMPONENT_PRIVATE *pCompPrv = NULL;
+ OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent;
+
+ PROXY_require((hComp->pComponentPrivate != NULL),
+ OMX_ErrorBadParameter, NULL);
+
+ pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate;
+
+ DOMX_ENTER
+ ("hComponent = %p, pCompPrv = %p, eCmd = %d, nParam = %d, pCmdData = %p",
+ hComponent, pCompPrv, eCmd, nParam, pCmdData);
+
+ if(eCmd == OMX_CommandStateSet)
+ {
+ //Set appropriate stride before Loaded to Idle transition.
+ if((OMX_STATETYPE)nParam == OMX_StateIdle && pCompPrv->IsLoadedState == OMX_TRUE)
+ {
+ eError = RPC_UTIL_SetStrideAndPadding(hComponent, pCompPrv);
+ PROXY_require(eError == OMX_ErrorNone, eError,
+ "Stride and padding setting from proxy returned");
+ pCompPrv->IsLoadedState = OMX_FALSE;
+ }
+ }
+ else if(eCmd == OMX_CommandPortEnable)
+ {
+ if(nParam == OMX_ALL || nParam == OMX_VIDEODECODER_OUTPUT_PORT)
+ {
+ eError = RPC_UTIL_SetStrideAndPadding(hComponent, pCompPrv);
+ PROXY_require(eError == OMX_ErrorNone, eError,
+ "Stride and padding setting from proxy returned");
+ }
+ }
+
+ eError =
+ PROXY_SendCommand(hComponent, eCmd, nParam, pCmdData);
+
+ EXIT:
+ DOMX_EXIT("eError: %d", eError);
+ return eError;
+}
+
+/* ===========================================================================*/
+/**
+ * @name PROXY_EventHandler()
+ * @brief
+ * @param void
+ * @return OMX_ErrorNone = Successful
+ * @sa TBD
+ *
+ */
+/* ===========================================================================*/
+OMX_ERRORTYPE PROXY_VIDDEC_EventHandler(OMX_HANDLETYPE hComponent,
+ OMX_PTR pAppData, OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2,
+ OMX_PTR pEventData)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ PROXY_COMPONENT_PRIVATE *pCompPrv = NULL;
+ OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent;
+
+ pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate;
+
+ PROXY_require((hComp->pComponentPrivate != NULL),
+ OMX_ErrorBadParameter,
+ "This is fatal error, processing cant proceed - please debug");
+
+ DOMX_ENTER
+ ("hComponent=%p, pCompPrv=%p, eEvent=%p, nData1=%p, nData2=%p, pEventData=%p",
+ hComponent, pCompPrv, eEvent, nData1, nData2, pEventData);
+
+ if((eEvent == OMX_EventCmdComplete) && ((OMX_COMMANDTYPE)nData1 == OMX_CommandStateSet))
+ {
+ if((OMX_STATETYPE)nData2 == OMX_StateLoaded)
+ {
+ pCompPrv->IsLoadedState = OMX_TRUE;
+ }
+ }
+ eError = PROXY_EventHandler(hComponent, pAppData, eEvent, nData1, nData2, pEventData);
+
+ EXIT:
+ return eError;
+}
+
+/* ===========================================================================*/
+/**
+ * @name RPC_UTIL_RPC_UTIL_SetStrideAndPadding()
+ * @brief Gets stride on this port. Used to set stride on OMX to tell whether buffer is 1D or 2D
+ * @param hRemoteComp [IN] : Remote component handle.
+ * @return OMX_ErrorNone = Successful
+ */
+/* ===========================================================================*/
+OMX_ERRORTYPE RPC_UTIL_SetStrideAndPadding(OMX_COMPONENTTYPE * hComponent,PROXY_COMPONENT_PRIVATE * pCompPrv)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_PARAM_PORTDEFINITIONTYPE sPortDef;
+ OMX_CONFIG_RECTTYPE tParamStruct;
+ OMX_U32 nPortIndex = 0;
+
+ for(nPortIndex=0; nPortIndex < TOTAL_DEC_PORTS ;nPortIndex++ )
+ {
+ /*Initializing Structure */
+ sPortDef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
+ sPortDef.nVersion.s.nVersionMajor = OMX_VER_MAJOR;
+ sPortDef.nVersion.s.nVersionMinor = OMX_VER_MINOR;
+ sPortDef.nVersion.s.nRevision = 0x0;
+ sPortDef.nVersion.s.nStep = 0x0;
+ sPortDef.nPortIndex = nPortIndex;
+
+ eError = PROXY_GetParameter(hComponent,OMX_IndexParamPortDefinition,
+ &sPortDef);
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error in Proxy GetParameter for Port Def");
+
+ if (sPortDef.eDomain == OMX_PortDomainVideo && sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingUnused)
+ {
+ if(pCompPrv->proxyPortBuffers[nPortIndex].IsBuffer2D == OMX_TRUE)
+ {
+ sPortDef.format.video.nStride = LINUX_PAGE_SIZE;
+ }
+ else
+ {
+ tParamStruct.nSize = sizeof(OMX_CONFIG_RECTTYPE);
+ tParamStruct.nVersion.s.nVersionMajor = OMX_VER_MAJOR;
+ tParamStruct.nVersion.s.nVersionMinor = OMX_VER_MINOR;
+ tParamStruct.nVersion.s.nRevision = 0x0;
+ tParamStruct.nVersion.s.nStep = 0x0;
+ tParamStruct.nPortIndex = nPortIndex;
+
+ eError = PROXY_GetParameter(hComponent,(OMX_INDEXTYPE)OMX_TI_IndexParam2DBufferAllocDimension,
+ &tParamStruct);
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error in Proxy GetParameter for 2D index");
+
+ sPortDef.format.video.nStride = tParamStruct.nWidth;
+ }
+ eError = PROXY_SetParameter(hComponent,OMX_IndexParamPortDefinition,
+ &sPortDef);
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error in Proxy SetParameter for Port Def");
+ }
+ }
+
+ EXIT:
+ return eError;
+}
+
+#endif
+
+#ifdef ANDROID_QUIRK_LOCK_BUFFER
+/* ===========================================================================*/
+/**
+ * @name PROXY_VIDDEC_FillThisBuffer()
+ * @brief Gets stride on this port. Used to set stride on OMX to tell whether buffer is 1D or 2D
+ */
+/* ===========================================================================*/
+OMX_ERRORTYPE PROXY_VIDDEC_FillThisBuffer(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE * pBufferHdr)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone;
+ RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
+ PROXY_COMPONENT_PRIVATE *pCompPrv;
+ OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent;
+ OMX_U32 count = 0;
+ IMG_native_handle_t* grallocHandle;
+ OMX_PARAM_PORTDEFINITIONTYPE sPortDef;
+
+ PROXY_require(pBufferHdr != NULL, OMX_ErrorBadParameter, NULL);
+ PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter,
+ NULL);
+ PROXY_CHK_VERSION(pBufferHdr, OMX_BUFFERHEADERTYPE);
+
+ pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate;
+
+ if(pCompPrv->proxyPortBuffers[OMX_VIDEODECODER_OUTPUT_PORT].proxyBufferType
+ == GrallocPointers)
+ {
+ /* Lock the Gralloc buffer till it gets rendered completely */
+ /* Extract the Gralloc handle from the Header and then call lock on that */
+ /* Note# There is no error check for the pBufferHdr here*/
+ grallocHandle = (IMG_native_handle_t*)pBufferHdr->pBuffer;
+
+ /*Initializing Structure */
+ sPortDef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
+ sPortDef.nVersion.s.nVersionMajor = OMX_VER_MAJOR;
+ sPortDef.nVersion.s.nVersionMinor = OMX_VER_MINOR;
+ sPortDef.nVersion.s.nRevision = 0x0;
+ sPortDef.nVersion.s.nStep = 0x0;
+ sPortDef.nPortIndex = OMX_VIDEODECODER_INPUT_PORT;
+ eError = PROXY_GetParameter(hComponent,OMX_IndexParamPortDefinition,
+ &sPortDef);
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error in Proxy GetParameter for Port Def");
+
+#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY
+ /* Get the Video frame crop window */
+ OMX_CONFIG_RECTTYPE rect;
+ rect.nSize = sizeof(rect);
+ rect.nVersion.s.nVersionMajor = OMX_VER_MAJOR;
+ rect.nVersion.s.nVersionMinor = OMX_VER_MINOR;
+ rect.nVersion.s.nRevision = 0x0;
+ rect.nVersion.s.nStep = 0x0;
+ rect.nPortIndex = OMX_VIDEODECODER_OUTPUT_PORT;
+
+ eError = PROXY_GetConfig(hComponent, OMX_IndexConfigCommonOutputCrop, &rect);
+
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error while getting output crop");
+ pCompPrv->debugframeInfo.frame_width = rect.nWidth;
+ pCompPrv->debugframeInfo.frame_height = rect.nHeight;
+ pCompPrv->debugframeInfo.frame_xoffset = rect.nLeft;
+ pCompPrv->debugframeInfo.frame_yoffset = rect.nTop;
+#endif
+ pCompPrv->grallocModule->lock((gralloc_module_t const *) pCompPrv->grallocModule,
+ (buffer_handle_t)grallocHandle, GRALLOC_USAGE_HW_RENDER,
+ 0,0,sPortDef.format.video.nFrameWidth, sPortDef.format.video.nFrameHeight,NULL);
+ }
+
+ eRPCError = PROXY_FillThisBuffer(hComponent, pBufferHdr);
+
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error in Proxy SetParameter for Port Def");
+
+ EXIT:
+ DOMX_EXIT("eError: %d", eError);
+ return eError;
+}
+
+/* ===========================================================================*/
+/**
+ * @name PROXY_VIDDEC_FillBufferDone()
+ * @brief Gets stride on this port. Used to set stride on OMX to tell whether buffer is 1D or 2D
+ */
+/* ===========================================================================*/
+OMX_ERRORTYPE PROXY_VIDDEC_FillBufferDone(OMX_HANDLETYPE hComponent,
+ OMX_U32 remoteBufHdr, OMX_U32 nfilledLen, OMX_U32 nOffset, OMX_U32 nFlags,
+ OMX_TICKS nTimeStamp, OMX_HANDLETYPE hMarkTargetComponent,
+ OMX_PTR pMarkData)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone;
+ RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
+ PROXY_COMPONENT_PRIVATE *pCompPrv = NULL;
+ OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent;
+ OMX_U32 count = 0;
+ IMG_native_handle_t* grallocHandle;
+
+ PROXY_require((hComp->pComponentPrivate != NULL),
+ OMX_ErrorBadParameter,
+ "This is fatal error, processing cant proceed - please debug");
+
+ pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate;
+
+ /* Lock the Gralloc buffer till it gets rendered completely */
+ /* Extract the Gralloc handle from the Header and then call lock on that */
+ /* Note# There is no error check for the pBufferHdr here*/
+
+ if(pCompPrv->proxyPortBuffers[OMX_VIDEODECODER_OUTPUT_PORT].proxyBufferType
+ == GrallocPointers) {
+ for (count = 0; count < pCompPrv->nTotalBuffers; ++count)
+ {
+ if (pCompPrv->tBufList[count].pBufHeaderRemote == remoteBufHdr)
+ {
+ grallocHandle = (IMG_native_handle_t*)(pCompPrv->tBufList[count].pBufHeader)->pBuffer;
+ break;
+ }
+ }
+
+ PROXY_assert((count != pCompPrv->nTotalBuffers),
+ OMX_ErrorBadParameter,
+ "Received invalid-buffer header from OMX component");
+ pCompPrv->grallocModule->unlock((gralloc_module_t const *) pCompPrv->grallocModule, (buffer_handle_t)grallocHandle);
+
+#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY
+ ALOGV("frm[%u] to[%u] run[%u]", pCompPrv->debugframeInfo.fromFrame, pCompPrv->debugframeInfo.toFrame, pCompPrv->debugframeInfo.runningFrame);
+ /* Fill buffer Done successed, hence start dumping if requested */
+ OMX_BUFFERHEADERTYPE *pBufHdr = pCompPrv->tBufList[count].pBufHeader;
+ if ((pCompPrv->debugframeInfo.fromFrame == 0) && (pCompPrv->debugframeInfo.runningFrame <= pCompPrv->debugframeInfo.toFrame))
+ {
+ /* Lock the buffer for SW read usage and then access it */
+ pCompPrv->grallocModule->lock((gralloc_module_t const*) pCompPrv->grallocModule,
+ (buffer_handle_t)grallocHandle,
+ GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_SW_READ_RARELY,
+ pCompPrv->debugframeInfo.frame_xoffset,
+ pCompPrv->debugframeInfo.frame_yoffset,
+ pCompPrv->debugframeInfo.frame_width,
+ pCompPrv->debugframeInfo.frame_height,
+ (void*)pCompPrv->debugframeInfo.y_uv);
+
+ DumpVideoFrame(&pCompPrv->debugframeInfo);
+
+ pCompPrv->grallocModule->unlock((gralloc_module_t const *) pCompPrv->grallocModule,
+ (buffer_handle_t)grallocHandle);
+ pCompPrv->debugframeInfo.runningFrame++;
+ }
+ else if (pCompPrv->debugframeInfo.fromFrame > 0)
+ {
+ pCompPrv->debugframeInfo.fromFrame--;
+ }
+#endif
+ }
+
+ eRPCError = PROXY_FillBufferDone(hComponent,remoteBufHdr, nfilledLen, nOffset, nFlags,
+ nTimeStamp, hMarkTargetComponent, pMarkData);
+
+ PROXY_assert(eError == OMX_ErrorNone,
+ eError," Error in PROXY FillBufferDone for Port Def");
+
+EXIT:
+ DOMX_EXIT("eError: %d", eError);
+ return eError;
+}
+
+#endif
+
diff --git a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c
new file mode 100644
index 0000000..473a7f0
--- /dev/null
+++ b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c
@@ -0,0 +1,157 @@
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include "omx_proxy_common.h"
+#include <timm_osal_interfaces.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER.secure"
+
+extern OMX_U32 DUCATI_IN_SECURE_MODE;
+extern OMX_U32 SECURE_COMPONENTS_RUNNING;
+
+extern OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE PROXY_VIDDEC_Secure_ComponentDeInit(OMX_HANDLETYPE hComponent);
+
+OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL;
+ const OMX_U8 enable = 1, disable = 0;
+ OMX_U8 mode;
+ int ret;
+
+ pHandle = (OMX_COMPONENTTYPE *) hComponent;
+
+ DOMX_ENTER("");
+
+ DOMX_DEBUG("Component name provided is %s", COMPONENT_NAME);
+
+ pHandle->pComponentPrivate =
+ (PROXY_COMPONENT_PRIVATE *)
+ TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE,
+ 0, TIMMOSAL_MEM_SEGMENT_INT);
+
+ PROXY_assert(pHandle->pComponentPrivate != NULL,
+ OMX_ErrorInsufficientResources,
+ "ERROR IN ALLOCATING PROXY COMPONENT PRIVATE STRUCTURE");
+
+ pComponentPrivate =
+ (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate;
+
+ TIMM_OSAL_Memset(pComponentPrivate, 0,
+ sizeof(PROXY_COMPONENT_PRIVATE));
+
+ pComponentPrivate->cCompName =
+ TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8),
+ TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT);
+
+ PROXY_assert(pComponentPrivate->cCompName != NULL,
+ OMX_ErrorInsufficientResources,
+ " Error in Allocating space for proxy component table");
+
+ // Copying component Name - this will be picked up in the proxy common
+ PROXY_assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH,
+ OMX_ErrorInvalidComponentName,
+ "Length of component name is longer than the max allowed");
+ TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME,
+ strlen(COMPONENT_NAME) + 1);
+
+ pComponentPrivate->secure_misc_drv_fd = open("/dev/rproc_user", O_SYNC | O_RDWR);
+ if (pComponentPrivate->secure_misc_drv_fd < 0)
+ {
+ DOMX_ERROR("Can't open rproc_user device 0x%x\n", errno);
+ eError = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ ret = write(pComponentPrivate->secure_misc_drv_fd, &enable, sizeof(enable));
+ if(ret != 1)
+ {
+ DOMX_ERROR("errno from setting secure mode = %x",errno);
+ ret = write(pComponentPrivate->secure_misc_drv_fd, &disable, sizeof(disable));
+ if (ret < 0)
+ {
+ DOMX_ERROR("Setting unsecure mode failed");
+ }
+
+ ret = close(pComponentPrivate->secure_misc_drv_fd);
+ if (ret < 0)
+ {
+ DOMX_ERROR("Can't close the driver");
+ }
+ eError = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ ret = read(pComponentPrivate->secure_misc_drv_fd, &mode, sizeof(mode));
+ PROXY_assert(mode == enable, OMX_ErrorUndefined,"ERROR: We are not in secure mode");
+ DOMX_DEBUG("secure mode recieved from Misc driver for secure playback = 0x%x\n", mode);
+
+ eError = OMX_ProxyViddecInit(hComponent);
+ pHandle->ComponentDeInit = PROXY_VIDDEC_Secure_ComponentDeInit;
+
+#ifdef USE_ION
+ pComponentPrivate->bUseIon = OMX_TRUE;
+ pComponentPrivate->bMapIonBuffers = OMX_FALSE;
+#endif
+ EXIT:
+ if (eError != OMX_ErrorNone)
+ {
+ DOMX_DEBUG("Error in Initializing Proxy");
+ if (pComponentPrivate->cCompName != NULL)
+ {
+ TIMM_OSAL_Free(pComponentPrivate->cCompName);
+ pComponentPrivate->cCompName = NULL;
+ }
+ if (pComponentPrivate != NULL)
+ {
+ TIMM_OSAL_Free(pComponentPrivate);
+ pComponentPrivate = NULL;
+ }
+ }
+ return eError;
+}
+
+OMX_ERRORTYPE PROXY_VIDDEC_Secure_ComponentDeInit(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL;
+ int ret;
+ const OMX_U8 disable = 0;
+ int secure_misc_drv_fd;
+
+ pHandle = (OMX_COMPONENTTYPE *) hComponent;
+
+ pComponentPrivate =
+ (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate;
+
+ secure_misc_drv_fd = pComponentPrivate->secure_misc_drv_fd;
+
+ eError = PROXY_ComponentDeInit(hComponent);
+ if(eError != OMX_ErrorNone)
+ {
+ DOMX_ERROR("Proxy common deinit returned error = %x",eError);
+ }
+ pComponentPrivate = NULL;
+
+ ret = write(secure_misc_drv_fd, &disable, sizeof(disable));
+ if (ret < 0)
+ {
+ DOMX_ERROR("Setting unsecure mode failed");
+ }
+
+ ret = close(secure_misc_drv_fd);
+ if (ret < 0)
+ {
+ DOMX_ERROR("Can't close the driver");
+ }
+
+ return eError;
+}
+
diff --git a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c
new file mode 100755
index 0000000..53922fd
--- /dev/null
+++ b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*==============================================================
+ *! Revision History
+ *! ============================
+ *! 21-Oct-2011 Rajesh vandanapu sarthav@ti.com: Initial Version
+ *================================================================*/
+
+/******************************************************************
+ * INCLUDE FILES
+ ******************************************************************/
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include "omx_proxy_common.h"
+#include <timm_osal_interfaces.h>
+#include "OMX_TI_IVCommon.h"
+#include "OMX_TI_Video.h"
+#include "OMX_TI_Index.h"
+
+#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY
+#define LOG_TAG "OMXPROXYVIDEODEC"
+#include <fcntl.h>
+#include <cutils/properties.h>
+#include <utils/Log.h>
+#include <stdlib.h>
+#include <errno.h>
+#endif
+
+#define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER"
+/* needs to be specific for every configuration wrapper */
+
+/* DEFINITIONS for parsing the config information & sequence header for WMV*/
+#define VIDDEC_GetUnalignedDword( pb, dw ) \
+ (dw) = ((OMX_U32) *(pb + 3) << 24) + \
+ ((OMX_U32) *(pb + 2) << 16) + \
+ ((OMX_U16) *(pb + 1) << 8) + *pb;
+
+#define VIDDEC_GetUnalignedDwordEx( pb, dw ) VIDDEC_GetUnalignedDword( pb, dw ); (pb) += sizeof(OMX_U32);
+#define VIDDEC_LoadDWORD( dw, p ) VIDDEC_GetUnalignedDwordEx( p, dw )
+#define VIDDEC_MAKEFOURCC(ch0, ch1, ch2, ch3) \
+ ((OMX_U32)(OMX_U8)(ch0) | ((OMX_U32)(OMX_U8)(ch1) << 8) | \
+ ((OMX_U32)(OMX_U8)(ch2) << 16) | ((OMX_U32)(OMX_U8)(ch3) << 24 ))
+
+#define VIDDEC_FOURCC(ch0, ch1, ch2, ch3) VIDDEC_MAKEFOURCC(ch0, ch1, ch2, ch3)
+
+#define FOURCC_WMV3 VIDDEC_FOURCC('W','M','V','3')
+#define FOURCC_WMV2 VIDDEC_FOURCC('W','M','V','2')
+#define FOURCC_WMV1 VIDDEC_FOURCC('W','M','V','1')
+#define FOURCC_WVC1 VIDDEC_FOURCC('W','V','C','1')
+
+#define CSD_POSITION 51 /*Codec Specific Data position on the "stream propierties object"(ASF spec)*/
+
+typedef struct VIDDEC_WMV_RCV_struct {
+ OMX_U32 nNumFrames : 24;
+ OMX_U32 nFrameType : 8;
+ OMX_U32 nID : 32;
+ OMX_U32 nStructData : 32; //STRUCT_C
+ OMX_U32 nVertSize; //STRUCT_A-1
+ OMX_U32 nHorizSize; //STRUCT_A-2
+ OMX_U32 nID2 : 32;
+ OMX_U32 nSequenceHdr : 32; //STRUCT_B
+} VIDDEC_WMV_RCV_struct;
+
+typedef struct VIDDEC_WMV_VC1_struct {
+ OMX_U32 nNumFrames : 24;
+ OMX_U32 nFrameType : 8;
+ OMX_U32 nID : 32;
+ OMX_U32 nStructData : 32; //STRUCT_C
+ OMX_U32 nVertSize; //STRUCT_A-1
+ OMX_U32 nHorizSize; //STRUCT_A-2
+ OMX_U32 nID2 : 32;
+ OMX_U32 nSequenceHdr : 32; //STRUCT_B
+} VIDDEC_WMV_VC1_struct;
+
+
+OMX_ERRORTYPE PrearrageEmptyThisBuffer(OMX_HANDLETYPE hComponent,
+ OMX_BUFFERHEADERTYPE * pBufferHdr)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ PROXY_COMPONENT_PRIVATE *pCompPrv = NULL;
+ OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent;
+ OMX_U8* pBuffer = NULL;
+ OMX_U8* pData = NULL;
+ OMX_U32 nValue = 0;
+ OMX_U32 nWidth = 0;
+ OMX_U32 nHeight = 0;
+ OMX_U32 nActualCompression = 0;
+ OMX_U8* pCSD = NULL;
+ OMX_U32 nSize_CSD = 0;
+ DOMX_ENTER("");
+
+ PROXY_assert(pBufferHdr != NULL, OMX_ErrorBadParameter, NULL);
+
+ if (pBufferHdr->nFlags & OMX_BUFFERFLAG_CODECCONFIG){
+ PROXY_assert(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, NULL);
+
+ pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate;
+ /* Get component role */
+ OMX_PARAM_COMPONENTROLETYPE compRole;
+ compRole.nSize = sizeof(OMX_PARAM_COMPONENTROLETYPE);
+ compRole.nVersion.s.nVersionMajor = 1;
+ compRole.nVersion.s.nVersionMinor = 1; //Ducati OMX version
+ compRole.nVersion.s.nRevision = 0;
+ compRole.nVersion.s.nStep = 0;
+
+ eError = PROXY_GetParameter(hComp, OMX_IndexParamStandardComponentRole, &compRole);
+ if(eError != OMX_ErrorNone){
+ DOMX_ERROR("Error getting OMX_IndexParamStandardComponentRole");
+ }
+
+ if(!strcmp((char *)(compRole.cRole), "video_decoder.wmv")){
+ pBuffer = pBufferHdr->pBuffer;
+
+ VIDDEC_WMV_RCV_struct sStructRCV;
+
+ DOMX_DEBUG("nFlags: %x", pBufferHdr->nFlags);
+
+ pData = pBufferHdr->pBuffer + 15; /*Position to Width & Height*/
+ VIDDEC_LoadDWORD(nValue, pData);
+ nWidth = nValue;
+ VIDDEC_LoadDWORD(nValue, pData);
+ nHeight = nValue;
+
+ pData += 4; /*Position to compression type*/
+ VIDDEC_LoadDWORD(nValue, pData);
+ nActualCompression = nValue;
+
+ /*Seting pCSD to proper position*/
+ pCSD = pBufferHdr->pBuffer;
+ pCSD += CSD_POSITION;
+ nSize_CSD = pBufferHdr->nFilledLen - CSD_POSITION;
+
+ if(nActualCompression == FOURCC_WMV3){
+
+ //From VC-1 spec: Table 265: Sequence Layer Data Structure
+ sStructRCV.nNumFrames = 0xFFFFFF; /*Infinite frame number*/
+ sStructRCV.nFrameType = 0xc5; /*0x85 is the value given by ASF to rcv converter*/
+ sStructRCV.nID = 0x04; /*WMV3*/
+ sStructRCV.nStructData = 0x018a3106; /*0x06318a01zero fill 0x018a3106*/
+ sStructRCV.nVertSize = nHeight;
+ sStructRCV.nHorizSize = nWidth;
+ sStructRCV.nID2 = 0x0c; /* Fix value */
+ sStructRCV.nSequenceHdr = 0x00002a9f; /* This value is not provided by parser, so giving a value from a video*/
+
+ DOMX_DEBUG("initial: nStructData: %x", sStructRCV.nStructData);
+ DOMX_DEBUG("pCSD = %x", (OMX_U32)*pCSD);
+
+ sStructRCV.nStructData = (OMX_U32)pCSD[0] << 0 |
+ pCSD[1] << 8 |
+ pCSD[2] << 16 |
+ pCSD[3] << 24;
+
+ DOMX_DEBUG("FINAL: nStructData: %x", sStructRCV.nStructData);
+
+ //Copy RCV structure to actual buffer
+ assert(pBufferHdr->nFilledLen < pBufferHdr->nAllocLen);
+ pBufferHdr->nFilledLen = sizeof(VIDDEC_WMV_RCV_struct);
+ TIMM_OSAL_Memcpy(pBufferHdr->pBuffer, (OMX_U8*)(&sStructRCV),
+ pBufferHdr->nFilledLen);
+
+ }
+ else if (nActualCompression == FOURCC_WVC1){
+ DOMX_DEBUG("VC-1 Advance Profile prearrange");
+ pBufferHdr->nOffset = pBufferHdr->nOffset+52;
+ pBufferHdr->nFilledLen= pBufferHdr->nFilledLen-52;
+ }
+ }
+ }
+
+ EXIT:
+ DOMX_EXIT("eError: %d", eError);
+
+ return PROXY_EmptyThisBuffer(hComponent, pBufferHdr);
+}
+
+#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY
+/**
+* Usage#
+* By default this feature is kept disabled to avoid security leaks.
+*
+* (1) Uncomment the below 2 lines from Android.mk
+* #LOCAL_CFLAGS += -DENABLE_RAW_BUFFERS_DUMP_UTILITY
+* #LOCAL_SHARED_LIBRARIES += libcutils
+* And rebuild the omx proxy common component
+*
+* (2) Before start playback, make sure that "data" folder has r/w
+* permissions. For this, execute the below
+* mount -o rw,remount -t ext3 /dev/block/mmcblk0p1 /data/
+* chmod 777 /data/
+*
+* (3) Set the property for number of frames to dump
+* eg: setprop debug.video.dumpframe 10:20
+* would dump frames from 10 to 20.
+*
+* (4) Pull the frames to PC over adb
+* adb pull /data/frame_10.txt
+*
+* (5) Analyse on PC tools.
+*/
+
+/*
+* Method to convert NV12 to YUV420p for PC analysis
+*/
+static void convertNV12ToYuv420(DebugFrame_Dump *frameInfo, void *dst)
+{
+ int stride = 4096; /* ARM Page size = 4k */
+ uint32_t ybuf_offset = frameInfo->frame_yoffset * stride + frameInfo->frame_xoffset;
+ uint8_t* p1y = (uint8_t*)frameInfo->y_uv[0] + ybuf_offset;
+ uint8_t* p2y = (uint8_t*) dst;
+ int i, j, j1;
+ int width = frameInfo->frame_width;
+ int height = frameInfo->frame_height;
+
+ LOGD("Coverting NV-12 to YUV420p Width[%d], Height[%d] and Stride[%d] offset[%d]",
+ width, height, stride, ybuf_offset);
+
+ /* copy y-buffer, almost bytewise copy, except for stride jumps.*/
+ for(i=0;i<height;i++)
+ {
+ /* copy whole row of Y pixels. source and desination will point to new row each time.*/
+ memcpy(p2y+i*width, p1y+i*stride, width);
+ }
+
+ /** copy uv buffers
+ * rearrange from packed planar [uvuvuv] to planar [uuu][vvvv] packages pixel wise
+ * calculate the offset for UV buffer
+ */
+ uint32_t UV_offset = frameInfo->frame_xoffset +
+ (frameInfo->frame_yoffset * stride)/2;
+
+ const uint8_t* p1uv = (uint8_t*)frameInfo->y_uv[1] + UV_offset;
+
+ uint8_t* p2u = ((uint8_t*) dst + (width * height));
+ uint8_t* p2v = ((uint8_t*) p2u + ((width/2) * (height/2)));
+ for(i=0;(i < height/2);i++)
+ {
+ for(j=0,j1=0;(j< width/2);j++,j1+=2)
+ {
+ p2u[j] = p1uv[j1];
+ p2v[j] = p1uv[j1+1];
+ }
+ p1uv+=stride;
+ p2u+=width/2;
+ p2v+=width/2;
+ }
+}
+
+void DumpVideoFrame(DebugFrame_Dump *frameInfo)
+{
+ /* First convert the frame to 420p and then write to SD Card */
+ OMX_U32 framesize = (frameInfo->frame_width *
+ frameInfo->frame_height * 3) / 2;
+ OMX_U8* localbuffer = malloc(framesize);
+ if (localbuffer == NULL)
+ {
+ LOGE("NO HEAP");
+ goto EXIT;
+ }
+ convertNV12ToYuv420(frameInfo, localbuffer);
+ int filedes = -1;
+ char framenumber[100];
+ sprintf(framenumber, "/data/frame_%ld.txt", frameInfo->runningFrame);
+ LOGD("file path %s",framenumber);
+ filedes = open(framenumber, O_CREAT | O_WRONLY | O_SYNC | O_TRUNC, 0777);
+ if(filedes < 0)
+ {
+ LOGE("\n!!!!!!!!!Error in file open!!!!!!!! [%d][%s]\n", filedes, strerror(errno));
+ goto EXIT;
+ }
+ int ret = write (filedes, (void*)localbuffer, framesize);
+ if (ret < (int)framesize)
+ {
+ LOGE("File Write Failed");
+ }
+EXIT:
+ if (localbuffer)
+ {
+ free(localbuffer);
+ localbuffer = NULL;
+ }
+ if (filedes > 0)
+ {
+ close(filedes);
+ }
+}
+
+#endif