1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110 |
- <?php
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
- class getid3_riff
- {
- function getid3_riff(&$fd, &$ThisFileInfo) {
-
-
- $ThisFileInfo['riff'] = array('raw'=>array());
-
- $thisfile_riff = &$ThisFileInfo['riff'];
- $thisfile_riff_raw = &$thisfile_riff['raw'];
- $thisfile_audio = &$ThisFileInfo['audio'];
- $thisfile_video = &$ThisFileInfo['video'];
- $thisfile_avdataoffset = &$ThisFileInfo['avdataoffset'];
- $thisfile_avdataend = &$ThisFileInfo['avdataend'];
- $thisfile_audio_dataformat = &$thisfile_audio['dataformat'];
- $thisfile_riff_audio = &$thisfile_riff['audio'];
- $thisfile_riff_video = &$thisfile_riff['video'];
- $Original['avdataoffset'] = $thisfile_avdataoffset;
- $Original['avdataend'] = $thisfile_avdataend;
- fseek($fd, $thisfile_avdataoffset, SEEK_SET);
- $RIFFheader = fread($fd, 12);
- $RIFFsubtype = substr($RIFFheader, 8, 4);
- switch (substr($RIFFheader, 0, 4)) {
- case 'FORM':
- $ThisFileInfo['fileformat'] = 'aiff';
- $RIFFheaderSize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($RIFFheader, 4, 4));
- $thisfile_riff[$RIFFsubtype] = getid3_riff::ParseRIFF($fd, $thisfile_avdataoffset + 12, $thisfile_avdataoffset + $RIFFheaderSize, $ThisFileInfo);
- $thisfile_riff['header_size'] = $RIFFheaderSize;
- break;
- case 'RIFF':
- case 'SDSS':
- case 'RMP3':
- if ($RIFFsubtype == 'RMP3') {
-
- $RIFFsubtype = 'WAVE';
- }
- $ThisFileInfo['fileformat'] = 'riff';
- $RIFFheaderSize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($RIFFheader, 4, 4));
- $thisfile_riff['header_size'] = $RIFFheaderSize;
- $thisfile_riff[$RIFFsubtype] = getid3_riff::ParseRIFF($fd, $thisfile_avdataoffset + 12, $thisfile_avdataoffset + $RIFFheaderSize, $ThisFileInfo);
- fseek($fd, $thisfile_avdataoffset + $RIFFheaderSize);
- $nextRIFFheader = fread($fd, 20);
- if (substr($nextRIFFheader, 8, 4) == 'RIFF') {
- $nextRIFFsize = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($nextRIFFheader, 12, 4));
- $nextRIFFtype = substr($nextRIFFheader, 16, 4).'<br>';
- $thisfile_riff[$nextRIFFtype]['offset'] = ftell($fd) - 4;
- $thisfile_riff[$nextRIFFtype]['size'] = $nextRIFFsize;
- $ThisFileInfo['avdataend'] = $thisfile_riff[$nextRIFFtype]['offset'] + $thisfile_riff[$nextRIFFtype]['size'];
- $ThisFileInfo['error'][] = 'AVI extends beyond 2GB and PHP filesystem functions cannot read that far, playtime is probably wrong';
- $ThisFileInfo['warning'][] = '[avdataend] value may be incorrect, multiple AVIX chunks may be present';
- $thisfile_riff[$nextRIFFtype] = getid3_riff::ParseRIFF($fd, $thisfile_riff[$nextRIFFtype]['offset'] + 4, $thisfile_riff[$nextRIFFtype]['offset'] + $thisfile_riff[$nextRIFFtype]['size'], $ThisFileInfo);
- }
- if ($RIFFsubtype == 'WAVE') {
- $thisfile_riff_WAVE = &$thisfile_riff['WAVE'];
- }
- break;
- default:
- $ThisFileInfo['error'][] = 'Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "'.$RIFFsubtype.'" instead';
- unset($ThisFileInfo['fileformat']);
- return false;
- break;
- }
- $streamindex = 0;
- switch ($RIFFsubtype) {
- case 'WAVE':
- if (empty($thisfile_audio['bitrate_mode'])) {
- $thisfile_audio['bitrate_mode'] = 'cbr';
- }
- if (empty($thisfile_audio_dataformat)) {
- $thisfile_audio_dataformat = 'wav';
- }
- if (isset($thisfile_riff_WAVE['data'][0]['offset'])) {
- $thisfile_avdataoffset = $thisfile_riff_WAVE['data'][0]['offset'] + 8;
- $thisfile_avdataend = $thisfile_avdataoffset + $thisfile_riff_WAVE['data'][0]['size'];
- }
- if (isset($thisfile_riff_WAVE['fmt '][0]['data'])) {
- $thisfile_riff_audio[$streamindex] = getid3_riff::RIFFparseWAVEFORMATex($thisfile_riff_WAVE['fmt '][0]['data']);
- $thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
- if (@$thisfile_riff_audio[$streamindex]['bitrate'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt RIFF file: bitrate_audio == zero';
- return false;
- }
- $thisfile_riff_raw['fmt '] = $thisfile_riff_audio[$streamindex]['raw'];
- unset($thisfile_riff_audio[$streamindex]['raw']);
- $thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex];
- $thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
- if (substr($thisfile_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') {
- $ThisFileInfo['warning'][] = 'Audio codec = '.$thisfile_audio['codec'];
- }
- $thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
- $ThisFileInfo['playtime_seconds'] = (float) ((($thisfile_avdataend - $thisfile_avdataoffset) * 8) / $thisfile_audio['bitrate']);
- $thisfile_audio['lossless'] = false;
- if (isset($thisfile_riff_WAVE['data'][0]['offset']) && isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
- switch ($thisfile_riff_raw['fmt ']['wFormatTag']) {
- case 0x0001:
- $thisfile_audio['lossless'] = true;
- break;
- case 0x2000:
- $thisfile_audio_dataformat = 'ac3';
- break;
- default:
-
- break;
- }
- }
- $thisfile_audio['streams'][$streamindex]['wformattag'] = $thisfile_audio['wformattag'];
- $thisfile_audio['streams'][$streamindex]['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
- $thisfile_audio['streams'][$streamindex]['lossless'] = $thisfile_audio['lossless'];
- $thisfile_audio['streams'][$streamindex]['dataformat'] = $thisfile_audio_dataformat;
- }
- if (isset($thisfile_riff_WAVE['rgad'][0]['data'])) {
-
- $rgadData = &$thisfile_riff_WAVE['rgad'][0]['data'];
- $thisfile_riff_raw['rgad'] = array('track'=>array(), 'album'=>array());
- $thisfile_riff_raw_rgad = &$thisfile_riff_raw['rgad'];
- $thisfile_riff_raw_rgad_track = &$thisfile_riff_raw_rgad['track'];
- $thisfile_riff_raw_rgad_album = &$thisfile_riff_raw_rgad['album'];
- $thisfile_riff_raw_rgad['fPeakAmplitude'] = getid3_lib::LittleEndian2Float(substr($rgadData, 0, 4));
- $thisfile_riff_raw_rgad['nRadioRgAdjust'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($rgadData, 4, 2));
- $thisfile_riff_raw_rgad['nAudiophileRgAdjust'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($rgadData, 6, 2));
- $nRadioRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT);
- $nAudiophileRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT);
- $thisfile_riff_raw_rgad_track['name'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 0, 3));
- $thisfile_riff_raw_rgad_track['originator'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 3, 3));
- $thisfile_riff_raw_rgad_track['signbit'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 6, 1));
- $thisfile_riff_raw_rgad_track['adjustment'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 7, 9));
- $thisfile_riff_raw_rgad_album['name'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 0, 3));
- $thisfile_riff_raw_rgad_album['originator'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 3, 3));
- $thisfile_riff_raw_rgad_album['signbit'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 6, 1));
- $thisfile_riff_raw_rgad_album['adjustment'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 7, 9));
- $thisfile_riff['rgad']['peakamplitude'] = $thisfile_riff_raw_rgad['fPeakAmplitude'];
- if (($thisfile_riff_raw_rgad_track['name'] != 0) && ($thisfile_riff_raw_rgad_track['originator'] != 0)) {
- $thisfile_riff['rgad']['track']['name'] = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_track['name']);
- $thisfile_riff['rgad']['track']['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_track['originator']);
- $thisfile_riff['rgad']['track']['adjustment'] = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_track['adjustment'], $thisfile_riff_raw_rgad_track['signbit']);
- }
- if (($thisfile_riff_raw_rgad_album['name'] != 0) && ($thisfile_riff_raw_rgad_album['originator'] != 0)) {
- $thisfile_riff['rgad']['album']['name'] = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_album['name']);
- $thisfile_riff['rgad']['album']['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_album['originator']);
- $thisfile_riff['rgad']['album']['adjustment'] = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_album['adjustment'], $thisfile_riff_raw_rgad_album['signbit']);
- }
- }
- if (isset($thisfile_riff_WAVE['fact'][0]['data'])) {
- $thisfile_riff_raw['fact']['NumberOfSamples'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_WAVE['fact'][0]['data'], 0, 4));
-
-
-
-
-
-
- }
- if (!empty($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'])) {
- $thisfile_audio['bitrate'] = getid3_lib::CastAsInt($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'] * 8);
- }
- if (isset($thisfile_riff_WAVE['bext'][0]['data'])) {
-
- $thisfile_riff_WAVE_bext_0 = &$thisfile_riff_WAVE['bext'][0];
- $thisfile_riff_WAVE_bext_0['title'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 0, 256));
- $thisfile_riff_WAVE_bext_0['author'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 256, 32));
- $thisfile_riff_WAVE_bext_0['reference'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 288, 32));
- $thisfile_riff_WAVE_bext_0['origin_date'] = substr($thisfile_riff_WAVE_bext_0['data'], 320, 10);
- $thisfile_riff_WAVE_bext_0['origin_time'] = substr($thisfile_riff_WAVE_bext_0['data'], 330, 8);
- $thisfile_riff_WAVE_bext_0['time_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 338, 8));
- $thisfile_riff_WAVE_bext_0['bwf_version'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 346, 1));
- $thisfile_riff_WAVE_bext_0['reserved'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 347, 254));
- $thisfile_riff_WAVE_bext_0['coding_history'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_bext_0['data'], 601)));
- $thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime(
- substr($thisfile_riff_WAVE_bext_0['origin_time'], 0, 2),
- substr($thisfile_riff_WAVE_bext_0['origin_time'], 3, 2),
- substr($thisfile_riff_WAVE_bext_0['origin_time'], 6, 2),
- substr($thisfile_riff_WAVE_bext_0['origin_date'], 5, 2),
- substr($thisfile_riff_WAVE_bext_0['origin_date'], 8, 2),
- substr($thisfile_riff_WAVE_bext_0['origin_date'], 0, 4));
- $thisfile_riff['comments']['author'][] = $thisfile_riff_WAVE_bext_0['author'];
- $thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_bext_0['title'];
- }
- if (isset($thisfile_riff_WAVE['MEXT'][0]['data'])) {
-
- $thisfile_riff_WAVE_MEXT_0 = &$thisfile_riff_WAVE['MEXT'][0];
- $thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 0, 2));
- $thisfile_riff_WAVE_MEXT_0['flags']['homogenous'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0001);
- if ($thisfile_riff_WAVE_MEXT_0['flags']['homogenous']) {
- $thisfile_riff_WAVE_MEXT_0['flags']['padding'] = ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0002) ? false : true;
- $thisfile_riff_WAVE_MEXT_0['flags']['22_or_44'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0004);
- $thisfile_riff_WAVE_MEXT_0['flags']['free_format'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0008);
- $thisfile_riff_WAVE_MEXT_0['nominal_frame_size'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 2, 2));
- }
- $thisfile_riff_WAVE_MEXT_0['anciliary_data_length'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 6, 2));
- $thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 8, 2));
- $thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_left'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x0001);
- $thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_free'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x0002);
- $thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_right'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x0004);
- }
- if (isset($thisfile_riff_WAVE['cart'][0]['data'])) {
-
- $thisfile_riff_WAVE_cart_0 = &$thisfile_riff_WAVE['cart'][0];
- $thisfile_riff_WAVE_cart_0['version'] = substr($thisfile_riff_WAVE_cart_0['data'], 0, 4);
- $thisfile_riff_WAVE_cart_0['title'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 4, 64));
- $thisfile_riff_WAVE_cart_0['artist'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 68, 64));
- $thisfile_riff_WAVE_cart_0['cut_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 132, 64));
- $thisfile_riff_WAVE_cart_0['client_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 196, 64));
- $thisfile_riff_WAVE_cart_0['category'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 260, 64));
- $thisfile_riff_WAVE_cart_0['classification'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 324, 64));
- $thisfile_riff_WAVE_cart_0['out_cue'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 388, 64));
- $thisfile_riff_WAVE_cart_0['start_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 452, 10));
- $thisfile_riff_WAVE_cart_0['start_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 462, 8));
- $thisfile_riff_WAVE_cart_0['end_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 470, 10));
- $thisfile_riff_WAVE_cart_0['end_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 480, 8));
- $thisfile_riff_WAVE_cart_0['producer_app_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 488, 64));
- $thisfile_riff_WAVE_cart_0['producer_app_version'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 552, 64));
- $thisfile_riff_WAVE_cart_0['user_defined_text'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 616, 64));
- $thisfile_riff_WAVE_cart_0['zero_db_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_cart_0['data'], 680, 4), true);
- for ($i = 0; $i < 8; $i++) {
- $thisfile_riff_WAVE_cart_0['post_time'][$i]['usage_fourcc'] = substr($thisfile_riff_WAVE_cart_0['data'], 684 + ($i * 8), 4);
- $thisfile_riff_WAVE_cart_0['post_time'][$i]['timer_value'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_cart_0['data'], 684 + ($i * 8) + 4, 4));
- }
- $thisfile_riff_WAVE_cart_0['url'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 748, 1024));
- $thisfile_riff_WAVE_cart_0['tag_text'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_cart_0['data'], 1772)));
- $thisfile_riff['comments']['artist'][] = $thisfile_riff_WAVE_cart_0['artist'];
- $thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_cart_0['title'];
- }
- if (!isset($thisfile_audio['bitrate']) && isset($thisfile_riff_audio[$streamindex]['bitrate'])) {
- $thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
- $ThisFileInfo['playtime_seconds'] = (float) ((($thisfile_avdataend - $thisfile_avdataoffset) * 8) / $thisfile_audio['bitrate']);
- }
- if (!empty($ThisFileInfo['wavpack'])) {
- $thisfile_audio_dataformat = 'wavpack';
- $thisfile_audio['bitrate_mode'] = 'vbr';
- $thisfile_audio['encoder'] = 'WavPack v'.$ThisFileInfo['wavpack']['version'];
-
- $thisfile_avdataend = $Original['avdataend'];
- $thisfile_audio['bitrate'] = (($thisfile_avdataend - $thisfile_avdataoffset) * 8) / $ThisFileInfo['playtime_seconds'];
- fseek($fd, $thisfile_avdataoffset - 44, SEEK_SET);
- $RIFFdata = fread($fd, 44);
- $OrignalRIFFheaderSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 4, 4)) + 8;
- $OrignalRIFFdataSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 40, 4)) + 44;
- if ($OrignalRIFFheaderSize > $OrignalRIFFdataSize) {
- $thisfile_avdataend -= ($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
- fseek($fd, $thisfile_avdataend, SEEK_SET);
- $RIFFdata .= fread($fd, $OrignalRIFFheaderSize - $OrignalRIFFdataSize);
- }
-
-
-
- $RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8);
- getid3_riff::ParseRIFFdata($RIFFdata, $ThisFileInfo);
- }
- if (isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
- switch ($thisfile_riff_raw['fmt ']['wFormatTag']) {
- case 0x08AE:
- $thisfile_audio['bitrate_mode'] = 'vbr';
- $thisfile_audio_dataformat = 'litewave';
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $thisfile_riff['litewave']['raw'] = array();
- $thisfile_riff_litewave = &$thisfile_riff['litewave'];
- $thisfile_riff_litewave_raw = &$thisfile_riff_litewave['raw'];
- $thisfile_riff_litewave_raw['compression_method'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 18, 1));
- $thisfile_riff_litewave_raw['compression_flags'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 19, 1));
- $thisfile_riff_litewave_raw['m_dwScale'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 20, 4));
- $thisfile_riff_litewave_raw['m_dwBlockSize'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 24, 4));
- $thisfile_riff_litewave_raw['m_wQuality'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 28, 2));
- $thisfile_riff_litewave_raw['m_wMarkDistance'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 30, 2));
- $thisfile_riff_litewave_raw['m_wReserved'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 32, 2));
- $thisfile_riff_litewave_raw['m_dwOrgSize'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 34, 4));
- $thisfile_riff_litewave_raw['m_bFactExists'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 38, 2));
- $thisfile_riff_litewave_raw['m_dwRiffChunkSize'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 40, 4));
-
- $thisfile_riff_litewave['quality_factor'] = $thisfile_riff_litewave_raw['m_wQuality'];
- $thisfile_riff_litewave['flags']['raw_source'] = ($thisfile_riff_litewave_raw['compression_flags'] & 0x01) ? false : true;
- $thisfile_riff_litewave['flags']['vbr_blocksize'] = ($thisfile_riff_litewave_raw['compression_flags'] & 0x02) ? false : true;
- $thisfile_riff_litewave['flags']['seekpoints'] = (bool) ($thisfile_riff_litewave_raw['compression_flags'] & 0x04);
- $thisfile_audio['lossless'] = (($thisfile_riff_litewave_raw['m_wQuality'] == 100) ? true : false);
- $thisfile_audio['encoder_options'] = '-q'.$thisfile_riff_litewave['quality_factor'];
- break;
- default:
- break;
- }
- }
- if ($thisfile_avdataend > $ThisFileInfo['filesize']) {
- switch (@$thisfile_audio_dataformat) {
- case 'wavpack':
- case 'lpac':
- case 'ofr':
- case 'ofs':
-
- break;
- case 'litewave':
- if (($thisfile_avdataend - $ThisFileInfo['filesize']) == 1) {
-
-
-
- } else {
-
- $ThisFileInfo['warning'][] = 'Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' (short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($ThisFileInfo['filesize'] - $thisfile_avdataoffset)).' bytes)';
- $thisfile_avdataend = $ThisFileInfo['filesize'];
- }
- break;
- default:
- if ((($thisfile_avdataend - $ThisFileInfo['filesize']) == 1) && (($thisfile_riff[$RIFFsubtype]['data'][0]['size'] % 2) == 0) && ((($ThisFileInfo['filesize'] - $thisfile_avdataoffset) % 2) == 1)) {
-
-
- $ThisFileInfo['warning'][] = 'File should probably be padded to nearest WORD boundary, but it is not (expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' therefore short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($ThisFileInfo['filesize'] - $thisfile_avdataoffset)).' bytes)';
- $thisfile_avdataend = $ThisFileInfo['filesize'];
- break;
- }
-
- $ThisFileInfo['warning'][] = 'Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' (short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($ThisFileInfo['filesize'] - $thisfile_avdataoffset)).' bytes)';
- $thisfile_avdataend = $ThisFileInfo['filesize'];
- break;
- }
- }
- if (!empty($ThisFileInfo['mpeg']['audio']['LAME']['audio_bytes'])) {
- if ((($thisfile_avdataend - $thisfile_avdataoffset) - $ThisFileInfo['mpeg']['audio']['LAME']['audio_bytes']) == 1) {
- $thisfile_avdataend--;
- $ThisFileInfo['warning'][] = 'Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored';
- }
- }
- if (@$thisfile_audio_dataformat == 'ac3') {
- unset($thisfile_audio['bits_per_sample']);
- if (!empty($ThisFileInfo['ac3']['bitrate']) && ($ThisFileInfo['ac3']['bitrate'] != $thisfile_audio['bitrate'])) {
- $thisfile_audio['bitrate'] = $ThisFileInfo['ac3']['bitrate'];
- }
- }
- break;
- case 'AVI ':
- $thisfile_video['bitrate_mode'] = 'vbr';
- $thisfile_video['dataformat'] = 'avi';
- $ThisFileInfo['mime_type'] = 'video/avi';
- if (isset($thisfile_riff[$RIFFsubtype]['movi']['offset'])) {
- $thisfile_avdataoffset = $thisfile_riff[$RIFFsubtype]['movi']['offset'] + 8;
- $thisfile_avdataend = $thisfile_avdataoffset + $thisfile_riff[$RIFFsubtype]['movi']['size'];
- if ($thisfile_avdataend > $ThisFileInfo['filesize']) {
- $ThisFileInfo['warning'][] = 'Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['movi']['size'].' bytes of data, only found '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' (short by '.($thisfile_riff[$RIFFsubtype]['movi']['size'] - ($ThisFileInfo['filesize'] - $thisfile_avdataoffset)).' bytes)';
- $thisfile_avdataend = $ThisFileInfo['filesize'];
- }
- }
- if (isset($thisfile_riff['AVI ']['hdrl']['strl']['indx'])) {
-
-
-
-
-
-
-
-
-
-
- foreach ($thisfile_riff['AVI ']['hdrl']['strl']['indx'] as $streamnumber => $steamdataarray) {
- $thisfile_riff_avi_hdrl_strl_indx_stream_data = &$thisfile_riff['AVI ']['hdrl']['strl']['indx'][$streamnumber]['data'];
- $thisfile_riff_raw['indx'][$streamnumber]['wLongsPerEntry'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 0, 2));
- $thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 2, 1));
- $thisfile_riff_raw['indx'][$streamnumber]['bIndexType'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 3, 1));
- $thisfile_riff_raw['indx'][$streamnumber]['nEntriesInUse'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 4, 4));
- $thisfile_riff_raw['indx'][$streamnumber]['dwChunkId'] = substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 8, 4);
- $thisfile_riff_raw['indx'][$streamnumber]['dwReserved'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 12, 4));
-
-
- unset($thisfile_riff_avi_hdrl_strl_indx_stream_data);
- }
- }
- if (isset($thisfile_riff['AVI ']['hdrl']['avih'][$streamindex]['data'])) {
- $avihData = $thisfile_riff['AVI ']['hdrl']['avih'][$streamindex]['data'];
-
- $thisfile_riff_raw['avih'] = array();
- $thisfile_riff_raw_avih = &$thisfile_riff_raw['avih'];
- $thisfile_riff_raw_avih['dwMicroSecPerFrame'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 0, 4));
- if ($thisfile_riff_raw_avih['dwMicroSecPerFrame'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupt RIFF file: avih.dwMicroSecPerFrame == zero';
- return false;
- }
- $thisfile_riff_raw_avih['dwMaxBytesPerSec'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 4, 4));
- $thisfile_riff_raw_avih['dwPaddingGranularity'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 8, 4));
- $thisfile_riff_raw_avih['dwFlags'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 12, 4));
- $thisfile_riff_raw_avih['dwTotalFrames'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 16, 4));
- $thisfile_riff_raw_avih['dwInitialFrames'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 20, 4));
- $thisfile_riff_raw_avih['dwStreams'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 24, 4));
- $thisfile_riff_raw_avih['dwSuggestedBufferSize'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 28, 4));
- $thisfile_riff_raw_avih['dwWidth'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 32, 4));
- $thisfile_riff_raw_avih['dwHeight'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 36, 4));
- $thisfile_riff_raw_avih['dwScale'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 40, 4));
- $thisfile_riff_raw_avih['dwRate'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 44, 4));
- $thisfile_riff_raw_avih['dwStart'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 48, 4));
- $thisfile_riff_raw_avih['dwLength'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($avihData, 52, 4));
- $thisfile_riff_raw_avih['flags']['hasindex'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00000010);
- $thisfile_riff_raw_avih['flags']['mustuseindex'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00000020);
- $thisfile_riff_raw_avih['flags']['interleaved'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00000100);
- $thisfile_riff_raw_avih['flags']['trustcktype'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00000800);
- $thisfile_riff_raw_avih['flags']['capturedfile'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00010000);
- $thisfile_riff_raw_avih['flags']['copyrighted'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x00020010);
-
- $thisfile_riff_video[$streamindex] = array();
- $thisfile_riff_video_current = &$thisfile_riff_video[$streamindex];
- if ($thisfile_riff_raw_avih['dwWidth'] > 0) {
- $thisfile_riff_video_current['frame_width'] = $thisfile_riff_raw_avih['dwWidth'];
- $thisfile_video['resolution_x'] = $thisfile_riff_video_current['frame_width'];
- }
- if ($thisfile_riff_raw_avih['dwHeight'] > 0) {
- $thisfile_riff_video_current['frame_height'] = $thisfile_riff_raw_avih['dwHeight'];
- $thisfile_video['resolution_y'] = $thisfile_riff_video_current['frame_height'];
- }
- if ($thisfile_riff_raw_avih['dwTotalFrames'] > 0) {
- $thisfile_riff_video_current['total_frames'] = $thisfile_riff_raw_avih['dwTotalFrames'];
- $thisfile_video['total_frames'] = $thisfile_riff_video_current['total_frames'];
- }
- $thisfile_riff_video_current['frame_rate'] = round(1000000 / $thisfile_riff_raw_avih['dwMicroSecPerFrame'], 3);
- $thisfile_video['frame_rate'] = $thisfile_riff_video_current['frame_rate'];
- }
- if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][0]['data'])) {
- if (is_array($thisfile_riff['AVI ']['hdrl']['strl']['strh'])) {
- for ($i = 0; $i < count($thisfile_riff['AVI ']['hdrl']['strl']['strh']); $i++) {
- if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'])) {
- $strhData = $thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'];
- $strhfccType = substr($strhData, 0, 4);
- if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'])) {
- $strfData = $thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'];
-
- $thisfile_riff_raw_strf_strhfccType_streamindex = &$thisfile_riff_raw['strf'][$strhfccType][$streamindex];
- switch ($strhfccType) {
- case 'auds':
- $thisfile_audio['bitrate_mode'] = 'cbr';
- $thisfile_audio_dataformat = 'wav';
- if (isset($thisfile_riff_audio) && is_array($thisfile_riff_audio)) {
- $streamindex = count($thisfile_riff_audio);
- }
- $thisfile_riff_audio[$streamindex] = getid3_riff::RIFFparseWAVEFORMATex($strfData);
- $thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
-
- $thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex];
- $thisfile_audio_streams_currentstream = &$thisfile_audio['streams'][$streamindex];
- if ($thisfile_audio_streams_currentstream['bits_per_sample'] == 0) {
- unset($thisfile_audio_streams_currentstream['bits_per_sample']);
- }
- $thisfile_audio_streams_currentstream['wformattag'] = $thisfile_audio_streams_currentstream['raw']['wFormatTag'];
- unset($thisfile_audio_streams_currentstream['raw']);
-
- $thisfile_riff_raw['strf'][$strhfccType][$streamindex] = $thisfile_riff_audio[$streamindex]['raw'];
- unset($thisfile_riff_audio[$streamindex]['raw']);
- $thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
- $thisfile_audio['lossless'] = false;
- switch ($thisfile_riff_raw_strf_strhfccType_streamindex['wFormatTag']) {
- case 0x0001:
- $thisfile_audio_dataformat = 'wav';
- $thisfile_audio['lossless'] = true;
- break;
- case 0x0050:
- $thisfile_audio_dataformat = 'mp2';
- break;
- case 0x0055:
- $thisfile_audio_dataformat = 'mp3';
- break;
- case 0x00FF:
- $thisfile_audio_dataformat = 'aac';
- break;
- case 0x0161:
- case 0x0162:
- case 0x0163:
- $thisfile_audio_dataformat = 'wma';
- break;
- case 0x2000:
- $thisfile_audio_dataformat = 'ac3';
- break;
- case 0x2001:
- $thisfile_audio_dataformat = 'dts';
- break;
- default:
- $thisfile_audio_dataformat = 'wav';
- break;
- }
- $thisfile_audio_streams_currentstream['dataformat'] = $thisfile_audio_dataformat;
- $thisfile_audio_streams_currentstream['lossless'] = $thisfile_audio['lossless'];
- $thisfile_audio_streams_currentstream['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
- break;
- case 'iavs':
- case 'vids':
-
- $thisfile_riff_raw['strh'][$i] = array();
- $thisfile_riff_raw_strh_current = &$thisfile_riff_raw['strh'][$i];
- $thisfile_riff_raw_strh_current['fccType'] = substr($strhData, 0, 4);
- $thisfile_riff_raw_strh_current['fccHandler'] = substr($strhData, 4, 4);
- $thisfile_riff_raw_strh_current['dwFlags'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 8, 4));
- $thisfile_riff_raw_strh_current['wPriority'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 12, 2));
- $thisfile_riff_raw_strh_current['wLanguage'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 14, 2));
- $thisfile_riff_raw_strh_current['dwInitialFrames'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 16, 4));
- $thisfile_riff_raw_strh_current['dwScale'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 20, 4));
- $thisfile_riff_raw_strh_current['dwRate'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 24, 4));
- $thisfile_riff_raw_strh_current['dwStart'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 28, 4));
- $thisfile_riff_raw_strh_current['dwLength'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 32, 4));
- $thisfile_riff_raw_strh_current['dwSuggestedBufferSize'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 36, 4));
- $thisfile_riff_raw_strh_current['dwQuality'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 40, 4));
- $thisfile_riff_raw_strh_current['dwSampleSize'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 44, 4));
- $thisfile_riff_raw_strh_current['rcFrame'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($strhData, 48, 4));
- $thisfile_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($thisfile_riff_raw_strh_current['fccHandler']);
- $thisfile_video['fourcc'] = $thisfile_riff_raw_strh_current['fccHandler'];
- if (!$thisfile_riff_video_current['codec'] && isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) && getid3_riff::RIFFfourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) {
- $thisfile_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']);
- $thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'];
- }
- $thisfile_video['codec'] = $thisfile_riff_video_current['codec'];
- $thisfile_video['pixel_aspect_ratio'] = (float) 1;
- switch ($thisfile_riff_raw_strh_current['fccHandler']) {
- case 'HFYU':
- case 'IRAW':
- case 'YUY2':
- $thisfile_video['lossless'] = true;
- break;
- default:
- $thisfile_video['lossless'] = false;
- break;
- }
- switch ($strhfccType) {
- case 'vids':
- $thisfile_riff_raw_strf_strhfccType_streamindex = getid3_riff::ParseBITMAPINFOHEADER(substr($strfData, 0, 40), ($ThisFileInfo['fileformat'] == 'riff'));
-
-
-
-
-
-
-
-
-
-
-
- $thisfile_video['bits_per_sample'] = $thisfile_riff_raw_strf_strhfccType_streamindex['biBitCount'];
- if ($thisfile_riff_video_current['codec'] == 'DV') {
- $thisfile_riff_video_current['dv_type'] = 2;
- }
- break;
- case 'iavs':
- $thisfile_riff_video_current['dv_type'] = 1;
- break;
- }
- break;
- default:
- $ThisFileInfo['warning'][] = 'Unhandled fccType for stream ('.$i.'): "'.$strhfccType.'"';
- break;
- }
- }
- }
- if (isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) && getid3_riff::RIFFfourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) {
- $thisfile_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']);
- $thisfile_video['codec'] = $thisfile_riff_video_current['codec'];
- $thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'];
- switch ($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) {
- case 'HFYU':
- case 'IRAW':
- case 'YUY2':
- $thisfile_video['lossless'] = true;
- $thisfile_video['bits_per_sample'] = 24;
- break;
- default:
- $thisfile_video['lossless'] = false;
- $thisfile_video['bits_per_sample'] = 24;
- break;
- }
- }
- }
- }
- }
- break;
- case 'CDDA':
- $thisfile_audio['bitrate_mode'] = 'cbr';
- $thisfile_audio_dataformat = 'cda';
- $thisfile_audio['lossless'] = true;
- unset($ThisFileInfo['mime_type']);
- $thisfile_avdataoffset = 44;
- if (isset($thisfile_riff['CDDA']['fmt '][0]['data'])) {
-
- $thisfile_riff_CDDA_fmt_0 = &$thisfile_riff['CDDA']['fmt '][0];
- $thisfile_riff_CDDA_fmt_0['unknown1'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 0, 2));
- $thisfile_riff_CDDA_fmt_0['track_num'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 2, 2));
- $thisfile_riff_CDDA_fmt_0['disc_id'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 4, 4));
- $thisfile_riff_CDDA_fmt_0['start_offset_frame'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 8, 4));
- $thisfile_riff_CDDA_fmt_0['playtime_frames'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 12, 4));
- $thisfile_riff_CDDA_fmt_0['unknown6'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 16, 4));
- $thisfile_riff_CDDA_fmt_0['unknown7'] = getid3_riff::EitherEndian2Int($ThisFileInfo, substr($thisfile_riff_CDDA_fmt_0['data'], 20, 4));
- $thisfile_riff_CDDA_fmt_0['start_offset_seconds'] = (float) $thisfile_riff_CDDA_fmt_0['start_offset_frame'] / 75;
- $thisfile_riff_CDDA_fmt_0['playtime_seconds'] = (float) $thisfile_riff_CDDA_fmt_0['playtime_frames'] / 75;
- $ThisFileInfo['comments']['track'] = $thisfile_riff_CDDA_fmt_0['track_num'];
- $ThisFileInfo['playtime_seconds'] = $thisfile_riff_CDDA_fmt_0['playtime_seconds'];
-
- $thisfile_audio['sample_rate'] = 44100;
- $thisfile_audio['channels'] = 2;
- $thisfile_audio['bits_per_sample'] = 16;
- $thisfile_audio['bitrate'] = $thisfile_audio['sample_rate'] * $thisfile_audio['channels'] * $thisfile_audio['bits_per_sample'];
- $thisfile_audio['bitrate_mode'] = 'cbr';
- }
- break;
- case 'AIFF':
- case 'AIFC':
- $thisfile_audio['bitrate_mode'] = 'cbr';
- $thisfile_audio_dataformat = 'aiff';
- $thisfile_audio['lossless'] = true;
- $ThisFileInfo['mime_type'] = 'audio/x-aiff';
- if (isset($thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'])) {
- $thisfile_avdataoffset = $thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'] + 8;
- $thisfile_avdataend = $thisfile_avdataoffset + $thisfile_riff[$RIFFsubtype]['SSND'][0]['size'];
- if ($thisfile_avdataend > $ThisFileInfo['filesize']) {
- if (($thisfile_avdataend == ($ThisFileInfo['filesize'] + 1)) && (($ThisFileInfo['filesize'] % 2) == 1)) {
-
-
- } else {
- $ThisFileInfo['warning'][] = 'Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['SSND'][0]['size'].' bytes of audio data, only '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' bytes found';
- }
- $thisfile_avdataend = $ThisFileInfo['filesize'];
- }
- }
- if (isset($thisfile_riff[$RIFFsubtype]['COMM'][0]['data'])) {
-
- $thisfile_riff_RIFFsubtype_COMM_0_data = &$thisfile_riff[$RIFFsubtype]['COMM'][0]['data'];
- $thisfile_riff_audio['channels'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 0, 2), true);
- $thisfile_riff_audio['total_samples'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 2, 4), false);
- $thisfile_riff_audio['bits_per_sample'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 6, 2), true);
- $thisfile_riff_audio['sample_rate'] = (int) getid3_lib::BigEndian2Float(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 8, 10));
- if ($thisfile_riff[$RIFFsubtype]['COMM'][0]['size'] > 18) {
- $thisfile_riff_audio['codec_fourcc'] = substr($thisfile_riff_RIFFsubtype_COMM_0_data, 18, 4);
- $CodecNameSize = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 22, 1), false);
- $thisfile_riff_audio['codec_name'] = substr($thisfile_riff_RIFFsubtype_COMM_0_data, 23, $CodecNameSize);
- switch ($thisfile_riff_audio['codec_name']) {
- case 'NONE':
- $thisfile_audio['codec'] = 'Pulse Code Modulation (PCM)';
- $thisfile_audio['lossless'] = true;
- break;
- case '':
- switch ($thisfile_riff_audio['codec_fourcc']) {
-
- case 'sowt':
- $thisfile_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM';
- $thisfile_audio['lossless'] = true;
- break;
- case 'twos':
- $thisfile_riff_audio['codec_name'] = 'Two\'s Compliment Big-Endian PCM';
- $thisfile_audio['lossless'] = true;
- break;
- default:
- break;
- }
- break;
- default:
- $thisfile_audio['codec'] = $thisfile_riff_audio['codec_name'];
- $thisfile_audio['lossless'] = false;
- break;
- }
- }
- $thisfile_audio['channels'] = $thisfile_riff_audio['channels'];
- if ($thisfile_riff_audio['bits_per_sample'] > 0) {
- $thisfile_audio['bits_per_sample'] = $thisfile_riff_audio['bits_per_sample'];
- }
- $thisfile_audio['sample_rate'] = $thisfile_riff_audio['sample_rate'];
- if ($thisfile_audio['sample_rate'] == 0) {
- $ThisFileInfo['error'][] = 'Corrupted AIFF file: sample_rate == zero';
- return false;
- }
- $ThisFileInfo['playtime_seconds'] = $thisfile_riff_audio['total_samples'] / $thisfile_audio['sample_rate'];
- }
- if (isset($thisfile_riff[$RIFFsubtype]['COMT'])) {
- $offset = 0;
- $CommentCount = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);
- $offset += 2;
- for ($i = 0; $i < $CommentCount; $i++) {
- $ThisFileInfo['comments_raw'][$i]['timestamp'] = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 4), false);
- $offset += 4;
- $ThisFileInfo['comments_raw'][$i]['marker_id'] = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), true);
- $offset += 2;
- $CommentLength = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);
- $offset += 2;
- $ThisFileInfo['comments_raw'][$i]['comment'] = substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, $CommentLength);
- $offset += $CommentLength;
- $ThisFileInfo['comments_raw'][$i]['timestamp_unix'] = getid3_lib::DateMac2Unix($ThisFileInfo['comments_raw'][$i]['timestamp']);
- $thisfile_riff['comments']['comment'][] = $ThisFileInfo['comments_raw'][$i]['comment'];
- }
- }
- $CommentsChunkNames = array('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment');
- foreach ($CommentsChunkNames as $key => $value) {
- if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) {
- $thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data'];
- }
- }
- break;
- case '8SVX':
- $thisfile_audio['bitrate_mode'] = 'cbr';
- $thisfile_audio_dataformat = '8svx';
- $thisfile_audio['bits_per_sample'] = 8;
- $thisfile_audio['channels'] = 1;
- $ThisFileInfo['mime_type'] = 'audio/x-aiff';
- if (isset($thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'])) {
- $thisfile_avdataoffset = $thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'] + 8;
- $thisfile_avdataend = $thisfile_avdataoffset + $thisfile_riff[$RIFFsubtype]['BODY'][0]['size'];
- if ($thisfile_avdataend > $ThisFileInfo['filesize']) {
- $ThisFileInfo['warning'][] = 'Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['BODY'][0]['size'].' bytes of audio data, only '.($ThisFileInfo['filesize'] - $thisfile_avdataoffset).' bytes found';
- }
- }
- if (isset($thisfile_riff[$RIFFsubtype]['VHDR'][0]['offset'])) {
-
- $thisfile_riff_RIFFsubtype_VHDR_0 = &$thisfile_riff[$RIFFsubtype]['VHDR'][0];
- $thisfile_riff_RIFFsubtype_VHDR_0['oneShotHiSamples'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 0, 4));
- $thisfile_riff_RIFFsubtype_VHDR_0['repeatHiSamples'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 4, 4));
- $thisfile_riff_RIFFsubtype_VHDR_0['samplesPerHiCycle'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 8, 4));
- $thisfile_riff_RIFFsubtype_VHDR_0['samplesPerSec'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 12, 2));
- $thisfile_riff_RIFFsubtype_VHDR_0['ctOctave'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 14, 1));
- $thisfile_riff_RIFFsubtype_VHDR_0['sCompression'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 15, 1));
- $thisfile_riff_RIFFsubtype_VHDR_0['Volume'] = getid3_lib::FixedPoint16_16(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 16, 4));
- $thisfile_audio['sample_rate'] = $thisfile_riff_RIFFsubtype_VHDR_0['samplesPerSec'];
- switch ($thisfile_riff_RIFFsubtype_VHDR_0['sCompression']) {
- case 0:
- $thisfile_audio['codec'] = 'Pulse Code Modulation (PCM)';
- $thisfile_audio['lossless'] = true;
- $ActualBitsPerSample = 8;
- break;
- case 1:
- $thisfile_audio['codec'] = 'Fibonacci-delta encoding';
- $thisfile_audio['lossless'] = false;
- $ActualBitsPerSample = 4;
- break;
- default:
- $ThisFileInfo['warning'][] = 'Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "'.sCompression.'"';
- break;
- }
- }
- if (isset($thisfile_riff[$RIFFsubtype]['CHAN'][0]['data'])) {
- $ChannelsIndex = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['CHAN'][0]['data'], 0, 4));
- switch ($ChannelsIndex) {
- case 6:
- $thisfile_audio['channels'] = 2;
- break;
- case 2:
- case 4:
- $thisfile_audio['channels'] = 1;
- break;
- default:
- $ThisFileInfo['warning'][] = 'Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "'.$ChannelsIndex.'"';
- break;
- }
- }
- $CommentsChunkNames = array('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment');
- foreach ($CommentsChunkNames as $key => $value) {
- if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) {
- $thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data'];
- }
- }
- $thisfile_audio['bitrate'] = $thisfile_audio['sample_rate'] * $ActualBitsPerSample * $thisfile_audio['channels'];
- if (!empty($thisfile_audio['bitrate'])) {
- $ThisFileInfo['playtime_seconds'] = ($thisfile_avdataend - $thisfile_avdataoffset) / ($thisfile_audio['bitrate'] / 8);
- }
- break;
- case 'CDXA':
- $ThisFileInfo['mime_type'] = 'video/mpeg';
- if (!empty($thisfile_riff['CDXA']['data'][0]['size'])) {
- $GETID3_ERRORARRAY = &$ThisFileInfo['warning'];
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.mpeg.php', __FILE__, false)) {
- $dummy = $ThisFileInfo;
- $dummy['error'] = array();
- $mpeg_scanner = new getid3_mpeg($fd, $dummy);
- if (empty($dummy['error'])) {
- $ThisFileInfo['audio'] = $dummy['audio'];
- $ThisFileInfo['video'] = $dummy['video'];
- $ThisFileInfo['mpeg'] = $dummy['mpeg'];
- $ThisFileInfo['warning'] = $dummy['warning'];
- }
- unset($mpeg_scanner);
- }
- }
- break;
- default:
- $ThisFileInfo['error'][] = 'Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "'.$RIFFsubtype.'" instead';
- unset($ThisFileInfo['fileformat']);
- break;
- }
- if (@$thisfile_riff_raw['fmt ']['wFormatTag'] == 1) {
-
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $FirstFourBytes = fread($fd, 4);
- if (preg_match('/^\xFF\x1F\x00\xE8/s', $FirstFourBytes)) {
-
- $thisfile_audio_dataformat = 'dts';
- } elseif (preg_match('/^\x7F\xFF\x80\x01/s', $FirstFourBytes)) {
-
- $thisfile_audio_dataformat = 'dts';
- }
- }
- if (isset($thisfile_riff_WAVE['DISP']) && is_array($thisfile_riff_WAVE['DISP'])) {
- $thisfile_riff['comments']['title'][] = trim(substr($thisfile_riff_WAVE['DISP'][count($thisfile_riff_WAVE['DISP']) - 1]['data'], 4));
- }
- if (isset($thisfile_riff_WAVE['INFO']) && is_array($thisfile_riff_WAVE['INFO'])) {
- $this->RIFFcommentsParse($thisfile_riff_WAVE['INFO'], $thisfile_riff['comments']);
- }
- if (empty($thisfile_audio['encoder']) && !empty($ThisFileInfo['mpeg']['audio']['LAME']['short_version'])) {
- $thisfile_audio['encoder'] = $ThisFileInfo['mpeg']['audio']['LAME']['short_version'];
- }
- if (!isset($ThisFileInfo['playtime_seconds'])) {
- $ThisFileInfo['playtime_seconds'] = 0;
- }
- if (isset($thisfile_riff_raw['avih']['dwTotalFrames']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) {
- $ThisFileInfo['playtime_seconds'] = $thisfile_riff_raw['avih']['dwTotalFrames'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
- }
- if ($ThisFileInfo['playtime_seconds'] > 0) {
- if (isset($thisfile_riff_audio) && isset($thisfile_riff_video)) {
- if (!isset($ThisFileInfo['bitrate'])) {
- $ThisFileInfo['bitrate'] = ((($thisfile_avdataend - $thisfile_avdataoffset) / $ThisFileInfo['playtime_seconds']) * 8);
- }
- } elseif (isset($thisfile_riff_audio) && !isset($thisfile_riff_video)) {
- if (!isset($thisfile_audio['bitrate'])) {
- $thisfile_audio['bitrate'] = ((($thisfile_avdataend - $thisfile_avdataoffset) / $ThisFileInfo['playtime_seconds']) * 8);
- }
- } elseif (!isset($thisfile_riff_audio) && isset($thisfile_riff_video)) {
- if (!isset($thisfile_video['bitrate'])) {
- $thisfile_video['bitrate'] = ((($thisfile_avdataend - $thisfile_avdataoffset) / $ThisFileInfo['playtime_seconds']) * 8);
- }
- }
- }
- if (isset($thisfile_riff_video) && isset($thisfile_audio['bitrate']) && ($thisfile_audio['bitrate'] > 0) && ($ThisFileInfo['playtime_seconds'] > 0)) {
- $ThisFileInfo['bitrate'] = ((($thisfile_avdataend - $thisfile_avdataoffset) / $ThisFileInfo['playtime_seconds']) * 8);
- $thisfile_audio['bitrate'] = 0;
- $thisfile_video['bitrate'] = $ThisFileInfo['bitrate'];
- foreach ($thisfile_riff_audio as $channelnumber => $audioinfoarray) {
- $thisfile_video['bitrate'] -= $audioinfoarray['bitrate'];
- $thisfile_audio['bitrate'] += $audioinfoarray['bitrate'];
- }
- if ($thisfile_video['bitrate'] <= 0) {
- unset($thisfile_video['bitrate']);
- }
- if ($thisfile_audio['bitrate'] <= 0) {
- unset($thisfile_audio['bitrate']);
- }
- }
- if (isset($ThisFileInfo['mpeg']['audio'])) {
- $thisfile_audio_dataformat = 'mp'.$ThisFileInfo['mpeg']['audio']['layer'];
- $thisfile_audio['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
- $thisfile_audio['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
- $thisfile_audio['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
- $thisfile_audio['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
- if (!empty($ThisFileInfo['mpeg']['audio']['codec'])) {
- $thisfile_audio['codec'] = $ThisFileInfo['mpeg']['audio']['codec'].' '.$thisfile_audio['codec'];
- }
- if (!empty($thisfile_audio['streams'])) {
- foreach ($thisfile_audio['streams'] as $streamnumber => $streamdata) {
- if ($streamdata['dataformat'] == $thisfile_audio_dataformat) {
- $thisfile_audio['streams'][$streamnumber]['sample_rate'] = $thisfile_audio['sample_rate'];
- $thisfile_audio['streams'][$streamnumber]['channels'] = $thisfile_audio['channels'];
- $thisfile_audio['streams'][$streamnumber]['bitrate'] = $thisfile_audio['bitrate'];
- $thisfile_audio['streams'][$streamnumber]['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
- $thisfile_audio['streams'][$streamnumber]['codec'] = $thisfile_audio['codec'];
- }
- }
- }
- $thisfile_audio['encoder_options'] = getid3_mp3::GuessEncoderOptions($ThisFileInfo);
- }
- if (!empty($thisfile_riff_raw['fmt ']['wBitsPerSample']) && ($thisfile_riff_raw['fmt ']['wBitsPerSample'] > 0)) {
- switch ($thisfile_audio_dataformat) {
- case 'ac3':
-
- break;
- default:
- $thisfile_audio['bits_per_sample'] = $thisfile_riff_raw['fmt ']['wBitsPerSample'];
- break;
- }
- }
- if (empty($thisfile_riff_raw)) {
- unset($thisfile_riff['raw']);
- }
- if (empty($thisfile_riff_audio)) {
- unset($thisfile_riff['audio']);
- }
- if (empty($thisfile_riff_video)) {
- unset($thisfile_riff['video']);
- }
- return true;
- }
- function RIFFcommentsParse(&$RIFFinfoArray, &$CommentsTargetArray) {
- $RIFFinfoKeyLookup = 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'
- );
- foreach ($RIFFinfoKeyLookup as $key => $value) {
- if (isset($RIFFinfoArray[$key])) {
- foreach ($RIFFinfoArray[$key] as $commentid => $commentdata) {
- if (trim($commentdata['data']) != '') {
- @$CommentsTargetArray[$value][] = trim($commentdata['data']);
- }
- }
- }
- }
- return true;
- }
- function ParseRIFF(&$fd, $startoffset, $maxoffset, &$ThisFileInfo) {
- $maxoffset = min($maxoffset, $ThisFileInfo['avdataend']);
- $RIFFchunk = false;
- $FoundAllChunksWeNeed = false;
- if (($startoffset < 0) || ($startoffset >= pow(2, 31))) {
- $ThisFileInfo['warning'][] = 'Unable to ParseRIFF() at '.$startoffset.' because beyond 2GB limit of PHP filesystem functions';
- return false;
- }
- fseek($fd, $startoffset, SEEK_SET);
- while (ftell($fd) < $maxoffset) {
- $chunkname = fread($fd, 4);
- if (strlen($chunkname) < 4) {
- $ThisFileInfo['error'][] = 'Expecting chunk name at offset '.(ftell($fd) - 4).' but found nothing. Aborting RIFF parsing.';
- break;
- }
- $chunksize = getid3_riff::EitherEndian2Int($ThisFileInfo, fread($fd, 4));
- if ($chunksize == 0) {
- $ThisFileInfo['warning'][] = 'Chunk size at offset '.(ftell($fd) - 4).' is zero. Aborting RIFF parsing.';
- continue;
- }
- if (($chunksize % 2) != 0) {
-
- $chunksize++;
- }
- switch ($chunkname) {
- case 'LIST':
- $listname = fread($fd, 4);
- if (eregi('^(movi|rec )$', $listname)) {
- $RIFFchunk[$listname]['offset'] = ftell($fd) - 4;
- $RIFFchunk[$listname]['size'] = $chunksize;
- if ($FoundAllChunksWeNeed) {
-
- } else {
- $WhereWeWere = ftell($fd);
- $AudioChunkHeader = fread($fd, 12);
- $AudioChunkStreamNum = substr($AudioChunkHeader, 0, 2);
- $AudioChunkStreamType = substr($AudioChunkHeader, 2, 2);
- $AudioChunkSize = getid3_lib::LittleEndian2Int(substr($AudioChunkHeader, 4, 4));
- if ($AudioChunkStreamType == 'wb') {
- $FirstFourBytes = substr($AudioChunkHeader, 8, 4);
- if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', $FirstFourBytes)) {
-
- if (getid3_mp3::MPEGaudioHeaderBytesValid($FirstFourBytes)) {
- $dummy = $ThisFileInfo;
- $dummy['avdataoffset'] = ftell($fd) - 4;
- $dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
- getid3_mp3::getOnlyMPEGaudioInfo($fd, $dummy, $dummy['avdataoffset'], false);
- if (isset($dummy['mpeg']['audio'])) {
- $ThisFileInfo = $dummy;
- $ThisFileInfo['audio']['dataformat'] = 'mp'.$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'];
- $ThisFileInfo['bitrate'] = $ThisFileInfo['audio']['bitrate'];
- $ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
- }
- unset($dummy);
- }
- } elseif (preg_match('/^\x0B\x77/s', $FirstFourBytes)) {
-
- $GETID3_ERRORARRAY = &$ThisFileInfo['warning'];
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
- $dummy = $ThisFileInfo;
- $dummy['avdataoffset'] = ftell($fd) - 4;
- $dummy['avdataend'] = ftell($fd) + $AudioChunkSize;
- $dummy['error'] = array();
- $ac3_tag = new getid3_ac3($fd, $dummy);
- if (empty($dummy['error'])) {
- $ThisFileInfo['audio'] = $dummy['audio'];
- $ThisFileInfo['ac3'] = $dummy['ac3'];
- $ThisFileInfo['warning'] = $dummy['warning'];
- }
- unset($ac3_tag);
- }
- }
- }
- $FoundAllChunksWeNeed = true;
- fseek($fd, $WhereWeWere, SEEK_SET);
- }
- fseek($fd, $chunksize - 4, SEEK_CUR);
-
-
-
-
- } else {
- if (!isset($RIFFchunk[$listname])) {
- $RIFFchunk[$listname] = array();
- }
- $LISTchunkParent = $listname;
- $LISTchunkMaxOffset = ftell($fd) - 4 + $chunksize;
- if ($parsedChunk = getid3_riff::ParseRIFF($fd, ftell($fd), ftell($fd) + $chunksize - 4, $ThisFileInfo)) {
- $RIFFchunk[$listname] = array_merge_recursive($RIFFchunk[$listname], $parsedChunk);
- }
- }
- break;
- default:
- if (eregi('^[0-9]{2}(wb|pc|dc|db)$', $chunkname)) {
- $nextoffset = ftell($fd) + $chunksize;
- if (($nextoffset < 0) || ($nextoffset >= pow(2, 31))) {
- $ThisFileInfo['warning'][] = 'Unable to parse chunk at offset '.$nextoffset.' because beyond 2GB limit of PHP filesystem functions';
- break 2;
- }
- fseek($fd, $nextoffset, SEEK_SET);
- break;
- }
- $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':
- $ThisFileInfo['avdataoffset'] = ftell($fd);
- $ThisFileInfo['avdataend'] = $ThisFileInfo['avdataoffset'] + $chunksize;
- $RIFFdataChunkContentsTest = fread($fd, 36);
- if ((strlen($RIFFdataChunkContentsTest) > 0) && preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', substr($RIFFdataChunkContentsTest, 0, 4))) {
-
- if (getid3_mp3::MPEGaudioHeaderBytesValid(substr($RIFFdataChunkContentsTest, 0, 4))) {
-
- $dummy = $ThisFileInfo;
- getid3_mp3::getOnlyMPEGaudioInfo($fd, $dummy, $RIFFchunk[$chunkname][$thisindex]['offset'], false);
-
- if (empty($dummy['error'])) {
- $ThisFileInfo = $dummy;
- }
- }
- } elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 0, 2) == "\x0B\x77")) {
-
- $GETID3_ERRORARRAY = &$ThisFileInfo['warning'];
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
- $dummy = $ThisFileInfo;
- $dummy['avdataoffset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
- $dummy['avdataend'] = $dummy['avdataoffset'] + $RIFFchunk[$chunkname][$thisindex]['size'];
- $dummy['error'] = array();
- $ac3_tag = new getid3_ac3($fd, $dummy);
- if (empty($dummy['error'])) {
- $ThisFileInfo['audio'] = $dummy['audio'];
- $ThisFileInfo['ac3'] = $dummy['ac3'];
- $ThisFileInfo['warning'] = $dummy['warning'];
- }
- unset($ac3_tag);
- }
- } elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 8, 2) == "\x77\x0B")) {
-
-
-
- $GETID3_ERRORARRAY = &$ThisFileInfo['warning'];
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
-
- if ($fd_temp = tmpfile()) {
- for ($i = 0; $i < 28; $i += 2) {
-
- fwrite($fd_temp, substr($RIFFdataChunkContentsTest, 8 + $i + 1, 1));
- fwrite($fd_temp, substr($RIFFdataChunkContentsTest, 8 + $i + 0, 1));
- }
- $dummy = $ThisFileInfo;
- $dummy['avdataoffset'] = 0;
- $dummy['avdataend'] = 20;
- $dummy['error'] = array();
- $ac3_tag = new getid3_ac3($fd_temp, $dummy);
- fclose($fd_temp);
- if (empty($dummy['error'])) {
- $ThisFileInfo['audio'] = $dummy['audio'];
- $ThisFileInfo['ac3'] = $dummy['ac3'];
- $ThisFileInfo['warning'] = $dummy['warning'];
- } else {
- $ThisFileInfo['error'][] = 'Errors parsing DolbyDigital WAV: '.explode(';', $dummy['error']);
- }
- unset($ac3_tag);
- } else {
- $ThisFileInfo['error'][] = 'Could not create temporary file to analyze DolbyDigital WAV';
- }
- }
- } elseif ((strlen($RIFFdataChunkContentsTest) > 0) && (substr($RIFFdataChunkContentsTest, 0, 4) == 'wvpk')) {
-
- $ThisFileInfo['wavpack']['offset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
- $ThisFileInfo['wavpack']['size'] = getid3_lib::LittleEndian2Int(substr($RIFFdataChunkContentsTest, 4, 4));
- getid3_riff::RIFFparseWavPackHeader(substr($RIFFdataChunkContentsTest, 8, 28), $ThisFileInfo);
- } else {
-
-
- }
- $nextoffset = $RIFFchunk[$chunkname][$thisindex]['offset'] + 8 + $chunksize;
- if (($nextoffset < 0) || ($nextoffset >= pow(2, 31))) {
- $ThisFileInfo['warning'][] = 'Unable to parse chunk at offset '.$nextoffset.' because beyond 2GB limit of PHP filesystem functions';
- break 3;
- }
- fseek($fd, $RIFFchunk[$chunkname][$thisindex]['offset'] + 8 + $chunksize, SEEK_SET);
- break;
- case 'bext':
- case 'cart':
- case 'fmt ':
- case 'strh':
- case 'strf':
- case 'indx':
- case 'MEXT':
- case 'DISP':
-
- $RIFFchunk[$chunkname][$thisindex]['data'] = fread($fd, $chunksize);
- break;
- default:
- if (!ereg('^[0-9]{2}(wb|pc|dc|db)$', $chunkname) && !empty($LISTchunkParent) && (($RIFFchunk[$chunkname][$thisindex]['offset'] + $RIFFchunk[$chunkname][$thisindex]['size']) <= $LISTchunkMaxOffset)) {
- $RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['offset'] = $RIFFchunk[$chunkname][$thisindex]['offset'];
- $RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['size'] = $RIFFchunk[$chunkname][$thisindex]['size'];
- unset($RIFFchunk[$chunkname][$thisindex]['offset']);
- unset($RIFFchunk[$chunkname][$thisindex]['size']);
- if (isset($RIFFchunk[$chunkname][$thisindex]) && empty($RIFFchunk[$chunkname][$thisindex])) {
- unset($RIFFchunk[$chunkname][$thisindex]);
- }
- if (isset($RIFFchunk[$chunkname]) && empty($RIFFchunk[$chunkname])) {
- unset($RIFFchunk[$chunkname]);
- }
- $RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['data'] = fread($fd, $chunksize);
- } elseif ($chunksize < 2048) {
-
- $RIFFchunk[$chunkname][$thisindex]['data'] = fread($fd, $chunksize);
- } else {
- $nextoffset = ftell($fd) + $chunksize;
- if (($nextoffset < 0) || ($nextoffset >= pow(2, 31))) {
- $ThisFileInfo['warning'][] = 'Unable to parse chunk at offset '.$nextoffset.' because beyond 2GB limit of PHP filesystem functions';
- break 3;
- }
- fseek($fd, $nextoffset, SEEK_SET);
- }
- break;
- }
- break;
- }
- }
- return $RIFFchunk;
- }
- function ParseRIFFdata(&$RIFFdata, &$ThisFileInfo) {
- if ($RIFFdata) {
- $tempfile = tempnam('*', 'getID3');
- $fp_temp = fopen($tempfile, "wb");
- $RIFFdataLength = strlen($RIFFdata);
- $NewLengthString = getid3_lib::LittleEndian2String($RIFFdataLength, 4);
- for ($i = 0; $i < 4; $i++) {
- $RIFFdata{$i + 4} = $NewLengthString{$i};
- }
- fwrite($fp_temp, $RIFFdata);
- fclose($fp_temp);
- $fp_temp = fopen($tempfile, "rb");
- $dummy = array('filesize'=>$RIFFdataLength, 'filenamepath'=>$ThisFileInfo['filenamepath'], 'tags'=>$ThisFileInfo['tags'], 'avdataoffset'=>0, 'avdataend'=>$RIFFdataLength, 'warning'=>$ThisFileInfo['warning'], 'error'=>$ThisFileInfo['error'], 'comments'=>$ThisFileInfo['comments'], 'audio'=>(isset($ThisFileInfo['audio']) ? $ThisFileInfo['audio'] : array()), 'video'=>(isset($ThisFileInfo['video']) ? $ThisFileInfo['video'] : array()));
- $riff = new getid3_riff($fp_temp, $dummy);
- $ThisFileInfo['riff'] = $dummy['riff'];
- $ThisFileInfo['warning'] = $dummy['warning'];
- $ThisFileInfo['error'] = $dummy['error'];
- $ThisFileInfo['tags'] = $dummy['tags'];
- $ThisFileInfo['comments'] = $dummy['comments'];
- unset($riff);
- fclose($fp_temp);
- unlink($tempfile);
- return true;
- }
- return false;
- }
- function RIFFparseWAVEFORMATex($WaveFormatExData) {
-
- $WaveFormatEx['raw'] = array();
- $WaveFormatEx_raw = &$WaveFormatEx['raw'];
- $WaveFormatEx_raw['wFormatTag'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 0, 2));
- $WaveFormatEx_raw['nChannels'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 2, 2));
- $WaveFormatEx_raw['nSamplesPerSec'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 4, 4));
- $WaveFormatEx_raw['nAvgBytesPerSec'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 8, 4));
- $WaveFormatEx_raw['nBlockAlign'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 12, 2));
- $WaveFormatEx_raw['wBitsPerSample'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 14, 2));
- if (strlen($WaveFormatExData) > 16) {
- $WaveFormatEx_raw['cbSize'] = getid3_lib::LittleEndian2Int(substr($WaveFormatExData, 16, 2));
- }
- $WaveFormatEx['codec'] = getid3_riff::RIFFwFormatTagLookup($WaveFormatEx_raw['wFormatTag']);
- $WaveFormatEx['channels'] = $WaveFormatEx_raw['nChannels'];
- $WaveFormatEx['sample_rate'] = $WaveFormatEx_raw['nSamplesPerSec'];
- $WaveFormatEx['bitrate'] = $WaveFormatEx_raw['nAvgBytesPerSec'] * 8;
- $WaveFormatEx['bits_per_sample'] = $WaveFormatEx_raw['wBitsPerSample'];
- return $WaveFormatEx;
- }
- function RIFFparseWavPackHeader($WavPackChunkData, &$ThisFileInfo) {
-
-
-
-
-
-
-
-
-
-
- $ThisFileInfo['wavpack'] = array();
- $thisfile_wavpack = &$ThisFileInfo['wavpack'];
- $thisfile_wavpack['version'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 0, 2));
- if ($thisfile_wavpack['version'] >= 2) {
- $thisfile_wavpack['bits'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 2, 2));
- }
- if ($thisfile_wavpack['version'] >= 3) {
- $thisfile_wavpack['flags_raw'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 4, 2));
- $thisfile_wavpack['shift'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 6, 2));
- $thisfile_wavpack['total_samples'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 8, 4));
- $thisfile_wavpack['crc1'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 12, 4));
- $thisfile_wavpack['crc2'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 16, 4));
- $thisfile_wavpack['extension'] = substr($WavPackChunkData, 20, 4);
- $thisfile_wavpack['extra_bc'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 24, 1));
- for ($i = 0; $i <= 2; $i++) {
- $thisfile_wavpack['extras'][] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 25 + $i, 1));
- }
-
- $thisfile_wavpack['flags'] = array();
- $thisfile_wavpack_flags = &$thisfile_wavpack['flags'];
- $thisfile_wavpack_flags['mono'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000001);
- $thisfile_wavpack_flags['fast_mode'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000002);
- $thisfile_wavpack_flags['raw_mode'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000004);
- $thisfile_wavpack_flags['calc_noise'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000008);
- $thisfile_wavpack_flags['high_quality'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000010);
- $thisfile_wavpack_flags['3_byte_samples'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000020);
- $thisfile_wavpack_flags['over_20_bits'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000040);
- $thisfile_wavpack_flags['use_wvc'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000080);
- $thisfile_wavpack_flags['noiseshaping'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000100);
- $thisfile_wavpack_flags['very_fast_mode'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000200);
- $thisfile_wavpack_flags['new_high_quality'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000400);
- $thisfile_wavpack_flags['cancel_extreme'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000800);
- $thisfile_wavpack_flags['cross_decorrelation'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x001000);
- $thisfile_wavpack_flags['new_decorrelation'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x002000);
- $thisfile_wavpack_flags['joint_stereo'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x004000);
- $thisfile_wavpack_flags['extra_decorrelation'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x008000);
- $thisfile_wavpack_flags['override_noiseshape'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x010000);
- $thisfile_wavpack_flags['override_jointstereo'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x020000);
- $thisfile_wavpack_flags['copy_source_filetime'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x040000);
- $thisfile_wavpack_flags['create_exe'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x080000);
- }
- return true;
- }
- function ParseBITMAPINFOHEADER($BITMAPINFOHEADER, $littleEndian=true) {
-
- $getid3_lib = new getid3_lib();
- $functionname = ($littleEndian ? 'LittleEndian2Int' : 'BigEndian2Int');
- $parsed['biSize'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 0, 4));
- $parsed['biWidth'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 4, 4));
- $parsed['biHeight'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 8, 4));
- $parsed['biPlanes'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 12, 2));
- $parsed['biBitCount'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 14, 2));
- $parsed['fourcc'] = substr($BITMAPINFOHEADER, 16, 4);
- $parsed['biSizeImage'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 20, 4));
- $parsed['biXPelsPerMeter'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 24, 4));
- $parsed['biYPelsPerMeter'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 28, 4));
- $parsed['biClrUsed'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 32, 4));
- $parsed['biClrImportant'] = $getid3_lib->$functionname(substr($BITMAPINFOHEADER, 36, 4));
- return $parsed;
- }
- function RIFFwFormatTagLookup($wFormatTag) {
- $begin = __LINE__;
-
- return getid3_lib::EmbeddedLookup('0x'.str_pad(strtoupper(dechex($wFormatTag)), 4, '0', STR_PAD_LEFT), $begin, __LINE__, __FILE__, 'riff-wFormatTag');
- }
- function RIFFfourccLookup($fourcc) {
- $begin = __LINE__;
-
- return getid3_lib::EmbeddedLookup($fourcc, $begin, __LINE__, __FILE__, 'riff-fourcc');
- }
- function EitherEndian2Int(&$ThisFileInfo, $byteword, $signed=false) {
- if ($ThisFileInfo['fileformat'] == 'riff') {
- return getid3_lib::LittleEndian2Int($byteword, $signed);
- }
- return getid3_lib::BigEndian2Int($byteword, false, $signed);
- }
- }
- ?>
|