From 16916838831d489b0dfc2535d2d40f582193caed Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 9 Dec 2008 14:19:16 +0000 Subject: [PATCH] gst/rtp/gstrtpjpegdepay.c: Add an EOI marker at the end of the jpeg frame when it's missing. Original commit message from CVS: * gst/rtp/gstrtpjpegdepay.c: (gst_rtp_jpeg_depay_process): Add an EOI marker at the end of the jpeg frame when it's missing. Fixes #563056. --- ChangeLog | 6 ++++++ gst/rtp/gstrtpjpegdepay.c | 23 +++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e6ef952..020f6cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-12-09 Wim Taymans + + * gst/rtp/gstrtpjpegdepay.c: (gst_rtp_jpeg_depay_process): + Add an EOI marker at the end of the jpeg frame when it's missing. + Fixes #563056. + 2008-12-09 Sebastian Dröge * tests/check/elements/videocrop.c: (check_1x1_buffer): diff --git a/gst/rtp/gstrtpjpegdepay.c b/gst/rtp/gstrtpjpegdepay.c index 17fbe12..44f2dde 100644 --- a/gst/rtp/gstrtpjpegdepay.c +++ b/gst/rtp/gstrtpjpegdepay.c @@ -549,7 +549,6 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) GST_BUFFER_SIZE (outbuf) = size; gst_adapter_push (rtpjpegdepay->adapter, outbuf); - } /* take JPEG data, push in the adapter */ @@ -560,12 +559,32 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) if (gst_rtp_buffer_get_marker (buf)) { guint avail; + guint8 end[2]; + guint8 *data; /* last buffer take all data out of the adapter */ avail = gst_adapter_available (rtpjpegdepay->adapter); + GST_DEBUG_OBJECT (rtpjpegdepay, "marker set, last buffer"); + + /* take the last bytes of the jpeg data to see if there is an EOI + * marker */ + gst_adapter_copy (rtpjpegdepay->adapter, end, avail - 2, 2); + + if (end[0] != 0xff && end[1] != 0xd9) { + GST_DEBUG_OBJECT (rtpjpegdepay, "no EOI marker, adding one"); + + /* no EOI marker, add one */ + outbuf = gst_buffer_new_and_alloc (2); + data = GST_BUFFER_DATA (outbuf); + data[0] = 0xff; + data[1] = 0xd9; + + gst_adapter_push (rtpjpegdepay->adapter, outbuf); + avail += 2; + } outbuf = gst_adapter_take_buffer (rtpjpegdepay->adapter, avail); - GST_DEBUG_OBJECT (rtpjpegdepay, "last buffer, returning %u bytes", avail); + GST_DEBUG_OBJECT (rtpjpegdepay, "returning %u bytes", avail); } return outbuf; -- 2.7.4