Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Add support for more formats. At present 24 bit for...
details: https://anonhg.NetBSD.org/src/rev/220b9cf92b58
branches: trunk
changeset: 354529:220b9cf92b58
user: nat <nat%NetBSD.org@localhost>
date: Tue Jun 20 07:21:50 2017 +0000
description:
Add support for more formats. At present 24 bit formats do not work and
have been disabled.
Ok christos@.
diffstat:
sys/dev/auconv.c | 557 +++++++++++++++++++++++++++++++++++++-----------------
sys/dev/auconv.h | 28 ++-
sys/dev/mulaw.c | 362 +++++++++++++++++++++--------------
sys/dev/mulaw.h | 27 ++-
4 files changed, 648 insertions(+), 326 deletions(-)
diffs (truncated from 1133 to 300 lines):
diff -r 7b1dfd18a1f6 -r 220b9cf92b58 sys/dev/auconv.c
--- a/sys/dev/auconv.c Tue Jun 20 07:13:09 2017 +0000
+++ b/sys/dev/auconv.c Tue Jun 20 07:21:50 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auconv.c,v 1.26 2017/06/01 09:44:30 pgoyette Exp $ */
+/* $NetBSD: auconv.c,v 1.27 2017/06/20 07:21:50 nat Exp $ */
/*
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.26 2017/06/01 09:44:30 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.27 2017/06/20 07:21:50 nat Exp $");
#include <sys/types.h>
#include <sys/audioio.h>
@@ -113,86 +113,216 @@
stream_filter_factory_t *play_conv;
stream_filter_factory_t *rec_conv;
};
+#define TABLE_LIST(prec, valid, target) \
+ {AUDIO_ENCODING_SLINEAR_LE, prec, valid, \
+ linear##target##_##target##_to_linear##prec, \
+ linear##prec##_##valid##_to_linear##target}, \
+ {AUDIO_ENCODING_SLINEAR_BE, prec, valid, \
+ linear##target##_##target##_to_linear##prec, \
+ linear##prec##_##valid##_to_linear##target}, \
+ {AUDIO_ENCODING_ULINEAR_LE, prec, valid, \
+ linear##target##_##target##_to_linear##prec, \
+ linear##prec##_##valid##_to_linear##target}, \
+ {AUDIO_ENCODING_ULINEAR_BE, prec, valid, \
+ linear##target##_##target##_to_linear##prec, \
+ linear##prec##_##valid##_to_linear##target},
+#if NMULAW > 0
+#define MULAW_TABLE(prec, valid, target) \
+ {AUDIO_ENCODING_ULAW, 8, 8, \
+ linear##prec##_##valid##_to_mulaw, \
+ mulaw_to_linear##target}, \
+ {AUDIO_ENCODING_ALAW, 8, 8, \
+ linear##prec##_##valid##_to_alaw, \
+ alaw_to_linear##target},
+#endif
/*
* SLINEAR-16 or SLINEAR-24 should precede in a table because
* aurateconv supports only SLINEAR.
*/
static const struct conv_table s8_table[] = {
- {AUDIO_ENCODING_SLINEAR_LE, 16, 16,
- linear8_to_linear16, linear16_to_linear8},
- {AUDIO_ENCODING_SLINEAR_BE, 16, 16,
- linear8_to_linear16, linear16_to_linear8},
- {AUDIO_ENCODING_ULINEAR_LE, 8, 8,
- change_sign8, change_sign8},
+ TABLE_LIST(32, 32, 8)
+ TABLE_LIST(24, 32, 8)
+ TABLE_LIST(24, 24, 8)
+ TABLE_LIST(16, 16, 8)
+ TABLE_LIST(8, 8, 8)
+#if NMULAW > 0
+ MULAW_TABLE(8, 8, 8)
+#endif
{0, 0, 0, NULL, NULL}};
static const struct conv_table u8_table[] = {
- {AUDIO_ENCODING_SLINEAR_LE, 16, 16,
- linear8_to_linear16, linear16_to_linear8},
- {AUDIO_ENCODING_SLINEAR_BE, 16, 16,
- linear8_to_linear16, linear16_to_linear8},
- {AUDIO_ENCODING_SLINEAR_LE, 8, 8,
- change_sign8, change_sign8},
- {AUDIO_ENCODING_ULINEAR_LE, 16, 16,
- linear8_to_linear16, linear16_to_linear8},
- {AUDIO_ENCODING_ULINEAR_BE, 16, 16,
- linear8_to_linear16, linear16_to_linear8},
+ TABLE_LIST(32, 32, 8)
+ TABLE_LIST(24, 32, 8)
+ TABLE_LIST(24, 24, 8)
+ TABLE_LIST(16, 16, 8)
+ TABLE_LIST(8, 8, 8)
+#if NMULAW > 0
+ MULAW_TABLE(8, 8, 8)
+#endif
{0, 0, 0, NULL, NULL}};
static const struct conv_table s16le_table[] = {
- {AUDIO_ENCODING_SLINEAR_BE, 16, 16,
- swap_bytes, swap_bytes},
- {AUDIO_ENCODING_ULINEAR_LE, 16, 16,
- change_sign16, change_sign16},
- {AUDIO_ENCODING_ULINEAR_BE, 16, 16,
- swap_bytes_change_sign16, swap_bytes_change_sign16},
+ TABLE_LIST(32, 32, 16)
+ TABLE_LIST(24, 32, 16)
+ TABLE_LIST(24, 24, 16)
+ TABLE_LIST(16, 16, 16)
+ TABLE_LIST(8, 8, 16)
+#if NMULAW > 0
+ MULAW_TABLE(16, 16, 16)
+#endif
{0, 0, 0, NULL, NULL}};
static const struct conv_table s16be_table[] = {
- {AUDIO_ENCODING_SLINEAR_LE, 16, 16,
- swap_bytes, swap_bytes},
- {AUDIO_ENCODING_ULINEAR_BE, 16, 16,
- change_sign16, change_sign16},
- {AUDIO_ENCODING_ULINEAR_LE, 16, 16,
- swap_bytes_change_sign16, swap_bytes_change_sign16},
+ TABLE_LIST(32, 32, 16)
+ TABLE_LIST(24, 32, 16)
+ TABLE_LIST(24, 24, 16)
+ TABLE_LIST(16, 16, 16)
+ TABLE_LIST(8, 8, 16)
+#if NMULAW > 0
+ MULAW_TABLE(16, 16, 16)
+#endif
{0, 0, 0, NULL, NULL}};
static const struct conv_table u16le_table[] = {
- {AUDIO_ENCODING_SLINEAR_LE, 16, 16,
- change_sign16, change_sign16},
- {AUDIO_ENCODING_ULINEAR_BE, 16, 16,
- swap_bytes, swap_bytes},
- {AUDIO_ENCODING_SLINEAR_BE, 16, 16,
- swap_bytes_change_sign16, swap_bytes_change_sign16},
+ TABLE_LIST(32, 32, 16)
+ TABLE_LIST(24, 32, 16)
+ TABLE_LIST(24, 24, 16)
+ TABLE_LIST(16, 16, 16)
+ TABLE_LIST(8, 8, 16)
+#if NMULAW > 0
+ MULAW_TABLE(16, 16, 16)
+#endif
{0, 0, 0, NULL, NULL}};
static const struct conv_table u16be_table[] = {
- {AUDIO_ENCODING_SLINEAR_BE, 16, 16,
- change_sign16, change_sign16},
- {AUDIO_ENCODING_ULINEAR_LE, 16, 16,
- swap_bytes, swap_bytes},
- {AUDIO_ENCODING_SLINEAR_LE, 16, 16,
- swap_bytes_change_sign16, swap_bytes_change_sign16},
+ TABLE_LIST(32, 32, 16)
+ TABLE_LIST(24, 32, 16)
+ TABLE_LIST(24, 24, 16)
+ TABLE_LIST(16, 16, 16)
+ TABLE_LIST(8, 8, 16)
+#if NMULAW > 0
+ MULAW_TABLE(16, 16, 16)
+#endif
+ {0, 0, 0, NULL, NULL}};
+static const struct conv_table s24le_table[] = {
+ TABLE_LIST(32, 32, 24)
+ TABLE_LIST(24, 32, 24)
+ TABLE_LIST(24, 24, 24)
+ TABLE_LIST(16, 16, 24)
+ TABLE_LIST(8, 8, 24)
+#if NMULAW > 0
+ MULAW_TABLE(24, 24, 24)
+#endif
+ {0, 0, 0, NULL, NULL}};
+static const struct conv_table s24be_table[] = {
+ TABLE_LIST(32, 32, 24)
+ TABLE_LIST(24, 32, 24)
+ TABLE_LIST(24, 24, 24)
+ TABLE_LIST(16, 16, 24)
+ TABLE_LIST(8, 8, 24)
+#if NMULAW > 0
+ MULAW_TABLE(24, 24, 24)
+#endif
+ {0, 0, 0, NULL, NULL}};
+static const struct conv_table u24le_table[] = {
+ TABLE_LIST(32, 32, 24)
+ TABLE_LIST(24, 32, 24)
+ TABLE_LIST(24, 24, 24)
+ TABLE_LIST(16, 16, 24)
+ TABLE_LIST(8, 8, 24)
+#if NMULAW > 0
+ MULAW_TABLE(24, 24, 24)
+#endif
+ {0, 0, 0, NULL, NULL}};
+static const struct conv_table u24be_table[] = {
+ TABLE_LIST(32, 32, 24)
+ TABLE_LIST(24, 32, 24)
+ TABLE_LIST(24, 24, 24)
+ TABLE_LIST(16, 16, 24)
+ TABLE_LIST(8, 8, 24)
+#if NMULAW > 0
+ MULAW_TABLE(24, 24, 24)
+#endif
+ {0, 0, 0, NULL, NULL}};
+static const struct conv_table s32le_table[] = {
+ TABLE_LIST(32, 32, 32)
+ TABLE_LIST(24, 32, 32)
+ TABLE_LIST(24, 24, 32)
+ TABLE_LIST(16, 16, 32)
+ TABLE_LIST(8, 8, 32)
+#if NMULAW > 0
+ MULAW_TABLE(32, 32, 32)
+#endif
+ {0, 0, 0, NULL, NULL}};
+static const struct conv_table s32be_table[] = {
+ TABLE_LIST(32, 32, 32)
+ TABLE_LIST(24, 32, 32)
+ TABLE_LIST(24, 24, 32)
+ TABLE_LIST(16, 16, 32)
+ TABLE_LIST(8, 8, 32)
+#if NMULAW > 0
+ MULAW_TABLE(32, 32, 32)
+#endif
+ {0, 0, 0, NULL, NULL}};
+static const struct conv_table u32le_table[] = {
+ TABLE_LIST(32, 32, 32)
+ TABLE_LIST(24, 32, 32)
+ TABLE_LIST(24, 24, 32)
+ TABLE_LIST(16, 16, 32)
+ TABLE_LIST(8, 8, 32)
+#if NMULAW > 0
+ MULAW_TABLE(32, 32, 32)
+#endif
+ {0, 0, 0, NULL, NULL}};
+static const struct conv_table u32be_table[] = {
+ TABLE_LIST(32, 32, 32)
+ TABLE_LIST(24, 32, 32)
+ TABLE_LIST(24, 24, 32)
+ TABLE_LIST(16, 16, 32)
+ TABLE_LIST(8, 8, 32)
+#if NMULAW > 0
+ MULAW_TABLE(32, 32, 32)
+#endif
{0, 0, 0, NULL, NULL}};
#if NMULAW > 0
+#define MULAW_LIST(prec, valid, target) \
+ {AUDIO_ENCODING_SLINEAR_LE, prec, valid, \
+ mulaw_to_linear##target, \
+ linear##prec##_##valid##_to_mulaw}, \
+ {AUDIO_ENCODING_SLINEAR_BE, prec, valid, \
+ mulaw_to_linear##target, \
+ linear##prec##_##valid##_to_mulaw}, \
+ {AUDIO_ENCODING_ULINEAR_LE, prec, valid, \
+ mulaw_to_linear##target, \
+ linear##prec##_##valid##_to_mulaw}, \
+ {AUDIO_ENCODING_ULINEAR_BE, prec, valid, \
+ mulaw_to_linear##target, \
+ linear##prec##_##valid##_to_mulaw},
+
+#define ALAW_LIST(prec, valid, target) \
+ {AUDIO_ENCODING_SLINEAR_LE, prec, valid, \
+ alaw_to_linear##target, \
+ linear##prec##_##valid##_to_alaw}, \
+ {AUDIO_ENCODING_SLINEAR_BE, prec, valid, \
+ alaw_to_linear##target, \
+ linear##prec##_##valid##_to_alaw}, \
+ {AUDIO_ENCODING_ULINEAR_LE, prec, valid, \
+ alaw_to_linear##target, \
+ linear##prec##_##valid##_to_alaw}, \
+ {AUDIO_ENCODING_ULINEAR_BE, prec, valid, \
+ alaw_to_linear##target, \
+ linear##prec##_##valid##_to_alaw},
+
static const struct conv_table mulaw_table[] = {
- {AUDIO_ENCODING_SLINEAR_LE, 16, 16,
- mulaw_to_linear16, linear16_to_mulaw},
- {AUDIO_ENCODING_SLINEAR_BE, 16, 16,
- mulaw_to_linear16, linear16_to_mulaw},
- {AUDIO_ENCODING_ULINEAR_LE, 16, 16,
- mulaw_to_linear16, linear16_to_mulaw},
- {AUDIO_ENCODING_ULINEAR_BE, 16, 16,
- mulaw_to_linear16, linear16_to_mulaw},
+ MULAW_LIST(32, 32, 32)
+ MULAW_LIST(24, 32, 24)
+ MULAW_LIST(24, 24, 24)
+ MULAW_LIST(16, 16, 16)
{AUDIO_ENCODING_SLINEAR_LE, 8, 8,
mulaw_to_linear8, linear8_to_mulaw},
{AUDIO_ENCODING_ULINEAR_LE, 8, 8,
mulaw_to_linear8, linear8_to_mulaw},
{0, 0, 0, NULL, NULL}};
static const struct conv_table alaw_table[] = {
- {AUDIO_ENCODING_SLINEAR_LE, 16, 16,
- alaw_to_linear16, linear16_to_alaw},
- {AUDIO_ENCODING_SLINEAR_BE, 16, 16,
- alaw_to_linear16, linear16_to_alaw},
- {AUDIO_ENCODING_ULINEAR_LE, 16, 16,
- alaw_to_linear16, linear16_to_alaw},
- {AUDIO_ENCODING_ULINEAR_BE, 16, 16,
- alaw_to_linear16, linear16_to_alaw},
+ ALAW_LIST(32, 32, 32)
+ ALAW_LIST(24, 32, 24)
+ ALAW_LIST(24, 24, 24)
+ ALAW_LIST(16, 16, 16)
{AUDIO_ENCODING_SLINEAR_LE, 8, 8,
alaw_to_linear8, linear8_to_alaw},
{AUDIO_ENCODING_ULINEAR_LE, 8, 8,
@@ -351,124 +481,193 @@
return 0;
}
-DEFINE_FILTER(linear8_to_linear16)
-{
- stream_filter_t *this;
- int m, err, enc_dst, enc_src;
-
Home |
Main Index |
Thread Index |
Old Index