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:
77 VDPAUHWContext *hwctx = avctx->hwaccel_context;
78 VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
79 VdpVideoSurfaceQueryCapabilities *surface_query_caps;
80 VdpDecoderQueryCapabilities *decoder_query_caps;
85 uint32_t max_level, max_mb, max_width, max_height;
87 uint32_t
width = (avctx->coded_width + 1) & ~1;
88 uint32_t
height = (avctx->coded_height + 3) & ~3;
90 vdctx->width = UINT32_MAX;
91 vdctx->height = UINT32_MAX;
94 vdctx->
device = VDP_INVALID_HANDLE;
95 av_log(avctx,
AV_LOG_WARNING,
"hwaccel_context has not been setup by the user application, cannot initialize\n");
99 if (hwctx->context.decoder != VDP_INVALID_HANDLE) {
100 vdctx->
decoder = hwctx->context.decoder;
101 vdctx->render = hwctx->context.render;
102 vdctx->
device = VDP_INVALID_HANDLE;
107 vdctx->
device = hwctx->device;
116 VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
118 if (status != VDP_STATUS_OK)
121 surface_query_caps =
func;
123 status = surface_query_caps(vdctx->
device, VDP_CHROMA_TYPE_420, &supported,
124 &max_width, &max_height);
125 if (status != VDP_STATUS_OK)
127 if (supported != VDP_TRUE ||
128 max_width < width || max_height < height)
132 VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,
134 if (status != VDP_STATUS_OK)
137 decoder_query_caps =
func;
139 status = decoder_query_caps(vdctx->
device, profile, &supported, &max_level,
140 &max_mb, &max_width, &max_height);
141 if (status != VDP_STATUS_OK)
144 if (supported != VDP_TRUE || max_level < level ||
145 max_width < width || max_height < height)
150 if (status != VDP_STATUS_OK)
157 if (status != VDP_STATUS_OK)
160 vdctx->render =
func;
162 status =
create(vdctx->
device, profile, width, height, avctx->refs,
164 if (status == VDP_STATUS_OK) {
165 vdctx->width = avctx->coded_width;
166 vdctx->height = avctx->coded_height;
179 if (vdctx->
device == VDP_INVALID_HANDLE)
181 if (vdctx->width == UINT32_MAX && vdctx->height == UINT32_MAX)
185 VDP_FUNC_ID_DECODER_DESTROY, &func);
186 if (status != VDP_STATUS_OK)
200 if (vdctx->
device == VDP_INVALID_HANDLE)
214 pic_ctx->bitstream_buffers_allocated = 0;
215 pic_ctx->bitstream_buffers_used = 0;
216 pic_ctx->bitstream_buffers = NULL;
221 struct vdpau_picture_context *pic_ctx)
233 #if FF_API_BUFS_VDPAU
235 hwctx->
info = pic_ctx->info;
243 status = hwctx->
render2(avctx, frame, (
void *)&pic_ctx->info,
244 pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
246 status = vdctx->render(vdctx->
decoder, surf, (
void *)&pic_ctx->info,
247 pic_ctx->bitstream_buffers_used,
248 pic_ctx->bitstream_buffers);
250 av_freep(&pic_ctx->bitstream_buffers);
252 #if FF_API_BUFS_VDPAU
263 #if CONFIG_H263_VDPAU_HWACCEL || CONFIG_MPEG1_VDPAU_HWACCEL || \
264 CONFIG_MPEG2_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL || \
265 CONFIG_VC1_VDPAU_HWACCEL || CONFIG_WMV3_VDPAU_HWACCEL
285 VdpBitstreamBuffer *
buffers = pic_ctx->bitstream_buffers;
287 buffers =
av_fast_realloc(buffers, &pic_ctx->bitstream_buffers_allocated,
288 (pic_ctx->bitstream_buffers_used + 1) *
sizeof(*buffers));
292 pic_ctx->bitstream_buffers =
buffers;
293 buffers += pic_ctx->bitstream_buffers_used++;
295 buffers->struct_version = VDP_BITSTREAM_BUFFER_VERSION;
296 buffers->bitstream =
buf;
297 buffers->bitstream_bytes =
size;
306 VdpReferenceFrameH264 *rf, *rf2;
308 int i, list, pic_frame_idx;
313 rf = &render->
info.
h264.referenceFrames[0];
314 #define H264_RF_COUNT FF_ARRAY_ELEMS(render->info.h264.referenceFrames)
316 for (list = 0; list < 2; ++list) {
320 for (i = 0; i < ls; ++i) {
329 rf2 = &render->
info.
h264.referenceFrames[0];
332 (rf2->surface == render_ref->
surface)
333 && (rf2->is_long_term == pic->
long_ref)
334 && (rf2->frame_idx == pic_frame_idx)
348 rf->surface = render_ref->
surface;
352 rf->field_order_cnt[0] = pic->
field_poc[0];
353 rf->field_order_cnt[1] = pic->
field_poc[1];
354 rf->frame_idx = pic_frame_idx;
361 rf->surface = VDP_INVALID_HANDLE;
362 rf->is_long_term = 0;
363 rf->top_is_reference = 0;
364 rf->bottom_is_reference = 0;
365 rf->field_order_cnt[0] = 0;
366 rf->field_order_cnt[1] = 0;
388 #if CONFIG_H264_VDPAU_DECODER
397 for (i = 0; i < 2; ++i) {
401 render->
info.
h264.field_order_cnt[i] = foc;
415 if (render->
info.
h264.slice_count < 1)
451 #if CONFIG_MPEG_VDPAU_DECODER || CONFIG_MPEG1_VDPAU_DECODER
453 int buf_size,
int slice_count)
479 for (i = 0; i < 64; ++i) {
484 render->
info.
mpeg.forward_reference = VDP_INVALID_HANDLE;
485 render->
info.
mpeg.backward_reference = VDP_INVALID_HANDLE;
502 render->
info.
mpeg.slice_count = slice_count;
510 #if CONFIG_VC1_VDPAU_DECODER
521 render->
info.
vc1.frame_coding_mode = v->
fcm ? v->
fcm + 1 : 0;
551 render->
info.
vc1.forward_reference = VDP_INVALID_HANDLE;
552 render->
info.
vc1.backward_reference = VDP_INVALID_HANDLE;
555 render->
info.
vc1.picture_type = 4;
574 render->
info.
vc1.slice_count = 1;
581 #if CONFIG_MPEG4_VDPAU_DECODER
611 for (i = 0; i < 64; ++i) {
615 render->
info.
mpeg4.forward_reference = VDP_INVALID_HANDLE;
616 render->
info.
mpeg4.backward_reference = VDP_INVALID_HANDLE;
640 #define PROFILE(prof) \
652 default:
return AVERROR(EINVAL);
659 default:
return AVERROR(EINVAL);
667 default:
return AVERROR(EINVAL);
675 default:
return AVERROR(EINVAL);
687 VdpGetProcAddress *get_proc,
unsigned flags)
689 VDPAUHWContext *hwctx;
699 memset(hwctx, 0,
sizeof(*hwctx));
700 hwctx->context.decoder = VDP_INVALID_HANDLE;
701 hwctx->device = device;
702 hwctx->get_proc_address = get_proc;
703 hwctx->flags =
flags;