mirror of https://github.com/mpv-player/mpv.git
player: rearrange video sync opts/enums/defines
The video sync logic for mpv lies completely within its core at essentially the highest layer of abstraction. The problem with this is that it is impossible for VOs to know what video sync mode mpv is currently using since it has no access to the opts. Because different video sync modes completely changes how mpv's render loop operates, it's reasonable that a VO may want to change how it renders based on the current mode (see the next commit for an example). Let's just move the video sync option to mp_vo_opts. MPContext, of course, can still access the value of the option so it only requires minor changes in player/video.c. Additionally, move the VS_IS_DISP define from to player/core.h to common/common.h. All VOs already have access to common/common.h, and there's no need for them to gain access to everything that's in player/core.h.
This commit is contained in:
parent
2c2a856f25
commit
fe6d9b6962
|
@ -68,6 +68,24 @@ enum stream_type {
|
|||
STREAM_TYPE_COUNT,
|
||||
};
|
||||
|
||||
enum video_sync {
|
||||
VS_DEFAULT = 0,
|
||||
VS_DISP_RESAMPLE,
|
||||
VS_DISP_RESAMPLE_VDROP,
|
||||
VS_DISP_RESAMPLE_NONE,
|
||||
VS_DISP_ADROP,
|
||||
VS_DISP_VDROP,
|
||||
VS_DISP_NONE,
|
||||
VS_NONE,
|
||||
};
|
||||
|
||||
#define VS_IS_DISP(x) ((x) == VS_DISP_RESAMPLE || \
|
||||
(x) == VS_DISP_RESAMPLE_VDROP || \
|
||||
(x) == VS_DISP_RESAMPLE_NONE || \
|
||||
(x) == VS_DISP_ADROP || \
|
||||
(x) == VS_DISP_VDROP || \
|
||||
(x) == VS_DISP_NONE)
|
||||
|
||||
extern const char mpv_version[];
|
||||
extern const char mpv_builddate[];
|
||||
extern const char mpv_copyright[];
|
||||
|
|
|
@ -162,6 +162,15 @@ static const m_option_t mp_vo_opt_list[] = {
|
|||
{"override-display-fps", OPT_DOUBLE(override_display_fps),
|
||||
M_RANGE(0, DBL_MAX)},
|
||||
{"video-timing-offset", OPT_DOUBLE(timing_offset), M_RANGE(0.0, 1.0)},
|
||||
{"video-sync", OPT_CHOICE(video_sync,
|
||||
{"audio", VS_DEFAULT},
|
||||
{"display-resample", VS_DISP_RESAMPLE},
|
||||
{"display-resample-vdrop", VS_DISP_RESAMPLE_VDROP},
|
||||
{"display-resample-desync", VS_DISP_RESAMPLE_NONE},
|
||||
{"display-adrop", VS_DISP_ADROP},
|
||||
{"display-vdrop", VS_DISP_VDROP},
|
||||
{"display-desync", VS_DISP_NONE},
|
||||
{"desync", VS_NONE})},
|
||||
#if HAVE_X11
|
||||
{"x11-netwm", OPT_CHOICE(x11_netwm, {"auto", 0}, {"no", -1}, {"yes", 1})},
|
||||
{"x11-bypass-compositor", OPT_CHOICE(x11_bypass_compositor,
|
||||
|
@ -719,15 +728,6 @@ static const m_option_t mp_opts[] = {
|
|||
|
||||
// a-v sync stuff:
|
||||
{"initial-audio-sync", OPT_FLAG(initial_audio_sync)},
|
||||
{"video-sync", OPT_CHOICE(video_sync,
|
||||
{"audio", VS_DEFAULT},
|
||||
{"display-resample", VS_DISP_RESAMPLE},
|
||||
{"display-resample-vdrop", VS_DISP_RESAMPLE_VDROP},
|
||||
{"display-resample-desync", VS_DISP_RESAMPLE_NONE},
|
||||
{"display-adrop", VS_DISP_ADROP},
|
||||
{"display-vdrop", VS_DISP_VDROP},
|
||||
{"display-desync", VS_DISP_NONE},
|
||||
{"desync", VS_NONE})},
|
||||
{"video-sync-max-video-change", OPT_DOUBLE(sync_max_video_change),
|
||||
M_RANGE(0, DBL_MAX)},
|
||||
{"video-sync-max-audio-change", OPT_DOUBLE(sync_max_audio_change),
|
||||
|
|
|
@ -61,6 +61,7 @@ typedef struct mp_vo_opts {
|
|||
|
||||
double override_display_fps;
|
||||
double timing_offset;
|
||||
int video_sync;
|
||||
|
||||
// vo_drm
|
||||
struct drm_opts *drm_opts;
|
||||
|
@ -215,7 +216,6 @@ typedef struct MPOpts {
|
|||
int hls_bitrate;
|
||||
int edition_id;
|
||||
int initial_audio_sync;
|
||||
int video_sync;
|
||||
double sync_max_video_change;
|
||||
double sync_max_audio_change;
|
||||
int sync_max_factor;
|
||||
|
|
|
@ -64,7 +64,7 @@ static void update_speed_filters(struct MPContext *mpctx)
|
|||
speed = 1.0;
|
||||
}
|
||||
|
||||
if (mpctx->display_sync_active && mpctx->opts->video_sync == VS_DISP_ADROP) {
|
||||
if (mpctx->display_sync_active && mpctx->video_out->opts->video_sync == VS_DISP_ADROP) {
|
||||
drop *= speed * resample;
|
||||
resample = speed = 1.0;
|
||||
}
|
||||
|
|
|
@ -92,24 +92,6 @@ struct seek_params {
|
|||
unsigned flags; // MPSEEK_FLAG_*
|
||||
};
|
||||
|
||||
enum video_sync {
|
||||
VS_DEFAULT = 0,
|
||||
VS_DISP_RESAMPLE,
|
||||
VS_DISP_RESAMPLE_VDROP,
|
||||
VS_DISP_RESAMPLE_NONE,
|
||||
VS_DISP_ADROP,
|
||||
VS_DISP_VDROP,
|
||||
VS_DISP_NONE,
|
||||
VS_NONE,
|
||||
};
|
||||
|
||||
#define VS_IS_DISP(x) ((x) == VS_DISP_RESAMPLE || \
|
||||
(x) == VS_DISP_RESAMPLE_VDROP || \
|
||||
(x) == VS_DISP_RESAMPLE_NONE || \
|
||||
(x) == VS_DISP_ADROP || \
|
||||
(x) == VS_DISP_VDROP || \
|
||||
(x) == VS_DISP_NONE)
|
||||
|
||||
// Information about past video frames that have been sent to the VO.
|
||||
struct frame_info {
|
||||
double pts;
|
||||
|
|
|
@ -583,7 +583,7 @@ static void update_avsync_before_frame(struct MPContext *mpctx)
|
|||
|
||||
if (mpctx->video_status < STATUS_READY) {
|
||||
mpctx->time_frame = 0;
|
||||
} else if (mpctx->display_sync_active || opts->video_sync == VS_NONE) {
|
||||
} else if (mpctx->display_sync_active || vo->opts->video_sync == VS_NONE) {
|
||||
// don't touch the timing
|
||||
} else if (mpctx->audio_status == STATUS_PLAYING &&
|
||||
mpctx->video_status == STATUS_PLAYING &&
|
||||
|
@ -737,7 +737,7 @@ static double compute_audio_drift(struct MPContext *mpctx, double vsync)
|
|||
static void adjust_audio_resample_speed(struct MPContext *mpctx, double vsync)
|
||||
{
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
int mode = opts->video_sync;
|
||||
int mode = mpctx->video_out->opts->video_sync;
|
||||
|
||||
if (mode != VS_DISP_RESAMPLE || mpctx->audio_status != STATUS_PLAYING) {
|
||||
mpctx->speed_factor_a = mpctx->speed_factor_v;
|
||||
|
@ -797,7 +797,7 @@ static void handle_display_sync_frame(struct MPContext *mpctx,
|
|||
{
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
struct vo *vo = mpctx->video_out;
|
||||
int mode = opts->video_sync;
|
||||
int mode = vo->opts->video_sync;
|
||||
|
||||
if (!mpctx->display_sync_active) {
|
||||
mpctx->display_sync_error = 0.0;
|
||||
|
|
Loading…
Reference in New Issue