[MPlayer-cvslog] CVS: main/libmpdemux demux_mov.c,1.110,1.111
Reimar Döffinger CVS
syncmail at mplayerhq.hu
Tue Dec 21 13:27:41 CET 2004
CVS change done by Reimar Döffinger CVS
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv9024/libmpdemux
Modified Files:
demux_mov.c
Log Message:
fix position bar and length display for mov files
Index: demux_mov.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mov.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -r1.110 -r1.111
--- demux_mov.c 18 Dec 2004 01:12:02 -0000 1.110
+++ demux_mov.c 21 Dec 2004 12:27:38 -0000 1.111
@@ -1696,6 +1696,18 @@
return 1;
}
+/**
+ * \brief return the mov track that belongs to a demuxer stream
+ * \param ds the demuxer stream, may be NULL
+ * \return the mov track info structure belonging to the stream,
+ * NULL if not found
+ */
+static mov_track_t *stream_track(mov_priv_t *priv, demux_stream_t *ds) {
+ if (ds && (ds->id >= 0) && (ds->id < priv->track_db))
+ return priv->tracks[ds->id];
+ return NULL;
+}
+
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
@@ -1706,8 +1718,8 @@
int x;
off_t pos;
- if(ds->id<0 || ds->id>=priv->track_db) return 0;
- trak=priv->tracks[ds->id];
+ trak = stream_track(priv, ds);
+ if (!trak) return 0;
if(trak->samplesize){
// read chunk:
@@ -1835,12 +1847,13 @@
void demux_seek_mov(demuxer_t *demuxer,float pts,int flags){
mov_priv_t* priv=demuxer->priv;
demux_stream_t* ds;
+ mov_track_t* trak;
// printf("MOV seek called %5.3f flag=%d \n",pts,flags);
ds=demuxer->video;
- if(ds && ds->id>=0 && ds->id<priv->track_db){
- mov_track_t* trak=priv->tracks[ds->id];
+ trak = stream_track(priv, ds);
+ if (trak) {
//if(flags&2) pts*=(float)trak->length/(float)trak->timescale;
//if(!(flags&1)) pts+=ds->pts;
pts=ds->pts=mov_seek_track(trak,pts,flags);
@@ -1848,8 +1861,8 @@
}
ds=demuxer->audio;
- if(ds && ds->id>=0 && ds->id<priv->track_db){
- mov_track_t* trak=priv->tracks[ds->id];
+ trak = stream_track(priv, ds);
+ if (trak) {
//if(flags&2) pts*=(float)trak->length/(float)trak->timescale;
//if(!(flags&1)) pts+=ds->pts;
ds->pts=mov_seek_track(trak,pts,flags);
@@ -1857,3 +1870,34 @@
}
+int demux_mov_control(demuxer_t *demuxer, int cmd, void *arg){
+ mov_track_t* track;
+
+ // try the video track
+ track = stream_track(demuxer->priv, demuxer->video);
+ if (!track || !track->length)
+ // otherwise try to get the info from the audio track
+ track = stream_track(demuxer->priv, demuxer->audio);
+
+ if (!track || !track->length)
+ return DEMUXER_CTRL_DONTKNOW;
+
+ switch(cmd) {
+ case DEMUXER_CTRL_GET_TIME_LENGTH:
+ if (!track->timescale)
+ return DEMUXER_CTRL_DONTKNOW;
+ *((unsigned long *)arg) = track->length / track->timescale;
+ return DEMUXER_CTRL_OK;
+
+ case DEMUXER_CTRL_GET_PERCENT_POS:
+ {
+ off_t pos = track->pos;
+ if (track->durmap_size >= 1)
+ pos *= track->durmap[0].dur;
+ *((int *)arg) = (int)(100 * pos / track->length);
+ return DEMUXER_CTRL_OK;
+ }
+ }
+ return DEMUXER_CTRL_NOTIMPL;
+}
+
More information about the MPlayer-cvslog
mailing list