History

avfilter/vf_v360: make FOV adjusted for dual fisheye too

Remove any usage of padding for this format.

Paul B Mahol committed 6 years ago

Commit 29708461 parent d8147c42 files · +25 −21Browse files

Unified · Split

2 files
  1. doc/filters.texi +11 −11
  2. libavfilter/vf_v360.c +14 −10
doc/filters.texi+11−11
@@ -19043,19 +19043,19 @@ Dual fisheye. · 19042 unmodified lines
19043 19043
19044Format specific options:19044Format specific options:
19045@table @option19045@table @option
19046@item in_pad19046@item h_fov
19047@item out_pad19047@item v_fov
19048Set padding proportion. Values in decimals.19048@item d_fov
19049Set output horizontal/vertical/diagonal field of view. Values in degrees.
19049 19050
19050Example values:19051If diagonal field of view is set it overrides horizontal and vertical field of view.
19051@table @samp
19052@item 0
19053No padding.
19054@item 0.01
190551% padding.
19056@end table
19057 19052
19058Default value is @b{@samp{0}}.19053@item ih_fov
19054@item iv_fov
19055@item id_fov
19056Set input horizontal/vertical/diagonal field of view. Values in degrees.
19057
19058If diagonal field of view is set it overrides horizontal and vertical field of view.
19059@end table19059@end table
19060 19060
19061@item barrel19061@item barrel
libavfilter/vf_v360.c+14−10
@@ -2991,16 +2991,14 @@ static int dfisheye_to_xyz(const V360Context *s, · 2990 unmodified lines
2991 int i, int j, int width, int height,2991 int i, int j, int width, int height,
2992 float *vec)2992 float *vec)
2993{2993{
2994 const float scale = 1.f + s->out_pad;
2995
2996 const float ew = width / 2.f;2994 const float ew = width / 2.f;
2997 const float eh = height;2995 const float eh = height;
2998 2996
2999 const int ei = i >= ew ? i - ew : i;2997 const int ei = i >= ew ? i - ew : i;
3000 const float m = i >= ew ? 1.f : -1.f;2998 const float m = i >= ew ? 1.f : -1.f;
3001 2999
3002 const float uf = ((2.f * ei) / ew - 1.f) * scale;3000 const float uf = s->flat_range[0] * ((2.f * ei) / ew - 1.f);
3003 const float vf = ((2.f * j + 1.f) / eh - 1.f) * scale;3001 const float vf = s->flat_range[1] * ((2.f * j + 1.f) / eh - 1.f);
3004 3002
3005 const float h = hypotf(uf, vf);3003 const float h = hypotf(uf, vf);
3006 const float lh = h > 0.f ? h : 1.f;3004 const float lh = h > 0.f ? h : 1.f;
@@ -3034,8 +3032,6 @@ static int xyz_to_dfisheye(const V360Context *s, · 27 unmodified lines
3034 const float *vec, int width, int height,3032 const float *vec, int width, int height,
3035 int16_t us[4][4], int16_t vs[4][4], float *du, float *dv)3033 int16_t us[4][4], int16_t vs[4][4], float *du, float *dv)
3036{3034{
3037 const float scale = 1.f - s->in_pad;
3038
3039 const float ew = width / 2.f;3035 const float ew = width / 2.f;
3040 const float eh = height;3036 const float eh = height;
3041 3037
@@ -3043,8 +3039,8 @@ static int xyz_to_dfisheye(const V360Context *s, · 1 unmodified line
3043 const float lh = h > 0.f ? h : 1.f;3039 const float lh = h > 0.f ? h : 1.f;
3044 const float theta = acosf(fabsf(vec[2])) / M_PI;3040 const float theta = acosf(fabsf(vec[2])) / M_PI;
3045 3041
3046 float uf = (theta * (vec[0] / lh) * s->input_mirror_modifier[0] * scale + 0.5f) * ew;3042 float uf = (theta * (vec[0] / lh) * s->input_mirror_modifier[0] / s->iflat_range[0] + 0.5f) * ew;
3047 float vf = (theta * (vec[1] / lh) * s->input_mirror_modifier[1] * scale + 0.5f) * eh;3043 float vf = (theta * (vec[1] / lh) * s->input_mirror_modifier[1] / s->iflat_range[1] + 0.5f) * eh;
3048 3044
3049 int ui, vi;3045 int ui, vi;
3050 int u_shift;3046 int u_shift;
@@ -3657,6 +3653,14 @@ static void fov_from_dfov(int format, float d_fov, float w, float h, float *h_fo · 606 unmodified lines
3657 *v_fov = 2.f * atan2f(h * 0.5f, l) * 360.f / M_PI;3653 *v_fov = 2.f * atan2f(h * 0.5f, l) * 360.f / M_PI;
3658 }3654 }
3659 break;3655 break;
3656 case DUAL_FISHEYE:
3657 {
3658 const float d = 0.5f * hypotf(w * 0.5f, h);
3659
3660 *h_fov = d / w * 2.f * d_fov;
3661 *v_fov = d / h * d_fov;
3662 }
3663 break;
3660 case FISHEYE:3664 case FISHEYE:
3661 {3665 {
3662 const float d = 0.5f * hypotf(w, h);3666 const float d = 0.5f * hypotf(w, h);
@@ -3928,7 +3932,7 @@ static int config_output(AVFilterLink *outlink) · 265 unmodified lines
3928 return AVERROR(EINVAL);3932 return AVERROR(EINVAL);
3929 case DUAL_FISHEYE:3933 case DUAL_FISHEYE:
3930 s->in_transform = xyz_to_dfisheye;3934 s->in_transform = xyz_to_dfisheye;
3931 err = 0;3935 err = prepare_fisheye_in(ctx);
3932 wf = w;3936 wf = w;
3933 hf = h;3937 hf = h;
3934 break;3938 break;
@@ -4058,7 +4062,7 @@ static int config_output(AVFilterLink *outlink) · 123 unmodified lines
4058 break;4062 break;
4059 case DUAL_FISHEYE:4063 case DUAL_FISHEYE:
4060 s->out_transform = dfisheye_to_xyz;4064 s->out_transform = dfisheye_to_xyz;
4061 prepare_out = NULL;4065 prepare_out = prepare_fisheye_out;
4062 w = lrintf(wf);4066 w = lrintf(wf);
4063 h = lrintf(hf);4067 h = lrintf(hf);
4064 break;4068 break;

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