diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-11-13 20:04:12 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-11-13 20:04:12 +0000 |
commit | 6d94a5b2e34c55611f2d6ea70c241971e65afc8c (patch) | |
tree | 2f5893ae395f1656a9e54869b02f2d441e462a31 /sbc | |
parent | 1d85e2973463f7b194a4c31bd9c5954822cf3022 (diff) |
Add sbc_reinit.
Diffstat (limited to 'sbc')
-rw-r--r-- | sbc/sbc.c | 38 | ||||
-rw-r--r-- | sbc/sbc.h | 1 |
2 files changed, 31 insertions, 8 deletions
@@ -1208,6 +1208,17 @@ struct sbc_priv { struct sbc_encoder_state enc_state; }; +static void sbc_fill_defaults(sbc_t *sbc, unsigned long flags) +{ + sbc->rate = 44100; + sbc->channels = 2; + sbc->joint = 0; + sbc->subbands = 8; + sbc->blocks = 16; + sbc->bitpool = 32; + sbc->swap = 0; +} + int sbc_init(sbc_t *sbc, unsigned long flags) { if (!sbc) @@ -1221,13 +1232,7 @@ int sbc_init(sbc_t *sbc, unsigned long flags) memset(sbc->priv, 0, sizeof(struct sbc_priv)); - sbc->rate = 44100; - sbc->channels = 2; - sbc->joint = 0; - sbc->subbands = 8; - sbc->blocks = 16; - sbc->bitpool = 32; - sbc->swap = 0; + sbc_fill_defaults(sbc, flags); return 0; } @@ -1389,7 +1394,7 @@ int sbc_get_frame_length(sbc_t *sbc) ret = 4 + (4 * sbc->subbands * sbc->channels) / 8; - /* This term is not always evenly devide so we round it up */ + /* This term is not always evenly divide so we round it up */ if (sbc->channels == 1) ret += ((sbc->blocks * sbc->channels * sbc->bitpool) + 7) / 8; else @@ -1403,3 +1408,20 @@ int sbc_get_codesize(sbc_t *sbc) { return sbc->subbands * sbc->blocks * sbc->channels * 2; } + +int sbc_reinit(sbc_t *sbc, unsigned long flags) +{ + struct sbc_priv *priv; + + if (!sbc || !sbc->priv) + return -EIO; + + priv = sbc->priv; + + if (priv->init == 1) + memset(sbc->priv, 0, sizeof(struct sbc_priv)); + + sbc_fill_defaults(sbc, flags); + + return 0; +} @@ -50,6 +50,7 @@ struct sbc_struct { typedef struct sbc_struct sbc_t; int sbc_init(sbc_t *sbc, unsigned long flags); +int sbc_reinit(sbc_t *sbc, unsigned long flags); int sbc_parse(sbc_t *sbc, void *input, int input_len); int sbc_decode(sbc_t *sbc, void *input, int input_len, void *output, int output_len, int *len); |