static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image, GLuint *out_textures) { struct priv *p = hw->priv; GL *gl = hw->gl; assert(hw_image && hw_image->imgfmt == IMGFMT_VDPAU); int pe = mp_vdpau_handle_preemption(p->ctx, &p->preemption_counter); if (pe < 1) { mark_vdpau_objects_uninitialized(hw); if (pe < 0) return -1; if (reinit(hw, &p->image_params) < 0) return -1; } if (!p->vdpgl_surface) return -1; if (p->mapped) gl->VDPAUUnmapSurfacesNV(1, &p->vdpgl_surface); mp_vdpau_mixer_render(p->mixer, NULL, p->vdp_surface, NULL, hw_image, NULL); gl->VDPAUMapSurfacesNV(1, &p->vdpgl_surface); p->mapped = true; out_textures[0] = p->gl_texture; return 0; }
static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image, GLuint *out_textures) { struct priv *p = hw->priv; GL *gl = hw->mpgl->gl; assert(hw_image && hw_image->imgfmt == IMGFMT_VDPAU); if (handle_preemption(hw) < 0) return -1; if (!p->vdpgl_surface) return -1; mp_vdpau_mixer_render(p->mixer, NULL, p->vdp_surface, NULL, hw_image, NULL); gl->VDPAUMapSurfacesNV(1, &p->vdpgl_surface); out_textures[0] = p->gl_texture; 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; }