3 * Copyright (C) Texas Instruments - http://www.ti.com/
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.
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.
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
21 /* =============================================================================
22 * Texas Instruments OMAP(TM) Platform Software
23 * (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
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 * ============================================================================ */
29 * @file OMX_AacDec_Utils.h
31 * This is an header file for an audio AAC decoder that is fully
32 * compliant with the OMX Audio specification.
33 * This the file is used internally by the component
36 * @path $(CSLPATH)\OMAPSW_MPU\linux\audio\src\openmax_il\aac_dec\inc\
40 /* --------------------------------------------------------------------------- */
41 #ifndef OMX_AACDEC_UTILS__H
42 #define OMX_AACDEC_UTILS__H
44 #include <OMX_Component.h>
45 #include <OMX_TI_Common.h>
46 #include <OMX_TI_Debug.h>
47 #include "LCML_DspCodec.h"
51 #ifdef RESOURCE_MANAGER_ENABLED
52 #include <ResourceManagerProxyAPI.h>
67 #ifdef __PERF_INSTRUMENTATION__
76 /* Log for Android system*/
78 #define LOG_TAG "OMX_AACDEC"
80 /* PV opencore capability custom parameter index */
81 #define PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX 0xFF7A347
84 #define OBJECTTYPE_LC 2
85 #define OBJECTTYPE_LTP 4
86 #define OBJECTTYPE_HE 5
87 #define OBJECTTYPE_HE2 29
89 #define EXIT_COMPONENT_THRD 10
92 /* ======================================================================= */
94 * @def AAC_DEC__XXX_VER Component version
96 /* ======================================================================= */
97 #define AACDEC_MAJOR_VER 1
98 #define AACDEC_MINOR_VER 1
99 /* ======================================================================= */
101 * @def NOT_USED_AACDEC Defines a value for "don't care" parameters
103 /* ======================================================================= */
104 #define NOT_USED_AACDEC 0
105 /* ======================================================================= */
107 * @def NORMAL_BUFFER_AACDEC Defines the flag value with all flags turned off
109 /* ======================================================================= */
110 #define NORMAL_BUFFER_AACDEC 0
111 /* ======================================================================= */
113 * @def OMX_AACDEC_DEFAULT_SEGMENT Default segment ID for the LCML
115 /* ======================================================================= */
116 #define OMX_AACDEC_DEFAULT_SEGMENT (0)
117 /* ======================================================================= */
119 * @def OMX_AACDEC_SN_TIMEOUT Timeout value for the socket node
121 /* ======================================================================= */
122 #define OMX_AACDEC_SN_TIMEOUT (-1)
123 /* ======================================================================= */
125 * @def OMX_AACDEC_SN_PRIORITY Priority for the socket node
127 /* ======================================================================= */
128 #define OMX_AACDEC_SN_PRIORITY (10)
129 /* ======================================================================= */
131 * @def OMX_AACDEC_NUM_DLLS number of DLL's
133 /* ======================================================================= */
134 #define OMX_AACDEC_NUM_DLLS (2)
136 #define AACDEC_BUFHEADER_VERSION 0x1
137 /* ======================================================================= */
139 ** Default timeout used to come out of blocking calls*
142 /* ======================================================================= */
143 #define AACD_TIMEOUT (1000) /* millisecs */
145 /* ======================================================================= */
150 /* ======================================================================= */
154 /* ======================================================================= */
156 * @def AACDEC_USN_DLL_NAME USN DLL name
158 /* ======================================================================= */
160 #define AACDEC_USN_DLL_NAME "\\windows\\usn.dll64P"
162 #define AACDEC_USN_DLL_NAME "usn.dll64P"
165 /* ======================================================================= */
167 * @def AACDEC_DLL_NAME AAC Dec Decoder socket node DLL name
169 /* ======================================================================= */
171 #define AACDEC_DLL_NAME "\\windows\\mpeg4aacdec_sn.dll64P"
173 #define AACDEC_DLL_NAME "mpeg4aacdec_sn.dll64P"
178 /* ======================================================================= */
180 * @def AACDEC_CPU_USAGE for Resource Mannager (MHZ)
182 /* ======================================================================= */
183 #define AACDEC_CPU_USAGE 50
186 /* ======================================================================= */
188 * @def AACDEC_SBR_CONTENT flag detection
190 /* ======================================================================= */
192 #define AACDEC_SBR_CONTENT 0x601
195 /* ======================================================================= */
197 * @def AACDEC_PS_CONTENT flag detection
199 /* ======================================================================= */
201 #define AACDEC_PS_CONTENT 0x602
204 /* ======================================================================= */
206 * @def AACDEC_DEBUG Debug print macro
208 /* ======================================================================= */
211 #define _ERROR_PROPAGATION__
215 /* ======================================================================= */
217 * @def DEBUG Memory print macro
219 /* ======================================================================= */
221 #define AACDEC_DPRINT printf
222 #define AACDEC_MEMPRINT printf
223 #define AACDEC_STATEPRINT printf
224 #define AACDEC_BUFPRINT printf
225 #define AACDEC_MEMPRINT printf
226 #define AACDEC_EPRINT printf
228 #define AACDEC_DPRINT
229 #define AACDEC_MEMPRINT
230 #define AACDEC_STATEPRINT
231 #define AACDEC_BUFPRINT
232 #define AACDEC_MEMPRINT
233 #define AACDEC_EPRINT
236 #else /* for Linux */
239 #define AACDEC_DPRINT printf
240 #undef AACDEC_BUFPRINT printf
241 #undef AACDEC_MEMPRINT printf
242 #define AACDEC_STATEPRINT printf
244 #define AACDEC_DPRINT(...)
247 #ifdef AACDEC_STATEDETAILS
248 #define AACDEC_STATEPRINT printf
250 #define AACDEC_STATEPRINT(...)
253 #ifdef AACDEC_BUFDETAILS
254 #define AACDEC_BUFPRINT printf
256 #define AACDEC_BUFPRINT(...)
259 #ifdef AACDEC_MEMDETAILS
260 #define AACDEC_MEMPRINT(...) fprintf(stdout, "%s %d:: ",__FUNCTION__, __LINE__); \
261 fprintf(stdout, __VA_ARGS__); \
262 fprintf(stdout, "\n");
264 #define AACDEC_MEMPRINT(...)
267 #define AACDEC_EPRINT LOGE
272 /* ======================================================================= */
274 * @def AACDEC_OMX_ERROR_EXIT Exit print and return macro
276 /* ======================================================================= */
277 #define AACDEC_OMX_ERROR_EXIT(_e_, _c_, _s_) \
279 OMXDBG_PRINT(stderr, ERROR, 4, 0, "\n**************** OMX ERROR ************************\n"); \
280 OMXDBG_PRINT(stderr, ERROR, 4, 0, "%d : Error Name: %s : Error Num = %x",__LINE__, _s_, _e_); \
281 OMXDBG_PRINT(stderr, ERROR, 4, 0, "\n**************** OMX ERROR ************************\n"); \
284 /* ======================================================================= */
286 * @def AACDEC_OMX_CONF_CHECK_CMD Command check Macro
288 /* ======================================================================= */
289 #define AACDEC_OMX_CONF_CHECK_CMD(_ptr1, _ptr2, _ptr3) \
291 if(!_ptr1 || !_ptr2 || !_ptr3){ \
292 eError = OMX_ErrorBadParameter; \
297 /* ======================================================================= */
299 * @def OMX_CONF_INIT_STRUCT Macro to Initialise the structure variables
301 /* ======================================================================= */
302 #define OMX_CONF_INIT_STRUCT(_s_, _name_) \
303 memset((_s_), 0x0, sizeof(_name_)); \
304 (_s_)->nSize = sizeof(_name_); \
305 (_s_)->nVersion.s.nVersionMajor = 1; \
306 (_s_)->nVersion.s.nVersionMinor = 1; \
307 (_s_)->nVersion.s.nRevision = 0x0; \
308 (_s_)->nVersion.s.nStep = 0x0
310 /* ======================================================================= */
312 * @def AACDEC_BUFDETAILS Turns buffer messaging on and off
314 /* ======================================================================= */
315 #undef AACDEC_BUFDETAILS
316 /* ======================================================================= */
318 * @def AACDEC_STATEDETAILS Turns state messaging on and off
320 /* ======================================================================= */
321 #undef AACDEC_STATEDETAILS
322 /* ======================================================================= */
324 * @def AACDEC_MEMDETAILS Turns memory messaging on and off
326 /* ======================================================================= */
327 #undef AACDEC_MEMDETAILS
329 #define AACDEC_OUTPUT_PORT 1
330 #define AACDEC_INPUT_PORT 0
331 #define AACDEC_APP_ID 100
332 #define MAX_NUM_OF_BUFS_AACDEC 15
333 #define PARAMETRIC_STEREO_AACDEC 1
334 #define NON_PARAMETRIC_STEREO_AACDEC 0
335 /* ======================================================================= */
337 * @def NUM_OF_PORTS_AACDEC Number of ports
339 /* ======================================================================= */
340 #define NUM_OF_PORTS_AACDEC 2
341 /* ======================================================================= */
343 * @def STREAM_COUNT_AACDEC Number of streams
345 /* ======================================================================= */
346 #define STREAM_COUNT_AACDEC 2
348 /** Default timeout used to come out of blocking calls*/
350 /* ======================================================================= */
352 * @def AACD_NUM_INPUT_BUFFERS Default number of input buffers
355 /* ======================================================================= */
356 #define AACD_NUM_INPUT_BUFFERS 4
357 /* ======================================================================= */
359 * @def AACD_NUM_OUTPUT_BUFFERS Default number of output buffers
362 /* ======================================================================= */
363 #define AACD_NUM_OUTPUT_BUFFERS 4
365 /* ======================================================================= */
367 * @def AACD_INPUT_BUFFER_SIZE Default input buffer size
370 /* ======================================================================= */
371 #define AACD_INPUT_BUFFER_SIZE 1536*4
372 /* ======================================================================= */
374 * @def AACD_OUTPUT_BUFFER_SIZE Default output buffer size
377 /* ======================================================================= */
378 #define AACD_OUTPUT_BUFFER_SIZE 8192*2
379 /* ======================================================================= */
381 * @def AACD_SAMPLING_FREQUENCY Sampling frequency
383 /* ======================================================================= */
384 #define AACD_SAMPLING_FREQUENCY 44100
386 /* ======================================================================= */
388 * @def AACDec macros for MONO,STEREO_INTERLEAVED,STEREO_NONINTERLEAVED
390 /* ======================================================================= */
391 /*#define AACD_STEREO_INTERLEAVED_STREAM 2
392 #define AACD_STEREO_NONINTERLEAVED_STREAM 3*/
393 /* ======================================================================= */
395 * @def AACDec macros for MONO,STEREO_INTERLEAVED,STEREO_NONINTERLEAVED
397 /* ======================================================================= */
398 /* Stream types supported*/
399 #define MONO_STREAM_AACDEC 1
400 #define STEREO_INTERLEAVED_STREAM_AACDEC 2
401 #define STEREO_NONINTERLEAVED_STREAM_AACDEC 3
403 /* ======================================================================= */
405 * pthread variable to indicate OMX returned all buffers to app
407 /* ======================================================================= */
408 pthread_mutex_t bufferReturned_mutex;
409 pthread_cond_t bufferReturned_condition;
413 * AAC Decoder Profile:0 - MAIN, 1 - LC, 2 - SSR, 3 - LTP.
421 /* ======================================================================= */
422 /** COMP_PORT_TYPE_AACDEC Port types
424 * @param INPUT_PORT_AACDEC Input port
426 * @param OUTPUT_PORT_AACDEC Output port
428 /* ==================================================================== */
429 /*This enum must not be changed. */
430 typedef enum COMP_PORT_TYPE_AACDEC {
431 INPUT_PORT_AACDEC = 0,
433 }COMP_PORT_TYPE_AACDEC;
434 /* ======================================================================= */
435 /** OMX_INDEXAUDIOTYPE_AACDEC Defines the custom configuration settings
438 * @param OMX_IndexCustomMode16_24bit_AACDEC Sets the 16/24 mode
440 * @param OMX_IndexCustomModeProfile_AACDEC Sets the Profile mode
442 * @param OMX_IndexCustomModeSBR_AACDEC Sets the SBR mode
444 * @param OMX_IndexCustomModeDasfConfig_AACDEC Sets the DASF mode
446 * @param OMX_IndexCustomModeRAW_AACDEC Sets the RAW mode
448 * @param OMX_IndexCustomModePS_AACDEC Sets the ParametricStereo mode
451 /* ==================================================================== */
452 typedef enum OMX_INDEXAUDIOTYPE_AACDEC {
453 OMX_IndexCustomAacDecHeaderInfoConfig = 0xFF000001,
454 OMX_IndexCustomAacDecStreamIDConfig,
455 OMX_IndexCustomAacDecDataPath,
457 }OMX_INDEXAUDIOTYPE_AACDEC;
459 /* ======================================================================= */
460 /** IAUDIO_PcmFormat: This value is used by DSP.
462 * @param IAUDIO_BLOCK: It is used in DASF mode.
464 * @param IAUDIO_INTERLEAVED: It specifies interleaved format of SN.
466 /* ==================================================================== */
472 /* ======================================================================= */
473 /** IAUDIO_PcmFormat: This value is used by DSP.
475 * @param IAUDIO_BLOCK: It is used in DASF mode.
477 * @param IAUDIO_INTERLEAVED: It specifies interleaved format of SN.
479 /* ==================================================================== */
484 /* ======================================================================= */
485 /** MPEG4AACDEC_UALGParams
487 * @param lOutputFormat - To set interleaved/Block format:Refer to IAUDIO_AacFormat.
488 * @param DownSampleSbr -
490 /* ==================================================================== */
496 long lSamplingRateIdx;
499 } MPEG4AACDEC_UALGParams;
501 /* ======================================================================= */
502 /** IUALG_Cmd_AAC_DEC: This enum type describes the standard set of commands that
503 * will be passed to iualg control API at DSP. This enum is taken as it is from
504 * DSP side USN source code.
506 * @param IUALG_CMD_STOP: This command indicates that higher layer framework
507 * has received a stop command and no more process API will be called for the
508 * current data stream. The iualg layer is expected to ensure that all processed
509 * output as is put in the output IUALG_Buf buffers and the state of all buffers
510 * changed as to free or DISPATCH after this function call.
512 * @param IUALG_CMD_PAUSE: This command indicates that higher layer framework
513 * has received a PAUSE command on the current data stream. The iualg layer
514 * can change the state of some of its output IUALG_Bufs to DISPATCH to enable
515 * high level framework to use the processed data until the command was received.
517 * @param IUALG_CMD_GETSTATUS: This command indicates that some algo specific
518 * status needs to be returned to the framework. The pointer to the status
519 * structure will be in IALG_status * variable passed to the control API.
520 * The interpretation of the content of this pointer is left to IUALG layer.
522 * @param IUALG_CMD_SETSTATUS: This command indicates that some algo specific
523 * status needs to be set. The pointer to the status structure will be in
524 * IALG_status * variable passed to the control API. The interpretation of the
525 * content of this pointer is left to IUALG layer.
527 * @param IUALG_CMD_USERCMDSTART: The algorithm specific control commands can
528 * have the enum type set from this number.
530 /* ==================================================================== */
535 IUALG_CMD_GETSTATUS = 2,
536 IUALG_CMD_SETSTATUS = 3,
537 IUALG_CMD_USERCMDSTART_AACDEC = 100
543 typedef struct OMX_Event {
547 int OMX_CreateEvent(OMX_Event *event);
548 int OMX_SignalEvent(OMX_Event *event);
549 int OMX_WaitForEvent(OMX_Event *event);
550 int OMX_DestroyEvent(OMX_Event *event);
553 /* ======================================================================= */
554 /** IUALG_PCMDCmd: This enum specifies the command to DSP.
556 * @param IULAG_CMD_SETSTREAMTYPE: Specifies the stream type to be sent to DSP.
558 /* ==================================================================== */
560 IULAG_CMD_SETSTREAMTYPE = IUALG_CMD_USERCMDSTART_AACDEC
563 /* ======================================================================= */
564 /** AACDEC_UAlgInBufParamStruct: This struct is passed with input buffers that
567 /* ==================================================================== */
569 /* Set to 1 if buffer is last buffer */
570 unsigned short bLastBuffer;
571 unsigned short bConcealBuffer;
572 }AACDEC_UAlgInBufParamStruct;
574 /* ======================================================================= */
575 /** USN_AudioCodecParams: This contains the information which does to Codec
579 /* ==================================================================== */
580 typedef struct USN_AudioCodecParams{
581 /* Specifies the sample frequency */
582 unsigned long ulSamplingFreq;
583 /* Specifies the UUID */
584 unsigned long unUUID;
585 /* Specifies the audio format */
586 unsigned short unAudioFormat;
587 }USN_AudioCodecParams;
589 /* ======================================================================= */
590 /** AACDEC_UAlgOutBufParamStruct: This is passed with output buffer to DSP.
592 /* ==================================================================== */
594 unsigned long ulFrameCount;
595 unsigned long isLastBuffer;
596 }AACDEC_UAlgOutBufParamStruct;
598 typedef struct AACDEC_UALGParams{
599 unsigned long lOutputFormat;
600 unsigned long lMonoToStereoCopy;
603 /* ======================================================================= */
604 /** AACD_LCML_BUFHEADERTYPE: This is LCML buffer header which is sent to LCML
605 * for both input and output buffers.
607 /* ==================================================================== */
608 typedef struct AACD_LCML_BUFHEADERTYPE {
609 /* Direction whether input or output buffer */
611 /* Pointer to OMX Buffer Header */
612 OMX_BUFFERHEADERTYPE *pBufHdr;
613 /* Other parameters, may be useful for enhancements */
614 void *pOtherParams[10];
615 /* Input Parameter Information structure */
616 AACDEC_UAlgInBufParamStruct *pIpParam;
617 /* Output Parameter Information structure */
618 AACDEC_UAlgOutBufParamStruct *pOpParam;
619 }AACD_LCML_BUFHEADERTYPE;
621 /* Component Port Context */
622 typedef struct AUDIODEC_PORT_TYPE {
623 /* Used in tunneling, this is handle of tunneled component */
624 OMX_HANDLETYPE hTunnelComponent;
625 /* Port which has to be tunneled */
627 /* Buffer Supplier Information */
628 OMX_BUFFERSUPPLIERTYPE eSupplierSetting;
629 /* Number of buffers */
631 /* Port format information */
632 OMX_AUDIO_PARAM_PORTFORMATTYPE* pPortFormat;
633 } AUDIODEC_PORT_TYPE;
636 /* ======================================================================= */
637 /** AAC_DEC_BUFFERLIST: This contains information about a buffer's owner whether
638 * it is application or component, number of buffers owned etc.
640 * @see OMX_BUFFERHEADERTYPE
642 /* ==================================================================== */
643 struct AAC_DEC_BUFFERLIST{
644 /* Array of pointer to OMX buffer headers */
645 OMX_BUFFERHEADERTYPE *pBufHdr[MAX_NUM_OF_BUFS_AACDEC];
646 /* Array that tells about owner of each buffer */
647 OMX_U32 bufferOwner[MAX_NUM_OF_BUFS_AACDEC];
648 /* Tracks pending buffers */
649 OMX_U32 bBufferPending[MAX_NUM_OF_BUFS_AACDEC];
650 /* Number of buffers */
654 typedef struct AAC_DEC_BUFFERLIST AACDEC_BUFFERLIST;
656 typedef struct PV_OMXComponentCapabilityFlagsType
658 ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS (for opencore compatability)
659 OMX_BOOL iIsOMXComponentMultiThreaded;
660 OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc;
661 OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc;
662 OMX_BOOL iOMXComponentSupportsMovableInputBuffers;
663 OMX_BOOL iOMXComponentSupportsPartialFrames;
664 OMX_BOOL iOMXComponentNeedsNALStartCode;
665 OMX_BOOL iOMXComponentCanHandleIncompleteFrames;
666 } PV_OMXComponentCapabilityFlagsType;
668 /* ======================================================================= */
669 /** AACDEC_COMPONENT_PRIVATE: This is the major and main structure of the
670 * component which contains all type of information of buffers, ports etc
671 * contained in the component.
673 * @see OMX_BUFFERHEADERTYPE
674 * @see OMX_AUDIO_PARAM_PORTFORMATTYPE
675 * @see OMX_PARAM_PORTDEFINITIONTYPE
676 * @see AACD_LCML_BUFHEADERTYPE
677 * @see OMX_PORT_PARAM_TYPE
678 * @see OMX_PRIORITYMGMTTYPE
679 * @see AUDIODEC_PORT_TYPE
680 * @see AACDEC_BUFFERLIST
684 /* ==================================================================== */
686 typedef struct AACDEC_COMPONENT_PRIVATE
689 OMX_CALLBACKTYPE cbInfo;
690 /** Handle for use with async callbacks */
691 OMX_PORT_PARAM_TYPE* sPortParam;
692 /* Input port information */
693 OMX_AUDIO_PARAM_PORTFORMATTYPE sInPortFormat;
694 /* Output port information */
695 OMX_AUDIO_PARAM_PORTFORMATTYPE sOutPortFormat;
696 /* Buffer owner information */
697 OMX_U32 bIsBufferOwned[NUM_OF_PORTS_AACDEC];
699 /** This will contain info like how many buffers
700 are there for input/output ports, their size etc, but not
701 BUFFERHEADERTYPE POINTERS. */
702 OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[NUM_OF_PORTS_AACDEC];
703 /* Contains information that come from application */
704 OMX_AUDIO_PARAM_AACPROFILETYPE* aacParams;
706 OMX_AUDIO_PARAM_PCMMODETYPE* pcmParams;
708 /** This is component handle */
709 OMX_COMPONENTTYPE* pHandle;
711 /** Current state of this component */
712 OMX_STATETYPE curState;
714 /** The component thread handle */
715 pthread_t ComponentThread;
717 /** The pipes for sending buffers to the thread */
720 /** The pipes for sending buffers to the thread */
723 /** The pipes for sending command data to the thread */
726 /** Set to indicate component is stopping */
729 /** Count of number of buffers outstanding with bridge */
732 /** Count of number of buffers outstanding with bridge */
735 /** Counts of number of input buffers sent to LCML */
737 /** Counts of number of input buffers received from LCML */
738 OMX_U32 lcml_nCntIpRes;
739 /** Counts of number of output buffers sent to LCML */
741 /** Counts of number of output buffers received from LCML */
742 OMX_U32 lcml_nCntOpReceived;
743 /** Counts of number of buffers sent to App */
744 OMX_U32 lcml_nCntApp;
745 /** Counts of number of buffers received from App */
749 /** Counts of number of output buffers reclaimed from lcml */
750 OMX_U32 num_Reclaimed_Op_Buff;
751 /** Counts of number of input buffers sent to lcml */
752 OMX_U32 num_Sent_Ip_Buff;
753 /** Counts of number of output buffers sent to lcml */
754 OMX_U32 num_Op_Issued;
755 /** Holds the value of dasf mode, 1: DASF mode or 0: File Mode */
758 /** This is LCML handle */
759 OMX_HANDLETYPE pLcmlHandle;
763 /** Contains pointers to LCML Buffer Headers */
764 AACD_LCML_BUFHEADERTYPE *pLcmlBufHeader[2];
766 #ifdef __PERF_INSTRUMENTATION__
767 PERF_OBJHANDLE pPERF, pPERFcomp;
768 OMX_U32 nLcml_nCntIp;
769 OMX_U32 nLcml_nCntOpReceived;
772 /** Tells whether buffers on ports have been allocated */
773 OMX_U32 bPortDefsAllocated;
774 /** Tells whether component thread has started */
775 OMX_U32 bCompThreadStarted;
776 /** Marks the buffer data */
778 /** Marks the buffer */
779 OMX_MARKTYPE *pMarkBuf;
780 /** Marks the target component */
781 OMX_HANDLETYPE hMarkTargetComponent;
782 /** Flag to track when input buffer's filled length is 0 */
784 /** Input port enable flag */
785 OMX_U32 ipPortEnableFlag;
786 /** Input port disble flag */
787 OMX_U32 ipPortDisableFlag;
788 /** Pointer to port parameter structure */
789 OMX_PORT_PARAM_TYPE* pPortParamType;
790 /** Pointer to port priority management structure */
791 OMX_PRIORITYMGMTTYPE* pPriorityMgmt;
793 #ifdef RESOURCE_MANAGER_ENABLED
794 RMPROXY_CALLBACKTYPE rmproxyCallback;
800 /** Contains the port related info of both the ports */
801 AUDIODEC_PORT_TYPE *pCompPort[NUM_OF_PORTS_AACDEC];
802 /* Checks whether or not buffer were allocated by appliction */
804 /** Flag to check about execution of component thread */
805 OMX_U16 bExitCompThrd;
806 /** Pointer to list of input buffers */
807 AACDEC_BUFFERLIST *pInputBufferList;
808 /** Pointer to list of output buffers */
809 AACDEC_BUFFERLIST *pOutputBufferList;
810 /** it is used for component's create phase arguments */
811 LCML_STRMATTR *strmAttr;
812 /** Contains the version information */
815 /** Number of input buffers at runtime */
816 OMX_U32 nRuntimeInputBuffers;
818 /** Number of output buffers at runtime */
819 OMX_U32 nRuntimeOutputBuffers;
821 /** Parameters being passed to the SN */
822 USN_AudioCodecParams *pParams;
824 /** Dynamic Parameters being passed to the SN */
825 MPEG4AACDEC_UALGParams * AACDEC_UALGParam;
829 OMX_STRING cComponentName;
831 OMX_VERSIONTYPE ComponentVersion;
834 OMX_U32 parameteric_stereo;
835 OMX_U32 dualMonoMode;
838 OMX_U32 nFillThisBufferCount;
839 OMX_U32 nFillBufferDoneCount;
840 OMX_U32 nEmptyThisBufferCount;
841 OMX_U32 nEmptyBufferDoneCount;
842 OMX_U32 bInitParamsInitialized;
843 AACDEC_BUFFERLIST *pInputBufferListQueue;
844 AACDEC_BUFFERLIST *pOutputBufferListQueue;
845 /** To store input buffers recieved while in paused state **/
846 OMX_BUFFERHEADERTYPE *pInputBufHdrPending[MAX_NUM_OF_BUFS_AACDEC];
847 OMX_U32 nNumInputBufPending;
849 /** To store out buffers received while in puased state **/
850 OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[MAX_NUM_OF_BUFS_AACDEC];
851 OMX_U32 nNumOutputBufPending;
853 /** Flags to control port disable command **/
854 OMX_U32 bDisableCommandPending;
855 OMX_U32 bDisableCommandParam;
856 /** Flags to control port enable command **/
857 OMX_U32 bEnableCommandPending;
858 OMX_U32 bEnableCommandParam;
860 OMX_U32 nInvalidFrameCount;
861 OMX_U32 numPendingBuffers;
862 OMX_U32 bNoIdleOnStop;
863 OMX_U32 bDspStoppedWhileExecuting;
864 /* bIdleCommandPending;*/
865 OMX_S32 nOutStandingFillDones;
866 OMX_BOOL bIsInvalidState;
867 OMX_STRING* sDeviceString;
869 pthread_mutex_t AlloBuf_mutex;
870 pthread_cond_t AlloBuf_threshold;
871 OMX_U8 AlloBuf_waitingsignal;
873 pthread_mutex_t InLoaded_mutex;
874 pthread_cond_t InLoaded_threshold;
875 OMX_U8 InLoaded_readytoidle;
877 pthread_mutex_t InIdle_mutex;
878 pthread_cond_t InIdle_threshold;
879 OMX_U8 InIdle_goingtoloaded;
881 pthread_mutex_t codecStop_mutex;
882 pthread_cond_t codecStop_threshold;
883 OMX_U8 codecStop_waitingsignal;
885 pthread_mutex_t codecFlush_mutex;
886 pthread_cond_t codecFlush_threshold;
887 OMX_U8 codecFlush_waitingsignal;
889 OMX_U32 nUnhandledFillThisBuffers;
890 OMX_U32 nHandledFillThisBuffers;
891 OMX_U32 nUnhandledEmptyThisBuffers;
892 OMX_U32 nHandledEmptyThisBuffers;
893 OMX_BOOL bFlushOutputPortCommandPending;
894 OMX_BOOL bFlushInputPortCommandPending;
896 OMX_Event AlloBuf_event;
897 OMX_U8 AlloBuf_waitingsignal;
899 OMX_Event InLoaded_event;
900 OMX_U8 InLoaded_readytoidle;
902 OMX_Event InIdle_event;
903 OMX_U8 InIdle_goingtoloaded;
906 OMX_BOOL bLoadedCommandPending;
907 OMX_PARAM_COMPONENTROLETYPE *componentRole;
909 OMX_U8 PendingInPausedBufs;
910 OMX_BUFFERHEADERTYPE *pInBufHdrPausedPending[MAX_NUM_OF_BUFS_AACDEC];
911 OMX_U8 PendingOutPausedBufs;
912 OMX_BUFFERHEADERTYPE *pOutBufHdrPausedPending[MAX_NUM_OF_BUFS_AACDEC];
914 /** Keep buffer timestamps **/
915 OMX_S64 arrBufIndex[MAX_NUM_OF_BUFS_AACDEC];
916 /**Keep buffer tickcount*/
917 OMX_U32 arrBufIndexTick[MAX_NUM_OF_BUFS_AACDEC];
919 /** Index to arrBufIndex[] and arrBufIndexTick[], used for input buffer timestamps */
921 /** Index to arrBufIndex[] and arrBufIndexTick[], used for input buffer timestamps */
924 /** Flag to flush SN after EOS in order to process more buffers after EOS**/
927 /** Flag to mark the first sent buffer**/
929 /** First Time Stamp sent **/
931 /** Temporal time stamp **/
934 PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags;
935 OMX_BOOL bConfigData;
936 OMX_BOOL reconfigInputPort;
937 OMX_BOOL reconfigOutputPort;
940 struct OMX_TI_Debug dbg;
942 /** Indicate when first output buffer received from DSP **/
943 OMX_U32 first_output_buf_rcv;
945 } AACDEC_COMPONENT_PRIVATE;
947 /* ================================================================================= * */
949 * OMX_ComponentInit() function is called by OMX Core to initialize the component
950 * with default values of the component. Before calling this function OMX_Init
951 * must have been called.
953 * @param *hComp This is component handle allocated by the OMX core.
955 * @pre OMX_Init should be called by application.
957 * @post Component has initialzed with default values.
959 * @return OMX_ErrorNone = Successful Inirialization of the component\n
960 * OMX_ErrorInsufficientResources = Not enough memory
962 * @see AacDec_StartCompThread()
964 /* ================================================================================ * */
966 OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
968 /* WinCE Implicit Export Syntax */
969 #define OMX_EXPORT __declspec(dllexport)
970 /* =========================================================== */
972 * OMX_ComponentInit() Initializes component
975 * @param hComp OMX Handle
977 * @return OMX_ErrorNone = Successful
978 * Other error code = fail
981 /*================================================================== */
982 OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp);
985 /* ================================================================================= * */
987 * AacDec_StartCompThread() starts the component thread. This is internal
988 * function of the component.
990 * @param pHandle This is component handle allocated by the OMX core.
996 * @return OMX_ErrorNone = Successful Inirialization of the component\n
997 * OMX_ErrorInsufficientResources = Not enough memory
1001 /* ================================================================================ * */
1002 OMX_ERRORTYPE AacDec_StartCompThread(OMX_HANDLETYPE pHandle);
1003 /* ================================================================================= * */
1005 * AACDEC_Fill_LCMLInitParams() fills the LCML initialization structure.
1007 * @param pHandle This is component handle allocated by the OMX core.
1009 * @param plcml_Init This structure is filled and sent to LCML.
1015 * @return OMX_ErrorNone = Successful Inirialization of the LCML struct.
1016 * OMX_ErrorInsufficientResources = Not enough memory
1020 /* ================================================================================ * */
1021 OMX_ERRORTYPE AACDEC_Fill_LCMLInitParams(OMX_HANDLETYPE pHandle, LCML_DSP *plcml_Init, OMX_U16 arr[]);
1022 /* ================================================================================= * */
1024 * AACDEC_GetBufferDirection() function determines whether it is input buffer or
1027 * @param *pBufHeader This is pointer to buffer header whose direction needs to
1030 * @param *eDir This is output argument which stores the direction of buffer.
1036 * @return OMX_ErrorNone = Successful processing.
1037 * OMX_ErrorBadParameter = In case of invalid buffer
1041 /* ================================================================================ * */
1042 OMX_ERRORTYPE AACDEC_GetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader,
1044 /* ================================================================================= * */
1046 * AACDEC_LCML_Callback() function is callback which is called by LCML whenever
1047 * there is an even generated for the component.
1049 * @param event This is event that was generated.
1051 * @param arg This has other needed arguments supplied by LCML like handles
1058 * @return OMX_ErrorNone = Successful processing.
1059 * OMX_ErrorInsufficientResources = Not enough memory
1063 /* ================================================================================ * */
1064 OMX_ERRORTYPE AACDEC_LCML_Callback (TUsnCodecEvent event,void * args [10]);
1065 /* ================================================================================= * */
1067 * AACDEC_HandleCommand() function handles the command sent by the application.
1068 * All the state transitions, except from nothing to loaded state, of the
1069 * component are done by this function.
1071 * @param pComponentPrivate This is component's private date structure.
1077 * @return OMX_ErrorNone = Successful processing.
1078 * OMX_ErrorInsufficientResources = Not enough memory
1079 * OMX_ErrorHardware = Hardware error has occured lile LCML failed
1080 * to do any said operartion.
1084 /* ================================================================================ * */
1085 OMX_U32 AACDEC_HandleCommand (AACDEC_COMPONENT_PRIVATE *pComponentPrivate);
1086 /* ================================================================================= * */
1088 * AACDEC_HandleDataBuf_FromApp() function handles the input and output buffers
1089 * that come from the application. It is not direct function wich gets called by
1090 * the application rather, it gets called eventually.
1092 * @param *pBufHeader This is the buffer header that needs to be processed.
1094 * @param *pComponentPrivate This is component's private date structure.
1100 * @return OMX_ErrorNone = Successful processing.
1101 * OMX_ErrorInsufficientResources = Not enough memory
1102 * OMX_ErrorHardware = Hardware error has occured lile LCML failed
1103 * to do any said operartion.
1107 /* ================================================================================ * */
1108 OMX_ERRORTYPE AACDEC_HandleDataBuf_FromApp(OMX_BUFFERHEADERTYPE *pBufHeader,
1109 AACDEC_COMPONENT_PRIVATE *pComponentPrivate);
1110 /* ================================================================================= * */
1112 * AACDEC_GetLCMLHandle() function gets the LCML handle and interacts with LCML
1113 * by using this LCML Handle.
1115 * @param *pBufHeader This is the buffer header that needs to be processed.
1117 * @param *pComponentPrivate This is component's private date structure.
1123 * @return OMX_HANDLETYPE = Successful loading of LCML library.
1124 * OMX_ErrorHardware = Hardware error has occured.
1128 /* ================================================================================ * */
1129 OMX_HANDLETYPE AACDEC_GetLCMLHandle(AACDEC_COMPONENT_PRIVATE* pComponentPrivate);
1130 /* ================================================================================= * */
1132 * AACDEC_GetCorresponding_LCMLHeader() function gets the corresponding LCML
1133 * header from the actual data buffer for required processing.
1135 * @param *pBuffer This is the data buffer pointer.
1137 * @param eDir This is direction of buffer. Input/Output.
1139 * @param *AACD_LCML_BUFHEADERTYPE This is pointer to LCML Buffer Header.
1145 * @return OMX_ErrorNone = Successful Inirialization of the component\n
1146 * OMX_ErrorHardware = Hardware error has occured.
1150 /* ================================================================================ * */
1151 OMX_ERRORTYPE AACDEC_GetCorresponding_LCMLHeader(AACDEC_COMPONENT_PRIVATE* pComponentPrivate,
1154 AACD_LCML_BUFHEADERTYPE **ppLcmlHdr);
1155 /* ================================================================================= * */
1157 * AACDEC_FreeCompResources() function frees the component resources.
1159 * @param pComponent This is the component handle.
1165 * @return OMX_ErrorNone = Successful Inirialization of the component\n
1166 * OMX_ErrorHardware = Hardware error has occured.
1170 /* ================================================================================ * */
1171 OMX_ERRORTYPE AACDEC_FreeCompResources(OMX_HANDLETYPE pComponent);
1172 /* ================================================================================= * */
1174 * AACDEC_CleanupInitParams() function frees only the initialization time
1175 * memories allocated. For example, it will not close pipes, it will not free the
1176 * memory allocated to the buffers etc. But it does free the memory of buffers
1177 * utilized by the LCML etc. It is basically subset of AACDEC_FreeCompResources()
1180 * @param pComponent This is the component handle.
1186 * @return OMX_ErrorNone = Successful Inirialization of the component\n
1190 /* ================================================================================ * */
1191 void AACDEC_CleanupInitParams(OMX_HANDLETYPE pComponent);
1192 /* ================================================================================= * */
1194 * AACDEC_CleanupInitParamsEx() function frees only the initialization time
1195 * memories allocated. For example, it will not close pipes, it will not free the
1196 * memory allocated to the buffers etc. But it does free the memory of buffers
1197 * utilized by the LCML etc. It is basically subset of AACDEC_FreeCompResources()
1198 * function. Called while port disable when port reconfiguration takes place.
1200 * @param pComponent This is the component handle.
1206 * @return OMX_ErrorNone = Successful Inirialization of the component\n
1210 /* ================================================================================ * */
1211 void AACDEC_CleanupInitParamsEx(OMX_HANDLETYPE pComponent,OMX_U32 indexport);
1212 /* =========================================================== */
1214 * AACDEC_SetPending() Called when the component queues a buffer
1217 * @param pComponentPrivate Component private data
1219 * @param pBufHdr Buffer header
1221 * @param eDir Direction of the buffer
1225 /*================================================================== */
1226 void AACDEC_SetPending(AACDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber);
1227 /* =========================================================== */
1229 * AACDEC_ClearPending() Called when a buffer is returned
1232 * @param pComponentPrivate Component private data
1234 * @param pBufHdr Buffer header
1236 * @param eDir Direction of the buffer
1240 /*================================================================== */
1241 void AACDEC_ClearPending(AACDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir, OMX_U32 lineNumber) ;
1242 /* =========================================================== */
1244 * AACDEC_IsPending()
1247 * @param pComponentPrivate Component private data
1249 * @return OMX_ErrorNone = Successful
1250 * Other error code = fail
1252 /*================================================================== */
1253 OMX_U32 AACDEC_IsPending(AACDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_BUFFERHEADERTYPE *pBufHdr, OMX_DIRTYPE eDir);
1254 /* =========================================================== */
1256 * AACDECFill_LCMLInitParamsEx() Fills the parameters needed
1257 * to initialize the LCML without recreating the socket node
1259 * @param pComponent OMX Handle
1264 /*================================================================== */
1265 OMX_ERRORTYPE AACDECFill_LCMLInitParamsEx(OMX_HANDLETYPE pComponent,OMX_U32 indexport);
1266 /* =========================================================== */
1271 * @param pComponentPrivate Component private data
1273 * @return OMX_ErrorNone = Successful
1274 * Other error code = fail
1276 /*================================================================== */
1277 OMX_U32 AACDEC_IsValid(AACDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U8 *pBuffer, OMX_DIRTYPE eDir) ;
1279 #ifdef RESOURCE_MANAGER_ENABLED
1280 void AACDEC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData);
1282 /*=======================================================================*/
1283 /*! @fn AACDec_GetSampleRateIndexL
1285 * @brief Gets the sample rate index
1287 * @param aRate : Actual Sampling Freq
1292 /*=======================================================================*/
1293 int AACDec_GetSampleRateIndexL( const int aRate);
1294 int AACDec_GetSampleRatebyIndex( const int index);
1295 void* AACDEC_ComponentThread (void* pThreadData);
1297 OMX_U32 AACDEC_ParseHeader(OMX_BUFFERHEADERTYPE* pBufHeader,
1298 AACDEC_COMPONENT_PRIVATE *pComponentPrivate);
1300 /* =========================================================================*/
1303 /* desc Gets aBits number of bits from position aPosition of one buffer */
1304 /* and returns the value in a TUint value. */
1305 /* =========================================================================*/
1306 OMX_U32 AACDEC_GetBits(OMX_U32* nPosition, OMX_U8 nBits, OMX_U8* pBuffer, OMX_BOOL bIcreasePosition);
1308 /* =========================================================================*/
1309 /* func AACDEC_HandleUSNError
1311 * desc Handles error messages returned by the dsp
1315 * =========================================================================*/
1316 void AACDEC_HandleUSNError (AACDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 arg);
1318 /*=======================================================================*/
1319 /*! @fn SignalIfAllBuffersAreReturned
1320 * @brief Sends pthread signal to indicate OMX has returned all buffers to app
1324 /*=======================================================================*/
1325 void SignalIfAllBuffersAreReturned(AACDEC_COMPONENT_PRIVATE *pComponentPrivate);