mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 23:28:16 +00:00
opusparse: do not drop preskip and gain from OpusHead header
https://bugzilla.gnome.org/show_bug.cgi?id=753275
This commit is contained in:
parent
c91689db2a
commit
413406d28a
1 changed files with 33 additions and 42 deletions
|
@ -366,54 +366,45 @@ gst_opus_parse_parse_frame (GstBaseParse * base, GstBaseParseFrame * frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(frame->flags & GST_BASE_PARSE_FRAME_FLAG_QUEUE)) {
|
if (!(frame->flags & GST_BASE_PARSE_FRAME_FLAG_QUEUE)) {
|
||||||
if (FALSE && parse->id_header && parse->comment_header) {
|
GstCaps *sink_caps;
|
||||||
guint16 pre_skip;
|
guint32 sample_rate = 48000;
|
||||||
|
guint8 n_channels, n_streams, n_stereo_streams, channel_mapping_family;
|
||||||
|
guint8 channel_mapping[256];
|
||||||
|
GstBuffer *id_header;
|
||||||
|
guint16 pre_skip = 0;
|
||||||
|
gint16 gain = 0;
|
||||||
|
|
||||||
|
if (parse->id_header) {
|
||||||
gst_buffer_map (parse->id_header, &map, GST_MAP_READWRITE);
|
gst_buffer_map (parse->id_header, &map, GST_MAP_READWRITE);
|
||||||
pre_skip = GST_READ_UINT16_LE (map.data + 10);
|
pre_skip = GST_READ_UINT16_LE (map.data + 10);
|
||||||
if (pre_skip != parse->pre_skip) {
|
gain = GST_READ_UINT16_LE (map.data + 16);
|
||||||
GST_DEBUG_OBJECT (parse,
|
|
||||||
"Fixing up pre-skip %u -> %" G_GUINT64_FORMAT, pre_skip,
|
|
||||||
parse->pre_skip);
|
|
||||||
GST_WRITE_UINT16_LE (map.data + 10, parse->pre_skip);
|
|
||||||
}
|
|
||||||
gst_buffer_unmap (parse->id_header, &map);
|
gst_buffer_unmap (parse->id_header, &map);
|
||||||
|
|
||||||
caps =
|
|
||||||
gst_codec_utils_opus_create_caps_from_header (parse->id_header,
|
|
||||||
parse->comment_header);
|
|
||||||
} else {
|
|
||||||
GstCaps *sink_caps;
|
|
||||||
guint32 sample_rate = 48000;
|
|
||||||
guint8 n_channels, n_streams, n_stereo_streams, channel_mapping_family;
|
|
||||||
guint8 channel_mapping[256];
|
|
||||||
GstBuffer *id_header;
|
|
||||||
|
|
||||||
sink_caps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (parse));
|
|
||||||
if (!sink_caps
|
|
||||||
|| !gst_codec_utils_opus_parse_caps (sink_caps, &sample_rate,
|
|
||||||
&n_channels, &channel_mapping_family, &n_streams,
|
|
||||||
&n_stereo_streams, channel_mapping)) {
|
|
||||||
GST_INFO_OBJECT (parse,
|
|
||||||
"No headers and no caps, blindly setting up canonical stereo");
|
|
||||||
n_channels = 2;
|
|
||||||
n_streams = 1;
|
|
||||||
n_stereo_streams = 1;
|
|
||||||
channel_mapping_family = 0;
|
|
||||||
channel_mapping[0] = 0;
|
|
||||||
channel_mapping[1] = 1;
|
|
||||||
}
|
|
||||||
if (sink_caps)
|
|
||||||
gst_caps_unref (sink_caps);
|
|
||||||
|
|
||||||
id_header =
|
|
||||||
gst_codec_utils_opus_create_header (sample_rate, n_channels,
|
|
||||||
channel_mapping_family, n_streams, n_stereo_streams,
|
|
||||||
channel_mapping, parse->pre_skip, 0);
|
|
||||||
caps = gst_codec_utils_opus_create_caps_from_header (id_header, NULL);
|
|
||||||
gst_buffer_unref (id_header);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sink_caps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (parse));
|
||||||
|
if (!sink_caps
|
||||||
|
|| !gst_codec_utils_opus_parse_caps (sink_caps, &sample_rate,
|
||||||
|
&n_channels, &channel_mapping_family, &n_streams,
|
||||||
|
&n_stereo_streams, channel_mapping)) {
|
||||||
|
GST_INFO_OBJECT (parse,
|
||||||
|
"No headers and no caps, blindly setting up canonical stereo");
|
||||||
|
n_channels = 2;
|
||||||
|
n_streams = 1;
|
||||||
|
n_stereo_streams = 1;
|
||||||
|
channel_mapping_family = 0;
|
||||||
|
channel_mapping[0] = 0;
|
||||||
|
channel_mapping[1] = 1;
|
||||||
|
}
|
||||||
|
if (sink_caps)
|
||||||
|
gst_caps_unref (sink_caps);
|
||||||
|
|
||||||
|
id_header =
|
||||||
|
gst_codec_utils_opus_create_header (sample_rate, n_channels,
|
||||||
|
channel_mapping_family, n_streams, n_stereo_streams,
|
||||||
|
channel_mapping, pre_skip, gain);
|
||||||
|
caps = gst_codec_utils_opus_create_caps_from_header (id_header, NULL);
|
||||||
|
gst_buffer_unref (id_header);
|
||||||
|
|
||||||
gst_buffer_replace (&parse->id_header, NULL);
|
gst_buffer_replace (&parse->id_header, NULL);
|
||||||
gst_buffer_replace (&parse->comment_header, NULL);
|
gst_buffer_replace (&parse->comment_header, NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue