FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/img2.c
Date: 2022-12-09 07:38:14
Exec Total Coverage
Lines: 12 12 100.0%
Functions: 2 2 100.0%
Branches: 6 6 100.0%

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 "libavutil/avstring.h"
24 #include "internal.h"
25 #include "img2.h"
26
27 const IdStrMap ff_img_tags[] = {
28 { AV_CODEC_ID_MJPEG, "jpeg" },
29 { AV_CODEC_ID_MJPEG, "jpg" },
30 { AV_CODEC_ID_MJPEG, "jps" },
31 { AV_CODEC_ID_MJPEG, "mpo" },
32 { AV_CODEC_ID_LJPEG, "ljpg" },
33 { AV_CODEC_ID_JPEGLS, "jls" },
34 { AV_CODEC_ID_PNG, "png" },
35 { AV_CODEC_ID_PNG, "pns" },
36 { AV_CODEC_ID_PNG, "mng" },
37 { AV_CODEC_ID_PPM, "ppm" },
38 { AV_CODEC_ID_PPM, "pnm" },
39 { AV_CODEC_ID_PGM, "pgm" },
40 { AV_CODEC_ID_PGMYUV, "pgmyuv" },
41 { AV_CODEC_ID_PBM, "pbm" },
42 { AV_CODEC_ID_PAM, "pam" },
43 { AV_CODEC_ID_PFM, "pfm" },
44 { AV_CODEC_ID_PHM, "phm" },
45 { AV_CODEC_ID_CRI, "cri" },
46 { AV_CODEC_ID_ALIAS_PIX, "pix" },
47 { AV_CODEC_ID_DDS, "dds" },
48 { AV_CODEC_ID_MPEG1VIDEO, "mpg1-img" },
49 { AV_CODEC_ID_MPEG2VIDEO, "mpg2-img" },
50 { AV_CODEC_ID_MPEG4, "mpg4-img" },
51 { AV_CODEC_ID_RAWVIDEO, "y" },
52 { AV_CODEC_ID_RAWVIDEO, "raw" },
53 { AV_CODEC_ID_BMP, "bmp" },
54 { AV_CODEC_ID_TARGA, "tga" },
55 { AV_CODEC_ID_TIFF, "tiff" },
56 { AV_CODEC_ID_TIFF, "tif" },
57 { AV_CODEC_ID_TIFF, "dng" },
58 { AV_CODEC_ID_SGI, "sgi" },
59 { AV_CODEC_ID_PTX, "ptx" },
60 { AV_CODEC_ID_PHOTOCD, "pcd" },
61 { AV_CODEC_ID_PCX, "pcx" },
62 { AV_CODEC_ID_QDRAW, "pic" },
63 { AV_CODEC_ID_QDRAW, "pct" },
64 { AV_CODEC_ID_QDRAW, "pict" },
65 { AV_CODEC_ID_SUNRAST, "sun" },
66 { AV_CODEC_ID_SUNRAST, "ras" },
67 { AV_CODEC_ID_SUNRAST, "rs" },
68 { AV_CODEC_ID_SUNRAST, "im1" },
69 { AV_CODEC_ID_SUNRAST, "im8" },
70 { AV_CODEC_ID_SUNRAST, "im24" },
71 { AV_CODEC_ID_SUNRAST, "im32" },
72 { AV_CODEC_ID_SUNRAST, "sunras" },
73 { AV_CODEC_ID_SVG, "svg" },
74 { AV_CODEC_ID_SVG, "svgz" },
75 { AV_CODEC_ID_JPEG2000, "j2c" },
76 { AV_CODEC_ID_JPEG2000, "jp2" },
77 { AV_CODEC_ID_JPEG2000, "jpc" },
78 { AV_CODEC_ID_JPEG2000, "j2k" },
79 { AV_CODEC_ID_DPX, "dpx" },
80 { AV_CODEC_ID_EXR, "exr" },
81 { AV_CODEC_ID_PICTOR, "pic" },
82 { AV_CODEC_ID_V210X, "yuv10" },
83 { AV_CODEC_ID_WEBP, "webp" },
84 { AV_CODEC_ID_XBM, "xbm" },
85 { AV_CODEC_ID_XPM, "xpm" },
86 { AV_CODEC_ID_XFACE, "xface" },
87 { AV_CODEC_ID_XWD, "xwd" },
88 { AV_CODEC_ID_GEM, "img" },
89 { AV_CODEC_ID_GEM, "ximg" },
90 { AV_CODEC_ID_GEM, "timg" },
91 { AV_CODEC_ID_VBN, "vbn" },
92 { AV_CODEC_ID_JPEGXL, "jxl" },
93 { AV_CODEC_ID_QOI, "qoi" },
94 { AV_CODEC_ID_RADIANCE_HDR, "hdr" },
95 { AV_CODEC_ID_WBMP, "wbmp" },
96 { AV_CODEC_ID_NONE, NULL }
97 };
98
99 7795 static enum AVCodecID str2id(const IdStrMap *tags, const char *str)
100 {
101 7795 str = strrchr(str, '.');
102
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 7756 times.
7795 if (!str)
103 39 return AV_CODEC_ID_NONE;
104 7756 str++;
105
106
2/2
✓ Branch 0 taken 491698 times.
✓ Branch 1 taken 6805 times.
498503 while (tags->id) {
107
2/2
✓ Branch 1 taken 951 times.
✓ Branch 2 taken 490747 times.
491698 if (!av_strcasecmp(str, tags->str))
108 951 return tags->id;
109
110 490747 tags++;
111 }
112 6805 return AV_CODEC_ID_NONE;
113 }
114
115 7795 enum AVCodecID ff_guess_image2_codec(const char *filename)
116 {
117 7795 return str2id(ff_img_tags, filename);
118 }
119