Make the bsinc l and m coefficients unsigned
This commit is contained in:
parent
1da7512628
commit
aca9f4e095
@ -67,8 +67,8 @@ extern Resampler ResamplerDefault;
|
||||
*/
|
||||
struct BsincState {
|
||||
ALfloat sf; /* Scale interpolation factor. */
|
||||
ALsizei m; /* Coefficient count. */
|
||||
ALsizei l; /* Left coefficient offset. */
|
||||
ALuint m; /* Coefficient count. */
|
||||
ALuint l; /* Left coefficient offset. */
|
||||
/* Filter coefficients, followed by the scale, phase, and scale-phase
|
||||
* delta coefficients. Starting at phase index 0, each subsequent phase
|
||||
* index follows contiguously.
|
||||
|
@ -21,7 +21,7 @@ inline ALfloat do_cubic(const InterpState&, const ALfloat *RESTRICT vals, const
|
||||
{ return cubic(vals[0], vals[1], vals[2], vals[3], static_cast<float>(frac)*(1.0f/FRACTIONONE)); }
|
||||
inline ALfloat do_bsinc(const InterpState &istate, const ALfloat *RESTRICT vals, const ALuint frac)
|
||||
{
|
||||
ASSUME(istate.bsinc.m > 0);
|
||||
const size_t m{istate.bsinc.m};
|
||||
|
||||
// Calculate the phase index and factor.
|
||||
#define FRAC_PHASE_BITDIFF (FRACTIONBITS-BSINC_PHASE_BITS)
|
||||
@ -30,14 +30,14 @@ inline ALfloat do_bsinc(const InterpState &istate, const ALfloat *RESTRICT vals,
|
||||
(1.0f/(1<<FRAC_PHASE_BITDIFF))};
|
||||
#undef FRAC_PHASE_BITDIFF
|
||||
|
||||
const ALfloat *fil{istate.bsinc.filter + istate.bsinc.m*static_cast<ptrdiff_t>(pi*4)};
|
||||
const ALfloat *scd{fil + istate.bsinc.m};
|
||||
const ALfloat *phd{scd + istate.bsinc.m};
|
||||
const ALfloat *spd{phd + istate.bsinc.m};
|
||||
const ALfloat *fil{istate.bsinc.filter + m*pi*4};
|
||||
const ALfloat *scd{fil + m};
|
||||
const ALfloat *phd{scd + m};
|
||||
const ALfloat *spd{phd + m};
|
||||
|
||||
// Apply the scale and phase interpolated filter.
|
||||
ALfloat r{0.0f};
|
||||
for(ALsizei j_f{0};j_f < istate.bsinc.m;j_f++)
|
||||
for(size_t j_f{0};j_f < m;j_f++)
|
||||
r += (fil[j_f] + istate.bsinc.sf*scd[j_f] + pf*(phd[j_f] + istate.bsinc.sf*spd[j_f])) * vals[j_f];
|
||||
return r;
|
||||
}
|
||||
|
@ -74,9 +74,7 @@ const ALfloat *Resample_<BSincTag,NEONTag>(const InterpState *state, const ALflo
|
||||
{
|
||||
const ALfloat *const filter{state->bsinc.filter};
|
||||
const float32x4_t sf4{vdupq_n_f32(state->bsinc.sf)};
|
||||
const ptrdiff_t m{state->bsinc.m};
|
||||
|
||||
ASSUME(m > 0);
|
||||
const size_t m{state->bsinc.m};
|
||||
|
||||
src -= state->bsinc.l;
|
||||
for(float &out_sample : dst)
|
||||
@ -92,11 +90,11 @@ const ALfloat *Resample_<BSincTag,NEONTag>(const InterpState *state, const ALflo
|
||||
float32x4_t r4{vdupq_n_f32(0.0f)};
|
||||
{
|
||||
const float32x4_t pf4{vdupq_n_f32(pf)};
|
||||
const float *fil{filter + m*static_cast<ptrdiff_t>(pi*4)};
|
||||
const float *fil{filter + m*pi*4};
|
||||
const float *scd{fil + m};
|
||||
const float *phd{scd + m};
|
||||
const float *spd{phd + m};
|
||||
ptrdiff_t td{m >> 2};
|
||||
size_t td{m >> 2};
|
||||
size_t j{0u};
|
||||
|
||||
do {
|
||||
@ -110,8 +108,7 @@ const ALfloat *Resample_<BSincTag,NEONTag>(const InterpState *state, const ALflo
|
||||
j += 4;
|
||||
} while(--td);
|
||||
}
|
||||
r4 = vaddq_f32(r4, vcombine_f32(vrev64_f32(vget_high_f32(r4)),
|
||||
vrev64_f32(vget_low_f32(r4))));
|
||||
r4 = vaddq_f32(r4, vrev64q_f32(r4));
|
||||
out_sample = vget_lane_f32(vadd_f32(vget_low_f32(r4), vget_high_f32(r4)), 0);
|
||||
|
||||
frac += increment;
|
||||
|
@ -19,9 +19,7 @@ const ALfloat *Resample_<BSincTag,SSETag>(const InterpState *state, const ALfloa
|
||||
{
|
||||
const ALfloat *const filter{state->bsinc.filter};
|
||||
const __m128 sf4{_mm_set1_ps(state->bsinc.sf)};
|
||||
const ptrdiff_t m{state->bsinc.m};
|
||||
|
||||
ASSUME(m > 0);
|
||||
const size_t m{state->bsinc.m};
|
||||
|
||||
src -= state->bsinc.l;
|
||||
for(float &out_sample : dst)
|
||||
@ -41,7 +39,7 @@ const ALfloat *Resample_<BSincTag,SSETag>(const InterpState *state, const ALfloa
|
||||
const float *scd{fil + m};
|
||||
const float *phd{scd + m};
|
||||
const float *spd{phd + m};
|
||||
ptrdiff_t td{m >> 2};
|
||||
size_t td{m >> 2};
|
||||
size_t j{0u};
|
||||
|
||||
#define MLA4(x, y, z) _mm_add_ps(x, _mm_mul_ps(y, z))
|
||||
|
@ -300,17 +300,17 @@ static void BsiGenerateTables(FILE *output, const char *tabname, const double re
|
||||
fprintf(output, " /* scaleBase */ %.9ef, /* scaleRange */ %.9ef,\n", scaleBase, 1.0 / scaleRange);
|
||||
|
||||
fprintf(output, " /* m */ {");
|
||||
fprintf(output, " %d", mt[0]);
|
||||
fprintf(output, " %du", mt[0]);
|
||||
for(si = 1; si < BSINC_SCALE_COUNT; si++)
|
||||
fprintf(output, ", %d", mt[si]);
|
||||
fprintf(output, ", %du", mt[si]);
|
||||
fprintf(output, " },\n");
|
||||
|
||||
fprintf(output, " /* filterOffset */ {");
|
||||
fprintf(output, " %d", 0);
|
||||
fprintf(output, " %du", 0);
|
||||
i = mt[0]*4*BSINC_PHASE_COUNT;
|
||||
for(si = 1; si < BSINC_SCALE_COUNT; si++)
|
||||
{
|
||||
fprintf(output, ", %d", i);
|
||||
fprintf(output, ", %du", i);
|
||||
i += mt[si]*4*BSINC_PHASE_COUNT;
|
||||
}
|
||||
|
||||
@ -344,14 +344,15 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
output = stdout;
|
||||
|
||||
fprintf(output, "/* Generated by bsincgen, do not edit! */\n\n"
|
||||
fprintf(output, "/* Generated by bsincgen, do not edit! */\n"
|
||||
"#pragma once\n\n"
|
||||
"static_assert(BSINC_SCALE_COUNT == %d, \"Unexpected BSINC_SCALE_COUNT value!\");\n"
|
||||
"static_assert(BSINC_PHASE_COUNT == %d, \"Unexpected BSINC_PHASE_COUNT value!\");\n"
|
||||
"static_assert(FRACTIONONE == %d, \"Unexpected FRACTIONONE value!\");\n\n"
|
||||
"struct BSincTable {\n"
|
||||
" const float scaleBase, scaleRange;\n"
|
||||
" const int m[BSINC_SCALE_COUNT];\n"
|
||||
" const int filterOffset[BSINC_SCALE_COUNT];\n"
|
||||
" const unsigned int m[BSINC_SCALE_COUNT];\n"
|
||||
" const unsigned int filterOffset[BSINC_SCALE_COUNT];\n"
|
||||
" const float *Tab;\n"
|
||||
"};\n\n", BSINC_SCALE_COUNT, BSINC_PHASE_COUNT, FRACTIONONE);
|
||||
/* A 23rd order filter with a -60dB drop at nyquist. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user