aboutsummaryrefslogtreecommitdiffstats
path: root/src/codec_hr.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-05-28 10:20:54 +0200
committerHarald Welte <laforge@gnumonks.org>2017-05-28 10:44:06 +0200
commit5912848d2edbf61158ac7edc72c2302649a0d9ed (patch)
treede76a2a48b98730f5cb92af44410e47761d0e61d /src/codec_hr.c
parent62688b60c29225d557da8844d7259ce3eee962c5 (diff)
prepare gapk for dealing with variable-length frames
The existing architecture was modelled around fixed-length codec frame sizes, which of course fails with multi-rate codecs such as AMR.
Diffstat (limited to 'src/codec_hr.c')
-rw-r--r--src/codec_hr.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/codec_hr.c b/src/codec_hr.c
index 4377f19..0b16985 100644
--- a/src/codec_hr.c
+++ b/src/codec_hr.c
@@ -17,6 +17,8 @@
* along with gapk. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <assert.h>
+
#include <gapk/codecs.h>
#include <gapk/benchmark.h>
@@ -41,25 +43,31 @@ codec_hr_exit(void *_state)
}
static int
-codec_hr_encode(void *_state, uint8_t *cod, const uint8_t *pcm)
+codec_hr_encode(void *_state, uint8_t *cod, const uint8_t *pcm, unsigned int pcm_len)
{
struct gsmhr *state = _state;
int rc;
+ assert(pcm_len == PCM_CANON_LEN);
BENCHMARK_START;
rc = gsmhr_encode(state, (int16_t *)cod, (const int16_t *)pcm);
BENCHMARK_STOP(CODEC_HR, 1);
- return rc;
+ if (rc < 0)
+ return rc;
+ return HR_CANON_LEN;
}
static int
-codec_hr_decode(void *_state, uint8_t *pcm, const uint8_t *cod)
+codec_hr_decode(void *_state, uint8_t *pcm, const uint8_t *cod, unsigned int cod_len)
{
struct gsmhr *state = _state;
int rc;
+ assert(cod_len == HR_CANON_LEN);
BENCHMARK_START;
rc = gsmhr_decode(state, (int16_t *)pcm, (const int16_t *)cod);
BENCHMARK_STOP(CODEC_HR, 0);
- return rc;
+ if (rc < 0)
+ return rc;
+ return PCM_CANON_LEN;
}
#endif /* HAVE_LIBGSMHR */