Signed-off-by: 凌怀 <huangyuxing....@alibaba-inc.com> --- libavfilter/vf_v360.c | 49 ++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 14 deletions(-)
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c index 0c47883d4d..c0dafe6bbe 100644 --- a/libavfilter/vf_v360.c +++ b/libavfilter/vf_v360.c @@ -1790,8 +1790,8 @@ static int hequirect_to_xyz(const V360Context *s, int i, int j, int width, int height, float *vec) { - const float phi = ((2.f * i + 0.5f) / width - 1.f) * M_PI_2; - const float theta = ((2.f * j + 0.5f) / height - 1.f) * M_PI_2; + const float phi = ((2.f * i + 1.0f) / width - 1.f) * M_PI_2; + const float theta = ((2.f * j + 1.0f) / height - 1.f) * M_PI_2; const float sin_phi = sinf(phi); const float cos_phi = cosf(phi); @@ -2158,8 +2158,8 @@ static int xyz_to_equirect(const V360Context *s, const float phi = atan2f(vec[0], vec[2]); const float theta = asinf(vec[1]); - const float uf = (phi / s->iflat_range[0] + 1.f) * width / 2.f; - const float vf = (theta / s->iflat_range[1] + 1.f) * height / 2.f; + const float uf = (phi / s->iflat_range[0] + 1.f) * width / 2.f - 0.5f; + const float vf = (theta / s->iflat_range[1] + 1.f) * height / 2.f - 0.5f; const int ui = floorf(uf); const int vi = floorf(vf); @@ -2866,7 +2866,7 @@ static int fisheye_to_xyz(const V360Context *s, int i, int j, int width, int height, float *vec) { - const float uf = s->flat_range[0] * ((2.f * i) / width - 1.f); + const float uf = s->flat_range[0] * ((2.f * i + 1.f) / width - 1.f); const float vf = s->flat_range[1] * ((2.f * j + 1.f) / height - 1.f); const float phi = atan2f(vf, uf); @@ -2932,6 +2932,9 @@ static int xyz_to_fisheye(const V360Context *s, uf = (uf + 0.5f) * width; vf = (vf + 0.5f) * height; + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3007,8 +3010,8 @@ static int xyz_to_pannini(const V360Context *s, const float x = S * sinf(phi); const float y = S * tanf(theta); - const float uf = (x + 1.f) * width / 2.f; - const float vf = (y + 1.f) * height / 2.f; + const float uf = (x + 1.f) * width / 2.f - 0.5f; + const float vf = (y + 1.f) * height / 2.f - 0.5f; const int ui = floorf(uf); const int vi = floorf(vf); @@ -3115,8 +3118,8 @@ static int xyz_to_cylindrical(const V360Context *s, const float phi = atan2f(vec[0], vec[2]) / s->iflat_range[0]; const float theta = asinf(vec[1]); - const float uf = (phi + 1.f) * (width - 1) / 2.f; - const float vf = (tanf(theta) / s->iflat_range[1] + 1.f) * height / 2.f; + const float uf = (phi + 1.f) * (width - 1) / 2.f - 0.5f; + const float vf = (tanf(theta) / s->iflat_range[1] + 1.f) * height / 2.f - 0.5f; const int ui = floorf(uf); const int vi = floorf(vf); @@ -3225,8 +3228,8 @@ static int xyz_to_cylindricalea(const V360Context *s, const float phi = atan2f(vec[0], vec[2]) / s->iflat_range[0]; const float theta = asinf(vec[1]); - const float uf = (phi + 1.f) * (width - 1) / 2.f; - const float vf = (sinf(theta) / s->iflat_range[1] + 1.f) * height / 2.f; + const float uf = (phi + 1.f) * (width - 1) / 2.f - 0.5f; + const float vf = (sinf(theta) / s->iflat_range[1] + 1.f) * height / 2.f - 0.5f; const int ui = floorf(uf); const int vi = floorf(vf); @@ -3361,6 +3364,9 @@ static int xyz_to_tetrahedron(const V360Context *s, uf *= width; vf *= height; + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3397,7 +3403,7 @@ static int dfisheye_to_xyz(const V360Context *s, const int ei = i >= ew ? i - ew : i; const float m = i >= ew ? 1.f : -1.f; - const float uf = s->flat_range[0] * ((2.f * ei) / ew - 1.f); + const float uf = s->flat_range[0] * ((2.f * ei + 1.f) / ew - 1.f); const float vf = s->flat_range[1] * ((2.f * j + 1.f) / eh - 1.f); const float h = hypotf(uf, vf); @@ -3452,6 +3458,9 @@ static int xyz_to_dfisheye(const V360Context *s, uf = ew - uf; } + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3491,8 +3500,8 @@ static int barrel_to_xyz(const V360Context *s, const int ew = 4 * width / 5; const int eh = height; - const float phi = ((2.f * i) / ew - 1.f) * M_PI / scale; - const float theta = ((2.f * j) / eh - 1.f) * theta_range / scale; + const float phi = ((2.f * i + 1.f) / ew - 1.f) * M_PI / scale; + const float theta = ((2.f * j + 1.f) / eh - 1.f) * theta_range / scale; const float sin_phi = sinf(phi); const float cos_phi = cosf(phi); @@ -3596,6 +3605,9 @@ static int xyz_to_barrel(const V360Context *s, vf = 0.5f * eh * (vf * scale + 1.f); } + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3692,6 +3704,9 @@ static int xyz_to_barrelsplit(const V360Context *s, vf = height * 0.25f * (vf * scaleh + 1.f) + v_offset; } + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3910,6 +3925,9 @@ static int xyz_to_tspyramid(const V360Context *s, uf *= width; vf *= height; + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3995,6 +4013,9 @@ static int xyz_to_octahedron(const V360Context *s, uf *= width; vf *= height; + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".