Comment unused code in libmad. Clean up initialization and memset'ing of decoder arrays.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27159 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andree Buschmann 2010-06-27 18:11:07 +00:00
parent 9e86287946
commit 4c026f0c7f
7 changed files with 47 additions and 50 deletions

View file

@ -50,6 +50,7 @@
# include "synth.h"
# include "decoder.h"
#if 0 /* rockbox: not used */
/*
* NAME: decoder->init()
* DESCRIPTION: initialize a decoder object with callback routines
@ -585,3 +586,4 @@ int mad_decoder_message(struct mad_decoder *decoder,
return -1;
# endif
}
#endif

View file

@ -56,7 +56,7 @@ struct mad_decoder {
} *sync;
void *cb_data;
/* rockbox: unused
enum mad_flow (*input_func)(void *, struct mad_stream *);
enum mad_flow (*header_func)(void *, struct mad_header const *);
enum mad_flow (*filter_func)(void *,
@ -65,8 +65,9 @@ struct mad_decoder {
struct mad_header const *, struct mad_pcm *);
enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *);
enum mad_flow (*message_func)(void *, void *, unsigned int *);
*/
};
/* rockbox: unused
void mad_decoder_init(struct mad_decoder *, void *,
enum mad_flow (*)(void *, struct mad_stream *),
enum mad_flow (*)(void *, struct mad_header const *),
@ -87,5 +88,6 @@ int mad_decoder_finish(struct mad_decoder *);
int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode);
int mad_decoder_message(struct mad_decoder *, void *, unsigned int *);
*/
# endif

View file

@ -92,8 +92,10 @@ void mad_frame_init(struct mad_frame *frame)
mad_header_init(&frame->header);
frame->options = 0;
/* rockbox: comment this to proper zero this array in mad_frame_mute(). overlap
* is linked to an array in rockbox' apps/codecs/mpa.c before calling this.
frame->overlap = 0;
*/
mad_frame_mute(frame);
}
@ -101,6 +103,7 @@ void mad_frame_init(struct mad_frame *frame)
* NAME: frame->finish()
* DESCRIPTION: deallocate any dynamic memory associated with frame
*/
/* rockbox: unused
void mad_frame_finish(struct mad_frame *frame)
{
mad_header_finish(&frame->header);
@ -110,6 +113,7 @@ void mad_frame_finish(struct mad_frame *frame)
frame->overlap = 0;
}
}
*/
/*
* NAME: decode_header()
@ -484,21 +488,7 @@ int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream)
*/
void mad_frame_mute(struct mad_frame *frame)
{
unsigned int s, sb;
for (s = 0; s < 36; ++s) {
for (sb = 0; sb < 32; ++sb) {
(*frame->sbsample)[0][s][sb] =
(*frame->sbsample)[1][s][sb] = 0;
}
}
if (frame->overlap) {
for (s = 0; s < 18; ++s) {
for (sb = 0; sb < 32; ++sb) {
(*frame->overlap)[0][sb][s] =
(*frame->overlap)[1][sb][s] = 0;
}
}
}
memset((*frame->sbsample_prev), 0, sizeof(*frame->sbsample_prev));
memset((*frame->sbsample) , 0, sizeof(*frame->sbsample));
memset((*frame->overlap) , 0, sizeof(*frame->overlap));
}

View file

@ -3230,8 +3230,10 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame)
enum mad_error error;
int result = 0;
#if 0 /* rockbox: do not allocate */
/* allocate Layer III dynamic structures */
/* rockbox: not used. Both pointers are linked to an array in rockbox'
* apps/codecs/mpa.c before calling this. */
if (stream->main_data == 0) {
stream->main_data = malloc(MAD_BUFFER_MDLEN);
if (stream->main_data == 0) {
@ -3247,6 +3249,13 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame)
return -1;
}
}
#else
/* rockbox: This should not happen. Return with error. */
if ((stream->main_data == 0) || (frame->overlap == 0)) {
stream->error = MAD_ERROR_NOMEM;
return -1;
}
#endif /* rockbox */
nch = MAD_NCHANNELS(header);
si_len = (header->flags & MAD_FLAG_LSF_EXT) ?

View file

@ -48,7 +48,10 @@ void mad_stream_init(struct mad_stream *stream)
mad_bit_init(&stream->anc_ptr, 0);
stream->anc_bitlen = 0;
/* rockbox: comment this to avoid allocation in following code. main_data is
* linked to an array in rockbox' apps/codecs/mpa.c before calling this.
stream->main_data = 0;
*/
stream->md_len = 0;
stream->options = 0;

View file

@ -55,18 +55,6 @@ void mad_synth_init(struct mad_synth *synth)
*/
void mad_synth_mute(struct mad_synth *synth)
{
/*
unsigned int ch, s, v;
for (ch = 0; ch < 2; ++ch) {
for (s = 0; s < 16; ++s) {
for (v = 0; v < 8; ++v) {
synth->filter[ch][0][0][s][v] = synth->filter[ch][0][1][s][v] =
synth->filter[ch][1][0][s][v] = synth->filter[ch][1][1][s][v] = 0;
}
}
}
*/
memset(synth->filter, 0, sizeof(synth->filter));
}
@ -1272,8 +1260,10 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame)
{
unsigned int nch, ns;
#if 0 /* rockbox: unused */
void (*synth_frame)(struct mad_synth *, struct mad_frame const *,
unsigned int, unsigned int);
#endif
nch = MAD_NCHANNELS(&frame->header);
ns = MAD_NSBSAMPLES(&frame->header);
@ -1282,18 +1272,20 @@ void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame)
synth->pcm.channels = nch;
synth->pcm.length = 32 * ns;
#if 0 /* rockbox: unused */
synth_frame = synth_full;
#if 0 /* rockbox: unused */
if (frame->options & MAD_OPTION_HALFSAMPLERATE) {
synth->pcm.samplerate /= 2;
synth->pcm.length /= 2;
synth_frame = synth_half;
}
#endif
synth_frame(synth, frame, nch, ns);
#else
synth_full(synth, frame, nch, ns);
#endif
synth->phase = (synth->phase + ns) % 16;
}

View file

@ -62,27 +62,26 @@ static void init_mad(void)
ci->memset(&frame , 0, sizeof(struct mad_frame));
ci->memset(&synth , 0, sizeof(struct mad_synth));
ci->memset(&sbsample, 0, sizeof(sbsample));
#ifdef MPA_SYNTH_ON_COP
frame.sbsample_prev = &sbsample_prev;
ci->memset(&sbsample_prev, 0, sizeof(sbsample_prev));
frame.sbsample = &sbsample;
#else
frame.sbsample_prev = &sbsample;
frame.sbsample = &sbsample;
#endif
frame.sbsample=&sbsample;
mad_stream_init(&stream);
mad_frame_init(&frame);
mad_synth_init(&synth);
/* We do this so libmad doesn't try to call codec_calloc() */
ci->memset(mad_frame_overlap, 0, sizeof(mad_frame_overlap));
/* We do this so libmad doesn't try to call codec_calloc(). This needs to
* be called before mad_stream_init(), mad_frame_inti() and
* mad_synth_init(). */
frame.overlap = &mad_frame_overlap;
stream.main_data = &mad_main_data;
/* Call mad initialization. Those will zero the arrays frame.overlap,
* frame.sbsample and frame.sbsample_prev. Therefore there is no need to
* zero them here. */
mad_stream_init(&stream);
mad_frame_init(&frame);
mad_synth_init(&synth);
}
static int get_file_pos(int newtime)