pcm/Dsd2Pcm: move code to CalcOutputSample()
This commit is contained in:
parent
e7483bc5bc
commit
6bfbc5d320
|
@ -161,6 +161,18 @@ Dsd2Pcm::Reset() noexcept
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline float
|
||||||
|
Dsd2Pcm::CalcOutputSample(unsigned ffp) const noexcept
|
||||||
|
{
|
||||||
|
double acc = 0;
|
||||||
|
for (unsigned i = 0; i < CTABLES; ++i) {
|
||||||
|
unsigned bite1 = fifo[(ffp -i) & FIFOMASK] & 0xFF;
|
||||||
|
unsigned bite2 = fifo[(ffp-(CTABLES*2-1)+i) & FIFOMASK] & 0xFF;
|
||||||
|
acc += ctables[i][bite1] + ctables[i][bite2];
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Dsd2Pcm::Translate(size_t samples,
|
Dsd2Pcm::Translate(size_t samples,
|
||||||
const unsigned char *src, ptrdiff_t src_stride,
|
const unsigned char *src, ptrdiff_t src_stride,
|
||||||
|
@ -174,13 +186,8 @@ Dsd2Pcm::Translate(size_t samples,
|
||||||
fifo[ffp] = bite1; src += src_stride;
|
fifo[ffp] = bite1; src += src_stride;
|
||||||
unsigned char *p = fifo + ((ffp-CTABLES) & FIFOMASK);
|
unsigned char *p = fifo + ((ffp-CTABLES) & FIFOMASK);
|
||||||
*p = bit_reverse(*p);
|
*p = bit_reverse(*p);
|
||||||
double acc = 0;
|
*dst = CalcOutputSample(ffp);
|
||||||
for (unsigned i = 0; i < CTABLES; ++i) {
|
dst += dst_stride;
|
||||||
bite1 = fifo[(ffp -i) & FIFOMASK] & 0xFF;
|
|
||||||
unsigned bite2 = fifo[(ffp-(CTABLES*2-1)+i) & FIFOMASK] & 0xFF;
|
|
||||||
acc += ctables[i][bite1] + ctables[i][bite2];
|
|
||||||
}
|
|
||||||
*dst = (float)acc; dst += dst_stride;
|
|
||||||
ffp = (ffp + 1) & FIFOMASK;
|
ffp = (ffp + 1) & FIFOMASK;
|
||||||
}
|
}
|
||||||
fifopos = ffp;
|
fifopos = ffp;
|
||||||
|
|
|
@ -73,6 +73,9 @@ public:
|
||||||
const unsigned char *src, ptrdiff_t src_stride,
|
const unsigned char *src, ptrdiff_t src_stride,
|
||||||
bool lsbitfirst,
|
bool lsbitfirst,
|
||||||
float *dst, ptrdiff_t dst_stride) noexcept;
|
float *dst, ptrdiff_t dst_stride) noexcept;
|
||||||
|
|
||||||
|
private:
|
||||||
|
float CalcOutputSample(unsigned ffp) const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* include guard DSD2PCM_H_INCLUDED */
|
#endif /* include guard DSD2PCM_H_INCLUDED */
|
||||||
|
|
Loading…
Reference in New Issue