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_WbAmrEnc_Utils.h 30 * 31 * This is an header file for an WBAMR 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\wbamr_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_WBAMRENC_UTILS__H 60 #define OMX_WBAMRENC_UTILS__H 61 62 #include "LCML_DspCodec.h" 63 #include <semaphore.h> 64 65 #ifdef RESOURCE_MANAGER_ENABLED 66 #include <ResourceManagerProxyAPI.h> 67 #endif 68 69 #ifdef __PERF_INSTRUMENTATION__ 70 #include "perf.h" 71 #endif 72 73 #include <OMX_Component.h> 74 #include "OMX_TI_Common.h" 75 #include "OMX_TI_Debug.h" 76 #ifdef DSP_RENDERING_ON 77 #include <AudioManagerAPI.h> 78 #endif 79 80 #ifdef UNDER_CE 81 #define sleep Sleep 82 #endif 83 84 #ifndef ANDROID 85 #define ANDROID 86 #endif 87 88 #ifdef ANDROID 89 #undef LOG_TAG 90 #define LOG_TAG "OMX_WBAMRENC" 91 92 /* PV opencore capability custom parameter index */ 93 #define PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX 0xFF7A347 94 #endif 95 96 /* ======================================================================= */ 97 /** 98 * @def WBAMRENC_DEBUG Turns debug messaging on and off 99 */ 100 /* ======================================================================= */ 101 #undef WBAMRENC_DEBUG 102 /* ======================================================================= */ 103 /** 104 * @def WBAMRENC_MEMCHECK Turns memory messaging on and off 105 */ 106 /* ======================================================================= */ 107 #undef WBAMRENC_MEMCHECK 108 109 /* ======================================================================= */ 110 /** 111 * @def WBAMRENC_DEBUGMEM Turns memory leaks messaging on and off. 112 * APP_DEBUGMEM must be defined in Test App in order to get 113 * this functionality On. 114 */ 115 /* ======================================================================= */ 116 #undef WBAMRENC_DEBUGMEM 117 /*#define WBAMRENC_DEBUGMEM*/ 118 119 /* ======================================================================= */ 120 /** 121 * M A C R O S FOR MEMORY and CLOSING PIPES 122 */ 123 /* ======================================================================= */ 124 125 #define OMX_WBCONF_INIT_STRUCT(_s_, _name_) \ 126 memset((_s_), 0x0, sizeof(_name_)); \ 127 (_s_)->nSize = sizeof(_name_); \ 128 (_s_)->nVersion.s.nVersionMajor = 0x1; \ 129 (_s_)->nVersion.s.nVersionMinor = 0x0; \ 130 (_s_)->nVersion.s.nRevision = 0x0; \ 131 (_s_)->nVersion.s.nStep = 0x0 132 133 #define OMX_WBCLOSE_PIPE(_pStruct_,err)\ 134 OMXDBG_PRINT(stderr, BUFFER, 2, OMX_DBG_BASEMASK, "Closing pipes = %d\n",_pStruct_);\ 135 err = close (_pStruct_);\ 136 if(0 != err && OMX_ErrorNone == eError){\ 137 eError = OMX_ErrorHardware;\ 138 OMXDBG_PRINT(stderr, ERROR, 4, OMX_DBG_BASEMASK, "Error while closing pipe\n");\ 139 goto EXIT;\ 140 } 141 142 #define WBAMRENC_OMX_ERROR_EXIT(_e_, _c_, _s_)\ 143 _e_ = _c_;\ 144 OMXDBG_PRINT(stderr, ERROR, 4, OMX_DBG_BASEMASK, "Error Name: %s : Error Num = %x", _s_, _e_);\ 145 goto EXIT; 146 147 /* ======================================================================= */ 148 /** 149 * @def WBAMRENC_SAMPLING_FREQUENCY Sampling frequency 150 */ 151 /* ======================================================================= */ 152 #define WBAMRENC_SAMPLING_FREQUENCY 16000 153 /* ======================================================================= */ 154 /** 155 * @def WBAMRENC_CPU_LOAD CPU Load in MHz 156 */ 157 /* ======================================================================= */ 158 #define WBAMRENC_CPU_LOAD 20 159 /* ======================================================================= */ 160 /** 161 * @def WBAMRENC_MAX_NUM_OF_BUFS Maximum number of buffers 162 */ 163 /* ======================================================================= */ 164 #define WBAMRENC_MAX_NUM_OF_BUFS 15 165 /* ======================================================================= */ 166 /** 167 * @def WBAMRENC_NUM_OF_PORTS Number of ports 168 */ 169 /* ======================================================================= */ 170 #define WBAMRENC_NUM_OF_PORTS 2 171 /* ======================================================================= */ 172 /** 173 * @def WBAMRENC_XXX_VER Component version 174 */ 175 /* ======================================================================= */ 176 #define WBAMRENC_MAJOR_VER 0xF1 177 #define WBAMRENC_MINOR_VER 0xF2 178 /* ======================================================================= */ 179 /** 180 * @def WBAMRENC_NOT_USED Defines a value for "don't care" parameters 181 */ 182 /* ======================================================================= */ 183 #define WBAMRENC_NOT_USED 10 184 /* ======================================================================= */ 185 /** 186 * @def WBAMRENC_NORMAL_BUFFER Defines flag value with all flags off 187 */ 188 /* ======================================================================= */ 189 #define WBAMRENC_NORMAL_BUFFER 0 190 /* ======================================================================= */ 191 /** 192 * @def OMX_WBAMRENC_DEFAULT_SEGMENT Default segment ID for the LCML 193 */ 194 /* ======================================================================= */ 195 #define WBAMRENC_DEFAULT_SEGMENT (0) 196 /* ======================================================================= */ 197 /** 198 * @def OMX_WBAMRENC_SN_TIMEOUT Timeout value for the socket node 199 */ 200 /* ======================================================================= */ 201 #define WBAMRENC_SN_TIMEOUT (-1) 202 /* ======================================================================= */ 203 /** 204 * @def OMX_WBAMRENC_SN_PRIORITY Priority for the socket node 205 */ 206 /* ======================================================================= */ 207 #define WBAMRENC_SN_PRIORITY (10) 208 /* ======================================================================= */ 209 /** 210 * @def OMX_WBAMRENC_NUM_DLLS number of DLL's 211 */ 212 /* ======================================================================= */ 213 #define WBAMRENC_NUM_DLLS (2) 214 /* ======================================================================= */ 215 /** 216 * @def WBAMRENC_USN_DLL_NAME USN DLL name 217 */ 218 /* ======================================================================= */ 219 #ifdef UNDER_CE 220 #define WBAMRENC_USN_DLL_NAME "\\windows\\usn.dll64P" 221 #else 222 #define WBAMRENC_USN_DLL_NAME "usn.dll64P" 223 #endif 224 225 /* ======================================================================= */ 226 /** 227 * @def WBAMRENC_DLL_NAME WBAMR Encoder socket node dll name 228 */ 229 /* ======================================================================= */ 230 #ifdef UNDER_CE 231 #define WBAMRENC_DLL_NAME "\\windows\\wbamrenc_sn.dll64P" 232 #else 233 #define WBAMRENC_DLL_NAME "wbamrenc_sn.dll64P" 234 #endif 235 236 /* ======================================================================= */ 237 /** WBAMRENC_StreamType Stream types 238 * 239 * @param WBAMRENC_DMM DMM 240 * 241 * @param WBAMRENC_INSTRM Input stream 242 * 243 * @param WBAMRENC_OUTSTRM Output stream 244 */ 245 /* ======================================================================= */ 246 enum WBAMRENC_StreamType { 247 WBAMRENC_DMM = 0, 248 WBAMRENC_INSTRM, 249 WBAMRENC_OUTSTRM 250 }; 251 /* ======================================================================= */ 252 /** WBAMRENC_EncodeType coding types 253 * 254 * @param WBAMRENC_WBAMR WBAMR mode 255 * 256 * @param WBAMRENC_EFR EFR mode 257 * 258 */ 259 /* ======================================================================= */ 260 enum WBAMRENC_EncodeType { 261 WBAMRENC_WBAMR = 0, 262 WBAMRENC_EFR 263 }; 264 /* ======================================================================= */ 265 /** WBAMRENC_MimeMode format types 266 * 267 * @param WBAMRENC_MIMEMODE MIME 268 * 269 * @param WBAMRENC_FORMATCONFORMANCE WBAMR mode 270 * 271 * @param WBAMRENC_IF2 IF2 mode 272 * 273 */ 274 /* ======================================================================= */ 275 enum WBAMRENC_MimeMode { 276 WBAMRENC_FORMATCONFORMANCE = 0, 277 WBAMRENC_MIMEMODE, 278 WBAMRENC_IF2 279 }; 280 281 /* ======================================================================= */ 282 /* 283 * Different Frame sizes for different index in MIME Mode 284 */ 285 /* ======================================================================= */ 286 #define WBAMRENC_FRAME_SIZE_0 0 287 #define WBAMRENC_FRAME_SIZE_1 1 288 #define WBAMRENC_FRAME_SIZE_6 6 289 #define WBAMRENC_FRAME_SIZE_18 18 290 #define WBAMRENC_FRAME_SIZE_23 23 291 #define WBAMRENC_FRAME_SIZE_24 24 292 #define WBAMRENC_FRAME_SIZE_33 33 293 #define WBAMRENC_FRAME_SIZE_37 37 294 #define WBAMRENC_FRAME_SIZE_41 41 295 #define WBAMRENC_FRAME_SIZE_47 47 296 #define WBAMRENC_FRAME_SIZE_51 51 297 #define WBAMRENC_FRAME_SIZE_59 59 298 #define WBAMRENC_FRAME_SIZE_61 61 299 300 301 302 /* ======================================================================= */ 303 /** 304 * @def WBAMRENC_TIMEOUT Default timeout used to come out of blocking calls 305 */ 306 /* ======================================================================= */ 307 #define WBAMRENC_TIMEOUT 1000 308 /* ======================================================================= */ 309 /* 310 * @def WBAMRENC_OMX_MAX_TIMEOUTS Max Time Outs 311 * @def WBAMRENC_DONT_CARE Dont Care Condition 312 * @def WBAMRENC_NUM_CHANNELS Number of Channels 313 * @def WBAMRENC_APP_ID App ID Value setting 314 */ 315 /* ======================================================================= */ 316 #define WBAMRENC_OMX_MAX_TIMEOUTS 20 317 #define WBAMRENC_DONT_CARE 0 318 #define WBAMRENC_NUM_CHANNELS 1 319 /* ======================================================================= */ 320 /** 321 * @def WBAMRENC_STREAM_COUNT Number of streams 322 * WBAMRENC_INPUT_STREAM_ID Stream ID for Input Buffer 323 */ 324 /* ======================================================================= */ 325 #define WBAMRENC_STREAM_COUNT 2 326 #define WBAMRENC_INPUT_STREAM_ID 0 327 328 /* ======================================================================= */ 329 /** 330 * @def _ERROR_PROPAGATION__ Allow Logic to Detec&Report Arm Errors 331 */ 332 /* ======================================================================= */ 333 #define _ERROR_PROPAGATION__ 334 335 typedef struct PV_OMXComponentCapabilityFlagsType { 336 /* OMX COMPONENT CAPABILITY RELATED MEMBERS (for opencore compatability)*/ 337 OMX_BOOL iIsOMXComponentMultiThreaded; 338 OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc; 339 OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc; 340 OMX_BOOL iOMXComponentSupportsMovableInputBuffers; 341 OMX_BOOL iOMXComponentSupportsPartialFrames; 342 OMX_BOOL iOMXComponentNeedsNALStartCode; 343 OMX_BOOL iOMXComponentCanHandleIncompleteFrames; 344 } PV_OMXComponentCapabilityFlagsType; 345 346 /** WBAMRENC_COMP_PORT_TYPE Port types 347 * 348 * @param WBAMRENC_INPUT_PORT Input port 349 * 350 * @param WBAMRENC_OUTPUT_PORT Output port 351 */ 352 /* ====================================================================== */ 353 /*This enum must not be changed. */ 354 typedef enum WBAMRENC_COMP_PORT_TYPE { 355 WBAMRENC_INPUT_PORT = 0, 356 WBAMRENC_OUTPUT_PORT 357 } WBAMRENC_COMP_PORT_TYPE; 358 359 /* ======================================================================= */ 360 /** AUDIO_SN_WBAMRBANDMODETYPE 361 * 362 * @SN_AUDIO_BRXXX This constant is used to determine the code to send 363 * to SN to set the BitRate. 364 */ 365 /* ====================================================================== */ 366 typedef enum AUDIO_SN_WBAMRBANDMODETYPE { 367 SN_AUDIO_BR2385 = 8, 368 SN_AUDIO_BR2305, 369 SN_AUDIO_BR1985, 370 SN_AUDIO_BR1825, 371 SN_AUDIO_BR1585, 372 SN_AUDIO_BR1425, 373 SN_AUDIO_BR1265, 374 SN_AUDIO_BR885, 375 SN_AUDIO_BR660, 376 SN_AUDIO_WBAMRBandModeMax = 0x7FFFFFFF 377 } AUDIO_SN_WBAMRBANDMODETYPE; 378 379 /* ======================================================================= */ 380 /** WBAMRENC_BUFFER_Dir Buffer Direction 381 * 382 * @param WBAMRENC_DIRECTION_INPUT Input direction 383 * 384 * @param WBAMRENC_DIRECTION_OUTPUT Output direction 385 * 386 */ 387 /* ======================================================================= */ 388 typedef enum { 389 WBAMRENC_DIRECTION_INPUT, 390 WBAMRENC_DIRECTION_OUTPUT 391 } WBAMRENC_BUFFER_Dir; 392 393 /* ======================================================================= */ 394 /** WBAMRENC_BUFFS Buffer details 395 * 396 * @param BufHeader Buffer header 397 * 398 * @param Buffer Buffer 399 * 400 */ 401 /* ======================================================================= */ 402 typedef struct WBAMRENC_BUFFS { 403 char BufHeader; 404 char Buffer; 405 } WBAMRENC_BUFFS; 406 407 /* ======================================================================= */ 408 /** WBAMRENC_BUFFERHEADERTYPE_INFO 409 * 410 * @param pBufHeader 411 * 412 * @param bBufOwner 413 * 414 */ 415 /* ======================================================================= */ 416 typedef struct WBAMRENC_BUFFERHEADERTYPE_INFO { 417 OMX_BUFFERHEADERTYPE* pBufHeader[WBAMRENC_MAX_NUM_OF_BUFS]; 418 WBAMRENC_BUFFS bBufOwner[WBAMRENC_MAX_NUM_OF_BUFS]; 419 } WBAMRENC_BUFFERHEADERTYPE_INFO; 420 421 422 typedef OMX_ERRORTYPE (*WBAMRENC_fpo)(OMX_HANDLETYPE); 423 424 /* =================================================================================== */ 425 /** 426 * Socket node Audio Codec Configuration parameters. 427 */ 428 /* =================================================================================== */ 429 typedef struct WBAMRENC_AudioCodecParams { 430 unsigned long iSamplingRate; 431 unsigned long iStrmId; 432 unsigned short iAudioFormat; 433 } WBAMRENC_AudioCodecParams; 434 435 /* =================================================================================== */ 436 /** 437 * WBAMRENC_TALGCtrl Socket Node Alg Control parameters. 438 * WBAMRENC_TALGCtrlDTX Socket Node Alg Control parameters (DTX). 439 * WBAMRENC_UAlgInBufParamStruct Input Buffer Param Structure 440 * WBAMRENC_UAlgOutBufParamStruct Output Buffer Param Structure 441 */ 442 /* =================================================================================== */ 443 /* Algorithm specific command parameters */ 444 typedef struct { 445 int iSize; 446 unsigned int iBitrate; 447 } WBAMRENC_TALGCtrl; 448 449 typedef struct { 450 int iSize; 451 unsigned int iVADFlag; 452 453 } WBAMRENC_TALGCtrlDTX; 454 /* =================================================================================== */ 455 /** 456 * WBAMRENC_UAlgInBufParamStruct Input Buffer Param Structure 457 * usLastFrame To Send Last Buufer Flag 458 */ 459 /* =================================================================================== */ 460 typedef struct { 461 unsigned long int usLastFrame; 462 } WBAMRENC_FrameStruct; 463 464 typedef struct { 465 unsigned long int usNbFrames; 466 WBAMRENC_FrameStruct *pParamElem; 467 } WBAMRENC_ParamStruct; 468 469 /* =================================================================================== */ 470 /** 471 * WBAMRENC_UAlgOutBufParamStruct Output Buffer Param Structure 472 * ulFrameCount No.of Frames Encoded 473 */ 474 /* =================================================================================== */ 475 typedef struct { 476 unsigned long ulFrameCount; 477 } WBAMRENC_UAlgOutBufParamStruct; 478 479 /* =================================================================================== */ 480 /** 481 * WBAMRENC_LCML_BUFHEADERTYPE Buffer Header Type 482 */ 483 /* =================================================================================== */ 484 typedef struct WBAMRENC_LCML_BUFHEADERTYPE { 485 WBAMRENC_BUFFER_Dir eDir; 486 WBAMRENC_FrameStruct *pFrameParam; 487 WBAMRENC_ParamStruct *pBufferParam; 488 DMM_BUFFER_OBJ* pDmmBuf; 489 OMX_BUFFERHEADERTYPE* buffer; 490 } WBAMRENC_LCML_BUFHEADERTYPE; 491 492 typedef struct _WBAMRENC_BUFFERLIST WBAMRENC_BUFFERLIST; 493 494 /* =================================================================================== */ 495 /** 496 * _WBAMRENC_BUFFERLIST Structure for buffer list 497 */ 498 /* ================================================================================== */ 499 struct _WBAMRENC_BUFFERLIST { 500 OMX_BUFFERHEADERTYPE sBufHdr; 501 OMX_BUFFERHEADERTYPE *pBufHdr[WBAMRENC_MAX_NUM_OF_BUFS]; 502 OMX_U32 bufferOwner[WBAMRENC_MAX_NUM_OF_BUFS]; 503 OMX_U32 bBufferPending[WBAMRENC_MAX_NUM_OF_BUFS]; 504 OMX_U32 numBuffers; 505 WBAMRENC_BUFFERLIST *pNextBuf; 506 WBAMRENC_BUFFERLIST *pPrevBuf; 507 }; 508 509 /* =================================================================================== */ 510 /** 511 * WBAMRENC_PORT_TYPE Structure for PortFormat details 512 */ 513 /* =================================================================================== */ 514 typedef struct WBAMRENC_PORT_TYPE { 515 OMX_HANDLETYPE hTunnelComponent; 516 OMX_U32 nTunnelPort; 517 OMX_BUFFERSUPPLIERTYPE eSupplierSetting; 518 OMX_U8 nBufferCnt; 519 OMX_AUDIO_PARAM_PORTFORMATTYPE* pPortFormat; 520 } WBAMRENC_PORT_TYPE; 521 522 #ifdef UNDER_CE 523 #ifndef _OMX_EVENT_ 524 #define _OMX_EVENT_ 525 typedef struct OMX_Event { 526 HANDLE event; 527 } OMX_Event; 528 #endif 529 int OMX_CreateEvent(OMX_Event *event); 530 int OMX_SignalEvent(OMX_Event *event); 531 int OMX_WaitForEvent(OMX_Event *event); 532 int OMX_DestroyEvent(OMX_Event *event); 533 #endif 534 535 typedef struct WBAMRENC_BUFDATA { 536 OMX_U8 nFrames; 537 } WBAMRENC_BUFDATA; 538 /* =================================================================================== */ 539 /** 540 * WBAMRENC_COMPONENT_PRIVATE Component private data Structure 541 */ 542 /* =================================================================================== */ 543 typedef struct WBAMRENC_COMPONENT_PRIVATE { 544 /** Array of pointers to BUFFERHEADERTYPE structues 545 This pBufHeader[INPUT_PORT] will point to all the 546 BUFFERHEADERTYPE structures related to input port, 547 not just one structure. Same is the case for output 548 port also. */ 549 OMX_BUFFERHEADERTYPE* pBufHeader[WBAMRENC_NUM_OF_PORTS]; 550 /** Number of input buffers at runtime */ 551 OMX_U32 nRuntimeInputBuffers; 552 553 /** Number of output buffers at runtime */ 554 OMX_U32 nRuntimeOutputBuffers; 555 556 OMX_CALLBACKTYPE cbInfo; 557 OMX_PORT_PARAM_TYPE* sPortParam; 558 OMX_PRIORITYMGMTTYPE* sPriorityMgmt; 559 560 #ifdef RESOURCE_MANAGER_ENABLED 561 RMPROXY_CALLBACKTYPE rmproxyCallback; 562 #endif 563 564 OMX_BOOL bPreempted; 565 566 OMX_PARAM_PORTDEFINITIONTYPE* pPortDef[WBAMRENC_NUM_OF_PORTS]; 567 OMX_PORT_PARAM_TYPE* pPortParamType; 568 OMX_AUDIO_PARAM_AMRTYPE* amrParams; 569 OMX_AUDIO_PARAM_PCMMODETYPE* pcmParams; 570 571 WBAMRENC_BUFFERHEADERTYPE_INFO BufInfo[WBAMRENC_NUM_OF_PORTS]; 572 WBAMRENC_PORT_TYPE *pCompPort[WBAMRENC_NUM_OF_PORTS]; 573 WBAMRENC_LCML_BUFHEADERTYPE *pLcmlBufHeader[WBAMRENC_NUM_OF_PORTS]; 574 /** This is component handle */ 575 OMX_COMPONENTTYPE* pHandle; 576 /** Current state of this component */ 577 OMX_STATETYPE curState; 578 /** The component thread handle */ 579 pthread_t ComponentThread; 580 /** The pipes for sending buffers to the thread */ 581 int dataPipe[2]; 582 /** The pipes for sending command to the thread */ 583 int cmdPipe[2]; 584 /** The pipes for sending cmd data to the thread */ 585 int cmdDataPipe[2]; 586 587 OMX_U32 efrMode; 588 589 OMX_U32 amrMode; 590 591 OMX_U32 dasfMode; 592 593 OMX_U32 frameMode; 594 595 OMX_U32 acdnMode; 596 597 OMX_U32 nMultiFrameMode; 598 599 OMX_S32 fdwrite; 600 601 OMX_S32 fdread; 602 603 /** Set to indicate component is stopping */ 604 OMX_U32 bIsThreadstop; 605 606 /** Count of number of buffers outstanding with bridge */ 607 OMX_U32 lcml_nIpBuf; 608 609 /** Count of number of buffers outstanding with bridge */ 610 OMX_U32 lcml_nOpBuf; 611 612 OMX_U32 app_nBuf; 613 614 OMX_U32 lcml_nCntIp; 615 616 OMX_U32 lcml_nCntOpReceived; 617 618 OMX_U32 bIsBufferOwned[WBAMRENC_NUM_OF_PORTS]; 619 620 OMX_U32 streamID; 621 622 OMX_U32 bCompThreadStarted; 623 624 OMX_U32 nVersion; 625 626 OMX_U32 amrMimeBytes[16]; 627 628 OMX_U32 amrIf2Bytes[16]; 629 630 OMX_U32 iHoldLen; 631 632 OMX_U32 nHoldLength; 633 634 OMX_U32 nFillThisBufferCount; 635 636 OMX_U32 nFillBufferDoneCount; 637 638 OMX_U32 nEmptyThisBufferCount; 639 640 OMX_U32 nEmptyBufferDoneCount; 641 642 OMX_U32 bInitParamsInitialized; 643 644 OMX_U32 nNumInputBufPending; 645 646 OMX_U32 nNumOutputBufPending; 647 648 OMX_U32 bDisableCommandPending; 649 650 OMX_U32 bDisableCommandParam; 651 652 OMX_U32 bEnableCommandPending; 653 654 OMX_U32 bEnableCommandParam; 655 656 OMX_HANDLETYPE pLcmlHandle; 657 658 OMX_PTR pMarkData; 659 660 OMX_MARKTYPE *pMarkBuf; 661 662 OMX_HANDLETYPE hMarkTargetComponent; 663 664 WBAMRENC_BUFFERLIST *pInputBufferList; 665 666 WBAMRENC_BUFFERLIST *pOutputBufferList; 667 668 LCML_STRMATTR *strmAttr; 669 670 WBAMRENC_TALGCtrl *pAlgParam; 671 672 WBAMRENC_TALGCtrlDTX *pAlgParamDTX; 673 674 WBAMRENC_AudioCodecParams *pParams; 675 676 OMX_STRING cComponentName; 677 678 OMX_VERSIONTYPE ComponentVersion; 679 680 OMX_BUFFERHEADERTYPE *pInputBufHdrPending[WBAMRENC_MAX_NUM_OF_BUFS]; 681 682 OMX_BUFFERHEADERTYPE *pOutputBufHdrPending[WBAMRENC_MAX_NUM_OF_BUFS]; 683 684 OMX_BUFFERHEADERTYPE *iMMFDataLastBuffer; 685 686 OMX_U8* pHoldBuffer, *pHoldBuffer2; 687 688 OMX_U8* iHoldBuffer; 689 690 /** Flag to set when socket node stop callback should not transition 691 component to OMX_StateIdle */ 692 OMX_U32 bNoIdleOnStop; 693 694 /** Flag set when socket node is stopped */ 695 OMX_U32 bDspStoppedWhileExecuting; 696 697 /** Number of outstanding FillBufferDone() calls */ 698 OMX_S32 nOutStandingFillDones; 699 700 OMX_S32 nOutStandingEmptyDones; 701 702 #ifndef UNDER_CE 703 pthread_mutex_t AlloBuf_mutex; 704 pthread_cond_t AlloBuf_threshold; 705 OMX_U8 AlloBuf_waitingsignal; 706 707 pthread_mutex_t InLoaded_mutex; 708 pthread_cond_t InLoaded_threshold; 709 OMX_U8 InLoaded_readytoidle; 710 711 pthread_mutex_t InIdle_mutex; 712 pthread_cond_t InIdle_threshold; 713 OMX_U8 InIdle_goingtoloaded; 714 715 pthread_mutex_t ToLoaded_mutex; 716 /* 717 sem_t allobuf; 718 sem_t inloaded; 719 sem_t inidle; 720 */ 721 #else 722 OMX_Event AlloBuf_event; 723 OMX_U8 AlloBuf_waitingsignal; 724 725 OMX_Event InLoaded_event; 726 OMX_U8 InLoaded_readytoidle; 727 728 OMX_Event InIdle_event; 729 OMX_U8 InIdle_goingtoloaded; 730 #endif 731 732 OMX_U8 nNumOfFramesSent; 733 734 OMX_U8 InBuf_Eos_alreadysent; 735 736 #ifdef __PERF_INSTRUMENTATION__ 737 PERF_OBJHANDLE pPERF, pPERFcomp; 738 OMX_U32 nLcml_nCntIp; 739 OMX_U32 nLcml_nCntOpReceived; 740 #endif 741 742 OMX_BUFFERHEADERTYPE *LastOutbuf; 743 OMX_BOOL bIsInvalidState; 744 745 OMX_STRING* sDeviceString; 746 void* ptrLibLCML; 747 748 /** Circular array to keep buffer timestamps */ 749 OMX_S64 arrBufIndex[WBAMRENC_MAX_NUM_OF_BUFS]; 750 /** Circular array to keep buffer nTickCounts */ 751 OMX_S64 arrTickCount[WBAMRENC_MAX_NUM_OF_BUFS]; 752 /** Index to arrBufIndex[], used for input buffer timestamps */ 753 OMX_U8 IpBufindex; 754 /** Index to arrBufIndex[], used for output buffer timestamps */ 755 OMX_U8 OpBufindex; 756 757 OMX_S8 ProcessingInputBuf; 758 OMX_S8 ProcessingOutputBuf; 759 760 OMX_BOOL bLoadedCommandPending; 761 762 OMX_PARAM_COMPONENTROLETYPE componentRole; 763 764 /* Pointer to OpenCore capabilities structure */ 765 PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags; 766 767 struct OMX_TI_Debug dbg; 768 769 /* Reference count for pending state change requests */ 770 OMX_U32 nPendingStateChangeRequests; 771 pthread_mutex_t mutexStateChangeRequest; 772 pthread_cond_t StateChangeCondition; 773 774 } WBAMRENC_COMPONENT_PRIVATE; 775 776 777 /* =================================================================================== */ 778 /** 779 * OMX_ComponentInit() Initializes component 780 * 781 * 782 * @param hComp OMX Handle 783 * 784 * @return OMX_ErrorNone = Successful 785 * Other error code = fail 786 * 787 */ 788 /* =================================================================================== */ 789 OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp); 790 /* =================================================================================== */ 791 /** 792 * WBAMRENC_StartComponentThread() Starts component thread 793 * 794 * 795 * @param hComp OMX Handle 796 * 797 * @return OMX_ErrorNone = Successful 798 * Other error code = fail 799 * 800 */ 801 /* =================================================================================== */ 802 OMX_ERRORTYPE WBAMRENC_StartComponentThread(OMX_HANDLETYPE pHandle); 803 /* =================================================================================== */ 804 /** 805 * WBAMRENC_StopComponentThread() Stops component thread 806 * 807 * 808 * @param hComp OMX Handle 809 * 810 * @return OMX_ErrorNone = Successful 811 * Other error code = fail 812 * 813 */ 814 /* =================================================================================== */ 815 OMX_ERRORTYPE WBAMRENC_StopComponentThread(OMX_HANDLETYPE pHandle); 816 /* =================================================================================== */ 817 /** 818 * WBAMRENC_FreeCompResources() Frees allocated memory 819 * 820 * 821 * @param hComp OMX Handle 822 * 823 * @return OMX_ErrorNone = Successful 824 * Other error code = fail 825 * 826 */ 827 /* =================================================================================== */ 828 OMX_ERRORTYPE WBAMRENC_FreeCompResources(OMX_HANDLETYPE pComponent); 829 /* =================================================================================== */ 830 /** 831 * WBAMRENC_GetCorrespondingLCMLHeader() Returns LCML header 832 * that corresponds to the given buffer 833 * 834 * @param pComponentPrivate Component private data 835 * 836 * @return OMX_ErrorNone = Successful 837 * Other error code = fail 838 */ 839 /* =================================================================================== */ 840 OMX_ERRORTYPE WBAMRENC_GetCorrespondingLCMLHeader(WBAMRENC_COMPONENT_PRIVATE *pComponentPrivate, 841 OMX_U8 *pBuffer, 842 OMX_DIRTYPE eDir, 843 WBAMRENC_LCML_BUFHEADERTYPE **ppLcmlHdr); 844 /* =================================================================================== */ 845 /** 846 * WBAMRENC_LCMLCallback() Callback from LCML 847 * 848 * @param event Codec Event 849 * 850 * @param args Arguments from LCML 851 * 852 * @return OMX_ErrorNone = Successful 853 * Other error code = fail 854 */ 855 /* =================================================================================== */ 856 OMX_ERRORTYPE WBAMRENC_LCMLCallback(TUsnCodecEvent event, 857 void * args [10]); 858 /* =================================================================================== */ 859 /** 860 * WBAMRENC_FillLCMLInitParams() Fills the parameters needed 861 * to initialize the LCML 862 * 863 * @param pHandle OMX Handle 864 * 865 * @param plcml_Init LCML initialization parameters 866 * 867 * @return OMX_ErrorNone = Successful 868 * Other error code = fail 869 * 870 */ 871 /* =================================================================================== */ 872 OMX_ERRORTYPE WBAMRENC_FillLCMLInitParams(OMX_HANDLETYPE pHandle, 873 LCML_DSP *plcml_Init, 874 OMX_U16 arr[]); 875 /* =================================================================================== */ 876 /** 877 * WBAMRENC_GetBufferDirection() Returns direction of pBufHeader 878 * 879 * @param pBufHeader Buffer header 880 * 881 * @param eDir Buffer direction 882 * 883 * @param pComponentPrivate Component private data 884 * 885 * @return OMX_ErrorNone = Successful 886 * Other error code = fail 887 */ 888 /* =================================================================================== */ 889 OMX_ERRORTYPE WBAMRENC_GetBufferDirection(OMX_BUFFERHEADERTYPE *pBufHeader, 890 OMX_DIRTYPE *eDir); 891 /* =========================================================== */ 892 /** 893 * WBAMRENC_HandleCommand() Handles commands sent via SendCommand() 894 * 895 * @param pComponentPrivate Component private data 896 * 897 * @return OMX_ErrorNone = Successful 898 * Other error code = fail 899 * @return OMX_ErrorNone = Successful 900 * Other error code = fail 901 */ 902 /* =================================================================================== */ 903 OMX_U32 WBAMRENC_HandleCommand(WBAMRENC_COMPONENT_PRIVATE *pComponentPrivate, 904 OMX_COMMANDTYPE cmd, 905 OMX_U32 cmdData); 906 /* =================================================================================== */ 907 /** 908 * WBAMRENC_HandleDataBufFromApp() Handles data buffers received 909 * from the IL Client 910 * 911 * @param pComponentPrivate Component private data 912 * 913 * @return OMX_ErrorNone = Successful 914 * Other error code = fail 915 * @return OMX_ErrorNone = Successful 916 * Other error code = fail 917 */ 918 /* =================================================================================== */ 919 OMX_ERRORTYPE WBAMRENC_HandleDataBufFromApp(OMX_BUFFERHEADERTYPE *pBufHeader, 920 WBAMRENC_COMPONENT_PRIVATE *pComponentPrivate); 921 /* =================================================================================== */ 922 /** 923 * WBAMRENC_GetLCMLHandle() Get the handle to the LCML 924 * 925 * 926 * @return OMX_ErrorNone = Successful 927 * Other error code = fail 928 */ 929 /* =================================================================================== */ 930 OMX_HANDLETYPE WBAMRENC_GetLCMLHandle(WBAMRENC_COMPONENT_PRIVATE *pComponentPrivate); 931 /* =================================================================================== */ 932 /** 933 * WBAMRENC_FreeLCMLHandle() Frees the handle to the LCML 934 * 935 * 936 * @return OMX_ErrorNone = Successful 937 * Other error code = fail 938 */ 939 /* =================================================================================== */ 940 OMX_ERRORTYPE WBAMRENC_FreeLCMLHandle(WBAMRENC_COMPONENT_PRIVATE *pComponentPrivate); 941 /* =================================================================================== */ 942 /** 943 * WBAMRENC_CleanupInitParams() Starts component thread 944 * 945 * @param pComponent OMX Handle 946 * 947 * @return OMX_ErrorNone = Successful 948 * Other error code = fail 949 */ 950 /* =================================================================================== */ 951 OMX_ERRORTYPE WBAMRENC_CleanupInitParams(OMX_HANDLETYPE pHandle); 952 /* =================================================================================== */ 953 /** 954 * WBAMRENC_SetPending() Called when the component queues a buffer 955 * to the LCML 956 * 957 * @param pComponentPrivate Component private data 958 * 959 * @param pBufHdr Buffer header 960 * 961 * @param eDir Direction of the buffer 962 * 963 * @return None 964 */ 965 /* =================================================================================== */ 966 void WBAMRENC_SetPending(WBAMRENC_COMPONENT_PRIVATE *pComponentPrivate, 967 OMX_BUFFERHEADERTYPE *pBufHdr, 968 OMX_DIRTYPE eDir, 969 OMX_U32 lineNumber); 970 /* =================================================================================== */ 971 /** 972 * WBAMRENC_ClearPending() Called when a buffer is returned 973 * from the LCML 974 * 975 * @param pComponentPrivate Component private data 976 * 977 * @param pBufHdr Buffer header 978 * 979 * @param eDir Direction of the buffer 980 * 981 * @return None 982 */ 983 /* =================================================================================== */ 984 void WBAMRENC_ClearPending(WBAMRENC_COMPONENT_PRIVATE *pComponentPrivate, 985 OMX_BUFFERHEADERTYPE *pBufHdr, 986 OMX_DIRTYPE eDir, 987 OMX_U32 lineNumber); 988 /* =================================================================================== */ 989 /** 990 * WBAMRENC_IsPending() 991 * 992 * 993 * @param pComponentPrivate Component private data 994 * 995 * @return OMX_ErrorNone = Successful 996 * Other error code = fail 997 */ 998 /* =================================================================================== */ 999 OMX_U32 WBAMRENC_IsPending(WBAMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1000 OMX_BUFFERHEADERTYPE *pBufHdr, 1001 OMX_DIRTYPE eDir); 1002 /* =================================================================================== */ 1003 /** 1004 * WBAMRENC_FillLCMLInitParamsEx() Fills the parameters needed 1005 * to initialize the LCML without recreating the socket node 1006 * 1007 * @param pComponent OMX Handle 1008 * 1009 * @return None 1010 */ 1011 /* =================================================================================== */ 1012 OMX_ERRORTYPE WBAMRENC_FillLCMLInitParamsEx(OMX_HANDLETYPE pComponent); 1013 /* =================================================================================== */ 1014 /** 1015 * WBAMRENC_IsValid() Returns whether a buffer is valid 1016 * 1017 * 1018 * @param pComponentPrivate Component private data 1019 * 1020 * @param pBuffer Data buffer 1021 * 1022 * @param eDir Buffer direction 1023 * 1024 * @return OMX_True = Valid 1025 * OMX_False= Invalid 1026 */ 1027 /* =================================================================================== */ 1028 OMX_U32 WBAMRENC_IsValid(WBAMRENC_COMPONENT_PRIVATE *pComponentPrivate, 1029 OMX_U8 *pBuffer, 1030 OMX_DIRTYPE eDir); 1031 1032 OMX_ERRORTYPE OMX_DmmMap(DSP_HPROCESSOR ProcHandle, int size, void* pArmPtr, DMM_BUFFER_OBJ* pDmmBuf, struct OMX_TI_Debug dbg); 1033 OMX_ERRORTYPE OMX_DmmUnMap(DSP_HPROCESSOR ProcHandle, void* pMapPtr, void* pResPtr, struct OMX_TI_Debug dbg); 1034 1035 #ifdef RESOURCE_MANAGER_ENABLED 1036 void WBAMRENC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData); 1037 #endif 1038 1039 void WBAMRENC_HandleUSNError (WBAMRENC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 arg); 1040 1041 /*===============================================================*/ 1042 1043 typedef enum { 1044 IUALG_CMD_STOP = 0, 1045 IUALG_CMD_PAUSE = 1, 1046 IUALG_CMD_GETSTATUS = 2, 1047 IUALG_CMD_SETSTATUS = 3, 1048 IUALG_CMD_USERSETCMDSTART = 100, 1049 IUALG_CMD_USERGETCMDSTART = 150, 1050 IUALG_CMD_FLUSH = 0x100 1051 } IUALG_Cmd; 1052 1053 typedef enum { 1054 ALGCMD_BITRATE = IUALG_CMD_USERSETCMDSTART, 1055 ALGCMD_DTX 1056 1057 } eSPEECHENCODE_AlgCmd; 1058 1059 OMX_ERRORTYPE AddStateTransition(WBAMRENC_COMPONENT_PRIVATE* pComponentPrivate); 1060 OMX_ERRORTYPE RemoveStateTransition(WBAMRENC_COMPONENT_PRIVATE* pComponentPrivate, OMX_BOOL bEnableSignal); 1061 1062 1063 #endif /* OMX_WBAMRENC_UTILS__H */ 1064