[FFmpeg-cvslog] lavu: add ff_parity()

Clément Bœsch git at videolan.org
Thu Jan 7 22:52:18 CET 2016


ffmpeg | branch: master | Clément Bœsch <u at pkh.me> | Sun Jan  3 20:14:37 2016 +0100| [2ce29d17656fab36286a76a9bb68e001e2815a3d] | committer: Clément Bœsch

lavu: add ff_parity()

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2ce29d17656fab36286a76a9bb68e001e2815a3d
---

 configure           |    2 ++
 libavutil/intmath.h |   12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/configure b/configure
index 1bff7f6..90b8fcc 100755
--- a/configure
+++ b/configure
@@ -1736,6 +1736,7 @@ BUILTIN_LIST="
     machine_rw_barrier
     MemoryBarrier
     mm_empty
+    parity
     rdtsc
     sarestart
     sync_val_compare_and_swap
@@ -5241,6 +5242,7 @@ check_builtin sarestart signal.h "SA_RESTART"
 check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
 check_builtin gmtime_r time.h "time_t *time; struct tm *tm; gmtime_r(time, tm)"
 check_builtin localtime_r time.h "time_t *time; struct tm *tm; localtime_r(time, tm)"
+check_builtin parity "" "__builtin_parity(123)"
 
 case "$custom_allocator" in
     jemalloc)
diff --git a/libavutil/intmath.h b/libavutil/intmath.h
index 82193a6..17c4f1b 100644
--- a/libavutil/intmath.h
+++ b/libavutil/intmath.h
@@ -153,6 +153,18 @@ static av_always_inline av_const unsigned ff_clz_c(unsigned x)
 }
 #endif
 
+#ifndef ff_parity
+#define ff_parity ff_parity_c
+static av_always_inline av_const int ff_parity_c(uint32_t v)
+{
+#if HAVE_PARITY
+    return __builtin_parity(v);
+#else
+    return av_popcount(v) & 1;
+#endif
+}
+#endif
+
 /**
  * @}
  */



More information about the ffmpeg-cvslog mailing list