update sdl Merge commit '644725478f4de0f074a6834e8423ac36dce3974f'

This commit is contained in:
2023-09-23 18:53:11 +02:00
172 changed files with 7495 additions and 4062 deletions

View File

@ -1069,11 +1069,6 @@ typedef SDL_GameControllerButton, SDL_GamepadButton;
- SDL_GameControllerButton
+ SDL_GamepadButton
@@
typedef SDL_GameControllerButtonBind, SDL_GamepadBinding;
@@
- SDL_GameControllerButtonBind
+ SDL_GamepadBinding
@@
@@
- SDL_GameControllerClose
+ SDL_CloseGamepad
@ -1115,16 +1110,6 @@ typedef SDL_GameControllerButtonBind, SDL_GamepadBinding;
(...)
@@
@@
- SDL_GameControllerGetBindForAxis
+ SDL_GetGamepadBindForAxis
(...)
@@
@@
- SDL_GameControllerGetBindForButton
+ SDL_GetGamepadBindForButton
(...)
@@
@@
- SDL_GameControllerGetButton
+ SDL_GetGamepadButton
(...)
@ -2591,51 +2576,51 @@ typedef SDL_cond, SDL_Condition;
@@
@@
- AUDIO_F32
+ SDL_AUDIO_F32
+ SDL_AUDIO_F32LE
@@
@@
- AUDIO_F32LSB
+ SDL_AUDIO_F32LSB
+ SDL_AUDIO_F32LE
@@
@@
- AUDIO_F32MSB
+ SDL_AUDIO_F32MSB
+ SDL_AUDIO_F32BE
@@
@@
- AUDIO_F32SYS
+ SDL_AUDIO_F32SYS
+ SDL_AUDIO_F32
@@
@@
- AUDIO_S16
+ SDL_AUDIO_S16
+ SDL_AUDIO_S16LE
@@
@@
- AUDIO_S16LSB
+ SDL_AUDIO_S16LSB
+ SDL_AUDIO_S16LE
@@
@@
- AUDIO_S16MSB
+ SDL_AUDIO_S16MSB
+ SDL_AUDIO_S16BE
@@
@@
- AUDIO_S16SYS
+ SDL_AUDIO_S16SYS
+ SDL_AUDIO_S16
@@
@@
- AUDIO_S32
+ SDL_AUDIO_S32
+ SDL_AUDIO_S32LE
@@
@@
- AUDIO_S32LSB
+ SDL_AUDIO_S32LSB
+ SDL_AUDIO_S32LE
@@
@@
- AUDIO_S32MSB
+ SDL_AUDIO_S32MSB
+ SDL_AUDIO_S32BE
@@
@@
- AUDIO_S32SYS
+ SDL_AUDIO_S32SYS
+ SDL_AUDIO_S32
@@
@@
- AUDIO_S8

View File

@ -0,0 +1,599 @@
#!/usr/bin/perl -w
# Add source files and headers to Xcode and Visual Studio projects.
# THIS IS NOT ROBUST, THIS IS JUST RYAN AVOIDING RUNNING BETWEEN
# THREE COMPUTERS AND A BUNCH OF DEVELOPMENT ENVIRONMENTS TO ADD
# A STUPID FILE TO THE BUILD.
use warnings;
use strict;
use File::Basename;
my %xcode_references = ();
sub generate_xcode_id {
my @chars = ('0'..'9', 'A'..'F');
my $str;
do {
my $len = 16;
$str = '0000'; # start and end with '0000' so we know we added it.
while ($len--) {
$str .= $chars[rand @chars]
};
$str .= '0000'; # start and end with '0000' so we know we added it.
} while (defined($xcode_references{$str}));
$xcode_references{$str} = 1; # so future calls can't generate this one.
return $str;
}
sub process_xcode {
my $addpath = shift;
my $pbxprojfname = shift;
my $lineno;
%xcode_references = ();
my $addfname = basename($addpath);
my $addext = '';
if ($addfname =~ /\.(.*?)\Z/) {
$addext = $1;
}
my $is_public_header = ($addpath =~ /\Ainclude\/SDL3\//) ? 1 : 0;
my $filerefpath = $is_public_header ? "SDL3/$addfname" : $addfname;
my $srcs_or_headers = '';
my $addfiletype = '';
if ($addext eq 'c') {
$srcs_or_headers = 'Sources';
$addfiletype = 'sourcecode.c.c';
} elsif ($addext eq 'm') {
$srcs_or_headers = 'Sources';
$addfiletype = 'sourcecode.c.objc';
} elsif ($addext eq 'h') {
$srcs_or_headers = 'Headers';
$addfiletype = 'sourcecode.c.h';
} else {
die("Unexpected file extension '$addext'\n");
}
my $fh;
open $fh, '<', $pbxprojfname or die("Failed to open '$pbxprojfname': $!\n");
chomp(my @pbxproj = <$fh>);
close($fh);
# build a table of all ids, in case we duplicate one by some miracle.
$lineno = 0;
foreach (@pbxproj) {
$lineno++;
# like "F3676F582A7885080091160D /* SDL3.dmg */ = {"
if (/\A\t\t([A-F0-9]{24}) \/\* (.*?) \*\/ \= \{\Z/) {
$xcode_references{$1} = $2;
}
}
# build out of a tree of PBXGroup items.
my %pbxgroups = ();
my $thispbxgroup;
my $pbxgroup_children;
my $pbxgroup_state = 0;
my $pubheaders_group_hash = '';
my $libsrc_group_hash = '';
$lineno = 0;
foreach (@pbxproj) {
$lineno++;
if ($pbxgroup_state == 0) {
$pbxgroup_state++ if /\A\/\* Begin PBXGroup section \*\/\Z/;
} elsif ($pbxgroup_state == 1) {
# like "F3676F582A7885080091160D /* SDL3.dmg */ = {"
if (/\A\t\t([A-F0-9]{24}) \/\* (.*?) \*\/ \= \{\Z/) {
my %newhash = ();
$pbxgroups{$1} = \%newhash;
$thispbxgroup = \%newhash;
$pubheaders_group_hash = $1 if $2 eq 'Public Headers';
$libsrc_group_hash = $1 if $2 eq 'Library Source';
$pbxgroup_state++;
} elsif (/\A\/\* End PBXGroup section \*\/\Z/) {
last;
} else {
die("Expected pbxgroup obj on '$pbxprojfname' line $lineno\n");
}
} elsif ($pbxgroup_state == 2) {
if (/\A\t\t\tisa \= PBXGroup;\Z/) {
$pbxgroup_state++;
} else {
die("Expected pbxgroup obj's isa field on '$pbxprojfname' line $lineno\n");
}
} elsif ($pbxgroup_state == 3) {
if (/\A\t\t\tchildren \= \(\Z/) {
my %newhash = ();
$$thispbxgroup{'children'} = \%newhash;
$pbxgroup_children = \%newhash;
$pbxgroup_state++;
} else {
die("Expected pbxgroup obj's children field on '$pbxprojfname' line $lineno\n");
}
} elsif ($pbxgroup_state == 4) {
if (/\A\t\t\t\t([A-F0-9]{24}) \/\* (.*?) \*\/,\Z/) {
$$pbxgroup_children{$1} = $2;
} elsif (/\A\t\t\t\);\Z/) {
$pbxgroup_state++;
} else {
die("Expected pbxgroup obj's children element on '$pbxprojfname' line $lineno\n");
}
} elsif ($pbxgroup_state == 5) {
if (/\A\t\t\t(.*?) \= (.*?);\Z/) {
$$thispbxgroup{$1} = $2;
} elsif (/\A\t\t\};\Z/) {
$pbxgroup_state = 1;
} else {
die("Expected pbxgroup obj field on '$pbxprojfname' line $lineno\n");
}
} else {
die("bug in this script.");
}
}
die("Didn't see PBXGroup section in '$pbxprojfname'. Bug?\n") if $pbxgroup_state == 0;
die("Didn't see Public Headers PBXGroup in '$pbxprojfname'. Bug?\n") if $pubheaders_group_hash eq '';
die("Didn't see Library Source PBXGroup in '$pbxprojfname'. Bug?\n") if $libsrc_group_hash eq '';
# Some debug log dumping...
if (0) {
foreach (keys %pbxgroups) {
my $k = $_;
my $g = $pbxgroups{$k};
print("$_:\n");
foreach (keys %$g) {
print(" $_:\n");
if ($_ eq 'children') {
my $kids = $$g{$_};
foreach (keys %$kids) {
print(" $_ -> " . $$kids{$_} . "\n");
}
} else {
print(' ' . $$g{$_} . "\n");
}
}
print("\n");
}
}
# Get some unique IDs for our new thing.
my $fileref = generate_xcode_id();
my $buildfileref = generate_xcode_id();
# Figure out what group to insert this into (or what groups to make)
my $add_to_group_fileref = $fileref;
my $add_to_group_addfname = $addfname;
my $newgrptext = '';
my $grphash = '';
if ($is_public_header) {
$grphash = $pubheaders_group_hash; # done!
} else {
$grphash = $libsrc_group_hash;
my @splitpath = split(/\//, dirname($addpath));
if ($splitpath[0] eq 'src') {
shift @splitpath;
}
while (my $elem = shift(@splitpath)) {
my $g = $pbxgroups{$grphash};
my $kids = $$g{'children'};
my $found = 0;
foreach (keys %$kids) {
my $hash = $_;
my $fname = $$kids{$hash};
if (uc($fname) eq uc($elem)) {
$grphash = $hash;
$found = 1;
last;
}
}
unshift(@splitpath, $elem), last if (not $found);
}
if (@splitpath) { # still elements? We need to build groups.
my $newgroupref = generate_xcode_id();
$add_to_group_fileref = $newgroupref;
$add_to_group_addfname = $splitpath[0];
while (my $elem = shift(@splitpath)) {
my $lastelem = @splitpath ? 0 : 1;
my $childhash = $lastelem ? $fileref : generate_xcode_id();
my $childpath = $lastelem ? $addfname : $splitpath[0];
$newgrptext .= "\t\t$newgroupref /* $elem */ = {\n";
$newgrptext .= "\t\t\tisa = PBXGroup;\n";
$newgrptext .= "\t\t\tchildren = (\n";
$newgrptext .= "\t\t\t\t$childhash /* $childpath */,\n";
$newgrptext .= "\t\t\t);\n";
$newgrptext .= "\t\t\tpath = $elem;\n";
$newgrptext .= "\t\t\tsourceTree = \"<group>\";\n";
$newgrptext .= "\t\t};\n";
$newgroupref = $childhash;
}
}
}
my $tmpfname = "$pbxprojfname.tmp";
open $fh, '>', $tmpfname or die("Failed to open '$tmpfname': $!\n");
my $add_to_this_group = 0;
$pbxgroup_state = 0;
$lineno = 0;
foreach (@pbxproj) {
$lineno++;
if ($pbxgroup_state == 0) {
# Drop in new references at the end of their sections...
if (/\A\/\* End PBXBuildFile section \*\/\Z/) {
print $fh "\t\t$buildfileref /* $addfname in $srcs_or_headers */ = {isa = PBXBuildFile; fileRef = $fileref /* $addfname */;";
if ($is_public_header) {
print $fh " settings = {ATTRIBUTES = (Public, ); };";
}
print $fh " };\n";
} elsif (/\A\/\* End PBXFileReference section \*\/\Z/) {
print $fh "\t\t$fileref /* $addfname */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = $addfiletype; name = $addfname; path = $filerefpath; sourceTree = \"<group>\"; };\n";
} elsif (/\A\/\* Begin PBXGroup section \*\/\Z/) {
$pbxgroup_state = 1;
} elsif (/\A\/\* Begin PBXSourcesBuildPhase section \*\/\Z/) {
$pbxgroup_state = 5;
}
} elsif ($pbxgroup_state == 1) {
if (/\A\t\t([A-F0-9]{24}) \/\* (.*?) \*\/ \= \{\Z/) {
$pbxgroup_state++;
$add_to_this_group = $1 eq $grphash;
} elsif (/\A\/\* End PBXGroup section \*\/\Z/) {
print $fh $newgrptext;
$pbxgroup_state = 0;
}
} elsif ($pbxgroup_state == 2) {
if (/\A\t\t\tchildren \= \(\Z/) {
$pbxgroup_state++;
}
} elsif ($pbxgroup_state == 3) {
if (/\A\t\t\t\);\Z/) {
if ($add_to_this_group) {
print $fh "\t\t\t\t$add_to_group_fileref /* $add_to_group_addfname */,\n";
}
$pbxgroup_state++;
}
} elsif ($pbxgroup_state == 4) {
if (/\A\t\t\};\Z/) {
$add_to_this_group = 0;
}
$pbxgroup_state = 1;
} elsif ($pbxgroup_state == 5) {
if (/\A\t\t\t\);\Z/) {
if ($srcs_or_headers eq 'Sources') {
print $fh "\t\t\t\t$buildfileref /* $addfname in $srcs_or_headers */,\n";
}
$pbxgroup_state = 0;
}
}
print $fh "$_\n";
}
close($fh);
rename($tmpfname, $pbxprojfname);
}
my %visualc_references = ();
sub generate_visualc_id { # these are just standard Windows GUIDs.
my @chars = ('0'..'9', 'a'..'f');
my $str;
do {
my $len = 24;
$str = '0000'; # start and end with '0000' so we know we added it.
while ($len--) {
$str .= $chars[rand @chars]
};
$str .= '0000'; # start and end with '0000' so we know we added it.
$str =~ s/\A(........)(....)(....)(............)\Z/$1-$2-$3-$4/; # add dashes in the appropriate places.
} while (defined($visualc_references{$str}));
$visualc_references{$str} = 1; # so future calls can't generate this one.
return $str;
}
sub process_visualstudio {
my $addpath = shift;
my $vcxprojfname = shift;
my $lineno;
%visualc_references = ();
my $is_public_header = ($addpath =~ /\Ainclude\/SDL3\//) ? 1 : 0;
my $addfname = basename($addpath);
my $addext = '';
if ($addfname =~ /\.(.*?)\Z/) {
$addext = $1;
}
my $isheader = 0;
if ($addext eq 'c') {
$isheader = 0;
} elsif ($addext eq 'm') {
return; # don't add Objective-C files to Visual Studio projects!
} elsif ($addext eq 'h') {
$isheader = 1;
} else {
die("Unexpected file extension '$addext'\n");
}
my $fh;
open $fh, '<', $vcxprojfname or die("Failed to open '$vcxprojfname': $!\n");
chomp(my @vcxproj = <$fh>);
close($fh);
my $vcxgroup_state;
my $rawaddvcxpath = "$addpath";
$rawaddvcxpath =~ s/\//\\/g;
# Figure out relative path from vcxproj file...
my $addvcxpath = '';
my @subdirs = split(/\//, $vcxprojfname);
pop @subdirs;
foreach (@subdirs) {
$addvcxpath .= "..\\";
}
$addvcxpath .= $rawaddvcxpath;
my $prevname = undef;
my $tmpfname;
$tmpfname = "$vcxprojfname.tmp";
open $fh, '>', $tmpfname or die("Failed to open '$tmpfname': $!\n");
my $added = 0;
$added = 0;
$vcxgroup_state = 0;
$prevname = undef;
$lineno = 0;
foreach (@vcxproj) {
$lineno++;
if ($vcxgroup_state == 0) {
if (/\A \<ItemGroup\>\Z/) {
$vcxgroup_state = 1;
$prevname = undef;
}
} elsif ($vcxgroup_state == 1) {
if (/\A \<ClInclude .*\Z/) {
$vcxgroup_state = 2 if $isheader;
} elsif (/\A \<ClCompile .*\Z/) {
$vcxgroup_state = 3 if not $isheader;
} elsif (/\A \<\/ItemGroup\>\Z/) {
$vcxgroup_state = 0;
$prevname = undef;
}
}
# Don't do elsif, we need to check this line again.
if ($vcxgroup_state == 2) {
if (/\A <ClInclude Include="(.*?)" \/\>\Z/) {
my $nextname = $1;
if ((not $added) && (((not defined $prevname) || (uc($prevname) lt uc($addvcxpath))) && (uc($nextname) gt uc($addvcxpath)))) {
print $fh " <ClInclude Include=\"$addvcxpath\" />\n";
$vcxgroup_state = 0;
$added = 1;
}
$prevname = $nextname;
} elsif (/\A \<\/ItemGroup\>\Z/) {
if ((not $added) && ((not defined $prevname) || (uc($prevname) lt uc($addvcxpath)))) {
print $fh " <ClInclude Include=\"$addvcxpath\" />\n";
$vcxgroup_state = 0;
$added = 1;
}
}
} elsif ($vcxgroup_state == 3) {
if (/\A <ClCompile Include="(.*?)" \/\>\Z/) {
my $nextname = $1;
if ((not $added) && (((not defined $prevname) || (uc($prevname) lt uc($addvcxpath))) && (uc($nextname) gt uc($addvcxpath)))) {
print $fh " <ClCompile Include=\"$addvcxpath\" />\n";
$vcxgroup_state = 0;
$added = 1;
}
$prevname = $nextname;
} elsif (/\A \<\/ItemGroup\>\Z/) {
if ((not $added) && ((not defined $prevname) || (uc($prevname) lt uc($addvcxpath)))) {
print $fh " <ClCompile Include=\"$addvcxpath\" />\n";
$vcxgroup_state = 0;
$added = 1;
}
}
}
print $fh "$_\n";
}
close($fh);
rename($tmpfname, $vcxprojfname);
my $vcxfiltersfname = "$vcxprojfname.filters";
open $fh, '<', $vcxfiltersfname or die("Failed to open '$vcxfiltersfname': $!\n");
chomp(my @vcxfilters = <$fh>);
close($fh);
my $newgrptext = '';
my $filter = '';
if ($is_public_header) {
$filter = 'API Headers';
} else {
$filter = lc(dirname($addpath));
$filter =~ s/\Asrc\///; # there's no filter for the base "src/" dir, where SDL.c and friends live.
$filter =~ s/\//\\/g;
if ($filter ne '') {
# see if the filter already exists, otherwise add it.
my %existing_filters = ();
my $current_filter = '';
my $found = 0;
foreach (@vcxfilters) {
# These lines happen to be unique, so we don't have to parse down to find this section.
if (/\A \<Filter Include\="(.*?)"\>\Z/) {
$current_filter = lc($1);
if ($current_filter eq $filter) {
$found = 1;
}
} elsif (/\A \<UniqueIdentifier\>\{(.*?)\}\<\/UniqueIdentifier\>\Z/) {
$visualc_references{$1} = $current_filter; # gather up existing GUIDs to avoid duplicates.
$existing_filters{$current_filter} = $1;
}
}
if (not $found) { # didn't find it? We need to build filters.
my $subpath = '';
my @splitpath = split(/\\/, $filter);
while (my $elem = shift(@splitpath)) {
$subpath .= "\\" if ($subpath ne '');
$subpath .= $elem;
if (not $existing_filters{$subpath}) {
my $newgroupref = generate_visualc_id();
$newgrptext .= " <Filter Include=\"$subpath\">\n";
$newgrptext .= " <UniqueIdentifier>{$newgroupref}</UniqueIdentifier>\n";
$newgrptext .= " </Filter>\n"
}
}
}
}
}
$tmpfname = "$vcxfiltersfname.tmp";
open $fh, '>', $tmpfname or die("Failed to open '$tmpfname': $!\n");
$added = 0;
$vcxgroup_state = 0;
$prevname = undef;
$lineno = 0;
foreach (@vcxfilters) {
$lineno++;
# We cheat here, because these lines are unique, we don't have to fully parse this file.
if ($vcxgroup_state == 0) {
if (/\A \<Filter Include\="(.*?)"\>\Z/) {
if ($newgrptext ne '') {
$vcxgroup_state = 1;
$prevname = undef;
}
} elsif (/\A \<ClInclude .*\Z/) {
if ($isheader) {
$vcxgroup_state = 2;
$prevname = undef;
}
} elsif (/\A \<ClCompile .*\Z/) {
if (not $isheader) {
$vcxgroup_state = 3;
$prevname = undef;
}
}
}
# Don't do elsif, we need to check this line again.
if ($vcxgroup_state == 1) {
if (/\A \<\/ItemGroup\>\Z/) {
print $fh $newgrptext;
$newgrptext = '';
$vcxgroup_state = 0;
}
} elsif ($vcxgroup_state == 2) {
if (/\A <ClInclude Include="(.*?)"/) {
my $nextname = $1;
if ((not $added) && (((not defined $prevname) || (uc($prevname) lt uc($addvcxpath))) && (uc($nextname) gt uc($addvcxpath)))) {
print $fh " <ClInclude Include=\"$addvcxpath\"";
if ($filter ne '') {
print $fh ">\n";
print $fh " <Filter>$filter</Filter>\n";
print $fh " </ClInclude>\n";
} else {
print $fh " />\n";
}
$added = 1;
}
$prevname = $nextname;
} elsif (/\A \<\/ItemGroup\>\Z/) {
if ((not $added) && ((not defined $prevname) || (uc($prevname) lt uc($addvcxpath)))) {
print $fh " <ClInclude Include=\"$addvcxpath\"";
if ($filter ne '') {
print $fh ">\n";
print $fh " <Filter>$filter</Filter>\n";
print $fh " </ClInclude>\n";
} else {
print $fh " />\n";
}
$added = 1;
}
$vcxgroup_state = 0;
}
} elsif ($vcxgroup_state == 3) {
if (/\A <ClCompile Include="(.*?)"/) {
my $nextname = $1;
if ((not $added) && (((not defined $prevname) || (uc($prevname) lt uc($addvcxpath))) && (uc($nextname) gt uc($addvcxpath)))) {
print $fh " <ClCompile Include=\"$addvcxpath\"";
if ($filter ne '') {
print $fh ">\n";
print $fh " <Filter>$filter</Filter>\n";
print $fh " </ClCompile>\n";
} else {
print $fh " />\n";
}
$added = 1;
}
$prevname = $nextname;
} elsif (/\A \<\/ItemGroup\>\Z/) {
if ((not $added) && ((not defined $prevname) || (uc($prevname) lt uc($addvcxpath)))) {
print $fh " <ClCompile Include=\"$addvcxpath\"";
if ($filter ne '') {
print $fh ">\n";
print $fh " <Filter>$filter</Filter>\n";
print $fh " </ClCompile>\n";
} else {
print $fh " />\n";
}
$added = 1;
}
$vcxgroup_state = 0;
}
}
print $fh "$_\n";
}
close($fh);
rename($tmpfname, $vcxfiltersfname);
}
# Mainline!
chdir(dirname($0)); # assumed to be in build-scripts
chdir('..'); # head to root of source tree.
foreach (@ARGV) {
s/\A\.\///; # Turn "./path/to/file.txt" into "path/to/file.txt"
my $arg = $_;
process_xcode($arg, 'Xcode/SDL/SDL.xcodeproj/project.pbxproj');
process_visualstudio($arg, 'VisualC/SDL/SDL.vcxproj');
process_visualstudio($arg, 'VisualC-GDK/SDL/SDL.vcxproj');
process_visualstudio($arg, 'VisualC-WinRT/SDL-UWP.vcxproj');
}
print("Done. Please run `git diff` and make sure this looks okay!\n");
exit(0);

View File

@ -41,23 +41,28 @@ gcc -o genfilter build-scripts/gen_audio_resampler_filter.c -lm && ./genfilter >
#include <stdio.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define RESAMPLER_ZERO_CROSSINGS 5
#define RESAMPLER_BITS_PER_SAMPLE 16
#define RESAMPLER_SAMPLES_PER_ZERO_CROSSING (1 << ((RESAMPLER_BITS_PER_SAMPLE / 2) + 1))
#define RESAMPLER_FILTER_SIZE ((RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS) + 1)
#define RESAMPLER_BITS_PER_ZERO_CROSSING ((RESAMPLER_BITS_PER_SAMPLE / 2) + 1)
#define RESAMPLER_SAMPLES_PER_ZERO_CROSSING (1 << RESAMPLER_BITS_PER_ZERO_CROSSING)
#define RESAMPLER_FILTER_SIZE (RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS)
/* This is a "modified" bessel function, so you can't use POSIX j0() */
static double
bessel(const double x)
{
const double xdiv2 = x / 2.0;
double i0 = 1.0f;
double f = 1.0f;
double i0 = 1.0;
double f = 1.0;
int i = 1;
while (1) {
const double diff = pow(xdiv2, i * 2) / pow(f, 2);
if (diff < 1.0e-21f) {
if (diff < 1.0e-21) {
break;
}
i0 += diff;
@ -70,30 +75,21 @@ bessel(const double x)
/* build kaiser table with cardinal sine applied to it, and array of differences between elements. */
static void
kaiser_and_sinc(float *table, float *diffs, const int tablelen, const double beta)
kaiser_and_sinc(double *table, const int tablelen, const double beta)
{
const int lenm1 = tablelen - 1;
const int lenm1div2 = lenm1 / 2;
const double bessel_beta = bessel(beta);
int i;
table[0] = 1.0f;
for (i = 1; i < tablelen; i++) {
const double kaiser = bessel(beta * sqrt(1.0 - pow(((i - lenm1) / 2.0) / lenm1div2, 2.0))) / bessel_beta;
table[tablelen - i] = (float) kaiser;
}
table[0] = 1.0;
for (i = 1; i < tablelen; i++) {
const float x = (((float) i) / ((float) RESAMPLER_SAMPLES_PER_ZERO_CROSSING)) * ((float) M_PI);
table[i] *= sinf(x) / x;
diffs[i - 1] = table[i] - table[i - 1];
const double kaiser = bessel(beta * sqrt(1.0 - pow((double)i / (double)(tablelen), 2.0))) / bessel_beta;
const double x = (((double) i) / ((double) RESAMPLER_SAMPLES_PER_ZERO_CROSSING)) * M_PI;
table[i] = kaiser * (sin(x) / x);
}
diffs[lenm1] = 0.0f;
}
static float ResamplerFilter[RESAMPLER_FILTER_SIZE];
static float ResamplerFilterDifference[RESAMPLER_FILTER_SIZE];
static double ResamplerFilter[RESAMPLER_FILTER_SIZE];
static void
PrepareResampleFilter(void)
@ -101,12 +97,12 @@ PrepareResampleFilter(void)
/* if dB > 50, beta=(0.1102 * (dB - 8.7)), according to Matlab. */
const double dB = 80.0;
const double beta = 0.1102 * (dB - 8.7);
kaiser_and_sinc(ResamplerFilter, ResamplerFilterDifference, RESAMPLER_FILTER_SIZE, beta);
kaiser_and_sinc(ResamplerFilter, RESAMPLER_FILTER_SIZE, beta);
}
int main(void)
{
int i;
int i, j;
PrepareResampleFilter();
@ -136,22 +132,16 @@ int main(void)
"\n"
"#define RESAMPLER_ZERO_CROSSINGS %d\n"
"#define RESAMPLER_BITS_PER_SAMPLE %d\n"
"#define RESAMPLER_SAMPLES_PER_ZERO_CROSSING (1 << ((RESAMPLER_BITS_PER_SAMPLE / 2) + 1))\n"
"#define RESAMPLER_FILTER_SIZE ((RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS) + 1)\n"
"#define RESAMPLER_BITS_PER_ZERO_CROSSING ((RESAMPLER_BITS_PER_SAMPLE / 2) + 1)\n"
"#define RESAMPLER_SAMPLES_PER_ZERO_CROSSING (1 << RESAMPLER_BITS_PER_ZERO_CROSSING)\n"
"#define RESAMPLER_FILTER_SIZE (RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS)\n"
"\n", RESAMPLER_ZERO_CROSSINGS, RESAMPLER_BITS_PER_SAMPLE
);
printf("static const float ResamplerFilter[RESAMPLER_FILTER_SIZE] = {\n");
printf(" %.9ff", ResamplerFilter[0]);
for (i = 0; i < RESAMPLER_FILTER_SIZE-1; i++) {
printf("%s%.9ff", ((i % 5) == 4) ? ",\n " : ", ", ResamplerFilter[i+1]);
}
printf("\n};\n\n");
printf("static const float ResamplerFilterDifference[RESAMPLER_FILTER_SIZE] = {\n");
printf(" %.9ff", ResamplerFilterDifference[0]);
for (i = 0; i < RESAMPLER_FILTER_SIZE-1; i++) {
printf("%s%.9ff", ((i % 5) == 4) ? ",\n " : ", ", ResamplerFilterDifference[i+1]);
printf("static const float ResamplerFilter[RESAMPLER_FILTER_SIZE] = {");
for (i = 0; i < RESAMPLER_FILTER_SIZE; i++) {
j = (i % RESAMPLER_ZERO_CROSSINGS) * RESAMPLER_SAMPLES_PER_ZERO_CROSSING + (i / RESAMPLER_ZERO_CROSSINGS);
printf("%s%12.9ff,", (i % RESAMPLER_ZERO_CROSSINGS) ? "" : "\n ", ResamplerFilter[j]);
}
printf("\n};\n\n");

View File

@ -31,6 +31,7 @@ my $optionsfname = undef;
my $wikipreamble = undef;
my $changeformat = undef;
my $manpath = undef;
my $gitrev = undef;
foreach (@ARGV) {
$warn_about_missing = 1, next if $_ eq '--warn-about-missing';
@ -47,6 +48,9 @@ foreach (@ARGV) {
} elsif (/\A--manpath=(.*)\Z/) {
$manpath = $1;
next;
} elsif (/\A--rev=(.*)\Z/) {
$gitrev = $1;
next;
}
$srcpath = $_, next if not defined $srcpath;
$wikipath = $_, next if not defined $wikipath;
@ -788,6 +792,45 @@ while (my $d = readdir(DH)) {
}
closedir(DH);
delete $wikifuncs{"Undocumented"};
{
my $path = "$wikipath/Undocumented.md";
open(FH, '>', $path) or die("Can't open '$path': $!\n");
print FH "# Undocumented\n\n";
print FH "## Functions defined in the headers, but not in the wiki\n\n";
my $header_only_func = 0;
foreach (sort keys %headerfuncs) {
my $fn = $_;
if (not defined $wikifuncs{$fn}) {
print FH "- [$fn]($fn)\n";
$header_only_func = 1;
}
}
if (!$header_only_func) {
print FH "(none)\n";
}
print FH "\n";
print FH "## Functions defined in the wiki, but not in the headers\n\n";
my $wiki_only_func = 0;
foreach (sort keys %wikifuncs) {
my $fn = $_;
if (not defined $headerfuncs{$fn}) {
print FH "- [$fn]($fn)\n";
$wiki_only_func = 1;
}
}
if (!$wiki_only_func) {
print FH "(none)\n";
}
print FH "\n";
close(FH);
}
if ($warn_about_missing) {
foreach (keys %wikifuncs) {
@ -1437,8 +1480,10 @@ if ($copy_direction == 1) { # --copy-to-headers
close(FH);
}
my $gitrev = `cd "$srcpath" ; git rev-list HEAD~..`;
chomp($gitrev);
if (!$gitrev) {
$gitrev = `cd "$srcpath" ; git rev-list HEAD~..`;
chomp($gitrev);
}
# !!! FIXME
open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n");