aboutsummaryrefslogtreecommitdiffstats
path: root/src/fmt_rawpcm.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/fmt_rawpcm.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/fmt_rawpcm.c')
-rw-r--r--src/fmt_rawpcm.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/fmt_rawpcm.c b/src/fmt_rawpcm.c
index e20fcaf..207708c 100644
--- a/src/fmt_rawpcm.c
+++ b/src/fmt_rawpcm.c
@@ -17,35 +17,40 @@
* along with gapk. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <assert.h>
+
#include <gapk/codecs.h>
#include <gapk/formats.h>
-
static int
-rawpcm_s16le_from_canon(uint8_t *dst, const uint8_t *src)
+rawpcm_s16le_from_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len)
{
int i;
const uint16_t *samples = (const uint16_t *)src;
+ assert(src_len == PCM_CANON_LEN);
+
for (i=0; i<160; i++) {
uint16_t w = samples[i];
dst[(i<<1) ] = w & 0xff;
dst[(i<<1)+1] = (w >> 8) & 0xff;
}
- return 0;
+ return PCM_CANON_LEN;
}
static int
-rawpcm_s16le_to_canon(uint8_t *dst, const uint8_t *src)
+rawpcm_s16le_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len)
{
int i;
uint16_t *samples = (uint16_t *)dst;
+ assert(src_len == PCM_CANON_LEN);
+
for (i=0; i<160; i++)
samples[i] = (src[(i<<1)+1] << 8) | src[(i<<1)];
- return 0;
+ return PCM_CANON_LEN;
}
const struct format_desc fmt_rawpcm_s16le = {