aboutsummaryrefslogtreecommitdiff
path: root/lib/ffmpeg/libavcodec
diff options
context:
space:
mode:
authorBen Avison <bavison@riscosopen.org>2013-08-05 13:12:49 +0100
committerpopcornmix <popcornmix@gmail.com>2013-08-07 21:45:00 +0100
commit45b07141ab2d33092811bb912070212ba816daf0 (patch)
tree07c09d75a831cababc9ad9e163f75439a196435c /lib/ffmpeg/libavcodec
parent6aec5772fd5331b3514f308ab0895f6234b60045 (diff)
[ffmpeg] - backport - mpegts: Remove one 64-bit integer modulus operation per packet
The common case of the pointer having increased by one packet (which results in no change to the modulus) can be detected with a 64-bit subtraction, which is far cheaper than a division on many platforms. Before After Mean StdDev Mean StdDev Change Divisions 248.3 8.8 51.5 7.4 +381.7% Overall 2773.2 25.6 2372.5 43.1 +16.9% Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'lib/ffmpeg/libavcodec')
-rw-r--r--lib/ffmpeg/libavcodec/mathops.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/ffmpeg/libavcodec/mathops.h b/lib/ffmpeg/libavcodec/mathops.h
index 592f5a5e75..1d573424f4 100644
--- a/lib/ffmpeg/libavcodec/mathops.h
+++ b/lib/ffmpeg/libavcodec/mathops.h
@@ -195,6 +195,15 @@ if ((y) < (x)) {\
# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32))
#endif /* FASTDIV */
+#ifndef MOD_UNLIKELY
+# define MOD_UNLIKELY(modulus, dividend, divisor, prev_dividend) \
+ do { \
+ if ((prev_dividend) == 0 || (dividend) - (prev_dividend) != (divisor)) \
+ (modulus) = (dividend) % (divisor); \
+ (prev_dividend) = (dividend); \
+ } while (0)
+#endif
+
static inline av_const unsigned int ff_sqrt(unsigned int a)
{
unsigned int b;