gst/matroska/matroska-demux.c: When seeking, seek to closest index entry at or before the requested seek position, no...

Original commit message from CVS:
Reviewed by: Tim-Philipp Müller  <tim at centricular dot net>
* gst/matroska/matroska-demux.c: (gst_matroskademux_do_index_seek):
When seeking, seek to closest index entry at or before the requested
seek position, not just the closest one (#321001).
This commit is contained in:
Tim-Philipp Müller 2005-11-15 19:41:21 +00:00
parent 12aed9b96e
commit 7f63b50f3f
2 changed files with 19 additions and 16 deletions

View file

@ -1,3 +1,11 @@
2005-11-15 Vincent Torri <torri at iecn dot u-nancy dot fr>
Reviewed by: Tim-Philipp Müller <tim at centricular dot net>
* gst/matroska/matroska-demux.c: (gst_matroskademux_do_index_seek):
When seeking, seek to closest index entry at or before the requested
seek position, not just the closest one (#321001).
2005-11-15 Tim-Philipp Müller <tim at centricular dot net>
* gst/avi/gstavidemux.c: (swap_line), (gst_avi_demux_invert),

View file

@ -992,27 +992,22 @@ gst_matroska_demux_handle_src_query (GstPad * pad, GstQuery * query)
static GstMatroskaIndex *
gst_matroskademux_do_index_seek (GstMatroskaDemux * demux, guint64 seek_pos)
{
guint entry = (guint) - 1;
guint n;
for (n = 0; n < demux->num_indexes; n++) {
if (entry == (guint) - 1) {
entry = n;
} else {
gfloat diff_old = fabs (1. * (demux->index[entry].time - seek_pos)),
diff_new = fabs (1. * (demux->index[n].time - seek_pos));
if (diff_new < diff_old) {
entry = n;
}
}
}
if (entry != (guint) - 1) {
return &demux->index[entry];
}
guint entry = demux->num_indexes - 1;
guint n = 0;
if (!demux->num_indexes)
return NULL;
while (n < demux->num_indexes - 1) {
if ((demux->index[n].time <= seek_pos) &&
(demux->index[n + 1].time > seek_pos)) {
entry = n;
break;
}
n++;
}
return &demux->index[entry];
}
/* takes ownership of the passed event! */