diff options
Diffstat (limited to 'video/out/vo_corevideo.c')
-rw-r--r-- | video/out/vo_corevideo.c | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/video/out/vo_corevideo.c b/video/out/vo_corevideo.c index 3c08af585d..16189920a2 100644 --- a/video/out/vo_corevideo.c +++ b/video/out/vo_corevideo.c @@ -71,15 +71,13 @@ struct cv_functions { void (*bind_texture)(struct vo *vo); void (*unbind_texture)(struct vo *vo); mp_image_t *(*get_screenshot)(struct vo *vo); - int (*get_yuv_colorspace)(struct vo *vo, struct mp_csp_details *csp); - int (*set_yuv_colorspace)(struct vo *vo, struct mp_csp_details *csp); + void (*get_colorspace)(struct vo *vo, struct mp_image_params *p); }; struct priv { MPGLContext *mpglctx; unsigned int image_width; unsigned int image_height; - struct mp_csp_details colorspace; struct mp_rect src_rect; struct mp_rect dst_rect; struct mp_osd_res osd_res; @@ -213,7 +211,6 @@ static int preinit(struct vo *vo) *p = (struct priv) { .mpglctx = mpgl_init(vo, "cocoa"), - .colorspace = MP_CSP_DETAILS_DEFAULTS, .quad = talloc_ptrtype(p, p->quad), }; @@ -245,8 +242,11 @@ static CFStringRef get_cv_csp_matrix(enum mp_csp format) static void apply_csp(struct vo *vo, CVPixelBufferRef pbuf) { struct priv *p = vo->priv; - CFStringRef matrix = get_cv_csp_matrix(p->colorspace.format); - assert(matrix); + if (!vo->params) + return; + CFStringRef matrix = get_cv_csp_matrix(vo->params->colorspace); + if (!matrix) + return; CVPixelBufferLockBaseAddress(pbuf, 0); CVBufferSetAttachment(pbuf, kCVImageBufferYCbCrMatrixKey, matrix, @@ -254,11 +254,11 @@ static void apply_csp(struct vo *vo, CVPixelBufferRef pbuf) CVPixelBufferUnlockBaseAddress(pbuf, 0); } -static int get_yuv_colorspace(struct vo *vo, struct mp_csp_details *csp) +static void get_colorspace(struct vo *vo, struct mp_image_params *p) { struct priv *p = vo->priv; - *(struct mp_csp_details *)csp = p->colorspace; - return VO_TRUE; + if (vo->params && get_cv_csp_matrix(vo->params->colorspace)) + p->colorspace = vo->params->colorspace; } static int get_image_fmt(struct vo *vo, CVPixelBufferRef pbuf) @@ -312,10 +312,9 @@ static int control(struct vo *vo, uint32_t request, void *data) case VOCTRL_REDRAW_FRAME: do_render(vo); return VO_TRUE; - case VOCTRL_SET_YUV_COLORSPACE: - return p->fns.set_yuv_colorspace(vo, data); - case VOCTRL_GET_YUV_COLORSPACE: - return p->fns.get_yuv_colorspace(vo, data); + case VOCTRL_GET_COLORSPACE: + p->fns.get_colorspace(vo, data); + return VO_TRUE; case VOCTRL_SCREENSHOT: { struct voctrl_screenshot_args *args = data; if (args->full_window) @@ -404,16 +403,7 @@ static mp_image_t *cv_get_screenshot(struct vo *vo) return get_screenshot(vo, p->cv.pbuf); } -static int cv_set_yuv_colorspace(struct vo *vo, struct mp_csp_details *csp) -{ - struct priv *p = vo->priv; - if (get_cv_csp_matrix(csp->format)) { - p->colorspace = *csp; - return VO_TRUE; - } else - return VO_NOTIMPL; -} static struct cv_functions cv_functions = { .init = dummy_cb, @@ -422,8 +412,7 @@ static struct cv_functions cv_functions = { .unbind_texture = cv_unbind_texture, .prepare_texture = upload_opengl_texture, .get_screenshot = cv_get_screenshot, - .get_yuv_colorspace = get_yuv_colorspace, - .set_yuv_colorspace = cv_set_yuv_colorspace, + .get_colorspace = get_colorspace, }; #if HAVE_VDA_HWACCEL @@ -506,14 +495,9 @@ static mp_image_t *iosurface_get_screenshot(struct vo *vo) return get_screenshot(vo, p->dr.pbuf); } -static int iosurface_set_yuv_csp(struct vo *vo, struct mp_csp_details *csp) +static void iosurface_get_colorspace(struct vo *vo, struct mp_image_params *p) { - if (csp->format == MP_CSP_BT_601) { - struct priv *p = vo->priv; - p->colorspace = *csp; - return VO_TRUE; - } else - return VO_NOTIMPL; + p->colorspace = MP_CSP_BT_601; } static struct cv_functions iosurface_functions = { @@ -523,8 +507,7 @@ static struct cv_functions iosurface_functions = { .unbind_texture = iosurface_unbind_texture, .prepare_texture = extract_texture_from_iosurface, .get_screenshot = iosurface_get_screenshot, - .get_yuv_colorspace = get_yuv_colorspace, - .set_yuv_colorspace = iosurface_set_yuv_csp, + .get_colorspace = iosurface_get_colorspace, }; #endif /* HAVE_VDA_HWACCEL */ |