(device, batch_size, filenames, stride, sequence_length)
| 575 | *[(device, 3, vfr_files, 2, 1000) for device in ["cpu", "mixed"]], |
| 576 | ) |
| 577 | def 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") |
nothing calls this directly
no test coverage detected