summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--player/lua.c10
-rw-r--r--sub/osd.c6
-rw-r--r--video/out/gl_video.c2
3 files changed, 10 insertions, 8 deletions
diff --git a/player/lua.c b/player/lua.c
index ddcd8acc50..06d61f4c83 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -892,7 +892,7 @@ static int script_get_screen_size(lua_State *L)
struct MPContext *mpctx = get_mpctx(L);
struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd, OSDTYPE_EXTERNAL);
double aspect = 1.0 * vo_res.w / MPMAX(vo_res.h, 1) /
- vo_res.display_par;
+ (vo_res.display_par ? vo_res.display_par : 1);
lua_pushnumber(L, vo_res.w);
lua_pushnumber(L, vo_res.h);
lua_pushnumber(L, aspect);
@@ -978,10 +978,10 @@ static int script_input_set_section_mouse_area(lua_State *L)
osd_object_get_scale_factor(mpctx->osd, OSDTYPE_EXTERNAL, &sw, &sh);
char *section = (char *)luaL_checkstring(L, 1);
- int x0 = luaL_checkinteger(L, 2) / sw;
- int y0 = luaL_checkinteger(L, 3) / sh;
- int x1 = luaL_checkinteger(L, 4) / sw;
- int y1 = luaL_checkinteger(L, 5) / sh;
+ int x0 = sw ? luaL_checkinteger(L, 2) / sw : 0;
+ int y0 = sh ? luaL_checkinteger(L, 3) / sh : 0;
+ int x1 = sw ? luaL_checkinteger(L, 4) / sw : 0;
+ int y1 = sh ? luaL_checkinteger(L, 5) / sh : 0;
mp_input_set_section_mouse_area(mpctx->input, section, x0, y0, x1, y1);
return 0;
}
diff --git a/sub/osd.c b/sub/osd.c
index e88df98afe..85d951b3b7 100644
--- a/sub/osd.c
+++ b/sub/osd.c
@@ -428,9 +428,11 @@ void osd_object_get_scale_factor(struct osd_state *osd, int obj,
int nw, nh;
osd_object_get_resolution(osd, obj, &nw, &nh);
pthread_mutex_lock(&osd->lock);
- *sw = nw / (double)osd->objs[obj]->vo_res.w;
- *sh = nh / (double)osd->objs[obj]->vo_res.h;
+ int vow = osd->objs[obj]->vo_res.w;
+ int voh = osd->objs[obj]->vo_res.h;
pthread_mutex_unlock(&osd->lock);
+ *sw = vow ? nw / (double)vow : 0;
+ *sh = voh ? nh / (double)voh : 0;
}
// Turn *x and *y, which are given in OSD coordinates, to video coordinates.
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index e2b64968ce..5923a697e9 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -573,7 +573,7 @@ static void update_uniforms(struct gl_video *p, GLuint program)
}
loc = gl->GetUniformLocation(program, "transform");
- if (loc >= 0) {
+ if (loc >= 0 && p->vp_w > 0 && p->vp_h > 0) {
float matrix[3][3];
matrix_ortho2d(matrix, 0, p->vp_w, p->vp_h, 0);
gl->UniformMatrix3fv(loc, 1, GL_FALSE, &matrix[0][0]);