History

avfilter/vf_v360: simplify xyz_to_dfisheye() calculations

Paul B Mahol committed 7 years ago

Commit 073d2261 parent b3426781 file · +5 −4Browse files

Unified · Split

libavfilter/vf_v360.c+5−4
@@ -2083,11 +2083,12 @@ static void xyz_to_dfisheye(const V360Context *s, · 2082 unmodified lines
20832083 const float ew = width / 2.f;
20842084 const float eh = height;
20852085
2086− const float phi = atan2f(-vec[1], -vec[0]) * s->input_mirror_modifier[0];
2087− const float theta = acosf(fabsf(vec[2])) / M_PI * s->input_mirror_modifier[1];
2086+ const float h = hypotf(vec[0], vec[1]);
2087+ const float lh = h > 0.f ? h : 1.f;
2088+ const float theta = acosf(fabsf(vec[2])) / M_PI;
20882089
2089− float uf = (theta * cosf(phi) * scale + 0.5f) * ew;
2090− float vf = (theta * sinf(phi) * scale + 0.5f) * eh;
2090+ float uf = (theta * (-vec[0] / lh) * s->input_mirror_modifier[0] * scale + 0.5f) * ew;
2091+ float vf = (theta * (-vec[1] / lh) * s->input_mirror_modifier[1] * scale + 0.5f) * eh;
20912092
20922093 int ui, vi;
20932094 int u_shift;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t