From patchwork Fri Nov 11 22:49:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vittorio Giovara X-Patchwork-Id: 1388 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp12836vsb; Fri, 11 Nov 2016 15:01:47 -0800 (PST) X-Received: by 10.28.137.81 with SMTP id l78mr310206wmd.36.1478905307115; Fri, 11 Nov 2016 15:01:47 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 62si13306327wml.99.2016.11.11.15.01.45; Fri, 11 Nov 2016 15:01:47 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3DBE9689EDD; Sat, 12 Nov 2016 01:01:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f196.google.com (mail-qk0-f196.google.com [209.85.220.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CEF93689D95 for ; Sat, 12 Nov 2016 01:01:36 +0200 (EET) Received: by mail-qk0-f196.google.com with SMTP id h201so3521984qke.3 for ; Fri, 11 Nov 2016 15:01:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=LbeLG9TZH9Q1AN7H0JJNSqRl4LIuFcorHD3sizQJPn0=; b=XJ0ATl7BzQu2CdsgFJHEXxOjs0Z+Q8jx6RJtERgvmmpMWbQlyKVEceBmlPPjrGL1e1 Ewwufat18kvZo/mnTgtVCV4OFAGbfZ7dYEXTW1ukk9cniq4ebGc3hH0VR52Wkdfnkwd1 XAbOJ+JQFkZU5wzoh7PtRoGUzyxV2k2XC9BlLfFh7izWJuM22MplthcnXqGEwsG+6njr Xxhme+n/dsqfJuwthmNnabveiRXy2yZDNJvVeFzqrwmtDblvYdbQgW8Z0jvQZmycm5eO dgImwI0Rl2QiEjQyEZYi7wpVXWWCNkvtj6bSjr0+iLDwF/Z8UaDVtXb8vIqPJYcvFvy+ Ku6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=LbeLG9TZH9Q1AN7H0JJNSqRl4LIuFcorHD3sizQJPn0=; b=FCQ2M6EvpLiFok7uLDJ3aHziKVMe6Ku40Jjtk1rlhLcQS3qGT1V7xRQy2b7ZJjXL0U WNvzLlfcKSmyhuqjQifXKgEwQOiYo6oF3qdCDT16HKvfrZRa2ScO1eZoQiAE6/m601VL lzhQBJqypgcBSQ48jbLWhguiv12kPhmjn2UlQkn8GBUPfX9mmkC7kfZqRKVL67MupIPQ FohOUmAZ9SsBpYZWKOVNBBr3jTWx3KB0udWOpyVifoHg9qOIJb8jTnSBLHoQatw/Zo8w igi3/8SNCiZX5q8wtVE7fk/m2riyFUeWJ6s1Zo4QfG7ohpYbxVk8pwAaR5RUUzDgsaAk kWJw== X-Gm-Message-State: ABUngvcbvVE4Ac8PYfJ03JCo5TIjbfOLKQAyE0PLDuj/8lewIPYNh9oriaXbGGmRg1vb5w== X-Received: by 10.55.18.30 with SMTP id c30mr6558702qkh.213.1478904544700; Fri, 11 Nov 2016 14:49:04 -0800 (PST) Received: from vimacbookpro.vimeows.com (nyv-exweb.iac.com. [216.112.252.10]) by smtp.gmail.com with ESMTPSA id f21sm4894494qkh.17.2016.11.11.14.49.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 11 Nov 2016 14:49:04 -0800 (PST) From: Vittorio Giovara To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Nov 2016 17:49:01 -0500 Message-Id: <20161111224902.83581-2-vittorio.giovara@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161111224902.83581-1-vittorio.giovara@gmail.com> References: <20161111224902.83581-1-vittorio.giovara@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/3] lavc: Add spherical packet side data API X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Vittorio Giovara --- Missing version bump (do so when pushing). Please CC. Vittorio ffprobe.c | 18 ++++++++++++++++++ libavcodec/avcodec.h | 8 +++++++- libavcodec/avpacket.c | 1 + libavcodec/utils.c | 1 + libavformat/dump.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/ffprobe.c b/ffprobe.c index a2980b3..e89e5d9 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -37,6 +37,7 @@ #include "libavutil/hash.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#include "libavutil/spherical.h" #include "libavutil/stereo3d.h" #include "libavutil/dict.h" #include "libavutil/intreadwrite.h" @@ -1783,6 +1784,23 @@ static void print_pkt_side_data(WriterContext *w, const AVStereo3D *stereo = (AVStereo3D *)sd->data; print_str("type", av_stereo3d_type_name(stereo->type)); print_int("inverted", !!(stereo->flags & AV_STEREO3D_FLAG_INVERT)); + } else if (sd->type == AV_PKT_DATA_SPHERICAL) { + const AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data; + if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR) + print_str("projection", "equirectangular"); + else if (spherical->projection == AV_SPHERICAL_CUBEMAP) + print_str("projection", "cubemap"); + else + print_str("projection", "unknown"); + + print_int("yaw", spherical->yaw); + print_int("pitch", spherical->pitch); + print_int("roll", spherical->roll); + + print_int("left", spherical->left_offset); + print_int("top", spherical->top_offset); + print_int("right", spherical->right_offset); + print_int("bottom", spherical->bottom_offset); } writer_print_section_footer(w); } diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 211112f..9497cc3 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1536,7 +1536,13 @@ enum AVPacketSideDataType { * should be associated with a video stream and containts data in the form * of the AVMasteringDisplayMetadata struct. */ - AV_PKT_DATA_MASTERING_DISPLAY_METADATA + AV_PKT_DATA_MASTERING_DISPLAY_METADATA, + + /** + * This side data should be associated with a video stream and corresponds + * to the AVSphericalMapping structure. + */ + AV_PKT_DATA_SPHERICAL, }; #define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index c3f871c..a799610 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -371,6 +371,7 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type) case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update"; case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID"; case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata"; + case AV_PKT_DATA_SPHERICAL: return "Spherical mapping"; } return NULL; } diff --git a/libavcodec/utils.c b/libavcodec/utils.c index d6dca18..89a12c6 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -762,6 +762,7 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) } sd[] = { { AV_PKT_DATA_REPLAYGAIN , AV_FRAME_DATA_REPLAYGAIN }, { AV_PKT_DATA_DISPLAYMATRIX, AV_FRAME_DATA_DISPLAYMATRIX }, + { AV_PKT_DATA_SPHERICAL, AV_FRAME_DATA_SPHERICAL }, { AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D }, { AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE }, { AV_PKT_DATA_MASTERING_DISPLAY_METADATA, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA }, diff --git a/libavformat/dump.c b/libavformat/dump.c index cd14625..3931a2f 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,34 @@ 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; + + if (sd->size < sizeof(*spherical)) { + 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; + } + + av_log(ctx, AV_LOG_INFO, "(%f/%f/%f) ", + spherical->yaw, spherical->pitch, spherical->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 +422,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);