2004-07-15 18:32:54 +00:00
|
|
|
/*
|
|
|
|
* Image format
|
2009-01-19 15:46:40 +00:00
|
|
|
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
2004-07-15 18:32:54 +00:00
|
|
|
* Copyright (c) 2004 Michael Niedermayer
|
|
|
|
*
|
2006-10-07 15:30:46 +00:00
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2004-07-15 18:32:54 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 15:30:46 +00:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2004-07-15 18:32:54 +00:00
|
|
|
*
|
2006-10-07 15:30:46 +00:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2004-07-15 18:32:54 +00: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
|
2006-10-07 15:30:46 +00:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2006-01-12 22:43:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-07-15 18:32:54 +00:00
|
|
|
*/
|
2008-05-09 11:56:36 +00:00
|
|
|
|
|
|
|
#include "libavutil/avstring.h"
|
2011-04-05 11:13:53 +00:00
|
|
|
#include "internal.h"
|
2015-09-06 15:07:20 +00:00
|
|
|
#include "img2.h"
|
2004-07-15 18:32:54 +00:00
|
|
|
|
2015-09-06 15:07:20 +00:00
|
|
|
const IdStrMap ff_img_tags[] = {
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_MJPEG, "jpeg" },
|
|
|
|
{ AV_CODEC_ID_MJPEG, "jpg" },
|
2012-11-30 13:49:13 +00:00
|
|
|
{ AV_CODEC_ID_MJPEG, "jps" },
|
2013-10-16 15:37:02 +00:00
|
|
|
{ AV_CODEC_ID_MJPEG, "mpo" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_LJPEG, "ljpg" },
|
2012-11-30 13:49:13 +00:00
|
|
|
{ AV_CODEC_ID_JPEGLS, "jls" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_PNG, "png" },
|
2012-11-30 13:49:13 +00:00
|
|
|
{ AV_CODEC_ID_PNG, "pns" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_PNG, "mng" },
|
|
|
|
{ AV_CODEC_ID_PPM, "ppm" },
|
|
|
|
{ AV_CODEC_ID_PPM, "pnm" },
|
|
|
|
{ AV_CODEC_ID_PGM, "pgm" },
|
|
|
|
{ AV_CODEC_ID_PGMYUV, "pgmyuv" },
|
|
|
|
{ AV_CODEC_ID_PBM, "pbm" },
|
|
|
|
{ AV_CODEC_ID_PAM, "pam" },
|
2014-03-20 00:15:25 +00:00
|
|
|
{ AV_CODEC_ID_ALIAS_PIX, "pix" },
|
2015-05-26 23:30:51 +00:00
|
|
|
{ AV_CODEC_ID_DDS, "dds" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_MPEG1VIDEO, "mpg1-img" },
|
|
|
|
{ AV_CODEC_ID_MPEG2VIDEO, "mpg2-img" },
|
|
|
|
{ AV_CODEC_ID_MPEG4, "mpg4-img" },
|
|
|
|
{ AV_CODEC_ID_RAWVIDEO, "y" },
|
2012-11-30 13:49:13 +00:00
|
|
|
{ AV_CODEC_ID_RAWVIDEO, "raw" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_BMP, "bmp" },
|
|
|
|
{ AV_CODEC_ID_TARGA, "tga" },
|
|
|
|
{ AV_CODEC_ID_TIFF, "tiff" },
|
|
|
|
{ AV_CODEC_ID_TIFF, "tif" },
|
2019-05-30 10:42:42 +00:00
|
|
|
{ AV_CODEC_ID_TIFF, "dng" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_SGI, "sgi" },
|
|
|
|
{ AV_CODEC_ID_PTX, "ptx" },
|
|
|
|
{ AV_CODEC_ID_PCX, "pcx" },
|
2015-04-18 16:25:21 +00:00
|
|
|
{ AV_CODEC_ID_QDRAW, "pic" },
|
|
|
|
{ AV_CODEC_ID_QDRAW, "pct" },
|
|
|
|
{ AV_CODEC_ID_QDRAW, "pict" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_SUNRAST, "sun" },
|
|
|
|
{ AV_CODEC_ID_SUNRAST, "ras" },
|
|
|
|
{ AV_CODEC_ID_SUNRAST, "rs" },
|
|
|
|
{ AV_CODEC_ID_SUNRAST, "im1" },
|
|
|
|
{ AV_CODEC_ID_SUNRAST, "im8" },
|
|
|
|
{ AV_CODEC_ID_SUNRAST, "im24" },
|
2012-11-30 13:49:13 +00:00
|
|
|
{ AV_CODEC_ID_SUNRAST, "im32" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_SUNRAST, "sunras" },
|
2017-05-21 23:09:21 +00:00
|
|
|
{ AV_CODEC_ID_SVG, "svg" },
|
|
|
|
{ AV_CODEC_ID_SVG, "svgz" },
|
2012-11-30 13:49:13 +00:00
|
|
|
{ AV_CODEC_ID_JPEG2000, "j2c" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_JPEG2000, "jp2" },
|
|
|
|
{ AV_CODEC_ID_JPEG2000, "jpc" },
|
2013-03-26 22:21:12 +00:00
|
|
|
{ AV_CODEC_ID_JPEG2000, "j2k" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_DPX, "dpx" },
|
2012-11-30 13:49:13 +00:00
|
|
|
{ AV_CODEC_ID_EXR, "exr" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_PICTOR, "pic" },
|
2012-11-30 13:49:13 +00:00
|
|
|
{ AV_CODEC_ID_V210X, "yuv10" },
|
2013-03-22 02:42:35 +00:00
|
|
|
{ AV_CODEC_ID_WEBP, "webp" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_XBM, "xbm" },
|
2017-03-11 21:01:23 +00:00
|
|
|
{ AV_CODEC_ID_XPM, "xpm" },
|
2012-11-30 13:49:13 +00:00
|
|
|
{ AV_CODEC_ID_XFACE, "xface" },
|
2012-11-29 03:56:40 +00:00
|
|
|
{ AV_CODEC_ID_XWD, "xwd" },
|
|
|
|
{ AV_CODEC_ID_NONE, NULL }
|
2004-07-15 18:32:54 +00:00
|
|
|
};
|
|
|
|
|
2016-02-24 00:44:18 +00:00
|
|
|
static enum AVCodecID str2id(const IdStrMap *tags, const char *str)
|
2004-07-15 18:32:54 +00:00
|
|
|
{
|
2012-11-29 03:56:40 +00:00
|
|
|
str = strrchr(str, '.');
|
|
|
|
if (!str)
|
|
|
|
return AV_CODEC_ID_NONE;
|
2004-09-22 21:25:09 +00:00
|
|
|
str++;
|
2004-07-15 18:32:54 +00:00
|
|
|
|
|
|
|
while (tags->id) {
|
2011-11-02 19:17:25 +00:00
|
|
|
if (!av_strcasecmp(str, tags->str))
|
2008-05-12 01:17:00 +00:00
|
|
|
return tags->id;
|
2004-07-15 18:32:54 +00:00
|
|
|
|
|
|
|
tags++;
|
|
|
|
}
|
2012-08-05 09:11:04 +00:00
|
|
|
return AV_CODEC_ID_NONE;
|
2004-07-15 18:32:54 +00:00
|
|
|
}
|
|
|
|
|
2012-08-05 09:11:04 +00:00
|
|
|
enum AVCodecID ff_guess_image2_codec(const char *filename)
|
2012-02-21 14:49:41 +00:00
|
|
|
{
|
2016-04-11 13:59:58 +00:00
|
|
|
return str2id(ff_img_tags, filename);
|
2012-02-21 14:49:41 +00:00
|
|
|
}
|