ref: afc8d53b1b1d4a740551b3bbf8c2ac45061786ed
parent: c7ab61b3c6a6c2a141f5a0266cd40d119aa18c66
author: Gregory Maxwell <[email protected]>
date: Wed Sep 28 11:13:26 EDT 2011
Cleans up some leaking opus_custom symbols in celt/
--- a/celt/celt.c
+++ b/celt/celt.c
@@ -54,6 +54,12 @@
#define OPUS_VERSION "unknown"
#endif
+#ifdef CUSTOM_MODES
+#define OPUS_CUSTOM_NOSTATIC
+#else
+#define OPUS_CUSTOM_NOSTATIC static inline
+#endif
+
static const unsigned char trim_icdf[11] = {126, 124, 119, 109, 87, 41, 19, 9, 4, 2, 0};
/* Probs: NONE: 21.875%, LIGHT: 6.25%, NORMAL: 65.625%, AGGRESSIVE: 6.25% */
static const unsigned char spread_icdf[4] = {25, 23, 2, 0};
@@ -192,7 +198,7 @@
return opus_custom_encoder_get_size(mode, channels);
}
-int opus_custom_encoder_get_size(const CELTMode *mode, int channels)
+OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int channels)
{
int size = sizeof(struct CELTEncoder)
+ (2*channels*mode->overlap-1)*sizeof(celt_sig)
@@ -232,7 +238,7 @@
return OPUS_OK;
}
-int opus_custom_encoder_init(CELTEncoder *st, const CELTMode *mode, int channels)
+OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_init(CELTEncoder *st, const CELTMode *mode, int channels)
{
if (channels < 0 || channels > 2)
return OPUS_BAD_ARG;
@@ -1906,7 +1912,7 @@
return opus_custom_decoder_get_size(mode, channels);
}
-int opus_custom_decoder_get_size(const CELTMode *mode, int channels)
+OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_get_size(const CELTMode *mode, int channels)
{
int size = sizeof(struct CELTDecoder)
+ (channels*(DECODE_BUFFER_SIZE+mode->overlap)-1)*sizeof(celt_sig)
@@ -1945,7 +1951,7 @@
return OPUS_OK;
}
-int opus_custom_decoder_init(CELTDecoder *st, const CELTMode *mode, int channels)
+OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_init(CELTDecoder *st, const CELTMode *mode, int channels)
{
if (channels < 0 || channels > 2)
return OPUS_BAD_ARG;
@@ -2660,7 +2666,6 @@
#endif
#endif /* CUSTOM_MODES */
-
int opus_custom_decoder_ctl(CELTDecoder * restrict st, int request, ...)
{
--- a/celt/modes.c
+++ b/celt/modes.c
@@ -397,11 +397,11 @@
#endif /* !CUSTOM_MODES */
}
+#ifdef CUSTOM_MODES
void opus_custom_mode_destroy(CELTMode *mode)
{
if (mode == NULL)
return;
-#ifdef CUSTOM_MODES
#ifndef CUSTOM_MODES_ONLY
{
int i;
@@ -426,5 +426,5 @@
clt_mdct_clear(&mode->mdct);
opus_free((CELTMode *)mode);
-#endif
}
+#endif
--- a/celt/opus_custom.h
+++ b/celt/opus_custom.h
@@ -44,9 +44,15 @@
#ifdef CUSTOM_MODES
#define OPUS_CUSTOM_EXPORT OPUS_EXPORT
+#define OPUS_CUSTOM_EXPORT_STATIC OPUS_EXPORT
#else
#define OPUS_CUSTOM_EXPORT
+#ifdef CELT_C
+#define OPUS_CUSTOM_EXPORT_STATIC static inline
+#else
+#define OPUS_CUSTOM_EXPORT_STATIC
#endif
+#endif
/** Contains the state of an encoder. One encoder state is needed
for each stream. It is initialised once at the beginning of the
@@ -66,7 +72,6 @@
bad */
typedef struct OpusCustomMode OpusCustomMode;
-
/** Creates a new mode struct. This will be passed to an encoder or
decoder. The mode MUST NOT BE DESTROYED until the encoders and
decoders that use it are destroyed as well.
@@ -84,11 +89,9 @@
*/
OPUS_CUSTOM_EXPORT void opus_custom_mode_destroy(OpusCustomMode *mode);
-
-
/* Encoder */
-OPUS_CUSTOM_EXPORT int opus_custom_encoder_get_size(const OpusCustomMode *mode, int channels);
+OPUS_CUSTOM_EXPORT_STATIC int opus_custom_encoder_get_size(const OpusCustomMode *mode, int channels);
/** Creates a new encoder state. Each stream needs its own encoder
state (can't be shared across simultaneous streams).
@@ -101,7 +104,7 @@
*/
OPUS_CUSTOM_EXPORT OpusCustomEncoder *opus_custom_encoder_create(const OpusCustomMode *mode, int channels, int *error);
-OPUS_CUSTOM_EXPORT int opus_custom_encoder_init(OpusCustomEncoder *st, const OpusCustomMode *mode, int channels);
+OPUS_CUSTOM_EXPORT_STATIC int opus_custom_encoder_init(OpusCustomEncoder *st, const OpusCustomMode *mode, int channels);
/** Destroys a an encoder state.
@param st Encoder state to be destroyed
@@ -152,11 +155,9 @@
*/
OPUS_CUSTOM_EXPORT int opus_custom_encoder_ctl(OpusCustomEncoder * restrict st, int request, ...);
-
-
/* Decoder */
-OPUS_CUSTOM_EXPORT int opus_custom_decoder_get_size(const OpusCustomMode *mode, int channels);
+OPUS_CUSTOM_EXPORT_STATIC int opus_custom_decoder_get_size(const OpusCustomMode *mode, int channels);
/** Creates a new decoder state. Each stream needs its own decoder state (can't
be shared across simultaneous streams).
@@ -168,7 +169,7 @@
*/
OPUS_CUSTOM_EXPORT OpusCustomDecoder *opus_custom_decoder_create(const OpusCustomMode *mode, int channels, int *error);
-OPUS_CUSTOM_EXPORT int opus_custom_decoder_init(OpusCustomDecoder *st, const OpusCustomMode *mode, int channels);
+OPUS_CUSTOM_EXPORT_STATIC int opus_custom_decoder_init(OpusCustomDecoder *st, const OpusCustomMode *mode, int channels);
/** Destroys a a decoder state.
@param st Decoder state to be destroyed
@@ -204,7 +205,6 @@
@return Error code
*/
OPUS_CUSTOM_EXPORT int opus_custom_decoder_ctl(OpusCustomDecoder * restrict st, int request, ...);
-
#ifdef __cplusplus
}
--- a/celt/tests/cwrs32-test.c
+++ b/celt/tests/cwrs32-test.c
@@ -5,6 +5,12 @@
#include <stdio.h>
#include <string.h>
+#ifndef CUSTOM_MODES
+#define CUSTOM_MODES
+#else
+#define TEST_CUSTOM_MODES
+#endif
+
#define CELT_C
#include "../celt/stack_alloc.h"
#include "../celt/entenc.c"
@@ -17,7 +23,7 @@
#define NMAX (240)
#define KMAX (128)
-#ifdef CUSTOM_MODES
+#ifdef TEST_CUSTOM_MODES
#define NDIMS (46)
static const int pn[NDIMS]={
@@ -37,7 +43,7 @@
4
};
-#else /* CUSTOM_MODES */
+#else /* TEST_CUSTOM_MODES */
#define NDIMS (22)
static const int pn[NDIMS]={
--- a/celt/tests/mathops-test.c
+++ b/celt/tests/mathops-test.c
@@ -2,6 +2,10 @@
#include "config.h"
#endif
+#ifndef CUSTOM_MODES
+#define CUSTOM_MODES
+#endif
+
#define CELT_C
#include "mathops.c"
--- a/celt/tests/rotation-test.c
+++ b/celt/tests/rotation-test.c
@@ -2,6 +2,10 @@
#include "config.h"
#endif
+#ifndef CUSTOM_MODES
+#define CUSTOM_MODES
+#endif
+
#define CELT_C
#include <stdio.h>