summaryrefslogtreecommitdiff
path: root/modules/amr
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2018-02-03 18:32:38 +0100
committerGitHub <noreply@github.com>2018-02-03 18:32:38 +0100
commit74db759ddbed32127ae763ab72be552cff2aebcc (patch)
tree123ceaaf86cf06a211d8dc29a97007f36cdaa236 /modules/amr
parent671f293bbdf8f234a73d8c2e6fb75a8ee3d039ce (diff)
Aucodec sample format (#352)
* aucodec: merge s16 and fmt encode/decode into one having 2 different encode functions for s16 and other formats turned out to be a bit impractical. better to have 1 function where the sample format (fmt) can be specified. * update some aucodec modules * update test * update codec2 * update g7221 module
Diffstat (limited to 'modules/amr')
-rw-r--r--modules/amr/amr.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/modules/amr/amr.c b/modules/amr/amr.c
index 885a318..58343a1 100644
--- a/modules/amr/amr.c
+++ b/modules/amr/amr.c
@@ -16,6 +16,7 @@
#include <dec_if.h>
#endif
#include <re.h>
+#include <rem.h>
#include <baresip.h>
#include "amr.h"
@@ -205,7 +206,7 @@ static int decode_update(struct audec_state **adsp,
#ifdef AMR_WB
static int encode_wb(struct auenc_state *st, uint8_t *buf, size_t *len,
- const int16_t *sampv, size_t sampc)
+ int fmt, const void *sampv, size_t sampc)
{
int n;
@@ -215,6 +216,9 @@ static int encode_wb(struct auenc_state *st, uint8_t *buf, size_t *len,
if (*len < NB_SERIAL_MAX)
return ENOMEM;
+ if (fmt != AUFMT_S16LE)
+ return ENOTSUP;
+
/* CMR value 15 indicates that no mode request is present */
buf[0] = 15 << 4;
@@ -228,7 +232,8 @@ static int encode_wb(struct auenc_state *st, uint8_t *buf, size_t *len,
}
-static int decode_wb(struct audec_state *st, int16_t *sampv, size_t *sampc,
+static int decode_wb(struct audec_state *st,
+ int fmt, void *sampv, size_t *sampc,
const uint8_t *buf, size_t len)
{
if (*sampc < L_FRAME16k)
@@ -236,6 +241,9 @@ static int decode_wb(struct audec_state *st, int16_t *sampv, size_t *sampc,
if (len > NB_SERIAL_MAX)
return EINVAL;
+ if (fmt != AUFMT_S16LE)
+ return ENOTSUP;
+
IF2D_IF_decode(st->dec, &buf[1], sampv, 0);
*sampc = L_FRAME16k;
@@ -247,7 +255,7 @@ static int decode_wb(struct audec_state *st, int16_t *sampv, size_t *sampc,
#ifdef AMR_NB
static int encode_nb(struct auenc_state *st, uint8_t *buf,
- size_t *len, const int16_t *sampv, size_t sampc)
+ size_t *len, int fmt, const void *sampv, size_t sampc)
{
int r;
@@ -256,6 +264,9 @@ static int encode_nb(struct auenc_state *st, uint8_t *buf,
if (*len < NB_SERIAL_MAX)
return ENOMEM;
+ if (fmt != AUFMT_S16LE)
+ return ENOTSUP;
+
/* CMR value 15 indicates that no mode request is present */
buf[0] = 15 << 4;
@@ -269,7 +280,7 @@ static int encode_nb(struct auenc_state *st, uint8_t *buf,
}
-static int decode_nb(struct audec_state *st, int16_t *sampv,
+static int decode_nb(struct audec_state *st, int fmt, void *sampv,
size_t *sampc, const uint8_t *buf, size_t len)
{
if (!st || !sampv || !sampc || !buf)
@@ -281,6 +292,9 @@ static int decode_nb(struct audec_state *st, int16_t *sampv,
if (*sampc < L_FRAME16k)
return ENOMEM;
+ if (fmt != AUFMT_S16LE)
+ return ENOTSUP;
+
Decoder_Interface_Decode(st->dec, &buf[1], sampv, 0);
*sampc = FRAMESIZE_NB;