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 /* GstDucatiVidDec 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 = ALIGN2 (w + (2 * PADX), 7);
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 params->presetLevelIdc = IH264VDEC_LEVEL41;
90 params->errConcealmentMode = IH264VDEC_APPLY_CONCEALMENT;
91 }
93 return ret;
94 }
96 /* GObject vmethod implementations */
98 static void
99 gst_ducati_h264dec_base_init (gpointer gclass)
100 {
101 GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
103 gst_element_class_set_details_simple (element_class,
104 "DucatiH264Dec",
105 "Codec/Decoder/Video",
106 "Decodes video in H.264/bytestream format with ducati",
107 "Rob Clark <rob@ti.com>");
109 gst_element_class_add_pad_template (element_class,
110 gst_static_pad_template_get (&sink_factory));
111 }
113 static void
114 gst_ducati_h264dec_class_init (GstDucatiH264DecClass * klass)
115 {
116 GstDucatiVidDecClass *bclass = GST_DUCATIVIDDEC_CLASS (klass);
117 bclass->codec_name = "ivahd_h264dec";
118 bclass->update_buffer_size =
119 GST_DEBUG_FUNCPTR (gst_ducati_h264dec_update_buffer_size);
120 bclass->allocate_params =
121 GST_DEBUG_FUNCPTR (gst_ducati_h264dec_allocate_params);
122 }
124 static void
125 gst_ducati_h264dec_init (GstDucatiH264Dec * self,
126 GstDucatiH264DecClass * gclass)
127 {
128 }