Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / gst / smpte / gstsmpte.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /**
21  * SECTION:element-smpte
22  *
23  * smpte can accept I420 video streams with the same width, height and
24  * framerate. The two incomming buffers are blended together using an effect
25  * specific alpha mask. 
26  *
27  * The #GstSmpte:depth property defines the presision in bits of the mask. A
28  * higher presision will create a mask with smoother gradients in order to avoid
29  * banding.
30  *
31  * <refsect2>
32  * <title>Sample pipelines</title>
33  * |[
34  * gst-launch -v videotestsrc pattern=1 ! smpte name=s border=20000 type=234 duration=2000000000 ! ffmpegcolorspace ! ximagesink videotestsrc ! s.
35  * ]| A pipeline to demonstrate the smpte transition.
36  * It shows a pinwheel transition a from a snow videotestsrc to an smpte
37  * pattern videotestsrc. The transition will take 2 seconds to complete. The
38  * edges of the transition are smoothed with a 20000 big border.
39  * </refsect2>
40  */
41
42 #ifdef HAVE_CONFIG_H
43 #include "config.h"
44 #endif
45 #include <string.h>
46 #include "gstsmpte.h"
47 #include <gst/video/video.h>
48 #include "paint.h"
49
50 GST_DEBUG_CATEGORY_STATIC (gst_smpte_debug);
51 #define GST_CAT_DEFAULT gst_smpte_debug
52
53 static GstStaticPadTemplate gst_smpte_src_template =
54 GST_STATIC_PAD_TEMPLATE ("src",
55     GST_PAD_SRC,
56     GST_PAD_ALWAYS,
57     GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")
58     )
59     );
60
61 static GstStaticPadTemplate gst_smpte_sink1_template =
62 GST_STATIC_PAD_TEMPLATE ("sink1",
63     GST_PAD_SINK,
64     GST_PAD_ALWAYS,
65     GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")
66     )
67     );
68
69 static GstStaticPadTemplate gst_smpte_sink2_template =
70 GST_STATIC_PAD_TEMPLATE ("sink2",
71     GST_PAD_SINK,
72     GST_PAD_ALWAYS,
73     GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")
74     )
75     );
76
77
78 /* SMPTE signals and args */
79 enum
80 {
81   /* FILL ME */
82   LAST_SIGNAL
83 };
84
85 #define DEFAULT_PROP_TYPE       1
86 #define DEFAULT_PROP_BORDER     0
87 #define DEFAULT_PROP_DEPTH      16
88 #define DEFAULT_PROP_FPS        0.
89 #define DEFAULT_PROP_DURATION   GST_SECOND
90 #define DEFAULT_PROP_INVERT   FALSE
91
92 enum
93 {
94   PROP_0,
95   PROP_TYPE,
96   PROP_BORDER,
97   PROP_DEPTH,
98   PROP_FPS,
99   PROP_DURATION,
100   PROP_INVERT,
101   PROP_LAST,
102 };
103
104 #define I420_Y_ROWSTRIDE(width) (GST_ROUND_UP_4(width))
105 #define I420_U_ROWSTRIDE(width) (GST_ROUND_UP_8(width)/2)
106 #define I420_V_ROWSTRIDE(width) ((GST_ROUND_UP_8(I420_Y_ROWSTRIDE(width)))/2)
107
108 #define I420_Y_OFFSET(w,h) (0)
109 #define I420_U_OFFSET(w,h) (I420_Y_OFFSET(w,h)+(I420_Y_ROWSTRIDE(w)*GST_ROUND_UP_2(h)))
110 #define I420_V_OFFSET(w,h) (I420_U_OFFSET(w,h)+(I420_U_ROWSTRIDE(w)*GST_ROUND_UP_2(h)/2))
111
112 #define I420_SIZE(w,h)     (I420_V_OFFSET(w,h)+(I420_V_ROWSTRIDE(w)*GST_ROUND_UP_2(h)/2))
113
114
115 #define GST_TYPE_SMPTE_TRANSITION_TYPE (gst_smpte_transition_type_get_type())
116 static GType
117 gst_smpte_transition_type_get_type (void)
118 {
119   static GType smpte_transition_type = 0;
120   GEnumValue *smpte_transitions;
121
122   if (!smpte_transition_type) {
123     const GList *definitions;
124     gint i = 0;
125
126     definitions = gst_mask_get_definitions ();
127     smpte_transitions =
128         g_new0 (GEnumValue, g_list_length ((GList *) definitions) + 1);
129
130     while (definitions) {
131       GstMaskDefinition *definition = (GstMaskDefinition *) definitions->data;
132
133       definitions = g_list_next (definitions);
134
135       smpte_transitions[i].value = definition->type;
136       /* older GLib versions have the two fields as non-const, hence the cast */
137       smpte_transitions[i].value_nick = (gchar *) definition->short_name;
138       smpte_transitions[i].value_name = (gchar *) definition->long_name;
139
140       i++;
141     }
142
143     smpte_transition_type =
144         g_enum_register_static ("GstSMPTETransitionType", smpte_transitions);
145   }
146   return smpte_transition_type;
147 }
148
149
150 static void gst_smpte_class_init (GstSMPTEClass * klass);
151 static void gst_smpte_base_init (GstSMPTEClass * klass);
152 static void gst_smpte_init (GstSMPTE * smpte);
153 static void gst_smpte_finalize (GstSMPTE * smpte);
154
155 static GstFlowReturn gst_smpte_collected (GstCollectPads * pads,
156     GstSMPTE * smpte);
157
158 static void gst_smpte_set_property (GObject * object, guint prop_id,
159     const GValue * value, GParamSpec * pspec);
160 static void gst_smpte_get_property (GObject * object, guint prop_id,
161     GValue * value, GParamSpec * pspec);
162
163 static GstStateChangeReturn gst_smpte_change_state (GstElement * element,
164     GstStateChange transition);
165
166 static GstElementClass *parent_class = NULL;
167
168 /*static guint gst_smpte_signals[LAST_SIGNAL] = { 0 }; */
169
170 static GType
171 gst_smpte_get_type (void)
172 {
173   static GType smpte_type = 0;
174
175   if (!smpte_type) {
176     static const GTypeInfo smpte_info = {
177       sizeof (GstSMPTEClass),
178       (GBaseInitFunc) gst_smpte_base_init,
179       NULL,
180       (GClassInitFunc) gst_smpte_class_init,
181       NULL,
182       NULL,
183       sizeof (GstSMPTE),
184       0,
185       (GInstanceInitFunc) gst_smpte_init,
186     };
187
188     smpte_type =
189         g_type_register_static (GST_TYPE_ELEMENT, "GstSMPTE", &smpte_info, 0);
190   }
191   return smpte_type;
192 }
193
194 static void
195 gst_smpte_base_init (GstSMPTEClass * klass)
196 {
197   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
198
199   gst_element_class_add_static_pad_template (element_class,
200       &gst_smpte_sink1_template);
201   gst_element_class_add_static_pad_template (element_class,
202       &gst_smpte_sink2_template);
203   gst_element_class_add_static_pad_template (element_class,
204       &gst_smpte_src_template);
205   gst_element_class_set_details_simple (element_class, "SMPTE transitions",
206       "Filter/Editor/Video",
207       "Apply the standard SMPTE transitions on video images",
208       "Wim Taymans <wim.taymans@chello.be>");
209 }
210
211 static void
212 gst_smpte_class_init (GstSMPTEClass * klass)
213 {
214   GObjectClass *gobject_class;
215   GstElementClass *gstelement_class;
216
217   gobject_class = (GObjectClass *) klass;
218   gstelement_class = (GstElementClass *) klass;
219
220   parent_class = g_type_class_peek_parent (klass);
221
222   gobject_class->set_property = gst_smpte_set_property;
223   gobject_class->get_property = gst_smpte_get_property;
224   gobject_class->finalize = (GObjectFinalizeFunc) gst_smpte_finalize;
225
226   _gst_mask_init ();
227
228   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TYPE,
229       g_param_spec_enum ("type", "Type", "The type of transition to use",
230           GST_TYPE_SMPTE_TRANSITION_TYPE, DEFAULT_PROP_TYPE,
231           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
232   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FPS,
233       g_param_spec_float ("fps", "FPS",
234           "Frames per second if no input files are given (deprecated)", 0.,
235           G_MAXFLOAT, DEFAULT_PROP_FPS,
236           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
237   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BORDER,
238       g_param_spec_int ("border", "Border",
239           "The border width of the transition", 0, G_MAXINT,
240           DEFAULT_PROP_BORDER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
241   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DEPTH,
242       g_param_spec_int ("depth", "Depth", "Depth of the mask in bits", 1, 24,
243           DEFAULT_PROP_DEPTH, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
244   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DURATION,
245       g_param_spec_uint64 ("duration", "Duration",
246           "Duration of the transition effect in nanoseconds", 0, G_MAXUINT64,
247           DEFAULT_PROP_DURATION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
248   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_INVERT,
249       g_param_spec_boolean ("invert", "Invert",
250           "Invert transition mask", DEFAULT_PROP_INVERT,
251           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
252
253   gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_smpte_change_state);
254 }
255
256 /*                              wht  yel  cya  grn  mag  red  blu  blk   -I    Q */
257 static const int y_colors[] = { 255, 226, 179, 150, 105, 76, 29, 16, 16, 0 };
258 static const int u_colors[] = { 128, 0, 170, 46, 212, 85, 255, 128, 0, 128 };
259 static const int v_colors[] = { 128, 155, 0, 21, 235, 255, 107, 128, 128, 255 };
260
261 static void
262 fill_i420 (guint8 * data, gint width, gint height, gint color)
263 {
264   gint size = I420_Y_ROWSTRIDE (width) * GST_ROUND_UP_2 (height);
265   gint size4 = size >> 2;
266   guint8 *yp = data;
267   guint8 *up = data + I420_U_OFFSET (width, height);
268   guint8 *vp = data + I420_V_OFFSET (width, height);
269
270   memset (yp, y_colors[color], size);
271   memset (up, u_colors[color], size4);
272   memset (vp, v_colors[color], size4);
273 }
274
275 static gboolean
276 gst_smpte_update_mask (GstSMPTE * smpte, gint type, gboolean invert,
277     gint depth, gint width, gint height)
278 {
279   GstMask *newmask;
280
281   if (smpte->mask) {
282     if (smpte->type == type &&
283         smpte->invert == invert &&
284         smpte->depth == depth &&
285         smpte->width == width && smpte->height == height)
286       return TRUE;
287   }
288
289   newmask = gst_mask_factory_new (type, invert, depth, width, height);
290   if (newmask) {
291     if (smpte->mask) {
292       gst_mask_destroy (smpte->mask);
293     }
294     smpte->mask = newmask;
295     smpte->type = type;
296     smpte->invert = invert;
297     smpte->depth = depth;
298     smpte->width = width;
299     smpte->height = height;
300
301     return TRUE;
302   }
303   return FALSE;
304 }
305
306 static gboolean
307 gst_smpte_setcaps (GstPad * pad, GstCaps * caps)
308 {
309   GstSMPTE *smpte;
310   GstStructure *structure;
311   gboolean ret;
312
313   smpte = GST_SMPTE (GST_PAD_PARENT (pad));
314
315   structure = gst_caps_get_structure (caps, 0);
316
317   ret = gst_structure_get_int (structure, "width", &smpte->width);
318   ret &= gst_structure_get_int (structure, "height", &smpte->height);
319   ret &= gst_structure_get_fraction (structure, "framerate",
320       &smpte->fps_num, &smpte->fps_denom);
321   if (!ret)
322     return FALSE;
323
324   /* for backward compat, we store these here */
325   smpte->fps = ((gdouble) smpte->fps_num) / smpte->fps_denom;
326
327   /* figure out the duration in frames */
328   smpte->end_position = gst_util_uint64_scale (smpte->duration,
329       smpte->fps_num, GST_SECOND * smpte->fps_denom);
330
331   GST_DEBUG_OBJECT (smpte, "duration: %d frames", smpte->end_position);
332
333   ret =
334       gst_smpte_update_mask (smpte, smpte->type, smpte->invert, smpte->depth,
335       smpte->width, smpte->height);
336
337   return ret;
338 }
339
340 static void
341 gst_smpte_init (GstSMPTE * smpte)
342 {
343   smpte->sinkpad1 =
344       gst_pad_new_from_static_template (&gst_smpte_sink1_template, "sink1");
345   gst_pad_set_setcaps_function (smpte->sinkpad1,
346       GST_DEBUG_FUNCPTR (gst_smpte_setcaps));
347   gst_pad_set_getcaps_function (smpte->sinkpad1,
348       GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
349   gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad1);
350
351   smpte->sinkpad2 =
352       gst_pad_new_from_static_template (&gst_smpte_sink2_template, "sink2");
353   gst_pad_set_setcaps_function (smpte->sinkpad2,
354       GST_DEBUG_FUNCPTR (gst_smpte_setcaps));
355   gst_pad_set_getcaps_function (smpte->sinkpad2,
356       GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
357   gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad2);
358
359   smpte->srcpad =
360       gst_pad_new_from_static_template (&gst_smpte_src_template, "src");
361   gst_element_add_pad (GST_ELEMENT (smpte), smpte->srcpad);
362
363   smpte->collect = gst_collect_pads_new ();
364   gst_collect_pads_set_function (smpte->collect,
365       (GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_smpte_collected), smpte);
366   gst_collect_pads_start (smpte->collect);
367
368   gst_collect_pads_add_pad (smpte->collect, smpte->sinkpad1,
369       sizeof (GstCollectData));
370   gst_collect_pads_add_pad (smpte->collect, smpte->sinkpad2,
371       sizeof (GstCollectData));
372
373   smpte->fps = DEFAULT_PROP_FPS;
374   smpte->type = DEFAULT_PROP_TYPE;
375   smpte->border = DEFAULT_PROP_BORDER;
376   smpte->depth = DEFAULT_PROP_DEPTH;
377   smpte->duration = DEFAULT_PROP_DURATION;
378   smpte->invert = DEFAULT_PROP_INVERT;
379   smpte->fps_num = 0;
380   smpte->fps_denom = 1;
381 }
382
383 static void
384 gst_smpte_finalize (GstSMPTE * smpte)
385 {
386   if (smpte->collect) {
387     gst_object_unref (smpte->collect);
388   }
389
390   G_OBJECT_CLASS (parent_class)->finalize ((GObject *) smpte);
391 }
392
393 static void
394 gst_smpte_reset (GstSMPTE * smpte)
395 {
396   smpte->width = -1;
397   smpte->height = -1;
398   smpte->position = 0;
399   smpte->end_position = 0;
400 }
401
402 static void
403 gst_smpte_blend_i420 (guint8 * in1, guint8 * in2, guint8 * out, GstMask * mask,
404     gint width, gint height, gint border, gint pos)
405 {
406   guint32 *maskp;
407   gint value;
408   gint i, j;
409   gint min, max;
410   guint8 *in1u, *in1v, *in2u, *in2v, *outu, *outv;
411   gint lumsize = width * height;
412   gint chromsize = lumsize >> 2;
413
414   if (border == 0)
415     border++;
416
417   min = pos - border;
418   max = pos;
419
420   in1u = in1 + lumsize;
421   in1v = in1u + chromsize;
422   in2u = in2 + lumsize;
423   in2v = in2u + chromsize;
424   outu = out + lumsize;
425   outv = outu + chromsize;
426
427   maskp = mask->data;
428
429   for (i = 0; i < height; i++) {
430     for (j = 0; j < width; j++) {
431       value = *maskp++;
432       value = ((CLAMP (value, min, max) - min) << 8) / border;
433
434       *out++ = ((*in1++ * value) + (*in2++ * (256 - value))) >> 8;
435       if (!(i & 1) && !(j & 1)) {
436         *outu++ = ((*in1u++ * value) + (*in2u++ * (256 - value))) >> 8;
437         *outv++ = ((*in1v++ * value) + (*in2v++ * (256 - value))) >> 8;
438       }
439     }
440   }
441 }
442
443 static GstFlowReturn
444 gst_smpte_collected (GstCollectPads * pads, GstSMPTE * smpte)
445 {
446   GstBuffer *outbuf;
447   GstClockTime ts;
448   GstBuffer *in1 = NULL, *in2 = NULL;
449   GSList *collected;
450
451   if (G_UNLIKELY (smpte->fps_num == 0))
452     goto not_negotiated;
453
454   if (!GST_PAD_CAPS (smpte->sinkpad1) || !GST_PAD_CAPS (smpte->sinkpad2))
455     goto not_negotiated;
456
457   ts = gst_util_uint64_scale_int (smpte->position * GST_SECOND,
458       smpte->fps_denom, smpte->fps_num);
459
460   for (collected = pads->data; collected; collected = g_slist_next (collected)) {
461     GstCollectData *data;
462
463     data = (GstCollectData *) collected->data;
464
465     if (data->pad == smpte->sinkpad1)
466       in1 = gst_collect_pads_pop (pads, data);
467     else if (data->pad == smpte->sinkpad2)
468       in2 = gst_collect_pads_pop (pads, data);
469   }
470
471   if (in1 == NULL) {
472     /* if no input, make picture black */
473     in1 = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
474     fill_i420 (GST_BUFFER_DATA (in1), smpte->width, smpte->height, 7);
475   }
476   if (in2 == NULL) {
477     /* if no input, make picture white */
478     in2 = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
479     fill_i420 (GST_BUFFER_DATA (in2), smpte->width, smpte->height, 0);
480   }
481
482   if (GST_BUFFER_SIZE (in1) != GST_BUFFER_SIZE (in2))
483     goto input_formats_do_not_match;
484
485   if (smpte->position < smpte->end_position) {
486     outbuf = gst_buffer_new_and_alloc (I420_SIZE (smpte->width, smpte->height));
487
488     /* set caps if not done yet */
489     if (!GST_PAD_CAPS (smpte->srcpad)) {
490       GstCaps *caps;
491
492       caps =
493           gst_caps_copy (gst_static_caps_get
494           (&gst_smpte_src_template.static_caps));
495       gst_caps_set_simple (caps, "width", G_TYPE_INT, smpte->width, "height",
496           G_TYPE_INT, smpte->height, "framerate", GST_TYPE_FRACTION,
497           smpte->fps_num, smpte->fps_denom, NULL);
498
499       gst_pad_set_caps (smpte->srcpad, caps);
500
501       gst_pad_push_event (smpte->srcpad,
502           gst_event_new_new_segment_full (FALSE,
503               1.0, 1.0, GST_FORMAT_TIME, 0, -1, 0));
504
505     }
506     gst_buffer_set_caps (outbuf, GST_PAD_CAPS (smpte->srcpad));
507
508     gst_smpte_blend_i420 (GST_BUFFER_DATA (in1),
509         GST_BUFFER_DATA (in2),
510         GST_BUFFER_DATA (outbuf),
511         smpte->mask, smpte->width, smpte->height,
512         smpte->border,
513         ((1 << smpte->depth) + smpte->border) *
514         smpte->position / smpte->end_position);
515
516   } else {
517     outbuf = in2;
518     gst_buffer_ref (in2);
519   }
520
521   smpte->position++;
522
523   if (in1)
524     gst_buffer_unref (in1);
525   if (in2)
526     gst_buffer_unref (in2);
527
528   GST_BUFFER_TIMESTAMP (outbuf) = ts;
529
530   return gst_pad_push (smpte->srcpad, outbuf);
531
532   /* ERRORS */
533 not_negotiated:
534   {
535     GST_ELEMENT_ERROR (smpte, CORE, NEGOTIATION, (NULL),
536         ("No input format negotiated"));
537     return GST_FLOW_NOT_NEGOTIATED;
538   }
539 input_formats_do_not_match:
540   {
541     GST_ELEMENT_ERROR (smpte, CORE, NEGOTIATION, (NULL),
542         ("input formats don't match: %" GST_PTR_FORMAT " vs. %" GST_PTR_FORMAT,
543             GST_PAD_CAPS (smpte->sinkpad1), GST_PAD_CAPS (smpte->sinkpad2)));
544     return GST_FLOW_ERROR;
545   }
546 }
547
548 static void
549 gst_smpte_set_property (GObject * object, guint prop_id,
550     const GValue * value, GParamSpec * pspec)
551 {
552   GstSMPTE *smpte;
553
554   smpte = GST_SMPTE (object);
555
556   switch (prop_id) {
557     case PROP_TYPE:
558       smpte->type = g_value_get_enum (value);
559       break;
560     case PROP_BORDER:
561       smpte->border = g_value_get_int (value);
562       break;
563     case PROP_FPS:
564       smpte->fps = g_value_get_float (value);
565       break;
566     case PROP_DEPTH:
567       smpte->depth = g_value_get_int (value);
568       break;
569     case PROP_DURATION:
570       smpte->duration = g_value_get_uint64 (value);
571       break;
572     case PROP_INVERT:
573       smpte->invert = g_value_get_boolean (value);
574       break;
575     default:
576       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
577       break;
578   }
579 }
580
581 static void
582 gst_smpte_get_property (GObject * object, guint prop_id,
583     GValue * value, GParamSpec * pspec)
584 {
585   GstSMPTE *smpte;
586
587   smpte = GST_SMPTE (object);
588
589   switch (prop_id) {
590     case PROP_TYPE:
591       g_value_set_enum (value, smpte->type);
592       break;
593     case PROP_FPS:
594       g_value_set_float (value, smpte->fps);
595       break;
596     case PROP_BORDER:
597       g_value_set_int (value, smpte->border);
598       break;
599     case PROP_DEPTH:
600       g_value_set_int (value, smpte->depth);
601       break;
602     case PROP_DURATION:
603       g_value_set_uint64 (value, smpte->duration);
604       break;
605     case PROP_INVERT:
606       g_value_set_boolean (value, smpte->invert);
607       break;
608     default:
609       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
610       break;
611   }
612 }
613
614 static GstStateChangeReturn
615 gst_smpte_change_state (GstElement * element, GstStateChange transition)
616 {
617   GstStateChangeReturn ret;
618   GstSMPTE *smpte;
619
620   smpte = GST_SMPTE (element);
621
622   switch (transition) {
623     case GST_STATE_CHANGE_READY_TO_PAUSED:
624       gst_smpte_reset (smpte);
625       GST_LOG_OBJECT (smpte, "starting collectpads");
626       gst_collect_pads_start (smpte->collect);
627       break;
628     case GST_STATE_CHANGE_PAUSED_TO_READY:
629       GST_LOG_OBJECT (smpte, "stopping collectpads");
630       gst_collect_pads_stop (smpte->collect);
631       break;
632     default:
633       break;
634   }
635
636   ret = parent_class->change_state (element, transition);
637
638   switch (transition) {
639     case GST_STATE_CHANGE_PAUSED_TO_READY:
640       gst_smpte_reset (smpte);
641       break;
642     default:
643       break;
644   }
645   return ret;
646 }
647
648 gboolean
649 gst_smpte_plugin_init (GstPlugin * plugin)
650 {
651   GST_DEBUG_CATEGORY_INIT (gst_smpte_debug, "smpte", 0,
652       "SMPTE transition effect");
653
654   return gst_element_register (plugin, "smpte", GST_RANK_NONE, GST_TYPE_SMPTE);
655 }