[FFmpeg-devel] [PATCH 3/5] mathops: add [SU]DIVMOD macros

Mans Rullgard mans
Mon Apr 12 00:05:52 CEST 2010


These macros calculate the quotient and remainder of two values. This
is necessary for adding workarounds for gcc failing to calculate
quotient and remainder simultaneously on some platforms.
---
 libavcodec/mathops.h |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
index 149910b..4107706 100644
--- a/libavcodec/mathops.h
+++ b/libavcodec/mathops.h
@@ -146,5 +146,25 @@ if ((y) < (x)) {\
 #   define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
 #endif
 
+#ifndef SDIVMOD
+#   define SDIVMOD(q, r, n, d) do {             \
+        int qq, rr;                             \
+        qq = (n) / (d);                         \
+        rr = (n) % (d);                         \
+        (q) = qq;                               \
+        (r) = rr;                               \
+    } while (0)
+#endif
+
+#ifndef UDIVMOD
+#   define UDIVMOD(q, r, n, d) do {             \
+        unsigned qq, rr;                        \
+        qq = (n) / (d);                         \
+        rr = (n) % (d);                         \
+        (q) = qq;                               \
+        (r) = rr;                               \
+    } while (0)
+#endif
+
 #endif /* AVCODEC_MATHOPS_H */
 
-- 
1.7.0.4




More information about the ffmpeg-devel mailing list