<ul>
<li>Improved compression with no impact on format or decoding speed.</li>
<li>Encoding and decoding speedups across the board. Encoding at -8 is twice as fast.</li>
+ <li>Added a new option <span class="argument"><a href="documentation_tools_flac.html#flac_options_warnings_as_errors">-w,-@@@@@@-warnings-as-errors</a></span> for treating all warnings as errors.</li>
+ <li>Allow <span class="argument"><a href="documentation_tools_flac.html#flac_options_picture">-@@@@@@-picture</a></span> option to take only a filename, and have all other attributes extracted from the file itself.</li>
<li>Fixed a bug that caused suboptimal default compression settings in some locales (<a href="https://sourceforge.net/tracker/index.php?func=detail&aid=1608883&group_id=13478&atid=113478">SF #1608883</a>).</li>
<li>Fixed a bug where FLAC-to-FLAC transcoding of a corrupted FLAC file would truncate the transcoded file at the first error (<a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1615019&group_id=13478&atid=113478">SF #1615019</a>).</li>
<li>Fixed a bug where using <span class="argument"><a href="documentation_tools_flac.html#flac_options_decode_through_errors">-F</a></span> with FLAC-to-FLAC transcoding of a corrupted FLAC would have no effect (<a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1615391&group_id=13478&atid=113478">SF #1615391</a>).</li>
<li>
metaflac:
<ul>
+ <li>Allow <span class="argument"><a href="documentation_tools_metaflac.html#metaflac_shorthand_import_picture_from">-@@@@@@-import-picture-from</a></span> option to take only a filename, and have all other attributes extracted from the file itself.</li>
<li>(none)</li>
</ul>
</li>
</tr>
<tr>
<td nowrap="nowrap" align="right" valign="top" bgcolor="#F4F4CC">
+ <a name="flac_options_warnings_as_errors" />
+ <span class="argument">-w</span>, <span class="argument">--warnings-as-errors</span>
+ </td>
+ <td>
+ Treat all warnings as errors (which cause <span class="commandname">flac</span> to terminate with a non-zero exit code).
+ </td>
+ </tr>
+ <tr>
+ <td nowrap="nowrap" align="right" valign="top" bgcolor="#F4F4CC">
<a name="flac_options_force" />
<span class="argument">-f</span>, <span class="argument">--force</span>
</td>
<tr>
<td nowrap="nowrap" align="right" valign="top" bgcolor="#F4F4CC">
<a name="flac_options_picture" />
- <span class="argument">--picture=SPECIFICATION</span>
+ <span class="argument">--picture={FILENAME|SPECIFICATION}</span>
</td>
<td>
- Import a picture and store it in a <a href="format.html#def_PICTURE"><span class="code">PICTURE</span></a> metadata block. More than one <span class="argument">--picture</span> command can be specified. The <span class="argument">SPECIFICATION</span> is a string whose parts are separated by <span class="argument">|</span> (pipe) characters. Some parts may be left empty to invoke default values. The format of <span class="argument">SPECIFICATION</span> is<br />
+ Import a picture and store it in a <a href="format.html#def_PICTURE"><span class="code">PICTURE</span></a> metadata block. More than one <span class="argument">--picture</span> command can be specified. Either a filename for the picture file or a more complete specification form can be used. The <span class="argument">SPECIFICATION</span> is a string whose parts are separated by | (pipe) characters. Some parts may be left empty to invoke default values. <span class="argument">FILENAME</span> is just shorthand for <span class="argument">||||FILENAME</span>. The format of <span class="argument">SPECIFICATION</span> is<br />
<br />
- <tt> [TYPE]|MIME-TYPE|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE</tt><br />
+ <tt> [TYPE]|[MIME-TYPE]|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE</tt><br />
<br />
<span class="argument">TYPE</span> is optional; it is a number from one of:<br />
<ul>
</ul>
The default is 3 (front cover). There may only be one picture each of type 1 and 2 in a file.<br/>
<br />
- <span class="argument">MIME-TYPE</span> is mandatory; for best compatibility with players, use pictures with MIME type <tt>image/jpeg</tt> or <tt>image/png</tt>. The MIME type can also be --> to mean that <span class="argument">FILE</span> is actually a URL to an image, though this use is discouraged.<br />
+ <span class="argument">MIME-TYPE</span> is optional; if left blank, it will be detected from the file. For best compatibility with players, use pictures with MIME type <tt>image/jpeg</tt> or <tt>image/png</tt>. The MIME type can also be --> to mean that <span class="argument">FILE</span> is actually a URL to an image, though this use is discouraged.<br />
<br />
<span class="argument">DESCRIPTION</span> is optional; the default is an empty string.<br />
<br />
<span class="argument">--no-seektable</span><br />
<span class="argument">--no-silent</span><br />
<span class="argument">--no-verify</span>
+ <span class="argument">--no-warnings-as-errors</span>
</td>
<td>
Can all be used to turn off a particular option.
<a href="#negative_options" /><span class="argument">--no-seektable</span></a><br />
<a href="#negative_options" /><span class="argument">--no-silent</span></a><br />
<a href="#negative_options" /><span class="argument">--no-verify</span></a><br />
+ <a href="#negative_options" /><span class="argument">--no-warnings-as-errors</span></a><br />
<a href="#flac_options_output_name" /><span class="argument">-o</span></a><br />
<a href="#flac_options_ogg" /><span class="argument">--ogg</span></a><br />
<a href="#flac_options_output_name" /><span class="argument">--output-name</span></a><br />
<a href="#flac_options_verify" /><span class="argument">-V</span></a><br />
<a href="#flac_options_version" /><span class="argument">-v</span></a><br />
<a href="#flac_options_verify" /><span class="argument">--verify</span></a><br />
+ <a href="#flac_options_warnings_as_errors" /><span class="argument">-w</span></a><br />
+ <a href="#flac_options_warnings_as_errors" /><span class="argument">--warnings-as-errors</span></a><br />
<a href="#flac_options_version" /><span class="argument">--version</span></a><br />
</div>
<tr>
<td nowrap="nowrap" align="right" valign="top" bgcolor="#F4F4CC">
<a name="metaflac_shorthand_import_picture_from" />
- <span class="argument">--import-picture-from=SPECIFICATION</span>
+ <span class="argument">--import-picture-from={FILENAME|SPECIFICATION}</span>
</td>
<td>
Import a picture and store it in a <a href="format.html#def_PICTURE"><span class="code">PICTURE</span></a> metadata block. See the <span class="commandname">flac</span> option <span class="argument"><a href="documentation_tools_flac.html#flac_options_picture">--picture</a></span> for an explanation of the <span class="argument">SPECIFICATION</span> syntax.
</varlistentry>
<varlistentry>
+ <term><option>-w</option>, <option>--warnings-as-errors</option>
+ </term>
+ <listitem>
+ <para>Treat all warnings as errors (which cause flac to terminate with a non-zero exit code).</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-f</option>, <option>--force</option>
</term>
<listitem>
</varlistentry>
<varlistentry>
- <term><option>--picture</option>=<replaceable>SPECIFICATION</replaceable></term>
+ <term><option>--picture</option>={<replaceable>FILENAME</replaceable>|<replaceable>SPECIFICATION</replaceable>}</term>
<listitem>
- <para>Import a picture and store it in a PICTURE metadata block. More than one --picture command can be specified. The SPECIFICATION is a string whose parts are separated by | (pipe) characters. Some parts may be left empty to invoke default values. The format of SPECIFICATION is</para>
- <para>[TYPE]|MIME-TYPE|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE</para>
+ <para>Import a picture and store it in a PICTURE metadata block. More than one --picture command can be specified. Either a filename for the picture file or a more complete specification form can be used. The SPECIFICATION is a string whose parts are separated by | (pipe) characters. Some parts may be left empty to invoke default values. FILENAME is just shorthand for "||||FILENAME". The format of SPECIFICATION is</para>
+ <para>[TYPE]|[MIME-TYPE]|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE</para>
<para>TYPE is optional; it is a number from one of:</para>
<para>0: Other</para>
<para>1: 32x32 pixels 'file icon' (PNG only)</para>
<para>20: Publisher/Studio logotype</para>
<para>The default is 3 (front cover). There may only be one picture each of type 1 and 2 in a file.</para>
- <para>MIME-TYPE is mandatory; for best compatibility with players, use pictures with MIME type image/jpeg or image/png. The MIME type can also be --> to mean that FILE is actually a URL to an image, though this use is discouraged.</para>
+ <para>MIME-TYPE is optional; if left blank, it will be detected from the file. For best compatibility with players, use pictures with MIME type image/jpeg or image/png. The MIME type can also be --> to mean that FILE is actually a URL to an image, though this use is discouraged.</para>
<para>DESCRIPTION is optional; the default is an empty string.</para>
<term><option>--no-seektable</option></term>
<term><option>--no-silent</option></term>
<term><option>--no-verify</option></term>
+ <term><option>--no-warnings-as-errors</option></term>
<listitem>
<para>These flags can be used to invert the sense of the corresponding normal option.</para>
</listitem>
FLAC__bool is_aiff_out;
FLAC__bool is_wave_out;
+ FLAC__bool treat_warnings_as_errors;
FLAC__bool continue_through_decode_errors;
FLAC__bool channel_map_none;
/*
* local routines
*/
-static FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool continue_through_decode_errors, FLAC__bool channel_map_none, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename);
+static FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool treat_warnings_as_errors, FLAC__bool continue_through_decode_errors, FLAC__bool channel_map_none, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename);
static void DecoderSession_destroy(DecoderSession *d, FLAC__bool error_occurred);
static FLAC__bool DecoderSession_init_decoder(DecoderSession *d, decode_options_t decode_options, const char *infilename);
static FLAC__bool DecoderSession_process(DecoderSession *d);
#endif
/*is_aiff_out=*/true,
/*is_wave_out=*/false,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
options.common.channel_map_none,
options.common.replaygain_synthesis_spec,
#endif
/*is_aiff_out=*/false,
/*is_wave_out=*/true,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
options.common.channel_map_none,
options.common.replaygain_synthesis_spec,
#endif
/*is_aiff_out=*/false,
/*is_wave_out=*/false,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
options.common.channel_map_none,
options.common.replaygain_synthesis_spec,
return DecoderSession_finish_ok(&decoder_session);
}
-FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool continue_through_decode_errors, FLAC__bool channel_map_none, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename)
+FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool treat_warnings_as_errors, FLAC__bool continue_through_decode_errors, FLAC__bool channel_map_none, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename)
{
#if FLAC__HAS_OGG
d->is_ogg = is_ogg;
d->is_aiff_out = is_aiff_out;
d->is_wave_out = is_wave_out;
+ d->treat_warnings_as_errors = treat_warnings_as_errors;
d->continue_through_decode_errors = continue_through_decode_errors;
d->channel_map_none = channel_map_none;
d->replaygain.spec = replaygain_synthesis_spec;
else {
if(!d->got_stream_info) {
flac__utils_printf(stderr, 1, "\r%s: WARNING, cannot check MD5 signature since there was no STREAMINFO\n", d->inbasefilename);
+ ok = !d->treat_warnings_as_errors;
}
else if(!d->has_md5sum) {
flac__utils_printf(stderr, 1, "\r%s: WARNING, cannot check MD5 signature since it was unset in the STREAMINFO\n", d->inbasefilename);
+ ok = !d->treat_warnings_as_errors;
}
flac__utils_printf(stderr, 2, "\r%s: %s \n", d->inbasefilename, d->test_only? "ok ":d->analysis_mode?"done ":"done");
}
flac__utils_printf(stderr, 1, "%s: WARNING, don't have accurate sample count available for %s header.\n", decoder_session->inbasefilename, fmt_desc);
flac__utils_printf(stderr, 1, " Generated %s file will have a data chunk size of 0. Try\n", fmt_desc);
flac__utils_printf(stderr, 1, " decoding directly to a file instead.\n");
+ if(decoder_session->treat_warnings_as_errors)
+ return false;
}
else {
decoder_session->iff_headers_need_fixup = true;
double reference, gain, peak;
if (!(decoder_session->replaygain.apply = grabbag__replaygain_load_from_vorbiscomment(metadata, decoder_session->replaygain.spec.use_album_gain, /*strict=*/false, &reference, &gain, &peak))) {
flac__utils_printf(stderr, 1, "%s: WARNING: can't get %s (or even %s) ReplayGain tags\n", decoder_session->inbasefilename, decoder_session->replaygain.spec.use_album_gain? "album":"track", decoder_session->replaygain.spec.use_album_gain? "track":"album");
+ if(decoder_session->treat_warnings_as_errors) {
+ decoder_session->abort_flag = true;
+ return;
+ }
}
else {
const char *ls[] = { "no", "peak", "hard" };
FLAC__replaygain_synthesis__init_dither_context(&decoder_session->replaygain.dither_context, decoder_session->bps, decoder_session->replaygain.spec.noise_shaping);
flac__utils_printf(stderr, 1, "%s: INFO: applying %s ReplayGain (gain=%0.2fdB+preamp=%0.1fdB, %s noise shaping, %s limiting) to output\n", decoder_session->inbasefilename, decoder_session->replaygain.spec.use_album_gain? "album":"track", gain, decoder_session->replaygain.spec.preamp, ns[decoder_session->replaygain.spec.noise_shaping], ls[decoder_session->replaygain.spec.limiter]);
flac__utils_printf(stderr, 1, "%s: WARNING: applying ReplayGain is not lossless\n", decoder_session->inbasefilename);
+ /* don't check if(decoder_session->treat_warnings_as_errors) because the user explicitly asked for it */
}
}
(void)flac__utils_get_channel_mask_tag(metadata, &decoder_session->channel_mask);
} replaygain_synthesis_spec_t;
typedef struct {
+ FLAC__bool treat_warnings_as_errors;
FLAC__bool continue_through_decode_errors;
replaygain_synthesis_spec_t replaygain_synthesis_spec;
#if FLAC__HAS_OGG
FLAC__uint64 skip;
FLAC__uint64 until; /* a value of 0 mean end-of-stream (i.e. --until=-0) */
+ FLAC__bool treat_warnings_as_errors;
FLAC__bool continue_through_decode_errors;
FLAC__bool replay_gain;
unsigned channels;
/*
* local routines
*/
-static FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FLAC__bool continue_through_decode_errors, FILE *infile, const char *infilename, const char *outfilename);
+static FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FLAC__bool treat_warnings_as_errors, FLAC__bool continue_through_decode_errors, FILE *infile, const char *infilename, const char *outfilename);
static void EncoderSession_destroy(EncoderSession *e);
static int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_align_zero);
static int EncoderSession_finish_error(EncoderSession *e);
static FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
static void flac_decoder_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
static void flac_decoder_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-static FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset);
+static FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool treat_warnings_as_errors);
static void print_stats(const EncoderSession *encoder_session);
static void print_error_with_init_status(const EncoderSession *e, const char *message, FLAC__StreamEncoderInitStatus init_status);
static void print_error_with_state(const EncoderSession *e, const char *message);
/*use_ogg=*/false,
#endif
options.common.verify,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
infile,
infilename,
}
else if(!is_aifc && xx!=minimum_comm_size) {
flac__utils_printf(stderr, 1, "%s: WARNING: non-standard %s 'COMM' chunk has length = %u, expected %u\n", encoder_session.inbasefilename, is_aifc? "AIFF-C" : "AIFF", (unsigned int)xx, minimum_comm_size);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
skip= (xx-minimum_comm_size)+(xx & 1U);
}
else if(feof(infile)) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
data_bytes= 0;
}
}
}
else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_frame) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)bytes_read, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else {
info_align_carry= *options.common.align_reservoir_samples;
else { /* other chunk */
if(!memcmp(chunk_id, "COMM", 4)) {
flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'COMM' chunk\n", encoder_session.inbasefilename);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else if(!memcmp(chunk_id, "SSND", 4)) {
flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'SSND' chunk\n", encoder_session.inbasefilename);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else {
flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown chunk '%s'\n", encoder_session.inbasefilename, chunk_id);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
/* chunk size */
/*use_ogg=*/false,
#endif
options.common.verify,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
infile,
infilename,
if(bps == 24 || bps == 32) {
/* let these slide with a warning since they're unambiguous */
flac__utils_printf(stderr, 1, "%s: WARNING: legacy WAVE file has format type %u but bits-per-sample=%u\n", encoder_session.inbasefilename, (unsigned)format, bps);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else {
/* @@@ we could add an option to specify left- or right-justified blocks so we knew how to set 'shift' */
if(bps % 8) {
/* assume legacy file is byte aligned with some LSBs zero; this is double-checked in format_input() */
flac__utils_printf(stderr, 1, "%s: WARNING: legacy WAVE file (format type %d) has block alignment=%u, bits-per-sample=%u, channels=%u\n", encoder_session.inbasefilename, (unsigned)format, block_align, bps, channels);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
shift = 8 - (bps % 8);
bps += shift;
}
}
else if(feof(infile)) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
data_bytes = 0;
}
}
}
else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_wide_sample) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)bytes_read, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else {
info_align_carry = *options.common.align_reservoir_samples;
else {
if(xx == 0x20746d66 && got_fmt_chunk) { /* "fmt " */
flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'fmt ' sub-chunk\n", encoder_session.inbasefilename);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else if(xx == 0x61746164) { /* "data" */
if(got_data_chunk) {
flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'data' sub-chunk\n", encoder_session.inbasefilename);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else if(!got_fmt_chunk) {
flac__utils_printf(stderr, 1, "%s: ERROR: got 'data' sub-chunk before 'fmt' sub-chunk\n", encoder_session.inbasefilename);
}
else {
flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown sub-chunk '%c%c%c%c'\n", encoder_session.inbasefilename, (char)(xx&255), (char)((xx>>8)&255), (char)((xx>>16)&255), (char)(xx>>24));
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
/* sub-chunk size */
if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
/*use_ogg=*/false,
#endif
options.common.verify,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
infile,
infilename,
}
else if(feof(infile)) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
total_input_bytes_read = max_input_bytes;
}
}
}
else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_wide_sample) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)bytes_read, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else {
info_align_carry = *options.common.align_reservoir_samples;
/*use_ogg=*/false,
#endif
options.common.verify,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
infile,
infilename,
return EncoderSession_finish_error(&encoder_session);
}
-FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FLAC__bool continue_through_decode_errors, FILE *infile, const char *infilename, const char *outfilename)
+FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FLAC__bool treat_warnings_as_errors, FLAC__bool continue_through_decode_errors, FILE *infile, const char *infilename, const char *outfilename)
{
unsigned i;
FLAC__uint32 test = 1;
(void)use_ogg;
#endif
e->verify = verify;
+ e->treat_warnings_as_errors = treat_warnings_as_errors;
e->continue_through_decode_errors = continue_through_decode_errors;
e->is_stdout = (0 == strcmp(outfilename, "-"));
}
}
- if(!parse_cuesheet(&cuesheet, options.cuesheet_filename, e->inbasefilename, is_cdda, e->total_samples_to_encode))
+ if(!parse_cuesheet(&cuesheet, options.cuesheet_filename, e->inbasefilename, is_cdda, e->total_samples_to_encode, e->treat_warnings_as_errors))
return false;
if(!convert_to_seek_table_template(options.requested_seek_points, options.num_requested_seek_points, options.cued_seekpoints? cuesheet : 0, e)) {
if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_VORBIS_COMMENT && options.vorbis_comment->data.vorbis_comment.num_comments > 0) {
(void) flac__utils_get_channel_mask_tag(flac_decoder_data->metadata_blocks[i], &channel_mask);
flac__utils_printf(stderr, 1, "%s: WARNING, replacing tags from input FLAC file with those given on the command-line\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ if(0 != cuesheet)
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
FLAC__metadata_object_delete(flac_decoder_data->metadata_blocks[i]);
flac_decoder_data->metadata_blocks[i] = 0;
}
const FLAC__StreamMetadata_CueSheet *cs = &flac_decoder_data->metadata_blocks[i]->data.cue_sheet;
if(e->total_samples_to_encode == 0) {
flac__utils_printf(stderr, 1, "%s: WARNING, cuesheet in input FLAC file cannot be kept if input size is not known, dropping it...\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ if(0 != cuesheet)
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
existing_cuesheet_is_bad = true;
}
else if(e->total_samples_to_encode != cs->tracks[cs->num_tracks-1].offset) {
flac__utils_printf(stderr, 1, "%s: WARNING, lead-out offset of cuesheet in input FLAC file does not match input length, dropping existing cuesheet...\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ if(0 != cuesheet)
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
existing_cuesheet_is_bad = true;
}
}
if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_CUESHEET && (existing_cuesheet_is_bad || 0 != cuesheet)) {
- if(0 != cuesheet)
+ if(0 != cuesheet) {
flac__utils_printf(stderr, 1, "%s: WARNING, replacing cuesheet in input FLAC file with the one given on the command-line\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
+ }
FLAC__metadata_object_delete(flac_decoder_data->metadata_blocks[i]);
flac_decoder_data->metadata_blocks[i] = 0;
}
if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_SEEKTABLE)
existing_seektable = true;
if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_SEEKTABLE && (e->total_samples_to_encode != flac_decoder_data->metadata_blocks[0]->data.stream_info.total_samples || options.num_requested_seek_points >= 0)) {
- if(options.num_requested_seek_points > 0)
+ if(options.num_requested_seek_points > 0) {
flac__utils_printf(stderr, 1, "%s: WARNING, replacing seektable in input FLAC file with the one given on the command-line\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ if(0 != cuesheet)
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
+ }
else if(options.num_requested_seek_points == 0)
; /* no warning, silently delete existing SEEKTABLE since user specified --no-seektable (-S-) */
- else
+ else {
flac__utils_printf(stderr, 1, "%s: WARNING, can't use existing seektable in input FLAC since the input size is changing or unknown, dropping existing SEEKTABLE block...\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ if(0 != cuesheet)
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
+ }
FLAC__metadata_object_delete(flac_decoder_data->metadata_blocks[i]);
flac_decoder_data->metadata_blocks[i] = 0;
existing_seektable = false;
if(e->replay_gain) {
if(!grabbag__replaygain_analyze(buffer, e->channels==2, e->bits_per_sample, samples)) {
flac__utils_printf(stderr, 1, "%s: WARNING, error while calculating ReplayGain\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors)
+ return false;
}
}
if(has_real_points) {
if(e->is_stdout) {
flac__utils_printf(stderr, 1, "%s: WARNING, cannot write back seekpoints when encoding to stdout\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors)
+ return false;
}
}
data->fatal_error = true;
}
-FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset)
+FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool treat_warnings_as_errors)
{
FILE *f;
unsigned last_line_read;
/* if we're expecting CDDA, warn about non-compliance */
if(is_cdda && !FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/true, &error_message)) {
flac__utils_printf(stderr, 1, "%s: WARNING cuesheet \"%s\" is not audio CD compliant: %s\n", inbasefilename, cuesheet_filename, error_message);
+ if(treat_warnings_as_errors)
+ return false;
(*cuesheet)->data.cue_sheet.is_cd = false;
}
char *requested_seek_points;
int num_requested_seek_points;
const char *cuesheet_filename;
+ FLAC__bool treat_warnings_as_errors;
FLAC__bool continue_through_decode_errors; /* currently only obeyed when encoding from FLAC or Ogg FLAC */
FLAC__bool cued_seekpoints;
FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */
/*
* general options
*/
- { "help" , share__no_argument, 0, 'h' },
- { "explain" , share__no_argument, 0, 'H' },
- { "version" , share__no_argument, 0, 'v' },
- { "decode" , share__no_argument, 0, 'd' },
- { "analyze" , share__no_argument, 0, 'a' },
- { "test" , share__no_argument, 0, 't' },
- { "stdout" , share__no_argument, 0, 'c' },
- { "silent" , share__no_argument, 0, 's' },
- { "totally-silent" , share__no_argument, 0, 0 },
- { "force" , share__no_argument, 0, 'f' },
- { "delete-input-file", share__no_argument, 0, 0 },
- { "output-prefix" , share__required_argument, 0, 0 },
- { "output-name" , share__required_argument, 0, 'o' },
- { "skip" , share__required_argument, 0, 0 },
- { "until" , share__required_argument, 0, 0 },
- { "channel-map" , share__required_argument, 0, 0 }, /* undocumented */
+ { "help" , share__no_argument, 0, 'h' },
+ { "explain" , share__no_argument, 0, 'H' },
+ { "version" , share__no_argument, 0, 'v' },
+ { "decode" , share__no_argument, 0, 'd' },
+ { "analyze" , share__no_argument, 0, 'a' },
+ { "test" , share__no_argument, 0, 't' },
+ { "stdout" , share__no_argument, 0, 'c' },
+ { "silent" , share__no_argument, 0, 's' },
+ { "totally-silent" , share__no_argument, 0, 0 },
+ { "warnings-as-errors", share__no_argument, 0, 'w' },
+ { "force" , share__no_argument, 0, 'f' },
+ { "delete-input-file" , share__no_argument, 0, 0 },
+ { "output-prefix" , share__required_argument, 0, 0 },
+ { "output-name" , share__required_argument, 0, 'o' },
+ { "skip" , share__required_argument, 0, 0 },
+ { "until" , share__required_argument, 0, 0 },
+ { "channel-map" , share__required_argument, 0, 0 }, /* undocumented */
/*
* decoding options
{ "no-qlp-coeff-prec-search" , share__no_argument, 0, 0 },
{ "no-padding" , share__no_argument, 0, 0 },
{ "no-verify" , share__no_argument, 0, 0 },
+ { "no-warnings-as-errors" , share__no_argument, 0, 0 },
{ "no-residual-gnuplot" , share__no_argument, 0, 0 },
{ "no-residual-text" , share__no_argument, 0, 0 },
/*
FLAC__bool show_version;
FLAC__bool mode_decode;
FLAC__bool verify;
+ FLAC__bool treat_warnings_as_errors;
FLAC__bool force_file_overwrite;
FLAC__bool continue_through_decode_errors;
replaygain_synthesis_spec_t replaygain_synthesis_spec;
option_values.show_explain = false;
option_values.mode_decode = false;
option_values.verify = false;
+ option_values.treat_warnings_as_errors = false;
option_values.force_file_overwrite = false;
option_values.continue_through_decode_errors = false;
option_values.replaygain_synthesis_spec.apply = false;
int short_option;
int option_index = 1;
FLAC__bool had_error = false;
- const char *short_opts = "0123456789aA:b:cdefFhHl:mMo:pP:q:r:sS:tT:vV";
+ const char *short_opts = "0123456789aA:b:cdefFhHl:mMo:pP:q:r:sS:tT:vVw";
while ((short_option = share__getopt_long(argc, argv, short_opts, long_options_, &option_index)) != -1) {
switch (short_option) {
else if(0 == strcmp(long_option, "no-verify")) {
option_values.verify = false;
}
+ else if(0 == strcmp(long_option, "no-warnings-as-errors")) {
+ option_values.treat_warnings_as_errors = false;
+ }
else if(0 == strcmp(long_option, "no-residual-gnuplot")) {
option_values.aopts.do_residual_gnuplot = false;
}
case 'V':
option_values.verify = true;
break;
+ case 'w':
+ option_values.treat_warnings_as_errors = true;
+ break;
case 'S':
FLAC__ASSERT(0 != option_argument);
if(0 == strcmp(option_argument, "-")) {
printf(" -c, --stdout Write output to stdout\n");
printf(" -s, --silent Do not write runtime encode/decode statistics\n");
printf(" --totally-silent Do not print anything, including errors\n");
+ printf(" -w, --warnings-as-errors Treat all warnings as errors\n");
printf(" -f, --force Force overwriting of output files\n");
printf(" -o, --output-name=FILENAME Force the output file name\n");
printf(" --output-prefix=STRING Prepend STRING to output names\n");
printf(" --no-silent\n");
printf(" --no-force\n");
printf(" --no-verify\n");
+ printf(" --no-warnings-as-errors\n");
}
void show_explain(void)
printf(" --totally-silent Do not print anything of any kind, including\n");
printf(" warnings or errors. The exit code will be the\n");
printf(" only way to determine successful completion.\n");
+ printf(" -w, --warnings-as-errors Treat all warnings as errors\n");
printf(" -f, --force Force overwriting of output files\n");
printf(" -o, --output-name=FILENAME Force the output file name; usually flac just\n");
printf(" changes the extension. May only be used when\n");
printf(" --no-cued-seekpoints is specified.\n");
printf(" --picture=SPECIFICATION Import a picture and store it in a PICTURE block.\n");
printf(" More than one --picture command can be specified.\n");
- printf(" The SPECIFICATION is a string whose parts are\n");
- printf(" separated by | characters. Some parts may be\n");
- printf(" left empty to invoke default values. The format:\n");
- printf(" [TYPE]|MIME-TYPE|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE\n");
+ printf(" The SPECIFICATION can either be a simple filename\n");
+ printf(" for the picture file, or a complete specification\n");
+ printf(" whose parts are separated by | characters. Some\n");
+ printf(" parts may be left empty to invoke default values.\n");
+ printf(" Using a filename is shorthand for \"||||FILE\".\n");
+ printf(" The SPECIFICATION format is:\n");
+ printf(" [TYPE]|[MIME-TYPE]|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE\n");
printf(" TYPE is optional; it is a number from one of:\n");
printf(" 0: Other\n");
printf(" 1: 32x32 pixels 'file icon' (PNG only)\n");
printf(" 20: Publisher/Studio logotype\n");
printf(" The default is 3 (front cover). There may only be one picture each\n");
printf(" of type 1 and 2 in a file.\n");
- printf(" MIME-TYPE is mandatory; for best compatibility with players, use\n");
- printf(" pictures with MIME type image/jpeg or image/png. The MIME type can\n");
- printf(" also be --> to mean that FILE is actually a URL to an image, though\n");
- printf(" this use is discouraged.\n");
+ printf(" MIME-TYPE is optional; if left blank, it will be detected from the\n");
+ printf(" file. For best compatibility with players, use pictures with MIME\n");
+ printf(" type image/jpeg or image/png. The MIME type can also be --> to\n");
+ printf(" mean that FILE is actually a URL to an image, though this use is\n");
+ printf(" discouraged.\n");
printf(" DESCRIPTION is optional; the default is an empty string\n");
printf(" The next part specfies the resolution and color information. If\n");
printf(" the MIME-TYPE is image/jpeg, image/png, or image/gif, you can\n");
printf(" --no-silent\n");
printf(" --no-force\n");
printf(" --no-verify\n");
+ printf(" --no-warnings-as-errors\n");
}
void format_mistake(const char *infilename, FileFormat wrong, FileFormat right)
/* attempt to guess the file type based on the first 12 bytes */
if((lookahead_length = fread(lookahead, 1, 12, encode_infile)) < 12) {
- if(fmt != RAW)
+ if(fmt != RAW) {
format_mistake(infilename, fmt, RAW);
+ if(option_values.treat_warnings_as_errors) {
+ conditional_fclose(encode_infile);
+ return 1;
+ }
+ }
fmt= RAW;
}
else {
else if(!memcmp(lookahead, "OggS", 4))
fmt= OGGFLAC;
else {
- if(fmt != RAW)
+ if(fmt != RAW) {
format_mistake(infilename, fmt, RAW);
+ if(option_values.treat_warnings_as_errors) {
+ conditional_fclose(encode_infile);
+ return 1;
+ }
+ }
fmt= RAW;
}
}
common_options.until_specification.is_relative = true;
common_options.verify = option_values.verify;
+ common_options.treat_warnings_as_errors = option_values.treat_warnings_as_errors;
#if FLAC__HAS_OGG
common_options.use_ogg = option_values.use_ogg;
/* set a random serial number if one has not yet been specified */
else
common_options.has_cue_specification = false;
+ common_options.treat_warnings_as_errors = option_values.treat_warnings_as_errors;
common_options.continue_through_decode_errors = option_values.continue_through_decode_errors;
common_options.replaygain_synthesis_spec = option_values.replaygain_synthesis_spec;
#if FLAC__HAS_OGG