[MPlayer-cvslog] r25951 - in trunk: cfg-mplayer.h libmpdemux/demux_lavf.c libmpdemux/demux_mkv.c libmpdemux/demux_real.c libmpdemux/demuxer.c libmpdemux/demuxer.h

reimar subversion at mplayerhq.hu
Sun Feb 3 13:14:29 CET 2008


Author: reimar
Date: Sun Feb  3 13:14:29 2008
New Revision: 25951

Log:
Allow demuxers to choose a default value for correct_pts


Modified:
   trunk/cfg-mplayer.h
   trunk/libmpdemux/demux_lavf.c
   trunk/libmpdemux/demux_mkv.c
   trunk/libmpdemux/demux_real.c
   trunk/libmpdemux/demuxer.c
   trunk/libmpdemux/demuxer.h

Modified: trunk/cfg-mplayer.h
==============================================================================
--- trunk/cfg-mplayer.h	(original)
+++ trunk/cfg-mplayer.h	Sun Feb  3 13:14:29 2008
@@ -319,8 +319,8 @@ const m_option_t mplayer_opts[]={
 	{"playlist", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL},
 
 	// a-v sync stuff:
-        {"correct-pts", &correct_pts, CONF_TYPE_FLAG, 0, 0, 1, NULL},
-        {"no-correct-pts", &correct_pts, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+        {"correct-pts", &user_correct_pts, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+        {"no-correct-pts", &user_correct_pts, CONF_TYPE_FLAG, 0, 1, 0, NULL},
 	{"noautosync", &autosync, CONF_TYPE_FLAG, 0, 0, -1, NULL},
 	{"autosync", &autosync, CONF_TYPE_INT, CONF_RANGE, 0, 10000, NULL},
 //	{"dapsync", &dapsync, CONF_TYPE_FLAG, 0, 0, 1, NULL},

Modified: trunk/libmpdemux/demux_lavf.c
==============================================================================
--- trunk/libmpdemux/demux_lavf.c	(original)
+++ trunk/libmpdemux/demux_lavf.c	Sun Feb  3 13:14:29 2008
@@ -463,7 +463,7 @@ static demuxer_t* demux_open_lavf(demuxe
 
     if (opt_cryptokey)
         parse_cryptokey(avfc, opt_cryptokey);
-    if (correct_pts)
+    if (user_correct_pts != 0)
         avfc->flags |= AVFMT_FLAG_GENPTS;
     if (index_mode == 0)
         avfc->flags |= AVFMT_FLAG_IGNIDX;
@@ -644,6 +644,8 @@ static int demux_lavf_control(demuxer_t 
     lavf_priv_t *priv = demuxer->priv;
 
     switch (cmd) {
+        case DEMUXER_CTRL_CORRECT_PTS:
+	    return DEMUXER_CTRL_OK;
         case DEMUXER_CTRL_GET_TIME_LENGTH:
 	    if (priv->avfc->duration == 0 || priv->avfc->duration == AV_NOPTS_VALUE)
 	        return DEMUXER_CTRL_DONTKNOW;

Modified: trunk/libmpdemux/demux_mkv.c
==============================================================================
--- trunk/libmpdemux/demux_mkv.c	(original)
+++ trunk/libmpdemux/demux_mkv.c	Sun Feb  3 13:14:29 2008
@@ -1827,7 +1827,7 @@ demux_mkv_open_video (demuxer_t *demuxer
               bih = realloc (bih, bih->biSize);
               memcpy (bih + 1, track->private_data, track->private_size);
             }
-          track->reorder_timecodes = !correct_pts;
+          track->reorder_timecodes = user_correct_pts == 0;
           if (!vi->id) {
               mp_msg (MSGT_DEMUX,MSGL_WARN, MSGTR_MPDEMUX_MKV_UnknownCodecID,
                       track->codec_id, track->tnum);
@@ -3456,6 +3456,8 @@ demux_mkv_control (demuxer_t *demuxer, i
   
   switch (cmd)
     {
+    case DEMUXER_CTRL_CORRECT_PTS:
+      return DEMUXER_CTRL_OK;
     case DEMUXER_CTRL_GET_TIME_LENGTH:
       if (mkv_d->duration == 0)
         return DEMUXER_CTRL_DONTKNOW;

Modified: trunk/libmpdemux/demux_real.c
==============================================================================
--- trunk/libmpdemux/demux_real.c	(original)
+++ trunk/libmpdemux/demux_real.c	Sun Feb  3 13:14:29 2008
@@ -743,7 +743,7 @@ got_audio:
                     break;
             }
             priv->audio_need_keyframe = 0;
-            priv->audio_timestamp[priv->sub_packet_cnt] = (priv->a_pts==timestamp) ? (correct_pts ? MP_NOPTS_VALUE : 0) : (timestamp/1000.0);
+            priv->audio_timestamp[priv->sub_packet_cnt] = (priv->a_pts==timestamp) ? (user_correct_pts > 0 ? MP_NOPTS_VALUE : 0) : (timestamp/1000.0);
             priv->a_pts = timestamp;
             if (priv->sub_packet_cnt == 0)
                 priv->audio_filepos = demuxer->filepos;

Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c	(original)
+++ trunk/libmpdemux/demuxer.c	Sun Feb  3 13:14:29 2008
@@ -684,6 +684,7 @@ int get_demuxer_type_from_name(char *dem
 int extension_parsing=1; // 0=off 1=mixed (used only for unstable formats)
 
 int correct_pts=0;
+int user_correct_pts=-1;
 
 /*
   NOTE : Several demuxers may be opened at the same time so
@@ -869,6 +870,7 @@ extern float stream_cache_seek_min_perce
 demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int dvdsub_id,char* filename){
   stream_t *as = NULL,*ss = NULL;
   demuxer_t *vd,*ad = NULL,*sd = NULL;
+  demuxer_t *res;
   int afmt =DEMUXER_TYPE_UNKNOWN,sfmt = DEMUXER_TYPE_UNKNOWN ;
   int audio_demuxer_type = 0, sub_demuxer_type = 0;
   int demuxer_force = 0, audio_demuxer_force = 0,
@@ -935,13 +937,18 @@ demuxer_t* demux_open(stream_t *vs,int f
   }
 
   if(ad && sd)
-    return new_demuxers_demuxer(vd,ad,sd);
+    res = new_demuxers_demuxer(vd,ad,sd);
   else if(ad)
-    return new_demuxers_demuxer(vd,ad,vd);
+    res = new_demuxers_demuxer(vd,ad,vd);
   else if(sd)
-    return new_demuxers_demuxer(vd,vd,sd);
+    res = new_demuxers_demuxer(vd,vd,sd);
   else
-    return vd;
+    res = vd;
+
+  correct_pts = user_correct_pts;
+  if (correct_pts < 0)
+    correct_pts = demux_control(res, DEMUXER_CTRL_CORRECT_PTS, NULL) == DEMUXER_CTRL_OK;
+  return res;
 }
 
 

Modified: trunk/libmpdemux/demuxer.h
==============================================================================
--- trunk/libmpdemux/demuxer.h	(original)
+++ trunk/libmpdemux/demuxer.h	Sun Feb  3 13:14:29 2008
@@ -82,6 +82,7 @@
 #define DEMUXER_CTRL_RESYNC 13
 #define DEMUXER_CTRL_SWITCH_VIDEO 14
 #define DEMUXER_CTRL_IDENTIFY_PROGRAM 15
+#define DEMUXER_CTRL_CORRECT_PTS 16
 
 #define SEEK_ABSOLUTE (1 << 0)
 #define SEEK_FACTOR   (1 << 1)
@@ -143,6 +144,7 @@ typedef struct demuxer_info_st {
 struct demuxer_st;
 
 extern int correct_pts;
+extern int user_correct_pts;
 
 /**
  * Demuxer description structure



More information about the MPlayer-cvslog mailing list