[FFmpeg-devel] [PATCH] Change type of spherical stuff to uint32_t

Michael Niedermayer michael at niedermayer.cc
Sun Mar 12 23:16:46 EET 2017


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

Previous version reviewed-by: James Almer <jamrial at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 ffprobe.c             |  2 +-
 libavformat/dump.c    |  6 +++---
 libavutil/spherical.c |  6 +++---
 libavutil/spherical.h | 16 ++++++++--------
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/ffprobe.c b/ffprobe.c
index b104390990..b3466b1708 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;
+                uint32_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..a6309cbf71 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;
+        uint32_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, "[%"PRIu32", %"PRIu32", %"PRIu32", %"PRIu32"] ", 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 %"PRIu32"] ", spherical->padding);
     }
 }
 
diff --git a/libavutil/spherical.c b/libavutil/spherical.c
index 0ca2dd367a..66056961a0 100644
--- a/libavutil/spherical.c
+++ b/libavutil/spherical.c
@@ -34,9 +34,9 @@ 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)
+                              uint32_t width, uint32_t height,
+                              uint32_t *left, uint32_t*top,
+                              uint32_t *right, uint32_t *bottom)
 {
     /* conversion from 0.32 coordinates to pixels */
     uint64_t orig_width  = (uint64_t) width  * UINT32_MAX /
diff --git a/libavutil/spherical.h b/libavutil/spherical.h
index db9bdc0be5..ff25c139ee 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
+    uint32_t bound_left;   ///< Distance from the left edge
+    uint32_t bound_top;    ///< Distance from the top edge
+    uint32_t bound_right;  ///< Distance from the right edge
+    uint32_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;
+    uint32_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);
+                              uint32_t width, uint32_t height,
+                              uint32_t *left, uint32_t *top,
+                              uint32_t *right, uint32_t *bottom);
 /**
  * @}
  * @}
-- 
2.11.0



More information about the ffmpeg-devel mailing list