00001 #ifndef MADMP3_H_
00002 #define MADMP3_H_
00003
00004 #include "decoder.h"
00005
00006 extern "C" {
00007 #include <mad.h>
00008 }
00009
00010 class Metadata;
00011
00012 class MadDecoder : public Decoder
00013 {
00014 public:
00015 MadDecoder(const QString &file, DecoderFactory *, QIODevice *, AudioOutput *);
00016 virtual ~MadDecoder(void);
00017
00018 bool initialize();
00019 void seek(double);
00020 void stop();
00021
00022 static const int maxDecodeRetries;
00023 static const int maxFrameSize;
00024 static const int maxFrameCheck;
00025 static const int initialFrameSize;
00026
00027 MetaIO *doCreateTagger(void);
00028
00029 private:
00030 void run();
00031
00032 enum mad_flow madOutput();
00033 enum mad_flow madError(struct mad_stream *, struct mad_frame *);
00034
00035 void flush(bool = FALSE);
00036 void deinit();
00037 bool findHeader();
00038 bool findXingHeader(struct mad_bitptr, unsigned int);
00039 void calcLength(struct mad_header *);
00040
00041 bool inited, user_stop, done, finish, derror, eof, useeq;
00042 double totalTime, seekTime;
00043 int stat, channels;
00044 long bitrate, freq, len;
00045 unsigned int bks;
00046 mad_fixed_t eqbands[32];
00047
00048 char *input_buf;
00049 unsigned long input_bytes;
00050
00051 char *output_buf;
00052 unsigned long output_bytes, output_at, output_size;
00053
00054 struct {
00055 int flags;
00056 unsigned long frames;
00057 unsigned long bytes;
00058 unsigned char toc[100];
00059 long scale;
00060 } xing;
00061
00062 enum {
00063 XING_FRAMES = 0x0001,
00064 XING_BYTES = 0x0002,
00065 XING_TOC = 0x0004,
00066 XING_SCALE = 0x0008
00067 };
00068
00069 struct mad_stream stream;
00070 struct mad_frame frame;
00071 struct mad_synth synth;
00072 };
00073
00074 #endif
00075