add --input-size option to flac

This commit is contained in:
Josh Coalson 2004-10-14 05:00:59 +00:00
parent c99aa82edf
commit ed1db1f6a0
3 changed files with 49 additions and 0 deletions

View File

@ -900,6 +900,15 @@
Specify that the samples in the raw file are signed or unsigned (the default is signed).
</TD>
</TR>
<TR>
<TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
<A NAME="flac_options_input_size">
<TT>--input-size=#</TT>
</TD>
<TD>
Specify the size of the raw input in bytes. If you are encoding raw samples from stdin, you must set this option in order to be able to use --skip, --until, --cue-sheet, or other options that need to know the size of the input beforehand. If the size given is greater than what is found in the input stream, the encoder will complain about an unexpected end-of-file. If the size given is less, samples will be truncated.
</TD>
</TR>
<TR>
<TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
<A NAME="flac_options_force_aiff_format">

View File

@ -694,6 +694,21 @@
</listitem>
</varlistentry>
<varlistentry>
<term><option>--input-size</option>=<replaceable>#</replaceable></term>
<listitem>
<para>Specify the size of the raw input in bytes. If you are
encoding raw samples from stdin, you must set this option
in order to be able to use --skip, --until, --cue-sheet, or
other options that need to know the size of the input
beforehand. If the size given is greater than what is
found in the input stream, the encoder will complain about
an unexpected end-of-file. If the size given is less,
samples will be truncated.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--force-aiff-format</option></term>

View File

@ -153,6 +153,7 @@ static struct share__option long_options_[] = {
{ "bps" , share__required_argument, 0, 0 },
{ "sample-rate" , share__required_argument, 0, 0 },
{ "sign" , share__required_argument, 0, 0 },
{ "input-size" , share__required_argument, 0, 0 },
/*
* analysis options
@ -237,6 +238,7 @@ static struct {
int format_channels;
int format_bps;
int format_sample_rate;
long format_input_size;
int blocksize;
int min_residual_partition_order;
int max_residual_partition_order;
@ -574,6 +576,7 @@ FLAC__bool init_options()
option_values.format_channels = -1;
option_values.format_bps = -1;
option_values.format_sample_rate = -1;
option_values.format_input_size = -1;
option_values.blocksize = -1;
option_values.min_residual_partition_order = -1;
option_values.max_residual_partition_order = -1;
@ -661,6 +664,10 @@ int parse_option(int short_option, const char *long_option, const char *option_a
FLAC__ASSERT(0 != option_argument);
option_values.until_specification = option_argument;
}
else if(0 == strcmp(long_option, "input-size")) {
FLAC__ASSERT(0 != option_argument);
option_values.format_input_size = atol(option_argument);
}
else if(0 == strcmp(long_option, "cue")) {
FLAC__ASSERT(0 != option_argument);
option_values.cue_specification = option_argument;
@ -1202,6 +1209,7 @@ void show_help()
printf(" --bps=# Number of bits per sample\n");
printf(" --sample-rate=# Sample rate in Hz\n");
printf(" --sign={signed|unsigned} Sign of samples\n");
printf(" --input-size=# Size of the raw input in bytes\n");
printf(" --force-aiff-format Force decoding to AIFF format\n");
printf(" --force-raw-format Treat input or output as raw samples\n");
printf("negative options:\n");
@ -1420,6 +1428,15 @@ void show_explain()
printf(" --bps=# Number of bits per sample\n");
printf(" --sample-rate=# Sample rate in Hz\n");
printf(" --sign={signed|unsigned} Sign of samples (the default is signed)\n");
printf(" --input-size=# Size of the raw input in bytes. If you are\n");
printf(" encoding raw samples from stdin, you must set\n");
printf(" this option in order to be able to use --skip,\n");
printf(" --until, --cue-sheet, or other options that need\n");
printf(" to know the size of the input beforehand. If\n");
printf(" the size given is greater than what is found in\n");
printf(" the input stream, the encoder will complain\n");
printf(" about an unexpected end-of-file. If the size\n");
printf(" given is less, samples will be truncated.\n");
printf(" --force-aiff-format Force the decoder to output AIFF format. This\n");
printf(" option is not needed if the output filename (as\n");
printf(" set by -o) ends with .aif or .aiff; this option\n");
@ -1518,6 +1535,14 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
}
}
if(option_values.format_input_size >= 0 && (fmt != RAW || infilesize >= 0)) {
flac__utils_printf(stderr, 1, "ERROR: can only use --input-size when encoding raw samples from stdin\n");
return 1;
}
else {
infilesize = option_values.format_input_size;
}
if(option_values.sector_align && fmt == RAW && infilesize < 0) {
flac__utils_printf(stderr, 1, "ERROR: can't --sector-align when the input size is unknown\n");
return 1;