Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com> --- avprobe.c | 20 ++++++++++++++ doc/APIchanges | 4 +++ libavcodec/avcodec.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ libavcodec/utils.c | 12 +++++++++ libavcodec/version.h | 4 +-- libavformat/dump.c | 28 ++++++++++++++++++++ 6 files changed, 140 insertions(+), 2 deletions(-)
diff --git a/avprobe.c b/avprobe.c index eff9c0d..474b325 100644 --- a/avprobe.c +++ b/avprobe.c @@ -729,6 +729,7 @@ static void show_stream(InputFile *ifile, InputStream *ist) for (i = 0; i < stream->nb_side_data; i++) { const AVPacketSideData* sd = &stream->side_data[i]; AVStereo3D *stereo; + AVSphericalVideo *spherical; switch (sd->type) { case AV_PKT_DATA_DISPLAYMATRIX: @@ -749,6 +750,25 @@ static void show_stream(InputFile *ifile, InputStream *ist) !!(stereo->flags & AV_STEREO3D_FLAG_INVERT)); probe_object_footer("stereo3d"); break; + case AV_PKT_DATA_SPHERICAL: + spherical = (AVSphericalVideo *)sd->data; + probe_object_header("spherical"); + + if (spherical->type == AV_SPHERICAL_EQUIRECTANGULAR) + probe_str("projection", "equirectangular"); + else if (spherical->type == AV_SPHERICAL_CUBEMAP) + probe_str("projection", "cubemap"); + else if (spherical->type == AV_SPHERICAL_MESH) + probe_str("projection", "mesh"); + else + probe_str("projection", "unknown"); + + probe_int("yaw", spherical->yaw); + probe_int("pitch", spherical->pitch); + probe_int("roll", spherical->roll); + + probe_object_footer("spherical"); + break; } } probe_object_footer("sidedata"); diff --git a/doc/APIchanges b/doc/APIchanges index 011ff0a..8079d02 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,10 @@ libavutil: 2015-08-28 API changes, most recent first: +2016-xx-xx - xxxxxxx - lavc 57.29.0 - avcodec.h + Add AVSphericalVideo type, av_spherical_alloc() API, and + AV_PKT_DATA_SPHERICAL packet side data to export 360 video information. + 2016-xx-xx - xxxxxxx - lavu 55.25.0 - pixfmt.h Add AV_PIX_FMT_GBRAP12(LE/BE). diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 88e6c62..439177d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -702,6 +702,63 @@ enum AVAudioServiceType { AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI }; +/** + * Video surface should be mapped on a sphere, and probably needs additional + * processing before it can be displayed. + */ +enum AVSphericalType { + /** + * 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, + + /** + * Video represents a mesh containing vertexes and texture coordinates. + */ + AV_SPHERICAL_MESH, +}; + +/** + * Spherical video type: this structure describes how to handle spherical + * videos, outlining information such as the projection type and the initial + * orientation. + * + * @note The struct must be allocated with av_spherical_alloc() and + * its size is not a part of the public ABI. + */ +typedef struct AVSphericalVideo { + /** + * Projection type. + */ + enum AVSphericalType type; + + /** + * Clockwise rotation in degrees around the up vector, [-180.0, 180.0]. + */ + double yaw; + + /** + * Counter-clockwise rotation in degrees around the right vector + * post yaw transform, [-90.0, 90.0]. + */ + double pitch; + + /** + * Counter-clockwise rotation in degrees around the forward vector post + * yaw and pitch transform, [-180.0, 180.0]. + */ + double roll; +} AVSphericalVideo; + /** * @ingroup lavc_encoding */ @@ -1289,6 +1346,12 @@ enum AVPacketSideDataType { * This side data corresponds to the AVCPBProperties struct. */ AV_PKT_DATA_CPB_PROPERTIES, + + /** + * This side data should be associated with a video stream and corresponds + * to the AVSphericalVideo struct. + */ + AV_PKT_DATA_SPHERICAL, }; typedef struct AVPacketSideData { @@ -5340,6 +5403,17 @@ const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name); */ AVCPBProperties *av_cpb_properties_alloc(size_t *size); +/** + * Allocate a AVSphericalVideo structure initialize its fields to default + * values. + * + * @param size if non-NULL, the size of the allocated struct will be written + * here. This is useful for embedding it in side data. + * + * @return the newly allocated struct or NULL on failure + */ +AVSphericalVideo *av_spherical_alloc(size_t *size); + /** * @} */ diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 329233d..110d37c 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2779,6 +2779,18 @@ AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx) return props; } +AVSphericalVideo *av_spherical_alloc(size_t *size) +{ + AVSphericalVideo *spherical = av_mallocz(sizeof(AVSphericalVideo)); + if (!spherical) + return NULL; + + if (size) + *size = sizeof(*spherical); + + return spherical; +} + static void codec_parameters_reset(AVCodecParameters *par) { av_freep(&par->extradata); diff --git a/libavcodec/version.h b/libavcodec/version.h index 6f439c0..6b6d16b 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,8 +28,8 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 57 -#define LIBAVCODEC_VERSION_MINOR 28 -#define LIBAVCODEC_VERSION_MICRO 1 +#define LIBAVCODEC_VERSION_MINOR 29 +#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavformat/dump.c b/libavformat/dump.c index 3b50f5d..61f438f 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -306,6 +306,30 @@ static void dump_cpb(void *ctx, AVPacketSideData *sd) cpb->vbv_delay); } +static void dump_spherical(void *ctx, AVPacketSideData *sd) +{ + AVSphericalVideo *spherical = (AVSphericalVideo *)sd->data; + + if (sd->size < sizeof(*spherical)) { + av_log(ctx, AV_LOG_INFO, "invalid data"); + return; + } + + if (spherical->type == AV_SPHERICAL_EQUIRECTANGULAR) + av_log(ctx, AV_LOG_INFO, "equirectangular "); + else if (spherical->type == AV_SPHERICAL_CUBEMAP) + av_log(ctx, AV_LOG_INFO, "cubemap "); + else if (spherical->type == AV_SPHERICAL_MESH) + av_log(ctx, AV_LOG_INFO, "mesh "); + else { + av_log(ctx, AV_LOG_WARNING, "unknown"); + return; + } + + av_log(ctx, AV_LOG_INFO, "(%f/%f/%f) ", + spherical->yaw, spherical->pitch, spherical->roll); +} + static void dump_sidedata(void *ctx, AVStream *st, const char *indent) { int i; @@ -354,6 +378,10 @@ static void dump_sidedata(void *ctx, AVStream *st, const char *indent) av_log(ctx, AV_LOG_INFO, "cpb: "); dump_cpb(ctx, &sd); break; + case AV_PKT_DATA_SPHERICAL: + av_log(ctx, AV_LOG_INFO, "spherical: "); + dump_spherical(ctx, &sd); + break; default: av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)", sd.type, sd.size); -- 2.10.0 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel