mirror of
https://github.com/mpv-player/mpv.git
synced 2026-06-06 20:10:30 +00:00
sanitizer: avoid divide-by-zero instances
Merges pull request #1094, with some minor changes. mpv expects IEEE, and IEEE allows divisions by 0 for floats, so these shouldn't actually be a problem, but do it anyway for the sake of clang. Signed-off-by: wm4 <wm4@nowhere>
This commit is contained in:
+5
-5
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user