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-ducatijpegdec
22 *
23 * FIXME:Describe ducatijpegdec here.
24 *
25 * <refsect2>
26 * <title>Example launch line</title>
27 * |[
28 * gst-launch -v -m fakesrc ! ducatijpegdec ! fakesink silent=TRUE
29 * ]|
30 * </refsect2>
31 */
33 #ifdef HAVE_CONFIG_H
34 # include <config.h>
35 #endif
37 #include "gstducatijpegdec.h"
39 GST_BOILERPLATE (GstDucatiJpegDec, gst_ducati_jpegdec, GstDucatiVidDec,
40 GST_TYPE_DUCATIVIDDEC);
42 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
43 GST_PAD_SINK,
44 GST_PAD_ALWAYS,
45 GST_STATIC_CAPS ("image/jpeg, "
46 "parsed = (boolean)true, "
47 "width = (int)[ 32, 2048 ], "
48 "height = (int)[ 32, 2048 ], " "framerate = (fraction)[ 0, max ];")
49 );
51 /* GstDucatiVidDec vmethod implementations */
53 static void
54 gst_ducati_jpegdec_update_buffer_size (GstDucatiVidDec * self)
55 {
56 gint w = self->width;
57 gint h = self->height;
59 /* calculate output buffer parameters: */
60 self->padded_width = w;
61 self->padded_height = h;
62 self->min_buffers = 1;
63 }
65 static gboolean
66 gst_ducati_jpegdec_allocate_params (GstDucatiVidDec * self, gint params_sz,
67 gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz)
68 {
69 IJPEGVDEC_DynamicParams *dynParams;
71 gboolean ret = parent_class->allocate_params (self,
72 sizeof (IJPEGVDEC_Params), sizeof (IJPEGVDEC_DynamicParams),
73 sizeof (IJPEGVDEC_Status), sizeof (IJPEGVDEC_InArgs),
74 sizeof (IJPEGVDEC_OutArgs));
76 if (!ret)
77 return ret;
79 /* We're doing ENTIREFRAME decoding so in theory 0 should be a valid value
80 * for this. The codec seems to check that it's non-zero though...
81 */
82 self->params->numOutputDataUnits = 1;
84 dynParams = (IJPEGVDEC_DynamicParams *) self->dynParams;
85 dynParams->decodeThumbnail = 0;
86 dynParams->thumbnailMode = 3;
87 dynParams->downsamplingFactor = 1;
88 dynParams->streamingCompliant = 0;
90 return ret;
91 }
93 /* GObject vmethod implementations */
95 static void
96 gst_ducati_jpegdec_base_init (gpointer gclass)
97 {
98 GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
100 gst_element_class_set_details_simple (element_class,
101 "DucatiJpegDec",
102 "Codec/Decoder/Video",
103 "Decodes video in MPEG-2 format with ducati",
104 "Alessandro Decina <alessandro.decina@collabora.co.uk>");
106 gst_element_class_add_pad_template (element_class,
107 gst_static_pad_template_get (&sink_factory));
108 }
110 static void
111 gst_ducati_jpegdec_class_init (GstDucatiJpegDecClass * klass)
112 {
113 GstDucatiVidDecClass *bclass = GST_DUCATIVIDDEC_CLASS (klass);
114 bclass->codec_name = "ivahd_jpegvdec";
115 bclass->update_buffer_size =
116 GST_DEBUG_FUNCPTR (gst_ducati_jpegdec_update_buffer_size);
117 bclass->allocate_params =
118 GST_DEBUG_FUNCPTR (gst_ducati_jpegdec_allocate_params);
119 }
121 static void
122 gst_ducati_jpegdec_init (GstDucatiJpegDec * self,
123 GstDucatiJpegDecClass * gclass)
124 {
125 GstDucatiVidDec *vdec = GST_DUCATIVIDDEC (self);
126 vdec->pageMemType = XDM_MEMTYPE_RAW;
127 }