Quoting Vittorio Giovara (2016-11-15 18:07:33) > While no decoder currently exports spherical information, this type > represents a frame property that has to be passed through from container > to frames. > > Signed-off-by: Vittorio Giovara <[email protected]> > --- > Changed yaw, pitch, roll to be fixed point instead of double. > Vittorio > > doc/APIchanges | 4 ++ > libavutil/Makefile | 2 + > libavutil/frame.h | 6 +++ > libavutil/spherical.c | 34 ++++++++++++ > libavutil/spherical.h | 146 > ++++++++++++++++++++++++++++++++++++++++++++++++++ > 5 files changed, 192 insertions(+) > create mode 100644 libavutil/spherical.c > create mode 100644 libavutil/spherical.h > > diff --git a/doc/APIchanges b/doc/APIchanges > index 6e0d27d..4995043 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -13,6 +13,10 @@ libavutil: 2015-08-28 > > API changes, most recent first: > > +2016-xx-xx - xxxxxxx - lavu 55.29.0 - spherical.h > + Add AV_FRAME_DATA_SPHERICAL value, av_spherical_alloc() API and > + AVSphericalMapping type to export and describe spherical video properties. > + > 2016-xx-xx - xxxxxxx - lavu 55.28.0 - pixfmt.h > Add AV_PIX_FMT_GRAY12(LE/BE). > > diff --git a/libavutil/Makefile b/libavutil/Makefile > index fbcf1a7..28372c9 100644 > --- a/libavutil/Makefile > +++ b/libavutil/Makefile > @@ -48,6 +48,7 @@ HEADERS = adler32.h > \ > replaygain.h \ > samplefmt.h \ > sha.h \ > + spherical.h \ > stereo3d.h \ > time.h \ > version.h \ > @@ -102,6 +103,7 @@ OBJS = adler32.o > \ > rc4.o \ > samplefmt.o \ > sha.o \ > + spherical.o \ > stereo3d.o \ > time.o \ > tree.o \ > diff --git a/libavutil/frame.h b/libavutil/frame.h > index 12624d7..4052199 100644 > --- a/libavutil/frame.h > +++ b/libavutil/frame.h > @@ -92,6 +92,12 @@ enum AVFrameSideDataType { > * enum AVAudioServiceType defined in avcodec.h. > */ > AV_FRAME_DATA_AUDIO_SERVICE_TYPE, > + > + /** > + * The data represents the AVSphericalMapping structure defined in > + * libavutil/spherical.h. > + */ > + AV_FRAME_DATA_SPHERICAL, > }; > > enum AVActiveFormatDescription { > diff --git a/libavutil/spherical.c b/libavutil/spherical.c > new file mode 100644 > index 0000000..f6e53d1 > --- /dev/null > +++ b/libavutil/spherical.c > @@ -0,0 +1,34 @@ > +/* > + * Copyright (c) 2016 Vittorio Giovara <[email protected]> > + * > + * This file is part of Libav. > + * > + * Libav is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * Libav is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with Libav; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +#include "mem.h" > +#include "spherical.h" > + > +AVSphericalMapping *av_spherical_alloc(size_t *size) > +{ > + AVSphericalMapping *spherical = av_mallocz(sizeof(AVSphericalMapping)); > + if (!spherical) > + return NULL; > + > + if (size) > + *size = sizeof(*spherical); > + > + return spherical; > +} > diff --git a/libavutil/spherical.h b/libavutil/spherical.h > new file mode 100644 > index 0000000..a061516 > --- /dev/null > +++ b/libavutil/spherical.h > @@ -0,0 +1,146 @@ > +/* > + * Copyright (c) 2016 Vittorio Giovara <[email protected]> > + * > + * This file is part of Libav. > + * > + * Libav is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * Libav is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with Libav; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +/** > + * @file > + * Spherical video > + */ > + > +#ifndef AVUTIL_SPHERICAL_H > +#define AVUTIL_SPHERICAL_H > + > +/** > + * @addtogroup lavu_video > + * @{ > + * > + * @defgroup lavu_video_spherical Spherical video mapping > + * @{ > + */ > + > +/** > + * @addtogroup lavu_video_spherical > + * A spherical video file contains surfaces that need to be mapped onto a > + * sphere. Depending on how the frame was converted, a different distortion > + * transformation or surface recomposition function needs to be applied > before > + * the video should be mapped and displayed. > + */ > + > +/** > + * Projection of the video surface(s) on a sphere. > + */ > +enum AVSphericalProjection { > + /** > + * Video represents a sphere mapped on a flat surface. > + */ > + AV_SPHERICAL_EQUIRECTANGULAR, > + > + /** > + * Video frame is split into 6 faces of a cube, and arranged on a > + * 3x2 layout. Faces are oriented upwards for the front, left, right, > + * and back faces. The up face is oriented so the top of the face is > + * forwards and the down face is oriented so the top of the face is > + * to the back. > + */ > + AV_SPHERICAL_CUBEMAP, > +}; > + > +/** > + * This structure describes how to handle spherical videos, outlining > + * information about projection, initial layout, and any other view modifier. > + * > + * @note The struct must be allocated with av_spherical_alloc() and > + * its size is not a part of the public ABI. > + */ > +typedef struct AVSphericalMapping { > + /** > + * Projection type. > + */ > + enum AVSphericalProjection projection; > + > + /** > + * @name Initial orientation > + * @{ > + * These fields represent the pose values that measure the rotation > + * transformation (in degrees) to be applied to the projection. > + * They are exported as 16.16 fixed point. > + * > + * See this equirectangular projection as example: > + * > + * @code{.unparsed} > + * Yaw > + * -180 0 180 > + * 90 +-------------+-------------+ 180 > + * | | | > + * P | | o> | > + * i | ^ | > + * t 0 +-------------X-------------+ 0 Roll > + * c | | | > + * h | | | > + * | | | > + * -90 +-------------+-------------+ -180 > + * > + * X - the default camera center > + * ^ - the default up vector > + * > - the up vector for a rotation of 90 degrees > + * o - the image center for yaw = 90, pitch = 45, roll = 0 > + * @endcode > + * > + * The order of transformation is always yaw, followed by pitch, and > + * finally by roll. > + */ > + int32_t yaw; ///< Clockwise rotation around the up vector [-180, 180]. > + int32_t pitch; ///< Counter-clockwise rotation around the right vector > [-90, 90]. > + int32_t roll; ///< Counter-clockwise rotation around the forward vector > [-180, 180]. > + /** > + * @} > + */ > + > + /** > + * @name Bounding rectangle > + * @{ > + * These fields are the amount of pixels to crop from the edge > + * of the video surface. > + * > + * @note For cubemap projections these values apply to each > + * face of the cube. > + */ > + unsigned int left_offset; ///< Pixels to crop from the left edge. > + unsigned int top_offset; ///< Pixels to crop from the top edge. > + unsigned int right_offset; ///< Pixels to crop from the right edge. > + unsigned int bottom_offset; ///< Pixels to crop from the bottom edge.
I'm wondering if this should even be here and not in a separate side data type. In any case, in the name of the future it should probably be size_t rather than uint. -- Anton Khirnov _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
