MadMP3Decoder.hpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: MadMP3Decoder.hpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 /*********************************************************************** 00037 * * 00038 * REVISION HISTORY: * 00039 * * 00040 * * 00041 * * 00042 ***********************************************************************/ 00043 00044 #ifndef _MadMP3Decoder_HPP 00045 #define _MadMP3Decoder_HPP 00046 00047 #include <math.h> /* for pow() and log10() */ 00048 #include <mad.h> 00049 00050 #include "AudioAdaptor.hpp" 00051 #include "AudioESInfo.hpp" 00052 #include "IO.hpp" 00053 #include "io/DevNull.hpp" 00054 00055 00067 class MadMP3Decoder : public AudioAdaptor { 00068 public: 00069 00070 /* Constructor 00071 * @param outStream defines th IO class for writing the output 00072 * @param autoFix if set to <code>false</code>, automatic insertion feature turned off 00073 * 00074 */ 00075 MadMP3Decoder(AudioESInfo* es); 00076 00077 virtual ~MadMP3Decoder(); 00078 00079 list < Frame * >adapt(Frame * frm); 00080 00081 Adaptor* clone() { return new MadMP3Decoder(es); }; 00082 00083 void initialize(); 00084 00085 list < Frame * >close() { 00086 list < Frame * >tmp; 00087 return tmp; 00088 }; 00089 00090 00095 u32 getTranscodingCosts() const { 00096 return es->getAvgBandwidth()/8; 00097 } 00098 00099 private: 00100 protected: 00101 static signed short MadFixedToSshort(mad_fixed_t Fixed); 00102 static void PrintFrameInfo(struct mad_header *Header); 00103 00104 00105 00106 #define MAD_INPUT_BUFFER_SIZE (5*8192) 00107 00108 struct mad_stream Stream; 00109 struct mad_frame madFrame; 00110 struct mad_synth Synth; 00111 mad_timer_t Timer; 00112 unsigned char *inputBuffer; 00113 unsigned char *guardPtr; 00114 int Status; 00115 unsigned long FrameCount; 00116 00117 u32 numInFrames; 00118 bool initialized; 00119 u32 lastTS; 00120 AU * pAU; 00121 }; 00122 00123 #endif 00124