From: Tim-Philipp Müller Date: Fri, 3 Dec 2010 00:22:48 +0000 (+0000) Subject: wavparse: detect DTS advertised as PCM correctly in some more cases X-Git-Tag: 1.19.3~509^2~7980 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd87d8d1ddd22dde0dc30c7161c5d38e134c9a88;p=platform%2Fupstream%2Fgstreamer.git wavparse: detect DTS advertised as PCM correctly in some more cases The DTS typefinder may return a lower probability for frames that start at non-zero offsets and where there's no second frame sync in the first buffer. It's fairly unlikely that we'll acidentally identify PCM data as DTS, so we don't do additional checks for now. https://bugzilla.gnome.org/show_bug.cgi?id=636234 --- diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c index ff01168..6e56f8e 100644 --- a/gst/wavparse/gstwavparse.c +++ b/gst/wavparse/gstwavparse.c @@ -1723,6 +1723,27 @@ gst_wavparse_send_event (GstElement * element, GstEvent * event) return res; } +static gboolean +gst_wavparse_have_dts_caps (const GstCaps * caps, GstTypeFindProbability prob) +{ + GstStructure *s; + + s = gst_caps_get_structure (caps, 0); + if (!gst_structure_has_name (s, "audio/x-dts")) + return FALSE; + if (prob >= GST_TYPE_FIND_LIKELY) + return TRUE; + /* DTS at non-0 offsets and without second sync may yield POSSIBLE .. */ + if (prob < GST_TYPE_FIND_POSSIBLE) + return FALSE; + /* .. in which case we want at least a valid-looking rate and channels */ + if (!gst_structure_has_field (s, "channels")) + return FALSE; + /* and for extra assurance we could also check the rate from the DTS frame + * against the one in the wav header, but for now let's not do that */ + return gst_structure_has_field (s, "rate"); +} + static void gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf) { @@ -1738,9 +1759,8 @@ gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf) tf_caps = gst_type_find_helper_for_buffer (GST_OBJECT (wav), buf, &prob); if (tf_caps != NULL) { - s = gst_caps_get_structure (tf_caps, 0); - if (gst_structure_has_name (s, "audio/x-dts") - && prob >= GST_TYPE_FIND_LIKELY) { + GST_LOG ("typefind caps = %" GST_PTR_FORMAT ", P=%d", tf_caps, prob); + if (gst_wavparse_have_dts_caps (tf_caps, prob)) { GST_INFO_OBJECT (wav, "Found DTS marker in file marked as raw PCM"); gst_caps_unref (wav->caps); wav->caps = tf_caps;