Commit f7648c27 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanups

parent 5d1c895a
Pipeline #60903 passed with stages
in 19 minutes and 39 seconds
......@@ -1055,84 +1055,6 @@ Return Value
*/
DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex);
#ifndef DR_FLAC_NO_STDIO
/*
Opens a FLAC decoder from the file at the given path.
Parameters
----------
pFileName (in)
The path of the file to open, either absolute or relative to the current directory.
pAllocationCallbacks (in, optional)
A pointer to application defined callbacks for managing memory allocations.
Return Value
------------
A pointer to an object representing the decoder.
Remarks
-------
Close the decoder with drflac_close().
Remarks
-------
This will hold a handle to the file until the decoder is closed with drflac_close(). Some platforms will restrict the number of files a process can have open
at any given time, so keep this mind if you have many decoders open at the same time.
See Also
--------
drflac_open_file_with_metadata()
drflac_open()
drflac_close()
*/
DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
/*
Opens a FLAC decoder from the file at the given path and notifies the caller of the metadata chunks (album art, etc.)
Parameters
----------
pFileName (in)
The path of the file to open, either absolute or relative to the current directory.
pAllocationCallbacks (in, optional)
A pointer to application defined callbacks for managing memory allocations.
onMeta (in)
The callback to fire for each metadata block.
pUserData (in)
A pointer to the user data to pass to the metadata callback.
pAllocationCallbacks (in)
A pointer to application defined callbacks for managing memory allocations.
Remarks
-------
Look at the documentation for drflac_open_with_metadata() for more information on how metadata is handled.
See Also
--------
drflac_open_with_metadata()
drflac_open()
drflac_close()
*/
DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
#endif
/*
Opens a FLAC decoder from a pre-allocated block of memory
......@@ -1225,17 +1147,6 @@ DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc on
/* Same as drflac_open_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
#ifndef DR_FLAC_NO_STDIO
/* Same as drflac_open_and_read_pcm_frames_s32() except opens the decoder from a file. */
DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
/* Same as drflac_open_file_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
/* Same as drflac_open_file_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
#endif
/* Same as drflac_open_and_read_pcm_frames_s32() except opens the decoder from a block of memory. */
DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
......@@ -1982,19 +1893,6 @@ static DRFLAC_INLINE drflac_uint8 drflac_crc8(drflac_uint8 crc, drflac_uint32 da
(void)data;
(void)count;
return 0;
#else
#if 0
/* REFERENCE (use of this implementation requires an explicit flush by doing "drflac_crc8(crc, 0, 8);") */
drflac_uint8 p = 0x07;
for (int i = count-1; i >= 0; --i) {
drflac_uint8 bit = (data & (1 << i)) >> i;
if (crc & 0x80) {
crc = ((crc << 1) | bit) ^ p;
} else {
crc = ((crc << 1) | bit);
}
}
return crc;
#else
drflac_uint32 wholeBytes;
drflac_uint32 leftoverBits;
......@@ -2019,7 +1917,6 @@ static DRFLAC_INLINE drflac_uint8 drflac_crc8(drflac_uint8 crc, drflac_uint32 da
}
return crc;
#endif
#endif
}
static DRFLAC_INLINE drflac_uint16 drflac_crc16_byte(drflac_uint16 crc, drflac_uint8 data)
......@@ -2062,106 +1959,6 @@ static DRFLAC_INLINE drflac_uint16 drflac_crc16_bytes(drflac_uint16 crc, drflac_
return crc;
}
#if 0
static DRFLAC_INLINE drflac_uint16 drflac_crc16__32bit(drflac_uint16 crc, drflac_uint32 data, drflac_uint32 count)
{
#ifdef DR_FLAC_NO_CRC
(void)crc;
(void)data;
(void)count;
return 0;
#else
#if 0
/* REFERENCE (use of this implementation requires an explicit flush by doing "drflac_crc16(crc, 0, 16);") */
drflac_uint16 p = 0x8005;
for (int i = count-1; i >= 0; --i) {
drflac_uint16 bit = (data & (1ULL << i)) >> i;
if (r & 0x8000) {
r = ((r << 1) | bit) ^ p;
} else {
r = ((r << 1) | bit);
}
}
return crc;
#else
drflac_uint32 wholeBytes;
drflac_uint32 leftoverBits;
drflac_uint64 leftoverDataMask;
static drflac_uint64 leftoverDataMaskTable[8] = {
0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
};
DRFLAC_ASSERT(count <= 64);
wholeBytes = count >> 3;
leftoverBits = count & 7;
leftoverDataMask = leftoverDataMaskTable[leftoverBits];
switch (wholeBytes) {
default:
case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
}
return crc;
#endif
#endif
}
static DRFLAC_INLINE drflac_uint16 drflac_crc16__64bit(drflac_uint16 crc, drflac_uint64 data, drflac_uint32 count)
{
#ifdef DR_FLAC_NO_CRC
(void)crc;
(void)data;
(void)count;
return 0;
#else
drflac_uint32 wholeBytes;
drflac_uint32 leftoverBits;
drflac_uint64 leftoverDataMask;
static drflac_uint64 leftoverDataMaskTable[8] = {
0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
};
DRFLAC_ASSERT(count <= 64);
wholeBytes = count >> 3;
leftoverBits = count & 7;
leftoverDataMask = leftoverDataMaskTable[leftoverBits];
switch (wholeBytes) {
default:
case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000 << 32) << leftoverBits)) >> (56 + leftoverBits))); /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000 << 32) << leftoverBits)) >> (48 + leftoverBits)));
case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00 << 32) << leftoverBits)) >> (40 + leftoverBits)));
case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF << 32) << leftoverBits)) >> (32 + leftoverBits)));
case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000 ) << leftoverBits)) >> (24 + leftoverBits)));
case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000 ) << leftoverBits)) >> (16 + leftoverBits)));
case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00 ) << leftoverBits)) >> ( 8 + leftoverBits)));
case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF ) << leftoverBits)) >> ( 0 + leftoverBits)));
case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
}
return crc;
#endif
}
static DRFLAC_INLINE drflac_uint16 drflac_crc16(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 count)
{
#ifdef DRFLAC_64BIT
return drflac_crc16__64bit(crc, data, count);
#else
return drflac_crc16__32bit(crc, data, count);
#endif
}
#endif
#ifdef DRFLAC_64BIT
#define drflac__be2host__cache_line drflac__be2host_64
#else
......@@ -2456,27 +2253,6 @@ static drflac_bool32 drflac__read_uint64(drflac_bs* bs, unsigned int bitCount, d
}
#endif
/* Function below is unused, but leaving it here in case I need to quickly add it again. */
#if 0
static drflac_bool32 drflac__read_int64(drflac_bs* bs, unsigned int bitCount, drflac_int64* pResultOut)
{
drflac_uint64 result;
drflac_uint64 signbit;
DRFLAC_ASSERT(bitCount <= 64);
if (!drflac__read_uint64(bs, bitCount, &result)) {
return DRFLAC_FALSE;
}
signbit = ((result >> (bitCount-1)) & 0x01);
result |= (~signbit + 1) << bitCount;
*pResultOut = (drflac_int64)result;
return DRFLAC_TRUE;
}
#endif
static drflac_bool32 drflac__read_uint16(drflac_bs* bs, unsigned int bitCount, drflac_uint16* pResult)
{
drflac_uint32 result;
......@@ -2494,25 +2270,6 @@ static drflac_bool32 drflac__read_uint16(drflac_bs* bs, unsigned int bitCount, d
return DRFLAC_TRUE;
}
#if 0
static drflac_bool32 drflac__read_int16(drflac_bs* bs, unsigned int bitCount, drflac_int16* pResult)
{
drflac_int32 result;
DRFLAC_ASSERT(bs != NULL);
DRFLAC_ASSERT(pResult != NULL);
DRFLAC_ASSERT(bitCount > 0);
DRFLAC_ASSERT(bitCount <= 16);
if (!drflac__read_int32(bs, bitCount, &result)) {
return DRFLAC_FALSE;
}
*pResult = (drflac_int16)result;
return DRFLAC_TRUE;
}
#endif
static drflac_bool32 drflac__read_uint8(drflac_bs* bs, unsigned int bitCount, drflac_uint8* pResult)
{
drflac_uint32 result;
......@@ -3183,236 +2940,75 @@ static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_64(drflac_uint32
return (drflac_int32)(prediction >> shift);
}
#if 0
/*
Reference implementation for reading and decoding samples with residual. This is intentionally left unoptimized for the
sake of readability and should only be used as a reference.
*/
static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
{
drflac_uint32 i;
drflac_uint32 riceParamPlus1 = riceParam + 1;
/*drflac_cache_t riceParamPlus1Mask = DRFLAC_CACHE_L1_SELECTION_MASK(riceParamPlus1);*/
drflac_uint32 riceParamPlus1Shift = DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPlus1);
drflac_uint32 riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
DRFLAC_ASSERT(bs != NULL);
DRFLAC_ASSERT(count > 0);
DRFLAC_ASSERT(pSamplesOut != NULL);
/*
The idea here is to use local variables for the cache in an attempt to encourage the compiler to store them in registers. I have
no idea how this will work in practice...
*/
drflac_cache_t bs_cache = bs->cache;
drflac_uint32 bs_consumedBits = bs->consumedBits;
for (i = 0; i < count; ++i) {
drflac_uint32 zeroCounter = 0;
for (;;) {
drflac_uint8 bit;
if (!drflac__read_uint8(bs, 1, &bit)) {
return DRFLAC_FALSE;
}
/* The first thing to do is find the first unset bit. Most likely a bit will be set in the current cache line. */
drflac_uint32 lzcount = drflac__clz(bs_cache);
if (lzcount < sizeof(bs_cache)*8) {
pZeroCounterOut[0] = lzcount;
if (bit == 0) {
zeroCounter += 1;
} else {
break;
}
}
/*
It is most likely that the riceParam part (which comes after the zero counter) is also on this cache line. When extracting
this, we include the set bit from the unary coded part because it simplifies cache management. This bit will be handled
outside of this function at a higher level.
*/
extract_rice_param_part:
bs_cache <<= lzcount;
bs_consumedBits += lzcount;
drflac_uint32 decodedRice;
if (riceParam > 0) {
if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
return DRFLAC_FALSE;
}
if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
/* Getting here means the rice parameter part is wholly contained within the current cache line. */
pRiceParamPartOut[0] = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
bs_cache <<= riceParamPlus1;
bs_consumedBits += riceParamPlus1;
} else {
decodedRice = 0;
}
drflac_uint32 riceParamPartHi;
drflac_uint32 riceParamPartLo;
drflac_uint32 riceParamPartLoBitCount;
decodedRice |= (zeroCounter << riceParam);
if ((decodedRice & 0x01)) {
decodedRice = ~(decodedRice >> 1);
} else {
decodedRice = (decodedRice >> 1);
}
/*
Getting here means the rice parameter part straddles the cache line. We need to read from the tail of the current cache
line, reload the cache, and then combine it with the head of the next cache line.
*/
/* Grab the high part of the rice parameter part. */
riceParamPartHi = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
if (bitsPerSample+shift >= 32) {
pSamplesOut[i] = decodedRice + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
} else {
pSamplesOut[i] = decodedRice + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
}
}
/* Before reloading the cache we need to grab the size in bits of the low part. */
riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
return DRFLAC_TRUE;
}
#endif
/* Now reload the cache. */
if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
#ifndef DR_FLAC_NO_CRC
drflac__update_crc16(bs);
#endif
bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
bs_consumedBits = riceParamPartLoBitCount;
#ifndef DR_FLAC_NO_CRC
bs->crc16Cache = bs_cache;
#endif
} else {
/* Slow path. We need to fetch more data from the client. */
if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE;
}
#if 0
static drflac_bool32 drflac__read_rice_parts__reference(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
{
drflac_uint32 zeroCounter = 0;
drflac_uint32 decodedRice;
for (;;) {
drflac_uint8 bit;
if (!drflac__read_uint8(bs, 1, &bit)) {
return DRFLAC_FALSE;
}
if (bit == 0) {
zeroCounter += 1;
} else {
break;
}
}
if (riceParam > 0) {
if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
return DRFLAC_FALSE;
}
} else {
decodedRice = 0;
}
*pZeroCounterOut = zeroCounter;
*pRiceParamPartOut = decodedRice;
return DRFLAC_TRUE;
}
#endif
#if 0
static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
{
drflac_cache_t riceParamMask;
drflac_uint32 zeroCounter;
drflac_uint32 setBitOffsetPlus1;
drflac_uint32 riceParamPart;
drflac_uint32 riceLength;
DRFLAC_ASSERT(riceParam > 0); /* <-- riceParam should never be 0. drflac__read_rice_parts__param_equals_zero() should be used instead for this case. */
riceParamMask = DRFLAC_CACHE_L1_SELECTION_MASK(riceParam);
zeroCounter = 0;
while (bs->cache == 0) {
zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE;
}
}
setBitOffsetPlus1 = drflac__clz(bs->cache);
zeroCounter += setBitOffsetPlus1;
setBitOffsetPlus1 += 1;
riceLength = setBitOffsetPlus1 + riceParam;
if (riceLength < DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
riceParamPart = (drflac_uint32)((bs->cache & (riceParamMask >> setBitOffsetPlus1)) >> DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceLength));
bs->consumedBits += riceLength;
bs->cache <<= riceLength;
} else {
drflac_uint32 bitCountLo;
drflac_cache_t resultHi;
bs->consumedBits += riceLength;
bs->cache <<= setBitOffsetPlus1 & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1); /* <-- Equivalent to "if (setBitOffsetPlus1 < DRFLAC_CACHE_L1_SIZE_BITS(bs)) { bs->cache <<= setBitOffsetPlus1; }" */
/* It straddles the cached data. It will never cover more than the next chunk. We just read the number in two parts and combine them. */
bitCountLo = bs->consumedBits - DRFLAC_CACHE_L1_SIZE_BITS(bs);
resultHi = DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, riceParam); /* <-- Use DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE() if ever this function allows riceParam=0. */
if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
#ifndef DR_FLAC_NO_CRC
drflac__update_crc16(bs);
#endif
bs->cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
bs->consumedBits = 0;
#ifndef DR_FLAC_NO_CRC
bs->crc16Cache = bs->cache;
#endif
} else {
/* Slow path. We need to fetch more data from the client. */
if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE;
}
}
riceParamPart = (drflac_uint32)(resultHi | DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, bitCountLo));
bs->consumedBits += bitCountLo;
bs->cache <<= bitCountLo;
}
pZeroCounterOut[0] = zeroCounter;
pRiceParamPartOut[0] = riceParamPart;
return DRFLAC_TRUE;
}
#endif
static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
{
drflac_uint32 riceParamPlus1 = riceParam + 1;
/*drflac_cache_t riceParamPlus1Mask = DRFLAC_CACHE_L1_SELECTION_MASK(riceParamPlus1);*/
drflac_uint32 riceParamPlus1Shift = DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPlus1);
drflac_uint32 riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
/*
The idea here is to use local variables for the cache in an attempt to encourage the compiler to store them in registers. I have
no idea how this will work in practice...
*/
drflac_cache_t bs_cache = bs->cache;
drflac_uint32 bs_consumedBits = bs->consumedBits;
/* The first thing to do is find the first unset bit. Most likely a bit will be set in the current cache line. */
drflac_uint32 lzcount = drflac__clz(bs_cache);
if (lzcount < sizeof(bs_cache)*8) {
pZeroCounterOut[0] = lzcount;
/*
It is most likely that the riceParam part (which comes after the zero counter) is also on this cache line. When extracting
this, we include the set bit from the unary coded part because it simplifies cache management. This bit will be handled
outside of this function at a higher level.
*/
extract_rice_param_part:
bs_cache <<= lzcount;
bs_consumedBits += lzcount;
if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
/* Getting here means the rice parameter part is wholly contained within the current cache line. */
pRiceParamPartOut[0] = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
bs_cache <<= riceParamPlus1;
bs_consumedBits += riceParamPlus1;
} else {
drflac_uint32 riceParamPartHi;
drflac_uint32 riceParamPartLo;
drflac_uint32 riceParamPartLoBitCount;
/*
Getting here means the rice parameter part straddles the cache line. We need to read from the tail of the current cache
line, reload the cache, and then combine it with the head of the next cache line.
*/
/* Grab the high part of the rice parameter part. */
riceParamPartHi = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
/* Before reloading the cache we need to grab the size in bits of the low part. */
riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
/* Now reload the cache. */
if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
#ifndef DR_FLAC_NO_CRC
drflac__update_crc16(bs);
#endif
bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
bs_consumedBits = riceParamPartLoBitCount;
#ifndef DR_FLAC_NO_CRC
bs->crc16Cache = bs_cache;
#endif
} else {
/* Slow path. We need to fetch more data from the client. */
if (!drflac__reload_cache(bs)) {
return DRFLAC_FALSE;
}
bs_cache = bs->cache;
bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
}
bs_cache = bs->cache;
bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
}
/* We should now have enough information to construct the rice parameter part. */
riceParamPartLo = (drflac_uint32)(bs_cache >> (DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPartLoBitCount)));
......@@ -4704,11 +4300,7 @@ static drflac_bool32 drflac__decode_samples_with_residual__rice(drflac_bs* bs, d
#endif
{
/* Scalar fallback. */
#if 0
return drflac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
#else
return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
#endif
}
}
......@@ -5826,16 +5418,6 @@ static drflac_bool32 drflac__seek_to_approximate_flac_frame_to_byte(drflac* pFla
static drflac_bool32 drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 offset)
{
/* This section of code would be used if we were only decoding the FLAC frame header when calling drflac__seek_to_approximate_flac_frame_to_byte(). */
#if 0
if (drflac__decode_flac_frame(pFlac) != DRFLAC_SUCCESS) {
/* We failed to decode this frame which may be due to it being corrupt. We'll just use the next valid FLAC frame. */
if (drflac__read_and_decode_next_flac_frame(pFlac) == DRFLAC_FALSE) {
return DRFLAC_FALSE;
}
}
#endif
return drflac__seek_forward_by_pcm_frames(pFlac, offset) == offset;
}
......@@ -6845,24 +6427,6 @@ static DRFLAC_INLINE drflac_uint32 drflac_crc32_byte(drflac_uint32 crc32, drflac
#endif
}