From 526fc6e5e906937c3227b88c238d2a6d7e520434 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 28 May 2017 16:16:21 +0200 Subject: [PATCH] Fix HR codec block sizes The ETSI reference codec actually uses an array of 20/22 16bit values rather than a "canonical" format. The conversion is what fmt_hr_ref.c is doing. However, codec_hr.c must then subsequently not check for the canonical input/output sizes, but those specific to it. --- include/gapk/codecs.h | 2 ++ src/codec_hr.c | 4 ++-- src/fmt_hr_ref.c | 3 --- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/gapk/codecs.h b/include/gapk/codecs.h index f62cb25..aa1c829 100644 --- a/include/gapk/codecs.h +++ b/include/gapk/codecs.h @@ -26,6 +26,8 @@ #define HR_CANON_LEN 14 #define EFR_CANON_LEN 31 #define PCM_CANON_LEN (160*sizeof(uint16_t)) +#define HR_REF_ENC_LEN (20 * sizeof(uint16_t)) +#define HR_REF_DEC_LEN (22 * sizeof(uint16_t)) enum codec_type { CODEC_INVALID = 0, diff --git a/src/codec_hr.c b/src/codec_hr.c index 0b16985..b3247e0 100644 --- a/src/codec_hr.c +++ b/src/codec_hr.c @@ -53,7 +53,7 @@ codec_hr_encode(void *_state, uint8_t *cod, const uint8_t *pcm, unsigned int pcm BENCHMARK_STOP(CODEC_HR, 1); if (rc < 0) return rc; - return HR_CANON_LEN; + return HR_REF_ENC_LEN; } static int @@ -61,7 +61,7 @@ codec_hr_decode(void *_state, uint8_t *pcm, const uint8_t *cod, unsigned int cod { struct gsmhr *state = _state; int rc; - assert(cod_len == HR_CANON_LEN); + assert(cod_len == HR_REF_DEC_LEN); BENCHMARK_START; rc = gsmhr_decode(state, (int16_t *)pcm, (const int16_t *)cod); BENCHMARK_STOP(CODEC_HR, 0); diff --git a/src/fmt_hr_ref.c b/src/fmt_hr_ref.c index 32e8d48..d64918b 100644 --- a/src/fmt_hr_ref.c +++ b/src/fmt_hr_ref.c @@ -26,9 +26,6 @@ #include #include -#define HR_REF_DEC_LEN (22 * sizeof(uint16_t)) -#define HR_REF_ENC_LEN (20 * sizeof(uint16_t)) - static const int params_unvoiced[] = { 5, /* R0 */ 11, /* k1Tok3 */