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

Function test_decoder_full

dlib/test/ffmpeg.cpp:225–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223 class image_type
224 >
225 void test_decoder_full (
226 const std::string& filepath,
227 const std::string& codec,
228 const int nframes,
229 const int height,
230 const int width,
231 const int sample_rate,
232 bool has_image,
233 bool has_audio
234 )
235 {
236 decoder dec([&] {
237 decoder::args args;
238 args.codec_name = codec;
239 return args;
240 }());
241
242 DLIB_TEST(dec.is_open());
243 DLIB_TEST(dec.get_codec_name() == codec);
244 DLIB_TEST(dec.is_audio_decoder() == has_audio);
245 DLIB_TEST(dec.is_image_decoder() == has_image);
246
247 image_type img;
248 audio<int16_t, 2> audio_buf;
249 frame frame_copy;
250 int count{0};
251 int nsamples{0};
252 int iteration{0};
253
254 ifstream fin{filepath, std::ios::binary};
255 std::vector<char> buf(1024);
256
257 const resizing_args args_image {
258 0,
259 0,
260 pix_traits<pixel_type_t<image_type>>::fmt
261 };
262
263 const resampling_args args_audio {
264 sample_rate,
265 dlib::ffmpeg::details::get_layout_from_channels(decltype(audio_buf)::nchannels),
266 sample_traits<decltype(audio_buf)::format>::fmt
267 };
268
269 const auto callback = [&](frame& f)
270 {
271 if (has_audio)
272 {
273 convert(f, audio_buf);
274 convert(audio_buf, frame_copy);
275 DLIB_TEST(f.is_audio());
276 DLIB_TEST(f.sample_rate() == sample_rate);
277 DLIB_TEST(f.samplefmt() == args_audio.fmt);
278 DLIB_TEST(frame_copy.is_audio());
279 DLIB_TEST(frame_copy.sample_rate() == sample_rate);
280 DLIB_TEST(frame_copy.samplefmt() == args_audio.fmt);
281
282 nsamples += f.nsamples();

Callers

nothing calls this directly

Calls 15

get_layout_from_channelsFunction · 0.85
print_spinnerFunction · 0.85
is_audio_decoderMethod · 0.80
is_image_decoderMethod · 0.80
is_audioMethod · 0.80
samplefmtMethod · 0.80
nsamplesMethod · 0.80
is_imageMethod · 0.80
pixfmtMethod · 0.80
readMethod · 0.80
wrapFunction · 0.70
convertFunction · 0.50

Tested by

no test coverage detected