23a06a8a8ff4a7d056b350d9b60a34f758c60c55
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 GstSegment segment;
80 gdouble qos_proportion;
81 GstClockTime qos_earliest_time;
83 gboolean need_out_buf;
85 /* by default, codec_data from sinkpad is prepended to first buffer: */
86 GstBuffer *codec_data;
88 Engine_Handle engine;
89 VIDDEC3_Handle codec;
90 VIDDEC3_Params *params;
91 VIDDEC3_DynamicParams *dynParams;
92 VIDDEC3_Status *status;
93 XDM2_BufDesc *inBufs;
94 XDM2_BufDesc *outBufs;
95 VIDDEC3_InArgs *inArgs;
96 VIDDEC3_OutArgs *outArgs;
98 XDAS_Int16 pageMemType;
99 };
101 struct _GstDucatiVidDecClass
102 {
103 GstElementClass parent_class;
105 const gchar *codec_name;
107 /**
108 * Parse codec specific fields the given caps structure. The base-
109 * class implementation of this method handles standard stuff like
110 * width/height/framerate/codec_data.
111 */
112 gboolean (*parse_caps) (GstDucatiVidDec * self, GstStructure * s);
114 /**
115 * Called when the input buffer size changes, to recalculate codec required
116 * output buffer size and minimum count
117 */
118 void (*update_buffer_size) (GstDucatiVidDec * self);
120 /**
121 * Called to allocate/initialize params/dynParams/status/inArgs/outArgs
122 */
123 gboolean (*allocate_params) (GstDucatiVidDec * self, gint params_sz,
124 gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz);
126 /**
127 * Push input data into codec's input buffer, returning a sub-buffer of
128 * any remaining data, or NULL if none. Consumes reference to 'buf'
129 */
130 GstBuffer * (*push_input) (GstDucatiVidDec * self, GstBuffer * buf);
131 };
133 GType gst_ducati_viddec_get_type (void);
135 /* helper methods for derived classes: */
137 static inline void
138 push_input (GstDucatiVidDec * self, guint8 *in, gint sz)
139 {
140 GST_DEBUG_OBJECT (self, "push: %d bytes)", sz);
141 memcpy (self->input + self->in_size, in, sz);
142 self->in_size += sz;
143 }
145 G_END_DECLS
147 #endif /* __GST_DUCATIVIDDEC_H__ */