jpegdec: Don't pass the same data over and over

We already pass the entire frame to the decoder. If the decoder ask for
more data, don't pass the same data again as this leads to infinit loop.
Instead, simply fail the fill function to signal the problem with that
frame. It will then be skipped properly.

https://bugzilla.gnome.org/show_bug.cgi?id=761670
This commit is contained in:
Nicolas Dufresne 2016-02-07 15:02:35 -05:00
parent f301e3f236
commit 905e28a0f3

View file

@ -183,17 +183,9 @@ gst_jpeg_dec_class_init (GstJpegDecClass * klass)
static boolean
gst_jpeg_dec_fill_input_buffer (j_decompress_ptr cinfo)
{
GstJpegDec *dec;
dec = CINFO_GET_JPEGDEC (cinfo);
g_return_val_if_fail (dec != NULL, FALSE);
g_return_val_if_fail (dec->current_frame != NULL, FALSE);
g_return_val_if_fail (dec->current_frame_map.data != NULL, FALSE);
cinfo->src->next_input_byte = dec->current_frame_map.data;
cinfo->src->bytes_in_buffer = dec->current_frame_map.size;
return TRUE;
/* We pass in full frame initially, if this get called, the frame is most likely
* corrupted */
return FALSE;
}
static void
@ -1002,7 +994,9 @@ gst_jpeg_dec_handle_frame (GstVideoDecoder * bdec, GstVideoCodecFrame * frame)
dec->current_frame = frame;
gst_buffer_map (frame->input_buffer, &dec->current_frame_map, GST_MAP_READ);
gst_jpeg_dec_fill_input_buffer (&dec->cinfo);
dec->cinfo.src->next_input_byte = dec->current_frame_map.data;
dec->cinfo.src->bytes_in_buffer = dec->current_frame_map.size;
if (setjmp (dec->jerr.setjmp_buffer)) {
code = dec->jerr.pub.msg_code;