mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
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
This commit is contained in:
parent
a97c77177e
commit
bd87d8d1dd
1 changed files with 23 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue