mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
ext/jpeg/gstjpegdec.*: Make mjpeg actually work and skip jpeg data parsing if we know that the input is packetized (i...
Original commit message from CVS: * ext/jpeg/gstjpegdec.c: (gst_jpeg_dec_init), (gst_jpeg_dec_setcaps), (gst_jpeg_dec_chain), (gst_jpeg_dec_change_state): * ext/jpeg/gstjpegdec.h: Make mjpeg actually work and skip jpeg data parsing if we know that the input is packetized (ie. each input buffer is exactly one jpeg frame).
This commit is contained in:
parent
09253dcaf3
commit
471fec5c95
3 changed files with 45 additions and 21 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-08-09 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* ext/jpeg/gstjpegdec.c: (gst_jpeg_dec_init),
|
||||||
|
(gst_jpeg_dec_setcaps), (gst_jpeg_dec_chain),
|
||||||
|
(gst_jpeg_dec_change_state):
|
||||||
|
* ext/jpeg/gstjpegdec.h:
|
||||||
|
Make mjpeg actually work and skip jpeg data parsing if we
|
||||||
|
know that the input is packetized (ie. each input buffer
|
||||||
|
is exactly one jpeg frame).
|
||||||
|
|
||||||
2005-08-09 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
2005-08-09 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||||
|
|
||||||
* ext/mad/gstmad.c: (gst_mad_init), (gst_mad_chain):
|
* ext/mad/gstmad.c: (gst_mad_init), (gst_mad_chain):
|
||||||
|
|
|
@ -247,6 +247,7 @@ gst_jpeg_dec_init (GstJpegDec * dec)
|
||||||
(&gst_jpeg_dec_src_pad_template), "src");
|
(&gst_jpeg_dec_src_pad_template), "src");
|
||||||
gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad);
|
gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad);
|
||||||
|
|
||||||
|
dec->packetized = FALSE;
|
||||||
dec->next_ts = 0;
|
dec->next_ts = 0;
|
||||||
dec->fps = 1.0;
|
dec->fps = 1.0;
|
||||||
|
|
||||||
|
@ -604,20 +605,19 @@ gst_jpeg_dec_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
GstJpegDec *dec;
|
GstJpegDec *dec;
|
||||||
gdouble fps;
|
gdouble fps;
|
||||||
gint width, height;
|
|
||||||
|
|
||||||
dec = GST_JPEG_DEC (GST_OBJECT_PARENT (pad));
|
dec = GST_JPEG_DEC (GST_OBJECT_PARENT (pad));
|
||||||
s = gst_caps_get_structure (caps, 0);
|
s = gst_caps_get_structure (caps, 0);
|
||||||
|
|
||||||
if (gst_structure_get_double (s, "framerate", &fps))
|
if (gst_structure_get_double (s, "framerate", &fps)) {
|
||||||
dec->fps = fps;
|
dec->fps = fps;
|
||||||
|
dec->packetized = TRUE;
|
||||||
if (gst_structure_get_int (s, "width", &width)
|
GST_DEBUG ("got framerate of %f fps => packetized mode", fps);
|
||||||
&& gst_structure_get_int (s, "height", &height)) {
|
|
||||||
dec->width = width;
|
|
||||||
dec->height = height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* do not extract width/height here. we do that in the chain
|
||||||
|
* function on a per-frame basis (including the line[] array
|
||||||
|
* setup) */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,22 +652,32 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
|
||||||
if (!gst_jpeg_dec_ensure_header (dec))
|
if (!gst_jpeg_dec_ensure_header (dec))
|
||||||
return GST_FLOW_OK; /* need more data */
|
return GST_FLOW_OK; /* need more data */
|
||||||
|
|
||||||
|
/* If we know that each input buffer contains data
|
||||||
|
* for a whole jpeg image (e.g. MJPEG streams), just
|
||||||
|
* do some sanity checking instead of parsing all of
|
||||||
|
* the jpeg data */
|
||||||
|
if (dec->packetized) {
|
||||||
|
img_len = GST_BUFFER_SIZE (dec->tempbuf);
|
||||||
#if 0
|
#if 0
|
||||||
/* This is a very crude way to handle 'progressive
|
/* This does not work, e.g. avidemux adds an
|
||||||
* loading' without parsing the image, and thus
|
* extra 0 at the end of the buffer */
|
||||||
* considerably cheaper. It should work for most
|
if (!gst_jpeg_dec_have_end_marker (dec)) {
|
||||||
* most use cases, as with most use cases the end
|
gst_util_dump_mem (GST_BUFFER_DATA (dec->tempbuf),
|
||||||
* of the image is also the end of a buffer. */
|
GST_BUFFER_SIZE (dec->tempbuf));
|
||||||
if (!gst_jpeg_dec_have_end_marker (dec))
|
GST_ELEMENT_ERROR (dec, STREAM, DECODE, ("JPEG input without EOI marker"),
|
||||||
return GST_FLOW_OK; /* need more data */
|
(NULL));
|
||||||
|
ret = GST_FLOW_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
/* Parse jpeg image to handle jpeg input that
|
/* Parse jpeg image to handle jpeg input that
|
||||||
* is not aligned to buffer boundaries */
|
* is not aligned to buffer boundaries */
|
||||||
img_len = gst_jpeg_dec_parse_image_data (dec);
|
img_len = gst_jpeg_dec_parse_image_data (dec);
|
||||||
|
|
||||||
if (img_len == 0)
|
if (img_len == 0)
|
||||||
return GST_FLOW_OK; /* need more data */
|
return GST_FLOW_OK; /* need more data */
|
||||||
|
}
|
||||||
|
|
||||||
data = (guchar *) GST_BUFFER_DATA (dec->tempbuf);
|
data = (guchar *) GST_BUFFER_DATA (dec->tempbuf);
|
||||||
size = img_len;
|
size = img_len;
|
||||||
|
@ -681,7 +691,7 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
|
||||||
GST_DEBUG ("jpeg input EOF error, we probably need more data");
|
GST_DEBUG ("jpeg input EOF error, we probably need more data");
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
GST_ELEMENT_ERROR (dec, LIBRARY, TOO_LAZY,
|
GST_ELEMENT_ERROR (dec, STREAM, DECODE,
|
||||||
(_("Failed to decode JPEG image")), (NULL));
|
(_("Failed to decode JPEG image")), (NULL));
|
||||||
ret = GST_FLOW_ERROR;
|
ret = GST_FLOW_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -829,6 +839,7 @@ gst_jpeg_dec_change_state (GstElement * element)
|
||||||
dec->next_ts = 0;
|
dec->next_ts = 0;
|
||||||
dec->width = -1;
|
dec->width = -1;
|
||||||
dec->height = -1;
|
dec->height = -1;
|
||||||
|
dec->packetized = FALSE;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_READY_TO_NULL:
|
case GST_STATE_READY_TO_NULL:
|
||||||
g_free (dec->line[0]);
|
g_free (dec->line[0]);
|
||||||
|
|
|
@ -69,6 +69,9 @@ struct _GstJpegDec {
|
||||||
|
|
||||||
GstBuffer *tempbuf;
|
GstBuffer *tempbuf;
|
||||||
|
|
||||||
|
/* TRUE if each input buffer contains a whole jpeg image */
|
||||||
|
gboolean packetized;
|
||||||
|
|
||||||
/* the timestamp of the next frame */
|
/* the timestamp of the next frame */
|
||||||
guint64 next_ts;
|
guint64 next_ts;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue