Compensate for timestamp/duration rounding errors

This commit is contained in:
Sebastian Dröge 2009-01-29 19:42:09 +01:00
parent a930b36adc
commit dfa0e43848
2 changed files with 13 additions and 0 deletions

View file

@ -1534,6 +1534,18 @@ gst_mxf_demux_handle_generic_container_essence_element (GstMXFDemux * demux,
GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET_NONE;
GST_BUFFER_OFFSET_END (outbuf) = GST_BUFFER_OFFSET_NONE;
/* Update accumulated error and compensate */
{
guint64 abs_error = (GST_SECOND * pad->material_track->edit_rate.d) %
pad->material_track->edit_rate.n;
pad->last_stop_accumulated_error +=
((gdouble) abs_error) / ((gdouble) pad->material_track->edit_rate.n);
}
if (pad->last_stop_accumulated_error >= 1.0) {
GST_BUFFER_DURATION (outbuf) += 1;
pad->last_stop_accumulated_error -= 1.0;
}
if (pad->need_segment) {
gst_pad_push_event (GST_PAD_CAST (pad),
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1,

View file

@ -93,6 +93,7 @@ struct _GstMXFDemuxPad
gboolean need_segment;
GstClockTime last_stop;
gdouble last_stop_accumulated_error;
GstFlowReturn last_flow;
gboolean eos, discont;