From cc2490ea7eb4dc1480bc26d62a3bbb15d387c35b Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 10 May 2018 15:57:36 +0200 Subject: input: add a define for the number of mouse buttons and use it (Why the fuck are there up to 20 mouse buttons?) --- video/out/x11_common.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'video') diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 5f2c658a9c..fae53fc93d 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -1133,6 +1133,8 @@ void vo_x11_check_events(struct vo *vo) mp_input_put_key(x11->input_ctx, MP_KEY_MOUSE_ENTER); break; case ButtonPress: + if (Event.xbutton.button - 1 >= MP_KEY_MOUSE_BTN_COUNT) + break; if (Event.xbutton.button == 1) x11->win_drag_button1_down = true; mp_input_put_key(x11->input_ctx, @@ -1142,6 +1144,8 @@ void vo_x11_check_events(struct vo *vo) vo_x11_xembed_send_message(x11, msg); break; case ButtonRelease: + if (Event.xbutton.button - 1 >= MP_KEY_MOUSE_BTN_COUNT) + break; if (Event.xbutton.button == 1) x11->win_drag_button1_down = false; mp_input_put_key(x11->input_ctx, -- cgit v1.2.3 From c9fcd20959ef8d0463be0599e8596002ae68ffd2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 16 May 2018 20:54:46 +0200 Subject: vd_lavc: minor simplification for get_format fallback The default get_format does exactly do this, so we don't need to duplicate it. The only potential problem with this is that the logic doesn't entirely prevent that the avcodec_default_get_format hw_device_ctx path is triggered, which would probably work, but has unknown consequences and interactions. But the way the logic currently works it can't happen, provided the hwaccel metadata libavcodec provides is correct. --- video/decode/vd_lavc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'video') diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index a2f1d7d494..25049aa341 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -818,13 +818,7 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx, if (select == AV_PIX_FMT_NONE) { ctx->hwdec_failed = true; - for (int i = 0; fmt[i] != AV_PIX_FMT_NONE; i++) { - const AVPixFmtDescriptor *d = av_pix_fmt_desc_get(fmt[i]); - if (d && !(d->flags & AV_PIX_FMT_FLAG_HWACCEL)) { - select = fmt[i]; - break; - } - } + select = avcodec_default_get_format(avctx, fmt); } const char *name = av_get_pix_fmt_name(select); -- cgit v1.2.3 From a770006c6ec1c0173e33a63d36cafca743e63808 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 21 May 2018 16:05:03 +0200 Subject: vd_lavc: move hwdec opts to local config, don't use global MPOpts The --hwdec* options are a good fit for the vd_lavc local option struct. This annoyingly requires manual prefixing of most of these options with --vd-lavc (could be avoided by using more sub-struct craziness, but let's not). --- video/decode/vd_lavc.c | 62 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 21 deletions(-) (limited to 'video') diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 25049aa341..17c719b710 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -28,9 +28,12 @@ #include #include +#include "config.h" + #include "mpv_talloc.h" #include "common/global.h" #include "common/msg.h" +#include "options/m_config.h" #include "options/options.h" #include "misc/bstr.h" #include "common/av_common.h" @@ -59,6 +62,8 @@ static void uninit_avctx(struct mp_filter *vd); static int get_buffer2_direct(AVCodecContext *avctx, AVFrame *pic, int flags); static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx, const enum AVPixelFormat *pix_fmt); +static int hwdec_validate_opt(struct mp_log *log, const m_option_t *opt, + struct bstr name, struct bstr param); #define HWDEC_DELAY_QUEUE_COUNT 2 @@ -84,6 +89,9 @@ struct vd_lavc_params { int software_fallback; char **avopts; int dr; + char *hwdec_api; + char *hwdec_codecs; + int hwdec_image_format; }; static const struct m_opt_choice_alternatives discard_names[] = { @@ -101,20 +109,24 @@ static const struct m_opt_choice_alternatives discard_names[] = { const struct m_sub_options vd_lavc_conf = { .opts = (const m_option_t[]){ - OPT_FLAG("fast", fast, 0), - OPT_FLAG("show-all", show_all, 0), - OPT_DISCARD("skiploopfilter", skip_loop_filter, 0), - OPT_DISCARD("skipidct", skip_idct, 0), - OPT_DISCARD("skipframe", skip_frame, 0), - OPT_DISCARD("framedrop", framedrop, 0), - OPT_INT("threads", threads, M_OPT_MIN, .min = 0), - OPT_FLAG("bitexact", bitexact, 0), - OPT_FLAG("assume-old-x264", old_x264, 0), - OPT_FLAG("check-hw-profile", check_hw_profile, 0), - OPT_CHOICE_OR_INT("software-fallback", software_fallback, 0, 1, INT_MAX, - ({"no", INT_MAX}, {"yes", 1})), - OPT_KEYVALUELIST("o", avopts, 0), - OPT_FLAG("dr", dr, 0), + OPT_FLAG("vd-lavc-fast", fast, 0), + OPT_FLAG("vd-lavc-show-all", show_all, 0), + OPT_DISCARD("vd-lavc-skiploopfilter", skip_loop_filter, 0), + OPT_DISCARD("vd-lavc-skipidct", skip_idct, 0), + OPT_DISCARD("vd-lavc-skipframe", skip_frame, 0), + OPT_DISCARD("vd-lavc-framedrop", framedrop, 0), + OPT_INT("vd-lavc-threads", threads, M_OPT_MIN, .min = 0), + OPT_FLAG("vd-lavc-bitexact", bitexact, 0), + OPT_FLAG("vd-lavc-assume-old-x264", old_x264, 0), + OPT_FLAG("vd-lavc-check-hw-profile", check_hw_profile, 0), + OPT_CHOICE_OR_INT("vd-lavc-software-fallback", software_fallback, + 0, 1, INT_MAX, ({"no", INT_MAX}, {"yes", 1})), + OPT_KEYVALUELIST("vd-lavc-o", avopts, 0), + OPT_FLAG("vd-lavc-dr", dr, 0), + OPT_STRING_VALIDATE("hwdec", hwdec_api, M_OPT_OPTIONAL_PARAM, + hwdec_validate_opt), + OPT_STRING("hwdec-codecs", hwdec_codecs, 0), + OPT_IMAGEFORMAT("hwdec-image-format", hwdec_image_format, 0, .min = -1), {0} }, .size = sizeof(struct vd_lavc_params), @@ -127,6 +139,8 @@ const struct m_sub_options vd_lavc_conf = { .skip_frame = AVDISCARD_DEFAULT, .framedrop = AVDISCARD_NONREF, .dr = 1, + .hwdec_api = HAVE_RPI ? "mmal" : "no", + .hwdec_codecs = "h264,vc1,wmv3,hevc,mpeg2video,vp9", }, }; @@ -147,7 +161,8 @@ struct hwdec_info { typedef struct lavc_ctx { struct mp_log *log; - struct MPOpts *opts; + struct m_config_cache *opts_cache; + struct vd_lavc_params *opts; struct mp_codec_params *codec; AVCodecContext *avctx; AVFrame *pic; @@ -409,6 +424,8 @@ static void select_and_set_hwdec(struct mp_filter *vd) vd_ffmpeg_ctx *ctx = vd->priv; const char *codec = ctx->codec->codec; + m_config_cache_update(ctx->opts_cache); + bstr opt = bstr0(ctx->opts->hwdec_api); bool hwdec_requested = !bstr_equals0(opt, "no"); @@ -493,8 +510,8 @@ static void select_and_set_hwdec(struct mp_filter *vd) } } -int hwdec_validate_opt(struct mp_log *log, const m_option_t *opt, - struct bstr name, struct bstr param) +static int hwdec_validate_opt(struct mp_log *log, const m_option_t *opt, + struct bstr name, struct bstr param) { if (bstr_equals0(param, "help")) { struct hwdec_info *hwdecs = NULL; @@ -543,9 +560,11 @@ static void reinit(struct mp_filter *vd) static void init_avctx(struct mp_filter *vd) { vd_ffmpeg_ctx *ctx = vd->priv; - struct vd_lavc_params *lavc_param = ctx->opts->vd_lavc_params; + struct vd_lavc_params *lavc_param = ctx->opts; struct mp_codec_params *c = ctx->codec; + m_config_cache_update(ctx->opts_cache); + assert(!ctx->avctx); const AVCodec *lavc_codec = NULL; @@ -911,7 +930,7 @@ static bool prepare_decoding(struct mp_filter *vd) { vd_ffmpeg_ctx *ctx = vd->priv; AVCodecContext *avctx = ctx->avctx; - struct vd_lavc_params *opts = ctx->opts->vd_lavc_params; + struct vd_lavc_params *opts = ctx->opts; if (!avctx || ctx->hwdec_failed) return false; @@ -937,7 +956,7 @@ static bool prepare_decoding(struct mp_filter *vd) static void handle_err(struct mp_filter *vd) { vd_ffmpeg_ctx *ctx = vd->priv; - struct vd_lavc_params *opts = ctx->opts->vd_lavc_params; + struct vd_lavc_params *opts = ctx->opts; MP_WARN(vd, "Error while decoding frame!\n"); @@ -1194,7 +1213,8 @@ static struct mp_decoder *create(struct mp_filter *parent, vd_ffmpeg_ctx *ctx = vd->priv; ctx->log = vd->log; - ctx->opts = vd->global->opts; + ctx->opts_cache = m_config_cache_alloc(ctx, vd->global, &vd_lavc_conf); + ctx->opts = ctx->opts_cache->opts; ctx->codec = codec; ctx->decoder = talloc_strdup(ctx, decoder); ctx->hwdec_swpool = mp_image_pool_new(ctx); -- cgit v1.2.3 From f8ab59eacdde31af39f4defeb964adf4de140a50 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 21 May 2018 16:25:52 +0200 Subject: player: get rid of mpv_global.opts This was always a legacy thing. Remove it by applying an orgy of mp_get_config_group() calls, and sometimes m_config_cache_alloc() or mp_read_option_raw(). win32 changes untested. --- video/out/gpu/video.c | 4 +++- video/out/vo.c | 18 +++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'video') diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index 3fb460469d..46d9026742 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -3854,7 +3854,9 @@ static void reinit_from_options(struct gl_video *p) gl_video_setup_hooks(p); reinit_osd(p); - if (p->opts.interpolation && !p->global->opts->video_sync && !p->dsi_warned) { + int vs; + mp_read_option_raw(p->global, "video-sync", &m_option_type_choice, &vs); + if (p->opts.interpolation && !vs && !p->dsi_warned) { MP_WARN(p, "Interpolation now requires enabling display-sync mode.\n" "E.g.: --video-sync=display-resample\n"); p->dsi_warned = true; diff --git a/video/out/vo.c b/video/out/vo.c index 9ecfd76a1f..aa3e1b5a6a 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -332,7 +332,9 @@ error: struct vo *init_best_video_out(struct mpv_global *global, struct vo_extra *ex) { - struct m_obj_settings *vo_list = global->opts->vo->video_driver_list; + struct mp_vo_opts *opts = mp_get_config_group(NULL, global, &vo_sub_opts); + struct m_obj_settings *vo_list = opts->video_driver_list; + struct vo *vo = NULL; // first try the preferred drivers, with their optional subdevice param: if (vo_list && vo_list[0].name) { for (int n = 0; vo_list[n].name; n++) { @@ -340,11 +342,11 @@ struct vo *init_best_video_out(struct mpv_global *global, struct vo_extra *ex) if (strlen(vo_list[n].name) == 0) goto autoprobe; bool p = !!vo_list[n + 1].name; - struct vo *vo = vo_create(p, global, ex, vo_list[n].name); + vo = vo_create(p, global, ex, vo_list[n].name); if (vo) - return vo; + goto done; } - return NULL; + goto done; } autoprobe: // now try the rest... @@ -352,11 +354,13 @@ autoprobe: const struct vo_driver *driver = video_out_drivers[i]; if (driver == &video_out_null) break; - struct vo *vo = vo_create(true, global, ex, (char *)driver->name); + vo = vo_create(true, global, ex, (char *)driver->name); if (vo) - return vo; + goto done; } - return NULL; +done: + talloc_free(opts); + return vo; } static void terminate_vo(void *p) -- cgit v1.2.3 From b406f679b127aa3f5fa5f728adb27bc8d500dff1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 24 May 2018 18:31:09 +0200 Subject: vo: remove bogus #if If anyone happened to build with GL disabled, this could lead to option changes not always refreshing the screen. Since vo_gpu is always enabled now (just not necessarily any backend for it), we can drop the #if completely. (The way this works is a bit idiotic - the option cache exists only to grab the change notification, which will trigger a redraw and make vo_gpu update its own second copy of them. But at least it avoids some layering issues for now.) --- video/out/vo.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'video') diff --git a/video/out/vo.c b/video/out/vo.c index aa3e1b5a6a..a33d9fd15f 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -300,11 +300,9 @@ static struct vo *vo_create(bool probing, struct mpv_global *global, m_config_cache_set_dispatch_change_cb(vo->opts_cache, vo->in->dispatch, update_opts, vo); -#if HAVE_GL vo->gl_opts_cache = m_config_cache_alloc(NULL, global, &gl_video_conf); m_config_cache_set_dispatch_change_cb(vo->gl_opts_cache, vo->in->dispatch, update_opts, vo); -#endif vo->eq_opts_cache = m_config_cache_alloc(NULL, global, &mp_csp_equalizer_conf); m_config_cache_set_dispatch_change_cb(vo->eq_opts_cache, vo->in->dispatch, -- cgit v1.2.3