static void destroy_objects(struct gl_hwdec *hw) { struct priv *p = hw->priv; GL *gl = hw->gl; struct vdp_functions *vdp = &p->ctx->vdp; VdpStatus vdp_st; if (p->mapped) gl->VDPAUUnmapSurfacesNV(1, &p->vdpgl_surface); p->mapped = false; if (p->vdpgl_surface) gl->VDPAUUnregisterSurfaceNV(p->vdpgl_surface); p->vdpgl_surface = 0; glDeleteTextures(1, &p->gl_texture); p->gl_texture = 0; if (p->vdp_surface != VDP_INVALID_HANDLE) { vdp_st = vdp->output_surface_destroy(p->vdp_surface); CHECK_VDP_WARNING(p, "Error when calling vdp_output_surface_destroy"); } p->vdp_surface = VDP_INVALID_HANDLE; glCheckError(gl, hw->log, "Before uninitializing OpenGL interop"); if (p->vdpgl_initialized) gl->VDPAUFiniNV(); p->vdpgl_initialized = false; glCheckError(gl, hw->log, "After uninitializing OpenGL interop"); }
static void destroy_objects(struct gl_hwdec *hw) { struct priv *p = hw->priv; GL *gl = hw->gl; struct vdp_functions *vdp = &p->ctx->vdp; VdpStatus vdp_st; if (p->mapped) gl->VDPAUUnmapSurfacesNV(1, &p->vdpgl_surface); p->mapped = false; if (p->vdpgl_surface) gl->VDPAUUnregisterSurfaceNV(p->vdpgl_surface); p->vdpgl_surface = 0; glDeleteTextures(1, &p->gl_texture); p->gl_texture = 0; if (p->vdp_surface != VDP_INVALID_HANDLE) { vdp_st = vdp->output_surface_destroy(p->vdp_surface); CHECK_VDP_WARNING(p, "Error when calling vdp_output_surface_destroy"); } p->vdp_surface = VDP_INVALID_HANDLE; glCheckError(gl, hw->log, "Before uninitializing OpenGL interop"); gl->VDPAUFiniNV(); // If the GL/vdpau state is not initialized, above calls raises an error. while (1) { if (gl->GetError() == GL_NO_ERROR) break; } }
static int filter_ext(struct vf_instance *vf, struct mp_image *mpi) { VdpStatus vdp_st; struct vf_priv_s *p = vf->priv; struct mp_vdpau_ctx *ctx = p->ctx; struct vdp_functions *vdp = &ctx->vdp; if (!mpi) { return 0; } // Pass-through anything that's not been decoded by VDPAU if (mpi->imgfmt != IMGFMT_VDPAU) { vf_add_output_frame(vf, mpi); return 0; } if (mp_vdpau_mixed_frame_get(mpi)) { MP_ERR(vf, "Can't apply vdpaurb filter after vdpaupp filter.\n"); mp_image_unrefp(&mpi); return -1; } struct mp_image *out = vf_alloc_out_image(vf); if (!out) { mp_image_unrefp(&mpi); return -1; } mp_image_copy_attributes(out, mpi); VdpVideoSurface surface = (uintptr_t)mpi->planes[3]; assert(surface > 0); vdp_st = vdp->video_surface_get_bits_y_cb_cr(surface, VDP_YCBCR_FORMAT_NV12, (void * const *)out->planes, out->stride); CHECK_VDP_WARNING(vf, "Error when calling vdp_output_surface_get_bits_y_cb_cr"); vf_add_output_frame(vf, out); mp_image_unrefp(&mpi); return 0; }
static int render_video_to_output_surface(struct vo *vo, VdpOutputSurface output_surface, VdpRect *output_rect, VdpRect *video_rect) { struct vdpctx *vc = vo->priv; struct vdp_functions *vdp = vc->vdp; VdpTime dummy; VdpStatus vdp_st; struct mp_image *mpi = vc->current_image; if (!mpi) { // At least clear the screen if there is nothing to render int flags = VDP_OUTPUT_SURFACE_RENDER_ROTATE_0; vdp_st = vdp->output_surface_render_output_surface(output_surface, NULL, vc->black_pixel, NULL, NULL, NULL, flags); return -1; } vdp_st = vdp->presentation_queue_block_until_surface_idle(vc->flip_queue, output_surface, &dummy); CHECK_VDP_WARNING(vo, "Error when calling " "vdp_presentation_queue_block_until_surface_idle"); if (vc->rgb_mode) { VdpOutputSurface surface = (uintptr_t)mpi->planes[3]; int flags = VDP_OUTPUT_SURFACE_RENDER_ROTATE_0; vdp_st = vdp->output_surface_render_output_surface(output_surface, NULL, vc->black_pixel, NULL, NULL, NULL, flags); CHECK_VDP_WARNING(vo, "Error clearing screen"); vdp_st = vdp->output_surface_render_output_surface(output_surface, output_rect, surface, video_rect, NULL, NULL, flags); CHECK_VDP_WARNING(vo, "Error when calling " "vdp_output_surface_render_output_surface"); return 0; } struct mp_vdpau_mixer_frame *frame = mp_vdpau_mixed_frame_get(mpi); struct mp_vdpau_mixer_opts opts = {0}; if (frame) opts = frame->opts; // Apply custom vo_vdpau suboptions. opts.chroma_deint |= vc->chroma_deint; opts.pullup |= vc->pullup; opts.denoise = MPCLAMP(opts.denoise + vc->denoise, 0, 1); opts.sharpen = MPCLAMP(opts.sharpen + vc->sharpen, -1, 1); if (vc->hqscaling) opts.hqscaling = vc->hqscaling; mp_vdpau_mixer_render(vc->video_mixer, &opts, output_surface, output_rect, mpi, video_rect); return 0; }