]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gst-plugin-ducati.git/blob - src/gstducatih264dec.c
324826c1eb3251417a771c7572fb3ebb5df0f593
[glsdk/gst-plugin-ducati.git] / src / gstducatih264dec.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 /**
21  * SECTION:element-ducatih264dec
22  *
23  * FIXME:Describe ducatih264dec here.
24  *
25  * <refsect2>
26  * <title>Example launch line</title>
27  * |[
28  * gst-launch -v -m fakesrc ! ducatih264dec ! fakesink silent=TRUE
29  * ]|
30  * </refsect2>
31  */
33 #ifdef HAVE_CONFIG_H
34 #  include <config.h>
35 #endif
37 #include <gst/gst.h>
38 #include <gst/video/video.h>
40 #include "gstducatih264dec.h"
43 #define PADX  32
44 #define PADY  24
47 GST_BOILERPLATE (GstDucatiH264Dec, gst_ducati_h264dec, GstDucatiVidDec,
48     GST_TYPE_DUCATIVIDDEC);
50 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
51     GST_PAD_SINK,
52     GST_PAD_ALWAYS,
53     GST_STATIC_CAPS ("video/x-h264, "
54 //        "alignment = au, "              /* only entire frames */
55 //        "stream-format = byte-stream, " /* only byte-stream */
56         "width = (int)[ 16, 2048 ], "
57         "height = (int)[ 16, 2048 ], "
58         "framerate = (fraction)[ 0, max ];")
59     );
61 /* GstDucatiVideDec vmethod implementations */
63 static void
64 gst_ducati_h264dec_update_buffer_size (GstDucatiVidDec * self)
65 {
66   gint w = self->width;
67   gint h = self->height;
69   /* calculate output buffer parameters: */
70   self->padded_width = (w + (2 * PADX) + 127) & 0xFFFFFF80;
71   self->padded_height = h + 4 * PADY;
72   self->min_buffers = MIN (16, 32768 / ((w / 16) * (h / 16))) + 3;
73 }
75 static gboolean
76 gst_ducati_h264dec_allocate_params (GstDucatiVidDec * self, gint params_sz,
77     gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz)
78 {
79   gboolean ret = parent_class->allocate_params (self,
80       sizeof (IH264VDEC_Params), sizeof (IH264VDEC_DynamicParams),
81       sizeof (IH264VDEC_Status), sizeof (IH264VDEC_InArgs),
82       sizeof (IH264VDEC_OutArgs));
84   if (ret) {
85     IH264VDEC_Params *params = (IH264VDEC_Params *) self->params;
86     self->params->displayDelay = IVIDDEC3_DISPLAY_DELAY_AUTO;
87     params->maxNumRefFrames = IH264VDEC_NUM_REFFRAMES_AUTO;
88     params->pConstantMemory = 0;
89   }
91   return ret;
92 }
94 /* GObject vmethod implementations */
96 static void
97 gst_ducati_h264dec_base_init (gpointer gclass)
98 {
99   GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
101   gst_element_class_set_details_simple (element_class,
102       "DucatiH264Dec",
103       "Codec/Decoder/Video",
104       "Decodes video in H.264/AVC format with ducati",
105       "Rob Clark <rob@ti.com>");
107   gst_element_class_add_pad_template (element_class,
108       gst_static_pad_template_get (&sink_factory));
111 static void
112 gst_ducati_h264dec_class_init (GstDucatiH264DecClass * klass)
114   GstDucatiVidDecClass *bclass = GST_DUCATIVIDDEC_CLASS (klass);
115   bclass->codec_name = "ivahd_h264dec";
116   bclass->update_buffer_size =
117       GST_DEBUG_FUNCPTR (gst_ducati_h264dec_update_buffer_size);
118   bclass->allocate_params =
119       GST_DEBUG_FUNCPTR (gst_ducati_h264dec_allocate_params);
122 static void
123 gst_ducati_h264dec_init (GstDucatiH264Dec * self,
124     GstDucatiH264DecClass * gclass)