OMX_AmrEnc_Utils.h revision fb3766f18a2c18b6f4798a6a631fdb88fcacd1dc
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_AmrEnc_Utils.h 30* 31* This is an header file for an NBAMR Encoder that is fully 32* compliant with the OMX Audio specification 1.5. 33* This the file that the application that uses OMX would include in its code. 34* 35* @path $(CSLPATH)\OMAPSW_MPU\linux\audio\src\openmax_il\nbamr_enc\inc 36* 37* @rev 1.0 38*/ 39/* --------------------------------------------------------------------------- */ 40/* ---------------------------------------------------------------------------- 41*! 42*! Revision History 43*! =================================== 44*! 21-sept-2006 bk: updated review findings for alpha release 45*! 24-Aug-2006 bk: Khronos OpenMAX (TM) 1.0 Conformance tests some more 46*! 18-July-2006 bk: Khronos OpenMAX (TM) 1.0 Conformance tests validated for few cases 47*! 21-Jun-2006 bk: Khronos OpenMAX (TM) 1.0 migration done 48*! 22-May-2006 bk: DASF recording quality improved 49*! 19-Apr-2006 bk: DASF recording speed issue resloved 50*! 23-Feb-2006 bk: DASF functionality added 51*! 18-Jan-2006 bk: Repated recording issue fixed and LCML changes taken care 52*! 14-Dec-2005 bk: Initial Version 53*! 16-Nov-2005 bk: Initial Version 54*! 23-Sept-2005 bk: Initial Version 55*! 10-Sept-2005 bk: Initial Version 56*! 10-Sept-2005 bk: 57*! This is newest file 58* =========================================================================== */ 59#ifndef OMX_AMRENC_UTILS__H 60#define OMX_AMRENC_UTILS__H 61 62#include <pthread.h> 63#include "LCML_DspCodec.h" 64#include <OMX_Component.h> 65#include "OMX_TI_Common.h" 66#include <TIDspOmx.h> 67/* #include <ResourceManagerProxyAPI.h> */ 68 69#ifdef __PERF_INSTRUMENTATION__ 70 #include "perf.h" 71#endif 72 73#ifdef DSP_RENDERING_ON 74 #include <AudioManagerAPI.h> 75#endif 76 77#ifdef UNDER_CE 78 #define sleep Sleep 79#endif 80 81#ifndef ANDROID 82 #define ANDROID 83#endif 84 85#ifdef ANDROID 86 #include <utils/Log.h> 87 #undef LOG_TAG 88 #define LOG_TAG "nbamr_enc" 89#endif 90/* ======================================================================= */ 91/** 92 * @def AMRENC_DEBUG Turns debug messaging on and off 93 */ 94/* ======================================================================= */ 95//#define AMRENC_DEBUG 96/* ======================================================================= */ 97/** 98 * @def AMRENC_MEMCHECK Turns memory messaging on and off 99 */ 100/* ======================================================================= */ 101#undef AMRENC_MEMCHECK 102 103/* ======================================================================= */ 104/** 105 * @def NBAMRENC_DEBUGMEM Turns memory leaks messaging on and off. 106 * APP_DEBUGMEM must be defined in Test App in order to get 107 * this functionality On. 108 */ 109/* ======================================================================= */ 110#undef NBAMRENC_DEBUGMEM 111 112/* ======================================================================= */ 113/** 114 * @def AMRENC_EPRINT Error print macro 115 */ 116/* ======================================================================= */ 117#ifndef UNDER_CE 118 #ifdef ANDROID 119 #define AMRENC_EPRINT LOGE 120 #else 121 #define AMRENC_EPRINT(...) fprintf(stderr,__VA_ARGS__) 122 #endif 123#else 124 #define AMRENC_EPRINT 125#endif 126 127 128 129/* ======================================================================= */ 130/** 131 * @def AMRENC_DEBUG Debug print macro 132 */ 133/* ======================================================================= */ 134#ifndef UNDER_CE 135 136#ifdef AMRENC_DEBUG 137 #define AMRENC_DPRINT(...) fprintf(stderr,__VA_ARGS__) 138 139 #ifdef ANDROID 140 #undef AMRENC_DPRINT 141 #define AMRENC_DPRINT LOGW 142 #endif 143 144#else 145 #define AMRENC_DPRINT(...) 146#endif 147 148 149/* ======================================================================= */ 150/** 151 * @def AMRENC_MEMCHECK Memory print macro 152 */ 153/* ======================================================================= */ 154#ifdef AMRENC_MEMCHECK 155 #define AMRENC_MEMPRINT(...) fprintf(stderr,__VA_ARGS__) 156 157 #ifdef ANDROID 158 #undef AMRENC_MEMPRINT 159 #define AMRENC_MEMPRINT LOGW 160 #endif 161 162#else 163 #define AMRENC_MEMPRINT(...) printf 164#endif 165 166#else /*UNDER_CE*/ 167/* ======================================================================= */ 168/** 169 * @def AMRENC_DEBUG Debug print macro 170 */ 171/* ======================================================================= */ 172#ifdef AMRENC_DEBUG 173 #define AMRENC_DPRINT(STR, ARG...) printf() 174#else 175 176#endif 177/* ======================================================================= */ 178/** 179 * @def AMRENC_MEMCHECK Memory print macro 180 */ 181/* ======================================================================= */ 182#ifdef AMRENC_MEMCHECK 183 #define AMRENC_MEMPRINT(STR, ARG...) printf() 184#else 185 186#endif 187 188#ifdef UNDER_CE 189 190#ifdef DEBUG 191 #ifdef ANDROID 192 #define AMRENC_DPRINT LOGW 193 #define AMRENC_MEMPRINT LOGW 194 #else 195 #define AMRENC_DPRINT printf 196 #define AMRENC_MEMPRINT printf 197 #endif 198#else 199 #define AMRENC_DPRINT 200 #define AMRENC_MEMPRINT 201#endif 202 203#endif /*UNDER_CE*/ 204 205#endif 206 207/* ======================================================================= */ 208/** 209 * M A C R O S FOR MALLOC and MEMORY FREE and CLOSING PIPES 210 */ 211/* ======================================================================= */ 212 213#define OMX_NBCONF_INIT_STRUCT(_s_, _name_) \ 214 memset((_s_), 0x0, sizeof(_name_)); \ 215 (_s_)->nSize = sizeof(_name_); \ 216 (_s_)->nVersion.s.nVersionMajor = 0x1; \ 217 (_s_)->nVersion.s.nVersionMinor = 0x0; \ 218 (_s_)->nVersion.s.nRevision = 0x0; \ 219 (_s_)->nVersion.s.nStep = 0x0 220 221#define OMX_NBMEMFREE_STRUCT(_pStruct_)\ 222 AMRENC_MEMPRINT("%d :: [FREE] %p\n",__LINE__,_pStruct_);\ 223 if(_pStruct_ != NULL){\ 224 newfree(_pStruct_);\ 225 _pStruct_ = NULL;\ 226 } 227 228 229#define OMX_NBCLOSE_PIPE(_pStruct_,err)\ 230 AMRENC_DPRINT("%d :: CLOSING PIPE \n",__LINE__);\ 231 err = close (_pStruct_);\ 232 if(0 != err && OMX_ErrorNone == eError){\ 233 eError = OMX_ErrorHardware;\ 234 printf("%d :: Error while closing pipe\n",__LINE__);\ 235 goto EXIT;\ 236 } 237 238#define NBAMRENC_OMX_MALLOC(_pStruct_, _sName_) \ 239 _pStruct_ = (_sName_*)newmalloc(sizeof(_sName_)); \ 240 if(_pStruct_ == NULL){ \ 241 printf("***********************************\n"); \ 242 printf("%d :: Malloc Failed\n",__LINE__); \ 243 printf("***********************************\n"); \ 244 eError = OMX_ErrorInsufficientResources; \ 245 goto EXIT; \ 246 } \ 247 memset(_pStruct_,0,sizeof(_sName_));\ 248 AMRENC_MEMPRINT("%d :: Malloced = %p\n",__LINE__,_pStruct_); 249 250 251 252#define NBAMRENC_OMX_MALLOC_SIZE(_ptr_, _size_,_name_) \ 253 _ptr_ = (_name_ *)newmalloc(_size_); \ 254 if(_ptr_ == NULL){ \ 255 printf("***********************************\n"); \ 256 printf("%d :: Malloc Failed\n",__LINE__); \ 257 printf("***********************************\n"); \ 258 eError = OMX_ErrorInsufficientResources; \ 259 goto EXIT; \ 260 } \ 261 memset(_ptr_,0,_size_); \ 262 AMRENC_MEMPRINT("%d :: Malloced = %p\n",__LINE__,_ptr_); 263 264#define NBAMRENC_OMX_ERROR_EXIT(_e_, _c_, _s_)\ 265 _e_ = _c_;\ 266 printf("\n**************** OMX ERROR ************************\n");\ 267 printf("%d : Error Name: %s : Error Num = %x",__LINE__, _s_, _e_);\ 268 printf("\n**************** OMX ERROR ************************\n");\ 269 goto EXIT; 270 271#define NBAMRENC_OMX_FREE(ptr) \ 272 if(NULL != ptr) { \ 273 AMRENC_MEMPRINT("%d :: Freeing Address = %p\n",__LINE__,ptr); \ 274 newfree(ptr); \ 275 ptr = NULL; \ 276 } 277 278 279/* PV opencore capability custom parameter index */ 280#define PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX 0xFF7A347 281 282/* ======================================================================= */ 283/** 284 * @def EXTRA_BYTES Extra bytes For Cache alignment 285 * DSP_CACHE_ALIGNMENT Cache alignment value 286 */ 287/* ======================================================================= */ 288 289#define EXTRA_BYTES 128 290#define DSP_CACHE_ALIGNMENT 256 291 292/* ======================================================================= */ 293/** 294 * @def NBAMRENC_NUM_INPUT_BUFFERS Default number of input buffers 295 */ 296/* ======================================================================= */ 297#define NBAMRENC_NUM_INPUT_BUFFERS 1 298/* ======================================================================= */ 299/** 300 * @def NBAMRENC_NUM_INPUT_BUFFERS_DASF Default No.of input buffers DASF 301 */ 302/* ======================================================================= */ 303#define NBAMRENC_NUM_INPUT_BUFFERS_DASF 2 304/* ======================================================================= */ 305/** 306 * @def NBAMRENC_NUM_OUTPUT_BUFFERS Default number of output buffers 307 */ 308/* ======================================================================= */ 309#define NBAMRENC_NUM_OUTPUT_BUFFERS 1 310/* ======================================================================= */ 311/** 312 * @def NBAMRENC_INPUT_BUFFER_SIZE Default input buffer size 313 * NBAMRENC_INPUT_BUFFER_SIZE_DASF Default input buffer size DASF 314 * NBAMRENC_INPUT_FRAME_SIZE Default input Frame Size 315 */ 316/* ======================================================================= */ 317#define NBAMRENC_INPUT_BUFFER_SIZE 320 318#define NBAMRENC_INPUT_BUFFER_SIZE_DASF 320 319#define NBAMRENC_INPUT_FRAME_SIZE 320 320/* ======================================================================= */ 321/** 322 * @def NBAMRENC_OUTPUT_BUFFER_SIZE Default output buffer size 323 * NBAMRENC_OUTPUT_FRAME_SIZE Default output frame size 324 */ 325/* ======================================================================= */ 326#define NBAMRENC_OUTPUT_BUFFER_SIZE 118 327#define NBAMRENC_OUTPUT_FRAME_SIZE 118 328/* ======================================================================= */ 329/** 330 * @def NBAMRENC_OUTPUT_BUFFER_SIZE_MIME Default input buffer size MIME 331 */ 332/* ======================================================================= */ 333#define NBAMRENC_OUTPUT_BUFFER_SIZE_MIME 34 334 335/* ======================================================================= */ 336/** 337 * @def NBAMRENC_OUTPUT_BUFFER_SIZE_MIME Default input buffer size IF2 338 */ 339/* ======================================================================= */ 340#define NBAMRENC_OUTPUT_BUFFER_SIZE_IF2 32 341 342/* ======================================================================= */ 343/** 344 * @def NBAMRENC_OUTPUT_BUFFER_SIZE_EFR Default input buffer size EFR 345 */ 346/* ======================================================================= */ 347#define NBAMRENC_OUTPUT_BUFFER_SIZE_EFR 120 348 349/* ======================================================================= */ 350/* 351 * @def NBAMRENC_APP_ID App ID Value setting 352 */ 353/* ======================================================================= */ 354#define NBAMRENC_APP_ID 100 355 356/* ======================================================================= */ 357/** 358 * @def NBAMRENC_SAMPLING_FREQUENCY Sampling frequency 359 */ 360/* ======================================================================= */ 361#define NBAMRENC_SAMPLING_FREQUENCY 8000 362/* ======================================================================= */ 363/** 364 * @def NBAMRENC_CPU_LOAD CPU Load in MHz 365 */ 366/* ======================================================================= */ 367#define NBAMRENC_CPU_LOAD 12 368/* ======================================================================= */ 369/** 370 * @def NBAMRENC_MAX_NUM_OF_BUFS Maximum number of buffers 371 */ 372/* ======================================================================= */ 373#define NBAMRENC_MAX_NUM_OF_BUFS 15 374/* ======================================================================= */ 375/** 376 * @def NBAMRENC_NUM_OF_PORTS Number of ports 377 */ 378/* ======================================================================= */ 379#define NBAMRENC_NUM_OF_PORTS 2 380/* ======================================================================= */ 381/** 382 * @def NBAMRENC_XXX_VER Component version 383 */ 384/* ======================================================================= */ 385#define NBAMRENC_MAJOR_VER 0x1 386#define NBAMRENC_MINOR_VER 0x1 387/* ======================================================================= */ 388/** 389 * @def NBAMRENC_NOT_USED Defines a value for "don't care" parameters 390 */ 391/* ======================================================================= */ 392#define NBAMRENC_NOT_USED 10 393/* ======================================================================= */ 394/** 395 * @def NBAMRENC_NORMAL_BUFFER Defines flag value with all flags off 396 */ 397/* ======================================================================= */ 398#define NBAMRENC_NORMAL_BUFFER 0 399/* ======================================================================= */ 400/** 401 * @def OMX_NBAMRENC_DEFAULT_SEGMENT Default segment ID for the LCML 402 */ 403/* ======================================================================= */ 404#define NBAMRENC_DEFAULT_SEGMENT (0) 405/* ======================================================================= */ 406/** 407 * @def OMX_NBAMRENC_SN_TIMEOUT Timeout value for the socket node 408 */ 409/* ======================================================================= */ 410#define NBAMRENC_SN_TIMEOUT (-1) 411/* ======================================================================= */ 412/** 413 * @def OMX_NBAMRENC_SN_PRIORITY Priority for the socket node 414 */ 415/* ======================================================================= */ 416#define NBAMRENC_SN_PRIORITY (10) 417/* ======================================================================= */ 418/** 419 * @def OMX_NBAMRENC_NUM_DLLS number of DLL's 420 */ 421/* ======================================================================= */ 422#define NBAMRENC_NUM_DLLS (2) 423/* ======================================================================= */ 424/** 425 * @def NBAMRENC_USN_DLL_NAME USN DLL name 426 */ 427/* ======================================================================= */ 428#ifdef UNDER_CE 429 #define NBAMRENC_USN_DLL_NAME "\\windows\\usn.dll64P" 430#else 431 #define NBAMRENC_USN_DLL_NAME "usn.dll64P" 432#endif 433 434/* ======================================================================= */ 435/** 436 * @def NBAMRENC_DLL_NAME NBAMR Encoder socket node dll name 437 */ 438/* ======================================================================= */ 439#ifdef UNDER_CE 440 #define NBAMRENC_DLL_NAME "\\windows\\nbamrenc_sn.dll64P" 441#else 442 #define NBAMRENC_DLL_NAME "nbamrenc_sn.dll64P" 443#endif 444 445/* ======================================================================= */ 446/** NBAMRENC_StreamType Stream types 447* 448* @param NBAMRENC_DMM DMM 449* 450* @param NBAMRENC_INSTRM Input stream 451* 452* @param NBAMRENC_OUTSTRM Output stream 453*/ 454/* ======================================================================= */ 455enum NBAMRENC_StreamType { 456 NBAMRENC_DMM = 0, 457 NBAMRENC_INSTRM, 458 NBAMRENC_OUTSTRM 459}; 460/* ======================================================================= */ 461/** NBAMRENC_EncodeType coding types 462* 463* @param NBAMRENC_NBAMR NBAMR mode 464* 465* @param NBAMRENC_EFR EFR mode 466* 467*/ 468/* ======================================================================= */ 469enum NBAMRENC_EncodeType { 470 NBAMRENC_NBAMR = 0, 471 NBAMRENC_EFR 472}; 473/* ======================================================================= */ 474/** NBAMRENC_MimeMode format types 475* 476* @param NBAMRENC_MIMEMODE MIME 477* 478* @param NBAMRENC_FORMATCONFORMANCE NBAMR mode 479* 480* @param NBAMRENC_IF2 IF2 481* 482*/ 483/* ======================================================================= */ 484enum NBAMRENC_MimeMode { 485 NBAMRENC_FORMATCONFORMANCE = 0, 486 NBAMRENC_MIMEMODE, 487 NBAMRENC_IF2 488}; 489 490/* ======================================================================= */ 491/* 492 * Different Frame sizes for different index in MIME Mode 493 */ 494/* ======================================================================= */ 495#define NBAMRENC_FRAME_SIZE_0 0 496#define NBAMRENC_FRAME_SIZE_1 1 497#define NBAMRENC_FRAME_SIZE_6 6 498#define NBAMRENC_FRAME_SIZE_13 13 499#define NBAMRENC_FRAME_SIZE_14 14 500#define NBAMRENC_FRAME_SIZE_16 16 501#define NBAMRENC_FRAME_SIZE_18 18 502#define NBAMRENC_FRAME_SIZE_19 19 503#define NBAMRENC_FRAME_SIZE_20 20 504#define NBAMRENC_FRAME_SIZE_21 21 505#define NBAMRENC_FRAME_SIZE_26 26 506#define NBAMRENC_FRAME_SIZE_27 27 507#define NBAMRENC_FRAME_SIZE_31 31 508#define NBAMRENC_FRAME_SIZE_32 32 509 510 511 512/* ======================================================================= */ 513/** 514 * @def NBAMRENC_TIMEOUT Default timeout used to come out of blocking calls 515 */ 516/* ======================================================================= */ 517#define NBAMRENC_TIMEOUT 1000 518/* ======================================================================= */ 519/* 520 * @def NBAMRENC_OMX_MAX_TIMEOUTS Max Time Outs 521 * @def NBAMRENC_DONT_CARE Dont Care Condition 522 * @def NBAMRENC_NUM_CHANNELS Number of Channels 523 * @def NBAMRENC_APP_ID App ID Value setting 524 */ 525/* ======================================================================= */ 526#define NBAMRENC_OMX_MAX_TIMEOUTS 20 527#define NBAMRENC_DONT_CARE 0 528#define NBAMRENC_NUM_CHANNELS 1 529/* ======================================================================= */ 530/** 531 * @def NBAMRENC_STREAM_COUNT Number of streams 532 * NBAMRENC_INPUT_STREAM_ID Stream ID for Input Buffer 533 */ 534/* ======================================================================= */ 535#define NBAMRENC_STREAM_COUNT 2 536#define NBAMRENC_INPUT_STREAM_ID 0 537 538/* ======================================================================= */ 539/** 540 * @def _ERROR_PROPAGATION__ Allow Logic to Detec&Report Arm Errors 541 */ 542/* ======================================================================= */ 543#define _ERROR_PROPAGATION__ 544 545 546typedef struct PV_OMXComponentCapabilityFlagsType 547{ 548 ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS (for opencore compatability) 549 OMX_BOOL iIsOMXComponentMultiThreaded; 550 OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc; 551 OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc; 552 OMX_BOOL iOMXComponentSupportsMovableInputBuffers; 553 OMX_BOOL iOMXComponentSupportsPartialFrames; 554 OMX_BOOL iOMXComponentNeedsNALStartCode; 555 OMX_BOOL iOMXComponentCanHandleIncompleteFrames; 556} PV_OMXComponentCapabilityFlagsType; 557/* ======================================================================= */ 558/** NBAMRENC_COMP_PORT_TYPE Port types 559 * 560 * @param NBAMRENC_INPUT_PORT Input port 561 * 562 * @param NBAMRENC_OUTPUT_PORT Output port 563 */ 564/* ====================================================================== */ 565/*This enum must not be changed. */ 566typedef enum NBAMRENC_COMP_PORT_TYPE { 567 NBAMRENC_INPUT_PORT = 0, 568 NBAMRENC_OUTPUT_PORT 569}NBAMRENC_COMP_PORT_TYPE; 570 571/* ======================================================================= */ 572/** NBAMRENC_BUFFER_Dir Buffer Direction 573* 574* @param NBAMRENC_DIRECTION_INPUT Input direction 575* 576* @param NBAMRENC_DIRECTION_OUTPUT Output direction 577* 578*/ 579/* ======================================================================= */ 580typedef enum { 581 NBAMRENC_DIRECTION_INPUT, 582 NBAMRENC_DIRECTION_OUTPUT 583}NBAMRENC_BUFFER_Dir; 584 585/* ======================================================================= */ 586/** AUDIO_SN_AMRBANDMODETYPE BitRate Enum on the format used by 587* the SN 588* @param SN_AUDIO_BR_X 589*/ 590/* ======================================================================= */ 591typedef enum AUDIO_SN_AMRBANDMODETYPE { 592 SN_AUDIO_BR122 = 0, 593 SN_AUDIO_BR102, 594 SN_AUDIO_BR795, 595 SN_AUDIO_BR74, 596 SN_AUDIO_BR67, 597 SN_AUDIO_BR59, 598 SN_AUDIO_BR515, 599 SN_AUDIO_475, 600 SN_AUDIO_AMRBandModeMax = 0x7FFFFFFF 601}AUDIO_SN_AMRBANDMODETYPE; 602 603/* ======================================================================= */ 604/** NBAMRENC_BUFFS Buffer details 605* 606* @param BufHeader Buffer header 607* 608* @param Buffer Buffer 609* 610*/ 611/* ======================================================================= */ 612typedef struct NBAMRENC_BUFFS { 613 char BufHeader; 614 char Buffer; 615}NBAMRENC_BUFFS; 616 617/* ======================================================================= */ 618/** NBAMRENC_BUFFERHEADERTYPE_INFO 619* 620* @param pBufHeader 621* 622* @param bBufOwner 623* 624*/ 625/* ======================================================================= */ 626typedef struct NBAMRENC_BUFFERHEADERTYPE_INFO { 627 OMX_BUFFERHEADERTYPE* pBufHeader[NBAMRENC_MAX_NUM_OF_BUFS]; 628 NBAMRENC_BUFFS bBufOwner[NBAMRENC_MAX_NUM_OF_BUFS]; 629}NBAMRENC_BUFFERHEADERTYPE_INFO; 630 631 632typedef OMX_ERRORTYPE (*NBAMRENC_fpo)(OMX_HANDLETYPE); 633 634/* =================================================================================== */ 635/** 636* Socket node Audio Codec Configuration parameters. 637*/ 638/* =================================================================================== */ 639typedef struct NBAMRENC_AudioCodecParams { 640 unsigned long iSamplingRate; 641 unsigned long iStrmId; 642 unsigned short iAudioFormat; 643}NBAMRENC_AudioCodecParams; 644 645/* =================================================================================== */ 646/** 647* NBAMRENC_TALGCtrl Socket Node Alg Control parameters. 648* NBAMRENC_UAlgInBufParamStruct Input Buffer Param Structure 649* NBAMRENC_UAlgOutBufParamStruct Output Buffer Param Structure 650*/ 651/* =================================================================================== */ 652/* Algorithm specific command parameters */ 653typedef struct { 654 unsigned int iSize; 655 unsigned int iBitrate; 656 unsigned int iDTX; 657 unsigned int iMode; 658 unsigned int iFrameSize; 659 unsigned int iNoiseSuppressionMode; 660 unsigned int ittyTddMode; 661 unsigned int idtmfMode; 662 unsigned int idataTransmit; 663}NBAMRENC_TALGCtrl; 664 665/* =================================================================================== */ 666/** 667* NBAMRENC_UAlgInBufParamStruct Input Buffer Param Structure 668* usLastFrame To Send Last Buufer Flag 669*/ 670/* =================================================================================== */ 671typedef struct { 672 unsigned long int usLastFrame; 673}NBAMRENC_FrameStruct; 674 675typedef struct{ 676 unsigned long int usNbFrames; 677 NBAMRENC_FrameStruct *pParamElem; 678}NBAMRENC_ParamStruct; 679 680/* =================================================================================== */ 681/** 682* NBAMRENC_LCML_BUFHEADERTYPE Buffer Header Type 683*/ 684/* =================================================================================== */ 685typedef struct NBAMRENC_LCML_BUFHEADERTYPE { 686 NBAMRENC_BUFFER_Dir eDir; 687 NBAMRENC_FrameStruct *pFrameParam; 688 NBAMRENC_ParamStruct *pBufferParam; 689 DMM_BUFFER_OBJ* pDmmBuf; 690 OMX_BUFFERHEADERTYPE* buffer; 691}NBAMRENC_LCML_BUFHEADERTYPE; 692 693typedef struct _NBAMRENC_BUFFERLIST NBAMRENC_BUFFERLIST; 694 695/* =================================================================================== */ 696/** 697* _NBAMRENC_BUFFERLIST Structure for buffer list 698*/ 699/* ================================================================================== */ 700struct _NBAMRENC_BUFFERLIST{ 701 OMX_BUFFERHEADERTYPE sBufHdr; 702 OMX_BUFFERHEADERTYPE *pBufHdr[NBAMRENC_MAX_NUM_OF_BUFS]; 703 OMX_U32 bufferOwner[NBAMRENC_MAX_NUM_OF_BUFS]; 704 OMX_U32 bBufferPending[NBAMRENC_MAX_NUM_OF_BUFS]; 705 OMX_U16 numBuffers; 706 NBAMRENC_BUFFERLIST *pNextBuf; 707 NBAMRENC_BUFFERLIST *pPrevBuf; 708}; 709 710/* =================================================================================== */ 711/** 712* NBAMRENC_PORT_TYPE Structure for PortFormat details 713*/ 714/* =================================================================================== */ 715typedef struct NBAMRENC_PORT_TYPE { 716 OMX_HANDLETYPE hTunnelComponent; 717 OMX_U32 nTunnelPort; 718 OMX_BUFFERSUPPLIERTYPE eSupplierSetting; 719 OMX_U8 nBufferCnt; 720 OMX_AUDIO_PARAM_PORTFORMATTYPE* pPortFormat; 721} NBAMRENC_PORT_TYPE; 722 723#ifdef UNDER_CE 724 #ifndef _OMX_EVENT_ 725 #define _OMX_EVENT_ 726 typedef struct OMX_Event { 727 HANDLE event; 728 } OMX_Event; 729 #endif 730 int OMX_CreateEvent(OMX_Event *event); 731 int OMX_SignalEvent(OMX_Event *event); 732 int OMX_WaitForEvent(OMX_Event *event); 733 int OMX_DestroyEvent(OMX_Event *event); 734#endif 735 736/* =================================================================================== */ 737/** 738* NBAMRENC_BUFDATA 739*/ 740/* =================================================================================== */ 741typedef struct NBAMRENC_BUFDATA { 742 OMX_U8 nFrames; 743}NBAMRENC_BUFDATA; 744 745/* =================================================================================== */ 746/** 747* AMRENC_COMPONENT_PRIVATE Component private data Structure 748*/ 749/* =================================================================================== */ 750typedef struct AMRENC_COMPONENT_PRIVATE 751{ 752 /** Array of pointers to BUFFERHEADERTYPE structues 753 This pBufHeader[INPUT_PORT] will point to all the 754 BUFFERHEADERTYPE structures related to input port, 755 not just one structure. Same is the case for output 756 port also. */ 757 OMX_BUFFERHEADERTYPE* pBufHeader[NBAMRENC_NUM_OF_PORTS]; 758 OMX_U32 nRuntimeInputBuffers; 759 760 OMX_U32 nRuntimeOutputBuffers; 761 OMX_CALLBACKTYPE cbInfo; 762 OMX_PORT_PARAM_TYPE* sPortParam; 763 OMX_PRIORITYMGMTTYPE* sPriorityMgmt; 764 765 /* RMPROXY_CALLBACKTYPE rmproxyCallback; */ 766 OMX_BOOL bPreempted; 767 768 OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[NBAMRENC_NUM_OF_PORTS]; 769 OMX_PORT_PARAM_TYPE* pPortParamType; 770 OMX_AUDIO_PARAM_AMRTYPE* amrParams; 771 OMX_AUDIO_PARAM_PCMMODETYPE* pcmParams; 772 NBAMRENC_BUFFERHEADERTYPE_INFO BufInfo[NBAMRENC_NUM_OF_PORTS]; 773 NBAMRENC_PORT_TYPE *pCompPort[NBAMRENC_NUM_OF_PORTS]; 774 NBAMRENC_LCML_BUFHEADERTYPE *pLcmlBufHeader[NBAMRENC_NUM_OF_PORTS]; 775 /** This is component handle */ 776 OMX_COMPONENTTYPE* pHandle; 777 /** Current state of this component */ 778 OMX_STATETYPE curState; 779 /** The component thread handle */ 780 pthread_t ComponentThread; 781 /** The pipes for sending buffers to the thread */ 782 int dataPipe[2]; 783 /** The pipes for sending command to the thread */ 784 int cmdPipe[2]; 785 /** The pipes for sending cmd data to the thread */ 786 int cmdDataPipe[2]; 787 788 OMX_U32 efrMode; 789 790 OMX_U32 amrMode; 791 792 OMX_U32 dasfMode; 793 794 OMX_U32 frameMode; 795 796 OMX_U32 acdnMode; 797 798 OMX_U32 nMultiFrameMode; 799 800 OMX_U32 fdwrite; 801 802 OMX_U32 fdread; 803 804 /** Set to indicate component is stopping */ 805 OMX_U32 bIsStopping; 806 807 OMX_U32 bIsThreadstop; 808 809 /** Count of number of buffers outstanding with bridge */ 810 OMX_U32 lcml_nIpBuf; 811 812 /** Count of number of buffers outstanding with bridge */ 813 OMX_U32 lcml_nOpBuf; 814 815 OMX_U32 app_nBuf; 816 817 OMX_U32 num_Op_Issued; 818 819 OMX_U32 streamID; 820 821 OMX_U32 bCompThreadStarted; 822 823 OMX_U32 nVersion; 824 825 OMX_U32 amrMimeBytes[16]; 826 827 OMX_U32 amrIf2Bytes[16]; 828 829 OMX_U32 iHoldLen; 830 831 OMX_U32 nHoldLength; 832 833 OMX_U32 nFillThisBufferCount; 834 835 OMX_U32 nFillBufferDoneCount; 836 837 OMX_U32 nEmptyThisBufferCount; 838 839 OMX_U32 nEmptyBufferDoneCount; 840 841 OMX_U32 bInitParamsInitialized; 842 843 OMX_U32 nNumInputBufPending; 844 845 OMX_U32 nNumOutputBufPending; 846 847 OMX_U32 bDisableCommandPending; 848 849 OMX_U32 bEnableCommandPending; 850 851 OMX_U32 bDisableCommandParam; 852 853 OMX_U32 bEnableCommandParam; 854 855 OMX_HANDLETYPE pLcmlHandle; 856 857 OMX_PTR pMarkData; 858 859 OMX_MARKTYPE *pMarkBuf; 860 861 OMX_HANDLETYPE hMarkTargetComponent; 862 863 NBAMRENC_BUFFERLIST *pInputBufferList; 864 865 NBAMRENC_BUFFERLIST *pOutputBufferList; 866 867 LCML_STRMATTR *strmAttr; 868 869 NBAMRENC_TALGCtrl *pAlgParam; 870 871 NBAMRENC_AudioCodecParams *pParams; 872 873 OMX_STRING cComponentName; 874 875 OMX_VERSIONTYPE ComponentVersion; 876 877 OMX_BUFFERHEADERTYPE *pInputBufHdrPending[NBAMRENC_MAX_NUM_OF_BUFS]; 878 879 OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[NBAMRENC_MAX_NUM_OF_BUFS]; 880 881 OMX_BUFFERHEADERTYPE *iMMFDataLastBuffer; 882 883 OMX_U8 *pHoldBuffer,*pHoldBuffer2; 884 885 OMX_U8* iHoldBuffer; 886 887 888 /** Flag to set when socket node stop callback should not transition 889 component to OMX_StateIdle */ 890 OMX_U32 bNoIdleOnStop; 891 892 /** Flag set when socket node is stopped */ 893 OMX_U32 bDspStoppedWhileExecuting; 894 895 /** Number of outstanding FillBufferDone() calls */ 896 OMX_S32 nOutStandingFillDones; 897 OMX_S32 nOutStandingEmptyDones; 898 899#ifndef UNDER_CE 900 pthread_mutex_t AlloBuf_mutex; 901 pthread_cond_t AlloBuf_threshold; 902 OMX_U8 AlloBuf_waitingsignal; 903 904 pthread_mutex_t InLoaded_mutex; 905 pthread_cond_t InLoaded_threshold; 906 OMX_U8 InLoaded_readytoidle; 907 908 pthread_mutex_t InIdle_mutex; 909 pthread_cond_t InIdle_threshold; 910 OMX_U8 InIdle_goingtoloaded; 911 912 OMX_U8 nUnhandledFillThisBuffers; 913 OMX_U8 nUnhandledEmptyThisBuffers; 914 OMX_BOOL bFlushOutputPortCommandPending; 915 OMX_BOOL bFlushInputPortCommandPending; 916 917 pthread_mutex_t ToLoaded_mutex; 918#else 919 OMX_Event AlloBuf_event; 920 OMX_U8 AlloBuf_waitingsignal; 921 922 OMX_Event InLoaded_event; 923 OMX_U8 InLoaded_readytoidle; 924 925 OMX_Event InIdle_event; 926 OMX_U8 InIdle_goingtoloaded; 927#endif 928 929 OMX_U8 nNumOfFramesSent; 930 931 OMX_U8 InBuf_Eos_alreadysent; 932 933 OMX_U8 PendingPausedBufs; 934 OMX_BUFFERHEADERTYPE *pOutputBufHdrPausedPending[NBAMRENC_MAX_NUM_OF_BUFS]; 935 936#ifdef __PERF_INSTRUMENTATION__ 937 PERF_OBJHANDLE pPERF, pPERFcomp; 938 OMX_U32 nLcml_nCntIp; 939 OMX_U32 nLcml_nCntOpReceived; 940#endif 941 OMX_BUFFERHEADERTYPE *LastOutbuf; 942 OMX_BOOL bIsInvalidState; 943 944 OMX_STRING* sDeviceString; 945 946 void* ptrLibLCML; 947 948 /** Circular array to keep buffer timestamps */ 949 OMX_S64 arrBufIndex[NBAMRENC_MAX_NUM_OF_BUFS]; 950 /** Circular array to keep buffer nTickCounts */ 951 OMX_S64 arrTickCount[NBAMRENC_MAX_NUM_OF_BUFS]; 952 /** Index to arrBufIndex[], used for input buffer timestamps */ 953 OMX_U8 IpBufindex; 954 /** Index to arrBufIndex[], used for output buffer timestamps */ 955 OMX_U8 OpBufindex; 956 OMX_TICKS TimeStamp; 957 OMX_BOOL bFirstInputBufReceived; 958 959 OMX_S8 ProcessingInputBuf; 960 OMX_S8 ProcessingOutputBuf; 961 962 OMX_BOOL bLoadedCommandPending; 963 OMX_BOOL bLoadedWaitingFreeBuffers; 964 965 OMX_PARAM_COMPONENTROLETYPE componentRole; 966 OMX_U32 teeMode; 967 PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags; 968 969} AMRENC_COMPONENT_PRIVATE; 970 971 972#ifndef UNDER_CE 973 OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp); 974#else 975/* WinCE Implicit Export Syntax */ 976#define OMX_EXPORT __declspec(dllexport) 977/* =================================================================================== */ 978/** 979* OMX_ComponentInit() Initializes component 980* 981* 982* @param hComp OMX Handle 983* 984* @return OMX_ErrorNone = Successful 985* Other error code = fail 986* 987*/ 988/* =================================================================================== */ 989OMX_EXPORT OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp); 990#endif 991/* =================================================================================== */ 992/** 993* NBAMRENC_StartComponentThread() Starts component thread 994* 995* 996* @param hComp OMX Handle 997* 998* @return OMX_ErrorNone = Successful 999* Other error code = fail 1000* 1001*/ 1002/* =================================================================================== */ 1003OMX_ERRORTYPE NBAMRENC_StartComponentThread(OMX_HANDLETYPE pHandle); 1004/* =================================================================================== */ 1005/** 1006* NBAMRENC_StopComponentThread() Stops component thread 1007* 1008* 1009* @param hComp OMX Handle 1010* 1011* @return OMX_ErrorNone = Successful 1012* Other error code = fail 1013* 1014*/ 1015/* =================================================================================== */ 1016OMX_ERRORTYPE NBAMRENC_StopComponentThread(OMX_HANDLETYPE pHandle); 1017/* =================================================================================== */ 1018/** 1019* NBAMRENC_FreeCompResources() Frees allocated memory 1020* 1021* 1022* @param hComp OMX Handle 1023* 1024* @return OMX_ErrorNone = Successful 1025* Other error code = fail 1026* 1027*/ 1028/* =================================================================================== */ 1029OMX_ERRORTYPE NBAMRENC_FreeCompResources(OMX_HANDLETYPE pComponent); 1030/* =================================================================================== */ 1031/** 1032* NBAMRENC_GetCorrespondingLCMLHeader() Returns LCML header 1033* that corresponds to the given buffer 1034* 1035* @param pComponentPrivate Component private data 1036* 1037* @return OMX_ErrorNone = Successful 1038* Other error code = fail 1039*/ 1040/* =================================================================================== */ 1041OMX_ERRORTYPE NBAMRENC_GetCorrespondingLCMLHeader(AMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1042 OMX_U8 *pBuffer, 1043 OMX_DIRTYPE eDir, 1044 NBAMRENC_LCML_BUFHEADERTYPE **ppLcmlHdr); 1045/* =================================================================================== */ 1046/** 1047* NBAMRENC_LCMLCallback() Callback from LCML 1048* 1049* @param event Codec Event 1050* 1051* @param args Arguments from LCML 1052* 1053* @return OMX_ErrorNone = Successful 1054* Other error code = fail 1055*/ 1056/* =================================================================================== */ 1057OMX_ERRORTYPE NBAMRENC_LCMLCallback(TUsnCodecEvent event, 1058 void * args [10]); 1059/* =================================================================================== */ 1060/** 1061* NBAMRENC_FillLCMLInitParams() Fills the parameters needed 1062* to initialize the LCML 1063* 1064* @param pHandle OMX Handle 1065* 1066* @param plcml_Init LCML initialization parameters 1067* 1068* @return OMX_ErrorNone = Successful 1069* Other error code = fail 1070* 1071*/ 1072/* =================================================================================== */ 1073OMX_ERRORTYPE NBAMRENC_FillLCMLInitParams(OMX_HANDLETYPE pHandle, 1074 LCML_DSP *plcml_Init, 1075 OMX_U16 arr[]); 1076/* =================================================================================== */ 1077/** 1078* NBAMRENC_GetBufferDirection() Returns direction of pBufHeader 1079* 1080* @param pBufHeader Buffer header 1081* 1082* @param eDir Buffer direction 1083* 1084* @param pComponentPrivate Component private data 1085* 1086* @return OMX_ErrorNone = Successful 1087* Other error code = fail 1088*/ 1089/* =================================================================================== */ 1090OMX_ERRORTYPE NBAMRENC_GetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader, 1091 OMX_DIRTYPE *eDir); 1092/* =========================================================== */ 1093/** 1094* NBAMRENC_HandleCommand() Handles commands sent via SendCommand() 1095* 1096* @param pComponentPrivate Component private data 1097* 1098* @return OMX_ErrorNone = Successful 1099* Other error code = fail 1100* @return OMX_ErrorNone = Successful 1101* Other error code = fail 1102*/ 1103/* =================================================================================== */ 1104OMX_U32 NBAMRENC_HandleCommand(AMRENC_COMPONENT_PRIVATE *pComponentPrivate); 1105/* =================================================================================== */ 1106/** 1107* NBAMRENC_HandleDataBufFromApp() Handles data buffers received 1108* from the IL Client 1109* 1110* @param pComponentPrivate Component private data 1111* 1112* @return OMX_ErrorNone = Successful 1113* Other error code = fail 1114* @return OMX_ErrorNone = Successful 1115* Other error code = fail 1116*/ 1117/* =================================================================================== */ 1118OMX_ERRORTYPE NBAMRENC_HandleDataBufFromApp(OMX_BUFFERHEADERTYPE *pBufHeader, 1119 AMRENC_COMPONENT_PRIVATE *pComponentPrivate); 1120/* =================================================================================== */ 1121/** 1122* NBAMRENC_GetLCMLHandle() Get the handle to the LCML 1123* 1124* 1125* @return OMX_ErrorNone = Successful 1126* Other error code = fail 1127*/ 1128/* =================================================================================== */ 1129OMX_HANDLETYPE NBAMRENC_GetLCMLHandle(AMRENC_COMPONENT_PRIVATE *pComponentPrivate); 1130/* =================================================================================== */ 1131/** 1132* NBAMRENC_FreeLCMLHandle() Frees the handle to the LCML 1133* 1134* 1135* @return OMX_ErrorNone = Successful 1136* Other error code = fail 1137*/ 1138/* =================================================================================== */ 1139OMX_ERRORTYPE NBAMRENC_FreeLCMLHandle(AMRENC_COMPONENT_PRIVATE *pComponentPrivate); 1140/* =================================================================================== */ 1141/** 1142* NBAMRENC_CleanupInitParams() Starts component thread 1143* 1144* @param pComponent OMX Handle 1145* 1146* @return OMX_ErrorNone = Successful 1147* Other error code = fail 1148*/ 1149/* =================================================================================== */ 1150OMX_ERRORTYPE NBAMRENC_CleanupInitParams(OMX_HANDLETYPE pHandle); 1151/* =================================================================================== */ 1152/** 1153* NBAMRENC_SetPending() Called when the component queues a buffer 1154* to the LCML 1155* 1156* @param pComponentPrivate Component private data 1157* 1158* @param pBufHdr Buffer header 1159* 1160* @param eDir Direction of the buffer 1161* 1162* @return None 1163*/ 1164/* =================================================================================== */ 1165void NBAMRENC_SetPending(AMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1166 OMX_BUFFERHEADERTYPE *pBufHdr, 1167 OMX_DIRTYPE eDir, 1168 OMX_U32 lineNumber); 1169/* =================================================================================== */ 1170/** 1171* NBAMRENC_ClearPending() Called when a buffer is returned 1172* from the LCML 1173* 1174* @param pComponentPrivate Component private data 1175* 1176* @param pBufHdr Buffer header 1177* 1178* @param eDir Direction of the buffer 1179* 1180* @return None 1181*/ 1182/* =================================================================================== */ 1183void NBAMRENC_ClearPending(AMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1184 OMX_BUFFERHEADERTYPE *pBufHdr, 1185 OMX_DIRTYPE eDir, 1186 OMX_U32 lineNumber); 1187/* =================================================================================== */ 1188/** 1189* NBAMRENC_IsPending() 1190* 1191* 1192* @param pComponentPrivate Component private data 1193* 1194* @return OMX_ErrorNone = Successful 1195* Other error code = fail 1196*/ 1197/* =================================================================================== */ 1198OMX_U32 NBAMRENC_IsPending(AMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1199 OMX_BUFFERHEADERTYPE *pBufHdr, 1200 OMX_DIRTYPE eDir); 1201/* =================================================================================== */ 1202/** 1203* NBAMRENC_FillLCMLInitParamsEx() Fills the parameters needed 1204* to initialize the LCML without recreating the socket node 1205* 1206* @param pComponent OMX Handle 1207* 1208* @return None 1209*/ 1210/* =================================================================================== */ 1211OMX_ERRORTYPE NBAMRENC_FillLCMLInitParamsEx(OMX_HANDLETYPE pComponent); 1212/* =================================================================================== */ 1213/** 1214* NBAMRENC_IsValid() Returns whether a buffer is valid 1215* 1216* 1217* @param pComponentPrivate Component private data 1218* 1219* @param pBuffer Data buffer 1220* 1221* @param eDir Buffer direction 1222* 1223* @return OMX_True = Valid 1224* OMX_False= Invalid 1225*/ 1226/* =================================================================================== */ 1227OMX_U32 NBAMRENC_IsValid(AMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1228 OMX_U8 *pBuffer, 1229 OMX_DIRTYPE eDir); 1230 1231 1232/* void NBAMRENC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData); 1233 1234/* ======================================================================= */ 1235/** OMX_NBAMRENC_INDEXAUDIOTYPE Defines the custom configuration settings 1236* for the component 1237* 1238* @param OMX_IndexCustomNBAMRENCModeConfig Sets the DASF mode 1239* 1240* 1241*/ 1242/* ==================================================================== */ 1243typedef enum OMX_NBAMRENC_INDEXAUDIOTYPE { 1244 OMX_IndexCustomNBAMRENCModeConfig = 0xFF000001, 1245 OMX_IndexCustomNBAMRENCStreamIDConfig, 1246 OMX_IndexCustomNBAMRENCDataPath 1247}OMX_NBAMRENC_INDEXAUDIOTYPE; 1248 1249OMX_ERRORTYPE OMX_DmmMap(DSP_HPROCESSOR ProcHandle, int size, void* pArmPtr, DMM_BUFFER_OBJ* pDmmBuf); 1250OMX_ERRORTYPE OMX_DmmUnMap(DSP_HPROCESSOR ProcHandle, void* pMapPtr, void* pResPtr); 1251 1252/*===============================================================*/ 1253 1254typedef enum { 1255 IUALG_CMD_STOP = 0, 1256 IUALG_CMD_PAUSE = 1, 1257 IUALG_CMD_GETSTATUS = 2, 1258 IUALG_CMD_SETSTATUS = 3, 1259 IUALG_CMD_USERSETCMDSTART = 100, 1260 IUALG_CMD_USERGETCMDSTART = 150, 1261 IUALG_CMD_FLUSH = 0x100 1262}IUALG_Cmd; 1263 1264typedef enum 1265{ 1266 ALGCMD_BITRATE = IUALG_CMD_USERSETCMDSTART, 1267 ALGCMD_DTX 1268 1269} eSPEECHENCODE_AlgCmd; 1270 1271#endif /* OMX_AMRENC_UTILS__H */ 1272