| 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 |
nothing calls this directly
no test coverage detected