mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-04 06:29:31 +00:00
opusdec: handle NULL packets (used for PLC)
This commit is contained in:
parent
de87d061fc
commit
a6ca3673b4
1 changed files with 13 additions and 7 deletions
|
@ -244,12 +244,19 @@ opus_dec_chain_parse_data (GstOpusDec * dec, GstBuffer * buf)
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data) {
|
||||||
samples =
|
samples =
|
||||||
opus_packet_get_samples_per_frame (data,
|
opus_packet_get_samples_per_frame (data,
|
||||||
dec->sample_rate) * opus_packet_get_nb_frames (data, size);
|
dec->sample_rate) * opus_packet_get_nb_frames (data, size);
|
||||||
packet_size = samples * dec->n_channels * 2;
|
packet_size = samples * dec->n_channels * 2;
|
||||||
GST_DEBUG_OBJECT (dec, "bandwidth %d", opus_packet_get_bandwidth (data));
|
GST_DEBUG_OBJECT (dec, "bandwidth %d", opus_packet_get_bandwidth (data));
|
||||||
GST_DEBUG_OBJECT (dec, "samples %d", samples);
|
GST_DEBUG_OBJECT (dec, "samples %d", samples);
|
||||||
|
} else {
|
||||||
|
/* use maximum size (120 ms) as we do now know in advance how many samples
|
||||||
|
will be returned */
|
||||||
|
samples = 120 * dec->sample_rate / 1000;
|
||||||
|
}
|
||||||
|
packet_size = samples * dec->n_channels * 2;
|
||||||
|
|
||||||
res = gst_pad_alloc_buffer_and_set_caps (GST_AUDIO_DECODER_SRC_PAD (dec),
|
res = gst_pad_alloc_buffer_and_set_caps (GST_AUDIO_DECODER_SRC_PAD (dec),
|
||||||
GST_BUFFER_OFFSET_NONE, packet_size,
|
GST_BUFFER_OFFSET_NONE, packet_size,
|
||||||
|
@ -262,14 +269,13 @@ opus_dec_chain_parse_data (GstOpusDec * dec, GstBuffer * buf)
|
||||||
|
|
||||||
out_data = (gint16 *) GST_BUFFER_DATA (outbuf);
|
out_data = (gint16 *) GST_BUFFER_DATA (outbuf);
|
||||||
|
|
||||||
GST_LOG_OBJECT (dec, "decoding %d samples, in size %u", samples, size);
|
|
||||||
|
|
||||||
n = opus_decode (dec->state, data, size, out_data, samples, 0);
|
n = opus_decode (dec->state, data, size, out_data, samples, 0);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
GST_ELEMENT_ERROR (dec, STREAM, DECODE, ("Decoding error: %d", n), (NULL));
|
GST_ELEMENT_ERROR (dec, STREAM, DECODE, ("Decoding error: %d", n), (NULL));
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
GST_DEBUG_OBJECT (dec, "decoded %d samples", n);
|
GST_DEBUG_OBJECT (dec, "decoded %d samples", n);
|
||||||
|
GST_BUFFER_SIZE (outbuf) = n * 2 * dec->n_channels;
|
||||||
|
|
||||||
res = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (dec), outbuf, 1);
|
res = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (dec), outbuf, 1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue