From patchwork Sun Mar 12 20:06:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 2904 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp908383vsy; Sun, 12 Mar 2017 13:06:39 -0700 (PDT) X-Received: by 10.28.127.149 with SMTP id a143mr7842179wmd.87.1489349199151; Sun, 12 Mar 2017 13:06:39 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f126si8116202wma.32.2017.03.12.13.06.38; Sun, 12 Mar 2017 13:06:39 -0700 (PDT) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B2011689C85; Sun, 12 Mar 2017 22:06:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe04-2.mx.upcmail.net (vie01a-dmta-pe04-2.mx.upcmail.net [62.179.121.164]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C76E5689ADD for ; Sun, 12 Mar 2017 22:06:14 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe04.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1cn9l7-0006Wg-Ei for ffmpeg-devel@ffmpeg.org; Sun, 12 Mar 2017 21:06:29 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id v86T1u00S0S5wYM0186U1v; Sun, 12 Mar 2017 21:06:28 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 12 Mar 2017 21:06:26 +0100 Message-Id: <20170312200626.26047-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH] Change type of spherical stuff to uint64_t 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" Using the same type across platforms is more robust and avoids platform specific issues from differences in range. Also fixed point integers are on a semantical level not size_t Signed-off-by: Michael Niedermayer --- ffprobe.c | 2 +- libavformat/dump.c | 6 +++--- libavutil/spherical.c | 10 +++++----- libavutil/spherical.h | 16 ++++++++-------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ffprobe.c b/ffprobe.c index b104390990..a73566b7a3 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -1793,7 +1793,7 @@ static void print_pkt_side_data(WriterContext *w, print_str("projection", "cubemap"); print_int("padding", spherical->padding); } else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) { - size_t l, t, r, b; + uint64_t l, t, r, b; av_spherical_tile_bounds(spherical, par->width, par->height, &l, &t, &r, &b); print_str("projection", "tiled equirectangular"); diff --git a/libavformat/dump.c b/libavformat/dump.c index 505d572301..0a1208a375 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -370,12 +370,12 @@ static void dump_spherical(void *ctx, AVCodecParameters *par, AVPacketSideData * av_log(ctx, AV_LOG_INFO, "(%f/%f/%f) ", yaw, pitch, roll); if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) { - size_t l, t, r, b; + uint64_t l, t, r, b; av_spherical_tile_bounds(spherical, par->width, par->height, &l, &t, &r, &b); - av_log(ctx, AV_LOG_INFO, "[%zu, %zu, %zu, %zu] ", l, t, r, b); + av_log(ctx, AV_LOG_INFO, "[%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64"] ", l, t, r, b); } else if (spherical->projection == AV_SPHERICAL_CUBEMAP) { - av_log(ctx, AV_LOG_INFO, "[pad %zu] ", spherical->padding); + av_log(ctx, AV_LOG_INFO, "[pad %"PRIu64"] ", spherical->padding); } } diff --git a/libavutil/spherical.c b/libavutil/spherical.c index 0ca2dd367a..1e9805c2a5 100644 --- a/libavutil/spherical.c +++ b/libavutil/spherical.c @@ -34,14 +34,14 @@ AVSphericalMapping *av_spherical_alloc(size_t *size) } void av_spherical_tile_bounds(AVSphericalMapping *map, - size_t width, size_t height, - size_t *left, size_t *top, - size_t *right, size_t *bottom) + uint64_t width, uint64_t height, + uint64_t *left, uint64_t*top, + uint64_t *right, uint64_t *bottom) { /* conversion from 0.32 coordinates to pixels */ - uint64_t orig_width = (uint64_t) width * UINT32_MAX / + uint64_t orig_width = width * UINT32_MAX / (UINT32_MAX - map->bound_right - map->bound_left); - uint64_t orig_height = (uint64_t) height * UINT32_MAX / + uint64_t orig_height = height * UINT32_MAX / (UINT32_MAX - map->bound_bottom - map->bound_top); /* add a (UINT32_MAX - 1) to round up integer division */ diff --git a/libavutil/spherical.h b/libavutil/spherical.h index db9bdc0be5..92a82199b2 100644 --- a/libavutil/spherical.h +++ b/libavutil/spherical.h @@ -164,10 +164,10 @@ typedef struct AVSphericalMapping { * projection type (@ref AV_SPHERICAL_EQUIRECTANGULAR_TILE), * and should be ignored in all other cases. */ - size_t bound_left; ///< Distance from the left edge - size_t bound_top; ///< Distance from the top edge - size_t bound_right; ///< Distance from the right edge - size_t bound_bottom; ///< Distance from the bottom edge + uint64_t bound_left; ///< Distance from the left edge + uint64_t bound_top; ///< Distance from the top edge + uint64_t bound_right; ///< Distance from the right edge + uint64_t bound_bottom; ///< Distance from the bottom edge /** * @} */ @@ -179,7 +179,7 @@ typedef struct AVSphericalMapping { * (@ref AV_SPHERICAL_CUBEMAP), and should be ignored in all other * cases. */ - size_t padding; + uint64_t padding; } AVSphericalMapping; /** @@ -203,9 +203,9 @@ AVSphericalMapping *av_spherical_alloc(size_t *size); * @param bottom Pixels from the bottom edge. */ void av_spherical_tile_bounds(AVSphericalMapping *map, - size_t width, size_t height, - size_t *left, size_t *top, - size_t *right, size_t *bottom); + uint64_t width, uint64_t height, + uint64_t *left, uint64_t *top, + uint64_t *right, uint64_t *bottom); /** * @} * @}