Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -2484,11 +2484,12 @@ static int xyz_to_fisheye(const V360Context *s, · 2483 unmodified lines | ||
| 2484 | 2484 | const float *vec, int width, int height, |
| 2485 | 2485 | int16_t us[4][4], int16_t vs[4][4], float *du, float *dv) |
| 2486 | 2486 | { |
| 2487 | − const float phi = -atan2f(hypotf(vec[0], vec[1]), -vec[2]) / M_PI; | |
| 2488 | − const float theta = -atan2f(vec[0], vec[1]); | |
| 2487 | + const float h = hypotf(vec[0], vec[1]); | |
| 2488 | + const float lh = h > 0.f ? h : 1.f; | |
| 2489 | + const float phi = atan2f(h, -vec[2]) / M_PI; | |
| 2489 | 2490 | |
| 2490 | − float uf = sinf(theta) * phi * s->input_mirror_modifier[0] / s->iflat_range[0]; | |
| 2491 | − float vf = cosf(theta) * phi * s->input_mirror_modifier[1] / s->iflat_range[1]; | |
| 2491 | + float uf = vec[0] / lh * phi * s->input_mirror_modifier[0] / s->iflat_range[0]; | |
| 2492 | + float vf = -vec[1] / lh * phi * s->input_mirror_modifier[1] / s->iflat_range[1]; | |
| 2492 | 2493 | |
| 2493 | 2494 | const int visible = hypotf(uf, vf) <= 0.5f; |
| 2494 | 2495 | int ui, vi; |