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 <vittorio.giov...@gmail.com>
---
Modified the name, added more documentation, added cropping (!).
Moved to lavu as suggested by Anton.

Still undecided whether to leave double or fixed point for yaw pitch roll,
any ideas?
Vittorio

 doc/APIchanges        |  4 +++
 libavutil/Makefile    |  2 ++
 libavutil/frame.h     |  6 ++++
 libavutil/spherical.c | 29 +++++++++++++++
 libavutil/spherical.h | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++
 libavutil/version.h   |  2 +-
 6 files changed, 141 insertions(+), 1 deletion(-)
 create mode 100644 libavutil/spherical.c
 create mode 100644 libavutil/spherical.h

diff --git a/doc/APIchanges b/doc/APIchanges
index 735b947..b34d475 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.28.0 - spherical.h
+  Add AV_FRAME_DATA_SPHERICAL, av_spherical_alloc() and AVSphericalMapping
+  type to export and describe spherical video properties.
+
 2016-xx-xx - xxxxxxx - lavu 55.27.0 - hwcontext.h
   Add av_hwframe_map() and associated AV_HWFRAME_MAP_* flags.
   Add av_hwframe_ctx_create_derived().
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..d31ee8b
--- /dev/null
+++ b/libavutil/spherical.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016 Vittorio Giovara <vittorio.giov...@gmail.com>
+ *
+ * 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 <stdint.h>
+
+#include "mem.h"
+#include "spherical.h"
+
+AVSphericalMapping *av_spherical_alloc(void)
+{
+    return av_mallocz(sizeof(AVSphericalMapping));
+}
diff --git a/libavutil/spherical.h b/libavutil/spherical.h
new file mode 100644
index 0000000..f2f50b2
--- /dev/null
+++ b/libavutil/spherical.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2016 Vittorio Giovara <vittorio.giov...@gmail.com>
+ *
+ * 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
+ */
+
+#ifndef AVUTIL_SPHERICAL_H
+#define AVUTIL_SPHERICAL_H
+
+#include <stdint.h>
+
+#include "mem.h"
+
+/**
+ * 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;
+
+    /* @defgroup orientation
+     * @{
+     * Pose values measuring rotation in degrees to be applied to the
+     * projection. The transform order should be yaw, pitch, and roll.
+     */
+
+    double yaw;   ///< Clockwise around the up vector [-180, 180].
+    double pitch; ///< Counter-clockwise around the right vector [-90, 90].
+    double roll;  ///< Counter-clockwise around the forward vector [-180, 180].
+
+    /**
+     * @}
+     */
+
+    /**
+     * @defgroup bounds
+     * @{
+     * Amount of pixels to crop the edge of the video surface.
+     * @note for cubemap projections these values apply to each face.
+     */
+
+    unsigned int left_off;   ///< Pixels to crop from the left.
+    unsigned int top_off;    ///< Pixels to crop from the top.
+    unsigned int right_off;  ///< Pixels to crop from the right.
+    unsigned int bottom_off; ///< Pixels to crop from the bottom.
+
+    /**
+     * @}
+     */
+} AVSphericalMapping;
+
+/**
+ * Allocate a AVSphericalVideo structure and initialize its fields to default
+ * values.
+ *
+ * @return the newly allocated struct or NULL on failure
+ */
+AVSphericalMapping *av_spherical_alloc(void);
+
+#endif /* AVUTIL_SPHERICAL_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index 9287a0b..95aea2f 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 55
-#define LIBAVUTIL_VERSION_MINOR 27
+#define LIBAVUTIL_VERSION_MINOR 28
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.10.0

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to