vl: add H264 encoding interface
[mesa.git] / src / gallium / include / pipe / p_video_codec.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_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 codec for a specific format/profile
45 */
46 struct pipe_video_codec
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 unsigned max_references;
56 bool expect_chunked_decode;
57
58 /**
59 * destroy this video decoder
60 */
61 void (*destroy)(struct pipe_video_codec *codec);
62
63 /**
64 * start decoding of a new frame
65 */
66 void (*begin_frame)(struct pipe_video_codec *codec,
67 struct pipe_video_buffer *target,
68 struct pipe_picture_desc *picture);
69
70 /**
71 * decode a macroblock
72 */
73 void (*decode_macroblock)(struct pipe_video_codec *codec,
74 struct pipe_video_buffer *target,
75 struct pipe_picture_desc *picture,
76 const struct pipe_macroblock *macroblocks,
77 unsigned num_macroblocks);
78
79 /**
80 * decode a bitstream
81 */
82 void (*decode_bitstream)(struct pipe_video_codec *codec,
83 struct pipe_video_buffer *target,
84 struct pipe_picture_desc *picture,
85 unsigned num_buffers,
86 const void * const *buffers,
87 const unsigned *sizes);
88
89 /**
90 * encode to a bitstream
91 */
92 void (*encode_bitstream)(struct pipe_video_codec *codec,
93 struct pipe_video_buffer *source,
94 struct pipe_resource *destination,
95 void **feedback);
96
97 /**
98 * end decoding of the current frame
99 */
100 void (*end_frame)(struct pipe_video_codec *codec,
101 struct pipe_video_buffer *target,
102 struct pipe_picture_desc *picture);
103
104 /**
105 * flush any outstanding command buffers to the hardware
106 * should be called before a video_buffer is acessed by the state tracker again
107 */
108 void (*flush)(struct pipe_video_codec *codec);
109
110 /**
111 * get encoder feedback
112 */
113 void (*get_feedback)(struct pipe_video_codec *codec, void *feedback, unsigned *size);
114 };
115
116 /**
117 * output for decoding / input for displaying
118 */
119 struct pipe_video_buffer
120 {
121 struct pipe_context *context;
122
123 enum pipe_format buffer_format;
124 enum pipe_video_chroma_format chroma_format;
125 unsigned width;
126 unsigned height;
127 bool interlaced;
128
129 /**
130 * destroy this video buffer
131 */
132 void (*destroy)(struct pipe_video_buffer *buffer);
133
134 /**
135 * get a individual sampler view for each plane
136 */
137 struct pipe_sampler_view **(*get_sampler_view_planes)(struct pipe_video_buffer *buffer);
138
139 /**
140 * get a individual sampler view for each component
141 */
142 struct pipe_sampler_view **(*get_sampler_view_components)(struct pipe_video_buffer *buffer);
143
144 /**
145 * get a individual surfaces for each plane
146 */
147 struct pipe_surface **(*get_surfaces)(struct pipe_video_buffer *buffer);
148
149 /*
150 * auxiliary associated data
151 */
152 void *associated_data;
153
154 /*
155 * codec where the associated data came from
156 */
157 struct pipe_video_codec *codec;
158
159 /*
160 * destroy the associated data
161 */
162 void (*destroy_associated_data)(void *associated_data);
163 };
164
165 #ifdef __cplusplus
166 }
167 #endif
168
169 #endif /* PIPE_VIDEO_CONTEXT_H */