mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
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.
This commit is contained in:
parent
716eaf765b
commit
bb5b0f2d12
1 changed files with 2 additions and 3 deletions
|
@ -224,13 +224,11 @@ gst_opus_dec_negotiate (GstOpusDec * dec, const GstAudioChannelPosition * pos)
|
||||||
caps = gst_caps_truncate (caps);
|
caps = gst_caps_truncate (caps);
|
||||||
caps = gst_caps_make_writable (caps);
|
caps = gst_caps_make_writable (caps);
|
||||||
s = gst_caps_get_structure (caps, 0);
|
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_get_int (s, "rate", &dec->sample_rate);
|
||||||
gst_structure_fixate_field_nearest_int (s, "channels", dec->n_channels);
|
gst_structure_fixate_field_nearest_int (s, "channels", dec->n_channels);
|
||||||
gst_structure_get_int (s, "channels", &dec->n_channels);
|
gst_structure_get_int (s, "channels", &dec->n_channels);
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
} else {
|
|
||||||
dec->sample_rate = 48000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_INFO_OBJECT (dec, "Negotiated %d channels, %d Hz", dec->n_channels,
|
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->n_channels = data[9];
|
||||||
|
dec->sample_rate = GST_READ_UINT32_LE (data + 12);
|
||||||
dec->pre_skip = GST_READ_UINT16_LE (data + 10);
|
dec->pre_skip = GST_READ_UINT16_LE (data + 10);
|
||||||
dec->r128_gain = GST_READ_UINT16_LE (data + 16);
|
dec->r128_gain = GST_READ_UINT16_LE (data + 16);
|
||||||
dec->r128_gain_volume = gst_opus_dec_get_r128_volume (dec->r128_gain);
|
dec->r128_gain_volume = gst_opus_dec_get_r128_volume (dec->r128_gain);
|
||||||
|
|
Loading…
Reference in a new issue