Mercurial > mplayer.hg
annotate libmpdemux/demux_mov.c @ 2507:ad6424619117
cursor on/off, screenblank off -> fbdev
author | gabucino |
---|---|
date | Sun, 28 Oct 2001 10:47:06 +0000 |
parents | 22bfa362af42 |
children | 1adeb4ce84d4 |
rev | line source |
---|---|
2148 | 1 // QuickTime MOV file parser by A'rpi |
2 // based on TOOLS/movinfo.c by me & Al3x | |
3 // compressed header support from moov.c of the openquicktime lib. | |
2386 | 4 // References: http://openquicktime.sf.net/, http://www.heroinewarrior.com/ |
1490 | 5 |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #include <unistd.h> | |
9 | |
1567 | 10 #include "config.h" |
2148 | 11 |
1567 | 12 #include "mp_msg.h" |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1567
diff
changeset
|
13 #include "help_mp.h" |
1490 | 14 |
15 #include "stream.h" | |
16 #include "demuxer.h" | |
17 #include "stheader.h" | |
18 | |
2386 | 19 #include "bswap.h" |
20 | |
2148 | 21 #ifdef HAVE_ZLIB |
22 #include <zlib.h> | |
23 #endif | |
24 | |
1490 | 25 typedef struct { |
2100 | 26 unsigned int pts; // duration |
27 unsigned int size; | |
28 off_t pos; | |
29 } mov_sample_t; | |
30 | |
31 typedef struct { | |
2115 | 32 unsigned int sample; // number of the first sample in teh chunk |
33 unsigned int size; // number of samples in the chunk | |
34 int desc; // for multiple codecs mode - not used | |
2100 | 35 off_t pos; |
36 } mov_chunk_t; | |
37 | |
38 typedef struct { | |
39 unsigned int first; | |
40 unsigned int spc; | |
41 unsigned int sdid; | |
42 } mov_chunkmap_t; | |
43 | |
44 typedef struct { | |
2115 | 45 unsigned int num; |
46 unsigned int dur; | |
47 } mov_durmap_t; | |
48 | |
49 typedef struct { | |
1490 | 50 int id; |
51 int type; | |
2101 | 52 int pos; |
53 // | |
1490 | 54 int timescale; |
2100 | 55 unsigned int length; |
2115 | 56 int samplesize; // 0 = variable |
57 int duration; // 0 = variable | |
1490 | 58 int width,height; // for video |
59 unsigned int fourcc; | |
2115 | 60 // |
2101 | 61 int tkdata_len; // track data |
62 unsigned char* tkdata; | |
63 int stdata_len; // stream data | |
64 unsigned char* stdata; | |
2100 | 65 int samples_size; |
66 mov_sample_t* samples; | |
67 int chunks_size; | |
68 mov_chunk_t* chunks; | |
69 int chunkmap_size; | |
70 mov_chunkmap_t* chunkmap; | |
2115 | 71 int durmap_size; |
72 mov_durmap_t* durmap; | |
1490 | 73 } mov_track_t; |
74 | |
2100 | 75 void mov_build_index(mov_track_t* trak){ |
76 int i,j,s; | |
77 int last=trak->chunks_size; | |
2115 | 78 unsigned int pts=0; |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
79 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
|
80 mp_msg(MSGT_DEMUX, MSGL_HINT, "pts=%d scale=%d time=%5.3f\n",trak->length,trak->timescale,(float)trak->length/(float)trak->timescale); |
2100 | 81 // process chunkmap: |
82 i=trak->chunkmap_size; | |
83 while(i>0){ | |
84 --i; | |
85 for(j=trak->chunkmap[i].first;j<last;j++){ | |
86 trak->chunks[j].desc=trak->chunkmap[i].sdid; | |
87 trak->chunks[j].size=trak->chunkmap[i].spc; | |
88 } | |
89 last=trak->chunkmap[i].first; | |
90 } | |
2115 | 91 |
92 // calc pts of chunks: | |
93 s=0; | |
94 for(j=0;j<trak->chunks_size;j++){ | |
95 trak->chunks[j].sample=s; | |
96 s+=trak->chunks[j].size; | |
97 } | |
98 | |
99 if(!trak->samples_size){ | |
100 // constant sampesize | |
101 if(trak->durmap_size==1 || (trak->durmap_size==2 && trak->durmap[1].num==1)){ | |
2227 | 102 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
|
103 } 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 | 104 return; |
105 } | |
106 | |
107 // calc pts: | |
108 s=0; | |
109 for(j=0;j<trak->durmap_size;j++){ | |
110 for(i=0;i<trak->durmap[j].num;i++){ | |
111 trak->samples[s].pts=pts; | |
112 ++s; | |
113 pts+=trak->durmap[j].dur; | |
114 } | |
115 } | |
2100 | 116 |
117 // calc sample offsets | |
118 s=0; | |
119 for(j=0;j<trak->chunks_size;j++){ | |
120 off_t pos=trak->chunks[j].pos; | |
121 for(i=0;i<trak->chunks[j].size;i++){ | |
122 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
|
123 mp_msg(MSGT_DEMUX, MSGL_DBG3, "Sample %5d: pts=%8d off=0x%08X size=%d\n",s, |
2100 | 124 trak->samples[s].pts, |
125 (int)trak->samples[s].pos, | |
126 trak->samples[s].size); | |
127 pos+=trak->samples[s].size; | |
128 ++s; | |
129 } | |
130 } | |
131 | |
132 } | |
133 | |
1490 | 134 #define MOV_MAX_TRACKS 256 |
135 | |
136 #define MOV_TRAK_UNKNOWN 0 | |
137 #define MOV_TRAK_VIDEO 1 | |
138 #define MOV_TRAK_AUDIO 2 | |
139 | |
140 typedef struct { | |
141 off_t moov_start; | |
142 off_t moov_end; | |
143 off_t mdat_start; | |
144 off_t mdat_end; | |
145 int track_db; | |
146 mov_track_t* tracks[MOV_MAX_TRACKS]; | |
147 } mov_priv_t; | |
148 | |
149 #define MOV_FOURCC(a,b,c,d) ((a<<24)|(b<<16)|(c<<8)|(d)) | |
150 | |
151 int mov_check_file(demuxer_t* demuxer){ | |
152 int flags=0; | |
153 mov_priv_t* priv=malloc(sizeof(mov_priv_t)); | |
154 | |
1567 | 155 mp_msg(MSGT_DEMUX,MSGL_V,"Checking for MOV\n"); |
1490 | 156 |
157 memset(priv,0,sizeof(mov_priv_t)); | |
158 demuxer->priv=priv; | |
159 | |
160 while(1){ | |
161 off_t len=stream_read_dword(demuxer->stream); | |
162 unsigned int id=stream_read_dword(demuxer->stream); | |
163 if(stream_eof(demuxer->stream)) break; // EOF | |
164 if(len<8) break; // invalid chunk | |
165 switch(id){ | |
166 case MOV_FOURCC('m','o','o','v'): | |
1567 | 167 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: Movie header found!\n"); |
1490 | 168 priv->moov_start=stream_tell(demuxer->stream); |
169 priv->moov_end=priv->moov_start+len-8; | |
170 flags|=1; | |
171 break; | |
172 case MOV_FOURCC('m','d','a','t'): | |
1567 | 173 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: Movie DATA found!\n"); |
1490 | 174 priv->mdat_start=stream_tell(demuxer->stream); |
175 priv->mdat_end=priv->mdat_start+len-8; | |
176 flags|=2; | |
177 break; | |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
178 case MOV_FOURCC('f','r','e','e'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
179 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
180 case MOV_FOURCC('w','i','d','e'): |
1490 | 181 default: |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
182 id = bswap_32(id); |
1567 | 183 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: unknown chunk: %.4s %d\n",&id,(int)len); |
1490 | 184 } |
185 if(!stream_skip(demuxer->stream,len-8)) break; | |
186 } | |
2148 | 187 |
188 if(flags==1) | |
189 mp_msg(MSGT_DEMUX,MSGL_WARN,"MOV: missing data (mdat) chunk! Maybe broken file...\n"); | |
190 else if(flags==2) | |
191 mp_msg(MSGT_DEMUX,MSGL_WARN,"MOV: missing header (moov/cmov) chunk! Maybe broken file...\n"); | |
1490 | 192 |
193 return (flags==3); | |
194 } | |
195 | |
196 static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak){ | |
197 mov_priv_t* priv=demuxer->priv; | |
198 while(1){ | |
199 off_t pos; | |
200 off_t len; | |
201 unsigned int id; | |
202 // | |
203 pos=stream_tell(demuxer->stream); | |
2148 | 204 // printf("stream_tell==%d\n",pos); |
1490 | 205 if(pos>=endpos) return; // END |
206 len=stream_read_dword(demuxer->stream); | |
2148 | 207 // printf("len==%d\n",len); |
1490 | 208 if(len<8) return; // error |
209 len-=8; | |
210 id=stream_read_dword(demuxer->stream); | |
211 // | |
1567 | 212 mp_msg(MSGT_DEMUX,MSGL_DBG2,"lschunks %.4s %d\n",&id,(int)len); |
1490 | 213 // |
214 if(trak){ | |
215 switch(id){ | |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
216 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
|
217 /* here not supported :p */ |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
218 break; |
1490 | 219 case MOV_FOURCC('t','k','h','d'): { |
1567 | 220 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sTrack header!\n",level,""); |
2101 | 221 // read codec data |
222 trak->tkdata_len=len; | |
223 trak->tkdata=malloc(trak->tkdata_len); | |
224 stream_read(demuxer->stream,trak->tkdata,trak->tkdata_len); | |
1490 | 225 break; |
226 } | |
227 case MOV_FOURCC('m','d','h','d'): { | |
2100 | 228 unsigned int tmp; |
1567 | 229 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sMedia header!\n",level,""); |
2100 | 230 #if 0 |
231 tmp=stream_read_dword(demuxer->stream); | |
232 printf("dword1: 0x%08X (%d)\n",tmp,tmp); | |
233 tmp=stream_read_dword(demuxer->stream); | |
234 printf("dword2: 0x%08X (%d)\n",tmp,tmp); | |
235 tmp=stream_read_dword(demuxer->stream); | |
236 printf("dword3: 0x%08X (%d)\n",tmp,tmp); | |
237 tmp=stream_read_dword(demuxer->stream); | |
238 printf("dword4: 0x%08X (%d)\n",tmp,tmp); | |
239 tmp=stream_read_dword(demuxer->stream); | |
240 printf("dword5: 0x%08X (%d)\n",tmp,tmp); | |
241 tmp=stream_read_dword(demuxer->stream); | |
242 printf("dword6: 0x%08X (%d)\n",tmp,tmp); | |
243 #endif | |
244 stream_skip(demuxer->stream,12); | |
1490 | 245 // read timescale |
2100 | 246 trak->timescale=stream_read_dword(demuxer->stream); |
247 // read length | |
248 trak->length=stream_read_dword(demuxer->stream); | |
1490 | 249 break; |
250 } | |
251 case MOV_FOURCC('v','m','h','d'): { | |
1567 | 252 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sVideo header!\n",level,""); |
1490 | 253 trak->type=MOV_TRAK_VIDEO; |
254 // read video data | |
255 break; | |
256 } | |
257 case MOV_FOURCC('s','m','h','d'): { | |
1567 | 258 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSound header!\n",level,""); |
1490 | 259 trak->type=MOV_TRAK_AUDIO; |
260 // read audio data | |
261 break; | |
262 } | |
263 case MOV_FOURCC('s','t','s','d'): { | |
264 int i=stream_read_dword(demuxer->stream); // temp! | |
265 int count=stream_read_dword(demuxer->stream); | |
1567 | 266 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sDescription list! (cnt:%d)\n",level,"",count); |
1490 | 267 for(i=0;i<count;i++){ |
268 off_t pos=stream_tell(demuxer->stream); | |
269 off_t len=stream_read_dword(demuxer->stream); | |
270 unsigned int fourcc=stream_read_dword_le(demuxer->stream); | |
271 if(len<8) break; // error | |
1567 | 272 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*s desc #%d: %.4s",level,"",i,&fourcc); |
1490 | 273 if(!i){ |
274 trak->fourcc=fourcc; | |
275 // read codec data | |
2101 | 276 trak->stdata_len=len-8; |
277 trak->stdata=malloc(trak->stdata_len); | |
278 stream_read(demuxer->stream,trak->stdata,trak->stdata_len); | |
279 if(trak->type==MOV_TRAK_VIDEO && trak->stdata_len>43){ | |
280 mp_msg(MSGT_DEMUX,MSGL_V," '%.*s'",trak->stdata_len-43,trak->stdata+43); | |
1490 | 281 } |
282 } | |
1567 | 283 mp_msg(MSGT_DEMUX,MSGL_V,"\n"); |
1490 | 284 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
|
285 mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_MOVvariableFourCC); |
1490 | 286 if(!stream_seek(demuxer->stream,pos+len)) break; |
287 } | |
288 break; | |
289 } | |
2100 | 290 case MOV_FOURCC('s','t','t','s'): { |
291 int temp=stream_read_dword(demuxer->stream); | |
292 int len=stream_read_dword(demuxer->stream); | |
293 int i; | |
294 int x=0; | |
295 unsigned int pts=0; | |
296 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample duration table! (%d blocks)\n",level,"",len); | |
2115 | 297 trak->durmap=malloc(sizeof(mov_durmap_t)*len); |
298 memset(trak->durmap,0,sizeof(mov_durmap_t)*len); | |
299 trak->durmap_size=len; | |
2100 | 300 for(i=0;i<len;i++){ |
2115 | 301 trak->durmap[i].num=stream_read_dword(demuxer->stream); |
302 trak->durmap[i].dur=stream_read_dword(demuxer->stream); | |
303 pts+=trak->durmap[i].num*trak->durmap[i].dur; | |
2386 | 304 |
305 if(i==0) | |
306 { | |
307 sh_video_t* sh=new_sh_video(demuxer,priv->track_db); | |
308 if (!sh->fps) | |
309 sh->fps = trak->timescale/trak->durmap[i].dur; | |
310 /* initial fps */ | |
311 } | |
2100 | 312 } |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
313 if(trak->length!=pts) mp_msg(MSGT_DEMUX, MSGL_WARN, "Warning! pts=%d length=%d\n",pts,trak->length); |
2100 | 314 break; |
315 } | |
316 case MOV_FOURCC('s','t','s','c'): { | |
317 int temp=stream_read_dword(demuxer->stream); | |
318 int len=stream_read_dword(demuxer->stream); | |
319 int i; | |
320 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample->Chunk mapping table! (%d blocks)\n",level,"",len); | |
321 // read data: | |
322 trak->chunkmap_size=len; | |
323 trak->chunkmap=malloc(sizeof(mov_chunkmap_t)*len); | |
324 for(i=0;i<len;i++){ | |
2103 | 325 trak->chunkmap[i].first=stream_read_dword(demuxer->stream)-1; |
2100 | 326 trak->chunkmap[i].spc=stream_read_dword(demuxer->stream); |
327 trak->chunkmap[i].sdid=stream_read_dword(demuxer->stream); | |
328 } | |
329 break; | |
330 } | |
331 case MOV_FOURCC('s','t','s','z'): { | |
332 int temp=stream_read_dword(demuxer->stream); | |
333 int ss=stream_read_dword(demuxer->stream); | |
334 int len=stream_read_dword(demuxer->stream); | |
335 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample size table! len=%d ss=%d\n",level,"",len,ss); | |
2115 | 336 trak->samplesize=ss; |
337 if(!ss){ | |
338 // variable samplesize | |
339 int i; | |
2100 | 340 trak->samples=realloc(trak->samples,sizeof(mov_sample_t)*len); |
341 trak->samples_size=len; | |
2115 | 342 for(i=0;i<len;i++) |
343 trak->samples[i].size=stream_read_dword(demuxer->stream); | |
2100 | 344 } |
345 break; | |
346 } | |
347 case MOV_FOURCC('s','t','c','o'): { | |
348 int temp=stream_read_dword(demuxer->stream); | |
349 int len=stream_read_dword(demuxer->stream); | |
350 int i; | |
351 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sChunk offset table! (%d chunks)\n",level,"",len); | |
352 // extend array if needed: | |
353 if(len>trak->chunks_size){ | |
354 trak->chunks=realloc(trak->chunks,sizeof(mov_chunk_t)*len); | |
355 trak->chunks_size=len; | |
356 } | |
357 // read elements: | |
358 for(i=0;i<len;i++) trak->chunks[i].pos=stream_read_dword(demuxer->stream); | |
359 break; | |
360 } | |
1490 | 361 case MOV_FOURCC('m','d','i','a'): { |
1567 | 362 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sMedia stream!\n",level,""); |
1490 | 363 lschunks(demuxer,level+1,pos+len,trak); |
364 break; | |
365 } | |
366 case MOV_FOURCC('m','i','n','f'): { | |
1567 | 367 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sMedia info!\n",level,""); |
1490 | 368 lschunks(demuxer,level+1,pos+len,trak); |
369 break; | |
370 } | |
371 case MOV_FOURCC('s','t','b','l'): { | |
1567 | 372 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: %*sSample info!\n",level,""); |
1490 | 373 lschunks(demuxer,level+1,pos+len,trak); |
374 break; | |
375 } | |
376 }//switch(id) | |
377 } else | |
378 if(id==MOV_FOURCC('t','r','a','k')){ | |
379 // if(trak) printf("MOV: Warning! trak in trak?\n"); | |
380 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
|
381 mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_MOVtooManyTrk); |
1490 | 382 return; |
383 } | |
384 trak=malloc(sizeof(mov_track_t)); | |
385 memset(trak,0,sizeof(mov_track_t)); | |
1567 | 386 mp_msg(MSGT_DEMUX,MSGL_V,"MOV: Track #%d:\n",priv->track_db); |
1490 | 387 trak->id=priv->track_db; |
2100 | 388 priv->tracks[priv->track_db]=trak; |
1490 | 389 lschunks(demuxer,level+1,pos+len,trak); |
2100 | 390 mov_build_index(trak); |
391 switch(trak->type){ | |
392 case MOV_TRAK_AUDIO: { | |
393 sh_audio_t* sh=new_sh_audio(demuxer,priv->track_db); | |
394 sh->format=trak->fourcc; | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
395 mp_msg(MSGT_DEMUX, MSGL_INFO, "Audio bits: %d chans: %d\n",trak->stdata[19],trak->stdata[17]); |
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
396 mp_msg(MSGT_DEMUX, MSGL_INFO, "Fourcc: %.4s\n",&trak->fourcc); |
2101 | 397 // Emulate WAVEFORMATEX struct: |
398 sh->wf=malloc(sizeof(WAVEFORMATEX)); | |
399 memset(sh->wf,0,sizeof(WAVEFORMATEX)); | |
400 sh->wf->nChannels=trak->stdata[17]; | |
401 sh->wf->wBitsPerSample=trak->stdata[19]; | |
402 sh->wf->nSamplesPerSec=trak->timescale; | |
403 sh->wf->nAvgBytesPerSec=sh->wf->nChannels*((sh->wf->wBitsPerSample+7)/8)*sh->wf->nSamplesPerSec; | |
404 // Selection: | |
405 if(demuxer->audio->id==-1 || demuxer->audio->id==priv->track_db){ | |
406 // (auto)selected audio track: | |
407 demuxer->audio->id=priv->track_db; | |
408 demuxer->audio->sh=sh; sh->ds=demuxer->audio; | |
409 } | |
2100 | 410 break; |
411 } | |
412 case MOV_TRAK_VIDEO: { | |
413 sh_video_t* sh=new_sh_video(demuxer,priv->track_db); | |
414 sh->format=trak->fourcc; | |
2386 | 415 if(!sh->fps) sh->fps=trak->timescale; |
2100 | 416 sh->frametime=1.0f/sh->fps; |
2101 | 417 sh->disp_w=trak->tkdata[77]|(trak->tkdata[76]<<8); |
418 sh->disp_h=trak->tkdata[81]|(trak->tkdata[80]<<8); | |
419 | |
420 // emulate BITMAPINFOHEADER: | |
421 sh->bih=malloc(sizeof(BITMAPINFOHEADER)); | |
422 memset(sh->bih,0,sizeof(BITMAPINFOHEADER)); | |
423 sh->bih->biSize=40; | |
424 sh->bih->biWidth=sh->disp_w; | |
425 sh->bih->biHeight=sh->disp_h; | |
426 sh->bih->biPlanes=0; | |
427 sh->bih->biBitCount=16; | |
428 sh->bih->biCompression=trak->fourcc; | |
429 sh->bih->biSizeImage=sh->bih->biWidth*sh->bih->biHeight; | |
430 | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
431 mp_msg(MSGT_DEMUX, MSGL_INFO, "Image size: %d x %d\n",sh->disp_w,sh->disp_h); |
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
432 mp_msg(MSGT_DEMUX, MSGL_INFO, "Fourcc: %.4s Codec: '%.*s'\n",&trak->fourcc,trak->stdata_len-43,trak->stdata+43); |
2115 | 433 |
2101 | 434 if(demuxer->video->id==-1 || demuxer->video->id==priv->track_db){ |
435 // (auto)selected video track: | |
436 demuxer->video->id=priv->track_db; | |
437 demuxer->video->sh=sh; sh->ds=demuxer->video; | |
438 } | |
2100 | 439 break; |
440 } | |
441 } | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
442 mp_msg(MSGT_DEMUX, MSGL_INFO, "--------------\n"); |
2100 | 443 priv->track_db++; |
1490 | 444 trak=NULL; |
445 } else | |
2148 | 446 #ifndef HAVE_ZLIB |
1490 | 447 if(id==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
|
448 mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_MOVcomprhdr); |
1490 | 449 return; |
450 } | |
2148 | 451 #else |
452 if(id==MOV_FOURCC('c','m','o','v')){ | |
453 // mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_MOVcomprhdr); | |
454 lschunks(demuxer,level+1,pos+len,NULL); | |
455 } else | |
456 if(id==MOV_FOURCC('d','c','o','m')){ | |
457 // int temp=stream_read_dword(demuxer->stream); | |
2386 | 458 unsigned int len=bswap_32(stream_read_dword(demuxer->stream)); |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
459 mp_msg(MSGT_DEMUX, MSGL_INFO, "Compressed header uses %.4s algo!\n",&len); |
2148 | 460 } else |
461 if(id==MOV_FOURCC('c','m','v','d')){ | |
462 // int temp=stream_read_dword(demuxer->stream); | |
463 unsigned int moov_sz=stream_read_dword(demuxer->stream); | |
464 unsigned int cmov_sz=len-4; | |
465 unsigned char* cmov_buf=malloc(cmov_sz); | |
466 unsigned char* moov_buf=malloc(moov_sz+16); | |
467 int zret; | |
468 z_stream zstrm; | |
469 stream_t* backup; | |
470 | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
471 mp_msg(MSGT_DEMUX, MSGL_INFO, "Compressed header size: %d / %d\n",cmov_sz,moov_sz); |
2148 | 472 |
473 stream_read(demuxer->stream,cmov_buf,cmov_sz); | |
474 | |
475 zstrm.zalloc = (alloc_func)0; | |
476 zstrm.zfree = (free_func)0; | |
477 zstrm.opaque = (voidpf)0; | |
478 zstrm.next_in = cmov_buf; | |
479 zstrm.avail_in = cmov_sz; | |
480 zstrm.next_out = moov_buf; | |
481 zstrm.avail_out = moov_sz; | |
482 | |
483 zret = inflateInit(&zstrm); | |
484 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
|
485 { mp_msg(MSGT_DEMUX, MSGL_ERR, "QT cmov: inflateInit err %d\n",zret); |
2148 | 486 return; |
487 } | |
488 zret = inflate(&zstrm, Z_NO_FLUSH); | |
489 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
|
490 { mp_msg(MSGT_DEMUX, MSGL_ERR, "QT cmov inflate: ERR %d\n",zret); |
2148 | 491 return; |
492 } | |
493 #if 0 | |
494 else { | |
495 FILE *DecOut; | |
496 DecOut = fopen("Out.bin", "w"); | |
497 fwrite(moov_buf, 1, moov_sz, DecOut); | |
498 fclose(DecOut); | |
499 } | |
500 #endif | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
501 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
|
502 mp_msg(MSGT_DEMUX, MSGL_WARN, "Warning! moov size differs cmov: %d zlib: %d\n",moov_sz,zstrm.total_out); |
2148 | 503 zret = inflateEnd(&zstrm); |
504 | |
505 backup=demuxer->stream; | |
506 demuxer->stream=new_memory_stream(moov_buf,moov_sz); | |
507 stream_skip(demuxer->stream,8); | |
508 lschunks(demuxer,level+1,moov_sz,NULL); // parse uncompr. 'moov' | |
509 //free_stream(demuxer->stream); | |
510 demuxer->stream=backup; | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
511 free(cmov_buf); |
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
512 free(moov_buf); |
2148 | 513 } |
514 #endif | |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
515 else if (id==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
|
516 { |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
517 unsigned int udta_id; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
518 off_t udta_len; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
519 off_t udta_size = len; |
1490 | 520 |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
521 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
|
522 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
|
523 |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
524 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
|
525 { |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
526 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
|
527 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
|
528 udta_size -= 8; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
529 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
|
530 switch (udta_id) |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
531 { |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
532 case MOV_FOURCC(0xa9,'c','p','y'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
533 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
|
534 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
|
535 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
|
536 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
|
537 case MOV_FOURCC(0xa9,'c','m','t'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
538 case MOV_FOURCC(0xa9,'r','e','q'): |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
539 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
|
540 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
|
541 { |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
542 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
|
543 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
|
544 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
|
545 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
|
546 switch(udta_id) |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
547 { |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
548 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
|
549 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
|
550 break; |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
551 case MOV_FOURCC(0xa9,'c','p','y'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
552 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
|
553 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
554 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
|
555 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
|
556 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
557 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
|
558 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
|
559 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
560 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
|
561 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
|
562 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
563 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
|
564 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
|
565 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
566 case MOV_FOURCC(0xa9,'c','m','t'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
567 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
|
568 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
569 case MOV_FOURCC(0xa9,'r','e','q'): |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
570 mp_msg(MSGT_DEMUX, MSGL_INFO, " Requests(codec): %s\n", &text[2]); |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
571 break; |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
572 case MOV_FOURCC(0xa9,'s','w','r'): |
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
573 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
|
574 break; |
2429
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
575 } |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
576 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
|
577 break; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
578 } |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
579 default: |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
580 { |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
581 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
|
582 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
|
583 udta_size -= udta_len; |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
584 } |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
585 } |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
586 } |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
587 } /* eof udta */ |
8d00b25169af
handling free chunk (wide needs implementation) and displaying clip info (datas from udta chunk)
alex
parents:
2419
diff
changeset
|
588 |
1490 | 589 pos+=len+8; |
590 if(pos>=endpos) break; | |
591 if(!stream_seek(demuxer->stream,pos)) break; | |
592 } | |
593 } | |
594 | |
595 int mov_read_header(demuxer_t* demuxer){ | |
596 mov_priv_t* priv=demuxer->priv; | |
597 | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
598 mp_msg(MSGT_DEMUX, MSGL_DBG3, "mov_read_header!\n"); |
1490 | 599 |
600 // Parse header: | |
2100 | 601 stream_reset(demuxer->stream); |
1490 | 602 if(!stream_seek(demuxer->stream,priv->moov_start)) return 0; // ??? |
603 lschunks(demuxer, 0, priv->moov_end, NULL); | |
604 | |
2127 | 605 return 1; |
1490 | 606 } |
2101 | 607 |
608 // return value: | |
609 // 0 = EOF or no stream found | |
610 // 1 = successfully read a packet | |
611 int demux_mov_fill_buffer(demuxer_t *demuxer,demux_stream_t* ds){ | |
612 mov_priv_t* priv=demuxer->priv; | |
613 mov_track_t* trak=NULL; | |
614 float pts; | |
615 | |
616 if(ds->id<0 || ds->id>=priv->track_db) return 0; | |
617 trak=priv->tracks[ds->id]; | |
618 | |
2115 | 619 if(trak->samplesize){ |
620 // read chunk: | |
2419 | 621 int x; |
2115 | 622 if(trak->pos>=trak->chunks_size) return 0; // EOF |
623 stream_seek(demuxer->stream,trak->chunks[trak->pos].pos); | |
624 pts=(float)(trak->chunks[trak->pos].sample*trak->duration)/(float)trak->timescale; | |
2419 | 625 x=trak->chunks[trak->pos].size*trak->samplesize; |
626 x/=ds->ss_div; x*=ds->ss_mul; // compression ratio fix | |
627 ds_read_packet(ds,demuxer->stream,x,pts,trak->chunks[trak->pos].pos,0); | |
2483
22bfa362af42
added two new clip info types, all printf's were upgraded to mp_msg
alex
parents:
2429
diff
changeset
|
628 if(ds==demuxer->audio) mp_msg(MSGT_DEMUX, MSGL_DBG2, "sample %d bytes pts %5.3f\n",trak->chunks[trak->pos].size*trak->samplesize,pts); |
2115 | 629 } else { |
2101 | 630 // read sample: |
631 if(trak->pos>=trak->samples_size) return 0; // EOF | |
632 stream_seek(demuxer->stream,trak->samples[trak->pos].pos); | |
633 pts=(float)trak->samples[trak->pos].pts/(float)trak->timescale; | |
634 ds_read_packet(ds,demuxer->stream,trak->samples[trak->pos].size,pts,trak->samples[trak->pos].pos,0); | |
2115 | 635 } |
2101 | 636 ++trak->pos; |
2115 | 637 |
2101 | 638 return 1; |
639 | |
640 } | |
2227 | 641 |
642 static float mov_seek_track(mov_track_t* trak,float pts,int flags){ | |
643 | |
644 // printf("MOV track seek called %5.3f \n",pts); | |
645 if(flags&2) pts*=trak->length; else pts*=(float)trak->timescale; | |
646 | |
647 if(trak->samplesize){ | |
648 int sample=pts/trak->duration; | |
649 // printf("MOV track seek - chunk: %d (pts: %5.3f dur=%d) \n",sample,pts,trak->duration); | |
650 if(!(flags&1)) sample+=trak->chunks[trak->pos].sample; // relative | |
651 trak->pos=0; | |
652 while(trak->pos<trak->chunks_size && trak->chunks[trak->pos].sample<sample) ++trak->pos; | |
653 pts=(float)(trak->chunks[trak->pos].sample*trak->duration)/(float)trak->timescale; | |
654 } else { | |
655 unsigned int ipts=pts; | |
656 // printf("MOV track seek - sample: %d \n",ipts); | |
657 if(!(flags&1)) ipts+=trak->samples[trak->pos].pts; | |
658 trak->pos=0; | |
659 while(trak->pos<trak->samples_size && trak->samples[trak->pos].pts<ipts) ++trak->pos; | |
660 pts=(float)trak->samples[trak->pos].pts/(float)trak->timescale; | |
661 } | |
662 | |
663 // printf("MOV track seek done: %5.3f \n",pts); | |
664 | |
665 return pts; | |
666 } | |
667 | |
668 void demux_seek_mov(demuxer_t *demuxer,float pts,int flags){ | |
669 mov_priv_t* priv=demuxer->priv; | |
670 demux_stream_t* ds; | |
671 | |
672 // printf("MOV seek called %5.3f flag=%d \n",pts,flags); | |
673 | |
674 ds=demuxer->video; | |
675 if(ds && ds->id>=0 && ds->id<priv->track_db){ | |
676 mov_track_t* trak=priv->tracks[ds->id]; | |
677 //if(flags&2) pts*=(float)trak->length/(float)trak->timescale; | |
678 //if(!(flags&1)) pts+=ds->pts; | |
679 pts=ds->pts=mov_seek_track(trak,pts,flags); | |
680 flags=1; // absolute seconds | |
681 } | |
682 | |
683 ds=demuxer->audio; | |
684 if(ds && ds->id>=0 && ds->id<priv->track_db){ | |
685 mov_track_t* trak=priv->tracks[ds->id]; | |
686 //if(flags&2) pts*=(float)trak->length/(float)trak->timescale; | |
687 //if(!(flags&1)) pts+=ds->pts; | |
688 ds->pts=mov_seek_track(trak,pts,flags); | |
689 } | |
690 | |
691 } | |
692 |