Skip to content

Commit

Permalink
corevideo: fix video initialization when not using VDA
Browse files Browse the repository at this point in the history
query_format was setting state even if wasn't the correct thing to do. Somehow
it worked by pure luck (until commit e6e6b88).

Fix the initialization by setting state inside of reconfig.
  • Loading branch information
pigoz committed Dec 26, 2013
1 parent c7f9c06 commit 2e8b641
Showing 1 changed file with 46 additions and 52 deletions.
98 changes: 46 additions & 52 deletions video/out/vo_corevideo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 2e8b641

Please sign in to comment.