2004-07-15 21:32:54 +03:00
|
|
|
/*
|
|
|
|
* Image format
|
2009-01-19 17:46:40 +02:00
|
|
|
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
2004-07-15 21:32:54 +03:00
|
|
|
* Copyright (c) 2004 Michael Niedermayer
|
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* This file is part of Libav.
|
2006-10-07 18:30:46 +03:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2004-07-15 21:32:54 +03:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 18:30:46 +03:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2004-07-15 21:32:54 +03:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2004-07-15 21:32:54 +03:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2011-03-18 19:35:10 +02:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2006-01-13 00:43:26 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-07-15 21:32:54 +03:00
|
|
|
*/
|
2008-05-09 14:56:36 +03:00
|
|
|
|
|
|
|
#include "libavutil/avstring.h"
|
2011-04-05 14:13:53 +03:00
|
|
|
#include "internal.h"
|
2004-07-15 21:32:54 +03:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
enum CodecID id;
|
|
|
|
const char *str;
|
|
|
|
} IdStrMap;
|
|
|
|
|
|
|
|
static const IdStrMap img_tags[] = {
|
|
|
|
{ CODEC_ID_MJPEG , "jpeg"},
|
|
|
|
{ CODEC_ID_MJPEG , "jpg"},
|
2009-06-20 17:51:03 +03:00
|
|
|
{ CODEC_ID_LJPEG , "ljpg"},
|
2004-11-10 01:31:46 +02:00
|
|
|
{ CODEC_ID_PNG , "png"},
|
2008-02-26 12:21:33 +02:00
|
|
|
{ CODEC_ID_PNG , "mng"},
|
2004-11-11 20:09:28 +02:00
|
|
|
{ CODEC_ID_PPM , "ppm"},
|
2008-12-04 17:08:04 +02:00
|
|
|
{ CODEC_ID_PPM , "pnm"},
|
2004-11-11 20:09:28 +02:00
|
|
|
{ CODEC_ID_PGM , "pgm"},
|
|
|
|
{ CODEC_ID_PGMYUV , "pgmyuv"},
|
|
|
|
{ CODEC_ID_PBM , "pbm"},
|
|
|
|
{ CODEC_ID_PAM , "pam"},
|
2004-07-15 21:32:54 +03:00
|
|
|
{ CODEC_ID_MPEG1VIDEO, "mpg1-img"},
|
|
|
|
{ CODEC_ID_MPEG2VIDEO, "mpg2-img"},
|
|
|
|
{ CODEC_ID_MPEG4 , "mpg4-img"},
|
|
|
|
{ CODEC_ID_FFV1 , "ffv1-img"},
|
2005-01-04 15:27:35 +02:00
|
|
|
{ CODEC_ID_RAWVIDEO , "y"},
|
2005-11-30 03:40:50 +02:00
|
|
|
{ CODEC_ID_BMP , "bmp"},
|
2006-10-22 18:07:25 +03:00
|
|
|
{ CODEC_ID_GIF , "gif"},
|
2006-10-23 16:17:46 +03:00
|
|
|
{ CODEC_ID_TARGA , "tga"},
|
|
|
|
{ CODEC_ID_TIFF , "tiff"},
|
2008-05-30 16:26:40 +03:00
|
|
|
{ CODEC_ID_TIFF , "tif"},
|
2007-04-06 21:29:27 +03:00
|
|
|
{ CODEC_ID_SGI , "sgi"},
|
2007-05-08 14:57:49 +03:00
|
|
|
{ CODEC_ID_PTX , "ptx"},
|
2007-12-27 00:17:46 +02:00
|
|
|
{ CODEC_ID_PCX , "pcx"},
|
2007-12-28 15:07:43 +02:00
|
|
|
{ CODEC_ID_SUNRAST , "sun"},
|
|
|
|
{ CODEC_ID_SUNRAST , "ras"},
|
|
|
|
{ CODEC_ID_SUNRAST , "rs"},
|
|
|
|
{ CODEC_ID_SUNRAST , "im1"},
|
|
|
|
{ CODEC_ID_SUNRAST , "im8"},
|
|
|
|
{ CODEC_ID_SUNRAST , "im24"},
|
|
|
|
{ CODEC_ID_SUNRAST , "sunras"},
|
2008-12-17 13:22:51 +02:00
|
|
|
{ CODEC_ID_JPEG2000 , "jp2"},
|
2011-05-24 00:13:34 +03:00
|
|
|
{ CODEC_ID_JPEG2000 , "jpc"},
|
2009-06-12 08:29:29 +03:00
|
|
|
{ CODEC_ID_DPX , "dpx"},
|
2010-06-08 14:55:55 +03:00
|
|
|
{ CODEC_ID_PICTOR , "pic"},
|
2012-03-17 20:43:58 +03:00
|
|
|
{ CODEC_ID_XBM , "xbm"},
|
2012-01-21 20:45:52 +03:00
|
|
|
{ CODEC_ID_XWD , "xwd"},
|
2008-05-12 13:30:40 +03:00
|
|
|
{ CODEC_ID_NONE , NULL}
|
2004-07-15 21:32:54 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static enum CodecID av_str2id(const IdStrMap *tags, const char *str)
|
|
|
|
{
|
2004-09-23 00:25:09 +03:00
|
|
|
str= strrchr(str, '.');
|
|
|
|
if(!str) return CODEC_ID_NONE;
|
|
|
|
str++;
|
2004-07-15 21:32:54 +03:00
|
|
|
|
|
|
|
while (tags->id) {
|
2011-11-02 22:17:25 +03:00
|
|
|
if (!av_strcasecmp(str, tags->str))
|
2008-05-12 04:17:00 +03:00
|
|
|
return tags->id;
|
2004-07-15 21:32:54 +03:00
|
|
|
|
|
|
|
tags++;
|
|
|
|
}
|
|
|
|
return CODEC_ID_NONE;
|
|
|
|
}
|
|
|
|
|
2012-02-21 17:49:41 +03:00
|
|
|
enum CodecID ff_guess_image2_codec(const char *filename)
|
|
|
|
{
|
|
|
|
return av_str2id(img_tags, filename);
|
|
|
|
}
|