summaryrefslogtreecommitdiff
path: root/omx/audio/src/openmax_il/aac_enc/inc/OMX_AacEnc_Utils.h
blob: c4ac3cc873c015954ac9a55a350a623e198af283 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694

/*
 * Copyright (C) Texas Instruments - http://www.ti.com/
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
#ifndef OMX_AACENC_UTILS__H
#define OMX_AACENC_UTILS__H

#include <OMX_Component.h>
#include <OMX_TI_Common.h>
#include <OMX_TI_Debug.h>
#include "LCML_DspCodec.h"
#include "OMX_AacEncoder.h"
/* #include <ResourceManagerProxyAPI.h> */

#define AACENC_MAJOR_VER 0x0001
#define AACENC_MINOR_VER 0x0001
#define NOT_USED 10
#define NORMAL_BUFFER 0
#define OMX_AACENC_DEFAULT_SEGMENT (0)
#define OMX_AACENC_SN_TIMEOUT (1000)
#define OMX_AACENC_SN_PRIORITY (10)
#define OMX_AACENC_NUM_DLLS (2)
#define AACENC_CPU_USAGE 45
#define _ERROR_PROPAGATION__ 
#define MPEG4AACENC_MAX_OUTPUT_FRAMES 24

#ifndef ANDROID
    #define ANDROID
#endif

#ifdef ANDROID
    #undef LOG_TAG
    #define LOG_TAG "OMX_AACENC"

/* PV opencore capability custom parameter index */
    #define PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX 0xFF7A347
#endif

#define EXTRA_BYTES 128 
#define DSP_CACHE_ALIGNMENT 256 

#ifdef __PERF_INSTRUMENTATION__
    #include "perf.h"
#endif
#include <OMX_Component.h>

#define OMX_CONF_INIT_STRUCT(_s_, _name_)   \
    memset((_s_), 0x0, sizeof(_name_)); \
    (_s_)->nSize = sizeof(_name_);      \
    (_s_)->nVersion.s.nVersionMajor = AACENC_MAJOR_VER;  \
    (_s_)->nVersion.s.nVersionMinor = AACENC_MINOR_VER;  \
    (_s_)->nVersion.s.nRevision = 0x0001;      \
    (_s_)->nVersion.s.nStep = 0x0

#define OMX_CONF_CHECK_CMD(_ptr1, _ptr2, _ptr3) \
{                       \
    if(!_ptr1 || !_ptr2 || !_ptr3){     \
        OMXDBG_PRINT(stderr, ERROR, 4, 0, "%d :: Error bad parameter \n",__LINE__);\
        eError = OMX_ErrorBadParameter;     \
    goto EXIT;          \
    }                       \
}

#define OMX_CONF_SET_ERROR_BAIL(_eError, _eCode)\
{                       \
    _eError = _eCode;               \
    goto OMX_CONF_CMD_BAIL;         \
}

#define OMX_MALLOC_STRUCT(_pStruct_, _sName_)   \
    _pStruct_ = (_sName_*)newmalloc(sizeof(_sName_));   \
    if(_pStruct_ == NULL){  \
        eError = OMX_ErrorInsufficientResources;    \
        goto EXIT;  \
    } \
    memset(_pStruct_,0,sizeof(_sName_));
    
#define OMX_MALLOC_STRUCT_SIZE(_ptr_, _size_,_name_)    \
    _ptr_ = (_name_ *)newmalloc(_size_);    \
    if(_ptr_ == NULL){  \
        eError = OMX_ErrorInsufficientResources;    \
        goto EXIT;  \
    } \
    memset(_ptr_,0,_size_);
    
    
#define OMX_MEMFREE_STRUCT(_pStruct_)\
    OMXDBG_PRINT(stderr, PRINT, 2, OMX_DBG_BASEMASK, "%d :: FREEING MEMORY = %p\n",__LINE__,_pStruct_);\
    if(_pStruct_ != NULL){\
        newfree(_pStruct_);\
        _pStruct_ = NULL;\
    }

#define OMX_CLOSE_PIPE(_pStruct_,err)\
    OMXDBG_PRINT(stderr, PRINT, 2, OMX_DBG_BASEMASK, "%d :: CLOSING PIPE \n",__LINE__);\
    err = close (_pStruct_);\
    if(0 != err && OMX_ErrorNone == eError){\
        eError = OMX_ErrorHardware;\
        OMXDBG_PRINT(stderr, ERROR, 4, 0, "%d :: Error while closing pipe\n",__LINE__);\
        goto EXIT;\
    }

#define OMX_DPRINT_ADDRESS(_s_, _ptr_)  \
    OMXDBG_PRINT(stderr, PRINT, 2, 0, "%s = %p\n", _s_, _ptr_);


#undef SWAT_ANALYSIS

/* debug message */ 
#undef AACENC_DEBUG        
#define AACENC_ERROR


#ifndef UNDER_CE
#ifdef  AACENC_ERROR
     #define AACENC_EPRINT(...) fprintf(stderr,__VA_ARGS__)
#else
     #define AACENC_EPRINT(...)
#endif /* AAC_ERROR*/


#ifdef  AACENC_DEBUG
     #define AACENC_DPRINT(...) fprintf(stderr,__VA_ARGS__)
#else
     #define AACENC_DPRINT(...)
#endif

#else /*UNDER_CE*/ 

#ifdef  AACENC_DEBUG
 #define AACENC_DPRINT(STR, ARG...) printf()
#else
#endif

#endif /*UNDER_CE*/ 

/* ======================================================================= */
/**
 * @def    AACENC_USN_DLL_NAME   USN DLL name
 */
/* ======================================================================= */
#ifdef UNDER_CE
#define AACENC_USN_DLL_NAME "\\windows\\usn.dll64P"
#else
#define AACENC_USN_DLL_NAME "usn.dll64P"
#endif

/* ======================================================================= */
/**
 * @def    AACENC_DLL_NAME   AAC Enc Encoder socket node DLL name
 */
/* ======================================================================= */
#ifdef UNDER_CE
#define AACENC_DLL_NAME "\\windows\\mpeg4aacenc_sn.dll64P"
#else
#define AACENC_DLL_NAME "mpeg4aacenc_sn.dll64P"
#endif

typedef struct 
{
    OMX_BOOL bLastBuffer;
}AACENC_UAlgInBufParamStruct;

typedef struct 
{
    unsigned long unNumFramesEncoded;
    unsigned long unFrameSizes[MPEG4AACENC_MAX_OUTPUT_FRAMES];
}AACENC_UAlgOutBufParamStruct;


typedef struct PV_OMXComponentCapabilityFlagsType
{
        ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS (for opencore compatability)
        OMX_BOOL iIsOMXComponentMultiThreaded;
        OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc;
        OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc;
        OMX_BOOL iOMXComponentSupportsMovableInputBuffers;
        OMX_BOOL iOMXComponentSupportsPartialFrames;
        OMX_BOOL iOMXComponentNeedsNALStartCode;
        OMX_BOOL iOMXComponentCanHandleIncompleteFrames;
} PV_OMXComponentCapabilityFlagsType;

/*This enum must not be changed.*/
typedef enum COMP_PORT_TYPE 
{
    INPUT_PORT = 0,
    OUTPUT_PORT
}COMP_PORT_TYPE;

typedef enum 
{
    DIRECTION_INPUT,
    DIRECTION_OUTPUT
}BUFFER_Dir;

typedef struct BUFFS 
{
    char BufHeader;
    char Buffer;
}BUFFS;

typedef struct BUFFERHEADERTYPE_INFO 
{
    OMX_BUFFERHEADERTYPE* pBufHeader[MAX_NUM_OF_BUFS];
    BUFFS bBufOwner[MAX_NUM_OF_BUFS];
}BUFFERHEADERTYPE_INFO;

typedef OMX_ERRORTYPE (*fpo)(OMX_HANDLETYPE);

typedef struct AACENC_AudioCodecParams 
{
    unsigned long  iSamplingRate;
    unsigned long  iStrmId;
    unsigned short iAudioFormat;
}AACENC_AudioCodecParams;

/* enum AACENC_BOOL_TYPE                        */
/* brief Enumerated type for Boolean decision   */

typedef enum 
{
    AACENC_FALSE = 0,     /*!< To indicate False  */
    AACENC_TRUE  = 1      /*!< To indicate True   */
} AACENC_BOOL_TYPE;

/*! \enum AACENC_OBJ_TYP  */
/*! \brief enumerated type for output format */
typedef enum
{
  AACENC_OBJ_TYP_LC           = 2,   /*!< AAC Low Complexity  */
  AACENC_OBJ_TYP_HEAAC        = 5,   /*!< HE AAC              */
  AACENC_OBJ_TYP_PS           = 29   /*!< AAC LC + SBR + PS   */
} AACENC_OBJ_TYP;

/*! \enum  AACENC_TRANSPORT_TYPE */
/*! \brief Enumerated type for output file format */
typedef enum 
{
  AACENC_TT_RAW    = 0,              /*!< Raw Output Format   */
  AACENC_TT_ADIF   = 1,              /*!< ADIF File Format    */
  AACENC_TT_ADTS   = 2               /*!< ADTS File Format    */
} AACENC_TRANSPORT_TYPE;

/* ======================================================================= */
/** MPEG4AACENC_UALGParams
 *
 * @param lOutputFormat - To set interleaved/Block format:Refer to IAUDIO_PcmFormat.
 * @param DownSampleSbr -
 */
/* ==================================================================== */
typedef struct 
{
    long size;           /* size of this structure */
    long bitRate;        /* Average bit rate in bits per second */
    long sampleRate;     /* Samplling frequency in Hz */
    long numChannels;    /* Number of Channels: IAUDIO_ChannelId */

}MPEG4AUDENC_UALGdynamicparams;


typedef struct MPEG4AACENC_UALGParams 
{
    int size;
    MPEG4AUDENC_UALGdynamicparams audenc_dynamicparams; 
                                            /*!< generic encoder dynamic parameters  */

    /* For RESET Command */
    AACENC_BOOL_TYPE        useTns;         /*!< Flag for activating TNS feature     */
    AACENC_BOOL_TYPE        usePns;         /*!< Flag for activating PNS feature     */

    AACENC_OBJ_TYP          outObjectType;  /*!< Output Object Type LC/HE/HEv2     */
    AACENC_TRANSPORT_TYPE   outFileFormat;  /*!< Output File Format            */

} MPEG4AACENC_UALGParams;

typedef enum {
    IUALG_CMD_STOP          = 0,
    IUALG_CMD_PAUSE         = 1,
    IUALG_CMD_GETSTATUS     = 2,
    IUALG_CMD_SETSTATUS     = 3,    
    IUALG_CMD_USERCMDSTART  = 100
}IUALG_Cmd;

typedef enum {
    IAUDIO_BLOCK=0,
    IAUDIO_INTERLEAVED
} IAUDIO_AacFormat;

typedef struct LCML_AACENC_BUFHEADERTYPE 
{
      BUFFER_Dir eDir;
      OMX_BUFFERHEADERTYPE* buffer;
      AACENC_UAlgInBufParamStruct *pIpParam;
      AACENC_UAlgOutBufParamStruct *pOpParam;
}LCML_AACENC_BUFHEADERTYPE;



typedef struct _BUFFERLIST BUFFERLIST;

struct _BUFFERLIST
{
    OMX_BUFFERHEADERTYPE sBufHdr;                   /* actual buffer header */
    OMX_BUFFERHEADERTYPE *pBufHdr[MAX_NUM_OF_BUFS]; /* records buffer header send by client */
    OMX_U32 bufferOwner[MAX_NUM_OF_BUFS];
    OMX_U16 numBuffers;
    OMX_U32 bBufferPending[MAX_NUM_OF_BUFS];
    BUFFERLIST *pNextBuf;
    BUFFERLIST *pPrevBuf;
};

#ifdef UNDER_CE
    #ifndef _OMX_EVENT_
        #define _OMX_EVENT_
        typedef struct OMX_Event {
            HANDLE event;
        } OMX_Event;
    #endif
    int OMX_CreateEvent(OMX_Event *event);
    int OMX_SignalEvent(OMX_Event *event);
    int OMX_WaitForEvent(OMX_Event *event);
    int OMX_DestroyEvent(OMX_Event *event);
#endif



typedef struct AACENC_COMPONENT_PRIVATE 
{
    /** Array of pointers to BUFFERHEADERTYPE structues
       This pBufHeader[INPUT_PORT] will point to all the
       BUFFERHEADERTYPE structures related to input port,
       not just one structure. Same is for output port
       also. */
    OMX_BUFFERHEADERTYPE* pBufHeader[NUM_OF_PORTS];

    BUFFERHEADERTYPE_INFO BufInfo[NUM_OF_PORTS];

    OMX_CALLBACKTYPE cbInfo;
    /** Handle for use with async callbacks */
    OMX_PORT_PARAM_TYPE sPortParam;
    
    OMX_PRIORITYMGMTTYPE* sPriorityMgmt;
    
/*  RMPROXY_CALLBACKTYPE rmproxyCallback; */
    OMX_BOOL bPreempted;
    
    OMX_AUDIO_PARAM_PORTFORMATTYPE sInPortFormat;
    
    OMX_AUDIO_PARAM_PORTFORMATTYPE sOutPortFormat;
    
    OMX_U32 bIsBufferOwned[NUM_OF_PORTS];
    /** This will contain info like how many buffers
        are there for input/output ports, their size etc, but not
        BUFFERHEADERTYPE POINTERS. */
    OMX_U32 abc;
    
    OMX_U32 def;
    
    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[NUM_OF_PORTS];
    
    OMX_AUDIO_PARAM_AACPROFILETYPE* aacParams[NUM_OF_PORTS];

    OMX_AUDIO_PARAM_PCMMODETYPE* pcmParam[NUM_OF_PORTS];

    /** This is component handle */
    OMX_COMPONENTTYPE* pHandle;

    /** Current state of this component */
    OMX_STATETYPE curState;

    /** The component thread handle */
    pthread_t ComponentThread;

    /** The pipes for sending buffers to the thread */
    int dataPipe[2];

    /** The pipes for sending buffers to the thread */
    int cmdPipe[2];
    /** The pipes for sending buffers to the thread */
    int cmdDataPipe[2];

    /** The pipes for sending buffers to the thread */
  /*  int lcml_Pipe[2];  */

    /** Set to indicate component is stopping */
    OMX_U32 bIsStopping;

    /** Number of input buffers at runtime */
    OMX_U32 nRuntimeInputBuffers;

    /** Number of output buffers at runtime */
    OMX_U32 nRuntimeOutputBuffers;

    OMX_U32 bIsThreadstop;

    OMX_U32 bIsEOFSent;

    /** Count of number of buffers outstanding with bridge */
    OMX_U32 lcml_nIpBuf;

    OMX_BOOL CustomConfiguration;

#ifdef __PERF_INSTRUMENTATION__
        PERF_OBJHANDLE pPERF, pPERFcomp;
        OMX_U32 nLcml_nCntIp;         
        OMX_U32 nLcml_nCntOpReceived;
#endif

    /** Count of number of buffers outstanding with bridge */
    OMX_U32 lcml_nOpBuf;

    OMX_U32 app_nBuf;

    OMX_U32 lcml_nCntIp;
    
    OMX_U32 lcml_nCntOpReceived;
    
    OMX_U32 lcml_nCntApp;
    
    OMX_U32 lcml_compID;

    OMX_U32 num_Reclaimed_Op_Buff;

    OMX_U32 num_Sent_Ip_Buff;

    OMX_U32 num_Op_Issued;

    OMX_HANDLETYPE pLcmlHandle;

    LCML_AACENC_BUFHEADERTYPE *pLcmlBufHeader[2];

    MPEG4AACENC_UALGParams* ptAlgDynParams;

    AACENC_AudioCodecParams* pParams;

    OMX_U16 ulSamplingRate;
    
    OMX_U16 unNumChannels;
    
    OMX_U32 unBitrate;
    
    OMX_U16 nObjectType;
    
    OMX_U32 bitRateMode;
    
    OMX_U16 File_Format;
    
    OMX_U32 dasfmode;

    OMX_U32 EmptybufferdoneCount;
    
    OMX_U32 EmptythisbufferCount;

    OMX_U32 FillbufferdoneCount;
    
    OMX_U32 FillthisbufferCount;
    
    OMX_U32 bPortDefsAllocated;
    
    OMX_U32 bCompThreadStarted;
    
    OMX_PTR pMarkData;
    
    OMX_MARKTYPE *pMarkBuf;
    
    OMX_HANDLETYPE hMarkTargetComponent;
    
    OMX_U32 bBypassDSP;
    
    BUFFERLIST *pInputBufferList;
    
    BUFFERLIST *pOutputBufferList;
    
    LCML_STRMATTR *strmAttr;
    
    OMX_U32 nVersion;
    
    OMX_STRING cComponentName;
    
    OMX_VERSIONTYPE ComponentVersion;
    
    OMX_U32 streamID;
    
    OMX_U32 bInputBufferHeaderAllocated;
    /** Stores input buffers while paused */
    OMX_BUFFERHEADERTYPE *pInputBufHdrPending[MAX_NUM_OF_BUFS];

    /** Number of input buffers received while paused */
    OMX_U32 nNumInputBufPending;

    /** Stores output buffers while paused */   
    OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[MAX_NUM_OF_BUFS];

    /** Number of output buffers received while paused */
    OMX_U32 nNumOutputBufPending;


    OMX_U8 PendingInPausedBufs;
    OMX_BUFFERHEADERTYPE *pInBufHdrPausedPending[MAX_NUM_OF_BUFS];
    OMX_U8 PendingOutPausedBufs;
    OMX_BUFFERHEADERTYPE *pOutBufHdrPausedPending[MAX_NUM_OF_BUFS];



    OMX_U32 bPlayCompleteFlag;

    /** Flag set when a disable command is pending */
    OMX_U32 bDisableCommandPending;

    /** Parameter for pending disable command */
    OMX_U32 bDisableCommandParam;

    /** Flag set when a disable command is pending */
    OMX_U32 bEnableCommandPending;

    /** Parameter for pending disable command */
    OMX_U32 nEnableCommandParam;

    /** Flag to set when socket node stop callback should not transition
        component to OMX_StateIdle */
    OMX_U32 bNoIdleOnStop;

    /** Flag set when idle command is pending */
    /* OMX_U32 bIdleCommandPending; */

    /** Flag set when pause command is pending */
    OMX_U32 bPauseCommandPending;

    /** Flag set when socket node is stopped */
    OMX_U32 bDspStoppedWhileExecuting;

    /** Number of outstanding FillBufferDone() calls */
    OMX_S32 nOutStandingFillDones;

    /** Number of outstanding EmptyBufferDone() calls */
    OMX_S32 nOutStandingEmptyDones;

    OMX_BUFFERHEADERTYPE *LastOutputBufferHdrQueued;
    
#ifndef UNDER_CE
    pthread_mutex_t AlloBuf_mutex;    
    pthread_cond_t AlloBuf_threshold;
    OMX_U8 AlloBuf_waitingsignal;
    
    pthread_mutex_t codecStop_mutex;    
    pthread_cond_t codecStop_threshold;
    OMX_U8 codecStop_waitingsignal;

    pthread_mutex_t codecFlush_mutex;    
    pthread_cond_t codecFlush_threshold;
    OMX_U8 codecFlush_waitingsignal;

pthread_mutex_t InLoaded_mutex;
    pthread_cond_t InLoaded_threshold;
    OMX_U8 InLoaded_readytoidle;
    
    pthread_mutex_t InIdle_mutex;
    pthread_cond_t InIdle_threshold;
    OMX_U8 InIdle_goingtoloaded;
    
    OMX_U8 nUnhandledFillThisBuffers;
    OMX_U8 nUnhandledEmptyThisBuffers;
    OMX_BOOL bFlushOutputPortCommandPending;
    OMX_BOOL bFlushInputPortCommandPending;
    
#else
    OMX_Event AlloBuf_event;
    OMX_U8 AlloBuf_waitingsignal;
    
    OMX_Event InLoaded_event;
    OMX_U8 InLoaded_readytoidle;
    
    OMX_Event InIdle_event;
    OMX_U8 InIdle_goingtoloaded; 

    
#endif
    OMX_BOOL bLoadedCommandPending;
    OMX_BOOL bIsInvalidState;
    void* PtrCollector[6];
    
    OMX_BUFFERHEADERTYPE *LastOutbuf;
    OMX_PARAM_COMPONENTROLETYPE componentRole;
    OMX_U16 FramesPer_OutputBuffer;

    /* backup pointer for LCML */
    void* ptrLibLCML;

    OMX_BOOL bCodecDestroyed;
    OMX_BOOL bGotLCML;
    
    OMX_STRING* sDeviceString;
    OMX_BOOL bFirstOutputBuffer;

    /** Keep buffer timestamps **/
    OMX_S64 timestampBufIndex[MAX_NUM_OF_BUFS];
    /** Index to arrBufIndex[], used for input buffer timestamps */
    OMX_U8 IpBufindex;
    /** Index to arrBufIndex[], used for output buffer timestamps */
    OMX_U8 OpBufindex;

    /** Keep buffer tickcount **/
    OMX_U32 tickcountBufIndex[MAX_NUM_OF_BUFS];
    
    PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags;

    struct OMX_TI_Debug dbg;

} AACENC_COMPONENT_PRIVATE;

OMX_ERRORTYPE AACENCGetCorresponding_LCMLHeader(AACENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U8 *pBuffer,
                                                  OMX_DIRTYPE eDir,
                                                  LCML_AACENC_BUFHEADERTYPE **ppLcmlHdr);

OMX_ERRORTYPE AACENCLCML_Callback(TUsnCodecEvent event,void * args [10]);

OMX_ERRORTYPE AACENCFill_LCMLInitParams(OMX_HANDLETYPE pHandle,
                                          LCML_DSP *plcml_Init,OMX_U16 arr[]);

OMX_ERRORTYPE AACENCGetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader, OMX_DIRTYPE *eDir);

OMX_U32 AACENCHandleCommand(AACENC_COMPONENT_PRIVATE *pComponentPrivate);

OMX_ERRORTYPE AACENCHandleDataBuf_FromApp(OMX_BUFFERHEADERTYPE *pBufHeader,
                                            AACENC_COMPONENT_PRIVATE *pComponentPrivate);

int AACEnc_GetSampleRateIndexL( const int aRate);

OMX_HANDLETYPE AACENCGetLCMLHandle(AACENC_COMPONENT_PRIVATE *pComponentPrivate);

OMX_ERRORTYPE AACENC_CleanupInitParams(OMX_HANDLETYPE pHandle);

void AACENC_SetPending(AACENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber);

void AACENC_ClearPending(AACENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber) ;

OMX_U32 AACENC_IsPending(AACENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir);

/* ===========================================================  */
/**
*  AACENC_TransitionToIdle() Transitions component to idle
* 
*
*  @param pComponentPrivate     Component private data
*
*  @return OMX_ErrorNone = No error
*          OMX Error code = Error
*/
/*================================================================== */
/*OMX_ERRORTYPE AACENC_TransitionToIdle(AACENC_COMPONENT_PRIVATE *pComponentPrivate); */

OMX_ERRORTYPE AACENC_TransitionToPause(AACENC_COMPONENT_PRIVATE *pComponentPrivate);

OMX_ERRORTYPE AACENCFill_LCMLInitParamsEx(OMX_HANDLETYPE pComponent);

OMX_ERRORTYPE AACENCWriteConfigHeader(AACENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr);

/* void AACENC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData); */

#ifndef UNDER_CE
OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
#else
/*  WinCE Implicit Export Syntax */
#define OMX_EXPORT __declspec(dllexport)
OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
#endif


OMX_ERRORTYPE AACENC_StartComponentThread(OMX_HANDLETYPE pHandle);

OMX_ERRORTYPE AACENC_StopComponentThread(OMX_HANDLETYPE pHandle);

OMX_ERRORTYPE AACENC_FreeCompResources(OMX_HANDLETYPE pComponent);

#endif