diff --git a/src/opus.c b/src/opus.c
index 9f3a4ecf74ca785363b99febbe38828f3753498f..0181e11d18641566e3abf2698d1e3c99acb9b9ab 100644
--- a/src/opus.c
+++ b/src/opus.c
@@ -30,11 +30,25 @@
 #endif
 
 #include "opus.h"
+#include "opus_private.h"
 
 #ifndef OPUS_VERSION
 #define OPUS_VERSION "unknown"
 #endif
 
+int encode_size(int size, unsigned char *data)
+{
+   if (size < 252)
+   {
+      data[0] = size;
+      return 1;
+   } else {
+      data[0] = 252+(size&0x3);
+      data[1] = (size-(int)data[0])>>2;
+      return 2;
+   }
+}
+
 const char *opus_strerror(int error)
 {
    static const char *error_strings[8] = {
diff --git a/src/opus_private.h b/src/opus_private.h
index 6d03a94c7604c13704ec903836d994a331873dc7..9015e3897e6487fc52206956957a51d5d44966d7 100644
--- a/src/opus_private.h
+++ b/src/opus_private.h
@@ -29,6 +29,8 @@
 #ifndef OPUS_PRIVATE_H
 #define OPUS_PRIVATE_H
 
+int encode_size(int size, unsigned char *data);
+
 /* Make sure everything's aligned to 4 bytes (this may need to be increased
    on really weird architectures) */
 static inline int align(int i)
diff --git a/src/repacketizer.c b/src/repacketizer.c
index f6a76e675c5971381f423858a4b222086190099d..76c15cfde37189fe203a333268d6cc07edde13e3 100644
--- a/src/repacketizer.c
+++ b/src/repacketizer.c
@@ -42,18 +42,7 @@ struct OpusRepacketizer {
    int framesize;
 };
 
-static int encode_size(int size, unsigned char *data)
-{
-   if (size < 252)
-   {
-      data[0] = size;
-      return 1;
-   } else {
-      data[0] = 252+(size&0x3);
-      data[1] = (size-(int)data[0])>>2;
-      return 2;
-   }
-}
+
 
 int opus_repacketizer_get_size(void)
 {