From: Sebastian Dröge Date: Wed, 4 Jan 2012 15:05:59 +0000 (+0100) Subject: a52dec: Update for the new raw audio caps X-Git-Tag: 1.19.3~505^2~884 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=882aaf0de2a15b950588d59c8e123d6f77155a0e;p=platform%2Fupstream%2Fgstreamer.git a52dec: Update for the new raw audio caps --- diff --git a/ext/a52dec/gsta52dec.c b/ext/a52dec/gsta52dec.c index 64ddb09..558eb9b 100644 --- a/ext/a52dec/gsta52dec.c +++ b/ext/a52dec/gsta52dec.c @@ -43,7 +43,6 @@ #include "_stdint.h" #include -#include #include #include @@ -84,6 +83,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw, " "format = (string) " SAMPLE_FORMAT ", " + "layout = (string) interleaved, " "rate = (int) [ 4000, 96000 ], " "channels = (int) [ 1, 6 ]") ); @@ -231,21 +231,14 @@ gst_a52dec_init (GstA52Dec * a52dec) } static gint -gst_a52dec_channels (int flags, GstAudioChannelPosition ** _pos) +gst_a52dec_channels (int flags, GstAudioChannelPosition * pos) { gint chans = 0; - GstAudioChannelPosition *pos = NULL; - - /* allocated just for safety. Number makes no sense */ - if (_pos) { - pos = g_new (GstAudioChannelPosition, 6); - *_pos = pos; - } if (flags & A52_LFE) { chans += 1; if (pos) { - pos[0] = GST_AUDIO_CHANNEL_POSITION_LFE; + pos[0] = GST_AUDIO_CHANNEL_POSITION_LFE1; } } flags &= A52_CHANNEL_MASK; @@ -305,13 +298,12 @@ gst_a52dec_channels (int flags, GstAudioChannelPosition ** _pos) break; case A52_MONO: if (pos) { - pos[0 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO; + pos[0 + chans] = GST_AUDIO_CHANNEL_POSITION_MONO; } chans += 1; break; default: /* error, caller should post error message */ - g_free (pos); return 0; } @@ -381,6 +373,9 @@ gst_a52dec_push (GstA52Dec * a52dec, data[n * chans + c] = samples[c * 256 + n]; } } + gst_audio_reorder_channels (data, 256 * chans * (SAMPLE_WIDTH / 8), + (SAMPLE_WIDTH == 64) ? GST_AUDIO_FORMAT_F64 : GST_AUDIO_FORMAT_F32, chans, + a52dec->from, a52dec->to); gst_buffer_unmap (buf, data, -1); GST_BUFFER_TIMESTAMP (buf) = timestamp; @@ -423,23 +418,36 @@ no_channels: static gboolean gst_a52dec_reneg (GstA52Dec * a52dec, GstPad * pad) { - GstAudioChannelPosition *pos; - gint channels = gst_a52dec_channels (a52dec->using_channels, &pos); + gint channels; GstCaps *caps = NULL; gboolean result = FALSE; + channels = gst_a52dec_channels (a52dec->using_channels, a52dec->from); + if (!channels) goto done; GST_INFO_OBJECT (a52dec, "reneg channels:%d rate:%d", channels, a52dec->sample_rate); + memcpy (a52dec->to, a52dec->from, sizeof (a52dec->from)); + gst_audio_channel_positions_to_valid_order (a52dec->to, channels); + caps = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, SAMPLE_FORMAT, + "layout", G_TYPE_STRING, "interleaved", "channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, a52dec->sample_rate, NULL); - gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos); - g_free (pos); + + if (channels > 1) { + guint64 channel_mask = 0; + gint i; + + for (i = 0; i < channels; i++) + channel_mask |= G_GUINT64_CONSTANT (1) << a52dec->to[i]; + gst_caps_set_simple (caps, "channel-mask", GST_TYPE_BITMASK, channel_mask, + NULL); + } if (!gst_pad_set_caps (pad, caps)) goto done; @@ -977,10 +985,6 @@ plugin_init (GstPlugin * plugin) orc_init (); #endif - /* ensure GstAudioChannelPosition type is registered */ - if (!gst_audio_channel_position_get_type ()) - return FALSE; - if (!gst_element_register (plugin, "a52dec", GST_RANK_SECONDARY, GST_TYPE_A52DEC)) return FALSE; diff --git a/ext/a52dec/gsta52dec.h b/ext/a52dec/gsta52dec.h index e575b81..4508a82 100644 --- a/ext/a52dec/gsta52dec.h +++ b/ext/a52dec/gsta52dec.h @@ -22,6 +22,7 @@ #define __GST_A52DEC_H__ #include +#include G_BEGIN_DECLS @@ -60,6 +61,8 @@ struct _GstA52Dec { int request_channels; int using_channels; + GstAudioChannelPosition from[6], to[6]; + sample_t level; sample_t bias; gboolean dynamic_range_compression;