add --input-size option to flac
authorJosh Coalson <jcoalson@users.sourceforce.net>
Thu, 14 Oct 2004 05:00:59 +0000 (05:00 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Thu, 14 Oct 2004 05:00:59 +0000 (05:00 +0000)
doc/html/documentation.html
man/flac.sgml
src/flac/main.c

index bbdd204f3800b8fd219c542d3b5756753de1abdb..f13bd0382b4558b7267354126dcd73a2c21116bb 100644 (file)
                                Specify that the samples in the raw file are signed or unsigned (the default is signed).
                        </TD>
                </TR>
+               <TR>
+                       <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
+                               <A NAME="flac_options_input_size">
+                               <TT>--input-size=#</TT>
+                       </TD>
+                       <TD>
+                               Specify the size of the raw input in bytes.  If you are encoding raw samples from stdin, you must set this option in order to be able to use --skip, --until, --cue-sheet, or other options that need to know the size of the input beforehand.  If the size given is greater than what is found in the input stream, the encoder will complain about an unexpected end-of-file.  If the size given is less, samples will be truncated.
+                       </TD>
+               </TR>
                <TR>
                        <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
                                <A NAME="flac_options_force_aiff_format">
index 489f10feb3f1d036e805ca767785241085bcac4e..c80a989ae87f9cf39d72b0a499eefb2840057296 100644 (file)
                </listitem>
              </varlistentry>
 
+             <varlistentry>
+               <term><option>--input-size</option>=<replaceable>#</replaceable></term>
+
+               <listitem>
+                 <para>Specify the size of the raw input in bytes.  If you are
+                   encoding raw samples from stdin, you must set this option
+                   in order to be able to use --skip, --until, --cue-sheet, or
+                   other options that need to know the size of the input
+                   beforehand.  If the size given is greater than what is
+                   found in the input stream, the encoder will complain about
+                   an unexpected end-of-file.  If the size given is less,
+                   samples will be truncated.</para>
+               </listitem>
+             </varlistentry>
+
              <varlistentry>
                <term><option>--force-aiff-format</option></term>
 
index 0fa01fc8949be5a4a9f816c57c115deaa85dbac6..ebab49569b7f7c6ffdba0db2fa2fb825ae84b881 100644 (file)
@@ -153,6 +153,7 @@ static struct share__option long_options_[] = {
        { "bps"                       , share__required_argument, 0, 0 },
        { "sample-rate"               , share__required_argument, 0, 0 },
        { "sign"                      , share__required_argument, 0, 0 },
+       { "input-size"                , share__required_argument, 0, 0 },
 
        /*
         * analysis options
@@ -237,6 +238,7 @@ static struct {
        int format_channels;
        int format_bps;
        int format_sample_rate;
+       long format_input_size;
        int blocksize;
        int min_residual_partition_order;
        int max_residual_partition_order;
@@ -574,6 +576,7 @@ FLAC__bool init_options()
        option_values.format_channels = -1;
        option_values.format_bps = -1;
        option_values.format_sample_rate = -1;
+       option_values.format_input_size = -1;
        option_values.blocksize = -1;
        option_values.min_residual_partition_order = -1;
        option_values.max_residual_partition_order = -1;
@@ -661,6 +664,10 @@ int parse_option(int short_option, const char *long_option, const char *option_a
                        FLAC__ASSERT(0 != option_argument);
                        option_values.until_specification = option_argument;
                }
+               else if(0 == strcmp(long_option, "input-size")) {
+                       FLAC__ASSERT(0 != option_argument);
+                       option_values.format_input_size = atol(option_argument);
+               }
                else if(0 == strcmp(long_option, "cue")) {
                        FLAC__ASSERT(0 != option_argument);
                        option_values.cue_specification = option_argument;
@@ -1202,6 +1209,7 @@ void show_help()
        printf("      --bps=#                  Number of bits per sample\n");
        printf("      --sample-rate=#          Sample rate in Hz\n");
        printf("      --sign={signed|unsigned} Sign of samples\n");
+       printf("      --input-size=#           Size of the raw input in bytes\n");
        printf("      --force-aiff-format      Force decoding to AIFF format\n");
        printf("      --force-raw-format       Treat input or output as raw samples\n");
        printf("negative options:\n");
@@ -1420,6 +1428,15 @@ void show_explain()
        printf("      --bps=#                  Number of bits per sample\n");
        printf("      --sample-rate=#          Sample rate in Hz\n");
        printf("      --sign={signed|unsigned} Sign of samples (the default is signed)\n");
+       printf("      --input-size=#           Size of the raw input in bytes.  If you are\n");
+       printf("                               encoding raw samples from stdin, you must set\n");
+       printf("                               this option in order to be able to use --skip,\n");
+       printf("                               --until, --cue-sheet, or other options that need\n");
+       printf("                               to know the size of the input beforehand.  If\n");
+       printf("                               the size given is greater than what is found in\n");
+       printf("                               the input stream, the encoder will complain\n");
+       printf("                               about an unexpected end-of-file.  If the size\n");
+       printf("                               given is less, samples will be truncated.\n");
        printf("      --force-aiff-format      Force the decoder to output AIFF format.  This\n");
        printf("                               option is not needed if the output filename (as\n");
        printf("                               set by -o) ends with .aif or .aiff; this option\n");
@@ -1518,6 +1535,14 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
                }
        }
 
+       if(option_values.format_input_size >= 0 && (fmt != RAW || infilesize >= 0)) {
+               flac__utils_printf(stderr, 1, "ERROR: can only use --input-size when encoding raw samples from stdin\n");
+               return 1;
+       }
+       else {
+               infilesize = option_values.format_input_size;
+       }
+
        if(option_values.sector_align && fmt == RAW && infilesize < 0) {
                flac__utils_printf(stderr, 1, "ERROR: can't --sector-align when the input size is unknown\n");
                return 1;