s/Tungsten Graphics/VMware/
[mesa.git] / src / gallium / state_trackers / vdpau / decode.c
1 /**************************************************************************
2 *
3 * Copyright 2010 Thomas Balling Sørensen.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include "util/u_memory.h"
29 #include "util/u_math.h"
30 #include "util/u_debug.h"
31 #include "util/u_video.h"
32
33 #include "vl/vl_vlc.h"
34
35 #include "vdpau_private.h"
36
37 /**
38 * Create a VdpDecoder.
39 */
40 VdpStatus
41 vlVdpDecoderCreate(VdpDevice device,
42 VdpDecoderProfile profile,
43 uint32_t width, uint32_t height,
44 uint32_t max_references,
45 VdpDecoder *decoder)
46 {
47 struct pipe_video_codec templat = {};
48 struct pipe_context *pipe;
49 struct pipe_screen *screen;
50 vlVdpDevice *dev;
51 vlVdpDecoder *vldecoder;
52 VdpStatus ret;
53 bool supported;
54 uint32_t maxwidth, maxheight;
55
56 if (!decoder)
57 return VDP_STATUS_INVALID_POINTER;
58 *decoder = 0;
59
60 if (!(width && height))
61 return VDP_STATUS_INVALID_VALUE;
62
63 templat.profile = ProfileToPipe(profile);
64 if (templat.profile == PIPE_VIDEO_PROFILE_UNKNOWN)
65 return VDP_STATUS_INVALID_DECODER_PROFILE;
66
67 dev = vlGetDataHTAB(device);
68 if (!dev)
69 return VDP_STATUS_INVALID_HANDLE;
70
71 pipe = dev->context;
72 screen = dev->vscreen->pscreen;
73
74 pipe_mutex_lock(dev->mutex);
75
76 supported = screen->get_video_param
77 (
78 screen,
79 templat.profile,
80 PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
81 PIPE_VIDEO_CAP_SUPPORTED
82 );
83 if (!supported) {
84 pipe_mutex_unlock(dev->mutex);
85 return VDP_STATUS_INVALID_DECODER_PROFILE;
86 }
87
88 maxwidth = screen->get_video_param
89 (
90 screen,
91 templat.profile,
92 PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
93 PIPE_VIDEO_CAP_MAX_WIDTH
94 );
95 maxheight = screen->get_video_param
96 (
97 screen,
98 templat.profile,
99 PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
100 PIPE_VIDEO_CAP_MAX_HEIGHT
101 );
102 if (width > maxwidth || height > maxheight) {
103 pipe_mutex_unlock(dev->mutex);
104 return VDP_STATUS_INVALID_SIZE;
105 }
106
107 vldecoder = CALLOC(1,sizeof(vlVdpDecoder));
108 if (!vldecoder) {
109 pipe_mutex_unlock(dev->mutex);
110 return VDP_STATUS_RESOURCES;
111 }
112
113 vldecoder->device = dev;
114
115 templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
116 templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
117 templat.width = width;
118 templat.height = height;
119 templat.max_references = max_references;
120
121 vldecoder->decoder = pipe->create_video_codec(pipe, &templat);
122
123 if (!vldecoder->decoder) {
124 ret = VDP_STATUS_ERROR;
125 goto error_decoder;
126 }
127
128 *decoder = vlAddDataHTAB(vldecoder);
129 if (*decoder == 0) {
130 ret = VDP_STATUS_ERROR;
131 goto error_handle;
132 }
133
134 pipe_mutex_init(vldecoder->mutex);
135 pipe_mutex_unlock(dev->mutex);
136
137 return VDP_STATUS_OK;
138
139 error_handle:
140 vldecoder->decoder->destroy(vldecoder->decoder);
141
142 error_decoder:
143 pipe_mutex_unlock(dev->mutex);
144 FREE(vldecoder);
145 return ret;
146 }
147
148 /**
149 * Destroy a VdpDecoder.
150 */
151 VdpStatus
152 vlVdpDecoderDestroy(VdpDecoder decoder)
153 {
154 vlVdpDecoder *vldecoder;
155
156 vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
157 if (!vldecoder)
158 return VDP_STATUS_INVALID_HANDLE;
159
160 pipe_mutex_lock(vldecoder->mutex);
161 vldecoder->decoder->destroy(vldecoder->decoder);
162 pipe_mutex_unlock(vldecoder->mutex);
163 pipe_mutex_destroy(vldecoder->mutex);
164
165 vlRemoveDataHTAB(decoder);
166 FREE(vldecoder);
167
168 return VDP_STATUS_OK;
169 }
170
171 /**
172 * Retrieve the parameters used to create a VdpDecoder.
173 */
174 VdpStatus
175 vlVdpDecoderGetParameters(VdpDecoder decoder,
176 VdpDecoderProfile *profile,
177 uint32_t *width,
178 uint32_t *height)
179 {
180 vlVdpDecoder *vldecoder;
181
182 vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
183 if (!vldecoder)
184 return VDP_STATUS_INVALID_HANDLE;
185
186 *profile = PipeToProfile(vldecoder->decoder->profile);
187 *width = vldecoder->decoder->width;
188 *height = vldecoder->decoder->height;
189
190 return VDP_STATUS_OK;
191 }
192
193 static VdpStatus
194 vlVdpGetReferenceFrame(VdpVideoSurface handle, struct pipe_video_buffer **ref_frame)
195 {
196 vlVdpSurface *surface;
197
198 /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */
199 if (handle == VDP_INVALID_HANDLE) {
200 *ref_frame = NULL;
201 return VDP_STATUS_OK;
202 }
203
204 surface = vlGetDataHTAB(handle);
205 if (!surface)
206 return VDP_STATUS_INVALID_HANDLE;
207
208 *ref_frame = surface->video_buffer;
209 if (!*ref_frame)
210 return VDP_STATUS_INVALID_HANDLE;
211
212 return VDP_STATUS_OK;
213 }
214
215 /**
216 * Decode a mpeg 1/2 video.
217 */
218 static VdpStatus
219 vlVdpDecoderRenderMpeg12(struct pipe_mpeg12_picture_desc *picture,
220 VdpPictureInfoMPEG1Or2 *picture_info)
221 {
222 VdpStatus r;
223
224 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG12\n");
225
226 r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]);
227 if (r != VDP_STATUS_OK)
228 return r;
229
230 r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]);
231 if (r != VDP_STATUS_OK)
232 return r;
233
234 picture->picture_coding_type = picture_info->picture_coding_type;
235 picture->picture_structure = picture_info->picture_structure;
236 picture->frame_pred_frame_dct = picture_info->frame_pred_frame_dct;
237 picture->q_scale_type = picture_info->q_scale_type;
238 picture->alternate_scan = picture_info->alternate_scan;
239 picture->intra_vlc_format = picture_info->intra_vlc_format;
240 picture->concealment_motion_vectors = picture_info->concealment_motion_vectors;
241 picture->intra_dc_precision = picture_info->intra_dc_precision;
242 picture->f_code[0][0] = picture_info->f_code[0][0] - 1;
243 picture->f_code[0][1] = picture_info->f_code[0][1] - 1;
244 picture->f_code[1][0] = picture_info->f_code[1][0] - 1;
245 picture->f_code[1][1] = picture_info->f_code[1][1] - 1;
246 picture->num_slices = picture_info->slice_count;
247 picture->top_field_first = picture_info->top_field_first;
248 picture->full_pel_forward_vector = picture_info->full_pel_forward_vector;
249 picture->full_pel_backward_vector = picture_info->full_pel_backward_vector;
250 picture->intra_matrix = picture_info->intra_quantizer_matrix;
251 picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix;
252
253 return VDP_STATUS_OK;
254 }
255
256 /**
257 * Decode a mpeg 4 video.
258 */
259 static VdpStatus
260 vlVdpDecoderRenderMpeg4(struct pipe_mpeg4_picture_desc *picture,
261 VdpPictureInfoMPEG4Part2 *picture_info)
262 {
263 VdpStatus r;
264 unsigned i;
265
266 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG4\n");
267
268 r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]);
269 if (r != VDP_STATUS_OK)
270 return r;
271
272 r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]);
273 if (r != VDP_STATUS_OK)
274 return r;
275
276 for (i = 0; i < 2; ++i) {
277 picture->trd[i] = picture_info->trd[i];
278 picture->trb[i] = picture_info->trb[i];
279 }
280 picture->vop_time_increment_resolution = picture_info->vop_time_increment_resolution;
281 picture->vop_coding_type = picture_info->vop_coding_type;
282 picture->vop_fcode_forward = picture_info->vop_fcode_forward;
283 picture->vop_fcode_backward = picture_info->vop_fcode_backward;
284 picture->resync_marker_disable = picture_info->resync_marker_disable;
285 picture->interlaced = picture_info->interlaced;
286 picture->quant_type = picture_info->quant_type;
287 picture->quarter_sample = picture_info->quarter_sample;
288 picture->short_video_header = picture_info->short_video_header;
289 picture->rounding_control = picture_info->rounding_control;
290 picture->alternate_vertical_scan_flag = picture_info->alternate_vertical_scan_flag;
291 picture->top_field_first = picture_info->top_field_first;
292 picture->intra_matrix = picture_info->intra_quantizer_matrix;
293 picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix;
294
295 return VDP_STATUS_OK;
296 }
297
298 static VdpStatus
299 vlVdpDecoderRenderVC1(struct pipe_vc1_picture_desc *picture,
300 VdpPictureInfoVC1 *picture_info)
301 {
302 VdpStatus r;
303
304 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding VC-1\n");
305
306 r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]);
307 if (r != VDP_STATUS_OK)
308 return r;
309
310 r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]);
311 if (r != VDP_STATUS_OK)
312 return r;
313
314 picture->slice_count = picture_info->slice_count;
315 picture->picture_type = picture_info->picture_type;
316 picture->frame_coding_mode = picture_info->frame_coding_mode;
317 picture->postprocflag = picture_info->postprocflag;
318 picture->pulldown = picture_info->pulldown;
319 picture->interlace = picture_info->interlace;
320 picture->tfcntrflag = picture_info->tfcntrflag;
321 picture->finterpflag = picture_info->finterpflag;
322 picture->psf = picture_info->psf;
323 picture->dquant = picture_info->dquant;
324 picture->panscan_flag = picture_info->panscan_flag;
325 picture->refdist_flag = picture_info->refdist_flag;
326 picture->quantizer = picture_info->quantizer;
327 picture->extended_mv = picture_info->extended_mv;
328 picture->extended_dmv = picture_info->extended_dmv;
329 picture->overlap = picture_info->overlap;
330 picture->vstransform = picture_info->vstransform;
331 picture->loopfilter = picture_info->loopfilter;
332 picture->fastuvmc = picture_info->fastuvmc;
333 picture->range_mapy_flag = picture_info->range_mapy_flag;
334 picture->range_mapy = picture_info->range_mapy;
335 picture->range_mapuv_flag = picture_info->range_mapuv_flag;
336 picture->range_mapuv = picture_info->range_mapuv;
337 picture->multires = picture_info->multires;
338 picture->syncmarker = picture_info->syncmarker;
339 picture->rangered = picture_info->rangered;
340 picture->maxbframes = picture_info->maxbframes;
341 picture->deblockEnable = picture_info->deblockEnable;
342 picture->pquant = picture_info->pquant;
343
344 return VDP_STATUS_OK;
345 }
346
347 static VdpStatus
348 vlVdpDecoderRenderH264(struct pipe_h264_picture_desc *picture,
349 VdpPictureInfoH264 *picture_info)
350 {
351 unsigned i;
352
353 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding H264\n");
354
355 picture->pps->sps->mb_adaptive_frame_field_flag = picture_info->mb_adaptive_frame_field_flag;
356 picture->pps->sps->frame_mbs_only_flag = picture_info->frame_mbs_only_flag;
357 picture->pps->sps->log2_max_frame_num_minus4 = picture_info->log2_max_frame_num_minus4;
358 picture->pps->sps->pic_order_cnt_type = picture_info->pic_order_cnt_type;
359 picture->pps->sps->log2_max_pic_order_cnt_lsb_minus4 = picture_info->log2_max_pic_order_cnt_lsb_minus4;
360 picture->pps->sps->delta_pic_order_always_zero_flag = picture_info->delta_pic_order_always_zero_flag;
361 picture->pps->sps->direct_8x8_inference_flag = picture_info->direct_8x8_inference_flag;
362
363 picture->pps->transform_8x8_mode_flag = picture_info->transform_8x8_mode_flag;
364 picture->pps->chroma_qp_index_offset = picture_info->chroma_qp_index_offset;
365 picture->pps->second_chroma_qp_index_offset = picture_info->second_chroma_qp_index_offset;
366 picture->pps->pic_init_qp_minus26 = picture_info->pic_init_qp_minus26;
367 picture->pps->entropy_coding_mode_flag = picture_info->entropy_coding_mode_flag;
368 picture->pps->deblocking_filter_control_present_flag = picture_info->deblocking_filter_control_present_flag;
369 picture->pps->redundant_pic_cnt_present_flag = picture_info->redundant_pic_cnt_present_flag;
370 picture->pps->constrained_intra_pred_flag = picture_info->constrained_intra_pred_flag;
371 picture->pps->weighted_pred_flag = picture_info->weighted_pred_flag;
372 picture->pps->weighted_bipred_idc = picture_info->weighted_bipred_idc;
373 picture->pps->bottom_field_pic_order_in_frame_present_flag = picture_info->pic_order_present_flag;
374 memcpy(picture->pps->ScalingList4x4, picture_info->scaling_lists_4x4, 6*16);
375 memcpy(picture->pps->ScalingList8x8, picture_info->scaling_lists_8x8, 2*64);
376
377 picture->slice_count = picture_info->slice_count;
378 picture->field_order_cnt[0] = picture_info->field_order_cnt[0];
379 picture->field_order_cnt[1] = picture_info->field_order_cnt[1];
380 picture->is_reference = picture_info->is_reference;
381 picture->frame_num = picture_info->frame_num;
382 picture->field_pic_flag = picture_info->field_pic_flag;
383 picture->bottom_field_flag = picture_info->bottom_field_flag;
384 picture->num_ref_frames = picture_info->num_ref_frames;
385
386 picture->num_ref_idx_l0_active_minus1 = picture_info->num_ref_idx_l0_active_minus1;
387 picture->num_ref_idx_l1_active_minus1 = picture_info->num_ref_idx_l1_active_minus1;
388
389 for (i = 0; i < 16; ++i) {
390 VdpStatus ret = vlVdpGetReferenceFrame
391 (
392 picture_info->referenceFrames[i].surface,
393 &picture->ref[i]
394 );
395 if (ret != VDP_STATUS_OK)
396 return ret;
397
398 picture->is_long_term[i] = picture_info->referenceFrames[i].is_long_term;
399 picture->top_is_reference[i] = picture_info->referenceFrames[i].top_is_reference;
400 picture->bottom_is_reference[i] = picture_info->referenceFrames[i].bottom_is_reference;
401 picture->field_order_cnt_list[i][0] = picture_info->referenceFrames[i].field_order_cnt[0];
402 picture->field_order_cnt_list[i][1] = picture_info->referenceFrames[i].field_order_cnt[1];
403 picture->frame_num_list[i] = picture_info->referenceFrames[i].frame_idx;
404 }
405
406 return VDP_STATUS_OK;
407 }
408
409 static void
410 vlVdpDecoderFixVC1Startcode(uint32_t *num_buffers, const void *buffers[], unsigned sizes[])
411 {
412 static const uint8_t vc1_startcode[] = { 0x00, 0x00, 0x01, 0x0D };
413 struct vl_vlc vlc;
414 unsigned i;
415
416 /* search the first 64 bytes for a startcode */
417 vl_vlc_init(&vlc, *num_buffers, buffers, sizes);
418 while (vl_vlc_search_byte(&vlc, 64*8, 0x00) && vl_vlc_bits_left(&vlc) >= 32) {
419 uint32_t value = vl_vlc_peekbits(&vlc, 32);
420 if (value == 0x0000010D ||
421 value == 0x0000010C ||
422 value == 0x0000010B)
423 return;
424 vl_vlc_eatbits(&vlc, 8);
425 }
426
427 /* none found, ok add one manually */
428 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Manually adding VC-1 startcode\n");
429 for (i = *num_buffers; i > 0; --i) {
430 buffers[i] = buffers[i - 1];
431 sizes[i] = sizes[i - 1];
432 }
433 ++(*num_buffers);
434 buffers[0] = vc1_startcode;
435 sizes[0] = 4;
436 }
437
438 /**
439 * Decode a compressed field/frame and render the result into a VdpVideoSurface.
440 */
441 VdpStatus
442 vlVdpDecoderRender(VdpDecoder decoder,
443 VdpVideoSurface target,
444 VdpPictureInfo const *picture_info,
445 uint32_t bitstream_buffer_count,
446 VdpBitstreamBuffer const *bitstream_buffers)
447 {
448 const void * buffers[bitstream_buffer_count + 1];
449 unsigned sizes[bitstream_buffer_count + 1];
450 vlVdpDecoder *vldecoder;
451 vlVdpSurface *vlsurf;
452 VdpStatus ret;
453 struct pipe_screen *screen;
454 struct pipe_video_codec *dec;
455 bool buffer_support[2];
456 unsigned i;
457 struct pipe_h264_sps sps = {};
458 struct pipe_h264_pps pps = { &sps };
459 union {
460 struct pipe_picture_desc base;
461 struct pipe_mpeg12_picture_desc mpeg12;
462 struct pipe_mpeg4_picture_desc mpeg4;
463 struct pipe_vc1_picture_desc vc1;
464 struct pipe_h264_picture_desc h264;
465 } desc;
466
467 if (!(picture_info && bitstream_buffers))
468 return VDP_STATUS_INVALID_POINTER;
469
470 vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
471 if (!vldecoder)
472 return VDP_STATUS_INVALID_HANDLE;
473 dec = vldecoder->decoder;
474 screen = dec->context->screen;
475
476 vlsurf = (vlVdpSurface *)vlGetDataHTAB(target);
477 if (!vlsurf)
478 return VDP_STATUS_INVALID_HANDLE;
479
480 if (vlsurf->device != vldecoder->device)
481 return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
482
483 if (vlsurf->video_buffer != NULL && vlsurf->video_buffer->chroma_format != dec->chroma_format)
484 // TODO: Recreate decoder with correct chroma
485 return VDP_STATUS_INVALID_CHROMA_TYPE;
486
487 buffer_support[0] = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
488 PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE);
489 buffer_support[1] = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
490 PIPE_VIDEO_CAP_SUPPORTS_INTERLACED);
491
492 if (vlsurf->video_buffer == NULL ||
493 !screen->is_video_format_supported(screen, vlsurf->video_buffer->buffer_format,
494 dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM) ||
495 !buffer_support[vlsurf->video_buffer->interlaced]) {
496
497 pipe_mutex_lock(vlsurf->device->mutex);
498
499 /* destroy the old one */
500 if (vlsurf->video_buffer)
501 vlsurf->video_buffer->destroy(vlsurf->video_buffer);
502
503 /* set the buffer format to the prefered one */
504 vlsurf->templat.buffer_format = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
505 PIPE_VIDEO_CAP_PREFERED_FORMAT);
506
507 /* also set interlacing to decoders preferences */
508 vlsurf->templat.interlaced = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
509 PIPE_VIDEO_CAP_PREFERS_INTERLACED);
510
511 /* and recreate the video buffer */
512 vlsurf->video_buffer = dec->context->create_video_buffer(dec->context, &vlsurf->templat);
513
514 /* still no luck? get me out of here... */
515 if (!vlsurf->video_buffer) {
516 pipe_mutex_unlock(vlsurf->device->mutex);
517 return VDP_STATUS_NO_IMPLEMENTATION;
518 }
519 vlVdpVideoSurfaceClear(vlsurf);
520 pipe_mutex_unlock(vlsurf->device->mutex);
521 }
522
523 for (i = 0; i < bitstream_buffer_count; ++i) {
524 buffers[i] = bitstream_buffers[i].bitstream;
525 sizes[i] = bitstream_buffers[i].bitstream_bytes;
526 }
527
528 memset(&desc, 0, sizeof(desc));
529 desc.base.profile = dec->profile;
530 switch (u_reduce_video_profile(dec->profile)) {
531 case PIPE_VIDEO_FORMAT_MPEG12:
532 ret = vlVdpDecoderRenderMpeg12(&desc.mpeg12, (VdpPictureInfoMPEG1Or2 *)picture_info);
533 break;
534 case PIPE_VIDEO_FORMAT_MPEG4:
535 ret = vlVdpDecoderRenderMpeg4(&desc.mpeg4, (VdpPictureInfoMPEG4Part2 *)picture_info);
536 break;
537 case PIPE_VIDEO_FORMAT_VC1:
538 if (dec->profile == PIPE_VIDEO_PROFILE_VC1_ADVANCED)
539 vlVdpDecoderFixVC1Startcode(&bitstream_buffer_count, buffers, sizes);
540 ret = vlVdpDecoderRenderVC1(&desc.vc1, (VdpPictureInfoVC1 *)picture_info);
541 break;
542 case PIPE_VIDEO_FORMAT_MPEG4_AVC:
543 desc.h264.pps = &pps;
544 ret = vlVdpDecoderRenderH264(&desc.h264, (VdpPictureInfoH264 *)picture_info);
545 break;
546 default:
547 return VDP_STATUS_INVALID_DECODER_PROFILE;
548 }
549
550 if (ret != VDP_STATUS_OK)
551 return ret;
552
553 pipe_mutex_lock(vldecoder->mutex);
554 dec->begin_frame(dec, vlsurf->video_buffer, &desc.base);
555 dec->decode_bitstream(dec, vlsurf->video_buffer, &desc.base, bitstream_buffer_count, buffers, sizes);
556 dec->end_frame(dec, vlsurf->video_buffer, &desc.base);
557 pipe_mutex_unlock(vldecoder->mutex);
558 return ret;
559 }