Skip to content

Commit

Permalink
Remove dca_clz64().
Browse files Browse the repository at this point in the history
  • Loading branch information
foo86 committed Dec 14, 2015
1 parent ea7023c commit bcc1f7e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
2 changes: 1 addition & 1 deletion libdcadec/bitstream.c
Expand Up @@ -83,7 +83,7 @@ static int bits_get_unsigned_rice(struct bitstream *bits, int k)
while (bits->index < bits->total) {
uint32_t v = bits_peek(bits);
if (v) {
int z = dca_clz32(v);
int z = dca_clz(v);
bits->index += z + 1;
unary += z;
break;
Expand Down
20 changes: 2 additions & 18 deletions libdcadec/common.h
Expand Up @@ -34,10 +34,9 @@
#include "ta.h"

#if AT_LEAST_GCC(3, 4)
#define dca_clz32(x) __builtin_clz(x)
#define dca_clz64(x) __builtin_clzll(x)
#define dca_clz(x) __builtin_clz(x)
#else
static inline int dca_clz32(uint32_t x)
static inline int dca_clz(uint32_t x)
{
int r = 0;

Expand All @@ -50,21 +49,6 @@ static inline int dca_clz32(uint32_t x)

return 31 - r;
}

static inline int dca_clz64(uint64_t x)
{
int r = 0;

assert(x);
if (x & 0xffffffff00000000) { x >>= 32; r |= 32; }
if (x & 0x00000000ffff0000) { x >>= 16; r |= 16; }
if (x & 0x000000000000ff00) { x >>= 8; r |= 8; }
if (x & 0x00000000000000f0) { x >>= 4; r |= 4; }
if (x & 0x000000000000000c) { x >>= 2; r |= 2; }
if (x & 0x0000000000000002) { x >>= 1; r |= 1; }

return 63 - r;
}
#endif

#if (defined __GNUC__) && (defined __POPCNT__)
Expand Down
2 changes: 1 addition & 1 deletion libdcadec/core_decoder.c
Expand Up @@ -690,7 +690,7 @@ static inline void dequantize(int *output, const int *input, int step_size,

// Limit scale factor resolution to 22 bits
if (step_scale > (1 << 23)) {
shift = 32 - dca_clz32(step_scale >> 23);
shift = 32 - dca_clz(step_scale >> 23);
step_scale >>= shift;
}

Expand Down
2 changes: 1 addition & 1 deletion libdcadec/dca_context.c
Expand Up @@ -244,7 +244,7 @@ static int down_mix_prim_chset(struct dcadec_context *dca,
memset(dca->dmix_sample_buffer, 0, 2 * nsamples * sizeof(int));

int nchannels = dca_popcount(*ch_mask);
int nsamples_log2 = 31 - dca_clz32(nsamples);
int nsamples_log2 = 31 - dca_clz(nsamples);

// Perform downmix
for (int spkr = 0, pos = 0; spkr < SPEAKER_COUNT; spkr++) {
Expand Down

0 comments on commit bcc1f7e

Please sign in to comment.