summaryrefslogtreecommitdiff
path: root/apps/codecs/libgme/resampler.h
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-08-17 22:20:09 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-08-17 22:20:09 +0000
commit4d01ace73fdffca366211157b54418516b3a73b6 (patch)
tree8165a373967a826ba67826b60f55911ac344c028 /apps/codecs/libgme/resampler.h
parent4070f4f17b77a030049e146245fc9a399bb68204 (diff)
downloadrockbox-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.h74
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
10typedef short dsample_t; 10typedef short sample_t;
11 11
12enum { stereo = 2 }; 12enum { stereo = 2 };
13enum { max_buf_size = 3960 }; 13enum { max_buf_size = 3960 };
@@ -15,54 +15,62 @@ enum { max_resampler_size = 5942 };
15enum { write_offset = 8 * stereo }; 15enum { write_offset = 8 * stereo };
16enum { gain_bits = 14 }; 16enum { gain_bits = 14 };
17 17
18struct Resampler { 18struct 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
40static inline void Resampler_init( struct Resampler* this ) 41static 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
47blargg_err_t Resampler_reset( struct Resampler* this, int max_pairs ); 51blargg_err_t Resampler_reset( struct Resampler* this, int max_pairs );
48void Resampler_resize( struct Resampler* this, int pairs_per_frame ); 52void Resampler_resize( struct Resampler* this, int pairs_per_frame );
49 53void Resampler_play( struct Resampler* this, int count, sample_t* out, struct Blip_Buffer* );
50void Resampler_play( struct Resampler* this, long count, dsample_t* out, struct Stereo_Buffer* );
51 54
52static inline void Resampler_set_callback(struct Resampler* this, int (*func)( void*, blip_time_t, int, dsample_t* ), void* user_data ) 55static 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
58blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain ); 61blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain );
59 62
60static inline void Resampler_clear( struct Resampler* this ) 63static 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; 71static 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