mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-20 06:08:14 +00:00
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:
commit
619915ea74
5 changed files with 34 additions and 11 deletions
|
@ -70,3 +70,19 @@ const GstAudioChannelPosition gst_opus_channel_positions[][8] = {
|
|||
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
||||
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"
|
||||
};
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
extern const GstAudioChannelPosition gst_opus_channel_positions[][8];
|
||||
extern const char *gst_opus_channel_names[];
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -219,7 +219,8 @@ gst_opus_dec_parse_header (GstOpusDec * dec, GstBuffer * buf)
|
|||
|
||||
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->pre_skip = GST_READ_UINT16_LE (data + 10);
|
||||
|
@ -288,6 +289,7 @@ gst_opus_dec_parse_header (GstOpusDec * dec, GstBuffer * buf)
|
|||
dec->sample_rate);
|
||||
|
||||
if (pos) {
|
||||
GST_DEBUG_OBJECT (dec, "Setting channel positions on caps");
|
||||
gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
|
||||
}
|
||||
|
||||
|
|
|
@ -187,11 +187,9 @@ static void
|
|||
gst_opus_enc_class_init (GstOpusEncClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstAudioEncoderClass *base_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstelement_class = (GstElementClass *) klass;
|
||||
base_class = (GstAudioEncoderClass *) klass;
|
||||
|
||||
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);
|
||||
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) {
|
||||
if (gst_opus_channel_positions[enc->n_channels - 1][c] == pos) {
|
||||
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) {
|
||||
/* We did not find that position, so use undefined */
|
||||
GST_WARNING_OBJECT (enc,
|
||||
"Position %d not found in Vorbis mapping, using unknown mapping",
|
||||
pos);
|
||||
"Position %d (%s) not found in Vorbis mapping, using unknown mapping",
|
||||
pos, gst_opus_channel_positions[pos]);
|
||||
enc->channel_mapping_family = 255;
|
||||
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;
|
||||
}
|
||||
GST_INFO_OBJECT (enc, "Permutation found, using Vorbis mapping");
|
||||
|
@ -512,13 +512,17 @@ gst_opus_enc_set_format (GstAudioEncoder * benc, GstAudioInfo * info)
|
|||
static gboolean
|
||||
gst_opus_enc_setup (GstOpusEnc * enc)
|
||||
{
|
||||
int error = OPUS_OK;
|
||||
int error = OPUS_OK, n;
|
||||
guint8 trivial_mapping[256];
|
||||
|
||||
GST_DEBUG_OBJECT (enc, "setup");
|
||||
|
||||
for (n = 0; n < 256; ++n)
|
||||
trivial_mapping[n] = n;
|
||||
|
||||
enc->state =
|
||||
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,
|
||||
&error);
|
||||
if (!enc->state || error != OPUS_OK)
|
||||
|
|
|
@ -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_uint8 (&bw, channel_mapping_family);
|
||||
if (channel_mapping_family > 0) {
|
||||
gst_byte_writer_put_uint8 (&bw, (nchannels + 1) / 2);
|
||||
gst_byte_writer_put_uint8 (&bw, nchannels / 2);
|
||||
gst_byte_writer_put_uint8 (&bw, nchannels);
|
||||
gst_byte_writer_put_uint8 (&bw, 0);
|
||||
gst_byte_writer_put_data (&bw, channel_mapping, nchannels);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue