st/nine: Correctly declare NineTranslateInstruction_Mkxn inputs
[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 DeviceReference(&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 DeviceReference(&vldecoder->device, NULL);
145 FREE(vldecoder);
146 return ret;
147 }
148
149 /**
150 * Destroy a VdpDecoder.
151 */
152 VdpStatus
153 vlVdpDecoderDestroy(VdpDecoder decoder)
154 {
155 vlVdpDecoder *vldecoder;
156
157 vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
158 if (!vldecoder)
159 return VDP_STATUS_INVALID_HANDLE;
160
161 pipe_mutex_lock(vldecoder->mutex);
162 vldecoder->decoder->destroy(vldecoder->decoder);
163 pipe_mutex_unlock(vldecoder->mutex);
164 pipe_mutex_destroy(vldecoder->mutex);
165
166 vlRemoveDataHTAB(decoder);
167 DeviceReference(&vldecoder->device, NULL);
168 FREE(vldecoder);
169
170 return VDP_STATUS_OK;
171 }
172
173 /**
174 * Retrieve the parameters used to create a VdpDecoder.
175 */
176 VdpStatus
177 vlVdpDecoderGetParameters(VdpDecoder decoder,
178 VdpDecoderProfile *profile,
179 uint32_t *width,
180 uint32_t *height)
181 {
182 vlVdpDecoder *vldecoder;
183
184 vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
185 if (!vldecoder)
186 return VDP_STATUS_INVALID_HANDLE;
187
188 *profile = PipeToProfile(vldecoder->decoder->profile);
189 *width = vldecoder->decoder->width;
190 *height = vldecoder->decoder->height;
191
192 return VDP_STATUS_OK;
193 }
194
195 static VdpStatus
196 vlVdpGetReferenceFrame(VdpVideoSurface handle, struct pipe_video_buffer **ref_frame)
197 {
198 vlVdpSurface *surface;
199
200 /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */
201 if (handle == VDP_INVALID_HANDLE) {
202 *ref_frame = NULL;
203 return VDP_STATUS_OK;
204 }
205
206 surface = vlGetDataHTAB(handle);
207 if (!surface)
208 return VDP_STATUS_INVALID_HANDLE;
209
210 *ref_frame = surface->video_buffer;
211 if (!*ref_frame)
212 return VDP_STATUS_INVALID_HANDLE;
213
214 return VDP_STATUS_OK;
215 }
216
217 /**
218 * Decode a mpeg 1/2 video.
219 */
220 static VdpStatus
221 vlVdpDecoderRenderMpeg12(struct pipe_mpeg12_picture_desc *picture,
222 VdpPictureInfoMPEG1Or2 *picture_info)
223 {
224 VdpStatus r;
225
226 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG12\n");
227
228 r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]);
229 if (r != VDP_STATUS_OK)
230 return r;
231
232 r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]);
233 if (r != VDP_STATUS_OK)
234 return r;
235
236 picture->picture_coding_type = picture_info->picture_coding_type;
237 picture->picture_structure = picture_info->picture_structure;
238 picture->frame_pred_frame_dct = picture_info->frame_pred_frame_dct;
239 picture->q_scale_type = picture_info->q_scale_type;
240 picture->alternate_scan = picture_info->alternate_scan;
241 picture->intra_vlc_format = picture_info->intra_vlc_format;
242 picture->concealment_motion_vectors = picture_info->concealment_motion_vectors;
243 picture->intra_dc_precision = picture_info->intra_dc_precision;
244 picture->f_code[0][0] = picture_info->f_code[0][0] - 1;
245 picture->f_code[0][1] = picture_info->f_code[0][1] - 1;
246 picture->f_code[1][0] = picture_info->f_code[1][0] - 1;
247 picture->f_code[1][1] = picture_info->f_code[1][1] - 1;
248 picture->num_slices = picture_info->slice_count;
249 picture->top_field_first = picture_info->top_field_first;
250 picture->full_pel_forward_vector = picture_info->full_pel_forward_vector;
251 picture->full_pel_backward_vector = picture_info->full_pel_backward_vector;
252 picture->intra_matrix = picture_info->intra_quantizer_matrix;
253 picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix;
254
255 return VDP_STATUS_OK;
256 }
257
258 /**
259 * Decode a mpeg 4 video.
260 */
261 static VdpStatus
262 vlVdpDecoderRenderMpeg4(struct pipe_mpeg4_picture_desc *picture,
263 VdpPictureInfoMPEG4Part2 *picture_info)
264 {
265 VdpStatus r;
266 unsigned i;
267
268 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG4\n");
269
270 r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]);
271 if (r != VDP_STATUS_OK)
272 return r;
273
274 r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]);
275 if (r != VDP_STATUS_OK)
276 return r;
277
278 for (i = 0; i < 2; ++i) {
279 picture->trd[i] = picture_info->trd[i];
280 picture->trb[i] = picture_info->trb[i];
281 }
282 picture->vop_time_increment_resolution = picture_info->vop_time_increment_resolution;
283 picture->vop_coding_type = picture_info->vop_coding_type;
284 picture->vop_fcode_forward = picture_info->vop_fcode_forward;
285 picture->vop_fcode_backward = picture_info->vop_fcode_backward;
286 picture->resync_marker_disable = picture_info->resync_marker_disable;
287 picture->interlaced = picture_info->interlaced;
288 picture->quant_type = picture_info->quant_type;
289 picture->quarter_sample = picture_info->quarter_sample;
290 picture->short_video_header = picture_info->short_video_header;
291 picture->rounding_control = picture_info->rounding_control;
292 picture->alternate_vertical_scan_flag = picture_info->alternate_vertical_scan_flag;
293 picture->top_field_first = picture_info->top_field_first;
294 picture->intra_matrix = picture_info->intra_quantizer_matrix;
295 picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix;
296
297 return VDP_STATUS_OK;
298 }
299
300 static VdpStatus
301 vlVdpDecoderRenderVC1(struct pipe_vc1_picture_desc *picture,
302 VdpPictureInfoVC1 *picture_info)
303 {
304 VdpStatus r;
305
306 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding VC-1\n");
307
308 r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]);
309 if (r != VDP_STATUS_OK)
310 return r;
311
312 r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]);
313 if (r != VDP_STATUS_OK)
314 return r;
315
316 picture->slice_count = picture_info->slice_count;
317 picture->picture_type = picture_info->picture_type;
318 picture->frame_coding_mode = picture_info->frame_coding_mode;
319 picture->postprocflag = picture_info->postprocflag;
320 picture->pulldown = picture_info->pulldown;
321 picture->interlace = picture_info->interlace;
322 picture->tfcntrflag = picture_info->tfcntrflag;
323 picture->finterpflag = picture_info->finterpflag;
324 picture->psf = picture_info->psf;
325 picture->dquant = picture_info->dquant;
326 picture->panscan_flag = picture_info->panscan_flag;
327 picture->refdist_flag = picture_info->refdist_flag;
328 picture->quantizer = picture_info->quantizer;
329 picture->extended_mv = picture_info->extended_mv;
330 picture->extended_dmv = picture_info->extended_dmv;
331 picture->overlap = picture_info->overlap;
332 picture->vstransform = picture_info->vstransform;
333 picture->loopfilter = picture_info->loopfilter;
334 picture->fastuvmc = picture_info->fastuvmc;
335 picture->range_mapy_flag = picture_info->range_mapy_flag;
336 picture->range_mapy = picture_info->range_mapy;
337 picture->range_mapuv_flag = picture_info->range_mapuv_flag;
338 picture->range_mapuv = picture_info->range_mapuv;
339 picture->multires = picture_info->multires;
340 picture->syncmarker = picture_info->syncmarker;
341 picture->rangered = picture_info->rangered;
342 picture->maxbframes = picture_info->maxbframes;
343 picture->deblockEnable = picture_info->deblockEnable;
344 picture->pquant = picture_info->pquant;
345
346 return VDP_STATUS_OK;
347 }
348
349 static VdpStatus
350 vlVdpDecoderRenderH264(struct pipe_h264_picture_desc *picture,
351 VdpPictureInfoH264 *picture_info)
352 {
353 unsigned i;
354
355 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding H264\n");
356
357 picture->pps->sps->mb_adaptive_frame_field_flag = picture_info->mb_adaptive_frame_field_flag;
358 picture->pps->sps->frame_mbs_only_flag = picture_info->frame_mbs_only_flag;
359 picture->pps->sps->log2_max_frame_num_minus4 = picture_info->log2_max_frame_num_minus4;
360 picture->pps->sps->pic_order_cnt_type = picture_info->pic_order_cnt_type;
361 picture->pps->sps->log2_max_pic_order_cnt_lsb_minus4 = picture_info->log2_max_pic_order_cnt_lsb_minus4;
362 picture->pps->sps->delta_pic_order_always_zero_flag = picture_info->delta_pic_order_always_zero_flag;
363 picture->pps->sps->direct_8x8_inference_flag = picture_info->direct_8x8_inference_flag;
364
365 picture->pps->transform_8x8_mode_flag = picture_info->transform_8x8_mode_flag;
366 picture->pps->chroma_qp_index_offset = picture_info->chroma_qp_index_offset;
367 picture->pps->second_chroma_qp_index_offset = picture_info->second_chroma_qp_index_offset;
368 picture->pps->pic_init_qp_minus26 = picture_info->pic_init_qp_minus26;
369 picture->pps->entropy_coding_mode_flag = picture_info->entropy_coding_mode_flag;
370 picture->pps->deblocking_filter_control_present_flag = picture_info->deblocking_filter_control_present_flag;
371 picture->pps->redundant_pic_cnt_present_flag = picture_info->redundant_pic_cnt_present_flag;
372 picture->pps->constrained_intra_pred_flag = picture_info->constrained_intra_pred_flag;
373 picture->pps->weighted_pred_flag = picture_info->weighted_pred_flag;
374 picture->pps->weighted_bipred_idc = picture_info->weighted_bipred_idc;
375 picture->pps->bottom_field_pic_order_in_frame_present_flag = picture_info->pic_order_present_flag;
376 memcpy(picture->pps->ScalingList4x4, picture_info->scaling_lists_4x4, 6*16);
377 memcpy(picture->pps->ScalingList8x8, picture_info->scaling_lists_8x8, 2*64);
378
379 picture->slice_count = picture_info->slice_count;
380 picture->field_order_cnt[0] = picture_info->field_order_cnt[0];
381 picture->field_order_cnt[1] = picture_info->field_order_cnt[1];
382 picture->is_reference = picture_info->is_reference;
383 picture->frame_num = picture_info->frame_num;
384 picture->field_pic_flag = picture_info->field_pic_flag;
385 picture->bottom_field_flag = picture_info->bottom_field_flag;
386 picture->num_ref_frames = picture_info->num_ref_frames;
387
388 picture->num_ref_idx_l0_active_minus1 = picture_info->num_ref_idx_l0_active_minus1;
389 picture->num_ref_idx_l1_active_minus1 = picture_info->num_ref_idx_l1_active_minus1;
390
391 for (i = 0; i < 16; ++i) {
392 VdpStatus ret = vlVdpGetReferenceFrame
393 (
394 picture_info->referenceFrames[i].surface,
395 &picture->ref[i]
396 );
397 if (ret != VDP_STATUS_OK)
398 return ret;
399
400 picture->is_long_term[i] = picture_info->referenceFrames[i].is_long_term;
401 picture->top_is_reference[i] = picture_info->referenceFrames[i].top_is_reference;
402 picture->bottom_is_reference[i] = picture_info->referenceFrames[i].bottom_is_reference;
403 picture->field_order_cnt_list[i][0] = picture_info->referenceFrames[i].field_order_cnt[0];
404 picture->field_order_cnt_list[i][1] = picture_info->referenceFrames[i].field_order_cnt[1];
405 picture->frame_num_list[i] = picture_info->referenceFrames[i].frame_idx;
406 }
407
408 return VDP_STATUS_OK;
409 }
410
411 static void
412 vlVdpDecoderFixVC1Startcode(uint32_t *num_buffers, const void *buffers[], unsigned sizes[])
413 {
414 static const uint8_t vc1_startcode[] = { 0x00, 0x00, 0x01, 0x0D };
415 struct vl_vlc vlc;
416 unsigned i;
417
418 /* search the first 64 bytes for a startcode */
419 vl_vlc_init(&vlc, *num_buffers, buffers, sizes);
420 while (vl_vlc_search_byte(&vlc, 64*8, 0x00) && vl_vlc_bits_left(&vlc) >= 32) {
421 uint32_t value = vl_vlc_peekbits(&vlc, 32);
422 if (value == 0x0000010D ||
423 value == 0x0000010C ||
424 value == 0x0000010B)
425 return;
426 vl_vlc_eatbits(&vlc, 8);
427 }
428
429 /* none found, ok add one manually */
430 VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Manually adding VC-1 startcode\n");
431 for (i = *num_buffers; i > 0; --i) {
432 buffers[i] = buffers[i - 1];
433 sizes[i] = sizes[i - 1];
434 }
435 ++(*num_buffers);
436 buffers[0] = vc1_startcode;
437 sizes[0] = 4;
438 }
439
440 /**
441 * Decode a compressed field/frame and render the result into a VdpVideoSurface.
442 */
443 VdpStatus
444 vlVdpDecoderRender(VdpDecoder decoder,
445 VdpVideoSurface target,
446 VdpPictureInfo const *picture_info,
447 uint32_t bitstream_buffer_count,
448 VdpBitstreamBuffer const *bitstream_buffers)
449 {
450 const void * buffers[bitstream_buffer_count + 1];
451 unsigned sizes[bitstream_buffer_count + 1];
452 vlVdpDecoder *vldecoder;
453 vlVdpSurface *vlsurf;
454 VdpStatus ret;
455 struct pipe_screen *screen;
456 struct pipe_video_codec *dec;
457 bool buffer_support[2];
458 unsigned i;
459 struct pipe_h264_sps sps = {};
460 struct pipe_h264_pps pps = { &sps };
461 union {
462 struct pipe_picture_desc base;
463 struct pipe_mpeg12_picture_desc mpeg12;
464 struct pipe_mpeg4_picture_desc mpeg4;
465 struct pipe_vc1_picture_desc vc1;
466 struct pipe_h264_picture_desc h264;
467 } desc;
468
469 if (!(picture_info && bitstream_buffers))
470 return VDP_STATUS_INVALID_POINTER;
471
472 vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
473 if (!vldecoder)
474 return VDP_STATUS_INVALID_HANDLE;
475 dec = vldecoder->decoder;
476 screen = dec->context->screen;
477
478 vlsurf = (vlVdpSurface *)vlGetDataHTAB(target);
479 if (!vlsurf)
480 return VDP_STATUS_INVALID_HANDLE;
481
482 if (vlsurf->device != vldecoder->device)
483 return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
484
485 if (vlsurf->video_buffer != NULL && vlsurf->video_buffer->chroma_format != dec->chroma_format)
486 // TODO: Recreate decoder with correct chroma
487 return VDP_STATUS_INVALID_CHROMA_TYPE;
488
489 buffer_support[0] = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
490 PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE);
491 buffer_support[1] = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
492 PIPE_VIDEO_CAP_SUPPORTS_INTERLACED);
493
494 if (vlsurf->video_buffer == NULL ||
495 !screen->is_video_format_supported(screen, vlsurf->video_buffer->buffer_format,
496 dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM) ||
497 !buffer_support[vlsurf->video_buffer->interlaced]) {
498
499 pipe_mutex_lock(vlsurf->device->mutex);
500
501 /* destroy the old one */
502 if (vlsurf->video_buffer)
503 vlsurf->video_buffer->destroy(vlsurf->video_buffer);
504
505 /* set the buffer format to the prefered one */
506 vlsurf->templat.buffer_format = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
507 PIPE_VIDEO_CAP_PREFERED_FORMAT);
508
509 /* also set interlacing to decoders preferences */
510 vlsurf->templat.interlaced = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
511 PIPE_VIDEO_CAP_PREFERS_INTERLACED);
512
513 /* and recreate the video buffer */
514 vlsurf->video_buffer = dec->context->create_video_buffer(dec->context, &vlsurf->templat);
515
516 /* still no luck? get me out of here... */
517 if (!vlsurf->video_buffer) {
518 pipe_mutex_unlock(vlsurf->device->mutex);
519 return VDP_STATUS_NO_IMPLEMENTATION;
520 }
521 vlVdpVideoSurfaceClear(vlsurf);
522 pipe_mutex_unlock(vlsurf->device->mutex);
523 }
524
525 for (i = 0; i < bitstream_buffer_count; ++i) {
526 buffers[i] = bitstream_buffers[i].bitstream;
527 sizes[i] = bitstream_buffers[i].bitstream_bytes;
528 }
529
530 memset(&desc, 0, sizeof(desc));
531 desc.base.profile = dec->profile;
532 switch (u_reduce_video_profile(dec->profile)) {
533 case PIPE_VIDEO_FORMAT_MPEG12:
534 ret = vlVdpDecoderRenderMpeg12(&desc.mpeg12, (VdpPictureInfoMPEG1Or2 *)picture_info);
535 break;
536 case PIPE_VIDEO_FORMAT_MPEG4:
537 ret = vlVdpDecoderRenderMpeg4(&desc.mpeg4, (VdpPictureInfoMPEG4Part2 *)picture_info);
538 break;
539 case PIPE_VIDEO_FORMAT_VC1:
540 if (dec->profile == PIPE_VIDEO_PROFILE_VC1_ADVANCED)
541 vlVdpDecoderFixVC1Startcode(&bitstream_buffer_count, buffers, sizes);
542 ret = vlVdpDecoderRenderVC1(&desc.vc1, (VdpPictureInfoVC1 *)picture_info);
543 break;
544 case PIPE_VIDEO_FORMAT_MPEG4_AVC:
545 desc.h264.pps = &pps;
546 ret = vlVdpDecoderRenderH264(&desc.h264, (VdpPictureInfoH264 *)picture_info);
547 break;
548 default:
549 return VDP_STATUS_INVALID_DECODER_PROFILE;
550 }
551
552 if (ret != VDP_STATUS_OK)
553 return ret;
554
555 pipe_mutex_lock(vldecoder->mutex);
556 dec->begin_frame(dec, vlsurf->video_buffer, &desc.base);
557 dec->decode_bitstream(dec, vlsurf->video_buffer, &desc.base, bitstream_buffer_count, buffers, sizes);
558 dec->end_frame(dec, vlsurf->video_buffer, &desc.base);
559 pipe_mutex_unlock(vldecoder->mutex);
560 return ret;
561 }