MP3FrameParams Class Reference

#include <MP3Internals.hh>

Collaboration diagram for MP3FrameParams:

Collaboration graph
[legend]

Public Member Functions

 MP3FrameParams ()
 ~MP3FrameParams ()
void setParamsFromHeader ()
void setBytePointer (unsigned char const *restOfFrame, unsigned totNumBytes)
void getSideInfo (MP3SideInfo &si)
unsigned getBits (unsigned numBits)
unsigned get1Bit ()

Data Fields

unsigned hdr
unsigned char frameBytes [MAX_MP3_FRAME_SIZE]
Boolean isMPEG2
unsigned layer
unsigned bitrate
unsigned samplingFreq
Boolean isStereo
Boolean isFreeFormat
unsigned frameSize
unsigned sideInfoSize
Boolean hasCRC
unsigned oldHdr
unsigned firstHdr

Private Member Functions

unsigned computeSideInfoSize ()

Private Attributes

BitVector bv
unsigned bitrateIndex
unsigned samplingFreqIndex
Boolean isMPEG2_5
Boolean padding
Boolean extension
unsigned mode
unsigned mode_ext
Boolean copyright
Boolean original
unsigned emphasis
unsigned stereo

Detailed Description

Definition at line 66 of file MP3Internals.hh.


Constructor & Destructor Documentation

MP3FrameParams::MP3FrameParams (  ) 

Definition at line 99 of file MP3Internals.cpp.

References False, firstHdr, i_slen2, n_slen2, oldHdr, and True.

00100   : bv(frameBytes, 0, sizeof frameBytes) /* by default */ {
00101   oldHdr = firstHdr = 0;
00102 
00103   static Boolean doneInit = False;
00104   if (doneInit) return;
00105   doneInit = True;
00106 
00107   int i,j,k,l;
00108 
00109   for (i=0;i<5;i++) {
00110     for (j=0;j<6;j++) {
00111       for (k=0;k<6;k++) {
00112         int n = k + j * 6 + i * 36;
00113         i_slen2[n] = i|(j<<3)|(k<<6)|(3<<12);
00114       }
00115     }
00116   }
00117   for (i=0;i<4;i++) {
00118     for (j=0;j<4;j++) {
00119       for (k=0;k<4;k++) {
00120         int n = k + j * 4 + i * 16;
00121         i_slen2[n+180] = i|(j<<3)|(k<<6)|(4<<12);
00122       }
00123     }
00124   }
00125   for (i=0;i<4;i++) {
00126     for (j=0;j<3;j++) {
00127       int n = j + i * 3;
00128       i_slen2[n+244] = i|(j<<3) | (5<<12);
00129       n_slen2[n+500] = i|(j<<3) | (2<<12) | (1<<15);
00130     }
00131   }
00132 
00133   for (i=0;i<5;i++) {
00134     for (j=0;j<5;j++) {
00135       for (k=0;k<4;k++) {
00136         for (l=0;l<4;l++) {
00137           int n = l + k * 4 + j * 16 + i * 80;
00138           n_slen2[n] = i|(j<<3)|(k<<6)|(l<<9)|(0<<12);
00139         }
00140       }
00141     }
00142   }
00143   for (i=0;i<5;i++) {
00144     for (j=0;j<5;j++) {
00145       for (k=0;k<4;k++) {
00146         int n = k + j * 4 + i * 20;
00147         n_slen2[n+400] = i|(j<<3)|(k<<6)|(1<<12);
00148       }
00149     }
00150   }
00151 }

MP3FrameParams::~MP3FrameParams (  ) 

Definition at line 153 of file MP3Internals.cpp.

00153                                 {
00154 }


Member Function Documentation

void MP3FrameParams::setParamsFromHeader (  ) 

Definition at line 156 of file MP3Internals.cpp.

References bitrate, bitrateIndex, ComputeFrameSize(), computeSideInfoSize(), copyright, emphasis, extension, frameSize, hasCRC, hdr, isFreeFormat, isMPEG2, isMPEG2_5, isStereo, layer, live_freqs, live_tabsel, mode, mode_ext, MPG_MD_MONO, original, padding, samplingFreq, samplingFreqIndex, sideInfoSize, and stereo.

Referenced by MP3StreamState::findNextFrame(), GetADUInfoFromMP3Frame(), MPEG1or2AudioStreamParser::parse(), TranscodeMP3ADU(), and ZeroOutMP3SideInfo().

00156                                          {
00157   if (hdr & (1<<20)) {
00158     isMPEG2 = (hdr & (1<<19)) ? 0x0 : 0x1;
00159     isMPEG2_5 = 0;
00160   }
00161   else {
00162     isMPEG2 = 1;
00163     isMPEG2_5 = 1;
00164   }
00165 
00166   layer = 4-((hdr>>17)&3);
00167   if (layer == 4) layer = 3; // layer==4 is not allowed
00168   bitrateIndex = ((hdr>>12)&0xf);
00169 
00170   if (isMPEG2_5) {
00171     samplingFreqIndex = ((hdr>>10)&0x3) + 6;
00172   } else {
00173     samplingFreqIndex = ((hdr>>10)&0x3) + (isMPEG2*3);
00174   }
00175 
00176   hasCRC = ((hdr>>16)&0x1)^0x1;
00177 
00178   padding   = ((hdr>>9)&0x1);
00179   extension = ((hdr>>8)&0x1);
00180   mode      = ((hdr>>6)&0x3);
00181   mode_ext  = ((hdr>>4)&0x3);
00182   copyright = ((hdr>>3)&0x1);
00183   original  = ((hdr>>2)&0x1);
00184   emphasis  = hdr & 0x3;
00185 
00186   stereo    = (mode == MPG_MD_MONO) ? 1 : 2;
00187 
00188   if (((hdr>>10)&0x3) == 0x3) {
00189 #ifdef DEBUG_ERRORS
00190     fprintf(stderr,"Stream error - hdr: 0x%08x\n", hdr);
00191 #endif
00192   }
00193 
00194   bitrate = live_tabsel[isMPEG2][layer-1][bitrateIndex];
00195   samplingFreq = live_freqs[samplingFreqIndex];
00196   isStereo = (stereo > 1);
00197   isFreeFormat = (bitrateIndex == 0);
00198   frameSize
00199     = ComputeFrameSize(bitrate, samplingFreq, padding, isMPEG2, layer);
00200   sideInfoSize = computeSideInfoSize();
00201  }

void MP3FrameParams::setBytePointer ( unsigned char const *  restOfFrame,
unsigned  totNumBytes 
) [inline]

Definition at line 89 of file MP3Internals.hh.

References bv, and BitVector::setup().

Referenced by MP3StreamState::findNextFrame(), GetADUInfoFromMP3Frame(), and ZeroOutMP3SideInfo().

00090                                             {// called during setup
00091     bv.setup((unsigned char*)restOfFrame, 0, 8*totNumBytes);
00092   }

void MP3FrameParams::getSideInfo ( MP3SideInfo si  ) 

Definition at line 514 of file MP3Internals.cpp.

References getBits(), getSideInfo1(), getSideInfo2(), hasCRC, isMPEG2, mode, mode_ext, MPG_MD_JOINT_STEREO, samplingFreqIndex, and stereo.

Referenced by GetADUInfoFromMP3Frame(), and ZeroOutMP3SideInfo().

00514                                                 {
00515   // First skip over the CRC if present:
00516   if (hasCRC) getBits(16);
00517 
00518   int single = -1;
00519   int ms_stereo, i_stereo;
00520   int sfreq = samplingFreqIndex;
00521 
00522   if (stereo == 1) {
00523     single = 0;
00524   }
00525 
00526   ms_stereo = (mode == MPG_MD_JOINT_STEREO) && (mode_ext & 0x2);
00527   i_stereo = (mode == MPG_MD_JOINT_STEREO) && (mode_ext & 0x1);
00528 
00529   if (isMPEG2) {
00530     getSideInfo2(*this, si, stereo, ms_stereo, sfreq, single);
00531   } else {
00532     getSideInfo1(*this, si, stereo, ms_stereo, sfreq, single);
00533   }
00534 }

unsigned MP3FrameParams::getBits ( unsigned  numBits  )  [inline]

Definition at line 101 of file MP3Internals.hh.

References bv, and BitVector::getBits().

Referenced by getSideInfo(), getSideInfo1(), and getSideInfo2().

00101 { return bv.getBits(numBits); }

unsigned MP3FrameParams::get1Bit (  )  [inline]

Definition at line 102 of file MP3Internals.hh.

References bv, and BitVector::get1Bit().

Referenced by getSideInfo1(), and getSideInfo2().

00102 { return bv.get1Bit(); }

unsigned MP3FrameParams::computeSideInfoSize (  )  [private]

Definition at line 203 of file MP3Internals.cpp.

References hasCRC, isMPEG2, isStereo, and size.

Referenced by setParamsFromHeader().

00203                                              {
00204   unsigned size;
00205 
00206   if (isMPEG2) {
00207     size = isStereo ? 17 : 9;
00208   } else {
00209     size = isStereo ? 32 : 17;
00210   }
00211 
00212   if (hasCRC) {
00213     size += 2;
00214   }
00215 
00216   return size;
00217 }


Field Documentation

unsigned MP3FrameParams::hdr

Definition at line 72 of file MP3Internals.hh.

Referenced by MP3StreamState::findNextFrame(), MP3StreamState::findNextHeader(), GetADUInfoFromMP3Frame(), MPEG1or2AudioStreamParser::parse(), MP3StreamState::readFrame(), setParamsFromHeader(), TranscodeMP3ADU(), and ZeroOutMP3SideInfo().

unsigned char MP3FrameParams::frameBytes[MAX_MP3_FRAME_SIZE]

Definition at line 75 of file MP3Internals.hh.

Referenced by MP3StreamState::checkForXingHeader().

Boolean MP3FrameParams::isMPEG2

Definition at line 79 of file MP3Internals.hh.

Referenced by assignADUBackpointer(), computeSideInfoSize(), MP3StreamState::currentFramePlayTime(), getSideInfo(), PutMP3SideInfoIntoFrame(), setParamsFromHeader(), and TranscodeMP3ADU().

unsigned MP3FrameParams::layer

Definition at line 80 of file MP3Internals.hh.

Referenced by GetADUInfoFromMP3Frame(), and setParamsFromHeader().

unsigned MP3FrameParams::bitrate

Definition at line 81 of file MP3Internals.hh.

Referenced by setParamsFromHeader().

unsigned MP3FrameParams::samplingFreq

Definition at line 82 of file MP3Internals.hh.

Referenced by MP3StreamState::currentFramePlayTime(), and setParamsFromHeader().

Boolean MP3FrameParams::isStereo

Definition at line 83 of file MP3Internals.hh.

Referenced by computeSideInfoSize(), PutMP3SideInfoIntoFrame(), and setParamsFromHeader().

Boolean MP3FrameParams::isFreeFormat

Definition at line 84 of file MP3Internals.hh.

Referenced by setParamsFromHeader().

unsigned MP3FrameParams::frameSize

Definition at line 85 of file MP3Internals.hh.

Referenced by assignADUBackpointer(), MP3StreamState::checkForXingHeader(), MP3StreamState::filePlayTime(), GetADUInfoFromMP3Frame(), MPEG1or2AudioStreamParser::parse(), MP3StreamState::readFrame(), setParamsFromHeader(), and TranscodeMP3ADU().

unsigned MP3FrameParams::sideInfoSize

Definition at line 86 of file MP3Internals.hh.

Referenced by assignADUBackpointer(), MP3StreamState::checkForXingHeader(), GetADUInfoFromMP3Frame(), PutMP3SideInfoIntoFrame(), setParamsFromHeader(), TranscodeMP3ADU(), and ZeroOutMP3SideInfo().

Boolean MP3FrameParams::hasCRC

Definition at line 87 of file MP3Internals.hh.

Referenced by computeSideInfoSize(), getSideInfo(), PutMP3SideInfoIntoFrame(), and setParamsFromHeader().

unsigned MP3FrameParams::oldHdr

Definition at line 95 of file MP3Internals.hh.

Referenced by MP3StreamState::findNextFrame(), and MP3FrameParams().

unsigned MP3FrameParams::firstHdr

Definition at line 95 of file MP3Internals.hh.

Referenced by MP3StreamState::findNextFrame(), and MP3FrameParams().

BitVector MP3FrameParams::bv [private]

Definition at line 105 of file MP3Internals.hh.

Referenced by get1Bit(), getBits(), PutMP3SideInfoIntoFrame(), putSideInfo1(), putSideInfo2(), and setBytePointer().

unsigned MP3FrameParams::bitrateIndex [private]

Definition at line 108 of file MP3Internals.hh.

Referenced by setParamsFromHeader().

unsigned MP3FrameParams::samplingFreqIndex [private]

Definition at line 109 of file MP3Internals.hh.

Referenced by getSideInfo(), and setParamsFromHeader().

Boolean MP3FrameParams::isMPEG2_5 [private]

Definition at line 110 of file MP3Internals.hh.

Referenced by setParamsFromHeader().

Boolean MP3FrameParams::padding [private]

Definition at line 111 of file MP3Internals.hh.

Referenced by setParamsFromHeader().

Boolean MP3FrameParams::extension [private]

Definition at line 112 of file MP3Internals.hh.

Referenced by setParamsFromHeader().

unsigned MP3FrameParams::mode [private]

Definition at line 113 of file MP3Internals.hh.

Referenced by getSideInfo(), and setParamsFromHeader().

unsigned MP3FrameParams::mode_ext [private]

Definition at line 114 of file MP3Internals.hh.

Referenced by getSideInfo(), and setParamsFromHeader().

Boolean MP3FrameParams::copyright [private]

Definition at line 115 of file MP3Internals.hh.

Referenced by setParamsFromHeader().

Boolean MP3FrameParams::original [private]

Definition at line 116 of file MP3Internals.hh.

Referenced by setParamsFromHeader().

unsigned MP3FrameParams::emphasis [private]

Definition at line 117 of file MP3Internals.hh.

Referenced by setParamsFromHeader().

unsigned MP3FrameParams::stereo [private]

Definition at line 118 of file MP3Internals.hh.

Referenced by getSideInfo(), putSideInfo1(), putSideInfo2(), and setParamsFromHeader().


The documentation for this class was generated from the following files:
Generated on Tue Oct 7 15:39:55 2008 for live by  doxygen 1.5.2