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