src/audio/sdlgenaudiocvt.pl
changeset 3019 dfd23eb79be9
parent 3008 786a48f8309c
child 3020 70d876a0b90e
     1.1 --- a/src/audio/sdlgenaudiocvt.pl	Sun Jan 11 04:29:36 2009 +0000
     1.2 +++ b/src/audio/sdlgenaudiocvt.pl	Sun Jan 11 04:39:09 2009 +0000
     1.3 @@ -62,6 +62,29 @@
     1.4  #include "SDL_audio.h"
     1.5  #include "SDL_audio_c.h"
     1.6  
     1.7 +#ifndef DEBUG_CONVERT
     1.8 +#define DEBUG_CONVERT 0
     1.9 +#endif
    1.10 +
    1.11 +
    1.12 +/* If you can guarantee your data and need space, you can eliminate code... */
    1.13 +
    1.14 +/* Just build the arbitrary resamplers if you're saving code space. */
    1.15 +#ifndef LESS_RESAMPLERS
    1.16 +#define LESS_RESAMPLERS 0
    1.17 +#endif
    1.18 +
    1.19 +/* Don't build any resamplers if you're REALLY saving code space. */
    1.20 +#ifndef NO_RESAMPLERS
    1.21 +#define NO_RESAMPLERS 0
    1.22 +#endif
    1.23 +
    1.24 +/* Don't build any type converters if you're saving code space. */
    1.25 +#ifndef NO_CONVERTERS
    1.26 +#define NO_CONVERTERS 0
    1.27 +#endif
    1.28 +
    1.29 +
    1.30  /* *INDENT-OFF* */
    1.31  
    1.32  EOF
    1.33 @@ -290,6 +313,7 @@
    1.34  
    1.35  
    1.36  sub buildTypeConverters {
    1.37 +    print "#if !NO_CONVERTERS\n\n";
    1.38      foreach (@audiotypes) {
    1.39          my $from = $_;
    1.40          foreach (@audiotypes) {
    1.41 @@ -297,8 +321,10 @@
    1.42              buildCvtFunc($from, $to);
    1.43          }
    1.44      }
    1.45 +    print "#endif  /* !NO_CONVERTERS */\n\n\n";
    1.46  
    1.47      print "const SDL_AudioTypeFilters sdl_audio_type_filters[] =\n{\n";
    1.48 +    print "#if !NO_CONVERTERS\n";
    1.49      foreach (@audiotypes) {
    1.50          my $from = $_;
    1.51          foreach (@audiotypes) {
    1.52 @@ -310,6 +336,7 @@
    1.53              }
    1.54          }
    1.55      }
    1.56 +    print "#endif  /* !NO_CONVERTERS */\n";
    1.57  
    1.58      print "};\n\n\n";
    1.59  }
    1.60 @@ -652,6 +679,17 @@
    1.61  }
    1.62  
    1.63  sub buildResamplers {
    1.64 +    print "#if !NO_RESAMPLERS\n\n";
    1.65 +    foreach (@audiotypes) {
    1.66 +        my $from = $_;
    1.67 +        foreach (@channels) {
    1.68 +            my $channel = $_;
    1.69 +            buildArbitraryResampleFunc($from, $channel, 1);
    1.70 +            buildArbitraryResampleFunc($from, $channel, 0);
    1.71 +        }
    1.72 +    }
    1.73 +
    1.74 +    print "\n#if !LESS_RESAMPLERS\n\n";
    1.75      foreach (@audiotypes) {
    1.76          my $from = $_;
    1.77          foreach (@channels) {
    1.78 @@ -660,17 +698,32 @@
    1.79                  buildMultipleResampleFunc($from, $channel, 1, $multiple);
    1.80                  buildMultipleResampleFunc($from, $channel, 0, $multiple);
    1.81              }
    1.82 -            buildArbitraryResampleFunc($from, $channel, 1);
    1.83 -            buildArbitraryResampleFunc($from, $channel, 0);
    1.84          }
    1.85      }
    1.86  
    1.87 +    print "#endif  /* !LESS_RESAMPLERS */\n";
    1.88 +    print "#endif  /* !NO_RESAMPLERS */\n\n\n";
    1.89 +
    1.90      print "const SDL_AudioRateFilters sdl_audio_rate_filters[] =\n{\n";
    1.91 +    print "#if !NO_RESAMPLERS\n";
    1.92      foreach (@audiotypes) {
    1.93          my $from = $_;
    1.94          foreach (@channels) {
    1.95              my $channel = $_;
    1.96 -            for (my $multiple = 0; $multiple <= 4; $multiple += 2) {
    1.97 +            for (my $upsample = 0; $upsample <= 1; $upsample++) {
    1.98 +                my $hashid = getResamplerHashId($from, $channel, $upsample, 0);
    1.99 +                my $sym = $funcs{$hashid};
   1.100 +                print("    { AUDIO_$from, $channel, $upsample, 0, $sym },\n");
   1.101 +            }
   1.102 +        }
   1.103 +    }
   1.104 +
   1.105 +    print "#if !LESS_RESAMPLERS\n";
   1.106 +    foreach (@audiotypes) {
   1.107 +        my $from = $_;
   1.108 +        foreach (@channels) {
   1.109 +            my $channel = $_;
   1.110 +            for (my $multiple = 2; $multiple <= 4; $multiple += 2) {
   1.111                  for (my $upsample = 0; $upsample <= 1; $upsample++) {
   1.112                      my $hashid = getResamplerHashId($from, $channel, $upsample, $multiple);
   1.113                      my $sym = $funcs{$hashid};
   1.114 @@ -680,6 +733,8 @@
   1.115          }
   1.116      }
   1.117  
   1.118 +    print "#endif  /* !LESS_RESAMPLERS */\n";
   1.119 +    print "#endif  /* !NO_RESAMPLERS */\n";
   1.120      print "};\n\n";
   1.121  }
   1.122