+ else if(!strcmp(name, "s")) {
+ samplerate = atoi(val);
+ if(samplerate > 5000 && samplerate < 6000)
+ samplerate = 5512;
+ else if(samplerate > 11000 && samplerate < 12000)
+ samplerate = 11025;
+ else if(samplerate > 22000 && samplerate < 23000)
+ samplerate = 22050;
+ else if(samplerate > 44000 && samplerate < 45000)
+ samplerate = 44100;
+ else {
+ fprintf(stderr, "Invalid samplerate: %d\n", samplerate);
+ fprintf(stderr, "Allowed values: 11025, 22050, 44100\n", samplerate);
+ exit(1);
+ }
+ return 1;
+ }
+ else if(!strcmp(name, "b")) {
+ int t;
+ int b = atoi(val);
+ if(b<=0) {
+ fprintf(stderr, "Not a valid bitrate: %s\n", val);
+ exit(1);
+ }
+ if(b>160) {
+ fprintf(stderr, "Bitrate must be <144. (%s)\n", val);
+ exit(1);
+ }
+ for(t=0;mp3_bitrates[t];t++) {
+ if(b== mp3_bitrates[t]) {
+ bitrate = b;
+ return 1;
+ }
+ }
+ fprintf(stderr, "Invalid bitrate. Allowed bitrates are:\n");
+ for(t=0;mp3_bitrates[t];t++) {
+ printf("%d ", mp3_bitrates[t]);
+ }
+ printf("\n");
+ exit(1);
+ }