diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/libpng/gstpngdec.c | 56 | ||||
-rw-r--r-- | ext/libpng/gstpngdec.h | 1 |
2 files changed, 33 insertions, 24 deletions
diff --git a/ext/libpng/gstpngdec.c b/ext/libpng/gstpngdec.c index 1135d6577..48543aa23 100644 --- a/ext/libpng/gstpngdec.c +++ b/ext/libpng/gstpngdec.c @@ -111,6 +111,7 @@ gst_pngdec_init (GstPngDec * pngdec) pngdec->color_type = -1; pngdec->image_ready = FALSE; + pngdec->read_data = 0; } static void @@ -411,6 +412,7 @@ gst_pngdec_parse (GstVideoDecoder * decoder, GstVideoCodecFrame * frame, gconstpointer data; guint64 signature; gsize size; + GstPngDec *pngdec = (GstPngDec *) decoder; GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame); @@ -425,39 +427,42 @@ gst_pngdec_parse (GstVideoDecoder * decoder, GstVideoCodecFrame * frame, data = gst_adapter_map (adapter, size); gst_byte_reader_init (&reader, data, size); - if (!gst_byte_reader_peek_uint64_be (&reader, &signature)) - goto need_more_data; + if (pngdec->read_data == 0) { + if (!gst_byte_reader_peek_uint64_be (&reader, &signature)) + goto need_more_data; - if (signature != PNG_SIGNATURE) { - for (;;) { - guint offset; + if (signature != PNG_SIGNATURE) { + for (;;) { + guint offset; - offset = gst_byte_reader_masked_scan_uint32 (&reader, 0xffffffff, - 0x89504E47, 0, gst_byte_reader_get_remaining (&reader)); + offset = gst_byte_reader_masked_scan_uint32 (&reader, 0xffffffff, + 0x89504E47, 0, gst_byte_reader_get_remaining (&reader)); - if (offset == -1) { - gst_adapter_flush (adapter, - gst_byte_reader_get_remaining (&reader) - 4); - goto need_more_data; - } + if (offset == -1) { + gst_adapter_flush (adapter, + gst_byte_reader_get_remaining (&reader) - 4); + goto need_more_data; + } - if (!gst_byte_reader_skip (&reader, offset)) - goto need_more_data; + if (!gst_byte_reader_skip (&reader, offset)) + goto need_more_data; - if (!gst_byte_reader_peek_uint64_be (&reader, &signature)) - goto need_more_data; + if (!gst_byte_reader_peek_uint64_be (&reader, &signature)) + goto need_more_data; - if (signature == PNG_SIGNATURE) { - /* We're skipping, go out, we'll be back */ - gst_adapter_flush (adapter, gst_byte_reader_get_pos (&reader)); - goto need_more_data; + if (signature == PNG_SIGNATURE) { + /* We're skipping, go out, we'll be back */ + gst_adapter_flush (adapter, gst_byte_reader_get_pos (&reader)); + goto need_more_data; + } + if (!gst_byte_reader_skip (&reader, 4)) + goto need_more_data; } - if (!gst_byte_reader_skip (&reader, 4)) - goto need_more_data; } + pngdec->read_data = 8; } - if (!gst_byte_reader_skip (&reader, 8)) + if (!gst_byte_reader_skip (&reader, pngdec->read_data)) goto need_more_data; for (;;) { @@ -477,8 +482,10 @@ gst_pngdec_parse (GstVideoDecoder * decoder, GstVideoCodecFrame * frame, toadd = gst_byte_reader_get_pos (&reader); GST_DEBUG_OBJECT (decoder, "Have complete frame of size %" G_GSIZE_FORMAT, toadd); + pngdec->read_data = 0; goto have_full_frame; - } + } else + pngdec->read_data += length + 12; } g_assert_not_reached (); @@ -591,6 +598,7 @@ gst_pngdec_libpng_clear (GstPngDec * pngdec) } pngdec->color_type = -1; + pngdec->read_data = 0; } static gboolean diff --git a/ext/libpng/gstpngdec.h b/ext/libpng/gstpngdec.h index d89323aec..a995851bb 100644 --- a/ext/libpng/gstpngdec.h +++ b/ext/libpng/gstpngdec.h @@ -56,6 +56,7 @@ struct _GstPngDec gint color_type; gboolean image_ready; + gsize read_data; }; struct _GstPngDecClass |