summaryrefslogtreecommitdiff
path: root/media/ffvpx/libavutil/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'media/ffvpx/libavutil/common.h')
-rw-r--r--media/ffvpx/libavutil/common.h38
1 files changed, 34 insertions, 4 deletions
diff --git a/media/ffvpx/libavutil/common.h b/media/ffvpx/libavutil/common.h
index 8142b31fdb..8db0291170 100644
--- a/media/ffvpx/libavutil/common.h
+++ b/media/ffvpx/libavutil/common.h
@@ -158,7 +158,7 @@ static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, in
*/
static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
{
- if (a&(~0xFF)) return (-a)>>31;
+ if (a&(~0xFF)) return (~a)>>31;
else return a;
}
@@ -180,7 +180,7 @@ static av_always_inline av_const int8_t av_clip_int8_c(int a)
*/
static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
{
- if (a&(~0xFFFF)) return (-a)>>31;
+ if (a&(~0xFFFF)) return (~a)>>31;
else return a;
}
@@ -228,7 +228,7 @@ static av_always_inline av_const int av_clip_intp2_c(int a, int p)
*/
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
{
- if (a & ~((1<<p) - 1)) return -a >> 31 & ((1<<p) - 1);
+ if (a & ~((1<<p) - 1)) return (~a) >> 31 & ((1<<p) - 1);
else return a;
}
@@ -260,7 +260,7 @@ static av_always_inline int av_sat_add32_c(int a, int b)
*
* @param a first value
* @param b value doubled and added to a
- * @return sum with signed saturation
+ * @return sum sat(a + sat(2*b)) with signed saturation
*/
static av_always_inline int av_sat_dadd32_c(int a, int b)
{
@@ -268,6 +268,30 @@ static av_always_inline int av_sat_dadd32_c(int a, int b)
}
/**
+ * Subtract two signed 32-bit values with saturation.
+ *
+ * @param a one value
+ * @param b another value
+ * @return difference with signed saturation
+ */
+static av_always_inline int av_sat_sub32_c(int a, int b)
+{
+ return av_clipl_int32((int64_t)a - b);
+}
+
+/**
+ * Subtract a doubled value from another value with saturation at both stages.
+ *
+ * @param a first value
+ * @param b value doubled and subtracted from a
+ * @return difference sat(a - sat(2*b)) with signed saturation
+ */
+static av_always_inline int av_sat_dsub32_c(int a, int b)
+{
+ return av_sat_sub32(a, av_sat_add32(b, b));
+}
+
+/**
* Clip a float value into the amin-amax range.
* @param a value to clip
* @param amin minimum value of the clip range
@@ -513,6 +537,12 @@ static av_always_inline av_const int av_parity_c(uint32_t v)
#ifndef av_sat_dadd32
# define av_sat_dadd32 av_sat_dadd32_c
#endif
+#ifndef av_sat_sub32
+# define av_sat_sub32 av_sat_sub32_c
+#endif
+#ifndef av_sat_dsub32
+# define av_sat_dsub32 av_sat_dsub32_c
+#endif
#ifndef av_clipf
# define av_clipf av_clipf_c
#endif