g3dvl: Rework the decoder interface part 1/5
[mesa.git] / src / gallium / include / pipe / p_video_decoder.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_CONTEXT_H
29 #define PIPE_VIDEO_CONTEXT_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #include <pipe/p_video_state.h>
36
37 struct pipe_screen;
38 struct pipe_surface;
39 struct pipe_macroblock;
40 struct pipe_picture_desc;
41 struct pipe_fence_handle;
42
43 /**
44 * Gallium video decoder for a specific codec/profile
45 */
46 struct pipe_video_decoder
47 {
48 struct pipe_context *context;
49
50 enum pipe_video_profile profile;
51 enum pipe_video_entrypoint entrypoint;
52 enum pipe_video_chroma_format chroma_format;
53 unsigned width;
54 unsigned height;
55
56 /**
57 * destroy this video decoder
58 */
59 void (*destroy)(struct pipe_video_decoder *decoder);
60
61 /**
62 * Creates a decoder buffer
63 */
64 void *(*create_buffer)(struct pipe_video_decoder *decoder);
65
66 /**
67 * Destroys a decoder buffer
68 */
69 void (*destroy_buffer)(struct pipe_video_decoder *decoder, void *buffer);
70
71 /**
72 * set the current decoder buffer
73 */
74 void (*set_decode_buffer)(struct pipe_video_decoder *decoder, void *buffer);
75
76 /**
77 * set the picture parameters for the next frame
78 * only used for bitstream decoding
79 */
80 void (*set_picture_parameters)(struct pipe_video_decoder *decoder,
81 struct pipe_picture_desc *picture);
82
83 /**
84 * set the quantification matrixes
85 */
86 void (*set_quant_matrix)(struct pipe_video_decoder *decoder,
87 const uint8_t intra_matrix[64],
88 const uint8_t non_intra_matrix[64]);
89
90 /**
91 * set target where video data is decoded to
92 */
93 void (*set_decode_target)(struct pipe_video_decoder *decoder,
94 struct pipe_video_buffer *target);
95
96 /**
97 * set reference frames for motion compensation
98 */
99 void (*set_reference_frames)(struct pipe_video_decoder *decoder,
100 struct pipe_video_buffer **ref_frames,
101 unsigned num_ref_frames);
102
103 /**
104 * start decoding of a new frame
105 */
106 void (*begin_frame)(struct pipe_video_decoder *decoder);
107
108 /**
109 * get the pointer where to put the ycbcr blocks of a component
110 */
111 struct pipe_ycbcr_block *(*get_ycbcr_stream)(struct pipe_video_decoder *decoder, int component);
112
113 /**
114 * get the pointer where to put the ycbcr dct block data of a component
115 */
116 short *(*get_ycbcr_buffer)(struct pipe_video_decoder *decoder, int component);
117
118 /**
119 * get the stride of the mv buffer
120 */
121 unsigned (*get_mv_stream_stride)(struct pipe_video_decoder *decoder);
122
123 /**
124 * get the pointer where to put the motion vectors of a ref frame
125 */
126 struct pipe_motionvector *(*get_mv_stream)(struct pipe_video_decoder *decoder, int ref_frame);
127
128 /**
129 * decode a bitstream
130 */
131 void (*decode_bitstream)(struct pipe_video_decoder *decoder,
132 unsigned num_bytes, const void *data,
133 unsigned num_ycbcr_blocks[3]);
134
135 /**
136 * end decoding of the current frame
137 */
138 void (*end_frame)(struct pipe_video_decoder *decoder, unsigned num_ycbcr_blocks[3]);
139
140 /**
141 * flush any outstanding command buffers to the hardware
142 * should be called before a video_buffer is acessed by the state tracker again
143 */
144 void (*flush)(struct pipe_video_decoder *decoder);
145 };
146
147 /**
148 * output for decoding / input for displaying
149 */
150 struct pipe_video_buffer
151 {
152 struct pipe_context *context;
153
154 enum pipe_format buffer_format;
155 enum pipe_video_chroma_format chroma_format;
156 unsigned width;
157 unsigned height;
158
159 /**
160 * destroy this video buffer
161 */
162 void (*destroy)(struct pipe_video_buffer *buffer);
163
164 /**
165 * get a individual sampler view for each plane
166 */
167 struct pipe_sampler_view **(*get_sampler_view_planes)(struct pipe_video_buffer *buffer);
168
169 /**
170 * get a individual sampler view for each component
171 */
172 struct pipe_sampler_view **(*get_sampler_view_components)(struct pipe_video_buffer *buffer);
173
174 /**
175 * get a individual surfaces for each plane
176 */
177 struct pipe_surface **(*get_surfaces)(struct pipe_video_buffer *buffer);
178 };
179
180 #ifdef __cplusplus
181 }
182 #endif
183
184 #endif /* PIPE_VIDEO_CONTEXT_H */