diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-17 22:20:09 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-17 22:20:09 +0000 |
commit | 4d01ace73fdffca366211157b54418516b3a73b6 (patch) | |
tree | 8165a373967a826ba67826b60f55911ac344c028 /apps/codecs/libgme/resampler.h | |
parent | 4070f4f17b77a030049e146245fc9a399bb68204 (diff) | |
download | rockbox-4d01ace73fdffca366211157b54418516b3a73b6.tar.gz rockbox-4d01ace73fdffca366211157b54418516b3a73b6.zip |
Submit a patch to the VGM codec by Mauricio Gama which saves some more RAM through changes of the buffer configuration and an update of the resampler code. Additionally enable VGM for low memory targets and update the manual.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30327 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libgme/resampler.h')
-rw-r--r-- | apps/codecs/libgme/resampler.h | 74 |
1 files changed, 41 insertions, 33 deletions
diff --git a/apps/codecs/libgme/resampler.h b/apps/codecs/libgme/resampler.h index 3106b84d35..1d8f86670b 100644 --- a/apps/codecs/libgme/resampler.h +++ b/apps/codecs/libgme/resampler.h | |||
@@ -4,10 +4,10 @@ | |||
4 | #ifndef RESAMPLER_H | 4 | #ifndef RESAMPLER_H |
5 | #define RESAMPLER_H | 5 | #define RESAMPLER_H |
6 | 6 | ||
7 | #include "blargg_config.h" | 7 | #include "blargg_common.h" |
8 | #include "multi_buffer.h" | 8 | #include "multi_buffer.h" |
9 | 9 | ||
10 | typedef short dsample_t; | 10 | typedef short sample_t; |
11 | 11 | ||
12 | enum { stereo = 2 }; | 12 | enum { stereo = 2 }; |
13 | enum { max_buf_size = 3960 }; | 13 | enum { max_buf_size = 3960 }; |
@@ -15,54 +15,62 @@ enum { max_resampler_size = 5942 }; | |||
15 | enum { write_offset = 8 * stereo }; | 15 | enum { write_offset = 8 * stereo }; |
16 | enum { gain_bits = 14 }; | 16 | enum { gain_bits = 14 }; |
17 | 17 | ||
18 | struct Resampler { | 18 | struct Resampler { |
19 | int (*callback)( void*, blip_time_t, int, dsample_t* ); | 19 | int (*callback)( void*, blip_time_t, int, sample_t* ); |
20 | void* callback_data; | 20 | void* callback_data; |
21 | 21 | ||
22 | dsample_t sample_buf [max_buf_size]; | 22 | int sample_buffer_size; |
23 | int sample_buf_size; | 23 | int sample_buf_size; |
24 | int oversamples_per_frame; | 24 | int oversamples_per_frame; |
25 | int buf_pos; | 25 | int buf_pos; |
26 | int resampler_size; | 26 | int resampler_size; |
27 | int gain_; | 27 | int gain_; |
28 | 28 | ||
29 | // Internal resampler | 29 | int buffer_size; |
30 | dsample_t buf [max_resampler_size]; | 30 | int write_pos; |
31 | int buffer_size; | 31 | |
32 | 32 | int pos; | |
33 | int write_pos; | 33 | int step; |
34 | int rate_; | 34 | |
35 | 35 | int rate_; | |
36 | int pos; | 36 | |
37 | int step; | 37 | sample_t sample_buf [max_buf_size]; |
38 | sample_t buf [max_resampler_size]; // Internal resampler | ||
38 | }; | 39 | }; |
39 | 40 | ||
40 | static inline void Resampler_init( struct Resampler* this ) | 41 | static inline void Resampler_init( struct Resampler* this ) |
41 | { | 42 | { |
42 | this->pos = 0; | 43 | this->pos = 0; |
43 | this->write_pos = 0; | 44 | this->write_pos = 0; |
44 | this->rate_ = 0; | 45 | this->rate_ = 0; |
46 | this->sample_buf_size = 0; | ||
47 | this->sample_buffer_size = 0; | ||
48 | this->oversamples_per_frame = 0; | ||
45 | } | 49 | } |
46 | 50 | ||
47 | blargg_err_t Resampler_reset( struct Resampler* this, int max_pairs ); | 51 | blargg_err_t Resampler_reset( struct Resampler* this, int max_pairs ); |
48 | void Resampler_resize( struct Resampler* this, int pairs_per_frame ); | 52 | void Resampler_resize( struct Resampler* this, int pairs_per_frame ); |
49 | 53 | void Resampler_play( struct Resampler* this, int count, sample_t* out, struct Blip_Buffer* ); | |
50 | void Resampler_play( struct Resampler* this, long count, dsample_t* out, struct Stereo_Buffer* ); | ||
51 | 54 | ||
52 | static inline void Resampler_set_callback(struct Resampler* this, int (*func)( void*, blip_time_t, int, dsample_t* ), void* user_data ) | 55 | static inline void Resampler_set_callback(struct Resampler* this, int (*func)( void*, blip_time_t, int, sample_t* ), void* user_data ) |
53 | { | 56 | { |
54 | this->callback = func; | 57 | this->callback = func; |
55 | this->callback_data = user_data; | 58 | this->callback_data = user_data; |
56 | } | 59 | } |
57 | 60 | ||
58 | blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain ); | 61 | blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain ); |
59 | 62 | ||
60 | static inline void Resampler_clear( struct Resampler* this ) | 63 | static inline void Resampler_clear( struct Resampler* this ) |
61 | { | 64 | { |
62 | this->buf_pos = this->sample_buf_size; | 65 | this->buf_pos = this->sample_buf_size; |
66 | |||
67 | this->pos = 0; | ||
68 | this->write_pos = 0; | ||
69 | } | ||
63 | 70 | ||
64 | this->pos = 0; | 71 | static inline int Resampler_rate( struct Resampler* this ) |
65 | this->write_pos = 0; | 72 | { |
73 | return this->rate_; | ||
66 | } | 74 | } |
67 | 75 | ||
68 | #endif | 76 | #endif |