Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions dali/operators/video/frames_decoder_base.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,18 @@

namespace dali {

namespace {

// FFmpeg's log level is a plain global (av_log_set_level only stores it). It is set once, while the
// library is loaded and before any decoder exists, rather than by every decoder: decoders are
// created on several threads
const bool av_log_level_set = [] {
av_log_set_level(AV_LOG_ERROR);
return true;
}();

} // namespace

int MemoryVideoFile::Read(unsigned char *buffer, int buffer_size) {
int left_in_file = size_ - position_;
if (left_in_file <= 0) {
Expand Down Expand Up @@ -213,7 +225,6 @@ bool FramesDecoderBase::CheckDimensions() {
}

FramesDecoderBase::FramesDecoderBase(const std::string &filename, DALIImageType image_type) {
av_log_set_level(AV_LOG_ERROR);
filename_ = filename;
DALI_ENFORCE(image_type == DALI_YCbCr || image_type == DALI_RGB,
make_string("Invalid image type: ", image_type));
Expand All @@ -234,7 +245,6 @@ FramesDecoderBase::FramesDecoderBase(const std::string &filename, DALIImageType
}

FramesDecoderBase::FramesDecoderBase(const char *memory_file, size_t memory_file_size, std::string_view source_info, DALIImageType image_type) {
av_log_set_level(AV_LOG_ERROR);
filename_ = source_info;
DALI_ENFORCE(image_type == DALI_YCbCr || image_type == DALI_RGB,
make_string("Invalid image type: ", image_type));
Expand Down
6 changes: 3 additions & 3 deletions dali/operators/video/video_utils.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@
#include <fstream>
#include <sstream>
#include <string>
#include <utility>

namespace dali {

Expand Down Expand Up @@ -148,8 +149,7 @@ std::vector<VideoFileMeta> GetVideoFiles(const std::string& file_root,
}

std::string av_error_string(int ret) {
static char msg[AV_ERROR_MAX_STRING_SIZE];
memset(msg, 0, sizeof(msg));
char msg[AV_ERROR_MAX_STRING_SIZE] = {}; // not static: decoders run on several threads
return std::string(av_make_error_string(msg, AV_ERROR_MAX_STRING_SIZE, ret));
}

Expand Down
Loading