1 /* flac - Command-line FLAC encoder/decoder
2 * Copyright (C) 2000,2001 Josh Coalson
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 static int usage(const char *message, ...);
30 static int encode_file(const char *infilename, const char *forced_outfilename);
31 static int decode_file(const char *infilename, const char *forced_outfilename);
33 bool verify = false, verbose = true, lax = false, test_only = false, analyze = false;
34 bool do_mid_side = true, loose_mid_side = false, do_exhaustive_model_search = false, do_qlp_coeff_prec_search = false;
35 bool force_to_stdout = false;
36 analysis_options aopts = { false, false };
38 unsigned max_lpc_order = 8;
39 unsigned qlp_coeff_precision = 0;
41 int format_is_wave = -1, format_is_big_endian = -1, format_is_unsigned_samples = false;
42 int format_channels = -1, format_bps = -1, format_sample_rate = -1;
43 int blocksize = -1, min_residual_partition_order = -1, max_residual_partition_order = -1, rice_parameter_search_dist = -1;
44 char requested_seek_points[50000]; /* @@@ bad MAGIC NUMBER */
45 int num_requested_seek_points = -1; /* -1 => no -S options were given, 0 => -S- was given */
47 int main(int argc, char *argv[])
50 bool mode_decode = false;
56 for(i = 1; i < argc; i++) {
57 if(argv[i][0] != '-' || argv[i][1] == 0)
59 if(0 == strcmp(argv[i], "-d"))
61 else if(0 == strcmp(argv[i], "-a")) {
65 else if(0 == strcmp(argv[i], "-t")) {
69 else if(0 == strcmp(argv[i], "-c"))
70 force_to_stdout = true;
71 else if(0 == strcmp(argv[i], "-s"))
73 else if(0 == strcmp(argv[i], "-s-"))
75 else if(0 == strcmp(argv[i], "-S")) {
76 if(num_requested_seek_points < 0)
77 num_requested_seek_points = 0;
78 num_requested_seek_points++;
79 strcat(requested_seek_points, argv[++i]);
80 strcat(requested_seek_points, "<");
82 else if(0 == strcmp(argv[i], "-S-")) {
83 num_requested_seek_points = 0;
84 requested_seek_points[0] = '\0';
86 else if(0 == strcmp(argv[i], "--skip"))
87 skip = (uint64)atoi(argv[++i]); /* @@@ takes a pretty damn big file to overflow atoi() here, but it could happen */
88 else if(0 == strcmp(argv[i], "--lax"))
90 else if(0 == strcmp(argv[i], "--lax-"))
92 else if(0 == strcmp(argv[i], "-b"))
93 blocksize = atoi(argv[++i]);
94 else if(0 == strcmp(argv[i], "-e"))
95 do_exhaustive_model_search = true;
96 else if(0 == strcmp(argv[i], "-e-"))
97 do_exhaustive_model_search = false;
98 else if(0 == strcmp(argv[i], "-l"))
99 max_lpc_order = atoi(argv[++i]);
100 else if(0 == strcmp(argv[i], "-m")) {
102 loose_mid_side = false;
104 else if(0 == strcmp(argv[i], "-m-"))
105 do_mid_side = loose_mid_side = false;
106 else if(0 == strcmp(argv[i], "-M"))
107 loose_mid_side = do_mid_side = true;
108 else if(0 == strcmp(argv[i], "-M-"))
109 loose_mid_side = do_mid_side = false;
110 else if(0 == strcmp(argv[i], "-p"))
111 do_qlp_coeff_prec_search = true;
112 else if(0 == strcmp(argv[i], "-p-"))
113 do_qlp_coeff_prec_search = false;
114 else if(0 == strcmp(argv[i], "-P"))
115 padding = atoi(argv[++i]);
116 else if(0 == strcmp(argv[i], "-q"))
117 qlp_coeff_precision = atoi(argv[++i]);
118 else if(0 == strcmp(argv[i], "-r")) {
119 char *p = strchr(argv[++i], ',');
121 min_residual_partition_order = 0;
122 max_residual_partition_order = atoi(argv[i]);
125 min_residual_partition_order = atoi(argv[i]);
126 max_residual_partition_order = atoi(++p);
129 else if(0 == strcmp(argv[i], "-R"))
130 rice_parameter_search_dist = atoi(argv[++i]);
131 else if(0 == strcmp(argv[i], "-V"))
133 else if(0 == strcmp(argv[i], "-V-"))
135 else if(0 == strcmp(argv[i], "-fb"))
136 format_is_big_endian = true;
137 else if(0 == strcmp(argv[i], "-fl"))
138 format_is_big_endian = false;
139 else if(0 == strcmp(argv[i], "-fc"))
140 format_channels = atoi(argv[++i]);
141 else if(0 == strcmp(argv[i], "-fp"))
142 format_bps = atoi(argv[++i]);
143 else if(0 == strcmp(argv[i], "-fs"))
144 format_sample_rate = atoi(argv[++i]);
145 else if(0 == strcmp(argv[i], "-fu"))
146 format_is_unsigned_samples = true;
147 else if(0 == strcmp(argv[i], "-fr"))
148 format_is_wave = false;
149 else if(0 == strcmp(argv[i], "-fw"))
150 format_is_wave = true;
151 else if(0 == strcmp(argv[i], "--a-rgp"))
152 aopts.do_residual_gnuplot = true;
153 else if(0 == strcmp(argv[i], "--a-rgp-"))
154 aopts.do_residual_gnuplot = false;
155 else if(0 == strcmp(argv[i], "--a-rtext"))
156 aopts.do_residual_text = true;
157 else if(0 == strcmp(argv[i], "--a-rtext-"))
158 aopts.do_residual_text = false;
159 else if(0 == strcmp(argv[i], "-0")) {
160 do_exhaustive_model_search = false;
162 loose_mid_side = false;
163 qlp_coeff_precision = 0;
164 min_residual_partition_order = max_residual_partition_order = 0;
165 rice_parameter_search_dist = 0;
168 else if(0 == strcmp(argv[i], "-1")) {
169 do_exhaustive_model_search = false;
171 loose_mid_side = true;
172 qlp_coeff_precision = 0;
173 min_residual_partition_order = max_residual_partition_order = 2;
174 rice_parameter_search_dist = 0;
177 else if(0 == strcmp(argv[i], "-2")) {
178 do_exhaustive_model_search = false;
180 loose_mid_side = false;
181 qlp_coeff_precision = 0;
182 min_residual_partition_order = 0;
183 max_residual_partition_order = 3;
184 rice_parameter_search_dist = 0;
187 else if(0 == strcmp(argv[i], "-3")) {
188 do_exhaustive_model_search = false;
190 loose_mid_side = false;
191 qlp_coeff_precision = 0;
192 min_residual_partition_order = max_residual_partition_order = 3;
193 rice_parameter_search_dist = 0;
196 else if(0 == strcmp(argv[i], "-4")) {
197 do_exhaustive_model_search = false;
199 loose_mid_side = true;
200 qlp_coeff_precision = 0;
201 min_residual_partition_order = max_residual_partition_order = 3;
202 rice_parameter_search_dist = 0;
205 else if(0 == strcmp(argv[i], "-5")) {
206 do_exhaustive_model_search = false;
208 loose_mid_side = false;
209 qlp_coeff_precision = 0;
210 min_residual_partition_order = max_residual_partition_order = 3;
211 rice_parameter_search_dist = 0;
214 else if(0 == strcmp(argv[i], "-6")) {
215 do_exhaustive_model_search = false;
217 loose_mid_side = false;
218 qlp_coeff_precision = 0;
219 min_residual_partition_order = 0;
220 max_residual_partition_order = 4;
221 rice_parameter_search_dist = 0;
224 else if(0 == strcmp(argv[i], "-7")) {
225 do_exhaustive_model_search = true;
227 loose_mid_side = false;
228 qlp_coeff_precision = 0;
229 min_residual_partition_order = 0;
230 max_residual_partition_order = 6;
231 rice_parameter_search_dist = 0;
234 else if(0 == strcmp(argv[i], "-8")) {
235 do_exhaustive_model_search = true;
237 loose_mid_side = false;
238 qlp_coeff_precision = 0;
239 min_residual_partition_order = 0;
240 max_residual_partition_order = 6;
241 rice_parameter_search_dist = 0;
244 else if(0 == strcmp(argv[i], "-9")) {
245 do_exhaustive_model_search = true;
247 loose_mid_side = false;
248 do_qlp_coeff_prec_search = true;
249 min_residual_partition_order = 0;
250 max_residual_partition_order = 16;
251 rice_parameter_search_dist = 32;
254 else if(isdigit((int)(argv[i][1]))) {
255 return usage("ERROR: compression level '%s' is still reserved\n", argv[i]);
258 return usage("ERROR: invalid option '%s'\n", argv[i]);
262 /* tweak options; validate the values */
265 if(max_lpc_order == 0)
270 if(max_residual_partition_order < 0) {
271 if(blocksize <= 1152)
272 max_residual_partition_order = 2;
273 else if(blocksize <= 2304)
274 max_residual_partition_order = 3;
275 else if(blocksize <= 4608)
276 max_residual_partition_order = 3;
278 max_residual_partition_order = 4;
279 min_residual_partition_order = max_residual_partition_order;
281 if(rice_parameter_search_dist < 0) {
282 rice_parameter_search_dist = 0;
288 return usage("ERROR: --skip is not allowed in test mode\n");
292 FLAC__ASSERT(blocksize >= 0 || mode_decode);
294 if(format_channels >= 0) {
295 if(format_channels == 0 || (unsigned)format_channels > FLAC__MAX_CHANNELS)
296 return usage("ERROR: invalid number of channels '%u', must be > 0 and <= %u\n", format_channels, FLAC__MAX_CHANNELS);
298 if(format_bps >= 0) {
299 if(format_bps != 8 && format_bps != 16 && format_bps != 24)
300 return usage("ERROR: invalid bits per sample '%u' (must be 8/16/24)\n", format_bps);
302 if(format_sample_rate >= 0) {
303 if(format_sample_rate == 0 || (unsigned)format_sample_rate > FLAC__MAX_SAMPLE_RATE)
304 return usage("ERROR: invalid sample rate '%u', must be > 0 and <= %u\n", format_sample_rate, FLAC__MAX_SAMPLE_RATE);
306 if(!mode_decode && ((unsigned)blocksize < FLAC__MIN_BLOCK_SIZE || (unsigned)blocksize > FLAC__MAX_BLOCK_SIZE)) {
307 return usage("ERROR: invalid blocksize '%u', must be >= %u and <= %u\n", (unsigned)blocksize, FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE);
309 if(qlp_coeff_precision > 0 && qlp_coeff_precision < FLAC__MIN_QLP_COEFF_PRECISION) {
310 return usage("ERROR: invalid value for -q '%u', must be 0 or >= %u\n", qlp_coeff_precision, FLAC__MIN_QLP_COEFF_PRECISION);
314 fprintf(stderr, "\n");
315 fprintf(stderr, "flac %s, Copyright (C) 2000,2001 Josh Coalson\n", FLAC__VERSION_STRING);
316 fprintf(stderr, "flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are\n");
317 fprintf(stderr, "welcome to redistribute it under certain conditions. Type `flac' for details.\n\n");
320 fprintf(stderr, "options:%s -P %u -b %u%s -l %u%s%s -q %u -r %u,%u -R %u%s\n",
321 lax?" --lax":"", padding, (unsigned)blocksize, loose_mid_side?" -M":do_mid_side?" -m":"", max_lpc_order,
322 do_exhaustive_model_search?" -e":"", do_qlp_coeff_prec_search?" -p":"",
324 (unsigned)min_residual_partition_order, (unsigned)max_residual_partition_order, (unsigned)rice_parameter_search_dist,
335 retval = decode_file("-", 0);
336 else if(i + 2 == argc && 0 == strcmp(argv[i], "-"))
337 retval = decode_file("-", argv[i+1]);
339 for(retval = 0; i < argc && retval == 0; i++) {
340 if(0 == strcmp(argv[i], "-") && !first)
342 save_format = format_is_wave;
343 retval = decode_file(argv[i], 0);
344 format_is_wave = save_format;
354 retval = encode_file("-", 0);
355 else if(i + 2 == argc && 0 == strcmp(argv[i], "-"))
356 retval = encode_file("-", argv[i+1]);
358 for(retval = 0; i < argc && retval == 0; i++) {
359 if(0 == strcmp(argv[i], "-") && !first)
361 save_format = format_is_wave;
362 retval = encode_file(argv[i], 0);
363 format_is_wave = save_format;
372 int usage(const char *message, ...)
377 va_start(args, message);
379 (void) vfprintf(stderr, message, args);
384 fprintf(stderr, "===============================================================================\n");
385 fprintf(stderr, "flac - Command-line FLAC encoder/decoder version %s\n", FLAC__VERSION_STRING);
386 fprintf(stderr, "Copyright (C) 2000,2001 Josh Coalson\n");
387 fprintf(stderr, "\n");
388 fprintf(stderr, "This program is free software; you can redistribute it and/or\n");
389 fprintf(stderr, "modify it under the terms of the GNU General Public License\n");
390 fprintf(stderr, "as published by the Free Software Foundation; either version 2\n");
391 fprintf(stderr, "of the License, or (at your option) any later version.\n");
392 fprintf(stderr, "\n");
393 fprintf(stderr, "This program is distributed in the hope that it will be useful,\n");
394 fprintf(stderr, "but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
395 fprintf(stderr, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
396 fprintf(stderr, "GNU General Public License for more details.\n");
397 fprintf(stderr, "\n");
398 fprintf(stderr, "You should have received a copy of the GNU General Public License\n");
399 fprintf(stderr, "along with this program; if not, write to the Free Software\n");
400 fprintf(stderr, "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n");
401 fprintf(stderr, "===============================================================================\n");
402 fprintf(stderr, "Usage:\n");
403 fprintf(stderr, " flac [options] [infile [...]]\n");
404 fprintf(stderr, "\n");
405 fprintf(stderr, "For encoding:\n");
406 fprintf(stderr, " the input file(s) may be a PCM RIFF WAVE file or raw samples\n");
407 fprintf(stderr, " the output file(s) will be in FLAC format\n");
408 fprintf(stderr, "For decoding, the reverse is true\n");
409 fprintf(stderr, "\n");
410 fprintf(stderr, "A single 'infile' may be - for stdin. No 'infile' implies stdin. Use of\n");
411 fprintf(stderr, "stdin implies -c (write to stdout). However, flac allows the special\n");
412 fprintf(stderr, "encoding/decoding forms:\n");
413 fprintf(stderr, " flac [options] - outfilename or flac -d [options] - outfilename\n");
414 fprintf(stderr, "which is better than:\n");
415 fprintf(stderr, " flac [options] > outfilename or flac -d [options] > outfilename\n");
416 fprintf(stderr, "since the former allows flac to seek backwards to write the STREAMINFO or\n");
417 fprintf(stderr, "RIFF WAVE header contents when necessary.\n");
418 fprintf(stderr, "\n");
419 fprintf(stderr, "If the unencoded filename ends with '.wav' or -fw is used, it's assumed to be\n");
420 fprintf(stderr, "RIFF WAVE. Otherwise, flac will check for the presence of a RIFF header. If\n");
421 fprintf(stderr, "any infile is raw you must specify the format options {-fb|fl} -fc -fp and -fs,\n");
422 fprintf(stderr, "which will apply to all raw files. You can force a .wav file to be treated as\n");
423 fprintf(stderr, "a raw file using -fr.\n");
424 fprintf(stderr, "\n");
425 fprintf(stderr, "generic options:\n");
426 fprintf(stderr, " -d : decode (default behavior is encode)\n");
427 fprintf(stderr, " -t : test (same as -d except no decoded file is written)\n");
428 fprintf(stderr, " -a : analyze (same as -d except an analysis file is written)\n");
429 fprintf(stderr, " -c : write output to stdout\n");
430 fprintf(stderr, " -s : silent (do not write runtime encode/decode statistics)\n");
431 fprintf(stderr, " --skip samples : can be used both for encoding and decoding\n");
432 fprintf(stderr, "analyze options:\n");
433 fprintf(stderr, " --a-rtext : include residual signal in text output\n");
434 fprintf(stderr, " --a-rgp : generate gnuplot files of residual distribution of each subframe\n");
435 fprintf(stderr, "encoding options:\n");
436 fprintf(stderr, " --lax : allow encoder to generate non-Subset files\n");
437 fprintf(stderr, " -S { # | X | #x } : include a point or points in a SEEKTABLE\n");
438 fprintf(stderr, " # : a specific sample number for a seek point\n");
439 fprintf(stderr, " X : a placeholder point (always goes at the end of the SEEKTABLE)\n");
440 fprintf(stderr, " #x : # evenly spaced seekpoints, the first being at sample 0\n");
441 fprintf(stderr, " You may use many -S options; the resulting SEEKTABLE will be the unique-\n");
442 fprintf(stderr, " ified union of all such values.\n");
443 fprintf(stderr, " With no -S options, flac defaults to '-S 100x'. Use -S- for no SEEKTABLE.\n");
444 fprintf(stderr, " Note: -S #x will not work if the encoder can't determine the input size\n");
445 fprintf(stderr, " before starting.\n");
446 fprintf(stderr, " Note: if you use -S # and # is >= samples in the input, there will be\n");
447 fprintf(stderr, " either no seek point entered (if the input size is determinable\n");
448 fprintf(stderr, " before encoding starts) or a placeholder point (if input size is not\n");
449 fprintf(stderr, " determinable)\n");
450 fprintf(stderr, " -P # : write a PADDING block of # bytes (goes after SEEKTABLE)\n");
451 fprintf(stderr, " (0 => no PADDING block, default is -P 0)\n");
452 fprintf(stderr, " -b # : specify blocksize in samples; default is 1152 for -l 0, else 4608;\n");
453 fprintf(stderr, " must be 192/576/1152/2304/4608/256/512/1024/2048/4096/8192/16384/32768\n");
454 fprintf(stderr, " (unless --lax is used)\n");
455 fprintf(stderr, " -m : try mid-side coding for each frame (stereo input only)\n");
456 fprintf(stderr, " -M : loose mid-side coding for all frames (stereo input only)\n");
457 fprintf(stderr, " -0 .. -9 : fastest compression .. highest compression, default is -5\n");
458 fprintf(stderr, " these are synonyms for other options:\n");
459 fprintf(stderr, " -0 : synonymous with -l 0 -b 1152\n");
460 fprintf(stderr, " -1 : synonymous with -l 0 -b 1152 -M -r 2,2\n");
461 fprintf(stderr, " -2 : synonymous with -l 0 -b 1152 -m -r 3\n");
462 fprintf(stderr, " -3 : synonymous with -l 6 -b 4608 -r 3,3\n");
463 fprintf(stderr, " -4 : synonymous with -l 8 -b 4608 -M -r 3,3\n");
464 fprintf(stderr, " -5 : synonymous with -l 8 -b 4608 -m -r 3,3\n");
465 fprintf(stderr, " -6 : synonymous with -l 8 -b 4608 -m -r 4\n");
466 fprintf(stderr, " -7 : synonymous with -l 8 -b 4608 -m -e -r 6\n");
467 fprintf(stderr, " -8 : synonymous with -l 12 -b 4608 -m -e -r 6\n");
468 fprintf(stderr, " -9 : synonymous with -l 32 -b 4608 -m -e -r 16 -R 32 -p (very slow!)\n");
469 fprintf(stderr, " -e : do exhaustive model search (expensive!)\n");
470 fprintf(stderr, " -l # : specify max LPC order; 0 => use only fixed predictors\n");
471 fprintf(stderr, " -p : do exhaustive search of LP coefficient quantization (expensive!);\n");
472 fprintf(stderr, " overrides -q, does nothing if using -l 0\n");
473 fprintf(stderr, " -q # : specify precision in bits of quantized linear-predictor coefficients;\n");
474 fprintf(stderr, " 0 => let encoder decide (min is %u, default is -q 0)\n", FLAC__MIN_QLP_COEFF_PRECISION);
475 fprintf(stderr, " -r [#,]# : [min,]max residual partition order (# is 0..16; min defaults to 0;\n");
476 fprintf(stderr, " default is -r 0; above 4 doesn't usually help much)\n");
477 fprintf(stderr, " -R # : Rice parameter search distance (# is 0..32; above 2 doesn't help much)\n");
478 fprintf(stderr, " -V : verify a correct encoding by decoding the output in parallel and\n");
479 fprintf(stderr, " comparing to the original\n");
480 fprintf(stderr, " -S-, -m-, -M-, -e-, -p-, -V-, --lax- can all be used to turn off a particular\n");
481 fprintf(stderr, " option\n");
482 fprintf(stderr, "format options:\n");
483 fprintf(stderr, " -fb | -fl : big-endian | little-endian byte order\n");
484 fprintf(stderr, " -fc channels\n");
485 fprintf(stderr, " -fp bits_per_sample\n");
486 fprintf(stderr, " -fs sample_rate : in Hz\n");
487 fprintf(stderr, " -fu : unsigned samples (default is signed)\n");
488 fprintf(stderr, " -fr : force to raw format (even if filename ends in .wav)\n");
489 fprintf(stderr, " -fw : force to RIFF WAVE\n");
493 int encode_file(const char *infilename, const char *forced_outfilename)
496 char outfilename[4096]; /* @@@ bad MAGIC NUMBER */
499 if(0 == strcmp(infilename, "-")) {
500 encode_infile = stdin;
503 if(0 == (encode_infile = fopen(infilename, "rb"))) {
504 fprintf(stderr, "ERROR: can't open input file %s\n", infilename);
510 fprintf(stderr, "%s:\n", infilename);
512 if(format_is_wave < 0) {
513 /* lamely attempt to guess the file type based on the first 4 bytes (which is all ungetc will guarantee us) */
516 /* first set format based on name */
517 if(strstr(infilename, ".wav") == infilename + (strlen(infilename) - strlen(".wav")))
518 format_is_wave = true;
520 format_is_wave = false;
521 if((n = fread(head, 1, 4, encode_infile)) < 4) {
523 fprintf(stderr, "WARNING: %s is not a WAVE file, treating as a raw file\n", infilename);
524 format_is_wave = false;
527 if(strncmp(head, "RIFF", 4)) {
529 fprintf(stderr, "WARNING: %s is not a WAVE file, treating as a raw file\n", infilename);
530 format_is_wave = false;
533 format_is_wave = true;
535 for(h = n-1; h >= 0; h--)
536 ungetc(head[h], encode_infile);
539 if(!format_is_wave) {
540 if(format_is_big_endian < 0 || format_channels < 0 || format_bps < 0 || format_sample_rate < 0)
541 return usage("ERROR: for encoding a raw file you must specify { -fb or -fl }, -fc, -fp, and -fs\n");
544 if(encode_infile == stdin || force_to_stdout)
545 strcpy(outfilename, "-");
547 strcpy(outfilename, infilename);
548 if(0 == (p = strrchr(outfilename, '.')))
549 strcat(outfilename, ".flac");
551 if(0 == strcmp(p, ".flac"))
552 strcpy(p, "_new.flac");
557 if(0 == forced_outfilename)
558 forced_outfilename = outfilename;
561 return encode_wav(encode_infile, infilename, forced_outfilename, verbose, skip, verify, lax, do_mid_side, loose_mid_side, do_exhaustive_model_search, do_qlp_coeff_prec_search, min_residual_partition_order, max_residual_partition_order, rice_parameter_search_dist, max_lpc_order, (unsigned)blocksize, qlp_coeff_precision, padding, requested_seek_points, num_requested_seek_points);
563 return encode_raw(encode_infile, infilename, forced_outfilename, verbose, skip, verify, lax, do_mid_side, loose_mid_side, do_exhaustive_model_search, do_qlp_coeff_prec_search, min_residual_partition_order, max_residual_partition_order, rice_parameter_search_dist, max_lpc_order, (unsigned)blocksize, qlp_coeff_precision, padding, requested_seek_points, num_requested_seek_points, format_is_big_endian, format_is_unsigned_samples, format_channels, format_bps, format_sample_rate);
566 int decode_file(const char *infilename, const char *forced_outfilename)
568 static const char *suffixes[] = { ".wav", ".raw" };
569 char outfilename[4096]; /* @@@ bad MAGIC NUMBER */
572 if(!test_only && !analyze) {
573 if(format_is_wave < 0) {
574 format_is_wave = true;
576 if(!format_is_wave) {
577 if(format_is_big_endian < 0)
578 return usage("ERROR: for decoding to a raw file you must specify -fb or -fl\n");
582 if(0 == strcmp(infilename, "-") || force_to_stdout)
583 strcpy(outfilename, "-");
585 const char *suffix = suffixes[format_is_wave? 0:1];
586 strcpy(outfilename, infilename);
587 if(0 == (p = strrchr(outfilename, '.')))
588 strcat(outfilename, suffix);
590 if(0 == strcmp(p, suffix)) {
598 if(0 == forced_outfilename)
599 forced_outfilename = outfilename;
602 return decode_wav(infilename, test_only? 0 : forced_outfilename, analyze, aopts, verbose, skip);
604 return decode_raw(infilename, test_only? 0 : forced_outfilename, analyze, aopts, verbose, skip, format_is_big_endian, format_is_unsigned_samples);