History

avfilter/vf_v360: simplify dfisheye_to_xyz() calculations

Paul B Mahol committed 7 years ago

Commit b3426781 parent a46ee091 file · +5 −6Browse files

Unified · Split

libavfilter/vf_v360.c+5−6
@@ -2048,16 +2048,15 @@ static void dfisheye_to_xyz(const V360Context *s, · 2047 unmodified lines
20482048 const float uf = ((2.f * ei) / ew - 1.f) * scale;
20492049 const float vf = ((2.f * j) / eh - 1.f) * scale;
20502050
2051− const float phi = M_PI + atan2f(vf, uf * m);
2052− const float theta = m * M_PI_2 * (1.f - hypotf(uf, vf));
2051+ const float h = hypotf(uf, vf);
2052+ const float lh = h > 0.f ? h : 1.f;
2053+ const float theta = m * M_PI_2 * (1.f - h);
20532054
2054− const float sin_phi = sinf(phi);
2055− const float cos_phi = cosf(phi);
20562055 const float sin_theta = sinf(theta);
20572056 const float cos_theta = cosf(theta);
20582057
2059− vec[0] = cos_theta * cos_phi;
2060− vec[1] = cos_theta * sin_phi;
2058+ vec[0] = cos_theta * uf / lh;
2059+ vec[1] = cos_theta * -vf / lh;
20612060 vec[2] = sin_theta;
20622061
20632062 normalize_vector(vec);

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