Added floor and align function to FVID2 Utils
authorRishabh Garg <rishabh@ti.com>
Wed, 11 Apr 2018 16:11:47 +0000 (21:41 +0530)
committerRishabh Garg <rishabh@ti.com>
Wed, 11 Apr 2018 16:11:47 +0000 (21:41 +0530)
Signed-off-by: Rishabh Garg <rishabh@ti.com>
include/fvid2_utils.h [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 5f0b3f7..9d1d825
@@ -569,6 +569,28 @@ uint32_t Fvid2Utils_isQEmpty(Fvid2Utils_QHandle handle);
  */
 uint32_t Fvid2Utils_getNumQElem(Fvid2Utils_QHandle handle);
 
+/**
+ *  Fvid2Utils_floor
+ *  \brief Floor a integer value.
+ *
+ *  \param val          [IN] Integer to floor.
+ *  \param align        [IN] Alignment.
+ *
+ *  \return Returns the floored integer.
+ */
+static inline uint32_t Fvid2Utils_floor(uint32_t val, uint32_t align);
+
+/**
+ *  Fvid2Utils_align
+ *  \brief Align a integer value.
+ *
+ *  \param val          [IN] Integer to align.
+ *  \param align        [IN] Alignment.
+ *
+ *  \return Returns the aligned integer.
+ */
+static inline uint32_t Fvid2Utils_align(uint32_t val, uint32_t align);
+
 /**
  *  Fvid2Utils_initPool
  *  \brief Initializes the pool object structure.
@@ -654,6 +676,16 @@ static inline uint64_t Osal_getTimestamp64(void);
 /*                       Static Function Definitions                          */
 /* ========================================================================== */
 
+static inline uint32_t Fvid2Utils_floor(uint32_t val, uint32_t align)
+{
+    return ((uint32_t) ((val / align) * align));
+}
+
+static inline uint32_t Fvid2Utils_align(uint32_t val, uint32_t align)
+{
+    return (Fvid2Utils_floor((uint32_t) (val + (align - 1U)), align));
+}
+
 static inline void Fvid2Utils_initPool(Fvid2Utils_PoolParams *params,
                                        void                  *mem,
                                        uint32_t               numElem,