Move in out of loop.
Unified · Split
| @@ -1396,6 +1396,26 @@ static void equirect_to_xyz(const V360Context *s, · 1395 unmodified lines | |||
| 1396 | vec[2] = -cos_theta * cos_phi; | 1396 | vec[2] = -cos_theta * cos_phi; |
| 1397 | } | 1397 | } |
| 1398 | 1398 | ||
| 1399 | /** | ||
| 1400 | * Prepare data for processing stereographic output format. | ||
| 1401 | * | ||
| 1402 | * @param ctx filter context | ||
| 1403 | * | ||
| 1404 | * @return error code | ||
| 1405 | */ | ||
| 1406 | static int prepare_stereographic_out(AVFilterContext *ctx) | ||
| 1407 | { | ||
| 1408 | V360Context *s = ctx->priv; | ||
| 1409 | |||
| 1410 | const float h_angle = tan(FFMIN(s->h_fov, 359.f) * M_PI / 720.f); | ||
| 1411 | const float v_angle = tan(FFMIN(s->v_fov, 359.f) * M_PI / 720.f); | ||
| 1412 | |||
| 1413 | s->flat_range[0] = h_angle; | ||
| 1414 | s->flat_range[1] = v_angle; | ||
| 1415 | |||
| 1416 | return 0; | ||
| 1417 | } | ||
| 1418 | |||
| 1399 | /** | 1419 | /** |
| 1400 | * Calculate 3D coordinates on sphere for corresponding frame position in stereographic format. | 1420 | * Calculate 3D coordinates on sphere for corresponding frame position in stereographic format. |
| 1401 | * | 1421 | * |
| @@ -1410,11 +1430,8 @@ static void stereographic_to_xyz(const V360Context *s, · 8 unmodified lines | |||
| 1410 | int i, int j, int width, int height, | 1430 | int i, int j, int width, int height, |
| 1411 | float *vec) | 1431 | float *vec) |
| 1412 | { | 1432 | { |
| 1413 | const float h_angle = tan(FFMIN(s->h_fov, 359.f) * M_PI / 720.f); | 1433 | const float x = ((2.f * i) / width - 1.f) * s->flat_range[0]; |
| 1414 | const float v_angle = tan(FFMIN(s->v_fov, 359.f) * M_PI / 720.f); | 1434 | const float y = ((2.f * j) / height - 1.f) * s->flat_range[1]; |
| 1415 | |||
| 1416 | const float x = ((2.f * i) / width - 1.f) * h_angle; | ||
| 1417 | const float y = ((2.f * j) / height - 1.f) * v_angle; | ||
| 1418 | const float xy = x * x + y * y; | 1435 | const float xy = x * x + y * y; |
| 1419 | 1436 | ||
| 1420 | vec[0] = 2.f * x / (1.f + xy); | 1437 | vec[0] = 2.f * x / (1.f + xy); |
| @@ -2282,7 +2299,7 @@ static int config_output(AVFilterLink *outlink) · 861 unmodified lines | |||
| 2282 | break; | 2299 | break; |
| 2283 | case STEREOGRAPHIC: | 2300 | case STEREOGRAPHIC: |
| 2284 | out_transform = stereographic_to_xyz; | 2301 | out_transform = stereographic_to_xyz; |
| 2285 | err = 0; | 2302 | err = prepare_stereographic_out(ctx); |
| 2286 | w = FFMAX(roundf(wf), roundf(hf)); | 2303 | w = FFMAX(roundf(wf), roundf(hf)); |
| 2287 | h = w; | 2304 | h = w; |
| 2288 | break; | 2305 | break; |