[xiph-cvs] cvs commit: ices/src encode.c logging.h reencode.c stream.c stream_shared.c

Michael Smith msmith at xiph.org
Sat Aug 3 05:11:58 PDT 2002



msmith      02/08/03 05:11:58

  Modified:    src      encode.c logging.h reencode.c stream.c
                        stream_shared.c
  Log:
  Less broken managed modes, and general fixes for better error checking.

Revision  Changes    Path
1.10      +27 -11    ices/src/encode.c

Index: encode.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/encode.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- encode.c	2002/08/03 08:14:54	1.9
+++ encode.c	2002/08/03 12:11:57	1.10
@@ -1,7 +1,7 @@
 /* encode.c
  * - runtime encoding of PCM data.
  *
- * $Id: encode.c,v 1.9 2002/08/03 08:14:54 msmith Exp $
+ * $Id: encode.c,v 1.10 2002/08/03 12:11:57 msmith Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -45,26 +45,42 @@
         encoder_state *s = calloc(1, sizeof(encoder_state));
         ogg_packet h1,h2,h3;
 
-    if(managed)
+    // FIXME: These messages are wrong in some cases, and this mode setup
+    // is generally pretty broken.
+    if(min_br < 0 && max_br < 0 && nom_br < 0)
+	    LOG_INFO3("Encoder initialising at %d channel(s), %d Hz, quality %f", 
+		    	channels, rate, quality);
+    else
         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);
 
-    if(min_br < 0 && max_br < 0 && nom_br < 0)
-        vorbis_encode_setup_vbr(&s->vi, channels, rate, quality*0.1);
-    else
-        vorbis_encode_setup_managed(&s->vi, channels, rate, max_br, nom_br, 
-                min_br);
+    if(min_br < 0 && max_br < 0 && nom_br < 0) {
+        if(vorbis_encode_setup_vbr(&s->vi, channels, rate, quality*0.1)) {
+            LOG_ERROR3("Failed to configure VBR encoding for %d channel(s), "
+                    "at %d Hz, quality level %f", channels, rate, quality);
+            free(s);
+            return NULL;
+        }
+    }
+    else {
+        if(vorbis_encode_setup_managed(&s->vi, channels, rate, max_br, nom_br, 
+                    min_br)) {
+            LOG_ERROR5("Failed to configure encoding mode for %d channel(s), "
+                "at %d Hz, with bitrates %d max %d nominal, %d min", 
+                channels, rate, max_br, nom_br, min_br);
+            free(s);
+            return NULL;
+        }
+    }
 
     if(managed && nom_br < 0)
         vorbis_encode_ctl(&s->vi, OV_ECTL_RATEMANAGE_AVG, NULL);
-    else if(!managed)
+    else if(!managed) {
         vorbis_encode_ctl(&s->vi, OV_ECTL_RATEMANAGE_SET, NULL);
+    }
     
     vorbis_encode_setup_init(&s->vi);
 

<p><p>1.5       +3 -1      ices/src/logging.h

Index: logging.h
===================================================================
RCS file: /usr/local/cvsroot/ices/src/logging.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- logging.h	2002/08/03 08:14:54	1.4
+++ logging.h	2002/08/03 12:11:57	1.5
@@ -1,7 +1,7 @@
 /* logging.h
  * - macros used for logging. #define MODULE before including
  *
- * $Id: logging.h,v 1.4 2002/08/03 08:14:54 msmith Exp $
+ * $Id: logging.h,v 1.5 2002/08/03 12:11:57 msmith Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -26,6 +26,7 @@
 #define LOG_ERROR2(x,a,b) log_write(ices_config->log_id,1, MODULE, __FUNCTION__,x, a,b)
 #define LOG_ERROR3(x,a,b,c) log_write(ices_config->log_id,1, MODULE, __FUNCTION__,x, a,b,c)
 #define LOG_ERROR4(x,a,b,c,d) log_write(ices_config->log_id,1, MODULE, __FUNCTION__,x, a,b,c,d)
+#define LOG_ERROR5(x,a,b,c,d,e) log_write(ices_config->log_id,1, MODULE, __FUNCTION__,x, a,b,c,d,e)
 
 #define LOG_WARN0(x) log_write(ices_config->log_id,2, MODULE, __FUNCTION__,x)
 #define LOG_WARN1(x,a) log_write(ices_config->log_id,2, MODULE, __FUNCTION__,x, a)
@@ -45,6 +46,7 @@
 #define LOG_DEBUG2(x,a,b) log_write(ices_config->log_id,4, MODULE, __FUNCTION__,x, a,b)
 #define LOG_DEBUG3(x,a,b,c) log_write(ices_config->log_id,4, MODULE, __FUNCTION__,x, a,b,c)
 #define LOG_DEBUG4(x,a,b,c,d) log_write(ices_config->log_id,4, MODULE, __FUNCTION__,x, a,b,c,d)
+#define LOG_DEBUG5(x,a,b,c,d,e) log_write(ices_config->log_id,4, MODULE, __FUNCTION__,x, a,b,c,d,e)
 
 
 #endif /* __LOGGING_H */

<p><p>1.5       +5 -1      ices/src/reencode.c

Index: reencode.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/reencode.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- reencode.c	2002/01/28 00:19:15	1.4
+++ reencode.c	2002/08/03 12:11:57	1.5
@@ -1,7 +1,7 @@
 /* reencode.c
  * - runtime reencoding of vorbis audio (usually to lower bitrates).
  *
- * $Id: reencode.c,v 1.4 2002/01/28 00:19:15 msmith Exp $
+ * $Id: reencode.c,v 1.5 2002/08/03 12:11:57 msmith Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -152,6 +152,10 @@
                                                         s->out_samplerate, s->managed, 
                             s->out_min_br, s->out_nom_br, s->out_max_br,
                                                         s->quality, s->current_serial, &s->vc);
+                    if(!s->encoder) {
+                        LOG_ERROR0("Failed to configure encoder for reencoding");
+                        return -1;
+                    }
                                 }
                         }
                         else

<p><p>1.14      +6 -1      ices/src/stream.c

Index: stream.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/stream.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- stream.c	2002/08/03 08:14:54	1.13
+++ stream.c	2002/08/03 12:11:57	1.14
@@ -1,7 +1,7 @@
 /* stream.c
  * - Core streaming functions/main loop.
  *
- * $Id: stream.c,v 1.13 2002/08/03 08:14:54 msmith Exp $
+ * $Id: stream.c,v 1.14 2002/08/03 12:11:57 msmith Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -137,6 +137,11 @@
                 sdsc->enc = encode_initialise(stream->channels, stream->samplerate,
                                 stream->managed, stream->min_br, stream->nom_br, stream->max_br,
                 stream->quality, stream->serial++, &sdsc->vc);
+        if(!sdsc->enc) {
+            LOG_ERROR0("Failed to configure encoder");
+		    stream->died = 1;
+            return NULL; /* FIXME: probably leaking some memory here */
+        }
         }
         else if(reencoding)
                 sdsc->reenc = reencode_init(stream);

<p><p>1.10      +6 -1      ices/src/stream_shared.c

Index: stream_shared.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/stream_shared.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- stream_shared.c	2002/08/03 08:14:54	1.9
+++ stream_shared.c	2002/08/03 12:11:57	1.10
@@ -1,7 +1,7 @@
 /* stream_shared.c
  * - Stream utility functions.
  *
- * $Id: stream_shared.c,v 1.9 2002/08/03 08:14:54 msmith Exp $
+ * $Id: stream_shared.c,v 1.10 2002/08/03 12:11:57 msmith Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -164,6 +164,11 @@
                     sdsc->stream->min_br, sdsc->stream->nom_br, 
                     sdsc->stream->max_br, sdsc->stream->quality,
                     sdsc->stream->serial++, &sdsc->vc);
+            if(!sdsc->enc) {
+                LOG_ERROR0("Failed to initialise encoder");
+                return -2;
+            }
+
                 }
 
         if(sdsc->downmix) {

<p><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