typefind: strengthen check for valid H.263 picture layer
Avoids some false positives leading to miss identification: * Prevent picture start code emulation for the first 2 bytes read * Add check for valid "picture coding type" and "PB-frames mode" combination Additionally, change name on confusingly named TR var to what it is, the layer's PTYPE. https://bugzilla.gnome.org/show_bug.cgi?id=693263
This commit is contained in:
parent
5d78aab810
commit
9cf5645860
@ -2587,12 +2587,13 @@ static void
|
|||||||
h263_video_type_find (GstTypeFind * tf, gpointer unused)
|
h263_video_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
{
|
{
|
||||||
DataScanCtx c = { 0, NULL, 0 };
|
DataScanCtx c = { 0, NULL, 0 };
|
||||||
guint64 data = 0;
|
guint64 data = 0xffff; /* prevents false positive for first 2 bytes */
|
||||||
guint64 psc = 0;
|
guint64 psc = 0;
|
||||||
guint8 tr = 0;
|
guint8 ptype = 0;
|
||||||
guint format;
|
guint format;
|
||||||
guint good = 0;
|
guint good = 0;
|
||||||
guint bad = 0;
|
guint bad = 0;
|
||||||
|
guint pc_type, pb_mode;
|
||||||
|
|
||||||
while (c.offset < H263_MAX_PROBE_LENGTH) {
|
while (c.offset < H263_MAX_PROBE_LENGTH) {
|
||||||
if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 4)))
|
if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 4)))
|
||||||
@ -2603,16 +2604,21 @@ h263_video_type_find (GstTypeFind * tf, gpointer unused)
|
|||||||
psc = data & G_GUINT64_CONSTANT (0xfffffc0000);
|
psc = data & G_GUINT64_CONSTANT (0xfffffc0000);
|
||||||
if (psc == 0x800000) {
|
if (psc == 0x800000) {
|
||||||
/* Found PSC */
|
/* Found PSC */
|
||||||
/* TR */
|
/* PTYPE */
|
||||||
tr = (data & 0x3fc) >> 2;
|
ptype = (data & 0x3fc) >> 2;
|
||||||
/* Source Format */
|
/* Source Format */
|
||||||
format = tr & 0x07;
|
format = ptype & 0x07;
|
||||||
|
|
||||||
/* Now that we have a Valid PSC, check if we also have a valid PTYPE and
|
/* Now that we have a Valid PSC, check if we also have a valid PTYPE and
|
||||||
the Source Format, which should range between 1 and 5 */
|
the Source Format, which should range between 1 and 5 */
|
||||||
if (((tr >> 6) == 0x2) && (format > 0 && format < 6))
|
if (((ptype >> 6) == 0x2) && (format > 0 && format < 6)) {
|
||||||
good++;
|
pc_type = data & 0x02;
|
||||||
else
|
pb_mode = c.data[1] & 0x20 >> 4;
|
||||||
|
if (!pc_type && pb_mode)
|
||||||
|
bad++;
|
||||||
|
else
|
||||||
|
good++;
|
||||||
|
} else
|
||||||
bad++;
|
bad++;
|
||||||
|
|
||||||
/* FIXME: maybe bail out early if we get mostly bad syncs ? */
|
/* FIXME: maybe bail out early if we get mostly bad syncs ? */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user