diff options
Diffstat (limited to 'video/out/vo.h')
-rw-r--r-- | video/out/vo.h | 118 |
1 files changed, 77 insertions, 41 deletions
diff --git a/video/out/vo.h b/video/out/vo.h index 7efec53ba0..313c08aafc 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -29,6 +29,7 @@ #include "video/img_format.h" #include "common/common.h" #include "options/options.h" +#include "osdep/threads.h" enum { // VO needs to redraw @@ -66,7 +67,6 @@ enum mp_voctrl { VOCTRL_RESUME, VOCTRL_SET_PANSCAN, - VOCTRL_SET_EQUALIZER, // Triggered by any change to mp_vo_opts. This is for convenience. In theory, // you could install your own listener. @@ -75,12 +75,7 @@ enum mp_voctrl { /* private to vo_gpu */ VOCTRL_LOAD_HWDEC_API, - // Redraw the image previously passed to draw_image() (basically, repeat - // the previous draw_image call). If this is handled, the OSD should also - // be updated and redrawn. Optional; emulated if not available. - VOCTRL_REDRAW_FRAME, - - // Only used internally in vo_opengl_cb + // Only used internally in vo_libmpv VOCTRL_PREINIT, VOCTRL_UNINIT, VOCTRL_RECONFIG, @@ -92,6 +87,8 @@ enum mp_voctrl { VOCTRL_SET_CURSOR_VISIBILITY, // bool* + VOCTRL_CONTENT_TYPE, // enum mp_content_type* + VOCTRL_KILL_SCREENSAVER, VOCTRL_RESTORE_SCREENSAVER, @@ -120,9 +117,25 @@ enum mp_voctrl { VOCTRL_GET_AMBIENT_LUX, // int* VOCTRL_GET_DISPLAY_FPS, // double* VOCTRL_GET_HIDPI_SCALE, // double* + VOCTRL_GET_DISPLAY_RES, // int[2] + VOCTRL_GET_WINDOW_ID, // int64_t* - /* private to vo_gpu */ + /* private to vo_gpu and vo_gpu_next */ VOCTRL_EXTERNAL_RESIZE, + + // Begin VO dragging. + VOCTRL_BEGIN_DRAGGING, + + // Native context menu + VOCTRL_SHOW_MENU, + VOCTRL_UPDATE_MENU, +}; + +// Helper to expose what kind of content is currently playing to the VO. +enum mp_content_type { + MP_CONTENT_NONE, // used for force-window + MP_CONTENT_IMAGE, + MP_CONTENT_VIDEO, }; #define VO_TRUE true @@ -150,14 +163,12 @@ struct mp_pass_perf { }; #define VO_PASS_PERF_MAX 64 +#define VO_PASS_DESC_MAX_LEN 128 struct mp_frame_perf { int count; struct mp_pass_perf perf[VO_PASS_PERF_MAX]; - // The owner of this struct does not have ownership over the names, and - // they may change at any time - so this struct should not be stored - // anywhere or the results reused - char *desc[VO_PASS_PERF_MAX]; + char desc[VO_PASS_PERF_MAX][VO_PASS_DESC_MAX_LEN]; }; struct voctrl_performance_data { @@ -165,7 +176,7 @@ struct voctrl_performance_data { }; struct voctrl_screenshot { - bool scaled, subs, osd, high_bit_depth; + bool scaled, subs, osd, high_bit_depth, native_csp; struct mp_image *res; }; @@ -176,9 +187,17 @@ enum { VO_CAP_FRAMEDROP = 1 << 1, // VO does not allow frames to be retained (vo_mediacodec_embed). VO_CAP_NORETAIN = 1 << 2, + // VO supports applying film grain + VO_CAP_FILM_GRAIN = 1 << 3, +}; + +enum { + // Require DR buffers to be host-cached (i.e. fast readback) + VO_DR_FLAG_HOST_CACHED = 1 << 0, }; #define VO_MAX_REQ_FRAMES 10 +#define VO_MAX_SWAPCHAIN_DEPTH 8 struct vo; struct osd_state; @@ -194,11 +213,11 @@ struct vo_extra { }; struct vo_frame { - // If > 0, realtime when frame should be shown, in mp_time_us() units. + // If > 0, realtime when frame should be shown, in mp_time_ns() units. // If 0, present immediately. int64_t pts; - // Approximate frame duration, in us. - int duration; + // Approximate frame duration, in ns. + double duration; // Realtime of estimated distance between 2 vsync events. double vsync_interval; // "ideal" display time within the vsync @@ -206,6 +225,10 @@ struct vo_frame { // "ideal" frame duration (can be different from num_vsyncs*vsync_interval // up to a vsync) - valid for the entire frame, i.e. not changed for repeats double ideal_frame_duration; + // "ideal" frame vsync point relative to the pts + double ideal_frame_vsync; + // "ideal" frame duration relative to the pts + double ideal_frame_vsync_duration; // how often the frame will be repeated (does not include OSD redraws) int num_vsyncs; // Set if the current frame is repeated from the previous. It's guaranteed @@ -235,6 +258,8 @@ struct vo_frame { // VO if frames are dropped. int num_frames; struct mp_image *frames[VO_MAX_REQ_FRAMES]; + // Speed unadjusted, approximate frame duration inferred from past frames + double approx_duration; // ID for frames[0] (== current). If current==NULL, the number is // meaningless. Otherwise, it's an unique ID for the frame. The ID for // a frame is guaranteed not to change (instant redraws will use the same @@ -247,13 +272,13 @@ struct vo_frame { // Presentation feedback. See get_vsync() for how backends should fill this // struct. struct vo_vsync_info { - // mp_time_us() timestamp at which the last queued frame will likely be + // mp_time_ns() timestamp at which the last queued frame will likely be // displayed (this is in the future, unless the frame is instantly output). - // -1 if unset or unsupported. + // 0 or lower if unset or unsupported. // This implies the latency of the output. int64_t last_queue_display_time; - // Time between 2 vsync events in microseconds. The difference should be the + // Time between 2 vsync events in nanoseconds. The difference should be the // from 2 times sampled from the same reference point (it should not be the // difference between e.g. the end of scanout and the start of the next one; // it must be continuous). @@ -289,6 +314,9 @@ struct vo_driver { // Disable video timing, push frames as quickly as possible, never redraw. bool untimed; + // The VO is responsible for freeing frames. + bool frame_owner; + const char *name; const char *description; @@ -340,8 +368,10 @@ struct vo_driver { * allocated image. It's even possible that only 1 plane uses the buffer * allocated by the get_image function. The VO has to check for this. * - * stride_align is always a value >=1 that is a power of 2. The stride - * values of the returned image must be divisible by this value. + * stride_align is always a value >=1. The stride values of the returned + * image must be divisible by this value. This may be a non power of two. + * + * flags is a combination of VO_DR_FLAG_* flags. * * Currently, the returned image must have exactly 1 AVBufferRef set, for * internal implementation simplicity. @@ -350,7 +380,7 @@ struct vo_driver { * will silently fallback to a default allocator */ struct mp_image *(*get_image)(struct vo *vo, int imgfmt, int w, int h, - int stride_align); + int stride_align, int flags); /* * Thread-safe variant of get_image. Set at most one of these callbacks. @@ -358,23 +388,13 @@ struct vo_driver { * vo_driver.uninit is not called before this function returns. */ struct mp_image *(*get_image_ts)(struct vo *vo, int imgfmt, int w, int h, - int stride_align); - - /* - * Render the given frame to the VO's backbuffer. This operation will be - * followed by a draw_osd and a flip_page[_timed] call. - * mpi belongs to the VO; the VO must free it eventually. - * - * This also should draw the OSD. - * - * Deprecated for draw_frame. A VO should have only either callback set. - */ - void (*draw_image)(struct vo *vo, struct mp_image *mpi); + int stride_align, int flags); /* Render the given frame. Note that this is also called when repeating * or redrawing frames. * - * frame is freed by the caller, but the callee can still modify the + * frame is freed by the caller if the callee did not assume ownership + * of the frames, but in any case the callee can still modify the * contained data and references. */ void (*draw_frame)(struct vo *vo, struct vo_frame *frame); @@ -406,7 +426,7 @@ struct vo_driver { * immediately. */ void (*wakeup)(struct vo *vo); - void (*wait_events)(struct vo *vo, int64_t until_time_us); + void (*wait_events)(struct vo *vo, int64_t until_time_ns); /* * Closes driver. Should restore the original state of the system. @@ -439,9 +459,9 @@ struct vo { struct mpv_global *global; struct vo_x11_state *x11; struct vo_w32_state *w32; - struct vo_cocoa_state *cocoa; struct vo_wayland_state *wl; struct vo_android_state *android; + struct vo_drm_state *drm; struct mp_hwdec_devices *hwdec_devs; struct input_ctx *input_ctx; struct osd_state *osd; @@ -457,7 +477,17 @@ struct vo { // be accessed unsynchronized (read-only). int config_ok; // Last config call was successful? - struct mp_image_params *params; // Configured parameters (as in vo_reconfig) + + // --- The following fields are synchronized by params_mutex, most of + // the params are set only in the vo_reconfig and safe to read + // unsynchronized. Some of the parameters are updated in draw_frame, + // which are still safe to read in the play loop, but for correctness + // generic getter is protected by params_mutex. + mp_mutex params_mutex; + // Configured parameters (changed in vo_reconfig) + struct mp_image_params *params; + // Target display parameters (VO is responsible for re-/setting) + struct mp_image_params *target_params; // --- The following fields can be accessed only by the VO thread, or from // anywhere _if_ the VO thread is suspended (use vo->dispatch). @@ -473,6 +503,9 @@ struct vo { int dwidth; int dheight; float monitor_par; + + // current GPU context (--vo=gpu and --vo=gpu-next only) + const char *context_name; }; struct mpv_global; @@ -500,9 +533,9 @@ void vo_query_formats(struct vo *vo, uint8_t *list); void vo_event(struct vo *vo, int event); int vo_query_and_reset_events(struct vo *vo, int events); struct mp_image *vo_get_current_frame(struct vo *vo); -void vo_set_queue_params(struct vo *vo, int64_t offset_us, int num_req_frames); +void vo_set_queue_params(struct vo *vo, int64_t offset_ns, int num_req_frames); int vo_get_num_req_frames(struct vo *vo); -int64_t vo_get_vsync_interval(struct vo *vo); +double vo_get_vsync_interval(struct vo *vo); double vo_get_estimated_vsync_interval(struct vo *vo); double vo_get_estimated_vsync_jitter(struct vo *vo); double vo_get_display_fps(struct vo *vo); @@ -510,7 +543,7 @@ double vo_get_delay(struct vo *vo); void vo_discard_timing_info(struct vo *vo); struct vo_frame *vo_get_current_vo_frame(struct vo *vo); struct mp_image *vo_get_image(struct vo *vo, int imgfmt, int w, int h, - int stride_align); + int stride_align, int flags); void vo_wakeup(struct vo *vo); void vo_wait_default(struct vo *vo, int64_t until_time); @@ -527,4 +560,7 @@ void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src, struct vo_frame *vo_frame_ref(struct vo_frame *frame); +struct mp_image_params vo_get_current_params(struct vo *vo); +struct mp_image_params vo_get_target_params(struct vo *vo); + #endif /* MPLAYER_VIDEO_OUT_H */ |