This avoids the struct type casting and having to pass a parameter that says which kind of struct it actually is.
Showing the changes to codec/encoder/plus/src/welsEncoderExt.cpp (1 of 7 files). Show all
Unified · Split
| @@ -200,33 +200,39 @@ void CWelsH264SVCEncoder::InitEncoder (void) { · 199 unmodified lines | ||
| 200 | 200 | /* |
| 201 | 201 | * SVC Encoder Initialization |
| 202 | 202 | */ |
| 203 | −int CWelsH264SVCEncoder::Initialize (const void* argv, const INIT_TYPE iInitType) { | |
| 203 | +int CWelsH264SVCEncoder::Initialize (const SEncParamBase* argv) { | |
| 204 | 204 | |
| 205 | + if (NULL == argv) { | |
| 206 | + WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid argv= 0x%p\n", | |
| 207 | + argv); | |
| 208 | + return cmInitParaError; | |
| 209 | + } | |
| 205 | 210 | |
| 206 | − if ((INIT_TYPE_PARAMETER_BASED != iInitType && INIT_TYPE_PARAMETER_EXT != iInitType)|| NULL == argv) { | |
| 207 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid iInitType= %d, argv= 0x%p\n", | |
| 208 | − iInitType, (void*)argv); | |
| 211 | + SWelsSvcCodingParam sConfig (true); | |
| 212 | + // Convert SEncParamBase into WelsSVCParamConfig here.. | |
| 213 | + if (sConfig.ParamBaseTranscode (*argv, true)) { | |
| 214 | + WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), parameter_translation failed.\n"); | |
| 215 | + Uninitialize(); | |
| 216 | + return cmInitParaError; | |
| 217 | + } | |
| 218 | + | |
| 219 | + return Initialize2 (&sConfig); | |
| 220 | +} | |
| 221 | + | |
| 222 | +int CWelsH264SVCEncoder::InitializeExt (const SEncParamExt* argv) { | |
| 223 | + | |
| 224 | + if (NULL == argv) { | |
| 225 | + WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid argv= 0x%p\n", | |
| 226 | + argv); | |
| 209 | 227 | return cmInitParaError; |
| 210 | 228 | } |
| 211 | 229 | |
| 212 | 230 | SWelsSvcCodingParam sConfig (true); |
| 213 | − if(iInitType == INIT_TYPE_PARAMETER_BASED) | |
| 214 | − { | |
| 215 | − // Convert SEncParamBase into WelsSVCParamConfig here.. | |
| 216 | − if (sConfig.ParamBaseTranscode (*(const SEncParamBase*)argv, true)) { | |
| 217 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), parameter_translation failed.\n"); | |
| 218 | − Uninitialize(); | |
| 219 | − return cmInitParaError; | |
| 220 | − } | |
| 221 | − } | |
| 222 | − else if(iInitType == INIT_TYPE_PARAMETER_EXT) | |
| 223 | − { | |
| 224 | − // Convert SEncParamExt into WelsSVCParamConfig here.. | |
| 225 | − if (sConfig.ParamTranscode (*(const SEncParamExt*)argv)) { | |
| 226 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), parameter_translation failed.\n"); | |
| 227 | − Uninitialize(); | |
| 228 | − return cmInitParaError; | |
| 229 | − } | |
| 231 | + // Convert SEncParamExt into WelsSVCParamConfig here.. | |
| 232 | + if (sConfig.ParamTranscode (*argv)) { | |
| 233 | + WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), parameter_translation failed.\n"); | |
| 234 | + Uninitialize(); | |
| 235 | + return cmInitParaError; | |
| 230 | 236 | } |
| 231 | 237 | |
| 232 | 238 | return Initialize2 (&sConfig); |