Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com> --- Updated with fate changes and more consistent names. Please CC. Vittorio
doc/APIchanges | 5 +++ ffprobe.c | 11 +++++-- libavformat/dump.c | 10 ++++++ libavutil/spherical.h | 56 ++++++++++++++++++++++++++++++++++ libavutil/version.h | 2 +- tests/ref/fate/matroska-spherical-mono | 2 +- tests/ref/fate/mov-spherical-mono | 2 +- 7 files changed, 83 insertions(+), 5 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index d739895..663bab1 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.48.100 / 55.33.0 - spherical.h + Add AV_SPHERICAL_EQUIRECTANGULAR_TILE, and projection-specific properties + (bound_left, bound_top, bound_right, bound_bottom, padding) to + AVSphericalMapping. + 2017-02-13 - xxxxxxx - lavc 57.80.100 - avcodec.h Add AVCodecContext.hw_device_ctx. diff --git a/ffprobe.c b/ffprobe.c index 046f080..acda9bc 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("bound_left", spherical->bound_left); + print_int("bound_top", spherical->bound_top); + print_int("bound_right", spherical->bound_right); + print_int("bound_bottom", spherical->bound_bottom); + } 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..ae93c7a 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->bound_left, spherical->bound_top, + spherical->bound_right, spherical->bound_bottom); + } 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..3c9f3a5 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} + * +----------------+----------+ + * | |bound_top | + * | +--------+ | + * | bound_left |tile | | + * +<---------->| |<--->+bound_right + * | +--------+ | + * | | | + * | bound_bottom| | + * +----------------+----------+ + * @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 + bound_left + bound_right; + * original_height = tile->height + bound_top + bound_bottom; + * @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 bound_left; ///< Distance in pixels from the left edge + size_t bound_top; ///< Distance in pixels from the top edge + size_t bound_right; ///< Distance in pixels from the right edge + size_t bound_bottom; ///< Distance in pixels 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 a8b00bf..4d5a405 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 55 -#define LIBAVUTIL_VERSION_MINOR 47 +#define LIBAVUTIL_VERSION_MINOR 48 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/tests/ref/fate/matroska-spherical-mono b/tests/ref/fate/matroska-spherical-mono index 9f4b4f8..8048aff 100644 --- a/tests/ref/fate/matroska-spherical-mono +++ b/tests/ref/fate/matroska-spherical-mono @@ -7,7 +7,7 @@ inverted=0 [/SIDE_DATA] [SIDE_DATA] side_data_type=Spherical Mapping -side_data_size=16 +side_data_size=56 projection=equirectangular yaw=45 pitch=30 diff --git a/tests/ref/fate/mov-spherical-mono b/tests/ref/fate/mov-spherical-mono index 9f4b4f8..8048aff 100644 --- a/tests/ref/fate/mov-spherical-mono +++ b/tests/ref/fate/mov-spherical-mono @@ -7,7 +7,7 @@ inverted=0 [/SIDE_DATA] [SIDE_DATA] side_data_type=Spherical Mapping -side_data_size=16 +side_data_size=56 projection=equirectangular yaw=45 pitch=30 -- 2.10.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel