Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Image format | ||
3 | * Copyright (c) 2000, 2001, 2002 Fabrice Bellard | ||
4 | * Copyright (c) 2004 Michael Niedermayer | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | #include "config_components.h" | ||
24 | |||
25 | #define _DEFAULT_SOURCE | ||
26 | #define _BSD_SOURCE | ||
27 | #include <sys/stat.h> | ||
28 | #include "libavutil/avassert.h" | ||
29 | #include "libavutil/avstring.h" | ||
30 | #include "libavutil/log.h" | ||
31 | #include "libavutil/mem.h" | ||
32 | #include "libavutil/opt.h" | ||
33 | #include "libavutil/pixdesc.h" | ||
34 | #include "libavutil/intreadwrite.h" | ||
35 | #include "libavcodec/gif.h" | ||
36 | #include "avformat.h" | ||
37 | #include "avio_internal.h" | ||
38 | #include "demux.h" | ||
39 | #include "internal.h" | ||
40 | #include "img2.h" | ||
41 | #include "os_support.h" | ||
42 | #include "libavcodec/jpegxl_parse.h" | ||
43 | #include "libavcodec/mjpeg.h" | ||
44 | #include "libavcodec/vbn.h" | ||
45 | #include "libavcodec/xwd.h" | ||
46 | #include "subtitles.h" | ||
47 | |||
48 | #if HAVE_GLOB | ||
49 | /* Locally define as 0 (bitwise-OR no-op) any missing glob options that | ||
50 | are non-posix glibc/bsd extensions. */ | ||
51 | #ifndef GLOB_NOMAGIC | ||
52 | #define GLOB_NOMAGIC 0 | ||
53 | #endif | ||
54 | #ifndef GLOB_BRACE | ||
55 | #define GLOB_BRACE 0 | ||
56 | #endif | ||
57 | |||
58 | #endif /* HAVE_GLOB */ | ||
59 | |||
60 | static const int sizes[][2] = { | ||
61 | { 640, 480 }, | ||
62 | { 720, 480 }, | ||
63 | { 720, 576 }, | ||
64 | { 352, 288 }, | ||
65 | { 352, 240 }, | ||
66 | { 160, 128 }, | ||
67 | { 512, 384 }, | ||
68 | { 640, 352 }, | ||
69 | { 640, 240 }, | ||
70 | }; | ||
71 | |||
72 | ✗ | static int infer_size(int *width_ptr, int *height_ptr, int size) | |
73 | { | ||
74 | int i; | ||
75 | |||
76 | ✗ | for (i = 0; i < FF_ARRAY_ELEMS(sizes); i++) { | |
77 | ✗ | if ((sizes[i][0] * sizes[i][1]) == size) { | |
78 | ✗ | *width_ptr = sizes[i][0]; | |
79 | ✗ | *height_ptr = sizes[i][1]; | |
80 | ✗ | return 0; | |
81 | } | ||
82 | } | ||
83 | |||
84 | ✗ | return -1; | |
85 | } | ||
86 | |||
87 | /** | ||
88 | * Get index range of image files matched by path. | ||
89 | * | ||
90 | * @param pfirst_index pointer to index updated with the first number in the range | ||
91 | * @param plast_index pointer to index updated with the last number in the range | ||
92 | * @param path path which has to be matched by the image files in the range | ||
93 | * @param start_index minimum accepted value for the first index in the range | ||
94 | * @return -1 if no image file could be found | ||
95 | */ | ||
96 | 3109 | static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index, | |
97 | const char *path, int start_index, int start_index_range) | ||
98 | { | ||
99 | char buf[1024]; | ||
100 | int range, last_index, range1, first_index; | ||
101 | |||
102 | /* find the first image */ | ||
103 |
1/2✓ Branch 0 taken 3168 times.
✗ Branch 1 not taken.
|
3168 | for (first_index = start_index; first_index < start_index + start_index_range; first_index++) { |
104 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3164 times.
|
3168 | if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0) { |
105 | 4 | *pfirst_index = | |
106 | 4 | *plast_index = 1; | |
107 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
4 | if (pb || avio_check(buf, AVIO_FLAG_READ) > 0) |
108 | 4 | return 0; | |
109 | ✗ | return -1; | |
110 | } | ||
111 |
2/2✓ Branch 1 taken 3105 times.
✓ Branch 2 taken 59 times.
|
3164 | if (avio_check(buf, AVIO_FLAG_READ) > 0) |
112 | 3105 | break; | |
113 | } | ||
114 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3105 times.
|
3105 | if (first_index == start_index + start_index_range) |
115 | ✗ | goto fail; | |
116 | |||
117 | /* find the last image */ | ||
118 | 3105 | last_index = first_index; | |
119 | for (;;) { | ||
120 | 12345 | range = 0; | |
121 | for (;;) { | ||
122 |
2/2✓ Branch 0 taken 12345 times.
✓ Branch 1 taken 36877 times.
|
49222 | if (!range) |
123 | 12345 | range1 = 1; | |
124 | else | ||
125 | 36877 | range1 = 2 * range; | |
126 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 49222 times.
|
49222 | if (av_get_frame_filename(buf, sizeof(buf), path, |
127 | last_index + range1) < 0) | ||
128 | ✗ | goto fail; | |
129 |
2/2✓ Branch 1 taken 12345 times.
✓ Branch 2 taken 36877 times.
|
49222 | if (avio_check(buf, AVIO_FLAG_READ) <= 0) |
130 | 12345 | break; | |
131 | 36877 | range = range1; | |
132 | /* just in case... */ | ||
133 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 36877 times.
|
36877 | if (range >= (1 << 30)) |
134 | ✗ | goto fail; | |
135 | } | ||
136 | /* we are sure than image last_index + range exists */ | ||
137 |
2/2✓ Branch 0 taken 3105 times.
✓ Branch 1 taken 9240 times.
|
12345 | if (!range) |
138 | 3105 | break; | |
139 | 9240 | last_index += range; | |
140 | } | ||
141 | 3105 | *pfirst_index = first_index; | |
142 | 3105 | *plast_index = last_index; | |
143 | 3105 | return 0; | |
144 | |||
145 | ✗ | fail: | |
146 | ✗ | return -1; | |
147 | } | ||
148 | |||
149 | 11155 | static int img_read_probe(const AVProbeData *p) | |
150 | { | ||
151 |
4/4✓ Branch 0 taken 8118 times.
✓ Branch 1 taken 3037 times.
✓ Branch 3 taken 755 times.
✓ Branch 4 taken 7363 times.
|
11155 | if (p->filename && ff_guess_image2_codec(p->filename)) { |
152 |
2/2✓ Branch 1 taken 193 times.
✓ Branch 2 taken 562 times.
|
755 | if (av_filename_number_test(p->filename)) |
153 | 193 | return AVPROBE_SCORE_MAX; | |
154 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
|
562 | else if (p->filename[strcspn(p->filename, "*?{")]) // probably PT_GLOB |
155 | ✗ | return AVPROBE_SCORE_EXTENSION + 2; // score chosen to be a tad above the image pipes | |
156 |
2/2✓ Branch 0 taken 281 times.
✓ Branch 1 taken 281 times.
|
562 | else if (p->buf_size == 0) |
157 | 281 | return 0; | |
158 |
2/4✓ Branch 1 taken 281 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 281 times.
|
281 | else if (av_match_ext(p->filename, "raw") || av_match_ext(p->filename, "gif")) |
159 | ✗ | return 5; | |
160 | else | ||
161 | 281 | return AVPROBE_SCORE_EXTENSION; | |
162 | } | ||
163 | 10400 | return 0; | |
164 | } | ||
165 | |||
166 | 3418 | int ff_img_read_header(AVFormatContext *s1) | |
167 | { | ||
168 | 3418 | VideoDemuxData *s = s1->priv_data; | |
169 | 3418 | int first_index = 1, last_index = 1; | |
170 | AVStream *st; | ||
171 | 3418 | enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; | |
172 | |||
173 | 3418 | s1->ctx_flags |= AVFMTCTX_NOHEADER; | |
174 | |||
175 | 3418 | st = avformat_new_stream(s1, NULL); | |
176 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3418 times.
|
3418 | if (!st) { |
177 | ✗ | return AVERROR(ENOMEM); | |
178 | } | ||
179 | |||
180 |
3/4✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3409 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
3427 | if (s->pixel_format && |
181 | 9 | (pix_fmt = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) { | |
182 | ✗ | av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", | |
183 | s->pixel_format); | ||
184 | ✗ | return AVERROR(EINVAL); | |
185 | } | ||
186 | |||
187 | 3418 | av_strlcpy(s->path, s1->url, sizeof(s->path)); | |
188 | 3418 | s->img_number = 0; | |
189 | 3418 | s->img_count = 0; | |
190 | |||
191 | /* find format */ | ||
192 |
2/2✓ Branch 0 taken 3134 times.
✓ Branch 1 taken 284 times.
|
3418 | if (s1->iformat->flags & AVFMT_NOFILE) |
193 | 3134 | s->is_pipe = 0; | |
194 | else { | ||
195 | 284 | s->is_pipe = 1; | |
196 | 284 | ffstream(st)->need_parsing = AVSTREAM_PARSE_FULL; | |
197 | } | ||
198 | |||
199 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3418 times.
|
3418 | if (s->ts_from_file == 2) { |
200 | #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC | ||
201 | av_log(s1, AV_LOG_ERROR, "POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n"); | ||
202 | return AVERROR(ENOSYS); | ||
203 | #endif | ||
204 | ✗ | avpriv_set_pts_info(st, 64, 1, 1000000000); | |
205 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3418 times.
|
3418 | } else if (s->ts_from_file) |
206 | ✗ | avpriv_set_pts_info(st, 64, 1, 1); | |
207 | else { | ||
208 | 3418 | avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num); | |
209 | 3418 | st->avg_frame_rate = st->r_frame_rate = s->framerate; | |
210 | } | ||
211 | |||
212 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3418 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3418 | if (s->width && s->height) { |
213 | ✗ | st->codecpar->width = s->width; | |
214 | ✗ | st->codecpar->height = s->height; | |
215 | } | ||
216 | |||
217 |
2/2✓ Branch 0 taken 3134 times.
✓ Branch 1 taken 284 times.
|
3418 | if (!s->is_pipe) { |
218 |
1/2✓ Branch 0 taken 3134 times.
✗ Branch 1 not taken.
|
3134 | if (s->pattern_type == PT_DEFAULT) { |
219 |
2/2✓ Branch 0 taken 25 times.
✓ Branch 1 taken 3109 times.
|
3134 | if (s1->pb) { |
220 | 25 | s->pattern_type = PT_NONE; | |
221 | } else | ||
222 | 3109 | s->pattern_type = PT_SEQUENCE; | |
223 | } | ||
224 |
2/2✓ Branch 0 taken 3109 times.
✓ Branch 1 taken 25 times.
|
3134 | if (s->pattern_type == PT_SEQUENCE) { |
225 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3109 times.
|
3109 | if (find_image_range(s1->pb, &first_index, &last_index, s->path, |
226 | s->start_number, s->start_number_range) < 0) { | ||
227 | ✗ | av_log(s1, AV_LOG_ERROR, | |
228 | "Could find no file with path '%s' and index in the range %d-%d\n", | ||
229 | ✗ | s->path, s->start_number, s->start_number + s->start_number_range - 1); | |
230 | ✗ | return AVERROR(ENOENT); | |
231 | } | ||
232 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
|
25 | } else if (s->pattern_type == PT_GLOB) { |
233 | #if HAVE_GLOB | ||
234 | int gerr; | ||
235 | ✗ | gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate); | |
236 | ✗ | if (gerr != 0) { | |
237 | ✗ | return AVERROR(ENOENT); | |
238 | } | ||
239 | ✗ | first_index = 0; | |
240 | ✗ | last_index = s->globstate.gl_pathc - 1; | |
241 | ✗ | s->use_glob = 1; | |
242 | #else | ||
243 | av_log(s1, AV_LOG_ERROR, | ||
244 | "Pattern type 'glob' was selected but globbing " | ||
245 | "is not supported by this libavformat build\n"); | ||
246 | return AVERROR(ENOSYS); | ||
247 | #endif | ||
248 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
|
25 | } else if (s->pattern_type != PT_NONE) { |
249 | ✗ | av_log(s1, AV_LOG_ERROR, | |
250 | "Unknown value '%d' for pattern_type option\n", s->pattern_type); | ||
251 | ✗ | return AVERROR(EINVAL); | |
252 | } | ||
253 | 3134 | s->img_first = first_index; | |
254 | 3134 | s->img_last = last_index; | |
255 | 3134 | s->img_number = first_index; | |
256 | /* compute duration */ | ||
257 |
1/2✓ Branch 0 taken 3134 times.
✗ Branch 1 not taken.
|
3134 | if (!s->ts_from_file) { |
258 | 3134 | st->start_time = 0; | |
259 | 3134 | st->duration = last_index - first_index + 1; | |
260 | } | ||
261 | } | ||
262 | |||
263 |
2/2✓ Branch 0 taken 3037 times.
✓ Branch 1 taken 381 times.
|
3418 | if (s1->video_codec_id) { |
264 | 3037 | st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; | |
265 | 3037 | st->codecpar->codec_id = s1->video_codec_id; | |
266 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
|
381 | } else if (s1->audio_codec_id) { |
267 | ✗ | st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; | |
268 | ✗ | st->codecpar->codec_id = s1->audio_codec_id; | |
269 |
2/2✓ Branch 1 taken 270 times.
✓ Branch 2 taken 111 times.
|
381 | } else if (ffifmt(s1->iformat)->raw_codec_id) { |
270 | 270 | st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; | |
271 | 270 | st->codecpar->codec_id = ffifmt(s1->iformat)->raw_codec_id; | |
272 | } else { | ||
273 | 111 | const char *str = strrchr(s->path, '.'); | |
274 |
2/4✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
|
111 | s->split_planes = str && !av_strcasecmp(str + 1, "y"); |
275 | 111 | st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; | |
276 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 77 times.
|
111 | if (s1->pb) { |
277 | 34 | int probe_buffer_size = 2048; | |
278 | 34 | uint8_t *probe_buffer = av_realloc(NULL, probe_buffer_size + AVPROBE_PADDING_SIZE); | |
279 | 34 | const AVInputFormat *fmt = NULL; | |
280 | 34 | void *fmt_iter = NULL; | |
281 | 34 | AVProbeData pd = { 0 }; | |
282 | |||
283 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
|
34 | if (!probe_buffer) |
284 | ✗ | return AVERROR(ENOMEM); | |
285 | |||
286 | 34 | probe_buffer_size = avio_read(s1->pb, probe_buffer, probe_buffer_size); | |
287 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
|
34 | if (probe_buffer_size < 0) { |
288 | ✗ | av_free(probe_buffer); | |
289 | ✗ | return probe_buffer_size; | |
290 | } | ||
291 | 34 | memset(probe_buffer + probe_buffer_size, 0, AVPROBE_PADDING_SIZE); | |
292 | |||
293 | 34 | pd.buf = probe_buffer; | |
294 | 34 | pd.buf_size = probe_buffer_size; | |
295 | 34 | pd.filename = s1->url; | |
296 | |||
297 |
2/2✓ Branch 1 taken 11768 times.
✓ Branch 2 taken 13 times.
|
11781 | while ((fmt = av_demuxer_iterate(&fmt_iter))) { |
298 | 11768 | const FFInputFormat *fmt2 = ffifmt(fmt); | |
299 |
2/2✓ Branch 0 taken 933 times.
✓ Branch 1 taken 10835 times.
|
11768 | if (fmt2->read_header != ff_img_read_header || |
300 |
2/2✓ Branch 0 taken 899 times.
✓ Branch 1 taken 34 times.
|
933 | !fmt2->read_probe || |
301 |
2/2✓ Branch 0 taken 865 times.
✓ Branch 1 taken 34 times.
|
899 | (fmt->flags & AVFMT_NOFILE) || |
302 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
|
865 | !fmt2->raw_codec_id) |
303 | 10903 | continue; | |
304 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 2 taken 844 times.
|
865 | if (fmt2->read_probe(&pd) > 0) { |
305 | 21 | st->codecpar->codec_id = fmt2->raw_codec_id; | |
306 | 21 | break; | |
307 | } | ||
308 | } | ||
309 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
|
34 | if (s1->flags & AVFMT_FLAG_CUSTOM_IO) { |
310 | ✗ | avio_seek(s1->pb, 0, SEEK_SET); | |
311 | ✗ | av_freep(&probe_buffer); | |
312 | } else | ||
313 | 34 | ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size); | |
314 | } | ||
315 |
2/2✓ Branch 0 taken 90 times.
✓ Branch 1 taken 21 times.
|
111 | if (st->codecpar->codec_id == AV_CODEC_ID_NONE) |
316 | 90 | st->codecpar->codec_id = ff_guess_image2_codec(s->path); | |
317 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
|
111 | if (st->codecpar->codec_id == AV_CODEC_ID_LJPEG) |
318 | ✗ | st->codecpar->codec_id = AV_CODEC_ID_MJPEG; | |
319 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
|
111 | if (st->codecpar->codec_id == AV_CODEC_ID_ALIAS_PIX) // we cannot distinguish this from BRENDER_PIX |
320 | ✗ | st->codecpar->codec_id = AV_CODEC_ID_NONE; | |
321 | } | ||
322 |
3/4✓ Branch 0 taken 3418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 3409 times.
|
3418 | if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && |
323 | pix_fmt != AV_PIX_FMT_NONE) | ||
324 | 9 | st->codecpar->format = pix_fmt; | |
325 | |||
326 | 3418 | return 0; | |
327 | } | ||
328 | |||
329 | /** | ||
330 | * Add this frame's source path and basename to packet's sidedata | ||
331 | * as a dictionary, so it can be used by filters like 'drawtext'. | ||
332 | */ | ||
333 | ✗ | static int add_filename_as_pkt_side_data(char *filename, AVPacket *pkt) { | |
334 | ✗ | AVDictionary *d = NULL; | |
335 | ✗ | char *packed_metadata = NULL; | |
336 | size_t metadata_len; | ||
337 | int ret; | ||
338 | |||
339 | ✗ | av_dict_set(&d, "lavf.image2dec.source_path", filename, 0); | |
340 | ✗ | av_dict_set(&d, "lavf.image2dec.source_basename", av_basename(filename), 0); | |
341 | |||
342 | ✗ | packed_metadata = av_packet_pack_dictionary(d, &metadata_len); | |
343 | ✗ | av_dict_free(&d); | |
344 | ✗ | if (!packed_metadata) | |
345 | ✗ | return AVERROR(ENOMEM); | |
346 | ✗ | ret = av_packet_add_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, | |
347 | packed_metadata, metadata_len); | ||
348 | ✗ | if (ret < 0) { | |
349 | ✗ | av_freep(&packed_metadata); | |
350 | ✗ | return ret; | |
351 | } | ||
352 | ✗ | return 0; | |
353 | } | ||
354 | |||
355 | 117445 | int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) | |
356 | { | ||
357 | 117445 | VideoDemuxData *s = s1->priv_data; | |
358 | char filename_bytes[1024]; | ||
359 | 117445 | char *filename = filename_bytes; | |
360 | int i, res; | ||
361 | 117445 | int size[3] = { 0 }, ret[3] = { 0 }; | |
362 | 117445 | AVIOContext *f[3] = { NULL }; | |
363 | 117445 | AVCodecParameters *par = s1->streams[0]->codecpar; | |
364 | |||
365 |
2/2✓ Branch 0 taken 102936 times.
✓ Branch 1 taken 14509 times.
|
117445 | if (!s->is_pipe) { |
366 | /* loop over input */ | ||
367 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 102936 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
102936 | if (s->loop && s->img_number > s->img_last) { |
368 | ✗ | s->img_number = s->img_first; | |
369 | } | ||
370 |
2/2✓ Branch 0 taken 229 times.
✓ Branch 1 taken 102707 times.
|
102936 | if (s->img_number > s->img_last) |
371 | 229 | return AVERROR_EOF; | |
372 |
2/2✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102682 times.
|
102707 | if (s->pattern_type == PT_NONE) { |
373 | 25 | av_strlcpy(filename_bytes, s->path, sizeof(filename_bytes)); | |
374 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 102682 times.
|
102682 | } else if (s->use_glob) { |
375 | #if HAVE_GLOB | ||
376 | ✗ | filename = s->globstate.gl_pathv[s->img_number]; | |
377 | #endif | ||
378 | } else { | ||
379 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 102678 times.
|
102682 | if (av_get_frame_filename(filename_bytes, sizeof(filename_bytes), |
380 | 102682 | s->path, | |
381 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | s->img_number) < 0 && s->img_number > 1) |
382 | ✗ | return AVERROR(EIO); | |
383 | } | ||
384 |
1/2✓ Branch 0 taken 102707 times.
✗ Branch 1 not taken.
|
102707 | for (i = 0; i < 3; i++) { |
385 |
2/2✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102682 times.
|
102707 | if (s1->pb && |
386 |
1/2✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
|
25 | !strcmp(filename_bytes, s->path) && |
387 |
1/2✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
|
25 | !s->loop && |
388 |
1/2✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
|
25 | !s->split_planes) { |
389 | 25 | f[i] = s1->pb; | |
390 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 102682 times.
|
102682 | } else if (s1->io_open(s1, &f[i], filename, AVIO_FLAG_READ, NULL) < 0) { |
391 | ✗ | if (i >= 1) | |
392 | ✗ | break; | |
393 | ✗ | av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n", | |
394 | filename); | ||
395 | ✗ | return AVERROR(EIO); | |
396 | } | ||
397 | 102707 | size[i] = avio_size(f[i]); | |
398 | |||
399 |
1/2✓ Branch 0 taken 102707 times.
✗ Branch 1 not taken.
|
102707 | if (!s->split_planes) |
400 | 102707 | break; | |
401 | ✗ | filename[strlen(filename) - 1] = 'U' + i; | |
402 | } | ||
403 | |||
404 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 102707 times.
|
102707 | if (par->codec_id == AV_CODEC_ID_NONE) { |
405 | ✗ | AVProbeData pd = { 0 }; | |
406 | const FFInputFormat *ifmt; | ||
407 | uint8_t header[PROBE_BUF_MIN + AVPROBE_PADDING_SIZE]; | ||
408 | int ret; | ||
409 | ✗ | int score = 0; | |
410 | |||
411 | ✗ | ret = avio_read(f[0], header, PROBE_BUF_MIN); | |
412 | ✗ | if (ret < 0) | |
413 | ✗ | return ret; | |
414 | ✗ | memset(header + ret, 0, sizeof(header) - ret); | |
415 | ✗ | avio_skip(f[0], -ret); | |
416 | ✗ | pd.buf = header; | |
417 | ✗ | pd.buf_size = ret; | |
418 | ✗ | pd.filename = filename; | |
419 | |||
420 | ✗ | ifmt = ffifmt(av_probe_input_format3(&pd, 1, &score)); | |
421 | ✗ | if (ifmt && ifmt->read_packet == ff_img_read_packet && ifmt->raw_codec_id) | |
422 | ✗ | par->codec_id = ifmt->raw_codec_id; | |
423 | } | ||
424 | |||
425 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 102707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
102707 | if (par->codec_id == AV_CODEC_ID_RAWVIDEO && !par->width) |
426 | ✗ | infer_size(&par->width, &par->height, size[0]); | |
427 | } else { | ||
428 | 14509 | f[0] = s1->pb; | |
429 |
3/6✓ Branch 1 taken 417 times.
✓ Branch 2 taken 14092 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 417 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
14509 | if (avio_feof(f[0]) && s->loop && s->is_pipe) |
430 | ✗ | avio_seek(f[0], 0, SEEK_SET); | |
431 |
2/2✓ Branch 1 taken 417 times.
✓ Branch 2 taken 14092 times.
|
14509 | if (avio_feof(f[0])) |
432 | 417 | return AVERROR_EOF; | |
433 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14092 times.
|
14092 | if (s->frame_size > 0) { |
434 | ✗ | size[0] = s->frame_size; | |
435 |
2/2✓ Branch 1 taken 375 times.
✓ Branch 2 taken 13717 times.
|
14092 | } else if (!ffstream(s1->streams[0])->parser) { |
436 | 375 | size[0] = avio_size(s1->pb); | |
437 | } else { | ||
438 | 13717 | size[0] = 4096; | |
439 | } | ||
440 | } | ||
441 | |||
442 | 116799 | res = av_new_packet(pkt, size[0] + size[1] + size[2]); | |
443 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 116799 times.
|
116799 | if (res < 0) { |
444 | ✗ | goto fail; | |
445 | } | ||
446 | 116799 | pkt->stream_index = 0; | |
447 | 116799 | pkt->flags |= AV_PKT_FLAG_KEY; | |
448 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 116799 times.
|
116799 | if (s->ts_from_file) { |
449 | struct stat img_stat; | ||
450 | ✗ | av_assert0(!s->is_pipe); // The ts_from_file option is not supported by piped input demuxers | |
451 | ✗ | if (stat(filename, &img_stat)) { | |
452 | ✗ | res = AVERROR(EIO); | |
453 | ✗ | goto fail; | |
454 | } | ||
455 | ✗ | pkt->pts = (int64_t)img_stat.st_mtime; | |
456 | #if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC | ||
457 | ✗ | if (s->ts_from_file == 2) | |
458 | ✗ | pkt->pts = 1000000000*pkt->pts + img_stat.st_mtim.tv_nsec; | |
459 | #endif | ||
460 | ✗ | av_add_index_entry(s1->streams[0], s->img_number, pkt->pts, 0, 0, AVINDEX_KEYFRAME); | |
461 |
2/2✓ Branch 0 taken 102707 times.
✓ Branch 1 taken 14092 times.
|
116799 | } else if (!s->is_pipe) { |
462 | 102707 | pkt->pts = s->pts; | |
463 | } | ||
464 | |||
465 |
2/2✓ Branch 0 taken 14092 times.
✓ Branch 1 taken 102707 times.
|
116799 | if (s->is_pipe) |
466 | 14092 | pkt->pos = avio_tell(f[0]); | |
467 | |||
468 | /* | ||
469 | * export_path_metadata must be explicitly enabled via | ||
470 | * command line options for path metadata to be exported | ||
471 | * as packet side_data. | ||
472 | */ | ||
473 |
3/4✓ Branch 0 taken 102707 times.
✓ Branch 1 taken 14092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102707 times.
|
116799 | if (!s->is_pipe && s->export_path_metadata == 1) { |
474 | ✗ | res = add_filename_as_pkt_side_data(filename, pkt); | |
475 | ✗ | if (res < 0) | |
476 | ✗ | goto fail; | |
477 | } | ||
478 | |||
479 | 116799 | pkt->size = 0; | |
480 |
2/2✓ Branch 0 taken 350397 times.
✓ Branch 1 taken 116799 times.
|
467196 | for (i = 0; i < 3; i++) { |
481 |
2/2✓ Branch 0 taken 116799 times.
✓ Branch 1 taken 233598 times.
|
350397 | if (f[i]) { |
482 | 116799 | ret[i] = avio_read(f[i], pkt->data + pkt->size, size[i]); | |
483 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 116799 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
116799 | if (s->loop && s->is_pipe && ret[i] == AVERROR_EOF) { |
484 | ✗ | if (avio_seek(f[i], 0, SEEK_SET) >= 0) { | |
485 | ✗ | pkt->pos = 0; | |
486 | ✗ | ret[i] = avio_read(f[i], pkt->data + pkt->size, size[i]); | |
487 | } | ||
488 | } | ||
489 |
4/4✓ Branch 0 taken 102707 times.
✓ Branch 1 taken 14092 times.
✓ Branch 2 taken 102682 times.
✓ Branch 3 taken 25 times.
|
116799 | if (!s->is_pipe && f[i] != s1->pb) |
490 | 102682 | ff_format_io_close(s1, &f[i]); | |
491 |
2/2✓ Branch 0 taken 116616 times.
✓ Branch 1 taken 183 times.
|
116799 | if (ret[i] > 0) |
492 | 116616 | pkt->size += ret[i]; | |
493 | } | ||
494 | } | ||
495 | |||
496 |
4/6✓ Branch 0 taken 116616 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 116616 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 116616 times.
|
116799 | if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) { |
497 |
1/2✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
|
183 | if (ret[0] < 0) { |
498 | 183 | res = ret[0]; | |
499 | ✗ | } else if (ret[1] < 0) { | |
500 | ✗ | res = ret[1]; | |
501 | ✗ | } else if (ret[2] < 0) { | |
502 | ✗ | res = ret[2]; | |
503 | } else { | ||
504 | ✗ | res = AVERROR_EOF; | |
505 | } | ||
506 | 183 | goto fail; | |
507 | } else { | ||
508 | 116616 | memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE); | |
509 | 116616 | s->img_count++; | |
510 | 116616 | s->img_number++; | |
511 | 116616 | s->pts++; | |
512 | 116616 | return 0; | |
513 | } | ||
514 | |||
515 | 183 | fail: | |
516 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 183 times.
|
183 | if (!s->is_pipe) { |
517 | ✗ | for (i = 0; i < 3; i++) { | |
518 | ✗ | if (f[i] != s1->pb) | |
519 | ✗ | ff_format_io_close(s1, &f[i]); | |
520 | } | ||
521 | } | ||
522 | 183 | return res; | |
523 | } | ||
524 | |||
525 | 3134 | static int img_read_close(struct AVFormatContext* s1) | |
526 | { | ||
527 | #if HAVE_GLOB | ||
528 | 3134 | VideoDemuxData *s = s1->priv_data; | |
529 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3134 times.
|
3134 | if (s->use_glob) { |
530 | ✗ | globfree(&s->globstate); | |
531 | } | ||
532 | #endif | ||
533 | 3134 | return 0; | |
534 | } | ||
535 | |||
536 | 208 | static int img_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) | |
537 | { | ||
538 | 208 | VideoDemuxData *s1 = s->priv_data; | |
539 | 208 | AVStream *st = s->streams[0]; | |
540 | |||
541 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
|
208 | if (s1->ts_from_file) { |
542 | ✗ | int index = av_index_search_timestamp(st, timestamp, flags); | |
543 | ✗ | if(index < 0) | |
544 | ✗ | return -1; | |
545 | ✗ | s1->img_number = ffstream(st)->index_entries[index].pos; | |
546 | ✗ | return 0; | |
547 | } | ||
548 | |||
549 |
5/6✓ Branch 0 taken 144 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 144 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✓ Branch 5 taken 24 times.
|
208 | if (timestamp < 0 || !s1->loop && timestamp > s1->img_last - s1->img_first) |
550 | 184 | return -1; | |
551 | 24 | s1->img_number = timestamp%(s1->img_last - s1->img_first + 1) + s1->img_first; | |
552 | 24 | s1->pts = timestamp; | |
553 | 24 | return 0; | |
554 | } | ||
555 | |||
556 | #define OFFSET(x) offsetof(VideoDemuxData, x) | ||
557 | #define DEC AV_OPT_FLAG_DECODING_PARAM | ||
558 | #define COMMON_OPTIONS \ | ||
559 | { "framerate", "set the video framerate", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC }, \ | ||
560 | { "pixel_format", "set video pixel format", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, \ | ||
561 | { "video_size", "set video size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, DEC }, \ | ||
562 | { "loop", "force loop over input file sequence", OFFSET(loop), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, DEC }, \ | ||
563 | { NULL }, | ||
564 | |||
565 | #if CONFIG_IMAGE2_DEMUXER | ||
566 | const AVOption ff_img_options[] = { | ||
567 | { "pattern_type", "set pattern type", OFFSET(pattern_type), AV_OPT_TYPE_INT, {.i64=PT_DEFAULT}, 0, INT_MAX, DEC, .unit = "pattern_type"}, | ||
568 | { "glob", "select glob pattern type", 0, AV_OPT_TYPE_CONST, {.i64=PT_GLOB }, INT_MIN, INT_MAX, DEC, .unit = "pattern_type" }, | ||
569 | { "sequence", "select sequence pattern type", 0, AV_OPT_TYPE_CONST, {.i64=PT_SEQUENCE }, INT_MIN, INT_MAX, DEC, .unit = "pattern_type" }, | ||
570 | { "none", "disable pattern matching", 0, AV_OPT_TYPE_CONST, {.i64=PT_NONE }, INT_MIN, INT_MAX, DEC, .unit = "pattern_type" }, | ||
571 | { "start_number", "set first number in the sequence", OFFSET(start_number), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, DEC }, | ||
572 | { "start_number_range", "set range for looking at the first sequence number", OFFSET(start_number_range), AV_OPT_TYPE_INT, {.i64 = 5}, 1, INT_MAX, DEC }, | ||
573 | { "ts_from_file", "set frame timestamp from file's one", OFFSET(ts_from_file), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, DEC, .unit = "ts_type" }, | ||
574 | { "none", "none", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 2, DEC, .unit = "ts_type" }, | ||
575 | { "sec", "second precision", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 2, DEC, .unit = "ts_type" }, | ||
576 | { "ns", "nano second precision", 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 2, DEC, .unit = "ts_type" }, | ||
577 | { "export_path_metadata", "enable metadata containing input path information", OFFSET(export_path_metadata), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, DEC }, \ | ||
578 | COMMON_OPTIONS | ||
579 | }; | ||
580 | |||
581 | static const AVClass img2_class = { | ||
582 | .class_name = "image2 demuxer", | ||
583 | .item_name = av_default_item_name, | ||
584 | .option = ff_img_options, | ||
585 | .version = LIBAVUTIL_VERSION_INT, | ||
586 | }; | ||
587 | const FFInputFormat ff_image2_demuxer = { | ||
588 | .p.name = "image2", | ||
589 | .p.long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), | ||
590 | .p.flags = AVFMT_NOFILE, | ||
591 | .p.priv_class = &img2_class, | ||
592 | .priv_data_size = sizeof(VideoDemuxData), | ||
593 | .read_probe = img_read_probe, | ||
594 | .read_header = ff_img_read_header, | ||
595 | .read_packet = ff_img_read_packet, | ||
596 | .read_close = img_read_close, | ||
597 | .read_seek = img_read_seek, | ||
598 | }; | ||
599 | #endif | ||
600 | |||
601 | static const AVOption img2pipe_options[] = { | ||
602 | { "frame_size", "force frame size in bytes", OFFSET(frame_size), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, DEC }, | ||
603 | COMMON_OPTIONS | ||
604 | }; | ||
605 | static const AVClass imagepipe_class = { | ||
606 | .class_name = "imagepipe demuxer", | ||
607 | .item_name = av_default_item_name, | ||
608 | .option = img2pipe_options, | ||
609 | .version = LIBAVUTIL_VERSION_INT, | ||
610 | }; | ||
611 | |||
612 | #if CONFIG_IMAGE2PIPE_DEMUXER | ||
613 | const FFInputFormat ff_image2pipe_demuxer = { | ||
614 | .p.name = "image2pipe", | ||
615 | .p.long_name = NULL_IF_CONFIG_SMALL("piped image2 sequence"), | ||
616 | .p.priv_class = &imagepipe_class, | ||
617 | .priv_data_size = sizeof(VideoDemuxData), | ||
618 | .read_header = ff_img_read_header, | ||
619 | .read_packet = ff_img_read_packet, | ||
620 | }; | ||
621 | #endif | ||
622 | |||
623 | 7294 | static int bmp_probe(const AVProbeData *p) | |
624 | { | ||
625 | 7294 | const uint8_t *b = p->buf; | |
626 | int ihsize; | ||
627 | |||
628 |
2/2✓ Branch 0 taken 7279 times.
✓ Branch 1 taken 15 times.
|
7294 | if (AV_RB16(b) != 0x424d) |
629 | 7279 | return 0; | |
630 | |||
631 | 15 | ihsize = AV_RL32(b+14); | |
632 |
2/4✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
|
15 | if (ihsize < 12 || ihsize > 255) |
633 | ✗ | return 0; | |
634 | |||
635 |
1/2✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
|
15 | if (!AV_RN32(b + 6)) { |
636 | 15 | return AVPROBE_SCORE_EXTENSION + 1; | |
637 | } | ||
638 | ✗ | return AVPROBE_SCORE_EXTENSION / 4; | |
639 | } | ||
640 | |||
641 | 7293 | static int cri_probe(const AVProbeData *p) | |
642 | { | ||
643 | 7293 | const uint8_t *b = p->buf; | |
644 | |||
645 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 7283 times.
|
7293 | if ( AV_RL32(b) == 1 |
646 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
|
10 | && AV_RL32(b + 4) == 4 |
647 | ✗ | && AV_RN32(b + 8) == AV_RN32("DVCC")) | |
648 | ✗ | return AVPROBE_SCORE_MAX - 1; | |
649 | 7293 | return 0; | |
650 | } | ||
651 | |||
652 | 7293 | static int dds_probe(const AVProbeData *p) | |
653 | { | ||
654 | 7293 | const uint8_t *b = p->buf; | |
655 | |||
656 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 7245 times.
|
7293 | if ( AV_RB64(b) == 0x444453207c000000 |
657 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | && AV_RL32(b + 8) |
658 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | && AV_RL32(b + 12)) |
659 | 48 | return AVPROBE_SCORE_MAX - 1; | |
660 | 7245 | return 0; | |
661 | } | ||
662 | |||
663 | 7293 | static int dpx_probe(const AVProbeData *p) | |
664 | { | ||
665 | 7293 | const uint8_t *b = p->buf; | |
666 | int w, h; | ||
667 | 7293 | int is_big = (AV_RN32(b) == AV_RN32("SDPX")); | |
668 | |||
669 |
2/2✓ Branch 0 taken 106 times.
✓ Branch 1 taken 7187 times.
|
7293 | if (p->buf_size < 0x304+8) |
670 | 106 | return 0; | |
671 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7186 times.
|
7187 | w = is_big ? AV_RB32(p->buf + 0x304) : AV_RL32(p->buf + 0x304); |
672 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7186 times.
|
7187 | h = is_big ? AV_RB32(p->buf + 0x308) : AV_RL32(p->buf + 0x308); |
673 |
4/4✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 3812 times.
✓ Branch 2 taken 720 times.
✓ Branch 3 taken 2655 times.
|
7187 | if (w <= 0 || h <= 0) |
674 | 4532 | return 0; | |
675 | |||
676 |
4/4✓ Branch 0 taken 2654 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2652 times.
|
2655 | if (is_big || AV_RN32(b) == AV_RN32("XPDS")) |
677 | 3 | return AVPROBE_SCORE_EXTENSION + 1; | |
678 | 2652 | return 0; | |
679 | } | ||
680 | |||
681 | 7292 | static int exr_probe(const AVProbeData *p) | |
682 | { | ||
683 | 7292 | const uint8_t *b = p->buf; | |
684 | |||
685 |
2/2✓ Branch 0 taken 74 times.
✓ Branch 1 taken 7218 times.
|
7292 | if (AV_RL32(b) == 20000630) |
686 | 74 | return AVPROBE_SCORE_EXTENSION + 1; | |
687 | 7218 | return 0; | |
688 | } | ||
689 | |||
690 | 7292 | static int j2k_probe(const AVProbeData *p) | |
691 | { | ||
692 | 7292 | const uint8_t *b = p->buf; | |
693 | |||
694 |
1/2✓ Branch 0 taken 7292 times.
✗ Branch 1 not taken.
|
7292 | if (AV_RB64(b) == 0x0000000c6a502020 || |
695 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 7277 times.
|
7292 | AV_RB32(b) == 0xff4fff51) |
696 | 15 | return AVPROBE_SCORE_EXTENSION + 1; | |
697 | 7277 | return 0; | |
698 | } | ||
699 | |||
700 | 7292 | static int jpeg_probe(const AVProbeData *p) | |
701 | { | ||
702 | 7292 | const uint8_t *b = p->buf; | |
703 | 7292 | int i, state = SOI, got_header = 0; | |
704 | |||
705 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 7262 times.
|
7292 | if (AV_RB16(b) != 0xFFD8 || |
706 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26 times.
|
30 | AV_RB32(b) == 0xFFD8FFF7) |
707 | 7266 | return 0; | |
708 | |||
709 | 26 | b += 2; | |
710 |
2/2✓ Branch 0 taken 27795 times.
✓ Branch 1 taken 26 times.
|
27821 | for (i = 0; i < p->buf_size - 3; i++) { |
711 | int c; | ||
712 |
2/2✓ Branch 0 taken 27452 times.
✓ Branch 1 taken 343 times.
|
27795 | if (b[i] != 0xFF) |
713 | 27452 | continue; | |
714 | 343 | c = b[i + 1]; | |
715 |
7/8✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 41 times.
✓ Branch 7 taken 148 times.
|
343 | switch (c) { |
716 | ✗ | case SOI: | |
717 | ✗ | return 0; | |
718 | 19 | case SOF0: | |
719 | case SOF1: | ||
720 | case SOF2: | ||
721 | case SOF3: | ||
722 | case SOF5: | ||
723 | case SOF6: | ||
724 | case SOF7: | ||
725 | 19 | i += AV_RB16(&b[i + 2]) + 1; | |
726 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
|
19 | if (state != SOI) |
727 | ✗ | return 0; | |
728 | 19 | state = SOF0; | |
729 | 19 | break; | |
730 | 114 | case SOS: | |
731 | 114 | i += AV_RB16(&b[i + 2]) + 1; | |
732 |
3/4✓ Branch 0 taken 95 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 95 times.
|
114 | if (state != SOF0 && state != SOS) |
733 | ✗ | return 0; | |
734 | 114 | state = SOS; | |
735 | 114 | break; | |
736 | 1 | case EOI: | |
737 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (state != SOS) |
738 | ✗ | return 0; | |
739 | 1 | state = EOI; | |
740 | 1 | break; | |
741 | 18 | case APP0: | |
742 |
3/4✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 2 times.
|
18 | if (c == APP0 && AV_RL32(&b[i + 4]) == MKTAG('J','F','I','F')) |
743 | 16 | got_header = 1; | |
744 | /* fallthrough */ | ||
745 | case APP1: | ||
746 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
20 | if (c == APP1 && AV_RL32(&b[i + 4]) == MKTAG('E','x','i','f')) |
747 | 2 | got_header = 1; | |
748 | /* fallthrough */ | ||
749 | case APP2: | ||
750 | case APP3: | ||
751 | case APP4: | ||
752 | case APP5: | ||
753 | case APP6: | ||
754 | case APP7: | ||
755 | case APP8: | ||
756 | case APP9: | ||
757 | case APP10: | ||
758 | case APP11: | ||
759 | case APP12: | ||
760 | case APP13: | ||
761 | case APP14: | ||
762 | case APP15: | ||
763 | case DQT: /* fallthrough */ | ||
764 | case COM: | ||
765 | 61 | i += AV_RB16(&b[i + 2]) + 1; | |
766 | 61 | break; | |
767 | 148 | default: | |
768 |
3/4✓ Branch 0 taken 98 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
|
148 | if ( (c > TEM && c < SOF0) |
769 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
|
148 | || c == JPG) |
770 | ✗ | return 0; | |
771 | } | ||
772 | } | ||
773 | |||
774 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
|
26 | if (state == EOI) |
775 | 1 | return AVPROBE_SCORE_EXTENSION + 1; | |
776 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 7 times.
|
25 | if (state == SOS) |
777 | 18 | return AVPROBE_SCORE_EXTENSION / 2 + got_header; | |
778 | 7 | return AVPROBE_SCORE_EXTENSION / 8 + 1; | |
779 | } | ||
780 | |||
781 | 7282 | static int jpegls_probe(const AVProbeData *p) | |
782 | { | ||
783 | 7282 | const uint8_t *b = p->buf; | |
784 | |||
785 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 7278 times.
|
7282 | if (AV_RB32(b) == 0xffd8fff7) |
786 | 4 | return AVPROBE_SCORE_EXTENSION + 1; | |
787 | 7278 | return 0; | |
788 | } | ||
789 | |||
790 | 7282 | static int jpegxl_probe(const AVProbeData *p) | |
791 | { | ||
792 | 7282 | const uint8_t *b = p->buf; | |
793 | |||
794 | /* ISOBMFF-based container */ | ||
795 | /* 0x4a584c20 == "JXL " */ | ||
796 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7279 times.
|
7282 | if (AV_RL64(b) == FF_JPEGXL_CONTAINER_SIGNATURE_LE) |
797 | 3 | return AVPROBE_SCORE_EXTENSION + 1; | |
798 | /* Raw codestreams all start with 0xff0a */ | ||
799 |
2/2✓ Branch 0 taken 7276 times.
✓ Branch 1 taken 3 times.
|
7279 | if (AV_RL16(b) != FF_JPEGXL_CODESTREAM_SIGNATURE_LE) |
800 | 7276 | return 0; | |
801 | #if CONFIG_IMAGE_JPEGXL_PIPE_DEMUXER | ||
802 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | if (ff_jpegxl_parse_codestream_header(p->buf, p->buf_size, NULL, 5) >= 0) |
803 | 3 | return AVPROBE_SCORE_MAX - 2; | |
804 | #endif | ||
805 | ✗ | return 0; | |
806 | } | ||
807 | |||
808 | 7281 | static int pcx_probe(const AVProbeData *p) | |
809 | { | ||
810 | 7281 | const uint8_t *b = p->buf; | |
811 | |||
812 |
2/2✓ Branch 0 taken 7275 times.
✓ Branch 1 taken 6 times.
|
7281 | if ( p->buf_size < 128 |
813 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7275 times.
|
7275 | || b[0] != 10 |
814 | ✗ | || b[1] > 5 | |
815 | ✗ | || b[2] > 1 | |
816 | ✗ | || av_popcount(b[3]) != 1 || b[3] > 8 | |
817 | ✗ | || AV_RL16(&b[4]) > AV_RL16(&b[8]) | |
818 | ✗ | || AV_RL16(&b[6]) > AV_RL16(&b[10]) | |
819 | ✗ | || b[64]) | |
820 | 7281 | return 0; | |
821 | ✗ | b += 73; | |
822 | ✗ | while (++b < p->buf + 128) | |
823 | ✗ | if (*b) | |
824 | ✗ | return AVPROBE_SCORE_EXTENSION / 4; | |
825 | |||
826 | ✗ | return AVPROBE_SCORE_EXTENSION + 1; | |
827 | } | ||
828 | |||
829 | 7277 | static int qdraw_probe(const AVProbeData *p) | |
830 | { | ||
831 | 7277 | const uint8_t *b = p->buf; | |
832 | |||
833 |
2/2✓ Branch 0 taken 7184 times.
✓ Branch 1 taken 93 times.
|
7277 | if ( p->buf_size >= 528 |
834 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7184 times.
|
7184 | && (AV_RB64(b + 520) & 0xFFFFFFFFFFFF) == 0x001102ff0c00 |
835 | ✗ | && AV_RB16(b + 520) | |
836 | ✗ | && AV_RB16(b + 518)) | |
837 | ✗ | return AVPROBE_SCORE_MAX * 3 / 4; | |
838 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7275 times.
|
7277 | if ( (AV_RB64(b + 8) & 0xFFFFFFFFFFFF) == 0x001102ff0c00 |
839 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | && AV_RB16(b + 8) |
840 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | && AV_RB16(b + 6)) |
841 | 2 | return AVPROBE_SCORE_EXTENSION / 4; | |
842 | 7275 | return 0; | |
843 | } | ||
844 | |||
845 | 7280 | static int pictor_probe(const AVProbeData *p) | |
846 | { | ||
847 | 7280 | const uint8_t *b = p->buf; | |
848 | |||
849 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7278 times.
|
7280 | if (AV_RL16(b) == 0x1234) |
850 | 2 | return AVPROBE_SCORE_EXTENSION / 4; | |
851 | 7278 | return 0; | |
852 | } | ||
853 | |||
854 | 7279 | static int png_probe(const AVProbeData *p) | |
855 | { | ||
856 | 7279 | const uint8_t *b = p->buf; | |
857 | |||
858 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 7231 times.
|
7279 | if (AV_RB64(b) == 0x89504e470d0a1a0a) |
859 | 48 | return AVPROBE_SCORE_MAX - 1; | |
860 | 7231 | return 0; | |
861 | } | ||
862 | |||
863 | 7277 | static int psd_probe(const AVProbeData *p) | |
864 | { | ||
865 | 7277 | const uint8_t *b = p->buf; | |
866 | 7277 | int ret = 0; | |
867 | uint16_t color_mode; | ||
868 | |||
869 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 7262 times.
|
7277 | if (AV_RL32(b) == MKTAG('8','B','P','S')) { |
870 | 15 | ret += 1; | |
871 | } else { | ||
872 | 7262 | return 0; | |
873 | } | ||
874 | |||
875 |
2/4✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
|
15 | if ((b[4] == 0) && (b[5] == 1)) {/* version 1 is PSD, version 2 is PSB */ |
876 | 15 | ret += 1; | |
877 | } else { | ||
878 | ✗ | return 0; | |
879 | } | ||
880 | |||
881 |
2/4✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
|
15 | if ((AV_RL32(b+6) == 0) && (AV_RL16(b+10) == 0))/* reserved must be 0 */ |
882 | 15 | ret += 1; | |
883 | |||
884 | 15 | color_mode = AV_RB16(b+24); | |
885 |
3/6✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
|
15 | if ((color_mode <= 9) && (color_mode != 5) && (color_mode != 6)) |
886 | 15 | ret += 1; | |
887 | |||
888 | 15 | return AVPROBE_SCORE_EXTENSION + ret; | |
889 | } | ||
890 | |||
891 | 7275 | static int sgi_probe(const AVProbeData *p) | |
892 | { | ||
893 | 7275 | const uint8_t *b = p->buf; | |
894 | |||
895 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7263 times.
|
7275 | if (AV_RB16(b) == 474 && |
896 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | (b[2] & ~1) == 0 && |
897 |
2/4✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
|
12 | (b[3] & ~3) == 0 && b[3] && |
898 |
2/4✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
|
12 | (AV_RB16(b + 4) & ~7) == 0 && AV_RB16(b + 4)) |
899 | 12 | return AVPROBE_SCORE_EXTENSION + 1; | |
900 | 7263 | return 0; | |
901 | } | ||
902 | |||
903 | 7275 | static int sunrast_probe(const AVProbeData *p) | |
904 | { | ||
905 | 7275 | const uint8_t *b = p->buf; | |
906 | |||
907 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7268 times.
|
7275 | if (AV_RB32(b) == 0x59a66a95) |
908 | 7 | return AVPROBE_SCORE_EXTENSION + 1; | |
909 | 7268 | return 0; | |
910 | } | ||
911 | |||
912 | 7275 | static int svg_probe(const AVProbeData *p) | |
913 | { | ||
914 | 7275 | const uint8_t *b = p->buf; | |
915 | 7275 | const uint8_t *end = p->buf + p->buf_size; | |
916 |
3/4✓ Branch 0 taken 7353 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
✓ Branch 3 taken 7275 times.
|
7353 | while (b < end && av_isspace(*b)) |
917 | 78 | b++; | |
918 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7275 times.
|
7275 | if (b >= end - 5) |
919 | ✗ | return 0; | |
920 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7275 times.
|
7275 | if (!memcmp(b, "<svg", 4)) |
921 | ✗ | return AVPROBE_SCORE_EXTENSION + 1; | |
922 |
2/4✓ Branch 0 taken 7275 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7275 times.
✗ Branch 3 not taken.
|
7275 | if (memcmp(p->buf, "<?xml", 5) && memcmp(b, "<!--", 4)) |
923 | 7275 | return 0; | |
924 | ✗ | while (b < end) { | |
925 | ✗ | int inc = ff_subtitles_next_line(b); | |
926 | ✗ | if (!inc) | |
927 | ✗ | break; | |
928 | ✗ | b += inc; | |
929 | ✗ | if (b >= end - 4) | |
930 | ✗ | return 0; | |
931 | ✗ | if (!memcmp(b, "<svg", 4)) | |
932 | ✗ | return AVPROBE_SCORE_EXTENSION + 1; | |
933 | } | ||
934 | ✗ | return 0; | |
935 | } | ||
936 | |||
937 | 7275 | static int tiff_probe(const AVProbeData *p) | |
938 | { | ||
939 | 7275 | const uint8_t *b = p->buf; | |
940 | |||
941 |
2/2✓ Branch 0 taken 7268 times.
✓ Branch 1 taken 7 times.
|
7275 | if (AV_RB32(b) == 0x49492a00 || |
942 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7266 times.
|
7268 | AV_RB32(b) == 0x4D4D002a) |
943 | 9 | return AVPROBE_SCORE_EXTENSION + 1; | |
944 | 7266 | return 0; | |
945 | } | ||
946 | |||
947 | 7275 | static int webp_probe(const AVProbeData *p) | |
948 | { | ||
949 | 7275 | const uint8_t *b = p->buf; | |
950 | |||
951 |
2/2✓ Branch 0 taken 974 times.
✓ Branch 1 taken 6301 times.
|
7275 | if (AV_RB32(b) == 0x52494646 && |
952 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 966 times.
|
974 | AV_RB32(b + 8) == 0x57454250) |
953 | 8 | return AVPROBE_SCORE_MAX - 1; | |
954 | 7267 | return 0; | |
955 | } | ||
956 | |||
957 | 94648 | static int pnm_magic_check(const AVProbeData *p, int magic) | |
958 | { | ||
959 | 94648 | const uint8_t *b = p->buf; | |
960 | |||
961 |
4/4✓ Branch 0 taken 246 times.
✓ Branch 1 taken 94402 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 237 times.
|
94648 | return b[0] == 'P' && b[1] == magic + '0'; |
962 | } | ||
963 | |||
964 | 9 | static inline int pnm_probe(const AVProbeData *p) | |
965 | { | ||
966 | 9 | const uint8_t *b = p->buf; | |
967 | |||
968 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | while (b[2] == '\r') |
969 | ✗ | b++; | |
970 |
5/8✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
|
9 | if (b[2] == '\n' && (b[3] == '#' || (b[3] >= '0' && b[3] <= '9'))) |
971 | 9 | return AVPROBE_SCORE_EXTENSION + 2; | |
972 | ✗ | return 0; | |
973 | } | ||
974 | |||
975 | 7282 | static int pbm_probe(const AVProbeData *p) | |
976 | { | ||
977 |
3/4✓ Branch 1 taken 7282 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 7280 times.
|
7282 | return pnm_magic_check(p, 1) || pnm_magic_check(p, 4) ? pnm_probe(p) : 0; |
978 | } | ||
979 | |||
980 | 7281 | static int pfm_probe(const AVProbeData *p) | |
981 | { | ||
982 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 7281 times.
|
14562 | return pnm_magic_check(p, 'F' - '0') || |
983 |
1/2✓ Branch 0 taken 7281 times.
✗ Branch 1 not taken.
|
14562 | pnm_magic_check(p, 'f' - '0') ? pnm_probe(p) : 0; |
984 | } | ||
985 | |||
986 | 7280 | static int phm_probe(const AVProbeData *p) | |
987 | { | ||
988 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 7280 times.
|
14560 | return pnm_magic_check(p, 'H' - '0') || |
989 |
1/2✓ Branch 0 taken 7280 times.
✗ Branch 1 not taken.
|
14560 | pnm_magic_check(p, 'h' - '0') ? pnm_probe(p) : 0; |
990 | } | ||
991 | |||
992 | 14562 | static inline int pgmx_probe(const AVProbeData *p) | |
993 | { | ||
994 |
3/4✓ Branch 1 taken 14562 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 14558 times.
|
14562 | return pnm_magic_check(p, 2) || pnm_magic_check(p, 5) ? pnm_probe(p) : 0; |
995 | } | ||
996 | |||
997 | 7281 | static int pgm_probe(const AVProbeData *p) | |
998 | { | ||
999 | 7281 | int ret = pgmx_probe(p); | |
1000 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7279 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
7281 | return ret && !av_match_ext(p->filename, "pgmyuv") ? ret : 0; |
1001 | } | ||
1002 | |||
1003 | 7281 | static int pgmyuv_probe(const AVProbeData *p) // custom FFmpeg format recognized by file extension | |
1004 | { | ||
1005 | 7281 | int ret = pgmx_probe(p); | |
1006 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7279 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
|
7281 | return ret && av_match_ext(p->filename, "pgmyuv") ? ret : 0; |
1007 | } | ||
1008 | |||
1009 | 7280 | static int pgx_probe(const AVProbeData *p) | |
1010 | { | ||
1011 | 7280 | const uint8_t *b = p->buf; | |
1012 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7280 times.
|
7280 | if (!memcmp(b, "PG ML ", 6)) |
1013 | ✗ | return AVPROBE_SCORE_EXTENSION + 1; | |
1014 | 7280 | return 0; | |
1015 | } | ||
1016 | |||
1017 | 7278 | static int ppm_probe(const AVProbeData *p) | |
1018 | { | ||
1019 |
3/4✓ Branch 1 taken 7278 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 7275 times.
|
7278 | return pnm_magic_check(p, 3) || pnm_magic_check(p, 6) ? pnm_probe(p) : 0; |
1020 | } | ||
1021 | |||
1022 | 7282 | static int pam_probe(const AVProbeData *p) | |
1023 | { | ||
1024 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 7282 times.
|
7282 | return pnm_magic_check(p, 7) ? pnm_probe(p) : 0; |
1025 | } | ||
1026 | |||
1027 | 7292 | static int hdr_probe(const AVProbeData *p) | |
1028 | { | ||
1029 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7292 times.
|
7292 | if (!memcmp(p->buf, "#?RADIANCE\n", 11)) |
1030 | ✗ | return AVPROBE_SCORE_MAX; | |
1031 | 7292 | return 0; | |
1032 | } | ||
1033 | |||
1034 | 7275 | static int xbm_probe(const AVProbeData *p) | |
1035 | { | ||
1036 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7274 times.
|
7275 | if (!memcmp(p->buf, "/* XBM X10 format */", 20)) |
1037 | 1 | return AVPROBE_SCORE_MAX; | |
1038 | |||
1039 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7272 times.
|
7274 | if (!memcmp(p->buf, "#define", 7)) |
1040 | 2 | return AVPROBE_SCORE_MAX - 1; | |
1041 | 7272 | return 0; | |
1042 | } | ||
1043 | |||
1044 | 7274 | static int xpm_probe(const AVProbeData *p) | |
1045 | { | ||
1046 | 7274 | const uint8_t *b = p->buf; | |
1047 | |||
1048 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7274 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7274 | if (AV_RB64(b) == 0x2f2a2058504d202a && *(b+8) == '/') |
1049 | ✗ | return AVPROBE_SCORE_MAX - 1; | |
1050 | 7274 | return 0; | |
1051 | } | ||
1052 | |||
1053 | 7274 | static int xwd_probe(const AVProbeData *p) | |
1054 | { | ||
1055 | 7274 | const uint8_t *b = p->buf; | |
1056 | unsigned width, bpp, bpad, lsize; | ||
1057 | |||
1058 |
2/2✓ Branch 0 taken 7269 times.
✓ Branch 1 taken 5 times.
|
7274 | if ( p->buf_size < XWD_HEADER_SIZE |
1059 |
2/2✓ Branch 0 taken 6257 times.
✓ Branch 1 taken 1012 times.
|
7269 | || AV_RB32(b ) < XWD_HEADER_SIZE // header size |
1060 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6256 times.
|
6257 | || AV_RB32(b + 4) != XWD_VERSION // version |
1061 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | || AV_RB32(b + 8) != XWD_Z_PIXMAP // format |
1062 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | || AV_RB32(b + 12) > 32 || !AV_RB32(b + 12) // depth |
1063 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | || AV_RB32(b + 16) == 0 // width |
1064 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | || AV_RB32(b + 20) == 0 // height |
1065 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | || AV_RB32(b + 28) > 1 // byteorder |
1066 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | || AV_RB32(b + 32) & ~56 || av_popcount(AV_RB32(b + 32)) != 1 // bitmap unit |
1067 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | || AV_RB32(b + 36) > 1 // bitorder |
1068 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | || AV_RB32(b + 40) & ~56 || av_popcount(AV_RB32(b + 40)) != 1 // padding |
1069 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | || AV_RB32(b + 44) > 32 || !AV_RB32(b + 44) // bpp |
1070 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | || AV_RB32(b + 68) > 256) // colours |
1071 | 7273 | return 0; | |
1072 | |||
1073 | 1 | width = AV_RB32(b + 16); | |
1074 | 1 | bpad = AV_RB32(b + 40); | |
1075 | 1 | bpp = AV_RB32(b + 44); | |
1076 | 1 | lsize = AV_RB32(b + 48); | |
1077 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (lsize < FFALIGN(width * bpp, bpad) >> 3) |
1078 | ✗ | return 0; | |
1079 | |||
1080 | 1 | return AVPROBE_SCORE_MAX / 2 + 1; | |
1081 | } | ||
1082 | |||
1083 | 7292 | static int gif_probe(const AVProbeData *p) | |
1084 | { | ||
1085 | /* check magick */ | ||
1086 |
3/4✓ Branch 0 taken 7292 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7277 times.
✓ Branch 3 taken 15 times.
|
7292 | if (memcmp(p->buf, gif87a_sig, 6) && memcmp(p->buf, gif89a_sig, 6)) |
1087 | 7277 | return 0; | |
1088 | |||
1089 | /* width or height contains zero? */ | ||
1090 |
2/4✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
|
15 | if (!AV_RL16(&p->buf[6]) || !AV_RL16(&p->buf[8])) |
1091 | ✗ | return 0; | |
1092 | |||
1093 | 15 | return AVPROBE_SCORE_MAX - 1; | |
1094 | } | ||
1095 | |||
1096 | 7280 | static int photocd_probe(const AVProbeData *p) | |
1097 | { | ||
1098 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7280 times.
|
7280 | if (!memcmp(p->buf, "PCD_OPA", 7)) |
1099 | ✗ | return AVPROBE_SCORE_MAX - 1; | |
1100 | |||
1101 |
3/4✓ Branch 0 taken 3222 times.
✓ Branch 1 taken 4058 times.
✓ Branch 2 taken 3222 times.
✗ Branch 3 not taken.
|
7280 | if (p->buf_size < 0x807 || memcmp(p->buf + 0x800, "PCD_IPI", 7)) |
1102 | 7280 | return 0; | |
1103 | |||
1104 | ✗ | return AVPROBE_SCORE_MAX - 1; | |
1105 | } | ||
1106 | |||
1107 | 7276 | static int qoi_probe(const AVProbeData *p) | |
1108 | { | ||
1109 |
2/2✓ Branch 0 taken 7275 times.
✓ Branch 1 taken 1 times.
|
7276 | if (memcmp(p->buf, "qoif", 4)) |
1110 | 7275 | return 0; | |
1111 | |||
1112 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if (AV_RB32(p->buf + 4) == 0 || AV_RB32(p->buf + 8) == 0) |
1113 | ✗ | return 0; | |
1114 | |||
1115 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | if (p->buf[12] != 3 && p->buf[12] != 4) |
1116 | ✗ | return 0; | |
1117 | |||
1118 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (p->buf[13] > 1) |
1119 | ✗ | return 0; | |
1120 | |||
1121 | 1 | return AVPROBE_SCORE_MAX - 1; | |
1122 | } | ||
1123 | |||
1124 | 7292 | static int gem_probe(const AVProbeData *p) | |
1125 | { | ||
1126 | 7292 | const uint8_t *b = p->buf; | |
1127 |
4/4✓ Branch 0 taken 5866 times.
✓ Branch 1 taken 1426 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 5865 times.
|
7292 | if ( AV_RB16(b ) >= 1 && AV_RB16(b ) <= 3 && |
1128 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | AV_RB16(b + 2) >= 8 && AV_RB16(b + 2) <= 779 && |
1129 | ✗ | (AV_RB16(b + 4) > 0 && AV_RB16(b + 4) <= 32) && /* planes */ | |
1130 | ✗ | (AV_RB16(b + 6) > 0 && AV_RB16(b + 6) <= 8) && /* pattern_size */ | |
1131 | ✗ | AV_RB16(b + 8) && | |
1132 | ✗ | AV_RB16(b + 10) && | |
1133 | ✗ | AV_RB16(b + 12) && | |
1134 | ✗ | AV_RB16(b + 14)) { | |
1135 | ✗ | if (AV_RN32(b + 16) == AV_RN32("STTT") || | |
1136 | ✗ | AV_RN32(b + 16) == AV_RN32("TIMG") || | |
1137 | ✗ | AV_RN32(b + 16) == AV_RN32("XIMG")) | |
1138 | ✗ | return AVPROBE_SCORE_EXTENSION + 1; | |
1139 | ✗ | return AVPROBE_SCORE_EXTENSION / 4; | |
1140 | } | ||
1141 | 7292 | return 0; | |
1142 | } | ||
1143 | |||
1144 | 7275 | static int vbn_probe(const AVProbeData *p) | |
1145 | { | ||
1146 | 7275 | const uint8_t *b = p->buf; | |
1147 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 7271 times.
|
7275 | if (AV_RL32(b ) == VBN_MAGIC && |
1148 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | AV_RL32(b + 4) == VBN_MAJOR && |
1149 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | AV_RL32(b + 8) == VBN_MINOR) |
1150 | 4 | return AVPROBE_SCORE_MAX - 1; | |
1151 | 7271 | return 0; | |
1152 | } | ||
1153 | |||
1154 | #define IMAGEAUTO_DEMUXER_0(imgname, codecid) | ||
1155 | #define IMAGEAUTO_DEMUXER_1(imgname, codecid)\ | ||
1156 | const FFInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\ | ||
1157 | .p.name = AV_STRINGIFY(imgname) "_pipe",\ | ||
1158 | .p.long_name = NULL_IF_CONFIG_SMALL("piped " AV_STRINGIFY(imgname) " sequence"),\ | ||
1159 | .p.priv_class = &imagepipe_class,\ | ||
1160 | .p.flags = AVFMT_GENERIC_INDEX,\ | ||
1161 | .priv_data_size = sizeof(VideoDemuxData),\ | ||
1162 | .read_probe = imgname ## _probe,\ | ||
1163 | .read_header = ff_img_read_header,\ | ||
1164 | .read_packet = ff_img_read_packet,\ | ||
1165 | .raw_codec_id = codecid,\ | ||
1166 | }; | ||
1167 | |||
1168 | #define IMAGEAUTO_DEMUXER_2(imgname, codecid, enabled) \ | ||
1169 | IMAGEAUTO_DEMUXER_ ## enabled(imgname, codecid) | ||
1170 | #define IMAGEAUTO_DEMUXER_3(imgname, codecid, config) \ | ||
1171 | IMAGEAUTO_DEMUXER_2(imgname, codecid, config) | ||
1172 | #define IMAGEAUTO_DEMUXER_EXT(imgname, codecid, uppercase_name) \ | ||
1173 | IMAGEAUTO_DEMUXER_3(imgname, AV_CODEC_ID_ ## codecid, \ | ||
1174 | CONFIG_IMAGE_ ## uppercase_name ## _PIPE_DEMUXER) | ||
1175 | #define IMAGEAUTO_DEMUXER(imgname, codecid) \ | ||
1176 | IMAGEAUTO_DEMUXER_EXT(imgname, codecid, codecid) | ||
1177 | |||
1178 | IMAGEAUTO_DEMUXER(bmp, BMP) | ||
1179 | IMAGEAUTO_DEMUXER(cri, CRI) | ||
1180 | IMAGEAUTO_DEMUXER(dds, DDS) | ||
1181 | IMAGEAUTO_DEMUXER(dpx, DPX) | ||
1182 | IMAGEAUTO_DEMUXER(exr, EXR) | ||
1183 | IMAGEAUTO_DEMUXER(gem, GEM) | ||
1184 | IMAGEAUTO_DEMUXER(gif, GIF) | ||
1185 | IMAGEAUTO_DEMUXER_EXT(hdr, RADIANCE_HDR, HDR) | ||
1186 | IMAGEAUTO_DEMUXER_EXT(j2k, JPEG2000, J2K) | ||
1187 | IMAGEAUTO_DEMUXER_EXT(jpeg, MJPEG, JPEG) | ||
1188 | IMAGEAUTO_DEMUXER(jpegls, JPEGLS) | ||
1189 | IMAGEAUTO_DEMUXER(jpegxl, JPEGXL) | ||
1190 | IMAGEAUTO_DEMUXER(pam, PAM) | ||
1191 | IMAGEAUTO_DEMUXER(pbm, PBM) | ||
1192 | IMAGEAUTO_DEMUXER(pcx, PCX) | ||
1193 | IMAGEAUTO_DEMUXER(pfm, PFM) | ||
1194 | IMAGEAUTO_DEMUXER(pgm, PGM) | ||
1195 | IMAGEAUTO_DEMUXER(pgmyuv, PGMYUV) | ||
1196 | IMAGEAUTO_DEMUXER(pgx, PGX) | ||
1197 | IMAGEAUTO_DEMUXER(phm, PHM) | ||
1198 | IMAGEAUTO_DEMUXER(photocd, PHOTOCD) | ||
1199 | IMAGEAUTO_DEMUXER(pictor, PICTOR) | ||
1200 | IMAGEAUTO_DEMUXER(png, PNG) | ||
1201 | IMAGEAUTO_DEMUXER(ppm, PPM) | ||
1202 | IMAGEAUTO_DEMUXER(psd, PSD) | ||
1203 | IMAGEAUTO_DEMUXER(qdraw, QDRAW) | ||
1204 | IMAGEAUTO_DEMUXER(qoi, QOI) | ||
1205 | IMAGEAUTO_DEMUXER(sgi, SGI) | ||
1206 | IMAGEAUTO_DEMUXER(sunrast, SUNRAST) | ||
1207 | IMAGEAUTO_DEMUXER(svg, SVG) | ||
1208 | IMAGEAUTO_DEMUXER(tiff, TIFF) | ||
1209 | IMAGEAUTO_DEMUXER(vbn, VBN) | ||
1210 | IMAGEAUTO_DEMUXER(webp, WEBP) | ||
1211 | IMAGEAUTO_DEMUXER(xbm, XBM) | ||
1212 | IMAGEAUTO_DEMUXER(xpm, XPM) | ||
1213 | IMAGEAUTO_DEMUXER(xwd, XWD) | ||
1214 |