diff options
author | Chris Robinson <[email protected]> | 2017-08-25 05:52:19 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-08-25 05:52:19 -0700 |
commit | 561e95528f55be2837541239236281c4cd63d728 (patch) | |
tree | 6d57db817feef0cc132293e0c319dd2796a8bc41 | |
parent | 9ea32713b57fd95832172de5e8d8534339bb646b (diff) |
Rename the bsinc resampler to bsinc12
-rw-r--r-- | Alc/ALu.c | 12 | ||||
-rw-r--r-- | Alc/bsinc_inc.c | 33 | ||||
-rw-r--r-- | Alc/converter.c | 2 | ||||
-rw-r--r-- | Alc/mixer.c | 4 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 4 | ||||
-rw-r--r-- | OpenAL32/alState.c | 4 | ||||
-rw-r--r-- | utils/bsincgen.c | 94 |
7 files changed, 78 insertions, 75 deletions
@@ -234,7 +234,7 @@ ALboolean BsincPrepare(const ALuint increment, BsincState *state) if(increment > FRACTIONONE) { sf = (ALfloat)FRACTIONONE / increment; - if(sf < bsinc.scaleBase) + if(sf < bsinc12.scaleBase) { /* Signal has been completely cut. The return result can be used * to skip the filter (and output zeros) as an optimization. @@ -245,7 +245,7 @@ ALboolean BsincPrepare(const ALuint increment, BsincState *state) } else { - sf = (BSINC_SCALE_COUNT - 1) * (sf - bsinc.scaleBase) * bsinc.scaleRange; + sf = (BSINC_SCALE_COUNT - 1) * (sf - bsinc12.scaleBase) * bsinc12.scaleRange; si = fastf2i(sf); /* The interpolation factor is fit to this diagonally-symmetric * curve to reduce the transition ripple caused by interpolating @@ -261,9 +261,9 @@ ALboolean BsincPrepare(const ALuint increment, BsincState *state) } state->sf = sf; - state->m = bsinc.m[si]; + state->m = bsinc12.m[si]; state->l = -((state->m/2) - 1); - state->filter = bsinc.Tab + bsinc.filterOffset[si]; + state->filter = bsinc12.Tab + bsinc12.filterOffset[si]; return uncut; } @@ -1038,7 +1038,7 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *p voice->Step = MAX_PITCH<<FRACTIONBITS; else voice->Step = maxi(fastf2i(Pitch*FRACTIONONE + 0.5f), 1); - if(props->Resampler == BSincResampler) + if(props->Resampler == BSinc12Resampler) BsincPrepare(voice->Step, &voice->ResampleState.bsinc); else voice->ResampleState.sinc4.filter = sinc4Tab; @@ -1384,7 +1384,7 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop voice->Step = MAX_PITCH<<FRACTIONBITS; else voice->Step = maxi(fastf2i(Pitch*FRACTIONONE + 0.5f), 1); - if(props->Resampler == BSincResampler) + if(props->Resampler == BSinc12Resampler) BsincPrepare(voice->Step, &voice->ResampleState.bsinc); else voice->ResampleState.sinc4.filter = sinc4Tab; diff --git a/Alc/bsinc_inc.c b/Alc/bsinc_inc.c index 23b4f356..306280a7 100644 --- a/Alc/bsinc_inc.c +++ b/Alc/bsinc_inc.c @@ -1,19 +1,24 @@ /* Generated by bsincgen, do not edit! */ -/* Table of windowed sinc coefficients and deltas. This 11th order filter - * has a rejection of -60dB, yielding a transition width of ~0.330 - * (normalized frequency). Order increases when downsampling to a limit of - * one octave, after which the quality of the filter (transition width) - * suffers to reduce the CPU cost. The bandlimiting will cut all sound after - * downsampling by ~2.60 octaves. - */ -static const struct { - alignas(16) const float Tab[19968]; +typedef struct BSincTable { const float scaleBase, scaleRange; const int m[BSINC_SCALE_COUNT]; const int filterOffset[BSINC_SCALE_COUNT]; -} bsinc = { - /* Tab */ { + alignas(16) const float Tab[]; +} BSincTable; + +/* This 11th order filter has a rejection of -60dB, yielding a transition width + * of ~0.330 (normalized frequency). Order increases when downsampling to a + * limit of one octave, after which the quality of the filter (transition + * width) suffers to reduce the CPU cost. The bandlimiting will cut all sound + * after downsampling by ~2.60 octaves. + */ +static const BSincTable bsinc12 = { + /* scaleBase */ 1.647904275e-01f, /* scaleRange */ 1.197304285e+00f, + /* m */ { 24, 24, 24, 24, 24, 24, 24, 20, 20, 20, 16, 16, 16, 12, 12, 12 }, + /* filterOffset */ { 0, 1536, 3072, 4608, 6144, 7680, 9216, 10752, 12032, 13312, 14592, 15616, 16640, 17664, 18432, 19200 }, + + /* Tab (19968 entries) */ { /* 0, 0 (24) */ +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +1.519885812e-03f, +3.451133814e-03f, +6.515582343e-03f, +1.087383005e-02f, +1.652921626e-02f, +2.328367055e-02f, +3.072645296e-02f, +3.826378940e-02f, +4.518869460e-02f, +5.078083067e-02f, +5.441847120e-02f, +5.568063817e-02f, +5.441847120e-02f, +5.078083067e-02f, +4.518869460e-02f, +3.826378940e-02f, +3.072645296e-02f, +2.328367055e-02f, +1.652921626e-02f, +1.087383005e-02f, +6.515582343e-03f, +3.451133814e-03f, +1.519885812e-03f, +4.670736076e-04f, @@ -1294,11 +1299,7 @@ static const struct { +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +1.544493457e-04f, +4.223256891e-05f, -2.661988046e-03f, +7.330028758e-03f, -3.445837508e-03f, -3.834855341e-02f, +2.120373480e-03f, +3.776872257e-02f, +1.185399556e-03f, -6.580914053e-03f, +2.738584812e-03f, -1.901296535e-04f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, +0.000000000e+00f, - }, - - /* scaleBase */ 1.647904275e-01f, /* scaleRange */ 1.197304285e+00f, - /* m */ { 24, 24, 24, 24, 24, 24, 24, 20, 20, 20, 16, 16, 16, 12, 12, 12 }, - /* filterOffset */ { 0, 1536, 3072, 4608, 6144, 7680, 9216, 10752, 12032, 13312, 14592, 15616, 16640, 17664, 18432, 19200 } + } }; alignas(16) static const float sinc4Tab[FRACTIONONE][4] = { diff --git a/Alc/converter.c b/Alc/converter.c index 304e9a80..fa9928c2 100644 --- a/Alc/converter.c +++ b/Alc/converter.c @@ -34,7 +34,7 @@ SampleConverter *CreateSampleConverter(enum DevFmtType srcType, enum DevFmtType { /* TODO: Allow other resamplers. */ BsincPrepare(converter->mIncrement, &converter->mState.bsinc); - converter->mResample = SelectResampler(BSincResampler); + converter->mResample = SelectResampler(BSinc12Resampler); } END_MIXER_MODE(); diff --git a/Alc/mixer.c b/Alc/mixer.c index bb71fde4..cf2f96fb 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -141,7 +141,7 @@ ResamplerFunc SelectResampler(enum Resampler resampler) return Resample_fir4_SSE3; #endif return Resample_fir4_C; - case BSincResampler: + case BSinc12Resampler: #ifdef HAVE_NEON if((CPUCapFlags&CPU_CAP_NEON)) return Resample_bsinc_Neon; @@ -170,7 +170,7 @@ void aluInitMixer(void) else if(strcasecmp(str, "sinc4") == 0) ResamplerDefault = FIR4Resampler; else if(strcasecmp(str, "bsinc") == 0) - ResamplerDefault = BSincResampler; + ResamplerDefault = BSinc12Resampler; else if(strcasecmp(str, "cubic") == 0 || strcasecmp(str, "sinc8") == 0) { WARN("Resampler option \"%s\" is deprecated, using sinc4\n", str); diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index d902a8c4..e5fd8b09 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -53,9 +53,9 @@ enum Resampler { PointResampler, LinearResampler, FIR4Resampler, - BSincResampler, + BSinc12Resampler, - ResamplerMax = BSincResampler + ResamplerMax = BSinc12Resampler }; extern enum Resampler ResamplerDefault; diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index a7dc1006..19b0996c 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -51,7 +51,7 @@ static const ALchar alErrOutOfMemory[] = "Out of Memory"; static const ALchar alPointResampler[] = "Nearest"; static const ALchar alLinearResampler[] = "Linear"; static const ALchar alSinc4Resampler[] = "4-Point Sinc"; -static const ALchar alBSincResampler[] = "Band-limited Sinc (12/24)"; +static const ALchar alBSinc12Resampler[] = "Band-limited Sinc (12/24)"; AL_API ALvoid AL_APIENTRY alEnable(ALenum capability) { @@ -750,7 +750,7 @@ AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index) { const char *ResamplerNames[] = { alPointResampler, alLinearResampler, - alSinc4Resampler, alBSincResampler, + alSinc4Resampler, alBSinc12Resampler, }; const ALchar *value = NULL; ALCcontext *context; diff --git a/utils/bsincgen.c b/utils/bsincgen.c index 15813e36..0064060f 100644 --- a/utils/bsincgen.c +++ b/utils/bsincgen.c @@ -239,31 +239,50 @@ static void BsiGenerateTables(const char *tabname, const double rejection, const for(si = 0; si < BSINC_SCALE_COUNT; si++)
mt[si] = (mt[si]+3) & ~3;
+ fprintf(stdout,
+"/* This %d%s order filter has a rejection of -%.0fdB, yielding a transition width\n"
+" * of ~%.3f (normalized frequency). Order increases when downsampling to a\n"
+" * limit of one octave, after which the quality of the filter (transition\n"
+" * width) suffers to reduce the CPU cost. The bandlimiting will cut all sound\n"
+" * after downsampling by ~%.2f octaves.\n"
+" */\n"
+"static const BSincTable %s = {\n",
+ order, (((order%100)/10) == 1) ? "th" :
+ ((order%10) == 1) ? "st" :
+ ((order%10) == 2) ? "nd" :
+ ((order%10) == 3) ? "rd" : "th",
+ rejection, width, log2(1.0/scaleBase), tabname);
+
+ /* The scaleBase is calculated from the Kaiser window transition width.
+ It represents the absolute limit to the filter before it fully cuts
+ the signal. The limit in octaves can be calculated by taking the
+ base-2 logarithm of its inverse: log_2(1 / scaleBase)
+ */
+ fprintf(stdout, " /* scaleBase */ %.9ef, /* scaleRange */ %.9ef,\n", scaleBase, 1.0 / scaleRange);
+
+ fprintf(stdout, " /* m */ {");
+ fprintf(stdout, " %d", mt[0]);
+ for(si = 1; si < BSINC_SCALE_COUNT; si++)
+ fprintf(stdout, ", %d", mt[si]);
+ fprintf(stdout, " },\n");
+
+ fprintf(stdout, " /* filterOffset */ {");
+ fprintf(stdout, " %d", 0);
+ i = mt[0]*4*BSINC_PHASE_COUNT;
+ for(si = 1; si < BSINC_SCALE_COUNT; si++)
+ {
+ fprintf(stdout, ", %d", i);
+ i += mt[si]*4*BSINC_PHASE_COUNT;
+ }
+
+ fprintf(stdout, " },\n");
+
// Calculate the table size.
i = 0;
for(si = 0; si < BSINC_SCALE_COUNT; si++)
i += 4 * BSINC_PHASE_COUNT * mt[si];
- fprintf(stdout, "/* Generated by bsincgen, do not edit! */\n\n"
-"/* Table of windowed sinc coefficients and deltas. This %d%s order filter\n"
-" * has a rejection of -%gdB, yielding a transition width of ~%.3f\n"
-" * (normalized frequency). Order increases when downsampling to a limit of\n"
-" * one octave, after which the quality of the filter (transition width)\n"
-" * suffers to reduce the CPU cost. The bandlimiting will cut all sound after\n"
-" * downsampling by ~%.2f octaves.\n"
-" */\n"
-"static const struct {\n"
-" alignas(16) const float Tab[%d];\n"
-" const float scaleBase, scaleRange;\n"
-" const int m[BSINC_SCALE_COUNT];\n"
-" const int filterOffset[BSINC_SCALE_COUNT];\n"
-"} %s = {\n", order, (((order%100)/10) == 1) ? "th" :
- ((order%10) == 1) ? "st" :
- ((order%10) == 2) ? "nd" :
- ((order%10) == 3) ? "rd" : "th",
- rejection, width, log2(1.0/scaleBase), i, tabname);
-
- fprintf(stdout, " /* Tab */ {\n");
+ fprintf(stdout, "\n /* Tab (%d entries) */ {\n", i);
for(si = 0; si < BSINC_SCALE_COUNT; si++)
{
const int m = mt[si];
@@ -287,31 +306,7 @@ static void BsiGenerateTables(const char *tabname, const double rejection, const fprintf(stdout, "\n");
}
}
- fprintf(stdout, " },\n\n");
-
- /* The scaleBase is calculated from the Kaiser window transition width.
- It represents the absolute limit to the filter before it fully cuts
- the signal. The limit in octaves can be calculated by taking the
- base-2 logarithm of its inverse: log_2(1 / scaleBase)
- */
- fprintf(stdout, " /* scaleBase */ %.9ef, /* scaleRange */ %.9ef,\n", scaleBase, 1.0 / scaleRange);
-
- fprintf(stdout, " /* m */ {");
- fprintf(stdout, " %d", mt[0]);
- for(si = 1; si < BSINC_SCALE_COUNT; si++)
- fprintf(stdout, ", %d", mt[si]);
- fprintf(stdout, " },\n");
-
- fprintf(stdout, " /* filterOffset */ {");
- fprintf(stdout, " %d", 0);
- i = mt[0]*4*BSINC_PHASE_COUNT;
- for(si = 1; si < BSINC_SCALE_COUNT; si++)
- {
- fprintf(stdout, ", %d", i);
- i += mt[si]*4*BSINC_PHASE_COUNT;
- }
-
- fprintf(stdout, " }\n};\n\n");
+ fprintf(stdout, " }\n};\n\n");
}
@@ -358,8 +353,15 @@ static void Sinc4GenerateTables(const double rejection) int main(void)
{
+ fprintf(stdout, "/* Generated by bsincgen, do not edit! */\n\n"
+"typedef struct BSincTable {\n"
+" const float scaleBase, scaleRange;\n"
+" const int m[BSINC_SCALE_COUNT];\n"
+" const int filterOffset[BSINC_SCALE_COUNT];\n"
+" alignas(16) const float Tab[];\n"
+"} BSincTable;\n\n");
/* An 11th order filter with a -60dB drop at nyquist. */
- BsiGenerateTables("bsinc", 60.0, 11);
+ BsiGenerateTables("bsinc12", 60.0, 11);
Sinc4GenerateTables(60.0);
return 0;
}
|