Esempio n. 1
0
 protected function readmp3frame()
 {
     $iscbrmp3 = true;
     if ($this->startswithid3()) {
         $this->skipid3tag();
     } else {
         if ($this->containsvbrxing()) {
             $this->mp3data['Encoding'] = 'VBR';
             $iscbrmp3 = false;
         } else {
             if ($this->startswithpk()) {
                 $this->mp3data['Encoding'] = 'Unknown';
                 $iscbrmp3 = false;
             }
         }
     }
     if ($iscbrmp3) {
         $i = 0;
         $max = 5000;
         //look in 5000 bytes...
         //the largest framesize is 4609bytes(256kbps@8000Hz  mp3)
         for ($i = 0; $i < $max; $i++) {
             //looking for 1111 1111 111 (frame synchronization bits)
             if ($this->getnextbyte() == 0xff) {
                 if ($this->getnextbit() && $this->getnextbit() && $this->getnextbit()) {
                     break;
                 }
             }
         }
         if ($i == $max) {
             $iscbrmp3 = false;
         }
     }
     if ($iscbrmp3) {
         $this->mp3data['Encoding'] = 'CBR';
         $this->mp3data['MPEG version'] = $this->getnextbits(2);
         $this->mp3data['Layer Description'] = $this->getnextbits(2);
         $this->mp3data['Protection Bit'] = $this->getnextbits(1);
         $this->mp3data['Bitrate Index'] = $this->getnextbits(4);
         $this->mp3data['Sampling Freq Idx'] = $this->getnextbits(2);
         $this->mp3data['Padding Bit'] = $this->getnextbits(1);
         $this->mp3data['Private Bit'] = $this->getnextbits(1);
         $this->mp3data['Channel Mode'] = $this->getnextbits(2);
         $this->mp3data['Mode Extension'] = $this->getnextbits(2);
         $this->mp3data['Copyright'] = $this->getnextbits(1);
         $this->mp3data['Original Media'] = $this->getnextbits(1);
         $this->mp3data['Emphasis'] = $this->getnextbits(1);
         $this->mp3data['Bitrate'] = mp3file::bitratelookup($this->mp3data);
         $this->mp3data['Sampling Rate'] = mp3file::samplelookup($this->mp3data);
         $this->mp3data['Frame Size'] = mp3file::getframesize($this->mp3data);
         $this->mp3data['Length'] = mp3file::getduration($this->mp3data, $this->tell2());
         $this->mp3data['Length mm:ss'] = mp3file::seconds_to_mmss($this->mp3data['Length']);
         if ($this->mp3data['Bitrate'] == 'bad' || $this->mp3data['Bitrate'] == 'free' || $this->mp3data['Sampling Rate'] == 'unknown' || $this->mp3data['Frame Size'] == 'unknown' || $this->mp3data['Length'] == 'unknown') {
             $this->mp3data = array('Filesize' => $this->mp3data['Filesize'], 'Encoding' => 'Unknown');
         }
     } else {
         if (!isset($this->mp3data['Encoding'])) {
             $this->mp3data['Encoding'] = 'Unknown';
         }
     }
 }