1 
2 /*
3  * Copyright (C) Texas Instruments - http://www.ti.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 /* =============================================================================
22 *             Texas Instruments OMAP(TM) Platform Software
23 *  (c) Copyright Texas Instruments, Incorporated.  All Rights Reserved.
24 *
25 *  Use of this software is controlled by the terms and conditions found
26 *  in the license agreement under which this software has been supplied.
27 * ============================================================================ */
28 /**
29 * @file OMX_JpegDec_Utils.h
30 *
31 ** This is a header file for a JPEG decoder.
32 
33 * ================================================================================
34 */
35 
36 #ifndef OMX_JPEGDEC_UTILS__H
37 #define OMX_JPEGDEC_UTILS__H
38 
39 #include <OMX_Component.h>
40 #include <OMX_IVCommon.h>
41 #include "LCML_DspCodec.h"
42 #include "LCML_Types.h"
43 #include "LCML_CodecInterface.h"
44 #include <pthread.h>
45 #include <OMX_Core.h>
46 #include <OMX_Types.h>
47 #include <OMX_Image.h>
48 #include <sys/time.h>
49 #include <stdio.h>
50 #include <errno.h>
51 #include <OMX_TI_Common.h>
52 #include <OMX_TI_Debug.h>
53 
54 #include <utils/Log.h>
55 #define LOG_TAG "OMX_JPGDEC"
56 
57 #ifdef RESOURCE_MANAGER_ENABLED
58 #include <ResourceManagerProxyAPI.h>
59 #endif
60 
61 #ifdef __PERF_INSTRUMENTATION__
62     #include "perf.h"
63 #endif
64 
65 
66 #ifdef UNDER_CE
67     #include <oaf_debug.h>
68 #endif
69 
70 
71 #define JPEGDEC1MPImage 1000000
72 #define JPEGDEC2MPImage 2000000
73 #define JPEGDEC3MPImage 3000000
74 #define JPEGDEC4MPImage 4000000
75 
76 #define COMP_MAX_NAMESIZE 127
77 
78 /*Linked List */
79 
80 typedef struct Node {
81     struct Node *pNextNode;
82     void *pValue;
83 } Node;
84 
85 typedef struct LinkedList {
86     Node *pRoot;
87 }   LinkedList;
88 
89 LinkedList AllocList;
90 
91 void LinkedList_Create(LinkedList *LinkedList);
92 void LinkedList_AddElement(LinkedList *LinkedList, void *pValue);
93 void LinkedList_FreeElement(LinkedList *LinkedList, void *pValue);
94 void LinkedList_FreeAll(LinkedList *LinkedList);
95 void LinkedList_DisplayAll(LinkedList *LinkedList);
96 void LinkedList_Destroy(LinkedList *LinkedList);
97 
98 /*
99  *     M A C R O S
100  */
101 #define KHRONOS_1_1
102 
103 #define OMX_CONF_INIT_STRUCT(_s_, _name_)   \
104     memset((_s_), 0x0, sizeof(_name_)); \
105     (_s_)->nSize = sizeof(_name_);      \
106     (_s_)->nVersion.s.nVersionMajor = 0x1;  \
107     (_s_)->nVersion.s.nVersionMinor = 0x0;  \
108     (_s_)->nVersion.s.nRevision = 0x0;      \
109     (_s_)->nVersion.s.nStep = 0x0
110 
111 
112 #define OMX_MEMCPY_CHECK(_s_)\
113 {\
114     if (_s_ == NULL) { \
115     eError = OMX_ErrorInsufficientResources;  \
116     goto EXIT;   \
117     } \
118 }
119 #define OMX_CHECK_PARAM(_ptr_)  \
120 {   \
121     if(!_ptr_) {    \
122     eError = OMX_ErrorBadParameter; \
123     goto EXIT; \
124     }   \
125 }
126 
127 #define JPEGDEC_OMX_CONF_CHECK_CMD(_ptr1, _ptr2, _ptr3)\
128 do {					       \
129     if(!_ptr1 || !_ptr2 || !_ptr3){	       \
130         eError = OMX_ErrorBadParameter;        \
131         goto EXIT;                             \
132     }					       \
133 } while(0)
134 
135 #define OMX_MALLOC(_pStruct_, _size_)   \
136     _pStruct_ = malloc(_size_);  \
137     if(_pStruct_ == NULL){  \
138         eError = OMX_ErrorInsufficientResources;    \
139         goto EXIT;  \
140     } \
141     memset(_pStruct_, 0, _size_);\
142     LinkedList_AddElement(&AllocList, _pStruct_);
143 
144 #define OMX_FREE(_ptr)   \
145 {                     \
146     if (_ptr != NULL) { \
147         LinkedList_FreeElement(&AllocList, _ptr);\
148         _ptr = NULL; \
149     }                \
150 }
151 
152 #define OMX_FREEALL()   \
153 {                     \
154         LinkedList_FreeAll(&AllocList);\
155 }
156 
157 #define JPEGDEC_WAIT_PORT_POPULATION(_pComponentPrivate_)    \
158 {                                                                           \
159     int nRet = 0x0;                                                         \
160     struct timespec  ts;                                                    \
161     struct timeval sTime;                                                   \
162     struct timezone sTimeZone;                                              \
163                                                                             \
164     pthread_mutex_lock(&((_pComponentPrivate_)->mJpegDecMutex));     \
165     gettimeofday(&sTime, &sTimeZone);                                       \
166     ts.tv_sec = sTime.tv_sec;                                               \
167     ts.tv_sec += JPEGDEC_TIMEOUT;                                      \
168                                                                    \
169     nRet = pthread_cond_timedwait(&((_pComponentPrivate_)->sPortPopulated_cond),\
170                                   &((_pComponentPrivate_)->mJpegDecMutex), \
171                                   &ts);                                 \
172     if (nRet == ETIMEDOUT)                                              \
173     {                                                                   \
174         OMX_PRBUFFER4((_pComponentPrivate_)->dbg, "Wait for port to be Populated time-out"); \
175         pthread_mutex_unlock(&((_pComponentPrivate_)->mJpegDecMutex));\
176         \
177         eError = OMX_ErrorPortUnresponsiveDuringAllocation;\
178         \
179         break;                                  \
180     }                                                                   \
181    pthread_mutex_unlock(&((_pComponentPrivate_)->mJpegDecMutex));     \
182 }
183 
184 #define JPEGDEC_WAIT_PORT_UNPOPULATION(_pComponentPrivate_)    \
185 {                                                                           \
186     int nRet = 0x0;                                                         \
187     struct timespec  ts;                                                    \
188     struct timeval sTime;                                                   \
189     struct timezone sTimeZone;                                              \
190                                                                             \
191     pthread_mutex_lock(&((_pComponentPrivate_)->mJpegDecMutex));     \
192     gettimeofday(&sTime, &sTimeZone);                                       \
193     ts.tv_sec = sTime.tv_sec;                                               \
194     ts.tv_sec += JPEGDEC_TIMEOUT;                                      \
195                                                                    \
196     nRet = pthread_cond_timedwait(&((_pComponentPrivate_)->sPortPopulated_cond),\
197                                   &((_pComponentPrivate_)->mJpegDecMutex), \
198                                   &ts);                                 \
199     if (nRet == ETIMEDOUT)                                              \
200     {                                                                   \
201         OMX_PRBUFFER4((_pComponentPrivate_)->dbg, "Wait for port to be Unpopulated time-out"); \
202         pthread_mutex_unlock(&((_pComponentPrivate_)->mJpegDecMutex));\
203         \
204         eError = OMX_ErrorPortUnresponsiveDuringDeallocation;\
205         \
206         break;                                  \
207     }                                                                   \
208    pthread_mutex_unlock(&((_pComponentPrivate_)->mJpegDecMutex));     \
209 }
210 
211 #define JPEGDEC_WAIT_FLUSH(_pComponentPrivate_)     \
212 {                                                                                           \
213     int nRet = 0x0;                                                         \
214     struct timespec  ts;                                                    \
215     struct timeval sTime;                                                   \
216     struct timezone sTimeZone;                                              \
217                                                                             \
218     pthread_mutex_lock(&((_pComponentPrivate_)->mJpegDecFlushMutex));     \
219     gettimeofday(&sTime, &sTimeZone);                                       \
220     ts.tv_sec = sTime.tv_sec;                                               \
221     ts.tv_sec += JPEGDEC_TIMEOUT;                                      \
222                                                                    \
223     nRet = pthread_cond_timedwait(&((_pComponentPrivate_)->sFlush_cond),\
224                                   &((_pComponentPrivate_)->mJpegDecFlushMutex), \
225                                   &ts);                                 \
226     if (nRet == ETIMEDOUT)                                              \
227     {                                                                   \
228 	OMX_PRBUFFER4((_pComponentPrivate_)->dbg, "Wait for port to be Unpopulated time-out"); \
229         pthread_mutex_unlock(&((_pComponentPrivate_)->mJpegDecFlushMutex));\
230         _pComponentPrivate_->cbInfo.EventHandler(_pComponentPrivate_->pHandle,\
231                                                _pComponentPrivate_->pHandle->pApplicationPrivate,\
232                                                OMX_EventError,\
233                                                OMX_ErrorTimeout,\
234                                                OMX_TI_ErrorMajor,\
235                                                "TimeOut - whlie doing flush");\
236         break;                                  \
237     }                                                                   \
238    pthread_mutex_unlock(&((_pComponentPrivate_)->mJpegDecFlushMutex));     \
239 }
240 
241 
242 #define OMX_DPRINT_ADDRESS(_s_, _ptr_)  \
243     OMX_PRINT2(pComponentPrivate->dbg, "%s = %p\n", _s_, _ptr_);
244 
245 #ifdef RESOURCE_MANAGER_ENABLED
246 #define OMX_GET_RM_VALUE(_Res_, _RM_) \
247 {   \
248     if (_Res_ <= JPEGDEC1MPImage){  \
249         _RM_ = 25;  \
250         }   \
251     else if (_Res_ <= JPEGDEC2MPImage){ \
252         _RM_ = 40;  \
253         }   \
254     else if (_Res_ <= JPEGDEC3MPImage){ \
255         _RM_ = 55;  \
256         }   \
257     else if (_Res_ <= JPEGDEC4MPImage){ \
258         _RM_ = 70;  \
259         }   \
260     else {  \
261         _RM_ = 90;  \
262         }   \
263         \
264     OMX_PRMGR2(pComponentPrivate->dbg, "Value in MHz requested to RM = %d\n",_RM_); \
265 }
266 #endif
267 
268 #define NUM_OF_BUFFERS 4
269 #define NUM_OF_PORTS 2
270 
271 
272 #define OMX_JPEGDEC_NUM_DLLS (3)
273 #ifdef UNDER_CE
274     #define JPEG_DEC_NODE_DLL "/windows/jpegdec_sn.dll64P"
275     #define JPEG_COMMON_DLL "/windows/usn.dll64P"
276     #define USN_DLL "/windows/usn.dll64P"
277 #else
278 #define JPEG_DEC_NODE_DLL "jpegdec_sn.dll64P"
279 #define JPEG_COMMON_DLL "usn.dll64P"
280 #define USN_DLL "usn.dll64P"
281 #endif
282 
283 #define JPGDEC_SNTEST_STRMCNT       2
284 #define JPGDEC_SNTEST_INSTRMID      0
285 #define JPGDEC_SNTEST_OUTSTRMID     1
286 #define JPGDEC_SNTEST_MAX_HEIGHT    3000
287 #define JPGDEC_SNTEST_MAX_WIDTH     4000
288 #define JPGDEC_SNTEST_PROG_FLAG     1
289 #define JPGDEC_SNTEST_INBUFCNT      4
290 #define JPGDEC_SNTEST_OUTBUFCNT     4
291 
292 #define OMX_NOPORT 0xFFFFFFFE
293 
294 #define JPEGD_DSPSTOP       0x01
295 #define JPEGD_BUFFERBACK    0x02
296 #define JPEGD_IDLEREADY     ( JPEGD_DSPSTOP | JPEGD_BUFFERBACK )
297 
298 #define DSP_MMU_FAULT_HANDLING
299 
300 #define OMX_CustomCommandStopThread (OMX_CommandMax - 1)
301 
302 typedef OMX_ERRORTYPE (*jpegdec_fpo)(OMX_HANDLETYPE);
303 
304 static const struct DSP_UUID JPEGDSOCKET_TI_UUID = {
305     0x5D9CB711, 0x4645, 0x11d6, 0xb0, 0xdc, {
306         0x00, 0xc0, 0x4f, 0x1f, 0xc0, 0x36
307     }
308 };
309 
310 static const struct DSP_UUID USN_UUID = {
311     0x79A3C8B3, 0x95F2, 0x403F, 0x9A, 0x4B, {
312         0xCF, 0x80, 0x57, 0x73, 0x05, 0x41
313     }
314 };
315 
316 typedef enum JPEGDEC_COMP_PORT_TYPE
317 {
318     JPEGDEC_INPUT_PORT = 0,
319     JPEGDEC_OUTPUT_PORT
320 }JPEGDEC_COMP_PORT_TYPE;
321 
322 
323 typedef enum JPEGDEC_BUFFER_OWNER
324 {
325     JPEGDEC_BUFFER_CLIENT = 0x0,
326     JPEGDEC_BUFFER_COMPONENT_IN,
327     JPEGDEC_BUFFER_COMPONENT_OUT,
328     JPEGDEC_BUFFER_DSP,
329     JPEGDEC_BUFFER_TUNNEL_COMPONENT
330 } JPEGDEC_BUFFER_OWNER;
331 
332 typedef struct _JPEGDEC_BUFFERFLAG_TRACK {
333     OMX_U32 flag;
334     OMX_U32 buffer_id;
335     OMX_HANDLETYPE hMarkTargetComponent;
336     OMX_PTR pMarkData;
337 } JPEGDEC_BUFFERFLAG_TRACK;
338 
339 typedef struct _JPEGDEC_BUFFERMARK_TRACK {
340     OMX_U32 buffer_id;
341     OMX_HANDLETYPE hMarkTargetComponent;
342     OMX_PTR pMarkData;
343 } JPEGDEC_BUFFERMARK_TRACK;
344 
345 typedef struct JPEGDEC_BUFFER_PRIVATE {
346     OMX_BUFFERHEADERTYPE* pBufferHdr;
347     OMX_PTR pUALGParams;
348     JPEGDEC_BUFFER_OWNER eBufferOwner;
349     OMX_BOOL bAllocbyComponent;
350     OMX_BOOL bReadFromPipe;
351 } JPEGDEC_BUFFER_PRIVATE;
352 
353 typedef struct JPEGDEC_PORT_TYPE
354 {
355     OMX_HANDLETYPE hTunnelComponent;
356     OMX_U32 nTunnelPort;
357     JPEGDEC_BUFFER_PRIVATE* pBufferPrivate[NUM_OF_BUFFERS];
358     JPEGDEC_BUFFERFLAG_TRACK sBufferFlagTrack[NUM_OF_BUFFERS];
359     JPEGDEC_BUFFERMARK_TRACK sBufferMarkTrack[NUM_OF_BUFFERS];
360     OMX_PARAM_PORTDEFINITIONTYPE* pPortDef;
361     OMX_PARAM_BUFFERSUPPLIERTYPE *pParamBufSupplier;
362     OMX_IMAGE_PARAM_PORTFORMATTYPE* pPortFormat;
363     OMX_U8 nBuffCount;
364 } JPEGDEC_PORT_TYPE;
365 
366 typedef struct OMX_CUSTOM_IMAGE_DECODE_SECTION
367 {
368     OMX_U32 nSize;
369     OMX_VERSIONTYPE nVersion;
370     OMX_U32 nMCURow;
371     OMX_U32 nAU;
372     OMX_BOOL bSectionsInput;
373     OMX_BOOL bSectionsOutput;
374 }OMX_CUSTOM_IMAGE_DECODE_SECTION;
375 
376 typedef struct OMX_CUSTOM_IMAGE_DECODE_SUBREGION
377 {
378     OMX_U32 nSize;
379     OMX_VERSIONTYPE nVersion;
380     OMX_U32 nXOrg;         /*Sectional decoding: X origin*/
381     OMX_U32 nYOrg;         /*Sectional decoding: Y origin*/
382     OMX_U32 nXLength;      /*Sectional decoding: X lenght*/
383     OMX_U32 nYLength;      /*Sectional decoding: Y lenght*/
384 }OMX_CUSTOM_IMAGE_DECODE_SUBREGION;
385 
386 
387 typedef struct OMX_CUSTOM_RESOLUTION
388 {
389 	OMX_U32 nWidth;
390 	OMX_U32 nHeight;
391 } OMX_CUSTOM_RESOLUTION;
392 
393 
394 typedef struct JPEGDEC_COMPONENT_PRIVATE
395 {
396     JPEGDEC_PORT_TYPE *pCompPort[NUM_OF_PORTS];
397     OMX_PORT_PARAM_TYPE* pPortParamType;
398     OMX_PRIORITYMGMTTYPE* pPriorityMgmt;
399     OMX_CONFIG_SCALEFACTORTYPE* pScalePrivate;
400     OMX_PORT_PARAM_TYPE* pAudioPortType;
401     OMX_PORT_PARAM_TYPE* pVideoPortType;
402     OMX_PORT_PARAM_TYPE* pOtherPortType;
403     /* Handle for use with async callbacks */
404     OMX_CALLBACKTYPE cbInfo;
405     /*Component name OMX.TI.JPEG.decoder*/
406     OMX_STRING      cComponentName;
407     OMX_VERSIONTYPE ComponentVersion;
408     OMX_VERSIONTYPE SpecVersion;
409 
410     OMX_U8 nSize;
411     OMX_STATETYPE nToState;
412     OMX_U8        ExeToIdleFlag;  /* StateCheck */
413     /* This is component handle */
414     OMX_COMPONENTTYPE* pHandle;
415     /* Current state of this component */
416     OMX_STATETYPE nCurState;
417     /* The component thread handle */
418     pthread_t pComponentThread;
419     /* The pipes to maintain free buffers */
420     int nFree_outBuf_Q[2];
421     /* The pipes to maintain input buffers sent from app*/
422     int nFilled_inpBuf_Q[2];
423     /* The pipes for sending buffers to the thread */
424     int nCmdPipe[2];
425     int nCmdDataPipe[2];
426     void* pLcmlHandle;
427     void * pDllHandle;
428     int nProgressive;
429     int nProfileID;
430     int nIsLCMLActive;
431     OMX_PTR pMarkData;
432     OMX_MARKTYPE *pMarkBuf;
433     OMX_HANDLETYPE hMarkTargetComponent;
434     LCML_DSP_INTERFACE* pLCML;
435     OMX_BOOL bFlushComplete;
436     OMX_U32 nInPortIn;
437     OMX_U32 nOutPortOut;
438     OMX_BOOL bInportDisableComplete;
439     OMX_BOOL bOutportDisableComplete;
440     OMX_U32 nMarkPort;
441 
442     pthread_mutex_t mJpegDecMutex;
443     pthread_cond_t  sStop_cond;
444 
445     /* Condition to signal threads PortTransition */
446     pthread_cond_t sPortPopulated_cond;
447     /*Condition signal Flush & Mutex*/
448     pthread_mutex_t mJpegDecFlushMutex;
449     pthread_cond_t sFlush_cond;
450 
451 #ifdef KHRONOS_1_1
452     OMX_PARAM_COMPONENTROLETYPE* pCompRole;
453     OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE* pQuantTable;
454     OMX_IMAGE_PARAM_HUFFMANTTABLETYPE* pHuffmanTable;
455 #endif
456 
457     int nInputFrameWidth;
458     int nOutputColorFormat;
459 
460 #ifdef RESOURCE_MANAGER_ENABLED
461     RMPROXY_CALLBACKTYPE rmproxyCallback;
462 #endif
463 
464     OMX_BOOL bPreempted;
465 
466 #ifdef __PERF_INSTRUMENTATION__
467     PERF_OBJHANDLE pPERF, pPERFcomp;
468 #endif
469 #ifdef KHRONOS_1_1
470     OMX_PARAM_COMPONENTROLETYPE componentRole;
471 #endif
472     OMX_CUSTOM_IMAGE_DECODE_SECTION* pSectionDecode;
473     OMX_CUSTOM_IMAGE_DECODE_SUBREGION* pSubRegionDecode;
474     OMX_CUSTOM_RESOLUTION sMaxResolution;
475     struct OMX_TI_Debug dbg;
476 } JPEGDEC_COMPONENT_PRIVATE;
477 
478 
479 typedef struct
480 {
481     long int lInBufCount;       /*set it to zero*/
482     OMX_U32 ulInNumFrame;       /*set it to 1*/
483     OMX_U32 ulInFrameAlign;     /*set it to 4*/
484     OMX_U32 ulInFrameSize;      /*same as buffer size*/
485     OMX_U32 ulInDisplayWidth;   /*Width of the buffer into which the image is to be decoded*/
486     OMX_U32 ulInReserved0;      /*could be like thumbnail decode only*/
487     OMX_U32 ulInReserved1;      /*could be output format � later. Let�s fix it to 422 always now*/
488     OMX_U32 ulInReserved2;      /*could be post processing flag*/
489     OMX_U32 ulInReserved3;
490     OMX_U32 ulInResizeOption;   /*Rescale factor */
491     OMX_U32 ulnumAU;            /*Number of MCUs to decode; set as DEFAULT for full image decoding*/
492     OMX_U32 uldecodeHeader;     /*DECODE_AU = Decode at one shot; PARSE_HEADER = Parse header   */
493     OMX_U32 maxHeight;          /*Maximum height of image that can be decoded*/
494     OMX_U32 maxWidth;           /*Maximum width of image that can be decoded*/
495     OMX_U32 maxScans;           /*Maximum number of frames in the input image*/
496     OMX_U32 uldataEndianness;   /*Endianness of input data*/
497     OMX_U32 forceChromaFormat;  /*Set to CHROMAFORMAT ; Set to DEFAULT to avoid resampling.*/
498     OMX_U32 RGB_Format;         /* Set the output RGB format */
499                                                     /* 0: BGR24                                 */
500                                                     /* 1: BGR32                                 */
501                                                     /* 2: RGB16                                 */
502     OMX_U32 ulNumMCURow;    /*Slide decoding: Set the numbers of lines to decode*/
503     OMX_U32 ulXOrg;         /*Sectional decoding: X origin*/
504     OMX_U32 ulYOrg;         /*Sectional decoding: Y origin*/
505     OMX_U32 ulXLength;      /*Sectional decoding: X lenght*/
506     OMX_U32 ulYLength;      /*Sectional decoding: Y lenght*/
507     OMX_U32 ulAlphaRGB;   /* Alpha RGB value, it only takes values from 0 to 255 */
508 }JPEGDEC_UAlgInBufParamStruct;
509 
510 typedef struct
511 {
512     long int lOutBufCount;      /*set it to zero*/
513     OMX_U32 ulOutNumFrame;      /*set it to 1*/
514     OMX_U32 ulOutFrameAlign;    /*set it to 4*/
515     OMX_U32 ulOutFrameSize;     /*same as buffer size*/
516     OMX_U32 ulOutImgFormat;     /*output format*/
517     OMX_U32 ulOutImageWidth;    /*Width of the image*/
518     OMX_U32 ulOutImageHeight;   /*Height of the image*/
519     OMX_U32 ulOutnProgressiveFlag; /*nProgressive flag*/
520     OMX_U32 ulOutErrorCode;     /*error code*/
521     OMX_U32 ulOutReserved0;
522     OMX_U32 ulOutReserved1;
523     OMX_U32 ulOutReserved2;
524     OMX_U32 lastMCU;            /* 1-Decoded all MCU�s0 - Decoding not completed*/
525     OMX_U32 stride[3];          /*Stride values for Y, U, and V components*/
526     OMX_U32 ulOutputHeight;     /* Output Height */
527     OMX_U32 ulOutputWidth;      /* Output Width*/
528     OMX_U32 ultotalAU;          /* Total number of Access unit(MCU)*/
529     OMX_U32 ulbytesConsumed;    /* Total number of bytes consumed*/
530     OMX_U32 ulcurrentAU;        /* current access unit number */
531     OMX_U32 ulcurrentScan;      /*current scan number*/
532 }JPEGDEC_UAlgOutBufParamStruct;
533 
534 typedef enum OMX_INDEXIMAGETYPE
535 {
536     OMX_IndexCustomProgressiveFactor = 0xFF000001,
537     OMX_IndexCustomInputFrameWidth,
538     OMX_IndexCustomOutputColorFormat,
539     OMX_IndexCustomSectionDecode,
540     OMX_IndexCustomSubRegionDecode,
541     OMX_IndexCustomSetMaxResolution,
542     OMX_IndexCustomDebug
543 }OMX_INDEXIMAGETYPE;
544 
545 typedef struct _JPEGDEC_CUSTOM_PARAM_DEFINITION
546 {
547     OMX_U8 cCustomParamName[128];
548     OMX_INDEXTYPE nCustomParamIndex;
549 } JPEGDEC_CUSTOM_PARAM_DEFINITION;
550 
551 /* function declarations */
552 OMX_ERRORTYPE ComponentDeInit(OMX_HANDLETYPE hComponent);
553 OMX_U32 HandleCommandJpegDec(JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1);
554 OMX_U32 HandleCommandFlush(JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1);
555 OMX_ERRORTYPE DisablePortJpegDec(JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1);
556 OMX_ERRORTYPE EnablePortJpegDec(JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1);
557 OMX_ERRORTYPE Start_ComponentThreadJpegDec(OMX_HANDLETYPE pHandle);
558 OMX_ERRORTYPE HandleDataBuf_FromAppJpegDec(JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate );
559 OMX_ERRORTYPE HandleDataBuf_FromDspJpegDec(JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE* pBuffHead);
560 OMX_ERRORTYPE HandleFreeDataBufJpegDec(JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE* pBuffHead );
561 OMX_ERRORTYPE HandleFreeOutputBufferFromAppJpegDec( JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate );
562 OMX_ERRORTYPE JpegDec_AllocResources( JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate );
563 OMX_ERRORTYPE LCML_CallbackJpegDec(TUsnCodecEvent event,void * argsCb [10]);
564 OMX_ERRORTYPE Free_ComponentResourcesJpegDec(JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate);
565 OMX_ERRORTYPE Fill_LCMLInitParamsJpegDec(LCML_DSP *lcml_dsp, OMX_U16 arr[], OMX_HANDLETYPE pComponent);
566 OMX_ERRORTYPE GetLCMLHandleJpegDec(OMX_HANDLETYPE pComponent);
567 OMX_ERRORTYPE HandleInternalFlush(JPEGDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1);
568 OMX_BOOL IsTIOMXComponent(OMX_HANDLETYPE hComp);
569 void* OMX_JpegDec_Thread (void* pThreadData);
570 
571 #ifdef RESOURCE_MANAGER_ENABLED
572 void ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData);
573 #endif
574 
575 
576 #endif
577