Commit 8a6f9aa5 authored by Wim Taymans's avatar Wim Taymans
Browse files

gst/law/: Fix law encoder timestamps.

Original commit message from CVS:
* gst/law/alaw-encode.c: (gst_alawenc_init), (gst_alawenc_chain):
* gst/law/alaw-encode.h:
* gst/law/mulaw-encode.c: (gst_mulawenc_init),
(gst_mulawenc_chain):
* gst/law/mulaw-encode.h:
Fix law encoder timestamps.
parent 5ff86cd7
2007-09-12 Wim Taymans <wim.taymans@gmail.com>
* gst/law/alaw-encode.c: (gst_alawenc_init), (gst_alawenc_chain):
* gst/law/alaw-encode.h:
* gst/law/mulaw-encode.c: (gst_mulawenc_init),
(gst_mulawenc_chain):
* gst/law/mulaw-encode.h:
Fix law encoder timestamps.
2007-09-12 Stefan Kost <ensonic@users.sf.net>
* ext/gconf/gstgconfaudiosink.c:
......
......@@ -264,7 +264,6 @@ gst_alawenc_init (GstALawEnc * alawenc)
/* init rest */
alawenc->channels = 0;
alawenc->rate = 0;
alawenc->ts = 0;
}
static GstFlowReturn
......@@ -278,6 +277,7 @@ gst_alawenc_chain (GstPad * pad, GstBuffer * buffer)
GstBuffer *outbuf;
gint i;
GstFlowReturn ret;
GstClockTime timestamp, duration;
alawenc = GST_ALAWENC (gst_pad_get_parent (pad));
......@@ -289,14 +289,22 @@ gst_alawenc_chain (GstPad * pad, GstBuffer * buffer)
alaw_size = linear_size / 2;
timestamp = GST_BUFFER_TIMESTAMP (buffer);
duration = GST_BUFFER_DURATION (buffer);
if (duration == -1) {
duration = gst_util_uint64_scale_int (alaw_size,
GST_SECOND, alawenc->rate * alawenc->channels);
}
outbuf = gst_buffer_new_and_alloc (alaw_size);
alaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
/* FIXME, just copy (and interpolate) timestamp */
GST_BUFFER_DURATION (outbuf) = gst_util_uint64_scale_int (alaw_size,
GST_SECOND, alawenc->rate * alawenc->channels);
GST_BUFFER_TIMESTAMP (outbuf) = alawenc->ts;
alawenc->ts += GST_BUFFER_DURATION (outbuf);
/* copy discont flag */
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
GST_BUFFER_DURATION (outbuf) = duration;
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (alawenc->srcpad));
......
......@@ -43,7 +43,6 @@ struct _GstALawEnc {
GstElement element;
GstPad *sinkpad,*srcpad;
guint64 ts;
gint channels;
gint rate;
......
......@@ -199,7 +199,6 @@ gst_mulawenc_init (GstMuLawEnc * mulawenc)
/* init rest */
mulawenc->channels = 0;
mulawenc->rate = 0;
mulawenc->ts = 0;
}
static GstFlowReturn
......@@ -207,10 +206,12 @@ gst_mulawenc_chain (GstPad * pad, GstBuffer * buffer)
{
GstMuLawEnc *mulawenc;
gint16 *linear_data;
guint linear_size;
guint8 *mulaw_data;
guint mulaw_size;
GstBuffer *outbuf;
GstFlowReturn ret;
GstClockTime timestamp, duration;
mulawenc = GST_MULAWENC (gst_pad_get_parent (pad));
......@@ -218,7 +219,16 @@ gst_mulawenc_chain (GstPad * pad, GstBuffer * buffer)
goto not_negotiated;
linear_data = (gint16 *) GST_BUFFER_DATA (buffer);
mulaw_size = GST_BUFFER_SIZE (buffer) / 2;
linear_size = GST_BUFFER_SIZE (buffer);
mulaw_size = linear_size / 2;
timestamp = GST_BUFFER_TIMESTAMP (buffer);
duration = GST_BUFFER_DURATION (buffer);
if (duration == -1) {
duration = gst_util_uint64_scale_int (mulaw_size,
GST_SECOND, mulawenc->rate * mulawenc->channels);
}
outbuf = gst_buffer_new_and_alloc (mulaw_size);
mulaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
......@@ -227,8 +237,9 @@ gst_mulawenc_chain (GstPad * pad, GstBuffer * buffer)
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
GST_BUFFER_DURATION (outbuf) = duration;
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mulawenc->srcpad));
mulaw_encode (linear_data, mulaw_data, mulaw_size);
......
......@@ -44,8 +44,6 @@ struct _GstMuLawEnc {
GstPad *sinkpad,*srcpad;
guint64 ts;
gint channels;
gint rate;
};
......
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