summaryrefslogtreecommitdiff
path: root/omx/image
diff options
context:
space:
mode:
authorRebecca Schultz Zavin <rebecca@android.com>2009-07-29 17:23:50 -0700
committerRebecca Schultz Zavin <rebecca@android.com>2009-07-30 14:38:43 -0700
commitb44cdb1b44b144d09e8ec950d1e8e4c280064056 (patch)
tree74c611897d728c5d73ad2479ef1ab123654721fc /omx/image
parent3410a0df3ef3d3f8254eea6430d999f631191e9f (diff)
downloadomap3-b44cdb1b44b144d09e8ec950d1e8e4c280064056.tar.gz
New version of ti OMX code to support ti mm release 25.9
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
Diffstat (limited to 'omx/image')
-rw-r--r--omx/image/src/openmax_il/jpeg_dec/Android.mk20
-rw-r--r--omx/image/src/openmax_il/jpeg_dec/inc/OMX_JpegDec_Utils.h47
-rw-r--r--omx/image/src/openmax_il/jpeg_dec/src/OMX_JpegDec_Utils.c260
-rw-r--r--omx/image/src/openmax_il/jpeg_dec/src/OMX_JpegDecoder.c112
-rwxr-xr-xomx/image/src/openmax_il/jpeg_dec/tests/JPEGTest.c1608
-rwxr-xr-xomx/image/src/openmax_il/jpeg_dec/tests/JPEGTest.h118
-rw-r--r--omx/image/src/openmax_il/jpeg_enc/Android.mk20
-rw-r--r--omx/image/src/openmax_il/jpeg_enc/inc/OMX_JpegEnc_CustomCmd.h22
-rw-r--r--omx/image/src/openmax_il/jpeg_enc/inc/OMX_JpegEnc_Utils.h247
-rw-r--r--omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEnc_Thread.c10
-rw-r--r--omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEnc_Utils.c1562
-rw-r--r--omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEncoder.c413
-rwxr-xr-xomx/image/src/openmax_il/jpeg_enc/test/JPEGTestEnc.c2098
-rwxr-xr-xomx/image/src/openmax_il/jpeg_enc/test/JPEGTestEnc.h114
14 files changed, 5574 insertions, 1077 deletions
diff --git a/omx/image/src/openmax_il/jpeg_dec/Android.mk b/omx/image/src/openmax_il/jpeg_dec/Android.mk
index c76af7e..4dc6cc7 100644
--- a/omx/image/src/openmax_il/jpeg_dec/Android.mk
+++ b/omx/image/src/openmax_il/jpeg_dec/Android.mk
@@ -20,3 +20,23 @@ LOCAL_CFLAGS := $(TI_OMX_CFLAGS) -DOMAP_2430 #-DOMX_DEBUG
LOCAL_MODULE:= libOMX.TI.JPEG.Decoder
include $(BUILD_SHARED_LIBRARY)
+
+
+#########################################################
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= tests/JPEGTest.c
+
+LOCAL_C_INCLUDES := $(TI_OMX_COMP_C_INCLUDES) \
+ $(TI_OMX_IMAGE)/jpeg_dec/inc \
+
+LOCAL_SHARED_LIBRARIES := libOMX.TI.JPEG.Decoder
+
+LOCAL_CFLAGS := -Wall -fpic -pipe -O0 -DOMX_DEBUG=1
+
+LOCAL_MODULE:= JpegTestCommon
+
+include $(BUILD_EXECUTABLE)
+
+
diff --git a/omx/image/src/openmax_il/jpeg_dec/inc/OMX_JpegDec_Utils.h b/omx/image/src/openmax_il/jpeg_dec/inc/OMX_JpegDec_Utils.h
index 4180e73..61b8f2e 100644
--- a/omx/image/src/openmax_il/jpeg_dec/inc/OMX_JpegDec_Utils.h
+++ b/omx/image/src/openmax_il/jpeg_dec/inc/OMX_JpegDec_Utils.h
@@ -72,6 +72,26 @@
#define COMP_MAX_NAMESIZE 127
+/*Linked List */
+
+typedef struct Node {
+ struct Node *pNextNode;
+ void *pValue;
+} Node;
+
+typedef struct LinkedList {
+ Node *pRoot;
+} LinkedList;
+
+LinkedList AllocList;
+
+void LinkedList_Create(LinkedList *LinkedList);
+void LinkedList_AddElement(LinkedList *LinkedList, void *pValue);
+void LinkedList_FreeElement(LinkedList *LinkedList, void *pValue);
+void LinkedList_FreeAll(LinkedList *LinkedList);
+void LinkedList_DisplayAll(LinkedList *LinkedList);
+void LinkedList_Destroy(LinkedList *LinkedList);
+
/*
* M A C R O S
*/
@@ -109,30 +129,28 @@ do { \
} \
} while(0)
-#define OMX_MALLOC_STRUCT(_pStruct_, _sName_) \
- _pStruct_ = (_sName_*)malloc(sizeof(_sName_)); \
+#define OMX_MALLOC(_pStruct_, _size_) \
+ _pStruct_ = malloc(_size_); \
if(_pStruct_ == NULL){ \
eError = OMX_ErrorInsufficientResources; \
goto EXIT; \
- } \
- memset(_pStruct_, 0, sizeof(_sName_));
-
-#define MALLOC(_pStruct, _sName, _nExtraSize) \
- _pStruct = (_sName*)malloc(sizeof(_sName) + _nExtraSize); \
- if(_pStruct == NULL){ \
- eError = OMX_ErrorInsufficientResources; \
- goto EXIT; \
- } \
- memset(_pStruct, 0, (sizeof(_sName) + _nExtraSize));
+ } \
+ memset(_pStruct_, 0, _size_);\
+ LinkedList_AddElement(&AllocList, _pStruct_);
-#define FREE(_ptr) \
+#define OMX_FREE(_ptr) \
{ \
if (_ptr != NULL) { \
- free(_ptr); \
+ LinkedList_FreeElement(&AllocList, _ptr);\
_ptr = NULL; \
} \
}
+#define OMX_FREEALL() \
+{ \
+ LinkedList_FreeAll(&AllocList);\
+}
+
#define JPEGDEC_WAIT_PORT_POPULATION(_pComponentPrivate_) \
{ \
int nRet = 0x0; \
@@ -274,6 +292,7 @@ do { \
#define JPEGD_BUFFERBACK 0x02
#define JPEGD_IDLEREADY ( JPEGD_DSPSTOP | JPEGD_BUFFERBACK )
+#define DSP_MMU_FAULT_HANDLING
#define OMX_CustomCommandStopThread (OMX_CommandMax - 1)
diff --git a/omx/image/src/openmax_il/jpeg_dec/src/OMX_JpegDec_Utils.c b/omx/image/src/openmax_il/jpeg_dec/src/OMX_JpegDec_Utils.c
index 3c48a48..8497632 100644
--- a/omx/image/src/openmax_il/jpeg_dec/src/OMX_JpegDec_Utils.c
+++ b/omx/image/src/openmax_il/jpeg_dec/src/OMX_JpegDec_Utils.c
@@ -397,7 +397,6 @@ OMX_ERRORTYPE Free_ComponentResourcesJpegDec(JPEGDEC_COMPONENT_PRIVATE *pCompone
OMX_ERRORTYPE threadError = OMX_ErrorNone;
OMX_ERRORTYPE eErr = OMX_ErrorNone;
int pthreadError = 0, nRet = 0;
- OMX_U8 nCount = 0;
OMX_COMMANDTYPE eCmd = OMX_CustomCommandStopThread;
struct OMX_TI_Debug dbg;
@@ -514,127 +513,7 @@ OMX_ERRORTYPE Free_ComponentResourcesJpegDec(JPEGDEC_COMPONENT_PRIVATE *pCompone
eError = OMX_ErrorHardware;
OMX_PRCOMM4(pComponentPrivate->dbg, "Error while closing cmd pipe\n");
}
-
- /* Free Resources */
-#ifdef KHRONOS_1_1
-
- if (pComponentPrivate->pAudioPortType)
- {
- free(pComponentPrivate->pAudioPortType);
- pComponentPrivate->pAudioPortType = NULL;
- }
-
- if (pComponentPrivate->pVideoPortType)
- {
- free(pComponentPrivate->pVideoPortType);
- pComponentPrivate->pVideoPortType = NULL;
- }
- if (pComponentPrivate->pOtherPortType)
- {
- free(pComponentPrivate->pOtherPortType);
- pComponentPrivate->pOtherPortType = NULL;
- }
- if (pComponentPrivate->pCompRole)
- {
- free(pComponentPrivate->pCompRole);
- pComponentPrivate->pCompRole = NULL;
- }
- if (pComponentPrivate->pQuantTable)
- {
- free(pComponentPrivate->pQuantTable);
- pComponentPrivate->pQuantTable = NULL;
- }
- if (pComponentPrivate->pHuffmanTable)
- {
- free(pComponentPrivate->pHuffmanTable);
- pComponentPrivate->pHuffmanTable = NULL;
- }
-
-#endif
-
- if(pComponentPrivate->cComponentName){
- free(pComponentPrivate->cComponentName);
- pComponentPrivate->cComponentName = NULL;
- }
- for (nCount = 0; nCount < NUM_OF_BUFFERS; nCount++) {
- if (pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nCount]) {
- free(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nCount]);
- pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nCount] = NULL;
- }
- }
- for (nCount = 0; nCount < NUM_OF_BUFFERS; nCount++) {
- if (pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nCount]) {
- free(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nCount]);
- pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nCount] = NULL;
- }
- }
-
- if (pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pParamBufSupplier) {
- free(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pParamBufSupplier);
- pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pParamBufSupplier = NULL;
- }
-
- if (pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pParamBufSupplier) {
- free(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pParamBufSupplier);
- pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pParamBufSupplier = NULL;
- }
-
- if (pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortDef) {
- free (pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortDef);
- pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortDef = NULL;
- }
-
- if (pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortDef) {
- free (pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortDef);
- pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortDef = NULL;
- }
-
- if (pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortFormat) {
- free (pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortFormat);
- pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortFormat = NULL;
- }
-
- if (pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortFormat) {
- free (pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortFormat);
- pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortFormat = NULL;
- }
-
- if (pComponentPrivate->pPriorityMgmt) {
- free (pComponentPrivate->pPriorityMgmt);
- pComponentPrivate->pPriorityMgmt = NULL;
- }
-
- if (pComponentPrivate->pPortParamType) {
- free (pComponentPrivate->pPortParamType);
- pComponentPrivate->pPortParamType = NULL;
- }
-
- if (pComponentPrivate->pScalePrivate) {
- free(pComponentPrivate->pScalePrivate);
- pComponentPrivate->pScalePrivate = NULL;
- }
-
- if(pComponentPrivate->pSectionDecode) {
- free(pComponentPrivate->pSectionDecode);
- pComponentPrivate->pSectionDecode = NULL;
- }
-
- if(pComponentPrivate->pSubRegionDecode) {
- free(pComponentPrivate->pSubRegionDecode);
- pComponentPrivate->pSubRegionDecode = NULL;
- }
-
- if (pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]) {
- free(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]);
- pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT] = NULL;
- }
-
- if (pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]) {
- free(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]);
- pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT] = NULL;
- }
-
if (pthread_mutex_destroy(&(pComponentPrivate->mJpegDecMutex)) != 0){
OMX_TRACE4(pComponentPrivate->dbg, "Error with pthread_mutex_destroy");
}
@@ -650,10 +529,9 @@ OMX_ERRORTYPE Free_ComponentResourcesJpegDec(JPEGDEC_COMPONENT_PRIVATE *pCompone
PERF_Done(pComponentPrivate->pPERF);
#endif
- if (pComponentPrivate) {
- free(pComponentPrivate);
- pComponentPrivate = NULL;
- }
+ /*LinkedList_DisplayAll (&AllocList); */
+ OMX_FREEALL();
+ LinkedList_Destroy(&AllocList);
EXIT:
OMX_PRINT1(dbg, "Exiting Successfully After Freeing All Resources Errror %x, \n", eError);
@@ -1241,7 +1119,7 @@ OMX_U32 HandleCommandJpegDec(JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate,
switch ((OMX_STATETYPE)(nParam1))
{
case OMX_StateIdle:
- OMX_PRINT2(pComponentPrivate->dbg, "JPEG HandleCommand: Cmd Idle \n");
+ OMX_PRINT2(pComponentPrivate->dbg, "JPEG HandleCommand: Cmd Idle \n");
OMX_PRSTATE2(pComponentPrivate->dbg, "CURRENT STATE IS %d\n",pComponentPrivate->nCurState);
if (pComponentPrivate->nCurState == OMX_StateIdle) {
eError = OMX_ErrorSameState;
@@ -1869,7 +1747,7 @@ OMX_ERRORTYPE HandleDataBuf_FromAppJpegDec(JPEGDEC_COMPONENT_PRIVATE *pComponent
}
ptJPGDecUALGInBufParam = (JPEGDEC_UAlgInBufParamStruct *)pBuffPrivate->pUALGParams;
- ptJPGDecUALGInBufParam->ulAlphaRGB = 0;
+ ptJPGDecUALGInBufParam->ulAlphaRGB = 0xFF;
ptJPGDecUALGInBufParam->lInBufCount = 0;
ptJPGDecUALGInBufParam->ulInNumFrame = 1;
ptJPGDecUALGInBufParam->ulInFrameAlign = 4;
@@ -1898,7 +1776,8 @@ OMX_ERRORTYPE HandleDataBuf_FromAppJpegDec(JPEGDEC_COMPONENT_PRIVATE *pComponent
ptJPGDecUALGInBufParam->forceChromaFormat = 10;
ptJPGDecUALGInBufParam->RGB_Format = 10;
}
- else if (pComponentPrivate->nOutputColorFormat == OMX_COLOR_Format32bitARGB8888) {
+ else if (pComponentPrivate->nOutputColorFormat == OMX_COLOR_Format32bitARGB8888 ||
+ pComponentPrivate->nOutputColorFormat == OMX_COLOR_Format32bitBGRA8888 ) {
ptJPGDecUALGInBufParam->forceChromaFormat = 11;
ptJPGDecUALGInBufParam->RGB_Format = 11;
}
@@ -2238,8 +2117,28 @@ OMX_ERRORTYPE LCML_CallbackJpegDec (TUsnCodecEvent event,
OMX_ErrorHardware,
OMX_TI_ErrorCritical,
NULL);
+ pComponentPrivate->nCurState = OMX_StateInvalid;
+ pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
+ pComponentPrivate->pHandle->pApplicationPrivate,
+ OMX_EventError,
+ OMX_ErrorInvalidState,
+ OMX_TI_ErrorCritical,
+ "DSP Hardware Error");
}
goto EXIT;
+
+#ifdef DSP_MMU_FAULT_HANDLING
+ /* Cheking for MMU_fault */
+ if((argsCb[4] == (void *)NULL) && (argsCb[5] == (void*)NULL)) {
+ pComponentPrivate->nCurState = OMX_StateInvalid;
+ pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
+ pComponentPrivate->pHandle->pApplicationPrivate,
+ OMX_EventError,
+ OMX_ErrorInvalidState,
+ OMX_TI_ErrorCritical,
+ "DSP MMU FAULT");
+ }
+#endif
}
if (event == EMMCodecInternalError) {
@@ -2376,28 +2275,109 @@ void ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData)
*
**/
/*-------------------------------------------------------------------*/
-
OMX_BOOL IsTIOMXComponent(OMX_HANDLETYPE hComp)
{
OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_STRING cTunnelComponentName = NULL;
- OMX_VERSIONTYPE sTunnelComponentVersion;
- OMX_VERSIONTYPE sSpecVersion;
- OMX_UUIDTYPE sComponentUUID;
- OMX_STRING cSubstring = NULL;
+ OMX_STRING pTunnelcComponentName = NULL;
+ OMX_VERSIONTYPE* pTunnelComponentVersion = NULL;
+ OMX_VERSIONTYPE* pSpecVersion = NULL;
+ OMX_UUIDTYPE* pComponentUUID = NULL;
+ char *pSubstring = NULL;
OMX_BOOL bResult = OMX_TRUE;
- MALLOC(cTunnelComponentName, char, COMP_MAX_NAMESIZE);
- eError = OMX_GetComponentVersion (hComp, cTunnelComponentName, &sTunnelComponentVersion, &sSpecVersion, &sComponentUUID);
- /* Check if tunneled component is a TI component */
+ OMX_MALLOC(pTunnelcComponentName, 128);
+ OMX_MALLOC(pTunnelComponentVersion, sizeof(OMX_VERSIONTYPE));
+ OMX_MALLOC(pSpecVersion, sizeof(OMX_VERSIONTYPE));
+ OMX_MALLOC(pComponentUUID, sizeof(OMX_UUIDTYPE));
+
+ eError = OMX_GetComponentVersion (hComp, pTunnelcComponentName, pTunnelComponentVersion, pSpecVersion, pComponentUUID);
- cSubstring = strstr(cTunnelComponentName, "OMX.TI.");
- if(cSubstring == NULL) {
+ /* Check if tunneled component is a TI component */
+ pSubstring = strstr(pTunnelcComponentName, "OMX.TI.");
+ if(pSubstring == NULL) {
bResult = OMX_FALSE;
}
EXIT:
- FREE(cTunnelComponentName);
+ OMX_FREE(pTunnelcComponentName);
+ OMX_FREE(pTunnelComponentVersion);
+ OMX_FREE(pSpecVersion);
+ OMX_FREE(pComponentUUID);
return bResult;
} /* End of IsTIOMXComponent */
+void LinkedList_Create(LinkedList *LinkedList) {
+ LinkedList->pRoot = NULL;
+}
+
+void LinkedList_AddElement(LinkedList *LinkedList, void *pValue) {
+ /* create new node and fill the value */
+ Node *pNewNode = (Node *)malloc(sizeof(Node));
+ pNewNode->pValue = (void *)pValue;
+ /*printf("LinkedList:::: Pointer=%p has been added.\n", pNewNode->pValue); */
+ /* add new node on the root to implement quick FIFO */
+ /* modify new node pointers */
+ if(LinkedList->pRoot == NULL) {
+ pNewNode->pNextNode = NULL;
+ }
+ else {
+ pNewNode->pNextNode = LinkedList->pRoot;
+ }
+ /*modify root */
+ LinkedList->pRoot = pNewNode;
+}
+
+void LinkedList_FreeElement(LinkedList *LinkedList, void *pValue) {
+ Node *pNode = LinkedList->pRoot;
+ Node *pPastNode = NULL;
+ while (pNode != NULL) {
+ if (pNode->pValue == pValue) {
+ Node *pTempNode = pNode->pNextNode;
+ if(pPastNode == NULL) {
+ LinkedList->pRoot = pTempNode;
+ }
+ else {
+ pPastNode->pNextNode = pTempNode;
+ }
+ /*printf("LinkedList:::: Pointer=%p has been freed\n", pNode->pValue); */
+ free(pNode->pValue);
+ free(pNode);
+ break;
+ }
+ pPastNode = pNode;
+ pNode = pNode->pNextNode;
+ }
+}
+
+void LinkedList_FreeAll(LinkedList *LinkedList) {
+ Node *pTempNode;
+ int nodes = 0;
+ while (LinkedList->pRoot != NULL) {
+ pTempNode = LinkedList->pRoot->pNextNode;
+ /*printf("LinkedList:::: Pointer=%p has been freed\n", LinkedList->pRoot->pValue); */
+ free(LinkedList->pRoot->pValue);
+ free(LinkedList->pRoot);
+ LinkedList->pRoot = pTempNode;
+ nodes++;
+ }
+ /*printf("==================No. of deleted nodes: %d=======================================\n\n", nodes); */
+}
+
+void LinkedList_DisplayAll(LinkedList *LinkedList) {
+ Node *pNode = LinkedList->pRoot;
+ int nodes = 0;
+ printf("\n================== Displaying contents of linked list=%p=====================\n", LinkedList);
+ printf("root->\n");
+ while (pNode != NULL) {
+ printf("[Value=%p, NextNode=%p]->\n", pNode->pValue, pNode->pNextNode);
+ pNode = pNode->pNextNode;
+ nodes++;
+ }
+ printf("==================No. of existing nodes: %d=======================================\n\n", nodes);
+}
+
+void LinkedList_Destroy(LinkedList *LinkedList) {
+ /* do nothing */
+}
+
+
diff --git a/omx/image/src/openmax_il/jpeg_dec/src/OMX_JpegDecoder.c b/omx/image/src/openmax_il/jpeg_dec/src/OMX_JpegDecoder.c
index 213b820..9d14efb 100644
--- a/omx/image/src/openmax_il/jpeg_dec/src/OMX_JpegDecoder.c
+++ b/omx/image/src/openmax_il/jpeg_dec/src/OMX_JpegDecoder.c
@@ -195,7 +195,7 @@ static OMX_ERRORTYPE AllocateBuffer_JPEGDec(OMX_IN OMX_HANDLETYPE hComponent,
}
if (nPortIndex == JPEGDEC_INPUT_PORT) {
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr, OMX_BUFFERHEADERTYPE)
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr, sizeof(OMX_BUFFERHEADERTYPE));
OMX_CONF_INIT_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr, OMX_BUFFERHEADERTYPE);
OMX_PRBUFFER1(pComponentPrivate->dbg, "pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr = %p\n", pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr);
pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr->nOutputPortIndex = OMX_NOPORT;
@@ -211,7 +211,7 @@ static OMX_ERRORTYPE AllocateBuffer_JPEGDec(OMX_IN OMX_HANDLETYPE hComponent,
}
else if (nPortIndex == JPEGDEC_OUTPUT_PORT) {
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr, OMX_BUFFERHEADERTYPE);
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr, sizeof(OMX_BUFFERHEADERTYPE));
OMX_CONF_INIT_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr, OMX_BUFFERHEADERTYPE);
OMX_PRBUFFER1(pComponentPrivate->dbg, "pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBuffCount]->pBufferHdr = %p\n", pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr);
pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr->nOutputPortIndex = pPortDef->nPortIndex;
@@ -231,7 +231,7 @@ static OMX_ERRORTYPE AllocateBuffer_JPEGDec(OMX_IN OMX_HANDLETYPE hComponent,
}
if (nPortIndex == JPEGDEC_INPUT_PORT) {
- MALLOC(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr->pBuffer, OMX_U8, (nSizeBytes + 255));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr->pBuffer, nSizeBytes + 256);
pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr->pBuffer = (pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr->pBuffer) + 128;
#ifdef __PERF_INSTRUMENTATION__
@@ -243,7 +243,7 @@ static OMX_ERRORTYPE AllocateBuffer_JPEGDec(OMX_IN OMX_HANDLETYPE hComponent,
}
else if (nPortIndex == JPEGDEC_OUTPUT_PORT) {
- MALLOC(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr->pBuffer, OMX_U8, (nSizeBytes + 255));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr->pBuffer, nSizeBytes + 256);
pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr->pBuffer = pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr->pBuffer + 128;
#ifdef __PERF_INSTRUMENTATION__
@@ -350,7 +350,7 @@ static OMX_ERRORTYPE FreeBuffer_JPEGDec(OMX_IN OMX_HANDLETYPE hComponent,
pTemp = (OMX_U8*)(pBuffPrivate->pUALGParams);
pTemp -= 128;
(pBuffPrivate->pUALGParams) = (JPEGDEC_UAlgInBufParamStruct *)pTemp;
- free(pBuffPrivate->pUALGParams);
+ OMX_FREE(pBuffPrivate->pUALGParams);
pBuffPrivate->pUALGParams = NULL;
}
}
@@ -361,7 +361,7 @@ static OMX_ERRORTYPE FreeBuffer_JPEGDec(OMX_IN OMX_HANDLETYPE hComponent,
pTemp = (OMX_U8*)(pBuffPrivate->pUALGParams);
pTemp -= 128;
(pBuffPrivate->pUALGParams) = (JPEGDEC_UAlgOutBufParamStruct *)pTemp;
- free(pBuffPrivate->pUALGParams);
+ OMX_FREE(pBuffPrivate->pUALGParams);
pBuffPrivate->pUALGParams = NULL;
}
}
@@ -382,13 +382,13 @@ static OMX_ERRORTYPE FreeBuffer_JPEGDec(OMX_IN OMX_HANDLETYPE hComponent,
OMX_PRBUFFER1(pComponentPrivate->dbg, "INTERNAL BUFFER USED , trying to free it.\n");
pBuffHead->pBuffer -= 128;
- free(pBuffHead->pBuffer);
+ OMX_FREE(pBuffHead->pBuffer);
pBuffHead->pBuffer = NULL;
}
}
if (pBuffHead) {
- free(pBuffHead);
+ OMX_FREE(pBuffHead);
pBuffHead = NULL;
}
@@ -490,11 +490,11 @@ static OMX_ERRORTYPE UseBuffer_JPEGDec(OMX_IN OMX_HANDLETYPE hComponent,
if (nPortIndex == JPEGDEC_INPUT_PORT) {
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr, OMX_BUFFERHEADERTYPE);
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr, sizeof(OMX_BUFFERHEADERTYPE));
*ppBufferHdr = pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr;
}
else if (nPortIndex == JPEGDEC_OUTPUT_PORT) {
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr, OMX_BUFFERHEADERTYPE);
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr, sizeof(OMX_BUFFERHEADERTYPE));
*ppBufferHdr = pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr;
}
else {
@@ -586,7 +586,9 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
OMX_CHECK_PARAM(hComponent);
pHandle = (OMX_COMPONENTTYPE *)hComponent;
- OMX_MALLOC_STRUCT(pHandle->pComponentPrivate, JPEGDEC_COMPONENT_PRIVATE);
+ LinkedList_Create(&AllocList);
+
+ OMX_MALLOC(pHandle->pComponentPrivate, sizeof(JPEGDEC_COMPONENT_PRIVATE));
pComponentPrivate = (JPEGDEC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
@@ -607,7 +609,7 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
pComponentPrivate->ComponentVersion.s.nVersionMinor = 0x00;
pComponentPrivate->ComponentVersion.s.nRevision = 0x00;
pComponentPrivate->ComponentVersion.s.nStep = 0x00;
- MALLOC(pComponentPrivate->cComponentName, char, COMP_MAX_NAMESIZE);
+ OMX_MALLOC(pComponentPrivate->cComponentName, COMP_MAX_NAMESIZE + 1);
strncpy(pComponentPrivate->cComponentName, cJPEGdecName, COMP_MAX_NAMESIZE);
pHandle->SetCallbacks = SetCallbacks_JPEGDec;
@@ -631,33 +633,33 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
#endif
/* Allocate memory for component data structures */
- OMX_MALLOC_STRUCT(pComponentPrivate->pPortParamType, OMX_PORT_PARAM_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pPriorityMgmt, OMX_PRIORITYMGMTTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT], JPEGDEC_PORT_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT], JPEGDEC_PORT_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pParamBufSupplier, OMX_PARAM_BUFFERSUPPLIERTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pParamBufSupplier, OMX_PARAM_BUFFERSUPPLIERTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortFormat, OMX_IMAGE_PARAM_PORTFORMATTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortFormat, OMX_IMAGE_PARAM_PORTFORMATTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pScalePrivate, OMX_CONFIG_SCALEFACTORTYPE); /* Scale Factor */
- OMX_MALLOC_STRUCT(pComponentPrivate->pSectionDecode, OMX_CUSTOM_IMAGE_DECODE_SECTION);
- OMX_MALLOC_STRUCT(pComponentPrivate->pSubRegionDecode, OMX_CUSTOM_IMAGE_DECODE_SUBREGION);
+ OMX_MALLOC(pComponentPrivate->pPortParamType, sizeof(OMX_PORT_PARAM_TYPE));
+ OMX_MALLOC(pComponentPrivate->pPriorityMgmt, sizeof(OMX_PRIORITYMGMTTYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT], sizeof(JPEGDEC_PORT_TYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT], sizeof(JPEGDEC_PORT_TYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pParamBufSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pParamBufSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortFormat, sizeof(OMX_IMAGE_PARAM_PORTFORMATTYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortFormat, sizeof(OMX_IMAGE_PARAM_PORTFORMATTYPE));
+ OMX_MALLOC(pComponentPrivate->pScalePrivate, sizeof(OMX_CONFIG_SCALEFACTORTYPE)); /* Scale Factor */
+ OMX_MALLOC(pComponentPrivate->pSectionDecode, sizeof(OMX_CUSTOM_IMAGE_DECODE_SECTION));
+ OMX_MALLOC(pComponentPrivate->pSubRegionDecode, sizeof(OMX_CUSTOM_IMAGE_DECODE_SUBREGION));
#ifdef KHRONOS_1_1
- OMX_MALLOC_STRUCT(pComponentPrivate->pAudioPortType, OMX_PORT_PARAM_TYPE);
+ OMX_MALLOC(pComponentPrivate->pAudioPortType, sizeof(OMX_PORT_PARAM_TYPE));
OMX_CONF_INIT_STRUCT(pComponentPrivate->pAudioPortType, OMX_PORT_PARAM_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pVideoPortType, OMX_PORT_PARAM_TYPE);
+ OMX_MALLOC(pComponentPrivate->pVideoPortType, sizeof(OMX_PORT_PARAM_TYPE));
OMX_CONF_INIT_STRUCT(pComponentPrivate->pVideoPortType, OMX_PORT_PARAM_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pOtherPortType, OMX_PORT_PARAM_TYPE);
+ OMX_MALLOC(pComponentPrivate->pOtherPortType, sizeof(OMX_PORT_PARAM_TYPE));
OMX_CONF_INIT_STRUCT(pComponentPrivate->pOtherPortType, OMX_PORT_PARAM_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompRole,OMX_PARAM_COMPONENTROLETYPE);
+ OMX_MALLOC(pComponentPrivate->pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
OMX_CONF_INIT_STRUCT(pComponentPrivate->pCompRole,OMX_PARAM_COMPONENTROLETYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pQuantTable, OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE);
+ OMX_MALLOC(pComponentPrivate->pQuantTable, sizeof(OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE));
OMX_CONF_INIT_STRUCT(pComponentPrivate->pQuantTable,OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE);
pComponentPrivate->pQuantTable->eQuantizationTable = OMX_IMAGE_QuantizationTableLuma;
- OMX_MALLOC_STRUCT(pComponentPrivate->pHuffmanTable, OMX_IMAGE_PARAM_HUFFMANTTABLETYPE);
+ OMX_MALLOC(pComponentPrivate->pHuffmanTable, sizeof(OMX_IMAGE_PARAM_HUFFMANTTABLETYPE));
OMX_CONF_INIT_STRUCT(pComponentPrivate->pHuffmanTable,OMX_IMAGE_PARAM_HUFFMANTTABLETYPE);
pComponentPrivate->pHuffmanTable->eHuffmanTable = OMX_IMAGE_HuffmanTableAC;
@@ -670,12 +672,12 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
#endif
for (i = 0;i<NUM_OF_BUFFERS;i++) {
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[i], JPEGDEC_BUFFER_PRIVATE);
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[i], sizeof(JPEGDEC_BUFFER_PRIVATE));
pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[i]->pBufferHdr = NULL;
}
for (i = 0;i<NUM_OF_BUFFERS;i++) {
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[i], JPEGDEC_BUFFER_PRIVATE);
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[i], sizeof(JPEGDEC_BUFFER_PRIVATE));
pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[i]->pBufferHdr = NULL;
}
@@ -829,39 +831,9 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
EXIT:
if(eError != OMX_ErrorNone){
- FREE(pComponentPrivate->cComponentName);
- FREE(pComponentPrivate->pPortParamType);
- FREE(pComponentPrivate->pPriorityMgmt);
- FREE(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pParamBufSupplier);
- FREE(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pParamBufSupplier);
- FREE(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortDef);
- FREE(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortDef);
- FREE(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortFormat);
- FREE(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortFormat);
- FREE(pComponentPrivate->pScalePrivate); /* Scale Factor */
- for (i = 0;i<NUM_OF_BUFFERS;i++) {
- FREE(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[i]);
- FREE(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pBufferPrivate[i]);
- }
- FREE(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]);
- FREE(pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]);
- FREE(pComponentPrivate->pScalePrivate);
- FREE(pComponentPrivate->pSectionDecode);
- FREE(pComponentPrivate->pSubRegionDecode);
-
-#ifdef KHRONOS_1_1
- FREE(pComponentPrivate->pAudioPortType);
- FREE(pComponentPrivate->pVideoPortType);
- FREE(pComponentPrivate->pOtherPortType);
- FREE(pComponentPrivate->pCompRole);
- FREE(pComponentPrivate->pQuantTable);
- FREE(pComponentPrivate->pHuffmanTable);
-#endif
-#ifdef __PERF_INSTRUMENTATION__
- PERF_Done(pComponentPrivate->pPERF);
- FREE(pComponentPrivate->pPERF);
-#endif
- FREE(pComponentPrivate);
+ /* LinkedList_DisplayAll (&AllocList); */
+ OMX_FREEALL();
+ LinkedList_Destroy(&AllocList);
}
return eError;
} /* End of OMX_ComponentInit */
@@ -1197,8 +1169,8 @@ static OMX_ERRORTYPE GetParameter_JPEGDec(OMX_IN OMX_HANDLETYPE hComponent,
break;
case OMX_IndexParamPortDefinition:
- OMX_PRINT1(pComponentPrivate->dbg, "get param %lu\n", ((OMX_PARAM_PORTDEFINITIONTYPE *)(ComponentParameterStructure))->nPortIndex);
- OMX_PRINT1(pComponentPrivate->dbg, " port 0 enable: %d\n", pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortDef->bEnabled);
+ OMX_PRINT1(pComponentPrivate->dbg, "get param %lu\n", ((OMX_PARAM_PORTDEFINITIONTYPE *)(ComponentParameterStructure))->nPortIndex);
+ OMX_PRINT1(pComponentPrivate->dbg, " port 0 enable: %d\n", pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortDef->bEnabled);
OMX_PRINT1(pComponentPrivate->dbg, " port 1 enable: %d\n", pComponentPrivate->pCompPort[JPEGDEC_OUTPUT_PORT]->pPortDef->bEnabled);
if (((OMX_PARAM_PORTDEFINITIONTYPE *)(ComponentParameterStructure))->nPortIndex == pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortDef->nPortIndex) {
memcpy(ComponentParameterStructure, pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
@@ -2265,14 +2237,14 @@ static OMX_ERRORTYPE Allocate_DSPResources_JPEGDec(OMX_IN JPEGDEC_COMPONENT_PRIV
nBufferCount = pComponentPrivate->pCompPort[nPortIndex]->nBuffCount;
if (nPortIndex == JPEGDEC_INPUT_PORT) {
- MALLOC(pUalgInpParams, JPEGDEC_UAlgInBufParamStruct, 256);
+ OMX_MALLOC(pUalgInpParams, sizeof(JPEGDEC_UAlgInBufParamStruct) + 256);
pTemp = (OMX_U8*)pUalgInpParams;
pTemp += 128;
pUalgInpParams = pTemp;
(pComponentPrivate->pCompPort[JPEGDEC_INPUT_PORT]->pBufferPrivate[nBufferCount]->pUALGParams) = (JPEGDEC_UAlgInBufParamStruct *)(pUalgInpParams);
}
else if (nPortIndex == JPEGDEC_OUTPUT_PORT) {
- MALLOC(pUalgOutParams, JPEGDEC_UAlgOutBufParamStruct, 256);
+ OMX_MALLOC(pUalgOutParams, sizeof(JPEGDEC_UAlgOutBufParamStruct) + 256);
pTemp = (OMX_U8*)pUalgOutParams;
pTemp += 128;
pUalgOutParams = pTemp;
diff --git a/omx/image/src/openmax_il/jpeg_dec/tests/JPEGTest.c b/omx/image/src/openmax_il/jpeg_dec/tests/JPEGTest.c
new file mode 100755
index 0000000..ddf59d7
--- /dev/null
+++ b/omx/image/src/openmax_il/jpeg_dec/tests/JPEGTest.c
@@ -0,0 +1,1608 @@
+
+/*
+ * Copyright 2001-2008 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.
+ */
+/* ====================================================================
+* Texas Instruments OMAP(TM) Platform Software
+* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
+*
+* Use of this software is controlled by the terms and conditions found
+* in the license agreement under which this software has been supplied.
+* ==================================================================== */
+#ifdef UNDER_CE
+#include <windows.h>
+#else
+#include <sys/stat.h>
+#include <sys/time.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sched.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/select.h>
+#include <time.h>
+#include <OMX_Component.h>
+#include "JPEGTest.h"
+
+/* DSP recovery includes */
+#include <qosregistry.h>
+#include <qosti.h>
+#include <dbapi.h>
+#include <DSPManager.h>
+#include <DSPProcessor.h>
+#include <DSPProcessor_OEM.h>
+
+#ifdef UNDER_CE
+#define PRINT printf
+#else
+/*#define OMX_DEB*/
+#ifdef OMX_DEB
+#define PRINT(str,args...) fprintf(stdout,"[%s] %s():%d: *** "str"",__FILE__,__FUNCTION__,__LINE__,##args)
+#else
+#define PRINT(str, args...)
+#endif
+#endif
+
+typedef unsigned char uchar;
+/**
+ * Pipe used to communicate back to the main thread from the component thread;
+**/
+
+int IpBuf_Pipe[2];
+int OpBuf_Pipe[2];
+int Event_Pipe[2];
+struct timeval tim;
+int DEINIT_FLAG = 0;
+int bPreempted=0;
+
+
+/* safe routine to get the maximum of 2 integers */
+
+inline int maxint(int a, int b)
+{
+ return(a>b) ? a : b;
+}
+
+
+ /*Define prototypes*/
+
+#ifdef DSP_MMU_FAULT_HANDLING
+int LoadBaseImage();
+#endif
+
+ static OMX_ERRORTYPE WaitForEvent_JPEG(OMX_HANDLETYPE* pHandle,
+ OMX_EVENTTYPE DesiredEvent,
+ OMX_U32 data,
+ OMX_STATETYPE DesiredState);
+
+
+static int Get16m(const void * Short)
+{
+ return(((uchar *)Short)[0] << 8) | ((uchar *)Short)[1];
+}
+
+void FixFrameSize ( IMAGE_INFO* imageinfo)
+{
+
+ int nWidth=imageinfo->nWidth, nHeight=imageinfo->nHeight;
+
+ /*round up if nWidth is not multiple of 32*/
+ ( (nWidth%32 ) !=0 ) ? nWidth=32 * ( ( nWidth/32 ) + 1 ) : nWidth;
+ PRINT("411 file new nWidth %d \n", nWidth);
+
+ /*round up if nHeight is not multiple of 16*/
+ ( (nHeight%16) !=0 ) ? nHeight=16 * ( ( nHeight/16 ) + 1 ) : nHeight;
+ PRINT("new nHeight %d \n", nHeight);
+
+ imageinfo->nWidth = nWidth;
+ imageinfo->nHeight = nHeight;
+}
+
+
+int GetYUVformat(uchar * Data)
+{
+ unsigned char Nf;
+ int j;
+ int temp_index;
+ int temp;
+ int image_format;
+ short H[4],V[4];
+
+ Nf = Data[7];
+
+
+ for (j = 0; j < Nf; j++)
+ {
+ temp_index = j * 3 + 7 + 2;
+ /*---------------------------------------------------------*/
+ /* H[j]: upper 4 bits of a byte, horizontal sampling fator. */
+ /* V[j]: lower 4 bits of a byte, vertical sampling factor. */
+ /*---------------------------------------------------------*/
+ H[j] = (0x0f & (Data[temp_index] >> 4));
+ V[j] = (0x0f & Data[temp_index]);
+ }
+
+ /*------------------------------------------------------------------*/
+ /* Set grayscale flag, namely if image is gray then set it to 1, */
+ /* else set it to 0. */
+ /*------------------------------------------------------------------*/
+ image_format = -1;
+
+
+ if (Nf == 1){
+ image_format = OMX_COLOR_FormatL8;
+ }
+
+
+ if (Nf == 3)
+ {
+ temp = (V[0]*H[0])/(V[1]*H[1]) ;
+
+ if (temp == 4 && H[0] == 2)
+ image_format = OMX_COLOR_FormatYUV420PackedPlanar;
+
+ if (temp == 4 && H[0] == 4)
+ image_format = OMX_COLOR_FormatYUV411Planar;
+
+ if (temp == 2)
+ image_format = OMX_COLOR_FormatCbYCrY; /* YUV422 interleaved, little endian */
+
+ if (temp == 1)
+ image_format = OMX_COLOR_FormatYUV444Interleaved;
+ }
+
+ return (image_format);
+
+}
+
+/*--------------------------------------------------------------------------
+* Parse the marker stream until SOS or EOI is seen;
+* ------------------------------------------------------------------------*/
+
+#ifdef UNDER_CE
+int ReadJpegSections (HANDLE infile,
+ IMAGE_INFO* imageinfo)
+#else
+int ReadJpegSections (FILE * infile,
+ IMAGE_INFO* imageinfo)
+#endif
+{
+ int a = 0;
+ long lSize = 0;
+#ifdef UNDER_CE
+ int got = 0;
+ int b = 0;
+ lSize = GetFileSize(infile, NULL );
+ SetFilePointer(infile, 0, NULL, FILE_BEGIN);
+#else
+ fseek (infile , 0 , SEEK_END);
+ lSize = ftell (infile);
+ rewind (infile);
+#endif
+
+ PRINT ("Size is %d \n", (int)lSize);
+ imageinfo->nProgressive = 0; /*Default value is non progressive*/
+
+
+#ifdef UNDER_CE
+ ReadFile(infile, &a, 1, &got, NULL);
+#else
+ a = fgetc(infile);
+#endif
+
+#ifdef UNDER_CE
+ ReadFile(infile, &b, 1, &got, NULL);
+ if ( a != 0xff || b != M_SOI ) {
+#else
+ if ( a != 0xff || fgetc(infile) != M_SOI ) {
+#endif
+ return 0;
+ }
+ for ( ;; ) {
+ int itemlen = 0;
+ int marker = 0;
+ int ll = 0,lh = 0, got = 0;
+ uchar * Data = NULL;
+
+ for ( a=0;a<7;a++ ) {
+#ifdef UNDER_CE
+ ReadFile(infile, &marker, 1, &got, NULL);
+#else
+ marker = fgetc(infile);
+#endif
+ PRINT("MARKER IS %x\n",marker);
+
+ if ( marker != 0xff ) {
+ break;
+ }
+ if ( a >= 6 ) {
+ PRINT("too many padding bytes\n");
+ if ( Data != NULL ) {
+ free(Data);
+ Data=NULL;
+ }
+ return 0;
+ }
+ }
+ if ( marker == 0xff ) {
+ /* 0xff is legal padding, but if we get that many, something's wrong.*/
+ PRINT("too many padding bytes!");
+ }
+
+ /* Read the length of the section.*/
+#ifdef UNDER_CE
+ ReadFile(infile, &lh, 1, &got, NULL);
+ ReadFile(infile, &ll, 1, &got, NULL);
+#else
+ lh = fgetc(infile);
+ ll = fgetc(infile);
+#endif
+
+ itemlen = (lh << 8) | ll;
+
+ if ( itemlen < 2 ) {
+ PRINT("invalid marker");
+ }
+
+ Data = (uchar *)malloc(itemlen);
+ if ( Data == NULL ) {
+ PRINT("Could not allocate memory");
+ }
+
+ /* Store first two pre-read bytes. */
+ Data[0] = (uchar)lh;
+ Data[1] = (uchar)ll;
+
+#ifdef UNDER_CE
+ ReadFile(infile, Data+2, itemlen-2, &got, NULL);
+#else
+ got = fread(Data+2, 1, itemlen-2, infile); /* Read the whole section.*/
+#endif
+ if ( got != itemlen-2 ) {
+ PRINT("Premature end of file?");
+ }
+
+ PRINT("Jpeg section marker 0x%02x size %d\n",marker, itemlen);
+ switch ( marker ) {
+
+ case M_SOS:
+ if ( Data != NULL ) {
+ free(Data);
+ Data=NULL;
+ }
+
+ return lSize;
+
+ case M_EOI:
+ PRINT("No image in jpeg!\n");
+ if ( Data != NULL ) {
+ free(Data);
+ Data=NULL;
+ }
+ return 0;
+
+ case M_COM: /* Comment section */
+
+ break;
+
+ case M_JFIF:
+
+ break;
+
+ case M_EXIF:
+
+ break;
+
+ case M_SOF2:
+ PRINT("nProgressive IMAGE!\n");
+ imageinfo->nProgressive=1;
+
+ case M_SOF0:
+ case M_SOF1:
+ case M_SOF3:
+ case M_SOF5:
+ case M_SOF6:
+ case M_SOF7:
+ case M_SOF9:
+ case M_SOF10:
+ case M_SOF11:
+ case M_SOF13:
+ case M_SOF14:
+ case M_SOF15:
+
+ imageinfo->nHeight = Get16m(Data+3);
+ imageinfo->nWidth = Get16m(Data+5);
+ imageinfo->format = GetYUVformat(Data);
+ switch (imageinfo->format) {
+ case OMX_COLOR_FormatYUV420PackedPlanar:
+ printf("APP:: Image chroma format is OMX_COLOR_FormatYUV420PackedPlanar\n");
+ break;
+ case OMX_COLOR_FormatYUV411Planar:
+ printf("APP:: Image chroma format is OMX_COLOR_FormatYUV411Planar\n");
+ break;
+ case OMX_COLOR_FormatCbYCrY:
+ printf("APP:: Image chroma format is OMX_COLOR_FormatYUV422Interleaved\n");
+ break;
+ case OMX_COLOR_FormatYUV444Interleaved:
+ printf("APP:: Image chroma format is OMX_COLOR_FormatYUV444Interleaved\n");
+ break;
+ case OMX_COLOR_FormatL8:
+ printf("APP:: Image chroma format is OMX_COLOR_FormatL8 \n");
+ break;
+ default:
+ printf("APP:: Cannot find Image chroma format \n");
+ imageinfo->format = OMX_COLOR_FormatUnused;
+ break;
+ }
+ printf("APP:: Image Width x Height = %u * %u\n", Get16m(Data+5), Get16m(Data+3) );
+ /*
+ PRINT("JPEG image is %uw * %uh,\n", Get16m(Data+3), Get16m(Data+5) );
+
+ if ( *(Data+9)==0x41 ) {
+ PRINT("THIS IS A YUV 411 ENCODED IMAGE \n" );
+ imageinfo->format= 1;
+ }
+ */
+
+ if ( Data != NULL ) {
+ free(Data);
+ Data=NULL;
+ }
+ break;
+ default:
+ /* Skip any other sections.*/
+ break;
+ }
+
+ if ( Data != NULL ) {
+ free(Data);
+ Data=NULL;
+ }
+ }
+
+
+ return 0;
+}
+
+
+
+OMX_ERRORTYPE EventHandler(OMX_HANDLETYPE hComponent,
+ OMX_PTR pAppData,
+ OMX_EVENTTYPE eEvent,
+ OMX_U32 nData1,
+ OMX_U32 data2,
+ OMX_PTR pEventData)
+{
+ JPEGD_EVENTPRIVATE MyEvent;
+
+ MyEvent.eEvent = eEvent;
+ MyEvent.nData1 = nData1;
+ MyEvent.nData2 = data2;
+ MyEvent.pAppData = pAppData;
+ MyEvent.pEventInfo = pEventData;
+
+ PRINT("eEvent = %x, nData1 = %x\n\n", eEvent, (unsigned int)nData1);
+
+ switch ( eEvent ) {
+ case OMX_EventCmdComplete:
+ PRINT ("Component State Changed To %ld\n", data2);
+ break;
+
+ case OMX_EventError:
+ if ( nData1 != OMX_ErrorNone ){
+ printf ("APP:: ErrorNotification received: Error Num %x,\tSeverity = %ld\n", (unsigned int)nData1, data2);
+ if ((nData1 == OMX_ErrorHardware) || (nData1 == OMX_ErrorInsufficientResources)){
+ printf("\nAPP:: OMX_ErrorHardware. Deinitialization of the component....\n\n");
+ break;
+ }
+ else if(nData1 == OMX_ErrorResourcesPreempted) {
+ bPreempted = 1;
+ PRINT("APP:: OMX_ErrorResourcesPreempted !\n\n");
+ }
+ else if(nData1 == OMX_ErrorInvalidState){
+ return OMX_ErrorNone;
+ }
+ else if(nData1 == OMX_ErrorTimeout){
+ return OMX_ErrorNone;
+ }
+ else {
+ DEINIT_FLAG = 1;
+ }
+ }
+ break;
+
+ case OMX_EventResourcesAcquired:
+ bPreempted = 0;
+ break;
+ case OMX_EventBufferFlag:
+ printf("APP:: OMX_EventBufferFlag received\n");
+ break;
+ case OMX_EventPortSettingsChanged:
+ case OMX_EventMax:
+ case OMX_EventMark:
+ break;
+
+ default:
+ break;
+ }
+
+ write(Event_Pipe[1], &MyEvent, sizeof(JPEGD_EVENTPRIVATE));
+
+ return OMX_ErrorNone;
+}
+
+
+
+void FillBufferDone (OMX_HANDLETYPE hComponent,
+ OMX_PTR ptr,
+ OMX_BUFFERHEADERTYPE* pBuffHead)
+{
+ PRINT("OutBufHeader %p, pBuffer = %p\n", pBuffHead, pBuffHead->pBuffer);
+ write(OpBuf_Pipe[1], &pBuffHead, sizeof(pBuffHead));
+ /* if (eError == -1) {
+ PRINT ("Error while writing in OpBuf_pipe from app\n");
+
+ }*/
+
+}
+
+
+
+
+void EmptyBufferDone(OMX_HANDLETYPE hComponent,
+ OMX_PTR ptr,
+ OMX_BUFFERHEADERTYPE* pBuffer)
+{
+ write(IpBuf_Pipe[1], &pBuffer, sizeof(pBuffer));
+ /* if (eError == -1) {
+ PRINT ("Error while writing in IpBuf_pipe from EmptyBufferDone\n");
+ }*/
+}
+
+
+
+#ifdef UNDER_CE
+int fill_data (OMX_BUFFERHEADERTYPE *pBuf,
+ HANDLE fIn, long lBuffUsed)
+#else
+int fill_data (OMX_BUFFERHEADERTYPE *pBuf,
+ FILE *fIn, int lBuffUsed)
+#endif
+{
+ int nRead;
+
+ PRINT(" checking buf address %x\n", (unsigned int)pBuf->pBuffer);
+
+#ifdef UNDER_CE
+ lSize = GetFileSize(fIn, NULL );
+ SetFilePointer(fIn, 0, NULL, FILE_BEGIN);
+#else
+ //fseek (fIn , 0 , SEEK_END);
+ //lSize = ftell (fIn);
+ //rewind (fIn);
+#endif
+
+#ifdef UNDER_CE
+ ReadFile(fIn, pBuf->pBuffer, lBuffUsed, &nRead, NULL);
+#else
+ nRead = fread(pBuf->pBuffer,1, lBuffUsed, fIn);
+#endif
+
+ PRINT ("printing lsize %d \n", (int) lBuffUsed);
+ PRINT( "Read %d bytes from file\n", nRead);
+
+ pBuf->nFilledLen = nRead;
+ return nRead;
+}
+/* This method will wait for the component to get to the event
+ * specified by the DesiredEvent input. */
+static OMX_ERRORTYPE WaitForEvent_JPEG(OMX_HANDLETYPE* pHandle,
+ OMX_EVENTTYPE DesiredEvent,
+ OMX_U32 nFDmax,
+ OMX_STATETYPE DesiredState)
+{
+ OMX_ERRORTYPE error = OMX_ErrorNone;
+ OMX_STATETYPE CurrentState;
+ OMX_COMPONENTTYPE *pComponent = (OMX_COMPONENTTYPE *)pHandle;
+ int nRetval;
+ sigset_t set;
+
+ while(1) {
+
+ error = pComponent->GetState(pHandle, &CurrentState);
+ if(error || CurrentState == DesiredState) {
+ break;
+ }
+
+ fd_set rfds;
+ FD_ZERO(&rfds);
+ FD_SET(Event_Pipe[0], &rfds);
+ sigemptyset(&set);
+ sigaddset(&set,SIGALRM);
+
+ nRetval = pselect(nFDmax+1, &rfds, NULL, NULL, NULL, &set);
+
+ if ( nRetval == -1 ) {
+#ifndef UNDER_CE
+ perror("select()");
+#endif
+ fprintf (stderr, " : Error \n");
+ break;
+ }
+
+ if ( nRetval == 0 ) {
+ PRINT("Waiting: Desired Event = %x, Desired State = %x \n",DesiredEvent, DesiredState);
+ }
+
+ if ( FD_ISSET(Event_Pipe[0], &rfds)) {
+
+ JPEGD_EVENTPRIVATE EventPrivate;
+ read(Event_Pipe[0], &EventPrivate, sizeof(JPEGD_EVENTPRIVATE));
+
+ if (EventPrivate.eEvent == DesiredEvent &&
+ EventPrivate.nData1 == OMX_CommandStateSet &&
+ EventPrivate.nData2 == DesiredState) {
+ PRINT("OMX_EventCmdComplete :: nData2 = %x\n", (unsigned int)EventPrivate.nData2);
+ break;
+ }
+ else if (EventPrivate.eEvent == OMX_EventError &&
+ EventPrivate.nData1 == OMX_ErrorInsufficientResources &&
+ DesiredState == OMX_StateIdle) {
+ printf("\n\n Received OMX_EventError: Error = 0x%x,\tSeverity = %ld\n\n", (unsigned int)EventPrivate.nData1, EventPrivate.nData2);
+ error = OMX_ErrorInsufficientResources;
+ break;
+ }
+ else if (EventPrivate.eEvent == OMX_EventError &&
+ EventPrivate.nData1 == OMX_ErrorResourcesLost &&
+ DesiredState == OMX_StateLoaded) {
+ printf("\n\n Received OMX_EventError: Error = 0x%x,\tSeverity = %ld\n\n", (unsigned int)EventPrivate.nData1, EventPrivate.nData2);
+ break;
+ }
+ }
+
+ }
+
+ PRINT("Exit from Wait For Event function JPEGD\n");
+ return error;
+}
+
+
+
+#ifdef UNDER_CE
+int _tmain(int argc, TCHAR **argv)
+#else
+int main(int argc, char** argv)
+#endif
+{
+
+ OMX_HANDLETYPE pHandle = NULL;
+ OMX_U32 AppData = 100;
+ OMX_CALLBACKTYPE JPEGCaBa = { (void *)EventHandler,
+ (void*) EmptyBufferDone,
+ (void*)FillBufferDone};
+
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_BOOL bError = OMX_FALSE;
+ int nRetval;
+ int nWidth;
+ int nHeight;
+ /*int nFramesent= 0;*/
+ long lBuffused;
+ int nOutformat;
+ int nResizeMode;
+ int nIndex1;
+ int nIndex2;
+ OMX_U32 nMCURow = 0;
+ OMX_U32 nXOrg = 0; /*Sectional decoding: X origin*/
+ OMX_U32 nYOrg = 0; /*Sectional decoding: Y origin*/
+ OMX_U32 nXLength = 0; /*Sectional decoding: X lenght*/
+ OMX_U32 nYLength = 0; /*Sectional decoding: Y lenght*/
+ OMX_U32 i = 0; /*Temporary counter*/
+
+ IMAGE_INFO* imageinfo = NULL;
+ OMX_PORT_PARAM_TYPE* pPortParamType = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE* pParamPortDef = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE* pInPortDef = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE* pOutPortDef = NULL;
+ OMX_CONFIG_SCALEFACTORTYPE* pScaleFactor = NULL;
+ OMX_PORT_PARAM_TYPE* pPortType = NULL;
+ OMX_CUSTOM_IMAGE_DECODE_SECTION* pSectionDecode = NULL;
+ OMX_CUSTOM_IMAGE_DECODE_SUBREGION* pSubRegionDecode = NULL;
+ OMX_CUSTOM_RESOLUTION *pMaxResolution = NULL;
+
+#ifdef UNDER_CE
+ TCHAR* szInFile = NULL;
+ TCHAR* szOutFile = NULL;
+ HANDLE fIn = NULL;
+ HANDLE fOut = NULL;
+ DWORD dwWritten;
+#else
+ char* szInFile = NULL;
+ char* szOutFile = NULL;
+ FILE* fIn = NULL;
+ FILE* fOut = NULL;
+#endif
+
+ int nFramesDecoded = 0;
+ double t1 = 0;
+ double t2 = 0;
+ /*int nCountstarted = 0;*/
+ OMX_S32 nPostProcCompId = 200;
+ /*int nDone = 0;*/
+ int nExternal= 0;
+ OMX_U8 * pTemp;
+ OMX_BUFFERHEADERTYPE* pInBuffHead[NUM_OF_BUFFERS];
+ OMX_BUFFERHEADERTYPE* pOutBuffHead[NUM_OF_BUFFERS];
+ OMX_U8* pInBuffer = NULL;
+ OMX_U8* pOutBuffer = NULL;
+ int nFdmax;
+ int nRead;
+ OMX_INDEXTYPE nCustomIndex = OMX_IndexMax;
+ OMX_U16 nBufferHdrSend = 0;
+ OMX_U16 nSampleFactor = 32;
+ OMX_U8 nNUM_OF_DECODING_BUFFERS = 1;
+ sigset_t set;
+ OMX_BOOL bWaitForLoaded = OMX_FALSE;
+ int nMaxFrames = 1;
+ OMX_BUFFERHEADERTYPE* pInBufferHdr;
+ struct timeval tv1, tv2;
+
+ /* validate command line args */
+ if ( (argc < 5) || ((argc > 7) && (argc < 11)) ||(argc > 11)) {
+#ifdef UNDER_CE
+ printf("usage: %S <input.jpg> <output.yuv> <nOutformat-1:420 4:422 9:RGB16 10: RGB24 11:RGB32 12:BGR32> <nResizeMode> <nRepeat> <nSections> <nXOrigin> <nYOrigin> <nXLenght> <nYLenght>\n",
+ argv[0]);
+#else
+ printf("usage: %s <input.jpg> <output.yuv> <nOutformat-1:Original(default) 4:422 9:RGB16 10: RGB24 11:RGB32 12:BGR32> <nResizeMode> <nRepeat> <nSections> <nXOrigin> <nYOrigin> <nXLenght> <nYLenght>\n",
+ argv[0]);
+#endif
+ printf("nResizeMode 100:No Rescaling\nnResizeMode 50:Rescale to 50 percent of original size \n");
+ printf("nResizeMode 25:Rescale to 25 percent of original size\nnResizeMode 12:Rescale to 12.5 percent of original size\n\n");
+ printf("Example ./JpegTestCommon patterns/shrek.jpg shrek.yuv 1 50 \n");
+ printf("Input: 720x480. Output: YUV420, 360x240\n\n");
+ printf("nRepeat: It is an optional parameter. Range is 0 to 100. Repeatedly encode the same frame 'nRepeat+1' times");
+ printf("Example ./JpegTestCommon patterns/shrek.jpg shrek.yuv 1 50 0\n");
+ printf("Example ./JpegTestCommon patterns/shrek.jpg shrek.yuv 1 50 9\n");
+ printf("Output: YUV420, 360x240\n\n");
+ printf("<nSections> It's an optional parameter. Values: 0, 1, 2, ...\n");
+ printf("Example ./JpegTestCommon patterns/shrek.jpg shrek.yuv 4 50 0 1\n");
+ printf("Output: YUV422, 360x240\n\n");
+ printf("SubRegion decode:\n");
+ printf("<nXOrigin> <nYOrigin> <nXLenght> <nYLenght>\n");
+ printf("Example ./JpegTestCommon patterns/shrek.jpg shrek.yuv 1 100 0 0 192 48 288 256\n");
+ printf("Output: YUV420, 288x256\n\n");
+ return -1;
+ }
+
+
+ szInFile = argv[1];
+ szOutFile = argv[2];
+#ifdef UNDER_CE
+ nOutformat = _wtoi(argv[3]);
+ nResizeMode = _wtoi(argv[4]);
+#else
+ nOutformat = atoi(argv[3]);
+ nResizeMode = atoi(argv[4]);
+#endif
+
+ if (argc >= 6){
+ nMaxFrames = atoi(argv[5]) + 1;
+ }
+
+ if(argc >= 7){
+ nMCURow = atoi(argv[6]);
+ if(nOutformat >= 9){
+ printf("\nAPP: WARNING Sectional decoding is not supported for RGB color formats\n\n");
+ nMCURow = 0;
+ }
+ if(nMCURow){
+ nNUM_OF_DECODING_BUFFERS = NUM_OF_BUFFERS;
+ }
+ else{
+ nNUM_OF_DECODING_BUFFERS = 1;
+ }
+ }
+
+ if(argc > 7){
+ nXOrg = atoi(argv[7]);
+ nYOrg = atoi(argv[8]);
+ nXLength = atoi(argv[9]);
+ nYLength = atoi(argv[10]);
+ }
+
+ imageinfo = (IMAGE_INFO *)malloc (sizeof (IMAGE_INFO ) );
+ pPortParamType = (OMX_PORT_PARAM_TYPE*)malloc(sizeof(OMX_PORT_PARAM_TYPE));
+ pParamPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*)malloc(sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ pInPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*)malloc(sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ pOutPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*)malloc(sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ pScaleFactor = (OMX_CONFIG_SCALEFACTORTYPE*)malloc(sizeof(OMX_CONFIG_SCALEFACTORTYPE));
+ pPortType = (OMX_PORT_PARAM_TYPE*)malloc(sizeof(OMX_PORT_PARAM_TYPE));
+ pSectionDecode = (OMX_CUSTOM_IMAGE_DECODE_SECTION*)malloc(sizeof(OMX_CUSTOM_IMAGE_DECODE_SECTION));
+ pSubRegionDecode = (OMX_CUSTOM_IMAGE_DECODE_SUBREGION*)malloc(sizeof(OMX_CUSTOM_IMAGE_DECODE_SUBREGION));
+ pMaxResolution = (OMX_CUSTOM_RESOLUTION *)malloc(sizeof(OMX_CUSTOM_RESOLUTION ));
+
+
+ printf("\n------------------------------------------------\n");
+ printf("OMX JPEG Decoder Test App built on " __DATE__ ":" __TIME__ "\n");
+ printf("------------------------------------------------\n");
+ printf("\nAPP:: Output File Name is %s \n", szOutFile);
+
+ /* Create a pipe used to queue data from the callback. */
+ nRetval = pipe(IpBuf_Pipe);
+ PRINT("Pipe InBuf_Pipe just created\n");
+ if ( nRetval != 0 ) {
+ fprintf(stderr, "Error:Fill Data Pipe failed to open\n");
+ goto EXIT;
+ }
+
+ PRINT("Pipe OpBuf_Pipe just created\n");
+ nRetval = pipe(OpBuf_Pipe);
+ if ( nRetval != 0 ) {
+ fprintf(stderr, "Error:Empty Data Pipe failed to open\n");
+ goto EXIT;
+ }
+
+ PRINT("Pipe Event_Pipe just created\n");
+ nRetval = pipe(Event_Pipe);
+ if ( nRetval != 0 ) {
+ fprintf(stderr, "Error:Empty Data Pipe failed to open\n");
+ goto EXIT;
+ }
+
+ /* save off the "max" of the handles for the selct statement */
+ nFdmax = maxint(IpBuf_Pipe[0], OpBuf_Pipe[0]);
+ nFdmax = maxint(Event_Pipe[0], nFdmax);
+
+#ifdef DSP_MMU_FAULT_HANDLING
+ /* LOAD BASE IMAGE FIRST TIME */
+ LoadBaseImage();
+#endif
+
+ eError = TIOMX_Init();
+ if ( eError != OMX_ErrorNone ) {
+ PRINT("%d :: Error returned by TIOMX_Init()\n",__LINE__);
+ goto EXIT;
+ }
+
+ /*--------------------------------------------------------------------------------
+ *
+ * Open the file of data to be rendered. Since this is a just sample
+ * application, the data is "rendered" to a test mixer. So, the test
+ * file better contain data that can be printed to the terminal w/o
+ * problems or you will not be a happy [JPEGTest.c] fill_data():473: *** Read 997386 bytes from file
+ **/
+ PRINT("Opening input & output file\n");
+#ifdef UNDER_CE
+ fOut = CreateFile(szOutFile, GENERIC_WRITE, 0,
+ NULL,CREATE_ALWAYS, 0, NULL);
+ if (INVALID_HANDLE_VALUE == fOut)
+ {
+ PRINT("Error: failed to create the output file %S\n",
+ szOutFile);
+ goto EXIT;
+ }
+
+ fIn = CreateFile(szInFile, GENERIC_READ, 0,
+ NULL,OPEN_EXISTING, 0, NULL);
+ if (INVALID_HANDLE_VALUE == fIn) {
+ PRINT("Error: failed to open the file %s for readonly\n" \
+ "access\n", szInFile);
+ goto EXIT;
+ }
+
+#else
+
+ fIn = fopen(szInFile, "r");
+ if ( fIn == NULL ) {
+ printf("\nError: failed to open the file <%s> for reading\n",
+ szInFile);
+ goto EXIT;
+ }
+ PRINT("APP:: File %s opened \n" , szInFile);
+#endif
+
+ lBuffused = ReadJpegSections(fIn , imageinfo);
+
+ if (lBuffused == 0) {
+ printf("The file size is 0. Maybe the format of the file is not correct\n");
+ goto EXIT;
+ }
+
+ /* Load the JPEGDecoder Component */
+
+ PRINT("Calling TIOMX_GetHandle\n");
+ eError = TIOMX_GetHandle(&pHandle,StrJpegDecoder, (void *)&AppData, &JPEGCaBa);
+ if ( (eError != OMX_ErrorNone) || (pHandle == NULL) ) {
+ fprintf (stderr,"Error in Get Handle function\n");
+ goto EXIT;
+ }
+
+ eError = OMX_GetParameter(pHandle, OMX_IndexParamImageInit, pPortType);
+ if ( eError != OMX_ErrorNone ) {
+ goto EXIT;
+ }
+
+
+ nIndex1 = pPortType->nStartPortNumber;
+ nIndex2 = nIndex1 + 1;
+ nHeight = imageinfo->nHeight;
+ nWidth = imageinfo->nWidth;
+
+ FixFrameSize(imageinfo);
+
+ pScaleFactor->xWidth = (int)nResizeMode;
+ pScaleFactor->xHeight = (int)nResizeMode;
+
+ eError = OMX_SetConfig (pHandle, OMX_IndexConfigCommonScale, pScaleFactor);
+ if ( eError != OMX_ErrorNone ) {
+ goto EXIT;
+ }
+
+ eError = OMX_GetParameter (pHandle, OMX_IndexParamPortDefinition, pInPortDef);
+ if ( eError != OMX_ErrorNone ) {
+ eError = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ if (pInPortDef->eDir == nIndex1 ) {
+ pInPortDef->nPortIndex = nIndex1;
+ }
+ else {
+ pInPortDef->nPortIndex = nIndex2;
+ }
+
+ /* Set the component's OMX_PARAM_PORTDEFINITIONTYPE structure (input) */
+ /**********************************************************************/
+
+ pInPortDef->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
+ pInPortDef->nVersion.s.nVersionMajor = 0x1;
+ pInPortDef->nVersion.s.nVersionMinor = 0x0;
+ pInPortDef->nVersion.s.nRevision = 0x0;
+ pInPortDef->nVersion.s.nStep = 0x0;
+ pInPortDef->nPortIndex = 0x0;
+ pInPortDef->eDir = OMX_DirInput;
+ pInPortDef->nBufferCountActual =1;
+ pInPortDef->nBufferCountMin = 1;
+ pInPortDef->bEnabled = OMX_TRUE;
+ pInPortDef->bPopulated = OMX_FALSE;
+ pInPortDef->eDomain = OMX_PortDomainImage;
+ pInPortDef->format.image.cMIMEType = "JPEGDEC";
+ pInPortDef->format.image.pNativeRender = NULL;
+ pInPortDef->format.image.nFrameWidth = imageinfo->nWidth;
+ pInPortDef->format.image.nFrameHeight = imageinfo->nHeight;
+ pInPortDef->format.image.nStride = -1;
+ pInPortDef->format.image.nSliceHeight = -1;
+ pInPortDef->format.image.bFlagErrorConcealment = OMX_FALSE;
+ pInPortDef->format.image.eColorFormat =OMX_COLOR_FormatCbYCrY ;
+ pInPortDef->format.image.eCompressionFormat = OMX_IMAGE_CodingJPEG;
+ pInPortDef->nBufferSize = lBuffused;
+
+
+ if (imageinfo->format == OMX_COLOR_FormatYCbYCr ||
+ imageinfo->format == OMX_COLOR_FormatYUV444Interleaved ||
+ imageinfo->format == OMX_COLOR_FormatUnused) {
+ pInPortDef->format.image.eColorFormat = OMX_COLOR_FormatCbYCrY;
+ }
+ else {
+ pInPortDef->format.image.eColorFormat = OMX_COLOR_FormatYUV420PackedPlanar;
+ }
+
+ PRINT("Calling OMX_SetParameter\n");
+
+ /* Set max width & height value*/
+ eError = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.decode.Param.SetMaxResolution", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+
+ pMaxResolution->nWidth = imageinfo->nWidth;
+ pMaxResolution->nHeight = imageinfo->nHeight;
+
+ eError = OMX_SetParameter (pHandle, nCustomIndex, pMaxResolution);
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+
+ eError = OMX_SetParameter (pHandle, OMX_IndexParamPortDefinition, pInPortDef);
+ if ( eError != OMX_ErrorNone ) {
+ eError = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ memset(pOutPortDef, 0x0, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ eError = OMX_GetParameter (pHandle, OMX_IndexParamPortDefinition, pOutPortDef);
+ if ( eError != OMX_ErrorNone ) {
+ eError = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ if (pOutPortDef->eDir == nIndex1 ) {
+ pOutPortDef->nPortIndex = nIndex1;
+ }
+ else {
+ pOutPortDef->nPortIndex = nIndex2;
+ }
+
+ /*****************************************************************/
+ /* Set the component's OMX_PARAM_PORTDEFINITIONTYPE structure (Output) */
+ /**********************************************************************/
+ pOutPortDef->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
+ pOutPortDef->nVersion.s.nVersionMajor = 0x1;
+ pOutPortDef->nVersion.s.nVersionMinor = 0x0;
+ pOutPortDef->nVersion.s.nRevision = 0x0;
+ pOutPortDef->nVersion.s.nStep = 0x0;
+ pOutPortDef->nPortIndex = 0x1;
+ pOutPortDef->eDir = OMX_DirOutput;
+ pOutPortDef->nBufferCountActual = nNUM_OF_DECODING_BUFFERS;
+ pOutPortDef->nBufferCountMin = 1;
+ pOutPortDef->bEnabled = OMX_TRUE;
+ pOutPortDef->bPopulated = OMX_FALSE;
+ pOutPortDef->eDomain = OMX_PortDomainImage;
+
+ /* OMX_IMAGE_PORTDEFINITION values for Output port */
+ pOutPortDef->format.image.cMIMEType = "JPEGDEC";
+ pOutPortDef->format.image.pNativeRender = NULL;
+ pOutPortDef->format.image.nFrameWidth = imageinfo->nWidth;
+ pOutPortDef->format.image.nFrameHeight = imageinfo->nHeight;
+ pOutPortDef->format.image.nStride = -1;
+ pOutPortDef->format.image.nSliceHeight = -1;
+ pOutPortDef->format.image.bFlagErrorConcealment = OMX_FALSE;
+ pOutPortDef->format.image.eCompressionFormat = OMX_IMAGE_CodingUnused;
+
+ PRINT("nWidth and nHeight = %d and %d\n",nWidth,nHeight);
+ if ( nOutformat == 4 ) {
+ pOutPortDef->format.image.eColorFormat = OMX_COLOR_FormatCbYCrY;
+ }
+ else if (nOutformat == 9) {
+ pOutPortDef->format.image.eColorFormat = OMX_COLOR_Format16bitRGB565;
+ PRINT("color format is %d\n", pOutPortDef->format.image.eColorFormat);
+ }
+ else if (nOutformat == 10) {
+ pOutPortDef->format.image.eColorFormat = OMX_COLOR_Format24bitRGB888;
+ }
+ else if (nOutformat == 11) {
+ pOutPortDef->format.image.eColorFormat = OMX_COLOR_Format32bitARGB8888;
+ }
+ else if (nOutformat == 12) {
+ pOutPortDef->format.image.eColorFormat = OMX_COLOR_Format32bitBGRA8888;
+ }
+ else { /*Set DEFAULT (original) color format*/
+ pOutPortDef->format.image.eColorFormat = imageinfo->format; /*Setting input original format */
+
+ if(imageinfo->format == OMX_COLOR_Format16bitRGB565 ||
+ imageinfo->format == OMX_COLOR_Format24bitRGB888 ||
+ imageinfo->format == OMX_COLOR_Format32bitARGB8888 ||
+ imageinfo->format == OMX_COLOR_Format32bitBGRA8888 ||
+ imageinfo->format == OMX_COLOR_FormatL8){
+ for(i = 0; i < strlen(szOutFile); i++){
+ if(szOutFile[i]=='.'){
+ if(szOutFile[i+1]=='y'){
+ szOutFile[i+1]='r';
+ szOutFile[i+2]='a';
+ szOutFile[i+3]='w';
+ szOutFile[i+4]='\0';
+ printf("\n\nAPP::--WARNING:\nIncorrect output file extension. Changing output file name extension--\n");
+ printf("APP:: New file name: %s\n\n\n", szOutFile);
+ break;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ fOut = fopen(szOutFile, "w");
+ if ( fOut == NULL ) {
+ printf("\nError: failed to open the file <%s> for writing", szOutFile);
+ goto EXIT;
+ }
+
+ if(nResizeMode == 800){
+ nWidth *= 8;
+ nHeight *= 8;
+ }
+ else if(nResizeMode == 400){
+ nWidth *= 4;
+ nHeight *= 4;
+ }
+ else if(nResizeMode == 200){
+ nWidth *= 2;
+ nHeight *= 2;
+ }
+ else if (nResizeMode == 50) {
+ nWidth /= 2;
+ nHeight /= 2;
+ } else if (nResizeMode == 25) {
+ nWidth /= 4;
+ nHeight /= 4;
+ } else if (nResizeMode == 12) {
+ nWidth /= 4;
+ nHeight /= 4;
+ }
+
+ if(nMCURow == 0){ /*Full frame decoding*/
+ if ( nOutformat == 1 ) { /* Buffer size depends on the Original color format*/
+ if (imageinfo->format == OMX_COLOR_FormatYUV420PackedPlanar ||
+ imageinfo->format == OMX_COLOR_FormatYUV411Planar) {
+ pOutPortDef->nBufferSize = ( int )((( nWidth * nHeight) *3 ) /2);
+ }
+ else if (imageinfo->format == OMX_COLOR_FormatCbYCrY) {
+ pOutPortDef->nBufferSize = ( int ) ((nWidth * nHeight) *2);
+ }
+ else if (imageinfo->format == OMX_COLOR_FormatYUV444Interleaved) {
+ pOutPortDef->nBufferSize = ( int ) ((nWidth * nHeight) *3);
+ }
+ else {
+ pOutPortDef->nBufferSize = ( int ) (nWidth * nHeight) * 2;
+ }
+ }
+ else if (nOutformat == 4 || nOutformat == 9) { /* OMX_COLOR_FormatCbYCrY & OMX_COLOR_Format16bitRGB565*/
+ pOutPortDef->nBufferSize = (int)((nWidth * nHeight) * 2);
+ }
+ else if (nOutformat == 10) { /* OMX_COLOR_Format24bitRGB888 */
+ pOutPortDef->nBufferSize = (int) ((nWidth * nHeight) * 3);
+ }
+ else if (nOutformat == 11 || nOutformat == 12) { /* OMX_COLOR_Format32bitARGB8888 & OMX_COLOR_Format32bitBGRA8888*/
+ pOutPortDef->nBufferSize = (int) ((nWidth * nHeight) * 4);
+ }
+ else {
+ eError = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+ else{ /*Slice Decoding*/
+ switch(imageinfo->format){
+ case OMX_COLOR_FormatYUV420PackedPlanar:
+ nSampleFactor = 16;
+ break;
+ case OMX_COLOR_FormatYUV411Planar:
+ case OMX_COLOR_FormatCbYCrY:
+ case OMX_COLOR_FormatYUV444Interleaved:
+ nSampleFactor = 8;
+ break;
+ default:
+ nSampleFactor = 8;
+ break;
+ }
+
+
+ if(nResizeMode == 12){ /* setting to 13 instead of 12.5 */
+ nResizeMode = 13;
+ }
+
+ if ( nOutformat == 1 ) { /* Buffer size depends on the Original color format*/
+ if (imageinfo->format == OMX_COLOR_FormatYUV420PackedPlanar ||
+ imageinfo->format == OMX_COLOR_FormatYUV411Planar) {
+ pOutPortDef->nBufferSize = (OMX_U32)(((nWidth*3)/2)*(nSampleFactor*nMCURow*nResizeMode)/100);
+
+ }
+ else if (imageinfo->format == OMX_COLOR_FormatCbYCrY){
+ pOutPortDef->nBufferSize = (OMX_U32) ( (nWidth * 2) * (nSampleFactor * nMCURow*nResizeMode)/100);
+ }
+ else if (imageinfo->format == OMX_COLOR_FormatYUV444Interleaved) {
+ pOutPortDef->nBufferSize = (OMX_U32) ( (nWidth * 3) * (nSampleFactor * nMCURow*nResizeMode)/100);
+ }
+ else{
+ pOutPortDef->nBufferSize = (OMX_U32) ( (nWidth) * (nSampleFactor * nMCURow*nResizeMode)/100);
+ }
+ }
+ else if(nOutformat == 4){ /*YUV422 ILE */
+ pOutPortDef->nBufferSize = (OMX_U32)((nWidth * 2) * (nSampleFactor * nMCURow * nResizeMode)/100);
+ }
+ }
+
+ printf("APP:: Output buffer size is %ld\n", pOutPortDef->nBufferSize);
+ printf("APP:: Output color format is ");
+ if (nOutformat == 4){
+ printf("OMX_COLOR_FormatCbYCrY (YUV422ILE)\n");
+ }
+ else if (nOutformat == 9){
+ printf("OMX_COLOR_Format16bitRGB565 (RGB16)\n");
+ }
+ else if (nOutformat == 10){
+ printf("OMX_COLOR_Format24bitRGB888 (BGR24)\n");
+ }
+ else if (nOutformat == 11){
+ printf("OMX_COLOR_Format32bitARGB8888 (ARGB32)\n");
+ }
+ else if (nOutformat == 12){
+ printf("OMX_COLOR_Format32bitBGRA8888 (BGRA32)\n");
+ }
+ else{
+ if (imageinfo->format == OMX_COLOR_FormatYUV420PackedPlanar){
+ printf("OMX_COLOR_FormatYUV420PackedPlanar\n");
+ }
+ else if (imageinfo->format == OMX_COLOR_FormatYUV411Planar) {
+ printf("OMX_COLOR_FormatYUV411Planar\n");
+ }
+ else if (imageinfo->format == OMX_COLOR_FormatCbYCrY){
+ printf("OMX_COLOR_FormatCbYCrY (YUV422ILE)\n");
+ }
+ else if (imageinfo->format == OMX_COLOR_FormatYUV444Interleaved) {
+ printf("OMX_COLOR_FormatYUV444Interleaved\n");
+ }
+ else if (imageinfo->format == OMX_COLOR_FormatL8){
+ printf("OMX_COLOR_FormatL8 (Gray 8)\n");
+ }
+ else{
+ printf("Unknow format\n");
+ }
+ }
+
+ eError = OMX_SetParameter (pHandle, OMX_IndexParamPortDefinition, pOutPortDef);
+ if ( eError != OMX_ErrorNone ) {
+ eError = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ eError = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.decode.Config.ProgressiveFactor", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+ eError = OMX_SetConfig (pHandle, nCustomIndex, &(imageinfo->nProgressive));
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+
+ eError = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.decode.Config.OutputColorFormat", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+
+ eError = OMX_SetConfig (pHandle, nCustomIndex, &(pOutPortDef->format.image.eColorFormat));
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+
+ if(nMCURow){
+ eError = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.decode.Param.SectionDecode", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+ eError = OMX_GetParameter(pHandle, nCustomIndex, pSectionDecode);
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+ pSectionDecode->nMCURow = nMCURow; /*number of slices*/
+ pSectionDecode->bSectionsInput = OMX_FALSE; /*Should be false at input port. Unsupported slice dec at input port at the moment*/
+ pSectionDecode->bSectionsOutput = OMX_TRUE; /*Should be true if slice at output port*/
+ eError = OMX_SetParameter(pHandle, nCustomIndex, pSectionDecode);
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+ }
+
+ if(nXOrg || nYOrg || nXLength || nYLength){
+ eError = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.decode.Param.SubRegionDecode", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+
+ eError = OMX_GetParameter(pHandle, nCustomIndex, pSubRegionDecode);
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+
+ pSubRegionDecode->nXOrg = nXOrg;
+ pSubRegionDecode->nYOrg = nYOrg;
+ pSubRegionDecode->nXLength = nXLength;
+ pSubRegionDecode->nYLength = nYLength;
+ eError = OMX_SetParameter(pHandle, nCustomIndex, pSubRegionDecode);
+ if ( eError != OMX_ErrorNone ) {
+ printf ("JPEGDec test:: %d:error= %x\n", __LINE__, eError);
+ goto EXIT;
+ }
+ PRINT("pSubRegionDecode set\n");
+ }
+
+ /********* EXTERNAL BUFFER ****************/
+
+ if ( nExternal == 1 ) {
+ pTemp=(OMX_U8*)malloc(pInPortDef->nBufferSize+256);
+ pTemp+=128;
+ pInBuffer = pTemp;
+ pTemp=(OMX_U8*)malloc(pOutPortDef->nBufferSize+256);
+ pTemp+=128;
+ pOutBuffer = pTemp;
+
+ eError = OMX_UseBuffer(pHandle, &pInBuffHead[0], nIndex1, pInBuffHead, pInPortDef->nBufferSize, pInBuffer);
+ for(nBufferHdrSend = 0; (nBufferHdrSend < nNUM_OF_DECODING_BUFFERS); nBufferHdrSend++){
+ eError = OMX_UseBuffer(pHandle, &pOutBuffHead[nBufferHdrSend], nIndex2 , pOutBuffHead, pOutPortDef->nBufferSize, pOutBuffer);
+ }
+ }
+ else {
+
+ OMX_AllocateBuffer(pHandle, &pInBuffHead[0], nIndex1, (void *)&nPostProcCompId, pInPortDef->nBufferSize);
+
+ for(nBufferHdrSend = 0; (nBufferHdrSend < nNUM_OF_DECODING_BUFFERS); nBufferHdrSend++){
+ OMX_AllocateBuffer(pHandle, &pOutBuffHead[nBufferHdrSend], nIndex2, (void *)&nPostProcCompId, pOutPortDef->nBufferSize);
+ PRINT("APP:: AllocateBuff Hdr = %p ; pBuffer = %p\n", pOutBuffHead[nBufferHdrSend], pOutBuffHead[nBufferHdrSend]->pBuffer);
+ }
+
+ }
+
+ gettimeofday(&tv1, NULL);
+ eError = OMX_SendCommand(pHandle, OMX_CommandStateSet, OMX_StateIdle ,NULL);
+ if ( eError != OMX_ErrorNone ) {
+ fprintf (stderr,"Error from SendCommand-Idle(Init) State function\n");
+ goto EXIT;
+ }
+
+ WaitForEvent_JPEG(pHandle, OMX_EventCmdComplete, nFdmax, OMX_StateIdle);
+
+ PRINT("Transitioned to IDLE State\n");
+ /*PRINT("from loaded to idle: %ld %ld %ld %ld\n", tv1.tv_sec, tv1.tv_usec, tv2.tv_sec, tv2.tv_usec);*/
+
+ gettimeofday(&tv1, NULL);
+ eError = OMX_SendCommand(pHandle,OMX_CommandStateSet, OMX_StateExecuting, NULL);
+ if ( eError != OMX_ErrorNone ) {
+ fprintf (stderr,"eError from SendCommand-Executing State function\n");
+ goto EXIT;
+ }
+
+ WaitForEvent_JPEG(pHandle, OMX_EventCmdComplete, nFdmax, OMX_StateExecuting);
+ gettimeofday(&tv2, NULL);
+
+ PRINT("Transitioned to EXECUTE State\n");
+ /*PRINT("from idle to exec: %ld %ld %ld %ld\n", tv1.tv_sec, tv1.tv_usec, tv2.tv_sec, tv2.tv_usec);*/
+
+ rewind(fIn);
+ nRead = fill_data(pInBuffHead[0], fIn, lBuffused);
+
+#ifndef UNDER_CE
+
+ gettimeofday(&tim, NULL);
+ t1=tim.tv_sec+(tim.tv_usec/1000000.0);
+#endif
+
+ pInBuffHead[0]->nFilledLen = nRead;
+ pInBuffHead[0]->nFlags = OMX_BUFFERFLAG_EOS;
+
+ OMX_EmptyThisBuffer(pHandle, pInBuffHead[0]);
+ DEINIT_FLAG = 0;
+
+ if(nMCURow){
+ for(nBufferHdrSend = 0; nBufferHdrSend < nNUM_OF_DECODING_BUFFERS; nBufferHdrSend++){
+ OMX_FillThisBuffer(pHandle, pOutBuffHead[nBufferHdrSend]);
+ }
+ }
+ else{
+ OMX_FillThisBuffer(pHandle, pOutBuffHead[0]);
+ }
+
+ /** Handle the component's requests for data until we run out of data. Do this
+ * in a way that will allow the UI to continue to run (if there is a UI, which
+ * this sample application does NOT have)
+ **/
+
+ PRINT("\n\n\n*******************************************\n\n\n");
+
+ while (DEINIT_FLAG == 0){
+
+ if (bPreempted){
+ goto DEINIT2;
+ }
+
+ fd_set rfds;
+ FD_ZERO(&rfds);
+
+ FD_SET(IpBuf_Pipe[0], &rfds);
+ FD_SET(OpBuf_Pipe[0], &rfds);
+ FD_SET(Event_Pipe[0], &rfds);
+
+ sigemptyset(&set);
+ sigaddset(&set,SIGALRM);
+ nRetval = pselect(nFdmax+1, &rfds, NULL, NULL, NULL, &set);
+ if ( nRetval == -1 ) {
+#ifndef UNDER_CE
+ perror("select()");
+#endif
+ fprintf (stderr, " : Error \n");
+ break;
+ }
+
+ /**
+ * If FD_ISSET then there is data available in the pipe.
+ * Read it and get the buffer data out.
+ * Then re-fill the buffer and send it back.
+ **/
+ if ( FD_ISSET(Event_Pipe[0], &rfds)) {
+
+ JPEGD_EVENTPRIVATE EventPrivate;
+ read(Event_Pipe[0], &EventPrivate, sizeof(JPEGD_EVENTPRIVATE));
+ switch(EventPrivate.eEvent) {
+
+ case OMX_EventError:
+ DEINIT_FLAG = OMX_TRUE;
+ bError = OMX_TRUE;
+ printf("APP:: Waiting for OMX_StateInvalid... \n");
+ WaitForEvent_JPEG(pHandle, OMX_EventCmdComplete, nFdmax, OMX_StateInvalid);
+ printf("APP:: At Invalid state.\n");
+ goto EXIT;
+ break;
+
+ case OMX_EventBufferFlag:
+ printf("APP:: Unloading component...\n");
+ break;
+
+ default:
+ printf("APP:: Non-error event rise. Event -> 0x%x\n", EventPrivate.eEvent);
+ break;
+ }
+ }
+
+ if ( FD_ISSET(IpBuf_Pipe[0], &rfds)){
+ read(IpBuf_Pipe[0], &pInBufferHdr, sizeof(pInBufferHdr));
+
+ if ( (!nMCURow) && (nFramesDecoded < nMaxFrames)){
+ pInBuffHead[0]->nFilledLen = nRead;
+ pInBuffHead[0]->nFlags = OMX_BUFFERFLAG_EOS;
+ OMX_EmptyThisBuffer(pHandle, pInBufferHdr);
+ }
+ }
+
+ if ( FD_ISSET(OpBuf_Pipe[0], &rfds) ) {
+ OMX_BUFFERHEADERTYPE* pBuf;
+#ifndef UNDER_CE
+ gettimeofday(&tim, NULL);
+ t2=tim.tv_sec+(tim.tv_usec/1000000.0);
+ /* printf("\n%.6lf seconds elapsed\n", t2-t1); */
+#endif
+ read(OpBuf_Pipe[0], &pBuf, sizeof(pBuf));
+
+ PRINT("%d ::App: Read from OpBuf_Pipe OutBufHeader %p, nFilledLen = %d\n", __LINE__, pBuf, (int)pBuf->nFilledLen);
+
+#ifdef UNDER_CE
+ WriteFile(fOut, pBuf->pBuffer, pBuf->nFilledLen, &dwWritten, NULL);
+#else
+ fwrite(pBuf->pBuffer, 1, (int ) (int)pBuf->nFilledLen, fOut);
+ fflush(fOut);
+#endif
+
+ nFramesDecoded++;
+ PRINT("\n\n\n*******************************************\n\n\n");
+
+ if (( (nMCURow) && (pBuf->nFlags && OMX_BUFFERFLAG_EOS)) ||
+ ( (!nMCURow) && (nFramesDecoded >= nMaxFrames))){
+ break;
+ }
+ PRINT("---------------------------- Output Buff FRAME %d ----------------------------\n", nFramesDecoded);
+
+ eError = OMX_FillThisBuffer(pHandle, pBuf);
+ if ( eError != OMX_ErrorNone ) {
+ printf ("Error from OMX_FillThisBuffer\n");
+ goto EXIT;
+ }
+
+ if (!nMCURow){
+ rewind(fOut);
+ }
+ }
+ }/***** End of While Loop *****/
+
+ if (bError == OMX_FALSE){
+ PRINT("APP:: Sending back to Idle\n");
+
+ eError = OMX_SendCommand(pHandle,OMX_CommandStateSet, OMX_StateIdle, NULL);
+ if ( eError != OMX_ErrorNone ) {
+ fprintf (stderr,"Error from SendCommand-Idle(nStop) State function\n");
+ goto EXIT;
+ }
+ }
+DEINIT2:
+
+ if (bError == OMX_FALSE){
+ WaitForEvent_JPEG(pHandle, OMX_EventCmdComplete, nFdmax, OMX_StateIdle);
+
+ eError = OMX_SendCommand(pHandle,OMX_CommandStateSet, OMX_StateLoaded, NULL);
+ if ( eError != OMX_ErrorNone ) {
+ fprintf (stderr,"Error from SendCommand-Idle State function\n");
+ goto EXIT;
+ }
+
+ bWaitForLoaded = OMX_TRUE;
+ }
+//DEINIT1:
+
+ eError = OMX_SendCommand(pHandle, OMX_CommandPortDisable, 0x0, NULL);
+ if ( eError != OMX_ErrorNone ) {
+ fprintf (stderr,"APP:: Error from SendCommand-PortDisable function. Input port.\n");
+ goto EXIT;
+ }
+
+ eError = OMX_SendCommand(pHandle, OMX_CommandPortDisable, 0x1, NULL);
+ if ( eError != OMX_ErrorNone ) {
+ fprintf (stderr,"APP:: Error from SendCommand-PortDisable function. Output port.\n");
+ goto EXIT;
+ }
+
+ /* Free buffers */
+ if ( nExternal==1 )
+ {
+ pOutBuffer-=128;
+ pInBuffer-=128;
+ eError = OMX_FreeBuffer(pHandle, nIndex1, pInBuffHead[0]);
+ for(nBufferHdrSend = 0; nBufferHdrSend < nNUM_OF_DECODING_BUFFERS; nBufferHdrSend++){
+ eError = OMX_FreeBuffer(pHandle, nIndex2, pOutBuffHead[nBufferHdrSend]);
+ }
+
+ free(pOutBuffer);
+ free(pInBuffer);
+
+ }
+ else {
+ eError = OMX_FreeBuffer(pHandle, nIndex1, pInBuffHead[0]);
+ for (nBufferHdrSend = 0; nBufferHdrSend < nNUM_OF_DECODING_BUFFERS; nBufferHdrSend ++) {
+ eError = OMX_FreeBuffer(pHandle, nIndex2, pOutBuffHead[nBufferHdrSend]);
+ }
+ }
+
+ if (bWaitForLoaded && (bError == OMX_FALSE)){
+ WaitForEvent_JPEG(pHandle, OMX_EventCmdComplete, nFdmax, OMX_StateLoaded);
+ }
+
+EXIT:
+ if (pPortParamType) {
+ free(pPortParamType);
+ pPortParamType = NULL;
+ }
+ if (pParamPortDef) {
+ free(pParamPortDef);
+ pParamPortDef = NULL;
+ }
+ if (pInPortDef) {
+ free(pInPortDef);
+ pInPortDef = NULL;
+ }
+ if (pOutPortDef) {
+ free(pOutPortDef);
+ pOutPortDef = NULL;
+ }
+ if (imageinfo) {
+ free(imageinfo);
+ imageinfo = NULL;
+ }
+ if (pScaleFactor) {
+ free(pScaleFactor);
+ pScaleFactor = NULL;
+ }
+ if (pPortType) {
+ free(pPortType);
+ pPortType = NULL;
+ }
+ if(pSectionDecode){
+ free(pSectionDecode);
+ pSectionDecode = NULL;
+ }
+ if(pSubRegionDecode){
+ free(pSubRegionDecode);
+ pSubRegionDecode = NULL;
+ }
+ if(pMaxResolution) {
+ free(pMaxResolution);
+ pMaxResolution = NULL;
+ }
+
+ if ( fOut != NULL ) {
+ PRINT("Closing Output File\n");
+#ifdef UNDER_CE
+ CloseHandle(fOut);
+#else
+ fclose(fOut);
+#endif
+ }
+
+ if ( fIn != NULL ) {
+ PRINT("Closing Input File\n");
+#ifdef UNDER_CE
+ CloseHandle(fIn);
+#else
+ fclose(fIn);
+#endif
+ }
+
+ if (pHandle) {
+ eError = TIOMX_FreeHandle(pHandle);
+ if ( (eError != OMX_ErrorNone) ) {
+ fprintf (stderr,"Error in Free Handle function\n");
+ }
+ }
+
+#ifdef DSP_MMU_FAULT_HANDLING
+ if(bError) {
+ LoadBaseImage();
+ }
+#endif
+
+ eError = TIOMX_Deinit();
+ if ( eError != OMX_ErrorNone ) {
+ PRINT("Error returned by OMX_Init()\n");
+ goto EXIT;
+ }
+
+ return eError;
+}
+
+
+#ifdef DSP_MMU_FAULT_HANDLING
+
+int LoadBaseImage() {
+ unsigned int uProcId = 0; /* default proc ID is 0. */
+ unsigned int index = 0;
+
+ struct DSP_PROCESSORINFO dspInfo;
+ DSP_HPROCESSOR hProc;
+ DSP_STATUS status = DSP_SOK;
+ unsigned int numProcs;
+ char* argv[2];
+
+ argv[0] = "/lib/dsp/baseimage.dof";
+
+ status = (DBAPI)DspManager_Open(0, NULL);
+ if (DSP_FAILED(status)) {
+ printf("DSPManager_Open failed \n");
+ return -1;
+ }
+ while (DSP_SUCCEEDED(DSPManager_EnumProcessorInfo(index,&dspInfo,
+ (unsigned int)sizeof(struct DSP_PROCESSORINFO),&numProcs))) {
+ if ((dspInfo.uProcessorType == DSPTYPE_55) ||
+ (dspInfo.uProcessorType == DSPTYPE_64)) {
+ uProcId = index;
+ status = DSP_SOK;
+ break;
+ }
+ index++;
+ }
+ status = DSPProcessor_Attach(uProcId, NULL, &hProc);
+ if (DSP_SUCCEEDED(status)) {
+ status = DSPProcessor_Stop(hProc);
+ if (DSP_SUCCEEDED(status)) {
+ status = DSPProcessor_Load(hProc,1,(const char **)argv,NULL);
+ if (DSP_SUCCEEDED(status)) {
+ status = DSPProcessor_Start(hProc);
+ if (DSP_SUCCEEDED(status)) {
+ }
+ else {
+ }
+ }
+ else {
+ }
+ DSPProcessor_Detach(hProc);
+ }
+ else {
+ }
+ }
+ else {
+ }
+ fprintf(stderr,"Baseimage Loaded\n");
+
+ return 0;
+}
+#endif
+
diff --git a/omx/image/src/openmax_il/jpeg_dec/tests/JPEGTest.h b/omx/image/src/openmax_il/jpeg_dec/tests/JPEGTest.h
new file mode 100755
index 0000000..ed5f72b
--- /dev/null
+++ b/omx/image/src/openmax_il/jpeg_dec/tests/JPEGTest.h
@@ -0,0 +1,118 @@
+
+/*
+ * Copyright 2001-2008 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.
+ */
+/**
+ * Global data used communicate state changes back to the applicaiton. This probably
+ * should really be via a pipe or some other protected mechanism for better
+ * reliability, but this is sufficient for a demo.
+**/
+/*Not used anymore in 2430*/
+/*static volatile OMX_State gComponentState = OMX_STATE_INVALID;*/
+
+#ifndef OMX_TESTDEC_H
+#define OMX_TESTDEC_H
+
+
+#ifndef UNDER_CE
+#include <unistd.h>
+#include <signal.h>
+#endif
+
+#include <OMX_Core.h>
+#include <OMX_Types.h>
+#include <OMX_Image.h>
+
+/* this implements the function for initializing the debug handle */
+
+#define NUM_OF_BUFFERS 4
+
+
+#define M_SOF0 0xC0 /* nStart Of Frame N*/
+#define M_SOF1 0xC1 /* N indicates which compression process*/
+#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use*/
+#define M_SOF3 0xC3
+#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers*/
+#define M_SOF6 0xC6
+#define M_SOF7 0xC7
+#define M_SOF9 0xC9
+#define M_SOF10 0xCA
+#define M_SOF11 0xCB
+#define M_SOF13 0xCD
+#define M_SOF14 0xCE
+#define M_SOF15 0xCF
+#define M_SOI 0xD8 /* nStart Of Image (beginning of datastream)*/
+#define M_EOI 0xD9 /* End Of Image (end of datastream)*/
+#define M_SOS 0xDA /* nStart Of Scan (begins compressed data)*/
+#define M_JFIF 0xE0 /* Jfif marker*/
+#define M_EXIF 0xE1 /* Exif marker*/
+#define M_COM 0xFE /* COMment */
+#define M_DQT 0xDB
+#define M_DHT 0xC4
+#define M_DRI 0xDD
+
+#define DSP_MMU_FAULT_HANDLING
+
+typedef struct IMAGE_INFO {
+ int nWidth;
+ int nHeight ;
+ int format;
+ int nProgressive;
+
+} IMAGE_INFO;
+
+#ifdef UNDER_CE
+OMX_STRING StrJpegDecoder= "OMX.TI.IMAGE.JPEG.DEC";
+#else
+OMX_STRING StrJpegDecoder= "OMX.TI.JPEG.Decoder";
+#endif
+
+
+typedef struct JPEGD_EVENTPRIVATE {
+ OMX_EVENTTYPE eEvent;
+ OMX_PTR pAppData;
+ OMX_PTR pEventInfo;
+ OMX_U32 nData1;
+ OMX_U32 nData2;
+}JPEGD_EVENTPRIVATE;
+
+typedef struct OMX_CUSTOM_IMAGE_DECODE_SECTION
+{
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_U32 nMCURow;
+ OMX_U32 nAU;
+ OMX_BOOL bSectionsInput;
+ OMX_BOOL bSectionsOutput;
+}OMX_CUSTOM_IMAGE_DECODE_SECTION;
+
+
+typedef struct OMX_CUSTOM_IMAGE_DECODE_SUBREGION
+{
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_U32 nXOrg; /*Sectional decoding: X origin*/
+ OMX_U32 nYOrg; /*Sectional decoding: Y origin*/
+ OMX_U32 nXLength; /*Sectional decoding: X lenght*/
+ OMX_U32 nYLength; /*Sectional decoding: Y lenght*/
+}OMX_CUSTOM_IMAGE_DECODE_SUBREGION;
+
+typedef struct OMX_CUSTOM_RESOLUTION
+{
+ OMX_U32 nWidth;
+ OMX_U32 nHeight;
+} OMX_CUSTOM_RESOLUTION;
+
+#endif /*OMX_TESTDEC_H*/
diff --git a/omx/image/src/openmax_il/jpeg_enc/Android.mk b/omx/image/src/openmax_il/jpeg_enc/Android.mk
index 4341ea8..631b250 100644
--- a/omx/image/src/openmax_il/jpeg_enc/Android.mk
+++ b/omx/image/src/openmax_il/jpeg_enc/Android.mk
@@ -14,9 +14,27 @@ LOCAL_C_INCLUDES := $(TI_OMX_COMP_C_INCLUDES) \
LOCAL_SHARED_LIBRARIES := $(TI_OMX_COMP_SHARED_LIBRARIES)
-
LOCAL_CFLAGS := $(TI_OMX_CFLAGS) -DOMAP_2430 #-DOMX_DEBUG
LOCAL_MODULE:= libOMX.TI.JPEG.Encoder
include $(BUILD_SHARED_LIBRARY)
+
+#########################################################
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= test/JPEGTestEnc.c
+
+LOCAL_C_INCLUDES := $(TI_OMX_COMP_C_INCLUDES) \
+ $(TI_OMX_IMAGE)/jpeg_enc/inc \
+
+LOCAL_SHARED_LIBRARIES := libOMX.TI.JPEG.Encoder
+
+LOCAL_CFLAGS := -Wall -fpic -pipe -O0 -DOMX_DEBUG=1
+
+LOCAL_MODULE:= JPEGTestEnc_common
+
+include $(BUILD_EXECUTABLE)
+
+
diff --git a/omx/image/src/openmax_il/jpeg_enc/inc/OMX_JpegEnc_CustomCmd.h b/omx/image/src/openmax_il/jpeg_enc/inc/OMX_JpegEnc_CustomCmd.h
index 868860f..fde450b 100644
--- a/omx/image/src/openmax_il/jpeg_enc/inc/OMX_JpegEnc_CustomCmd.h
+++ b/omx/image/src/openmax_il/jpeg_enc/inc/OMX_JpegEnc_CustomCmd.h
@@ -71,8 +71,6 @@ typedef struct JPEGENC_CUSTOM_HUFFMAN_TABLE {
OMX_U16 chm_ac_nsymbols;
}JPEGENC_CUSTOM_HUFFMAN_TABLE;
-
-
typedef struct JPEGENC_CUSTOM_HUFFMANTTABLETYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
@@ -80,13 +78,19 @@ typedef struct JPEGENC_CUSTOM_HUFFMANTTABLETYPE {
JPEGENC_CUSTOM_HUFFMAN_TABLE sHuffmanTable;
}JPEGENC_CUSTOM_HUFFMANTTABLETYPE;
-
-
-typedef struct _APP_INFO {
- OMX_U8 *app;
- OMX_U16 size;
-} APP_INFO;
-
+typedef struct JPEG_APPTHUMB_MARKER {
+ OMX_BOOL bMarkerEnabled; /* Boolean flag to enable/disable this marker on its whole */
+ OMX_U8 *pMarkerBuffer; /* This pointer must point to the marker buffer allocated by application */
+ OMX_U32 nMarkerSize; /* This variable holds the size of the marker buffer */
+ OMX_U32 nThumbnailWidth; /* This variable holds the thumbnail's width value (0 = No thumbnail) */
+ OMX_U32 nThumbnailHeight; /* This variable holds the thumbnail's height value (0 = No thumbnail) */
+} JPEG_APPTHUMB_MARKER;
+
+typedef struct JPEG_APP13_MARKER {
+ OMX_BOOL bMarkerEnabled; /* Boolean flag to enable/disable this marker on its whole */
+ OMX_U8 *pMarkerBuffer; /* This pointer must point to the marker buffer allocated by application */
+ OMX_U32 nMarkerSize; /* This variable holds the size of the marker buffer */
+} JPEG_APP13_MARKER;
#endif /* OMX_JPEGENC_CUSTOMCMD_H */
diff --git a/omx/image/src/openmax_il/jpeg_enc/inc/OMX_JpegEnc_Utils.h b/omx/image/src/openmax_il/jpeg_enc/inc/OMX_JpegEnc_Utils.h
index d4383b2..d59ab9d 100644
--- a/omx/image/src/openmax_il/jpeg_enc/inc/OMX_JpegEnc_Utils.h
+++ b/omx/image/src/openmax_il/jpeg_enc/inc/OMX_JpegEnc_Utils.h
@@ -1,4 +1,3 @@
-
/*
* Copyright (C) Texas Instruments - http://www.ti.com/
*
@@ -64,7 +63,7 @@
#include <OMX_Core.h>
#include <OMX_Types.h>
#include <OMX_Image.h>
-#include <OMX_TI_Common.h>
+#include<OMX_TI_Common.h>
#include <OMX_TI_Debug.h>
#ifdef RESOURCE_MANAGER_ENABLED
#include <ResourceManagerProxyAPI.h>
@@ -104,9 +103,32 @@
#define JPEGENC2MPImage 2000000
#endif
+#define DSP_MMU_FAULT_HANDLING
+
+/*Linked List */
+
+typedef struct Node {
+ struct Node *pNextNode;
+ void *pValue;
+} Node;
+
+typedef struct LinkedList {
+ Node *pRoot;
+} LinkedList;
+
+LinkedList AllocList;
+
+void LinkedList_Create(LinkedList *LinkedList);
+void LinkedList_AddElement(LinkedList *LinkedList, void *pValue);
+void LinkedList_FreeElement(LinkedList *LinkedList, void *pValue);
+void LinkedList_FreeAll(LinkedList *LinkedList);
+void LinkedList_DisplayAll(LinkedList *LinkedList);
+void LinkedList_Destroy(LinkedList *LinkedList);
+
/*
* M A C R O S
*/
+
#define OMX_CONF_INIT_STRUCT(_s_, _name_) \
memset((_s_), 0x0, sizeof(_name_)); \
(_s_)->nSize = sizeof(_name_); \
@@ -129,22 +151,27 @@
goto OMX_CONF_CMD_BAIL; \
}
-#define OMX_MALLOC_STRUCT(_pStruct_, _sName_) \
- _pStruct_ = (_sName_*)malloc(sizeof(_sName_)); \
+#define OMX_MALLOC(_pStruct_, _size_) \
+ _pStruct_ = malloc(_size_); \
if(_pStruct_ == NULL){ \
eError = OMX_ErrorInsufficientResources; \
goto EXIT; \
} \
- memset(_pStruct_, 0, sizeof(_sName_));
+ memset(_pStruct_, 0, _size_);\
+ LinkedList_AddElement(&AllocList, _pStruct_);
-#define OMX_MALLOC_STRUCT_EXTRA(_pStruct, _sName, _nExtraSize) \
- _pStruct = (_sName*)malloc(sizeof(_sName) + _nExtraSize); \
- if(_pStruct == NULL){ \
- eError = OMX_ErrorInsufficientResources; \
- goto EXIT; \
- } \
- memset(_pStruct, 0, (sizeof(_sName) + _nExtraSize));
+#define OMX_FREE(_ptr) \
+{ \
+ if (_ptr != NULL) { \
+ LinkedList_FreeElement(&AllocList, _ptr);\
+ _ptr = NULL; \
+ } \
+}
+#define OMX_FREEALL() \
+{ \
+ LinkedList_FreeAll(&AllocList);\
+}
#define OMX_MEMCPY_CHECK(_p_)\
{\
@@ -152,16 +179,9 @@
eError = OMX_ErrorInsufficientResources; \
goto EXIT; \
} \
-}
-
-#define FREE(_ptr) \
-{ \
- if (_ptr != NULL) { \
- free(_ptr); \
- _ptr = NULL; \
- } \
}
+
#ifdef RESOURCE_MANAGER_ENABLED
#define OMX_GET_RM_VALUE(_Res_, _RM_, _dbg_) \
{ \
@@ -207,27 +227,43 @@ typedef struct IIMGENC_DynamicParams {
/* The array "chm_quant_tab" defines the quantization table for the chroma component. */
OMX_U16 chm_quant_tab[64];
} IDMJPGE_TIGEM_CustomQuantTables;
-
+
typedef struct IDMJPGE_TIGEM_DynamicParams {
IIMGENC_DynamicParams params;
- OMX_U32 captureHeight; /* if set to 0 use image height
+ OMX_U32 captureHeight; /* if set to 0 use image height
else should set to actual Image height */
- OMX_U32 DRI_Interval ;
+ OMX_U32 DRI_Interval ;
JPEGENC_CUSTOM_HUFFMAN_TABLE *huffmanTable;
IDMJPGE_TIGEM_CustomQuantTables *quantTable;
} IDMJPGE_TIGEM_DynamicParams;
-#define OMX_JPEGENC_NUM_DLLS (3)
+#define __JPEG_OMX_PPLIB_ENABLED__
+
+#ifdef __JPEG_OMX_PPLIB_ENABLED__
+#define OMX_JPEGENC_NUM_DLLS (5)
+#else
+#define OMX_JPEGENC_NUM_DLLS (4)
+#endif
+
+
#ifdef UNDER_CE
#define JPEG_ENC_NODE_DLL "/windows/jpegenc_sn.dll64P"
#define JPEG_COMMON_DLL "/windows/usn.dll64P"
#define USN_DLL "/windows/usn.dll64P"
+#define CONVERSIONS_DLL "/windows/conversions.dll64P"
+ #ifdef __JPEG_OMX_PPLIB_ENABLED__
+ #define PPLIB_DLL "/windows/postprocessor_dualout.dll64P"
+ #endif
#else
#define JPEG_ENC_NODE_DLL "jpegenc_sn.dll64P"
#define JPEG_COMMON_DLL "usn.dll64P"
#define USN_DLL "usn.dll64P"
+#define CONVERSIONS_DLL "conversions.dll64P"
+ #ifdef __JPEG_OMX_PPLIB_ENABLED__
+ #define PPLIB_DLL "postprocessor_dualout.dll64P"
+ #endif
#endif
#define JPGENC_SNTEST_STRMCNT 2
@@ -262,27 +298,17 @@ typedef enum Content_Type
APP13_THUMB_H,
APP13_THUMB_W,
APP0_THUMB_INDEX,
- APP1_THUMB_INDEX,
+ APP1_THUMB_INDEX,
APP13_THUMB_INDEX,
DYNPARAMS_HUFFMANTABLE,
- DYNPARAMS_QUANTTABLE
+ DYNPARAMS_QUANTTABLE,
+ APP5_BUFFER,
+ APP5_NUMBUF,
+ APP5_THUMB_H,
+ APP5_THUMB_W,
+ APP5_THUMB_INDEX
} Content_Type;
-typedef struct _THUMBNAIL_INFO {
- OMX_U16 APP0_THUMB_INDEX;
- OMX_U16 APP0_THUMB_W;
- OMX_U16 APP0_THUMB_H;
- OMX_U16 APP1_THUMB_INDEX;
- OMX_U16 APP1_THUMB_W;
- OMX_U16 APP1_THUMB_H;
- OMX_U16 APP13_THUMB_INDEX;
- OMX_U16 APP13_THUMB_W;
- OMX_U16 APP13_THUMB_H;
- APP_INFO APP0_BUF;
- APP_INFO APP1_BUF;
- APP_INFO APP13_BUF;
-} THUMBNAIL_INFO;
-
/*This enum must not be changed. */
typedef enum JPEG_PORT_TYPE_INDEX
{
@@ -290,7 +316,6 @@ typedef enum JPEG_PORT_TYPE_INDEX
JPEGENC_OUT_PORT
}JPEG_PORT_TYPE_INDEX;
-
typedef enum JPEGENC_BUFFER_OWNER {
JPEGENC_BUFFER_CLIENT = 0x0,
JPEGENC_BUFFER_COMPONENT_IN,
@@ -298,31 +323,28 @@ typedef enum JPEGENC_BUFFER_OWNER {
JPEGENC_BUFFER_DSP,
JPEGENC_BUFFER_TUNNEL_COMPONENT
} JPEGENC_BUFFER_OWNER;
-
+
typedef struct _JPEGENC_BUFFERFLAG_TRACK {
OMX_U32 flag;
OMX_U32 buffer_id;
- OMX_HANDLETYPE hMarkTargetComponent;
+ OMX_HANDLETYPE hMarkTargetComponent;
OMX_PTR pMarkData;
} JPEGENC_BUFFERFLAG_TRACK;
typedef struct _JPEGENC_BUFFERMARK_TRACK {
OMX_U32 buffer_id;
- OMX_HANDLETYPE hMarkTargetComponent;
+ OMX_HANDLETYPE hMarkTargetComponent;
OMX_PTR pMarkData;
} JPEGENC_BUFFERMARK_TRACK;
-
typedef struct JPEGENC_BUFFER_PRIVATE {
- OMX_BUFFERHEADERTYPE* pBufferHdr;
+ OMX_BUFFERHEADERTYPE* pBufferHdr;
JPEGENC_BUFFER_OWNER eBufferOwner;
OMX_BOOL bAllocByComponent;
OMX_BOOL bReadFromPipe;
-} JPEGENC_BUFFER_PRIVATE;
-
+} JPEGENC_BUFFER_PRIVATE;
typedef struct JPEG_PORT_TYPE {
-
OMX_HANDLETYPE hTunnelComponent;
OMX_U32 nTunnelPort;
JPEGENC_BUFFER_PRIVATE* pBufferPrivate[NUM_OF_BUFFERSJPEG];
@@ -340,17 +362,14 @@ typedef struct JPEGE_INPUT_PARAMS {
OMX_U32 size;
} JPEGE_INPUT_PARAMS;
-typedef struct _JPEGENC_CUSTOM_PARAM_DEFINITION
-{
+typedef struct _JPEGENC_CUSTOM_PARAM_DEFINITION {
OMX_U8 cCustomParamName[128];
OMX_INDEXTYPE nCustomParamIndex;
} JPEGENC_CUSTOM_PARAM_DEFINITION;
-
-
typedef struct JPEGENC_COMPONENT_PRIVATE
{
- JPEG_PORT_TYPE* pCompPort[NUM_OF_PORTS];
+ JPEG_PORT_TYPE* pCompPort[NUM_OF_PORTS];
OMX_PORT_PARAM_TYPE* pPortParamType;
OMX_PORT_PARAM_TYPE* pPortParamTypeAudio;
OMX_PORT_PARAM_TYPE* pPortParamTypeVideo;
@@ -365,7 +384,7 @@ typedef struct JPEGENC_COMPONENT_PRIVATE
OMX_STRING cComponentName;
OMX_VERSIONTYPE ComponentVersion;
OMX_VERSIONTYPE SpecVersion;
-
+
/** Current state of this component */
OMX_STATETYPE nCurState;
OMX_STATETYPE nToState;
@@ -378,17 +397,17 @@ typedef struct JPEGENC_COMPONENT_PRIVATE
OMX_BOOL bInportDisableIncomplete;
OMX_BOOL bOutportDisableIncomplete;
OMX_BOOL bSetLumaQuantizationTable;
- OMX_BOOL bSetChromaQuantizationTable;
+ OMX_BOOL bSetChromaQuantizationTable;
OMX_BOOL bSetHuffmanTable;
OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE *pCustomLumaQuantTable;
- OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE *pCustomChromaQuantTable;
+ OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE *pCustomChromaQuantTable;
JPEGENC_CUSTOM_HUFFMANTTABLETYPE *pHuffmanTable;
-
-
+
+
/** The component thread handle */
pthread_t ComponentThread;
/** The pipes to maintain free buffers */
- int free_outBuf_Q[2];
+ int free_outBuf_Q[2];
/** The pipes to maintain input buffers sent from app*/
int filled_inpBuf_Q[2];
/** The pipes for sending buffers to the thread */
@@ -398,18 +417,24 @@ typedef struct JPEGENC_COMPONENT_PRIVATE
short int nNum_dspBuf;
int nCommentFlag;
OMX_U8 *pString_Comment;
- THUMBNAIL_INFO ThumbnailInfo;
+ JPEG_APPTHUMB_MARKER sAPP0;
+ JPEG_APPTHUMB_MARKER sAPP1;
+ JPEG_APPTHUMB_MARKER sAPP5;
+ JPEG_APP13_MARKER sAPP13;
JPEGE_INPUT_PARAMS InParams;
+#ifdef __JPEG_OMX_PPLIB_ENABLED__
+ OMX_U32 *pOutParams;
+#endif
#ifdef RESOURCE_MANAGER_ENABLED
RMPROXY_CALLBACKTYPE rmproxyCallback;
#endif
- OMX_BOOL bPreempted;
+ OMX_BOOL bPreempted;
int nFlags;
int nMarkPort;
- OMX_PTR pMarkData;
- OMX_HANDLETYPE hMarkTargetComponent;
+ OMX_PTR pMarkData;
+ OMX_HANDLETYPE hMarkTargetComponent;
OMX_BOOL bDSPStopAck;
- OMX_BOOL bFlushComplete;
+ OMX_BOOL bFlushComplete;
OMX_BOOL bAckFromSetStatus;
void* pLcmlHandle; /* Review Utils.c */
int isLCMLActive;
@@ -428,7 +453,8 @@ typedef struct JPEGENC_COMPONENT_PRIVATE
pthread_mutex_t jpege_mutex_app;
pthread_cond_t populate_cond;
pthread_cond_t unpopulate_cond;
-
+
+
#ifdef __PERF_INSTRUMENTATION__
PERF_OBJHANDLE pPERF, pPERFcomp;
#endif
@@ -448,12 +474,59 @@ OMX_ERRORTYPE HandleJpegEncFreeDataBuf( JPEGENC_COMPONENT_PRIVATE *pComponentPri
OMX_ERRORTYPE HandleJpegEncFreeOutputBufferFromApp( JPEGENC_COMPONENT_PRIVATE *pComponentPrivate );
OMX_ERRORTYPE AllocJpegEncResources( JPEGENC_COMPONENT_PRIVATE *pComponentPrivate );
OMX_ERRORTYPE JPEGEnc_Free_ComponentResources(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate);
-OMX_ERRORTYPE Fill_JpegEncLCMLInitParams(LCML_DSP *lcml_dsp, OMX_U16 arr[], OMX_HANDLETYPE pComponent);
+OMX_ERRORTYPE Fill_JpegEncLCMLInitParams(LCML_DSP *lcml_dsp, OMX_U16 arr[], OMX_HANDLETYPE pComponent);
OMX_ERRORTYPE GetJpegEncLCMLHandle(OMX_HANDLETYPE pComponent);
OMX_ERRORTYPE SetJpegEncInParams(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate);
OMX_ERRORTYPE SendDynamicParam(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate);
OMX_BOOL IsTIOMXComponent(OMX_HANDLETYPE hComp);
+#ifdef __JPEG_OMX_PPLIB_ENABLED__
+#define JPEGENC_PPLIB_CREATEPARAM_SIZE 28
+#define JPEGENC_PPLIB_DYNPARM_SIZE 252
+OMX_ERRORTYPE SendDynamicPPLibParam(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate,OMX_U32 *ptInputParam);
+
+
+
+typedef struct _PPLIB_UALGRunTimeParam_t
+{
+ OMX_U32 size; /**< Size of the structure in bytes. */
+ OMX_U32 ulInWidth; /**< Input picture buffer width. This value should be the same as the original decoded output width of the WMV9/VC1 stream. */
+ OMX_U32 ulInHeight; /**< Input picture buffer height. This value should be the same as the original decoded output height of the WMV9/VC1 stream. */
+ OMX_U32 ulFrameEnabled[2]; /**< It is possible to run the VGPOP twice with two separate sets of configuration parameters using PPLIB. This parameter specifies whether each set of configuration parameters is to be used when running PPLIB for this particular frame. */
+ OMX_U32 ulEnableYUVOutput[2]; /**< Flag to enable YUV output */
+ OMX_U32 ulEnableRGBOutput[2]; /**< Flag to enable RGB output. */
+ OMX_U32 ulFrameInputStartYOffset[2]; /**< Offset from the start of the input buffer where the input Y data is located. You can specify a different offset for each set of VGPOP parameters. In most cases, this will be 0. */
+ OMX_U32 ulFrameInputStartCOffset[2]; /**< Offset from the start of the input buffer where the input CrCb data is located. You can specify a different offset for each set of VGPOP parameters. In most cases, this will be the same as (input width * input height) + Y offset. */
+ OMX_U32 ulFrameOutputStartYOffset[2]; /**< Offset from the start of the output buffer where the output Y data should be placed. You can specify a different offset for each set of VGPOP parameters. */
+ OMX_U32 ulFrameOutputStartCOffset[2]; /**< Offset from the start of the output buffer where the output CrCb data should be placed. You can specify a different offset for each set of VGPOP parameters. In most cases, this will be the same as (output width * output height) + Y offset. */
+ OMX_U32 ulFrameOutputRGBOffset[2]; /**< Offset from the start of the output buffer where the output RGB data is located. You can specify a different offset for each set of VGPOP parameters. In most cases, this will be 0. */
+ OMX_U32 ulFrameOutputHeight[2]; /**< Output picture buffer height for each VGPOP parameter set.*/
+ OMX_U32 ulFrameOutputWidth[2]; /**< Output picture buffer width for each VGPOP parameter set. */
+ OMX_U32 ulFrameContrast[2]; /**< Contrast Method for each VGPOP parameter set */
+ OMX_U32 ulFrameInXStart[2]; /**< Horizontal cropping start position in the input buffer. Set to 0 if no cropping is desired. */
+ OMX_U32 ulFrameInYStart[2]; /**< Vertical cropping start position in the input buffer. Set to 0 if no cropping is desired.*/
+ OMX_U32 ulFrameInXSize[2]; /**< Horizontal cropping width. Set to 0 if no cropping is desired */
+ OMX_U32 ulFrameInYSize[2]; /**< Vertical cropping height. Set to 0 if no cropping is desired.*/
+ OMX_U32 ulFrameZoomFactor[2]; /**< Zooming ratio value, where ulZoomFactor = (Desired Zoom Ratio * 1024). Set to 1024 if no zooming is desired. Set above 1024 to enable zooming. */
+ OMX_U32 ulFrameZoomLimit[2]; /**< Zooming ratio limit, where ulZoomLimit=(Desired Zoom Limit * 1024).*/
+ OMX_U32 ulFrameZoomSpeed[2]; /**< Speed of ratio change. Set to 0 to disable zoom variation. The variation speed is proportional to the value while the direction (in/out) is given by the sign.*/
+ OMX_U32 ulFrameEnableLightChroma[2]; /**< Light chrominance process. */
+ OMX_U32 ulFrameEnableAspectRatioLock[2]; /**< Locked H/V ratio */
+ OMX_U32 ulFrameEnableMirroring[2]; /**< To mirror the picture: */
+ OMX_U32 ulFrameRGBRotation[2]; /**< Rotation to apply to RGB Output. May be set to 0, 90, 180 or 270.*/
+ OMX_U32 ulFrameYUVRotation[2]; /**< Rotation to apply to YUV Output. May be set to 0, 90, 180, or 270*/
+ OMX_U32 ulFrameIORange[2]; /**< IO Video Range. */
+ OMX_U32 ulFrameEnableDithering[2]; /**< Dithering Enable */
+ OMX_U32 ulFrameOutputPitch[2]; /**< Enable an output pitch */
+ OMX_U32 ulAlphaRGB[2]; /**< This is the default alpha values for ARGB32 or RGBA32. */
+ OMX_U32 ulIsFrameGenerated[2]; /**< Flag to notify the user if a frame has been generated */
+ OMX_U32 ulYUVFrameSize[2]; /**< YUV output size in bytes */
+ OMX_U32 ulRGBFrameSize[2]; /**< RGB output size in bytes. */
+} PPLIB_UALGRunTimeParam_t;
+
+
+
+#endif
typedef OMX_ERRORTYPE (*fpo)(OMX_HANDLETYPE);
@@ -470,6 +543,19 @@ static const struct DSP_UUID USN_UUID = {
}
};
+static const struct DSP_UUID CONVERSIONS_UUID = {
+ 0x722DD0DA, 0xF532, 0x4238, 0xB8, 0x46, {
+ 0xAB, 0xFF, 0x5D, 0xA4, 0xBA, 0x02
+ }
+};
+
+#ifdef __JPEG_OMX_PPLIB_ENABLED__
+static const struct DSP_UUID PPLIB_UUID = {
+ 0xFC8CF948, 0xD3E9, 0x4B65, 0xBC, 0xA7, {
+ 0x08, 0x2E, 0xA0, 0xAD, 0x86, 0xF0
+ }
+};
+#endif
void* OMX_JpegEnc_Thread (void* pThreadData);
typedef enum ThrCmdType
@@ -485,40 +571,29 @@ typedef enum ThrCmdType
EmptyBuf
} ThrCmdType;
-
-
-
typedef enum OMX_JPEGE_INDEXTYPE {
OMX_IndexCustomCommentFlag = 0xFF000001,
OMX_IndexCustomCommentString = 0xFF000002,
OMX_IndexCustomInputFrameWidth,
OMX_IndexCustomInputFrameHeight,
- OMX_IndexCustomThumbnailAPP0_INDEX,
- OMX_IndexCustomThumbnailAPP0_W,
- OMX_IndexCustomThumbnailAPP0_H,
- OMX_IndexCustomThumbnailAPP0_BUF,
- OMX_IndexCustomThumbnailAPP1_INDEX,
- OMX_IndexCustomThumbnailAPP1_W,
- OMX_IndexCustomThumbnailAPP1_H,
- OMX_IndexCustomThumbnailAPP1_BUF,
- OMX_IndexCustomThumbnailAPP13_INDEX,
- OMX_IndexCustomThumbnailAPP13_W,
- OMX_IndexCustomThumbnailAPP13_H,
- OMX_IndexCustomThumbnailAPP13_BUF,
+ OMX_IndexCustomAPP0,
+ OMX_IndexCustomAPP1,
+ OMX_IndexCustomAPP5,
+ OMX_IndexCustomAPP13,
OMX_IndexCustomQFactor,
OMX_IndexCustomDRI,
OMX_IndexCustomHuffmanTable,
- OMX_IndexCustomDebug,
+ OMX_IndexCustomDebug
}OMX_INDEXIMAGETYPE;
typedef struct IUALG_Buf {
- OMX_PTR pBufAddr;
+ OMX_PTR pBufAddr;
unsigned long ulBufSize;
OMX_PTR pParamAddr;
unsigned long ulParamSize;
unsigned long ulBufSizeUsed;
- //IUALG_BufState tBufState;
+ //IUALG_BufState tBufState;
OMX_BOOL bBufActive;
OMX_U32 unBufID;
unsigned long ulReserved;
diff --git a/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEnc_Thread.c b/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEnc_Thread.c
index 0aebd16..e50a556 100644
--- a/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEnc_Thread.c
+++ b/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEnc_Thread.c
@@ -55,7 +55,6 @@
#include <oaf_osal.h>
#include <omx_core.h>
#else
-#include <wchar.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -102,6 +101,7 @@ void* OMX_JpegEnc_Thread (void* pThreadData)
OMX_U32 nParam1;
sigset_t set;
+
OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pThreadData;
JPEGENC_COMPONENT_PRIVATE *pComponentPrivate = (JPEGENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
@@ -137,8 +137,8 @@ void* OMX_JpegEnc_Thread (void* pThreadData)
tv.tv_sec = 1;
tv.tv_usec = 0;
- sigemptyset(&set);
- sigaddset(&set,SIGALRM);
+ sigemptyset(&set) ;
+ sigaddset(&set,SIGALRM);
status = pselect (fdmax+1, &rfds, NULL, NULL, NULL,&set);
if ( 0 == status ) {
@@ -179,8 +179,8 @@ void* OMX_JpegEnc_Thread (void* pThreadData)
if ( FD_ISSET (pComponentPrivate->nCmdPipe[0], &rfds) ) {
/* Do not accept any command when the component is stopping */
OMX_PRCOMM2(pComponentPrivate->dbg, "CMD pipe is set in Component Thread\n");
- eCmd = 0;
- read (pComponentPrivate->nCmdPipe[0], &eCmd, sizeof(eCmd));
+
+ read (pComponentPrivate->nCmdPipe[0], &eCmd, sizeof (eCmd));
read (pComponentPrivate->nCmdDataPipe[0], &nParam1, sizeof (nParam1));
#ifdef __PERF_INSTRUMENTATION__
diff --git a/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEnc_Utils.c b/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEnc_Utils.c
index 120e8ec..1cad17c 100644
--- a/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEnc_Utils.c
+++ b/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEnc_Utils.c
@@ -51,12 +51,11 @@
/* ----- System and Platform Files ----------------------------*/
-#ifdef UNDER_CE
+#ifdef UNDER_CE
#include <windows.h>
#include <oaf_osal.h>
#include <omx_core.h>
#else
-#include <wchar.h>
#include <unistd.h>
#include <sys/types.h>
#include <malloc.h>
@@ -95,7 +94,7 @@
#endif
#define JPEGENC_TIMEOUT 0xFFFFFFFE
-
+
static OMX_ERRORTYPE HandleJpegEncInternalFlush(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1);
#ifdef RESOURCE_MANAGER_ENABLED
@@ -119,12 +118,12 @@ OMX_ERRORTYPE GetJpegEncLCMLHandle(OMX_HANDLETYPE pComponent)
OMX_ERRORTYPE eError = OMX_ErrorNone;
#ifndef UNDER_CE
OMX_HANDLETYPE LCML_pHandle;
-
+
OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent;
JPEGENC_COMPONENT_PRIVATE *pComponentPrivate = (JPEGENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
fpo fpGetHandle ;
void *handle = NULL;
- char *error = NULL;
+ char *error =NULL;
OMX_PRDSP1(pComponentPrivate->dbg, "Inside GetLCMLHandle function\n");
@@ -136,7 +135,6 @@ OMX_ERRORTYPE GetJpegEncLCMLHandle(OMX_HANDLETYPE pComponent)
}
fpGetHandle = dlsym (handle, "GetHandle");
- ;
if ( (error = (char *)dlerror()) != NULL ) {
fputs(error, stderr);
eError = OMX_ErrorInvalidComponent;
@@ -158,30 +156,30 @@ OMX_ERRORTYPE GetJpegEncLCMLHandle(OMX_HANDLETYPE pComponent)
pComponentPrivate->pLCML = (void *)LCML_pHandle;
pComponentPrivate->pLCML->pComponentPrivate = (JPEGENC_COMPONENT_PRIVATE *)pComponentPrivate;
#else
- typedef OMX_ERRORTYPE (*LPFNDLLFUNC1)(OMX_HANDLETYPE);
+ typedef OMX_ERRORTYPE (*LPFNDLLFUNC1)(OMX_HANDLETYPE);
LPFNDLLFUNC1 fpGetHandle1;
OMX_HANDLETYPE LCML_pHandle = NULL;
- OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent;
+ OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)pComponent;
JPEGENC_COMPONENT_PRIVATE *pComponentPrivate = (JPEGENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
- HINSTANCE hDLL;
-
+ HINSTANCE hDLL;
+
hDLL = LoadLibraryEx(TEXT("OAF_BML.dll"), NULL, 0);
if (hDLL == NULL)
{
eError = OMX_ErrorComponentNotFound;
goto EXIT;
}
-
+
fpGetHandle1 = (LPFNDLLFUNC1)GetProcAddress(hDLL,TEXT("GetHandle"));
if (!fpGetHandle1)
{
-
+
FreeLibrary(hDLL);
eError = OMX_ErrorComponentNotFound;
goto EXIT;
}
-
-
+
+
eError = fpGetHandle1(&LCML_pHandle);
if(eError != OMX_ErrorNone) {
@@ -189,7 +187,7 @@ OMX_ERRORTYPE GetJpegEncLCMLHandle(OMX_HANDLETYPE pComponent)
LCML_pHandle = NULL;
goto EXIT;
}
-
+
(LCML_DSP_INTERFACE*)pComponentPrivate->pLCML = (LCML_DSP_INTERFACE *)LCML_pHandle;
pComponentPrivate->pLCML->pComponentPrivate = (JPEGENC_COMPONENT_PRIVATE *)pComponentPrivate;
@@ -220,18 +218,18 @@ OMX_ERRORTYPE JpegEncDisablePort (JPEGENC_COMPONENT_PRIVATE* pComponentPrivate,
OMX_PRINT1(pComponentPrivate->dbg, "Inside DisablePort function\n");
OMX_PRBUFFER1(pComponentPrivate->dbg, "Inside disable port (%lu) %lu %lu %lu %lu\n",
- nParam1,
- pComponentPrivate->nInPortIn,
+ nParam1,
+ pComponentPrivate->nInPortIn,
pComponentPrivate->nInPortOut,
pComponentPrivate->nOutPortIn,
pComponentPrivate->nOutPortOut);
- if (pComponentPrivate->nCurState == OMX_StateExecuting || pComponentPrivate->nCurState == OMX_StatePause) {
+ if (pComponentPrivate->nCurState == OMX_StateExecuting || pComponentPrivate->nCurState == OMX_StatePause) {
if ((nParam1 == JPEGENC_INP_PORT) || (nParam1 == JPEGENC_OUT_PORT) || ((int)nParam1 == -1)) {
- eError = HandleJpegEncInternalFlush(pComponentPrivate, nParam1);
- }
- }
-
+ eError = HandleJpegEncInternalFlush(pComponentPrivate, nParam1);
+ }
+ }
+
EXIT:
OMX_PRINT1(pComponentPrivate->dbg, "Exit form JPEGEnc Disable Port eError is = %x\n",eError);
return eError;
@@ -306,7 +304,7 @@ OMX_ERRORTYPE JpegEncEnablePort (JPEGENC_COMPONENT_PRIVATE* pComponentPrivate, O
OMX_CommandPortEnable,
JPEGENC_INP_PORT,
NULL);
-
+
pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
OMX_EventCmdComplete,
@@ -339,15 +337,12 @@ OMX_ERRORTYPE JPEGEnc_Start_ComponentThread(OMX_HANDLETYPE pComponent)
OMX_COMPONENTTYPE *pHandle = NULL;
JPEGENC_COMPONENT_PRIVATE *pComponentPrivate = NULL;
+
OMX_CHECK_PARAM(pComponent);
pHandle = (OMX_COMPONENTTYPE *)pComponent;
pComponentPrivate = (JPEGENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
-
OMX_PRINT1(pComponentPrivate->dbg, "Inside JPEGEnc_Start_ComponentThread function\n");
-
- /* create the pipe used to maintain free input buffers*/
-
/* create the pipe used to maintain free output buffers*/
eError = pipe (pComponentPrivate->free_outBuf_Q);
if ( eError ) {
@@ -362,8 +357,6 @@ OMX_ERRORTYPE JPEGEnc_Start_ComponentThread(OMX_HANDLETYPE pComponent)
goto EXIT;
}
- /* create the pipe used to maintain dsp output/encoded buffers*/
-
/* create the pipe used to send commands to the thread */
eError = pipe (pComponentPrivate->nCmdPipe);
if ( eError ) {
@@ -425,10 +418,8 @@ OMX_ERRORTYPE JPEGEnc_Free_ComponentResources(JPEGENC_COMPONENT_PRIVATE *pCompon
OMX_ERRORTYPE err = OMX_ErrorNone;
int pipeError = 0;
int pthreadError = 0;
- int nCount = 0;
OMX_COMMANDTYPE eCmd = OMX_CustomCommandStopThread;
OMX_U32 nParam = 0;
- OMX_U8 *p;
struct OMX_TI_Debug dbg;
#ifdef __PERF_INSTRUMENTATION__
@@ -438,14 +429,12 @@ OMX_ERRORTYPE JPEGEnc_Free_ComponentResources(JPEGENC_COMPONENT_PRIVATE *pCompon
OMX_DBG_INIT_BASE(dbg);
OMX_CHECK_PARAM(pComponentPrivate);
- memcpy(&dbg, &pComponentPrivate->dbg, sizeof(dbg));
- OMX_PRINT1(dbg, "Inside JPEGEnc_Free_ComponentResources function\n");
- if ( pComponentPrivate &&
- pComponentPrivate->isLCMLActive ==1 ) {
- LCML_ControlCodec(((LCML_DSP_INTERFACE*)pComponentPrivate->pLCML)->pCodecinterfacehandle,EMMCodecControlDestroy,NULL);
- dlclose(pComponentPrivate->pDllHandle);
- pComponentPrivate->isLCMLActive = 0;
+ if ( pComponentPrivate->pLCML != NULL && pComponentPrivate->isLCMLActive) {
+ LCML_ControlCodec(((LCML_DSP_INTERFACE*)pComponentPrivate->pLCML)->pCodecinterfacehandle,EMMCodecControlDestroy,NULL);
+ dlclose(pComponentPrivate->pDllHandle);
+ pComponentPrivate->pLCML = NULL;
+ pComponentPrivate->isLCMLActive = 0;
}
pipeError = write(pComponentPrivate->nCmdPipe[1], &eCmd, sizeof(eCmd));
@@ -459,27 +448,27 @@ OMX_ERRORTYPE JPEGEnc_Free_ComponentResources(JPEGENC_COMPONENT_PRIVATE *pCompon
eError = OMX_ErrorHardware;
OMX_PRCOMM4(dbg, "Error while writing to nCmdPipe\n");
}
-
+
pthreadError = pthread_join (pComponentPrivate->ComponentThread,
(void*)&threadError);
if ( 0 != pthreadError ) {
eError = OMX_ErrorHardware;
OMX_TRACE4(dbg, "Error while closing Component Thread\n");
}
-
+
if ( OMX_ErrorNone != threadError && OMX_ErrorNone != eError ) {
eError = OMX_ErrorInsufficientResources;
OMX_TRACE4(dbg, "Error while closing Component Thread\n");
}
-
+
/* close the data pipe handles */
-
+
err = close (pComponentPrivate->free_outBuf_Q[0]);
if ( 0 != err && OMX_ErrorNone == eError ) {
eError = OMX_ErrorHardware;
OMX_PRCOMM4(dbg, "Error while closing data pipe\n");
}
-
+
err = close (pComponentPrivate->filled_inpBuf_Q[0]);
if ( 0 != err && OMX_ErrorNone == eError ) {
eError = OMX_ErrorHardware;
@@ -498,7 +487,7 @@ OMX_ERRORTYPE JPEGEnc_Free_ComponentResources(JPEGENC_COMPONENT_PRIVATE *pCompon
OMX_PRCOMM4(dbg, "Error while closing data pipe\n");
}
- /* Close the command pipe handles */
+ /* close the command pipe handles */
err = close (pComponentPrivate->nCmdPipe[0]);
if ( 0 != err && OMX_ErrorNone == eError ) {
eError = OMX_ErrorHardware;
@@ -511,7 +500,7 @@ OMX_ERRORTYPE JPEGEnc_Free_ComponentResources(JPEGENC_COMPONENT_PRIVATE *pCompon
OMX_PRCOMM4(dbg, "Error while closing cmd pipe\n");
}
- /* Close the command data pipe handles */
+ /* close the command data pipe handles */
err = close (pComponentPrivate->nCmdDataPipe[0]);
if ( 0 != err && OMX_ErrorNone == eError ) {
eError = OMX_ErrorHardware;
@@ -524,41 +513,6 @@ OMX_ERRORTYPE JPEGEnc_Free_ComponentResources(JPEGENC_COMPONENT_PRIVATE *pCompon
OMX_PRCOMM4(dbg, "Error while closing cmd pipe\n");
}
- FREE(pComponentPrivate->pPortParamType);
- FREE(pComponentPrivate->pPortParamTypeAudio);
- FREE(pComponentPrivate->pPortParamTypeVideo);
- FREE(pComponentPrivate->pPortParamTypeOthers);
- FREE(pComponentPrivate->pCustomLumaQuantTable);
- FREE(pComponentPrivate->pCustomChromaQuantTable);
- FREE(pComponentPrivate->pHuffmanTable);
- FREE(pComponentPrivate->pDynParams);
- FREE(pComponentPrivate->cComponentName);
- FREE(pComponentPrivate->pString_Comment);
-
- if (pComponentPrivate->InParams.pInParams) {
- p = (OMX_U8 *)pComponentPrivate->InParams.pInParams;
- p -= 128;
- FREE(p);
- pComponentPrivate->InParams.pInParams = NULL;
- pComponentPrivate->InParams.size = 0;
- }
-
- for (nCount = 0; nCount < NUM_OF_BUFFERSJPEG; nCount++) {
- FREE(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pBufferPrivate[nCount]);
- FREE(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pBufferPrivate[nCount]);
- }
-
- FREE(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortDef);
- FREE(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef);
- FREE(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortFormat);
- FREE(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortFormat);
- FREE(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pParamBufSupplier);
- FREE(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pParamBufSupplier);
- FREE(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]);
- FREE(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]);
- FREE (pComponentPrivate->pPriorityMgmt);
- FREE( pComponentPrivate->pQualityfactor );
-
pthread_mutex_destroy(&pComponentPrivate->jpege_mutex);
pthread_cond_destroy(&pComponentPrivate->stop_cond);
pthread_cond_destroy(&pComponentPrivate->flush_cond);
@@ -568,20 +522,20 @@ OMX_ERRORTYPE JPEGEnc_Free_ComponentResources(JPEGENC_COMPONENT_PRIVATE *pCompon
pthread_cond_destroy(&pComponentPrivate->populate_cond);
pthread_cond_destroy(&pComponentPrivate->unpopulate_cond);
#ifdef __PERF_INSTRUMENTATION__
- PERF_Boundary(pComponentPrivate->pPERF,
- PERF_BoundaryComplete | PERF_BoundaryCleanup);
- PERF_Done(pComponentPrivate->pPERF);
+ PERF_Boundary(pComponentPrivate->pPERF,
+ PERF_BoundaryComplete | PERF_BoundaryCleanup);
+ PERF_Done(pComponentPrivate->pPERF);
#endif
- FREE(pComponentPrivate );
-
- EXIT:
+ /* LinkedList_DisplayAll (&AllocList); */
+ OMX_FREEALL();
+ LinkedList_Destroy(&AllocList);
+
+EXIT:
OMX_PRINT1(dbg, "Exiting JPEG FreeComponentresources\n");
return eError;
}
-
-
OMX_ERRORTYPE Fill_JpegEncLCMLInitParams(LCML_DSP *lcml_dsp, OMX_U16 arr[], OMX_HANDLETYPE pComponent)
{
OMX_ERRORTYPE eError = OMX_ErrorNone;
@@ -589,8 +543,10 @@ OMX_ERRORTYPE Fill_JpegEncLCMLInitParams(LCML_DSP *lcml_dsp, OMX_U16 arr[], OMX_
JPEGENC_COMPONENT_PRIVATE *pComponentPrivate = NULL;
OMX_PARAM_PORTDEFINITIONTYPE* pPortDefOut = NULL;
OMX_PARAM_PORTDEFINITIONTYPE* pPortDefIn = NULL;
- int outbufsize = 0;
+ int outbufsize = 0;
+ OMX_U16 *ptCreateString = (OMX_U16*)arr;
+ OMX_U32 *ptCreateStringPPLIB = (OMX_U32*)arr;
OMX_CHECK_PARAM(pComponent);
pHandle = (OMX_COMPONENTTYPE *)pComponent;
@@ -621,76 +577,161 @@ OMX_ERRORTYPE Fill_JpegEncLCMLInitParams(LCML_DSP *lcml_dsp, OMX_U16 arr[], OMX_
strcpy ((char *)lcml_dsp->NodeInfo.AllUUIDs[2].DllName,USN_DLL);
lcml_dsp->NodeInfo.AllUUIDs[2].eDllType = DLL_DEPENDENT;
+ lcml_dsp->NodeInfo.AllUUIDs[3].uuid =(struct DSP_UUID * ) &CONVERSIONS_UUID;
+ strcpy ((char *)lcml_dsp->NodeInfo.AllUUIDs[3].DllName,CONVERSIONS_DLL);
+ lcml_dsp->NodeInfo.AllUUIDs[3].eDllType = DLL_DEPENDENT;
+
+#ifdef __JPEG_OMX_PPLIB_ENABLED__
+ lcml_dsp->NodeInfo.AllUUIDs[4].uuid =(struct DSP_UUID * ) &PPLIB_UUID;
+ strcpy ((char *)lcml_dsp->NodeInfo.AllUUIDs[4].DllName,PPLIB_DLL);
+ lcml_dsp->NodeInfo.AllUUIDs[4].eDllType = DLL_DEPENDENT;
+#endif
lcml_dsp->SegID = 0;
lcml_dsp->Timeout = -1;
lcml_dsp->Alignment = 0;
lcml_dsp->Priority = 5;
- lcml_dsp->ProfileID = -1;
-
- OMX_PRDSP2(pComponentPrivate->dbg, "Setting DSP variables.....\n");
+ if ((pPortDefIn->format.image.nFrameHeight * pPortDefIn->format.image.nFrameWidth) <= (352*288)) {
+ lcml_dsp->ProfileID = 2 ;
+ }
+ else if ((pPortDefIn->format.image.nFrameHeight * pPortDefIn->format.image.nFrameWidth) <= (640*480)) {
+ lcml_dsp->ProfileID = 2 +1 ; // temporary fix meanwhile SN confirms is there's any problem with VGA profile ID
+ }
+ else if ((pPortDefIn->format.image.nFrameHeight * pPortDefIn->format.image.nFrameWidth) <= (720*576)) {
+ lcml_dsp->ProfileID = 3 ;
+ }
+ else if ((pPortDefIn->format.image.nFrameHeight * pPortDefIn->format.image.nFrameWidth) <= (1*1024*1024)) {
+ lcml_dsp->ProfileID = 4 ;
+ }
+ else if ((pPortDefIn->format.image.nFrameHeight * pPortDefIn->format.image.nFrameWidth) <= (2*1024*1024)) {
+ lcml_dsp->ProfileID = 5 ;
+ }
+ else if ((pPortDefIn->format.image.nFrameHeight * pPortDefIn->format.image.nFrameWidth) <= (3*1024*1024)) {
+ lcml_dsp->ProfileID = 6 ;
+ }
+ else if ((pPortDefIn->format.image.nFrameHeight * pPortDefIn->format.image.nFrameWidth) <= (4*1024*1024)) {
+ lcml_dsp->ProfileID = 7 ;
+ }
+ else if ((pPortDefIn->format.image.nFrameHeight * pPortDefIn->format.image.nFrameWidth) <= (5*1024*1024)) {
+ lcml_dsp->ProfileID = 8 ;
+ }
+ else if ((pPortDefIn->format.image.nFrameHeight * pPortDefIn->format.image.nFrameWidth) <= (6*1024*1024)) {
+ lcml_dsp->ProfileID = 9 ;
+ }
+ else {
+ lcml_dsp->ProfileID = 10;
+ }
+
/* CrPhArgs for JpegEnc */
- arr[0] = JPGENC_SNTEST_STRMCNT;
- arr[1] = JPGENC_SNTEST_INSTRMID; /* Stream ID */
- arr[2] = 0; /* Stream based input stream */
- arr[3] = JPGENC_SNTEST_INBUFCNT; /* Number of buffers on input stream */
- arr[4] = JPGENC_SNTEST_OUTSTRMID;/* Stream ID */
- arr[5] = 0; /* Stream based input stream */
- arr[6] = JPGENC_SNTEST_OUTBUFCNT;/* Number of buffers on input stream */
-
- if(pPortDefOut->format.image.nFrameWidth > 0) {
- arr[7] = (OMX_U16)pPortDefOut->format.image.nFrameWidth;
- }
- else {
- arr[7] = (OMX_U16)JPGENC_SNTEST_MAX_WIDTH;
- }
-
- if(pPortDefOut->format.image.nFrameHeight > 0) {
- arr[8] = (OMX_U16)pPortDefOut->format.image.nFrameHeight;
- }
- else {
- arr[8] = (OMX_U16)JPGENC_SNTEST_MAX_HEIGHT;
- }
-
- /* arr[9] = 1; */
-
+ ptCreateString[0] = JPGENC_SNTEST_STRMCNT;
+ ptCreateString[1] = JPGENC_SNTEST_INSTRMID; /* Stream ID */
+ ptCreateString[2] = 0; /* Stream based input stream */
+ ptCreateString[3] = JPGENC_SNTEST_INBUFCNT; /* Number of buffers on input stream */
+ ptCreateString[4] = JPGENC_SNTEST_OUTSTRMID;/* Stream ID */
+ ptCreateString[5] = 0; /* Stream based input stream */
+ ptCreateString[6] = JPGENC_SNTEST_OUTBUFCNT;/* Number of buffers on input stream */
+ ptCreateString[7] = (pPortDefOut->format.image.nFrameWidth > 0) ? pPortDefOut->format.image.nFrameWidth : JPGENC_SNTEST_MAX_WIDTH;
+ ptCreateString[8] = (pPortDefOut->format.image.nFrameHeight > 0) ? pPortDefOut->format.image.nFrameHeight : JPGENC_SNTEST_MAX_HEIGHT;
+
/*
if ( pPortDefIn->format.image.eColorFormat == OMX_COLOR_FormatYUV420PackedPlanar ) {
arr[9] = 1;
} else if ( pPortDefIn->format.image.eColorFormat == OMX_COLOR_FormatCbYCrY ) {
- arr[9] = 4;
+ arr[9] = 4;
} else {
arr[9] = 4;
}
*/
- arr[9] = 1;
-
- arr[10] = 320; /* Maximum Horizontal Size of the Thumbnail for App0 marker */
- arr[11] = 240; /* Maximum Vertical Size of the Thumbnail for App0 marker */
- arr[12] = 320; /* Maximum Horizontal Size of the Thumbnail for App1 marker */
- arr[13] = 240; /* Maximum Vertical Size of the Thumbnail for App1 marker */
- arr[14] = 320; /* Maximum Horizontal Size of the Thumbnail for App13 marker */
- arr[15] = 240; /* Maximum Vertical Size of the Thumbnail for App13 marker */
- arr[16] = END_OF_CR_PHASE_ARGS;
-
+ ptCreateString[9] = 1;
+
+ ptCreateString[10] = 320; /* Maximum Horizontal Size of the Thumbnail for App0 marker */
+ ptCreateString[11] = 240; /* Maximum Vertical Size of the Thumbnail for App0 marker */
+ ptCreateString[12] = 320; /* Maximum Horizontal Size of the Thumbnail for App1 marker */
+ ptCreateString[13] = 240; /* Maximum Vertical Size of the Thumbnail for App1 marker */
+ ptCreateString[14] = 320; /* Maximum Horizontal Size of the Thumbnail for App13 marker */
+ ptCreateString[15] = 240; /* Maximum Vertical Size of the Thumbnail for App13 marker */
+ ptCreateString[16] = 0; /* Number of scans is always 0 */
+ if (pPortDefIn->format.image.eColorFormat == OMX_COLOR_FormatYUV420PackedPlanar)
+ {
+ ptCreateString[16] = 1;
+ }
+
+ ptCreateString[17] = 0;
+ if ( pPortDefIn->format.image.eColorFormat == OMX_COLOR_Format32bitARGB8888){
+ ptCreateString[17] = 1; //Convert flag
+ }
+
+ ptCreateString[18] = 320; /* Maximum Horizontal Size of the Thumbnail for App5 marker */
+ ptCreateString[19] = 240; /* Maximum Vertical Size of the Thumbnail for App5 marker */
+
+#ifdef __JPEG_OMX_PPLIB_ENABLED__
+
+ //size
+ ptCreateStringPPLIB[10] = JPEGENC_PPLIB_CREATEPARAM_SIZE;
+
+ //SlibVersion
+ ptCreateStringPPLIB[11] = 0x00000100;
+
+ //MaxInWidth
+ ptCreateStringPPLIB[12] = pPortDefIn->format.image.nFrameWidth;
+
+ //MaxOutWidth
+ ptCreateStringPPLIB[13] = pPortDefIn->format.image.nFrameWidth;
+ //Input Format => 0:RGB24, 1:RGB16, 2:RGB12, 3:RGB8, 4:RGB4, 5:YUV422ILE, 6:YUV422IBE,
+ // 7:422_IN_UY_WS, 8:422_IN_YU_WS, 9:YUV420P, 10:GRAY8, 11:GRAY4, 12:GRAY2_IN, 13:GRAY1
+ if (pPortDefIn->format.image.eColorFormat == OMX_COLOR_FormatCbYCrY
+ || pPortDefIn->format.image.eColorFormat == OMX_COLOR_Format32bitARGB8888
+ || pPortDefIn->format.image.eColorFormat == OMX_COLOR_FormatYCbYCr)
+ {
+ ptCreateStringPPLIB[14] = 5;
+ }
+ else if (pPortDefIn->format.image.eColorFormat == OMX_COLOR_FormatYUV420PackedPlanar)
+ {
+ ptCreateStringPPLIB[14] = 9;
+ }
+ else if (pPortDefIn->format.image.eColorFormat == OMX_COLOR_Format16bitRGB565)
+ {
+ ptCreateStringPPLIB[14] = 1;
+ }
+ else{
+ ptCreateStringPPLIB[14] = 9;
+ }
+
+ //YuvOutputFormat
+ // --> 0 = OFF, 1 = YUV420, 2 = YUV422ILE, 3 = YUV422IBE
+ if (pPortDefIn->format.image.eColorFormat == OMX_COLOR_FormatYUV420PackedPlanar)
+ {
+ ptCreateStringPPLIB[15] = 1;
+ }
+ else
+ {
+ ptCreateStringPPLIB[15] = 2;
+ }
- lcml_dsp->pCrPhArgs = arr;
+ //RGBOuputFormat
+ // --> 0 = OFF, 1 = RGB4, 2 = RGB8, 3 = RGB12, 4 = RGB16, 5 = RGB24, 6 = RGB32,
+ // 7 = GRAY8, 8 = GRAY4, 9 = GRAY2, 10 = GRAY1
+ ptCreateStringPPLIB[16] = 0;
+
+ ptCreateString[34] = END_OF_CR_PHASE_ARGS;
+#else
+ ptCreateString[20] = END_OF_CR_PHASE_ARGS;
+#endif
+ lcml_dsp->pCrPhArgs = ptCreateString;
EXIT:
return eError;
}
-
-
static OMX_ERRORTYPE HandleJpegEncInternalFlush(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1)
{
OMX_ERRORTYPE eError = OMX_ErrorNone;
OMX_U32 aParam[4];
LCML_DSP_INTERFACE *pLcmlHandle = NULL;
-
+
OMX_CHECK_PARAM(pComponentPrivate);
- if ( nParam1 == 0x0 ||
+ if ( nParam1 == 0x0 ||
(int)nParam1 == -1 ) {
pComponentPrivate->bFlushComplete = OMX_FALSE;
@@ -712,7 +753,7 @@ static OMX_ERRORTYPE HandleJpegEncInternalFlush(JPEGENC_COMPONENT_PRIVATE *pComp
pComponentPrivate->bFlushComplete = OMX_FALSE;
}
- if ( nParam1 == 0x1 ||
+ if ( nParam1 == 0x1 ||
(int)nParam1 == -1 ) {
pComponentPrivate->bFlushComplete = OMX_FALSE;
@@ -748,10 +789,10 @@ OMX_ERRORTYPE HandleJpegEncCommandFlush(JPEGENC_COMPONENT_PRIVATE *pComponentPri
OMX_ERRORTYPE eError = OMX_ErrorNone;
OMX_U32 aParam[4];
LCML_DSP_INTERFACE *pLcmlHandle = NULL;
-
+
OMX_CHECK_PARAM(pComponentPrivate);
- if ( nParam1 == 0x0 ||
+ if ( nParam1 == 0x0 ||
(int)nParam1 == -1 ) {
pComponentPrivate->bFlushComplete = OMX_FALSE;
@@ -796,15 +837,15 @@ OMX_ERRORTYPE HandleJpegEncCommandFlush(JPEGENC_COMPONENT_PRIVATE *pComponentPri
pComponentPrivate->nInPortIn,
pComponentPrivate->nInPortOut,
pComponentPrivate->nOutPortIn,
- pComponentPrivate->nOutPortOut);
+ pComponentPrivate->nOutPortOut);
OMX_PRBUFFER1(pComponentPrivate->dbg, "before EmptyBufferDone\n");
pComponentPrivate->cbInfo.EmptyBufferDone(
pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- pBuffHead);
+ pBuffHead);
OMX_PRBUFFER1(pComponentPrivate->dbg, "after EmptyBufferDone\n");
}
-#if 0
+#if 0
for ( i=0; i < pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortDef->nBufferCountActual; i++ ) {
#ifdef __PERF_INSTRUMENTATION__
@@ -816,24 +857,24 @@ OMX_ERRORTYPE HandleJpegEncCommandFlush(JPEGENC_COMPONENT_PRIVATE *pComponentPri
pBuffPrivate = (JPEGENC_BUFFER_PRIVATE*) pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pBufferPrivate[i]->pBufferHdr->pInputPortPrivate;
OMX_PRBUFFER2(pComponentPrivate->dbg, "flush input port. buffer owner (%d) %d\n", i, pBuffPrivate->eBufferOwner);
}
-#endif
+#endif
OMX_PRBUFFER1(pComponentPrivate->dbg, "buffer summary (flush input) %lu %lu %lu %lu\n",
pComponentPrivate->nInPortIn,
pComponentPrivate->nInPortOut,
pComponentPrivate->nOutPortIn,
- pComponentPrivate->nOutPortOut);
+ pComponentPrivate->nOutPortOut);
/* returned all input buffers */
- pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
+ pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- OMX_EventCmdComplete,
+ OMX_EventCmdComplete,
OMX_CommandFlush,
- JPEGENC_INP_PORT,
- NULL);
+ JPEGENC_INP_PORT,
+ NULL);
}
- if ( nParam1 == 0x1 ||
+ if ( nParam1 == 0x1 ||
(int)nParam1 == -1 ) {
pComponentPrivate->bFlushComplete = OMX_FALSE;
@@ -857,7 +898,7 @@ OMX_ERRORTYPE HandleJpegEncCommandFlush(JPEGENC_COMPONENT_PRIVATE *pComponentPri
pComponentPrivate->bFlushComplete = OMX_FALSE;
/* return all output buffers */
-
+
#if 0
for ( i=0; i < pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef->nBufferCountActual ; i++ ) {
OMX_PRBUFFER1(pComponentPrivate->dbg, "BEFORE FillBufferDone in OMX_CommandFlush\n");
@@ -906,11 +947,11 @@ OMX_ERRORTYPE HandleJpegEncCommandFlush(JPEGENC_COMPONENT_PRIVATE *pComponentPri
pComponentPrivate->nInPortIn,
pComponentPrivate->nInPortOut,
pComponentPrivate->nOutPortIn,
- pComponentPrivate->nOutPortOut);
+ pComponentPrivate->nOutPortOut);
OMX_PRBUFFER1(pComponentPrivate->dbg, "before FillBufferDone\n");
pComponentPrivate->cbInfo.FillBufferDone(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- pBuffHead);
+ pBuffHead);
OMX_PRBUFFER1(pComponentPrivate->dbg, "after FillBufferDone\n");
}
@@ -918,14 +959,14 @@ OMX_ERRORTYPE HandleJpegEncCommandFlush(JPEGENC_COMPONENT_PRIVATE *pComponentPri
pComponentPrivate->nInPortIn,
pComponentPrivate->nInPortOut,
pComponentPrivate->nOutPortIn,
- pComponentPrivate->nOutPortOut);
-
- pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
+ pComponentPrivate->nOutPortOut);
+
+ pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- OMX_EventCmdComplete,
+ OMX_EventCmdComplete,
OMX_CommandFlush,
- JPEGENC_OUT_PORT,
- NULL);
+ JPEGENC_OUT_PORT,
+ NULL);
}
EXIT:
@@ -954,34 +995,37 @@ OMX_ERRORTYPE SendDynamicParam(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate)
//ptParam.nSize = sizeof(IIMGENC_DynamicParams);
ptParam.nSize = sizeof(IDMJPGE_TIGEM_DynamicParams) ;
- if ( pPortDefOut->format.image.eColorFormat == OMX_COLOR_FormatYUV420PackedPlanar ) {
+ if ( pPortDefIn->format.image.eColorFormat == OMX_COLOR_FormatYUV420PackedPlanar ) {
ptParam.nInputChromaFormat = 1;
-
- }
- else if ( pPortDefOut->format.image.eColorFormat == OMX_COLOR_FormatCbYCrY ) {
+ }
+ else if ( pPortDefIn->format.image.eColorFormat == OMX_COLOR_FormatCbYCrY
+ || pPortDefIn->format.image.eColorFormat == OMX_COLOR_Format32bitARGB8888
+ || pPortDefIn->format.image.eColorFormat == OMX_COLOR_Format16bitRGB565) {
ptParam.nInputChromaFormat = 4;
-
- }
+ }
+ else if ( pPortDefIn->format.image.eColorFormat == OMX_COLOR_FormatYCbYCr) {
+ ptParam.nInputChromaFormat = 9;
+ }
else {
ptParam.nInputChromaFormat = 1;
}
if (pComponentPrivate->pCrop->nWidth == 0)
{
- ptParam.nInputWidth = pPortDefIn->format.image.nFrameWidth;
+ ptParam.nInputWidth = pPortDefIn->format.image.nFrameWidth;
}
else
{
- ptParam.nInputWidth = pComponentPrivate->pCrop->nWidth;
+ ptParam.nInputWidth = pComponentPrivate->pCrop->nWidth;
}
-
+
if (pComponentPrivate->pCrop->nHeight == 0)
{
- ptParam.nInputHeight = pPortDefIn->format.image.nFrameHeight;
+ ptParam.nInputHeight = pPortDefIn->format.image.nFrameHeight;
}
else
{
- ptParam.nInputHeight = pComponentPrivate->pCrop->nHeight;
+ ptParam.nInputHeight = pComponentPrivate->pCrop->nHeight;
}
ptParam.nCaptureWidth = pPortDefIn->format.image.nFrameWidth;
@@ -1000,21 +1044,348 @@ OMX_ERRORTYPE SendDynamicParam(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate)
pTmpDynParams->DRI_Interval = pComponentPrivate->nDRI_Interval;
pTmpDynParams->huffmanTable = NULL;
pTmpDynParams->quantTable = NULL;
-
- cmdValues[0] = IUALG_CMD_SETSTATUS;
+
+ cmdValues[0] = IUALG_CMD_SETSTATUS;
cmdValues[1] = (OMX_U32)(pTmpDynParams);
cmdValues[2] = sizeof(IDMJPGE_TIGEM_DynamicParams) + 128;
pComponentPrivate->bAckFromSetStatus = 0;
pLcmlHandle =(LCML_DSP_INTERFACE*)pComponentPrivate->pLCML;
eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,
- EMMCodecControlAlgCtrl,
+ EMMCodecControlAlgCtrl,
(void*)&cmdValues);
EXIT:
return eError;
}
+#ifdef __JPEG_OMX_PPLIB_ENABLED__
+OMX_ERRORTYPE SendDynamicPPLibParam(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate,OMX_U32 *ptInputParam)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_PARAM_PORTDEFINITIONTYPE* pPortDefIn = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE* pPortDefOut = NULL;
+
+ OMX_CHECK_PARAM(pComponentPrivate);
+ pPortDefIn = pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortDef;
+ pPortDefOut = pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef;
+
+ // PPLIB hardcoded params
+ OMX_U32 ulOutPitch = 0;
+ OMX_U32 ulPPLIBVideoGain=64;
+ OMX_U32 ulPPLIBEnableCropping=0;
+ OMX_U32 ulPPLIBXstart=0;
+ OMX_U32 ulPPLIBYstart=0;
+ OMX_U32 ulPPLIBXsize=0;
+ OMX_U32 ulPPLIBYsize=0;
+ OMX_U32 ulPPLIBEnableZoom=0;
+ OMX_U32 ulPPLIBZoomFactor=0;
+ OMX_U32 ulPPLIBZoomLimit=0;
+ OMX_U32 ulPPLIBZoomSpeed=0;
+ OMX_U32 ulPPLIBLightChroma=0;
+ OMX_U32 ulPPLIBLockedRatio=1;
+ OMX_U32 ulPPLIBMirroring=0;
+ OMX_U32 ulPPLIBRGBrotation=0;
+ OMX_U32 ulPPLIBYUVRotation=0;
+ OMX_U32 ulPPLIBIORange=1;
+ OMX_U32 ulPPLIBDithering=0;
+
+ OMX_U32 cOffset = 0;
+
+ /* PPLIB_RunTimeParams */
+ // LgUns size; // size of structure
+
+ ptInputParam[0] = JPEGENC_PPLIB_DYNPARM_SIZE; // 252 bytes
+
+ // LgUns ulInWidth; // picture buffer width
+
+ ptInputParam[1] = pPortDefIn->format.image.nFrameWidth;
+
+ // LgUns ulInHeight; // picture buffer height
+
+ ptInputParam[2] = pPortDefIn->format.image.nFrameHeight;
+
+ // LgUns FrameEnabled[0] (enable instance 1 of VGPOP)
+
+ ptInputParam[3] = 1;
+
+ // LgUns FrameEnabled[1] (enable instance 2 of VGPOP - not used now)
+
+ ptInputParam[4] = 0;
+
+ // LgUns EnalbeYUVOutput[0]
+
+ ptInputParam[5] = 1;
+
+ // LgUns FrameEnabled[1]
+
+ ptInputParam[6] = 0;
+
+ // LgUns EnalbeRGBOutput[0]
+
+ ptInputParam[7] = 0;
+
+ // LgUns EnalbeRGBOutput[1]
+
+ ptInputParam[8] = 0;
+
+ // LgUns FrameInputStartYOffset[0]
+
+ ptInputParam[9] = 0;
+
+ // LgUns FrameInputStartYOffset[1]
+
+ ptInputParam[10] = 0;
+
+ cOffset = (pPortDefIn->format.image.nFrameWidth * pPortDefIn->format.image.nFrameHeight);
+
+ // LgUns FrameInputStartCOffset[0]
+
+ ptInputParam[11] = cOffset;
+
+ // LgUns FrameInputStartCOffset[1]
+
+ ptInputParam[12] = cOffset;
+
+ // LgUns FrameOutputStartYOffset[0]
+
+ ptInputParam[13] = 0;
+
+ // LgUns FrameOutputStartYOffset[1]
+
+ ptInputParam[14] = 0;
+
+ if (ulOutPitch > 0) {
+ if (ulPPLIBYUVRotation == 0 || ulPPLIBYUVRotation == 180) {
+ cOffset = (pPortDefIn->format.image.nFrameHeight * ulOutPitch);
+ }
+ else {
+ cOffset = (pPortDefIn->format.image.nFrameWidth * ulOutPitch);
+ }
+ }
+ else {
+ cOffset = (pPortDefIn->format.image.nFrameHeight * pPortDefIn->format.image.nFrameWidth);
+ }
+
+ // LgUns FrameOutputStartCOffset[0]
+ ptInputParam[15] = cOffset;
+
+ // LgUns FrameOutputStartCOffset[1]
+ ptInputParam[16] = cOffset;
+
+ // LgUns FrameOutputRGBOffset[0]
+ ptInputParam[17] = 0;
+
+ // LgUns FrameOutputRGBOffset[1]
+ ptInputParam[18] = 0;
+
+ // LgUns ulOutHeight[0]; // picture buffer height
+ ptInputParam[19] = pPortDefIn->format.image.nFrameHeight;
+
+ // LgUns ulOutHeight[1]; // picture buffer height
+ ptInputParam[20] = 0;
+
+ // LgUns ulOutWidth[0]; // picture buffer width
+ ptInputParam[21] = pPortDefIn->format.image.nFrameWidth;
+
+ // LgUns ulOutWidth[1]; // picture buffer width
+ ptInputParam[22] = 0;
+
+ //Contrast (same as Video Gain)
+ ptInputParam[23] = ulPPLIBVideoGain;
+
+ //Contrast (same as Video Gain)
+ ptInputParam[24] = ulPPLIBVideoGain;
+
+ if (ulPPLIBEnableCropping == 1) {
+ // Cropping
+ // LgUns ulInXstart[0]; // Hin active start
+ ptInputParam[25] = ulPPLIBXstart;
+
+ // Cropping
+ // LgUns ulInXstart[1]; // Hin active start
+ ptInputParam[26] = 0;
+
+ //LgUns ulInYstart[0]; // Vin active start
+ ptInputParam[27] = ulPPLIBYstart;
+
+ //LgUns ulInYstart[1]; // Vin active start
+ ptInputParam[28] = 0;
+
+ // LgUns ulInXsize[0]; // Hin active width
+ ptInputParam[29] = ulPPLIBXsize;
+
+ // LgUns ulInXsize[1]; // Hin active width
+ ptInputParam[30] = 0;
+
+ // LgUns ulInYsize; // Vin active height
+ ptInputParam[31] = ulPPLIBYsize;
+
+ // LgUns ulInYsize; // Vin active height
+ ptInputParam[32] = 0;
+ }
+ else {
+ // Cropping
+ // LgUns ulInXstart; // Hin active start
+ ptInputParam[25] = 0;
+
+ // Cropping
+ // LgUns ulInXstart[1]; // Hin active start
+ ptInputParam[26] = 0;
+
+ //LgUns ulInYstart; // Vin active start
+ ptInputParam[27] = 0;
+
+ //LgUns ulInYstart[1]; // Vin active start
+ ptInputParam[28] = 0;
+
+ // LgUns ulInXsize; // Hin active width
+ ptInputParam[29] = 0;
+
+ // LgUns ulInXsize[1]; // Hin active width
+ ptInputParam[30] = 0;
+
+ // LgUns ulInYsize; // Vin active height
+ ptInputParam[31] = 0;
+
+ // LgUns ulInYsize; // Vin active height
+ ptInputParam[32] = 0;
+ }
+
+ if (ulPPLIBEnableZoom) {
+ //Zoom
+ //LgUns ulZoomFactor; // zooming ratio (/1024)
+ ptInputParam[33] = ulPPLIBZoomFactor;
+
+ //Zoom
+ //LgUns ulZoomFactor; // zooming ratio (/1024)
+ ptInputParam[34] = 1024;
+
+ // LgUns ulZoomLimit; // zooming ratio limit (/1024)
+ ptInputParam[35] = ulPPLIBZoomLimit;
+
+ // LgUns ulZoomLimit; // zooming ratio limit (/1024)
+ ptInputParam[36] = 1024;
+
+ // LgInt slZoomSpeed; // speed of ratio change
+ ptInputParam[37] = ulPPLIBZoomSpeed;
+
+ // LgInt slZoomSpeed; // speed of ratio change
+ ptInputParam[38] = 0;
+ }
+ else {
+ //Zoom
+ //LgUns ulZoomFactor; // zooming ratio (/1024)
+ ptInputParam[33] = 1024;
+
+ //Zoom
+ //LgUns ulZoomFactor; // zooming ratio (/1024)
+ ptInputParam[34] = 1024;
+
+ // LgUns ulZoomLimit; // zooming ratio limit (/1024)
+ ptInputParam[35] = 1024;
+
+ // LgUns ulZoomLimit; // zooming ratio limit (/1024)
+ ptInputParam[36] = 1024;
+
+ // LgInt slZoomSpeed; // speed of ratio change
+ ptInputParam[37] = 0;
+
+ // LgInt slZoomSpeed; // speed of ratio change
+ ptInputParam[38] = 0;
+ }
+
+ // LgUns bLightChroma[0]; // Light chrominance process
+ ptInputParam[39] = ulPPLIBLightChroma;
+
+ // LgUns bLightChroma[1]; // Light chrominance process
+ ptInputParam[40] = ulPPLIBLightChroma;
+
+ //Aspect Ration Locked/unlocked
+ // LgUns bLockedRatio; // keep H/V ratio
+ ptInputParam[41] = ulPPLIBLockedRatio;
+
+ //Aspect Ration Locked/unlocked
+ // LgUns bLockedRatio; // keep H/V ratio
+ ptInputParam[42] = ulPPLIBLockedRatio;
+
+ //Mirroring and Rotation
+ // LgUns bMirror; // to mirror the picture
+ ptInputParam[43] = ulPPLIBMirroring;
+
+ //Mirroring and Rotation
+ // LgUns bMirror; // to mirror the picture
+ ptInputParam[44] = ulPPLIBMirroring;
+
+ // LgUns eRGBrotation; // 0, 90, 180, 270 deg.
+ ptInputParam[45] = ulPPLIBRGBrotation;
+
+ // LgUns eRGBrotation; // 0, 90, 180, 270 deg.
+ ptInputParam[46] = ulPPLIBRGBrotation;
+
+ // LgUns eYUVrotation; // 0, 90, 180, 270 deg.
+ ptInputParam[47] = ulPPLIBYUVRotation;
+
+ // LgUns eYUVrotation; // 0, 90, 180, 270 deg.
+ ptInputParam[48] = ulPPLIBYUVRotation;
+
+ // IO Range and Dithering
+ // LgUns eIORange; // Input/Output video range
+ // 0 = VGPOP_IN_16_235_OUT_16_235 (limi range to limi range),
+ // 1 = VGPOP_IN_00_255_OUT_00_255 (full range to full range),
+ // 2 = VGPOP_IN_00_255_OUT_16_235 (full range to limi range),
+ // 3 = VGPOP_IN_16_235_OUT_00_255 (limi range to full range)
+ ptInputParam[49] = ulPPLIBIORange;
+
+ // IO Range and Dithering
+ // LgUns eIORange; // Input/Output video range
+ // 0 = VGPOP_IN_16_235_OUT_16_235 (limi range to limi range),
+ // 1 = VGPOP_IN_00_255_OUT_00_255 (full range to full range),
+ // 2 = VGPOP_IN_00_255_OUT_16_235 (full range to limi range),
+ // 3 = VGPOP_IN_16_235_OUT_00_255 (limi range to full range)
+ ptInputParam[50] = ulPPLIBIORange;
+
+ // LgUns bDithering; // ON Enables the dithering
+ ptInputParam[51] = ulPPLIBDithering;
+
+ // LgUns bDithering; // ON Enables the dithering
+ ptInputParam[52] = ulPPLIBDithering;
+
+ // LgUns ulFrameOutputPitch; // ON Enables the dithering
+ ptInputParam[53] = ulOutPitch;
+
+ // LgUns bDithering; // ON Enables the dithering
+ ptInputParam[54] = ulOutPitch;
+
+ // LgUns ulAlphaRGB;
+ ptInputParam[55] = 0;
+
+ // LgUns ulAlphaRGB;
+ ptInputParam[56] = 0;
+
+ // LgUns ulIsFrameGenerated[0]
+ ptInputParam[57] = 0;
+
+ // LgUns ulIsFrameGenerated[1]
+ ptInputParam[58] = 0;
+
+ // LgUns ulYUVFrameSize[0]
+ ptInputParam[59] = 0;
+
+ // LgUns ulYUVFrameSize[1]
+ ptInputParam[60] = 0;
+
+ // LgUns ulRGBFrameSize[0]
+ ptInputParam[61] = 0;
+
+ // LgUns ulRGBFrameSize[1]
+ ptInputParam[62] = 0;
+
+EXIT:
+ return eError;
+}
+#endif
+
/*-------------------------------------------------------------------*/
/**
* HandleCommand() Handle State type commands
@@ -1031,7 +1402,7 @@ EXIT:
/*-------------------------------------------------------------------*/
OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1)
{
-
+
OMX_ERRORTYPE eError = OMX_ErrorNone;
OMX_COMPONENTTYPE *pHandle = NULL;
OMX_PARAM_PORTDEFINITIONTYPE* pPortDefIn = NULL;
@@ -1045,12 +1416,14 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
OMX_U8 nMHzRM = 0;
#endif
+
+
OMX_CHECK_PARAM(pComponentPrivate);
OMX_PRINT1(pComponentPrivate->dbg, "JPEGEnc Handlecommand\n");
pHandle = (OMX_COMPONENTTYPE *) pComponentPrivate->pHandle;
pPortDefIn = pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortDef;
pPortDefOut = pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef;
-
+
switch ( (OMX_STATETYPE)(nParam1) ) {
case OMX_StateIdle:
OMX_PRSTATE2(pComponentPrivate->dbg, "HandleCommand: Cmd OMX_StateIdle\n");
@@ -1060,55 +1433,20 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
if ( pComponentPrivate->nCurState == OMX_StateIdle ) {
pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- OMX_EventError,
- OMX_ErrorSameState,
- OMX_TI_ErrorMinor,
+ OMX_EventError,
+ OMX_ErrorSameState,
+ OMX_TI_ErrorMinor,
NULL);
break;
- }
- else if ( pComponentPrivate->nCurState == OMX_StateLoaded ||
+ }
+ else if ( pComponentPrivate->nCurState == OMX_StateLoaded ||
pComponentPrivate->nCurState == OMX_StateWaitForResources) {
-
+
OMX_PRSTATE2(pComponentPrivate->dbg, "state tranc from loaded to idle\n");
#ifdef __PERF_INSTRUMENTATION__
PERF_Boundary(pComponentPrivate->pPERFcomp,
PERF_BoundaryStart | PERF_BoundarySetup);
#endif
-
-#if 0
- nTimeout=0x0;
- if ( pPortDefIn->bEnabled == OMX_TRUE &&
- pPortDefOut->bEnabled == OMX_TRUE )
- {
-
- nTimeout = 0x0;
- while ( 1 )
- {
-
- if (pPortDefIn->bPopulated) {
- OMX_PRINT2(pComponentPrivate->dbg, "Entrando al break\n");
- break;
- }
- else if ( nTimeout++ > JPEGENC_TIMEOUT ) {
- OMX_PRINT2(pComponentPrivate->dbg, "Timeout ...\n");
- pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
- pComponentPrivate->pHandle->pApplicationPrivate,
- OMX_EventError,
- OMX_ErrorPortUnresponsiveDuringAllocation,
- 0x0,
- "Not response Port -Idle");
- break;
- }
-
-#ifndef UNDER_CE
- sched_yield();
-#else
- Sleep(0);
-#endif
- /* sleep(1); */
- }
- }
-#endif
#ifdef RESOURCE_MANAGER_ENABLED /* Resource Manager Proxy Calls */
pComponentPrivate->rmproxyCallback.RMPROXY_Callback = (void *)ResourceManagerCallback;
@@ -1144,8 +1482,8 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
pthread_mutex_unlock(&pComponentPrivate->jpege_mutex_app);
}
- eError = GetJpegEncLCMLHandle(pHandle);
-
+ eError = GetJpegEncLCMLHandle(pHandle);
+
if ( eError != OMX_ErrorNone ) {
OMX_PRDSP4(pComponentPrivate->dbg, "GetLCMLHandle failed...\n");
goto EXIT;
@@ -1155,12 +1493,18 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
Fill_JpegEncLCMLInitParams(lcml_dsp,arr, pHandle);
cb.LCML_Callback = (void *) JpegEncLCML_Callback;
OMX_PRDSP2(pComponentPrivate->dbg, "Start LCML_InitMMCodec JPEG Phase in JPEG.....\n");
-
+
/* calling initMMCodec to init codec with details filled earlier */
eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, NULL, &pLcmlHandle, NULL, &cb);
-
if ( eError != OMX_ErrorNone ) {
OMX_PRDSP4(pComponentPrivate->dbg, "InitMMCodec failed... %x\n", eError);
+ printf("Error : InitMMCodec failed...>>>>>>");
+ pComponentPrivate->cbInfo.EventHandler(pHandle,
+ pHandle->pApplicationPrivate,
+ OMX_EventError,
+ OMX_ErrorHardware,
+ OMX_TI_ErrorSevere,
+ NULL);
goto EXIT;
}
pComponentPrivate->isLCMLActive = 1;
@@ -1173,7 +1517,7 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
pComponentPrivate->nInPortIn = pComponentPrivate->nInPortOut = 0;
pComponentPrivate->nOutPortIn = pComponentPrivate->nOutPortOut = 0;
-
+
#ifdef RESOURCE_MANAGER_ENABLED
eError= RMProxy_NewSendCommand(pHandle, RMProxy_StateSet, OMX_JPEG_Encoder_COMPONENT, OMX_StateIdle, 3456, NULL);
@@ -1189,33 +1533,33 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
break;
}
#endif
-
+
#ifdef __PERF_INSTRUMENTATION__
PERF_Boundary(pComponentPrivate->pPERFcomp,
PERF_BoundaryComplete | PERF_BoundarySetup);
#endif
- pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
+ pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- OMX_EventCmdComplete,
+ OMX_EventCmdComplete,
OMX_CommandStateSet,
- pComponentPrivate->nCurState,
+ pComponentPrivate->nCurState,
NULL);
break;
-
- }
- else if ( pComponentPrivate->nCurState == OMX_StateExecuting ||
+
+ }
+ else if ( pComponentPrivate->nCurState == OMX_StateExecuting ||
pComponentPrivate->nCurState == OMX_StatePause ) {
#ifdef __PERF_INSTRUMENTATION__
PERF_Boundary(pComponentPrivate->pPERFcomp,
PERF_BoundaryComplete | PERF_BoundarySteadyState);
#endif
-
+
pLcmlHandle =(LCML_DSP_INTERFACE*)pComponentPrivate->pLCML;
pComponentPrivate->bDSPStopAck = OMX_FALSE;
OMX_PRDSP2(pComponentPrivate->dbg, "bDSPStopAck is %d\n", pComponentPrivate->bDSPStopAck);
eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,MMCodecControlStop,NULL);
- pComponentPrivate->nApp_nBuf= 1;
+ pComponentPrivate->nApp_nBuf= 1;
/* HandleJpegEncCommandFlush(pComponentPrivate, -1); */
/*
if ( pComponentPrivate->isLCMLActive ==1 ) {
@@ -1227,17 +1571,17 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
#ifdef RESOURCE_MANAGER_ENABLED
- eError= RMProxy_NewSendCommand(pHandle, RMProxy_StateSet, OMX_JPEG_Encoder_COMPONENT, OMX_StateIdle, 3456, NULL);
- if (eError != OMX_ErrorNone) {
- OMX_PRMGR4(pComponentPrivate->dbg, "Resources not available Executing ->Idle\n");
- pComponentPrivate->nCurState = OMX_StateWaitForResources;
- pComponentPrivate->cbInfo.EventHandler(pHandle,
- pHandle->pApplicationPrivate,
- OMX_EventCmdComplete,
- OMX_CommandStateSet,
- pComponentPrivate->nCurState,
- NULL);
- break;
+ eError= RMProxy_NewSendCommand(pHandle, RMProxy_StateSet, OMX_JPEG_Encoder_COMPONENT, OMX_StateIdle, 3456, NULL);
+ if (eError != OMX_ErrorNone) {
+ OMX_PRMGR4(pComponentPrivate->dbg, "Resources not available Executing ->Idle\n");
+ pComponentPrivate->nCurState = OMX_StateWaitForResources;
+ pComponentPrivate->cbInfo.EventHandler(pHandle,
+ pHandle->pApplicationPrivate,
+ OMX_EventCmdComplete,
+ OMX_CommandStateSet,
+ pComponentPrivate->nCurState,
+ NULL);
+ break;
}
#endif
pComponentPrivate->ExeToIdleFlag |= JPEGE_BUFFERBACK;
@@ -1260,7 +1604,7 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
int i;
for (i = 0; i < (int)(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortDef->nBufferCountActual); i ++) {
- JPEGENC_BUFFER_PRIVATE *pBuffPrivate = NULL;
+ JPEGENC_BUFFER_PRIVATE *pBuffPrivate = NULL;
OMX_BUFFERHEADERTYPE* pBuffHead = NULL;
pBuffHead = pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pBufferPrivate[i]->pBufferHdr;
@@ -1277,19 +1621,19 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
pComponentPrivate->cbInfo.EmptyBufferDone(
pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- pBuffHead);
+ pBuffHead);
}
else{
OMX_PRBUFFER2(pComponentPrivate->dbg, "JPEG enc:: Sending beffer to tunnel, pHandle=%p\n", pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->hTunnelComponent);
pBuffHead->nFilledLen = 0;
pBuffPrivate->eBufferOwner = JPEGENC_BUFFER_CLIENT;
- eError = OMX_FillThisBuffer(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->hTunnelComponent,
+ eError = OMX_FillThisBuffer(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->hTunnelComponent,
pBuffHead);
}
}
}
}
-
+
OMX_PRBUFFER2(pComponentPrivate->dbg, "returned all input buffers\n");
for (i = 0; i < (int)(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef->nBufferCountActual); i ++) {
@@ -1315,7 +1659,7 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
else{
OMX_PRBUFFER2(pComponentPrivate->dbg, "JPEG enc:: Sending OUTPUT buffer to Tunnel component\n");
pBuffPrivate->eBufferOwner = JPEGENC_BUFFER_CLIENT;
- eError = OMX_EmptyThisBuffer(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->hTunnelComponent,
+ eError = OMX_EmptyThisBuffer(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->hTunnelComponent,
pBuffHead);
}
}
@@ -1326,68 +1670,68 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
pComponentPrivate->nCurState = OMX_StateIdle;
pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- OMX_EventCmdComplete,
- OMX_CommandStateSet,
- pComponentPrivate->nCurState,
+ OMX_EventCmdComplete,
+ OMX_CommandStateSet,
+ pComponentPrivate->nCurState,
NULL);
pComponentPrivate->ExeToIdleFlag = 0;
- }
+ }
else {
OMX_PRSTATE4(pComponentPrivate->dbg, "Error: Invalid State Given by Application\n");
- pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle,
+ pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- OMX_EventError,
- OMX_ErrorIncorrectStateTransition,
- OMX_TI_ErrorMinor,
+ OMX_EventError,
+ OMX_ErrorIncorrectStateTransition,
+ OMX_TI_ErrorMinor,
"Invalid State");
}
break;
case OMX_StateExecuting:
-
+
OMX_PRSTATE2(pComponentPrivate->dbg, "HandleCommand: Cmd OMX_StateExecuting \n");
OMX_PRBUFFER2(pComponentPrivate->dbg, "In exec in %lu out %lu\n", pComponentPrivate->nInPortIn, pComponentPrivate->nOutPortOut);
if ( pComponentPrivate->nCurState == OMX_StateExecuting ) {
pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- OMX_EventError,
- OMX_ErrorSameState,
- OMX_TI_ErrorMinor,
+ OMX_EventError,
+ OMX_ErrorSameState,
+ OMX_TI_ErrorMinor,
NULL);
- }
+ }
else if ( pComponentPrivate->nCurState == OMX_StateIdle || pComponentPrivate->nCurState == OMX_StatePause ) {
#ifdef __PERF_INSTRUMENTATION__
PERF_Boundary(pComponentPrivate->pPERFcomp,
PERF_BoundaryStart | PERF_BoundarySteadyState);
-#endif
+#endif
-#if 1
+#if 1
eError = SendDynamicParam(pComponentPrivate);
if (eError != OMX_ErrorNone ) {
OMX_PRDSP4(pComponentPrivate->dbg, "SETSTATUS failed... %x\n", eError);
goto EXIT;
}
#endif
-
+
OMX_PRDSP2(pComponentPrivate->dbg, "after SendDynamicParam\n");
pLcmlHandle =(LCML_DSP_INTERFACE*)pComponentPrivate->pLCML;
eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,EMMCodecControlStart,NULL);
-
+
#ifdef RESOURCE_MANAGER_ENABLED
eError= RMProxy_NewSendCommand(pHandle, RMProxy_StateSet, OMX_JPEG_Encoder_COMPONENT, OMX_StateExecuting, 3456, NULL);
if (eError != OMX_ErrorNone) {
OMX_PRMGR4(pComponentPrivate->dbg, "Resources not available\n");
pComponentPrivate->nCurState = OMX_StateWaitForResources;
- pComponentPrivate->cbInfo.EventHandler(pHandle,
+ pComponentPrivate->cbInfo.EventHandler(pHandle,
pHandle->pApplicationPrivate,
- OMX_EventCmdComplete,
- OMX_CommandStateSet,
- pComponentPrivate->nCurState,
+ OMX_EventCmdComplete,
+ OMX_CommandStateSet,
+ pComponentPrivate->nCurState,
NULL);
break;
}
@@ -1402,16 +1746,16 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- OMX_EventCmdComplete,
- OMX_CommandStateSet,
- pComponentPrivate->nCurState,
+ OMX_EventCmdComplete,
+ OMX_CommandStateSet,
+ pComponentPrivate->nCurState,
NULL);
} else {
pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
- OMX_EventError,
- OMX_ErrorIncorrectStateTransition,
- OMX_TI_ErrorMinor,
+ OMX_EventError,
+ OMX_ErrorIncorrectStateTransition,
+ OMX_TI_ErrorMinor,
NULL);
}
break;
@@ -1448,7 +1792,7 @@ OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate
}
break;
-
+
case OMX_StateInvalid:
OMX_PRSTATE2(pComponentPrivate->dbg, "HandleCommand: Cmd OMX_StateInvalid::\n");
if ( pComponentPrivate->nCurState == OMX_StateInvalid ) {
@@ -1666,6 +2010,9 @@ OMX_ERRORTYPE HandleJpegEncFreeOutputBufferFromApp(JPEGENC_COMPONENT_PRIVATE *pC
LCML_DSP_INTERFACE* pLcmlHandle = NULL;
JPEGENC_BUFFER_PRIVATE* pBuffPrivate = NULL;
int ret;
+#ifdef __JPEG_OMX_PPLIB_ENABLED__
+ OMX_U8 *ptInputParam;
+#endif
OMX_PRINT1(pComponentPrivate->dbg, "Inside HandleFreeOutputBufferFromApp function\n");
@@ -1724,16 +2071,46 @@ OMX_ERRORTYPE HandleJpegEncFreeOutputBufferFromApp(JPEGENC_COMPONENT_PRIVATE *pC
/* ptParam = (IUALG_Buf *)pBuffPrivate->pUALGParams; */
pBuffPrivate->eBufferOwner = JPEGENC_BUFFER_DSP;
- OMX_PRDSP2(pComponentPrivate->dbg, "before queue output buffer %p\n", pBuffHead);
+#ifdef __JPEG_OMX_PPLIB_ENABLED__
+ if (pComponentPrivate->pOutParams != NULL)
+ {
+ OMX_FREE(pComponentPrivate->pOutParams);
+ }
+ OMX_MALLOC(pComponentPrivate->pOutParams,sizeof(PPLIB_UALGRunTimeParam_t));
+
+ if (pComponentPrivate->pOutParams != NULL)
+ {
+ }
+ else
+ {
+ goto EXIT;
+ }
+
+ eError = SendDynamicPPLibParam(pComponentPrivate,pComponentPrivate->pOutParams);
+ if (eError != OMX_ErrorNone ) {
+ goto EXIT;
+ }
+
+
+ eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,
+ EMMCodecOuputBuffer,
+ pBuffHead->pBuffer,
+ pPortDefOut->nBufferSize,
+ 0,
+ (OMX_U8 *)pComponentPrivate->pOutParams,
+ sizeof(PPLIB_UALGRunTimeParam_t),
+ (OMX_U8 *) pBuffHead);
+
+#else
eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,
EMMCodecOuputBuffer,
pBuffHead->pBuffer,
pPortDefOut->nBufferSize,
- 0,
- NULL,
- 0,
+ 0,
+ NULL,
+ 0,
(OMX_U8 *) pBuffHead);
- OMX_PRDSP2(pComponentPrivate->dbg, "after queue output buffer %p\n", pBuffHead);
+#endif
OMX_PRINT1(pComponentPrivate->dbg, "Error is %x\n",eError);
@@ -1741,137 +2118,217 @@ OMX_ERRORTYPE HandleJpegEncFreeOutputBufferFromApp(JPEGENC_COMPONENT_PRIVATE *pC
return eError;
}
-static OMX_U32 CalInParamBufSize(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate)
-{
- THUMBNAIL_INFO *pThumbnailInfo = &pComponentPrivate->ThumbnailInfo;
- OMX_U32 size = 0;
- int str_size;
+OMX_U32 CalculateParamsSize (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate) {
- size ++; /* for the first field: total size of buffer */
+ OMX_U32 i = 0;
+ i+= 4; /* 4 bytes for the size of the whole array */
- if (!pThumbnailInfo->APP0_THUMB_INDEX) {
- size += 6;
- } else {
- size += 12; /* for INDEX, W and H */
- if (pThumbnailInfo->APP0_BUF.size > 0) {
- size += 2 + pThumbnailInfo->APP0_BUF.size / 4;
- if (pThumbnailInfo->APP0_BUF.size % 4) {
- size ++;
- }
- } else {
- // size += 4; /* for default APP0_BUF */
- size += 3;
- }
+ /* Set Custom Quantization Table */
+ if (pComponentPrivate->bSetLumaQuantizationTable && pComponentPrivate->bSetChromaQuantizationTable) {
+ i+=4; /* 4 bytes for the Quantization table TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=256; /* 256 bytes for the Quantization table data*/
}
- if (!pThumbnailInfo->APP1_THUMB_INDEX) {
- size += 6;
- } else {
- size += 12; /* for INDEX, W and H */
- if (pThumbnailInfo->APP1_BUF.size > 0) {
- size += 2 + pThumbnailInfo->APP1_BUF.size / 4;
- if (pThumbnailInfo->APP1_BUF.size % 4) {
- size ++;
- }
- } else {
- size += 4; /* for default APP1_BUF */
+ /* Set Custom Huffman Table */
+ if (pComponentPrivate->bSetHuffmanTable) {
+ i+=4; /* 4 bytes for the Huffman table TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ if (sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) % 4) {
+ i += (sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) + (4 - (sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) % 4)));
}
- }
- if (!pThumbnailInfo->APP13_THUMB_INDEX) {
- size += 6;
- } else {
- size += 12; /* for INDEX, W and H */
- if (pThumbnailInfo->APP13_BUF.size > 0) {
- size += 2 + pThumbnailInfo->APP13_BUF.size / 4;
- if (pThumbnailInfo->APP13_BUF.size % 4) {
- size ++;
- }
- } else {
- size += 4; /* for default APP13_BUF */
+ else {
+ i += sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE);
}
}
- size ++; /* for the COMMENT_BUFFER */
+ /* handle APP0 marker (JFIF)*/
+ if(pComponentPrivate->sAPP0.bMarkerEnabled) {
+ i+=4; /* 4 bytes for the Number of buffers TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual number of buffers (just 1 buffer) */
+ i+=4; /* 4 bytes for the buffer0 TAG */
- if (pComponentPrivate->nCommentFlag == 0 || pComponentPrivate->pString_Comment == NULL) {
- size += 3;
- } else {
- size ++; /* for storing the length of comment */
- str_size = strlen((char *)pComponentPrivate->pString_Comment);
- size += str_size / 4;
- if (str_size % 4) {
- size ++;
+ /* if thumbnail is set, or if explicity specified by application, set the marker from algo, otherwise set it from application */
+ if ((pComponentPrivate->sAPP0.nThumbnailWidth > 0 && pComponentPrivate->sAPP0.nThumbnailHeight > 0)
+ || pComponentPrivate->sAPP0.nMarkerSize <= 0) {
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data of this TAG */
+ }
+ else {
+ i+=4; /* 4 bytes for the size of this TAG */
+ i += (pComponentPrivate->sAPP0.nMarkerSize/4)*4; /* x bytes for the actual buffer data for this TAG */
+ if (pComponentPrivate->sAPP0.nMarkerSize % 4) {
+ i +=4; /* 4 extra bytes if the size is not divisible by 4*/
+ }
+ }
+ /* if thumbnail is set, configure it accordingly */
+ if (pComponentPrivate->sAPP0.nThumbnailWidth > 0 && pComponentPrivate->sAPP0.nThumbnailHeight > 0) {
+ i+=4; /* 4 bytes for the THUMB INDEX TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data for this TAG */
+
+ i+=4; /* 4 bytes for the THUMB W TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data for this TAG (width value) */
+
+ i+=4; /* 4 bytes for the THUMB H TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data for this TAG (height value) */
}
}
- if (pComponentPrivate->bSetLumaQuantizationTable && pComponentPrivate->bSetChromaQuantizationTable)
- {
- size += 64 /* Table Size 64 * 2 * 2 */ + 2 /* Content Type and Length */;
+ /* handle APP1 marker (EXIF)*/
+ if (pComponentPrivate->sAPP1.bMarkerEnabled) {
+ i+=4; /* 4 bytes for the Number of buffers TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual number of buffers (just 1 buffer) */
+ i+=4; /* 4 bytes for the buffer0 TAG */
+
+ /* if explicity specified by application, set the marker from algo, otherwise set it from application */
+ if (pComponentPrivate->sAPP1.nMarkerSize <= 0) {
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data of this TAG */
+ i+=4; /* 4 bytes for the actual data of this TAG */
+ }
+ else {
+ i+=4; /* 4 bytes for the size of this TAG */
+ i += (pComponentPrivate->sAPP1.nMarkerSize/4)*4; /* x bytes for the actual buffer data for this TAG */
+ if (pComponentPrivate->sAPP1.nMarkerSize % 4) {
+ i +=4; /* 4 extra bytes if the size is not divisible by 4*/
+ }
+ }
+
+ /* if thumbnail is set, configure it accordingly */
+ if (pComponentPrivate->sAPP1.nThumbnailWidth > 0 && pComponentPrivate->sAPP1.nThumbnailHeight > 0) {
+ i+=4; /* 4 bytes for the THUMB INDEX TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data for this TAG */
+
+ i+=4; /* 4 bytes for the THUMB W TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data for this TAG (width value) */
+
+ i+=4; /* 4 bytes for the THUMB H TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data for this TAG (height value) */
+ }
}
- if (pComponentPrivate->bSetHuffmanTable)
- {
- size += 2 /* Content Type and Length */;
- if (sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) % 4) {
- size += (sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) + (4 - (sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) % 4))) / 4 ;
- }
- else {
- size += sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) / 4;
- }
+
+ /* handle APP5 marker */
+ if (pComponentPrivate->sAPP5.bMarkerEnabled) {
+ i+=4; /* 4 bytes for the Number of buffers TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual number of buffers (just 1 buffer) */
+ i+=4; /* 4 bytes for the buffer0 TAG */
+
+ /* if explicity specified by application, set the marker from algo, otherwise set it from application */
+ if (pComponentPrivate->sAPP5.nMarkerSize <= 0) {
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data of this TAG */
+ i+=4; /* 4 bytes for the actual data of this TAG */
+ }
+ else {
+ i+=4; /* 4 bytes for the size of this TAG */
+ i += (pComponentPrivate->sAPP5.nMarkerSize/4)*4; /* x bytes for the actual buffer data for this TAG */
+ if (pComponentPrivate->sAPP5.nMarkerSize % 4) {
+ i +=4; /* 4 extra bytes if the size is not divisible by 4*/
+ }
+ }
+
+ /* if thumbnail is set, configure it accordingly */
+ if (pComponentPrivate->sAPP5.nThumbnailWidth > 0 && pComponentPrivate->sAPP5.nThumbnailHeight > 0) {
+ i+=4; /* 4 bytes for the THUMB INDEX TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data for this TAG */
+
+ i+=4; /* 4 bytes for the THUMB W TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data for this TAG (width value) */
+
+ i+=4; /* 4 bytes for the THUMB H TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data for this TAG (height value) */
+ }
+ }
+ /* handle APP13 marker */
+ if (pComponentPrivate->sAPP13.bMarkerEnabled) {
+ i+=4; /* 4 bytes for the Number of buffers TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual number of buffers (just 1 buffer) */
+ i+=4; /* 4 bytes for the buffer0 TAG */
+
+ /* if explicity specified by application, set the marker from algo, otherwise set it from application */
+ if (pComponentPrivate->sAPP13.nMarkerSize <= 0) {
+ i+=4; /* 4 bytes for the size of this TAG */
+ i+=4; /* 4 bytes for the actual data of this TAG */
+ i+=4; /* 4 bytes for the actual data of this TAG */
+ }
+ else {
+ i+=4; /* 4 bytes for the size of this TAG */
+ i += (pComponentPrivate->sAPP13.nMarkerSize/4)*4; /* x bytes for the actual buffer data for this TAG */
+ if (pComponentPrivate->sAPP13.nMarkerSize % 4) {
+ i +=4; /* 4 extra bytes if the size is not divisible by 4*/
+ }
+ }
}
-
- return (size * 4);
+
+ /* comment flag needed */
+ i+=4; /* 4 bytes for the size of this TAG */
+
+ /* handle CommentFlag */
+ if (pComponentPrivate->nCommentFlag == 1 && pComponentPrivate->pString_Comment) {
+ i+=4; /* 4 bytes for the Comment TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ /* comment string upper limit is 256 bytes */
+ i+=256;
+ }
+ else {
+ i+=4; /* 4 bytes for the Comment TAG */
+ i+=4; /* 4 bytes for the size of this TAG */
+ }
+
+ return i;
}
-static OMX_ERRORTYPE SetJpegEncInPortParams(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32* new_params, OMX_U32 buf_size)
+static OMX_ERRORTYPE SetJpegEncInPortParams(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32* new_params)
{
OMX_ERRORTYPE eError = OMX_ErrorNone;
int i = 1;
- OMX_U8 *p;
- int str_size;
- THUMBNAIL_INFO *pThumbnailInfo = &pComponentPrivate->ThumbnailInfo;
-
- new_params[0] = buf_size;
/* Set Custom Quantization Table */
- if (pComponentPrivate->bSetLumaQuantizationTable && pComponentPrivate->bSetChromaQuantizationTable)
- {
+ if (pComponentPrivate->bSetLumaQuantizationTable && pComponentPrivate->bSetChromaQuantizationTable) {
new_params[i++] = DYNPARAMS_QUANTTABLE;
new_params[i++] = 256; /* 2 tables * 64 entries * 2(16bit entries) */
OMX_U16 *temp = (OMX_U16 *)&new_params[i];
int j, k;
- for (j = 0; j < 64; j++)
- {
+ for (j = 0; j < 64; j++) {
temp[j] = pComponentPrivate->pCustomLumaQuantTable->nQuantizationMatrix[j];
}
- for (k = 0; k < 64; k++, j++)
- {
+ for (k = 0; k < 64; k++, j++) {
temp[j] = pComponentPrivate->pCustomChromaQuantTable->nQuantizationMatrix[k];
}
i += 64; /* 256 / 4 */
-
}
/* Set Custom Huffman Table */
- if (pComponentPrivate->bSetHuffmanTable)
- {
+ if (pComponentPrivate->bSetHuffmanTable) {
new_params[i++] = DYNPARAMS_HUFFMANTABLE;
new_params[i++] = sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE); /* 2572 % 4 = 0 */
memcpy((OMX_U8 *)(&new_params[i]), &(pComponentPrivate->pHuffmanTable->sHuffmanTable), sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE));
if (sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) % 4) {
- i += (sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) + (4 - (sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) % 4)))/4 ;
+ i += (sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) + (4 - (sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE) % 4)))/4 ;
}
else {
i += sizeof(JPEGENC_CUSTOM_HUFFMAN_TABLE)/4;
}
}
-
-
- /* handle thumbnail in APP0 marker (JFIF)*/
- if (pThumbnailInfo->APP0_THUMB_INDEX) {
+ /* handle APP0 marker (JFIF)*/
+ if(pComponentPrivate->sAPP0.bMarkerEnabled) {
new_params[i++] = APP0_NUMBUF;
new_params[i++] = 4;
new_params[i++] = 1;
@@ -1879,180 +2336,191 @@ static OMX_ERRORTYPE SetJpegEncInPortParams(JPEGENC_COMPONENT_PRIVATE *pComponen
/* set default APP0 BUFFER */
new_params[i++] = APP0_BUFFER;
- pThumbnailInfo->APP0_BUF.size = 0;
- if (pThumbnailInfo->APP0_BUF.size > 0) {
- OMX_U8 *t;
- new_params[i++] = pThumbnailInfo->APP0_BUF.size;
- t = (OMX_U8 *) &new_params[i];
- memcpy(t, pThumbnailInfo->APP0_BUF.app, pThumbnailInfo->APP0_BUF.size);
- i += pThumbnailInfo->APP0_BUF.size / 4;
- if (pThumbnailInfo->APP0_BUF.size % 4) {
- i ++;
- }
- } else {
- new_params[i++] = 4;
- new_params[i++] = 0;
+ /* if thumbnail is set, or if explicity specified by application, set the marker from algo, otherwise set it from application */
+ if ((pComponentPrivate->sAPP0.nThumbnailWidth > 0 && pComponentPrivate->sAPP0.nThumbnailHeight > 0)
+ || pComponentPrivate->sAPP0.nMarkerSize <= 0) {
+ new_params[i++] = 4;
+ new_params[i++] = 0;
+ }
+ else {
+ new_params[i++] = pComponentPrivate->sAPP0.nMarkerSize;
+ memcpy(new_params + i, pComponentPrivate->sAPP0.pMarkerBuffer, pComponentPrivate->sAPP0.nMarkerSize);
+ i += pComponentPrivate->sAPP0.nMarkerSize / 4;
+ if (pComponentPrivate->sAPP0.nMarkerSize % 4) {
+ i ++;
+ }
}
- new_params[i++] = APP0_THUMB_INDEX;
- new_params[i++] = 4;
- new_params[i++] = 1;
-
- new_params[i++] = APP0_THUMB_W;
- new_params[i++] = 4;
- new_params[i++] = pThumbnailInfo->APP0_THUMB_W;
-
- new_params[i++] = APP0_THUMB_H;
- new_params[i++] = 4;
- new_params[i++] = pThumbnailInfo->APP0_THUMB_H;
-
-
-
+ /* if thumbnail is set, configure it accordingly */
+ if (pComponentPrivate->sAPP0.nThumbnailWidth > 0 && pComponentPrivate->sAPP0.nThumbnailHeight > 0) {
+ new_params[i++] = APP0_THUMB_INDEX;
+ new_params[i++] = 4;
+ new_params[i++] = 1;
- } else {
- new_params[i++] = APP0_THUMB_INDEX;
- new_params[i++] = 4;
- new_params[i++] = 0;
+ new_params[i++] = APP0_THUMB_W;
+ new_params[i++] = 4;
+ new_params[i++] = pComponentPrivate->sAPP0.nThumbnailWidth;
- new_params[i++] = APP0_NUMBUF;
- new_params[i++] = 4;
- new_params[i++] = 0;
+ new_params[i++] = APP0_THUMB_H;
+ new_params[i++] = 4;
+ new_params[i++] = pComponentPrivate->sAPP0.nThumbnailHeight;
+ }
}
-
-
- /* handle thumbnail in APP1 marker (EXIF)*/
- if (pThumbnailInfo->APP1_THUMB_INDEX) {
- new_params[i++] = APP1_THUMB_INDEX;
- new_params[i++] = 4;
- new_params[i++] = 1;
-
- new_params[i++] = APP1_THUMB_W;
- new_params[i++] = 4;
- new_params[i++] = pThumbnailInfo->APP1_THUMB_W;
-
- new_params[i++] = APP1_THUMB_H;
- new_params[i++] = 4;
- new_params[i++] = pThumbnailInfo->APP1_THUMB_H;
-
+ /* handle APP1 marker (EXIF)*/
+ if(pComponentPrivate->sAPP1.bMarkerEnabled) {
new_params[i++] = APP1_NUMBUF;
new_params[i++] = 4;
new_params[i++] = 1;
/* set default APP1 BUFFER */
-
new_params[i++] = APP1_BUFFER;
- if (pThumbnailInfo->APP1_BUF.size > 0) {
- OMX_U8 *t;
- new_params[i++] = pThumbnailInfo->APP1_BUF.size;
- t = (OMX_U8 *) &new_params[i];
- memcpy(t, pThumbnailInfo->APP1_BUF.app, pThumbnailInfo->APP1_BUF.size);
- i += pThumbnailInfo->APP1_BUF.size / 4;
- if (pThumbnailInfo->APP1_BUF.size % 4) {
- i ++;
- }
- } else {
- new_params[i++] = 8;
- new_params[i++] = 0;
- new_params[i++] = 'F' | 'F' << 8 | 'F' << 16 | 'F' << 24;
+ /* if explicity specified by application, set the marker from algo, otherwise set it from application */
+ if (pComponentPrivate->sAPP1.nMarkerSize <= 0) {
+ new_params[i++] = 8;
+ new_params[i++] = 0;
+ new_params[i++] = 'F' | 'F' << 8 | 'F' << 16 | 'F' << 24;
+ }
+ else {
+ new_params[i++] = pComponentPrivate->sAPP1.nMarkerSize;
+ memcpy(new_params + i, pComponentPrivate->sAPP1.pMarkerBuffer, pComponentPrivate->sAPP1.nMarkerSize);
+ i += pComponentPrivate->sAPP1.nMarkerSize / 4;
+ if (pComponentPrivate->sAPP1.nMarkerSize % 4) {
+ i ++;
+ }
}
- } else {
- new_params[i++] = APP1_THUMB_INDEX;
- new_params[i++] = 4;
- new_params[i++] = 0;
+ /* if thumbnail is set, configure it accordingly */
+ if (pComponentPrivate->sAPP1.nThumbnailWidth > 0 && pComponentPrivate->sAPP1.nThumbnailHeight > 0) {
+ new_params[i++] = APP1_THUMB_INDEX;
+ new_params[i++] = 4;
+ new_params[i++] = 1;
- new_params[i++] = APP1_NUMBUF;
- new_params[i++] = 4;
- new_params[i++] = 0;
+ new_params[i++] = APP1_THUMB_W;
+ new_params[i++] = 4;
+ new_params[i++] = pComponentPrivate->sAPP1.nThumbnailWidth;
+
+ new_params[i++] = APP1_THUMB_H;
+ new_params[i++] = 4;
+ new_params[i++] = pComponentPrivate->sAPP1.nThumbnailHeight;
+ }
}
- /* handle thumbnail in APP13 marker */
- if (pThumbnailInfo->APP13_THUMB_INDEX) {
- new_params[i++] = APP13_THUMB_INDEX;
+
+ /* handle APP5 marker */
+ if(pComponentPrivate->sAPP5.bMarkerEnabled) {
+ new_params[i++] = APP5_NUMBUF;
new_params[i++] = 4;
new_params[i++] = 1;
- new_params[i++] = APP13_THUMB_W;
- new_params[i++] = 4;
- new_params[i++] = pThumbnailInfo->APP13_THUMB_W;
+ /* set default APP5 BUFFER */
+ new_params[i++] = APP5_BUFFER;
- new_params[i++] = APP13_THUMB_H;
- new_params[i++] = 4;
- new_params[i++] = pThumbnailInfo->APP13_THUMB_H;
+ /* if explicity specified by application, set the marker from algo, otherwise set it from application */
+ if (pComponentPrivate->sAPP5.nMarkerSize <= 0) {
+ new_params[i++] = 8;
+ new_params[i++] = 0;
+ new_params[i++] = 'F' | 'F' << 8 | 'F' << 16 | 'F' << 24;
+ }
+ else {
+ new_params[i++] = pComponentPrivate->sAPP5.nMarkerSize;
+ memcpy(new_params + i, pComponentPrivate->sAPP5.pMarkerBuffer, pComponentPrivate->sAPP5.nMarkerSize);
+ i += pComponentPrivate->sAPP5.nMarkerSize / 4;
+ if (pComponentPrivate->sAPP5.nMarkerSize % 4) {
+ i ++;
+ }
+ }
+
+ /* if thumbnail is set, configure it accordingly */
+ if (pComponentPrivate->sAPP5.nThumbnailWidth > 0 && pComponentPrivate->sAPP5.nThumbnailHeight > 0) {
+ new_params[i++] = APP5_THUMB_INDEX;
+ new_params[i++] = 4;
+ new_params[i++] = 1;
+
+ new_params[i++] = APP5_THUMB_W;
+ new_params[i++] = 4;
+ new_params[i++] = pComponentPrivate->sAPP5.nThumbnailWidth;
+
+ new_params[i++] = APP5_THUMB_H;
+ new_params[i++] = 4;
+ new_params[i++] = pComponentPrivate->sAPP5.nThumbnailHeight;
+ }
+ }
+
+ /* handle APP13 marker */
+ if(pComponentPrivate->sAPP13.bMarkerEnabled) {
new_params[i++] = APP13_NUMBUF;
new_params[i++] = 4;
new_params[i++] = 1;
- /* set default APP1 BUFFER */
+ /* set default APP13 BUFFER */
new_params[i++] = APP13_BUFFER;
- if (pThumbnailInfo->APP13_BUF.size > 0) {
- OMX_U8 *t;
- new_params[i++] = pThumbnailInfo->APP13_BUF.size;
- t = (OMX_U8 *) &new_params[i];
- memcpy(t, pThumbnailInfo->APP13_BUF.app, pThumbnailInfo->APP13_BUF.size);
- i += pThumbnailInfo->APP13_BUF.size / 4;
- if (pThumbnailInfo->APP13_BUF.size % 4) {
- i ++;
- }
- } else {
- new_params[i++] = 8;
- new_params[i++] = 0;
- new_params[i++] = 'F' | 'F' << 8 | 'F' << 16 | 'F' << 24;
+ /* if explicity specified by application, set the marker from algo, otherwise set it from application */
+ if (pComponentPrivate->sAPP13.nMarkerSize <= 0) {
+ new_params[i++] = 8;
+ new_params[i++] = 0;
+ new_params[i++] = 'F' | 'F' << 8 | 'F' << 16 | 'F' << 24;
}
- } else {
- new_params[i++] = APP13_THUMB_INDEX;
- new_params[i++] = 4;
- new_params[i++] = 0;
+ else {
+ new_params[i++] = pComponentPrivate->sAPP13.nMarkerSize;
+ memcpy(new_params + i, pComponentPrivate->sAPP13.pMarkerBuffer, pComponentPrivate->sAPP13.nMarkerSize);
+ i += pComponentPrivate->sAPP13.nMarkerSize / 4;
+ if (pComponentPrivate->sAPP13.nMarkerSize % 4) {
+ i ++;
+ }
+ }
+ }
- new_params[i++] = APP13_NUMBUF;
+ new_params[i++] = COMMENT_BUFFER;
+
+ /* handle CommentFlag */
+ if (pComponentPrivate->nCommentFlag == 1 && pComponentPrivate->pString_Comment) {
+ new_params[i++] = strlen((char *)pComponentPrivate->pString_Comment) + 4 ;
+ new_params[i++] = 0;
+ strncpy((char *)(new_params+i), (char *)pComponentPrivate->pString_Comment, 255);
+ }
+ else {
new_params[i++] = 4;
new_params[i++] = 0;
}
- /*if(pComponentPrivate->nCommentFlag){*/
- new_params[i++] = COMMENT_BUFFER;
- if (pComponentPrivate->nCommentFlag == 1 && pComponentPrivate->pString_Comment) {
- str_size = strlen((char *)pComponentPrivate->pString_Comment);
- new_params[i++] = str_size + 4 ;
- new_params[i++] = 0; /* index ? */
- p = (OMX_U8 *) &new_params[i];
- strncpy((char *)p, (char *)pComponentPrivate->pString_Comment, 255);
- /* new_params[0] = i * 4 + str_size + ((str_size % 4)? 4 - (str_size % 4) : 0); */
- }
- else {
- new_params[i++] = 5;
- new_params[i++] = 0;
- new_params[i++] = ' ';
- /* new_params[0] = i * 4; */
- }
-/* }*/
+ /* now that we know the final size of the buffer, we can set it accordingly */
+ new_params[0] = i * sizeof(OMX_U32);
+
+/*
+ printf("=========DUMP of new_params array=============\n");
+ int j;
+ for (j=0; j< i*4; j++) {
+ printf("new_params[%d] = 0x%x\n", j, *(((unsigned char *)new_params)+j));
+ }
+ printf("================================\n");
+*/
return eError;
}
OMX_ERRORTYPE SetJpegEncInParams(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate)
{
OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_U32 buf_size;
OMX_U8 *p = NULL;
-
- buf_size = CalInParamBufSize(pComponentPrivate);
+ OMX_U32 params_size;
if (pComponentPrivate->InParams.pInParams) {
p = (OMX_U8 *)pComponentPrivate->InParams.pInParams;
p -= 128;
- FREE(p);
+ OMX_FREE(p);
pComponentPrivate->InParams.pInParams = NULL;
}
- OMX_MALLOC_STRUCT_EXTRA(p, OMX_U8, (buf_size + 256 + 256 + 500 - 1));
+ /*alloc enough memory for params array*/
+ params_size = CalculateParamsSize(pComponentPrivate);
+ OMX_MALLOC(p, params_size + 256);
p += 128;
pComponentPrivate->InParams.pInParams = (OMX_U32 *)p;
p = NULL;
- eError = SetJpegEncInPortParams(pComponentPrivate, pComponentPrivate->InParams.pInParams, buf_size);
+ eError = SetJpegEncInPortParams(pComponentPrivate, pComponentPrivate->InParams.pInParams);
EXIT:
return eError;
@@ -2463,8 +2931,29 @@ OMX_ERRORTYPE JpegEncLCML_Callback (TUsnCodecEvent event,void * argsCb [10])
OMX_ErrorHardware,
OMX_TI_ErrorCritical,
NULL);
+
+ pComponentPrivate->nCurState = OMX_StateInvalid;
+ pComponentPrivate->cbInfo.EventHandler(pHandle,
+ pHandle->pApplicationPrivate,
+ OMX_EventError,
+ OMX_ErrorInvalidState,
+ OMX_TI_ErrorCritical,
+ "DSP Hardware Error");
goto EXIT;
}
+#ifdef DSP_MMU_FAULT_HANDLING
+ /* Cheking for MMU_fault */
+ if((argsCb[4] == (void *)NULL) && (argsCb[5] == (void*)NULL)) {
+ //JPEGENC_DPRINT("DSP MMU_Fault");
+ pComponentPrivate->nCurState = OMX_StateInvalid;
+ pComponentPrivate->cbInfo.EventHandler(pHandle,
+ pHandle->pApplicationPrivate,
+ OMX_EventError,
+ OMX_ErrorInvalidState,
+ OMX_TI_ErrorCritical,
+ "DSP MMU FAULT");
+ }
+#endif
}
if (event == EMMCodecInternalError) {
eError = OMX_ErrorHardware;
@@ -2533,31 +3022,27 @@ OMX_BOOL IsTIOMXComponent(OMX_HANDLETYPE hComp)
char *pSubstring = NULL;
OMX_BOOL bResult = OMX_TRUE;
- OMX_MALLOC_STRUCT_EXTRA(pTunnelcComponentName, char, 127);
- OMX_MALLOC_STRUCT(pTunnelComponentVersion, OMX_VERSIONTYPE);
- OMX_MALLOC_STRUCT(pSpecVersion, OMX_VERSIONTYPE);
- OMX_MALLOC_STRUCT(pComponentUUID, OMX_UUIDTYPE);
+ OMX_MALLOC(pTunnelcComponentName, 128);
+ OMX_MALLOC(pTunnelComponentVersion, sizeof(OMX_VERSIONTYPE));
+ OMX_MALLOC(pSpecVersion, sizeof(OMX_VERSIONTYPE));
+ OMX_MALLOC(pComponentUUID, sizeof(OMX_UUIDTYPE));
eError = OMX_GetComponentVersion (hComp, pTunnelcComponentName, pTunnelComponentVersion, pSpecVersion, pComponentUUID);
/* Check if tunneled component is a TI component */
pSubstring = strstr(pTunnelcComponentName, "OMX.TI.");
-
if(pSubstring == NULL) {
bResult = OMX_FALSE;
}
EXIT:
- FREE(pTunnelcComponentName);
- FREE(pTunnelComponentVersion);
- FREE(pSpecVersion);
- FREE(pComponentUUID);
-
+ OMX_FREE(pTunnelcComponentName);
+ OMX_FREE(pTunnelComponentVersion);
+ OMX_FREE(pSpecVersion);
+ OMX_FREE(pComponentUUID);
return bResult;
} /* End of IsTIOMXComponent */
-
-
#ifdef RESOURCE_MANAGER_ENABLED
/* ========================================================================== */
/**
@@ -2626,10 +3111,99 @@ void ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData)
write (pComponentPrivate->nCmdDataPipe[1], &(pComponentPrivate->nToState) ,sizeof(OMX_U32));
OMX_PRMGR2(pComponentPrivate->dbg, "OMX_RmProxyCallback_ResourcesAcquired.\n");
}
+ }
+ else if (RM_Error == OMX_RmProxyCallback_FatalError){
+ /* Deinitialize the component...no error should be returned from
+ * this function. It should clean the system as much as possible */
+ if ( pComponentPrivate->pLCML != NULL && pComponentPrivate->isLCMLActive) {
+ LCML_ControlCodec(((LCML_DSP_INTERFACE*)pComponentPrivate->pLCML)->pCodecinterfacehandle, EMMCodecControlDestroy, NULL);
+ dlclose(pComponentPrivate->pDllHandle);
+ pComponentPrivate->pLCML = NULL;
+ pComponentPrivate->isLCMLActive = 0;
+ }
+
+ pComponentPrivate->nCurState = OMX_StateInvalid;
+ pComponentPrivate->cbInfo.EventHandler(pHandle,
+ pHandle->pApplicationPrivate,
+ OMX_EventError,
+ OMX_ErrorInvalidState,
+ OMX_TI_ErrorSevere,
+ NULL);
+ }
+}
+#endif
+
+void LinkedList_Create(LinkedList *LinkedList) {
+ LinkedList->pRoot = NULL;
+}
+
+void LinkedList_AddElement(LinkedList *LinkedList, void *pValue) {
+ /* create new node and fill the value */
+ Node *pNewNode = (Node *)malloc(sizeof(Node));
+ pNewNode->pValue = (void *)pValue;
+ /*printf("LinkedList:::: Pointer=%p has been added.\n", pNewNode->pValue); */
+ /* add new node on the root to implement quick FIFO */
+ /* modify new node pointers */
+ if(LinkedList->pRoot == NULL) {
+ pNewNode->pNextNode = NULL;
+ }
+ else {
+ pNewNode->pNextNode = LinkedList->pRoot;
+ }
+ /*modify root */
+ LinkedList->pRoot = pNewNode;
+}
+
+void LinkedList_FreeElement(LinkedList *LinkedList, void *pValue) {
+ Node *pNode = LinkedList->pRoot;
+ Node *pPastNode = NULL;
+ while (pNode != NULL) {
+ if (pNode->pValue == pValue) {
+ Node *pTempNode = pNode->pNextNode;
+ if(pPastNode == NULL) {
+ LinkedList->pRoot = pTempNode;
+ }
+ else {
+ pPastNode->pNextNode = pTempNode;
+ }
+ /*printf("LinkedList:::: Pointer=%p has been freed\n", pNode->pValue); */
+ free(pNode->pValue);
+ free(pNode);
+ break;
+ }
+ pPastNode = pNode;
+ pNode = pNode->pNextNode;
}
+}
+void LinkedList_FreeAll(LinkedList *LinkedList) {
+ Node *pTempNode;
+ int nodes = 0;
+ while (LinkedList->pRoot != NULL) {
+ pTempNode = LinkedList->pRoot->pNextNode;
+ /*printf("LinkedList:::: Pointer=%p has been freed\n", LinkedList->pRoot->pValue); */
+ free(LinkedList->pRoot->pValue);
+ free(LinkedList->pRoot);
+ LinkedList->pRoot = pTempNode;
+ nodes++;
+ }
+ /*printf("==================No. of deleted nodes: %d=======================================\n\n", nodes); */
}
-#endif
+void LinkedList_DisplayAll(LinkedList *LinkedList) {
+ Node *pNode = LinkedList->pRoot;
+ int nodes = 0;
+ printf("\n================== Displaying contents of linked list=%p=====================\n", LinkedList);
+ printf("root->\n");
+ while (pNode != NULL) {
+ printf("[Value=%p, NextNode=%p]->\n", pNode->pValue, pNode->pNextNode);
+ pNode = pNode->pNextNode;
+ nodes++;
+ }
+ printf("==================No. of existing nodes: %d=======================================\n\n", nodes);
+}
+void LinkedList_Destroy(LinkedList *LinkedList) {
+ /* do nothing */
+}
diff --git a/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEncoder.c b/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEncoder.c
index 4ee01e1..a6c8df7 100644
--- a/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEncoder.c
+++ b/omx/image/src/openmax_il/jpeg_enc/src/OMX_JpegEncoder.c
@@ -55,7 +55,6 @@
#include <oaf_osal.h>
#include <omx_core.h>
#else
-#include <wchar.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -217,15 +216,12 @@ static OMX_ERRORTYPE JPEGENC_FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent,
if (pBuffer->pBuffer) {
pTemp = (char*)pBuffer->pBuffer;
pTemp -= 128;
- free(pTemp);
+ OMX_FREE(pTemp);
pBuffer->pBuffer = NULL;
}
}
- if (pBuffer) {
- free(pBuffer);
- pBuffer = NULL;
- }
+ OMX_FREE(pBuffer);
if ( pPortDef->bEnabled &&
((pComponentPrivate->nCurState == OMX_StateIdle && pComponentPrivate->nToState != OMX_StateLoaded) ||
@@ -239,7 +235,7 @@ static OMX_ERRORTYPE JPEGENC_FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent,
"Port Unpopulated");
}
- pCompPort->nBuffCount--;
+ pCompPort->nBuffCount--;
OMX_PRBUFFER2(pComponentPrivate->dbg, "JPEGE: bPopulated %d\n", pComponentPrivate->pCompPort[nPortIndex]->pPortDef->bPopulated);
if (pCompPort->nBuffCount == 0) {
pComponentPrivate->pCompPort[nPortIndex]->pPortDef->bPopulated = OMX_FALSE;
@@ -279,8 +275,6 @@ EXIT:
return eError;
}
-
-
OMX_ERRORTYPE JPEGENC_UseBuffer(OMX_IN OMX_HANDLETYPE hComponent,
OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
OMX_IN OMX_U32 nPortIndex,
@@ -304,7 +298,7 @@ OMX_ERRORTYPE JPEGENC_UseBuffer(OMX_IN OMX_HANDLETYPE hComponent,
OMX_CHECK_PARAM(ppBufferHdr);
OMX_CHECK_PARAM(pBuffer);
- if (/*nPortIndex < 0 || */nPortIndex > 1) {
+ if (nPortIndex < 0 || nPortIndex > 1) {
eError = OMX_ErrorBadParameter;
goto EXIT;
}
@@ -329,13 +323,13 @@ OMX_ERRORTYPE JPEGENC_UseBuffer(OMX_IN OMX_HANDLETYPE hComponent,
nOutIndex = pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortFormat->nPortIndex;
if ( (int)nPortIndex == nInpIndex ) {
- OMX_MALLOC_STRUCT(pBuffHeader, OMX_BUFFERHEADERTYPE);
+ OMX_MALLOC(pBuffHeader, sizeof(OMX_BUFFERHEADERTYPE));
OMX_CONF_INIT_STRUCT(pBuffHeader, OMX_BUFFERHEADERTYPE);
pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr = pBuffHeader;
*ppBufferHdr = pBuffHeader;
}
else if ( (int)nPortIndex == nOutIndex ) {
- OMX_MALLOC_STRUCT(pBuffHeader, OMX_BUFFERHEADERTYPE);
+ OMX_MALLOC(pBuffHeader, sizeof(OMX_BUFFERHEADERTYPE));
OMX_CONF_INIT_STRUCT(pBuffHeader, OMX_BUFFERHEADERTYPE);
pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pBufferPrivate[nBufferCount]->pBufferHdr = pBuffHeader;
*ppBufferHdr = pBuffHeader;
@@ -427,11 +421,16 @@ OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComponent)
OMX_ERRORTYPE eError = OMX_ErrorNone;
JPEGENC_COMPONENT_PRIVATE *pComponentPrivate = NULL;
OMX_U8 i = 0;
-
- OMX_CHECK_PARAM(hComponent);
+ /* Allocate memory for component's private data area */
+ OMX_CHECK_PARAM(hComponent);
+
+
+ LinkedList_Create(&AllocList);
+
pHandle = (OMX_COMPONENTTYPE *)hComponent;
- OMX_MALLOC_STRUCT (pHandle->pComponentPrivate, JPEGENC_COMPONENT_PRIVATE);
+ OMX_MALLOC(pHandle->pComponentPrivate, sizeof(JPEGENC_COMPONENT_PRIVATE));
+
pComponentPrivate = (JPEGENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
/* get default settings for debug */
@@ -445,11 +444,11 @@ OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComponent)
pComponentPrivate->pPERFcomp = NULL;
#endif
- /*
- * Assigning address of Component Structure point to place holder
- * inside componentprivate structure
- */
- pComponentPrivate->pHandle = pHandle;
+ /**Assigning address of Component Structure point to place holder inside comp
+ nentprivate structure
+ */
+ ((JPEGENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->pHandle = pHandle;
+
pComponentPrivate->nCurState = OMX_StateLoaded;
pHandle->SetCallbacks = JPEGENC_SetCallbacks;
@@ -476,30 +475,30 @@ OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComponent)
pComponentPrivate->ComponentVersion.s.nVersionMinor = 0x00;
pComponentPrivate->ComponentVersion.s.nRevision = 0x00;
pComponentPrivate->ComponentVersion.s.nStep = 0x00;
- OMX_MALLOC_STRUCT_EXTRA(pComponentPrivate->cComponentName, char, COMP_MAX_NAMESIZE);
+ OMX_MALLOC(pComponentPrivate->cComponentName, COMP_MAX_NAMESIZE+1);
strncpy(pComponentPrivate->cComponentName, cJPEGencName, COMP_MAX_NAMESIZE);
/* Allocate memory for component data structures */
- OMX_MALLOC_STRUCT(pComponentPrivate->pPortParamType, OMX_PORT_PARAM_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pPortParamTypeAudio, OMX_PORT_PARAM_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pPortParamTypeVideo, OMX_PORT_PARAM_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pPortParamTypeOthers, OMX_PORT_PARAM_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGENC_INP_PORT], JPEG_PORT_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT], JPEG_PORT_TYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortFormat, OMX_IMAGE_PARAM_PORTFORMATTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortFormat, OMX_IMAGE_PARAM_PORTFORMATTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pParamBufSupplier, OMX_PARAM_BUFFERSUPPLIERTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pParamBufSupplier, OMX_PARAM_BUFFERSUPPLIERTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pPriorityMgmt, OMX_PRIORITYMGMTTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pQualityfactor, OMX_IMAGE_PARAM_QFACTORTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCrop, OMX_CONFIG_RECTTYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCustomLumaQuantTable, OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pCustomChromaQuantTable, OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE);
- OMX_MALLOC_STRUCT(pComponentPrivate->pHuffmanTable, JPEGENC_CUSTOM_HUFFMANTTABLETYPE);
+ OMX_MALLOC(pComponentPrivate->pPortParamType, sizeof(OMX_PORT_PARAM_TYPE));
+ OMX_MALLOC(pComponentPrivate->pPortParamTypeAudio, sizeof(OMX_PORT_PARAM_TYPE));
+ OMX_MALLOC(pComponentPrivate->pPortParamTypeVideo, sizeof(OMX_PORT_PARAM_TYPE));
+ OMX_MALLOC(pComponentPrivate->pPortParamTypeOthers, sizeof(OMX_PORT_PARAM_TYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGENC_INP_PORT], sizeof(JPEG_PORT_TYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT], sizeof(JPEG_PORT_TYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortFormat, sizeof(OMX_IMAGE_PARAM_PORTFORMATTYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortFormat, sizeof(OMX_IMAGE_PARAM_PORTFORMATTYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pParamBufSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pParamBufSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+ OMX_MALLOC(pComponentPrivate->pPriorityMgmt, sizeof(OMX_PRIORITYMGMTTYPE));
+ OMX_MALLOC(pComponentPrivate->pQualityfactor, sizeof(OMX_IMAGE_PARAM_QFACTORTYPE));
+ OMX_MALLOC(pComponentPrivate->pCrop, sizeof(OMX_CONFIG_RECTTYPE));
+ OMX_MALLOC(pComponentPrivate->pCustomLumaQuantTable, sizeof(OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE));
+ OMX_MALLOC(pComponentPrivate->pCustomChromaQuantTable, sizeof(OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE));
+ OMX_MALLOC(pComponentPrivate->pHuffmanTable, sizeof(JPEGENC_CUSTOM_HUFFMANTTABLETYPE));
for (i = 0;i<NUM_OF_BUFFERSJPEG;i++) {
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pBufferPrivate[i], JPEGENC_BUFFER_PRIVATE);
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pBufferPrivate[i], sizeof(JPEGENC_BUFFER_PRIVATE));
}
for (i = 0;i<NUM_OF_BUFFERSJPEG;i++) {
@@ -507,7 +506,7 @@ OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComponent)
}
for (i = 0;i<NUM_OF_BUFFERSJPEG;i++) {
- OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pBufferPrivate[i], JPEGENC_BUFFER_PRIVATE);
+ OMX_MALLOC(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pBufferPrivate[i], sizeof(JPEGENC_BUFFER_PRIVATE));
}
for (i = 0;i<NUM_OF_BUFFERSJPEG;i++) {
@@ -526,19 +525,11 @@ OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComponent)
pComponentPrivate->bSetLumaQuantizationTable = OMX_FALSE;
pComponentPrivate->bSetChromaQuantizationTable = OMX_FALSE;
- pComponentPrivate->ThumbnailInfo.APP0_THUMB_INDEX = 0;
- pComponentPrivate->ThumbnailInfo.APP1_THUMB_INDEX = 0;
- pComponentPrivate->ThumbnailInfo.APP13_THUMB_INDEX = 0;
-
- pComponentPrivate->ThumbnailInfo.APP0_BUF.size = 0;
- pComponentPrivate->ThumbnailInfo.APP1_BUF.size = 0;
- pComponentPrivate->ThumbnailInfo.APP13_BUF.size = 0;
-
pComponentPrivate->InParams.pInParams = NULL;
pComponentPrivate->InParams.size = 0;
pComponentPrivate->bPreempted = OMX_FALSE;
- OMX_MALLOC_STRUCT_EXTRA(pComponentPrivate->pDynParams, IDMJPGE_TIGEM_DynamicParams, 256);
+ OMX_MALLOC(pComponentPrivate->pDynParams, sizeof(IDMJPGE_TIGEM_DynamicParams)+256);
if (!pComponentPrivate->pDynParams) {
eError = OMX_ErrorInsufficientResources;
goto EXIT;
@@ -648,7 +639,17 @@ OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComponent)
OMX_CONF_INIT_STRUCT(pComponentPrivate->pQualityfactor, OMX_IMAGE_PARAM_QFACTORTYPE);
pComponentPrivate->pQualityfactor->nPortIndex = 1;
pComponentPrivate->pQualityfactor->nQFactor = 100;
-
+
+ pComponentPrivate->sAPP0.bMarkerEnabled = OMX_FALSE;
+ pComponentPrivate->sAPP1.bMarkerEnabled = OMX_FALSE;
+ pComponentPrivate->sAPP5.bMarkerEnabled = OMX_FALSE;
+ pComponentPrivate->sAPP13.bMarkerEnabled = OMX_FALSE;
+
+ pComponentPrivate->sAPP0.pMarkerBuffer = NULL;
+ pComponentPrivate->sAPP1.pMarkerBuffer = NULL;
+ pComponentPrivate->sAPP5.pMarkerBuffer = NULL;
+ pComponentPrivate->sAPP13.pMarkerBuffer = NULL;
+
OMX_CONF_INIT_STRUCT(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pParamBufSupplier, OMX_PARAM_BUFFERSUPPLIERTYPE);
pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pParamBufSupplier->nPortIndex = JPEGENC_INP_PORT;
pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pParamBufSupplier->eBufferSupplier = 0x0;
@@ -695,33 +696,9 @@ OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComponent)
OMX_PRBUFFER2(pComponentPrivate->dbg, "JPEG-ENC: actual buffer %d\n", (int)(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortDef->nBufferCountActual));
EXIT:
if(eError != OMX_ErrorNone){
- FREE(pComponentPrivate->cComponentName);
- FREE(pComponentPrivate->pPortParamType);
- FREE(pComponentPrivate->pPortParamTypeAudio);
- FREE(pComponentPrivate->pPortParamTypeVideo);
- FREE(pComponentPrivate->pPortParamTypeOthers);
- FREE(pComponentPrivate->pCustomLumaQuantTable);
- FREE(pComponentPrivate->pCustomChromaQuantTable);
- FREE(pComponentPrivate->pHuffmanTable);
- FREE(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortDef);
- FREE(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef);
- FREE(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pPortFormat);
- FREE(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortFormat);
- FREE(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pParamBufSupplier);
- FREE(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pParamBufSupplier);
- FREE(pComponentPrivate->pPriorityMgmt);
- FREE(pComponentPrivate->pQualityfactor);
- FREE(pComponentPrivate->pDynParams);
- for (i = 0;i<NUM_OF_BUFFERSJPEG;i++) {
- FREE(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]->pBufferPrivate[i]);
- FREE(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pBufferPrivate[i]);
- }
-#ifdef __PERF_INSTRUMENTATION__
- FREE(pComponentPrivate->pPERF);
-#endif
- FREE(pComponentPrivate->pCompPort[JPEGENC_INP_PORT]);
- FREE(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]);
- FREE(pComponentPrivate);
+ /* LinkedList_DisplayAll (&AllocList); */
+ OMX_FREEALL();
+ LinkedList_Destroy(&AllocList);
}
return eError;
}
@@ -1377,182 +1354,105 @@ static OMX_ERRORTYPE JPEGENC_SetConfig (OMX_HANDLETYPE hComp,
break;
}
- case OMX_IndexCustomThumbnailAPP1_INDEX:
- {
-
- if(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef->format.image.eCompressionFormat == OMX_IMAGE_CodingEXIF){
- pComponentPrivate->ThumbnailInfo.APP1_THUMB_INDEX = * (int *)ComponentConfigStructure;
- if (pComponentPrivate->ThumbnailInfo.APP1_THUMB_INDEX) {
- pComponentPrivate->ThumbnailInfo.APP1_THUMB_W = 44;
- pComponentPrivate->ThumbnailInfo.APP1_THUMB_H = 36;
- }
- eError = SetJpegEncInParams(pComponentPrivate);
- }
- else{
- eError = OMX_ErrorUnsupportedIndex;
- }
- break;
- }
- case OMX_IndexCustomThumbnailAPP1_BUF:
- {
- APP_INFO *pAppInfo;
- if(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef->format.image.eCompressionFormat == OMX_IMAGE_CodingEXIF){
- pAppInfo = (APP_INFO *) ComponentConfigStructure;
- if(pComponentPrivate->ThumbnailInfo.APP1_BUF.app != NULL){
- free(pComponentPrivate->ThumbnailInfo.APP1_BUF.app);
- pComponentPrivate->ThumbnailInfo.APP1_BUF.app = NULL;
- pComponentPrivate->ThumbnailInfo.APP1_BUF.size = 0;
- }
- OMX_MALLOC_STRUCT_EXTRA(pComponentPrivate->ThumbnailInfo.APP1_BUF.app, OMX_U8, (pAppInfo->size-1));
- memcpy(pComponentPrivate->ThumbnailInfo.APP1_BUF.app, pAppInfo->app, pAppInfo->size);
- OMX_MEMCPY_CHECK(pComponentPrivate->ThumbnailInfo.APP1_BUF.app);
- pComponentPrivate->ThumbnailInfo.APP1_BUF.size = pAppInfo->size;
- eError = SetJpegEncInParams(pComponentPrivate);
- }
- else{
- eError = OMX_ErrorUnsupportedIndex;
- }
- break;
- }
- case OMX_IndexCustomThumbnailAPP1_W:
- if(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef->format.image.eCompressionFormat == OMX_IMAGE_CodingEXIF ){
- if (pComponentPrivate->ThumbnailInfo.APP1_THUMB_INDEX) {
- pComponentPrivate->ThumbnailInfo.APP1_THUMB_W = * (int *)ComponentConfigStructure;
- eError = SetJpegEncInParams(pComponentPrivate);
- }
- }
- else{
- eError = OMX_ErrorUnsupportedIndex;
- }
- break;
- case OMX_IndexCustomThumbnailAPP1_H:
- if(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef->format.image.eCompressionFormat == OMX_IMAGE_CodingEXIF){
- if (pComponentPrivate->ThumbnailInfo.APP1_THUMB_INDEX) {
- pComponentPrivate->ThumbnailInfo.APP1_THUMB_H = * (int *)ComponentConfigStructure;
- eError = SetJpegEncInParams(pComponentPrivate);
- }
- }
- else{
- eError = OMX_ErrorUnsupportedIndex;
- }
- break;
+ case OMX_IndexCustomAPP0:
+ {
+ JPEG_APPTHUMB_MARKER *pMarkerInfo = (JPEG_APPTHUMB_MARKER *) ComponentConfigStructure;
+ if (pMarkerInfo->nThumbnailHeight < 0 || pMarkerInfo->nThumbnailWidth < 0) {
+ eError = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
- case OMX_IndexCustomThumbnailAPP0_INDEX:
- {
- if(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef->format.image.eCompressionFormat == OMX_IMAGE_CodingJPEG){
- pComponentPrivate->ThumbnailInfo.APP0_THUMB_INDEX = * (int *)ComponentConfigStructure;
- if (pComponentPrivate->ThumbnailInfo.APP0_THUMB_INDEX) {
- pComponentPrivate->ThumbnailInfo.APP0_THUMB_W = 44;
- pComponentPrivate->ThumbnailInfo.APP0_THUMB_H = 32;
- }
- eError = SetJpegEncInParams(pComponentPrivate);
- }
- else{
- eError = OMX_ErrorUnsupportedIndex;
- }
- break;
- }
- case OMX_IndexCustomThumbnailAPP0_BUF:
- {
- APP_INFO *pAppInfo;
- if(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef->format.image.eCompressionFormat == OMX_IMAGE_CodingJPEG ){
- pAppInfo = (APP_INFO *) ComponentConfigStructure;
- if(pComponentPrivate->ThumbnailInfo.APP0_BUF.app != NULL){
- free(pComponentPrivate->ThumbnailInfo.APP0_BUF.app);
- pComponentPrivate->ThumbnailInfo.APP0_BUF.app = NULL;
- pComponentPrivate->ThumbnailInfo.APP0_BUF.size = 0;
- }
- OMX_MALLOC_STRUCT_EXTRA(pComponentPrivate->ThumbnailInfo.APP0_BUF.app, OMX_U8, (pAppInfo->size-1));
- memcpy(pComponentPrivate->ThumbnailInfo.APP0_BUF.app, pAppInfo->app, pAppInfo->size);
- OMX_MEMCPY_CHECK(pComponentPrivate->ThumbnailInfo.APP0_BUF.app);
- pComponentPrivate->ThumbnailInfo.APP0_BUF.size = pAppInfo->size;
+ if (pComponentPrivate->sAPP0.pMarkerBuffer != NULL) {
+ OMX_FREE(pComponentPrivate->sAPP0.pMarkerBuffer);
+ }
- SetJpegEncInParams(pComponentPrivate);
- }
- else{
- eError = OMX_ErrorUnsupportedIndex;
- }
-
- break;
- }
- case OMX_IndexCustomThumbnailAPP0_W:
- if(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef->format.image.eCompressionFormat == OMX_IMAGE_CodingJPEG ){
- if (pComponentPrivate->ThumbnailInfo.APP0_THUMB_INDEX) {
- pComponentPrivate->ThumbnailInfo.APP0_THUMB_W = * (int *)ComponentConfigStructure;
- eError = SetJpegEncInParams(pComponentPrivate);
- }
- }
- else{
- eError = OMX_ErrorUnsupportedIndex;
- }
- break;
- case OMX_IndexCustomThumbnailAPP0_H:
- if(pComponentPrivate->pCompPort[JPEGENC_OUT_PORT]->pPortDef->format.image.eCompressionFormat == OMX_IMAGE_CodingJPEG ){
- if (pComponentPrivate->ThumbnailInfo.APP0_THUMB_INDEX) {
- pComponentPrivate->ThumbnailInfo.APP0_THUMB_H = * (int *)ComponentConfigStructure;
- eError = SetJpegEncInParams(pComponentPrivate);
- }
- }
- else{
- eError = OMX_ErrorUnsupportedIndex;
- }
- break;
-
- case OMX_IndexCustomThumbnailAPP13_INDEX:
- {
- pComponentPrivate->ThumbnailInfo.APP13_THUMB_INDEX = * (int *)ComponentConfigStructure;
- if (pComponentPrivate->ThumbnailInfo.APP13_THUMB_INDEX) {
- pComponentPrivate->ThumbnailInfo.APP13_THUMB_W = 44;
- pComponentPrivate->ThumbnailInfo.APP13_THUMB_H = 36;
- }
- eError = SetJpegEncInParams(pComponentPrivate);
+ memcpy (&pComponentPrivate->sAPP0, pMarkerInfo, sizeof(JPEG_APPTHUMB_MARKER));
+ OMX_MEMCPY_CHECK(&pComponentPrivate->sAPP0);
+ if (pMarkerInfo->pMarkerBuffer != NULL) {
+ OMX_MALLOC(pComponentPrivate->sAPP0.pMarkerBuffer, pMarkerInfo->nMarkerSize);
+ memcpy (pComponentPrivate->sAPP0.pMarkerBuffer, pMarkerInfo->pMarkerBuffer, pMarkerInfo->nMarkerSize);
+ OMX_MEMCPY_CHECK(pComponentPrivate->sAPP0.pMarkerBuffer);
+ }
+ eError = SetJpegEncInParams(pComponentPrivate);
break;
- }
- case OMX_IndexCustomThumbnailAPP13_BUF:
- {
- APP_INFO *pAppInfo;
+ }
+
+ case OMX_IndexCustomAPP1:
+ {
+ JPEG_APPTHUMB_MARKER *pMarkerInfo = (JPEG_APPTHUMB_MARKER *) ComponentConfigStructure;
+ if (pMarkerInfo->nThumbnailHeight < 0 || pMarkerInfo->nThumbnailWidth < 0) {
+ eError = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ if (pComponentPrivate->sAPP1.pMarkerBuffer != NULL) {
+ OMX_FREE(pComponentPrivate->sAPP1.pMarkerBuffer);
+ }
+
+ memcpy (&pComponentPrivate->sAPP1, pMarkerInfo, sizeof(JPEG_APPTHUMB_MARKER));
+ OMX_MEMCPY_CHECK(&pComponentPrivate->sAPP1);
+ if (pMarkerInfo->pMarkerBuffer != NULL) {
+ OMX_MALLOC(pComponentPrivate->sAPP1.pMarkerBuffer, pMarkerInfo->nMarkerSize);
+ memcpy (pComponentPrivate->sAPP1.pMarkerBuffer, pMarkerInfo->pMarkerBuffer, pMarkerInfo->nMarkerSize);
+ OMX_MEMCPY_CHECK(pComponentPrivate->sAPP1.pMarkerBuffer);
+ }
+
+ eError = SetJpegEncInParams(pComponentPrivate);
+ break;
+ }
+
+ case OMX_IndexCustomAPP5:
+ {
+ JPEG_APPTHUMB_MARKER *pMarkerInfo = (JPEG_APPTHUMB_MARKER *) ComponentConfigStructure;
+ if (pMarkerInfo->nThumbnailHeight < 0 || pMarkerInfo->nThumbnailWidth < 0) {
+ eError = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ if (pComponentPrivate->sAPP5.pMarkerBuffer != NULL) {
+ OMX_FREE(pComponentPrivate->sAPP5.pMarkerBuffer);
+ }
+
+ memcpy (&pComponentPrivate->sAPP5, pMarkerInfo, sizeof(JPEG_APPTHUMB_MARKER));
+ OMX_MEMCPY_CHECK(&pComponentPrivate->sAPP5);
+ if (pMarkerInfo->pMarkerBuffer != NULL) {
+ OMX_MALLOC(pComponentPrivate->sAPP5.pMarkerBuffer, pMarkerInfo->nMarkerSize);
+ memcpy (pComponentPrivate->sAPP5.pMarkerBuffer, pMarkerInfo->pMarkerBuffer, pMarkerInfo->nMarkerSize);
+ OMX_MEMCPY_CHECK(pComponentPrivate->sAPP5.pMarkerBuffer);
+ }
+ eError = SetJpegEncInParams(pComponentPrivate);
+ break;
+ }
+
+ case OMX_IndexCustomAPP13:
+ {
+ JPEG_APP13_MARKER *pMarkerInfo = (JPEG_APP13_MARKER *) ComponentConfigStructure;
+ if (pComponentPrivate->sAPP13.pMarkerBuffer != NULL) {
+ OMX_FREE(pComponentPrivate->sAPP13.pMarkerBuffer);
+ }
+
+ memcpy (&pComponentPrivate->sAPP13, pMarkerInfo, sizeof(JPEG_APP13_MARKER));
+ OMX_MEMCPY_CHECK(&pComponentPrivate->sAPP13);
+ if (pMarkerInfo->pMarkerBuffer != NULL) {
+ OMX_MALLOC(pComponentPrivate->sAPP13.pMarkerBuffer, pMarkerInfo->nMarkerSize);
+ memcpy (pComponentPrivate->sAPP13.pMarkerBuffer, pMarkerInfo->pMarkerBuffer, pMarkerInfo->nMarkerSize);
+ OMX_MEMCPY_CHECK(pComponentPrivate->sAPP13.pMarkerBuffer);
+ }
+
+ eError = SetJpegEncInParams(pComponentPrivate);
+ break;
+ }
- pAppInfo = (APP_INFO *) ComponentConfigStructure;
- if(pComponentPrivate->ThumbnailInfo.APP13_BUF.app != NULL){
- free(pComponentPrivate->ThumbnailInfo.APP13_BUF.app);
- pComponentPrivate->ThumbnailInfo.APP13_BUF.app = NULL;
- pComponentPrivate->ThumbnailInfo.APP13_BUF.size = 0;
- }
- OMX_MALLOC_STRUCT_EXTRA(pComponentPrivate->ThumbnailInfo.APP13_BUF.app, OMX_U8, (pAppInfo->size-1));
- memcpy(pComponentPrivate->ThumbnailInfo.APP13_BUF.app, pAppInfo->app, pAppInfo->size);
- OMX_MEMCPY_CHECK(pComponentPrivate->ThumbnailInfo.APP13_BUF.app);
- pComponentPrivate->ThumbnailInfo.APP13_BUF.size = pAppInfo->size;
-
- eError = SetJpegEncInParams(pComponentPrivate);
-
- break;
- }
- case OMX_IndexCustomThumbnailAPP13_W:
-
- if (pComponentPrivate->ThumbnailInfo.APP13_THUMB_INDEX) {
- pComponentPrivate->ThumbnailInfo.APP13_THUMB_W = * (int *)ComponentConfigStructure;
- eError = SetJpegEncInParams(pComponentPrivate);
- }
-
- break;
- case OMX_IndexCustomThumbnailAPP13_H:
-
- if (pComponentPrivate->ThumbnailInfo.APP13_THUMB_INDEX) {
- pComponentPrivate->ThumbnailInfo.APP13_THUMB_H = * (int *)ComponentConfigStructure;
- eError = SetJpegEncInParams(pComponentPrivate);
- }
-
- break;
case OMX_IndexCustomDRI:
pComponentPrivate->nDRI_Interval = *(OMX_U8 *)ComponentConfigStructure;
break;
+
case OMX_IndexCustomCommentString :
{
if(((JPEGENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->pString_Comment == NULL){
- OMX_MALLOC_STRUCT_EXTRA(((JPEGENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->pString_Comment ,
- OMX_U8, 255);
+ OMX_MALLOC(((JPEGENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->pString_Comment , 256);
}
strncpy((char *)((JPEGENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->pString_Comment, (char *)ComponentConfigStructure, 255);
eError = SetJpegEncInParams(pComponentPrivate);
@@ -1667,7 +1567,7 @@ static OMX_ERRORTYPE JPEGENC_GetState (OMX_HANDLETYPE pComponent, OMX_STATETYPE*
}
if ( pHandle && pHandle->pComponentPrivate ) {
- *pState = pComponentPrivate->nCurState;
+ *pState = ((JPEGENC_COMPONENT_PRIVATE*)pHandle->pComponentPrivate)->nCurState;
}
else
{
@@ -1982,11 +1882,13 @@ static OMX_ERRORTYPE JPEGENC_ComponentDeInit(OMX_HANDLETYPE hComponent)
#endif
EXIT:
+#if 0
#ifdef __PERF_INSTRUMENTATION__
PERF_Boundary(pComponentPrivate->pPERF,
PERF_BoundaryComplete | PERF_BoundaryCleanup);
PERF_Done(pComponentPrivate->pPERF);
#endif
+#endif
OMX_DBG_CLOSE(dbg);
return eError;
}
@@ -2223,7 +2125,7 @@ OMX_ERRORTYPE JPEGENC_AllocateBuffer(OMX_IN OMX_HANDLETYPE hComponent,
}
if(nPortIndex == JPEGENC_INP_PORT) {
- OMX_MALLOC_STRUCT(pBufferHdr, OMX_BUFFERHEADERTYPE);
+ OMX_MALLOC(pBufferHdr, sizeof(OMX_BUFFERHEADERTYPE));
OMX_PRBUFFER2(pComponentPrivate->dbg, "Allocate Buffer Input pBufferPrivate = %p\n",pBufferHdr);
OMX_CONF_INIT_STRUCT(pBufferHdr, OMX_BUFFERHEADERTYPE);
@@ -2238,7 +2140,7 @@ OMX_ERRORTYPE JPEGENC_AllocateBuffer(OMX_IN OMX_HANDLETYPE hComponent,
*ppBuffHead = pBufferHdr;
}
else if(nPortIndex == JPEGENC_OUT_PORT) {
- OMX_MALLOC_STRUCT(pBufferHdr, OMX_BUFFERHEADERTYPE);
+ OMX_MALLOC(pBufferHdr, sizeof(OMX_BUFFERHEADERTYPE));
OMX_PRBUFFER2(pComponentPrivate->dbg, "Allocate Buffer Output pBufferPrivate[0] = %p\n", pBufferHdr);
OMX_CONF_INIT_STRUCT(pBufferHdr, OMX_BUFFERHEADERTYPE);
pBufferHdr->nInputPortIndex = OMX_NOPORT;
@@ -2256,7 +2158,7 @@ OMX_ERRORTYPE JPEGENC_AllocateBuffer(OMX_IN OMX_HANDLETYPE hComponent,
goto EXIT;
}
- OMX_MALLOC_STRUCT_EXTRA(pBufferHdr->pBuffer, OMX_U8, (nSizeBytes+255));
+ OMX_MALLOC(pBufferHdr->pBuffer, nSizeBytes+256);
#ifdef __PERF_INSTRUMENTATION__
PERF_ReceivedFrame(pComponentPrivate->pPERF,
@@ -2380,18 +2282,10 @@ OMX_ERRORTYPE JPEGENC_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN
{"OMX.TI.JPEG.encoder.Config.CommentString", OMX_IndexCustomCommentString},
{"OMX.TI.JPEG.encoder.Config.InputFrameWidth", OMX_IndexCustomInputFrameWidth},
{"OMX.TI.JPEG.encoder.Config.InputFrameHeight", OMX_IndexCustomInputFrameHeight},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP0_INDEX", OMX_IndexCustomThumbnailAPP0_INDEX},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP0_W", OMX_IndexCustomThumbnailAPP0_W},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP0_H", OMX_IndexCustomThumbnailAPP0_H},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP0_BUF", OMX_IndexCustomThumbnailAPP0_BUF},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP1_INDEX", OMX_IndexCustomThumbnailAPP1_INDEX},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP1_W", OMX_IndexCustomThumbnailAPP1_W},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP1_H", OMX_IndexCustomThumbnailAPP1_H},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP1_BUF", OMX_IndexCustomThumbnailAPP1_BUF},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP13_INDEX", OMX_IndexCustomThumbnailAPP13_INDEX},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP13_W", OMX_IndexCustomThumbnailAPP13_W},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP13_H", OMX_IndexCustomThumbnailAPP13_H},
- {"OMX.TI.JPEG.encoder.Config.ThumbnailAPP13_BUF", OMX_IndexCustomThumbnailAPP13_BUF},
+ {"OMX.TI.JPEG.encoder.Config.APP0", OMX_IndexCustomAPP0},
+ {"OMX.TI.JPEG.encoder.Config.APP1", OMX_IndexCustomAPP1},
+ {"OMX.TI.JPEG.encoder.Config.APP5", OMX_IndexCustomAPP5},
+ {"OMX.TI.JPEG.encoder.Config.APP13", OMX_IndexCustomAPP13},
{"OMX.TI.JPEG.encoder.Config.QFactor", OMX_IndexCustomQFactor},
{"OMX.TI.JPEG.encoder.Config.DRI", OMX_IndexCustomDRI},
{"OMX.TI.JPEG.encoder.Config.Debug", OMX_IndexCustomDebug},
@@ -2418,3 +2312,6 @@ OMX_ERRORTYPE JPEGENC_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN
EXIT:
return eError;
}
+
+
+
diff --git a/omx/image/src/openmax_il/jpeg_enc/test/JPEGTestEnc.c b/omx/image/src/openmax_il/jpeg_enc/test/JPEGTestEnc.c
new file mode 100755
index 0000000..1d512b1
--- /dev/null
+++ b/omx/image/src/openmax_il/jpeg_enc/test/JPEGTestEnc.c
@@ -0,0 +1,2098 @@
+
+/*
+ * Copyright 2001-2008 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.
+ */
+/* ====================================================================
+* Texas Instruments OMAP(TM) Platform Software
+* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
+*
+* Use of this software is controlled by the terms and conditions found
+* in the license agreement under which this software has been supplied.
+* ==================================================================== */
+/**
+* @file JPEGTestEnc.c
+*
+* This file implements OMX Component for JPEG encoder that
+* is fully compliant with the OMX specification 1.5.
+*
+* @path $(CSLPATH)\src
+*
+* @rev 0.1
+*/
+/* -------------------------------------------------------------------------------- */
+/* ================================================================================
+*!
+*! Revision History
+*! ===================================
+*!
+*! 22-May-2006 mf: Revisions appear in reverse chronological order;
+*! that is, newest first. The date format is dd-Mon-yyyy.
+* ================================================================================= */
+
+/*utilities includes */
+#ifdef UNDER_CE
+#include <windows.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sched.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/select.h>
+#include <time.h>
+//#include <mcheck.h>
+#include <getopt.h>
+#include <signal.h>
+
+/* OMX includes */
+#include <OMX_Component.h>
+#include "OMX_JpegEnc_CustomCmd.h"
+#include "JPEGTestEnc.h"
+
+/* DSP recovery includes */
+#include <qosregistry.h>
+#include <qosti.h>
+#include <dbapi.h>
+#include <DSPManager.h>
+#include <DSPProcessor.h>
+#include <DSPProcessor_OEM.h>
+
+#define STRESS
+#define NSTRESSCASES 1
+#define STRESSMULTILOAD 1
+#define NUM_OF_PORTS 2
+#define NUM_OF_BUFFERSJPEG 1
+
+#ifdef UNDER_CE
+OMX_STRING StrJpegEncoder= "OMX.TI.IMAGE.JPEG.ENC";
+#else
+ OMX_STRING StrJpegEncoder= "OMX.TI.JPEG.Encoder";
+/* OMX_STRING StrJpegEncoder= "OMX.TI.JPEG.encoder"; */
+#endif
+
+OMX_U8 APPLICATION1_NOTHUMB[]={
+
+/* 0 */0, 0, 0, 0, 0x45, 0x78, 0x69, 0x66, 0x00, 0x00, /* Indicate Exif Data*/
+
+/* 10 */ 0x49, 0x49, /* "Intel" type byte align*/
+
+0x2A, 0x00, /* Confirm "Intel" type byte align*/
+
+/* 14 */ 0x08, 0x00, 0x00, 0x00, /* Offset to first IFDc*/
+
+0x06, 0x00, /* Number of IFD as 1*/
+
+/* 21 */0x0f, 0x01, /* TAG: Make*/
+
+0x02, 0x00, /* Type: Data format is 0x0002, ASCII */
+
+0x0c, 0x00, 0x00, 0x00, /* Count: number of chars*/
+
+0x56, 0x00, 0x00, 0x00, /* Offset Make data*/
+
+/* 33 */0x10, 0x01, /* TAG: Model*/
+
+0x02, 0x00, /* Type: Data format is 0x0002, ASCII */
+
+0x05, 0x00, 0x00, 0x00, /* Count: number of chars*/
+
+0x62, 0x00, 0x00, 0x00, /* Offset Model data*/
+
+/*45*/0x12, 0x01, /* TAG: Orientation*/
+
+0x03, 0x00, /* Type: Data format is 0x0003, (short)*/
+
+0x01, 0x00, 0x00, 0x00, /* Count: number of chars*/
+
+0x01, 0x00, 0x00, 0x00, /* 1 means normal orientation*/
+
+/*57*/0x31, 0x01, /* TAG: Software*/
+
+0x02, 0x00, /* Type: ASCII*/
+
+0x08, 0x00, 0x00, 0x00, /* Count: number of chars*/
+
+0x67, 0x00, 0x00, 0x00, /* Offset*/
+
+/*69*/0x3b, 0x01, /* TAG: Artist*/
+
+0x02, 0x00, /* Type: ASCII*/
+
+0x09, 0x00, 0x00, 0x00, /* Count: number of chars*/
+
+0x6f, 0x00, 0x00, 0x00, /* Offset*/
+
+/* 81 */0x69, 0x87, /* Exif SubIFD*/
+
+/* 83 */ 0x04, 0x00, /* Data format is 0x0004, ULInt*/
+
+0x01, 0x00, 0x00, 0x00, /* number of components is 1.*/
+
+/*long integer data size is 4bytes/components, so total data length is 1x4=4bytes*/
+
+/* 89 */ 0x78, 0x00,0x00, 0x00, /* Offset of Exif data*/
+
+/*93*/0x9E, 0x00, 0x00, 0x00, /* Offset to next IFD. As we are saying only one directory( Number of IFD as 1) this indicate the offset of next IFD*/
+
+/*97*/0x53, 0x61, 0x73, 0x6b, 0x65, 0x6e, 0x20, 0x26, 0x20, 0x54, 0x49, 0x00, /*Make*/
+
+/*109*/0x4f, 0x4d, 0x41, 0x50,0x00, /*Model*/
+
+/*114*/0x4f, 0x70, 0x65, 0x6e, 0x4d, 0x61, 0x78, 0x00, /*Software*/
+
+/*122*/0x47, 0x65, 0x6f, 0x72, 0x67, 0x65, 0x20, 0x53, 0x00, /*Artist*/
+
+/* exif ub-ID start Here */
+
+/* 131 */ 0x03, 0x00, /* Number of Exif ID*/
+
+0x00, 0x90, /* Exif Version*/
+
+0x07, 0x00, /*Data format is 0x0007, undefined*/
+
+0x04, 0x00, 0x00, 0x00, /* number of components is 4.*/
+
+/*Undefined data size is 1bytes/components, so total data length is 4x1=4bytes*/
+
+0x30, 0x32, 0x32, 0x30, /* Exif version number 30 32 32 30 meaning 0220 (2.2)*/
+
+/* next IFD start Here */
+
+/*169*/0x03, 0x00, /* Number of IFD1*/
+
+/*171*/0x03, 0x01, /* Compression (0x0103)*/
+
+0x03, 0x00, /*Data format is 0x0003 unsigned short,*/
+
+0x01, 0x00, 0x00, 0x00, /* number of components is 1.*/
+
+/*unsigned short data size is 2bytes/components, so total data length is 1x2=2bytes*/
+
+/*183*/ 0x01, 0x02, /* JpegIFOffset (0x0201)*/
+
+ 0x04, 0x00, /* Data format is 0x0004, ULInt*/
+
+ 0x01, 0x00, 0x00, 0x00, /* number of components is 1.*/
+
+/*195*/ 0x02, 0x02, /* JpegIFByteCount (0x0202)*/
+
+ 0x04, 0x00, /* Data format is 0x0004, ULInt*/
+
+ 0x01, 0x00, 0x00, 0x00, /* number of components is 1.*/
+
+/*203*/ 0xff, 0xff,0xff, 0xff, /* Legth of thumbnail data*/
+
+};
+
+OMX_U8 APPLICATION1_THUMB[]={
+/* 0 */0, 0, 0, 0, 0x45, 0x78, 0x69, 0x66, 0x00, 0x00, /* Indicate Exif Data*/
+/* 10 */ 0x49, 0x49, /* "Intel" type byte align*/
+0x2A, 0x00, /* Confirm "Intel" type byte align*/
+/* 14 */ 0x08, 0x00, 0x00, 0x00, /* Offset to first IFDc*/
+0x06, 0x00, /* Number of IFD as 1*/
+
+/* 21 */0x0f, 0x01, /* TAG: Make*/
+0x02, 0x00, /* Type: Data format is 0x0002, ASCII */
+0x0c, 0x00, 0x00, 0x00, /* Count: number of chars*/
+0x56, 0x00, 0x00, 0x00, /* Offset Make data*/
+
+/* 33 */0x10, 0x01, /* TAG: Model*/
+0x02, 0x00, /* Type: Data format is 0x0002, ASCII */
+0x05, 0x00, 0x00, 0x00, /* Count: number of chars*/
+0x62, 0x00, 0x00, 0x00, /* Offset Model data*/
+
+/*45*/0x12, 0x01, /* TAG: Orientation*/
+0x03, 0x00, /* Type: Data format is 0x0003, (short)*/
+0x01, 0x00, 0x00, 0x00, /* Count: number of chars*/
+0x01, 0x00, 0x00, 0x00, /* 1 means normal orientation*/
+
+/*57*/0x31, 0x01, /* TAG: Software*/
+0x02, 0x00, /* Type: ASCII*/
+0x08, 0x00, 0x00, 0x00, /* Count: number of chars*/
+0x67, 0x00, 0x00, 0x00, /* Offset*/
+
+/*69*/0x3b, 0x01, /* TAG: Artist*/
+0x02, 0x00, /* Type: ASCII*/
+0x09, 0x00, 0x00, 0x00, /* Count: number of chars*/
+0x6f, 0x00, 0x00, 0x00, /* Offset*/
+
+
+/* 81 */0x69, 0x87, /* Exif SubIFD*/
+/* 83 */ 0x04, 0x00, /* Data format is 0x0004, ULInt*/
+0x01, 0x00, 0x00, 0x00, /* number of components is 1.*/
+/*long integer data size is 4bytes/components, so total data length is 1x4=4bytes*/
+/* 89 */ 0x78, 0x00,0x00, 0x00, /* Offset of Exif data*/
+
+/*93*/0x9E, 0x00, 0x00, 0x00, /* Offset to next IFD. As we are saying only one directory( Number of IFD as 1) this indicate the offset of next IFD*/
+
+/*97*/0x53, 0x61, 0x73, 0x6b, 0x65, 0x6e, 0x20, 0x26, 0x20, 0x54, 0x49, 0x00, /*Make*/
+
+/*109*/0x4f, 0x4d, 0x41, 0x50,0x00, /*Model*/
+
+/*114*/0x4f, 0x70, 0x65, 0x6e, 0x4d, 0x61, 0x78, 0x00, /*Software*/
+
+/*122*/0x47, 0x65, 0x6f, 0x72, 0x67, 0x65, 0x20, 0x53, 0x00, /*Artist*/
+
+/* exif ub-ID start Here */
+/* 131 */ 0x03, 0x00, /* Number of Exif ID*/
+0x00, 0x90, /* Exif Version*/
+0x07, 0x00, /*Data format is 0x0007, undefined*/
+0x04, 0x00, 0x00, 0x00, /* number of components is 4.*/
+/*Undefined data size is 1bytes/components, so total data length is 4x1=4bytes*/
+0x30, 0x32, 0x32, 0x30, /* Exif version number 30 32 32 30 meaning 0220 (2.2)*/
+
+/*145*/0x02, 0xA0, /* Exif Image Width (0xA002)*/
+0x04, 0x00, /* Data format is 0x0004, ULInt*/
+0x01, 0x00, 0x00, 0x00, /* number of components is 1.*/
+/* 153 */ 0xB0, 0x00,0x00, 0x00, /* Image width , 0x00000280 i.e. 640*/
+
+/*157*/0x03, 0xA0, /* Exif Image Width (0xA003)*/
+0x04, 0x00, /* Data format is 0x0004, ULInt*/
+0x01, 0x00, 0x00, 0x00, /* number of components is 1.*/
+/* 165 */ 0x90, 0x00,0x00, 0x00, /* Image Height , 0x000001E0 i.e. 480*/
+
+
+
+/* next IFD start Here */
+/*169*/0x03, 0x00, /* Number of IFD1*/
+/*171*/0x03, 0x01, /* Compression (0x0103)*/
+0x03, 0x00, /*Data format is 0x0003 unsigned short,*/
+0x01, 0x00, 0x00, 0x00, /* number of components is 1.*/
+/*unsigned short data size is 2bytes/components, so total data length is 1x2=2bytes*/
+
+0x06, 0x00,0x00, 0x00, /* '6' means JPEG compression.*/
+ /*Shows compression method.
+ o '1' means no compression,
+ o '6' means JPEG compression.*/
+
+/*183*/ 0x01, 0x02, /* JpegIFOffset (0x0201)*/
+ 0x04, 0x00, /* Data format is 0x0004, ULInt*/
+ 0x01, 0x00, 0x00, 0x00, /* number of components is 1.*/
+/*191*/ 0xc4, 0x00,0x00, 0x00, /* Address 0f Thumbnail data*/
+
+/*195*/ 0x02, 0x02, /* JpegIFByteCount (0x0202)*/
+ 0x04, 0x00, /* Data format is 0x0004, ULInt*/
+ 0x01, 0x00, 0x00, 0x00, /* number of components is 1.*/
+/*203*/ 0xff, 0xff,0xff, 0xff, /* Legth of thumbnail data*/
+};
+
+/*Set the fist 4 bytes to 0*/
+OMX_U8 APPLICATION13[200] = {
+ 0x00, 0x00, 0x00, 0x00, /*We should set the first 4 bytes to 0 */
+ 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x20, 0x33, 0x2e, 0x30, 0x00,/*Photoshop header*/
+ 0x38, 0x42, 0x49, 0x4d, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x4e, /* Initial marker*/
+ /*IPTC Marker TAG Size of string*/
+ 0x1c, 0x02, 0x78, 0x00, 0x20,
+ 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x61, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, /*String of data (ASCII)*/
+ 0x1c, 0x02, 0x7a, 0x00, 0x16,
+ 0x49, 0x27,0x6d, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x61, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x77, 0x72, 0x69, 0x74, 0x65, 0x72,
+ 0x1c, 0x02, 0x5a, 0x00, 0x09,
+ 0x4d, 0x6f, 0x6e, 0x74, 0x65, 0x72, 0x72, 0x65, 0x79,
+
+};
+
+OMX_U8 APPLICATION0[19]={0, 0, 0, 0,
+ 0x4A, 0x46, 0x49, 0x46, 0x00, // JFIF Identifier
+ 0x01, 0x02, // Version
+ 0x00, // X and Y Unit Densities.
+ 0x00, 0x08, // Horizontal Pixel density
+ 0x00, 0x09, // Vertical Pixel density
+ 0x00,
+ 0x00,
+ 0x00,
+};
+
+OMX_U8 APPLICATION5[6]={0xff,0xff,0xff,0xff,0xff,0xff};
+const OMX_U8 CustomLumaQuantizationTable[64]= {
+14, 10, 9, 14, 22, 30, 41, 51,
+12, 12, 14, 19, 26, 58, 60, 55,
+14, 13, 16, 24, 40, 57, 69, 56,
+14, 17, 22, 29, 51, 87, 80, 62,
+18, 22, 37, 56, 68, 109, 103, 77,
+24, 35, 55, 64, 81, 104, 113, 92,
+49, 64, 78, 87, 103, 121, 120, 101,
+72, 92, 95, 98, 112, 100, 103, 99,
+};
+
+const OMX_U8 CustomChromaQuantizationTable[64]= {
+15, 16, 22, 35, 99, 99, 99, 99,
+18, 21, 26, 66, 99, 99, 99, 99,
+24, 26, 56, 99, 99, 99, 99, 99,
+47, 66, 99, 99, 99, 99, 99, 99,
+99, 99, 99, 99, 99, 99, 99, 99,
+99, 99, 99, 99, 99, 99, 99, 99,
+99, 99, 99, 99, 99, 99, 99, 99,
+99, 99, 99, 99, 99, 99, 99, 99
+};
+
+JPEGENC_CUSTOM_HUFFMAN_TABLE CustomHuffmanTable =
+{
+ /* VLC Tables */
+ /*Set 1 for Y Component */
+ /*DC-Y*/
+ /*const unsigned int JPEGENC_DCHUFFY[12] */
+ /*Length[16]-Codeword[16]*/
+ {
+ 0x00020000,
+ 0x00030002,
+ 0x00030003,
+ 0x00030004,
+ 0x00030005,
+ 0x00030006,
+ 0x0004000e,
+ 0x0005001e,
+ 0x0006003e,
+ 0x0007007e,
+ 0x000800fe,
+ 0x000901fe
+ },
+
+ /*AC-Y*/
+ /*const unsigned int JPEGENC_ACHUFFY[16][16] */
+ /*Length[16]-Codeword[16]*/
+ {
+ {
+ 0x0004000a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x000b07f9
+ },
+ {
+ 0x00020000, 0x0004000c, 0x0005001c, 0x0006003a, 0x0006003b, 0x0007007a,
+ 0x0007007b, 0x000800fa, 0x000901f8, 0x000901f9, 0x000901fa, 0x000a03f9,
+ 0x000a03fa, 0x000b07f8, 0x0010ffeb, 0x0010fff5
+ },
+ {
+ 0x00020001, 0x0005001b, 0x000800f9, 0x000901f7, 0x000a03f8, 0x000b07f7,
+ 0x000c0ff6, 0x000c0ff7, 0x000f7fc0, 0x0010ffbe, 0x0010ffc7, 0x0010ffd0,
+ 0x0010ffd9, 0x0010ffe2, 0x0010ffec, 0x0010fff6
+ },
+ {
+ 0x00030004, 0x00070079, 0x000a03f7, 0x000c0ff5, 0x0010ff96, 0x0010ff9e,
+ 0x0010ffa6, 0x0010ffae, 0x0010ffb6, 0x0010ffbf, 0x0010ffc8, 0x0010ffd1,
+ 0x0010ffda, 0x0010ffe3, 0x0010ffed, 0x0010fff7
+ },
+ {
+ 0x0004000b, 0x000901f6, 0x000c0ff4, 0x0010ff8f, 0x0010ff97, 0x0010ff9f,
+ 0x0010ffa7, 0x0010ffaf, 0x0010ffb7, 0x0010ffc0, 0x0010ffc9, 0x0010ffd2,
+ 0x0010ffdb, 0x0010ffe4, 0x0010ffee, 0x0010fff8
+ },
+ {
+ 0x0005001a, 0x000b07f6, 0x0010ff89, 0x0010ff90, 0x0010ff98, 0x0010ffa0,
+ 0x0010ffa8, 0x0010ffb0, 0x0010ffb8, 0x0010ffc1, 0x0010ffca, 0x0010ffd3,
+ 0x0010ffdc, 0x0010ffe5, 0x0010ffef, 0x0010fff9
+ },
+ {
+ 0x00070078, 0x0010ff84, 0x0010ff8a, 0x0010ff91, 0x0010ff99, 0x0010ffa1,
+ 0x0010ffa9, 0x0010ffb1, 0x0010ffb9, 0x0010ffc2, 0x0010ffcb, 0x0010ffd4,
+ 0x0010ffdd, 0x0010ffe6, 0x0010fff0, 0x0010fffa
+ },
+ {
+ 0x000800f8, 0x0010ff85, 0x0010ff8b, 0x0010ff92, 0x0010ff9a, 0x0010ffa2,
+ 0x0010ffaa, 0x0010ffb2, 0x0010ffba, 0x0010ffc3, 0x0010ffcc, 0x0010ffd5,
+ 0x0010ffde, 0x0010ffe7, 0x0010fff1, 0x0010fffb
+ },
+ {
+ 0x000a03f6, 0x0010ff86, 0x0010ff8c, 0x0010ff93, 0x0010ff9b, 0x0010ffa3,
+ 0x0010ffab, 0x0010ffb3, 0x0010ffbb, 0x0010ffc4, 0x0010ffcd, 0x0010ffd6,
+ 0x0010ffdf, 0x0010ffe8, 0x0010fff2, 0x0010fffc
+ },
+ {
+ 0x0010ff82, 0x0010ff87, 0x0010ff8d, 0x0010ff94, 0x0010ff9c, 0x0010ffa4,
+ 0x0010ffac, 0x0010ffb4, 0x0010ffbc, 0x0010ffc5, 0x0010ffce, 0x0010ffd7,
+ 0x0010ffe0, 0x0010ffe9, 0x0010fff3, 0x0010fffd
+ },
+ {
+ 0x0010ff83, 0x0010ff88, 0x0010ff8e, 0x0010ff95, 0x0010ff9d, 0x0010ffa5,
+ 0x0010ffad, 0x0010ffb5, 0x0010ffbd, 0x0010ffc6, 0x0010ffcf, 0x0010ffd8,
+ 0x0010ffe1, 0x0010ffea, 0x0010fff4, 0x0010fffe
+ },
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ },
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ },
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ },
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ },
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ }
+ },
+
+ /*Set 2 for U & V Component */
+ /*DC-UV*/
+ /*const unsigned int JPEGENC_DCHUFFUV[12] */
+ /*Length[16]-Codeword[16]*/
+ {
+ 0x00020000,
+ 0x00020001,
+ 0x00020002,
+ 0x00030006,
+ 0x0004000e,
+ 0x0005001e,
+ 0x0006003e,
+ 0x0007007e,
+ 0x000800fe,
+ 0x000901fe,
+ 0x000a03fe,
+ 0x000b07fe
+ },
+
+ /*AC-UV*/
+ /*const unsigned int JPEGENC_ACHUFFUV[16][16] */
+ /*Length[16]-Codeword[16]*/
+ {
+ {
+ 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x000a03fa
+ },
+ {
+ 0x00020001, 0x0004000b, 0x0005001a, 0x0005001b, 0x0006003a, 0x0006003b,
+ 0x00070079, 0x0007007a, 0x000800f9, 0x000901f7, 0x000901f8, 0x000901f9,
+ 0x000901fa, 0x000b07f9, 0x000e3fe0, 0x000f7fc3
+ },
+ {
+ 0x00030004, 0x00060039, 0x000800f7, 0x000800f8, 0x000901f6, 0x000a03f9,
+ 0x000b07f7, 0x000b07f8, 0x0010ffb7, 0x0010ffc0, 0x0010ffc9, 0x0010ffd2,
+ 0x0010ffdb, 0x0010ffe4, 0x0010ffed, 0x0010fff6
+ },
+ {
+ 0x0004000a, 0x000800f6, 0x000a03f7, 0x000a03f8, 0x0010ff97, 0x0010ff9f,
+ 0x0010ffa7, 0x0010ffaf, 0x0010ffb8, 0x0010ffc1, 0x0010ffca, 0x0010ffd3,
+ 0x0010ffdc, 0x0010ffe5, 0x0010ffee, 0x0010fff7
+ },
+ {
+ 0x00050018, 0x000901f5, 0x000c0ff6, 0x000c0ff7, 0x0010ff98, 0x0010ffa0,
+ 0x0010ffa8, 0x0010ffb0, 0x0010ffb9, 0x0010ffc2, 0x0010ffcb, 0x0010ffd4,
+ 0x0010ffdd, 0x0010ffe6, 0x0010ffef, 0x0010fff8
+ },
+ {
+ 0x00050019, 0x000b07f6, 0x000f7fc2, 0x0010ff91, 0x0010ff99, 0x0010ffa1,
+ 0x0010ffa9, 0x0010ffb1, 0x0010ffba, 0x0010ffc3, 0x0010ffcc, 0x0010ffd5,
+ 0x0010ffde, 0x0010ffe7, 0x0010fff0, 0x0010fff9
+ },
+ {
+ 0x00060038, 0x000c0ff5, 0x0010ff8c, 0x0010ff92, 0x0010ff9a, 0x0010ffa2,
+ 0x0010ffaa, 0x0010ffb2, 0x0010ffbb, 0x0010ffc4, 0x0010ffcd, 0x0010ffd6,
+ 0x0010ffdf, 0x0010ffe8, 0x0010fff1, 0x0010fffa
+ },
+ {
+ 0x00070078, 0x0010ff88, 0x0010ff8d, 0x0010ff93, 0x0010ff9b, 0x0010ffa3,
+ 0x0010ffab, 0x0010ffb3, 0x0010ffbc, 0x0010ffc5, 0x0010ffce, 0x0010ffd7,
+ 0x0010ffe0, 0x0010ffe9, 0x0010fff2, 0x0010fffb
+ },
+ {
+ 0x000901f4, 0x0010ff89, 0x0010ff8e, 0x0010ff94, 0x0010ff9c, 0x0010ffa4,
+ 0x0010ffac, 0x0010ffb4, 0x0010ffbd, 0x0010ffc6, 0x0010ffcf, 0x0010ffd8,
+ 0x0010ffe1, 0x0010ffea, 0x0010fff3, 0x0010fffc
+ },
+ {
+ 0x000a03f6, 0x0010ff8a, 0x0010ff8f, 0x0010ff95, 0x0010ff9d, 0x0010ffa5,
+ 0x0010ffad, 0x0010ffb5, 0x0010ffbe, 0x0010ffc7, 0x0010ffd0, 0x0010ffd9,
+ 0x0010ffe2, 0x0010ffeb, 0x0010fff4, 0x0010fffd
+ },
+ {
+ 0x000c0ff4, 0x0010ff8b, 0x0010ff90, 0x0010ff96, 0x0010ff9e, 0x0010ffa6,
+ 0x0010ffae, 0x0010ffb6, 0x0010ffbf, 0x0010ffc8, 0x0010ffd1, 0x0010ffda,
+ 0x0010ffe3, 0x0010ffec, 0x0010fff5, 0x0010fffe
+ },
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ },
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ },
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ },
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ },
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000
+ }
+ },
+
+ /* DHT Marker */
+ /* lum_dc_codelens */
+ {0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0},
+ /* lum_dc_ncodes */
+ 16,
+ /* lum_dc_symbols */
+ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
+ /* lum_dc_nsymbols */
+ 12,
+ /* lum_ac_codelens */
+ {0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d},
+ /* lum_ac_ncodes */
+ 16,
+ /* lum_ac_symbols */
+ {
+ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
+ 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
+ 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
+ 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
+ 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
+ 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
+ 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
+ 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
+ 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
+ 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
+ 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
+ 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
+ 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
+ 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
+ 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
+ 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
+ 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
+ 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+ 0xf9, 0xfa
+ },
+
+ /* lum_ac_nsymbols */
+ 162,
+ /* chm_dc_codelens */
+ {0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0},
+ /* chm_dc_ncodes */
+ 16,
+ /* chm_dc_symbols */
+ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
+ /* chm_dc_nsymbols */
+ 12,
+ /* chm_ac_codelens */
+ {0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77},
+ /* chm_ac_ncodes */
+ 16,
+ /* chm_ac_symbols */
+ {
+ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
+ 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
+ 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
+ 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
+ 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
+ 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
+ 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
+ 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
+ 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
+ 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
+ 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
+ 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
+ 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
+ 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+ 0xf9, 0xfa
+ },
+ /* chm_ac_nsymbols */
+ 162
+};
+
+
+typedef unsigned char uchar;
+/**
+ * Pipe used to communicate back to the main thread from the component thread;
+**/
+int IpBuf_Pipe[2];
+int OpBuf_Pipe[2];
+int Event_Pipe[2];
+
+/* the FLAG when we need to DeInit the OMX */
+int DEINIT_FLAG = 0;
+
+/* Flag set when component is preempted */
+int bPreempted=0;
+
+/* Hardware error flag */
+OMX_BOOL bError = OMX_FALSE;
+
+/*function prototypes */
+inline int maxint(int a, int b);
+OMX_ERRORTYPE SetMarkers(OMX_HANDLETYPE pHandle, IMAGE_INFO *imageinfo, OMX_CONFIG_RECTTYPE sCrop, int nWidth, int nHeight);
+
+#ifdef DSP_MMU_FAULT_HANDLING
+int LoadBaseImage();
+#endif
+
+/*Routine to get the maximum of 2 integers */
+inline int maxint(int a, int b)
+{
+ return(a>b) ? a : b;
+}
+
+
+/**
+ * This method will wait for the component or mixer to get to the correct
+ * state. It is not a real implementation, but just simulates what a real
+ * wait routine may do.
+**/
+static OMX_ERRORTYPE WaitForState(OMX_HANDLETYPE* pHandle,
+ OMX_STATETYPE DesiredState)
+{
+ OMX_STATETYPE CurState = OMX_StateInvalid;
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ int nCnt = 0;
+ OMX_COMPONENTTYPE *pComponent = (OMX_COMPONENTTYPE *)pHandle;
+
+ PRINT("Inside Test Application WaitForState function\n");
+ eError = pComponent->GetState(pHandle, &CurState);
+ while ( (eError == OMX_ErrorNone) &&
+ (CurState != DesiredState)) {
+ sched_yield();
+ /*sleep(1);*/
+ if ( nCnt++ == 0xFFFFFFFE ) {
+ fprintf(stderr, "Press CTL-C to continue\n");
+ }
+
+ eError = pComponent->GetState(pHandle, &CurState);
+ if (CurState == OMX_StateInvalid && DesiredState != OMX_StateInvalid) {
+ eError = OMX_ErrorInvalidState;
+ break;
+ }
+ }
+
+ if ( eError != OMX_ErrorNone ) {
+ PRINT("Error: Couldn't get state for component or sent to invalid state because of an error.\n");
+ return eError;
+ }
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE EventHandler(OMX_HANDLETYPE hComponent,OMX_PTR pAppData,OMX_EVENTTYPE eEvent,
+ OMX_U32 nData1, OMX_U32 data2, OMX_PTR pEventData)
+{
+ OMX_COMPONENTTYPE *pComponent = (OMX_COMPONENTTYPE *)hComponent;
+ OMX_STATETYPE state;
+ OMX_ERRORTYPE eError;
+ JPEGE_EVENTPRIVATE MyEvent;
+
+ MyEvent.eEvent = eEvent;
+ MyEvent.nData1 = nData1;
+ MyEvent.nData2 = data2;
+ MyEvent.pAppData = pAppData;
+ MyEvent.pEventInfo = pEventData;
+ PRINT("Inside Test Application EventHandler function\n");
+ eError = pComponent->GetState (hComponent, &state);
+ if ( eError != OMX_ErrorNone ) {
+ PRINT("Error: From JPEGENC_GetState\n");
+ }
+ switch ( eEvent ) {
+
+ case OMX_EventCmdComplete:
+ PRINT ("Component State Changed\n");
+ break;
+
+ case OMX_EventError:
+ if (nData1 == OMX_ErrorHardware){
+ printf("\n\nAPP:: ErrorNotification received: Error Num = %p Severity = %ld String = %s\n", (OMX_PTR)nData1, data2, (OMX_STRING)pEventData);
+ printf("\nAPP:: OMX_ErrorHardware. Deinitialization of the component....\n\n");
+ if(!bError) {
+ bError = OMX_TRUE;
+ write(Event_Pipe[1], &MyEvent, sizeof(JPEGE_EVENTPRIVATE));
+ }
+ }
+ else if(nData1 == OMX_ErrorResourcesPreempted) {
+ bPreempted = 1;
+ PRINT("APP:: OMX_ErrorResourcesPreempted !\n\n");
+ }
+ else if(nData1 == OMX_ErrorInvalidState) {
+ printf("\n\nAPP:: ErrorNotification received: Error Num = %p Severity = %ld String = %s\n", (OMX_PTR)nData1, data2, (OMX_STRING)pEventData);
+ printf("\nAPP:: Invalid state\n\n");
+ if(!bError) {
+ bError = OMX_TRUE;
+ write(Event_Pipe[1], &MyEvent, sizeof(JPEGE_EVENTPRIVATE));
+ }
+ }
+ else if(nData1 == OMX_ErrorPortUnpopulated) {
+ printf("APP:: OMX_ErrorPortUnpopulated\n");
+ bError = OMX_TRUE;
+ }
+ else if (nData1 == OMX_ErrorStreamCorrupt) {
+ printf("\n\nAPP:: ErrorNotification received: Error Num = %p Severity = %ld String = %s\n", (OMX_PTR)nData1, data2, (OMX_STRING)pEventData);
+ printf("%s: Stream Corrupt (%ld %s)\n",__FUNCTION__,data2,(char*)pEventData);
+ if(!bError) {
+ bError = OMX_TRUE;
+ write(Event_Pipe[1], &MyEvent, sizeof(JPEGE_EVENTPRIVATE));
+ }
+ }
+ else {
+ bError = OMX_TRUE;
+ DEINIT_FLAG = 1;
+ }
+
+ break;
+
+ case OMX_EventResourcesAcquired:
+ bPreempted = 0;
+ break;
+
+ case OMX_EventPortSettingsChanged:
+ case OMX_EventBufferFlag:
+ PRINT("Event Buffer Flag detected\n");
+ case OMX_EventMax:
+ case OMX_EventMark:
+ break;
+
+ default:
+ PRINT("ErrorNotification received: Error Num %p: String :%s\n", (OMX_PTR)nData1, (OMX_STRING)pEventData);
+ }
+
+ return OMX_ErrorNone;
+}
+
+
+void FillBufferDone (OMX_HANDLETYPE hComponent, OMX_PTR ptr,
+ OMX_BUFFERHEADERTYPE* pBuffHead)
+{
+ PRINT("Inside Test Application FillBufferDone function\n");
+ write(OpBuf_Pipe[1], &pBuffHead, sizeof(pBuffHead));
+}
+
+
+void EmptyBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR ptr,
+ OMX_BUFFERHEADERTYPE* pBuffer)
+{
+ PRINT("Inside Test Application EmptyBufferDone function\n");
+ write(IpBuf_Pipe[1], &pBuffer, sizeof(pBuffer));
+}
+
+#ifdef UNDER_CE
+int fill_data (OMX_BUFFERHEADERTYPE *pBufferPrivate, HANDLE fIn, int buffSize)
+#else
+int fill_data (OMX_BUFFERHEADERTYPE *pBuf, FILE *fIn, int buffSize)
+#endif
+{
+ int nRead;
+ OMX_U8 oneByte;
+ PRINT("Inside Test Application fill_data function\n");
+
+#ifdef UNDER_CE
+ ReadFile(fIn, pBuf->pBuffer, lSize, &nRead, NULL);
+#else
+ nRead = fread(pBuf->pBuffer,1, buffSize , fIn);
+#endif
+
+ printf ("Buffer Size = %d. Read %d bytes from file. \n", (int) buffSize, (int)nRead);
+ pBuf->nFilledLen = nRead;
+
+ oneByte = fgetc(fIn);
+ if (feof(fIn)){
+ pBuf->nFlags = OMX_BUFFERFLAG_ENDOFFRAME;
+ PRINT("Read full file...\n");
+ rewind(fIn);
+ }
+ else{
+ ungetc(oneByte, fIn);
+ }
+
+ return nRead;
+}
+
+OMX_ERRORTYPE SetMarkers(OMX_HANDLETYPE pHandle, IMAGE_INFO *imageinfo, OMX_CONFIG_RECTTYPE sCrop, int nWidth, int nHeight) {
+
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_INDEXTYPE nCustomIndex = OMX_IndexMax;
+
+ /* Set APP0 Marker config (JFIF) */
+ if (imageinfo->bAPP0) {
+
+ JPEG_APPTHUMB_MARKER sAPP0;
+
+ sAPP0.bMarkerEnabled = OMX_TRUE;
+
+ /* set JFIF marker buffer */
+ sAPP0.nMarkerSize = sizeof(APPLICATION0);
+ sAPP0.pMarkerBuffer = APPLICATION0;
+ sAPP0.nThumbnailWidth = imageinfo->nThumbnailWidth_app0;
+ sAPP0.nThumbnailHeight = imageinfo->nThumbnailHeight_app0;
+
+ eError = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.encoder.Config.APP0", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ eError = OMX_SetConfig(pHandle, nCustomIndex, &sAPP0);
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ }
+
+ /* Set APP1 Marker config (EXIF) */
+ if (imageinfo->bAPP1) {
+
+ JPEG_APPTHUMB_MARKER sAPP1;
+
+ sAPP1.bMarkerEnabled = OMX_TRUE;
+
+ /* set JFIF marker buffer */
+ sAPP1.nThumbnailWidth = imageinfo->nThumbnailWidth_app1;
+ sAPP1.nThumbnailHeight = imageinfo->nThumbnailHeight_app1;
+
+ /* if thumbnail is set, use APPLICATION structure with thumbnail */
+ if(sAPP1.nThumbnailWidth > 0 && sAPP1.nThumbnailHeight > 0) {
+ sAPP1.nMarkerSize = sizeof(APPLICATION1_THUMB);
+ sAPP1.pMarkerBuffer = APPLICATION1_THUMB;
+ }
+ else {
+ sAPP1.nMarkerSize = sizeof(APPLICATION1_NOTHUMB);
+ sAPP1.pMarkerBuffer = APPLICATION1_NOTHUMB;
+ }
+
+ /*set crop */
+ if (sCrop.nWidth != 0)
+ {
+ sAPP1.pMarkerBuffer[152] = sCrop.nWidth & 0xFF;
+ sAPP1.pMarkerBuffer[153] = (sCrop.nWidth >> 8) & 0xFF;
+ }
+ else
+ {
+ sAPP1.pMarkerBuffer[152] = nWidth & 0xFF;
+ sAPP1.pMarkerBuffer[153] = (nWidth >> 8) & 0xFF;
+ }
+
+ if (sCrop.nHeight != 0)
+ {
+ sAPP1.pMarkerBuffer[164] = sCrop.nHeight;
+ sAPP1.pMarkerBuffer[165] = (sCrop.nHeight >> 8) & 0xFF;
+ }
+ else
+ {
+ sAPP1.pMarkerBuffer[164] = nHeight;
+ sAPP1.pMarkerBuffer[165] = (nHeight >> 8) & 0xFF;
+ }
+
+ eError = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.encoder.Config.APP1", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ eError = OMX_SetConfig(pHandle, nCustomIndex, &sAPP1);
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ }
+
+ /* Set APP5 Marker config */
+ if (imageinfo->bAPP5) {
+
+ JPEG_APPTHUMB_MARKER sAPP5;
+
+ sAPP5.bMarkerEnabled = OMX_TRUE;
+
+ /* set JFIF marker buffer */
+ sAPP5.nMarkerSize = sizeof(APPLICATION5);
+ sAPP5.pMarkerBuffer = APPLICATION5;
+ sAPP5.nThumbnailWidth = imageinfo->nThumbnailWidth_app5;
+ sAPP5.nThumbnailHeight = imageinfo->nThumbnailHeight_app5;
+
+ eError = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.encoder.Config.APP5", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ eError = OMX_SetConfig(pHandle, nCustomIndex, &sAPP5);
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ }
+
+ /* Set APP13 Marker config */
+ if (imageinfo->bAPP13) {
+
+ JPEG_APP13_MARKER sAPP13;
+
+ sAPP13.bMarkerEnabled = OMX_TRUE;
+
+ /* set JFIF marker buffer */
+ sAPP13.nMarkerSize = sizeof(APPLICATION13);
+ sAPP13.pMarkerBuffer = APPLICATION13;
+
+ eError = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.encoder.Config.APP13", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ eError = OMX_SetConfig(pHandle, nCustomIndex, &sAPP13);
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ }
+
+ /* set comment marker */
+ if (imageinfo->nComment) {
+ eError = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.encoder.Config.CommentFlag", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ eError = OMX_SetConfig(pHandle, nCustomIndex, &(imageinfo->nComment));
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ eError = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.encoder.Config.CommentString", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ eError = OMX_SetConfig(pHandle, nCustomIndex, imageinfo->pCommentString);
+ if ( eError != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, eError);
+ eError = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ }
+
+EXIT:
+ return eError;
+}
+
+void PrintUsage(void)
+{
+ printf("\ni.. Input File\n");
+ printf("o.. Output File\n");
+ printf("w.. Width Of Image\n");
+ printf("h.. Height Of Image\n");
+ printf("f.. Input Of Image:\n 1.- YUV 420 Planer\n 2.- YUV 422 Interleaved UYVY\n 3.- 32 bit RAW (RGB32)\n 4.- 16 bit RAW (RGB16)\n 5.- YUV 422 Interleaved YUYV\n");
+ printf("q.. Quality Factor Of Image: 1 to 100\n");
+ printf("b.. Exit Buffer: 1 o 2\n");
+ printf("c.. Marker Comment: The comment string length should be less than 255 characters\n");
+ printf("j.. Marker APP0: Contain Information about JFIF\n");
+ printf("e.. Marker APP1: Contain Information about EXIF\n");
+ printf("d.. Marker APP5: Contain Miscellaneous Information\n");
+ printf("m.. Marker APP13: Contain Miscellaneous Information\n");
+ printf("x.. Width of Thumbnail of EXIF (default set to 88)\n");
+ printf("y.. Height of Thumbnail of EXIF (default set to 72)\n");
+ printf("s.. Width of Thumbnail of JFIF (default set to 88)\n");
+ printf("k.. Height of Thumbnail of JFIF (default set to 72)\n");
+ printf("n.. Width of Thumbnail of APP5 (default set to 88)\n");
+ printf("p.. Height of Thumbnail of APP5 (default set to 72)\n");
+ printf("t.. Type of Quantization Table \n\t 0.-Default Quantization Tables \n\t 1.-Custom Luma And Choma Tables\n");
+ printf("u.. Type of Huffman Table \n\t 0.-Default Huffman Table \n\t 1.-Custom Huffman Table\n");
+ printf("r.. No. of times to repeat\n");
+ printf("v.. Crop width value\n");
+ printf("l.. Crop height value\n");
+
+ printf("\na.. Prints this information\n");
+ printf("\nExample: ./JPEGTestEnc_common -i patterns/JPGE_CONF_003.yuv -o output.jpg -w 176 -h 144 -f 2 -q 100 -b 1 -c JPEG -j -e -m -x 100 -y 100 -r 1\n\n");
+}
+
+
+#ifdef UNDER_CE
+int _tmain(int argc, TCHAR **argv)
+#else
+int main(int argc, char** argv)
+#endif
+{
+
+#ifndef UNDER_CE
+//mtrace();
+#endif
+ OMX_HANDLETYPE pHandle;
+ OMX_U32 AppData = 100;
+
+ OMX_CALLBACKTYPE JPEGCaBa = {(void *)EventHandler,
+ (void*) EmptyBufferDone,
+ (void*)FillBufferDone};
+ int retval;
+ int nWidth;
+ int nHeight;
+ int framesent = 0;
+ int nRepeated = 0;
+ int maxRepeat = 1;
+ int inputformat;
+ int qualityfactor;
+ int buffertype;
+ int bSetCustomHuffmanTable=0;
+ int bSetCustomQuatizationTable=0;
+ sigset_t set;
+
+ OMX_STATETYPE state;
+ OMX_COMPONENTTYPE *pComponent;
+ IMAGE_INFO* imageinfo = NULL;
+ OMX_PORT_PARAM_TYPE* pPortParamType = NULL;
+ OMX_IMAGE_PARAM_QFACTORTYPE* pQfactorType = NULL;
+ JPEGENC_CUSTOM_HUFFMANTTABLETYPE *pHuffmanTable = NULL;
+ OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE *pQuantizationTable = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE* pInPortDef = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE* pOutPortDef = NULL;
+ OMX_CONFIG_RECTTYPE sCrop;
+
+#ifdef UNDER_CE
+ TCHAR* szInFile = NULL;
+ TCHAR* szOutFile = NULL;
+ HANDLE fIn = NULL;
+ HANDLE fOut = NULL;
+ DWORD dwWritten;
+#else
+ char* szInFile = NULL;
+ char* szOutFile = NULL;
+
+ FILE* fIn = NULL;
+ FILE* fOut = NULL;
+#endif
+
+ OMX_BUFFERHEADERTYPE* pInBuff[NUM_OF_BUFFERSJPEG];
+ OMX_BUFFERHEADERTYPE* pOutBuff[NUM_OF_BUFFERSJPEG];
+ int nCounter = 0;
+ int fdmax;
+ OMX_U8* pTemp;
+ OMX_U8* pInBuffer[NUM_OF_BUFFERSJPEG];
+ OMX_U8* pOutBuffer[NUM_OF_BUFFERSJPEG];
+ OMX_BUFFERHEADERTYPE* pBuffer;
+ OMX_BUFFERHEADERTYPE* pBuf;
+ int nRead;
+ int done;
+ OMX_S32 sJPEGEnc_CompID = 300;
+ int nIndex1= 0;
+ int nIndex2 = 0;
+ int nframerecieved = 0;
+ int nMultFactor = 0;
+ int nHeightNew, nWidthNew;
+ OMX_INDEXTYPE nCustomIndex = OMX_IndexMax;
+ OMX_ERRORTYPE error = OMX_ErrorNone;
+
+#ifdef STRESS
+ int multiload = 0;
+#endif
+
+ int next_option;
+ const char* const short_options = "i:o:w:h:f:q:b:c:x:y:s:k:t:u:r:v:l:n:p:ajemd";
+ const struct option long_options[] =
+ {
+ { "InputFile",1, NULL, 'i' },
+ { "OutputFile",1, NULL, 'o' },
+ { "WidthImage",1, NULL, 'w' },
+ { "HeightImage",1, NULL, 'h' },
+ { "inputFormat",1, NULL, 'f' },
+ { "QualityFactor",1, NULL, 'q' },
+ { "Ext/IntBuffer",1, NULL, 'b' },
+ { "MarkerComment",1, NULL, 'c' },
+ { "EXIFwidthThumbnail",1, NULL, 'x' },
+ { "EXIFheightThumbnail",1, NULL, 'y' },
+ { "JFIFwidthThumbnail",1, NULL, 's' },
+ { "JFIFheightThumbnail",1, NULL, 'k' },
+ { "APP5heightThumbnail",1, NULL, 'p' },
+ { "APP5widthThumbnail",1, NULL, 'n' },
+ { "Repetition",1, NULL, 'r' },
+ {"QuantizationTable",1,NULL,'t'},
+ {"HuffmanTable",1,NULL,'u'},
+ { "help", 0, NULL, 'a' },
+ { "MarkerAPP0",0,NULL,'j'},
+ { "MarkerAPP1",0,NULL,'e'},
+ { "MarkerAPP13",0,NULL,'m'},
+ { "MarkerAPP5",0,NULL,'d'},
+ { "CroppedWidth",0,NULL,'v'},
+ { "CroppedHeight",0,NULL,'l'},
+ { NULL, 0, NULL, 0 }
+ };
+
+ MALLOC(pPortParamType, OMX_PORT_PARAM_TYPE);
+ MALLOC(pQfactorType, OMX_IMAGE_PARAM_QFACTORTYPE);
+ MALLOC(pQuantizationTable,OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE);
+ MALLOC(pHuffmanTable, JPEGENC_CUSTOM_HUFFMANTTABLETYPE);
+ MALLOC(pInPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
+ MALLOC(pOutPortDef, OMX_PARAM_PORTDEFINITIONTYPE);
+ MALLOC(imageinfo, IMAGE_INFO);
+
+ /* Setting up default parameters */
+ szOutFile="output.jpg";
+ nWidth=176;
+ nHeight=144;
+ inputformat=1;
+ qualityfactor=100;
+ buffertype=1;
+
+ imageinfo->nThumbnailWidth_app0 = 0;
+ imageinfo->nThumbnailHeight_app0 = 0;
+ imageinfo->nThumbnailWidth_app1 = 0;
+ imageinfo->nThumbnailHeight_app1 = 0;
+ imageinfo->nThumbnailWidth_app5 = 0;
+ imageinfo->nThumbnailHeight_app5 = 0;
+ imageinfo->nThumbnailWidth_app13 = 0;
+ imageinfo->nThumbnailHeight_app13 = 0;
+
+ imageinfo->bAPP0 = OMX_FALSE;
+ imageinfo->bAPP1 = OMX_FALSE;
+ imageinfo->bAPP5 = OMX_FALSE;
+ imageinfo->bAPP13 = OMX_FALSE;
+ imageinfo->nComment = OMX_FALSE;
+ imageinfo->pCommentString = NULL;
+
+ sCrop.nTop = 0;
+ sCrop.nLeft = 0;
+ sCrop.nWidth = 0;
+ sCrop.nHeight = 0;
+
+ if (argc <= 1)
+ {
+ PrintUsage();
+ return 0;
+ }
+
+do
+{
+ next_option = getopt_long(argc, argv, short_options,long_options, NULL);
+ switch(next_option)
+ {
+ case 'a':
+ PrintUsage();
+ return 0;
+ break;
+
+ case 'i':
+ szInFile=optarg;
+ break;
+
+ case 'o':
+ szOutFile=optarg;
+ break;
+
+ case 'w':
+ nWidth = atoi(optarg);
+ break;
+
+ case 'h':
+ nHeight=atoi(optarg);
+ break;
+
+ case 'f':
+ inputformat=atoi(optarg);
+ break;
+
+ case 'q':
+ qualityfactor=atoi(optarg);
+ break;
+
+ case 'b':
+ buffertype=atoi(optarg);
+ break;
+
+ case 'c':
+ imageinfo->nComment = 1;
+ imageinfo->pCommentString = (char *)optarg;
+ break;
+
+ /*EXIF */
+
+ case 'e':
+ imageinfo->bAPP1 = OMX_TRUE;
+ break;
+
+ case 'x':
+ imageinfo->nThumbnailWidth_app1 = atoi(optarg);
+ break;
+
+ case 'y':
+ imageinfo->nThumbnailHeight_app1 = atoi(optarg);
+ break;
+
+ /* JFIF */
+ case 'j':
+ imageinfo->bAPP0 = OMX_TRUE;
+ break;
+
+ case 's':
+ imageinfo->nThumbnailWidth_app0 = atoi(optarg);
+ break;
+
+ case 'k':
+ imageinfo->nThumbnailHeight_app0 = atoi(optarg);
+ break;
+
+
+ case 'n':
+ imageinfo->nThumbnailWidth_app5 = atoi(optarg);
+ break;
+
+ case 'p':
+ imageinfo->nThumbnailHeight_app5 = atoi(optarg);
+ break;
+
+ case 'm':
+ imageinfo->bAPP13 = OMX_TRUE;
+ break;
+
+ case 'd':
+ imageinfo->bAPP5 = OMX_TRUE;
+ break;
+
+ case 't':
+ bSetCustomQuatizationTable=atoi(optarg);
+ break;
+
+ case 'u':
+ bSetCustomHuffmanTable=atoi(optarg);
+ break;
+
+ case 'r':
+ maxRepeat = atoi(optarg);
+ break;
+
+ case 'v':
+ sCrop.nWidth = atoi(optarg);
+ break;
+
+ case 'l':
+ sCrop.nHeight = atoi(optarg);
+ break;
+
+ }
+}while (next_option != -1);
+
+ printf("\n------------------------------------------------\n");
+ printf("OMX JPEG Encoder Test App built on " __DATE__ ":" __TIME__ "\n");
+ printf("------------------------------------------------\n");
+ printf("Output File Name is %s \n" , szOutFile);
+
+#ifdef STRESS
+
+ for (multiload = 0; multiload < STRESSMULTILOAD; multiload ++) {
+ printf("Stress Test: Iteration %d\n", multiload + 1);
+#endif
+
+
+#ifdef DSP_MMU_FAULT_HANDLING
+/* LOAD BASE IMAGE FIRST TIME */
+ LoadBaseImage();
+#endif
+
+ error = TIOMX_Init();
+ if ( error != OMX_ErrorNone ) {
+ PRINT("Error returned by OMX_Init()\n");
+ goto EXIT;
+ }
+
+ printf("OMX_Init Successful!\n");
+
+ error = TIOMX_GetHandle(&pHandle,StrJpegEncoder,(void *)&AppData, &JPEGCaBa);
+ if ( (error != OMX_ErrorNone) || (pHandle == NULL) ) {
+ fprintf (stderr,"Error in Get Handle function\n");
+ goto EXIT;
+ }
+
+#ifdef STRESS
+ OMX_U8 i;
+ for(i=0; i < NSTRESSCASES; i++) {
+ printf("Stress test number %d\n",i);
+#endif
+
+ /* Create a pipe used to queue data from the callback. */
+ retval = pipe(IpBuf_Pipe);
+ if ( retval != 0 ) {
+ fprintf(stderr, "Error:Fill Data Pipe failed to open\n");
+ goto EXIT;
+ }
+
+ retval = pipe(OpBuf_Pipe);
+ if ( retval != 0 ) {
+ fprintf(stderr, "Error:Empty Data Pipe failed to open\n");
+ goto EXIT;
+ }
+
+ retval = pipe(Event_Pipe);
+ if ( retval != 0 ) {
+ fprintf(stderr, "Error:Empty Data Pipe failed to open\n");
+ goto EXIT;
+ }
+
+ PRINT("Input/Output Pipes created\n");
+
+ /* save off the "max" of the handles for the selct statement */
+ fdmax = maxint(IpBuf_Pipe[0], OpBuf_Pipe[0]);
+ fdmax = maxint(Event_Pipe[0], fdmax);
+
+#ifdef UNDER_CE
+ fIn = CreateFile(szInFile, GENERIC_READ, 0,
+ NULL,OPEN_EXISTING, 0, NULL);
+ if (INVALID_HANDLE_VALUE == fIn)
+ {
+ PRINT("Error: failed to open the file %s for " \
+ "reading\n", szInFile);
+ goto EXIT;
+ }
+#else
+ fIn = fopen(szInFile, "r");
+ if ( fIn == NULL ) {
+ printf("Error: failed to open the file <%s> for reading\n",
+ szInFile);
+ goto EXIT;
+ }
+ PRINT(" File %s opened \n" , szInFile);
+#endif
+
+
+ error = OMX_GetParameter(pHandle, OMX_IndexParamImageInit, pPortParamType);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ nIndex1 = pPortParamType->nStartPortNumber;
+ nIndex2 = nIndex1 + 1;
+ pInPortDef->nPortIndex = nIndex1;
+ error = OMX_GetParameter (pHandle, OMX_IndexParamPortDefinition, pInPortDef);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ if (pInPortDef->eDir == nIndex1 ) {
+ pInPortDef->nPortIndex = nIndex1;
+ }
+ else {
+ pInPortDef->nPortIndex = nIndex2;
+ }
+
+ /* Set the component's OMX_PARAM_PORTDEFINITIONTYPE structure (input) */
+ pInPortDef->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
+ pInPortDef->nVersion.s.nVersionMajor = 0x1;
+ pInPortDef->nVersion.s.nVersionMinor = 0x0;
+ pInPortDef->nVersion.s.nRevision = 0x0;
+ pInPortDef->nVersion.s.nStep = 0x0;
+ pInPortDef->nPortIndex = 0x0;
+ pInPortDef->eDir = OMX_DirInput;
+ pInPortDef->nBufferCountActual = NUM_OF_BUFFERSJPEG;
+ pInPortDef->nBufferCountMin = 1;
+ pInPortDef->bEnabled = OMX_TRUE;
+ pInPortDef->bPopulated = OMX_FALSE;
+ pInPortDef->eDomain = OMX_PortDomainImage;
+
+ /* OMX_IMAGE_PORTDEFINITION values for input port */
+ pInPortDef->format.image.cMIMEType = "JPEGENC";
+ pInPortDef->format.image.pNativeRender = NULL;
+ pInPortDef->format.image.nFrameWidth = nWidth;
+ pInPortDef->format.image.nFrameHeight = nHeight;
+ pInPortDef->format.image.nSliceHeight = -1;
+ pInPortDef->format.image.bFlagErrorConcealment = OMX_FALSE;
+
+ if ( inputformat == 2) {
+ pInPortDef->format.image.eColorFormat = OMX_COLOR_FormatCbYCrY;
+ }
+ else if ( inputformat == 3) {
+ pInPortDef->format.image.eColorFormat = OMX_COLOR_Format32bitARGB8888;
+ }
+ else if (inputformat == 4) {
+ pInPortDef->format.image.eColorFormat = OMX_COLOR_Format16bitRGB565;
+ }
+ else if ( inputformat == 5) {
+ pInPortDef->format.image.eColorFormat = OMX_COLOR_FormatYCbYCr;
+ }
+ else {
+ pInPortDef->format.image.eColorFormat = OMX_COLOR_FormatYUV420PackedPlanar;
+ }
+
+ pInPortDef->format.image.eCompressionFormat = OMX_IMAGE_CodingUnused;
+
+ nMultFactor = (nWidth + 16 - 1)/16;
+ nWidthNew = (int)(nMultFactor) * 16;
+
+ nMultFactor = (nHeight + 16 - 1)/16;
+ nHeightNew = (int)(nMultFactor) * 16;
+
+ if (inputformat == 1) {
+ pInPortDef->nBufferSize = (nWidthNew * nHeightNew * 1.5);
+ if (pInPortDef->nBufferSize < 1600) {
+ pInPortDef->nBufferSize = 1600;
+ }
+ }
+ else if(inputformat == 3) {
+ pInPortDef->nBufferSize = (nWidthNew * nHeightNew * 4);
+ }
+ else {
+ pInPortDef->nBufferSize = (nWidthNew * nHeightNew * 2);
+ if (pInPortDef->nBufferSize < 400) {
+ pInPortDef->nBufferSize = 400;
+ }
+ }
+
+
+ error = OMX_SetParameter (pHandle, OMX_IndexParamPortDefinition, pInPortDef);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pOutPortDef->nPortIndex = nIndex2;
+ error = OMX_GetParameter(pHandle, OMX_IndexParamPortDefinition, pOutPortDef);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pOutPortDef->eDir == nIndex1 ) {
+ pOutPortDef->nPortIndex = nIndex1;
+ }
+ else {
+ pOutPortDef->nPortIndex = nIndex2;
+ }
+ /* Set the component's OMX_PARAM_PORTDEFINITIONTYPE structure (input) */
+
+ pOutPortDef->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
+ pOutPortDef->nVersion.s.nVersionMajor = 0x1;
+ pOutPortDef->nVersion.s.nVersionMinor = 0x0;
+ pOutPortDef->nVersion.s.nRevision = 0x0;
+ pOutPortDef->nVersion.s.nStep = 0x0;
+ pOutPortDef->nPortIndex = 0x1;
+ pOutPortDef->eDir = OMX_DirInput;
+ pOutPortDef->nBufferCountActual = NUM_OF_BUFFERSJPEG;
+ pOutPortDef->nBufferCountMin = 1;
+ pOutPortDef->bEnabled = OMX_TRUE;
+ pOutPortDef->bPopulated = OMX_FALSE;
+ pOutPortDef->eDomain = OMX_PortDomainImage;
+
+ /* OMX_IMAGE_PORTDEFINITION values for input port */
+ pOutPortDef->format.image.cMIMEType = "JPEGENC";
+ pOutPortDef->format.image.pNativeRender = NULL;
+ pOutPortDef->format.image.nFrameWidth = nWidth;
+ pOutPortDef->format.image.nFrameHeight = nHeight;
+ pOutPortDef->format.image.nStride = -1;
+ pOutPortDef->format.image.nSliceHeight = -1;
+ pOutPortDef->format.image.bFlagErrorConcealment = OMX_FALSE;
+
+ /*Minimum buffer size requirement */
+ pOutPortDef->nBufferSize = (nWidth*nHeight);
+ if( qualityfactor < 10){
+ pOutPortDef->nBufferSize /=10;
+ }
+ else if (qualityfactor <100){
+ pOutPortDef->nBufferSize /= (100/qualityfactor);
+ }
+
+ /*Adding memory to include Thumbnail, comments & markers information and header (depends on the app)*/
+ pOutPortDef->nBufferSize += 12288;
+
+
+ if ( inputformat == 2 || inputformat == 3 || inputformat == 4 ) {
+ pOutPortDef->format.image.eColorFormat = OMX_COLOR_FormatCbYCrY;
+ }
+ else {
+ pOutPortDef->format.image.eColorFormat = OMX_COLOR_FormatYUV420PackedPlanar;
+ }
+
+ if (imageinfo->bAPP1) {
+ pOutPortDef->format.image.eCompressionFormat = OMX_IMAGE_CodingEXIF;
+ }
+ else {
+ pOutPortDef->format.image.eCompressionFormat = OMX_IMAGE_CodingJPEG;
+ }
+
+ error = OMX_SetParameter (pHandle, OMX_IndexParamPortDefinition, pOutPortDef);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pComponent = (OMX_COMPONENTTYPE *)pHandle;
+
+ error = OMX_SetConfig(pHandle, OMX_IndexConfigCommonInputCrop, &sCrop);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ if (bSetCustomQuatizationTable){
+
+ pQuantizationTable->eQuantizationTable = OMX_IMAGE_QuantizationTableLuma;
+ error = OMX_GetParameter(pHandle, OMX_IndexParamQuantizationTable, pQuantizationTable);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pTemp = (OMX_U8*)memcpy(pQuantizationTable->nQuantizationMatrix, CustomLumaQuantizationTable, sizeof(CustomLumaQuantizationTable));
+ if(pTemp == NULL){
+ printf("%d::APP_Error at function call\n", __LINE__);
+ error = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ error = OMX_SetParameter(pHandle, OMX_IndexParamQuantizationTable, pQuantizationTable);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pQuantizationTable->eQuantizationTable = OMX_IMAGE_QuantizationTableChroma;
+ error = OMX_GetParameter(pHandle, OMX_IndexParamQuantizationTable, pQuantizationTable);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pTemp = (OMX_U8*)memcpy(pQuantizationTable->nQuantizationMatrix, CustomChromaQuantizationTable, sizeof(CustomChromaQuantizationTable));
+ if(pTemp == NULL){
+ error = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ error = OMX_SetParameter(pHandle, OMX_IndexParamQuantizationTable, pQuantizationTable);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+
+ if (bSetCustomHuffmanTable){
+
+ error = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.encoder.Config.HuffmanTable", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ error = OMX_GetParameter(pHandle, nCustomIndex, pHuffmanTable);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pTemp = (OMX_U8*)memcpy(&(pHuffmanTable->sHuffmanTable), &CustomHuffmanTable, sizeof(CustomHuffmanTable));
+ if(pTemp == NULL){
+ error = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ error = OMX_SetParameter(pHandle, nCustomIndex, pHuffmanTable);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ error = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+
+
+ pComponent = (OMX_COMPONENTTYPE *)pHandle;
+ error = OMX_SendCommand(pHandle, OMX_CommandStateSet, OMX_StateIdle ,NULL);
+ if ( error != OMX_ErrorNone ) {
+ fprintf (stderr,"Error from SendCommand-Idle(Init) State function\n");
+ goto EXIT;
+ }
+
+ if (buffertype == 1) {
+
+ for (nCounter = 0; nCounter < NUM_OF_BUFFERSJPEG; nCounter++) {
+ pTemp=(OMX_U8*)malloc(pInPortDef->nBufferSize+256);
+ if(pTemp == NULL){
+ error = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pTemp+= 128;
+ pInBuffer[nCounter] = pTemp;
+ pTemp = NULL;
+
+ pTemp= (OMX_U8*)malloc(pOutPortDef->nBufferSize+256);
+ if(pTemp == NULL){
+ error = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pTemp+= 128;
+ pOutBuffer[nCounter] = pTemp;
+ }
+
+ for (nCounter = 0; nCounter < NUM_OF_BUFFERSJPEG; nCounter++) {
+ error = OMX_UseBuffer(pHandle, &pInBuff[nCounter], nIndex1, (void*)&sJPEGEnc_CompID, pInPortDef->nBufferSize,pInBuffer[nCounter]);
+ }
+ for (nCounter = 0; nCounter < NUM_OF_BUFFERSJPEG; nCounter++) {
+ error = OMX_UseBuffer(pHandle, &pOutBuff[nCounter], nIndex2, (void*)&sJPEGEnc_CompID, pOutPortDef->nBufferSize,pOutBuffer[nCounter]);
+ }
+ }
+
+ if (buffertype == 2) {
+ for (nCounter = 0; nCounter < NUM_OF_BUFFERSJPEG; nCounter++) {
+ error = OMX_AllocateBuffer(pHandle, &pInBuff[nCounter], nIndex1, (void *)&sJPEGEnc_CompID, pInPortDef->nBufferSize);
+ }
+ for (nCounter = 0; nCounter < NUM_OF_BUFFERSJPEG; nCounter++) {
+ error = OMX_AllocateBuffer(pHandle, &pOutBuff[nCounter], nIndex2, (void *)&sJPEGEnc_CompID, pOutPortDef->nBufferSize);
+ }
+ }
+
+ /* set markers */
+ error = SetMarkers(pHandle, imageinfo, sCrop, nWidth, nHeight);
+ if ( error != OMX_ErrorNone ) {
+ fprintf (stderr,"Error from SetMarkers() function\n");
+ goto EXIT;
+ }
+
+ /**
+ * wait for initialization to complete (as indicated by the statechange
+ * callback saying that component has been loaded (and is therefore
+ * initialized. Note that you should probably handle GUI events
+ * in the WaitForState method.
+ **/
+
+ PRINT("Waiting for state Idle\n");
+ error = WaitForState(pHandle, OMX_StateIdle);
+ if ( error != OMX_ErrorNone ) {
+ PRINT("Error: JpegEncoder->WaitForState has timed out or failed %X\n",
+ error);
+ goto EXIT;
+ }
+
+ pQfactorType->nSize = sizeof(OMX_IMAGE_PARAM_QFACTORTYPE);
+ pQfactorType->nQFactor = (OMX_U32) qualityfactor;
+ pQfactorType->nVersion.s.nVersionMajor = 0x1;
+ pQfactorType->nVersion.s.nVersionMinor = 0x0;
+ pQfactorType->nVersion.s.nRevision = 0x0;
+ pQfactorType->nVersion.s.nStep = 0x0;
+ pQfactorType->nPortIndex = 0x0;
+
+ error = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.encoder.Config.QFactor", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ goto EXIT;
+ }
+ error = OMX_SetConfig (pHandle, nCustomIndex, pQfactorType);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ goto EXIT;
+ }
+
+
+ /**
+ * Open the file of data to be rendered. Since this is a just sample
+ * application, the data is "rendered" to a test mixer. So, the test
+ * file better contain data that can be printed to the terminal w/o
+ * problems or you will not be a happy camper.
+ **/
+ PRINT("Opening output jpg file\n");
+#ifdef UNDER_CE
+ fOut = CreateFile(szOutFile, GENERIC_WRITE, 0,
+ NULL,CREATE_ALWAYS, 0, NULL);
+ if (INVALID_HANDLE_VALUE == fOut){
+ PRINT("Error: failed to open the file <%s> for writing\n",
+ szOutFile);
+ goto EXIT;
+ }
+#else
+ fOut = fopen(szOutFile, "w");
+ if ( fOut == NULL ) {
+ PRINT("Error: failed to open the file <%s> for writing\n",
+ szOutFile);
+ goto EXIT;
+ }
+#endif
+
+ error = OMX_SendCommand(pHandle,OMX_CommandStateSet, OMX_StateExecuting, NULL);
+ if ( error != OMX_ErrorNone ) {
+ fprintf (stderr,"Error from SendCommand-Executing State function\n");
+ goto EXIT;
+ }
+ pComponent = (OMX_COMPONENTTYPE *)pHandle;
+
+ /**
+ * wait for startup to complete (as indicated by the statechange
+ * callback saying that component has been loaded (and is therefore
+ * initialized. Note that you should probably handle GUI events
+ * in the WaitForState method.
+ **/
+
+ PRINT("Waiting for OMX_StateExcecuting\n");
+ error = WaitForState(pHandle, OMX_StateExecuting);
+ if ( error != OMX_ErrorNone ) {
+ PRINT("Error: JpegEncoder->WaitForState has timed out or failed %X\n", error);
+ goto EXIT;
+ }
+
+#if 0
+ if (imageinfo->nDRI) {
+ error = OMX_GetExtensionIndex(pHandle, "OMX.TI.JPEG.encoder.Config.DRI", (OMX_INDEXTYPE*)&nCustomIndex);
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ goto EXIT;
+ }
+ error = OMX_SetConfig(pHandle, nCustomIndex, &(imageinfo->nDRI));
+ if ( error != OMX_ErrorNone ) {
+ printf("%d::APP_Error at function call: %x\n", __LINE__, error);
+ goto EXIT;
+ }
+ }
+#endif
+
+ /** Handle the component's requests for data until we run out of data. Do this
+ * in a way that will allow the UI to continue to run (if there is a UI, which
+ * this sample application does NOT have)
+ **/
+
+ done = 0;
+ pComponent->GetState(pHandle, &state);
+ PRINT("Error is %d , cur state is %d ",error, state);
+
+
+ for (nCounter =0; nCounter<1 /*NUM_OF_BUFFERSJPEG*/; nCounter++) {
+ nRead = fill_data(pInBuff[nCounter], fIn,pInPortDef->nBufferSize);
+ pComponent->FillThisBuffer(pHandle, pOutBuff[nCounter]);
+ pComponent->EmptyThisBuffer(pHandle, pInBuff[nCounter]);
+ framesent++;
+ PRINT("Sent Frame # %d\n", framesent);
+ if (pInBuff[nCounter]->nFlags == OMX_BUFFERFLAG_ENDOFFRAME)
+ break;
+ }
+
+ while ((error == OMX_ErrorNone) &&
+ (state != OMX_StateIdle)) {
+
+ if (bPreempted)
+ {
+ PRINT("Preempted - Forced tp Idle State - Waiting for OMX_StateIdle\n");
+ error = WaitForState(pHandle, OMX_StateIdle);
+ if ( error != OMX_ErrorNone ) {
+ PRINT("Error: JpegEncoder->WaitForState has timed out or failed %X", error);
+ goto EXIT;
+ }
+ break;
+ }
+
+ fd_set rfds;
+ sigemptyset(&set);
+ sigaddset(&set,SIGALRM);
+
+ FD_ZERO(&rfds);
+ FD_SET(IpBuf_Pipe[0], &rfds);
+ FD_SET(OpBuf_Pipe[0], &rfds);
+ FD_SET(Event_Pipe[0], &rfds);
+ retval = pselect(fdmax+1, &rfds, NULL, NULL, NULL,&set);
+ if ( retval == -1 ) {
+#ifndef UNDER_CE
+ perror("select()");
+#endif
+ fprintf (stderr, " : Error \n");
+ break;
+ }
+ else if ( retval == 0 ) {
+ PRINT("App Timeout !!!!!!!!!!!\n");
+ }
+
+ /**
+ * If FD_ISSET for Event_Pipe, there is an event remaining on the pipe. Read it
+ * and get act accordingly to the event.
+ **/
+ if ( FD_ISSET(Event_Pipe[0], &rfds)) {
+
+ JPEGE_EVENTPRIVATE EventPrivate;
+ read(Event_Pipe[0], &EventPrivate, sizeof(JPEGE_EVENTPRIVATE));
+
+ switch(EventPrivate.eEvent) {
+ case OMX_EventError:
+ if(bError) {
+ error = WaitForState(pHandle, OMX_StateInvalid);
+ if (error != OMX_ErrorNone) {
+ printf("APP:: Error: JpegEncoder->WaitForState has timed out or failed %X\n", error);
+ goto EXIT;
+ }
+ printf("APP:: Component is in Invalid state now.\n");
+ goto EXIT;
+ }
+ break;
+
+ case OMX_EventBufferFlag:
+ printf("APP:: EOS flag received\n");
+ break;
+
+ default:
+ printf("APP:: Non-error event rised. Event -> 0x%x\n", EventPrivate.eEvent);
+ break;
+ }
+ }
+
+ /**
+ * If FD_ISSET for IpBuf_Pipe, then there is an empty buffer available on the pipe. Read it
+ * from the pipe, then re-fill the buffer and send it back.
+ **/
+ if ( FD_ISSET(IpBuf_Pipe[0], &rfds) && !DEINIT_FLAG ) {
+
+ /*read buffer */
+ read(IpBuf_Pipe[0], &pBuffer, sizeof(pBuffer));
+
+ /* re-fill this buffer with data from JPEG file */
+ nRead = fill_data(pBuffer, fIn,pInPortDef->nBufferSize);
+
+ /* call EmptyThisBuffer (send buffer back to component */
+ OMX_EmptyThisBuffer(pHandle, pBuffer);
+
+ /*increment count */
+ framesent++;
+ PRINT("Sent Frame # %d\n", framesent);
+ }
+
+ /**
+ * If FD_ISSET for OpBuf_Pipe, then there is a filled buffer available on the pipe. Read it
+ * and get the buffer data out, write it to a file and then re-empty the buffer and send
+ * the buffer back to the component.
+ **/
+ if (FD_ISSET(OpBuf_Pipe[0], &rfds)) {
+
+ /* read buffer */
+ read(OpBuf_Pipe[0], &pBuf, sizeof(pBuf));
+
+ /* write data to a file, buffer is assumed to be emptied after this*/
+#ifdef UNDER_CE
+ WriteFile(fOut, pBuf->pBuffer, pBuf->nFilledLen, &dwWritten, NULL);
+#else
+ printf("APP:: Write into file %lu bytes (%d)\n",pBuf->nFilledLen, nframerecieved);
+ fwrite(pBuf->pBuffer, 1, (int)pBuf->nFilledLen, fOut);
+ fflush(fOut);
+#endif
+ /*increment count and validate for limits; call FillThisBuffer */
+ nframerecieved++;
+ nRepeated++;
+ PRINT("\n%d***************%d***************%d***************%d***************%d\n", nRepeated, nRepeated, nRepeated, nRepeated, nRepeated);
+ if (nRepeated >= maxRepeat) {
+ DEINIT_FLAG = 1;
+ }
+ else {
+ PRINT("Sending another output buffer\n");
+ pComponent->FillThisBuffer(pHandle,pBuf);
+ }
+ }
+
+ if (DEINIT_FLAG == 1) {
+ done = 1;
+ pHandle = (OMX_HANDLETYPE *) pComponent;
+ error = OMX_SendCommand(pHandle,OMX_CommandStateSet, OMX_StateIdle, NULL);
+ if ( error != OMX_ErrorNone ) {
+ fprintf (stderr,"APP:: Error from SendCommand-Idle(Stop) State function\n");
+ goto EXIT;
+ }
+
+ PRINT("Waiting for OMX_StateIdle\n");
+ error = WaitForState(pHandle, OMX_StateIdle);
+ if ( error != OMX_ErrorNone ) {
+ PRINT("Error: JpegEncoder->WaitForState has timed out %X", error);
+ goto EXIT;
+ }
+
+ error = OMX_SendCommand(pHandle, OMX_CommandPortDisable, 0, NULL);
+ if ( error != OMX_ErrorNone ) {
+ PRINT("Error from SendCommand-PortDisable function\n");
+ goto EXIT;
+ }
+ }
+
+ if (done == 1) {
+ error = pComponent->GetState(pHandle, &state);
+ if ( error != OMX_ErrorNone ){
+ fprintf(stderr, "Warning: JpegEncoder->JPEGENC_GetState has returned status %X\n", error);
+ goto EXIT;
+ }
+ PRINT("After GetState() in while loop.\n");
+ }
+ }
+
+
+
+
+#ifdef STRESS
+ }
+#endif
+
+ printf("\nTest Completed Successfully! Deinitializing ... \n\n");
+
+EXIT:
+
+ printf("\nClosing application...\n");
+
+ /**
+ * Freeing memory
+ **/
+
+/*close handles */
+#ifdef UNDER_CE
+ CloseHandle(fOut);
+ CloseHandle(fIn);
+#else
+ fclose(fOut);
+ rewind (fIn);
+ fclose(fIn);
+#endif
+
+ PRINT("Freeing memory from test app\n");
+ FREE(pPortParamType);
+ FREE(pQfactorType);
+ FREE(pInPortDef);
+ FREE(pOutPortDef);
+ FREE(imageinfo);
+ FREE(pQuantizationTable);
+ FREE(pHuffmanTable);
+
+ if( error != OMX_ErrorNone){
+ if (buffertype == 1) {
+ for (nCounter = 0; nCounter < NUM_OF_BUFFERSJPEG; nCounter++) {
+ pOutBuffer[nCounter]-=128;
+ pInBuffer[nCounter]-=128;
+ FREE(pOutBuffer[nCounter]);
+ FREE(pInBuffer[nCounter]);
+ }
+ }
+ for (nCounter = 0; nCounter < NUM_OF_BUFFERSJPEG; nCounter++) {
+ error = OMX_FreeBuffer(pHandle, nIndex1, pInBuff[nCounter]);
+ if ( (error != OMX_ErrorNone) ) {
+ printf ("Error in OMX_FreeBuffer: %d\n", __LINE__);
+ }
+ error = OMX_FreeBuffer(pHandle, nIndex2, pOutBuff[nCounter]);
+ if ( (error != OMX_ErrorNone) ) {
+ printf ("Error in OMX_FreeBuffer: %d\n", __LINE__);
+ }
+ }
+ }
+
+ error = TIOMX_FreeHandle(pHandle);
+ if ( (error != OMX_ErrorNone) ) {
+ printf ("Error in Free Handle function\n");
+ }
+
+#ifdef DSP_MMU_FAULT_HANDLING
+
+ if(bError) {
+ LoadBaseImage();
+ }
+
+#endif
+
+ error = TIOMX_Deinit();
+ if ( error != OMX_ErrorNone ) {
+ printf("Error returned by OMX_Init()\n");
+ }
+
+#ifdef STRESS
+
+} /* end of multiload loop */
+
+#endif
+
+#ifndef UNDER_CE
+//muntrace();
+#endif
+ PRINT ("Free Handle returned Successfully = %x\n",error);
+ return error;
+}
+
+#ifdef DSP_MMU_FAULT_HANDLING
+
+int LoadBaseImage() {
+ unsigned int uProcId = 0; /* default proc ID is 0. */
+ unsigned int index = 0;
+
+ struct DSP_PROCESSORINFO dspInfo;
+ DSP_HPROCESSOR hProc;
+ DSP_STATUS status = DSP_SOK;
+ unsigned int numProcs;
+ char* argv[2];
+
+ argv[0] = "/lib/dsp/baseimage.dof";
+
+ status = (DBAPI)DspManager_Open(0, NULL);
+ if (DSP_FAILED(status)) {
+ printf("DSPManager_Open failed \n");
+ return -1;
+ }
+ while (DSP_SUCCEEDED(DSPManager_EnumProcessorInfo(index,&dspInfo,
+ (unsigned int)sizeof(struct DSP_PROCESSORINFO),&numProcs))) {
+ if ((dspInfo.uProcessorType == DSPTYPE_55) ||
+ (dspInfo.uProcessorType == DSPTYPE_64)) {
+ uProcId = index;
+ status = DSP_SOK;
+ break;
+ }
+ index++;
+ }
+ status = DSPProcessor_Attach(uProcId, NULL, &hProc);
+ if (DSP_SUCCEEDED(status)) {
+ status = DSPProcessor_Stop(hProc);
+ if (DSP_SUCCEEDED(status)) {
+ status = DSPProcessor_Load(hProc,1,(const char **)argv,NULL);
+ if (DSP_SUCCEEDED(status)) {
+ status = DSPProcessor_Start(hProc);
+ if (DSP_SUCCEEDED(status)) {
+ }
+ else {
+ }
+ }
+ else {
+ }
+ DSPProcessor_Detach(hProc);
+ }
+ else {
+ }
+ }
+ else {
+ }
+ fprintf(stderr,"Baseimage Loaded\n");
+
+ return 0;
+}
+#endif
diff --git a/omx/image/src/openmax_il/jpeg_enc/test/JPEGTestEnc.h b/omx/image/src/openmax_il/jpeg_enc/test/JPEGTestEnc.h
new file mode 100755
index 0000000..255f2fe
--- /dev/null
+++ b/omx/image/src/openmax_il/jpeg_enc/test/JPEGTestEnc.h
@@ -0,0 +1,114 @@
+
+/*
+ * Copyright 2001-2008 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.
+ */
+/* ================================================================================
+* Texas Instruments OMAP(TM) Platform Software
+* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
+*
+* Use of this software is controlled by the terms and conditions found
+* in the license agreement under which this software has been supplied.
+* ================================================================================= */
+/**
+* @file JPEGTest.h
+*
+* This file implements OMX Component for JPEG encoder that
+* is fully compliant with the OMX specification 1.5.
+*
+* @path $(CSLPATH)\src
+*
+* @rev 0.1
+*/
+/* -------------------------------------------------------------------------------- */
+/* ================================================================================
+*!
+*! Revision History
+*! ===================================
+*!
+*! 22-May-2006 mf: Revisions appear in reverse chronological order;
+*! that is, newest first. The date format is dd-Mon-yyyy.
+* ================================================================================= */
+#ifndef OMX_JPEGTEST_H
+#define OMX_JPEGTEST_H
+
+
+typedef struct IMAGE_INFO {
+ int nWidth;
+ int nHeight ;
+ int nFormat;
+ int nComment;
+ char* pCommentString;
+ int nThumbnailWidth_app0;
+ int nThumbnailHeight_app0;
+ int nThumbnailWidth_app1;
+ int nThumbnailHeight_app1;
+ int nThumbnailWidth_app5;
+ int nThumbnailHeight_app5;
+ int nThumbnailWidth_app13;
+ int nThumbnailHeight_app13;
+ int nDRI;
+ OMX_BOOL bAPP0;
+ OMX_BOOL bAPP1;
+ OMX_BOOL bAPP5;
+ OMX_BOOL bAPP13;
+} IMAGE_INFO;
+
+typedef struct JPEGE_EVENTPRIVATE {
+ OMX_EVENTTYPE eEvent;
+ OMX_PTR pAppData;
+ OMX_PTR pEventInfo;
+ OMX_U32 nData1;
+ OMX_U32 nData2;
+}JPEGE_EVENTPRIVATE;
+
+#define MALLOC(_pStruct_, _sName_) \
+ _pStruct_ = (_sName_*)malloc(sizeof(_sName_)); \
+ if(_pStruct_ == NULL){ \
+ error = OMX_ErrorInsufficientResources; \
+ goto EXIT; \
+ }\
+ memset((void *)_pStruct_, 0, sizeof(_sName_))
+
+#define FREE(_ptr) \
+{ \
+ if (_ptr != NULL) { \
+ free(_ptr); \
+ _ptr = NULL; \
+ } \
+}
+
+#define OMX_CONF_CHECK_CMD(_ptr1, _ptr2, _ptr3) \
+{ \
+ if(!_ptr1 || !_ptr2 || !_ptr3){ \
+ eError = OMX_ErrorBadParameter; \
+ goto OMX_CONF_CMD_BAIL; \
+ } \
+}
+#ifdef UNDER_CE
+#define sleep Sleep
+#endif
+
+
+/*#define OMX_DEB*/
+#ifdef OMX_DEB
+ #define PRINT(...) fprintf(stdout,__VA_ARGS__)
+#else
+ #define PRINT(...)
+#endif
+
+#define DSP_MMU_FAULT_HANDLING
+
+#endif /* OMX_JPEGTEST_H */
+