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

Method RunTest

dali/operators/video/frames_decoder_test.cc:56–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54 }
55
56 virtual void RunTest(FramesDecoderBase &decoder, TestVideo &ground_truth, bool has_index = true,
57 double eps = 1.0) {
58 ASSERT_EQ(decoder.Height(), ground_truth.Height());
59 ASSERT_EQ(decoder.Width(), ground_truth.Width());
60 ASSERT_EQ(decoder.Channels(), ground_truth.NumChannels());
61 ASSERT_EQ(decoder.NumFrames(), ground_truth.NumFrames());
62 if (has_index) {
63 ASSERT_EQ(decoder.IsVfr(), ground_truth.IsVfr());
64 }
65
66 RunSequentialTest(decoder, ground_truth, eps);
67 decoder.Reset();
68
69 // Read first frame
70 ASSERT_EQ(decoder.NextFrameIdx(), 0);
71 decoder.ReadNextFrame(FrameData());
72 AssertFrame(FrameData(), 0, ground_truth, eps);
73
74 // Seek to frame
75 decoder.SeekFrame(25);
76 ASSERT_EQ(decoder.NextFrameIdx(), 25);
77 decoder.ReadNextFrame(FrameData());
78 AssertFrame(FrameData(), 25, ground_truth, eps);
79
80 // Seek back to frame
81 decoder.SeekFrame(12);
82 ASSERT_EQ(decoder.NextFrameIdx(), 12);
83 decoder.ReadNextFrame(FrameData());
84 AssertFrame(FrameData(), 12, ground_truth, eps);
85
86 // Seek to last frame (flush frame)
87 int last_frame_index = ground_truth.NumFrames() - 1;
88 decoder.SeekFrame(last_frame_index);
89 ASSERT_EQ(decoder.NextFrameIdx(), last_frame_index);
90 decoder.ReadNextFrame(FrameData());
91 AssertFrame(FrameData(), last_frame_index, ground_truth, eps);
92 ASSERT_EQ(decoder.NextFrameIdx(), -1);
93
94 // Wrap around to first frame
95 ASSERT_FALSE(decoder.ReadNextFrame(FrameData()));
96 decoder.Reset();
97 ASSERT_EQ(decoder.NextFrameIdx(), 0);
98 decoder.ReadNextFrame(FrameData());
99 AssertFrame(FrameData(), 0, ground_truth, eps);
100
101 // Seek to random frames and read them
102 std::mt19937 gen(0);
103 std::uniform_int_distribution<> distr(0, last_frame_index);
104
105 for (int i = 0; i < 20; ++i) {
106 int next_index = distr(gen);
107
108 decoder.SeekFrame(next_index);
109 decoder.ReadNextFrame(FrameData());
110 AssertFrame(FrameData(), next_index, ground_truth, eps);
111 }
112 }
113

Callers

nothing calls this directly

Calls 9

HeightMethod · 0.80
WidthMethod · 0.80
ChannelsMethod · 0.80
IsVfrMethod · 0.80
NumChannelsMethod · 0.45
NumFramesMethod · 0.45
ResetMethod · 0.45
ReadNextFrameMethod · 0.45
SeekFrameMethod · 0.45

Tested by

no test coverage detected