Skip to content

Commit 2b49b86

Browse files
author
Daniel Flores
committed
remove unused avioContextHolder_
1 parent f8939ce commit 2b49b86

File tree

2 files changed

+3
-23
lines changed

2 files changed

+3
-23
lines changed

src/torchcodec/_core/Encoder.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -555,18 +555,10 @@ TensorFormat analyzeTensorFormat(const torch::Tensor& frames) {
555555
} // namespace
556556

557557
VideoEncoder::~VideoEncoder() {
558-
close_avio();
559-
}
560-
561-
void VideoEncoder::close_avio() {
562558
if (avFormatContext_ && avFormatContext_->pb) {
563559
avio_flush(avFormatContext_->pb);
564-
565-
if (!avioContextHolder_) {
566-
avio_close(avFormatContext_->pb);
567-
// avoids closing again in destructor, which would segfault.
568-
avFormatContext_->pb = nullptr;
569-
}
560+
avio_close(avFormatContext_->pb);
561+
avFormatContext_->pb = nullptr;
570562
}
571563
}
572564

@@ -779,7 +771,7 @@ void VideoEncoder::encode() {
779771
"Error in av_write_trailer: ",
780772
getFFMPEGErrorStringFromErrorCode(status));
781773

782-
close_avio();
774+
// close_avio();
783775
}
784776

785777
void VideoEncoder::encodeFrame(

src/torchcodec/_core/Encoder.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,8 @@ class VideoEncoder {
6868
std::string_view fileName,
6969
const VideoStreamOptions& videoStreamOptions);
7070

71-
VideoEncoder(
72-
const torch::Tensor& frames,
73-
int frameRate,
74-
std::string_view formatName,
75-
std::unique_ptr<AVIOContextHolder> avioContextHolder,
76-
const VideoStreamOptions& videoStreamOptions);
77-
7871
void encode();
7972

80-
torch::Tensor encodeToTensor();
81-
8273
private:
8374
void initializeEncoder(const VideoStreamOptions& videoStreamOptions);
8475
UniqueAVFrame convertTensorToAVFrame(
@@ -105,10 +96,7 @@ class VideoEncoder {
10596
int outHeight_ = -1;
10697
AVPixelFormat outPixelFormat_ = AV_PIX_FMT_NONE;
10798

108-
std::unique_ptr<AVIOContextHolder> avioContextHolder_;
109-
11099
bool encodeWasCalled_ = false;
111-
int64_t lastEncodedAVFramePts_ = 0;
112100
};
113101
} // namespace facebook::torchcodec
114102

0 commit comments

Comments
 (0)