changeset 2875:9d06c6456f98

use libSAD-based converter in icecast plugin
author Andrew O. Shadoura <bugzilla@tut.by>
date Thu, 07 Aug 2008 14:00:20 +0300
parents 11ef2164d90b
children 07bbc6cae113
files src/icecast/Makefile src/icecast/icecast.c
diffstat 2 files changed, 10 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/src/icecast/Makefile	Thu Aug 07 04:16:17 2008 +0300
+++ b/src/icecast/Makefile	Thu Aug 07 14:00:20 2008 +0300
@@ -2,7 +2,8 @@
 
 SRCS = icecast.c		\
        ../filewriter/mp3.o	\
-       ../filewriter/vorbis.o
+       ../filewriter/vorbis.o	\
+       ../filewriter/convert.o
 
 include ../../buildsys.mk
 include ../../extra.mk
--- a/src/icecast/icecast.c	Thu Aug 07 04:16:17 2008 +0300
+++ b/src/icecast/icecast.c	Thu Aug 07 14:00:20 2008 +0300
@@ -24,6 +24,7 @@
 
 #include "../filewriter/filewriter.h"
 #include "../filewriter/plugins.h"
+#include "../filewriter/convert.h"
 #include <shout/shout.h>
 
 struct format_info input;
@@ -325,78 +326,21 @@
         }
     }
 
+    convert_init(fmt, plugin.format_required, nch);
+
     rv = (plugin.open)();
 
     g_debug("ICE_OPEN");
     return rv;
 }
 
-static void convert_buffer(gpointer buffer, gint length)
-{
-    gint i;
-
-    if (input.format == FMT_S8)
-    {
-        guint8 *ptr1 = buffer;
-        gint8 *ptr2 = buffer;
-
-        for (i = 0; i < length; i++)
-            *(ptr1++) = *(ptr2++) + 128;
-    }
-    if (input.format == FMT_S16_BE)
-    {
-        gint16 *ptr = buffer;
-
-        for (i = 0; i < length >> 1; i++, ptr++)
-            *ptr = GINT16_FROM_BE(*ptr);
-    }
-    if (input.format == FMT_S16_LE)
-    {
-        gint16 *ptr = buffer;
-
-        for (i = 0; i < length >> 1; i++, ptr++)
-            *ptr = GINT16_FROM_LE(*ptr);
-    }
-    if (input.format == FMT_U16_BE)
-    {
-        gint16 *ptr1 = buffer;
-        guint16 *ptr2 = buffer;
-
-        for (i = 0; i < length >> 1; i++, ptr2++)
-            *(ptr1++) = GUINT16_FROM_BE(*ptr2) - 32768;
-    }
-    if (input.format == FMT_U16_LE)
-    {
-        gint16 *ptr1 = buffer;
-        guint16 *ptr2 = buffer;
-
-        for (i = 0; i < length >> 1; i++, ptr2++)
-            *(ptr1++) = GUINT16_FROM_LE(*ptr2) - 32768;
-    }
-    if (input.format == FMT_U16_NE)
-    {
-        gint16 *ptr1 = buffer;
-        guint16 *ptr2 = buffer;
-
-        for (i = 0; i < length >> 1; i++, ptr2++)
-            *(ptr1++) = (*ptr2) - 32768;
-    }
-}
-
 static void ice_write(void *ptr, gint length)
 {
-    if (input.format == FMT_S8 || input.format == FMT_U16_NE ||
-        input.format == FMT_U16_LE || input.format == FMT_U16_BE)
-        convert_buffer(ptr, length);
-#ifdef WORDS_BIGENDIAN
-    if (input.format == FMT_S16_LE)
-        convert_buffer(ptr, length);
-#else
-    if (input.format == FMT_S16_BE)
-        convert_buffer(ptr, length);
-#endif
+    int len;
 
-    plugin.write(ptr, length);
+    len = convert_process(ptr, length);
+
+    plugin.write(convert_output, length);
 }
 
 static gint ice_real_write(void* ptr, gint length)
@@ -437,6 +381,7 @@
 static gboolean ice_real_close(gpointer data)
 {
     plugin.close();
+    convert_free();
 
     if (shout)
     {