changeset 25919:382672c7480a

Allow demuxers to choose a default value for correct_pts
author reimar
date Sun, 03 Feb 2008 12:14:29 +0000
parents 35698e5aa40c
children 822e7d3d8b94
files cfg-mplayer.h libmpdemux/demux_lavf.c libmpdemux/demux_mkv.c libmpdemux/demux_real.c libmpdemux/demuxer.c libmpdemux/demuxer.h
diffstat 6 files changed, 22 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-mplayer.h	Sat Feb 02 17:22:07 2008 +0000
+++ b/cfg-mplayer.h	Sun Feb 03 12:14:29 2008 +0000
@@ -319,8 +319,8 @@
 	{"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},
--- a/libmpdemux/demux_lavf.c	Sat Feb 02 17:22:07 2008 +0000
+++ b/libmpdemux/demux_lavf.c	Sun Feb 03 12:14:29 2008 +0000
@@ -463,7 +463,7 @@
 
     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 @@
     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;
--- a/libmpdemux/demux_mkv.c	Sat Feb 02 17:22:07 2008 +0000
+++ b/libmpdemux/demux_mkv.c	Sun Feb 03 12:14:29 2008 +0000
@@ -1827,7 +1827,7 @@
               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 @@
   
   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;
--- a/libmpdemux/demux_real.c	Sat Feb 02 17:22:07 2008 +0000
+++ b/libmpdemux/demux_real.c	Sun Feb 03 12:14:29 2008 +0000
@@ -743,7 +743,7 @@
                     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;
--- a/libmpdemux/demuxer.c	Sat Feb 02 17:22:07 2008 +0000
+++ b/libmpdemux/demuxer.c	Sun Feb 03 12:14:29 2008 +0000
@@ -684,6 +684,7 @@
 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 @@
 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 @@
   }
 
   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;
 }
 
 
--- a/libmpdemux/demuxer.h	Sat Feb 02 17:22:07 2008 +0000
+++ b/libmpdemux/demuxer.h	Sun Feb 03 12:14:29 2008 +0000
@@ -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 @@
 struct demuxer_st;
 
 extern int correct_pts;
+extern int user_correct_pts;
 
 /**
  * Demuxer description structure