make --serial-number or the default random serial number apply only to the first stream, and increment it for subsequent streams

This commit is contained in:
Josh Coalson 2004-07-16 01:05:28 +00:00
parent 47f51b1c22
commit 0b695a6eac
5 changed files with 18 additions and 21 deletions

View File

@ -420,7 +420,7 @@
<TT>--serial-number=#</TT>
</TD>
<TD>
When used with --ogg, specifies the serial number to use the for the FLAC stream. When encoding and no serial number is given, flac uses '0'. When decoding and no number is given, flac uses the serial number of the first page.<P>
When used with --ogg, specifies the serial number to use for the first Ogg FLAC stream, which is then incremented for each additional stream. When encoding and no serial number is given, <TT><B>flac</B></TT> uses a random number for the first stream, then increments it for each additional stream. When decoding and no number is given, <TT><B>flac</B></TT> uses the serial number of the first page.<P>
</TD>
</TR>
</TABLE>

View File

@ -240,11 +240,13 @@
<term><option>--serial-number</option>=<replaceable>#</replaceable></term>
<listitem>
<para>When used with --ogg, specifies the serial
number to use for the FLAC stream. When encoding and
no serial number is given, flac uses '0'. When
decoding and no number is given, flac uses the serial
number of the first page.</para>
<para>When used with --ogg, specifies the serial number to
use for the first Ogg FLAC stream, which is then
incremented for each additional stream. When encoding and
no serial number is given, flac uses a random number for
the first stream, then increments it for each additional
stream. When decoding and no number is given, flac uses
the serial number of the first page.</para>
</listitem>
</varlistentry>

View File

@ -28,7 +28,6 @@
#include <stdio.h> /* for FILE etc. */
#include <stdlib.h> /* for malloc */
#include <string.h> /* for strcmp() */
#include <time.h>
#include "FLAC/all.h"
#include "share/grabbag.h"
#include "encode.h"
@ -1460,18 +1459,10 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
e->blocksize = options.blocksize;
e->stats_mask = (options.do_exhaustive_model_search || options.do_qlp_coeff_prec_search)? 0x0f : 0x3f;
/* set a random serial number if one has not yet been specified */
if(!options.has_serial_number) {
srand(time(0));
options.serial_number = rand();
options.has_serial_number = true;
}
#ifdef FLAC__HAS_OGG
if(e->use_ogg) {
if(e->is_stdout) {
if(options.has_serial_number)
OggFLAC__stream_encoder_set_serial_number(e->encoder.ogg.stream, options.serial_number);
OggFLAC__stream_encoder_set_serial_number(e->encoder.ogg.stream, options.serial_number);
OggFLAC__stream_encoder_set_verify(e->encoder.ogg.stream, options.verify);
OggFLAC__stream_encoder_set_streamable_subset(e->encoder.ogg.stream, !options.lax);
OggFLAC__stream_encoder_set_do_mid_side_stereo(e->encoder.ogg.stream, options.do_mid_side);
@ -1506,8 +1497,7 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
}
}
else {
if(options.has_serial_number)
OggFLAC__file_encoder_set_serial_number(e->encoder.ogg.file, options.serial_number);
OggFLAC__file_encoder_set_serial_number(e->encoder.ogg.file, options.serial_number);
OggFLAC__file_encoder_set_filename(e->encoder.ogg.file, e->outfilename);
OggFLAC__file_encoder_set_verify(e->encoder.ogg.file, options.verify);
OggFLAC__file_encoder_set_streamable_subset(e->encoder.ogg.file, !options.lax);

View File

@ -33,7 +33,6 @@ typedef struct {
FLAC__bool verify;
#ifdef FLAC__HAS_OGG
FLAC__bool use_ogg;
FLAC__bool has_serial_number;
long serial_number;
#endif
FLAC__bool lax;

View File

@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -1510,8 +1511,13 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
common_options.verify = option_values.verify;
#ifdef FLAC__HAS_OGG
common_options.use_ogg = option_values.use_ogg;
common_options.has_serial_number = option_values.has_serial_number;
common_options.serial_number = option_values.serial_number;
/* set a random serial number if one has not yet been specified */
if(!option_values.has_serial_number) {
srand(time(0));
option_values.serial_number = rand();
option_values.has_serial_number = true;
}
common_options.serial_number = option_values.serial_number++;
#endif
common_options.lax = option_values.lax;
common_options.do_mid_side = option_values.do_mid_side;