Tizen 2.0 Release
[framework/multimedia/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapidecoder_priv.h
1 /*
2  *  gstvaapidecoder_priv.h - VA decoder abstraction (private definitions)
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *  Copyright (C) 2011-2012 Intel Corporation
6  *
7  *  This library is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU Lesser General Public License
9  *  as published by the Free Software Foundation; either version 2.1
10  *  of the License, or (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *  Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public
18  *  License along with this library; if not, write to the Free
19  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  *  Boston, MA 02110-1301 USA
21  */
22
23 #ifndef GST_VAAPI_DECODER_PRIV_H
24 #define GST_VAAPI_DECODER_PRIV_H
25
26 #include <glib.h>
27 #include <gst/vaapi/gstvaapidecoder.h>
28 #include <gst/vaapi/gstvaapicontext.h>
29
30 G_BEGIN_DECLS
31
32 #define GST_VAAPI_DECODER_CAST(decoder) ((GstVaapiDecoder *)(decoder))
33
34 /**
35  * GST_VAAPI_DECODER_DISPLAY:
36  * @decoder: a #GstVaapiDecoder
37  *
38  * Macro that evaluates to the #GstVaapiDisplay of @decoder.
39  * This is an internal macro that does not do any run-time type check.
40  */
41 #undef  GST_VAAPI_DECODER_DISPLAY
42 #define GST_VAAPI_DECODER_DISPLAY(decoder) \
43     GST_VAAPI_DECODER_CAST(decoder)->priv->display
44
45 /**
46  * GST_VAAPI_DECODER_CONTEXT:
47  * @decoder: a #GstVaapiDecoder
48  *
49  * Macro that evaluates to the #GstVaapiContext of @decoder.
50  * This is an internal macro that does not do any run-time type check.
51  */
52 #undef  GST_VAAPI_DECODER_CONTEXT
53 #define GST_VAAPI_DECODER_CONTEXT(decoder) \
54     GST_VAAPI_DECODER_CAST(decoder)->priv->context
55
56 /**
57  * GST_VAAPI_DECODER_CODEC:
58  * @decoder: a #GstVaapiDecoder
59  *
60  * Macro that evaluates to the #GstVaapiCodec of @decoder.
61  * This is an internal macro that does not do any run-time type check.
62  */
63 #undef  GST_VAAPI_DECODER_CODEC
64 #define GST_VAAPI_DECODER_CODEC(decoder) \
65     GST_VAAPI_DECODER_CAST(decoder)->priv->codec
66
67 /**
68  * GST_VAAPI_DECODER_CODEC_DATA:
69  * @decoder: a #GstVaapiDecoder
70  *
71  * Macro that evaluates to the #GstBuffer holding optional codec data
72  * for @decoder.
73  * This is an internal macro that does not do any run-time type check.
74  */
75 #undef  GST_VAAPI_DECODER_CODEC_DATA
76 #define GST_VAAPI_DECODER_CODEC_DATA(decoder) \
77     GST_VAAPI_DECODER_CAST(decoder)->priv->codec_data
78
79 /**
80  * GST_VAAPI_DECODER_WIDTH:
81  * @decoder: a #GstVaapiDecoder
82  *
83  * Macro that evaluates to the coded width of the picture
84  * This is an internal macro that does not do any run-time type check.
85  */
86 #undef  GST_VAAPI_DECODER_WIDTH
87 #define GST_VAAPI_DECODER_WIDTH(decoder) \
88     GST_VAAPI_DECODER_CAST(decoder)->priv->width
89
90 /**
91  * GST_VAAPI_DECODER_HEIGHT:
92  * @decoder: a #GstVaapiDecoder
93  *
94  * Macro that evaluates to the coded height of the picture
95  * This is an internal macro that does not do any run-time type check.
96  */
97 #undef  GST_VAAPI_DECODER_HEIGHT
98 #define GST_VAAPI_DECODER_HEIGHT(decoder) \
99     GST_VAAPI_DECODER_CAST(decoder)->priv->height
100
101 /* End-of-Stream buffer */
102 #define GST_BUFFER_FLAG_EOS (GST_BUFFER_FLAG_LAST + 0)
103
104 #define GST_BUFFER_IS_EOS(buffer) \
105     GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_EOS)
106
107 #define GST_VAAPI_DECODER_GET_PRIVATE(obj)                      \
108     (G_TYPE_INSTANCE_GET_PRIVATE((obj),                         \
109                                  GST_VAAPI_TYPE_DECODER,        \
110                                  GstVaapiDecoderPrivate))
111
112 /* Number of scratch surfaces beyond those used as reference */
113 /* 5 = 2 + 4; 2 for reference, 4  for scratch*/
114 #define GST_DECODER_DEFAULT_SURFACES_COUNT 6
115
116 struct _GstVaapiDecoderPrivate {
117     GstVaapiDisplay    *display;
118     VADisplay           va_display;
119     GstVaapiContext    *context;
120     VAContextID         va_context;
121     GstCaps            *caps;
122     GstVaapiCodec       codec;
123     GstBuffer          *codec_data;
124     guint               width;
125     guint               height;
126     guint               fps_n;
127     guint               fps_d;
128     guint               par_n;
129     guint               par_d;
130     GQueue             *buffers;
131     GQueue             *surfaces;
132     guint               is_interlaced   : 1;
133 };
134
135 G_GNUC_INTERNAL
136 void
137 gst_vaapi_decoder_set_picture_size(
138     GstVaapiDecoder    *decoder,
139     guint               width,
140     guint               height
141 );
142
143 G_GNUC_INTERNAL
144 void
145 gst_vaapi_decoder_set_framerate(
146     GstVaapiDecoder    *decoder,
147     guint               fps_n,
148     guint               fps_d
149 );
150
151 G_GNUC_INTERNAL
152 void
153 gst_vaapi_decoder_set_pixel_aspect_ratio(
154     GstVaapiDecoder    *decoder,
155     guint               par_n,
156     guint               par_d
157 );
158
159 G_GNUC_INTERNAL
160 void
161 gst_vaapi_decoder_set_interlaced(GstVaapiDecoder *decoder, gboolean interlaced);
162
163 G_GNUC_INTERNAL
164 gboolean
165 gst_vaapi_decoder_ensure_context(
166     GstVaapiDecoder    *decoder,
167     GstVaapiProfile     profile,
168     GstVaapiEntrypoint  entrypoint,
169     guint               width,
170     guint               height,
171     guint               surface_num
172 );
173
174 G_GNUC_INTERNAL
175 gboolean
176 gst_vaapi_decoder_push_buffer_sub(
177     GstVaapiDecoder *decoder,
178     GstBuffer       *buffer,
179     guint            offset,
180     guint            size
181 );
182
183 G_GNUC_INTERNAL
184 void
185 gst_vaapi_decoder_push_surface_proxy(
186     GstVaapiDecoder      *decoder,
187     GstVaapiSurfaceProxy *proxy
188 );
189
190 G_GNUC_INTERNAL
191 GstVaapiDecoderStatus
192 gst_vaapi_decoder_check_status(GstVaapiDecoder *decoder);
193
194 G_END_DECLS
195
196 #endif /* GST_VAAPI_DECODER_PRIV_H */