@@ -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-
248226TEST_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+
412426TEST_P (VideoDecoderTest, GetAudioMetadata) {
413427 std::string path = getResourcePath (" nasa_13013.mp4.audio.mp3" );
414428 std::unique_ptr<VideoDecoder> decoder =
0 commit comments