baseparse: fails to skip buffers > 2 MB
I am using the jpegparse element to parse an MJPEG stream. The stream can contain invalid JPEG images, which should be skipped by the jpegparse element, but the parsing should continue, because there are further images after the invalid image.
As long as I have relatively small images, this works fine, but the images are usually about 3 MB and streaming stops whenever jpegparse tries to skip an invalid frame.
The reason is a limit of 2 MB in the baseparse element for looking for the next sync point. As the invalid images have the same size as the valid images, the next image starts more than 2 MB away from the last sync point and the base parse is not able to find it.
if (G_UNLIKELY (parse->priv->discont &&
parse->priv->offset - parse->priv->sync_offset > 2 * 1024 * 1024)) {
GST_ERROR_OBJECT (parse, "offset %d, sync_offset %d",
parse->priv->offset, parse->priv->sync_offset);
GST_ELEMENT_ERROR (parse, STREAM, DECODE,
("Failed to parse stream"), (NULL));
return GST_FLOW_ERROR;
}
I guess that the 2 MB are an arbitrary limit, but simply increasing the limit is not really a solution, because you might want to stop parsing data with smaller size per unit much earlier.
I think users should be able to configure the limit on the parser element. While this is not optimal, because you might not know the limit in advance, at least you would be able to change it if you know more about the data that is parsed.