static int control(struct vo *vo, uint32_t request, void *data) { struct xvctx *ctx = vo->priv; switch (request) { case VOCTRL_GET_PANSCAN: return VO_TRUE; case VOCTRL_SET_PANSCAN: resize(vo); return VO_TRUE; case VOCTRL_SET_EQUALIZER: { vo->want_redraw = true; struct voctrl_set_equalizer_args *args = data; return xv_set_eq(vo, ctx->xv_port, args->name, args->value); } case VOCTRL_GET_EQUALIZER: { struct voctrl_get_equalizer_args *args = data; return xv_get_eq(vo, ctx->xv_port, args->name, args->valueptr); } case VOCTRL_REDRAW_FRAME: draw_image(vo, ctx->original_image); return true; } int events = 0; int r = vo_x11_control(vo, &events, request, data); if (events & (VO_EVENT_EXPOSE | VO_EVENT_RESIZE)) resize(vo); vo_event(vo, events); return r; }
static void read_xv_csp(struct vo *vo) { struct xvctx *ctx = vo->priv; ctx->cached_csp = 0; int bt709_enabled; if (xv_get_eq(vo, ctx->xv_port, "bt_709", &bt709_enabled)) ctx->cached_csp = bt709_enabled == 100 ? MP_CSP_BT_709 : MP_CSP_BT_601; }
static void read_xv_csp(struct vo *vo) { struct xvctx *ctx = vo->priv; struct mp_csp_details *cspc = &ctx->cached_csp; *cspc = (struct mp_csp_details) MP_CSP_DETAILS_DEFAULTS; int bt709_enabled; if (xv_get_eq(vo, ctx->xv_port, "bt_709", &bt709_enabled)) cspc->format = bt709_enabled == 100 ? MP_CSP_BT_709 : MP_CSP_BT_601; }
static int control(struct vo *vo, uint32_t request, void *data) { struct xvctx *ctx = vo->priv; switch (request) { case VOCTRL_GET_PANSCAN: return VO_TRUE; case VOCTRL_SET_PANSCAN: resize(vo); return VO_TRUE; case VOCTRL_SET_EQUALIZER: { vo->want_redraw = true; struct voctrl_set_equalizer_args *args = data; return xv_set_eq(vo, ctx->xv_port, args->name, args->value); } case VOCTRL_GET_EQUALIZER: { struct voctrl_get_equalizer_args *args = data; return xv_get_eq(vo, ctx->xv_port, args->name, args->valueptr); } case VOCTRL_SET_YUV_COLORSPACE:; struct mp_csp_details* given_cspc = data; int is_709 = given_cspc->format == MP_CSP_BT_709; xv_set_eq(vo, ctx->xv_port, "bt_709", is_709 * 200 - 100); read_xv_csp(vo); vo->want_redraw = true; return true; case VOCTRL_GET_YUV_COLORSPACE:; struct mp_csp_details* cspc = data; read_xv_csp(vo); *cspc = ctx->cached_csp; return true; case VOCTRL_REDRAW_FRAME: redraw_frame(vo); return true; case VOCTRL_SCREENSHOT: { struct voctrl_screenshot_args *args = data; args->out_image = get_screenshot(vo); return true; } case VOCTRL_WINDOW_TO_OSD_COORDS: { float *c = data; struct mp_rect *src = &ctx->src_rect; struct mp_rect *dst = &ctx->dst_rect; c[0] = av_clipf(c[0], dst->x0, dst->x1) - dst->x0; c[1] = av_clipf(c[1], dst->y0, dst->y1) - dst->y0; c[0] = c[0] / (dst->x1 - dst->x0) * (src->x1 - src->x0) + src->x0; c[1] = c[1] / (dst->y1 - dst->y0) * (src->y1 - src->y0) + src->y0; return VO_TRUE; } } int events = 0; int r = vo_x11_control(vo, &events, request, data); if (events & (VO_EVENT_EXPOSE | VO_EVENT_RESIZE)) resize(vo); return r; }
static int control(struct vo *vo, uint32_t request, void *data) { struct xvctx *ctx = vo->priv; switch (request) { case VOCTRL_GET_PANSCAN: return VO_TRUE; case VOCTRL_SET_PANSCAN: resize(vo); return VO_TRUE; case VOCTRL_SET_EQUALIZER: { vo->want_redraw = true; struct voctrl_set_equalizer_args *args = data; return xv_set_eq(vo, ctx->xv_port, args->name, args->value); } case VOCTRL_GET_EQUALIZER: { struct voctrl_get_equalizer_args *args = data; return xv_get_eq(vo, ctx->xv_port, args->name, args->valueptr); } case VOCTRL_GET_COLORSPACE: { struct mp_image_params *params = data; read_xv_csp(vo); params->colorspace = ctx->cached_csp; return true; } case VOCTRL_REDRAW_FRAME: draw_image(vo, ctx->original_image); return true; case VOCTRL_SCREENSHOT: { struct voctrl_screenshot_args *args = data; args->out_image = get_screenshot(vo); return true; } } int events = 0; int r = vo_x11_control(vo, &events, request, data); if (events & (VO_EVENT_EXPOSE | VO_EVENT_RESIZE)) resize(vo); return r; }