diff options
Diffstat (limited to 'video/out/opengl')
-rw-r--r-- | video/out/opengl/hwdec.h | 1 | ||||
-rw-r--r-- | video/out/opengl/hwdec_osx.c | 22 |
2 files changed, 20 insertions, 3 deletions
diff --git a/video/out/opengl/hwdec.h b/video/out/opengl/hwdec.h index c04962dd76..5126d7f0fa 100644 --- a/video/out/opengl/hwdec.h +++ b/video/out/opengl/hwdec.h @@ -39,6 +39,7 @@ struct gl_hwdec_driver { // Prepare for rendering video. (E.g. create textures.) // Called on initialization, and every time the video size changes. // *params must be set to the format the hw textures return. + // This also can update hw->converted_imgfmt. int (*reinit)(struct gl_hwdec *hw, struct mp_image_params *params); // Return textures that contain a copy or reference of the given hw_image. int (*map_image)(struct gl_hwdec *hw, struct mp_image *hw_image, diff --git a/video/out/opengl/hwdec_osx.c b/video/out/opengl/hwdec_osx.c index 78d01b3894..3046768604 100644 --- a/video/out/opengl/hwdec_osx.c +++ b/video/out/opengl/hwdec_osx.c @@ -146,14 +146,21 @@ static bool check_hwdec(struct gl_hwdec *hw) return true; } +static uint32_t get_vt_fmt(struct mp_hwdec_ctx *ctx) +{ + struct gl_hwdec *hw = ctx->priv; + struct vt_format *f = + vt_get_gl_format_from_imgfmt(hw->global->opts->videotoolbox_format); + return f ? f->cvpixfmt : (uint32_t)-1; +} + static int create(struct gl_hwdec *hw) { if (!check_hwdec(hw)) return -1; struct priv *p = talloc_zero(hw, struct priv); - struct vt_format *f = - vt_get_gl_format_from_imgfmt(hw->global->opts->videotoolbox_format); + struct vt_format *f = vt_get_gl_format_from_imgfmt(IMGFMT_NV12); if (!f) return -1; @@ -162,17 +169,26 @@ static int create(struct gl_hwdec *hw) hw->hwctx = &p->hwctx; hw->hwctx->download_image = download_image; hw->hwctx->type = HWDEC_VIDEOTOOLBOX; - hw->hwctx->priv = (void *)(uintptr_t)f->cvpixfmt; + hw->hwctx->get_vt_fmt = get_vt_fmt; hw->gl_texture_target = GL_TEXTURE_RECTANGLE; hw->gl->GenTextures(MP_MAX_PLANES, p->gl_planes); + hw->hwctx->priv = hw; return 0; } static int reinit(struct gl_hwdec *hw, struct mp_image_params *params) { assert(params->imgfmt == hw->driver->imgfmt); + + struct vt_format *f = vt_get_gl_format(params->hw_subfmt); + if (!f) { + MP_ERR(hw, "Unsupported CVPixelBuffer format.\n"); + return -1; + } + + hw->converted_imgfmt = f->imgfmt; return 0; } |