avfilter/vf_v360: fix mercator_to_xyz()

pull/323/head
Paul B Mahol 5 years ago
parent b4d2bea647
commit a8925d264a
  1. 15
      libavfilter/vf_v360.c

@ -1589,17 +1589,18 @@ static void mercator_to_xyz(const V360Context *s,
int i, int j, int width, int height, int i, int j, int width, int height,
float *vec) float *vec)
{ {
const float phi = ((2.f * i) / width - 1.f) * M_PI; const float phi = ((2.f * i) / width - 1.f) * M_PI + M_PI_2;
const float theta = atanf(sinhf(((2.f * j) / height - 1.f) * 2.f * M_PI)); const float y = ((2.f * j) / height - 1.f) * M_PI;
const float div = expf(2.f * y) + 1.f;
const float sin_phi = sinf(phi); const float sin_phi = sinf(phi);
const float cos_phi = cosf(phi); const float cos_phi = cosf(phi);
const float sin_theta = sinf(theta); const float sin_theta = -2.f * expf(y) / div;
const float cos_theta = cosf(theta); const float cos_theta = -(expf(2.f * y) - 1.f) / div;
vec[0] = cos_theta * sin_phi; vec[0] = sin_theta * cos_phi;
vec[1] = -sin_theta; vec[1] = cos_theta;
vec[2] = -cos_theta * cos_phi; vec[2] = sin_theta * sin_phi;
} }
/** /**

Loading…
Cancel
Save