MCPcopy Create free account
hub / github.com/davisking/dlib / test_decoder_images_only

Function test_decoder_images_only

dlib/test/ffmpeg.cpp:173–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171 class image_type
172 >
173 void test_decoder_images_only(
174 const std::string& filepath,
175 const std::string& codec,
176 const int nframes,
177 const int height,
178 const int width
179 )
180 {
181 decoder dec([&] {
182 decoder::args args;
183 args.codec_name = codec;
184 return args;
185 }());
186
187 DLIB_TEST(dec.is_open());
188 DLIB_TEST(dec.get_codec_name() == codec);
189 DLIB_TEST(dec.is_image_decoder());
190 // You can't test for dec.height() or dec.width() yet because no data has been pushed to the decoder.
191
192 image_type img;
193 int counter{0};
194
195 ifstream fin{filepath, std::ios::binary};
196 std::vector<char> buf(1024);
197
198 const auto callback = [&](image_type& img) mutable
199 {
200 DLIB_TEST(img.nr() == height);
201 DLIB_TEST(img.nc() == width);
202 DLIB_TEST(dec.height() == height);
203 DLIB_TEST(dec.width() == width);
204 ++counter;
205
206 if (counter % 10 == 0)
207 print_spinner();
208 };
209
210 while (fin)
211 {
212 fin.read(buf.data(), buf.size());
213 size_t ret = fin.gcount();
214 DLIB_TEST(dec.push((const uint8_t*)buf.data(), ret, wrap(callback)));
215 }
216
217 dec.flush(wrap(callback));
218 DLIB_TEST(counter == nframes);
219 DLIB_TEST(!dec.is_open());
220 }
221
222 template <
223 class image_type

Callers

nothing calls this directly

Calls 14

print_spinnerFunction · 0.85
is_image_decoderMethod · 0.80
readMethod · 0.80
wrapFunction · 0.70
is_openMethod · 0.45
get_codec_nameMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45
heightMethod · 0.45
widthMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected