ext/vorbis/: Add sane defaults for the 7 and 8 channel layouts as those are undefined in the Vorbis spec. Use NONE ch...

Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (vorbis_handle_identification_packet):
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_generate_sink_caps):
Add sane defaults for the 7 and 8 channel layouts as those are
undefined in the Vorbis spec. Use NONE channel layouts when decoding
more than 8 channels instead of erroring out. Fixes bug #535356.
This commit is contained in:
Sebastian Dröge 2008-05-29 07:02:50 +00:00
parent 1a3053b241
commit 31b677599a
3 changed files with 78 additions and 13 deletions

View file

@ -1,3 +1,11 @@
2008-05-29 Sebastian Dröge <slomo@circular-chaos.org>
* ext/vorbis/vorbisdec.c: (vorbis_handle_identification_packet):
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_generate_sink_caps):
Add sane defaults for the 7 and 8 channel layouts as those are
undefined in the Vorbis spec. Use NONE channel layouts when decoding
more than 8 channels instead of erroring out. Fixes bug #535356.
2008-05-28 Wim Taymans <wim.taymans@collabora.co.uk>
* docs/plugins/Makefile.am:

View file

@ -618,8 +618,49 @@ vorbis_handle_identification_packet (GstVorbisDec * vd)
pos = pos6;
break;
}
default:
goto channel_count_error;
/* FIXME: for >6 channels the layout is not defined by the Vorbis
* spec. These are the gstreamer "defaults" for 7/8 channels and
* NONE layouts for more channels
*/
case 7:{
static const GstAudioChannelPosition pos7[] = {
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
GST_AUDIO_CHANNEL_POSITION_LFE,
GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
};
pos = pos7;
}
case 8:{
static const GstAudioChannelPosition pos8[] = {
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
GST_AUDIO_CHANNEL_POSITION_LFE,
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
};
pos = pos8;
}
default:{
gint i;
GstAudioChannelPosition *posn =
g_new (GstAudioChannelPosition, vd->vi.channels);
GST_ELEMENT_WARNING (GST_ELEMENT (vd), STREAM, DECODE,
(NULL), ("Using NONE channel layout for more than 8 channels"));
for (i = 0; i < vd->vi.channels; i++)
posn[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
pos = posn;
}
}
caps = gst_caps_new_simple ("audio/x-raw-float",
@ -630,18 +671,15 @@ vorbis_handle_identification_packet (GstVorbisDec * vd)
if (pos) {
gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
}
if (vd->vi.channels > 8) {
g_free ((GstAudioChannelPosition *) pos);
}
gst_pad_set_caps (vd->srcpad, caps);
gst_caps_unref (caps);
return GST_FLOW_OK;
/* ERROR */
channel_count_error:
{
GST_ELEMENT_ERROR (vd, STREAM, NOT_IMPLEMENTED, (NULL),
("Unsupported channel count %d", vd->vi.channels));
return GST_FLOW_ERROR;
}
}
static GstFlowReturn

View file

@ -241,7 +241,7 @@ gst_vorbis_enc_dispose (GObject * object)
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static const GstAudioChannelPosition vorbischannelpositions[][6] = {
static const GstAudioChannelPosition vorbischannelpositions[][8] = {
{ /* Mono */
GST_AUDIO_CHANNEL_POSITION_FRONT_MONO},
{ /* Stereo */
@ -272,6 +272,25 @@ static const GstAudioChannelPosition vorbischannelpositions[][6] = {
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
GST_AUDIO_CHANNEL_POSITION_LFE,
},
{ /* Not defined by spec, GStreamer default */
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
GST_AUDIO_CHANNEL_POSITION_LFE,
GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
},
{ /* Not defined by spec, GStreamer default */
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
GST_AUDIO_CHANNEL_POSITION_LFE,
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
},
};
static GstCaps *
gst_vorbis_enc_generate_sink_caps (void)
@ -291,7 +310,7 @@ gst_vorbis_enc_generate_sink_caps (void)
"endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32,
NULL));
for (i = 3; i <= 6; i++) {
for (i = 3; i <= 8; i++) {
GValue chanpos = { 0 };
GValue pos = { 0 };
GstStructure *structure;
@ -317,7 +336,7 @@ gst_vorbis_enc_generate_sink_caps (void)
gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw-float",
"rate", GST_TYPE_INT_RANGE, 1, 200000,
"channels", GST_TYPE_INT_RANGE, 7, 256,
"channels", GST_TYPE_INT_RANGE, 9, 256,
"endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32,
NULL));