Documentation
¶
Overview ¶
Package stereo describes how a video frame packs one or two eye images, and where each eye's pixels are.
It is deliberately just the packing. Nothing here knows about projection, decoding or displays: a frame is a rectangle, a layout says how it is divided, and the answer is a sub-rectangle. That separation is what lets the same 3840x1080 frame be read as two 1920x1080 eyes whether its content is a flat film, a 180-degree hemisphere or a full sphere.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Format ¶
type Format struct {
Layout Layout
// Swapped says the eye images are the other way round: the left half holds
// the RIGHT eye. It happens, it is not detectable from the pixels, and
// getting it wrong inverts the depth of the whole scene — near objects read
// as far — which viewers report as eye strain rather than as a wrong image.
// So it is an explicit flag, never a guess.
Swapped bool
}
Format fully describes how to read a frame.
func (Format) EyeRect ¶
EyeRect returns the region of a frameW x frameH frame holding eye's image.
An odd frame dimension cannot be halved exactly. Rather than round and let one eye silently read a column of the other, the split floors: with a 1921-wide side-by-side frame each eye gets 960 pixels and the middle column is left unread. Losing one column is invisible; a column of the wrong eye is not.
type Layout ¶
type Layout int
Layout is how a frame packs its eye images.
const ( // Mono is a single image; both eyes are given the whole frame and see the // same thing. Monoscopic 360 video is this. Mono Layout = iota // SideBySide splits the frame left half / right half. This is what the XR // glasses' own 3D display mode expects, and what most stereoscopic material // ships as. SideBySide // OverUnder splits the frame top half / bottom half. Preferred by some // encoders because it keeps the horizontal resolution intact, which matters // more than the vertical for a wide field of view. OverUnder )
The layouts encountered in real material.
func (Layout) AspectCorrection ¶
AspectCorrection is what an eye image's width must be multiplied by to undo the layout's anamorphic squeeze, so the content is measured in the same units whatever the packing.
Full-size side-by-side halves the horizontal resolution of each eye without changing what it depicts: a 3840x1080 side-by-side frame is two 1920x1080 eye images, each still covering the full field of view. So the pixels are not square any more, and a projection that assumes they are gets the geometry wrong by a factor of two. Over-under does the same to the vertical.
func (Layout) Stereoscopic ¶
Stereoscopic reports whether the layout carries two distinct eye images.