comparison src/audio/sdlgenaudiocvt.pl @ 3019:dfd23eb79be9

Allow builds that reduce or eliminate the converters/resamplers. We should probably give options to drop resamplers by channels, too, for developers that know they'll never need more than stereo, etc.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 11 Jan 2009 04:39:09 +0000
parents 786a48f8309c
children 70d876a0b90e
comparison
equal deleted inserted replaced
3018:d706d3170d7d 3019:dfd23eb79be9
59 */ 59 */
60 60
61 #include "SDL_config.h" 61 #include "SDL_config.h"
62 #include "SDL_audio.h" 62 #include "SDL_audio.h"
63 #include "SDL_audio_c.h" 63 #include "SDL_audio_c.h"
64
65 #ifndef DEBUG_CONVERT
66 #define DEBUG_CONVERT 0
67 #endif
68
69
70 /* If you can guarantee your data and need space, you can eliminate code... */
71
72 /* Just build the arbitrary resamplers if you're saving code space. */
73 #ifndef LESS_RESAMPLERS
74 #define LESS_RESAMPLERS 0
75 #endif
76
77 /* Don't build any resamplers if you're REALLY saving code space. */
78 #ifndef NO_RESAMPLERS
79 #define NO_RESAMPLERS 0
80 #endif
81
82 /* Don't build any type converters if you're saving code space. */
83 #ifndef NO_CONVERTERS
84 #define NO_CONVERTERS 0
85 #endif
86
64 87
65 /* *INDENT-OFF* */ 88 /* *INDENT-OFF* */
66 89
67 EOF 90 EOF
68 91
288 } 311 }
289 } 312 }
290 313
291 314
292 sub buildTypeConverters { 315 sub buildTypeConverters {
316 print "#if !NO_CONVERTERS\n\n";
293 foreach (@audiotypes) { 317 foreach (@audiotypes) {
294 my $from = $_; 318 my $from = $_;
295 foreach (@audiotypes) { 319 foreach (@audiotypes) {
296 my $to = $_; 320 my $to = $_;
297 buildCvtFunc($from, $to); 321 buildCvtFunc($from, $to);
298 } 322 }
299 } 323 }
324 print "#endif /* !NO_CONVERTERS */\n\n\n";
300 325
301 print "const SDL_AudioTypeFilters sdl_audio_type_filters[] =\n{\n"; 326 print "const SDL_AudioTypeFilters sdl_audio_type_filters[] =\n{\n";
327 print "#if !NO_CONVERTERS\n";
302 foreach (@audiotypes) { 328 foreach (@audiotypes) {
303 my $from = $_; 329 my $from = $_;
304 foreach (@audiotypes) { 330 foreach (@audiotypes) {
305 my $to = $_; 331 my $to = $_;
306 if ($from ne $to) { 332 if ($from ne $to) {
308 my $sym = $funcs{$hashid}; 334 my $sym = $funcs{$hashid};
309 print(" { AUDIO_$from, AUDIO_$to, $sym },\n"); 335 print(" { AUDIO_$from, AUDIO_$to, $sym },\n");
310 } 336 }
311 } 337 }
312 } 338 }
339 print "#endif /* !NO_CONVERTERS */\n";
313 340
314 print "};\n\n\n"; 341 print "};\n\n\n";
315 } 342 }
316 343
317 sub getBiggerCtype { 344 sub getBiggerCtype {
650 EOF 677 EOF
651 678
652 } 679 }
653 680
654 sub buildResamplers { 681 sub buildResamplers {
682 print "#if !NO_RESAMPLERS\n\n";
683 foreach (@audiotypes) {
684 my $from = $_;
685 foreach (@channels) {
686 my $channel = $_;
687 buildArbitraryResampleFunc($from, $channel, 1);
688 buildArbitraryResampleFunc($from, $channel, 0);
689 }
690 }
691
692 print "\n#if !LESS_RESAMPLERS\n\n";
655 foreach (@audiotypes) { 693 foreach (@audiotypes) {
656 my $from = $_; 694 my $from = $_;
657 foreach (@channels) { 695 foreach (@channels) {
658 my $channel = $_; 696 my $channel = $_;
659 for (my $multiple = 2; $multiple <= 4; $multiple += 2) { 697 for (my $multiple = 2; $multiple <= 4; $multiple += 2) {
660 buildMultipleResampleFunc($from, $channel, 1, $multiple); 698 buildMultipleResampleFunc($from, $channel, 1, $multiple);
661 buildMultipleResampleFunc($from, $channel, 0, $multiple); 699 buildMultipleResampleFunc($from, $channel, 0, $multiple);
662 } 700 }
663 buildArbitraryResampleFunc($from, $channel, 1); 701 }
664 buildArbitraryResampleFunc($from, $channel, 0); 702 }
665 } 703
666 } 704 print "#endif /* !LESS_RESAMPLERS */\n";
705 print "#endif /* !NO_RESAMPLERS */\n\n\n";
667 706
668 print "const SDL_AudioRateFilters sdl_audio_rate_filters[] =\n{\n"; 707 print "const SDL_AudioRateFilters sdl_audio_rate_filters[] =\n{\n";
708 print "#if !NO_RESAMPLERS\n";
669 foreach (@audiotypes) { 709 foreach (@audiotypes) {
670 my $from = $_; 710 my $from = $_;
671 foreach (@channels) { 711 foreach (@channels) {
672 my $channel = $_; 712 my $channel = $_;
673 for (my $multiple = 0; $multiple <= 4; $multiple += 2) { 713 for (my $upsample = 0; $upsample <= 1; $upsample++) {
714 my $hashid = getResamplerHashId($from, $channel, $upsample, 0);
715 my $sym = $funcs{$hashid};
716 print(" { AUDIO_$from, $channel, $upsample, 0, $sym },\n");
717 }
718 }
719 }
720
721 print "#if !LESS_RESAMPLERS\n";
722 foreach (@audiotypes) {
723 my $from = $_;
724 foreach (@channels) {
725 my $channel = $_;
726 for (my $multiple = 2; $multiple <= 4; $multiple += 2) {
674 for (my $upsample = 0; $upsample <= 1; $upsample++) { 727 for (my $upsample = 0; $upsample <= 1; $upsample++) {
675 my $hashid = getResamplerHashId($from, $channel, $upsample, $multiple); 728 my $hashid = getResamplerHashId($from, $channel, $upsample, $multiple);
676 my $sym = $funcs{$hashid}; 729 my $sym = $funcs{$hashid};
677 print(" { AUDIO_$from, $channel, $upsample, $multiple, $sym },\n"); 730 print(" { AUDIO_$from, $channel, $upsample, $multiple, $sym },\n");
678 } 731 }
679 } 732 }
680 } 733 }
681 } 734 }
682 735
736 print "#endif /* !LESS_RESAMPLERS */\n";
737 print "#endif /* !NO_RESAMPLERS */\n";
683 print "};\n\n"; 738 print "};\n\n";
684 } 739 }
685 740
686 741
687 # mainline ... 742 # mainline ...