summaryrefslogtreecommitdiff
path: root/lib/rbcodec/dsp/dsp_sample_io.h
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2012-03-27 19:52:15 -0400
committerMichael Sevakis <jethead71@rockbox.org>2012-04-29 10:00:56 +0200
commitc9bcbe202d010234f76d1046880a790fe2c3a067 (patch)
tree2f15438664ad1b196d6ed8b78065cd050d351956 /lib/rbcodec/dsp/dsp_sample_io.h
parentc9c13497736d8be077663f4458948f7bd526841b (diff)
downloadrockbox-c9bcbe202d010234f76d1046880a790fe2c3a067.tar.gz
rockbox-c9bcbe202d010234f76d1046880a790fe2c3a067.zip
Fundamentally rewrite much of the audio DSP.
Creates a standard buffer passing, local data passing and messaging system for processing stages. Stages can be moved to their own source files to reduce clutter and ease assimilation of new ones. dsp.c becomes dsp_core.c which supports an engine and framework for effects. Formats and change notifications are passed along with the buffer so that they arrive at the correct time at each stage in the chain regardless of the internal delays of a particular one. Removes restrictions on the number of samples that can be processed at a time and it pays attention to destination buffer size restrictions without having to limit input count, which also allows pcmbuf to remain fuller and safely set its own buffer limits as it sees fit. There is no longer a need to query input/output counts given a certain number of input samples; just give it the sizes of the source and destination buffers. Works in harmony with stages that are not deterministic in terms of sample input/output ratio (like both resamplers but most notably the timestretch). As a result it fixes quirks with timestretch hanging up with certain settings and it now operates properly throughout its full settings range. Change-Id: Ib206ec78f6f6c79259c5af9009fe021d68be9734 Reviewed-on: http://gerrit.rockbox.org/200 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested-by: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'lib/rbcodec/dsp/dsp_sample_io.h')
-rw-r--r--lib/rbcodec/dsp/dsp_sample_io.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/rbcodec/dsp/dsp_sample_io.h b/lib/rbcodec/dsp/dsp_sample_io.h
new file mode 100644
index 0000000000..443038919d
--- /dev/null
+++ b/lib/rbcodec/dsp/dsp_sample_io.h
@@ -0,0 +1,62 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2012 Michael Sevakis
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef DSP_SAMPLE_IO_H
22#define DSP_SAMPLE_IO_H
23
24/* 16-bit samples are scaled based on these constants. The shift should be
25 * no more than 15.
26 */
27#define WORD_SHIFT 12
28#define WORD_FRACBITS 27
29#define NATIVE_DEPTH 16
30
31#define SAMPLE_BUF_COUNT 128 /* Per channel, per DSP */
32
33struct sample_io_data;
34
35/* DSP initial buffer input function call prototype */
36typedef void (*sample_input_fn_type)(struct sample_io_data *this,
37 struct dsp_buffer **buf_p);
38
39/* DSP final buffer output function call prototype */
40typedef void (*sample_output_fn_type)(struct sample_io_data *this,
41 struct dsp_buffer *src,
42 struct dsp_buffer *dst);
43
44/* This becomes part of the DSP aggregate */
45struct sample_io_data
46{
47 int outcount; /* 00h: Output count */
48 struct sample_format format; /* General format info */
49 int sample_depth; /* Codec-specified sample depth */
50 int stereo_mode; /* Codec-specified input format */
51 sample_input_fn_type input_samples[2]; /* input functions */
52 struct dsp_buffer sample_buf; /* Buffer descriptor for converted samples */
53 int32_t sample_buf_arr[2][SAMPLE_BUF_COUNT]; /* Internal format */
54 sample_output_fn_type output_samples[2]; /* Final output functions */
55};
56
57/* Sample IO watches the format setting from the codec */
58void dsp_sample_io_configure(struct sample_io_data *this,
59 unsigned int setting,
60 intptr_t value);
61
62#endif /* DSP_SAMPLE_IO_H */