diff options
author | Alfred E. Heggestad <alfred.heggestad@gmail.com> | 2018-02-03 18:32:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-03 18:32:38 +0100 |
commit | 74db759ddbed32127ae763ab72be552cff2aebcc (patch) | |
tree | 123ceaaf86cf06a211d8dc29a97007f36cdaa236 /modules/codec2 | |
parent | 671f293bbdf8f234a73d8c2e6fb75a8ee3d039ce (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/codec2')
-rw-r--r-- | modules/codec2/codec2.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/codec2/codec2.c b/modules/codec2/codec2.c index b6911dc..44e8e43 100644 --- a/modules/codec2/codec2.c +++ b/modules/codec2/codec2.c @@ -123,7 +123,7 @@ static int decode_update(struct audec_state **adsp, static int encode(struct auenc_state *aes, uint8_t *buf, - size_t *len, const int16_t *sampv, size_t sampc) + size_t *len, int fmt, const void *sampv, size_t sampc) { if (!buf || !len || !sampv) return EINVAL; @@ -133,6 +133,9 @@ static int encode(struct auenc_state *aes, uint8_t *buf, if (sampc != (size_t)codec2_samples_per_frame(aes->c2)) return EPROTO; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + codec2_encode(aes->c2, buf, (short *)sampv); *len = codec2_bits_per_frame(aes->c2)/8; @@ -141,7 +144,7 @@ static int encode(struct auenc_state *aes, uint8_t *buf, } -static int decode(struct audec_state *ads, int16_t *sampv, +static int decode(struct audec_state *ads, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { if (!sampv || !sampc || !buf) @@ -152,6 +155,9 @@ static int decode(struct audec_state *ads, int16_t *sampv, if (len < (size_t)codec2_bits_per_frame(ads->c2)/8) return EPROTO; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + codec2_decode(ads->c2, sampv, buf); *sampc = codec2_samples_per_frame(ads->c2); |