[MPlayer-cvslog] CVS: main/libmpdemux demux_mkv.c,1.51,1.52

Loren Merritt CVS syncmail at mplayerhq.hu
Sat Nov 5 05:56:25 CET 2005


CVS change done by Loren Merritt CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv2517

Modified Files:
	demux_mkv.c 
Log Message:
sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)



Index: demux_mkv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- demux_mkv.c	30 Oct 2005 09:19:05 -0000	1.51
+++ demux_mkv.c	5 Nov 2005 04:56:23 -0000	1.52
@@ -2779,21 +2779,29 @@
  * or P frame arrives these timecodes can be changed to I at 0ms, P at 40ms,
  * B at 80ms and B at 120ms.
  *
+ * This works for simple H.264 B-frame pyramids, but not for arbitrary orders.
+ *
  * \param demuxer The Matroska demuxer struct for this instance.
  * \param track The track structure whose cache should be handled.
  */
 static void
 flush_cached_dps (demuxer_t *demuxer, mkv_track_t *track)
 {
-  float tmp_pts;
-  int i;
+  int i, ok;
 
   if (track->num_cached_dps == 0)
     return;
-  tmp_pts = track->cached_dps[0]->pts;
-  for (i = 1; i < track->num_cached_dps; i++)
-    track->cached_dps[i - 1]->pts = track->cached_dps[i]->pts;
-  track->cached_dps[track->num_cached_dps - 1]->pts = tmp_pts;
+
+  do {
+    ok = 1;
+    for (i = 1; i < track->num_cached_dps; i++)
+      if (track->cached_dps[i - 1]->pts > track->cached_dps[i]->pts) {
+        float tmp_pts = track->cached_dps[i - 1]->pts;
+        track->cached_dps[i - 1]->pts = track->cached_dps[i]->pts;
+        track->cached_dps[i]->pts = tmp_pts;
+        ok = 0;
+      }
+  } while (!ok);
 
   for (i = 0; i < track->num_cached_dps; i++)
     ds_add_packet (demuxer->video, track->cached_dps[i]);




More information about the MPlayer-cvslog mailing list