in Transform360/Library/VideoFrameTransform.cpp [903:933]
void VideoFrameTransform::transformInputPos(
float tx,
float ty,
float tz,
float inputPixelWidth,
float* outX,
float* outY) {
switch (ctx_.input_layout) {
case LAYOUT_CUBEMAP_32:
{
float d = sqrtf(tx * tx + ty * ty + tz * tz);
transformCubeFacePos(tx / d, ty / d, tz / d, outX, outY);
break;
}
default:
{
// Assumming equirect
float d = sqrtf(tx * tx + ty * ty + tz * tz);
*outX = -atan2f (-tx / d, tz / d) / (M_PI * 2.0f) + 0.5f;
if (ctx_.output_layout == LAYOUT_BARREL ||
ctx_.output_layout == LAYOUT_BARREL_SPLIT) {
// Clamp pixels on the right, since we might have padding from ffmpeg.
*outX = std::min(*outX, 1.0f - inputPixelWidth * 0.5f);
*outX = std::max(*outX, inputPixelWidth * 0.5f);
}
*outY = asinf (-ty / d) / M_PI + 0.5f;
break;
}
}
}