Skip to content

Commit bc1acd3

Browse files
committed
Just duplicate the thing
1 parent 30db736 commit bc1acd3

File tree

2 files changed

+39
-23
lines changed

2 files changed

+39
-23
lines changed

packaging/check_glibcxx.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
all_symbols.add(match.group(0))
4747

4848
if not all_symbols:
49-
raise ValueError(f"No GLIBCXX symbols found in {symbol_matches}. Something is wrong.")
49+
raise ValueError(
50+
f"No GLIBCXX symbols found in {symbol_matches}. Something is wrong."
51+
)
5052

5153
all_versions = (symbol.split("_")[1].split(".") for symbol in all_symbols)
5254
all_versions = (tuple(int(v) for v in version) for version in all_versions)

test/decoders/VideoDecoderTest.cpp

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -223,28 +223,6 @@ TEST_P(VideoDecoderTest, DecodesFramesInABatchInNCHW) {
223223
EXPECT_TRUE(torch::equal(tensor[1], tensorTime6FromFFMPEG));
224224
}
225225

226-
void testDecoderWithColorConversion(const std::string& colorConversionLibrary) {
227-
std::string path = getResourcePath("nasa_13013.mp4");
228-
auto preAllocatedOutputTensor = torch::empty({270, 480, 3}, {torch::kUInt8});
229-
230-
std::unique_ptr<VideoDecoder> ourDecoder =
231-
createDecoderFromPath(path, GetParam());
232-
ourDecoder->scanFileAndUpdateMetadataAndIndex();
233-
int bestVideoStreamIndex =
234-
*ourDecoder->getContainerMetadata().bestVideoStreamIndex;
235-
ourDecoder->addVideoStreamDecoder(
236-
bestVideoStreamIndex,
237-
VideoDecoder::VideoStreamDecoderOptions(
238-
"color_conversion_library=" + colorConversionLibrary));
239-
auto output = ourDecoder->getFrameAtIndex(
240-
bestVideoStreamIndex, 0, preAllocatedOutputTensor);
241-
EXPECT_EQ(output.frame.data_ptr(), preAllocatedOutputTensor.data_ptr());
242-
}
243-
TEST_P(VideoDecoderTest, PreAllocatedTensor) {
244-
testDecoderWithColorConversion("swscale");
245-
testDecoderWithColorConversion("filtergraph");
246-
}
247-
248226
TEST_P(VideoDecoderTest, DecodesFramesInABatchInNHWC) {
249227
std::string path = getResourcePath("nasa_13013.mp4");
250228
std::unique_ptr<VideoDecoder> ourDecoder =
@@ -409,6 +387,42 @@ TEST_P(VideoDecoderTest, SeeksToFrameWithSpecificPts) {
409387
}
410388
}
411389

390+
TEST_P(VideoDecoderTest, PreAllocatedTensorFilterGraph) {
391+
std::string path = getResourcePath("nasa_13013.mp4");
392+
auto preAllocatedOutputTensor = torch::empty({270, 480, 3}, {torch::kUInt8});
393+
394+
std::unique_ptr<VideoDecoder> ourDecoder =
395+
VideoDecoderTest::createDecoderFromPath(path, GetParam());
396+
ourDecoder->scanFileAndUpdateMetadataAndIndex();
397+
int bestVideoStreamIndex =
398+
*ourDecoder->getContainerMetadata().bestVideoStreamIndex;
399+
ourDecoder->addVideoStreamDecoder(
400+
bestVideoStreamIndex,
401+
VideoDecoder::VideoStreamDecoderOptions(
402+
"color_conversion_library=filtergraph"));
403+
auto output = ourDecoder->getFrameAtIndex(
404+
bestVideoStreamIndex, 0, preAllocatedOutputTensor);
405+
EXPECT_EQ(output.frame.data_ptr(), preAllocatedOutputTensor.data_ptr());
406+
}
407+
408+
TEST_P(VideoDecoderTest, PreAllocatedTensorSwscale) {
409+
std::string path = getResourcePath("nasa_13013.mp4");
410+
auto preAllocatedOutputTensor = torch::empty({270, 480, 3}, {torch::kUInt8});
411+
412+
std::unique_ptr<VideoDecoder> ourDecoder =
413+
VideoDecoderTest::createDecoderFromPath(path, GetParam());
414+
ourDecoder->scanFileAndUpdateMetadataAndIndex();
415+
int bestVideoStreamIndex =
416+
*ourDecoder->getContainerMetadata().bestVideoStreamIndex;
417+
ourDecoder->addVideoStreamDecoder(
418+
bestVideoStreamIndex,
419+
VideoDecoder::VideoStreamDecoderOptions(
420+
"color_conversion_library=swscale"));
421+
auto output = ourDecoder->getFrameAtIndex(
422+
bestVideoStreamIndex, 0, preAllocatedOutputTensor);
423+
EXPECT_EQ(output.frame.data_ptr(), preAllocatedOutputTensor.data_ptr());
424+
}
425+
412426
TEST_P(VideoDecoderTest, GetAudioMetadata) {
413427
std::string path = getResourcePath("nasa_13013.mp4.audio.mp3");
414428
std::unique_ptr<VideoDecoder> decoder =

0 commit comments

Comments
 (0)