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)
{
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;