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-ducativp7dec
22 *
23 * FIXME:Describe ducativp7dec here.
24 *
25 * <refsect2>
26 * <title>Example launch line</title>
27 * |[
28 * gst-launch -v -m fakesrc ! ducativp7dec ! fakesink silent=TRUE
29 * ]|
30 * </refsect2>
31 */
33 #ifdef HAVE_CONFIG_H
34 # include <config.h>
35 #endif
37 #include "gstducativp7dec.h"
40 #define PADX 48
41 #define PADY 48
44 GST_BOILERPLATE (GstDucatiVP7Dec, gst_ducati_vp7dec, GstDucatiVidDec,
45 GST_TYPE_DUCATIVIDDEC);
47 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
48 GST_PAD_SINK,
49 GST_PAD_ALWAYS,
50 GST_STATIC_CAPS ("video/x-vp7, "
51 "width = (int)[ 16, 2048 ], "
52 "height = (int)[ 16, 2048 ], "
53 "framerate = (fraction)[ 0, max ];")
54 );
56 /* GstDucatiVidDec vmethod implementations */
58 static void
59 gst_ducati_vp7dec_update_buffer_size (GstDucatiVidDec * self)
60 {
61 gint w = self->width;
62 gint h = self->height;
64 /* calculate output buffer parameters: */
65 self->padded_width = ALIGN2 (w + (2 * PADX), 7);
66 self->padded_height = h + 2 * PADY;
67 self->min_buffers = 8;
68 }
70 static gboolean
71 gst_ducati_vp7dec_allocate_params (GstDucatiVidDec * self, gint params_sz,
72 gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz)
73 {
74 gboolean ret = parent_class->allocate_params (self,
75 sizeof (Ivp7VDEC_Params), sizeof (Ivp7VDEC_DynamicParams),
76 sizeof (Ivp7VDEC_Status), sizeof (Ivp7VDEC_InArgs),
77 sizeof (Ivp7VDEC_OutArgs));
79 if (ret) {
80 Ivp7VDEC_Params *params = (Ivp7VDEC_Params *) self->params;
81 self->params->displayDelay = IVIDDEC3_DECODE_ORDER;
82 self->dynParams->newFrameFlag = FALSE;
83 self->dynParams->lateAcquireArg = -1;
84 self->params->numInputDataUnits = 1;
85 self->params->numOutputDataUnits = 1;
86 params->ivfFormat = FALSE;
87 }
89 return ret;
90 }
92 /* this should be unneeded in future codec versions: */
93 static GstBuffer *
94 gst_ducati_vp7dec_push_input (GstDucatiVidDec * vdec, GstBuffer * buf)
95 {
96 guint32 sz;
98 if (G_UNLIKELY (vdec->first_in_buffer) && vdec->codec_data) {
99 // XXX none of the vp7 clips I've seen have codec_data..
100 }
102 /* current codec version requires size prepended on input buffer: */
103 sz = GST_BUFFER_SIZE (buf);
104 push_input (vdec, (guint8 *)&sz, 4);
106 push_input (vdec, GST_BUFFER_DATA (buf), sz);
107 gst_buffer_unref (buf);
109 return NULL;
110 }
113 /* GObject vmethod implementations */
115 static void
116 gst_ducati_vp7dec_base_init (gpointer gclass)
117 {
118 GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
120 gst_element_class_set_details_simple (element_class,
121 "DucatiVP7Dec",
122 "Codec/Decoder/Video",
123 "Decodes video in On2 VP7 format with ducati",
124 "Rob Clark <rob@ti.com>");
126 gst_element_class_add_pad_template (element_class,
127 gst_static_pad_template_get (&sink_factory));
128 }
130 static void
131 gst_ducati_vp7dec_class_init (GstDucatiVP7DecClass * klass)
132 {
133 GstDucatiVidDecClass *bclass = GST_DUCATIVIDDEC_CLASS (klass);
134 bclass->codec_name = "ivahd_vp7dec";
135 bclass->update_buffer_size =
136 GST_DEBUG_FUNCPTR (gst_ducati_vp7dec_update_buffer_size);
137 bclass->allocate_params =
138 GST_DEBUG_FUNCPTR (gst_ducati_vp7dec_allocate_params);
139 bclass->push_input =
140 GST_DEBUG_FUNCPTR (gst_ducati_vp7dec_push_input);
141 }
143 static void
144 gst_ducati_vp7dec_init (GstDucatiVP7Dec * self,
145 GstDucatiVP7DecClass * gclass)
146 {
147 }