Skip to content

Commit 436b431

Browse files
committed
Fixes
Signed-off-by: Janusz Lisiecki <[email protected]>
1 parent 9d673f7 commit 436b431

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

dali/operators/reader/loader/video_loader.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ static int64_t seek_file(void *opaque, int64_t offset, int whence) {
266266
}
267267
}
268268

269+
void clean_avformat_context(AVFormatContext **p){
270+
if ((*p)->flags & AVFMT_FLAG_CUSTOM_IO) {
271+
av_freep(&(*p)->pb->buffer);
272+
av_freep(&(*p)->pb);
273+
}
274+
avformat_close_input(p);
275+
}
276+
269277
VideoFile& VideoLoader::get_or_open_file(const std::string &filename) {
270278
static VideoFile empty_file = {};
271279
auto& file = open_files_[filename];
@@ -304,7 +312,7 @@ VideoFile& VideoLoader::get_or_open_file(const std::string &filename) {
304312
open_files_.erase(filename);
305313
return empty_file;
306314
}
307-
file.fmt_ctx_ = make_unique_av<AVFormatContext>(tmp_raw_fmt_ctx, avformat_close_input);
315+
file.fmt_ctx_ = make_unique_av<AVFormatContext>(tmp_raw_fmt_ctx, clean_avformat_context);
308316
LOG_LINE << "File open " << filename << std::endl;
309317

310318
LOG_LINE << "File info fetched for " << filename << std::endl;
@@ -402,6 +410,7 @@ VideoFile& VideoLoader::get_or_open_file(const std::string &filename) {
402410
if (ret < 0) {
403411
DALI_WARN(make_string("Unable to read frame from file :", filename));
404412
open_files_.erase(filename);
413+
av_packet_unref(&pkt);
405414
return empty_file;
406415
}
407416

qa/leak.sup

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ leak:numba
1111
leak:libmxnet
1212
leak:libtorch
1313
leak:libc10
14+
# we don't control FFmpegDemuxer destructor so we cannot fix that in DALI
15+
leak:FFmpegDemuxer
1416
# tensorflow
1517
leak:PyInit__pywrap_debug_events_writer
1618
leak:_pywrap

0 commit comments

Comments
 (0)