mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
gst/law/: Some cleanups in the chain functions.
Original commit message from CVS: * gst/law/alaw-decode.c: (gst_alawdec_chain): * gst/law/alaw-decode.h: * gst/law/alaw-encode.c: (gst_alawenc_chain): * gst/law/alaw-encode.h: * gst/law/mulaw-decode.c: (gst_mulawdec_chain): * gst/law/mulaw-decode.h: * gst/law/mulaw-encode.c: (gst_mulawenc_chain): * gst/law/mulaw-encode.h: Some cleanups in the chain functions. Remove some GStreamer 0.0.2 bits.
This commit is contained in:
parent
d4e266cd6d
commit
7b39d55850
9 changed files with 105 additions and 97 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2006-05-24 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/law/alaw-decode.c: (gst_alawdec_chain):
|
||||||
|
* gst/law/alaw-decode.h:
|
||||||
|
* gst/law/alaw-encode.c: (gst_alawenc_chain):
|
||||||
|
* gst/law/alaw-encode.h:
|
||||||
|
* gst/law/mulaw-decode.c: (gst_mulawdec_chain):
|
||||||
|
* gst/law/mulaw-decode.h:
|
||||||
|
* gst/law/mulaw-encode.c: (gst_mulawenc_chain):
|
||||||
|
* gst/law/mulaw-encode.h:
|
||||||
|
Some cleanups in the chain functions.
|
||||||
|
Remove some GStreamer 0.0.2 bits.
|
||||||
|
|
||||||
2006-05-23 Tim-Philipp Müller <tim at centricular dot net>
|
2006-05-23 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
Patch by: Mark Nauwelaerts <manauw at skynet be>
|
Patch by: Mark Nauwelaerts <manauw at skynet be>
|
||||||
|
|
|
@ -229,24 +229,35 @@ gst_alawdec_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
GstALawDec *alawdec;
|
GstALawDec *alawdec;
|
||||||
gint16 *linear_data;
|
gint16 *linear_data;
|
||||||
guint8 *alaw_data;
|
guint8 *alaw_data;
|
||||||
|
guint alaw_size;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
gint i;
|
gint i;
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
alawdec = GST_ALAWDEC (GST_OBJECT_PARENT (pad));
|
alawdec = GST_ALAWDEC (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
|
alaw_data = GST_BUFFER_DATA (buffer);
|
||||||
|
alaw_size = GST_BUFFER_SIZE (buffer);
|
||||||
|
|
||||||
|
outbuf = gst_buffer_new_and_alloc (alaw_size * 2);
|
||||||
|
linear_data = (gint16 *) GST_BUFFER_DATA (outbuf);
|
||||||
|
|
||||||
|
/* copy discont flag */
|
||||||
|
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
|
||||||
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
|
||||||
|
|
||||||
alaw_data = (guint8 *) GST_BUFFER_DATA (buffer);
|
|
||||||
outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buffer) * 2);
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
|
||||||
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (alawdec->srcpad));
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (alawdec->srcpad));
|
||||||
linear_data = (gint16 *) GST_BUFFER_DATA (outbuf);
|
|
||||||
|
|
||||||
for (i = 0; i < GST_BUFFER_SIZE (buffer); i++) {
|
for (i = 0; i < alaw_size; i++) {
|
||||||
*linear_data = alaw_to_s16 (*alaw_data);
|
linear_data[i] = alaw_to_s16 (alaw_data[i]);
|
||||||
linear_data++;
|
|
||||||
alaw_data++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return gst_pad_push (alawdec->srcpad, outbuf);
|
|
||||||
|
ret = gst_pad_push (alawdec->srcpad, outbuf);
|
||||||
|
|
||||||
|
gst_object_unref (alawdec);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,9 @@
|
||||||
#ifndef __GST_ALAWDECODE_H__
|
#ifndef __GST_ALAWDECODE_H__
|
||||||
#define __GST_ALAWDECODE_H__
|
#define __GST_ALAWDECODE_H__
|
||||||
|
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
/* #include <gst/meta/audioraw.h> */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_ALAWDEC \
|
#define GST_TYPE_ALAWDEC \
|
||||||
(gst_alawdec_get_type())
|
(gst_alawdec_get_type())
|
||||||
|
@ -49,9 +43,6 @@ struct _GstALawDec {
|
||||||
GstElement element;
|
GstElement element;
|
||||||
|
|
||||||
GstPad *sinkpad,*srcpad;
|
GstPad *sinkpad,*srcpad;
|
||||||
|
|
||||||
/*MetaAudioRaw meta; */
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstALawDecClass {
|
struct _GstALawDecClass {
|
||||||
|
@ -60,9 +51,6 @@ struct _GstALawDecClass {
|
||||||
|
|
||||||
GType gst_alawdec_get_type(void);
|
GType gst_alawdec_get_type(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
G_END_DECLS
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GST_STEREO_H__ */
|
#endif /* __GST_STEREO_H__ */
|
||||||
|
|
|
@ -269,40 +269,50 @@ gst_alawenc_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstALawEnc *alawenc;
|
GstALawEnc *alawenc;
|
||||||
gint16 *linear_data;
|
gint16 *linear_data;
|
||||||
|
guint linear_size;
|
||||||
guint8 *alaw_data;
|
guint8 *alaw_data;
|
||||||
|
guint alaw_size;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
gint bufsize;
|
|
||||||
gint i;
|
gint i;
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
alawenc = GST_ALAWENC (GST_OBJECT_PARENT (pad));
|
alawenc = GST_ALAWENC (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
if (!alawenc->rate || !alawenc->channels)
|
if (!alawenc->rate || !alawenc->channels)
|
||||||
goto not_negotiated;
|
goto not_negotiated;
|
||||||
|
|
||||||
linear_data = (gint16 *) GST_BUFFER_DATA (buffer);
|
linear_data = (gint16 *) GST_BUFFER_DATA (buffer);
|
||||||
bufsize = GST_BUFFER_SIZE (buffer) / 2;
|
linear_size = GST_BUFFER_SIZE (buffer);
|
||||||
outbuf = gst_buffer_new_and_alloc (bufsize);
|
|
||||||
|
|
||||||
GST_BUFFER_DURATION (outbuf) = GST_SECOND * (bufsize) /
|
alaw_size = linear_size / 2;
|
||||||
(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;
|
GST_BUFFER_TIMESTAMP (outbuf) = alawenc->ts;
|
||||||
alawenc->ts += GST_BUFFER_DURATION (outbuf);
|
alawenc->ts += GST_BUFFER_DURATION (outbuf);
|
||||||
|
|
||||||
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (alawenc->srcpad));
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (alawenc->srcpad));
|
||||||
alaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
|
|
||||||
|
|
||||||
for (i = 0; i < GST_BUFFER_SIZE (outbuf); i++) {
|
for (i = 0; i < alaw_size; i++) {
|
||||||
*alaw_data = s16_to_alaw (*linear_data);
|
alaw_data[i] = s16_to_alaw (linear_data[i]);
|
||||||
alaw_data++;
|
|
||||||
linear_data++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return gst_pad_push (alawenc->srcpad, outbuf);
|
ret = gst_pad_push (alawenc->srcpad, outbuf);
|
||||||
|
|
||||||
|
done:
|
||||||
|
gst_object_unref (alawenc);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
not_negotiated:
|
not_negotiated:
|
||||||
{
|
{
|
||||||
return GST_FLOW_NOT_NEGOTIATED;
|
ret = GST_FLOW_NOT_NEGOTIATED;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,9 @@
|
||||||
#ifndef __GST_ALAWENCODE_H__
|
#ifndef __GST_ALAWENCODE_H__
|
||||||
#define __GST_ALAWENCODE_H__
|
#define __GST_ALAWENCODE_H__
|
||||||
|
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
/* #include <gst/meta/audioraw.h> */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_ALAWENC \
|
#define GST_TYPE_ALAWENC \
|
||||||
(gst_alawenc_get_type())
|
(gst_alawenc_get_type())
|
||||||
|
@ -53,9 +47,6 @@ struct _GstALawEnc {
|
||||||
|
|
||||||
gint channels;
|
gint channels;
|
||||||
gint rate;
|
gint rate;
|
||||||
|
|
||||||
/*MetaAudioRaw meta; */
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstALawEncClass {
|
struct _GstALawEncClass {
|
||||||
|
@ -64,9 +55,6 @@ struct _GstALawEncClass {
|
||||||
|
|
||||||
GType gst_alawenc_get_type(void);
|
GType gst_alawenc_get_type(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
G_END_DECLS
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GST_STEREO_H__ */
|
#endif /* __GST_STEREO_H__ */
|
||||||
|
|
|
@ -205,20 +205,33 @@ gst_mulawdec_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
GstMuLawDec *mulawdec;
|
GstMuLawDec *mulawdec;
|
||||||
gint16 *linear_data;
|
gint16 *linear_data;
|
||||||
guint8 *mulaw_data;
|
guint8 *mulaw_data;
|
||||||
|
guint mulaw_size;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
mulawdec = GST_MULAWDEC (GST_OBJECT_PARENT (pad));
|
mulawdec = GST_MULAWDEC (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
mulaw_data = (guint8 *) GST_BUFFER_DATA (buffer);
|
mulaw_data = (guint8 *) GST_BUFFER_DATA (buffer);
|
||||||
outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buffer) * 2);
|
mulaw_size = GST_BUFFER_SIZE (buffer);
|
||||||
|
|
||||||
|
outbuf = gst_buffer_new_and_alloc (mulaw_size * 2);
|
||||||
|
linear_data = (gint16 *) GST_BUFFER_DATA (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) = GST_BUFFER_TIMESTAMP (buffer);
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
|
||||||
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mulawdec->srcpad));
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mulawdec->srcpad));
|
||||||
linear_data = (gint16 *) GST_BUFFER_DATA (outbuf);
|
|
||||||
|
|
||||||
mulaw_decode (mulaw_data, linear_data, GST_BUFFER_SIZE (buffer));
|
mulaw_decode (mulaw_data, linear_data, mulaw_size);
|
||||||
|
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return gst_pad_push (mulawdec->srcpad, outbuf);
|
ret = gst_pad_push (mulawdec->srcpad, outbuf);
|
||||||
|
|
||||||
|
gst_object_unref (mulawdec);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,19 +17,12 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __GST_MULAWDECODE_H__
|
#ifndef __GST_MULAWDECODE_H__
|
||||||
#define __GST_MULAWDECODE_H__
|
#define __GST_MULAWDECODE_H__
|
||||||
|
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
/* #include <gst/meta/audioraw.h> */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_MULAWDEC \
|
#define GST_TYPE_MULAWDEC \
|
||||||
(gst_mulawdec_get_type())
|
(gst_mulawdec_get_type())
|
||||||
|
@ -49,9 +42,6 @@ struct _GstMuLawDec {
|
||||||
GstElement element;
|
GstElement element;
|
||||||
|
|
||||||
GstPad *sinkpad,*srcpad;
|
GstPad *sinkpad,*srcpad;
|
||||||
|
|
||||||
/*MetaAudioRaw meta; */
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstMuLawDecClass {
|
struct _GstMuLawDecClass {
|
||||||
|
@ -60,9 +50,6 @@ struct _GstMuLawDecClass {
|
||||||
|
|
||||||
GType gst_mulawdec_get_type(void);
|
GType gst_mulawdec_get_type(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
G_END_DECLS
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GST_STEREO_H__ */
|
#endif /* __GST_STEREO_H__ */
|
||||||
|
|
|
@ -205,34 +205,43 @@ gst_mulawenc_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
GstMuLawEnc *mulawenc;
|
GstMuLawEnc *mulawenc;
|
||||||
gint16 *linear_data;
|
gint16 *linear_data;
|
||||||
guint8 *mulaw_data;
|
guint8 *mulaw_data;
|
||||||
|
guint mulaw_size;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
gint bufsize;
|
GstFlowReturn ret;
|
||||||
|
|
||||||
mulawenc = GST_MULAWENC (GST_OBJECT_PARENT (pad));
|
mulawenc = GST_MULAWENC (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
if (!mulawenc->rate || !mulawenc->channels)
|
if (!mulawenc->rate || !mulawenc->channels)
|
||||||
goto not_negotiated;
|
goto not_negotiated;
|
||||||
|
|
||||||
linear_data = (gint16 *) GST_BUFFER_DATA (buffer);
|
linear_data = (gint16 *) GST_BUFFER_DATA (buffer);
|
||||||
bufsize = GST_BUFFER_SIZE (buffer) / 2;
|
mulaw_size = GST_BUFFER_SIZE (buffer) / 2;
|
||||||
outbuf = gst_buffer_new_and_alloc (bufsize);
|
|
||||||
|
|
||||||
GST_BUFFER_DURATION (outbuf) = GST_SECOND * (bufsize) /
|
outbuf = gst_buffer_new_and_alloc (mulaw_size);
|
||||||
(mulawenc->rate * mulawenc->channels);
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = mulawenc->ts;
|
|
||||||
mulawenc->ts += GST_BUFFER_DURATION (outbuf);
|
|
||||||
|
|
||||||
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mulawenc->srcpad));
|
|
||||||
mulaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
|
mulaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
|
||||||
|
|
||||||
mulaw_encode (linear_data, mulaw_data, GST_BUFFER_SIZE (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_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
|
||||||
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mulawenc->srcpad));
|
||||||
|
|
||||||
|
mulaw_encode (linear_data, mulaw_data, mulaw_size);
|
||||||
|
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return gst_pad_push (mulawenc->srcpad, outbuf);
|
ret = gst_pad_push (mulawenc->srcpad, outbuf);
|
||||||
|
|
||||||
|
done:
|
||||||
|
gst_object_unref (mulawenc);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
not_negotiated:
|
not_negotiated:
|
||||||
{
|
{
|
||||||
return GST_FLOW_NOT_NEGOTIATED;
|
ret = GST_FLOW_NOT_NEGOTIATED;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,9 @@
|
||||||
#ifndef __GST_MULAWENCODE_H__
|
#ifndef __GST_MULAWENCODE_H__
|
||||||
#define __GST_MULAWENCODE_H__
|
#define __GST_MULAWENCODE_H__
|
||||||
|
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
/* #include <gst/meta/audioraw.h> */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_MULAWENC \
|
#define GST_TYPE_MULAWENC \
|
||||||
(gst_mulawenc_get_type())
|
(gst_mulawenc_get_type())
|
||||||
|
@ -54,8 +48,6 @@ struct _GstMuLawEnc {
|
||||||
|
|
||||||
gint channels;
|
gint channels;
|
||||||
gint rate;
|
gint rate;
|
||||||
/*MetaAudioRaw meta; */
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstMuLawEncClass {
|
struct _GstMuLawEncClass {
|
||||||
|
@ -64,9 +56,6 @@ struct _GstMuLawEncClass {
|
||||||
|
|
||||||
GType gst_mulawenc_get_type(void);
|
GType gst_mulawenc_get_type(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
G_END_DECLS
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GST_STEREO_H__ */
|
#endif /* __GST_STEREO_H__ */
|
||||||
|
|
Loading…
Reference in a new issue