summaryrefslogtreecommitdiff
path: root/ext/opus/gstopusdec.c
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-03-23 11:57:09 +0100
committerSebastian Dröge <sebastian@centricular.com>2015-03-23 11:57:09 +0100
commitbb5b0f2d127b14f8d80c6df041ea37e6fd1f0475 (patch)
tree0be0064b36bd40558cd74f4a9825c21f6795dbe0 /ext/opus/gstopusdec.c
parent716eaf765b1251bdddb8eb6c3a9ecc87967123a8 (diff)
downloadgstreamer-plugins-bad-bb5b0f2d127b14f8d80c6df041ea37e6fd1f0475.tar.gz
opusdec: Take output sample rate from the stream headers too
This way we let opusdec do the resampling if needed and don't carry around buffers with a too high sample rate if not required. While Opus always uses 48kHz internally, this information from the header specifies which frequencies are safe to drop.
Diffstat (limited to 'ext/opus/gstopusdec.c')
-rw-r--r--ext/opus/gstopusdec.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/ext/opus/gstopusdec.c b/ext/opus/gstopusdec.c
index cfa711a18..2b7bcb283 100644
--- a/ext/opus/gstopusdec.c
+++ b/ext/opus/gstopusdec.c
@@ -224,13 +224,11 @@ gst_opus_dec_negotiate (GstOpusDec * dec, const GstAudioChannelPosition * pos)
caps = gst_caps_truncate (caps);
caps = gst_caps_make_writable (caps);
s = gst_caps_get_structure (caps, 0);
- gst_structure_fixate_field_nearest_int (s, "rate", 48000);
+ gst_structure_fixate_field_nearest_int (s, "rate", dec->sample_rate);
gst_structure_get_int (s, "rate", &dec->sample_rate);
gst_structure_fixate_field_nearest_int (s, "channels", dec->n_channels);
gst_structure_get_int (s, "channels", &dec->n_channels);
gst_caps_unref (caps);
- } else {
- dec->sample_rate = 48000;
}
GST_INFO_OBJECT (dec, "Negotiated %d channels, %d Hz", dec->n_channels,
@@ -282,6 +280,7 @@ gst_opus_dec_parse_header (GstOpusDec * dec, GstBuffer * buf)
}
dec->n_channels = data[9];
+ dec->sample_rate = GST_READ_UINT32_LE (data + 12);
dec->pre_skip = GST_READ_UINT16_LE (data + 10);
dec->r128_gain = GST_READ_UINT16_LE (data + 16);
dec->r128_gain_volume = gst_opus_dec_get_r128_volume (dec->r128_gain);