From 4e45988caad8d8a1b5f9ea7890f947c9bff54b92 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Mon, 10 Mar 2014 18:56:28 -0400 Subject: [PATCH] Refactor to FasTC::Replicate where appropriate --- ASTCEncoder/src/Decompressor.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/ASTCEncoder/src/Decompressor.cpp b/ASTCEncoder/src/Decompressor.cpp index 54287f9..63b3f3b 100644 --- a/ASTCEncoder/src/Decompressor.cpp +++ b/ASTCEncoder/src/Decompressor.cpp @@ -62,6 +62,7 @@ #include "TexCompTypes.h" +#include "Bits.h" #include "BitStream.h" using FasTC::BitStreamReadOnly; @@ -334,25 +335,14 @@ namespace ASTCC { assert(bitlen >= 1); uint32 A = 0, B = 0, C = 0, D = 0; - // A is just the lsb replicated 8 times. - for(uint32 i = 0; i < 9; i++) { - A |= bitval & 1; - A <<= 1; - } + // A is just the lsb replicated 9 times. + A = FasTC::Replicate(bitval & 1, 1, 9); switch(val.GetEncoding()) { // Replicate bits - case eIntegerEncoding_JustBits: { - uint32 result = bitval; - uint32 resultLen = bitlen; - while(resultLen < 8) { - result <<= bitlen; - result |= bitval & ((1 << std::min(8 - bitlen, bitlen)) - 1); - resultLen += bitlen; - } - out[outIdx++] = result; - } - break; + case eIntegerEncoding_JustBits: + out[outIdx++] = FasTC::Replicate(bitval, bitlen, 8); + break; // Use algorithm in C.2.13 case eIntegerEncoding_Trit: {