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_Video_Dec_Utils.c 30 * 31 * This file implements OMX Component for MPEG-4 decoder that 32 * is fully compliant with the Khronos OMX specification 1.0. 33 * 34 * @path $(CSLPATH)\src 35 * 36 * @rev 0.1 37 */ 38 /* -------------------------------------------------------------------------- */ 39 /* ============================================================================= 40 *! 41 *! Revision History 42 *! =================================== 43 *! 44 *! 02-Feb-2006 mf: Revisions appear in reverse chronological order; 45 *! that is, newest first. The date format is dd-Mon-yyyy. 46 * =========================================================================== */ 47 48 /* ------compilation control switches ----------------------------------------*/ 49 /******************************************************************************* 50 * INCLUDE FILES 51 *******************************************************************************/ 52 /* ----- system and platform files -------------------------------------------*/ 53 #include "OMX_VideoDecoder.h" 54 #include "OMX_VideoDec_Utils.h" 55 #include "OMX_VideoDec_DSP.h" 56 #include "OMX_VideoDec_Thread.h" 57 #define LOG_TAG "TI_Video_Decoder" 58 /*----------------------------------------------------------------------------*/ 59 /** 60 * VIDDEC_GetRMFrecuency() Return the value for frecuecny to use RM. 61 **/ 62 /*----------------------------------------------------------------------------*/ 63 OMX_U32 VIDDEC_GetRMFrecuency(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) 64 { 65 OMX_U32 nReturnValue = VIDDEC_MPU; 66 67 OMX_PRINT1(pComponentPrivate->dbg, "+++ENTERING\n"); 68 #ifdef RESOURCE_MANAGER_ENABLED 69 /*resolution for greater than CIF*/ 70 if ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > VIDDEC_CIF_WIDTH) || 71 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > VIDDEC_CIF_HEIGHT)) { 72 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 73 nReturnValue = VIDDEC_RM_FREC_H264_VGA; 74 } 75 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 76 nReturnValue = VIDDEC_RM_FREC_WMV_VGA; 77 } 78 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4) { 79 if ((OMX_U16)pComponentPrivate->pInPortDef->format.video.nFrameHeight > VIDDEC_D1MAX_HEIGHT || 80 (OMX_U16)pComponentPrivate->pInPortDef->format.video.nFrameWidth > VIDDEC_D1MAX_WIDTH) 81 { 82 nReturnValue = VIDDEC_RM_FREC_MPEG4_720P; 83 } 84 else 85 { 86 nReturnValue = VIDDEC_RM_FREC_MPEG4_VGA; 87 } 88 } 89 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 90 nReturnValue = VIDDEC_RM_FREC_MPEG2_VGA; 91 } 92 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 93 nReturnValue = VIDDEC_RM_FREC_H263_VGA; 94 } 95 #ifdef VIDDEC_SPARK_CODE 96 else if (VIDDEC_SPARKCHECK) { 97 nReturnValue = VIDDEC_RM_FREC_SPARK_VGA; 98 } 99 #endif 100 else { 101 nReturnValue = VIDDEC_MPU; 102 } 103 } 104 /*resolution from QCIF up to CIF*/ 105 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= VIDDEC_CIF_WIDTH) && 106 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > VIDDEC_QCIF_WIDTH)) || 107 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= VIDDEC_CIF_HEIGHT) && 108 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > VIDDEC_QCIF_HEIGHT))) { 109 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 110 nReturnValue = VIDDEC_RM_FREC_H264_CIF; 111 } 112 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 113 nReturnValue = VIDDEC_RM_FREC_WMV_CIF; 114 } 115 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4) { 116 nReturnValue = VIDDEC_RM_FREC_MPEG4_CIF; 117 } 118 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 119 nReturnValue = VIDDEC_RM_FREC_MPEG2_CIF; 120 } 121 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 122 nReturnValue = VIDDEC_RM_FREC_H263_CIF; 123 } 124 #ifdef VIDDEC_SPARK_CODE 125 else if (VIDDEC_SPARKCHECK) { 126 nReturnValue = VIDDEC_RM_FREC_SPARK_CIF; 127 } 128 #endif 129 else { 130 nReturnValue = VIDDEC_MPU; 131 } 132 } 133 /*resolution up to QCIF*/ 134 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= VIDDEC_QCIF_WIDTH) && 135 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth >= VIDDEC_MIN_WIDTH)) || 136 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= VIDDEC_QCIF_HEIGHT) && 137 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight >= VIDDEC_MIN_HEIGHT))) { 138 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 139 nReturnValue = VIDDEC_RM_FREC_H264_QCIF; 140 } 141 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 142 nReturnValue = VIDDEC_RM_FREC_WMV_QCIF; 143 } 144 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4) { 145 nReturnValue = VIDDEC_RM_FREC_MPEG4_QCIF; 146 } 147 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 148 nReturnValue = VIDDEC_RM_FREC_MPEG2_QCIF; 149 } 150 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 151 nReturnValue = VIDDEC_RM_FREC_H263_QCIF; 152 } 153 #ifdef VIDDEC_SPARK_CODE 154 else if (VIDDEC_SPARKCHECK) { 155 nReturnValue = VIDDEC_RM_FREC_SPARK_QCIF; 156 } 157 #endif 158 else { 159 nReturnValue = VIDDEC_MPU; 160 } 161 } 162 else { 163 nReturnValue = VIDDEC_MPU; 164 } 165 OMX_PRDSP2(pComponentPrivate->dbg, "Used RM Frec value = %d\n",(int)nReturnValue); 166 #else 167 OMX_PRDSP2(pComponentPrivate->dbg, "Used RM Frec defaulted value = %d\n",(int)nReturnValue); 168 #endif 169 OMX_PRINT1(pComponentPrivate->dbg, "---EXITING\n"); 170 return nReturnValue; 171 172 } 173 174 OMX_ERRORTYPE VIDDEC_Queue_Init(VIDDEC_QUEUE_TYPE *queue, VIDDEC_QUEUE_TYPES type) 175 { 176 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 177 OMX_U32 count; 178 179 queue->nHead = 0; 180 queue->nTail = 0; 181 queue->nElements = 0; 182 183 switch(type) 184 { 185 case VIDDEC_QUEUE_OMX_U32: 186 queue->Elements = (void*)malloc(VIDDEC_MAX_QUEUE_SIZE*sizeof(OMX_U32)); 187 /*OMX_MALLOC_STRUCT_SIZED(queue->Elements, void, VIDDEC_MAX_QUEUE_SIZE*sizeof(OMX_U32));*/ 188 break; 189 case VIDDEC_QUEUE_OMX_MARKTYPE: 190 queue->Elements = (void*)malloc(VIDDEC_MAX_QUEUE_SIZE*sizeof(OMX_MARKTYPE)); 191 /*OMX_MALLOC_STRUCT_SIZED(queue->Elements, void, VIDDEC_MAX_QUEUE_SIZE*sizeof(OMX_MARKTYPE));*/ 192 break; 193 } 194 195 pthread_mutex_init(&(queue->mMutex), NULL); 196 197 for(count=0; count < VIDDEC_MAX_QUEUE_SIZE; count++) 198 { 199 queue->CounterElements[count] = 0; 200 } 201 202 eError = OMX_ErrorNone; 203 /*EXIT:*/ 204 return eError; 205 } 206 207 OMX_ERRORTYPE VIDDEC_Queue_Flush(VIDDEC_QUEUE_TYPE *queue) 208 { 209 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 210 OMX_U32 count; 211 212 if (pthread_mutex_lock (&(queue->mMutex)) != 0) { 213 eError = OMX_ErrorUndefined; 214 goto EXIT; 215 } 216 queue->nHead = 0; 217 queue->nTail = 0; 218 queue->nElements = 0; 219 220 for(count=0; count < VIDDEC_MAX_QUEUE_SIZE; count++) 221 { 222 queue->CounterElements[count] = 0; 223 } 224 eError = OMX_ErrorNone; 225 226 if (pthread_mutex_unlock (&(queue->mMutex)) != 0) { 227 eError = OMX_ErrorUndefined; 228 } 229 230 EXIT: 231 return eError; 232 } 233 234 OMX_ERRORTYPE VIDDEC_Queue_Add(VIDDEC_QUEUE_TYPE *queue, OMX_PTR pElement, VIDDEC_QUEUE_TYPES type) 235 { 236 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 237 238 if (pthread_mutex_lock (&(queue->mMutex)) != 0) { 239 eError = OMX_ErrorUndefined; 240 goto EXIT; 241 } 242 if(queue->nElements == 0) 243 { 244 switch(type) 245 { 246 case VIDDEC_QUEUE_OMX_U32: 247 { 248 OMX_U32 *pLocal = (OMX_U32 *)queue->Elements; 249 pLocal[queue->nHead] = *(OMX_U32 *)pElement; 250 } 251 break; 252 case VIDDEC_QUEUE_OMX_MARKTYPE: 253 { 254 OMX_MARKTYPE *pLocal = (OMX_MARKTYPE *)queue->Elements; 255 pLocal[queue->nHead] = *(OMX_MARKTYPE *)pElement; 256 /*memcpy(&pLocal[queue->nHead], pElement, sizeof(OMX_MARKTYPE));*/ 257 } 258 break; 259 } 260 queue->CounterElements[queue->nHead] = 1; 261 queue->nElements++; 262 eError = OMX_ErrorNone; 263 } 264 else 265 { 266 switch(type) 267 { 268 case VIDDEC_QUEUE_OMX_U32: 269 { 270 OMX_U32 *pLocal = (OMX_U32 *)queue->Elements; 271 272 if(pLocal[queue->nHead] == *(OMX_U32 *)pElement) 273 { 274 queue->CounterElements[queue->nHead]++; 275 eError = OMX_ErrorNone; 276 } 277 else 278 { 279 if(queue->nElements >= VIDDEC_MAX_QUEUE_SIZE) 280 { 281 eError = OMX_ErrorInsufficientResources; 282 goto UNLOCK; 283 } 284 queue->nHead++; 285 if(queue->nHead >= VIDDEC_MAX_QUEUE_SIZE) 286 { 287 queue->nHead = 0; 288 } 289 pLocal[queue->nHead] = *(OMX_U32 *)pElement; 290 queue->CounterElements[queue->nHead] = 1; 291 queue->nElements++; 292 } 293 } 294 break; 295 case VIDDEC_QUEUE_OMX_MARKTYPE: 296 { 297 OMX_MARKTYPE *pLocal = (OMX_MARKTYPE *)queue->Elements; 298 299 if(pLocal[queue->nHead].hMarkTargetComponent == ((OMX_MARKTYPE *)pElement)->hMarkTargetComponent 300 && pLocal[queue->nHead].pMarkData == ((OMX_MARKTYPE *)pElement)->pMarkData) 301 { 302 queue->CounterElements[queue->nHead]++; 303 eError = OMX_ErrorNone; 304 } 305 else 306 { 307 if(queue->nElements >= VIDDEC_MAX_QUEUE_SIZE) 308 { 309 eError = OMX_ErrorInsufficientResources; 310 goto UNLOCK; 311 } 312 queue->nHead++; 313 if(queue->nHead >= VIDDEC_MAX_QUEUE_SIZE) 314 { 315 queue->nHead = 0; 316 } 317 pLocal[queue->nHead] = *(OMX_MARKTYPE *)pElement; 318 queue->CounterElements[queue->nHead] = 1; 319 queue->nElements++; 320 } 321 } 322 break; 323 } 324 325 eError = OMX_ErrorNone; 326 } 327 UNLOCK: 328 if (pthread_mutex_unlock (&(queue->mMutex)) != 0) { 329 eError = OMX_ErrorUndefined; 330 } 331 EXIT: 332 return eError; 333 334 } 335 336 OMX_ERRORTYPE VIDDEC_Queue_Remove(VIDDEC_QUEUE_TYPE *queue, OMX_PTR pElement, VIDDEC_QUEUE_TYPES type) 337 { 338 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 339 340 if (pthread_mutex_lock (&(queue->mMutex)) != 0) { 341 eError = OMX_ErrorUndefined; 342 goto EXIT; 343 } 344 345 if(queue->nElements > 0) 346 { 347 if(pElement) 348 { 349 switch(type) 350 { 351 case VIDDEC_QUEUE_OMX_U32: 352 { 353 OMX_U32 *pLocal = (OMX_U32 *)queue->Elements; 354 *(OMX_U32 *)pElement = pLocal[queue->nTail]; 355 break; 356 } 357 case VIDDEC_QUEUE_OMX_MARKTYPE: 358 { 359 OMX_MARKTYPE *pLocal = (OMX_MARKTYPE *)queue->Elements; 360 *(OMX_MARKTYPE *)pElement = pLocal[queue->nTail]; 361 break; 362 } 363 } 364 } 365 queue->CounterElements[queue->nTail]--; 366 if(queue->CounterElements[queue->nTail] == 0) 367 { 368 queue->nElements--; 369 if(queue->nElements > 0) 370 { 371 queue->nTail++; 372 if(queue->nTail == VIDDEC_MAX_QUEUE_SIZE) 373 { 374 queue->nTail = 0; 375 } 376 } 377 } 378 eError = OMX_ErrorNone; 379 } 380 381 if (pthread_mutex_unlock (&(queue->mMutex)) != 0) { 382 eError = OMX_ErrorUndefined; 383 } 384 EXIT: 385 return eError; 386 } 387 388 OMX_ERRORTYPE VIDDEC_Queue_Get_Tail(VIDDEC_QUEUE_TYPE *queue, OMX_PTR pElement, VIDDEC_QUEUE_TYPES type) 389 { 390 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 391 392 if (pthread_mutex_lock (&(queue->mMutex)) != 0) { 393 eError = OMX_ErrorUndefined; 394 goto EXIT; 395 } 396 if(queue->nElements > 0) 397 { 398 switch(type) 399 { 400 case VIDDEC_QUEUE_OMX_U32: 401 { 402 OMX_U32 *pLocal = (OMX_U32 *)queue->Elements; 403 *(OMX_U32 *)pElement = pLocal[queue->nTail]; 404 break; 405 } 406 case VIDDEC_QUEUE_OMX_MARKTYPE: 407 { 408 OMX_MARKTYPE *pLocal = (OMX_MARKTYPE *)queue->Elements; 409 *(OMX_MARKTYPE *)pElement = pLocal[queue->nTail]; 410 break; 411 } 412 } 413 eError = OMX_ErrorNone; 414 } 415 if (pthread_mutex_unlock (&(queue->mMutex)) != 0) { 416 eError = OMX_ErrorUndefined; 417 } 418 419 EXIT: 420 return eError; 421 } 422 423 OMX_ERRORTYPE VIDDEC_Queue_Replace_Tail(VIDDEC_QUEUE_TYPE *queue, OMX_PTR pElement, VIDDEC_QUEUE_TYPES type) 424 { 425 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 426 427 if (pthread_mutex_lock (&(queue->mMutex)) != 0) { 428 eError = OMX_ErrorUndefined; 429 goto EXIT; 430 } 431 if(queue->nElements > 0) 432 { 433 switch(type) 434 { 435 case VIDDEC_QUEUE_OMX_U32: 436 { 437 OMX_U32 *pLocal = (OMX_U32 *)queue->Elements; 438 if(*(OMX_U32 *)pElement != pLocal[queue->nTail]) 439 { 440 if(queue->CounterElements[queue->nTail] != 1) 441 { 442 if(queue->nElements >= VIDDEC_MAX_QUEUE_SIZE) 443 { 444 eError = OMX_ErrorInsufficientResources; 445 goto UNLOCK; 446 } 447 queue->CounterElements[queue->nTail]--; 448 queue->nTail--; 449 if(queue->nTail >= VIDDEC_MAX_QUEUE_SIZE) 450 { 451 queue->nTail = VIDDEC_MAX_QUEUE_SIZE-1; 452 } 453 queue->CounterElements[queue->nTail] = 1; 454 queue->nElements++; 455 } 456 pLocal[queue->nTail] = *(OMX_U32 *)pElement; 457 eError = OMX_ErrorNone; 458 goto UNLOCK; 459 } 460 break; 461 } 462 case VIDDEC_QUEUE_OMX_MARKTYPE: 463 { 464 OMX_MARKTYPE *pLocal = (OMX_MARKTYPE *)queue->Elements; 465 if(pLocal[queue->nTail].hMarkTargetComponent != ((OMX_MARKTYPE *)pElement)->hMarkTargetComponent 466 || pLocal[queue->nTail].pMarkData != ((OMX_MARKTYPE *)pElement)->pMarkData) 467 { 468 if(queue->CounterElements[queue->nTail] != 1) 469 { 470 if(queue->nElements >= VIDDEC_MAX_QUEUE_SIZE) 471 { 472 eError = OMX_ErrorInsufficientResources; 473 goto UNLOCK; 474 } 475 queue->CounterElements[queue->nTail]--; 476 queue->nTail--; 477 if(queue->nTail >= VIDDEC_MAX_QUEUE_SIZE) 478 { 479 queue->nTail = VIDDEC_MAX_QUEUE_SIZE-1; 480 } 481 queue->CounterElements[queue->nTail] = 1; 482 queue->nElements++; 483 } 484 pLocal[queue->nTail] = *(OMX_MARKTYPE *)pElement; 485 eError = OMX_ErrorNone; 486 goto UNLOCK; 487 } 488 break; 489 } 490 } 491 } 492 UNLOCK: 493 if (pthread_mutex_unlock (&(queue->mMutex)) != 0) { 494 eError = OMX_ErrorUndefined; 495 } 496 EXIT: 497 return eError; 498 } 499 500 OMX_ERRORTYPE VIDDEC_Queue_Free(VIDDEC_QUEUE_TYPE *queue) 501 { 502 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 503 504 queue->nHead = 0; 505 queue->nTail = 0; 506 queue->nElements = 0; 507 508 if(queue->Elements) 509 { 510 free(queue->Elements); 511 } 512 queue->Elements = NULL; 513 514 if (pthread_mutex_destroy (&(queue->mMutex)) != 0) { 515 eError = OMX_ErrorUndefined; 516 goto EXIT; 517 } 518 519 eError = OMX_ErrorNone; 520 EXIT: 521 return eError; 522 } 523 524 /*----------------------------------------------------------------------------*/ 525 /** 526 * VIDDEC_CircBuf_Init() 527 **/ 528 /*----------------------------------------------------------------------------*/ 529 OMX_ERRORTYPE VIDDEC_CircBuf_Init(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, VIDDEC_CBUFFER_TYPE nTypeIndex, VIDDEC_PORT_INDEX nPortIndex) 530 { 531 OMX_ERRORTYPE eError = OMX_ErrorNone; 532 VIDDEC_CIRCULAR_BUFFER *pTempCBuffer = NULL; 533 OMX_U32 nCount = 0; 534 535 if(nTypeIndex == VIDDEC_CBUFFER_TIMESTAMP){ 536 pTempCBuffer = &pComponentPrivate->pCompPort[nPortIndex]->eTimeStamp; 537 } 538 else { 539 eError = OMX_ErrorBadParameter; 540 return eError; 541 } 542 #ifdef VIDDEC_CBUFFER_LOCK 543 if(pTempCBuffer->m_lock != NULL) { 544 free(pTempCBuffer->m_lock); 545 pTempCBuffer->m_lock = NULL; 546 } 547 OMX_MALLOC_STRUCT(pTempCBuffer->m_lock, pthread_mutex_t,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel3]); 548 /*pTempCBuffer->m_lock = malloc(sizeof(pthread_mutex_t));*/ 549 pthread_mutex_init(pTempCBuffer->m_lock, NULL); 550 #endif 551 for(nCount = 0; nCount >= CBUFFER_SIZE; nCount++) { 552 pTempCBuffer->pElement[nCount] = NULL; 553 } 554 EXIT: 555 pTempCBuffer->nCount = 0; 556 pTempCBuffer->nHead = 0; 557 pTempCBuffer->nTail = 0; 558 559 return eError; 560 } 561 562 /*----------------------------------------------------------------------------*/ 563 /** 564 * VIDDEC_CircBuf_Flush() 565 **/ 566 /*----------------------------------------------------------------------------*/ 567 OMX_ERRORTYPE VIDDEC_CircBuf_Flush(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, VIDDEC_CBUFFER_TYPE nTypeIndex, VIDDEC_PORT_INDEX nPortIndex) 568 { 569 OMX_ERRORTYPE eError = OMX_ErrorNone; 570 VIDDEC_CIRCULAR_BUFFER *pTempCBuffer = NULL; 571 OMX_U32 nCount = 0; 572 573 if(nTypeIndex == VIDDEC_CBUFFER_TIMESTAMP){ 574 pTempCBuffer = &pComponentPrivate->pCompPort[nPortIndex]->eTimeStamp; 575 } 576 else { 577 eError = OMX_ErrorBadParameter; 578 return eError; 579 } 580 #ifdef VIDDEC_CBUFFER_LOCK 581 if(pthread_mutex_lock(pTempCBuffer->m_lock) != 0) { 582 eError = OMX_ErrorHardware; 583 return eError; 584 } 585 #endif 586 for (nCount = pTempCBuffer->nTail; nCount <= pTempCBuffer->nHead; nCount++){ 587 pTempCBuffer->pElement[nCount] = NULL; 588 } 589 pTempCBuffer->nCount = 0; 590 pTempCBuffer->nHead = 0; 591 pTempCBuffer->nTail = 0; 592 593 #ifdef VIDDEC_CBUFFER_LOCK 594 if(pthread_mutex_unlock(pTempCBuffer->m_lock) != 0) { 595 eError = OMX_ErrorHardware; 596 return eError; 597 } 598 #endif 599 return eError; 600 } 601 602 /*----------------------------------------------------------------------------*/ 603 /** 604 * VIDDEC_CircBuf_DeInit() 605 **/ 606 /*----------------------------------------------------------------------------*/ 607 OMX_ERRORTYPE VIDDEC_CircBuf_DeInit(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, VIDDEC_CBUFFER_TYPE nTypeIndex, VIDDEC_PORT_INDEX nPortIndex) 608 { 609 OMX_ERRORTYPE eError = OMX_ErrorNone; 610 VIDDEC_CIRCULAR_BUFFER *pTempCBuffer = NULL; 611 OMX_U32 nCount = 0; 612 613 if(nTypeIndex == VIDDEC_CBUFFER_TIMESTAMP){ 614 pTempCBuffer = &pComponentPrivate->pCompPort[nPortIndex]->eTimeStamp; 615 } 616 else { 617 eError = OMX_ErrorBadParameter; 618 return eError; 619 } 620 #ifdef VIDDEC_CBUFFER_LOCK 621 if(pTempCBuffer->m_lock != NULL) { 622 free(pTempCBuffer->m_lock); 623 pTempCBuffer->m_lock = NULL; 624 } 625 #endif 626 for(nCount = 0; nCount >= CBUFFER_SIZE; nCount++) { 627 pTempCBuffer->pElement[nCount] = NULL; 628 } 629 return eError; 630 } 631 632 /*----------------------------------------------------------------------------*/ 633 /** 634 * VIDDEC_CircBuf_Add() set the last element in the Circular Buffer 635 * return the error number in case of exist an error. 636 **/ 637 /*----------------------------------------------------------------------------*/ 638 OMX_ERRORTYPE VIDDEC_CircBuf_Add(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, VIDDEC_CBUFFER_TYPE nTypeIndex, VIDDEC_PORT_INDEX nPortIndex, OMX_PTR pElement) 639 { 640 OMX_ERRORTYPE eError = OMX_ErrorNone; 641 VIDDEC_CIRCULAR_BUFFER *pTempCBuffer = NULL; 642 643 if(nTypeIndex == VIDDEC_CBUFFER_TIMESTAMP){ 644 pTempCBuffer = &pComponentPrivate->pCompPort[nPortIndex]->eTimeStamp; 645 } 646 else { 647 eError = OMX_ErrorBadParameter; 648 return eError; 649 } 650 #ifdef VIDDEC_CBUFFER_LOCK 651 if(pthread_mutex_lock(pTempCBuffer->m_lock) != 0) { 652 eError = OMX_ErrorHardware; 653 return eError; 654 } 655 #endif 656 pTempCBuffer->pElement[pTempCBuffer->nHead++] = pElement; 657 pTempCBuffer->nCount++; 658 if(pTempCBuffer->nHead >= CBUFFER_SIZE){ 659 pTempCBuffer->nHead = 0; 660 } 661 #ifdef VIDDEC_CBUFFER_LOCK 662 if(pthread_mutex_unlock(pTempCBuffer->m_lock) != 0) { 663 eError = OMX_ErrorHardware; 664 return eError; 665 } 666 #endif 667 return eError; 668 } 669 670 /*----------------------------------------------------------------------------*/ 671 /** 672 * VIDDEC_CircBuf_Remove() get the first element in the Circular Buffer 673 * return the error number in case of exist an error. 674 **/ 675 /*----------------------------------------------------------------------------*/ 676 OMX_ERRORTYPE VIDDEC_CircBuf_Remove(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, VIDDEC_CBUFFER_TYPE nTypeIndex, VIDDEC_PORT_INDEX nPortIndex, OMX_PTR* pElement) 677 { 678 OMX_ERRORTYPE eError = OMX_ErrorNone; 679 VIDDEC_CIRCULAR_BUFFER *pTempCBuffer = NULL; 680 681 if(nTypeIndex == VIDDEC_CBUFFER_TIMESTAMP){ 682 pTempCBuffer = &pComponentPrivate->pCompPort[nPortIndex]->eTimeStamp; 683 } 684 else { 685 eError = OMX_ErrorBadParameter; 686 return eError; 687 } 688 #ifdef VIDDEC_CBUFFER_LOCK 689 if(pthread_mutex_lock(pTempCBuffer->m_lock) != 0) { 690 eError = OMX_ErrorHardware; 691 return eError; 692 } 693 #endif 694 if(pTempCBuffer->nCount) 695 { 696 *pElement = pTempCBuffer->pElement[pTempCBuffer->nTail]; 697 pTempCBuffer->pElement[pTempCBuffer->nTail++] = NULL; 698 pTempCBuffer->nCount--; 699 if(pTempCBuffer->nTail >= CBUFFER_SIZE){ 700 pTempCBuffer->nTail = 0; 701 } 702 } 703 else 704 { 705 *pElement = NULL; 706 } 707 #ifdef VIDDEC_CBUFFER_LOCK 708 if(pthread_mutex_unlock(pTempCBuffer->m_lock) != 0) { 709 eError = OMX_ErrorHardware; 710 return eError; 711 } 712 #endif 713 return eError; 714 } 715 716 /*----------------------------------------------------------------------------*/ 717 /** 718 * VIDDEC_CircBuf_Count() get the number of elements in the Circular Buffer 719 * return the error number in case of exist an error. 720 **/ 721 /*----------------------------------------------------------------------------*/ 722 OMX_ERRORTYPE VIDDEC_CircBuf_Count(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, VIDDEC_CBUFFER_TYPE nTypeIndex, VIDDEC_PORT_INDEX nPortIndex, OMX_U8* pCount) 723 { 724 OMX_ERRORTYPE eError = OMX_ErrorNone; 725 VIDDEC_CIRCULAR_BUFFER *pTempCBuffer = NULL; 726 727 if(nTypeIndex == VIDDEC_CBUFFER_TIMESTAMP){ 728 pTempCBuffer = &pComponentPrivate->pCompPort[nPortIndex]->eTimeStamp; 729 } 730 else { 731 eError = OMX_ErrorBadParameter; 732 pCount = 0; 733 return eError; 734 } 735 #ifdef VIDDEC_CBUFFER_LOCK 736 if(pthread_mutex_lock(pTempCBuffer->m_lock) != 0) { 737 eError = OMX_ErrorHardware; 738 return eError; 739 } 740 #endif 741 742 *pCount = pTempCBuffer->nCount; 743 744 #ifdef VIDDEC_CBUFFER_LOCK 745 if(pthread_mutex_unlock(pTempCBuffer->m_lock) != 0) { 746 eError = OMX_ErrorHardware; 747 return eError; 748 } 749 #endif 750 return eError; 751 } 752 753 /*----------------------------------------------------------------------------*/ 754 /** 755 * VIDDEC_CircBuf_Head() get the number of elements in the Circular Buffer 756 * return the error number in case of exist an error. 757 **/ 758 /*----------------------------------------------------------------------------*/ 759 OMX_U8 VIDDEC_CircBuf_GetHead(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, VIDDEC_CBUFFER_TYPE nTypeIndex, VIDDEC_PORT_INDEX nPortIndex) 760 { 761 /*OMX_ERRORTYPE eError = OMX_ErrorNone;*/ 762 VIDDEC_CIRCULAR_BUFFER *pTempCBuffer = NULL; 763 OMX_U8 ucHead = 0; 764 765 if(nTypeIndex == VIDDEC_CBUFFER_TIMESTAMP){ 766 pTempCBuffer = &pComponentPrivate->pCompPort[nPortIndex]->eTimeStamp; 767 } 768 else { 769 ucHead = 0; 770 return 0; 771 } 772 #ifdef VIDDEC_CBUFFER_LOCK 773 if(pthread_mutex_lock(pTempCBuffer->m_lock) != 0) { 774 return 0; 775 } 776 #endif 777 778 ucHead = pTempCBuffer->nHead; 779 780 #ifdef VIDDEC_CBUFFER_LOCK 781 if(pthread_mutex_unlock(pTempCBuffer->m_lock) != 0) { 782 return 0; 783 } 784 #endif 785 return ucHead; 786 } 787 788 /* ========================================================================== */ 789 /** 790 * VIDDEC_Load_Defaults() function will be called by the component to 791 * 792 * load the default values 793 * 794 * @param pComponentPrivate Pointer to the pComponentPrivatePrivate 795 * 796 * @retval OMX_NoError Success, ready to roll 797 **/ 798 /* ========================================================================== */ 799 800 OMX_ERRORTYPE VIDDEC_Load_Defaults (VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, OMX_S32 nPassing) 801 { 802 OMX_U32 iCount = 0; 803 OMX_ERRORTYPE eError = OMX_ErrorNone; 804 805 switch(nPassing){ 806 case VIDDEC_INIT_ALL: 807 case VIDDEC_INIT_STRUCTS: 808 pComponentPrivate->nInBufIndex = 0; 809 pComponentPrivate->nOutBufIndex = 0; 810 pComponentPrivate->nInMarkBufIndex = 0; 811 pComponentPrivate->nOutMarkBufIndex = 0; 812 pComponentPrivate->nInCmdMarkBufIndex = 0; 813 pComponentPrivate->nOutCmdMarkBufIndex = 0; 814 815 pComponentPrivate->pCompPort[0]->hTunnelComponent = NULL; 816 pComponentPrivate->pCompPort[1]->hTunnelComponent = NULL; 817 818 /* Set component version */ 819 pComponentPrivate->pComponentVersion.s.nVersionMajor = VERSION_MAJOR; 820 pComponentPrivate->pComponentVersion.s.nVersionMinor = VERSION_MINOR; 821 pComponentPrivate->pComponentVersion.s.nRevision = VERSION_REVISION; 822 pComponentPrivate->pComponentVersion.s.nStep = VERSION_STEP; 823 824 /* Set spec version */ 825 pComponentPrivate->pSpecVersion.s.nVersionMajor = VERSION_MAJOR; 826 pComponentPrivate->pSpecVersion.s.nVersionMinor = VERSION_MINOR; 827 pComponentPrivate->pSpecVersion.s.nRevision = VERSION_REVISION; 828 pComponentPrivate->pSpecVersion.s.nStep = VERSION_STEP; 829 830 pComponentPrivate->pHandle->pApplicationPrivate = NULL; 831 /* Set pPortParamType defaults */ 832 OMX_CONF_INIT_STRUCT(pComponentPrivate->pPortParamType, OMX_PORT_PARAM_TYPE, pComponentPrivate->dbg); 833 pComponentPrivate->pPortParamType->nPorts = NUM_OF_PORTS; 834 pComponentPrivate->pPortParamType->nStartPortNumber = VIDDEC_INPUT_PORT; 835 #ifdef __STD_COMPONENT__ 836 OMX_CONF_INIT_STRUCT(pComponentPrivate->pPortParamTypeAudio, OMX_PORT_PARAM_TYPE, pComponentPrivate->dbg); 837 pComponentPrivate->pPortParamTypeAudio->nPorts = VIDDEC_ZERO; 838 pComponentPrivate->pPortParamTypeAudio->nStartPortNumber = VIDDEC_ZERO; 839 OMX_CONF_INIT_STRUCT(pComponentPrivate->pPortParamTypeImage, OMX_PORT_PARAM_TYPE, pComponentPrivate->dbg); 840 pComponentPrivate->pPortParamTypeImage->nPorts = VIDDEC_ZERO; 841 pComponentPrivate->pPortParamTypeImage->nStartPortNumber = VIDDEC_ZERO; 842 OMX_CONF_INIT_STRUCT(pComponentPrivate->pPortParamTypeOthers, OMX_PORT_PARAM_TYPE, pComponentPrivate->dbg); 843 pComponentPrivate->pPortParamTypeOthers->nPorts = VIDDEC_ZERO; 844 pComponentPrivate->pPortParamTypeOthers->nStartPortNumber = VIDDEC_ZERO; 845 #endif 846 847 pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->nBufferCnt = 0; 848 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->nBufferCnt = 0; 849 850 /* Set pInPortDef defaults */ 851 OMX_CONF_INIT_STRUCT(pComponentPrivate->pInPortDef, OMX_PARAM_PORTDEFINITIONTYPE, pComponentPrivate->dbg); 852 pComponentPrivate->pInPortDef->nPortIndex = VIDDEC_INPUT_PORT; 853 pComponentPrivate->pInPortDef->eDir = OMX_DirInput; 854 pComponentPrivate->pInPortDef->nBufferCountActual = MAX_PRIVATE_IN_BUFFERS; 855 pComponentPrivate->pInPortDef->nBufferCountMin = VIDDEC_BUFFERMINCOUNT; 856 pComponentPrivate->pInPortDef->nBufferSize = VIDDEC_DEFAULT_INPUT_BUFFER_SIZE; 857 pComponentPrivate->pInPortDef->bEnabled = VIDDEC_PORT_ENABLED; 858 pComponentPrivate->pInPortDef->bPopulated = VIDDEC_PORT_POPULATED; 859 pComponentPrivate->pInPortDef->eDomain = VIDDEC_PORT_DOMAIN; 860 #ifdef KHRONOS_1_2 861 pComponentPrivate->pInPortDef->bBuffersContiguous = OMX_FALSE; 862 pComponentPrivate->pInPortDef->nBufferAlignment = OMX_FALSE; 863 #endif 864 pComponentPrivate->pInPortDef->format.video.pNativeRender = VIDDEC_INPUT_PORT_NATIVERENDER; 865 pComponentPrivate->pInPortDef->format.video.nFrameWidth = VIDDEC_DEFAULT_WIDTH; 866 pComponentPrivate->pInPortDef->format.video.nFrameHeight = VIDDEC_DEFAULT_HEIGHT; 867 pComponentPrivate->pInPortDef->format.video.nStride = VIDDEC_INPUT_PORT_STRIDE; 868 pComponentPrivate->pInPortDef->format.video.nSliceHeight = VIDDEC_INPUT_PORT_SLICEHEIGHT; 869 pComponentPrivate->pInPortDef->format.video.nBitrate = VIDDEC_INPUT_PORT_BITRATE; 870 pComponentPrivate->pInPortDef->format.video.xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 871 pComponentPrivate->pInPortDef->format.video.cMIMEType = VIDDEC_MIMETYPEMPEG4; 872 pComponentPrivate->pInPortDef->format.video.bFlagErrorConcealment = VIDDEC_INPUT_PORT_FLAGERRORCONCEALMENT; 873 pComponentPrivate->pInPortDef->format.video.eCompressionFormat = VIDDEC_INPUT_PORT_COMPRESSIONFORMAT; 874 pComponentPrivate->pInPortDef->format.video.eColorFormat = VIDDEC_COLORFORMATUNUSED; 875 #ifdef KHRONOS_1_1 876 pComponentPrivate->pInPortDef->format.video.pNativeWindow = 0; 877 #endif 878 879 /* Set pOutPortDef defaults */ 880 OMX_CONF_INIT_STRUCT(pComponentPrivate->pOutPortDef, OMX_PARAM_PORTDEFINITIONTYPE, pComponentPrivate->dbg); 881 pComponentPrivate->pOutPortDef->nPortIndex = VIDDEC_OUTPUT_PORT; 882 pComponentPrivate->pOutPortDef->eDir = OMX_DirOutput; 883 pComponentPrivate->pOutPortDef->nBufferCountActual = MAX_PRIVATE_OUT_BUFFERS; 884 pComponentPrivate->pOutPortDef->nBufferCountMin = VIDDEC_BUFFERMINCOUNT; 885 pComponentPrivate->pOutPortDef->nBufferSize = VIDDEC_DEFAULT_OUTPUT_BUFFER_SIZE; 886 pComponentPrivate->pOutPortDef->bEnabled = VIDDEC_PORT_ENABLED; 887 pComponentPrivate->pOutPortDef->bPopulated = VIDDEC_PORT_POPULATED; 888 pComponentPrivate->pOutPortDef->eDomain = VIDDEC_PORT_DOMAIN; 889 #ifdef KHRONOS_1_2 890 pComponentPrivate->pInPortDef->bBuffersContiguous = OMX_FALSE; 891 pComponentPrivate->pInPortDef->nBufferAlignment = OMX_FALSE; 892 #endif 893 pComponentPrivate->pOutPortDef->format.video.cMIMEType = VIDDEC_MIMETYPEYUV; 894 pComponentPrivate->pOutPortDef->format.video.pNativeRender = VIDDEC_OUTPUT_PORT_NATIVERENDER; 895 pComponentPrivate->pOutPortDef->format.video.nFrameWidth = VIDDEC_DEFAULT_WIDTH; 896 pComponentPrivate->pOutPortDef->format.video.nFrameHeight = VIDDEC_DEFAULT_HEIGHT; 897 pComponentPrivate->pOutPortDef->format.video.nStride = VIDDEC_OUTPUT_PORT_STRIDE; 898 pComponentPrivate->pOutPortDef->format.video.nSliceHeight = VIDDEC_OUTPUT_PORT_SLICEHEIGHT; 899 pComponentPrivate->pOutPortDef->format.video.nBitrate = VIDDEC_OUTPUT_PORT_BITRATE; 900 pComponentPrivate->pOutPortDef->format.video.xFramerate = VIDDEC_OUTPUT_PORT_FRAMERATE; 901 pComponentPrivate->pOutPortDef->format.video.bFlagErrorConcealment = VIDDEC_OUTPUT_PORT_FLAGERRORCONCEALMENT; 902 pComponentPrivate->pOutPortDef->format.video.eCompressionFormat = VIDDEC_OUTPUT_PORT_COMPRESSIONFORMAT; 903 pComponentPrivate->pOutPortDef->format.video.eColorFormat = VIDDEC_COLORFORMAT420; 904 #ifdef KHRONOS_1_1 905 pComponentPrivate->pOutPortDef->format.video.pNativeWindow = 0; 906 #endif 907 for (iCount = 0; iCount < MAX_PRIVATE_BUFFERS; iCount++) { 908 OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount], VIDDEC_BUFFER_PRIVATE,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel0]); 909 pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr = NULL; 910 } 911 912 for (iCount = 0; iCount < MAX_PRIVATE_BUFFERS; iCount++) { 913 OMX_MALLOC_STRUCT(pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount], VIDDEC_BUFFER_PRIVATE,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel0]); 914 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr = NULL; 915 } 916 917 /* Set pInPortFormat defaults */ 918 OMX_CONF_INIT_STRUCT(pComponentPrivate->pInPortFormat, OMX_VIDEO_PARAM_PORTFORMATTYPE, pComponentPrivate->dbg); 919 pComponentPrivate->pInPortFormat->nPortIndex = VIDDEC_INPUT_PORT; 920 pComponentPrivate->pInPortFormat->nIndex = VIDDEC_DEFAULT_INPUT_INDEX_MPEG4; 921 pComponentPrivate->pInPortFormat->eCompressionFormat = VIDDEC_INPUT_PORT_COMPRESSIONFORMAT; 922 pComponentPrivate->pInPortFormat->eColorFormat = VIDDEC_COLORFORMATUNUSED; 923 #ifdef KHRONOS_1_1 924 pComponentPrivate->pInPortFormat->xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 925 #endif 926 927 /* Set pOutPortFormat defaults */ 928 OMX_CONF_INIT_STRUCT(pComponentPrivate->pOutPortFormat, OMX_VIDEO_PARAM_PORTFORMATTYPE, pComponentPrivate->dbg); 929 pComponentPrivate->pOutPortFormat->nPortIndex = VIDDEC_OUTPUT_PORT; 930 pComponentPrivate->pOutPortFormat->nIndex = VIDDEC_DEFAULT_OUTPUT_INDEX_PLANAR420; 931 pComponentPrivate->pOutPortFormat->eCompressionFormat = VIDDEC_OUTPUT_PORT_COMPRESSIONFORMAT; 932 pComponentPrivate->pOutPortFormat->eColorFormat = VIDDEC_COLORFORMAT420; 933 #ifdef KHRONOS_1_1 934 pComponentPrivate->pOutPortFormat->xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 935 #endif 936 /* Set pPriorityMgmt defaults */ 937 OMX_CONF_INIT_STRUCT(pComponentPrivate->pPriorityMgmt, OMX_PRIORITYMGMTTYPE, pComponentPrivate->dbg); 938 pComponentPrivate->pPriorityMgmt->nGroupPriority = -1; 939 pComponentPrivate->pPriorityMgmt->nGroupID = -1; 940 941 /* Buffer supplier setting */ 942 pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->eSupplierSetting = OMX_BufferSupplyOutput; 943 944 /* Set pInBufSupplier defaults */ 945 OMX_CONF_INIT_STRUCT(pComponentPrivate->pInBufSupplier, OMX_PARAM_BUFFERSUPPLIERTYPE , pComponentPrivate->dbg); 946 pComponentPrivate->pInBufSupplier->nPortIndex = VIDDEC_INPUT_PORT; 947 pComponentPrivate->pInBufSupplier->eBufferSupplier = VIDDEC_INPUT_PORT_BUFFERSUPPLIER; 948 949 /* Set pOutBufSupplier defaults */ 950 OMX_CONF_INIT_STRUCT(pComponentPrivate->pOutBufSupplier, OMX_PARAM_BUFFERSUPPLIERTYPE , pComponentPrivate->dbg); 951 pComponentPrivate->pOutBufSupplier->nPortIndex = VIDDEC_OUTPUT_PORT; 952 pComponentPrivate->pOutBufSupplier->eBufferSupplier = VIDDEC_OUTPUT_PORT_BUFFERSUPPLIER; 953 954 #ifdef KHRONOS_1_1 955 /*MBError Reporting code */ 956 /* Set eMBErrorReport defaults */ 957 OMX_CONF_INIT_STRUCT(&pComponentPrivate->eMBErrorReport, OMX_CONFIG_MBERRORREPORTINGTYPE , pComponentPrivate->dbg); 958 pComponentPrivate->eMBErrorReport.nPortIndex = VIDDEC_OUTPUT_PORT; 959 pComponentPrivate->eMBErrorReport.bEnabled = OMX_FALSE; 960 /*MBError Reporting code */ 961 /* Set eMBErrorMapType defaults */ 962 for (iCount = 0; iCount < MAX_PRIVATE_BUFFERS; iCount++) { 963 OMX_CONF_INIT_STRUCT(&pComponentPrivate->eMBErrorMapType[iCount], OMX_CONFIG_MACROBLOCKERRORMAPTYPE_TI , pComponentPrivate->dbg); 964 pComponentPrivate->eMBErrorMapType[iCount].nPortIndex = VIDDEC_OUTPUT_PORT; 965 pComponentPrivate->eMBErrorMapType[iCount].nErrMapSize = (VIDDEC_DEFAULT_WIDTH * VIDDEC_DEFAULT_HEIGHT) / 256; 966 } 967 pComponentPrivate->cMBErrorIndexIn = 0; 968 pComponentPrivate->cMBErrorIndexOut = 0; 969 970 #endif 971 972 pComponentPrivate->nPendingStateChangeRequests = 0; 973 if(pthread_mutex_init(&pComponentPrivate->mutexStateChangeRequest, NULL)) { 974 return OMX_ErrorUndefined; 975 } 976 if(pthread_cond_init (&pComponentPrivate->StateChangeCondition, NULL)) { 977 return OMX_ErrorUndefined; 978 } 979 980 /* Set pMpeg4 defaults */ 981 OMX_CONF_INIT_STRUCT (pComponentPrivate->pMpeg4, OMX_VIDEO_PARAM_MPEG4TYPE, pComponentPrivate->dbg); 982 pComponentPrivate->pMpeg4->nPortIndex = VIDDEC_DEFAULT_MPEG4_PORTINDEX; 983 pComponentPrivate->pMpeg4->nSliceHeaderSpacing = VIDDEC_DEFAULT_MPEG4_SLICEHEADERSPACING; 984 pComponentPrivate->pMpeg4->bSVH = VIDDEC_DEFAULT_MPEG4_SVH; 985 pComponentPrivate->pMpeg4->bGov = VIDDEC_DEFAULT_MPEG4_GOV; 986 pComponentPrivate->pMpeg4->nPFrames = VIDDEC_DEFAULT_MPEG4_PFRAMES; 987 pComponentPrivate->pMpeg4->nBFrames = VIDDEC_DEFAULT_MPEG4_BFRAMES; 988 pComponentPrivate->pMpeg4->nIDCVLCThreshold = VIDDEC_DEFAULT_MPEG4_IDCVLCTHRESHOLD; 989 pComponentPrivate->pMpeg4->bACPred = VIDDEC_DEFAULT_MPEG4_ACPRED; 990 pComponentPrivate->pMpeg4->nMaxPacketSize = VIDDEC_DEFAULT_MPEG4_MAXPACKETSIZE; 991 pComponentPrivate->pMpeg4->nTimeIncRes = VIDDEC_DEFAULT_MPEG4_TIMEINCRES; 992 pComponentPrivate->pMpeg4->eProfile = VIDDEC_DEFAULT_MPEG4_PROFILE; 993 pComponentPrivate->pMpeg4->eLevel = VIDDEC_DEFAULT_MPEG4_LEVEL; 994 pComponentPrivate->pMpeg4->nAllowedPictureTypes = VIDDEC_DEFAULT_MPEG4_ALLOWEDPICTURETYPES; 995 pComponentPrivate->pMpeg4->nHeaderExtension = VIDDEC_DEFAULT_MPEG4_HEADEREXTENSION; 996 pComponentPrivate->pMpeg4->bReversibleVLC = VIDDEC_DEFAULT_MPEG4_REVERSIBLEVLC; 997 998 /* Set pMpeg2 defaults */ 999 OMX_CONF_INIT_STRUCT (pComponentPrivate->pMpeg2, OMX_VIDEO_PARAM_MPEG2TYPE, pComponentPrivate->dbg); 1000 pComponentPrivate->pMpeg2->nPortIndex = VIDDEC_DEFAULT_MPEG2_PORTINDEX; 1001 pComponentPrivate->pMpeg2->nPFrames = VIDDEC_DEFAULT_MPEG2_PFRAMES; 1002 pComponentPrivate->pMpeg2->nBFrames = VIDDEC_DEFAULT_MPEG2_BFRAMES; 1003 pComponentPrivate->pMpeg2->eProfile = VIDDEC_DEFAULT_MPEG2_PROFILE; 1004 pComponentPrivate->pMpeg2->eLevel = VIDDEC_DEFAULT_MPEG2_LEVEL; 1005 1006 /* Set pH264 defaults */ 1007 OMX_CONF_INIT_STRUCT(pComponentPrivate->pH264, OMX_VIDEO_PARAM_AVCTYPE, pComponentPrivate->dbg); 1008 pComponentPrivate->pH264->nPortIndex = VIDDEC_DEFAULT_H264_PORTINDEX; 1009 pComponentPrivate->pH264->nSliceHeaderSpacing = VIDDEC_DEFAULT_H264_SLICEHEADERSPACING; 1010 pComponentPrivate->pH264->nPFrames = VIDDEC_DEFAULT_H264_PFRAMES; 1011 pComponentPrivate->pH264->nBFrames = VIDDEC_DEFAULT_H264_BFRAMES; 1012 pComponentPrivate->pH264->bUseHadamard = VIDDEC_DEFAULT_H264_USEHADAMARD; 1013 pComponentPrivate->pH264->nRefFrames = VIDDEC_DEFAULT_H264_REFFRAMES; 1014 pComponentPrivate->pH264->nRefIdx10ActiveMinus1 = VIDDEC_DEFAULT_H264_REFIDX10ACTIVEMINUS1; 1015 pComponentPrivate->pH264->nRefIdx11ActiveMinus1 = VIDDEC_DEFAULT_H264_REFIDX11ACTIVEMINUS1; 1016 pComponentPrivate->pH264->bEnableUEP = VIDDEC_DEFAULT_H264_ENABLEUEP; 1017 pComponentPrivate->pH264->bEnableFMO = VIDDEC_DEFAULT_H264_ENABLEFMO; 1018 pComponentPrivate->pH264->bEnableASO = VIDDEC_DEFAULT_H264_ENABLEASO; 1019 pComponentPrivate->pH264->bEnableRS = VIDDEC_DEFAULT_H264_ENABLERS; 1020 pComponentPrivate->pH264->eProfile = VIDDEC_DEFAULT_H264_PROFILE; 1021 pComponentPrivate->pH264->eLevel = VIDDEC_DEFAULT_H264_LEVEL; 1022 pComponentPrivate->pH264->nAllowedPictureTypes = VIDDEC_DEFAULT_H264_ALLOWEDPICTURETYPES; 1023 pComponentPrivate->pH264->bFrameMBsOnly = VIDDEC_DEFAULT_H264_FRAMEMBSONLY; 1024 pComponentPrivate->pH264->bMBAFF = VIDDEC_DEFAULT_H264_MBAFF; 1025 pComponentPrivate->pH264->bEntropyCodingCABAC = VIDDEC_DEFAULT_H264_ENTROPYCODINGCABAC; 1026 pComponentPrivate->pH264->bWeightedPPrediction = VIDDEC_DEFAULT_H264_WEIGHTEDPPREDICTION; 1027 pComponentPrivate->pH264->nWeightedBipredicitonMode = VIDDEC_DEFAULT_H264_WEIGHTEDBIPREDICITONMODE; 1028 pComponentPrivate->pH264->bconstIpred = VIDDEC_DEFAULT_H264_CONSTIPRED; 1029 pComponentPrivate->pH264->bDirect8x8Inference = VIDDEC_DEFAULT_H264_DIRECT8X8INFERENCE; 1030 pComponentPrivate->pH264->bDirectSpatialTemporal = VIDDEC_DEFAULT_H264_DIRECTSPATIALTEMPORAL; 1031 pComponentPrivate->pH264->nCabacInitIdc = VIDDEC_DEFAULT_H264_CABACINITIDC; 1032 pComponentPrivate->pH264->eLoopFilterMode = VIDDEC_DEFAULT_H264_LOOPFILTERMODE; 1033 pComponentPrivate->H264BitStreamFormat = VIDDEC_DEFAULT_H264BITSTRMFMT; 1034 1035 pComponentPrivate->pH263->nPortIndex = VIDDEC_DEFAULT_H263_PORTINDEX; 1036 pComponentPrivate->pH263->nPFrames = VIDDEC_DEFAULT_H263_PFRAMES; 1037 pComponentPrivate->pH263->nBFrames = VIDDEC_DEFAULT_H263_BFRAMES; 1038 pComponentPrivate->pH263->eProfile = VIDDEC_DEFAULT_H263_PROFILE; 1039 pComponentPrivate->pH263->eLevel = VIDDEC_DEFAULT_H263_LEVEL; 1040 pComponentPrivate->pH263->bPLUSPTYPEAllowed = VIDDEC_DEFAULT_H263_PLUSPTYPEALLOWED; 1041 pComponentPrivate->pH263->nAllowedPictureTypes = VIDDEC_DEFAULT_H263_ALLOWEDPICTURETYPES; 1042 pComponentPrivate->pH263->bForceRoundingTypeToZero = VIDDEC_DEFAULT_H263_FORCEROUNDINGTYPETOZERO; 1043 pComponentPrivate->pH263->nPictureHeaderRepetition = VIDDEC_DEFAULT_H263_PICTUREHEADERREPETITION; 1044 pComponentPrivate->pH263->nGOBHeaderInterval = VIDDEC_DEFAULT_H263_GOBHEADERINTERVAL; 1045 1046 OMX_CONF_INIT_STRUCT(pComponentPrivate->pWMV, OMX_VIDEO_PARAM_WMVTYPE, pComponentPrivate->dbg); 1047 pComponentPrivate->pWMV->nPortIndex = VIDDEC_DEFAULT_WMV_PORTINDEX; 1048 pComponentPrivate->pWMV->eFormat = VIDDEC_DEFAULT_WMV_FORMAT; 1049 pComponentPrivate->nWMVFileType = VIDDEC_WMV_RCVSTREAM; /* RCVSTREAM must be the default value*/ 1050 pComponentPrivate->wmvProfile = VIDDEC_WMV_PROFILEMAX; 1051 #ifdef UNDER_CE 1052 pComponentPrivate->bIsNALBigEndian = OMX_TRUE; 1053 #else 1054 pComponentPrivate->bIsNALBigEndian = OMX_FALSE; 1055 #endif 1056 pComponentPrivate->eLCMLState = VidDec_LCML_State_Unload; 1057 pComponentPrivate->bLCMLHalted = OMX_TRUE; 1058 #ifndef UNDER_CE 1059 pComponentPrivate->bLCMLOut = OMX_FALSE; 1060 #endif 1061 pComponentPrivate->eRMProxyState = VidDec_RMPROXY_State_Unload; 1062 pComponentPrivate->ProcessMode = VIDDEC_DEFAULT_PROCESSMODE; 1063 pComponentPrivate->bParserEnabled = OMX_TRUE; 1064 1065 VIDDEC_CircBuf_Init(pComponentPrivate, VIDDEC_CBUFFER_TIMESTAMP, VIDDEC_INPUT_PORT); 1066 #ifndef UNDER_CE 1067 VIDDEC_PTHREAD_MUTEX_INIT(pComponentPrivate->sMutex); 1068 VIDDEC_PTHREAD_SEMAPHORE_INIT(pComponentPrivate->sInSemaphore); 1069 VIDDEC_PTHREAD_SEMAPHORE_INIT(pComponentPrivate->sOutSemaphore); 1070 #endif 1071 for (iCount = 0; iCount < CBUFFER_SIZE; iCount++) { 1072 pComponentPrivate->aBufferFlags[iCount].nTimeStamp = 0; 1073 pComponentPrivate->aBufferFlags[iCount].nFlags = 0; 1074 pComponentPrivate->aBufferFlags[iCount].pMarkData = NULL; 1075 pComponentPrivate->aBufferFlags[iCount].hMarkTargetComponent = NULL; 1076 } 1077 pComponentPrivate->pBufferRCV.sStructRCV.nNumFrames = 0xFFFFFF; /*Infinite frame number*/ 1078 pComponentPrivate->pBufferRCV.sStructRCV.nFrameType = 0x85; /*85*/ 1079 pComponentPrivate->pBufferRCV.sStructRCV.nID = 0x04; /*WMV3*/ 1080 pComponentPrivate->pBufferRCV.sStructRCV.nStructData = 0x018a3106; /*0x06318a01zero fill 0x018a3106*/ 1081 pComponentPrivate->pBufferRCV.sStructRCV.nVertSize = 352; /*720*/ 1082 pComponentPrivate->pBufferRCV.sStructRCV.nHorizSize = 288; /*576*/ 1083 OMX_CONF_INIT_STRUCT( &pComponentPrivate->pBufferTemp, OMX_BUFFERHEADERTYPE, pComponentPrivate->dbg); 1084 pComponentPrivate->pBufferTemp.nFilledLen = sizeof(VIDDEC_WMV_RCV_header); 1085 pComponentPrivate->pBufferTemp.nAllocLen = sizeof(VIDDEC_WMV_RCV_header); 1086 1087 #ifdef ANDROID 1088 /*Set PV (opencore) capability flags*/ 1089 pComponentPrivate->pPVCapabilityFlags->iIsOMXComponentMultiThreaded = OMX_TRUE; 1090 pComponentPrivate->pPVCapabilityFlags->iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE; 1091 pComponentPrivate->pPVCapabilityFlags->iOMXComponentSupportsExternalInputBufferAlloc = OMX_FALSE; 1092 pComponentPrivate->pPVCapabilityFlags->iOMXComponentSupportsMovableInputBuffers = OMX_FALSE; 1093 pComponentPrivate->pPVCapabilityFlags->iOMXComponentSupportsPartialFrames = OMX_FALSE; 1094 pComponentPrivate->pPVCapabilityFlags->iOMXComponentCanHandleIncompleteFrames = OMX_FALSE; 1095 1096 1097 if (pComponentPrivate->ProcessMode == 0 && pComponentPrivate->H264BitStreamFormat == 0) { 1098 /* frame mode + bytestream */ 1099 pComponentPrivate->pPVCapabilityFlags->iOMXComponentUsesNALStartCodes = OMX_TRUE; 1100 } 1101 else if (pComponentPrivate->ProcessMode == 0 && pComponentPrivate->H264BitStreamFormat >= 1) { 1102 /* frame mode + NAL-bitstream */ 1103 pComponentPrivate->pPVCapabilityFlags->iOMXComponentUsesNALStartCodes = OMX_FALSE; 1104 } 1105 else if (pComponentPrivate->ProcessMode == 1 && pComponentPrivate->H264BitStreamFormat == 0) { 1106 /* stream mode + bytestream */ 1107 pComponentPrivate->pPVCapabilityFlags->iOMXComponentUsesNALStartCodes = OMX_TRUE; 1108 } 1109 else if (pComponentPrivate->ProcessMode == 1 && pComponentPrivate->H264BitStreamFormat >= 1) { 1110 /* stream mode + NAL-bitstream */ 1111 /* not supported */ 1112 } 1113 else { 1114 } 1115 1116 if (pComponentPrivate->ProcessMode == 0 && pComponentPrivate->H264BitStreamFormat == 0) { 1117 /* frame mode + bytestream */ 1118 pComponentPrivate->pPVCapabilityFlags->iOMXComponentUsesFullAVCFrames = OMX_TRUE; 1119 } 1120 else if (pComponentPrivate->ProcessMode == 0 && pComponentPrivate->H264BitStreamFormat >= 1) { 1121 /* frame mode + NAL-bitstream */ 1122 pComponentPrivate->pPVCapabilityFlags->iOMXComponentUsesFullAVCFrames = OMX_TRUE; 1123 } 1124 else if (pComponentPrivate->ProcessMode == 1 && pComponentPrivate->H264BitStreamFormat == 0) { 1125 /* stream mode + bytestream */ 1126 pComponentPrivate->pPVCapabilityFlags->iOMXComponentUsesFullAVCFrames = OMX_FALSE; 1127 } 1128 else if (pComponentPrivate->ProcessMode == 1 && pComponentPrivate->H264BitStreamFormat >= 1) { 1129 /* stream mode + NAL-bitstream */ 1130 /* not supported */ 1131 } 1132 else { 1133 } 1134 #endif 1135 /* Set default deblocking value for default format MPEG4 */ 1136 OMX_CONF_INIT_STRUCT(pComponentPrivate->pDeblockingParamType, OMX_PARAM_DEBLOCKINGTYPE, pComponentPrivate->dbg); 1137 pComponentPrivate->pDeblockingParamType->nPortIndex = VIDDEC_OUTPUT_PORT; 1138 pComponentPrivate->pDeblockingParamType->bDeblocking = OMX_FALSE; 1139 1140 1141 case VIDDEC_INIT_VARS: 1142 /* Set the process mode to zero, frame = 0, stream = 1 */ 1143 VIDDEC_CircBuf_Flush(pComponentPrivate, VIDDEC_CBUFFER_TIMESTAMP, VIDDEC_INPUT_PORT); 1144 pComponentPrivate->bIsPaused = 0; 1145 pComponentPrivate->bIsStopping = 0; 1146 pComponentPrivate->bFirstBuffer = 1; 1147 pComponentPrivate->eIdleToLoad = OMX_StateInvalid; 1148 pComponentPrivate->iEndofInputSent = 0; 1149 pComponentPrivate->nCountInputBFromDsp = 0; 1150 pComponentPrivate->nCountOutputBFromDsp = 0; 1151 pComponentPrivate->nCountInputBFromApp = 0; 1152 pComponentPrivate->nCountOutputBFromApp = 0; 1153 pComponentPrivate->frameCounter = 0; 1154 pComponentPrivate->bMult16Size = OMX_FALSE; 1155 pComponentPrivate->bFlushOut = OMX_FALSE; 1156 pComponentPrivate->nBytesConsumed = 0; 1157 pComponentPrivate->bBuffMarkTaked = OMX_FALSE; 1158 pComponentPrivate->bBuffalreadyMarked = OMX_FALSE; 1159 pComponentPrivate->bFirstHeader = OMX_FALSE; 1160 pComponentPrivate->nDisplayWidth = 0; 1161 pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel1] = 0; 1162 pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel2] = 0; 1163 pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel3] = 0; 1164 pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4] = 0; 1165 pComponentPrivate->bVC1Fix = OMX_TRUE; 1166 pComponentPrivate->eFirstBuffer.pFirstBufferSaved = NULL; 1167 pComponentPrivate->eFirstBuffer.bSaveFirstBuffer = OMX_FALSE; 1168 pComponentPrivate->eFirstBuffer.nFilledLen = 0; 1169 pComponentPrivate->bDynamicConfigurationInProgress = OMX_FALSE; 1170 pComponentPrivate->nInternalConfigBufferFilledAVC = 0; 1171 pComponentPrivate->eMBErrorReport.bEnabled = OMX_FALSE; 1172 pComponentPrivate->firstBufferEos = OMX_FALSE; 1173 break; 1174 1175 case VIDDEC_INIT_IDLEEXECUTING: 1176 /* Set the process mode to zero, frame = 0, stream = 1 */ 1177 pComponentPrivate->bIsPaused = 0; 1178 pComponentPrivate->bIsStopping = 0; 1179 pComponentPrivate->bFirstBuffer = 1; 1180 pComponentPrivate->iEndofInputSent = 0; 1181 pComponentPrivate->nCountInputBFromDsp = 0; 1182 pComponentPrivate->nCountOutputBFromDsp = 0; 1183 pComponentPrivate->nCountInputBFromApp = 0; 1184 pComponentPrivate->nCountOutputBFromApp = 0; 1185 pComponentPrivate->frameCounter = 0; 1186 pComponentPrivate->bMult16Size = OMX_FALSE; 1187 pComponentPrivate->bFlushOut = OMX_FALSE; 1188 pComponentPrivate->bFirstHeader = OMX_FALSE; 1189 pComponentPrivate->nInBufIndex = 0; 1190 pComponentPrivate->nOutBufIndex = 0; 1191 pComponentPrivate->nInMarkBufIndex = 0; 1192 pComponentPrivate->nOutMarkBufIndex = 0; 1193 pComponentPrivate->nInCmdMarkBufIndex = 0; 1194 pComponentPrivate->nOutCmdMarkBufIndex = 0; 1195 break; 1196 1197 case VIDDEC_INIT_H263: 1198 pComponentPrivate->pH263->nPortIndex = VIDDEC_DEFAULT_H263_PORTINDEX; 1199 pComponentPrivate->pH263->nPFrames = VIDDEC_DEFAULT_H263_PFRAMES; 1200 pComponentPrivate->pH263->nBFrames = VIDDEC_DEFAULT_H263_BFRAMES; 1201 pComponentPrivate->pH263->eProfile = OMX_VIDEO_H263ProfileBaseline; 1202 pComponentPrivate->pH263->eLevel = OMX_VIDEO_H263Level10; 1203 pComponentPrivate->pH263->bPLUSPTYPEAllowed = VIDDEC_DEFAULT_H263_PLUSPTYPEALLOWED; 1204 pComponentPrivate->pH263->nAllowedPictureTypes = VIDDEC_DEFAULT_H263_ALLOWEDPICTURETYPES; 1205 pComponentPrivate->pH263->bForceRoundingTypeToZero = VIDDEC_DEFAULT_H263_FORCEROUNDINGTYPETOZERO; 1206 pComponentPrivate->pH263->nPictureHeaderRepetition = VIDDEC_DEFAULT_H263_PICTUREHEADERREPETITION; 1207 pComponentPrivate->pH263->nGOBHeaderInterval = VIDDEC_DEFAULT_H263_GOBHEADERINTERVAL; 1208 1209 pComponentPrivate->pInPortFormat->nPortIndex = VIDDEC_INPUT_PORT; 1210 pComponentPrivate->pInPortFormat->nIndex = VIDDEC_DEFAULT_INPUT_INDEX_H263; 1211 pComponentPrivate->pInPortFormat->eCompressionFormat = OMX_VIDEO_CodingH263; 1212 pComponentPrivate->pInPortFormat->eColorFormat = OMX_COLOR_FormatUnused; 1213 #ifdef KHRONOS_1_1 1214 pComponentPrivate->pInPortFormat->xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1215 #endif 1216 pComponentPrivate->pInPortDef->format.video.nFrameWidth = VIDDEC_DEFAULT_WIDTH; 1217 pComponentPrivate->pInPortDef->format.video.nFrameHeight = VIDDEC_DEFAULT_HEIGHT; 1218 pComponentPrivate->pInPortDef->format.video.nBitrate = VIDDEC_INPUT_PORT_BITRATE; 1219 pComponentPrivate->pInPortDef->format.video.xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1220 pComponentPrivate->pInPortDef->format.video.eCompressionFormat = OMX_VIDEO_CodingH263; 1221 pComponentPrivate->pInPortDef->format.video.eColorFormat = OMX_COLOR_FormatUnused; 1222 pComponentPrivate->pInPortDef->nBufferSize = pComponentPrivate->pInPortDef->format.video.nFrameWidth * 1223 pComponentPrivate->pInPortDef->format.video.nFrameHeight * 1224 VIDDEC_FACTORFORMAT420; 1225 pComponentPrivate->pDeblockingParamType->bDeblocking = OMX_FALSE; 1226 pComponentPrivate->bIsSparkInput = OMX_FALSE; 1227 break; 1228 #ifdef VIDDEC_SPARK_CODE 1229 case VIDDEC_INIT_SPARK: 1230 pComponentPrivate->pInPortFormat->nPortIndex = VIDDEC_INPUT_PORT; 1231 pComponentPrivate->pInPortFormat->nIndex = VIDDEC_DEFAULT_INPUT_INDEX_H263; 1232 pComponentPrivate->pInPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; 1233 pComponentPrivate->pInPortFormat->eColorFormat = OMX_COLOR_FormatUnused; 1234 #ifdef KHRONOS_1_1 1235 pComponentPrivate->pInPortFormat->xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1236 #endif 1237 pComponentPrivate->pInPortDef->format.video.nFrameWidth = VIDDEC_DEFAULT_WIDTH; 1238 pComponentPrivate->pInPortDef->format.video.nFrameHeight = VIDDEC_DEFAULT_HEIGHT; 1239 pComponentPrivate->pInPortDef->format.video.nBitrate = VIDDEC_INPUT_PORT_BITRATE; 1240 pComponentPrivate->pInPortDef->format.video.xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1241 pComponentPrivate->pInPortDef->format.video.eCompressionFormat = pComponentPrivate->pInPortFormat->eCompressionFormat; 1242 pComponentPrivate->pInPortDef->format.video.eColorFormat = pComponentPrivate->pInPortFormat->eColorFormat; 1243 pComponentPrivate->pInPortDef->nBufferSize = pComponentPrivate->pInPortDef->format.video.nFrameWidth * 1244 pComponentPrivate->pInPortDef->format.video.nFrameHeight * 1245 VIDDEC_FACTORFORMAT420; 1246 pComponentPrivate->pDeblockingParamType->bDeblocking = OMX_FALSE; 1247 pComponentPrivate->bIsSparkInput = OMX_TRUE; 1248 break; 1249 #endif 1250 1251 case VIDDEC_INIT_H264: 1252 pComponentPrivate->pH264->nPortIndex = VIDDEC_DEFAULT_H264_PORTINDEX; 1253 pComponentPrivate->pH264->nPFrames = VIDDEC_DEFAULT_H264_PFRAMES; 1254 pComponentPrivate->pH264->nBFrames = VIDDEC_DEFAULT_H264_BFRAMES; 1255 pComponentPrivate->pH264->eProfile = OMX_VIDEO_AVCProfileBaseline; 1256 pComponentPrivate->pH264->eLevel = OMX_VIDEO_AVCLevelMax; 1257 1258 pComponentPrivate->pInPortFormat->nPortIndex = VIDDEC_INPUT_PORT; 1259 pComponentPrivate->pInPortFormat->nIndex = VIDDEC_DEFAULT_INPUT_INDEX_H264; 1260 pComponentPrivate->pInPortFormat->eCompressionFormat = OMX_VIDEO_CodingAVC; 1261 pComponentPrivate->pInPortFormat->eColorFormat = OMX_COLOR_FormatUnused; 1262 #ifdef KHRONOS_1_1 1263 pComponentPrivate->pInPortFormat->xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1264 #endif 1265 pComponentPrivate->pInPortDef->format.video.nFrameWidth = VIDDEC_DEFAULT_WIDTH; 1266 pComponentPrivate->pInPortDef->format.video.nFrameHeight = VIDDEC_DEFAULT_HEIGHT; 1267 pComponentPrivate->pInPortDef->format.video.nBitrate = VIDDEC_INPUT_PORT_BITRATE; 1268 pComponentPrivate->pInPortDef->format.video.xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1269 pComponentPrivate->pInPortDef->format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; 1270 pComponentPrivate->pInPortDef->format.video.eColorFormat = OMX_COLOR_FormatUnused; 1271 pComponentPrivate->pInPortDef->nBufferSize = pComponentPrivate->pInPortDef->format.video.nFrameWidth * 1272 pComponentPrivate->pInPortDef->format.video.nFrameHeight * 1273 VIDDEC_FACTORFORMAT420; 1274 pComponentPrivate->pDeblockingParamType->bDeblocking = OMX_TRUE; /* Always enable */ 1275 pComponentPrivate->bIsSparkInput = OMX_FALSE; 1276 break; 1277 1278 case VIDDEC_INIT_MPEG2: 1279 pComponentPrivate->pMpeg2->nPortIndex = VIDDEC_DEFAULT_MPEG2_PORTINDEX; 1280 pComponentPrivate->pMpeg2->nPFrames = VIDDEC_DEFAULT_MPEG2_PFRAMES; 1281 pComponentPrivate->pMpeg2->nBFrames = VIDDEC_DEFAULT_MPEG2_BFRAMES; 1282 pComponentPrivate->pMpeg2->eProfile = OMX_VIDEO_MPEG2ProfileSimple; 1283 pComponentPrivate->pMpeg2->eLevel = OMX_VIDEO_MPEG2LevelLL; 1284 1285 pComponentPrivate->pInPortFormat->nPortIndex = VIDDEC_INPUT_PORT; 1286 pComponentPrivate->pInPortFormat->nIndex = VIDDEC_DEFAULT_INPUT_INDEX_MPEG2; 1287 pComponentPrivate->pInPortFormat->eCompressionFormat = OMX_VIDEO_CodingMPEG2; 1288 pComponentPrivate->pInPortFormat->eColorFormat = OMX_COLOR_FormatUnused; 1289 #ifdef KHRONOS_1_1 1290 pComponentPrivate->pInPortFormat->xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1291 #endif 1292 pComponentPrivate->pInPortDef->format.video.nFrameWidth = VIDDEC_DEFAULT_WIDTH; 1293 pComponentPrivate->pInPortDef->format.video.nFrameHeight = VIDDEC_DEFAULT_HEIGHT; 1294 pComponentPrivate->pInPortDef->format.video.nBitrate = VIDDEC_INPUT_PORT_BITRATE; 1295 pComponentPrivate->pInPortDef->format.video.xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1296 pComponentPrivate->pInPortDef->format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG2; 1297 pComponentPrivate->pInPortDef->format.video.eColorFormat = OMX_COLOR_FormatUnused; 1298 pComponentPrivate->pInPortDef->nBufferSize = pComponentPrivate->pInPortDef->format.video.nFrameWidth * 1299 pComponentPrivate->pInPortDef->format.video.nFrameHeight * 1300 VIDDEC_FACTORFORMAT420; 1301 pComponentPrivate->pDeblockingParamType->bDeblocking = OMX_FALSE; /*TODO: Verify with algo team*/ 1302 pComponentPrivate->bIsSparkInput = OMX_FALSE; 1303 break; 1304 1305 case VIDDEC_INIT_MPEG4: 1306 pComponentPrivate->pMpeg4->nPortIndex = VIDDEC_DEFAULT_MPEG4_PORTINDEX; 1307 pComponentPrivate->pMpeg4->nPFrames = VIDDEC_DEFAULT_MPEG4_PFRAMES; 1308 pComponentPrivate->pMpeg4->nBFrames = VIDDEC_DEFAULT_MPEG4_BFRAMES; 1309 pComponentPrivate->pMpeg4->eProfile = OMX_VIDEO_MPEG4ProfileSimple; 1310 #ifdef KHRONOS_1_1 1311 pComponentPrivate->pMpeg4->eLevel = OMX_VIDEO_MPEG4Level1; 1312 #else 1313 pComponentPrivate->pMpeg4->eLevel = OMX_VIDEO_MPEG4Levell; 1314 #endif 1315 pComponentPrivate->pInPortFormat->nPortIndex = VIDDEC_INPUT_PORT; 1316 pComponentPrivate->pInPortFormat->nIndex = VIDDEC_DEFAULT_INPUT_INDEX_MPEG4; 1317 pComponentPrivate->pInPortFormat->eCompressionFormat = OMX_VIDEO_CodingMPEG4; 1318 pComponentPrivate->pInPortFormat->eColorFormat = OMX_COLOR_FormatUnused; 1319 #ifdef KHRONOS_1_1 1320 pComponentPrivate->pInPortFormat->xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1321 #endif 1322 pComponentPrivate->pInPortDef->format.video.nFrameWidth = VIDDEC_DEFAULT_WIDTH; 1323 pComponentPrivate->pInPortDef->format.video.nFrameHeight = VIDDEC_DEFAULT_HEIGHT; 1324 pComponentPrivate->pInPortDef->format.video.nBitrate = VIDDEC_INPUT_PORT_BITRATE; 1325 pComponentPrivate->pInPortDef->format.video.xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1326 pComponentPrivate->pInPortDef->format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; 1327 pComponentPrivate->pInPortDef->format.video.eColorFormat = OMX_COLOR_FormatUnused; 1328 pComponentPrivate->pInPortDef->nBufferSize = pComponentPrivate->pInPortDef->format.video.nFrameWidth * 1329 pComponentPrivate->pInPortDef->format.video.nFrameHeight * 1330 VIDDEC_FACTORFORMAT420; 1331 pComponentPrivate->pDeblockingParamType->bDeblocking = OMX_FALSE; 1332 pComponentPrivate->bIsSparkInput = OMX_FALSE; 1333 break; 1334 1335 case VIDDEC_INIT_WMV9: 1336 pComponentPrivate->pWMV->nPortIndex = VIDDEC_DEFAULT_WMV_PORTINDEX; 1337 pComponentPrivate->pWMV->eFormat = OMX_VIDEO_WMVFormat9; 1338 1339 pComponentPrivate->pInPortFormat->nPortIndex = VIDDEC_INPUT_PORT; 1340 pComponentPrivate->pInPortFormat->nIndex = VIDDEC_DEFAULT_INPUT_INDEX_WMV9; 1341 pComponentPrivate->pInPortFormat->eCompressionFormat = OMX_VIDEO_CodingWMV; 1342 pComponentPrivate->pInPortFormat->eColorFormat = OMX_COLOR_FormatUnused; 1343 #ifdef KHRONOS_1_1 1344 pComponentPrivate->pInPortFormat->xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1345 #endif 1346 pComponentPrivate->pInPortDef->format.video.nFrameWidth = VIDDEC_DEFAULT_WIDTH; 1347 pComponentPrivate->pInPortDef->format.video.nFrameHeight = VIDDEC_DEFAULT_HEIGHT; 1348 pComponentPrivate->pInPortDef->format.video.nBitrate = VIDDEC_INPUT_PORT_BITRATE; 1349 pComponentPrivate->pInPortDef->format.video.xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1350 pComponentPrivate->pInPortDef->format.video.eCompressionFormat = OMX_VIDEO_CodingWMV; 1351 pComponentPrivate->pInPortDef->format.video.eColorFormat = OMX_COLOR_FormatUnused; 1352 pComponentPrivate->pInPortDef->nBufferSize = pComponentPrivate->pInPortDef->format.video.nFrameWidth * 1353 pComponentPrivate->pInPortDef->format.video.nFrameHeight * 1354 VIDDEC_FACTORFORMAT420; 1355 1356 pComponentPrivate->nWMVFileType = VIDDEC_WMV_RCVSTREAM; /* RCVSTREAM must be the default value*/ 1357 pComponentPrivate->pDeblockingParamType->bDeblocking = OMX_TRUE; /* Always enable */ 1358 pComponentPrivate->bIsSparkInput = OMX_FALSE; 1359 break; 1360 1361 case VIDDEC_INIT_PLANAR420: 1362 1363 pComponentPrivate->pOutPortFormat->nPortIndex = VIDDEC_OUTPUT_PORT; 1364 pComponentPrivate->pOutPortFormat->nIndex = VIDDEC_DEFAULT_OUTPUT_INDEX_PLANAR420; 1365 pComponentPrivate->pOutPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; 1366 pComponentPrivate->pOutPortFormat->eColorFormat = VIDDEC_COLORFORMAT420; 1367 #ifdef KHRONOS_1_1 1368 pComponentPrivate->pOutPortFormat->xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1369 #endif 1370 pComponentPrivate->pOutPortDef->format.video.nFrameWidth = VIDDEC_DEFAULT_WIDTH; 1371 pComponentPrivate->pOutPortDef->format.video.nFrameHeight = VIDDEC_DEFAULT_HEIGHT; 1372 pComponentPrivate->pOutPortDef->format.video.nBitrate = VIDDEC_OUTPUT_PORT_BITRATE; 1373 pComponentPrivate->pOutPortDef->format.video.xFramerate = VIDDEC_OUTPUT_PORT_FRAMERATE; 1374 pComponentPrivate->pOutPortDef->format.video.eCompressionFormat = VIDDEC_OUTPUT_PORT_COMPRESSIONFORMAT; 1375 pComponentPrivate->pOutPortDef->format.video.eColorFormat = VIDDEC_COLORFORMAT420; 1376 pComponentPrivate->pOutPortDef->nBufferSize = pComponentPrivate->pOutPortDef->format.video.nFrameWidth * 1377 pComponentPrivate->pOutPortDef->format.video.nFrameHeight * 1378 VIDDEC_FACTORFORMAT420; 1379 1380 break; 1381 1382 case VIDDEC_INIT_INTERLEAVED422: 1383 pComponentPrivate->pOutPortFormat->nPortIndex = VIDDEC_OUTPUT_PORT; 1384 pComponentPrivate->pOutPortFormat->nIndex = VIDDEC_DEFAULT_OUTPUT_INDEX_INTERLEAVED422; 1385 pComponentPrivate->pOutPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; 1386 pComponentPrivate->pOutPortFormat->eColorFormat = VIDDEC_COLORFORMAT422; 1387 #ifdef KHRONOS_1_1 1388 pComponentPrivate->pOutPortFormat->xFramerate = VIDDEC_INPUT_PORT_FRAMERATE; 1389 #endif 1390 pComponentPrivate->pOutPortDef->format.video.nFrameWidth = VIDDEC_DEFAULT_WIDTH; 1391 pComponentPrivate->pOutPortDef->format.video.nFrameHeight = VIDDEC_DEFAULT_HEIGHT; 1392 pComponentPrivate->pOutPortDef->format.video.nBitrate = VIDDEC_OUTPUT_PORT_BITRATE; 1393 pComponentPrivate->pOutPortDef->format.video.xFramerate = VIDDEC_OUTPUT_PORT_FRAMERATE; 1394 pComponentPrivate->pOutPortDef->format.video.eCompressionFormat = VIDDEC_OUTPUT_PORT_COMPRESSIONFORMAT; 1395 pComponentPrivate->pOutPortDef->format.video.eColorFormat = VIDDEC_COLORFORMAT422; 1396 pComponentPrivate->pOutPortDef->nBufferSize = pComponentPrivate->pOutPortDef->format.video.nFrameWidth * 1397 pComponentPrivate->pOutPortDef->format.video.nFrameHeight * 1398 VIDDEC_FACTORFORMAT422; 1399 1400 break; 1401 1402 } 1403 1404 EXIT: 1405 return(eError); 1406 } 1407 1408 /*----------------------------------------------------------------------------*/ 1409 /** 1410 * VIDDEC_Start_ComponentThread() starts the component thread and all the pipes 1411 * to achieve communication between dsp and application for commands and buffer 1412 * interchanging 1413 **/ 1414 /*----------------------------------------------------------------------------*/ 1415 OMX_ERRORTYPE VIDDEC_Start_ComponentThread(OMX_HANDLETYPE hComponent) 1416 { 1417 OMX_ERRORTYPE eError = OMX_ErrorNone; 1418 OMX_COMPONENTTYPE* pComp = (OMX_COMPONENTTYPE*)hComponent; 1419 VIDDEC_COMPONENT_PRIVATE* pComponentPrivate = (VIDDEC_COMPONENT_PRIVATE*)pComp->pComponentPrivate; 1420 1421 pComponentPrivate->bIsStopping = 0; 1422 1423 OMX_PRINT1(pComponentPrivate->dbg, "+++ENTERING\n"); 1424 /* create the pipe used to maintain free input buffers*/ 1425 eError = pipe(pComponentPrivate->free_inpBuf_Q); 1426 if (eError) { 1427 eError = OMX_ErrorInsufficientResources; 1428 goto EXIT; 1429 } 1430 1431 /* create the pipe used to maintain free input buffers*/ 1432 eError = pipe(pComponentPrivate->free_outBuf_Q); 1433 if (eError) { 1434 eError = OMX_ErrorInsufficientResources; 1435 goto EXIT; 1436 } 1437 1438 /* create the pipe used to maintain input buffers*/ 1439 eError = pipe(pComponentPrivate->filled_inpBuf_Q); 1440 if (eError) { 1441 eError = OMX_ErrorInsufficientResources; 1442 goto EXIT; 1443 } 1444 1445 /* create the pipe used to maintain dsp output/encoded buffers*/ 1446 eError = pipe(pComponentPrivate->filled_outBuf_Q); 1447 if (eError) { 1448 eError = OMX_ErrorInsufficientResources; 1449 goto EXIT; 1450 } 1451 1452 /* create the pipe used to send commands to the thread */ 1453 eError = pipe(pComponentPrivate->cmdPipe); 1454 if (eError) { 1455 eError = OMX_ErrorInsufficientResources; 1456 goto EXIT; 1457 } 1458 1459 /* create the pipe used to send commands to the thread */ 1460 eError = pipe(pComponentPrivate->cmdDataPipe); 1461 if (eError) { 1462 eError = OMX_ErrorInsufficientResources; 1463 goto EXIT; 1464 } 1465 1466 /* Create the Component Thread */ 1467 eError = pthread_create(&(pComponentPrivate->ComponentThread), 1468 NULL, 1469 OMX_VidDec_Thread, 1470 pComponentPrivate); 1471 1472 OMX_TRACE2(pComponentPrivate->dbg, "pthread_create 0x%lx\n",(OMX_U32) pComponentPrivate->ComponentThread); 1473 if (eError || !pComponentPrivate->ComponentThread) { 1474 OMX_TRACE4(pComponentPrivate->dbg, "pthread_create 0x%x\n",eError); 1475 eError = OMX_ErrorInsufficientResources; 1476 goto EXIT; 1477 } 1478 1479 #ifdef __PERF_INSTRUMENTATION__ 1480 PERF_ThreadCreated(pComponentPrivate->pPERF, 1481 pComponentPrivate->ComponentThread, 1482 PERF_FOURS("VD T")); 1483 #endif 1484 1485 EXIT: 1486 OMX_PRINT1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 1487 return eError; 1488 } 1489 1490 /* ========================================================================== */ 1491 /** 1492 * @Stop_ComponentThread() This function is called by the component during 1493 * de-init to close component thread, Command pipe & data pipes. 1494 * 1495 * @param pComponent handle for this instance of the component 1496 * 1497 * @pre 1498 * 1499 * @post 1500 * 1501 * @return none 1502 */ 1503 /* ========================================================================== */ 1504 OMX_ERRORTYPE VIDDEC_Stop_ComponentThread(OMX_HANDLETYPE pComponent) 1505 { 1506 OMX_ERRORTYPE eError = OMX_ErrorNone; 1507 OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*)pComponent; 1508 VIDDEC_COMPONENT_PRIVATE* pComponentPrivate = (VIDDEC_COMPONENT_PRIVATE*)pHandle->pComponentPrivate; 1509 OMX_ERRORTYPE threadError = OMX_ErrorNone; 1510 OMX_ERRORTYPE err = OMX_ErrorNone; 1511 int pthreadError = 0; 1512 1513 /* Join the component thread */ 1514 OMX_PRINT1(pComponentPrivate->dbg, "+++ENTERING\n"); 1515 OMX_TRACE2(pComponentPrivate->dbg, "pthread_join 0x%lx\n",(OMX_U32) pComponentPrivate->ComponentThread); 1516 1517 #ifdef UNDER_CE 1518 pthreadError = pthread_join(pComponentPrivate->ComponentThread, (void*)&threadError); 1519 if (0 != pthreadError) { 1520 eError = OMX_ErrorHardware; 1521 } 1522 #else 1523 if(pComponentPrivate->bLCMLOut == OMX_TRUE) { 1524 /*pthreadError = pthread_cancel(pComponentPrivate->ComponentThread);*/ 1525 if (0 != pthreadError) { 1526 eError = OMX_ErrorHardware; 1527 } 1528 } 1529 else{ 1530 pthreadError = pthread_join(pComponentPrivate->ComponentThread, (void*)&threadError); 1531 if (0 != pthreadError) { 1532 eError = OMX_ErrorHardware; 1533 } 1534 } 1535 #endif 1536 1537 /* Check for the errors */ 1538 if (OMX_ErrorNone != eError) { 1539 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1540 pComponentPrivate->pHandle->pApplicationPrivate, 1541 OMX_EventError, 1542 eError, 1543 OMX_TI_ErrorSevere, 1544 "Error while closing Component Thread\n"); 1545 } 1546 1547 /* close the data pipe handles */ 1548 err = close(pComponentPrivate->free_inpBuf_Q[VIDDEC_PIPE_READ]); 1549 if (0 != err) { 1550 eError = OMX_ErrorHardware; 1551 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1552 pComponentPrivate->pHandle->pApplicationPrivate, 1553 OMX_EventError, 1554 eError, 1555 OMX_TI_ErrorMajor, 1556 "Error while closing data pipe\n"); 1557 } 1558 1559 err = close(pComponentPrivate->free_outBuf_Q[VIDDEC_PIPE_READ]); 1560 if (0 != err) { 1561 eError = OMX_ErrorHardware; 1562 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1563 pComponentPrivate->pHandle->pApplicationPrivate, 1564 OMX_EventError, 1565 eError, 1566 OMX_TI_ErrorMajor, 1567 "Error while closing data pipe\n"); 1568 } 1569 1570 err = close(pComponentPrivate->filled_inpBuf_Q[VIDDEC_PIPE_READ]); 1571 if (0 != err) { 1572 eError = OMX_ErrorHardware; 1573 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1574 pComponentPrivate->pHandle->pApplicationPrivate, 1575 OMX_EventError, 1576 eError, 1577 OMX_TI_ErrorMajor, 1578 "Error while closing data pipe\n"); 1579 } 1580 1581 err = close(pComponentPrivate->filled_outBuf_Q[VIDDEC_PIPE_READ]); 1582 if (0 != err) { 1583 eError = OMX_ErrorHardware; 1584 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1585 pComponentPrivate->pHandle->pApplicationPrivate, 1586 OMX_EventError, 1587 eError, 1588 OMX_TI_ErrorMajor, 1589 "Error while closing data pipe\n"); 1590 } 1591 1592 err = close(pComponentPrivate->free_inpBuf_Q[VIDDEC_PIPE_WRITE]); 1593 if (0 != err) { 1594 eError = OMX_ErrorHardware; 1595 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1596 pComponentPrivate->pHandle->pApplicationPrivate, 1597 OMX_EventError, 1598 eError, 1599 OMX_TI_ErrorMajor, 1600 "Error while closing data pipe\n"); 1601 } 1602 1603 err = close(pComponentPrivate->free_outBuf_Q[VIDDEC_PIPE_WRITE]); 1604 if (0 != err) { 1605 eError = OMX_ErrorHardware; 1606 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1607 pComponentPrivate->pHandle->pApplicationPrivate, 1608 OMX_EventError, 1609 eError, 1610 OMX_TI_ErrorMajor, 1611 "Error while closing data pipe\n"); 1612 } 1613 1614 err = close(pComponentPrivate->filled_inpBuf_Q[VIDDEC_PIPE_WRITE]); 1615 if (0 != err) { 1616 eError = OMX_ErrorHardware; 1617 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1618 pComponentPrivate->pHandle->pApplicationPrivate, 1619 OMX_EventError, 1620 eError, 1621 OMX_TI_ErrorMajor, 1622 "Error while closing data pipe\n"); 1623 } 1624 1625 err = close(pComponentPrivate->filled_outBuf_Q[VIDDEC_PIPE_WRITE]); 1626 if (0 != err) { 1627 eError = OMX_ErrorHardware; 1628 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1629 pComponentPrivate->pHandle->pApplicationPrivate, 1630 OMX_EventError, 1631 eError, 1632 OMX_TI_ErrorMajor, 1633 "Error while closing data pipe\n"); 1634 } 1635 1636 /* Close the command pipe handles */ 1637 err = close(pComponentPrivate->cmdPipe[VIDDEC_PIPE_READ]); 1638 if (0 != err) { 1639 eError = OMX_ErrorHardware; 1640 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1641 pComponentPrivate->pHandle->pApplicationPrivate, 1642 OMX_EventError, 1643 eError, 1644 OMX_TI_ErrorMajor, 1645 "Error while closing cmd pipe\n"); 1646 } 1647 1648 err = close(pComponentPrivate->cmdPipe[VIDDEC_PIPE_WRITE]); 1649 if (0 != err) { 1650 eError = OMX_ErrorHardware; 1651 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1652 pComponentPrivate->pHandle->pApplicationPrivate, 1653 OMX_EventError, 1654 eError, 1655 OMX_TI_ErrorMajor, 1656 "Error while closing cmd pipe\n"); 1657 } 1658 1659 /* Close the command data pipe handles */ 1660 err = close (pComponentPrivate->cmdDataPipe[VIDDEC_PIPE_READ]); 1661 if (0 != err) { 1662 eError = OMX_ErrorHardware; 1663 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1664 pComponentPrivate->pHandle->pApplicationPrivate, 1665 OMX_EventError, 1666 eError, 1667 OMX_TI_ErrorMajor, 1668 "Error while closing cmd pipe\n"); 1669 } 1670 1671 err = close (pComponentPrivate->cmdDataPipe[VIDDEC_PIPE_WRITE]); 1672 if (0 != err) { 1673 eError = OMX_ErrorHardware; 1674 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1675 pComponentPrivate->pHandle->pApplicationPrivate, 1676 OMX_EventError, 1677 eError, 1678 OMX_TI_ErrorMajor, 1679 "Error while closing cmd pipe\n"); 1680 } 1681 OMX_PRINT1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 1682 return eError; 1683 } 1684 1685 /* ========================================================================== */ 1686 /** 1687 * Disable Port() 1688 * 1689 * Called by component thread, handles commands sent by the app. 1690 * 1691 * @param 1692 * 1693 * @retval OMX_ErrorNone success, ready to roll 1694 * 1695 **/ 1696 /* ========================================================================== */ 1697 1698 OMX_ERRORTYPE VIDDEC_DisablePort (VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, OMX_U32 nParam1) 1699 { 1700 OMX_ERRORTYPE eError = OMX_ErrorNone; 1701 static OMX_BOOL bFirstTimeToUnLoadCodec = OMX_TRUE; /*Needed when port disable is been call for input & output ports*/ 1702 OMX_PRINT1(pComponentPrivate->dbg, "+++ENTERING\n"); 1703 OMX_PRINT1(pComponentPrivate->dbg, "pComponentPrivate 0x%p nParam1 0x%lx\n",pComponentPrivate, nParam1); 1704 1705 /* Protect VIDDEC_UnloadCodec() to be called twice while doing Dynamic port configuration*/ 1706 if(pComponentPrivate->bDynamicConfigurationInProgress && bFirstTimeToUnLoadCodec){ 1707 OMX_PRINT1(pComponentPrivate->dbg, "VIDDEC_UnloadCodec\n"); 1708 eError = VIDDEC_UnloadCodec(pComponentPrivate); 1709 if (eError != OMX_ErrorNone) { 1710 goto EXIT; 1711 } 1712 bFirstTimeToUnLoadCodec = OMX_FALSE; 1713 } 1714 1715 eError = VIDDEC_HandleCommandFlush(pComponentPrivate, -1, OMX_FALSE); 1716 1717 1718 1719 #ifdef UNDER_CE 1720 while(1) { 1721 if (nParam1 == VIDDEC_INPUT_PORT && !pComponentPrivate->pInPortDef->bPopulated) { 1722 /* return cmdcomplete event if input unpopulated */ 1723 OMX_PRBUFFER2(pComponentPrivate->dbg, "Unpopulated VIDDEC_INPUT_PORT IN 0x%x\n",pComponentPrivate->pInPortDef->bPopulated); 1724 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 1725 pComponentPrivate->pHandle->pApplicationPrivate, 1726 OMX_EventCmdComplete, 1727 OMX_CommandPortDisable, 1728 VIDDEC_INPUT_PORT, 1729 NULL); 1730 break; 1731 } 1732 else if (nParam1 == VIDDEC_OUTPUT_PORT && !pComponentPrivate->pOutPortDef->bPopulated) { 1733 /* return cmdcomplete event if output unpopulated */ 1734 OMX_PRBUFFER2(pComponentPrivate->dbg, "Unpopulated VIDDEC_OUTPUT_PORT OUT 0x%x\n",pComponentPrivate->pOutPortDef->bPopulated); 1735 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 1736 pComponentPrivate->pHandle->pApplicationPrivate, 1737 OMX_EventCmdComplete, 1738 OMX_CommandPortDisable, 1739 VIDDEC_OUTPUT_PORT, 1740 NULL); 1741 break; 1742 } 1743 else if (nParam1 == VIDDEC_BOTH_PORT && !pComponentPrivate->pInPortDef->bPopulated && 1744 !pComponentPrivate->pOutPortDef->bPopulated) { 1745 /* return cmdcomplete event if inout & output unpopulated */ 1746 OMX_PRBUFFER2(pComponentPrivate->dbg, "Unpopulated VIDDEC_INPUT_PORT IN 0x%x\n",pComponentPrivate->pInPortDef->bPopulated); 1747 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 1748 pComponentPrivate->pHandle->pApplicationPrivate, 1749 OMX_EventCmdComplete, 1750 OMX_CommandPortDisable, 1751 VIDDEC_INPUT_PORT, 1752 NULL); 1753 OMX_PRBUFFER2(pComponentPrivate->dbg, "Unpopulated VIDDEC_OUTPUT_PORT OUT 0x%x\n",pComponentPrivate->pOutPortDef->bPopulated); 1754 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 1755 pComponentPrivate->pHandle->pApplicationPrivate, 1756 OMX_EventCmdComplete, 1757 OMX_CommandPortDisable, 1758 VIDDEC_OUTPUT_PORT, 1759 NULL); 1760 break; 1761 } 1762 else if (nParam1 == VIDDEC_BOTH_PORT && !pComponentPrivate->pInPortDef->bPopulated && 1763 (pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL)) { 1764 /* return cmdcomplete event if inout & output unpopulated */ 1765 OMX_PRBUFFER2(pComponentPrivate->dbg, "Unpopulated VIDDEC_INPUT_PORT IN 0x%x\n",pComponentPrivate->pInPortDef->bPopulated); 1766 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 1767 pComponentPrivate->pHandle->pApplicationPrivate, 1768 OMX_EventCmdComplete, 1769 OMX_CommandPortDisable, 1770 VIDDEC_INPUT_PORT, 1771 NULL); 1772 break; 1773 } 1774 VIDDEC_WAIT_CODE(); 1775 } 1776 #else 1777 if (nParam1 == VIDDEC_INPUT_PORT) { 1778 if((!(pComponentPrivate->eState == OMX_StateLoaded) && pComponentPrivate->pInPortDef->bPopulated) || 1779 pComponentPrivate->sInSemaphore.bSignaled) { 1780 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 1781 } 1782 OMX_PRBUFFER2(pComponentPrivate->dbg, "Unpopulated VIDDEC_INPUT_PORT IN 0x%x\n",pComponentPrivate->pInPortDef->bPopulated); 1783 pComponentPrivate->bInPortSettingsChanged = OMX_FALSE; 1784 OMX_PRBUFFER1(pComponentPrivate->dbg, "bInPortSettingsChanged = OMX_FALSE;\n"); 1785 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 1786 pComponentPrivate->pHandle->pApplicationPrivate, 1787 OMX_EventCmdComplete, 1788 OMX_CommandPortDisable, 1789 VIDDEC_INPUT_PORT, 1790 NULL); 1791 } 1792 else if (nParam1 == VIDDEC_OUTPUT_PORT) { 1793 if((!(pComponentPrivate->eState == OMX_StateLoaded) && pComponentPrivate->pOutPortDef->bPopulated) || 1794 pComponentPrivate->sOutSemaphore.bSignaled) { 1795 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sOutSemaphore); 1796 } 1797 1798 OMX_PRBUFFER2(pComponentPrivate->dbg, "Unpopulated VIDDEC_OUTPUT_PORT OUT 0x%x\n",pComponentPrivate->pOutPortDef->bPopulated); 1799 OMX_PRBUFFER1(pComponentPrivate->dbg, "bOutPortSettingsChanged = OMX_FALSE;\n"); 1800 pComponentPrivate->bOutPortSettingsChanged = OMX_FALSE; 1801 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 1802 pComponentPrivate->pHandle->pApplicationPrivate, 1803 OMX_EventCmdComplete, 1804 OMX_CommandPortDisable, 1805 VIDDEC_OUTPUT_PORT, 1806 NULL); 1807 } 1808 else if (nParam1 == OMX_ALL) { 1809 if(pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL) { 1810 if((!(pComponentPrivate->eState == OMX_StateLoaded) && pComponentPrivate->pInPortDef->bPopulated) || 1811 pComponentPrivate->sInSemaphore.bSignaled) { 1812 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 1813 } 1814 OMX_PRBUFFER2(pComponentPrivate->dbg, "Unpopulated VIDDEC_INPUT_PORT IN 0x%x\n",pComponentPrivate->pInPortDef->bPopulated); 1815 pComponentPrivate->bInPortSettingsChanged = OMX_FALSE; 1816 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 1817 pComponentPrivate->pHandle->pApplicationPrivate, 1818 OMX_EventCmdComplete, 1819 OMX_CommandPortDisable, 1820 VIDDEC_INPUT_PORT, 1821 NULL); 1822 } 1823 else { 1824 if((!(pComponentPrivate->eState == OMX_StateLoaded) && pComponentPrivate->pInPortDef->bPopulated) || 1825 pComponentPrivate->sInSemaphore.bSignaled) { 1826 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 1827 } 1828 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_INPUT_PORT IN 0x%x\n",pComponentPrivate->pInPortDef->bPopulated); 1829 pComponentPrivate->bInPortSettingsChanged = OMX_FALSE; 1830 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 1831 pComponentPrivate->pHandle->pApplicationPrivate, 1832 OMX_EventCmdComplete, 1833 OMX_CommandPortDisable, 1834 VIDDEC_INPUT_PORT, 1835 NULL); 1836 if((!(pComponentPrivate->eState == OMX_StateLoaded) && pComponentPrivate->pOutPortDef->bPopulated) || 1837 pComponentPrivate->sOutSemaphore.bSignaled) { 1838 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sOutSemaphore); 1839 } 1840 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_OUTPUT_PORT IN 0x%x\n",pComponentPrivate->pInPortDef->bPopulated); 1841 pComponentPrivate->bOutPortSettingsChanged = OMX_FALSE; 1842 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 1843 pComponentPrivate->pHandle->pApplicationPrivate, 1844 OMX_EventCmdComplete, 1845 OMX_CommandPortDisable, 1846 VIDDEC_OUTPUT_PORT, 1847 NULL); 1848 } 1849 } 1850 #endif 1851 1852 /* Reset values to initial state*/ 1853 if(pComponentPrivate->bDynamicConfigurationInProgress){ 1854 if(pComponentPrivate->bOutPortSettingsChanged == OMX_FALSE && pComponentPrivate->bInPortSettingsChanged == OMX_FALSE){ 1855 pComponentPrivate->bDynamicConfigurationInProgress = OMX_FALSE; 1856 bFirstTimeToUnLoadCodec = OMX_TRUE; 1857 OMX_PRBUFFER1(pComponentPrivate->dbg, "bDynamicConfigurationInProgress = OMX_FALSE;\n"); 1858 } 1859 } 1860 1861 EXIT: 1862 OMX_PRINT1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 1863 return eError; 1864 } 1865 1866 OMX_ERRORTYPE VIDDEC_EmptyBufferDone(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, OMX_BUFFERHEADERTYPE* pBufferHeader) 1867 { 1868 //LOGI("VIDDEC_EmptyBufferDone: header %p buffer %p", pBufferHeader, pBufferHeader->pBuffer); 1869 ((VIDDEC_BUFFER_PRIVATE* )pBufferHeader->pInputPortPrivate)->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 1870 1871 // No buffer flag EOS event needs to be sent for INPUT port 1872 1873 OMX_ERRORTYPE ret = pComponentPrivate->cbInfo.EmptyBufferDone(pComponentPrivate->pHandle, 1874 pComponentPrivate->pHandle->pApplicationPrivate, 1875 pBufferHeader); 1876 1877 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->inputFlushCompletionMutex); 1878 OMX_U32 nCountInputBFromDsp = 0; 1879 pthread_mutex_lock(&pComponentPrivate->mutexInputBFromDSP); 1880 nCountInputBFromDsp = pComponentPrivate->nCountInputBFromDsp; 1881 pthread_mutex_unlock(&pComponentPrivate->mutexInputBFromDSP); 1882 if (pComponentPrivate->bIsInputFlushPending && nCountInputBFromDsp == 0) { 1883 VIDDEC_PTHREAD_MUTEX_SIGNAL(pComponentPrivate->inputFlushCompletionMutex); 1884 } 1885 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->inputFlushCompletionMutex); 1886 1887 return ret; 1888 } 1889 1890 OMX_ERRORTYPE VIDDEC_FillBufferDone(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, OMX_BUFFERHEADERTYPE* pBufferHeader) 1891 { 1892 //LOGI("VIDDEC_FillBufferDone: header %p buffer %p", pBufferHeader, pBufferHeader->pBuffer); 1893 ((VIDDEC_BUFFER_PRIVATE* )pBufferHeader->pOutputPortPrivate)->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 1894 1895 // OpenMAX-IL standard specifies that a component generates the OMX_EventBufferFlag event when an OUTPUT port 1896 // emits a buffer with the OMX_BUFFERFLAG_EOS flag set in the nFlags field 1897 if (pBufferHeader->nFlags & OMX_BUFFERFLAG_EOS) { 1898 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 1899 pComponentPrivate->pHandle->pApplicationPrivate, 1900 OMX_EventBufferFlag, 1901 VIDDEC_OUTPUT_PORT, 1902 pBufferHeader->nFlags, 1903 NULL); 1904 } 1905 1906 OMX_ERRORTYPE ret = pComponentPrivate->cbInfo.FillBufferDone(pComponentPrivate->pHandle, 1907 pComponentPrivate->pHandle->pApplicationPrivate, 1908 pBufferHeader); 1909 1910 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->outputFlushCompletionMutex); 1911 OMX_U32 nCountOutputBFromDsp = 0; 1912 pthread_mutex_lock(&pComponentPrivate->mutexOutputBFromDSP); 1913 nCountOutputBFromDsp = pComponentPrivate->nCountOutputBFromDsp; 1914 pthread_mutex_unlock(&pComponentPrivate->mutexOutputBFromDSP); 1915 if (pComponentPrivate->bIsOutputFlushPending && nCountOutputBFromDsp == 0) { 1916 VIDDEC_PTHREAD_MUTEX_SIGNAL(pComponentPrivate->outputFlushCompletionMutex); 1917 } 1918 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->outputFlushCompletionMutex); 1919 1920 return ret; 1921 } 1922 /* ========================================================================== */ 1923 /** 1924 * Return Buffers() 1925 * 1926 * Called by Disable and Enable Buffers, return the buffers to their respective source. 1927 * 1928 * @param 1929 * 1930 * @retval OMX_ErrorNone success, ready to roll 1931 * 1932 **/ 1933 /* ========================================================================== */ 1934 OMX_ERRORTYPE VIDDEC_ReturnBuffers (VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, OMX_U32 nParam1, OMX_BOOL bRetDSP) 1935 { 1936 OMX_U8 i = 0; 1937 OMX_ERRORTYPE eError = OMX_ErrorNone; 1938 OMX_BUFFERHEADERTYPE *pBuffHead; 1939 1940 OMX_PRBUFFER1(pComponentPrivate->dbg, "+++ENTERING\n"); 1941 OMX_PRBUFFER1(pComponentPrivate->dbg, "pComponentPrivate 0x%p nParam1 0x%lx bRetDSP 0x%x\n",pComponentPrivate,nParam1,bRetDSP); 1942 OMX_VidDec_Return(pComponentPrivate); 1943 if (nParam1 == pComponentPrivate->pInPortFormat->nPortIndex || nParam1 == OMX_ALL) { 1944 for (i = 0; i < pComponentPrivate->pInPortDef->nBufferCountActual; i++) { 1945 if((pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[i]->eBufferOwner == VIDDEC_BUFFER_WITH_DSP) && bRetDSP){ 1946 OMX_PRBUFFER1(pComponentPrivate->dbg, "inBuffer 0x%p eBufferOwner 0x%x\n",pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[i]->pBufferHdr, 1947 pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[i]->eBufferOwner); 1948 pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[i]->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 1949 pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[i]->pBufferHdr->nFilledLen = 0; 1950 1951 #ifdef __PERF_INSTRUMENTATION__ 1952 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 1953 pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[i]->pBufferHdr->pBuffer, 1954 pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[i]->pBufferHdr->nFilledLen, 1955 PERF_ModuleHLMM); 1956 #endif 1957 1958 eError = VIDDEC_EmptyBufferDone(pComponentPrivate, pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[i]->pBufferHdr); 1959 } 1960 } 1961 } 1962 if (nParam1 == pComponentPrivate->pOutPortFormat->nPortIndex || nParam1 == OMX_ALL) { 1963 if (pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->hTunnelComponent != NULL) { 1964 for (i = 0; i < pComponentPrivate->pOutPortDef->nBufferCountActual; i++) { 1965 OMX_PRBUFFER1(pComponentPrivate->dbg, "tunnelVideoDecBuffer[%x]=%x-%lx\n",i, 1966 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->eBufferOwner,pComponentPrivate->pOutPortDef->nBufferCountActual); 1967 OMX_PRBUFFER1(pComponentPrivate->dbg, "enter return %lx\n",pComponentPrivate->pOutPortDef->nBufferCountActual); 1968 if((pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->eBufferOwner == VIDDEC_BUFFER_WITH_DSP) && bRetDSP){ 1969 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->eBufferOwner = VIDDEC_BUFFER_WITH_TUNNELEDCOMP; 1970 OMX_PRBUFFER1(pComponentPrivate->dbg, "Buffer 0x%x eBufferOwner 0x%x\n",(int)pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->pBufferHdr 1971 ,pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->eBufferOwner); 1972 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->pBufferHdr->nFilledLen = 0; 1973 1974 #ifdef __PERF_INSTRUMENTATION__ 1975 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 1976 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->pBufferHdr->pBuffer, 1977 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->pBufferHdr->nFilledLen, 1978 PERF_ModuleLLMM); 1979 #endif 1980 1981 OMX_PRBUFFER1(pComponentPrivate->dbg, "VideDec->PostProc EmptyThisBuffer\n"); 1982 OMX_PRBUFFER1(pComponentPrivate->dbg, "wait to return buffer\n"); 1983 pBuffHead = (OMX_BUFFERHEADERTYPE*)pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->pBufferHdr; 1984 VIDDEC_Propagate_Mark(pComponentPrivate, pBuffHead); 1985 eError = OMX_EmptyThisBuffer(pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->hTunnelComponent, pBuffHead); 1986 } 1987 } 1988 } 1989 else { 1990 OMX_PRINT1(pComponentPrivate->dbg, "non tunneling\n"); 1991 for (i = 0; i < pComponentPrivate->pOutPortDef->nBufferCountActual; i++) { 1992 if((pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->eBufferOwner == VIDDEC_BUFFER_WITH_DSP) && bRetDSP){ 1993 OMX_PRBUFFER1(pComponentPrivate->dbg, "xBuffer 0x%p eBufferOwner 0x%x\n",pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->pBufferHdr, 1994 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->eBufferOwner); 1995 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 1996 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->pBufferHdr->nFilledLen = 0; 1997 1998 #ifdef __PERF_INSTRUMENTATION__ 1999 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 2000 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->pBufferHdr->pBuffer, 2001 pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->pBufferHdr->nFilledLen, 2002 PERF_ModuleHLMM); 2003 #endif 2004 2005 pBuffHead = (OMX_BUFFERHEADERTYPE*)pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[i]->pBufferHdr; 2006 VIDDEC_Propagate_Mark(pComponentPrivate, pBuffHead); 2007 eError = VIDDEC_FillBufferDone(pComponentPrivate, pBuffHead); 2008 } 2009 } 2010 } 2011 } 2012 OMX_PRBUFFER1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 2013 return eError; 2014 } 2015 2016 2017 /* ========================================================================== */ 2018 /** 2019 * Enable Port() 2020 * 2021 * Called by component thread, handles commands sent by the app. 2022 * 2023 * @param 2024 * 2025 * @retval OMX_ErrorNone success, ready to roll 2026 * 2027 **/ 2028 /* ========================================================================== */ 2029 OMX_ERRORTYPE VIDDEC_EnablePort (VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, OMX_U32 nParam1) 2030 { 2031 OMX_ERRORTYPE eError = OMX_ErrorNone; 2032 OMX_PRINT1(pComponentPrivate->dbg, "+++ENTERING\n"); 2033 OMX_PRINT1(pComponentPrivate->dbg, "pComponentPrivate 0x%p nParam1 0x%lx\n",pComponentPrivate, nParam1); 2034 2035 #ifdef UNDER_CE 2036 while(1) { 2037 if (nParam1 == VIDDEC_INPUT_PORT && (pComponentPrivate->eState == OMX_StateLoaded || pComponentPrivate->pInPortDef->bPopulated)) { 2038 /* return cmdcomplete event if input unpopulated */ 2039 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_INPUT_PORT 0x%x\n",pComponentPrivate->pInPortDef->bEnabled); 2040 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 2041 pComponentPrivate->pHandle->pApplicationPrivate, 2042 OMX_EventCmdComplete, 2043 OMX_CommandPortEnable, 2044 VIDDEC_INPUT_PORT, 2045 NULL); 2046 break; 2047 } 2048 else if (nParam1 == VIDDEC_OUTPUT_PORT && (pComponentPrivate->eState == OMX_StateLoaded || 2049 pComponentPrivate->pOutPortDef->bPopulated)) { 2050 /* return cmdcomplete event if output unpopulated */ 2051 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_OUTPUT_PORT 0x%x\n",pComponentPrivate->pOutPortDef->bEnabled); 2052 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 2053 pComponentPrivate->pHandle->pApplicationPrivate, 2054 OMX_EventCmdComplete, 2055 OMX_CommandPortEnable, 2056 VIDDEC_OUTPUT_PORT, 2057 NULL); 2058 break; 2059 } 2060 else if (nParam1 == VIDDEC_BOTH_PORT && (pComponentPrivate->eState == OMX_StateLoaded || 2061 (pComponentPrivate->pInPortDef->bPopulated && 2062 pComponentPrivate->pOutPortDef->bPopulated))) { 2063 /* return cmdcomplete event if inout & output unpopulated */ 2064 OMX_PRBUFFER2(pComponentPrivate->dbg, "Enabling VIDDEC_OUTPUT_PORT 0x%x\n",pComponentPrivate->pOutPortDef->bEnabled); 2065 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_INPUT_PORT 0x%x\n",pComponentPrivate->pOutPortDef->bEnabled); 2066 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 2067 pComponentPrivate->pHandle->pApplicationPrivate, 2068 OMX_EventCmdComplete, 2069 OMX_CommandPortEnable, 2070 VIDDEC_INPUT_PORT, 2071 NULL); 2072 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_OUTPUT_PORT 0x%x\n",pComponentPrivate->pOutPortDef->bEnabled); 2073 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 2074 pComponentPrivate->pHandle->pApplicationPrivate, 2075 OMX_EventCmdComplete, 2076 OMX_CommandPortEnable, 2077 VIDDEC_OUTPUT_PORT, 2078 NULL); 2079 break; 2080 } 2081 else if (nParam1 == OMX_ALL && && (pComponentPrivate->eState == OMX_StateLoaded || 2082 pComponentPrivate->pInPortDef->bPopulated) && 2083 (pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL)) { 2084 /* return cmdcomplete event if inout & output unpopulated */ 2085 OMX_PRBUFFER2(pComponentPrivate->dbg, "Enabling VIDDEC_OUTPUT_PORT 0x%x\n",pComponentPrivate->pOutPortDef->bEnabled); 2086 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_INPUT_PORT 0x%x\n",pComponentPrivate->pOutPortDef->bEnabled); 2087 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 2088 pComponentPrivate->pHandle->pApplicationPrivate, 2089 OMX_EventCmdComplete, 2090 OMX_CommandPortEnable, 2091 VIDDEC_INPUT_PORT, 2092 NULL); 2093 break; 2094 } 2095 VIDDEC_WAIT_CODE(); 2096 } 2097 #else 2098 if (nParam1 == VIDDEC_INPUT_PORT) { 2099 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_INPUT_PORT IN 0x%x\n",pComponentPrivate->pInPortDef->bPopulated); 2100 if((!(pComponentPrivate->eState == OMX_StateLoaded) && !pComponentPrivate->pInPortDef->bPopulated) || 2101 pComponentPrivate->sInSemaphore.bSignaled) { 2102 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 2103 } 2104 2105 2106 if(pComponentPrivate->eLCMLState == VidDec_LCML_State_Unload && 2107 pComponentPrivate->bDynamicConfigurationInProgress == OMX_FALSE && 2108 pComponentPrivate->pInPortDef->bEnabled == OMX_TRUE && 2109 pComponentPrivate->pOutPortDef->bEnabled == OMX_TRUE){ 2110 OMX_PRBUFFER1(pComponentPrivate->dbg, "BSC VIDDEC_INPUT_PORT\n"); 2111 eError = VIDDEC_LoadCodec(pComponentPrivate); 2112 if(eError != OMX_ErrorNone){ 2113 goto EXIT; 2114 } 2115 } 2116 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 2117 pComponentPrivate->pHandle->pApplicationPrivate, 2118 OMX_EventCmdComplete, 2119 OMX_CommandPortEnable, 2120 VIDDEC_INPUT_PORT, 2121 NULL); 2122 } 2123 else if (nParam1 == VIDDEC_OUTPUT_PORT) { 2124 2125 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_OUTPUT_PORT OUT 0x%x\n",pComponentPrivate->pOutPortDef->bPopulated); 2126 if((!(pComponentPrivate->eState == OMX_StateLoaded) && !pComponentPrivate->pOutPortDef->bPopulated) || 2127 pComponentPrivate->sOutSemaphore.bSignaled) { 2128 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sOutSemaphore); 2129 } 2130 2131 if(pComponentPrivate->eLCMLState == VidDec_LCML_State_Unload && 2132 pComponentPrivate->bDynamicConfigurationInProgress == OMX_FALSE && 2133 pComponentPrivate->pInPortDef->bEnabled == OMX_TRUE && 2134 pComponentPrivate->pOutPortDef->bEnabled == OMX_TRUE){ 2135 OMX_PRBUFFER1(pComponentPrivate->dbg, "BSC VIDDEC_OUTPUT_PORT\n"); 2136 eError = VIDDEC_LoadCodec(pComponentPrivate); 2137 if(eError != OMX_ErrorNone){ 2138 goto EXIT; 2139 } 2140 } 2141 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 2142 pComponentPrivate->pHandle->pApplicationPrivate, 2143 OMX_EventCmdComplete, 2144 OMX_CommandPortEnable, 2145 VIDDEC_OUTPUT_PORT, 2146 NULL); 2147 } 2148 else if (nParam1 == OMX_ALL) { 2149 if(pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL) { 2150 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_INPUT_PORT IN 0x%x\n",pComponentPrivate->pInPortDef->bPopulated); 2151 if((!(pComponentPrivate->eState == OMX_StateLoaded) && !pComponentPrivate->pInPortDef->bPopulated) || 2152 pComponentPrivate->sInSemaphore.bSignaled) { 2153 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 2154 } 2155 2156 if(pComponentPrivate->eLCMLState == VidDec_LCML_State_Unload){ 2157 eError = VIDDEC_LoadCodec(pComponentPrivate); 2158 if(eError != OMX_ErrorNone){ 2159 goto EXIT; 2160 } 2161 } 2162 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 2163 pComponentPrivate->pHandle->pApplicationPrivate, 2164 OMX_EventCmdComplete, 2165 OMX_CommandPortEnable, 2166 VIDDEC_INPUT_PORT, 2167 NULL); 2168 } 2169 else { 2170 if((!(pComponentPrivate->eState == OMX_StateLoaded) && !pComponentPrivate->pInPortDef->bPopulated) || 2171 pComponentPrivate->sInSemaphore.bSignaled) { 2172 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 2173 } 2174 if(pComponentPrivate->eLCMLState == VidDec_LCML_State_Unload){ 2175 OMX_PRBUFFER1(pComponentPrivate->dbg, "BSC OMX_ALL\n"); 2176 eError = VIDDEC_LoadCodec(pComponentPrivate); 2177 if(eError != OMX_ErrorNone){ 2178 goto EXIT; 2179 } 2180 } 2181 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_INPUT_PORT IN 0x%x\n",pComponentPrivate->pInPortDef->bPopulated); 2182 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 2183 pComponentPrivate->pHandle->pApplicationPrivate, 2184 OMX_EventCmdComplete, 2185 OMX_CommandPortEnable, 2186 VIDDEC_INPUT_PORT, 2187 NULL); 2188 if((!(pComponentPrivate->eState == OMX_StateLoaded) && !pComponentPrivate->pOutPortDef->bPopulated) || 2189 pComponentPrivate->sOutSemaphore.bSignaled) { 2190 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sOutSemaphore); 2191 } 2192 OMX_PRBUFFER2(pComponentPrivate->dbg, "Populated VIDDEC_INPUT_PORT IN 0x%x\n",pComponentPrivate->pInPortDef->bPopulated); 2193 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 2194 pComponentPrivate->pHandle->pApplicationPrivate, 2195 OMX_EventCmdComplete, 2196 OMX_CommandPortEnable, 2197 VIDDEC_OUTPUT_PORT, 2198 NULL); 2199 } 2200 } 2201 #endif 2202 EXIT: 2203 OMX_PRINT1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 2204 return eError; 2205 } 2206 2207 /* ========================================================================== */ 2208 /** 2209 * HandleCommandFlush() 2210 * 2211 * Called by component thread, handles the flush command from thread. 2212 * 2213 * @param 2214 * 2215 * @retval OMX_ErrorNone success, ready to roll 2216 * 2217 **/ 2218 /* ========================================================================== */ 2219 2220 OMX_ERRORTYPE VIDDEC_HandleCommandFlush(VIDDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1, OMX_BOOL bPass) 2221 { 2222 OMX_ERRORTYPE eError = OMX_ErrorNone; 2223 OMX_U32 aParam[4]; 2224 LCML_DSP_INTERFACE *pLcmlHandle = NULL; 2225 2226 OMX_PRINT1(pComponentPrivate->dbg, "+++ENTERING\n"); 2227 OMX_PRINT1(pComponentPrivate->dbg, "pComponentPrivate 0x%p nParam1 0x%lx\n",pComponentPrivate, nParam1); 2228 2229 if ( nParam1 == VIDDEC_INPUT_PORT || nParam1 == OMX_ALL){ 2230 if(bPass) { 2231 OMX_VidDec_Return(pComponentPrivate); 2232 } 2233 2234 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 2235 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 2236 pComponentPrivate->pLCML != NULL && pComponentPrivate->bLCMLHalted != OMX_TRUE){ 2237 aParam[0] = USN_STRMCMD_FLUSH; 2238 aParam[1] = VIDDEC_INPUT_PORT; 2239 aParam[2] = 0; 2240 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 2241 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 2242 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,EMMCodecControlStrmCtrl, (void*)aParam); 2243 if (eError != OMX_ErrorNone) { 2244 eError = OMX_ErrorHardware; 2245 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 2246 goto EXIT; 2247 } 2248 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 2249 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 2250 2251 } 2252 VIDDEC_CircBuf_Flush(pComponentPrivate, VIDDEC_CBUFFER_TIMESTAMP, VIDDEC_INPUT_PORT); 2253 OMX_VidDec_Return(pComponentPrivate); 2254 if(bPass) { 2255 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->inputFlushCompletionMutex); 2256 pComponentPrivate->bIsInputFlushPending = OMX_TRUE; 2257 OMX_U32 nCountInputBFromDsp = 0; 2258 pthread_mutex_lock(&pComponentPrivate->mutexInputBFromDSP); 2259 nCountInputBFromDsp = pComponentPrivate->nCountInputBFromDsp; 2260 pthread_mutex_unlock(&pComponentPrivate->mutexInputBFromDSP); 2261 if (nCountInputBFromDsp > 0) { 2262 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->inputFlushCompletionMutex); 2263 } 2264 pComponentPrivate->bIsInputFlushPending = OMX_FALSE; 2265 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->inputFlushCompletionMutex); 2266 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2267 pComponentPrivate->pHandle->pApplicationPrivate, 2268 OMX_EventCmdComplete, 2269 OMX_CommandFlush, 2270 VIDDEC_INPUT_PORT, 2271 NULL); 2272 } 2273 } 2274 2275 if ( nParam1 == VIDDEC_OUTPUT_PORT || nParam1 == OMX_ALL){ 2276 if(bPass){ 2277 OMX_VidDec_Return(pComponentPrivate); 2278 } 2279 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 2280 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 2281 pComponentPrivate->pLCML != NULL && pComponentPrivate->bLCMLHalted != OMX_TRUE){ 2282 aParam[0] = USN_STRMCMD_FLUSH; 2283 aParam[1] = VIDDEC_OUTPUT_PORT; 2284 aParam[2] = 0; 2285 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 2286 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 2287 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,EMMCodecControlStrmCtrl, (void*)aParam); 2288 if (eError != OMX_ErrorNone) { 2289 eError = OMX_ErrorHardware; 2290 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 2291 goto EXIT; 2292 } 2293 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 2294 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 2295 } 2296 OMX_VidDec_Return(pComponentPrivate); 2297 if(bPass) { 2298 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->outputFlushCompletionMutex); 2299 pComponentPrivate->bIsOutputFlushPending = OMX_TRUE; 2300 OMX_U32 nCountOutputBFromDsp = 0; 2301 pthread_mutex_lock(&pComponentPrivate->mutexOutputBFromDSP); 2302 nCountOutputBFromDsp = pComponentPrivate->nCountOutputBFromDsp; 2303 pthread_mutex_unlock(&pComponentPrivate->mutexOutputBFromDSP); 2304 if (nCountOutputBFromDsp > 0) { 2305 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->outputFlushCompletionMutex); 2306 } 2307 pComponentPrivate->bIsOutputFlushPending = OMX_FALSE; 2308 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->outputFlushCompletionMutex); 2309 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2310 pComponentPrivate->pHandle->pApplicationPrivate, 2311 OMX_EventCmdComplete, 2312 OMX_CommandFlush, 2313 VIDDEC_OUTPUT_PORT, 2314 NULL); 2315 2316 } 2317 } 2318 EXIT: 2319 OMX_PRINT1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 2320 return eError; 2321 2322 } 2323 2324 /* ========================================================================== */ 2325 /** 2326 * HandleCommandMarkBuffer() 2327 * 2328 * Called by component thread, handles the Mark Buffer command from thread. 2329 * 2330 * @param 2331 * 2332 * @retval OMX_ErrorNone success, ready to roll 2333 * 2334 **/ 2335 /* ========================================================================== */ 2336 2337 OMX_ERRORTYPE VIDDEC_HandleCommandMarkBuffer(VIDDEC_COMPONENT_PRIVATE *pComponentPrivate, OMX_U32 nParam1, OMX_PTR pCmdData) 2338 { 2339 OMX_ERRORTYPE eError = OMX_ErrorNone; 2340 OMX_PRBUFFER1(pComponentPrivate->dbg, "+++ENTERING\n"); 2341 OMX_PRBUFFER1(pComponentPrivate->dbg, "pComponentPrivate 0x%p nParam1 0x%lx pCmdData 0x%p\n",pComponentPrivate, nParam1, pCmdData); 2342 OMX_PRBUFFER1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 2343 return eError; 2344 2345 } 2346 /* ========================================================================== */ 2347 /** 2348 * OMX_HandleCommand() state machine in charge of interpretation of every 2349 * command received from application, depending on which state the component 2350 * is. 2351 **/ 2352 /* ========================================================================== */ 2353 2354 OMX_ERRORTYPE VIDDEC_HandleCommand (OMX_HANDLETYPE phandle, OMX_U32 nParam1) 2355 { 2356 OMX_U32 message[4]; 2357 OMX_U32 iCount = 0; 2358 VIDDEC_COMPONENT_PRIVATE* pComponentPrivate = (VIDDEC_COMPONENT_PRIVATE*)phandle; 2359 LCML_DSP_INTERFACE *pLcmlHandle = NULL; 2360 OMX_PARAM_PORTDEFINITIONTYPE* pPortDefIn = pComponentPrivate->pInPortDef; 2361 OMX_PARAM_PORTDEFINITIONTYPE* pPortDefOut = pComponentPrivate->pOutPortDef; 2362 OMX_ERRORTYPE eError = OMX_ErrorNone; 2363 unsigned int cmd_rcv = 0; 2364 OMX_HANDLETYPE hLCML = NULL; 2365 void* p = NULL; 2366 2367 #ifdef UNDER_CE 2368 typedef OMX_ERRORTYPE (*LPFNDLLFUNC1)(OMX_HANDLETYPE); 2369 HINSTANCE hDLL; 2370 LPFNDLLFUNC1 fpGetHandle1; 2371 #else 2372 void* pMyLCML; 2373 VIDDEC_fpo fpGetHandle; 2374 char* error; 2375 #endif 2376 2377 OMX_PRINT1(pComponentPrivate->dbg, "+++ENTERING\n"); 2378 OMX_PRINT1(pComponentPrivate->dbg, "pComponentPrivate 0x%p phandle 0x%lx\n",pComponentPrivate, nParam1); 2379 pComponentPrivate->frameCounter = 0; 2380 2381 message[0] = 0x400; 2382 message[1] = 100; 2383 message[2] = 0; 2384 p = (void*)&message; 2385 cmd_rcv = (unsigned int)nParam1; 2386 2387 switch (nParam1) { 2388 case OMX_StateIdle: 2389 LOGD("Handle request for state transition: %d => OMX_StateIdle", pComponentPrivate->eState); 2390 if (pComponentPrivate->eState == OMX_StateIdle) { 2391 eError = OMX_ErrorSameState; 2392 OMX_PRSTATE4(pComponentPrivate->dbg, "Same State 0x%x\n", eError); 2393 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2394 pComponentPrivate->pHandle->pApplicationPrivate, 2395 OMX_EventError, 2396 OMX_ErrorSameState, 2397 OMX_TI_ErrorMinor, 2398 "Same state"); 2399 break; 2400 } 2401 else if (( pComponentPrivate->eState == OMX_StateLoaded) || pComponentPrivate->eState == OMX_StateWaitForResources ) { 2402 #ifdef __PERF_INSTRUMENTATION__ 2403 PERF_Boundary(pComponentPrivate->pPERFcomp, 2404 PERF_BoundaryStart | PERF_BoundarySetup); 2405 #endif 2406 2407 if ((pPortDefIn->bEnabled == OMX_TRUE && pPortDefOut->bEnabled == OMX_TRUE) || 2408 (pPortDefIn->bEnabled == OMX_TRUE && pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL)) { 2409 OMX_PRBUFFER1(pComponentPrivate->dbg, "Before pPortDefIn->bEnabled 0x%x pPortDefOut->bEnabled 0x%x\n",pPortDefIn->bEnabled, pPortDefOut->bEnabled); 2410 #ifdef UNDER_CE 2411 while (1) { 2412 if (pPortDefIn->bPopulated && pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL) { 2413 OMX_PRBUFFER1(pComponentPrivate->dbg, "tunneling pPortDefIn->bEnabled 0x%x pPortDefOut->bEnabled 0x%x\n", 2414 pPortDefIn->bEnabled, pPortDefOut->bEnabled); 2415 break; 2416 } 2417 if (pPortDefIn->bPopulated && pPortDefOut->bPopulated) { 2418 OMX_PRINT1(pComponentPrivate->dbg, "Standalone pPortDefIn->bEnabled 0x%x pPortDefOut->bEnabled 0x%x\n", 2419 pPortDefIn->bEnabled, pPortDefOut->bEnabled); 2420 break; 2421 } 2422 /* Sleep for a while, so the application thread can allocate buffers */ 2423 VIDDEC_WAIT_CODE(); 2424 } 2425 #else 2426 if(pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL) { 2427 if((!pComponentPrivate->pInPortDef->bPopulated) || pComponentPrivate->sInSemaphore.bSignaled) { 2428 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 2429 OMX_PRBUFFER1(pComponentPrivate->dbg, "tunneling pPortDefIn->bEnabled 0x%x pPortDefOut->bEnabled 0x%x\n", 2430 pPortDefIn->bEnabled, pPortDefOut->bEnabled); 2431 } 2432 } 2433 else { 2434 if((!pComponentPrivate->pOutPortDef->bPopulated) || pComponentPrivate->sOutSemaphore.bSignaled) { 2435 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 2436 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sOutSemaphore); 2437 OMX_PRBUFFER1(pComponentPrivate->dbg, "Standalone pPortDefIn->bEnabled 0x%x pPortDefOut->bEnabled 0x%x\n", 2438 pPortDefIn->bEnabled, pPortDefOut->bEnabled); 2439 } 2440 } 2441 #endif 2442 OMX_PRBUFFER1(pComponentPrivate->dbg, "After pPortDefIn->bEnabled 0x%x pPortDefOut->bEnabled 0x%x\n",pPortDefIn->bEnabled, pPortDefOut->bEnabled); 2443 } 2444 #ifndef UNDER_CE 2445 else { 2446 if(pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL) { 2447 if(pComponentPrivate->sInSemaphore.bSignaled){ 2448 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 2449 } 2450 } 2451 else { 2452 if(pComponentPrivate->sInSemaphore.bSignaled){ 2453 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 2454 } 2455 if(pComponentPrivate->sOutSemaphore.bSignaled){ 2456 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sOutSemaphore); 2457 } 2458 } 2459 } 2460 #endif 2461 2462 #if 1 2463 #ifndef UNDER_CE 2464 pMyLCML = dlopen("libLCML.so", RTLD_LAZY); 2465 if (!pMyLCML) { 2466 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorBadParameter\n"); 2467 fputs(dlerror(), stderr); 2468 eError = OMX_ErrorBadParameter; 2469 goto EXIT; 2470 } 2471 fpGetHandle = dlsym(pMyLCML, "GetHandle"); 2472 if ((error = dlerror()) != NULL) { 2473 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorBadParameter\n"); 2474 fputs(error, stderr); 2475 dlclose(pMyLCML); 2476 pMyLCML = NULL; 2477 eError = OMX_ErrorBadParameter; 2478 goto EXIT; 2479 } 2480 eError = (*fpGetHandle)(&hLCML); 2481 if (eError != OMX_ErrorNone) { 2482 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorBadParameter\n"); 2483 dlclose(pMyLCML); 2484 pMyLCML = NULL; 2485 eError = OMX_ErrorBadParameter; 2486 goto EXIT; 2487 } 2488 pComponentPrivate->pModLCML = pMyLCML; 2489 #else 2490 hDLL = LoadLibraryEx(TEXT("OAF_BML.dll"), NULL, 0); 2491 if (hDLL == NULL) { 2492 OMX_PRDSP4(pComponentPrivate->dbg, "BML Load Failed!!!\n"); 2493 eError = OMX_ErrorBadParameter; 2494 goto EXIT; 2495 } 2496 fpGetHandle1 = (LPFNDLLFUNC1)GetProcAddress(hDLL,TEXT("GetHandle")); 2497 if (!fpGetHandle1) { 2498 /* handle the error */ 2499 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorBadParameter\n"); 2500 FreeLibrary(hDLL); 2501 hDLL = NULL; 2502 eError = OMX_ErrorBadParameter; 2503 goto EXIT; 2504 } 2505 /* call the function */ 2506 eError = fpGetHandle1(&hLCML); 2507 if (eError != OMX_ErrorNone) { 2508 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorBadParameter\n"); 2509 FreeLibrary(hDLL); 2510 hDLL = NULL; 2511 eError = OMX_ErrorBadParameter; 2512 goto EXIT; 2513 } 2514 pComponentPrivate->pModLCML = hDLL; 2515 #endif 2516 2517 pComponentPrivate->eLCMLState = VidDec_LCML_State_Load; 2518 OMX_PRDSP2(pComponentPrivate->dbg, "LCML Handler 0x%p\n",hLCML); 2519 /*(LCML_DSP_INTERFACE*)pComponentPrivate->pLCML = (LCML_DSP_INTERFACE*)hLCML;*/ 2520 pComponentPrivate->pLCML = (LCML_DSP_INTERFACE*)hLCML; 2521 pComponentPrivate->pLCML->pComponentPrivate = pComponentPrivate; 2522 #endif 2523 2524 #ifdef __PERF_INSTRUMENTATION__ 2525 pComponentPrivate->lcml_nCntOpReceived = 0; 2526 #endif 2527 eError = OMX_ErrorNone; 2528 #ifndef UNDER_CE 2529 pComponentPrivate->bLCMLOut = OMX_TRUE; 2530 #endif 2531 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 2532 eError = VIDDEC_InitDSP_H264Dec(pComponentPrivate); 2533 } 2534 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 2535 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 2536 eError = VIDDEC_InitDSP_Mpeg4Dec(pComponentPrivate); 2537 } 2538 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 2539 eError = VIDDEC_InitDSP_Mpeg2Dec(pComponentPrivate); 2540 } 2541 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 2542 eError = VIDDEC_InitDSP_WMVDec(pComponentPrivate); 2543 } 2544 #ifdef VIDDEC_SPARK_CODE 2545 else if (VIDDEC_SPARKCHECK) { 2546 eError = VIDDEC_InitDSP_SparkDec(pComponentPrivate); 2547 } 2548 #endif 2549 else { 2550 OMX_ERROR4(pComponentPrivate->dbg, "OMX_ErrorUnsupportedSetting\n"); 2551 eError = OMX_ErrorUnsupportedSetting; 2552 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2553 pComponentPrivate->pHandle->pApplicationPrivate, 2554 OMX_EventError, 2555 OMX_ErrorUnsupportedSetting, 2556 OMX_TI_ErrorMinor, 2557 "DSP Initialization"); 2558 goto EXIT; 2559 } 2560 /************************************************************************/ 2561 /************************************************************************/ 2562 /************************************************************************/ 2563 if(eError != OMX_ErrorNone){ 2564 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 2565 pComponentPrivate->pModLCML != NULL){ 2566 #ifndef UNDER_CE 2567 if(pComponentPrivate->pModLCML != NULL){ 2568 dlclose(pComponentPrivate->pModLCML); 2569 pComponentPrivate->pModLCML = NULL; 2570 pComponentPrivate->pLCML = NULL; 2571 pComponentPrivate->eLCMLState = VidDec_LCML_State_Unload; 2572 } 2573 #else 2574 if(pComponentPrivate->pModLCML != NULL){ 2575 FreeLibrary(pComponentPrivate->pModLCML); 2576 pComponentPrivate->pModLCML = NULL; 2577 pComponentPrivate->pLCML = NULL; 2578 pComponentPrivate->eLCMLState = VidDec_LCML_State_Unload; 2579 } 2580 #endif 2581 2582 pComponentPrivate->bLCMLHalted = OMX_TRUE; 2583 } 2584 OMX_PRDSP4(pComponentPrivate->dbg, "LCML Error %x\n", pComponentPrivate->eState); 2585 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2586 pComponentPrivate->pHandle->pApplicationPrivate, 2587 OMX_EventError, 2588 eError, 2589 OMX_TI_ErrorSevere, 2590 "DSP Initialization"); 2591 goto EXIT; 2592 } 2593 2594 #ifndef UNDER_CE 2595 pComponentPrivate->bLCMLOut = OMX_FALSE; 2596 #endif 2597 pComponentPrivate->bLCMLHalted = OMX_FALSE; 2598 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 2599 if (!pLcmlHandle) { 2600 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorBadParameter\n"); 2601 eError = OMX_ErrorHardware; 2602 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2603 pComponentPrivate->pHandle->pApplicationPrivate, 2604 OMX_EventError, 2605 OMX_ErrorHardware, 2606 OMX_TI_ErrorSevere, 2607 "Lcml Handle NULL"); 2608 goto EXIT; 2609 } 2610 pComponentPrivate->eLCMLState = VidDec_LCML_State_Init; 2611 OMX_PRINT1(pComponentPrivate->dbg, "OUTPUT width=%lu height=%lu\n", pComponentPrivate->pOutPortDef->format.video.nFrameWidth, pComponentPrivate->pOutPortDef->format.video.nFrameHeight); 2612 OMX_PRINT1(pComponentPrivate->dbg, "INPUT width=%lu height=%lu\n", pComponentPrivate->pInPortDef->format.video.nFrameWidth, pComponentPrivate->pInPortDef->format.video.nFrameHeight); 2613 2614 2615 #if 1 2616 #ifdef RESOURCE_MANAGER_ENABLED 2617 pComponentPrivate->rmproxyCallback.RMPROXY_Callback = (void *) VIDDEC_ResourceManagerCallback; 2618 if(pComponentPrivate->eRMProxyState != VidDec_RMPROXY_State_Unload){ 2619 OMX_PRMGR2(pComponentPrivate->dbg, "memory usage 1 %u : %u bytes\n",(unsigned int)pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel0],(unsigned int)VIDDEC_MEMUSAGE); 2620 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 2621 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_RequestResource, OMX_H264_Decode_COMPONENT, VIDDEC_GetRMFrecuency(pComponentPrivate), VIDDEC_MEMUSAGE, &(pComponentPrivate->rmproxyCallback)); 2622 } 2623 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4) { 2624 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_RequestResource, OMX_MPEG4_Decode_COMPONENT, VIDDEC_GetRMFrecuency(pComponentPrivate), VIDDEC_MEMUSAGE, &(pComponentPrivate->rmproxyCallback)); 2625 } 2626 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 2627 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_RequestResource, OMX_H263_Decode_COMPONENT, VIDDEC_GetRMFrecuency(pComponentPrivate), VIDDEC_MEMUSAGE, &(pComponentPrivate->rmproxyCallback)); 2628 } 2629 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 2630 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_RequestResource, OMX_MPEG2_Decode_COMPONENT, VIDDEC_GetRMFrecuency(pComponentPrivate), VIDDEC_MEMUSAGE, &(pComponentPrivate->rmproxyCallback)); 2631 } 2632 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 2633 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_RequestResource, OMX_WMV_Decode_COMPONENT, VIDDEC_GetRMFrecuency(pComponentPrivate), VIDDEC_MEMUSAGE, &(pComponentPrivate->rmproxyCallback)); 2634 } 2635 #ifdef VIDDEC_SPARK_CODE 2636 else if (VIDDEC_SPARKCHECK) { 2637 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_RequestResource, OMX_MPEG4_Decode_COMPONENT, VIDDEC_GetRMFrecuency(pComponentPrivate), VIDDEC_MEMUSAGE, &(pComponentPrivate->rmproxyCallback)); 2638 } 2639 #endif 2640 else { 2641 eError = OMX_ErrorUnsupportedSetting; 2642 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2643 pComponentPrivate->pHandle->pApplicationPrivate, 2644 OMX_EventError, 2645 OMX_ErrorUnsupportedSetting, 2646 OMX_TI_ErrorMajor, 2647 "RM SendCommand OMX_ErrorUnsupportedSetting Error"); 2648 OMX_PRMGR4(pComponentPrivate->dbg, "OMX_ErrorUnsupportedSetting 0x%x\n",eError); 2649 goto EXIT; 2650 } 2651 if (eError != OMX_ErrorNone) { 2652 pComponentPrivate->eState = OMX_StateLoaded; 2653 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2654 pComponentPrivate->pHandle->pApplicationPrivate, 2655 OMX_EventError, 2656 OMX_ErrorInsufficientResources, 2657 OMX_TI_ErrorMajor, 2658 "RM SendCommand Error"); 2659 OMX_PRMGR4(pComponentPrivate->dbg, "OMX_ErrorUnsupportedSetting 0x%x\n",eError); 2660 break; 2661 } 2662 pComponentPrivate->eRMProxyState = VidDec_RMPROXY_State_Registered; 2663 } 2664 #endif 2665 #endif 2666 /* Send command to USN to do the propagation of the EOS flag */ 2667 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 2668 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 2669 pComponentPrivate->pLCML != NULL && 2670 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 2671 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlUsnEos 0x%p\n",pLcmlHandle); 2672 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,EMMCodecControlUsnEos, NULL); 2673 if (eError != OMX_ErrorNone) { 2674 OMX_PRDSP4(pComponentPrivate->dbg, "error in EMMCodecControlUsnEos %x\n",eError); 2675 eError = OMX_ErrorHardware; 2676 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2677 pComponentPrivate->pHandle->pApplicationPrivate, 2678 OMX_EventError, 2679 OMX_ErrorHardware, 2680 OMX_TI_ErrorSevere, 2681 "LCML_ControlCodec EMMCodecControlUsnEos function"); 2682 OMX_ERROR4(pComponentPrivate->dbg, "OMX_ErrorHardware 0x%x\n",eError); 2683 goto EXIT; 2684 } 2685 } 2686 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat != OMX_VIDEO_CodingWMV) { 2687 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 2688 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 2689 pComponentPrivate->pLCML != NULL && 2690 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 2691 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 2692 message[1] = 4; 2693 } 2694 else { 2695 message[1] = 100; 2696 } 2697 message[0] = 0x400; 2698 message[2] = 0; 2699 p = (void*)&message; 2700 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 2701 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlSendDspMessage 0x%p\n",pLcmlHandle); 2702 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,EMMCodecControlSendDspMessage, (void *)p); 2703 if (eError != OMX_ErrorNone) { 2704 OMX_PRDSP4(pComponentPrivate->dbg, "error in EMMCodecControlSendDspMessage %x\n",eError); 2705 eError = OMX_ErrorHardware; 2706 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2707 pComponentPrivate->pHandle->pApplicationPrivate, 2708 OMX_EventError, 2709 OMX_ErrorHardware, 2710 OMX_TI_ErrorSevere, 2711 "LCML_ControlCodec function"); 2712 OMX_ERROR4(pComponentPrivate->dbg, "OMX_ErrorHardware 0x%x\n",eError); 2713 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 2714 goto EXIT; 2715 } 2716 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 2717 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 2718 } 2719 } 2720 2721 pComponentPrivate->eState = OMX_StateIdle; 2722 pComponentPrivate->bIsPaused = 0; 2723 2724 /* Decrement reference count with signal enabled */ 2725 if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { 2726 return OMX_ErrorUndefined; 2727 } 2728 2729 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2730 pComponentPrivate->pHandle->pApplicationPrivate, 2731 OMX_EventCmdComplete, 2732 OMX_CommandStateSet, 2733 pComponentPrivate->eState, 2734 NULL); 2735 LOGD("OMX_StateIdle state reached"); 2736 break; 2737 } 2738 else if (pComponentPrivate->eState == OMX_StateExecuting || pComponentPrivate->eState == OMX_StatePause) { 2739 /*Set the bIsStopping bit*/ 2740 if (pComponentPrivate->bDynamicConfigurationInProgress == OMX_TRUE) { 2741 pComponentPrivate->bDynamicConfigurationInProgress = OMX_FALSE; 2742 OMX_PRSTATE1(pComponentPrivate->dbg, "We were doing DynamicConfiguration, canceling it. %d \n",pComponentPrivate->bDynamicConfigurationInProgress); 2743 } 2744 pComponentPrivate->bIsStopping = 1; 2745 OMX_PRSTATE1(pComponentPrivate->dbg, "bIsStopping 0x%lx\n",pComponentPrivate->bIsStopping); 2746 OMX_PRSTATE1(pComponentPrivate->dbg, "eExecuteToIdle 0x%x\n",pComponentPrivate->eExecuteToIdle); 2747 OMX_VidDec_Return(pComponentPrivate); 2748 2749 #ifdef __PERF_INSTRUMENTATION__ 2750 PERF_Boundary(pComponentPrivate->pPERFcomp, 2751 PERF_BoundaryComplete | PERF_BoundarySteadyState); 2752 #endif 2753 pComponentPrivate->bIsPaused = 0; 2754 pComponentPrivate->iEndofInputSent = 0; 2755 /********************************************************************************************************************/ 2756 if (pComponentPrivate->bIsStopping == OMX_TRUE) { 2757 pComponentPrivate->bIsPaused = OMX_FALSE; 2758 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 2759 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 2760 pComponentPrivate->pLCML != NULL && 2761 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 2762 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 2763 pLcmlHandle = (LCML_DSP_INTERFACE *)pComponentPrivate->pLCML; 2764 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, MMCodecControlStop, NULL); 2765 if (eError != OMX_ErrorNone) { 2766 eError = OMX_ErrorHardware; 2767 OMX_PRDSP4(pComponentPrivate->dbg, "Error Occurred in Codec Stop...\n"); 2768 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 2769 break; 2770 } 2771 pComponentPrivate->eLCMLState = VidDec_LCML_State_Stop; 2772 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 2773 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 2774 } 2775 VIDDEC_HandleCommandFlush(pComponentPrivate, -1, OMX_FALSE); 2776 2777 #if 1 2778 #ifdef RESOURCE_MANAGER_ENABLED 2779 if(pComponentPrivate->eRMProxyState != VidDec_RMPROXY_State_Unload){ 2780 OMX_PRMGR2(pComponentPrivate->dbg, "memory usage 2 %d : %d bytes\n",(unsigned int)pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel0],(unsigned int)VIDDEC_MEMUSAGE); 2781 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 2782 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_H264_Decode_COMPONENT, OMX_StateIdle, VIDDEC_MEMUSAGE, NULL); 2783 } 2784 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4) { 2785 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_MPEG4_Decode_COMPONENT, OMX_StateIdle, VIDDEC_MEMUSAGE, NULL); 2786 } 2787 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 2788 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_H263_Decode_COMPONENT, OMX_StateIdle, VIDDEC_MEMUSAGE, NULL); 2789 } 2790 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 2791 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_MPEG2_Decode_COMPONENT, OMX_StateIdle, VIDDEC_MEMUSAGE, NULL); 2792 } 2793 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 2794 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_WMV_Decode_COMPONENT, OMX_StateIdle, VIDDEC_MEMUSAGE, NULL); 2795 } 2796 #ifdef VIDDEC_SPARK_CODE 2797 else if (VIDDEC_SPARKCHECK) { 2798 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_MPEG4_Decode_COMPONENT, OMX_StateIdle, VIDDEC_MEMUSAGE, NULL); 2799 } 2800 #endif 2801 } 2802 #endif 2803 #endif 2804 OMX_MEMFREE_STRUCT_DSPALIGN(pComponentPrivate->pUalgParams,OMX_PTR); 2805 2806 pComponentPrivate->bIsStopping = OMX_FALSE; 2807 pComponentPrivate->eState = OMX_StateIdle; 2808 /* Decrement reference count with signal enabled */ 2809 if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { 2810 return OMX_ErrorUndefined; 2811 } 2812 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2813 pComponentPrivate->pHandle->pApplicationPrivate, 2814 OMX_EventCmdComplete, 2815 OMX_CommandStateSet, 2816 pComponentPrivate->eState, 2817 NULL); 2818 LOGD("OMX_StateIdle state reached"); 2819 eError = OMX_ErrorNone; 2820 pComponentPrivate->bTransPause = 0; 2821 pComponentPrivate->bIsPaused = 0; 2822 pComponentPrivate->eExecuteToIdle = OMX_StateInvalid; 2823 } 2824 /********************************************************************************************************************/ 2825 2826 } 2827 else { 2828 eError = OMX_ErrorIncorrectStateTransition; 2829 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2830 pComponentPrivate->pHandle->pApplicationPrivate, 2831 OMX_EventError, 2832 OMX_ErrorIncorrectStateTransition, 2833 OMX_TI_ErrorMinor, 2834 NULL); 2835 OMX_ERROR4(pComponentPrivate->dbg, "OMX_ErrorHardware 0x%x\n",eError); 2836 } 2837 pComponentPrivate->eExecuteToIdle = OMX_StateInvalid; 2838 OMX_PRSTATE1(pComponentPrivate->dbg, "Passing bIsStopping 0x%lx\n",pComponentPrivate->bIsStopping); 2839 OMX_PRSTATE1(pComponentPrivate->dbg, "Passing eExecuteToIdle 0x%x\n",pComponentPrivate->eExecuteToIdle); 2840 break; 2841 2842 case OMX_StateExecuting: 2843 #ifdef __PERF_INSTRUMENTATION__ 2844 pComponentPrivate->lcml_nCntOpReceived = 0; 2845 #endif 2846 OMX_PRSTATE2(pComponentPrivate->dbg, "Transitioning to OMX_StateExecuting C 0x%x N 0x%lx\n",pComponentPrivate->eState, nParam1); 2847 if (pComponentPrivate->eState == OMX_StateExecuting) { 2848 eError = OMX_ErrorSameState; 2849 pComponentPrivate->cbInfo.EventHandler (pComponentPrivate->pHandle, 2850 pComponentPrivate->pHandle->pApplicationPrivate, 2851 OMX_EventError, 2852 OMX_ErrorSameState, 2853 OMX_TI_ErrorMinor, 2854 "Invalid State"); 2855 OMX_PRSTATE4(pComponentPrivate->dbg, "OMX_ErrorSameState 0x%x\n",eError); 2856 } 2857 else if (pComponentPrivate->eState == OMX_StateIdle || pComponentPrivate->eState == OMX_StatePause) { 2858 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 2859 pComponentPrivate->bIsPaused = 0; 2860 pComponentPrivate->bFirstBuffer = 1; 2861 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 2862 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 2863 pComponentPrivate->pLCML != NULL && 2864 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 2865 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlStart 0x%p\n",pLcmlHandle); 2866 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,EMMCodecControlStart,NULL); 2867 if (eError != OMX_ErrorNone) { 2868 eError = OMX_ErrorHardware; 2869 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 2870 pComponentPrivate->pHandle->pApplicationPrivate, 2871 OMX_EventError, 2872 OMX_ErrorHardware, 2873 OMX_TI_ErrorSevere, 2874 "LCML_ControlCodec Start"); 2875 break; 2876 OMX_PRDSP4(pComponentPrivate->dbg, "Occurred in Codec Start... 0x%x\n",eError); 2877 } 2878 } 2879 pComponentPrivate->eLCMLState = VidDec_LCML_State_Start; 2880 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC && 2881 pComponentPrivate->eState == OMX_StateIdle) { 2882 H264_Iualg_Cmd_SetStatus* pDynParams = NULL; 2883 char* pTmp = NULL; 2884 OMX_U32 cmdValues[3] = {0, 0, 0}; 2885 2886 VIDDEC_Load_Defaults(pComponentPrivate, VIDDEC_INIT_IDLEEXECUTING); 2887 OMX_PRDSP2(pComponentPrivate->dbg, "Initializing DSP for h264 eCompressionFormat 0x%x\n", 2888 pComponentPrivate->pInPortDef->format.video.eCompressionFormat); 2889 OMX_MALLOC_STRUCT_SIZED(pDynParams, H264_Iualg_Cmd_SetStatus, sizeof(H264_Iualg_Cmd_SetStatus) + VIDDEC_PADDING_FULL,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 2890 if (pDynParams == NULL) { 2891 OMX_TRACE4(pComponentPrivate->dbg, "Error: Malloc failed\n"); 2892 eError = OMX_ErrorInsufficientResources; 2893 goto EXIT; 2894 } 2895 memset(pDynParams, 0, sizeof(H264_Iualg_Cmd_SetStatus) + VIDDEC_PADDING_FULL); 2896 pTmp = (char*)pDynParams; 2897 pTmp += VIDDEC_PADDING_HALF; 2898 pDynParams = (H264_Iualg_Cmd_SetStatus*)pTmp; 2899 #ifdef VIDDEC_SN_R8_14 2900 pDynParams->size = sizeof(H264_Iualg_Cmd_SetStatus); 2901 #endif 2902 pDynParams->ulDecodeHeader = 1; 2903 pDynParams->ulDisplayWidth = 0; 2904 pDynParams->ulFrameSkipMode = 0; 2905 pDynParams->ulPPType = 0; 2906 2907 cmdValues[0] = IUALG_CMD_SETSTATUS; 2908 cmdValues[1] = (OMX_U32)(pDynParams); 2909 cmdValues[2] = sizeof(H264_Iualg_Cmd_SetStatus); 2910 2911 p = (void*)&cmdValues; 2912 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 2913 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 2914 pComponentPrivate->pLCML != NULL && 2915 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 2916 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 2917 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 2918 EMMCodecControlAlgCtrl, 2919 (void*)p); 2920 if (eError != OMX_ErrorNone) { 2921 eError = OMX_ErrorHardware; 2922 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 2923 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,H264_Iualg_Cmd_SetStatus); 2924 break; 2925 } 2926 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 2927 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 2928 } 2929 2930 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,H264_Iualg_Cmd_SetStatus); 2931 2932 if (eError != OMX_ErrorNone) { 2933 OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError); 2934 goto EXIT; 2935 } 2936 } 2937 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2 && 2938 pComponentPrivate->eState == OMX_StateIdle) { 2939 MP2VDEC_UALGDynamicParams* pDynParams = NULL; 2940 char* pTmp = NULL; 2941 OMX_U32 cmdValues[3] = {0, 0, 0}; 2942 2943 VIDDEC_Load_Defaults(pComponentPrivate, VIDDEC_INIT_IDLEEXECUTING); 2944 OMX_PRDSP2(pComponentPrivate->dbg, "Initializing DSP for wmv9 eCompressionFormat 0x%x\n", 2945 pComponentPrivate->pInPortDef->format.video.eCompressionFormat); 2946 OMX_MALLOC_STRUCT_SIZED(pDynParams, MP2VDEC_UALGDynamicParams, sizeof(MP2VDEC_UALGDynamicParams) + VIDDEC_PADDING_FULL,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 2947 memset(pDynParams, 0, sizeof(MP2VDEC_UALGDynamicParams) + VIDDEC_PADDING_FULL); 2948 pTmp = (char*)pDynParams; 2949 pTmp += VIDDEC_PADDING_HALF; 2950 pDynParams = (MP2VDEC_UALGDynamicParams*)pTmp; 2951 2952 #ifdef VIDDEC_SN_R8_14 2953 pDynParams->size = sizeof(MP2VDEC_UALGDynamicParams); 2954 #endif 2955 if (pComponentPrivate->nDisplayWidth > 0) { 2956 if (pComponentPrivate->pInPortDef->format.video.nFrameWidth > pComponentPrivate->nDisplayWidth) { 2957 pComponentPrivate->nDisplayWidth = pComponentPrivate->pInPortDef->format.video.nFrameWidth; 2958 } 2959 pDynParams->ulDisplayWidth = (((pComponentPrivate->nDisplayWidth + 15) >> 4) << 4); 2960 if (pComponentPrivate->nDisplayWidth != pDynParams->ulDisplayWidth ) { 2961 pComponentPrivate->nDisplayWidth = pDynParams->ulDisplayWidth; 2962 OMX_PRINT2(pComponentPrivate->dbg, "warning Display Width adjusted to %lu\n",pDynParams->ulDisplayWidth); 2963 } 2964 } 2965 else if (pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL){ 2966 if (pComponentPrivate->pInPortDef->format.video.nFrameWidth > pComponentPrivate->nDisplayWidth) { 2967 pComponentPrivate->nDisplayWidth = pComponentPrivate->pInPortDef->format.video.nFrameWidth; 2968 } 2969 pDynParams->ulDisplayWidth = (((pComponentPrivate->nDisplayWidth + 15) >> 4) << 4); 2970 if (pComponentPrivate->nDisplayWidth != pDynParams->ulDisplayWidth ) { 2971 pComponentPrivate->nDisplayWidth = pDynParams->ulDisplayWidth; 2972 OMX_PRINT2(pComponentPrivate->dbg, "warning Display Width adjusted to %lu\n",pDynParams->ulDisplayWidth); 2973 } 2974 } 2975 else { 2976 pDynParams->ulDisplayWidth = 0; 2977 } 2978 pDynParams->ulDecodeHeader = 0; 2979 pDynParams->ulFrameSkipMode = 0; 2980 pDynParams->ulPPType = 0; 2981 pDynParams->ulPpNone = 0; 2982 if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT422) { 2983 pDynParams->ulDyna_chroma_format = MP2VIDDEC_YUVFORMAT_INTERLEAVED422; 2984 } 2985 else { 2986 pDynParams->ulDyna_chroma_format = MP2VIDDEC_YUVFORMAT_PLANAR420; 2987 } 2988 2989 cmdValues[0] = IUALG_CMD_SETSTATUS; 2990 cmdValues[1] = (OMX_U32)(pDynParams); 2991 cmdValues[2] = sizeof(MP2VDEC_UALGDynamicParams); 2992 2993 pComponentPrivate->bTransPause = 0; 2994 p = (void*)&cmdValues; 2995 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 2996 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 2997 pComponentPrivate->pLCML != NULL && 2998 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 2999 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 3000 EMMCodecControlAlgCtrl, 3001 (void*)p); 3002 if(eError != OMX_ErrorNone){ 3003 eError = OMX_ErrorHardware; 3004 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3005 pComponentPrivate->pHandle->pApplicationPrivate, 3006 OMX_EventError, 3007 eError, 3008 0x0, 3009 "LCML_ControlCodec function"); 3010 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP2VDEC_UALGDynamicParams); 3011 goto EXIT; 3012 } 3013 while(1) { 3014 if(pComponentPrivate->bTransPause != 0) { 3015 pComponentPrivate->bTransPause = 0; 3016 break; 3017 } 3018 VIDDEC_WAIT_CODE(); 3019 } 3020 } 3021 3022 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP2VDEC_UALGDynamicParams); 3023 3024 if (eError != OMX_ErrorNone) { 3025 OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError); 3026 goto EXIT; 3027 } 3028 } 3029 #ifdef VIDDEC_SPARK_CODE 3030 else if (VIDDEC_SPARKCHECK) { 3031 if(pComponentPrivate->eState == OMX_StateIdle) { 3032 SPARKVDEC_UALGDynamicParams* pDynParams = NULL; 3033 char* pTmp = NULL; 3034 OMX_U32 cmdValues[3] = {0, 0, 0}; 3035 3036 VIDDEC_Load_Defaults(pComponentPrivate, VIDDEC_INIT_IDLEEXECUTING); 3037 OMX_PRDSP2(pComponentPrivate->dbg, "Initializing DSP for mpeg4 and h263 eCompressionFormat 0x%x\n", 3038 pComponentPrivate->pInPortDef->format.video.eCompressionFormat); 3039 OMX_MALLOC_STRUCT_SIZED(pDynParams, SPARKVDEC_UALGDynamicParams, sizeof(SPARKVDEC_UALGDynamicParams) + VIDDEC_PADDING_FULL,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 3040 if (pDynParams == NULL) { 3041 OMX_TRACE4(pComponentPrivate->dbg, "Error: Malloc failed\n"); 3042 eError = OMX_ErrorInsufficientResources; 3043 goto EXIT; 3044 } 3045 memset(pDynParams, 0, sizeof(SPARKVDEC_UALGDynamicParams) + VIDDEC_PADDING_FULL); 3046 pTmp = (char*)pDynParams; 3047 pTmp += VIDDEC_PADDING_HALF; 3048 pDynParams = (SPARKVDEC_UALGDynamicParams*)pTmp; 3049 #ifdef VIDDEC_SN_R8_14 3050 pDynParams->size = sizeof(SPARKVDEC_UALGDynamicParams); 3051 #endif 3052 pDynParams->ulDecodeHeader = 0; 3053 pDynParams->ulDisplayWidth = 0; 3054 pDynParams->ulFrameSkipMode = 0; 3055 pDynParams->ulPPType = 0; 3056 3057 cmdValues[0] = IUALG_CMD_SETSTATUS; 3058 cmdValues[1] = (OMX_U32)(pDynParams); 3059 cmdValues[2] = sizeof(SPARKVDEC_UALGDynamicParams); 3060 3061 /*pComponentPrivate->bTransPause = 0;*//*flag to wait for the generated event*/ 3062 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 3063 p = (void*)&cmdValues; 3064 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 3065 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 3066 pComponentPrivate->pLCML != NULL && 3067 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 3068 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 3069 EMMCodecControlAlgCtrl, 3070 (void*)p); 3071 if (eError != OMX_ErrorNone) { 3072 eError = OMX_ErrorHardware; 3073 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,SPARKVDEC_UALGDynamicParams); 3074 goto EXIT; 3075 } 3076 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 3077 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 3078 } 3079 3080 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,SPARKVDEC_UALGDynamicParams); 3081 3082 if (eError != OMX_ErrorNone) { 3083 OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError); 3084 goto EXIT; 3085 } 3086 } 3087 } 3088 #endif 3089 else { 3090 if(pComponentPrivate->eState == OMX_StateIdle) { 3091 eError = VIDDEC_SetMpeg4_Parameters(pComponentPrivate); 3092 if (eError != OMX_ErrorNone){ 3093 goto EXIT; 3094 } 3095 } 3096 } 3097 3098 /* Start existing code */ 3099 #if 1 3100 #ifdef RESOURCE_MANAGER_ENABLED 3101 if(pComponentPrivate->eRMProxyState != VidDec_RMPROXY_State_Unload){ 3102 OMX_PRMGR2(pComponentPrivate->dbg, "memory usage 3 %d : %d bytes\n",(unsigned int)pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel0],(unsigned int)VIDDEC_MEMUSAGE); 3103 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 3104 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_H264_Decode_COMPONENT, OMX_StateExecuting, VIDDEC_MEMUSAGE, NULL); 3105 } 3106 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4) { 3107 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_MPEG4_Decode_COMPONENT, OMX_StateExecuting, VIDDEC_MEMUSAGE, NULL); 3108 } 3109 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 3110 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_H263_Decode_COMPONENT, OMX_StateExecuting, VIDDEC_MEMUSAGE, NULL); 3111 } 3112 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 3113 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_MPEG2_Decode_COMPONENT, OMX_StateExecuting, VIDDEC_MEMUSAGE, NULL); 3114 } 3115 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 3116 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_WMV_Decode_COMPONENT, OMX_StateExecuting, VIDDEC_MEMUSAGE, NULL); 3117 } 3118 #ifdef VIDDEC_SPARK_CODE 3119 else if (VIDDEC_SPARKCHECK) { 3120 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_MPEG4_Decode_COMPONENT, OMX_StateExecuting, VIDDEC_MEMUSAGE, NULL); 3121 } 3122 #endif 3123 else { 3124 eError = OMX_ErrorUnsupportedSetting; 3125 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3126 pComponentPrivate->pHandle->pApplicationPrivate, 3127 OMX_EventError, 3128 OMX_ErrorUnsupportedSetting, 3129 OMX_TI_ErrorMinor, 3130 "RM SendCommand OMX_ErrorUnsupportedSetting Error"); 3131 OMX_ERROR4(pComponentPrivate->dbg, "OMX_ErrorUnsupportedSetting 0x%x\n",eError); 3132 goto EXIT; 3133 } 3134 if (eError != OMX_ErrorNone) { 3135 pComponentPrivate->eState = OMX_StateLoaded; 3136 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3137 pComponentPrivate->pHandle->pApplicationPrivate, 3138 OMX_EventError, 3139 OMX_ErrorInsufficientResources, 3140 OMX_TI_ErrorMajor, 3141 "RM SendCommand Error"); 3142 OMX_PRMGR4(pComponentPrivate->dbg, "OMX_ErrorUnsupportedSetting 0x%x\n",eError); 3143 break; 3144 } 3145 } 3146 #endif 3147 #endif 3148 3149 eError = OMX_ErrorNone; 3150 pComponentPrivate->bIsPaused = 0; 3151 pComponentPrivate->iEndofInputSent = 0; 3152 pComponentPrivate->eState = OMX_StateExecuting; 3153 /* Decrement reference count with signal enabled */ 3154 if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { 3155 return OMX_ErrorUndefined; 3156 } 3157 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3158 pComponentPrivate->pHandle->pApplicationPrivate, 3159 OMX_EventCmdComplete, 3160 OMX_CommandStateSet, 3161 pComponentPrivate->eState, 3162 NULL); 3163 OMX_PRSTATE2(pComponentPrivate->dbg, "Transition to OMX_StateExecuting\n"); 3164 } 3165 else { 3166 eError = OMX_ErrorIncorrectStateTransition; 3167 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3168 pComponentPrivate->pHandle->pApplicationPrivate, 3169 OMX_EventError, 3170 OMX_ErrorIncorrectStateTransition, 3171 OMX_TI_ErrorMinor, 3172 "Incorrect State Transition"); 3173 OMX_PRSTATE4(pComponentPrivate->dbg, "OMX_ErrorIncorrectStateTransition 0x%x\n",eError); 3174 } 3175 break; 3176 case OMX_StateLoaded: 3177 OMX_PRSTATE2(pComponentPrivate->dbg, "Transitioning to OMX_StateLoaded C 0x%x N 0x%lx\n",pComponentPrivate->eState, nParam1); 3178 if (pComponentPrivate->eState == OMX_StateLoaded) { 3179 eError = OMX_ErrorSameState; 3180 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3181 pComponentPrivate->pHandle->pApplicationPrivate, 3182 OMX_EventError, 3183 OMX_ErrorSameState, 3184 OMX_TI_ErrorMinor, 3185 "Same State"); 3186 OMX_PRSTATE4(pComponentPrivate->dbg, "OMX_ErrorSameState 0x%x\n",eError); 3187 } 3188 else if (pComponentPrivate->eState == OMX_StateIdle) { 3189 #ifdef __PERF_INSTRUMENTATION__ 3190 PERF_Boundary(pComponentPrivate->pPERFcomp, 3191 PERF_BoundaryStart | PERF_BoundaryCleanup); 3192 #endif 3193 OMX_VidDec_Return(pComponentPrivate); 3194 pComponentPrivate->eIdleToLoad = OMX_StateLoaded; 3195 if(pComponentPrivate->eFirstBuffer.pFirstBufferSaved){ 3196 free(pComponentPrivate->eFirstBuffer.pFirstBufferSaved); 3197 pComponentPrivate->eFirstBuffer.pFirstBufferSaved = NULL; 3198 pComponentPrivate->eFirstBuffer.bSaveFirstBuffer = OMX_FALSE; 3199 pComponentPrivate->eFirstBuffer.nFilledLen = 0; 3200 } 3201 #ifdef RESOURCE_MANAGER_ENABLED 3202 if(pComponentPrivate->eRMProxyState == VidDec_RMPROXY_State_Registered){ 3203 OMX_PRMGR2(pComponentPrivate->dbg, "memory usage 4 %d : %d bytes\n",(unsigned int)pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel0],(unsigned int)VIDDEC_MEMUSAGE); 3204 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 3205 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_H264_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3206 if (eError != OMX_ErrorNone) { 3207 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3208 } 3209 } 3210 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 3211 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_WMV_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3212 if (eError != OMX_ErrorNone) { 3213 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3214 } 3215 } 3216 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4) { 3217 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_MPEG4_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3218 if (eError != OMX_ErrorNone) { 3219 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3220 } 3221 } 3222 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 3223 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_H263_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3224 if (eError != OMX_ErrorNone) { 3225 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3226 } 3227 } 3228 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 3229 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_MPEG2_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3230 if (eError != OMX_ErrorNone) { 3231 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3232 } 3233 } 3234 #ifdef VIDDEC_SPARK_CODE 3235 else if (VIDDEC_SPARKCHECK) { 3236 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_MPEG4_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3237 if (eError != OMX_ErrorNone) { 3238 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3239 } 3240 } 3241 #endif 3242 else { 3243 eError = OMX_ErrorUnsupportedSetting; 3244 goto EXIT; 3245 } 3246 pComponentPrivate->eRMProxyState = VidDec_RMPROXY_State_Load; 3247 } 3248 #endif 3249 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 3250 pComponentPrivate->pLCML != NULL){ 3251 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlDestroy 0x%p\n",pLcmlHandle); 3252 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 3253 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, EMMCodecControlDestroy, NULL); 3254 if (eError != OMX_ErrorNone) { 3255 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3256 pComponentPrivate->pHandle->pApplicationPrivate, 3257 OMX_EventError, 3258 OMX_ErrorHardware, 3259 OMX_TI_ErrorSevere, 3260 NULL); 3261 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorHardware 0x%x\n",eError); 3262 break; 3263 } 3264 pComponentPrivate->eLCMLState = VidDec_LCML_State_Destroy; 3265 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlDestroy 0x%p\n",pLcmlHandle); 3266 } 3267 3268 OMX_PRDSP2(pComponentPrivate->dbg, "Closing LCML lib 0x%p\n",pComponentPrivate->pModLCML); 3269 3270 #ifndef UNDER_CE 3271 if(pComponentPrivate->pModLCML != NULL){ 3272 dlclose(pComponentPrivate->pModLCML); 3273 pComponentPrivate->pModLCML = NULL; 3274 pComponentPrivate->pLCML = NULL; 3275 } 3276 #else 3277 if(pComponentPrivate->pModLCML != NULL){ 3278 FreeLibrary(pComponentPrivate->pModLCML); 3279 pComponentPrivate->pModLCML = NULL; 3280 pComponentPrivate->pLCML = NULL; 3281 } 3282 #endif 3283 pComponentPrivate->eLCMLState = VidDec_LCML_State_Unload; 3284 3285 OMX_PRDSP1(pComponentPrivate->dbg, "Closed LCML lib 0x%p\n",pComponentPrivate->pModLCML); 3286 OMX_PRBUFFER2(pComponentPrivate->dbg, "Waiting for unpopulate ports IN 0x%x OUT 0x%x\n",pPortDefIn->bEnabled,pPortDefOut->bEnabled); 3287 OMX_PRBUFFER1(pComponentPrivate->dbg, "Tunneling 0x%p\n",(pComponentPrivate->pCompPort[1]->hTunnelComponent)); 3288 if ((pPortDefIn->bEnabled == OMX_TRUE && pPortDefOut->bEnabled == OMX_TRUE) || 3289 (pPortDefIn->bEnabled == OMX_TRUE && pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL)) { 3290 #ifdef UNDER_CE 3291 while(1) { 3292 if(!pPortDefIn->bPopulated && !pPortDefOut->bPopulated) { 3293 OMX_PRBUFFER2(pComponentPrivate->dbg, "Standalone unpopulated ports IN 0x%x OUT 0x%x\n",pPortDefIn->bEnabled,pPortDefOut->bEnabled); 3294 eError = OMX_ErrorNone; 3295 pComponentPrivate->bIsPaused = 0; 3296 pComponentPrivate->eState = OMX_StateLoaded; 3297 /* Decrement reference count with signal enabled */ 3298 if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { 3299 return OMX_ErrorUndefined; 3300 } 3301 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3302 pComponentPrivate->pHandle->pApplicationPrivate, 3303 OMX_EventCmdComplete, 3304 OMX_CommandStateSet, 3305 pComponentPrivate->eState, 3306 NULL); 3307 OMX_PRSTATE2(pComponentPrivate->dbg, "Transition to OMX_StateLoaded\n"); 3308 VIDDEC_Load_Defaults(pComponentPrivate, VIDDEC_INIT_VARS); 3309 pComponentPrivate->eIdleToLoad = OMX_StateInvalid; 3310 break; 3311 } 3312 else if(!pPortDefIn->bPopulated && (pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL)) { 3313 OMX_PRBUFFER2(pComponentPrivate->dbg, "Tunneling unpopulated ports IN 0x%x TUNNEL 0x%x\n", 3314 pPortDefIn->bEnabled,pComponentPrivate->pCompPort[1]->hTunnelComponent); 3315 eError = OMX_ErrorNone; 3316 pComponentPrivate->bIsPaused = 0; 3317 pComponentPrivate->eState = OMX_StateLoaded; 3318 /* Decrement reference count with signal enabled */ 3319 if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { 3320 return OMX_ErrorUndefined; 3321 } 3322 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3323 pComponentPrivate->pHandle->pApplicationPrivate, 3324 OMX_EventCmdComplete, 3325 OMX_CommandStateSet, 3326 pComponentPrivate->eState, 3327 NULL); 3328 OMX_PRSTATE2(pComponentPrivate->dbg, "Transition to OMX_StateLoaded\n"); 3329 VIDDEC_Load_Defaults(pComponentPrivate, VIDDEC_INIT_VARS); 3330 pComponentPrivate->eIdleToLoad = OMX_StateInvalid; 3331 break; 3332 } 3333 VIDDEC_WAIT_CODE(); 3334 } 3335 #else 3336 if(pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL) { 3337 if((!(pComponentPrivate->eState == OMX_StateLoaded) && pComponentPrivate->pInPortDef->bPopulated) || 3338 pComponentPrivate->sInSemaphore.bSignaled) { 3339 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 3340 } 3341 OMX_PRBUFFER2(pComponentPrivate->dbg, "Tunneling unpopulated ports IN 0x%x TUNNEL 0x%p\n", 3342 pPortDefIn->bEnabled,pComponentPrivate->pCompPort[1]->hTunnelComponent); 3343 eError = OMX_ErrorNone; 3344 pComponentPrivate->bIsPaused = 0; 3345 pComponentPrivate->eState = OMX_StateLoaded; 3346 /* Decrement reference count with signal enabled */ 3347 if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { 3348 return OMX_ErrorUndefined; 3349 } 3350 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3351 pComponentPrivate->pHandle->pApplicationPrivate, 3352 OMX_EventCmdComplete, 3353 OMX_CommandStateSet, 3354 pComponentPrivate->eState, 3355 NULL); 3356 OMX_PRSTATE2(pComponentPrivate->dbg, "Transition to OMX_StateLoaded\n"); 3357 VIDDEC_Load_Defaults(pComponentPrivate, VIDDEC_INIT_VARS); 3358 pComponentPrivate->eIdleToLoad = OMX_StateInvalid; 3359 } 3360 else { 3361 if((!(pComponentPrivate->eState == OMX_StateLoaded) && pComponentPrivate->pInPortDef->bPopulated) || 3362 pComponentPrivate->sInSemaphore.bSignaled) { 3363 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 3364 } 3365 if((!(pComponentPrivate->eState == OMX_StateLoaded) && pComponentPrivate->pOutPortDef->bPopulated) || 3366 pComponentPrivate->sOutSemaphore.bSignaled) { 3367 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sOutSemaphore); 3368 } 3369 OMX_PRBUFFER2(pComponentPrivate->dbg, "Standalone unpopulated ports IN 0x%x OUT 0x%x\n",pPortDefIn->bEnabled,pPortDefOut->bEnabled); 3370 eError = OMX_ErrorNone; 3371 pComponentPrivate->bIsPaused = 0; 3372 pComponentPrivate->eState = OMX_StateLoaded; 3373 /* Decrement reference count with signal enabled */ 3374 if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { 3375 return OMX_ErrorUndefined; 3376 } 3377 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3378 pComponentPrivate->pHandle->pApplicationPrivate, 3379 OMX_EventCmdComplete, 3380 OMX_CommandStateSet, 3381 pComponentPrivate->eState, 3382 NULL); 3383 OMX_PRSTATE2(pComponentPrivate->dbg, "Transition to OMX_StateLoaded\n"); 3384 VIDDEC_Load_Defaults(pComponentPrivate, VIDDEC_INIT_VARS); 3385 pComponentPrivate->eIdleToLoad = OMX_StateInvalid; 3386 3387 } 3388 3389 3390 #endif 3391 #ifdef __PERF_INSTRUMENTATION__ 3392 PERF_Boundary(pComponentPrivate->pPERFcomp, 3393 PERF_BoundaryComplete | PERF_BoundaryCleanup); 3394 #endif 3395 3396 } 3397 #ifndef UNDER_CE 3398 else { 3399 if(pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL) { 3400 if(pComponentPrivate->sInSemaphore.bSignaled){ 3401 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 3402 } 3403 } 3404 else { 3405 if(pComponentPrivate->sInSemaphore.bSignaled){ 3406 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sInSemaphore); 3407 } 3408 if(pComponentPrivate->sOutSemaphore.bSignaled){ 3409 VIDDEC_PTHREAD_SEMAPHORE_WAIT(pComponentPrivate->sOutSemaphore); 3410 } 3411 } 3412 pComponentPrivate->eState = OMX_StateLoaded; 3413 pComponentPrivate->bIsPaused = 0; 3414 /* Decrement reference count with signal enabled */ 3415 if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { 3416 return OMX_ErrorUndefined; 3417 } 3418 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3419 pComponentPrivate->pHandle->pApplicationPrivate, 3420 OMX_EventCmdComplete, 3421 OMX_CommandStateSet, 3422 pComponentPrivate->eState, 3423 NULL); 3424 pComponentPrivate->eIdleToLoad = OMX_StateInvalid; 3425 VIDDEC_Load_Defaults(pComponentPrivate, VIDDEC_INIT_VARS); 3426 OMX_PRSTATE2(pComponentPrivate->dbg, "Transition to OMX_StateLoaded\n"); 3427 break; 3428 } 3429 #endif 3430 } 3431 else if (pComponentPrivate->eState == OMX_StateWaitForResources) { 3432 pComponentPrivate->eState = OMX_StateLoaded; 3433 pComponentPrivate->bIsPaused = 0; 3434 /* Decrement reference count with signal enabled */ 3435 if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { 3436 return OMX_ErrorUndefined; 3437 } 3438 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3439 pComponentPrivate->pHandle->pApplicationPrivate, 3440 OMX_EventCmdComplete, 3441 OMX_CommandStateSet, 3442 pComponentPrivate->eState, 3443 NULL); 3444 OMX_PRSTATE2(pComponentPrivate->dbg, "Transition to OMX_StateLoaded\n"); 3445 break; 3446 } 3447 else { 3448 eError = OMX_ErrorIncorrectStateTransition; 3449 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3450 pComponentPrivate->pHandle->pApplicationPrivate, 3451 OMX_EventError, 3452 OMX_ErrorIncorrectStateTransition, 3453 OMX_TI_ErrorMinor, 3454 NULL); 3455 OMX_PRSTATE2(pComponentPrivate->dbg, "Incorrect State Transition 0x%x\n",eError); 3456 } 3457 break; 3458 case OMX_StatePause: 3459 OMX_VidDec_Return(pComponentPrivate); 3460 OMX_PRSTATE2(pComponentPrivate->dbg, "Transitioning to OMX_StatePause C 0x%x N 0x%lx\n",pComponentPrivate->eState, nParam1); 3461 if (pComponentPrivate->eState == OMX_StatePause) { 3462 eError = OMX_ErrorSameState; 3463 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3464 pComponentPrivate->pHandle->pApplicationPrivate, 3465 OMX_EventError, 3466 OMX_ErrorSameState, 3467 OMX_TI_ErrorMinor, 3468 NULL); 3469 OMX_PRSTATE4(pComponentPrivate->dbg, "Same State 0x%x\n",eError); 3470 break; 3471 } 3472 else if (pComponentPrivate->eState == OMX_StateExecuting) { 3473 #ifdef __PERF_INSTRUMENTATION__ 3474 pComponentPrivate->lcml_nCntOpReceived = 0; 3475 PERF_Boundary(pComponentPrivate->pPERFcomp, 3476 PERF_BoundaryComplete | PERF_BoundarySteadyState); 3477 #endif 3478 3479 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 3480 pComponentPrivate->bIsPaused = 1; 3481 OMX_VidDec_Return(pComponentPrivate); 3482 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 3483 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 3484 pComponentPrivate->pLCML != NULL && 3485 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 3486 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 3487 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlPause 0x%p\n",pLcmlHandle); 3488 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, EMMCodecControlPause, NULL); 3489 if (eError != OMX_ErrorNone) { 3490 eError = OMX_ErrorHardware; 3491 OMX_PRDSP4(pComponentPrivate->dbg, "Error during EMMCodecControlPause...\n"); 3492 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3493 pComponentPrivate->pHandle->pApplicationPrivate, 3494 OMX_EventError, 3495 eError, 3496 OMX_TI_ErrorSevere, 3497 NULL); 3498 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 3499 break; 3500 } 3501 eError = OMX_ErrorNone; 3502 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 3503 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 3504 } 3505 pComponentPrivate->eLCMLState = VidDec_LCML_State_Pause; 3506 OMX_VidDec_Return(pComponentPrivate); 3507 pComponentPrivate->eLCMLState = VidDec_LCML_State_Pause; 3508 eError = OMX_ErrorNone; 3509 pComponentPrivate->bIsPaused = 1; 3510 pComponentPrivate->eState = OMX_StatePause; 3511 /* Decrement reference count with signal enabled */ 3512 if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { 3513 return OMX_ErrorUndefined; 3514 } 3515 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3516 pComponentPrivate->pHandle->pApplicationPrivate, 3517 OMX_EventCmdComplete, 3518 OMX_CommandStateSet, 3519 pComponentPrivate->eState, 3520 NULL); 3521 3522 break; 3523 } 3524 else if (pComponentPrivate->eState == OMX_StateIdle) { 3525 pComponentPrivate->bIsPaused = 1; 3526 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 3527 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 3528 pComponentPrivate->pLCML != NULL && 3529 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 3530 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 3531 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 3532 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlPause 0x%p\n",pLcmlHandle); 3533 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, EMMCodecControlPause, NULL); 3534 if (eError != OMX_ErrorNone) { 3535 OMX_PRDSP4(pComponentPrivate->dbg, "During EMMCodecControlPause...\n"); 3536 eError = OMX_ErrorHardware; 3537 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3538 pComponentPrivate->pHandle->pApplicationPrivate, 3539 OMX_EventError, 3540 eError, 3541 OMX_TI_ErrorSevere, 3542 NULL); 3543 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 3544 break; 3545 } 3546 eError = OMX_ErrorNone; 3547 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 3548 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 3549 } 3550 pComponentPrivate->eLCMLState = VidDec_LCML_State_Pause; 3551 eError = OMX_ErrorNone; 3552 pComponentPrivate->bIsPaused = 1; 3553 pComponentPrivate->eState = OMX_StatePause; 3554 /* Decrement reference count with signal enabled */ 3555 if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { 3556 return OMX_ErrorUndefined; 3557 } 3558 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3559 pComponentPrivate->pHandle->pApplicationPrivate, 3560 OMX_EventCmdComplete, 3561 OMX_CommandStateSet, 3562 pComponentPrivate->eState, 3563 NULL); 3564 OMX_PRSTATE2(pComponentPrivate->dbg, "Transition to OMX_StatePause\n"); 3565 } 3566 else { 3567 eError = OMX_ErrorIncorrectStateTransition; 3568 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3569 pComponentPrivate->pHandle->pApplicationPrivate, 3570 OMX_EventError, 3571 OMX_ErrorIncorrectStateTransition, 3572 OMX_TI_ErrorMinor, 3573 "Incorrect State Transition"); 3574 OMX_PRSTATE4(pComponentPrivate->dbg, "Incorrect State Transition\n"); 3575 } 3576 break; 3577 case OMX_StateInvalid: 3578 OMX_PRINT1(pComponentPrivate->dbg, "Transitioning to OMX_StateInvalid C 0x%x N 0x%lx\n",pComponentPrivate->eState, nParam1); 3579 if (pComponentPrivate->eState == OMX_StateInvalid) { 3580 eError = OMX_ErrorSameState; 3581 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3582 pComponentPrivate->pHandle->pApplicationPrivate, 3583 OMX_EventError, 3584 OMX_ErrorSameState, 3585 OMX_TI_ErrorCritical, 3586 "Same State"); 3587 OMX_PRSTATE4(pComponentPrivate->dbg, "Same State...\n"); 3588 break; 3589 } 3590 else if (pComponentPrivate->eState == OMX_StateIdle || pComponentPrivate->eState == OMX_StateExecuting) { 3591 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 3592 if (pComponentPrivate->eState == OMX_StateExecuting) { 3593 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 3594 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 3595 pComponentPrivate->pLCML != NULL && 3596 pComponentPrivate->bLCMLHalted != OMX_TRUE) { 3597 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 3598 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called MMCodecControlStop 0x%x\n",eError); 3599 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, MMCodecControlStop, NULL); 3600 if (eError != OMX_ErrorNone) { 3601 OMX_PRDSP4(pComponentPrivate->dbg, "Occurred in Codec Stop...\n"); 3602 eError = OMX_ErrorHardware; 3603 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3604 pComponentPrivate->pHandle->pApplicationPrivate, 3605 OMX_EventError, 3606 eError, 3607 OMX_TI_ErrorCritical, 3608 NULL); 3609 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 3610 break; 3611 } 3612 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 3613 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 3614 } 3615 3616 pComponentPrivate->eLCMLState = VidDec_LCML_State_Stop; 3617 } 3618 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 3619 pComponentPrivate->pLCML != NULL){ 3620 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, EMMCodecControlDestroy, NULL); 3621 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlDestroy 0x%p\n",pLcmlHandle); 3622 if (eError != OMX_ErrorNone) { 3623 OMX_PRDSP4(pComponentPrivate->dbg, "Occurred in Codec Destroy...\n"); 3624 eError = OMX_ErrorHardware; 3625 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3626 pComponentPrivate->pHandle->pApplicationPrivate, 3627 OMX_EventError, 3628 eError, 3629 OMX_TI_ErrorCritical, 3630 NULL); 3631 OMX_PRSTATE4(pComponentPrivate->dbg, "Incorrect State Transition 0x%x\n", eError); 3632 break; 3633 } 3634 } 3635 3636 pComponentPrivate->eLCMLState = VidDec_LCML_State_Destroy; 3637 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload) { 3638 #ifndef UNDER_CE 3639 if(pComponentPrivate->pModLCML != NULL){ 3640 dlclose(pComponentPrivate->pModLCML); 3641 pComponentPrivate->pModLCML = NULL; 3642 pComponentPrivate->pLCML = NULL; 3643 pComponentPrivate->eLCMLState = VidDec_LCML_State_Unload; 3644 } 3645 #else 3646 if(pComponentPrivate->pModLCML != NULL){ 3647 FreeLibrary(pComponentPrivate->pModLCML); 3648 pComponentPrivate->pModLCML = NULL; 3649 pComponentPrivate->pLCML = NULL; 3650 pComponentPrivate->eLCMLState = VidDec_LCML_State_Unload; 3651 } 3652 #endif 3653 } 3654 for (iCount = 0; iCount < MAX_PRIVATE_BUFFERS; iCount++) { 3655 if(pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->bAllocByComponent == OMX_TRUE){ 3656 if(pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr != NULL) { 3657 OMX_BUFFERHEADERTYPE* pBuffHead = NULL; 3658 pBuffHead = pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr; 3659 OMX_MEMFREE_STRUCT_DSPALIGN(pBuffHead->pBuffer,OMX_U8); 3660 } 3661 } 3662 } 3663 3664 for (iCount = 0; iCount < MAX_PRIVATE_BUFFERS; iCount++) { 3665 if(pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->bAllocByComponent == OMX_TRUE){ 3666 if(pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr != NULL) { 3667 OMX_BUFFERHEADERTYPE* pBuffHead = NULL; 3668 pBuffHead = pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr; 3669 OMX_MEMFREE_STRUCT_DSPALIGN(pBuffHead->pBuffer,OMX_U8); 3670 } 3671 } 3672 } 3673 #ifdef RESOURCE_MANAGER_ENABLED 3674 if(pComponentPrivate->eRMProxyState == VidDec_RMPROXY_State_Registered){ 3675 OMX_PRMGR2(pComponentPrivate->dbg, "memory usage 4 %d : %d bytes\n",(unsigned int)pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel0],(unsigned int)VIDDEC_MEMUSAGE); 3676 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 3677 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_H264_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3678 if (eError != OMX_ErrorNone) { 3679 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3680 } 3681 } 3682 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 3683 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_WMV_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3684 if (eError != OMX_ErrorNone) { 3685 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3686 } 3687 } 3688 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4) { 3689 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_MPEG4_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3690 if (eError != OMX_ErrorNone) { 3691 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3692 } 3693 } 3694 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 3695 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_H263_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3696 if (eError != OMX_ErrorNone) { 3697 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3698 } 3699 } 3700 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 3701 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_MPEG2_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3702 if (eError != OMX_ErrorNone) { 3703 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3704 } 3705 } 3706 #ifdef VIDDEC_SPARK_CODE 3707 else if (VIDDEC_SPARKCHECK) { 3708 eError = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_FreeResource, OMX_MPEG4_Decode_COMPONENT, 0, VIDDEC_MEMUSAGE, NULL); 3709 if (eError != OMX_ErrorNone) { 3710 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3711 } 3712 } 3713 #endif 3714 else { 3715 eError = OMX_ErrorUnsupportedSetting; 3716 goto EXIT; 3717 } 3718 pComponentPrivate->eRMProxyState = VidDec_RMPROXY_State_Load; 3719 } 3720 if(pComponentPrivate->eRMProxyState != VidDec_RMPROXY_State_Unload){ 3721 eError = RMProxy_DeinitalizeEx(OMX_COMPONENTTYPE_VIDEO); 3722 if (eError != OMX_ErrorNone) { 3723 OMX_PRMGR4(pComponentPrivate->dbg, "Error returned from destroy ResourceManagerProxy thread\n"); 3724 } 3725 pComponentPrivate->eRMProxyState = VidDec_RMPROXY_State_Unload; 3726 } 3727 #endif 3728 eError = OMX_ErrorInvalidState; 3729 pComponentPrivate->eState = OMX_StateInvalid; 3730 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3731 pComponentPrivate->pHandle->pApplicationPrivate, 3732 OMX_EventError, 3733 OMX_ErrorInvalidState, 3734 OMX_TI_ErrorCritical, 3735 "Invalid State"); 3736 OMX_PRSTATE4(pComponentPrivate->dbg, "Incorrect State Transition 0x%x\n", eError); 3737 break; 3738 } 3739 else{ 3740 eError = OMX_ErrorIncorrectStateTransition; 3741 pComponentPrivate->eState = OMX_StateInvalid; 3742 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3743 pComponentPrivate->pHandle->pApplicationPrivate, 3744 OMX_EventError, 3745 OMX_ErrorInvalidState, 3746 OMX_TI_ErrorCritical, 3747 "Incorrect State Transition"); 3748 OMX_PRSTATE4(pComponentPrivate->dbg, "Incorrect State Transition 0x%x\n", eError); 3749 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3750 pComponentPrivate->pHandle->pApplicationPrivate, 3751 OMX_EventCmdComplete, 3752 OMX_CommandStateSet, 3753 pComponentPrivate->eState, 3754 NULL); 3755 3756 } 3757 break; 3758 case OMX_StateWaitForResources: 3759 OMX_PRSTATE2(pComponentPrivate->dbg, "Transitioning to OMX_StateWaitForResources C 0x%x N 0x%lx\n",pComponentPrivate->eState, nParam1); 3760 if (pComponentPrivate->eState == OMX_StateWaitForResources) { 3761 eError = OMX_ErrorSameState; 3762 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3763 pComponentPrivate->pHandle->pApplicationPrivate, 3764 OMX_EventError, 3765 OMX_ErrorSameState, 3766 OMX_TI_ErrorMinor, 3767 NULL); 3768 OMX_PRSTATE4(pComponentPrivate->dbg, "Same State 0x%x\n", eError); 3769 } 3770 else if (pComponentPrivate->eState == OMX_StateLoaded) { 3771 /*add code to wait for resources*/ 3772 eError = OMX_ErrorNone; 3773 pComponentPrivate->bIsPaused = 0; 3774 pComponentPrivate->eState = OMX_StateWaitForResources; 3775 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3776 pComponentPrivate->pHandle->pApplicationPrivate, 3777 OMX_EventCmdComplete, 3778 OMX_CommandStateSet, 3779 pComponentPrivate->eState, 3780 NULL); 3781 } 3782 else { 3783 eError = OMX_ErrorIncorrectStateTransition; 3784 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3785 pComponentPrivate->pHandle->pApplicationPrivate, 3786 OMX_EventError, 3787 OMX_ErrorIncorrectStateTransition, 3788 OMX_TI_ErrorMinor, 3789 NULL); 3790 OMX_PRSTATE4(pComponentPrivate->dbg, "Incorrect State Transition 0x%x\n", eError); 3791 } 3792 3793 break; 3794 3795 case OMX_StateMax: 3796 OMX_PRSTATE2(pComponentPrivate->dbg, "Transitioning to OMX_StateMax C 0x%x N 0x%lx\n",pComponentPrivate->eState, nParam1); 3797 eError = OMX_ErrorIncorrectStateTransition; 3798 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3799 pComponentPrivate->pHandle->pApplicationPrivate, 3800 OMX_EventError, 3801 OMX_ErrorIncorrectStateTransition, 3802 OMX_TI_ErrorMinor, 3803 NULL); 3804 OMX_PRSTATE4(pComponentPrivate->dbg, "Incorrect State Transition 0x%x\n", eError); 3805 break; 3806 default: 3807 OMX_PRSTATE2(pComponentPrivate->dbg, "Transitioning to default C 0x%x N 0x%lx\n",pComponentPrivate->eState, nParam1); 3808 eError = OMX_ErrorIncorrectStateTransition; 3809 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 3810 pComponentPrivate->pHandle->pApplicationPrivate, 3811 OMX_EventError, 3812 OMX_ErrorIncorrectStateTransition, 3813 OMX_TI_ErrorMinor, 3814 NULL); 3815 OMX_PRSTATE4(pComponentPrivate->dbg, "Incorrect State Transition 0x%x\n", eError); 3816 break; 3817 } /* End of Switch */ 3818 3819 3820 3821 EXIT: 3822 OMX_PRINT1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 3823 return eError; 3824 } 3825 3826 /******************************************************************************/ 3827 /** 3828 * Sets free output buffers 3829 **/ 3830 /******************************************************************************/ 3831 3832 OMX_ERRORTYPE VIDDEC_HandleFreeOutputBufferFromApp(VIDDEC_COMPONENT_PRIVATE *pComponentPrivate) 3833 { 3834 OMX_ERRORTYPE eError = OMX_ErrorNone; 3835 OMX_BUFFERHEADERTYPE* pBuffHead; 3836 OMX_U32 size_out_buf; 3837 int ret; 3838 LCML_DSP_INTERFACE* pLcmlHandle; 3839 VIDDEC_BUFFER_PRIVATE* pBufferPrivate = NULL; 3840 OMX_PRBUFFER1(pComponentPrivate->dbg, "+++ENTERING\n"); 3841 OMX_PRBUFFER1(pComponentPrivate->dbg, "pComponentPrivate 0x%p\n", pComponentPrivate); 3842 size_out_buf = (OMX_U32)pComponentPrivate->pOutPortDef->nBufferSize; 3843 pLcmlHandle = (LCML_DSP_INTERFACE*)(pComponentPrivate->pLCML); 3844 ret = read(pComponentPrivate->free_outBuf_Q[0], &pBuffHead, sizeof(pBuffHead)); 3845 3846 3847 if (ret == -1) { 3848 OMX_PRCOMM4(pComponentPrivate->dbg, "Error while reading from the pipe\n"); 3849 eError = OMX_ErrorHardware; 3850 goto EXIT; 3851 } 3852 3853 eError = DecrementCount (&(pComponentPrivate->nCountOutputBFromApp), &(pComponentPrivate->mutexOutputBFromApp)); 3854 if (eError != OMX_ErrorNone) { 3855 return eError; 3856 } 3857 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead 0x%p eExecuteToIdle 0x%x\n", pBuffHead, pComponentPrivate->eExecuteToIdle); 3858 if(pBuffHead->pOutputPortPrivate != NULL) { 3859 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pOutputPortPrivate; 3860 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 3861 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 3862 pComponentPrivate->pLCML != NULL) { 3863 #ifdef KHRONOS_1_1 3864 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 3865 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 3866 MP4VD_GPP_SN_UALGOutputParams* pUalgOutParams = NULL; 3867 pUalgOutParams = (MP4VD_GPP_SN_UALGOutputParams *)pBufferPrivate->pUalgParam; 3868 if (pComponentPrivate->eMBErrorReport.bEnabled) { 3869 pUalgOutParams->lMbErrorBufFlag = 1; 3870 } 3871 else { 3872 pUalgOutParams->lMbErrorBufFlag = 0; 3873 } 3874 } 3875 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 3876 H264VDEC_UALGOutputParam* pUalgOutParams = NULL; 3877 pUalgOutParams = (H264VDEC_UALGOutputParam *)pBufferPrivate->pUalgParam; 3878 if (pComponentPrivate->eMBErrorReport.bEnabled) { 3879 pUalgOutParams->lMBErrStatFlag = 1; 3880 } 3881 else { 3882 pUalgOutParams->lMBErrStatFlag = 0; 3883 } 3884 } 3885 #endif 3886 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_DSP; 3887 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 3888 3889 #ifdef __PERF_INSTRUMENTATION__ 3890 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 3891 pBuffHead->pBuffer, 3892 pBuffHead->nFilledLen, 3893 PERF_ModuleCommonLayer); 3894 #endif 3895 3896 OMX_PRDSP1(pComponentPrivate->dbg, "LCML_QueueBuffer(OUTPUT)\n"); 3897 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 3898 EMMCodecOutputBufferMapBufLen, 3899 pBuffHead->pBuffer, 3900 pBuffHead->nAllocLen, 3901 pBuffHead->nFilledLen, 3902 (OMX_U8*)(pBufferPrivate->pUalgParam), 3903 (OMX_S32)pBufferPrivate->nUalgParamSize, 3904 (OMX_U8*)pBuffHead); 3905 if (eError != OMX_ErrorNone){ 3906 OMX_PRDSP4(pComponentPrivate->dbg, "LCML_QueueBuffer 0x%x\n", eError); 3907 eError = OMX_ErrorHardware; 3908 goto EXIT; 3909 } 3910 } 3911 else { 3912 eError = OMX_ErrorHardware; 3913 goto EXIT; 3914 } 3915 } 3916 else { 3917 OMX_PRBUFFER2(pComponentPrivate->dbg, "null element *************n\n"); 3918 } 3919 3920 EXIT: 3921 OMX_PRBUFFER1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 3922 return eError; 3923 } 3924 3925 #ifdef VIDDEC_ACTIVATEPARSER 3926 OMX_S32 GET_NUM_BIT_REQ(OMX_U32 num) 3927 { 3928 OMX_S32 i; 3929 for ( i = 31; i >= 0; i--) 3930 { 3931 if (num & (0x1 << i) ) break; 3932 } 3933 return (i+1); 3934 } 3935 #endif 3936 3937 #ifdef VIDDEC_ACTIVATEPARSER 3938 /* ==========================================================================*/ 3939 /* func VIDDEC_ParseVideo_MPEG2 */ 3940 /* */ 3941 /* desc */ 3942 /* ==========================================================================*/ 3943 OMX_ERRORTYPE VIDDEC_ParseVideo_MPEG2( OMX_S32* nWidth, OMX_S32* nHeight, OMX_BUFFERHEADERTYPE *pBuffHead) 3944 { 3945 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 3946 OMX_U32 nTempValue = 0; 3947 /*OMX_U8* pTempValue = 0;*/ 3948 /*OMX_U8* pTempSize = 0;*/ 3949 /*OMX_U32 nProfile = 0;*/ 3950 /*OMX_U32 nLevel = 0;*/ 3951 OMX_U32 nBitPosition = 0; 3952 OMX_U8* pHeaderStream = (OMX_U8*)pBuffHead->pBuffer; 3953 OMX_BOOL nStartFlag = OMX_FALSE; 3954 OMX_U32 nInBytePosition = 0; 3955 OMX_U32 nTotalInBytes = 0; 3956 OMX_U32 nNalUnitType = 0; 3957 3958 nTotalInBytes = pBuffHead->nFilledLen; 3959 3960 do{ 3961 for (; (!nStartFlag) && (nInBytePosition < nTotalInBytes - 3); ) { 3962 if (VIDDEC_GetBits(&nBitPosition, 24, pHeaderStream, OMX_FALSE) != 0x000001) { 3963 nBitPosition += 8; 3964 nInBytePosition++; 3965 } 3966 else { 3967 nStartFlag = OMX_TRUE; 3968 nBitPosition += 24; 3969 nInBytePosition += 3; 3970 } 3971 } 3972 if (!nStartFlag) { 3973 eError = OMX_ErrorStreamCorrupt; 3974 goto EXIT; 3975 } 3976 nNalUnitType = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); 3977 nInBytePosition++; 3978 if (nNalUnitType != 0xB3) { 3979 nStartFlag = OMX_FALSE; 3980 } 3981 }while (nNalUnitType != 0xB3); 3982 3983 if (nNalUnitType == 0xB3) { 3984 nTempValue = VIDDEC_GetBits(&nBitPosition, 12, pHeaderStream, OMX_TRUE); 3985 (*nWidth) = (nTempValue); 3986 nTempValue = VIDDEC_GetBits(&nBitPosition, 12, pHeaderStream, OMX_TRUE); 3987 (*nHeight) = (nTempValue); 3988 eError = OMX_ErrorNone; 3989 } 3990 3991 EXIT: 3992 return eError; 3993 } 3994 #endif 3995 3996 #ifdef VIDDEC_ACTIVATEPARSER 3997 /* ==========================================================================*/ 3998 /* func VIDDEC_ParseVideo_WMV9_VC1 */ 3999 /* */ 4000 /* desc */ 4001 /* ==========================================================================*/ 4002 OMX_ERRORTYPE VIDDEC_ParseVideo_WMV9_VC1( OMX_S32* nWidth, OMX_S32* nHeight, OMX_BUFFERHEADERTYPE *pBuffHead) 4003 { 4004 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 4005 OMX_U32 nTempValue = 0; 4006 /*OMX_U8* pTempValue = 0;*/ 4007 /*OMX_U8* pTempSize = 0;*/ 4008 OMX_U32 nProfile = 0; 4009 OMX_U32 nLevel = 0; 4010 OMX_U32 nBitPosition = 0; 4011 OMX_U8* pHeaderStream = (OMX_U8*)pBuffHead->pBuffer; 4012 OMX_BOOL nStartFlag = OMX_FALSE; 4013 OMX_U32 nInBytePosition = 0; 4014 OMX_U32 nTotalInBytes = 0; 4015 OMX_U32 nNalUnitType = 0; 4016 4017 nTotalInBytes = pBuffHead->nFilledLen; 4018 4019 do{ 4020 for (; (!nStartFlag) && (nInBytePosition < nTotalInBytes - 3); ) { 4021 if (VIDDEC_GetBits(&nBitPosition, 24, pHeaderStream, OMX_FALSE) != 0x000001) { 4022 nBitPosition += 8; 4023 nInBytePosition++; 4024 } 4025 else { 4026 nStartFlag = OMX_TRUE; 4027 nBitPosition += 24; 4028 nInBytePosition += 3; 4029 } 4030 } 4031 if (!nStartFlag) { 4032 eError = OMX_ErrorStreamCorrupt; 4033 goto EXIT; 4034 } 4035 nNalUnitType = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); 4036 nInBytePosition++; 4037 if (nNalUnitType != 0x0f && nNalUnitType != 0x0e) { 4038 nStartFlag = OMX_FALSE; 4039 } 4040 }while (nNalUnitType != 0x0f && nNalUnitType != 0x0e); 4041 4042 if (nNalUnitType == 0x0f || nNalUnitType == 0x0e) { 4043 nProfile = VIDDEC_GetBits(&nBitPosition, 2, pHeaderStream, OMX_TRUE); 4044 nLevel = VIDDEC_GetBits(&nBitPosition, 3, pHeaderStream, OMX_TRUE); 4045 nTempValue = VIDDEC_GetBits(&nBitPosition, 11, pHeaderStream, OMX_TRUE); 4046 nTempValue = VIDDEC_GetBits(&nBitPosition, 12, pHeaderStream, OMX_TRUE); 4047 (*nWidth) = (nTempValue * 2) + 2; 4048 nTempValue = VIDDEC_GetBits(&nBitPosition, 12, pHeaderStream, OMX_TRUE); 4049 (*nHeight) = (nTempValue * 2) + 2; 4050 eError = OMX_ErrorNone; 4051 } 4052 4053 EXIT: 4054 return eError; 4055 } 4056 #endif 4057 4058 #ifdef VIDDEC_ACTIVATEPARSER 4059 /* ==========================================================================*/ 4060 /* func VIDDEC_ParseVideo_WMV9_RCV */ 4061 /* */ 4062 /* desc */ 4063 /* ==========================================================================*/ 4064 OMX_ERRORTYPE VIDDEC_ParseVideo_WMV9_RCV( OMX_S32* nWidth, OMX_S32* nHeight, OMX_BUFFERHEADERTYPE *pBuffHead) 4065 { 4066 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 4067 OMX_U32 nTempValue = 0; 4068 OMX_U8* pTempValue = 0; 4069 /*OMX_U8* pTempSize = 0;*/ 4070 OMX_U32 Profile = 0; 4071 /*OMX_U32 i = 0;*/ 4072 OMX_U32 nBitPosition = 0; 4073 OMX_U8* pHeaderStream = (OMX_U8*)pBuffHead->pBuffer; 4074 4075 if (pBuffHead->nFilledLen >= 20) { 4076 nTempValue = VIDDEC_GetBits(&nBitPosition, 32, pHeaderStream, OMX_TRUE); 4077 nTempValue = VIDDEC_GetBits(&nBitPosition, 32, pHeaderStream, OMX_TRUE); 4078 Profile = VIDDEC_GetBits(&nBitPosition, 4, pHeaderStream, OMX_TRUE); 4079 nTempValue = VIDDEC_GetBits(&nBitPosition, 28, pHeaderStream, OMX_TRUE); 4080 4081 pTempValue = (OMX_U8*)&nTempValue; 4082 pTempValue[0] = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); 4083 pTempValue[1] = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); 4084 pTempValue[2] = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); 4085 pTempValue[3] = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); 4086 (*nHeight) = nTempValue; 4087 4088 pTempValue[0] = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); 4089 pTempValue[1] = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); 4090 pTempValue[2] = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); 4091 pTempValue[3] = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); 4092 (*nWidth) = nTempValue; 4093 eError = OMX_ErrorNone; 4094 } 4095 else { 4096 (*nWidth) = 0; 4097 (*nHeight) = 0; 4098 eError = OMX_ErrorUndefined; 4099 } 4100 4101 return eError; 4102 } 4103 #endif 4104 4105 #ifdef VIDDEC_ACTIVATEPARSER 4106 /* ==========================================================================*/ 4107 /* func VIDDEC_ParseVideo_MPEG4 */ 4108 /* */ 4109 /* desc */ 4110 /* ==========================================================================*/ 4111 OMX_ERRORTYPE VIDDEC_ParseVideo_MPEG4( OMX_S32* nWidth, OMX_S32* nHeight, OMX_BUFFERHEADERTYPE *pBuffHead) 4112 { 4113 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 4114 OMX_U32 nSartCode = 0; 4115 OMX_U32 nBitPosition = 0; 4116 OMX_BOOL bHeaderParseCompleted = OMX_FALSE; 4117 OMX_BOOL bFillHeaderInfo = OMX_FALSE; 4118 OMX_U8* pHeaderStream = (OMX_U8*)pBuffHead->pBuffer; 4119 4120 /*OMX_U32 nTotalInBytes = pBuffHead->nFilledLen;*/ 4121 VIDDEC_MPEG4_ParserParam MPEG4_Param; 4122 VIDDEC_MPEG4UncompressedVideoFormat iOutputFormat = {0}; 4123 VIDDEC_MPEG4_ParserParam* sMPEG4_Param = &MPEG4_Param; 4124 VIDDEC_VideoPictureHeader sPictHeaderDummy; 4125 VIDDEC_MPEG4VisualVOLHeader sVolHeaderDummy; 4126 VIDDEC_VideoPictureHeader* pPictHeaderPtr = &sPictHeaderDummy; 4127 VIDDEC_MPEG4VisualVOLHeader* sVolHeaderPtr = &sVolHeaderDummy; 4128 4129 pPictHeaderPtr->cnOptional = (OMX_U8*)malloc( sizeof(VIDDEC_MPEG4VisualVOLHeader)); 4130 while (!bHeaderParseCompleted) 4131 { 4132 nSartCode = VIDDEC_GetBits(&nBitPosition, 32, pHeaderStream, OMX_TRUE); 4133 if (nSartCode == 0x1B0) 4134 { 4135 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 4); 4136 pPictHeaderPtr->nProfile = VIDDEC_GetBits(&nBitPosition, 4, pHeaderStream, OMX_TRUE); 4137 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 4); 4138 pPictHeaderPtr->nLevel = VIDDEC_GetBits(&nBitPosition, 4, pHeaderStream, OMX_TRUE); 4139 } 4140 else if (nSartCode == 0x1B5) 4141 { 4142 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4143 sMPEG4_Param->nIsVisualObjectIdentifier = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4144 if (sMPEG4_Param->nIsVisualObjectIdentifier) 4145 { 4146 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 7); 4147 (void)VIDDEC_GetBits(&nBitPosition, 7, pHeaderStream, OMX_TRUE); /* DISCARD THIS INFO (7 bits)*/ 4148 } 4149 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 4); 4150 sMPEG4_Param->nVisualObjectType = VIDDEC_GetBits(&nBitPosition, 4, pHeaderStream, OMX_TRUE); 4151 if (sMPEG4_Param->nVisualObjectType== 1|| sMPEG4_Param->nVisualObjectType== 2) 4152 { 4153 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4154 sMPEG4_Param->nVideoSignalType = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4155 if (sMPEG4_Param->nVideoSignalType) 4156 { 4157 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 3); 4158 sMPEG4_Param->nVideoFormat = VIDDEC_GetBits(&nBitPosition, 3, pHeaderStream, OMX_TRUE); 4159 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4160 sMPEG4_Param->nVideoRange = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4161 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4162 sMPEG4_Param->nColorDescription = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4163 if (sMPEG4_Param->nColorDescription) 4164 { 4165 /*Discard this info*/ 4166 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 24); 4167 (void)VIDDEC_GetBits(&nBitPosition, 24, pHeaderStream, OMX_TRUE); 4168 } 4169 } 4170 } 4171 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4172 sMPEG4_Param->NBitZero = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4173 while ((nBitPosition%8)!= 0) { 4174 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4175 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE);/*discard align bits*/ 4176 } 4177 } 4178 else if ((nSartCode >= 0x100)&&(nSartCode <= 0x11F)) 4179 { 4180 /*Do nothing*/ 4181 /* OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 8); 4182 (void)VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE);*/ 4183 } 4184 else if (nSartCode == 0x1B3) /*GOV*/ 4185 { 4186 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 20); 4187 (void)VIDDEC_GetBits(&nBitPosition, 20, pHeaderStream, OMX_TRUE); 4188 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4189 sMPEG4_Param->NBitZero = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4190 while ((nBitPosition%8)!= 0){ 4191 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4192 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE);/*discard align bits*/ 4193 } 4194 } 4195 else if (nSartCode == 0x1B2) /*user data*/ 4196 { 4197 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 24); 4198 while (VIDDEC_GetBits(&nBitPosition, 24, pHeaderStream, OMX_TRUE)!= 0x1) 4199 nBitPosition-=16; /*discard only 8 bits and try againg until*/ 4200 /*the next start code is found*/ 4201 nBitPosition -=24; /* prepare to read the entire start code*/ 4202 /* OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4203 sMPEG4_Param->NBitZero = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4204 PRINT("sMPEG4_Param->NBitZero = %d", sMPEG4_Param->NBitZero); 4205 while ((nBitPosition%8)!= 0) { 4206 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4207 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE);*//*discard align bits*/ 4208 /*}*/ 4209 } 4210 else if ((nSartCode >= 0x120)&&(nSartCode <= 0x12F)) 4211 { 4212 sVolHeaderPtr->nVideoObjectLayerId = nSartCode&0x0000000f; 4213 sVolHeaderPtr->bShortVideoHeader = 0; 4214 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4215 pPictHeaderPtr->bIsRandomAccessible = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4216 sVolHeaderPtr->bRandomAccessibleVOL = pPictHeaderPtr->bIsRandomAccessible; 4217 if (pPictHeaderPtr->bIsRandomAccessible) 4218 { 4219 /* it seems this never happens*/ 4220 } 4221 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 8); 4222 sMPEG4_Param->nVideoObjectTypeIndication = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); /* 8 bits*/ 4223 sVolHeaderPtr->nVideoObjectTypeIndication = sMPEG4_Param->nVideoObjectTypeIndication; 4224 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4225 sMPEG4_Param->nIsVisualObjectLayerIdentifier = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE);/*1 bit*/ 4226 sVolHeaderPtr->nVideoObjectLayerId = sMPEG4_Param->nIsVisualObjectLayerIdentifier; 4227 sMPEG4_Param->nLayerVerId = 0; 4228 if (sMPEG4_Param->nIsVisualObjectLayerIdentifier) 4229 { 4230 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 4); 4231 sMPEG4_Param->nLayerVerId = VIDDEC_GetBits(&nBitPosition, 4, pHeaderStream, OMX_TRUE); /*4 bits*/ 4232 sVolHeaderPtr->nVideoObjectLayerVerId = sMPEG4_Param->nLayerVerId; 4233 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 3); 4234 sMPEG4_Param->nLayerPriority = VIDDEC_GetBits(&nBitPosition, 3, pHeaderStream, OMX_TRUE); /*3 bits*/ 4235 sVolHeaderPtr->nVideoObjectLayerPriority = sMPEG4_Param->nLayerPriority; 4236 } 4237 4238 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 4); 4239 sMPEG4_Param->nAspectRadio = VIDDEC_GetBits(&nBitPosition, 4, pHeaderStream, OMX_TRUE); /*4 bits*/ 4240 if (sMPEG4_Param->nAspectRadio == 0xf) 4241 { 4242 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 8); 4243 sMPEG4_Param->nParWidth = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); /*8 bits*/ 4244 sVolHeaderPtr->nAspectRatioNum = sMPEG4_Param->nParWidth; 4245 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 8); 4246 sMPEG4_Param->nParHeight = VIDDEC_GetBits(&nBitPosition, 8, pHeaderStream, OMX_TRUE); /*8 bits*/ 4247 sVolHeaderPtr->nAspectRatioDenom = sMPEG4_Param->nParHeight; 4248 } 4249 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4250 sMPEG4_Param->nControlParameters = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4251 if ( sMPEG4_Param->nControlParameters ) 4252 { 4253 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 2); 4254 sMPEG4_Param->nChromaFormat = VIDDEC_GetBits(&nBitPosition, 2, pHeaderStream, OMX_TRUE); /*2 bits*/ 4255 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4256 sMPEG4_Param->nLowDelay = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4257 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4258 sMPEG4_Param->nVbvParameters = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4259 if (sMPEG4_Param->nVbvParameters) 4260 { 4261 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 15); 4262 sMPEG4_Param->nBitRate = VIDDEC_GetBits(&nBitPosition, 15, pHeaderStream, OMX_TRUE)<<15; /*15 bit*/ 4263 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4264 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4265 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 15); 4266 sMPEG4_Param->nBitRate |= VIDDEC_GetBits(&nBitPosition, 15, pHeaderStream, OMX_TRUE); /*15 bit*/ 4267 sVolHeaderPtr->sVbvParams.nBitRate = sMPEG4_Param->nBitRate; 4268 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4269 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4270 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 15); 4271 sMPEG4_Param->nFirstHalfVbvBufferSize = VIDDEC_GetBits(&nBitPosition, 15, pHeaderStream, OMX_TRUE); 4272 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4273 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4274 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 3); 4275 sMPEG4_Param->nLatterHalfVbvBufferSize = VIDDEC_GetBits(&nBitPosition, 3, pHeaderStream, OMX_TRUE); 4276 sVolHeaderPtr->sVbvParams.nVbvBufferSize = 4277 (((sMPEG4_Param->nFirstHalfVbvBufferSize) << 3) + sMPEG4_Param->nLatterHalfVbvBufferSize) * 2048; 4278 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 11); 4279 sMPEG4_Param->nFirstHalfVbvOccupancy = VIDDEC_GetBits(&nBitPosition, 11, pHeaderStream, OMX_TRUE); 4280 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4281 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4282 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 15); 4283 sMPEG4_Param->nLatterHalfVbvOccupancy = VIDDEC_GetBits(&nBitPosition, 15, pHeaderStream, OMX_TRUE); 4284 sVolHeaderPtr->sVbvParams.nVbvOccupancy = 4285 (((sMPEG4_Param->nFirstHalfVbvOccupancy) << 15) + sMPEG4_Param->nLatterHalfVbvOccupancy) * 2048; 4286 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4287 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4288 4289 /*OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 48); 4290 (void)VIDDEC_GetBits(&nBitPosition, 48, pHeaderStream, OMX_TRUE);*/ 4291 } 4292 else 4293 { 4294 sMPEG4_Param->nBitRate = 0; 4295 } 4296 } 4297 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 2); 4298 sMPEG4_Param->nLayerShape = VIDDEC_GetBits(&nBitPosition, 2, pHeaderStream, OMX_TRUE); /*2 bits*/ 4299 /*skip one marker_bit*/ 4300 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4301 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4302 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 16); 4303 sMPEG4_Param->nTimeIncrementResolution = VIDDEC_GetBits(&nBitPosition, 16, pHeaderStream, OMX_TRUE); /*16 bits*/ 4304 sVolHeaderPtr->nVOPTimeIncrementResolution = sMPEG4_Param->nTimeIncrementResolution; 4305 /*skip one market bit*/ 4306 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4307 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4308 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4309 sMPEG4_Param->nFnXedVopRate = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4310 sVolHeaderPtr->bnFnXedVopRate = sMPEG4_Param->nFnXedVopRate; 4311 if (sMPEG4_Param->nFnXedVopRate) 4312 { 4313 sMPEG4_Param->nNum_bits = GET_NUM_BIT_REQ (sMPEG4_Param->nTimeIncrementResolution); 4314 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, sMPEG4_Param->nNum_bits); 4315 sVolHeaderPtr->nFnXedVOPTimeIncrement = VIDDEC_GetBits (&nBitPosition, sMPEG4_Param->nNum_bits, pHeaderStream, OMX_TRUE); 4316 } 4317 /*skip one market bit*/ 4318 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4319 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4320 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 13); 4321 (*nWidth) = VIDDEC_GetBits(&nBitPosition, 13, pHeaderStream, OMX_TRUE); /*13 bits*/ 4322 /*skip one market bit*/ 4323 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4324 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4325 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 13); 4326 (*nHeight) = VIDDEC_GetBits(&nBitPosition, 13, pHeaderStream, OMX_TRUE); /*13 bits*/ 4327 4328 /*skip one market bit*/ 4329 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4330 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4331 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4332 sMPEG4_Param->nInterlaced = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4333 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4334 sMPEG4_Param->nObmc = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4335 if (sMPEG4_Param->nLayerVerId) 4336 { 4337 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4338 sMPEG4_Param->NSpriteNotSupported = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4339 if (sMPEG4_Param->NSpriteNotSupported) 4340 { 4341 } 4342 } 4343 else 4344 { 4345 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 2); 4346 sMPEG4_Param->NSpriteNotSupported = VIDDEC_GetBits(&nBitPosition, 2, pHeaderStream, OMX_TRUE); /*2 bits*/ 4347 if (sMPEG4_Param->NSpriteNotSupported) 4348 { 4349 } 4350 } 4351 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4352 sMPEG4_Param->nNot8Bit = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bits*/ 4353 sMPEG4_Param->nQuantPrecision = 5; 4354 sMPEG4_Param->nBitsPerPnXel = 8; 4355 if (sMPEG4_Param->nNot8Bit) 4356 { 4357 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 4); 4358 sMPEG4_Param->nQuantPrecision = VIDDEC_GetBits(&nBitPosition,4, pHeaderStream, OMX_TRUE); /* 4 bits*/ 4359 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 4); 4360 sMPEG4_Param->nBitsPerPnXel = VIDDEC_GetBits(&nBitPosition,4, pHeaderStream, OMX_TRUE); /* 4 bits*/ 4361 } 4362 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4363 sMPEG4_Param->nIsInverseQuantMethodFirst = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bits*/ 4364 if (sMPEG4_Param->nLayerVerId !=1) 4365 { 4366 /*does not support quater sample*/ 4367 /*kip one market bit*/ 4368 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4369 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4370 } 4371 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4372 sMPEG4_Param->nComplexityEstimationDisable = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4373 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4374 sMPEG4_Param->nIsResyncMarkerDisabled = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4375 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4376 sMPEG4_Param->nIsDataPartitioned = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4377 sVolHeaderPtr->bDataPartitioning = sMPEG4_Param->nIsDataPartitioned; 4378 if (sMPEG4_Param->nIsDataPartitioned) 4379 { 4380 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4381 sMPEG4_Param->nRvlc = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4382 sVolHeaderPtr->bReversibleVLC = sMPEG4_Param->nRvlc; 4383 if (sMPEG4_Param->nRvlc) 4384 { 4385 } 4386 } 4387 if (sMPEG4_Param->nLayerVerId !=1) 4388 { 4389 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 2); 4390 (void)VIDDEC_GetBits(&nBitPosition, 2, pHeaderStream, OMX_TRUE); /*2 bit*/ 4391 } 4392 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 1); 4393 sMPEG4_Param->nScalability = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); /*1 bit*/ 4394 /*pPictHeaderPtr->sSizeInMemory.nWidth = (*nWidth); 4395 pPictHeaderPtr->sSizeInMemory.nHeight = (*nHeight); 4396 pPictHeaderPtr->sDisplayedRect = TRect(TSize((*nWidth),(*nHeight)));*/ 4397 if (iOutputFormat.iYuvFormat.iPattern == 0x00000001) 4398 pPictHeaderPtr->nPostDecoderBufferSize = (*nHeight) * (*nWidth) * 3 / 2; /*YUV 420 Planar*/ 4399 else if (iOutputFormat.iYuvFormat.iPattern == 0x00000008) 4400 pPictHeaderPtr->nPostDecoderBufferSize = (*nHeight) * (*nWidth) * 2; /*YUV 422 Interleaved*/ 4401 pPictHeaderPtr->nOptions |= 0x00000008; 4402 if(bFillHeaderInfo) 4403 { 4404 ; 4405 } 4406 bHeaderParseCompleted = OMX_TRUE; 4407 eError = OMX_ErrorNone; 4408 } 4409 else if ( (nSartCode&0xfffffc00) == 0x00008000 ) 4410 { 4411 sVolHeaderPtr->bShortVideoHeader = 1; 4412 /* discard 3 bits for split_screen_indicator, document_camera_indicator*/ 4413 /* and full_picture_freeze_release*/ 4414 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 3); 4415 (void)VIDDEC_GetBits(&nBitPosition, 3, pHeaderStream, OMX_TRUE); 4416 OMX_PARSER_CHECKLIMIT(nTotalInBytes, nBitPosition, 3); 4417 sMPEG4_Param->nSourceFormat = VIDDEC_GetBits(&nBitPosition, 3, pHeaderStream, OMX_TRUE); 4418 if (sMPEG4_Param->nSourceFormat == 0x1) 4419 { 4420 (*nWidth) = 128; 4421 (*nHeight) = 96; 4422 } 4423 else if (sMPEG4_Param->nSourceFormat == 0x2) 4424 { 4425 (*nWidth) = 176; 4426 (*nHeight) = 144; 4427 } 4428 else if (sMPEG4_Param->nSourceFormat == 0x3) 4429 { 4430 (*nWidth) = 352; 4431 (*nHeight) = 288; 4432 } 4433 else if (sMPEG4_Param->nSourceFormat == 0x4) 4434 { 4435 (*nWidth) = 704; 4436 (*nHeight) = 576; 4437 } 4438 else if (sMPEG4_Param->nSourceFormat == 0x5) 4439 { 4440 (*nWidth) = 1408; 4441 (*nHeight) = 1152; 4442 } 4443 else if (sMPEG4_Param->nSourceFormat == 0x7) 4444 { 4445 sMPEG4_Param->nUFEP = VIDDEC_GetBits(&nBitPosition, 3, pHeaderStream, OMX_TRUE); 4446 if(sMPEG4_Param->nUFEP == 1) { 4447 sMPEG4_Param->nSourceFormat = VIDDEC_GetBits(&nBitPosition, 3, pHeaderStream, OMX_TRUE); 4448 if (sMPEG4_Param->nSourceFormat == 0x1) 4449 { 4450 (*nWidth) = 128; 4451 (*nHeight) = 96; 4452 } 4453 else if (sMPEG4_Param->nSourceFormat == 0x2) 4454 { 4455 (*nWidth) = 176; 4456 (*nHeight) = 144; 4457 } 4458 else if (sMPEG4_Param->nSourceFormat == 0x3) 4459 { 4460 (*nWidth) = 352; 4461 (*nHeight) = 288; 4462 } 4463 else if (sMPEG4_Param->nSourceFormat == 0x4) 4464 { 4465 4466 (*nWidth) = 704; 4467 (*nHeight) = 576; 4468 } 4469 else if (sMPEG4_Param->nSourceFormat == 0x5) 4470 { 4471 (*nWidth) = 1408; 4472 (*nHeight) = 1152; 4473 } 4474 else if (sMPEG4_Param->nSourceFormat == 0x6) 4475 { 4476 (void)VIDDEC_GetBits(&nBitPosition, 24, pHeaderStream, OMX_TRUE); 4477 sMPEG4_Param->nCPM = VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4478 if(sMPEG4_Param->nCPM) 4479 (void)VIDDEC_GetBits(&nBitPosition, 2, pHeaderStream, OMX_TRUE); 4480 4481 (void)VIDDEC_GetBits(&nBitPosition, 4, pHeaderStream, OMX_TRUE); 4482 4483 sMPEG4_Param->nPWI = VIDDEC_GetBits(&nBitPosition, 9, pHeaderStream, OMX_TRUE); 4484 (*nWidth) = (sMPEG4_Param->nPWI + 1)*4; 4485 4486 (void)VIDDEC_GetBits(&nBitPosition, 1, pHeaderStream, OMX_TRUE); 4487 4488 sMPEG4_Param->nPHI = VIDDEC_GetBits(&nBitPosition, 9, pHeaderStream, OMX_TRUE); 4489 (*nHeight) = sMPEG4_Param->nPHI*4; 4490 4491 } 4492 else if (sMPEG4_Param->nSourceFormat == 0x7) 4493 { 4494 sMPEG4_Param->nSourceFormat = VIDDEC_GetBits(&nBitPosition, 3, pHeaderStream, OMX_TRUE); 4495 (*nWidth) = 1408; 4496 (*nHeight) = 1152; 4497 } 4498 else 4499 { 4500 eError = OMX_ErrorUnsupportedSetting; 4501 goto EXIT; 4502 } 4503 } 4504 } 4505 else 4506 { 4507 eError = OMX_ErrorUnsupportedSetting; 4508 goto EXIT; 4509 } 4510 bHeaderParseCompleted = OMX_TRUE; 4511 eError = OMX_ErrorNone; 4512 } 4513 else 4514 { 4515 eError = OMX_ErrorUnsupportedSetting; 4516 goto EXIT; 4517 } 4518 } 4519 EXIT: 4520 if(pPictHeaderPtr->cnOptional != NULL) 4521 { 4522 free( pPictHeaderPtr->cnOptional); 4523 pPictHeaderPtr->cnOptional = NULL; 4524 } 4525 return eError; 4526 } 4527 #endif 4528 4529 #ifdef VIDDEC_ACTIVATEPARSER 4530 /* ==========================================================================*/ 4531 /* func VIDDEC_ScanConfigBufferAVC */ 4532 /* */ 4533 /* desc Use to scan buffer for certain patter. Used to know if ConfigBuffers are together */ 4534 /* ==========================================================================*/ 4535 static OMX_U32 VIDDEC_ScanConfigBufferAVC(OMX_BUFFERHEADERTYPE* pBuffHead, OMX_U32 pattern){ 4536 OMX_U32 nBitPosition = 0; 4537 OMX_U32 nInBytePosition = 0; 4538 OMX_U32 nPatternCounter = 0; 4539 OMX_U32 nTotalInBytes = pBuffHead->nFilledLen; 4540 OMX_U8* nBitStream = (OMX_U8*)pBuffHead->pBuffer; 4541 4542 while (nInBytePosition < nTotalInBytes - 3){ 4543 if (VIDDEC_GetBits(&nBitPosition, 24, nBitStream, OMX_FALSE) != pattern) { 4544 nBitPosition += 8; 4545 nInBytePosition++; 4546 } 4547 else { 4548 /*Pattern found; add count*/ 4549 nPatternCounter++; 4550 nBitPosition += 24; 4551 nInBytePosition += 3; 4552 } 4553 } 4554 return nPatternCounter; 4555 } 4556 4557 /* ==========================================================================*/ 4558 /* func VIDDEC_ParseVideo_H264 */ 4559 /* */ 4560 /* desc */ 4561 /* ==========================================================================*/ 4562 OMX_ERRORTYPE VIDDEC_ParseVideo_H264(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, 4563 OMX_BUFFERHEADERTYPE* pBuffHead,OMX_S32* nWidth, 4564 OMX_S32* nHeight, OMX_S32* nCropWidth, 4565 OMX_S32* nCropHeight, OMX_U32 nType) 4566 { 4567 OMX_ERRORTYPE eError = OMX_ErrorBadParameter; 4568 OMX_S32 i = 0; 4569 VIDDEC_AVC_ParserParam* sParserParam = NULL; 4570 /*OMX_S32 nRetVal = 0;*/ 4571 OMX_BOOL nStartFlag = OMX_FALSE; 4572 OMX_U32 nBitPosition = 0; 4573 OMX_U32 nRbspPosition = 0; 4574 OMX_U32 nTotalInBytes = 0; 4575 OMX_U32 nInBytePosition = 0; 4576 OMX_U32 nInPositionTemp = 0; 4577 OMX_U32 nNumOfBytesInRbsp = 0; 4578 OMX_S32 nNumBytesInNALunit = 0; 4579 OMX_U8* nBitStream = 0; 4580 OMX_U32 nNalUnitType = 0; 4581 OMX_U8* nRbspByte = NULL; 4582 4583 OMX_U8 *pDataBuf; 4584 4585 /* counter used for fragmentation of Config Buffer Code */ 4586 static OMX_U32 nConfigBufferCounter; 4587 4588 nTotalInBytes = pBuffHead->nFilledLen; 4589 nBitStream = (OMX_U8*)pBuffHead->pBuffer;/* + (OMX_U8*)pBuffHead->nOffset;*/ 4590 nRbspByte = (OMX_U8*)malloc(nTotalInBytes); 4591 if (!nRbspByte) { 4592 eError = OMX_ErrorInsufficientResources; 4593 goto EXIT; 4594 } 4595 memset(nRbspByte, 0x0, nTotalInBytes); 4596 sParserParam = (VIDDEC_AVC_ParserParam *)malloc(sizeof(VIDDEC_AVC_ParserParam)); 4597 if (!sParserParam) { 4598 eError = OMX_ErrorInsufficientResources; 4599 goto EXIT; 4600 } 4601 4602 if (nType == 0) { 4603 /* Start of Handle fragmentation of Config Buffer Code*/ 4604 /*Scan for 2 "0x000001", requiered on buffer to parser properly*/ 4605 nConfigBufferCounter += VIDDEC_ScanConfigBufferAVC(pBuffHead, 0x000001); 4606 if(nConfigBufferCounter < 2){ /*If less of 2 we need to store the data internally to later assembly the complete ConfigBuffer*/ 4607 /*Set flag to False, the Config Buffer is not complete */ 4608 OMX_PRINT2(pComponentPrivate->dbg, "Setting bConfigBufferCompleteAVC = OMX_FALSE"); 4609 pComponentPrivate->bConfigBufferCompleteAVC = OMX_FALSE; 4610 /* Malloc Buffer if is not created yet, use Port buffer size*/ 4611 if(pComponentPrivate->pInternalConfigBufferAVC == NULL){ 4612 pComponentPrivate->pInternalConfigBufferAVC = malloc(pComponentPrivate->pInPortDef->nBufferSize); 4613 if(pComponentPrivate->pInternalConfigBufferAVC == NULL){ 4614 eError = OMX_ErrorInsufficientResources; 4615 goto EXIT; 4616 } 4617 } 4618 /* Check if memcpy is safe*/ 4619 if(pComponentPrivate->pInPortDef->nBufferSize >= pComponentPrivate->nInternalConfigBufferFilledAVC + pBuffHead->nFilledLen){ 4620 /*Append current buffer data to Internal Config Buffer */ 4621 if(memcpy((OMX_U8*)(pComponentPrivate->pInternalConfigBufferAVC + pComponentPrivate->nInternalConfigBufferFilledAVC), 4622 pBuffHead->pBuffer, 4623 pBuffHead->nFilledLen) == NULL) { 4624 eError = OMX_ErrorInsufficientResources; 4625 goto EXIT; 4626 } 4627 } 4628 else{ 4629 eError =OMX_ErrorInsufficientResources; 4630 goto EXIT; 4631 } 4632 /*Update Filled length of Internal Buffer*/ 4633 pComponentPrivate->nInternalConfigBufferFilledAVC += pBuffHead->nFilledLen; 4634 /* Exit with out error*/ 4635 eError = OMX_ErrorNone; 4636 goto EXIT; 4637 } 4638 else{ /* We have all the requiered data*/ 4639 OMX_PRINT2(pComponentPrivate->dbg, "Setting bConfigBufferCompleteAVC = OMX_TRUE"); 4640 pComponentPrivate->bConfigBufferCompleteAVC = OMX_TRUE; 4641 /* If we have already Config data of previous buffer, we assembly the final ConfigBuffer*/ 4642 if(pComponentPrivate->pInternalConfigBufferAVC != NULL){ 4643 /*Check if memcpy is safe*/ 4644 if(pComponentPrivate->pInPortDef->nBufferSize >= 4645 pComponentPrivate->nInternalConfigBufferFilledAVC + pBuffHead->nFilledLen){ 4646 /*The current data of the Buffer has to be placed at the end of buffer*/ 4647 if(memcpy((OMX_U8*)(pBuffHead->pBuffer + pComponentPrivate->nInternalConfigBufferFilledAVC), 4648 pBuffHead->pBuffer, 4649 pBuffHead->nFilledLen) == NULL){ 4650 eError = OMX_ErrorInsufficientResources; 4651 goto EXIT; 4652 } 4653 /*The data internally stored has to be put at the begining of the buffer*/ 4654 if(memcpy(pBuffHead->pBuffer, 4655 pComponentPrivate->pInternalConfigBufferAVC, 4656 pComponentPrivate->nInternalConfigBufferFilledAVC) == NULL){ 4657 eError = OMX_ErrorInsufficientResources; 4658 goto EXIT; 4659 } 4660 } 4661 else{ 4662 eError = OMX_ErrorInsufficientResources; 4663 goto EXIT; 4664 } 4665 4666 /*Update filled length of current buffer */ 4667 pBuffHead->nFilledLen = pComponentPrivate->nInternalConfigBufferFilledAVC + pBuffHead->nFilledLen; 4668 /*Free Internal Buffer used to temporarly hold the data*/ 4669 if (pComponentPrivate->pInternalConfigBufferAVC != NULL) 4670 free(pComponentPrivate->pInternalConfigBufferAVC); 4671 /* Reset Internal Variables*/ 4672 pComponentPrivate->pInternalConfigBufferAVC = NULL; 4673 pComponentPrivate->nInternalConfigBufferFilledAVC = 0; 4674 nConfigBufferCounter = 0; 4675 /* Update Buffer Variables before parsing */ 4676 nTotalInBytes = pBuffHead->nFilledLen; 4677 if ( nRbspByte != NULL ) 4678 free(nRbspByte); 4679 nRbspByte = (OMX_U8*)malloc(nTotalInBytes); 4680 if(nRbspByte == NULL){ 4681 eError = OMX_ErrorInsufficientResources; 4682 goto EXIT; 4683 } 4684 memset(nRbspByte, 0x0, nTotalInBytes); 4685 /*Buffer ready to be parse =) */ 4686 } 4687 } 4688 /* End of Handle fragmentation Config Buffer Code*/ 4689 4690 do{ 4691 for (; (!nStartFlag) && (nInBytePosition < nTotalInBytes - 3); ) 4692 { 4693 if (VIDDEC_GetBits(&nBitPosition, 24, nBitStream, OMX_FALSE) != 0x000001) 4694 { 4695 nBitPosition += 8; 4696 nInBytePosition++; 4697 } 4698 else 4699 { 4700 /*Start Code found*/ 4701 nStartFlag = OMX_TRUE; 4702 nBitPosition += 24; 4703 nInBytePosition += 3; 4704 } 4705 } 4706 nStartFlag = OMX_FALSE; 4707 /* offset to NumBytesInNALunit*/ 4708 nNumBytesInNALunit = nInBytePosition; 4709 sParserParam->nBitPosTemp = nBitPosition; 4710 for (;(!nStartFlag)&&(nNumBytesInNALunit < nTotalInBytes-3); ) 4711 { 4712 if (VIDDEC_GetBits(&sParserParam->nBitPosTemp, 24, nBitStream, OMX_FALSE) != 0x000001) 4713 /*find start code*/ 4714 { 4715 sParserParam->nBitPosTemp += 8; 4716 nNumBytesInNALunit++; 4717 } 4718 else 4719 { 4720 /*Start Code found*/ 4721 nStartFlag = OMX_TRUE; 4722 sParserParam->nBitPosTemp += 24; 4723 nNumBytesInNALunit += 3; 4724 } 4725 } 4726 4727 if (!nStartFlag) 4728 { 4729 eError = OMX_ErrorStreamCorrupt; 4730 goto EXIT; 4731 } 4732 /* forbidden_zero_bit */ 4733 sParserParam->nForbiddenZeroBit = VIDDEC_GetBits(&nBitPosition, 1, nBitStream, OMX_TRUE); 4734 /* nal_ref_idc */ 4735 sParserParam->nNalRefIdc = VIDDEC_GetBits(&nBitPosition, 2, nBitStream, OMX_TRUE); 4736 /* nal_unit_type */ 4737 nNalUnitType = VIDDEC_GetBits(&nBitPosition, 5, nBitStream, OMX_TRUE); 4738 nInBytePosition++; 4739 4740 /* This code is to ensure we will get parameter info */ 4741 if (nNalUnitType != 7) 4742 { 4743 OMX_PRINT2(pComponentPrivate->dbg, "nal_unit_type does not specify parameter information need to look for next startcode\n"); 4744 nStartFlag = OMX_FALSE; 4745 } 4746 }while (nNalUnitType != 7); 4747 } 4748 else { 4749 pDataBuf = (OMX_U8*)nBitStream; 4750 do { 4751 /* iOMXComponentUsesNALStartCodes is set to OMX_FALSE on opencore */ 4752 #ifndef ANDROID 4753 if (pComponentPrivate->H264BitStreamFormat == 1) { 4754 if (pComponentPrivate->bIsNALBigEndian) { 4755 nNumBytesInNALunit = (OMX_U32)pDataBuf[nInBytePosition]; 4756 } 4757 else { 4758 nNumBytesInNALunit = (OMX_U32)pDataBuf[nInBytePosition]; 4759 } 4760 } 4761 else if (pComponentPrivate->H264BitStreamFormat == 2) { 4762 if (pComponentPrivate>bIsNALBigEndian) { 4763 nNumBytesInNALunit = (OMX_U32)pDataBuf[nInBytePosition] << 8 | pDataBuf[nInBytePosition+1]; 4764 } 4765 else { 4766 nNumBytesInNALunit = (OMX_U32)pDataBuf[nInBytePosition] << 0 | pDataBuf[nInBytePosition+1] << 8 ; 4767 } 4768 } 4769 else if (pComponentPrivate->H264BitStreamFormat == 4){ 4770 if (pComponentPrivate->bIsNALBigEndian) { 4771 nNumBytesInNALunit = (OMX_U32)pDataBuf[nInBytePosition]<<24 | pDataBuf[nInBytePosition+1] << 16 | pDataBuf[nInBytePosition+2] << 8 | pDataBuf[nInBytePosition+3]; 4772 } 4773 else { 4774 nNumBytesInNALunit = (OMX_U32)pDataBuf[nInBytePosition]<<0 | pDataBuf[nInBytePosition+1] << 8 | pDataBuf[nInBytePosition+2] << 16 | pDataBuf[nInBytePosition+3]<<24; 4775 } 4776 } 4777 else { 4778 eError = OMX_ErrorBadParameter; 4779 goto EXIT; 4780 } 4781 #endif 4782 nBitPosition = (nInPositionTemp + nType) * 8; 4783 nInBytePosition = nInPositionTemp + nType; 4784 nInPositionTemp += nNumBytesInNALunit + nType; 4785 if (nInBytePosition > nTotalInBytes) { 4786 eError = OMX_ErrorBadParameter; 4787 goto EXIT; 4788 } 4789 /* forbidden_zero_bit */ 4790 sParserParam->nForbiddenZeroBit = VIDDEC_GetBits(&nBitPosition, 1, nBitStream, OMX_TRUE); 4791 /* nal_ref_idc */ 4792 sParserParam->nNalRefIdc = VIDDEC_GetBits(&nBitPosition, 2, nBitStream, OMX_TRUE); 4793 /* nal_unit_type */ 4794 nNalUnitType = VIDDEC_GetBits(&nBitPosition, 5, nBitStream, OMX_TRUE); 4795 nInBytePosition++; 4796 /* This code is to ensure we will get parameter info */ 4797 if (nNalUnitType != 7) { 4798 /*nBitPosition += (nNumBytesInNALunit - 1) * 8; 4799 nInBytePosition += (nNumBytesInNALunit - 1);*/ 4800 nBitPosition = (nInPositionTemp) * 8; 4801 nInBytePosition = (nInPositionTemp); 4802 4803 } 4804 } while (nNalUnitType != 7); 4805 nNumBytesInNALunit += 8 + nInBytePosition;/*sum to keep the code flow*/ 4806 /*the buffer must had enough space to enter this number*/ 4807 } 4808 for (i=0; nInBytePosition < nNumBytesInNALunit - 3; ) 4809 { 4810 4811 if (((nInBytePosition + 2) < nNumBytesInNALunit - 3)&& 4812 (VIDDEC_GetBits(&nBitPosition, 24, nBitStream, OMX_FALSE) == 0x000003)) 4813 { 4814 OMX_PRINT2(pComponentPrivate->dbg, "discard emulation prev byte\n"); 4815 nRbspByte[i++] = nBitStream[nInBytePosition++]; 4816 nRbspByte[i++] = nBitStream[nInBytePosition++]; 4817 nNumOfBytesInRbsp += 2; 4818 /* discard emulation prev byte */ 4819 nInBytePosition++; 4820 nBitPosition += 24; 4821 } 4822 else 4823 { 4824 nRbspByte[i++] = nBitStream[nInBytePosition++]; 4825 nNumOfBytesInRbsp++; 4826 nBitPosition += 8; 4827 } 4828 } 4829 4830 4831 /*Parse RBSP sequence*/ 4832 /*///////////////////*/ 4833 /* profile_idc u(8) */ 4834 sParserParam->nProfileIdc = VIDDEC_GetBits(&nRbspPosition, 8, nRbspByte, OMX_TRUE); 4835 /* constraint_set0_flag u(1)*/ 4836 sParserParam->nConstraintSet0Flag = VIDDEC_GetBits(&nRbspPosition, 1, nRbspByte, OMX_TRUE); 4837 /* constraint_set1_flag u(1)*/ 4838 sParserParam->nConstraintSet1Flag = VIDDEC_GetBits(&nRbspPosition, 1, nRbspByte, OMX_TRUE); 4839 /* constraint_set2_flag u(1)*/ 4840 sParserParam->nConstraintSet2Flag = VIDDEC_GetBits(&nRbspPosition, 1, nRbspByte, OMX_TRUE); 4841 /* reserved_zero_5bits u(5)*/ 4842 sParserParam->nReservedZero5bits = VIDDEC_GetBits(&nRbspPosition, 5, nRbspByte, OMX_TRUE); 4843 /* level_idc*/ 4844 sParserParam->nLevelIdc = VIDDEC_GetBits(&nRbspPosition, 8, nRbspByte, OMX_TRUE); 4845 sParserParam->nSeqParameterSetId = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4846 sParserParam->nLog2MaxFrameNumMinus4 = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4847 sParserParam->nPicOrderCntType = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4848 4849 if ( sParserParam->nPicOrderCntType == 0 ) 4850 { 4851 sParserParam->nLog2MaxPicOrderCntLsbMinus4 = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4852 } 4853 else if( sParserParam->nPicOrderCntType == 1 ) 4854 { 4855 /* delta_pic_order_always_zero_flag*/ 4856 VIDDEC_GetBits(&nRbspPosition, 1, nRbspByte, OMX_TRUE); 4857 sParserParam->nOffsetForNonRefPic = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4858 if (sParserParam->nOffsetForNonRefPic > 1) 4859 sParserParam->nOffsetForNonRefPic = sParserParam->nOffsetForNonRefPic & 0x1 ? 4860 sParserParam->nOffsetForNonRefPic >> 1 : 4861 -(sParserParam->nOffsetForNonRefPic >> 1); 4862 sParserParam->nOffsetForTopToBottomField = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4863 sParserParam->nNumRefFramesInPicOrderCntCycle = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4864 for(i = 0; i < sParserParam->nNumRefFramesInPicOrderCntCycle; i++ ) 4865 VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); /*offset_for_ref_frame[i]*/ 4866 } 4867 4868 sParserParam->nNumRefFrames = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4869 sParserParam->nGapsInFrameNumValueAllowedFlag = VIDDEC_GetBits(&nRbspPosition, 1, nRbspByte, OMX_TRUE); 4870 sParserParam->nPicWidthInMbsMinus1 = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4871 (*nWidth) = (sParserParam->nPicWidthInMbsMinus1 + 1) * 16; 4872 sParserParam->nPicHeightInMapUnitsMinus1 = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4873 (*nHeight) = (sParserParam->nPicHeightInMapUnitsMinus1 + 1) * 16; 4874 /* Checking for cropping in picture saze */ 4875 /* getting frame_mbs_only_flag */ 4876 sParserParam->nFrameMbsOnlyFlag = VIDDEC_GetBits(&nRbspPosition, 1, nRbspByte, OMX_TRUE); 4877 if (!sParserParam->nFrameMbsOnlyFlag) 4878 { 4879 sParserParam->nMBAdaptiveFrameFieldFlag = VIDDEC_GetBits(&nRbspPosition, 1, nRbspByte, OMX_TRUE); 4880 } 4881 /*getting direct_8x8_inference_flag and frame_cropping_flag*/ 4882 sParserParam->nDirect8x8InferenceFlag = VIDDEC_GetBits(&nRbspPosition, 1, nRbspByte, OMX_TRUE); 4883 sParserParam->nFrameCroppingFlag = VIDDEC_GetBits(&nRbspPosition, 1, nRbspByte, OMX_TRUE); 4884 /*getting the crop values if exist*/ 4885 if (sParserParam->nFrameCroppingFlag) 4886 { 4887 sParserParam->nFrameCropLeftOffset = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4888 sParserParam->nFrameCropRightOffset = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4889 sParserParam->nFrameCropTopOffset = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4890 sParserParam->nFrameCropBottomOffset = VIDDEC_UVLC_dec(&nRbspPosition, nRbspByte); 4891 /* Update framesize taking into account the cropping values */ 4892 (*nCropWidth) = (2 * sParserParam->nFrameCropLeftOffset + 2 * sParserParam->nFrameCropRightOffset); 4893 (*nCropHeight) = (2 * sParserParam->nFrameCropTopOffset + 2 * sParserParam->nFrameCropBottomOffset); 4894 } 4895 eError = OMX_ErrorNone; 4896 4897 EXIT: 4898 if (nRbspByte) 4899 free( nRbspByte); 4900 if (sParserParam) 4901 free( sParserParam); 4902 return eError; 4903 } 4904 #endif 4905 4906 #ifdef VIDDEC_ACTIVATEPARSER 4907 /* =========================================================================*/ 4908 /* func GetBits */ 4909 /* */ 4910 /* desc Gets aBits number of bits from position aPosition of one buffer */ 4911 /* and returns the value in a TUint value. */ 4912 /* =========================================================================*/ 4913 OMX_U32 VIDDEC_GetBits(OMX_U32* nPosition, OMX_U8 nBits, OMX_U8* pBuffer, OMX_BOOL bIcreasePosition) 4914 { 4915 OMX_U32 nOutput; 4916 OMX_U32 nNumBitsRead = 0; 4917 OMX_U32 nBytePosition = 0; 4918 OMX_U8 nBitPosition = 0; 4919 nBytePosition = *nPosition / 8; 4920 nBitPosition = *nPosition % 8; 4921 4922 if (bIcreasePosition) 4923 *nPosition += nBits; 4924 nOutput = ((OMX_U32)pBuffer[nBytePosition] << (24+nBitPosition) ); 4925 nNumBitsRead = nNumBitsRead + (8 - nBitPosition); 4926 if (nNumBitsRead < nBits) 4927 { 4928 nOutput = nOutput | ( pBuffer[nBytePosition + 1] << (16+nBitPosition)); 4929 nNumBitsRead = nNumBitsRead + 8; 4930 } 4931 if (nNumBitsRead < nBits) 4932 { 4933 nOutput = nOutput | ( pBuffer[nBytePosition + 2] << (8+nBitPosition)); 4934 nNumBitsRead = nNumBitsRead + 8; 4935 } 4936 if (nNumBitsRead < nBits) 4937 { 4938 nOutput = nOutput | ( pBuffer[nBytePosition + 3] << (nBitPosition)); 4939 nNumBitsRead = nNumBitsRead + 8; 4940 } 4941 nOutput = nOutput >> (32 - nBits) ; 4942 return nOutput; 4943 } 4944 4945 4946 OMX_S32 VIDDEC_UVLC_dec(OMX_U32 *nPosition, OMX_U8* pBuffer) 4947 { 4948 4949 OMX_U32 nBytePosition = (*nPosition) / 8; 4950 OMX_U8 cBitPosition = (*nPosition) % 8; 4951 OMX_U32 nLen = 1; 4952 OMX_U32 nCtrBit = 0; 4953 OMX_U32 nVal = 1; 4954 OMX_S32 nInfoBit=0; 4955 4956 nCtrBit = pBuffer[nBytePosition] & (0x1 << (7-cBitPosition)); 4957 while (nCtrBit==0) 4958 { 4959 nLen++; 4960 cBitPosition++; 4961 (*nPosition)++; 4962 if (!(cBitPosition%8)) 4963 { 4964 cBitPosition=0; 4965 nBytePosition++; 4966 } 4967 nCtrBit = pBuffer[nBytePosition] & (0x1<<(7-cBitPosition)); 4968 } 4969 for(nInfoBit=0; (nInfoBit<(nLen-1)); nInfoBit++) 4970 { 4971 cBitPosition++; 4972 (*nPosition)++; 4973 4974 if (!(cBitPosition%8)) 4975 { 4976 cBitPosition=0; 4977 nBytePosition++; 4978 } 4979 nVal=(nVal << 1); 4980 if(pBuffer[nBytePosition] & (0x01 << (7 - cBitPosition))) 4981 nVal |= 1; 4982 } 4983 (*nPosition)++; 4984 nVal -= 1; 4985 return nVal; 4986 } 4987 #endif 4988 4989 #ifdef VIDDEC_ACTIVATEPARSER 4990 /* ========================================================================== */ 4991 /** 4992 * Parse the input buffer to get the correct width and height 4993 **/ 4994 /* ========================================================================== */ 4995 OMX_ERRORTYPE VIDDEC_ParseHeader(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, OMX_BUFFERHEADERTYPE *pBuffHead) 4996 { 4997 OMX_ERRORTYPE eError = OMX_ErrorNone; 4998 OMX_S32 nWidth = 0; 4999 OMX_S32 nHeight = 0; 5000 OMX_S32 nPadWidth = 0; 5001 OMX_S32 nPadHeight = 0; 5002 OMX_S32 nCropWidth = 0; 5003 OMX_S32 nCropHeight = 0; 5004 OMX_S32 nCroppedWidth = 0; 5005 OMX_S32 nCroppedHeight = 0; 5006 5007 OMX_U32 nOutMinBufferSize = 0; 5008 OMX_BOOL bInPortSettingsChanged = OMX_FALSE; 5009 OMX_BOOL bOutPortSettingsChanged = OMX_FALSE; 5010 OMX_U32 nOutPortActualAllocLen = 0; 5011 5012 OMX_PRINT1(pComponentPrivate->dbg, "IN\n"); 5013 if(!pComponentPrivate) { 5014 goto EXIT; 5015 } 5016 5017 bInPortSettingsChanged = pComponentPrivate->bInPortSettingsChanged; 5018 bOutPortSettingsChanged = pComponentPrivate->bOutPortSettingsChanged; 5019 /*Get output port allocated buffer size*/ 5020 nOutPortActualAllocLen = pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[0]->pBufferHdr->nAllocLen; 5021 5022 OMX_PRINT1(pComponentPrivate->dbg, "pBuffHead %x, Original resolution IN %dx%d : OUT %dx%d\n", 5023 (unsigned int)pBuffHead, 5024 (unsigned int)pComponentPrivate->pInPortDef->format.video.nFrameWidth, 5025 (unsigned int)pComponentPrivate->pInPortDef->format.video.nFrameHeight, 5026 (unsigned int)pComponentPrivate->pOutPortDef->format.video.nFrameWidth, 5027 (unsigned int)pComponentPrivate->pOutPortDef->format.video.nFrameHeight); 5028 5029 5030 if( pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 5031 eError = VIDDEC_ParseVideo_H264( pComponentPrivate, pBuffHead, &nWidth, &nHeight, 5032 &nCropWidth, &nCropHeight, pComponentPrivate->H264BitStreamFormat); 5033 5034 /* Start Code to handle fragmentation of ConfigBuffer for AVC*/ 5035 if(pComponentPrivate->bConfigBufferCompleteAVC == OMX_FALSE && 5036 pComponentPrivate->ProcessMode == 0 && pComponentPrivate->H264BitStreamFormat == 0){ 5037 /* We have received some part of the config Buffer. 5038 * Send EmptyThisBuffer of the buffer we have just received to Client 5039 */ 5040 VIDDEC_EmptyBufferDone(pComponentPrivate, pBuffHead); 5041 /* Exit with out error to avoid sending again EmptyBufferDone in upper function*/ 5042 eError = OMX_ErrorNone; 5043 goto EXIT; 5044 } 5045 /*End Code to handle fragmentation of ConfigBuffer for AVC*/ 5046 } 5047 else if( pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 5048 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 5049 VIDDEC_ParseVideo_MPEG4( &nWidth, &nHeight, pBuffHead); 5050 /* Work around force reconfiguration */ 5051 bOutPortSettingsChanged = OMX_TRUE; 5052 } 5053 else if( pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 5054 VIDDEC_ParseVideo_MPEG2( &nWidth, &nHeight, pBuffHead); 5055 } 5056 else if( pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 5057 if (pComponentPrivate->nWMVFileType == VIDDEC_WMV_ELEMSTREAM) { 5058 eError = VIDDEC_ParseVideo_WMV9_VC1( &nWidth, &nHeight, pBuffHead); 5059 } 5060 else { 5061 eError = VIDDEC_ParseVideo_WMV9_RCV( &nWidth, &nHeight, pBuffHead); 5062 } 5063 } 5064 5065 nPadWidth = nWidth; 5066 nPadHeight = nHeight; 5067 if((nPadWidth%16) != 0){ 5068 nPadWidth += 16-(nPadWidth%16); 5069 } 5070 if((nPadHeight%16) != 0){ 5071 nPadHeight += 16-(nPadHeight%16); 5072 } 5073 5074 /*TODO: Test Croped MPEG4*/ 5075 5076 if(pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 5077 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263){ 5078 if(nPadWidth == 864){ 5079 nPadWidth = 854; 5080 } 5081 if(nPadHeight == 864){ 5082 nPadHeight = 864; 5083 } 5084 } 5085 5086 /*TODO: Get minimum INPUT buffer size & verify if the actual size is enough*/ 5087 /*Verify correct values in the initial setup*/ 5088 5089 /*Verify if actual width & height parameters are correct*/ 5090 if (pComponentPrivate->pInPortDef->format.video.nFrameWidth != nWidth || 5091 pComponentPrivate->pInPortDef->format.video.nFrameHeight != nHeight) { 5092 if((nWidth >= 1500) || (nHeight >= 1500)){ 5093 pComponentPrivate->pInPortDef->format.video.nFrameHeight = 576; 5094 pComponentPrivate->pInPortDef->format.video.nFrameWidth = 720; 5095 eError = OMX_ErrorBadParameter; 5096 goto EXIT; 5097 } 5098 else if(((nWidth < 16) || (nHeight < 16))){ 5099 pComponentPrivate->pInPortDef->format.video.nFrameHeight = 576; 5100 pComponentPrivate->pInPortDef->format.video.nFrameWidth = 720; 5101 eError = OMX_ErrorBadParameter; 5102 goto EXIT; 5103 } 5104 pComponentPrivate->pInPortDef->format.video.nFrameWidth = nPadWidth; 5105 pComponentPrivate->pInPortDef->format.video.nFrameHeight = nPadHeight; 5106 #ifdef ANDROID 5107 /*Force reload the component to configure create face args (SN)*/ 5108 bOutPortSettingsChanged = OMX_TRUE; 5109 OMX_PRINT1(pComponentPrivate->dbg, "Input port setting change, Force reload component !!!!!!\n"); 5110 #else 5111 /*OpenCORE doesn't support dynamic input port configuration*/ 5112 bInPortSettingsChanged = OMX_TRUE; 5113 #endif 5114 } 5115 5116 if(pComponentPrivate->pInPortDef->format.video.eCompressionFormat != OMX_VIDEO_CodingAVC && 5117 pComponentPrivate->pInPortDef->format.video.eCompressionFormat != OMX_VIDEO_CodingMPEG4 && 5118 pComponentPrivate->pInPortDef->format.video.eCompressionFormat != OMX_VIDEO_CodingH263){ 5119 if(pComponentPrivate->pOutPortDef->format.video.nFrameWidth != nWidth || 5120 pComponentPrivate->pOutPortDef->format.video.nFrameHeight != nHeight) { 5121 5122 pComponentPrivate->pOutPortDef->format.video.nFrameWidth = nPadWidth; 5123 pComponentPrivate->pOutPortDef->format.video.nFrameHeight = nPadHeight; 5124 bOutPortSettingsChanged = OMX_TRUE; 5125 OMX_PRINT1(pComponentPrivate->dbg, "Resolution: default new: %dx%d\n", nPadWidth, nPadHeight); 5126 } 5127 } 5128 else if(pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 5129 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263){ 5130 if(pComponentPrivate->pOutPortDef->format.video.nFrameWidth != nWidth || 5131 pComponentPrivate->pOutPortDef->format.video.nFrameHeight != nHeight) { 5132 5133 pComponentPrivate->pOutPortDef->format.video.nFrameWidth = nWidth; 5134 pComponentPrivate->pOutPortDef->format.video.nFrameHeight = nHeight; 5135 bOutPortSettingsChanged = OMX_TRUE; 5136 OMX_PRINT1(pComponentPrivate->dbg, "Resolution: new MPEG4: %dx%d\n", nWidth, nHeight); 5137 } 5138 } 5139 else{ /*OMX_VIDEO_CodingAVC*/ 5140 /* nCroppedWidth & nCroppedHeight indicate the resultant o/p resolution */ 5141 if((nWidth%16) != 0){ 5142 nWidth += 16-(nWidth%16); 5143 } 5144 if((nHeight%16) != 0){ 5145 nHeight += 16-(nHeight%16); 5146 } 5147 nCroppedWidth = nWidth - nCropWidth; 5148 nCroppedHeight = nHeight - nCropHeight; 5149 if(pComponentPrivate->pOutPortDef->format.video.nFrameWidth != nCroppedWidth || 5150 pComponentPrivate->pOutPortDef->format.video.nFrameHeight != nCroppedHeight) { 5151 5152 pComponentPrivate->pOutPortDef->format.video.nFrameWidth = nCroppedWidth; 5153 pComponentPrivate->pOutPortDef->format.video.nFrameHeight = nCroppedHeight; 5154 bOutPortSettingsChanged = OMX_TRUE; 5155 OMX_PRINT1(pComponentPrivate->dbg, "Resolution: AVC new: %dx%d \n", nCroppedWidth, nCroppedHeight); 5156 } 5157 } 5158 5159 /*Get minimum OUTPUT buffer size, 5160 * verify if the actual allocated size is the same as require by display driver*/ 5161 nOutMinBufferSize = pComponentPrivate->pOutPortDef->format.video.nFrameWidth * 5162 pComponentPrivate->pOutPortDef->format.video.nFrameHeight * 5163 ((pComponentPrivate->pOutPortFormat->eColorFormat == VIDDEC_COLORFORMAT420) ? VIDDEC_FACTORFORMAT420 : VIDDEC_FACTORFORMAT422); 5164 5165 if(nOutPortActualAllocLen != nOutMinBufferSize){ 5166 pComponentPrivate->pOutPortDef->nBufferSize = nOutMinBufferSize; 5167 bOutPortSettingsChanged = OMX_TRUE; 5168 OMX_PRINT1(pComponentPrivate->dbg, "NEW output BUFFSIZE:0x%x \n", nOutMinBufferSize); 5169 } 5170 5171 5172 OMX_PRINT1(pComponentPrivate->dbg, "pBuffHead %x, Resolution after parser: IN %dx%d : OUT %dx%d\n", 5173 (unsigned int)pBuffHead, 5174 (unsigned int)pComponentPrivate->pInPortDef->format.video.nFrameWidth, 5175 (unsigned int)pComponentPrivate->pInPortDef->format.video.nFrameHeight, 5176 (unsigned int)pComponentPrivate->pOutPortDef->format.video.nFrameWidth, 5177 (unsigned int)pComponentPrivate->pOutPortDef->format.video.nFrameHeight); 5178 5179 pComponentPrivate->bInPortSettingsChanged |= bInPortSettingsChanged; 5180 pComponentPrivate->bOutPortSettingsChanged |= bOutPortSettingsChanged; 5181 5182 if(bOutPortSettingsChanged || bInPortSettingsChanged){ 5183 OMX_PRINT1(pComponentPrivate->dbg, "bDynamicConfigurationInProgress = OMX_TRUE\n"); 5184 pComponentPrivate->bDynamicConfigurationInProgress = OMX_TRUE; 5185 5186 if(bOutPortSettingsChanged && bInPortSettingsChanged){ 5187 OMX_PRBUFFER2(pComponentPrivate->dbg, "sending OMX_EventPortSettingsChanged to both ports\n"); 5188 5189 5190 #ifdef ANDROID 5191 /*We must send first INPUT port callback*/ 5192 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sDynConfigMutex); 5193 #endif 5194 5195 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 5196 pComponentPrivate->pHandle->pApplicationPrivate, 5197 OMX_EventPortSettingsChanged, 5198 VIDDEC_INPUT_PORT, 5199 0, 5200 NULL); 5201 VIDDEC_WAIT_CODE(); 5202 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 5203 pComponentPrivate->pHandle->pApplicationPrivate, 5204 OMX_EventPortSettingsChanged, 5205 VIDDEC_OUTPUT_PORT, 5206 0, 5207 NULL); 5208 5209 #ifdef ANDROID 5210 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sDynConfigMutex); 5211 #endif 5212 eError = OMX_ErrorBadParameter; 5213 goto EXIT; 5214 } 5215 else { 5216 OMX_PRBUFFER2(pComponentPrivate->dbg, "sending OMX_EventPortSettingsChanged SINGLE port\n"); 5217 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 5218 pComponentPrivate->pHandle->pApplicationPrivate, 5219 OMX_EventPortSettingsChanged, 5220 bOutPortSettingsChanged ? VIDDEC_OUTPUT_PORT : VIDDEC_INPUT_PORT, 5221 0, 5222 NULL); 5223 eError = OMX_ErrorBadParameter; 5224 goto EXIT; 5225 } 5226 } 5227 else { 5228 eError = OMX_ErrorNone; 5229 } 5230 EXIT: 5231 if (pComponentPrivate) 5232 OMX_PRINT1(pComponentPrivate->dbg, "OUT\n"); 5233 return eError; 5234 } 5235 #endif 5236 5237 /* ========================================================================== */ 5238 /** 5239 * Handle Data Buff function from application 5240 **/ 5241 /* ========================================================================== */ 5242 5243 OMX_ERRORTYPE VIDDEC_HandleDataBuf_FromApp(VIDDEC_COMPONENT_PRIVATE *pComponentPrivate) 5244 { 5245 OMX_ERRORTYPE eError = OMX_ErrorNone; 5246 OMX_BUFFERHEADERTYPE* pBuffHead = NULL; 5247 VIDDEC_BUFFER_PRIVATE* pBufferPrivate = NULL; 5248 OMX_U32 inpBufSize; 5249 int ret = 0; 5250 OMX_U32 size_dsp; 5251 OMX_U8* pCSD = NULL; 5252 OMX_U8* pData = NULL; 5253 OMX_U32 nValue = 0; 5254 OMX_U32 nWidth = 0; 5255 OMX_U32 nHeight = 0; 5256 OMX_U32 nActualCompression = 0; 5257 OMX_U32 nSize_CSD = 0; 5258 5259 void* pUalgInpParams = NULL; 5260 LCML_DSP_INTERFACE* pLcmlHandle; 5261 OMX_PRBUFFER1(pComponentPrivate->dbg, "+++ENTERING\n"); 5262 OMX_PRBUFFER1(pComponentPrivate->dbg, "pComponentPrivate 0x%p iEndofInputSent 0x%x\n", pComponentPrivate, pComponentPrivate->iEndofInputSent); 5263 inpBufSize = pComponentPrivate->pInPortDef->nBufferSize; 5264 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 5265 ret = read(pComponentPrivate->filled_inpBuf_Q[0], &(pBuffHead), sizeof(pBuffHead)); 5266 if (ret == -1) { 5267 OMX_PRCOMM4(pComponentPrivate->dbg, "Error while reading from the pipe\n"); 5268 eError = OMX_ErrorHardware; 5269 goto EXIT; 5270 } 5271 eError = DecrementCount (&(pComponentPrivate->nCountInputBFromApp), &(pComponentPrivate->mutexInputBFromApp)); 5272 if (eError != OMX_ErrorNone) { 5273 return eError; 5274 } 5275 if( pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV && 5276 pComponentPrivate->ProcessMode == 0 && 5277 pBuffHead->nFilledLen != 0) { 5278 5279 if (pComponentPrivate->bFirstHeader == OMX_FALSE) { 5280 if (pBuffHead->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { 5281 #ifdef VIDDEC_HANDLE_FULL_STRM_PROP_OBJ 5282 pData = pBuffHead->pBuffer + 15; /*Position to Width & Height*/ 5283 5284 VIDDEC_LoadDWORD(nValue, pData); 5285 nWidth = nValue; 5286 VIDDEC_LoadDWORD(nValue, pData); 5287 nHeight = nValue; 5288 5289 if((nWidth != (OMX_U32)pComponentPrivate->pOutPortDef->format.video.nFrameWidth) || 5290 (nHeight != (OMX_U32)pComponentPrivate->pOutPortDef->format.video.nFrameHeight)){ 5291 pComponentPrivate->pOutPortDef->format.video.nFrameWidth = nWidth; 5292 pComponentPrivate->pOutPortDef->format.video.nFrameHeight = nHeight; 5293 pComponentPrivate->bOutPortSettingsChanged = OMX_TRUE; 5294 } 5295 5296 pData += 4; /*Position to compression type*/ 5297 VIDDEC_LoadDWORD(nValue, pData); 5298 nActualCompression = nValue; 5299 5300 /*If incorrect re-load SN with the proper nWMVFileType*/ 5301 OMX_PRINT2(pComponentPrivate->dbg, "Compressions: WMV1=%lu, WMV2=%lu, WMV3=%lu, WVC1=%lu. Actual=%lu\n", 5302 FOURCC_WMV1, FOURCC_WMV2, FOURCC_WMV3, FOURCC_WVC1, nActualCompression); 5303 if(pComponentPrivate->nWMVFileType == VIDDEC_WMV_RCVSTREAM && nActualCompression == FOURCC_WVC1){ 5304 pComponentPrivate->nWMVFileType = VIDDEC_WMV_ELEMSTREAM; 5305 } 5306 5307 eError = VIDDEC_Set_SN_StreamType(pComponentPrivate); 5308 if(eError != OMX_ErrorNone){ 5309 goto EXIT; 5310 } 5311 5312 /*Seting pCSD to proper position*/ 5313 pCSD = pBuffHead->pBuffer; 5314 pCSD += CSD_POSITION; 5315 nSize_CSD = pBuffHead->nFilledLen - CSD_POSITION; 5316 #else 5317 pCSD = pBuffHead->pBuffer; 5318 nSize_CSD = pBuffHead->nFilledLen; 5319 #endif 5320 } 5321 if (pComponentPrivate->nWMVFileType == VIDDEC_WMV_RCVSTREAM) { 5322 if(pComponentPrivate->pUalgParams == NULL) { 5323 OMX_U8* pTemp = NULL; 5324 OMX_MALLOC_STRUCT_SIZED(pComponentPrivate->pUalgParams, WMV9DEC_UALGInputParam, 5325 sizeof(WMV9DEC_UALGInputParam) + VIDDEC_PADDING_FULL, 5326 pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel1]); 5327 pTemp = (OMX_U8*)(pComponentPrivate->pUalgParams); 5328 pTemp += VIDDEC_PADDING_HALF; 5329 pComponentPrivate->pUalgParams = (OMX_PTR*)pTemp; 5330 } 5331 pBuffHead->nFlags &= ~(OMX_BUFFERFLAG_CODECCONFIG); 5332 if (pComponentPrivate->bIsNALBigEndian) { 5333 pComponentPrivate->pBufferRCV.sStructRCV.nStructData = (OMX_U32)pCSD[0] << 24 | 5334 pCSD[1] << 16 | 5335 pCSD[2] << 8 | 5336 pCSD[3]; 5337 } 5338 else { 5339 pComponentPrivate->pBufferRCV.sStructRCV.nStructData = (OMX_U32)pCSD[0] << 0 | 5340 pCSD[1] << 8 | 5341 pCSD[2] << 16 | 5342 pCSD[3] << 24; 5343 } 5344 size_dsp = sizeof(WMV9DEC_UALGInputParam); 5345 ((WMV9DEC_UALGInputParam*)pComponentPrivate->pUalgParams)->lBuffCount = ++pComponentPrivate->frameCounter; 5346 pUalgInpParams = pComponentPrivate->pUalgParams; 5347 /* Only WMV need to send EMMCodecInputBufferMapBufLen buffers */ 5348 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*) 5349 pLcmlHandle)->pCodecinterfacehandle, 5350 EMMCodecInputBufferMapBufLen, 5351 (OMX_U8*)&pComponentPrivate->pBufferRCV.pBuffer, 5352 sizeof(VIDDEC_WMV_RCV_struct), 5353 sizeof(VIDDEC_WMV_RCV_struct), 5354 (OMX_U8 *)pUalgInpParams, 5355 size_dsp, 5356 (OMX_U8*)&pComponentPrivate->pBufferTemp); 5357 OMX_PRBUFFER1(pComponentPrivate->dbg, "Returning First Input Buffer to test application\n"); 5358 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 5359 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 5360 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 5361 #ifdef __PERF_INSTRUMENTATION__ 5362 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 5363 pBuffHead->pBuffer, 5364 pBuffHead->nFilledLen, 5365 PERF_ModuleHLMM); 5366 #endif 5367 VIDDEC_EmptyBufferDone(pComponentPrivate, pBuffHead); 5368 pComponentPrivate->bFirstHeader = OMX_TRUE; 5369 goto EXIT; 5370 } 5371 else { /* VC1 Advance profile */ 5372 #ifdef VIDDEC_WMVPOINTERFIXED 5373 if (pComponentPrivate->pCodecData == NULL || 5374 !(pBuffHead->pBuffer[0] == 0 && 5375 pBuffHead->pBuffer[1] == 0 && 5376 pBuffHead->pBuffer[2] == 1)) { 5377 #else 5378 if (pBuffHead->nOffset != 0) { 5379 #endif 5380 if (pBuffHead->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { 5381 pBuffHead->nFlags &= ~(OMX_BUFFERFLAG_CODECCONFIG); 5382 if (pComponentPrivate->pCodecData != NULL) { 5383 free(pComponentPrivate->pCodecData); 5384 pComponentPrivate->pCodecData = NULL; 5385 } 5386 /* Save Codec Specific Data */ 5387 pComponentPrivate->pCodecData = malloc (pBuffHead->nFilledLen); 5388 #ifdef VIDDEC_WMVPOINTERFIXED 5389 memcpy (pComponentPrivate->pCodecData, pBuffHead->pBuffer, pBuffHead->nFilledLen); 5390 #else 5391 memcpy (pComponentPrivate->pCodecData, pBuffHead->pBuffer + pBuffHead->nOffset, pBuffHead->nFilledLen); 5392 #endif 5393 pComponentPrivate->nCodecDataSize = pBuffHead->nFilledLen; 5394 if(pComponentPrivate->nCodecDataSize > VIDDEC_WMV_BUFFER_OFFSET){ 5395 OMX_ERROR4(pComponentPrivate->dbg, "Insufficient space in buffer pbuffer %p - nCodecDataSize %u\n", 5396 (void *)pBuffHead->pBuffer,pComponentPrivate->nCodecDataSize); 5397 eError = OMX_ErrorStreamCorrupt; 5398 goto EXIT; 5399 } 5400 #ifdef VIDDEC_ACTIVATEPARSER 5401 eError = VIDDEC_ParseHeader( pComponentPrivate, pBuffHead); 5402 #endif 5403 OMX_PRBUFFER1(pComponentPrivate->dbg, "Returning First Input Buffer to test application %x\n",eError); 5404 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 5405 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 5406 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 5407 #ifdef __PERF_INSTRUMENTATION__ 5408 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 5409 pBuffHead->pBuffer, 5410 pBuffHead->nFilledLen, 5411 PERF_ModuleHLMM); 5412 #endif 5413 #ifdef VIDDEC_WMVPOINTERFIXED 5414 OMX_PRBUFFER1(pComponentPrivate->dbg, "restoring buffer pointer 0x%p >> pBuffer 0x%p\n", 5415 pBufferPrivate->pTempBuffer, pBuffHead->pBuffer); 5416 pBuffHead->pBuffer = pBufferPrivate->pTempBuffer; 5417 #else 5418 pBuffHead->nOffset = VIDDEC_WMV_BUFFER_OFFSET; 5419 #endif 5420 VIDDEC_EmptyBufferDone(pComponentPrivate, pBuffHead); 5421 return OMX_ErrorNone; 5422 } 5423 else { 5424 /* VC-1: First data buffer received, add configuration data to it*/ 5425 pComponentPrivate->bFirstHeader = OMX_TRUE; 5426 OMX_WMV_INSERT_CODEC_DATA(pBuffHead, pComponentPrivate); 5427 eError = OMX_ErrorNone; 5428 } 5429 } 5430 else { 5431 /*if no config flag is set just parse buffer and set flag first buffer*/ 5432 /*this is ejecuted by the first buffer regular buffer*/ 5433 if (pComponentPrivate->bFirstHeader == OMX_FALSE) { 5434 pComponentPrivate->bFirstHeader = OMX_TRUE; 5435 eError = VIDDEC_ParseHeader(pComponentPrivate, pBuffHead); 5436 if(eError != OMX_ErrorNone) { 5437 OMX_PRBUFFER1(pComponentPrivate->dbg, "Returning First Input Buffer to test application\n"); 5438 pComponentPrivate->bFirstHeader = OMX_TRUE; 5439 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 5440 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 5441 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 5442 #ifdef __PERF_INSTRUMENTATION__ 5443 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 5444 pBuffHead->pBuffer, 5445 pBuffHead->nFilledLen, 5446 PERF_ModuleHLMM); 5447 #endif 5448 #ifdef VIDDEC_WMVPOINTERFIXED 5449 OMX_PRBUFFER1(pComponentPrivate->dbg, "restoring buffer pointer 0x%p >> pBuffer 0x%p\n", 5450 pBufferPrivate->pTempBuffer, pBuffHead->pBuffer); 5451 pBuffHead->pBuffer = pBufferPrivate->pTempBuffer; 5452 #else 5453 pBuffHead->nOffset = VIDDEC_WMV_BUFFER_OFFSET; 5454 #endif 5455 VIDDEC_EmptyBufferDone(pComponentPrivate, pBuffHead); 5456 eError = OMX_ErrorNone; 5457 goto EXIT; 5458 } 5459 else { 5460 eError = OMX_ErrorNone; 5461 } 5462 } 5463 } 5464 } 5465 }/*codec data is stored one time and repeated for each Config buffer*/ 5466 else if (pComponentPrivate->nWMVFileType == VIDDEC_WMV_ELEMSTREAM) { 5467 #ifdef VIDDEC_WMVPOINTERFIXED 5468 if (!(pBuffHead->pBuffer[0] == 0 && 5469 pBuffHead->pBuffer[1] == 0 && 5470 pBuffHead->pBuffer[2] == 1)) { 5471 #else 5472 if (pBuffHead->nOffset != 0) { 5473 #endif 5474 OMX_S32 nDifference = 0; 5475 OMX_U8* pTempBuffer = NULL; 5476 #ifdef VIDDEC_WMVPOINTERFIXED 5477 pTempBuffer = pBuffHead->pBuffer; 5478 #else 5479 pTempBuffer = pBuffHead->pBuffer + pBuffHead->nOffset; 5480 #endif 5481 #ifdef VIDDEC_WMVPOINTERFIXED 5482 nDifference = pBuffHead->pBuffer - pTempBuffer; 5483 #else 5484 nDifference = pTempBuffer - pBuffHead->pBuffer; 5485 #endif 5486 if (nDifference < 0) { 5487 OMX_ERROR4(pComponentPrivate->dbg, "Insufficient space in buffer pbuffer %p - nOffset %lx\n", 5488 pBuffHead->pBuffer, pBuffHead->nOffset); 5489 eError = OMX_ErrorStreamCorrupt; 5490 goto EXIT; 5491 } 5492 (*(--pTempBuffer)) = 0x0d; 5493 (*(--pTempBuffer)) = 0x01; 5494 (*(--pTempBuffer)) = 0x00; 5495 (*(--pTempBuffer)) = 0x00; 5496 pBuffHead->nFilledLen += 4; 5497 #ifdef VIDDEC_WMVPOINTERFIXED 5498 pBuffHead->pBuffer = pTempBuffer; 5499 pBuffHead->nOffset = 0; 5500 #else 5501 pBuffHead->nOffset = pTempBuffer - pBuffHead->pBuffer; 5502 #endif 5503 OMX_PRBUFFER1(pComponentPrivate->dbg, "pTempBuffer %p - pBuffHead->pBuffer %p - pBuffHead->nOffset %lx\n", 5504 pTempBuffer,pBuffHead->pBuffer,pBuffHead->nOffset); 5505 eError = OMX_ErrorNone; 5506 } 5507 else { 5508 OMX_PRBUFFER1(pComponentPrivate->dbg, "incorrect path %lu\n",pBuffHead->nOffset); 5509 /*if no config flag is set just parse buffer and set flag first buffer*/ 5510 /*this is ejecuted by the first buffer regular buffer*/ 5511 if (pComponentPrivate->bFirstHeader == OMX_FALSE) { 5512 pComponentPrivate->bFirstHeader = OMX_TRUE; 5513 eError = VIDDEC_ParseHeader(pComponentPrivate, pBuffHead); 5514 if(eError != OMX_ErrorNone) { 5515 OMX_PRBUFFER1(pComponentPrivate->dbg, "Returning First Input Buffer to test application\n"); 5516 pComponentPrivate->bFirstHeader = OMX_TRUE; 5517 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 5518 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 5519 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 5520 #ifdef __PERF_INSTRUMENTATION__ 5521 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 5522 pBuffHead->pBuffer, 5523 pBuffHead->nFilledLen, 5524 PERF_ModuleHLMM); 5525 #endif 5526 #ifdef VIDDEC_WMVPOINTERFIXED 5527 OMX_PRBUFFER1(pComponentPrivate->dbg, "restoring buffer pointer 0x%p >> pBuffer 0x%p\n", 5528 pBufferPrivate->pTempBuffer, pBuffHead->pBuffer); 5529 pBuffHead->pBuffer = pBufferPrivate->pTempBuffer; 5530 #else 5531 pBuffHead->nOffset = VIDDEC_WMV_BUFFER_OFFSET; 5532 #endif 5533 VIDDEC_EmptyBufferDone(pComponentPrivate, pBuffHead); 5534 eError = OMX_ErrorNone; 5535 goto EXIT; 5536 } 5537 else { 5538 eError = OMX_ErrorNone; 5539 } 5540 } 5541 } 5542 } 5543 } 5544 #ifdef VIDDEC_ACTIVATEPARSER 5545 if((((pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) || 5546 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 5547 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2 || 5548 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) || 5549 (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV && 5550 pComponentPrivate->ProcessMode == 1)) && 5551 pComponentPrivate->bParserEnabled && 5552 pComponentPrivate->bFirstHeader == OMX_FALSE) { 5553 pComponentPrivate->bFirstHeader = OMX_TRUE; 5554 /* If VIDDEC_ParseHeader() does not return OMX_ErrorNone, then 5555 * reconfiguration is required. 5556 * eError is set to OMX_ErrorNone after saving the buffer, which will 5557 * be used later by the reconfiguration logic. 5558 */ 5559 eError = VIDDEC_ParseHeader( pComponentPrivate, pBuffHead); 5560 5561 /* The MPEG4 & H.263 algorithm expects both the configuration buffer 5562 * and the first data buffer to be in the same frame - this logic only 5563 * applies when in frame mode and when the framework sends the config data 5564 * separately. The same situation is handled elsewhere for H.264 & WMV 5565 * decoding. 5566 */ 5567 if(eError != OMX_ErrorNone || 5568 ((pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 5569 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) && 5570 pComponentPrivate->ProcessMode == 0)) { 5571 if (pBuffHead != NULL) { 5572 5573 #ifdef ANDROID 5574 OMX_PRINT1(pComponentPrivate->dbg,"save 1st ccd buffer - pBuffhead->nFilledLen = %d\n", pBuffHead->nFilledLen); 5575 eError = VIDDEC_SaveBuffer(pComponentPrivate, pBuffHead); 5576 if(eError != OMX_ErrorNone){ 5577 goto EXIT; 5578 } 5579 /* only if NAL-bitstream format in frame mode */ 5580 if (pComponentPrivate->ProcessMode == 0 && pComponentPrivate->H264BitStreamFormat > 0) { 5581 pComponentPrivate->aCCDsize[pComponentPrivate->nCCDcnt++] = pBuffHead->nFilledLen; 5582 } 5583 #endif 5584 5585 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 5586 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 5587 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 5588 #ifdef __PERF_INSTRUMENTATION__ 5589 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 5590 pBuffHead->pBuffer, 5591 pBuffHead->nFilledLen, 5592 PERF_ModuleHLMM); 5593 #endif 5594 5595 VIDDEC_EmptyBufferDone(pComponentPrivate, pBuffHead); 5596 } 5597 eError = OMX_ErrorNone; 5598 goto EXIT; 5599 } 5600 else { 5601 /* We have received only one part of the Config Buffer, we need to wait for more buffers. ONLY FOR AVC*/ 5602 if(pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC && 5603 pComponentPrivate->bConfigBufferCompleteAVC == FALSE){ 5604 /* Set bFirstHeader flag to false so next buffer enters to ParseHeade again*/ 5605 pComponentPrivate->bFirstHeader = OMX_FALSE; 5606 OMX_PRINT1(pComponentPrivate->dbg, "AVC: bConfigBufferCompleateAVC == FALSE!"); 5607 goto EXIT; 5608 } 5609 eError = OMX_ErrorNone; 5610 } 5611 } 5612 #endif 5613 5614 5615 if (pComponentPrivate->nInCmdMarkBufIndex != pComponentPrivate->nOutCmdMarkBufIndex) { 5616 pComponentPrivate->arrMarkBufIndex[pComponentPrivate->nInMarkBufIndex].hMarkTargetComponent = pComponentPrivate->arrCmdMarkBufIndex[pComponentPrivate->nOutCmdMarkBufIndex].hMarkTargetComponent; 5617 pComponentPrivate->arrMarkBufIndex[pComponentPrivate->nInMarkBufIndex].pMarkData = pComponentPrivate->arrCmdMarkBufIndex[pComponentPrivate->nOutCmdMarkBufIndex].pMarkData; 5618 pComponentPrivate->nOutCmdMarkBufIndex++; 5619 pComponentPrivate->nOutCmdMarkBufIndex %= VIDDEC_MAX_QUEUE_SIZE; 5620 pComponentPrivate->nInMarkBufIndex++; 5621 pComponentPrivate->nInMarkBufIndex %= VIDDEC_MAX_QUEUE_SIZE; 5622 } 5623 else { 5624 pComponentPrivate->arrMarkBufIndex[pComponentPrivate->nInMarkBufIndex].hMarkTargetComponent = pBuffHead->hMarkTargetComponent; 5625 pComponentPrivate->arrMarkBufIndex[pComponentPrivate->nInMarkBufIndex].pMarkData = pBuffHead->pMarkData; 5626 pComponentPrivate->nInMarkBufIndex++; 5627 pComponentPrivate->nInMarkBufIndex %= VIDDEC_MAX_QUEUE_SIZE; 5628 } 5629 5630 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead 0x%p eExecuteToIdle 0x%x\n", pBuffHead,pComponentPrivate->eExecuteToIdle); 5631 OMX_PRBUFFER1(pComponentPrivate->dbg, "nFilledLen 0x%lx nFlags 0x%lx\n", pBuffHead->nFilledLen,pBuffHead->nFlags); 5632 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 5633 5634 if(pBuffHead->nFlags & OMX_BUFFERFLAG_EOS){ 5635 OMX_PRBUFFER2(pComponentPrivate->dbg, "End of Input EOS, nFlags=0x%x nFilledLen 0x%lx\n", pBuffHead->nFlags, pBuffHead->nFilledLen); 5636 if(pBuffHead->nFilledLen != 0) { /*TODO: Validate this lagic*/ 5637 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 5638 pUalgInpParams = (OMX_PTR)pBufferPrivate->pUalgParam; 5639 if ((pBuffHead->nFlags & OMX_BUFFERFLAG_EOS) == 0) { 5640 ((H264VDEC_UALGInputParam *)pUalgInpParams)->lBuffCount = ++pComponentPrivate->frameCounter; 5641 5642 /* prepare buffer and input parameter if H264BitStreamFormat = 1 */ 5643 /* the orignial buffer is: NAL1_Len NAL1 NAL2_Len NAL2...*/ 5644 /* we need to pack the data buffer as: NAL1 NAL2 NAL3..*/ 5645 /* and put the length info to the parameter array*/ 5646 if (pComponentPrivate->H264BitStreamFormat) { 5647 OMX_U32 nal_len, i; 5648 OMX_U8 *pDataBuf; 5649 OMX_U32 length_pos = 0; 5650 OMX_U32 data_pos = 0; 5651 OMX_U32 buf_len; 5652 H264VDEC_UALGInputParam *pParam; 5653 5654 buf_len = pBuffHead->nFilledLen; 5655 pDataBuf = pBuffHead->pBuffer; 5656 pParam = (H264VDEC_UALGInputParam *)pUalgInpParams; 5657 pParam->ulNumOfNALU = 0; 5658 while (pBuffHead->nFilledLen > length_pos+pComponentPrivate->H264BitStreamFormat) { 5659 if (pComponentPrivate->H264BitStreamFormat == 1) 5660 if (pComponentPrivate->bIsNALBigEndian) { 5661 nal_len = (OMX_U32)pDataBuf[length_pos]; 5662 } 5663 else { 5664 nal_len = (OMX_U32)pDataBuf[length_pos]; 5665 } 5666 else if (pComponentPrivate->H264BitStreamFormat == 2) 5667 if (pComponentPrivate->bIsNALBigEndian) { 5668 nal_len = (OMX_U32)pDataBuf[length_pos] << 8 | pDataBuf[length_pos+1]; 5669 } 5670 else { 5671 nal_len = (OMX_U32)pDataBuf[length_pos] << 0 | pDataBuf[length_pos+1] << 8 ; 5672 } 5673 else if (pComponentPrivate->H264BitStreamFormat == 4){ 5674 if (pComponentPrivate->bIsNALBigEndian) { 5675 nal_len = (OMX_U32)pDataBuf[length_pos]<<24 | pDataBuf[length_pos+1] << 16 | pDataBuf[length_pos+2] << 8 | pDataBuf[length_pos+3]; 5676 } 5677 else { 5678 nal_len = (OMX_U32)pDataBuf[length_pos]<<0 | pDataBuf[length_pos+1] << 8 | pDataBuf[length_pos+2] << 16 | pDataBuf[length_pos+3]<<24; 5679 } 5680 } 5681 else { 5682 eError = OMX_ErrorBadParameter; 5683 goto EXIT; 5684 } 5685 length_pos += pComponentPrivate->H264BitStreamFormat; 5686 if (nal_len > buf_len - length_pos) { 5687 eError = OMX_ErrorBadParameter; 5688 goto EXIT; 5689 } 5690 /* move the memory*/ 5691 for (i=0; i<nal_len; i++) 5692 pDataBuf[data_pos+i] = pDataBuf[length_pos+i]; 5693 data_pos += nal_len; 5694 length_pos += nal_len; 5695 /* save the size*/ 5696 pParam->pNALUSizeArray[pParam->ulNumOfNALU++] = nal_len; 5697 } 5698 /* update with the new data size*/ 5699 pBuffHead->nFilledLen = data_pos; 5700 } 5701 } 5702 size_dsp = sizeof(H264VDEC_UALGInputParam); 5703 } 5704 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 5705 pUalgInpParams = (OMX_PTR)pBufferPrivate->pUalgParam; 5706 if ((pBuffHead->nFlags & OMX_BUFFERFLAG_EOS) == 0) { 5707 ((WMV9DEC_UALGInputParam*)pUalgInpParams)->lBuffCount = ++pComponentPrivate->frameCounter; 5708 } 5709 size_dsp = sizeof(WMV9DEC_UALGInputParam); 5710 } 5711 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 5712 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 5713 pUalgInpParams = (OMX_PTR)pBufferPrivate->pUalgParam; 5714 if ((pBuffHead->nFlags & OMX_BUFFERFLAG_EOS) == 0) { 5715 ((MP4VD_GPP_SN_UALGInputParams*)pUalgInpParams)->nBuffCount = ++pComponentPrivate->frameCounter; 5716 ((MP4VD_GPP_SN_UALGInputParams*)pUalgInpParams)->uRingIOBlocksize = 0; 5717 ((MP4VD_GPP_SN_UALGInputParams*)pUalgInpParams)->nPerformMode = 2; 5718 } 5719 size_dsp = sizeof(MP4VD_GPP_SN_UALGInputParams); 5720 } 5721 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 5722 pUalgInpParams = (OMX_PTR)pBufferPrivate->pUalgParam; 5723 if ((pBuffHead->nFlags & OMX_BUFFERFLAG_EOS) == 0) { 5724 ((MP2VDEC_UALGInputParam*)pUalgInpParams)->lBuffCount = ++pComponentPrivate->frameCounter; 5725 } 5726 size_dsp = sizeof(MP2VDEC_UALGInputParam); 5727 } 5728 #ifdef VIDDEC_SPARK_CODE 5729 else if (VIDDEC_SPARKCHECK) { 5730 pUalgInpParams = (OMX_PTR)pBufferPrivate->pUalgParam; 5731 if ((pBuffHead->nFlags & OMX_BUFFERFLAG_EOS) == 0) { 5732 ((SPARKVD_GPP_SN_UALGInputParams*)pUalgInpParams)->lBuffCount = ++pComponentPrivate->frameCounter; 5733 } 5734 ((SPARKVD_GPP_SN_UALGInputParams*)pUalgInpParams)->nIsSparkInput = 1; 5735 size_dsp = sizeof(SPARKVD_GPP_SN_UALGInputParams); 5736 } 5737 #endif 5738 else { 5739 eError = OMX_ErrorUnsupportedSetting; 5740 OMX_PRBUFFER4(pComponentPrivate->dbg, "VIDDEC_HandleDataBuf_FromApp 0x%x\n", eError); 5741 goto EXIT; 5742 } 5743 5744 if (pComponentPrivate->ProcessMode == 0) { 5745 OMX_U8 ucIndex = 0; 5746 OMX_PTR pBufferFlags = NULL; 5747 ucIndex = VIDDEC_CircBuf_GetHead(pComponentPrivate, 5748 VIDDEC_CBUFFER_TIMESTAMP, 5749 VIDDEC_INPUT_PORT); 5750 pComponentPrivate->aBufferFlags[ucIndex].nTimeStamp = pBuffHead->nTimeStamp; 5751 pComponentPrivate->aBufferFlags[ucIndex].nTickCount = pBuffHead->nTickCount; 5752 pBuffHead->nFlags &= ~OMX_BUFFERFLAG_EOS; 5753 pComponentPrivate->aBufferFlags[ucIndex].nFlags = pBuffHead->nFlags; 5754 pBufferFlags = &pComponentPrivate->aBufferFlags[ucIndex]; 5755 VIDDEC_CircBuf_Add(pComponentPrivate, 5756 VIDDEC_CBUFFER_TIMESTAMP, 5757 VIDDEC_INPUT_PORT, 5758 pBufferFlags); 5759 } 5760 else { 5761 pComponentPrivate->arrBufIndex[pComponentPrivate->nInBufIndex] = pBuffHead->nTimeStamp; 5762 pComponentPrivate->nInBufIndex++; 5763 pComponentPrivate->nInBufIndex %= VIDDEC_MAX_QUEUE_SIZE; 5764 } 5765 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead->nTimeStamp %lld\n", pBuffHead->nTimeStamp); 5766 5767 #ifdef __PERF_INSTRUMENTATION__ 5768 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 5769 pBuffHead->pBuffer, 5770 pBuffHead->nFilledLen, 5771 PERF_ModuleCommonLayer); 5772 #endif 5773 5774 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 5775 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 5776 pComponentPrivate->pLCML != NULL){ 5777 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_DSP; 5778 pBuffHead->nFlags = 0; 5779 5780 #ifdef __PERF_INSTRUMENTATION__ 5781 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 5782 pBuffHead->pBuffer, 5783 pBuffHead->nFilledLen, 5784 PERF_ModuleHLMM); 5785 #endif 5786 5787 if(pComponentPrivate->bDynamicConfigurationInProgress){ 5788 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 5789 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 5790 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 5791 5792 OMX_PRBUFFER2(pComponentPrivate->dbg, "Sending buffer back to client pBuffer=%p\n", pBuffHead->pBuffer); 5793 VIDDEC_EmptyBufferDone(pComponentPrivate, pBuffHead); 5794 goto EXIT; 5795 } 5796 5797 OMX_PRDSP1(pComponentPrivate->dbg, "Sending EOS Filled eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 5798 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_QueueBuffer(INPUT)\n"); 5799 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*) 5800 pLcmlHandle)->pCodecinterfacehandle, 5801 ((pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) ? EMMCodecInputBufferMapBufLen : EMMCodecInputBuffer), 5802 &pBuffHead->pBuffer[pBuffHead->nOffset],/*WMV_VC1_CHANGES*/ 5803 pBuffHead->nAllocLen, 5804 pBuffHead->nFilledLen, 5805 (OMX_U8 *)pUalgInpParams, 5806 size_dsp, 5807 (OMX_U8 *)pBuffHead); 5808 if (eError != OMX_ErrorNone){ 5809 OMX_PRDSP4(pComponentPrivate->dbg, "LCML_QueueBuffer(INPUT):OMX_BUFFERFLAG_EOS, Error 0x%x\n", eError); 5810 eError = OMX_ErrorHardware; 5811 goto EXIT; 5812 } 5813 } 5814 else { 5815 eError = OMX_ErrorHardware; 5816 goto EXIT; 5817 } 5818 } 5819 else { 5820 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_COMPONENT; 5821 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 5822 eError = IncrementCount (&(pComponentPrivate->nCountInputBFromDsp), &(pComponentPrivate->mutexInputBFromDSP)); 5823 if (eError != OMX_ErrorNone) { 5824 return eError; 5825 } 5826 ret = write(pComponentPrivate->free_inpBuf_Q[1], &pBuffHead, sizeof(pBuffHead)); 5827 if(ret == -1){ 5828 OMX_PRCOMM4(pComponentPrivate->dbg, "writing to the input pipe %x (%d)\n", OMX_ErrorInsufficientResources,ret); 5829 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_DSP; 5830 DecrementCount (&(pComponentPrivate->nCountInputBFromDsp), &(pComponentPrivate->mutexInputBFromDSP)); 5831 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 5832 pComponentPrivate->pHandle->pApplicationPrivate, 5833 OMX_EventError, 5834 OMX_ErrorInsufficientResources, 5835 OMX_TI_ErrorSevere, 5836 "Error writing to the output pipe"); 5837 } 5838 } 5839 5840 if(pComponentPrivate->iEndofInputSent == 0){ 5841 //pComponentPrivate->iEndofInputSent = 1; 5842 OMX_PRBUFFER1(pComponentPrivate->dbg, "Sending EOS Empty eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 5843 if(pComponentPrivate->eFirstBuffer.bSaveFirstBuffer == OMX_FALSE){ 5844 OMX_MEMFREE_STRUCT_DSPALIGN(pComponentPrivate->pUalgParams,OMX_PTR); 5845 } 5846 5847 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 5848 if(pComponentPrivate->pUalgParams == NULL){ 5849 OMX_U8* pTemp = NULL; 5850 OMX_MALLOC_STRUCT_SIZED(pComponentPrivate->pUalgParams, 5851 H264VDEC_UALGInputParam, 5852 sizeof(H264VDEC_UALGInputParam) + VIDDEC_PADDING_FULL, 5853 pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel1]); 5854 pTemp = (OMX_U8*)(pComponentPrivate->pUalgParams); 5855 pTemp += VIDDEC_PADDING_HALF; 5856 pComponentPrivate->pUalgParams = (OMX_PTR*)pTemp; 5857 } 5858 size_dsp = sizeof(H264VDEC_UALGInputParam); 5859 ((H264VDEC_UALGInputParam *)pComponentPrivate->pUalgParams)->lBuffCount = -1; 5860 OMX_PRBUFFER1(pComponentPrivate->dbg, "lBuffCount 0x%lx\n", 5861 ((H264VDEC_UALGInputParam *)pComponentPrivate->pUalgParams)->lBuffCount); 5862 } 5863 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 5864 if(pComponentPrivate->pUalgParams == NULL){ 5865 OMX_U8* pTemp = NULL; 5866 OMX_MALLOC_STRUCT_SIZED(pComponentPrivate->pUalgParams, 5867 WMV9DEC_UALGInputParam, 5868 sizeof(WMV9DEC_UALGInputParam) + VIDDEC_PADDING_FULL, 5869 pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel1]); 5870 pTemp = (OMX_U8*)(pComponentPrivate->pUalgParams); 5871 pTemp += VIDDEC_PADDING_HALF; 5872 pComponentPrivate->pUalgParams = (OMX_PTR*)pTemp; 5873 } 5874 size_dsp = sizeof(WMV9DEC_UALGInputParam); 5875 ((WMV9DEC_UALGInputParam*)pComponentPrivate->pUalgParams)->lBuffCount = -1; 5876 OMX_PRBUFFER1(pComponentPrivate->dbg, "lBuffCount 0x%lx\n", 5877 ((WMV9DEC_UALGInputParam*)pComponentPrivate->pUalgParams)->lBuffCount); 5878 } 5879 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 5880 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 5881 if(pComponentPrivate->pUalgParams == NULL){ 5882 OMX_U8* pTemp = NULL; 5883 OMX_MALLOC_STRUCT_SIZED(pComponentPrivate->pUalgParams, 5884 MP4VD_GPP_SN_UALGInputParams, 5885 sizeof(MP4VD_GPP_SN_UALGInputParams) + VIDDEC_PADDING_FULL, 5886 pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel1]); 5887 pTemp = (OMX_U8*)(pComponentPrivate->pUalgParams); 5888 pTemp += VIDDEC_PADDING_HALF; 5889 pComponentPrivate->pUalgParams = (OMX_PTR*)pTemp; 5890 } 5891 size_dsp = sizeof(MP4VD_GPP_SN_UALGInputParams); 5892 ((MP4VD_GPP_SN_UALGInputParams*)pComponentPrivate->pUalgParams)->nBuffCount = -1; 5893 ((MP4VD_GPP_SN_UALGInputParams*)pComponentPrivate->pUalgParams)->uRingIOBlocksize = 0; 5894 /* If EOS is sent, set nPerformMode to 0 (this handle thumbnail case)*/ 5895 ((MP4VD_GPP_SN_UALGInputParams*)pComponentPrivate->pUalgParams)->nPerformMode = 0; 5896 OMX_PRBUFFER1(pComponentPrivate->dbg, "lBuffCount 0x%lx\n", 5897 ((MP4VD_GPP_SN_UALGInputParams*)pComponentPrivate->pUalgParams)->nBuffCount); 5898 } 5899 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 5900 if(pComponentPrivate->pUalgParams == NULL){ 5901 OMX_U8* pTemp = NULL; 5902 OMX_MALLOC_STRUCT_SIZED(pComponentPrivate->pUalgParams, 5903 MP2VDEC_UALGInputParam, 5904 sizeof(MP2VDEC_UALGInputParam) + VIDDEC_PADDING_FULL, 5905 pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel1]); 5906 pTemp = (OMX_U8*)(pComponentPrivate->pUalgParams); 5907 pTemp += VIDDEC_PADDING_HALF; 5908 pComponentPrivate->pUalgParams = (OMX_PTR*)pTemp; 5909 } 5910 size_dsp = sizeof(MP2VDEC_UALGInputParam); 5911 ((MP2VDEC_UALGInputParam*)pComponentPrivate->pUalgParams)->lBuffCount = -1; 5912 OMX_PRBUFFER1(pComponentPrivate->dbg, "lBuffCount 0x%lx\n", 5913 ((MP2VDEC_UALGInputParam*)pComponentPrivate->pUalgParams)->lBuffCount); 5914 } 5915 #ifdef VIDDEC_SPARK_CODE 5916 else if (VIDDEC_SPARKCHECK) { 5917 if(pComponentPrivate->pUalgParams == NULL){ 5918 OMX_U8* pTemp = NULL; 5919 OMX_MALLOC_STRUCT_SIZED(pComponentPrivate->pUalgParams, 5920 SPARKVD_GPP_SN_UALGInputParams, 5921 sizeof(SPARKVD_GPP_SN_UALGInputParams) + VIDDEC_PADDING_FULL, 5922 pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel1]); 5923 pTemp = (OMX_U8*)(pComponentPrivate->pUalgParams); 5924 pTemp += VIDDEC_PADDING_HALF; 5925 pComponentPrivate->pUalgParams = (OMX_PTR*)pTemp; 5926 } 5927 size_dsp = sizeof(SPARKVD_GPP_SN_UALGInputParams); 5928 ((SPARKVD_GPP_SN_UALGInputParams*)pComponentPrivate->pUalgParams)->lBuffCount = -1; 5929 ((SPARKVD_GPP_SN_UALGInputParams*)pComponentPrivate->pUalgParams)->nIsSparkInput = 1; 5930 OMX_PRBUFFER1(pComponentPrivate->dbg, "lBuffCount 0x%lx\n", 5931 ((SPARKVD_GPP_SN_UALGInputParams*)pComponentPrivate->pUalgParams)->lBuffCount); 5932 } 5933 #endif 5934 else { 5935 eError = OMX_ErrorUnsupportedSetting; 5936 goto EXIT; 5937 } 5938 5939 #ifdef __PERF_INSTRUMENTATION__ 5940 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 5941 NULL, 0, 5942 PERF_ModuleCommonLayer); 5943 #endif 5944 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 5945 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 5946 pComponentPrivate->pLCML != NULL){ 5947 pComponentPrivate->pTempBuffHead.nFlags = 0; 5948 //pComponentPrivate->pTempBuffHead.nFlags |= OMX_BUFFERFLAG_EOS; 5949 pComponentPrivate->pTempBuffHead.nFilledLen = 0; 5950 pComponentPrivate->pTempBuffHead.pBuffer = NULL; 5951 5952 #ifdef __PERF_INSTRUMENTATION__ 5953 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 5954 pBuffHead->pBuffer, 5955 pBuffHead->nFilledLen, 5956 PERF_ModuleHLMM); 5957 #endif 5958 5959 if(pComponentPrivate->bDynamicConfigurationInProgress){ 5960 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 5961 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 5962 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 5963 OMX_PRBUFFER2(pComponentPrivate->dbg, "Sending buffer back to client pBuffer=%p\n", pBuffHead->pBuffer); 5964 VIDDEC_EmptyBufferDone(pComponentPrivate, pBuffHead); 5965 goto EXIT; 5966 } 5967 5968 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_QueueBuffer(INPUT)\n"); 5969 5970 /* Verify if first buffer as been stored. 5971 * Handle case were only one frame is decoded */ 5972 if(pComponentPrivate->eFirstBuffer.bSaveFirstBuffer){ 5973 if (pBuffHead->nFlags & OMX_BUFFERFLAG_EOS){ 5974 pComponentPrivate->firstBufferEos = OMX_TRUE; 5975 } 5976 eError = VIDDEC_CopyBuffer(pComponentPrivate, pBuffHead); 5977 if (eError != OMX_ErrorNone) { 5978 OMX_PRDSP4(pComponentPrivate->dbg, "VIDDEC_HandleDataBuf_FromApp: VIDDEC_CopyBuffer()= 0x%x\n", eError); 5979 if (eError == OMX_ErrorInsufficientResources) { 5980 goto EXIT; 5981 } 5982 } 5983 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_DSP; 5984 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*) 5985 pLcmlHandle)->pCodecinterfacehandle, 5986 ((pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) ? EMMCodecInputBufferMapBufLen : EMMCodecInputBuffer), 5987 &pBuffHead->pBuffer[pBuffHead->nOffset],/*WMV_VC1_CHANGES*/ 5988 pBuffHead->nAllocLen, 5989 pBuffHead->nFilledLen, 5990 (OMX_U8 *)pComponentPrivate->pUalgParams, 5991 size_dsp, 5992 (OMX_U8 *)pBuffHead); 5993 if (eError != OMX_ErrorNone){ 5994 OMX_PRDSP4(pComponentPrivate->dbg, "LCML_QueueBuffer EOS (0x%x)\n",eError); 5995 eError = OMX_ErrorHardware; 5996 goto EXIT; 5997 } 5998 } 5999 else{ 6000 eError = LCML_QueueBuffer(pLcmlHandle->pCodecinterfacehandle, 6001 ((pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) ? EMMCodecInputBufferMapBufLen : EMMCodecInputBuffer), 6002 NULL, 6003 0, 6004 0, 6005 (OMX_U8 *)pComponentPrivate->pUalgParams, 6006 size_dsp, 6007 (OMX_PTR)&pComponentPrivate->pTempBuffHead); 6008 } 6009 if (eError != OMX_ErrorNone){ 6010 OMX_PRDSP4(pComponentPrivate->dbg, "LCML_QueueBuffer 1 (0x%x)\n",eError); 6011 eError = OMX_ErrorHardware; 6012 goto EXIT; 6013 } 6014 } 6015 else { 6016 eError = OMX_ErrorHardware; 6017 goto EXIT; 6018 } 6019 } 6020 } 6021 else { 6022 pComponentPrivate->iEndofInputSent = 0; 6023 if(pBuffHead->nFilledLen != 0) { 6024 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 6025 pUalgInpParams = pBufferPrivate->pUalgParam; 6026 if ((pBuffHead->nFlags & OMX_BUFFERFLAG_EOS) == 0) { 6027 ((H264VDEC_UALGInputParam *)pUalgInpParams)->lBuffCount = ++pComponentPrivate->frameCounter; 6028 if (pComponentPrivate->H264BitStreamFormat) { 6029 H264VDEC_UALGInputParam *pParam; 6030 #ifndef ANDROID 6031 OMX_U32 nal_len, i; 6032 OMX_U8 *pDataBuf; 6033 OMX_U32 length_pos = 0; 6034 OMX_U32 data_pos = 0; 6035 OMX_U32 buf_len; 6036 6037 buf_len = pBuffHead->nFilledLen; 6038 pDataBuf = pBuffHead->pBuffer; 6039 pParam = (H264VDEC_UALGInputParam *)pUalgInpParams; 6040 pParam->ulNumOfNALU = 0; 6041 while (pBuffHead->nFilledLen > length_pos+pComponentPrivate->H264BitStreamFormat) { 6042 if (pComponentPrivate->H264BitStreamFormat == 1) 6043 if (pComponentPrivate->bIsNALBigEndian) { 6044 nal_len = (OMX_U32)pDataBuf[length_pos]; 6045 } 6046 else { 6047 nal_len = (OMX_U32)pDataBuf[length_pos]; 6048 } 6049 else if (pComponentPrivate->H264BitStreamFormat == 2) 6050 if (pComponentPrivate->bIsNALBigEndian) { 6051 nal_len = (OMX_U32)pDataBuf[length_pos] << 8 | pDataBuf[length_pos+1]; 6052 } 6053 else { 6054 nal_len = (OMX_U32)pDataBuf[length_pos] << 0 | pDataBuf[length_pos+1] << 8 ; 6055 } 6056 else if (pComponentPrivate->H264BitStreamFormat == 4){ 6057 if (pComponentPrivate->bIsNALBigEndian) { 6058 nal_len = (OMX_U32)pDataBuf[length_pos]<<24 | pDataBuf[length_pos+1] << 16 | pDataBuf[length_pos+2] << 8 | pDataBuf[length_pos+3]; 6059 } 6060 else { 6061 nal_len = (OMX_U32)pDataBuf[length_pos]<<0 | pDataBuf[length_pos+1] << 8 | pDataBuf[length_pos+2] << 16 | pDataBuf[length_pos+3]<<24; 6062 } 6063 } 6064 else { 6065 eError = OMX_ErrorBadParameter; 6066 goto EXIT; 6067 } 6068 length_pos += pComponentPrivate->H264BitStreamFormat; 6069 if (nal_len > buf_len - length_pos) { 6070 eError = OMX_ErrorBadParameter; 6071 goto EXIT; 6072 } 6073 /* move the memory*/ 6074 for (i=0; i<nal_len; i++) 6075 pDataBuf[data_pos+i] = pDataBuf[length_pos+i]; 6076 data_pos += nal_len; 6077 length_pos += nal_len; 6078 /* save the size*/ 6079 pParam->pNALUSizeArray[pParam->ulNumOfNALU++] = nal_len; 6080 } 6081 /* update with the new data size*/ 6082 pBuffHead->nFilledLen = data_pos; 6083 #else 6084 pParam = (H264VDEC_UALGInputParam *)pUalgInpParams; 6085 pParam->ulNumOfNALU = 0; 6086 6087 if (pBuffHead->nFlags >= OMX_BUFFERFLAG_CODECCONFIG) { 6088 OMX_PRINT1(pComponentPrivate->dbg,"nFlags = %x\n", pBuffHead->nFlags); 6089 OMX_PRINT1(pComponentPrivate->dbg,"copy previous codec config data to current ccd buffer\n"); 6090 eError = VIDDEC_CopyBuffer(pComponentPrivate, pBuffHead); 6091 6092 OMX_PRINT1(pComponentPrivate->dbg,"save current ccd buff - nFilledLen = %d\n", pBuffHead->nFilledLen); 6093 eError = VIDDEC_SaveBuffer(pComponentPrivate, pBuffHead); 6094 pComponentPrivate->aCCDsize[pComponentPrivate->nCCDcnt++] = pBuffHead->nFilledLen; 6095 6096 OMX_PRINT1(pComponentPrivate->dbg,"send ccd buffer back to client\n"); 6097 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 6098 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 6099 VIDDEC_EmptyBufferDone(pComponentPrivate, pBuffHead); 6100 goto EXIT; 6101 } 6102 else { 6103 H264VDEC_UALGInputParam *pParam; 6104 OMX_U32 len = 0; /* offset+filledlen+padding */ 6105 OMX_U32 off = 0; /* offset */ 6106 OMX_U32 fl = 0; /* filledlen */ 6107 OMX_U32 rem = 0; /* modulus */ 6108 OMX_U32 pad = 0; /* padding */ 6109 OMX_U32 numnalu = 0; /* number of nal units */ 6110 OMX_U32 sp = 0; /* starting position of 4 byte nDataSize */ 6111 OMX_U32 nalusize[256] = {0}; /* array to store nal sizes */ 6112 OMX_U32 i = 0; 6113 OMX_U32 j = 0; 6114 OMX_U32 t1 = 0; 6115 OMX_U32 t2 = 0; 6116 6117 /* This is how pBuffer is arranged when 6118 * iOMXComponentUsesFullAVCFrames is set 6119 * to true 6120 */ 6121 6122 /* offset, 6123 * NALU1, NALU2, ... 6124 * padding, 6125 * nSize, 6126 * nVersion, 6127 * nPortIndex, 6128 * eType, 6129 * nDataSize, 6130 * NAL1Len, NAL2Len, ... 6131 */ 6132 6133 pParam = (H264VDEC_UALGInputParam *)pUalgInpParams; 6134 pParam->ulNumOfNALU = 0; 6135 off = pBuffHead->nOffset; 6136 fl = pBuffHead->nFilledLen; 6137 rem = (off + fl) % 4; 6138 if (rem > 0) { 6139 pad = 4 - rem; 6140 } 6141 6142 len = off + fl + pad; 6143 OMX_PRINT1(pComponentPrivate->dbg,"nFlags = %x\n", pBuffHead->nFlags); 6144 OMX_PRINT1(pComponentPrivate->dbg,"off=%d,fl=%d,rem=%d,pad=%d,len=%d\n", off, fl, rem, pad, len); 6145 6146 /* print the OMX_ExtraDataNALSizeArry marker */ 6147 OMX_PRINT1(pComponentPrivate->dbg,"extradata marker -> 0x %x %x %x %x\n", 6148 pBuffHead->pBuffer[len+15], 6149 pBuffHead->pBuffer[len+14], 6150 pBuffHead->pBuffer[len+13], 6151 pBuffHead->pBuffer[len+12]); 6152 6153 /* store number of numnalu */ 6154 ((OMX_U8*)(&numnalu))[3] = pBuffHead->pBuffer[len+19]; 6155 ((OMX_U8*)(&numnalu))[2] = pBuffHead->pBuffer[len+18]; 6156 ((OMX_U8*)(&numnalu))[1] = pBuffHead->pBuffer[len+17]; 6157 ((OMX_U8*)(&numnalu))[0] = pBuffHead->pBuffer[len+16]; 6158 numnalu /= 4; 6159 6160 /* print the numnalu */ 6161 OMX_PRINT1(pComponentPrivate->dbg,"numnalu -> 0x %x %x %x %x\n", ((OMX_U8*)(&numnalu))[3] 6162 , ((OMX_U8*)(&numnalu))[2] 6163 , ((OMX_U8*)(&numnalu))[1] 6164 , ((OMX_U8*)(&numnalu))[0]); 6165 6166 /* print the nDataSize */ 6167 OMX_PRINT1(pComponentPrivate->dbg,"nDataSize -> 0x %x %x %x %x\n", pBuffHead->pBuffer[len+19] 6168 , pBuffHead->pBuffer[len+18] 6169 , pBuffHead->pBuffer[len+17] 6170 , pBuffHead->pBuffer[len+16]); 6171 /* print the first NALU len */ 6172 OMX_PRINT1(pComponentPrivate->dbg,"first NALU len -> 0x %x %x %x %x\n", pBuffHead->pBuffer[len+23] 6173 , pBuffHead->pBuffer[len+22] 6174 , pBuffHead->pBuffer[len+21] 6175 , pBuffHead->pBuffer[len+20]); 6176 pParam->ulNumOfNALU = 0; 6177 6178 /* starting position of nalu sizes */ 6179 sp = t1 = len+20; 6180 t2 = i; 6181 6182 OMX_PRINT1(pComponentPrivate->dbg,"numnalu = %d", numnalu); 6183 6184 while (i<(t2+numnalu)) { 6185 j=0; 6186 while (sp<(t1+4)) { 6187 ((OMX_U8*)(&nalusize[i]))[j] = pBuffHead->pBuffer[sp]; 6188 sp++; 6189 j++; 6190 } 6191 t1 = sp; 6192 i++; 6193 } 6194 OMX_PRINT1(pComponentPrivate->dbg,"confirm ulNumOfNALU = %d\n", i); 6195 6196 if (pComponentPrivate->bCopiedCCDBuffer == OMX_FALSE){ 6197 pComponentPrivate->bCopiedCCDBuffer = OMX_TRUE; 6198 OMX_PRINT1(pComponentPrivate->dbg,"copy saved ccd buffer to data buffer\n"); 6199 eError = VIDDEC_CopyBuffer(pComponentPrivate, pBuffHead); 6200 6201 i=0; 6202 /* tally number of ccd nalus and add sizes to nalu array */ 6203 while (i < pComponentPrivate->nCCDcnt) { 6204 if (i == 0) { 6205 pParam->pNALUSizeArray[i] = pComponentPrivate->aCCDsize[i]; 6206 } 6207 else { 6208 pParam->pNALUSizeArray[i] = pComponentPrivate->aCCDsize[i] - 6209 pComponentPrivate->aCCDsize[i-1]; 6210 } 6211 pParam->ulNumOfNALU++; 6212 OMX_PRINT1(pComponentPrivate->dbg,"aCCDsize[%d] = %d\n", i, pParam->pNALUSizeArray[i]); 6213 i++; 6214 } 6215 6216 /* adjust the filled length to account for the ccd nalus */ 6217 pBuffHead->nFilledLen = fl + pComponentPrivate->aCCDsize[i-1]; 6218 6219 OMX_PRINT1(pComponentPrivate->dbg,"new nFilledLen=%d; old fl=%d + aCCDsize=%d\n", pBuffHead->nFilledLen 6220 , fl 6221 , pComponentPrivate->aCCDsize[i-1]); 6222 t1 = i; 6223 j=0; 6224 6225 /* now, add the data nalu sizes to the array, 6226 * which already contain the ccd nalu sizes */ 6227 for(;i<t1+numnalu;i++) { 6228 pParam->pNALUSizeArray[i] = nalusize[j]; 6229 j++; 6230 } 6231 pParam->ulNumOfNALU = i+numnalu; 6232 6233 for(j=0;j<i;j++) { 6234 OMX_PRINT1(pComponentPrivate->dbg,"pParm->pNALUSizeArray[%d] = %d\n",j,pParam->pNALUSizeArray[j]); 6235 } 6236 } 6237 else { 6238 /* add the data nalu sizes to the array. 6239 * we should not have any ccd sizes in here */ 6240 for(j=0;j<i;j++) { 6241 pParam->pNALUSizeArray[j] = nalusize[j]; 6242 OMX_PRINT1(pComponentPrivate->dbg,"pParm->pNALUSizeArray[%d] = %d\n",j,pParam->pNALUSizeArray[j]); 6243 } 6244 pParam->ulNumOfNALU = i; 6245 } 6246 }/* end else */ 6247 #endif 6248 }/* end bitstrm fmt */ 6249 }/* end nFlags & EOS */ 6250 size_dsp = sizeof(H264VDEC_UALGInputParam); 6251 }/* end if AVC */ 6252 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 6253 pUalgInpParams = pBufferPrivate->pUalgParam; 6254 if ((pBuffHead->nFlags & OMX_BUFFERFLAG_EOS) == 0) { 6255 ((WMV9DEC_UALGInputParam*)pUalgInpParams)->lBuffCount = ++pComponentPrivate->frameCounter; 6256 } 6257 size_dsp = sizeof(WMV9DEC_UALGInputParam); 6258 } 6259 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 6260 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 6261 pUalgInpParams = pBufferPrivate->pUalgParam; 6262 ((MP4VD_GPP_SN_UALGInputParams*)pUalgInpParams)->uRingIOBlocksize = 0; 6263 ((MP4VD_GPP_SN_UALGInputParams*)pUalgInpParams)->nPerformMode = 2; 6264 6265 if ((pBuffHead->nFlags & OMX_BUFFERFLAG_EOS) == 0) { 6266 ((MP4VD_GPP_SN_UALGInputParams*)pUalgInpParams)->nBuffCount = ++pComponentPrivate->frameCounter; 6267 } 6268 size_dsp = sizeof(MP4VD_GPP_SN_UALGInputParams); 6269 } 6270 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 6271 pUalgInpParams = pBufferPrivate->pUalgParam; 6272 if ((pBuffHead->nFlags & OMX_BUFFERFLAG_EOS) == 0) { 6273 ((MP2VDEC_UALGInputParam*)pUalgInpParams)->lBuffCount = ++pComponentPrivate->frameCounter; 6274 } 6275 size_dsp = sizeof(MP2VDEC_UALGInputParam); 6276 } 6277 #ifdef VIDDEC_SPARK_CODE 6278 else if (VIDDEC_SPARKCHECK) { 6279 pUalgInpParams = pBufferPrivate->pUalgParam; 6280 if ((pBuffHead->nFlags & OMX_BUFFERFLAG_EOS) == 0) { 6281 ((SPARKVD_GPP_SN_UALGInputParams*)pUalgInpParams)->lBuffCount = ++pComponentPrivate->frameCounter; 6282 } 6283 ((SPARKVD_GPP_SN_UALGInputParams*)pUalgInpParams)->nIsSparkInput = 1; 6284 size_dsp = sizeof(SPARKVD_GPP_SN_UALGInputParams); 6285 } 6286 #endif 6287 else { 6288 eError = OMX_ErrorUnsupportedSetting; 6289 OMX_PRBUFFER4(pComponentPrivate->dbg, "VIDDEC_HandleDataBuf_FromApp 0x%x\n", eError); 6290 goto EXIT; 6291 } 6292 /* Store time stamp information */ 6293 if (pComponentPrivate->ProcessMode == 0) { 6294 OMX_U8 ucIndex = 0; 6295 OMX_PTR pBufferFlags = NULL; 6296 if ((pBuffHead->nFlags & OMX_BUFFERFLAG_CODECCONFIG) == 0 ) { //tag if not equal to OMX_BUFFERFLAG_CODECCONFIG 6297 ucIndex = VIDDEC_CircBuf_GetHead(pComponentPrivate, 6298 VIDDEC_CBUFFER_TIMESTAMP, 6299 VIDDEC_INPUT_PORT); 6300 pComponentPrivate->aBufferFlags[ucIndex].nTimeStamp = pBuffHead->nTimeStamp; 6301 pBuffHead->nFlags &= ~OMX_BUFFERFLAG_EOS; 6302 pComponentPrivate->aBufferFlags[ucIndex].nFlags = pBuffHead->nFlags; 6303 pComponentPrivate->aBufferFlags[ucIndex].nTickCount = pBuffHead->nTickCount; 6304 pBufferFlags = &pComponentPrivate->aBufferFlags[ucIndex]; 6305 VIDDEC_CircBuf_Add(pComponentPrivate, 6306 VIDDEC_CBUFFER_TIMESTAMP, 6307 VIDDEC_INPUT_PORT, 6308 pBufferFlags); 6309 } 6310 } 6311 else { 6312 pComponentPrivate->arrBufIndex[pComponentPrivate->nInBufIndex] = pBuffHead->nTimeStamp; 6313 pComponentPrivate->nInBufIndex++; 6314 pComponentPrivate->nInBufIndex %= VIDDEC_MAX_QUEUE_SIZE; 6315 } 6316 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead->nTimeStamp %lld\n", pBuffHead->nTimeStamp); 6317 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead->nOffset %lu\n", pBuffHead->nOffset); 6318 #ifdef __PERF_INSTRUMENTATION__ 6319 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 6320 pBuffHead->pBuffer, 6321 pBuffHead->nFilledLen, 6322 PERF_ModuleCommonLayer); 6323 #endif 6324 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 6325 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 6326 pComponentPrivate->pLCML != NULL){ 6327 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_DSP; 6328 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead->nFilledLen %lu\n", pBuffHead->nFilledLen); 6329 OMX_PRBUFFER1(pComponentPrivate->dbg, "Sending Filled eBufferOwner 0x%x f%x\n", pBufferPrivate->eBufferOwner, pComponentPrivate->frameCounter); 6330 6331 6332 #ifdef __PERF_INSTRUMENTATION__ 6333 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 6334 pBuffHead->pBuffer, 6335 pBuffHead->nFilledLen, 6336 PERF_ModuleHLMM); 6337 #endif 6338 6339 if(pComponentPrivate->bDynamicConfigurationInProgress){ 6340 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 6341 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 6342 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 6343 6344 OMX_PRBUFFER2(pComponentPrivate->dbg, "Sending buffer back to client pBuffer=%p\n", pBuffHead->pBuffer); 6345 VIDDEC_EmptyBufferDone(pComponentPrivate, pBuffHead); 6346 goto EXIT; 6347 } 6348 #ifdef ANDROID 6349 6350 if(pComponentPrivate->eFirstBuffer.bSaveFirstBuffer == OMX_TRUE){ 6351 if(pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV && 6352 pComponentPrivate->nWMVFileType == VIDDEC_WMV_RCVSTREAM){ 6353 ((WMV9DEC_UALGInputParam*)pComponentPrivate->pUalgParams)->lBuffCount = ++pComponentPrivate->frameCounter; 6354 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*) 6355 pLcmlHandle)->pCodecinterfacehandle, 6356 EMMCodecInputBufferMapBufLen, 6357 (OMX_U8*)&pComponentPrivate->pBufferRCV.pBuffer, 6358 sizeof(VIDDEC_WMV_RCV_struct), 6359 sizeof(VIDDEC_WMV_RCV_struct), 6360 (OMX_U8 *)pUalgInpParams, 6361 sizeof(WMV9DEC_UALGInputParam), 6362 (OMX_U8*)&pComponentPrivate->pBufferTemp); 6363 } 6364 else { 6365 eError = VIDDEC_CopyBuffer(pComponentPrivate, pBuffHead); 6366 if (eError != OMX_ErrorNone) { 6367 OMX_PRDSP4(pComponentPrivate->dbg, "VIDDEC_HandleDataBuf_FromApp: VIDDEC_CopyBuffer()= 0x%x\n", eError); 6368 if (eError == OMX_ErrorInsufficientResources) { 6369 goto EXIT; 6370 } 6371 } 6372 } 6373 } 6374 #endif 6375 6376 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_QueueBuffer(INPUT), nFilledLen=0x%x nFlags=0x%x", pBuffHead->nFilledLen, pBuffHead->nFlags); 6377 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_DSP; 6378 eError = LCML_QueueBuffer(((LCML_DSP_INTERFACE*) 6379 pLcmlHandle)->pCodecinterfacehandle, 6380 ((pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) ? EMMCodecInputBufferMapBufLen : EMMCodecInputBuffer), /*Only WMV need to send map buffers */ 6381 &pBuffHead->pBuffer[pBuffHead->nOffset],/*WMV_VC1_CHANGES*/ 6382 pBuffHead->nAllocLen, 6383 pBuffHead->nFilledLen, 6384 (OMX_U8 *)pUalgInpParams, 6385 size_dsp, 6386 (OMX_U8 *)pBuffHead); 6387 if (eError != OMX_ErrorNone){ 6388 OMX_PRDSP4(pComponentPrivate->dbg, "LCML_QueueBuffer 2 (0x%x)\n",eError); 6389 eError = OMX_ErrorHardware; 6390 goto EXIT; 6391 } 6392 } 6393 else { 6394 eError = OMX_ErrorHardware; 6395 goto EXIT; 6396 } 6397 } 6398 else { 6399 pBuffHead->nFilledLen = 0; 6400 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_COMPONENT; 6401 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 6402 eError = IncrementCount (&(pComponentPrivate->nCountInputBFromDsp), &(pComponentPrivate->mutexInputBFromDSP)); 6403 if (eError != OMX_ErrorNone) { 6404 return eError; 6405 } 6406 ret = write(pComponentPrivate->free_inpBuf_Q[1], &pBuffHead, sizeof(pBuffHead)); 6407 if(ret == -1){ 6408 OMX_PRCOMM4(pComponentPrivate->dbg, "writing to the input pipe %x (%d)\n", OMX_ErrorInsufficientResources,ret); 6409 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_DSP; 6410 DecrementCount (&(pComponentPrivate->nCountInputBFromDsp), &(pComponentPrivate->mutexInputBFromDSP)); 6411 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 6412 pComponentPrivate->pHandle->pApplicationPrivate, 6413 OMX_EventError, 6414 OMX_ErrorInsufficientResources, 6415 OMX_TI_ErrorSevere, 6416 "Error writing to the output pipe"); 6417 } 6418 } 6419 } 6420 EXIT: 6421 OMX_PRBUFFER1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 6422 return eError; 6423 } 6424 6425 /* ========================================================================== */ 6426 /** 6427 * Handle Data Buff function from DSP 6428 **/ 6429 /* ========================================================================== */ 6430 6431 OMX_ERRORTYPE VIDDEC_HandleDataBuf_FromDsp(VIDDEC_COMPONENT_PRIVATE *pComponentPrivate) 6432 { 6433 OMX_ERRORTYPE eError = OMX_ErrorNone; 6434 OMX_ERRORTYPE eExtendedError = OMX_ErrorNone; 6435 OMX_BUFFERHEADERTYPE* pBuffHead; 6436 VIDDEC_BUFFER_PRIVATE* pBufferPrivate = NULL; 6437 int ret; 6438 6439 OMX_PRBUFFER1(pComponentPrivate->dbg, "+++ENTERING\n"); 6440 OMX_PRBUFFER1(pComponentPrivate->dbg, "pComponentPrivate 0x%p\n", (int*)pComponentPrivate); 6441 ret = read(pComponentPrivate->filled_outBuf_Q[0], &pBuffHead, sizeof(pBuffHead)); 6442 if (ret == -1) { 6443 OMX_PRDSP4(pComponentPrivate->dbg, "Error while reading from dsp out pipe\n"); 6444 eError = OMX_ErrorHardware; 6445 goto EXIT; 6446 } 6447 eError = DecrementCount (&(pComponentPrivate->nCountOutputBFromDsp), &(pComponentPrivate->mutexOutputBFromDSP)); 6448 if (eError != OMX_ErrorNone) { 6449 return eError; 6450 } 6451 OMX_PRBUFFER1(pComponentPrivate->dbg, "BufferSize fromDSP %lu \n",pBuffHead->nAllocLen); 6452 OMX_PRBUFFER1(pComponentPrivate->dbg, "AllocLen: 0x%x, FilledLen: 0x%x\n", pBuffHead->nAllocLen, pBuffHead->nFilledLen); 6453 OMX_PRSTATE1(pComponentPrivate->dbg, "pBuffHead 0x%p eExecuteToIdle 0x%x\n", pBuffHead,pComponentPrivate->eExecuteToIdle); 6454 if (pComponentPrivate->eState == OMX_StateLoaded || pComponentPrivate->eState == OMX_StateIdle) { 6455 eError = OMX_ErrorNone; 6456 goto EXIT; 6457 } 6458 OMX_PRBUFFER1(pComponentPrivate->dbg, "BufferSize fromDSP %lu \n",pBuffHead->nAllocLen); 6459 OMX_PRBUFFER1(pComponentPrivate->dbg, "AllocLen: 0x%x, FilledLen: 0x%x\n", pBuffHead->nAllocLen, pBuffHead->nFilledLen); 6460 OMX_PRSTATE1(pComponentPrivate->dbg, "pBuffHead 0x%p eExecuteToIdle 0x%x\n", pBuffHead,pComponentPrivate->eExecuteToIdle); 6461 if(pBuffHead != NULL) { 6462 OMX_S32 nErrorCode = 0; 6463 OMX_S32 nInternalErrorCode = 0; 6464 OMX_U32 ulDisplayID = 0; 6465 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pOutputPortPrivate; 6466 pBuffHead->nFlags &= ~(OMX_BUFFERFLAG_SYNCFRAME); 6467 pBuffHead->nFlags &= ~(VIDDEC_BUFFERFLAG_FRAMETYPE_MASK); 6468 pBuffHead->nFlags &= ~(VIDDEC_BUFFERFLAG_EXTENDERROR_MASK); 6469 6470 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 6471 H264VDEC_UALGOutputParam* pUalgOutParams = NULL; 6472 pUalgOutParams = (H264VDEC_UALGOutputParam *)pBufferPrivate->pUalgParam; 6473 nErrorCode = (pUalgOutParams->iErrorCode); 6474 ulDisplayID = pUalgOutParams->ulDisplayID; 6475 if(pUalgOutParams->ulDecodedFrameType == VIDDEC_I_FRAME) { 6476 pBuffHead->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; 6477 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_I_FRAME; 6478 } 6479 else if(pUalgOutParams->ulDecodedFrameType == VIDDEC_P_FRAME){ 6480 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_P_FRAME; 6481 } 6482 else if(pUalgOutParams->ulDecodedFrameType == VIDDEC_B_FRAME){ 6483 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_B_FRAME; 6484 } 6485 else { 6486 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_IDR_FRAME; 6487 } 6488 /*VIDDEC_ISFLAGSET*/ 6489 } 6490 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 6491 WMV9DEC_UALGOutputParam* pUalgOutParams = NULL; 6492 pUalgOutParams = (WMV9DEC_UALGOutputParam *)pBufferPrivate->pUalgParam; 6493 nErrorCode = (pUalgOutParams->iErrorCode); 6494 ulDisplayID = pUalgOutParams->ulDisplayID; 6495 if(pUalgOutParams->ulDecodedFrameType == VIDDEC_I_FRAME) { 6496 pBuffHead->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; 6497 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_I_FRAME; 6498 } 6499 else if(pUalgOutParams->ulDecodedFrameType == VIDDEC_P_FRAME){ 6500 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_P_FRAME; 6501 } 6502 else if(pUalgOutParams->ulDecodedFrameType == VIDDEC_B_FRAME){ 6503 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_B_FRAME; 6504 } 6505 else { 6506 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_IDR_FRAME; 6507 } 6508 } 6509 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 6510 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 6511 MP4VD_GPP_SN_UALGOutputParams* pUalgOutParams = NULL; 6512 pUalgOutParams = (MP4VD_GPP_SN_UALGOutputParams *)pBufferPrivate->pUalgParam; 6513 nErrorCode = (pUalgOutParams->iErrorCode); 6514 ulDisplayID = pUalgOutParams->ulDisplayID; 6515 if(pUalgOutParams->ulDecodedFrameType == VIDDEC_I_FRAME) { 6516 pBuffHead->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; 6517 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_I_FRAME; 6518 } 6519 else if(pUalgOutParams->ulDecodedFrameType == VIDDEC_P_FRAME){ 6520 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_P_FRAME; 6521 } 6522 else if(pUalgOutParams->ulDecodedFrameType == VIDDEC_B_FRAME){ 6523 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_B_FRAME; 6524 } 6525 else { 6526 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_IDR_FRAME; 6527 } 6528 } 6529 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 6530 MP2VDEC_UALGOutputParam* pUalgOutParams = NULL; 6531 pUalgOutParams = (MP2VDEC_UALGOutputParam *)pBufferPrivate->pUalgParam; 6532 nErrorCode = (pUalgOutParams->lErrorCode); 6533 ulDisplayID = pUalgOutParams->ulDisplayID; 6534 if(pUalgOutParams->ulDecodedFrameType == VIDDEC_I_FRAME) { 6535 pBuffHead->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; 6536 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_I_FRAME; 6537 } 6538 else if(pUalgOutParams->ulDecodedFrameType == VIDDEC_P_FRAME){ 6539 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_P_FRAME; 6540 } 6541 else if(pUalgOutParams->ulDecodedFrameType == VIDDEC_B_FRAME){ 6542 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_B_FRAME; 6543 } 6544 else { 6545 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_IDR_FRAME; 6546 } 6547 } 6548 #ifdef VIDDEC_SPARK_CODE 6549 else if (VIDDEC_SPARKCHECK) { 6550 SPARKVD_GPP_SN_UALGOutputParams* pUalgOutParams = NULL; 6551 pUalgOutParams = (SPARKVD_GPP_SN_UALGOutputParams *)pBufferPrivate->pUalgParam; 6552 nErrorCode = (pUalgOutParams->iErrorCode); 6553 ulDisplayID = pUalgOutParams->ulDisplayID; 6554 if(pUalgOutParams->ulDecodedFrameType == VIDDEC_I_FRAME) { 6555 pBuffHead->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; 6556 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_I_FRAME; 6557 } 6558 else if(pUalgOutParams->ulDecodedFrameType == VIDDEC_P_FRAME){ 6559 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_P_FRAME; 6560 } 6561 else if(pUalgOutParams->ulDecodedFrameType == VIDDEC_B_FRAME){ 6562 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_B_FRAME; 6563 } 6564 else { 6565 pBuffHead->nFlags |= VIDDEC_BUFFERFLAG_FRAMETYPE_IDR_FRAME; 6566 } 6567 } 6568 #endif 6569 else { 6570 eError = OMX_ErrorUnsupportedSetting; 6571 goto EXIT; 6572 } 6573 pBuffHead->nFlags |= (nErrorCode<<12); 6574 /*OMX_ERROR4(pComponentPrivate->dbg, "nErrorCode %x nFlags %x\n", (int *)nErrorCode, (int *)pBuffHead->nFlags);*/ 6575 if((nErrorCode & 0xff) != 0){/*OMX_BUFFERFLAG_DATACORRUPT*/ 6576 nInternalErrorCode = ((nErrorCode & VIDDEC_BUFFERFLAG_EXTENDERROR_DIRTY)>>12); 6577 if(VIDDEC_ISFLAGSET(nErrorCode,VIDDEC_XDM_FATALERROR)){ 6578 eExtendedError = OMX_ErrorStreamCorrupt; 6579 pBuffHead->nFlags |= OMX_BUFFERFLAG_DATACORRUPT; 6580 pBuffHead->nFilledLen = 0; 6581 OMX_PRDSP4(pComponentPrivate->dbg, "Not Recoverable Error Detected in Buffer in buffer %p %lu(int# %lx/%lu) OMX_ErrorStreamCorrupt\n", 6582 pBuffHead, ulDisplayID, (nErrorCode & VIDDEC_BUFFERFLAG_EXTENDERROR_DIRTY), pBuffHead->nFilledLen); 6583 } 6584 if(VIDDEC_ISFLAGSET(nErrorCode,VIDDEC_XDM_APPLIEDCONCEALMENT)){ 6585 pBuffHead->nFlags |= OMX_BUFFERFLAG_DATACORRUPT; 6586 OMX_PRDSP4(pComponentPrivate->dbg, "Applied Concealment in buffer %p %lu(int# %lx/%lu)\n", 6587 pBuffHead, ulDisplayID, nInternalErrorCode, pBuffHead->nFilledLen); 6588 } 6589 if(VIDDEC_ISFLAGSET(nErrorCode,VIDDEC_XDM_INSUFFICIENTDATA)){ 6590 pBuffHead->nFlags |= OMX_BUFFERFLAG_DATACORRUPT; 6591 pBuffHead->nFilledLen = 0; 6592 OMX_PRDSP4(pComponentPrivate->dbg, "Insufficient Data in buffer %p %lu(int# %lx/%lu)\n", 6593 pBuffHead, ulDisplayID, nInternalErrorCode, pBuffHead->nFilledLen); 6594 } 6595 if(VIDDEC_ISFLAGSET(nErrorCode,VIDDEC_XDM_CORRUPTEDDATA)){ 6596 pBuffHead->nFlags |= OMX_BUFFERFLAG_DATACORRUPT; 6597 pBuffHead->nFilledLen = 0; 6598 OMX_PRDSP4(pComponentPrivate->dbg, "Corrupted Data in buffer %p %lu(int# %lx/%lu)\n", 6599 pBuffHead, ulDisplayID, nInternalErrorCode, pBuffHead->nFilledLen); 6600 } 6601 if(VIDDEC_ISFLAGSET(nErrorCode,VIDDEC_XDM_CORRUPTEDHEADER)){ 6602 pBuffHead->nFlags |= OMX_BUFFERFLAG_DATACORRUPT; 6603 pBuffHead->nFilledLen = 0; 6604 OMX_PRDSP4(pComponentPrivate->dbg, "Corrupted Header in buffer %p %lu(int# %lx/%lu)\n", 6605 pBuffHead, ulDisplayID, nInternalErrorCode, pBuffHead->nFilledLen); 6606 } 6607 if(VIDDEC_ISFLAGSET(nErrorCode,VIDDEC_XDM_UNSUPPORTEDINPUT)){ 6608 pBuffHead->nFlags |= OMX_BUFFERFLAG_DATACORRUPT; 6609 pBuffHead->nFilledLen = 0; 6610 OMX_PRDSP4(pComponentPrivate->dbg, "Unsupported Input in buffer %p %lu(int# %lx/%lu)\n", 6611 pBuffHead, ulDisplayID, nInternalErrorCode, pBuffHead->nFilledLen); 6612 } 6613 if(VIDDEC_ISFLAGSET(nErrorCode,VIDDEC_XDM_UNSUPPORTEDPARAM)){ 6614 pBuffHead->nFlags |= OMX_BUFFERFLAG_DATACORRUPT; 6615 pBuffHead->nFilledLen = 0; 6616 OMX_PRDSP4(pComponentPrivate->dbg, "Unsupported Parameter in buffer %p %lu(int# %lx/%lu)\n", 6617 pBuffHead, ulDisplayID, nInternalErrorCode, pBuffHead->nFilledLen); 6618 } 6619 } 6620 #ifdef KHRONOS_1_1 6621 if (pComponentPrivate->eMBErrorReport.bEnabled) {/* && pBuffHead->nFilledLen != 0*/ 6622 OMX_U8* ErrMapFrom = NULL; 6623 OMX_U8* ErrMapTo = NULL; 6624 /*OMX_U32 nlooping = 0;*/ 6625 OMX_U32 nErrMapSize = 0; 6626 if (pComponentPrivate->MPEG4Codec_IsTI && 6627 (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 6628 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263)) { 6629 MP4VD_GPP_SN_UALGOutputParams* pUalgOutParams = NULL; 6630 pUalgOutParams = (MP4VD_GPP_SN_UALGOutputParams *)pBufferPrivate->pUalgParam; 6631 ErrMapFrom = pUalgOutParams->usMbErrorBuf; 6632 /*todo add code to use ualg_array*/ 6633 nErrMapSize = pComponentPrivate->pOutPortDef->format.video.nFrameWidth * 6634 pComponentPrivate->pOutPortDef->format.video.nFrameHeight / 256; 6635 ErrMapTo = pComponentPrivate->eMBErrorMapType[pComponentPrivate->cMBErrorIndexIn].ErrMap; 6636 pComponentPrivate->eMBErrorMapType[pComponentPrivate->cMBErrorIndexIn].nErrMapSize = nErrMapSize; 6637 memcpy(ErrMapTo, ErrMapFrom, nErrMapSize); 6638 pComponentPrivate->cMBErrorIndexIn++; 6639 pComponentPrivate->cMBErrorIndexIn %= pComponentPrivate->pOutPortDef->nBufferCountActual; 6640 } 6641 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 6642 H264VDEC_UALGOutputParam* pUalgOutParams = NULL; 6643 pUalgOutParams = (H264VDEC_UALGOutputParam *)pBufferPrivate->pUalgParam; 6644 ErrMapFrom = pUalgOutParams->pMBErrStatOutBuf; 6645 /*todo add code to use ualg_array*/ 6646 nErrMapSize = pComponentPrivate->pOutPortDef->format.video.nFrameWidth * 6647 pComponentPrivate->pOutPortDef->format.video.nFrameHeight / 256; 6648 ErrMapTo = pComponentPrivate->eMBErrorMapType[pComponentPrivate->cMBErrorIndexIn].ErrMap; 6649 pComponentPrivate->eMBErrorMapType[pComponentPrivate->cMBErrorIndexIn].nErrMapSize = nErrMapSize; 6650 memcpy(ErrMapTo, ErrMapFrom, nErrMapSize); 6651 pComponentPrivate->cMBErrorIndexIn++; 6652 pComponentPrivate->cMBErrorIndexIn %= pComponentPrivate->pOutPortDef->nBufferCountActual; 6653 } 6654 } 6655 #endif 6656 if (pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL) { 6657 if(pComponentPrivate->bFirstBuffer) { 6658 OMX_PRBUFFER2(pComponentPrivate->dbg, "**** Setting OMX_BUFFERFLAG_STARTTIME\n"); 6659 pBuffHead->nFlags |= OMX_BUFFERFLAG_STARTTIME; 6660 pComponentPrivate->bFirstBuffer = 0; 6661 } 6662 else { 6663 pBuffHead->nFlags &= ~(OMX_BUFFERFLAG_STARTTIME); 6664 } 6665 if(pBuffHead != NULL){ 6666 if((pBuffHead->nFlags & OMX_BUFFERFLAG_DECODEONLY) == 0) { 6667 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_TUNNELEDCOMP; 6668 OMX_PRBUFFER1(pComponentPrivate->dbg, "tunnel eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 6669 #ifdef __PERF_INSTRUMENTATION__ 6670 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 6671 pBuffHead->pBuffer, 6672 pBuffHead->nFilledLen, 6673 PERF_ModuleLLMM); 6674 #endif 6675 OMX_PRDSP2(pComponentPrivate->dbg, "VIDDEC_HandleDataBuf_FromDsp %x %x\n",(int)pBuffHead->nFlags,(int)pBuffHead->nFilledLen); 6676 VIDDEC_Propagate_Mark(pComponentPrivate, pBuffHead); 6677 eError = OMX_EmptyThisBuffer(pComponentPrivate->pCompPort[1]->hTunnelComponent, pBuffHead); 6678 } 6679 else { 6680 ret = write(pComponentPrivate->free_outBuf_Q[1],&pBuffHead,sizeof(pBuffHead)); 6681 if (ret == -1) { 6682 OMX_PRDSP4(pComponentPrivate->dbg, "Error while writing to out pipe to client\n"); 6683 eError = OMX_ErrorHardware; 6684 return eError; 6685 } 6686 eError = IncrementCount (&(pComponentPrivate->nCountOutputBFromApp), &(pComponentPrivate->mutexOutputBFromApp)); 6687 if (eError != OMX_ErrorNone) { 6688 return eError; 6689 } 6690 } 6691 } 6692 } 6693 else { 6694 if(pBuffHead != NULL) { 6695 if (pComponentPrivate->firstBufferEos){ 6696 pComponentPrivate->firstBufferEos = OMX_FALSE; 6697 pBuffHead->nFlags |= OMX_BUFFERFLAG_EOS; 6698 pBuffHead->nFilledLen = 0; 6699 } 6700 #ifdef __PERF_INSTRUMENTATION__ 6701 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 6702 pBuffHead->pBuffer, 6703 pBuffHead->nFilledLen, 6704 PERF_ModuleHLMM); 6705 #endif 6706 6707 VIDDEC_Propagate_Mark(pComponentPrivate, pBuffHead); 6708 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 6709 OMX_PRBUFFER1(pComponentPrivate->dbg, "standalone buffer eBufferOwner 0x%x -- %lx\n", pBufferPrivate->eBufferOwner,pBuffHead->nFlags); 6710 VIDDEC_FillBufferDone(pComponentPrivate, pBuffHead); 6711 } 6712 } 6713 } 6714 6715 EXIT: 6716 if(eExtendedError != OMX_ErrorNone) { 6717 eError = eExtendedError; 6718 } 6719 OMX_PRBUFFER1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 6720 return eError; 6721 } 6722 6723 /* ========================================================================== */ 6724 /** 6725 * Handle Free Data Buff 6726 **/ 6727 /* ========================================================================== */ 6728 6729 OMX_ERRORTYPE VIDDEC_HandleFreeDataBuf( VIDDEC_COMPONENT_PRIVATE *pComponentPrivate ) 6730 { 6731 OMX_ERRORTYPE eError = OMX_ErrorNone; 6732 OMX_BUFFERHEADERTYPE* pBuffHead; 6733 VIDDEC_BUFFER_PRIVATE* pBufferPrivate = NULL; 6734 int ret; 6735 int inputbufsize = (int)pComponentPrivate->pInPortDef->nBufferSize; 6736 6737 OMX_PRBUFFER1(pComponentPrivate->dbg, "+++ENTERING\n"); 6738 OMX_PRBUFFER1(pComponentPrivate->dbg, "pComponentPrivate 0x%p\n", (int*)pComponentPrivate); 6739 ret = read(pComponentPrivate->free_inpBuf_Q[0], &pBuffHead, sizeof(pBuffHead)); 6740 if (ret == -1) { 6741 OMX_PRCOMM4(pComponentPrivate->dbg, "Error while reading from the free Q\n"); 6742 eError = OMX_ErrorHardware; 6743 goto EXIT; 6744 } 6745 eError = DecrementCount (&(pComponentPrivate->nCountInputBFromDsp), &(pComponentPrivate->mutexInputBFromDSP)); 6746 if (eError != OMX_ErrorNone) { 6747 return eError; 6748 } 6749 OMX_PRSTATE1(pComponentPrivate->dbg, "pBuffHead 0x%p eExecuteToIdle 0x%x\n", pBuffHead,pComponentPrivate->eExecuteToIdle); 6750 if (pComponentPrivate->eState == OMX_StateLoaded || pComponentPrivate->eState == OMX_StateIdle) { 6751 eError = OMX_ErrorNone; 6752 goto EXIT; 6753 } 6754 OMX_PRSTATE1(pComponentPrivate->dbg, "pBuffHead 0x%p eExecuteToIdle 0x%x\n", pBuffHead,pComponentPrivate->eExecuteToIdle); 6755 if (pBuffHead != NULL) { 6756 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 6757 pBuffHead->nAllocLen = inputbufsize; 6758 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_CLIENT; 6759 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 6760 #ifdef __PERF_INSTRUMENTATION__ 6761 PERF_SendingFrame(pComponentPrivate->pPERFcomp, 6762 pBuffHead->pBuffer, 6763 pBuffHead->nFilledLen, 6764 PERF_ModuleHLMM); 6765 #endif 6766 6767 VIDDEC_EmptyBufferDone(pComponentPrivate, pBuffHead); 6768 } 6769 OMX_PRBUFFER1(pComponentPrivate->dbg, "---EXITING(0x%x) \n",eError); 6770 EXIT: 6771 return eError; 6772 } 6773 6774 /*-------------------------------------------------------------------*/ 6775 /** 6776 * Function to fill DSP structures via LCML 6777 * 6778 * 6779 * 6780 * @retval OMX_NoError Success, ready to roll 6781 * 6782 **/ 6783 /*-------------------------------------------------------------------*/ 6784 OMX_ERRORTYPE VIDDEC_InitDSP_WMVDec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) 6785 { 6786 OMX_ERRORTYPE eError = OMX_ErrorNone; 6787 LCML_DSP_INTERFACE *pLcmlHandle = NULL; 6788 LCML_DSP *lcml_dsp = NULL; 6789 OMX_U32 nInpBuff = MAX_PRIVATE_IN_BUFFERS; 6790 OMX_U32 nInpBuffSize = 0; 6791 OMX_U32 nOutBuff = MAX_PRIVATE_OUT_BUFFERS; 6792 OMX_U32 nOutBuffSize = 0; 6793 WMV9DEC_SNCreatePhArg* pCreatePhaseArgs = NULL; 6794 LCML_CALLBACKTYPE cb; 6795 6796 OMX_PRDSP1(pComponentPrivate->dbg, "+++ENTERING\n"); 6797 nInpBuff = pComponentPrivate->pInPortDef->nBufferCountActual; 6798 nOutBuff = pComponentPrivate->pOutPortDef->nBufferCountActual; 6799 6800 /* Back it up for further use in this function */ 6801 nInpBuffSize = pComponentPrivate->pInPortDef->nBufferSize; 6802 nOutBuffSize = pComponentPrivate->pOutPortDef->nBufferSize; 6803 6804 pLcmlHandle = (LCML_DSP_INTERFACE *)pComponentPrivate->pLCML; 6805 lcml_dsp = (((LCML_DSP_INTERFACE*)pLcmlHandle)->dspCodec); 6806 6807 lcml_dsp->DeviceInfo.TypeofDevice = 0; 6808 lcml_dsp->DeviceInfo.DspStream = NULL; 6809 6810 lcml_dsp->In_BufInfo.nBuffers = nInpBuff; 6811 lcml_dsp->In_BufInfo.nSize = nInpBuffSize; 6812 lcml_dsp->In_BufInfo.DataTrMethod = DMM_METHOD; 6813 6814 lcml_dsp->Out_BufInfo.nBuffers = nOutBuff; 6815 lcml_dsp->Out_BufInfo.nSize = nOutBuffSize; 6816 lcml_dsp->Out_BufInfo.DataTrMethod = DMM_METHOD; 6817 6818 lcml_dsp->NodeInfo.nNumOfDLLs = OMX_WMVDEC_NUM_DLLS; 6819 lcml_dsp->NodeInfo.AllUUIDs[0].uuid = (struct DSP_UUID *)&WMVDSOCKET_TI_UUID; 6820 strcpy ((char*)(lcml_dsp->NodeInfo.AllUUIDs[0].DllName),(char*)WMV_DEC_NODE_DLL); 6821 lcml_dsp->NodeInfo.AllUUIDs[0].eDllType = DLL_NODEOBJECT; 6822 6823 lcml_dsp->NodeInfo.AllUUIDs[1].uuid = (struct DSP_UUID *)&WMVDSOCKET_TI_UUID; 6824 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[1].DllName,(char*)WMV_DEC_NODE_DLL); 6825 lcml_dsp->NodeInfo.AllUUIDs[1].eDllType = DLL_DEPENDENT; 6826 6827 lcml_dsp->NodeInfo.AllUUIDs[2].uuid = (struct DSP_UUID *)&USN_UUID; 6828 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[2].DllName,(char*)USN_DLL); 6829 lcml_dsp->NodeInfo.AllUUIDs[2].eDllType = DLL_DEPENDENT; 6830 6831 lcml_dsp->NodeInfo.AllUUIDs[3].uuid = (struct DSP_UUID *)&RINGIO_TI_UUID; 6832 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[3].DllName,(char*)RINGIO_NODE_DLL); 6833 lcml_dsp->NodeInfo.AllUUIDs[3].eDllType = DLL_DEPENDENT; 6834 6835 lcml_dsp->NodeInfo.AllUUIDs[4].uuid = (struct DSP_UUID *)&CONVERSIONS_UUID; 6836 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[4].DllName,(char*)CONVERSIONS_DLL); 6837 lcml_dsp->NodeInfo.AllUUIDs[4].eDllType = DLL_DEPENDENT; 6838 6839 6840 lcml_dsp->SegID = 0; 6841 lcml_dsp->Timeout = -1; 6842 lcml_dsp->Alignment = 0; 6843 lcml_dsp->Priority = 5; 6844 6845 if(pComponentPrivate->ProcessMode == 0){ 6846 if(pComponentPrivate->wmvProfile == VIDDEC_WMV_PROFILEMAX) 6847 { 6848 if ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 640) || 6849 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 480)) { 6850 lcml_dsp->ProfileID = 4; 6851 } 6852 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 640) && 6853 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 352)) || 6854 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 480) && 6855 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 288))) { 6856 lcml_dsp->ProfileID = 2; 6857 } 6858 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 352) && 6859 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 176)) || 6860 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 288) && 6861 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 144))) { 6862 lcml_dsp->ProfileID = 1; 6863 } 6864 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 176) && 6865 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth >= 16)) || 6866 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 144) && 6867 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight >= 16))) { 6868 lcml_dsp->ProfileID = 0; 6869 } 6870 else { 6871 eError = OMX_ErrorUnsupportedSetting; 6872 goto EXIT; 6873 } 6874 } 6875 else 6876 { 6877 switch(pComponentPrivate->wmvProfile) 6878 { 6879 case VIDDEC_WMV_PROFILE0: 6880 lcml_dsp->ProfileID = VIDDEC_WMV_PROFILE_ID0; 6881 break; 6882 case VIDDEC_WMV_PROFILE1: 6883 lcml_dsp->ProfileID = VIDDEC_WMV_PROFILE_ID1; 6884 break; 6885 case VIDDEC_WMV_PROFILE2: 6886 lcml_dsp->ProfileID = VIDDEC_WMV_PROFILE_ID2; 6887 break; 6888 default: 6889 { 6890 eError = OMX_ErrorBadParameter; 6891 goto EXIT; 6892 } 6893 } 6894 } 6895 } else if(pComponentPrivate->ProcessMode == 1) 6896 { 6897 switch(pComponentPrivate->wmvProfile) 6898 { 6899 case VIDDEC_WMV_PROFILE3: 6900 lcml_dsp->ProfileID = VIDDEC_WMV_PROFILE_ID3; 6901 break; 6902 case VIDDEC_WMV_PROFILE4: 6903 lcml_dsp->ProfileID = VIDDEC_WMV_PROFILE_ID4; 6904 break; 6905 case VIDDEC_WMV_PROFILE5: 6906 lcml_dsp->ProfileID = VIDDEC_WMV_PROFILE_ID5; 6907 break; 6908 case VIDDEC_WMV_PROFILE6: 6909 lcml_dsp->ProfileID = VIDDEC_WMV_PROFILE_ID6; 6910 break; 6911 case VIDDEC_WMV_PROFILE7: 6912 lcml_dsp->ProfileID = VIDDEC_WMV_PROFILE_ID7; 6913 break; 6914 case VIDDEC_WMV_PROFILE8: 6915 lcml_dsp->ProfileID = VIDDEC_WMV_PROFILE_ID8; 6916 break; 6917 case VIDDEC_WMV_PROFILEMAX: 6918 lcml_dsp->ProfileID = VIDDEC_WMV_PROFILE_ID8; 6919 break; 6920 default: 6921 eError = OMX_ErrorBadParameter; 6922 goto EXIT; 6923 } 6924 } 6925 else 6926 { 6927 eError = OMX_ErrorUnsupportedSetting; 6928 goto EXIT; 6929 } 6930 6931 OMX_MALLOC_STRUCT(pCreatePhaseArgs, WMV9DEC_SNCreatePhArg,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 6932 if (pCreatePhaseArgs == NULL) { 6933 eError = OMX_ErrorInsufficientResources; 6934 goto EXIT; 6935 } 6936 pCreatePhaseArgs->unNumOfStreams = 2; 6937 pCreatePhaseArgs->unInputStreamID = 0; 6938 pCreatePhaseArgs->unInputBufferType = 0; 6939 pCreatePhaseArgs->unInputNumBufsPerStream = (OMX_U16)nInpBuff; 6940 pCreatePhaseArgs->unOutputStreamID = 1; 6941 pCreatePhaseArgs->unOutputBufferType = 0; 6942 pCreatePhaseArgs->unOutputNumBufsPerStream = (OMX_U16)nOutBuff; 6943 pCreatePhaseArgs->ulMaxWidth = (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth); 6944 pCreatePhaseArgs->ulMaxHeight = (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight); 6945 6946 if (pComponentPrivate->nWMVFileType != VIDDEC_WMV_ELEMSTREAM) { 6947 pComponentPrivate->pBufferRCV.sStructRCV.nVertSize = (OMX_U32)(pComponentPrivate->pInPortDef->format.video.nFrameHeight); 6948 pComponentPrivate->pBufferRCV.sStructRCV.nHorizSize = (OMX_U32)(pComponentPrivate->pInPortDef->format.video.nFrameWidth); 6949 } 6950 6951 if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT422) { 6952 pCreatePhaseArgs->ulYUVFormat = WMV9VIDDEC_YUVFORMAT_INTERLEAVED422; 6953 } 6954 else if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT420) { 6955 pCreatePhaseArgs->ulYUVFormat = WMV9VIDDEC_YUVFORMAT_PLANAR420; 6956 } 6957 else 6958 { 6959 OMX_PRDSP4(pComponentPrivate->dbg, "Incorrect Color format %x\n",pComponentPrivate->pOutPortDef->format.video.eColorFormat); 6960 eError = OMX_ErrorUnsupportedSetting; 6961 goto EXIT; 6962 } 6963 6964 pCreatePhaseArgs->ulMaxFrameRate = 0; 6965 pCreatePhaseArgs->ulMaxBitRate = 0; 6966 pCreatePhaseArgs->ulDataEndianness = 1; 6967 pCreatePhaseArgs->ulProfile = -1; 6968 pCreatePhaseArgs->ulMaxLevel = -1; 6969 pCreatePhaseArgs->ulProcessMode = pComponentPrivate->ProcessMode; 6970 pCreatePhaseArgs->lPreRollBufConfig = 0; 6971 pCreatePhaseArgs->bCopiedCCDBuffer = 0; 6972 6973 if (pComponentPrivate->nWMVFileType == VIDDEC_WMV_ELEMSTREAM) { 6974 pCreatePhaseArgs->usIsElementaryStream = VIDDEC_SN_WMV_ELEMSTREAM; 6975 } 6976 else { 6977 pCreatePhaseArgs->usIsElementaryStream = VIDDEC_SN_WMV_RCVSTREAM; 6978 } 6979 6980 pCreatePhaseArgs->endArgs = END_OF_CR_PHASE_ARGS; 6981 6982 lcml_dsp->pCrPhArgs = (OMX_U16 *) pCreatePhaseArgs; 6983 cb.LCML_Callback = (void *) VIDDEC_LCML_Callback; 6984 6985 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 6986 pComponentPrivate->pLCML != NULL){ 6987 eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, NULL, &pLcmlHandle, NULL, &cb); 6988 if (eError != OMX_ErrorNone) { 6989 OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...%x\n",eError); 6990 eError = OMX_ErrorHardware; 6991 goto EXIT; 6992 } 6993 } 6994 else { 6995 eError = OMX_ErrorHardware; 6996 goto EXIT; 6997 } 6998 EXIT: 6999 if ( pCreatePhaseArgs != NULL ) 7000 free(pCreatePhaseArgs); 7001 pCreatePhaseArgs = NULL; 7002 7003 OMX_PRDSP1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 7004 return eError; 7005 } 7006 7007 7008 7009 /*-------------------------------------------------------------------*/ 7010 /** 7011 * Function to fill DSP structures via LCML 7012 * 7013 * 7014 * 7015 * @retval OMX_NoError Success, ready to roll 7016 * 7017 **/ 7018 /*-------------------------------------------------------------------*/ 7019 7020 OMX_ERRORTYPE VIDDEC_InitDSP_H264Dec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) 7021 { 7022 OMX_ERRORTYPE eError = OMX_ErrorNone; 7023 LCML_DSP_INTERFACE *pLcmlHandle = NULL; 7024 LCML_DSP *lcml_dsp = NULL; 7025 OMX_U32 nInpBuff = MAX_PRIVATE_IN_BUFFERS; 7026 OMX_U32 nInpBuffSize = 0; 7027 OMX_U32 nOutBuff = MAX_PRIVATE_OUT_BUFFERS; 7028 OMX_U32 nOutBuffSize = 0; 7029 H264VDEC_SNCreatePhArg* pCreatePhaseArgs = NULL; 7030 LCML_CALLBACKTYPE cb; 7031 OMX_U32 nFrameWidth = 0; 7032 OMX_U32 nFrameHeight = 0; 7033 7034 OMX_PRDSP1(pComponentPrivate->dbg, "+++ENTERING\n"); 7035 7036 /* Get number of input and output buffers */ 7037 nInpBuff = pComponentPrivate->pInPortDef->nBufferCountActual; 7038 nOutBuff = pComponentPrivate->pOutPortDef->nBufferCountActual; 7039 7040 /* Back it up for further use in this function */ 7041 nInpBuffSize = pComponentPrivate->pInPortDef->nBufferSize; 7042 nOutBuffSize = pComponentPrivate->pOutPortDef->nBufferSize; 7043 7044 pLcmlHandle = (LCML_DSP_INTERFACE *)pComponentPrivate->pLCML; 7045 lcml_dsp = (((LCML_DSP_INTERFACE*)pLcmlHandle)->dspCodec); 7046 7047 lcml_dsp->DeviceInfo.TypeofDevice = 0; 7048 lcml_dsp->DeviceInfo.DspStream = NULL; 7049 7050 lcml_dsp->In_BufInfo.nBuffers = nInpBuff; 7051 lcml_dsp->In_BufInfo.nSize = nInpBuffSize; 7052 lcml_dsp->In_BufInfo.DataTrMethod = DMM_METHOD; 7053 7054 lcml_dsp->Out_BufInfo.nBuffers = nOutBuff; 7055 lcml_dsp->Out_BufInfo.nSize = nOutBuffSize; 7056 lcml_dsp->Out_BufInfo.DataTrMethod = DMM_METHOD; 7057 7058 lcml_dsp->NodeInfo.nNumOfDLLs = OMX_H264DEC_NUM_DLLS; 7059 lcml_dsp->NodeInfo.AllUUIDs[0].uuid = (struct DSP_UUID *)&H264VDSOCKET_TI_UUID; 7060 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[0].DllName,(char*)H264_DEC_NODE_DLL); 7061 lcml_dsp->NodeInfo.AllUUIDs[0].eDllType = DLL_NODEOBJECT; 7062 7063 lcml_dsp->NodeInfo.AllUUIDs[1].uuid = (struct DSP_UUID *)&H264VDSOCKET_TI_UUID; 7064 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[1].DllName,(char*)H264_DEC_NODE_DLL); 7065 lcml_dsp->NodeInfo.AllUUIDs[1].eDllType = DLL_DEPENDENT; 7066 7067 lcml_dsp->NodeInfo.AllUUIDs[2].uuid = (struct DSP_UUID *)&USN_UUID; 7068 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[2].DllName,(char*)USN_DLL); 7069 lcml_dsp->NodeInfo.AllUUIDs[2].eDllType = DLL_DEPENDENT; 7070 7071 lcml_dsp->NodeInfo.AllUUIDs[3].uuid = (struct DSP_UUID *)&RINGIO_TI_UUID; 7072 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[3].DllName,(char*)RINGIO_NODE_DLL); 7073 lcml_dsp->NodeInfo.AllUUIDs[3].eDllType = DLL_DEPENDENT; 7074 7075 lcml_dsp->NodeInfo.AllUUIDs[4].uuid = (struct DSP_UUID *)&CONVERSIONS_UUID; 7076 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[4].DllName,(char*)CONVERSIONS_DLL); 7077 lcml_dsp->NodeInfo.AllUUIDs[4].eDllType = DLL_DEPENDENT; 7078 7079 lcml_dsp->SegID = 0; 7080 lcml_dsp->Timeout = -1; 7081 lcml_dsp->Alignment = 0; 7082 lcml_dsp->Priority = 5; 7083 7084 if(pComponentPrivate->ProcessMode == 0){ 7085 if ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 352) || 7086 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 288)) { 7087 lcml_dsp->ProfileID = 3; 7088 } 7089 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 352) && 7090 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 176)) || 7091 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 288) && 7092 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 144))) { 7093 lcml_dsp->ProfileID = 2; 7094 } 7095 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 176) && 7096 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth >= 16)) || 7097 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 144) && 7098 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight >= 16))) { 7099 lcml_dsp->ProfileID = 1; 7100 } 7101 else { 7102 eError = OMX_ErrorUnsupportedSetting; 7103 goto EXIT; 7104 } 7105 } 7106 else if(pComponentPrivate->ProcessMode == 1) { 7107 /*OMX_VIDEO_AVCLevelMax*/ 7108 switch(pComponentPrivate->pH264->eLevel) { 7109 case OMX_VIDEO_AVCLevel1: 7110 lcml_dsp->ProfileID = 8; 7111 break; 7112 case OMX_VIDEO_AVCLevel1b: 7113 lcml_dsp->ProfileID = 9; 7114 break; 7115 case OMX_VIDEO_AVCLevel11: 7116 lcml_dsp->ProfileID = 10; 7117 break; 7118 case OMX_VIDEO_AVCLevel12: 7119 lcml_dsp->ProfileID = 11; 7120 break; 7121 case OMX_VIDEO_AVCLevel13: 7122 case OMX_VIDEO_AVCLevel2: 7123 lcml_dsp->ProfileID = 12; 7124 break; 7125 case OMX_VIDEO_AVCLevel21: 7126 case OMX_VIDEO_AVCLevel22: 7127 lcml_dsp->ProfileID = 13; 7128 break; 7129 default: 7130 lcml_dsp->ProfileID = 14; 7131 break; 7132 } 7133 } 7134 /*add code to error*/ 7135 OMX_PRDSP1(pComponentPrivate->dbg, "lcml_dsp->ProfileID = %lu\n", lcml_dsp->ProfileID); 7136 OMX_MALLOC_STRUCT(pCreatePhaseArgs, H264VDEC_SNCreatePhArg,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 7137 if (pCreatePhaseArgs == NULL) { 7138 eError = OMX_ErrorInsufficientResources; 7139 goto EXIT; 7140 } 7141 7142 nFrameWidth = pComponentPrivate->pInPortDef->format.video.nFrameWidth; 7143 nFrameHeight = pComponentPrivate->pInPortDef->format.video.nFrameHeight; 7144 if (nFrameWidth & 0xF) nFrameWidth = (nFrameWidth & 0xFFF0) + 0x10; 7145 if (nFrameHeight & 0xF) nFrameHeight = (nFrameHeight & 0xFFF0) + 0x10; 7146 7147 pCreatePhaseArgs->unNumOfStreams = 2; 7148 pCreatePhaseArgs->unInputStreamID = 0; 7149 pCreatePhaseArgs->unInputBufferType = 0; 7150 pCreatePhaseArgs->unInputNumBufsPerStream = (OMX_U16)nInpBuff; 7151 pCreatePhaseArgs->unOutputStreamID = 1; 7152 pCreatePhaseArgs->unOutputBufferType = 0; 7153 pCreatePhaseArgs->unOutputNumBufsPerStream = (OMX_U16)nOutBuff; 7154 pCreatePhaseArgs->ulMaxWidth = nFrameWidth; 7155 pCreatePhaseArgs->ulMaxHeight = nFrameHeight; 7156 7157 7158 if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT422) { 7159 pCreatePhaseArgs->ulYUVFormat = H264VIDDEC_YUVFORMAT_INTERLEAVED422; 7160 } 7161 else if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT420) { 7162 pCreatePhaseArgs->ulYUVFormat = H264VIDDEC_YUVFORMAT_PLANAR420; 7163 } 7164 else 7165 { 7166 OMX_PRDSP4(pComponentPrivate->dbg, "Incorrect Color format %x\n",pComponentPrivate->pOutPortDef->format.video.eColorFormat); 7167 eError = OMX_ErrorUnsupportedSetting; 7168 goto EXIT; 7169 } 7170 7171 pCreatePhaseArgs->ulMaxFrameRate = 0; 7172 pCreatePhaseArgs->ulMaxBitRate = 0; 7173 pCreatePhaseArgs->ulDataEndianness = 1; 7174 pCreatePhaseArgs->ulProfile = 0; 7175 pCreatePhaseArgs->ulMaxLevel = -1; 7176 pCreatePhaseArgs->ulProcessMode = pComponentPrivate->ProcessMode; 7177 pCreatePhaseArgs->lPreRollBufConfig = 0; 7178 pCreatePhaseArgs->ulBitStreamFormat = (pComponentPrivate->H264BitStreamFormat>0?1:0); 7179 7180 pCreatePhaseArgs->ulDisplayWidth = 0; 7181 pCreatePhaseArgs->endArgs = END_OF_CR_PHASE_ARGS; 7182 7183 memcpy (pComponentPrivate->arr, pCreatePhaseArgs, sizeof(H264VDEC_SNCreatePhArg)); 7184 lcml_dsp->pCrPhArgs = pComponentPrivate->arr; 7185 cb.LCML_Callback = (void *) VIDDEC_LCML_Callback; 7186 7187 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 7188 pComponentPrivate->pLCML != NULL){ 7189 eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, NULL, &pLcmlHandle, NULL, &cb); 7190 if (eError != OMX_ErrorNone) { 7191 OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...%x\n",eError); 7192 eError = OMX_ErrorHardware; 7193 goto EXIT; 7194 } 7195 } 7196 else { 7197 eError = OMX_ErrorHardware; 7198 goto EXIT; 7199 } 7200 EXIT: 7201 if (pCreatePhaseArgs) { 7202 free(pCreatePhaseArgs); 7203 pCreatePhaseArgs = NULL; 7204 } 7205 OMX_PRDSP1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 7206 return eError; 7207 } 7208 7209 /*-------------------------------------------------------------------*/ 7210 /** 7211 * Function to fill DSP structures via LCML 7212 * 7213 * 7214 * 7215 * @retval OMX_NoError Success, ready to roll 7216 * 7217 **/ 7218 /*-------------------------------------------------------------------*/ 7219 7220 OMX_ERRORTYPE VIDDEC_InitDSP_Mpeg4Dec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) 7221 { 7222 OMX_ERRORTYPE eError = OMX_ErrorNone; 7223 LCML_DSP_INTERFACE *pLcmlHandle = NULL; 7224 LCML_DSP *lcml_dsp = NULL; 7225 OMX_U32 nInpBuff = MAX_PRIVATE_IN_BUFFERS; 7226 OMX_U32 nInpBuffSize = 0; 7227 OMX_U32 nOutBuff = MAX_PRIVATE_OUT_BUFFERS; 7228 OMX_U32 nOutBuffSize = 0; 7229 MP4VD_GPP_SN_Obj_CreatePhase* pCreatePhaseArgs = NULL; 7230 LCML_CALLBACKTYPE cb; 7231 7232 OMX_PRDSP1(pComponentPrivate->dbg, "+++ENTERING\n"); 7233 /* Get number of input and output buffers */ 7234 nInpBuff = pComponentPrivate->pInPortDef->nBufferCountActual; 7235 nOutBuff = pComponentPrivate->pOutPortDef->nBufferCountActual; 7236 7237 /* Back it up for further use in this function */ 7238 nInpBuffSize = pComponentPrivate->pInPortDef->nBufferSize; 7239 nOutBuffSize = pComponentPrivate->pOutPortDef->nBufferSize; 7240 7241 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 7242 lcml_dsp = (((LCML_DSP_INTERFACE*)pLcmlHandle)->dspCodec); 7243 7244 lcml_dsp->DeviceInfo.TypeofDevice = 0; 7245 lcml_dsp->DeviceInfo.DspStream = NULL; 7246 7247 lcml_dsp->In_BufInfo.nBuffers = nInpBuff; 7248 lcml_dsp->In_BufInfo.nSize = nInpBuffSize; 7249 lcml_dsp->In_BufInfo.DataTrMethod = DMM_METHOD; 7250 7251 lcml_dsp->Out_BufInfo.nBuffers = nOutBuff; 7252 lcml_dsp->Out_BufInfo.nSize = nOutBuffSize; 7253 lcml_dsp->Out_BufInfo.DataTrMethod = DMM_METHOD; 7254 7255 lcml_dsp->NodeInfo.nNumOfDLLs = OMX_MP4DEC_NUM_DLLS; 7256 OMX_U32 nFrameWidth = pComponentPrivate->pOutPortDef->format.video.nFrameWidth; 7257 OMX_U32 nFrameHeight = pComponentPrivate->pOutPortDef->format.video.nFrameHeight; 7258 7259 nFrameWidth = (nFrameWidth + 0x0f) & ~0x0f; 7260 nFrameHeight = (nFrameHeight + 0x0f) & ~0x0f; 7261 if (nFrameWidth * nFrameHeight > 880 * 720) 7262 { 7263 lcml_dsp->NodeInfo.AllUUIDs[0].uuid = (struct DSP_UUID *)&MP4D720PSOCKET_TI_UUID; 7264 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[0].DllName,(char*)MP4720P_DEC_NODE_DLL); 7265 lcml_dsp->NodeInfo.AllUUIDs[0].eDllType = DLL_NODEOBJECT; 7266 7267 lcml_dsp->NodeInfo.AllUUIDs[1].uuid = (struct DSP_UUID *)&MP4D720PSOCKET_TI_UUID; 7268 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[1].DllName,(char*)MP4720P_DEC_NODE_DLL); 7269 lcml_dsp->NodeInfo.AllUUIDs[1].eDllType = DLL_DEPENDENT; 7270 7271 pComponentPrivate->eMBErrorReport.bEnabled = FALSE; 7272 pComponentPrivate->MPEG4Codec_IsTI = FALSE; 7273 } 7274 else 7275 { 7276 lcml_dsp->NodeInfo.AllUUIDs[0].uuid = (struct DSP_UUID *)&MP4DSOCKET_TI_UUID; 7277 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[0].DllName,(char*)MP4_DEC_NODE_DLL); 7278 lcml_dsp->NodeInfo.AllUUIDs[0].eDllType = DLL_NODEOBJECT; 7279 7280 lcml_dsp->NodeInfo.AllUUIDs[1].uuid = (struct DSP_UUID *)&MP4DSOCKET_TI_UUID; 7281 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[1].DllName,(char*)MP4_DEC_NODE_DLL); 7282 lcml_dsp->NodeInfo.AllUUIDs[1].eDllType = DLL_DEPENDENT; 7283 pComponentPrivate->MPEG4Codec_IsTI = TRUE; 7284 } 7285 7286 lcml_dsp->NodeInfo.AllUUIDs[2].uuid = (struct DSP_UUID *)&RINGIO_TI_UUID; 7287 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[2].DllName,(char*)RINGIO_NODE_DLL); 7288 lcml_dsp->NodeInfo.AllUUIDs[2].eDllType = DLL_DEPENDENT; 7289 7290 lcml_dsp->NodeInfo.AllUUIDs[3].uuid = (struct DSP_UUID *)&USN_UUID; 7291 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[3].DllName,(char*)USN_DLL); 7292 lcml_dsp->NodeInfo.AllUUIDs[3].eDllType = DLL_DEPENDENT; 7293 7294 lcml_dsp->NodeInfo.AllUUIDs[4].uuid = (struct DSP_UUID *)&CONVERSIONS_UUID; 7295 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[4].DllName,(char*)CONVERSIONS_DLL); 7296 lcml_dsp->NodeInfo.AllUUIDs[4].eDllType = DLL_DEPENDENT; 7297 7298 lcml_dsp->SegID = 0; 7299 lcml_dsp->Timeout = -1; 7300 lcml_dsp->Alignment = 0; 7301 lcml_dsp->Priority = 5; 7302 7303 if (nFrameWidth * nFrameHeight > 640 * 480) { 7304 lcml_dsp->ProfileID = 4; 7305 } 7306 else if (nFrameWidth * nFrameHeight > 352 * 288) { 7307 lcml_dsp->ProfileID = 3; 7308 } 7309 else if (nFrameWidth * nFrameHeight > 176 * 144) { 7310 lcml_dsp->ProfileID = 2; 7311 } 7312 else if (nFrameWidth * nFrameHeight >= 16 * 16) { 7313 lcml_dsp->ProfileID = 1; 7314 } 7315 else { 7316 eError = OMX_ErrorUnsupportedSetting; 7317 goto EXIT; 7318 } 7319 7320 OMX_MALLOC_STRUCT(pCreatePhaseArgs, MP4VD_GPP_SN_Obj_CreatePhase,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 7321 if (pCreatePhaseArgs == NULL) { 7322 eError = OMX_ErrorInsufficientResources; 7323 goto EXIT; 7324 } 7325 pCreatePhaseArgs->unNumOfStreams = 2; 7326 pCreatePhaseArgs->unInputStreamID = 0; 7327 pCreatePhaseArgs->unInputBufferType = 0; 7328 pCreatePhaseArgs->unlInputNumBufsPerStream = (OMX_U16)(pComponentPrivate->pInPortDef->nBufferCountActual); 7329 pCreatePhaseArgs->unOutputStreamID = 1; 7330 pCreatePhaseArgs->unOutputBufferType = 0; 7331 pCreatePhaseArgs->unOutputNumBufsPerStream = (OMX_U16)(pComponentPrivate->pOutPortDef->nBufferCountActual); 7332 7333 /* ulMaxWidth and ulMaxHeight needs to be multiples of 16. */ 7334 nFrameWidth = pComponentPrivate->pInPortDef->format.video.nFrameWidth; 7335 nFrameHeight = pComponentPrivate->pInPortDef->format.video.nFrameHeight; 7336 if (nFrameWidth & 0xF) nFrameWidth = (nFrameWidth & 0xFFF0) + 0x10; 7337 if (nFrameHeight & 0xF) nFrameHeight = (nFrameHeight & 0xFFF0) + 0x10; 7338 7339 pCreatePhaseArgs->ulMaxWidth = (OMX_U16)(nFrameWidth); 7340 pCreatePhaseArgs->ulMaxHeight = (OMX_U16)(nFrameHeight); 7341 7342 if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT422) { 7343 pCreatePhaseArgs->ulYUVFormat = MP4VIDDEC_YUVFORMAT_INTERLEAVED422; 7344 } 7345 else if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT420) { 7346 pCreatePhaseArgs->ulYUVFormat = MP4VIDDEC_YUVFORMAT_PLANAR420; 7347 } 7348 else 7349 { 7350 OMX_PRDSP4(pComponentPrivate->dbg, "Incorrect Color format %x\n",pComponentPrivate->pOutPortDef->format.video.eColorFormat); 7351 OMX_PRDSP1(pComponentPrivate->dbg, "lcml_dsp->ProfileID = %lu\n", lcml_dsp->ProfileID); 7352 eError = OMX_ErrorUnsupportedSetting; 7353 goto EXIT; 7354 } 7355 7356 OMX_PRBUFFER1(pComponentPrivate->dbg, "pCreatePhaseArgs->ulMaxWidth %lu pCreatePhaseArgs->ulMaxHeight %lu\n", 7357 pCreatePhaseArgs->ulMaxWidth,pCreatePhaseArgs->ulMaxHeight); 7358 7359 pCreatePhaseArgs->ulMaxFrameRate = VIDDEC_MAX_FRAMERATE; 7360 pCreatePhaseArgs->ulMaxBitRate = VIDDEC_MAX_BITRATE; 7361 pCreatePhaseArgs->ulDataEndianness = 1; 7362 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4){ 7363 pCreatePhaseArgs->ulProfile = 0; 7364 } 7365 else { 7366 pCreatePhaseArgs->ulProfile = 8; 7367 } 7368 pCreatePhaseArgs->ulMaxLevel = -1; 7369 pCreatePhaseArgs->ulProcessMode = pComponentPrivate->ProcessMode; 7370 pCreatePhaseArgs->ulPreRollBufConfig = 0; 7371 pCreatePhaseArgs->ulDisplayWidth = 0; 7372 pCreatePhaseArgs->endArgs = END_OF_CR_PHASE_ARGS; 7373 7374 memcpy(pComponentPrivate->arr, pCreatePhaseArgs, sizeof(MP4VD_GPP_SN_Obj_CreatePhase)); 7375 lcml_dsp->pCrPhArgs = pComponentPrivate->arr; 7376 cb.LCML_Callback = (void*) VIDDEC_LCML_Callback; 7377 7378 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 7379 pComponentPrivate->pLCML != NULL){ 7380 pComponentPrivate->eLCMLState = VidDec_LCML_State_Init; 7381 7382 eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, NULL, &pLcmlHandle, NULL, &cb); 7383 if (eError != OMX_ErrorNone) { 7384 OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...%x\n",eError); 7385 eError = OMX_ErrorHardware; 7386 goto EXIT; 7387 } 7388 } 7389 else { 7390 eError = OMX_ErrorHardware; 7391 goto EXIT; 7392 } 7393 EXIT: 7394 if (pCreatePhaseArgs) { 7395 free(pCreatePhaseArgs); 7396 pCreatePhaseArgs = NULL; 7397 } 7398 OMX_PRDSP1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 7399 return eError; 7400 } 7401 7402 7403 /*-------------------------------------------------------------------*/ 7404 /** 7405 * Function to fill DSP structures via LCML 7406 * 7407 * 7408 * 7409 * @retval OMX_NoError Success, ready to roll 7410 * 7411 **/ 7412 /*-------------------------------------------------------------------*/ 7413 7414 OMX_ERRORTYPE VIDDEC_InitDSP_Mpeg2Dec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) 7415 { 7416 OMX_ERRORTYPE eError = OMX_ErrorNone; 7417 LCML_DSP_INTERFACE *pLcmlHandle = NULL; 7418 LCML_DSP *lcml_dsp = NULL; 7419 OMX_U32 nInpBuff = MAX_PRIVATE_IN_BUFFERS; 7420 OMX_U32 nInpBuffSize = 0; 7421 OMX_U32 nOutBuff = MAX_PRIVATE_OUT_BUFFERS; 7422 OMX_U32 nOutBuffSize = 0; 7423 MP2VDEC_SNCreatePhArg* pCreatePhaseArgs = NULL; 7424 LCML_CALLBACKTYPE cb; 7425 7426 OMX_PRDSP1(pComponentPrivate->dbg, "+++ENTERING\n"); 7427 /* Get number of input and output buffers */ 7428 nInpBuff = pComponentPrivate->pInPortDef->nBufferCountActual; 7429 nOutBuff = pComponentPrivate->pOutPortDef->nBufferCountActual; 7430 7431 /* Back it up for further use in this function */ 7432 nInpBuffSize = pComponentPrivate->pInPortDef->nBufferSize; 7433 nOutBuffSize = pComponentPrivate->pOutPortDef->nBufferSize; 7434 7435 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 7436 lcml_dsp = (((LCML_DSP_INTERFACE*)pLcmlHandle)->dspCodec); 7437 7438 lcml_dsp->DeviceInfo.TypeofDevice = 0; 7439 lcml_dsp->DeviceInfo.DspStream = NULL; 7440 7441 lcml_dsp->In_BufInfo.nBuffers = nInpBuff; 7442 lcml_dsp->In_BufInfo.nSize = nInpBuffSize; 7443 lcml_dsp->In_BufInfo.DataTrMethod = DMM_METHOD; 7444 7445 lcml_dsp->Out_BufInfo.nBuffers = nOutBuff; 7446 lcml_dsp->Out_BufInfo.nSize = nOutBuffSize; 7447 lcml_dsp->Out_BufInfo.DataTrMethod = DMM_METHOD; 7448 7449 lcml_dsp->NodeInfo.nNumOfDLLs = OMX_MP2DEC_NUM_DLLS; 7450 lcml_dsp->NodeInfo.AllUUIDs[0].uuid = (struct DSP_UUID *)&MP2DSOCKET_TI_UUID; 7451 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[0].DllName,(char*)MP2_DEC_NODE_DLL); 7452 lcml_dsp->NodeInfo.AllUUIDs[0].eDllType = DLL_NODEOBJECT; 7453 7454 lcml_dsp->NodeInfo.AllUUIDs[1].uuid = (struct DSP_UUID *)&MP2DSOCKET_TI_UUID; 7455 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[1].DllName,(char*)MP2_DEC_NODE_DLL); 7456 lcml_dsp->NodeInfo.AllUUIDs[1].eDllType = DLL_DEPENDENT; 7457 7458 lcml_dsp->NodeInfo.AllUUIDs[2].uuid = (struct DSP_UUID *)&RINGIO_TI_UUID; 7459 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[2].DllName,(char*)RINGIO_NODE_DLL); 7460 lcml_dsp->NodeInfo.AllUUIDs[2].eDllType = DLL_DEPENDENT; 7461 7462 lcml_dsp->NodeInfo.AllUUIDs[3].uuid = (struct DSP_UUID *)&USN_UUID; 7463 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[3].DllName,(char*)USN_DLL); 7464 lcml_dsp->NodeInfo.AllUUIDs[3].eDllType = DLL_DEPENDENT; 7465 7466 lcml_dsp->SegID = 0; 7467 lcml_dsp->Timeout = -1; 7468 lcml_dsp->Alignment = 0; 7469 lcml_dsp->Priority = 5; 7470 7471 if(pComponentPrivate->ProcessMode == 0){ 7472 if ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 352) || 7473 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 288)) { 7474 lcml_dsp->ProfileID = 3; 7475 } 7476 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 352) && 7477 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 176)) || 7478 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 288) && 7479 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 144))) { 7480 lcml_dsp->ProfileID = 2; 7481 } 7482 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 176) && 7483 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth >= 16)) || 7484 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 144) && 7485 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight >= 16))) { 7486 lcml_dsp->ProfileID = 1; 7487 } 7488 else { 7489 eError = OMX_ErrorUnsupportedSetting; 7490 goto EXIT; 7491 } 7492 } 7493 else if(pComponentPrivate->ProcessMode == 1) { 7494 if ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 352) || 7495 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 288)) { 7496 lcml_dsp->ProfileID = 3; 7497 } 7498 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 352) && 7499 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 176)) || 7500 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 288) && 7501 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 144))) { 7502 lcml_dsp->ProfileID = 2; 7503 } 7504 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 176) && 7505 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth >= 16)) || 7506 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 144) && 7507 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight >= 16))) { 7508 lcml_dsp->ProfileID = 1; 7509 } 7510 else { 7511 eError = OMX_ErrorUnsupportedSetting; 7512 goto EXIT; 7513 } 7514 } 7515 7516 OMX_MALLOC_STRUCT(pCreatePhaseArgs, MP2VDEC_SNCreatePhArg,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 7517 if (pCreatePhaseArgs == NULL) { 7518 eError = OMX_ErrorInsufficientResources; 7519 goto EXIT; 7520 } 7521 pCreatePhaseArgs->unNumOfStreams = 2; 7522 pCreatePhaseArgs->unInputStreamID = 0; 7523 pCreatePhaseArgs->unInputBufferType = 0; 7524 pCreatePhaseArgs->unInputNumBufsPerStream = (OMX_U16)(pComponentPrivate->pInPortDef->nBufferCountActual); 7525 pCreatePhaseArgs->unOutputStreamID = 1; 7526 pCreatePhaseArgs->unOutputBufferType = 0; 7527 pCreatePhaseArgs->unOutputNumBufsPerStream = (OMX_U16)(pComponentPrivate->pOutPortDef->nBufferCountActual); 7528 pCreatePhaseArgs->ulMaxWidth = (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth); 7529 pCreatePhaseArgs->ulMaxHeight = (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight); 7530 7531 if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT422) { 7532 pCreatePhaseArgs->ulYUVFormat = MP2VIDDEC_YUVFORMAT_INTERLEAVED422; 7533 } 7534 else if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT420) { 7535 pCreatePhaseArgs->ulYUVFormat = MP2VIDDEC_YUVFORMAT_PLANAR420; 7536 } 7537 else 7538 { 7539 OMX_PRDSP4(pComponentPrivate->dbg, "Incorrect Color format %x\n",pComponentPrivate->pOutPortDef->format.video.eColorFormat); 7540 eError = OMX_ErrorUnsupportedSetting; 7541 goto EXIT; 7542 } 7543 7544 pCreatePhaseArgs->ulMaxFrameRate = 0; 7545 pCreatePhaseArgs->ulMaxBitRate = -1; 7546 pCreatePhaseArgs->ulDataEndianness = 1; 7547 pCreatePhaseArgs->ulProfile = 0; 7548 pCreatePhaseArgs->lMaxLevel = -1; 7549 pCreatePhaseArgs->ulProcessMode = pComponentPrivate->ProcessMode; 7550 pCreatePhaseArgs->lPreRollBufConfig = 0; 7551 pCreatePhaseArgs->ulDisplayWidth = 0; 7552 pCreatePhaseArgs->endArgs = END_OF_CR_PHASE_ARGS; 7553 7554 7555 memcpy(pComponentPrivate->arr, pCreatePhaseArgs, sizeof(MP2VDEC_SNCreatePhArg)); 7556 lcml_dsp->pCrPhArgs = pComponentPrivate->arr; 7557 cb.LCML_Callback = (void*) VIDDEC_LCML_Callback; 7558 7559 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 7560 pComponentPrivate->pLCML != NULL){ 7561 eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, NULL, &pLcmlHandle, NULL, &cb); 7562 if (eError != OMX_ErrorNone) { 7563 OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...%x\n",eError); 7564 eError = OMX_ErrorHardware; 7565 goto EXIT; 7566 } 7567 } 7568 else { 7569 eError = OMX_ErrorHardware; 7570 goto EXIT; 7571 } 7572 EXIT: 7573 if (pCreatePhaseArgs) { 7574 free(pCreatePhaseArgs); 7575 pCreatePhaseArgs = NULL; 7576 } 7577 OMX_PRDSP1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 7578 return eError; 7579 } 7580 7581 /*-------------------------------------------------------------------*/ 7582 /** 7583 * Function to fill DSP structures via LCML 7584 * 7585 * 7586 * 7587 * @retval OMX_NoError Success, ready to roll 7588 * 7589 **/ 7590 /*-------------------------------------------------------------------*/ 7591 7592 OMX_ERRORTYPE VIDDEC_InitDSP_SparkDec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) 7593 { 7594 OMX_ERRORTYPE eError = OMX_ErrorNone; 7595 LCML_DSP_INTERFACE *pLcmlHandle = NULL; 7596 LCML_DSP *lcml_dsp = NULL; 7597 OMX_U32 nInpBuff = MAX_PRIVATE_IN_BUFFERS; 7598 OMX_U32 nInpBuffSize = 0; 7599 OMX_U32 nOutBuff = MAX_PRIVATE_OUT_BUFFERS; 7600 OMX_U32 nOutBuffSize = 0; 7601 SPARKVD_GPP_SN_Obj_CreatePhase* pCreatePhaseArgs = NULL; 7602 LCML_CALLBACKTYPE cb; 7603 7604 OMX_PRDSP1(pComponentPrivate->dbg, "+++ENTERING\n"); 7605 /* Get number of input and output buffers */ 7606 nInpBuff = pComponentPrivate->pInPortDef->nBufferCountActual; 7607 nOutBuff = pComponentPrivate->pOutPortDef->nBufferCountActual; 7608 7609 /* Back it up for further use in this function */ 7610 nInpBuffSize = pComponentPrivate->pInPortDef->nBufferSize; 7611 nOutBuffSize = pComponentPrivate->pOutPortDef->nBufferSize; 7612 7613 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 7614 lcml_dsp = (((LCML_DSP_INTERFACE*)pLcmlHandle)->dspCodec); 7615 7616 lcml_dsp->DeviceInfo.TypeofDevice = 0; 7617 lcml_dsp->DeviceInfo.DspStream = NULL; 7618 7619 lcml_dsp->In_BufInfo.nBuffers = nInpBuff; 7620 lcml_dsp->In_BufInfo.nSize = nInpBuffSize; 7621 lcml_dsp->In_BufInfo.DataTrMethod = DMM_METHOD; 7622 7623 lcml_dsp->Out_BufInfo.nBuffers = nOutBuff; 7624 lcml_dsp->Out_BufInfo.nSize = nOutBuffSize; 7625 lcml_dsp->Out_BufInfo.DataTrMethod = DMM_METHOD; 7626 7627 lcml_dsp->NodeInfo.nNumOfDLLs = OMX_SPARKDEC_NUM_DLLS; 7628 lcml_dsp->NodeInfo.AllUUIDs[0].uuid = (struct DSP_UUID *)&SPARKDSOCKET_TI_UUID; 7629 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[0].DllName,(char*)SPARK_DEC_NODE_DLL); 7630 lcml_dsp->NodeInfo.AllUUIDs[0].eDllType = DLL_NODEOBJECT; 7631 7632 lcml_dsp->NodeInfo.AllUUIDs[1].uuid = (struct DSP_UUID *)&SPARKDSOCKET_TI_UUID; 7633 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[1].DllName,(char*)SPARK_DEC_NODE_DLL); 7634 lcml_dsp->NodeInfo.AllUUIDs[1].eDllType = DLL_DEPENDENT; 7635 7636 lcml_dsp->NodeInfo.AllUUIDs[2].uuid = (struct DSP_UUID *)&RINGIO_TI_UUID; 7637 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[2].DllName,(char*)RINGIO_NODE_DLL); 7638 lcml_dsp->NodeInfo.AllUUIDs[2].eDllType = DLL_DEPENDENT; 7639 7640 lcml_dsp->NodeInfo.AllUUIDs[3].uuid = (struct DSP_UUID *)&USN_UUID; 7641 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[3].DllName,(char*)USN_DLL); 7642 lcml_dsp->NodeInfo.AllUUIDs[3].eDllType = DLL_DEPENDENT; 7643 7644 lcml_dsp->NodeInfo.AllUUIDs[4].uuid = (struct DSP_UUID *)&CONVERSIONS_UUID; 7645 strcpy ((char*)lcml_dsp->NodeInfo.AllUUIDs[4].DllName,(char*)CONVERSIONS_DLL); 7646 lcml_dsp->NodeInfo.AllUUIDs[4].eDllType = DLL_DEPENDENT; 7647 7648 lcml_dsp->SegID = 0; 7649 lcml_dsp->Timeout = -1; 7650 lcml_dsp->Alignment = 0; 7651 lcml_dsp->Priority = 5; 7652 7653 7654 if(pComponentPrivate->ProcessMode == 0){ 7655 if ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 640) || 7656 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 480)) { 7657 lcml_dsp->ProfileID = 4; 7658 } 7659 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 640) && 7660 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 352)) || 7661 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 480) && 7662 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 288))) { 7663 lcml_dsp->ProfileID = 3; 7664 } 7665 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 352) && 7666 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 176)) || 7667 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 288) && 7668 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 144))) { 7669 lcml_dsp->ProfileID = 2; 7670 } 7671 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 176) && 7672 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth >= 16)) || 7673 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 144) && 7674 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight >= 16))) { 7675 lcml_dsp->ProfileID = 1; 7676 } 7677 else { 7678 eError = OMX_ErrorUnsupportedSetting; 7679 goto EXIT; 7680 } 7681 } 7682 else if(pComponentPrivate->ProcessMode == 1) { 7683 if ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 640) || 7684 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 480)) { 7685 lcml_dsp->ProfileID = 4; 7686 } 7687 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 640) && 7688 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 352)) || 7689 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 480) && 7690 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 288))) { 7691 lcml_dsp->ProfileID = 3; 7692 } 7693 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 352) && 7694 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth > 176)) || 7695 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 288) && 7696 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight > 144))) { 7697 lcml_dsp->ProfileID = 2; 7698 } 7699 else if (((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth <= 176) && 7700 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth >= 16)) || 7701 ((OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight <= 144) && 7702 (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight >= 16))) { 7703 lcml_dsp->ProfileID = 1; 7704 } 7705 else { 7706 eError = OMX_ErrorUnsupportedSetting; 7707 goto EXIT; 7708 } 7709 } 7710 7711 OMX_MALLOC_STRUCT(pCreatePhaseArgs, SPARKVD_GPP_SN_Obj_CreatePhase,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 7712 if (pCreatePhaseArgs == NULL) { 7713 eError = OMX_ErrorInsufficientResources; 7714 goto EXIT; 7715 } 7716 pCreatePhaseArgs->unNumOfStreams = 2; 7717 pCreatePhaseArgs->unInputStreamID = 0; 7718 pCreatePhaseArgs->unInputBufferType = 0; 7719 pCreatePhaseArgs->unlInputNumBufsPerStream = (OMX_U16)(pComponentPrivate->pInPortDef->nBufferCountActual); 7720 pCreatePhaseArgs->unOutputStreamID = 1; 7721 pCreatePhaseArgs->unOutputBufferType = 0; 7722 pCreatePhaseArgs->unOutputNumBufsPerStream = (OMX_U16)(pComponentPrivate->pOutPortDef->nBufferCountActual); 7723 pCreatePhaseArgs->ulMaxWidth = (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameWidth); 7724 pCreatePhaseArgs->ulMaxHeight = (OMX_U16)(pComponentPrivate->pInPortDef->format.video.nFrameHeight); 7725 7726 if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT422) { 7727 pCreatePhaseArgs->ulYUVFormat = SPARKVIDDEC_YUVFORMAT_INTERLEAVED422; 7728 } 7729 else if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT420) { 7730 pCreatePhaseArgs->ulYUVFormat = SPARKVIDDEC_YUVFORMAT_PLANAR420; 7731 } 7732 else 7733 { 7734 OMX_PRDSP4(pComponentPrivate->dbg, "Incorrect Color format %x\n",pComponentPrivate->pOutPortDef->format.video.eColorFormat); 7735 eError = OMX_ErrorUnsupportedSetting; 7736 goto EXIT; 7737 } 7738 7739 pCreatePhaseArgs->ulMaxFrameRate = 0; 7740 pCreatePhaseArgs->ulMaxBitRate = -1; 7741 pCreatePhaseArgs->ulDataEndianness = 1; 7742 pCreatePhaseArgs->ulProfile = 0; 7743 pCreatePhaseArgs->ulMaxLevel = -1; 7744 pCreatePhaseArgs->ulProcessMode = pComponentPrivate->ProcessMode; 7745 pCreatePhaseArgs->ulPreRollBufConfig = 0; 7746 pCreatePhaseArgs->endArgs = END_OF_CR_PHASE_ARGS; 7747 7748 memcpy(pComponentPrivate->arr, pCreatePhaseArgs, sizeof(SPARKVD_GPP_SN_Obj_CreatePhase)); 7749 lcml_dsp->pCrPhArgs = pComponentPrivate->arr; 7750 cb.LCML_Callback = (void*) VIDDEC_LCML_Callback; 7751 7752 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 7753 pComponentPrivate->pLCML != NULL){ 7754 eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, NULL, &pLcmlHandle, NULL, &cb); 7755 if (eError != OMX_ErrorNone) { 7756 OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...%x\n",eError); 7757 eError = OMX_ErrorHardware; 7758 goto EXIT; 7759 } 7760 } 7761 else { 7762 eError = OMX_ErrorHardware; 7763 goto EXIT; 7764 } 7765 EXIT: 7766 if (pCreatePhaseArgs) { 7767 free(pCreatePhaseArgs); 7768 pCreatePhaseArgs = NULL; 7769 } 7770 OMX_PRDSP1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 7771 return eError; 7772 } 7773 7774 /* ========================================================================== */ 7775 /** 7776 * VIDDEC_Handle_InvalidState() Function called for a non recoverable error 7777 * 7778 * @param pComponentPrivate This is the pointer to the private structure 7779 * 7780 * @retval OMX_NoError Success, ready to roll 7781 * OMX_ErrorHardware If OMX_StateInvalid is the actual state 7782 **/ 7783 /* ========================================================================== */ 7784 OMX_ERRORTYPE VIDDEC_Handle_InvalidState (VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) 7785 { 7786 OMX_ERRORTYPE eError = OMX_ErrorNone; 7787 7788 OMX_PRSTATE1(pComponentPrivate->dbg, "+++ENTERING\n"); 7789 OMX_PRSTATE2(pComponentPrivate->dbg, "pComponentPrivate 0x%p\n", (int*)pComponentPrivate); 7790 7791 if(pComponentPrivate->eState != OMX_StateInvalid) { 7792 pComponentPrivate->eState = OMX_StateInvalid; 7793 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 7794 pComponentPrivate->pHandle->pApplicationPrivate, 7795 OMX_EventError, 7796 OMX_ErrorInvalidState, 7797 OMX_TI_ErrorCritical, 7798 "Transitioning to Invalid State"); 7799 eError = OMX_ErrorNone; 7800 } 7801 else { 7802 eError = OMX_ErrorHardware; 7803 } 7804 OMX_PRSTATE1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 7805 return eError; 7806 } 7807 7808 7809 /* ========================================================================== */ 7810 /** 7811 * VIDDEC_PROPAGATE_MARK() Function called for propagate mark from input buffers to output buffers 7812 * 7813 * @param pComponentPrivate This is the pointer to the private structure 7814 * @param pBuffHead This is the pointer to the output buffer 7815 * 7816 * @retval OMX_NoError Success 7817 * OMX_ErrorUnsupportedSetting If CompressionFormat has not a valid value 7818 **/ 7819 /* ========================================================================== */ 7820 OMX_ERRORTYPE VIDDEC_Propagate_Mark(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, OMX_BUFFERHEADERTYPE *pBuffHead) 7821 { 7822 OMX_ERRORTYPE eError = OMX_ErrorNone; 7823 7824 if (pBuffHead->nFilledLen != 0) { 7825 pBuffHead->hMarkTargetComponent = pComponentPrivate->arrMarkBufIndex[pComponentPrivate->nInMarkBufIndex].hMarkTargetComponent; 7826 pBuffHead->pMarkData = pComponentPrivate->arrMarkBufIndex[pComponentPrivate->nInMarkBufIndex].pMarkData; 7827 pComponentPrivate->nOutMarkBufIndex++; 7828 pComponentPrivate->nOutMarkBufIndex %= VIDDEC_MAX_QUEUE_SIZE; 7829 eError = OMX_ErrorNone; 7830 } 7831 if(pBuffHead->hMarkTargetComponent == pComponentPrivate->pHandle) 7832 { 7833 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 7834 pComponentPrivate->pHandle->pApplicationPrivate, 7835 OMX_EventMark, 7836 0, 7837 0, 7838 pBuffHead->pMarkData); 7839 } 7840 7841 return eError; 7842 } 7843 7844 7845 7846 /* ========================================================================== */ 7847 /** 7848 * Callback() function will be called LCML component to write the msg 7849 * 7850 * @param msgBuffer This buffer will be returned by the LCML 7851 * 7852 * @retval OMX_NoError Success, ready to roll 7853 * OMX_Error_BadParameter The input parameter pointer is null 7854 **/ 7855 /* ========================================================================== */ 7856 7857 OMX_ERRORTYPE VIDDEC_LCML_Callback (TUsnCodecEvent event,void * argsCb [10]) 7858 { 7859 VIDDEC_COMPONENT_PRIVATE* pComponentPrivate = NULL; 7860 OMX_ERRORTYPE eError = OMX_ErrorNone; 7861 VIDDEC_BUFFER_PRIVATE* pBufferPrivate = NULL; 7862 OMX_S32 nRetVal = 0; 7863 7864 pComponentPrivate = (VIDDEC_COMPONENT_PRIVATE*)((LCML_DSP_INTERFACE*)argsCb[6])->pComponentPrivate; 7865 7866 #if 0 7867 switch(event) { 7868 case EMMCodecDspError: 7869 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecDspError (int)argsCb [0] %x (int)argsCb [4] %x (int)argsCb [5] %x\n",(int)argsCb [0],(int)argsCb [4],(int)argsCb [5]); 7870 break; 7871 7872 case EMMCodecInternalError: 7873 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecInternalError\n"); 7874 break; 7875 7876 case EMMCodecInitError: 7877 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecInitError\n"); 7878 break; 7879 7880 case EMMCodecDspMessageRecieved: 7881 OMX_PRDSP1(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecDspMessageRecieved\n"); 7882 break; 7883 case EMMCodecBufferProcessed: 7884 OMX_PRDSP0(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecBufferProcessed %x\n",(int)argsCb [0]); 7885 break; 7886 case EMMCodecProcessingStarted: 7887 OMX_PRDSP1(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecProcessingStarted\n"); 7888 break; 7889 7890 case EMMCodecProcessingPaused: 7891 OMX_PRDSP1(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecProcessingPaused\n"); 7892 break; 7893 7894 case EMMCodecProcessingStoped: 7895 OMX_PRDSP1(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecProcessingStoped\n"); 7896 break; 7897 7898 case EMMCodecProcessingEof: 7899 OMX_PRDSP1(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecProcessingEof\n"); 7900 break; 7901 case EMMCodecBufferNotProcessed: 7902 OMX_PRDSP2(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecBufferNotProcessed %x\n",(int)argsCb [0]); 7903 break; 7904 case EMMCodecAlgCtrlAck: 7905 OMX_PRDSP1(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecAlgCtrlAck\n"); 7906 break; 7907 7908 case EMMCodecStrmCtrlAck: 7909 OMX_PRDSP1(pComponentPrivate->dbg, "[LCML CALLBACK EVENT] EMMCodecStrmCtrlAck\n"); 7910 break; 7911 } 7912 #endif 7913 7914 OMX_PRDSP0(pComponentPrivate->dbg, "+++ENTERING\n"); 7915 OMX_PRDSP0(pComponentPrivate->dbg, "pComponentPrivate 0x%p 0x%x\n", (int*)pComponentPrivate,event); 7916 7917 if(pComponentPrivate->pCompPort[0] == NULL){ 7918 OMX_PRDSP4(pComponentPrivate->dbg, "*****************************error in lcmlcalback******************************\n"); 7919 goto EXIT; 7920 } 7921 if (event == EMMCodecProcessingPaused) { 7922 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 7923 VIDDEC_PTHREAD_MUTEX_SIGNAL(pComponentPrivate->sMutex); 7924 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 7925 pComponentPrivate->bTransPause = 1; 7926 } 7927 else if (event == EMMCodecAlgCtrlAck) { 7928 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 7929 VIDDEC_PTHREAD_MUTEX_SIGNAL(pComponentPrivate->sMutex); 7930 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 7931 pComponentPrivate->bTransPause = 1; 7932 } 7933 else if (event == EMMCodecProcessingStoped) { 7934 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 7935 VIDDEC_PTHREAD_MUTEX_SIGNAL(pComponentPrivate->sMutex); 7936 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 7937 pComponentPrivate->bTransPause = 1; 7938 pComponentPrivate->bIsPaused = 0; 7939 } 7940 else if (event == EMMCodecProcessingStarted) { 7941 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 7942 VIDDEC_PTHREAD_MUTEX_SIGNAL(pComponentPrivate->sMutex); 7943 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 7944 pComponentPrivate->bTransPause = 1; 7945 pComponentPrivate->bIsPaused = 0; 7946 } 7947 else if (event == EMMCodecBufferProcessed) { 7948 OMX_PRDSP2(pComponentPrivate->dbg, "EMMCodecBufferProcessed 0x%lx\n", (OMX_U32)argsCb [0]); 7949 if ((OMX_U32)argsCb [0] == EMMCodecOuputBuffer) { 7950 OMX_PRBUFFER1(pComponentPrivate->dbg, "EMMCodecOuputBuffer\n"); 7951 OMX_BUFFERHEADERTYPE* pBuffHead = NULL; 7952 VIDDEC_BUFFER_PRIVATE* pBuffPriv = NULL; 7953 OMX_U8* pBuffer; 7954 7955 if (pComponentPrivate->eState != OMX_StateLoaded && pComponentPrivate->eState != OMX_StateIdle) { 7956 pBuffHead = (OMX_BUFFERHEADERTYPE*)argsCb[7]; 7957 if(pBuffHead != NULL) 7958 { 7959 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead Output 0x%p pBuffer 0x%p\n", pBuffHead, argsCb[1]); 7960 pBuffPriv = (VIDDEC_BUFFER_PRIVATE*)pBuffHead->pOutputPortPrivate; 7961 if (pBuffPriv != NULL) { 7962 if(pBuffPriv->eBufferOwner != VIDDEC_BUFFER_WITH_CLIENT) 7963 { 7964 #ifdef __PERF_INSTRUMENTATION__ 7965 pComponentPrivate->lcml_nCntOpReceived++; 7966 if (pComponentPrivate->lcml_nCntOpReceived == 4) { 7967 PERF_Boundary(pComponentPrivate->pPERFcomp, 7968 PERF_BoundaryStart | PERF_BoundarySteadyState); 7969 } 7970 #endif 7971 pBuffer = (OMX_U8*)argsCb[1]; 7972 /* Retrieve time stamp information */ 7973 if (pComponentPrivate->ProcessMode == 0) { 7974 OMX_PTR pBufferFlags; 7975 VIDDEC_CircBuf_Remove(pComponentPrivate, 7976 VIDDEC_CBUFFER_TIMESTAMP, 7977 VIDDEC_INPUT_PORT, 7978 &pBufferFlags); 7979 if(pBufferFlags != NULL){ 7980 pBuffHead->nTimeStamp = (OMX_TICKS)((VIDDEC_CBUFFER_BUFFERFLAGS*)pBufferFlags)->nTimeStamp; 7981 /*pBuffHead->nFlags = 0; 7982 pBuffHead->nFlags = (OMX_U32)((VIDDEC_CBUFFER_BUFFERFLAGS*)pBufferFlags)->nFlags;*/ 7983 pBuffHead->nFlags |= (((OMX_U32)((VIDDEC_CBUFFER_BUFFERFLAGS*)pBufferFlags)->nFlags) & OMX_BUFFERFLAG_DECODEONLY); 7984 pBuffHead->nTickCount = (OMX_U32)((VIDDEC_CBUFFER_BUFFERFLAGS*)pBufferFlags)->nTickCount; 7985 } 7986 else { 7987 pBuffHead->nTimeStamp = 0; 7988 pBuffHead->nTickCount = 0; 7989 } 7990 } 7991 else { 7992 if (pBuffHead->nFilledLen != 0){ 7993 pBuffHead->nTimeStamp = (OMX_TICKS)pComponentPrivate->arrBufIndex[pComponentPrivate->nOutBufIndex]; 7994 pComponentPrivate->nOutBufIndex++; 7995 pComponentPrivate->nOutBufIndex %= VIDDEC_MAX_QUEUE_SIZE; 7996 } 7997 } 7998 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead->nTimeStamp %lld\n", pBuffHead->nTimeStamp); 7999 if(pBuffHead != NULL){ 8000 /*if (pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL) { 8001 pBuffHead->nFilledLen = (OMX_S32)argsCb[2]; 8002 } 8003 else {*/ 8004 pBuffHead->nFilledLen = (OMX_S32)argsCb[8]; 8005 /*}*/ 8006 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead->nFilledLen %lu\n", pBuffHead->nFilledLen); 8007 eError = IncrementCount (&(pComponentPrivate->nCountOutputBFromDsp), &(pComponentPrivate->mutexOutputBFromDSP)); 8008 if (eError != OMX_ErrorNone) { 8009 return eError; 8010 } 8011 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pOutputPortPrivate; 8012 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_COMPONENT; 8013 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 8014 #ifdef __PERF_INSTRUMENTATION__ 8015 PERF_ReceivedFrame(pComponentPrivate->pPERFcomp, 8016 pBuffHead->pBuffer, 8017 pBuffHead->nFilledLen, 8018 PERF_ModuleCommonLayer); 8019 #endif 8020 8021 nRetVal = write(pComponentPrivate->filled_outBuf_Q[1],&pBuffHead,sizeof(pBuffHead)); 8022 if(nRetVal == -1){ 8023 DecrementCount (&(pComponentPrivate->nCountOutputBFromDsp), &(pComponentPrivate->mutexOutputBFromDSP)); 8024 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_DSP; 8025 OMX_PRCOMM4(pComponentPrivate->dbg, "writing to the input pipe %x (%ld)\n", OMX_ErrorInsufficientResources,nRetVal); 8026 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8027 pComponentPrivate->pHandle->pApplicationPrivate, 8028 OMX_EventError, 8029 OMX_ErrorInsufficientResources, 8030 OMX_TI_ErrorSevere, 8031 "Error writing to the output pipe"); 8032 } 8033 } 8034 } 8035 else { 8036 OMX_PRDSP1(pComponentPrivate->dbg, "buffer dropped lcml out process pBuffHead %p owner %d\n",pBuffHead,pBuffPriv->eBufferOwner); 8037 } 8038 } 8039 } 8040 } 8041 } 8042 if ((OMX_U32)argsCb [0] == EMMCodecInputBuffer || 8043 ((OMX_U32)argsCb [0] == EMMCodecInputBufferMapBufLen)) { 8044 OMX_PRBUFFER1(pComponentPrivate->dbg, "EMMCodecInputBuffer\n"); 8045 OMX_BUFFERHEADERTYPE* pBuffHead = NULL; 8046 VIDDEC_BUFFER_PRIVATE* pBuffPriv = NULL; 8047 OMX_U8* pBuffer; 8048 if (pComponentPrivate->eState != OMX_StateLoaded && pComponentPrivate->eState != OMX_StateIdle) { 8049 pBuffHead = (OMX_BUFFERHEADERTYPE*)argsCb[7]; 8050 if(pBuffHead != NULL) 8051 { 8052 pBuffPriv = (VIDDEC_BUFFER_PRIVATE*)pBuffHead->pInputPortPrivate; 8053 if (pBuffPriv == NULL ) { 8054 goto EXIT; 8055 } 8056 else { 8057 if(pBuffPriv->eBufferOwner != VIDDEC_BUFFER_WITH_CLIENT) 8058 { 8059 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead Input 0x%p pBuffer 0x%p\n", pBuffHead, argsCb[1]); 8060 pBuffer = (OMX_U8*)argsCb[1]; 8061 if(pBuffer != NULL){ 8062 eError = IncrementCount (&(pComponentPrivate->nCountInputBFromDsp), &(pComponentPrivate->mutexInputBFromDSP)); 8063 if (eError != OMX_ErrorNone) { 8064 return eError; 8065 } 8066 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 8067 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_COMPONENT; 8068 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 8069 #ifdef __PERF_INSTRUMENTATION__ 8070 PERF_ReceivedFrame(pComponentPrivate->pPERFcomp, 8071 PREF(pBuffHead,pBuffer), 8072 PREF(pBuffHead,nFilledLen), 8073 PERF_ModuleCommonLayer); 8074 #endif 8075 pBuffHead->nFilledLen = 0; 8076 if (pComponentPrivate->nWMVFileType == VIDDEC_WMV_ELEMSTREAM && 8077 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV && 8078 pComponentPrivate->ProcessMode == 0) { 8079 /* vc-1 fix */ 8080 #ifdef VIDDEC_WMVPOINTERFIXED 8081 OMX_PRBUFFER1(pComponentPrivate->dbg, "restoring buffer pointer 0x%p >> pBuffer 0x%p\n", 8082 pBufferPrivate->pTempBuffer, pBuffHead->pBuffer); 8083 pBuffHead->pBuffer = pBufferPrivate->pTempBuffer; 8084 #else 8085 pBuffHead->nOffset = VIDDEC_WMV_BUFFER_OFFSET; 8086 #endif 8087 } 8088 nRetVal = write(pComponentPrivate->free_inpBuf_Q[1], &pBuffHead, sizeof(pBuffHead)); 8089 if(nRetVal == -1){ 8090 OMX_PRCOMM4(pComponentPrivate->dbg, "writing to the input pipe %x (%lu)\n", OMX_ErrorInsufficientResources,nRetVal); 8091 DecrementCount (&(pComponentPrivate->nCountInputBFromDsp), &(pComponentPrivate->mutexInputBFromDSP)); 8092 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_DSP; 8093 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8094 pComponentPrivate->pHandle->pApplicationPrivate, 8095 OMX_EventError, 8096 OMX_ErrorInsufficientResources, 8097 OMX_TI_ErrorSevere, 8098 "Error writing to the output pipe"); 8099 } 8100 } 8101 } 8102 else { 8103 OMX_PRDSP1(pComponentPrivate->dbg, "buffer dropped lcml in notprocess pBuffHead %p owner %d\n",pBuffHead,pBuffPriv->eBufferOwner); 8104 } 8105 } 8106 } 8107 } 8108 } 8109 } 8110 /************************************************************************************************/ 8111 else if (event == EMMCodecBufferNotProcessed) { 8112 OMX_PRDSP2(pComponentPrivate->dbg, "EMMCodecBufferNotProcessed\n"); 8113 if ((OMX_U32)argsCb [0] == EMMCodecOuputBuffer) { 8114 OMX_BUFFERHEADERTYPE* pBuffHead = NULL; 8115 VIDDEC_BUFFER_PRIVATE* pBuffPriv = NULL; 8116 OMX_U8* pBuffer; 8117 8118 if (pComponentPrivate->eState != OMX_StateLoaded && pComponentPrivate->eState != OMX_StateIdle) { 8119 pBuffHead = (OMX_BUFFERHEADERTYPE*)argsCb[7]; 8120 if(pBuffHead != NULL) 8121 { 8122 pBuffPriv = (VIDDEC_BUFFER_PRIVATE*)pBuffHead->pOutputPortPrivate; 8123 if (pBuffPriv != NULL) { 8124 if(pBuffPriv->eBufferOwner != VIDDEC_BUFFER_WITH_CLIENT) 8125 { 8126 #ifdef __PERF_INSTRUMENTATION__ 8127 pComponentPrivate->lcml_nCntOpReceived++; 8128 if (pComponentPrivate->lcml_nCntOpReceived == 4) { 8129 PERF_Boundary(pComponentPrivate->pPERFcomp, 8130 PERF_BoundaryStart | PERF_BoundarySteadyState); 8131 } 8132 #endif 8133 pBuffer = (OMX_U8*)argsCb[1]; 8134 /* Retrieve time stamp information */ 8135 if (pComponentPrivate->ProcessMode == 0) { 8136 OMX_PTR pBufferFlags; 8137 VIDDEC_CircBuf_Remove(pComponentPrivate, 8138 VIDDEC_CBUFFER_TIMESTAMP, 8139 VIDDEC_INPUT_PORT, 8140 &pBufferFlags); 8141 if(pBufferFlags != NULL){ 8142 pBuffHead->nTimeStamp = (OMX_TICKS)((VIDDEC_CBUFFER_BUFFERFLAGS*)pBufferFlags)->nTimeStamp; 8143 /*pBuffHead->nFlags = 0; 8144 pBuffHead->nFlags = (OMX_U32)((VIDDEC_CBUFFER_BUFFERFLAGS*)pBufferFlags)->nFlags;*/ 8145 pBuffHead->nFlags |= (((OMX_U32)((VIDDEC_CBUFFER_BUFFERFLAGS*)pBufferFlags)->nFlags) & OMX_BUFFERFLAG_DECODEONLY); 8146 pBuffHead->nTickCount = (OMX_U32)((VIDDEC_CBUFFER_BUFFERFLAGS*)pBufferFlags)->nTickCount; 8147 } 8148 else { 8149 pBuffHead->nTimeStamp = 0; 8150 pBuffHead->nTickCount = 0; 8151 } 8152 } 8153 else { 8154 if (pBuffHead->nFilledLen != 0){ 8155 pBuffHead->nTimeStamp = (OMX_TICKS)pComponentPrivate->arrBufIndex[pComponentPrivate->nOutBufIndex]; 8156 pComponentPrivate->nOutBufIndex++; 8157 pComponentPrivate->nOutBufIndex %= VIDDEC_MAX_QUEUE_SIZE; 8158 } 8159 } 8160 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead->nTimeStamp %lld\n", pBuffHead->nTimeStamp); 8161 if(pBuffHead != NULL){ 8162 /*if (pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL) { 8163 pBuffHead->nFilledLen = (OMX_S32)argsCb[2]; 8164 } 8165 else {*/ 8166 pBuffHead->nFilledLen = (OMX_S32)argsCb[8]; 8167 /*}*/ 8168 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead->nFilledLen %lu\n", pBuffHead->nFilledLen); 8169 eError = IncrementCount (&(pComponentPrivate->nCountOutputBFromDsp), &(pComponentPrivate->mutexOutputBFromDSP)); 8170 if (eError != OMX_ErrorNone) { 8171 return eError; 8172 } 8173 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pOutputPortPrivate; 8174 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_COMPONENT; 8175 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 8176 #ifdef __PERF_INSTRUMENTATION__ 8177 PERF_ReceivedFrame(pComponentPrivate->pPERFcomp, 8178 pBuffHead->pBuffer, 8179 pBuffHead->nFilledLen, 8180 PERF_ModuleCommonLayer); 8181 #endif 8182 8183 nRetVal = write(pComponentPrivate->filled_outBuf_Q[1],&pBuffHead,sizeof(pBuffHead)); 8184 if(nRetVal == -1){ 8185 DecrementCount (&(pComponentPrivate->nCountOutputBFromDsp), &(pComponentPrivate->mutexOutputBFromDSP)); 8186 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_DSP; 8187 OMX_PRCOMM4(pComponentPrivate->dbg, "writing to the input pipe %x (%lu)\n", OMX_ErrorInsufficientResources,nRetVal); 8188 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8189 pComponentPrivate->pHandle->pApplicationPrivate, 8190 OMX_EventError, 8191 OMX_ErrorInsufficientResources, 8192 OMX_TI_ErrorSevere, 8193 "Error writing to the output pipe"); 8194 } 8195 } 8196 } 8197 else { 8198 OMX_PRDSP1(pComponentPrivate->dbg, "buffer dropped lcml out process pBuffHead %p owner %d\n",pBuffHead,pBuffPriv->eBufferOwner); 8199 } 8200 } 8201 } 8202 } 8203 } 8204 if ((OMX_U32)argsCb [0] == EMMCodecInputBuffer || 8205 ((OMX_U32)argsCb [0] == EMMCodecInputBufferMapBufLen)) { 8206 OMX_BUFFERHEADERTYPE* pBuffHead = NULL; 8207 VIDDEC_BUFFER_PRIVATE* pBuffPriv = NULL; 8208 OMX_U8* pBuffer; 8209 if (pComponentPrivate->eState != OMX_StateLoaded && pComponentPrivate->eState != OMX_StateIdle) { 8210 pBuffHead = (OMX_BUFFERHEADERTYPE*)argsCb[7]; 8211 if(pBuffHead != NULL) 8212 { 8213 pBuffPriv = (VIDDEC_BUFFER_PRIVATE*)pBuffHead->pInputPortPrivate; 8214 if (pBuffPriv == NULL ) { 8215 goto EXIT; 8216 } 8217 else { 8218 if(pBuffPriv->eBufferOwner != VIDDEC_BUFFER_WITH_CLIENT) 8219 { 8220 OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead Input 0x%p pBuffer 0x%p\n", pBuffHead, argsCb[1]); 8221 pBuffer = (OMX_U8*)argsCb[1]; 8222 if(pBuffer != NULL){ 8223 eError = IncrementCount (&(pComponentPrivate->nCountInputBFromDsp), &(pComponentPrivate->mutexInputBFromDSP)); 8224 if (eError != OMX_ErrorNone) { 8225 return eError; 8226 } 8227 pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate; 8228 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_COMPONENT; 8229 OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner); 8230 #ifdef __PERF_INSTRUMENTATION__ 8231 PERF_ReceivedFrame(pComponentPrivate->pPERFcomp, 8232 PREF(pBuffHead,pBuffer), 8233 PREF(pBuffHead,nFilledLen), 8234 PERF_ModuleCommonLayer); 8235 #endif 8236 pBuffHead->nFilledLen = 0; 8237 if (pComponentPrivate->nWMVFileType == VIDDEC_WMV_ELEMSTREAM && 8238 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV && 8239 pComponentPrivate->ProcessMode == 0) { 8240 /* vc-1 fix */ 8241 #ifdef VIDDEC_WMVPOINTERFIXED 8242 OMX_PRBUFFER1(pComponentPrivate->dbg, "restoring buffer pointer 0x%p >> pBuffer 0x%p\n", 8243 pBufferPrivate->pTempBuffer, pBuffHead->pBuffer); 8244 pBuffHead->pBuffer = pBufferPrivate->pTempBuffer; 8245 #else 8246 pBuffHead->nOffset = VIDDEC_WMV_BUFFER_OFFSET; 8247 #endif 8248 } 8249 nRetVal = write(pComponentPrivate->free_inpBuf_Q[1], &pBuffHead, sizeof(pBuffHead)); 8250 if(nRetVal == -1){ 8251 OMX_PRCOMM4(pComponentPrivate->dbg, "writing to the input pipe %x (%lu)\n", OMX_ErrorInsufficientResources,nRetVal); 8252 DecrementCount (&(pComponentPrivate->nCountInputBFromDsp), &(pComponentPrivate->mutexInputBFromDSP)); 8253 pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_DSP; 8254 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8255 pComponentPrivate->pHandle->pApplicationPrivate, 8256 OMX_EventError, 8257 OMX_ErrorInsufficientResources, 8258 OMX_TI_ErrorSevere, 8259 "Error writing to the output pipe"); 8260 } 8261 } 8262 } 8263 else { 8264 OMX_PRDSP1(pComponentPrivate->dbg, "buffer dropped lcml in notprocess pBuffHead %p owner %d\n",pBuffHead,pBuffPriv->eBufferOwner); 8265 } 8266 } 8267 } 8268 } 8269 } 8270 } 8271 /************************************************************************************************/ 8272 else if (event == EMMCodecDspError) { 8273 OMX_PRDSP2(pComponentPrivate->dbg, "EMMCodecDspError\n"); 8274 if((argsCb[4] == (void *)NULL) && (argsCb[5] == (void*)NULL)) { 8275 OMX_PRDSP4(pComponentPrivate->dbg, "DSP MMU_Fault\n"); 8276 pComponentPrivate->bLCMLHalted = OMX_TRUE; 8277 pComponentPrivate->pHandle->SendCommand( pComponentPrivate->pHandle, OMX_CommandStateSet, -2, 0); 8278 } 8279 if((int)argsCb[5] == IUALG_ERR_NOT_SUPPORTED) 8280 { 8281 OMX_PRDSP4(pComponentPrivate->dbg, "Algorithm error. Parameter not supported\n"); 8282 OMX_PRDSP2(pComponentPrivate->dbg, "argsCb5 = %p\n",argsCb[5]); 8283 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_Callback: IUALG_ERR_NOT_SUPPORTED\n"); 8284 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8285 pComponentPrivate->pHandle->pApplicationPrivate, 8286 OMX_EventError, 8287 OMX_ErrorInsufficientResources, 8288 OMX_TI_ErrorCritical, 8289 "Error from the DSP"); 8290 goto EXIT; 8291 } 8292 if ((int)argsCb [0] == USN_DSPMSG_EVENT) { 8293 if ((int)argsCb [4] == USN_ERR_WARNING) { 8294 if ((int)argsCb [5] == IUALG_WARN_PLAYCOMPLETED) { 8295 OMX_PRDSP2(pComponentPrivate->dbg, "Received PLAYCOMPLETED\n"); 8296 } 8297 else { 8298 OMX_PRDSP4(pComponentPrivate->dbg, "Error from the DSP: argsCb[5]=%d.\n", (int)argsCb [5]); 8299 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8300 pComponentPrivate->pHandle->pApplicationPrivate, 8301 OMX_EventError, 8302 OMX_ErrorHardware, 8303 OMX_TI_ErrorCritical, 8304 "Error from the DSP"); 8305 } 8306 } 8307 else { 8308 OMX_PRDSP4(pComponentPrivate->dbg, "Error from the DSP: argsCb[4]=%d.\n", (int)argsCb [4]); 8309 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8310 pComponentPrivate->pHandle->pApplicationPrivate, 8311 OMX_EventError, 8312 OMX_ErrorHardware, 8313 OMX_TI_ErrorCritical, 8314 "Error from the DSP"); 8315 goto EXIT; 8316 } 8317 } 8318 else { 8319 OMX_PRDSP4(pComponentPrivate->dbg, "LCML Halted: argsCb[0]=%d.\n", (int)argsCb [0]); 8320 pComponentPrivate->bLCMLHalted = OMX_TRUE; 8321 pComponentPrivate->pHandle->SendCommand( pComponentPrivate->pHandle, OMX_CommandStateSet, -2, 0); 8322 8323 } 8324 } 8325 else if (event == EMMCodecInternalError || event == EMMCodecInitError) { 8326 OMX_PRDSP4(pComponentPrivate->dbg, "EMMCodecInternalError || EMMCodecInitError\n"); 8327 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8328 pComponentPrivate->pHandle->pApplicationPrivate, 8329 OMX_EventError, 8330 OMX_ErrorHardware, 8331 OMX_TI_ErrorCritical, 8332 "Error from the DSP"); 8333 } 8334 else if (event == EMMCodecStrmCtrlAck) { 8335 if ((int)argsCb [0] == USN_ERR_NONE) { 8336 OMX_PRDSP2(pComponentPrivate->dbg, "EMMCodecStrmCtrlAck\n"); 8337 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 8338 VIDDEC_PTHREAD_MUTEX_SIGNAL(pComponentPrivate->sMutex); 8339 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 8340 } else { 8341 OMX_PRDSP4(pComponentPrivate->dbg, "EMMCodecStrmCtrlAck: argsCb[0]=%d\n", (int)argsCb [0]); 8342 } 8343 } else { 8344 OMX_PRDSP4(pComponentPrivate->dbg, "Unknown event: %d\n", event); 8345 } 8346 8347 EXIT: 8348 OMX_PRDSP0(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError); 8349 return eError; 8350 } 8351 8352 #ifdef RESOURCE_MANAGER_ENABLED 8353 void VIDDEC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData) 8354 { 8355 8356 /*OMX_COMMANDTYPE Cmd = OMX_CommandStateSet; 8357 OMX_U32 state ; 8358 OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)cbData.hComponent;*/ 8359 VIDDEC_COMPONENT_PRIVATE *pCompPrivate = NULL; 8360 pCompPrivate = NULL; 8361 } 8362 #endif 8363 8364 #ifdef ANDROID 8365 /* ========================================================================== */ 8366 /** 8367 * VIDDEC_SaveBuffer() function will be use to copy a buffer at private space, to be used later by VIDDEC_CopyBuffer() 8368 * 8369 * @param 8370 * pComponentPrivate Component private structure 8371 * pBuffHead Header of the buffer to be store 8372 * 8373 * @retval OMX_ErrorNone Success, ready to roll 8374 * OMX_ErrorInsufficientResources Not enough memory to save first buffer 8375 **/ 8376 /* ========================================================================== */ 8377 8378 OMX_ERRORTYPE VIDDEC_SaveBuffer(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, 8379 OMX_BUFFERHEADERTYPE* pBuffHead) 8380 { 8381 OMX_ERRORTYPE eError = OMX_ErrorNone; 8382 OMX_PRINT1(pComponentPrivate->dbg, "IN\n"); 8383 pComponentPrivate->eFirstBuffer.bSaveFirstBuffer = OMX_TRUE; 8384 8385 OMX_MALLOC_STRUCT_SIZED(pComponentPrivate->eFirstBuffer.pFirstBufferSaved, OMX_U8, pBuffHead->nFilledLen, NULL); 8386 memcpy(pComponentPrivate->eFirstBuffer.pFirstBufferSaved, pBuffHead->pBuffer, pBuffHead->nFilledLen); 8387 8388 pComponentPrivate->eFirstBuffer.nFilledLen = pBuffHead->nFilledLen; 8389 8390 EXIT: 8391 OMX_PRINT1(pComponentPrivate->dbg, "OUT\n"); 8392 return eError; 8393 } 8394 8395 8396 8397 /* ========================================================================== */ 8398 /** 8399 * VIDDEC_CopyBuffer() function will insert an the begining of pBuffer the buffer stored using VIDDEC_SaveBuffer() 8400 * and update nFilledLen of the buffer header 8401 * 8402 * @param 8403 * pComponentPrivate Component private structure 8404 * pBuffHead Header of the buffer to be store 8405 * 8406 * @retval OMX_ErrorNone Success, ready to roll 8407 * OMX_ErrorUndefined No buffer to be copy. 8408 * OMX_ErrorInsufficientResources Not enough memory to save buffer 8409 **/ 8410 /* ========================================================================== */ 8411 8412 OMX_ERRORTYPE VIDDEC_CopyBuffer(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, 8413 OMX_BUFFERHEADERTYPE* pBuffHead) 8414 { 8415 OMX_PRINT1(pComponentPrivate->dbg, "IN\n"); 8416 OMX_ERRORTYPE eError = OMX_ErrorNone; 8417 if (pComponentPrivate->eFirstBuffer.bSaveFirstBuffer == OMX_FALSE) { 8418 eError = OMX_ErrorUndefined; 8419 goto EXIT; 8420 } 8421 OMX_PRINT1(pComponentPrivate->dbg, "pBuffer=%p\n", pBuffHead->pBuffer); 8422 OMX_PTR pTemp = NULL; 8423 pComponentPrivate->eFirstBuffer.bSaveFirstBuffer = OMX_FALSE; 8424 8425 /* only if NAL-bitstream format in frame mode */ 8426 if ( 8427 ((pComponentPrivate->ProcessMode == 0 && pComponentPrivate->H264BitStreamFormat > 0) 8428 || (pBuffHead->nFilledLen > pComponentPrivate->eFirstBuffer.nFilledLen)) 8429 && (pBuffHead->nAllocLen >= pComponentPrivate->eFirstBuffer.nFilledLen + pBuffHead->nFilledLen) 8430 ) { 8431 OMX_MALLOC_STRUCT_SIZED(pTemp, OMX_U8, pBuffHead->nFilledLen, NULL); 8432 memcpy(pTemp, pBuffHead->pBuffer, pBuffHead->nFilledLen); /*copy somewere actual buffer*/ 8433 memcpy(pBuffHead->pBuffer, pComponentPrivate->eFirstBuffer.pFirstBufferSaved, pComponentPrivate->eFirstBuffer.nFilledLen); /*copy first buffer to the beganing of pBuffer.*/ 8434 memcpy((OMX_U8 *)pBuffHead->pBuffer+pComponentPrivate->eFirstBuffer.nFilledLen, pTemp, pBuffHead->nFilledLen); /* copy back actual buffer after first buffer*/ 8435 pBuffHead->nFilledLen += pComponentPrivate->eFirstBuffer.nFilledLen; /*Add first buffer size*/ 8436 8437 free(pTemp); 8438 free(pComponentPrivate->eFirstBuffer.pFirstBufferSaved); 8439 pComponentPrivate->eFirstBuffer.pFirstBufferSaved = NULL; 8440 } 8441 /*The first buffer has more information than the second, so the first buffer will be send to codec*/ 8442 /*We are loosing the second fame. TODO: Fix this*/ 8443 else if (pBuffHead->nAllocLen >= pComponentPrivate->eFirstBuffer.nFilledLen){ 8444 /*copy first buffer data to the actual buffer*/ 8445 memcpy(pBuffHead->pBuffer, pComponentPrivate->eFirstBuffer.pFirstBufferSaved, pComponentPrivate->eFirstBuffer.nFilledLen); /*copy first buffer*/ 8446 pBuffHead->nFilledLen = pComponentPrivate->eFirstBuffer.nFilledLen; /*Update buffer size*/ 8447 free(pComponentPrivate->eFirstBuffer.pFirstBufferSaved); 8448 pComponentPrivate->eFirstBuffer.pFirstBufferSaved = NULL; 8449 } else { 8450 LOGE("Not enough memory in the buffer to concatenate the 2 frames, loosing first frame\n"); 8451 } 8452 EXIT: 8453 OMX_PRINT1(pComponentPrivate->dbg, "OUT\n"); 8454 return eError; 8455 } 8456 #endif 8457 8458 8459 /* ========================================================================== */ 8460 /** 8461 * VIDDEC_LoadCodec() function will get LCML resource and start the codec. 8462 * 8463 * @param 8464 * pComponentPrivate Component private structure 8465 * 8466 * @retval OMX_ErrorNone Success, ready to roll 8467 * OMX_ErrorUndefined 8468 * OMX_ErrorInsufficientResources Not enough memory 8469 **/ 8470 /* ========================================================================== */ 8471 8472 OMX_ERRORTYPE VIDDEC_LoadCodec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) 8473 { 8474 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 8475 OMX_U32 message[4]; 8476 LCML_DSP_INTERFACE *pLcmlHandle = NULL; 8477 OMX_HANDLETYPE hLCML = NULL; 8478 void* p = NULL; 8479 #ifdef UNDER_CE 8480 typedef OMX_ERRORTYPE (*LPFNDLLFUNC1)(OMX_HANDLETYPE); 8481 HINSTANCE hDLL; 8482 LPFNDLLFUNC1 fpGetHandle1; 8483 #else 8484 VIDDEC_fpo fpGetHandle; 8485 char* error; 8486 #endif 8487 8488 #ifndef UNDER_CE 8489 pComponentPrivate->pModLCML = dlopen("libLCML.so", RTLD_LAZY); 8490 if (!pComponentPrivate->pModLCML) { 8491 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorBadParameter\n"); 8492 fputs(dlerror(), stderr); 8493 eError = OMX_ErrorBadParameter; 8494 goto EXIT; 8495 } 8496 fpGetHandle = dlsym(pComponentPrivate->pModLCML, "GetHandle"); 8497 if ((error = dlerror()) != NULL) { 8498 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorBadParameter\n"); 8499 fputs(error, stderr); 8500 dlclose(pComponentPrivate->pModLCML); 8501 pComponentPrivate->pModLCML = NULL; 8502 eError = OMX_ErrorBadParameter; 8503 goto EXIT; 8504 } 8505 eError = (*fpGetHandle)(&hLCML); 8506 if (eError != OMX_ErrorNone) { 8507 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorBadParameter\n"); 8508 dlclose(pComponentPrivate->pModLCML); 8509 pComponentPrivate->pModLCML = NULL; 8510 eError = OMX_ErrorBadParameter; 8511 goto EXIT; 8512 } 8513 8514 #endif 8515 8516 pComponentPrivate->eLCMLState = VidDec_LCML_State_Load; 8517 OMX_PRDSP2(pComponentPrivate->dbg, "LCML Handler 0x%p\n",hLCML); 8518 /*(LCML_DSP_INTERFACE*)pComponentPrivate->pLCML = (LCML_DSP_INTERFACE*)hLCML;*/ 8519 pComponentPrivate->pLCML = (LCML_DSP_INTERFACE*)hLCML; 8520 pComponentPrivate->pLCML->pComponentPrivate = pComponentPrivate; 8521 8522 8523 #ifdef __PERF_INSTRUMENTATION__ 8524 pComponentPrivate->lcml_nCntOpReceived = 0; 8525 #endif 8526 eError = OMX_ErrorNone; 8527 #ifndef UNDER_CE 8528 pComponentPrivate->bLCMLOut = OMX_TRUE; 8529 #endif 8530 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 8531 eError = VIDDEC_InitDSP_H264Dec(pComponentPrivate); 8532 } 8533 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 || 8534 pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) { 8535 eError = VIDDEC_InitDSP_Mpeg4Dec(pComponentPrivate); 8536 } 8537 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) { 8538 eError = VIDDEC_InitDSP_Mpeg2Dec(pComponentPrivate); 8539 } 8540 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) { 8541 eError = VIDDEC_InitDSP_WMVDec(pComponentPrivate); 8542 } 8543 #ifdef VIDDEC_SPARK_CODE 8544 else if (VIDDEC_SPARKCHECK) { 8545 eError = VIDDEC_InitDSP_SparkDec(pComponentPrivate); 8546 } 8547 #endif 8548 else { 8549 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorUnsupportedSetting\n"); 8550 eError = OMX_ErrorUnsupportedSetting; 8551 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8552 pComponentPrivate->pHandle->pApplicationPrivate, 8553 OMX_EventError, 8554 OMX_ErrorUnsupportedSetting, 8555 OMX_TI_ErrorMinor, 8556 "DSP Initialization"); 8557 goto EXIT; 8558 } 8559 if (eError != OMX_ErrorNone){ 8560 OMX_PRDSP4(pComponentPrivate->dbg, "LCML Error %x\n", pComponentPrivate->eState); 8561 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8562 pComponentPrivate->pHandle->pApplicationPrivate, 8563 OMX_EventError, 8564 eError, 8565 OMX_TI_ErrorSevere, 8566 "DSP Initialization"); 8567 goto EXIT; 8568 } 8569 #ifndef UNDER_CE 8570 pComponentPrivate->bLCMLOut = OMX_FALSE; 8571 #endif 8572 pComponentPrivate->bLCMLHalted = OMX_FALSE; 8573 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 8574 pComponentPrivate->eLCMLState = VidDec_LCML_State_Init; 8575 8576 OMX_PRDSP2(pComponentPrivate->dbg, "OUTPUT width=%lu height=%lu\n", pComponentPrivate->pOutPortDef->format.video.nFrameWidth, pComponentPrivate->pOutPortDef->format.video.nFrameHeight); 8577 OMX_PRDSP2(pComponentPrivate->dbg, "INPUT width=%lu height=%lu\n", pComponentPrivate->pInPortDef->format.video.nFrameWidth, pComponentPrivate->pInPortDef->format.video.nFrameHeight); 8578 8579 /*Enable EOS propagation at USN*/ 8580 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 8581 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 8582 pComponentPrivate->pLCML != NULL && 8583 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 8584 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlUsnEos 0x%p\n",pLcmlHandle); 8585 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,EMMCodecControlUsnEos, NULL); 8586 if (eError != OMX_ErrorNone) { 8587 OMX_PRDSP4(pComponentPrivate->dbg, "error in EMMCodecControlUsnEos %x\n",eError); 8588 eError = OMX_ErrorHardware; 8589 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8590 pComponentPrivate->pHandle->pApplicationPrivate, 8591 OMX_EventError, 8592 OMX_ErrorHardware, 8593 OMX_TI_ErrorSevere, 8594 "LCML_ControlCodec EMMCodecControlUsnEos function"); 8595 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorHardware 0x%x\n",eError); 8596 goto EXIT; 8597 } 8598 } 8599 8600 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat != OMX_VIDEO_CodingWMV) { 8601 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) { 8602 message[1] = 4; 8603 } 8604 else { 8605 message[1] = 100; 8606 } 8607 message[0] = 0x400; 8608 message[2] = 0; 8609 p = (void*)&message; 8610 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 8611 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlSendDspMessage 0x%p\n",pLcmlHandle); 8612 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,EMMCodecControlSendDspMessage, (void *)p); 8613 if (eError != OMX_ErrorNone) { 8614 OMX_PRDSP4(pComponentPrivate->dbg, "error in EMMCodecControlSendDspMessage %x\n",eError); 8615 eError = OMX_ErrorHardware; 8616 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8617 pComponentPrivate->pHandle->pApplicationPrivate, 8618 OMX_EventError, 8619 OMX_ErrorHardware, 8620 OMX_TI_ErrorSevere, 8621 "LCML_ControlCodec function"); 8622 OMX_PRDSP4(pComponentPrivate->dbg, "OMX_ErrorHardware 0x%x\n",eError); 8623 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 8624 goto EXIT; 8625 } 8626 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 8627 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 8628 } 8629 8630 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 8631 pComponentPrivate->bIsPaused = 0; 8632 pComponentPrivate->bFirstBuffer = 1; 8633 8634 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlStart 0x%p\n",pLcmlHandle); 8635 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,EMMCodecControlStart,NULL); 8636 if (eError != OMX_ErrorNone) { 8637 eError = OMX_ErrorHardware; 8638 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8639 pComponentPrivate->pHandle->pApplicationPrivate, 8640 OMX_EventError, 8641 OMX_ErrorHardware, 8642 OMX_TI_ErrorSevere, 8643 "LCML_ControlCodec Start"); 8644 goto EXIT; 8645 OMX_PRDSP4(pComponentPrivate->dbg, "Occurred in Codec Start... 0x%x\n",eError); 8646 } 8647 pComponentPrivate->eLCMLState = VidDec_LCML_State_Start; 8648 8649 if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC && 8650 pComponentPrivate->eState == OMX_StateIdle) { 8651 H264_Iualg_Cmd_SetStatus* pDynParams = NULL; 8652 char* pTmp = NULL; 8653 OMX_U32 cmdValues[3] = {0, 0, 0}; 8654 8655 OMX_PRDSP2(pComponentPrivate->dbg, "Initializing DSP for h264 eCompressionFormat 0x%x\n", 8656 pComponentPrivate->pInPortDef->format.video.eCompressionFormat); 8657 OMX_MALLOC_STRUCT_SIZED(pDynParams, H264_Iualg_Cmd_SetStatus, sizeof(H264_Iualg_Cmd_SetStatus) + VIDDEC_PADDING_FULL,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 8658 if (pDynParams == NULL) { 8659 OMX_TRACE4(pComponentPrivate->dbg, "Error: Malloc failed\n"); 8660 eError = OMX_ErrorInsufficientResources; 8661 goto EXIT; 8662 } 8663 memset(pDynParams, 0, sizeof(H264_Iualg_Cmd_SetStatus) + VIDDEC_PADDING_FULL); 8664 pTmp = (char*)pDynParams; 8665 pTmp += VIDDEC_PADDING_HALF; 8666 pDynParams = (H264_Iualg_Cmd_SetStatus*)pTmp; 8667 #ifdef VIDDEC_SN_R8_14 8668 pDynParams->size = sizeof(H264_Iualg_Cmd_SetStatus); 8669 #endif 8670 pDynParams->ulDecodeHeader = 1; 8671 pDynParams->ulDisplayWidth = 0; 8672 pDynParams->ulFrameSkipMode = 0; 8673 pDynParams->ulPPType = 0; 8674 8675 cmdValues[0] = IUALG_CMD_SETSTATUS; 8676 cmdValues[1] = (OMX_U32)(pDynParams); 8677 cmdValues[2] = sizeof(H264_Iualg_Cmd_SetStatus); 8678 8679 p = (void*)&cmdValues; 8680 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 8681 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 8682 pComponentPrivate->pLCML != NULL && 8683 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 8684 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 8685 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 8686 EMMCodecControlAlgCtrl, 8687 (void*)p); 8688 if (eError != OMX_ErrorNone) { 8689 eError = OMX_ErrorHardware; 8690 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 8691 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,H264_Iualg_Cmd_SetStatus); 8692 goto EXIT; 8693 } 8694 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 8695 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 8696 } 8697 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,H264_Iualg_Cmd_SetStatus); 8698 8699 if (eError != OMX_ErrorNone) { 8700 OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError); 8701 goto EXIT; 8702 } 8703 } 8704 else if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2 && 8705 pComponentPrivate->eState == OMX_StateIdle) { 8706 MP2VDEC_UALGDynamicParams* pDynParams = NULL; 8707 char* pTmp = NULL; 8708 OMX_U32 cmdValues[3] = {0, 0, 0}; 8709 8710 OMX_PRDSP2(pComponentPrivate->dbg, "Initializing DSP for wmv9 eCompressionFormat 0x%x\n", 8711 pComponentPrivate->pInPortDef->format.video.eCompressionFormat); 8712 OMX_MALLOC_STRUCT_SIZED(pDynParams, MP2VDEC_UALGDynamicParams, sizeof(MP2VDEC_UALGDynamicParams) + VIDDEC_PADDING_FULL,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 8713 memset(pDynParams, 0, sizeof(MP2VDEC_UALGDynamicParams) + VIDDEC_PADDING_FULL); 8714 pTmp = (char*)pDynParams; 8715 pTmp += VIDDEC_PADDING_HALF; 8716 pDynParams = (MP2VDEC_UALGDynamicParams*)pTmp; 8717 8718 #ifdef VIDDEC_SN_R8_14 8719 pDynParams->size = sizeof(MP2VDEC_UALGDynamicParams); 8720 #endif 8721 if (pComponentPrivate->nDisplayWidth > 0) { 8722 if (pComponentPrivate->pInPortDef->format.video.nFrameWidth > pComponentPrivate->nDisplayWidth) { 8723 pComponentPrivate->nDisplayWidth = pComponentPrivate->pInPortDef->format.video.nFrameWidth; 8724 } 8725 pDynParams->ulDisplayWidth = (((pComponentPrivate->nDisplayWidth + 15) >> 4) << 4); 8726 if (pComponentPrivate->nDisplayWidth != pDynParams->ulDisplayWidth ) { 8727 pComponentPrivate->nDisplayWidth = pDynParams->ulDisplayWidth; 8728 OMX_PRDSP2(pComponentPrivate->dbg, "warning Display Width adjusted to %lu\n",pDynParams->ulDisplayWidth); 8729 } 8730 } 8731 else if (pComponentPrivate->pCompPort[1]->hTunnelComponent != NULL){ 8732 if (pComponentPrivate->pInPortDef->format.video.nFrameWidth > pComponentPrivate->nDisplayWidth) { 8733 pComponentPrivate->nDisplayWidth = pComponentPrivate->pInPortDef->format.video.nFrameWidth; 8734 } 8735 pDynParams->ulDisplayWidth = (((pComponentPrivate->nDisplayWidth + 15) >> 4) << 4); 8736 if (pComponentPrivate->nDisplayWidth != pDynParams->ulDisplayWidth ) { 8737 pComponentPrivate->nDisplayWidth = pDynParams->ulDisplayWidth; 8738 OMX_PRDSP2(pComponentPrivate->dbg, "warning Display Width adjusted to %lu\n",pDynParams->ulDisplayWidth); 8739 } 8740 } 8741 else { 8742 pDynParams->ulDisplayWidth = 0; 8743 } 8744 pDynParams->ulDecodeHeader = 0; 8745 pDynParams->ulFrameSkipMode = 0; 8746 pDynParams->ulPPType = 0; 8747 pDynParams->ulPpNone = 0; 8748 if (pComponentPrivate->pOutPortDef->format.video.eColorFormat == VIDDEC_COLORFORMAT422) { 8749 pDynParams->ulDyna_chroma_format = MP2VIDDEC_YUVFORMAT_INTERLEAVED422; 8750 } 8751 else { 8752 pDynParams->ulDyna_chroma_format = MP2VIDDEC_YUVFORMAT_PLANAR420; 8753 } 8754 8755 cmdValues[0] = IUALG_CMD_SETSTATUS; 8756 cmdValues[1] = (OMX_U32)(pDynParams); 8757 cmdValues[2] = sizeof(MP2VDEC_UALGDynamicParams); 8758 8759 pComponentPrivate->bTransPause = 0; 8760 p = (void*)&cmdValues; 8761 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 8762 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 8763 pComponentPrivate->pLCML != NULL && 8764 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 8765 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 8766 EMMCodecControlAlgCtrl, 8767 (void*)p); 8768 if(eError != OMX_ErrorNone){ 8769 eError = OMX_ErrorHardware; 8770 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8771 pComponentPrivate->pHandle->pApplicationPrivate, 8772 OMX_EventError, 8773 eError, 8774 0x0, 8775 "LCML_ControlCodec function"); 8776 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP2VDEC_UALGDynamicParams); 8777 goto EXIT; 8778 } 8779 while(1) { 8780 if(pComponentPrivate->bTransPause != 0) { 8781 pComponentPrivate->bTransPause = 0; 8782 break; 8783 } 8784 VIDDEC_WAIT_CODE(); 8785 } 8786 } 8787 8788 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP2VDEC_UALGDynamicParams); 8789 8790 if (eError != OMX_ErrorNone) { 8791 OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError); 8792 goto EXIT; 8793 } 8794 } 8795 #ifdef VIDDEC_SPARK_CODE 8796 else if (VIDDEC_SPARKCHECK) { 8797 if(pComponentPrivate->eState == OMX_StateIdle) { 8798 SPARKVDEC_UALGDynamicParams* pDynParams = NULL; 8799 char* pTmp = NULL; 8800 OMX_U32 cmdValues[3] = {0, 0, 0}; 8801 8802 OMX_PRDSP2(pComponentPrivate->dbg, "Initializing DSP for mpeg4 and h263 eCompressionFormat 0x%x\n", 8803 pComponentPrivate->pInPortDef->format.video.eCompressionFormat); 8804 OMX_MALLOC_STRUCT_SIZED(pDynParams, SPARKVDEC_UALGDynamicParams, sizeof(SPARKVDEC_UALGDynamicParams) + VIDDEC_PADDING_FULL,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 8805 if (pDynParams == NULL) { 8806 OMX_TRACE4(pComponentPrivate->dbg, "Error: Malloc failed\n"); 8807 eError = OMX_ErrorInsufficientResources; 8808 goto EXIT; 8809 } 8810 memset(pDynParams, 0, sizeof(SPARKVDEC_UALGDynamicParams) + VIDDEC_PADDING_FULL); 8811 pTmp = (char*)pDynParams; 8812 pTmp += VIDDEC_PADDING_HALF; 8813 pDynParams = (SPARKVDEC_UALGDynamicParams*)pTmp; 8814 #ifdef VIDDEC_SN_R8_14 8815 pDynParams->size = sizeof(SPARKVDEC_UALGDynamicParams); 8816 #endif 8817 pDynParams->ulDecodeHeader = 0; 8818 pDynParams->ulDisplayWidth = 0; 8819 pDynParams->ulFrameSkipMode = 0; 8820 pDynParams->ulPPType = 0; 8821 8822 cmdValues[0] = IUALG_CMD_SETSTATUS; 8823 cmdValues[1] = (OMX_U32)(pDynParams); 8824 cmdValues[2] = sizeof(SPARKVDEC_UALGDynamicParams); 8825 8826 /*pComponentPrivate->bTransPause = 0;*//*flag to wait for the generated event*/ 8827 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 8828 p = (void*)&cmdValues; 8829 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 8830 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 8831 pComponentPrivate->pLCML != NULL && 8832 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 8833 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 8834 EMMCodecControlAlgCtrl, 8835 (void*)p); 8836 if (eError != OMX_ErrorNone) { 8837 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 8838 eError = OMX_ErrorHardware; 8839 OMX_MEMFREE_STRUCT_DSPALIGN (pDynParams,SPARKVDEC_UALGDynamicParams); 8840 goto EXIT; 8841 } 8842 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 8843 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 8844 } 8845 8846 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,SPARKVDEC_UALGDynamicParams); 8847 8848 if (eError != OMX_ErrorNone) { 8849 OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError); 8850 goto EXIT; 8851 } 8852 } 8853 } 8854 #endif 8855 else { 8856 eError = VIDDEC_SetMpeg4_Parameters(pComponentPrivate); 8857 if (eError != OMX_ErrorNone){ 8858 goto EXIT; 8859 } 8860 } 8861 8862 eError = OMX_ErrorNone; 8863 8864 EXIT: 8865 return eError; 8866 } 8867 8868 8869 8870 /* ========================================================================== */ 8871 /** 8872 * VIDDEC_UnloadCodec() function will stop & destroy the codec. LCML resource is also been freed. 8873 * 8874 * @param 8875 * pComponentPrivate Component private structure 8876 * 8877 * @retval OMX_NoError Success, ready to roll 8878 * OMX_ErrorUndefined 8879 * OMX_ErrorInsufficientResources Not enough memory 8880 **/ 8881 /* ========================================================================== */ 8882 8883 OMX_ERRORTYPE VIDDEC_UnloadCodec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) 8884 { 8885 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 8886 LCML_DSP_INTERFACE *pLcmlHandle = NULL; 8887 OMX_PRDSP1(pComponentPrivate->dbg, "+++ENTERING\n"); 8888 if (!(pComponentPrivate->eState == OMX_StateLoaded) && 8889 !(pComponentPrivate->eState == OMX_StateWaitForResources)) { 8890 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 8891 if (pComponentPrivate->eState == OMX_StateExecuting) { 8892 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 8893 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 8894 pComponentPrivate->pLCML != NULL && 8895 pComponentPrivate->bLCMLHalted != OMX_TRUE) { 8896 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 8897 OMX_PRDSP1(pComponentPrivate->dbg, "LCML_ControlCodec called MMCodecControlStop 0x%x\n",eError); 8898 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, MMCodecControlStop, NULL); 8899 if (eError != OMX_ErrorNone) { 8900 OMX_PRDSP4(pComponentPrivate->dbg, "Occurred in Codec Stop...\n"); 8901 eError = OMX_ErrorHardware; 8902 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8903 pComponentPrivate->pHandle->pApplicationPrivate, 8904 OMX_EventError, 8905 eError, 8906 OMX_TI_ErrorCritical, 8907 NULL); 8908 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 8909 goto EXIT; 8910 } 8911 8912 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 8913 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 8914 } 8915 pComponentPrivate->eLCMLState = VidDec_LCML_State_Stop; 8916 } 8917 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 8918 pComponentPrivate->pLCML != NULL){ 8919 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, EMMCodecControlDestroy, NULL); 8920 8921 OMX_PRDSP2(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlDestroy 0x%p\n",pLcmlHandle); 8922 if (eError != OMX_ErrorNone) { 8923 OMX_PRDSP4(pComponentPrivate->dbg, "Occurred in Codec Destroy...\n"); 8924 eError = OMX_ErrorHardware; 8925 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 8926 pComponentPrivate->pHandle->pApplicationPrivate, 8927 OMX_EventError, 8928 eError, 8929 OMX_TI_ErrorCritical, 8930 NULL); 8931 OMX_ERROR4(pComponentPrivate->dbg, "Incorrect State Transition 0x%x\n", eError); 8932 goto EXIT; 8933 } 8934 } 8935 pComponentPrivate->eLCMLState = VidDec_LCML_State_Destroy; 8936 OMX_PRDSP1(pComponentPrivate->dbg, "LCML_ControlCodec called EMMCodecControlDestroy 0x%p\n",pLcmlHandle); 8937 8938 #ifndef UNDER_CE 8939 if(pComponentPrivate->pModLCML != NULL){ 8940 dlclose(pComponentPrivate->pModLCML); 8941 pComponentPrivate->pModLCML = NULL; 8942 pComponentPrivate->pLCML = NULL; 8943 pComponentPrivate->eLCMLState = VidDec_LCML_State_Unload; 8944 } 8945 #else 8946 if(pComponentPrivate->pModLCML != NULL){ 8947 FreeLibrary(pComponentPrivate->pModLCML); 8948 pComponentPrivate->pModLCML = NULL; 8949 pComponentPrivate->pLCML = NULL; 8950 pComponentPrivate->eLCMLState = VidDec_LCML_State_Unload; 8951 } 8952 #endif 8953 8954 pComponentPrivate->bLCMLHalted = OMX_TRUE; 8955 } 8956 eError = OMX_ErrorNone; 8957 EXIT: 8958 return eError; 8959 } 8960 8961 8962 8963 /* ========================================================================== */ 8964 /** 8965 * VIDDEC_Set_SN_StreamType() Set stream type using dynamic parameters at the SN. 8966 * 8967 * @param 8968 * pComponentPrivate Component private structure 8969 * 8970 * @retval OMX_NoError Success, ready to roll 8971 * OMX_ErrorUndefined 8972 * OMX_ErrorInsufficientResources Not enough memory 8973 **/ 8974 /* ========================================================================== */ 8975 8976 OMX_ERRORTYPE VIDDEC_Set_SN_StreamType(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) 8977 { 8978 8979 WMV9DEC_UALGDynamicParams* pDynParams = NULL; 8980 LCML_DSP_INTERFACE* pLcmlHandle; 8981 char* pTmp = NULL; 8982 OMX_U32 cmdValues[3] = {0, 0, 0}; 8983 void* p = NULL; 8984 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 8985 8986 OMX_PRDSP1(pComponentPrivate->dbg, "Initializing DSP for wmv9 eCompressionFormat 0x%x\n", 8987 pComponentPrivate->pInPortDef->format.video.eCompressionFormat); 8988 8989 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 8990 OMX_MALLOC_STRUCT_SIZED(pDynParams, WMV9DEC_UALGDynamicParams, sizeof(WMV9DEC_UALGDynamicParams) + VIDDEC_PADDING_FULL,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 8991 if (pDynParams == NULL) { 8992 OMX_TRACE4(pComponentPrivate->dbg, "Error: Malloc failed\n"); 8993 eError = OMX_ErrorInsufficientResources; 8994 goto EXIT; 8995 } 8996 memset(pDynParams, 0, sizeof(WMV9DEC_UALGDynamicParams) + VIDDEC_PADDING_FULL); 8997 pTmp = (char*)pDynParams; 8998 pTmp += VIDDEC_PADDING_HALF; 8999 pDynParams = (WMV9DEC_UALGDynamicParams*)pTmp; 9000 9001 pDynParams->size = sizeof(WMV9DEC_UALGDynamicParams); 9002 pDynParams->ulDecodeHeader = 0; 9003 pDynParams->ulDisplayWidth = 0; 9004 pDynParams->ulFrameSkipMode = 0; 9005 pDynParams->ulPPType = 0; 9006 9007 if (pComponentPrivate->nWMVFileType == VIDDEC_WMV_ELEMSTREAM) { 9008 pDynParams->usIsElementaryStream = VIDDEC_SN_WMV_ELEMSTREAM; 9009 } 9010 else { 9011 pDynParams->usIsElementaryStream = VIDDEC_SN_WMV_RCVSTREAM; 9012 } 9013 9014 cmdValues[0] = IUALG_CMD_SETSTATUS; /* add #define IUALG_CMD_SETSTATUS 3 */ 9015 cmdValues[1] = (OMX_U32)(pDynParams); 9016 cmdValues[2] = sizeof(WMV9DEC_UALGDynamicParams); 9017 9018 p = (void*)&cmdValues; 9019 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 9020 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 9021 pComponentPrivate->pLCML != NULL && 9022 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 9023 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 9024 OMX_PRDSP1(pComponentPrivate->dbg, "Sending Control coded command EMMCodecControlAlgCtrl\n"); 9025 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 9026 EMMCodecControlAlgCtrl, 9027 (void*)p); 9028 if(eError != OMX_ErrorNone){ 9029 eError = OMX_ErrorHardware; 9030 pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, 9031 pComponentPrivate->pHandle->pApplicationPrivate, 9032 OMX_EventError, 9033 eError, 9034 OMX_TI_ErrorSevere, 9035 "LCML_ControlCodec function"); 9036 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 9037 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,WMV9DEC_UALGDynamicParams); 9038 goto EXIT; 9039 } 9040 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 9041 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 9042 /*This flag is set to TRUE in the LCML callback from EMMCodecControlAlgCtrl 9043 * this is not the case were we need it*/ 9044 pComponentPrivate->bTransPause = OMX_FALSE; 9045 } 9046 9047 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,WMV9DEC_UALGDynamicParams); 9048 if (eError != OMX_ErrorNone) { 9049 OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError); 9050 } 9051 9052 EXIT: 9053 return eError; 9054 } 9055 9056 9057 9058 /* ========================================================================== */ 9059 /** 9060 * VIDDEC_SetMpeg4_Parameters() Enable Deblocking filter 9061 * 9062 * @param 9063 * pComponentPrivate Component private structure 9064 * 9065 * @retval OMX_NoError Success, ready to roll 9066 * OMX_ErrorUndefined 9067 * OMX_ErrorInsufficientResources Not enough memory 9068 **/ 9069 /* ========================================================================== */ 9070 9071 OMX_ERRORTYPE VIDDEC_SetMpeg4_Parameters(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) 9072 { 9073 MP4VDEC_UALGDynamicParams* pDynParams = NULL; 9074 LCML_DSP_INTERFACE* pLcmlHandle = NULL; 9075 char* pTmp = NULL; 9076 OMX_U32 cmdValues[3] = {0, 0, 0}; 9077 void* p = NULL; 9078 char value[PROPERTY_VALUE_MAX]; 9079 static int mDisableDeblockingIfD1 = 0; 9080 OMX_BOOL bDisDeblocking = OMX_FALSE; 9081 OMX_ERRORTYPE eError = OMX_ErrorUndefined; 9082 9083 property_get("deblocking.video.disableIfD1", value, "0"); 9084 mDisableDeblockingIfD1 = atoi(value); 9085 LOGD_IF(mDisableDeblockingIfD1, "Disabling deblocking if D1 resolution"); 9086 9087 OMX_PRDSP2(pComponentPrivate->dbg,"Initializing DSP for mpeg4 and h263 eCompressionFormat 0x%x\n", 9088 pComponentPrivate->pInPortDef->format.video.eCompressionFormat); 9089 pLcmlHandle = (LCML_DSP_INTERFACE*)pComponentPrivate->pLCML; 9090 OMX_MALLOC_STRUCT_SIZED(pDynParams, MP4VDEC_UALGDynamicParams, sizeof(MP4VDEC_UALGDynamicParams) + VIDDEC_PADDING_FULL,pComponentPrivate->nMemUsage[VIDDDEC_Enum_MemLevel4]); 9091 if (pDynParams == NULL) { 9092 OMX_TRACE4(pComponentPrivate->dbg, "Error: Malloc failed\n"); 9093 eError = OMX_ErrorInsufficientResources; 9094 goto EXIT; 9095 } 9096 memset(pDynParams, 0, sizeof(MP4VDEC_UALGDynamicParams) + VIDDEC_PADDING_FULL); 9097 pTmp = (char*)pDynParams; 9098 pTmp += VIDDEC_PADDING_HALF; 9099 pDynParams = (MP4VDEC_UALGDynamicParams*)pTmp; 9100 #ifdef VIDDEC_SN_R8_14 9101 pDynParams->size = sizeof(MP4VDEC_UALGDynamicParams); 9102 #endif 9103 pDynParams->ulDecodeHeader = 0; 9104 pDynParams->ulDisplayWidth = 0; 9105 pDynParams->ulFrameSkipMode = 0; 9106 pDynParams->useHighPrecIdctQp1 = 0; 9107 9108 9109 if(mDisableDeblockingIfD1){ 9110 /* Disable if resolution higher than D1 NTSC (720x480) */ 9111 if(pComponentPrivate->pOutPortDef->format.video.nFrameWidth > 480 || 9112 pComponentPrivate->pOutPortDef->format.video.nFrameHeight > 480){ 9113 bDisDeblocking = OMX_TRUE; 9114 LOGD("D1 or higher resolution: Disable Deblocking!!"); 9115 } 9116 } 9117 9118 if(pComponentPrivate->pDeblockingParamType->bDeblocking && bDisDeblocking == OMX_FALSE){ 9119 pDynParams->ulPPType = 1; /* Enable deblocking filter*/ 9120 } 9121 else{ 9122 pDynParams->ulPPType = 0; /* Disable */ 9123 } 9124 9125 cmdValues[0] = IUALG_CMD_SETSTATUS; 9126 cmdValues[1] = (OMX_U32)(pDynParams); 9127 cmdValues[2] = sizeof(MP4VDEC_UALGDynamicParams); 9128 9129 p = (void*)&cmdValues; 9130 if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload && 9131 pComponentPrivate->eLCMLState != VidDec_LCML_State_Destroy && 9132 pComponentPrivate->pLCML != NULL && 9133 pComponentPrivate->bLCMLHalted != OMX_TRUE){ 9134 9135 VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex); 9136 eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, 9137 EMMCodecControlAlgCtrl, 9138 (void*)p); 9139 if (eError != OMX_ErrorNone) { 9140 eError = OMX_ErrorHardware; 9141 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 9142 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP4VDEC_UALGDynamicParams); 9143 goto EXIT; 9144 } 9145 VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex); 9146 VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex); 9147 /*This flag is set to TRUE in the LCML callback from EMMCodecControlAlgCtrl 9148 * this is not the case were we need it*/ 9149 pComponentPrivate->bTransPause = OMX_FALSE; 9150 } 9151 9152 OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP4VDEC_UALGDynamicParams); 9153 9154 if (eError != OMX_ErrorNone) { 9155 OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError); 9156 goto EXIT; 9157 } 9158 9159 EXIT: 9160 return eError; 9161 } 9162 9163 OMX_ERRORTYPE AddStateTransition(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate) { 9164 9165 OMX_ERRORTYPE eError = OMX_ErrorNone; 9166 9167 if(pthread_mutex_lock(&pComponentPrivate->mutexStateChangeRequest)) { 9168 return OMX_ErrorUndefined; 9169 } 9170 9171 /* Increment state change request reference count */ 9172 pComponentPrivate->nPendingStateChangeRequests++; 9173 9174 if(pthread_mutex_unlock(&pComponentPrivate->mutexStateChangeRequest)) { 9175 return OMX_ErrorUndefined; 9176 } 9177 9178 return eError; 9179 } 9180 9181 OMX_ERRORTYPE RemoveStateTransition(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate, OMX_BOOL bEnableSignal) { 9182 OMX_ERRORTYPE eError = OMX_ErrorNone; 9183 9184 /* Decrement state change request reference count*/ 9185 if(pthread_mutex_lock(&pComponentPrivate->mutexStateChangeRequest)) { 9186 return OMX_ErrorUndefined; 9187 } 9188 9189 pComponentPrivate->nPendingStateChangeRequests--; 9190 9191 /* If there are no more pending requests, signal the thread waiting on this*/ 9192 if(!pComponentPrivate->nPendingStateChangeRequests && bEnableSignal) { 9193 pthread_cond_signal(&(pComponentPrivate->StateChangeCondition)); 9194 } 9195 9196 if(pthread_mutex_unlock(&pComponentPrivate->mutexStateChangeRequest)) { 9197 return OMX_ErrorUndefined; 9198 } 9199 9200 return eError; 9201 } 9202 9203 OMX_ERRORTYPE IncrementCount (OMX_U8 * pCounter, pthread_mutex_t *pMutex) { 9204 OMX_ERRORTYPE eError = OMX_ErrorNone; 9205 if(pthread_mutex_lock(pMutex)) { 9206 return OMX_ErrorUndefined; 9207 } 9208 (*pCounter)++; 9209 if(pthread_mutex_unlock(pMutex)) { 9210 return OMX_ErrorUndefined; 9211 } 9212 return eError; 9213 } 9214 9215 OMX_ERRORTYPE DecrementCount (OMX_U8 * pCounter, pthread_mutex_t *pMutex) { 9216 OMX_ERRORTYPE eError = OMX_ErrorNone; 9217 if(pthread_mutex_lock(pMutex)) { 9218 return OMX_ErrorUndefined; 9219 } 9220 (*pCounter)--; 9221 if(pthread_mutex_unlock(pMutex)) { 9222 return OMX_ErrorUndefined; 9223 } 9224 return eError; 9225 } 9226 9227