summaryrefslogtreecommitdiffstats
path: root/ext/dts
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>2004-11-25 20:36:29 +0000
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>2004-11-25 20:36:29 +0000
commitbf45760b330d18dfde219b5601d2efbf4e88d8bf (patch)
tree8a75526a9653b9235c073502afd34c7f6f520c67 /ext/dts
parentaf874a090dde36541bcba5ca204be1052ccf4c71 (diff)
downloadgst-plugins-bad-bf45760b330d18dfde219b5601d2efbf4e88d8bf.tar.gz
gst-plugins-bad-bf45760b330d18dfde219b5601d2efbf4e88d8bf.tar.bz2
gst-plugins-bad-bf45760b330d18dfde219b5601d2efbf4e88d8bf.zip
Surround sound support.
Original commit message from CVS: * ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push), (gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init): * ext/alsa/gstalsa.c: (gst_alsa_get_caps): * ext/alsa/gstalsaplugin.c: (plugin_init): * ext/dts/gstdtsdec.c: (gst_dtsdec_channels), (gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init): * ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst), (gst_faad_chanpos_to_gst), (gst_faad_sinkconnect), (gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain), (gst_faad_change_state), (plugin_init): * ext/faad/gstfaad.h: * ext/vorbis/vorbis.c: (plugin_init): * ext/vorbis/vorbisdec.c: (vorbis_dec_chain): * gst-libs/gst/audio/Makefile.am: * gst-libs/gst/audio/audio.c: (plugin_init): * gst-libs/gst/audio/multichannel.c: (gst_audio_check_channel_positions), (gst_audio_get_channel_positions), (gst_audio_set_channel_positions), (gst_audio_set_structure_channel_positions_list), (add_list_to_struct), (gst_audio_set_caps_channel_positions_list), (gst_audio_fixate_channel_positions): * gst-libs/gst/audio/multichannel.h: * gst-libs/gst/audio/testchannels.c: (main): * gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_class_init), (gst_audio_convert_init), (gst_audio_convert_dispose), (gst_audio_convert_getcaps), (gst_audio_convert_parse_caps), (gst_audio_convert_link), (gst_audio_convert_fixate), (gst_audio_convert_channels): * gst/audioconvert/plugin.c: (plugin_init): Surround sound support.
Diffstat (limited to 'ext/dts')
-rw-r--r--ext/dts/gstdtsdec.c80
1 files changed, 74 insertions, 6 deletions
diff --git a/ext/dts/gstdtsdec.c b/ext/dts/gstdtsdec.c
index db4bd7de..edcc8bcc 100644
--- a/ext/dts/gstdtsdec.c
+++ b/ext/dts/gstdtsdec.c
@@ -26,6 +26,8 @@
#include <stdlib.h>
#include <gst/gst.h>
+#include <gst/audio/multichannel.h>
+
#include <dts.h>
#include "gstdtsdec.h"
@@ -180,42 +182,102 @@ gst_dtsdec_init (GstDtsDec * dtsdec)
}
static gint
-gst_dtsdec_channels (uint32_t flags)
+gst_dtsdec_channels (uint32_t flags, GstAudioChannelPosition ** pos)
{
gint chans = 0;
switch (flags & DTS_CHANNEL_MASK) {
case DTS_MONO:
chans = 1;
+ if (pos) {
+ *pos = g_new (GstAudioChannelPosition, 2);
+ *pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO;
+ }
break;
- case DTS_CHANNEL:
+ /* case DTS_CHANNEL: */
case DTS_STEREO:
case DTS_STEREO_SUMDIFF:
case DTS_STEREO_TOTAL:
case DTS_DOLBY:
chans = 2;
+ if (pos) {
+ *pos = g_new (GstAudioChannelPosition, 3);
+ *pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+ *pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+ }
break;
case DTS_3F:
+ chans = 3;
+ if (pos) {
+ *pos = g_new (GstAudioChannelPosition, 4);
+ *pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER;
+ *pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+ *pos[2] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+ }
+ break;
case DTS_2F1R:
chans = 3;
+ if (pos) {
+ *pos = g_new (GstAudioChannelPosition, 4);
+ *pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+ *pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+ *pos[2] = GST_AUDIO_CHANNEL_POSITION_REAR_CENTER;
+ }
break;
case DTS_3F1R:
+ chans = 4;
+ if (pos) {
+ *pos = g_new (GstAudioChannelPosition, 5);
+ *pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER;
+ *pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+ *pos[2] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+ *pos[3] = GST_AUDIO_CHANNEL_POSITION_REAR_CENTER;
+ }
+ break;
case DTS_2F2R:
chans = 4;
+ if (pos) {
+ *pos = g_new (GstAudioChannelPosition, 5);
+ *pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+ *pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+ *pos[2] = GST_AUDIO_CHANNEL_POSITION_REAR_LEFT;
+ *pos[3] = GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT;
+ }
break;
case DTS_3F2R:
chans = 5;
+ if (pos) {
+ *pos = g_new (GstAudioChannelPosition, 6);
+ *pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER;
+ *pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+ *pos[2] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+ *pos[3] = GST_AUDIO_CHANNEL_POSITION_REAR_LEFT;
+ *pos[4] = GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT;
+ }
break;
case DTS_4F2R:
chans = 6;
+ if (pos) {
+ *pos = g_new (GstAudioChannelPosition, 7);
+ *pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER;
+ *pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER;
+ *pos[2] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+ *pos[3] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+ *pos[4] = GST_AUDIO_CHANNEL_POSITION_REAR_LEFT;
+ *pos[5] = GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT;
+ }
break;
default:
/* error */
g_warning ("dtsdec: invalid flags 0x%x", flags);
return 0;
}
- if (flags & DTS_LFE)
+ if (flags & DTS_LFE) {
+ if (pos) {
+ *pos[chans] = GST_AUDIO_CHANNEL_POSITION_LFE;
+ }
chans += 1;
+ }
return chans;
}
@@ -223,8 +285,12 @@ gst_dtsdec_channels (uint32_t flags)
static gboolean
gst_dtsdec_renegotiate (GstDtsDec * dts)
{
+ GstAudioChannelPosition *pos;
GstCaps *caps = gst_caps_from_string (DTS_CAPS);
- gint channels = gst_dtsdec_channels (dts->using_channels);
+ gint channels = gst_dtsdec_channels (dts->using_channels, &pos);
+
+ if (!channels)
+ return FALSE;
GST_INFO ("dtsdec renegotiate, channels=%d, rate=%d",
channels, dts->sample_rate);
@@ -232,6 +298,8 @@ gst_dtsdec_renegotiate (GstDtsDec * dts)
gst_caps_set_simple (caps,
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, (gint) dts->sample_rate, NULL);
+ gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
+ g_free (pos);
return gst_pad_set_explicit_caps (dts->srcpad, caps);
}
@@ -381,7 +449,7 @@ gst_dtsdec_loop (GstElement * element)
}
samples = dts_samples (dts->state);
- num_c = gst_dtsdec_channels (dts->using_channels);
+ num_c = gst_dtsdec_channels (dts->using_channels, NULL);
out = gst_buffer_new_and_alloc ((SAMPLE_WIDTH / 8) * 256 * num_c);
GST_BUFFER_TIMESTAMP (out) = timestamp;
GST_BUFFER_DURATION (out) = GST_SECOND * 256 / dts->sample_rate;
@@ -497,7 +565,7 @@ gst_dtsdec_get_property (GObject * object, guint prop_id, GValue * value,
static gboolean
plugin_init (GstPlugin * plugin)
{
- if (!gst_library_load ("gstbytestream"))
+ if (!gst_library_load ("gstbytestream") || !gst_library_load ("gstaudio"))
return FALSE;
if (!gst_element_register (plugin, "dtsdec", GST_RANK_PRIMARY,