Skip to content

Commit 234e1d9

Browse files
committed
Fix merge
1 parent bf6a743 commit 234e1d9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/torchcodec/_core/FFMPEGCommon.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ using UniqueAVCodecContext = std::unique_ptr<
7373
Deleterp<AVCodecContext, void, avcodec_free_context>>;
7474
using SharedAVCodecContext = std::shared_ptr<AVCodecContext>;
7575

76+
// create SharedAVCodecContext with custom deleter
77+
inline SharedAVCodecContext makeSharedAVCodecContext(AVCodecContext* ctx) {
78+
return SharedAVCodecContext(
79+
ctx, Deleterp<AVCodecContext, void, avcodec_free_context>{});
80+
}
81+
7682
using UniqueAVFrame =
7783
std::unique_ptr<AVFrame, Deleterp<AVFrame, void, av_frame_free>>;
7884
using UniqueAVFilterGraph = std::unique_ptr<

src/torchcodec/_core/SingleStreamDecoder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,7 @@ void SingleStreamDecoder::addStream(
440440

441441
AVCodecContext* codecContext = avcodec_alloc_context3(avCodec);
442442
TORCH_CHECK(codecContext != nullptr);
443-
streamInfo.codecContext = SharedAVCodecContext(
444-
codecContext, [](AVCodecContext* ctx) { avcodec_free_context(&ctx); });
443+
streamInfo.codecContext = makeSharedAVCodecContext(codecContext);
445444

446445
int retVal = avcodec_parameters_to_context(
447446
streamInfo.codecContext.get(), streamInfo.stream->codecpar);

0 commit comments

Comments
 (0)