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
1610 int i, int j, int width, int height,1610 int i, int j, int width, int height,
1611 float *vec)1611 float *vec)
1612{1612{
1613 const float x = ((2.f * i) / width - 1.f) * s->flat_range[0];1613 const float x = ((2.f * i + 1.f) / width - 1.f) * s->flat_range[0];
1614 const float y = ((2.f * j) / height - 1.f) * s->flat_range[1];1614 const float y = ((2.f * j + 1.f) / height - 1.f) * s->flat_range[1];
1615 const float xy = x * x + y * y;1615 const float xy = x * x + y * y;
1616 1616
1617 vec[0] = 2.f * x / (1.f + xy);1617 vec[0] = 2.f * x / (1.f + xy);
@@ -1837,8 +1837,8 @@ static int mercator_to_xyz(const V360Context *s, · 219 unmodified lines
1837 int i, int j, int width, int height,1837 int i, int j, int width, int height,
1838 float *vec)1838 float *vec)
1839{1839{
1840 const float phi = ((2.f * i) / width - 1.f) * M_PI + M_PI_2;1840 const float phi = ((2.f * i + 1.f) / width - 1.f) * M_PI + M_PI_2;
1841 const float y = ((2.f * j) / height - 1.f) * M_PI;1841 const float y = ((2.f * j + 1.f) / height - 1.f) * M_PI;
1842 const float div = expf(2.f * y) + 1.f;1842 const float div = expf(2.f * y) + 1.f;
1843 1843
1844 const float sin_phi = sinf(phi);1844 const float sin_phi = sinf(phi);
@@ -1907,8 +1907,8 @@ static int ball_to_xyz(const V360Context *s, · 62 unmodified lines
1907 int i, int j, int width, int height,1907 int i, int j, int width, int height,
1908 float *vec)1908 float *vec)
1909{1909{
1910 const float x = (2.f * i) / width - 1.f;1910 const float x = (2.f * i + 1.f) / width - 1.f;
1911 const float y = (2.f * j) / height - 1.f;1911 const float y = (2.f * j + 1.f) / height - 1.f;
1912 const float l = hypotf(x, y);1912 const float l = hypotf(x, y);
1913 1913
1914 if (l <= 1.f) {1914 if (l <= 1.f) {
@@ -1941,8 +1941,8 @@ static int hammer_to_xyz(const V360Context *s, · 26 unmodified lines
1941 int i, int j, int width, int height,1941 int i, int j, int width, int height,
1942 float *vec)1942 float *vec)
1943{1943{
1944 const float x = ((2.f * i) / width - 1.f);1944 const float x = ((2.f * i + 1.f) / width - 1.f);
1945 const float y = ((2.f * j) / height - 1.f);1945 const float y = ((2.f * j + 1.f) / height - 1.f);
1946 1946
1947 const float xx = x * x;1947 const float xx = x * x;
1948 const float yy = y * y;1948 const float yy = y * y;
@@ -2022,8 +2022,8 @@ static int sinusoidal_to_xyz(const V360Context *s, · 73 unmodified lines
2022 int i, int j, int width, int height,2022 int i, int j, int width, int height,
2023 float *vec)2023 float *vec)
2024{2024{
2025 const float theta = ((2.f * j) / height - 1.f) * M_PI_2;2025 const float theta = ((2.f * j + 1.f) / height - 1.f) * M_PI_2;
2026 const float phi = ((2.f * i) / width - 1.f) * M_PI / cosf(theta);2026 const float phi = ((2.f * i + 1.f) / width - 1.f) * M_PI / cosf(theta);
2027 2027
2028 const float sin_phi = sinf(phi);2028 const float sin_phi = sinf(phi);
2029 const float cos_phi = cosf(phi);2029 const float cos_phi = cosf(phi);
@@ -2360,8 +2360,8 @@ static int flat_to_xyz(const V360Context *s, · 330 unmodified lines
2360 int i, int j, int width, int height,2360 int i, int j, int width, int height,
2361 float *vec)2361 float *vec)
2362{2362{
2363 const float l_x = s->flat_range[0] * (2.f * i / width - 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 / height - 1.f);2364 const float l_y = -s->flat_range[1] * ((2.f * j + 0.5f) / height - 1.f);
2365 2365
2366 vec[0] = l_x;2366 vec[0] = l_x;
2367 vec[1] = l_y;2367 vec[1] = l_y;
@@ -2493,8 +2493,8 @@ static int pannini_to_xyz(const V360Context *s, · 125 unmodified lines
2493 int i, int j, int width, int height,2493 int i, int j, int width, int height,
2494 float *vec)2494 float *vec)
2495{2495{
2496 const float uf = ((2.f * i) / width - 1.f);2496 const float uf = ((2.f * i + 1.f) / width - 1.f);
2497 const float vf = ((2.f * j) / height - 1.f);2497 const float vf = ((2.f * j + 1.f) / height - 1.f);
2498 2498
2499 const float d = s->h_fov;2499 const float d = s->h_fov;
2500 const float k = uf * uf / ((d + 1.f) * (d + 1.f));2500 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
2544 int i, int j, int width, int height,2544 int i, int j, int width, int height,
2545 float *vec)2545 float *vec)
2546{2546{
2547 const float uf = s->flat_range[0] * ((2.f * i) / width - 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) / height - 1.f);2548 const float vf = s->flat_range[1] * ((2.f * j + 1.f) / height - 1.f);
2549 2549
2550 const float phi = uf;2550 const float phi = uf;
2551 const float theta = atanf(vf);2551 const float theta = atanf(vf);
@@ -2638,8 +2638,8 @@ static int perspective_to_xyz(const V360Context *s, · 86 unmodified lines
2638 int i, int j, int width, int height,2638 int i, int j, int width, int height,
2639 float *vec)2639 float *vec)
2640{2640{
2641 const float uf = ((2.f * i) / width - 1.f);2641 const float uf = ((2.f * i + 1.f) / width - 1.f);
2642 const float vf = ((2.f * j) / height - 1.f);2642 const float vf = ((2.f * j + 1.f) / height - 1.f);
2643 const float rh = hypotf(uf, vf);2643 const float rh = hypotf(uf, vf);
2644 const float sinzz = 1.f - rh * rh;2644 const float sinzz = 1.f - rh * rh;
2645 const float h = 1.f + s->v_fov;2645 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