00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef AVFORMAT_ISOM_H
00025 #define AVFORMAT_ISOM_H
00026
00027 #include "avio.h"
00028 #include "internal.h"
00029 #include "dv.h"
00030
00031
00032 extern const AVCodecTag ff_mp4_obj_type[];
00033 extern const AVCodecTag ff_codec_movvideo_tags[];
00034 extern const AVCodecTag ff_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
00041
00042
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;
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 {
00091 unsigned int count;
00092 unsigned int index;
00093 } MOVSbgp;
00094
00095 typedef struct MOVStreamContext {
00096 AVIOContext *pb;
00097 int ffindex;
00098 int next_chunk;
00099 unsigned int chunk_count;
00100 int64_t *chunk_offsets;
00101 unsigned int stts_count;
00102 MOVStts *stts_data;
00103 unsigned int ctts_count;
00104 MOVStts *ctts_data;
00105 unsigned int stsc_count;
00106 MOVStsc *stsc_data;
00107 unsigned int stps_count;
00108 unsigned *stps_data;
00109 int ctts_index;
00110 int ctts_sample;
00111 unsigned int sample_size;
00112 unsigned int alt_sample_size;
00113 unsigned int sample_count;
00114 int *sample_sizes;
00115 int keyframe_absent;
00116 unsigned int keyframe_count;
00117 int *keyframes;
00118 int time_scale;
00119 int64_t empty_duration;
00120 int64_t start_time;
00121 int64_t time_offset;
00122 int current_sample;
00123 unsigned int bytes_per_frame;
00124 unsigned int samples_per_frame;
00125 int dv_audio_container;
00126 int pseudo_stream_id;
00127 int16_t audio_cid;
00128 unsigned drefs_count;
00129 MOVDref *drefs;
00130 int dref_id;
00131 unsigned tref_type;
00132 unsigned trefs_count;
00133 uint32_t *trefs;
00134 int wrong_dts;
00135 int width;
00136 int height;
00137 int dts_shift;
00138 uint32_t palette[256];
00139 int has_palette;
00140 int64_t data_size;
00141 uint32_t tmcd_flags;
00142 int64_t track_end;
00143 int start_pad;
00144 unsigned int rap_group_count;
00145 MOVSbgp *rap_group;
00146 } MOVStreamContext;
00147
00148 typedef struct MOVContext {
00149 AVClass *avclass;
00150 AVFormatContext *fc;
00151 int time_scale;
00152 int64_t duration;
00153 int found_moov;
00154 int found_mdat;
00155 DVDemuxContext *dv_demux;
00156 AVFormatContext *dv_fctx;
00157 int isom;
00158 MOVFragment fragment;
00159 MOVTrackExt *trex_data;
00160 unsigned trex_count;
00161 int itunes_metadata;
00162 int chapter_track;
00163 int use_absolute_path;
00164 int64_t next_root_atom;
00165 } MOVContext;
00166
00167 int ff_mp4_read_descr_len(AVIOContext *pb);
00168 int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag);
00169 int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb);
00170 void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
00171
00172 #define MP4ODescrTag 0x01
00173 #define MP4IODescrTag 0x02
00174 #define MP4ESDescrTag 0x03
00175 #define MP4DecConfigDescrTag 0x04
00176 #define MP4DecSpecificDescrTag 0x05
00177 #define MP4SLDescrTag 0x06
00178
00179 #define MOV_TFHD_BASE_DATA_OFFSET 0x01
00180 #define MOV_TFHD_STSD_ID 0x02
00181 #define MOV_TFHD_DEFAULT_DURATION 0x08
00182 #define MOV_TFHD_DEFAULT_SIZE 0x10
00183 #define MOV_TFHD_DEFAULT_FLAGS 0x20
00184 #define MOV_TFHD_DURATION_IS_EMPTY 0x010000
00185
00186 #define MOV_TRUN_DATA_OFFSET 0x01
00187 #define MOV_TRUN_FIRST_SAMPLE_FLAGS 0x04
00188 #define MOV_TRUN_SAMPLE_DURATION 0x100
00189 #define MOV_TRUN_SAMPLE_SIZE 0x200
00190 #define MOV_TRUN_SAMPLE_FLAGS 0x400
00191 #define MOV_TRUN_SAMPLE_CTS 0x800
00192
00193 #define MOV_FRAG_SAMPLE_FLAG_DEGRADATION_PRIORITY_MASK 0x0000ffff
00194 #define MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC 0x00010000
00195 #define MOV_FRAG_SAMPLE_FLAG_PADDING_MASK 0x000e0000
00196 #define MOV_FRAG_SAMPLE_FLAG_REDUNDANCY_MASK 0x00300000
00197 #define MOV_FRAG_SAMPLE_FLAG_DEPENDED_MASK 0x00c00000
00198 #define MOV_FRAG_SAMPLE_FLAG_DEPENDS_MASK 0x03000000
00199
00200 #define MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO 0x02000000
00201 #define MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES 0x01000000
00202
00203 int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom);
00204 enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags);
00205
00206 int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries);
00207 int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, int64_t size);
00208 void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout);
00209
00210 #endif