[MPlayer-cvslog] r25911 - in trunk: libmpdemux/demux_aac.c libmpdemux/demux_asf.c libmpdemux/demux_audio.c libmpdemux/demux_avi.c libmpdemux/demux_avs.c libmpdemux/demux_film.c libmpdemux/demux_fli.c libmpdemux/demux_lavf.c libmpdemux/demux_mf.c libmpdemux/demux_mkv.c libmpdemux/demux_mov.c libmpdemux/demux_mpc.c libmpdemux/demux_mpg.c libmpdemux/demux_nut.c libmpdemux/demux_ogg.c libmpdemux/demux_rawaudio.c libmpdemux/demux_rawdv.c libmpdemux/demux_rawvideo.c libmpdemux/demux_real.c libmpdemux/demux_ts.c libmpdemux/demux_ty.c libmpdemux/demux_vqf.c libmpdemux/demux_xmms.c libmpdemux/demuxer.c libmpdemux/demuxer.h mplayer.c

reimar subversion at mplayerhq.hu
Tue Jan 29 16:11:39 CET 2008


Author: reimar
Date: Tue Jan 29 16:11:38 2008
New Revision: 25911

Log:
Use defines to give names to the different seek flags.
A better solution should be considered later, esp. for the many
broken demuxers that do not treat these flags correctly.


Modified:
   trunk/libmpdemux/demux_aac.c
   trunk/libmpdemux/demux_asf.c
   trunk/libmpdemux/demux_audio.c
   trunk/libmpdemux/demux_avi.c
   trunk/libmpdemux/demux_avs.c
   trunk/libmpdemux/demux_film.c
   trunk/libmpdemux/demux_fli.c
   trunk/libmpdemux/demux_lavf.c
   trunk/libmpdemux/demux_mf.c
   trunk/libmpdemux/demux_mkv.c
   trunk/libmpdemux/demux_mov.c
   trunk/libmpdemux/demux_mpc.c
   trunk/libmpdemux/demux_mpg.c
   trunk/libmpdemux/demux_nut.c
   trunk/libmpdemux/demux_ogg.c
   trunk/libmpdemux/demux_rawaudio.c
   trunk/libmpdemux/demux_rawdv.c
   trunk/libmpdemux/demux_rawvideo.c
   trunk/libmpdemux/demux_real.c
   trunk/libmpdemux/demux_ts.c
   trunk/libmpdemux/demux_ty.c
   trunk/libmpdemux/demux_vqf.c
   trunk/libmpdemux/demux_xmms.c
   trunk/libmpdemux/demuxer.c
   trunk/libmpdemux/demuxer.h
   trunk/mplayer.c

Modified: trunk/libmpdemux/demux_aac.c
==============================================================================
--- trunk/libmpdemux/demux_aac.c	(original)
+++ trunk/libmpdemux/demux_aac.c	Tue Jan 29 16:11:38 2008
@@ -218,7 +218,7 @@ static void demux_aac_seek(demuxer_t *de
 
 	ds_free_packs(d_audio);
 
-	time = (flags & 1) ? rel_seek_secs - priv->last_pts : rel_seek_secs;
+	time = (flags & SEEK_ABSOLUTE) ? rel_seek_secs - priv->last_pts : rel_seek_secs;
 	if(time < 0) 
 	{
 		stream_seek(demuxer->stream, demuxer->movi_start);

Modified: trunk/libmpdemux/demux_asf.c
==============================================================================
--- trunk/libmpdemux/demux_asf.c	(original)
+++ trunk/libmpdemux/demux_asf.c	Tue Jan 29 16:11:38 2008
@@ -522,7 +522,7 @@ static void demux_seek_asf(demuxer_t *de
 
   //================= seek in ASF ==========================
     float p_rate=asf->packetrate; // packets / sec
-    off_t rel_seek_packs=(flags&2)?	 // FIXME: int may be enough?
+    off_t rel_seek_packs=(flags&SEEK_FACTOR)?	 // FIXME: int may be enough?
 	(rel_seek_secs*(demuxer->movi_end-demuxer->movi_start)/asf->packetsize):
 	(rel_seek_secs*p_rate);
     off_t rel_seek_bytes=rel_seek_packs*asf->packetsize;
@@ -530,7 +530,7 @@ static void demux_seek_asf(demuxer_t *de
     //printf("ASF: packs: %d  duration: %d  \n",(int)fileh.packets,*((int*)&fileh.duration));
 //    printf("ASF_seek: %d secs -> %d packs -> %d bytes  \n",
 //       rel_seek_secs,rel_seek_packs,rel_seek_bytes);
-    newpos=((flags&1)?demuxer->movi_start:demuxer->filepos)+rel_seek_bytes;
+    newpos=((flags&SEEK_ABSOLUTE)?demuxer->movi_start:demuxer->filepos)+rel_seek_bytes;
     if(newpos<0 || newpos<demuxer->movi_start) newpos=demuxer->movi_start;
 //    printf("\r -- asf: newpos=%d -- \n",newpos);
     stream_seek(demuxer->stream,newpos);

Modified: trunk/libmpdemux/demux_audio.c
==============================================================================
--- trunk/libmpdemux/demux_audio.c	(original)
+++ trunk/libmpdemux/demux_audio.c	Tue Jan 29 16:11:38 2008
@@ -646,8 +646,8 @@ static void demux_audio_seek(demuxer_t *
   s = demuxer->stream;
   priv = demuxer->priv;
 
-  if(priv->frmt == MP3 && hr_mp3_seek && !(flags & 2)) {
-    len = (flags & 1) ? rel_seek_secs - priv->next_pts : rel_seek_secs;
+  if(priv->frmt == MP3 && hr_mp3_seek && !(flags & SEEK_FACTOR)) {
+    len = (flags & SEEK_ABSOLUTE) ? rel_seek_secs - priv->next_pts : rel_seek_secs;
     if(len < 0) {
       stream_seek(s,demuxer->movi_start);
       len = priv->next_pts + len;
@@ -658,8 +658,8 @@ static void demux_audio_seek(demuxer_t *
     return;
   }
 
-  base = flags&1 ? demuxer->movi_start : stream_tell(s);
-  if(flags&2)
+  base = flags&SEEK_ABSOLUTE ? demuxer->movi_start : stream_tell(s);
+  if(flags&SEEK_FACTOR)
     pos = base + ((demuxer->movi_end - demuxer->movi_start)*rel_seek_secs);
   else
     pos = base + (rel_seek_secs*sh_audio->i_bps);

Modified: trunk/libmpdemux/demux_avi.c
==============================================================================
--- trunk/libmpdemux/demux_avi.c	(original)
+++ trunk/libmpdemux/demux_avi.c	Tue Jan 29 16:11:38 2008
@@ -571,12 +571,12 @@ void demux_seek_avi(demuxer_t *demuxer,f
     int video_chunk_pos=d_video->pos;
     int i;
 
-      if(flags&1){
+      if(flags&SEEK_ABSOLUTE){
 	// seek absolute
 	video_chunk_pos=0;
       }
       
-      if(flags&2){
+      if(flags&SEEK_FACTOR){
 	rel_seek_frames=rel_seek_secs*priv->numberofframes;
       }
     

Modified: trunk/libmpdemux/demux_avs.c
==============================================================================
--- trunk/libmpdemux/demux_avs.c	(original)
+++ trunk/libmpdemux/demux_avs.c	Tue Jan 29 16:11:38 2008
@@ -418,10 +418,8 @@ static void demux_seek_avs(demuxer_t *de
     
     //mp_msg(MSGT_DEMUX, MSGL_V, "AVS: seek rel_seek_secs = %f - flags = %x\n", rel_seek_secs, flags);
     
-    // seek absolute
-    if (flags&1) video_pos=0;
-    // seek precent
-    if (flags&2) rel_seek_secs *= duration;
+    if (flags&SEEK_ABSOLUTE) video_pos=0;
+    if (flags&SEEK_FACTOR) rel_seek_secs *= duration;
 
     video_pos += rel_seek_secs;
     if (video_pos < 0) video_pos = 0;

Modified: trunk/libmpdemux/demux_film.c
==============================================================================
--- trunk/libmpdemux/demux_film.c	(original)
+++ trunk/libmpdemux/demux_film.c	Tue Jan 29 16:11:38 2008
@@ -49,9 +49,9 @@ typedef struct film_data_t
 static void demux_seek_film(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags)
 {
   film_data_t *film_data = (film_data_t *)demuxer->priv;
-  int new_current_chunk=(flags&1)?0:film_data->current_chunk;
+  int new_current_chunk=(flags&SEEK_ABSOLUTE)?0:film_data->current_chunk;
 
-  if(flags&2)
+  if(flags&SEEK_FACTOR)
       new_current_chunk += rel_seek_secs * film_data->total_chunks; // 0..1
   else
       new_current_chunk += rel_seek_secs * film_data->chunks_per_second; // secs

Modified: trunk/libmpdemux/demux_fli.c
==============================================================================
--- trunk/libmpdemux/demux_fli.c	(original)
+++ trunk/libmpdemux/demux_fli.c	Tue Jan 29 16:11:38 2008
@@ -25,8 +25,8 @@ typedef struct {
 static void demux_seek_fli(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
   fli_frames_t *frames = (fli_frames_t *)demuxer->priv;
   sh_video_t *sh_video = demuxer->video->sh;
-  int newpos=(flags&1)?0:frames->current_frame;
-  if(flags&2){
+  int newpos=(flags&SEEK_ABSOLUTE)?0:frames->current_frame;
+  if(flags&SEEK_FACTOR){
       // float 0..1
       newpos+=rel_seek_secs*frames->num_frames;
   } else {

Modified: trunk/libmpdemux/demux_lavf.c
==============================================================================
--- trunk/libmpdemux/demux_lavf.c	(original)
+++ trunk/libmpdemux/demux_lavf.c	Tue Jan 29 16:11:38 2008
@@ -614,12 +614,12 @@ static void demux_seek_lavf(demuxer_t *d
     int avsflags = 0;
     mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf(%p, %f, %f, %d)\n", demuxer, rel_seek_secs, audio_delay, flags);
 
-    if (flags & 1) { // absolute seek
+    if (flags & SEEK_ABSOLUTE) {
       priv->last_pts = priv->avfc->start_time;
     } else {
       if (rel_seek_secs < 0) avsflags = AVSEEK_FLAG_BACKWARD;
     }
-    if (flags & 2) { // percent seek
+    if (flags & SEEK_FACTOR) {
       if (priv->avfc->duration == 0 || priv->avfc->duration == AV_NOPTS_VALUE)
         return;
       priv->last_pts += rel_seek_secs * priv->avfc->duration;

Modified: trunk/libmpdemux/demux_mf.c
==============================================================================
--- trunk/libmpdemux/demux_mf.c	(original)
+++ trunk/libmpdemux/demux_mf.c	Tue Jan 29 16:11:38 2008
@@ -18,9 +18,9 @@
 static void demux_seek_mf(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
   mf_t * mf = (mf_t *)demuxer->priv;
   sh_video_t   * sh_video = demuxer->video->sh;
-  int newpos = (flags & 1)?0:mf->curr_frame - 1;
+  int newpos = (flags & SEEK_ABSOLUTE)?0:mf->curr_frame - 1;
   
-  if ( flags & 2 ) newpos+=rel_seek_secs*(mf->nr_of_files - 1);
+  if ( flags & SEEK_FACTOR ) newpos+=rel_seek_secs*(mf->nr_of_files - 1);
    else newpos+=rel_seek_secs * sh_video->fps;
   if ( newpos < 0 ) newpos=0;
   if( newpos >= mf->nr_of_files) newpos=mf->nr_of_files - 1;

Modified: trunk/libmpdemux/demux_mkv.c
==============================================================================
--- trunk/libmpdemux/demux_mkv.c	(original)
+++ trunk/libmpdemux/demux_mkv.c	Tue Jan 29 16:11:38 2008
@@ -2534,7 +2534,8 @@ demux_mkv_open (demuxer_t *demuxer)
               mkv_d->has_first_tc = 1;
             }
           demux_mkv_seek (demuxer,
-                          demuxer->chapters[dvd_chapter-1].start/1000.0, 0.0, 1);
+                          demuxer->chapters[dvd_chapter-1].start/1000.0, 0.0,
+                          SEEK_ABSOLUTE);
         }
     }
 
@@ -3289,14 +3290,14 @@ static void
 demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags)
 {
   free_cached_dps (demuxer);
-  if (!(flags & 2))  /* time in secs */
+  if (!(flags & SEEK_FACTOR))  /* time in secs */
     {
       mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
       stream_t *s = demuxer->stream;
       int64_t target_timecode = 0, diff, min_diff=0xFFFFFFFFFFFFFFFLL;
       int i;
 
-      if (!(flags & 1))  /* relative seek */
+      if (!(flags & SEEK_ABSOLUTE))  /* relative seek */
         target_timecode = (int64_t) (mkv_d->last_pts * 1000.0);
       target_timecode += (int64_t)(rel_seek_secs * 1000.0);
       if (target_timecode < 0)
@@ -3371,7 +3372,7 @@ demux_mkv_seek (demuxer_t *demuxer, floa
                 diff = target_timecode + mkv_d->first_tc -
                        (int64_t) mkv_d->indexes[i].timecode * mkv_d->tc_scale / 1000000.0;
 
-                if ((flags & 1 || target_timecode <= mkv_d->last_pts*1000)) {
+                if ((flags & SEEK_ABSOLUTE || target_timecode <= mkv_d->last_pts*1000)) {
                     // Absolute seek or seek backward: find the last index
                     // position before target time
                     if (diff < 0 || diff >= min_diff)
@@ -3408,7 +3409,7 @@ demux_mkv_seek (demuxer_t *demuxer, floa
 
       demux_mkv_fill_buffer(demuxer, NULL);
     }
-  else if ((demuxer->movi_end <= 0) || !(flags & 1))
+  else if ((demuxer->movi_end <= 0) || !(flags & SEEK_ABSOLUTE))
     mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] seek unsupported flags\n");
   else
     {

Modified: trunk/libmpdemux/demux_mov.c
==============================================================================
--- trunk/libmpdemux/demux_mov.c	(original)
+++ trunk/libmpdemux/demux_mov.c	Tue Jan 29 16:11:38 2008
@@ -2202,19 +2202,19 @@ if(trak->pos==0 && trak->stream_header_l
 static float mov_seek_track(mov_track_t* trak,float pts,int flags){
 
 //    printf("MOV track seek called  %5.3f  \n",pts);
-    if(flags&2) pts*=trak->length; else pts*=(float)trak->timescale;
+    if(flags&SEEK_FACTOR) pts*=trak->length; else pts*=(float)trak->timescale;
 
 if(trak->samplesize){
     int sample=pts/trak->duration;
 //    printf("MOV track seek - chunk: %d  (pts: %5.3f  dur=%d)  \n",sample,pts,trak->duration);
-    if(!(flags&1)) sample+=trak->chunks[trak->pos].sample; // relative
+    if(!(flags&SEEK_ABSOLUTE)) sample+=trak->chunks[trak->pos].sample; // relative
     trak->pos=0;
     while(trak->pos<trak->chunks_size && trak->chunks[trak->pos].sample<sample) ++trak->pos;
     if (trak->pos == trak->chunks_size) return -1;
     pts=(float)(trak->chunks[trak->pos].sample*trak->duration)/(float)trak->timescale;
 } else {
     unsigned int ipts;
-    if(!(flags&1)) pts+=trak->samples[trak->pos].pts;
+    if(!(flags&SEEK_ABSOLUTE)) pts+=trak->samples[trak->pos].pts;
     if(pts<0) pts=0;
     ipts=pts;
     //printf("MOV track seek - sample: %d  \n",ipts);

Modified: trunk/libmpdemux/demux_mpc.c
==============================================================================
--- trunk/libmpdemux/demux_mpc.c	(original)
+++ trunk/libmpdemux/demux_mpc.c	Tue Jan 29 16:11:38 2008
@@ -156,9 +156,9 @@ static void demux_mpc_seek(demuxer_t *de
   da_priv_t* priv = demuxer->priv;
   stream_t* s = demuxer->stream;
   float target = rel_seek_secs;
-  if (flags & 2)
+  if (flags & SEEK_FACTOR)
     target *= priv->length;
-  if (!(flags & 1))
+  if (!(flags & SEEK_ABSOLUTE))
     target += priv->last_pts;
   if (target < priv->last_pts) {
     stream_seek(s, demuxer->movi_start);

Modified: trunk/libmpdemux/demux_mpg.c
==============================================================================
--- trunk/libmpdemux/demux_mpg.c	(original)
+++ trunk/libmpdemux/demux_mpg.c	Tue Jan 29 16:11:38 2008
@@ -893,14 +893,14 @@ void demux_seek_mpg(demuxer_t *demuxer,f
     float oldpts = 0;
     off_t oldpos = demuxer->filepos;
     float newpts = 0; 
-    off_t newpos = (flags & 1) ? demuxer->movi_start : oldpos;
+    off_t newpos = (flags & SEEK_ABSOLUTE) ? demuxer->movi_start : oldpos;
 
     if(mpg_d)
       oldpts = mpg_d->last_pts;
-    newpts = (flags & 1) ? 0.0 : oldpts;
+    newpts = (flags & SEEK_ABSOLUTE) ? 0.0 : oldpts;
   //================= seek in MPEG ==========================
   //calculate the pts to seek to
-    if(flags & 2) {
+    if(flags & SEEK_FACTOR) {
       if (mpg_d && mpg_d->first_to_final_pts_len > 0.0)
         newpts += mpg_d->first_to_final_pts_len * rel_seek_secs;
       else
@@ -909,7 +909,7 @@ void demux_seek_mpg(demuxer_t *demuxer,f
       newpts += rel_seek_secs;
     if (newpts < 0) newpts = 0;
 	
-    if(flags&2){
+    if(flags&SEEK_FACTOR){
 	// float seek 0..1
 	newpos+=(demuxer->movi_end-demuxer->movi_start)*rel_seek_secs;
     } else {

Modified: trunk/libmpdemux/demux_nut.c
==============================================================================
--- trunk/libmpdemux/demux_nut.c	(original)
+++ trunk/libmpdemux/demux_nut.c	Tue Jan 29 16:11:38 2008
@@ -247,12 +247,12 @@ static void demux_seek_nut(demuxer_t * d
 	int ret;
 	const int tmp[] = { 0, -1 };
 
-	if (!(flags & 1)) {
+	if (!(flags & SEEK_ABSOLUTE)) {
 		nutflags |= 1; // relative
 		if (time_pos > 0) nutflags |= 2; // forwards
 	}
 
-	if (flags & 2) // percent
+	if (flags & SEEK_FACTOR)
 		time_pos *= priv->s[0].max_pts *
 		               (double)priv->s[0].time_base.num /
 		                       priv->s[0].time_base.den;

Modified: trunk/libmpdemux/demux_ogg.c
==============================================================================
--- trunk/libmpdemux/demux_ogg.c	(original)
+++ trunk/libmpdemux/demux_ogg.c	Tue Jan 29 16:11:38 2008
@@ -1366,8 +1366,8 @@ static void demux_ogg_seek(demuxer_t *de
   old_pos = ogg_d->pos;
 
   //calculate the granulepos to seek to
-    gp = flags & 1 ? 0 : os->lastpos;
-  if(flags & 2) {
+    gp = flags & SEEK_ABSOLUTE ? 0 : os->lastpos;
+  if(flags & SEEK_FACTOR) {
     if (ogg_d->final_granulepos > 0)
       gp += ogg_d->final_granulepos * rel_seek_secs;
       else
@@ -1392,8 +1392,8 @@ static void demux_ogg_seek(demuxer_t *de
     pos = ogg_d->syncpoints[sp].page_pos;
     precision = 0;
   } else {
-    pos = flags & 1 ? 0 : ogg_d->pos;
-    if(flags & 2)
+    pos = flags & SEEK_ABSOLUTE ? 0 : ogg_d->pos;
+    if(flags & SEEK_FACTOR)
       pos += (demuxer->movi_end - demuxer->movi_start) * rel_seek_secs;
     else {
       if (ogg_d->final_granulepos > 0) {

Modified: trunk/libmpdemux/demux_rawaudio.c
==============================================================================
--- trunk/libmpdemux/demux_rawaudio.c	(original)
+++ trunk/libmpdemux/demux_rawaudio.c	Tue Jan 29 16:11:38 2008
@@ -84,8 +84,8 @@ static void demux_rawaudio_seek(demuxer_
   sh_audio_t* sh_audio = demuxer->audio->sh;
   off_t base,pos;
 
-  base = (flags & 1) ? demuxer->movi_start : stream_tell(s);
-  if(flags & 2)
+  base = (flags & SEEK_ABSOLUTE) ? demuxer->movi_start : stream_tell(s);
+  if(flags & SEEK_FACTOR)
     pos = base + ((demuxer->movi_end - demuxer->movi_start)*rel_seek_secs);
   else
     pos = base + (rel_seek_secs*sh_audio->i_bps);

Modified: trunk/libmpdemux/demux_rawdv.c
==============================================================================
--- trunk/libmpdemux/demux_rawdv.c	(original)
+++ trunk/libmpdemux/demux_rawdv.c	Tue Jan 29 16:11:38 2008
@@ -38,8 +38,8 @@ static void demux_seek_rawdv(demuxer_t *
 {
    rawdv_frames_t *frames = (rawdv_frames_t *)demuxer->priv;
    sh_video_t *sh_video = demuxer->video->sh;
-   off_t newpos=(flags&1)?0:frames->current_frame;
-   if(flags&2)
+   off_t newpos=(flags&SEEK_ABSOLUTE)?0:frames->current_frame;
+   if(flags&SEEK_FACTOR)
    {
       // float 0..1
       newpos+=rel_seek_secs*frames->frame_number;

Modified: trunk/libmpdemux/demux_rawvideo.c
==============================================================================
--- trunk/libmpdemux/demux_rawvideo.c	(original)
+++ trunk/libmpdemux/demux_rawvideo.c	Tue Jan 29 16:11:38 2008
@@ -124,8 +124,8 @@ static void demux_rawvideo_seek(demuxer_
   sh_video_t* sh_video = demuxer->video->sh;
   off_t pos;
 
-  pos = (flags & 1) ? demuxer->movi_start : stream_tell(s);
-  if(flags & 2)
+  pos = (flags & SEEK_ABSOLUTE) ? demuxer->movi_start : stream_tell(s);
+  if(flags & SEEK_FACTOR)
     pos += ((demuxer->movi_end - demuxer->movi_start)*rel_seek_secs);
   else
     pos += (rel_seek_secs*sh_video->i_bps);

Modified: trunk/libmpdemux/demux_real.c
==============================================================================
--- trunk/libmpdemux/demux_real.c	(original)
+++ trunk/libmpdemux/demux_real.c	Tue Jan 29 16:11:38 2008
@@ -1813,10 +1813,9 @@ static void demux_seek_real(demuxer_t *d
     if (!streams)
 	return;
 
-    if (flags & 1)
-	/* seek absolute */
+    if (flags & SEEK_ABSOLUTE)
 	priv->current_apacket = priv->current_vpacket = 0;
-    if (flags & 2) // percent seek
+    if (flags & SEEK_FACTOR)
         rel_seek_secs *= priv->duration;
 
     if ((streams & 1) && priv->current_vpacket >= priv->index_table_size[vid])

Modified: trunk/libmpdemux/demux_ts.c
==============================================================================
--- trunk/libmpdemux/demux_ts.c	(original)
+++ trunk/libmpdemux/demux_ts.c	Tue Jan 29 16:11:38 2008
@@ -3107,8 +3107,8 @@ static void demux_seek_ts(demuxer_t *dem
 			video_stats = sh_video->i_bps;
 	}
 
-	newpos = (flags & 1) ? demuxer->movi_start : demuxer->filepos;
-	if(flags & 2) // float seek 0..1
+	newpos = (flags & SEEK_ABSOLUTE) ? demuxer->movi_start : demuxer->filepos;
+	if(flags & SEEK_FACTOR) // float seek 0..1
 		newpos+=(demuxer->movi_end-demuxer->movi_start)*rel_seek_secs;
 	else
 	{

Modified: trunk/libmpdemux/demux_ty.c
==============================================================================
--- trunk/libmpdemux/demux_ty.c	(original)
+++ trunk/libmpdemux/demux_ty.c	Tue Jan 29 16:11:38 2008
@@ -760,9 +760,9 @@ static void demux_seek_ty( demuxer_t *de
    //================= seek in MPEG ==========================
    demuxer->filepos = stream_tell( demuxer->stream );
 
-   newpos = ( flags & 1 ) ? demuxer->movi_start : demuxer->filepos;
+   newpos = ( flags & SEEK_ABSOLUTE ) ? demuxer->movi_start : demuxer->filepos;
 
-   if( flags & 2 )
+   if( flags & SEEK_FACTOR )
       // float seek 0..1
       newpos += ( demuxer->movi_end - demuxer->movi_start ) * rel_seek_secs;
    else

Modified: trunk/libmpdemux/demux_vqf.c
==============================================================================
--- trunk/libmpdemux/demux_vqf.c	(original)
+++ trunk/libmpdemux/demux_vqf.c	Tue Jan 29 16:11:38 2008
@@ -186,8 +186,8 @@ static void demux_seek_vqf(demuxer_t *de
   sh_audio_t* sh_audio = demuxer->audio->sh;
   off_t base,pos;
 
-  base = (flags & 1) ? demuxer->movi_start : stream_tell(s);
-  if(flags & 2)
+  base = (flags & SEEK_ABSOLUTE) ? demuxer->movi_start : stream_tell(s);
+  if(flags & SEEK_FACTOR)
     pos = base + ((demuxer->movi_end - demuxer->movi_start)*rel_seek_secs);
   else
     pos = base + (rel_seek_secs*sh_audio->i_bps);

Modified: trunk/libmpdemux/demux_xmms.c
==============================================================================
--- trunk/libmpdemux/demux_xmms.c	(original)
+++ trunk/libmpdemux/demux_xmms.c	Tue Jan 29 16:11:38 2008
@@ -350,8 +350,8 @@ static void demux_xmms_seek(demuxer_t *d
 
     if(priv->ip->get_time()<0) return;
 
-    pos = (flags & 1) ? 0 : priv->spos / sh_audio->wf->nAvgBytesPerSec;
-    if (flags & 2)
+    pos = (flags & SEEK_ABSOLUTE) ? 0 : priv->spos / sh_audio->wf->nAvgBytesPerSec;
+    if (flags & SEEK_FACTOR)
         pos+= rel_seek_secs*xmms_length;
     else
         pos+= rel_seek_secs;

Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c	(original)
+++ trunk/libmpdemux/demuxer.c	Tue Jan 29 16:11:38 2008
@@ -980,7 +980,7 @@ if(!demuxer->seekable){
     if(sh_video) sh_video->timer=0; // !!!!!!
 #endif
 
-    if(flags & 1)  // absolute seek
+    if(flags & SEEK_ABSOLUTE)
       pts = 0.0f;
     else {
       if(demuxer->stream_pts == MP_NOPTS_VALUE)
@@ -988,7 +988,7 @@ if(!demuxer->seekable){
       pts = demuxer->stream_pts;
     }
 
-    if(flags & 2) {  // percent seek
+    if(flags & SEEK_FACTOR) {
       if(stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, &tmp) == STREAM_UNSUPPORTED)
         goto dmx_seek;
       pts += tmp * rel_seek_secs;

Modified: trunk/libmpdemux/demuxer.h
==============================================================================
--- trunk/libmpdemux/demuxer.h	(original)
+++ trunk/libmpdemux/demuxer.h	Tue Jan 29 16:11:38 2008
@@ -83,6 +83,9 @@
 #define DEMUXER_CTRL_SWITCH_VIDEO 14
 #define DEMUXER_CTRL_IDENTIFY_PROGRAM 15
 
+#define SEEK_ABSOLUTE (1 << 0)
+#define SEEK_FACTOR   (1 << 1)
+
 // Holds one packet/frame/whatever
 typedef struct demux_packet_st {
   int len;

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	(original)
+++ trunk/mplayer.c	Tue Jan 29 16:11:38 2008
@@ -2483,8 +2483,8 @@ static void edl_update(MPContext *mpctx)
 }
 
 
-// style & 1 == 0 means seek relative to current position, == 1 means absolute
-// style & 2 == 0 means amount in seconds, == 2 means fraction of file length
+// style & SEEK_ABSOLUTE == 0 means seek relative to current position, == 1 means absolute
+// style & SEEK_FACTOR == 0 means amount in seconds, == 2 means fraction of file length
 // return -1 if seek failed (non-seekable stream?), 0 otherwise
 static int seek(MPContext *mpctx, double amount, int style)
 {
@@ -3626,7 +3626,7 @@ if(play_n_frames==0){
 }
 
 if (seek_to_sec) {
-    seek(mpctx, seek_to_sec, 1);
+    seek(mpctx, seek_to_sec, SEEK_ABSOLUTE);
     end_at.pos += seek_to_sec;
 }
 
@@ -3831,7 +3831,7 @@ if(step_sec>0) {
     if(mpctx->loop_times==1) mpctx->loop_times=-1;
     play_n_frames=play_n_frames_mf;
     mpctx->eof=0;
-    abs_seek_pos=1; rel_seek_secs=seek_to_sec;
+    abs_seek_pos=SEEK_ABSOLUTE; rel_seek_secs=seek_to_sec;
     loop_seek = 1;
   }
 



More information about the MPlayer-cvslog mailing list