1/*
2 * Copyright (C) Texas Instruments - http://www.ti.com/
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Lesser General Public License for more details.
14 *
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 */
20/* =============================================================================
21* Done            Texas Instruments OMAP(TM) Platform Software
22*  (c) Copyright Texas Instruments, Incorporated.  All Rights Reserved.
23*
24*  Use of this software is controlled by the terms and conditions found
25*  in the license agreement under which this software has been supplied.
26* ============================================================================ */
27/**
28* @file OMX_JpegEnc_Utils.h
29*
30* This is a header file for a JPEG encoder that is fully
31* compliant with the OMX Image specification.
32* This the file that the application that uses OMX would include
33* in its code.
34*
35* @path  $(CSLPATH)\inc
36*
37* @rev  0.1
38*/
39/* -------------------------------------------------------------------------------- */
40/* ================================================================================
41*!
42*! Revision History
43*! ===================================
44*!
45*! 22-May-2006 mf: Revisions appear in reverse chronological order;
46*! that is, newest first.  The date format is dd-Mon-yyyy.
47* ================================================================================= */
48
49#ifndef OMX_JPEGENC_UTILS__H
50#define OMX_JPEGENC_UTILS__H
51#include <OMX_Component.h>
52#include <OMX_IVCommon.h>
53
54
55#ifndef UNDER_CE
56#include <dlfcn.h>
57#endif
58#include "LCML_DspCodec.h"
59#include "LCML_Types.h"
60#include "LCML_CodecInterface.h"
61#include <pthread.h>
62#include <stdarg.h>
63#include <OMX_Core.h>
64#include <OMX_Types.h>
65#include <OMX_Image.h>
66#include<OMX_TI_Common.h>
67#include <OMX_TI_Debug.h>
68#ifdef RESOURCE_MANAGER_ENABLED
69#include <ResourceManagerProxyAPI.h>
70#endif
71#include "OMX_JpegEnc_CustomCmd.h"
72
73#include <utils/Log.h>
74#define LOG_TAG "OMX_JPGENC"
75
76#ifdef __PERF_INSTRUMENTATION__
77#include "perf.h"
78#endif
79
80#define OMX_JPEGENC_NonMIME 1
81#define OMX_NOPORT 0xFFFFFFFE
82#define JPEGE_TIMEOUT (100000)
83#define NUM_OF_PORTS  2
84#define NUM_OF_BUFFERSJPEG 4
85
86#define MAX_INPARAM_SIZE 1024
87
88#define COMP_MAX_NAMESIZE 127
89
90#define OMX_CustomCommandStopThread (OMX_CommandMax - 1)
91
92#define PADDING_128_BYTE	128
93#define PADDING_256_BYTE	256
94#define JPEGENC_THUMBNAIL_ABSENT_WARNING 4
95
96#ifdef UNDER_CE
97    #include <oaf_debug.h>
98#endif
99
100#define KHRONOS_1_1
101
102#ifndef FUNC
103#define FUNC 1
104#endif
105
106#ifdef RESOURCE_MANAGER_ENABLED
107#define JPEGENC1MPImage 1000000
108#define JPEGENC2MPImage 2000000
109#endif
110
111#define DSP_MMU_FAULT_HANDLING
112
113//JPEG Encoder Specific DSP Err Codes
114#define IUALG_ERR_INSUFF_BUFFER 0x8401
115
116/*Linked List */
117
118typedef struct Node {
119    struct Node *pNextNode;
120    void *pValue;
121} Node;
122
123typedef struct LinkedList {
124    Node *pRoot;
125    pthread_mutex_t lock;
126}   LinkedList;
127
128LinkedList AllocList;
129
130void LinkedList_Create(LinkedList *LinkedList);
131void LinkedList_AddElement(LinkedList *LinkedList, void *pValue);
132void LinkedList_FreeElement(LinkedList *LinkedList, void *pValue);
133void LinkedList_FreeAll(LinkedList *LinkedList);
134void LinkedList_DisplayAll(LinkedList *LinkedList);
135void LinkedList_Destroy(LinkedList *LinkedList);
136
137/*
138 *     M A C R O S
139 */
140
141#define OMX_CONF_INIT_STRUCT(_s_, _name_)   \
142    memset((_s_), 0x0, sizeof(_name_)); \
143    (_s_)->nSize = sizeof(_name_);      \
144    (_s_)->nVersion.s.nVersionMajor = 0x1;  \
145    (_s_)->nVersion.s.nVersionMinor = 0x0;  \
146    (_s_)->nVersion.s.nRevision = 0x0;      \
147    (_s_)->nVersion.s.nStep = 0x0
148
149#define OMX_CHECK_PARAM(_ptr_)  \
150{   \
151    if(!_ptr_) {    \
152    eError = OMX_ErrorBadParameter; \
153    goto EXIT; \
154    }   \
155}
156
157#define OMX_CONF_SET_ERROR_BAIL(_eError, _eCode)\
158{                       \
159    _eError = _eCode;               \
160    goto OMX_CONF_CMD_BAIL;         \
161}
162
163#define OMX_MALLOC(_pStruct_, _size_)   \
164    _pStruct_ = malloc(_size_);  \
165    if(_pStruct_ == NULL){  \
166        eError = OMX_ErrorInsufficientResources;    \
167        goto EXIT;  \
168    } \
169    memset(_pStruct_, 0, _size_);\
170    LinkedList_AddElement(&AllocList, _pStruct_);
171
172#define OMX_FREE(_ptr)   \
173{                     \
174    if (_ptr != NULL) { \
175        LinkedList_FreeElement(&AllocList, _ptr);\
176        _ptr = NULL; \
177    }                \
178}
179
180#define OMX_FREEALL()   \
181{                     \
182        LinkedList_FreeAll(&AllocList);\
183}
184
185#define OMX_MEMCPY_CHECK(_p_)\
186{\
187    if (_p_ == NULL) { \
188    eError = OMX_ErrorInsufficientResources;  \
189    goto EXIT;   \
190    } \
191}
192
193
194#ifdef RESOURCE_MANAGER_ENABLED
195#define OMX_GET_RM_VALUE(_Res_, _RM_, _dbg_) \
196{   \
197    if ((_Res_) <= JPEGENC1MPImage){  \
198        (_RM_) = 30;  \
199        }   \
200    else {  \
201        (_RM_) = 60;  \
202        }   \
203    \
204        \
205    OMX_PRMGR2((_dbg_), "Value in MHz requested to RM = %d\n", (_RM_)); \
206}
207#endif
208
209typedef struct IDMJPGE_TIGEM_Comment {
210  OMX_U8 comment[256];
211  OMX_U16 commentLen;
212} IDMJPGE_TIGEM_Comment;
213
214
215typedef struct IIMGENC_DynamicParams {
216    OMX_U32 nSize;             /* nSize of this structure */
217    OMX_U32 nNumAU;            /* Number of Access unit to encode,
218                                  * set to XDM_DEFAULT in case of entire frame
219                                  */
220    OMX_U32 nInputChromaFormat;/* Input chroma format, Refer above comments regarding chroma                    */
221    OMX_U32 nInputHeight;       /* Input nHeight*/
222    OMX_U32 nInputWidth;        /* Input nWidth*/
223    OMX_U32 nCaptureWidth;      /* 0: use imagewidth as pitch, otherwise:
224                                   * use given display nWidth (if > imagewidth)
225                                   * for pitch.
226                                   */
227    OMX_U32 nGenerateHeader;    /* XDM_ENCODE_AU or XDM_GENERATE_HEADER */
228    OMX_U32 qValue;            /* Q value compression factor for encoder */
229} IIMGENC_DynamicParams;
230
231
232  typedef struct IDMJPGE_TIGEM_CustomQuantTables
233  {
234    /* The array "lum_quant_tab" defines the quantization table for the luma component. */
235    OMX_U16 lum_quant_tab[64];
236    /* The array "chm_quant_tab" defines the quantization table for the chroma component.  */
237    OMX_U16 chm_quant_tab[64];
238  } IDMJPGE_TIGEM_CustomQuantTables;
239
240
241typedef struct IDMJPGE_TIGEM_DynamicParams {
242    IIMGENC_DynamicParams  params;
243    OMX_U32 captureHeight;       /* if set to 0 use image height
244                                     else should set to actual Image height */
245    OMX_U32 DRI_Interval ;
246    JPEGENC_CUSTOM_HUFFMAN_TABLE *huffmanTable;
247    IDMJPGE_TIGEM_CustomQuantTables *quantTable;
248} IDMJPGE_TIGEM_DynamicParams;
249
250/* PPLIB not needed if the the input to jpeg encoder is yuv. Uncomment the next line if PPLIB is needed */
251/* #define __JPEG_OMX_PPLIB_ENABLED__ */
252
253#ifdef __JPEG_OMX_PPLIB_ENABLED__
254#define OMX_JPEGENC_NUM_DLLS (5)
255#else
256#define OMX_JPEGENC_NUM_DLLS (4)
257#endif
258
259
260#ifdef UNDER_CE
261#define JPEG_ENC_NODE_DLL "/windows/jpegenc_sn.dll64P"
262#define JPEG_COMMON_DLL "/windows/usn.dll64P"
263#define USN_DLL "/windows/usn.dll64P"
264#define CONVERSIONS_DLL "/windows/conversions.dll64P"
265	#ifdef __JPEG_OMX_PPLIB_ENABLED__
266		#define PPLIB_DLL "/windows/postprocessor_dualout.dll64P"
267	#endif
268#else
269#define JPEG_ENC_NODE_DLL "jpegenc_sn.dll64P"
270#define JPEG_COMMON_DLL "usn.dll64P"
271#define USN_DLL "usn.dll64P"
272#define CONVERSIONS_DLL "conversions.dll64P"
273	#ifdef __JPEG_OMX_PPLIB_ENABLED__
274		#define PPLIB_DLL "postprocessor_dualout.dll64P"
275	#endif
276#endif
277
278#define JPGENC_SNTEST_STRMCNT          2
279#define JPGENC_SNTEST_INSTRMID         0
280#define JPGENC_SNTEST_OUTSTRMID        1
281#define JPGENC_SNTEST_ARGLENGTH        20
282#define JPGENC_SNTEST_INBUFCNT         4
283#define JPGENC_SNTEST_OUTBUFCNT        4
284#define JPGENC_SNTEST_MAX_HEIGHT       4096
285#define JPGENC_SNTEST_MAX_WIDTH        4096
286#define JPGENC_SNTEST_PROG_FLAG        1
287#define M_COM   0xFE            /* COMment  */
288
289#define JPEGE_DSPSTOP       0x01
290#define JPEGE_BUFFERBACK    0x02
291#define JPEGE_IDLEREADY     ( JPEGE_DSPSTOP | JPEGE_BUFFERBACK )
292
293typedef enum Content_Type
294{
295    APP0_BUFFER = 0,
296    APP1_BUFFER,
297    APP13_BUFFER,
298    COMMENT_BUFFER,
299    APP0_NUMBUF,
300    APP1_NUMBUF,
301    APP13_NUMBUF,
302    COMMENT_NUMBUF,
303    APP0_THUMB_H,
304    APP0_THUMB_W,
305    APP1_THUMB_H,
306    APP1_THUMB_W,
307    APP13_THUMB_H,
308    APP13_THUMB_W,
309    APP0_THUMB_INDEX,
310    APP1_THUMB_INDEX,
311    APP13_THUMB_INDEX,
312    DYNPARAMS_HUFFMANTABLE,
313    DYNPARAMS_QUANTTABLE,
314    APP5_BUFFER,
315    APP5_NUMBUF,
316    APP5_THUMB_H,
317    APP5_THUMB_W,
318    APP5_THUMB_INDEX
319} Content_Type;
320
321/*This enum must not be changed.  */
322typedef enum JPEG_PORT_TYPE_INDEX
323    {
324    JPEGENC_INP_PORT,
325    JPEGENC_OUT_PORT
326}JPEG_PORT_TYPE_INDEX;
327
328typedef enum JPEGENC_BUFFER_OWNER {
329    JPEGENC_BUFFER_CLIENT = 0x0,
330    JPEGENC_BUFFER_COMPONENT_IN,
331    JPEGENC_BUFFER_COMPONENT_OUT,
332    JPEGENC_BUFFER_DSP,
333    JPEGENC_BUFFER_TUNNEL_COMPONENT
334} JPEGENC_BUFFER_OWNER;
335
336typedef struct _JPEGENC_BUFFERFLAG_TRACK {
337    OMX_U32 flag;
338    OMX_U32 buffer_id;
339    OMX_HANDLETYPE hMarkTargetComponent;
340    OMX_PTR pMarkData;
341} JPEGENC_BUFFERFLAG_TRACK;
342
343typedef struct _JPEGENC_BUFFERMARK_TRACK {
344    OMX_U32 buffer_id;
345    OMX_HANDLETYPE hMarkTargetComponent;
346    OMX_PTR pMarkData;
347} JPEGENC_BUFFERMARK_TRACK;
348
349typedef struct JPEGENC_BUFFER_PRIVATE {
350    OMX_BUFFERHEADERTYPE* pBufferHdr;
351    JPEGENC_BUFFER_OWNER eBufferOwner;
352    OMX_BOOL bAllocByComponent;
353    OMX_BOOL bReadFromPipe;
354} JPEGENC_BUFFER_PRIVATE;
355
356typedef struct JPEG_PORT_TYPE   {
357    OMX_HANDLETYPE hTunnelComponent;
358    OMX_U32 nTunnelPort;
359    JPEGENC_BUFFER_PRIVATE* pBufferPrivate[NUM_OF_BUFFERSJPEG];
360    JPEGENC_BUFFERFLAG_TRACK sBufferFlagTrack[NUM_OF_BUFFERSJPEG];
361    JPEGENC_BUFFERMARK_TRACK sBufferMarkTrack[NUM_OF_BUFFERSJPEG];
362    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef;
363    OMX_BUFFERSUPPLIERTYPE pBufSupplier;
364    OMX_PARAM_BUFFERSUPPLIERTYPE* pParamBufSupplier;
365    OMX_IMAGE_PARAM_PORTFORMATTYPE* pPortFormat;
366    OMX_U8 nBuffCount;
367}JPEG_PORT_TYPE;
368
369typedef struct JPEGE_INPUT_PARAMS {
370    OMX_U32 *pInParams;
371    OMX_U32 size;
372} JPEGE_INPUT_PARAMS;
373
374typedef struct _JPEGENC_CUSTOM_PARAM_DEFINITION {
375    OMX_U8 cCustomParamName[128];
376    OMX_INDEXTYPE nCustomParamIndex;
377} JPEGENC_CUSTOM_PARAM_DEFINITION;
378
379typedef struct JPEGENC_COMPONENT_PRIVATE
380{
381    JPEG_PORT_TYPE* pCompPort[NUM_OF_PORTS];
382    OMX_PORT_PARAM_TYPE* pPortParamType;
383    OMX_PORT_PARAM_TYPE* pPortParamTypeAudio;
384    OMX_PORT_PARAM_TYPE* pPortParamTypeVideo;
385    OMX_PORT_PARAM_TYPE* pPortParamTypeOthers;
386    OMX_PRIORITYMGMTTYPE* pPriorityMgmt;
387    OMX_CALLBACKTYPE cbInfo;
388    OMX_IMAGE_PARAM_QFACTORTYPE* pQualityfactor;
389    OMX_CONFIG_RECTTYPE  *pCrop;
390    /** This is component handle */
391    OMX_COMPONENTTYPE* pHandle;
392    /*Comonent Name& Version*/
393    OMX_STRING cComponentName;
394    OMX_VERSIONTYPE ComponentVersion;
395    OMX_VERSIONTYPE SpecVersion;
396
397    /** Current state of this component */
398    OMX_STATETYPE   nCurState;
399    OMX_STATETYPE   nToState;
400    OMX_U8          ExeToIdleFlag;  /* StateCheck */
401
402    OMX_U32 nInPortIn;
403    OMX_U32 nInPortOut;
404    OMX_U32 nOutPortIn;
405    OMX_U32 nOutPortOut;
406    OMX_BOOL bInportDisableIncomplete;
407    OMX_BOOL bOutportDisableIncomplete;
408    OMX_BOOL bSetLumaQuantizationTable;
409    OMX_BOOL bSetChromaQuantizationTable;
410    OMX_BOOL bSetHuffmanTable;
411	OMX_BOOL bConvert420pTo422i;
412	OMX_BOOL bPPLibEnable;
413    OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE *pCustomLumaQuantTable;
414    OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE *pCustomChromaQuantTable;
415    JPEGENC_CUSTOM_HUFFMANTTABLETYPE *pHuffmanTable;
416
417
418    /** The component thread handle */
419    pthread_t ComponentThread;
420    /** The pipes to maintain free buffers */
421    int free_outBuf_Q[2];
422    /** The pipes to maintain input buffers sent from app*/
423    int filled_inpBuf_Q[2];
424    /** The pipes for sending buffers to the thread */
425    int nCmdPipe[2];
426    int nCmdDataPipe[2];
427    OMX_U32 nApp_nBuf;
428    short int nNum_dspBuf;
429    int nCommentFlag;
430    OMX_U8 *pString_Comment;
431    JPEG_APPTHUMB_MARKER sAPP0;
432    JPEG_APPTHUMB_MARKER sAPP1;
433    JPEG_APPTHUMB_MARKER sAPP5;
434    JPEG_APP13_MARKER sAPP13;
435    JPEGE_INPUT_PARAMS InParams;
436#ifdef __JPEG_OMX_PPLIB_ENABLED__
437    OMX_U32 *pOutParams;
438#endif
439#ifdef RESOURCE_MANAGER_ENABLED
440    RMPROXY_CALLBACKTYPE rmproxyCallback;
441#endif
442    OMX_BOOL bPreempted;
443    int nFlags;
444    int nMarkPort;
445    OMX_PTR pMarkData;
446    OMX_HANDLETYPE hMarkTargetComponent;
447    OMX_BOOL bDSPStopAck;
448   OMX_BOOL bFlushComplete;
449    OMX_BOOL bAckFromSetStatus;
450    void* pLcmlHandle;   /* Review Utils.c */
451    int isLCMLActive;
452    LCML_DSP_INTERFACE* pLCML;
453    void * pDllHandle;
454    OMX_U8 nDRI_Interval;
455#ifdef KHRONOS_1_1
456    OMX_PARAM_COMPONENTROLETYPE componentRole;
457#endif
458    IDMJPGE_TIGEM_DynamicParams *pDynParams;
459
460    pthread_mutex_t jpege_mutex;
461    pthread_cond_t  stop_cond;
462    pthread_cond_t  flush_cond;
463    /* pthread_cond_t  control_cond; */
464    pthread_mutex_t jpege_mutex_app;
465    pthread_cond_t  populate_cond;
466    pthread_cond_t  unpopulate_cond;
467
468
469#ifdef __PERF_INSTRUMENTATION__
470    PERF_OBJHANDLE pPERF, pPERFcomp;
471#endif
472    struct OMX_TI_Debug dbg;
473
474    /* Reference count for pending state change requests */
475    OMX_U32 nPendingStateChangeRequests;
476    pthread_mutex_t mutexStateChangeRequest;
477    pthread_cond_t StateChangeCondition;
478
479} JPEGENC_COMPONENT_PRIVATE;
480
481
482OMX_ERRORTYPE HandleJpegEncCommand (JPEGENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1);
483OMX_ERRORTYPE JpegEncDisablePort(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1);
484OMX_ERRORTYPE JpegEncEnablePort(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1);
485OMX_ERRORTYPE HandleJpegEncCommandFlush(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1);
486OMX_ERRORTYPE JPEGEnc_Start_ComponentThread(OMX_HANDLETYPE pHandle);
487OMX_ERRORTYPE HandleJpegEncDataBuf_FromApp(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate );
488OMX_ERRORTYPE HandleJpegEncDataBuf_FromDsp( JPEGENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE* pBuffHead );
489OMX_ERRORTYPE HandleJpegEncFreeDataBuf( JPEGENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE* pBuffHead );
490OMX_ERRORTYPE HandleJpegEncFreeOutputBufferFromApp( JPEGENC_COMPONENT_PRIVATE *pComponentPrivate );
491OMX_ERRORTYPE AllocJpegEncResources( JPEGENC_COMPONENT_PRIVATE *pComponentPrivate );
492OMX_ERRORTYPE JPEGEnc_Free_ComponentResources(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate);
493OMX_ERRORTYPE Fill_JpegEncLCMLInitParams(LCML_DSP *lcml_dsp, OMX_U16 arr[], OMX_HANDLETYPE pComponent);
494OMX_ERRORTYPE GetJpegEncLCMLHandle(OMX_HANDLETYPE pComponent);
495OMX_ERRORTYPE SetJpegEncInParams(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate);
496OMX_ERRORTYPE SendDynamicParam(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate);
497OMX_BOOL IsTIOMXComponent(OMX_HANDLETYPE hComp);
498
499#ifdef __JPEG_OMX_PPLIB_ENABLED__
500#define JPEGENC_PPLIB_CREATEPARAM_SIZE 28
501#define JPEGENC_PPLIB_DYNPARM_SIZE 252
502OMX_ERRORTYPE SendDynamicPPLibParam(JPEGENC_COMPONENT_PRIVATE *pComponentPrivate,OMX_U32 *ptInputParam);
503
504
505
506typedef struct _PPLIB_UALGRunTimeParam_t
507{
508    OMX_U32 size;                            /**< Size of the structure in bytes. */
509    OMX_U32 ulInWidth;                       /**< Input picture buffer width.  This value should be the same as the original decoded output width of the WMV9/VC1 stream. */
510    OMX_U32 ulInHeight;                      /**< Input picture buffer height.  This value should be the same as the original decoded output height of the WMV9/VC1 stream. */
511    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. */
512    OMX_U32 ulEnableYUVOutput[2];            /**< Flag to enable YUV output */
513    OMX_U32 ulEnableRGBOutput[2];            /**< Flag to enable RGB output. */
514    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. */
515    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. */
516    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. */
517    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. */
518    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. */
519    OMX_U32 ulFrameOutputHeight[2];          /**< Output picture buffer height for each VGPOP parameter set.*/
520    OMX_U32 ulFrameOutputWidth[2];           /**< Output picture buffer width for each VGPOP parameter set. */
521    OMX_U32 ulFrameContrast[2];              /**< Contrast Method for each VGPOP parameter set */
522    OMX_U32 ulFrameInXStart[2];              /**< Horizontal cropping start position in the input buffer.  Set to 0 if no cropping is desired. */
523    OMX_U32 ulFrameInYStart[2];              /**< Vertical cropping start position in the input buffer.  Set to 0 if no cropping is desired.*/
524    OMX_U32 ulFrameInXSize[2];               /**< Horizontal cropping width.  Set to 0 if no cropping is desired */
525    OMX_U32 ulFrameInYSize[2];               /**< Vertical cropping height.  Set to 0 if no cropping is desired.*/
526    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. */
527    OMX_U32 ulFrameZoomLimit[2];             /**< Zooming ratio limit, where ulZoomLimit=(Desired Zoom Limit * 1024).*/
528    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.*/
529    OMX_U32 ulFrameEnableLightChroma[2];     /**< Light chrominance process.  */
530    OMX_U32 ulFrameEnableAspectRatioLock[2]; /**< Locked H/V ratio */
531    OMX_U32 ulFrameEnableMirroring[2];       /**< To mirror the picture: */
532    OMX_U32 ulFrameRGBRotation[2];           /**< Rotation to apply to RGB Output. May be set to 0, 90, 180 or 270.*/
533    OMX_U32 ulFrameYUVRotation[2];           /**< Rotation to apply to YUV Output. May be set to 0, 90, 180, or 270*/
534    OMX_U32 ulFrameIORange[2];               /**< IO Video Range.   */
535    OMX_U32 ulFrameEnableDithering[2];       /**< Dithering Enable */
536    OMX_U32 ulFrameOutputPitch[2];           /**< Enable an output pitch */
537    OMX_U32 ulAlphaRGB[2];                   /**< This is the default alpha values for ARGB32 or RGBA32. */
538    OMX_U32 ulIsFrameGenerated[2];           /**< Flag to notify the user if a frame has been generated */
539    OMX_U32 ulYUVFrameSize[2];               /**< YUV output size in bytes */
540    OMX_U32 ulRGBFrameSize[2];               /**< RGB output size in bytes. */
541} PPLIB_UALGRunTimeParam_t;
542
543
544
545#endif
546
547typedef OMX_ERRORTYPE (*fpo)(OMX_HANDLETYPE);
548
549static const struct DSP_UUID JPEGESOCKET_TI_UUID = {
550    0xCB70C0C1, 0x4C85, 0x11D6, 0xB1, 0x05, {
551        0x00, 0xC0, 0x4F, 0x32, 0x90, 0x31
552    }
553};
554
555
556static const struct DSP_UUID USN_UUID = {
557    0x79A3C8B3, 0x95F2, 0x403F, 0x9A, 0x4B, {
558        0xCF, 0x80, 0x57, 0x73, 0x05, 0x41
559    }
560};
561
562static const struct DSP_UUID CONVERSIONS_UUID = {
563	0x722DD0DA, 0xF532, 0x4238, 0xB8, 0x46, {
564		0xAB, 0xFF, 0x5D, 0xA4, 0xBA, 0x02
565	}
566};
567
568#ifdef __JPEG_OMX_PPLIB_ENABLED__
569static const struct DSP_UUID PPLIB_UUID = {
570	0xFC8CF948, 0xD3E9, 0x4B65, 0xBC, 0xA7, {
571	0x08, 0x2E, 0xA0, 0xAD, 0x86, 0xF0
572    }
573};
574#endif
575void* OMX_JpegEnc_Thread (void* pThreadData);
576
577typedef enum ThrCmdType
578{
579    SetState,
580    Flush,
581    StopPort,
582    RestartPort,
583    MarkBuf,
584    Start,
585    Stop,
586    FillBuf,
587    EmptyBuf
588} ThrCmdType;
589
590typedef enum OMX_JPEGE_INDEXTYPE  {
591
592    OMX_IndexCustomCommentFlag = 0xFF000001,
593    OMX_IndexCustomCommentString = 0xFF000002,
594    OMX_IndexCustomInputFrameWidth,
595    OMX_IndexCustomInputFrameHeight,
596    OMX_IndexCustomAPP0,
597    OMX_IndexCustomAPP1,
598    OMX_IndexCustomAPP5,
599    OMX_IndexCustomAPP13,
600    OMX_IndexCustomQFactor,
601    OMX_IndexCustomDRI,
602    OMX_IndexCustomHuffmanTable,
603    OMX_IndexCustomDebug,
604	OMX_IndexCustomColorFormatConvertion_420pTo422i,
605	OMX_IndexCustomPPLibEnable
606}OMX_INDEXIMAGETYPE;
607
608typedef struct IUALG_Buf {
609    OMX_PTR            pBufAddr;
610    unsigned long          ulBufSize;
611    OMX_PTR            pParamAddr;
612    unsigned long        ulParamSize;
613    unsigned long          ulBufSizeUsed;
614    //IUALG_BufState tBufState;
615    OMX_BOOL           bBufActive;
616    OMX_U32          unBufID;
617    unsigned long          ulReserved;
618} IUALG_Buf;
619
620typedef enum {
621    IUALG_CMD_STOP             = 0,
622    IUALG_CMD_PAUSE            = 1,
623    IUALG_CMD_GETSTATUS        = 2,
624    IUALG_CMD_SETSTATUS        = 3,
625    IUALG_CMD_USERSETCMDSTART  = 100,
626    IUALG_CMD_USERGETCMDSTART  = 150,
627    IUALG_CMD_FLUSH            = 0x100
628}IUALG_Cmd;
629
630OMX_ERRORTYPE AddStateTransition(JPEGENC_COMPONENT_PRIVATE* pComponentPrivate);
631OMX_ERRORTYPE RemoveStateTransition(JPEGENC_COMPONENT_PRIVATE* pComponentPrivate, OMX_BOOL bEnableSignal);
632
633#endif /*OMX_JPEGENC_UTILS__H*/
634