History

avfilter/vf_v360: improve precision of some output formats

Paul B Mahol committed 6 years ago

Commit fc7d4d01 parent b6879b61 file · +18 −18Browse files

Unified · Split

libavfilter/vf_v360.c+18−18
@@ -1610,8 +1610,8 @@ static int stereographic_to_xyz(const V360Context *s, · 1609 unmodified lines
16101610 int i, int j, int width, int height,
16111611 float *vec)
16121612 {
1613− const float x = ((2.f * i) / width - 1.f) * s->flat_range[0];
1614− const float y = ((2.f * j) / height - 1.f) * s->flat_range[1];
1613+ const float x = ((2.f * i + 1.f) / width - 1.f) * s->flat_range[0];
1614+ const float y = ((2.f * j + 1.f) / height - 1.f) * s->flat_range[1];
16151615 const float xy = x * x + y * y;
16161616
16171617 vec[0] = 2.f * x / (1.f + xy);
@@ -1837,8 +1837,8 @@ static int mercator_to_xyz(const V360Context *s, · 219 unmodified lines
18371837 int i, int j, int width, int height,
18381838 float *vec)
18391839 {
1840− const float phi = ((2.f * i) / width - 1.f) * M_PI + M_PI_2;
1841− const float y = ((2.f * j) / height - 1.f) * M_PI;
1840+ const float phi = ((2.f * i + 1.f) / width - 1.f) * M_PI + M_PI_2;
1841+ const float y = ((2.f * j + 1.f) / height - 1.f) * M_PI;
18421842 const float div = expf(2.f * y) + 1.f;
18431843
18441844 const float sin_phi = sinf(phi);
@@ -1907,8 +1907,8 @@ static int ball_to_xyz(const V360Context *s, · 62 unmodified lines
19071907 int i, int j, int width, int height,
19081908 float *vec)
19091909 {
1910− const float x = (2.f * i) / width - 1.f;
1911− const float y = (2.f * j) / height - 1.f;
1910+ const float x = (2.f * i + 1.f) / width - 1.f;
1911+ const float y = (2.f * j + 1.f) / height - 1.f;
19121912 const float l = hypotf(x, y);
19131913
19141914 if (l <= 1.f) {
@@ -1941,8 +1941,8 @@ static int hammer_to_xyz(const V360Context *s, · 26 unmodified lines
19411941 int i, int j, int width, int height,
19421942 float *vec)
19431943 {
1944− const float x = ((2.f * i) / width - 1.f);
1945− const float y = ((2.f * j) / height - 1.f);
1944+ const float x = ((2.f * i + 1.f) / width - 1.f);
1945+ const float y = ((2.f * j + 1.f) / height - 1.f);
19461946
19471947 const float xx = x * x;
19481948 const float yy = y * y;
@@ -2022,8 +2022,8 @@ static int sinusoidal_to_xyz(const V360Context *s, · 73 unmodified lines
20222022 int i, int j, int width, int height,
20232023 float *vec)
20242024 {
2025− const float theta = ((2.f * j) / height - 1.f) * M_PI_2;
2026− const float phi = ((2.f * i) / width - 1.f) * M_PI / cosf(theta);
2025+ const float theta = ((2.f * j + 1.f) / height - 1.f) * M_PI_2;
2026+ const float phi = ((2.f * i + 1.f) / width - 1.f) * M_PI / cosf(theta);
20272027
20282028 const float sin_phi = sinf(phi);
20292029 const float cos_phi = cosf(phi);
@@ -2360,8 +2360,8 @@ static int flat_to_xyz(const V360Context *s, · 330 unmodified lines
23602360 int i, int j, int width, int height,
23612361 float *vec)
23622362 {
2363− const float l_x = s->flat_range[0] * (2.f * i / width - 1.f);
2364− const float l_y = -s->flat_range[1] * (2.f * j / height - 1.f);
2363+ const float l_x = s->flat_range[0] * ((2.f * i + 0.5f) / width - 1.f);
2364+ const float l_y = -s->flat_range[1] * ((2.f * j + 0.5f) / height - 1.f);
23652365
23662366 vec[0] = l_x;
23672367 vec[1] = l_y;
@@ -2493,8 +2493,8 @@ static int pannini_to_xyz(const V360Context *s, · 125 unmodified lines
24932493 int i, int j, int width, int height,
24942494 float *vec)
24952495 {
2496− const float uf = ((2.f * i) / width - 1.f);
2497− const float vf = ((2.f * j) / height - 1.f);
2496+ const float uf = ((2.f * i + 1.f) / width - 1.f);
2497+ const float vf = ((2.f * j + 1.f) / height - 1.f);
24982498
24992499 const float d = s->h_fov;
25002500 const float k = uf * uf / ((d + 1.f) * (d + 1.f));
@@ -2544,8 +2544,8 @@ static int cylindrical_to_xyz(const V360Context *s, · 43 unmodified lines
25442544 int i, int j, int width, int height,
25452545 float *vec)
25462546 {
2547− const float uf = s->flat_range[0] * ((2.f * i) / width - 1.f);
2548− const float vf = s->flat_range[1] * ((2.f * j) / height - 1.f);
2547+ const float uf = s->flat_range[0] * ((2.f * i + 1.f) / width - 1.f);
2548+ const float vf = s->flat_range[1] * ((2.f * j + 1.f) / height - 1.f);
25492549
25502550 const float phi = uf;
25512551 const float theta = atanf(vf);
@@ -2638,8 +2638,8 @@ static int perspective_to_xyz(const V360Context *s, · 86 unmodified lines
26382638 int i, int j, int width, int height,
26392639 float *vec)
26402640 {
2641− const float uf = ((2.f * i) / width - 1.f);
2642− const float vf = ((2.f * j) / height - 1.f);
2641+ const float uf = ((2.f * i + 1.f) / width - 1.f);
2642+ const float vf = ((2.f * j + 1.f) / height - 1.f);
26432643 const float rh = hypotf(uf, vf);
26442644 const float sinzz = 1.f - rh * rh;
26452645 const float h = 1.f + s->v_fov;

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