int format_channels;
int format_bps;
int format_sample_rate;
- off_t format_input_size;
+ FLAC__off_t format_input_size;
char requested_seek_points[5000]; /* bad MAGIC NUMBER but buffer overflow is checked */
int num_requested_seek_points; /* -1 => no -S options were given, 0 => -S- was given */
const char *cuesheet_filename;
option_values.format_channels = -1;
option_values.format_bps = -1;
option_values.format_sample_rate = -1;
- option_values.format_input_size = (off_t)(-1);
+ option_values.format_input_size = (FLAC__off_t)(-1);
option_values.requested_seek_points[0] = '\0';
option_values.num_requested_seek_points = -1;
option_values.cuesheet_filename = 0;
int parse_option(int short_option, const char *long_option, const char *option_argument)
{
const char *violation;
- char *p;
- int i;
if(short_option == 0) {
FLAC__ASSERT(0 != long_option);
FLAC__ASSERT(0 != option_argument);
{
char *end;
- FLAC__int64 i;
- i = strtoll(option_argument, &end, 10);
+ FLAC__int64 ix;
+ ix = strtoll(option_argument, &end, 10);
if(0 == strlen(option_argument) || *end)
return usage_error("ERROR: --%s must be a number\n", long_option);
- option_values.format_input_size = (off_t)i;
- if(option_values.format_input_size != i) /* check if off_t is smaller than long long */
+ option_values.format_input_size = (FLAC__off_t)ix;
+ if(option_values.format_input_size != ix) /* check if FLAC__off_t is smaller than long long */
return usage_error("ERROR: --%s too large; this build of flac does not support filesizes over 2GB\n", long_option);
if(option_values.format_input_size <= 0)
return usage_error("ERROR: --%s must be > 0\n", long_option);
return usage_error("ERROR: argument to -%c must be >= 0; for no padding use -%c-\n", short_option, short_option);
break;
case 'b':
- FLAC__ASSERT(0 != option_argument);
- i = atoi(option_argument);
- if((i < (int)FLAC__MIN_BLOCK_SIZE || i > (int)FLAC__MAX_BLOCK_SIZE))
- return usage_error("ERROR: invalid blocksize (-%c) '%d', must be >= %u and <= %u\n", short_option, i, FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE);
- add_compression_setting_unsigned(CST_BLOCKSIZE, (unsigned)i);
+ {
+ unsigned i ;
+ FLAC__ASSERT(0 != option_argument);
+ i = atoi(option_argument);
+ if((i < (int)FLAC__MIN_BLOCK_SIZE || i > (int)FLAC__MAX_BLOCK_SIZE))
+ return usage_error("ERROR: invalid blocksize (-%c) '%d', must be >= %u and <= %u\n", short_option, i, FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE);
+ add_compression_setting_unsigned(CST_BLOCKSIZE, (unsigned)i);
+ }
break;
case 'e':
add_compression_setting_bool(CST_DO_EXHAUSTIVE_MODEL_SEARCH, true);
add_compression_setting_bool(CST_DO_ESCAPE_CODING, true);
break;
case 'l':
- FLAC__ASSERT(0 != option_argument);
- i = atoi(option_argument);
- if((i < 0 || i > (int)FLAC__MAX_LPC_ORDER))
- return usage_error("ERROR: invalid LPC order (-%c) '%d', must be >= %u and <= %u\n", short_option, i, 0, FLAC__MAX_LPC_ORDER);
- add_compression_setting_unsigned(CST_MAX_LPC_ORDER, (unsigned)i);
+ {
+ unsigned i ;
+ FLAC__ASSERT(0 != option_argument);
+ i = atoi(option_argument);
+ if(i > FLAC__MAX_LPC_ORDER)
+ return usage_error("ERROR: invalid LPC order (-%c) '%d', must be >= %u and <= %u\n", short_option, i, 0, FLAC__MAX_LPC_ORDER);
+ add_compression_setting_unsigned(CST_MAX_LPC_ORDER, i);
+ }
break;
case 'A':
FLAC__ASSERT(0 != option_argument);
add_compression_setting_bool(CST_DO_QLP_COEFF_PREC_SEARCH, true);
break;
case 'q':
- FLAC__ASSERT(0 != option_argument);
- i = atoi(option_argument);
- if(i < 0 || (i > 0 && (i < (int)FLAC__MIN_QLP_COEFF_PRECISION || i > (int)FLAC__MAX_QLP_COEFF_PRECISION)))
- return usage_error("ERROR: invalid value '%d' for qlp coeff precision (-%c), must be 0 or between %u and %u, inclusive\n", i, short_option, FLAC__MIN_QLP_COEFF_PRECISION, FLAC__MAX_QLP_COEFF_PRECISION);
- add_compression_setting_unsigned(CST_QLP_COEFF_PRECISION, (unsigned)i);
- break;
- case 'r':
- FLAC__ASSERT(0 != option_argument);
- p = strchr(option_argument, ',');
- if(0 == p) {
- add_compression_setting_unsigned(CST_MIN_RESIDUAL_PARTITION_ORDER, 0);
+ {
+ unsigned i ;
+ FLAC__ASSERT(0 != option_argument);
i = atoi(option_argument);
- if(i < 0)
- return usage_error("ERROR: invalid value '%d' for residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER);
- add_compression_setting_unsigned(CST_MAX_RESIDUAL_PARTITION_ORDER, (unsigned)i);
+ if((i > 0 && (i < FLAC__MIN_QLP_COEFF_PRECISION || i > FLAC__MAX_QLP_COEFF_PRECISION)))
+ return usage_error("ERROR: invalid value '%d' for qlp coeff precision (-%c), must be 0 or between %u and %u, inclusive\n", i, short_option, FLAC__MIN_QLP_COEFF_PRECISION, FLAC__MAX_QLP_COEFF_PRECISION);
+ add_compression_setting_unsigned(CST_QLP_COEFF_PRECISION, i);
}
- else {
- i = atoi(option_argument);
- if(i < 0)
- return usage_error("ERROR: invalid value '%d' for min residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER);
- add_compression_setting_unsigned(CST_MIN_RESIDUAL_PARTITION_ORDER, (unsigned)i);
- i = atoi(++p);
- if(i < 0)
- return usage_error("ERROR: invalid value '%d' for max residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER);
- add_compression_setting_unsigned(CST_MAX_RESIDUAL_PARTITION_ORDER, (unsigned)i);
+ break;
+ case 'r':
+ {
+ unsigned i;
+ char * p;
+ FLAC__ASSERT(0 != option_argument);
+ p = strchr(option_argument, ',');
+ if(0 == p) {
+ add_compression_setting_unsigned(CST_MIN_RESIDUAL_PARTITION_ORDER, 0);
+ i = atoi(option_argument);
+ if(i > FLAC__MAX_RICE_PARTITION_ORDER)
+ return usage_error("ERROR: invalid value '%d' for residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER);
+ add_compression_setting_unsigned(CST_MAX_RESIDUAL_PARTITION_ORDER, i);
+ }
+ else {
+ i = atoi(option_argument);
+ if(i > FLAC__MAX_RICE_PARTITION_ORDER)
+ return usage_error("ERROR: invalid value '%d' for min residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER);
+ add_compression_setting_unsigned(CST_MIN_RESIDUAL_PARTITION_ORDER, i);
+ i = atoi(++p);
+ if(i > FLAC__MAX_RICE_PARTITION_ORDER)
+ return usage_error("ERROR: invalid value '%d' for max residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER);
+ add_compression_setting_unsigned(CST_MAX_RESIDUAL_PARTITION_ORDER, i);
+ }
}
break;
case 'R':
- i = atoi(option_argument);
- if(i < 0)
- return usage_error("ERROR: invalid value '%d' for Rice parameter search distance (-%c), must be >= 0\n", i, short_option);
- add_compression_setting_unsigned(CST_RICE_PARAMETER_SEARCH_DIST, (unsigned)i);
+ {
+ unsigned i;
+ i = atoi(option_argument);
+ add_compression_setting_unsigned(CST_RICE_PARAMETER_SEARCH_DIST, i);
+ }
break;
default:
FLAC__ASSERT(0);
printf("encoding options:\n");
printf(" -V, --verify Verify a correct encoding\n");
printf(" --lax Allow encoder to generate non-Subset files\n");
-#if 0 /*@@@ currently undocumented */
printf(" --ignore-chunk-sizes Ignore data chunk sizes in WAVE/AIFF files\n");
-#endif
printf(" --sector-align (DEPRECATED) Align multiple files on sector boundaries\n");
printf(" --replay-gain Calculate ReplayGain & store in FLAC tags\n");
printf(" --cuesheet=FILENAME Import cuesheet and store in CUESHEET block\n");
printf(" --no-replay-gain\n");
printf(" --no-residual-gnuplot\n");
printf(" --no-residual-text\n");
-#if 0 /*@@@ currently undocumented */
printf(" --no-ignore-chunk-sizes\n");
-#endif
printf(" --no-sector-align\n");
printf(" --no-seektable\n");
printf(" --no-silent\n");
unsigned lookahead_length = 0;
FileFormat input_format = FORMAT_RAW;
int retval;
- off_t infilesize;
+ FLAC__off_t infilesize;
encode_options_t encode_options;
const char *outfilename = get_encoded_outfilename(infilename); /* the final name of the encoded file */
/* internal_outfilename is the file we will actually write to; it will be a temporary name if infilename==outfilename */
}
if(0 == strcmp(infilename, "-")) {
- infilesize = (off_t)(-1);
+ infilesize = (FLAC__off_t)(-1);
encode_infile = grabbag__file_get_binary_stdin();
}
else {
* Error if output file already exists (and -f not used).
* Use grabbag__file_get_filesize() as a cheap way to check.
*/
- if(!option_values.test_only && !option_values.force_file_overwrite && strcmp(outfilename, "-") && grabbag__file_get_filesize(outfilename) != (off_t)(-1)) {
+ if(!option_values.test_only && !option_values.force_file_overwrite && strcmp(outfilename, "-") && grabbag__file_get_filesize(outfilename) != (FLAC__off_t)(-1)) {
if(input_format == FORMAT_FLAC) {
/* need more detailed error message when re-flac'ing to avoid confusing the user */
flac__utils_printf(stderr, 1,
* Error if output file already exists (and -f not used).
* Use grabbag__file_get_filesize() as a cheap way to check.
*/
- if(!option_values.test_only && !option_values.force_file_overwrite && strcmp(outfilename, "-") && grabbag__file_get_filesize(outfilename) != (off_t)(-1)) {
+ if(!option_values.test_only && !option_values.force_file_overwrite && strcmp(outfilename, "-") && grabbag__file_get_filesize(outfilename) != (FLAC__off_t)(-1)) {
flac__utils_printf(stderr, 1, "ERROR: output file %s already exists, use -f to override\n", outfilename);
return 1;
}