[FFmpeg-devel] [PATCH 1/3] spherical: Add tiled equirectangular type and projection-specific properties

Vittorio Giovara vittorio.giovara at gmail.com
Fri Feb 10 23:11:43 EET 2017


Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
---
This should help not losing details over muxing and allows
callers to get additional information in a clean manner.

Please keep me in CC.
Vittorio

 doc/APIchanges        |  5 +++++
 ffprobe.c             | 11 ++++++++--
 libavformat/dump.c    | 10 +++++++++
 libavutil/spherical.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++
 libavutil/version.h   |  2 +-
 5 files changed, 81 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 8bca71e..8268295 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,11 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2017-02-10 - xxxxxxx - lavu 55.47.100 / 55.31.0 - spherical.h
+  Add AV_SPHERICAL_EQUIRECTANGULAR_TILE, and projection-specific properties
+  (left_bound, top_bound, right_bound, bottom_bound, padding) to
+  AVSphericalMapping.
+
 2017-01-31 - xxxxxxx - lavu 55.46.100 / 55.20.0 - cpu.h
   Add AV_CPU_FLAG_SSSE3SLOW.
 
diff --git a/ffprobe.c b/ffprobe.c
index 046f080..dafac56 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -1788,9 +1788,16 @@ static void print_pkt_side_data(WriterContext *w,
             const AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data;
             if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR)
                 print_str("projection", "equirectangular");
-            else if (spherical->projection == AV_SPHERICAL_CUBEMAP)
+            else if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
                 print_str("projection", "cubemap");
-            else
+                print_int("padding", spherical->padding);
+            } else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
+                print_str("projection", "tiled equirectangular");
+                print_int("left_bound", spherical->left_bound);
+                print_int("top_bound", spherical->top_bound);
+                print_int("right_bound", spherical->right_bound);
+                print_int("bottom_bound", spherical->bottom_bound);
+            } else
                 print_str("projection", "unknown");
 
             print_int("yaw", (double) spherical->yaw / (1 << 16));
diff --git a/libavformat/dump.c b/libavformat/dump.c
index d9aa3af..6fbbd5a 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -357,6 +357,8 @@ static void dump_spherical(void *ctx, AVPacketSideData *sd)
         av_log(ctx, AV_LOG_INFO, "equirectangular ");
     else if (spherical->projection == AV_SPHERICAL_CUBEMAP)
         av_log(ctx, AV_LOG_INFO, "cubemap ");
+    else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE)
+        av_log(ctx, AV_LOG_INFO, "tiled equirectangular ");
     else {
         av_log(ctx, AV_LOG_WARNING, "unknown");
         return;
@@ -366,6 +368,14 @@ static void dump_spherical(void *ctx, AVPacketSideData *sd)
     pitch = ((double)spherical->pitch) / (1 << 16);
     roll = ((double)spherical->roll) / (1 << 16);
     av_log(ctx, AV_LOG_INFO, "(%f/%f/%f) ", yaw, pitch, roll);
+
+    if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
+        av_log(ctx, AV_LOG_INFO, "[%zu, %zu, %zu, %zu] ",
+               spherical->left_bound, spherical->top_bound,
+               spherical->right_bound, spherical->bottom_bound);
+    } else if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
+        av_log(ctx, AV_LOG_INFO, "[pad %zu] ", spherical->padding);
+    }
 }
 
 static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
diff --git a/libavutil/spherical.h b/libavutil/spherical.h
index eeda625..0cfd0d9 100644
--- a/libavutil/spherical.h
+++ b/libavutil/spherical.h
@@ -63,6 +63,13 @@ enum AVSphericalProjection {
      * to the back.
      */
     AV_SPHERICAL_CUBEMAP,
+
+    /**
+     * Video represents a portion of a sphere mapped on a flat surface
+     * using equirectangular projection. The @ref bounding fields indicate
+     * the position of the current video in a larger surface.
+     */
+    AV_SPHERICAL_EQUIRECTANGULAR_TILE,
 };
 
 /**
@@ -122,6 +129,55 @@ typedef struct AVSphericalMapping {
     /**
      * @}
      */
+
+    /**
+     * @name Bounding rectangle
+     * @anchor bounding
+     * @{
+     * These fields indicate the location of the current tile, and where
+     * it should be mapped relative to the original surface.
+     *
+     * @code{.unparsed}
+     *      +----------------+----------+
+     *      |                |top_bound |
+     *      |            +--------+     |
+     *      | left_bound |tile    |     |
+     *      +<---------->|        |<--->+right_bound
+     *      |            +--------+     |
+     *      |                |          |
+     *      |    bottom_bound|          |
+     *      +----------------+----------+
+     * @endcode
+     *
+     * If needed, the original video surface dimensions can be derived
+     * by adding the current stream or frame size to the related bounds,
+     * like in the following example:
+     *
+     * @code{c}
+     *     original_width  = tile->width  + left_bound + right_bound;
+     *     original_height = tile->height + top_bound  + bottom_bound;
+     * @endcode
+     *
+     * @note These values are valid only for the tiled equirectangular
+     *       projection type (@ref AV_SPHERICAL_EQUIRECTANGULAR_TILE),
+     *       and should be ignored in all other cases.
+     */
+    size_t left_bound;   ///< Distance in pixel from the left edge
+    size_t top_bound;    ///< Distance in pixel from the top edge
+    size_t right_bound;  ///< Distance in pixel from the right edge
+    size_t bottom_bound; ///< Distance in pixel from the bottom edge
+    /**
+     * @}
+     */
+
+    /**
+     * Amount of pixel to pad from the edge of each cube face.
+     *
+     * @note This value is valid for only for the cubemap projection type
+     *       (@ref AV_SPHERICAL_CUBEMAP), and should be ignored in all other
+     *       cases.
+     */
+    size_t padding;
 } AVSphericalMapping;
 
 /**
diff --git a/libavutil/version.h b/libavutil/version.h
index 8866064..a8b00bf 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  55
-#define LIBAVUTIL_VERSION_MINOR  46
+#define LIBAVUTIL_VERSION_MINOR  47
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.10.0



More information about the ffmpeg-devel mailing list