Skip to content

Commit 17e5b18

Browse files
author
Daniel Flores
committed
reorder header
1 parent 764888d commit 17e5b18

File tree

1 file changed

+42
-41
lines changed

1 file changed

+42
-41
lines changed

src/torchcodec/_core/Encoder.h

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -58,47 +58,6 @@ class AudioEncoder {
5858
int64_t lastEncodedAVFramePts_ = 0;
5959
};
6060

61-
class VideoEncoder {
62-
public:
63-
~VideoEncoder();
64-
65-
VideoEncoder(
66-
const torch::Tensor& frames,
67-
int frameRate,
68-
std::string_view fileName,
69-
const VideoStreamOptions& videoStreamOptions);
70-
71-
void encode();
72-
73-
private:
74-
void initializeEncoder(const VideoStreamOptions& videoStreamOptions);
75-
UniqueAVFrame convertTensorToAVFrame(
76-
const torch::Tensor& frameTensor,
77-
int frameIndex);
78-
void encodeFrame(AutoAVPacket& autoAVPacket, const UniqueAVFrame& avFrame);
79-
void flushBuffers();
80-
void close_avio();
81-
82-
UniqueEncodingAVFormatContext avFormatContext_;
83-
UniqueAVCodecContext avCodecContext_;
84-
int streamIndex_;
85-
UniqueSwsContext swsContext_;
86-
87-
const torch::Tensor frames_;
88-
int frameRate_;
89-
90-
int inWidth_ = -1;
91-
int inHeight_ = -1;
92-
AVPixelFormat inPixelFormat_ = AV_PIX_FMT_NONE;
93-
94-
int outWidth_ = -1;
95-
int outHeight_ = -1;
96-
AVPixelFormat outPixelFormat_ = AV_PIX_FMT_NONE;
97-
98-
bool encodeWasCalled_ = false;
99-
};
100-
} // namespace facebook::torchcodec
101-
10261
/* clang-format off */
10362
//
10463
// Note: [Encoding loop, sample rate conversion and FIFO]
@@ -161,3 +120,45 @@ class VideoEncoder {
161120
//
162121
//
163122
/* clang-format on */
123+
124+
class VideoEncoder {
125+
public:
126+
~VideoEncoder();
127+
128+
VideoEncoder(
129+
const torch::Tensor& frames,
130+
int frameRate,
131+
std::string_view fileName,
132+
const VideoStreamOptions& videoStreamOptions);
133+
134+
void encode();
135+
136+
private:
137+
void initializeEncoder(const VideoStreamOptions& videoStreamOptions);
138+
UniqueAVFrame convertTensorToAVFrame(
139+
const torch::Tensor& frame,
140+
int frameIndex);
141+
void encodeFrame(AutoAVPacket& autoAVPacket, const UniqueAVFrame& avFrame);
142+
void flushBuffers();
143+
void close_avio();
144+
145+
UniqueEncodingAVFormatContext avFormatContext_;
146+
UniqueAVCodecContext avCodecContext_;
147+
int streamIndex_;
148+
UniqueSwsContext swsContext_;
149+
150+
const torch::Tensor frames_;
151+
int inFrameRate_;
152+
153+
int inWidth_ = -1;
154+
int inHeight_ = -1;
155+
AVPixelFormat inPixelFormat_ = AV_PIX_FMT_NONE;
156+
157+
int outWidth_ = -1;
158+
int outHeight_ = -1;
159+
AVPixelFormat outPixelFormat_ = AV_PIX_FMT_NONE;
160+
161+
bool encodeWasCalled_ = false;
162+
};
163+
164+
} // namespace facebook::torchcodec

0 commit comments

Comments
 (0)