]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gst-plugin-ducati.git/blob - src/gstducatividdec.c
mpeg2dec: add MPEG-2 support
[glsdk/gst-plugin-ducati.git] / src / gstducatividdec.c
1 /*
2  * GStreamer
3  * Copyright (c) 2010, Texas Instruments Incorporated
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation
8  * version 2.1 of the License.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18  */
20 #ifdef HAVE_CONFIG_H
21 #  include <config.h>
22 #endif
24 #include <gst/gst.h>
25 #include <gst/video/video.h>
27 #include "gstducatividdec.h"
29 GST_BOILERPLATE (GstDucatiVidDec, gst_ducati_viddec, GstElement,
30     GST_TYPE_ELEMENT);
32 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
33     GST_PAD_SRC,
34     GST_PAD_ALWAYS,
35     GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV_STRIDED ("NV12", "[ 0, max ]"))
36     );
38 /* helper functions */
40 static void
41 engine_close (GstDucatiVidDec * self)
42 {
43   if (self->engine) {
44     Engine_close (self->engine);
45     self->engine = NULL;
46   }
48   if (self->params) {
49     dce_free (self->params);
50     self->params = NULL;
51   }
53   if (self->dynParams) {
54     dce_free (self->dynParams);
55     self->dynParams = NULL;
56   }
58   if (self->status) {
59     dce_free (self->status);
60     self->status = NULL;
61   }
63   if (self->inBufs) {
64     dce_free (self->inBufs);
65     self->inBufs = NULL;
66   }
68   if (self->outBufs) {
69     dce_free (self->outBufs);
70     self->outBufs = NULL;
71   }
73   if (self->inArgs) {
74     dce_free (self->inArgs);
75     self->inArgs = NULL;
76   }
78   if (self->outArgs) {
79     dce_free (self->outArgs);
80     self->outArgs = NULL;
81   }
82 }
84 static gboolean
85 engine_open (GstDucatiVidDec * self)
86 {
87   gboolean ret;
89   if (G_UNLIKELY (self->engine)) {
90     return TRUE;
91   }
93   GST_DEBUG_OBJECT (self, "opening engine");
95   self->engine = Engine_open ("ivahd_vidsvr", NULL, NULL);
96   if (G_UNLIKELY (!self->engine)) {
97     GST_ERROR_OBJECT (self, "could not create engine");
98     return FALSE;
99   }
101   ret = GST_DUCATIVIDDEC_GET_CLASS (self)->allocate_params (self,
102       sizeof (IVIDDEC3_Params), sizeof (IVIDDEC3_DynamicParams),
103       sizeof (IVIDDEC3_Status), sizeof (IVIDDEC3_InArgs),
104       sizeof (IVIDDEC3_OutArgs));
106   return ret;
109 static void
110 codec_delete (GstDucatiVidDec * self)
112   if (self->codec) {
113     VIDDEC3_delete(self->codec);
114     self->codec = NULL;
115   }
117   if (self->input) {
118     MemMgr_Free (self->input);
119     self->input = NULL;
120   }
123 static gboolean
124 codec_create (GstDucatiVidDec * self)
126   gint err;
127   const gchar *codec_name;
129   codec_delete (self);
131   if (G_UNLIKELY (!self->engine)) {
132     GST_ERROR_OBJECT (self, "no engine");
133     return FALSE;
134   }
136   /* these need to be set before VIDDEC3_create */
137   self->params->maxWidth = (self->width + 15) & ~0xf;   /* round up to MB */
138   self->params->maxHeight = (self->height + 15) & ~0xf; /* round up to MB */
140   codec_name = GST_DUCATIVIDDEC_GET_CLASS (self)->codec_name;
142   /* create codec: */
143   GST_DEBUG_OBJECT (self, "creating codec: %s", codec_name);
144   self->codec = VIDDEC3_create (self->engine, (char *)codec_name, self->params);
146   if (!self->codec) {
147     return FALSE;
148   }
150   err = VIDDEC3_control (self->codec, XDM_SETPARAMS, self->dynParams, self->status);
151   if (err) {
152     GST_ERROR_OBJECT (self, "failed XDM_SETPARAMS");
153     return FALSE;
154   }
156 #if 0
157   /* not entirely sure why we need to call this here.. just copying omx.. */
158   err = VIDDEC3_control(self->codec, XDM_GETBUFINFO, self->dynParams, self->status);
159   if (err) {
160     GST_ERROR_OBJECT (self, "failed XDM_GETBUFINFO");
161     return FALSE;
162   }
163 #endif
165   self->first_in_buffer = TRUE;
166   self->first_out_buffer = TRUE;
168   /* allocate input buffer and initialize inBufs: */
169   self->inBufs->numBufs = 1;
170   self->input = gst_ducati_alloc_1d (self->width * self->height);
171   self->inBufs->descs[0].buf = (XDAS_Int8 *) TilerMem_VirtToPhys (self->input);
172   self->inBufs->descs[0].memType = XDM_MEMTYPE_RAW;
174   return TRUE;
177 static XDAS_Int32
178 codec_prepare_outbuf (GstDucatiVidDec * self, GstBuffer * buf)
180   XDAS_Int16 y_type, uv_type;
181   guint8 *y_vaddr, *uv_vaddr;
182   SSPtr y_paddr, uv_paddr;
184   y_vaddr = GST_BUFFER_DATA (buf);
185   uv_vaddr = y_vaddr + self->stride * self->padded_height;
187   y_paddr = TilerMem_VirtToPhys (y_vaddr);
188   uv_paddr = TilerMem_VirtToPhys (uv_vaddr);
190   y_type = gst_ducati_get_mem_type (y_paddr);
191   uv_type = gst_ducati_get_mem_type (uv_paddr);
193   if ((y_type < 0) || (uv_type < 0)) {
194     return 0;
195   }
197   if (!self->outBufs->numBufs) {
198     /* initialize output buffer type */
199     self->outBufs->numBufs = 2;
200     self->outBufs->descs[0].memType = y_type;
201     self->outBufs->descs[0].bufSize.tileMem.width = self->padded_width;
202     self->outBufs->descs[0].bufSize.tileMem.height = self->padded_height;
203     self->outBufs->descs[1].memType = uv_type;
204     /* note that UV interleaved width is same a Y: */
205     self->outBufs->descs[1].bufSize.tileMem.width = self->padded_width;
206     self->outBufs->descs[1].bufSize.tileMem.height = self->padded_height / 2;
207   } else {
208     /* verify output buffer type matches what we've already given
209      * to the codec
210      */
211     // TODO
212   }
214   self->outBufs->descs[0].buf = (XDAS_Int8 *) y_paddr;
215   self->outBufs->descs[1].buf = (XDAS_Int8 *) uv_paddr;
217   return (XDAS_Int32) buf;      // XXX use lookup table
220 static GstBuffer *
221 codec_get_outbuf (GstDucatiVidDec * self, XDAS_Int32 id)
223   GstBuffer *buf = (GstBuffer *) id;    // XXX use lookup table
224   if (buf) {
225     gst_buffer_ref (buf);
226   }
227   return buf;
230 static void
231 codec_unlock_outbuf (GstDucatiVidDec * self, XDAS_Int32 id)
233   GstBuffer *buf = (GstBuffer *) id;    // XXX use lookup table
234   if (buf) {
235     gst_buffer_unref (buf);
236   }
239 static gint
240 codec_process (GstDucatiVidDec * self, gboolean send, gboolean flush)
242   gint err;
243   GstClockTime t;
244   GstBuffer *outbuf = NULL;
245   gint i;
247   t = gst_util_get_timestamp ();
248   err = VIDDEC3_process (self->codec,
249       self->inBufs, self->outBufs, self->inArgs, self->outArgs);
250   GST_INFO_OBJECT (self, "%10dns", (gint) (gst_util_get_timestamp () - t));
251   if (err) {
252     if (XDM_ISFATALERROR (self->outArgs->extendedError) || flush) {
253       return err;
254     }
255     /* we are processing for display and it is a non-fatal error, so lets
256      * try to recover..
257      */
258     err = XDM_EOK;
259   }
261   for (i = 0; self->outArgs->outputID[i]; i++) {
262     if (G_UNLIKELY (self->first_out_buffer) && send) {
263       /* send region of interest to sink on first buffer: */
264       XDM_Rect *r = &(self->outArgs->displayBufs.bufDesc[0].activeFrameRegion);
266       GST_DEBUG_OBJECT (self, "setting crop to %d, %d, %d, %d",
267           r->topLeft.x, r->topLeft.y, r->bottomRight.x, r->bottomRight.y);
269       gst_pad_push_event (self->srcpad,
270           gst_event_new_crop (r->topLeft.y, r->topLeft.x,
271               r->bottomRight.x - r->topLeft.x,
272               r->bottomRight.y - r->topLeft.y));
274       self->first_out_buffer = FALSE;
275     }
277     outbuf = codec_get_outbuf (self, self->outArgs->outputID[i]);
278     if (send) {
279       GST_DEBUG_OBJECT (self, "got buffer: %d %p (%" GST_TIME_FORMAT ")",
280           i, outbuf, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
281       gst_pad_push (self->srcpad, outbuf);
282     } else {
283       gst_buffer_unref (outbuf);
284     }
285   }
287   for (i = 0; self->outArgs->freeBufID[i]; i++) {
288     codec_unlock_outbuf (self, self->outArgs->freeBufID[i]);
289   }
291   return err;
294 /** call control(FLUSH), and then process() to pop out all buffers */
295 static gboolean
296 codec_flush (GstDucatiVidDec * self, gboolean eos)
298   gint err;
300   GST_DEBUG_OBJECT (self, "flush: eos=%d", eos);
302   if (G_UNLIKELY (self->first_in_buffer)) {
303     return TRUE;
304   }
306   if (G_UNLIKELY (!self->codec)) {
307     GST_WARNING_OBJECT (self, "no codec");
308     return TRUE;
309   }
311   err = VIDDEC3_control (self->codec, XDM_FLUSH,
312       self->dynParams, self->status);
313   if (err) {
314     GST_ERROR_OBJECT (self, "failed XDM_FLUSH");
315     return FALSE;
316   }
318   do {
319     err = codec_process (self, eos, TRUE);
320   } while (err != XDM_EFAIL);
322   self->first_in_buffer = TRUE;
324   GST_DEBUG_OBJECT (self, "done");
326   return TRUE;
329 /* GstDucatiVidDec vmethod default implementations */
331 static gboolean
332 gst_ducati_viddec_parse_caps (GstDucatiVidDec * self, GstStructure * s)
334   const GValue *codec_data;
336   if (gst_structure_get_int (s, "width", &self->width) &&
337       gst_structure_get_int (s, "height", &self->height)) {
339     const GValue *codec_data = gst_structure_get_value (s, "codec_data");
341     if (codec_data) {
342       GstBuffer *buffer = gst_value_get_buffer (codec_data);
343       GST_DEBUG_OBJECT (self, "codec_data: %" GST_PTR_FORMAT, buffer);
344       self->codec_data = gst_buffer_ref (buffer);
345     }
347     return TRUE;
348   }
350   return FALSE;
353 static gboolean
354 gst_ducati_viddec_allocate_params (GstDucatiVidDec * self, gint params_sz,
355     gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz)
358   /* allocate params: */
359   self->params = dce_alloc (params_sz);
360   if (G_UNLIKELY (!self->params)) {
361     return FALSE;
362   }
363   self->params->size = params_sz;
364   self->params->maxFrameRate = 30000;
365   self->params->maxBitRate = 10000000;
367   //rv??
369   self->params->dataEndianness = XDM_BYTE;
370   self->params->forceChromaFormat = XDM_YUV_420SP;
371   self->params->operatingMode = IVIDEO_DECODE_ONLY;
373   self->params->displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED;
374   self->params->inputDataMode = IVIDEO_ENTIREFRAME;
375   self->params->outputDataMode = IVIDEO_ENTIREFRAME;
376   self->params->numInputDataUnits = 0;
377   self->params->numOutputDataUnits = 0;
379   self->params->metadataType[0] = IVIDEO_METADATAPLANE_NONE;
380   self->params->metadataType[1] = IVIDEO_METADATAPLANE_NONE;
381   self->params->metadataType[2] = IVIDEO_METADATAPLANE_NONE;
382   self->params->errorInfoMode = IVIDEO_ERRORINFO_OFF;
384   /* allocate dynParams: */
385   self->dynParams = dce_alloc (dynparams_sz);
386   if (G_UNLIKELY (!self->dynParams)) {
387     return FALSE;
388   }
389   self->dynParams->size = dynparams_sz;
390   self->dynParams->decodeHeader = XDM_DECODE_AU;
391   self->dynParams->displayWidth = 0;
392   self->dynParams->frameSkipMode = IVIDEO_NO_SKIP;
393   self->dynParams->newFrameFlag = XDAS_TRUE;
395   /* allocate status: */
396   self->status = dce_alloc (status_sz);
397   if (G_UNLIKELY (!self->status)) {
398     return FALSE;
399   }
400   self->status->size = status_sz;
402   /* allocate inBufs/outBufs: */
403   self->inBufs = dce_alloc (sizeof (XDM2_BufDesc));
404   self->outBufs = dce_alloc (sizeof (XDM2_BufDesc));
405   if (G_UNLIKELY (!self->inBufs) || G_UNLIKELY (!self->outBufs)) {
406     return FALSE;
407   }
409   /* allocate inArgs/outArgs: */
410   self->inArgs = dce_alloc (inargs_sz);
411   self->outArgs = dce_alloc (outargs_sz);
412   if (G_UNLIKELY (!self->inArgs) || G_UNLIKELY (!self->outArgs)) {
413     return FALSE;
414   }
415   self->inArgs->size = inargs_sz;
416   self->outArgs->size = outargs_sz;
419 static GstBuffer *
420 gst_ducati_viddec_push_input (GstDucatiVidDec * self, GstBuffer * buf)
422   if (G_UNLIKELY (self->first_in_buffer) && self->codec_data) {
423     push_input (self, GST_BUFFER_DATA (self->codec_data),
424         GST_BUFFER_SIZE (self->codec_data));
425   }
427   /* just copy entire buffer */
428   push_input (self, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
429   gst_buffer_unref (buf);
431   return NULL;
434 /* GstElement vmethod implementations */
436 static gboolean
437 gst_ducati_viddec_set_caps (GstPad * pad, GstCaps * caps)
439   gboolean ret = TRUE;
440   GstDucatiVidDec *self = GST_DUCATIVIDDEC (gst_pad_get_parent (pad));
441   GstDucatiVidDecClass *klass = GST_DUCATIVIDDEC_GET_CLASS (self);
442   GstStructure *s;
444   g_return_val_if_fail (caps, FALSE);
445   g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE);
447   s = gst_caps_get_structure (caps, 0);
449   if (pad == self->sinkpad) {
450     gint frn = 0, frd = 1;
451     GST_INFO_OBJECT (self, "setcaps (sink): %" GST_PTR_FORMAT, caps);
453     if (klass->parse_caps (self, s)) {
454       GstCaps *outcaps;
456       gst_structure_get_fraction (s, "framerate", &frn, &frd);
458       self->stride = 4096;      /* TODO: don't hardcode */
460       /* update output/padded sizes:
461        */
462       klass->update_buffer_size (self);
464       self->outsize =
465           GST_ROUND_UP_2 (self->stride * self->padded_height * 3) / 2;
467       outcaps = gst_caps_new_simple ("video/x-raw-yuv-strided",
468           "rowstride", G_TYPE_INT, self->stride,
469           "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('N','V','1','2'),
470           "width", G_TYPE_INT, self->padded_width,
471           "height", G_TYPE_INT, self->padded_height,
472           "framerate", GST_TYPE_FRACTION, frn, frd,
473           NULL);
475       GST_DEBUG_OBJECT (self, "outcaps: %" GST_PTR_FORMAT, outcaps);
477       ret = gst_pad_set_caps (self->srcpad, outcaps);
478       gst_caps_unref (outcaps);
480       if (!ret) {
481         GST_WARNING_OBJECT (self, "failed to set caps");
482         return FALSE;
483       }
484     } else {
485       GST_WARNING_OBJECT (self, "missing required fields");
486       return FALSE;
487     }
488   } else {
489     GST_INFO_OBJECT (self, "setcaps (src): %" GST_PTR_FORMAT, caps);
490     // XXX check to make sure caps are ok.. keep track if we
491     // XXX need to handle unstrided buffers..
492     GST_WARNING_OBJECT (self, "TODO");
493   }
495   gst_object_unref (self);
497   return gst_pad_set_caps (pad, caps);
500 static gboolean
501 gst_ducati_viddec_query (GstPad * pad, GstQuery * query)
503   GstDucatiVidDec *self = GST_DUCATIVIDDEC (GST_OBJECT_PARENT (pad));
505   switch (GST_QUERY_TYPE (query)) {
506     case GST_QUERY_BUFFERS:
507       GST_DEBUG_OBJECT (self, "min buffers: %d", self->min_buffers);
508       gst_query_set_buffers_count (query, self->min_buffers);
510       GST_DEBUG_OBJECT (self, "min dimensions: %dx%d",
511           self->padded_width, self->padded_height);
512       gst_query_set_buffers_dimensions (query,
513           self->padded_width, self->padded_height);
514       return TRUE;
515     default:
516       return FALSE;
517   }
520 static GstFlowReturn
521 gst_ducati_viddec_chain (GstPad * pad, GstBuffer * buf)
523   GstDucatiVidDec *self = GST_DUCATIVIDDEC (GST_OBJECT_PARENT (pad));
524   GstFlowReturn ret;
525   Int32 err;
526   GstBuffer *outbuf = NULL;
528   if (G_UNLIKELY (!self->engine)) {
529     GST_ERROR_OBJECT (self, "no engine");
530     return GST_FLOW_ERROR;
531   }
533   /* do this before creating codec to ensure reverse caps negotiation
534    * happens first:
535    */
536   ret = gst_pad_alloc_buffer_and_set_caps (self->srcpad, 0, self->outsize,
537       GST_PAD_CAPS (self->srcpad), &outbuf);
539   if (ret != GST_FLOW_OK) {
540     /* TODO: if we had our own buffer class, we could allocate our own
541      * output buffer from TILER...
542      */
543     GST_WARNING_OBJECT (self, "TODO: allocate output TILER buffer");
544     return ret;
545   }
547   if (G_UNLIKELY (!self->codec)) {
548     if (!codec_create (self)) {
549       GST_ERROR_OBJECT (self, "could not create codec");
550       return GST_FLOW_ERROR;
551     }
552   }
554   GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
555   GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
557   /* pass new output buffer as to the decoder to decode into: */
558   self->inArgs->inputID = codec_prepare_outbuf (self, outbuf);
559   if (!self->inArgs->inputID) {
560     GST_ERROR_OBJECT (self, "could not prepare output buffer");
561     return GST_FLOW_ERROR;
562   }
564   self->in_size = 0;
565   buf = GST_DUCATIVIDDEC_GET_CLASS (self)->push_input (self, buf);
567   if (self->in_size == 0) {
568     GST_DEBUG_OBJECT (self, "no input, skipping process");
569     gst_buffer_unref (outbuf);
570     return GST_FLOW_OK;
571   }
573   self->inArgs->numBytes = self->in_size;
574   self->inBufs->descs[0].bufSize.bytes = self->in_size;
576   if (buf) {
577     // XXX
578     GST_WARNING_OBJECT (self, "TODO.. can't push more than one.. need loop");
579     gst_buffer_unref (buf);
580     buf = NULL;
581   }
583   err = codec_process (self, TRUE, FALSE);
584   if (err) {
585     GST_ERROR_OBJECT (self, "process returned error: %d %08x",
586         err, self->outArgs->extendedError);
587     return GST_FLOW_ERROR;
588   }
590   self->first_in_buffer = FALSE;
592   if (self->outArgs->outBufsInUseFlag) {
593     GST_WARNING_OBJECT (self, "TODO... outBufsInUseFlag");      // XXX
594   }
596   return GST_FLOW_OK;
599 static gboolean
600 gst_ducati_viddec_event (GstPad * pad, GstEvent * event)
602   GstDucatiVidDec *self = GST_DUCATIVIDDEC (GST_OBJECT_PARENT (pad));
603   gboolean ret = TRUE;
604   gboolean eos = FALSE;
606   GST_INFO_OBJECT (self, "begin: event=%s", GST_EVENT_TYPE_NAME (event));
608   switch (GST_EVENT_TYPE (event)) {
609     case GST_EVENT_EOS:
610       eos = TRUE;
611       /* fall-through */
612     case GST_EVENT_FLUSH_STOP:
613       if (!codec_flush (self, eos)) {
614         GST_ERROR_OBJECT (self, "could not flush");
615         return FALSE;
616       }
617       /* fall-through */
618     default:
619       ret = gst_pad_push_event (self->srcpad, event);
620       break;
621   }
623   GST_LOG_OBJECT (self, "end");
625   return ret;
628 static GstStateChangeReturn
629 gst_ducati_viddec_change_state (GstElement * element,
630     GstStateChange transition)
632   GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
633   GstDucatiVidDec *self = GST_DUCATIVIDDEC (element);
635   GST_INFO_OBJECT (self, "begin: changing state %s -> %s",
636       gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
637       gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
639   switch (transition) {
640     case GST_STATE_CHANGE_NULL_TO_READY:
641       if (!engine_open (self)) {
642         GST_ERROR_OBJECT (self, "could not open");
643         return GST_STATE_CHANGE_FAILURE;
644       }
645       break;
646     default:
647       break;
648   }
650   ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
652   if (ret == GST_STATE_CHANGE_FAILURE)
653     goto leave;
655   switch (transition) {
656     case GST_STATE_CHANGE_READY_TO_NULL:
657       codec_delete (self);
658       engine_close (self);
659       break;
660     default:
661       break;
662   }
664 leave:
665   GST_LOG_OBJECT (self, "end");
667   return ret;
670 /* GObject vmethod implementations */
672 static void
673 gst_ducati_viddec_finalize (GObject * obj)
675   GstDucatiVidDec *self = GST_DUCATIVIDDEC (obj);
677   codec_delete (self);
678   engine_close (self);
680   if (self->codec_data) {
681       gst_buffer_unref (self->codec_data);
682       self->codec_data = NULL;
683   }
685   G_OBJECT_CLASS (parent_class)->finalize (obj);
688 static void
689 gst_ducati_viddec_base_init (gpointer gclass)
691   GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
693   gst_element_class_add_pad_template (element_class,
694       gst_static_pad_template_get (&src_factory));
697 static void
698 gst_ducati_viddec_class_init (GstDucatiVidDecClass * klass)
700   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
701   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
703   gobject_class->finalize = gst_ducati_viddec_finalize;
704   gstelement_class->change_state = gst_ducati_viddec_change_state;
706   klass->parse_caps =
707       GST_DEBUG_FUNCPTR (gst_ducati_viddec_parse_caps);
708   klass->allocate_params =
709       GST_DEBUG_FUNCPTR (gst_ducati_viddec_allocate_params);
710   klass->push_input =
711       GST_DEBUG_FUNCPTR (gst_ducati_viddec_push_input);
714 static void
715 gst_ducati_viddec_init (GstDucatiVidDec * self, GstDucatiVidDecClass * klass)
717   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
719   self->sinkpad = gst_pad_new_from_template (
720       gst_element_class_get_pad_template (gstelement_class, "sink"), "sink");
721   gst_pad_set_setcaps_function (self->sinkpad,
722       GST_DEBUG_FUNCPTR (gst_ducati_viddec_set_caps));
723   gst_pad_set_chain_function (self->sinkpad,
724       GST_DEBUG_FUNCPTR (gst_ducati_viddec_chain));
725   gst_pad_set_event_function (self->sinkpad,
726       GST_DEBUG_FUNCPTR (gst_ducati_viddec_event));
728   self->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
729   gst_pad_set_setcaps_function (self->srcpad,
730       GST_DEBUG_FUNCPTR (gst_ducati_viddec_set_caps));
731   gst_pad_set_query_function (self->srcpad,
732           GST_DEBUG_FUNCPTR (gst_ducati_viddec_query));
734   gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
735   gst_element_add_pad (GST_ELEMENT (self), self->srcpad);