From patchwork Fri Feb 10 21:11:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vittorio Giovara X-Patchwork-Id: 2491 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp696836vsb; Fri, 10 Feb 2017 13:12:09 -0800 (PST) X-Received: by 10.223.176.210 with SMTP id j18mr10468007wra.8.1486761129890; Fri, 10 Feb 2017 13:12:09 -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 c6si3636465wrd.136.2017.02.10.13.12.08; Fri, 10 Feb 2017 13:12:09 -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 3E505689DA9; Fri, 10 Feb 2017 23:11:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 494F168995A for ; Fri, 10 Feb 2017 23:11:48 +0200 (EET) Received: by mail-pg0-f65.google.com with SMTP id v184so3908463pgv.1 for ; Fri, 10 Feb 2017 13:11:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=1n3QQfMM2C1O3Si0iGKLg//ichPzfbiSBUuCHl/Txus=; b=VDKy2zOXP0Dqy1PYHRn7xA3VAg8QSPOy3oQV5YXrq2bWmNS1WliD9DaVIecw5CSwD/ XoMLBssgmIgGknMq3t/awvItAFeRDPQdOMv3VI1uHJXjMnQtYBcEwlz+BfDZeflMpoye nlaDLkKRbR+fnwOgXpiALtIGf0Zf5vXPXuXAHv4N7HaF6VEgTeyP0VaTxOASYHlzl4uK qQW//Pt+2ISM5S+LAT39qa6DcdUrXVP3h+Z0n+WOzHCSCUMOmmACs5XIBEAM2T/S3EzP ATgXsUoXak/zO6hQev8wXf37veRTR8OsXc4fuHUsqOCci0Sqqrx0wzHxFxCiGHcGntJD FHMA== 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:in-reply-to :references; bh=1n3QQfMM2C1O3Si0iGKLg//ichPzfbiSBUuCHl/Txus=; b=QBKjDBfVjIEVjdYuJjzp5/bek7iBFsDCu1LLkZUe/2wi1XcIvultkTO/GO2oKJj5en L57G/6EZGO3zlhvScotZvq8vR/lazT4aRP8fT9fjDIYCDT5CuWn3WNmdwHZNgB1WrmdR 1gvMo4YhcVv1OEvSl6DyFKtLqI/JRuZ+p7ajgjfdqGIcUhP81soEeR/0fj0NeUwfSb3r H08PkgnEgVZ5/gzYwwh4BJXmOrORb5c+Dc6y0UtOiXL3Z0PzNbx4AddBgATHD+3cLKgD /ipA0Kupndo/aRqjTZmG2qG5VyIyI41wiL4SODUnMjzU0eYN+kbZFv+Mll4gKercAci1 SAzQ== X-Gm-Message-State: AMke39kbyYTxOqDvqkxxvATED691YMDUPXmdTxxovCqt0Piod8JForMsfWpoVe3VFYkZ2A== X-Received: by 10.98.50.66 with SMTP id y63mr12640178pfy.21.1486761110734; Fri, 10 Feb 2017 13:11:50 -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.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 Feb 2017 13:11:50 -0800 (PST) From: Vittorio Giovara To: ffmpeg-devel@ffmpeg.org Date: Fri, 10 Feb 2017 16:11:44 -0500 Message-Id: <20170210211145.54685-2-vittorio.giovara@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20170210211145.54685-1-vittorio.giovara@gmail.com> References: <20170210211145.54685-1-vittorio.giovara@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/3] mov: Export bounds and padding from spherical metadata 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" Update the fate test as needed. --- Please keep me in CC. Vittorio libavformat/mov.c | 46 ++++++++++++++++++++++++++++++++++++++- tests/ref/fate/mov-spherical-mono | 8 +++++-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ca49786..a8900c1 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4625,6 +4625,8 @@ static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom) MOVStreamContext *sc; int size; int32_t yaw, pitch, roll; + size_t l, t, r, b; + size_t padding = 0; uint32_t tag; enum AVSphericalProjection projection; @@ -4686,9 +4688,17 @@ static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom) switch (tag) { case MKTAG('c','b','m','p'): projection = AV_SPHERICAL_CUBEMAP; + padding = avio_rb32(pb); break; case MKTAG('e','q','u','i'): - projection = AV_SPHERICAL_EQUIRECTANGULAR; + t = avio_rb32(pb); + b = avio_rb32(pb); + l = avio_rb32(pb); + r = avio_rb32(pb); + if (l || t || r || b) + projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE; + else + projection = AV_SPHERICAL_EQUIRECTANGULAR; break; default: av_log(c->fc, AV_LOG_ERROR, "Unknown projection type\n"); @@ -4705,6 +4715,20 @@ static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->spherical->pitch = pitch; sc->spherical->roll = roll; + sc->spherical->padding = padding; + + if (projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) { + /* conversion from 0.32 coordinates to pixels */ + uint32_t max_coord = (uint32_t) -1; + size_t orig_width = (size_t) sc->width * max_coord / (max_coord - r - l); + size_t orig_height = (size_t) sc->height * max_coord / (max_coord - b - t); + + /* add a (max_coord - 1) to round up integer division */ + sc->spherical->left_bound = (orig_width * l + max_coord - 1) / max_coord; + sc->spherical->top_bound = (orig_height * t + max_coord - 1) / max_coord; + sc->spherical->right_bound = orig_width - sc->width - sc->spherical->left_bound; + sc->spherical->bottom_bound = orig_height - sc->height - sc->spherical->top_bound; + } return 0; } @@ -4763,6 +4787,26 @@ static int mov_parse_uuid_spherical(MOVStreamContext *sc, AVIOContext *pb, size_ val = av_stristr(buffer, ""); if (val) sc->spherical->roll = strtol(val, NULL, 10) * (1 << 16); + + /* tiling */ + val = av_stristr(buffer, ""); + if (val) + sc->spherical->left_bound = strtol(val, NULL, 10); + val = av_stristr(buffer, ""); + if (val) + sc->spherical->top_bound = strtol(val, NULL, 10); + val = av_stristr(buffer, ""); + if (val) + sc->spherical->right_bound = + sc->width - sc->spherical->left_bound - strtol(val, NULL, 10); + val = av_stristr(buffer, ""); + if (val) + sc->spherical->bottom_bound = + sc->height - sc->spherical->top_bound - strtol(val, NULL, 10); + + if (sc->spherical->left_bound || sc->spherical->top_bound || + sc->spherical->right_bound || sc->spherical->bottom_bound) + sc->spherical->projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE; } out: diff --git a/tests/ref/fate/mov-spherical-mono b/tests/ref/fate/mov-spherical-mono index 9f4b4f8..a1365c4 100644 --- a/tests/ref/fate/mov-spherical-mono +++ b/tests/ref/fate/mov-spherical-mono @@ -7,8 +7,12 @@ inverted=0 [/SIDE_DATA] [SIDE_DATA] side_data_type=Spherical Mapping -side_data_size=16 -projection=equirectangular +side_data_size=56 +projection=tiled equirectangular +left_bound=148 +top_bound=73 +right_bound=147 +bottom_bound=72 yaw=45 pitch=30 roll=15