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_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–1121 of 1121. Previous lines
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_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; } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////