Mercurial > mplayer.hg
annotate libmpdemux/demux_mov.c @ 5373:b476f5d1c91e
10l to nick - ACCEPT_WIDTH fixed
author | arpi |
---|---|
date | Wed, 27 Mar 2002 21:49:19 +0000 |
parents | ee9dd55ef383 |
children | e1179cdffbf5 |
rev | line source |
---|---|
5372
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
1 //#define USE_QTX_CODECS |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
2 |
2148 | 3 // QuickTime MOV file parser by A'rpi |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
4 // additional work by Atmos |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
5 // based on TOOLS/movinfo.c by A'rpi & Al3x |
2148 | 6 // compressed header support from moov.c of the openquicktime lib. |
2386 | 7 // References: http://openquicktime.sf.net/, http://www.heroinewarrior.com/ |
2542 | 8 // http://www.geocities.com/SiliconValley/Lakes/2160/fformats/files/mov.pdf |
5242
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
9 // (above url no longer works, file mirrored somewhere? ::atmos) |
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
10 // The QuickTime File Format PDF from Apple: |
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
11 // http://developer.apple.com/techpubs/quicktime/qtdevdocs/PDF/QTFileFormat.pdf |
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
12 // (Complete list of documentation at http://developer.apple.com/quicktime/) |
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
13 // MP4-Lib sources from http://mpeg4ip.sf.net/ might be usefull fot .mp4 |
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
14 // aswell as .mov specific stuff. |
5254
142ea546abb5
Add a usefull url, btw. audio esds needs some fixing with some files, I'll investigate.
atmos4
parents:
5252
diff
changeset
|
15 // All sort of Stuff about MPEG4: |
142ea546abb5
Add a usefull url, btw. audio esds needs some fixing with some files, I'll investigate.
atmos4
parents:
5252
diff
changeset
|
16 // http://www.cmlab.csie.ntu.edu.tw/~pkhsiao/thesis.html |
5257 | 17 // I really recommend N4270-1.doc and N4270-2.doc which are exact specs |
18 // of the MP4-File Format and the MPEG4 Specific extensions. ::atmos | |
1490 | 19 |
20 #include <stdio.h> | |
21 #include <stdlib.h> | |
22 #include <unistd.h> | |
23 | |
1567 | 24 #include "config.h" |
25 #include "mp_msg.h" | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1567
diff
changeset
|
26 #include "help_mp.h" |
1490 | 27 |
28 #include "stream.h" | |
29 #include "demuxer.h" | |
30 #include "stheader.h" | |
31 | |
2386 | 32 #include "bswap.h" |
33 | |
4332 | 34 #include "qtpalette.h" |
5301 | 35 #include "parse_mp4.h" // MP3 specific stuff |
4332 | 36 |
5372
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
37 #ifdef USE_QTX_CODECS |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
38 #include "../loader/qtx/qtxsdk/components.h" |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
39 #endif |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
40 |
2148 | 41 #ifdef HAVE_ZLIB |
42 #include <zlib.h> | |
43 #endif | |
44 | |
2786 | 45 #include <fcntl.h> |
46 | |
4129
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
47 #define BE_16(x) (be2me_16(*(unsigned short *)(x))) |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
48 #define BE_32(x) (be2me_32(*(unsigned int *)(x))) |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
49 |
5301 | 50 #ifndef WORDS_BIGENDIAN |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
51 #define char2short(x,y) ((x[y]<<8)|x[y+1]) |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
52 #define char2int(x,y) ((x[y]<<24)|(x[y+1]<<16)|(x[y+2]<<8)|x[y+3]) |
5301 | 53 #else |
54 #warning Check the implementation of char2short and char2int on BIGENDIAN!!! | |
55 #define char2short(x,y) (x[y]|(x[y+1]<<8)) | |
56 #define char2int(x,y) (x[y]|(x[y+1]<<8)|(x[y+2]<<16)|(x[y+3]<<24)) | |
57 #endif | |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
58 |
1490 | 59 typedef struct { |
2100 | 60 unsigned int pts; // duration |
61 unsigned int size; | |
62 off_t pos; | |
63 } mov_sample_t; | |
64 | |
65 typedef struct { | |
2546
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
66 unsigned int sample; // number of the first sample in the chunk |
2115 | 67 unsigned int size; // number of samples in the chunk |
68 int desc; // for multiple codecs mode - not used | |
2100 | 69 off_t pos; |
70 } mov_chunk_t; | |
71 | |
72 typedef struct { | |
73 unsigned int first; | |
74 unsigned int spc; | |
75 unsigned int sdid; | |
76 } mov_chunkmap_t; | |
77 | |
78 typedef struct { | |
2115 | 79 unsigned int num; |
80 unsigned int dur; | |
81 } mov_durmap_t; | |
82 | |
4624 | 83 #define MOV_TRAK_UNKNOWN 0 |
84 #define MOV_TRAK_VIDEO 1 | |
85 #define MOV_TRAK_AUDIO 2 | |
86 #define MOV_TRAK_FLASH 3 | |
87 #define MOV_TRAK_GENERIC 4 | |
88 #define MOV_TRAK_CODE 5 | |
89 | |
2115 | 90 typedef struct { |
1490 | 91 int id; |
92 int type; | |
3999
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
93 off_t pos; |
2101 | 94 // |
1490 | 95 int timescale; |
2100 | 96 unsigned int length; |
2115 | 97 int samplesize; // 0 = variable |
98 int duration; // 0 = variable | |
1490 | 99 int width,height; // for video |
100 unsigned int fourcc; | |
2115 | 101 // |
2101 | 102 int tkdata_len; // track data |
103 unsigned char* tkdata; | |
104 int stdata_len; // stream data | |
105 unsigned char* stdata; | |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
106 // |
5252 | 107 unsigned char* stream_header; |
108 int stream_header_len; // if >0, this header should be sent before the 1st frame | |
109 // | |
2100 | 110 int samples_size; |
111 mov_sample_t* samples; | |
112 int chunks_size; | |
113 mov_chunk_t* chunks; | |
114 int chunkmap_size; | |
115 mov_chunkmap_t* chunkmap; | |
2115 | 116 int durmap_size; |
117 mov_durmap_t* durmap; | |
2544 | 118 int keyframes_size; |
119 unsigned int* keyframes; | |
5372
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
120 // |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
121 void* desc; // image/sound/etc description (pointer to ImageDescription etc) |
1490 | 122 } mov_track_t; |
123 | |
2100 | 124 void mov_build_index(mov_track_t* trak){ |
125 int i,j,s; | |
126 int last=trak->chunks_size; | |
2115 | 127 unsigned int pts=0; |
3652
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
128 |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
129 #if 0 |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
130 if (trak->chunks_size <= 0) |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
131 { |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
132 mp_msg(MSGT_DEMUX, MSGL_WARN, "No chunk offset table, trying to build one!\n"); |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
133 |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
134 trak->chunks_size = trak->samples_size; /* XXX: FIXME ! */ |
3652
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
135 trak->chunks = realloc(trak->chunks, sizeof(mov_chunk_t)*trak->chunks_size); |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
136 |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
137 for (i=0; i < trak->chunks_size; i++) |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
138 trak->chunks[i].pos = -1; |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
139 } |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
140 #endif |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
141 |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
142 mp_msg(MSGT_DEMUX, MSGL_HINT, "MOV track: %d chunks, %d samples\n",trak->chunks_size,trak->samples_size); |
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
143 mp_msg(MSGT_DEMUX, MSGL_HINT, "pts=%d scale=%d time=%5.3f\n",trak->length,trak->timescale,(float)trak->length/(float)trak->timescale); |
2546
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
144 |
2100 | 145 // process chunkmap: |
146 i=trak->chunkmap_size; | |
147 while(i>0){ | |
148 --i; | |
149 for(j=trak->chunkmap[i].first;j<last;j++){ | |
150 trak->chunks[j].desc=trak->chunkmap[i].sdid; | |
151 trak->chunks[j].size=trak->chunkmap[i].spc; | |
152 } | |
153 last=trak->chunkmap[i].first; | |
154 } | |
2115 | 155 |
3652
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
156 #if 0 |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
157 for (i=0; i < trak->chunks_size; i++) |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
158 { |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
159 /* fixup position */ |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
160 if (trak->chunks[i].pos == -1) |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
161 if (i > 0) |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
162 trak->chunks[i].pos = trak->chunks[i-1].pos + trak->chunks[i-1].size; |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
163 else |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
164 trak->chunks[i].pos = 0; /* FIXME: set initial pos */ |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
165 } |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
166 #endif |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
167 |
2115 | 168 // calc pts of chunks: |
169 s=0; | |
170 for(j=0;j<trak->chunks_size;j++){ | |
171 trak->chunks[j].sample=s; | |
172 s+=trak->chunks[j].size; | |
173 } | |
174 | |
4624 | 175 // workaround for fixed-size video frames (dv and uncompressed) |
176 if(!trak->samples_size && trak->type==MOV_TRAK_VIDEO){ | |
177 trak->samples_size=s; | |
178 trak->samples=malloc(sizeof(mov_sample_t)*s); | |
179 for(i=0;i<s;i++) | |
180 trak->samples[i].size=trak->samplesize; | |
181 trak->samplesize=0; | |
182 } | |
183 | |
2115 | 184 if(!trak->samples_size){ |
185 // constant sampesize | |
186 if(trak->durmap_size==1 || (trak->durmap_size==2 && trak->durmap[1].num==1)){ | |
2227 | 187 trak->duration=trak->durmap[0].dur; |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
188 } else mp_msg(MSGT_DEMUX, MSGL_ERR, "*** constant samplesize & variable duration not yet supported! ***\nContact the author if you have such sample file!\n"); |
2115 | 189 return; |
190 } | |
191 | |
192 // calc pts: | |
193 s=0; | |
194 for(j=0;j<trak->durmap_size;j++){ | |
195 for(i=0;i<trak->durmap[j].num;i++){ | |
196 trak->samples[s].pts=pts; | |
197 ++s; | |
198 pts+=trak->durmap[j].dur; | |
199 } | |
200 } | |
2100 | 201 |
202 // calc sample offsets | |
203 s=0; | |
204 for(j=0;j<trak->chunks_size;j++){ | |
205 off_t pos=trak->chunks[j].pos; | |
206 for(i=0;i<trak->chunks[j].size;i++){ | |
207 trak->samples[s].pos=pos; | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
208 mp_msg(MSGT_DEMUX, MSGL_DBG3, "Sample %5d: pts=%8d off=0x%08X size=%d\n",s, |
2100 | 209 trak->samples[s].pts, |
210 (int)trak->samples[s].pos, | |
211 trak->samples[s].size); | |
212 pos+=trak->samples[s].size; | |
213 ++s; | |
214 } | |
215 } | |
216 | |
217 } | |
218 | |
1490 | 219 #define MOV_MAX_TRACKS 256 |
220 | |
221 typedef struct { | |
222 off_t moov_start; | |
223 off_t moov_end; | |
224 off_t mdat_start; | |
225 off_t mdat_end; | |
226 int track_db; | |
227 mov_track_t* tracks[MOV_MAX_TRACKS]; | |
228 } mov_priv_t; | |
229 | |
230 #define MOV_FOURCC(a,b,c,d) ((a<<24)|(b<<16)|(c<<8)|(d)) | |
231 | |
232 int mov_check_file(demuxer_t* demuxer){ | |
233 int flags=0; | |
2879 | 234 int no=0; |
1490 | 235 mov_priv_t* priv=malloc(sizeof(mov_priv_t)); |
236 | |
1567 | 237 mp_msg(MSGT_DEMUX,MSGL_V,"Checking for MOV\n"); |
1490 | 238 |
239 memset(priv,0,sizeof(mov_priv_t)); | |
240 demuxer->priv=priv; | |
241 | |
242 while(1){ | |
3999
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
243 int skipped=8; |
1490 | 244 off_t len=stream_read_dword(demuxer->stream); |
245 unsigned int id=stream_read_dword(demuxer->stream); | |
246 if(stream_eof(demuxer->stream)) break; // EOF | |
3999
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
247 if (len == 1) /* real size is 64bits - cjb */ |
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
248 { |
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
249 #ifndef _LARGEFILE_SOURCE |
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
250 if (stream_read_dword(demuxer->stream) != 0) |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
251 mp_msg(MSGT_DEMUX, MSGL_WARN, "64bit file, but you've compiled MPlayer without LARGEFILE support!\n"); |
3999
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
252 len = stream_read_dword(demuxer->stream); |
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
253 #else |
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
254 len = stream_read_qword(demuxer->stream); |
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
255 #endif |
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
256 skipped += 8; |
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
257 } |
5241
126d5fd76a70
temporary disabled len=0 code due to reported loop errors
alex
parents:
5236
diff
changeset
|
258 #if 0 |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
259 else if (len == 0) /* deleted chunk */ |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
260 { |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
261 /* XXX: CJB! is this right? - alex */ |
5243 | 262 goto skip_chunk; |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
263 } |
5241
126d5fd76a70
temporary disabled len=0 code due to reported loop errors
alex
parents:
5236
diff
changeset
|
264 #endif |
3999
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
265 else if(len<8) break; // invalid chunk |
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
266 |
1490 | 267 switch(id){ |
5257 | 268 case MOV_FOURCC('f','t','y','p'): { |
269 int i; | |
270 unsigned int tmp; | |
271 // File Type Box (ftyp): | |
272 // char[4] major_brand (eg. 'isom') | |
273 // int minor_version (eg. 0x00000000) | |
274 // char[4] compatible_brands[] (eg. 'mp41') | |
275 // compatible_brands list spans to the end of box | |
276 #if 1 | |
277 tmp = stream_read_dword(demuxer->stream); | |
278 switch(tmp) { | |
279 case MOV_FOURCC('i','s','o','m'): | |
280 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: File-Type Major-Brand: ISO Media File\n"); | |
281 break; | |
282 default: | |
283 tmp = be2me_32(tmp); | |
284 mp_msg(MSGT_DEMUX,MSGL_WARN,"MOV: File-Type unknown Major-Brand: %.4s\n",&tmp); | |
285 } | |
286 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: File-Type Minor-Version: %d\n", | |
287 stream_read_dword(demuxer->stream)); | |
288 skipped += 8; | |
289 // List all compatible brands | |
290 for(i = 0; i < ((len-16)/4); i++) { | |
291 tmp = be2me_32(stream_read_dword(demuxer->stream)); | |
292 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: File-Type Compatible-Brands #%d: %.4s\n",i,&tmp); | |
293 skipped += 4; | |
294 } | |
295 #endif | |
296 } break; | |
1490 | 297 case MOV_FOURCC('m','o','o','v'): |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
298 // case MOV_FOURCC('c','m','o','v'): |
1567 | 299 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: Movie header found!\n"); |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
300 priv->moov_start=(off_t)stream_tell(demuxer->stream); |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
301 priv->moov_end=(off_t)priv->moov_start+len-skipped; |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
302 mp_msg(MSGT_DEMUX,MSGL_DBG2,"MOV: Movie header: start: %x end: %x\n", |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
303 priv->moov_start, priv->moov_end); |
1490 | 304 flags|=1; |
305 break; | |
306 case MOV_FOURCC('m','d','a','t'): | |
1567 | 307 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: Movie DATA found!\n"); |
1490 | 308 priv->mdat_start=stream_tell(demuxer->stream); |
3999
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
309 priv->mdat_end=priv->mdat_start+len-skipped; |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
310 mp_msg(MSGT_DEMUX,MSGL_DBG2,"MOV: Movie data: start: %x end: %x\n", |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
311 priv->mdat_start, priv->mdat_end); |
1490 | 312 flags|=2; |
313 break; | |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
314 case MOV_FOURCC('f','r','e','e'): |
2942 | 315 case MOV_FOURCC('s','k','i','p'): |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
316 case MOV_FOURCC('w','i','d','e'): |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
317 case MOV_FOURCC('j','u','n','k'): |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
318 mp_msg(MSGT_DEMUX,MSGL_DBG2,"MOV: free space (len: %d)\n", len); |
2546
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
319 /* unused, if you edit a mov, you can use space provided by free atoms (redefining it) */ |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
320 break; |
1490 | 321 default: |
2879 | 322 if(no==0) return 0; // first chunk is bad! |
4903
d8b465e3fd88
fixed some endian issues, like changing bswap_32() -> be2me_32(), and
melanson
parents:
4646
diff
changeset
|
323 id = be2me_32(id); |
1567 | 324 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: unknown chunk: %.4s %d\n",&id,(int)len); |
1490 | 325 } |
5243 | 326 skip_chunk: |
3999
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
327 if(!stream_skip(demuxer->stream,len-skipped)) break; |
2879 | 328 ++no; |
1490 | 329 } |
2148 | 330 |
331 if(flags==1) | |
332 mp_msg(MSGT_DEMUX,MSGL_WARN,"MOV: missing data (mdat) chunk! Maybe broken file...\n"); | |
333 else if(flags==2) | |
334 mp_msg(MSGT_DEMUX,MSGL_WARN,"MOV: missing header (moov/cmov) chunk! Maybe broken file...\n"); | |
1490 | 335 |
336 return (flags==3); | |
337 } | |
338 | |
339 static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak){ | |
340 mov_priv_t* priv=demuxer->priv; | |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
341 // printf("lschunks (level=%d,endpos=%x)\n", level, endpos); |
1490 | 342 while(1){ |
343 off_t pos; | |
344 off_t len; | |
345 unsigned int id; | |
346 // | |
347 pos=stream_tell(demuxer->stream); | |
2148 | 348 // printf("stream_tell==%d\n",pos); |
1490 | 349 if(pos>=endpos) return; // END |
350 len=stream_read_dword(demuxer->stream); | |
2148 | 351 // printf("len==%d\n",len); |
1490 | 352 if(len<8) return; // error |
353 len-=8; | |
354 id=stream_read_dword(demuxer->stream); | |
355 // | |
1567 | 356 mp_msg(MSGT_DEMUX,MSGL_DBG2,"lschunks %.4s %d\n",&id,(int)len); |
1490 | 357 // |
358 if(trak){ | |
359 switch(id){ | |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
360 case MOV_FOURCC('m','d','a','t'): { |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
361 mp_msg(MSGT_DEMUX,MSGL_WARN,"Hmm, strange MOV, parsing mdat in lschunks?\n"); |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
362 return; |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
363 } |
3071 | 364 case MOV_FOURCC('f','r','e','e'): |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
365 case MOV_FOURCC('u','d','t','a'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
366 /* here not supported :p */ |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
367 break; |
1490 | 368 case MOV_FOURCC('t','k','h','d'): { |
1567 | 369 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sTrack header!\n",level,""); |
2101 | 370 // read codec data |
371 trak->tkdata_len=len; | |
372 trak->tkdata=malloc(trak->tkdata_len); | |
373 stream_read(demuxer->stream,trak->tkdata,trak->tkdata_len); | |
1490 | 374 break; |
375 } | |
376 case MOV_FOURCC('m','d','h','d'): { | |
2100 | 377 unsigned int tmp; |
1567 | 378 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sMedia header!\n",level,""); |
2100 | 379 #if 0 |
380 tmp=stream_read_dword(demuxer->stream); | |
381 printf("dword1: 0x%08X (%d)\n",tmp,tmp); | |
382 tmp=stream_read_dword(demuxer->stream); | |
383 printf("dword2: 0x%08X (%d)\n",tmp,tmp); | |
384 tmp=stream_read_dword(demuxer->stream); | |
385 printf("dword3: 0x%08X (%d)\n",tmp,tmp); | |
386 tmp=stream_read_dword(demuxer->stream); | |
387 printf("dword4: 0x%08X (%d)\n",tmp,tmp); | |
388 tmp=stream_read_dword(demuxer->stream); | |
389 printf("dword5: 0x%08X (%d)\n",tmp,tmp); | |
390 tmp=stream_read_dword(demuxer->stream); | |
391 printf("dword6: 0x%08X (%d)\n",tmp,tmp); | |
392 #endif | |
393 stream_skip(demuxer->stream,12); | |
1490 | 394 // read timescale |
2100 | 395 trak->timescale=stream_read_dword(demuxer->stream); |
396 // read length | |
397 trak->length=stream_read_dword(demuxer->stream); | |
1490 | 398 break; |
399 } | |
400 case MOV_FOURCC('v','m','h','d'): { | |
1567 | 401 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sVideo header!\n",level,""); |
1490 | 402 trak->type=MOV_TRAK_VIDEO; |
403 // read video data | |
404 break; | |
405 } | |
406 case MOV_FOURCC('s','m','h','d'): { | |
1567 | 407 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSound header!\n",level,""); |
1490 | 408 trak->type=MOV_TRAK_AUDIO; |
409 // read audio data | |
410 break; | |
411 } | |
2786 | 412 case MOV_FOURCC('g','m','h','d'): { |
413 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sGeneric header!\n",level,""); | |
414 trak->type=MOV_TRAK_GENERIC; | |
415 break; | |
416 } | |
4645
33c2fc18138c
added nmhd, added checking for audio trak in demux_mov_fill_buffer
alex
parents:
4624
diff
changeset
|
417 case MOV_FOURCC('n','m','h','d'): { |
33c2fc18138c
added nmhd, added checking for audio trak in demux_mov_fill_buffer
alex
parents:
4624
diff
changeset
|
418 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sGeneric header!\n",level,""); |
33c2fc18138c
added nmhd, added checking for audio trak in demux_mov_fill_buffer
alex
parents:
4624
diff
changeset
|
419 trak->type=MOV_TRAK_GENERIC; |
33c2fc18138c
added nmhd, added checking for audio trak in demux_mov_fill_buffer
alex
parents:
4624
diff
changeset
|
420 break; |
33c2fc18138c
added nmhd, added checking for audio trak in demux_mov_fill_buffer
alex
parents:
4624
diff
changeset
|
421 } |
1490 | 422 case MOV_FOURCC('s','t','s','d'): { |
423 int i=stream_read_dword(demuxer->stream); // temp! | |
424 int count=stream_read_dword(demuxer->stream); | |
1567 | 425 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sDescription list! (cnt:%d)\n",level,"",count); |
1490 | 426 for(i=0;i<count;i++){ |
427 off_t pos=stream_tell(demuxer->stream); | |
428 off_t len=stream_read_dword(demuxer->stream); | |
429 unsigned int fourcc=stream_read_dword_le(demuxer->stream); | |
430 if(len<8) break; // error | |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
431 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*s desc #%d: %.4s (%d bytes)\n",level,"",i,&fourcc,len-16); |
1490 | 432 if(!i){ |
433 trak->fourcc=fourcc; | |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
434 // read type specific (audio/video/time/text etc) header |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
435 // NOTE: trak type is not yet known at this point :((( |
2101 | 436 trak->stdata_len=len-8; |
437 trak->stdata=malloc(trak->stdata_len); | |
438 stream_read(demuxer->stream,trak->stdata,trak->stdata_len); | |
1490 | 439 } |
440 if(fourcc!=trak->fourcc && i) | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1567
diff
changeset
|
441 mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_MOVvariableFourCC); |
1490 | 442 if(!stream_seek(demuxer->stream,pos+len)) break; |
443 } | |
444 break; | |
445 } | |
2100 | 446 case MOV_FOURCC('s','t','t','s'): { |
447 int temp=stream_read_dword(demuxer->stream); | |
448 int len=stream_read_dword(demuxer->stream); | |
449 int i; | |
450 int x=0; | |
451 unsigned int pts=0; | |
452 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample duration table! (%d blocks)\n",level,"",len); | |
2115 | 453 trak->durmap=malloc(sizeof(mov_durmap_t)*len); |
454 memset(trak->durmap,0,sizeof(mov_durmap_t)*len); | |
455 trak->durmap_size=len; | |
2100 | 456 for(i=0;i<len;i++){ |
2115 | 457 trak->durmap[i].num=stream_read_dword(demuxer->stream); |
458 trak->durmap[i].dur=stream_read_dword(demuxer->stream); | |
459 pts+=trak->durmap[i].num*trak->durmap[i].dur; | |
2386 | 460 |
2786 | 461 if(i==0 && trak->type == MOV_TRAK_VIDEO) |
2386 | 462 { |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
463 sh_video_t* sh=get_sh_video(demuxer,priv->track_db); |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
464 if (sh && !sh->fps) |
2386 | 465 sh->fps = trak->timescale/trak->durmap[i].dur; |
466 /* initial fps */ | |
467 } | |
2100 | 468 } |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
469 if(trak->length!=pts) mp_msg(MSGT_DEMUX, MSGL_WARN, "Warning! pts=%d length=%d\n",pts,trak->length); |
2100 | 470 break; |
471 } | |
472 case MOV_FOURCC('s','t','s','c'): { | |
473 int temp=stream_read_dword(demuxer->stream); | |
474 int len=stream_read_dword(demuxer->stream); | |
2533 | 475 int ver = (temp << 24); |
476 int flags = (temp << 16)|(temp<<8)|temp; | |
2100 | 477 int i; |
2533 | 478 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample->Chunk mapping table! (%d blocks) (ver:%d,flags:%ld)\n", |
479 level,"",len,ver,flags); | |
2100 | 480 // read data: |
481 trak->chunkmap_size=len; | |
482 trak->chunkmap=malloc(sizeof(mov_chunkmap_t)*len); | |
483 for(i=0;i<len;i++){ | |
2103 | 484 trak->chunkmap[i].first=stream_read_dword(demuxer->stream)-1; |
2100 | 485 trak->chunkmap[i].spc=stream_read_dword(demuxer->stream); |
486 trak->chunkmap[i].sdid=stream_read_dword(demuxer->stream); | |
487 } | |
488 break; | |
489 } | |
490 case MOV_FOURCC('s','t','s','z'): { | |
491 int temp=stream_read_dword(demuxer->stream); | |
492 int ss=stream_read_dword(demuxer->stream); | |
2533 | 493 int ver = (temp << 24); |
494 int flags = (temp << 16)|(temp<<8)|temp; | |
495 int entries=stream_read_dword(demuxer->stream); | |
2546
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
496 int i; |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
497 |
2533 | 498 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample size table! (entries=%d ss=%d) (ver:%d,flags:%ld)\n", |
499 level,"",entries,ss,ver,flags); | |
2786 | 500 trak->samplesize=ss; |
501 if (!ss) { | |
502 // variable samplesize | |
503 trak->samples=realloc(trak->samples,sizeof(mov_sample_t)*entries); | |
504 trak->samples_size=entries; | |
505 for(i=0;i<entries;i++) | |
2546
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
506 trak->samples[i].size=stream_read_dword(demuxer->stream); |
2786 | 507 } |
2100 | 508 break; |
509 } | |
510 case MOV_FOURCC('s','t','c','o'): { | |
511 int temp=stream_read_dword(demuxer->stream); | |
512 int len=stream_read_dword(demuxer->stream); | |
513 int i; | |
514 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sChunk offset table! (%d chunks)\n",level,"",len); | |
515 // extend array if needed: | |
516 if(len>trak->chunks_size){ | |
517 trak->chunks=realloc(trak->chunks,sizeof(mov_chunk_t)*len); | |
518 trak->chunks_size=len; | |
519 } | |
520 // read elements: | |
521 for(i=0;i<len;i++) trak->chunks[i].pos=stream_read_dword(demuxer->stream); | |
522 break; | |
523 } | |
3652
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
524 case MOV_FOURCC('c','o','6','4'): { |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
525 int temp=stream_read_dword(demuxer->stream); |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
526 int len=stream_read_dword(demuxer->stream); |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
527 int i; |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
528 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*s64bit chunk offset table! (%d chunks)\n",level,"",len); |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
529 // extend array if needed: |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
530 if(len>trak->chunks_size){ |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
531 trak->chunks=realloc(trak->chunks,sizeof(mov_chunk_t)*len); |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
532 trak->chunks_size=len; |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
533 } |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
534 // read elements: |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
535 for(i=0;i<len;i++) |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
536 { |
3999
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
537 #ifndef _LARGEFILE_SOURCE |
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
538 if (stream_read_dword(demuxer->stream) != 0) |
3652
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
539 mp_msg(MSGT_DEMUX, MSGL_WARN, "Chunk %d has got 64bit address, but you've MPlayer compiled without LARGEFILE support!\n", i); |
3999
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
540 trak->chunks[i].pos = stream_read_dword(demuxer->stream); |
3652
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
541 #else |
3999
3c6b061ec033
mov_check_file 64bit support by Chris Bednar. also fixed co64 chunk and added warnings for 64bit files reading without largefiles support
alex
parents:
3652
diff
changeset
|
542 trak->chunks[i].pos = stream_read_qword(demuxer->stream); |
3652
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
543 #endif |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
544 } |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
545 break; |
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
546 } |
2533 | 547 case MOV_FOURCC('s','t','s','s'): { |
548 int temp=stream_read_dword(demuxer->stream); | |
549 int entries=stream_read_dword(demuxer->stream); | |
550 int ver = (temp << 24); | |
551 int flags = (temp << 16)|(temp<<8)|temp; | |
552 int i; | |
2542 | 553 mp_msg(MSGT_DEMUX, MSGL_V,"MOV: %*sSyncing samples (keyframes) table! (%d entries) (ver:%d,flags:%ld)\n", |
2533 | 554 level, "",entries, ver, flags); |
2544 | 555 trak->keyframes_size=entries; |
556 trak->keyframes=malloc(sizeof(unsigned int)*entries); | |
2546
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
557 for (i=0;i<entries;i++) |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
558 trak->keyframes[i]=stream_read_dword(demuxer->stream)-1; |
2544 | 559 // for (i=0;i<entries;i++) printf("%3d: %d\n",i,trak->keyframes[i]); |
2533 | 560 break; |
561 } | |
1490 | 562 case MOV_FOURCC('m','d','i','a'): { |
1567 | 563 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sMedia stream!\n",level,""); |
1490 | 564 lschunks(demuxer,level+1,pos+len,trak); |
565 break; | |
566 } | |
567 case MOV_FOURCC('m','i','n','f'): { | |
1567 | 568 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sMedia info!\n",level,""); |
1490 | 569 lschunks(demuxer,level+1,pos+len,trak); |
570 break; | |
571 } | |
572 case MOV_FOURCC('s','t','b','l'): { | |
1567 | 573 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample info!\n",level,""); |
1490 | 574 lschunks(demuxer,level+1,pos+len,trak); |
575 break; | |
576 } | |
2546
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
577 case MOV_FOURCC('e','d','t','s'): { |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
578 mp_msg(MSGT_DEMUX, MSGL_V, "MOV: %*sEdit atom!\n", level, ""); |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
579 lschunks(demuxer,level+1,pos+len,trak); |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
580 break; |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
581 } |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
582 case MOV_FOURCC('e','l','s','t'): { |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
583 int temp=stream_read_dword(demuxer->stream); |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
584 int entries=stream_read_dword(demuxer->stream); |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
585 int ver = (temp << 24); |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
586 int flags = (temp << 16)|(temp<<8)|temp; |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
587 int i; |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
588 |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
589 mp_msg(MSGT_DEMUX, MSGL_V,"MOV: %*sEdit list table (%d entries) (ver:%d,flags:%ld)\n", |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
590 level, "",entries, ver, flags); |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
591 #if 0 |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
592 for (i=0;i<entries;i++) |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
593 { |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
594 printf("entry#%d: dur: %ld mtime: %ld mrate: %ld\n", |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
595 i, stream_read_dword(demuxer->stream), |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
596 stream_read_dword(demuxer->stream), |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
597 stream_read_dword(demuxer->stream)); |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
598 } |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
599 #endif |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
600 break; |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
601 } |
2786 | 602 case MOV_FOURCC('c','o','d','e'): |
603 { | |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
604 /* XXX: Implement atom 'code' for FLASH support */ |
2786 | 605 } |
2532 | 606 default: |
4903
d8b465e3fd88
fixed some endian issues, like changing bswap_32() -> be2me_32(), and
melanson
parents:
4646
diff
changeset
|
607 id = be2me_32(id); |
2532 | 608 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: unknown chunk: %.4s %d\n",&id,(int)len); |
609 break; | |
1490 | 610 }//switch(id) |
2532 | 611 } else { /* not in track */ |
612 switch(id) { | |
613 case MOV_FOURCC('t','r','a','k'): { | |
1490 | 614 // if(trak) printf("MOV: Warning! trak in trak?\n"); |
615 if(priv->track_db>=MOV_MAX_TRACKS){ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1567
diff
changeset
|
616 mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_MOVtooManyTrk); |
1490 | 617 return; |
618 } | |
619 trak=malloc(sizeof(mov_track_t)); | |
620 memset(trak,0,sizeof(mov_track_t)); | |
1567 | 621 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: Track #%d:\n",priv->track_db); |
1490 | 622 trak->id=priv->track_db; |
2100 | 623 priv->tracks[priv->track_db]=trak; |
1490 | 624 lschunks(demuxer,level+1,pos+len,trak); |
2100 | 625 mov_build_index(trak); |
626 switch(trak->type){ | |
627 case MOV_TRAK_AUDIO: { | |
5206
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
628 #if 0 |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
629 struct { |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
630 int16_t version; // 0 or 1 (version 1 is qt3.0+) |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
631 int16_t revision; // 0 |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
632 int32_t vendor_id; // 0 |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
633 int16_t channels; // 1 or 2 (Mono/Stereo) |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
634 int16_t samplesize; // 8 or 16 (8Bit/16Bit) |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
635 int16_t compression_id; // if version 0 then 0 |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
636 // if version 1 and vbr then -2 else 0 |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
637 int16_t packet_size; // 0 |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
638 uint16_t sample_rate; // samplerate (Hz) |
5206
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
639 // qt3.0+ (version == 1) |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
640 uint32_t samples_per_packet; // 0 or num uncompressed samples in a packet |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
641 // if 0 below three values are also 0 |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
642 uint32_t bytes_per_packet; // 0 or num compressed bytes for one channel |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
643 uint32_t bytes_per_frame; // 0 or num compressed bytes for all channels |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
644 // (channels * bytes_per_packet) |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
645 uint32_t bytes_per_sample; // 0 or size of uncompressed sample |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
646 // if samples_per_packet and bytes_per_packet are constant (CBR) |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
647 // then bytes_per_frame and bytes_per_sample must be 0 (else is VBR) |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
648 // --- |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
649 // optional additional atom-based fields |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
650 // ([int32_t size,int32_t type,some data ],repeat) |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
651 } my_stdata; |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
652 #endif |
2100 | 653 sh_audio_t* sh=new_sh_audio(demuxer,priv->track_db); |
654 sh->format=trak->fourcc; | |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
655 |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
656 // assumptions for below table: short is 16bit, int is 32bit, intfp is 16bit |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
657 // XXX: 32bit fixed point numbers (intfp) are only 2 Byte! |
5206
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
658 // short values are usually one byte leftpadded by zero |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
659 // int values are usually two byte leftpadded by zero |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
660 // stdata[]: |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
661 // 8 short version |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
662 // 10 short revision |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
663 // 12 int vendor_id |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
664 // 16 short channels |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
665 // 18 short samplesize |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
666 // 20 short compression_id |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
667 // 22 short packet_size (==0) |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
668 // 24 intfp sample_rate |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
669 // (26 short) unknown (==0) |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
670 // ---- qt3.0+ |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
671 // 28 int samples_per_packet |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
672 // 32 int bytes_per_packet |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
673 // 36 int bytes_per_frame |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
674 // 40 int bytes_per_sample |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
675 // there may be additional atoms following at 28 (version 0) |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
676 // or 44 (version 1), eg. esds atom of .MP4 files |
5206
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
677 // esds atom: |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
678 // 28 int atom size (bytes of int size, int type and data) |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
679 // 32 char[4] atom type (fourc charater code -> esds) |
5307
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
680 // 36 char[] atom data (len=size-8) |
5206
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
681 |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
682 sh->samplesize=char2short(trak->stdata,18)/8; |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
683 sh->channels=char2short(trak->stdata,16); |
5212
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
684 /*printf("MOV: timescale: %d samplerate: %d durmap: %d (%d) -> %d (%d)\n", |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
685 trak->timescale, char2short(trak->stdata,24), trak->durmap[0].dur, |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
686 trak->durmap[0].num, trak->timescale/trak->durmap[0].dur, |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
687 char2short(trak->stdata,24)/trak->durmap[0].dur);*/ |
5206
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
688 sh->samplerate=char2short(trak->stdata,24); |
5301 | 689 if((sh->samplerate < 7000) && trak->durmap) { |
5212
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
690 switch(char2short(trak->stdata,24)/trak->durmap[0].dur) { |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
691 // TODO: add more cases. |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
692 case 31: |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
693 sh->samplerate = 32000; break; |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
694 case 43: |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
695 sh->samplerate = 44100; break; |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
696 case 47: |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
697 sh->samplerate = 48000; break; |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
698 default: |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
699 mp_msg(MSGT_DEMUX, MSGL_WARN, |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
700 "MOV: unable to determine audio samplerate, " |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
701 "assuming 44.1kHz (got %d)\n", |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
702 char2short(trak->stdata,24)/trak->durmap[0].dur); |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
703 sh->samplerate = 44100; |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
704 } |
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
705 } |
5206
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
706 |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
707 mp_msg(MSGT_DEMUX, MSGL_INFO, "Audio bits: %d chans: %d\n", |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
708 trak->stdata[19],trak->stdata[17]); |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
709 mp_msg(MSGT_DEMUX, MSGL_INFO, "Audio sample rate: %d\n", |
5212
12f7cbbe7022
add alternative samplerate calculation for files with timescale\!=samplerate
atmos4
parents:
5206
diff
changeset
|
710 sh->samplerate/*char2short(trak->stdata,24)*/); |
5206
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
711 if((trak->stdata[9]==0) && trak->stdata_len >= 36) { // version 0 with extra atoms |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
712 int atom_len = char2int(trak->stdata,28); |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
713 switch(char2int(trak->stdata,32)) { // atom type |
5301 | 714 case MOV_FOURCC('e','s','d','s'): { |
5242
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
715 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found MPEG4 audio Elementary Stream Descriptor atom (%d)!\n", atom_len); |
5307
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
716 if(atom_len > 8) { |
5305 | 717 esds_t esds; |
718 if(!mp4_parse_esds(&trak->stdata[36], atom_len-8, &esds)) { | |
5301 | 719 |
5305 | 720 sh->i_bps = esds.avgBitrate/8; |
5301 | 721 |
722 // dump away the codec specific configuration for the AAC decoder | |
5305 | 723 sh->codecdata_len = esds.decoderConfigLen; |
5301 | 724 sh->codecdata = (unsigned char *)malloc(sh->codecdata_len); |
5305 | 725 memcpy(sh->codecdata, esds.decoderConfig, sh->codecdata_len); |
5301 | 726 } |
5305 | 727 mp4_free_esds(&esds); // freeup esds mem |
5301 | 728 #if 0 |
729 { FILE* f=fopen("esds.dat","wb"); | |
730 fwrite(&trak->stdata[36],atom_len-8,1,f); | |
731 fclose(f); } | |
732 #endif | |
733 } | |
734 } break; | |
5206
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
735 default: |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
736 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found unknown audio atom %c%c%c%c (%d)!\n", |
5206
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
737 trak->stdata[32],trak->stdata[33],trak->stdata[34],trak->stdata[35], |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
738 atom_len); |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
739 } |
2ca5a9bfaa98
allow sh_audio struct to be initialized by demuxer, add parsing of mp4 esds header to mov demuxer, init faad from info from mov header
atmos4
parents:
5085
diff
changeset
|
740 } |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
741 mp_msg(MSGT_DEMUX, MSGL_INFO, "Fourcc: %.4s\n",&trak->fourcc); |
2543 | 742 #if 0 |
743 { FILE* f=fopen("stdata.dat","wb"); | |
744 fwrite(trak->stdata,trak->stdata_len,1,f); | |
745 fclose(f); } | |
746 { FILE* f=fopen("tkdata.dat","wb"); | |
747 fwrite(trak->tkdata,trak->tkdata_len,1,f); | |
748 fclose(f); } | |
749 #endif | |
2101 | 750 // Emulate WAVEFORMATEX struct: |
751 sh->wf=malloc(sizeof(WAVEFORMATEX)); | |
752 memset(sh->wf,0,sizeof(WAVEFORMATEX)); | |
2543 | 753 sh->wf->nChannels=(trak->stdata[16]<<8)+trak->stdata[17]; |
754 sh->wf->wBitsPerSample=(trak->stdata[18]<<8)+trak->stdata[19]; | |
755 // sh->wf->nSamplesPerSec=trak->timescale; | |
756 sh->wf->nSamplesPerSec=(trak->stdata[24]<<8)+trak->stdata[25]; | |
757 sh->wf->nAvgBytesPerSec=sh->wf->nChannels*sh->wf->wBitsPerSample*sh->wf->nSamplesPerSec/8; | |
2101 | 758 // Selection: |
759 if(demuxer->audio->id==-1 || demuxer->audio->id==priv->track_db){ | |
760 // (auto)selected audio track: | |
761 demuxer->audio->id=priv->track_db; | |
762 demuxer->audio->sh=sh; sh->ds=demuxer->audio; | |
763 } | |
2100 | 764 break; |
765 } | |
766 case MOV_TRAK_VIDEO: { | |
4129
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
767 int i, entry; |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
768 int flag, start, count_flag, end, palette_count; |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
769 int hdr_ptr = 76; // the byte just after depth |
4129
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
770 unsigned char *palette_map; |
2100 | 771 sh_video_t* sh=new_sh_video(demuxer,priv->track_db); |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
772 int depth = trak->stdata[75]|(trak->stdata[74]<<8); |
2100 | 773 sh->format=trak->fourcc; |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
774 |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
775 // stdata[]: |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
776 // 8 short version |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
777 // 10 short revision |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
778 // 12 int vendor_id |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
779 // 16 int temporal_quality |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
780 // 20 int spatial_quality |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
781 // 24 short width |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
782 // 26 short height |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
783 // 28 int h_dpi |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
784 // 32 int v_dpi |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
785 // 36 int 0 |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
786 // 40 short frames_per_sample |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
787 // 42 char[4] compressor_name |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
788 // 74 short depth |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
789 // 76 short color_table_id |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
790 // additional atoms may follow, |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
791 // eg esds atom from .MP4 files |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
792 // 78 int atom size |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
793 // 82 char[4] atom type |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
794 // 86 ... atom data |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
795 |
5372
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
796 #ifdef USE_QTX_CODECS |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
797 { ImageDescription* id=malloc(8+trak->stdata_len); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
798 trak->desc=id; |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
799 id->idSize=8+trak->stdata_len; |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
800 id->cType=trak->fourcc; |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
801 id->version=char2short(trak->stdata,8); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
802 id->revisionLevel=char2short(trak->stdata,10); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
803 id->vendor=char2int(trak->stdata,12); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
804 id->temporalQuality=char2int(trak->stdata,16); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
805 id->spatialQuality=char2int(trak->stdata,20); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
806 id->width=char2short(trak->stdata,24); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
807 id->height=char2short(trak->stdata,26); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
808 id->hRes=char2int(trak->stdata,28); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
809 id->vRes=char2int(trak->stdata,32); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
810 id->dataSize=char2int(trak->stdata,36); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
811 id->frameCount=char2short(trak->stdata,40); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
812 memcpy(&id->name,trak->stdata+42,32); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
813 id->depth=char2short(trak->stdata,74); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
814 id->clutID=char2short(trak->stdata,76); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
815 memcpy(((char*)&id->clutID)+2,trak->stdata+78,trak->stdata_len-78); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
816 if(1) // debug |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
817 { FILE *f=fopen("ImageDescription","wb"); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
818 fwrite(id,id->idSize,1,f); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
819 fclose(f); |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
820 } |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
821 } |
ee9dd55ef383
some under-devel code, will be required for qtx codecs
arpi
parents:
5307
diff
changeset
|
822 #endif |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
823 |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
824 if(trak->stdata_len >= 86) { // extra atoms found |
5250 | 825 int pos=78; |
5251 | 826 int atom_len; |
5250 | 827 while(pos+8<=trak->stdata_len && |
828 (pos+(atom_len=char2int(trak->stdata,pos)))<=trak->stdata_len){ | |
829 switch(char2int(trak->stdata,pos+4)) { // switch atom type | |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
830 case MOV_FOURCC('g','a','m','a'): |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
831 // intfp with gamma value at which movie was captured |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
832 // can be used to gamma correct movie display |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
833 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found unsupported Gamma-Correction movie atom (%d)!\n", |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
834 atom_len); |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
835 break; |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
836 case MOV_FOURCC('f','i','e','l'): |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
837 // 2 char-values (8bit int) that specify field handling |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
838 // see the Apple's QuickTime Fileformat PDF for more info |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
839 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found unsupported Field-Handling movie atom (%d)!\n", |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
840 atom_len); |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
841 break; |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
842 case MOV_FOURCC('m','j','q','t'): |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
843 // Motion-JPEG default quantization table |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
844 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found unsupported MJPEG-Quantization movie atom (%d)!\n", |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
845 atom_len); |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
846 break; |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
847 case MOV_FOURCC('m','j','h','t'): |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
848 // Motion-JPEG default huffman table |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
849 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found unsupported MJPEG-Huffman movie atom (%d)!\n", |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
850 atom_len); |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
851 break; |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
852 case MOV_FOURCC('e','s','d','s'): |
5242
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
853 // MPEG4 Elementary Stream Descriptor header |
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
854 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found MPEG4 movie Elementary Stream Descriptor atom (%d)!\n", atom_len); |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
855 // add code here to save esds header of length atom_len-8 |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
856 // beginning at stdata[86] to some variable to pass it |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
857 // on to the decoder ::atmos |
5307
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
858 if(atom_len > 8) { |
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
859 esds_t esds; |
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
860 if(!mp4_parse_esds(trak->stdata+pos+8, atom_len-8, &esds)) { |
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
861 |
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
862 // dump away the codec specific configuration for the AAC decoder |
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
863 trak->stream_header_len = esds.decoderConfigLen; |
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
864 trak->stream_header = (unsigned char *)malloc(trak->stream_header_len); |
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
865 memcpy(trak->stream_header, esds.decoderConfig, trak->stream_header_len); |
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
866 } |
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
867 mp4_free_esds(&esds); // freeup esds mem |
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
868 } |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
869 break; |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
870 default: |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
871 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found unknown movie atom %c%c%c%c (%d)!\n", |
5250 | 872 trak->stdata[pos+4],trak->stdata[pos+5],trak->stdata[pos+6],trak->stdata[pos+7], |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
873 atom_len); |
5250 | 874 } |
875 pos+=atom_len; | |
5252 | 876 // printf("pos=%d max=%d\n",pos,trak->stdata_len); |
5236
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
877 } |
f8a00b2c9c39
Add some atom parsing to movie trak and a bit cosmetics ;), Michael can now write esds movie header whereever he wants.
atmos4
parents:
5212
diff
changeset
|
878 } |
2386 | 879 if(!sh->fps) sh->fps=trak->timescale; |
2100 | 880 sh->frametime=1.0f/sh->fps; |
5242
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
881 |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
882 sh->disp_w=trak->stdata[25]|(trak->stdata[24]<<8); |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
883 sh->disp_h=trak->stdata[27]|(trak->stdata[26]<<8); |
5242
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
884 // if image size is zero, fallback to display size |
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
885 if(!sh->disp_w && !sh->disp_h) { |
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
886 sh->disp_w=trak->tkdata[77]|(trak->tkdata[76]<<8); |
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
887 sh->disp_h=trak->tkdata[81]|(trak->tkdata[80]<<8); |
d4ffcbe9ed3d
Recognize and skip ftype chunk used by some .mp4 files and
atmos4
parents:
5241
diff
changeset
|
888 } |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
889 |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
890 if(depth&(~15)) printf("*** depht = 0x%X\n",depth); |
2101 | 891 |
4129
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
892 // palettized? |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
893 depth&=31; // flag 32 means grayscale |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
894 if ((depth == 2) || (depth == 4) || (depth == 8)) |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
895 palette_count = (1 << depth); |
4129
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
896 else |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
897 palette_count = 0; |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
898 |
2101 | 899 // emulate BITMAPINFOHEADER: |
4129
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
900 if (palette_count) |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
901 { |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
902 sh->bih=malloc(sizeof(BITMAPINFOHEADER) + palette_count * 4); |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
903 memset(sh->bih,0,sizeof(BITMAPINFOHEADER) + palette_count * 4); |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
904 sh->bih->biSize=40 + palette_count * 4; |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
905 // fetch the relevant fields |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
906 flag = BE_16(&trak->stdata[hdr_ptr]); |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
907 hdr_ptr += 2; |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
908 start = BE_32(&trak->stdata[hdr_ptr]); |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
909 hdr_ptr += 4; |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
910 count_flag = BE_16(&trak->stdata[hdr_ptr]); |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
911 hdr_ptr += 2; |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
912 end = BE_16(&trak->stdata[hdr_ptr]); |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
913 hdr_ptr += 2; |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
914 palette_map = (unsigned char *)sh->bih + 40; |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
915 mp_msg(MSGT_DEMUX, MSGL_INFO, "Allocated %d entries for palette\n", |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
916 palette_count); |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
917 mp_msg(MSGT_DEMUX, MSGL_DBG2, "QT palette: start: %x, end: %x, count flag: %d, flags: %x\n", |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
918 start, end, count_flag, flag); |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
919 |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
920 /* XXX: problems with sample (statunit6.mov) with flag&0x4 set! - alex*/ |
4332 | 921 |
922 // load default palette | |
4646
59eb588c7115
reinstated original palette decision logic from XAnim (was the QT spec
melanson
parents:
4645
diff
changeset
|
923 if (flag & 0x08) |
4332 | 924 { |
4646
59eb588c7115
reinstated original palette decision logic from XAnim (was the QT spec
melanson
parents:
4645
diff
changeset
|
925 mp_msg(MSGT_DEMUX, MSGL_INFO, "Using default QT palette\n"); |
4332 | 926 if (palette_count == 4) |
927 memcpy(palette_map, qt_default_palette_4, 4 * 4); | |
928 else if (palette_count == 16) | |
929 memcpy(palette_map, qt_default_palette_16, 16 * 4); | |
930 if (palette_count == 256) | |
931 memcpy(palette_map, qt_default_palette_256, 256 * 4); | |
932 } | |
933 // load palette from file | |
934 else | |
4129
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
935 { |
4646
59eb588c7115
reinstated original palette decision logic from XAnim (was the QT spec
melanson
parents:
4645
diff
changeset
|
936 mp_msg(MSGT_DEMUX, MSGL_INFO, "Loading palette from file\n"); |
4332 | 937 for (i = start; i <= end; i++) |
938 { | |
939 entry = BE_16(&trak->stdata[hdr_ptr]); | |
940 hdr_ptr += 2; | |
941 // apparently, if count_flag is set, entry is same as i | |
942 if (count_flag & 0x8000) | |
943 entry = i; | |
944 // only care about top 8 bits of 16-bit R, G, or B value | |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
945 if (entry <= palette_count && entry >= 0) |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
946 { |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
947 palette_map[entry * 4 + 2] = trak->stdata[hdr_ptr + 0]; |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
948 palette_map[entry * 4 + 1] = trak->stdata[hdr_ptr + 2]; |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
949 palette_map[entry * 4 + 0] = trak->stdata[hdr_ptr + 4]; |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
950 mp_dbg(MSGT_DEMUX, MSGL_DBG2, "QT palette: added entry: %d of %d (colors: R:%x G:%x B:%x)\n", |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
951 entry, palette_count, |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
952 palette_map[entry * 4 + 2], |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
953 palette_map[entry * 4 + 1], |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
954 palette_map[entry * 4 + 0]); |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
955 } |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
956 else |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
957 mp_msg(MSGT_DEMUX, MSGL_V, "QT palette: skipped entry (out of count): %d of %d\n", |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
958 entry, palette_count); |
4332 | 959 hdr_ptr += 6; |
960 } | |
4129
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
961 } |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
962 } |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
963 else |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
964 { |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
965 sh->bih=malloc(sizeof(BITMAPINFOHEADER)); |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
966 memset(sh->bih,0,sizeof(BITMAPINFOHEADER)); |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
967 sh->bih->biSize=40; |
31cd2e0bb961
QT demuxer loads palette information from files that transport palettes in
melanson
parents:
3999
diff
changeset
|
968 } |
2101 | 969 sh->bih->biWidth=sh->disp_w; |
970 sh->bih->biHeight=sh->disp_h; | |
971 sh->bih->biPlanes=0; | |
3652
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
972 sh->bih->biBitCount=depth; |
2101 | 973 sh->bih->biCompression=trak->fourcc; |
974 sh->bih->biSizeImage=sh->bih->biWidth*sh->bih->biHeight; | |
975 | |
5067
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
976 mp_msg(MSGT_DEMUX, MSGL_INFO, "Image size: %d x %d (%d bpp)\n",sh->disp_w,sh->disp_h,sh->bih->biBitCount); |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
977 if(trak->tkdata_len>81) |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
978 mp_msg(MSGT_DEMUX, MSGL_INFO, "Display size: %d x %d\n", |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
979 trak->tkdata[77]|(trak->tkdata[76]<<8), |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
980 trak->tkdata[81]|(trak->tkdata[80]<<8)); |
54fe37e1f1a7
some cleanup, fixes for video header parsing. finally we get the coded size instead of display size\!
arpi
parents:
4903
diff
changeset
|
981 mp_msg(MSGT_DEMUX, MSGL_INFO, "Fourcc: %.4s Codec: '%.*s'\n",&trak->fourcc,trak->stdata[42]&31,trak->stdata+43); |
2115 | 982 |
2101 | 983 if(demuxer->video->id==-1 || demuxer->video->id==priv->track_db){ |
984 // (auto)selected video track: | |
985 demuxer->video->id=priv->track_db; | |
986 demuxer->video->sh=sh; sh->ds=demuxer->video; | |
987 } | |
2100 | 988 break; |
989 } | |
2786 | 990 case MOV_TRAK_GENERIC: |
991 mp_msg(MSGT_DEMUX, MSGL_INFO, "Generic track - not completly understood! (id: %d)\n", | |
992 trak->id); | |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
993 /* XXX: Also this contains the FLASH data */ |
2786 | 994 #if 0 |
995 mp_msg(MSGT_DEMUX, MSGL_INFO, "Extracting samples to files (possibly this is an flash anim)\n"); | |
996 { | |
997 int pos = stream_tell(demuxer->stream); | |
998 int i; | |
999 int fd; | |
1000 char name[20]; | |
1001 | |
1002 for (i=0; i<trak->samples_size; i++) | |
1003 { | |
1004 char buf[trak->samples[i].size]; | |
1005 stream_seek(demuxer->stream, trak->samples[i].pos); | |
1006 snprintf((char *)&name[0], 20, "samp%d", i); | |
1007 fd = open((char *)&name[0], O_CREAT|O_WRONLY); | |
1008 stream_read(demuxer->stream, &buf[0], trak->samples[i].size); | |
1009 write(fd, &buf[0], trak->samples[i].size); | |
1010 close(fd); | |
1011 } | |
1012 for (i=0; i<trak->chunks_size; i++) | |
1013 { | |
1014 char buf[trak->length]; | |
1015 stream_seek(demuxer->stream, trak->chunks[i].pos); | |
1016 snprintf((char *)&name[0], 20, "chunk%d", i); | |
1017 fd = open((char *)&name[0], O_CREAT|O_WRONLY); | |
1018 stream_read(demuxer->stream, &buf[0], trak->length); | |
1019 write(fd, &buf[0], trak->length); | |
1020 close(fd); | |
1021 } | |
1022 if (trak->samplesize > 0) | |
1023 { | |
1024 char *buf; | |
1025 | |
1026 buf = malloc(trak->samplesize); | |
1027 stream_seek(demuxer->stream, trak->chunks[0].pos); | |
1028 snprintf((char *)&name[0], 20, "trak%d", trak->id); | |
1029 fd = open((char *)&name[0], O_CREAT|O_WRONLY); | |
1030 stream_read(demuxer->stream, buf, trak->samplesize); | |
1031 write(fd, buf, trak->samplesize); | |
1032 close(fd); | |
1033 } | |
1034 stream_seek(demuxer->stream, pos); | |
1035 } | |
1036 #endif | |
1037 break; | |
2532 | 1038 default: |
1039 mp_msg(MSGT_DEMUX, MSGL_INFO, "Unknown track type found (type: %d)\n", trak->type); | |
1040 break; | |
2100 | 1041 } |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1042 mp_msg(MSGT_DEMUX, MSGL_INFO, "--------------\n"); |
2100 | 1043 priv->track_db++; |
1490 | 1044 trak=NULL; |
2532 | 1045 break; |
1046 } | |
2148 | 1047 #ifndef HAVE_ZLIB |
2532 | 1048 case MOV_FOURCC('c','m','o','v'): { |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1567
diff
changeset
|
1049 mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_MOVcomprhdr); |
1490 | 1050 return; |
1051 } | |
2148 | 1052 #else |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
1053 case MOV_FOURCC('m','o','o','v'): |
2532 | 1054 case MOV_FOURCC('c','m','o','v'): { |
2148 | 1055 // mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_MOVcomprhdr); |
1056 lschunks(demuxer,level+1,pos+len,NULL); | |
2532 | 1057 break; |
1058 } | |
1059 case MOV_FOURCC('d','c','o','m'): { | |
2148 | 1060 // int temp=stream_read_dword(demuxer->stream); |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
1061 unsigned int algo=be2me_32(stream_read_dword(demuxer->stream)); |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
1062 mp_msg(MSGT_DEMUX, MSGL_INFO, "Compressed header uses %.4s algo!\n",&algo); |
2532 | 1063 break; |
1064 } | |
1065 case MOV_FOURCC('c','m','v','d'): { | |
2148 | 1066 // int temp=stream_read_dword(demuxer->stream); |
1067 unsigned int moov_sz=stream_read_dword(demuxer->stream); | |
1068 unsigned int cmov_sz=len-4; | |
1069 unsigned char* cmov_buf=malloc(cmov_sz); | |
1070 unsigned char* moov_buf=malloc(moov_sz+16); | |
1071 int zret; | |
1072 z_stream zstrm; | |
1073 stream_t* backup; | |
1074 | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1075 mp_msg(MSGT_DEMUX, MSGL_INFO, "Compressed header size: %d / %d\n",cmov_sz,moov_sz); |
2148 | 1076 |
1077 stream_read(demuxer->stream,cmov_buf,cmov_sz); | |
1078 | |
1079 zstrm.zalloc = (alloc_func)0; | |
1080 zstrm.zfree = (free_func)0; | |
1081 zstrm.opaque = (voidpf)0; | |
1082 zstrm.next_in = cmov_buf; | |
1083 zstrm.avail_in = cmov_sz; | |
1084 zstrm.next_out = moov_buf; | |
1085 zstrm.avail_out = moov_sz; | |
1086 | |
1087 zret = inflateInit(&zstrm); | |
1088 if (zret != Z_OK) | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1089 { mp_msg(MSGT_DEMUX, MSGL_ERR, "QT cmov: inflateInit err %d\n",zret); |
2148 | 1090 return; |
1091 } | |
1092 zret = inflate(&zstrm, Z_NO_FLUSH); | |
1093 if ((zret != Z_OK) && (zret != Z_STREAM_END)) | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1094 { mp_msg(MSGT_DEMUX, MSGL_ERR, "QT cmov inflate: ERR %d\n",zret); |
2148 | 1095 return; |
1096 } | |
1097 #if 0 | |
1098 else { | |
1099 FILE *DecOut; | |
1100 DecOut = fopen("Out.bin", "w"); | |
1101 fwrite(moov_buf, 1, moov_sz, DecOut); | |
1102 fclose(DecOut); | |
1103 } | |
1104 #endif | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1105 if(moov_sz != zstrm.total_out) |
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1106 mp_msg(MSGT_DEMUX, MSGL_WARN, "Warning! moov size differs cmov: %d zlib: %d\n",moov_sz,zstrm.total_out); |
2148 | 1107 zret = inflateEnd(&zstrm); |
1108 | |
1109 backup=demuxer->stream; | |
1110 demuxer->stream=new_memory_stream(moov_buf,moov_sz); | |
1111 stream_skip(demuxer->stream,8); | |
1112 lschunks(demuxer,level+1,moov_sz,NULL); // parse uncompr. 'moov' | |
1113 //free_stream(demuxer->stream); | |
1114 demuxer->stream=backup; | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1115 free(cmov_buf); |
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1116 free(moov_buf); |
2532 | 1117 break; |
2148 | 1118 } |
1119 #endif | |
2532 | 1120 case MOV_FOURCC('u','d','t','a'): |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1121 { |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1122 unsigned int udta_id; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1123 off_t udta_len; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1124 off_t udta_size = len; |
1490 | 1125 |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1126 mp_msg(MSGT_DEMUX, MSGL_DBG2, "mov: user data record found\n"); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1127 mp_msg(MSGT_DEMUX, MSGL_INFO, "Quicktime Clip Info:\n"); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1128 |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1129 while((len > 8) && (udta_size > 8)) |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1130 { |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1131 udta_len = stream_read_dword(demuxer->stream); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1132 udta_id = stream_read_dword(demuxer->stream); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1133 udta_size -= 8; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1134 mp_msg(MSGT_DEMUX, MSGL_DBG2, "udta_id: %.4s (len: %d)\n", &udta_id, udta_len); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1135 switch (udta_id) |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1136 { |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1137 case MOV_FOURCC(0xa9,'c','p','y'): |
2542 | 1138 case MOV_FOURCC(0xa9,'d','a','y'): |
1139 case MOV_FOURCC(0xa9,'d','i','r'): | |
1140 /* 0xa9,'e','d','1' - '9' : edit timestamps */ | |
1141 case MOV_FOURCC(0xa9,'f','m','t'): | |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1142 case MOV_FOURCC(0xa9,'i','n','f'): |
2542 | 1143 case MOV_FOURCC(0xa9,'p','r','d'): |
1144 case MOV_FOURCC(0xa9,'p','r','f'): | |
1145 case MOV_FOURCC(0xa9,'r','e','q'): | |
1146 case MOV_FOURCC(0xa9,'s','r','c'): | |
1147 case MOV_FOURCC('n','a','m','e'): | |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1148 case MOV_FOURCC(0xa9,'n','a','m'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1149 case MOV_FOURCC(0xa9,'A','R','T'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1150 case MOV_FOURCC(0xa9,'c','m','t'): |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1151 case MOV_FOURCC(0xa9,'a','u','t'): |
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1152 case MOV_FOURCC(0xa9,'s','w','r'): |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1153 { |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1154 off_t text_len = stream_read_word(demuxer->stream); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1155 char text[text_len+2+1]; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1156 stream_read(demuxer->stream, (char *)&text, text_len+2); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1157 text[text_len+2] = 0x0; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1158 switch(udta_id) |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1159 { |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1160 case MOV_FOURCC(0xa9,'a','u','t'): |
3071 | 1161 demux_info_add(demuxer, "author", &text[2]); |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1162 mp_msg(MSGT_DEMUX, MSGL_INFO, " Author: %s\n", &text[2]); |
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1163 break; |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1164 case MOV_FOURCC(0xa9,'c','p','y'): |
3071 | 1165 demux_info_add(demuxer, "copyright", &text[2]); |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1166 mp_msg(MSGT_DEMUX, MSGL_INFO, " Copyright: %s\n", &text[2]); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1167 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1168 case MOV_FOURCC(0xa9,'i','n','f'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1169 mp_msg(MSGT_DEMUX, MSGL_INFO, " Info: %s\n", &text[2]); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1170 break; |
2542 | 1171 case MOV_FOURCC('n','a','m','e'): |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1172 case MOV_FOURCC(0xa9,'n','a','m'): |
3071 | 1173 demux_info_add(demuxer, "name", &text[2]); |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1174 mp_msg(MSGT_DEMUX, MSGL_INFO, " Name: %s\n", &text[2]); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1175 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1176 case MOV_FOURCC(0xa9,'A','R','T'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1177 mp_msg(MSGT_DEMUX, MSGL_INFO, " Artist: %s\n", &text[2]); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1178 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1179 case MOV_FOURCC(0xa9,'d','i','r'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1180 mp_msg(MSGT_DEMUX, MSGL_INFO, " Director: %s\n", &text[2]); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1181 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1182 case MOV_FOURCC(0xa9,'c','m','t'): |
3071 | 1183 demux_info_add(demuxer, "comments", &text[2]); |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1184 mp_msg(MSGT_DEMUX, MSGL_INFO, " Comment: %s\n", &text[2]); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1185 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1186 case MOV_FOURCC(0xa9,'r','e','q'): |
2542 | 1187 mp_msg(MSGT_DEMUX, MSGL_INFO, " Requirements: %s\n", &text[2]); |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1188 break; |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1189 case MOV_FOURCC(0xa9,'s','w','r'): |
3071 | 1190 demux_info_add(demuxer, "encoder", &text[2]); |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1191 mp_msg(MSGT_DEMUX, MSGL_INFO, " Software: %s\n", &text[2]); |
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1192 break; |
2542 | 1193 case MOV_FOURCC(0xa9,'d','a','y'): |
1194 mp_msg(MSGT_DEMUX, MSGL_INFO, " Creation timestamp: %s\n", &text[2]); | |
1195 break; | |
1196 case MOV_FOURCC(0xa9,'f','m','t'): | |
1197 mp_msg(MSGT_DEMUX, MSGL_INFO, " Format: %s\n", &text[2]); | |
1198 break; | |
1199 case MOV_FOURCC(0xa9,'p','r','d'): | |
1200 mp_msg(MSGT_DEMUX, MSGL_INFO, " Producer: %s\n", &text[2]); | |
1201 break; | |
1202 case MOV_FOURCC(0xa9,'p','r','f'): | |
1203 mp_msg(MSGT_DEMUX, MSGL_INFO, " Performer(s): %s\n", &text[2]); | |
1204 break; | |
1205 case MOV_FOURCC(0xa9,'s','r','c'): | |
1206 mp_msg(MSGT_DEMUX, MSGL_INFO, " Source providers: %s\n", &text[2]); | |
1207 break; | |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1208 } |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1209 udta_size -= 4+text_len; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1210 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1211 } |
2542 | 1212 /* some other shits: WLOC - window location, |
1213 LOOP - looping style, | |
1214 SelO - play only selected frames | |
1215 AllF - play all frames | |
1216 */ | |
1217 case MOV_FOURCC('W','L','O','C'): | |
1218 case MOV_FOURCC('L','O','O','P'): | |
1219 case MOV_FOURCC('S','e','l','O'): | |
1220 case MOV_FOURCC('A','l','l','F'): | |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1221 default: |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1222 { |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1223 char dump[udta_len-4]; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1224 stream_read(demuxer->stream, (char *)&dump, udta_len-4-4); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1225 udta_size -= udta_len; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1226 } |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1227 } |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1228 } |
2532 | 1229 break; |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1230 } /* eof udta */ |
2532 | 1231 default: |
4903
d8b465e3fd88
fixed some endian issues, like changing bswap_32() -> be2me_32(), and
melanson
parents:
4646
diff
changeset
|
1232 id = be2me_32(id); |
2532 | 1233 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: unknown chunk: %.4s %d\n",&id,(int)len); |
1234 } /* endof switch */ | |
1235 } /* endof else */ | |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
1236 |
1490 | 1237 pos+=len+8; |
1238 if(pos>=endpos) break; | |
1239 if(!stream_seek(demuxer->stream,pos)) break; | |
1240 } | |
1241 } | |
1242 | |
1243 int mov_read_header(demuxer_t* demuxer){ | |
1244 mov_priv_t* priv=demuxer->priv; | |
1245 | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
1246 mp_msg(MSGT_DEMUX, MSGL_DBG3, "mov_read_header!\n"); |
1490 | 1247 |
1248 // Parse header: | |
2100 | 1249 stream_reset(demuxer->stream); |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
1250 if(!stream_seek(demuxer->stream,priv->moov_start)) |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
1251 { |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
1252 mp_msg(MSGT_DEMUX,MSGL_ERR,"MOV: Cannot seek to the beginning of the Movie header (0x%x)\n", |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
1253 priv->moov_start); |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
1254 return 0; |
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
1255 } |
1490 | 1256 lschunks(demuxer, 0, priv->moov_end, NULL); |
1257 | |
2127 | 1258 return 1; |
1490 | 1259 } |
2101 | 1260 |
1261 // return value: | |
1262 // 0 = EOF or no stream found | |
1263 // 1 = successfully read a packet | |
1264 int demux_mov_fill_buffer(demuxer_t *demuxer,demux_stream_t* ds){ | |
1265 mov_priv_t* priv=demuxer->priv; | |
1266 mov_track_t* trak=NULL; | |
1267 float pts; | |
5252 | 1268 int x; |
1269 off_t pos; | |
2101 | 1270 |
1271 if(ds->id<0 || ds->id>=priv->track_db) return 0; | |
1272 trak=priv->tracks[ds->id]; | |
1273 | |
2115 | 1274 if(trak->samplesize){ |
1275 // read chunk: | |
1276 if(trak->pos>=trak->chunks_size) return 0; // EOF | |
1277 stream_seek(demuxer->stream,trak->chunks[trak->pos].pos); | |
1278 pts=(float)(trak->chunks[trak->pos].sample*trak->duration)/(float)trak->timescale; | |
3071 | 1279 if(trak->samplesize!=1) |
1280 { | |
4645
33c2fc18138c
added nmhd, added checking for audio trak in demux_mov_fill_buffer
alex
parents:
4624
diff
changeset
|
1281 mp_msg(MSGT_DEMUX, MSGL_DBG2, "WARNING! Samplesize(%d) != 1\n", |
3071 | 1282 trak->samplesize); |
1283 x=trak->chunks[trak->pos].size*trak->samplesize; | |
1284 } | |
1285 else | |
1286 x=trak->chunks[trak->pos].size; | |
3652
65fd971932dc
added co64 (64bit chunk offset table) chunk (needed for mov files created with xawtv) and added depth detection in video track (tested with my *.mov files (about 15-20) and worked fine)
alex
parents:
3071
diff
changeset
|
1287 // printf("X = %d\n", x); |
4645
33c2fc18138c
added nmhd, added checking for audio trak in demux_mov_fill_buffer
alex
parents:
4624
diff
changeset
|
1288 /* the following stuff is audio related */ |
33c2fc18138c
added nmhd, added checking for audio trak in demux_mov_fill_buffer
alex
parents:
4624
diff
changeset
|
1289 if (trak->type == MOV_TRAK_AUDIO) |
33c2fc18138c
added nmhd, added checking for audio trak in demux_mov_fill_buffer
alex
parents:
4624
diff
changeset
|
1290 { |
4624 | 1291 if(trak->stdata_len>=36 && trak->stdata[30] && trak->stdata[31]){ |
2543 | 1292 // extended stsd header - works for CBR MP3: |
1293 x/=(trak->stdata[30]<<8)+trak->stdata[31]; // samples/packet | |
1294 // x*=(trak->stdata[34]<<8)+trak->stdata[35]; // bytes/packet | |
1295 x*=(trak->stdata[38]<<8)+trak->stdata[39]; // bytes/frame | |
1296 } else { | |
1297 // works for ima4: -- we should find this info in mov headers! | |
2549 | 1298 if(ds->ss_div!=1 || ds->ss_mul!=1){ |
1299 x/=ds->ss_div; x*=ds->ss_mul; // compression ratio fix ! HACK ! | |
1300 } else { | |
1301 x*=(trak->stdata[18]<<8)+trak->stdata[19];x/=8; // bits/sample | |
1302 } | |
2543 | 1303 } |
5085
3d558414320f
workaround in palette reader for statunit6.mov, needed to implement support for flag&0x4 and small changes to avoid some sig11-places in the badly muxed cinepak pro movs
alex
parents:
5067
diff
changeset
|
1304 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Audio sample %d bytes pts %5.3f\n",trak->chunks[trak->pos].size*trak->samplesize,pts); |
4645
33c2fc18138c
added nmhd, added checking for audio trak in demux_mov_fill_buffer
alex
parents:
4624
diff
changeset
|
1305 } /* MOV_TRAK_AUDIO */ |
5252 | 1306 pos=trak->chunks[trak->pos].pos; |
2115 | 1307 } else { |
2101 | 1308 // read sample: |
1309 if(trak->pos>=trak->samples_size) return 0; // EOF | |
1310 stream_seek(demuxer->stream,trak->samples[trak->pos].pos); | |
1311 pts=(float)trak->samples[trak->pos].pts/(float)trak->timescale; | |
5252 | 1312 x=trak->samples[trak->pos].size; |
1313 pos=trak->samples[trak->pos].pos; | |
2115 | 1314 } |
5252 | 1315 if(trak->pos==0 && trak->stream_header_len>0){ |
1316 // we have to append the stream header... | |
1317 demux_packet_t* dp=new_demux_packet(x+trak->stream_header_len); | |
1318 memcpy(dp->buffer,trak->stream_header,trak->stream_header_len); | |
1319 stream_read(demuxer->stream,dp->buffer+trak->stream_header_len,x); | |
5307
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
1320 free(trak->stream_header); |
fb58b4a8fb18
Use esds parser for movie esds atom and only pass decoder specific configuration into the stream_header.
atmos4
parents:
5305
diff
changeset
|
1321 trak->stream_header = NULL; |
5252 | 1322 dp->pts=pts; |
1323 dp->flags=0; | |
1324 dp->pos=pos; // FIXME? | |
1325 ds_add_packet(ds,dp); | |
1326 } else | |
1327 ds_read_packet(ds,demuxer->stream,x,pts,pos,0); | |
1328 | |
2101 | 1329 ++trak->pos; |
2115 | 1330 |
2101 | 1331 return 1; |
1332 | |
1333 } | |
2227 | 1334 |
1335 static float mov_seek_track(mov_track_t* trak,float pts,int flags){ | |
1336 | |
1337 // printf("MOV track seek called %5.3f \n",pts); | |
1338 if(flags&2) pts*=trak->length; else pts*=(float)trak->timescale; | |
1339 | |
1340 if(trak->samplesize){ | |
1341 int sample=pts/trak->duration; | |
1342 // printf("MOV track seek - chunk: %d (pts: %5.3f dur=%d) \n",sample,pts,trak->duration); | |
1343 if(!(flags&1)) sample+=trak->chunks[trak->pos].sample; // relative | |
1344 trak->pos=0; | |
1345 while(trak->pos<trak->chunks_size && trak->chunks[trak->pos].sample<sample) ++trak->pos; | |
1346 pts=(float)(trak->chunks[trak->pos].sample*trak->duration)/(float)trak->timescale; | |
1347 } else { | |
2545 | 1348 unsigned int ipts; |
1349 if(!(flags&1)) pts+=trak->samples[trak->pos].pts; | |
1350 if(pts<0) pts=0; | |
1351 ipts=pts; | |
1352 //printf("MOV track seek - sample: %d \n",ipts); | |
2544 | 1353 for(trak->pos=0;trak->pos<trak->samples_size;++trak->pos){ |
1354 if(trak->samples[trak->pos].pts>=ipts) break; // found it! | |
1355 } | |
1356 if(trak->keyframes_size){ | |
1357 // find nearest keyframe | |
1358 int i; | |
1359 for(i=0;i<trak->keyframes_size;i++){ | |
1360 if(trak->keyframes[i]>=trak->pos) break; | |
1361 } | |
2546
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
1362 if(i>0 && (trak->keyframes[i]-trak->pos) > (trak->pos-trak->keyframes[i-1])) |
c9485365537d
added edit atom (edit list), some comments and typos fixes
alex
parents:
2545
diff
changeset
|
1363 --i; |
2544 | 1364 trak->pos=trak->keyframes[i]; |
1365 // printf("nearest keyframe: %d \n",trak->pos); | |
1366 } | |
2227 | 1367 pts=(float)trak->samples[trak->pos].pts/(float)trak->timescale; |
1368 } | |
1369 | |
1370 // printf("MOV track seek done: %5.3f \n",pts); | |
1371 | |
1372 return pts; | |
1373 } | |
1374 | |
1375 void demux_seek_mov(demuxer_t *demuxer,float pts,int flags){ | |
1376 mov_priv_t* priv=demuxer->priv; | |
1377 demux_stream_t* ds; | |
1378 | |
1379 // printf("MOV seek called %5.3f flag=%d \n",pts,flags); | |
1380 | |
1381 ds=demuxer->video; | |
1382 if(ds && ds->id>=0 && ds->id<priv->track_db){ | |
1383 mov_track_t* trak=priv->tracks[ds->id]; | |
1384 //if(flags&2) pts*=(float)trak->length/(float)trak->timescale; | |
1385 //if(!(flags&1)) pts+=ds->pts; | |
1386 pts=ds->pts=mov_seek_track(trak,pts,flags); | |
1387 flags=1; // absolute seconds | |
1388 } | |
1389 | |
1390 ds=demuxer->audio; | |
1391 if(ds && ds->id>=0 && ds->id<priv->track_db){ | |
1392 mov_track_t* trak=priv->tracks[ds->id]; | |
1393 //if(flags&2) pts*=(float)trak->length/(float)trak->timescale; | |
1394 //if(!(flags&1)) pts+=ds->pts; | |
1395 ds->pts=mov_seek_track(trak,pts,flags); | |
1396 } | |
1397 | |
1398 } | |
1399 |