00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _MP3_INTERNALS_HH
00022 #define _MP3_INTERNALS_HH
00023
00024 #ifndef _BOOLEAN_HH
00025 #include "Boolean.hh"
00026 #endif
00027 #ifndef _BIT_VECTOR_HH
00028 #include "BitVector.hh"
00029 #endif
00030
00031 typedef struct MP3SideInfo {
00032 unsigned main_data_begin;
00033 unsigned private_bits;
00034 typedef struct gr_info_s {
00035 int scfsi;
00036 unsigned part2_3_length;
00037 unsigned big_values;
00038 unsigned global_gain;
00039 unsigned scalefac_compress;
00040 unsigned window_switching_flag;
00041 unsigned block_type;
00042 unsigned mixed_block_flag;
00043 unsigned table_select[3];
00044 unsigned region0_count;
00045 unsigned region1_count;
00046 unsigned subblock_gain[3];
00047 unsigned maxband[3];
00048 unsigned maxbandl;
00049 unsigned maxb;
00050 unsigned region1start;
00051 unsigned region2start;
00052 unsigned preflag;
00053 unsigned scalefac_scale;
00054 unsigned count1table_select;
00055 double *full_gain[3];
00056 double *pow2gain;
00057 } gr_info_s_t;
00058 struct {
00059 gr_info_s_t gr[2];
00060 } ch[2];
00061 } MP3SideInfo_t;
00062
00063 #define SBLIMIT 32
00064 #define MAX_MP3_FRAME_SIZE 2500
00065
00066 class MP3FrameParams {
00067 public:
00068 MP3FrameParams();
00069 ~MP3FrameParams();
00070
00071
00072 unsigned hdr;
00073
00074
00075 unsigned char frameBytes[MAX_MP3_FRAME_SIZE];
00076
00077
00078 void setParamsFromHeader();
00079 Boolean isMPEG2;
00080 unsigned layer;
00081 unsigned bitrate;
00082 unsigned samplingFreq;
00083 Boolean isStereo;
00084 Boolean isFreeFormat;
00085 unsigned frameSize;
00086 unsigned sideInfoSize;
00087 Boolean hasCRC;
00088
00089 void setBytePointer(unsigned char const* restOfFrame,
00090 unsigned totNumBytes) {
00091 bv.setup((unsigned char*)restOfFrame, 0, 8*totNumBytes);
00092 }
00093
00094
00095 unsigned oldHdr, firstHdr;
00096
00097
00098 void getSideInfo(MP3SideInfo& si);
00099
00100
00101 unsigned getBits(unsigned numBits) { return bv.getBits(numBits); }
00102 unsigned get1Bit() { return bv.get1Bit(); }
00103
00104 private:
00105 BitVector bv;
00106
00107
00108 unsigned bitrateIndex;
00109 unsigned samplingFreqIndex;
00110 Boolean isMPEG2_5;
00111 Boolean padding;
00112 Boolean extension;
00113 unsigned mode;
00114 unsigned mode_ext;
00115 Boolean copyright;
00116 Boolean original;
00117 unsigned emphasis;
00118 unsigned stereo;
00119
00120 private:
00121 unsigned computeSideInfoSize();
00122 };
00123
00124 unsigned ComputeFrameSize(unsigned bitrate, unsigned samplingFreq,
00125 Boolean usePadding, Boolean isMPEG2,
00126 unsigned char layer);
00127
00128 Boolean GetADUInfoFromMP3Frame(unsigned char const* framePtr,
00129 unsigned totFrameSize,
00130 unsigned& hdr, unsigned& frameSize,
00131 MP3SideInfo& sideInfo, unsigned& sideInfoSize,
00132 unsigned& backpointer, unsigned& aduSize);
00133
00134 Boolean ZeroOutMP3SideInfo(unsigned char* framePtr, unsigned totFrameSize,
00135 unsigned newBackpointer);
00136
00137 unsigned TranscodeMP3ADU(unsigned char const* fromPtr, unsigned fromSize,
00138 unsigned toBitrate,
00139 unsigned char* toPtr, unsigned toMaxSize,
00140 unsigned& availableBytesForBackpointer);
00141
00142
00143 #endif