Showing the changes to codec/encoder/plus/src/welsEncoderExt.cpp (1 of 57 files). Show all
Unified · Split
| @@ -38,7 +38,7 @@ · 37 unmodified lines | ||
| 38 | 38 | #include "utils.h" |
| 39 | 39 | #include "macros.h" |
| 40 | 40 | #include "version.h" |
| 41 | −#include "crt_util_safe_x.h" // Safe CRT routines like util for cross platforms | |
| 41 | +#include "crt_util_safe_x.h" // Safe CRT routines like util for cross platforms | |
| 42 | 42 | #include "ref_list_mgr_svc.h" |
| 43 | 43 | #include "codec_ver.h" |
| 44 | 44 | |
| @@ -654,12 +654,12 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 609 unmodified lines | ||
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | switch (eOptionId) { |
| 657 | − case ENCODER_OPTION_INTER_SPATIAL_PRED: { // Inter spatial layer prediction flag | |
| 657 | + case ENCODER_OPTION_INTER_SPATIAL_PRED: { // Inter spatial layer prediction flag | |
| 658 | 658 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 659 | 659 | "ENCODER_OPTION_INTER_SPATIAL_PRED, this feature not supported at present."); |
| 660 | 660 | } |
| 661 | 661 | break; |
| 662 | − case ENCODER_OPTION_DATAFORMAT: { // Input color space | |
| 662 | + case ENCODER_OPTION_DATAFORMAT: { // Input color space | |
| 663 | 663 | int32_t iValue = * ((int32_t*)pOption); |
| 664 | 664 | int32_t iColorspace = iValue; |
| 665 | 665 | if (iColorspace == 0) { |
| @@ -689,7 +689,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 23 unmodified lines | ||
| 689 | 689 | int32_t iTargetWidth = 0; |
| 690 | 690 | int32_t iTargetHeight = 0; |
| 691 | 691 | |
| 692 | − memcpy (&sEncodingParam, pOption, sizeof (SEncParamBase)); // confirmed_safe_unsafe_usage | |
| 692 | + memcpy (&sEncodingParam, pOption, sizeof (SEncParamBase)); // confirmed_safe_unsafe_usage | |
| 693 | 693 | if (sConfig.ParamBaseTranscode (sEncodingParam)) { |
| 694 | 694 | return cmInitParaError; |
| 695 | 695 | } |
| @@ -721,7 +721,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 25 unmodified lines | ||
| 721 | 721 | int32_t iTargetWidth = 0; |
| 722 | 722 | int32_t iTargetHeight = 0; |
| 723 | 723 | |
| 724 | − memcpy (&sEncodingParam, pOption, sizeof (SEncParamExt)); // confirmed_safe_unsafe_usage | |
| 724 | + memcpy (&sEncodingParam, pOption, sizeof (SEncParamExt)); // confirmed_safe_unsafe_usage | |
| 725 | 725 | TraceParamInfo (&sEncodingParam); |
| 726 | 726 | #ifdef OUTPUT_BIT_STREAM |
| 727 | 727 | if (sEncodingParam.sSpatialLayers[sEncodingParam.iSpatialLayerNum - 1].iVideoWidth != |
| @@ -731,7 +731,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 3 unmodified lines | ||
| 731 | 731 | } |
| 732 | 732 | #endif//OUTPUT_BIT_STREAM |
| 733 | 733 | if (sEncodingParam.iSpatialLayerNum < 1 |
| 734 | − || sEncodingParam.iSpatialLayerNum > MAX_SPATIAL_LAYER_NUM) { // verify number of spatial layer | |
| 734 | + || sEncodingParam.iSpatialLayerNum > MAX_SPATIAL_LAYER_NUM) { // verify number of spatial layer | |
| 735 | 735 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 736 | 736 | "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, iSpatialLayerNum(%d) failed!", |
| 737 | 737 | sEncodingParam.iSpatialLayerNum); |
| @@ -782,7 +782,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 44 unmodified lines | ||
| 782 | 782 | m_pEncContext->pSvcParam->fMaxFrameRate); |
| 783 | 783 | } |
| 784 | 784 | break; |
| 785 | − case ENCODER_OPTION_BITRATE: { // Target bit-rate | |
| 785 | + case ENCODER_OPTION_BITRATE: { // Target bit-rate | |
| 786 | 786 | SBitrateInfo* pInfo = (static_cast<SBitrateInfo*> (pOption)); |
| 787 | 787 | int32_t iBitrate = pInfo->iBitrate; |
| 788 | 788 | if (iBitrate <= 0) { |
| @@ -828,7 +828,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 39 unmodified lines | ||
| 828 | 828 | |
| 829 | 829 | } |
| 830 | 830 | break; |
| 831 | − case ENCODER_OPTION_MAX_BITRATE: { // Target bit-rate | |
| 831 | + case ENCODER_OPTION_MAX_BITRATE: { // Target bit-rate | |
| 832 | 832 | SBitrateInfo* pInfo = (static_cast<SBitrateInfo*> (pOption)); |
| 833 | 833 | int32_t iBitrate = pInfo->iBitrate; |
| 834 | 834 | if (iBitrate <= 0) { |
| @@ -873,7 +873,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 38 unmodified lines | ||
| 873 | 873 | } |
| 874 | 874 | } |
| 875 | 875 | break; |
| 876 | − case ENCODER_OPTION_RC_MODE: { // 0:quality mode;1:bit-rate mode;2:bitrate limited mode | |
| 876 | + case ENCODER_OPTION_RC_MODE: { // 0:quality mode;1:bit-rate mode;2:bitrate limited mode | |
| 877 | 877 | int32_t iValue = * ((int32_t*)pOption); |
| 878 | 878 | m_pEncContext->pSvcParam->iRCMode = (RC_MODES) iValue; |
| 879 | 879 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| @@ -881,7 +881,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 1 unmodified line | ||
| 881 | 881 | iValue); |
| 882 | 882 | } |
| 883 | 883 | break; |
| 884 | − case ENCODER_PADDING_PADDING: { // 0:disable padding;1:padding | |
| 884 | + case ENCODER_PADDING_PADDING: { // 0:disable padding;1:padding | |
| 885 | 885 | int32_t iValue = * ((int32_t*)pOption); |
| 886 | 886 | m_pEncContext->pSvcParam->iPaddingFlag = iValue; |
| 887 | 887 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| @@ -1106,45 +1106,45 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) { · 218 unmodified lines | ||
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | switch (eOptionId) { |
| 1109 | − case ENCODER_OPTION_INTER_SPATIAL_PRED: { // Inter spatial layer prediction flag | |
| 1109 | + case ENCODER_OPTION_INTER_SPATIAL_PRED: { // Inter spatial layer prediction flag | |
| 1110 | 1110 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 1111 | 1111 | "ENCODER_OPTION_INTER_SPATIAL_PRED, this feature not supported at present."); |
| 1112 | 1112 | } |
| 1113 | 1113 | break; |
| 1114 | − case ENCODER_OPTION_DATAFORMAT: { // Input color space | |
| 1114 | + case ENCODER_OPTION_DATAFORMAT: { // Input color space | |
| 1115 | 1115 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 1116 | 1116 | "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_DATAFORMAT, m_iCspInternal= 0x%x", m_iCspInternal); |
| 1117 | 1117 | * ((int32_t*)pOption) = m_iCspInternal; |
| 1118 | 1118 | } |
| 1119 | 1119 | break; |
| 1120 | − case ENCODER_OPTION_IDR_INTERVAL: { // IDR Interval | |
| 1120 | + case ENCODER_OPTION_IDR_INTERVAL: { // IDR Interval | |
| 1121 | 1121 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 1122 | 1122 | "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_IDR_INTERVAL, uiIntraPeriod= %d", |
| 1123 | 1123 | m_pEncContext->pSvcParam->uiIntraPeriod); |
| 1124 | 1124 | * ((int32_t*)pOption) = m_pEncContext->pSvcParam->uiIntraPeriod; |
| 1125 | 1125 | } |
| 1126 | 1126 | break; |
| 1127 | − case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: { // SVC Encoding Parameter | |
| 1127 | + case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: { // SVC Encoding Parameter | |
| 1128 | 1128 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 1129 | 1129 | "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_EXT"); |
| 1130 | − memcpy (pOption, m_pEncContext->pSvcParam, sizeof (SEncParamExt)); // confirmed_safe_unsafe_usage | |
| 1130 | + memcpy (pOption, m_pEncContext->pSvcParam, sizeof (SEncParamExt)); // confirmed_safe_unsafe_usage | |
| 1131 | 1131 | } |
| 1132 | 1132 | break; |
| 1133 | − case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: { // SVC Encoding Parameter | |
| 1133 | + case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: { // SVC Encoding Parameter | |
| 1134 | 1134 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 1135 | 1135 | "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_BASE"); |
| 1136 | 1136 | m_pEncContext->pSvcParam->GetBaseParams ((SEncParamBase*) pOption); |
| 1137 | 1137 | } |
| 1138 | 1138 | break; |
| 1139 | 1139 | |
| 1140 | − case ENCODER_OPTION_FRAME_RATE: { // Maximal input frame rate | |
| 1140 | + case ENCODER_OPTION_FRAME_RATE: { // Maximal input frame rate | |
| 1141 | 1141 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 1142 | 1142 | "CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_FRAME_RATE, fMaxFrameRate = %.6ff", |
| 1143 | 1143 | m_pEncContext->pSvcParam->fMaxFrameRate); |
| 1144 | 1144 | * ((float*)pOption) = m_pEncContext->pSvcParam->fMaxFrameRate; |
| 1145 | 1145 | } |
| 1146 | 1146 | break; |
| 1147 | − case ENCODER_OPTION_BITRATE: { // Target bit-rate | |
| 1147 | + case ENCODER_OPTION_BITRATE: { // Target bit-rate | |
| 1148 | 1148 | |
| 1149 | 1149 | SBitrateInfo* pInfo = (static_cast<SBitrateInfo*> (pOption)); |
| 1150 | 1150 | if ((pInfo->iLayer != SPATIAL_LAYER_ALL) && (pInfo->iLayer != SPATIAL_LAYER_0) && (pInfo->iLayer != SPATIAL_LAYER_1) |
| @@ -1160,7 +1160,7 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) { · 9 unmodified lines | ||
| 1160 | 1160 | pInfo->iLayer, pInfo->iBitrate); |
| 1161 | 1161 | } |
| 1162 | 1162 | break; |
| 1163 | − case ENCODER_OPTION_MAX_BITRATE: { // Target bit-rate | |
| 1163 | + case ENCODER_OPTION_MAX_BITRATE: { // Target bit-rate | |
| 1164 | 1164 | SBitrateInfo* pInfo = (static_cast<SBitrateInfo*> (pOption)); |
| 1165 | 1165 | if ((pInfo->iLayer != SPATIAL_LAYER_ALL) && (pInfo->iLayer != SPATIAL_LAYER_0) && (pInfo->iLayer != SPATIAL_LAYER_1) |
| 1166 | 1166 | && (pInfo->iLayer != SPATIAL_LAYER_2) && (pInfo->iLayer != SPATIAL_LAYER_3)) |
| @@ -1216,20 +1216,20 @@ void CWelsH264SVCEncoder::DumpSrcPicture (const uint8_t* pSrc) { · 49 unmodified lines | ||
| 1216 | 1216 | char strFileName[256] = {0}; |
| 1217 | 1217 | const int32_t iDataLength = m_iMaxPicWidth * m_iMaxPicHeight; |
| 1218 | 1218 | |
| 1219 | − WelsStrncpy (strFileName, 256, "pic_in_"); // confirmed_safe_unsafe_usage | |
| 1219 | + WelsStrncpy (strFileName, 256, "pic_in_"); // confirmed_safe_unsafe_usage | |
| 1220 | 1220 | |
| 1221 | 1221 | if (m_iMaxPicWidth == 640) { |
| 1222 | − WelsStrcat (strFileName, 256, "360p."); // confirmed_safe_unsafe_usage | |
| 1222 | + WelsStrcat (strFileName, 256, "360p."); // confirmed_safe_unsafe_usage | |
| 1223 | 1223 | } else if (m_iMaxPicWidth == 320) { |
| 1224 | − WelsStrcat (strFileName, 256, "180p."); // confirmed_safe_unsafe_usage | |
| 1224 | + WelsStrcat (strFileName, 256, "180p."); // confirmed_safe_unsafe_usage | |
| 1225 | 1225 | } else if (m_iMaxPicWidth == 160) { |
| 1226 | − WelsStrcat (strFileName, 256, "90p."); // confirmed_safe_unsafe_usage | |
| 1226 | + WelsStrcat (strFileName, 256, "90p."); // confirmed_safe_unsafe_usage | |
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | 1229 | switch (m_iCspInternal) { |
| 1230 | 1230 | case videoFormatI420: |
| 1231 | 1231 | case videoFormatYV12: |
| 1232 | − WelsStrcat (strFileName, 256, "yuv"); // confirmed_safe_unsafe_usage | |
| 1232 | + WelsStrcat (strFileName, 256, "yuv"); // confirmed_safe_unsafe_usage | |
| 1233 | 1233 | pFile = WelsFopen (strFileName, "ab+"); |
| 1234 | 1234 | // WelsLog( &m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "WELS_CSP_I420, m_iCspInternal= 0x%x", m_iCspInternal); |
| 1235 | 1235 | if (NULL != pFile) { |
| @@ -1239,7 +1239,7 @@ void CWelsH264SVCEncoder::DumpSrcPicture (const uint8_t* pSrc) { · 3 unmodified lines | ||
| 1239 | 1239 | } |
| 1240 | 1240 | break; |
| 1241 | 1241 | case videoFormatRGB: |
| 1242 | − WelsStrcat (strFileName, 256, "rgb"); // confirmed_safe_unsafe_usage | |
| 1242 | + WelsStrcat (strFileName, 256, "rgb"); // confirmed_safe_unsafe_usage | |
| 1243 | 1243 | pFile = WelsFopen (strFileName, "ab+"); |
| 1244 | 1244 | if (NULL != pFile) { |
| 1245 | 1245 | fwrite (pSrc, sizeof (uint8_t), iDataLength * 3, pFile); |
| @@ -1247,7 +1247,7 @@ void CWelsH264SVCEncoder::DumpSrcPicture (const uint8_t* pSrc) { · 1 unmodified line | ||
| 1247 | 1247 | fclose (pFile); |
| 1248 | 1248 | } |
| 1249 | 1249 | case videoFormatBGR: |
| 1250 | − WelsStrcat (strFileName, 256, "bgr"); // confirmed_safe_unsafe_usage | |
| 1250 | + WelsStrcat (strFileName, 256, "bgr"); // confirmed_safe_unsafe_usage | |
| 1251 | 1251 | pFile = WelsFopen (strFileName, "ab+"); |
| 1252 | 1252 | // WelsLog( &m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "WELS_CSP_BGR, m_iCspInternal= 0x%x", m_iCspInternal); |
| 1253 | 1253 | if (NULL != pFile) { |
| @@ -1257,7 +1257,7 @@ void CWelsH264SVCEncoder::DumpSrcPicture (const uint8_t* pSrc) { · 3 unmodified lines | ||
| 1257 | 1257 | } |
| 1258 | 1258 | break; |
| 1259 | 1259 | case videoFormatYUY2: |
| 1260 | − WelsStrcat (strFileName, 256, "yuy2"); // confirmed_safe_unsafe_usage | |
| 1260 | + WelsStrcat (strFileName, 256, "yuy2"); // confirmed_safe_unsafe_usage | |
| 1261 | 1261 | pFile = WelsFopen (strFileName, "ab+"); |
| 1262 | 1262 | if (NULL != pFile) { |
| 1263 | 1263 | fwrite (pSrc, sizeof (uint8_t), (CALC_BI_STRIDE (m_iMaxPicWidth, 16)) * m_iMaxPicHeight, pFile); |