Remove sector align option

This option has been deprecated since FLAC 1.3.0.
This commit is contained in:
Martijn van Beurden 2023-05-31 21:49:44 +02:00 committed by GitHub
parent 1619af5a36
commit d6974b9702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 252 deletions

View File

@ -384,11 +384,6 @@ the HTML documentation.
FILENAME is just shorthand for "\|\|\|\|FILENAME". For the format of
SPECIFICATION, see the section **picture specification**.
**\--sector-align**
: Align encoding of multiple CD format files on sector boundaries. See the
HTML documentation for more information. This option is DEPRECATED and
may not exist in future versions of flac.
**\--ignore-chunk-sizes**
: When encoding to flac, ignore the file size headers in WAV and AIFF
files to attempt to work around problems with over-sized or malformed
@ -587,7 +582,6 @@ the HTML documentation.
**\--no-replay-gain**
**\--no-residual-gnuplot**
**\--no-residual-text**
**\--no-sector-align**
**\--no-seektable**
**\--no-silent**
**\--no-verify**

View File

@ -56,7 +56,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
flac__utils_verbosity_ = 0;
share__opterr = 0;
share__optind = 0;
align_reservoir_samples = 0;
if(size < 2)
return 0;

View File

@ -47,7 +47,6 @@
#endif
#define max(x,y) ((x)>(y)?(x):(y))
/* this MUST be >= 588 so that sector aligning can take place with one read */
/* this MUST be < 2^sizeof(size_t) / ( FLAC__MAX_CHANNELS * (FLAC__MAX_BITS_PER_SAMPLE/8) ) */
#define CHUNK_OF_SAMPLES 2048
@ -143,7 +142,7 @@ static FLAC__int32 *input_[FLAC__MAX_CHANNELS];
*/
static FLAC__bool EncoderSession_construct(EncoderSession *e, encode_options_t options, FLAC__off_t infilesize, FILE *infile, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, uint32_t lookahead_length);
static void EncoderSession_destroy(EncoderSession *e);
static int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_align_zero, foreign_metadata_t *foreign_metadata, FLAC__bool error_on_compression_fail);
static int EncoderSession_finish_ok(EncoderSession *e, foreign_metadata_t *foreign_metadata, FLAC__bool error_on_compression_fail);
static int EncoderSession_finish_error(EncoderSession *e);
static FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t options);
static FLAC__bool EncoderSession_process(EncoderSession *e, const FLAC__int32 * const buffer[], uint32_t samples);
@ -482,7 +481,6 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio
data_bytes = ds64_data_size;
}
if(options.ignore_chunk_sizes) {
FLAC__ASSERT(!options.sector_align);
if(data_bytes) {
flac__utils_printf(stderr, 1, "%s: WARNING: 'data' chunk has non-zero size, using --ignore-chunk-sizes is probably a bad idea\n", e->inbasefilename, chunk_id);
if(e->treat_warnings_as_errors)
@ -717,7 +715,6 @@ static FLAC__bool get_sample_info_aiff(EncoderSession *e, encode_options_t optio
return false;
data_bytes = xx;
if(options.ignore_chunk_sizes) {
FLAC__ASSERT(!options.sector_align);
if(data_bytes) {
flac__utils_printf(stderr, 1, "%s: WARNING: 'SSND' chunk has non-zero size, using --ignore-chunk-sizes is probably a bad idea\n", e->inbasefilename, chunk_id);
if(e->treat_warnings_as_errors)
@ -864,7 +861,6 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena
{
EncoderSession encoder_session;
size_t channel_map[FLAC__MAX_CHANNELS];
int info_align_carry = -1, info_align_zero = -1;
if(!EncoderSession_construct(&encoder_session, options, infilesize, infile, infilename, outfilename, lookahead, lookahead_length))
return 1;
@ -946,34 +942,19 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena
flac__utils_printf(stderr, 1, "%s: ERROR: unsupported bits-per-sample %u\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift);
return EncoderSession_finish_error(&encoder_session);
}
if(options.sector_align) {
if(encoder_session.info.channels != 2) {
flac__utils_printf(stderr, 1, "%s: ERROR: file has %u channels, must be 2 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.channels);
return EncoderSession_finish_error(&encoder_session);
}
if(encoder_session.info.sample_rate != 44100) {
flac__utils_printf(stderr, 1, "%s: ERROR: file's sample rate is %u, must be 44100 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.sample_rate);
return EncoderSession_finish_error(&encoder_session);
}
if(encoder_session.info.bits_per_sample-encoder_session.info.shift != 16) {
flac__utils_printf(stderr, 1, "%s: ERROR: file has %u bits-per-sample, must be 16 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift);
return EncoderSession_finish_error(&encoder_session);
}
}
{
FLAC__uint64 total_samples_in_input; /* WATCHOUT: may be 0 to mean "unknown" */
FLAC__uint64 skip;
FLAC__uint64 until; /* a value of 0 mean end-of-stream (i.e. --until=-0) */
uint32_t consecutive_eos_count = 0;
uint32_t align_remainder = 0;
switch(options.format) {
case FORMAT_RAW:
if(infilesize < 0)
total_samples_in_input = 0;
else
total_samples_in_input = (FLAC__uint64)infilesize / encoder_session.info.bytes_per_wide_sample + *options.align_reservoir_samples;
total_samples_in_input = (FLAC__uint64)infilesize / encoder_session.info.bytes_per_wide_sample;
break;
case FORMAT_WAVE:
case FORMAT_WAVE64:
@ -981,7 +962,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena
case FORMAT_AIFF:
case FORMAT_AIFF_C:
/* truncation in the division removes any padding byte that was counted in encoder_session.fmt.iff.data_bytes */
total_samples_in_input = encoder_session.fmt.iff.data_bytes / encoder_session.info.bytes_per_wide_sample + *options.align_reservoir_samples;
total_samples_in_input = encoder_session.fmt.iff.data_bytes / encoder_session.info.bytes_per_wide_sample;
/* check for chunks trailing the audio data */
if(!options.ignore_chunk_sizes && !options.format_options.iff.foreign_metadata
@ -1004,7 +985,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena
break;
case FORMAT_FLAC:
case FORMAT_OGGFLAC:
total_samples_in_input = encoder_session.fmt.flac.client_data.metadata_blocks[0]->data.stream_info.total_samples + *options.align_reservoir_samples;
total_samples_in_input = encoder_session.fmt.flac.client_data.metadata_blocks[0]->data.stream_info.total_samples;
break;
default:
FLAC__ASSERT(0);
@ -1022,9 +1003,6 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena
}
FLAC__ASSERT(options.skip_specification.value.samples >= 0);
skip = (FLAC__uint64)options.skip_specification.value.samples;
FLAC__ASSERT(!options.sector_align || (options.format != FORMAT_FLAC && options.format != FORMAT_OGGFLAC && skip == 0));
/* *options.align_reservoir_samples will be 0 unless --sector-align is used */
FLAC__ASSERT(options.sector_align || *options.align_reservoir_samples == 0);
/*
* now that we possibly know the input size, canonicalize the
@ -1033,7 +1011,6 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena
if(!canonicalize_until_specification(&options.until_specification, encoder_session.inbasefilename, encoder_session.info.sample_rate, skip, total_samples_in_input))
return EncoderSession_finish_error(&encoder_session);
until = (FLAC__uint64)options.until_specification.value.samples;
FLAC__ASSERT(!options.sector_align || until == 0);
/* adjust encoding parameters based on skip and until values */
switch(options.format) {
@ -1077,21 +1054,12 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena
if(until > 0) {
const FLAC__uint64 trim = total_samples_in_input - until;
FLAC__ASSERT(total_samples_in_input > 0);
FLAC__ASSERT(!options.sector_align);
if(options.format == FORMAT_RAW)
infilesize -= (FLAC__off_t)trim * encoder_session.info.bytes_per_wide_sample;
else if(EncoderSession_format_is_iff(&encoder_session))
encoder_session.fmt.iff.data_bytes -= trim * encoder_session.info.bytes_per_wide_sample;
encoder_session.total_samples_to_encode -= trim;
}
if(options.sector_align && (options.format != FORMAT_RAW || infilesize >=0)) { /* for RAW, need to know the filesize */
FLAC__ASSERT(skip == 0); /* asserted above too, but lest we forget */
align_remainder = (uint32_t)(encoder_session.total_samples_to_encode % 588);
if(options.is_last_file)
encoder_session.total_samples_to_encode += (588-align_remainder); /* will pad with zeroes */
else
encoder_session.total_samples_to_encode -= align_remainder; /* will stop short and carry over to next file */
}
switch(options.format) {
case FORMAT_RAW:
encoder_session.unencoded_size = encoder_session.total_samples_to_encode * encoder_session.info.bytes_per_wide_sample;
@ -1195,36 +1163,6 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena
}
}
/*
* first do any samples in the reservoir
*/
if(options.sector_align && *options.align_reservoir_samples > 0) {
FLAC__ASSERT(options.format != FORMAT_FLAC && options.format != FORMAT_OGGFLAC); /* check again */
if(!EncoderSession_process(&encoder_session, (const FLAC__int32 * const *)options.align_reservoir, *options.align_reservoir_samples)) {
print_error_with_state(&encoder_session, "ERROR during encoding");
return EncoderSession_finish_error(&encoder_session);
}
}
/*
* decrement infilesize or the data_bytes counter if we need to align the file
*/
if(options.sector_align) {
if(options.is_last_file) {
*options.align_reservoir_samples = 0;
}
else {
*options.align_reservoir_samples = align_remainder;
if(options.format == FORMAT_RAW) {
FLAC__ASSERT(infilesize >= 0);
infilesize -= (FLAC__off_t)((*options.align_reservoir_samples) * encoder_session.info.bytes_per_wide_sample);
FLAC__ASSERT(infilesize >= 0);
}
else if(EncoderSession_format_is_iff(&encoder_session))
encoder_session.fmt.iff.data_bytes -= (*options.align_reservoir_samples) * encoder_session.info.bytes_per_wide_sample;
}
}
/*
* now do samples from the file
*/
@ -1419,53 +1357,10 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena
return EncoderSession_finish_error(&encoder_session);
}
/*
* now read unaligned samples into reservoir or pad with zeroes if necessary
*/
if(options.sector_align) {
if(options.is_last_file) {
uint32_t wide_samples = 588 - align_remainder;
if(wide_samples < 588) {
uint32_t channel;
info_align_zero = wide_samples;
for(channel = 0; channel < encoder_session.info.channels; channel++)
memset(input_[channel], 0, sizeof(input_[0][0]) * wide_samples);
if(!EncoderSession_process(&encoder_session, (const FLAC__int32 * const *)input_, wide_samples)) {
print_error_with_state(&encoder_session, "ERROR during encoding");
return EncoderSession_finish_error(&encoder_session);
}
}
}
else {
if(*options.align_reservoir_samples > 0) {
size_t bytes_read;
FLAC__ASSERT(CHUNK_OF_SAMPLES >= 588);
bytes_read = fread(ubuffer.u8, sizeof(uint8_t), (*options.align_reservoir_samples) * encoder_session.info.bytes_per_wide_sample, infile);
if(bytes_read == 0 && ferror(infile)) {
flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else if(bytes_read != (*options.align_reservoir_samples) * encoder_session.info.bytes_per_wide_sample) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %" PRIu64 " bytes; expected %" PRIu64 " samples, got %" PRIu64 " samples\n", encoder_session.inbasefilename, bytes_read, encoder_session.total_samples_to_encode, encoder_session.samples_written);
if(encoder_session.treat_warnings_as_errors)
return EncoderSession_finish_error(&encoder_session);
}
else {
info_align_carry = *options.align_reservoir_samples;
if(!format_input(options.align_reservoir, *options.align_reservoir_samples, encoder_session.info.is_big_endian, encoder_session.info.is_unsigned_samples, encoder_session.info.channels, encoder_session.info.bits_per_sample, encoder_session.info.shift, channel_map))
return EncoderSession_finish_error(&encoder_session);
}
}
}
}
}
return EncoderSession_finish_ok(
&encoder_session,
info_align_carry,
info_align_zero,
EncoderSession_format_is_iff(&encoder_session)? options.format_options.iff.foreign_metadata : 0,
options.error_on_compression_fail
);
@ -1594,7 +1489,7 @@ void EncoderSession_destroy(EncoderSession *e)
}
}
int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_align_zero, foreign_metadata_t *foreign_metadata, FLAC__bool error_on_compression_fail)
int EncoderSession_finish_ok(EncoderSession *e, foreign_metadata_t *foreign_metadata, FLAC__bool error_on_compression_fail)
{
FLAC__StreamEncoderState fse_state = FLAC__STREAM_ENCODER_OK;
int ret = 0;
@ -1620,14 +1515,6 @@ int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_a
print_verify_error(e);
ret = 1;
}
else {
if(info_align_carry >= 0) {
flac__utils_printf(stderr, 1, "%s: INFO: sector alignment causing %d samples to be carried over\n", e->inbasefilename, info_align_carry);
}
if(info_align_zero >= 0) {
flac__utils_printf(stderr, 1, "%s: INFO: sector alignment causing %d zero samples to be appended\n", e->inbasefilename, info_align_zero);
}
}
/*@@@@@@ should this go here or somewhere else? */
if(ret == 0 && foreign_metadata) {

View File

@ -76,14 +76,10 @@ typedef struct {
FLAC__bool cued_seekpoints;
FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */
/* options related to --replay-gain and --sector-align */
FLAC__bool is_first_file;
FLAC__bool is_last_file;
FLAC__int32 **align_reservoir;
unsigned *align_reservoir_samples;
FLAC__bool replay_gain;
FLAC__bool ignore_chunk_sizes;
FLAC__bool sector_align;
FLAC__bool error_on_compression_fail;
FLAC__bool limit_min_bitrate;
FLAC__bool relaxed_foreign_metadata_handling;

View File

@ -151,7 +151,6 @@ static struct share__option long_options_[] = {
{ "lax" , share__no_argument, 0, 0 },
{ "replay-gain" , share__no_argument, 0, 0 },
{ "ignore-chunk-sizes" , share__no_argument, 0, 0 },
{ "sector-align" , share__no_argument, 0, 0 }, /* DEPRECATED */
{ "seekpoint" , share__required_argument, 0, 'S' },
{ "padding" , share__required_argument, 0, 'P' },
#if FLAC__HAS_OGG
@ -194,7 +193,6 @@ static struct share__option long_options_[] = {
{ "no-keep-foreign-metadata" , share__no_argument, 0, 0 },
{ "no-replay-gain" , share__no_argument, 0, 0 },
{ "no-ignore-chunk-sizes" , share__no_argument, 0, 0 },
{ "no-sector-align" , share__no_argument, 0, 0 }, /* DEPRECATED */
{ "no-utf8-convert" , share__no_argument, 0, 0 },
{ "no-lax" , share__no_argument, 0, 0 },
#if FLAC__HAS_OGG
@ -257,7 +255,6 @@ static struct {
FLAC__bool keep_foreign_metadata_if_present;
FLAC__bool replay_gain;
FLAC__bool ignore_chunk_sizes;
FLAC__bool sector_align;
FLAC__bool utf8_convert; /* true by default, to convert tag strings from locale to utf-8, false if --no-utf8-convert used */
const char *cmdline_forced_outfilename;
const char *output_prefix;
@ -302,10 +299,6 @@ static struct {
* miscellaneous globals
*/
static FLAC__int32 align_reservoir_0[588], align_reservoir_1[588]; /* for carrying over samples from --sector-align */ /* DEPRECATED */
static FLAC__int32 *align_reservoir[2] = { align_reservoir_0, align_reservoir_1 };
static uint32_t align_reservoir_samples = 0; /* 0 .. 587 */
#ifndef FUZZ_TOOL_FLAC
int main(int argc, char *argv[])
@ -441,8 +434,6 @@ int do_it(void)
if(option_values.ignore_chunk_sizes) {
if(option_values.mode_decode)
return usage_error("ERROR: --ignore-chunk-sizes only allowed for encoding\n");
if(0 != option_values.sector_align)
return usage_error("ERROR: --ignore-chunk-sizes not allowed with --sector-align\n");
if(0 != option_values.until_specification)
return usage_error("ERROR: --ignore-chunk-sizes not allowed with --until\n");
if(0 != option_values.cue_specification)
@ -450,22 +441,6 @@ int do_it(void)
if(0 != option_values.cuesheet_filename)
return usage_error("ERROR: --ignore-chunk-sizes not allowed with --cuesheet\n");
}
if(option_values.sector_align) {
if(option_values.mode_decode)
return usage_error("ERROR: --sector-align only allowed for encoding\n");
if(0 != option_values.skip_specification)
return usage_error("ERROR: --sector-align not allowed with --skip\n");
if(0 != option_values.until_specification)
return usage_error("ERROR: --sector-align not allowed with --until\n");
if(0 != option_values.cue_specification)
return usage_error("ERROR: --sector-align not allowed with --cue\n");
if(option_values.format_channels >= 0 && option_values.format_channels != 2)
return usage_error("ERROR: --sector-align can only be done with stereo input\n");
if(option_values.format_bps >= 0 && option_values.format_bps != 16)
return usage_error("ERROR: --sector-align can only be done with 16-bit samples\n");
if(option_values.format_sample_rate >= 0 && option_values.format_sample_rate != 44100)
return usage_error("ERROR: --sector-align can only be done with a sample rate of 44100\n");
}
if(option_values.replay_gain) {
if(option_values.force_to_stdout)
return usage_error("ERROR: --replay-gain not allowed with -c/--stdout\n");
@ -605,7 +580,6 @@ FLAC__bool init_options(void)
option_values.keep_foreign_metadata_if_present = false;
option_values.replay_gain = false;
option_values.ignore_chunk_sizes = false;
option_values.sector_align = false;
option_values.utf8_convert = true;
option_values.cmdline_forced_outfilename = 0;
option_values.output_prefix = 0;
@ -824,11 +798,6 @@ int parse_option(int short_option, const char *long_option, const char *option_a
else if(0 == strcmp(long_option, "ignore-chunk-sizes")) {
option_values.ignore_chunk_sizes = true;
}
else if(0 == strcmp(long_option, "sector-align")) {
flac__utils_printf(stderr, 1, "WARNING: --sector-align is DEPRECATED and may not exist in future versions of flac.\n");
flac__utils_printf(stderr, 1, " shntool provides similar functionality\n");
option_values.sector_align = true;
}
#if FLAC__HAS_OGG
else if(0 == strcmp(long_option, "ogg")) {
option_values.use_ogg = true;
@ -911,9 +880,6 @@ int parse_option(int short_option, const char *long_option, const char *option_a
else if(0 == strcmp(long_option, "no-ignore-chunk-sizes")) {
option_values.ignore_chunk_sizes = false;
}
else if(0 == strcmp(long_option, "no-sector-align")) {
option_values.sector_align = false;
}
else if(0 == strcmp(long_option, "no-utf8-convert")) {
option_values.utf8_convert = false;
}
@ -1340,7 +1306,6 @@ void show_help(void)
printf(" -V, --verify Verify a correct encoding\n");
printf(" --lax Allow encoder to generate non-Subset files\n");
printf(" --ignore-chunk-sizes Ignore data chunk sizes in WAVE/AIFF files\n");
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(" --picture=SPECIFICATION Import picture and store in PICTURE block\n");
@ -1406,7 +1371,6 @@ void show_help(void)
printf(" --no-residual-gnuplot\n");
printf(" --no-residual-text\n");
printf(" --no-ignore-chunk-sizes\n");
printf(" --no-sector-align\n");
printf(" --no-seektable\n");
printf(" --no-silent\n");
printf(" --no-force\n");
@ -1549,10 +1513,6 @@ void show_explain(void)
printf(" --ignore-chunk-sizes Ignore data chunk sizes in WAVE/AIFF files;\n");
printf(" useful when piping data from programs which\n");
printf(" generate bogus data chunk sizes.\n");
printf(" --sector-align Align encoding of multiple CD format WAVE files\n");
printf(" on sector boundaries. This option is DEPRECATED\n");
printf(" and may not exist in future versions of flac.\n");
printf(" shntool offers similar functionality.\n");
printf(" --replay-gain Calculate ReplayGain values and store them as\n");
printf(" FLAC tags. Title gains/peaks will be computed\n");
printf(" for each file, and an album gain/peak will be\n");
@ -1773,7 +1733,6 @@ void show_explain(void)
printf(" --no-residual-gnuplot\n");
printf(" --no-residual-text\n");
printf(" --no-ignore-chunk-sizes\n");
printf(" --no-sector-align\n");
printf(" --no-seektable\n");
printf(" --no-silent\n");
printf(" --no-force\n");
@ -1964,17 +1923,6 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
}
}
if(option_values.sector_align && (input_format == FORMAT_FLAC || input_format == FORMAT_OGGFLAC)) {
flac__utils_printf(stderr, 1, "ERROR: can't use --sector-align when the input file is FLAC or Ogg FLAC\n");
conditional_fclose(encode_infile);
return 1;
}
if(option_values.sector_align && input_format == FORMAT_RAW && infilesize < 0) {
flac__utils_printf(stderr, 1, "ERROR: can't use --sector-align when the input size is unknown\n");
conditional_fclose(encode_infile);
return 1;
}
if(input_format == FORMAT_RAW) {
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) {
conditional_fclose(encode_infile);
@ -2036,11 +1984,8 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
encode_options.channel_map_none = option_values.channel_map_none;
encode_options.is_first_file = is_first_file;
encode_options.is_last_file = is_last_file;
encode_options.align_reservoir = align_reservoir;
encode_options.align_reservoir_samples = &align_reservoir_samples;
encode_options.replay_gain = option_values.replay_gain;
encode_options.ignore_chunk_sizes = option_values.ignore_chunk_sizes;
encode_options.sector_align = option_values.sector_align;
encode_options.vorbis_comment = option_values.vorbis_comment;
FLAC__ASSERT(sizeof(encode_options.pictures) >= sizeof(option_values.pictures));
memcpy(encode_options.pictures, option_values.pictures, sizeof(option_values.pictures));

View File

@ -1092,45 +1092,12 @@ cp shortnoise.raw file0.raw
cp shortnoise.raw file1.raw
cp shortnoise.raw file2.raw
rm -f shortnoise.raw
# create authoritative sector-aligned files for comparison
file0_samples=$(( (short_noise_cdda_samples / 588) * 588))
file0_remainder=$((short_noise_cdda_samples - file0_samples))
file1_samples=$(( ( ( file0_remainder + short_noise_cdda_samples ) / 588 ) * 588))
file1_remainder=$((file0_remainder + short_noise_cdda_samples - file1_samples))
file1_samples=$((file1_samples - file0_remainder))
file2_samples=$(( ( ( file1_remainder + short_noise_cdda_samples ) / 588 ) * 588))
file2_remainder=$(( file1_remainder + short_noise_cdda_samples - file2_samples))
file2_samples=$((file2_samples - file1_remainder))
if [ $file2_remainder != '0' ] ; then
file2_samples=$((file2_samples + file2_remainder))
file2_remainder=$((588 - file2_remainder))
fi
dd if=file0.raw ibs=4 count=$file0_samples of=file0s.raw 2>/dev/null || $dddie
dd if=file0.raw ibs=4 count=$file0_remainder of=file1s.raw skip=$file0_samples 2>/dev/null || $dddie
dd if=file1.raw ibs=4 count=$file1_samples of=z.raw 2>/dev/null || $dddie
cat z.raw >> file1s.raw || die "ERROR: cat-ing sector-aligned files"
dd if=file1.raw ibs=4 count=$file1_remainder of=file2s.raw skip=$file1_samples 2>/dev/null || $dddie
dd if=file2.raw ibs=4 count=$file2_samples of=z.raw 2>/dev/null || $dddie
cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
dd if=/dev/zero ibs=4 count=$file2_remainder of=z.raw 2>/dev/null || $dddie
cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
rm -f z.raw
convert_to_wav file0s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
convert_to_wav file1s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
convert_to_wav file2s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
convert_to_aiff file0s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
convert_to_aiff file1s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
convert_to_aiff file2s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
test_multifile ()
{
input_type=$1
streamtype=$2
sector_align=$3
encode_options="$4"
encode_options="$3"
extra_encode_options=""
extra_decode_options=""
@ -1150,10 +1117,6 @@ test_multifile ()
suffix=flac
fi
if [ $sector_align = sector_align ] ; then
encode_options="$encode_options --sector-align"
fi
if [ $input_type = flac ] || [ $input_type = ogg ] ; then
CMP=md5cmp
else
@ -1165,15 +1128,9 @@ test_multifile ()
done
run_flac --force $encode_options $extra_encode_options file0x.$input_type file1x.$input_type file2x.$input_type || die "ERROR"
run_flac --force --decode $extra_decode_options file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
if [ $sector_align != sector_align ] ; then
for n in 0 1 2 ; do
$CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
done
else
for n in 0 1 2 ; do
$CMP file${n}s.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
done
fi
for n in 0 1 2 ; do
$CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
done
for n in 0 1 2 ; do
rm -f file${n}x.$suffix file${n}x.$input_type
done
@ -1186,36 +1143,20 @@ input_types="raw wav aiff flac"
#@@@fi
for input_type in $input_types ; do
echo "Testing multiple $input_type files without verify..."
test_multifile $input_type flac no_sector_align ""
test_multifile $input_type flac ""
echo "Testing multiple $input_type files with verify..."
test_multifile $input_type flac no_sector_align "--verify"
if [ $input_type != flac ] && [ $input_type != ogg ] ; then # --sector-align not supported for FLAC input
echo "Testing multiple $input_type files with --sector-align, without verify..."
test_multifile $input_type flac sector_align ""
echo "Testing multiple $input_type files with --sector-align, with verify..."
test_multifile $input_type flac sector_align "--verify"
fi
test_multifile $input_type flac "--verify"
if [ $has_ogg = yes ] ; then
echo "Testing multiple $input_type files with --ogg, without verify..."
test_multifile $input_type ogg no_sector_align ""
test_multifile $input_type ogg ""
echo "Testing multiple $input_type files with --ogg, with verify..."
test_multifile $input_type ogg no_sector_align "--verify"
if [ $input_type != flac ] ; then # --sector-align not supported for FLAC input
echo "Testing multiple $input_type files with --ogg and --sector-align, without verify..."
test_multifile $input_type ogg sector_align ""
echo "Testing multiple $input_type files with --ogg and --sector-align, with verify..."
test_multifile $input_type ogg sector_align "--verify"
fi
test_multifile $input_type ogg "--verify"
echo "Testing multiple $input_type files with --ogg and --serial-number, with verify..."
test_multifile $input_type ogg no_sector_align "--serial-number=321 --verify"
test_multifile $input_type ogg "--serial-number=321 --verify"
fi
done