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 #ifndef __GST_DUCATIVIDDEC_H__
21 #define __GST_DUCATIVIDDEC_H__
23 #include "gstducati.h"
24 #include "gstducatibufferpool.h"
26 #include <gst/video/video.h>
28 G_BEGIN_DECLS
31 #define GST_TYPE_DUCATIVIDDEC (gst_ducati_viddec_get_type())
32 #define GST_DUCATIVIDDEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_DUCATIVIDDEC, GstDucatiVidDec))
33 #define GST_DUCATIVIDDEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_DUCATIVIDDEC, GstDucatiVidDecClass))
34 #define GST_IS_DUCATIVIDDEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_DUCATIVIDDEC))
35 #define GST_IS_DUCATIVIDDEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_DUCATIVIDDEC))
36 #define GST_DUCATIVIDDEC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_DUCATIVIDDEC, GstDucatiVidDecClass))
38 typedef struct _GstDucatiVidDec GstDucatiVidDec;
39 typedef struct _GstDucatiVidDecClass GstDucatiVidDecClass;
41 struct _GstDucatiVidDec
42 {
43 GstElement parent;
45 GstPad *sinkpad, *srcpad;
47 GstDucatiBufferPool *pool;
49 /* minimum output size required by the codec: */
50 gint outsize;
52 /* minimum number of buffers required by the codec: */
53 gint min_buffers;
55 /* input (unpadded, unaligned) size of video: */
56 gint input_width, input_height;
58 /* input (unpadded, aligned to MB) size of video: */
59 gint width, height;
61 /* output (padded) size including any codec padding: */
62 gint padded_width, padded_height;
64 /* output stride (>= padded_width) */
65 gint stride;
67 /* input buffer, allocated when codec is created: */
68 guint8 *input;
70 /* number of bytes pushed to input on current frame: */
71 gint in_size;
73 /* on first output buffer, we need to send crop info to sink.. and some
74 * operations like flushing should be avoided if we haven't sent any
75 * input buffers:
76 */
77 gboolean first_out_buffer, first_in_buffer;
79 /* by default, codec_data from sinkpad is prepended to first buffer: */
80 GstBuffer *codec_data;
82 Engine_Handle engine;
83 VIDDEC3_Handle codec;
84 VIDDEC3_Params *params;
85 VIDDEC3_DynamicParams *dynParams;
86 VIDDEC3_Status *status;
87 XDM2_BufDesc *inBufs;
88 XDM2_BufDesc *outBufs;
89 VIDDEC3_InArgs *inArgs;
90 VIDDEC3_OutArgs *outArgs;
92 XDAS_Int16 pageMemType;
93 };
95 struct _GstDucatiVidDecClass
96 {
97 GstElementClass parent_class;
99 const gchar *codec_name;
101 /**
102 * Parse codec specific fields the given caps structure. The base-
103 * class implementation of this method handles standard stuff like
104 * width/height/framerate/codec_data.
105 */
106 gboolean (*parse_caps) (GstDucatiVidDec * self, GstStructure * s);
108 /**
109 * Called when the input buffer size changes, to recalculate codec required
110 * output buffer size and minimum count
111 */
112 void (*update_buffer_size) (GstDucatiVidDec * self);
114 /**
115 * Called to allocate/initialize params/dynParams/status/inArgs/outArgs
116 */
117 gboolean (*allocate_params) (GstDucatiVidDec * self, gint params_sz,
118 gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz);
120 /**
121 * Push input data into codec's input buffer, returning a sub-buffer of
122 * any remaining data, or NULL if none. Consumes reference to 'buf'
123 */
124 GstBuffer * (*push_input) (GstDucatiVidDec * self, GstBuffer * buf);
125 };
127 GType gst_ducati_viddec_get_type (void);
129 /* helper methods for derived classes: */
131 static inline void
132 push_input (GstDucatiVidDec * self, guint8 *in, gint sz)
133 {
134 GST_DEBUG_OBJECT (self, "push: %d bytes)", sz);
135 memcpy (self->input + self->in_size, in, sz);
136 self->in_size += sz;
137 }
139 G_END_DECLS
141 #endif /* __GST_DUCATIVIDDEC_H__ */