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 <gst/gst.h>
38 #include <gst/video/video.h>
40 #include "gstducativp7dec.h"
43 #define PADX 48
44 #define PADY 48
47 GST_BOILERPLATE (GstDucatiVP7Dec, gst_ducati_vp7dec, 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-vp7, "
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_vp7dec_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 = (w + (2 * PADX) + 0x7f) & ~0x7f;
69 self->padded_height = h + 2 * PADY;
70 self->min_buffers = 8;
71 }
73 static gboolean
74 gst_ducati_vp7dec_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 (Ivp7VDEC_Params), sizeof (Ivp7VDEC_DynamicParams),
79 sizeof (Ivp7VDEC_Status), sizeof (Ivp7VDEC_InArgs),
80 sizeof (Ivp7VDEC_OutArgs));
82 if (ret) {
83 Ivp7VDEC_Params *params = (Ivp7VDEC_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_vp7dec_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 vp7 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;
113 }
116 /* GObject vmethod implementations */
118 static void
119 gst_ducati_vp7dec_base_init (gpointer gclass)
120 {
121 GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
123 gst_element_class_set_details_simple (element_class,
124 "DucatiVP7Dec",
125 "Codec/Decoder/Video",
126 "Decodes video in On2 VP7 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));
131 }
133 static void
134 gst_ducati_vp7dec_class_init (GstDucatiVP7DecClass * klass)
135 {
136 GstDucatiVidDecClass *bclass = GST_DUCATIVIDDEC_CLASS (klass);
137 bclass->codec_name = "ivahd_vp7dec";
138 bclass->update_buffer_size =
139 GST_DEBUG_FUNCPTR (gst_ducati_vp7dec_update_buffer_size);
140 bclass->allocate_params =
141 GST_DEBUG_FUNCPTR (gst_ducati_vp7dec_allocate_params);
142 bclass->push_input =
143 GST_DEBUG_FUNCPTR (gst_ducati_vp7dec_push_input);
144 }
146 static void
147 gst_ducati_vp7dec_init (GstDucatiVP7Dec * self,
148 GstDucatiVP7DecClass * gclass)
149 {
150 }