Now all logging should use a non-null log context, allowing to pass the messages to the right recipient.
Unified · Split
| @@ -77,19 +77,6 @@ extern void WelsLog (void* pCtx, int32_t iLevel, const char* kpFmt, ...) __attri · 76 unmodified lines | |||
| 77 | extern void WelsLog (void* pCtx, int32_t iLevel, const char* kpFmt, ...); | 77 | extern void WelsLog (void* pCtx, int32_t iLevel, const char* kpFmt, ...); |
| 78 | #endif | 78 | #endif |
| 79 | 79 | ||
| 80 | /*! | ||
| 81 | ************************************************************************************* | ||
| 82 | * \brief set log callback from external call | ||
| 83 | * | ||
| 84 | * \param _log log function routine | ||
| 85 | * | ||
| 86 | * \return NONE | ||
| 87 | * | ||
| 88 | * \note N/A | ||
| 89 | ************************************************************************************* | ||
| 90 | */ | ||
| 91 | void WelsSetLogCallback (PWelsLogCallbackFunc _log); | ||
| 92 | |||
| 93 | /* | 80 | /* |
| 94 | * PSNR calculation routines | 81 | * PSNR calculation routines |
| 95 | */ | 82 | */ |
| @@ -48,33 +48,11 @@ float WelsCalcPsnr (const void* kpTarPic, · 47 unmodified lines | |||
| 48 | const int32_t kiHeight); | 48 | const int32_t kiHeight); |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | static PWelsLogCallbackFunc wlog; | ||
| 52 | |||
| 53 | /*! | ||
| 54 | ************************************************************************************* | ||
| 55 | * \brief set log callback from external call | ||
| 56 | * | ||
| 57 | * \param _log log function routine | ||
| 58 | * | ||
| 59 | * \return NONE | ||
| 60 | * | ||
| 61 | * \note N/A | ||
| 62 | ************************************************************************************* | ||
| 63 | */ | ||
| 64 | void WelsSetLogCallback (PWelsLogCallbackFunc _log) { | ||
| 65 | wlog = _log; | ||
| 66 | } | ||
| 67 | |||
| 68 | void WelsLog (void* pCtx, int32_t iLevel, const char* kpFmt, ...) { | 51 | void WelsLog (void* pCtx, int32_t iLevel, const char* kpFmt, ...) { |
| 69 | SLogContext* logCtx = (SLogContext*) pCtx; | 52 | SLogContext* logCtx = (SLogContext*) pCtx; |
| 70 | PWelsLogCallbackFunc pfLog = wlog; | ||
| 71 | if (logCtx != NULL && logCtx->pfLog != NULL) { | ||
| 72 | pfLog = logCtx->pfLog; | ||
| 73 | pCtx = logCtx->pLogCtx; | ||
| 74 | } | ||
| 75 | va_list vl; | 53 | va_list vl; |
| 76 | va_start (vl, kpFmt); | 54 | va_start (vl, kpFmt); |
| 77 | pfLog (pCtx, iLevel, kpFmt, vl); | 55 | logCtx->pfLog (logCtx->pLogCtx, iLevel, kpFmt, vl); |
| 78 | va_end (vl); | 56 | va_end (vl); |
| 79 | } | 57 | } |
| 80 | 58 | ||
| @@ -103,7 +103,6 @@ CWelsDecoder::CWelsDecoder (void) · 102 unmodified lines | |||
| 103 | m_pWelsTrace = new welsCodecTrace(); | 103 | m_pWelsTrace = new welsCodecTrace(); |
| 104 | if (m_pWelsTrace != NULL) { | 104 | if (m_pWelsTrace != NULL) { |
| 105 | m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR); | 105 | m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR); |
| 106 | WelsSetLogCallback (welsCodecTrace::CODEC_TRACE); | ||
| 107 | 106 | ||
| 108 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry"); | 107 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry"); |
| 109 | } | 108 | } |
| @@ -174,7 +174,6 @@ void CWelsH264SVCEncoder::InitEncoder (void) { · 173 unmodified lines | |||
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR); | 176 | m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR); |
| 177 | WelsSetLogCallback (welsCodecTrace::CODEC_TRACE); | ||
| 178 | 177 | ||
| 179 | #ifdef REC_FRAME_COUNT | 178 | #ifdef REC_FRAME_COUNT |
| 180 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, | 179 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |