/* Special optimized scan for mask 0xffffff00 and pattern 0x00000100 */
static inline gint
-_scan_for_start_code (const guint8 * data, guint offset, guint size)
+_scan_for_start_code (const guint8 * data, guint size)
{
guint8 *pdata = (guint8 *) data;
guint8 *pend = (guint8 *) (data + size - 4);
} else if (pdata[0] || pdata[2] != 1) {
pdata++;
} else {
- return (pdata - data + offset);
+ return (pdata - data);
}
}
/* Handle special case found in MPEG and H264 */
if ((pattern == 0x00000100) && (mask == 0xffffff00)) {
- guint ret = _scan_for_start_code (data, offset, size);
- if (G_UNLIKELY (value))
+ gint ret = _scan_for_start_code (data, size);
+
+ if (ret == -1)
+ return ret;
+
+ if (value != NULL)
*value = (1 << 8) | data[ret + 3];
- return ret;
+
+ return ret + offset;
}
/* set the state to something that does not match */