From 0ec35fa111391b8069640ba2f616746a1b5530a5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 17 Nov 2015 21:07:41 +0100 Subject: videotoolbox: make decoder format customizable Because apparently there's no ideal universally working format. The weird OpenGL texture format for kCVPixelFormatType_32BGRA is from: http://stackoverflow.com/questions/22077544/draw-an-iosurface-to-an-opengl-context (Which apparently got it from the linked Apple example code.) --- video/decode/videotoolbox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'video/decode/videotoolbox.c') diff --git a/video/decode/videotoolbox.c b/video/decode/videotoolbox.c index 470f6b6cf3..c5035f3a5b 100644 --- a/video/decode/videotoolbox.c +++ b/video/decode/videotoolbox.c @@ -31,7 +31,7 @@ static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info, const char *decoder) { hwdec_request_api(info, "videotoolbox"); - if (!info || !info->hwctx) + if (!info || !info->hwctx || info->hwctx->type != HWDEC_VIDEOTOOLBOX) return HWDEC_ERR_NO_CTX; switch (mp_codec_to_av_codec_id(decoder)) { case AV_CODEC_ID_H264: @@ -88,7 +88,7 @@ static int init_decoder(struct lavc_ctx *ctx, int w, int h) av_videotoolbox_default_free(ctx->avctx); AVVideotoolboxContext *vtctx = av_videotoolbox_alloc_context(); - vtctx->cv_pix_fmt_type = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; + vtctx->cv_pix_fmt_type = (uintptr_t)ctx->hwdec_info->hwctx->priv; int err = av_videotoolbox_default_init2(ctx->avctx, vtctx); if (err < 0) { -- cgit v1.2.3