gstreamer/gst/smpte/gstsmpte.c

651 lines
19 KiB
C
Raw Normal View History

/* 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.
*/
/**
* SECTION:element-smpte
* @short_description: Takes to video frames and applies an SMPTE transition
* effect on them.
*
* <refsect2>
* <para>
* 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.
* </para>
* <para>
* The depth property defines the presision in bits of the mask. A higher
* presision will create a mask with smoother gradients in order to avoid
* banding.
* </para>
* <title>Sample pipelines</title>
* <para>
* Here is a pipeline to demonstrate the smpte transition :
* <programlisting>
* gst-launch -v videotestsrc pattern=1 ! smpte name=s border=20000 type=234
* duration=2000000000 ! ffmpegcolorspace ! ximagesink videotestsrc ! s.
* </programlisting>
* This shows a pinwheel transition a from a snow videotestsrc to an smpte
* pattern videotestsrc. The transition will take 2 seconds to complete. The
* edges of the transition are smoothed with a 20000 big border.
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include "gstsmpte.h"
#include <gst/video/video.h>
#include "paint.h"
GST_DEBUG_CATEGORY_STATIC (gst_smpte_debug);
#define GST_CAT_DEFAULT gst_smpte_debug
/* elementfactory information */
Define GstElementDetails as const and also static (when defined as global) Original commit message from CVS: * ext/aalib/gstaasink.c: * ext/annodex/gstcmmldec.c: * ext/annodex/gstcmmlenc.c: * ext/cairo/gsttextoverlay.c: * ext/cairo/gsttimeoverlay.c: * ext/cdio/gstcdiocddasrc.c: * ext/dv/gstdvdec.c: * ext/dv/gstdvdemux.c: * ext/esd/esdmon.c: * ext/esd/esdsink.c: * ext/flac/gstflacenc.c: * ext/flac/gstflactag.c: * ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_base_init): * ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_base_init): * ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_base_init): * ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_base_init): * ext/gdk_pixbuf/pixbufscale.c: * ext/hal/gsthalaudiosink.c: (gst_hal_audio_sink_base_init): * ext/hal/gsthalaudiosrc.c: (gst_hal_audio_src_base_init): * ext/jpeg/gstjpegdec.c: * ext/jpeg/gstjpegenc.c: * ext/jpeg/gstsmokedec.c: * ext/jpeg/gstsmokeenc.c: * ext/libcaca/gstcacasink.c: * ext/libmng/gstmngdec.c: * ext/libmng/gstmngenc.c: * ext/libpng/gstpngdec.c: * ext/libpng/gstpngenc.c: * ext/mikmod/gstmikmod.c: * ext/raw1394/gstdv1394src.c: * ext/shout2/gstshout2.c: (gst_shout2send_init): * ext/shout2/gstshout2.h: * ext/speex/gstspeexdec.c: * ext/speex/gstspeexenc.c: * gst/alpha/gstalpha.c: * gst/alpha/gstalphacolor.c: * gst/apetag/gstapedemux.c: * gst/auparse/gstauparse.c: * gst/autodetect/gstautoaudiosink.c: (gst_auto_audio_sink_base_init): * gst/autodetect/gstautovideosink.c: (gst_auto_video_sink_base_init): * gst/avi/gstavidemux.c: (gst_avi_demux_base_init): * gst/avi/gstavimux.c: (gst_avimux_base_init): * gst/cutter/gstcutter.c: * gst/debug/breakmydata.c: * gst/debug/efence.c: * gst/debug/gstnavigationtest.c: * gst/debug/gstnavseek.c: * gst/debug/negotiation.c: * gst/debug/progressreport.c: * gst/debug/testplugin.c: * gst/effectv/gstaging.c: * gst/effectv/gstdice.c: * gst/effectv/gstedge.c: * gst/effectv/gstquark.c: * gst/effectv/gstrev.c: * gst/effectv/gstshagadelic.c: * gst/effectv/gstvertigo.c: * gst/effectv/gstwarp.c: * gst/flx/gstflxdec.c: * gst/goom/gstgoom.c: * gst/icydemux/gsticydemux.c: * gst/id3demux/gstid3demux.c: * gst/interleave/deinterleave.c: * gst/interleave/interleave.c: * gst/law/alaw-decode.c: (gst_alawdec_base_init): * gst/law/alaw-encode.c: (gst_alawenc_base_init): * gst/law/mulaw-decode.c: (gst_mulawdec_base_init): * gst/law/mulaw-encode.c: (gst_mulawenc_base_init): * gst/level/gstlevel.c: * gst/matroska/matroska-demux.c: (gst_matroska_demux_base_init): * gst/matroska/matroska-mux.c: (gst_matroska_mux_base_init): * gst/median/gstmedian.c: * gst/monoscope/gstmonoscope.c: * gst/multipart/multipartdemux.c: * gst/multipart/multipartmux.c: * gst/oldcore/gstaggregator.c: * gst/oldcore/gstfdsink.c: * gst/oldcore/gstmd5sink.c: * gst/oldcore/gstmultifilesrc.c: * gst/oldcore/gstpipefilter.c: * gst/oldcore/gstshaper.c: * gst/oldcore/gststatistics.c: * gst/rtp/gstasteriskh263.c: * gst/rtp/gstrtpL16depay.c: * gst/rtp/gstrtpL16pay.c: * gst/rtp/gstrtpamrdepay.c: * gst/rtp/gstrtpamrpay.c: * gst/rtp/gstrtpdepay.c: * gst/rtp/gstrtpgsmpay.c: * gst/rtp/gstrtph263pay.c: * gst/rtp/gstrtph263pdepay.c: * gst/rtp/gstrtph263ppay.c: * gst/rtp/gstrtpilbcdepay.c: * gst/rtp/gstrtpmp4gpay.c: * gst/rtp/gstrtpmp4vdepay.c: * gst/rtp/gstrtpmp4vpay.c: * gst/rtp/gstrtpmpadepay.c: * gst/rtp/gstrtpmpapay.c: * gst/rtp/gstrtppcmadepay.c: * gst/rtp/gstrtppcmapay.c: * gst/rtp/gstrtppcmudepay.c: * gst/rtp/gstrtppcmupay.c: * gst/rtp/gstrtpspeexdepay.c: * gst/rtp/gstrtpspeexpay.c: * gst/rtsp/gstrtpdec.c: * gst/rtsp/gstrtspsrc.c: * gst/smpte/gstsmpte.c: * gst/udp/gstdynudpsink.c: * gst/udp/gstmultiudpsink.c: * gst/udp/gstudpsink.c: * gst/udp/gstudpsrc.c: * gst/videobox/gstvideobox.c: * gst/videofilter/gstgamma.c: (gst_gamma_base_init): * gst/videofilter/gstvideobalance.c: * gst/videofilter/gstvideoflip.c: * gst/videofilter/gstvideotemplate.c: (gst_videotemplate_base_init): * gst/videomixer/videomixer.c: * gst/wavparse/gstwavparse.c: (gst_wavparse_base_init), (gst_wavparse_class_init), (gst_wavparse_dispose), (gst_wavparse_reset), (gst_wavparse_init), (gst_wavparse_perform_seek), (gst_wavparse_peek_chunk_info), (gst_wavparse_peek_chunk), (gst_wavparse_stream_headers), (gst_wavparse_parse_stream_init), (gst_wavparse_send_event), (gst_wavparse_add_src_pad), (gst_wavparse_stream_data), (gst_wavparse_chain), (gst_wavparse_srcpad_event), (gst_wavparse_sink_activate), (gst_wavparse_sink_activate_pull), (gst_wavparse_change_state): * gst/wavparse/gstwavparse.h: * sys/oss/gstossmixerelement.c: * sys/oss/gstosssink.c: * sys/oss/gstosssrc.c: * sys/osxaudio/gstosxaudioelement.c: * sys/osxaudio/gstosxaudiosink.c: * sys/osxaudio/gstosxaudiosrc.c: * sys/sunaudio/gstsunaudiomixer.c: * sys/sunaudio/gstsunaudiosink.c: Define GstElementDetails as const and also static (when defined as global)
2006-04-25 21:39:46 +00:00
static const GstElementDetails smpte_details =
better/unified long descriptions Original commit message from CVS: * ext/aalib/gstaasink.c: * ext/annodex/gstcmmldec.c: * ext/annodex/gstcmmlenc.c: * ext/cairo/gsttextoverlay.c: * ext/cairo/gsttimeoverlay.c: * ext/cdio/gstcdiocddasrc.c: * ext/dv/gstdvdec.c: * ext/esd/esdmon.c: * ext/esd/esdsink.c: * ext/flac/gstflacdec.c: * ext/flac/gstflacenc.c: * ext/flac/gstflactag.c: * ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_base_init): * ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_base_init): * ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_base_init): * ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_base_init): * ext/gdk_pixbuf/gstgdkpixbuf.c: * ext/gdk_pixbuf/pixbufscale.c: * ext/hal/gsthalaudiosink.c: (gst_hal_audio_sink_base_init): * ext/hal/gsthalaudiosrc.c: (gst_hal_audio_src_base_init): * ext/jpeg/gstjpegdec.c: * ext/jpeg/gstjpegenc.c: * ext/jpeg/gstsmokedec.c: * ext/jpeg/gstsmokeenc.c: * ext/libcaca/gstcacasink.c: * ext/libmng/gstmngdec.c: * ext/libmng/gstmngenc.c: * ext/libpng/gstpngdec.c: * ext/libpng/gstpngenc.c: * ext/mikmod/gstmikmod.c: * ext/raw1394/gstdv1394src.c: * ext/shout2/gstshout2.c: * ext/speex/gstspeexdec.c: * ext/speex/gstspeexenc.c: * gst/alpha/gstalpha.c: * gst/alpha/gstalphacolor.c: * gst/auparse/gstauparse.c: * gst/autodetect/gstautoaudiosink.c: (gst_auto_audio_sink_base_init): * gst/autodetect/gstautovideosink.c: (gst_auto_video_sink_base_init): * gst/avi/gstavimux.c: (gst_avimux_base_init): * gst/cutter/gstcutter.c: * gst/debug/breakmydata.c: * gst/debug/efence.c: * gst/debug/gstnavigationtest.c: * gst/debug/negotiation.c: * gst/debug/progressreport.c: * gst/debug/testplugin.c: * gst/effectv/gstaging.c: * gst/effectv/gstdice.c: * gst/effectv/gstedge.c: * gst/effectv/gstquark.c: * gst/effectv/gstrev.c: * gst/effectv/gstvertigo.c: * gst/effectv/gstwarp.c: * gst/flx/gstflxdec.c: * gst/goom/gstgoom.c: * gst/interleave/deinterleave.c: * gst/interleave/interleave.c: * gst/law/alaw-decode.c: (gst_alawdec_base_init): * gst/law/alaw-encode.c: (gst_alawenc_base_init): * gst/law/mulaw-decode.c: (gst_mulawdec_base_init): * gst/law/mulaw-encode.c: (gst_mulawenc_base_init): * gst/level/gstlevel.c: * gst/matroska/matroska-demux.c: (gst_matroska_demux_base_init): * gst/matroska/matroska-mux.c: (gst_matroska_mux_base_init): * gst/median/gstmedian.c: * gst/monoscope/gstmonoscope.c: * gst/multipart/multipartdemux.c: * gst/multipart/multipartmux.c: * gst/oldcore/gstmd5sink.c: * gst/oldcore/gstmultifilesrc.c: * gst/oldcore/gstpipefilter.c: * gst/oldcore/gstshaper.c: * gst/oldcore/gststatistics.c: * gst/rtp/gstasteriskh263.c: * gst/rtp/gstrtpL16depay.c: * gst/rtp/gstrtpL16pay.c: * gst/rtp/gstrtpamrdepay.c: * gst/rtp/gstrtpamrpay.c: * gst/rtp/gstrtpdepay.c: * gst/rtp/gstrtpgsmpay.c: * gst/rtp/gstrtph263pay.c: * gst/rtp/gstrtph263pdepay.c: * gst/rtp/gstrtph263ppay.c: * gst/rtp/gstrtpmp4gpay.c: * gst/rtp/gstrtpmp4vdepay.c: * gst/rtp/gstrtpmp4vpay.c: * gst/rtp/gstrtpmpadepay.c: * gst/rtp/gstrtpmpapay.c: * gst/rtp/gstrtppcmadepay.c: * gst/rtp/gstrtppcmapay.c: * gst/rtp/gstrtppcmudepay.c: * gst/rtp/gstrtppcmupay.c: * gst/rtp/gstrtpspeexdepay.c: * gst/rtp/gstrtpspeexpay.c: * gst/rtsp/gstrtpdec.c: * gst/smpte/gstsmpte.c: * gst/videobox/gstvideobox.c: * gst/videofilter/gstgamma.c: (gst_gamma_base_init): * gst/videofilter/gstvideobalance.c: * gst/videofilter/gstvideoflip.c: * gst/videofilter/gstvideotemplate.c: (gst_videotemplate_base_init): * gst/videomixer/videomixer.c: * gst/wavenc/gstwavenc.c: * gst/wavparse/gstwavparse.c: (gst_wavparse_base_init): better/unified long descriptions Fixed #336602 Some cleanups to auparse, don't send multiple newsegments.
2006-03-30 15:37:05 +00:00
GST_ELEMENT_DETAILS ("SMPTE transitions",
"Filter/Editor/Video",
"Apply the standard SMPTE transitions on video images",
"Wim Taymans <wim.taymans@chello.be>");
static GstStaticPadTemplate gst_smpte_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")
)
);
static GstStaticPadTemplate gst_smpte_sink1_template =
GST_STATIC_PAD_TEMPLATE ("sink1",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")
)
);
static GstStaticPadTemplate gst_smpte_sink2_template =
GST_STATIC_PAD_TEMPLATE ("sink2",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")
)
);
/* SMPTE signals and args */
enum
{
/* FILL ME */
LAST_SIGNAL
};
#define DEFAULT_PROP_TYPE 1
#define DEFAULT_PROP_BORDER 0
#define DEFAULT_PROP_DEPTH 16
#define DEFAULT_PROP_FPS 0.
#define DEFAULT_PROP_DURATION GST_SECOND
enum
{
PROP_0,
PROP_TYPE,
PROP_BORDER,
PROP_DEPTH,
PROP_FPS,
PROP_DURATION,
PROP_LAST,
};
#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))
#define GST_TYPE_SMPTE_TRANSITION_TYPE (gst_smpte_transition_type_get_type())
static GType
gst_smpte_transition_type_get_type (void)
{
static GType smpte_transition_type = 0;
GEnumValue *smpte_transitions;
if (!smpte_transition_type) {
const GList *definitions;
gint i = 0;
definitions = gst_mask_get_definitions ();
smpte_transitions =
g_new0 (GEnumValue, g_list_length ((GList *) definitions) + 1);
while (definitions) {
GstMaskDefinition *definition = (GstMaskDefinition *) definitions->data;
definitions = g_list_next (definitions);
smpte_transitions[i].value = definition->type;
/* 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;
i++;
}
smpte_transition_type =
g_enum_register_static ("GstSMPTETransitionType", smpte_transitions);
}
return smpte_transition_type;
}
static void gst_smpte_class_init (GstSMPTEClass * klass);
static void gst_smpte_base_init (GstSMPTEClass * klass);
static void gst_smpte_init (GstSMPTE * smpte);
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);
static GstFlowReturn gst_smpte_collected (GstCollectPads * pads,
GstSMPTE * smpte);
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);
static GstStateChangeReturn gst_smpte_change_state (GstElement * element,
GstStateChange transition);
static GstElementClass *parent_class = NULL;
/*static guint gst_smpte_signals[LAST_SIGNAL] = { 0 }; */
static GType
gst_smpte_get_type (void)
{
static GType smpte_type = 0;
if (!smpte_type) {
static const GTypeInfo smpte_info = {
sizeof (GstSMPTEClass),
(GBaseInitFunc) gst_smpte_base_init,
NULL,
(GClassInitFunc) gst_smpte_class_init,
NULL,
NULL,
sizeof (GstSMPTE),
0,
(GInstanceInitFunc) gst_smpte_init,
};
smpte_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstSMPTE", &smpte_info, 0);
}
return smpte_type;
}
static void
gst_smpte_base_init (GstSMPTEClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_smpte_sink1_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_smpte_sink2_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_smpte_src_template));
gst_element_class_set_details (element_class, &smpte_details);
}
static void
gst_smpte_class_init (GstSMPTEClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
Fix #337365 (g_type_class_ref <-> g_type_class_peek_parent) Original commit message from CVS: * ext/aalib/gstaasink.c: (gst_aasink_class_init): * ext/esd/esdsink.c: (gst_esdsink_class_init): * ext/flac/gstflactag.c: (gst_flac_tag_class_init): * ext/gdk_pixbuf/gstgdkpixbuf.c: (gst_gdk_pixbuf_class_init): * ext/jpeg/gstjpegenc.c: (gst_jpegenc_class_init): * ext/jpeg/gstsmokedec.c: (gst_smokedec_class_init): * ext/jpeg/gstsmokeenc.c: (gst_smokeenc_class_init): * ext/libcaca/gstcacasink.c: (gst_cacasink_class_init): * ext/libmng/gstmngdec.c: (gst_mngdec_class_init): * ext/libmng/gstmngenc.c: (gst_mngenc_class_init): * ext/libpng/gstpngdec.c: (gst_pngdec_class_init): * ext/libpng/gstpngenc.c: (gst_pngenc_class_init): * ext/mikmod/gstmikmod.c: (gst_mikmod_class_init): * ext/shout2/gstshout2.c: (gst_shout2send_class_init): * ext/speex/gstspeexenc.c: (gst_speexenc_class_init): * gst/alpha/gstalpha.c: (gst_alpha_class_init): * gst/avi/gstavimux.c: (gst_avimux_class_init): * gst/debug/efence.c: (gst_efence_class_init): * gst/debug/negotiation.c: (gst_negotiation_class_init): * gst/flx/gstflxdec.c: (gst_flxdec_class_init): * gst/goom/gstgoom.c: (gst_goom_class_init): * gst/id3demux/gstid3demux.c: (gst_id3demux_class_init): * gst/interleave/deinterleave.c: (deinterleave_class_init): * gst/interleave/interleave.c: (interleave_class_init): * gst/law/alaw-decode.c: (gst_alawdec_class_init): * gst/law/alaw-encode.c: (gst_alawenc_class_init): * gst/law/mulaw-encode.c: (gst_mulawenc_class_init): * gst/median/gstmedian.c: (gst_median_class_init): * gst/monoscope/gstmonoscope.c: (gst_monoscope_class_init): * gst/multipart/multipartmux.c: (gst_multipart_mux_class_init): * gst/rtp/gstasteriskh263.c: (gst_asteriskh263_class_init): * gst/rtp/gstrtpL16depay.c: (gst_rtp_L16depay_class_init): * gst/rtp/gstrtpL16pay.c: (gst_rtpL16pay_class_init): * gst/rtp/gstrtpamrdepay.c: (gst_rtp_amr_depay_class_init): * gst/rtp/gstrtpamrpay.c: (gst_rtp_amr_pay_class_init): * gst/rtp/gstrtpdepay.c: (gst_rtp_depay_class_init): * gst/rtp/gstrtpgsmdepay.c: (gst_rtp_gsm_depay_class_init): * gst/rtp/gstrtpgsmpay.c: (gst_rtp_gsm_pay_class_init): * gst/rtp/gstrtph263pay.c: (gst_rtp_h263_pay_class_init): * gst/rtp/gstrtph263pdepay.c: (gst_rtp_h263p_depay_class_init): * gst/rtp/gstrtph263ppay.c: (gst_rtp_h263p_pay_class_init): * gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_class_init): * gst/rtp/gstrtpmp4vdepay.c: (gst_rtp_mp4v_depay_class_init): * gst/rtp/gstrtpmp4vpay.c: (gst_rtp_mp4v_pay_class_init): * gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_class_init): * gst/rtp/gstrtpmpapay.c: (gst_rtp_mpa_pay_class_init): * gst/rtp/gstrtppcmadepay.c: (gst_rtp_pcma_depay_class_init): * gst/rtp/gstrtppcmapay.c: (gst_rtp_pcma_pay_class_init): * gst/rtp/gstrtppcmudepay.c: (gst_rtp_pcmu_depay_class_init): * gst/rtp/gstrtppcmupay.c: (gst_rtp_pcmu_pay_class_init): * gst/rtp/gstrtpspeexdepay.c: (gst_rtp_speex_depay_class_init): * gst/rtp/gstrtpspeexpay.c: (gst_rtp_speex_pay_class_init): * gst/rtsp/gstrtpdec.c: (gst_rtpdec_class_init): * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_class_init): * gst/smpte/gstsmpte.c: (gst_smpte_class_init): * gst/udp/gstdynudpsink.c: (gst_dynudpsink_class_init): * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init): * gst/udp/gstudpsink.c: (gst_udpsink_class_init): * gst/videomixer/videomixer.c: (gst_videomixer_class_init): * gst/wavenc/gstwavenc.c: (gst_wavenc_class_init): * sys/oss/gstossdmabuffer.c: (gst_ossdmabuffer_class_init): * sys/oss/gstosssink.c: (gst_oss_sink_class_init): * sys/osxaudio/gstosxaudioelement.c: (gst_osxaudioelement_class_init): * sys/osxaudio/gstosxaudiosink.c: (gst_osxaudiosink_class_init): * sys/osxaudio/gstosxaudiosrc.c: (gst_osxaudiosrc_class_init): * sys/sunaudio/gstsunaudiosink.c: (gst_sunaudiosink_class_init): Fix #337365 (g_type_class_ref <-> g_type_class_peek_parent)
2006-04-08 21:21:45 +00:00
parent_class = g_type_class_peek_parent (klass);
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;
_gst_mask_init ();
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TYPE,
g_param_spec_enum ("type", "Type", "The type of transition to use",
GST_TYPE_SMPTE_TRANSITION_TYPE, DEFAULT_PROP_TYPE,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FPS,
g_param_spec_float ("fps", "FPS",
"Frames per second if no input files are given (deprecated)", 0.,
G_MAXFLOAT, DEFAULT_PROP_FPS, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BORDER,
g_param_spec_int ("border", "Border",
"The border width of the transition", 0, G_MAXINT,
DEFAULT_PROP_BORDER, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DEPTH,
g_param_spec_int ("depth", "Depth", "Depth of the mask in bits", 1, 24,
DEFAULT_PROP_DEPTH, G_PARAM_READWRITE));
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,
DEFAULT_PROP_DURATION, G_PARAM_READWRITE));
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_smpte_change_state);
}
/* 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 };
static void
fill_i420 (guint8 * data, gint width, gint height, gint color)
{
gint size = I420_Y_ROWSTRIDE (width) * GST_ROUND_UP_2 (height);
gint size4 = size >> 2;
guint8 *yp = data;
guint8 *up = data + I420_U_OFFSET (width, height);
guint8 *vp = data + I420_V_OFFSET (width, height);
memset (yp, y_colors[color], size);
memset (up, u_colors[color], size4);
memset (vp, v_colors[color], size4);
}
static gboolean
gst_smpte_update_mask (GstSMPTE * smpte, gint type, gint depth, gint width,
gint height)
{
GstMask *newmask;
if (smpte->mask) {
if (smpte->type == type &&
smpte->depth == depth &&
smpte->width == width && smpte->height == height)
return TRUE;
}
newmask = gst_mask_factory_new (type, depth, width, height);
if (newmask) {
if (smpte->mask) {
gst_mask_destroy (smpte->mask);
}
smpte->mask = newmask;
smpte->type = type;
smpte->depth = depth;
smpte->width = width;
smpte->height = height;
return TRUE;
}
return FALSE;
}
static gboolean
gst_smpte_setcaps (GstPad * pad, GstCaps * caps)
{
GstSMPTE *smpte;
GstStructure *structure;
gboolean ret;
smpte = GST_SMPTE (GST_PAD_PARENT (pad));
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "width", &smpte->width);
ret &= gst_structure_get_int (structure, "height", &smpte->height);
ret &= gst_structure_get_fraction (structure, "framerate",
&smpte->fps_num, &smpte->fps_denom);
if (!ret)
return FALSE;
/* for backward compat, we store these here */
smpte->fps = ((gdouble) smpte->fps_num) / smpte->fps_denom;
/* 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);
ret = gst_smpte_update_mask (smpte, smpte->type, smpte->depth, smpte->width,
smpte->height);
return ret;
}
static void
gst_smpte_init (GstSMPTE * smpte)
{
smpte->sinkpad1 =
Fix memleak with gst_static_pad_template_get(). Original commit message from CVS: * ext/cairo/gsttextoverlay.c: (gst_text_overlay_init): * ext/dv/gstdvdemux.c: (gst_dvdemux_init), (gst_dvdemux_add_pads): * ext/gdk_pixbuf/gstgdkpixbuf.c: (gst_gdk_pixbuf_init): * ext/jpeg/gstjpegdec.c: (gst_jpeg_dec_init), (gst_jpeg_dec_setcaps): * ext/jpeg/gstjpegenc.c: (gst_jpegenc_init): * ext/jpeg/gstsmokedec.c: (gst_smokedec_init): * ext/jpeg/gstsmokeenc.c: (gst_smokeenc_init): * ext/libmng/gstmngdec.c: (gst_mngdec_init), (gst_mngdec_src_getcaps): * ext/libpng/gstpngdec.c: (gst_pngdec_init), (gst_pngdec_caps_create_and_set): * ext/libpng/gstpngenc.c: (gst_pngenc_init): * ext/mikmod/gstmikmod.c: (gst_mikmod_init): * ext/speex/gstspeexdec.c: (gst_speex_dec_init): * gst/alpha/gstalpha.c: (gst_alpha_init): * gst/auparse/gstauparse.c: (gst_au_parse_init): * gst/avi/gstavidemux.c: (gst_avi_demux_init), (gst_avi_demux_handle_src_event), (gst_avi_demux_parse_stream): * gst/cutter/gstcutter.c: (gst_cutter_init): * gst/debug/efence.c: (gst_efence_init), (gst_efence_getrange), (gst_efence_checkgetrange): * gst/debug/negotiation.c: (gst_negotiation_init): * gst/flx/gstflxdec.c: (gst_flxdec_init): * gst/goom/gstgoom.c: (gst_goom_init): * gst/rtp/gstasteriskh263.c: (gst_asteriskh263_init): * gst/rtp/gstrtpL16depay.c: (gst_rtp_L16depay_init): * gst/rtp/gstrtpL16pay.c: (gst_rtpL16pay_init): * gst/rtp/gstrtpamrdepay.c: (gst_rtp_amr_depay_init): * gst/rtp/gstrtpdepay.c: (gst_rtp_depay_init): * gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_init): * gst/rtsp/gstrtpdec.c: (gst_rtpdec_init): * gst/smpte/gstsmpte.c: (gst_smpte_init): * gst/wavparse/gstwavparse.c: (gst_wavparse_init), (gst_wavparse_create_sourcepad): Fix memleak with gst_static_pad_template_get(). This uses gst_pad_new_from_static_template() instead. Fixes #333512
2006-03-15 16:17:12 +00:00
gst_pad_new_from_static_template (&gst_smpte_sink1_template, "sink1");
gst_pad_set_setcaps_function (smpte->sinkpad1,
GST_DEBUG_FUNCPTR (gst_smpte_setcaps));
gst_pad_set_getcaps_function (smpte->sinkpad1,
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad1);
smpte->sinkpad2 =
Fix memleak with gst_static_pad_template_get(). Original commit message from CVS: * ext/cairo/gsttextoverlay.c: (gst_text_overlay_init): * ext/dv/gstdvdemux.c: (gst_dvdemux_init), (gst_dvdemux_add_pads): * ext/gdk_pixbuf/gstgdkpixbuf.c: (gst_gdk_pixbuf_init): * ext/jpeg/gstjpegdec.c: (gst_jpeg_dec_init), (gst_jpeg_dec_setcaps): * ext/jpeg/gstjpegenc.c: (gst_jpegenc_init): * ext/jpeg/gstsmokedec.c: (gst_smokedec_init): * ext/jpeg/gstsmokeenc.c: (gst_smokeenc_init): * ext/libmng/gstmngdec.c: (gst_mngdec_init), (gst_mngdec_src_getcaps): * ext/libpng/gstpngdec.c: (gst_pngdec_init), (gst_pngdec_caps_create_and_set): * ext/libpng/gstpngenc.c: (gst_pngenc_init): * ext/mikmod/gstmikmod.c: (gst_mikmod_init): * ext/speex/gstspeexdec.c: (gst_speex_dec_init): * gst/alpha/gstalpha.c: (gst_alpha_init): * gst/auparse/gstauparse.c: (gst_au_parse_init): * gst/avi/gstavidemux.c: (gst_avi_demux_init), (gst_avi_demux_handle_src_event), (gst_avi_demux_parse_stream): * gst/cutter/gstcutter.c: (gst_cutter_init): * gst/debug/efence.c: (gst_efence_init), (gst_efence_getrange), (gst_efence_checkgetrange): * gst/debug/negotiation.c: (gst_negotiation_init): * gst/flx/gstflxdec.c: (gst_flxdec_init): * gst/goom/gstgoom.c: (gst_goom_init): * gst/rtp/gstasteriskh263.c: (gst_asteriskh263_init): * gst/rtp/gstrtpL16depay.c: (gst_rtp_L16depay_init): * gst/rtp/gstrtpL16pay.c: (gst_rtpL16pay_init): * gst/rtp/gstrtpamrdepay.c: (gst_rtp_amr_depay_init): * gst/rtp/gstrtpdepay.c: (gst_rtp_depay_init): * gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_init): * gst/rtsp/gstrtpdec.c: (gst_rtpdec_init): * gst/smpte/gstsmpte.c: (gst_smpte_init): * gst/wavparse/gstwavparse.c: (gst_wavparse_init), (gst_wavparse_create_sourcepad): Fix memleak with gst_static_pad_template_get(). This uses gst_pad_new_from_static_template() instead. Fixes #333512
2006-03-15 16:17:12 +00:00
gst_pad_new_from_static_template (&gst_smpte_sink2_template, "sink2");
gst_pad_set_setcaps_function (smpte->sinkpad2,
GST_DEBUG_FUNCPTR (gst_smpte_setcaps));
gst_pad_set_getcaps_function (smpte->sinkpad2,
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad2);
smpte->srcpad =
Fix memleak with gst_static_pad_template_get(). Original commit message from CVS: * ext/cairo/gsttextoverlay.c: (gst_text_overlay_init): * ext/dv/gstdvdemux.c: (gst_dvdemux_init), (gst_dvdemux_add_pads): * ext/gdk_pixbuf/gstgdkpixbuf.c: (gst_gdk_pixbuf_init): * ext/jpeg/gstjpegdec.c: (gst_jpeg_dec_init), (gst_jpeg_dec_setcaps): * ext/jpeg/gstjpegenc.c: (gst_jpegenc_init): * ext/jpeg/gstsmokedec.c: (gst_smokedec_init): * ext/jpeg/gstsmokeenc.c: (gst_smokeenc_init): * ext/libmng/gstmngdec.c: (gst_mngdec_init), (gst_mngdec_src_getcaps): * ext/libpng/gstpngdec.c: (gst_pngdec_init), (gst_pngdec_caps_create_and_set): * ext/libpng/gstpngenc.c: (gst_pngenc_init): * ext/mikmod/gstmikmod.c: (gst_mikmod_init): * ext/speex/gstspeexdec.c: (gst_speex_dec_init): * gst/alpha/gstalpha.c: (gst_alpha_init): * gst/auparse/gstauparse.c: (gst_au_parse_init): * gst/avi/gstavidemux.c: (gst_avi_demux_init), (gst_avi_demux_handle_src_event), (gst_avi_demux_parse_stream): * gst/cutter/gstcutter.c: (gst_cutter_init): * gst/debug/efence.c: (gst_efence_init), (gst_efence_getrange), (gst_efence_checkgetrange): * gst/debug/negotiation.c: (gst_negotiation_init): * gst/flx/gstflxdec.c: (gst_flxdec_init): * gst/goom/gstgoom.c: (gst_goom_init): * gst/rtp/gstasteriskh263.c: (gst_asteriskh263_init): * gst/rtp/gstrtpL16depay.c: (gst_rtp_L16depay_init): * gst/rtp/gstrtpL16pay.c: (gst_rtpL16pay_init): * gst/rtp/gstrtpamrdepay.c: (gst_rtp_amr_depay_init): * gst/rtp/gstrtpdepay.c: (gst_rtp_depay_init): * gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_init): * gst/rtsp/gstrtpdec.c: (gst_rtpdec_init): * gst/smpte/gstsmpte.c: (gst_smpte_init): * gst/wavparse/gstwavparse.c: (gst_wavparse_init), (gst_wavparse_create_sourcepad): Fix memleak with gst_static_pad_template_get(). This uses gst_pad_new_from_static_template() instead. Fixes #333512
2006-03-15 16:17:12 +00:00
gst_pad_new_from_static_template (&gst_smpte_src_template, "src");
gst_element_add_pad (GST_ELEMENT (smpte), smpte->srcpad);
smpte->collect = gst_collect_pads_new ();
gst_collect_pads_set_function (smpte->collect,
(GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_smpte_collected), smpte);
gst_collect_pads_start (smpte->collect);
gst_collect_pads_add_pad (smpte->collect, smpte->sinkpad1,
sizeof (GstCollectData));
gst_collect_pads_add_pad (smpte->collect, smpte->sinkpad2,
sizeof (GstCollectData));
smpte->fps = DEFAULT_PROP_FPS;
smpte->type = DEFAULT_PROP_TYPE;
smpte->border = DEFAULT_PROP_BORDER;
smpte->depth = DEFAULT_PROP_DEPTH;
smpte->duration = DEFAULT_PROP_DURATION;
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);
}
static void
gst_smpte_reset (GstSMPTE * smpte)
{
smpte->width = -1;
smpte->height = -1;
smpte->position = 0;
smpte->end_position = 0;
}
static void
gst_smpte_blend_i420 (guint8 * in1, guint8 * in2, guint8 * out, GstMask * mask,
gint width, gint height, gint border, gint pos)
{
guint32 *maskp;
gint value;
gint i, j;
gint min, max;
guint8 *in1u, *in1v, *in2u, *in2v, *outu, *outv;
gint lumsize = width * height;
gint chromsize = lumsize >> 2;
if (border == 0)
border++;
min = pos - border;
max = pos;
in1u = in1 + lumsize;
in1v = in1u + chromsize;
in2u = in2 + lumsize;
in2v = in2u + chromsize;
outu = out + lumsize;
outv = outu + chromsize;
maskp = mask->data;
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
value = *maskp++;
value = ((CLAMP (value, min, max) - min) << 8) / border;
*out++ = ((*in1++ * value) + (*in2++ * (256 - value))) >> 8;
if (!(i & 1) && !(j & 1)) {
*outu++ = ((*in1u++ * value) + (*in2u++ * (256 - value))) >> 8;
*outv++ = ((*in1v++ * value) + (*in2v++ * (256 - value))) >> 8;
}
}
}
}
static GstFlowReturn
gst_smpte_collected (GstCollectPads * pads, GstSMPTE * smpte)
{
GstBuffer *outbuf;
GstClockTime ts;
GstBuffer *in1 = NULL, *in2 = NULL;
GSList *collected;
if (G_UNLIKELY (smpte->fps_num == 0))
goto not_negotiated;
if (!GST_PAD_CAPS (smpte->sinkpad1) || !GST_PAD_CAPS (smpte->sinkpad2))
goto not_negotiated;
ts = gst_util_uint64_scale_int (smpte->position * GST_SECOND,
smpte->fps_denom, smpte->fps_num);
for (collected = pads->data; collected; collected = g_slist_next (collected)) {
GstCollectData *data;
data = (GstCollectData *) collected->data;
if (data->pad == smpte->sinkpad1)
in1 = gst_collect_pads_pop (pads, data);
else if (data->pad == smpte->sinkpad2)
in2 = gst_collect_pads_pop (pads, data);
}
if (in1 == NULL) {
/* if no input, make picture black */
in1 = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
fill_i420 (GST_BUFFER_DATA (in1), smpte->width, smpte->height, 7);
}
if (in2 == NULL) {
/* if no input, make picture white */
in2 = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
fill_i420 (GST_BUFFER_DATA (in2), smpte->width, smpte->height, 0);
}
if (GST_BUFFER_SIZE (in1) != GST_BUFFER_SIZE (in2))
goto input_formats_do_not_match;
if (smpte->position < smpte->end_position) {
outbuf = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
/* set caps if not done yet */
if (!GST_PAD_CAPS (smpte->srcpad)) {
GstCaps *caps;
caps =
gst_caps_copy (gst_static_caps_get (&gst_smpte_src_template.
static_caps));
gst_caps_set_simple (caps, "width", G_TYPE_INT, smpte->width, "height",
G_TYPE_INT, smpte->height, "framerate", GST_TYPE_FRACTION,
smpte->fps_num, smpte->fps_denom, NULL);
gst_pad_set_caps (smpte->srcpad, caps);
gst_pad_push_event (smpte->srcpad,
gst_event_new_new_segment_full (FALSE,
1.0, 1.0, GST_FORMAT_TIME, 0, -1, 0));
}
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (smpte->srcpad));
gst_smpte_blend_i420 (GST_BUFFER_DATA (in1),
GST_BUFFER_DATA (in2),
GST_BUFFER_DATA (outbuf),
smpte->mask, smpte->width, smpte->height,
smpte->border,
((1 << smpte->depth) + smpte->border) *
smpte->position / smpte->end_position);
} else {
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;
return gst_pad_push (smpte->srcpad, outbuf);
/* ERRORS */
not_negotiated:
{
GST_ELEMENT_ERROR (smpte, CORE, NEGOTIATION, (NULL),
("No input format negotiated"));
return GST_FLOW_NOT_NEGOTIATED;
}
input_formats_do_not_match:
{
GST_ELEMENT_ERROR (smpte, CORE, NEGOTIATION, (NULL),
("input formats don't match: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
GST_PAD_CAPS (smpte->sinkpad1), GST_PAD_CAPS (smpte->sinkpad2)));
return GST_FLOW_ERROR;
}
}
static void
gst_smpte_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstSMPTE *smpte;
smpte = GST_SMPTE (object);
switch (prop_id) {
case PROP_TYPE:
smpte->type = g_value_get_enum (value);
break;
case PROP_BORDER:
smpte->border = g_value_get_int (value);
break;
case PROP_FPS:
smpte->fps = g_value_get_float (value);
break;
case PROP_DEPTH:
smpte->depth = g_value_get_int (value);
break;
case PROP_DURATION:
smpte->duration = g_value_get_uint64 (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_smpte_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstSMPTE *smpte;
smpte = GST_SMPTE (object);
switch (prop_id) {
case PROP_TYPE:
g_value_set_enum (value, smpte->type);
break;
case PROP_FPS:
g_value_set_float (value, smpte->fps);
break;
case PROP_BORDER:
g_value_set_int (value, smpte->border);
break;
case PROP_DEPTH:
g_value_set_int (value, smpte->depth);
break;
case PROP_DURATION:
g_value_set_uint64 (value, smpte->duration);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
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");
gst_collect_pads_start (smpte->collect);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
GST_LOG_OBJECT (smpte, "stopping collectpads");
gst_collect_pads_stop (smpte->collect);
break;
default:
break;
}
ret = parent_class->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_smpte_reset (smpte);
break;
default:
break;
}
return ret;
}
gboolean
gst_smpte_plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_smpte_debug, "smpte", 0,
"SMPTE transition effect");
return gst_element_register (plugin, "smpte", GST_RANK_NONE, GST_TYPE_SMPTE);
}