2002-10-10 21:19:12 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2006-12-07 17:30:03 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-smpte
|
|
|
|
*
|
|
|
|
* smpte can accept I420 video streams with the same width, height and
|
|
|
|
* framerate. The two incomming buffers are blended together using an effect
|
|
|
|
* specific alpha mask.
|
2009-01-28 10:29:42 +00:00
|
|
|
*
|
|
|
|
* The #GstSmpte:depth property defines the presision in bits of the mask. A
|
|
|
|
* higher presision will create a mask with smoother gradients in order to avoid
|
2006-12-07 17:30:03 +00:00
|
|
|
* banding.
|
2009-01-28 10:29:42 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
2006-12-07 17:30:03 +00:00
|
|
|
* <title>Sample pipelines</title>
|
2009-01-28 10:29:42 +00:00
|
|
|
* |[
|
2012-08-26 21:39:55 +00:00
|
|
|
* gst-launch-1.0 -v videotestsrc pattern=1 ! smpte name=s border=20000 type=234 duration=2000000000 ! videoconvert ! ximagesink videotestsrc ! s.
|
2009-01-28 10:29:42 +00:00
|
|
|
* ]| A pipeline to demonstrate the smpte transition.
|
|
|
|
* It shows a pinwheel transition a from a snow videotestsrc to an smpte
|
2006-12-07 17:30:03 +00:00
|
|
|
* pattern videotestsrc. The transition will take 2 seconds to complete. The
|
|
|
|
* edges of the transition are smoothed with a 20000 big border.
|
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2002-10-10 21:19:12 +00:00
|
|
|
#include <string.h>
|
2004-07-27 21:51:32 +00:00
|
|
|
#include "gstsmpte.h"
|
2002-10-10 21:19:12 +00:00
|
|
|
#include "paint.h"
|
|
|
|
|
2006-12-07 17:30:03 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_smpte_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_smpte_debug
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate gst_smpte_src_template =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-03-22 17:21:52 +00:00
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("I420")
|
2004-03-14 22:34:33 +00:00
|
|
|
)
|
|
|
|
);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate gst_smpte_sink1_template =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink1",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-03-22 17:21:52 +00:00
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("I420")
|
2004-03-14 22:34:33 +00:00
|
|
|
)
|
|
|
|
);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate gst_smpte_sink2_template =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink2",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-03-22 17:21:52 +00:00
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("I420")
|
2004-03-14 22:34:33 +00:00
|
|
|
)
|
|
|
|
);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* SMPTE signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-10-10 21:19:12 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2006-12-07 17:30:03 +00:00
|
|
|
#define DEFAULT_PROP_TYPE 1
|
|
|
|
#define DEFAULT_PROP_BORDER 0
|
|
|
|
#define DEFAULT_PROP_DEPTH 16
|
|
|
|
#define DEFAULT_PROP_DURATION GST_SECOND
|
2010-04-15 20:28:58 +00:00
|
|
|
#define DEFAULT_PROP_INVERT FALSE
|
2006-12-07 17:30:03 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2006-12-07 17:30:03 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_TYPE,
|
|
|
|
PROP_BORDER,
|
|
|
|
PROP_DEPTH,
|
|
|
|
PROP_DURATION,
|
2010-04-15 20:28:58 +00:00
|
|
|
PROP_INVERT,
|
2006-12-07 17:30:03 +00:00
|
|
|
PROP_LAST,
|
2002-10-10 21:19:12 +00:00
|
|
|
};
|
|
|
|
|
2007-01-19 10:35:13 +00:00
|
|
|
#define I420_Y_ROWSTRIDE(width) (GST_ROUND_UP_4(width))
|
|
|
|
#define I420_U_ROWSTRIDE(width) (GST_ROUND_UP_8(width)/2)
|
|
|
|
#define I420_V_ROWSTRIDE(width) ((GST_ROUND_UP_8(I420_Y_ROWSTRIDE(width)))/2)
|
|
|
|
|
|
|
|
#define I420_Y_OFFSET(w,h) (0)
|
|
|
|
#define I420_U_OFFSET(w,h) (I420_Y_OFFSET(w,h)+(I420_Y_ROWSTRIDE(w)*GST_ROUND_UP_2(h)))
|
|
|
|
#define I420_V_OFFSET(w,h) (I420_U_OFFSET(w,h)+(I420_U_ROWSTRIDE(w)*GST_ROUND_UP_2(h)/2))
|
|
|
|
|
|
|
|
#define I420_SIZE(w,h) (I420_V_OFFSET(w,h)+(I420_V_ROWSTRIDE(w)*GST_ROUND_UP_2(h)/2))
|
|
|
|
|
|
|
|
|
2002-10-10 21:19:12 +00:00
|
|
|
#define GST_TYPE_SMPTE_TRANSITION_TYPE (gst_smpte_transition_type_get_type())
|
|
|
|
static GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_smpte_transition_type_get_type (void)
|
2002-10-10 21:19:12 +00:00
|
|
|
{
|
|
|
|
static GType smpte_transition_type = 0;
|
|
|
|
GEnumValue *smpte_transitions;
|
|
|
|
|
|
|
|
if (!smpte_transition_type) {
|
|
|
|
const GList *definitions;
|
2004-03-14 22:34:33 +00:00
|
|
|
gint i = 0;
|
2002-10-10 21:19:12 +00:00
|
|
|
|
|
|
|
definitions = gst_mask_get_definitions ();
|
2004-03-14 22:34:33 +00:00
|
|
|
smpte_transitions =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_new0 (GEnumValue, g_list_length ((GList *) definitions) + 1);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
|
|
|
while (definitions) {
|
|
|
|
GstMaskDefinition *definition = (GstMaskDefinition *) definitions->data;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-10-10 21:19:12 +00:00
|
|
|
definitions = g_list_next (definitions);
|
|
|
|
|
|
|
|
smpte_transitions[i].value = definition->type;
|
2007-02-06 16:29:30 +00:00
|
|
|
/* older GLib versions have the two fields as non-const, hence the cast */
|
|
|
|
smpte_transitions[i].value_nick = (gchar *) definition->short_name;
|
|
|
|
smpte_transitions[i].value_name = (gchar *) definition->long_name;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-10-10 21:19:12 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
smpte_transition_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_enum_register_static ("GstSMPTETransitionType", smpte_transitions);
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
|
|
|
return smpte_transition_type;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2002-10-10 21:19:12 +00:00
|
|
|
|
|
|
|
|
Fix a bunch of leaks shown by the newly-added states test.
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flac_enc_finalize):
* ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_class_init),
(gst_gconf_audio_sink_dispose), (gst_gconf_audio_sink_finalize):
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_base_init),
(gst_gconf_audio_src_class_init), (gst_gconf_audio_src_dispose),
(gst_gconf_audio_src_finalize), (do_toggle_element):
* ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_base_init),
(gst_gconf_video_sink_class_init), (gst_gconf_video_sink_finalize),
(do_toggle_element):
* ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_base_init),
(gst_gconf_video_src_class_init), (gst_gconf_video_src_dispose),
(gst_gconf_video_src_finalize), (do_toggle_element):
* ext/gconf/gstswitchsink.c: (gst_switch_sink_class_init),
(gst_switch_sink_reset), (gst_switch_sink_set_child):
* ext/hal/gsthalaudiosink.c: (gst_hal_audio_sink_base_init):
* ext/hal/gsthalaudiosrc.c: (gst_hal_audio_src_base_init):
* ext/shout2/gstshout2.c: (gst_shout2send_class_init),
(gst_shout2send_init), (gst_shout2send_finalize):
* gst/debug/testplugin.c: (gst_test_class_init),
(gst_test_finalize):
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(gst_flxdec_dispose):
* gst/multipart/multipartmux.c: (gst_multipart_mux_finalize):
* gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize):
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_init),
(gst_rtspsrc_finalize):
* gst/rtsp/rtspextwms.c: (rtsp_ext_wms_free_context):
* gst/rtsp/rtspextwms.h:
* gst/smpte/gstsmpte.c: (gst_smpte_class_init),
(gst_smpte_finalize):
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_finalize):
* gst/udp/gstudpsink.c: (gst_udpsink_class_init),
(gst_udpsink_finalize):
* gst/wavparse/gstwavparse.c: (gst_wavparse_dispose),
(gst_wavparse_sink_activate):
* sys/oss/gstosssink.c: (gst_oss_sink_finalise):
* sys/oss/gstosssrc.c: (gst_oss_src_class_init),
(gst_oss_src_finalize):
* sys/v4l2/gstv4l2object.c: (gst_v4l2_object_destroy):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_finalize):
* sys/ximage/gstximagesrc.c: (gst_ximage_src_ximage_get):
Fix a bunch of leaks shown by the newly-added states test.
2007-03-04 13:52:03 +00:00
|
|
|
static void gst_smpte_finalize (GstSMPTE * smpte);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2012-04-17 13:14:27 +00:00
|
|
|
static GstFlowReturn gst_smpte_collected (GstCollectPads * pads,
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
GstSMPTE * smpte);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_smpte_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_smpte_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2006-12-07 17:30:03 +00:00
|
|
|
static GstStateChangeReturn gst_smpte_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
|
|
|
|
2002-10-10 21:19:12 +00:00
|
|
|
/*static guint gst_smpte_signals[LAST_SIGNAL] = { 0 }; */
|
|
|
|
|
2012-04-13 14:54:53 +00:00
|
|
|
#define gst_smpte_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE (GstSMPTE, gst_smpte, GST_TYPE_ELEMENT);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_smpte_class_init (GstSMPTEClass * klass)
|
2002-10-10 21:19:12 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2006-04-08 21:21:45 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_smpte_set_property;
|
|
|
|
gobject_class->get_property = gst_smpte_get_property;
|
Fix a bunch of leaks shown by the newly-added states test.
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flac_enc_finalize):
* ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_class_init),
(gst_gconf_audio_sink_dispose), (gst_gconf_audio_sink_finalize):
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_base_init),
(gst_gconf_audio_src_class_init), (gst_gconf_audio_src_dispose),
(gst_gconf_audio_src_finalize), (do_toggle_element):
* ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_base_init),
(gst_gconf_video_sink_class_init), (gst_gconf_video_sink_finalize),
(do_toggle_element):
* ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_base_init),
(gst_gconf_video_src_class_init), (gst_gconf_video_src_dispose),
(gst_gconf_video_src_finalize), (do_toggle_element):
* ext/gconf/gstswitchsink.c: (gst_switch_sink_class_init),
(gst_switch_sink_reset), (gst_switch_sink_set_child):
* ext/hal/gsthalaudiosink.c: (gst_hal_audio_sink_base_init):
* ext/hal/gsthalaudiosrc.c: (gst_hal_audio_src_base_init):
* ext/shout2/gstshout2.c: (gst_shout2send_class_init),
(gst_shout2send_init), (gst_shout2send_finalize):
* gst/debug/testplugin.c: (gst_test_class_init),
(gst_test_finalize):
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(gst_flxdec_dispose):
* gst/multipart/multipartmux.c: (gst_multipart_mux_finalize):
* gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize):
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_init),
(gst_rtspsrc_finalize):
* gst/rtsp/rtspextwms.c: (rtsp_ext_wms_free_context):
* gst/rtsp/rtspextwms.h:
* gst/smpte/gstsmpte.c: (gst_smpte_class_init),
(gst_smpte_finalize):
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_finalize):
* gst/udp/gstudpsink.c: (gst_udpsink_class_init),
(gst_udpsink_finalize):
* gst/wavparse/gstwavparse.c: (gst_wavparse_dispose),
(gst_wavparse_sink_activate):
* sys/oss/gstosssink.c: (gst_oss_sink_finalise):
* sys/oss/gstosssrc.c: (gst_oss_src_class_init),
(gst_oss_src_finalize):
* sys/v4l2/gstv4l2object.c: (gst_v4l2_object_destroy):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_finalize):
* sys/ximage/gstximagesrc.c: (gst_ximage_src_ximage_get):
Fix a bunch of leaks shown by the newly-added states test.
2007-03-04 13:52:03 +00:00
|
|
|
gobject_class->finalize = (GObjectFinalizeFunc) gst_smpte_finalize;
|
2002-10-10 21:19:12 +00:00
|
|
|
|
|
|
|
_gst_mask_init ();
|
|
|
|
|
2006-12-07 17:30:03 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TYPE,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_enum ("type", "Type", "The type of transition to use",
|
2006-12-07 17:30:03 +00:00
|
|
|
GST_TYPE_SMPTE_TRANSITION_TYPE, DEFAULT_PROP_TYPE,
|
2010-10-13 14:21:23 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2006-12-07 17:30:03 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BORDER,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_int ("border", "Border",
|
2006-12-07 17:30:03 +00:00
|
|
|
"The border width of the transition", 0, G_MAXINT,
|
2010-10-13 14:21:23 +00:00
|
|
|
DEFAULT_PROP_BORDER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2006-12-07 17:30:03 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DEPTH,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_int ("depth", "Depth", "Depth of the mask in bits", 1, 24,
|
2010-10-13 14:21:23 +00:00
|
|
|
DEFAULT_PROP_DEPTH, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2006-12-07 17:30:03 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DURATION,
|
|
|
|
g_param_spec_uint64 ("duration", "Duration",
|
|
|
|
"Duration of the transition effect in nanoseconds", 0, G_MAXUINT64,
|
2010-10-13 14:21:23 +00:00
|
|
|
DEFAULT_PROP_DURATION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2010-04-15 20:28:58 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_INVERT,
|
|
|
|
g_param_spec_boolean ("invert", "Invert",
|
2010-10-13 14:21:23 +00:00
|
|
|
"Invert transition mask", DEFAULT_PROP_INVERT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2006-12-07 17:30:03 +00:00
|
|
|
|
|
|
|
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_smpte_change_state);
|
2012-03-22 17:21:52 +00:00
|
|
|
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&gst_smpte_sink1_template));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&gst_smpte_sink2_template));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&gst_smpte_src_template));
|
2012-04-09 23:51:41 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class, "SMPTE transitions",
|
2012-03-22 17:21:52 +00:00
|
|
|
"Filter/Editor/Video",
|
|
|
|
"Apply the standard SMPTE transitions on video images",
|
|
|
|
"Wim Taymans <wim.taymans@chello.be>");
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
|
|
|
|
2007-01-19 13:06:07 +00:00
|
|
|
/* wht yel cya grn mag red blu blk -I Q */
|
|
|
|
static const int y_colors[] = { 255, 226, 179, 150, 105, 76, 29, 16, 16, 0 };
|
|
|
|
static const int u_colors[] = { 128, 0, 170, 46, 212, 85, 255, 128, 0, 128 };
|
|
|
|
static const int v_colors[] = { 128, 155, 0, 21, 235, 255, 107, 128, 128, 255 };
|
2002-10-10 21:19:12 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
fill_i420 (guint8 * data, gint width, gint height, gint color)
|
2002-10-10 21:19:12 +00:00
|
|
|
{
|
2007-01-19 10:35:13 +00:00
|
|
|
gint size = I420_Y_ROWSTRIDE (width) * GST_ROUND_UP_2 (height);
|
|
|
|
gint size4 = size >> 2;
|
2002-10-10 21:19:12 +00:00
|
|
|
guint8 *yp = data;
|
2007-01-19 10:35:13 +00:00
|
|
|
guint8 *up = data + I420_U_OFFSET (width, height);
|
|
|
|
guint8 *vp = data + I420_V_OFFSET (width, height);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-10-13 18:46:10 +00:00
|
|
|
memset (yp, y_colors[color], size);
|
|
|
|
memset (up, u_colors[color], size4);
|
|
|
|
memset (vp, v_colors[color], size4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2010-04-15 20:28:58 +00:00
|
|
|
gst_smpte_update_mask (GstSMPTE * smpte, gint type, gboolean invert,
|
|
|
|
gint depth, gint width, gint height)
|
2002-10-13 18:46:10 +00:00
|
|
|
{
|
|
|
|
GstMask *newmask;
|
|
|
|
|
2007-01-23 17:27:39 +00:00
|
|
|
if (smpte->mask) {
|
|
|
|
if (smpte->type == type &&
|
2010-04-15 20:28:58 +00:00
|
|
|
smpte->invert == invert &&
|
2007-01-23 17:27:39 +00:00
|
|
|
smpte->depth == depth &&
|
|
|
|
smpte->width == width && smpte->height == height)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-04-15 20:28:58 +00:00
|
|
|
newmask = gst_mask_factory_new (type, invert, depth, width, height);
|
2002-10-13 18:46:10 +00:00
|
|
|
if (newmask) {
|
|
|
|
if (smpte->mask) {
|
|
|
|
gst_mask_destroy (smpte->mask);
|
|
|
|
}
|
|
|
|
smpte->mask = newmask;
|
|
|
|
smpte->type = type;
|
2010-04-15 20:28:58 +00:00
|
|
|
smpte->invert = invert;
|
2002-10-13 18:46:10 +00:00
|
|
|
smpte->depth = depth;
|
|
|
|
smpte->width = width;
|
|
|
|
smpte->height = height;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
gst_smpte_setcaps (GstPad * pad, GstCaps * caps)
|
2002-10-10 21:19:12 +00:00
|
|
|
{
|
|
|
|
GstSMPTE *smpte;
|
2003-12-22 01:47:09 +00:00
|
|
|
gboolean ret;
|
2012-03-22 17:21:52 +00:00
|
|
|
GstVideoInfo vinfo;
|
2002-10-10 21:19:12 +00:00
|
|
|
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
smpte = GST_SMPTE (GST_PAD_PARENT (pad));
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2012-03-22 17:21:52 +00:00
|
|
|
gst_video_info_init (&vinfo);
|
|
|
|
if (!gst_video_info_from_caps (&vinfo, caps))
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
return FALSE;
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2012-03-22 17:21:52 +00:00
|
|
|
smpte->width = GST_VIDEO_INFO_WIDTH (&vinfo);
|
|
|
|
smpte->height = GST_VIDEO_INFO_HEIGHT (&vinfo);
|
|
|
|
smpte->fps_num = GST_VIDEO_INFO_FPS_N (&vinfo);
|
|
|
|
smpte->fps_denom = GST_VIDEO_INFO_FPS_D (&vinfo);
|
|
|
|
|
2006-12-07 17:30:03 +00:00
|
|
|
/* figure out the duration in frames */
|
|
|
|
smpte->end_position = gst_util_uint64_scale (smpte->duration,
|
|
|
|
smpte->fps_num, GST_SECOND * smpte->fps_denom);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (smpte, "duration: %d frames", smpte->end_position);
|
|
|
|
|
2010-04-15 20:28:58 +00:00
|
|
|
ret =
|
|
|
|
gst_smpte_update_mask (smpte, smpte->type, smpte->invert, smpte->depth,
|
|
|
|
smpte->width, smpte->height);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2012-03-22 17:21:52 +00:00
|
|
|
if (pad == smpte->sinkpad1) {
|
|
|
|
GST_DEBUG_OBJECT (smpte, "setting pad1 info");
|
|
|
|
smpte->vinfo1 = vinfo;
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (smpte, "setting pad2 info");
|
|
|
|
smpte->vinfo2 = vinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-04-17 13:14:27 +00:00
|
|
|
gst_smpte_sink_event (GstCollectPads * pads,
|
|
|
|
GstCollectData * data, GstEvent * event, gpointer user_data)
|
2012-03-22 17:21:52 +00:00
|
|
|
{
|
|
|
|
GstPad *pad;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
pad = data->pad;
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_CAPS:
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
gst_event_parse_caps (event, &caps);
|
|
|
|
ret = gst_smpte_setcaps (pad, caps);
|
|
|
|
gst_event_unref (event);
|
|
|
|
event = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-04-16 14:37:49 +00:00
|
|
|
break;
|
2012-03-22 17:21:52 +00:00
|
|
|
}
|
|
|
|
|
2012-04-16 14:37:49 +00:00
|
|
|
if (event != NULL)
|
2012-04-17 13:14:27 +00:00
|
|
|
return gst_collect_pads_event_default (pads, data, event, FALSE);
|
2012-04-16 14:37:49 +00:00
|
|
|
|
2006-12-07 17:30:03 +00:00
|
|
|
return ret;
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_smpte_init (GstSMPTE * smpte)
|
2002-10-10 21:19:12 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
smpte->sinkpad1 =
|
2006-03-15 16:17:12 +00:00
|
|
|
gst_pad_new_from_static_template (&gst_smpte_sink1_template, "sink1");
|
2012-03-22 17:21:52 +00:00
|
|
|
GST_PAD_SET_PROXY_CAPS (smpte->sinkpad1);
|
2002-10-10 21:19:12 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad1);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
smpte->sinkpad2 =
|
2006-03-15 16:17:12 +00:00
|
|
|
gst_pad_new_from_static_template (&gst_smpte_sink2_template, "sink2");
|
2012-03-22 17:21:52 +00:00
|
|
|
GST_PAD_SET_PROXY_CAPS (smpte->sinkpad2);
|
2002-10-10 21:19:12 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad2);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
smpte->srcpad =
|
2006-03-15 16:17:12 +00:00
|
|
|
gst_pad_new_from_static_template (&gst_smpte_src_template, "src");
|
2002-10-10 21:19:12 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (smpte), smpte->srcpad);
|
|
|
|
|
2012-04-17 13:14:27 +00:00
|
|
|
smpte->collect = gst_collect_pads_new ();
|
|
|
|
gst_collect_pads_set_function (smpte->collect,
|
|
|
|
(GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_smpte_collected), smpte);
|
|
|
|
gst_collect_pads_set_event_function (smpte->collect,
|
2012-03-22 17:21:52 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_smpte_sink_event), smpte);
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
|
2012-04-17 13:14:27 +00:00
|
|
|
gst_collect_pads_add_pad (smpte->collect, smpte->sinkpad1,
|
2012-09-12 19:05:44 +00:00
|
|
|
sizeof (GstCollectData), NULL, TRUE);
|
2012-04-17 13:14:27 +00:00
|
|
|
gst_collect_pads_add_pad (smpte->collect, smpte->sinkpad2,
|
2012-09-12 19:05:44 +00:00
|
|
|
sizeof (GstCollectData), NULL, TRUE);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2006-12-07 17:30:03 +00:00
|
|
|
smpte->type = DEFAULT_PROP_TYPE;
|
|
|
|
smpte->border = DEFAULT_PROP_BORDER;
|
|
|
|
smpte->depth = DEFAULT_PROP_DEPTH;
|
|
|
|
smpte->duration = DEFAULT_PROP_DURATION;
|
2010-04-15 20:28:58 +00:00
|
|
|
smpte->invert = DEFAULT_PROP_INVERT;
|
2006-12-07 17:30:03 +00:00
|
|
|
smpte->fps_num = 0;
|
|
|
|
smpte->fps_denom = 1;
|
|
|
|
}
|
|
|
|
|
Fix a bunch of leaks shown by the newly-added states test.
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flac_enc_finalize):
* ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_class_init),
(gst_gconf_audio_sink_dispose), (gst_gconf_audio_sink_finalize):
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_base_init),
(gst_gconf_audio_src_class_init), (gst_gconf_audio_src_dispose),
(gst_gconf_audio_src_finalize), (do_toggle_element):
* ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_base_init),
(gst_gconf_video_sink_class_init), (gst_gconf_video_sink_finalize),
(do_toggle_element):
* ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_base_init),
(gst_gconf_video_src_class_init), (gst_gconf_video_src_dispose),
(gst_gconf_video_src_finalize), (do_toggle_element):
* ext/gconf/gstswitchsink.c: (gst_switch_sink_class_init),
(gst_switch_sink_reset), (gst_switch_sink_set_child):
* ext/hal/gsthalaudiosink.c: (gst_hal_audio_sink_base_init):
* ext/hal/gsthalaudiosrc.c: (gst_hal_audio_src_base_init):
* ext/shout2/gstshout2.c: (gst_shout2send_class_init),
(gst_shout2send_init), (gst_shout2send_finalize):
* gst/debug/testplugin.c: (gst_test_class_init),
(gst_test_finalize):
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(gst_flxdec_dispose):
* gst/multipart/multipartmux.c: (gst_multipart_mux_finalize):
* gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize):
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_init),
(gst_rtspsrc_finalize):
* gst/rtsp/rtspextwms.c: (rtsp_ext_wms_free_context):
* gst/rtsp/rtspextwms.h:
* gst/smpte/gstsmpte.c: (gst_smpte_class_init),
(gst_smpte_finalize):
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_finalize):
* gst/udp/gstudpsink.c: (gst_udpsink_class_init),
(gst_udpsink_finalize):
* gst/wavparse/gstwavparse.c: (gst_wavparse_dispose),
(gst_wavparse_sink_activate):
* sys/oss/gstosssink.c: (gst_oss_sink_finalise):
* sys/oss/gstosssrc.c: (gst_oss_src_class_init),
(gst_oss_src_finalize):
* sys/v4l2/gstv4l2object.c: (gst_v4l2_object_destroy):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_finalize):
* sys/ximage/gstximagesrc.c: (gst_ximage_src_ximage_get):
Fix a bunch of leaks shown by the newly-added states test.
2007-03-04 13:52:03 +00:00
|
|
|
static void
|
|
|
|
gst_smpte_finalize (GstSMPTE * smpte)
|
|
|
|
{
|
|
|
|
if (smpte->collect) {
|
|
|
|
gst_object_unref (smpte->collect);
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize ((GObject *) smpte);
|
|
|
|
}
|
|
|
|
|
2006-12-07 17:30:03 +00:00
|
|
|
static void
|
|
|
|
gst_smpte_reset (GstSMPTE * smpte)
|
|
|
|
{
|
|
|
|
smpte->width = -1;
|
|
|
|
smpte->height = -1;
|
2002-10-10 21:19:12 +00:00
|
|
|
smpte->position = 0;
|
2006-12-07 17:30:03 +00:00
|
|
|
smpte->end_position = 0;
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-03-22 17:21:52 +00:00
|
|
|
gst_smpte_blend_i420 (GstVideoFrame * frame1, GstVideoFrame * frame2,
|
|
|
|
GstVideoFrame * oframe, GstMask * mask, gint border, gint pos)
|
2002-10-10 21:19:12 +00:00
|
|
|
{
|
2002-10-13 18:46:10 +00:00
|
|
|
guint32 *maskp;
|
|
|
|
gint value;
|
2002-10-17 21:36:20 +00:00
|
|
|
gint i, j;
|
2002-10-13 18:46:10 +00:00
|
|
|
gint min, max;
|
2012-03-22 17:21:52 +00:00
|
|
|
guint8 *in1, *in2, *out, *in1u, *in1v, *in2u, *in2v, *outu, *outv;
|
|
|
|
gint width, height;
|
2002-10-13 18:46:10 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (border == 0)
|
|
|
|
border++;
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
min = pos - border;
|
2002-10-13 18:46:10 +00:00
|
|
|
max = pos;
|
|
|
|
|
2012-03-22 17:21:52 +00:00
|
|
|
width = GST_VIDEO_FRAME_WIDTH (frame1);
|
|
|
|
height = GST_VIDEO_FRAME_HEIGHT (frame1);
|
2012-03-12 13:48:47 +00:00
|
|
|
|
2012-03-22 17:21:52 +00:00
|
|
|
in1 = GST_VIDEO_FRAME_COMP_DATA (frame1, 0);
|
|
|
|
in2 = GST_VIDEO_FRAME_COMP_DATA (frame2, 0);
|
|
|
|
out = GST_VIDEO_FRAME_COMP_DATA (oframe, 0);
|
2012-03-12 13:48:47 +00:00
|
|
|
|
2012-03-22 17:21:52 +00:00
|
|
|
in1u = GST_VIDEO_FRAME_COMP_DATA (frame1, 1);
|
|
|
|
in1v = GST_VIDEO_FRAME_COMP_DATA (frame1, 2);
|
|
|
|
in2u = GST_VIDEO_FRAME_COMP_DATA (frame2, 1);
|
|
|
|
in2v = GST_VIDEO_FRAME_COMP_DATA (frame2, 2);
|
|
|
|
outu = GST_VIDEO_FRAME_COMP_DATA (oframe, 1);
|
|
|
|
outv = GST_VIDEO_FRAME_COMP_DATA (oframe, 2);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-10-13 18:46:10 +00:00
|
|
|
maskp = mask->data;
|
|
|
|
|
2002-10-17 21:36:20 +00:00
|
|
|
for (i = 0; i < height; i++) {
|
|
|
|
for (j = 0; j < width; j++) {
|
|
|
|
value = *maskp++;
|
|
|
|
value = ((CLAMP (value, min, max) - min) << 8) / border;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2012-03-12 13:48:47 +00:00
|
|
|
out[j] = ((in1[j] * value) + (in2[j] * (256 - value))) >> 8;
|
2002-10-17 21:36:20 +00:00
|
|
|
if (!(i & 1) && !(j & 1)) {
|
2012-03-12 13:48:47 +00:00
|
|
|
outu[j / 2] =
|
|
|
|
((in1u[j / 2] * value) + (in2u[j / 2] * (256 - value))) >> 8;
|
|
|
|
outv[j / 2] =
|
|
|
|
((in1v[j / 2] * value) + (in2v[j / 2] * (256 - value))) >> 8;
|
2002-10-17 21:36:20 +00:00
|
|
|
}
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
2012-03-22 17:21:52 +00:00
|
|
|
|
|
|
|
in1 += GST_VIDEO_FRAME_COMP_STRIDE (frame1, 0);
|
|
|
|
in2 += GST_VIDEO_FRAME_COMP_STRIDE (frame2, 0);
|
|
|
|
out += GST_VIDEO_FRAME_COMP_STRIDE (oframe, 0);
|
|
|
|
|
2012-03-12 13:48:47 +00:00
|
|
|
if (!(i & 1)) {
|
2012-03-22 17:21:52 +00:00
|
|
|
in1u += GST_VIDEO_FRAME_COMP_STRIDE (frame1, 1);
|
|
|
|
in2u += GST_VIDEO_FRAME_COMP_STRIDE (frame2, 1);
|
|
|
|
in1v += GST_VIDEO_FRAME_COMP_STRIDE (frame1, 2);
|
|
|
|
in2v += GST_VIDEO_FRAME_COMP_STRIDE (frame1, 2);
|
|
|
|
outu += GST_VIDEO_FRAME_COMP_STRIDE (oframe, 1);
|
|
|
|
outv += GST_VIDEO_FRAME_COMP_STRIDE (oframe, 2);
|
2012-03-12 13:48:47 +00:00
|
|
|
}
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
static GstFlowReturn
|
2012-04-17 13:14:27 +00:00
|
|
|
gst_smpte_collected (GstCollectPads * pads, GstSMPTE * smpte)
|
2002-10-10 21:19:12 +00:00
|
|
|
{
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
GstClockTime ts;
|
|
|
|
GstBuffer *in1 = NULL, *in2 = NULL;
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
GSList *collected;
|
2012-03-22 17:21:52 +00:00
|
|
|
GstMapInfo map;
|
|
|
|
GstVideoFrame frame1, frame2, oframe;
|
2002-10-10 21:19:12 +00:00
|
|
|
|
2007-01-19 13:06:07 +00:00
|
|
|
if (G_UNLIKELY (smpte->fps_num == 0))
|
|
|
|
goto not_negotiated;
|
|
|
|
|
2012-03-22 17:21:52 +00:00
|
|
|
if (!gst_pad_has_current_caps (smpte->sinkpad1) ||
|
|
|
|
!gst_pad_has_current_caps (smpte->sinkpad2))
|
2006-12-07 17:30:03 +00:00
|
|
|
goto not_negotiated;
|
|
|
|
|
|
|
|
ts = gst_util_uint64_scale_int (smpte->position * GST_SECOND,
|
|
|
|
smpte->fps_denom, smpte->fps_num);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
for (collected = pads->data; collected; collected = g_slist_next (collected)) {
|
2012-04-17 13:14:27 +00:00
|
|
|
GstCollectData *data;
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
|
2012-04-17 13:14:27 +00:00
|
|
|
data = (GstCollectData *) collected->data;
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
|
|
|
|
if (data->pad == smpte->sinkpad1)
|
2012-04-17 13:14:27 +00:00
|
|
|
in1 = gst_collect_pads_pop (pads, data);
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
else if (data->pad == smpte->sinkpad2)
|
2012-04-17 13:14:27 +00:00
|
|
|
in2 = gst_collect_pads_pop (pads, data);
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
2003-02-25 21:34:10 +00:00
|
|
|
|
|
|
|
if (in1 == NULL) {
|
2006-12-07 17:30:03 +00:00
|
|
|
/* if no input, make picture black */
|
2007-01-19 10:35:13 +00:00
|
|
|
in1 = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
|
2012-03-22 17:21:52 +00:00
|
|
|
gst_buffer_map (in1, &map, GST_MAP_WRITE);
|
|
|
|
fill_i420 (map.data, smpte->width, smpte->height, 7);
|
|
|
|
gst_buffer_unmap (in1, &map);
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
2003-02-25 21:34:10 +00:00
|
|
|
if (in2 == NULL) {
|
2006-12-07 17:30:03 +00:00
|
|
|
/* if no input, make picture white */
|
2007-01-19 10:35:13 +00:00
|
|
|
in2 = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
|
2012-03-22 17:21:52 +00:00
|
|
|
gst_buffer_map (in2, &map, GST_MAP_WRITE);
|
|
|
|
fill_i420 (map.data, smpte->width, smpte->height, 0);
|
|
|
|
gst_buffer_unmap (in1, &map);
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
|
|
|
|
2012-03-22 17:21:52 +00:00
|
|
|
if (GST_VIDEO_INFO_WIDTH (&smpte->vinfo1) !=
|
|
|
|
GST_VIDEO_INFO_WIDTH (&smpte->vinfo2) ||
|
|
|
|
GST_VIDEO_INFO_HEIGHT (&smpte->vinfo1) !=
|
|
|
|
GST_VIDEO_INFO_HEIGHT (&smpte->vinfo2))
|
2007-01-19 13:06:07 +00:00
|
|
|
goto input_formats_do_not_match;
|
|
|
|
|
2006-12-07 17:30:03 +00:00
|
|
|
if (smpte->position < smpte->end_position) {
|
2007-01-19 10:35:13 +00:00
|
|
|
outbuf = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
|
2002-10-10 21:19:12 +00:00
|
|
|
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
/* set caps if not done yet */
|
2012-03-22 17:21:52 +00:00
|
|
|
if (!gst_pad_has_current_caps (smpte->srcpad)) {
|
2003-12-22 01:47:09 +00:00
|
|
|
GstCaps *caps;
|
2012-03-22 17:21:52 +00:00
|
|
|
GstSegment segment;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
caps =
|
2012-03-27 14:41:06 +00:00
|
|
|
gst_caps_make_writable (gst_static_caps_get
|
2009-01-28 10:29:42 +00:00
|
|
|
(&gst_smpte_src_template.static_caps));
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_caps_set_simple (caps, "width", G_TYPE_INT, smpte->width, "height",
|
2006-12-07 17:30:03 +00:00
|
|
|
G_TYPE_INT, smpte->height, "framerate", GST_TYPE_FRACTION,
|
|
|
|
smpte->fps_num, smpte->fps_denom, NULL);
|
2003-12-22 01:47:09 +00:00
|
|
|
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
gst_pad_set_caps (smpte->srcpad, caps);
|
2012-03-27 14:41:06 +00:00
|
|
|
gst_caps_unref (caps);
|
2006-12-07 17:30:03 +00:00
|
|
|
|
2012-03-22 17:21:52 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
|
|
|
gst_pad_push_event (smpte->srcpad, gst_event_new_segment (&segment));
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
|
|
|
|
2012-03-22 17:21:52 +00:00
|
|
|
gst_video_frame_map (&frame1, &smpte->vinfo1, in1, GST_MAP_READ);
|
|
|
|
gst_video_frame_map (&frame2, &smpte->vinfo2, in2, GST_MAP_READ);
|
|
|
|
/* re-use either info, now know they are essentially identical */
|
|
|
|
gst_video_frame_map (&oframe, &smpte->vinfo1, outbuf, GST_MAP_WRITE);
|
|
|
|
gst_smpte_blend_i420 (&frame1, &frame2, &oframe, smpte->mask, smpte->border,
|
2004-03-15 19:32:27 +00:00
|
|
|
((1 << smpte->depth) + smpte->border) *
|
2006-12-07 17:30:03 +00:00
|
|
|
smpte->position / smpte->end_position);
|
2012-03-22 17:21:52 +00:00
|
|
|
gst_video_frame_unmap (&frame1);
|
|
|
|
gst_video_frame_unmap (&frame2);
|
|
|
|
gst_video_frame_unmap (&oframe);
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2002-10-10 21:19:12 +00:00
|
|
|
outbuf = in2;
|
|
|
|
gst_buffer_ref (in2);
|
|
|
|
}
|
|
|
|
|
|
|
|
smpte->position++;
|
|
|
|
|
|
|
|
if (in1)
|
|
|
|
gst_buffer_unref (in1);
|
|
|
|
if (in2)
|
|
|
|
gst_buffer_unref (in2);
|
|
|
|
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = ts;
|
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm sure someone will fix it.
Original commit message from CVS:
* configure.ac:
* ext/aalib/Makefile.am:
* ext/aalib/gstaasink.c: (gst_aasink_get_type),
(gst_aasink_class_init), (gst_aasink_fixate), (gst_aasink_setcaps),
(gst_aasink_init), (gst_aasink_get_times), (gst_aasink_render),
(gst_aasink_set_property), (gst_aasink_get_property),
(gst_aasink_open), (gst_aasink_close), (gst_aasink_change_state):
* ext/aalib/gstaasink.h:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_setcaps), (gst_smpte_init),
(gst_smpte_collected):
* gst/smpte/gstsmpte.h:
Ported 2 more plugins. usgly hack in the Makefile.am though, I'm
sure someone will fix it.
2005-05-06 19:55:22 +00:00
|
|
|
|
|
|
|
return gst_pad_push (smpte->srcpad, outbuf);
|
2006-12-07 17:30:03 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
not_negotiated:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (smpte, CORE, NEGOTIATION, (NULL),
|
|
|
|
("No input format negotiated"));
|
|
|
|
return GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
}
|
2007-01-19 13:06:07 +00:00
|
|
|
input_formats_do_not_match:
|
|
|
|
{
|
2012-03-22 17:21:52 +00:00
|
|
|
GstCaps *caps1, *caps2;
|
|
|
|
|
|
|
|
caps1 = gst_pad_get_current_caps (smpte->sinkpad1);
|
|
|
|
caps2 = gst_pad_get_current_caps (smpte->sinkpad2);
|
2007-01-19 13:06:07 +00:00
|
|
|
GST_ELEMENT_ERROR (smpte, CORE, NEGOTIATION, (NULL),
|
|
|
|
("input formats don't match: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
|
2012-03-22 17:21:52 +00:00
|
|
|
caps1, caps2));
|
|
|
|
gst_caps_unref (caps1);
|
|
|
|
gst_caps_unref (caps2);
|
2007-01-19 13:06:07 +00:00
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_smpte_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2002-10-10 21:19:12 +00:00
|
|
|
{
|
|
|
|
GstSMPTE *smpte;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
smpte = GST_SMPTE (object);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2006-12-07 17:30:03 +00:00
|
|
|
case PROP_TYPE:
|
|
|
|
smpte->type = g_value_get_enum (value);
|
2002-10-13 18:46:10 +00:00
|
|
|
break;
|
2006-12-07 17:30:03 +00:00
|
|
|
case PROP_BORDER:
|
2002-10-13 18:46:10 +00:00
|
|
|
smpte->border = g_value_get_int (value);
|
|
|
|
break;
|
2006-12-07 17:30:03 +00:00
|
|
|
case PROP_DEPTH:
|
|
|
|
smpte->depth = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case PROP_DURATION:
|
|
|
|
smpte->duration = g_value_get_uint64 (value);
|
2002-10-10 21:19:12 +00:00
|
|
|
break;
|
2010-04-15 20:28:58 +00:00
|
|
|
case PROP_INVERT:
|
|
|
|
smpte->invert = g_value_get_boolean (value);
|
|
|
|
break;
|
2002-10-10 21:19:12 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_smpte_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
2002-10-10 21:19:12 +00:00
|
|
|
{
|
|
|
|
GstSMPTE *smpte;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
smpte = GST_SMPTE (object);
|
2002-10-10 21:19:12 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2006-12-07 17:30:03 +00:00
|
|
|
case PROP_TYPE:
|
|
|
|
g_value_set_enum (value, smpte->type);
|
2002-10-10 21:19:12 +00:00
|
|
|
break;
|
2006-12-07 17:30:03 +00:00
|
|
|
case PROP_BORDER:
|
2002-10-13 18:46:10 +00:00
|
|
|
g_value_set_int (value, smpte->border);
|
|
|
|
break;
|
2006-12-07 17:30:03 +00:00
|
|
|
case PROP_DEPTH:
|
2002-10-13 18:46:10 +00:00
|
|
|
g_value_set_int (value, smpte->depth);
|
|
|
|
break;
|
2006-12-07 17:30:03 +00:00
|
|
|
case PROP_DURATION:
|
|
|
|
g_value_set_uint64 (value, smpte->duration);
|
|
|
|
break;
|
2010-04-15 20:28:58 +00:00
|
|
|
case PROP_INVERT:
|
|
|
|
g_value_set_boolean (value, smpte->invert);
|
|
|
|
break;
|
2002-10-10 21:19:12 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-07 17:30:03 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_smpte_change_state (GstElement * element, GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstStateChangeReturn ret;
|
|
|
|
GstSMPTE *smpte;
|
|
|
|
|
|
|
|
smpte = GST_SMPTE (element);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
|
|
|
gst_smpte_reset (smpte);
|
|
|
|
GST_LOG_OBJECT (smpte, "starting collectpads");
|
2012-04-17 13:14:27 +00:00
|
|
|
gst_collect_pads_start (smpte->collect);
|
2006-12-07 17:30:03 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
GST_LOG_OBJECT (smpte, "stopping collectpads");
|
2012-04-17 13:14:27 +00:00
|
|
|
gst_collect_pads_stop (smpte->collect);
|
2006-12-07 17:30:03 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-04-13 14:54:53 +00:00
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2006-12-07 17:30:03 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
gst_smpte_reset (smpte);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2002-10-10 21:19:12 +00:00
|
|
|
|
gst/smpte/: Add new plugin that adds the SMPTE transition in the alpha channel of
Original commit message from CVS:
* gst/smpte/Makefile.am:
* gst/smpte/gstsmpte.c: (gst_smpte_plugin_init):
* gst/smpte/gstsmpte.h:
* gst/smpte/gstsmptealpha.c:
(gst_smpte_alpha_transition_type_get_type),
(gst_smpte_alpha_get_type), (gst_smpte_alpha_base_init),
(gst_smpte_alpha_class_init), (gst_smpte_alpha_update_mask),
(gst_smpte_alpha_setcaps), (gst_smpte_alpha_get_unit_size),
(gst_smpte_alpha_init), (gst_smpte_alpha_finalize),
(gst_smpte_alpha_do_ayuv), (gst_smpte_alpha_do_i420),
(gst_smpte_alpha_transform), (gst_smpte_alpha_set_property),
(gst_smpte_alpha_get_property), (gst_smpte_alpha_plugin_init):
* gst/smpte/gstsmptealpha.h:
* gst/smpte/plugin.c: (plugin_init):
Add new plugin that adds the SMPTE transition in the alpha channel of
I420 and AYUV frames so that they can be blended with videomixer later
on. Uses all niceties such as using base transform for efficient alloc
and negotiation. It currently requires GstController to control the
position in the transition effect.
2008-05-20 09:29:28 +00:00
|
|
|
gboolean
|
|
|
|
gst_smpte_plugin_init (GstPlugin * plugin)
|
2002-10-10 21:19:12 +00:00
|
|
|
{
|
2006-12-07 17:30:03 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_smpte_debug, "smpte", 0,
|
|
|
|
"SMPTE transition effect");
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
return gst_element_register (plugin, "smpte", GST_RANK_NONE, GST_TYPE_SMPTE);
|
2002-10-10 21:19:12 +00:00
|
|
|
}
|