77e22d0a566a2ee512e9a6c6e843da364a81714c
[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 /* u_reduce_video_profile() needs these */
32 #include <pipe/p_compiler.h>
33
34 #include <pipe/p_defines.h>
35 #include <pipe/p_format.h>
36 #include <pipe/p_state.h>
37 #include <pipe/p_screen.h>
38 #include <util/u_inlines.h>
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 struct pipe_video_surface
45 {
46 struct pipe_reference reference;
47 struct pipe_screen *screen;
48 enum pipe_video_chroma_format chroma_format;
49 /*enum pipe_video_surface_format surface_format;*/
50 unsigned width;
51 unsigned height;
52 };
53
54 static INLINE void
55 pipe_video_surface_reference(struct pipe_video_surface **ptr, struct pipe_video_surface *surf)
56 {
57 struct pipe_video_surface *old_surf = *ptr;
58
59 if (pipe_reference(&(*ptr)->reference, &surf->reference))
60 old_surf->screen->video_surface_destroy(old_surf);
61 *ptr = surf;
62 }
63
64 struct pipe_video_rect
65 {
66 unsigned x, y, w, h;
67 };
68
69 static INLINE enum pipe_video_codec
70 u_reduce_video_profile(enum pipe_video_profile profile)
71 {
72 switch (profile)
73 {
74 case PIPE_VIDEO_PROFILE_MPEG1:
75 case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
76 case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
77 return PIPE_VIDEO_CODEC_MPEG12;
78
79 case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE:
80 case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:
81 return PIPE_VIDEO_CODEC_MPEG4;
82
83 case PIPE_VIDEO_PROFILE_VC1_SIMPLE:
84 case PIPE_VIDEO_PROFILE_VC1_MAIN:
85 case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
86 return PIPE_VIDEO_CODEC_VC1;
87
88 case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
89 case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
90 case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
91 return PIPE_VIDEO_CODEC_MPEG4_AVC;
92
93 default:
94 assert(0);
95 return PIPE_VIDEO_CODEC_UNKNOWN;
96 }
97 }
98
99 enum pipe_mpeg12_picture_type
100 {
101 PIPE_MPEG12_PICTURE_TYPE_FIELD_TOP,
102 PIPE_MPEG12_PICTURE_TYPE_FIELD_BOTTOM,
103 PIPE_MPEG12_PICTURE_TYPE_FRAME
104 };
105
106 enum pipe_mpeg12_macroblock_type
107 {
108 PIPE_MPEG12_MACROBLOCK_TYPE_INTRA,
109 PIPE_MPEG12_MACROBLOCK_TYPE_FWD,
110 PIPE_MPEG12_MACROBLOCK_TYPE_BKWD,
111 PIPE_MPEG12_MACROBLOCK_TYPE_BI,
112
113 PIPE_MPEG12_MACROBLOCK_NUM_TYPES
114 };
115
116 enum pipe_mpeg12_motion_type
117 {
118 PIPE_MPEG12_MOTION_TYPE_FIELD,
119 PIPE_MPEG12_MOTION_TYPE_FRAME,
120 PIPE_MPEG12_MOTION_TYPE_DUALPRIME,
121 PIPE_MPEG12_MOTION_TYPE_16x8
122 };
123
124 enum pipe_mpeg12_dct_type
125 {
126 PIPE_MPEG12_DCT_TYPE_FIELD,
127 PIPE_MPEG12_DCT_TYPE_FRAME
128 };
129
130 struct pipe_macroblock
131 {
132 enum pipe_video_codec codec;
133 };
134
135 struct pipe_mpeg12_macroblock
136 {
137 struct pipe_macroblock base;
138
139 unsigned mbx;
140 unsigned mby;
141 enum pipe_mpeg12_macroblock_type mb_type;
142 enum pipe_mpeg12_motion_type mo_type;
143 enum pipe_mpeg12_dct_type dct_type;
144 signed pmv[2][2][2];
145 unsigned cbp;
146 void *blocks;
147 };
148
149 #if 0
150 struct pipe_picture_desc
151 {
152 enum pipe_video_format format;
153 };
154
155 struct pipe_mpeg12_picture_desc
156 {
157 struct pipe_picture_desc base;
158
159 /* TODO: Use bitfields where possible? */
160 struct pipe_surface *forward_reference;
161 struct pipe_surface *backward_reference;
162 unsigned picture_coding_type;
163 unsigned fcode;
164 unsigned intra_dc_precision;
165 unsigned picture_structure;
166 unsigned top_field_first;
167 unsigned frame_pred_frame_dct;
168 unsigned concealment_motion_vectors;
169 unsigned q_scale_type;
170 unsigned intra_vlc_format;
171 unsigned alternate_scan;
172 unsigned full_pel_forward_vector;
173 unsigned full_pel_backward_vector;
174 struct pipe_buffer *intra_quantizer_matrix;
175 struct pipe_buffer *non_intra_quantizer_matrix;
176 struct pipe_buffer *chroma_intra_quantizer_matrix;
177 struct pipe_buffer *chroma_non_intra_quantizer_matrix;
178 };
179 #endif
180
181 #ifdef __cplusplus
182 }
183 #endif
184
185 #endif /* PIPE_VIDEO_STATE_H */