| 199 | } |
| 200 | |
| 201 | std::tuple<unsigned int, unsigned int, int> parse_ppm_header(std::ifstream &fs) |
| 202 | { |
| 203 | // Check the PPM magic number is valid |
| 204 | std::array<char, 2> magic_number{{0}}; |
| 205 | fs >> magic_number[0] >> magic_number[1]; |
| 206 | ARM_COMPUTE_ERROR_ON_MSG(magic_number[0] != 'P' || magic_number[1] != '6', "Invalid file type"); |
| 207 | ARM_COMPUTE_UNUSED(magic_number); |
| 208 | |
| 209 | discard_comments_and_spaces(fs); |
| 210 | |
| 211 | unsigned int width = 0; |
| 212 | fs >> width; |
| 213 | |
| 214 | discard_comments_and_spaces(fs); |
| 215 | |
| 216 | unsigned int height = 0; |
| 217 | fs >> height; |
| 218 | |
| 219 | discard_comments_and_spaces(fs); |
| 220 | |
| 221 | int max_val = 0; |
| 222 | fs >> max_val; |
| 223 | |
| 224 | discard_comments(fs); |
| 225 | |
| 226 | ARM_COMPUTE_ERROR_ON_MSG(isspace(fs.peek()) == 0, "Invalid PPM header"); |
| 227 | fs.ignore(1); |
| 228 | |
| 229 | return std::make_tuple(width, height, max_val); |
| 230 | } |
| 231 | |
| 232 | npy::header_t parse_npy_header(std::ifstream &fs) //NOLINT |
| 233 | { |
no test coverage detected