Commit f742b93b authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

flac: Implement --no-error-on-compression-fail command line option.

This is designed for the test suite where a number of artificially created
files end up bigger than the original.
parent 3418acc1
......@@ -129,7 +129,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, unsigned 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);
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_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[], unsigned samples);
......@@ -1489,7 +1489,8 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena
&encoder_session,
info_align_carry,
info_align_zero,
EncoderSession_format_is_iff(&encoder_session)? options.format_options.iff.foreign_metadata : 0
EncoderSession_format_is_iff(&encoder_session)? options.format_options.iff.foreign_metadata : 0,
options.error_on_compression_fail
);
}
......@@ -1608,7 +1609,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)
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)
{
FLAC__StreamEncoderState fse_state = FLAC__STREAM_ENCODER_OK;
int ret = 0;
......@@ -1652,7 +1653,7 @@ int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_a
}
}
if (e->compression_ratio >= 1.0) {
if (error_on_compression_fail && e->compression_ratio >= 1.0) {
flac__utils_printf(stderr, 1, "ERROR: Compression failed (ratio %0.3f, should be < 1.0). Please contact the developers.\n", e->compression_ratio);
ret = 1;
}
......
......@@ -84,6 +84,7 @@ typedef struct {
FLAC__bool replay_gain;
FLAC__bool ignore_chunk_sizes;
FLAC__bool sector_align;
FLAC__bool error_on_compression_fail;
FLAC__StreamMetadata *vorbis_comment;
FLAC__StreamMetadata *pictures[64];
......
......@@ -207,6 +207,7 @@ static struct share__option long_options_[] = {
{ "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 },
{ "no-error-on-compression-fail", share__no_argument, 0, 0 },
/*
* undocumented debugging options for the test suite
*/
......@@ -271,6 +272,7 @@ static struct {
const char *cuesheet_filename;
FLAC__bool cued_seekpoints;
FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */
FLAC__bool error_on_compression_fail;
unsigned num_files;
char **filenames;
......@@ -594,6 +596,7 @@ FLAC__bool init_options(void)
option_values.cuesheet_filename = 0;
option_values.cued_seekpoints = true;
option_values.channel_map_none = false;
option_values.error_on_compression_fail = true;
option_values.num_files = 0;
option_values.filenames = 0;
......@@ -908,6 +911,9 @@ int parse_option(int short_option, const char *long_option, const char *option_a
else if(0 == strcmp(long_option, "no-md5-sum")) {
option_values.debug.do_md5 = false;
}
else if(0 == strcmp(long_option, "no-error-on-compression-fail")) {
option_values.error_on_compression_fail = false;
}
}
else {
switch(short_option) {
......@@ -1901,6 +1907,7 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
encode_options.debug.disable_fixed_subframes = option_values.debug.disable_fixed_subframes;
encode_options.debug.disable_verbatim_subframes = option_values.debug.disable_verbatim_subframes;
encode_options.debug.do_md5 = option_values.debug.do_md5;
encode_options.error_on_compression_fail = option_values.error_on_compression_fail;
/* if infilename and outfilename point to the same file, we need to write to a temporary file */
if(encode_infile != stdin && grabbag__file_are_same(infilename, outfilename)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment