From c8e4999eb02d68383f9c59aedd58f8b977969afa Mon Sep 17 00:00:00 2001 From: Young-Ho Cha Date: Fri, 2 Mar 2007 18:10:06 +0000 Subject: [PATCH] ext/dts/gstdtsdec.c: Don't do forced downmixing to stereo, but check what downstream can do and let libdts do the dow... Original commit message from CVS: Patch by: Young-Ho Cha * ext/dts/gstdtsdec.c: (gst_dtsdec_handle_frame), (gst_dtsdec_change_state): Don't do forced downmixing to stereo, but check what downstream can do and let libdts do the downmixing based on that (#400555). --- ChangeLog | 9 +++++++++ ext/dts/gstdtsdec.c | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 04d714a606..d5160fb5ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-03-02 Tim-Philipp Müller + + Patch by: Young-Ho Cha + + * ext/dts/gstdtsdec.c: (gst_dtsdec_handle_frame), + (gst_dtsdec_change_state): + Don't do forced downmixing to stereo, but check what downstream + can do and let libdts do the downmixing based on that (#400555). + 2007-03-02 Tim-Philipp Müller Patch by: Lutz Mueller diff --git a/ext/dts/gstdtsdec.c b/ext/dts/gstdtsdec.c index c2b3329c28..642cdde3e0 100644 --- a/ext/dts/gstdtsdec.c +++ b/ext/dts/gstdtsdec.c @@ -392,6 +392,45 @@ gst_dtsdec_handle_frame (GstDtsDec * dts, guint8 * data, gst_dtsdec_update_streaminfo (dts); } + if (dts->request_channels == DTS_CHANNEL) { + GstCaps *caps; + + caps = gst_pad_get_allowed_caps (dts->srcpad); + if (caps && gst_caps_get_size (caps) > 0) { + GstCaps *copy = gst_caps_copy_nth (caps, 0); + GstStructure *structure = gst_caps_get_structure (copy, 0); + gint channels; + const int dts_channels[6] = { + DTS_MONO, + DTS_STEREO, + DTS_STEREO | DTS_LFE, + DTS_2F2R, + DTS_2F2R | DTS_LFE, + DTS_3F2R | DTS_LFE, + }; + + /* Prefer the original number of channels, but fixate to something + * preferred (first in the caps) downstream if possible. + */ + gst_structure_fixate_field_nearest_int (structure, "channels", + flags ? gst_dtsdec_channels (flags, NULL) : 6); + gst_structure_get_int (structure, "channels", &channels); + if (channels <= 6) + dts->request_channels = dts_channels[channels - 1]; + else + dts->request_channels = dts_channels[5]; + + gst_caps_unref (copy); + } else if (flags) { + dts->request_channels = dts->stream_channels; + } else { + dts->request_channels = DTS_3F2R | DTS_LFE; + } + + if (caps) + gst_caps_unref (caps); + } + /* process */ flags = dts->request_channels | DTS_ADJUST_LEVEL; dts->level = 1; @@ -539,7 +578,7 @@ gst_dtsdec_change_state (GstElement * element, GstStateChange transition) dts->sample_rate = -1; dts->stream_channels = 0; /* FIXME force stereo for now */ - dts->request_channels = DTS_STEREO; + dts->request_channels = DTS_CHANNEL; dts->using_channels = 0; dts->level = 1; dts->bias = 0;