From patchwork Fri Feb 10 21:11:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vittorio Giovara X-Patchwork-Id: 2490 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp696790vsb; Fri, 10 Feb 2017 13:12:00 -0800 (PST) X-Received: by 10.28.60.66 with SMTP id j63mr9261528wma.74.1486761120472; Fri, 10 Feb 2017 13:12:00 -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 o64si2667719wmi.143.2017.02.10.13.11.59; Fri, 10 Feb 2017 13:12:00 -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 CC3D2689D9E; Fri, 10 Feb 2017 23:11:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3B717689948 for ; Fri, 10 Feb 2017 23:11:47 +0200 (EET) Received: by mail-pg0-f67.google.com with SMTP id 75so3898041pgf.3 for ; Fri, 10 Feb 2017 13:11:51 -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=NQH+raftTDus6zUDTmQGXy7hq6izvuIxJFubABDtdF8=; b=gYt1btIghXsmgCxTit4XAZokf5u3FfpMafTBfGFCp5SD9xAYBbeLObLhMnWbU945Gm LAMkoKRTCd2GrIvxi4vQwMIpU+M2Ishm9yb32bffGoJgL+uDV6hE8gA1vwVI7qP3BvNE 1+Q5uJakBO1SIgItjkJirjrR3775f6KWlIYhzPUkkGGvGIw8gkOfRrGMI/R87KzZhbhF 9BEU/nkIMmpKxRD+h7oX+SOTZLDATbvQPrggY8SPzwBlewjSgGxNDQCott4P2FktUk63 j+FdBEPruzKggRCODP1evj4qds2ofGTu71b2yeC4dINFWVYHmu2HmjSOKNCYYkPgI9c7 fEuQ== 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=NQH+raftTDus6zUDTmQGXy7hq6izvuIxJFubABDtdF8=; b=Q1kv0SME9RjVyL/MYwNRApsTmhnnLch+0Uci08gciKmVXL1xJ+4uPusLoOwF4s9/AK QE1cOCg/aHw36mx4RBBhzbpx8MVZaSXP3S3QVWGV+VZa3rI89jfKgFGcHa7T1ilnTEXL NgouW8I1SBHnTfIlg7LBfzev9D8ON2Gy/uzs20Vpjxn4sfpDUfDCyIvo7NMPko4fubMQ 2Qubu1pCJVVFXklneck6VVKIl3Ke5gxKF530e0yStsv6sYJ0dJRPOQaMDux5UZ3OE0fr omStygSmKY/ptTdODBgatDY7UdRFDCUZhQQpl10R1ubqsk/xVX42kG4ifLGgG57jtxl+ M1Lg== X-Gm-Message-State: AMke39l9KJ8ObW2NUrY5dMkcL/ZKDOgimmWKn4R2g/mGoWDKpRPYHgQ4A2k4/qFJnsFHgg== X-Received: by 10.98.211.8 with SMTP id q8mr12547760pfg.164.1486761109177; Fri, 10 Feb 2017 13:11:49 -0800 (PST) Received: from vimacbookpro.vimeows.com (nyv-exweb.iac.com. [216.112.252.10]) by smtp.gmail.com with ESMTPSA id d69sm7339147pfd.11.2017.02.10.13.11.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 Feb 2017 13:11:48 -0800 (PST) From: Vittorio Giovara To: ffmpeg-devel@ffmpeg.org Date: Fri, 10 Feb 2017 16:11:43 -0500 Message-Id: <20170210211145.54685-1-vittorio.giovara@gmail.com> X-Mailer: git-send-email 2.10.0 Subject: [FFmpeg-devel] [PATCH 1/3] 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 --- This should help not losing details over muxing and allows callers to get additional information in a clean manner. Please keep me in CC. Vittorio doc/APIchanges | 5 +++++ ffprobe.c | 11 ++++++++-- libavformat/dump.c | 10 +++++++++ libavutil/spherical.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ libavutil/version.h | 2 +- 5 files changed, 81 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 8bca71e..8268295 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.47.100 / 55.31.0 - spherical.h + Add AV_SPHERICAL_EQUIRECTANGULAR_TILE, and projection-specific properties + (left_bound, top_bound, right_bound, bottom_bound, padding) to + AVSphericalMapping. + 2017-01-31 - xxxxxxx - lavu 55.46.100 / 55.20.0 - cpu.h Add AV_CPU_FLAG_SSSE3SLOW. diff --git a/ffprobe.c b/ffprobe.c index 046f080..dafac56 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("left_bound", spherical->left_bound); + print_int("top_bound", spherical->top_bound); + print_int("right_bound", spherical->right_bound); + print_int("bottom_bound", spherical->bottom_bound); + } 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..6fbbd5a 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->left_bound, spherical->top_bound, + spherical->right_bound, spherical->bottom_bound); + } 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..0cfd0d9 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} + * +----------------+----------+ + * | |top_bound | + * | +--------+ | + * | left_bound |tile | | + * +<---------->| |<--->+right_bound + * | +--------+ | + * | | | + * | bottom_bound| | + * +----------------+----------+ + * @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 + left_bound + right_bound; + * original_height = tile->height + top_bound + bottom_bound; + * @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 left_bound; ///< Distance in pixel from the left edge + size_t top_bound; ///< Distance in pixel from the top edge + size_t right_bound; ///< Distance in pixel from the right edge + size_t bottom_bound; ///< Distance in pixel 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 8866064..a8b00bf 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 55 -#define LIBAVUTIL_VERSION_MINOR 46 +#define LIBAVUTIL_VERSION_MINOR 47 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \