aboutsummaryrefslogtreecommitdiffstats
path: root/include/gapk
diff options
context:
space:
mode:
Diffstat (limited to 'include/gapk')
-rw-r--r--include/gapk/Makefile.am6
-rw-r--r--include/gapk/benchmark.h60
-rw-r--r--include/gapk/codecs.h71
-rw-r--r--include/gapk/formats.h94
-rw-r--r--include/gapk/get_cycles.h138
-rw-r--r--include/gapk/procqueue.h72
-rw-r--r--include/gapk/utils.h104
7 files changed, 0 insertions, 545 deletions
diff --git a/include/gapk/Makefile.am b/include/gapk/Makefile.am
deleted file mode 100644
index 5fcc3b9..0000000
--- a/include/gapk/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-noinst_HEADERS = benchmark.h \
- codecs.h \
- formats.h \
- get_cycles.h \
- procqueue.h \
- utils.h
diff --git a/include/gapk/benchmark.h b/include/gapk/benchmark.h
deleted file mode 100644
index 49c2c36..0000000
--- a/include/gapk/benchmark.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef _BENCHMARK_H
-#define _BENCHMARK_H
-
-/*
- * This file is part of gapk (GSM Audio Pocket Knife).
- *
- * gapk is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * gapk is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with gapk. If not, see <http://www.gnu.org/licenses/>.
- *
- * (C) 2014 Harald Welte <laforge@gnumonks.org>
- */
-
-#include <gapk/get_cycles.h>
-#include <gapk/codecs.h>
-
-#define NUM_AVG 102400
-
-struct benchmark_cycles {
- cycles_t enc[NUM_AVG];
- unsigned int enc_used;
- cycles_t dec[NUM_AVG];
- unsigned int dec_used;
-};
-
-extern struct benchmark_cycles codec_cycles[_CODEC_MAX];
-
-static inline void benchmark_stop(enum codec_type codec, int encode, unsigned long cycles)
-{
- struct benchmark_cycles *bc = &codec_cycles[codec];
-
- if (encode) {
- bc->enc_used = (bc->enc_used + 1) % NUM_AVG;
- bc->enc[bc->enc_used] = cycles;
- } else {
- bc->dec_used = (bc->dec_used + 1) % NUM_AVG;
- bc->dec[bc->dec_used] = cycles;
- }
-}
-
-#define BENCHMARK_START do { \
- cycles_t _cycles_start, _cycles_stop; \
- _cycles_start = get_cycles()
-
-#define BENCHMARK_STOP(x,y) _cycles_stop = get_cycles(); \
- benchmark_stop(x, y, _cycles_stop - _cycles_start); \
- } while (0)
-
-void benchmark_dump(void);
-
-#endif
diff --git a/include/gapk/codecs.h b/include/gapk/codecs.h
deleted file mode 100644
index aa1c829..0000000
--- a/include/gapk/codecs.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Codecs handling */
-
-/*
- * This file is part of gapk (GSM Audio Pocket Knife).
- *
- * gapk is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * gapk is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with gapk. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GAPK_CODECS_H__
-#define __GAPK_CODECS_H__
-
-#include <stdint.h>
-
-#define FR_CANON_LEN 33
-#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,
- CODEC_PCM, /* 16 bits PCM samples */
- CODEC_HR, /* GSM Half Rate codec GSM 06.20 */
- CODEC_FR, /* GSM Full Rate codec GSM 06.10 */
- CODEC_EFR, /* GSM Enhanced Full Rate codec GSM 06.60 */
- CODEC_AMR, /* GSM Adaptive Multi Rate codec GSM 26.071 */
- _CODEC_MAX,
-};
-
-#include <gapk/formats.h> /* need to import here because or enum interdep */
-
-/*! call-back for actual codec conversion function
- * \param[in] state opaque state pointer (returned by codec->init)
- * \param[out] dst caller-allocated buffer for output data
- * \param[in] src input data
- * \param[in] src_len length of input data \a src
- * \returns number of output bytes written to \a dst; negative on error */
-typedef int (*codec_conv_cb_t)(void *state, uint8_t *dst, const uint8_t *src, unsigned int src_len);
-
-struct codec_desc {
- enum codec_type type;
- const char * name;
- const char * description;
- /*! canonical frame size (in bytes); 0 in case of variable length */
- unsigned int canon_frame_len;
-
- enum format_type codec_enc_format_type; /* what the encoder provides */
- enum format_type codec_dec_format_type; /* what to give the decoder */
- /*! codec initialization function pointer, returns opaque state */
- void * (*codec_init)(void);
- /*! codec exit function pointer, gets passed opaque state */
- void (*codec_exit)(void *state);
- codec_conv_cb_t codec_encode;
- codec_conv_cb_t codec_decode;
-};
-
-const struct codec_desc *codec_get_from_type(enum codec_type type);
-
-#endif /* __GAPK_CODECS_H__ */
diff --git a/include/gapk/formats.h b/include/gapk/formats.h
deleted file mode 100644
index 81670b8..0000000
--- a/include/gapk/formats.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Formats handling */
-
-/*
- * This file is part of gapk (GSM Audio Pocket Knife).
- *
- * gapk is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * gapk is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with gapk. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GAPK_FORMATS_H__
-#define __GAPK_FORMATS_H__
-
-#include <stdint.h>
-
-enum format_type {
- FMT_INVALID = 0,
-
- /* Classic .amr container */
- FMT_AMR_EFR,
-
- /* Classic .gsm file for FR */
- FMT_GSM,
-
- /* 3GPP Reference HR vocodec files */
- FMT_HR_REF_DEC,
- FMT_HR_REF_ENC,
-
- /* Racal 6103E TCH recordings */
- FMT_RACAL_HR,
- FMT_RACAL_FR,
- FMT_RACAL_EFR,
-
- /* Raw PCM */
- FMT_RAWPCM_S16LE,
-
- /* Texas Instrument calypso/locosto buffer format */
- FMT_TI_HR,
- FMT_TI_FR,
- FMT_TI_EFR,
-
- /* AMR encoded data, variable length */
- FMT_AMR_OPENCORE,
- FMT_RTP_AMR,
-
- FMT_RTP_EFR,
-
- /* HR in RTP according to ETSI TS 101 318 */
- FMT_RTP_HR_ETSI,
- /* HR in RTP according to IETF RFC5993 */
- FMT_RTP_HR_IETF,
-
- _FMT_MAX,
-};
-
-#include <gapk/codecs.h> /* need to import here because or enum interdep */
-
-/*! call-back for actual format conversion function
- * \param[out] dst caller-allocated buffer for output data
- * \param[in] src input data
- * \param[in] src_len length of input data \a src
- * \returns number of output bytes written to \a dst; negative on error */
-typedef int (*fmt_conv_cb_t)(uint8_t *dst, const uint8_t *src, unsigned int src_len);
-
-struct format_desc {
- enum format_type type;
- enum codec_type codec_type;
- const char * name;
- const char * description;
-
- /*! length of frames in this format (as opposed to canonical) */
- unsigned int frame_len;
- fmt_conv_cb_t conv_from_canon;
- fmt_conv_cb_t conv_to_canon;
-
- /*! length of a (global) header at start of file */
- unsigned int header_len;
- /*! exact match for (global) header at start of file */
- const uint8_t * header;
-};
-
-const struct format_desc *fmt_get_from_type(enum format_type type);
-const struct format_desc *fmt_get_from_name(const char *name);
-
-#endif /* __GAPK_FORMATS_H__ */
diff --git a/include/gapk/get_cycles.h b/include/gapk/get_cycles.h
deleted file mode 100644
index 9eb7bc3..0000000
--- a/include/gapk/get_cycles.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2005 Mellanox Technologies Ltd.,
- * (c) 2005 Harald Welte <laforge@gnumonks.org>, All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id$
- */
-
-#ifndef GET_CLOCK_H
-#define GET_CLOCK_H
-
-#if 0
-
-#define _POSIX_C_SOURCE 199506L
-#include <unistd.h>
-#include <time.h>
-
-/* Ideally we would be using clock_getres() and clock_gettime().
- * glibc manpage says CLOCK_PROCESS_CPUTIME_ID is only defined if it is
- * actually present. however, on ppc64 it is defined but not implemented. */
-#ifdef CLOCK_PROCESS_CPUTIME_ID
-typedef long cycles_t;
-static inline cycles_t get_cycles()
-{
- struct timespec ts;
-
-#if defined (__x86_64__) || defined(__i386__)
- asm volatile ("cpuid" : : : "eax", "ebx", "ecx", "edx" ); /* flush pipeline */
-#endif
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
- return ts.tv_nsec;
-}
-#endif
-
-#endif
-
-#if defined (__x86_64__) || defined(__i386__)
-/* Note: only x86 CPUs which have rdtsc instruction are supported. */
-typedef unsigned long long cycles_t;
-static inline cycles_t get_cycles()
-{
- unsigned low, high;
- unsigned long long val;
- asm volatile ("cpuid" : : : "eax", "ebx", "ecx", "edx" ); /* flush pipeline */
- asm volatile ("rdtsc" : "=a" (low), "=d" (high));
- val = high;
- val = (val << 32) | low;
- return val;
-}
-#elif defined(__PPC64__)
-/* Note: only PPC CPUs which have mftb instruction are supported. */
-typedef unsigned long long cycles_t;
-static inline cycles_t get_cycles()
-{
- cycles_t ret;
-
- asm volatile ("mftb %0" : "=r" (ret) : );
- return ret;
-}
-#elif defined(__sparc__)
-/* Note: only sparc64 supports this register */
-typedef unsigned long long cycles_t;
-#define TICK_PRIV_BIT (1ULL << 63)
-static inline cycles_t get_cycles()
-{
- cycles_t ret;
-
-#if defined(__sparcv9) || defined(__arch64__)
- asm volatile ("rd %%tick, %0" : "=r" (ret));
-#else
- asm volatile ("rd %%tick, %%g1\n\t"
- "srlx %%g1, 32, %H0\n\t"
- "srl %%g1, 0, %L0"
- : "=r" (ret)
- : /* no inputs */
- : "g1");
-#endif
- return ret & ~TICK_PRIV_BIT;
-}
-#elif defined(__PPC__)
-#define CPU_FTR_601 0x00000100
-typedef unsigned long cycles_t;
-static inline cycles_t get_cycles()
-{
- cycles_t ret;
-
- asm volatile (
- "98: mftb %0\n"
- "99:\n"
- ".section __ftr_fixup,\"a\"\n"
- " .long %1\n"
- " .long 0\n"
- " .long 98b\n"
- " .long 99b\n"
- ".previous"
- : "=r" (ret) : "i" (CPU_FTR_601));
- return ret;
-}
-#elif defined(__ia64__) || defined(__mips__) || \
- defined(__s390__)
-/* Itanium2 and up has ar.itc (Itanium1 has errata) */
-/* PPC64 has mftb */
-#include <asm/timex.h>
-#else
-#warning get_cycles not implemented for this architecture: attempt asm/timex.h
-#include <asm/timex.h>
-#endif
-
-extern double get_cpu_mhz(void);
-
-#endif /* GET_CLOCK_H */
diff --git a/include/gapk/procqueue.h b/include/gapk/procqueue.h
deleted file mode 100644
index d9a5546..0000000
--- a/include/gapk/procqueue.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Processing Queue Management */
-
-/*
- * This file is part of gapk (GSM Audio Pocket Knife).
- *
- * gapk is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * gapk is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with gapk. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GAPK_PROCQUEUE_H__
-#define __GAPK_PROCQUEUE_H__
-
-#include <stdint.h>
-#include <stdio.h> /* for FILE */
-
-struct pq;
-
-struct pq_item {
- /*! input frame size (in bytes). '0' in case of variable frames */
- int len_in;
- /*! output frame size (in bytes). '0' in case of variable frames */
- int len_out;
- /*! opaque state */
- void *state;
- /*! call-back for actual format conversion function
- * \param[in] state opaque state pointer
- * \param[out] out caller-allocated buffer for output data
- * \param[in] in input data
- * \param[in] in_len length of input data \a in
- * \returns number of output bytes written to \a out; negative on error */
- int (*proc)(void *state, uint8_t *out, const uint8_t *in, unsigned int in_len);
- void (*exit)(void *state);
-};
-
-/* Management */
-struct pq * pq_create(void);
-void pq_destroy(struct pq *pq);
-struct pq_item * pq_add_item(struct pq *pq);
-int pq_prepare(struct pq *pq);
-int pq_execute(struct pq *pq);
-
-/* File */
-int pq_queue_file_input(struct pq *pq, FILE *src, unsigned int block_len);
-int pq_queue_file_output(struct pq *pq, FILE *dst, unsigned int block_len);
-
-/* RTP */
-int pq_queue_rtp_input(struct pq *pq, int rtp_fd, unsigned int block_len);
-int pq_queue_rtp_output(struct pq *pq, int rtp_fd, unsigned int block_len);
-
-/* ALSA */
-int pq_queue_alsa_input(struct pq *pq, const char *hwdev, unsigned int blk_len);
-int pq_queue_alsa_output(struct pq *pq, const char *hwdev, unsigned int blk_len);
-
-/* Format */
-struct format_desc;
-int pq_queue_fmt_convert(struct pq *pq, const struct format_desc *fmt, int to_from_n);
-
-/* Codec */
-struct codec_desc;
-int pq_queue_codec(struct pq *pq, const struct codec_desc *codec, int encode);
-
-#endif /* __GAPK_PROCQUEUE_H__ */
diff --git a/include/gapk/utils.h b/include/gapk/utils.h
deleted file mode 100644
index 3b02049..0000000
--- a/include/gapk/utils.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* Various helpers */
-
-/*
- * This file is part of gapk (GSM Audio Pocket Knife).
- *
- * gapk is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * gapk is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with gapk. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GAPK_UTILS_H__
-#define __GAPK_UTILS_H__
-
-#include <stdint.h>
-
-static inline int
-msb_get_bit(const uint8_t *buf, int bn)
-{
- int pos_byte = bn >> 3;
- int pos_bit = 7 - (bn & 7);
-
- return (buf[pos_byte] >> pos_bit) & 1;
-}
-
-static inline void
-msb_put_bit(uint8_t *buf, int bn, int bit)
-{
- int pos_byte = bn >> 3;
- int pos_bit = 7 - (bn & 7);
-
- if (bit)
- buf[pos_byte] |= (1 << pos_bit);
- else
- buf[pos_byte] &= ~(1 << pos_bit);
-}
-
-static inline void
-msb_set_bit(uint8_t *buf, int bn)
-{
- int pos_byte = bn >> 3;
- int pos_bit = 7 - (bn & 7);
-
- buf[pos_byte] |= (1 << pos_bit);
-}
-
-static inline void
-msb_clr_bit(uint8_t *buf, int bn)
-{
- int pos_byte = bn >> 3;
- int pos_bit = 7 - (bn & 7);
-
- buf[pos_byte] &= ~(1 << pos_bit);
-}
-
-
-static inline int
-lsb_get_bit(const uint8_t *buf, int bn)
-{
- int pos_byte = bn >> 3;
- int pos_bit = bn & 7;
-
- return (buf[pos_byte] >> pos_bit) & 1;
-}
-
-static inline void
-lsb_put_bit(uint8_t *buf, int bn, int bit)
-{
- int pos_byte = bn >> 3;
- int pos_bit = bn & 7;
-
- if (bit)
- buf[pos_byte] |= (1 << pos_bit);
- else
- buf[pos_byte] &= ~(1 << pos_bit);
-}
-
-static inline void
-lsb_set_bit(uint8_t *buf, int bn)
-{
- int pos_byte = bn >> 3;
- int pos_bit = bn & 7;
-
- buf[pos_byte] |= (1 << pos_bit);
-}
-
-static inline void
-lsb_clr_bit(uint8_t *buf, int bn)
-{
- int pos_byte = bn >> 3;
- int pos_bit = bn & 7;
-
- buf[pos_byte] &= ~(1 << pos_bit);
-}
-
-#endif /* __GAPK_UTILS_H__ */