typefindfunctions: Consider the number and types of atoms found in a row for suggesting a probability
If there are 3 or more known atoms in a row, it's likely that this is actually MOV/MP4 even if we don't find any other known atoms. If 5 or more are found then this is most certainly MOV/MP4 and we can return. Also if a moov and mdat atom is found, this is definitely a MOV/MP4 file and can be used as such, independent of anything else following the mdat. Fixes typefinding of various MOV files that have no `ftyp` atom but otherwise a valid file structure followed by some garbage. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1013>
This commit is contained in:
parent
9ab400e267
commit
23370ec429
@ -3383,6 +3383,8 @@ qt_type_find (GstTypeFind * tf, gpointer unused)
|
|||||||
{
|
{
|
||||||
const guint8 *data;
|
const guint8 *data;
|
||||||
guint tip = 0;
|
guint tip = 0;
|
||||||
|
guint atoms_in_a_row = 0;
|
||||||
|
gboolean have_moov = FALSE, have_mdat = FALSE;
|
||||||
guint64 offset = 0;
|
guint64 offset = 0;
|
||||||
guint64 size;
|
guint64 size;
|
||||||
const gchar *variant = NULL;
|
const gchar *variant = NULL;
|
||||||
@ -3435,6 +3437,17 @@ qt_type_find (GstTypeFind * tf, gpointer unused)
|
|||||||
} else {
|
} else {
|
||||||
tip = GST_TYPE_FIND_NEARLY_CERTAIN;
|
tip = GST_TYPE_FIND_NEARLY_CERTAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (STRNCMP (&data[4], "moov", 4) == 0)
|
||||||
|
have_moov = TRUE;
|
||||||
|
if (STRNCMP (&data[4], "mdat", 4) == 0)
|
||||||
|
have_mdat = TRUE;
|
||||||
|
|
||||||
|
atoms_in_a_row += 1;
|
||||||
|
if ((have_moov && have_mdat) || atoms_in_a_row >= 5) {
|
||||||
|
tip = GST_TYPE_FIND_MAXIMUM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* other box/atom types, apparently quicktime specific */
|
/* other box/atom types, apparently quicktime specific */
|
||||||
else if (STRNCMP (&data[4], "pnot", 4) == 0 ||
|
else if (STRNCMP (&data[4], "pnot", 4) == 0 ||
|
||||||
@ -3444,6 +3457,9 @@ qt_type_find (GstTypeFind * tf, gpointer unused)
|
|||||||
tip = GST_TYPE_FIND_MAXIMUM;
|
tip = GST_TYPE_FIND_MAXIMUM;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
if (atoms_in_a_row >= 3)
|
||||||
|
tip = GST_TYPE_FIND_LIKELY;
|
||||||
|
else
|
||||||
tip = 0;
|
tip = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user