mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
ext/speex/gstspeexdec.c: Try to preserve input timestamps when we can.
Original commit message from CVS: * ext/speex/gstspeexdec.c: (speex_dec_chain_parse_data), (speex_dec_chain): Try to preserve input timestamps when we can. Do beginnings of error concealment.
This commit is contained in:
parent
d76f39be0e
commit
0062c4d6d0
2 changed files with 44 additions and 13 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2008-04-29 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
|
* ext/speex/gstspeexdec.c: (speex_dec_chain_parse_data),
|
||||||
|
(speex_dec_chain):
|
||||||
|
Try to preserve input timestamps when we can.
|
||||||
|
Do beginnings of error concealment.
|
||||||
|
|
||||||
2008-04-28 Michael Smith <msmith@songbirdnest.com>
|
2008-04-28 Michael Smith <msmith@songbirdnest.com>
|
||||||
|
|
||||||
* gst/debug/gstnavigationtest.c:
|
* gst/debug/gstnavigationtest.c:
|
||||||
|
|
|
@ -106,6 +106,9 @@ static void gst_speex_dec_get_property (GObject * object, guint prop_id,
|
||||||
static void gst_speex_dec_set_property (GObject * object, guint prop_id,
|
static void gst_speex_dec_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
|
static GstFlowReturn speex_dec_chain_parse_data (GstSpeexDec * dec,
|
||||||
|
GstBuffer * buf, GstClockTime timestamp, GstClockTime duration);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_speex_dec_base_init (gpointer g_class)
|
gst_speex_dec_base_init (gpointer g_class)
|
||||||
{
|
{
|
||||||
|
@ -623,13 +626,21 @@ speex_dec_chain_parse_comments (GstSpeexDec * dec, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf)
|
speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf,
|
||||||
|
GstClockTime timestamp, GstClockTime duration)
|
||||||
{
|
{
|
||||||
GstFlowReturn res = GST_FLOW_OK;
|
GstFlowReturn res = GST_FLOW_OK;
|
||||||
gint i, fpp;
|
gint i, fpp;
|
||||||
guint size;
|
guint size;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
SpeexBits *bits;
|
||||||
|
|
||||||
|
if (timestamp != -1) {
|
||||||
|
dec->segment.last_stop = timestamp;
|
||||||
|
dec->granulepos = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buf) {
|
||||||
data = GST_BUFFER_DATA (buf);
|
data = GST_BUFFER_DATA (buf);
|
||||||
size = GST_BUFFER_SIZE (buf);
|
size = GST_BUFFER_SIZE (buf);
|
||||||
|
|
||||||
|
@ -637,19 +648,27 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf)
|
||||||
speex_bits_read_from (&dec->bits, (char *) data, size);
|
speex_bits_read_from (&dec->bits, (char *) data, size);
|
||||||
|
|
||||||
fpp = dec->header->frames_per_packet;
|
fpp = dec->header->frames_per_packet;
|
||||||
|
bits = &dec->bits;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dec, "received buffer of size %u, fpp %d", size, fpp);
|
GST_DEBUG_OBJECT (dec, "received buffer of size %u, fpp %d", size, fpp);
|
||||||
|
|
||||||
|
/* copy timestamp */
|
||||||
|
} else {
|
||||||
|
GST_DEBUG_OBJECT (dec, "creating concealment data");
|
||||||
|
fpp = dec->header->frames_per_packet;
|
||||||
|
bits = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* now decode each frame */
|
/* now decode each frame */
|
||||||
for (i = 0; i < fpp; i++) {
|
for (i = 0; i < fpp; i++) {
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
gint64 timestamp;
|
|
||||||
gint16 *out_data;
|
gint16 *out_data;
|
||||||
gint ret, j;
|
gint ret, j;
|
||||||
|
|
||||||
GST_LOG_OBJECT (dec, "decoding frame %d/%d", i, fpp);
|
GST_LOG_OBJECT (dec, "decoding frame %d/%d", i, fpp);
|
||||||
|
|
||||||
ret = speex_decode (dec->state, &dec->bits, dec->output);
|
ret = speex_decode (dec->state, bits, dec->output);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
/* uh? end of stream */
|
/* uh? end of stream */
|
||||||
GST_WARNING_OBJECT (dec, "Unexpected end of stream found");
|
GST_WARNING_OBJECT (dec, "Unexpected end of stream found");
|
||||||
|
@ -659,7 +678,7 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (speex_bits_remaining (&dec->bits) < 0) {
|
if (bits && speex_bits_remaining (bits) < 0) {
|
||||||
GST_WARNING_OBJECT (dec, "Decoding overflow: corrupted stream?");
|
GST_WARNING_OBJECT (dec, "Decoding overflow: corrupted stream?");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -698,8 +717,10 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf)
|
||||||
GST_DEBUG_OBJECT (dec, "granulepos=%" G_GINT64_FORMAT, dec->granulepos);
|
GST_DEBUG_OBJECT (dec, "granulepos=%" G_GINT64_FORMAT, dec->granulepos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (timestamp == -1) {
|
||||||
timestamp = gst_util_uint64_scale_int (dec->granulepos,
|
timestamp = gst_util_uint64_scale_int (dec->granulepos,
|
||||||
GST_SECOND, dec->header->rate);
|
GST_SECOND, dec->header->rate);
|
||||||
|
}
|
||||||
|
|
||||||
GST_BUFFER_OFFSET (outbuf) = dec->granulepos;
|
GST_BUFFER_OFFSET (outbuf) = dec->granulepos;
|
||||||
GST_BUFFER_OFFSET_END (outbuf) = dec->granulepos + dec->frame_size;
|
GST_BUFFER_OFFSET_END (outbuf) = dec->granulepos + dec->frame_size;
|
||||||
|
@ -719,6 +740,7 @@ speex_dec_chain_parse_data (GstSpeexDec * dec, GstBuffer * buf)
|
||||||
GST_DEBUG_OBJECT (dec, "flow: %s", gst_flow_get_name (res));
|
GST_DEBUG_OBJECT (dec, "flow: %s", gst_flow_get_name (res));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
timestamp = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -740,7 +762,9 @@ speex_dec_chain (GstPad * pad, GstBuffer * buf)
|
||||||
res = speex_dec_chain_parse_comments (dec, buf);
|
res = speex_dec_chain_parse_comments (dec, buf);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
res = speex_dec_chain_parse_data (dec, buf);
|
res =
|
||||||
|
speex_dec_chain_parse_data (dec, buf, GST_BUFFER_TIMESTAMP (buf),
|
||||||
|
GST_BUFFER_DURATION (buf));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue