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 MOVStreamContext {
00091 AVIOContext *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 alt_sample_size;
00108 unsigned int sample_count;
00109 int *sample_sizes;
00110 int keyframe_absent;
00111 unsigned int keyframe_count;
00112 int *keyframes;
00113 int time_scale;
00114 int64_t empty_duration;
00115 int64_t start_time;
00116 int64_t time_offset;
00117 int current_sample;
00118 unsigned int bytes_per_frame;
00119 unsigned int samples_per_frame;
00120 int dv_audio_container;
00121 int pseudo_stream_id;
00122 int16_t audio_cid;
00123 unsigned drefs_count;
00124 MOVDref *drefs;
00125 int dref_id;
00126 int wrong_dts;
00127 int width;
00128 int height;
00129 int dts_shift;
00130 uint32_t palette[256];
00131 int has_palette;
00132 int64_t data_size;
00133 uint32_t tmcd_flags;
00134 int64_t track_end;
00135 } MOVStreamContext;
00136
00137 typedef struct MOVContext {
00138 AVClass *avclass;
00139 AVFormatContext *fc;
00140 int time_scale;
00141 int64_t duration;
00142 int found_moov;
00143 int found_mdat;
00144 DVDemuxContext *dv_demux;
00145 AVFormatContext *dv_fctx;
00146 int isom;
00147 MOVFragment fragment;
00148 MOVTrackExt *trex_data;
00149 unsigned trex_count;
00150 int itunes_metadata;
00151 int chapter_track;
00152 int use_absolute_path;
00153 int64_t next_root_atom;
00154 } MOVContext;
00155
00156 int ff_mp4_read_descr_len(AVIOContext *pb);
00157 int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag);
00158 int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb);
00159 void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
00160
00161 #define MP4ODescrTag 0x01
00162 #define MP4IODescrTag 0x02
00163 #define MP4ESDescrTag 0x03
00164 #define MP4DecConfigDescrTag 0x04
00165 #define MP4DecSpecificDescrTag 0x05
00166 #define MP4SLDescrTag 0x06
00167
00168 #define MOV_TFHD_BASE_DATA_OFFSET 0x01
00169 #define MOV_TFHD_STSD_ID 0x02
00170 #define MOV_TFHD_DEFAULT_DURATION 0x08
00171 #define MOV_TFHD_DEFAULT_SIZE 0x10
00172 #define MOV_TFHD_DEFAULT_FLAGS 0x20
00173 #define MOV_TFHD_DURATION_IS_EMPTY 0x010000
00174
00175 #define MOV_TRUN_DATA_OFFSET 0x01
00176 #define MOV_TRUN_FIRST_SAMPLE_FLAGS 0x04
00177 #define MOV_TRUN_SAMPLE_DURATION 0x100
00178 #define MOV_TRUN_SAMPLE_SIZE 0x200
00179 #define MOV_TRUN_SAMPLE_FLAGS 0x400
00180 #define MOV_TRUN_SAMPLE_CTS 0x800
00181
00182 #define MOV_FRAG_SAMPLE_FLAG_DEGRADATION_PRIORITY_MASK 0x0000ffff
00183 #define MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC 0x00010000
00184 #define MOV_FRAG_SAMPLE_FLAG_PADDING_MASK 0x000e0000
00185 #define MOV_FRAG_SAMPLE_FLAG_REDUNDANCY_MASK 0x00300000
00186 #define MOV_FRAG_SAMPLE_FLAG_DEPENDED_MASK 0x00c00000
00187 #define MOV_FRAG_SAMPLE_FLAG_DEPENDS_MASK 0x03000000
00188
00189 #define MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO 0x02000000
00190 #define MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES 0x01000000
00191
00192 int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom);
00193 enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags);
00194
00195 int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries);
00196 void ff_mov_read_chan(AVFormatContext *s, int64_t size, AVCodecContext *codec);
00197 void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout);
00198
00199 #endif