MCPcopy Create free account
hub / github.com/NVIDIA/DALI / test_video_decoder_no_padding

Function test_video_decoder_no_padding

dali/test/python/decoder/test_video.py:577–609  ·  view source on GitHub ↗
(device, batch_size, filenames, stride, sequence_length)

Source from the content-addressed store, hash-verified

575 *[(device, 3, vfr_files, 2, 1000) for device in ["cpu", "mixed"]],
576)
577def test_video_decoder_no_padding(device, batch_size, filenames, stride, sequence_length):
578 skip_if_m60()
579 batch = []
580 for i in range(batch_size):
581 with open(filenames[i % len(filenames)], "rb") as f:
582 batch.append(np.frombuffer(f.read(), dtype=np.uint8))
583
584 def get_batch():
585 return batch
586
587 @pipeline_def
588 def test_pipeline():
589 encoded = fn.external_source(source=get_batch, device="cpu")
590 # Get full video first as reference
591 reference = fn.experimental.decoders.video(encoded, device=device, stride=stride)
592 # Request frames that would exceed video length
593 decoded = fn.experimental.decoders.video(
594 encoded,
595 device=device,
596 stride=stride,
597 sequence_length=sequence_length,
598 pad_mode="none",
599 )
600 return (reference, decoded)
601
602 pipe = test_pipeline(batch_size=batch_size, num_threads=1, device_id=0)
603 out_ref, out = (o.as_cpu() for o in pipe.run())
604
605 # Verify each sample in the batch
606 for i in range(batch_size):
607 ref = out_ref.at(i)
608 actual = out.at(i)
609 compare_videos(ref, actual)
610
611
612@params("cpu", "mixed")

Callers

nothing calls this directly

Calls 7

skip_if_m60Function · 0.90
compare_videosFunction · 0.85
readMethod · 0.80
test_pipelineFunction · 0.70
appendMethod · 0.45
runMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected