FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/img2dec.c
Date: 2026-10-19 01:23:10
Exec Total Coverage
Lines: 513 669 76.7%
Functions: 48 49 98.0%
Branches: 369 608 60.7%

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