public function Analyze()
 {
     $getid3 = $this->getid3;
     $getid3->info['riff']['raw'] = array();
     $info_riff =& $getid3->info['riff'];
     $info_riff_raw =& $info_riff['raw'];
     $info_audio =& $getid3->info['audio'];
     $info_video =& $getid3->info['video'];
     $info_avdataoffset =& $getid3->info['avdataoffset'];
     $info_avdataend =& $getid3->info['avdataend'];
     $info_audio_dataformat =& $info_audio['dataformat'];
     $info_riff_audio =& $info_riff['audio'];
     $info_riff_video =& $info_riff['video'];
     $original['avdataend'] = $info_avdataend;
     $this->fseek($info_avdataoffset, SEEK_SET);
     $riff_header = $this->fread(12);
     $riff_sub_type = substr($riff_header, 8, 4);
     switch (substr($riff_header, 0, 4)) {
         case 'FORM':
             $getid3->info['fileformat'] = 'aiff';
             $this->endian_function = 'BigEndian2Int';
             $riff_header_size = getid3_lib::BigEndian2Int(substr($riff_header, 4, 4));
             $info_riff[$riff_sub_type] = $this->ParseRIFF($info_avdataoffset + 12, $info_avdataoffset + $riff_header_size);
             $info_riff['header_size'] = $riff_header_size;
             break;
         case 'RIFF':
         case 'SDSS':
             // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
         // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
         case 'RMP3':
             // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s
             if ($riff_sub_type == 'RMP3') {
                 $riff_sub_type = 'WAVE';
             }
             $getid3->info['fileformat'] = 'riff';
             $this->endian_function = 'LittleEndian2Int';
             $riff_header_size = getid3_lib::LittleEndian2Int(substr($riff_header, 4, 4));
             $info_riff[$riff_sub_type] = $this->ParseRIFF($info_avdataoffset + 12, $info_avdataoffset + $riff_header_size);
             $info_riff['header_size'] = $riff_header_size;
             if ($riff_sub_type == 'WAVE') {
                 $info_riff_wave =& $info_riff['WAVE'];
             }
             break;
         default:
             throw new getid3_exception('Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "' . $riff_sub_type . '" instead');
     }
     $endian_function = $this->endian_function;
     $stream_index = 0;
     switch ($riff_sub_type) {
         case 'WAVE':
             if (empty($info_audio['bitrate_mode'])) {
                 $info_audio['bitrate_mode'] = 'cbr';
             }
             if (empty($info_audio_dataformat)) {
                 $info_audio_dataformat = 'wav';
             }
             if (isset($info_riff_wave['data'][0]['offset'])) {
                 $info_avdataoffset = $info_riff_wave['data'][0]['offset'] + 8;
                 $info_avdataend = $info_avdataoffset + $info_riff_wave['data'][0]['size'];
             }
             if (isset($info_riff_wave['fmt '][0]['data'])) {
                 $info_riff_audio[$stream_index] = getid3_riff::RIFFparseWAVEFORMATex($info_riff_wave['fmt '][0]['data']);
                 $info_audio['wformattag'] = $info_riff_audio[$stream_index]['raw']['wFormatTag'];
                 $info_riff_raw['fmt '] = $info_riff_audio[$stream_index]['raw'];
                 unset($info_riff_audio[$stream_index]['raw']);
                 $info_audio['streams'][$stream_index] = $info_riff_audio[$stream_index];
                 $info_audio = getid3_riff::array_merge_noclobber($info_audio, $info_riff_audio[$stream_index]);
                 if (substr($info_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') {
                     $getid3->warning('Audio codec = ' . $info_audio['codec']);
                 }
                 $info_audio['bitrate'] = $info_riff_audio[$stream_index]['bitrate'];
                 $getid3->info['playtime_seconds'] = (double) (($info_avdataend - $info_avdataoffset) * 8 / $info_audio['bitrate']);
                 $info_audio['lossless'] = false;
                 if (isset($info_riff_wave['data'][0]['offset']) && isset($info_riff_raw['fmt ']['wFormatTag'])) {
                     switch ($info_riff_raw['fmt ']['wFormatTag']) {
                         case 0x1:
                             // PCM
                             $info_audio['lossless'] = true;
                             break;
                         case 0x2000:
                             // AC-3
                             $info_audio_dataformat = 'ac3';
                             break;
                         default:
                             // do nothing
                             break;
                     }
                 }
                 $info_audio['streams'][$stream_index]['wformattag'] = $info_audio['wformattag'];
                 $info_audio['streams'][$stream_index]['bitrate_mode'] = $info_audio['bitrate_mode'];
                 $info_audio['streams'][$stream_index]['lossless'] = $info_audio['lossless'];
                 $info_audio['streams'][$stream_index]['dataformat'] = $info_audio_dataformat;
             }
             if (isset($info_riff_wave['rgad'][0]['data'])) {
                 // shortcuts
                 $rgadData =& $info_riff_wave['rgad'][0]['data'];
                 $info_riff_raw['rgad'] = array('track' => array(), 'album' => array());
                 $info_riff_raw_rgad =& $info_riff_raw['rgad'];
                 $info_riff_raw_rgad_track =& $info_riff_raw_rgad['track'];
                 $info_riff_raw_rgad_album =& $info_riff_raw_rgad['album'];
                 $info_riff_raw_rgad['fPeakAmplitude'] = getid3_riff::BigEndian2Float(strrev(substr($rgadData, 0, 4)));
                 // LittleEndian2Float()
                 $info_riff_raw_rgad['nRadioRgAdjust'] = getid3_lib::$endian_function(substr($rgadData, 4, 2));
                 $info_riff_raw_rgad['nAudiophileRgAdjust'] = getid3_lib::$endian_function(substr($rgadData, 6, 2));
                 $n_track_rg_adjust_bit_string = str_pad(decbin($info_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT);
                 $n_album_rg_adjust_bit_string = str_pad(decbin($info_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT);
                 $info_riff_raw_rgad_track['name'] = bindec(substr($n_track_rg_adjust_bit_string, 0, 3));
                 $info_riff_raw_rgad_track['originator'] = bindec(substr($n_track_rg_adjust_bit_string, 3, 3));
                 $info_riff_raw_rgad_track['signbit'] = bindec($n_track_rg_adjust_bit_string[6]);
                 $info_riff_raw_rgad_track['adjustment'] = bindec(substr($n_track_rg_adjust_bit_string, 7, 9));
                 $info_riff_raw_rgad_album['name'] = bindec(substr($n_album_rg_adjust_bit_string, 0, 3));
                 $info_riff_raw_rgad_album['originator'] = bindec(substr($n_album_rg_adjust_bit_string, 3, 3));
                 $info_riff_raw_rgad_album['signbit'] = bindec($n_album_rg_adjust_bit_string[6]);
                 $info_riff_raw_rgad_album['adjustment'] = bindec(substr($n_album_rg_adjust_bit_string, 7, 9));
                 $info_riff['rgad']['peakamplitude'] = $info_riff_raw_rgad['fPeakAmplitude'];
                 if ($info_riff_raw_rgad_track['name'] != 0 && $info_riff_raw_rgad_track['originator'] != 0) {
                     $info_riff['rgad']['track']['name'] = getid3_lib_replaygain::NameLookup($info_riff_raw_rgad_track['name']);
                     $info_riff['rgad']['track']['originator'] = getid3_lib_replaygain::OriginatorLookup($info_riff_raw_rgad_track['originator']);
                     $info_riff['rgad']['track']['adjustment'] = getid3_lib_replaygain::AdjustmentLookup($info_riff_raw_rgad_track['adjustment'], $info_riff_raw_rgad_track['signbit']);
                 }
                 if ($info_riff_raw_rgad_album['name'] != 0 && $info_riff_raw_rgad_album['originator'] != 0) {
                     $info_riff['rgad']['album']['name'] = getid3_lib_replaygain::NameLookup($info_riff_raw_rgad_album['name']);
                     $info_riff['rgad']['album']['originator'] = getid3_lib_replaygain::OriginatorLookup($info_riff_raw_rgad_album['originator']);
                     $info_riff['rgad']['album']['adjustment'] = getid3_lib_replaygain::AdjustmentLookup($info_riff_raw_rgad_album['adjustment'], $info_riff_raw_rgad_album['signbit']);
                 }
             }
             if (isset($info_riff_wave['fact'][0]['data'])) {
                 $info_riff_raw['fact']['NumberOfSamples'] = getid3_lib::$endian_function(substr($info_riff_wave['fact'][0]['data'], 0, 4));
                 // This should be a good way of calculating exact playtime, but some sample files have had incorrect number of samples, so cannot use this method
                 // if (!empty($info_riff_raw['fmt ']['nSamplesPerSec'])) {
                 //     $getid3->info['playtime_seconds'] = (float)$info_riff_raw['fact']['NumberOfSamples'] / $info_riff_raw['fmt ']['nSamplesPerSec'];
                 // }
             }
             if (!empty($info_riff_raw['fmt ']['nAvgBytesPerSec'])) {
                 $info_audio['bitrate'] = (int) $info_riff_raw['fmt ']['nAvgBytesPerSec'] * 8;
             }
             if (isset($info_riff_wave['bext'][0]['data'])) {
                 $info_riff_wave_bext_0 =& $info_riff_wave['bext'][0];
                 getid3_lib::ReadSequence('LittleEndian2Int', $info_riff_wave_bext_0, $info_riff_wave_bext_0['data'], 0, array('title' => -256, 'author' => -32, 'reference' => -32, 'origin_date' => -10, 'origin_time' => -8, 'time_reference' => 8, 'bwf_version' => 1, 'reserved' => 254));
                 foreach (array('title', 'author', 'reference') as $key) {
                     $info_riff_wave_bext_0[$key] = trim($info_riff_wave_bext_0[$key]);
                 }
                 $info_riff_wave_bext_0['coding_history'] = explode("\r\n", trim(substr($info_riff_wave_bext_0['data'], 601)));
                 $info_riff_wave_bext_0['origin_date_unix'] = gmmktime(substr($info_riff_wave_bext_0['origin_time'], 0, 2), substr($info_riff_wave_bext_0['origin_time'], 3, 2), substr($info_riff_wave_bext_0['origin_time'], 6, 2), substr($info_riff_wave_bext_0['origin_date'], 5, 2), substr($info_riff_wave_bext_0['origin_date'], 8, 2), substr($info_riff_wave_bext_0['origin_date'], 0, 4));
                 $info_riff['comments']['author'][] = $info_riff_wave_bext_0['author'];
                 $info_riff['comments']['title'][] = $info_riff_wave_bext_0['title'];
             }
             if (isset($info_riff_wave['MEXT'][0]['data'])) {
                 $info_riff_wave_mext_0 =& $info_riff_wave['MEXT'][0];
                 $info_riff_wave_mext_0['raw']['sound_information'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 0, 2));
                 $info_riff_wave_mext_0['flags']['homogenous'] = (bool) ($info_riff_wave_mext_0['raw']['sound_information'] & 0x1);
                 if ($info_riff_wave_mext_0['flags']['homogenous']) {
                     $info_riff_wave_mext_0['flags']['padding'] = $info_riff_wave_mext_0['raw']['sound_information'] & 0x2 ? false : true;
                     $info_riff_wave_mext_0['flags']['22_or_44'] = (bool) ($info_riff_wave_mext_0['raw']['sound_information'] & 0x4);
                     $info_riff_wave_mext_0['flags']['free_format'] = (bool) ($info_riff_wave_mext_0['raw']['sound_information'] & 0x8);
                     $info_riff_wave_mext_0['nominal_frame_size'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 2, 2));
                 }
                 $info_riff_wave_mext_0['anciliary_data_length'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 6, 2));
                 $info_riff_wave_mext_0['raw']['anciliary_data_def'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 8, 2));
                 $info_riff_wave_mext_0['flags']['anciliary_data_left'] = (bool) ($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x1);
                 $info_riff_wave_mext_0['flags']['anciliary_data_free'] = (bool) ($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x2);
                 $info_riff_wave_mext_0['flags']['anciliary_data_right'] = (bool) ($info_riff_wave_mext_0['raw']['anciliary_data_def'] & 0x4);
             }
             if (isset($info_riff_wave['cart'][0]['data'])) {
                 $info_riff_wave_cart_0 =& $info_riff_wave['cart'][0];
                 getid3_lib::ReadSequence('LittleEndian2Int', $info_riff_wave_cart_0, $info_riff_wave_cart_0['data'], 0, array('version' => -4, 'title' => -64, 'artist' => -64, 'cut_id' => -64, 'client_id' => -64, 'category' => -64, 'classification' => -64, 'out_cue' => -64, 'start_date' => -10, 'start_time' => -8, 'end_date' => -10, 'end_time' => -8, 'producer_app_id' => -64, 'producer_app_version' => -64, 'user_defined_text' => -64));
                 foreach (array('artist', 'cut_id', 'client_id', 'category', 'classification', 'out_cue', 'start_date', 'start_time', 'end_date', 'end_time', 'producer_app_id', 'producer_app_version', 'user_defined_text') as $key) {
                     $info_riff_wave_cart_0[$key] = trim($info_riff_wave_cart_0[$key]);
                 }
                 $info_riff_wave_cart_0['zero_db_reference'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_cart_0['data'], 680, 4), true);
                 for ($i = 0; $i < 8; $i++) {
                     $info_riff_wave_cart_0['post_time'][$i]['usage_fourcc'] = substr($info_riff_wave_cart_0['data'], 684 + $i * 8, 4);
                     $info_riff_wave_cart_0['post_time'][$i]['timer_value'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_cart_0['data'], 684 + $i * 8 + 4, 4));
                 }
                 $info_riff_wave_cart_0['url'] = trim(substr($info_riff_wave_cart_0['data'], 748, 1024));
                 $info_riff_wave_cart_0['tag_text'] = explode("\r\n", trim(substr($info_riff_wave_cart_0['data'], 1772)));
                 $info_riff['comments']['artist'][] = $info_riff_wave_cart_0['artist'];
                 $info_riff['comments']['title'][] = $info_riff_wave_cart_0['title'];
             }
             if (!isset($info_audio['bitrate']) && isset($info_riff_audio[$stream_index]['bitrate'])) {
                 $info_audio['bitrate'] = $info_riff_audio[$stream_index]['bitrate'];
                 $getid3->info['playtime_seconds'] = (double) (($info_avdataend - $info_avdataoffset) * 8 / $info_audio['bitrate']);
             }
             if (@$getid3->info['wavpack']) {
                 if (!$this->data_string_flag) {
                     $info_audio_dataformat = 'wavpack';
                     $info_audio['bitrate_mode'] = 'vbr';
                     $info_audio['encoder'] = 'WavPack v' . $getid3->info['wavpack']['version'];
                     // Reset to the way it was - RIFF parsing will have messed this up
                     $info_avdataend = $original['avdataend'];
                     $info_audio['bitrate'] = ($info_avdataend - $info_avdataoffset) * 8 / $getid3->info['playtime_seconds'];
                     $this->fseek($info_avdataoffset - 44, SEEK_SET);
                     $riff_data = $this->fread(44);
                     $orignal_riff_header_size = getid3_lib::LittleEndian2Int(substr($riff_data, 4, 4)) + 8;
                     $orignal_riff_data_size = getid3_lib::LittleEndian2Int(substr($riff_data, 40, 4)) + 44;
                     if ($orignal_riff_header_size > $orignal_riff_data_size) {
                         $info_avdataend -= $orignal_riff_header_size - $orignal_riff_data_size;
                         $this->fseek($info_avdataend, SEEK_SET);
                         $riff_data .= $this->fread($orignal_riff_header_size - $orignal_riff_data_size);
                     }
                     // move the data chunk after all other chunks (if any)
                     // so that the RIFF parser doesn't see EOF when trying
                     // to skip over the data chunk
                     $riff_data = substr($riff_data, 0, 36) . substr($riff_data, 44) . substr($riff_data, 36, 8);
                     // Save audio info key
                     $saved_info_audio = $info_audio;
                     // Analyze riff_data
                     $this->AnalyzeString($riff_data);
                     // Restore info key
                     $info_audio = $saved_info_audio;
                 }
             }
             if (isset($info_riff_raw['fmt ']['wFormatTag'])) {
                 switch ($info_riff_raw['fmt ']['wFormatTag']) {
                     case 0x8ae:
                         // ClearJump LiteWave
                         $info_audio['bitrate_mode'] = 'vbr';
                         $info_audio_dataformat = 'litewave';
                         //typedef struct tagSLwFormat {
                         //  WORD    m_wCompFormat;     // low byte defines compression method, high byte is compression flags
                         //  DWORD   m_dwScale;         // scale factor for lossy compression
                         //  DWORD   m_dwBlockSize;     // number of samples in encoded blocks
                         //  WORD    m_wQuality;        // alias for the scale factor
                         //  WORD    m_wMarkDistance;   // distance between marks in bytes
                         //  WORD    m_wReserved;
                         //
                         //  //following paramters are ignored if CF_FILESRC is not set
                         //  DWORD   m_dwOrgSize;       // original file size in bytes
                         //  WORD    m_bFactExists;     // indicates if 'fact' chunk exists in the original file
                         //  DWORD   m_dwRiffChunkSize; // riff chunk size in the original file
                         //
                         //  PCMWAVEFORMAT m_OrgWf;     // original wave format
                         // }SLwFormat, *PSLwFormat;
                         $info_riff['litewave']['raw'] = array();
                         $info_riff_litewave =& $info_riff['litewave'];
                         $info_riff_litewave_raw =& $info_riff_litewave['raw'];
                         getid3_lib::ReadSequence('LittleEndian2Int', $info_riff_litewave_raw, $info_riff_wave['fmt '][0]['data'], 18, array('compression_method' => 1, 'compression_flags' => 1, 'm_dwScale' => 4, 'm_dwBlockSize' => 4, 'm_wQuality' => 2, 'm_wMarkDistance' => 2, 'm_wReserved' => 2, 'm_dwOrgSize' => 4, 'm_bFactExists' => 2, 'm_dwRiffChunkSize' => 4));
                         //$info_riff_litewave['quality_factor'] = intval(round((2000 - $info_riff_litewave_raw['m_dwScale']) / 20));
                         $info_riff_litewave['quality_factor'] = $info_riff_litewave_raw['m_wQuality'];
                         $info_riff_litewave['flags']['raw_source'] = $info_riff_litewave_raw['compression_flags'] & 0x1 ? false : true;
                         $info_riff_litewave['flags']['vbr_blocksize'] = $info_riff_litewave_raw['compression_flags'] & 0x2 ? false : true;
                         $info_riff_litewave['flags']['seekpoints'] = (bool) ($info_riff_litewave_raw['compression_flags'] & 0x4);
                         $info_audio['lossless'] = $info_riff_litewave_raw['m_wQuality'] == 100 ? true : false;
                         $info_audio['encoder_options'] = '-q' . $info_riff_litewave['quality_factor'];
                         break;
                 }
             }
             if ($info_avdataend > $getid3->info['filesize']) {
                 switch (@$info_audio_dataformat) {
                     case 'wavpack':
                         // WavPack
                     // WavPack
                     case 'lpac':
                         // LPAC
                     // LPAC
                     case 'ofr':
                         // OptimFROG
                     // OptimFROG
                     case 'ofs':
                         // OptimFROG DualStream
                         // lossless compressed audio formats that keep original RIFF headers - skip warning
                         break;
                     case 'litewave':
                         if ($info_avdataend - $getid3->info['filesize'] == 1) {
                             // LiteWave appears to incorrectly *not* pad actual output file
                             // to nearest WORD boundary so may appear to be short by one
                             // byte, in which case - skip warning
                         } else {
                             // Short by more than one byte, throw warning
                             $getid3->warning('Probably truncated file - expecting ' . $info_riff[$riff_sub_type]['data'][0]['size'] . ' bytes of data, only found ' . ($getid3->info['filesize'] - $info_avdataoffset) . ' (short by ' . ($info_riff[$riff_sub_type]['data'][0]['size'] - ($getid3->info['filesize'] - $info_avdataoffset)) . ' bytes)');
                         }
                         break;
                     default:
                         if ($info_avdataend - $getid3->info['filesize'] == 1 && $info_riff[$riff_sub_type]['data'][0]['size'] % 2 == 0 && ($getid3->info['filesize'] - $info_avdataoffset) % 2 == 1) {
                             // output file appears to be incorrectly *not* padded to nearest WORD boundary
                             // Output less severe warning
                             $getid3->warning('File should probably be padded to nearest WORD boundary, but it is not (expecting ' . $info_riff[$riff_sub_type]['data'][0]['size'] . ' bytes of data, only found ' . ($getid3->info['filesize'] - $info_avdataoffset) . ' therefore short by ' . ($info_riff[$riff_sub_type]['data'][0]['size'] - ($getid3->info['filesize'] - $info_avdataoffset)) . ' bytes)');
                             $info_avdataend = $getid3->info['filesize'];
                             break;
                         }
                         // Short by more than one byte, throw warning
                         $getid3->warning('Probably truncated file - expecting ' . $info_riff[$riff_sub_type]['data'][0]['size'] . ' bytes of data, only found ' . ($getid3->info['filesize'] - $info_avdataoffset) . ' (short by ' . ($info_riff[$riff_sub_type]['data'][0]['size'] - ($getid3->info['filesize'] - $info_avdataoffset)) . ' bytes)');
                         $info_avdataend = $getid3->info['filesize'];
                         break;
                 }
             }
             if (!empty($getid3->info['mpeg']['audio']['LAME']['audio_bytes'])) {
                 if ($info_avdataend - $info_avdataoffset - $getid3->info['mpeg']['audio']['LAME']['audio_bytes'] == 1) {
                     $info_avdataend--;
                     $getid3->warning('Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored');
                 }
             }
             if (@$info_audio_dataformat == 'ac3') {
                 unset($info_audio['bits_per_sample']);
                 if (!empty($getid3->info['ac3']['bitrate']) && $getid3->info['ac3']['bitrate'] != $info_audio['bitrate']) {
                     $info_audio['bitrate'] = $getid3->info['ac3']['bitrate'];
                 }
             }
             break;
         case 'AVI ':
             $info_video['bitrate_mode'] = 'vbr';
             // maybe not, but probably
             $info_video['dataformat'] = 'avi';
             $getid3->info['mime_type'] = 'video/avi';
             if (isset($info_riff[$riff_sub_type]['movi']['offset'])) {
                 $info_avdataoffset = $info_riff[$riff_sub_type]['movi']['offset'] + 8;
                 $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['movi']['size'];
                 if ($info_avdataend > $getid3->info['filesize']) {
                     $getid3->warning('Probably truncated file - expecting ' . $info_riff[$riff_sub_type]['movi']['size'] . ' bytes of data, only found ' . ($getid3->info['filesize'] - $info_avdataoffset) . ' (short by ' . ($info_riff[$riff_sub_type]['movi']['size'] - ($getid3->info['filesize'] - $info_avdataoffset)) . ' bytes)');
                     $info_avdataend = $getid3->info['filesize'];
                 }
             }
             if (isset($info_riff['AVI ']['hdrl']['avih'][$stream_index]['data'])) {
                 $avihData = $info_riff['AVI ']['hdrl']['avih'][$stream_index]['data'];
                 $info_riff_raw['avih'] = array();
                 $info_riff_raw_avih =& $info_riff_raw['avih'];
                 getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_avih, $avihData, 0, array('dwMicroSecPerFrame' => 4, 'dwMaxBytesPerSec' => 4, 'dwPaddingGranularity' => 4, 'dwFlags' => 4, 'dwTotalFrames' => 4, 'dwInitialFrames' => 4, 'dwStreams' => 4, 'dwSuggestedBufferSize' => 4, 'dwWidth' => 4, 'dwHeight' => 4, 'dwScale' => 4, 'dwRate' => 4, 'dwStart' => 4, 'dwLength' => 4));
                 $info_riff_raw_avih['flags']['hasindex'] = (bool) ($info_riff_raw_avih['dwFlags'] & 0x10);
                 $info_riff_raw_avih['flags']['mustuseindex'] = (bool) ($info_riff_raw_avih['dwFlags'] & 0x20);
                 $info_riff_raw_avih['flags']['interleaved'] = (bool) ($info_riff_raw_avih['dwFlags'] & 0x100);
                 $info_riff_raw_avih['flags']['trustcktype'] = (bool) ($info_riff_raw_avih['dwFlags'] & 0x800);
                 $info_riff_raw_avih['flags']['capturedfile'] = (bool) ($info_riff_raw_avih['dwFlags'] & 0x10000);
                 $info_riff_raw_avih['flags']['copyrighted'] = (bool) ($info_riff_raw_avih['dwFlags'] & 0x20010);
                 $info_riff_video[$stream_index] = array();
                 $info_riff_video_current =& $info_riff_video[$stream_index];
                 if ($info_riff_raw_avih['dwWidth'] > 0) {
                     $info_riff_video_current['frame_width'] = $info_riff_raw_avih['dwWidth'];
                     $info_video['resolution_x'] = $info_riff_video_current['frame_width'];
                 }
                 if ($info_riff_raw_avih['dwHeight'] > 0) {
                     $info_riff_video_current['frame_height'] = $info_riff_raw_avih['dwHeight'];
                     $info_video['resolution_y'] = $info_riff_video_current['frame_height'];
                 }
                 if ($info_riff_raw_avih['dwTotalFrames'] > 0) {
                     $info_riff_video_current['total_frames'] = $info_riff_raw_avih['dwTotalFrames'];
                     $info_video['total_frames'] = $info_riff_video_current['total_frames'];
                 }
                 $info_riff_video_current['frame_rate'] = round(1000000 / $info_riff_raw_avih['dwMicroSecPerFrame'], 3);
                 $info_video['frame_rate'] = $info_riff_video_current['frame_rate'];
             }
             if (isset($info_riff['AVI ']['hdrl']['strl']['strh'][0]['data'])) {
                 if (is_array($info_riff['AVI ']['hdrl']['strl']['strh'])) {
                     for ($i = 0; $i < count($info_riff['AVI ']['hdrl']['strl']['strh']); $i++) {
                         if (isset($info_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'])) {
                             $strh_data = $info_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'];
                             $strh_fcc_type = substr($strh_data, 0, 4);
                             if (isset($info_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'])) {
                                 $strf_data = $info_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'];
                                 // shortcut
                                 $info_riff_raw_strf_strh_fcc_type_stream_index =& $info_riff_raw['strf'][$strh_fcc_type][$stream_index];
                                 switch ($strh_fcc_type) {
                                     case 'auds':
                                         $info_audio['bitrate_mode'] = 'cbr';
                                         $info_audio_dataformat = 'wav';
                                         if (isset($info_riff_audio) && is_array($info_riff_audio)) {
                                             $stream_index = count($info_riff_audio);
                                         }
                                         $info_riff_audio[$stream_index] = getid3_riff::RIFFparseWAVEFORMATex($strf_data);
                                         $info_audio['wformattag'] = $info_riff_audio[$stream_index]['raw']['wFormatTag'];
                                         // shortcut
                                         $info_audio['streams'][$stream_index] = $info_riff_audio[$stream_index];
                                         $info_audio_streams_currentstream =& $info_audio['streams'][$stream_index];
                                         if (@$info_audio_streams_currentstream['bits_per_sample'] === 0) {
                                             unset($info_audio_streams_currentstream['bits_per_sample']);
                                         }
                                         $info_audio_streams_currentstream['wformattag'] = $info_audio_streams_currentstream['raw']['wFormatTag'];
                                         unset($info_audio_streams_currentstream['raw']);
                                         // shortcut
                                         $info_riff_raw['strf'][$strh_fcc_type][$stream_index] = $info_riff_audio[$stream_index]['raw'];
                                         unset($info_riff_audio[$stream_index]['raw']);
                                         $info_audio = getid3_riff::array_merge_noclobber($info_audio, $info_riff_audio[$stream_index]);
                                         $info_audio['lossless'] = false;
                                         switch ($info_riff_raw_strf_strh_fcc_type_stream_index['wFormatTag']) {
                                             case 0x1:
                                                 // PCM
                                                 $info_audio_dataformat = 'wav';
                                                 $info_audio['lossless'] = true;
                                                 break;
                                             case 0x50:
                                                 // MPEG Layer 2 or Layer 1
                                                 $info_audio_dataformat = 'mp2';
                                                 // Assume Layer-2
                                                 break;
                                             case 0x55:
                                                 // MPEG Layer 3
                                                 $info_audio_dataformat = 'mp3';
                                                 break;
                                             case 0xff:
                                                 // AAC
                                                 $info_audio_dataformat = 'aac';
                                                 break;
                                             case 0x161:
                                                 // Windows Media v7 / v8 / v9
                                             // Windows Media v7 / v8 / v9
                                             case 0x162:
                                                 // Windows Media Professional v9
                                             // Windows Media Professional v9
                                             case 0x163:
                                                 // Windows Media Lossess v9
                                                 $info_audio_dataformat = 'wma';
                                                 break;
                                             case 0x2000:
                                                 // AC-3
                                                 $info_audio_dataformat = 'ac3';
                                                 break;
                                             case 0x2001:
                                                 // DTS
                                                 $info_audio_dataformat = 'dts';
                                                 break;
                                             default:
                                                 $info_audio_dataformat = 'wav';
                                                 break;
                                         }
                                         $info_audio_streams_currentstream['dataformat'] = $info_audio_dataformat;
                                         $info_audio_streams_currentstream['lossless'] = $info_audio['lossless'];
                                         $info_audio_streams_currentstream['bitrate_mode'] = $info_audio['bitrate_mode'];
                                         break;
                                     case 'iavs':
                                     case 'vids':
                                         // shortcut
                                         $info_riff_raw['strh'][$i] = array();
                                         $info_riff_raw_strh_current =& $info_riff_raw['strh'][$i];
                                         getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_strh_current, $strh_data, 0, array('fccType' => -4, 'fccHandler' => -4, 'dwFlags' => 4, 'wPriority' => 2, 'wLanguage' => 2, 'dwInitialFrames' => 4, 'dwScale' => 4, 'dwRate' => 4, 'dwStart' => 4, 'dwLength' => 4, 'dwSuggestedBufferSize' => 4, 'dwQuality' => 4, 'dwSampleSize' => 4, 'rcFrame' => 4));
                                         $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strh_current['fccHandler']);
                                         $info_video['fourcc'] = $info_riff_raw_strh_current['fccHandler'];
                                         if (!$info_riff_video_current['codec'] && isset($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']) && getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc'])) {
                                             $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']);
                                             $info_video['fourcc'] = $info_riff_raw_strf_strh_fcc_type_stream_index['fourcc'];
                                         }
                                         $info_video['codec'] = $info_riff_video_current['codec'];
                                         $info_video['pixel_aspect_ratio'] = (double) 1;
                                         switch ($info_riff_raw_strh_current['fccHandler']) {
                                             case 'HFYU':
                                                 // Huffman Lossless Codec
                                             // Huffman Lossless Codec
                                             case 'IRAW':
                                                 // Intel YUV Uncompressed
                                             // Intel YUV Uncompressed
                                             case 'YUY2':
                                                 // Uncompressed YUV 4:2:2
                                                 $info_video['lossless'] = true;
                                                 break;
                                             default:
                                                 $info_video['lossless'] = false;
                                                 break;
                                         }
                                         switch ($strh_fcc_type) {
                                             case 'vids':
                                                 getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_strf_strh_fcc_type_stream_index, $strf_data, 0, array('biSize' => 4, 'biWidth' => 4, 'biHeight' => 4, 'biPlanes' => 2, 'biBitCount' => 2, 'fourcc' => -4, 'biSizeImage' => 4, 'biXPelsPerMeter' => 4, 'biYPelsPerMeter' => 4, 'biClrUsed' => 4, 'biClrImportant' => 4));
                                                 $info_video['bits_per_sample'] = $info_riff_raw_strf_strh_fcc_type_stream_index['biBitCount'];
                                                 if ($info_riff_video_current['codec'] == 'DV') {
                                                     $info_riff_video_current['dv_type'] = 2;
                                                 }
                                                 break;
                                             case 'iavs':
                                                 $info_riff_video_current['dv_type'] = 1;
                                                 break;
                                         }
                                         break;
                                     default:
                                         $getid3->warning('Unhandled fccType for stream (' . $i . '): "' . $strh_fcc_type . '"');
                                         break;
                                 }
                             }
                         }
                         if (isset($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']) && getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc'])) {
                             $info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']);
                             $info_video['codec'] = $info_riff_video_current['codec'];
                             $info_video['fourcc'] = $info_riff_raw_strf_strh_fcc_type_stream_index['fourcc'];
                             switch ($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']) {
                                 case 'HFYU':
                                     // Huffman Lossless Codec
                                 // Huffman Lossless Codec
                                 case 'IRAW':
                                     // Intel YUV Uncompressed
                                 // Intel YUV Uncompressed
                                 case 'YUY2':
                                     // Uncompressed YUV 4:2:2
                                     $info_video['lossless'] = true;
                                     $info_video['bits_per_sample'] = 24;
                                     break;
                                 default:
                                     $info_video['lossless'] = false;
                                     $info_video['bits_per_sample'] = 24;
                                     break;
                             }
                         }
                     }
                 }
             }
             break;
         case 'CDDA':
             $info_audio['bitrate_mode'] = 'cbr';
             $info_audio_dataformat = 'cda';
             $info_audio['lossless'] = true;
             unset($getid3->info['mime_type']);
             $info_avdataoffset = 44;
             if (isset($info_riff['CDDA']['fmt '][0]['data'])) {
                 $info_riff_cdda_fmt_0 =& $info_riff['CDDA']['fmt '][0];
                 getid3_lib::ReadSequence($this->endian_function, $info_riff_cdda_fmt_0, $info_riff_cdda_fmt_0['data'], 0, array('unknown1' => 2, 'track_num' => 2, 'disc_id' => 4, 'start_offset_frame' => 4, 'playtime_frames' => 4, 'unknown6' => 4, 'unknown7' => 4));
                 $info_riff_cdda_fmt_0['start_offset_seconds'] = (double) $info_riff_cdda_fmt_0['start_offset_frame'] / 75;
                 $info_riff_cdda_fmt_0['playtime_seconds'] = (double) $info_riff_cdda_fmt_0['playtime_frames'] / 75;
                 $getid3->info['comments']['track'] = $info_riff_cdda_fmt_0['track_num'];
                 $getid3->info['playtime_seconds'] = $info_riff_cdda_fmt_0['playtime_seconds'];
                 // hardcoded data for CD-audio
                 $info_audio['sample_rate'] = 44100;
                 $info_audio['channels'] = 2;
                 $info_audio['bits_per_sample'] = 16;
                 $info_audio['bitrate'] = $info_audio['sample_rate'] * $info_audio['channels'] * $info_audio['bits_per_sample'];
                 $info_audio['bitrate_mode'] = 'cbr';
             }
             break;
         case 'AIFF':
         case 'AIFC':
             $info_audio['bitrate_mode'] = 'cbr';
             $info_audio_dataformat = 'aiff';
             $info_audio['lossless'] = true;
             $getid3->info['mime_type'] = 'audio/x-aiff';
             if (isset($info_riff[$riff_sub_type]['SSND'][0]['offset'])) {
                 $info_avdataoffset = $info_riff[$riff_sub_type]['SSND'][0]['offset'] + 8;
                 $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['SSND'][0]['size'];
                 if ($info_avdataend > $getid3->info['filesize']) {
                     if ($info_avdataend == $getid3->info['filesize'] + 1 && $getid3->info['filesize'] % 2 == 1) {
                         // structures rounded to 2-byte boundary, but dumb encoders
                         // forget to pad end of file to make this actually work
                     } else {
                         $getid3->warning('Probable truncated AIFF file: expecting ' . $info_riff[$riff_sub_type]['SSND'][0]['size'] . ' bytes of audio data, only ' . ($getid3->info['filesize'] - $info_avdataoffset) . ' bytes found');
                     }
                     $info_avdataend = $getid3->info['filesize'];
                 }
             }
             if (isset($info_riff[$riff_sub_type]['COMM'][0]['data'])) {
                 // shortcut
                 $info_riff_RIFFsubtype_COMM_0_data =& $info_riff[$riff_sub_type]['COMM'][0]['data'];
                 $info_riff_audio['channels'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 0, 2));
                 $info_riff_audio['total_samples'] = getid3_lib::BigEndian2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 2, 4));
                 $info_riff_audio['bits_per_sample'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 6, 2));
                 $info_riff_audio['sample_rate'] = (int) getid3_riff::BigEndian2Float(substr($info_riff_RIFFsubtype_COMM_0_data, 8, 10));
                 if ($info_riff[$riff_sub_type]['COMM'][0]['size'] > 18) {
                     $info_riff_audio['codec_fourcc'] = substr($info_riff_RIFFsubtype_COMM_0_data, 18, 4);
                     $codec_name_size = getid3_lib::BigEndian2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 22, 1));
                     $info_riff_audio['codec_name'] = substr($info_riff_RIFFsubtype_COMM_0_data, 23, $codec_name_size);
                     switch ($info_riff_audio['codec_name']) {
                         case 'NONE':
                             $info_audio['codec'] = 'Pulse Code Modulation (PCM)';
                             $info_audio['lossless'] = true;
                             break;
                         case '':
                             switch ($info_riff_audio['codec_fourcc']) {
                                 // http://developer.apple.com/qa/snd/snd07.html
                                 case 'sowt':
                                     $info_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM';
                                     $info_audio['lossless'] = true;
                                     break;
                                 case 'twos':
                                     $info_riff_audio['codec_name'] = 'Two\'s Compliment Big-Endian PCM';
                                     $info_audio['lossless'] = true;
                                     break;
                                 default:
                                     break;
                             }
                             break;
                         default:
                             $info_audio['codec'] = $info_riff_audio['codec_name'];
                             $info_audio['lossless'] = false;
                             break;
                     }
                 }
                 $info_audio['channels'] = $info_riff_audio['channels'];
                 if ($info_riff_audio['bits_per_sample'] > 0) {
                     $info_audio['bits_per_sample'] = $info_riff_audio['bits_per_sample'];
                 }
                 $info_audio['sample_rate'] = $info_riff_audio['sample_rate'];
                 $getid3->info['playtime_seconds'] = $info_riff_audio['total_samples'] / $info_audio['sample_rate'];
             }
             if (isset($info_riff[$riff_sub_type]['COMT'])) {
                 $comment_count = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], 0, 2));
                 $offset = 2;
                 for ($i = 0; $i < $comment_count; $i++) {
                     $getid3->info['comments_raw'][$i]['timestamp'] = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 4));
                     $offset += 4;
                     $getid3->info['comments_raw'][$i]['marker_id'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 2));
                     $offset += 2;
                     $comment_length = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 2));
                     $offset += 2;
                     $getid3->info['comments_raw'][$i]['comment'] = substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, $comment_length);
                     $offset += $comment_length;
                     $getid3->info['comments_raw'][$i]['timestamp_unix'] = getid3_riff::DateMac2Unix($getid3->info['comments_raw'][$i]['timestamp']);
                     $info_riff['comments']['comment'][] = $getid3->info['comments_raw'][$i]['comment'];
                 }
             }
             foreach (array('NAME' => 'title', 'author' => 'artist', '(c) ' => 'copyright', 'ANNO' => 'comment') as $key => $value) {
                 if (isset($info_riff[$riff_sub_type][$key][0]['data'])) {
                     $info_riff['comments'][$value][] = $info_riff[$riff_sub_type][$key][0]['data'];
                 }
             }
             break;
         case '8SVX':
             $info_audio['bitrate_mode'] = 'cbr';
             $info_audio_dataformat = '8svx';
             $info_audio['bits_per_sample'] = 8;
             $info_audio['channels'] = 1;
             // overridden below, if need be
             $getid3->info['mime_type'] = 'audio/x-aiff';
             if (isset($info_riff[$riff_sub_type]['BODY'][0]['offset'])) {
                 $info_avdataoffset = $info_riff[$riff_sub_type]['BODY'][0]['offset'] + 8;
                 $info_avdataend = $info_avdataoffset + $info_riff[$riff_sub_type]['BODY'][0]['size'];
                 if ($info_avdataend > $getid3->info['filesize']) {
                     $getid3->warning('Probable truncated AIFF file: expecting ' . $info_riff[$riff_sub_type]['BODY'][0]['size'] . ' bytes of audio data, only ' . ($getid3->info['filesize'] - $info_avdataoffset) . ' bytes found');
                 }
             }
             if (isset($info_riff[$riff_sub_type]['VHDR'][0]['offset'])) {
                 // shortcut
                 $info_riff_riff_sub_type_vhdr_0 =& $info_riff[$riff_sub_type]['VHDR'][0];
                 getid3_lib::ReadSequence('BigEndian2Int', $info_riff_riff_sub_type_vhdr_0, $info_riff_riff_sub_type_vhdr_0['data'], 0, array('oneShotHiSamples' => 4, 'repeatHiSamples' => 4, 'samplesPerHiCycle' => 4, 'samplesPerSec' => 2, 'ctOctave' => 1, 'sCompression' => 1, 'Volume' => -4));
                 $info_riff_riff_sub_type_vhdr_0['Volume'] = getid3_riff::FixedPoint16_16($info_riff_riff_sub_type_vhdr_0['Volume']);
                 $info_audio['sample_rate'] = $info_riff_riff_sub_type_vhdr_0['samplesPerSec'];
                 switch ($info_riff_riff_sub_type_vhdr_0['sCompression']) {
                     case 0:
                         $info_audio['codec'] = 'Pulse Code Modulation (PCM)';
                         $info_audio['lossless'] = true;
                         $actual_bits_per_sample = 8;
                         break;
                     case 1:
                         $info_audio['codec'] = 'Fibonacci-delta encoding';
                         $info_audio['lossless'] = false;
                         $actual_bits_per_sample = 4;
                         break;
                     default:
                         $getid3->warning('Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "' . sCompression . '"');
                         break;
                 }
             }
             if (isset($info_riff[$riff_sub_type]['CHAN'][0]['data'])) {
                 $ChannelsIndex = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['CHAN'][0]['data'], 0, 4));
                 switch ($ChannelsIndex) {
                     case 6:
                         // Stereo
                         $info_audio['channels'] = 2;
                         break;
                     case 2:
                         // Left channel only
                     // Left channel only
                     case 4:
                         // Right channel only
                         $info_audio['channels'] = 1;
                         break;
                     default:
                         $getid3->warning('Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "' . $ChannelsIndex . '"');
                         break;
                 }
             }
             foreach (array('NAME' => 'title', 'author' => 'artist', '(c) ' => 'copyright', 'ANNO' => 'comment') as $key => $value) {
                 if (isset($info_riff[$riff_sub_type][$key][0]['data'])) {
                     $info_riff['comments'][$value][] = $info_riff[$riff_sub_type][$key][0]['data'];
                 }
             }
             $info_audio['bitrate'] = $info_audio['sample_rate'] * $actual_bits_per_sample * $info_audio['channels'];
             if (!empty($info_audio['bitrate'])) {
                 $getid3->info['playtime_seconds'] = ($info_avdataend - $info_avdataoffset) / ($info_audio['bitrate'] / 8);
             }
             break;
         case 'CDXA':
             $getid3->info['mime_type'] = 'video/mpeg';
             if (!empty($info_riff['CDXA']['data'][0]['size'])) {
                 $GETID3_ERRORARRAY =& $getid3->info['warning'];
                 if (!$getid3->include_module_optional('audio-video.mpeg')) {
                     $getid3->warning('MPEG skipped because mpeg module is missing.');
                 } else {
                     // Clone getid3 - messing with offsets - better safe than sorry
                     $clone = clone $getid3;
                     // Analyse
                     $mpeg = new getid3_mpeg($clone);
                     $mpeg->Analyze();
                     // Import from clone and destroy
                     $getid3->info['audio'] = $clone->info['audio'];
                     $getid3->info['video'] = $clone->info['video'];
                     $getid3->info['mpeg'] = $clone->info['mpeg'];
                     $getid3->info['warning'] = $clone->info['warning'];
                     unset($clone);
                 }
             }
             break;
         default:
             throw new getid3_exception('Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "' . $riff_sub_type . '" instead');
     }
     if (@$info_riff_raw['fmt ']['wFormatTag'] == 1) {
         // http://www.mega-nerd.com/erikd/Blog/Windiots/dts.html
         $this->fseek($getid3->info['avdataoffset'], SEEK_SET);
         $bytes4 = $this->fread(4);
         // DTSWAV
         if (preg_match('/^\\xFF\\x1F\\x00\\xE8/s', $bytes4)) {
             $info_audio_dataformat = 'dts';
         } elseif (preg_match('/^\\x7F\\xFF\\x80\\x01/s', $bytes4)) {
             $info_audio_dataformat = 'dts';
         }
     }
     if (@is_array($info_riff_wave['DISP'])) {
         $info_riff['comments']['title'][] = trim(substr($info_riff_wave['DISP'][count($info_riff_wave['DISP']) - 1]['data'], 4));
     }
     if (@is_array($info_riff_wave['INFO'])) {
         getid3_riff::RIFFCommentsParse($info_riff_wave['INFO'], $info_riff['comments']);
     }
     if (isset($info_riff_wave['INFO']) && is_array($info_riff_wave['INFO'])) {
         foreach (array('IARL' => 'archivallocation', 'IART' => 'artist', 'ICDS' => 'costumedesigner', 'ICMS' => 'commissionedby', 'ICMT' => 'comment', 'ICNT' => 'country', 'ICOP' => 'copyright', 'ICRD' => 'creationdate', 'IDIM' => 'dimensions', 'IDIT' => 'digitizationdate', 'IDPI' => 'resolution', 'IDST' => 'distributor', 'IEDT' => 'editor', 'IENG' => 'engineers', 'IFRM' => 'accountofparts', 'IGNR' => 'genre', 'IKEY' => 'keywords', 'ILGT' => 'lightness', 'ILNG' => 'language', 'IMED' => 'orignalmedium', 'IMUS' => 'composer', 'INAM' => 'title', 'IPDS' => 'productiondesigner', 'IPLT' => 'palette', 'IPRD' => 'product', 'IPRO' => 'producer', 'IPRT' => 'part', 'IRTD' => 'rating', 'ISBJ' => 'subject', 'ISFT' => 'software', 'ISGN' => 'secondarygenre', 'ISHP' => 'sharpness', 'ISRC' => 'sourcesupplier', 'ISRF' => 'digitizationsource', 'ISTD' => 'productionstudio', 'ISTR' => 'starring', 'ITCH' => 'encoded_by', 'IWEB' => 'url', 'IWRI' => 'writer') as $key => $value) {
             if (isset($info_riff_wave['INFO'][$key])) {
                 foreach ($info_riff_wave['INFO'][$key] as $comment_id => $comment_data) {
                     if (trim($comment_data['data']) != '') {
                         $info_riff['comments'][$value][] = trim($comment_data['data']);
                     }
                 }
             }
         }
     }
     if (empty($info_audio['encoder']) && !empty($getid3->info['mpeg']['audio']['LAME']['short_version'])) {
         $info_audio['encoder'] = $getid3->info['mpeg']['audio']['LAME']['short_version'];
     }
     if (!isset($getid3->info['playtime_seconds'])) {
         $getid3->info['playtime_seconds'] = 0;
     }
     if (isset($info_riff_raw['avih']['dwTotalFrames']) && isset($info_riff_raw['avih']['dwMicroSecPerFrame'])) {
         $getid3->info['playtime_seconds'] = $info_riff_raw['avih']['dwTotalFrames'] * ($info_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
     }
     if ($getid3->info['playtime_seconds'] > 0) {
         if (isset($info_riff_audio) && isset($info_riff_video)) {
             if (!isset($getid3->info['bitrate'])) {
                 $getid3->info['bitrate'] = ($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds'] * 8;
             }
         } elseif (isset($info_riff_audio) && !isset($info_riff_video)) {
             if (!isset($info_audio['bitrate'])) {
                 $info_audio['bitrate'] = ($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds'] * 8;
             }
         } elseif (!isset($info_riff_audio) && isset($info_riff_video)) {
             if (!isset($info_video['bitrate'])) {
                 $info_video['bitrate'] = ($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds'] * 8;
             }
         }
     }
     if (isset($info_riff_video) && isset($info_audio['bitrate']) && $info_audio['bitrate'] > 0 && $getid3->info['playtime_seconds'] > 0) {
         $getid3->info['bitrate'] = ($info_avdataend - $info_avdataoffset) / $getid3->info['playtime_seconds'] * 8;
         $info_audio['bitrate'] = 0;
         $info_video['bitrate'] = $getid3->info['bitrate'];
         foreach ($info_riff_audio as $channelnumber => $audioinfoarray) {
             $info_video['bitrate'] -= $audioinfoarray['bitrate'];
             $info_audio['bitrate'] += $audioinfoarray['bitrate'];
         }
         if ($info_video['bitrate'] <= 0) {
             unset($info_video['bitrate']);
         }
         if ($info_audio['bitrate'] <= 0) {
             unset($info_audio['bitrate']);
         }
     }
     if (isset($getid3->info['mpeg']['audio'])) {
         $info_audio_dataformat = 'mp' . $getid3->info['mpeg']['audio']['layer'];
         $info_audio['sample_rate'] = $getid3->info['mpeg']['audio']['sample_rate'];
         $info_audio['channels'] = $getid3->info['mpeg']['audio']['channels'];
         $info_audio['bitrate'] = $getid3->info['mpeg']['audio']['bitrate'];
         $info_audio['bitrate_mode'] = strtolower($getid3->info['mpeg']['audio']['bitrate_mode']);
         if (!empty($getid3->info['mpeg']['audio']['codec'])) {
             $info_audio['codec'] = $getid3->info['mpeg']['audio']['codec'] . ' ' . $info_audio['codec'];
         }
         if (!empty($info_audio['streams'])) {
             foreach ($info_audio['streams'] as $streamnumber => $streamdata) {
                 if ($streamdata['dataformat'] == $info_audio_dataformat) {
                     $info_audio['streams'][$streamnumber]['sample_rate'] = $info_audio['sample_rate'];
                     $info_audio['streams'][$streamnumber]['channels'] = $info_audio['channels'];
                     $info_audio['streams'][$streamnumber]['bitrate'] = $info_audio['bitrate'];
                     $info_audio['streams'][$streamnumber]['bitrate_mode'] = $info_audio['bitrate_mode'];
                     $info_audio['streams'][$streamnumber]['codec'] = $info_audio['codec'];
                 }
             }
         }
         $info_audio['encoder_options'] = getid3_mp3::GuessEncoderOptions($getid3->info);
     }
     if (!empty($info_riff_raw['fmt ']['wBitsPerSample']) && $info_riff_raw['fmt ']['wBitsPerSample'] > 0) {
         switch ($info_audio_dataformat) {
             case 'ac3':
                 // ignore bits_per_sample
                 break;
             default:
                 $info_audio['bits_per_sample'] = $info_riff_raw['fmt ']['wBitsPerSample'];
                 break;
         }
     }
     if (empty($info_riff_raw)) {
         unset($info_riff['raw']);
     }
     if (empty($info_riff_audio)) {
         unset($info_riff['audio']);
     }
     if (empty($info_riff_video)) {
         unset($info_riff['video']);
     }
     if (empty($info_audio_dataformat)) {
         unset($info_audio['dataformat']);
     }
     if (empty($getid3->info['audio'])) {
         unset($getid3->info['audio']);
     }
     if (empty($info_video)) {
         unset($getid3->info['video']);
     }
     return true;
 }