History

avfilter/vf_v360: simplify xyz_to_ball() calculations

Paul B Mahol committed 7 years ago

Commit ecaef691 parent b8dfc101 file · +4 −3Browse files

Unified · Split

libavfilter/vf_v360.c+4−3
@@ -1603,12 +1603,13 @@ static void xyz_to_ball(const V360Context *s, · 1602 unmodified lines
16031603 uint16_t us[4][4], uint16_t vs[4][4], float *du, float *dv)
16041604 {
16051605 const float l = hypotf(vec[0], vec[1]);
1606− const float r = sinf(acosf(-vec[2]) * 0.5f);
1606+ const float r = sqrtf(1.f + vec[2]) / M_SQRT2;
16071607 float uf, vf;
16081608 int ui, vi;
16091609
1610− uf = (1.f - r * vec[0] * s->input_mirror_modifier[0] / l) * width / 2.f;
1611− vf = (1.f + r * vec[1] * s->input_mirror_modifier[1] / l) * height / 2.f;
1610+ uf = (1.f + r * vec[0] * s->input_mirror_modifier[0] / (l > 0.f ? l : 1.f)) * width * 0.5f;
1611+ vf = (1.f - r * vec[1] * s->input_mirror_modifier[1] / (l > 0.f ? l : 1.f)) * height * 0.5f;
1612+
16121613 ui = floorf(uf);
16131614 vi = floorf(vf);
16141615

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