mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
jifmux: Detect EOI correctly
EOI are not always at the last 4 bytes. We need to search the last 5 bytes to find the 0xFFD9 sequence as jpegenc seems to round the buffer size to the next 4 multiple.
This commit is contained in:
parent
ba15ad9387
commit
d49acb5588
1 changed files with 19 additions and 2 deletions
|
@ -340,9 +340,26 @@ gst_jif_mux_parse_image (GstJifMux * self, GstBuffer * buf)
|
|||
}
|
||||
|
||||
if (marker == SOS) {
|
||||
gint eoi_pos = -1;
|
||||
gint i;
|
||||
|
||||
/* search the last 5 bytes for the EOI marker */
|
||||
g_assert (GST_BUFFER_SIZE (buf) >= 5);
|
||||
for (i = 5; i >= 2; i--) {
|
||||
if (GST_BUFFER_DATA (buf)[GST_BUFFER_SIZE (buf) - i] == 0xFF &&
|
||||
GST_BUFFER_DATA (buf)[GST_BUFFER_SIZE (buf) - i + 1] == EOI) {
|
||||
eoi_pos = GST_BUFFER_SIZE (buf) - i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (eoi_pos == -1) {
|
||||
GST_WARNING_OBJECT (self, "Couldn't find an EOI marker");
|
||||
eoi_pos = GST_BUFFER_SIZE (buf);
|
||||
}
|
||||
|
||||
/* remaining size except EOI is scan data */
|
||||
self->priv->scan_size = GST_BUFFER_SIZE (buf) - 4 -
|
||||
gst_byte_reader_get_pos (&reader);
|
||||
self->priv->scan_size = eoi_pos - gst_byte_reader_get_pos (&reader);
|
||||
if (!gst_byte_reader_get_data (&reader, self->priv->scan_size,
|
||||
&self->priv->scan_data))
|
||||
goto error;
|
||||
|
|
Loading…
Reference in a new issue