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_AmrDecoder.h
30*
31* This is an header file for an audio PCM decoder that is fully
32* compliant with the OMX Audio specification.
33* This the file that the application that uses OMX would include
34* in its code.
35*
36* @path $(CSLPATH)\
37*
38* @rev 0.1
39*/
40/* --------------------------------------------------------------------------- */
41
42#ifndef OMX_AMRDECODER_H
43#define OMX_AMRDECODER_H
44
45#include "LCML_DspCodec.h"
46#include <OMX_Component.h>
47#include <pthread.h>
48#include <OMX_TI_Debug.h>
49#include <cutils/log.h>
50
51#ifdef RESOURCE_MANAGER_ENABLED
52#include <ResourceManagerProxyAPI.h>
53#endif
54
55#ifdef __PERF_INSTRUMENTATION__
56    #include "perf.h"
57#endif
58
59#ifdef DSP_RENDERING_ON
60#include <AudioManagerAPI.h>
61#endif
62
63
64#ifndef ANDROID
65    #define ANDROID
66#endif
67
68#ifdef ANDROID
69    #undef LOG_TAG
70    #define LOG_TAG "OMX_NBAMRDEC"
71
72    /* PV opencore capability custom parameter index */
73    #define PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX 0xFF7A347
74#endif
75
76
77/* ======================================================================= */
78/**
79 * @def    EXTRA_BUFFBYTES                Num of Extra Bytes to be allocated
80 */
81/* ======================================================================= */
82#define EXTRA_BUFFBYTES (256)
83
84/* ======================================================================= */
85/**
86 * @def    NBAMRD_TIMEOUT   Default timeout used to come out of blocking calls
87 */
88/* ======================================================================= */
89#define NBAMRD_TIMEOUT (1000) /* millisecs */
90
91/* ======================================================================= */
92/**
93 * @def    NUM_NBAMRDEC_INPUT_BUFFERS              Number of Input Buffers
94 */
95/* ======================================================================= */
96#define NUM_NBAMRDEC_INPUT_BUFFERS 1
97
98/* ======================================================================= */
99/**
100 * @def    NUM_NBAMRDEC_OUTPUT_BUFFERS              Number of Output Buffers
101 */
102/* ======================================================================= */
103#define NUM_NBAMRDEC_OUTPUT_BUFFERS 2
104
105/* ======================================================================= */
106/**
107 * @def    NUM_NBAMRDEC_OUTPUT_BUFFERS_DASF         Number of Output Buffers
108 *                                                  on DASF mode
109 */
110/* ======================================================================= */
111#define NUM_NBAMRDEC_OUTPUT_BUFFERS_DASF 2
112
113/* ======================================================================= */
114/**
115 * @def    OUTPUT_NBAMRDEC_BUFFER_SIZE           Standart Output Buffer Size
116 */
117/* ======================================================================= */
118#define OUTPUT_NBAMRDEC_BUFFER_SIZE 320
119/* ======================================================================= */
120/**
121 * @def    INPUT_NBAMRDEC_BUFFER_SIZE_MIME       Mime Input Buffer Size
122 */
123/* ======================================================================= */
124#define INPUT_NBAMRDEC_BUFFER_SIZE_MIME 34
125
126/* ======================================================================= */
127/**
128 * @def    INPUT_BUFF_SIZE_EFR                  Input Buffer Size EFR
129 */
130/* ======================================================================= */
131#define INPUT_BUFF_SIZE_EFR 120
132
133/* @def    INPUT_NBAMRDEC_BUFFER_SIZE_MIME       IF2 Input Buffer Size*/
134/* ======================================================================= */
135#define INPUT_NBAMRDEC_BUFFER_SIZE_IF2 32
136
137
138/* ======================================================================= */
139/**
140 * @def    STD_NBAMRDEC_BUF_SIZE                  Standart Input Buffer Size
141 */
142/* ======================================================================= */
143#define STD_NBAMRDEC_BUF_SIZE 118
144
145/* ======================================================================= */
146/**
147 * @def    FRAME_SIZE_x                          Size in Bytes of determined
148 *                                               frame.
149 */
150/* ======================================================================= */
151#define  FRAME_SIZE_13  13
152#define  FRAME_SIZE_19  19
153#define  FRAME_SIZE_26  26
154#define  FRAME_SIZE_31  31
155#define  FRAME_SIZE_14  14
156#define  FRAME_SIZE_16  16
157#define  FRAME_SIZE_18  18
158#define  FRAME_SIZE_20  20
159#define  FRAME_SIZE_21  21
160#define  FRAME_SIZE_27  27
161#define  FRAME_SIZE_32  32
162#define  FRAME_SIZE_6   6
163#define  FRAME_SIZE_1   1
164#define  FRAME_SIZE_0   0
165
166/* ======================================================================= */
167/**
168 * @def    STREAM_COUNT                         Stream Count value for
169 *                                              LCML init.
170 */
171/* ======================================================================= */
172#define STREAM_COUNT 2
173
174/* ======================================================================= */
175/**
176 * @def    INPUT_STREAM_ID                      Input Stream ID
177 */
178/* ======================================================================= */
179#define INPUT_STREAM_ID 0
180
181
182
183/* ======================================================================= */
184/**
185 * @def    NBAMRDEC_SAMPLING_FREQUENCY          Sampling Frequency
186 */
187/* ======================================================================= */
188#define NBAMRDEC_SAMPLING_FREQUENCY 8000
189
190/* ======================================================================= */
191/**
192 * @def    NBAMRDEC_CPU_LOAD                    CPU Load in MHz
193 */
194/* ======================================================================= */
195#define NBAMRDEC_CPU_LOAD 10
196
197/* ======================================================================= */
198/**
199 * @def    MAX_NUM_OF_BUFS                      Max Num of Bufs Allowed
200 */
201/* ======================================================================= */
202#define MAX_NUM_OF_BUFS 12
203/* ======================================================================= */
204/**
205 * @def    IP_BUFFERSIZE                      Input Port Buffer Size
206 */
207/* ======================================================================= */
208#define IP_BUFFERSIZE 4096
209/* ======================================================================= */
210/**
211 * @def    NUM_MIME_BYTES_ARRAY               amrMimeBytes array size
212 */
213/* ======================================================================= */
214#define NUM_MIME_BYTES_ARRAY 16
215/* ======================================================================= */
216/**
217 * @def    NUM_IF2_BYTES_ARRAY                amrIF2Bytes array size
218 */
219/* ======================================================================= */
220#define NUM_IF2_BYTES_ARRAY 16
221
222/* ======================================================================= */
223/**
224 * @def    NBAMRDEC_DEBUGMEM   Turns memory leaks messaging on and off.
225 *         APP_DEBUGMEM must be defined in Test App in order to get
226 *         this functionality On.
227 */
228/* ======================================================================= */
229#undef NBAMRDEC_DEBUGMEM
230/*#define NBAMRDEC_DEBUGMEM*/
231
232
233/*#define AMRDEC_DEBUG*/
234#undef AMRDEC_DEBUG
235#undef AMRDEC_MEMCHECK
236
237
238#ifndef UNDER_CE
239
240#define AMRDEC_EPRINT(...)  __android_log_print(ANDROID_LOG_VERBOSE, __FILE__,"%s %d:: ERROR    ",__FUNCTION__, __LINE__);\
241                                    __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, __VA_ARGS__);\
242                                    __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, "\n");
243
244#ifdef  AMRDEC_DEBUG
245        #define AMRDEC_DPRINT(...)    __android_log_print(ANDROID_LOG_VERBOSE, __FILE__,"%s %d::    ",__FUNCTION__, __LINE__);\
246                                    __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, __VA_ARGS__);\
247                                    __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, "\n");
248#else
249        #define AMRDEC_DPRINT(...)
250#endif
251
252#ifdef  AMRDEC_MEMCHECK
253        #define AMRDEC_MEMPRINT(...)    fprintf(stderr,__VA_ARGS__)
254#else
255        #define AMRDEC_MEMPRINT(...)
256#endif
257
258
259#ifdef  AMRDEC_DEBUG_MCP
260        #define AMRDEC_MCP_DPRINT(...)    __android_log_print(ANDROID_LOG_VERBOSE, __FILE__,"%s %d:: MCP    ",__FUNCTION__, __LINE__);\
261                                    __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, __VA_ARGS__);\
262                                    __android_log_print(ANDROID_LOG_VERBOSE, __FILE__, "\n");
263#else
264        #define AMRDEC_MCP_DPRINT(...)
265#endif
266#else /*UNDER_CE*/
267#define AMRDEC_EPRINT   printf
268#ifdef  AMRDEC_DEBUG
269 #define AMRDEC_DPRINT(STR, ARG...) printf()
270#else
271#endif
272
273#ifdef AMRDEC_MEMCHECK
274    #define AMRDEC_MEMPRINT(STR, ARG...) printf()
275#else
276#endif
277#ifdef UNDER_CE
278
279#ifdef DEBUG
280    #define AMRDEC_DPRINT   printf
281    #define AMRDEC_MEMPRINT   printf
282
283#else
284    #define AMRDEC_DPRINT
285    #define AMRDEC_MEMPRINT
286#endif
287
288#endif  //UNDER_CE
289
290#endif
291
292
293/* ======================================================================= */
294/**
295  * @def  CACHE_ALIGNMENT                           Buffer Cache Alignment
296 */
297/* ======================================================================= */
298#define CACHE_ALIGNMENT 128
299
300/* ======================================================================= */
301/**
302 * @def    NUM_OF_PORTS                       Number of Comunication Port
303 */
304/* ======================================================================= */
305#define NUM_OF_PORTS 2
306
307/* ======================================================================= */
308/**
309 * @def    _ERROR_PROPAGATION__              Allow Logic to Detec Arm Errors
310 */
311/* ======================================================================= */
312#define _ERROR_PROPAGATION__
313
314/* ======================================================================= */
315/**
316* pthread variable to indicate OMX returned all buffers to app
317*/
318/* ======================================================================= */
319pthread_mutex_t bufferReturned_mutex;
320pthread_cond_t bufferReturned_condition;
321
322/* ======================================================================= */
323/** NBAMRDEC_COMP_PORT_TYPE  Port Type
324*
325*  @param  NBAMRDEC_INPUT_PORT                  Port Type Input
326*
327*  @param  NBAMRDEC_OUTPUT_PORT                 Port Type Output
328*
329*/
330/*  ==================================================================== */
331typedef enum NBAMRDEC_COMP_PORT_TYPE {
332    NBAMRDEC_INPUT_PORT = 0,
333    NBAMRDEC_OUTPUT_PORT
334}NBAMRDEC_COMP_PORT_TYPE;
335
336/* ======================================================================= */
337/** NBAMRDEC_StreamType  StreamType
338*
339*  @param  NBAMRDEC_DMM                 Stream Type DMM
340*
341*  @param  NBAMRDEC_INSTRM              Stream Type Input
342*
343*  @param  NBAMRDEC_OUTSTRM             Stream Type Output
344*/
345/*  ==================================================================== */
346enum NBAMRDEC_StreamType
347{
348    NBAMRDEC_DMM,
349    NBAMRDEC_INSTRM,
350    NBAMRDEC_OUTSTRM
351};
352
353/* ======================================================================= */
354/** NBAMRDEC_DecodeType  Decode Type Mode
355*
356*  @param  NBAMR                    OMX_AUDIO_AMRDTX
357*
358*  @param  NBAMRDEC_EFR             OMX_AUDIO_AMRDTX as EFR
359*/
360/*  ==================================================================== */
361enum NBAMRDEC_DecodeType
362{
363    NBAMR,
364    NBAMRDEC_EFR
365};
366
367/* ======================================================================= */
368/** NBAMRDEC_MimeMode  Mime Mode
369*
370*  @param  NBAMRDEC_FORMATCONFORMANCE       Mime Mode and IF2 Off
371*
372*  @param  NBAMRDEC_MIMEMODE                Mime Mode On
373*/
374/*  ==================================================================== */
375enum NBAMRDEC_MimeMode {
376    NBAMRDEC_FORMATCONFORMANCE,
377    NBAMRDEC_MIMEMODE,
378        NBAMRDEC_IF2,
379        NBAMRDEC_PADMIMEMODE
380};
381
382/* ======================================================================= */
383/** NBAMRDEC_BUFFER_Dir  Direction of the Buffer
384*
385*  @param  NBAMRDEC_DIRECTION_INPUT             Direction Input
386*
387*  @param  NBAMRDEC_DIRECTION_INPUT             Direction Output
388*/
389/*  ==================================================================== */
390typedef enum {
391    NBAMRDEC_DIRECTION_INPUT,
392    NBAMRDEC_DIRECTION_OUTPUT
393}NBAMRDEC_BUFFER_Dir;
394
395/* =================================================================================== */
396/**
397*  Buffer Information.
398*/
399/* ================================================================================== */
400typedef struct BUFFS
401{
402    OMX_S8 BufHeader;
403    OMX_S8 Buffer;
404}BUFFS;
405
406/* =================================================================================== */
407/**
408* NBAMR Buffer Header Type Info.
409*/
410/* ================================================================================== */
411typedef struct BUFFERHEADERTYPE_INFO
412{
413    OMX_BUFFERHEADERTYPE* pBufHeader[MAX_NUM_OF_BUFS];
414    BUFFS bBufOwner[MAX_NUM_OF_BUFS];
415}BUFFERHEADERTYPE_INFO;
416
417/* ======================================================================= */
418/** LCML_MimeMode  modes
419*
420*  @param  MODE_MIME                    Mode MIME
421*
422*  @param  MODE_NONMIME                 Mode NONMIME
423*/
424/*  ==================================================================== */
425typedef enum {
426    MODE_MIME,
427    MODE_NONMIME
428}LCML_MimeMode;
429
430/* =================================================================================== */
431/**
432* Socket node input parameters.
433*/
434/* ================================================================================== */
435typedef struct AMRDEC_AudioCodecParams
436{
437    unsigned long iSamplingRate;
438    unsigned long iStrmId;
439    unsigned short iAudioFormat;
440}AMRDEC_AudioCodecParams;
441
442/* =================================================================================== */
443/**
444* Socket node alg parameters..
445*/
446/* ================================================================================== */
447/*typedef struct {
448
449        unsigned long usEndOfFile;
450        unsigned long usFrameLost;
451}AMRDEC_UAlgInBufParamStruct;*/
452
453typedef struct {
454        unsigned long int usLastFrame;
455        unsigned long int usFrameLost;
456}NBAMRDEC_FrameStruct;
457
458typedef struct{
459         unsigned long int usNbFrames;
460         NBAMRDEC_FrameStruct *pParamElem;
461}NBAMRDEC_ParamStruct;
462
463/* =================================================================================== */
464/**
465* LCML_NBAMRDEC_BUFHEADERTYPE
466*/
467/* ================================================================================== */
468typedef struct LCML_NBAMRDEC_BUFHEADERTYPE {
469      NBAMRDEC_BUFFER_Dir  eDir;
470      OMX_BUFFERHEADERTYPE* buffer;
471      NBAMRDEC_FrameStruct *pFrameParam;
472      NBAMRDEC_ParamStruct *pBufferParam;
473      DMM_BUFFER_OBJ* pDmmBuf;
474}LCML_NBAMRDEC_BUFHEADERTYPE;
475
476#ifndef UNDER_CE
477
478OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
479
480#else
481/* =================================================================================== */
482/**
483*   OMX_EXPORT                                           WinCE Implicit Export Syntax
484*/
485/* ================================================================================== */
486#define OMX_EXPORT __declspec(dllexport)
487
488OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
489
490#endif
491
492OMX_ERRORTYPE NBAMRDEC_StartComponentThread(OMX_HANDLETYPE pHandle);
493OMX_ERRORTYPE NBAMRDEC_StopComponentThread(OMX_HANDLETYPE pHandle);
494OMX_ERRORTYPE NBAMRDEC_FreeCompResources(OMX_HANDLETYPE pComponent);
495
496/* =================================================================================== */
497/**
498* Instrumentation info
499*/
500/* ================================================================================== */
501
502typedef struct _NBAMRDEC_BUFFERLIST NBAMRDEC_BUFFERLIST;
503
504/* =================================================================================== */
505/**
506* Structure for buffer list
507*/
508/* ================================================================================== */
509struct _NBAMRDEC_BUFFERLIST{
510    OMX_BUFFERHEADERTYPE *pBufHdr[MAX_NUM_OF_BUFS]; /* records buffer header send by client */
511    OMX_U32 bufferOwner[MAX_NUM_OF_BUFS];
512    OMX_U32 bBufferPending[MAX_NUM_OF_BUFS];
513    OMX_U16 numBuffers;
514};
515
516#ifdef UNDER_CE
517    #ifndef _OMX_EVENT_
518        #define _OMX_EVENT_
519        typedef struct OMX_Event {
520            HANDLE event;
521        } OMX_Event;
522    #endif
523#endif
524
525typedef struct PV_OMXComponentCapabilityFlagsType
526{
527        ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS (for opencore compatability)
528        OMX_BOOL iIsOMXComponentMultiThreaded;
529        OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc;
530        OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc;
531        OMX_BOOL iOMXComponentSupportsMovableInputBuffers;
532        OMX_BOOL iOMXComponentSupportsPartialFrames;
533        OMX_BOOL iOMXComponentNeedsNALStartCode;
534        OMX_BOOL iOMXComponentCanHandleIncompleteFrames;
535} PV_OMXComponentCapabilityFlagsType;
536
537/* =================================================================================== */
538/*
539 * NBAMRDEC_BUFDATA
540 */
541/* =================================================================================== */
542typedef struct NBAMRDEC_BUFDATA {
543   OMX_U8 nFrames;
544}NBAMRDEC_BUFDATA;
545
546/* =================================================================================== */
547/**
548* Component private data
549*/
550/* ================================================================================== */
551typedef struct AMRDEC_COMPONENT_PRIVATE
552{
553    /** Array of pointers to BUFFERHEADERTYPE structues
554       This pBufHeader[NBAMRDEC_INPUT_PORT] will point to all the
555       BUFFERHEADERTYPE structures related to input port,
556       not just one structure. Same is for output port
557       also. */
558
559#ifdef __PERF_INSTRUMENTATION__
560    PERF_OBJHANDLE pPERF, pPERFcomp;
561    OMX_U32 nLcml_nCntIp;
562    OMX_U32 nLcml_nCntOpReceived;
563#endif
564
565    OMX_BUFFERHEADERTYPE* pBufHeader[NUM_OF_PORTS];
566
567    BUFFERHEADERTYPE_INFO BufInfo[NUM_OF_PORTS];
568
569    /** Structure of callback pointers */
570    OMX_CALLBACKTYPE cbInfo;
571
572    /** Handle for use with async callbacks */
573    OMX_PORT_PARAM_TYPE sPortParam;
574
575    /** Input port parameters */
576    OMX_AUDIO_PARAM_PORTFORMATTYPE sInPortFormat;
577
578    /** Output port parameters */
579    OMX_AUDIO_PARAM_PORTFORMATTYPE sOutPortFormat;
580
581    /** This will contain info like how many buffers
582        are there for input/output ports, their size etc, but not
583        BUFFERHEADERTYPE POINTERS. */
584    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[NUM_OF_PORTS];
585
586    /** NBAMR Component Parameters */
587    OMX_AUDIO_PARAM_AMRTYPE* amrParams[NUM_OF_PORTS]; /*amrParams[Output] = OMX_AUDIO_PARAM_PCMMODETYPE*/
588
589    /** This is component handle */
590    OMX_COMPONENTTYPE* pHandle;
591
592    /** Current state of this component */
593    OMX_STATETYPE curState;
594
595    /** The component thread handle */
596    pthread_t ComponentThread;
597
598    /** The pipes for sending buffers to the thread */
599    int dataPipe[2];
600
601    /** The pipes for sending buffers to the thread */
602    int cmdPipe[2];
603
604    /** The pipes for sending buffers to the thread */
605    int cmdDataPipe[2];
606
607    /** Set to indicate component is stopping */
608    OMX_U32 bIsStopping;
609
610    /** Count of number of buffers outstanding with bridge */
611    OMX_U32 lcml_nIpBuf;
612
613    /** Count of number of buffers outstanding with bridge */
614    OMX_U32 lcml_nOpBuf;
615
616    /** Number of Buffers In the Application*/
617    OMX_U32 app_nBuf;
618
619    /** LCML Number Input Buffer Received*/
620    OMX_U32 lcml_nCntIp;
621
622    /** LCML Number Output Buffer Received*/
623    OMX_U32 lcml_nCntOpReceived;
624
625    /** Num Reclaimed OutPut Buff    */
626    OMX_U32 num_Reclaimed_Op_Buff;
627
628    /** LCML Handle */
629    OMX_HANDLETYPE pLcmlHandle;
630
631    /** LCML Buffer Header */
632    LCML_NBAMRDEC_BUFHEADERTYPE *pLcmlBufHeader[2];
633
634    /** Flag for mime mode */
635    OMX_S16 iAmrMimeFlag;
636
637    /** Sampling Frequeny */
638    OMX_S16 iAmrSamplingFrequeny;
639
640    /** Number of channels */
641    OMX_U32 iAmrChannels;
642
643    /** Flag for Amr mode */
644    OMX_S16 iAmrMode;
645
646    /** Flag for DASF mode */
647    OMX_S16 dasfmode;
648
649    /** Flag for mime mode */
650    OMX_S16 mimemode;
651
652    /** Flag for ACDN mode */
653    OMX_S16 acdnmode;
654
655    /** Writing pipe Used for DSP_RENDERING_ON */
656    int fdwrite;
657
658    /** Reading pipe Used for DSP_RENDERING_ON */
659    int fdread;
660
661    /* ID stream ID*/
662    OMX_U32 streamID;
663
664    /* Flag for Port Defs Allocated*/
665    OMX_U32 bPortDefsAllocated;
666
667    /* Flag for Component Thread Started*/
668    OMX_U32 bCompThreadStarted;
669
670    /** Mark data */
671    OMX_PTR pMarkData;
672
673    /** Mark buffer */
674    OMX_MARKTYPE *pMarkBuf;
675
676    /** Mark target component */
677   OMX_HANDLETYPE hMarkTargetComponent;
678
679   /** Flag set when buffer should not be queued to the DSP */
680   OMX_U32 bBypassDSP;
681
682   /** Input buffer list */
683   NBAMRDEC_BUFFERLIST *pInputBufferList;
684
685   /** Output buffer list */
686   NBAMRDEC_BUFFERLIST *pOutputBufferList;
687
688   /** LCML stream attributes */
689   LCML_STRMATTR *strmAttr;
690
691   /** Component version */
692   OMX_U32 nVersion;
693
694   /** Play Complete Flag */
695   OMX_U32 bPlayCompleteFlag;
696
697   /** NBAMR Mime Bytes */
698   OMX_U32 amrMimeBytes[NUM_MIME_BYTES_ARRAY];
699
700   /**NBAMR IF2 Bytes**/
701   OMX_U32 amrIF2Bytes[NUM_IF2_BYTES_ARRAY];
702
703   /** Number of Bytes holding to be sent*/
704   OMX_U32 nHoldLength;
705
706   /** Pointer to the data holding to be sent*/
707   OMX_U8* pHoldBuffer;
708
709   /** Flag set when LCML handle is opened */
710   OMX_S16 bLcmlHandleOpened;
711
712   /** Keeps track of the number of nFillThisBufferCount() calls */
713   OMX_U32 nFillThisBufferCount;
714
715   /** Keeps track of the number of nFillBufferDoneCount() calls */
716    OMX_U32 nFillBufferDoneCount;
717
718   /** Keeps track of the number of nEmptyThisBufferCount() calls */
719    OMX_U32 nEmptyThisBufferCount;
720
721   /** Keeps track of the number of nEmptyBufferDoneCount() calls */
722    OMX_U32 nEmptyBufferDoneCount;
723
724   /** Parameters for the Audio Codec */
725   AMRDEC_AudioCodecParams *pParams;
726
727   /** Flag for Init Params Initialized */
728   OMX_U32 bInitParamsInitialized;
729
730   /** Flag for bIdleCommandPending */
731 /*  OMX_U32 bIdleCommandPending;  */
732
733   /** Array of Input Buffers that are pending to sent due State = Idle */
734   OMX_BUFFERHEADERTYPE *pInputBufHdrPending[MAX_NUM_OF_BUFS];
735
736   /** Number of Input Buffers that are pending to sent due State = Idle */
737   OMX_U32 nNumInputBufPending;
738
739   /** Array of Output Buffers that are pending to sent due State = Idle */
740   OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[MAX_NUM_OF_BUFS];
741
742   /** Number of Output Buffers that are pending to sent due State = Idle */
743   OMX_U32 nNumOutputBufPending;
744
745   /** Flag for bDisableCommandPending*/
746   OMX_U32 bDisableCommandPending;
747
748   OMX_U32 bEnableCommandPending;
749
750   /** Flag for bDisableCommandParam*/
751   OMX_U32 bDisableCommandParam;
752
753   OMX_U32 bEnableCommandParam;
754
755    /** Flag to set when socket node stop callback should not transition
756        component to OMX_StateIdle */
757    OMX_U32 bNoIdleOnStop;
758
759    /** Number of outstanding FillBufferDone() calls */
760    OMX_U32 nOutStandingFillDones;
761
762    /** Stop Codec Command Sent Flag*/
763    OMX_U8 bStopSent;
764
765    OMX_U32 nRuntimeInputBuffers;
766
767    OMX_U32 nRuntimeOutputBuffers;
768
769    /* Removing sleep() calls. Definition. */
770#ifndef UNDER_CE
771    pthread_mutex_t AlloBuf_mutex;
772    pthread_cond_t AlloBuf_threshold;
773    OMX_U8 AlloBuf_waitingsignal;
774
775    pthread_mutex_t codecStop_mutex;
776    pthread_cond_t codecStop_threshold;
777    OMX_U8 codecStop_waitingsignal;
778
779    pthread_mutex_t InLoaded_mutex;
780    pthread_cond_t InLoaded_threshold;
781    OMX_U8 InLoaded_readytoidle;
782
783    pthread_mutex_t InIdle_mutex;
784    pthread_cond_t InIdle_threshold;
785    OMX_U8 InIdle_goingtoloaded;
786
787    OMX_S8 nUnhandledFillThisBuffers;
788    OMX_S8 nUnhandledEmptyThisBuffers;
789    OMX_BOOL bFlushOutputPortCommandPending;
790    OMX_BOOL bFlushInputPortCommandPending;
791#else
792    OMX_Event AlloBuf_event;
793    OMX_U8 AlloBuf_waitingsignal;
794
795    OMX_Event InLoaded_event;
796    OMX_U8 InLoaded_readytoidle;
797
798    OMX_Event InIdle_event;
799    OMX_U8 InIdle_goingtoloaded;
800#endif
801    /* Removing sleep() calls. Definition. */
802
803    OMX_U8 PendingPausedBufs;
804    OMX_BUFFERHEADERTYPE *pOutputBufHdrPausedPending[MAX_NUM_OF_BUFS];
805
806    OMX_BUFFERHEADERTYPE *LastOutbuf;
807
808    OMX_BOOL bIsInvalidState;
809    OMX_STRING* sDeviceString;
810
811    void* ptrLibLCML;
812
813    /** Circular array to keep buffer timestamps */
814    OMX_S64 arrBufIndex[MAX_NUM_OF_BUFS];
815    /** Circular array to keep buffer nTickCounts */
816    OMX_S64 arrTickCount[MAX_NUM_OF_BUFS];
817    /** Index to arrBufIndex[], used for input buffer timestamps */
818    OMX_U8 IpBufindex;
819    /** Index to arrBufIndex[], used for output buffer timestamps */
820    OMX_U8 OpBufindex;
821
822    /** Flag to flush SN after EOS in order to process more buffers after EOS**/
823    OMX_U8 SendAfterEOS;
824
825    /** Flag to mark the first sent buffer**/
826    OMX_U8 first_buff;
827    /** First Time Stamp sent **/
828    OMX_TICKS first_TS;
829
830    /** Temporal time stamp **/
831    OMX_TICKS temp_TS;
832
833    OMX_BOOL bLoadedCommandPending;
834
835    OMX_PARAM_COMPONENTROLETYPE componentRole;
836
837    /** Pointer to port priority management structure */
838    OMX_PRIORITYMGMTTYPE* pPriorityMgmt;
839
840#ifdef RESOURCE_MANAGER_ENABLED
841    RMPROXY_CALLBACKTYPE rmproxyCallback;
842#endif
843
844    OMX_BOOL bPreempted;
845    OMX_BOOL bFrameLost;
846
847    /** Flag to mark RTSP**/
848    OMX_U8 using_rtsp;
849
850    PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags;
851
852    struct OMX_TI_Debug dbg;
853
854    /** Indicate when first output buffer received from DSP **/
855    OMX_U32 first_output_buf_rcv;
856
857} AMRDEC_COMPONENT_PRIVATE;
858
859typedef enum OMX_NBAMRDEC_INDEXAUDIOTYPE {
860        OMX_IndexCustomNbAmrDecModeEfrConfig = 0xFF000001,
861        OMX_IndexCustomNbAmrDecModeAmrConfig,
862        OMX_IndexCustomNbAmrDecModeAcdnConfig,
863        OMX_IndexCustomNbAmrDecModeDasfConfig,
864        OMX_IndexCustomNbAmrDecModeMimeConfig,
865        OMX_IndexCustomNbAmrDecHeaderInfoConfig,
866        OMX_IndexCustomNbAmrDecStreamIDConfig,
867        OMX_IndexCustomNbAmrDecDataPath,
868        OMX_IndexCustomNbAmrDecNextFrameLost,
869        OMX_IndexCustomDebug
870}OMX_NBAMRDEC_INDEXAUDIOTYPE;
871
872/*=======================================================================*/
873/*! @fn SignalIfAllBuffersAreReturned
874
875 * @brief Sends pthread signal to indicate OMX has returned all buffers to app
876
877 * @param  none
878
879 * @Return void
880
881 */
882/*=======================================================================*/
883void SignalIfAllBuffersAreReturned(AMRDEC_COMPONENT_PRIVATE *pComponentPrivate);
884
885#endif /* OMX_AMRDECODER_H */
886