From cf3e901996ab885d2556029564f956c9bca75a2e Mon Sep 17 00:00:00 2001 From: Gautier Portet Date: Fri, 9 Nov 2012 11:33:40 +0100 Subject: [PATCH] xingmux: Properly calculate the number of frames First, the xing header frame is never added to the count, we have to increment the count. Secondly, there is a rounding error when calculating the frame duration, as spf*GST_SECOND/rate is not an integer (26122448.9) an it must be 26122449. --- gst/xingmux/gstxingmux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gst/xingmux/gstxingmux.c b/gst/xingmux/gstxingmux.c index 5ace7b017c..dacd1ec3be 100644 --- a/gst/xingmux/gstxingmux.c +++ b/gst/xingmux/gstxingmux.c @@ -318,6 +318,7 @@ generate_xing_header (GstXingMux * xing) * SamplesPerFrame and SamplingRate are values for the current frame. */ number_of_frames = gst_util_uint64_scale (duration, rate, GST_SECOND) / spf; + number_of_frames += 1; /* Xing Header Frame */ GST_DEBUG ("Setting number of frames to %u", number_of_frames); number_of_frames = GUINT32_TO_BE (number_of_frames); memcpy (data, &number_of_frames, 4); @@ -555,7 +556,7 @@ gst_xing_mux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) seek_entry->byte = (seek_entry->timestamp == 0) ? 0 : xing->byte_count; xing->seek_table = g_list_append (xing->seek_table, seek_entry); - duration = gst_util_uint64_scale (spf, GST_SECOND, rate); + duration = gst_util_uint64_scale_ceil (spf, GST_SECOND, rate); GST_BUFFER_TIMESTAMP (outbuf) = (xing->duration == GST_CLOCK_TIME_NONE) ? 0 : xing->duration;