diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2012-12-19 17:34:57 -0500 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2013-05-04 13:43:33 -0400 |
commit | 78a45b47dede5ddf35dfc53e965b486a79177b18 (patch) | |
tree | edb3ad7c101e600a7cc3be4b40380430cbeb3e55 /lib/rbcodec/dsp/dsp_core.h | |
parent | cdb71c707bb434f44368b72f2db3becc37b7a46c (diff) | |
download | rockbox-78a45b47dede5ddf35dfc53e965b486a79177b18.tar.gz rockbox-78a45b47dede5ddf35dfc53e965b486a79177b18.zip |
Cleanup and simplify latest DSP code incarnation.
Some things can just be a bit simpler in handling the list of stages
and some things, especially format change handling, can be simplified
for each stage implementation. Format changes are sent through the
configure() callback.
Hide some internal details and variables from processing stages and
let the core deal with it.
Do some miscellaneous cleanup and keep things a bit better factored.
Change-Id: I19dd8ce1d0b792ba914d426013088a49a52ecb7e
Diffstat (limited to 'lib/rbcodec/dsp/dsp_core.h')
-rw-r--r-- | lib/rbcodec/dsp/dsp_core.h | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/lib/rbcodec/dsp/dsp_core.h b/lib/rbcodec/dsp/dsp_core.h index 0119da8af6..713190debc 100644 --- a/lib/rbcodec/dsp/dsp_core.h +++ b/lib/rbcodec/dsp/dsp_core.h | |||
@@ -39,8 +39,10 @@ enum dsp_settings | |||
39 | DSP_SET_SAMPLE_DEPTH, | 39 | DSP_SET_SAMPLE_DEPTH, |
40 | DSP_SET_STEREO_MODE, | 40 | DSP_SET_STEREO_MODE, |
41 | DSP_FLUSH, | 41 | DSP_FLUSH, |
42 | DSP_SET_PITCH, | ||
42 | DSP_PROC_INIT, | 43 | DSP_PROC_INIT, |
43 | DSP_PROC_CLOSE, | 44 | DSP_PROC_CLOSE, |
45 | DSP_PROC_NEW_FORMAT, | ||
44 | DSP_PROC_SETTING, /* stage-specific should be this + id */ | 46 | DSP_PROC_SETTING, /* stage-specific should be this + id */ |
45 | }; | 47 | }; |
46 | 48 | ||
@@ -54,10 +56,13 @@ enum dsp_stereo_modes | |||
54 | STEREO_NUM_MODES, | 56 | STEREO_NUM_MODES, |
55 | }; | 57 | }; |
56 | 58 | ||
57 | /* Format into for the buffer (if .valid == true) */ | 59 | /* Format into for the buffer */ |
58 | struct sample_format | 60 | struct sample_format |
59 | { | 61 | { |
60 | uint8_t changed; /* 00h: 0=no change, 1=changed (is also index) */ | 62 | uint8_t version; /* 00h: format version number (never == 0, |
63 | 0 is used to detect format calls for | ||
64 | individual stages, such as when they | ||
65 | are newly enabled) */ | ||
61 | uint8_t num_channels; /* 01h: number of channels of data */ | 66 | uint8_t num_channels; /* 01h: number of channels of data */ |
62 | uint8_t frac_bits; /* 02h: number of fractional bits */ | 67 | uint8_t frac_bits; /* 02h: number of fractional bits */ |
63 | uint8_t output_scale; /* 03h: output scaling shift */ | 68 | uint8_t output_scale; /* 03h: output scaling shift */ |
@@ -66,16 +71,6 @@ struct sample_format | |||
66 | /* 0ch */ | 71 | /* 0ch */ |
67 | }; | 72 | }; |
68 | 73 | ||
69 | /* Compare format data only */ | ||
70 | #define EQU_SAMPLE_FORMAT(f1, f2) \ | ||
71 | (!memcmp(&(f1).num_channels, &(f2).num_channels, \ | ||
72 | sizeof (f1) - sizeof ((f1).changed))) | ||
73 | |||
74 | static inline void format_change_set(struct sample_format *f) | ||
75 | { f->changed = 1; } | ||
76 | static inline void format_change_ack(struct sample_format *f) | ||
77 | { f->changed = 0; } | ||
78 | |||
79 | /* Used by ASM routines - keep field order or else fix the functions */ | 74 | /* Used by ASM routines - keep field order or else fix the functions */ |
80 | struct dsp_buffer | 75 | struct dsp_buffer |
81 | { | 76 | { |
@@ -133,30 +128,12 @@ static inline void dsp_advance_buffer32(struct dsp_buffer *buf, | |||
133 | buf->p32[1] += by_count; | 128 | buf->p32[1] += by_count; |
134 | } | 129 | } |
135 | 130 | ||
136 | /** For use by processing stages **/ | ||
137 | |||
138 | #define DSP_PRINT_FORMAT(name, id, format) \ | ||
139 | DEBUGF("DSP format- " #name "\n" \ | ||
140 | " id:%d chg:%c ch:%u fb:%u os:%u hz:%u chz:%u\n", \ | ||
141 | (int)id, \ | ||
142 | (format).changed ? 'y' : 'n', \ | ||
143 | (unsigned int)(format).num_channels, \ | ||
144 | (unsigned int)(format).frac_bits, \ | ||
145 | (unsigned int)(format).output_scale, \ | ||
146 | (unsigned int)(format).frequency, \ | ||
147 | (unsigned int)(format).codec_frequency); | ||
148 | |||
149 | /* Get DSP pointer */ | 131 | /* Get DSP pointer */ |
150 | struct dsp_config * dsp_get_config(enum dsp_ids id); | 132 | struct dsp_config * dsp_get_config(enum dsp_ids id); |
151 | 133 | ||
152 | /* Get DSP id */ | 134 | /* Get DSP id */ |
153 | enum dsp_ids dsp_get_id(const struct dsp_config *dsp); | 135 | enum dsp_ids dsp_get_id(const struct dsp_config *dsp); |
154 | 136 | ||
155 | #if 0 /* Not needed now but enable if something must know this */ | ||
156 | /* Is the DSP processing a buffer? */ | ||
157 | bool dsp_is_busy(const struct dsp_config *dsp); | ||
158 | #endif /* 0 */ | ||
159 | |||
160 | /** General DSP processing **/ | 137 | /** General DSP processing **/ |
161 | 138 | ||
162 | /* Process the given buffer - see implementation in dsp.c for more */ | 139 | /* Process the given buffer - see implementation in dsp.c for more */ |