API renamed to Opus
authorJean-Marc Valin <jean-marc.valin@octasic.com>
Mon, 18 Oct 2010 16:50:49 +0000 (12:50 -0400)
committerJean-Marc Valin <jean-marc.valin@octasic.com>
Mon, 18 Oct 2010 16:50:49 +0000 (12:50 -0400)
README
configure.ac
src/Makefile.am
src/framepack.c
src/opus.h [moved from src/harmony.h with 63% similarity]
src/opus_decoder.c [moved from src/harmony_decoder.c with 88% similarity]
src/opus_decoder.h [moved from src/harmony_decoder.h with 93% similarity]
src/opus_encoder.c [moved from src/harmony_encoder.c with 88% similarity]
src/opus_encoder.h [moved from src/harmony_encoder.h with 93% similarity]
src/test_opus.c [moved from src/test_harmony.c with 85% similarity]

diff --git a/README b/README
index b75ef84..589d119 100644 (file)
--- a/README
+++ b/README
@@ -23,10 +23,10 @@ To build from the git repository, the following steps are necessary
 % make
 
 
-Once you have compiled the codec, there will be a test_harmony executable in
+Once you have compiled the codec, there will be a test_opus executable in
 the src/ directory. This can be in the following way:
 
-% ./test_harmony 48000 1 960 80 input.sw output.sw
+% ./test_opus 48000 1 960 80 input.sw output.sw
 
 The arguments are:
 1) The sampling rate (only 48000 supported for now)
index dd64488..21d6b32 100644 (file)
@@ -2,8 +2,8 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.59])
-AC_INIT(src/harmony.h)
-AM_INIT_AUTOMAKE(harmony,20100921)
+AC_INIT(src/opus.h)
+AM_INIT_AUTOMAKE(opus,20100921)
 
 # Checks for programs.
 AC_PROG_CC
index f3f0240..1eb239a 100644 (file)
@@ -2,12 +2,12 @@
 INCLUDES = -I$(top_srcdir)/celt/libcelt/ -I$(top_srcdir)/silk/interface 
 
 lib_LTLIBRARIES = libietfcodec.la
-libietfcodec_la_SOURCES = harmony_decoder.c harmony_encoder.c
+libietfcodec_la_SOURCES = opus_decoder.c opus_encoder.c
 
-noinst_HEADERS = harmony_decoder.h harmony_encoder.h
+noinst_HEADERS = opus_decoder.h opus_encoder.h
 
-pkginclude_HEADERS = harmony.h
+pkginclude_HEADERS = opus.h
 
-noinst_PROGRAMS = test_harmony
-test_harmony_SOURCES = test_harmony.c $(top_srcdir)/silk/test/SKP_debug.c
-test_harmony_LDADD = libietfcodec.la $(top_builddir)/celt/libcelt/libcelt0.la $(top_builddir)/silk/libSKP_SILK_SDK.la
+noinst_PROGRAMS = test_opus
+test_opus_SOURCES = test_opus.c $(top_srcdir)/silk/test/SKP_debug.c
+test_opus_LDADD = libietfcodec.la $(top_builddir)/celt/libcelt/libcelt0.la $(top_builddir)/silk/libSKP_SILK_SDK.la
index c7a84c0..21209ac 100644 (file)
@@ -100,7 +100,7 @@ int count_frames(unsigned char *packet, int len)
 }
 
 #define MAX_FRAMES 256
-int harmony_merge_packets(unsigned char **packets, int *plen, int nb_packets,
+int opus_merge_packets(unsigned char **packets, int *plen, int nb_packets,
         unsigned *output, int maxlen)
 {
     int i;
similarity index 63%
rename from src/harmony.h
rename to src/opus.h
index ed8d1f3..85578fa 100644 (file)
@@ -29,8 +29,8 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef HARMONY_H
-#define HARMONY_H
+#ifndef OPUS_H
+#define OPUS_H
 
 #ifdef __cplusplus
 extern "C" {
@@ -59,44 +59,44 @@ extern "C" {
 
 
 
-#define HARMONY_SET_MODE_REQUEST 0
-#define HARMONY_SET_MODE(x) HARMONY_SET_MODE_REQUEST, __check_int(x)
-#define HARMONY_GET_MODE_REQUEST 1
-#define HARMONY_GET_MODE(x) HARMONY_GET_MODE_REQUEST, __check_int_ptr(x)
+#define OPUS_SET_MODE_REQUEST 0
+#define OPUS_SET_MODE(x) OPUS_SET_MODE_REQUEST, __check_int(x)
+#define OPUS_GET_MODE_REQUEST 1
+#define OPUS_GET_MODE(x) OPUS_GET_MODE_REQUEST, __check_int_ptr(x)
 
-#define HARMONY_SET_BANDWIDTH_REQUEST 2
-#define HARMONY_SET_BANDWIDTH(x) HARMONY_SET_BANDWIDTH_REQUEST, __check_int(x)
-#define HARMONY_GET_BANDWIDTH_REQUEST 3
-#define HARMONY_GET_BANDWIDTH(x) HARMONY_GET_BANDWIDTH_REQUEST, __check_int_ptr(x)
+#define OPUS_SET_BANDWIDTH_REQUEST 2
+#define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __check_int(x)
+#define OPUS_GET_BANDWIDTH_REQUEST 3
+#define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __check_int_ptr(x)
 
-#define HARMONY_SET_VBR_RATE_REQUEST 4
-#define HARMONY_SET_VBR_RATE(x) HARMONY_SET_VBR_RATE_REQUEST, __check_int(x)
-#define HARMONY_GET_VBR_RATE_REQUEST 5
-#define HARMONY_GET_VBR_RATE(x) HARMONY_GET_VBR_RATE_REQUEST, __check_int_ptr(x)
+#define OPUS_SET_VBR_RATE_REQUEST 4
+#define OPUS_SET_VBR_RATE(x) OPUS_SET_VBR_RATE_REQUEST, __check_int(x)
+#define OPUS_GET_VBR_RATE_REQUEST 5
+#define OPUS_GET_VBR_RATE(x) OPUS_GET_VBR_RATE_REQUEST, __check_int_ptr(x)
 
-typedef struct HarmonyEncoder HarmonyEncoder;
-typedef struct HarmonyDecoder HarmonyDecoder;
+typedef struct OpusEncoder OpusEncoder;
+typedef struct OpusDecoder OpusDecoder;
 
-HarmonyEncoder *harmony_encoder_create(int Fs);
+OpusEncoder *opus_encoder_create(int Fs);
 
-int harmony_encode(HarmonyEncoder *st, const short *pcm, int frame_size,
+int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
                unsigned char *data, int bytes_per_packet);
 
-void harmony_encoder_destroy(HarmonyEncoder *st);
+void opus_encoder_destroy(OpusEncoder *st);
 
-void harmony_encoder_ctl(HarmonyEncoder *st, int request, ...);
+void opus_encoder_ctl(OpusEncoder *st, int request, ...);
 
-HarmonyDecoder *harmony_decoder_create(int Fs);
+OpusDecoder *opus_decoder_create(int Fs);
 
-int harmony_decode(HarmonyDecoder *st, const unsigned char *data, int len,
+int opus_decode(OpusDecoder *st, const unsigned char *data, int len,
                short *pcm, int frame_size);
 
-void harmony_decoder_ctl(HarmonyDecoder *st, int request, ...);
+void opus_decoder_ctl(OpusDecoder *st, int request, ...);
 
-void harmony_decoder_destroy(HarmonyDecoder *st);
+void opus_decoder_destroy(OpusDecoder *st);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* HARMONY_H */
+#endif /* OPUS_H */
similarity index 88%
rename from src/harmony_decoder.c
rename to src/opus_decoder.c
index 7177d60..ded9c80 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
-#include "harmony_decoder.h"
+#include "opus_decoder.h"
 #include "entdec.h"
 #include "modes.h"
 #include "SKP_Silk_SDK_API.h"
 
 
-HarmonyDecoder *harmony_decoder_create(int Fs)
+OpusDecoder *opus_decoder_create(int Fs)
 {
     char *raw_state;
        int ret, silkDecSizeBytes, celtDecSizeBytes;
        CELTMode *celtMode;
-       HarmonyDecoder *st;
+       OpusDecoder *st;
 
     /* We should not have to create a CELT mode for each encoder state */
     celtMode = celt_mode_create(Fs, Fs/50, NULL);
@@ -58,10 +58,10 @@ HarmonyDecoder *harmony_decoder_create(int Fs)
         /* Handle error */
     }
     celtDecSizeBytes = celt_decoder_get_size(celtMode, 1);
-    raw_state = calloc(sizeof(HarmonyDecoder)+silkDecSizeBytes+celtDecSizeBytes, 1);
-    st = (HarmonyDecoder*)raw_state;
-    st->silk_dec = (void*)(raw_state+sizeof(HarmonyDecoder));
-    st->celt_dec = (CELTDecoder*)(raw_state+sizeof(HarmonyDecoder)+silkDecSizeBytes);
+    raw_state = calloc(sizeof(OpusDecoder)+silkDecSizeBytes+celtDecSizeBytes, 1);
+    st = (OpusDecoder*)raw_state;
+    st->silk_dec = (void*)(raw_state+sizeof(OpusDecoder));
+    st->celt_dec = (CELTDecoder*)(raw_state+sizeof(OpusDecoder)+silkDecSizeBytes);
 
     st->Fs = Fs;
     st->celt_mode = celtMode;
@@ -78,7 +78,7 @@ HarmonyDecoder *harmony_decoder_create(int Fs)
        return st;
 
 }
-int harmony_decode(HarmonyDecoder *st, const unsigned char *data,
+int opus_decode(OpusDecoder *st, const unsigned char *data,
                int len, short *pcm, int frame_size)
 {
        int i, silk_ret=0, celt_ret=0;
@@ -164,7 +164,7 @@ int harmony_decode(HarmonyDecoder *st, const unsigned char *data,
 
 }
 
-void harmony_decoder_ctl(HarmonyDecoder *st, int request, ...)
+void opus_decoder_ctl(OpusDecoder *st, int request, ...)
 {
     va_list ap;
 
@@ -172,39 +172,39 @@ void harmony_decoder_ctl(HarmonyDecoder *st, int request, ...)
 
     switch (request)
     {
-        case HARMONY_SET_MODE_REQUEST:
+        case OPUS_SET_MODE_REQUEST:
         {
             int value = va_arg(ap, int);
             st->mode = value;
         }
         break;
-        case HARMONY_GET_MODE_REQUEST:
+        case OPUS_GET_MODE_REQUEST:
         {
             int *value = va_arg(ap, int*);
             *value = st->mode;
         }
         break;
-        case HARMONY_SET_BANDWIDTH_REQUEST:
+        case OPUS_SET_BANDWIDTH_REQUEST:
         {
             int value = va_arg(ap, int);
             st->bandwidth = value;
         }
         break;
-        case HARMONY_GET_BANDWIDTH_REQUEST:
+        case OPUS_GET_BANDWIDTH_REQUEST:
         {
             int *value = va_arg(ap, int*);
             *value = st->bandwidth;
         }
         break;
         default:
-            fprintf(stderr, "unknown harmony_decoder_ctl() request: %d", request);
+            fprintf(stderr, "unknown opus_decoder_ctl() request: %d", request);
             break;
     }
 
     va_end(ap);
 }
 
-void harmony_decoder_destroy(HarmonyDecoder *st)
+void opus_decoder_destroy(OpusDecoder *st)
 {
        celt_mode_destroy(st->celt_mode);
 
similarity index 93%
rename from src/harmony_decoder.h
rename to src/opus_decoder.h
index 18f5c9e..9bb8106 100644 (file)
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef HARMONY_DECODER_H
-#define HARMONY_DECODER_H
+#ifndef OPUS_DECODER_H
+#define OPUS_DECODER_H
 
 #include "celt.h"
-#include "harmony.h"
+#include "opus.h"
 
-struct HarmonyDecoder {
+struct OpusDecoder {
        CELTMode    *celt_mode;
        CELTDecoder *celt_dec;
        void        *silk_dec;
@@ -47,5 +47,5 @@ struct HarmonyDecoder {
 };
 
 
-#endif /* HARMONY_DECODER_H */
+#endif /* OPUS_DECODER_H */
 
similarity index 88%
rename from src/harmony_encoder.c
rename to src/opus_encoder.c
index 569eb7a..e15f94b 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
-#include "harmony_encoder.h"
+#include "opus_encoder.h"
 #include "entenc.h"
 #include "modes.h"
 #include "SKP_Silk_SDK_API.h"
 
-HarmonyEncoder *harmony_encoder_create(int Fs)
+OpusEncoder *opus_encoder_create(int Fs)
 {
     char *raw_state;
     CELTMode *celtMode;
-       HarmonyEncoder *st;
+       OpusEncoder *st;
        int ret, silkEncSizeBytes, celtEncSizeBytes;
     SKP_SILK_SDK_EncControlStruct encControl;
 
@@ -58,10 +58,10 @@ HarmonyEncoder *harmony_encoder_create(int Fs)
        /* Handle error */
     }
     celtEncSizeBytes = celt_encoder_get_size(celtMode, 1);
-    raw_state = calloc(sizeof(HarmonyEncoder)+silkEncSizeBytes+celtEncSizeBytes, 1);
-    st = (HarmonyEncoder*)raw_state;
-    st->silk_enc = (void*)(raw_state+sizeof(HarmonyEncoder));
-    st->celt_enc = (CELTEncoder*)(raw_state+sizeof(HarmonyEncoder)+silkEncSizeBytes);
+    raw_state = calloc(sizeof(OpusEncoder)+silkEncSizeBytes+celtEncSizeBytes, 1);
+    st = (OpusEncoder*)raw_state;
+    st->silk_enc = (void*)(raw_state+sizeof(OpusEncoder));
+    st->celt_enc = (CELTEncoder*)(raw_state+sizeof(OpusEncoder)+silkEncSizeBytes);
 
     st->Fs = Fs;
     st->celt_mode = celtMode;
@@ -87,7 +87,7 @@ HarmonyEncoder *harmony_encoder_create(int Fs)
        return st;
 }
 
-int harmony_encode(HarmonyEncoder *st, const short *pcm, int frame_size,
+int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
                unsigned char *data, int bytes_per_packet)
 {
     int i;
@@ -199,7 +199,7 @@ int harmony_encode(HarmonyEncoder *st, const short *pcm, int frame_size,
         data[0] = 0x80;
         data[0] |= tmp << 5;
         data[0] |= period<<3;
-    } else /* Harmony */
+    } else /* Opus */
     {
         data[0] = 0x60;
         data[0] |= (st->bandwidth-BANDWIDTH_SUPERWIDEBAND)<<4;
@@ -210,7 +210,7 @@ int harmony_encode(HarmonyEncoder *st, const short *pcm, int frame_size,
     return ret+1;
 }
 
-void harmony_encoder_ctl(HarmonyEncoder *st, int request, ...)
+void opus_encoder_ctl(OpusEncoder *st, int request, ...)
 {
     va_list ap;
 
@@ -218,51 +218,51 @@ void harmony_encoder_ctl(HarmonyEncoder *st, int request, ...)
 
     switch (request)
     {
-        case HARMONY_SET_MODE_REQUEST:
+        case OPUS_SET_MODE_REQUEST:
         {
             int value = va_arg(ap, int);
             st->mode = value;
         }
         break;
-        case HARMONY_GET_MODE_REQUEST:
+        case OPUS_GET_MODE_REQUEST:
         {
             int *value = va_arg(ap, int*);
             *value = st->mode;
         }
         break;
-        case HARMONY_SET_BANDWIDTH_REQUEST:
+        case OPUS_SET_BANDWIDTH_REQUEST:
         {
             int value = va_arg(ap, int);
             st->bandwidth = value;
         }
         break;
-        case HARMONY_GET_BANDWIDTH_REQUEST:
+        case OPUS_GET_BANDWIDTH_REQUEST:
         {
             int *value = va_arg(ap, int*);
             *value = st->bandwidth;
         }
         break;
-        case HARMONY_SET_VBR_RATE_REQUEST:
+        case OPUS_SET_VBR_RATE_REQUEST:
         {
             int value = va_arg(ap, int);
             st->vbr_rate = value;
         }
         break;
-        case HARMONY_GET_VBR_RATE_REQUEST:
+        case OPUS_GET_VBR_RATE_REQUEST:
         {
             int *value = va_arg(ap, int*);
             *value = st->vbr_rate;
         }
         break;
         default:
-            fprintf(stderr, "unknown harmony_encoder_ctl() request: %d", request);
+            fprintf(stderr, "unknown opus_encoder_ctl() request: %d", request);
             break;
     }
 
     va_end(ap);
 }
 
-void harmony_encoder_destroy(HarmonyEncoder *st)
+void opus_encoder_destroy(OpusEncoder *st)
 {
        celt_mode_destroy(st->celt_mode);
        free(st);
similarity index 93%
rename from src/harmony_encoder.h
rename to src/opus_encoder.h
index 045d273..8c952ab 100644 (file)
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef HARMONY_ENCODER_H
-#define HARMONY_ENCODER_H
+#ifndef OPUS_ENCODER_H
+#define OPUS_ENCODER_H
 
 #include "celt.h"
-#include "harmony.h"
+#include "opus.h"
 #include "SKP_Silk_SDK_API.h"
 
 /* FIXME: This is only valid for 48 kHz */
 #define ENCODER_DELAY_COMPENSATION 130
 
-struct HarmonyEncoder {
+struct OpusEncoder {
        CELTMode    *celt_mode;
        CELTEncoder *celt_enc;
        void        *silk_enc;
@@ -54,5 +54,5 @@ struct HarmonyEncoder {
 };
 
 
-#endif /* HARMONY_ENCODER_H */
+#endif /* OPUS_ENCODER_H */
 
similarity index 85%
rename from src/test_harmony.c
rename to src/test_opus.c
index 6c873ce..5dbca20 100644 (file)
@@ -38,7 +38,7 @@
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
-#include "harmony.h"
+#include "opus.h"
 
 
 #define MAX_PACKET 1024
@@ -48,8 +48,8 @@ int main(int argc, char *argv[])
    int err;
    char *inFile, *outFile;
    FILE *fin, *fout;
-   HarmonyEncoder *enc;
-   HarmonyDecoder *dec;
+   OpusEncoder *enc;
+   OpusDecoder *dec;
    int len;
    int frame_size, channels;
    int bytes_per_packet;
@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
    double bits=0;
    if (argc != 9 && argc != 8 && argc != 7)
    {
-      fprintf (stderr, "Usage: test_harmony <rate (kHz)> <channels> <frame size> "
+      fprintf (stderr, "Usage: test_opus <rate (kHz)> <channels> <frame size> "
                " <bytes per packet>  [<VBR rate (kb/s)>] [<packet loss rate>] "
                "<input> <output>\n");
       return 1;
@@ -105,15 +105,15 @@ int main(int argc, char *argv[])
       return 1;
    }
 
-   enc = harmony_encoder_create(rate);
-   dec = harmony_decoder_create(rate);
+   enc = opus_encoder_create(rate);
+   dec = opus_decoder_create(rate);
 
    mode = MODE_HYBRID;
-   harmony_encoder_ctl(enc, HARMONY_SET_BANDWIDTH(BANDWIDTH_FULLBAND));
-   harmony_encoder_ctl(enc, HARMONY_SET_MODE(mode));
+   opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(BANDWIDTH_FULLBAND));
+   opus_encoder_ctl(enc, OPUS_SET_MODE(mode));
 
    if (vbr)
-       harmony_encoder_ctl(enc, HARMONY_SET_VBR_RATE(vbr));
+       opus_encoder_ctl(enc, OPUS_SET_VBR_RATE(vbr));
 
    skip = 5*rate/1000 + 10;
 
@@ -130,14 +130,14 @@ int main(int argc, char *argv[])
           for (i=err;i<frame_size*channels;i++)
               in[i] = 0;
       }
-      len = harmony_encode(enc, in, frame_size, data, bytes_per_packet);
+      len = opus_encode(enc, in, frame_size, data, bytes_per_packet);
       if (len <= 0)
       {
-         fprintf (stderr, "harmony_encode() returned %d\n", len);
+         fprintf (stderr, "opus_encode() returned %d\n", len);
          return 1;
       }
       bits += len*8;
-      harmony_decode(dec, rand()%100<loss ? NULL : data, len, out, frame_size);
+      opus_decode(dec, rand()%100<loss ? NULL : data, len, out, frame_size);
       count++;
       tot_written += (frame_size-skip)*channels;
       write_samples = frame_size;
@@ -150,8 +150,8 @@ int main(int argc, char *argv[])
       skip = 0;
    }
    fprintf (stderr, "average bit-rate: %f kb/s\n", bits*rate/(frame_size*(double)count));
-   harmony_encoder_destroy(enc);
-   harmony_decoder_destroy(dec);
+   opus_encoder_destroy(enc);
+   opus_decoder_destroy(dec);
    fclose(fin);
    fclose(fout);
    free(in);