DirectDraw Surface image decoder
[libav.git] / libavformat / img2.c
CommitLineData
03cfe134
MN
1/*
2 * Image format
406792e7 3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
03cfe134
MN
4 * Copyright (c) 2004 Michael Niedermayer
5 *
2912e87a 6 * This file is part of Libav.
b78e7197 7 *
2912e87a 8 * Libav is free software; you can redistribute it and/or
03cfe134
MN
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
b78e7197 11 * version 2.1 of the License, or (at your option) any later version.
03cfe134 12 *
2912e87a 13 * Libav is distributed in the hope that it will be useful,
03cfe134
MN
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
2912e87a 19 * License along with Libav; if not, write to the Free Software
5509bffa 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
03cfe134 21 */
245976da
DB
22
23#include "libavutil/avstring.h"
a9bf9d8e 24#include "internal.h"
03cfe134 25
daf8cf35 26typedef struct IdStrMap {
36ef5369 27 enum AVCodecID id;
03cfe134
MN
28 const char *str;
29} IdStrMap;
30
31static const IdStrMap img_tags[] = {
cc7d5cfe
DB
32 { AV_CODEC_ID_MJPEG, "jpeg" },
33 { AV_CODEC_ID_MJPEG, "jpg" },
ae9d13f0
ML
34 { AV_CODEC_ID_MJPEG, "jps" },
35 { AV_CODEC_ID_MJPEG, "mpo" },
cc7d5cfe
DB
36 { AV_CODEC_ID_LJPEG, "ljpg" },
37 { AV_CODEC_ID_PNG, "png" },
ae9d13f0 38 { AV_CODEC_ID_PNG, "pns" },
cc7d5cfe
DB
39 { AV_CODEC_ID_PNG, "mng" },
40 { AV_CODEC_ID_PPM, "ppm" },
41 { AV_CODEC_ID_PPM, "pnm" },
42 { AV_CODEC_ID_PGM, "pgm" },
43 { AV_CODEC_ID_PGMYUV, "pgmyuv" },
44 { AV_CODEC_ID_PBM, "pbm" },
45 { AV_CODEC_ID_PAM, "pam" },
e50f5d3c 46 { AV_CODEC_ID_ALIAS_PIX, "pix" },
5c018ee1 47 { AV_CODEC_ID_DDS, "dds" },
cc7d5cfe
DB
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_FFV1, "ffv1-img" },
52 { AV_CODEC_ID_RAWVIDEO, "y" },
53 { AV_CODEC_ID_BMP, "bmp" },
54 { AV_CODEC_ID_GIF, "gif" },
55 { AV_CODEC_ID_TARGA, "tga" },
56 { AV_CODEC_ID_TIFF, "tiff" },
57 { AV_CODEC_ID_TIFF, "tif" },
58 { AV_CODEC_ID_SGI, "sgi" },
59 { AV_CODEC_ID_PTX, "ptx" },
ae17878f 60 { AV_CODEC_ID_BRENDER_PIX,"pix" },
cc7d5cfe 61 { AV_CODEC_ID_PCX, "pcx" },
7b734ee5
VG
62 { AV_CODEC_ID_QDRAW, "pic" },
63 { AV_CODEC_ID_QDRAW, "pct" },
64 { AV_CODEC_ID_QDRAW, "pict" },
cc7d5cfe
DB
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, "sunras" },
6d78e852 72 { AV_CODEC_ID_JPEG2000, "j2c" },
cc7d5cfe
DB
73 { AV_CODEC_ID_JPEG2000, "jp2" },
74 { AV_CODEC_ID_JPEG2000, "jpc" },
5e46f6b5 75 { AV_CODEC_ID_JPEG2000, "j2k" },
cc7d5cfe 76 { AV_CODEC_ID_DPX, "dpx" },
38389058 77 { AV_CODEC_ID_EXR, "exr" },
cc7d5cfe 78 { AV_CODEC_ID_PICTOR, "pic" },
c4bfa098 79 { AV_CODEC_ID_WEBP, "webp" },
cc7d5cfe
DB
80 { AV_CODEC_ID_XBM, "xbm" },
81 { AV_CODEC_ID_XWD, "xwd" },
82 { AV_CODEC_ID_NONE, NULL }
03cfe134
MN
83};
84
36ef5369 85static enum AVCodecID av_str2id(const IdStrMap *tags, const char *str)
03cfe134 86{
cc7d5cfe
DB
87 str = strrchr(str, '.');
88 if (!str)
89 return AV_CODEC_ID_NONE;
3ed02129 90 str++;
03cfe134
MN
91
92 while (tags->id) {
bb3244de 93 if (!av_strcasecmp(str, tags->str))
3375a6a5 94 return tags->id;
03cfe134
MN
95
96 tags++;
97 }
36ef5369 98 return AV_CODEC_ID_NONE;
03cfe134
MN
99}
100
36ef5369 101enum AVCodecID ff_guess_image2_codec(const char *filename)
3f486e0d
DB
102{
103 return av_str2id(img_tags, filename);
104}