History

lavfi/vf_v360: fix barrelsplit transform with padding

Make it match Facebook's transform360 (https://github.com/facebook/transform360) Fixes one part of #9725.

Anton Khirnov committed 4 years ago

Commit 83a5ef51 parent 82784dd1 file · +23 −28Browse files

Unified · Split

libavfilter/vf_v360.c+23−28
@@ -3676,37 +3676,39 @@ static int xyz_to_barrelsplit(const V360Context *s, · 3675 unmodified lines
3676 } else {3676 } else {
3677 const float scalew = s->fin_pad > 0 ? 1.f - s->fin_pad / (width / 3.f) : 1.f - s->in_pad;3677 const float scalew = s->fin_pad > 0 ? 1.f - s->fin_pad / (width / 3.f) : 1.f - s->in_pad;
3678 const float scaleh = s->fin_pad > 0 ? 1.f - s->fin_pad / (height / 4.f) : 1.f - s->in_pad;3678 const float scaleh = s->fin_pad > 0 ? 1.f - s->fin_pad / (height / 4.f) : 1.f - s->in_pad;
3679 int v_offset = 0;
3680 3679
3681 ew = width / 3;3680 ew = width / 3;
3682 eh = height / 4;3681 eh = height / 4;
3683 3682
3684 u_shift = 2 * ew;3683 u_shift = 2 * ew;
3685 3684
3685 uf = vec[0] / vec[1] * scalew;
3686 vf = vec[2] / vec[1] * scaleh;
3687
3686 if (theta <= 0.f && theta >= -M_PI_2 &&3688 if (theta <= 0.f && theta >= -M_PI_2 &&
3687 phi <= M_PI_2 && phi >= -M_PI_2) {3689 phi <= M_PI_2 && phi >= -M_PI_2) {
3688 uf = -vec[0] / vec[1];3690 // front top
3689 vf = -vec[2] / vec[1];3691 uf *= -1.0f;
3692 vf = -(vf + 1.f) * scaleh + 1.f;
3690 v_shift = 0;3693 v_shift = 0;
3691 v_offset = -eh;
3692 } else if (theta >= 0.f && theta <= M_PI_2 &&3694 } else if (theta >= 0.f && theta <= M_PI_2 &&
3693 phi <= M_PI_2 && phi >= -M_PI_2) {3695 phi <= M_PI_2 && phi >= -M_PI_2) {
3694 uf = vec[0] / vec[1];3696 // front bottom
3695 vf = -vec[2] / vec[1];3697 vf = -(vf - 1.f) * scaleh;
3696 v_shift = height * 0.25f;3698 v_shift = height * 0.25f;
3697 } else if (theta <= 0.f && theta >= -M_PI_2) {3699 } else if (theta <= 0.f && theta >= -M_PI_2) {
3698 uf = vec[0] / vec[1];3700 // back top
3699 vf = vec[2] / vec[1];3701 vf = (vf - 1.f) * scaleh + 1.f;
3700 v_shift = height * 0.5f;3702 v_shift = height * 0.5f;
3701 v_offset = -eh;
3702 } else {3703 } else {
3703 uf = -vec[0] / vec[1];3704 // back bottom
3704 vf = vec[2] / vec[1];3705 uf *= -1.0f;
3706 vf = (vf + 1.f) * scaleh;
3705 v_shift = height * 0.75f;3707 v_shift = height * 0.75f;
3706 }3708 }
3707 3709
3708 uf = 0.5f * width / 3.f * (uf * scalew + 1.f);3710 uf = 0.5f * width / 3.f * (uf + 1.f);
3709 vf = height * 0.25f * (vf * scaleh + 1.f) + v_offset;3711 vf *= height * 0.25f;
3710 }3712 }
3711 3713
3712 ui = floorf(uf);3714 ui = floorf(uf);
@@ -3764,29 +3766,22 @@ static int barrelsplit_to_xyz(const V360Context *s, · 51 unmodified lines
3764 const float scalew = s->fout_pad > 0 ? 1.f - s->fout_pad / (width / 3.f) : 1.f - s->out_pad;3766 const float scalew = s->fout_pad > 0 ? 1.f - s->fout_pad / (width / 3.f) : 1.f - s->out_pad;
3765 const float scaleh = s->fout_pad > 0 ? 1.f - s->fout_pad / (height / 4.f) : 1.f - s->out_pad;3767 const float scaleh = s->fout_pad > 0 ? 1.f - s->fout_pad / (height / 4.f) : 1.f - s->out_pad;
3766 3768
3767 const int face = floorf(y * 4.f);3769 const float facef = floorf(y * 4.f);
3770 const int face = facef;
3768 const float dir_vert = (face == 1 || face == 3) ? 1.0f : -1.0f;3771 const float dir_vert = (face == 1 || face == 3) ? 1.0f : -1.0f;
3769 float uf, vf;3772 float uf, vf;
3770 3773
3771 uf = x * 3.f - 2.f;3774 uf = x * 3.f - 2.f;
3772 3775
3773 switch (face) {3776 switch (face) {
3774 case 0:3777 case 0: // front top
3775 vf = y * 2.f;3778 case 1: // front bottom
3776 uf = 1.f - uf;3779 uf = 1.f - uf;
3777 vf = 0.5f - vf;3780 vf = (0.5f - 2.f * y) / scaleh + facef;
3778 break;
3779 case 1:
3780 vf = y * 2.f;
3781 uf = 1.f - uf;
3782 vf = 1.f - (vf - 0.5f);
3783 break;
3784 case 2:
3785 vf = y * 2.f - 0.5f;
3786 vf = 1.f - (1.f - vf);
3787 break;3781 break;
3788 case 3:3782 case 2: // back top
3789 vf = y * 2.f - 1.5f;3783 case 3: // back bottom
3784 vf = (y * 2.f - 1.5f) / scaleh + 3.f - facef;
3790 break;3785 break;
3791 }3786 }
3792 l_x = (0.5f - uf) / scalew;3787 l_x = (0.5f - uf) / scalew;

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