diff options
Diffstat (limited to 'video/out/vo_vdpau.c')
-rw-r--r-- | video/out/vo_vdpau.c | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index 67784941e4..b22dcba0ce 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -31,7 +31,6 @@ #include <limits.h> #include <assert.h> -#include "config.h" #include "video/vdpau.h" #include "video/vdpau_mixer.h" #include "video/hwdec.h" @@ -81,18 +80,18 @@ struct vdpctx { struct mp_image *current_image; int64_t current_pts; - int current_duration; + int64_t current_duration; int output_surface_w, output_surface_h; int rotation; - int force_yuv; + bool force_yuv; struct mp_vdpau_mixer *video_mixer; - int pullup; + bool pullup; float denoise; float sharpen; int hqscaling; - int chroma_deint; + bool chroma_deint; int flip_offset_window; int flip_offset_fs; int64_t flip_offset_us; @@ -105,9 +104,9 @@ struct vdpctx { int surface_num; // indexes output_surfaces int query_surface_num; VdpTime recent_vsync_time; - float user_fps; - int composite_detect; - int vsync_interval; + double user_fps; + bool composite_detect; + int64_t vsync_interval; uint64_t last_queue_time; uint64_t queue_time[MAX_OUTPUT_SURFACES]; uint64_t last_ideal_time; @@ -280,7 +279,7 @@ static void resize(struct vo *vo) vc->flip_offset_us = vo->opts->fullscreen ? 1000LL * vc->flip_offset_fs : 1000LL * vc->flip_offset_window; - vo_set_queue_params(vo, vc->flip_offset_us, 1); + vo_set_queue_params(vo, vc->flip_offset_us * 1000, 1); if (vc->output_surface_w < vo->dwidth || vc->output_surface_h < vo->dheight || vc->rotation != vo->params->rotate) @@ -346,7 +345,7 @@ static int win_x11_init_vdpau_flip_queue(struct vo *vo) "vdp_presentation_queue_target_create_x11"); } - /* Emperically this seems to be the first call which fails when we + /* Empirically this seems to be the first call which fails when we * try to reinit after preemption while the user is still switched * from X to a virtual terminal (creating the vdp_device initially * succeeds, as does creating the flip_target above). This is @@ -478,7 +477,17 @@ static int reconfig(struct vo *vo, struct mp_image_params *params) VdpStatus vdp_st; if (!check_preemption(vo)) - return -1; + { + /* + * When prempted, leave the reconfig() immediately + * without reconfiguring the vo_window and without + * initializing the vdpau objects. When recovered + * from preemption, if there is a difference between + * the VD thread parameters and the VO thread parameters + * the reconfig() is triggered again. + */ + return 0; + } VdpChromaType chroma_type = VDP_CHROMA_TYPE_420; mp_vdpau_get_format(params->imgfmt, &chroma_type, NULL); @@ -586,11 +595,11 @@ static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs) case SUBBITMAP_LIBASS: format = VDP_RGBA_FORMAT_A8; break; - case SUBBITMAP_RGBA: + case SUBBITMAP_BGRA: format = VDP_RGBA_FORMAT_B8G8R8A8; break; default: - abort(); + MP_ASSERT_UNREACHABLE(); }; assert(imgs->packed); @@ -677,7 +686,7 @@ static void draw_osd(struct vo *vo) bool formats[SUBBITMAP_COUNT] = { [SUBBITMAP_LIBASS] = vc->supports_a8, - [SUBBITMAP_RGBA] = true, + [SUBBITMAP_BGRA] = true, }; double pts = vc->current_image ? vc->current_image->pts : 0; @@ -712,12 +721,12 @@ static int update_presentation_queue_status(struct vo *vo) break; if (vc->vsync_interval > 1) { uint64_t qtime = vc->queue_time[vc->query_surface_num]; - int diff = ((int64_t)vtime - (int64_t)qtime) / 1e6; - MP_TRACE(vo, "Queue time difference: %d ms\n", diff); + double diff = MP_TIME_NS_TO_MS((int64_t)vtime - (int64_t)qtime); + MP_TRACE(vo, "Queue time difference: %.4f ms\n", diff); if (vtime < qtime + vc->vsync_interval / 2) - MP_VERBOSE(vo, "Frame shown too early (%d ms)\n", diff); + MP_VERBOSE(vo, "Frame shown too early (%.4f ms)\n", diff); if (vtime > qtime + vc->vsync_interval) - MP_VERBOSE(vo, "Frame shown late (%d ms)\n", diff); + MP_VERBOSE(vo, "Frame shown late (%.4f ms)\n", diff); } vc->query_surface_num = WRAP_ADD(vc->query_surface_num, 1, vc->num_output_surfaces); @@ -745,8 +754,8 @@ static void flip_page(struct vo *vo) struct vdp_functions *vdp = vc->vdp; VdpStatus vdp_st; - int64_t pts_us = vc->current_pts; - int duration = vc->current_duration; + int64_t pts_ns = vc->current_pts; + int64_t duration = vc->current_duration; vc->dropped_frame = true; // changed at end if false @@ -757,15 +766,10 @@ static void flip_page(struct vo *vo) if (vc->user_fps > 0) { vc->vsync_interval = 1e9 / vc->user_fps; } else if (vc->user_fps == 0) { - vc->vsync_interval = vo_get_vsync_interval(vo) * 1000; + vc->vsync_interval = vo_get_vsync_interval(vo); } vc->vsync_interval = MPMAX(vc->vsync_interval, 1); - if (duration > INT_MAX / 1000) - duration = -1; - else - duration *= 1000; - if (vc->vsync_interval == 1) duration = -1; // Make sure drop logic is disabled @@ -773,8 +777,8 @@ static void flip_page(struct vo *vo) vdp_st = vdp->presentation_queue_get_time(vc->flip_queue, &vdp_time); CHECK_VDP_WARNING(vo, "Error when calling vdp_presentation_queue_get_time"); - int64_t rel_pts_ns = (pts_us - mp_time_us()) * 1000; - if (!pts_us || rel_pts_ns < 0) + int64_t rel_pts_ns = pts_ns - mp_time_ns(); + if (!pts_ns || rel_pts_ns < 0) rel_pts_ns = 0; uint64_t now = vdp_time; @@ -1019,6 +1023,7 @@ static int preinit(struct vo *vo) vo_x11_uninit(vo); return -1; } + vc->mpvdp->hwctx.hw_imgfmt = IMGFMT_VDPAU; vo->hwdec_devs = hwdec_devices_create(); hwdec_devices_add(vo->hwdec_devs, &vc->mpvdp->hwctx); @@ -1066,9 +1071,6 @@ static int control(struct vo *vo, uint32_t request, void *data) case VOCTRL_SET_PANSCAN: checked_resize(vo); return VO_TRUE; - case VOCTRL_SET_EQUALIZER: - vo->want_redraw = true; - return true; case VOCTRL_RESET: forget_frames(vo, true); return true; @@ -1109,23 +1111,20 @@ const struct vo_driver video_out_vdpau = { .uninit = uninit, .priv_size = sizeof(struct vdpctx), .options = (const struct m_option []){ - {"chroma-deint", OPT_FLAG(chroma_deint), OPTDEF_INT(1)}, - {"pullup", OPT_FLAG(pullup)}, + {"chroma-deint", OPT_BOOL(chroma_deint), OPTDEF_INT(1)}, + {"pullup", OPT_BOOL(pullup)}, {"denoise", OPT_FLOAT(denoise), M_RANGE(0, 1)}, {"sharpen", OPT_FLOAT(sharpen), M_RANGE(-1, 1)}, {"hqscaling", OPT_INT(hqscaling), M_RANGE(0, 9)}, - {"fps", OPT_FLOAT(user_fps)}, - {"composite-detect", OPT_FLAG(composite_detect), OPTDEF_INT(1)}, + {"fps", OPT_DOUBLE(user_fps)}, + {"composite-detect", OPT_BOOL(composite_detect), OPTDEF_INT(1)}, {"queuetime-windowed", OPT_INT(flip_offset_window), OPTDEF_INT(50)}, {"queuetime-fs", OPT_INT(flip_offset_fs), OPTDEF_INT(50)}, {"output-surfaces", OPT_INT(num_output_surfaces), M_RANGE(2, MAX_OUTPUT_SURFACES), OPTDEF_INT(3)}, {"colorkey", OPT_COLOR(colorkey), .defval = &(const struct m_color){.r = 2, .g = 5, .b = 7, .a = 255}}, - {"force-yuv", OPT_FLAG(force_yuv)}, - {"queuetime_windowed", OPT_REPLACED("queuetime-windowed")}, - {"queuetime_fs", OPT_REPLACED("queuetime-fs")}, - {"output_surfaces", OPT_REPLACED("output-surfaces")}, + {"force-yuv", OPT_BOOL(force_yuv)}, {NULL}, }, .options_prefix = "vo-vdpau", |