s/Tungsten Graphics/VMware/
[mesa.git] / src / gallium / include / pipe / p_video_state.h
1 /**************************************************************************
2 *
3 * Copyright 2009 Younes Manton.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef PIPE_VIDEO_STATE_H
29 #define PIPE_VIDEO_STATE_H
30
31 #include "pipe/p_defines.h"
32 #include "pipe/p_format.h"
33 #include "pipe/p_state.h"
34 #include "pipe/p_screen.h"
35 #include "util/u_inlines.h"
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /*
42 * see table 6-12 in the spec
43 */
44 enum pipe_mpeg12_picture_coding_type
45 {
46 PIPE_MPEG12_PICTURE_CODING_TYPE_I = 0x01,
47 PIPE_MPEG12_PICTURE_CODING_TYPE_P = 0x02,
48 PIPE_MPEG12_PICTURE_CODING_TYPE_B = 0x03,
49 PIPE_MPEG12_PICTURE_CODING_TYPE_D = 0x04
50 };
51
52 /*
53 * see table 6-14 in the spec
54 */
55 enum pipe_mpeg12_picture_structure
56 {
57 PIPE_MPEG12_PICTURE_STRUCTURE_RESERVED = 0x00,
58 PIPE_MPEG12_PICTURE_STRUCTURE_FIELD_TOP = 0x01,
59 PIPE_MPEG12_PICTURE_STRUCTURE_FIELD_BOTTOM = 0x02,
60 PIPE_MPEG12_PICTURE_STRUCTURE_FRAME = 0x03
61 };
62
63 /*
64 * flags for macroblock_type, see section 6.3.17.1 in the spec
65 */
66 enum pipe_mpeg12_macroblock_type
67 {
68 PIPE_MPEG12_MB_TYPE_QUANT = 0x01,
69 PIPE_MPEG12_MB_TYPE_MOTION_FORWARD = 0x02,
70 PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD = 0x04,
71 PIPE_MPEG12_MB_TYPE_PATTERN = 0x08,
72 PIPE_MPEG12_MB_TYPE_INTRA = 0x10
73 };
74
75 /*
76 * flags for motion_type, see table 6-17 and 6-18 in the spec
77 */
78 enum pipe_mpeg12_motion_type
79 {
80 PIPE_MPEG12_MO_TYPE_RESERVED = 0x00,
81 PIPE_MPEG12_MO_TYPE_FIELD = 0x01,
82 PIPE_MPEG12_MO_TYPE_FRAME = 0x02,
83 PIPE_MPEG12_MO_TYPE_16x8 = 0x02,
84 PIPE_MPEG12_MO_TYPE_DUAL_PRIME = 0x03
85 };
86
87 /*
88 * see section 6.3.17.1 and table 6-19 in the spec
89 */
90 enum pipe_mpeg12_dct_type
91 {
92 PIPE_MPEG12_DCT_TYPE_FRAME = 0,
93 PIPE_MPEG12_DCT_TYPE_FIELD = 1
94 };
95
96 enum pipe_mpeg12_field_select
97 {
98 PIPE_MPEG12_FS_FIRST_FORWARD = 0x01,
99 PIPE_MPEG12_FS_FIRST_BACKWARD = 0x02,
100 PIPE_MPEG12_FS_SECOND_FORWARD = 0x04,
101 PIPE_MPEG12_FS_SECOND_BACKWARD = 0x08
102 };
103
104 enum pipe_h264_slice_type
105 {
106 PIPE_H264_SLICE_TYPE_P = 0x0,
107 PIPE_H264_SLICE_TYPE_B = 0x1,
108 PIPE_H264_SLICE_TYPE_I = 0x2,
109 PIPE_H264_SLICE_TYPE_SP = 0x3,
110 PIPE_H264_SLICE_TYPE_SI = 0x4
111 };
112
113 struct pipe_picture_desc
114 {
115 enum pipe_video_profile profile;
116 };
117
118 struct pipe_quant_matrix
119 {
120 enum pipe_video_format codec;
121 };
122
123 struct pipe_macroblock
124 {
125 enum pipe_video_format codec;
126 };
127
128 struct pipe_mpeg12_picture_desc
129 {
130 struct pipe_picture_desc base;
131
132 unsigned picture_coding_type;
133 unsigned picture_structure;
134 unsigned frame_pred_frame_dct;
135 unsigned q_scale_type;
136 unsigned alternate_scan;
137 unsigned intra_vlc_format;
138 unsigned concealment_motion_vectors;
139 unsigned intra_dc_precision;
140 unsigned f_code[2][2];
141 unsigned top_field_first;
142 unsigned full_pel_forward_vector;
143 unsigned full_pel_backward_vector;
144 unsigned num_slices;
145
146 const uint8_t *intra_matrix;
147 const uint8_t *non_intra_matrix;
148
149 struct pipe_video_buffer *ref[2];
150 };
151
152 struct pipe_mpeg12_macroblock
153 {
154 struct pipe_macroblock base;
155
156 /* see section 6.3.17 in the spec */
157 unsigned short x, y;
158
159 /* see section 6.3.17.1 in the spec */
160 unsigned char macroblock_type;
161
162 union {
163 struct {
164 /* see table 6-17 in the spec */
165 unsigned int frame_motion_type:2;
166
167 /* see table 6-18 in the spec */
168 unsigned int field_motion_type:2;
169
170 /* see table 6-19 in the spec */
171 unsigned int dct_type:1;
172 } bits;
173 unsigned int value;
174 } macroblock_modes;
175
176 /* see section 6.3.17.2 in the spec */
177 unsigned char motion_vertical_field_select;
178
179 /* see Table 7-7 in the spec */
180 short PMV[2][2][2];
181
182 /* see figure 6.10-12 in the spec */
183 unsigned short coded_block_pattern;
184
185 /* see figure 6.10-12 in the spec */
186 short *blocks;
187
188 /* Number of skipped macroblocks after this macroblock */
189 unsigned short num_skipped_macroblocks;
190 };
191
192 struct pipe_mpeg4_picture_desc
193 {
194 struct pipe_picture_desc base;
195
196 int32_t trd[2];
197 int32_t trb[2];
198 uint16_t vop_time_increment_resolution;
199 uint8_t vop_coding_type;
200 uint8_t vop_fcode_forward;
201 uint8_t vop_fcode_backward;
202 uint8_t resync_marker_disable;
203 uint8_t interlaced;
204 uint8_t quant_type;
205 uint8_t quarter_sample;
206 uint8_t short_video_header;
207 uint8_t rounding_control;
208 uint8_t alternate_vertical_scan_flag;
209 uint8_t top_field_first;
210
211 const uint8_t *intra_matrix;
212 const uint8_t *non_intra_matrix;
213
214 struct pipe_video_buffer *ref[2];
215 };
216
217 struct pipe_vc1_picture_desc
218 {
219 struct pipe_picture_desc base;
220
221 uint32_t slice_count;
222 uint8_t picture_type;
223 uint8_t frame_coding_mode;
224 uint8_t postprocflag;
225 uint8_t pulldown;
226 uint8_t interlace;
227 uint8_t tfcntrflag;
228 uint8_t finterpflag;
229 uint8_t psf;
230 uint8_t dquant;
231 uint8_t panscan_flag;
232 uint8_t refdist_flag;
233 uint8_t quantizer;
234 uint8_t extended_mv;
235 uint8_t extended_dmv;
236 uint8_t overlap;
237 uint8_t vstransform;
238 uint8_t loopfilter;
239 uint8_t fastuvmc;
240 uint8_t range_mapy_flag;
241 uint8_t range_mapy;
242 uint8_t range_mapuv_flag;
243 uint8_t range_mapuv;
244 uint8_t multires;
245 uint8_t syncmarker;
246 uint8_t rangered;
247 uint8_t maxbframes;
248 uint8_t deblockEnable;
249 uint8_t pquant;
250
251 struct pipe_video_buffer *ref[2];
252 };
253
254 struct pipe_h264_sps
255 {
256 uint8_t chroma_format_idc;
257 uint8_t separate_colour_plane_flag;
258 uint8_t bit_depth_luma_minus8;
259 uint8_t bit_depth_chroma_minus8;
260 uint8_t seq_scaling_matrix_present_flag;
261 uint8_t ScalingList4x4[6][16];
262 uint8_t ScalingList8x8[6][64];
263 uint8_t log2_max_frame_num_minus4;
264 uint8_t pic_order_cnt_type;
265 uint8_t log2_max_pic_order_cnt_lsb_minus4;
266 uint8_t delta_pic_order_always_zero_flag;
267 int32_t offset_for_non_ref_pic;
268 int32_t offset_for_top_to_bottom_field;
269 uint8_t num_ref_frames_in_pic_order_cnt_cycle;
270 int32_t offset_for_ref_frame[256];
271 uint8_t max_num_ref_frames;
272 uint8_t frame_mbs_only_flag;
273 uint8_t mb_adaptive_frame_field_flag;
274 uint8_t direct_8x8_inference_flag;
275 };
276
277 struct pipe_h264_pps
278 {
279 struct pipe_h264_sps *sps;
280
281 uint8_t entropy_coding_mode_flag;
282 uint8_t bottom_field_pic_order_in_frame_present_flag;
283 uint8_t num_slice_groups_minus1;
284 uint8_t slice_group_map_type;
285 uint8_t slice_group_change_rate_minus1;
286 uint8_t num_ref_idx_l0_default_active_minus1;
287 uint8_t num_ref_idx_l1_default_active_minus1;
288 uint8_t weighted_pred_flag;
289 uint8_t weighted_bipred_idc;
290 int8_t pic_init_qp_minus26;
291 int8_t chroma_qp_index_offset;
292 uint8_t deblocking_filter_control_present_flag;
293 uint8_t constrained_intra_pred_flag;
294 uint8_t redundant_pic_cnt_present_flag;
295 uint8_t ScalingList4x4[6][16];
296 uint8_t ScalingList8x8[6][64];
297 uint8_t transform_8x8_mode_flag;
298 int8_t second_chroma_qp_index_offset;
299 };
300
301 struct pipe_h264_picture_desc
302 {
303 struct pipe_picture_desc base;
304
305 struct pipe_h264_pps *pps;
306
307 /* slice header */
308 uint32_t frame_num;
309 uint8_t field_pic_flag;
310 uint8_t bottom_field_flag;
311 uint8_t num_ref_idx_l0_active_minus1;
312 uint8_t num_ref_idx_l1_active_minus1;
313
314 uint32_t slice_count;
315 int32_t field_order_cnt[2];
316 bool is_reference;
317 uint8_t num_ref_frames;
318
319 bool is_long_term[16];
320 bool top_is_reference[16];
321 bool bottom_is_reference[16];
322 uint32_t field_order_cnt_list[16][2];
323 uint32_t frame_num_list[16];
324
325 struct pipe_video_buffer *ref[16];
326 };
327
328 #ifdef __cplusplus
329 }
330 #endif
331
332 #endif /* PIPE_VIDEO_STATE_H */