48 case VDP_STATUS_NO_IMPLEMENTATION:
50 case VDP_STATUS_DISPLAY_PREEMPTED:
52 case VDP_STATUS_INVALID_HANDLE:
54 case VDP_STATUS_INVALID_POINTER:
56 case VDP_STATUS_RESOURCES:
58 case VDP_STATUS_HANDLE_DEVICE_MISMATCH:
60 case VDP_STATUS_ERROR:
79 uint32_t w = avctx->coded_width;
80 uint32_t h = avctx->coded_height;
83 switch (avctx->sw_pix_fmt) {
86 t = VDP_CHROMA_TYPE_420;
92 t = VDP_CHROMA_TYPE_422;
98 t = VDP_CHROMA_TYPE_444;
119 VdpVideoSurfaceQueryCapabilities *surface_query_caps;
120 VdpDecoderQueryCapabilities *decoder_query_caps;
125 uint32_t max_level, max_mb, max_width, max_height;
130 vdctx->width = UINT32_MAX;
131 vdctx->height = UINT32_MAX;
134 vdctx->
device = VDP_INVALID_HANDLE;
135 av_log(avctx,
AV_LOG_WARNING,
"hwaccel_context has not been setup by the user application, cannot initialize\n");
139 if (hwctx->context.decoder != VDP_INVALID_HANDLE) {
140 vdctx->
decoder = hwctx->context.decoder;
141 vdctx->render = hwctx->context.render;
142 vdctx->
device = VDP_INVALID_HANDLE;
147 vdctx->
device = hwctx->device;
159 type != VDP_CHROMA_TYPE_420)
163 VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
165 if (status != VDP_STATUS_OK)
168 surface_query_caps =
func;
170 status = surface_query_caps(vdctx->
device, type, &supported,
171 &max_width, &max_height);
172 if (status != VDP_STATUS_OK)
174 if (supported != VDP_TRUE ||
175 max_width < width || max_height < height)
179 VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,
181 if (status != VDP_STATUS_OK)
184 decoder_query_caps =
func;
186 status = decoder_query_caps(vdctx->
device, profile, &supported, &max_level,
187 &max_mb, &max_width, &max_height);
188 #ifdef VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE
189 if (status != VDP_STATUS_OK && profile == VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE) {
191 profile = VDP_DECODER_PROFILE_H264_MAIN;
192 status = decoder_query_caps(vdctx->
device, profile, &supported,
194 &max_width, &max_height);
197 if (status != VDP_STATUS_OK)
200 if (supported != VDP_TRUE || max_level < level ||
201 max_width < width || max_height < height)
206 if (status != VDP_STATUS_OK)
213 if (status != VDP_STATUS_OK)
216 vdctx->render =
func;
220 if (status == VDP_STATUS_OK) {
235 if (vdctx->
device == VDP_INVALID_HANDLE)
237 if (vdctx->width == UINT32_MAX && vdctx->height == UINT32_MAX)
241 VDP_FUNC_ID_DECODER_DESTROY, &func);
242 if (status != VDP_STATUS_OK)
256 if (vdctx->
device == VDP_INVALID_HANDLE)
270 pic_ctx->bitstream_buffers_allocated = 0;
271 pic_ctx->bitstream_buffers_used = 0;
272 pic_ctx->bitstream_buffers =
NULL;
277 struct vdpau_picture_context *pic_ctx)
289 #if FF_API_BUFS_VDPAU
292 memcpy(&hwctx->
info, &pic_ctx->info,
sizeof(hwctx->
info));
300 status = hwctx->
render2(avctx, frame, (
void *)&pic_ctx->info,
301 pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
303 status = vdctx->render(vdctx->
decoder, surf, (
void *)&pic_ctx->info,
304 pic_ctx->bitstream_buffers_used,
305 pic_ctx->bitstream_buffers);
307 av_freep(&pic_ctx->bitstream_buffers);
309 #if FF_API_BUFS_VDPAU
320 #if CONFIG_H263_VDPAU_HWACCEL || CONFIG_MPEG1_VDPAU_HWACCEL || \
321 CONFIG_MPEG2_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL || \
322 CONFIG_VC1_VDPAU_HWACCEL || CONFIG_WMV3_VDPAU_HWACCEL
342 VdpBitstreamBuffer *
buffers = pic_ctx->bitstream_buffers;
344 buffers =
av_fast_realloc(buffers, &pic_ctx->bitstream_buffers_allocated,
345 (pic_ctx->bitstream_buffers_used + 1) *
sizeof(*buffers));
349 pic_ctx->bitstream_buffers =
buffers;
350 buffers += pic_ctx->bitstream_buffers_used++;
352 buffers->struct_version = VDP_BITSTREAM_BUFFER_VERSION;
353 buffers->bitstream =
buf;
354 buffers->bitstream_bytes =
size;
363 VdpReferenceFrameH264 *rf, *rf2;
365 int i, list, pic_frame_idx;
370 rf = &render->
info.
h264.referenceFrames[0];
371 #define H264_RF_COUNT FF_ARRAY_ELEMS(render->info.h264.referenceFrames)
373 for (list = 0; list < 2; ++list) {
377 for (i = 0; i < ls; ++i) {
386 rf2 = &render->
info.
h264.referenceFrames[0];
389 (rf2->surface == render_ref->
surface)
390 && (rf2->is_long_term == pic->
long_ref)
391 && (rf2->frame_idx == pic_frame_idx)
405 rf->surface = render_ref->
surface;
409 rf->field_order_cnt[0] = pic->
field_poc[0];
410 rf->field_order_cnt[1] = pic->
field_poc[1];
411 rf->frame_idx = pic_frame_idx;
418 rf->surface = VDP_INVALID_HANDLE;
419 rf->is_long_term = 0;
420 rf->top_is_reference = 0;
421 rf->bottom_is_reference = 0;
422 rf->field_order_cnt[0] = 0;
423 rf->field_order_cnt[1] = 0;
445 #if CONFIG_H264_VDPAU_DECODER
454 for (i = 0; i < 2; ++i) {
458 render->
info.
h264.field_order_cnt[i] = foc;
472 if (render->
info.
h264.slice_count < 1)
508 #if CONFIG_MPEG_VDPAU_DECODER || CONFIG_MPEG1_VDPAU_DECODER
510 int buf_size,
int slice_count)
536 for (i = 0; i < 64; ++i) {
541 render->
info.
mpeg.forward_reference = VDP_INVALID_HANDLE;
542 render->
info.
mpeg.backward_reference = VDP_INVALID_HANDLE;
559 render->
info.
mpeg.slice_count = slice_count;
567 #if CONFIG_VC1_VDPAU_DECODER
578 render->
info.
vc1.frame_coding_mode = v->
fcm ? v->
fcm + 1 : 0;
608 render->
info.
vc1.forward_reference = VDP_INVALID_HANDLE;
609 render->
info.
vc1.backward_reference = VDP_INVALID_HANDLE;
612 render->
info.
vc1.picture_type = 4;
631 render->
info.
vc1.slice_count = 1;
638 #if CONFIG_MPEG4_VDPAU_DECODER
668 for (i = 0; i < 64; ++i) {
672 render->
info.
mpeg4.forward_reference = VDP_INVALID_HANDLE;
673 render->
info.
mpeg4.backward_reference = VDP_INVALID_HANDLE;
697 #define PROFILE(prof) \
699 *profile = VDP_DECODER_PROFILE_##prof; \
709 default:
return AVERROR(EINVAL);
716 default:
return AVERROR(EINVAL);
724 #ifdef VDP_DECODER_PROFILE_H264_EXTENDED
727 default:
return AVERROR(EINVAL);
735 default:
return AVERROR(EINVAL);
748 VdpGetProcAddress *get_proc,
unsigned flags)
750 VDPAUHWContext *hwctx;
760 memset(hwctx, 0,
sizeof(*hwctx));
761 hwctx->context.decoder = VDP_INVALID_HANDLE;
762 hwctx->device = device;
763 hwctx->get_proc_address = get_proc;
764 hwctx->flags =
flags;