Don't use a global trace level, allow user-specified trace callbacks
Unified · Split
| @@ -93,7 +93,9 @@ typedef enum { · 92 unmodified lines | ||
| 93 | 93 | |
| 94 | 94 | ENCODER_OPTION_CURRENT_PATH, |
| 95 | 95 | ENCODER_OPTION_DUMP_FILE, |
| 96 | − ENCODER_OPTION_TRACE_LEVEL | |
| 96 | + ENCODER_OPTION_TRACE_LEVEL, | |
| 97 | + ENCODER_OPTION_TRACE_CALLBACK, // a void (*)(void* context, int level, const char* message) function which receives log messages | |
| 98 | + ENCODER_OPTION_TRACE_CALLBACK_CONTEXT, | |
| 97 | 99 | } ENCODER_OPTION; |
| 98 | 100 | |
| 99 | 101 | /* Option types introduced in decoder application */ |
| @@ -107,6 +109,9 @@ typedef enum { · 7 unmodified lines | ||
| 107 | 109 | DECODER_OPTION_LTR_MARKING_FLAG, // feedback wether current frame mark a LTR |
| 108 | 110 | DECODER_OPTION_LTR_MARKED_FRAME_NUM, // feedback frame num marked by current Frame |
| 109 | 111 | DECODER_OPTION_ERROR_CON_IDC, //not finished yet, indicate decoder error concealment status, in progress |
| 112 | + DECODER_OPTION_TRACE_LEVEL, | |
| 113 | + DECODER_OPTION_TRACE_CALLBACK, // a void (*)(void* context, int level, const char* message) function which receives log messages | |
| 114 | + DECODER_OPTION_TRACE_CALLBACK_CONTEXT, | |
| 110 | 115 | |
| 111 | 116 | } DECODER_OPTION; |
| 112 | 117 | |
| @@ -26,7 +26,6 @@ LOCAL_SRC_FILES := \ · 25 unmodified lines | ||
| 26 | 26 | $(CONSOLE_DEC_PATH)/src/h264dec.cpp \ |
| 27 | 27 | $(CONSOLE_DEC_PATH)/src/read_config.cpp \ |
| 28 | 28 | $(CONSOLE_DEC_PATH)/src/d3d9_utils.cpp \ |
| 29 | − $(CODEC_PATH)/common/src/logging.cpp \ | |
| 30 | 29 | myjni.cpp |
| 31 | 30 | # |
| 32 | 31 | # Header Includes |
| @@ -25,7 +25,6 @@ CONSOLE_ENC_PATH := ../../../../console/enc · 24 unmodified lines | ||
| 25 | 25 | LOCAL_SRC_FILES := \ |
| 26 | 26 | $(CONSOLE_ENC_PATH)/src/welsenc.cpp \ |
| 27 | 27 | $(CONSOLE_ENC_PATH)/src/read_config.cpp \ |
| 28 | − $(CODEC_PATH)/common/src/logging.cpp \ | |
| 29 | 28 | myjni.cpp |
| 30 | 29 | |
| 31 | 30 | # |
| @@ -14,7 +14,6 @@ · 13 unmodified lines | ||
| 14 | 14 | 4C3406CD18D96EA600DFA14A /* cpu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C3406C418D96EA600DFA14A /* cpu.cpp */; }; |
| 15 | 15 | 4C3406CE18D96EA600DFA14A /* crt_util_safe_x.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C3406C518D96EA600DFA14A /* crt_util_safe_x.cpp */; }; |
| 16 | 16 | 4C3406CF18D96EA600DFA14A /* deblocking_common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C3406C618D96EA600DFA14A /* deblocking_common.cpp */; }; |
| 17 | − 4C3406D018D96EA600DFA14A /* logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C3406C718D96EA600DFA14A /* logging.cpp */; }; | |
| 18 | 17 | 4C3406D118D96EA600DFA14A /* WelsThreadLib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C3406C818D96EA600DFA14A /* WelsThreadLib.cpp */; }; |
| 19 | 18 | 4CC61F0918FF6B4B00E56EAB /* copy_mb_neon.S in Sources */ = {isa = PBXBuildFile; fileRef = 4CC61F0818FF6B4B00E56EAB /* copy_mb_neon.S */; }; |
| 20 | 19 | 4CE443D918B722CD0017DF25 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CE443D818B722CD0017DF25 /* Foundation.framework */; }; |
| @@ -47,7 +46,6 @@ · 26 unmodified lines | ||
| 47 | 46 | 4C3406B818D96EA600DFA14A /* cpu_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpu_core.h; sourceTree = "<group>"; }; |
| 48 | 47 | 4C3406B918D96EA600DFA14A /* crt_util_safe_x.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = crt_util_safe_x.h; sourceTree = "<group>"; }; |
| 49 | 48 | 4C3406BA18D96EA600DFA14A /* deblocking_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deblocking_common.h; sourceTree = "<group>"; }; |
| 50 | − 4C3406BC18D96EA600DFA14A /* logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = logging.h; sourceTree = "<group>"; }; | |
| 51 | 49 | 4C3406BD18D96EA600DFA14A /* ls_defines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ls_defines.h; sourceTree = "<group>"; }; |
| 52 | 50 | 4C3406BE18D96EA600DFA14A /* macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = macros.h; sourceTree = "<group>"; }; |
| 53 | 51 | 4C3406BF18D96EA600DFA14A /* mc_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mc_common.h; sourceTree = "<group>"; }; |
| @@ -57,7 +55,6 @@ · 3 unmodified lines | ||
| 57 | 55 | 4C3406C418D96EA600DFA14A /* cpu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cpu.cpp; sourceTree = "<group>"; }; |
| 58 | 56 | 4C3406C518D96EA600DFA14A /* crt_util_safe_x.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = crt_util_safe_x.cpp; sourceTree = "<group>"; }; |
| 59 | 57 | 4C3406C618D96EA600DFA14A /* deblocking_common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deblocking_common.cpp; sourceTree = "<group>"; }; |
| 60 | − 4C3406C718D96EA600DFA14A /* logging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = logging.cpp; sourceTree = "<group>"; }; | |
| 61 | 58 | 4C3406C818D96EA600DFA14A /* WelsThreadLib.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WelsThreadLib.cpp; sourceTree = "<group>"; }; |
| 62 | 59 | 4CC61F0818FF6B4B00E56EAB /* copy_mb_neon.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = copy_mb_neon.S; sourceTree = "<group>"; }; |
| 63 | 60 | 4CE443D518B722CD0017DF25 /* libcommon.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libcommon.a; sourceTree = BUILT_PRODUCTS_DIR; }; |
| @@ -108,7 +105,6 @@ · 44 unmodified lines | ||
| 108 | 105 | 4C3406B918D96EA600DFA14A /* crt_util_safe_x.h */, |
| 109 | 106 | 53C1C9BA193F0F9E00404D8F /* expand_pic.h */, |
| 110 | 107 | 4C3406BA18D96EA600DFA14A /* deblocking_common.h */, |
| 111 | − 4C3406BC18D96EA600DFA14A /* logging.h */, | |
| 112 | 108 | 4C3406BD18D96EA600DFA14A /* ls_defines.h */, |
| 113 | 109 | 4C3406BE18D96EA600DFA14A /* macros.h */, |
| 114 | 110 | 4C3406BF18D96EA600DFA14A /* mc_common.h */, |
| @@ -128,7 +124,6 @@ · 13 unmodified lines | ||
| 128 | 124 | 4C3406C518D96EA600DFA14A /* crt_util_safe_x.cpp */, |
| 129 | 125 | 53C1C9BB193F0FB000404D8F /* expand_pic.cpp */, |
| 130 | 126 | 4C3406C618D96EA600DFA14A /* deblocking_common.cpp */, |
| 131 | − 4C3406C718D96EA600DFA14A /* logging.cpp */, | |
| 132 | 127 | 4C3406C818D96EA600DFA14A /* WelsThreadLib.cpp */, |
| 133 | 128 | ); |
| 134 | 129 | path = src; |
| @@ -238,7 +233,6 @@ · 103 unmodified lines | ||
| 238 | 233 | F556A8241906673900E156A8 /* arm_arch64_common_macro.S in Sources */, |
| 239 | 234 | 4C3406CE18D96EA600DFA14A /* crt_util_safe_x.cpp in Sources */, |
| 240 | 235 | 4C3406CF18D96EA600DFA14A /* deblocking_common.cpp in Sources */, |
| 241 | − 4C3406D018D96EA600DFA14A /* logging.cpp in Sources */, | |
| 242 | 236 | 4C3406D118D96EA600DFA14A /* WelsThreadLib.cpp in Sources */, |
| 243 | 237 | 4C3406CC18D96EA600DFA14A /* mc_neon.S in Sources */, |
| 244 | 238 | 4C3406CB18D96EA600DFA14A /* expand_picture_neon.S in Sources */, |
| @@ -902,10 +902,6 @@ · 901 unmodified lines | ||
| 902 | 902 | RelativePath="..\..\..\decoder\core\src\get_intra_predictor.cpp" |
| 903 | 903 | > |
| 904 | 904 | </File> |
| 905 | − <File | |
| 906 | − RelativePath="..\..\..\common\src\logging.cpp" | |
| 907 | − > | |
| 908 | − </File> | |
| 909 | 905 | <File |
| 910 | 906 | RelativePath="..\..\..\decoder\core\src\manage_dec_ref.cpp" |
| 911 | 907 | > |
| @@ -394,10 +394,6 @@ · 393 unmodified lines | ||
| 394 | 394 | RelativePath="..\..\..\console\dec\src\h264dec.cpp" |
| 395 | 395 | > |
| 396 | 396 | </File> |
| 397 | − <File | |
| 398 | − RelativePath="..\..\..\common\src\logging.cpp" | |
| 399 | − > | |
| 400 | − </File> | |
| 401 | 397 | <File |
| 402 | 398 | RelativePath="..\..\..\console\dec\src\read_config.cpp" |
| 403 | 399 | > |
| @@ -395,10 +395,6 @@ · 394 unmodified lines | ||
| 395 | 395 | RelativePath="..\..\..\encoder\core\src\get_intra_predictor.cpp" |
| 396 | 396 | > |
| 397 | 397 | </File> |
| 398 | − <File | |
| 399 | − RelativePath="..\..\..\common\src\logging.cpp" | |
| 400 | − > | |
| 401 | − </File> | |
| 402 | 398 | <File |
| 403 | 399 | RelativePath="..\..\..\encoder\core\src\mc.cpp" |
| 404 | 400 | > |
| @@ -394,10 +394,6 @@ · 393 unmodified lines | ||
| 394 | 394 | Name="Source Files" |
| 395 | 395 | Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" |
| 396 | 396 | > |
| 397 | − <File | |
| 398 | − RelativePath="..\..\..\common\src\logging.cpp" | |
| 399 | − > | |
| 400 | − </File> | |
| 401 | 397 | <File |
| 402 | 398 | RelativePath="..\..\..\console\enc\src\read_config.cpp" |
| 403 | 399 | > |
| @@ -1,54 +0,0 @@ | ||
| 1 | −/*! | |
| 2 | − * \copy | |
| 3 | − * Copyright (c) 2013, Cisco Systems | |
| 4 | − * Copyright (c) 2013, Mozilla | |
| 5 | − * All rights reserved. | |
| 6 | − * | |
| 7 | − * Redistribution and use in source and binary forms, with or without | |
| 8 | − * modification, are permitted provided that the following conditions | |
| 9 | − * are met: | |
| 10 | − * | |
| 11 | − * * Redistributions of source code must retain the above copyright | |
| 12 | − * notice, this list of conditions and the following disclaimer. | |
| 13 | − * | |
| 14 | − * * Redistributions in binary form must reproduce the above copyright | |
| 15 | − * notice, this list of conditions and the following disclaimer in | |
| 16 | − * the documentation and/or other materials provided with the | |
| 17 | − * distribution. | |
| 18 | − * | |
| 19 | − * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 20 | − * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 21 | − * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
| 22 | − * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
| 23 | − * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
| 24 | − * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
| 25 | − * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 26 | − * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| 27 | − * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 28 | − * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
| 29 | − * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 30 | − * POSSIBILITY OF SUCH DAMAGE. | |
| 31 | − * | |
| 32 | − */ | |
| 33 | − | |
| 34 | − | |
| 35 | −#ifndef WELS_LOGGING_H__ | |
| 36 | −#define WELS_LOGGING_H__ | |
| 37 | − | |
| 38 | −// API surface. | |
| 39 | −void WelsStderrSetTraceLevel (int32_t level); | |
| 40 | − | |
| 41 | − | |
| 42 | −// Internal details. | |
| 43 | −int32_t welsStderrLevelTrace (int32_t level, const char* format, va_list ap); | |
| 44 | − | |
| 45 | −template<int level> int32_t welsStderrTrace ( | |
| 46 | − const char* format, ...) { | |
| 47 | − va_list ap; | |
| 48 | − va_start (ap, format); | |
| 49 | − welsStderrLevelTrace (level, format, ap); | |
| 50 | − va_end (ap); | |
| 51 | − return 0; | |
| 52 | −} | |
| 53 | − | |
| 54 | −#endif | |
| @@ -47,7 +47,6 @@ · 46 unmodified lines | ||
| 47 | 47 | * Log output routines |
| 48 | 48 | */ |
| 49 | 49 | |
| 50 | −typedef int32_t iWelsLogLevel; | |
| 51 | 50 | enum { |
| 52 | 51 | WELS_LOG_QUIET = 0x00, // Quiet mode |
| 53 | 52 | WELS_LOG_ERROR = 1 << 0, // Error log iLevel |
| @@ -56,7 +55,7 @@ enum { · 2 unmodified lines | ||
| 56 | 55 | WELS_LOG_DEBUG = 1 << 3, // Debug log iLevel |
| 57 | 56 | WELS_LOG_RESV = 1 << 4, // Resversed log iLevel |
| 58 | 57 | WELS_LOG_LEVEL_COUNT = 5, |
| 59 | − WELS_LOG_DEFAULT = WELS_LOG_ERROR | WELS_LOG_WARNING | WELS_LOG_INFO | WELS_LOG_DEBUG // Default log iLevel in Wels codec | |
| 58 | + WELS_LOG_DEFAULT = WELS_LOG_DEBUG // Default log iLevel in Wels codec | |
| 60 | 59 | }; |
| 61 | 60 | |
| 62 | 61 | /* |
| @@ -65,14 +64,10 @@ enum { · 2 unmodified lines | ||
| 65 | 64 | // wels log output |
| 66 | 65 | typedef void (*PWelsLogCallbackFunc) (void* pCtx, const int32_t iLevel, const char* kpFmt, va_list argv); |
| 67 | 66 | |
| 68 | −// wels psnr calc | |
| 69 | −typedef float (*PWelsPsnrFunc) (const void* kpTarPic, | |
| 70 | − const int32_t kiTarStride, | |
| 71 | − const void* kpRefPic, | |
| 72 | − const int32_t kiRefStride, | |
| 73 | − const int32_t kiWidth, | |
| 74 | − const int32_t kiHeight); | |
| 75 | − | |
| 67 | +typedef struct TagLogContext { | |
| 68 | + PWelsLogCallbackFunc pfLog; | |
| 69 | + void* pLogCtx; | |
| 70 | +} SLogContext; | |
| 76 | 71 | |
| 77 | 72 | |
| 78 | 73 | #ifdef __GNUC__ |
| @@ -82,19 +77,6 @@ extern void WelsLog (void* pCtx, int32_t iLevel, const char* kpFmt, ...) __attri · 3 unmodified lines | ||
| 82 | 77 | extern void WelsLog (void* pCtx, int32_t iLevel, const char* kpFmt, ...); |
| 83 | 78 | #endif |
| 84 | 79 | |
| 85 | −/*! | |
| 86 | − ************************************************************************************* | |
| 87 | − * \brief set log callback from external call | |
| 88 | − * | |
| 89 | − * \param _log log function routine | |
| 90 | − * | |
| 91 | − * \return NONE | |
| 92 | − * | |
| 93 | − * \note N/A | |
| 94 | − ************************************************************************************* | |
| 95 | − */ | |
| 96 | −void WelsSetLogCallback (PWelsLogCallbackFunc _log); | |
| 97 | − | |
| 98 | 80 | /* |
| 99 | 81 | * PSNR calculation routines |
| 100 | 82 | */ |
| @@ -35,26 +35,29 @@ · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | #include <stdarg.h> |
| 37 | 37 | #include "typedefs.h" |
| 38 | +#include "utils.h" | |
| 38 | 39 | |
| 39 | −typedef int32_t (*CM_WELS_TRACE) (const char* format, ...); | |
| 40 | +typedef void (*CM_WELS_TRACE) (void* ctx, int level, const char* string); | |
| 40 | 41 | |
| 41 | 42 | class welsCodecTrace { |
| 42 | 43 | public: |
| 43 | 44 | welsCodecTrace(); |
| 44 | 45 | ~welsCodecTrace(); |
| 45 | 46 | |
| 46 | − static void TraceString (int32_t iLevel, const char* kpStrFormat); | |
| 47 | − static void CODEC_TRACE (void* pIgnore, const int32_t kiLevel, const char* kpStrFormat, va_list vl); | |
| 48 | − | |
| 49 | 47 | void SetTraceLevel (const int32_t kiLevel); |
| 48 | + void SetTraceCallback (CM_WELS_TRACE func); | |
| 49 | + void SetTraceCallbackContext (void* pCtx); | |
| 50 | + | |
| 51 | + private: | |
| 52 | + static void StaticCodecTrace (void* pCtx, const int32_t kiLevel, const char* kpStrFormat, va_list vl); | |
| 53 | + void CodecTrace (const int32_t kiLevel, const char* kpStrFormat, va_list vl); | |
| 50 | 54 | |
| 55 | + int32_t m_iTraceLevel; | |
| 56 | + CM_WELS_TRACE m_fpTrace; | |
| 57 | + void* m_pTraceCtx; | |
| 51 | 58 | public: |
| 52 | − static int32_t m_iTraceLevel; | |
| 53 | − static CM_WELS_TRACE m_fpDebugTrace; | |
| 54 | − static CM_WELS_TRACE m_fpInfoTrace; | |
| 55 | − static CM_WELS_TRACE m_fpWarnTrace; | |
| 56 | − static CM_WELS_TRACE m_fpErrorTrace; | |
| 57 | 59 | |
| 60 | + SLogContext m_sLogCtx; | |
| 58 | 61 | }; |
| 59 | 62 | |
| 60 | 63 | #endif //WELS_CODEC_TRACE |
| @@ -1,49 +0,0 @@ | ||
| 1 | −/*! | |
| 2 | − * \copy | |
| 3 | − * Copyright (c) 2013, Cisco Systems | |
| 4 | − * Copyright (c) 2013, Mozilla | |
| 5 | − * All rights reserved. | |
| 6 | − * | |
| 7 | − * Redistribution and use in source and binary forms, with or without | |
| 8 | − * modification, are permitted provided that the following conditions | |
| 9 | − * are met: | |
| 10 | − * | |
| 11 | − * * Redistributions of source code must retain the above copyright | |
| 12 | − * notice, this list of conditions and the following disclaimer. | |
| 13 | − * | |
| 14 | − * * Redistributions in binary form must reproduce the above copyright | |
| 15 | − * notice, this list of conditions and the following disclaimer in | |
| 16 | − * the documentation and/or other materials provided with the | |
| 17 | − * distribution. | |
| 18 | − * | |
| 19 | − * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 20 | − * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 21 | − * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
| 22 | − * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
| 23 | − * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
| 24 | − * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
| 25 | − * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 26 | − * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| 27 | − * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 28 | − * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
| 29 | − * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 30 | − * POSSIBILITY OF SUCH DAMAGE. | |
| 31 | − * | |
| 32 | − */ | |
| 33 | − | |
| 34 | −#include <stdarg.h> | |
| 35 | −#include <stdio.h> | |
| 36 | −#include "typedefs.h" | |
| 37 | − | |
| 38 | −static int32_t g_TraceLevel = 0; | |
| 39 | − | |
| 40 | −void WelsStderrSetTraceLevel (int32_t level) { | |
| 41 | − g_TraceLevel = level; | |
| 42 | −} | |
| 43 | − | |
| 44 | −int32_t welsStderrLevelTrace (int32_t level, const char* format, va_list ap) { | |
| 45 | − if (level < g_TraceLevel) { | |
| 46 | − vfprintf (stderr, format, ap); | |
| 47 | − } | |
| 48 | − return 0; | |
| 49 | −} | |
| @@ -48,27 +48,11 @@ float WelsCalcPsnr (const void* kpTarPic, · 47 unmodified lines | ||
| 48 | 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 | 51 | void WelsLog (void* pCtx, int32_t iLevel, const char* kpFmt, ...) { |
| 52 | + SLogContext* logCtx = (SLogContext*) pCtx; | |
| 69 | 53 | va_list vl; |
| 70 | 54 | va_start (vl, kpFmt); |
| 71 | − wlog (pCtx, iLevel, kpFmt, vl); | |
| 55 | + logCtx->pfLog (logCtx->pLogCtx, iLevel, kpFmt, vl); | |
| 72 | 56 | va_end (vl); |
| 73 | 57 | } |
| 74 | 58 | |
| @@ -44,57 +44,34 @@ · 43 unmodified lines | ||
| 44 | 44 | #include "welsCodecTrace.h" |
| 45 | 45 | #include "utils.h" |
| 46 | 46 | |
| 47 | −#include "logging.h" | |
| 48 | 47 | |
| 49 | −int32_t welsCodecTrace::m_iTraceLevel = WELS_LOG_DEFAULT; | |
| 50 | −CM_WELS_TRACE welsCodecTrace::m_fpDebugTrace = NULL; | |
| 51 | −CM_WELS_TRACE welsCodecTrace::m_fpInfoTrace = NULL; | |
| 52 | −CM_WELS_TRACE welsCodecTrace::m_fpWarnTrace = NULL; | |
| 53 | −CM_WELS_TRACE welsCodecTrace::m_fpErrorTrace = NULL; | |
| 48 | + | |
| 49 | +static void welsStderrTrace (void* ctx, int level, const char* string) { | |
| 50 | + fprintf (stderr, "%s", string); | |
| 51 | +} | |
| 54 | 52 | |
| 55 | 53 | welsCodecTrace::welsCodecTrace() { |
| 56 | 54 | |
| 57 | − m_fpDebugTrace = welsStderrTrace<WELS_LOG_DEBUG>; | |
| 58 | − m_fpInfoTrace = welsStderrTrace<WELS_LOG_INFO>; | |
| 59 | − m_fpWarnTrace = welsStderrTrace<WELS_LOG_WARNING>; | |
| 60 | − m_fpErrorTrace = welsStderrTrace<WELS_LOG_ERROR>; | |
| 61 | −} | |
| 55 | + m_iTraceLevel = WELS_LOG_DEFAULT; | |
| 56 | + m_fpTrace = welsStderrTrace; | |
| 57 | + m_pTraceCtx = NULL; | |
| 62 | 58 | |
| 63 | −welsCodecTrace::~welsCodecTrace() { | |
| 64 | − m_fpDebugTrace = NULL; | |
| 65 | − m_fpInfoTrace = NULL; | |
| 66 | − m_fpWarnTrace = NULL; | |
| 67 | − m_fpErrorTrace = NULL; | |
| 59 | + m_sLogCtx.pLogCtx = this; | |
| 60 | + m_sLogCtx.pfLog = StaticCodecTrace; | |
| 68 | 61 | } |
| 69 | 62 | |
| 70 | −void welsCodecTrace::TraceString (int32_t iLevel, const char* str) { | |
| 71 | − switch (iLevel) { | |
| 72 | − case WELS_LOG_ERROR: | |
| 73 | − if (m_fpErrorTrace) | |
| 74 | − m_fpErrorTrace ("%s", str); | |
| 75 | − break; | |
| 76 | − case WELS_LOG_WARNING: | |
| 77 | − if (m_fpWarnTrace) | |
| 78 | − m_fpWarnTrace ("%s", str); | |
| 79 | − break; | |
| 80 | − case WELS_LOG_INFO: | |
| 81 | − if (m_fpInfoTrace) | |
| 82 | − m_fpInfoTrace ("%s", str); | |
| 83 | − break; | |
| 84 | − case WELS_LOG_DEBUG: | |
| 85 | − if (m_fpDebugTrace) | |
| 86 | − m_fpDebugTrace ("%s", str); | |
| 87 | − break; | |
| 88 | − default: | |
| 89 | − if (m_fpDebugTrace) | |
| 90 | − m_fpInfoTrace ("%s", str); | |
| 91 | − break; | |
| 92 | − } | |
| 63 | +welsCodecTrace::~welsCodecTrace() { | |
| 64 | + m_fpTrace = NULL; | |
| 93 | 65 | } |
| 94 | 66 | |
| 95 | 67 | #define MAX_LOG_SIZE 1024 |
| 96 | 68 | |
| 97 | −void welsCodecTrace::CODEC_TRACE (void* ignore, const int32_t iLevel, const char* Str_Format, va_list vl) { | |
| 69 | +void welsCodecTrace::StaticCodecTrace (void* pCtx, const int32_t iLevel, const char* Str_Format, va_list vl) { | |
| 70 | + welsCodecTrace* self = (welsCodecTrace*) pCtx; | |
| 71 | + self->CodecTrace (iLevel, Str_Format, vl); | |
| 72 | +} | |
| 73 | + | |
| 74 | +void welsCodecTrace::CodecTrace (const int32_t iLevel, const char* Str_Format, va_list vl) { | |
| 98 | 75 | if (m_iTraceLevel < iLevel) { |
| 99 | 76 | return; |
| 100 | 77 | } |
| @@ -102,13 +79,19 @@ void welsCodecTrace::CODEC_TRACE (void* ignore, const int32_t iLevel, const char · 1 unmodified line | ||
| 102 | 79 | char pBuf[MAX_LOG_SIZE] = {0}; |
| 103 | 80 | WelsVsnprintf (pBuf, MAX_LOG_SIZE, Str_Format, vl); // confirmed_safe_unsafe_usage |
| 104 | 81 | |
| 105 | − welsCodecTrace::TraceString (iLevel, pBuf); | |
| 82 | + m_fpTrace (m_pTraceCtx, iLevel, pBuf); | |
| 106 | 83 | } |
| 107 | 84 | |
| 108 | 85 | void welsCodecTrace::SetTraceLevel (const int32_t iLevel) { |
| 109 | 86 | if (iLevel >= 0) |
| 110 | 87 | m_iTraceLevel = iLevel; |
| 111 | − WelsStderrSetTraceLevel (iLevel); | |
| 112 | 88 | } |
| 113 | 89 | |
| 90 | +void welsCodecTrace::SetTraceCallback (CM_WELS_TRACE func) { | |
| 91 | + m_fpTrace = func; | |
| 92 | +} | |
| 93 | + | |
| 94 | +void welsCodecTrace::SetTraceCallbackContext (void* ctx) { | |
| 95 | + m_pTraceCtx = ctx; | |
| 96 | +} | |
| 114 | 97 | |
| @@ -5,7 +5,6 @@ COMMON_CPP_SRCS=\ · 4 unmodified lines | ||
| 5 | 5 | $(COMMON_SRCDIR)/src/crt_util_safe_x.cpp\ |
| 6 | 6 | $(COMMON_SRCDIR)/src/deblocking_common.cpp\ |
| 7 | 7 | $(COMMON_SRCDIR)/src/expand_pic.cpp\ |
| 8 | − $(COMMON_SRCDIR)/src/logging.cpp\ | |
| 9 | 8 | $(COMMON_SRCDIR)/src/sad_common.cpp\ |
| 10 | 9 | $(COMMON_SRCDIR)/src/utils.cpp\ |
| 11 | 10 | $(COMMON_SRCDIR)/src/welsCodecTrace.cpp\ |
| @@ -51,7 +51,6 @@ · 50 unmodified lines | ||
| 51 | 51 | #include "typedefs.h" |
| 52 | 52 | #include "measure_time.h" |
| 53 | 53 | #include "d3d9_utils.h" |
| 54 | −#include "logging.h" | |
| 55 | 54 | |
| 56 | 55 | |
| 57 | 56 | using namespace std; |
| @@ -311,6 +310,7 @@ int32_t main (int32_t iArgC, char* pArgV[]) { · 253 unmodified lines | ||
| 311 | 310 | |
| 312 | 311 | SDecodingParam sDecParam = {0}; |
| 313 | 312 | string strInputFile (""), strOutputFile (""), strOptionFile (""); |
| 313 | + int iLevelSetting = -1; | |
| 314 | 314 | |
| 315 | 315 | sDecParam.sVideoProperty.size = sizeof (sDecParam.sVideoProperty); |
| 316 | 316 | |
| @@ -384,14 +384,14 @@ int32_t main (int32_t iArgC, char* pArgV[]) { · 67 unmodified lines | ||
| 384 | 384 | |
| 385 | 385 | if (!strcmp (cmd, "-options")) { |
| 386 | 386 | if (i + 1 < iArgC) |
| 387 | − strOptionFile = pArgV[i++]; | |
| 387 | + strOptionFile = pArgV[++i]; | |
| 388 | 388 | else { |
| 389 | 389 | printf ("options file not specified.\n"); |
| 390 | 390 | return 1; |
| 391 | 391 | } |
| 392 | 392 | } else if (!strcmp (cmd, "-trace")) { |
| 393 | 393 | if (i + 1 < iArgC) |
| 394 | − WelsStderrSetTraceLevel (atoi (pArgV[i++])); | |
| 394 | + iLevelSetting = atoi (pArgV[++i]); | |
| 395 | 395 | else { |
| 396 | 396 | printf ("trace level not specified.\n"); |
| 397 | 397 | return 1; |
| @@ -418,6 +418,9 @@ int32_t main (int32_t iArgC, char* pArgV[]) { · 20 unmodified lines | ||
| 418 | 418 | printf ("Create Decoder failed.\n"); |
| 419 | 419 | return 1; |
| 420 | 420 | } |
| 421 | + if (iLevelSetting >= 0) { | |
| 422 | + pDecoder->SetOption (DECODER_OPTION_TRACE_LEVEL, &iLevelSetting); | |
| 423 | + } | |
| 421 | 424 | |
| 422 | 425 | if (pDecoder->Initialize (&sDecParam)) { |
| 423 | 426 | printf ("Decoder initialization failed.\n"); |
| @@ -67,7 +67,6 @@ · 66 unmodified lines | ||
| 67 | 67 | #include "extern.h" |
| 68 | 68 | #include "macros.h" |
| 69 | 69 | #include "wels_const.h" |
| 70 | −#include "logging.h" | |
| 71 | 70 | |
| 72 | 71 | #include "mt_defs.h" |
| 73 | 72 | #include "WelsThreadLib.h" |
| @@ -102,7 +101,7 @@ static int g_iCtrlC = 0; · 28 unmodified lines | ||
| 102 | 101 | static void SigIntHandler (int a) { |
| 103 | 102 | g_iCtrlC = 1; |
| 104 | 103 | } |
| 105 | −static int g_LevelSetting = 0; | |
| 104 | +static int g_LevelSetting = -1; | |
| 106 | 105 | |
| 107 | 106 | int ParseLayerConfig (CReadConfig& cRdLayerCfg, const int iLayer, SEncParamExt& pSvcParam, SFilesSet& sFileSet) { |
| 108 | 107 | if (!cRdLayerCfg.ExistFile()) { |
| @@ -665,6 +664,9 @@ int ProcessEncoding(ISVCEncoder* pPtrEnc, int argc, char** argv,bool bConfigFile · 556 unmodified lines | ||
| 665 | 664 | iRet = 1; |
| 666 | 665 | goto INSIDE_MEM_FREE; |
| 667 | 666 | } |
| 667 | + if (g_LevelSetting >= 0) { | |
| 668 | + pPtrEnc->SetOption (ENCODER_OPTION_TRACE_LEVEL, &g_LevelSetting); | |
| 669 | + } | |
| 668 | 670 | //finish reading the configurations |
| 669 | 671 | iSourceWidth = pSrcPic->iPicWidth; |
| 670 | 672 | iSourceHeight = pSrcPic->iPicHeight; |
| @@ -68,7 +68,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 67 unmodified lines | ||
| 68 | 68 | * \note N/A |
| 69 | 69 | ************************************************************************************* |
| 70 | 70 | */ |
| 71 | −int32_t WelsInitDecoder (PWelsDecoderContext pCtx); | |
| 71 | +int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx); | |
| 72 | 72 | |
| 73 | 73 | /*! |
| 74 | 74 | ************************************************************************************* |
| @@ -164,6 +164,7 @@ enum { · 163 unmodified lines | ||
| 164 | 164 | */ |
| 165 | 165 | |
| 166 | 166 | typedef struct TagWelsDecoderContext { |
| 167 | + SLogContext sLogCtx; | |
| 167 | 168 | // Input |
| 168 | 169 | void* pArgDec; // structured arguments for decoder, reserved here for extension in the future |
| 169 | 170 | |
| @@ -127,9 +127,10 @@ static void DestroyPicBuff (PPicBuff* ppPicBuf) { · 126 unmodified lines | ||
| 127 | 127 | /* |
| 128 | 128 | * fill data fields in default for decoder context |
| 129 | 129 | */ |
| 130 | −void WelsDecoderDefaults (PWelsDecoderContext pCtx) { | |
| 130 | +void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { | |
| 131 | 131 | int32_t iCpuCores = 1; |
| 132 | 132 | memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first |
| 133 | + pCtx->sLogCtx = *pLogCtx; | |
| 133 | 134 | |
| 134 | 135 | pCtx->pArgDec = NULL; |
| 135 | 136 | |
| @@ -350,13 +351,13 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 214 unmodified lines | ||
| 350 | 351 | * \note N/A |
| 351 | 352 | ************************************************************************************* |
| 352 | 353 | */ |
| 353 | −int32_t WelsInitDecoder (PWelsDecoderContext pCtx) { | |
| 354 | +int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { | |
| 354 | 355 | if (pCtx == NULL) { |
| 355 | 356 | return ERR_INFO_INVALID_PTR; |
| 356 | 357 | } |
| 357 | 358 | |
| 358 | 359 | // default |
| 359 | − WelsDecoderDefaults (pCtx); | |
| 360 | + WelsDecoderDefaults (pCtx, pLogCtx); | |
| 360 | 361 | |
| 361 | 362 | // open decoder |
| 362 | 363 | WelsOpenDecoder (pCtx); |
| @@ -103,10 +103,9 @@ CWelsDecoder::CWelsDecoder (void) · 102 unmodified lines | ||
| 103 | 103 | m_pWelsTrace = new welsCodecTrace(); |
| 104 | 104 | if (m_pWelsTrace != NULL) { |
| 105 | 105 | m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR); |
| 106 | − WelsSetLogCallback (welsCodecTrace::CODEC_TRACE); | |
| 107 | − } | |
| 108 | 106 | |
| 109 | − WelsLog (NULL, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry"); | |
| 107 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry"); | |
| 108 | + } | |
| 110 | 109 | |
| 111 | 110 | #ifdef OUTPUT_BIT_STREAM |
| 112 | 111 | SWelsTime sCurTime; |
| @@ -161,7 +160,9 @@ CWelsDecoder::CWelsDecoder (void) · 48 unmodified lines | ||
| 161 | 160 | * return: none |
| 162 | 161 | ***************************************************************************/ |
| 163 | 162 | CWelsDecoder::~CWelsDecoder() { |
| 164 | − WelsLog (NULL, WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()"); | |
| 163 | + if (m_pWelsTrace != NULL) { | |
| 164 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()"); | |
| 165 | + } | |
| 165 | 166 | |
| 166 | 167 | UninitDecoder(); |
| 167 | 168 | |
| @@ -183,8 +184,12 @@ CWelsDecoder::~CWelsDecoder() { · 15 unmodified lines | ||
| 183 | 184 | } |
| 184 | 185 | |
| 185 | 186 | long CWelsDecoder::Initialize (const SDecodingParam* pParam) { |
| 187 | + if (m_pWelsTrace == NULL) { | |
| 188 | + return cmMallocMemeError; | |
| 189 | + } | |
| 190 | + | |
| 186 | 191 | if (pParam == NULL) { |
| 187 | − WelsLog (NULL, WELS_LOG_INFO, "CWelsDecoder::Initialize(), invalid input argument."); | |
| 192 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::Initialize(), invalid input argument."); | |
| 188 | 193 | return cmInitParaError; |
| 189 | 194 | } |
| 190 | 195 | |
| @@ -206,7 +211,7 @@ void CWelsDecoder::UninitDecoder (void) { · 15 unmodified lines | ||
| 206 | 211 | if (NULL == m_pDecContext) |
| 207 | 212 | return; |
| 208 | 213 | |
| 209 | − WelsLog (NULL, WELS_LOG_INFO, "into CWelsDecoder::uninit_decoder().."); | |
| 214 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "into CWelsDecoder::uninit_decoder().."); | |
| 210 | 215 | |
| 211 | 216 | WelsEndDecoder (m_pDecContext); |
| 212 | 217 | |
| @@ -216,19 +221,19 @@ void CWelsDecoder::UninitDecoder (void) { · 3 unmodified lines | ||
| 216 | 221 | m_pDecContext = NULL; |
| 217 | 222 | } |
| 218 | 223 | |
| 219 | − WelsLog (NULL , WELS_LOG_INFO, "left CWelsDecoder::uninit_decoder().."); | |
| 224 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "left CWelsDecoder::uninit_decoder().."); | |
| 220 | 225 | } |
| 221 | 226 | |
| 222 | 227 | // the return value of this function is not suitable, it need report failure info to upper layer. |
| 223 | 228 | void CWelsDecoder::InitDecoder (void) { |
| 224 | 229 | |
| 225 | − WelsLog (NULL, WELS_LOG_INFO, "CWelsDecoder::init_decoder().."); | |
| 230 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::init_decoder().."); | |
| 226 | 231 | |
| 227 | 232 | m_pDecContext = (PWelsDecoderContext)WelsMalloc (sizeof (SWelsDecoderContext), "m_pDecContext"); |
| 228 | 233 | |
| 229 | − WelsInitDecoder (m_pDecContext); | |
| 234 | + WelsInitDecoder (m_pDecContext, &m_pWelsTrace->m_sLogCtx); | |
| 230 | 235 | |
| 231 | − WelsLog (NULL, WELS_LOG_INFO, "CWelsDecoder::init_decoder().. left"); | |
| 236 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::init_decoder().. left"); | |
| 232 | 237 | } |
| 233 | 238 | |
| 234 | 239 | /* |
| @@ -237,7 +242,8 @@ void CWelsDecoder::InitDecoder (void) { · 2 unmodified lines | ||
| 237 | 242 | long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { |
| 238 | 243 | int iVal = 0; |
| 239 | 244 | |
| 240 | − if (m_pDecContext == NULL) | |
| 245 | + if (m_pDecContext == NULL && eOptID != DECODER_OPTION_TRACE_LEVEL && | |
| 246 | + eOptID != DECODER_OPTION_TRACE_CALLBACK && eOptID != DECODER_OPTION_TRACE_CALLBACK_CONTEXT) | |
| 241 | 247 | return dsInitialOptExpected; |
| 242 | 248 | |
| 243 | 249 | if (eOptID == DECODER_OPTION_DATAFORMAT) { // Set color space of decoding output frame |
| @@ -263,6 +269,24 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { · 19 unmodified lines | ||
| 263 | 269 | iVal = * ((int*)pOption); //EC method |
| 264 | 270 | m_pDecContext->iErrorConMethod = iVal; |
| 265 | 271 | return cmResultSuccess; |
| 272 | + } else if (eOptID == DECODER_OPTION_TRACE_LEVEL) { | |
| 273 | + if (m_pWelsTrace) { | |
| 274 | + uint32_t level = * ((uint32_t*)pOption); | |
| 275 | + m_pWelsTrace->SetTraceLevel (level); | |
| 276 | + } | |
| 277 | + return cmResultSuccess; | |
| 278 | + } else if (eOptID == DECODER_OPTION_TRACE_CALLBACK) { | |
| 279 | + if (m_pWelsTrace) { | |
| 280 | + CM_WELS_TRACE callback = * ((CM_WELS_TRACE*)pOption); | |
| 281 | + m_pWelsTrace->SetTraceCallback (callback); | |
| 282 | + } | |
| 283 | + return cmResultSuccess; | |
| 284 | + } else if (eOptID == DECODER_OPTION_TRACE_CALLBACK_CONTEXT) { | |
| 285 | + if (m_pWelsTrace) { | |
| 286 | + void* ctx = * ((void**)pOption); | |
| 287 | + m_pWelsTrace->SetTraceCallbackContext (ctx); | |
| 288 | + } | |
| 289 | + return cmResultSuccess; | |
| 266 | 290 | } |
| 267 | 291 | |
| 268 | 292 | return cmInitParaError; |
| @@ -386,7 +410,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 117 unmodified lines | ||
| 386 | 410 | } |
| 387 | 411 | } |
| 388 | 412 | |
| 389 | − WelsLog (NULL, WELS_LOG_INFO, "decode failed, failure type:%d \n", | |
| 413 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "decode failed, failure type:%d \n", | |
| 390 | 414 | m_pDecContext->iErrorCode); |
| 391 | 415 | return (DECODING_STATE)m_pDecContext->iErrorCode; |
| 392 | 416 | } |
| @@ -53,6 +53,7 @@ · 52 unmodified lines | ||
| 53 | 53 | #include "wels_preprocess.h" |
| 54 | 54 | #include "wels_func_ptr_def.h" |
| 55 | 55 | #include "crt_util_safe_x.h" |
| 56 | +#include "utils.h" | |
| 56 | 57 | |
| 57 | 58 | #include "mt_defs.h" // for multiple threadin, |
| 58 | 59 | #include "WelsThreadLib.h" |
| @@ -110,6 +111,7 @@ typedef struct TagStrideTables { · 51 unmodified lines | ||
| 110 | 111 | } SStrideTables; |
| 111 | 112 | |
| 112 | 113 | typedef struct TagWelsEncCtx { |
| 114 | + SLogContext sLogCtx; | |
| 113 | 115 | // Input |
| 114 | 116 | SWelsSvcCodingParam* pSvcParam; // SVC parameter, WelsSVCParamConfig in svc_param_settings.h |
| 115 | 117 | SWelsSliceBs* pSliceBs; // bitstream buffering for various slices, [uiSliceIdx] |
| @@ -64,7 +64,7 @@ int32_t InitPic (const void* kpSrc, const int32_t kiCsp, const int32_t kiWidth, · 63 unmodified lines | ||
| 64 | 64 | * \pParam pParam SWelsSvcCodingParam* |
| 65 | 65 | * \return successful - 0; otherwise none 0 for failed |
| 66 | 66 | */ |
| 67 | −int32_t ParamValidationExt (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam); | |
| 67 | +int32_t ParamValidationExt (SLogContext* pCtx, SWelsSvcCodingParam* pParam); | |
| 68 | 68 | |
| 69 | 69 | // GOM based RC related for uiSliceNum decision |
| 70 | 70 | void GomValidCheck (const int32_t kiMbWidth, const int32_t kiMbHeight, int32_t* pSliceNum); |
| @@ -75,7 +75,7 @@ void GomValidCheck (const int32_t kiMbWidth, const int32_t kiMbHeight, int32_t* · 4 unmodified lines | ||
| 75 | 75 | * \param para SWelsSvcCodingParam* |
| 76 | 76 | * \return successful - 0; otherwise none 0 for failed |
| 77 | 77 | */ |
| 78 | −int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pPara); | |
| 78 | +int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pPara, SLogContext* pLogCtx); | |
| 79 | 79 | |
| 80 | 80 | /*! |
| 81 | 81 | * \brief uninitialize Wels encoder core library |
| @@ -107,7 +107,7 @@ int32_t ForceCodingIDR (sWelsEncCtx* pCtx); · 25 unmodified lines | ||
| 107 | 107 | */ |
| 108 | 108 | int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNew); |
| 109 | 109 | void WelsEncoderApplyFrameRate (SWelsSvcCodingParam* pParam); |
| 110 | −void WelsEncoderApplyBitRate (SWelsSvcCodingParam* pParam, int32_t iLayer); | |
| 110 | +void WelsEncoderApplyBitRate (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iLayer); | |
| 111 | 111 | |
| 112 | 112 | int32_t FilterLTRRecoveryRequest (sWelsEncCtx* pCtx, SLTRRecoverRequest* pLTRRecoverRequest); |
| 113 | 113 | |
| @@ -81,8 +81,8 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg); · 80 unmodified lines | ||
| 81 | 81 | |
| 82 | 82 | int32_t CreateSliceThreads (sWelsEncCtx* pCtx); |
| 83 | 83 | |
| 84 | −int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, WELS_EVENT* pMasterEventsList, | |
| 85 | − SLayerBSInfo* pLayerBsInfo, | |
| 84 | +int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, | |
| 85 | + WELS_EVENT* pMasterEventsList, SLayerBSInfo* pLayerBsInfo, | |
| 86 | 86 | const uint32_t kuiNumThreads/*, int32_t *iLayerNum*/, SSliceCtx* pSliceCtx, const bool kbIsDynamicSlicingMode); |
| 87 | 87 | |
| 88 | 88 | int32_t DynamicDetectCpuCores(); |
| @@ -73,7 +73,7 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 72 unmodified lines | ||
| 73 | 73 | * \pParam pParam SWelsSvcCodingParam* |
| 74 | 74 | * \return successful - 0; otherwise none 0 for failed |
| 75 | 75 | */ |
| 76 | −int32_t ParamValidation (SWelsSvcCodingParam* pCfg) { | |
| 76 | +int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) { | |
| 77 | 77 | float fMaxFrameRate = 0.0f; |
| 78 | 78 | const float fEpsn = 0.000001f; |
| 79 | 79 | int32_t i = 0; |
| @@ -81,7 +81,7 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) { · 1 unmodified line | ||
| 81 | 81 | assert (pCfg != NULL); |
| 82 | 82 | |
| 83 | 83 | if ((pCfg->iUsageType != CAMERA_VIDEO_REAL_TIME) && (pCfg->iUsageType != SCREEN_CONTENT_REAL_TIME)) { |
| 84 | − WelsLog (NULL, WELS_LOG_ERROR, "ParamValidation(),Invalid usage type = %d\n", pCfg->iUsageType); | |
| 84 | + WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidation(),Invalid usage type = %d\n", pCfg->iUsageType); | |
| 85 | 85 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 86 | 86 | } |
| 87 | 87 | for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) { |
| @@ -89,13 +89,13 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) { · 1 unmodified line | ||
| 89 | 89 | if (fDlp->fOutputFrameRate > fDlp->fInputFrameRate || (fDlp->fInputFrameRate >= -fEpsn |
| 90 | 90 | && fDlp->fInputFrameRate <= fEpsn) |
| 91 | 91 | || (fDlp->fOutputFrameRate >= -fEpsn && fDlp->fOutputFrameRate <= fEpsn)) { |
| 92 | − WelsLog (NULL, WELS_LOG_ERROR, | |
| 92 | + WelsLog (pLogCtx, WELS_LOG_ERROR, | |
| 93 | 93 | "Invalid settings in input frame rate(%.6f) or output frame rate(%.6f) of layer #%d config file..\n", |
| 94 | 94 | fDlp->fInputFrameRate, fDlp->fOutputFrameRate, i); |
| 95 | 95 | return ENC_RETURN_INVALIDINPUT; |
| 96 | 96 | } |
| 97 | 97 | if (UINT_MAX == GetLogFactor (fDlp->fOutputFrameRate, fDlp->fInputFrameRate)) { |
| 98 | − WelsLog (NULL, WELS_LOG_ERROR, | |
| 98 | + WelsLog (pLogCtx, WELS_LOG_ERROR, | |
| 99 | 99 | "Invalid settings in input frame rate(%.6f) and output frame rate(%.6f) of layer #%d config file: iResult of output frame rate divided by input frame rate should be power of 2(i.e,in/pOut=2^n)..\n", |
| 100 | 100 | fDlp->fInputFrameRate, fDlp->fOutputFrameRate, i); |
| 101 | 101 | return ENC_RETURN_INVALIDINPUT; |
| @@ -121,7 +121,7 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) { · 19 unmodified lines | ||
| 121 | 121 | iTotalBitrate += fDlp->iSpatialBitrate; |
| 122 | 122 | } |
| 123 | 123 | if (iTotalBitrate > pCfg->iTargetBitrate) { |
| 124 | − WelsLog (NULL, WELS_LOG_ERROR, | |
| 124 | + WelsLog (pLogCtx, WELS_LOG_ERROR, | |
| 125 | 125 | "Invalid settings in bitrate. the sum of each layer bitrate(%d) is larger than total bitrate setting(%d)\n", |
| 126 | 126 | iTotalBitrate, pCfg->iTargetBitrate); |
| 127 | 127 | } |
| @@ -131,7 +131,7 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) { · 3 unmodified lines | ||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
| 134 | −int32_t ParamValidationExt (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pCodingParam) { | |
| 134 | +int32_t ParamValidationExt (SLogContext* pCtx, SWelsSvcCodingParam* pCodingParam) { | |
| 135 | 135 | int8_t i = 0; |
| 136 | 136 | int32_t iIdx = 0; |
| 137 | 137 | |
| @@ -383,7 +383,7 @@ int32_t ParamValidationExt (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pCodingParam · 245 unmodified lines | ||
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | − return ParamValidation (pCodingParam); | |
| 386 | + return ParamValidation (pCtx, pCodingParam); | |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | |
| @@ -412,7 +412,7 @@ void WelsEncoderApplyFrameRate (SWelsSvcCodingParam* pParam) { · 22 unmodified lines | ||
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | |
| 415 | −void WelsEncoderApplyBitRate (SWelsSvcCodingParam* pParam, int iLayer) { | |
| 415 | +void WelsEncoderApplyBitRate (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int iLayer) { | |
| 416 | 416 | //TODO (Sijia): this is a temporary solution which keep the ratio between layers |
| 417 | 417 | //but it is also possible to fulfill the bitrate of lower layer first |
| 418 | 418 | |
| @@ -421,7 +421,7 @@ void WelsEncoderApplyBitRate (SWelsSvcCodingParam* pParam, int iLayer) { · 2 unmodified lines | ||
| 421 | 421 | int32_t i, iOrigTotalBitrate = 0; |
| 422 | 422 | if (iLayer == SPATIAL_LAYER_ALL) { |
| 423 | 423 | if (pParam->iMaxBitrate < pParam->iTargetBitrate) { |
| 424 | − WelsLog (NULL, WELS_LOG_WARNING, | |
| 424 | + WelsLog (pLogCtx, WELS_LOG_WARNING, | |
| 425 | 425 | "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE,overall settting,TargetBitrate = %d,iMaxBitrate = %d\n", |
| 426 | 426 | pParam->iTargetBitrate, pParam->iMaxBitrate); |
| 427 | 427 | pParam->iMaxBitrate = pParam->iTargetBitrate; |
| @@ -439,7 +439,7 @@ void WelsEncoderApplyBitRate (SWelsSvcCodingParam* pParam, int iLayer) { · 11 unmodified lines | ||
| 439 | 439 | } |
| 440 | 440 | } else { |
| 441 | 441 | if (pParam->sSpatialLayers[iLayer].iMaxSpatialBitrate < pParam->sSpatialLayers[iLayer].iSpatialBitrate) { |
| 442 | − WelsLog (NULL, WELS_LOG_WARNING, | |
| 442 | + WelsLog (pLogCtx, WELS_LOG_WARNING, | |
| 443 | 443 | "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE,iLayer = %d,iTargetBitrate = %d,iMaxBitrate = %d\n", |
| 444 | 444 | iLayer, pParam->sSpatialLayers[iLayer].iSpatialBitrate, pParam->sSpatialLayers[iLayer].iMaxSpatialBitrate); |
| 445 | 445 | pParam->sSpatialLayers[iLayer].iMaxSpatialBitrate = pParam->sSpatialLayers[iLayer].iSpatialBitrate; |
| @@ -1723,7 +1723,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 1277 unmodified lines | ||
| 1723 | 1723 | #endif//MEMORY_MONITOR |
| 1724 | 1724 | |
| 1725 | 1725 | if ((*ppCtx)->pMemAlign != NULL) { |
| 1726 | − WelsLog (NULL, WELS_LOG_INFO, "FreeMemorySvc(), verify memory usage (%d bytes) after free..\n", | |
| 1726 | + WelsLog (*ppCtx, WELS_LOG_INFO, "FreeMemorySvc(), verify memory usage (%d bytes) after free..\n", | |
| 1727 | 1727 | (*ppCtx)->pMemAlign->WelsGetMemoryUsage()); |
| 1728 | 1728 | delete (*ppCtx)->pMemAlign; |
| 1729 | 1729 | (*ppCtx)->pMemAlign = NULL; |
| @@ -1734,7 +1734,8 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 4 unmodified lines | ||
| 1734 | 1734 | } |
| 1735 | 1735 | } |
| 1736 | 1736 | |
| 1737 | −int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCpuCores, int16_t* pMaxSliceCount) { | |
| 1737 | +int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingParam, const int32_t kiCpuCores, | |
| 1738 | + int16_t* pMaxSliceCount) { | |
| 1738 | 1739 | int32_t iSpatialIdx = 0, iSpatialNum = pCodingParam->iSpatialLayerNum; |
| 1739 | 1740 | uint16_t iMaxSliceCount = 0; |
| 1740 | 1741 | |
| @@ -1784,7 +1785,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 43 unmodified lines | ||
| 1784 | 1785 | pDlp->sSliceCfg.sSliceArgument.uiSliceNum = iMaxSliceCount; |
| 1785 | 1786 | } |
| 1786 | 1787 | if (pDlp->sSliceCfg.sSliceArgument.uiSliceNum == 1) { |
| 1787 | − WelsLog (NULL, WELS_LOG_DEBUG, | |
| 1788 | + WelsLog (pLogCtx, WELS_LOG_DEBUG, | |
| 1788 | 1789 | "InitSliceSettings(), uiSliceNum(%d) you set for SM_AUTO_SLICE, now turn to SM_SINGLE_SLICE type!\n", |
| 1789 | 1790 | pDlp->sSliceCfg.sSliceArgument.uiSliceNum); |
| 1790 | 1791 | pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| @@ -1799,7 +1800,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 8 unmodified lines | ||
| 1799 | 1800 | } else if (!CheckFixedSliceNumMultiSliceSetting (kiMbNumInFrame, |
| 1800 | 1801 | &pDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings |
| 1801 | 1802 | //check uiSliceMbNum with current uiSliceNum |
| 1802 | − WelsLog (NULL, WELS_LOG_ERROR, | |
| 1803 | + WelsLog (pLogCtx, WELS_LOG_ERROR, | |
| 1803 | 1804 | "InitSliceSettings(), invalid uiSliceMbNum (%d) settings!,now turn to SM_SINGLE_SLICE type\n", |
| 1804 | 1805 | pDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]); |
| 1805 | 1806 | pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| @@ -1838,9 +1839,10 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 32 unmodified lines | ||
| 1838 | 1839 | /*! |
| 1839 | 1840 | * \brief log output for cpu features/capabilities |
| 1840 | 1841 | */ |
| 1841 | −void OutputCpuFeaturesLog (uint32_t uiCpuFeatureFlags, uint32_t uiCpuCores, int32_t iCacheLineSize) { | |
| 1842 | +void OutputCpuFeaturesLog (SLogContext* pLogCtx, uint32_t uiCpuFeatureFlags, uint32_t uiCpuCores, | |
| 1843 | + int32_t iCacheLineSize) { | |
| 1842 | 1844 | // welstracer output |
| 1843 | − WelsLog (NULL, WELS_LOG_INFO, "WELS CPU features/capacities (0x%x) detected: \t" \ | |
| 1845 | + WelsLog (pLogCtx, WELS_LOG_INFO, "WELS CPU features/capacities (0x%x) detected: \t" \ | |
| 1844 | 1846 | "HTT: %c, " \ |
| 1845 | 1847 | "MMX: %c, " \ |
| 1846 | 1848 | "MMXEX: %c, " \ |
| @@ -1890,7 +1892,7 @@ void OutputCpuFeaturesLog (uint32_t uiCpuFeatureFlags, uint32_t uiCpuCores, int3 · 43 unmodified lines | ||
| 1890 | 1892 | * \pParam pParam SWelsSvcCodingParam* |
| 1891 | 1893 | * \return successful - 0; otherwise none 0 for failed |
| 1892 | 1894 | */ |
| 1893 | −int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam) { | |
| 1895 | +int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, SLogContext* pLogCtx) { | |
| 1894 | 1896 | sWelsEncCtx* pCtx = NULL; |
| 1895 | 1897 | int32_t iRet = 0; |
| 1896 | 1898 | uint32_t uiCpuFeatureFlags = 0; // CPU features |
| @@ -1900,14 +1902,14 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 3 unmodified lines | ||
| 1900 | 1902 | int16_t iSliceNum = 1; // number of slices used |
| 1901 | 1903 | |
| 1902 | 1904 | if (NULL == ppCtx || NULL == pCodingParam) { |
| 1903 | − WelsLog (NULL, WELS_LOG_ERROR, "WelsInitEncoderExt(), NULL == ppCtx(0x%p) or NULL == pCodingParam(0x%p).\n", | |
| 1905 | + WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), NULL == ppCtx(0x%p) or NULL == pCodingParam(0x%p).\n", | |
| 1904 | 1906 | (void*)ppCtx, (void*)pCodingParam); |
| 1905 | 1907 | return 1; |
| 1906 | 1908 | } |
| 1907 | 1909 | |
| 1908 | − iRet = ParamValidationExt (*ppCtx, pCodingParam); | |
| 1910 | + iRet = ParamValidationExt (pLogCtx, pCodingParam); | |
| 1909 | 1911 | if (iRet != 0) { |
| 1910 | − WelsLog (NULL, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.\n", iRet); | |
| 1912 | + WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.\n", iRet); | |
| 1911 | 1913 | return iRet; |
| 1912 | 1914 | } |
| 1913 | 1915 | |
| @@ -1922,7 +1924,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 8 unmodified lines | ||
| 1922 | 1924 | iCacheLineSize = 32; |
| 1923 | 1925 | else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_16) |
| 1924 | 1926 | iCacheLineSize = 16; |
| 1925 | − OutputCpuFeaturesLog (uiCpuFeatureFlags, uiCpuCores, iCacheLineSize); | |
| 1927 | + OutputCpuFeaturesLog (pLogCtx, uiCpuFeatureFlags, uiCpuCores, iCacheLineSize); | |
| 1926 | 1928 | #else |
| 1927 | 1929 | iCacheLineSize = 16; // 16 bytes aligned in default |
| 1928 | 1930 | #endif//X86_ASM |
| @@ -1953,8 +1955,8 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 24 unmodified lines | ||
| 1953 | 1955 | |
| 1954 | 1956 | uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM); |
| 1955 | 1957 | |
| 1956 | − if (InitSliceSettings (pCodingParam, uiCpuCores, &iSliceNum)) { | |
| 1957 | − WelsLog (NULL, WELS_LOG_ERROR, "WelsInitEncoderExt(), InitSliceSettings failed.\n"); | |
| 1958 | + if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) { | |
| 1959 | + WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), InitSliceSettings failed.\n"); | |
| 1958 | 1960 | return 1; |
| 1959 | 1961 | } |
| 1960 | 1962 | |
| @@ -1965,6 +1967,8 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 4 unmodified lines | ||
| 1965 | 1967 | WELS_VERIFY_RETURN_IF (1, (NULL == pCtx)) |
| 1966 | 1968 | memset (pCtx, 0, sizeof (sWelsEncCtx)); |
| 1967 | 1969 | |
| 1970 | + pCtx->sLogCtx = *pLogCtx; | |
| 1971 | + | |
| 1968 | 1972 | pCtx->pMemAlign = new CMemoryAlign (iCacheLineSize); |
| 1969 | 1973 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pCtx->pMemAlign), FreeMemorySvc (&pCtx)) |
| 1970 | 1974 | |
| @@ -3133,7 +3137,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 1162 unmodified lines | ||
| 3133 | 3137 | |
| 3134 | 3138 | pCtx->iActiveThreadsNum = iSliceCount; |
| 3135 | 3139 | // to fire slice coding threads |
| 3136 | − iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0], | |
| 3140 | + iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], | |
| 3141 | + &pCtx->pSliceThreading->pReadySliceCodingEvent[0], | |
| 3137 | 3142 | &pCtx->pSliceThreading->pThreadMasterEvent[0], |
| 3138 | 3143 | pLayerBsInfo, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false); |
| 3139 | 3144 | if (iRet) { |
| @@ -3172,7 +3177,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 32 unmodified lines | ||
| 3172 | 3177 | iNumThreadsScheduled = pCtx->iActiveThreadsNum; |
| 3173 | 3178 | iNumThreadsRunning = iNumThreadsScheduled; |
| 3174 | 3179 | // to fire slice coding threads |
| 3175 | − iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0], | |
| 3180 | + iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], | |
| 3181 | + &pCtx->pSliceThreading->pReadySliceCodingEvent[0], | |
| 3176 | 3182 | &pCtx->pSliceThreading->pThreadMasterEvent[0], |
| 3177 | 3183 | pLayerBsInfo, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false); |
| 3178 | 3184 | if (iRet) { |
| @@ -3218,7 +3224,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 39 unmodified lines | ||
| 3218 | 3224 | const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; |
| 3219 | 3225 | |
| 3220 | 3226 | // to fire slice coding threads |
| 3221 | − iRet = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0], | |
| 3227 | + iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], | |
| 3228 | + &pCtx->pSliceThreading->pReadySliceCodingEvent[0], | |
| 3222 | 3229 | &pCtx->pSliceThreading->pThreadMasterEvent[0], |
| 3223 | 3230 | pLayerBsInfo, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true); |
| 3224 | 3231 | if (iRet) { |
| @@ -3509,7 +3516,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 284 unmodified lines | ||
| 3509 | 3516 | if (NULL == ppCtx || NULL == *ppCtx || NULL == pNewParam) return 1; |
| 3510 | 3517 | |
| 3511 | 3518 | /* Check validation in new parameters */ |
| 3512 | − iReturn = ParamValidationExt (*ppCtx, pNewParam); | |
| 3519 | + iReturn = ParamValidationExt (& (*ppCtx)->sLogCtx, pNewParam); | |
| 3513 | 3520 | if (iReturn != ENC_RETURN_SUCCESS) return iReturn; |
| 3514 | 3521 | |
| 3515 | 3522 | pOldParam = (*ppCtx)->pSvcParam; |
| @@ -3574,6 +3581,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 58 unmodified lines | ||
| 3574 | 3581 | if (bNeedReset) { |
| 3575 | 3582 | SParaSetOffsetVariable sTmpPsoVariable[PARA_SET_TYPE]; |
| 3576 | 3583 | uint16_t uiTmpIdrPicId;//this is for LTR! |
| 3584 | + SLogContext sLogCtx = (*ppCtx)->sLogCtx; | |
| 3577 | 3585 | memcpy (sTmpPsoVariable, (*ppCtx)->sPSOVector.sParaSetOffsetVariable, |
| 3578 | 3586 | (PARA_SET_TYPE)*sizeof (SParaSetOffsetVariable)); // confirmed_safe_unsafe_usage |
| 3579 | 3587 | uiTmpIdrPicId = (*ppCtx)->sPSOVector.uiIdrPicId; |
| @@ -3581,7 +3589,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 1 unmodified line | ||
| 3581 | 3589 | WelsUninitEncoderExt (ppCtx); |
| 3582 | 3590 | |
| 3583 | 3591 | /* Update new parameters */ |
| 3584 | − if (WelsInitEncoderExt (ppCtx, pNewParam)) | |
| 3592 | + if (WelsInitEncoderExt (ppCtx, pNewParam, &sLogCtx)) | |
| 3585 | 3593 | return 1; |
| 3586 | 3594 | |
| 3587 | 3595 | // reset the scaled spatial picture size |
| @@ -968,15 +968,15 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 967 unmodified lines | ||
| 968 | 968 | return 0; |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | −int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, WELS_EVENT* pMasterEventsList, | |
| 972 | − SLayerBSInfo* pLbi, | |
| 971 | +int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, | |
| 972 | + WELS_EVENT* pMasterEventsList, SLayerBSInfo* pLbi, | |
| 973 | 973 | const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode) { |
| 974 | 974 | int32_t iEndMbIdx = 0; |
| 975 | 975 | int32_t iIdx = 0; |
| 976 | 976 | const int32_t kiEventCnt = uiNumThreads; |
| 977 | 977 | |
| 978 | 978 | if (pPriData == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) { |
| 979 | − WelsLog (NULL, WELS_LOG_ERROR, | |
| 979 | + WelsLog (pCtx, WELS_LOG_ERROR, | |
| 980 | 980 | "FiredSliceThreads(), fail due pPriData == %p || pLbi == %p || iEventCnt(%d) <= 0 || pEventsList == %p!!\n", |
| 981 | 981 | (void*)pPriData, (void*)pLbi, uiNumThreads, (void*)pEventsList); |
| 982 | 982 | return 1; |
| @@ -131,17 +131,15 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 130 unmodified lines | ||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | CWelsH264SVCEncoder::~CWelsH264SVCEncoder() { |
| 134 | − WelsLog (NULL, WELS_LOG_INFO, "CWelsH264SVCEncoder::~CWelsH264SVCEncoder()\n"); | |
| 134 | + if (m_pWelsTrace) { | |
| 135 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::~CWelsH264SVCEncoder()\n"); | |
| 135 | 136 | |
| 136 | − if (m_pWelsTrace != NULL) { | |
| 137 | − delete m_pWelsTrace; | |
| 138 | − m_pWelsTrace = NULL; | |
| 139 | − } | |
| 140 | 137 | #ifdef REC_FRAME_COUNT |
| 141 | − WelsLog (m_pEncContext, WELS_LOG_INFO, | |
| 142 | − "CWelsH264SVCEncoder::~CWelsH264SVCEncoder(), m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n", m_uiCountFrameNum, | |
| 143 | − m_iCspInternal); | |
| 138 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, | |
| 139 | + "CWelsH264SVCEncoder::~CWelsH264SVCEncoder(), m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n", m_uiCountFrameNum, | |
| 140 | + m_iCspInternal); | |
| 144 | 141 | #endif |
| 142 | + } | |
| 145 | 143 | |
| 146 | 144 | #ifdef REC_FRAME_COUNT |
| 147 | 145 | m_uiCountFrameNum = 0; |
| @@ -161,20 +159,26 @@ CWelsH264SVCEncoder::~CWelsH264SVCEncoder() { · 13 unmodified lines | ||
| 161 | 159 | #endif//OUTPUT_BIT_STREAM |
| 162 | 160 | |
| 163 | 161 | Uninitialize(); |
| 162 | + | |
| 163 | + if (m_pWelsTrace) { | |
| 164 | + delete m_pWelsTrace; | |
| 165 | + m_pWelsTrace = NULL; | |
| 166 | + } | |
| 164 | 167 | } |
| 165 | 168 | |
| 166 | 169 | void CWelsH264SVCEncoder::InitEncoder (void) { |
| 167 | 170 | |
| 171 | + m_pWelsTrace = new welsCodecTrace(); | |
| 172 | + if (m_pWelsTrace == NULL) { | |
| 173 | + return; | |
| 174 | + } | |
| 175 | + | |
| 176 | + m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR); | |
| 177 | + | |
| 168 | 178 | #ifdef REC_FRAME_COUNT |
| 169 | − WelsLog (m_pEncContext, WELS_LOG_INFO, | |
| 179 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, | |
| 170 | 180 | "CWelsH264SVCEncoder::InitEncoder, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n", m_uiCountFrameNum, m_iCspInternal); |
| 171 | 181 | #endif |
| 172 | − | |
| 173 | − m_pWelsTrace = new welsCodecTrace(); | |
| 174 | − if (m_pWelsTrace != NULL) { | |
| 175 | − m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR); | |
| 176 | − WelsSetLogCallback (welsCodecTrace::CODEC_TRACE); | |
| 177 | − } | |
| 178 | 182 | } |
| 179 | 183 | |
| 180 | 184 | /* Interfaces override from ISVCEncoder */ |
| @@ -188,9 +192,12 @@ int CWelsH264SVCEncoder::GetDefaultParams (SEncParamExt* argv) { · 7 unmodified lines | ||
| 188 | 192 | * SVC Encoder Initialization |
| 189 | 193 | */ |
| 190 | 194 | int CWelsH264SVCEncoder::Initialize (const SEncParamBase* argv) { |
| 195 | + if (m_pWelsTrace == NULL) { | |
| 196 | + return cmMallocMemeError; | |
| 197 | + } | |
| 191 | 198 | |
| 192 | 199 | if (NULL == argv) { |
| 193 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid argv= 0x%p\n", | |
| 200 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid argv= 0x%p\n", | |
| 194 | 201 | argv); |
| 195 | 202 | return cmInitParaError; |
| 196 | 203 | } |
| @@ -198,7 +205,8 @@ int CWelsH264SVCEncoder::Initialize (const SEncParamBase* argv) { · 1 unmodified line | ||
| 198 | 205 | SWelsSvcCodingParam sConfig; |
| 199 | 206 | // Convert SEncParamBase into WelsSVCParamConfig here.. |
| 200 | 207 | if (sConfig.ParamBaseTranscode (*argv)) { |
| 201 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), parameter_translation failed.\n"); | |
| 208 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, | |
| 209 | + "CWelsH264SVCEncoder::Initialize(), parameter_translation failed.\n"); | |
| 202 | 210 | Uninitialize(); |
| 203 | 211 | return cmInitParaError; |
| 204 | 212 | } |
| @@ -207,9 +215,12 @@ int CWelsH264SVCEncoder::Initialize (const SEncParamBase* argv) { · 2 unmodified lines | ||
| 207 | 215 | } |
| 208 | 216 | |
| 209 | 217 | int CWelsH264SVCEncoder::InitializeExt (const SEncParamExt* argv) { |
| 218 | + if (m_pWelsTrace == NULL) { | |
| 219 | + return cmMallocMemeError; | |
| 220 | + } | |
| 210 | 221 | |
| 211 | 222 | if (NULL == argv) { |
| 212 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitializeExt(), invalid argv= 0x%p\n", | |
| 223 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitializeExt(), invalid argv= 0x%p\n", | |
| 213 | 224 | argv); |
| 214 | 225 | return cmInitParaError; |
| 215 | 226 | } |
| @@ -217,7 +228,8 @@ int CWelsH264SVCEncoder::InitializeExt (const SEncParamExt* argv) { · 1 unmodified line | ||
| 217 | 228 | SWelsSvcCodingParam sConfig; |
| 218 | 229 | // Convert SEncParamExt into WelsSVCParamConfig here.. |
| 219 | 230 | if (sConfig.ParamTranscode (*argv)) { |
| 220 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitializeExt(), parameter_translation failed.\n"); | |
| 231 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, | |
| 232 | + "CWelsH264SVCEncoder::InitializeExt(), parameter_translation failed.\n"); | |
| 221 | 233 | Uninitialize(); |
| 222 | 234 | return cmInitParaError; |
| 223 | 235 | } |
| @@ -227,22 +239,24 @@ int CWelsH264SVCEncoder::InitializeExt (const SEncParamExt* argv) { · 3 unmodified lines | ||
| 227 | 239 | |
| 228 | 240 | int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { |
| 229 | 241 | if (NULL == pCfg) { |
| 230 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid argv= 0x%p.\n", | |
| 242 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid argv= 0x%p.\n", | |
| 231 | 243 | pCfg); |
| 232 | 244 | return cmInitParaError; |
| 233 | 245 | } |
| 234 | 246 | |
| 235 | 247 | if (m_bInitialFlag) { |
| 236 | − WelsLog (m_pEncContext, WELS_LOG_WARNING, "CWelsH264SVCEncoder::Initialize(), reinitialize, m_bInitialFlag= %d.\n", | |
| 248 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, | |
| 249 | + "CWelsH264SVCEncoder::Initialize(), reinitialize, m_bInitialFlag= %d.\n", | |
| 237 | 250 | m_bInitialFlag); |
| 238 | 251 | Uninitialize(); |
| 239 | 252 | } |
| 240 | 253 | |
| 241 | 254 | #ifdef REC_FRAME_COUNT |
| 242 | 255 | SWelsSvcCodingParam& sEncodingParam = *pCfg; |
| 243 | − WelsLog (m_pEncContext, WELS_LOG_INFO, "CWelsH264SVCEncoder::Initialize, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n", | |
| 256 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, | |
| 257 | + "CWelsH264SVCEncoder::Initialize, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n", | |
| 244 | 258 | m_uiCountFrameNum, m_iCspInternal); |
| 245 | − WelsLog (m_pEncContext, WELS_LOG_INFO, | |
| 259 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, | |
| 246 | 260 | "coding_param->iPicWidth= %d;coding_param->iPicHeight= %d;coding_param->iTargetBitrate= %d;coding_param->iRCMode= %d;coding_param->iTemporalLayerNum= %d;coding_param->iSpatialLayerNum= %d;coding_param->fFrameRate= %.6ff;coding_param->iInputCsp= %d;coding_param->uiIntraPeriod= %d;coding_param->bEnableSpsPpsIdAddition = %d;coding_param->bPrefixNalAddingCtrl = %d;coding_param->bEnableDenoise= %d;coding_param->bEnableBackgroundDetection= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableFrameSkip= %d;coding_param->bEnableCropPic= %d;coding_param->bEnableLongTermReference= %d;coding_param->iLtrMarkPeriod= %d;\n", |
| 247 | 261 | sEncodingParam.iPicWidth, |
| 248 | 262 | sEncodingParam.iPicHeight, |
| @@ -265,7 +279,7 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { · 16 unmodified lines | ||
| 265 | 279 | int32_t i = 0; |
| 266 | 280 | while (i < sEncodingParam.iSpatialLayerNum) { |
| 267 | 281 | SSpatialLayerConfig* spatial_cfg = &sEncodingParam.sSpatialLayers[i]; |
| 268 | − WelsLog (m_pEncContext, WELS_LOG_INFO, | |
| 282 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, | |
| 269 | 283 | "coding_param->sSpatialLayers[%d]: .iVideoWidth= %d; .iVideoHeight= %d; .fFrameRate= %.6ff; .iSpatialBitrate= %d; .sSliceCfg.uiSliceMode= %d; .sSliceCfg.sSliceArgument.uiSliceNum= %d; .sSliceCfg.sSliceArgument.uiSliceSizeConstraint= %d;\n", |
| 270 | 284 | i, spatial_cfg->iVideoWidth, |
| 271 | 285 | spatial_cfg->iVideoHeight, |
| @@ -281,7 +295,8 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { · 9 unmodified lines | ||
| 281 | 295 | |
| 282 | 296 | const int32_t iColorspace = pCfg->iInputCsp; |
| 283 | 297 | if (videoFormatI420 != iColorspace) { |
| 284 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid iInputCsp= %d.\n", iColorspace); | |
| 298 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid iInputCsp= %d.\n", | |
| 299 | + iColorspace); | |
| 285 | 300 | Uninitialize(); |
| 286 | 301 | return cmInitParaError; |
| 287 | 302 | } |
| @@ -289,7 +304,7 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { · 1 unmodified line | ||
| 289 | 304 | // Check valid parameters |
| 290 | 305 | const int32_t iNumOfLayers = pCfg->iSpatialLayerNum; |
| 291 | 306 | if (iNumOfLayers < 1 || iNumOfLayers > MAX_DEPENDENCY_LAYER) { |
| 292 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, | |
| 307 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, | |
| 293 | 308 | "CWelsH264SVCEncoder::Initialize(), invalid iSpatialLayerNum= %d, valid at range of [1, %d].\n", iNumOfLayers, |
| 294 | 309 | MAX_DEPENDENCY_LAYER); |
| 295 | 310 | Uninitialize(); |
| @@ -298,7 +313,7 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { · 2 unmodified lines | ||
| 298 | 313 | if (pCfg->iTemporalLayerNum < 1) |
| 299 | 314 | pCfg->iTemporalLayerNum = 1; |
| 300 | 315 | if (pCfg->iTemporalLayerNum > MAX_TEMPORAL_LEVEL) { |
| 301 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, | |
| 316 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, | |
| 302 | 317 | "CWelsH264SVCEncoder::Initialize(), invalid iTemporalLayerNum= %d, valid at range of [1, %d].\n", |
| 303 | 318 | pCfg->iTemporalLayerNum, MAX_TEMPORAL_LEVEL); |
| 304 | 319 | Uninitialize(); |
| @@ -308,7 +323,7 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { · 3 unmodified lines | ||
| 308 | 323 | // assert( cfg.uiGopSize >= 1 && ( cfg.uiIntraPeriod && (cfg.uiIntraPeriod % cfg.uiGopSize) == 0) ); |
| 309 | 324 | |
| 310 | 325 | if (pCfg->uiGopSize < 1 || pCfg->uiGopSize > MAX_GOP_SIZE) { |
| 311 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, | |
| 326 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, | |
| 312 | 327 | "CWelsH264SVCEncoder::Initialize(), invalid uiGopSize= %d, valid at range of [1, %d].\n", pCfg->uiGopSize, |
| 313 | 328 | MAX_GOP_SIZE); |
| 314 | 329 | Uninitialize(); |
| @@ -316,7 +331,7 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { · 1 unmodified line | ||
| 316 | 331 | } |
| 317 | 332 | |
| 318 | 333 | if (!WELS_POWER2_IF (pCfg->uiGopSize)) { |
| 319 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, | |
| 334 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, | |
| 320 | 335 | "CWelsH264SVCEncoder::Initialize(), invalid uiGopSize= %d, valid at range of [1, %d] and yield to power of 2.\n", |
| 321 | 336 | pCfg->uiGopSize, MAX_GOP_SIZE); |
| 322 | 337 | Uninitialize(); |
| @@ -324,7 +339,7 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { · 1 unmodified line | ||
| 324 | 339 | } |
| 325 | 340 | |
| 326 | 341 | if (pCfg->uiIntraPeriod && pCfg->uiIntraPeriod < pCfg->uiGopSize) { |
| 327 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, | |
| 342 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, | |
| 328 | 343 | "CWelsH264SVCEncoder::Initialize(), invalid uiIntraPeriod= %d, valid in case it equals to 0 for unlimited intra period or exceeds specified uiGopSize= %d.\n", |
| 329 | 344 | pCfg->uiIntraPeriod, pCfg->uiGopSize); |
| 330 | 345 | Uninitialize(); |
| @@ -332,7 +347,7 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { · 1 unmodified line | ||
| 332 | 347 | } |
| 333 | 348 | |
| 334 | 349 | if ((pCfg->uiIntraPeriod && (pCfg->uiIntraPeriod & (pCfg->uiGopSize - 1)) != 0)) { |
| 335 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, | |
| 350 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, | |
| 336 | 351 | "CWelsH264SVCEncoder::Initialize(), invalid uiIntraPeriod= %d, valid in case it equals to 0 for unlimited intra period or exceeds specified uiGopSize= %d also multiple of it.\n", |
| 337 | 352 | pCfg->uiIntraPeriod, pCfg->uiGopSize); |
| 338 | 353 | Uninitialize(); |
| @@ -371,8 +386,8 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { · 32 unmodified lines | ||
| 371 | 386 | m_iMaxPicWidth = pCfg->iPicWidth; |
| 372 | 387 | m_iMaxPicHeight = pCfg->iPicHeight; |
| 373 | 388 | |
| 374 | − if (WelsInitEncoderExt (&m_pEncContext, pCfg)) { | |
| 375 | − WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), WelsInitEncoderExt failed.\n"); | |
| 389 | + if (WelsInitEncoderExt (&m_pEncContext, pCfg, &m_pWelsTrace->m_sLogCtx)) { | |
| 390 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), WelsInitEncoderExt failed.\n"); | |
| 376 | 391 | Uninitialize(); |
| 377 | 392 | return cmInitParaError; |
| 378 | 393 | } |
| @@ -391,10 +406,10 @@ int32_t CWelsH264SVCEncoder::Uninitialize() { · 12 unmodified lines | ||
| 391 | 406 | return 0; |
| 392 | 407 | } |
| 393 | 408 | |
| 394 | − WelsLog (m_pEncContext, WELS_LOG_INFO, "CWelsH264SVCEncoder::Uninitialize()..\n"); | |
| 409 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::Uninitialize()..\n"); | |
| 395 | 410 | |
| 396 | 411 | #ifdef REC_FRAME_COUNT |
| 397 | − WelsLog (m_pEncContext, WELS_LOG_INFO, | |
| 412 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, | |
| 398 | 413 | "CWelsH264SVCEncoder::Uninitialize, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n", m_uiCountFrameNum, m_iCspInternal); |
| 399 | 414 | #endif//REC_FRAME_COUNT |
| 400 | 415 | |
| @@ -548,7 +563,8 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 147 unmodified lines | ||
| 548 | 563 | return cmInitParaError; |
| 549 | 564 | } |
| 550 | 565 | |
| 551 | − if (NULL == m_pEncContext || false == m_bInitialFlag) { | |
| 566 | + if ((NULL == m_pEncContext || false == m_bInitialFlag) && eOptionId != ENCODER_OPTION_TRACE_LEVEL | |
| 567 | + && eOptionId != ENCODER_OPTION_TRACE_CALLBACK && eOptionId != ENCODER_OPTION_TRACE_CALLBACK_CONTEXT) { | |
| 552 | 568 | return cmInitExpected; |
| 553 | 569 | } |
| 554 | 570 | |
| @@ -734,7 +750,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 179 unmodified lines | ||
| 734 | 750 | break; |
| 735 | 751 | } |
| 736 | 752 | //adjust to valid range |
| 737 | − WelsEncoderApplyBitRate (m_pEncContext->pSvcParam, pInfo->iLayer); | |
| 753 | + WelsEncoderApplyBitRate (&m_pWelsTrace->m_sLogCtx, m_pEncContext->pSvcParam, pInfo->iLayer); | |
| 738 | 754 | } |
| 739 | 755 | break; |
| 740 | 756 | case ENCODER_OPTION_MAX_BITRATE: { // Target bit-rate |
| @@ -775,7 +791,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 34 unmodified lines | ||
| 775 | 791 | break; |
| 776 | 792 | } |
| 777 | 793 | //adjust to valid range |
| 778 | − WelsEncoderApplyBitRate (m_pEncContext->pSvcParam, pInfo->iLayer); | |
| 794 | + WelsEncoderApplyBitRate (&m_pWelsTrace->m_sLogCtx, m_pEncContext->pSvcParam, pInfo->iLayer); | |
| 779 | 795 | } |
| 780 | 796 | break; |
| 781 | 797 | case ENCODER_OPTION_RC_MODE: { // 0:quality mode;1:bit-rate mode;2:bitrate limited mode |
| @@ -856,6 +872,20 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 74 unmodified lines | ||
| 856 | 872 | } |
| 857 | 873 | } |
| 858 | 874 | break; |
| 875 | + case ENCODER_OPTION_TRACE_CALLBACK: { | |
| 876 | + if (m_pWelsTrace) { | |
| 877 | + CM_WELS_TRACE callback = * ((CM_WELS_TRACE*)pOption); | |
| 878 | + m_pWelsTrace->SetTraceCallback (callback); | |
| 879 | + } | |
| 880 | + } | |
| 881 | + break; | |
| 882 | + case ENCODER_OPTION_TRACE_CALLBACK_CONTEXT: { | |
| 883 | + if (m_pWelsTrace) { | |
| 884 | + void* ctx = * ((void**)pOption); | |
| 885 | + m_pWelsTrace->SetTraceCallbackContext (ctx); | |
| 886 | + } | |
| 887 | + } | |
| 888 | + break; | |
| 859 | 889 | default: |
| 860 | 890 | return cmInitParaError; |
| 861 | 891 | } |