bool HTTPSourceMMIExtensionEventHandler::HTTPMMIEventQManager<T>::Peek
(
 T& eventToRead
)
{
  bool bOk = false;

  //Check if the queue is already empty, if not get the event from
  //the queue
  if (IsQEmpty())
  {
    QTV_MSG_PRIO( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                  "MMIEventQManager - MMI event queue empty" );
  }
  else
  {
    (void)MM_CriticalSection_Enter(m_hEventQLock);
    if (m_nEventReadIndex < ARR_SIZE(m_eventQ))
    {
      bOk = true;
      eventToRead = m_eventQ[m_nEventReadIndex];

      QTV_MSG_PRIO2( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                     "MMIEventQManager - Peeked event from index %u, "
                     "%u events remain", m_nEventReadIndex, m_nOutstandingEvents );
    }
    (void)MM_CriticalSection_Leave(m_hEventQLock);
  }

  return bOk;
}
Exemplo n.º 2
0
/*
 * This function is called with a presentation (printable or ASCII) format
 * address to be converted to its network address (binary) format.  The af
 * argument can be either AF_INET if the address to be converted is an IPv4
 * address or AF_INET6 if the address is an IPv6 address.  In case of error
 * the error code is returned in the dss_errno argument.
 *
 * The dst argument should have sufficient memory for the network address
 * of the appropriate family.  For IPv4 it should be at least
 * sizeof(struct in_addr) while for IPv6 it should be at least
 * sizeof(struct in6_addr).
 */
int32 inet_pton
(
  int32       af,        /* Address family of address in src argument      */
  const char *src,       /* String containing presentation form IP address */
  void *dst     /* Memory for returning address in network format */
)
{
  int32 retval = STREAMNET_FAILED;
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  if (src == NULL || dst == NULL)
  {
    QTV_MSG_PRIO2( QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
                   "inet_pton(): Called with src %p, dst %p", src, dst );
    return STREAMNET_FAILED;
  }
  if(af)
  {
    int32 retval_tmp = ::inet_pton(af, src, dst);
    if(retval_tmp == 1)
    {
      retval = STREAMNET_SUCCESS;
    }
  }

  return retval;
} /* inet_pton() */
Exemplo n.º 3
0
void convertFrameInfoToFrameDetails(struct Vdec_FrameDetailsType *Frame_details,
                struct vdec_frame_info *pFrame)
{
   int i;
   if (NULL == Frame_details || NULL == pFrame) {
      QTV_MSG_PRIO2(QTVDIAG_GENERAL, QTVDIAG_PRIO_LOW,
               "convertFrameInfoToFrameDetails() Frame Details or vdec-frame NULL "
               "Frame Details: 0x%x, pFrame: 0x%x\n",
               Frame_details, pFrame);
   }
   Frame_details->status = (Vdec_StatusType) pFrame->status;   //TBD
   Frame_details->userData1 = pFrame->data1;
   Frame_details->userData2 = pFrame->data2;
   Frame_details->timestamp =
       (unsigned long long)((unsigned long long)pFrame->
             timestamp_hi << 32 | (unsigned long long)
             pFrame->timestamp_lo & 0x0FFFFFFFFLL);
   Frame_details->calculatedTimeStamp =
       (unsigned long long)((unsigned long long)pFrame->
             cal_timestamp_hi << 32 | (unsigned long long)
             pFrame->cal_timestamp_lo & 0x0FFFFFFFFLL);
   Frame_details->nDecPicWidth = pFrame->dec_width;
   Frame_details->nDecPicHeight = pFrame->dec_height;
   Frame_details->cwin.x1 = pFrame->cwin.x1;
   Frame_details->cwin.y1 = pFrame->cwin.y1;
   Frame_details->cwin.x2 = pFrame->cwin.x2;
   Frame_details->cwin.y2 = pFrame->cwin.y2;
   for (i = 0; i < MAX_FIELDS; i++) {
      Frame_details->ePicType[i] =
          (Vdec_PictureType) pFrame->picture_type[i];
   }
   Frame_details->ePicFormat = (Vdec_PictureFormat) pFrame->picture_format;
   Frame_details->nVC1RangeY = pFrame->vc1_rangeY;
   Frame_details->nVC1RangeUV = pFrame->vc1_rangeUV;
   Frame_details->ePicResolution =
       (Vdec_PictureRes) pFrame->picture_resolution;
   Frame_details->nRepeatProgFrames = pFrame->frame_disp_repeat;
   Frame_details->bRepeatFirstField = pFrame->repeat_first_field;
   Frame_details->bTopFieldFirst = pFrame->top_field_first;
   Frame_details->bFrameInterpFlag = pFrame->interframe_interp;
   Frame_details->panScan.numWindows = pFrame->panscan.num;
   for (i = 0; i < MAX_VC1_PAN_SCAN_WINDOWS; i++) {
      Frame_details->panScan.winHeight[i] = pFrame->panscan.width[i];
      Frame_details->panScan.winHeight[i] = pFrame->panscan.height[i];
      Frame_details->panScan.winHorOffset[i] =
          pFrame->panscan.xoffset[i];
      Frame_details->panScan.winVerOffset[i] =
          pFrame->panscan.yoffset[i];
   }

   Frame_details->nPercentConcealedMacroblocks =
       pFrame->concealed_macblk_num;
   Frame_details->flags = pFrame->flags;
   Frame_details->performanceStats = pFrame->performance_stats;
}
/** @brief PLAYLIST_READY state handler.
*
* @param[in] pDownloadHelper - Reference to
*       PlaylistDownloadHelper
* @return
* HTTPDL_WAITING - Data successfully written or no data available to write
*                  and download incomplete
* HTTPDL_SUCCESS - Download complete
* HTTPDL_ERROR_ABORT - Otherwise
*/
HTTPDownloadStatus PlaylistDownloadHelper::PlaylistReadyStateHandler::Execute
(
 PlaylistDownloadHelper* pDownloadHelper
 )
{
  QTV_MSG_PRIO( QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_LOW,
    "PlaylistDownloadHelper::PlaylistReadyStateHandler::Execute()" );
  HTTPDownloadStatus status = HTTPCommon::HTTPDL_ERROR_ABORT;
  PlaylistDownloadHelper* pSelf = pDownloadHelper;

  //Validity check
  if (pSelf)
  {
    char* pRepresentationBuf = pSelf->m_RepresentationBuffer;
    int numBytesToRead = STD_MAX(0, pSelf->m_nRepresentationLen - pSelf->m_nRepresentationBytesRead);
    HTTPStackInterface& HTTPStack = *(pSelf->m_pHTTPStack);
    QTV_MSG_PRIO2( QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_MEDIUM,
      "numBytesToRead %d, (numBytesReceived %d)",
      numBytesToRead, pSelf->m_nRepresentationBytesRead );

    if (pSelf->m_RepresentationBuffer && numBytesToRead > 0)
    {
      status = HTTPCommon::HTTPDL_ERROR_ABORT;
      //Get a data chunk from HTTP stack
      size_t numBytesRead = 0;
      HTTPReturnCode result =
        HTTPStack.GetData(pSelf->m_nRequestID,
        pRepresentationBuf+pSelf->m_nRepresentationBytesRead,
        numBytesToRead,
        &numBytesRead);
      if (result != HTTP_FAILURE && result != HTTP_BADPARAM)
      {
        //Update total number of bytes dowloaded/written so far
        pSelf->m_nRepresentationBytesRead += (int)numBytesRead;
        status = HTTPCommon::HTTPDL_WAITING;
        if(result == HTTP_NOMOREDATA ||
          pSelf->m_nRepresentationBytesRead >= (pSelf->m_nRepresentationLen -1))
        {
          pSelf->m_nRepresentationLen = pSelf->m_nRepresentationBytesRead;
          status = HTTPCommon::HTTPDL_SUCCESS;
        }
        QTV_MSG_PRIO1( QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_HIGH,
          "Total numBytesReceived %d",  pSelf->m_nRepresentationBytesRead );
      }// result check
      else
      {
        //Data read failure
        QTV_MSG_PRIO1( QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_ERROR,
          "Error: Data read failure %d from HTTP stack", result );
      }
    }// if (HTTPSUCCEEDED(status))
  }// if (pSelf && pSelf->GetState() == DATA_READY)
  return status;
}
Exemplo n.º 5
0
Vdec_ReturnType vdec_release_frame(struct VDecoder *dec, struct vdec_frame *frame)
{
  VDEC_FRAME vdecFrame;
  VideoDecoder *pDec = (VideoDecoder*)(dec->core);
  QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: release_frame %p\n", frame);  
  if (NULL == dec || NULL == frame)
  {
	  QTV_MSG_PRIO2(QTVDIAG_GENERAL,QTVDIAG_PRIO_ERROR,"vdec: error: encountered NULL parameter vdec: 0x%x frame: 0x%x", (unsigned int)dec, (unsigned int)frame);
      return VDEC_EFAILED;
  } 
  //vdecFrame.pBuf = (VDEC_BYTE*)frame->phys;
  vdecFrame.pBuf = (VDEC_BYTE*)frame->base;
  vdecFrame.timestamp = (unsigned long long)frame->timestamp;
  pDec->ReuseFrameBuffer(&vdecFrame);

  QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: released_frame with ptr: 0x%x", (unsigned int)vdecFrame.pBuf);
  return VDEC_SUCCESS;
}
/** @brief Invoke the registered generic callback for the MMI base interface.
*
* @param[in] eventID - The async event to be reported in the callback
*/
void HTTPSourceMMIHelper::NotifyMmi
(
 OMX_U32 nEvtCode,
 OMX_U32 nEvtStatus,
 size_t nPayloadLen,
 void *pEvtData,
 void * /*pClientData*/
 )
{
  if (m_pHTTPSourceMMI && m_pHTTPSourceMMI->m_HTTPSourceMMIAsync_CB)
  {
    OMX_U32 eventID = 0;
    if(pEvtData)
    {
      MMI_ExtSpecificMsgType* mmiExtMsg;
      mmiExtMsg = (MMI_ExtSpecificMsgType *)pEvtData;
      eventID = mmiExtMsg->nData2;
    }
    if (m_pHTTPSourceMMI->IsShutDownInProgress() && !(eventID == QOMX_HTTP_IndexParamQOEStop))
    {
      QTV_MSG_PRIO(QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_HIGH,
        "HTTPSourceMMIHelper::NotifyMmi - Shutdown in progress,"
        " not sending any notifications to MMI");
    }
    else
    {
      QTV_MSG_PRIO2( QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_HIGH,
        "HTTPSourceMMIHelper::NotifyMmi - "
        "Async notification [event code - %d :Event Status - %d] "
        "sent to MMI source filter",
        (uint32)(nEvtCode-MMI_MSG_BASE), (uint32)(nEvtStatus-MMI_S_BASE));
      m_pHTTPSourceMMI->m_HTTPSourceMMIAsync_CB(nEvtCode, nEvtStatus,
        (OMX_U32)nPayloadLen, pEvtData,
        m_pHTTPSourceMMI->m_pClientData);
    }
  }
  else
  {
    QTV_MSG_PRIO( QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_ERROR,
      "Error: MMI async event suppressed - either "
      "m_pHTTPSourceMMI is NULL or CB not registered" );
  }
}
bool HTTPSourceMMIExtensionEventHandler::HTTPMMIEventQManager<T>::Enqueue
(
 const T& eventToWrite
)
{
  bool bOk = false;

  //Check if the queue is already full, if not push the new event
  //into the queue
  if (IsQFull())
  {
    QTV_MSG_PRIO( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                  "MMIEventQManager - MMI event queue full" );
  }
  else
  {
    (void)MM_CriticalSection_Enter(m_hEventQLock);
    if (m_nEventWriteIndex < ARR_SIZE(m_eventQ))
    {
      //Update the write index and number of queued events
      bOk = true;
      m_eventQ[m_nEventWriteIndex] = eventToWrite;
      m_nOutstandingEvents++;
      QTV_MSG_PRIO2( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                     "MMIEventQManager - Queued event to index %u, "
                     "%u events remain", m_nEventReadIndex, m_nOutstandingEvents );
      m_nEventWriteIndex = (m_nEventWriteIndex + 1) % (uint32)ARR_SIZE(m_eventQ);
    }
    else
    {
      QTV_MSG_PRIO1( QTVDIAG_STREAMING, QTVDIAG_PRIO_ERROR,
                     "MMIEventQManager - Invalid MMI event queue write index %u",
                     m_nEventWriteIndex );
    }
    (void)MM_CriticalSection_Leave(m_hEventQLock);
  }

  return bOk;
}
bool HTTPSourceMMIExtensionEventHandler::HTTPMMIEventQManager<T>::Dequeue
(
 T& eventToRead
)
{
  bool bOk = false;

  //Check if the queue is already empty, if not get the event from
  //the queue
  if (IsQEmpty())
  {
    QTV_MSG_PRIO( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                  "MMIEventQManager - MMI event queue empty" );
  }
  else
  {
    (void)MM_CriticalSection_Enter(m_hEventQLock);
    if (m_nEventReadIndex < ARR_SIZE(m_eventQ))
    {
      //Dequeue the event and update the read index and number of queued events
      bOk = true;
      eventToRead = m_eventQ[m_nEventReadIndex];
      m_nOutstandingEvents--;
      QTV_MSG_PRIO2( QTVDIAG_STREAMING, QTVDIAG_PRIO_MEDIUM,
                     "MMIEventQManager - Dequeued event from index %u, "
                     "%u events remain", m_nEventReadIndex, m_nOutstandingEvents );
      m_nEventReadIndex = (m_nEventReadIndex + 1) % (uint32)ARR_SIZE(m_eventQ);
    }
    else
    {
      QTV_MSG_PRIO1( QTVDIAG_STREAMING, QTVDIAG_PRIO_ERROR,
                     "MMIEventQManager - Invalid MMI event queue read index %u",
                     m_nEventReadIndex );
    }
    (void)MM_CriticalSection_Leave(m_hEventQLock);
  }
  return bOk;
}
/**
 * @brief Process the Buffering Status and enqueu the status
 *         and Notify clinet if required
 *
 * @param pHTTPSourceMMIHelper
 * @param portID
 * @param bDataAvailable
 * @param pClientData
 *
 * @return bool
 */
bool HTTPSourceMMIExtensionEventHandler::HTTPBufferingEventManager::ProcessBufferingStatus
(
  HTTPSourceMMIHelper *pHTTPSourceMMIHelper,
  const uint32 portID,
  bool bDataAvailable,
  void *pClientData
)
{
  bool bOk = false;

  QOMX_WATERMARKTYPE eCurrentBufferingEventType =
    (bDataAvailable == true)? QOMX_WATERMARK_NORMAL: QOMX_WATERMARK_UNDERRUN;

  if(eCurrentBufferingEventType != GetCurrentWatermarkType())
  {
    SetCurrentWatermarkType(eCurrentBufferingEventType);

    bool bNotify = m_HTTPBufferingEventMgr[eCurrentBufferingEventType].GetNotify();

    if(bNotify)
    {
      if(pHTTPSourceMMIHelper)
      {
        bOk = NotifyBufferingEvent(pHTTPSourceMMIHelper,portID,pClientData);
        if(eCurrentBufferingEventType == QOMX_WATERMARK_UNDERRUN)
        {
          pHTTPSourceMMIHelper->UpdateRebufCount(1);
        }
        QTV_MSG_PRIO2(QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_MEDIUM,
          "ProcessBufferingStatus: Notify watermark event on port %u as reached watermark type %d",
          portID, (int)eCurrentBufferingEventType);
      }
    }
  }

  return bOk;
}
void
HTTPStackHelper::SetState(HTTPStateBase *state)
{
  QTV_MSG_PRIO2(QTVDIAG_HTTP_STACK, QTVDIAG_PRIO_HIGH,
    "HTTPStackHelper::SetState. Transition from '%s' to '%s'",
    m_HTTPState->GetStateName(),
    state->GetStateName());

  m_HTTPState = state;

  // Update state information

  if (&(HTTPStackStateObjects::HTTPStateIdleObj) == state)
  {
    m_HTTPStateInfo.ResetPersistentConnection();
    StartNewRequest();
    ResetOptions();
  }
  else
  if (&(HTTPStackStateObjects::HTTPStateClosedObj) == state)
  {
    m_HTTPStateInfo.ResetPersistentConnection();
  }
}
Exemplo n.º 11
0
Vdec_ReturnType vdec_post_input_buffer(struct VDecoder *dec, video_input_frame_info *frame, void *cookie)
{
  QTV_MSG_PRIO3(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: post_input data=%p len=%d cookie=%p\n", frame->data, frame->len, cookie);
#ifdef LOG_INPUT_BUFFERS
  static int take_input = 1;
#endif
  int fatal_err = 0;

  /*checkBufAvail flag is needed since we do not need to checkout
   * YUV/Slice buffer incase the NAL corresponds to same frame.
   * This is required for multiple NALs in one input buffer
   */
  bool checkBufAvail = true;
  VDEC_INPUT_BUFFER input;
  VideoDecoder *pDec = (VideoDecoder*)(dec->core);
  VDEC_ERROR err  = VDEC_ERR_EVERYTHING_FINE;
  if (NULL == dec || NULL == frame || NULL == frame->data )
  {
	  QTV_MSG_PRIO3(QTVDIAG_GENERAL,QTVDIAG_PRIO_ERROR,"vdec: error: encountered NULL parameter dec: 0x%x frame: 0x%x data: 0x%x\n", 
		   (unsigned int)dec, 
		   (unsigned int)frame,
		   (unsigned int)frame->data);
    return VDEC_EFAILED;
  }

  input.buffer[0]      = (unsigned char*)frame->data;
  input.timestamp[0]   = (long long)frame->timestamp;
  input.buffer_size[0] = (unsigned long int)frame->len;
  input.buffer_pos[0]  = 0;
  input.layers         = 1;
  input.eOSIndicator[0]= false;

  QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_MED,"vdec: received ts: %lld", frame->timestamp);
  if (frame->timestamp < timestamp )
  {
	  QTV_MSG_PRIO2(QTVDIAG_GENERAL,QTVDIAG_PRIO_MED,"vdec: error: out of order stamp! %d < %d\n",
                  (int)(frame->timestamp&0xFFFFFFFF), timestamp);
  }
  timestamp = (int)frame->timestamp;

  QTV_MSG_PRIO2(QTVDIAG_GENERAL,QTVDIAG_PRIO_MED,"vdec: vdec_core_post_input. buffer_size[0]: %ld frame->flags: 0x%x\n",
                input.buffer_size[0], frame->flags);

  if (input.buffer_size[0] == 0 && frame->flags & FRAME_FLAG_EOS)
  {
	  QTV_MSG_PRIO(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: Zero-length buffer with EOS bit set\n");
          input.eOSIndicator[0] = true;

    if(pDec)
		err =  pDec->EOS( );
	else
		err = VDEC_ERR_NULL_STREAM_ID;

    if(VDEC_ERR_OUT_OF_BUFFERS == err) return VDEC_EOUTOFBUFFERS; 
    vdec_decoder_info->ctxt->buffer_done(vdec_decoder_info->ctxt, cookie);
    if (VDEC_ERR_EVERYTHING_FINE == err) return VDEC_SUCCESS;
    return VDEC_EFAILED;
  }

  QTV_MSG_PRIO(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: vdec_core_post_input\n");

#ifdef LOG_INPUT_BUFFERS
  if (take_input)
  {
    fwritex((unsigned char*)frame->data, frame->len, pInputFile);
	QTV_MSG_PRIO2(QTVDIAG_GENERAL,QTVDIAG_PRIO_HIGH,"vdec: frame %d frame->len %d\n", counter++, frame->len);
  }
#endif

  do {
    QPERF_TIME(arm_decode, err = pDec->Decode( &input, checkBufAvail ));
    if (VDEC_ERR_EVERYTHING_FINE != err)
    {
		QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_HIGH,"vdec: vdec_decoder error: %d\n", (int)err);
		if(VDEC_ERR_UNSUPPORTED_DIMENSIONS == err) {
			fatal_err = 1;
			break;
		}
    }
    checkBufAvail = false;
  } while( ( VDEC_ERR_EVERYTHING_FINE == err ) && ( 0 != input.buffer_size[0] ) );

#ifdef LOG_INPUT_BUFFERS
  take_input = (err==14?0:1);
#endif
  if(VDEC_ERR_OUT_OF_BUFFERS == err) return VDEC_EOUTOFBUFFERS;
  vdec_input_buffer_release_cb_handler(pDec,&input,cookie);
  if(VDEC_ERR_EVERYTHING_FINE == err) return VDEC_SUCCESS;
  if(fatal_err) {
      static struct vdec_frame frame;
      memset(&frame, 0, sizeof(frame));
      frame.flags |= FRAME_FLAG_FATAL_ERROR;
      QPERF_END(frame_data);
      vdec_decoder_info->ctxt->frame_done(vdec_decoder_info->ctxt, &frame);
  }
  return VDEC_EFAILED;
}
Exemplo n.º 12
0
struct VDecoder *vdec_open(struct vdec_context *ctxt)
{
  struct VDecoder *dec = NULL;
  VDEC_ERROR err = 0;
  const VDEC_CONCURRENCY_CONFIG concurrencyConfig = VDEC_CONCURRENT_NONE;
  VideoDecoder* pDec = NULL;
  dec = (VDecoder*)calloc(1, sizeof(struct VDecoder));
  if (!dec) { 
    return 0;
  }
  dec->ctxt = ctxt;
  dec->width = ctxt->width;
  dec->height = ctxt->height;
  dec->ctxt->outputBuffer.numBuffers = ctxt->outputBuffer.numBuffers;
  if(VDEC_SUCCESS != vdec_commit_memory(dec)) {	
    return 0;
  }

  QPERF_RESET(arm_decode);
  QPERF_RESET(frame_data);
  nFrameDoneCnt = 0;
  nGoodFrameCnt = 0;
#ifdef PROFILE_DECODER
  qperf_total_frame_cnt = 0;
#endif

  vdec_output_frame_index = 0;
  timestamp = 0;
  int i;
  VDEC_PARAMETER_DATA codeDetectionEnable;
  codeDetectionEnable.startCodeDetection.bStartCodeDetectionEnable = false; // by default set to false; MPEG4 doesnt require it

  QTV_MSG_PRIO2(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: vdec_open(). width: %d, height: %d\n", dec->width, dec->height);

  vdec_decoder_info = dec;
  QTV_MSG_PRIO3(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: vdec_open(). width: %d, height: %d kind[%s]\n", 
                                                   vdec_decoder_info->ctxt->width, vdec_decoder_info->ctxt->height, 
                                                   vdec_decoder_info->ctxt->kind);

  if(!strcmp(vdec_decoder_info->ctxt->kind,"OMX.qcom.video.decoder.avc"))
  {
	dec->core = reinterpret_cast<VDEC_STREAM_ID>(pCreateFnH264(&err));
	QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: Creating H264 Decoder [%p]\n",dec->core);
	VDEC_PARAMETER_DATA sizeOfNalLengthField;
        sizeOfNalLengthField.sizeOfNalLengthField.sizeOfNalLengthField = dec->ctxt->size_of_nal_length_field;
		QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: NAL lenght [%d]\n",dec->ctxt->size_of_nal_length_field);
        pDec = (VideoDecoder*)(dec->core);
        if (0 == dec->ctxt->size_of_nal_length_field) 
        {
		   QTV_MSG_PRIO(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: START CODE....\n");
	       codeDetectionEnable.startCodeDetection.bStartCodeDetectionEnable = true;
		   if(!pDec) 
	          err = VDEC_ERR_NULL_STREAM_ID;
	       else
		      err = pDec->SetParameter(VDEC_PARM_START_CODE_DETECTION,&codeDetectionEnable);
           if (VDEC_ERR_EVERYTHING_FINE != err)
           {
		      // TBD- printx("[vdec_core] set start code detection parameter failed: %d", (int)err);
		      QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_ERROR,"[vdec_core] set start code detection parameter failed: %d", (int)err);
              goto fail_initialize;
           }
        }
        else if(dec->ctxt->size_of_nal_length_field > 0 && dec->ctxt->size_of_nal_length_field <= 4)
        {
			QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_ERROR,"vdec: NALU LENGTH[%d]\n",dec->ctxt->size_of_nal_length_field);
           // test size of NAL length field decoder support 
	       if(!pDec) 
	          err = VDEC_ERR_NULL_STREAM_ID;
	       else
             err = pDec->SetParameter( VDEC_PARM_SIZE_OF_NAL_LENGTH_FIELD, &sizeOfNalLengthField );
	       if (VDEC_ERR_EVERYTHING_FINE != err)
           {
             // TBD- printx("[vdec_core] set start code detection parameter failed: %d", (int)err);
             goto fail_initialize;
           }
	    }
	    else
        {
			QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_ERROR,"vdec: Invalid size of nal length field: %d\n", dec->ctxt->size_of_nal_length_field);
            goto fail_core;
        } 
  }
  else if ((!strcmp(vdec_decoder_info->ctxt->kind,"OMX.qcom.video.decoder.mpeg4")) 
	       || (!strcmp(vdec_decoder_info->ctxt->kind,"OMX.qcom.video.decoder.h263")))
  {
	  dec->core = reinterpret_cast<VDEC_STREAM_ID>(pCreateFnMpeg4(&err));
	  pDec = (VideoDecoder*)(dec->core);
	  QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: Creating MP4 Decoder [%p]\n",dec->core);
  }
  else if (!strcmp(vdec_decoder_info->ctxt->kind,"OMX.qcom.video.decoder.vc1"))
  {
	  dec->core = reinterpret_cast<VDEC_STREAM_ID>(pCreateFnWmv(&err));
	  pDec = (VideoDecoder*)(dec->core);
	  QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_LOW,"vdec: Creating WMV Decoder [%p]\n",dec->core);
  }
  else
  { 
	QTV_MSG_PRIO(QTVDIAG_GENERAL,QTVDIAG_PRIO_ERROR,"Incorrect codec kind\n");
    goto fail_core;
  }

  if (VDEC_ERR_EVERYTHING_FINE != err || NULL == dec->core)
  {
	  QTV_MSG_PRIO(QTVDIAG_GENERAL,QTVDIAG_PRIO_ERROR,"vdec: create failed\n");
      goto fail_core;
  }

  for(i=0; i<VDEC_NFRAMES; i++)
  {
    slice_buffer_info[i].base = (char*)dec->input[i].base;
    //slice_buffer_info[i].phys = dec->input[i].phys;
    slice_buffer_info[i].fd = dec->input[i].pmem_id;
  }
  
  VDEC_DIMENSIONS frameSize;
  frameSize.height = dec->height;
  frameSize.width = dec->width;
  QTV_MSG_PRIO2(QTVDIAG_GENERAL,QTVDIAG_PRIO_HIGH,"vdec: Init width: %d height %d\n", frameSize.width, frameSize.height);

/*  
  VDEC_PARAMETER_DATA deblockerInfo;
  deblockerInfo.deblockerEnable.bDeblockerEnable = true;

  QTV_MSG_PRIO(QTVDIAG_GENERAL,QTVDIAG_PRIO_HIGH,"[vdec_core] SetParameter\n"); 
  err = vdec_set_parameter(dec->core, VDEC_PARM_DEBLOCKER_ENABLE, &deblockerInfo); 
  QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_HIGH,"[vdec_core] after SetParameter\n",err); 
  if (VDEC_ERR_EVERYTHING_FINE != err)
  {
    //TBD - printx("[vdec_core] set deblocker enable parameter failed: %d", (int)err);
    goto fail_initialize;
  }
*/

 
  QTV_MSG_PRIO(QTVDIAG_GENERAL,QTVDIAG_PRIO_HIGH,"vdec: vdec_initialize\n"); 
  if(!pDec) 
	  err = VDEC_ERR_NULL_STREAM_ID;
  else
  {
      err = pDec->Initialize(1,
			                 vdec_frame_buffer_malloc_cb_handler,
				             vdec_frame_buffer_free_cb_handler,
                             vdec_frame_cb_handler,
				             NULL,
				             frameSize,
				             VDEC_CONCURRENT_NONE,
				             slice_buffer_info,
					     dec->ctxt->outputBuffer.numBuffers,
					     ctxt->adsp_fd);
  }

  QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_HIGH,"vdec: vdec_initialize\n",err); 
  if (err != VDEC_ERR_EVERYTHING_FINE)
  {
	  QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_ERROR,"vdec: initialization failed: %d\n", (int)err);
      goto fail_initialize;
  }

#if NEED_VDEC_LP
#ifdef _ANDROID_
  dec->fake = adsp_open("/dev/adsp/VDEC_LP_MODE", dec->core, core_msg_func);
#else
  dec->fake = adsp_open("/dev/VDEC_LP_MODE", dec->core, core_msg_func);
#endif //_ANDROID_
  if (!dec->fake)
  {
	  QTV_MSG_PRIO1(QTVDIAG_GENERAL,QTVDIAG_PRIO_ERROR,"vdec: adsp_open() failed error: %s\n", strerror(errno));
    goto fail_initialize;
  }
  if (adsp_enable((adsp_module*)dec->fake)) goto fail_enable;
#endif

#ifdef LOG_YUV_FRAMES
#ifdef T_WINNT
  pYUVFile = fopen ( "../debug/yuvframes.yuv" , "wb" );
#elif _ANDROID_
  pYUVFile = fopen ( "/data/yuvframes.yuv" , "wb" );
#else
  pYUVFile = fopen ( "yuvframes.yuv" , "wb" );
#endif
#endif

#ifdef LOG_INPUT_BUFFERS
#ifdef T_WINNT
  pInputFile = fopen ( "../debug/inputbuffers.bin" , "wb" );
#elif _ANDROID_
  pInputFile = fopen ( "/data/inputbuffers.bin" , "wb" );
#else
  pInputFile = fopen ( "inputbuffers.bin" , "wb" );
#endif
#endif

  return dec;
fail_enable:
#if NEED_VDEC_LP
  adsp_close((adsp_module*)dec->fake);
#endif
fail_initialize:
  if(pDec) {
	  pDec->Suspend( );
	  QTV_Delete( pDec );
  }
fail_core:
  if (dec) {
    dec->dead = 1;
    free(dec);
  }
  return NULL;

}
Exemplo n.º 13
0
void adsp_close(struct adsp_module *mod)
{
#if PROFILE_DECODER
    QPERF_TERMINATE(dsp_decode);
    QPERF_RESET(dsp_decode);
#endif
#ifndef T_WINNT
   int ret;
   int thread_ret = 0;
   if (NULL == mod) {
      QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
               "adsp_close() mod NULL: 0x%x\n", mod);
      return ;
   }

   mod->dead = 1;

   if (ioctl(mod->fd, VDEC_IOCTL_CLOSE, NULL) < 0) {
      QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
              "VDEC_IOCTL_CLOSE failed\n");
      return;
   }

   QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_LOW, "adsp_close: 0x%x",
            (unsigned)mod);

   /*Wait on the adsp event thread completion */

   ret = pthread_join(mod->thr, (void **)&thread_ret);

   if (ret != 0) {
      QTV_MSG_PRIO1(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
               "*************adsp_close: Could not join on the adsp event thread err=%d!!\n",
               ret);
   }

   /*Wait on the adsp event thread completion */

   ret = close(mod->fd);
   if (ret < 0) {
      QTV_MSG_PRIO(QTVDIAG_GENERAL, QTVDIAG_PRIO_ERROR,
              "*************adsp_close ERROR!");
   }

   QTV_MSG_PRIO2(QTVDIAG_GENERAL, QTVDIAG_PRIO_LOW,
            "adsp_close returned %d, fd: %d", ret, mod->fd);

#if DEBUG
   if (logFD) {
      pthread_mutex_lock(&logMTX);
      fclose(logFD);
      logFD = NULL;
      pthread_mutex_destroy(&logMTX);
   }
#endif

   //sleep(1); /* XXX need better way to stop thread XXX */
   free(mod);
   mod = NULL;
#endif //T_WINNT
}