diff options
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/libmad/decoder.c | 2 | ||||
-rw-r--r-- | apps/codecs/libmad/decoder.h | 6 | ||||
-rw-r--r-- | apps/codecs/libmad/frame.c | 26 | ||||
-rw-r--r-- | apps/codecs/libmad/layer3.c | 11 | ||||
-rw-r--r-- | apps/codecs/libmad/stream.c | 3 | ||||
-rw-r--r-- | apps/codecs/libmad/synth.c | 22 | ||||
-rw-r--r-- | apps/codecs/mpa.c | 27 |
7 files changed, 47 insertions, 50 deletions
diff --git a/apps/codecs/libmad/decoder.c b/apps/codecs/libmad/decoder.c index 46f4dfe5f7..af8e96962d 100644 --- a/apps/codecs/libmad/decoder.c +++ b/apps/codecs/libmad/decoder.c | |||
@@ -50,6 +50,7 @@ | |||
50 | # include "synth.h" | 50 | # include "synth.h" |
51 | # include "decoder.h" | 51 | # include "decoder.h" |
52 | 52 | ||
53 | #if 0 /* rockbox: not used */ | ||
53 | /* | 54 | /* |
54 | * NAME: decoder->init() | 55 | * NAME: decoder->init() |
55 | * DESCRIPTION: initialize a decoder object with callback routines | 56 | * DESCRIPTION: initialize a decoder object with callback routines |
@@ -585,3 +586,4 @@ int mad_decoder_message(struct mad_decoder *decoder, | |||
585 | return -1; | 586 | return -1; |
586 | # endif | 587 | # endif |
587 | } | 588 | } |
589 | #endif | ||
diff --git a/apps/codecs/libmad/decoder.h b/apps/codecs/libmad/decoder.h index b9ea0b188f..7700df6f9b 100644 --- a/apps/codecs/libmad/decoder.h +++ b/apps/codecs/libmad/decoder.h | |||
@@ -56,7 +56,7 @@ struct mad_decoder { | |||
56 | } *sync; | 56 | } *sync; |
57 | 57 | ||
58 | void *cb_data; | 58 | void *cb_data; |
59 | 59 | /* rockbox: unused | |
60 | enum mad_flow (*input_func)(void *, struct mad_stream *); | 60 | enum mad_flow (*input_func)(void *, struct mad_stream *); |
61 | enum mad_flow (*header_func)(void *, struct mad_header const *); | 61 | enum mad_flow (*header_func)(void *, struct mad_header const *); |
62 | enum mad_flow (*filter_func)(void *, | 62 | enum mad_flow (*filter_func)(void *, |
@@ -65,8 +65,9 @@ struct mad_decoder { | |||
65 | struct mad_header const *, struct mad_pcm *); | 65 | struct mad_header const *, struct mad_pcm *); |
66 | enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); | 66 | enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); |
67 | enum mad_flow (*message_func)(void *, void *, unsigned int *); | 67 | enum mad_flow (*message_func)(void *, void *, unsigned int *); |
68 | */ | ||
68 | }; | 69 | }; |
69 | 70 | /* rockbox: unused | |
70 | void mad_decoder_init(struct mad_decoder *, void *, | 71 | void mad_decoder_init(struct mad_decoder *, void *, |
71 | enum mad_flow (*)(void *, struct mad_stream *), | 72 | enum mad_flow (*)(void *, struct mad_stream *), |
72 | enum mad_flow (*)(void *, struct mad_header const *), | 73 | enum mad_flow (*)(void *, struct mad_header const *), |
@@ -87,5 +88,6 @@ int mad_decoder_finish(struct mad_decoder *); | |||
87 | 88 | ||
88 | int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode); | 89 | int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode); |
89 | int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); | 90 | int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); |
91 | */ | ||
90 | 92 | ||
91 | # endif | 93 | # endif |
diff --git a/apps/codecs/libmad/frame.c b/apps/codecs/libmad/frame.c index 7fd4235e30..f5e0cf8d32 100644 --- a/apps/codecs/libmad/frame.c +++ b/apps/codecs/libmad/frame.c | |||
@@ -92,8 +92,10 @@ void mad_frame_init(struct mad_frame *frame) | |||
92 | mad_header_init(&frame->header); | 92 | mad_header_init(&frame->header); |
93 | 93 | ||
94 | frame->options = 0; | 94 | frame->options = 0; |
95 | 95 | /* rockbox: comment this to proper zero this array in mad_frame_mute(). overlap | |
96 | * is linked to an array in rockbox' apps/codecs/mpa.c before calling this. | ||
96 | frame->overlap = 0; | 97 | frame->overlap = 0; |
98 | */ | ||
97 | mad_frame_mute(frame); | 99 | mad_frame_mute(frame); |
98 | } | 100 | } |
99 | 101 | ||
@@ -101,6 +103,7 @@ void mad_frame_init(struct mad_frame *frame) | |||
101 | * NAME: frame->finish() | 103 | * NAME: frame->finish() |
102 | * DESCRIPTION: deallocate any dynamic memory associated with frame | 104 | * DESCRIPTION: deallocate any dynamic memory associated with frame |
103 | */ | 105 | */ |
106 | /* rockbox: unused | ||
104 | void mad_frame_finish(struct mad_frame *frame) | 107 | void mad_frame_finish(struct mad_frame *frame) |
105 | { | 108 | { |
106 | mad_header_finish(&frame->header); | 109 | mad_header_finish(&frame->header); |
@@ -110,6 +113,7 @@ void mad_frame_finish(struct mad_frame *frame) | |||
110 | frame->overlap = 0; | 113 | frame->overlap = 0; |
111 | } | 114 | } |
112 | } | 115 | } |
116 | */ | ||
113 | 117 | ||
114 | /* | 118 | /* |
115 | * NAME: decode_header() | 119 | * NAME: decode_header() |
@@ -484,21 +488,7 @@ int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream) | |||
484 | */ | 488 | */ |
485 | void mad_frame_mute(struct mad_frame *frame) | 489 | void mad_frame_mute(struct mad_frame *frame) |
486 | { | 490 | { |
487 | unsigned int s, sb; | 491 | memset((*frame->sbsample_prev), 0, sizeof(*frame->sbsample_prev)); |
488 | 492 | memset((*frame->sbsample) , 0, sizeof(*frame->sbsample)); | |
489 | for (s = 0; s < 36; ++s) { | 493 | memset((*frame->overlap) , 0, sizeof(*frame->overlap)); |
490 | for (sb = 0; sb < 32; ++sb) { | ||
491 | (*frame->sbsample)[0][s][sb] = | ||
492 | (*frame->sbsample)[1][s][sb] = 0; | ||
493 | } | ||
494 | } | ||
495 | |||
496 | if (frame->overlap) { | ||
497 | for (s = 0; s < 18; ++s) { | ||
498 | for (sb = 0; sb < 32; ++sb) { | ||
499 | (*frame->overlap)[0][sb][s] = | ||
500 | (*frame->overlap)[1][sb][s] = 0; | ||
501 | } | ||
502 | } | ||
503 | } | ||
504 | } | 494 | } |
diff --git a/apps/codecs/libmad/layer3.c b/apps/codecs/libmad/layer3.c index 752dbdbf63..0198e66a3d 100644 --- a/apps/codecs/libmad/layer3.c +++ b/apps/codecs/libmad/layer3.c | |||
@@ -3230,8 +3230,10 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) | |||
3230 | enum mad_error error; | 3230 | enum mad_error error; |
3231 | int result = 0; | 3231 | int result = 0; |
3232 | 3232 | ||
3233 | #if 0 /* rockbox: do not allocate */ | ||
3233 | /* allocate Layer III dynamic structures */ | 3234 | /* allocate Layer III dynamic structures */ |
3234 | 3235 | /* rockbox: not used. Both pointers are linked to an array in rockbox' | |
3236 | * apps/codecs/mpa.c before calling this. */ | ||
3235 | if (stream->main_data == 0) { | 3237 | if (stream->main_data == 0) { |
3236 | stream->main_data = malloc(MAD_BUFFER_MDLEN); | 3238 | stream->main_data = malloc(MAD_BUFFER_MDLEN); |
3237 | if (stream->main_data == 0) { | 3239 | if (stream->main_data == 0) { |
@@ -3247,6 +3249,13 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) | |||
3247 | return -1; | 3249 | return -1; |
3248 | } | 3250 | } |
3249 | } | 3251 | } |
3252 | #else | ||
3253 | /* rockbox: This should not happen. Return with error. */ | ||
3254 | if ((stream->main_data == 0) || (frame->overlap == 0)) { | ||
3255 | stream->error = MAD_ERROR_NOMEM; | ||
3256 | return -1; | ||
3257 | } | ||
3258 | #endif /* rockbox */ | ||
3250 | 3259 | ||
3251 | nch = MAD_NCHANNELS(header); | 3260 | nch = MAD_NCHANNELS(header); |
3252 | si_len = (header->flags & MAD_FLAG_LSF_EXT) ? | 3261 | si_len = (header->flags & MAD_FLAG_LSF_EXT) ? |
diff --git a/apps/codecs/libmad/stream.c b/apps/codecs/libmad/stream.c index adc982650c..b0c5ad36fd 100644 --- a/apps/codecs/libmad/stream.c +++ b/apps/codecs/libmad/stream.c | |||
@@ -48,7 +48,10 @@ void mad_stream_init(struct mad_stream *stream) | |||
48 | mad_bit_init(&stream->anc_ptr, 0); | 48 | mad_bit_init(&stream->anc_ptr, 0); |
49 | stream->anc_bitlen = 0; | 49 | stream->anc_bitlen = 0; |
50 | 50 | ||
51 | /* rockbox: comment this to avoid allocation in following code. main_data is | ||
52 | * linked to an array in rockbox' apps/codecs/mpa.c before calling this. | ||
51 | stream->main_data = 0; | 53 | stream->main_data = 0; |
54 | */ | ||
52 | stream->md_len = 0; | 55 | stream->md_len = 0; |
53 | 56 | ||
54 | stream->options = 0; | 57 | stream->options = 0; |
diff --git a/apps/codecs/libmad/synth.c b/apps/codecs/libmad/synth.c index 89f971a1ce..0e7c683783 100644 --- a/apps/codecs/libmad/synth.c +++ b/apps/codecs/libmad/synth.c | |||
@@ -55,18 +55,6 @@ void mad_synth_init(struct mad_synth *synth) | |||
55 | */ | 55 | */ |
56 | void mad_synth_mute(struct mad_synth *synth) | 56 | void mad_synth_mute(struct mad_synth *synth) |
57 | { | 57 | { |
58 | /* | ||
59 | unsigned int ch, s, v; | ||
60 | |||
61 | for (ch = 0; ch < 2; ++ch) { | ||
62 | for (s = 0; s < 16; ++s) { | ||
63 | for (v = 0; v < 8; ++v) { | ||
64 | synth->filter[ch][0][0][s][v] = synth->filter[ch][0][1][s][v] = | ||
65 | synth->filter[ch][1][0][s][v] = synth->filter[ch][1][1][s][v] = 0; | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | */ | ||
70 | memset(synth->filter, 0, sizeof(synth->filter)); | 58 | memset(synth->filter, 0, sizeof(synth->filter)); |
71 | } | 59 | } |
72 | 60 | ||
@@ -1272,8 +1260,10 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame, | |||
1272 | void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame) | 1260 | void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame) |
1273 | { | 1261 | { |
1274 | unsigned int nch, ns; | 1262 | unsigned int nch, ns; |
1263 | #if 0 /* rockbox: unused */ | ||
1275 | void (*synth_frame)(struct mad_synth *, struct mad_frame const *, | 1264 | void (*synth_frame)(struct mad_synth *, struct mad_frame const *, |
1276 | unsigned int, unsigned int); | 1265 | unsigned int, unsigned int); |
1266 | #endif | ||
1277 | 1267 | ||
1278 | nch = MAD_NCHANNELS(&frame->header); | 1268 | nch = MAD_NCHANNELS(&frame->header); |
1279 | ns = MAD_NSBSAMPLES(&frame->header); | 1269 | ns = MAD_NSBSAMPLES(&frame->header); |
@@ -1282,18 +1272,20 @@ void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame) | |||
1282 | synth->pcm.channels = nch; | 1272 | synth->pcm.channels = nch; |
1283 | synth->pcm.length = 32 * ns; | 1273 | synth->pcm.length = 32 * ns; |
1284 | 1274 | ||
1275 | #if 0 /* rockbox: unused */ | ||
1285 | synth_frame = synth_full; | 1276 | synth_frame = synth_full; |
1286 | 1277 | ||
1287 | #if 0 /* rockbox: unused */ | ||
1288 | if (frame->options & MAD_OPTION_HALFSAMPLERATE) { | 1278 | if (frame->options & MAD_OPTION_HALFSAMPLERATE) { |
1289 | synth->pcm.samplerate /= 2; | 1279 | synth->pcm.samplerate /= 2; |
1290 | synth->pcm.length /= 2; | 1280 | synth->pcm.length /= 2; |
1291 | 1281 | ||
1292 | synth_frame = synth_half; | 1282 | synth_frame = synth_half; |
1293 | } | 1283 | } |
1294 | #endif | 1284 | |
1295 | |||
1296 | synth_frame(synth, frame, nch, ns); | 1285 | synth_frame(synth, frame, nch, ns); |
1286 | #else | ||
1287 | synth_full(synth, frame, nch, ns); | ||
1288 | #endif | ||
1297 | 1289 | ||
1298 | synth->phase = (synth->phase + ns) % 16; | 1290 | synth->phase = (synth->phase + ns) % 16; |
1299 | } | 1291 | } |
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c index 6fea80807f..3140091434 100644 --- a/apps/codecs/mpa.c +++ b/apps/codecs/mpa.c | |||
@@ -59,30 +59,29 @@ int mpeg_framesize[3] = {384, 1152, 1152}; | |||
59 | static void init_mad(void) | 59 | static void init_mad(void) |
60 | { | 60 | { |
61 | ci->memset(&stream, 0, sizeof(struct mad_stream)); | 61 | ci->memset(&stream, 0, sizeof(struct mad_stream)); |
62 | ci->memset(&frame, 0, sizeof(struct mad_frame)); | 62 | ci->memset(&frame , 0, sizeof(struct mad_frame)); |
63 | ci->memset(&synth, 0, sizeof(struct mad_synth)); | 63 | ci->memset(&synth , 0, sizeof(struct mad_synth)); |
64 | |||
65 | ci->memset(&sbsample, 0, sizeof(sbsample)); | ||
66 | 64 | ||
67 | #ifdef MPA_SYNTH_ON_COP | 65 | #ifdef MPA_SYNTH_ON_COP |
68 | frame.sbsample_prev = &sbsample_prev; | 66 | frame.sbsample_prev = &sbsample_prev; |
69 | ci->memset(&sbsample_prev, 0, sizeof(sbsample_prev)); | 67 | frame.sbsample = &sbsample; |
70 | #else | 68 | #else |
71 | frame.sbsample_prev = &sbsample; | 69 | frame.sbsample_prev = &sbsample; |
70 | frame.sbsample = &sbsample; | ||
72 | #endif | 71 | #endif |
73 | 72 | ||
74 | frame.sbsample=&sbsample; | 73 | /* We do this so libmad doesn't try to call codec_calloc(). This needs to |
75 | 74 | * be called before mad_stream_init(), mad_frame_inti() and | |
75 | * mad_synth_init(). */ | ||
76 | frame.overlap = &mad_frame_overlap; | ||
77 | stream.main_data = &mad_main_data; | ||
78 | |||
79 | /* Call mad initialization. Those will zero the arrays frame.overlap, | ||
80 | * frame.sbsample and frame.sbsample_prev. Therefore there is no need to | ||
81 | * zero them here. */ | ||
76 | mad_stream_init(&stream); | 82 | mad_stream_init(&stream); |
77 | mad_frame_init(&frame); | 83 | mad_frame_init(&frame); |
78 | mad_synth_init(&synth); | 84 | mad_synth_init(&synth); |
79 | |||
80 | /* We do this so libmad doesn't try to call codec_calloc() */ | ||
81 | ci->memset(mad_frame_overlap, 0, sizeof(mad_frame_overlap)); | ||
82 | frame.overlap = &mad_frame_overlap; | ||
83 | stream.main_data = &mad_main_data; | ||
84 | |||
85 | |||
86 | } | 85 | } |
87 | 86 | ||
88 | static int get_file_pos(int newtime) | 87 | static int get_file_pos(int newtime) |