Commit d7b36194 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by gerrit2

libav: make av_log optionnal using environment

Using AVLOGLEVEL environment variable, user can now
finely define which av_log level is requiered.

AVLOGLEVEL has to be set using values accepted by av_log_set_level.

Issue: #79075
Change-Id: I25f4c8842eca159ebac0e13c9af4e29289c07962
parent e8ce28e7
......@@ -70,6 +70,7 @@ extern "C" {
#include <libavutil/mathematics.h> // for av_rescale_q (old libav support)
#include <libavutil/imgutils.h>
#include <libavutil/intreadwrite.h>
#include <libavutil/log.h>
}
#include "libav_utils.h"
......
......@@ -80,8 +80,25 @@ avcodecManageMutex(void **data, enum AVLockOp op)
return AVERROR(ret);
}
static constexpr const char* AVLOGLEVEL = "AVLOGLEVEL";
static void init_once()
static void
setAvLogLevel()
{
char* envvar = getenv(AVLOGLEVEL);
signed level = AV_LOG_ERROR;
if (envvar != nullptr) {
if (not (std::istringstream(envvar) >> level))
level = AV_LOG_ERROR;
level = std::max(AV_LOG_QUIET, std::min(level, AV_LOG_DEBUG));
}
av_log_set_level(level);
}
static void
init_once()
{
av_register_all();
avdevice_register_all();
......@@ -92,7 +109,7 @@ static void init_once()
av_lockmgr_register(avcodecManageMutex);
if (getDebugMode())
av_log_set_level(AV_LOG_VERBOSE);
setAvLogLevel();
}
static std::once_flag already_called;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment