mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 23:06:49 +00:00
gst/wavparse/gstwavparse.c: Handle rounding better to not drop last sample frame. Fixes #356692
Original commit message from CVS: Patch by: René Stadler <mail@renestadler.de> * gst/wavparse/gstwavparse.c: (uint64_ceiling_scale_int), (gst_wavparse_perform_seek), (gst_wavparse_stream_headers), (gst_wavparse_stream_data): Handle rounding better to not drop last sample frame. Fixes #356692
This commit is contained in:
parent
d3963f7a06
commit
a8b5f90ed0
2 changed files with 31 additions and 5 deletions
|
@ -1,3 +1,12 @@
|
|||
2007-03-02 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
Patch by: René Stadler <mail@renestadler.de>
|
||||
|
||||
* gst/wavparse/gstwavparse.c: (uint64_ceiling_scale_int),
|
||||
(gst_wavparse_perform_seek), (gst_wavparse_stream_headers),
|
||||
(gst_wavparse_stream_data):
|
||||
Handle rounding better to not drop last sample frame. Fixes #356692
|
||||
|
||||
2007-03-02 Jan Schmidt <thaytan@mad.scientist.com>
|
||||
|
||||
* tests/check/Makefile.am:
|
||||
|
|
|
@ -270,6 +270,23 @@ gst_wavparse_create_sourcepad (GstWavParse * wavparse)
|
|||
GST_DEBUG_OBJECT (wavparse, "srcpad created");
|
||||
}
|
||||
|
||||
/* Compute (value * nom) % denom, avoiding overflow. This can be used
|
||||
* to perform ceiling or rounding division together with
|
||||
* gst_util_uint64_scale[_int]. */
|
||||
#define uint64_scale_modulo(val, nom, denom) \
|
||||
((val % denom) * (nom % denom) % denom)
|
||||
|
||||
/* Like gst_util_uint64_scale_int, but performs ceiling division. */
|
||||
static guint64
|
||||
uint64_ceiling_scale_int (guint64 val, gint num, gint denom)
|
||||
{
|
||||
guint64 result = gst_util_uint64_scale_int (val, num, denom);
|
||||
|
||||
if (uint64_scale_modulo (val, num, denom) == 0)
|
||||
return result;
|
||||
else
|
||||
return result + 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
|
@ -833,7 +850,7 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
|
|||
* bytes. */
|
||||
if (wav->bps)
|
||||
wav->offset =
|
||||
gst_util_uint64_scale_int (seeksegment.last_stop, wav->bps,
|
||||
uint64_ceiling_scale_int (seeksegment.last_stop, wav->bps,
|
||||
GST_SECOND);
|
||||
else
|
||||
wav->offset = seeksegment.last_stop;
|
||||
|
@ -849,7 +866,7 @@ gst_wavparse_perform_seek (GstWavParse * wav, GstEvent * event)
|
|||
|
||||
if (stop_type != GST_SEEK_TYPE_NONE) {
|
||||
if (wav->bps)
|
||||
wav->end_offset = gst_util_uint64_scale_int (stop, wav->bps, GST_SECOND);
|
||||
wav->end_offset = uint64_ceiling_scale_int (stop, wav->bps, GST_SECOND);
|
||||
else
|
||||
wav->end_offset = stop;
|
||||
GST_LOG_OBJECT (wav, "end_offset=%" G_GUINT64_FORMAT, wav->end_offset);
|
||||
|
@ -1263,7 +1280,7 @@ gst_wavparse_stream_headers (GstWavParse * wav)
|
|||
}
|
||||
|
||||
if (wav->bps > 0) {
|
||||
duration = gst_util_uint64_scale_int (wav->datasize, GST_SECOND, wav->bps);
|
||||
duration = uint64_ceiling_scale_int (wav->datasize, wav->bps, GST_SECOND);
|
||||
GST_DEBUG_OBJECT (wav, "Got duration %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (duration));
|
||||
gst_segment_init (&wav->segment, GST_FORMAT_TIME);
|
||||
|
@ -1514,8 +1531,8 @@ iterate_adapter:
|
|||
|
||||
if (wav->bps > 0) {
|
||||
/* and timestamps if we have a bitrate, be carefull for overflows */
|
||||
timestamp = gst_util_uint64_scale_int (pos, GST_SECOND, wav->bps);
|
||||
next_timestamp = gst_util_uint64_scale_int (nextpos, GST_SECOND, wav->bps);
|
||||
timestamp = uint64_ceiling_scale_int (pos, wav->bps, GST_SECOND);
|
||||
next_timestamp = uint64_ceiling_scale_int (nextpos, wav->bps, GST_SECOND);
|
||||
duration = next_timestamp - timestamp;
|
||||
|
||||
/* update current running segment position */
|
||||
|
|
Loading…
Reference in a new issue