From: Wim T. <wt...@us...> - 2002-09-18 22:04:46
|
CVS Root: /cvsroot/gstreamer Module: gst-plugins Changes by: wtay Date: Wed Sep 18 2002 15:04:45 PDT Log message: Fix the timestamps. A new incomming timestamp should not be used on a pertial buffer. Modified files: ext/mad : gstmad.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/mad/gstmad.c.diff?r1=1.41&r2=1.42 ====Begin Diffs==== Index: gstmad.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/mad/gstmad.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- gstmad.c 18 Sep 2002 19:02:21 -0000 1.41 +++ gstmad.c 18 Sep 2002 22:04:32 -0000 1.42 @@ -925,6 +925,7 @@ GstMad *mad; gchar *data; glong size; + gboolean new_pts = FALSE; mad = GST_MAD (gst_pad_get_parent (pad)); @@ -957,6 +958,8 @@ time = 0; } + /* for now, this is the best we can do. Let's hope a real timestamp + * arrives with the next buffer */ mad->base_time = time; gst_event_unref (event); @@ -979,8 +982,17 @@ } if (GST_BUFFER_TIMESTAMP (buffer) != -1) { - mad->base_time = GST_BUFFER_TIMESTAMP (buffer); - mad->total_samples = 0; + /* if there is nothing queued (partial buffer), we prepare to set the + * timestamp on the next buffer */ + if (mad->tempsize == 0) { + mad->base_time = GST_BUFFER_TIMESTAMP (buffer); + mad->total_samples = 0; + } + /* else we need to finish the current partial frame with the old timestamp + * and queue this timestamp for the next frame */ + else { + new_pts = TRUE; + } } /* end of new bit */ @@ -1124,6 +1136,14 @@ mad->total_samples += nsamples; } + /* we have a queued timestamp on the incomming buffer that we should + * use for the next frame */ + if (new_pts) { + new_pts = FALSE; + mad->base_time = GST_BUFFER_TIMESTAMP (buffer); + mad->total_samples = 0; + } + if (mad->restart) { mad->restart = FALSE; mad->tempsize = 0; @@ -1131,7 +1151,6 @@ } next: - /* figure out how many bytes mad consumed */ consumed = mad->stream.next_frame - mad_input_buffer; |