diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2006-08-01 14:58:15 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2006-08-01 14:58:15 +0000 |
commit | e40ee6a268df9545f8c00fec4400a6850723bfe8 (patch) | |
tree | deb9b8b3ef501d8490401315a7fa1230d23c8b62 /libavformat | |
parent | 986c2ccb198135c59341751a1ae554065df5e363 (diff) | |
download | ffmpeg-e40ee6a268df9545f8c00fec4400a6850723bfe8.tar.gz |
move common code from mov.c and movenc.c to isom.c
Originally committed as revision 5882 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/Makefile | 12 | ||||
-rw-r--r-- | libavformat/isom.c | 128 | ||||
-rw-r--r-- | libavformat/isom.h | 15 | ||||
-rw-r--r-- | libavformat/mov.c | 106 | ||||
-rw-r--r-- | libavformat/mov.h | 13 | ||||
-rw-r--r-- | libavformat/movenc.c | 2 |
6 files changed, 151 insertions, 125 deletions
diff --git a/libavformat/Makefile b/libavformat/Makefile index 38d15be125..294c209cfe 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -57,12 +57,12 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroska.o riff.o OBJS-$(CONFIG_MM_DEMUXER) += mm.o OBJS-$(CONFIG_MMF_DEMUXER) += mmf.o riff.o OBJS-$(CONFIG_MMF_MUXER) += mmf.o riff.o -OBJS-$(CONFIG_MOV_DEMUXER) += mov.o riff.o -OBJS-$(CONFIG_MOV_MUXER) += movenc.o riff.o -OBJS-$(CONFIG_TGP_MUXER) += movenc.o riff.o -OBJS-$(CONFIG_MP4_MUXER) += movenc.o riff.o -OBJS-$(CONFIG_PSP_MUXER) += movenc.o riff.o -OBJS-$(CONFIG_TG2_MUXER) += movenc.o riff.o +OBJS-$(CONFIG_MOV_DEMUXER) += mov.o riff.o isom.o +OBJS-$(CONFIG_MOV_MUXER) += movenc.o riff.o isom.o +OBJS-$(CONFIG_TGP_MUXER) += movenc.o riff.o isom.o +OBJS-$(CONFIG_MP4_MUXER) += movenc.o riff.o isom.o +OBJS-$(CONFIG_PSP_MUXER) += movenc.o riff.o isom.o +OBJS-$(CONFIG_TG2_MUXER) += movenc.o riff.o isom.o OBJS-$(CONFIG_MP3_DEMUXER) += mp3.o OBJS-$(CONFIG_MP2_MUXER) += mp3.o OBJS-$(CONFIG_MP3_MUXER) += mp3.o diff --git a/libavformat/isom.c b/libavformat/isom.c new file mode 100644 index 0000000000..f4b468deb4 --- /dev/null +++ b/libavformat/isom.c @@ -0,0 +1,128 @@ +/* + * ISO Media common code + * Copyright (c) 2001 Fabrice Bellard. + * Copyright (c) 2002 Francois Revol <revol@free.fr> + * Copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * 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 + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avformat.h" +#include "riff.h" +#include "isom.h" + +/* http://gpac.sourceforge.net/tutorial/mediatypes.htm */ +const CodecTag ff_mov_obj_type[] = { + { CODEC_ID_MPEG4 , 32 }, + { CODEC_ID_H264 , 33 }, + { CODEC_ID_AAC , 64 }, + { CODEC_ID_MPEG2VIDEO, 96 }, /* MPEG2 Simple */ + { CODEC_ID_MPEG2VIDEO, 97 }, /* MPEG2 Main */ + { CODEC_ID_MPEG2VIDEO, 98 }, /* MPEG2 SNR */ + { CODEC_ID_MPEG2VIDEO, 99 }, /* MPEG2 Spatial */ + { CODEC_ID_MPEG2VIDEO, 100 }, /* MPEG2 High */ + { CODEC_ID_MPEG2VIDEO, 101 }, /* MPEG2 422 */ + { CODEC_ID_AAC , 102 }, /* MPEG2 AAC Main */ + { CODEC_ID_AAC , 103 }, /* MPEG2 AAC Low */ + { CODEC_ID_AAC , 104 }, /* MPEG2 AAC SSR */ + { CODEC_ID_MP3 , 105 }, + { CODEC_ID_MPEG1VIDEO, 106 }, + { CODEC_ID_MP2 , 107 }, + { CODEC_ID_MJPEG , 108 }, + { CODEC_ID_PCM_S16LE , 224 }, + { CODEC_ID_VORBIS , 221 }, + { CODEC_ID_AC3 , 226 }, + { CODEC_ID_PCM_ALAW , 227 }, + { CODEC_ID_PCM_MULAW , 228 }, + { CODEC_ID_PCM_S16BE , 230 }, + { CODEC_ID_H263 , 242 }, + { CODEC_ID_H261 , 243 }, + { 0, 0 }, +}; + +/* map numeric codes from mdhd atom to ISO 639 */ +/* cf. QTFileFormat.pdf p253, qtff.pdf p205 */ +/* http://developer.apple.com/documentation/mac/Text/Text-368.html */ +/* deprecated by putting the code as 3*5bit ascii */ +static const char *mov_mdhd_language_map[] = { + /* 0-9 */ + "eng", "fra", "ger", "ita", "dut", "sve", "spa", "dan", "por", "nor", + "heb", "jpn", "ara", "fin", "gre", "ice", "mlt", "tur", "hr "/*scr*/, "chi"/*ace?*/, + "urd", "hin", "tha", "kor", "lit", "pol", "hun", "est", "lav", NULL, + "fo ", NULL, "rus", "chi", NULL, "iri", "alb", "ron", "ces", "slk", + "slv", "yid", "sr ", "mac", "bul", "ukr", "bel", "uzb", "kaz", "aze", + /*?*/ + "aze", "arm", "geo", "mol", "kir", "tgk", "tuk", "mon", NULL, "pus", + "kur", "kas", "snd", "tib", "nep", "san", "mar", "ben", "asm", "guj", + "pa ", "ori", "mal", "kan", "tam", "tel", NULL, "bur", "khm", "lao", + /* roman? arabic? */ + "vie", "ind", "tgl", "may", "may", "amh", "tir", "orm", "som", "swa", + /*==rundi?*/ + NULL, "run", NULL, "mlg", "epo", NULL, NULL, NULL, NULL, NULL, + /* 100 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "wel", "baq", + "cat", "lat", "que", "grn", "aym", "tat", "uig", "dzo", "jav" +}; + +int ff_mov_iso639_to_lang(const char *lang, int mp4) +{ + int i, code = 0; + + /* old way, only for QT? */ + for (i = 0; !mp4 && (i < (sizeof(mov_mdhd_language_map)/sizeof(char *))); i++) { + if (mov_mdhd_language_map[i] && !strcmp(lang, mov_mdhd_language_map[i])) + return i; + } + /* XXX:can we do that in mov too? */ + if (!mp4) + return 0; + /* handle undefined as such */ + if (lang[0] == '\0') + lang = "und"; + /* 5bit ascii */ + for (i = 0; i < 3; i++) { + unsigned char c = (unsigned char)lang[i]; + if (c < 0x60) + return 0; + if (c > 0x60 + 0x1f) + return 0; + code <<= 5; + code |= (c - 0x60); + } + return code; +} + +int ff_mov_lang_to_iso639(int code, char *to) +{ + int i; + /* is it the mangled iso code? */ + /* see http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt */ + if (code > 138) { + for (i = 2; i >= 0; i--) { + to[i] = 0x60 + (code & 0x1f); + code >>= 5; + } + return 1; + } + /* old fashion apple lang code */ + if (code >= (sizeof(mov_mdhd_language_map)/sizeof(char *))) + return 0; + if (!mov_mdhd_language_map[code]) + return 0; + strncpy(to, mov_mdhd_language_map[code], 4); + return 1; +} diff --git a/libavformat/isom.h b/libavformat/isom.h new file mode 100644 index 0000000000..90a4ed0a37 --- /dev/null +++ b/libavformat/isom.h @@ -0,0 +1,15 @@ +#ifndef FFMPEG_ISOM_H +#define FFMPEG_ISOM_H + +/* isom.c */ +extern const CodecTag ff_mov_obj_type[]; + +int ff_mov_iso639_to_lang(const char *lang, int mp4); +int ff_mov_lang_to_iso639(int code, char *to); + +typedef struct Time2Sample{ + int count; + int duration; +}Time2Sample; + +#endif /* FFMPEG_ISOM_H */ diff --git a/libavformat/mov.c b/libavformat/mov.c index bba84d40dc..0b3380ea50 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -23,7 +23,7 @@ #include "avformat.h" #include "riff.h" -#include "mov.h" +#include "isom.h" #ifdef CONFIG_ZLIB #include <zlib.h> @@ -63,35 +63,6 @@ #undef NDEBUG #include <assert.h> -/* http://gpac.sourceforge.net/tutorial/mediatypes.htm */ -const CodecTag ff_mov_obj_type[] = { - { CODEC_ID_MPEG4 , 32 }, - { CODEC_ID_H264 , 33 }, - { CODEC_ID_AAC , 64 }, - { CODEC_ID_MPEG2VIDEO, 96 }, /* MPEG2 Simple */ - { CODEC_ID_MPEG2VIDEO, 97 }, /* MPEG2 Main */ - { CODEC_ID_MPEG2VIDEO, 98 }, /* MPEG2 SNR */ - { CODEC_ID_MPEG2VIDEO, 99 }, /* MPEG2 Spatial */ - { CODEC_ID_MPEG2VIDEO, 100 }, /* MPEG2 High */ - { CODEC_ID_MPEG2VIDEO, 101 }, /* MPEG2 422 */ - { CODEC_ID_AAC , 102 }, /* MPEG2 AAC Main */ - { CODEC_ID_AAC , 103 }, /* MPEG2 AAC Low */ - { CODEC_ID_AAC , 104 }, /* MPEG2 AAC SSR */ - { CODEC_ID_MP3 , 105 }, - { CODEC_ID_MPEG1VIDEO, 106 }, - { CODEC_ID_MP2 , 107 }, - { CODEC_ID_MJPEG , 108 }, - { CODEC_ID_PCM_S16LE , 224 }, - { CODEC_ID_VORBIS , 221 }, - { CODEC_ID_AC3 , 226 }, - { CODEC_ID_PCM_ALAW , 227 }, - { CODEC_ID_PCM_MULAW , 228 }, - { CODEC_ID_PCM_S16BE , 230 }, - { CODEC_ID_H263 , 242 }, - { CODEC_ID_H261 , 243 }, - { 0, 0 }, -}; - static const CodecTag mov_video_tags[] = { /* { CODEC_ID_, MKTAG('c', 'v', 'i', 'd') }, *//* Cinepak */ /* { CODEC_ID_H263, MKTAG('r', 'a', 'w', ' ') }, *//* Uncompressed RGB */ @@ -178,32 +149,6 @@ static const CodecTag mov_audio_tags[] = { { CODEC_ID_NONE, 0 }, }; -/* map numeric codes from mdhd atom to ISO 639 */ -/* cf. QTFileFormat.pdf p253, qtff.pdf p205 */ -/* http://developer.apple.com/documentation/mac/Text/Text-368.html */ -/* deprecated by putting the code as 3*5bit ascii */ -static const char *mov_mdhd_language_map[] = { -/* 0-9 */ -"eng", "fra", "ger", "ita", "dut", "sve", "spa", "dan", "por", "nor", -"heb", "jpn", "ara", "fin", "gre", "ice", "mlt", "tur", "hr "/*scr*/, "chi"/*ace?*/, -"urd", "hin", "tha", "kor", "lit", "pol", "hun", "est", "lav", NULL, -"fo ", NULL, "rus", "chi", NULL, "iri", "alb", "ron", "ces", "slk", -"slv", "yid", "sr ", "mac", "bul", "ukr", "bel", "uzb", "kaz", "aze", -/*?*/ -"aze", "arm", "geo", "mol", "kir", "tgk", "tuk", "mon", NULL, "pus", -"kur", "kas", "snd", "tib", "nep", "san", "mar", "ben", "asm", "guj", -"pa ", "ori", "mal", "kan", "tam", "tel", NULL, "bur", "khm", "lao", -/* roman? arabic? */ -"vie", "ind", "tgl", "may", "may", "amh", "tir", "orm", "som", "swa", -/*==rundi?*/ - NULL, "run", NULL, "mlg", "epo", NULL, NULL, NULL, NULL, NULL, -/* 100 */ - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "wel", "baq", -"cat", "lat", "que", "grn", "aym", "tat", "uig", "dzo", "jav" -}; - /* the QuickTime file format is quite convoluted... * it has lots of index tables, each indexing something in another one... * Here we just use what is needed to read the chunks @@ -351,55 +296,6 @@ typedef struct MOVParseTableEntry { mov_parse_function func; } MOVParseTableEntry; -static int ff_mov_lang_to_iso639(int code, char *to) -{ - int i; - /* is it the mangled iso code? */ - /* see http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt */ - if (code > 138) { - for (i = 2; i >= 0; i--) { - to[i] = 0x60 + (code & 0x1f); - code >>= 5; - } - return 1; - } - /* old fashion apple lang code */ - if (code >= (sizeof(mov_mdhd_language_map)/sizeof(char *))) - return 0; - if (!mov_mdhd_language_map[code]) - return 0; - strncpy(to, mov_mdhd_language_map[code], 4); - return 1; -} - -int ff_mov_iso639_to_lang(const char *lang, int mp4) -{ - int i, code = 0; - - /* old way, only for QT? */ - for (i = 0; !mp4 && (i < (sizeof(mov_mdhd_language_map)/sizeof(char *))); i++) { - if (mov_mdhd_language_map[i] && !strcmp(lang, mov_mdhd_language_map[i])) - return i; - } - /* XXX:can we do that in mov too? */ - if (!mp4) - return 0; - /* handle undefined as such */ - if (lang[0] == '\0') - lang = "und"; - /* 5bit ascii */ - for (i = 0; i < 3; i++) { - unsigned char c = (unsigned char)lang[i]; - if (c < 0x60) - return 0; - if (c > 0x60 + 0x1f) - return 0; - code <<= 5; - code |= (c - 0x60); - } - return code; -} - static int mov_read_leaf(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) { if (atom.size>1) diff --git a/libavformat/mov.h b/libavformat/mov.h deleted file mode 100644 index 8b87c41afa..0000000000 --- a/libavformat/mov.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef FFMPEG_MOV_H -#define FFMPEG_MOV_H - -/* mov.c */ -extern const CodecTag ff_mov_obj_type[]; -extern int ff_mov_iso639_to_lang(const char *lang, int mp4); - -typedef struct Time2Sample{ - int count; - int duration; -}Time2Sample; - -#endif /* FFMPEG_MOV_H */ diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 37c118c3d9..de9b4a5f25 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -20,7 +20,7 @@ #include "avformat.h" #include "riff.h" #include "avio.h" -#include "mov.h" +#include "isom.h" #undef NDEBUG #include <assert.h> |