]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gst-plugin-ducati.git/blob - src/gstducatividdec.c
mpeg4dec: add MPEG-4 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     //XXX this crashes ducati:
114     //VIDDEC3_delete(self->codec);
115     self->codec = NULL;
116   }
118   if (self->input) {
119     MemMgr_Free (self->input);
120     self->input = NULL;
121   }
124 static gboolean
125 codec_create (GstDucatiVidDec * self)
127   gint err;
128   const gchar *codec_name;
130   codec_delete (self);
132   if (G_UNLIKELY (!self->engine)) {
133     GST_ERROR_OBJECT (self, "no engine");
134     return FALSE;
135   }
137   /* these need to be set before VIDDEC3_create */
138   self->params->maxWidth = (self->width + 15) & ~0xf;   /* round up to MB */
139   self->params->maxHeight = (self->height + 15) & ~0xf; /* round up to MB */
141   codec_name = GST_DUCATIVIDDEC_GET_CLASS (self)->codec_name;
143   /* create codec: */
144   GST_DEBUG_OBJECT (self, "creating codec: %s", codec_name);
145   self->codec = VIDDEC3_create (self->engine, (char *)codec_name, self->params);
147   if (!self->codec) {
148     return FALSE;
149   }
151   err = VIDDEC3_control (self->codec, XDM_SETPARAMS, self->dynParams, self->status);
152   if (err) {
153     GST_ERROR_OBJECT (self, "failed XDM_SETPARAMS");
154     return FALSE;
155   }
157 #if 0
158   /* not entirely sure why we need to call this here.. just copying omx.. */
159   err = VIDDEC3_control(self->codec, XDM_GETBUFINFO, self->dynParams, self->status);
160   if (err) {
161     GST_ERROR_OBJECT (self, "failed XDM_GETBUFINFO");
162     return FALSE;
163   }
164 #endif
166   self->first_in_buffer = TRUE;
167   self->first_out_buffer = TRUE;
169   /* allocate input buffer and initialize inBufs: */
170   self->inBufs->numBufs = 1;
171   self->input = gst_ducati_alloc_1d (self->width * self->height);
172   self->inBufs->descs[0].buf = (XDAS_Int8 *) TilerMem_VirtToPhys (self->input);
173   self->inBufs->descs[0].memType = XDM_MEMTYPE_RAW;
175   return TRUE;
178 static XDAS_Int32
179 codec_prepare_outbuf (GstDucatiVidDec * self, GstBuffer * buf)
181   XDAS_Int16 y_type, uv_type;
182   guint8 *y_vaddr, *uv_vaddr;
183   SSPtr y_paddr, uv_paddr;
185   y_vaddr = GST_BUFFER_DATA (buf);
186   uv_vaddr = y_vaddr + self->stride * self->padded_height;
188   y_paddr = TilerMem_VirtToPhys (y_vaddr);
189   uv_paddr = TilerMem_VirtToPhys (uv_vaddr);
191   y_type = gst_ducati_get_mem_type (y_paddr);
192   uv_type = gst_ducati_get_mem_type (uv_paddr);
194   if ((y_type < 0) || (uv_type < 0)) {
195     return 0;
196   }
198   if (!self->outBufs->numBufs) {
199     /* initialize output buffer type */
200     self->outBufs->numBufs = 2;
201     self->outBufs->descs[0].memType = y_type;
202     self->outBufs->descs[0].bufSize.tileMem.width = self->padded_width;
203     self->outBufs->descs[0].bufSize.tileMem.height = self->padded_height;
204     self->outBufs->descs[1].memType = uv_type;
205     /* note that UV interleaved width is same a Y: */
206     self->outBufs->descs[1].bufSize.tileMem.width = self->padded_width;
207     self->outBufs->descs[1].bufSize.tileMem.height = self->padded_height / 2;
208   } else {
209     /* verify output buffer type matches what we've already given
210      * to the codec
211      */
212     // TODO
213   }
215   self->outBufs->descs[0].buf = (XDAS_Int8 *) y_paddr;
216   self->outBufs->descs[1].buf = (XDAS_Int8 *) uv_paddr;
218   return (XDAS_Int32) buf;      // XXX use lookup table
221 static GstBuffer *
222 codec_get_outbuf (GstDucatiVidDec * self, XDAS_Int32 id)
224   GstBuffer *buf = (GstBuffer *) id;    // XXX use lookup table
225   if (buf) {
226     gst_buffer_ref (buf);
227   }
228   return buf;
231 static void
232 codec_unlock_outbuf (GstDucatiVidDec * self, XDAS_Int32 id)
234   GstBuffer *buf = (GstBuffer *) id;    // XXX use lookup table
235   if (buf) {
236     gst_buffer_unref (buf);
237   }
240 static gint
241 codec_process (GstDucatiVidDec * self, gboolean send)
243   gint err;
244   GstClockTime t;
245   GstBuffer *outbuf = NULL;
246   gint i;
248   t = gst_util_get_timestamp ();
249   err = VIDDEC3_process (self->codec,
250       self->inBufs, self->outBufs, self->inArgs, self->outArgs);
251   GST_INFO_OBJECT (self, "%10dns", (gint) (gst_util_get_timestamp () - t));
252   if (err) {
253     return err;
254   }
256   for (i = 0; self->outArgs->outputID[i]; i++) {
257     if (G_UNLIKELY (self->first_out_buffer) && send) {
258       /* send region of interest to sink on first buffer: */
259       XDM_Rect *r = &(self->outArgs->displayBufs.bufDesc[0].activeFrameRegion);
261       gst_pad_push_event (self->srcpad,
262           gst_event_new_crop (r->topLeft.y, r->topLeft.x,
263               r->bottomRight.x - r->topLeft.x,
264               r->bottomRight.y - r->topLeft.y));
266       self->first_out_buffer = FALSE;
267     }
269     outbuf = codec_get_outbuf (self, self->outArgs->outputID[i]);
270     if (send) {
271       gst_pad_push (self->srcpad, outbuf);
272     } else {
273       gst_buffer_unref (outbuf);
274     }
275   }
277   for (i = 0; self->outArgs->freeBufID[i]; i++) {
278     codec_unlock_outbuf (self, self->outArgs->freeBufID[i]);
279   }
281   return err;
284 /** call control(FLUSH), and then process() to pop out all buffers */
285 static gboolean
286 codec_flush (GstDucatiVidDec * self, gboolean eos)
288   gint err;
290   GST_DEBUG_OBJECT (self, "flush: eos=%d", eos);
292   if (G_UNLIKELY (self->first_in_buffer)) {
293     return TRUE;
294   }
296   if (G_UNLIKELY (!self->codec)) {
297     GST_WARNING_OBJECT (self, "no codec");
298     return TRUE;
299   }
301   err = VIDDEC3_control (self->codec, XDM_FLUSH,
302       self->dynParams, self->status);
303   if (err) {
304     GST_ERROR_OBJECT (self, "failed XDM_FLUSH");
305     return FALSE;
306   }
308   do {
309     err = codec_process (self, eos);
310   } while (err != XDM_EFAIL);
312   self->first_in_buffer = TRUE;
314   GST_DEBUG_OBJECT (self, "done");
316   return TRUE;
319 /* GstDucatiVidDec vmethod default implementations */
321 static gboolean
322 gst_ducati_viddec_allocate_params (GstDucatiVidDec * self, gint params_sz,
323     gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz)
326   /* allocate params: */
327   self->params = dce_alloc (params_sz);
328   if (G_UNLIKELY (!self->params)) {
329     return FALSE;
330   }
331   self->params->size = params_sz;
332   self->params->maxFrameRate = 30000;
333   self->params->maxBitRate = 10000000;
335   //vc1:
336   //self->params->maxBitRate = 45000000;
337   //vc6/vc7/rv??
339   self->params->dataEndianness = XDM_BYTE;
340   self->params->forceChromaFormat = XDM_YUV_420SP;
341   self->params->operatingMode = IVIDEO_DECODE_ONLY;
343   //vc1:
344   //self->params->displayDelay = IVIDDEC3_DISPLAY_DELAY_1;
346   self->params->displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED;
347   self->params->inputDataMode = IVIDEO_ENTIREFRAME;
348   self->params->outputDataMode = IVIDEO_ENTIREFRAME;
349   self->params->numInputDataUnits = 0;
350   self->params->numOutputDataUnits = 0;
352   //vp6, vp7:
353   //self->params->numInputDataUnits = 1;
354   //self->params->numOutputDataUnits = 1;
356   self->params->metadataType[0] = IVIDEO_METADATAPLANE_NONE;
357   self->params->metadataType[1] = IVIDEO_METADATAPLANE_NONE;
358   self->params->metadataType[2] = IVIDEO_METADATAPLANE_NONE;
359   self->params->errorInfoMode = IVIDEO_ERRORINFO_OFF;
361   /* allocate dynParams: */
362   self->dynParams = dce_alloc (dynparams_sz);
363   if (G_UNLIKELY (!self->dynParams)) {
364     return FALSE;
365   }
366   self->dynParams->size = dynparams_sz;
367   self->dynParams->decodeHeader = XDM_DECODE_AU;
368   self->dynParams->displayWidth = 0;
369   self->dynParams->frameSkipMode = IVIDEO_NO_SKIP;
370   self->dynParams->newFrameFlag = XDAS_TRUE;
372   /* allocate status: */
373   self->status = dce_alloc (status_sz);
374   if (G_UNLIKELY (!self->status)) {
375     return FALSE;
376   }
377   self->status->size = status_sz;
379   /* allocate inBufs/outBufs: */
380   self->inBufs = dce_alloc (sizeof (XDM2_BufDesc));
381   self->outBufs = dce_alloc (sizeof (XDM2_BufDesc));
382   if (G_UNLIKELY (!self->inBufs) || G_UNLIKELY (!self->outBufs)) {
383     return FALSE;
384   }
386   /* allocate inArgs/outArgs: */
387   self->inArgs = dce_alloc (inargs_sz);
388   self->outArgs = dce_alloc (outargs_sz);
389   if (G_UNLIKELY (!self->inArgs) || G_UNLIKELY (!self->outArgs)) {
390     return FALSE;
391   }
392   self->inArgs->size = inargs_sz;
393   self->outArgs->size = outargs_sz;
396 static inline void
397 push_input (GstDucatiVidDec * self, GstBuffer * buf)
399   gint sz = GST_BUFFER_SIZE (buf);
400   GST_DEBUG_OBJECT (self, "push: %d bytes)", sz);
401   memcpy (self->input + self->in_size, GST_BUFFER_DATA (buf), sz);
402   self->in_size += sz;
405 static GstBuffer *
406 gst_ducati_viddec_push_input (GstDucatiVidDec * self, GstBuffer * buf)
408   gint sz;
410   if (self->first_in_buffer && self->codec_data) {
411     push_input (self, self->codec_data);
412   }
414   /* just copy entire buffer */
415   push_input (self, buf);
416   gst_buffer_unref (buf);
418   return NULL;
421 /* GstElement vmethod implementations */
423 static gboolean
424 gst_ducati_viddec_set_caps (GstPad * pad, GstCaps * caps)
426   gboolean ret = TRUE;
427   GstDucatiVidDec *self = GST_DUCATIVIDDEC (gst_pad_get_parent (pad));
428   GstStructure *s;
430   g_return_val_if_fail (caps, FALSE);
431   g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE);
433   s = gst_caps_get_structure (caps, 0);
435   if (pad == self->sinkpad) {
436     gint width, height, frn, frd;
437     GST_INFO_OBJECT (self, "setcaps (sink): %" GST_PTR_FORMAT, caps);
439     if (gst_structure_get_int (s, "width", &width) &&
440         gst_structure_get_int (s, "height", &height) &&
441         gst_structure_get_fraction (s, "framerate", &frn, &frd)) {
442       const GValue *codec_data;
443       GstCaps *outcaps;
445       /* ok, these caps seem sane.. grab the required values and construct
446        * appropriate output caps
447        */
448       self->width = width;
449       self->height = height;
450       self->stride = 4096;      /* TODO: don't hardcode */
452       codec_data = gst_structure_get_value (s, "codec_data");
453       if (codec_data) {
454         GstBuffer *buffer = gst_value_get_buffer (codec_data);
455         GST_DEBUG_OBJECT (self, "codec_data: %" GST_PTR_FORMAT, buffer);
456         self->codec_data = gst_buffer_ref (buffer);
457       }
459       /* update output/padded sizes:
460        */
461       GST_DUCATIVIDDEC_GET_CLASS (self)->update_buffer_size (self);
463       self->outsize =
464           GST_ROUND_UP_2 (self->stride * self->padded_height * 3) / 2;
466       outcaps = gst_caps_new_simple ("video/x-raw-yuv-strided",
467           "rowstride", G_TYPE_INT, self->stride,
468           "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('N','V','1','2'),
469           "width", G_TYPE_INT, self->padded_width,
470           "height", G_TYPE_INT, self->padded_height,
471           "framerate", GST_TYPE_FRACTION, frn, frd,
472           NULL);
474       GST_DEBUG_OBJECT (self, "outcaps: %" GST_PTR_FORMAT, outcaps);
476       ret = gst_pad_set_caps (self->srcpad, outcaps);
477       gst_caps_unref (outcaps);
479       if (!ret) {
480         GST_WARNING_OBJECT (self, "failed to set caps");
481         return FALSE;
482       }
483     } else {
484       GST_WARNING_OBJECT (self, "missing required fields");
485       return FALSE;
486     }
487   } else {
488     GST_INFO_OBJECT (self, "setcaps (src): %" GST_PTR_FORMAT, caps);
489     // XXX check to make sure caps are ok.. keep track if we
490     // XXX need to handle unstrided buffers..
491     GST_WARNING_OBJECT (self, "TODO");
492   }
494   gst_object_unref (self);
496   return gst_pad_set_caps (pad, caps);
499 static gboolean
500 gst_ducati_viddec_query (GstPad * pad, GstQuery * query)
502   GstDucatiVidDec *self = GST_DUCATIVIDDEC (GST_OBJECT_PARENT (pad));
504   switch (GST_QUERY_TYPE (query)) {
505     case GST_QUERY_BUFFERS:
506       GST_DEBUG_OBJECT (self, "min buffers: %d", self->min_buffers);
507       gst_query_set_buffers_count (query, self->min_buffers);
509       GST_DEBUG_OBJECT (self, "min dimensions: %dx%d",
510           self->padded_width, self->padded_height);
511       gst_query_set_buffers_dimensions (query,
512           self->padded_width, self->padded_height);
513       return TRUE;
514     default:
515       return FALSE;
516   }
519 static GstFlowReturn
520 gst_ducati_viddec_chain (GstPad * pad, GstBuffer * buf)
522   GstDucatiVidDec *self = GST_DUCATIVIDDEC (GST_OBJECT_PARENT (pad));
523   GstFlowReturn ret;
524   Int32 err;
525   GstBuffer *outbuf = NULL;
527   if (G_UNLIKELY (!self->engine)) {
528     GST_ERROR_OBJECT (self, "no engine");
529     return GST_FLOW_ERROR;
530   }
532   /* do this before creating codec to ensure reverse caps negotiation
533    * happens first:
534    */
535   ret = gst_pad_alloc_buffer_and_set_caps (self->srcpad, 0, self->outsize,
536       GST_PAD_CAPS (self->srcpad), &outbuf);
538   if (ret != GST_FLOW_OK) {
539     /* TODO: if we had our own buffer class, we could allocate our own
540      * output buffer from TILER...
541      */
542  GST_WARNING_OBJECT (self, "ret=%d", ret);
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);
566   self->inArgs->numBytes = self->in_size;
567   self->inBufs->descs[0].bufSize.bytes = self->in_size;
569   if (buf) {
570     // XXX
571     GST_WARNING_OBJECT (self, "TODO.. can't push more than one.. need loop");
572     gst_buffer_unref (buf);
573     buf = NULL;
574   }
576   err = codec_process (self, TRUE);
577   if (err) {
578     GST_ERROR_OBJECT (self, "process returned error: %d %08x",
579         err, self->outArgs->extendedError);
580     return GST_FLOW_ERROR;
581   }
583   self->first_in_buffer = FALSE;
585   if (self->outArgs->outBufsInUseFlag) {
586     GST_WARNING_OBJECT (self, "TODO... outBufsInUseFlag");      // XXX
587   }
589   return GST_FLOW_OK;
592 static gboolean
593 gst_ducati_viddec_event (GstPad * pad, GstEvent * event)
595   GstDucatiVidDec *self = GST_DUCATIVIDDEC (GST_OBJECT_PARENT (pad));
596   gboolean ret = TRUE;
597   gboolean eos = FALSE;
599   GST_INFO_OBJECT (self, "begin: event=%s", GST_EVENT_TYPE_NAME (event));
601   switch (GST_EVENT_TYPE (event)) {
602     case GST_EVENT_EOS:
603       eos = TRUE;
604       /* fall-through */
605     case GST_EVENT_FLUSH_STOP:
606       if (!codec_flush (self, eos)) {
607         GST_ERROR_OBJECT (self, "could not flush");
608         return FALSE;
609       }
610       /* fall-through */
611     default:
612       ret = gst_pad_push_event (self->srcpad, event);
613       break;
614   }
616   GST_LOG_OBJECT (self, "end");
618   return ret;
621 static GstStateChangeReturn
622 gst_ducati_viddec_change_state (GstElement * element,
623     GstStateChange transition)
625   GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
626   GstDucatiVidDec *self = GST_DUCATIVIDDEC (element);
628   GST_INFO_OBJECT (self, "begin: changing state %s -> %s",
629       gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
630       gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
632   switch (transition) {
633     case GST_STATE_CHANGE_NULL_TO_READY:
634       if (!engine_open (self)) {
635         GST_ERROR_OBJECT (self, "could not open");
636         return GST_STATE_CHANGE_FAILURE;
637       }
638       break;
639     default:
640       break;
641   }
643   ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
645   if (ret == GST_STATE_CHANGE_FAILURE)
646     goto leave;
648   switch (transition) {
649     case GST_STATE_CHANGE_READY_TO_NULL:
650       codec_delete (self);
651       engine_close (self);
652       break;
653     default:
654       break;
655   }
657 leave:
658   GST_LOG_OBJECT (self, "end");
660   return ret;
663 /* GObject vmethod implementations */
665 static void
666 gst_ducati_viddec_finalize (GObject * obj)
668   GstDucatiVidDec *self = GST_DUCATIVIDDEC (obj);
670   codec_delete (self);
671   engine_close (self);
673   if (self->codec_data) {
674       gst_buffer_unref (self->codec_data);
675       self->codec_data = NULL;
676   }
678   G_OBJECT_CLASS (parent_class)->finalize (obj);
681 static void
682 gst_ducati_viddec_base_init (gpointer gclass)
684   GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
686   gst_element_class_add_pad_template (element_class,
687       gst_static_pad_template_get (&src_factory));
690 static void
691 gst_ducati_viddec_class_init (GstDucatiVidDecClass * klass)
693   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
694   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
696   gobject_class->finalize = gst_ducati_viddec_finalize;
697   gstelement_class->change_state = gst_ducati_viddec_change_state;
699   klass->allocate_params =
700       GST_DEBUG_FUNCPTR (gst_ducati_viddec_allocate_params);
701   klass->push_input =
702       GST_DEBUG_FUNCPTR (gst_ducati_viddec_push_input);
705 static void
706 gst_ducati_viddec_init (GstDucatiVidDec * self, GstDucatiVidDecClass * klass)
708   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
710   self->sinkpad = gst_pad_new_from_template (
711       gst_element_class_get_pad_template (gstelement_class, "sink"), "sink");
712   gst_pad_set_setcaps_function (self->sinkpad,
713       GST_DEBUG_FUNCPTR (gst_ducati_viddec_set_caps));
714   gst_pad_set_chain_function (self->sinkpad,
715       GST_DEBUG_FUNCPTR (gst_ducati_viddec_chain));
716   gst_pad_set_event_function (self->sinkpad,
717       GST_DEBUG_FUNCPTR (gst_ducati_viddec_event));
719   self->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
720   gst_pad_set_setcaps_function (self->srcpad,
721       GST_DEBUG_FUNCPTR (gst_ducati_viddec_set_caps));
722   gst_pad_set_query_function (self->srcpad,
723           GST_DEBUG_FUNCPTR (gst_ducati_viddec_query));
725   gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
726   gst_element_add_pad (GST_ELEMENT (self), self->srcpad);