float BoundingBox::MaxDimension()
{
	float fltMax = -1;

	fltMax = STD_MAX(fabs(Min.x), fabs(Min.y));
	fltMax = STD_MAX((double) fltMax, fabs(Min.z));

	fltMax = STD_MAX((double) fltMax, fabs(Max.x));
	fltMax = STD_MAX((double) fltMax, fabs(Max.y));
	fltMax = STD_MAX((double) fltMax, fabs(Max.z));

	return fltMax;
}
Ejemplo n.º 2
0
//YUV convert to RGB
void YCbCrT_to_RGBA(int Y, int Cb, int Cr, int T,
                    uint8_t *R, uint8_t *G, uint8_t *B, uint8_t *A) {
    int r, g, b;
    int Ey, Epb, Epr;
    Ey = (Y - 16);
    Epb = (Cb - 128);
    Epr = (Cr - 128);
    /* ITU-R 709 */
    r = STD_MAX(STD_MIN(((298 * Ey             + 460 * Epr) / 256), 255), 0);
    g = STD_MAX(STD_MIN(((298 * Ey -  55 * Epb - 137 * Epr) / 256), 255), 0);
    b = STD_MAX(STD_MIN(((298 * Ey + 543 * Epb            ) / 256), 255), 0);

    *R = (uint8_t)r;
    *G = (uint8_t)g;
    *B = (uint8_t)b;
    *A = T;
}
/** @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;
}