[FFmpeg-devel] [PATCH 2/3 v2] lavc: Add spherical packet side data API

James Almer jamrial at gmail.com
Thu Nov 17 04:26:54 EET 2016


On 11/15/2016 1:56 PM, Vittorio Giovara wrote:
> Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
> ---
> Updated to use int32 for rotation.
> Please CC.
> Vittorio
[...]

> diff --git a/libavformat/dump.c b/libavformat/dump.c
> index cd14625..2dd7a0a 100644
> --- a/libavformat/dump.c
> +++ b/libavformat/dump.c
> @@ -31,6 +31,7 @@
>  #include "libavutil/opt.h"
>  #include "libavutil/avstring.h"
>  #include "libavutil/replaygain.h"
> +#include "libavutil/spherical.h"
>  #include "libavutil/stereo3d.h"
>  
>  #include "avformat.h"
> @@ -342,6 +343,37 @@ static void dump_mastering_display_metadata(void *ctx, AVPacketSideData* sd) {
>             av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance));
>  }
>  
> +static void dump_spherical(void *ctx, AVPacketSideData *sd)
> +{
> +    AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data;
> +    double yaw, pitch, roll;
> +
> +    if (sd->size < sizeof(*spherical)) {

sizeof(AVSphericalMapping) is explicitly not part of the ABI, and this file is
in libavformat.

i know Stereo3D, Mastering Display, and probably other side data types are
doing the same, so maybe something like av_{stereo3d,spherical}_size() should
be added to all of them in order to solve this.

> +        av_log(ctx, AV_LOG_INFO, "invalid data");
> +        return;
> +    }
> +
> +    if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR)
> +        av_log(ctx, AV_LOG_INFO, "equirectangular ");
> +    else if (spherical->projection == AV_SPHERICAL_CUBEMAP)
> +        av_log(ctx, AV_LOG_INFO, "cubemap ");
> +    else {
> +        av_log(ctx, AV_LOG_WARNING, "unknown");
> +        return;
> +    }
> +
> +    yaw = ((double)spherical->yaw) / (1 << 16);
> +    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->left_offset || spherical->top_offset ||
> +        spherical->right_offset || spherical->bottom_offset)
> +        av_log(ctx, AV_LOG_INFO, "[%d-%d-%d-%d] ",
> +               spherical->left_offset, spherical->top_offset,
> +               spherical->right_offset, spherical->bottom_offset);
> +}
> +
>  static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
>  {
>      int i;
> @@ -393,6 +425,10 @@ static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
>          case AV_PKT_DATA_MASTERING_DISPLAY_METADATA:
>              dump_mastering_display_metadata(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_INFO,
>                     "unknown side data type %d (%d bytes)", sd.type, sd.size);
> 



More information about the ffmpeg-devel mailing list