1263 lines · 49.0 KB · C++
RawDownload
  }  break;  case ENCODER_OPTION_NUMBER_REF: {    int32_t iValue = * ((int32_t*)pOption);    CheckReferenceNumSetting (iValue);    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_NUMBER_REF,expected refNum = %d,actual refnum = %d", iValue,             m_pEncContext->pSvcParam->iNumRefFrame);  }  break;  case ENCODER_OPTION_DELIVERY_STATUS: {    SDeliveryStatus* pValue = (static_cast<SDeliveryStatus*> (pOption));    m_pEncContext->bDeliveryFlag = pValue->bDeliveryFlag;    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_DELIVERY_STATUS,bDeliveryFlag = %d", pValue->bDeliveryFlag);  }  break;  case ENCODER_OPTION_COMPLEXITY: {    int32_t iValue = * (static_cast<int32_t*> (pOption));    m_pEncContext->pSvcParam->iComplexityMode = (ECOMPLEXITY_MODE)iValue;    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_COMPLEXITY,iComplexityMode = %d", iValue);  }  break;  case ENCODER_OPTION_GET_STATISTICS: {    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,             "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_GET_STATISTICS: this option is get-only!");  }  break;  case ENCODER_OPTION_STATISTICS_LOG_INTERVAL: {    int32_t iValue = * (static_cast<int32_t*> (pOption));    m_pEncContext->iStatisticsLogInterval = iValue;    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_STATISTICS_LOG_INTERVAL,iStatisticsLogInterval = %d", iValue);  }  break;  case ENCODER_OPTION_IS_LOSSLESS_LINK: {    bool bValue = * (static_cast<bool*> (pOption));    m_pEncContext->pSvcParam->bIsLosslessLink = bValue;    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_IS_LOSSLESS_LINK,bIsLosslessLink = %d", bValue);  }  break;  default:    return cmInitParaError;  }   return 0;} int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) {  if (NULL == pOption) {    return cmInitParaError;  }  if (NULL == m_pEncContext || false == m_bInitialFlag) {    return cmInitExpected;  }   switch (eOptionId) {  case ENCODER_OPTION_INTER_SPATIAL_PRED: {	// Inter spatial layer prediction flag    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "ENCODER_OPTION_INTER_SPATIAL_PRED, this feature not supported at present.");  }  break;  case ENCODER_OPTION_DATAFORMAT: {	// Input color space#ifdef REC_FRAME_COUNT    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_DATAFORMAT, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x",             m_uiCountFrameNum, m_iCspInternal);#endif//REC_FRAME_COUNT     * ((int32_t*)pOption)	= m_iCspInternal;  }  break;  case ENCODER_OPTION_IDR_INTERVAL: {	// IDR Interval#ifdef REC_FRAME_COUNT    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_IDR_INTERVAL, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x",             m_uiCountFrameNum, m_iCspInternal);#endif//REC_FRAME_COUNT    * ((int32_t*)pOption) = m_pEncContext->pSvcParam->uiIntraPeriod;  }  break;  case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: {	// SVC Encoding Parameter#ifdef REC_FRAME_COUNT    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x",             m_uiCountFrameNum, m_iCspInternal);#endif//REC_FRAME_COUNT    memcpy (pOption, m_pEncContext->pSvcParam, sizeof (SEncParamExt));	// confirmed_safe_unsafe_usage  }  break;  case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: {	// SVC Encoding Parameter#ifdef REC_FRAME_COUNT    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_BASE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x",             m_uiCountFrameNum, m_iCspInternal);#endif//REC_FRAME_COUNT    m_pEncContext->pSvcParam->GetBaseParams ((SEncParamBase*) pOption);  }  break;   case ENCODER_OPTION_FRAME_RATE: {	// Maximal input frame rate#ifdef REC_FRAME_COUNT    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_FRAME_RATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x",             m_uiCountFrameNum, m_iCspInternal);#endif//REC_FRAME_COUNT    * ((float*)pOption)	= m_pEncContext->pSvcParam->fMaxFrameRate;  }  break;  case ENCODER_OPTION_BITRATE: {	// Target bit-rate#ifdef REC_FRAME_COUNT    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_BITRATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x",             m_uiCountFrameNum, m_iCspInternal);#endif//REC_FRAME_COUNT    SBitrateInfo* pInfo = (static_cast<SBitrateInfo*> (pOption));    if ((pInfo->iLayer != SPATIAL_LAYER_ALL) && (pInfo->iLayer != SPATIAL_LAYER_0) && (pInfo->iLayer != SPATIAL_LAYER_1)        && (pInfo->iLayer != SPATIAL_LAYER_2) && (pInfo->iLayer != SPATIAL_LAYER_3))      return cmInitParaError;    if (pInfo->iLayer == SPATIAL_LAYER_ALL) {      pInfo->iBitrate = m_pEncContext->pSvcParam->iTargetBitrate;    } else {      pInfo->iBitrate = m_pEncContext->pSvcParam->sSpatialLayers[pInfo->iLayer].iSpatialBitrate;    }  }  break;  case ENCODER_OPTION_MAX_BITRATE: {	// Target bit-rate#ifdef REC_FRAME_COUNT    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,             "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_MAX_BITRATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x",             m_uiCountFrameNum, m_iCspInternal);#endif//REC_FRAME_COUNT    SBitrateInfo* pInfo = (static_cast<SBitrateInfo*> (pOption));    if ((pInfo->iLayer != SPATIAL_LAYER_ALL) && (pInfo->iLayer != SPATIAL_LAYER_0) && (pInfo->iLayer != SPATIAL_LAYER_1)        && (pInfo->iLayer != SPATIAL_LAYER_2) && (pInfo->iLayer != SPATIAL_LAYER_3))      return cmInitParaError;    if (pInfo->iLayer == SPATIAL_LAYER_ALL) {      pInfo->iBitrate = m_pEncContext->pSvcParam->iMaxBitrate;    } else {      pInfo->iBitrate = m_pEncContext->pSvcParam->sSpatialLayers[pInfo->iLayer].iMaxSpatialBitrate;    }  }  break;  case ENCODER_OPTION_GET_STATISTICS: {    SEncoderStatistics* pStatistics = (static_cast<SEncoderStatistics*> (pOption));    pStatistics->uiWidth = m_pEncContext->sEncoderStatistics.uiWidth;    pStatistics->uiHeight = m_pEncContext->sEncoderStatistics.uiHeight;    pStatistics->fAverageFrameSpeedInMs = m_pEncContext->sEncoderStatistics.fAverageFrameSpeedInMs;     // rate control related    pStatistics->fAverageFrameRate = m_pEncContext->sEncoderStatistics.fAverageFrameRate;    pStatistics->fLatestFrameRate = m_pEncContext->sEncoderStatistics.fLatestFrameRate;    pStatistics->uiBitRate = m_pEncContext->sEncoderStatistics.uiBitRate;     pStatistics->uiInputFrameCount = m_pEncContext->sEncoderStatistics.uiInputFrameCount;    pStatistics->uiSkippedFrameCount = m_pEncContext->sEncoderStatistics.uiSkippedFrameCount;     pStatistics->uiResolutionChangeTimes = m_pEncContext->sEncoderStatistics.uiResolutionChangeTimes;    pStatistics->uiIDRReqNum = m_pEncContext->sEncoderStatistics.uiIDRReqNum;    pStatistics->uiIDRSentNum = m_pEncContext->sEncoderStatistics.uiIDRSentNum;    pStatistics->uiLTRSentNum = m_pEncContext->sEncoderStatistics.uiLTRSentNum;  }  break;  case ENCODER_OPTION_STATISTICS_LOG_INTERVAL: {    * ((int32_t*)pOption)	= m_pEncContext->iStatisticsLogInterval;  }  break;  case ENCODER_OPTION_COMPLEXITY: {    * ((int32_t*)pOption) =  m_pEncContext->pSvcParam->iComplexityMode;  }  break;  default:    return cmInitParaError;  }   return 0;} void CWelsH264SVCEncoder::DumpSrcPicture (const uint8_t* pSrc) {#ifdef DUMP_SRC_PICTURE  FILE* pFile = NULL;  char strFileName[256] = {0};  const int32_t iDataLength = m_iMaxPicWidth * m_iMaxPicHeight;   WelsStrncpy (strFileName, 256, "pic_in_");	// confirmed_safe_unsafe_usage   if (m_iMaxPicWidth == 640) {    WelsStrcat (strFileName, 256, "360p.");	// confirmed_safe_unsafe_usage  } else if (m_iMaxPicWidth == 320) {    WelsStrcat (strFileName, 256, "180p.");	// confirmed_safe_unsafe_usage  } else if (m_iMaxPicWidth == 160) {    WelsStrcat (strFileName, 256, "90p.");	// confirmed_safe_unsafe_usage  }   switch (m_iCspInternal) {  case videoFormatI420:  case videoFormatYV12:    WelsStrcat (strFileName, 256, "yuv");	// confirmed_safe_unsafe_usage    pFile = WelsFopen (strFileName, "ab+");    //				WelsLog( &m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "WELS_CSP_I420, m_iCspInternal= 0x%x", m_iCspInternal);    if (NULL != pFile) {      fwrite (pSrc, sizeof (uint8_t), (iDataLength * 3) >> 1, pFile);      fflush (pFile);      fclose (pFile);    }    break;  case videoFormatRGB:    WelsStrcat (strFileName, 256, "rgb");	// confirmed_safe_unsafe_usage    pFile = WelsFopen (strFileName, "ab+");    if (NULL != pFile) {      fwrite (pSrc, sizeof (uint8_t), iDataLength * 3, pFile);      fflush (pFile);      fclose (pFile);    }  case videoFormatBGR:    WelsStrcat (strFileName, 256, "bgr");	// confirmed_safe_unsafe_usage    pFile = WelsFopen (strFileName, "ab+");    //				WelsLog( &m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "WELS_CSP_BGR, m_iCspInternal= 0x%x", m_iCspInternal);    if (NULL != pFile) {      fwrite (pSrc, sizeof (uint8_t), iDataLength * 3, pFile);      fflush (pFile);      fclose (pFile);    }    break;  case videoFormatYUY2:    WelsStrcat (strFileName, 256, "yuy2");	// confirmed_safe_unsafe_usage    pFile = WelsFopen (strFileName, "ab+");    if (NULL != pFile) {      fwrite (pSrc, sizeof (uint8_t), (CALC_BI_STRIDE (m_iMaxPicWidth,  16)) * m_iMaxPicHeight, pFile);      fflush (pFile);      fclose (pFile);    }    break;  default:    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "Exclusive case, m_iCspInternal= 0x%x", m_iCspInternal);    break;  }#endif//DUMP_SRC_PICTURE  return;}} using namespace WelsEnc; int32_t WelsCreateSVCEncoder (ISVCEncoder** ppEncoder) {  if ((*ppEncoder = new CWelsH264SVCEncoder()) != NULL) {    return 0;  }   return 1;} void WelsDestroySVCEncoder (ISVCEncoder* pEncoder) {  CWelsH264SVCEncoder* pSVCEncoder = (CWelsH264SVCEncoder*)pEncoder;   if (pSVCEncoder) {    delete pSVCEncoder;    pSVCEncoder = NULL;  }}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Lines 1001–1263 of 1263. Previous lines

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t