Merge lp:~3v1n0/ubuntu/trusty/vdpau-video/fix-buffers into lp:ubuntu/trusty/vdpau-video
- Trusty (14.04)
- fix-buffers
- Merge into trusty
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Merge reported by: | Martin Pitt |
Merged at revision: | not available |
Proposed branch: | lp:~3v1n0/ubuntu/trusty/vdpau-video/fix-buffers |
Merge into: | lp:ubuntu/trusty/vdpau-video |
Diff against target: |
4699 lines (+4523/-11) 17 files modified
.pc/01_dont_clear_va_buffer_too_early.patch/src/vdpau_buffer.c (+257/-0) .pc/01_dont_clear_va_buffer_too_early.patch/src/vdpau_buffer.h (+115/-0) .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_buffer.c (+259/-0) .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_buffer.h (+116/-0) .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_decode.c (+1271/-0) .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_video.c (+995/-0) .pc/03_mark_destroyed_buffers_as_deleted.patch/src/vdpau_decode.c (+1264/-0) .pc/applied-patches (+3/-0) debian/changelog (+7/-0) debian/patches/01_dont_clear_va_buffer_too_early.patch (+56/-0) debian/patches/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch (+111/-0) debian/patches/03_mark_destroyed_buffers_as_deleted.patch (+28/-0) debian/patches/series (+3/-0) src/vdpau_buffer.c (+24/-1) src/vdpau_buffer.h (+8/-0) src/vdpau_decode.c (+4/-10) src/vdpau_video.c (+2/-0) |
To merge this branch: | bzr merge lp:~3v1n0/ubuntu/trusty/vdpau-video/fix-buffers |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Pitt | Approve | ||
Review via email: mp+218516@code.launchpad.net |
Commit message
Added patch-set from upstream to fix crash when using gstreamer-vaapi
Description of the change
Backported upstream commits:
- http://
- http://
- http://
They fixes a crash when using gstreamer-vaapi.
To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Thank you!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory '.pc/01_dont_clear_va_buffer_too_early.patch' | |||
2 | === added directory '.pc/01_dont_clear_va_buffer_too_early.patch/src' | |||
3 | === added file '.pc/01_dont_clear_va_buffer_too_early.patch/src/vdpau_buffer.c' | |||
4 | --- .pc/01_dont_clear_va_buffer_too_early.patch/src/vdpau_buffer.c 1970-01-01 00:00:00 +0000 | |||
5 | +++ .pc/01_dont_clear_va_buffer_too_early.patch/src/vdpau_buffer.c 2014-05-06 21:31:51 +0000 | |||
6 | @@ -0,0 +1,257 @@ | |||
7 | 1 | /* | ||
8 | 2 | * vdpau_buffer.c - VDPAU backend for VA-API (VA buffers) | ||
9 | 3 | * | ||
10 | 4 | * vdpau-video (C) 2009-2011 Splitted-Desktop Systems | ||
11 | 5 | * | ||
12 | 6 | * This program is free software; you can redistribute it and/or modify | ||
13 | 7 | * it under the terms of the GNU General Public License as published by | ||
14 | 8 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | 9 | * (at your option) any later version. | ||
16 | 10 | * | ||
17 | 11 | * This program is distributed in the hope that it will be useful, | ||
18 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | 14 | * GNU General Public License for more details. | ||
21 | 15 | * | ||
22 | 16 | * You should have received a copy of the GNU General Public License | ||
23 | 17 | * along with this program; if not, write to the Free Software | ||
24 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
25 | 19 | */ | ||
26 | 20 | |||
27 | 21 | #include "sysdeps.h" | ||
28 | 22 | #include "vdpau_buffer.h" | ||
29 | 23 | #include "vdpau_driver.h" | ||
30 | 24 | #include "vdpau_video.h" | ||
31 | 25 | #include "vdpau_dump.h" | ||
32 | 26 | #include "utils.h" | ||
33 | 27 | |||
34 | 28 | #define DEBUG 1 | ||
35 | 29 | #include "debug.h" | ||
36 | 30 | |||
37 | 31 | |||
38 | 32 | // Create VA buffer object | ||
39 | 33 | object_buffer_p | ||
40 | 34 | create_va_buffer( | ||
41 | 35 | vdpau_driver_data_t *driver_data, | ||
42 | 36 | VAContextID context, | ||
43 | 37 | VABufferType buffer_type, | ||
44 | 38 | unsigned int num_elements, | ||
45 | 39 | unsigned int size | ||
46 | 40 | ) | ||
47 | 41 | { | ||
48 | 42 | VABufferID buffer_id; | ||
49 | 43 | object_buffer_p obj_buffer; | ||
50 | 44 | |||
51 | 45 | buffer_id = object_heap_allocate(&driver_data->buffer_heap); | ||
52 | 46 | if (buffer_id == VA_INVALID_BUFFER) | ||
53 | 47 | return NULL; | ||
54 | 48 | |||
55 | 49 | obj_buffer = VDPAU_BUFFER(buffer_id); | ||
56 | 50 | if (!obj_buffer) | ||
57 | 51 | return NULL; | ||
58 | 52 | |||
59 | 53 | obj_buffer->va_context = context; | ||
60 | 54 | obj_buffer->type = buffer_type; | ||
61 | 55 | obj_buffer->max_num_elements = num_elements; | ||
62 | 56 | obj_buffer->num_elements = num_elements; | ||
63 | 57 | obj_buffer->buffer_size = size * num_elements; | ||
64 | 58 | obj_buffer->buffer_data = malloc(obj_buffer->buffer_size); | ||
65 | 59 | obj_buffer->mtime = 0; | ||
66 | 60 | |||
67 | 61 | if (!obj_buffer->buffer_data) { | ||
68 | 62 | destroy_va_buffer(driver_data, obj_buffer); | ||
69 | 63 | return NULL; | ||
70 | 64 | } | ||
71 | 65 | return obj_buffer; | ||
72 | 66 | } | ||
73 | 67 | |||
74 | 68 | // Destroy VA buffer object | ||
75 | 69 | void | ||
76 | 70 | destroy_va_buffer( | ||
77 | 71 | vdpau_driver_data_t *driver_data, | ||
78 | 72 | object_buffer_p obj_buffer | ||
79 | 73 | ) | ||
80 | 74 | { | ||
81 | 75 | if (!obj_buffer) | ||
82 | 76 | return; | ||
83 | 77 | |||
84 | 78 | if (obj_buffer->buffer_data) { | ||
85 | 79 | free(obj_buffer->buffer_data); | ||
86 | 80 | obj_buffer->buffer_data = NULL; | ||
87 | 81 | } | ||
88 | 82 | object_heap_free(&driver_data->buffer_heap, (object_base_p)obj_buffer); | ||
89 | 83 | } | ||
90 | 84 | |||
91 | 85 | // Schedule VA buffer object for destruction | ||
92 | 86 | void | ||
93 | 87 | schedule_destroy_va_buffer( | ||
94 | 88 | vdpau_driver_data_p driver_data, | ||
95 | 89 | object_buffer_p obj_buffer | ||
96 | 90 | ) | ||
97 | 91 | { | ||
98 | 92 | object_context_p obj_context = VDPAU_CONTEXT(obj_buffer->va_context); | ||
99 | 93 | if (!obj_context) | ||
100 | 94 | return; | ||
101 | 95 | |||
102 | 96 | realloc_buffer( | ||
103 | 97 | &obj_context->dead_buffers, | ||
104 | 98 | &obj_context->dead_buffers_count_max, | ||
105 | 99 | 16 + obj_context->dead_buffers_count, | ||
106 | 100 | sizeof(*obj_context->dead_buffers) | ||
107 | 101 | ); | ||
108 | 102 | |||
109 | 103 | ASSERT(obj_context->dead_buffers); | ||
110 | 104 | obj_context->dead_buffers[obj_context->dead_buffers_count] = obj_buffer->base.id; | ||
111 | 105 | obj_context->dead_buffers_count++; | ||
112 | 106 | } | ||
113 | 107 | |||
114 | 108 | // vaCreateBuffer | ||
115 | 109 | VAStatus | ||
116 | 110 | vdpau_CreateBuffer( | ||
117 | 111 | VADriverContextP ctx, | ||
118 | 112 | VAContextID context, | ||
119 | 113 | VABufferType type, | ||
120 | 114 | unsigned int size, | ||
121 | 115 | unsigned int num_elements, | ||
122 | 116 | void *data, | ||
123 | 117 | VABufferID *buf_id | ||
124 | 118 | ) | ||
125 | 119 | { | ||
126 | 120 | VDPAU_DRIVER_DATA_INIT; | ||
127 | 121 | |||
128 | 122 | if (buf_id) | ||
129 | 123 | *buf_id = VA_INVALID_BUFFER; | ||
130 | 124 | |||
131 | 125 | /* Validate type */ | ||
132 | 126 | switch (type) { | ||
133 | 127 | case VAPictureParameterBufferType: | ||
134 | 128 | case VAIQMatrixBufferType: | ||
135 | 129 | case VASliceParameterBufferType: | ||
136 | 130 | case VASliceDataBufferType: | ||
137 | 131 | case VABitPlaneBufferType: | ||
138 | 132 | case VAImageBufferType: | ||
139 | 133 | /* Ok */ | ||
140 | 134 | break; | ||
141 | 135 | default: | ||
142 | 136 | D(bug("ERROR: unsupported buffer type %d\n", type)); | ||
143 | 137 | return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; | ||
144 | 138 | } | ||
145 | 139 | |||
146 | 140 | object_buffer_p obj_buffer; | ||
147 | 141 | obj_buffer = create_va_buffer(driver_data, context, type, num_elements, size); | ||
148 | 142 | if (!obj_buffer) | ||
149 | 143 | return VA_STATUS_ERROR_ALLOCATION_FAILED; | ||
150 | 144 | |||
151 | 145 | if (data) | ||
152 | 146 | memcpy(obj_buffer->buffer_data, data, obj_buffer->buffer_size); | ||
153 | 147 | |||
154 | 148 | if (buf_id) | ||
155 | 149 | *buf_id = obj_buffer->base.id; | ||
156 | 150 | |||
157 | 151 | return VA_STATUS_SUCCESS; | ||
158 | 152 | } | ||
159 | 153 | |||
160 | 154 | // vaDestroyBuffer | ||
161 | 155 | VAStatus | ||
162 | 156 | vdpau_DestroyBuffer( | ||
163 | 157 | VADriverContextP ctx, | ||
164 | 158 | VABufferID buffer_id | ||
165 | 159 | ) | ||
166 | 160 | { | ||
167 | 161 | VDPAU_DRIVER_DATA_INIT; | ||
168 | 162 | |||
169 | 163 | object_buffer_p obj_buffer = VDPAU_BUFFER(buffer_id); | ||
170 | 164 | |||
171 | 165 | if (obj_buffer) | ||
172 | 166 | destroy_va_buffer(driver_data, obj_buffer); | ||
173 | 167 | |||
174 | 168 | return VA_STATUS_SUCCESS; | ||
175 | 169 | } | ||
176 | 170 | |||
177 | 171 | // vaBufferSetNumElements | ||
178 | 172 | VAStatus | ||
179 | 173 | vdpau_BufferSetNumElements( | ||
180 | 174 | VADriverContextP ctx, | ||
181 | 175 | VABufferID buf_id, | ||
182 | 176 | unsigned int num_elements | ||
183 | 177 | ) | ||
184 | 178 | { | ||
185 | 179 | VDPAU_DRIVER_DATA_INIT; | ||
186 | 180 | |||
187 | 181 | object_buffer_p obj_buffer = VDPAU_BUFFER(buf_id); | ||
188 | 182 | if (!obj_buffer) | ||
189 | 183 | return VA_STATUS_ERROR_INVALID_BUFFER; | ||
190 | 184 | |||
191 | 185 | if (num_elements < 0 || num_elements > obj_buffer->max_num_elements) | ||
192 | 186 | return VA_STATUS_ERROR_UNKNOWN; | ||
193 | 187 | |||
194 | 188 | obj_buffer->num_elements = num_elements; | ||
195 | 189 | return VA_STATUS_SUCCESS; | ||
196 | 190 | } | ||
197 | 191 | |||
198 | 192 | // vaMapBuffer | ||
199 | 193 | VAStatus | ||
200 | 194 | vdpau_MapBuffer( | ||
201 | 195 | VADriverContextP ctx, | ||
202 | 196 | VABufferID buf_id, | ||
203 | 197 | void **pbuf | ||
204 | 198 | ) | ||
205 | 199 | { | ||
206 | 200 | VDPAU_DRIVER_DATA_INIT; | ||
207 | 201 | |||
208 | 202 | object_buffer_p obj_buffer = VDPAU_BUFFER(buf_id); | ||
209 | 203 | if (!obj_buffer) | ||
210 | 204 | return VA_STATUS_ERROR_INVALID_BUFFER; | ||
211 | 205 | |||
212 | 206 | if (pbuf) | ||
213 | 207 | *pbuf = obj_buffer->buffer_data; | ||
214 | 208 | |||
215 | 209 | if (obj_buffer->buffer_data == NULL) | ||
216 | 210 | return VA_STATUS_ERROR_UNKNOWN; | ||
217 | 211 | |||
218 | 212 | ++obj_buffer->mtime; | ||
219 | 213 | return VA_STATUS_SUCCESS; | ||
220 | 214 | } | ||
221 | 215 | |||
222 | 216 | // vaUnmapBuffer | ||
223 | 217 | VAStatus | ||
224 | 218 | vdpau_UnmapBuffer( | ||
225 | 219 | VADriverContextP ctx, | ||
226 | 220 | VABufferID buf_id | ||
227 | 221 | ) | ||
228 | 222 | { | ||
229 | 223 | VDPAU_DRIVER_DATA_INIT; | ||
230 | 224 | |||
231 | 225 | object_buffer_p obj_buffer = VDPAU_BUFFER(buf_id); | ||
232 | 226 | if (!obj_buffer) | ||
233 | 227 | return VA_STATUS_ERROR_INVALID_BUFFER; | ||
234 | 228 | |||
235 | 229 | ++obj_buffer->mtime; | ||
236 | 230 | return VA_STATUS_SUCCESS; | ||
237 | 231 | } | ||
238 | 232 | |||
239 | 233 | // vaBufferInfo | ||
240 | 234 | VAStatus | ||
241 | 235 | vdpau_BufferInfo( | ||
242 | 236 | VADriverContextP ctx, | ||
243 | 237 | VAContextID context, | ||
244 | 238 | VABufferID buf_id, | ||
245 | 239 | VABufferType *type, | ||
246 | 240 | unsigned int *size, | ||
247 | 241 | unsigned int *num_elements | ||
248 | 242 | ) | ||
249 | 243 | { | ||
250 | 244 | VDPAU_DRIVER_DATA_INIT; | ||
251 | 245 | |||
252 | 246 | object_buffer_p obj_buffer = VDPAU_BUFFER(buf_id); | ||
253 | 247 | if (!obj_buffer) | ||
254 | 248 | return VA_STATUS_ERROR_INVALID_BUFFER; | ||
255 | 249 | |||
256 | 250 | if (type) | ||
257 | 251 | *type = obj_buffer->type; | ||
258 | 252 | if (size) | ||
259 | 253 | *size = obj_buffer->buffer_size / obj_buffer->num_elements; | ||
260 | 254 | if (num_elements) | ||
261 | 255 | *num_elements = obj_buffer->num_elements; | ||
262 | 256 | return VA_STATUS_SUCCESS; | ||
263 | 257 | } | ||
264 | 0 | 258 | ||
265 | === added file '.pc/01_dont_clear_va_buffer_too_early.patch/src/vdpau_buffer.h' | |||
266 | --- .pc/01_dont_clear_va_buffer_too_early.patch/src/vdpau_buffer.h 1970-01-01 00:00:00 +0000 | |||
267 | +++ .pc/01_dont_clear_va_buffer_too_early.patch/src/vdpau_buffer.h 2014-05-06 21:31:51 +0000 | |||
268 | @@ -0,0 +1,115 @@ | |||
269 | 1 | /* | ||
270 | 2 | * vdpau_buffer.h - VDPAU backend for VA-API (VA buffers) | ||
271 | 3 | * | ||
272 | 4 | * vdpau-video (C) 2009-2011 Splitted-Desktop Systems | ||
273 | 5 | * | ||
274 | 6 | * This program is free software; you can redistribute it and/or modify | ||
275 | 7 | * it under the terms of the GNU General Public License as published by | ||
276 | 8 | * the Free Software Foundation; either version 2 of the License, or | ||
277 | 9 | * (at your option) any later version. | ||
278 | 10 | * | ||
279 | 11 | * This program is distributed in the hope that it will be useful, | ||
280 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
281 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
282 | 14 | * GNU General Public License for more details. | ||
283 | 15 | * | ||
284 | 16 | * You should have received a copy of the GNU General Public License | ||
285 | 17 | * along with this program; if not, write to the Free Software | ||
286 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
287 | 19 | */ | ||
288 | 20 | |||
289 | 21 | #ifndef VDPAU_BUFFER_H | ||
290 | 22 | #define VDPAU_BUFFER_H | ||
291 | 23 | |||
292 | 24 | #include "vdpau_driver.h" | ||
293 | 25 | |||
294 | 26 | typedef struct object_buffer object_buffer_t; | ||
295 | 27 | struct object_buffer { | ||
296 | 28 | struct object_base base; | ||
297 | 29 | VAContextID va_context; | ||
298 | 30 | VABufferType type; | ||
299 | 31 | void *buffer_data; | ||
300 | 32 | unsigned int buffer_size; | ||
301 | 33 | unsigned int max_num_elements; | ||
302 | 34 | unsigned int num_elements; | ||
303 | 35 | uint64_t mtime; | ||
304 | 36 | }; | ||
305 | 37 | |||
306 | 38 | // Create VA buffer object | ||
307 | 39 | object_buffer_p | ||
308 | 40 | create_va_buffer( | ||
309 | 41 | vdpau_driver_data_p driver_data, | ||
310 | 42 | VAContextID context, | ||
311 | 43 | VABufferType buffer_type, | ||
312 | 44 | unsigned int num_elements, | ||
313 | 45 | unsigned int size | ||
314 | 46 | ) attribute_hidden; | ||
315 | 47 | |||
316 | 48 | // Destroy VA buffer object | ||
317 | 49 | void | ||
318 | 50 | destroy_va_buffer( | ||
319 | 51 | vdpau_driver_data_p driver_data, | ||
320 | 52 | object_buffer_p obj_buffer | ||
321 | 53 | ) attribute_hidden; | ||
322 | 54 | |||
323 | 55 | // Schedule VA buffer object for destruction | ||
324 | 56 | void | ||
325 | 57 | schedule_destroy_va_buffer( | ||
326 | 58 | vdpau_driver_data_p driver_data, | ||
327 | 59 | object_buffer_p obj_buffer | ||
328 | 60 | ) attribute_hidden; | ||
329 | 61 | |||
330 | 62 | // vaCreateBuffer | ||
331 | 63 | VAStatus | ||
332 | 64 | vdpau_CreateBuffer( | ||
333 | 65 | VADriverContextP ctx, | ||
334 | 66 | VAContextID context, | ||
335 | 67 | VABufferType type, | ||
336 | 68 | unsigned int size, | ||
337 | 69 | unsigned int num_elements, | ||
338 | 70 | void *data, | ||
339 | 71 | VABufferID *buf_id | ||
340 | 72 | ) attribute_hidden; | ||
341 | 73 | |||
342 | 74 | // vaDestroyBuffer | ||
343 | 75 | VAStatus | ||
344 | 76 | vdpau_DestroyBuffer( | ||
345 | 77 | VADriverContextP ctx, | ||
346 | 78 | VABufferID buffer_id | ||
347 | 79 | ) attribute_hidden; | ||
348 | 80 | |||
349 | 81 | // vaBufferSetNumElements | ||
350 | 82 | VAStatus | ||
351 | 83 | vdpau_BufferSetNumElements( | ||
352 | 84 | VADriverContextP ctx, | ||
353 | 85 | VABufferID buf_id, | ||
354 | 86 | unsigned int num_elements | ||
355 | 87 | ) attribute_hidden; | ||
356 | 88 | |||
357 | 89 | // vaMapBuffer | ||
358 | 90 | VAStatus | ||
359 | 91 | vdpau_MapBuffer( | ||
360 | 92 | VADriverContextP ctx, | ||
361 | 93 | VABufferID buf_id, | ||
362 | 94 | void **pbuf | ||
363 | 95 | ) attribute_hidden; | ||
364 | 96 | |||
365 | 97 | // vaUnmapBuffer | ||
366 | 98 | VAStatus | ||
367 | 99 | vdpau_UnmapBuffer( | ||
368 | 100 | VADriverContextP ctx, | ||
369 | 101 | VABufferID buf_id | ||
370 | 102 | ) attribute_hidden; | ||
371 | 103 | |||
372 | 104 | // vaBufferInfo | ||
373 | 105 | VAStatus | ||
374 | 106 | vdpau_BufferInfo( | ||
375 | 107 | VADriverContextP ctx, | ||
376 | 108 | VAContextID context, | ||
377 | 109 | VABufferID buf_id, | ||
378 | 110 | VABufferType *type, | ||
379 | 111 | unsigned int *size, | ||
380 | 112 | unsigned int *num_elements | ||
381 | 113 | ) attribute_hidden; | ||
382 | 114 | |||
383 | 115 | #endif /* VDPAU_BUFFER_H */ | ||
384 | 0 | 116 | ||
385 | === added directory '.pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch' | |||
386 | === added directory '.pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src' | |||
387 | === added file '.pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_buffer.c' | |||
388 | --- .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_buffer.c 1970-01-01 00:00:00 +0000 | |||
389 | +++ .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_buffer.c 2014-05-06 21:31:51 +0000 | |||
390 | @@ -0,0 +1,259 @@ | |||
391 | 1 | /* | ||
392 | 2 | * vdpau_buffer.c - VDPAU backend for VA-API (VA buffers) | ||
393 | 3 | * | ||
394 | 4 | * vdpau-video (C) 2009-2011 Splitted-Desktop Systems | ||
395 | 5 | * | ||
396 | 6 | * This program is free software; you can redistribute it and/or modify | ||
397 | 7 | * it under the terms of the GNU General Public License as published by | ||
398 | 8 | * the Free Software Foundation; either version 2 of the License, or | ||
399 | 9 | * (at your option) any later version. | ||
400 | 10 | * | ||
401 | 11 | * This program is distributed in the hope that it will be useful, | ||
402 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
403 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
404 | 14 | * GNU General Public License for more details. | ||
405 | 15 | * | ||
406 | 16 | * You should have received a copy of the GNU General Public License | ||
407 | 17 | * along with this program; if not, write to the Free Software | ||
408 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
409 | 19 | */ | ||
410 | 20 | |||
411 | 21 | #include "sysdeps.h" | ||
412 | 22 | #include "vdpau_buffer.h" | ||
413 | 23 | #include "vdpau_driver.h" | ||
414 | 24 | #include "vdpau_video.h" | ||
415 | 25 | #include "vdpau_dump.h" | ||
416 | 26 | #include "utils.h" | ||
417 | 27 | |||
418 | 28 | #define DEBUG 1 | ||
419 | 29 | #include "debug.h" | ||
420 | 30 | |||
421 | 31 | |||
422 | 32 | // Create VA buffer object | ||
423 | 33 | object_buffer_p | ||
424 | 34 | create_va_buffer( | ||
425 | 35 | vdpau_driver_data_t *driver_data, | ||
426 | 36 | VAContextID context, | ||
427 | 37 | VABufferType buffer_type, | ||
428 | 38 | unsigned int num_elements, | ||
429 | 39 | unsigned int size | ||
430 | 40 | ) | ||
431 | 41 | { | ||
432 | 42 | VABufferID buffer_id; | ||
433 | 43 | object_buffer_p obj_buffer; | ||
434 | 44 | |||
435 | 45 | buffer_id = object_heap_allocate(&driver_data->buffer_heap); | ||
436 | 46 | if (buffer_id == VA_INVALID_BUFFER) | ||
437 | 47 | return NULL; | ||
438 | 48 | |||
439 | 49 | obj_buffer = VDPAU_BUFFER(buffer_id); | ||
440 | 50 | if (!obj_buffer) | ||
441 | 51 | return NULL; | ||
442 | 52 | |||
443 | 53 | obj_buffer->va_context = context; | ||
444 | 54 | obj_buffer->type = buffer_type; | ||
445 | 55 | obj_buffer->max_num_elements = num_elements; | ||
446 | 56 | obj_buffer->num_elements = num_elements; | ||
447 | 57 | obj_buffer->buffer_size = size * num_elements; | ||
448 | 58 | obj_buffer->buffer_data = malloc(obj_buffer->buffer_size); | ||
449 | 59 | obj_buffer->mtime = 0; | ||
450 | 60 | obj_buffer->delayed_destroy = 0; | ||
451 | 61 | |||
452 | 62 | if (!obj_buffer->buffer_data) { | ||
453 | 63 | destroy_va_buffer(driver_data, obj_buffer); | ||
454 | 64 | return NULL; | ||
455 | 65 | } | ||
456 | 66 | return obj_buffer; | ||
457 | 67 | } | ||
458 | 68 | |||
459 | 69 | // Destroy VA buffer object | ||
460 | 70 | void | ||
461 | 71 | destroy_va_buffer( | ||
462 | 72 | vdpau_driver_data_t *driver_data, | ||
463 | 73 | object_buffer_p obj_buffer | ||
464 | 74 | ) | ||
465 | 75 | { | ||
466 | 76 | if (!obj_buffer) | ||
467 | 77 | return; | ||
468 | 78 | |||
469 | 79 | if (obj_buffer->buffer_data) { | ||
470 | 80 | free(obj_buffer->buffer_data); | ||
471 | 81 | obj_buffer->buffer_data = NULL; | ||
472 | 82 | } | ||
473 | 83 | object_heap_free(&driver_data->buffer_heap, (object_base_p)obj_buffer); | ||
474 | 84 | } | ||
475 | 85 | |||
476 | 86 | // Schedule VA buffer object for destruction | ||
477 | 87 | void | ||
478 | 88 | schedule_destroy_va_buffer( | ||
479 | 89 | vdpau_driver_data_p driver_data, | ||
480 | 90 | object_buffer_p obj_buffer | ||
481 | 91 | ) | ||
482 | 92 | { | ||
483 | 93 | object_context_p obj_context = VDPAU_CONTEXT(obj_buffer->va_context); | ||
484 | 94 | if (!obj_context) | ||
485 | 95 | return; | ||
486 | 96 | |||
487 | 97 | realloc_buffer( | ||
488 | 98 | &obj_context->dead_buffers, | ||
489 | 99 | &obj_context->dead_buffers_count_max, | ||
490 | 100 | 16 + obj_context->dead_buffers_count, | ||
491 | 101 | sizeof(*obj_context->dead_buffers) | ||
492 | 102 | ); | ||
493 | 103 | |||
494 | 104 | ASSERT(obj_context->dead_buffers); | ||
495 | 105 | obj_context->dead_buffers[obj_context->dead_buffers_count] = obj_buffer->base.id; | ||
496 | 106 | obj_context->dead_buffers_count++; | ||
497 | 107 | obj_buffer->delayed_destroy = 1; | ||
498 | 108 | } | ||
499 | 109 | |||
500 | 110 | // vaCreateBuffer | ||
501 | 111 | VAStatus | ||
502 | 112 | vdpau_CreateBuffer( | ||
503 | 113 | VADriverContextP ctx, | ||
504 | 114 | VAContextID context, | ||
505 | 115 | VABufferType type, | ||
506 | 116 | unsigned int size, | ||
507 | 117 | unsigned int num_elements, | ||
508 | 118 | void *data, | ||
509 | 119 | VABufferID *buf_id | ||
510 | 120 | ) | ||
511 | 121 | { | ||
512 | 122 | VDPAU_DRIVER_DATA_INIT; | ||
513 | 123 | |||
514 | 124 | if (buf_id) | ||
515 | 125 | *buf_id = VA_INVALID_BUFFER; | ||
516 | 126 | |||
517 | 127 | /* Validate type */ | ||
518 | 128 | switch (type) { | ||
519 | 129 | case VAPictureParameterBufferType: | ||
520 | 130 | case VAIQMatrixBufferType: | ||
521 | 131 | case VASliceParameterBufferType: | ||
522 | 132 | case VASliceDataBufferType: | ||
523 | 133 | case VABitPlaneBufferType: | ||
524 | 134 | case VAImageBufferType: | ||
525 | 135 | /* Ok */ | ||
526 | 136 | break; | ||
527 | 137 | default: | ||
528 | 138 | D(bug("ERROR: unsupported buffer type %d\n", type)); | ||
529 | 139 | return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; | ||
530 | 140 | } | ||
531 | 141 | |||
532 | 142 | object_buffer_p obj_buffer; | ||
533 | 143 | obj_buffer = create_va_buffer(driver_data, context, type, num_elements, size); | ||
534 | 144 | if (!obj_buffer) | ||
535 | 145 | return VA_STATUS_ERROR_ALLOCATION_FAILED; | ||
536 | 146 | |||
537 | 147 | if (data) | ||
538 | 148 | memcpy(obj_buffer->buffer_data, data, obj_buffer->buffer_size); | ||
539 | 149 | |||
540 | 150 | if (buf_id) | ||
541 | 151 | *buf_id = obj_buffer->base.id; | ||
542 | 152 | |||
543 | 153 | return VA_STATUS_SUCCESS; | ||
544 | 154 | } | ||
545 | 155 | |||
546 | 156 | // vaDestroyBuffer | ||
547 | 157 | VAStatus | ||
548 | 158 | vdpau_DestroyBuffer( | ||
549 | 159 | VADriverContextP ctx, | ||
550 | 160 | VABufferID buffer_id | ||
551 | 161 | ) | ||
552 | 162 | { | ||
553 | 163 | VDPAU_DRIVER_DATA_INIT; | ||
554 | 164 | |||
555 | 165 | object_buffer_p obj_buffer = VDPAU_BUFFER(buffer_id); | ||
556 | 166 | |||
557 | 167 | if (obj_buffer && !obj_buffer->delayed_destroy) | ||
558 | 168 | destroy_va_buffer(driver_data, obj_buffer); | ||
559 | 169 | |||
560 | 170 | return VA_STATUS_SUCCESS; | ||
561 | 171 | } | ||
562 | 172 | |||
563 | 173 | // vaBufferSetNumElements | ||
564 | 174 | VAStatus | ||
565 | 175 | vdpau_BufferSetNumElements( | ||
566 | 176 | VADriverContextP ctx, | ||
567 | 177 | VABufferID buf_id, | ||
568 | 178 | unsigned int num_elements | ||
569 | 179 | ) | ||
570 | 180 | { | ||
571 | 181 | VDPAU_DRIVER_DATA_INIT; | ||
572 | 182 | |||
573 | 183 | object_buffer_p obj_buffer = VDPAU_BUFFER(buf_id); | ||
574 | 184 | if (!obj_buffer) | ||
575 | 185 | return VA_STATUS_ERROR_INVALID_BUFFER; | ||
576 | 186 | |||
577 | 187 | if (num_elements < 0 || num_elements > obj_buffer->max_num_elements) | ||
578 | 188 | return VA_STATUS_ERROR_UNKNOWN; | ||
579 | 189 | |||
580 | 190 | obj_buffer->num_elements = num_elements; | ||
581 | 191 | return VA_STATUS_SUCCESS; | ||
582 | 192 | } | ||
583 | 193 | |||
584 | 194 | // vaMapBuffer | ||
585 | 195 | VAStatus | ||
586 | 196 | vdpau_MapBuffer( | ||
587 | 197 | VADriverContextP ctx, | ||
588 | 198 | VABufferID buf_id, | ||
589 | 199 | void **pbuf | ||
590 | 200 | ) | ||
591 | 201 | { | ||
592 | 202 | VDPAU_DRIVER_DATA_INIT; | ||
593 | 203 | |||
594 | 204 | object_buffer_p obj_buffer = VDPAU_BUFFER(buf_id); | ||
595 | 205 | if (!obj_buffer) | ||
596 | 206 | return VA_STATUS_ERROR_INVALID_BUFFER; | ||
597 | 207 | |||
598 | 208 | if (pbuf) | ||
599 | 209 | *pbuf = obj_buffer->buffer_data; | ||
600 | 210 | |||
601 | 211 | if (obj_buffer->buffer_data == NULL) | ||
602 | 212 | return VA_STATUS_ERROR_UNKNOWN; | ||
603 | 213 | |||
604 | 214 | ++obj_buffer->mtime; | ||
605 | 215 | return VA_STATUS_SUCCESS; | ||
606 | 216 | } | ||
607 | 217 | |||
608 | 218 | // vaUnmapBuffer | ||
609 | 219 | VAStatus | ||
610 | 220 | vdpau_UnmapBuffer( | ||
611 | 221 | VADriverContextP ctx, | ||
612 | 222 | VABufferID buf_id | ||
613 | 223 | ) | ||
614 | 224 | { | ||
615 | 225 | VDPAU_DRIVER_DATA_INIT; | ||
616 | 226 | |||
617 | 227 | object_buffer_p obj_buffer = VDPAU_BUFFER(buf_id); | ||
618 | 228 | if (!obj_buffer) | ||
619 | 229 | return VA_STATUS_ERROR_INVALID_BUFFER; | ||
620 | 230 | |||
621 | 231 | ++obj_buffer->mtime; | ||
622 | 232 | return VA_STATUS_SUCCESS; | ||
623 | 233 | } | ||
624 | 234 | |||
625 | 235 | // vaBufferInfo | ||
626 | 236 | VAStatus | ||
627 | 237 | vdpau_BufferInfo( | ||
628 | 238 | VADriverContextP ctx, | ||
629 | 239 | VAContextID context, | ||
630 | 240 | VABufferID buf_id, | ||
631 | 241 | VABufferType *type, | ||
632 | 242 | unsigned int *size, | ||
633 | 243 | unsigned int *num_elements | ||
634 | 244 | ) | ||
635 | 245 | { | ||
636 | 246 | VDPAU_DRIVER_DATA_INIT; | ||
637 | 247 | |||
638 | 248 | object_buffer_p obj_buffer = VDPAU_BUFFER(buf_id); | ||
639 | 249 | if (!obj_buffer) | ||
640 | 250 | return VA_STATUS_ERROR_INVALID_BUFFER; | ||
641 | 251 | |||
642 | 252 | if (type) | ||
643 | 253 | *type = obj_buffer->type; | ||
644 | 254 | if (size) | ||
645 | 255 | *size = obj_buffer->buffer_size / obj_buffer->num_elements; | ||
646 | 256 | if (num_elements) | ||
647 | 257 | *num_elements = obj_buffer->num_elements; | ||
648 | 258 | return VA_STATUS_SUCCESS; | ||
649 | 259 | } | ||
650 | 0 | 260 | ||
651 | === added file '.pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_buffer.h' | |||
652 | --- .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_buffer.h 1970-01-01 00:00:00 +0000 | |||
653 | +++ .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_buffer.h 2014-05-06 21:31:51 +0000 | |||
654 | @@ -0,0 +1,116 @@ | |||
655 | 1 | /* | ||
656 | 2 | * vdpau_buffer.h - VDPAU backend for VA-API (VA buffers) | ||
657 | 3 | * | ||
658 | 4 | * vdpau-video (C) 2009-2011 Splitted-Desktop Systems | ||
659 | 5 | * | ||
660 | 6 | * This program is free software; you can redistribute it and/or modify | ||
661 | 7 | * it under the terms of the GNU General Public License as published by | ||
662 | 8 | * the Free Software Foundation; either version 2 of the License, or | ||
663 | 9 | * (at your option) any later version. | ||
664 | 10 | * | ||
665 | 11 | * This program is distributed in the hope that it will be useful, | ||
666 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
667 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
668 | 14 | * GNU General Public License for more details. | ||
669 | 15 | * | ||
670 | 16 | * You should have received a copy of the GNU General Public License | ||
671 | 17 | * along with this program; if not, write to the Free Software | ||
672 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
673 | 19 | */ | ||
674 | 20 | |||
675 | 21 | #ifndef VDPAU_BUFFER_H | ||
676 | 22 | #define VDPAU_BUFFER_H | ||
677 | 23 | |||
678 | 24 | #include "vdpau_driver.h" | ||
679 | 25 | |||
680 | 26 | typedef struct object_buffer object_buffer_t; | ||
681 | 27 | struct object_buffer { | ||
682 | 28 | struct object_base base; | ||
683 | 29 | VAContextID va_context; | ||
684 | 30 | VABufferType type; | ||
685 | 31 | void *buffer_data; | ||
686 | 32 | unsigned int buffer_size; | ||
687 | 33 | unsigned int max_num_elements; | ||
688 | 34 | unsigned int num_elements; | ||
689 | 35 | uint64_t mtime; | ||
690 | 36 | unsigned int delayed_destroy : 1; | ||
691 | 37 | }; | ||
692 | 38 | |||
693 | 39 | // Create VA buffer object | ||
694 | 40 | object_buffer_p | ||
695 | 41 | create_va_buffer( | ||
696 | 42 | vdpau_driver_data_p driver_data, | ||
697 | 43 | VAContextID context, | ||
698 | 44 | VABufferType buffer_type, | ||
699 | 45 | unsigned int num_elements, | ||
700 | 46 | unsigned int size | ||
701 | 47 | ) attribute_hidden; | ||
702 | 48 | |||
703 | 49 | // Destroy VA buffer object | ||
704 | 50 | void | ||
705 | 51 | destroy_va_buffer( | ||
706 | 52 | vdpau_driver_data_p driver_data, | ||
707 | 53 | object_buffer_p obj_buffer | ||
708 | 54 | ) attribute_hidden; | ||
709 | 55 | |||
710 | 56 | // Schedule VA buffer object for destruction | ||
711 | 57 | void | ||
712 | 58 | schedule_destroy_va_buffer( | ||
713 | 59 | vdpau_driver_data_p driver_data, | ||
714 | 60 | object_buffer_p obj_buffer | ||
715 | 61 | ) attribute_hidden; | ||
716 | 62 | |||
717 | 63 | // vaCreateBuffer | ||
718 | 64 | VAStatus | ||
719 | 65 | vdpau_CreateBuffer( | ||
720 | 66 | VADriverContextP ctx, | ||
721 | 67 | VAContextID context, | ||
722 | 68 | VABufferType type, | ||
723 | 69 | unsigned int size, | ||
724 | 70 | unsigned int num_elements, | ||
725 | 71 | void *data, | ||
726 | 72 | VABufferID *buf_id | ||
727 | 73 | ) attribute_hidden; | ||
728 | 74 | |||
729 | 75 | // vaDestroyBuffer | ||
730 | 76 | VAStatus | ||
731 | 77 | vdpau_DestroyBuffer( | ||
732 | 78 | VADriverContextP ctx, | ||
733 | 79 | VABufferID buffer_id | ||
734 | 80 | ) attribute_hidden; | ||
735 | 81 | |||
736 | 82 | // vaBufferSetNumElements | ||
737 | 83 | VAStatus | ||
738 | 84 | vdpau_BufferSetNumElements( | ||
739 | 85 | VADriverContextP ctx, | ||
740 | 86 | VABufferID buf_id, | ||
741 | 87 | unsigned int num_elements | ||
742 | 88 | ) attribute_hidden; | ||
743 | 89 | |||
744 | 90 | // vaMapBuffer | ||
745 | 91 | VAStatus | ||
746 | 92 | vdpau_MapBuffer( | ||
747 | 93 | VADriverContextP ctx, | ||
748 | 94 | VABufferID buf_id, | ||
749 | 95 | void **pbuf | ||
750 | 96 | ) attribute_hidden; | ||
751 | 97 | |||
752 | 98 | // vaUnmapBuffer | ||
753 | 99 | VAStatus | ||
754 | 100 | vdpau_UnmapBuffer( | ||
755 | 101 | VADriverContextP ctx, | ||
756 | 102 | VABufferID buf_id | ||
757 | 103 | ) attribute_hidden; | ||
758 | 104 | |||
759 | 105 | // vaBufferInfo | ||
760 | 106 | VAStatus | ||
761 | 107 | vdpau_BufferInfo( | ||
762 | 108 | VADriverContextP ctx, | ||
763 | 109 | VAContextID context, | ||
764 | 110 | VABufferID buf_id, | ||
765 | 111 | VABufferType *type, | ||
766 | 112 | unsigned int *size, | ||
767 | 113 | unsigned int *num_elements | ||
768 | 114 | ) attribute_hidden; | ||
769 | 115 | |||
770 | 116 | #endif /* VDPAU_BUFFER_H */ | ||
771 | 0 | 117 | ||
772 | === added file '.pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_decode.c' | |||
773 | --- .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_decode.c 1970-01-01 00:00:00 +0000 | |||
774 | +++ .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_decode.c 2014-05-06 21:31:51 +0000 | |||
775 | @@ -0,0 +1,1271 @@ | |||
776 | 1 | /* | ||
777 | 2 | * vdpau_decode.c - VDPAU backend for VA-API (decoder) | ||
778 | 3 | * | ||
779 | 4 | * vdpau-video (C) 2009-2011 Splitted-Desktop Systems | ||
780 | 5 | * | ||
781 | 6 | * This program is free software; you can redistribute it and/or modify | ||
782 | 7 | * it under the terms of the GNU General Public License as published by | ||
783 | 8 | * the Free Software Foundation; either version 2 of the License, or | ||
784 | 9 | * (at your option) any later version. | ||
785 | 10 | * | ||
786 | 11 | * This program is distributed in the hope that it will be useful, | ||
787 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
788 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
789 | 14 | * GNU General Public License for more details. | ||
790 | 15 | * | ||
791 | 16 | * You should have received a copy of the GNU General Public License | ||
792 | 17 | * along with this program; if not, write to the Free Software | ||
793 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
794 | 19 | */ | ||
795 | 20 | |||
796 | 21 | #include "sysdeps.h" | ||
797 | 22 | #include "vdpau_decode.h" | ||
798 | 23 | #include "vdpau_driver.h" | ||
799 | 24 | #include "vdpau_buffer.h" | ||
800 | 25 | #include "vdpau_video.h" | ||
801 | 26 | #include "vdpau_dump.h" | ||
802 | 27 | #include "utils.h" | ||
803 | 28 | #include "put_bits.h" | ||
804 | 29 | |||
805 | 30 | #define DEBUG 1 | ||
806 | 31 | #include "debug.h" | ||
807 | 32 | |||
808 | 33 | |||
809 | 34 | // Translates VdpDecoderProfile to VdpCodec | ||
810 | 35 | VdpCodec get_VdpCodec(VdpDecoderProfile profile) | ||
811 | 36 | { | ||
812 | 37 | switch (profile) { | ||
813 | 38 | case VDP_DECODER_PROFILE_MPEG1: | ||
814 | 39 | return VDP_CODEC_MPEG1; | ||
815 | 40 | case VDP_DECODER_PROFILE_MPEG2_SIMPLE: | ||
816 | 41 | case VDP_DECODER_PROFILE_MPEG2_MAIN: | ||
817 | 42 | return VDP_CODEC_MPEG2; | ||
818 | 43 | #if USE_VDPAU_MPEG4 | ||
819 | 44 | case VDP_DECODER_PROFILE_MPEG4_PART2_SP: | ||
820 | 45 | case VDP_DECODER_PROFILE_MPEG4_PART2_ASP: | ||
821 | 46 | case VDP_DECODER_PROFILE_DIVX4_QMOBILE: | ||
822 | 47 | case VDP_DECODER_PROFILE_DIVX4_MOBILE: | ||
823 | 48 | case VDP_DECODER_PROFILE_DIVX4_HOME_THEATER: | ||
824 | 49 | case VDP_DECODER_PROFILE_DIVX4_HD_1080P: | ||
825 | 50 | case VDP_DECODER_PROFILE_DIVX5_QMOBILE: | ||
826 | 51 | case VDP_DECODER_PROFILE_DIVX5_MOBILE: | ||
827 | 52 | case VDP_DECODER_PROFILE_DIVX5_HOME_THEATER: | ||
828 | 53 | case VDP_DECODER_PROFILE_DIVX5_HD_1080P: | ||
829 | 54 | return VDP_CODEC_MPEG4; | ||
830 | 55 | #endif | ||
831 | 56 | case VDP_DECODER_PROFILE_H264_BASELINE: | ||
832 | 57 | case VDP_DECODER_PROFILE_H264_MAIN: | ||
833 | 58 | case VDP_DECODER_PROFILE_H264_HIGH: | ||
834 | 59 | return VDP_CODEC_H264; | ||
835 | 60 | case VDP_DECODER_PROFILE_VC1_SIMPLE: | ||
836 | 61 | case VDP_DECODER_PROFILE_VC1_MAIN: | ||
837 | 62 | case VDP_DECODER_PROFILE_VC1_ADVANCED: | ||
838 | 63 | return VDP_CODEC_VC1; | ||
839 | 64 | } | ||
840 | 65 | return 0; | ||
841 | 66 | } | ||
842 | 67 | |||
843 | 68 | // Translates VAProfile to VdpDecoderProfile | ||
844 | 69 | VdpDecoderProfile get_VdpDecoderProfile(VAProfile profile) | ||
845 | 70 | { | ||
846 | 71 | switch (profile) { | ||
847 | 72 | case VAProfileMPEG2Simple: return VDP_DECODER_PROFILE_MPEG2_SIMPLE; | ||
848 | 73 | case VAProfileMPEG2Main: return VDP_DECODER_PROFILE_MPEG2_MAIN; | ||
849 | 74 | #if USE_VDPAU_MPEG4 | ||
850 | 75 | case VAProfileMPEG4Simple: return VDP_DECODER_PROFILE_MPEG4_PART2_SP; | ||
851 | 76 | case VAProfileMPEG4AdvancedSimple: return VDP_DECODER_PROFILE_MPEG4_PART2_ASP; | ||
852 | 77 | #endif | ||
853 | 78 | case VAProfileH264Baseline: return VDP_DECODER_PROFILE_H264_BASELINE; | ||
854 | 79 | case VAProfileH264Main: return VDP_DECODER_PROFILE_H264_MAIN; | ||
855 | 80 | case VAProfileH264High: return VDP_DECODER_PROFILE_H264_HIGH; | ||
856 | 81 | case VAProfileVC1Simple: return VDP_DECODER_PROFILE_VC1_SIMPLE; | ||
857 | 82 | case VAProfileVC1Main: return VDP_DECODER_PROFILE_VC1_MAIN; | ||
858 | 83 | case VAProfileVC1Advanced: return VDP_DECODER_PROFILE_VC1_ADVANCED; | ||
859 | 84 | default: break; | ||
860 | 85 | } | ||
861 | 86 | return (VdpDecoderProfile)-1; | ||
862 | 87 | } | ||
863 | 88 | |||
864 | 89 | // Checks whether the VDPAU implementation supports the specified profile | ||
865 | 90 | static inline VdpBool | ||
866 | 91 | is_supported_profile( | ||
867 | 92 | vdpau_driver_data_t *driver_data, | ||
868 | 93 | VdpDecoderProfile profile | ||
869 | 94 | ) | ||
870 | 95 | { | ||
871 | 96 | VdpBool is_supported = VDP_FALSE; | ||
872 | 97 | VdpStatus vdp_status; | ||
873 | 98 | uint32_t max_level, max_references, max_width, max_height; | ||
874 | 99 | |||
875 | 100 | if (profile == (VdpDecoderProfile)-1) | ||
876 | 101 | return VDP_FALSE; | ||
877 | 102 | |||
878 | 103 | vdp_status = vdpau_decoder_query_capabilities( | ||
879 | 104 | driver_data, | ||
880 | 105 | driver_data->vdp_device, | ||
881 | 106 | profile, | ||
882 | 107 | &is_supported, | ||
883 | 108 | &max_level, | ||
884 | 109 | &max_references, | ||
885 | 110 | &max_width, | ||
886 | 111 | &max_height | ||
887 | 112 | ); | ||
888 | 113 | return (VDPAU_CHECK_STATUS(vdp_status, "VdpDecoderQueryCapabilities()") && | ||
889 | 114 | is_supported); | ||
890 | 115 | } | ||
891 | 116 | |||
892 | 117 | // Checks decoder for profile/entrypoint is available | ||
893 | 118 | VAStatus | ||
894 | 119 | check_decoder( | ||
895 | 120 | vdpau_driver_data_t *driver_data, | ||
896 | 121 | VAProfile profile, | ||
897 | 122 | VAEntrypoint entrypoint | ||
898 | 123 | ) | ||
899 | 124 | { | ||
900 | 125 | if (!is_supported_profile(driver_data, get_VdpDecoderProfile(profile))) | ||
901 | 126 | return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; | ||
902 | 127 | |||
903 | 128 | /* VDPAU only supports VLD */ | ||
904 | 129 | if (entrypoint != VAEntrypointVLD) | ||
905 | 130 | return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; | ||
906 | 131 | |||
907 | 132 | return VA_STATUS_SUCCESS; | ||
908 | 133 | } | ||
909 | 134 | |||
910 | 135 | // Computes value for VdpDecoderCreate()::max_references parameter | ||
911 | 136 | static int | ||
912 | 137 | get_max_ref_frames( | ||
913 | 138 | VdpDecoderProfile profile, | ||
914 | 139 | unsigned int width, | ||
915 | 140 | unsigned int height | ||
916 | 141 | ) | ||
917 | 142 | { | ||
918 | 143 | int max_ref_frames = 2; | ||
919 | 144 | |||
920 | 145 | switch (profile) { | ||
921 | 146 | case VDP_DECODER_PROFILE_H264_MAIN: | ||
922 | 147 | case VDP_DECODER_PROFILE_H264_HIGH: | ||
923 | 148 | { | ||
924 | 149 | /* level 4.1 limits */ | ||
925 | 150 | unsigned int aligned_width = (width + 15) & -16; | ||
926 | 151 | unsigned int aligned_height = (height + 15) & -16; | ||
927 | 152 | unsigned int surface_size = (aligned_width * aligned_height * 3) / 2; | ||
928 | 153 | if ((max_ref_frames = (12 * 1024 * 1024) / surface_size) > 16) | ||
929 | 154 | max_ref_frames = 16; | ||
930 | 155 | break; | ||
931 | 156 | } | ||
932 | 157 | } | ||
933 | 158 | return max_ref_frames; | ||
934 | 159 | } | ||
935 | 160 | |||
936 | 161 | // Returns the maximum number of reference frames of a decode session | ||
937 | 162 | static inline int get_num_ref_frames(object_context_p obj_context) | ||
938 | 163 | { | ||
939 | 164 | if (obj_context->vdp_codec == VDP_CODEC_H264) | ||
940 | 165 | return obj_context->vdp_picture_info.h264.num_ref_frames; | ||
941 | 166 | return 2; | ||
942 | 167 | } | ||
943 | 168 | |||
944 | 169 | // Ensure VDPAU decoder is created for the specified number of reference frames | ||
945 | 170 | static VdpStatus | ||
946 | 171 | ensure_decoder_with_max_refs( | ||
947 | 172 | vdpau_driver_data_t *driver_data, | ||
948 | 173 | object_context_p obj_context, | ||
949 | 174 | int max_ref_frames | ||
950 | 175 | ) | ||
951 | 176 | { | ||
952 | 177 | VdpStatus vdp_status; | ||
953 | 178 | |||
954 | 179 | if (max_ref_frames < 0) | ||
955 | 180 | max_ref_frames = | ||
956 | 181 | get_max_ref_frames(obj_context->vdp_profile, | ||
957 | 182 | obj_context->picture_width, | ||
958 | 183 | obj_context->picture_height); | ||
959 | 184 | |||
960 | 185 | if (obj_context->vdp_decoder == VDP_INVALID_HANDLE || | ||
961 | 186 | obj_context->max_ref_frames < max_ref_frames) { | ||
962 | 187 | obj_context->max_ref_frames = max_ref_frames; | ||
963 | 188 | |||
964 | 189 | if (obj_context->vdp_decoder != VDP_INVALID_HANDLE) { | ||
965 | 190 | vdpau_decoder_destroy(driver_data, obj_context->vdp_decoder); | ||
966 | 191 | obj_context->vdp_decoder = VDP_INVALID_HANDLE; | ||
967 | 192 | } | ||
968 | 193 | |||
969 | 194 | vdp_status = vdpau_decoder_create( | ||
970 | 195 | driver_data, | ||
971 | 196 | driver_data->vdp_device, | ||
972 | 197 | obj_context->vdp_profile, | ||
973 | 198 | obj_context->picture_width, | ||
974 | 199 | obj_context->picture_height, | ||
975 | 200 | max_ref_frames, | ||
976 | 201 | &obj_context->vdp_decoder | ||
977 | 202 | ); | ||
978 | 203 | if (!VDPAU_CHECK_STATUS(vdp_status, "VdpDecoderCreate()")) | ||
979 | 204 | return vdp_status; | ||
980 | 205 | } | ||
981 | 206 | return VDP_STATUS_OK; | ||
982 | 207 | } | ||
983 | 208 | |||
984 | 209 | // Lazy allocate (generated) slice data buffer. Buffer lives until vaDestroyContext() | ||
985 | 210 | static uint8_t * | ||
986 | 211 | alloc_gen_slice_data(object_context_p obj_context, unsigned int size) | ||
987 | 212 | { | ||
988 | 213 | uint8_t *gen_slice_data = obj_context->gen_slice_data; | ||
989 | 214 | |||
990 | 215 | if (obj_context->gen_slice_data_size + size > obj_context->gen_slice_data_size_max) { | ||
991 | 216 | obj_context->gen_slice_data_size_max += size; | ||
992 | 217 | gen_slice_data = realloc(obj_context->gen_slice_data, | ||
993 | 218 | obj_context->gen_slice_data_size_max); | ||
994 | 219 | if (!gen_slice_data) | ||
995 | 220 | return NULL; | ||
996 | 221 | obj_context->gen_slice_data = gen_slice_data; | ||
997 | 222 | } | ||
998 | 223 | gen_slice_data += obj_context->gen_slice_data_size; | ||
999 | 224 | obj_context->gen_slice_data_size += size; | ||
1000 | 225 | return gen_slice_data; | ||
1001 | 226 | } | ||
1002 | 227 | |||
1003 | 228 | // Lazy allocate VdpBitstreamBuffer. Buffer lives until vaDestroyContext() | ||
1004 | 229 | static VdpBitstreamBuffer * | ||
1005 | 230 | alloc_VdpBitstreamBuffer(object_context_p obj_context) | ||
1006 | 231 | { | ||
1007 | 232 | VdpBitstreamBuffer *vdp_bitstream_buffers; | ||
1008 | 233 | |||
1009 | 234 | vdp_bitstream_buffers = realloc_buffer( | ||
1010 | 235 | &obj_context->vdp_bitstream_buffers, | ||
1011 | 236 | &obj_context->vdp_bitstream_buffers_count_max, | ||
1012 | 237 | 1 + obj_context->vdp_bitstream_buffers_count, | ||
1013 | 238 | sizeof(*obj_context->vdp_bitstream_buffers) | ||
1014 | 239 | ); | ||
1015 | 240 | if (!vdp_bitstream_buffers) | ||
1016 | 241 | return NULL; | ||
1017 | 242 | |||
1018 | 243 | return &vdp_bitstream_buffers[obj_context->vdp_bitstream_buffers_count++]; | ||
1019 | 244 | } | ||
1020 | 245 | |||
1021 | 246 | // Append VASliceDataBuffer hunk into VDPAU buffer | ||
1022 | 247 | static int | ||
1023 | 248 | append_VdpBitstreamBuffer( | ||
1024 | 249 | object_context_p obj_context, | ||
1025 | 250 | const uint8_t *buffer, | ||
1026 | 251 | uint32_t buffer_size | ||
1027 | 252 | ) | ||
1028 | 253 | { | ||
1029 | 254 | VdpBitstreamBuffer *bitstream_buffer; | ||
1030 | 255 | |||
1031 | 256 | bitstream_buffer = alloc_VdpBitstreamBuffer(obj_context); | ||
1032 | 257 | if (!bitstream_buffer) | ||
1033 | 258 | return -1; | ||
1034 | 259 | |||
1035 | 260 | bitstream_buffer->struct_version = VDP_BITSTREAM_BUFFER_VERSION; | ||
1036 | 261 | bitstream_buffer->bitstream = buffer; | ||
1037 | 262 | bitstream_buffer->bitstream_bytes = buffer_size; | ||
1038 | 263 | return 0; | ||
1039 | 264 | } | ||
1040 | 265 | |||
1041 | 266 | // Initialize VdpReferenceFrameH264 to default values | ||
1042 | 267 | static void init_VdpReferenceFrameH264(VdpReferenceFrameH264 *rf) | ||
1043 | 268 | { | ||
1044 | 269 | rf->surface = VDP_INVALID_HANDLE; | ||
1045 | 270 | rf->is_long_term = VDP_FALSE; | ||
1046 | 271 | rf->top_is_reference = VDP_FALSE; | ||
1047 | 272 | rf->bottom_is_reference = VDP_FALSE; | ||
1048 | 273 | rf->field_order_cnt[0] = 0; | ||
1049 | 274 | rf->field_order_cnt[1] = 0; | ||
1050 | 275 | rf->frame_idx = 0; | ||
1051 | 276 | } | ||
1052 | 277 | |||
1053 | 278 | static const uint8_t ff_identity[64] = { | ||
1054 | 279 | 0, 1, 2, 3, 4, 5, 6, 7, | ||
1055 | 280 | 8, 9, 10, 11, 12, 13, 14, 15, | ||
1056 | 281 | 16, 17, 18, 19, 20, 21, 22, 23, | ||
1057 | 282 | 24, 25, 26, 27, 28, 29, 30, 31, | ||
1058 | 283 | 32, 33, 34, 35, 36, 37, 38, 39, | ||
1059 | 284 | 40, 41, 42, 43, 44, 45, 46, 47, | ||
1060 | 285 | 48, 49, 50, 51, 52, 53, 54, 55, | ||
1061 | 286 | 56, 57, 58, 59, 60, 61, 62, 63 | ||
1062 | 287 | }; | ||
1063 | 288 | |||
1064 | 289 | static const uint8_t ff_zigzag_direct[64] = { | ||
1065 | 290 | 0, 1, 8, 16, 9, 2, 3, 10, | ||
1066 | 291 | 17, 24, 32, 25, 18, 11, 4, 5, | ||
1067 | 292 | 12, 19, 26, 33, 40, 48, 41, 34, | ||
1068 | 293 | 27, 20, 13, 6, 7, 14, 21, 28, | ||
1069 | 294 | 35, 42, 49, 56, 57, 50, 43, 36, | ||
1070 | 295 | 29, 22, 15, 23, 30, 37, 44, 51, | ||
1071 | 296 | 58, 59, 52, 45, 38, 31, 39, 46, | ||
1072 | 297 | 53, 60, 61, 54, 47, 55, 62, 63 | ||
1073 | 298 | }; | ||
1074 | 299 | |||
1075 | 300 | static const uint8_t ff_mpeg1_default_intra_matrix[64] = { | ||
1076 | 301 | 8, 16, 19, 22, 26, 27, 29, 34, | ||
1077 | 302 | 16, 16, 22, 24, 27, 29, 34, 37, | ||
1078 | 303 | 19, 22, 26, 27, 29, 34, 34, 38, | ||
1079 | 304 | 22, 22, 26, 27, 29, 34, 37, 40, | ||
1080 | 305 | 22, 26, 27, 29, 32, 35, 40, 48, | ||
1081 | 306 | 26, 27, 29, 32, 35, 40, 48, 58, | ||
1082 | 307 | 26, 27, 29, 34, 38, 46, 56, 69, | ||
1083 | 308 | 27, 29, 35, 38, 46, 56, 69, 83 | ||
1084 | 309 | }; | ||
1085 | 310 | |||
1086 | 311 | static const uint8_t ff_mpeg1_default_non_intra_matrix[64] = { | ||
1087 | 312 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
1088 | 313 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
1089 | 314 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
1090 | 315 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
1091 | 316 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
1092 | 317 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
1093 | 318 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
1094 | 319 | 16, 16, 16, 16, 16, 16, 16, 16 | ||
1095 | 320 | }; | ||
1096 | 321 | |||
1097 | 322 | static const uint8_t ff_mpeg4_default_intra_matrix[64] = { | ||
1098 | 323 | 8, 17, 18, 19, 21, 23, 25, 27, | ||
1099 | 324 | 17, 18, 19, 21, 23, 25, 27, 28, | ||
1100 | 325 | 20, 21, 22, 23, 24, 26, 28, 30, | ||
1101 | 326 | 21, 22, 23, 24, 26, 28, 30, 32, | ||
1102 | 327 | 22, 23, 24, 26, 28, 30, 32, 35, | ||
1103 | 328 | 23, 24, 26, 28, 30, 32, 35, 38, | ||
1104 | 329 | 25, 26, 28, 30, 32, 35, 38, 41, | ||
1105 | 330 | 27, 28, 30, 32, 35, 38, 41, 45, | ||
1106 | 331 | }; | ||
1107 | 332 | |||
1108 | 333 | static const uint8_t ff_mpeg4_default_non_intra_matrix[64] = { | ||
1109 | 334 | 16, 17, 18, 19, 20, 21, 22, 23, | ||
1110 | 335 | 17, 18, 19, 20, 21, 22, 23, 24, | ||
1111 | 336 | 18, 19, 20, 21, 22, 23, 24, 25, | ||
1112 | 337 | 19, 20, 21, 22, 23, 24, 26, 27, | ||
1113 | 338 | 20, 21, 22, 23, 25, 26, 27, 28, | ||
1114 | 339 | 21, 22, 23, 24, 26, 27, 28, 30, | ||
1115 | 340 | 22, 23, 24, 26, 27, 28, 30, 31, | ||
1116 | 341 | 23, 24, 25, 27, 28, 30, 31, 33, | ||
1117 | 342 | }; | ||
1118 | 343 | |||
1119 | 344 | // Compute integer log2 | ||
1120 | 345 | static inline int ilog2(uint32_t v) | ||
1121 | 346 | { | ||
1122 | 347 | /* From <http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog> */ | ||
1123 | 348 | uint32_t r, shift; | ||
1124 | 349 | r = (v > 0xffff) << 4; v >>= r; | ||
1125 | 350 | shift = (v > 0xff ) << 3; v >>= shift; r |= shift; | ||
1126 | 351 | shift = (v > 0xf ) << 2; v >>= shift; r |= shift; | ||
1127 | 352 | shift = (v > 0x3 ) << 1; v >>= shift; r |= shift; | ||
1128 | 353 | return r | (v >> 1); | ||
1129 | 354 | } | ||
1130 | 355 | |||
1131 | 356 | // Translate VASurfaceID | ||
1132 | 357 | static int | ||
1133 | 358 | translate_VASurfaceID( | ||
1134 | 359 | vdpau_driver_data_t *driver_data, | ||
1135 | 360 | VASurfaceID va_surface, | ||
1136 | 361 | VdpVideoSurface *vdp_surface | ||
1137 | 362 | ) | ||
1138 | 363 | { | ||
1139 | 364 | object_surface_p obj_surface; | ||
1140 | 365 | |||
1141 | 366 | if (va_surface == VA_INVALID_SURFACE) { | ||
1142 | 367 | *vdp_surface = VDP_INVALID_HANDLE; | ||
1143 | 368 | return 1; | ||
1144 | 369 | } | ||
1145 | 370 | |||
1146 | 371 | obj_surface = VDPAU_SURFACE(va_surface); | ||
1147 | 372 | if (!obj_surface) | ||
1148 | 373 | return 0; | ||
1149 | 374 | |||
1150 | 375 | *vdp_surface = obj_surface->vdp_surface; | ||
1151 | 376 | return 1; | ||
1152 | 377 | } | ||
1153 | 378 | |||
1154 | 379 | // Translate VAPictureH264 | ||
1155 | 380 | static int | ||
1156 | 381 | translate_VAPictureH264( | ||
1157 | 382 | vdpau_driver_data_t *driver_data, | ||
1158 | 383 | const VAPictureH264 *va_pic, | ||
1159 | 384 | VdpReferenceFrameH264 *rf | ||
1160 | 385 | ) | ||
1161 | 386 | { | ||
1162 | 387 | // Handle invalid surfaces specifically | ||
1163 | 388 | if (va_pic->picture_id == VA_INVALID_SURFACE) { | ||
1164 | 389 | init_VdpReferenceFrameH264(rf); | ||
1165 | 390 | return 1; | ||
1166 | 391 | } | ||
1167 | 392 | |||
1168 | 393 | if (!translate_VASurfaceID(driver_data, va_pic->picture_id, &rf->surface)) | ||
1169 | 394 | return 0; | ||
1170 | 395 | rf->is_long_term = (va_pic->flags & VA_PICTURE_H264_LONG_TERM_REFERENCE) != 0; | ||
1171 | 396 | if ((va_pic->flags & (VA_PICTURE_H264_TOP_FIELD|VA_PICTURE_H264_BOTTOM_FIELD)) == 0) { | ||
1172 | 397 | rf->top_is_reference = VDP_TRUE; | ||
1173 | 398 | rf->bottom_is_reference = VDP_TRUE; | ||
1174 | 399 | } | ||
1175 | 400 | else { | ||
1176 | 401 | rf->top_is_reference = (va_pic->flags & VA_PICTURE_H264_TOP_FIELD) != 0; | ||
1177 | 402 | rf->bottom_is_reference = (va_pic->flags & VA_PICTURE_H264_BOTTOM_FIELD) != 0; | ||
1178 | 403 | } | ||
1179 | 404 | rf->field_order_cnt[0] = va_pic->TopFieldOrderCnt; | ||
1180 | 405 | rf->field_order_cnt[1] = va_pic->BottomFieldOrderCnt; | ||
1181 | 406 | rf->frame_idx = va_pic->frame_idx; | ||
1182 | 407 | return 1; | ||
1183 | 408 | } | ||
1184 | 409 | |||
1185 | 410 | // Translate no buffer | ||
1186 | 411 | static int | ||
1187 | 412 | translate_nothing( | ||
1188 | 413 | vdpau_driver_data_t *driver_data, | ||
1189 | 414 | object_context_p obj_context, | ||
1190 | 415 | object_buffer_p obj_buffer | ||
1191 | 416 | ) | ||
1192 | 417 | { | ||
1193 | 418 | return 1; | ||
1194 | 419 | } | ||
1195 | 420 | |||
1196 | 421 | // Translate VASliceDataBuffer | ||
1197 | 422 | static int | ||
1198 | 423 | translate_VASliceDataBuffer( | ||
1199 | 424 | vdpau_driver_data_t *driver_data, | ||
1200 | 425 | object_context_p obj_context, | ||
1201 | 426 | object_buffer_p obj_buffer | ||
1202 | 427 | ) | ||
1203 | 428 | { | ||
1204 | 429 | if (obj_context->vdp_codec == VDP_CODEC_H264) { | ||
1205 | 430 | /* Check we have the start code */ | ||
1206 | 431 | /* XXX: check for other codecs too? */ | ||
1207 | 432 | /* XXX: this assumes we get SliceParams before SliceData */ | ||
1208 | 433 | static const uint8_t start_code_prefix[3] = { 0x00, 0x00, 0x01 }; | ||
1209 | 434 | VASliceParameterBufferH264 * const slice_params = obj_context->last_slice_params; | ||
1210 | 435 | unsigned int i; | ||
1211 | 436 | for (i = 0; i < obj_context->last_slice_params_count; i++) { | ||
1212 | 437 | VASliceParameterBufferH264 * const slice_param = &slice_params[i]; | ||
1213 | 438 | uint8_t *buf = (uint8_t *)obj_buffer->buffer_data + slice_param->slice_data_offset; | ||
1214 | 439 | if (memcmp(buf, start_code_prefix, sizeof(start_code_prefix)) != 0) { | ||
1215 | 440 | if (append_VdpBitstreamBuffer(obj_context, | ||
1216 | 441 | start_code_prefix, | ||
1217 | 442 | sizeof(start_code_prefix)) < 0) | ||
1218 | 443 | return 0; | ||
1219 | 444 | } | ||
1220 | 445 | if (append_VdpBitstreamBuffer(obj_context, | ||
1221 | 446 | buf, | ||
1222 | 447 | slice_param->slice_data_size) < 0) | ||
1223 | 448 | return 0; | ||
1224 | 449 | } | ||
1225 | 450 | return 1; | ||
1226 | 451 | } | ||
1227 | 452 | |||
1228 | 453 | #if USE_VDPAU_MPEG4 | ||
1229 | 454 | if (obj_context->vdp_codec == VDP_CODEC_MPEG4 && | ||
1230 | 455 | obj_context->vdp_bitstream_buffers_count == 0) { | ||
1231 | 456 | PutBitContext pb; | ||
1232 | 457 | uint8_t slice_header_buffer[32]; | ||
1233 | 458 | uint8_t *slice_header; | ||
1234 | 459 | int slice_header_size; | ||
1235 | 460 | const uint8_t *slice_data = obj_buffer->buffer_data; | ||
1236 | 461 | uint32_t slice_data_size = obj_buffer->buffer_size; | ||
1237 | 462 | VAPictureParameterBufferMPEG4 * const pic_param = obj_context->last_pic_param; | ||
1238 | 463 | VASliceParameterBufferMPEG4 * const slice_param = obj_context->last_slice_params; | ||
1239 | 464 | |||
1240 | 465 | int time_incr = 1 + ilog2(pic_param->vop_time_increment_resolution - 1); | ||
1241 | 466 | if (time_incr < 1) | ||
1242 | 467 | time_incr = 1; | ||
1243 | 468 | |||
1244 | 469 | static const uint16_t VOP_STARTCODE = 0x01b6; | ||
1245 | 470 | enum { | ||
1246 | 471 | VOP_I_TYPE = 0, | ||
1247 | 472 | VOP_P_TYPE, | ||
1248 | 473 | VOP_B_TYPE, | ||
1249 | 474 | VOP_S_TYPE | ||
1250 | 475 | }; | ||
1251 | 476 | |||
1252 | 477 | /* XXX: this is a hack to compute the length of | ||
1253 | 478 | modulo_time_base "1" sequence. We probably should be | ||
1254 | 479 | reconstructing through an extra VOP field in VA-API? */ | ||
1255 | 480 | int nbits = (32 + /* VOP start code */ | ||
1256 | 481 | 2 + /* vop_coding_type */ | ||
1257 | 482 | 1 + /* modulo_time_base "0" */ | ||
1258 | 483 | 1 + /* marker_bit */ | ||
1259 | 484 | time_incr + /* vop_time_increment */ | ||
1260 | 485 | 1 + /* marker_bit */ | ||
1261 | 486 | 1 + /* vop_coded */ | ||
1262 | 487 | (pic_param->vop_fields.bits.vop_coding_type == VOP_P_TYPE ? 1 : 0) + | ||
1263 | 488 | 3 + /* intra_dc_vlc_thr */ | ||
1264 | 489 | (pic_param->vol_fields.bits.interlaced ? 2 : 0) + | ||
1265 | 490 | 5 + /* vop_quant */ | ||
1266 | 491 | (pic_param->vop_fields.bits.vop_coding_type != VOP_I_TYPE ? 3 : 0) + | ||
1267 | 492 | (pic_param->vop_fields.bits.vop_coding_type == VOP_B_TYPE ? 3 : 0)); | ||
1268 | 493 | if ((nbits = slice_param->macroblock_offset - (nbits % 8)) < 0) | ||
1269 | 494 | nbits += 8; | ||
1270 | 495 | |||
1271 | 496 | /* Reconstruct the VOP header */ | ||
1272 | 497 | init_put_bits(&pb, slice_header_buffer, sizeof(slice_header_buffer)); | ||
1273 | 498 | put_bits(&pb, 16, 0); /* vop header */ | ||
1274 | 499 | put_bits(&pb, 16, VOP_STARTCODE); /* vop header */ | ||
1275 | 500 | put_bits(&pb, 2, pic_param->vop_fields.bits.vop_coding_type); | ||
1276 | 501 | while (nbits-- > 0) | ||
1277 | 502 | put_bits(&pb, 1, 1); /* modulo_time_base "1" */ | ||
1278 | 503 | put_bits(&pb, 1, 0); /* modulo_time_base "0" */ | ||
1279 | 504 | put_bits(&pb, 1, 1); /* marker */ | ||
1280 | 505 | put_bits(&pb, time_incr, 0); /* time increment */ | ||
1281 | 506 | put_bits(&pb, 1, 1); /* marker */ | ||
1282 | 507 | put_bits(&pb, 1, 1); /* vop coded */ | ||
1283 | 508 | if (pic_param->vop_fields.bits.vop_coding_type == VOP_P_TYPE) | ||
1284 | 509 | put_bits(&pb, 1, pic_param->vop_fields.bits.vop_rounding_type); | ||
1285 | 510 | put_bits(&pb, 3, pic_param->vop_fields.bits.intra_dc_vlc_thr); | ||
1286 | 511 | if (pic_param->vol_fields.bits.interlaced) { | ||
1287 | 512 | put_bits(&pb, 1, pic_param->vop_fields.bits.top_field_first); | ||
1288 | 513 | put_bits(&pb, 1, pic_param->vop_fields.bits.alternate_vertical_scan_flag); | ||
1289 | 514 | } | ||
1290 | 515 | put_bits(&pb, 5, slice_param->quant_scale); | ||
1291 | 516 | if (pic_param->vop_fields.bits.vop_coding_type != VOP_I_TYPE) | ||
1292 | 517 | put_bits(&pb, 3, pic_param->vop_fcode_forward); | ||
1293 | 518 | if (pic_param->vop_fields.bits.vop_coding_type == VOP_B_TYPE) | ||
1294 | 519 | put_bits(&pb, 3, pic_param->vop_fcode_backward); | ||
1295 | 520 | |||
1296 | 521 | /* Merge in bits from the first byte of the slice */ | ||
1297 | 522 | ASSERT((put_bits_count(&pb) % 8) == slice_param->macroblock_offset); | ||
1298 | 523 | if ((put_bits_count(&pb) % 8) != slice_param->macroblock_offset) | ||
1299 | 524 | return 0; | ||
1300 | 525 | const int r = 8 - (put_bits_count(&pb) % 8); | ||
1301 | 526 | if (r > 0) | ||
1302 | 527 | put_bits(&pb, r, slice_data[0] & ((1U << r) - 1)); | ||
1303 | 528 | flush_put_bits(&pb); | ||
1304 | 529 | |||
1305 | 530 | ASSERT((put_bits_count(&pb) % 8) == 0); | ||
1306 | 531 | slice_header_size = put_bits_count(&pb) / 8; | ||
1307 | 532 | ASSERT(slice_header_size <= sizeof(slice_header_buffer)); | ||
1308 | 533 | slice_header = alloc_gen_slice_data(obj_context, slice_header_size); | ||
1309 | 534 | if (!slice_header) | ||
1310 | 535 | return 0; | ||
1311 | 536 | memcpy(slice_header, slice_header_buffer, slice_header_size); | ||
1312 | 537 | if (append_VdpBitstreamBuffer(obj_context, slice_header, slice_header_size) < 0) | ||
1313 | 538 | return 0; | ||
1314 | 539 | if (append_VdpBitstreamBuffer(obj_context, slice_data + 1, slice_data_size - 1) < 0) | ||
1315 | 540 | return 0; | ||
1316 | 541 | return 1; | ||
1317 | 542 | } | ||
1318 | 543 | #endif | ||
1319 | 544 | |||
1320 | 545 | if (append_VdpBitstreamBuffer(obj_context, | ||
1321 | 546 | obj_buffer->buffer_data, | ||
1322 | 547 | obj_buffer->buffer_size) < 0) | ||
1323 | 548 | return 0; | ||
1324 | 549 | return 1; | ||
1325 | 550 | } | ||
1326 | 551 | |||
1327 | 552 | // Translate VAPictureParameterBufferMPEG2 | ||
1328 | 553 | static int | ||
1329 | 554 | translate_VAPictureParameterBufferMPEG2( | ||
1330 | 555 | vdpau_driver_data_t *driver_data, | ||
1331 | 556 | object_context_p obj_context, | ||
1332 | 557 | object_buffer_p obj_buffer | ||
1333 | 558 | ) | ||
1334 | 559 | { | ||
1335 | 560 | VdpPictureInfoMPEG1Or2 * const pic_info = &obj_context->vdp_picture_info.mpeg2; | ||
1336 | 561 | VAPictureParameterBufferMPEG2 * const pic_param = obj_buffer->buffer_data; | ||
1337 | 562 | |||
1338 | 563 | if (!translate_VASurfaceID(driver_data, | ||
1339 | 564 | pic_param->forward_reference_picture, | ||
1340 | 565 | &pic_info->forward_reference)) | ||
1341 | 566 | return 0; | ||
1342 | 567 | |||
1343 | 568 | if (!translate_VASurfaceID(driver_data, | ||
1344 | 569 | pic_param->backward_reference_picture, | ||
1345 | 570 | &pic_info->backward_reference)) | ||
1346 | 571 | return 0; | ||
1347 | 572 | |||
1348 | 573 | pic_info->picture_structure = pic_param->picture_coding_extension.bits.picture_structure; | ||
1349 | 574 | pic_info->picture_coding_type = pic_param->picture_coding_type; | ||
1350 | 575 | pic_info->intra_dc_precision = pic_param->picture_coding_extension.bits.intra_dc_precision; | ||
1351 | 576 | pic_info->frame_pred_frame_dct = pic_param->picture_coding_extension.bits.frame_pred_frame_dct; | ||
1352 | 577 | pic_info->concealment_motion_vectors = pic_param->picture_coding_extension.bits.concealment_motion_vectors; | ||
1353 | 578 | pic_info->intra_vlc_format = pic_param->picture_coding_extension.bits.intra_vlc_format; | ||
1354 | 579 | pic_info->alternate_scan = pic_param->picture_coding_extension.bits.alternate_scan; | ||
1355 | 580 | pic_info->q_scale_type = pic_param->picture_coding_extension.bits.q_scale_type; | ||
1356 | 581 | pic_info->top_field_first = pic_param->picture_coding_extension.bits.top_field_first; | ||
1357 | 582 | pic_info->full_pel_forward_vector = 0; | ||
1358 | 583 | pic_info->full_pel_backward_vector = 0; | ||
1359 | 584 | pic_info->f_code[0][0] = (pic_param->f_code >> 12) & 0xf; | ||
1360 | 585 | pic_info->f_code[0][1] = (pic_param->f_code >> 8) & 0xf; | ||
1361 | 586 | pic_info->f_code[1][0] = (pic_param->f_code >> 4) & 0xf; | ||
1362 | 587 | pic_info->f_code[1][1] = pic_param->f_code & 0xf; | ||
1363 | 588 | return 1; | ||
1364 | 589 | } | ||
1365 | 590 | |||
1366 | 591 | // Translate VAIQMatrixBufferMPEG2 | ||
1367 | 592 | static int | ||
1368 | 593 | translate_VAIQMatrixBufferMPEG2( | ||
1369 | 594 | vdpau_driver_data_t *driver_data, | ||
1370 | 595 | object_context_p obj_context, | ||
1371 | 596 | object_buffer_p obj_buffer | ||
1372 | 597 | ) | ||
1373 | 598 | { | ||
1374 | 599 | VdpPictureInfoMPEG1Or2 * const pic_info = &obj_context->vdp_picture_info.mpeg2; | ||
1375 | 600 | VAIQMatrixBufferMPEG2 * const iq_matrix = obj_buffer->buffer_data; | ||
1376 | 601 | const uint8_t *intra_matrix; | ||
1377 | 602 | const uint8_t *intra_matrix_lookup; | ||
1378 | 603 | const uint8_t *inter_matrix; | ||
1379 | 604 | const uint8_t *inter_matrix_lookup; | ||
1380 | 605 | int i; | ||
1381 | 606 | |||
1382 | 607 | if (iq_matrix->load_intra_quantiser_matrix) { | ||
1383 | 608 | intra_matrix = iq_matrix->intra_quantiser_matrix; | ||
1384 | 609 | intra_matrix_lookup = ff_zigzag_direct; | ||
1385 | 610 | } | ||
1386 | 611 | else { | ||
1387 | 612 | intra_matrix = ff_mpeg1_default_intra_matrix; | ||
1388 | 613 | intra_matrix_lookup = ff_identity; | ||
1389 | 614 | } | ||
1390 | 615 | |||
1391 | 616 | if (iq_matrix->load_non_intra_quantiser_matrix) { | ||
1392 | 617 | inter_matrix = iq_matrix->non_intra_quantiser_matrix; | ||
1393 | 618 | inter_matrix_lookup = ff_zigzag_direct; | ||
1394 | 619 | } | ||
1395 | 620 | else { | ||
1396 | 621 | inter_matrix = ff_mpeg1_default_non_intra_matrix; | ||
1397 | 622 | inter_matrix_lookup = ff_identity; | ||
1398 | 623 | } | ||
1399 | 624 | |||
1400 | 625 | for (i = 0; i < 64; i++) { | ||
1401 | 626 | pic_info->intra_quantizer_matrix[intra_matrix_lookup[i]] = | ||
1402 | 627 | intra_matrix[i]; | ||
1403 | 628 | pic_info->non_intra_quantizer_matrix[inter_matrix_lookup[i]] = | ||
1404 | 629 | inter_matrix[i]; | ||
1405 | 630 | } | ||
1406 | 631 | return 1; | ||
1407 | 632 | } | ||
1408 | 633 | |||
1409 | 634 | // Translate VASliceParameterBufferMPEG2 | ||
1410 | 635 | static int | ||
1411 | 636 | translate_VASliceParameterBufferMPEG2( | ||
1412 | 637 | vdpau_driver_data_t *driver_data, | ||
1413 | 638 | object_context_p obj_context, | ||
1414 | 639 | object_buffer_p obj_buffer | ||
1415 | 640 | ) | ||
1416 | 641 | { | ||
1417 | 642 | VdpPictureInfoMPEG1Or2 * const pic_info = &obj_context->vdp_picture_info.mpeg2; | ||
1418 | 643 | |||
1419 | 644 | pic_info->slice_count += obj_buffer->num_elements; | ||
1420 | 645 | obj_context->last_slice_params = obj_buffer->buffer_data; | ||
1421 | 646 | obj_context->last_slice_params_count = obj_buffer->num_elements; | ||
1422 | 647 | return 1; | ||
1423 | 648 | } | ||
1424 | 649 | |||
1425 | 650 | #if USE_VDPAU_MPEG4 | ||
1426 | 651 | // Translate VAPictureParameterBufferMPEG4 | ||
1427 | 652 | static int | ||
1428 | 653 | translate_VAPictureParameterBufferMPEG4( | ||
1429 | 654 | vdpau_driver_data_p driver_data, | ||
1430 | 655 | object_context_p obj_context, | ||
1431 | 656 | object_buffer_p obj_buffer | ||
1432 | 657 | ) | ||
1433 | 658 | { | ||
1434 | 659 | VdpPictureInfoMPEG4Part2 * const pic_info = &obj_context->vdp_picture_info.mpeg4; | ||
1435 | 660 | VAPictureParameterBufferMPEG4 * const pic_param = obj_buffer->buffer_data; | ||
1436 | 661 | |||
1437 | 662 | /* XXX: we don't support short-video-header formats */ | ||
1438 | 663 | if (pic_param->vol_fields.bits.short_video_header) | ||
1439 | 664 | return 0; | ||
1440 | 665 | |||
1441 | 666 | if (!translate_VASurfaceID(driver_data, | ||
1442 | 667 | pic_param->forward_reference_picture, | ||
1443 | 668 | &pic_info->forward_reference)) | ||
1444 | 669 | return 0; | ||
1445 | 670 | |||
1446 | 671 | if (!translate_VASurfaceID(driver_data, | ||
1447 | 672 | pic_param->backward_reference_picture, | ||
1448 | 673 | &pic_info->backward_reference)) | ||
1449 | 674 | return 0; | ||
1450 | 675 | |||
1451 | 676 | if (pic_param->vol_fields.bits.interlaced) { | ||
1452 | 677 | vdpau_information_message("unsupported MPEG-4 video with interlaced " | ||
1453 | 678 | "content, please report this video\n"); | ||
1454 | 679 | pic_info->trd[0] = 2*pic_param->TRD; /* XXX: + d(0) */ | ||
1455 | 680 | pic_info->trb[0] = 2*pic_param->TRB; /* XXX: + d(0) */ | ||
1456 | 681 | pic_info->trd[1] = 2*pic_param->TRD; /* XXX: + d(1) */ | ||
1457 | 682 | pic_info->trb[1] = 2*pic_param->TRB; /* XXX: + d(1) */ | ||
1458 | 683 | } | ||
1459 | 684 | else { | ||
1460 | 685 | pic_info->trd[0] = pic_param->TRD; | ||
1461 | 686 | pic_info->trb[0] = pic_param->TRB; | ||
1462 | 687 | pic_info->trd[1] = 0; | ||
1463 | 688 | pic_info->trb[1] = 0; | ||
1464 | 689 | } | ||
1465 | 690 | |||
1466 | 691 | pic_info->vop_time_increment_resolution = pic_param->vop_time_increment_resolution; | ||
1467 | 692 | pic_info->vop_coding_type = pic_param->vop_fields.bits.vop_coding_type; | ||
1468 | 693 | pic_info->vop_fcode_forward = pic_param->vop_fcode_forward; | ||
1469 | 694 | pic_info->vop_fcode_backward = pic_param->vop_fcode_backward; | ||
1470 | 695 | pic_info->resync_marker_disable = pic_param->vol_fields.bits.resync_marker_disable; | ||
1471 | 696 | pic_info->interlaced = pic_param->vol_fields.bits.interlaced; | ||
1472 | 697 | pic_info->quant_type = pic_param->vol_fields.bits.quant_type; | ||
1473 | 698 | pic_info->quarter_sample = pic_param->vol_fields.bits.quarter_sample; | ||
1474 | 699 | pic_info->short_video_header = pic_param->vol_fields.bits.short_video_header; | ||
1475 | 700 | pic_info->rounding_control = pic_param->vop_fields.bits.vop_rounding_type; | ||
1476 | 701 | pic_info->alternate_vertical_scan_flag = pic_param->vop_fields.bits.alternate_vertical_scan_flag; | ||
1477 | 702 | pic_info->top_field_first = pic_param->vop_fields.bits.top_field_first; | ||
1478 | 703 | |||
1479 | 704 | obj_context->last_pic_param = obj_buffer->buffer_data; | ||
1480 | 705 | return 1; | ||
1481 | 706 | } | ||
1482 | 707 | |||
1483 | 708 | // Translate VAIQMatrixBufferMPEG4 | ||
1484 | 709 | static int | ||
1485 | 710 | translate_VAIQMatrixBufferMPEG4( | ||
1486 | 711 | vdpau_driver_data_p driver_data, | ||
1487 | 712 | object_context_p obj_context, | ||
1488 | 713 | object_buffer_p obj_buffer | ||
1489 | 714 | ) | ||
1490 | 715 | { | ||
1491 | 716 | VdpPictureInfoMPEG4Part2 * const pic_info = &obj_context->vdp_picture_info.mpeg4; | ||
1492 | 717 | VAIQMatrixBufferMPEG4 * const iq_matrix = obj_buffer->buffer_data; | ||
1493 | 718 | const uint8_t *intra_matrix; | ||
1494 | 719 | const uint8_t *intra_matrix_lookup; | ||
1495 | 720 | const uint8_t *inter_matrix; | ||
1496 | 721 | const uint8_t *inter_matrix_lookup; | ||
1497 | 722 | int i; | ||
1498 | 723 | |||
1499 | 724 | if (iq_matrix->load_intra_quant_mat) { | ||
1500 | 725 | intra_matrix = iq_matrix->intra_quant_mat; | ||
1501 | 726 | intra_matrix_lookup = ff_zigzag_direct; | ||
1502 | 727 | } | ||
1503 | 728 | else { | ||
1504 | 729 | intra_matrix = ff_mpeg4_default_intra_matrix; | ||
1505 | 730 | intra_matrix_lookup = ff_identity; | ||
1506 | 731 | } | ||
1507 | 732 | |||
1508 | 733 | if (iq_matrix->load_non_intra_quant_mat) { | ||
1509 | 734 | inter_matrix = iq_matrix->non_intra_quant_mat; | ||
1510 | 735 | inter_matrix_lookup = ff_zigzag_direct; | ||
1511 | 736 | } | ||
1512 | 737 | else { | ||
1513 | 738 | inter_matrix = ff_mpeg4_default_non_intra_matrix; | ||
1514 | 739 | inter_matrix_lookup = ff_identity; | ||
1515 | 740 | } | ||
1516 | 741 | |||
1517 | 742 | for (i = 0; i < 64; i++) { | ||
1518 | 743 | pic_info->intra_quantizer_matrix[intra_matrix_lookup[i]] = | ||
1519 | 744 | intra_matrix[i]; | ||
1520 | 745 | pic_info->non_intra_quantizer_matrix[inter_matrix_lookup[i]] = | ||
1521 | 746 | inter_matrix[i]; | ||
1522 | 747 | } | ||
1523 | 748 | return 1; | ||
1524 | 749 | } | ||
1525 | 750 | |||
1526 | 751 | // Translate VASliceParameterBufferMPEG4 | ||
1527 | 752 | static int | ||
1528 | 753 | translate_VASliceParameterBufferMPEG4( | ||
1529 | 754 | vdpau_driver_data_p driver_data, | ||
1530 | 755 | object_context_p obj_context, | ||
1531 | 756 | object_buffer_p obj_buffer | ||
1532 | 757 | ) | ||
1533 | 758 | { | ||
1534 | 759 | obj_context->last_slice_params = obj_buffer->buffer_data; | ||
1535 | 760 | obj_context->last_slice_params_count = obj_buffer->num_elements; | ||
1536 | 761 | return 1; | ||
1537 | 762 | } | ||
1538 | 763 | #endif | ||
1539 | 764 | |||
1540 | 765 | // Translate VAPictureParameterBufferH264 | ||
1541 | 766 | static int | ||
1542 | 767 | translate_VAPictureParameterBufferH264( | ||
1543 | 768 | vdpau_driver_data_t *driver_data, | ||
1544 | 769 | object_context_p obj_context, | ||
1545 | 770 | object_buffer_p obj_buffer | ||
1546 | 771 | ) | ||
1547 | 772 | { | ||
1548 | 773 | VdpPictureInfoH264 * const pic_info = &obj_context->vdp_picture_info.h264; | ||
1549 | 774 | VAPictureParameterBufferH264 * const pic_param = obj_buffer->buffer_data; | ||
1550 | 775 | VAPictureH264 * const CurrPic = &pic_param->CurrPic; | ||
1551 | 776 | unsigned int i; | ||
1552 | 777 | |||
1553 | 778 | pic_info->field_order_cnt[0] = CurrPic->TopFieldOrderCnt; | ||
1554 | 779 | pic_info->field_order_cnt[1] = CurrPic->BottomFieldOrderCnt; | ||
1555 | 780 | pic_info->is_reference = pic_param->pic_fields.bits.reference_pic_flag; | ||
1556 | 781 | |||
1557 | 782 | pic_info->frame_num = pic_param->frame_num; | ||
1558 | 783 | pic_info->field_pic_flag = pic_param->pic_fields.bits.field_pic_flag; | ||
1559 | 784 | pic_info->bottom_field_flag = pic_param->pic_fields.bits.field_pic_flag && (CurrPic->flags & VA_PICTURE_H264_BOTTOM_FIELD) != 0; | ||
1560 | 785 | pic_info->num_ref_frames = pic_param->num_ref_frames; | ||
1561 | 786 | pic_info->mb_adaptive_frame_field_flag = pic_param->seq_fields.bits.mb_adaptive_frame_field_flag && !pic_info->field_pic_flag; | ||
1562 | 787 | pic_info->constrained_intra_pred_flag = pic_param->pic_fields.bits.constrained_intra_pred_flag; | ||
1563 | 788 | pic_info->weighted_pred_flag = pic_param->pic_fields.bits.weighted_pred_flag; | ||
1564 | 789 | pic_info->weighted_bipred_idc = pic_param->pic_fields.bits.weighted_bipred_idc; | ||
1565 | 790 | pic_info->frame_mbs_only_flag = pic_param->seq_fields.bits.frame_mbs_only_flag; | ||
1566 | 791 | pic_info->transform_8x8_mode_flag = pic_param->pic_fields.bits.transform_8x8_mode_flag; | ||
1567 | 792 | pic_info->chroma_qp_index_offset = pic_param->chroma_qp_index_offset; | ||
1568 | 793 | pic_info->second_chroma_qp_index_offset = pic_param->second_chroma_qp_index_offset; | ||
1569 | 794 | pic_info->pic_init_qp_minus26 = pic_param->pic_init_qp_minus26; | ||
1570 | 795 | pic_info->log2_max_frame_num_minus4 = pic_param->seq_fields.bits.log2_max_frame_num_minus4; | ||
1571 | 796 | pic_info->pic_order_cnt_type = pic_param->seq_fields.bits.pic_order_cnt_type; | ||
1572 | 797 | pic_info->log2_max_pic_order_cnt_lsb_minus4 = pic_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4; | ||
1573 | 798 | pic_info->delta_pic_order_always_zero_flag = pic_param->seq_fields.bits.delta_pic_order_always_zero_flag; | ||
1574 | 799 | pic_info->direct_8x8_inference_flag = pic_param->seq_fields.bits.direct_8x8_inference_flag; | ||
1575 | 800 | pic_info->entropy_coding_mode_flag = pic_param->pic_fields.bits.entropy_coding_mode_flag; | ||
1576 | 801 | pic_info->pic_order_present_flag = pic_param->pic_fields.bits.pic_order_present_flag; | ||
1577 | 802 | pic_info->deblocking_filter_control_present_flag = pic_param->pic_fields.bits.deblocking_filter_control_present_flag; | ||
1578 | 803 | pic_info->redundant_pic_cnt_present_flag = pic_param->pic_fields.bits.redundant_pic_cnt_present_flag; | ||
1579 | 804 | |||
1580 | 805 | for (i = 0; i < 16; i++) { | ||
1581 | 806 | if (!translate_VAPictureH264(driver_data, | ||
1582 | 807 | &pic_param->ReferenceFrames[i], | ||
1583 | 808 | &pic_info->referenceFrames[i])) | ||
1584 | 809 | return 0; | ||
1585 | 810 | } | ||
1586 | 811 | return 1; | ||
1587 | 812 | } | ||
1588 | 813 | |||
1589 | 814 | // Translate VAIQMatrixBufferH264 | ||
1590 | 815 | static int | ||
1591 | 816 | translate_VAIQMatrixBufferH264( | ||
1592 | 817 | vdpau_driver_data_t *driver_data, | ||
1593 | 818 | object_context_p obj_context, | ||
1594 | 819 | object_buffer_p obj_buffer | ||
1595 | 820 | ) | ||
1596 | 821 | { | ||
1597 | 822 | VdpPictureInfoH264 * const pic_info = &obj_context->vdp_picture_info.h264; | ||
1598 | 823 | VAIQMatrixBufferH264 * const iq_matrix = obj_buffer->buffer_data; | ||
1599 | 824 | int i, j; | ||
1600 | 825 | |||
1601 | 826 | if (sizeof(pic_info->scaling_lists_4x4) == sizeof(iq_matrix->ScalingList4x4)) | ||
1602 | 827 | memcpy(pic_info->scaling_lists_4x4, iq_matrix->ScalingList4x4, | ||
1603 | 828 | sizeof(pic_info->scaling_lists_4x4)); | ||
1604 | 829 | else { | ||
1605 | 830 | for (j = 0; j < 6; j++) { | ||
1606 | 831 | for (i = 0; i < 16; i++) | ||
1607 | 832 | pic_info->scaling_lists_4x4[j][i] = iq_matrix->ScalingList4x4[j][i]; | ||
1608 | 833 | } | ||
1609 | 834 | } | ||
1610 | 835 | |||
1611 | 836 | if (sizeof(pic_info->scaling_lists_8x8) == sizeof(iq_matrix->ScalingList8x8)) | ||
1612 | 837 | memcpy(pic_info->scaling_lists_8x8, iq_matrix->ScalingList8x8, | ||
1613 | 838 | sizeof(pic_info->scaling_lists_8x8)); | ||
1614 | 839 | else { | ||
1615 | 840 | for (j = 0; j < 2; j++) { | ||
1616 | 841 | for (i = 0; i < 64; i++) | ||
1617 | 842 | pic_info->scaling_lists_8x8[j][i] = iq_matrix->ScalingList8x8[j][i]; | ||
1618 | 843 | } | ||
1619 | 844 | } | ||
1620 | 845 | return 1; | ||
1621 | 846 | } | ||
1622 | 847 | |||
1623 | 848 | // Translate VASliceParameterBufferH264 | ||
1624 | 849 | static int | ||
1625 | 850 | translate_VASliceParameterBufferH264( | ||
1626 | 851 | vdpau_driver_data_t *driver_data, | ||
1627 | 852 | object_context_p obj_context, | ||
1628 | 853 | object_buffer_p obj_buffer | ||
1629 | 854 | ) | ||
1630 | 855 | { | ||
1631 | 856 | VdpPictureInfoH264 * const pic_info = &obj_context->vdp_picture_info.h264; | ||
1632 | 857 | VASliceParameterBufferH264 * const slice_params = obj_buffer->buffer_data; | ||
1633 | 858 | VASliceParameterBufferH264 * const slice_param = &slice_params[obj_buffer->num_elements - 1]; | ||
1634 | 859 | |||
1635 | 860 | pic_info->slice_count += obj_buffer->num_elements; | ||
1636 | 861 | pic_info->num_ref_idx_l0_active_minus1 = slice_param->num_ref_idx_l0_active_minus1; | ||
1637 | 862 | pic_info->num_ref_idx_l1_active_minus1 = slice_param->num_ref_idx_l1_active_minus1; | ||
1638 | 863 | obj_context->last_slice_params = obj_buffer->buffer_data; | ||
1639 | 864 | obj_context->last_slice_params_count = obj_buffer->num_elements; | ||
1640 | 865 | return 1; | ||
1641 | 866 | } | ||
1642 | 867 | |||
1643 | 868 | // Translate VAPictureParameterBufferVC1 | ||
1644 | 869 | static int | ||
1645 | 870 | translate_VAPictureParameterBufferVC1( | ||
1646 | 871 | vdpau_driver_data_t *driver_data, | ||
1647 | 872 | object_context_p obj_context, | ||
1648 | 873 | object_buffer_p obj_buffer | ||
1649 | 874 | ) | ||
1650 | 875 | { | ||
1651 | 876 | VdpPictureInfoVC1 * const pic_info = &obj_context->vdp_picture_info.vc1; | ||
1652 | 877 | VAPictureParameterBufferVC1 * const pic_param = obj_buffer->buffer_data; | ||
1653 | 878 | int picture_type, major_version, minor_version; | ||
1654 | 879 | |||
1655 | 880 | if (!translate_VASurfaceID(driver_data, | ||
1656 | 881 | pic_param->forward_reference_picture, | ||
1657 | 882 | &pic_info->forward_reference)) | ||
1658 | 883 | return 0; | ||
1659 | 884 | |||
1660 | 885 | if (!translate_VASurfaceID(driver_data, | ||
1661 | 886 | pic_param->backward_reference_picture, | ||
1662 | 887 | &pic_info->backward_reference)) | ||
1663 | 888 | return 0; | ||
1664 | 889 | |||
1665 | 890 | switch (pic_param->picture_fields.bits.picture_type) { | ||
1666 | 891 | case 0: picture_type = 0; break; /* I */ | ||
1667 | 892 | case 1: picture_type = 1; break; /* P */ | ||
1668 | 893 | case 2: picture_type = 3; break; /* B */ | ||
1669 | 894 | case 3: picture_type = 4; break; /* BI */ | ||
1670 | 895 | case 4: picture_type = 1; break; /* P "skipped" */ | ||
1671 | 896 | default: return 0; | ||
1672 | 897 | } | ||
1673 | 898 | |||
1674 | 899 | pic_info->picture_type = picture_type; | ||
1675 | 900 | pic_info->frame_coding_mode = pic_param->picture_fields.bits.frame_coding_mode; | ||
1676 | 901 | pic_info->postprocflag = pic_param->post_processing != 0; | ||
1677 | 902 | pic_info->pulldown = pic_param->sequence_fields.bits.pulldown; | ||
1678 | 903 | pic_info->interlace = pic_param->sequence_fields.bits.interlace; | ||
1679 | 904 | pic_info->tfcntrflag = pic_param->sequence_fields.bits.tfcntrflag; | ||
1680 | 905 | pic_info->finterpflag = pic_param->sequence_fields.bits.finterpflag; | ||
1681 | 906 | pic_info->psf = pic_param->sequence_fields.bits.psf; | ||
1682 | 907 | pic_info->dquant = pic_param->pic_quantizer_fields.bits.dquant; | ||
1683 | 908 | pic_info->panscan_flag = pic_param->entrypoint_fields.bits.panscan_flag; | ||
1684 | 909 | pic_info->refdist_flag = pic_param->reference_fields.bits.reference_distance_flag; | ||
1685 | 910 | pic_info->quantizer = pic_param->pic_quantizer_fields.bits.quantizer; | ||
1686 | 911 | pic_info->extended_mv = pic_param->mv_fields.bits.extended_mv_flag; | ||
1687 | 912 | pic_info->extended_dmv = pic_param->mv_fields.bits.extended_dmv_flag; | ||
1688 | 913 | pic_info->overlap = pic_param->sequence_fields.bits.overlap; | ||
1689 | 914 | pic_info->vstransform = pic_param->transform_fields.bits.variable_sized_transform_flag; | ||
1690 | 915 | pic_info->loopfilter = pic_param->entrypoint_fields.bits.loopfilter; | ||
1691 | 916 | pic_info->fastuvmc = pic_param->fast_uvmc_flag; | ||
1692 | 917 | pic_info->range_mapy_flag = pic_param->range_mapping_fields.bits.luma_flag; | ||
1693 | 918 | pic_info->range_mapy = pic_param->range_mapping_fields.bits.luma; | ||
1694 | 919 | pic_info->range_mapuv_flag = pic_param->range_mapping_fields.bits.chroma_flag; | ||
1695 | 920 | pic_info->range_mapuv = pic_param->range_mapping_fields.bits.chroma; | ||
1696 | 921 | pic_info->multires = pic_param->sequence_fields.bits.multires; | ||
1697 | 922 | pic_info->syncmarker = pic_param->sequence_fields.bits.syncmarker; | ||
1698 | 923 | pic_info->rangered = pic_param->sequence_fields.bits.rangered; | ||
1699 | 924 | if (!vdpau_is_nvidia(driver_data, &major_version, &minor_version) || | ||
1700 | 925 | (major_version > 180 || minor_version >= 35)) | ||
1701 | 926 | pic_info->rangered |= pic_param->range_reduction_frame << 1; | ||
1702 | 927 | pic_info->maxbframes = pic_param->sequence_fields.bits.max_b_frames; | ||
1703 | 928 | pic_info->deblockEnable = pic_param->post_processing != 0; /* XXX: this is NVIDIA's vdpau.c semantics (postprocflag & 1) */ | ||
1704 | 929 | pic_info->pquant = pic_param->pic_quantizer_fields.bits.pic_quantizer_scale; | ||
1705 | 930 | return 1; | ||
1706 | 931 | } | ||
1707 | 932 | |||
1708 | 933 | // Translate VASliceParameterBufferVC1 | ||
1709 | 934 | static int | ||
1710 | 935 | translate_VASliceParameterBufferVC1( | ||
1711 | 936 | vdpau_driver_data_t *driver_data, | ||
1712 | 937 | object_context_p obj_context, | ||
1713 | 938 | object_buffer_p obj_buffer | ||
1714 | 939 | ) | ||
1715 | 940 | { | ||
1716 | 941 | VdpPictureInfoVC1 * const pic_info = &obj_context->vdp_picture_info.vc1; | ||
1717 | 942 | |||
1718 | 943 | pic_info->slice_count += obj_buffer->num_elements; | ||
1719 | 944 | obj_context->last_slice_params = obj_buffer->buffer_data; | ||
1720 | 945 | obj_context->last_slice_params_count = obj_buffer->num_elements; | ||
1721 | 946 | return 1; | ||
1722 | 947 | } | ||
1723 | 948 | |||
1724 | 949 | // Translate VA buffer | ||
1725 | 950 | typedef int | ||
1726 | 951 | (*translate_buffer_func_t)(vdpau_driver_data_t *driver_data, | ||
1727 | 952 | object_context_p obj_context, | ||
1728 | 953 | object_buffer_p obj_buffer); | ||
1729 | 954 | |||
1730 | 955 | typedef struct translate_buffer_info translate_buffer_info_t; | ||
1731 | 956 | struct translate_buffer_info { | ||
1732 | 957 | VdpCodec codec; | ||
1733 | 958 | VABufferType type; | ||
1734 | 959 | translate_buffer_func_t func; | ||
1735 | 960 | }; | ||
1736 | 961 | |||
1737 | 962 | static int | ||
1738 | 963 | translate_buffer( | ||
1739 | 964 | vdpau_driver_data_t *driver_data, | ||
1740 | 965 | object_context_p obj_context, | ||
1741 | 966 | object_buffer_p obj_buffer | ||
1742 | 967 | ) | ||
1743 | 968 | { | ||
1744 | 969 | static const translate_buffer_info_t translate_info[] = { | ||
1745 | 970 | #define _(CODEC, TYPE) \ | ||
1746 | 971 | { VDP_CODEC_##CODEC, VA##TYPE##BufferType, \ | ||
1747 | 972 | translate_VA##TYPE##Buffer##CODEC } | ||
1748 | 973 | _(MPEG2, PictureParameter), | ||
1749 | 974 | _(MPEG2, IQMatrix), | ||
1750 | 975 | _(MPEG2, SliceParameter), | ||
1751 | 976 | #if USE_VDPAU_MPEG4 | ||
1752 | 977 | _(MPEG4, PictureParameter), | ||
1753 | 978 | _(MPEG4, IQMatrix), | ||
1754 | 979 | _(MPEG4, SliceParameter), | ||
1755 | 980 | #endif | ||
1756 | 981 | _(H264, PictureParameter), | ||
1757 | 982 | _(H264, IQMatrix), | ||
1758 | 983 | _(H264, SliceParameter), | ||
1759 | 984 | _(VC1, PictureParameter), | ||
1760 | 985 | _(VC1, SliceParameter), | ||
1761 | 986 | #undef _ | ||
1762 | 987 | { VDP_CODEC_VC1, VABitPlaneBufferType, translate_nothing }, | ||
1763 | 988 | { 0, VASliceDataBufferType, translate_VASliceDataBuffer }, | ||
1764 | 989 | { 0, 0, NULL } | ||
1765 | 990 | }; | ||
1766 | 991 | const translate_buffer_info_t *tbip; | ||
1767 | 992 | for (tbip = translate_info; tbip->func != NULL; tbip++) { | ||
1768 | 993 | if (tbip->codec && tbip->codec != obj_context->vdp_codec) | ||
1769 | 994 | continue; | ||
1770 | 995 | if (tbip->type != obj_buffer->type) | ||
1771 | 996 | continue; | ||
1772 | 997 | return tbip->func(driver_data, obj_context, obj_buffer); | ||
1773 | 998 | } | ||
1774 | 999 | D(bug("ERROR: no translate function found for %s%s\n", | ||
1775 | 1000 | string_of_VABufferType(obj_buffer->type), | ||
1776 | 1001 | obj_context->vdp_codec ? string_of_VdpCodec(obj_context->vdp_codec) : NULL)); | ||
1777 | 1002 | return 0; | ||
1778 | 1003 | } | ||
1779 | 1004 | |||
1780 | 1005 | // vaQueryConfigProfiles | ||
1781 | 1006 | VAStatus | ||
1782 | 1007 | vdpau_QueryConfigProfiles( | ||
1783 | 1008 | VADriverContextP ctx, | ||
1784 | 1009 | VAProfile *profile_list, | ||
1785 | 1010 | int *num_profiles | ||
1786 | 1011 | ) | ||
1787 | 1012 | { | ||
1788 | 1013 | VDPAU_DRIVER_DATA_INIT; | ||
1789 | 1014 | |||
1790 | 1015 | static const VAProfile va_profiles[] = { | ||
1791 | 1016 | VAProfileMPEG2Simple, | ||
1792 | 1017 | VAProfileMPEG2Main, | ||
1793 | 1018 | VAProfileMPEG4Simple, | ||
1794 | 1019 | VAProfileMPEG4AdvancedSimple, | ||
1795 | 1020 | VAProfileMPEG4Main, | ||
1796 | 1021 | VAProfileH264Baseline, | ||
1797 | 1022 | VAProfileH264Main, | ||
1798 | 1023 | VAProfileH264High, | ||
1799 | 1024 | VAProfileVC1Simple, | ||
1800 | 1025 | VAProfileVC1Main, | ||
1801 | 1026 | VAProfileVC1Advanced | ||
1802 | 1027 | }; | ||
1803 | 1028 | |||
1804 | 1029 | int i, n = 0; | ||
1805 | 1030 | for (i = 0; i < ARRAY_ELEMS(va_profiles); i++) { | ||
1806 | 1031 | VAProfile profile = va_profiles[i]; | ||
1807 | 1032 | VdpDecoderProfile vdp_profile = get_VdpDecoderProfile(profile); | ||
1808 | 1033 | if (is_supported_profile(driver_data, vdp_profile)) | ||
1809 | 1034 | profile_list[n++] = profile; | ||
1810 | 1035 | } | ||
1811 | 1036 | |||
1812 | 1037 | /* If the assert fails then VDPAU_MAX_PROFILES needs to be bigger */ | ||
1813 | 1038 | ASSERT(n <= VDPAU_MAX_PROFILES); | ||
1814 | 1039 | if (num_profiles) | ||
1815 | 1040 | *num_profiles = n; | ||
1816 | 1041 | |||
1817 | 1042 | return VA_STATUS_SUCCESS; | ||
1818 | 1043 | } | ||
1819 | 1044 | |||
1820 | 1045 | // vaQueryConfigEntrypoints | ||
1821 | 1046 | VAStatus | ||
1822 | 1047 | vdpau_QueryConfigEntrypoints( | ||
1823 | 1048 | VADriverContextP ctx, | ||
1824 | 1049 | VAProfile profile, | ||
1825 | 1050 | VAEntrypoint *entrypoint_list, | ||
1826 | 1051 | int *num_entrypoints | ||
1827 | 1052 | ) | ||
1828 | 1053 | { | ||
1829 | 1054 | VDPAU_DRIVER_DATA_INIT; | ||
1830 | 1055 | |||
1831 | 1056 | VdpDecoderProfile vdp_profile = get_VdpDecoderProfile(profile); | ||
1832 | 1057 | if (!is_supported_profile(driver_data, vdp_profile)) | ||
1833 | 1058 | return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; | ||
1834 | 1059 | |||
1835 | 1060 | VAEntrypoint entrypoint; | ||
1836 | 1061 | switch (profile) { | ||
1837 | 1062 | case VAProfileMPEG2Simple: | ||
1838 | 1063 | case VAProfileMPEG2Main: | ||
1839 | 1064 | entrypoint = VAEntrypointVLD; | ||
1840 | 1065 | break; | ||
1841 | 1066 | case VAProfileMPEG4Simple: | ||
1842 | 1067 | case VAProfileMPEG4AdvancedSimple: | ||
1843 | 1068 | case VAProfileMPEG4Main: | ||
1844 | 1069 | entrypoint = VAEntrypointVLD; | ||
1845 | 1070 | break; | ||
1846 | 1071 | case VAProfileH264Baseline: | ||
1847 | 1072 | case VAProfileH264Main: | ||
1848 | 1073 | case VAProfileH264High: | ||
1849 | 1074 | entrypoint = VAEntrypointVLD; | ||
1850 | 1075 | break; | ||
1851 | 1076 | case VAProfileVC1Simple: | ||
1852 | 1077 | case VAProfileVC1Main: | ||
1853 | 1078 | case VAProfileVC1Advanced: | ||
1854 | 1079 | entrypoint = VAEntrypointVLD; | ||
1855 | 1080 | break; | ||
1856 | 1081 | default: | ||
1857 | 1082 | entrypoint = 0; | ||
1858 | 1083 | break; | ||
1859 | 1084 | } | ||
1860 | 1085 | |||
1861 | 1086 | if (entrypoint_list) | ||
1862 | 1087 | *entrypoint_list = entrypoint; | ||
1863 | 1088 | |||
1864 | 1089 | if (num_entrypoints) | ||
1865 | 1090 | *num_entrypoints = entrypoint != 0; | ||
1866 | 1091 | |||
1867 | 1092 | return VA_STATUS_SUCCESS; | ||
1868 | 1093 | } | ||
1869 | 1094 | |||
1870 | 1095 | // vaBeginPicture | ||
1871 | 1096 | VAStatus | ||
1872 | 1097 | vdpau_BeginPicture( | ||
1873 | 1098 | VADriverContextP ctx, | ||
1874 | 1099 | VAContextID context, | ||
1875 | 1100 | VASurfaceID render_target | ||
1876 | 1101 | ) | ||
1877 | 1102 | { | ||
1878 | 1103 | VDPAU_DRIVER_DATA_INIT; | ||
1879 | 1104 | |||
1880 | 1105 | object_context_p obj_context = VDPAU_CONTEXT(context); | ||
1881 | 1106 | if (!obj_context) | ||
1882 | 1107 | return VA_STATUS_ERROR_INVALID_CONTEXT; | ||
1883 | 1108 | |||
1884 | 1109 | object_surface_p obj_surface = VDPAU_SURFACE(render_target); | ||
1885 | 1110 | if (!obj_surface) | ||
1886 | 1111 | return VA_STATUS_ERROR_INVALID_SURFACE; | ||
1887 | 1112 | |||
1888 | 1113 | obj_surface->va_surface_status = VASurfaceRendering; | ||
1889 | 1114 | obj_context->last_pic_param = NULL; | ||
1890 | 1115 | obj_context->last_slice_params = NULL; | ||
1891 | 1116 | obj_context->last_slice_params_count = 0; | ||
1892 | 1117 | obj_context->current_render_target = obj_surface->base.id; | ||
1893 | 1118 | obj_context->gen_slice_data_size = 0; | ||
1894 | 1119 | obj_context->vdp_bitstream_buffers_count = 0; | ||
1895 | 1120 | |||
1896 | 1121 | switch (obj_context->vdp_codec) { | ||
1897 | 1122 | case VDP_CODEC_MPEG1: | ||
1898 | 1123 | case VDP_CODEC_MPEG2: | ||
1899 | 1124 | obj_context->vdp_picture_info.mpeg2.slice_count = 0; | ||
1900 | 1125 | break; | ||
1901 | 1126 | case VDP_CODEC_MPEG4: | ||
1902 | 1127 | break; | ||
1903 | 1128 | case VDP_CODEC_H264: | ||
1904 | 1129 | obj_context->vdp_picture_info.h264.slice_count = 0; | ||
1905 | 1130 | break; | ||
1906 | 1131 | case VDP_CODEC_VC1: | ||
1907 | 1132 | obj_context->vdp_picture_info.vc1.slice_count = 0; | ||
1908 | 1133 | break; | ||
1909 | 1134 | default: | ||
1910 | 1135 | return VA_STATUS_ERROR_UNKNOWN; | ||
1911 | 1136 | } | ||
1912 | 1137 | return VA_STATUS_SUCCESS; | ||
1913 | 1138 | } | ||
1914 | 1139 | |||
1915 | 1140 | // vaRenderPicture | ||
1916 | 1141 | VAStatus | ||
1917 | 1142 | vdpau_RenderPicture( | ||
1918 | 1143 | VADriverContextP ctx, | ||
1919 | 1144 | VAContextID context, | ||
1920 | 1145 | VABufferID *buffers, | ||
1921 | 1146 | int num_buffers | ||
1922 | 1147 | ) | ||
1923 | 1148 | { | ||
1924 | 1149 | VDPAU_DRIVER_DATA_INIT; | ||
1925 | 1150 | int i; | ||
1926 | 1151 | |||
1927 | 1152 | object_context_p obj_context = VDPAU_CONTEXT(context); | ||
1928 | 1153 | if (!obj_context) | ||
1929 | 1154 | return VA_STATUS_ERROR_INVALID_CONTEXT; | ||
1930 | 1155 | |||
1931 | 1156 | object_surface_p obj_surface = VDPAU_SURFACE(obj_context->current_render_target); | ||
1932 | 1157 | if (!obj_surface) | ||
1933 | 1158 | return VA_STATUS_ERROR_INVALID_SURFACE; | ||
1934 | 1159 | |||
1935 | 1160 | /* Verify that we got valid buffer references */ | ||
1936 | 1161 | for (i = 0; i < num_buffers; i++) { | ||
1937 | 1162 | object_buffer_p obj_buffer = VDPAU_BUFFER(buffers[i]); | ||
1938 | 1163 | if (!obj_buffer) | ||
1939 | 1164 | return VA_STATUS_ERROR_INVALID_BUFFER; | ||
1940 | 1165 | } | ||
1941 | 1166 | |||
1942 | 1167 | /* Translate buffers */ | ||
1943 | 1168 | for (i = 0; i < num_buffers; i++) { | ||
1944 | 1169 | object_buffer_p obj_buffer = VDPAU_BUFFER(buffers[i]); | ||
1945 | 1170 | if (!translate_buffer(driver_data, obj_context, obj_buffer)) | ||
1946 | 1171 | return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; | ||
1947 | 1172 | /* Release any buffer that is not VASliceDataBuffer */ | ||
1948 | 1173 | /* VASliceParameterBuffer is also needed to check for start_codes */ | ||
1949 | 1174 | switch (obj_buffer->type) { | ||
1950 | 1175 | case VASliceParameterBufferType: | ||
1951 | 1176 | case VASliceDataBufferType: | ||
1952 | 1177 | schedule_destroy_va_buffer(driver_data, obj_buffer); | ||
1953 | 1178 | break; | ||
1954 | 1179 | case VAPictureParameterBufferType: | ||
1955 | 1180 | /* Preserve VAPictureParameterBufferMPEG4 */ | ||
1956 | 1181 | if (obj_context->vdp_codec == VDP_CODEC_MPEG4) { | ||
1957 | 1182 | schedule_destroy_va_buffer(driver_data, obj_buffer); | ||
1958 | 1183 | break; | ||
1959 | 1184 | } | ||
1960 | 1185 | /* fall-through */ | ||
1961 | 1186 | default: | ||
1962 | 1187 | destroy_va_buffer(driver_data, obj_buffer); | ||
1963 | 1188 | break; | ||
1964 | 1189 | } | ||
1965 | 1190 | } | ||
1966 | 1191 | |||
1967 | 1192 | return VA_STATUS_SUCCESS; | ||
1968 | 1193 | } | ||
1969 | 1194 | |||
1970 | 1195 | // vaEndPicture | ||
1971 | 1196 | VAStatus | ||
1972 | 1197 | vdpau_EndPicture( | ||
1973 | 1198 | VADriverContextP ctx, | ||
1974 | 1199 | VAContextID context | ||
1975 | 1200 | ) | ||
1976 | 1201 | { | ||
1977 | 1202 | VDPAU_DRIVER_DATA_INIT; | ||
1978 | 1203 | unsigned int i; | ||
1979 | 1204 | |||
1980 | 1205 | object_context_p obj_context = VDPAU_CONTEXT(context); | ||
1981 | 1206 | if (!obj_context) | ||
1982 | 1207 | return VA_STATUS_ERROR_INVALID_CONTEXT; | ||
1983 | 1208 | |||
1984 | 1209 | object_surface_p obj_surface = VDPAU_SURFACE(obj_context->current_render_target); | ||
1985 | 1210 | if (!obj_surface) | ||
1986 | 1211 | return VA_STATUS_ERROR_INVALID_SURFACE; | ||
1987 | 1212 | |||
1988 | 1213 | if (trace_enabled()) { | ||
1989 | 1214 | switch (obj_context->vdp_codec) { | ||
1990 | 1215 | case VDP_CODEC_MPEG1: | ||
1991 | 1216 | case VDP_CODEC_MPEG2: | ||
1992 | 1217 | dump_VdpPictureInfoMPEG1Or2(&obj_context->vdp_picture_info.mpeg2); | ||
1993 | 1218 | break; | ||
1994 | 1219 | #if HAVE_VDPAU_MPEG4 | ||
1995 | 1220 | case VDP_CODEC_MPEG4: | ||
1996 | 1221 | dump_VdpPictureInfoMPEG4Part2(&obj_context->vdp_picture_info.mpeg4); | ||
1997 | 1222 | break; | ||
1998 | 1223 | #endif | ||
1999 | 1224 | case VDP_CODEC_H264: | ||
2000 | 1225 | dump_VdpPictureInfoH264(&obj_context->vdp_picture_info.h264); | ||
2001 | 1226 | break; | ||
2002 | 1227 | case VDP_CODEC_VC1: | ||
2003 | 1228 | dump_VdpPictureInfoVC1(&obj_context->vdp_picture_info.vc1); | ||
2004 | 1229 | break; | ||
2005 | 1230 | default: | ||
2006 | 1231 | break; | ||
2007 | 1232 | } | ||
2008 | 1233 | for (i = 0; i < obj_context->vdp_bitstream_buffers_count; i++) | ||
2009 | 1234 | dump_VdpBitstreamBuffer(&obj_context->vdp_bitstream_buffers[i]); | ||
2010 | 1235 | } | ||
2011 | 1236 | |||
2012 | 1237 | VAStatus va_status; | ||
2013 | 1238 | VdpStatus vdp_status; | ||
2014 | 1239 | vdp_status = ensure_decoder_with_max_refs( | ||
2015 | 1240 | driver_data, | ||
2016 | 1241 | obj_context, | ||
2017 | 1242 | get_num_ref_frames(obj_context) | ||
2018 | 1243 | ); | ||
2019 | 1244 | if (vdp_status == VDP_STATUS_OK) | ||
2020 | 1245 | vdp_status = vdpau_decoder_render( | ||
2021 | 1246 | driver_data, | ||
2022 | 1247 | obj_context->vdp_decoder, | ||
2023 | 1248 | obj_surface->vdp_surface, | ||
2024 | 1249 | (VdpPictureInfo)&obj_context->vdp_picture_info, | ||
2025 | 1250 | obj_context->vdp_bitstream_buffers_count, | ||
2026 | 1251 | obj_context->vdp_bitstream_buffers | ||
2027 | 1252 | ); | ||
2028 | 1253 | va_status = vdpau_get_VAStatus(vdp_status); | ||
2029 | 1254 | |||
2030 | 1255 | /* XXX: assume we are done with rendering right away */ | ||
2031 | 1256 | obj_context->current_render_target = VA_INVALID_SURFACE; | ||
2032 | 1257 | |||
2033 | 1258 | /* Release pending buffers */ | ||
2034 | 1259 | if (obj_context->dead_buffers_count > 0) { | ||
2035 | 1260 | ASSERT(obj_context->dead_buffers); | ||
2036 | 1261 | int i; | ||
2037 | 1262 | for (i = 0; i < obj_context->dead_buffers_count; i++) { | ||
2038 | 1263 | object_buffer_p obj_buffer = VDPAU_BUFFER(obj_context->dead_buffers[i]); | ||
2039 | 1264 | ASSERT(obj_buffer); | ||
2040 | 1265 | destroy_va_buffer(driver_data, obj_buffer); | ||
2041 | 1266 | } | ||
2042 | 1267 | obj_context->dead_buffers_count = 0; | ||
2043 | 1268 | } | ||
2044 | 1269 | |||
2045 | 1270 | return va_status; | ||
2046 | 1271 | } | ||
2047 | 0 | 1272 | ||
2048 | === added file '.pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_video.c' | |||
2049 | --- .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_video.c 1970-01-01 00:00:00 +0000 | |||
2050 | +++ .pc/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch/src/vdpau_video.c 2014-05-06 21:31:51 +0000 | |||
2051 | @@ -0,0 +1,995 @@ | |||
2052 | 1 | /* | ||
2053 | 2 | * vdpau_video.c - VDPAU backend for VA-API | ||
2054 | 3 | * | ||
2055 | 4 | * vdpau-video (C) 2009-2011 Splitted-Desktop Systems | ||
2056 | 5 | * | ||
2057 | 6 | * This program is free software; you can redistribute it and/or modify | ||
2058 | 7 | * it under the terms of the GNU General Public License as published by | ||
2059 | 8 | * the Free Software Foundation; either version 2 of the License, or | ||
2060 | 9 | * (at your option) any later version. | ||
2061 | 10 | * | ||
2062 | 11 | * This program is distributed in the hope that it will be useful, | ||
2063 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2064 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2065 | 14 | * GNU General Public License for more details. | ||
2066 | 15 | * | ||
2067 | 16 | * You should have received a copy of the GNU General Public License | ||
2068 | 17 | * along with this program; if not, write to the Free Software | ||
2069 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
2070 | 19 | */ | ||
2071 | 20 | |||
2072 | 21 | #include "sysdeps.h" | ||
2073 | 22 | #include "vdpau_video.h" | ||
2074 | 23 | #include "vdpau_video_x11.h" | ||
2075 | 24 | #include "vdpau_decode.h" | ||
2076 | 25 | #include "vdpau_subpic.h" | ||
2077 | 26 | #include "vdpau_mixer.h" | ||
2078 | 27 | #include "utils.h" | ||
2079 | 28 | |||
2080 | 29 | #define DEBUG 1 | ||
2081 | 30 | #include "debug.h" | ||
2082 | 31 | |||
2083 | 32 | |||
2084 | 33 | /* Define wait delay (in microseconds) for vaSyncSurface() implementation | ||
2085 | 34 | with polling. */ | ||
2086 | 35 | #define VDPAU_SYNC_DELAY 5000 | ||
2087 | 36 | |||
2088 | 37 | // Translates VA-API chroma format to VdpChromaType | ||
2089 | 38 | static VdpChromaType get_VdpChromaType(int format) | ||
2090 | 39 | { | ||
2091 | 40 | switch (format) { | ||
2092 | 41 | case VA_RT_FORMAT_YUV420: return VDP_CHROMA_TYPE_420; | ||
2093 | 42 | case VA_RT_FORMAT_YUV422: return VDP_CHROMA_TYPE_422; | ||
2094 | 43 | case VA_RT_FORMAT_YUV444: return VDP_CHROMA_TYPE_444; | ||
2095 | 44 | } | ||
2096 | 45 | return (VdpChromaType)-1; | ||
2097 | 46 | } | ||
2098 | 47 | |||
2099 | 48 | |||
2100 | 49 | /* ====================================================================== */ | ||
2101 | 50 | /* === VA-API Implementation with VDPAU === */ | ||
2102 | 51 | /* ====================================================================== */ | ||
2103 | 52 | |||
2104 | 53 | // Returns the maximum dimensions supported by the VDPAU implementation for that profile | ||
2105 | 54 | static inline VdpBool | ||
2106 | 55 | get_max_surface_size( | ||
2107 | 56 | vdpau_driver_data_t *driver_data, | ||
2108 | 57 | VdpDecoderProfile profile, | ||
2109 | 58 | uint32_t *pmax_width, | ||
2110 | 59 | uint32_t *pmax_height | ||
2111 | 60 | ) | ||
2112 | 61 | { | ||
2113 | 62 | VdpBool is_supported = VDP_FALSE; | ||
2114 | 63 | VdpStatus vdp_status; | ||
2115 | 64 | uint32_t max_level, max_references, max_width, max_height; | ||
2116 | 65 | |||
2117 | 66 | if (pmax_width) | ||
2118 | 67 | *pmax_width = 0; | ||
2119 | 68 | if (pmax_height) | ||
2120 | 69 | *pmax_height = 0; | ||
2121 | 70 | |||
2122 | 71 | vdp_status = vdpau_decoder_query_capabilities( | ||
2123 | 72 | driver_data, | ||
2124 | 73 | driver_data->vdp_device, | ||
2125 | 74 | profile, | ||
2126 | 75 | &is_supported, | ||
2127 | 76 | &max_level, | ||
2128 | 77 | &max_references, | ||
2129 | 78 | &max_width, | ||
2130 | 79 | &max_height | ||
2131 | 80 | ); | ||
2132 | 81 | if (!VDPAU_CHECK_STATUS(vdp_status, "VdpDecoderQueryCapabilities()")) | ||
2133 | 82 | return VDP_FALSE; | ||
2134 | 83 | |||
2135 | 84 | if (!is_supported) | ||
2136 | 85 | return VDP_FALSE; | ||
2137 | 86 | |||
2138 | 87 | if (pmax_width) | ||
2139 | 88 | *pmax_width = max_width; | ||
2140 | 89 | if (max_height) | ||
2141 | 90 | *pmax_height = max_height; | ||
2142 | 91 | |||
2143 | 92 | return VDP_TRUE; | ||
2144 | 93 | } | ||
2145 | 94 | |||
2146 | 95 | // vaGetConfigAttributes | ||
2147 | 96 | VAStatus | ||
2148 | 97 | vdpau_GetConfigAttributes( | ||
2149 | 98 | VADriverContextP ctx, | ||
2150 | 99 | VAProfile profile, | ||
2151 | 100 | VAEntrypoint entrypoint, | ||
2152 | 101 | VAConfigAttrib *attrib_list, | ||
2153 | 102 | int num_attribs | ||
2154 | 103 | ) | ||
2155 | 104 | { | ||
2156 | 105 | VDPAU_DRIVER_DATA_INIT; | ||
2157 | 106 | |||
2158 | 107 | VAStatus va_status = check_decoder(driver_data, profile, entrypoint); | ||
2159 | 108 | if (va_status != VA_STATUS_SUCCESS) | ||
2160 | 109 | return va_status; | ||
2161 | 110 | |||
2162 | 111 | int i; | ||
2163 | 112 | for (i = 0; i < num_attribs; i++) { | ||
2164 | 113 | switch (attrib_list[i].type) { | ||
2165 | 114 | case VAConfigAttribRTFormat: | ||
2166 | 115 | attrib_list[i].value = VA_RT_FORMAT_YUV420; | ||
2167 | 116 | break; | ||
2168 | 117 | default: | ||
2169 | 118 | attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; | ||
2170 | 119 | break; | ||
2171 | 120 | } | ||
2172 | 121 | } | ||
2173 | 122 | return VA_STATUS_SUCCESS; | ||
2174 | 123 | } | ||
2175 | 124 | |||
2176 | 125 | static VAStatus | ||
2177 | 126 | vdpau_update_attribute(object_config_p obj_config, VAConfigAttrib *attrib) | ||
2178 | 127 | { | ||
2179 | 128 | int i; | ||
2180 | 129 | |||
2181 | 130 | /* Check existing attrbiutes */ | ||
2182 | 131 | for (i = 0; obj_config->attrib_count < i; i++) { | ||
2183 | 132 | if (obj_config->attrib_list[i].type == attrib->type) { | ||
2184 | 133 | /* Update existing attribute */ | ||
2185 | 134 | obj_config->attrib_list[i].value = attrib->value; | ||
2186 | 135 | return VA_STATUS_SUCCESS; | ||
2187 | 136 | } | ||
2188 | 137 | } | ||
2189 | 138 | if (obj_config->attrib_count < VDPAU_MAX_CONFIG_ATTRIBUTES) { | ||
2190 | 139 | i = obj_config->attrib_count; | ||
2191 | 140 | obj_config->attrib_list[i].type = attrib->type; | ||
2192 | 141 | obj_config->attrib_list[i].value = attrib->value; | ||
2193 | 142 | obj_config->attrib_count++; | ||
2194 | 143 | return VA_STATUS_SUCCESS; | ||
2195 | 144 | } | ||
2196 | 145 | return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; | ||
2197 | 146 | } | ||
2198 | 147 | |||
2199 | 148 | // vaDestroyConfig | ||
2200 | 149 | VAStatus vdpau_DestroyConfig(VADriverContextP ctx, VAConfigID config_id) | ||
2201 | 150 | { | ||
2202 | 151 | VDPAU_DRIVER_DATA_INIT; | ||
2203 | 152 | |||
2204 | 153 | object_config_p obj_config = VDPAU_CONFIG(config_id); | ||
2205 | 154 | if (!obj_config) | ||
2206 | 155 | return VA_STATUS_ERROR_INVALID_CONFIG; | ||
2207 | 156 | |||
2208 | 157 | object_heap_free(&driver_data->config_heap, (object_base_p)obj_config); | ||
2209 | 158 | return VA_STATUS_SUCCESS; | ||
2210 | 159 | } | ||
2211 | 160 | |||
2212 | 161 | // vaCreateConfig | ||
2213 | 162 | VAStatus | ||
2214 | 163 | vdpau_CreateConfig( | ||
2215 | 164 | VADriverContextP ctx, | ||
2216 | 165 | VAProfile profile, | ||
2217 | 166 | VAEntrypoint entrypoint, | ||
2218 | 167 | VAConfigAttrib *attrib_list, | ||
2219 | 168 | int num_attribs, | ||
2220 | 169 | VAConfigID *config_id | ||
2221 | 170 | ) | ||
2222 | 171 | { | ||
2223 | 172 | VDPAU_DRIVER_DATA_INIT; | ||
2224 | 173 | |||
2225 | 174 | VAStatus va_status; | ||
2226 | 175 | int configID; | ||
2227 | 176 | object_config_p obj_config; | ||
2228 | 177 | int i; | ||
2229 | 178 | |||
2230 | 179 | /* Validate profile and entrypoint */ | ||
2231 | 180 | va_status = check_decoder(driver_data, profile, entrypoint); | ||
2232 | 181 | if (va_status != VA_STATUS_SUCCESS) | ||
2233 | 182 | return va_status; | ||
2234 | 183 | |||
2235 | 184 | configID = object_heap_allocate(&driver_data->config_heap); | ||
2236 | 185 | if ((obj_config = VDPAU_CONFIG(configID)) == NULL) | ||
2237 | 186 | return VA_STATUS_ERROR_ALLOCATION_FAILED; | ||
2238 | 187 | |||
2239 | 188 | obj_config->profile = profile; | ||
2240 | 189 | obj_config->entrypoint = entrypoint; | ||
2241 | 190 | obj_config->attrib_list[0].type = VAConfigAttribRTFormat; | ||
2242 | 191 | obj_config->attrib_list[0].value = VA_RT_FORMAT_YUV420; | ||
2243 | 192 | obj_config->attrib_count = 1; | ||
2244 | 193 | |||
2245 | 194 | for(i = 0; i < num_attribs; i++) { | ||
2246 | 195 | va_status = vdpau_update_attribute(obj_config, &attrib_list[i]); | ||
2247 | 196 | if (va_status != VA_STATUS_SUCCESS) { | ||
2248 | 197 | vdpau_DestroyConfig(ctx, configID); | ||
2249 | 198 | return va_status; | ||
2250 | 199 | } | ||
2251 | 200 | } | ||
2252 | 201 | |||
2253 | 202 | if (config_id) | ||
2254 | 203 | *config_id = configID; | ||
2255 | 204 | |||
2256 | 205 | return va_status; | ||
2257 | 206 | } | ||
2258 | 207 | |||
2259 | 208 | // vaQueryConfigAttributes | ||
2260 | 209 | VAStatus | ||
2261 | 210 | vdpau_QueryConfigAttributes( | ||
2262 | 211 | VADriverContextP ctx, | ||
2263 | 212 | VAConfigID config_id, | ||
2264 | 213 | VAProfile *profile, | ||
2265 | 214 | VAEntrypoint *entrypoint, | ||
2266 | 215 | VAConfigAttrib *attrib_list, | ||
2267 | 216 | int *num_attribs | ||
2268 | 217 | ) | ||
2269 | 218 | { | ||
2270 | 219 | VDPAU_DRIVER_DATA_INIT; | ||
2271 | 220 | |||
2272 | 221 | VAStatus va_status = VA_STATUS_SUCCESS; | ||
2273 | 222 | object_config_p obj_config; | ||
2274 | 223 | int i; | ||
2275 | 224 | |||
2276 | 225 | obj_config = VDPAU_CONFIG(config_id); | ||
2277 | 226 | if (!obj_config) | ||
2278 | 227 | return VA_STATUS_ERROR_INVALID_CONFIG; | ||
2279 | 228 | |||
2280 | 229 | if (profile) | ||
2281 | 230 | *profile = obj_config->profile; | ||
2282 | 231 | |||
2283 | 232 | if (entrypoint) | ||
2284 | 233 | *entrypoint = obj_config->entrypoint; | ||
2285 | 234 | |||
2286 | 235 | if (num_attribs) | ||
2287 | 236 | *num_attribs = obj_config->attrib_count; | ||
2288 | 237 | |||
2289 | 238 | if (attrib_list) { | ||
2290 | 239 | for (i = 0; i < obj_config->attrib_count; i++) | ||
2291 | 240 | attrib_list[i] = obj_config->attrib_list[i]; | ||
2292 | 241 | } | ||
2293 | 242 | |||
2294 | 243 | return va_status; | ||
2295 | 244 | } | ||
2296 | 245 | |||
2297 | 246 | // Add subpicture association to surface | ||
2298 | 247 | // NOTE: the subpicture owns the SubpictureAssociation object | ||
2299 | 248 | int surface_add_association( | ||
2300 | 249 | object_surface_p obj_surface, | ||
2301 | 250 | SubpictureAssociationP assoc | ||
2302 | 251 | ) | ||
2303 | 252 | { | ||
2304 | 253 | /* Check that we don't already have this association */ | ||
2305 | 254 | if (obj_surface->assocs) { | ||
2306 | 255 | unsigned int i; | ||
2307 | 256 | for (i = 0; i < obj_surface->assocs_count; i++) { | ||
2308 | 257 | if (obj_surface->assocs[i] == assoc) | ||
2309 | 258 | return 0; | ||
2310 | 259 | if (obj_surface->assocs[i]->subpicture == assoc->subpicture) { | ||
2311 | 260 | /* XXX: this should not happen, but replace it in the interim */ | ||
2312 | 261 | ASSERT(obj_surface->assocs[i]->surface == assoc->surface); | ||
2313 | 262 | obj_surface->assocs[i] = assoc; | ||
2314 | 263 | return 0; | ||
2315 | 264 | } | ||
2316 | 265 | } | ||
2317 | 266 | } | ||
2318 | 267 | |||
2319 | 268 | /* Check that we have not reached the maximum subpictures capacity yet */ | ||
2320 | 269 | if (obj_surface->assocs_count >= VDPAU_MAX_SUBPICTURES) | ||
2321 | 270 | return -1; | ||
2322 | 271 | |||
2323 | 272 | /* Append this subpicture association */ | ||
2324 | 273 | SubpictureAssociationP *assocs; | ||
2325 | 274 | assocs = realloc_buffer( | ||
2326 | 275 | &obj_surface->assocs, | ||
2327 | 276 | &obj_surface->assocs_count_max, | ||
2328 | 277 | 1 + obj_surface->assocs_count, | ||
2329 | 278 | sizeof(obj_surface->assocs[0]) | ||
2330 | 279 | ); | ||
2331 | 280 | if (!assocs) | ||
2332 | 281 | return -1; | ||
2333 | 282 | |||
2334 | 283 | assocs[obj_surface->assocs_count++] = assoc; | ||
2335 | 284 | return 0; | ||
2336 | 285 | } | ||
2337 | 286 | |||
2338 | 287 | // Remove subpicture association from surface | ||
2339 | 288 | // NOTE: the subpicture owns the SubpictureAssociation object | ||
2340 | 289 | int surface_remove_association( | ||
2341 | 290 | object_surface_p obj_surface, | ||
2342 | 291 | SubpictureAssociationP assoc | ||
2343 | 292 | ) | ||
2344 | 293 | { | ||
2345 | 294 | if (!obj_surface->assocs || obj_surface->assocs_count == 0) | ||
2346 | 295 | return -1; | ||
2347 | 296 | |||
2348 | 297 | unsigned int i; | ||
2349 | 298 | const unsigned int last = obj_surface->assocs_count - 1; | ||
2350 | 299 | for (i = 0; i <= last; i++) { | ||
2351 | 300 | if (obj_surface->assocs[i] == assoc) { | ||
2352 | 301 | /* Swap with the last subpicture */ | ||
2353 | 302 | obj_surface->assocs[i] = obj_surface->assocs[last]; | ||
2354 | 303 | obj_surface->assocs[last] = NULL; | ||
2355 | 304 | obj_surface->assocs_count--; | ||
2356 | 305 | return 0; | ||
2357 | 306 | } | ||
2358 | 307 | } | ||
2359 | 308 | return -1; | ||
2360 | 309 | } | ||
2361 | 310 | |||
2362 | 311 | // vaDestroySurfaces | ||
2363 | 312 | VAStatus | ||
2364 | 313 | vdpau_DestroySurfaces( | ||
2365 | 314 | VADriverContextP ctx, | ||
2366 | 315 | VASurfaceID *surface_list, | ||
2367 | 316 | int num_surfaces | ||
2368 | 317 | ) | ||
2369 | 318 | { | ||
2370 | 319 | VDPAU_DRIVER_DATA_INIT; | ||
2371 | 320 | |||
2372 | 321 | int i, j, n; | ||
2373 | 322 | for (i = num_surfaces - 1; i >= 0; i--) { | ||
2374 | 323 | object_surface_p obj_surface = VDPAU_SURFACE(surface_list[i]); | ||
2375 | 324 | ASSERT(obj_surface); | ||
2376 | 325 | if (!obj_surface) | ||
2377 | 326 | continue; | ||
2378 | 327 | |||
2379 | 328 | if (obj_surface->vdp_surface != VDP_INVALID_HANDLE) { | ||
2380 | 329 | vdpau_video_surface_destroy(driver_data, obj_surface->vdp_surface); | ||
2381 | 330 | obj_surface->vdp_surface = VDP_INVALID_HANDLE; | ||
2382 | 331 | } | ||
2383 | 332 | |||
2384 | 333 | for (j = 0; j < obj_surface->output_surfaces_count; j++) { | ||
2385 | 334 | output_surface_unref(driver_data, obj_surface->output_surfaces[j]); | ||
2386 | 335 | obj_surface->output_surfaces[j] = NULL; | ||
2387 | 336 | } | ||
2388 | 337 | free(obj_surface->output_surfaces); | ||
2389 | 338 | obj_surface->output_surfaces_count = 0; | ||
2390 | 339 | obj_surface->output_surfaces_count_max = 0; | ||
2391 | 340 | |||
2392 | 341 | if (obj_surface->video_mixer) { | ||
2393 | 342 | video_mixer_unref(driver_data, obj_surface->video_mixer); | ||
2394 | 343 | obj_surface->video_mixer = NULL; | ||
2395 | 344 | } | ||
2396 | 345 | |||
2397 | 346 | if (obj_surface->assocs) { | ||
2398 | 347 | object_subpicture_p obj_subpicture; | ||
2399 | 348 | VAStatus status; | ||
2400 | 349 | const unsigned int n_assocs = obj_surface->assocs_count; | ||
2401 | 350 | |||
2402 | 351 | for (j = 0, n = 0; j < n_assocs; j++) { | ||
2403 | 352 | SubpictureAssociationP const assoc = obj_surface->assocs[0]; | ||
2404 | 353 | ASSERT(assoc); | ||
2405 | 354 | if (!assoc) | ||
2406 | 355 | continue; | ||
2407 | 356 | obj_subpicture = VDPAU_SUBPICTURE(assoc->subpicture); | ||
2408 | 357 | ASSERT(obj_subpicture); | ||
2409 | 358 | if (!obj_subpicture) | ||
2410 | 359 | continue; | ||
2411 | 360 | status = subpicture_deassociate_1(obj_subpicture, obj_surface); | ||
2412 | 361 | if (status == VA_STATUS_SUCCESS) | ||
2413 | 362 | ++n; | ||
2414 | 363 | } | ||
2415 | 364 | if (n != n_assocs) | ||
2416 | 365 | vdpau_error_message("vaDestroySurfaces(): surface 0x%08x still " | ||
2417 | 366 | "has %d subpictures associated to it\n", | ||
2418 | 367 | obj_surface->base.id, n_assocs - n); | ||
2419 | 368 | free(obj_surface->assocs); | ||
2420 | 369 | obj_surface->assocs = NULL; | ||
2421 | 370 | } | ||
2422 | 371 | obj_surface->assocs_count = 0; | ||
2423 | 372 | obj_surface->assocs_count_max = 0; | ||
2424 | 373 | |||
2425 | 374 | object_heap_free(&driver_data->surface_heap, (object_base_p)obj_surface); | ||
2426 | 375 | } | ||
2427 | 376 | return VA_STATUS_SUCCESS; | ||
2428 | 377 | } | ||
2429 | 378 | |||
2430 | 379 | // vaCreateSurfaces | ||
2431 | 380 | VAStatus | ||
2432 | 381 | vdpau_CreateSurfaces( | ||
2433 | 382 | VADriverContextP ctx, | ||
2434 | 383 | int width, | ||
2435 | 384 | int height, | ||
2436 | 385 | int format, | ||
2437 | 386 | int num_surfaces, | ||
2438 | 387 | VASurfaceID *surfaces | ||
2439 | 388 | ) | ||
2440 | 389 | { | ||
2441 | 390 | VDPAU_DRIVER_DATA_INIT; | ||
2442 | 391 | |||
2443 | 392 | VAStatus va_status = VA_STATUS_SUCCESS; | ||
2444 | 393 | VdpVideoSurface vdp_surface = VDP_INVALID_HANDLE; | ||
2445 | 394 | VdpChromaType vdp_chroma_type = get_VdpChromaType(format); | ||
2446 | 395 | VdpStatus vdp_status; | ||
2447 | 396 | int i; | ||
2448 | 397 | |||
2449 | 398 | /* We only support one format */ | ||
2450 | 399 | if (format != VA_RT_FORMAT_YUV420) | ||
2451 | 400 | return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; | ||
2452 | 401 | |||
2453 | 402 | for (i = 0; i < num_surfaces; i++) { | ||
2454 | 403 | vdp_status = vdpau_video_surface_create( | ||
2455 | 404 | driver_data, | ||
2456 | 405 | driver_data->vdp_device, | ||
2457 | 406 | vdp_chroma_type, | ||
2458 | 407 | width, height, | ||
2459 | 408 | &vdp_surface | ||
2460 | 409 | ); | ||
2461 | 410 | if (!VDPAU_CHECK_STATUS(vdp_status, "VdpVideoSurfaceCreate()")) { | ||
2462 | 411 | va_status = VA_STATUS_ERROR_ALLOCATION_FAILED; | ||
2463 | 412 | break; | ||
2464 | 413 | } | ||
2465 | 414 | |||
2466 | 415 | int va_surface = object_heap_allocate(&driver_data->surface_heap); | ||
2467 | 416 | object_surface_p obj_surface = VDPAU_SURFACE(va_surface); | ||
2468 | 417 | if (!obj_surface) { | ||
2469 | 418 | va_status = VA_STATUS_ERROR_ALLOCATION_FAILED; | ||
2470 | 419 | break; | ||
2471 | 420 | } | ||
2472 | 421 | obj_surface->va_context = VA_INVALID_ID; | ||
2473 | 422 | obj_surface->va_surface_status = VASurfaceReady; | ||
2474 | 423 | obj_surface->vdp_surface = vdp_surface; | ||
2475 | 424 | obj_surface->width = width; | ||
2476 | 425 | obj_surface->height = height; | ||
2477 | 426 | obj_surface->assocs = NULL; | ||
2478 | 427 | obj_surface->assocs_count = 0; | ||
2479 | 428 | obj_surface->assocs_count_max = 0; | ||
2480 | 429 | obj_surface->vdp_chroma_type = vdp_chroma_type; | ||
2481 | 430 | obj_surface->output_surfaces = NULL; | ||
2482 | 431 | obj_surface->output_surfaces_count = 0; | ||
2483 | 432 | obj_surface->output_surfaces_count_max = 0; | ||
2484 | 433 | obj_surface->video_mixer = NULL; | ||
2485 | 434 | surfaces[i] = va_surface; | ||
2486 | 435 | vdp_surface = VDP_INVALID_HANDLE; | ||
2487 | 436 | |||
2488 | 437 | object_mixer_p obj_mixer; | ||
2489 | 438 | obj_mixer = video_mixer_create_cached(driver_data, obj_surface); | ||
2490 | 439 | if (!obj_mixer) { | ||
2491 | 440 | va_status = VA_STATUS_ERROR_ALLOCATION_FAILED; | ||
2492 | 441 | break; | ||
2493 | 442 | } | ||
2494 | 443 | obj_surface->video_mixer = obj_mixer; | ||
2495 | 444 | } | ||
2496 | 445 | |||
2497 | 446 | /* Error recovery */ | ||
2498 | 447 | if (va_status != VA_STATUS_SUCCESS) { | ||
2499 | 448 | if (vdp_surface != VDP_INVALID_HANDLE) | ||
2500 | 449 | vdpau_video_surface_destroy(driver_data, vdp_surface); | ||
2501 | 450 | vdpau_DestroySurfaces(ctx, surfaces, i); | ||
2502 | 451 | } | ||
2503 | 452 | return va_status; | ||
2504 | 453 | } | ||
2505 | 454 | |||
2506 | 455 | // vaDestroyContext | ||
2507 | 456 | VAStatus vdpau_DestroyContext(VADriverContextP ctx, VAContextID context) | ||
2508 | 457 | { | ||
2509 | 458 | VDPAU_DRIVER_DATA_INIT; | ||
2510 | 459 | int i; | ||
2511 | 460 | |||
2512 | 461 | object_context_p obj_context = VDPAU_CONTEXT(context); | ||
2513 | 462 | if (!obj_context) | ||
2514 | 463 | return VA_STATUS_ERROR_INVALID_CONTEXT; | ||
2515 | 464 | |||
2516 | 465 | if (obj_context->gen_slice_data) { | ||
2517 | 466 | free(obj_context->gen_slice_data); | ||
2518 | 467 | obj_context->gen_slice_data = NULL; | ||
2519 | 468 | obj_context->gen_slice_data_size = 0; | ||
2520 | 469 | obj_context->gen_slice_data_size_max = 0; | ||
2521 | 470 | } | ||
2522 | 471 | |||
2523 | 472 | if (obj_context->vdp_bitstream_buffers) { | ||
2524 | 473 | free(obj_context->vdp_bitstream_buffers); | ||
2525 | 474 | obj_context->vdp_bitstream_buffers = NULL; | ||
2526 | 475 | obj_context->vdp_bitstream_buffers_count = 0; | ||
2527 | 476 | obj_context->vdp_bitstream_buffers_count_max = 0; | ||
2528 | 477 | } | ||
2529 | 478 | |||
2530 | 479 | if (obj_context->vdp_decoder != VDP_INVALID_HANDLE) { | ||
2531 | 480 | vdpau_decoder_destroy(driver_data, obj_context->vdp_decoder); | ||
2532 | 481 | obj_context->vdp_decoder = VDP_INVALID_HANDLE; | ||
2533 | 482 | } | ||
2534 | 483 | |||
2535 | 484 | if (obj_context->dead_buffers) { | ||
2536 | 485 | free(obj_context->dead_buffers); | ||
2537 | 486 | obj_context->dead_buffers = NULL; | ||
2538 | 487 | } | ||
2539 | 488 | |||
2540 | 489 | if (obj_context->render_targets) { | ||
2541 | 490 | for (i = 0; i < obj_context->num_render_targets; i++) { | ||
2542 | 491 | object_surface_p obj_surface; | ||
2543 | 492 | obj_surface = VDPAU_SURFACE(obj_context->render_targets[i]); | ||
2544 | 493 | if (obj_surface) | ||
2545 | 494 | obj_surface->va_context = VA_INVALID_ID; | ||
2546 | 495 | } | ||
2547 | 496 | free(obj_context->render_targets); | ||
2548 | 497 | obj_context->render_targets = NULL; | ||
2549 | 498 | } | ||
2550 | 499 | |||
2551 | 500 | obj_context->context_id = VA_INVALID_ID; | ||
2552 | 501 | obj_context->config_id = VA_INVALID_ID; | ||
2553 | 502 | obj_context->current_render_target = VA_INVALID_SURFACE; | ||
2554 | 503 | obj_context->picture_width = 0; | ||
2555 | 504 | obj_context->picture_height = 0; | ||
2556 | 505 | obj_context->num_render_targets = 0; | ||
2557 | 506 | obj_context->flags = 0; | ||
2558 | 507 | obj_context->dead_buffers_count = 0; | ||
2559 | 508 | obj_context->dead_buffers_count_max = 0; | ||
2560 | 509 | |||
2561 | 510 | object_heap_free(&driver_data->context_heap, (object_base_p)obj_context); | ||
2562 | 511 | return VA_STATUS_SUCCESS; | ||
2563 | 512 | } | ||
2564 | 513 | |||
2565 | 514 | // vaCreateContext | ||
2566 | 515 | VAStatus | ||
2567 | 516 | vdpau_CreateContext( | ||
2568 | 517 | VADriverContextP ctx, | ||
2569 | 518 | VAConfigID config_id, | ||
2570 | 519 | int picture_width, | ||
2571 | 520 | int picture_height, | ||
2572 | 521 | int flag, | ||
2573 | 522 | VASurfaceID *render_targets, | ||
2574 | 523 | int num_render_targets, | ||
2575 | 524 | VAContextID *context | ||
2576 | 525 | ) | ||
2577 | 526 | { | ||
2578 | 527 | VDPAU_DRIVER_DATA_INIT; | ||
2579 | 528 | |||
2580 | 529 | if (context) | ||
2581 | 530 | *context = VA_INVALID_ID; | ||
2582 | 531 | |||
2583 | 532 | object_config_p obj_config; | ||
2584 | 533 | if ((obj_config = VDPAU_CONFIG(config_id)) == NULL) | ||
2585 | 534 | return VA_STATUS_ERROR_INVALID_CONFIG; | ||
2586 | 535 | |||
2587 | 536 | /* XXX: validate flag */ | ||
2588 | 537 | |||
2589 | 538 | VdpDecoderProfile vdp_profile; | ||
2590 | 539 | uint32_t max_width, max_height; | ||
2591 | 540 | int i; | ||
2592 | 541 | vdp_profile = get_VdpDecoderProfile(obj_config->profile); | ||
2593 | 542 | if (!get_max_surface_size(driver_data, vdp_profile, &max_width, &max_height)) | ||
2594 | 543 | return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; | ||
2595 | 544 | if (picture_width > max_width || picture_height > max_height) | ||
2596 | 545 | return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; | ||
2597 | 546 | |||
2598 | 547 | VAContextID context_id = object_heap_allocate(&driver_data->context_heap); | ||
2599 | 548 | if (context_id == VA_INVALID_ID) | ||
2600 | 549 | return VA_STATUS_ERROR_ALLOCATION_FAILED; | ||
2601 | 550 | |||
2602 | 551 | object_context_p obj_context = VDPAU_CONTEXT(context_id); | ||
2603 | 552 | if (!obj_context) | ||
2604 | 553 | return VA_STATUS_ERROR_ALLOCATION_FAILED; | ||
2605 | 554 | if (context) | ||
2606 | 555 | *context = context_id; | ||
2607 | 556 | |||
2608 | 557 | obj_context->context_id = context_id; | ||
2609 | 558 | obj_context->config_id = config_id; | ||
2610 | 559 | obj_context->current_render_target = VA_INVALID_SURFACE; | ||
2611 | 560 | obj_context->picture_width = picture_width; | ||
2612 | 561 | obj_context->picture_height = picture_height; | ||
2613 | 562 | obj_context->num_render_targets = num_render_targets; | ||
2614 | 563 | obj_context->flags = flag; | ||
2615 | 564 | obj_context->max_ref_frames = -1; | ||
2616 | 565 | obj_context->render_targets = (VASurfaceID *) | ||
2617 | 566 | calloc(num_render_targets, sizeof(VASurfaceID)); | ||
2618 | 567 | obj_context->dead_buffers = NULL; | ||
2619 | 568 | obj_context->dead_buffers_count = 0; | ||
2620 | 569 | obj_context->dead_buffers_count_max = 0; | ||
2621 | 570 | obj_context->vdp_codec = get_VdpCodec(vdp_profile); | ||
2622 | 571 | obj_context->vdp_profile = vdp_profile; | ||
2623 | 572 | obj_context->vdp_decoder = VDP_INVALID_HANDLE; | ||
2624 | 573 | obj_context->gen_slice_data = NULL; | ||
2625 | 574 | obj_context->gen_slice_data_size = 0; | ||
2626 | 575 | obj_context->gen_slice_data_size_max = 0; | ||
2627 | 576 | obj_context->vdp_bitstream_buffers = NULL; | ||
2628 | 577 | obj_context->vdp_bitstream_buffers_count = 0; | ||
2629 | 578 | obj_context->vdp_bitstream_buffers_count_max = 0; | ||
2630 | 579 | |||
2631 | 580 | if (!obj_context->render_targets) { | ||
2632 | 581 | vdpau_DestroyContext(ctx, context_id); | ||
2633 | 582 | return VA_STATUS_ERROR_ALLOCATION_FAILED; | ||
2634 | 583 | } | ||
2635 | 584 | |||
2636 | 585 | for (i = 0; i < num_render_targets; i++) { | ||
2637 | 586 | object_surface_t *obj_surface; | ||
2638 | 587 | if ((obj_surface = VDPAU_SURFACE(render_targets[i])) == NULL) { | ||
2639 | 588 | vdpau_DestroyContext(ctx, context_id); | ||
2640 | 589 | return VA_STATUS_ERROR_INVALID_SURFACE; | ||
2641 | 590 | } | ||
2642 | 591 | obj_context->render_targets[i] = render_targets[i]; | ||
2643 | 592 | /* XXX: assume we can only associate a surface to a single context */ | ||
2644 | 593 | ASSERT(obj_surface->va_context == VA_INVALID_ID); | ||
2645 | 594 | obj_surface->va_context = context_id; | ||
2646 | 595 | } | ||
2647 | 596 | return VA_STATUS_SUCCESS; | ||
2648 | 597 | } | ||
2649 | 598 | |||
2650 | 599 | // Query surface status | ||
2651 | 600 | VAStatus | ||
2652 | 601 | query_surface_status( | ||
2653 | 602 | vdpau_driver_data_t *driver_data, | ||
2654 | 603 | object_surface_p obj_surface, | ||
2655 | 604 | VASurfaceStatus *status | ||
2656 | 605 | ) | ||
2657 | 606 | { | ||
2658 | 607 | VAStatus va_status = VA_STATUS_SUCCESS; | ||
2659 | 608 | |||
2660 | 609 | if (obj_surface->va_surface_status == VASurfaceDisplaying) { | ||
2661 | 610 | unsigned int i, num_output_surfaces_displaying = 0; | ||
2662 | 611 | for (i = 0; i < obj_surface->output_surfaces_count; i++) { | ||
2663 | 612 | object_output_p obj_output = obj_surface->output_surfaces[i]; | ||
2664 | 613 | if (!obj_output) | ||
2665 | 614 | return VA_STATUS_ERROR_INVALID_SURFACE; | ||
2666 | 615 | |||
2667 | 616 | VdpOutputSurface vdp_output_surface; | ||
2668 | 617 | vdp_output_surface = obj_output->vdp_output_surfaces[obj_output->displayed_output_surface]; | ||
2669 | 618 | if (vdp_output_surface == VDP_INVALID_HANDLE) | ||
2670 | 619 | continue; | ||
2671 | 620 | |||
2672 | 621 | VdpPresentationQueueStatus vdp_queue_status; | ||
2673 | 622 | VdpTime vdp_dummy_time; | ||
2674 | 623 | VdpStatus vdp_status; | ||
2675 | 624 | vdp_status = vdpau_presentation_queue_query_surface_status( | ||
2676 | 625 | driver_data, | ||
2677 | 626 | obj_output->vdp_flip_queue, | ||
2678 | 627 | vdp_output_surface, | ||
2679 | 628 | &vdp_queue_status, | ||
2680 | 629 | &vdp_dummy_time | ||
2681 | 630 | ); | ||
2682 | 631 | va_status = vdpau_get_VAStatus(vdp_status); | ||
2683 | 632 | |||
2684 | 633 | if (vdp_queue_status != VDP_PRESENTATION_QUEUE_STATUS_VISIBLE) | ||
2685 | 634 | ++num_output_surfaces_displaying; | ||
2686 | 635 | } | ||
2687 | 636 | |||
2688 | 637 | if (num_output_surfaces_displaying == 0) | ||
2689 | 638 | obj_surface->va_surface_status = VASurfaceReady; | ||
2690 | 639 | } | ||
2691 | 640 | |||
2692 | 641 | if (status) | ||
2693 | 642 | *status = obj_surface->va_surface_status; | ||
2694 | 643 | |||
2695 | 644 | return va_status; | ||
2696 | 645 | } | ||
2697 | 646 | |||
2698 | 647 | // vaQuerySurfaceStatus | ||
2699 | 648 | VAStatus | ||
2700 | 649 | vdpau_QuerySurfaceStatus( | ||
2701 | 650 | VADriverContextP ctx, | ||
2702 | 651 | VASurfaceID render_target, | ||
2703 | 652 | VASurfaceStatus *status | ||
2704 | 653 | ) | ||
2705 | 654 | { | ||
2706 | 655 | VDPAU_DRIVER_DATA_INIT; | ||
2707 | 656 | |||
2708 | 657 | object_surface_p obj_surface = VDPAU_SURFACE(render_target); | ||
2709 | 658 | if (!obj_surface) | ||
2710 | 659 | return VA_STATUS_ERROR_INVALID_SURFACE; | ||
2711 | 660 | |||
2712 | 661 | return query_surface_status(driver_data, obj_surface, status); | ||
2713 | 662 | } | ||
2714 | 663 | |||
2715 | 664 | // Wait for the surface to complete pending operations | ||
2716 | 665 | VAStatus | ||
2717 | 666 | sync_surface( | ||
2718 | 667 | vdpau_driver_data_t *driver_data, | ||
2719 | 668 | object_surface_p obj_surface | ||
2720 | 669 | ) | ||
2721 | 670 | { | ||
2722 | 671 | /* VDPAU only supports status interface for in-progress display */ | ||
2723 | 672 | /* XXX: polling is bad but there currently is no alternative */ | ||
2724 | 673 | for (;;) { | ||
2725 | 674 | VASurfaceStatus va_surface_status; | ||
2726 | 675 | VAStatus va_status; | ||
2727 | 676 | |||
2728 | 677 | va_status = query_surface_status( | ||
2729 | 678 | driver_data, | ||
2730 | 679 | obj_surface, | ||
2731 | 680 | &va_surface_status | ||
2732 | 681 | ); | ||
2733 | 682 | if (va_status != VA_STATUS_SUCCESS) | ||
2734 | 683 | return va_status; | ||
2735 | 684 | |||
2736 | 685 | if (va_surface_status != VASurfaceDisplaying) | ||
2737 | 686 | break; | ||
2738 | 687 | delay_usec(VDPAU_SYNC_DELAY); | ||
2739 | 688 | } | ||
2740 | 689 | return VA_STATUS_SUCCESS; | ||
2741 | 690 | } | ||
2742 | 691 | |||
2743 | 692 | // vaSyncSurface | ||
2744 | 693 | VAStatus | ||
2745 | 694 | vdpau_SyncSurface2( | ||
2746 | 695 | VADriverContextP ctx, | ||
2747 | 696 | VASurfaceID render_target | ||
2748 | 697 | ) | ||
2749 | 698 | { | ||
2750 | 699 | VDPAU_DRIVER_DATA_INIT; | ||
2751 | 700 | |||
2752 | 701 | object_surface_p obj_surface = VDPAU_SURFACE(render_target); | ||
2753 | 702 | if (!obj_surface) | ||
2754 | 703 | return VA_STATUS_ERROR_INVALID_SURFACE; | ||
2755 | 704 | |||
2756 | 705 | /* Assume that this shouldn't be called before vaEndPicture() */ | ||
2757 | 706 | object_context_p obj_context = VDPAU_CONTEXT(obj_surface->va_context); | ||
2758 | 707 | if (obj_context) { | ||
2759 | 708 | ASSERT(obj_context->current_render_target != obj_surface->base.id); | ||
2760 | 709 | if (obj_context->current_render_target == obj_surface->base.id) | ||
2761 | 710 | return VA_STATUS_ERROR_INVALID_CONTEXT; | ||
2762 | 711 | } | ||
2763 | 712 | |||
2764 | 713 | return sync_surface(driver_data, obj_surface); | ||
2765 | 714 | } | ||
2766 | 715 | |||
2767 | 716 | VAStatus | ||
2768 | 717 | vdpau_SyncSurface3( | ||
2769 | 718 | VADriverContextP ctx, | ||
2770 | 719 | VAContextID context, | ||
2771 | 720 | VASurfaceID render_target | ||
2772 | 721 | ) | ||
2773 | 722 | { | ||
2774 | 723 | VDPAU_DRIVER_DATA_INIT; | ||
2775 | 724 | |||
2776 | 725 | object_surface_p obj_surface = VDPAU_SURFACE(render_target); | ||
2777 | 726 | if (!obj_surface) | ||
2778 | 727 | return VA_STATUS_ERROR_INVALID_SURFACE; | ||
2779 | 728 | |||
2780 | 729 | /* Assume that this shouldn't be called before vaEndPicture() */ | ||
2781 | 730 | object_context_p obj_context = VDPAU_CONTEXT(context); | ||
2782 | 731 | if (obj_context) { | ||
2783 | 732 | ASSERT(obj_context->current_render_target != obj_surface->base.id); | ||
2784 | 733 | if (obj_context->current_render_target == obj_surface->base.id) | ||
2785 | 734 | return VA_STATUS_ERROR_INVALID_CONTEXT; | ||
2786 | 735 | } | ||
2787 | 736 | return sync_surface(driver_data, obj_surface); | ||
2788 | 737 | } | ||
2789 | 738 | |||
2790 | 739 | // Ensure VA Display Attributes are initialized | ||
2791 | 740 | static int ensure_display_attributes(vdpau_driver_data_t *driver_data) | ||
2792 | 741 | { | ||
2793 | 742 | VADisplayAttribute *attr; | ||
2794 | 743 | |||
2795 | 744 | if (driver_data->va_display_attrs_count > 0) | ||
2796 | 745 | return 0; | ||
2797 | 746 | |||
2798 | 747 | memset(driver_data->va_display_attrs_mtime, 0, sizeof(driver_data->va_display_attrs_mtime)); | ||
2799 | 748 | |||
2800 | 749 | attr = &driver_data->va_display_attrs[0]; | ||
2801 | 750 | |||
2802 | 751 | attr->type = VADisplayAttribDirectSurface; | ||
2803 | 752 | attr->value = 0; /* VdpVideoSurface is copied into VdpOutputSurface */ | ||
2804 | 753 | attr->min_value = attr->value; | ||
2805 | 754 | attr->max_value = attr->value; | ||
2806 | 755 | attr->flags = VA_DISPLAY_ATTRIB_GETTABLE; | ||
2807 | 756 | attr++; | ||
2808 | 757 | |||
2809 | 758 | attr->type = VADisplayAttribBrightness; | ||
2810 | 759 | attr->value = 0; | ||
2811 | 760 | attr->min_value = -100; | ||
2812 | 761 | attr->max_value = 100; | ||
2813 | 762 | attr->flags = VA_DISPLAY_ATTRIB_GETTABLE|VA_DISPLAY_ATTRIB_SETTABLE; | ||
2814 | 763 | attr++; | ||
2815 | 764 | |||
2816 | 765 | attr->type = VADisplayAttribContrast; | ||
2817 | 766 | attr->value = 0; | ||
2818 | 767 | attr->min_value = -100; | ||
2819 | 768 | attr->max_value = 100; | ||
2820 | 769 | attr->flags = VA_DISPLAY_ATTRIB_GETTABLE|VA_DISPLAY_ATTRIB_SETTABLE; | ||
2821 | 770 | attr++; | ||
2822 | 771 | |||
2823 | 772 | attr->type = VADisplayAttribHue; | ||
2824 | 773 | attr->value = 0; | ||
2825 | 774 | attr->min_value = -100; | ||
2826 | 775 | attr->max_value = 100; | ||
2827 | 776 | attr->flags = VA_DISPLAY_ATTRIB_GETTABLE|VA_DISPLAY_ATTRIB_SETTABLE; | ||
2828 | 777 | attr++; | ||
2829 | 778 | |||
2830 | 779 | attr->type = VADisplayAttribSaturation; | ||
2831 | 780 | attr->value = 0; | ||
2832 | 781 | attr->min_value = -100; | ||
2833 | 782 | attr->max_value = 100; | ||
2834 | 783 | attr->flags = VA_DISPLAY_ATTRIB_GETTABLE|VA_DISPLAY_ATTRIB_SETTABLE; | ||
2835 | 784 | attr++; | ||
2836 | 785 | |||
2837 | 786 | attr->type = VADisplayAttribBackgroundColor; | ||
2838 | 787 | attr->value = 0; | ||
2839 | 788 | attr->min_value = 0; | ||
2840 | 789 | attr->max_value = 0xffffff; | ||
2841 | 790 | attr->flags = VA_DISPLAY_ATTRIB_GETTABLE|VA_DISPLAY_ATTRIB_SETTABLE; | ||
2842 | 791 | attr++; | ||
2843 | 792 | |||
2844 | 793 | driver_data->va_display_attrs_count = attr - driver_data->va_display_attrs; | ||
2845 | 794 | ASSERT(driver_data->va_display_attrs_count <= VDPAU_MAX_DISPLAY_ATTRIBUTES); | ||
2846 | 795 | return 0; | ||
2847 | 796 | } | ||
2848 | 797 | |||
2849 | 798 | // Look up for the specified VA display attribute | ||
2850 | 799 | static VADisplayAttribute * | ||
2851 | 800 | get_display_attribute( | ||
2852 | 801 | vdpau_driver_data_t *driver_data, | ||
2853 | 802 | VADisplayAttribType type | ||
2854 | 803 | ) | ||
2855 | 804 | { | ||
2856 | 805 | if (ensure_display_attributes(driver_data) < 0) | ||
2857 | 806 | return NULL; | ||
2858 | 807 | |||
2859 | 808 | unsigned int i; | ||
2860 | 809 | for (i = 0; i < driver_data->va_display_attrs_count; i++) { | ||
2861 | 810 | if (driver_data->va_display_attrs[i].type == type) | ||
2862 | 811 | return &driver_data->va_display_attrs[i]; | ||
2863 | 812 | } | ||
2864 | 813 | return NULL; | ||
2865 | 814 | } | ||
2866 | 815 | |||
2867 | 816 | // vaQueryDisplayAttributes | ||
2868 | 817 | VAStatus | ||
2869 | 818 | vdpau_QueryDisplayAttributes( | ||
2870 | 819 | VADriverContextP ctx, | ||
2871 | 820 | VADisplayAttribute *attr_list, | ||
2872 | 821 | int *num_attributes | ||
2873 | 822 | ) | ||
2874 | 823 | { | ||
2875 | 824 | VDPAU_DRIVER_DATA_INIT; | ||
2876 | 825 | |||
2877 | 826 | if (ensure_display_attributes(driver_data) < 0) | ||
2878 | 827 | return VA_STATUS_ERROR_OPERATION_FAILED; | ||
2879 | 828 | |||
2880 | 829 | if (attr_list) | ||
2881 | 830 | memcpy(attr_list, driver_data->va_display_attrs, | ||
2882 | 831 | driver_data->va_display_attrs_count * sizeof(attr_list[0])); | ||
2883 | 832 | |||
2884 | 833 | if (num_attributes) | ||
2885 | 834 | *num_attributes = driver_data->va_display_attrs_count; | ||
2886 | 835 | |||
2887 | 836 | return VA_STATUS_SUCCESS; | ||
2888 | 837 | } | ||
2889 | 838 | |||
2890 | 839 | // vaGetDisplayAttributes | ||
2891 | 840 | VAStatus | ||
2892 | 841 | vdpau_GetDisplayAttributes( | ||
2893 | 842 | VADriverContextP ctx, | ||
2894 | 843 | VADisplayAttribute *attr_list, | ||
2895 | 844 | int num_attributes | ||
2896 | 845 | ) | ||
2897 | 846 | { | ||
2898 | 847 | VDPAU_DRIVER_DATA_INIT; | ||
2899 | 848 | |||
2900 | 849 | unsigned int i; | ||
2901 | 850 | for (i = 0; i < num_attributes; i++) { | ||
2902 | 851 | VADisplayAttribute * const dst_attr = &attr_list[i]; | ||
2903 | 852 | VADisplayAttribute *src_attr; | ||
2904 | 853 | |||
2905 | 854 | src_attr = get_display_attribute(driver_data, dst_attr->type); | ||
2906 | 855 | if (src_attr && (src_attr->flags & VA_DISPLAY_ATTRIB_GETTABLE) != 0) { | ||
2907 | 856 | dst_attr->min_value = src_attr->min_value; | ||
2908 | 857 | dst_attr->max_value = src_attr->max_value; | ||
2909 | 858 | dst_attr->value = src_attr->value; | ||
2910 | 859 | } | ||
2911 | 860 | else | ||
2912 | 861 | dst_attr->flags &= ~VA_DISPLAY_ATTRIB_GETTABLE; | ||
2913 | 862 | } | ||
2914 | 863 | return VA_STATUS_SUCCESS; | ||
2915 | 864 | } | ||
2916 | 865 | |||
2917 | 866 | // vaSetDisplayAttributes | ||
2918 | 867 | VAStatus | ||
2919 | 868 | vdpau_SetDisplayAttributes( | ||
2920 | 869 | VADriverContextP ctx, | ||
2921 | 870 | VADisplayAttribute *attr_list, | ||
2922 | 871 | int num_attributes | ||
2923 | 872 | ) | ||
2924 | 873 | { | ||
2925 | 874 | VDPAU_DRIVER_DATA_INIT; | ||
2926 | 875 | |||
2927 | 876 | unsigned int i; | ||
2928 | 877 | for (i = 0; i < num_attributes; i++) { | ||
2929 | 878 | VADisplayAttribute * const src_attr = &attr_list[i]; | ||
2930 | 879 | VADisplayAttribute *dst_attr; | ||
2931 | 880 | |||
2932 | 881 | dst_attr = get_display_attribute(driver_data, src_attr->type); | ||
2933 | 882 | if (!dst_attr) | ||
2934 | 883 | return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED; | ||
2935 | 884 | |||
2936 | 885 | if ((dst_attr->flags & VA_DISPLAY_ATTRIB_SETTABLE) != 0) { | ||
2937 | 886 | dst_attr->value = src_attr->value; | ||
2938 | 887 | |||
2939 | 888 | static uint64_t mtime; | ||
2940 | 889 | const int display_attr_index = dst_attr - driver_data->va_display_attrs; | ||
2941 | 890 | ASSERT(display_attr_index < VDPAU_MAX_DISPLAY_ATTRIBUTES); | ||
2942 | 891 | driver_data->va_display_attrs_mtime[display_attr_index] = ++mtime; | ||
2943 | 892 | } | ||
2944 | 893 | } | ||
2945 | 894 | return VA_STATUS_SUCCESS; | ||
2946 | 895 | } | ||
2947 | 896 | |||
2948 | 897 | // vaDbgCopySurfaceToBuffer (not a PUBLIC interface) | ||
2949 | 898 | VAStatus | ||
2950 | 899 | vdpau_DbgCopySurfaceToBuffer( | ||
2951 | 900 | VADriverContextP ctx, | ||
2952 | 901 | VASurfaceID surface, | ||
2953 | 902 | void **buffer, | ||
2954 | 903 | unsigned int *stride | ||
2955 | 904 | ) | ||
2956 | 905 | { | ||
2957 | 906 | /* TODO */ | ||
2958 | 907 | return VA_STATUS_ERROR_UNKNOWN; | ||
2959 | 908 | } | ||
2960 | 909 | |||
2961 | 910 | #if VA_CHECK_VERSION(0,30,0) | ||
2962 | 911 | // vaCreateSurfaceFromCIFrame | ||
2963 | 912 | VAStatus | ||
2964 | 913 | vdpau_CreateSurfaceFromCIFrame( | ||
2965 | 914 | VADriverContextP ctx, | ||
2966 | 915 | unsigned long frame_id, | ||
2967 | 916 | VASurfaceID *surface | ||
2968 | 917 | ) | ||
2969 | 918 | { | ||
2970 | 919 | /* TODO */ | ||
2971 | 920 | return VA_STATUS_ERROR_UNKNOWN; | ||
2972 | 921 | } | ||
2973 | 922 | |||
2974 | 923 | // vaCreateSurfaceFromV4L2Buf | ||
2975 | 924 | VAStatus | ||
2976 | 925 | vdpau_CreateSurfaceFromV4L2Buf( | ||
2977 | 926 | VADriverContextP ctx, | ||
2978 | 927 | int v4l2_fd, | ||
2979 | 928 | struct v4l2_format *v4l2_fmt, | ||
2980 | 929 | struct v4l2_buffer *v4l2_buf, | ||
2981 | 930 | VASurfaceID *surface | ||
2982 | 931 | ) | ||
2983 | 932 | { | ||
2984 | 933 | /* TODO */ | ||
2985 | 934 | return VA_STATUS_ERROR_UNKNOWN; | ||
2986 | 935 | } | ||
2987 | 936 | |||
2988 | 937 | // vaCopySurfaceToBuffer | ||
2989 | 938 | VAStatus | ||
2990 | 939 | vdpau_CopySurfaceToBuffer( | ||
2991 | 940 | VADriverContextP ctx, | ||
2992 | 941 | VASurfaceID surface, | ||
2993 | 942 | unsigned int *fourcc, | ||
2994 | 943 | unsigned int *luma_stride, | ||
2995 | 944 | unsigned int *chroma_u_stride, | ||
2996 | 945 | unsigned int *chroma_v_stride, | ||
2997 | 946 | unsigned int *luma_offset, | ||
2998 | 947 | unsigned int *chroma_u_offset, | ||
2999 | 948 | unsigned int *chroma_v_offset, | ||
3000 | 949 | void **buffer | ||
3001 | 950 | ) | ||
3002 | 951 | { | ||
3003 | 952 | /* TODO */ | ||
3004 | 953 | return VA_STATUS_ERROR_UNKNOWN; | ||
3005 | 954 | } | ||
3006 | 955 | #endif | ||
3007 | 956 | |||
3008 | 957 | #if VA_CHECK_VERSION(0,31,1) | ||
3009 | 958 | // vaLockSurface | ||
3010 | 959 | VAStatus | ||
3011 | 960 | vdpau_LockSurface( | ||
3012 | 961 | VADriverContextP ctx, | ||
3013 | 962 | VASurfaceID surface, | ||
3014 | 963 | unsigned int *fourcc, | ||
3015 | 964 | unsigned int *luma_stride, | ||
3016 | 965 | unsigned int *chroma_u_stride, | ||
3017 | 966 | unsigned int *chroma_v_stride, | ||
3018 | 967 | unsigned int *luma_offset, | ||
3019 | 968 | unsigned int *chroma_u_offset, | ||
3020 | 969 | unsigned int *chroma_v_offset, | ||
3021 | 970 | unsigned int *buffer_name, | ||
3022 | 971 | void **buffer | ||
3023 | 972 | ) | ||
3024 | 973 | { | ||
3025 | 974 | if (fourcc) *fourcc = VA_FOURCC('N','V','1','2'); | ||
3026 | 975 | if (luma_stride) *luma_stride = 0; | ||
3027 | 976 | if (chroma_u_stride) *chroma_u_stride = 0; | ||
3028 | 977 | if (chroma_v_stride) *chroma_v_stride = 0; | ||
3029 | 978 | if (luma_offset) *luma_offset = 0; | ||
3030 | 979 | if (chroma_u_offset) *chroma_u_offset = 0; | ||
3031 | 980 | if (chroma_v_offset) *chroma_v_offset = 0; | ||
3032 | 981 | if (buffer_name) *buffer_name = 0; | ||
3033 | 982 | if (buffer) *buffer = NULL; | ||
3034 | 983 | return VA_STATUS_SUCCESS; | ||
3035 | 984 | } | ||
3036 | 985 | |||
3037 | 986 | // vaUnlockSurface | ||
3038 | 987 | VAStatus | ||
3039 | 988 | vdpau_UnlockSurface( | ||
3040 | 989 | VADriverContextP ctx, | ||
3041 | 990 | VASurfaceID surface | ||
3042 | 991 | ) | ||
3043 | 992 | { | ||
3044 | 993 | return VA_STATUS_SUCCESS; | ||
3045 | 994 | } | ||
3046 | 995 | #endif | ||
3047 | 0 | 996 | ||
3048 | === added directory '.pc/03_mark_destroyed_buffers_as_deleted.patch' | |||
3049 | === added directory '.pc/03_mark_destroyed_buffers_as_deleted.patch/src' | |||
3050 | === added file '.pc/03_mark_destroyed_buffers_as_deleted.patch/src/vdpau_decode.c' | |||
3051 | --- .pc/03_mark_destroyed_buffers_as_deleted.patch/src/vdpau_decode.c 1970-01-01 00:00:00 +0000 | |||
3052 | +++ .pc/03_mark_destroyed_buffers_as_deleted.patch/src/vdpau_decode.c 2014-05-06 21:31:51 +0000 | |||
3053 | @@ -0,0 +1,1264 @@ | |||
3054 | 1 | /* | ||
3055 | 2 | * vdpau_decode.c - VDPAU backend for VA-API (decoder) | ||
3056 | 3 | * | ||
3057 | 4 | * vdpau-video (C) 2009-2011 Splitted-Desktop Systems | ||
3058 | 5 | * | ||
3059 | 6 | * This program is free software; you can redistribute it and/or modify | ||
3060 | 7 | * it under the terms of the GNU General Public License as published by | ||
3061 | 8 | * the Free Software Foundation; either version 2 of the License, or | ||
3062 | 9 | * (at your option) any later version. | ||
3063 | 10 | * | ||
3064 | 11 | * This program is distributed in the hope that it will be useful, | ||
3065 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3066 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3067 | 14 | * GNU General Public License for more details. | ||
3068 | 15 | * | ||
3069 | 16 | * You should have received a copy of the GNU General Public License | ||
3070 | 17 | * along with this program; if not, write to the Free Software | ||
3071 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
3072 | 19 | */ | ||
3073 | 20 | |||
3074 | 21 | #include "sysdeps.h" | ||
3075 | 22 | #include "vdpau_decode.h" | ||
3076 | 23 | #include "vdpau_driver.h" | ||
3077 | 24 | #include "vdpau_buffer.h" | ||
3078 | 25 | #include "vdpau_video.h" | ||
3079 | 26 | #include "vdpau_dump.h" | ||
3080 | 27 | #include "utils.h" | ||
3081 | 28 | #include "put_bits.h" | ||
3082 | 29 | |||
3083 | 30 | #define DEBUG 1 | ||
3084 | 31 | #include "debug.h" | ||
3085 | 32 | |||
3086 | 33 | |||
3087 | 34 | // Translates VdpDecoderProfile to VdpCodec | ||
3088 | 35 | VdpCodec get_VdpCodec(VdpDecoderProfile profile) | ||
3089 | 36 | { | ||
3090 | 37 | switch (profile) { | ||
3091 | 38 | case VDP_DECODER_PROFILE_MPEG1: | ||
3092 | 39 | return VDP_CODEC_MPEG1; | ||
3093 | 40 | case VDP_DECODER_PROFILE_MPEG2_SIMPLE: | ||
3094 | 41 | case VDP_DECODER_PROFILE_MPEG2_MAIN: | ||
3095 | 42 | return VDP_CODEC_MPEG2; | ||
3096 | 43 | #if USE_VDPAU_MPEG4 | ||
3097 | 44 | case VDP_DECODER_PROFILE_MPEG4_PART2_SP: | ||
3098 | 45 | case VDP_DECODER_PROFILE_MPEG4_PART2_ASP: | ||
3099 | 46 | case VDP_DECODER_PROFILE_DIVX4_QMOBILE: | ||
3100 | 47 | case VDP_DECODER_PROFILE_DIVX4_MOBILE: | ||
3101 | 48 | case VDP_DECODER_PROFILE_DIVX4_HOME_THEATER: | ||
3102 | 49 | case VDP_DECODER_PROFILE_DIVX4_HD_1080P: | ||
3103 | 50 | case VDP_DECODER_PROFILE_DIVX5_QMOBILE: | ||
3104 | 51 | case VDP_DECODER_PROFILE_DIVX5_MOBILE: | ||
3105 | 52 | case VDP_DECODER_PROFILE_DIVX5_HOME_THEATER: | ||
3106 | 53 | case VDP_DECODER_PROFILE_DIVX5_HD_1080P: | ||
3107 | 54 | return VDP_CODEC_MPEG4; | ||
3108 | 55 | #endif | ||
3109 | 56 | case VDP_DECODER_PROFILE_H264_BASELINE: | ||
3110 | 57 | case VDP_DECODER_PROFILE_H264_MAIN: | ||
3111 | 58 | case VDP_DECODER_PROFILE_H264_HIGH: | ||
3112 | 59 | return VDP_CODEC_H264; | ||
3113 | 60 | case VDP_DECODER_PROFILE_VC1_SIMPLE: | ||
3114 | 61 | case VDP_DECODER_PROFILE_VC1_MAIN: | ||
3115 | 62 | case VDP_DECODER_PROFILE_VC1_ADVANCED: | ||
3116 | 63 | return VDP_CODEC_VC1; | ||
3117 | 64 | } | ||
3118 | 65 | return 0; | ||
3119 | 66 | } | ||
3120 | 67 | |||
3121 | 68 | // Translates VAProfile to VdpDecoderProfile | ||
3122 | 69 | VdpDecoderProfile get_VdpDecoderProfile(VAProfile profile) | ||
3123 | 70 | { | ||
3124 | 71 | switch (profile) { | ||
3125 | 72 | case VAProfileMPEG2Simple: return VDP_DECODER_PROFILE_MPEG2_SIMPLE; | ||
3126 | 73 | case VAProfileMPEG2Main: return VDP_DECODER_PROFILE_MPEG2_MAIN; | ||
3127 | 74 | #if USE_VDPAU_MPEG4 | ||
3128 | 75 | case VAProfileMPEG4Simple: return VDP_DECODER_PROFILE_MPEG4_PART2_SP; | ||
3129 | 76 | case VAProfileMPEG4AdvancedSimple: return VDP_DECODER_PROFILE_MPEG4_PART2_ASP; | ||
3130 | 77 | #endif | ||
3131 | 78 | case VAProfileH264Baseline: return VDP_DECODER_PROFILE_H264_BASELINE; | ||
3132 | 79 | case VAProfileH264Main: return VDP_DECODER_PROFILE_H264_MAIN; | ||
3133 | 80 | case VAProfileH264High: return VDP_DECODER_PROFILE_H264_HIGH; | ||
3134 | 81 | case VAProfileVC1Simple: return VDP_DECODER_PROFILE_VC1_SIMPLE; | ||
3135 | 82 | case VAProfileVC1Main: return VDP_DECODER_PROFILE_VC1_MAIN; | ||
3136 | 83 | case VAProfileVC1Advanced: return VDP_DECODER_PROFILE_VC1_ADVANCED; | ||
3137 | 84 | default: break; | ||
3138 | 85 | } | ||
3139 | 86 | return (VdpDecoderProfile)-1; | ||
3140 | 87 | } | ||
3141 | 88 | |||
3142 | 89 | // Checks whether the VDPAU implementation supports the specified profile | ||
3143 | 90 | static inline VdpBool | ||
3144 | 91 | is_supported_profile( | ||
3145 | 92 | vdpau_driver_data_t *driver_data, | ||
3146 | 93 | VdpDecoderProfile profile | ||
3147 | 94 | ) | ||
3148 | 95 | { | ||
3149 | 96 | VdpBool is_supported = VDP_FALSE; | ||
3150 | 97 | VdpStatus vdp_status; | ||
3151 | 98 | uint32_t max_level, max_references, max_width, max_height; | ||
3152 | 99 | |||
3153 | 100 | if (profile == (VdpDecoderProfile)-1) | ||
3154 | 101 | return VDP_FALSE; | ||
3155 | 102 | |||
3156 | 103 | vdp_status = vdpau_decoder_query_capabilities( | ||
3157 | 104 | driver_data, | ||
3158 | 105 | driver_data->vdp_device, | ||
3159 | 106 | profile, | ||
3160 | 107 | &is_supported, | ||
3161 | 108 | &max_level, | ||
3162 | 109 | &max_references, | ||
3163 | 110 | &max_width, | ||
3164 | 111 | &max_height | ||
3165 | 112 | ); | ||
3166 | 113 | return (VDPAU_CHECK_STATUS(vdp_status, "VdpDecoderQueryCapabilities()") && | ||
3167 | 114 | is_supported); | ||
3168 | 115 | } | ||
3169 | 116 | |||
3170 | 117 | // Checks decoder for profile/entrypoint is available | ||
3171 | 118 | VAStatus | ||
3172 | 119 | check_decoder( | ||
3173 | 120 | vdpau_driver_data_t *driver_data, | ||
3174 | 121 | VAProfile profile, | ||
3175 | 122 | VAEntrypoint entrypoint | ||
3176 | 123 | ) | ||
3177 | 124 | { | ||
3178 | 125 | if (!is_supported_profile(driver_data, get_VdpDecoderProfile(profile))) | ||
3179 | 126 | return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; | ||
3180 | 127 | |||
3181 | 128 | /* VDPAU only supports VLD */ | ||
3182 | 129 | if (entrypoint != VAEntrypointVLD) | ||
3183 | 130 | return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; | ||
3184 | 131 | |||
3185 | 132 | return VA_STATUS_SUCCESS; | ||
3186 | 133 | } | ||
3187 | 134 | |||
3188 | 135 | // Computes value for VdpDecoderCreate()::max_references parameter | ||
3189 | 136 | static int | ||
3190 | 137 | get_max_ref_frames( | ||
3191 | 138 | VdpDecoderProfile profile, | ||
3192 | 139 | unsigned int width, | ||
3193 | 140 | unsigned int height | ||
3194 | 141 | ) | ||
3195 | 142 | { | ||
3196 | 143 | int max_ref_frames = 2; | ||
3197 | 144 | |||
3198 | 145 | switch (profile) { | ||
3199 | 146 | case VDP_DECODER_PROFILE_H264_MAIN: | ||
3200 | 147 | case VDP_DECODER_PROFILE_H264_HIGH: | ||
3201 | 148 | { | ||
3202 | 149 | /* level 4.1 limits */ | ||
3203 | 150 | unsigned int aligned_width = (width + 15) & -16; | ||
3204 | 151 | unsigned int aligned_height = (height + 15) & -16; | ||
3205 | 152 | unsigned int surface_size = (aligned_width * aligned_height * 3) / 2; | ||
3206 | 153 | if ((max_ref_frames = (12 * 1024 * 1024) / surface_size) > 16) | ||
3207 | 154 | max_ref_frames = 16; | ||
3208 | 155 | break; | ||
3209 | 156 | } | ||
3210 | 157 | } | ||
3211 | 158 | return max_ref_frames; | ||
3212 | 159 | } | ||
3213 | 160 | |||
3214 | 161 | // Returns the maximum number of reference frames of a decode session | ||
3215 | 162 | static inline int get_num_ref_frames(object_context_p obj_context) | ||
3216 | 163 | { | ||
3217 | 164 | if (obj_context->vdp_codec == VDP_CODEC_H264) | ||
3218 | 165 | return obj_context->vdp_picture_info.h264.num_ref_frames; | ||
3219 | 166 | return 2; | ||
3220 | 167 | } | ||
3221 | 168 | |||
3222 | 169 | // Ensure VDPAU decoder is created for the specified number of reference frames | ||
3223 | 170 | static VdpStatus | ||
3224 | 171 | ensure_decoder_with_max_refs( | ||
3225 | 172 | vdpau_driver_data_t *driver_data, | ||
3226 | 173 | object_context_p obj_context, | ||
3227 | 174 | int max_ref_frames | ||
3228 | 175 | ) | ||
3229 | 176 | { | ||
3230 | 177 | VdpStatus vdp_status; | ||
3231 | 178 | |||
3232 | 179 | if (max_ref_frames < 0) | ||
3233 | 180 | max_ref_frames = | ||
3234 | 181 | get_max_ref_frames(obj_context->vdp_profile, | ||
3235 | 182 | obj_context->picture_width, | ||
3236 | 183 | obj_context->picture_height); | ||
3237 | 184 | |||
3238 | 185 | if (obj_context->vdp_decoder == VDP_INVALID_HANDLE || | ||
3239 | 186 | obj_context->max_ref_frames < max_ref_frames) { | ||
3240 | 187 | obj_context->max_ref_frames = max_ref_frames; | ||
3241 | 188 | |||
3242 | 189 | if (obj_context->vdp_decoder != VDP_INVALID_HANDLE) { | ||
3243 | 190 | vdpau_decoder_destroy(driver_data, obj_context->vdp_decoder); | ||
3244 | 191 | obj_context->vdp_decoder = VDP_INVALID_HANDLE; | ||
3245 | 192 | } | ||
3246 | 193 | |||
3247 | 194 | vdp_status = vdpau_decoder_create( | ||
3248 | 195 | driver_data, | ||
3249 | 196 | driver_data->vdp_device, | ||
3250 | 197 | obj_context->vdp_profile, | ||
3251 | 198 | obj_context->picture_width, | ||
3252 | 199 | obj_context->picture_height, | ||
3253 | 200 | max_ref_frames, | ||
3254 | 201 | &obj_context->vdp_decoder | ||
3255 | 202 | ); | ||
3256 | 203 | if (!VDPAU_CHECK_STATUS(vdp_status, "VdpDecoderCreate()")) | ||
3257 | 204 | return vdp_status; | ||
3258 | 205 | } | ||
3259 | 206 | return VDP_STATUS_OK; | ||
3260 | 207 | } | ||
3261 | 208 | |||
3262 | 209 | // Lazy allocate (generated) slice data buffer. Buffer lives until vaDestroyContext() | ||
3263 | 210 | static uint8_t * | ||
3264 | 211 | alloc_gen_slice_data(object_context_p obj_context, unsigned int size) | ||
3265 | 212 | { | ||
3266 | 213 | uint8_t *gen_slice_data = obj_context->gen_slice_data; | ||
3267 | 214 | |||
3268 | 215 | if (obj_context->gen_slice_data_size + size > obj_context->gen_slice_data_size_max) { | ||
3269 | 216 | obj_context->gen_slice_data_size_max += size; | ||
3270 | 217 | gen_slice_data = realloc(obj_context->gen_slice_data, | ||
3271 | 218 | obj_context->gen_slice_data_size_max); | ||
3272 | 219 | if (!gen_slice_data) | ||
3273 | 220 | return NULL; | ||
3274 | 221 | obj_context->gen_slice_data = gen_slice_data; | ||
3275 | 222 | } | ||
3276 | 223 | gen_slice_data += obj_context->gen_slice_data_size; | ||
3277 | 224 | obj_context->gen_slice_data_size += size; | ||
3278 | 225 | return gen_slice_data; | ||
3279 | 226 | } | ||
3280 | 227 | |||
3281 | 228 | // Lazy allocate VdpBitstreamBuffer. Buffer lives until vaDestroyContext() | ||
3282 | 229 | static VdpBitstreamBuffer * | ||
3283 | 230 | alloc_VdpBitstreamBuffer(object_context_p obj_context) | ||
3284 | 231 | { | ||
3285 | 232 | VdpBitstreamBuffer *vdp_bitstream_buffers; | ||
3286 | 233 | |||
3287 | 234 | vdp_bitstream_buffers = realloc_buffer( | ||
3288 | 235 | &obj_context->vdp_bitstream_buffers, | ||
3289 | 236 | &obj_context->vdp_bitstream_buffers_count_max, | ||
3290 | 237 | 1 + obj_context->vdp_bitstream_buffers_count, | ||
3291 | 238 | sizeof(*obj_context->vdp_bitstream_buffers) | ||
3292 | 239 | ); | ||
3293 | 240 | if (!vdp_bitstream_buffers) | ||
3294 | 241 | return NULL; | ||
3295 | 242 | |||
3296 | 243 | return &vdp_bitstream_buffers[obj_context->vdp_bitstream_buffers_count++]; | ||
3297 | 244 | } | ||
3298 | 245 | |||
3299 | 246 | // Append VASliceDataBuffer hunk into VDPAU buffer | ||
3300 | 247 | static int | ||
3301 | 248 | append_VdpBitstreamBuffer( | ||
3302 | 249 | object_context_p obj_context, | ||
3303 | 250 | const uint8_t *buffer, | ||
3304 | 251 | uint32_t buffer_size | ||
3305 | 252 | ) | ||
3306 | 253 | { | ||
3307 | 254 | VdpBitstreamBuffer *bitstream_buffer; | ||
3308 | 255 | |||
3309 | 256 | bitstream_buffer = alloc_VdpBitstreamBuffer(obj_context); | ||
3310 | 257 | if (!bitstream_buffer) | ||
3311 | 258 | return -1; | ||
3312 | 259 | |||
3313 | 260 | bitstream_buffer->struct_version = VDP_BITSTREAM_BUFFER_VERSION; | ||
3314 | 261 | bitstream_buffer->bitstream = buffer; | ||
3315 | 262 | bitstream_buffer->bitstream_bytes = buffer_size; | ||
3316 | 263 | return 0; | ||
3317 | 264 | } | ||
3318 | 265 | |||
3319 | 266 | // Initialize VdpReferenceFrameH264 to default values | ||
3320 | 267 | static void init_VdpReferenceFrameH264(VdpReferenceFrameH264 *rf) | ||
3321 | 268 | { | ||
3322 | 269 | rf->surface = VDP_INVALID_HANDLE; | ||
3323 | 270 | rf->is_long_term = VDP_FALSE; | ||
3324 | 271 | rf->top_is_reference = VDP_FALSE; | ||
3325 | 272 | rf->bottom_is_reference = VDP_FALSE; | ||
3326 | 273 | rf->field_order_cnt[0] = 0; | ||
3327 | 274 | rf->field_order_cnt[1] = 0; | ||
3328 | 275 | rf->frame_idx = 0; | ||
3329 | 276 | } | ||
3330 | 277 | |||
3331 | 278 | static const uint8_t ff_identity[64] = { | ||
3332 | 279 | 0, 1, 2, 3, 4, 5, 6, 7, | ||
3333 | 280 | 8, 9, 10, 11, 12, 13, 14, 15, | ||
3334 | 281 | 16, 17, 18, 19, 20, 21, 22, 23, | ||
3335 | 282 | 24, 25, 26, 27, 28, 29, 30, 31, | ||
3336 | 283 | 32, 33, 34, 35, 36, 37, 38, 39, | ||
3337 | 284 | 40, 41, 42, 43, 44, 45, 46, 47, | ||
3338 | 285 | 48, 49, 50, 51, 52, 53, 54, 55, | ||
3339 | 286 | 56, 57, 58, 59, 60, 61, 62, 63 | ||
3340 | 287 | }; | ||
3341 | 288 | |||
3342 | 289 | static const uint8_t ff_zigzag_direct[64] = { | ||
3343 | 290 | 0, 1, 8, 16, 9, 2, 3, 10, | ||
3344 | 291 | 17, 24, 32, 25, 18, 11, 4, 5, | ||
3345 | 292 | 12, 19, 26, 33, 40, 48, 41, 34, | ||
3346 | 293 | 27, 20, 13, 6, 7, 14, 21, 28, | ||
3347 | 294 | 35, 42, 49, 56, 57, 50, 43, 36, | ||
3348 | 295 | 29, 22, 15, 23, 30, 37, 44, 51, | ||
3349 | 296 | 58, 59, 52, 45, 38, 31, 39, 46, | ||
3350 | 297 | 53, 60, 61, 54, 47, 55, 62, 63 | ||
3351 | 298 | }; | ||
3352 | 299 | |||
3353 | 300 | static const uint8_t ff_mpeg1_default_intra_matrix[64] = { | ||
3354 | 301 | 8, 16, 19, 22, 26, 27, 29, 34, | ||
3355 | 302 | 16, 16, 22, 24, 27, 29, 34, 37, | ||
3356 | 303 | 19, 22, 26, 27, 29, 34, 34, 38, | ||
3357 | 304 | 22, 22, 26, 27, 29, 34, 37, 40, | ||
3358 | 305 | 22, 26, 27, 29, 32, 35, 40, 48, | ||
3359 | 306 | 26, 27, 29, 32, 35, 40, 48, 58, | ||
3360 | 307 | 26, 27, 29, 34, 38, 46, 56, 69, | ||
3361 | 308 | 27, 29, 35, 38, 46, 56, 69, 83 | ||
3362 | 309 | }; | ||
3363 | 310 | |||
3364 | 311 | static const uint8_t ff_mpeg1_default_non_intra_matrix[64] = { | ||
3365 | 312 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
3366 | 313 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
3367 | 314 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
3368 | 315 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
3369 | 316 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
3370 | 317 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
3371 | 318 | 16, 16, 16, 16, 16, 16, 16, 16, | ||
3372 | 319 | 16, 16, 16, 16, 16, 16, 16, 16 | ||
3373 | 320 | }; | ||
3374 | 321 | |||
3375 | 322 | static const uint8_t ff_mpeg4_default_intra_matrix[64] = { | ||
3376 | 323 | 8, 17, 18, 19, 21, 23, 25, 27, | ||
3377 | 324 | 17, 18, 19, 21, 23, 25, 27, 28, | ||
3378 | 325 | 20, 21, 22, 23, 24, 26, 28, 30, | ||
3379 | 326 | 21, 22, 23, 24, 26, 28, 30, 32, | ||
3380 | 327 | 22, 23, 24, 26, 28, 30, 32, 35, | ||
3381 | 328 | 23, 24, 26, 28, 30, 32, 35, 38, | ||
3382 | 329 | 25, 26, 28, 30, 32, 35, 38, 41, | ||
3383 | 330 | 27, 28, 30, 32, 35, 38, 41, 45, | ||
3384 | 331 | }; | ||
3385 | 332 | |||
3386 | 333 | static const uint8_t ff_mpeg4_default_non_intra_matrix[64] = { | ||
3387 | 334 | 16, 17, 18, 19, 20, 21, 22, 23, | ||
3388 | 335 | 17, 18, 19, 20, 21, 22, 23, 24, | ||
3389 | 336 | 18, 19, 20, 21, 22, 23, 24, 25, | ||
3390 | 337 | 19, 20, 21, 22, 23, 24, 26, 27, | ||
3391 | 338 | 20, 21, 22, 23, 25, 26, 27, 28, | ||
3392 | 339 | 21, 22, 23, 24, 26, 27, 28, 30, | ||
3393 | 340 | 22, 23, 24, 26, 27, 28, 30, 31, | ||
3394 | 341 | 23, 24, 25, 27, 28, 30, 31, 33, | ||
3395 | 342 | }; | ||
3396 | 343 | |||
3397 | 344 | // Compute integer log2 | ||
3398 | 345 | static inline int ilog2(uint32_t v) | ||
3399 | 346 | { | ||
3400 | 347 | /* From <http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog> */ | ||
3401 | 348 | uint32_t r, shift; | ||
3402 | 349 | r = (v > 0xffff) << 4; v >>= r; | ||
3403 | 350 | shift = (v > 0xff ) << 3; v >>= shift; r |= shift; | ||
3404 | 351 | shift = (v > 0xf ) << 2; v >>= shift; r |= shift; | ||
3405 | 352 | shift = (v > 0x3 ) << 1; v >>= shift; r |= shift; | ||
3406 | 353 | return r | (v >> 1); | ||
3407 | 354 | } | ||
3408 | 355 | |||
3409 | 356 | // Translate VASurfaceID | ||
3410 | 357 | static int | ||
3411 | 358 | translate_VASurfaceID( | ||
3412 | 359 | vdpau_driver_data_t *driver_data, | ||
3413 | 360 | VASurfaceID va_surface, | ||
3414 | 361 | VdpVideoSurface *vdp_surface | ||
3415 | 362 | ) | ||
3416 | 363 | { | ||
3417 | 364 | object_surface_p obj_surface; | ||
3418 | 365 | |||
3419 | 366 | if (va_surface == VA_INVALID_SURFACE) { | ||
3420 | 367 | *vdp_surface = VDP_INVALID_HANDLE; | ||
3421 | 368 | return 1; | ||
3422 | 369 | } | ||
3423 | 370 | |||
3424 | 371 | obj_surface = VDPAU_SURFACE(va_surface); | ||
3425 | 372 | if (!obj_surface) | ||
3426 | 373 | return 0; | ||
3427 | 374 | |||
3428 | 375 | *vdp_surface = obj_surface->vdp_surface; | ||
3429 | 376 | return 1; | ||
3430 | 377 | } | ||
3431 | 378 | |||
3432 | 379 | // Translate VAPictureH264 | ||
3433 | 380 | static int | ||
3434 | 381 | translate_VAPictureH264( | ||
3435 | 382 | vdpau_driver_data_t *driver_data, | ||
3436 | 383 | const VAPictureH264 *va_pic, | ||
3437 | 384 | VdpReferenceFrameH264 *rf | ||
3438 | 385 | ) | ||
3439 | 386 | { | ||
3440 | 387 | // Handle invalid surfaces specifically | ||
3441 | 388 | if (va_pic->picture_id == VA_INVALID_SURFACE) { | ||
3442 | 389 | init_VdpReferenceFrameH264(rf); | ||
3443 | 390 | return 1; | ||
3444 | 391 | } | ||
3445 | 392 | |||
3446 | 393 | if (!translate_VASurfaceID(driver_data, va_pic->picture_id, &rf->surface)) | ||
3447 | 394 | return 0; | ||
3448 | 395 | rf->is_long_term = (va_pic->flags & VA_PICTURE_H264_LONG_TERM_REFERENCE) != 0; | ||
3449 | 396 | if ((va_pic->flags & (VA_PICTURE_H264_TOP_FIELD|VA_PICTURE_H264_BOTTOM_FIELD)) == 0) { | ||
3450 | 397 | rf->top_is_reference = VDP_TRUE; | ||
3451 | 398 | rf->bottom_is_reference = VDP_TRUE; | ||
3452 | 399 | } | ||
3453 | 400 | else { | ||
3454 | 401 | rf->top_is_reference = (va_pic->flags & VA_PICTURE_H264_TOP_FIELD) != 0; | ||
3455 | 402 | rf->bottom_is_reference = (va_pic->flags & VA_PICTURE_H264_BOTTOM_FIELD) != 0; | ||
3456 | 403 | } | ||
3457 | 404 | rf->field_order_cnt[0] = va_pic->TopFieldOrderCnt; | ||
3458 | 405 | rf->field_order_cnt[1] = va_pic->BottomFieldOrderCnt; | ||
3459 | 406 | rf->frame_idx = va_pic->frame_idx; | ||
3460 | 407 | return 1; | ||
3461 | 408 | } | ||
3462 | 409 | |||
3463 | 410 | // Translate no buffer | ||
3464 | 411 | static int | ||
3465 | 412 | translate_nothing( | ||
3466 | 413 | vdpau_driver_data_t *driver_data, | ||
3467 | 414 | object_context_p obj_context, | ||
3468 | 415 | object_buffer_p obj_buffer | ||
3469 | 416 | ) | ||
3470 | 417 | { | ||
3471 | 418 | return 1; | ||
3472 | 419 | } | ||
3473 | 420 | |||
3474 | 421 | // Translate VASliceDataBuffer | ||
3475 | 422 | static int | ||
3476 | 423 | translate_VASliceDataBuffer( | ||
3477 | 424 | vdpau_driver_data_t *driver_data, | ||
3478 | 425 | object_context_p obj_context, | ||
3479 | 426 | object_buffer_p obj_buffer | ||
3480 | 427 | ) | ||
3481 | 428 | { | ||
3482 | 429 | if (obj_context->vdp_codec == VDP_CODEC_H264) { | ||
3483 | 430 | /* Check we have the start code */ | ||
3484 | 431 | /* XXX: check for other codecs too? */ | ||
3485 | 432 | /* XXX: this assumes we get SliceParams before SliceData */ | ||
3486 | 433 | static const uint8_t start_code_prefix[3] = { 0x00, 0x00, 0x01 }; | ||
3487 | 434 | VASliceParameterBufferH264 * const slice_params = obj_context->last_slice_params; | ||
3488 | 435 | unsigned int i; | ||
3489 | 436 | for (i = 0; i < obj_context->last_slice_params_count; i++) { | ||
3490 | 437 | VASliceParameterBufferH264 * const slice_param = &slice_params[i]; | ||
3491 | 438 | uint8_t *buf = (uint8_t *)obj_buffer->buffer_data + slice_param->slice_data_offset; | ||
3492 | 439 | if (memcmp(buf, start_code_prefix, sizeof(start_code_prefix)) != 0) { | ||
3493 | 440 | if (append_VdpBitstreamBuffer(obj_context, | ||
3494 | 441 | start_code_prefix, | ||
3495 | 442 | sizeof(start_code_prefix)) < 0) | ||
3496 | 443 | return 0; | ||
3497 | 444 | } | ||
3498 | 445 | if (append_VdpBitstreamBuffer(obj_context, | ||
3499 | 446 | buf, | ||
3500 | 447 | slice_param->slice_data_size) < 0) | ||
3501 | 448 | return 0; | ||
3502 | 449 | } | ||
3503 | 450 | return 1; | ||
3504 | 451 | } | ||
3505 | 452 | |||
3506 | 453 | #if USE_VDPAU_MPEG4 | ||
3507 | 454 | if (obj_context->vdp_codec == VDP_CODEC_MPEG4 && | ||
3508 | 455 | obj_context->vdp_bitstream_buffers_count == 0) { | ||
3509 | 456 | PutBitContext pb; | ||
3510 | 457 | uint8_t slice_header_buffer[32]; | ||
3511 | 458 | uint8_t *slice_header; | ||
3512 | 459 | int slice_header_size; | ||
3513 | 460 | const uint8_t *slice_data = obj_buffer->buffer_data; | ||
3514 | 461 | uint32_t slice_data_size = obj_buffer->buffer_size; | ||
3515 | 462 | VAPictureParameterBufferMPEG4 * const pic_param = obj_context->last_pic_param; | ||
3516 | 463 | VASliceParameterBufferMPEG4 * const slice_param = obj_context->last_slice_params; | ||
3517 | 464 | |||
3518 | 465 | int time_incr = 1 + ilog2(pic_param->vop_time_increment_resolution - 1); | ||
3519 | 466 | if (time_incr < 1) | ||
3520 | 467 | time_incr = 1; | ||
3521 | 468 | |||
3522 | 469 | static const uint16_t VOP_STARTCODE = 0x01b6; | ||
3523 | 470 | enum { | ||
3524 | 471 | VOP_I_TYPE = 0, | ||
3525 | 472 | VOP_P_TYPE, | ||
3526 | 473 | VOP_B_TYPE, | ||
3527 | 474 | VOP_S_TYPE | ||
3528 | 475 | }; | ||
3529 | 476 | |||
3530 | 477 | /* XXX: this is a hack to compute the length of | ||
3531 | 478 | modulo_time_base "1" sequence. We probably should be | ||
3532 | 479 | reconstructing through an extra VOP field in VA-API? */ | ||
3533 | 480 | int nbits = (32 + /* VOP start code */ | ||
3534 | 481 | 2 + /* vop_coding_type */ | ||
3535 | 482 | 1 + /* modulo_time_base "0" */ | ||
3536 | 483 | 1 + /* marker_bit */ | ||
3537 | 484 | time_incr + /* vop_time_increment */ | ||
3538 | 485 | 1 + /* marker_bit */ | ||
3539 | 486 | 1 + /* vop_coded */ | ||
3540 | 487 | (pic_param->vop_fields.bits.vop_coding_type == VOP_P_TYPE ? 1 : 0) + | ||
3541 | 488 | 3 + /* intra_dc_vlc_thr */ | ||
3542 | 489 | (pic_param->vol_fields.bits.interlaced ? 2 : 0) + | ||
3543 | 490 | 5 + /* vop_quant */ | ||
3544 | 491 | (pic_param->vop_fields.bits.vop_coding_type != VOP_I_TYPE ? 3 : 0) + | ||
3545 | 492 | (pic_param->vop_fields.bits.vop_coding_type == VOP_B_TYPE ? 3 : 0)); | ||
3546 | 493 | if ((nbits = slice_param->macroblock_offset - (nbits % 8)) < 0) | ||
3547 | 494 | nbits += 8; | ||
3548 | 495 | |||
3549 | 496 | /* Reconstruct the VOP header */ | ||
3550 | 497 | init_put_bits(&pb, slice_header_buffer, sizeof(slice_header_buffer)); | ||
3551 | 498 | put_bits(&pb, 16, 0); /* vop header */ | ||
3552 | 499 | put_bits(&pb, 16, VOP_STARTCODE); /* vop header */ | ||
3553 | 500 | put_bits(&pb, 2, pic_param->vop_fields.bits.vop_coding_type); | ||
3554 | 501 | while (nbits-- > 0) | ||
3555 | 502 | put_bits(&pb, 1, 1); /* modulo_time_base "1" */ | ||
3556 | 503 | put_bits(&pb, 1, 0); /* modulo_time_base "0" */ | ||
3557 | 504 | put_bits(&pb, 1, 1); /* marker */ | ||
3558 | 505 | put_bits(&pb, time_incr, 0); /* time increment */ | ||
3559 | 506 | put_bits(&pb, 1, 1); /* marker */ | ||
3560 | 507 | put_bits(&pb, 1, 1); /* vop coded */ | ||
3561 | 508 | if (pic_param->vop_fields.bits.vop_coding_type == VOP_P_TYPE) | ||
3562 | 509 | put_bits(&pb, 1, pic_param->vop_fields.bits.vop_rounding_type); | ||
3563 | 510 | put_bits(&pb, 3, pic_param->vop_fields.bits.intra_dc_vlc_thr); | ||
3564 | 511 | if (pic_param->vol_fields.bits.interlaced) { | ||
3565 | 512 | put_bits(&pb, 1, pic_param->vop_fields.bits.top_field_first); | ||
3566 | 513 | put_bits(&pb, 1, pic_param->vop_fields.bits.alternate_vertical_scan_flag); | ||
3567 | 514 | } | ||
3568 | 515 | put_bits(&pb, 5, slice_param->quant_scale); | ||
3569 | 516 | if (pic_param->vop_fields.bits.vop_coding_type != VOP_I_TYPE) | ||
3570 | 517 | put_bits(&pb, 3, pic_param->vop_fcode_forward); | ||
3571 | 518 | if (pic_param->vop_fields.bits.vop_coding_type == VOP_B_TYPE) | ||
3572 | 519 | put_bits(&pb, 3, pic_param->vop_fcode_backward); | ||
3573 | 520 | |||
3574 | 521 | /* Merge in bits from the first byte of the slice */ | ||
3575 | 522 | ASSERT((put_bits_count(&pb) % 8) == slice_param->macroblock_offset); | ||
3576 | 523 | if ((put_bits_count(&pb) % 8) != slice_param->macroblock_offset) | ||
3577 | 524 | return 0; | ||
3578 | 525 | const int r = 8 - (put_bits_count(&pb) % 8); | ||
3579 | 526 | if (r > 0) | ||
3580 | 527 | put_bits(&pb, r, slice_data[0] & ((1U << r) - 1)); | ||
3581 | 528 | flush_put_bits(&pb); | ||
3582 | 529 | |||
3583 | 530 | ASSERT((put_bits_count(&pb) % 8) == 0); | ||
3584 | 531 | slice_header_size = put_bits_count(&pb) / 8; | ||
3585 | 532 | ASSERT(slice_header_size <= sizeof(slice_header_buffer)); | ||
3586 | 533 | slice_header = alloc_gen_slice_data(obj_context, slice_header_size); | ||
3587 | 534 | if (!slice_header) | ||
3588 | 535 | return 0; | ||
3589 | 536 | memcpy(slice_header, slice_header_buffer, slice_header_size); | ||
3590 | 537 | if (append_VdpBitstreamBuffer(obj_context, slice_header, slice_header_size) < 0) | ||
3591 | 538 | return 0; | ||
3592 | 539 | if (append_VdpBitstreamBuffer(obj_context, slice_data + 1, slice_data_size - 1) < 0) | ||
3593 | 540 | return 0; | ||
3594 | 541 | return 1; | ||
3595 | 542 | } | ||
3596 | 543 | #endif | ||
3597 | 544 | |||
3598 | 545 | if (append_VdpBitstreamBuffer(obj_context, | ||
3599 | 546 | obj_buffer->buffer_data, | ||
3600 | 547 | obj_buffer->buffer_size) < 0) | ||
3601 | 548 | return 0; | ||
3602 | 549 | return 1; | ||
3603 | 550 | } | ||
3604 | 551 | |||
3605 | 552 | // Translate VAPictureParameterBufferMPEG2 | ||
3606 | 553 | static int | ||
3607 | 554 | translate_VAPictureParameterBufferMPEG2( | ||
3608 | 555 | vdpau_driver_data_t *driver_data, | ||
3609 | 556 | object_context_p obj_context, | ||
3610 | 557 | object_buffer_p obj_buffer | ||
3611 | 558 | ) | ||
3612 | 559 | { | ||
3613 | 560 | VdpPictureInfoMPEG1Or2 * const pic_info = &obj_context->vdp_picture_info.mpeg2; | ||
3614 | 561 | VAPictureParameterBufferMPEG2 * const pic_param = obj_buffer->buffer_data; | ||
3615 | 562 | |||
3616 | 563 | if (!translate_VASurfaceID(driver_data, | ||
3617 | 564 | pic_param->forward_reference_picture, | ||
3618 | 565 | &pic_info->forward_reference)) | ||
3619 | 566 | return 0; | ||
3620 | 567 | |||
3621 | 568 | if (!translate_VASurfaceID(driver_data, | ||
3622 | 569 | pic_param->backward_reference_picture, | ||
3623 | 570 | &pic_info->backward_reference)) | ||
3624 | 571 | return 0; | ||
3625 | 572 | |||
3626 | 573 | pic_info->picture_structure = pic_param->picture_coding_extension.bits.picture_structure; | ||
3627 | 574 | pic_info->picture_coding_type = pic_param->picture_coding_type; | ||
3628 | 575 | pic_info->intra_dc_precision = pic_param->picture_coding_extension.bits.intra_dc_precision; | ||
3629 | 576 | pic_info->frame_pred_frame_dct = pic_param->picture_coding_extension.bits.frame_pred_frame_dct; | ||
3630 | 577 | pic_info->concealment_motion_vectors = pic_param->picture_coding_extension.bits.concealment_motion_vectors; | ||
3631 | 578 | pic_info->intra_vlc_format = pic_param->picture_coding_extension.bits.intra_vlc_format; | ||
3632 | 579 | pic_info->alternate_scan = pic_param->picture_coding_extension.bits.alternate_scan; | ||
3633 | 580 | pic_info->q_scale_type = pic_param->picture_coding_extension.bits.q_scale_type; | ||
3634 | 581 | pic_info->top_field_first = pic_param->picture_coding_extension.bits.top_field_first; | ||
3635 | 582 | pic_info->full_pel_forward_vector = 0; | ||
3636 | 583 | pic_info->full_pel_backward_vector = 0; | ||
3637 | 584 | pic_info->f_code[0][0] = (pic_param->f_code >> 12) & 0xf; | ||
3638 | 585 | pic_info->f_code[0][1] = (pic_param->f_code >> 8) & 0xf; | ||
3639 | 586 | pic_info->f_code[1][0] = (pic_param->f_code >> 4) & 0xf; | ||
3640 | 587 | pic_info->f_code[1][1] = pic_param->f_code & 0xf; | ||
3641 | 588 | return 1; | ||
3642 | 589 | } | ||
3643 | 590 | |||
3644 | 591 | // Translate VAIQMatrixBufferMPEG2 | ||
3645 | 592 | static int | ||
3646 | 593 | translate_VAIQMatrixBufferMPEG2( | ||
3647 | 594 | vdpau_driver_data_t *driver_data, | ||
3648 | 595 | object_context_p obj_context, | ||
3649 | 596 | object_buffer_p obj_buffer | ||
3650 | 597 | ) | ||
3651 | 598 | { | ||
3652 | 599 | VdpPictureInfoMPEG1Or2 * const pic_info = &obj_context->vdp_picture_info.mpeg2; | ||
3653 | 600 | VAIQMatrixBufferMPEG2 * const iq_matrix = obj_buffer->buffer_data; | ||
3654 | 601 | const uint8_t *intra_matrix; | ||
3655 | 602 | const uint8_t *intra_matrix_lookup; | ||
3656 | 603 | const uint8_t *inter_matrix; | ||
3657 | 604 | const uint8_t *inter_matrix_lookup; | ||
3658 | 605 | int i; | ||
3659 | 606 | |||
3660 | 607 | if (iq_matrix->load_intra_quantiser_matrix) { | ||
3661 | 608 | intra_matrix = iq_matrix->intra_quantiser_matrix; | ||
3662 | 609 | intra_matrix_lookup = ff_zigzag_direct; | ||
3663 | 610 | } | ||
3664 | 611 | else { | ||
3665 | 612 | intra_matrix = ff_mpeg1_default_intra_matrix; | ||
3666 | 613 | intra_matrix_lookup = ff_identity; | ||
3667 | 614 | } | ||
3668 | 615 | |||
3669 | 616 | if (iq_matrix->load_non_intra_quantiser_matrix) { | ||
3670 | 617 | inter_matrix = iq_matrix->non_intra_quantiser_matrix; | ||
3671 | 618 | inter_matrix_lookup = ff_zigzag_direct; | ||
3672 | 619 | } | ||
3673 | 620 | else { | ||
3674 | 621 | inter_matrix = ff_mpeg1_default_non_intra_matrix; | ||
3675 | 622 | inter_matrix_lookup = ff_identity; | ||
3676 | 623 | } | ||
3677 | 624 | |||
3678 | 625 | for (i = 0; i < 64; i++) { | ||
3679 | 626 | pic_info->intra_quantizer_matrix[intra_matrix_lookup[i]] = | ||
3680 | 627 | intra_matrix[i]; | ||
3681 | 628 | pic_info->non_intra_quantizer_matrix[inter_matrix_lookup[i]] = | ||
3682 | 629 | inter_matrix[i]; | ||
3683 | 630 | } | ||
3684 | 631 | return 1; | ||
3685 | 632 | } | ||
3686 | 633 | |||
3687 | 634 | // Translate VASliceParameterBufferMPEG2 | ||
3688 | 635 | static int | ||
3689 | 636 | translate_VASliceParameterBufferMPEG2( | ||
3690 | 637 | vdpau_driver_data_t *driver_data, | ||
3691 | 638 | object_context_p obj_context, | ||
3692 | 639 | object_buffer_p obj_buffer | ||
3693 | 640 | ) | ||
3694 | 641 | { | ||
3695 | 642 | VdpPictureInfoMPEG1Or2 * const pic_info = &obj_context->vdp_picture_info.mpeg2; | ||
3696 | 643 | |||
3697 | 644 | pic_info->slice_count += obj_buffer->num_elements; | ||
3698 | 645 | obj_context->last_slice_params = obj_buffer->buffer_data; | ||
3699 | 646 | obj_context->last_slice_params_count = obj_buffer->num_elements; | ||
3700 | 647 | return 1; | ||
3701 | 648 | } | ||
3702 | 649 | |||
3703 | 650 | #if USE_VDPAU_MPEG4 | ||
3704 | 651 | // Translate VAPictureParameterBufferMPEG4 | ||
3705 | 652 | static int | ||
3706 | 653 | translate_VAPictureParameterBufferMPEG4( | ||
3707 | 654 | vdpau_driver_data_p driver_data, | ||
3708 | 655 | object_context_p obj_context, | ||
3709 | 656 | object_buffer_p obj_buffer | ||
3710 | 657 | ) | ||
3711 | 658 | { | ||
3712 | 659 | VdpPictureInfoMPEG4Part2 * const pic_info = &obj_context->vdp_picture_info.mpeg4; | ||
3713 | 660 | VAPictureParameterBufferMPEG4 * const pic_param = obj_buffer->buffer_data; | ||
3714 | 661 | |||
3715 | 662 | /* XXX: we don't support short-video-header formats */ | ||
3716 | 663 | if (pic_param->vol_fields.bits.short_video_header) | ||
3717 | 664 | return 0; | ||
3718 | 665 | |||
3719 | 666 | if (!translate_VASurfaceID(driver_data, | ||
3720 | 667 | pic_param->forward_reference_picture, | ||
3721 | 668 | &pic_info->forward_reference)) | ||
3722 | 669 | return 0; | ||
3723 | 670 | |||
3724 | 671 | if (!translate_VASurfaceID(driver_data, | ||
3725 | 672 | pic_param->backward_reference_picture, | ||
3726 | 673 | &pic_info->backward_reference)) | ||
3727 | 674 | return 0; | ||
3728 | 675 | |||
3729 | 676 | if (pic_param->vol_fields.bits.interlaced) { | ||
3730 | 677 | vdpau_information_message("unsupported MPEG-4 video with interlaced " | ||
3731 | 678 | "content, please report this video\n"); | ||
3732 | 679 | pic_info->trd[0] = 2*pic_param->TRD; /* XXX: + d(0) */ | ||
3733 | 680 | pic_info->trb[0] = 2*pic_param->TRB; /* XXX: + d(0) */ | ||
3734 | 681 | pic_info->trd[1] = 2*pic_param->TRD; /* XXX: + d(1) */ | ||
3735 | 682 | pic_info->trb[1] = 2*pic_param->TRB; /* XXX: + d(1) */ | ||
3736 | 683 | } | ||
3737 | 684 | else { | ||
3738 | 685 | pic_info->trd[0] = pic_param->TRD; | ||
3739 | 686 | pic_info->trb[0] = pic_param->TRB; | ||
3740 | 687 | pic_info->trd[1] = 0; | ||
3741 | 688 | pic_info->trb[1] = 0; | ||
3742 | 689 | } | ||
3743 | 690 | |||
3744 | 691 | pic_info->vop_time_increment_resolution = pic_param->vop_time_increment_resolution; | ||
3745 | 692 | pic_info->vop_coding_type = pic_param->vop_fields.bits.vop_coding_type; | ||
3746 | 693 | pic_info->vop_fcode_forward = pic_param->vop_fcode_forward; | ||
3747 | 694 | pic_info->vop_fcode_backward = pic_param->vop_fcode_backward; | ||
3748 | 695 | pic_info->resync_marker_disable = pic_param->vol_fields.bits.resync_marker_disable; | ||
3749 | 696 | pic_info->interlaced = pic_param->vol_fields.bits.interlaced; | ||
3750 | 697 | pic_info->quant_type = pic_param->vol_fields.bits.quant_type; | ||
3751 | 698 | pic_info->quarter_sample = pic_param->vol_fields.bits.quarter_sample; | ||
3752 | 699 | pic_info->short_video_header = pic_param->vol_fields.bits.short_video_header; | ||
3753 | 700 | pic_info->rounding_control = pic_param->vop_fields.bits.vop_rounding_type; | ||
3754 | 701 | pic_info->alternate_vertical_scan_flag = pic_param->vop_fields.bits.alternate_vertical_scan_flag; | ||
3755 | 702 | pic_info->top_field_first = pic_param->vop_fields.bits.top_field_first; | ||
3756 | 703 | |||
3757 | 704 | obj_context->last_pic_param = obj_buffer->buffer_data; | ||
3758 | 705 | return 1; | ||
3759 | 706 | } | ||
3760 | 707 | |||
3761 | 708 | // Translate VAIQMatrixBufferMPEG4 | ||
3762 | 709 | static int | ||
3763 | 710 | translate_VAIQMatrixBufferMPEG4( | ||
3764 | 711 | vdpau_driver_data_p driver_data, | ||
3765 | 712 | object_context_p obj_context, | ||
3766 | 713 | object_buffer_p obj_buffer | ||
3767 | 714 | ) | ||
3768 | 715 | { | ||
3769 | 716 | VdpPictureInfoMPEG4Part2 * const pic_info = &obj_context->vdp_picture_info.mpeg4; | ||
3770 | 717 | VAIQMatrixBufferMPEG4 * const iq_matrix = obj_buffer->buffer_data; | ||
3771 | 718 | const uint8_t *intra_matrix; | ||
3772 | 719 | const uint8_t *intra_matrix_lookup; | ||
3773 | 720 | const uint8_t *inter_matrix; | ||
3774 | 721 | const uint8_t *inter_matrix_lookup; | ||
3775 | 722 | int i; | ||
3776 | 723 | |||
3777 | 724 | if (iq_matrix->load_intra_quant_mat) { | ||
3778 | 725 | intra_matrix = iq_matrix->intra_quant_mat; | ||
3779 | 726 | intra_matrix_lookup = ff_zigzag_direct; | ||
3780 | 727 | } | ||
3781 | 728 | else { | ||
3782 | 729 | intra_matrix = ff_mpeg4_default_intra_matrix; | ||
3783 | 730 | intra_matrix_lookup = ff_identity; | ||
3784 | 731 | } | ||
3785 | 732 | |||
3786 | 733 | if (iq_matrix->load_non_intra_quant_mat) { | ||
3787 | 734 | inter_matrix = iq_matrix->non_intra_quant_mat; | ||
3788 | 735 | inter_matrix_lookup = ff_zigzag_direct; | ||
3789 | 736 | } | ||
3790 | 737 | else { | ||
3791 | 738 | inter_matrix = ff_mpeg4_default_non_intra_matrix; | ||
3792 | 739 | inter_matrix_lookup = ff_identity; | ||
3793 | 740 | } | ||
3794 | 741 | |||
3795 | 742 | for (i = 0; i < 64; i++) { | ||
3796 | 743 | pic_info->intra_quantizer_matrix[intra_matrix_lookup[i]] = | ||
3797 | 744 | intra_matrix[i]; | ||
3798 | 745 | pic_info->non_intra_quantizer_matrix[inter_matrix_lookup[i]] = | ||
3799 | 746 | inter_matrix[i]; | ||
3800 | 747 | } | ||
3801 | 748 | return 1; | ||
3802 | 749 | } | ||
3803 | 750 | |||
3804 | 751 | // Translate VASliceParameterBufferMPEG4 | ||
3805 | 752 | static int | ||
3806 | 753 | translate_VASliceParameterBufferMPEG4( | ||
3807 | 754 | vdpau_driver_data_p driver_data, | ||
3808 | 755 | object_context_p obj_context, | ||
3809 | 756 | object_buffer_p obj_buffer | ||
3810 | 757 | ) | ||
3811 | 758 | { | ||
3812 | 759 | obj_context->last_slice_params = obj_buffer->buffer_data; | ||
3813 | 760 | obj_context->last_slice_params_count = obj_buffer->num_elements; | ||
3814 | 761 | return 1; | ||
3815 | 762 | } | ||
3816 | 763 | #endif | ||
3817 | 764 | |||
3818 | 765 | // Translate VAPictureParameterBufferH264 | ||
3819 | 766 | static int | ||
3820 | 767 | translate_VAPictureParameterBufferH264( | ||
3821 | 768 | vdpau_driver_data_t *driver_data, | ||
3822 | 769 | object_context_p obj_context, | ||
3823 | 770 | object_buffer_p obj_buffer | ||
3824 | 771 | ) | ||
3825 | 772 | { | ||
3826 | 773 | VdpPictureInfoH264 * const pic_info = &obj_context->vdp_picture_info.h264; | ||
3827 | 774 | VAPictureParameterBufferH264 * const pic_param = obj_buffer->buffer_data; | ||
3828 | 775 | VAPictureH264 * const CurrPic = &pic_param->CurrPic; | ||
3829 | 776 | unsigned int i; | ||
3830 | 777 | |||
3831 | 778 | pic_info->field_order_cnt[0] = CurrPic->TopFieldOrderCnt; | ||
3832 | 779 | pic_info->field_order_cnt[1] = CurrPic->BottomFieldOrderCnt; | ||
3833 | 780 | pic_info->is_reference = pic_param->pic_fields.bits.reference_pic_flag; | ||
3834 | 781 | |||
3835 | 782 | pic_info->frame_num = pic_param->frame_num; | ||
3836 | 783 | pic_info->field_pic_flag = pic_param->pic_fields.bits.field_pic_flag; | ||
3837 | 784 | pic_info->bottom_field_flag = pic_param->pic_fields.bits.field_pic_flag && (CurrPic->flags & VA_PICTURE_H264_BOTTOM_FIELD) != 0; | ||
3838 | 785 | pic_info->num_ref_frames = pic_param->num_ref_frames; | ||
3839 | 786 | pic_info->mb_adaptive_frame_field_flag = pic_param->seq_fields.bits.mb_adaptive_frame_field_flag && !pic_info->field_pic_flag; | ||
3840 | 787 | pic_info->constrained_intra_pred_flag = pic_param->pic_fields.bits.constrained_intra_pred_flag; | ||
3841 | 788 | pic_info->weighted_pred_flag = pic_param->pic_fields.bits.weighted_pred_flag; | ||
3842 | 789 | pic_info->weighted_bipred_idc = pic_param->pic_fields.bits.weighted_bipred_idc; | ||
3843 | 790 | pic_info->frame_mbs_only_flag = pic_param->seq_fields.bits.frame_mbs_only_flag; | ||
3844 | 791 | pic_info->transform_8x8_mode_flag = pic_param->pic_fields.bits.transform_8x8_mode_flag; | ||
3845 | 792 | pic_info->chroma_qp_index_offset = pic_param->chroma_qp_index_offset; | ||
3846 | 793 | pic_info->second_chroma_qp_index_offset = pic_param->second_chroma_qp_index_offset; | ||
3847 | 794 | pic_info->pic_init_qp_minus26 = pic_param->pic_init_qp_minus26; | ||
3848 | 795 | pic_info->log2_max_frame_num_minus4 = pic_param->seq_fields.bits.log2_max_frame_num_minus4; | ||
3849 | 796 | pic_info->pic_order_cnt_type = pic_param->seq_fields.bits.pic_order_cnt_type; | ||
3850 | 797 | pic_info->log2_max_pic_order_cnt_lsb_minus4 = pic_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4; | ||
3851 | 798 | pic_info->delta_pic_order_always_zero_flag = pic_param->seq_fields.bits.delta_pic_order_always_zero_flag; | ||
3852 | 799 | pic_info->direct_8x8_inference_flag = pic_param->seq_fields.bits.direct_8x8_inference_flag; | ||
3853 | 800 | pic_info->entropy_coding_mode_flag = pic_param->pic_fields.bits.entropy_coding_mode_flag; | ||
3854 | 801 | pic_info->pic_order_present_flag = pic_param->pic_fields.bits.pic_order_present_flag; | ||
3855 | 802 | pic_info->deblocking_filter_control_present_flag = pic_param->pic_fields.bits.deblocking_filter_control_present_flag; | ||
3856 | 803 | pic_info->redundant_pic_cnt_present_flag = pic_param->pic_fields.bits.redundant_pic_cnt_present_flag; | ||
3857 | 804 | |||
3858 | 805 | for (i = 0; i < 16; i++) { | ||
3859 | 806 | if (!translate_VAPictureH264(driver_data, | ||
3860 | 807 | &pic_param->ReferenceFrames[i], | ||
3861 | 808 | &pic_info->referenceFrames[i])) | ||
3862 | 809 | return 0; | ||
3863 | 810 | } | ||
3864 | 811 | return 1; | ||
3865 | 812 | } | ||
3866 | 813 | |||
3867 | 814 | // Translate VAIQMatrixBufferH264 | ||
3868 | 815 | static int | ||
3869 | 816 | translate_VAIQMatrixBufferH264( | ||
3870 | 817 | vdpau_driver_data_t *driver_data, | ||
3871 | 818 | object_context_p obj_context, | ||
3872 | 819 | object_buffer_p obj_buffer | ||
3873 | 820 | ) | ||
3874 | 821 | { | ||
3875 | 822 | VdpPictureInfoH264 * const pic_info = &obj_context->vdp_picture_info.h264; | ||
3876 | 823 | VAIQMatrixBufferH264 * const iq_matrix = obj_buffer->buffer_data; | ||
3877 | 824 | int i, j; | ||
3878 | 825 | |||
3879 | 826 | if (sizeof(pic_info->scaling_lists_4x4) == sizeof(iq_matrix->ScalingList4x4)) | ||
3880 | 827 | memcpy(pic_info->scaling_lists_4x4, iq_matrix->ScalingList4x4, | ||
3881 | 828 | sizeof(pic_info->scaling_lists_4x4)); | ||
3882 | 829 | else { | ||
3883 | 830 | for (j = 0; j < 6; j++) { | ||
3884 | 831 | for (i = 0; i < 16; i++) | ||
3885 | 832 | pic_info->scaling_lists_4x4[j][i] = iq_matrix->ScalingList4x4[j][i]; | ||
3886 | 833 | } | ||
3887 | 834 | } | ||
3888 | 835 | |||
3889 | 836 | if (sizeof(pic_info->scaling_lists_8x8) == sizeof(iq_matrix->ScalingList8x8)) | ||
3890 | 837 | memcpy(pic_info->scaling_lists_8x8, iq_matrix->ScalingList8x8, | ||
3891 | 838 | sizeof(pic_info->scaling_lists_8x8)); | ||
3892 | 839 | else { | ||
3893 | 840 | for (j = 0; j < 2; j++) { | ||
3894 | 841 | for (i = 0; i < 64; i++) | ||
3895 | 842 | pic_info->scaling_lists_8x8[j][i] = iq_matrix->ScalingList8x8[j][i]; | ||
3896 | 843 | } | ||
3897 | 844 | } | ||
3898 | 845 | return 1; | ||
3899 | 846 | } | ||
3900 | 847 | |||
3901 | 848 | // Translate VASliceParameterBufferH264 | ||
3902 | 849 | static int | ||
3903 | 850 | translate_VASliceParameterBufferH264( | ||
3904 | 851 | vdpau_driver_data_t *driver_data, | ||
3905 | 852 | object_context_p obj_context, | ||
3906 | 853 | object_buffer_p obj_buffer | ||
3907 | 854 | ) | ||
3908 | 855 | { | ||
3909 | 856 | VdpPictureInfoH264 * const pic_info = &obj_context->vdp_picture_info.h264; | ||
3910 | 857 | VASliceParameterBufferH264 * const slice_params = obj_buffer->buffer_data; | ||
3911 | 858 | VASliceParameterBufferH264 * const slice_param = &slice_params[obj_buffer->num_elements - 1]; | ||
3912 | 859 | |||
3913 | 860 | pic_info->slice_count += obj_buffer->num_elements; | ||
3914 | 861 | pic_info->num_ref_idx_l0_active_minus1 = slice_param->num_ref_idx_l0_active_minus1; | ||
3915 | 862 | pic_info->num_ref_idx_l1_active_minus1 = slice_param->num_ref_idx_l1_active_minus1; | ||
3916 | 863 | obj_context->last_slice_params = obj_buffer->buffer_data; | ||
3917 | 864 | obj_context->last_slice_params_count = obj_buffer->num_elements; | ||
3918 | 865 | return 1; | ||
3919 | 866 | } | ||
3920 | 867 | |||
3921 | 868 | // Translate VAPictureParameterBufferVC1 | ||
3922 | 869 | static int | ||
3923 | 870 | translate_VAPictureParameterBufferVC1( | ||
3924 | 871 | vdpau_driver_data_t *driver_data, | ||
3925 | 872 | object_context_p obj_context, | ||
3926 | 873 | object_buffer_p obj_buffer | ||
3927 | 874 | ) | ||
3928 | 875 | { | ||
3929 | 876 | VdpPictureInfoVC1 * const pic_info = &obj_context->vdp_picture_info.vc1; | ||
3930 | 877 | VAPictureParameterBufferVC1 * const pic_param = obj_buffer->buffer_data; | ||
3931 | 878 | int picture_type, major_version, minor_version; | ||
3932 | 879 | |||
3933 | 880 | if (!translate_VASurfaceID(driver_data, | ||
3934 | 881 | pic_param->forward_reference_picture, | ||
3935 | 882 | &pic_info->forward_reference)) | ||
3936 | 883 | return 0; | ||
3937 | 884 | |||
3938 | 885 | if (!translate_VASurfaceID(driver_data, | ||
3939 | 886 | pic_param->backward_reference_picture, | ||
3940 | 887 | &pic_info->backward_reference)) | ||
3941 | 888 | return 0; | ||
3942 | 889 | |||
3943 | 890 | switch (pic_param->picture_fields.bits.picture_type) { | ||
3944 | 891 | case 0: picture_type = 0; break; /* I */ | ||
3945 | 892 | case 1: picture_type = 1; break; /* P */ | ||
3946 | 893 | case 2: picture_type = 3; break; /* B */ | ||
3947 | 894 | case 3: picture_type = 4; break; /* BI */ | ||
3948 | 895 | case 4: picture_type = 1; break; /* P "skipped" */ | ||
3949 | 896 | default: return 0; | ||
3950 | 897 | } | ||
3951 | 898 | |||
3952 | 899 | pic_info->picture_type = picture_type; | ||
3953 | 900 | pic_info->frame_coding_mode = pic_param->picture_fields.bits.frame_coding_mode; | ||
3954 | 901 | pic_info->postprocflag = pic_param->post_processing != 0; | ||
3955 | 902 | pic_info->pulldown = pic_param->sequence_fields.bits.pulldown; | ||
3956 | 903 | pic_info->interlace = pic_param->sequence_fields.bits.interlace; | ||
3957 | 904 | pic_info->tfcntrflag = pic_param->sequence_fields.bits.tfcntrflag; | ||
3958 | 905 | pic_info->finterpflag = pic_param->sequence_fields.bits.finterpflag; | ||
3959 | 906 | pic_info->psf = pic_param->sequence_fields.bits.psf; | ||
3960 | 907 | pic_info->dquant = pic_param->pic_quantizer_fields.bits.dquant; | ||
3961 | 908 | pic_info->panscan_flag = pic_param->entrypoint_fields.bits.panscan_flag; | ||
3962 | 909 | pic_info->refdist_flag = pic_param->reference_fields.bits.reference_distance_flag; | ||
3963 | 910 | pic_info->quantizer = pic_param->pic_quantizer_fields.bits.quantizer; | ||
3964 | 911 | pic_info->extended_mv = pic_param->mv_fields.bits.extended_mv_flag; | ||
3965 | 912 | pic_info->extended_dmv = pic_param->mv_fields.bits.extended_dmv_flag; | ||
3966 | 913 | pic_info->overlap = pic_param->sequence_fields.bits.overlap; | ||
3967 | 914 | pic_info->vstransform = pic_param->transform_fields.bits.variable_sized_transform_flag; | ||
3968 | 915 | pic_info->loopfilter = pic_param->entrypoint_fields.bits.loopfilter; | ||
3969 | 916 | pic_info->fastuvmc = pic_param->fast_uvmc_flag; | ||
3970 | 917 | pic_info->range_mapy_flag = pic_param->range_mapping_fields.bits.luma_flag; | ||
3971 | 918 | pic_info->range_mapy = pic_param->range_mapping_fields.bits.luma; | ||
3972 | 919 | pic_info->range_mapuv_flag = pic_param->range_mapping_fields.bits.chroma_flag; | ||
3973 | 920 | pic_info->range_mapuv = pic_param->range_mapping_fields.bits.chroma; | ||
3974 | 921 | pic_info->multires = pic_param->sequence_fields.bits.multires; | ||
3975 | 922 | pic_info->syncmarker = pic_param->sequence_fields.bits.syncmarker; | ||
3976 | 923 | pic_info->rangered = pic_param->sequence_fields.bits.rangered; | ||
3977 | 924 | if (!vdpau_is_nvidia(driver_data, &major_version, &minor_version) || | ||
3978 | 925 | (major_version > 180 || minor_version >= 35)) | ||
3979 | 926 | pic_info->rangered |= pic_param->range_reduction_frame << 1; | ||
3980 | 927 | pic_info->maxbframes = pic_param->sequence_fields.bits.max_b_frames; | ||
3981 | 928 | pic_info->deblockEnable = pic_param->post_processing != 0; /* XXX: this is NVIDIA's vdpau.c semantics (postprocflag & 1) */ | ||
3982 | 929 | pic_info->pquant = pic_param->pic_quantizer_fields.bits.pic_quantizer_scale; | ||
3983 | 930 | return 1; | ||
3984 | 931 | } | ||
3985 | 932 | |||
3986 | 933 | // Translate VASliceParameterBufferVC1 | ||
3987 | 934 | static int | ||
3988 | 935 | translate_VASliceParameterBufferVC1( | ||
3989 | 936 | vdpau_driver_data_t *driver_data, | ||
3990 | 937 | object_context_p obj_context, | ||
3991 | 938 | object_buffer_p obj_buffer | ||
3992 | 939 | ) | ||
3993 | 940 | { | ||
3994 | 941 | VdpPictureInfoVC1 * const pic_info = &obj_context->vdp_picture_info.vc1; | ||
3995 | 942 | |||
3996 | 943 | pic_info->slice_count += obj_buffer->num_elements; | ||
3997 | 944 | obj_context->last_slice_params = obj_buffer->buffer_data; | ||
3998 | 945 | obj_context->last_slice_params_count = obj_buffer->num_elements; | ||
3999 | 946 | return 1; | ||
4000 | 947 | } | ||
4001 | 948 | |||
4002 | 949 | // Translate VA buffer | ||
4003 | 950 | typedef int | ||
4004 | 951 | (*translate_buffer_func_t)(vdpau_driver_data_t *driver_data, | ||
4005 | 952 | object_context_p obj_context, | ||
4006 | 953 | object_buffer_p obj_buffer); | ||
4007 | 954 | |||
4008 | 955 | typedef struct translate_buffer_info translate_buffer_info_t; | ||
4009 | 956 | struct translate_buffer_info { | ||
4010 | 957 | VdpCodec codec; | ||
4011 | 958 | VABufferType type; | ||
4012 | 959 | translate_buffer_func_t func; | ||
4013 | 960 | }; | ||
4014 | 961 | |||
4015 | 962 | static int | ||
4016 | 963 | translate_buffer( | ||
4017 | 964 | vdpau_driver_data_t *driver_data, | ||
4018 | 965 | object_context_p obj_context, | ||
4019 | 966 | object_buffer_p obj_buffer | ||
4020 | 967 | ) | ||
4021 | 968 | { | ||
4022 | 969 | static const translate_buffer_info_t translate_info[] = { | ||
4023 | 970 | #define _(CODEC, TYPE) \ | ||
4024 | 971 | { VDP_CODEC_##CODEC, VA##TYPE##BufferType, \ | ||
4025 | 972 | translate_VA##TYPE##Buffer##CODEC } | ||
4026 | 973 | _(MPEG2, PictureParameter), | ||
4027 | 974 | _(MPEG2, IQMatrix), | ||
4028 | 975 | _(MPEG2, SliceParameter), | ||
4029 | 976 | #if USE_VDPAU_MPEG4 | ||
4030 | 977 | _(MPEG4, PictureParameter), | ||
4031 | 978 | _(MPEG4, IQMatrix), | ||
4032 | 979 | _(MPEG4, SliceParameter), | ||
4033 | 980 | #endif | ||
4034 | 981 | _(H264, PictureParameter), | ||
4035 | 982 | _(H264, IQMatrix), | ||
4036 | 983 | _(H264, SliceParameter), | ||
4037 | 984 | _(VC1, PictureParameter), | ||
4038 | 985 | _(VC1, SliceParameter), | ||
4039 | 986 | #undef _ | ||
4040 | 987 | { VDP_CODEC_VC1, VABitPlaneBufferType, translate_nothing }, | ||
4041 | 988 | { 0, VASliceDataBufferType, translate_VASliceDataBuffer }, | ||
4042 | 989 | { 0, 0, NULL } | ||
4043 | 990 | }; | ||
4044 | 991 | const translate_buffer_info_t *tbip; | ||
4045 | 992 | for (tbip = translate_info; tbip->func != NULL; tbip++) { | ||
4046 | 993 | if (tbip->codec && tbip->codec != obj_context->vdp_codec) | ||
4047 | 994 | continue; | ||
4048 | 995 | if (tbip->type != obj_buffer->type) | ||
4049 | 996 | continue; | ||
4050 | 997 | return tbip->func(driver_data, obj_context, obj_buffer); | ||
4051 | 998 | } | ||
4052 | 999 | D(bug("ERROR: no translate function found for %s%s\n", | ||
4053 | 1000 | string_of_VABufferType(obj_buffer->type), | ||
4054 | 1001 | obj_context->vdp_codec ? string_of_VdpCodec(obj_context->vdp_codec) : NULL)); | ||
4055 | 1002 | return 0; | ||
4056 | 1003 | } | ||
4057 | 1004 | |||
4058 | 1005 | // vaQueryConfigProfiles | ||
4059 | 1006 | VAStatus | ||
4060 | 1007 | vdpau_QueryConfigProfiles( | ||
4061 | 1008 | VADriverContextP ctx, | ||
4062 | 1009 | VAProfile *profile_list, | ||
4063 | 1010 | int *num_profiles | ||
4064 | 1011 | ) | ||
4065 | 1012 | { | ||
4066 | 1013 | VDPAU_DRIVER_DATA_INIT; | ||
4067 | 1014 | |||
4068 | 1015 | static const VAProfile va_profiles[] = { | ||
4069 | 1016 | VAProfileMPEG2Simple, | ||
4070 | 1017 | VAProfileMPEG2Main, | ||
4071 | 1018 | VAProfileMPEG4Simple, | ||
4072 | 1019 | VAProfileMPEG4AdvancedSimple, | ||
4073 | 1020 | VAProfileMPEG4Main, | ||
4074 | 1021 | VAProfileH264Baseline, | ||
4075 | 1022 | VAProfileH264Main, | ||
4076 | 1023 | VAProfileH264High, | ||
4077 | 1024 | VAProfileVC1Simple, | ||
4078 | 1025 | VAProfileVC1Main, | ||
4079 | 1026 | VAProfileVC1Advanced | ||
4080 | 1027 | }; | ||
4081 | 1028 | |||
4082 | 1029 | int i, n = 0; | ||
4083 | 1030 | for (i = 0; i < ARRAY_ELEMS(va_profiles); i++) { | ||
4084 | 1031 | VAProfile profile = va_profiles[i]; | ||
4085 | 1032 | VdpDecoderProfile vdp_profile = get_VdpDecoderProfile(profile); | ||
4086 | 1033 | if (is_supported_profile(driver_data, vdp_profile)) | ||
4087 | 1034 | profile_list[n++] = profile; | ||
4088 | 1035 | } | ||
4089 | 1036 | |||
4090 | 1037 | /* If the assert fails then VDPAU_MAX_PROFILES needs to be bigger */ | ||
4091 | 1038 | ASSERT(n <= VDPAU_MAX_PROFILES); | ||
4092 | 1039 | if (num_profiles) | ||
4093 | 1040 | *num_profiles = n; | ||
4094 | 1041 | |||
4095 | 1042 | return VA_STATUS_SUCCESS; | ||
4096 | 1043 | } | ||
4097 | 1044 | |||
4098 | 1045 | // vaQueryConfigEntrypoints | ||
4099 | 1046 | VAStatus | ||
4100 | 1047 | vdpau_QueryConfigEntrypoints( | ||
4101 | 1048 | VADriverContextP ctx, | ||
4102 | 1049 | VAProfile profile, | ||
4103 | 1050 | VAEntrypoint *entrypoint_list, | ||
4104 | 1051 | int *num_entrypoints | ||
4105 | 1052 | ) | ||
4106 | 1053 | { | ||
4107 | 1054 | VDPAU_DRIVER_DATA_INIT; | ||
4108 | 1055 | |||
4109 | 1056 | VdpDecoderProfile vdp_profile = get_VdpDecoderProfile(profile); | ||
4110 | 1057 | if (!is_supported_profile(driver_data, vdp_profile)) | ||
4111 | 1058 | return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; | ||
4112 | 1059 | |||
4113 | 1060 | VAEntrypoint entrypoint; | ||
4114 | 1061 | switch (profile) { | ||
4115 | 1062 | case VAProfileMPEG2Simple: | ||
4116 | 1063 | case VAProfileMPEG2Main: | ||
4117 | 1064 | entrypoint = VAEntrypointVLD; | ||
4118 | 1065 | break; | ||
4119 | 1066 | case VAProfileMPEG4Simple: | ||
4120 | 1067 | case VAProfileMPEG4AdvancedSimple: | ||
4121 | 1068 | case VAProfileMPEG4Main: | ||
4122 | 1069 | entrypoint = VAEntrypointVLD; | ||
4123 | 1070 | break; | ||
4124 | 1071 | case VAProfileH264Baseline: | ||
4125 | 1072 | case VAProfileH264Main: | ||
4126 | 1073 | case VAProfileH264High: | ||
4127 | 1074 | entrypoint = VAEntrypointVLD; | ||
4128 | 1075 | break; | ||
4129 | 1076 | case VAProfileVC1Simple: | ||
4130 | 1077 | case VAProfileVC1Main: | ||
4131 | 1078 | case VAProfileVC1Advanced: | ||
4132 | 1079 | entrypoint = VAEntrypointVLD; | ||
4133 | 1080 | break; | ||
4134 | 1081 | default: | ||
4135 | 1082 | entrypoint = 0; | ||
4136 | 1083 | break; | ||
4137 | 1084 | } | ||
4138 | 1085 | |||
4139 | 1086 | if (entrypoint_list) | ||
4140 | 1087 | *entrypoint_list = entrypoint; | ||
4141 | 1088 | |||
4142 | 1089 | if (num_entrypoints) | ||
4143 | 1090 | *num_entrypoints = entrypoint != 0; | ||
4144 | 1091 | |||
4145 | 1092 | return VA_STATUS_SUCCESS; | ||
4146 | 1093 | } | ||
4147 | 1094 | |||
4148 | 1095 | // vaBeginPicture | ||
4149 | 1096 | VAStatus | ||
4150 | 1097 | vdpau_BeginPicture( | ||
4151 | 1098 | VADriverContextP ctx, | ||
4152 | 1099 | VAContextID context, | ||
4153 | 1100 | VASurfaceID render_target | ||
4154 | 1101 | ) | ||
4155 | 1102 | { | ||
4156 | 1103 | VDPAU_DRIVER_DATA_INIT; | ||
4157 | 1104 | |||
4158 | 1105 | object_context_p obj_context = VDPAU_CONTEXT(context); | ||
4159 | 1106 | if (!obj_context) | ||
4160 | 1107 | return VA_STATUS_ERROR_INVALID_CONTEXT; | ||
4161 | 1108 | |||
4162 | 1109 | object_surface_p obj_surface = VDPAU_SURFACE(render_target); | ||
4163 | 1110 | if (!obj_surface) | ||
4164 | 1111 | return VA_STATUS_ERROR_INVALID_SURFACE; | ||
4165 | 1112 | |||
4166 | 1113 | obj_surface->va_surface_status = VASurfaceRendering; | ||
4167 | 1114 | obj_context->last_pic_param = NULL; | ||
4168 | 1115 | obj_context->last_slice_params = NULL; | ||
4169 | 1116 | obj_context->last_slice_params_count = 0; | ||
4170 | 1117 | obj_context->current_render_target = obj_surface->base.id; | ||
4171 | 1118 | obj_context->gen_slice_data_size = 0; | ||
4172 | 1119 | obj_context->vdp_bitstream_buffers_count = 0; | ||
4173 | 1120 | |||
4174 | 1121 | switch (obj_context->vdp_codec) { | ||
4175 | 1122 | case VDP_CODEC_MPEG1: | ||
4176 | 1123 | case VDP_CODEC_MPEG2: | ||
4177 | 1124 | obj_context->vdp_picture_info.mpeg2.slice_count = 0; | ||
4178 | 1125 | break; | ||
4179 | 1126 | case VDP_CODEC_MPEG4: | ||
4180 | 1127 | break; | ||
4181 | 1128 | case VDP_CODEC_H264: | ||
4182 | 1129 | obj_context->vdp_picture_info.h264.slice_count = 0; | ||
4183 | 1130 | break; | ||
4184 | 1131 | case VDP_CODEC_VC1: | ||
4185 | 1132 | obj_context->vdp_picture_info.vc1.slice_count = 0; | ||
4186 | 1133 | break; | ||
4187 | 1134 | default: | ||
4188 | 1135 | return VA_STATUS_ERROR_UNKNOWN; | ||
4189 | 1136 | } | ||
4190 | 1137 | |||
4191 | 1138 | destroy_dead_va_buffers(driver_data, obj_context); | ||
4192 | 1139 | return VA_STATUS_SUCCESS; | ||
4193 | 1140 | } | ||
4194 | 1141 | |||
4195 | 1142 | // vaRenderPicture | ||
4196 | 1143 | VAStatus | ||
4197 | 1144 | vdpau_RenderPicture( | ||
4198 | 1145 | VADriverContextP ctx, | ||
4199 | 1146 | VAContextID context, | ||
4200 | 1147 | VABufferID *buffers, | ||
4201 | 1148 | int num_buffers | ||
4202 | 1149 | ) | ||
4203 | 1150 | { | ||
4204 | 1151 | VDPAU_DRIVER_DATA_INIT; | ||
4205 | 1152 | int i; | ||
4206 | 1153 | |||
4207 | 1154 | object_context_p obj_context = VDPAU_CONTEXT(context); | ||
4208 | 1155 | if (!obj_context) | ||
4209 | 1156 | return VA_STATUS_ERROR_INVALID_CONTEXT; | ||
4210 | 1157 | |||
4211 | 1158 | object_surface_p obj_surface = VDPAU_SURFACE(obj_context->current_render_target); | ||
4212 | 1159 | if (!obj_surface) | ||
4213 | 1160 | return VA_STATUS_ERROR_INVALID_SURFACE; | ||
4214 | 1161 | |||
4215 | 1162 | /* Verify that we got valid buffer references */ | ||
4216 | 1163 | for (i = 0; i < num_buffers; i++) { | ||
4217 | 1164 | object_buffer_p obj_buffer = VDPAU_BUFFER(buffers[i]); | ||
4218 | 1165 | if (!obj_buffer) | ||
4219 | 1166 | return VA_STATUS_ERROR_INVALID_BUFFER; | ||
4220 | 1167 | } | ||
4221 | 1168 | |||
4222 | 1169 | /* Translate buffers */ | ||
4223 | 1170 | for (i = 0; i < num_buffers; i++) { | ||
4224 | 1171 | object_buffer_p obj_buffer = VDPAU_BUFFER(buffers[i]); | ||
4225 | 1172 | if (!translate_buffer(driver_data, obj_context, obj_buffer)) | ||
4226 | 1173 | return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; | ||
4227 | 1174 | /* Release any buffer that is not VASliceDataBuffer */ | ||
4228 | 1175 | /* VASliceParameterBuffer is also needed to check for start_codes */ | ||
4229 | 1176 | switch (obj_buffer->type) { | ||
4230 | 1177 | case VASliceParameterBufferType: | ||
4231 | 1178 | case VASliceDataBufferType: | ||
4232 | 1179 | schedule_destroy_va_buffer(driver_data, obj_buffer); | ||
4233 | 1180 | break; | ||
4234 | 1181 | case VAPictureParameterBufferType: | ||
4235 | 1182 | /* Preserve VAPictureParameterBufferMPEG4 */ | ||
4236 | 1183 | if (obj_context->vdp_codec == VDP_CODEC_MPEG4) { | ||
4237 | 1184 | schedule_destroy_va_buffer(driver_data, obj_buffer); | ||
4238 | 1185 | break; | ||
4239 | 1186 | } | ||
4240 | 1187 | /* fall-through */ | ||
4241 | 1188 | default: | ||
4242 | 1189 | destroy_va_buffer(driver_data, obj_buffer); | ||
4243 | 1190 | break; | ||
4244 | 1191 | } | ||
4245 | 1192 | } | ||
4246 | 1193 | |||
4247 | 1194 | return VA_STATUS_SUCCESS; | ||
4248 | 1195 | } | ||
4249 | 1196 | |||
4250 | 1197 | // vaEndPicture | ||
4251 | 1198 | VAStatus | ||
4252 | 1199 | vdpau_EndPicture( | ||
4253 | 1200 | VADriverContextP ctx, | ||
4254 | 1201 | VAContextID context | ||
4255 | 1202 | ) | ||
4256 | 1203 | { | ||
4257 | 1204 | VDPAU_DRIVER_DATA_INIT; | ||
4258 | 1205 | unsigned int i; | ||
4259 | 1206 | |||
4260 | 1207 | object_context_p obj_context = VDPAU_CONTEXT(context); | ||
4261 | 1208 | if (!obj_context) | ||
4262 | 1209 | return VA_STATUS_ERROR_INVALID_CONTEXT; | ||
4263 | 1210 | |||
4264 | 1211 | object_surface_p obj_surface = VDPAU_SURFACE(obj_context->current_render_target); | ||
4265 | 1212 | if (!obj_surface) | ||
4266 | 1213 | return VA_STATUS_ERROR_INVALID_SURFACE; | ||
4267 | 1214 | |||
4268 | 1215 | if (trace_enabled()) { | ||
4269 | 1216 | switch (obj_context->vdp_codec) { | ||
4270 | 1217 | case VDP_CODEC_MPEG1: | ||
4271 | 1218 | case VDP_CODEC_MPEG2: | ||
4272 | 1219 | dump_VdpPictureInfoMPEG1Or2(&obj_context->vdp_picture_info.mpeg2); | ||
4273 | 1220 | break; | ||
4274 | 1221 | #if HAVE_VDPAU_MPEG4 | ||
4275 | 1222 | case VDP_CODEC_MPEG4: | ||
4276 | 1223 | dump_VdpPictureInfoMPEG4Part2(&obj_context->vdp_picture_info.mpeg4); | ||
4277 | 1224 | break; | ||
4278 | 1225 | #endif | ||
4279 | 1226 | case VDP_CODEC_H264: | ||
4280 | 1227 | dump_VdpPictureInfoH264(&obj_context->vdp_picture_info.h264); | ||
4281 | 1228 | break; | ||
4282 | 1229 | case VDP_CODEC_VC1: | ||
4283 | 1230 | dump_VdpPictureInfoVC1(&obj_context->vdp_picture_info.vc1); | ||
4284 | 1231 | break; | ||
4285 | 1232 | default: | ||
4286 | 1233 | break; | ||
4287 | 1234 | } | ||
4288 | 1235 | for (i = 0; i < obj_context->vdp_bitstream_buffers_count; i++) | ||
4289 | 1236 | dump_VdpBitstreamBuffer(&obj_context->vdp_bitstream_buffers[i]); | ||
4290 | 1237 | } | ||
4291 | 1238 | |||
4292 | 1239 | VAStatus va_status; | ||
4293 | 1240 | VdpStatus vdp_status; | ||
4294 | 1241 | vdp_status = ensure_decoder_with_max_refs( | ||
4295 | 1242 | driver_data, | ||
4296 | 1243 | obj_context, | ||
4297 | 1244 | get_num_ref_frames(obj_context) | ||
4298 | 1245 | ); | ||
4299 | 1246 | if (vdp_status == VDP_STATUS_OK) | ||
4300 | 1247 | vdp_status = vdpau_decoder_render( | ||
4301 | 1248 | driver_data, | ||
4302 | 1249 | obj_context->vdp_decoder, | ||
4303 | 1250 | obj_surface->vdp_surface, | ||
4304 | 1251 | (VdpPictureInfo)&obj_context->vdp_picture_info, | ||
4305 | 1252 | obj_context->vdp_bitstream_buffers_count, | ||
4306 | 1253 | obj_context->vdp_bitstream_buffers | ||
4307 | 1254 | ); | ||
4308 | 1255 | va_status = vdpau_get_VAStatus(vdp_status); | ||
4309 | 1256 | |||
4310 | 1257 | /* XXX: assume we are done with rendering right away */ | ||
4311 | 1258 | obj_context->current_render_target = VA_INVALID_SURFACE; | ||
4312 | 1259 | |||
4313 | 1260 | /* Release pending buffers */ | ||
4314 | 1261 | destroy_dead_va_buffers(driver_data, obj_context); | ||
4315 | 1262 | |||
4316 | 1263 | return va_status; | ||
4317 | 1264 | } | ||
4318 | 0 | 1265 | ||
4319 | === modified file '.pc/applied-patches' | |||
4320 | --- .pc/applied-patches 2013-04-13 09:39:54 +0000 | |||
4321 | +++ .pc/applied-patches 2014-05-06 21:31:51 +0000 | |||
4322 | @@ -1,2 +1,5 @@ | |||
4323 | 1 | autoreconf.patch | 1 | autoreconf.patch |
4324 | 2 | GL_VER_1_3.patch | 2 | GL_VER_1_3.patch |
4325 | 3 | 01_dont_clear_va_buffer_too_early.patch | ||
4326 | 4 | 02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch | ||
4327 | 5 | 03_mark_destroyed_buffers_as_deleted.patch | ||
4328 | 3 | 6 | ||
4329 | === modified file 'debian/changelog' | |||
4330 | --- debian/changelog 2013-04-13 09:39:54 +0000 | |||
4331 | +++ debian/changelog 2014-05-06 21:31:51 +0000 | |||
4332 | @@ -1,3 +1,10 @@ | |||
4333 | 1 | vdpau-video (0.7.3-2ubuntu2) UNRELEASED; urgency=medium | ||
4334 | 2 | |||
4335 | 3 | * Added patch-set from upstream to fix crash when using | ||
4336 | 4 | gstreamer-vaapi (LP: #1222790) | ||
4337 | 5 | |||
4338 | 6 | -- Marco Trevisan (Treviño) <marco@ubuntu.com> Tue, 06 May 2014 23:15:53 +0200 | ||
4339 | 7 | |||
4340 | 1 | vdpau-video (0.7.3-2ubuntu1) raring; urgency=low | 8 | vdpau-video (0.7.3-2ubuntu1) raring; urgency=low |
4341 | 2 | 9 | ||
4342 | 3 | * Added patch from Gentoo bug #438180 (backported from upstream | 10 | * Added patch from Gentoo bug #438180 (backported from upstream |
4343 | 4 | 11 | ||
4344 | === added file 'debian/patches/01_dont_clear_va_buffer_too_early.patch' | |||
4345 | --- debian/patches/01_dont_clear_va_buffer_too_early.patch 1970-01-01 00:00:00 +0000 | |||
4346 | +++ debian/patches/01_dont_clear_va_buffer_too_early.patch 2014-05-06 21:31:51 +0000 | |||
4347 | @@ -0,0 +1,56 @@ | |||
4348 | 1 | Description: Don't clear VA buffers too early. | ||
4349 | 2 | vaRenderPicture() is supposed to destroy a VA buffer implicitly. However, | ||
4350 | 3 | some buffers need to be kept until vaEndPicture() is reached. Besides, if | ||
4351 | 4 | user calls vaDestroyBuffer() in between, we still have to keep the buffer | ||
4352 | 5 | live for vaEndPicture(). | ||
4353 | 6 | |||
4354 | 7 | Origin: upstream, http://cgit.freedesktop.org/vaapi/vdpau-driver/commit/?id=d26b5b3 | ||
4355 | 8 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/1222790 | ||
4356 | 9 | Forwarded: yes | ||
4357 | 10 | Applied-Upstream: 0.7.4 | ||
4358 | 11 | Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com> | ||
4359 | 12 | |||
4360 | 13 | --- | ||
4361 | 14 | diff --git a/src/vdpau_buffer.c b/src/vdpau_buffer.c | ||
4362 | 15 | index f1171f3..540713f 100644 | ||
4363 | 16 | --- a/src/vdpau_buffer.c | ||
4364 | 17 | +++ b/src/vdpau_buffer.c | ||
4365 | 18 | @@ -57,6 +57,7 @@ create_va_buffer( | ||
4366 | 19 | obj_buffer->buffer_size = size * num_elements; | ||
4367 | 20 | obj_buffer->buffer_data = malloc(obj_buffer->buffer_size); | ||
4368 | 21 | obj_buffer->mtime = 0; | ||
4369 | 22 | + obj_buffer->delayed_destroy = 0; | ||
4370 | 23 | |||
4371 | 24 | if (!obj_buffer->buffer_data) { | ||
4372 | 25 | destroy_va_buffer(driver_data, obj_buffer); | ||
4373 | 26 | @@ -103,6 +104,7 @@ schedule_destroy_va_buffer( | ||
4374 | 27 | ASSERT(obj_context->dead_buffers); | ||
4375 | 28 | obj_context->dead_buffers[obj_context->dead_buffers_count] = obj_buffer->base.id; | ||
4376 | 29 | obj_context->dead_buffers_count++; | ||
4377 | 30 | + obj_buffer->delayed_destroy = 1; | ||
4378 | 31 | } | ||
4379 | 32 | |||
4380 | 33 | // vaCreateBuffer | ||
4381 | 34 | @@ -162,7 +164,7 @@ vdpau_DestroyBuffer( | ||
4382 | 35 | |||
4383 | 36 | object_buffer_p obj_buffer = VDPAU_BUFFER(buffer_id); | ||
4384 | 37 | |||
4385 | 38 | - if (obj_buffer) | ||
4386 | 39 | + if (obj_buffer && !obj_buffer->delayed_destroy) | ||
4387 | 40 | destroy_va_buffer(driver_data, obj_buffer); | ||
4388 | 41 | |||
4389 | 42 | return VA_STATUS_SUCCESS; | ||
4390 | 43 | diff --git a/src/vdpau_buffer.h b/src/vdpau_buffer.h | ||
4391 | 44 | index 7790f54..0168df9 100644 | ||
4392 | 45 | --- a/src/vdpau_buffer.h | ||
4393 | 46 | +++ b/src/vdpau_buffer.h | ||
4394 | 47 | @@ -33,6 +33,7 @@ struct object_buffer { | ||
4395 | 48 | unsigned int max_num_elements; | ||
4396 | 49 | unsigned int num_elements; | ||
4397 | 50 | uint64_t mtime; | ||
4398 | 51 | + unsigned int delayed_destroy : 1; | ||
4399 | 52 | }; | ||
4400 | 53 | |||
4401 | 54 | // Create VA buffer object | ||
4402 | 55 | -- | ||
4403 | 56 | cgit v0.9.0.2-2-gbebe | ||
4404 | 0 | 57 | ||
4405 | === added file 'debian/patches/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch' | |||
4406 | --- debian/patches/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch 1970-01-01 00:00:00 +0000 | |||
4407 | +++ debian/patches/02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch 2014-05-06 21:31:51 +0000 | |||
4408 | @@ -0,0 +1,111 @@ | |||
4409 | 1 | Description: Purge VA buffers on context destroy or new picture decdode sequence. | ||
4410 | 2 | Origin: upstream, http://cgit.freedesktop.org/vaapi/vdpau-driver/commit/?id=2630695 | ||
4411 | 3 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/1222790 | ||
4412 | 4 | Forwarded: yes | ||
4413 | 5 | Applied-Upstream: 0.7.4 | ||
4414 | 6 | Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com> | ||
4415 | 7 | |||
4416 | 8 | --- | ||
4417 | 9 | diff --git a/src/vdpau_buffer.c b/src/vdpau_buffer.c | ||
4418 | 10 | index 540713f..8766046 100644 | ||
4419 | 11 | --- a/src/vdpau_buffer.c | ||
4420 | 12 | +++ b/src/vdpau_buffer.c | ||
4421 | 13 | @@ -28,6 +28,27 @@ | ||
4422 | 14 | #define DEBUG 1 | ||
4423 | 15 | #include "debug.h" | ||
4424 | 16 | |||
4425 | 17 | +// Destroy dead VA buffers | ||
4426 | 18 | +void | ||
4427 | 19 | +destroy_dead_va_buffers( | ||
4428 | 20 | + vdpau_driver_data_t *driver_data, | ||
4429 | 21 | + object_context_p obj_context | ||
4430 | 22 | +) | ||
4431 | 23 | +{ | ||
4432 | 24 | + object_buffer_p obj_buffer; | ||
4433 | 25 | + unsigned int i; | ||
4434 | 26 | + | ||
4435 | 27 | + if (obj_context->dead_buffers_count < 1) | ||
4436 | 28 | + return; | ||
4437 | 29 | + | ||
4438 | 30 | + ASSERT(obj_context->dead_buffers); | ||
4439 | 31 | + for (i = 0; i < obj_context->dead_buffers_count; i++) { | ||
4440 | 32 | + obj_buffer = VDPAU_BUFFER(obj_context->dead_buffers[i]); | ||
4441 | 33 | + ASSERT(obj_buffer); | ||
4442 | 34 | + destroy_va_buffer(driver_data, obj_buffer); | ||
4443 | 35 | + } | ||
4444 | 36 | + obj_context->dead_buffers_count = 0; | ||
4445 | 37 | +} | ||
4446 | 38 | |||
4447 | 39 | // Create VA buffer object | ||
4448 | 40 | object_buffer_p | ||
4449 | 41 | diff --git a/src/vdpau_buffer.h b/src/vdpau_buffer.h | ||
4450 | 42 | index 0168df9..42672aa 100644 | ||
4451 | 43 | --- a/src/vdpau_buffer.h | ||
4452 | 44 | +++ b/src/vdpau_buffer.h | ||
4453 | 45 | @@ -36,6 +36,13 @@ struct object_buffer { | ||
4454 | 46 | unsigned int delayed_destroy : 1; | ||
4455 | 47 | }; | ||
4456 | 48 | |||
4457 | 49 | +// Destroy dead VA buffers | ||
4458 | 50 | +void | ||
4459 | 51 | +destroy_dead_va_buffers( | ||
4460 | 52 | + vdpau_driver_data_t *driver_data, | ||
4461 | 53 | + object_context_p obj_context | ||
4462 | 54 | +) attribute_hidden; | ||
4463 | 55 | + | ||
4464 | 56 | // Create VA buffer object | ||
4465 | 57 | object_buffer_p | ||
4466 | 58 | create_va_buffer( | ||
4467 | 59 | diff --git a/src/vdpau_decode.c b/src/vdpau_decode.c | ||
4468 | 60 | index 08dfbf0..dee3993 100644 | ||
4469 | 61 | --- a/src/vdpau_decode.c | ||
4470 | 62 | +++ b/src/vdpau_decode.c | ||
4471 | 63 | @@ -1134,6 +1134,8 @@ vdpau_BeginPicture( | ||
4472 | 64 | default: | ||
4473 | 65 | return VA_STATUS_ERROR_UNKNOWN; | ||
4474 | 66 | } | ||
4475 | 67 | + | ||
4476 | 68 | + destroy_dead_va_buffers(driver_data, obj_context); | ||
4477 | 69 | return VA_STATUS_SUCCESS; | ||
4478 | 70 | } | ||
4479 | 71 | |||
4480 | 72 | @@ -1256,16 +1258,7 @@ vdpau_EndPicture( | ||
4481 | 73 | obj_context->current_render_target = VA_INVALID_SURFACE; | ||
4482 | 74 | |||
4483 | 75 | /* Release pending buffers */ | ||
4484 | 76 | - if (obj_context->dead_buffers_count > 0) { | ||
4485 | 77 | - ASSERT(obj_context->dead_buffers); | ||
4486 | 78 | - int i; | ||
4487 | 79 | - for (i = 0; i < obj_context->dead_buffers_count; i++) { | ||
4488 | 80 | - object_buffer_p obj_buffer = VDPAU_BUFFER(obj_context->dead_buffers[i]); | ||
4489 | 81 | - ASSERT(obj_buffer); | ||
4490 | 82 | - destroy_va_buffer(driver_data, obj_buffer); | ||
4491 | 83 | - } | ||
4492 | 84 | - obj_context->dead_buffers_count = 0; | ||
4493 | 85 | - } | ||
4494 | 86 | + destroy_dead_va_buffers(driver_data, obj_context); | ||
4495 | 87 | |||
4496 | 88 | return va_status; | ||
4497 | 89 | } | ||
4498 | 90 | diff --git a/src/vdpau_video.c b/src/vdpau_video.c | ||
4499 | 91 | index 3821879..05d1f5e 100644 | ||
4500 | 92 | --- a/src/vdpau_video.c | ||
4501 | 93 | +++ b/src/vdpau_video.c | ||
4502 | 94 | @@ -24,6 +24,7 @@ | ||
4503 | 95 | #include "vdpau_decode.h" | ||
4504 | 96 | #include "vdpau_subpic.h" | ||
4505 | 97 | #include "vdpau_mixer.h" | ||
4506 | 98 | +#include "vdpau_buffer.h" | ||
4507 | 99 | #include "utils.h" | ||
4508 | 100 | |||
4509 | 101 | #define DEBUG 1 | ||
4510 | 102 | @@ -481,6 +482,7 @@ VAStatus vdpau_DestroyContext(VADriverContextP ctx, VAContextID context) | ||
4511 | 103 | obj_context->vdp_decoder = VDP_INVALID_HANDLE; | ||
4512 | 104 | } | ||
4513 | 105 | |||
4514 | 106 | + destroy_dead_va_buffers(driver_data, obj_context); | ||
4515 | 107 | if (obj_context->dead_buffers) { | ||
4516 | 108 | free(obj_context->dead_buffers); | ||
4517 | 109 | obj_context->dead_buffers = NULL; | ||
4518 | 110 | -- | ||
4519 | 111 | cgit v0.9.0.2-2-gbebe | ||
4520 | 0 | 112 | ||
4521 | === added file 'debian/patches/03_mark_destroyed_buffers_as_deleted.patch' | |||
4522 | --- debian/patches/03_mark_destroyed_buffers_as_deleted.patch 1970-01-01 00:00:00 +0000 | |||
4523 | +++ debian/patches/03_mark_destroyed_buffers_as_deleted.patch 2014-05-06 21:31:51 +0000 | |||
4524 | @@ -0,0 +1,28 @@ | |||
4525 | 1 | Description: decode: mark destroyed buffers as deleted | ||
4526 | 2 | In multi-threaded scenarios destroying a buffer via destroy_va_buffer() | ||
4527 | 3 | will allow other threads to claim the freed buffer object. If the | ||
4528 | 4 | calling code does not know whether the buffer object was freed it may | ||
4529 | 5 | attempt to vaDestroyBuffer, essentially destroying a buffer object which | ||
4530 | 6 | is in use by another thread. | ||
4531 | 7 | |||
4532 | 8 | Origin: upstream, http://cgit.freedesktop.org/vaapi/vdpau-driver/commit/?id=e4fd3b | ||
4533 | 9 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/1222790 | ||
4534 | 10 | Forwarded: yes | ||
4535 | 11 | Applied-Upstream: 0.7.4 | ||
4536 | 12 | Author: Philip Lorenz <philip@bithub.de> | ||
4537 | 13 | |||
4538 | 14 | --- | ||
4539 | 15 | diff --git a/src/vdpau_decode.c b/src/vdpau_decode.c | ||
4540 | 16 | index b9f1419..22d9cd9 100644 | ||
4541 | 17 | --- a/src/vdpau_decode.c | ||
4542 | 18 | +++ b/src/vdpau_decode.c | ||
4543 | 19 | @@ -1229,6 +1229,7 @@ vdpau_RenderPicture( | ||
4544 | 20 | destroy_va_buffer(driver_data, obj_buffer); | ||
4545 | 21 | break; | ||
4546 | 22 | } | ||
4547 | 23 | + buffers[i] = VA_INVALID_BUFFER; | ||
4548 | 24 | } | ||
4549 | 25 | |||
4550 | 26 | return VA_STATUS_SUCCESS; | ||
4551 | 27 | -- | ||
4552 | 28 | cgit v0.9.0.2-2-gbebe | ||
4553 | 0 | 29 | ||
4554 | === modified file 'debian/patches/series' | |||
4555 | --- debian/patches/series 2013-04-13 09:39:54 +0000 | |||
4556 | +++ debian/patches/series 2014-05-06 21:31:51 +0000 | |||
4557 | @@ -1,2 +1,5 @@ | |||
4558 | 1 | autoreconf.patch | 1 | autoreconf.patch |
4559 | 2 | GL_VER_1_3.patch | 2 | GL_VER_1_3.patch |
4560 | 3 | 01_dont_clear_va_buffer_too_early.patch | ||
4561 | 4 | 02_purge_va_buffers_on_context_destroy_or_new_picture_decode_seq.patch | ||
4562 | 5 | 03_mark_destroyed_buffers_as_deleted.patch | ||
4563 | 3 | 6 | ||
4564 | === modified file 'src/vdpau_buffer.c' | |||
4565 | --- src/vdpau_buffer.c 2011-09-22 11:35:45 +0000 | |||
4566 | +++ src/vdpau_buffer.c 2014-05-06 21:31:51 +0000 | |||
4567 | @@ -28,6 +28,27 @@ | |||
4568 | 28 | #define DEBUG 1 | 28 | #define DEBUG 1 |
4569 | 29 | #include "debug.h" | 29 | #include "debug.h" |
4570 | 30 | 30 | ||
4571 | 31 | // Destroy dead VA buffers | ||
4572 | 32 | void | ||
4573 | 33 | destroy_dead_va_buffers( | ||
4574 | 34 | vdpau_driver_data_t *driver_data, | ||
4575 | 35 | object_context_p obj_context | ||
4576 | 36 | ) | ||
4577 | 37 | { | ||
4578 | 38 | object_buffer_p obj_buffer; | ||
4579 | 39 | unsigned int i; | ||
4580 | 40 | |||
4581 | 41 | if (obj_context->dead_buffers_count < 1) | ||
4582 | 42 | return; | ||
4583 | 43 | |||
4584 | 44 | ASSERT(obj_context->dead_buffers); | ||
4585 | 45 | for (i = 0; i < obj_context->dead_buffers_count; i++) { | ||
4586 | 46 | obj_buffer = VDPAU_BUFFER(obj_context->dead_buffers[i]); | ||
4587 | 47 | ASSERT(obj_buffer); | ||
4588 | 48 | destroy_va_buffer(driver_data, obj_buffer); | ||
4589 | 49 | } | ||
4590 | 50 | obj_context->dead_buffers_count = 0; | ||
4591 | 51 | } | ||
4592 | 31 | 52 | ||
4593 | 32 | // Create VA buffer object | 53 | // Create VA buffer object |
4594 | 33 | object_buffer_p | 54 | object_buffer_p |
4595 | @@ -57,6 +78,7 @@ | |||
4596 | 57 | obj_buffer->buffer_size = size * num_elements; | 78 | obj_buffer->buffer_size = size * num_elements; |
4597 | 58 | obj_buffer->buffer_data = malloc(obj_buffer->buffer_size); | 79 | obj_buffer->buffer_data = malloc(obj_buffer->buffer_size); |
4598 | 59 | obj_buffer->mtime = 0; | 80 | obj_buffer->mtime = 0; |
4599 | 81 | obj_buffer->delayed_destroy = 0; | ||
4600 | 60 | 82 | ||
4601 | 61 | if (!obj_buffer->buffer_data) { | 83 | if (!obj_buffer->buffer_data) { |
4602 | 62 | destroy_va_buffer(driver_data, obj_buffer); | 84 | destroy_va_buffer(driver_data, obj_buffer); |
4603 | @@ -103,6 +125,7 @@ | |||
4604 | 103 | ASSERT(obj_context->dead_buffers); | 125 | ASSERT(obj_context->dead_buffers); |
4605 | 104 | obj_context->dead_buffers[obj_context->dead_buffers_count] = obj_buffer->base.id; | 126 | obj_context->dead_buffers[obj_context->dead_buffers_count] = obj_buffer->base.id; |
4606 | 105 | obj_context->dead_buffers_count++; | 127 | obj_context->dead_buffers_count++; |
4607 | 128 | obj_buffer->delayed_destroy = 1; | ||
4608 | 106 | } | 129 | } |
4609 | 107 | 130 | ||
4610 | 108 | // vaCreateBuffer | 131 | // vaCreateBuffer |
4611 | @@ -162,7 +185,7 @@ | |||
4612 | 162 | 185 | ||
4613 | 163 | object_buffer_p obj_buffer = VDPAU_BUFFER(buffer_id); | 186 | object_buffer_p obj_buffer = VDPAU_BUFFER(buffer_id); |
4614 | 164 | 187 | ||
4616 | 165 | if (obj_buffer) | 188 | if (obj_buffer && !obj_buffer->delayed_destroy) |
4617 | 166 | destroy_va_buffer(driver_data, obj_buffer); | 189 | destroy_va_buffer(driver_data, obj_buffer); |
4618 | 167 | 190 | ||
4619 | 168 | return VA_STATUS_SUCCESS; | 191 | return VA_STATUS_SUCCESS; |
4620 | 169 | 192 | ||
4621 | === modified file 'src/vdpau_buffer.h' | |||
4622 | --- src/vdpau_buffer.h 2011-09-22 11:35:45 +0000 | |||
4623 | +++ src/vdpau_buffer.h 2014-05-06 21:31:51 +0000 | |||
4624 | @@ -33,8 +33,16 @@ | |||
4625 | 33 | unsigned int max_num_elements; | 33 | unsigned int max_num_elements; |
4626 | 34 | unsigned int num_elements; | 34 | unsigned int num_elements; |
4627 | 35 | uint64_t mtime; | 35 | uint64_t mtime; |
4628 | 36 | unsigned int delayed_destroy : 1; | ||
4629 | 36 | }; | 37 | }; |
4630 | 37 | 38 | ||
4631 | 39 | // Destroy dead VA buffers | ||
4632 | 40 | void | ||
4633 | 41 | destroy_dead_va_buffers( | ||
4634 | 42 | vdpau_driver_data_t *driver_data, | ||
4635 | 43 | object_context_p obj_context | ||
4636 | 44 | ) attribute_hidden; | ||
4637 | 45 | |||
4638 | 38 | // Create VA buffer object | 46 | // Create VA buffer object |
4639 | 39 | object_buffer_p | 47 | object_buffer_p |
4640 | 40 | create_va_buffer( | 48 | create_va_buffer( |
4641 | 41 | 49 | ||
4642 | === modified file 'src/vdpau_decode.c' | |||
4643 | --- src/vdpau_decode.c 2011-09-22 11:35:45 +0000 | |||
4644 | +++ src/vdpau_decode.c 2014-05-06 21:31:51 +0000 | |||
4645 | @@ -1134,6 +1134,8 @@ | |||
4646 | 1134 | default: | 1134 | default: |
4647 | 1135 | return VA_STATUS_ERROR_UNKNOWN; | 1135 | return VA_STATUS_ERROR_UNKNOWN; |
4648 | 1136 | } | 1136 | } |
4649 | 1137 | |||
4650 | 1138 | destroy_dead_va_buffers(driver_data, obj_context); | ||
4651 | 1137 | return VA_STATUS_SUCCESS; | 1139 | return VA_STATUS_SUCCESS; |
4652 | 1138 | } | 1140 | } |
4653 | 1139 | 1141 | ||
4654 | @@ -1187,6 +1189,7 @@ | |||
4655 | 1187 | destroy_va_buffer(driver_data, obj_buffer); | 1189 | destroy_va_buffer(driver_data, obj_buffer); |
4656 | 1188 | break; | 1190 | break; |
4657 | 1189 | } | 1191 | } |
4658 | 1192 | buffers[i] = VA_INVALID_BUFFER; | ||
4659 | 1190 | } | 1193 | } |
4660 | 1191 | 1194 | ||
4661 | 1192 | return VA_STATUS_SUCCESS; | 1195 | return VA_STATUS_SUCCESS; |
4662 | @@ -1256,16 +1259,7 @@ | |||
4663 | 1256 | obj_context->current_render_target = VA_INVALID_SURFACE; | 1259 | obj_context->current_render_target = VA_INVALID_SURFACE; |
4664 | 1257 | 1260 | ||
4665 | 1258 | /* Release pending buffers */ | 1261 | /* Release pending buffers */ |
4676 | 1259 | if (obj_context->dead_buffers_count > 0) { | 1262 | destroy_dead_va_buffers(driver_data, obj_context); |
4667 | 1260 | ASSERT(obj_context->dead_buffers); | ||
4668 | 1261 | int i; | ||
4669 | 1262 | for (i = 0; i < obj_context->dead_buffers_count; i++) { | ||
4670 | 1263 | object_buffer_p obj_buffer = VDPAU_BUFFER(obj_context->dead_buffers[i]); | ||
4671 | 1264 | ASSERT(obj_buffer); | ||
4672 | 1265 | destroy_va_buffer(driver_data, obj_buffer); | ||
4673 | 1266 | } | ||
4674 | 1267 | obj_context->dead_buffers_count = 0; | ||
4675 | 1268 | } | ||
4677 | 1269 | 1263 | ||
4678 | 1270 | return va_status; | 1264 | return va_status; |
4679 | 1271 | } | 1265 | } |
4680 | 1272 | 1266 | ||
4681 | === modified file 'src/vdpau_video.c' | |||
4682 | --- src/vdpau_video.c 2011-09-22 11:35:45 +0000 | |||
4683 | +++ src/vdpau_video.c 2014-05-06 21:31:51 +0000 | |||
4684 | @@ -24,6 +24,7 @@ | |||
4685 | 24 | #include "vdpau_decode.h" | 24 | #include "vdpau_decode.h" |
4686 | 25 | #include "vdpau_subpic.h" | 25 | #include "vdpau_subpic.h" |
4687 | 26 | #include "vdpau_mixer.h" | 26 | #include "vdpau_mixer.h" |
4688 | 27 | #include "vdpau_buffer.h" | ||
4689 | 27 | #include "utils.h" | 28 | #include "utils.h" |
4690 | 28 | 29 | ||
4691 | 29 | #define DEBUG 1 | 30 | #define DEBUG 1 |
4692 | @@ -481,6 +482,7 @@ | |||
4693 | 481 | obj_context->vdp_decoder = VDP_INVALID_HANDLE; | 482 | obj_context->vdp_decoder = VDP_INVALID_HANDLE; |
4694 | 482 | } | 483 | } |
4695 | 483 | 484 | ||
4696 | 485 | destroy_dead_va_buffers(driver_data, obj_context); | ||
4697 | 484 | if (obj_context->dead_buffers) { | 486 | if (obj_context->dead_buffers) { |
4698 | 485 | free(obj_context->dead_buffers); | 487 | free(obj_context->dead_buffers); |
4699 | 486 | obj_context->dead_buffers = NULL; | 488 | obj_context->dead_buffers = NULL; |
Uploaded as
vdpau-video (0.7.3-2ubuntu1.1) trusty-proposed; urgency=medium
Thanks!