summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2010-02-03 14:37:43 +0100
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2010-02-15 12:10:41 +0100
commit5e06eaa5170c8cd90fabea6db9bf658d2fc6facd (patch)
treecbda09427b95c1941fbadcde31604aa8e449794e
parent40a841e377c53e61ef96420c687636c47aeeee31 (diff)
vorbisdec: reduce some hard-coding
... such as assuming float all over, and base src caps on template caps.
-rw-r--r--ext/vorbis/gstvorbisdec.c21
-rw-r--r--ext/vorbis/gstvorbisdec.h1
2 files changed, 12 insertions, 10 deletions
diff --git a/ext/vorbis/gstvorbisdec.c b/ext/vorbis/gstvorbisdec.c
index c56259a2..a8a46fa6 100644
--- a/ext/vorbis/gstvorbisdec.c
+++ b/ext/vorbis/gstvorbisdec.c
@@ -237,7 +237,7 @@ vorbis_dec_convert (GstPad * pad,
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_BYTES:
- scale = sizeof (float) * dec->vi.channels;
+ scale = dec->width * dec->vi.channels;
case GST_FORMAT_DEFAULT:
*dest_value =
scale * gst_util_uint64_scale_int (src_value, dec->vi.rate,
@@ -250,7 +250,7 @@ vorbis_dec_convert (GstPad * pad,
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
case GST_FORMAT_BYTES:
- *dest_value = src_value * sizeof (float) * dec->vi.channels;
+ *dest_value = src_value * dec->width * dec->vi.channels;
break;
case GST_FORMAT_TIME:
*dest_value =
@@ -263,11 +263,11 @@ vorbis_dec_convert (GstPad * pad,
case GST_FORMAT_BYTES:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
- *dest_value = src_value / (sizeof (float) * dec->vi.channels);
+ *dest_value = src_value / (dec->width * dec->vi.channels);
break;
case GST_FORMAT_TIME:
*dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND,
- dec->vi.rate * sizeof (float) * dec->vi.channels);
+ dec->vi.rate * dec->width * dec->vi.channels);
break;
default:
res = FALSE;
@@ -589,10 +589,11 @@ vorbis_handle_identification_packet (GstVorbisDec * vd)
}
}
- caps = gst_caps_new_simple ("audio/x-raw-float",
- "rate", G_TYPE_INT, vd->vi.rate,
- "channels", G_TYPE_INT, vd->vi.channels,
- "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32, NULL);
+ vd->width = 4;
+
+ caps = gst_caps_copy (gst_pad_get_pad_template_caps (vd->srcpad));
+ gst_caps_set_simple (caps, "rate", G_TYPE_INT, vd->vi.rate,
+ "channels", G_TYPE_INT, vd->vi.channels);
if (pos) {
gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
@@ -797,7 +798,7 @@ vorbis_dec_push_forward (GstVorbisDec * dec, GstBuffer * buf)
/* clip */
if (!(buf = gst_audio_buffer_clip (buf, &dec->segment, dec->vi.rate,
- dec->vi.channels * sizeof (float)))) {
+ dec->vi.channels * dec->width))) {
GST_LOG_OBJECT (dec, "clipped buffer");
return GST_FLOW_OK;
}
@@ -882,7 +883,7 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet,
if ((sample_count = vorbis_synthesis_pcmout (&vd->vd, NULL)) == 0)
goto done;
- size = sample_count * vd->vi.channels * sizeof (float);
+ size = sample_count * vd->vi.channels * vd->width;
GST_LOG_OBJECT (vd, "%d samples ready for reading, size %d", sample_count,
size);
diff --git a/ext/vorbis/gstvorbisdec.h b/ext/vorbis/gstvorbisdec.h
index 693ead85..c4e2d951 100644
--- a/ext/vorbis/gstvorbisdec.h
+++ b/ext/vorbis/gstvorbisdec.h
@@ -59,6 +59,7 @@ struct _GstVorbisDec {
vorbis_block vb;
gboolean initialized;
+ guint width;
/* list of buffers that need timestamps */
GList *queued;