From 56c199fc5dafe8b60916eb213a1a5ef1fa4f210b Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Mon, 10 Mar 2014 14:58:36 -0400 Subject: [PATCH] Add bit counter to utils --- ASTCEncoder/src/Utils.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ASTCEncoder/src/Utils.h b/ASTCEncoder/src/Utils.h index 514dc81..22c7572 100644 --- a/ASTCEncoder/src/Utils.h +++ b/ASTCEncoder/src/Utils.h @@ -101,6 +101,14 @@ namespace ASTCC { return -1; }; + // Count the number of bits set in a number. + Popcnt(uint32 n) { + uint32 c; + for(c = 0; n; c++) { + n &= n-1; + } + return c; + } } // namespace ASTCC #endif // ASTCENCODER_SRC_UTILS_H_