summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorAlexander Preisinger <alexander.preisinger@gmail.com>2014-01-28 13:52:12 +0100
committerAlexander Preisinger <alexander.preisinger@gmail.com>2014-01-28 13:52:12 +0100
commitcd2cfc80564175ab6a52814d48cd29e21506770d (patch)
tree202abb901d4167fedc3a9943a87c9d9add816da8 /video
parent0f90288bf6fa3f83374f662b5657e4ed7a7f3c67 (diff)
downloadmpv-cd2cfc80564175ab6a52814d48cd29e21506770d.tar.bz2
mpv-cd2cfc80564175ab6a52814d48cd29e21506770d.tar.xz
wayland/shm: RGB888 as default, change options
RGB565 is one of the fastest and most supported formats on low end consumer devices, but ffmpeg spams warning when using it. Make it opt-in instead of opt-out.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo_wayland.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/video/out/vo_wayland.c b/video/out/vo_wayland.c
index d03e1bfd3d..ac3aefce00 100644
--- a/video/out/vo_wayland.c
+++ b/video/out/vo_wayland.c
@@ -149,7 +149,7 @@ struct priv {
// options
int enable_alpha;
- int use_default;
+ int use_rgb565;
};
/* copied from weston clients */
@@ -232,6 +232,21 @@ static bool is_alpha_format(const struct fmtentry *fmt)
return !!(mp_imgfmt_get_desc(fmt->mp_fmt).flags & MP_IMGFLAG_ALPHA);
}
+static const struct fmtentry * is_wayland_format_supported(struct priv *p,
+ enum wl_shm_format fmt)
+{
+ struct supported_format *sf;
+
+ // find the matching format first
+ wl_list_for_each(sf, &p->format_list, link) {
+ if (sf->fmt->wl_fmt == fmt) {
+ return sf->fmt;
+ }
+ }
+
+ return NULL;
+}
+
static void buffer_swap(struct priv *p)
{
if (!p->back_buffer->is_new)
@@ -587,7 +602,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *fmt, int flags)
struct supported_format *sf;
- // find the same format first
+ // find the matching format first
wl_list_for_each(sf, &p->format_list, link) {
if (sf->fmt->mp_fmt == fmt->imgfmt && (p->enable_alpha == sf->is_alpha)) {
p->pref_format = sf->fmt;
@@ -595,25 +610,22 @@ static int reconfig(struct vo *vo, struct mp_image_params *fmt, int flags)
}
}
- // if the format is not supported choose one of the fancy formats next
- // the default formats are always last
if (!p->pref_format) {
- wl_list_for_each(sf, &p->format_list, link) {
- if (p->enable_alpha == sf->is_alpha) {
- p->pref_format = sf->fmt;
- break;
- }
- }
- }
-
- // if use default is enable overwrite the auto selected one
- if (p->use_default) {
+ // if use default is enable overwrite the auto selected one
if (p->enable_alpha)
p->pref_format = &fmttable[DEFAULT_ALPHA_FORMAT_ENTRY];
else
p->pref_format = &fmttable[DEFAULT_FORMAT_ENTRY];
}
+ // overides alpha
+ // use rgb565 if performance is your main concern
+ if (p->use_rgb565) {
+ const struct fmtentry *fmt =
+ is_wayland_format_supported(p, WL_SHM_FORMAT_RGB565);
+ if (fmt)
+ p->pref_format = fmt;
+ }
p->bytes_per_pixel = mp_imgfmt_get_desc(p->pref_format->mp_fmt).bytes[0];
MP_VERBOSE(p->wl, "bytes per pixel: %d\n", p->bytes_per_pixel);
@@ -718,7 +730,7 @@ const struct vo_driver video_out_wayland = {
.uninit = uninit,
.options = (const struct m_option[]) {
OPT_FLAG("alpha", enable_alpha, 0),
- OPT_FLAG("default-format", use_default, 0),
+ OPT_FLAG("rgb565", use_rgb565, 0),
{0}
},
};