mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 16:08:51 +00:00
opusdec: read pre-skip from first header if available
This commit is contained in:
parent
fbfc870343
commit
1e81bc4b64
2 changed files with 13 additions and 0 deletions
|
@ -77,6 +77,8 @@ static GstFlowReturn gst_opus_dec_handle_frame (GstAudioDecoder * dec,
|
||||||
GstBuffer * buffer);
|
GstBuffer * buffer);
|
||||||
static gboolean gst_opus_dec_set_format (GstAudioDecoder * bdec,
|
static gboolean gst_opus_dec_set_format (GstAudioDecoder * bdec,
|
||||||
GstCaps * caps);
|
GstCaps * caps);
|
||||||
|
static gboolean gst_opus_dec_is_header (GstBuffer * buf, const char *magic,
|
||||||
|
guint magic_size);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_opus_dec_base_init (gpointer g_class)
|
gst_opus_dec_base_init (gpointer g_class)
|
||||||
|
@ -122,6 +124,8 @@ gst_opus_dec_reset (GstOpusDec * dec)
|
||||||
|
|
||||||
gst_buffer_replace (&dec->streamheader, NULL);
|
gst_buffer_replace (&dec->streamheader, NULL);
|
||||||
gst_buffer_replace (&dec->vorbiscomment, NULL);
|
gst_buffer_replace (&dec->vorbiscomment, NULL);
|
||||||
|
|
||||||
|
dec->pre_skip = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -159,9 +163,17 @@ gst_opus_dec_stop (GstAudioDecoder * dec)
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_opus_dec_parse_header (GstOpusDec * dec, GstBuffer * buf)
|
gst_opus_dec_parse_header (GstOpusDec * dec, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
|
g_return_val_if_fail (gst_opus_dec_is_header (buf, "OpusHead", 8),
|
||||||
|
GST_FLOW_ERROR);
|
||||||
|
g_return_val_if_fail (GST_BUFFER_SIZE (buf) >= 19, GST_FLOW_ERROR);
|
||||||
|
|
||||||
|
dec->pre_skip = GST_READ_UINT16_LE (GST_BUFFER_DATA (buf) + 10);
|
||||||
|
GST_DEBUG_OBJECT (dec, "Found pre-skip of %u samples", dec->pre_skip);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_opus_dec_parse_comments (GstOpusDec * dec, GstBuffer * buf)
|
gst_opus_dec_parse_comments (GstOpusDec * dec, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,6 +53,7 @@ struct _GstOpusDec {
|
||||||
|
|
||||||
int sample_rate;
|
int sample_rate;
|
||||||
int n_channels;
|
int n_channels;
|
||||||
|
guint32 pre_skip;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstOpusDecClass {
|
struct _GstOpusDecClass {
|
||||||
|
|
Loading…
Reference in a new issue