2004-07-16 10:56:31 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
2012-04-07 07:52:09 +00:00
|
|
|
* Copyright (C) 2012 Collabora Ltd.
|
|
|
|
* Author : Edward Hervey <edward@collabora.com>
|
2013-05-07 14:30:59 +00:00
|
|
|
* Copyright (C) 2013 Collabora Ltd.
|
|
|
|
* Author : Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
|
|
|
* Olivier Crete <olivier.crete@collabora.com>
|
2004-07-16 10:56:31 +00:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2004-07-16 10:56:31 +00:00
|
|
|
*
|
|
|
|
*/
|
2007-07-18 09:21:23 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-pngdec
|
|
|
|
*
|
|
|
|
* Decodes png images. If there is no framerate set on sink caps, it sends EOS
|
|
|
|
* after the first picture.
|
|
|
|
*/
|
|
|
|
|
2004-07-16 10:56:31 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2005-10-15 16:48:55 +00:00
|
|
|
|
2004-07-16 10:56:31 +00:00
|
|
|
#include "gstpngdec.h"
|
2005-10-15 16:48:55 +00:00
|
|
|
|
2007-07-20 07:41:58 +00:00
|
|
|
#include <stdlib.h>
|
2005-10-15 16:48:55 +00:00
|
|
|
#include <string.h>
|
2013-05-07 14:30:59 +00:00
|
|
|
#include <gst/base/gstbytereader.h>
|
2004-07-16 10:56:31 +00:00
|
|
|
#include <gst/video/video.h>
|
2012-05-28 13:22:26 +00:00
|
|
|
#include <gst/video/gstvideometa.h>
|
|
|
|
#include <gst/video/gstvideopool.h>
|
2005-10-23 11:07:10 +00:00
|
|
|
#include <gst/gst-i18n-plugin.h>
|
2004-07-16 10:56:31 +00:00
|
|
|
|
2006-06-22 19:31:04 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (pngdec_debug);
|
2005-10-15 16:48:55 +00:00
|
|
|
#define GST_CAT_DEFAULT pngdec_debug
|
2004-07-16 10:56:31 +00:00
|
|
|
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
static gboolean gst_pngdec_libpng_init (GstPngDec * pngdec);
|
2004-07-16 10:56:31 +00:00
|
|
|
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
static GstFlowReturn gst_pngdec_caps_create_and_set (GstPngDec * pngdec);
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
static gboolean gst_pngdec_start (GstVideoDecoder * decoder);
|
|
|
|
static gboolean gst_pngdec_stop (GstVideoDecoder * decoder);
|
2013-08-15 13:08:05 +00:00
|
|
|
static gboolean gst_pngdec_flush (GstVideoDecoder * decoder);
|
2012-04-07 07:52:09 +00:00
|
|
|
static gboolean gst_pngdec_set_format (GstVideoDecoder * Decoder,
|
|
|
|
GstVideoCodecState * state);
|
2013-05-07 14:30:59 +00:00
|
|
|
static GstFlowReturn gst_pngdec_parse (GstVideoDecoder * decoder,
|
|
|
|
GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos);
|
2012-04-07 07:52:09 +00:00
|
|
|
static GstFlowReturn gst_pngdec_handle_frame (GstVideoDecoder * decoder,
|
|
|
|
GstVideoCodecFrame * frame);
|
2012-05-28 13:22:26 +00:00
|
|
|
static gboolean gst_pngdec_decide_allocation (GstVideoDecoder * decoder,
|
|
|
|
GstQuery * query);
|
2004-07-16 10:56:31 +00:00
|
|
|
|
2012-05-28 13:22:26 +00:00
|
|
|
#define parent_class gst_pngdec_parent_class
|
|
|
|
G_DEFINE_TYPE (GstPngDec, gst_pngdec, GST_TYPE_VIDEO_DECODER);
|
2004-07-16 10:56:31 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate gst_pngdec_src_pad_template =
|
2012-05-28 13:22:26 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
2004-07-16 10:56:31 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-05-28 13:22:26 +00:00
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
|
|
|
|
("{ RGBA, RGB, ARGB64, GRAY8, GRAY16_BE }"))
|
2004-07-16 10:56:31 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate gst_pngdec_sink_pad_template =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2005-10-17 15:23:24 +00:00
|
|
|
GST_STATIC_CAPS ("image/png")
|
2004-07-16 10:56:31 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static void
|
2012-05-28 13:22:26 +00:00
|
|
|
gst_pngdec_class_init (GstPngDecClass * klass)
|
2004-07-16 10:56:31 +00:00
|
|
|
{
|
2012-05-28 13:22:26 +00:00
|
|
|
GstElementClass *element_class = (GstElementClass *) klass;
|
|
|
|
GstVideoDecoderClass *vdec_class = (GstVideoDecoderClass *) klass;
|
2004-07-16 10:56:31 +00:00
|
|
|
|
2012-05-28 13:22:26 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&gst_pngdec_src_pad_template));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&gst_pngdec_sink_pad_template));
|
2012-10-17 16:03:39 +00:00
|
|
|
gst_element_class_set_static_metadata (element_class, "PNG image decoder",
|
2012-01-24 17:23:22 +00:00
|
|
|
"Codec/Decoder/Image",
|
|
|
|
"Decode a png video frame to a raw image",
|
|
|
|
"Wim Taymans <wim@fluendo.com>");
|
2012-04-07 07:52:09 +00:00
|
|
|
|
|
|
|
vdec_class->start = gst_pngdec_start;
|
2012-11-12 09:44:01 +00:00
|
|
|
vdec_class->stop = gst_pngdec_stop;
|
2013-08-15 13:08:05 +00:00
|
|
|
vdec_class->flush = gst_pngdec_flush;
|
2012-04-07 07:52:09 +00:00
|
|
|
vdec_class->set_format = gst_pngdec_set_format;
|
2013-05-07 14:30:59 +00:00
|
|
|
vdec_class->parse = gst_pngdec_parse;
|
2012-04-07 07:52:09 +00:00
|
|
|
vdec_class->handle_frame = gst_pngdec_handle_frame;
|
2012-05-28 13:22:26 +00:00
|
|
|
vdec_class->decide_allocation = gst_pngdec_decide_allocation;
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
|
2005-10-15 16:48:55 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (pngdec_debug, "pngdec", 0, "PNG image decoder");
|
2004-07-16 10:56:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-28 13:22:26 +00:00
|
|
|
gst_pngdec_init (GstPngDec * pngdec)
|
2004-07-16 10:56:31 +00:00
|
|
|
{
|
|
|
|
pngdec->png = NULL;
|
|
|
|
pngdec->info = NULL;
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
pngdec->endinfo = NULL;
|
2004-07-16 10:56:31 +00:00
|
|
|
|
|
|
|
pngdec->color_type = -1;
|
2007-11-20 12:20:38 +00:00
|
|
|
|
|
|
|
pngdec->image_ready = FALSE;
|
2014-11-04 02:48:41 +00:00
|
|
|
pngdec->read_data = 0;
|
2015-08-15 11:49:57 +00:00
|
|
|
|
|
|
|
gst_video_decoder_set_use_default_pad_acceptcaps (GST_VIDEO_DECODER_CAST
|
|
|
|
(pngdec), TRUE);
|
|
|
|
GST_PAD_SET_ACCEPT_TEMPLATE (GST_VIDEO_DECODER_SINK_PAD (pngdec));
|
2004-07-16 10:56:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
user_error_fn (png_structp png_ptr, png_const_charp error_msg)
|
2004-07-16 10:56:31 +00:00
|
|
|
{
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
GST_ERROR ("%s", error_msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
user_warning_fn (png_structp png_ptr, png_const_charp warning_msg)
|
|
|
|
{
|
|
|
|
GST_WARNING ("%s", warning_msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
user_info_callback (png_structp png_ptr, png_infop info)
|
|
|
|
{
|
|
|
|
GstPngDec *pngdec = NULL;
|
2014-09-18 10:34:03 +00:00
|
|
|
GstFlowReturn ret;
|
2004-07-16 10:56:31 +00:00
|
|
|
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
GST_LOG ("info ready");
|
2004-07-16 10:56:31 +00:00
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
pngdec = GST_PNGDEC (png_get_io_ptr (png_ptr));
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
/* Generate the caps and configure */
|
|
|
|
ret = gst_pngdec_caps_create_and_set (pngdec);
|
|
|
|
if (ret != GST_FLOW_OK) {
|
|
|
|
goto beach;
|
|
|
|
}
|
2004-07-16 10:56:31 +00:00
|
|
|
|
2012-01-24 17:23:22 +00:00
|
|
|
/* Allocate output buffer */
|
2012-05-28 13:22:26 +00:00
|
|
|
ret =
|
2012-07-23 08:32:36 +00:00
|
|
|
gst_video_decoder_allocate_output_frame (GST_VIDEO_DECODER (pngdec),
|
2012-05-28 13:22:26 +00:00
|
|
|
pngdec->current_frame);
|
|
|
|
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
|
|
|
GST_DEBUG_OBJECT (pngdec, "failed to acquire buffer");
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
|
|
|
|
beach:
|
|
|
|
pngdec->ret = ret;
|
2004-07-16 10:56:31 +00:00
|
|
|
}
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
static gboolean
|
|
|
|
gst_pngdec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state)
|
|
|
|
{
|
|
|
|
GstPngDec *pngdec = (GstPngDec *) decoder;
|
|
|
|
|
|
|
|
if (pngdec->input_state)
|
|
|
|
gst_video_codec_state_unref (pngdec->input_state);
|
|
|
|
pngdec->input_state = gst_video_codec_state_ref (state);
|
|
|
|
|
2014-09-16 07:53:16 +00:00
|
|
|
if (decoder->input_segment.format == GST_FORMAT_TIME)
|
2013-05-07 14:30:59 +00:00
|
|
|
gst_video_decoder_set_packetized (decoder, TRUE);
|
|
|
|
else
|
|
|
|
gst_video_decoder_set_packetized (decoder, FALSE);
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
/* We'll set format later on */
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
static void
|
|
|
|
user_endrow_callback (png_structp png_ptr, png_bytep new_row,
|
|
|
|
png_uint_32 row_num, int pass)
|
|
|
|
{
|
|
|
|
GstPngDec *pngdec = NULL;
|
|
|
|
|
2010-03-15 20:29:55 +00:00
|
|
|
pngdec = GST_PNGDEC (png_get_io_ptr (png_ptr));
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
|
2008-06-30 22:53:39 +00:00
|
|
|
/* If buffer_out doesn't exist, it means buffer_alloc failed, which
|
|
|
|
* will already have set the return code */
|
2014-04-10 13:38:19 +00:00
|
|
|
if (new_row && GST_IS_BUFFER (pngdec->current_frame->output_buffer)) {
|
2012-05-28 13:22:26 +00:00
|
|
|
GstVideoFrame frame;
|
|
|
|
GstBuffer *buffer = pngdec->current_frame->output_buffer;
|
|
|
|
size_t offset;
|
|
|
|
guint8 *data;
|
|
|
|
|
|
|
|
if (!gst_video_frame_map (&frame, &pngdec->output_state->info, buffer,
|
|
|
|
GST_MAP_WRITE)) {
|
|
|
|
pngdec->ret = GST_FLOW_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
|
2012-05-28 13:22:26 +00:00
|
|
|
data = GST_VIDEO_FRAME_COMP_DATA (&frame, 0);
|
|
|
|
offset = row_num * GST_VIDEO_FRAME_COMP_STRIDE (&frame, 0);
|
2014-04-10 13:38:19 +00:00
|
|
|
GST_LOG ("got row %u at pass %d, copying in buffer %p at offset %"
|
|
|
|
G_GSIZE_FORMAT, (guint) row_num, pass,
|
|
|
|
pngdec->current_frame->output_buffer, offset);
|
|
|
|
png_progressive_combine_row (pngdec->png, data + offset, new_row);
|
2012-05-28 13:22:26 +00:00
|
|
|
gst_video_frame_unmap (&frame);
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
pngdec->ret = GST_FLOW_OK;
|
2014-04-10 13:38:19 +00:00
|
|
|
} else
|
|
|
|
pngdec->ret = GST_FLOW_OK;
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
user_end_callback (png_structp png_ptr, png_infop info)
|
|
|
|
{
|
|
|
|
GstPngDec *pngdec = NULL;
|
|
|
|
|
2010-03-15 20:29:55 +00:00
|
|
|
pngdec = GST_PNGDEC (png_get_io_ptr (png_ptr));
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
|
ext/libpng/gstpngdec.*: Handle more than one frame if the content is framed, like with png-in-quicktime (#331917).
Original commit message from CVS:
* ext/libpng/gstpngdec.c: (gst_pngdec_init),
(user_endrow_callback), (user_end_callback),
(gst_pngdec_caps_create_and_set), (gst_pngdec_chain),
(gst_pngdec_sink_setcaps), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_change_state):
* ext/libpng/gstpngdec.h:
Handle more than one frame if the content is framed,
like with png-in-quicktime (#331917).
2006-04-11 09:35:45 +00:00
|
|
|
GST_LOG_OBJECT (pngdec, "and we are done reading this image");
|
|
|
|
|
2012-05-28 13:22:26 +00:00
|
|
|
if (!pngdec->current_frame->output_buffer)
|
2006-07-03 15:31:22 +00:00
|
|
|
return;
|
|
|
|
|
2012-05-28 13:22:26 +00:00
|
|
|
gst_buffer_unmap (pngdec->current_frame->input_buffer,
|
|
|
|
&pngdec->current_frame_map);
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
pngdec->ret =
|
|
|
|
gst_video_decoder_finish_frame (GST_VIDEO_DECODER (pngdec),
|
|
|
|
pngdec->current_frame);
|
|
|
|
|
2007-11-20 12:20:38 +00:00
|
|
|
pngdec->image_ready = TRUE;
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
}
|
|
|
|
|
2012-01-24 17:23:22 +00:00
|
|
|
|
2005-10-15 16:48:55 +00:00
|
|
|
static GstFlowReturn
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
gst_pngdec_caps_create_and_set (GstPngDec * pngdec)
|
2004-07-16 10:56:31 +00:00
|
|
|
{
|
2005-10-15 16:48:55 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2005-10-25 10:47:09 +00:00
|
|
|
gint bpc = 0, color_type;
|
|
|
|
png_uint_32 width, height;
|
2012-04-07 07:52:09 +00:00
|
|
|
GstVideoFormat format = GST_VIDEO_FORMAT_UNKNOWN;
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_PNGDEC (pngdec), GST_FLOW_ERROR);
|
|
|
|
|
2005-10-25 10:47:09 +00:00
|
|
|
/* Get bits per channel */
|
|
|
|
bpc = png_get_bit_depth (pngdec->png, pngdec->info);
|
|
|
|
|
|
|
|
/* Get Color type */
|
|
|
|
color_type = png_get_color_type (pngdec->png, pngdec->info);
|
|
|
|
|
2012-03-07 12:39:50 +00:00
|
|
|
/* Add alpha channel if 16-bit depth, but not for GRAY images */
|
|
|
|
if ((bpc > 8) && (color_type != PNG_COLOR_TYPE_GRAY)) {
|
|
|
|
png_set_add_alpha (pngdec->png, 0xffff, PNG_FILLER_BEFORE);
|
|
|
|
png_set_swap (pngdec->png);
|
|
|
|
}
|
2007-07-06 11:42:53 +00:00
|
|
|
#if 0
|
|
|
|
/* We used to have this HACK to reverse the outgoing bytes, but the problem
|
2012-08-26 21:39:55 +00:00
|
|
|
* that originally required the hack seems to have been in videoconvert's
|
2007-07-06 11:42:53 +00:00
|
|
|
* RGBA descriptions. It doesn't seem needed now that's fixed, but might
|
|
|
|
* still be needed on big-endian systems, I'm not sure. J.S. 6/7/2007 */
|
2005-10-25 10:47:09 +00:00
|
|
|
if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
|
|
|
png_set_bgr (pngdec->png);
|
2007-07-06 11:42:53 +00:00
|
|
|
#endif
|
2005-10-25 10:47:09 +00:00
|
|
|
|
2012-03-07 12:39:50 +00:00
|
|
|
/* Gray scale with alpha channel converted to RGB */
|
|
|
|
if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
|
|
|
GST_LOG_OBJECT (pngdec,
|
|
|
|
"converting grayscale png with alpha channel to RGB");
|
|
|
|
png_set_gray_to_rgb (pngdec->png);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Gray scale converted to upscaled to 8 bits */
|
2006-03-06 22:22:45 +00:00
|
|
|
if ((color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ||
|
|
|
|
(color_type == PNG_COLOR_TYPE_GRAY)) {
|
|
|
|
if (bpc < 8) { /* Convert to 8 bits */
|
|
|
|
GST_LOG_OBJECT (pngdec, "converting grayscale image to 8 bits");
|
2010-02-02 00:02:34 +00:00
|
|
|
#if PNG_LIBPNG_VER < 10400
|
2006-03-06 22:22:45 +00:00
|
|
|
png_set_gray_1_2_4_to_8 (pngdec->png);
|
2010-02-02 00:02:34 +00:00
|
|
|
#else
|
|
|
|
png_set_expand_gray_1_2_4_to_8 (pngdec->png);
|
|
|
|
#endif
|
2006-03-06 22:22:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Palette converted to RGB */
|
|
|
|
if (color_type == PNG_COLOR_TYPE_PALETTE) {
|
|
|
|
GST_LOG_OBJECT (pngdec, "converting palette png to RGB");
|
|
|
|
png_set_palette_to_rgb (pngdec->png);
|
|
|
|
}
|
|
|
|
|
2014-04-10 13:38:19 +00:00
|
|
|
png_set_interlace_handling (pngdec->png);
|
|
|
|
|
2005-10-25 10:47:09 +00:00
|
|
|
/* Update the info structure */
|
|
|
|
png_read_update_info (pngdec->png, pngdec->info);
|
|
|
|
|
|
|
|
/* Get IHDR header again after transformation settings */
|
|
|
|
png_get_IHDR (pngdec->png, pngdec->info, &width, &height,
|
|
|
|
&bpc, &pngdec->color_type, NULL, NULL, NULL);
|
|
|
|
|
2012-05-31 21:39:25 +00:00
|
|
|
GST_LOG_OBJECT (pngdec, "this is a %dx%d PNG image", (gint) width,
|
|
|
|
(gint) height);
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
|
|
|
|
switch (pngdec->color_type) {
|
|
|
|
case PNG_COLOR_TYPE_RGB:
|
2006-03-06 22:22:45 +00:00
|
|
|
GST_LOG_OBJECT (pngdec, "we have no alpha channel, depth is 24 bits");
|
2012-04-07 07:52:09 +00:00
|
|
|
if (bpc == 8)
|
|
|
|
format = GST_VIDEO_FORMAT_RGB;
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
break;
|
|
|
|
case PNG_COLOR_TYPE_RGB_ALPHA:
|
2012-04-07 07:52:09 +00:00
|
|
|
GST_LOG_OBJECT (pngdec,
|
|
|
|
"we have an alpha channel, depth is 32 or 64 bits");
|
|
|
|
if (bpc == 8)
|
2012-03-22 10:53:24 +00:00
|
|
|
format = GST_VIDEO_FORMAT_RGBA;
|
2012-04-07 07:52:09 +00:00
|
|
|
else if (bpc == 16)
|
2012-03-22 10:53:24 +00:00
|
|
|
format = GST_VIDEO_FORMAT_ARGB64;
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
break;
|
2012-03-07 12:39:50 +00:00
|
|
|
case PNG_COLOR_TYPE_GRAY:
|
|
|
|
GST_LOG_OBJECT (pngdec,
|
|
|
|
"We have an gray image, depth is 8 or 16 (be) bits");
|
2012-04-07 07:52:09 +00:00
|
|
|
if (bpc == 8)
|
2012-03-22 10:53:24 +00:00
|
|
|
format = GST_VIDEO_FORMAT_GRAY8;
|
2012-04-07 07:52:09 +00:00
|
|
|
else if (bpc == 16)
|
2012-03-22 10:53:24 +00:00
|
|
|
format = GST_VIDEO_FORMAT_GRAY16_BE;
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-04-07 07:52:09 +00:00
|
|
|
break;
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
}
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
if (format == GST_VIDEO_FORMAT_UNKNOWN) {
|
|
|
|
GST_ELEMENT_ERROR (pngdec, STREAM, NOT_IMPLEMENTED, (NULL),
|
|
|
|
("pngdec does not support this color type"));
|
|
|
|
ret = GST_FLOW_NOT_SUPPORTED;
|
2012-01-24 17:23:22 +00:00
|
|
|
goto beach;
|
|
|
|
}
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
/* Check if output state changed */
|
|
|
|
if (pngdec->output_state) {
|
|
|
|
GstVideoInfo *info = &pngdec->output_state->info;
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
if (width == GST_VIDEO_INFO_WIDTH (info) &&
|
|
|
|
height == GST_VIDEO_INFO_HEIGHT (info) &&
|
|
|
|
GST_VIDEO_INFO_FORMAT (info) == format) {
|
|
|
|
goto beach;
|
|
|
|
}
|
|
|
|
gst_video_codec_state_unref (pngdec->output_state);
|
2005-10-25 10:47:09 +00:00
|
|
|
}
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
pngdec->output_state =
|
|
|
|
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (pngdec), format,
|
|
|
|
width, height, pngdec->input_state);
|
2012-07-18 16:27:40 +00:00
|
|
|
gst_video_decoder_negotiate (GST_VIDEO_DECODER (pngdec));
|
2012-04-07 07:52:09 +00:00
|
|
|
GST_DEBUG ("Final %d %d", GST_VIDEO_INFO_WIDTH (&pngdec->output_state->info),
|
|
|
|
GST_VIDEO_INFO_HEIGHT (&pngdec->output_state->info));
|
|
|
|
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
beach:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2012-04-07 07:52:09 +00:00
|
|
|
gst_pngdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame)
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
{
|
2012-04-07 07:52:09 +00:00
|
|
|
GstPngDec *pngdec = (GstPngDec *) decoder;
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2004-07-16 10:56:31 +00:00
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
GST_LOG_OBJECT (pngdec, "Got buffer, size=%u",
|
2012-05-31 21:39:25 +00:00
|
|
|
(guint) gst_buffer_get_size (frame->input_buffer));
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
|
|
|
|
/* Let libpng come back here on error */
|
|
|
|
if (setjmp (png_jmpbuf (pngdec->png))) {
|
2006-07-17 10:22:54 +00:00
|
|
|
GST_WARNING_OBJECT (pngdec, "error during decoding");
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
ret = GST_FLOW_ERROR;
|
2005-10-15 16:48:55 +00:00
|
|
|
goto beach;
|
2004-07-16 10:56:31 +00:00
|
|
|
}
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
pngdec->current_frame = frame;
|
2012-01-24 17:23:22 +00:00
|
|
|
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
/* Progressive loading of the PNG image */
|
2012-05-28 13:22:26 +00:00
|
|
|
if (!gst_buffer_map (frame->input_buffer, &pngdec->current_frame_map,
|
|
|
|
GST_MAP_READ)) {
|
|
|
|
GST_WARNING_OBJECT (pngdec, "Failed to map input buffer");
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto beach;
|
|
|
|
}
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
png_process_data (pngdec->png, pngdec->info,
|
2012-05-28 13:22:26 +00:00
|
|
|
pngdec->current_frame_map.data, pngdec->current_frame_map.size);
|
2006-07-17 10:22:54 +00:00
|
|
|
|
2007-11-20 12:20:38 +00:00
|
|
|
if (pngdec->image_ready) {
|
2013-08-15 13:08:05 +00:00
|
|
|
/* Reset ourselves for the next frame */
|
|
|
|
gst_pngdec_flush (decoder);
|
|
|
|
GST_LOG_OBJECT (pngdec, "setting up callbacks for next frame");
|
|
|
|
png_set_progressive_read_fn (pngdec->png, pngdec,
|
|
|
|
user_info_callback, user_endrow_callback, user_end_callback);
|
2007-11-20 12:20:38 +00:00
|
|
|
pngdec->image_ready = FALSE;
|
2012-05-28 13:22:26 +00:00
|
|
|
} else {
|
|
|
|
/* An error happened and we have to unmap */
|
|
|
|
gst_buffer_unmap (pngdec->current_frame->input_buffer,
|
|
|
|
&pngdec->current_frame_map);
|
2007-11-20 12:20:38 +00:00
|
|
|
}
|
|
|
|
|
2006-07-03 15:31:22 +00:00
|
|
|
ret = pngdec->ret;
|
2012-01-24 17:23:22 +00:00
|
|
|
beach:
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-05-07 14:30:59 +00:00
|
|
|
/* Based on pngparse */
|
|
|
|
#define PNG_SIGNATURE G_GUINT64_CONSTANT (0x89504E470D0A1A0A)
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_pngdec_parse (GstVideoDecoder * decoder, GstVideoCodecFrame * frame,
|
|
|
|
GstAdapter * adapter, gboolean at_eos)
|
|
|
|
{
|
|
|
|
gsize toadd = 0;
|
|
|
|
GstByteReader reader;
|
|
|
|
gconstpointer data;
|
|
|
|
guint64 signature;
|
|
|
|
gsize size;
|
2014-11-04 02:48:41 +00:00
|
|
|
GstPngDec *pngdec = (GstPngDec *) decoder;
|
2013-05-07 14:30:59 +00:00
|
|
|
|
2014-03-26 07:02:43 +00:00
|
|
|
GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);
|
|
|
|
|
2013-05-07 14:30:59 +00:00
|
|
|
/* FIXME : The overhead of using scan_uint32 is massive */
|
|
|
|
|
|
|
|
size = gst_adapter_available (adapter);
|
|
|
|
GST_DEBUG ("Parsing PNG image data (%" G_GSIZE_FORMAT " bytes)", size);
|
|
|
|
|
|
|
|
if (size < 8)
|
|
|
|
goto need_more_data;
|
|
|
|
|
|
|
|
data = gst_adapter_map (adapter, size);
|
|
|
|
gst_byte_reader_init (&reader, data, size);
|
|
|
|
|
2014-11-04 02:48:41 +00:00
|
|
|
if (pngdec->read_data == 0) {
|
|
|
|
if (!gst_byte_reader_peek_uint64_be (&reader, &signature))
|
|
|
|
goto need_more_data;
|
2013-05-07 14:30:59 +00:00
|
|
|
|
2014-11-04 02:48:41 +00:00
|
|
|
if (signature != PNG_SIGNATURE) {
|
|
|
|
for (;;) {
|
|
|
|
guint offset;
|
2013-05-07 14:30:59 +00:00
|
|
|
|
2014-11-04 02:48:41 +00:00
|
|
|
offset = gst_byte_reader_masked_scan_uint32 (&reader, 0xffffffff,
|
|
|
|
0x89504E47, 0, gst_byte_reader_get_remaining (&reader));
|
2013-05-07 14:30:59 +00:00
|
|
|
|
2014-11-04 02:48:41 +00:00
|
|
|
if (offset == -1) {
|
|
|
|
gst_adapter_flush (adapter,
|
|
|
|
gst_byte_reader_get_remaining (&reader) - 4);
|
|
|
|
goto need_more_data;
|
|
|
|
}
|
2013-05-07 14:30:59 +00:00
|
|
|
|
2014-11-04 02:48:41 +00:00
|
|
|
if (!gst_byte_reader_skip (&reader, offset))
|
|
|
|
goto need_more_data;
|
2013-05-07 14:30:59 +00:00
|
|
|
|
2014-11-04 02:48:41 +00:00
|
|
|
if (!gst_byte_reader_peek_uint64_be (&reader, &signature))
|
|
|
|
goto need_more_data;
|
2013-05-07 14:30:59 +00:00
|
|
|
|
2014-11-04 02:48:41 +00:00
|
|
|
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;
|
2013-05-07 14:30:59 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-04 02:48:41 +00:00
|
|
|
pngdec->read_data = 8;
|
2013-05-07 14:30:59 +00:00
|
|
|
}
|
|
|
|
|
2014-11-04 02:48:41 +00:00
|
|
|
if (!gst_byte_reader_skip (&reader, pngdec->read_data))
|
2013-05-07 14:30:59 +00:00
|
|
|
goto need_more_data;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
guint32 length;
|
|
|
|
guint32 code;
|
|
|
|
|
|
|
|
if (!gst_byte_reader_get_uint32_be (&reader, &length))
|
|
|
|
goto need_more_data;
|
|
|
|
if (!gst_byte_reader_get_uint32_le (&reader, &code))
|
|
|
|
goto need_more_data;
|
|
|
|
|
|
|
|
if (!gst_byte_reader_skip (&reader, length + 4))
|
|
|
|
goto need_more_data;
|
|
|
|
|
|
|
|
if (code == GST_MAKE_FOURCC ('I', 'E', 'N', 'D')) {
|
|
|
|
/* Have complete frame */
|
|
|
|
toadd = gst_byte_reader_get_pos (&reader);
|
|
|
|
GST_DEBUG_OBJECT (decoder, "Have complete frame of size %" G_GSIZE_FORMAT,
|
|
|
|
toadd);
|
2014-11-04 02:48:41 +00:00
|
|
|
pngdec->read_data = 0;
|
2013-05-07 14:30:59 +00:00
|
|
|
goto have_full_frame;
|
2014-11-04 02:48:41 +00:00
|
|
|
} else
|
|
|
|
pngdec->read_data += length + 12;
|
2013-05-07 14:30:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
|
|
|
|
need_more_data:
|
|
|
|
return GST_VIDEO_DECODER_FLOW_NEED_DATA;
|
|
|
|
|
|
|
|
have_full_frame:
|
|
|
|
if (toadd)
|
|
|
|
gst_video_decoder_add_to_frame (decoder, toadd);
|
|
|
|
return gst_video_decoder_have_frame (decoder);
|
|
|
|
}
|
|
|
|
|
2012-05-28 13:22:26 +00:00
|
|
|
static gboolean
|
|
|
|
gst_pngdec_decide_allocation (GstVideoDecoder * bdec, GstQuery * query)
|
|
|
|
{
|
2012-08-08 09:56:51 +00:00
|
|
|
GstBufferPool *pool = NULL;
|
2012-05-28 13:22:26 +00:00
|
|
|
GstStructure *config;
|
|
|
|
|
|
|
|
if (!GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (bdec, query))
|
|
|
|
return FALSE;
|
|
|
|
|
2012-08-08 09:56:51 +00:00
|
|
|
if (gst_query_get_n_allocation_pools (query) > 0)
|
|
|
|
gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
if (pool == NULL)
|
|
|
|
return FALSE;
|
2012-05-28 13:22:26 +00:00
|
|
|
|
|
|
|
config = gst_buffer_pool_get_config (pool);
|
2012-07-06 09:26:46 +00:00
|
|
|
if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
|
2012-05-28 13:22:26 +00:00
|
|
|
gst_buffer_pool_config_add_option (config,
|
|
|
|
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
|
|
|
}
|
|
|
|
gst_buffer_pool_set_config (pool, config);
|
|
|
|
gst_object_unref (pool);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
static gboolean
|
|
|
|
gst_pngdec_libpng_init (GstPngDec * pngdec)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_PNGDEC (pngdec), FALSE);
|
|
|
|
|
2006-07-17 10:22:54 +00:00
|
|
|
GST_LOG ("init libpng structures");
|
2004-07-16 10:56:31 +00:00
|
|
|
|
|
|
|
/* initialize png struct stuff */
|
|
|
|
pngdec->png = png_create_read_struct (PNG_LIBPNG_VER_STRING,
|
|
|
|
(png_voidp) NULL, user_error_fn, user_warning_fn);
|
|
|
|
|
2006-07-17 10:22:54 +00:00
|
|
|
if (pngdec->png == NULL)
|
|
|
|
goto init_failed;
|
|
|
|
|
|
|
|
pngdec->info = png_create_info_struct (pngdec->png);
|
|
|
|
if (pngdec->info == NULL)
|
|
|
|
goto info_failed;
|
|
|
|
|
|
|
|
pngdec->endinfo = png_create_info_struct (pngdec->png);
|
|
|
|
if (pngdec->endinfo == NULL)
|
|
|
|
goto endinfo_failed;
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
png_set_progressive_read_fn (pngdec->png, pngdec,
|
|
|
|
user_info_callback, user_endrow_callback, user_end_callback);
|
2006-07-17 10:22:54 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
init_failed:
|
|
|
|
{
|
2005-01-09 01:40:14 +00:00
|
|
|
GST_ELEMENT_ERROR (pngdec, LIBRARY, INIT, (NULL),
|
|
|
|
("Failed to initialize png structure"));
|
2006-07-17 10:22:54 +00:00
|
|
|
return FALSE;
|
2004-07-16 10:56:31 +00:00
|
|
|
}
|
2006-07-17 10:22:54 +00:00
|
|
|
info_failed:
|
|
|
|
{
|
2005-01-09 01:40:14 +00:00
|
|
|
GST_ELEMENT_ERROR (pngdec, LIBRARY, INIT, (NULL),
|
|
|
|
("Failed to initialize info structure"));
|
2006-07-17 10:22:54 +00:00
|
|
|
return FALSE;
|
2004-07-16 10:56:31 +00:00
|
|
|
}
|
2006-07-17 10:22:54 +00:00
|
|
|
endinfo_failed:
|
|
|
|
{
|
2005-01-09 01:40:14 +00:00
|
|
|
GST_ELEMENT_ERROR (pngdec, LIBRARY, INIT, (NULL),
|
|
|
|
("Failed to initialize endinfo structure"));
|
2006-07-17 10:22:54 +00:00
|
|
|
return FALSE;
|
2004-07-16 10:56:31 +00:00
|
|
|
}
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
}
|
2004-07-16 10:56:31 +00:00
|
|
|
|
|
|
|
|
2012-11-12 09:10:15 +00:00
|
|
|
static void
|
|
|
|
gst_pngdec_libpng_clear (GstPngDec * pngdec)
|
ext/libpng/gstpngdec.*: Complete rewrite of pngdec. It's now very nice and handle push/pull based model. if you have ...
Original commit message from CVS:
2005-10-19 Julien MOUTTE <julien@moutte.net>
* ext/libpng/gstpngdec.c: (gst_pngdec_class_init),
(gst_pngdec_init), (user_error_fn), (user_warning_fn),
(user_info_callback), (user_endrow_callback),
(user_end_callback),
(user_read_data), (gst_pngdec_caps_create_and_set),
(gst_pngdec_task), (gst_pngdec_chain), (gst_pngdec_sink_event),
(gst_pngdec_libpng_clear), (gst_pngdec_libpng_init),
(gst_pngdec_change_state), (gst_pngdec_sink_activate_push),
(gst_pngdec_sink_activate_pull), (gst_pngdec_sink_activate):
* ext/libpng/gstpngdec.h: Complete rewrite of pngdec. It's now
very nice and handle push/pull based model. if you have filesrc
connected to it, it will do random access to load the png file.
If you have a network source that can't do _getrange, it does
progressive loading through the chain function.
* gst/alpha/gstalphacolor.c: (gst_alpha_color_transform_caps),
(transform_rgb), (transform_bgr): Fix caps negotiation correctly
thanks to Master Wim Taymans ;-)
2005-10-18 22:44:11 +00:00
|
|
|
{
|
2012-04-07 07:52:09 +00:00
|
|
|
png_infopp info = NULL, endinfo = NULL;
|
2012-01-24 17:23:22 +00:00
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
GST_LOG ("cleaning up libpng structures");
|
2012-01-24 17:23:22 +00:00
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
if (pngdec->info) {
|
|
|
|
info = &pngdec->info;
|
2012-01-24 17:23:22 +00:00
|
|
|
}
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
if (pngdec->endinfo) {
|
|
|
|
endinfo = &pngdec->endinfo;
|
|
|
|
}
|
2012-01-24 17:23:22 +00:00
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
if (pngdec->png) {
|
|
|
|
png_destroy_read_struct (&(pngdec->png), info, endinfo);
|
|
|
|
pngdec->png = NULL;
|
|
|
|
pngdec->info = NULL;
|
|
|
|
pngdec->endinfo = NULL;
|
|
|
|
}
|
2012-01-24 17:23:22 +00:00
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
pngdec->color_type = -1;
|
2014-11-04 02:48:41 +00:00
|
|
|
pngdec->read_data = 0;
|
2012-11-12 09:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_pngdec_start (GstVideoDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstPngDec *pngdec = (GstPngDec *) decoder;
|
|
|
|
|
2013-05-07 14:30:59 +00:00
|
|
|
gst_video_decoder_set_packetized (GST_VIDEO_DECODER (pngdec), FALSE);
|
2012-11-12 09:10:15 +00:00
|
|
|
gst_pngdec_libpng_init (pngdec);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_pngdec_stop (GstVideoDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstPngDec *pngdec = (GstPngDec *) decoder;
|
|
|
|
|
|
|
|
gst_pngdec_libpng_clear (pngdec);
|
2012-01-24 17:23:22 +00:00
|
|
|
|
2012-06-07 10:16:50 +00:00
|
|
|
if (pngdec->input_state) {
|
|
|
|
gst_video_codec_state_unref (pngdec->input_state);
|
|
|
|
pngdec->input_state = NULL;
|
|
|
|
}
|
|
|
|
if (pngdec->output_state) {
|
|
|
|
gst_video_codec_state_unref (pngdec->output_state);
|
|
|
|
pngdec->output_state = NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-07 07:52:09 +00:00
|
|
|
return TRUE;
|
2004-07-16 10:56:31 +00:00
|
|
|
}
|
2012-11-12 09:10:15 +00:00
|
|
|
|
|
|
|
/* Clean up the libpng structures */
|
|
|
|
static gboolean
|
2013-08-15 13:08:05 +00:00
|
|
|
gst_pngdec_flush (GstVideoDecoder * decoder)
|
2012-11-12 09:10:15 +00:00
|
|
|
{
|
2012-11-12 09:44:01 +00:00
|
|
|
gst_pngdec_libpng_clear ((GstPngDec *) decoder);
|
|
|
|
gst_pngdec_libpng_init ((GstPngDec *) decoder);
|
2012-11-12 09:10:15 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|