mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
ext/mad/gstmad.c: Merge patch from Radoslaw Szkodzinski (bug 326734)
Original commit message from CVS: * ext/mad/gstmad.c: (gst_mad_convert_src), (scale), (gst_mad_check_caps_reset), (gst_mad_chain): Merge patch from Radoslaw Szkodzinski (bug 326734)
This commit is contained in:
parent
aef0f9cfb1
commit
bcd611761c
2 changed files with 27 additions and 14 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2006-01-31 Jan Schmidt <thaytan@mad.scientist.com>
|
||||||
|
|
||||||
|
* ext/mad/gstmad.c: (gst_mad_convert_src), (scale),
|
||||||
|
(gst_mad_check_caps_reset), (gst_mad_chain):
|
||||||
|
Merge patch from Radoslaw Szkodzinski (bug 326734)
|
||||||
|
|
||||||
2006-01-31 Stefan Kost <ensonic@users.sf.net>
|
2006-01-31 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
* ext/mad/gstid3tag.c: (tag_list_to_id3_tag_foreach),
|
* ext/mad/gstid3tag.c: (tag_list_to_id3_tag_foreach),
|
||||||
|
|
|
@ -126,8 +126,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw-int, "
|
||||||
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
|
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
|
||||||
"signed = (boolean) true, "
|
"signed = (boolean) true, "
|
||||||
"width = (int) 16, "
|
"width = (int) 32, "
|
||||||
"depth = (int) 16, "
|
"depth = (int) 32, "
|
||||||
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
|
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
|
||||||
"channels = (int) [ 1, 2 ]")
|
"channels = (int) [ 1, 2 ]")
|
||||||
);
|
);
|
||||||
|
@ -476,7 +476,7 @@ gst_mad_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
|
||||||
|
|
||||||
mad = GST_MAD (GST_PAD_PARENT (pad));
|
mad = GST_MAD (GST_PAD_PARENT (pad));
|
||||||
|
|
||||||
bytes_per_sample = MAD_NCHANNELS (&mad->frame.header) << 1;
|
bytes_per_sample = MAD_NCHANNELS (&mad->frame.header) * 4;
|
||||||
|
|
||||||
switch (src_format) {
|
switch (src_format) {
|
||||||
case GST_FORMAT_BYTES:
|
case GST_FORMAT_BYTES:
|
||||||
|
@ -889,11 +889,13 @@ gst_mad_src_event (GstPad * pad, GstEvent * event)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline signed int
|
static inline gint32
|
||||||
scale (mad_fixed_t sample)
|
scale (mad_fixed_t sample)
|
||||||
{
|
{
|
||||||
|
#if MAD_F_FRACBITS < 28
|
||||||
/* round */
|
/* round */
|
||||||
sample += (1L << (MAD_F_FRACBITS - 16));
|
sample += (1L << (28 - MAD_F_FRACBITS - 1));
|
||||||
|
#endif
|
||||||
|
|
||||||
/* clip */
|
/* clip */
|
||||||
if (sample >= MAD_F_ONE)
|
if (sample >= MAD_F_ONE)
|
||||||
|
@ -901,8 +903,13 @@ scale (mad_fixed_t sample)
|
||||||
else if (sample < -MAD_F_ONE)
|
else if (sample < -MAD_F_ONE)
|
||||||
sample = -MAD_F_ONE;
|
sample = -MAD_F_ONE;
|
||||||
|
|
||||||
|
#if MAD_F_FRACBITS < 28
|
||||||
/* quantize */
|
/* quantize */
|
||||||
return sample >> (MAD_F_FRACBITS + 1 - 16);
|
sample >>= (28 - MAD_F_FRACBITS);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* convert from 29 bits to 32 bits */
|
||||||
|
return (gint32) (sample << 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do we need this function? */
|
/* do we need this function? */
|
||||||
|
@ -1265,8 +1272,8 @@ gst_mad_check_caps_reset (GstMad * mad)
|
||||||
caps = gst_caps_new_simple ("audio/x-raw-int",
|
caps = gst_caps_new_simple ("audio/x-raw-int",
|
||||||
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
||||||
"signed", G_TYPE_BOOLEAN, TRUE,
|
"signed", G_TYPE_BOOLEAN, TRUE,
|
||||||
"width", G_TYPE_INT, 16,
|
"width", G_TYPE_INT, 32,
|
||||||
"depth", G_TYPE_INT, 16,
|
"depth", G_TYPE_INT, 32,
|
||||||
"rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, nchannels, NULL);
|
"rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, nchannels, NULL);
|
||||||
|
|
||||||
gst_pad_set_caps (mad->srcpad, caps);
|
gst_pad_set_caps (mad->srcpad, caps);
|
||||||
|
@ -1519,13 +1526,13 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
to skip and send the remaining pcm samples */
|
to skip and send the remaining pcm samples */
|
||||||
|
|
||||||
GstBuffer *outbuffer = NULL;
|
GstBuffer *outbuffer = NULL;
|
||||||
gint16 *outdata;
|
gint32 *outdata;
|
||||||
mad_fixed_t const *left_ch, *right_ch;
|
mad_fixed_t const *left_ch, *right_ch;
|
||||||
|
|
||||||
/* will attach the caps to the buffer */
|
/* will attach the caps to the buffer */
|
||||||
result =
|
result =
|
||||||
gst_pad_alloc_buffer_and_set_caps (mad->srcpad, 0,
|
gst_pad_alloc_buffer_and_set_caps (mad->srcpad, 0,
|
||||||
nsamples * mad->channels * 2, GST_PAD_CAPS (mad->srcpad),
|
nsamples * mad->channels * 4, GST_PAD_CAPS (mad->srcpad),
|
||||||
&outbuffer);
|
&outbuffer);
|
||||||
if (result != GST_FLOW_OK) {
|
if (result != GST_FLOW_OK) {
|
||||||
/* Head for the exit, dropping samples as we go */
|
/* Head for the exit, dropping samples as we go */
|
||||||
|
@ -1538,7 +1545,7 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
left_ch = mad->synth.pcm.samples[0];
|
left_ch = mad->synth.pcm.samples[0];
|
||||||
right_ch = mad->synth.pcm.samples[1];
|
right_ch = mad->synth.pcm.samples[1];
|
||||||
|
|
||||||
outdata = (gint16 *) GST_BUFFER_DATA (outbuffer);
|
outdata = (gint32 *) GST_BUFFER_DATA (outbuffer);
|
||||||
|
|
||||||
GST_DEBUG ("mad out timestamp %" GST_TIME_FORMAT,
|
GST_DEBUG ("mad out timestamp %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (time_offset));
|
GST_TIME_ARGS (time_offset));
|
||||||
|
@ -1552,14 +1559,14 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
gint count = nsamples;
|
gint count = nsamples;
|
||||||
|
|
||||||
while (count--) {
|
while (count--) {
|
||||||
*outdata++ = scale (*left_ch++) & 0xffff;
|
*outdata++ = scale (*left_ch++) & 0xffffffff;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gint count = nsamples;
|
gint count = nsamples;
|
||||||
|
|
||||||
while (count--) {
|
while (count--) {
|
||||||
*outdata++ = scale (*left_ch++) & 0xffff;
|
*outdata++ = scale (*left_ch++) & 0xffffffff;
|
||||||
*outdata++ = scale (*right_ch++) & 0xffff;
|
*outdata++ = scale (*right_ch++) & 0xffffffff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue