From 5a78c3ef6bae02bec82d13838a8b27a81c5f4b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Mon, 5 May 2014 14:53:54 +0300 Subject: [PATCH] vo_xv: Check whether the Xv adaptor/port supports scaling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Perform a rudimentary scaling check in preinit() so that we can report the scaling caps more truthfully in query_format(). XvQueryBestSize() can be used to query whether the requested src/dst dimensions are supported. However when query_format() gets called we don't yet know the the actual dimensions so we will resort to using artificial 128x128->64x64 and 128x128->256x256 checks. The resolutions used in the check are pusposely kept rather low to avoid hitting any resolution/memory limits. The intent here is to catch such implementations that don't support any up/down scaling, and let everything else through as before. For a more accurate check we would need to renegotiate the caps after we already know the final src/dst dimensions, or implement swscale based fallback within vo_xv itself. But both of those options seem like a more significant undertaking. Signed-off-by: Ville Syrjälä --- libvo/vo_xv.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index 95600fc..ca36141 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -90,6 +90,7 @@ static unsigned int ver, rel, req, ev, err; static unsigned int formats, adaptors, xv_format; static XvAdaptorInfo *ai = NULL; static XvImageFormatValues *fo=NULL; +static int scale_flags; static int current_buf = 0; static int current_ip_buf = 0; @@ -518,7 +519,7 @@ static uint32_t get_image(mp_image_t * mpi) static int query_format(uint32_t format) { uint32_t i; - int flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_OSD | VFCAP_ACCEPT_STRIDE; // FIXME! check for DOWN + int flag = scale_flags | VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_ACCEPT_STRIDE; // FIXME! check for DOWN /* check image formats */ for (i = 0; i < formats; i++) @@ -559,6 +560,7 @@ static int preinit(const char *arg) strarg_t ck_src_arg = { 0, NULL }; strarg_t ck_method_arg = { 0, NULL }; int xv_adaptor = -1; + unsigned int w, h; const opt_t subopts[] = { @@ -678,6 +680,18 @@ static int preinit(const char *arg) fo = XvListImageFormats(mDisplay, xv_port, (int *) &formats); + scale_flags = 0; + + w = h = 128; + XvQueryBestSize(mDisplay, xv_port, True, 128, 128, 64, 64, &w, &h); + if (w < 128 && h < 128) + scale_flags |= VFCAP_HWSCALE_DOWN; + + w = h = 128; + XvQueryBestSize(mDisplay, xv_port, True, 128, 128, 256, 256, &w, &h); + if (w > 128 && h > 128) + scale_flags |= VFCAP_HWSCALE_UP; + mp_input_add_event_fd(ConnectionNumber(mDisplay), check_events); return 0; } -- 1.8.3.2