]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gst-plugin-ducati.git/blob - src/gstducatih264dec.c
ducatih264dec: specify in template caps that the decoder can do up to profile=high...
[glsdk/gst-plugin-ducati.git] / src / gstducatih264dec.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-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 "gstducatih264dec.h"
40 #define PADX  32
41 #define PADY  24
44 GST_BOILERPLATE (GstDucatiH264Dec, gst_ducati_h264dec, 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-h264, "
51         "stream-format = byte-stream, "   /* only byte-stream */
52         "align = au, "          /* only entire frames */
53         "width = (int)[ 16, 2048 ], "
54         "height = (int)[ 16, 2048 ], "
55         "framerate = (fraction)[ 0, max ],"
56         "profile = (string){constrained-baseline, baseline, main, extended};"
57         "video/x-h264, "
58         "stream-format = byte-stream, "   /* only byte-stream */
59         "align = au, "          /* only entire frames */
60         "width = (int)[ 16, 2048 ], "
61         "height = (int)[ 16, 2048 ], "
62         "framerate = (fraction)[ 0, max ],"
63         "profile = (string) {high, high-10-intra, high-10, high-4:2:2-intra, "
64         "high-4:2:2, high-4:4:4-intra, high-4:4:4, cavlc-4:4:4-intra}, "
65         "level = (string) {1, 1b, 1.1, 1.2, 1.3, 2, 2.1, 2.2, 3, 3.1, 3.2, 4, 4.1, 4.2};"
66         )
67     );
69 /* GstDucatiVidDec vmethod implementations */
71 static void
72 gst_ducati_h264dec_update_buffer_size (GstDucatiVidDec * self)
73 {
74   gint w = self->width;
75   gint h = self->height;
77   /* calculate output buffer parameters: */
78   self->padded_width = ALIGN2 (w + (2 * PADX), 7);
79   self->padded_height = h + 4 * PADY;
80   self->min_buffers = MIN (16, 32768 / ((w / 16) * (h / 16))) + 3;
81 }
83 static gboolean
84 gst_ducati_h264dec_allocate_params (GstDucatiVidDec * self, gint params_sz,
85     gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz)
86 {
87   gboolean ret = parent_class->allocate_params (self,
88       sizeof (IH264VDEC_Params), sizeof (IH264VDEC_DynamicParams),
89       sizeof (IH264VDEC_Status), sizeof (IH264VDEC_InArgs),
90       sizeof (IH264VDEC_OutArgs));
92   if (ret) {
93     IH264VDEC_Params *params = (IH264VDEC_Params *) self->params;
94     self->params->displayDelay = IVIDDEC3_DISPLAY_DELAY_AUTO;
95     params->maxNumRefFrames = IH264VDEC_NUM_REFFRAMES_AUTO;
96     params->pConstantMemory = 0;
97     params->presetLevelIdc = IH264VDEC_LEVEL41;
98     params->errConcealmentMode = IH264VDEC_APPLY_CONCEALMENT;
99     params->temporalDirModePred = TRUE;
100   }
102   return ret;
105 /* GObject vmethod implementations */
107 static void
108 gst_ducati_h264dec_base_init (gpointer gclass)
110   GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
112   gst_element_class_set_details_simple (element_class,
113       "DucatiH264Dec",
114       "Codec/Decoder/Video",
115       "Decodes video in H.264/bytestream format with ducati",
116       "Rob Clark <rob@ti.com>");
118   gst_element_class_add_pad_template (element_class,
119       gst_static_pad_template_get (&sink_factory));
122 static void
123 gst_ducati_h264dec_class_init (GstDucatiH264DecClass * klass)
125   GstDucatiVidDecClass *bclass = GST_DUCATIVIDDEC_CLASS (klass);
126   bclass->codec_name = "ivahd_h264dec";
127   bclass->update_buffer_size =
128       GST_DEBUG_FUNCPTR (gst_ducati_h264dec_update_buffer_size);
129   bclass->allocate_params =
130       GST_DEBUG_FUNCPTR (gst_ducati_h264dec_allocate_params);
133 static void
134 gst_ducati_h264dec_init (GstDucatiH264Dec * self,
135     GstDucatiH264DecClass * gclass)