[xiph-cvs] cvs commit: speex/src speexdec.c speexenc.c
Jean-Marc Valin
jm at xiph.org
Tue Jan 20 00:08:52 PST 2004
jm 04/01/20 03:08:51
Modified: src speexdec.c speexenc.c
Log:
added --quiet switch
Revision Changes Path
1.86 +24 -15 speex/src/speexdec.c
Index: speexdec.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexdec.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- speexdec.c 4 Dec 2003 21:29:19 -0000 1.85
+++ speexdec.c 20 Jan 2004 08:08:51 -0000 1.86
@@ -292,7 +292,7 @@
printf ("Copyright (C) 2002-2003 Jean-Marc Valin\n");
}
-static void *process_header(ogg_packet *op, int enh_enabled, int *frame_size, int *rate, int *nframes, int forceMode, int *channels, SpeexStereoState *stereo, int *extra_headers)
+static void *process_header(ogg_packet *op, int enh_enabled, int *frame_size, int *rate, int *nframes, int forceMode, int *channels, SpeexStereoState *stereo, int *extra_headers, int quiet)
{
void *st;
const SpeexMode *mode;
@@ -369,20 +369,23 @@
if (*channels==-1)
*channels = header->nb_channels;
- fprintf (stderr, "Decoding %d Hz audio using %s mode",
- *rate, mode->modeName);
+ if (!quiet)
+ {
+ fprintf (stderr, "Decoding %d Hz audio using %s mode",
+ *rate, mode->modeName);
- if (*channels==1)
- fprintf (stderr, " (mono");
- else
- fprintf (stderr, " (stereo");
+ if (*channels==1)
+ fprintf (stderr, " (mono");
+ else
+ fprintf (stderr, " (stereo");
- if (header->vbr)
- fprintf (stderr, ", VBR)\n");
- else
- fprintf(stderr, ")\n");
- /*fprintf (stderr, "Decoding %d Hz audio at %d bps using %s mode\n",
- *rate, mode->bitrate, mode->modeName);*/
+ if (header->vbr)
+ fprintf (stderr, ", VBR)\n");
+ else
+ fprintf(stderr, ")\n");
+ /*fprintf (stderr, "Decoding %d Hz audio at %d bps using %s mode\n",
+ *rate, mode->bitrate, mode->modeName);*/
+ }
*extra_headers = header->extra_headers;
@@ -403,9 +406,11 @@
SpeexBits bits;
int packet_count=0;
int stream_init = 0;
+ int quiet = 0;
struct option long_options[] =
{
{"help", no_argument, NULL, 0},
+ {"quiet", no_argument, NULL, 0},
{"version", no_argument, NULL, 0},
{"version-short", no_argument, NULL, 0},
{"enh", no_argument, NULL, 0},
@@ -456,6 +461,9 @@
{
usage();
exit(0);
+ } else if (strcmp(long_options[option_index].name,"quiet")==0)
+ {
+ quiet = 1;
} else if (strcmp(long_options[option_index].name,"version")==0)
{
version();
@@ -586,7 +594,7 @@
/*If first packet, process as Speex header*/
if (packet_count==0)
{
- st = process_header(&op, enh_enabled, &frame_size, &rate, &nframes, forceMode, &channels, &stereo, &extra_headers);
+ st = process_header(&op, enh_enabled, &frame_size, &rate, &nframes, forceMode, &channels, &stereo, &extra_headers, quiet);
if (!nframes)
nframes=1;
if (!st)
@@ -595,7 +603,8 @@
} else if (packet_count==1)
{
- print_comments((char*)op.packet, op.bytes);
+ if (!quiet)
+ print_comments((char*)op.packet, op.bytes);
} else if (packet_count<=1+extra_headers)
{
/* Ignore extra headers */
<p><p>1.84 +17 -7 speex/src/speexenc.c
Index: speexenc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexenc.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- speexenc.c 4 Dec 2003 21:29:19 -0000 1.83
+++ speexenc.c 20 Jan 2004 08:08:51 -0000 1.84
@@ -209,6 +209,7 @@
FILE *fin, *fout;
short input[MAX_FRAME_SIZE];
int frame_size;
+ int quiet=0;
int vbr_enabled=0;
int abr_enabled=0;
int vad_enabled=0;
@@ -234,6 +235,7 @@
{"denoise", no_argument, NULL, 0},
{"agc", no_argument, NULL, 0},
{"help", no_argument, NULL, 0},
+ {"quiet", no_argument, NULL, 0},
{"le", no_argument, NULL, 0},
{"be", no_argument, NULL, 0},
{"8bit", no_argument, NULL, 0},
@@ -341,6 +343,9 @@
{
usage();
exit(0);
+ } else if (strcmp(long_options[option_index].name,"quiet")==0)
+ {
+ quiet = 1;
} else if (strcmp(long_options[option_index].name,"version")==0)
{
version();
@@ -516,8 +521,9 @@
rate=32000;
}
- if (rate!=8000 && rate!=16000 && rate!=32000)
- fprintf (stderr, "Warning: Speex is only optimized for 8, 16 and 32 kHz. It will still work at %d Hz but your mileage may vary\n", rate);
+ if (!quiet)
+ if (rate!=8000 && rate!=16000 && rate!=32000)
+ fprintf (stderr, "Warning: Speex is only optimized for 8, 16 and 32 kHz. It will still work at %d Hz but your mileage may vary\n", rate);
speex_init_header(&header, rate, 1, mode);
header.frames_per_packet=nframes;
@@ -528,7 +534,8 @@
char *st_string="mono";
if (chan==2)
st_string="stereo";
- fprintf (stderr, "Encoding %d Hz audio using %s mode (%s)\n",
+ if (!quiet)
+ fprintf (stderr, "Encoding %d Hz audio using %s mode (%s)\n",
header.rate, mode->modeName, st_string);
}
/*fprintf (stderr, "Encoding %d Hz audio at %d bps using %s mode\n",
@@ -673,10 +680,13 @@
fputc (ch, stderr);
cumul_bits += tmp;
enc_frames += 1;
- if (vad_enabled || vbr_enabled || abr_enabled)
- fprintf (stderr, "Bitrate is use: %d bps (average %d bps) ", tmp, (int)(cumul_bits/enc_frames));
- else
- fprintf (stderr, "Bitrate is use: %d bps ", tmp);
+ if (!quiet)
+ {
+ if (vad_enabled || vbr_enabled || abr_enabled)
+ fprintf (stderr, "Bitrate is use: %d bps (average %d bps) ", tmp, (int)(cumul_bits/enc_frames));
+ else
+ fprintf (stderr, "Bitrate is use: %d bps ", tmp);
+ }
}
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list