00001 /* 00002 * ISO Media common code 00003 * copyright (c) 2001 Fabrice Bellard 00004 * copyright (c) 2002 Francois Revol <revol@free.fr> 00005 * copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr> 00006 * 00007 * This file is part of FFmpeg. 00008 * 00009 * FFmpeg is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * FFmpeg is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with FFmpeg; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 */ 00023 00024 #ifndef AVFORMAT_ISOM_H 00025 #define AVFORMAT_ISOM_H 00026 00027 #include "avio.h" 00028 #include "riff.h" 00029 #include "dv.h" 00030 00031 /* isom.c */ 00032 extern const AVCodecTag ff_mp4_obj_type[]; 00033 extern const AVCodecTag codec_movvideo_tags[]; 00034 extern const AVCodecTag codec_movaudio_tags[]; 00035 extern const AVCodecTag ff_codec_movsubtitle_tags[]; 00036 00037 int ff_mov_iso639_to_lang(const char lang[4], int mp4); 00038 int ff_mov_lang_to_iso639(unsigned code, char to[4]); 00039 00040 /* the QuickTime file format is quite convoluted... 00041 * it has lots of index tables, each indexing something in another one... 00042 * Here we just use what is needed to read the chunks 00043 */ 00044 00045 typedef struct { 00046 int count; 00047 int duration; 00048 } MOVStts; 00049 00050 typedef struct { 00051 int first; 00052 int count; 00053 int id; 00054 } MOVStsc; 00055 00056 typedef struct { 00057 uint32_t type; 00058 char *path; 00059 char *dir; 00060 char volume[28]; 00061 char filename[64]; 00062 int16_t nlvl_to, nlvl_from; 00063 } MOVDref; 00064 00065 typedef struct { 00066 uint32_t type; 00067 int64_t size; /* total size (excluding the size and type fields) */ 00068 } MOVAtom; 00069 00070 struct MOVParseTableEntry; 00071 00072 typedef struct { 00073 unsigned track_id; 00074 uint64_t base_data_offset; 00075 uint64_t moof_offset; 00076 unsigned stsd_id; 00077 unsigned duration; 00078 unsigned size; 00079 unsigned flags; 00080 } MOVFragment; 00081 00082 typedef struct { 00083 unsigned track_id; 00084 unsigned stsd_id; 00085 unsigned duration; 00086 unsigned size; 00087 unsigned flags; 00088 } MOVTrackExt; 00089 00090 typedef struct MOVStreamContext { 00091 ByteIOContext *pb; 00092 int ffindex; 00093 int next_chunk; 00094 unsigned int chunk_count; 00095 int64_t *chunk_offsets; 00096 unsigned int stts_count; 00097 MOVStts *stts_data; 00098 unsigned int ctts_count; 00099 MOVStts *ctts_data; 00100 unsigned int stsc_count; 00101 MOVStsc *stsc_data; 00102 unsigned int stps_count; 00103 unsigned *stps_data; 00104 int ctts_index; 00105 int ctts_sample; 00106 unsigned int sample_size; 00107 unsigned int sample_count; 00108 int *sample_sizes; 00109 unsigned int keyframe_count; 00110 int *keyframes; 00111 int time_scale; 00112 int time_offset; 00113 int current_sample; 00114 unsigned int bytes_per_frame; 00115 unsigned int samples_per_frame; 00116 int dv_audio_container; 00117 int pseudo_stream_id; 00118 int16_t audio_cid; 00119 unsigned drefs_count; 00120 MOVDref *drefs; 00121 int dref_id; 00122 int wrong_dts; 00123 int width; 00124 int height; 00125 int dts_shift; 00126 } MOVStreamContext; 00127 00128 typedef struct MOVContext { 00129 AVFormatContext *fc; 00130 int time_scale; 00131 int64_t duration; 00132 int found_moov; 00133 int found_mdat; 00134 DVDemuxContext *dv_demux; 00135 AVFormatContext *dv_fctx; 00136 int isom; 00137 MOVFragment fragment; 00138 MOVTrackExt *trex_data; 00139 unsigned trex_count; 00140 int itunes_metadata; 00141 int chapter_track; 00142 } MOVContext; 00143 00144 int ff_mp4_read_descr_len(ByteIOContext *pb); 00145 int ff_mov_read_esds(AVFormatContext *fc, ByteIOContext *pb, MOVAtom atom); 00146 enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags); 00147 00148 #endif /* AVFORMAT_ISOM_H */