mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
audioresample: Fix buffer overflow when pushing the drain
This commit is contained in:
parent
a69068d70d
commit
86b4c51c8c
1 changed files with 8 additions and 6 deletions
|
@ -46,6 +46,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "gstaudioresample.h"
|
#include "gstaudioresample.h"
|
||||||
|
#include <gst/gstutils.h>
|
||||||
#include <gst/audio/audio.h>
|
#include <gst/audio/audio.h>
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
|
|
||||||
|
@ -557,11 +558,11 @@ gst_audio_resample_transform_size (GstBaseTransform * base,
|
||||||
|
|
||||||
if (direction == GST_PAD_SINK) {
|
if (direction == GST_PAD_SINK) {
|
||||||
/* asked to convert size of an incoming buffer. Round up the output size */
|
/* 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;
|
*othersize *= bytes_per_samp;
|
||||||
} else {
|
} else {
|
||||||
/* asked to convert size of an outgoing buffer. Round down the input size */
|
/* 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;
|
*othersize *= bytes_per_samp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,7 +786,7 @@ gst_audio_resample_push_drain (GstAudioResample * resample)
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
GstFlowReturn res;
|
GstFlowReturn res;
|
||||||
gint outsize;
|
gint outsize;
|
||||||
guint out_len, out_processed;
|
guint history_len, out_len, out_processed;
|
||||||
gint err;
|
gint err;
|
||||||
guint num, den;
|
guint num, den;
|
||||||
|
|
||||||
|
@ -798,8 +799,9 @@ gst_audio_resample_push_drain (GstAudioResample * resample)
|
||||||
|
|
||||||
resample->funcs->get_ratio (resample->state, &num, &den);
|
resample->funcs->get_ratio (resample->state, &num, &den);
|
||||||
|
|
||||||
out_len = resample->funcs->get_input_latency (resample->state);
|
history_len = resample->funcs->get_input_latency (resample->state);
|
||||||
out_len = out_processed = (out_len * den + num - 1) / num;
|
out_len = out_processed =
|
||||||
|
gst_util_uint64_scale_int_ceil (history_len, den, num);
|
||||||
outsize = out_len * resample->channels * (resample->width / 8);
|
outsize = out_len * resample->channels * (resample->width / 8);
|
||||||
|
|
||||||
res =
|
res =
|
||||||
|
@ -830,7 +832,7 @@ gst_audio_resample_push_drain (GstAudioResample * resample)
|
||||||
GST_BUFFER_DATA (outbuf), out_processed, TRUE);
|
GST_BUFFER_DATA (outbuf), out_processed, TRUE);
|
||||||
} else {
|
} else {
|
||||||
/* don't need to convert data format; process */
|
/* 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);
|
GST_BUFFER_DATA (outbuf), &out_processed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue