]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gst-plugin-ducati.git/blob - src/gstducativp6dec.c
clean up padded buffer size calculations
[glsdk/gst-plugin-ducati.git] / src / gstducativp6dec.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-ducativp6dec
22  *
23  * FIXME:Describe ducativp6dec here.
24  *
25  * <refsect2>
26  * <title>Example launch line</title>
27  * |[
28  * gst-launch -v -m fakesrc ! ducativp6dec ! 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 "gstducativp6dec.h"
43 #define PADX  48
44 #define PADY  48
47 GST_BOILERPLATE (GstDucatiVP6Dec, gst_ducati_vp6dec, 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-vp6, "
54         "width = (int)[ 16, 2048 ], "
55         "height = (int)[ 16, 2048 ], "
56         "framerate = (fraction)[ 0, max ];")
57     );
59 /* GstDucatiVidDec vmethod implementations */
61 static void
62 gst_ducati_vp6dec_update_buffer_size (GstDucatiVidDec * self)
63 {
64   gint w = self->width;
65   gint h = self->height;
67   /* calculate output buffer parameters: */
68   self->padded_width = ALIGN2 (w + (2 * PADX), 7);
69   self->padded_height = h + 2 * PADY;
70   self->min_buffers = 8;
71 }
73 static gboolean
74 gst_ducati_vp6dec_allocate_params (GstDucatiVidDec * self, gint params_sz,
75     gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz)
76 {
77   gboolean ret = parent_class->allocate_params (self,
78       sizeof (Ivp6VDEC_Params), sizeof (Ivp6VDEC_DynamicParams),
79       sizeof (Ivp6VDEC_Status), sizeof (Ivp6VDEC_InArgs),
80       sizeof (Ivp6VDEC_OutArgs));
82   if (ret) {
83     Ivp6VDEC_Params *params = (Ivp6VDEC_Params *) self->params;
84     self->params->displayDelay = IVIDDEC3_DECODE_ORDER;
85     self->dynParams->newFrameFlag = FALSE;
86     self->dynParams->lateAcquireArg = -1;
87     self->params->numInputDataUnits = 1;
88     self->params->numOutputDataUnits = 1;
89     params->ivfFormat = FALSE;
90   }
92   return ret;
93 }
95 /* this should be unneeded in future codec versions: */
96 static GstBuffer *
97 gst_ducati_vp6dec_push_input (GstDucatiVidDec * vdec, GstBuffer * buf)
98 {
99   guint32 sz;
101   if (G_UNLIKELY (vdec->first_in_buffer) && vdec->codec_data) {
102     // XXX none of the vp6 clips I've seen have codec_data..
103   }
105   /* current codec version requires size prepended on input buffer: */
106   sz = GST_BUFFER_SIZE (buf);
107   push_input (vdec, (guint8 *)&sz, 4);
109   push_input (vdec, GST_BUFFER_DATA (buf), sz);
110   gst_buffer_unref (buf);
112   return NULL;
116 /* GObject vmethod implementations */
118 static void
119 gst_ducati_vp6dec_base_init (gpointer gclass)
121   GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
123   gst_element_class_set_details_simple (element_class,
124       "DucatiVP6Dec",
125       "Codec/Decoder/Video",
126       "Decodes video in On2 VP6 format with ducati",
127       "Rob Clark <rob@ti.com>");
129   gst_element_class_add_pad_template (element_class,
130       gst_static_pad_template_get (&sink_factory));
133 static void
134 gst_ducati_vp6dec_class_init (GstDucatiVP6DecClass * klass)
136   GstDucatiVidDecClass *bclass = GST_DUCATIVIDDEC_CLASS (klass);
137   bclass->codec_name = "ivahd_vp6dec";
138   bclass->update_buffer_size =
139       GST_DEBUG_FUNCPTR (gst_ducati_vp6dec_update_buffer_size);
140   bclass->allocate_params =
141       GST_DEBUG_FUNCPTR (gst_ducati_vp6dec_allocate_params);
142   bclass->push_input =
143       GST_DEBUG_FUNCPTR (gst_ducati_vp6dec_push_input);
146 static void
147 gst_ducati_vp6dec_init (GstDucatiVP6Dec * self,
148     GstDucatiVP6DecClass * gclass)