[xiph-cvs] cvs commit: ices/src config.c config.h encode.c encode.h logging.h reencode.c reencode.h stream.c stream_shared.c
Michael Smith
msmith at xiph.org
Sun Jan 27 16:19:17 PST 2002
msmith 02/01/27 16:19:16
Modified: conf ices-live.xml ices-playlist.xml
src config.c config.h encode.c encode.h logging.h
reencode.c reencode.h stream.c stream_shared.c
Log:
Give people a choice between VBR and CBR. Add min/max options for CBR.
Revision Changes Path
1.2 +3 -2 ices/conf/ices-live.xml
Index: ices-live.xml
===================================================================
RCS file: /usr/local/cvsroot/ices/conf/ices-live.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ices-live.xml 2001/09/10 02:30:49 1.1
+++ ices-live.xml 2002/01/28 00:19:14 1.2
@@ -24,7 +24,8 @@
<param name="rate">22050</param> <!-- samplerate -->
<param name="channels">1</param> <!-- number of channels -->
<param name="device">/dev/dsp</param> <!-- audio device -->
- <param name="metadata">1</param> <!-- Read metadata from stdin? -->
+ <param name="metadata">1</param> <!-- Read metadata (from stdin by default, or filename defined below (if the latter, only on SIGUSR1) -->
+ <param name="metadatafilename">test</param>
</input>
<!-- Stream instance
@@ -56,7 +57,7 @@
-->
<encode>
- <bitrate>64000</bitrate>
+ <quality>3</quality>
<samplerate>22050</samplerate>
<channels>1</channels>
</encode>
<p><p>1.3 +1 -1 ices/conf/ices-playlist.xml
Index: ices-playlist.xml
===================================================================
RCS file: /usr/local/cvsroot/ices/conf/ices-playlist.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ices-playlist.xml 2001/09/24 06:37:07 1.2
+++ ices-playlist.xml 2002/01/28 00:19:14 1.3
@@ -80,7 +80,7 @@
restriction will be relaxed in the future.
-->
<encode>
- <bitrate>64000</bitrate> <!-- bps. e.g. 64000 for 64 kbps -->
+ <nominal-bitrate>64000</nominal-bitrate> <!-- bps. e.g. 64000 for 64 kbps -->
<samplerate>44100</samplerate>
<channels>2</channels>
</encode>
<p><p>1.4 +36 -6 ices/src/config.c
Index: config.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/config.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- config.c 2001/10/21 16:22:40 1.3
+++ config.c 2002/01/28 00:19:15 1.4
@@ -1,7 +1,7 @@
/* config.c
* - config file reading code, plus default settings.
*
- * $Id: config.c,v 1.3 2001/10/21 16:22:40 jack Exp $
+ * $Id: config.c,v 1.4 2002/01/28 00:19:15 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -38,7 +38,11 @@
#define DEFAULT_PORT 8000
#define DEFAULT_PASSWORD "password"
#define DEFAULT_MOUNT "/stream.ogg"
-#define DEFAULT_BITRATE 128
+#define DEFAULT_MANAGED 0
+#define DEFAULT_MIN_BITRATE -1
+#define DEFAULT_NOM_BITRATE -1
+#define DEFAULT_MAX_BITRATE -1
+#define DEFAULT_QUALITY 3
#define DEFAULT_REENCODE 0
#define DEFAULT_RECONN_DELAY 2
#define DEFAULT_RECONN_ATTEMPTS 10
@@ -61,6 +65,13 @@
if (tmp) free(tmp);\
} while (0)
+#define SET_FLOAT(x) \
+ do {\
+ char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);\
+ (x) = atof(tmp);\
+ if (tmp) free(tmp);\
+ } while (0)
+
#define SET_PARM_STRING(p,x) \
do {\
if (x) free(x);\
@@ -106,7 +117,11 @@
instance->port = DEFAULT_PORT;
instance->password = strdup(DEFAULT_PASSWORD);
instance->mount = strdup(DEFAULT_MOUNT);
- instance->bitrate = DEFAULT_BITRATE;
+ instance->managed = DEFAULT_MANAGED;
+ instance->min_br = DEFAULT_MIN_BITRATE;
+ instance->nom_br = DEFAULT_NOM_BITRATE;
+ instance->max_br = DEFAULT_MAX_BITRATE;
+ instance->quality = DEFAULT_QUALITY;
instance->encode = DEFAULT_REENCODE;
instance->reconnect_delay = DEFAULT_RECONN_DELAY;
instance->reconnect_attempts = DEFAULT_RECONN_ATTEMPTS;
@@ -127,13 +142,24 @@
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
- if (strcmp(node->name, "bitrate") == 0)
- SET_INT(instance->bitrate);
+ if (strcmp(node->name, "nominal-bitrate") == 0)
+ SET_INT(instance->nom_br);
+ else if (strcmp(node->name, "minimum-bitrate") == 0)
+ SET_INT(instance->min_br);
+ else if (strcmp(node->name, "maximum-bitrate") == 0)
+ SET_INT(instance->max_br);
+ else if (strcmp(node->name, "quality") == 0)
+ SET_FLOAT(instance->quality);
else if (strcmp(node->name, "samplerate") == 0)
SET_INT(instance->samplerate);
else if (strcmp(node->name, "channels") == 0)
SET_INT(instance->channels);
} while ((node = node->next));
+
+ if(instance->nom_br > 0 || instance->min_br > 0 || instance->max_br > 0)
+ instance->managed = 1;
+ else
+ instance->managed = 0;
}
@@ -393,7 +419,11 @@
fprintf(stderr, "port = %d\n", i->port);
fprintf(stderr, "password = %s\n", i->password);
fprintf(stderr, "mount = %s\n", i->mount);
- fprintf(stderr, "bitrate = %d\n", i->bitrate);
+ fprintf(stderr, "minimum bitrate = %d\n", i->min_br);
+ fprintf(stderr, "nominal bitrate = %d\n", i->nom_br);
+ fprintf(stderr, "maximum bitrate = %d\n", i->max_br);
+ fprintf(stderr, "quality = %d\n", i->quality);
+ fprintf(stderr, "managed = %d\n", i->managed);
fprintf(stderr, "reencode = %d\n", i->encode);
fprintf(stderr, "reconnect: %d times at %d second intervals\n",
i->reconnect_attempts, i->reconnect_delay);
<p><p>1.9 +4 -2 ices/src/config.h
Index: config.h
===================================================================
RCS file: /usr/local/cvsroot/ices/src/config.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- config.h 2001/11/10 04:47:24 1.8
+++ config.h 2002/01/28 00:19:15 1.9
@@ -1,7 +1,7 @@
/* config.h
* - configuration, and global structures built from config
*
- * $Id: config.h,v 1.8 2001/11/10 04:47:24 msmith Exp $
+ * $Id: config.h,v 1.9 2002/01/28 00:19:15 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -41,7 +41,9 @@
char *savefilename;
/* Parameters for re-encoding */
- int bitrate;
+ int managed;
+ int min_br, nom_br, max_br;
+ float quality;
int samplerate;
int channels;
<p><p>1.5 +15 -5 ices/src/encode.c
Index: encode.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/encode.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- encode.c 2002/01/27 23:45:32 1.4
+++ encode.c 2002/01/28 00:19:15 1.5
@@ -1,7 +1,7 @@
/* encode.c
* - runtime encoding of PCM data.
*
- * $Id: encode.c,v 1.4 2002/01/27 23:45:32 msmith Exp $
+ * $Id: encode.c,v 1.5 2002/01/28 00:19:15 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -38,17 +38,27 @@
}
}
-encoder_state *encode_initialise(int channels, int rate, int bitrate,
+encoder_state *encode_initialise(int channels, int rate, int managed,
+ int min_br, int nom_br, int max_br, float quality,
int serial, vorbis_comment *vc)
{
encoder_state *s = calloc(1, sizeof(encoder_state));
ogg_packet h1,h2,h3;
- LOG_INFO3("Encoder initialising at %d channels, %d Hz, bitrate %d",
- channels, rate, bitrate);
+ if(managed)
+ LOG_INFO5("Encoder initialising with bitrate management: %d channels, "
+ "%d Hz, minimum bitrate %d, nominal %d, maximum %d",
+ channels, rate, min_br, nom_br, max_br);
+ else
+ LOG_INFO3("Encoder initialising at %d channels, %d Hz, quality %f",
+ channels, rate, quality);
vorbis_info_init(&s->vi);
- vorbis_encode_init(&s->vi, channels, rate, -1, bitrate, -1);
+
+ if(managed)
+ vorbis_encode_init(&s->vi, channels, rate, max_br, nom_br, min_br);
+ else
+ vorbis_encode_init_vbr(&s->vi, channels, rate, quality*0.1);
vorbis_analysis_init(&s->vd, &s->vi);
vorbis_block_init(&s->vd, &s->vb);
<p><p>1.3 +3 -2 ices/src/encode.h
Index: encode.h
===================================================================
RCS file: /usr/local/cvsroot/ices/src/encode.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- encode.h 2001/09/25 12:04:21 1.2
+++ encode.h 2002/01/28 00:19:15 1.3
@@ -1,7 +1,7 @@
/* encode.h
* - encoding functions
*
- * $Id: encode.h,v 1.2 2001/09/25 12:04:21 msmith Exp $
+ * $Id: encode.h,v 1.3 2002/01/28 00:19:15 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -29,7 +29,8 @@
int in_header;
} encoder_state;
-encoder_state *encode_initialise(int channels, int rate, int bitrate,
+encoder_state *encode_initialise(int channels, int rate, int managed,
+ int min_br, int nom_br, int max_br, float quality,
int serial, vorbis_comment *vc);
void encode_clear(encoder_state *s);
void encode_data_float(encoder_state *s, float **pcm, int samples);
<p><p>1.3 +2 -1 ices/src/logging.h
Index: logging.h
===================================================================
RCS file: /usr/local/cvsroot/ices/src/logging.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- logging.h 2001/09/25 12:04:22 1.2
+++ logging.h 2002/01/28 00:19:15 1.3
@@ -1,7 +1,7 @@
/* logging.h
* - macros used for logging. #define MODULE before including
*
- * $Id: logging.h,v 1.2 2001/09/25 12:04:22 msmith Exp $
+ * $Id: logging.h,v 1.3 2002/01/28 00:19:15 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -38,6 +38,7 @@
#define LOG_INFO2(x,a,b) log_write(ices_config->log_id,3, MODULE __FUNCTION__,x, a,b)
#define LOG_INFO3(x,a,b,c) log_write(ices_config->log_id,3, MODULE __FUNCTION__,x, a,b,c)
#define LOG_INFO4(x,a,b,c,d) log_write(ices_config->log_id,3, MODULE __FUNCTION__,x, a,b,c,d)
+#define LOG_INFO5(x,a,b,c,d,e) log_write(ices_config->log_id,3, MODULE __FUNCTION__,x, a,b,c,d,e)
#define LOG_DEBUG0(x) log_write(ices_config->log_id,4, MODULE __FUNCTION__,x)
#define LOG_DEBUG1(x,a) log_write(ices_config->log_id,4, MODULE __FUNCTION__,x, a)
<p><p>1.4 +10 -4 ices/src/reencode.c
Index: reencode.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/reencode.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- reencode.c 2001/11/10 04:47:24 1.3
+++ reencode.c 2002/01/28 00:19:15 1.4
@@ -1,7 +1,7 @@
/* reencode.c
* - runtime reencoding of vorbis audio (usually to lower bitrates).
*
- * $Id: reencode.c,v 1.3 2001/11/10 04:47:24 msmith Exp $
+ * $Id: reencode.c,v 1.4 2002/01/28 00:19:15 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -30,7 +30,12 @@
{
reencode_state *new = calloc(1, sizeof(reencode_state));
- new->out_bitrate = stream->bitrate;
+ new->out_min_br = stream->min_br;
+ new->out_nom_br = stream->nom_br;
+ new->out_max_br = stream->max_br;
+ new->quality = stream->quality;
+ new->managed = stream->managed;
+
new->out_samplerate = stream->samplerate;
new->out_channels = stream->channels;
new->current_serial = -1; /* FIXME: that's a valid serial */
@@ -144,8 +149,9 @@
}
s->encoder = encode_initialise(s->out_channels,
- s->out_samplerate, s->out_bitrate,
- s->current_serial, &s->vc);
+ s->out_samplerate, s->managed,
+ s->out_min_br, s->out_nom_br, s->out_max_br,
+ s->quality, s->current_serial, &s->vc);
}
}
else
<p><p>1.3 +6 -2 ices/src/reencode.h
Index: reencode.h
===================================================================
RCS file: /usr/local/cvsroot/ices/src/reencode.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- reencode.h 2001/09/25 12:04:22 1.2
+++ reencode.h 2002/01/28 00:19:15 1.3
@@ -1,7 +1,7 @@
/* reencode.h
* - reencoding functions
*
- * $Id: reencode.h,v 1.2 2001/09/25 12:04:22 msmith Exp $
+ * $Id: reencode.h,v 1.3 2002/01/28 00:19:15 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -22,7 +22,11 @@
#include "encode.h"
typedef struct {
- int out_bitrate;
+ int out_min_br;
+ int out_nom_br;
+ int out_max_br;
+ float quality;
+ int managed;
int out_samplerate;
int out_channels;
<p><p>1.11 +3 -2 ices/src/stream.c
Index: stream.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/stream.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- stream.c 2002/01/23 03:40:28 1.10
+++ stream.c 2002/01/28 00:19:15 1.11
@@ -1,7 +1,7 @@
/* stream.c
* - Core streaming functions/main loop.
*
- * $Id: stream.c,v 1.10 2002/01/23 03:40:28 jack Exp $
+ * $Id: stream.c,v 1.11 2002/01/28 00:19:15 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -123,7 +123,8 @@
if(inmod->metadata_update)
inmod->metadata_update(inmod->internal, &sdsc->vc);
sdsc->enc = encode_initialise(stream->channels, stream->samplerate,
- stream->bitrate, stream->serial++, &sdsc->vc);
+ stream->managed, stream->min_br, stream->nom_br, stream->max_br,
+ stream->quality, stream->serial++, &sdsc->vc);
}
else if(reencoding)
sdsc->reenc = reencode_init(stream);
<p><p>1.6 +4 -2 ices/src/stream_shared.c
Index: stream_shared.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/stream_shared.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- stream_shared.c 2002/01/23 03:40:28 1.5
+++ stream_shared.c 2002/01/28 00:19:15 1.6
@@ -1,7 +1,7 @@
/* stream_shared.c
* - Stream utility functions.
*
- * $Id: stream_shared.c,v 1.5 2002/01/23 03:40:28 jack Exp $
+ * $Id: stream_shared.c,v 1.6 2002/01/28 00:19:15 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -148,7 +148,9 @@
}
sdsc->enc = encode_initialise(sdsc->stream->channels,
- sdsc->stream->samplerate, sdsc->stream->bitrate,
+ sdsc->stream->samplerate, sdsc->stream->managed,
+ sdsc->stream->min_br, sdsc->stream->nom_br,
+ sdsc->stream->max_br, sdsc->stream->quality,
sdsc->stream->serial++, &sdsc->vc);
}
<p><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