Mercurial > mplayer.hg
changeset 7441:13716c8114a8
fixing edit-list playback (it uses the mvhd-timescale instead of the mdhd-one)
author | arpi |
---|---|
date | Wed, 18 Sep 2002 19:09:11 +0000 |
parents | db45f7ac40d9 |
children | e306a3dc08b4 |
files | libmpdemux/demux_mov.c |
diffstat | 1 files changed, 37 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_mov.c Wed Sep 18 16:03:22 2002 +0000 +++ b/libmpdemux/demux_mov.c Wed Sep 18 19:09:11 2002 +0000 @@ -138,7 +138,7 @@ void* desc; // image/sound/etc description (pointer to ImageDescription etc) } mov_track_t; -void mov_build_index(mov_track_t* trak){ +void mov_build_index(mov_track_t* trak,int timescale){ int i,j,s; int last=trak->chunks_size; unsigned int pts=0; @@ -248,8 +248,8 @@ if(pts<=trak->samples[sample].pts) break; } el->start_sample=sample; - el->pts_offset=e_pts-trak->samples[sample].pts; - pts+=el->dur; + el->pts_offset=((long long)e_pts*(long long)trak->timescale)/(long long)timescale-trak->samples[sample].pts; + pts+=((long long)el->dur*(long long)trak->timescale)/(long long)timescale; e_pts+=el->dur; // find end sample for(;sample<trak->samples_size;sample++){ @@ -271,6 +271,8 @@ off_t mdat_end; int track_db; mov_track_t* tracks[MOV_MAX_TRACKS]; + int timescale; // movie timescale + int duration; // movie duration (in movie timescale units) } mov_priv_t; #define MOV_FOURCC(a,b,c,d) ((a<<24)|(b<<16)|(c<<8)|(d)) @@ -423,6 +425,29 @@ trak->tkdata_len=len; trak->tkdata=malloc(trak->tkdata_len); stream_read(demuxer->stream,trak->tkdata,trak->tkdata_len); +/* +0 1 Version +1 3 Flags +4 4 Creation time +8 4 Modification time +12 4 Track ID +16 4 Reserved +20 4 Duration +24 8 Reserved +32 2 Layer +34 2 Alternate group +36 2 Volume +38 2 Reserved +40 36 Matrix structure +76 4 Track width +80 4 Track height +*/ + mp_msg(MSGT_DEMUX,MSGL_V,"tkhd len=%d ver=%d flags=0x%X id=%d dur=%d lay=%d vol=%d\n", + trak->tkdata_len, trak->tkdata[0], trak->tkdata[1], + char2int(trak->tkdata,12), // id + char2int(trak->tkdata,20), // duration + char2short(trak->tkdata,32), // layer + char2short(trak->tkdata,36)); // volume break; } case MOV_FOURCC('m','d','h','d'): { @@ -661,6 +686,14 @@ }//switch(id) } else { /* not in track */ switch(id) { + case MOV_FOURCC('m','v','h','d'): { + stream_skip(demuxer->stream,12); + priv->timescale=stream_read_dword(demuxer->stream); + priv->duration=stream_read_dword(demuxer->stream); + mp_msg(MSGT_DEMUX, MSGL_V,"MOV: %*sMovie header (%d bytes): tscale=%d dur=%d\n",level,"",(int)len, + (int)priv->timescale,(int)priv->duration); + break; + } case MOV_FOURCC('t','r','a','k'): { // if(trak) printf("MOV: Warning! trak in trak?\n"); if(priv->track_db>=MOV_MAX_TRACKS){ @@ -674,7 +707,7 @@ trak->id=priv->track_db; priv->tracks[priv->track_db]=trak; lschunks(demuxer,level+1,pos+len,trak); - mov_build_index(trak); + mov_build_index(trak,priv->timescale); switch(trak->type){ case MOV_TRAK_AUDIO: { #if 0