mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
gst/wavenc/gstwavenc.c: Don't allow width=32,depth=24 as input. WAV requires that the width is the next integer multi...
Original commit message from CVS: * gst/wavenc/gstwavenc.c: (gst_wavenc_chain): Don't allow width=32,depth=24 as input. WAV requires that the width is the next integer multiply of 8 from the depth.
This commit is contained in:
parent
09e449609f
commit
0e1f7b54bb
2 changed files with 8 additions and 53 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2008-10-28 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
|
* gst/wavenc/gstwavenc.c: (gst_wavenc_chain):
|
||||||
|
Don't allow width=32,depth=24 as input. WAV requires that the width
|
||||||
|
is the next integer multiply of 8 from the depth.
|
||||||
|
|
||||||
2008-10-28 Wim Taymans <wim.taymans@collabora.co.uk>
|
2008-10-28 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
* gst/rtp/gstrtpL16depay.c: (gst_rtp_L16_depay_setcaps):
|
* gst/rtp/gstrtpL16depay.c: (gst_rtp_L16_depay_setcaps):
|
||||||
|
|
|
@ -79,7 +79,7 @@ GST_ELEMENT_DETAILS ("WAV audio muxer",
|
||||||
"channels = (int) [ 1, 2 ], " \
|
"channels = (int) [ 1, 2 ], " \
|
||||||
"endianness = (int) LITTLE_ENDIAN, " \
|
"endianness = (int) LITTLE_ENDIAN, " \
|
||||||
"width = (int) 32, " \
|
"width = (int) 32, " \
|
||||||
"depth = (int) { 24, 32 }, " \
|
"depth = (int) 32, " \
|
||||||
"signed = (boolean) true" \
|
"signed = (boolean) true" \
|
||||||
"; " \
|
"; " \
|
||||||
"audio/x-raw-int, " \
|
"audio/x-raw-int, " \
|
||||||
|
@ -608,52 +608,6 @@ gst_wavenc_event (GstPad * pad, GstEvent * event)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copied from gst-plugins-base/gst/audioconvert/audioconvert.c */
|
|
||||||
#define READ24_FROM_LE(p) (p[0] | (p[1] << 8) | (p[2] << 16))
|
|
||||||
#define WRITE24_TO_LE(p,v) p[0] = v & 0xff; p[1] = (v >> 8) & 0xff; p[2] = (v >> 16) & 0xff
|
|
||||||
|
|
||||||
/* Correctly format samples with width!=depth for the wav format, i.e.
|
|
||||||
* have the data in the highest depth bits and all others zero */
|
|
||||||
static void
|
|
||||||
gst_wavenc_format_samples (GstBuffer * buf, guint width, guint depth)
|
|
||||||
{
|
|
||||||
guint8 *data = GST_BUFFER_DATA (buf);
|
|
||||||
guint nsamples = (GST_BUFFER_SIZE (buf) * 8) / width;
|
|
||||||
guint32 tmp;
|
|
||||||
|
|
||||||
for (; nsamples; nsamples--) {
|
|
||||||
switch (width) {
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
tmp = *data;
|
|
||||||
*data = *data << (width - depth);
|
|
||||||
data += 1;
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
tmp = GST_READ_UINT16_LE (data);
|
|
||||||
tmp = tmp << (width - depth);
|
|
||||||
GST_WRITE_UINT16_LE (data, tmp);
|
|
||||||
data += 2;
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
tmp = READ24_FROM_LE (data);
|
|
||||||
tmp = tmp << (width - depth);
|
|
||||||
WRITE24_TO_LE (data, tmp);
|
|
||||||
data += 3;
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
tmp = GST_READ_UINT32_LE (data);
|
|
||||||
tmp = tmp << (width - depth);
|
|
||||||
GST_WRITE_UINT32_LE (data, tmp);
|
|
||||||
data += 4;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef READ24_FROM_LE
|
|
||||||
#undef WRITE24_TO_LE
|
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_wavenc_chain (GstPad * pad, GstBuffer * buf)
|
gst_wavenc_chain (GstPad * pad, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
|
@ -679,12 +633,7 @@ gst_wavenc_chain (GstPad * pad, GstBuffer * buf)
|
||||||
GST_LOG_OBJECT (wavenc, "pushing %u bytes raw audio, ts=%" GST_TIME_FORMAT,
|
GST_LOG_OBJECT (wavenc, "pushing %u bytes raw audio, ts=%" GST_TIME_FORMAT,
|
||||||
GST_BUFFER_SIZE (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
|
GST_BUFFER_SIZE (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
|
||||||
|
|
||||||
if (wavenc->width != wavenc->depth) {
|
buf = gst_buffer_make_metadata_writable (buf);
|
||||||
buf = gst_buffer_make_writable (buf);
|
|
||||||
gst_wavenc_format_samples (buf, wavenc->width, wavenc->depth);
|
|
||||||
} else {
|
|
||||||
buf = gst_buffer_make_metadata_writable (buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_buffer_set_caps (buf, GST_PAD_CAPS (wavenc->srcpad));
|
gst_buffer_set_caps (buf, GST_PAD_CAPS (wavenc->srcpad));
|
||||||
GST_BUFFER_OFFSET (buf) = WAV_HEADER_LEN + wavenc->length;
|
GST_BUFFER_OFFSET (buf) = WAV_HEADER_LEN + wavenc->length;
|
||||||
|
|
Loading…
Reference in a new issue