[g3dvl] Implement MPEG2 VLD
[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 TUNGSTEN GRAPHICS 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 struct pipe_video_rect
42 {
43 unsigned x, y, w, h;
44 };
45
46 enum pipe_mpeg12_picture_type
47 {
48 PIPE_MPEG12_PICTURE_TYPE_FIELD_TOP,
49 PIPE_MPEG12_PICTURE_TYPE_FIELD_BOTTOM,
50 PIPE_MPEG12_PICTURE_TYPE_FRAME
51 };
52
53 enum pipe_mpeg12_dct_intra
54 {
55 PIPE_MPEG12_DCT_DELTA = 0,
56 PIPE_MPEG12_DCT_INTRA = 1
57 };
58
59 enum pipe_mpeg12_dct_type
60 {
61 PIPE_MPEG12_DCT_TYPE_FRAME = 0,
62 PIPE_MPEG12_DCT_TYPE_FIELD = 1
63 };
64
65 enum pipe_video_field_select
66 {
67 PIPE_VIDEO_FRAME = 0,
68 PIPE_VIDEO_TOP_FIELD = 1,
69 PIPE_VIDEO_BOTTOM_FIELD = 3,
70
71 /* TODO
72 PIPE_VIDEO_DUALPRIME
73 PIPE_VIDEO_16x8
74 */
75 };
76
77 enum pipe_video_mv_weight
78 {
79 PIPE_VIDEO_MV_WEIGHT_MIN = 0,
80 PIPE_VIDEO_MV_WEIGHT_HALF = 128,
81 PIPE_VIDEO_MV_WEIGHT_MAX = 256
82 };
83
84 /* bitfields because this is used as a vertex buffer element */
85 struct pipe_motionvector
86 {
87 struct {
88 signed x:16, y:16;
89 enum pipe_video_field_select field_select:16;
90 enum pipe_video_mv_weight weight:16;
91 } top, bottom;
92 };
93
94 /* bitfields because this is used as a vertex buffer element */
95 struct pipe_ycbcr_block
96 {
97 unsigned x:8, y:8;
98 enum pipe_mpeg12_dct_intra intra:8;
99 enum pipe_mpeg12_dct_type coding:8;
100 };
101
102 struct pipe_picture_desc
103 {
104 enum pipe_video_profile profile;
105 };
106
107 struct pipe_mpeg12_picture_desc
108 {
109 struct pipe_picture_desc base;
110
111 unsigned picture_coding_type;
112 unsigned picture_structure;
113 unsigned frame_pred_frame_dct;
114 unsigned q_scale_type;
115 unsigned alternate_scan;
116 unsigned intra_dc_precision;
117 unsigned intra_vlc_format;
118 unsigned concealment_motion_vectors;
119 unsigned f_code[2][2];
120
121 bool mpeg1;
122 uint8_t *intra_quantizer_matrix;
123 uint8_t *non_intra_quantizer_matrix;
124
125 /* predictor for DC coefficients in intra blocks */
126 int16_t dc_dct_pred[3];
127
128 int quantizer_scale;
129
130 #if 0
131 /* TODO: Use bitfields where possible? */
132 unsigned top_field_first;
133 unsigned full_pel_forward_vector;
134 unsigned full_pel_backward_vector;
135 struct pipe_buffer *chroma_intra_quantizer_matrix;
136 struct pipe_buffer *chroma_non_intra_quantizer_matrix;
137 #endif
138 };
139
140 #ifdef __cplusplus
141 }
142 #endif
143
144 #endif /* PIPE_VIDEO_STATE_H */