Commit e81c80a4 authored by Wim Taymans's avatar Wim Taymans
Browse files

ext/speex/gstspeexdec.c: Use different variables for nested for loops so that...

ext/speex/gstspeexdec.c: Use different variables for nested for loops so that the outer loop functions properly and s...

Original commit message from CVS:
* ext/speex/gstspeexdec.c: (speex_dec_chain_parse_data):
Use different variables for nested for loops so that the outer loop
functions properly and speex files with multiple frames per buffer work
properly.
Fixes #441408.
parent da0da245
2007-05-26 Wim Taymans <wim@fluendo.com>
* ext/speex/gstspeexdec.c: (speex_dec_chain_parse_data):
Use different variables for nested for loops so that the outer loop
functions properly and speex files with multiple frames per buffer work
properly.
Fixes #441408.
2007-05-25 Tim-Philipp Müller <tim at centricular dot net>
* gst/id3demux/gstid3demux.c: (gst_id3demux_sink_event):
......
......@@ -626,18 +626,28 @@ static GstFlowReturn
speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf)
{
GstFlowReturn res = GST_FLOW_OK;
gint i;
gint i, fpp;
guint size;
guint8 *data;
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
/* send data to the bitstream */
speex_bits_read_from (&dec->bits, (char *) GST_BUFFER_DATA (buf),
GST_BUFFER_SIZE (buf));
speex_bits_read_from (&dec->bits, (char *) data, size);
fpp = dec->header->frames_per_packet;
GST_DEBUG_OBJECT (dec, "received buffer of size %u, fpp %d", size, fpp);
/* now decode each frame */
for (i = 0; i < dec->header->frames_per_packet; i++) {
for (i = 0; i < fpp; i++) {
GstBuffer *outbuf;
gint64 timestamp;
gint16 *out_data;
gint ret;
gint ret, j;
GST_LOG_OBJECT (dec, "decoding frame %d/%d", i, fpp);
ret = speex_decode (dec->state, &dec->bits, dec->output);
if (ret == -1) {
......@@ -648,6 +658,7 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf)
GST_WARNING_OBJECT (dec, "Decoding error: corrupted stream?");
break;
}
if (speex_bits_remaining (&dec->bits) < 0) {
GST_WARNING_OBJECT (dec, "Decoding overflow: corrupted stream?");
break;
......@@ -667,13 +678,13 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf)
out_data = (gint16 *) GST_BUFFER_DATA (outbuf);
/*PCM saturation (just in case) */
for (i = 0; i < dec->frame_size * dec->header->nb_channels; i++) {
if (dec->output[i] > 32767.0)
out_data[i] = 32767;
for (j = 0; j < dec->frame_size * dec->header->nb_channels; j++) {
if (dec->output[j] > 32767.0)
out_data[j] = 32767;
else if (dec->output[i] < -32768.0)
out_data[i] = -32768;
out_data[j] = -32768;
else
out_data[i] = (gint16) dec->output[i];
out_data[j] = (gint16) dec->output[j];
}
if (dec->granulepos == -1) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment