summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-12-26 22:11:49 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-12-26 22:11:49 +0100
commit2e8b6419bd730fc5fc1575f2a655517b87a0fd5d (patch)
tree87d2ba91e86a6ee364c0da16954ed8f11507f636
parentc7f9c060e4dbca0a9ebe1eab63e1e64c317e3349 (diff)
downloadmpv-2e8b6419bd730fc5fc1575f2a655517b87a0fd5d.tar.bz2
mpv-2e8b6419bd730fc5fc1575f2a655517b87a0fd5d.tar.xz
corevideo: fix video initialization when not using VDA
query_format was setting state even if wasn't the correct thing to do. Somehow it worked by pure luck (until commit e6e6b88b6da). Fix the initialization by setting state inside of reconfig.
-rw-r--r--video/out/vo_corevideo.c98
1 files changed, 46 insertions, 52 deletions
diff --git a/video/out/vo_corevideo.c b/video/out/vo_corevideo.c
index 2a154b99f0..92b3c764ca 100644
--- a/video/out/vo_corevideo.c
+++ b/video/out/vo_corevideo.c
@@ -142,25 +142,6 @@ static int init_gl(struct vo *vo, uint32_t d_width, uint32_t d_height)
return 1;
}
-static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
-{
- struct priv *p = vo->priv;
- p->fns.uninit(vo);
-
- p->image_width = params->w;
- p->image_height = params->h;
-
- int mpgl_caps = MPGL_CAP_GL_LEGACY;
- if (!mpgl_config_window(
- p->mpglctx, mpgl_caps, vo->dwidth, vo->dheight, flags))
- return -1;
-
- init_gl(vo, vo->dwidth, vo->dheight);
- p->fns.init(vo);
-
- return 0;
-}
-
// map x/y (in range 0..1) to the video texture, and emit OpenGL vertexes
static void video_vertex(struct vo *vo, float x, float y)
{
@@ -548,43 +529,56 @@ static struct cv_functions iosurface_functions = {
};
#endif /* HAVE_VDA_HWACCEL */
-static int query_format(struct vo *vo, uint32_t format)
-{
- struct priv *p = vo->priv;
- const int flags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
+struct fmt_entry {
+ enum mp_imgfmt imgfmt;
+ OSType cvfmt;
+ struct cv_functions *funs;
+};
- switch (format) {
+static const struct fmt_entry supported_fmts[] = {
#if HAVE_VDA_HWACCEL
- case IMGFMT_VDA:
- p->fns = iosurface_functions;
- return flags;
+ { IMGFMT_VDA, 0, &iosurface_functions },
#endif
+ { IMGFMT_YUYV, kYUVSPixelFormat, &cv_functions },
+ { IMGFMT_UYVY, k2vuyPixelFormat, &cv_functions },
+ { IMGFMT_RGB24, k24RGBPixelFormat, &cv_functions },
+ { IMGFMT_BGRA, k32BGRAPixelFormat, &cv_functions },
+ { IMGFMT_NONE, 0, NULL }
+};
- case IMGFMT_YUYV:
- p->fns = cv_functions;
- p->cv.pixfmt = kYUVSPixelFormat;
- return flags;
-
- case IMGFMT_UYVY:
- p->fns = cv_functions;
- p->cv.pixfmt = k2vuyPixelFormat;
- return flags;
-
- case IMGFMT_RGB24:
- p->fns = cv_functions;
- p->cv.pixfmt = k24RGBPixelFormat;
- return flags;
-
- case IMGFMT_ARGB:
- p->fns = cv_functions;
- p->cv.pixfmt = k32ARGBPixelFormat;
- return flags;
-
- case IMGFMT_BGRA:
- p->fns = cv_functions;
- p->cv.pixfmt = k32BGRAPixelFormat;
- return flags;
- }
+static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
+{
+ struct priv *p = vo->priv;
+ if (p->fns.uninit)
+ p->fns.uninit(vo);
+
+ for (int i = 0; supported_fmts[i].imgfmt; i++)
+ if (supported_fmts[i].imgfmt == params->imgfmt) {
+ p->fns = *supported_fmts[i].funs;
+ p->cv.pixfmt = supported_fmts[i].cvfmt;
+ break;
+ }
+
+ p->image_width = params->w;
+ p->image_height = params->h;
+
+ int mpgl_caps = MPGL_CAP_GL_LEGACY;
+ if (!mpgl_config_window(
+ p->mpglctx, mpgl_caps, vo->dwidth, vo->dheight, flags))
+ return -1;
+
+ init_gl(vo, vo->dwidth, vo->dheight);
+ p->fns.init(vo);
+
+ return 0;
+}
+
+
+static int query_format(struct vo *vo, uint32_t format)
+{
+ for (int i = 0; supported_fmts[i].imgfmt; i++)
+ if (supported_fmts[i].imgfmt == format)
+ return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
return 0;
}