$LAMEmiscStereoModeLookup[7] = 'other'; } return isset($LAMEmiscStereoModeLookup[$StereoModeID]) ? $LAMEmiscStereoModeLookup[$StereoModeID] : ''; } function LAMEmiscSourceSampleFrequencyLookup($SourceSampleFrequencyID) { static $LAMEmiscSourceSampleFrequencyLookup = array(); if (empty($LAMEmiscSourceSampleFrequencyLookup)) { $LAMEmiscSourceSampleFrequencyLookup[0] = '<= 32 kHz'; $LAMEmiscSourceSampleFrequencyLookup[1] = '44.1 kHz'; $LAMEmiscSourceSampleFrequencyLookup[2] = '48 kHz'; $LAMEmiscSourceSampleFrequencyLookup[3] = '> 48kHz'; } return isset($LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID]) ? $LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID] : ''; } function LAMEsurroundInfoLookup($SurroundInfoID) { static $LAMEsurroundInfoLookup = array(); if (empty($LAMEsurroundInfoLookup)) { $LAMEsurroundInfoLookup[0] = 'no surround info'; $LAMEsurroundInfoLookup[1] = 'DPL encoding'; $LAMEsurroundInfoLookup[2] = 'DPL2 encoding'; $LAMEsurroundInfoLookup[3] = 'Ambisonic encoding'; } return isset($LAMEsurroundInfoLookup[$SurroundInfoID]) ? $LAMEsurroundInfoLookup[$SurroundInfoID] : 'reserved'; } for ($i = 0x0; $i <= 0xff; ++$i) { $head4 = "ÿþ" . chr($i) . ""; $isvalid = MPEGaudioHeaderBytesValid($head4); echo '<div style="color: ' . ($isvalid ? 'green' : 'red') . ';">' . str_pad(strtoupper(dechex($i)), 2, '0', STR_PAD_LEFT) . ' = ' . htmlentities(chr($i)) . ' = ' . ($isvalid ? 'valid' : 'INVALID') . '</div>'; }
function ParseRIFF(&$fd, $startoffset, $maxoffset, &$ThisFileInfo) { $maxoffset = min($maxoffset, $ThisFileInfo['avdataend']); $RIFFchunk = false; fseek($fd, $startoffset, SEEK_SET); while (ftell($fd) < $maxoffset) { $chunkname = fread($fd, 4); $chunksize = EitherEndian2Int($ThisFileInfo, fread($fd, 4)); if ($chunksize % 2 != 0) { // all structures are packed on word boundaries $chunksize++; } switch ($chunkname) { case 'LIST': $listname = fread($fd, 4); switch ($listname) { case 'movi': case 'rec ': // skip over $RIFFchunk["{$listname}"]['offset'] = ftell($fd) - 4; $RIFFchunk["{$listname}"]['size'] = $chunksize; fseek($fd, $chunksize - 4, SEEK_CUR); break; default: if (!isset($RIFFchunk["{$listname}"])) { $RIFFchunk["{$listname}"] = array(); } $RIFFchunk["{$listname}"] = array_merge_recursive($RIFFchunk["{$listname}"], ParseRIFF($fd, ftell($fd), ftell($fd) + $chunksize - 4, $ThisFileInfo)); break; } break; default: $thisindex = 0; if (isset($RIFFchunk["{$chunkname}"]) && is_array($RIFFchunk["{$chunkname}"])) { $thisindex = count($RIFFchunk["{$chunkname}"]); } $RIFFchunk["{$chunkname}"][$thisindex]['offset'] = ftell($fd) - 8; $RIFFchunk["{$chunkname}"][$thisindex]['size'] = $chunksize; switch ($chunkname) { case 'data': $RIFFdataChunkContentsTest = fread($fd, 8); if (strlen($RIFFdataChunkContentsTest) > 0 && $RIFFdataChunkContentsTest[0] == chr(0xff)) { // Probably (but not guaranteed) that this is MP3 data require_once GETID3_INCLUDEPATH . 'getid3.mp3.php'; if (MPEGaudioHeaderBytesValid(substr($RIFFdataChunkContentsTest, 0, 4))) { $WhereWeWere = ftell($fd); getOnlyMPEGaudioInfo($fd, $ThisFileInfo, $RIFFchunk["{$chunkname}"][$thisindex]['offset'], false); fseek($fd, $WhereWeWere, SEEK_SET); if (isset($ThisFileInfo['mpeg']['audio'])) { $ThisFileInfo['audio']['dataformat'] = 'mp' . strlen($ThisFileInfo['mpeg']['audio']['layer']); $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate']; $ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels']; $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'] * 1000; $ThisFileInfo['bitrate'] = $ThisFileInfo['audio']['bitrate']; $ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']); } fseek($fd, $chunksize - 8, SEEK_CUR); } } else { if (substr($RIFFdataChunkContentsTest, 0, 4) == 'wvpk') { // This is WavPack data $ThisFileInfo['wavpack']['offset'] = ftell($fd) - 8; $ThisFileInfo['wavpack']['size'] = LittleEndian2Int(substr($RIFFdataChunkContentsTest, 4, 4)); $WavPackData = fread($fd, $ThisFileInfo['wavpack']['size']); RIFFparseWavPackHeader($WavPackData, $ThisFileInfo); fseek($fd, $chunksize - 8 - $ThisFileInfo['wavpack']['size'], SEEK_CUR); } else { // This is some other kind of data (quite possibly just PCM) // do nothing special, just skip it fseek($fd, $chunksize - 8, SEEK_CUR); } } break; case 'bext': case 'cart': case 'fmt ': case 'MEXT': case 'DISP': // always read data in $RIFFchunk["{$chunkname}"][$thisindex]['data'] = fread($fd, $chunksize); break; default: // read data in if smaller than 2kB if ($chunksize < 2048) { $RIFFchunk["{$chunkname}"][$thisindex]['data'] = fread($fd, $chunksize); } else { fseek($fd, $chunksize, SEEK_CUR); } break; } break; } } return $RIFFchunk; }