Skip to content

Commit 8ad2e1b

Browse files
committed
Merge branch 'main' of github.com:pytorch/torchcodec
2 parents 7953714 + 91f1a6f commit 8ad2e1b

File tree

3 files changed

+204
-119
lines changed

3 files changed

+204
-119
lines changed

Diff for: src/torchcodec/decoders/_core/VideoDecoder.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@ VideoDecoder::BatchDecodedOutput::BatchDecodedOutput(
203203
frames = allocateEmptyHWCTensor(height, width, options.device, numFrames);
204204
}
205205

206+
bool VideoDecoder::SwsContextKey::operator==(
207+
const VideoDecoder::SwsContextKey& other) {
208+
return decodedWidth == other.decodedWidth && decodedHeight == decodedHeight &&
209+
decodedFormat == other.decodedFormat &&
210+
outputWidth == other.outputWidth && outputHeight == other.outputHeight;
211+
}
212+
213+
bool VideoDecoder::SwsContextKey::operator!=(
214+
const VideoDecoder::SwsContextKey& other) {
215+
return !(*this == other);
216+
}
217+
206218
VideoDecoder::VideoDecoder() {}
207219

208220
void VideoDecoder::initializeDecoder() {
@@ -1340,7 +1352,11 @@ int VideoDecoder::convertFrameToBufferUsingSwsScale(
13401352
int expectedOutputHeight = outputTensor.sizes()[0];
13411353
int expectedOutputWidth = outputTensor.sizes()[1];
13421354
auto curFrameSwsContextKey = SwsContextKey{
1343-
frame->width, frame->height, frameFormat, expectedOutputWidth, expectedOutputHeight};
1355+
frame->width,
1356+
frame->height,
1357+
frameFormat,
1358+
expectedOutputWidth,
1359+
expectedOutputHeight};
13441360
if (activeStream.swsContext.get() == nullptr ||
13451361
activeStream.swsContextKey != curFrameSwsContextKey) {
13461362
SwsContext* swsContext = sws_getContext(

Diff for: src/torchcodec/decoders/_core/VideoDecoder.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ class VideoDecoder {
323323
AVPixelFormat decodedFormat;
324324
int outputWidth;
325325
int outputHeight;
326-
bool operator==(const SwsContextKey&) const = default;
327-
bool operator!=(const SwsContextKey&) const = default;
326+
bool operator==(const SwsContextKey&);
327+
bool operator!=(const SwsContextKey&);
328328
};
329329
// Stores information for each stream.
330330
struct StreamInfo {

0 commit comments

Comments
 (0)