From patchwork Wed Feb 15 16:29:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vittorio Giovara X-Patchwork-Id: 2566 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp2045722vsb; Wed, 15 Feb 2017 08:37:30 -0800 (PST) X-Received: by 10.223.169.114 with SMTP id u105mr30534303wrc.173.1487176650310; Wed, 15 Feb 2017 08:37:30 -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 4si5688202wro.182.2017.02.15.08.37.22; Wed, 15 Feb 2017 08:37:30 -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 sp=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 DFE56680A8A; Wed, 15 Feb 2017 18:37:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f196.google.com (mail-qt0-f196.google.com [209.85.216.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 77B8A6808AD for ; Wed, 15 Feb 2017 18:37:06 +0200 (EET) Received: by mail-qt0-f196.google.com with SMTP id h53so21820768qth.3 for ; Wed, 15 Feb 2017 08:37:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=ABYtNwns7IAMHFeog81F5Zq2zNW2dEuYPAXHrtA1BDo=; b=CSNPcsFG7NNwz/cst5aMcIwVW/Eiw2T2HN7/FYuPtobtI/vtoZvH9NnEV6dE+Gyyhr 7JjZv9PTx6q4CMi1M7cEDmsgvyclhYwC+ORR9kRfGU0XUdQy+RbFNNSO54phX8AVuEVx x1hN4i3ZHhMV28qNoF7TbYDYi+kbkPoSYRaN/A1d4mxyDGEPVc5ge7dhwuxobDbTiyCK WQ31Y1jt2ZlTLhbeR+oxg+V+m7mUtuGhEoNjgCWNqofJ1PoZvPaS1OLJ+BFsGmC1Gqq3 uSKyRxdRtsMpDM4j+mF8w3hvY4Zg+1ZF43EYJvfPA+gmnqVRzO1r5xwN0DhgVf1ZyAh6 lbEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=ABYtNwns7IAMHFeog81F5Zq2zNW2dEuYPAXHrtA1BDo=; b=kmQ2tNCBFF6ZuccjGNV9/r1a7wDe40RTgpYJHLH0O4MHWFAQVXoofiOjeNnWt6GRUi Fa/d5vH0zF9eQ7z2pnetC4E8ml+wHPzyNHD0pld3dHeAmskhNzG6uWL7Wf1NNd23bWJB wkzzx2pQD0G8DAN0Tf8f67Uc1YPdi47aA4xqxuUCKj27jTQfWn35o/9xdlP1b+z0bpKi 2PLsOrFqHcRIJP8bUye3a1lfP6Jr9iyS907S5TOnXxXNY9nr9cPvDcNzCYddVCtNkGcL wcvN+EqCFVZ8PzXZOMkYNOJ4d/tpK7RDomlQ3FzS6h5OFzKhkcGa1NjrI8YpHRWYUJZu KU4A== X-Gm-Message-State: AMke39mfdjXS1V6O/Dm+Mm4BWpDU5x8Ef4PUxMAmSfQy4ra0Wi6ETselc78PqNsZWkZTUg== X-Received: by 10.237.37.209 with SMTP id y17mr33559666qtc.136.1487176144536; Wed, 15 Feb 2017 08:29:04 -0800 (PST) Received: from vimacbookpro.vimeows.com (nyv-exweb.iac.com. [216.112.252.10]) by smtp.gmail.com with ESMTPSA id s20sm2583735qtc.39.2017.02.15.08.29.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 15 Feb 2017 08:29:03 -0800 (PST) From: Vittorio Giovara To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Feb 2017 11:29:00 -0500 Message-Id: <20170215162903.36087-1-vittorio.giovara@gmail.com> X-Mailer: git-send-email 2.10.0 Subject: [FFmpeg-devel] [PATCHv2 1/4] spherical: Add tiled equirectangular type and projection-specific properties 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 --- 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