mirror of https://git.ffmpeg.org/ffmpeg.git
lavfi/vf_v360: fix barrelsplit transform with padding
Make it match Facebook's transform360 (https://github.com/facebook/transform360) Fixes one part of #9725.
This commit is contained in:
parent
82784ddf33
commit
83a5ef5113
|
@ -3676,37 +3676,39 @@ static int xyz_to_barrelsplit(const V360Context *s,
|
||||||
} else {
|
} else {
|
||||||
const float scalew = s->fin_pad > 0 ? 1.f - s->fin_pad / (width / 3.f) : 1.f - s->in_pad;
|
const float scalew = s->fin_pad > 0 ? 1.f - s->fin_pad / (width / 3.f) : 1.f - s->in_pad;
|
||||||
const float scaleh = s->fin_pad > 0 ? 1.f - s->fin_pad / (height / 4.f) : 1.f - s->in_pad;
|
const float scaleh = s->fin_pad > 0 ? 1.f - s->fin_pad / (height / 4.f) : 1.f - s->in_pad;
|
||||||
int v_offset = 0;
|
|
||||||
|
|
||||||
ew = width / 3;
|
ew = width / 3;
|
||||||
eh = height / 4;
|
eh = height / 4;
|
||||||
|
|
||||||
u_shift = 2 * ew;
|
u_shift = 2 * ew;
|
||||||
|
|
||||||
|
uf = vec[0] / vec[1] * scalew;
|
||||||
|
vf = vec[2] / vec[1] * scaleh;
|
||||||
|
|
||||||
if (theta <= 0.f && theta >= -M_PI_2 &&
|
if (theta <= 0.f && theta >= -M_PI_2 &&
|
||||||
phi <= M_PI_2 && phi >= -M_PI_2) {
|
phi <= M_PI_2 && phi >= -M_PI_2) {
|
||||||
uf = -vec[0] / vec[1];
|
// front top
|
||||||
vf = -vec[2] / vec[1];
|
uf *= -1.0f;
|
||||||
|
vf = -(vf + 1.f) * scaleh + 1.f;
|
||||||
v_shift = 0;
|
v_shift = 0;
|
||||||
v_offset = -eh;
|
|
||||||
} else if (theta >= 0.f && theta <= M_PI_2 &&
|
} else if (theta >= 0.f && theta <= M_PI_2 &&
|
||||||
phi <= M_PI_2 && phi >= -M_PI_2) {
|
phi <= M_PI_2 && phi >= -M_PI_2) {
|
||||||
uf = vec[0] / vec[1];
|
// front bottom
|
||||||
vf = -vec[2] / vec[1];
|
vf = -(vf - 1.f) * scaleh;
|
||||||
v_shift = height * 0.25f;
|
v_shift = height * 0.25f;
|
||||||
} else if (theta <= 0.f && theta >= -M_PI_2) {
|
} else if (theta <= 0.f && theta >= -M_PI_2) {
|
||||||
uf = vec[0] / vec[1];
|
// back top
|
||||||
vf = vec[2] / vec[1];
|
vf = (vf - 1.f) * scaleh + 1.f;
|
||||||
v_shift = height * 0.5f;
|
v_shift = height * 0.5f;
|
||||||
v_offset = -eh;
|
|
||||||
} else {
|
} else {
|
||||||
uf = -vec[0] / vec[1];
|
// back bottom
|
||||||
vf = vec[2] / vec[1];
|
uf *= -1.0f;
|
||||||
|
vf = (vf + 1.f) * scaleh;
|
||||||
v_shift = height * 0.75f;
|
v_shift = height * 0.75f;
|
||||||
}
|
}
|
||||||
|
|
||||||
uf = 0.5f * width / 3.f * (uf * scalew + 1.f);
|
uf = 0.5f * width / 3.f * (uf + 1.f);
|
||||||
vf = height * 0.25f * (vf * scaleh + 1.f) + v_offset;
|
vf *= height * 0.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui = floorf(uf);
|
ui = floorf(uf);
|
||||||
|
@ -3764,29 +3766,22 @@ static int barrelsplit_to_xyz(const V360Context *s,
|
||||||
const float scalew = s->fout_pad > 0 ? 1.f - s->fout_pad / (width / 3.f) : 1.f - s->out_pad;
|
const float scalew = s->fout_pad > 0 ? 1.f - s->fout_pad / (width / 3.f) : 1.f - s->out_pad;
|
||||||
const float scaleh = s->fout_pad > 0 ? 1.f - s->fout_pad / (height / 4.f) : 1.f - s->out_pad;
|
const float scaleh = s->fout_pad > 0 ? 1.f - s->fout_pad / (height / 4.f) : 1.f - s->out_pad;
|
||||||
|
|
||||||
const int face = floorf(y * 4.f);
|
const float facef = floorf(y * 4.f);
|
||||||
|
const int face = facef;
|
||||||
const float dir_vert = (face == 1 || face == 3) ? 1.0f : -1.0f;
|
const float dir_vert = (face == 1 || face == 3) ? 1.0f : -1.0f;
|
||||||
float uf, vf;
|
float uf, vf;
|
||||||
|
|
||||||
uf = x * 3.f - 2.f;
|
uf = x * 3.f - 2.f;
|
||||||
|
|
||||||
switch (face) {
|
switch (face) {
|
||||||
case 0:
|
case 0: // front top
|
||||||
vf = y * 2.f;
|
case 1: // front bottom
|
||||||
uf = 1.f - uf;
|
uf = 1.f - uf;
|
||||||
vf = 0.5f - vf;
|
vf = (0.5f - 2.f * y) / scaleh + facef;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 2: // back top
|
||||||
vf = y * 2.f;
|
case 3: // back bottom
|
||||||
uf = 1.f - uf;
|
vf = (y * 2.f - 1.5f) / scaleh + 3.f - facef;
|
||||||
vf = 1.f - (vf - 0.5f);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
vf = y * 2.f - 0.5f;
|
|
||||||
vf = 1.f - (1.f - vf);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
vf = y * 2.f - 1.5f;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
l_x = (0.5f - uf) / scalew;
|
l_x = (0.5f - uf) / scalew;
|
||||||
|
|
Loading…
Reference in New Issue