Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
libavformat
img2.c
Go to the documentation of this file.
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 Libav.
7
*
8
* Libav 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
* Libav 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 Libav; 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
26
typedef
struct
{
27
enum
AVCodecID
id
;
28
const
char
*
str
;
29
}
IdStrMap
;
30
31
static
const
IdStrMap
img_tags
[] = {
32
{
AV_CODEC_ID_MJPEG
,
"jpeg"
},
33
{
AV_CODEC_ID_MJPEG
,
"jpg"
},
34
{
AV_CODEC_ID_LJPEG
,
"ljpg"
},
35
{
AV_CODEC_ID_PNG
,
"png"
},
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_MPEG1VIDEO
,
"mpg1-img"
},
44
{
AV_CODEC_ID_MPEG2VIDEO
,
"mpg2-img"
},
45
{
AV_CODEC_ID_MPEG4
,
"mpg4-img"
},
46
{
AV_CODEC_ID_FFV1
,
"ffv1-img"
},
47
{
AV_CODEC_ID_RAWVIDEO
,
"y"
},
48
{
AV_CODEC_ID_BMP
,
"bmp"
},
49
{
AV_CODEC_ID_GIF
,
"gif"
},
50
{
AV_CODEC_ID_TARGA
,
"tga"
},
51
{
AV_CODEC_ID_TIFF
,
"tiff"
},
52
{
AV_CODEC_ID_TIFF
,
"tif"
},
53
{
AV_CODEC_ID_SGI
,
"sgi"
},
54
{
AV_CODEC_ID_PTX
,
"ptx"
},
55
{
AV_CODEC_ID_PCX
,
"pcx"
},
56
{
AV_CODEC_ID_SUNRAST
,
"sun"
},
57
{
AV_CODEC_ID_SUNRAST
,
"ras"
},
58
{
AV_CODEC_ID_SUNRAST
,
"rs"
},
59
{
AV_CODEC_ID_SUNRAST
,
"im1"
},
60
{
AV_CODEC_ID_SUNRAST
,
"im8"
},
61
{
AV_CODEC_ID_SUNRAST
,
"im24"
},
62
{
AV_CODEC_ID_SUNRAST
,
"sunras"
},
63
{
AV_CODEC_ID_JPEG2000
,
"jp2"
},
64
{
AV_CODEC_ID_JPEG2000
,
"jpc"
},
65
{
AV_CODEC_ID_DPX
,
"dpx"
},
66
{
AV_CODEC_ID_PICTOR
,
"pic"
},
67
{
AV_CODEC_ID_XBM
,
"xbm"
},
68
{
AV_CODEC_ID_XWD
,
"xwd"
},
69
{
AV_CODEC_ID_NONE
,
NULL
}
70
};
71
72
static
enum
AVCodecID
av_str2id
(
const
IdStrMap
*tags,
const
char
*str)
73
{
74
str = strrchr(str,
'.'
);
75
if
(!str)
76
return
AV_CODEC_ID_NONE
;
77
str++;
78
79
while
(tags->
id
) {
80
if
(!
av_strcasecmp
(str, tags->
str
))
81
return
tags->
id
;
82
83
tags++;
84
}
85
return
AV_CODEC_ID_NONE
;
86
}
87
88
enum
AVCodecID
ff_guess_image2_codec
(
const
char
*filename)
89
{
90
return
av_str2id
(img_tags, filename);
91
}
AV_CODEC_ID_NONE
Definition:
avcodec.h:96
id
enum AVCodecID id
Definition:
mxfenc.c:85
IdStrMap
Definition:
img2.c:26
IdStrMap::id
enum AVCodecID id
Definition:
img2.c:27
AV_CODEC_ID_PNG
Definition:
avcodec.h:161
img_tags
static const IdStrMap img_tags[]
Definition:
img2.c:31
AV_CODEC_ID_PBM
Definition:
avcodec.h:163
AV_CODEC_ID_LJPEG
Definition:
avcodec.h:108
AV_CODEC_ID_MPEG4
Definition:
avcodec.h:111
av_str2id
static enum AVCodecID av_str2id(const IdStrMap *tags, const char *str)
Definition:
img2.c:72
avstring.h
AV_CODEC_ID_PAM
Definition:
avcodec.h:166
AV_CODEC_ID_MJPEG
Definition:
avcodec.h:106
AV_CODEC_ID_PCX
Definition:
avcodec.h:209
AV_CODEC_ID_MPEG1VIDEO
Definition:
avcodec.h:99
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition:
avcodec.h:95
AV_CODEC_ID_BMP
Definition:
avcodec.h:178
internal.h
AV_CODEC_ID_XBM
Definition:
avcodec.h:260
IdStrMap::str
const char * str
Definition:
img2.c:28
av_strcasecmp
int av_strcasecmp(const char *a, const char *b)
Definition:
avstring.c:140
AV_CODEC_ID_SUNRAST
Definition:
avcodec.h:210
AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition:
avcodec.h:100
AV_CODEC_ID_XWD
Definition:
avcodec.h:258
NULL
NULL
Definition:
eval.c:52
AV_CODEC_ID_PICTOR
Definition:
avcodec.h:241
AV_CODEC_ID_PGMYUV
Definition:
avcodec.h:165
AV_CODEC_ID_TARGA
Definition:
avcodec.h:193
AV_CODEC_ID_DPX
Definition:
avcodec.h:228
AV_CODEC_ID_PGM
Definition:
avcodec.h:164
AV_CODEC_ID_JPEG2000
Definition:
avcodec.h:188
AV_CODEC_ID_TIFF
Definition:
avcodec.h:196
AV_CODEC_ID_FFV1
Definition:
avcodec.h:132
AV_CODEC_ID_PTX
Definition:
avcodec.h:204
ff_guess_image2_codec
enum AVCodecID ff_guess_image2_codec(const char *filename)
Definition:
img2.c:88
AV_CODEC_ID_PPM
Definition:
avcodec.h:162
AV_CODEC_ID_GIF
Definition:
avcodec.h:197
AV_CODEC_ID_RAWVIDEO
Definition:
avcodec.h:112
AV_CODEC_ID_SGI
Definition:
avcodec.h:201