annotate ffmpeg/libavformat/isom.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * ISO Media common code
yading@11 3 * copyright (c) 2001 Fabrice Bellard
yading@11 4 * copyright (c) 2002 Francois Revol <revol@free.fr>
yading@11 5 * copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr>
yading@11 6 *
yading@11 7 * This file is part of FFmpeg.
yading@11 8 *
yading@11 9 * FFmpeg is free software; you can redistribute it and/or
yading@11 10 * modify it under the terms of the GNU Lesser General Public
yading@11 11 * License as published by the Free Software Foundation; either
yading@11 12 * version 2.1 of the License, or (at your option) any later version.
yading@11 13 *
yading@11 14 * FFmpeg is distributed in the hope that it will be useful,
yading@11 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 17 * Lesser General Public License for more details.
yading@11 18 *
yading@11 19 * You should have received a copy of the GNU Lesser General Public
yading@11 20 * License along with FFmpeg; if not, write to the Free Software
yading@11 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 22 */
yading@11 23
yading@11 24 #ifndef AVFORMAT_ISOM_H
yading@11 25 #define AVFORMAT_ISOM_H
yading@11 26
yading@11 27 #include "avio.h"
yading@11 28 #include "internal.h"
yading@11 29 #include "dv.h"
yading@11 30
yading@11 31 /* isom.c */
yading@11 32 extern const AVCodecTag ff_mp4_obj_type[];
yading@11 33 extern const AVCodecTag ff_codec_movvideo_tags[];
yading@11 34 extern const AVCodecTag ff_codec_movaudio_tags[];
yading@11 35 extern const AVCodecTag ff_codec_movsubtitle_tags[];
yading@11 36
yading@11 37 int ff_mov_iso639_to_lang(const char lang[4], int mp4);
yading@11 38 int ff_mov_lang_to_iso639(unsigned code, char to[4]);
yading@11 39
yading@11 40 /* the QuickTime file format is quite convoluted...
yading@11 41 * it has lots of index tables, each indexing something in another one...
yading@11 42 * Here we just use what is needed to read the chunks
yading@11 43 */
yading@11 44
yading@11 45 typedef struct MOVStts {
yading@11 46 int count;
yading@11 47 int duration;
yading@11 48 } MOVStts;
yading@11 49
yading@11 50 typedef struct MOVStsc {
yading@11 51 int first;
yading@11 52 int count;
yading@11 53 int id;
yading@11 54 } MOVStsc;
yading@11 55
yading@11 56 typedef struct MOVDref {
yading@11 57 uint32_t type;
yading@11 58 char *path;
yading@11 59 char *dir;
yading@11 60 char volume[28];
yading@11 61 char filename[64];
yading@11 62 int16_t nlvl_to, nlvl_from;
yading@11 63 } MOVDref;
yading@11 64
yading@11 65 typedef struct MOVAtom {
yading@11 66 uint32_t type;
yading@11 67 int64_t size; /* total size (excluding the size and type fields) */
yading@11 68 } MOVAtom;
yading@11 69
yading@11 70 struct MOVParseTableEntry;
yading@11 71
yading@11 72 typedef struct MOVFragment {
yading@11 73 unsigned track_id;
yading@11 74 uint64_t base_data_offset;
yading@11 75 uint64_t moof_offset;
yading@11 76 unsigned stsd_id;
yading@11 77 unsigned duration;
yading@11 78 unsigned size;
yading@11 79 unsigned flags;
yading@11 80 } MOVFragment;
yading@11 81
yading@11 82 typedef struct MOVTrackExt {
yading@11 83 unsigned track_id;
yading@11 84 unsigned stsd_id;
yading@11 85 unsigned duration;
yading@11 86 unsigned size;
yading@11 87 unsigned flags;
yading@11 88 } MOVTrackExt;
yading@11 89
yading@11 90 typedef struct MOVSbgp {
yading@11 91 unsigned int count;
yading@11 92 unsigned int index;
yading@11 93 } MOVSbgp;
yading@11 94
yading@11 95 typedef struct MOVStreamContext {
yading@11 96 AVIOContext *pb;
yading@11 97 int pb_is_copied;
yading@11 98 int ffindex; ///< AVStream index
yading@11 99 int next_chunk;
yading@11 100 unsigned int chunk_count;
yading@11 101 int64_t *chunk_offsets;
yading@11 102 unsigned int stts_count;
yading@11 103 MOVStts *stts_data;
yading@11 104 unsigned int ctts_count;
yading@11 105 MOVStts *ctts_data;
yading@11 106 unsigned int stsc_count;
yading@11 107 MOVStsc *stsc_data;
yading@11 108 unsigned int stps_count;
yading@11 109 unsigned *stps_data; ///< partial sync sample for mpeg-2 open gop
yading@11 110 int ctts_index;
yading@11 111 int ctts_sample;
yading@11 112 unsigned int sample_size; ///< may contain value calculated from stsd or value from stsz atom
yading@11 113 unsigned int alt_sample_size; ///< always contains sample size from stsz atom
yading@11 114 unsigned int sample_count;
yading@11 115 int *sample_sizes;
yading@11 116 int keyframe_absent;
yading@11 117 unsigned int keyframe_count;
yading@11 118 int *keyframes;
yading@11 119 int time_scale;
yading@11 120 int64_t empty_duration; ///< empty duration of the first edit list entry
yading@11 121 int64_t start_time; ///< start time of the media
yading@11 122 int64_t time_offset; ///< time offset of the edit list entries
yading@11 123 int current_sample;
yading@11 124 unsigned int bytes_per_frame;
yading@11 125 unsigned int samples_per_frame;
yading@11 126 int dv_audio_container;
yading@11 127 int pseudo_stream_id; ///< -1 means demux all ids
yading@11 128 int16_t audio_cid; ///< stsd audio compression id
yading@11 129 unsigned drefs_count;
yading@11 130 MOVDref *drefs;
yading@11 131 int dref_id;
yading@11 132 int timecode_track;
yading@11 133 int wrong_dts; ///< dts are wrong due to huge ctts offset (iMovie files)
yading@11 134 int width; ///< tkhd width
yading@11 135 int height; ///< tkhd height
yading@11 136 int dts_shift; ///< dts shift when ctts is negative
yading@11 137 uint32_t palette[256];
yading@11 138 int has_palette;
yading@11 139 int64_t data_size;
yading@11 140 uint32_t tmcd_flags; ///< tmcd track flags
yading@11 141 int64_t track_end; ///< used for dts generation in fragmented movie files
yading@11 142 int start_pad; ///< amount of samples to skip due to enc-dec delay
yading@11 143 unsigned int rap_group_count;
yading@11 144 MOVSbgp *rap_group;
yading@11 145 } MOVStreamContext;
yading@11 146
yading@11 147 typedef struct MOVContext {
yading@11 148 AVClass *avclass;
yading@11 149 AVFormatContext *fc;
yading@11 150 int time_scale;
yading@11 151 int64_t duration; ///< duration of the longest track
yading@11 152 int found_moov; ///< 'moov' atom has been found
yading@11 153 int found_mdat; ///< 'mdat' atom has been found
yading@11 154 DVDemuxContext *dv_demux;
yading@11 155 AVFormatContext *dv_fctx;
yading@11 156 int isom; ///< 1 if file is ISO Media (mp4/3gp)
yading@11 157 MOVFragment fragment; ///< current fragment in moof atom
yading@11 158 MOVTrackExt *trex_data;
yading@11 159 unsigned trex_count;
yading@11 160 int itunes_metadata; ///< metadata are itunes style
yading@11 161 int chapter_track;
yading@11 162 int use_absolute_path;
yading@11 163 int ignore_editlist;
yading@11 164 int64_t next_root_atom; ///< offset of the next root atom
yading@11 165 } MOVContext;
yading@11 166
yading@11 167 int ff_mp4_read_descr_len(AVIOContext *pb);
yading@11 168 int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag);
yading@11 169 int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb);
yading@11 170 void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
yading@11 171
yading@11 172 #define MP4ODescrTag 0x01
yading@11 173 #define MP4IODescrTag 0x02
yading@11 174 #define MP4ESDescrTag 0x03
yading@11 175 #define MP4DecConfigDescrTag 0x04
yading@11 176 #define MP4DecSpecificDescrTag 0x05
yading@11 177 #define MP4SLDescrTag 0x06
yading@11 178
yading@11 179 #define MOV_TFHD_BASE_DATA_OFFSET 0x01
yading@11 180 #define MOV_TFHD_STSD_ID 0x02
yading@11 181 #define MOV_TFHD_DEFAULT_DURATION 0x08
yading@11 182 #define MOV_TFHD_DEFAULT_SIZE 0x10
yading@11 183 #define MOV_TFHD_DEFAULT_FLAGS 0x20
yading@11 184 #define MOV_TFHD_DURATION_IS_EMPTY 0x010000
yading@11 185
yading@11 186 #define MOV_TRUN_DATA_OFFSET 0x01
yading@11 187 #define MOV_TRUN_FIRST_SAMPLE_FLAGS 0x04
yading@11 188 #define MOV_TRUN_SAMPLE_DURATION 0x100
yading@11 189 #define MOV_TRUN_SAMPLE_SIZE 0x200
yading@11 190 #define MOV_TRUN_SAMPLE_FLAGS 0x400
yading@11 191 #define MOV_TRUN_SAMPLE_CTS 0x800
yading@11 192
yading@11 193 #define MOV_FRAG_SAMPLE_FLAG_DEGRADATION_PRIORITY_MASK 0x0000ffff
yading@11 194 #define MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC 0x00010000
yading@11 195 #define MOV_FRAG_SAMPLE_FLAG_PADDING_MASK 0x000e0000
yading@11 196 #define MOV_FRAG_SAMPLE_FLAG_REDUNDANCY_MASK 0x00300000
yading@11 197 #define MOV_FRAG_SAMPLE_FLAG_DEPENDED_MASK 0x00c00000
yading@11 198 #define MOV_FRAG_SAMPLE_FLAG_DEPENDS_MASK 0x03000000
yading@11 199
yading@11 200 #define MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO 0x02000000
yading@11 201 #define MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES 0x01000000
yading@11 202
yading@11 203 int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom);
yading@11 204 enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags);
yading@11 205
yading@11 206 int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries);
yading@11 207 void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout);
yading@11 208
yading@11 209 #endif /* AVFORMAT_ISOM_H */