add --no-md5-sum
authorJosh Coalson <jcoalson@users.sourceforce.net>
Tue, 19 Jun 2007 04:18:45 +0000 (04:18 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Tue, 19 Jun 2007 04:18:45 +0000 (04:18 +0000)
src/flac/encode.c
src/flac/encode.h
src/flac/main.c

index 0b0e89d..cde28d0 100644 (file)
@@ -116,6 +116,7 @@ static FLAC__int32 *input_[FLAC__MAX_CHANNELS];
 extern FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
 extern FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
 extern FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
+extern FLAC__bool FLAC__stream_encoder_set_do_md5(FLAC__StreamEncoder *encoder, FLAC__bool value);
 
 /*
  * local routines
@@ -151,7 +152,9 @@ static FLAC__bool read_big_endian_uint32(FILE *f, FLAC__uint32 *val, FLAC__bool
 static FLAC__bool read_sane_extended(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn);
 static FLAC__bool fskip_ahead(FILE *f, FLAC__uint64 offset);
 static unsigned count_channel_mask_bits(FLAC__uint32 mask);
+#if 0
 static FLAC__uint32 limit_channel_mask(FLAC__uint32 mask, unsigned channels);
+#endif
 
 /*
  * public routines
@@ -2073,6 +2076,15 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
        FLAC__stream_encoder_disable_constant_subframes(e->encoder, options.debug.disable_constant_subframes);
        FLAC__stream_encoder_disable_fixed_subframes(e->encoder, options.debug.disable_fixed_subframes);
        FLAC__stream_encoder_disable_verbatim_subframes(e->encoder, options.debug.disable_verbatim_subframes);
+       if(!options.debug.do_md5) {
+               flac__utils_printf(stderr, 1, "%s: WARNING, MD5 computation disabled, resulting file will not have MD5 sum\n", e->inbasefilename);
+               if(e->treat_warnings_as_errors) {
+                       if(0 != cuesheet)
+                               FLAC__metadata_object_delete(cuesheet);
+                       return false;
+               }
+               FLAC__stream_encoder_set_do_md5(e->encoder, false);
+       }
 
 #if FLAC__HAS_OGG
        if(e->use_ogg) {
@@ -2797,6 +2809,7 @@ unsigned count_channel_mask_bits(FLAC__uint32 mask)
        return count;
 }
 
+#if 0
 FLAC__uint32 limit_channel_mask(FLAC__uint32 mask, unsigned channels)
 {
        FLAC__uint32 x = 0x80000000;
@@ -2811,3 +2824,4 @@ FLAC__uint32 limit_channel_mask(FLAC__uint32 mask, unsigned channels)
        FLAC__ASSERT(count_channel_mask_bits(mask) == channels);
        return mask;
 }
+#endif
index 183f1b5..b98586d 100644 (file)
@@ -94,6 +94,7 @@ typedef struct {
                FLAC__bool disable_constant_subframes;
                FLAC__bool disable_fixed_subframes;
                FLAC__bool disable_verbatim_subframes;
+               FLAC__bool do_md5;
        } debug;
 } encode_options_t;
 
index 9a59c7b..2a58217 100644 (file)
@@ -207,6 +207,7 @@ static struct share__option long_options_[] = {
        { "disable-constant-subframes", share__no_argument, 0, 0 },
        { "disable-fixed-subframes"   , share__no_argument, 0, 0 },
        { "disable-verbatim-subframes", share__no_argument, 0, 0 },
+       { "no-md5-sum"                , share__no_argument, 0, 0 },
 
        {0, 0, 0, 0}
 };
@@ -270,6 +271,7 @@ static struct {
                FLAC__bool disable_constant_subframes;
                FLAC__bool disable_fixed_subframes;
                FLAC__bool disable_verbatim_subframes;
+               FLAC__bool do_md5;
        } debug;
 } option_values;
 
@@ -557,6 +559,7 @@ FLAC__bool init_options(void)
        option_values.debug.disable_constant_subframes = false;
        option_values.debug.disable_fixed_subframes = false;
        option_values.debug.disable_verbatim_subframes = false;
+       option_values.debug.do_md5 = true;
 
        return true;
 }
@@ -834,6 +837,9 @@ int parse_option(int short_option, const char *long_option, const char *option_a
                else if(0 == strcmp(long_option, "disable-verbatim-subframes")) {
                        option_values.debug.disable_verbatim_subframes = true;
                }
+               else if(0 == strcmp(long_option, "no-md5-sum")) {
+                       option_values.debug.do_md5 = false;
+               }
        }
        else {
                switch(short_option) {
@@ -1731,6 +1737,7 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
        common_options.debug.disable_constant_subframes = option_values.debug.disable_constant_subframes;
        common_options.debug.disable_fixed_subframes = option_values.debug.disable_fixed_subframes;
        common_options.debug.disable_verbatim_subframes = option_values.debug.disable_verbatim_subframes;
+       common_options.debug.do_md5 = option_values.debug.do_md5;
 
        /* 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)) {