summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorKipp Cannon <kcannon@ligo.caltech.edu>2009-08-21 06:58:31 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2009-08-26 09:10:17 +0200
commit86b4c51c8c6fc09eefef4ab002ff350aade01baa (patch)
tree20f69fd542b9f8af61aebd890f6b64c9fb12054d /gst
parenta69068d70d58467ebec0cd662889f9e5fe95fc8c (diff)
audioresample: Fix buffer overflow when pushing the drain
Diffstat (limited to 'gst')
-rw-r--r--gst/audioresample/gstaudioresample.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gst/audioresample/gstaudioresample.c b/gst/audioresample/gstaudioresample.c
index 5910a12e5..13db12a8d 100644
--- a/gst/audioresample/gstaudioresample.c
+++ b/gst/audioresample/gstaudioresample.c
@@ -46,6 +46,7 @@
#include <math.h>
#include "gstaudioresample.h"
+#include <gst/gstutils.h>
#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
@@ -557,11 +558,11 @@ gst_audio_resample_transform_size (GstBaseTransform * base,
if (direction == GST_PAD_SINK) {
/* asked to convert size of an incoming buffer. Round up the output size */
- *othersize = (size * ratio_den + ratio_num - 1) / ratio_num;
+ *othersize = gst_util_uint64_scale_int_ceil (size, ratio_den, ratio_num);
*othersize *= bytes_per_samp;
} else {
/* asked to convert size of an outgoing buffer. Round down the input size */
- *othersize = (size * ratio_num) / ratio_den;
+ *othersize = gst_util_uint64_scale_int (size, ratio_num, ratio_den);
*othersize *= bytes_per_samp;
}
@@ -785,7 +786,7 @@ gst_audio_resample_push_drain (GstAudioResample * resample)
GstBuffer *outbuf;
GstFlowReturn res;
gint outsize;
- guint out_len, out_processed;
+ guint history_len, out_len, out_processed;
gint err;
guint num, den;
@@ -798,8 +799,9 @@ gst_audio_resample_push_drain (GstAudioResample * resample)
resample->funcs->get_ratio (resample->state, &num, &den);
- out_len = resample->funcs->get_input_latency (resample->state);
- out_len = out_processed = (out_len * den + num - 1) / num;
+ history_len = resample->funcs->get_input_latency (resample->state);
+ out_len = out_processed =
+ gst_util_uint64_scale_int_ceil (history_len, den, num);
outsize = out_len * resample->channels * (resample->width / 8);
res =
@@ -830,7 +832,7 @@ gst_audio_resample_push_drain (GstAudioResample * resample)
GST_BUFFER_DATA (outbuf), out_processed, TRUE);
} else {
/* don't need to convert data format; process */
- err = resample->funcs->process (resample->state, NULL, &out_len,
+ err = resample->funcs->process (resample->state, NULL, &history_len,
GST_BUFFER_DATA (outbuf), &out_processed);
}