Merge remote-tracking branch 'origin/master' into 0.11

Conflicts:
	ext/opus/gstopusdec.c
	ext/opus/gstopusparse.c
	gst-libs/gst/video/gstbasevideodecoder.c
	gst-libs/gst/video/gstbasevideodecoder.h
This commit is contained in:
Tim-Philipp Müller 2011-11-26 15:37:25 +00:00
commit 619915ea74
5 changed files with 34 additions and 11 deletions

View file

@ -70,3 +70,19 @@ const GstAudioChannelPosition gst_opus_channel_positions[][8] = {
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
GST_AUDIO_CHANNEL_POSITION_LFE}, GST_AUDIO_CHANNEL_POSITION_LFE},
}; };
const char *gst_opus_channel_names[] = {
"mono",
"front left",
"front right",
"rear center",
"rear left",
"rear right",
"lfe",
"front center",
"front left of center",
"front right of center",
"side left",
"side right",
"none"
};

View file

@ -27,6 +27,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
extern const GstAudioChannelPosition gst_opus_channel_positions[][8]; extern const GstAudioChannelPosition gst_opus_channel_positions[][8];
extern const char *gst_opus_channel_names[];
G_END_DECLS G_END_DECLS

View file

@ -219,7 +219,8 @@ gst_opus_dec_parse_header (GstOpusDec * dec, GstBuffer * buf)
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ); data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
g_return_val_if_fail (dec->n_channels != data[9], GST_FLOW_ERROR); g_return_val_if_fail (dec->n_channels == 0
|| dec->n_channels == data[9], GST_FLOW_ERROR);
dec->n_channels = data[9]; dec->n_channels = data[9];
dec->pre_skip = GST_READ_UINT16_LE (data + 10); dec->pre_skip = GST_READ_UINT16_LE (data + 10);
@ -288,6 +289,7 @@ gst_opus_dec_parse_header (GstOpusDec * dec, GstBuffer * buf)
dec->sample_rate); dec->sample_rate);
if (pos) { if (pos) {
GST_DEBUG_OBJECT (dec, "Setting channel positions on caps");
gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos); gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
} }

View file

@ -187,11 +187,9 @@ static void
gst_opus_enc_class_init (GstOpusEncClass * klass) gst_opus_enc_class_init (GstOpusEncClass * klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstAudioEncoderClass *base_class; GstAudioEncoderClass *base_class;
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
base_class = (GstAudioEncoderClass *) klass; base_class = (GstAudioEncoderClass *) klass;
gobject_class->set_property = gst_opus_enc_set_property; gobject_class->set_property = gst_opus_enc_set_property;
@ -446,7 +444,8 @@ gst_opus_enc_setup_channel_mapping (GstOpusEnc * enc, const GstAudioInfo * info)
GstAudioChannelPosition pos = GST_AUDIO_INFO_POSITION (info, n); GstAudioChannelPosition pos = GST_AUDIO_INFO_POSITION (info, n);
int c; int c;
GST_DEBUG_OBJECT (enc, "Channel %d has position %d", n, pos); GST_DEBUG_OBJECT (enc, "Channel %d has position %d (%s)", n, pos,
gst_opus_channel_names[pos]);
for (c = 0; c < enc->n_channels; ++c) { for (c = 0; c < enc->n_channels; ++c) {
if (gst_opus_channel_positions[enc->n_channels - 1][c] == pos) { if (gst_opus_channel_positions[enc->n_channels - 1][c] == pos) {
GST_DEBUG_OBJECT (enc, "Found in Vorbis mapping as channel %d", c); GST_DEBUG_OBJECT (enc, "Found in Vorbis mapping as channel %d", c);
@ -456,12 +455,13 @@ gst_opus_enc_setup_channel_mapping (GstOpusEnc * enc, const GstAudioInfo * info)
if (c == enc->n_channels) { if (c == enc->n_channels) {
/* We did not find that position, so use undefined */ /* We did not find that position, so use undefined */
GST_WARNING_OBJECT (enc, GST_WARNING_OBJECT (enc,
"Position %d not found in Vorbis mapping, using unknown mapping", "Position %d (%s) not found in Vorbis mapping, using unknown mapping",
pos); pos, gst_opus_channel_positions[pos]);
enc->channel_mapping_family = 255; enc->channel_mapping_family = 255;
return; return;
} }
GST_DEBUG_OBJECT (enc, "Mapping output channel %d to %d", c, n); GST_DEBUG_OBJECT (enc, "Mapping output channel %d to %d (%s)", c, n,
gst_opus_channel_names[pos]);
enc->channel_mapping[c] = n; enc->channel_mapping[c] = n;
} }
GST_INFO_OBJECT (enc, "Permutation found, using Vorbis mapping"); GST_INFO_OBJECT (enc, "Permutation found, using Vorbis mapping");
@ -512,13 +512,17 @@ gst_opus_enc_set_format (GstAudioEncoder * benc, GstAudioInfo * info)
static gboolean static gboolean
gst_opus_enc_setup (GstOpusEnc * enc) gst_opus_enc_setup (GstOpusEnc * enc)
{ {
int error = OPUS_OK; int error = OPUS_OK, n;
guint8 trivial_mapping[256];
GST_DEBUG_OBJECT (enc, "setup"); GST_DEBUG_OBJECT (enc, "setup");
for (n = 0; n < 256; ++n)
trivial_mapping[n] = n;
enc->state = enc->state =
opus_multistream_encoder_create (enc->sample_rate, enc->n_channels, opus_multistream_encoder_create (enc->sample_rate, enc->n_channels,
(enc->n_channels + 1) / 2, enc->n_channels / 2, enc->channel_mapping, enc->n_channels, 0, trivial_mapping,
enc->audio_or_voip ? OPUS_APPLICATION_AUDIO : OPUS_APPLICATION_VOIP, enc->audio_or_voip ? OPUS_APPLICATION_AUDIO : OPUS_APPLICATION_VOIP,
&error); &error);
if (!enc->state || error != OPUS_OK) if (!enc->state || error != OPUS_OK)

View file

@ -44,8 +44,8 @@ gst_opus_enc_create_id_buffer (gint nchannels, gint sample_rate,
gst_byte_writer_put_uint16_le (&bw, 0); /* output gain */ gst_byte_writer_put_uint16_le (&bw, 0); /* output gain */
gst_byte_writer_put_uint8 (&bw, channel_mapping_family); gst_byte_writer_put_uint8 (&bw, channel_mapping_family);
if (channel_mapping_family > 0) { if (channel_mapping_family > 0) {
gst_byte_writer_put_uint8 (&bw, (nchannels + 1) / 2); gst_byte_writer_put_uint8 (&bw, nchannels);
gst_byte_writer_put_uint8 (&bw, nchannels / 2); gst_byte_writer_put_uint8 (&bw, 0);
gst_byte_writer_put_data (&bw, channel_mapping, nchannels); gst_byte_writer_put_data (&bw, channel_mapping, nchannels);
} }