diff options
Diffstat (limited to 'video/out/opengl/hwdec_osx.c')
-rw-r--r-- | video/out/opengl/hwdec_osx.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/video/out/opengl/hwdec_osx.c b/video/out/opengl/hwdec_osx.c index 5aa4d3dcd4..2c1ffc71ae 100644 --- a/video/out/opengl/hwdec_osx.c +++ b/video/out/opengl/hwdec_osx.c @@ -33,6 +33,7 @@ struct vt_gl_plane_format { GLenum gl_format; GLenum gl_type; GLenum gl_internal_format; + char swizzle[5]; }; struct vt_format { @@ -65,7 +66,7 @@ static struct vt_format vt_formats[] = { .imgfmt = IMGFMT_UYVY, .planes = 1, .gl = { - { GL_RGB_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, GL_RGB } + { GL_RGB_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, GL_RGB, "gbra" } } }, { @@ -163,14 +164,8 @@ static int create(struct gl_hwdec *hw) return -1; struct priv *p = talloc_zero(hw, struct priv); - struct vt_format *f = vt_get_gl_format_from_imgfmt(IMGFMT_NV12); - if (!f) - return -1; - hw->priv = p; - hw->converted_imgfmt = f->imgfmt; - hw->gl_texture_target = GL_TEXTURE_RECTANGLE; hw->gl->GenTextures(MP_MAX_PLANES, p->gl_planes); p->vtctx = (struct mp_vt_ctx){ @@ -197,16 +192,13 @@ static int reinit(struct gl_hwdec *hw, struct mp_image_params *params) return -1; } - hw->converted_imgfmt = f->imgfmt; + params->imgfmt = f->imgfmt; return 0; } -static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image, - GLuint *out_textures) +static int map_frame(struct gl_hwdec *hw, struct mp_image *hw_image, + struct gl_hwdec_frame *out_frame) { - if (!check_hwdec(hw)) - return -1; - struct priv *p = hw->priv; GL *gl = hw->gl; @@ -230,11 +222,13 @@ static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image, const int planes = CVPixelBufferGetPlaneCount(p->pbuf); assert(planar && planes == f->planes || f->planes == 1); + GLenum gl_target = GL_TEXTURE_RECTANGLE; + for (int i = 0; i < f->planes; i++) { - gl->BindTexture(hw->gl_texture_target, p->gl_planes[i]); + gl->BindTexture(gl_target, p->gl_planes[i]); CGLError err = CGLTexImageIOSurface2D( - CGLGetCurrentContext(), hw->gl_texture_target, + CGLGetCurrentContext(), gl_target, f->gl[i].gl_internal_format, IOSurfaceGetWidthOfPlane(surface, i), IOSurfaceGetHeightOfPlane(surface, i), @@ -244,9 +238,14 @@ static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image, MP_ERR(hw, "error creating IOSurface texture for plane %d: %s (%x)\n", i, CGLErrorString(err), gl->GetError()); - gl->BindTexture(hw->gl_texture_target, 0); + gl->BindTexture(gl_target, 0); - out_textures[i] = p->gl_planes[i]; + out_frame->planes[i] = (struct gl_hwdec_plane){ + .gl_texture = p->gl_planes[i], + .gl_target = gl_target, + .tex_w = IOSurfaceGetWidthOfPlane(surface, i), + .tex_h = IOSurfaceGetHeightOfPlane(surface, i), + }; } return 0; @@ -269,6 +268,6 @@ const struct gl_hwdec_driver gl_hwdec_videotoolbox = { .imgfmt = IMGFMT_VIDEOTOOLBOX, .create = create, .reinit = reinit, - .map_image = map_image, + .map_frame = map_frame, .destroy = destroy, }; |