fix various little bugs related to format options

This commit is contained in:
Josh Coalson
2002-08-20 20:37:26 +00:00
parent 87977bad56
commit eb20903946
7 changed files with 43 additions and 26 deletions

View File

@@ -717,7 +717,7 @@
</TR> </TR>
<TR> <TR>
<TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC"> <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
<TT>--force-raw-input</TT> <TT>--force-raw-format</TT>
</TD> </TD>
<TD> <TD>
Treat the input file (or output file if decoding) as a raw file, regardless of the extension. Treat the input file (or output file if decoding) as a raw file, regardless of the extension.

View File

@@ -3,7 +3,7 @@
.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/> .\" <http://shell.ipoline.com/~elmert/comp/docbook2X/>
.\" Please send any bug reports, improvements, comments, patches, .\" Please send any bug reports, improvements, comments, patches,
.\" etc. to Steve Cheng <steve@ggi-project.org>. .\" etc. to Steve Cheng <steve@ggi-project.org>.
.TH "FLAC" "1" "19 August 2002" "" "" .TH "FLAC" "1" "20 August 2002" "" ""
.SH NAME .SH NAME
flac \- Free Lossless Audio Codec flac \- Free Lossless Audio Codec
.SH SYNOPSIS .SH SYNOPSIS
@@ -255,8 +255,9 @@ Set sample rate (in Hz).
\fB--sign={\fIsigned\fB|\fIunsigned\fB}\fR \fB--sign={\fIsigned\fB|\fIunsigned\fB}\fR
Set the sign of samples (the default is signed). Set the sign of samples (the default is signed).
.TP .TP
\fB--force-raw-input\fR \fB--force-raw-format\fR
Force input to be treated as raw samples (even if filename ends Force input (when encoding) or output (when decoding)
to be treated as raw samples (even if filename ends
in \fI.wav\fR). in \fI.wav\fR).
.SS "NEGATIVE OPTIONS" .SS "NEGATIVE OPTIONS"
.TP .TP

View File

@@ -4,7 +4,7 @@
<!ENTITY dhfirstname "<firstname>Matt</firstname>"> <!ENTITY dhfirstname "<firstname>Matt</firstname>">
<!ENTITY dhsurname "<surname>Zimmerman</surname>"> <!ENTITY dhsurname "<surname>Zimmerman</surname>">
<!-- Please adjust the date whenever revising the manpage. --> <!-- Please adjust the date whenever revising the manpage. -->
<!ENTITY dhdate "<date>August 19, 2002</date>"> <!ENTITY dhdate "<date>August 20, 2002</date>">
<!-- SECTION should be 1-8, maybe w/ subsection other parameters are <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
allowed: see man(7), man(1). --> allowed: see man(7), man(1). -->
<!ENTITY dhsection "<manvolnum>1</manvolnum>"> <!ENTITY dhsection "<manvolnum>1</manvolnum>">
@@ -572,10 +572,11 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><option>--force-raw-input</option></term> <term><option>--force-raw-format</option></term>
<listitem> <listitem>
<para>Force input to be treated as raw samples (even if filename ends <para>Force input (when encoding) or output (when decoding)
to be treated as raw samples (even if filename ends
in <filename>.wav</filename>).</para> in <filename>.wav</filename>).</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -107,7 +107,7 @@ static struct FLAC__share__option long_options_[] = {
{ "fast", 0, 0, '0' }, { "fast", 0, 0, '0' },
{ "super-secret-impractical-compression-level", 0, 0, 0 }, { "super-secret-impractical-compression-level", 0, 0, 0 },
{ "verify", 0, 0, 'V' }, { "verify", 0, 0, 'V' },
{ "force-raw-input", 0, 0, 0 }, { "force-raw-format", 0, 0, 0 },
{ "lax", 0, 0, 0 }, { "lax", 0, 0, 0 },
{ "sector-align", 0, 0, 0 }, { "sector-align", 0, 0, 0 },
{ "seekpoint", 1, 0, 'S' }, { "seekpoint", 1, 0, 'S' },
@@ -314,6 +314,20 @@ int do_it()
if(!FLAC__format_sample_rate_is_valid(option_values.format_sample_rate)) if(!FLAC__format_sample_rate_is_valid(option_values.format_sample_rate))
return usage_error("ERROR: invalid sample rate '%u', must be > 0 and <= %u\n", option_values.format_sample_rate, FLAC__MAX_SAMPLE_RATE); return usage_error("ERROR: invalid sample rate '%u', must be > 0 and <= %u\n", option_values.format_sample_rate, FLAC__MAX_SAMPLE_RATE);
} }
if(option_values.mode_decode) {
if(!option_values.force_raw_format) {
if(option_values.format_is_big_endian >= 0)
return usage_error("ERROR: --endian only allowed with --force-raw-format\n");
if(option_values.format_is_unsigned_samples >= 0)
return usage_error("ERROR: --sign only allowed with --force-raw-format\n");
}
if(option_values.format_channels >= 0)
return usage_error("ERROR: --channels not allowed with --decode\n");
if(option_values.format_bps >= 0)
return usage_error("ERROR: --bps not allowed with --decode\n");
if(option_values.format_sample_rate >= 0)
return usage_error("ERROR: --sample-rate not allowed with --decode\n");
}
if(!option_values.mode_decode && ((unsigned)option_values.blocksize < FLAC__MIN_BLOCK_SIZE || (unsigned)option_values.blocksize > FLAC__MAX_BLOCK_SIZE)) { if(!option_values.mode_decode && ((unsigned)option_values.blocksize < FLAC__MIN_BLOCK_SIZE || (unsigned)option_values.blocksize > FLAC__MAX_BLOCK_SIZE)) {
return usage_error("ERROR: invalid blocksize '%u', must be >= %u and <= %u\n", (unsigned)option_values.blocksize, FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE); return usage_error("ERROR: invalid blocksize '%u', must be >= %u and <= %u\n", (unsigned)option_values.blocksize, FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE);
} }
@@ -449,7 +463,7 @@ void init_options()
option_values.qlp_coeff_precision = 0; option_values.qlp_coeff_precision = 0;
option_values.skip = 0; option_values.skip = 0;
option_values.format_is_big_endian = -1; option_values.format_is_big_endian = -1;
option_values.format_is_unsigned_samples = false; option_values.format_is_unsigned_samples = -1;
option_values.format_channels = -1; option_values.format_channels = -1;
option_values.format_bps = -1; option_values.format_bps = -1;
option_values.format_sample_rate = -1; option_values.format_sample_rate = -1;
@@ -534,7 +548,7 @@ int parse_option(int short_option, const char *long_option, const char *option_a
option_values.rice_parameter_search_dist = 0; option_values.rice_parameter_search_dist = 0;
option_values.max_lpc_order = 32; option_values.max_lpc_order = 32;
} }
else if(0 == strcmp(long_option, "force-raw-input")) { else if(0 == strcmp(long_option, "force-raw-format")) {
option_values.force_raw_format = true; option_values.force_raw_format = true;
} }
else if(0 == strcmp(long_option, "lax")) { else if(0 == strcmp(long_option, "lax")) {
@@ -984,7 +998,7 @@ void show_help()
printf(" --bps=# Number of bits per sample\n"); printf(" --bps=# Number of bits per sample\n");
printf(" --sample-rate=# Sample rate in Hz\n"); printf(" --sample-rate=# Sample rate in Hz\n");
printf(" --sign={signed|unsigned} Sign of samples\n"); printf(" --sign={signed|unsigned} Sign of samples\n");
printf(" --force-raw-input Force input to be treated as raw samples\n"); printf(" --force-raw-format Treat input or output as raw samples\n");
printf("negative options:\n"); printf("negative options:\n");
printf(" --no-adaptive-mid-side\n"); printf(" --no-adaptive-mid-side\n");
printf(" --no-decode-through-errors\n"); printf(" --no-decode-through-errors\n");
@@ -1164,7 +1178,8 @@ void show_explain()
printf(" --bps=# Number of bits per sample\n"); printf(" --bps=# Number of bits per sample\n");
printf(" --sample-rate=# Sample rate in Hz\n"); printf(" --sample-rate=# Sample rate in Hz\n");
printf(" --sign={signed|unsigned} Sign of samples (the default is signed)\n"); printf(" --sign={signed|unsigned} Sign of samples (the default is signed)\n");
printf(" --force-raw-input Force input to be treated as raw samples\n"); printf(" --force-raw-format Force input (when encoding) or output (when\n");
printf(" decoding) to be treated as raw samples\n");
printf("negative options:\n"); printf("negative options:\n");
printf(" --no-adaptive-mid-side\n"); printf(" --no-adaptive-mid-side\n");
printf(" --no-decode-through-errors\n"); printf(" --no-decode-through-errors\n");
@@ -1253,8 +1268,8 @@ int encode_file(const char *infilename, const char *forced_outfilename, FLAC__bo
} }
if(fmt == RAW) { if(fmt == RAW) {
if(option_values.format_is_big_endian < 0 || option_values.format_channels < 0 || option_values.format_bps < 0 || option_values.format_sample_rate < 0) if(option_values.format_is_big_endian < 0 || option_values.format_is_unsigned_samples < 0 || option_values.format_channels < 0 || option_values.format_bps < 0 || option_values.format_sample_rate < 0)
return usage_error("ERROR: for encoding a raw file you must specify a value for --endian, --channels, --bps, and --sample-rate\n"); return usage_error("ERROR: for encoding a raw file you must specify a value for --endian, --sign, --channels, --bps, and --sample-rate\n");
} }
if(encode_infile == stdin || option_values.force_to_stdout) if(encode_infile == stdin || option_values.force_to_stdout)
@@ -1348,8 +1363,8 @@ int decode_file(const char *infilename, const char *forced_outfilename)
decode_options_t common_options; decode_options_t common_options;
if(!option_values.test_only && !option_values.analyze) { if(!option_values.test_only && !option_values.analyze) {
if(option_values.force_raw_format && option_values.format_is_big_endian < 0) if(option_values.force_raw_format && (option_values.format_is_big_endian < 0 || option_values.format_is_unsigned_samples < 0))
return usage_error("ERROR: for decoding to a raw file you must specify a value for --endian\n"); return usage_error("ERROR: for decoding to a raw file you must specify a value for --endian and --sign\n");
} }
if(0 == strcmp(infilename, "-") || option_values.force_to_stdout) if(0 == strcmp(infilename, "-") || option_values.force_to_stdout)

View File

@@ -32,7 +32,7 @@ test_file ()
encode_options="$4" encode_options="$4"
echo -n "$name: encode..." echo -n "$name: encode..."
cmd="flac --verify --silent --force-raw-input --endian=big --sample-rate=44100 --bps=$bps --channels=$channels $encode_options $name.bin" cmd="flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options $name.bin"
echo "### ENCODE $name #######################################################" >> ./streams.log echo "### ENCODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log echo "### cmd=$cmd" >> ./streams.log
if $cmd 2>>./streams.log ; then : ; else if $cmd 2>>./streams.log ; then : ; else
@@ -40,7 +40,7 @@ test_file ()
exit 1 exit 1
fi fi
echo -n "decode..." echo -n "decode..."
cmd="flac --silent --endian=big --decode --force-raw-input $name.flac"; cmd="flac --silent --endian=big --decode --force-raw-format $name.flac";
echo "### DECODE $name #######################################################" >> ./streams.log echo "### DECODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log echo "### cmd=$cmd" >> ./streams.log
if $cmd 2>>./streams.log ; then : ; else if $cmd 2>>./streams.log ; then : ; else

View File

@@ -30,7 +30,7 @@ metaflac --help 1>/dev/null 2>/dev/null || (echo "ERROR can't find metaflac exec
if [ $? != 0 ] ; then exit 1 ; fi if [ $? != 0 ] ; then exit 1 ; fi
echo "Generating stream..." echo "Generating stream..."
if flac --verify -0 --output-name=$flacfile --force-raw-input --endian=big --channels=1 --bps=8 --sample-rate=44100 /bin/sh ; then if flac --verify -0 --output-name=$flacfile --force-raw-format --endian=big --sign=signed --channels=1 --bps=8 --sample-rate=44100 /bin/sh ; then
chmod +w $flacfile chmod +w $flacfile
else else
echo "ERROR during generation" 1>&2 echo "ERROR during generation" 1>&2

View File

@@ -43,7 +43,7 @@ fi
# multi-file tests # multi-file tests
# #
echo "Generating multiple input files from noise..." echo "Generating multiple input files from noise..."
if flac --verify --silent --force-raw-input --endian=big --sample-rate=44100 --bps=16 --channels=2 noise.raw ; then : ; else if flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 noise.raw ; then : ; else
echo "ERROR generating FLAC file" 1>&2 echo "ERROR generating FLAC file" 1>&2
exit 1 exit 1
fi fi
@@ -135,7 +135,7 @@ test_file ()
encode_options="$4" encode_options="$4"
echo -n "$name: encode..." echo -n "$name: encode..."
cmd="flac --verify --silent --force-raw-input --endian=big --sample-rate=44100 --bps=$bps --channels=$channels $encode_options $name.raw" cmd="flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options $name.raw"
echo "### ENCODE $name #######################################################" >> ./streams.log echo "### ENCODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log echo "### cmd=$cmd" >> ./streams.log
if $cmd 2>>./streams.log ; then : ; else if $cmd 2>>./streams.log ; then : ; else
@@ -143,7 +143,7 @@ test_file ()
exit 1 exit 1
fi fi
echo -n "decode..." echo -n "decode..."
cmd="flac --silent --endian=big --decode --force-raw-input --output-name=$name.cmp $name.flac" cmd="flac --silent --endian=big --decode --force-raw-format --output-name=$name.cmp $name.flac"
echo "### DECODE $name #######################################################" >> ./streams.log echo "### DECODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log echo "### cmd=$cmd" >> ./streams.log
if $cmd 2>>./streams.log ; then : ; else if $cmd 2>>./streams.log ; then : ; else
@@ -176,7 +176,7 @@ test_file_piped ()
echo -n "$name: encode via pipes..." echo -n "$name: encode via pipes..."
if [ $is_win = yes ] ; then if [ $is_win = yes ] ; then
cmd="flac --verify --silent --force-raw-input --endian=big --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --stdout $name.raw" cmd="flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --stdout $name.raw"
echo "### ENCODE $name #######################################################" >> ./streams.log echo "### ENCODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log echo "### cmd=$cmd" >> ./streams.log
if $cmd 1>$name.flac 2>>./streams.log ; then : ; else if $cmd 1>$name.flac 2>>./streams.log ; then : ; else
@@ -184,7 +184,7 @@ test_file_piped ()
exit 1 exit 1
fi fi
else else
cmd="flac --verify --silent --force-raw-input --endian=big --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --stdout -" cmd="flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $encode_options --stdout -"
echo "### ENCODE $name #######################################################" >> ./streams.log echo "### ENCODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log echo "### cmd=$cmd" >> ./streams.log
if cat $name.raw | $cmd 1>$name.flac 2>>./streams.log ; then : ; else if cat $name.raw | $cmd 1>$name.flac 2>>./streams.log ; then : ; else
@@ -194,7 +194,7 @@ test_file_piped ()
fi fi
echo -n "decode via pipes..." echo -n "decode via pipes..."
if [ $is_win = yes ] ; then if [ $is_win = yes ] ; then
cmd="flac --silent --endian=big --decode --force-raw-input --stdout $name.flac" cmd="flac --silent --endian=big --decode --force-raw-format --stdout $name.flac"
echo "### DECODE $name #######################################################" >> ./streams.log echo "### DECODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log echo "### cmd=$cmd" >> ./streams.log
if $cmd 1>$name.cmp 2>>./streams.log ; then : ; else if $cmd 1>$name.cmp 2>>./streams.log ; then : ; else
@@ -202,7 +202,7 @@ test_file_piped ()
exit 1 exit 1
fi fi
else else
cmd="flac --silent --endian=big --decode --force-raw-input --stdout -" cmd="flac --silent --endian=big --decode --force-raw-format --stdout -"
echo "### DECODE $name #######################################################" >> ./streams.log echo "### DECODE $name #######################################################" >> ./streams.log
echo "### cmd=$cmd" >> ./streams.log echo "### cmd=$cmd" >> ./streams.log
if cat $name.flac | $cmd 1>$name.cmp 2>>./streams.log ; then : ; else if cat $name.flac | $cmd 1>$name.cmp 2>>./streams.log ; then : ; else