Add a log context to the encoder and decoder contexts

This will allow setting non-global logging callbacks, that
are different for each encoder or decoder instance.
This commit is contained in:
Martin Storsjö 2014-06-10 12:29:14 +03:00
parent c8b81b4239
commit 4e428ab020
4 changed files with 14 additions and 1 deletions

View File

@ -64,6 +64,10 @@ enum {
// wels log output // wels log output
typedef void (*PWelsLogCallbackFunc) (void* pCtx, const int32_t iLevel, const char* kpFmt, va_list argv); typedef void (*PWelsLogCallbackFunc) (void* pCtx, const int32_t iLevel, const char* kpFmt, va_list argv);
typedef struct TagLogContext {
PWelsLogCallbackFunc pfLog;
void* pLogCtx;
} SLogContext;
#ifdef __GNUC__ #ifdef __GNUC__

View File

@ -66,9 +66,15 @@ void WelsSetLogCallback (PWelsLogCallbackFunc _log) {
} }
void WelsLog (void* pCtx, int32_t iLevel, const char* kpFmt, ...) { void WelsLog (void* pCtx, int32_t iLevel, const char* kpFmt, ...) {
SLogContext* logCtx = (SLogContext*) pCtx;
PWelsLogCallbackFunc pfLog = wlog;
if (logCtx != NULL && logCtx->pfLog != NULL) {
pfLog = logCtx->pfLog;
pCtx = logCtx->pLogCtx;
}
va_list vl; va_list vl;
va_start (vl, kpFmt); va_start (vl, kpFmt);
wlog (pCtx, iLevel, kpFmt, vl); pfLog (pCtx, iLevel, kpFmt, vl);
va_end (vl); va_end (vl);
} }

View File

@ -164,6 +164,7 @@ enum {
*/ */
typedef struct TagWelsDecoderContext { typedef struct TagWelsDecoderContext {
SLogContext sLogCtx;
// Input // Input
void* pArgDec; // structured arguments for decoder, reserved here for extension in the future void* pArgDec; // structured arguments for decoder, reserved here for extension in the future

View File

@ -53,6 +53,7 @@
#include "wels_preprocess.h" #include "wels_preprocess.h"
#include "wels_func_ptr_def.h" #include "wels_func_ptr_def.h"
#include "crt_util_safe_x.h" #include "crt_util_safe_x.h"
#include "utils.h"
#include "mt_defs.h" // for multiple threadin, #include "mt_defs.h" // for multiple threadin,
#include "WelsThreadLib.h" #include "WelsThreadLib.h"
@ -110,6 +111,7 @@ typedef struct TagStrideTables {
} SStrideTables; } SStrideTables;
typedef struct TagWelsEncCtx { typedef struct TagWelsEncCtx {
SLogContext sLogCtx;
// Input // Input
SWelsSvcCodingParam* pSvcParam; // SVC parameter, WelsSVCParamConfig in svc_param_settings.h SWelsSvcCodingParam* pSvcParam; // SVC parameter, WelsSVCParamConfig in svc_param_settings.h
SWelsSliceBs* pSliceBs; // bitstream buffering for various slices, [uiSliceIdx] SWelsSliceBs* pSliceBs; // bitstream buffering for various slices, [uiSliceIdx]