[0.11] gst-plugins-good: matroskamux: make default duration check less sensitive
Wim Taymans
wtay at kemper.freedesktop.org
Tue Sep 6 07:38:04 PDT 2011
Module: gst-plugins-good
Branch: 0.11
Commit: aa0ae490d052eee96a56c845b599066aa00855e5
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=aa0ae490d052eee96a56c845b599066aa00855e5
Author: Mark Nauwelaerts <mark.nauwelaerts at collabora.co.uk>
Date: Tue Sep 6 15:05:37 2011 +0200
matroskamux: make default duration check less sensitive
Frame duration might vary for 1 usecond, in this case matroskamux
decides to create BLOCKGROUP instead of SIMPLEBLOCK.
Convert duration to timecodescale which is (typically) less precise, and
then also allow the difference of 1/-1 to arrange for less sensitive check.
Based on patch by Alexey Fisher <bug-track at fisher-privat.net>
Fixes #653080.
---
gst/matroska/matroska-mux.c | 19 +++++++++++++------
gst/matroska/matroska-mux.h | 1 +
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c
index 2a639d4..ed98df1 100644
--- a/gst/matroska/matroska-mux.c
+++ b/gst/matroska/matroska-mux.c
@@ -2204,6 +2204,10 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
child = gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_TRACKENTRY);
gst_matroska_mux_track_header (mux, collect_pad->track);
gst_ebml_write_master_finish (ebml, child);
+ /* some remaing pad/track setup */
+ collect_pad->default_duration_scaled =
+ gst_util_uint64_scale (collect_pad->track->default_duration,
+ 1, mux->time_scale);
}
}
gst_ebml_write_master_finish (ebml, master);
@@ -2767,9 +2771,14 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
/* Check if the duration differs from the default duration. */
write_duration = FALSE;
- block_duration = GST_BUFFER_DURATION (buf);
+ block_duration = 0;
if (GST_BUFFER_DURATION_IS_VALID (buf)) {
- if (block_duration != collect_pad->track->default_duration) {
+ block_duration = gst_util_uint64_scale (GST_BUFFER_DURATION (buf),
+ 1, mux->time_scale);
+
+ /* small difference should be ok. */
+ if (block_duration > collect_pad->default_duration_scaled + 1 ||
+ block_duration < collect_pad->default_duration_scaled - 1) {
write_duration = TRUE;
}
}
@@ -2810,10 +2819,8 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad)
hdr =
gst_matroska_mux_create_buffer_header (collect_pad->track,
relative_timestamp, 0);
- if (write_duration) {
- gst_ebml_write_uint (ebml, GST_MATROSKA_ID_BLOCKDURATION,
- gst_util_uint64_scale (block_duration, 1, mux->time_scale));
- }
+ if (write_duration)
+ gst_ebml_write_uint (ebml, GST_MATROSKA_ID_BLOCKDURATION, block_duration);
gst_ebml_write_buffer_header (ebml, GST_MATROSKA_ID_BLOCK,
GST_BUFFER_SIZE (buf) + GST_BUFFER_SIZE (hdr));
gst_ebml_write_buffer (ebml, hdr);
diff --git a/gst/matroska/matroska-mux.h b/gst/matroska/matroska-mux.h
index 1270072..e5074a7 100644
--- a/gst/matroska/matroska-mux.h
+++ b/gst/matroska/matroska-mux.h
@@ -64,6 +64,7 @@ typedef struct
guint64 duration;
GstClockTime start_ts;
GstClockTime end_ts; /* last timestamp + (if available) duration */
+ guint64 default_duration_scaled;
}
GstMatroskaPad;
More information about the gstreamer-commits
mailing list