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