<Website>

getID3

PHK Home

File: /lib/module.audio-video.swf.php

Size:3790
Storage flags:strip

<?php
















class getid3_swf extends getid3_handler
{
public 
$ReturnAllTagData false;

public function 
Analyze() {
$info = &$this->getid3->info;

$info['fileformat'] = 'swf';
$info['video']['dataformat'] = 'swf';



$this->fseek($info['avdataoffset']);

$SWFfileData $this->fread($info['avdataend'] - $info['avdataoffset']); 

$info['swf']['header']['signature'] = substr($SWFfileData03);
switch (
$info['swf']['header']['signature']) {
case 
'FWS':
$info['swf']['header']['compressed'] = false;
break;

case 
'CWS':
$info['swf']['header']['compressed'] = true;
break;

default:
$info['error'][] = 'Expecting "FWS" or "CWS" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['swf']['header']['signature']).'"';
unset(
$info['swf']);
unset(
$info['fileformat']);
return 
false;
break;
}
$info['swf']['header']['version'] = getid3_lib::LittleEndian2Int(substr($SWFfileData31));
$info['swf']['header']['length'] = getid3_lib::LittleEndian2Int(substr($SWFfileData44));

if (
$info['swf']['header']['compressed']) {
$SWFHead substr($SWFfileData08);
$SWFfileData substr($SWFfileData8);
if (
$decompressed = @gzuncompress($SWFfileData)) {
$SWFfileData $SWFHead.$decompressed;
} else {
$info['error'][] = 'Error decompressing compressed SWF data ('.strlen($SWFfileData).' bytes compressed, should be '.($info['swf']['header']['length'] - 8).' bytes uncompressed)';
return 
false;
}
}

$FrameSizeBitsPerValue = (ord(substr($SWFfileData81)) & 0xF8) >> 3;
$FrameSizeDataLength ceil((+ ($FrameSizeBitsPerValue)) / 8);
$FrameSizeDataString str_pad(decbin(ord(substr($SWFfileData81)) & 0x07), 3'0'STR_PAD_LEFT);
for (
$i 1$i $FrameSizeDataLength$i++) {
$FrameSizeDataString .= str_pad(decbin(ord(substr($SWFfileData$i1))), 8'0'STR_PAD_LEFT);
}
list(
$X1$X2$Y1$Y2) = explode("\n"wordwrap($FrameSizeDataString$FrameSizeBitsPerValue"\n"1));
$info['swf']['header']['frame_width'] = getid3_lib::Bin2Dec($X2);
$info['swf']['header']['frame_height'] = getid3_lib::Bin2Dec($Y2);


 
 
 
 


 
$info['swf']['header']['frame_rate'] = getid3_lib::LittleEndian2Int(substr($SWFfileData$FrameSizeDataLength1));
$info['swf']['header']['frame_count'] = getid3_lib::LittleEndian2Int(substr($SWFfileData10 $FrameSizeDataLength2));

$info['video']['frame_rate'] = $info['swf']['header']['frame_rate'];
$info['video']['resolution_x'] = intval(round($info['swf']['header']['frame_width'] / 20));
$info['video']['resolution_y'] = intval(round($info['swf']['header']['frame_height'] / 20));
$info['video']['pixel_aspect_ratio'] = (float) 1;

if ((
$info['swf']['header']['frame_count'] > 0) && ($info['swf']['header']['frame_rate'] > 0)) {
$info['playtime_seconds'] = $info['swf']['header']['frame_count'] / $info['swf']['header']['frame_rate'];
}





$CurrentOffset 12 $FrameSizeDataLength;
$SWFdataLength strlen($SWFfileData);

while (
$CurrentOffset $SWFdataLength) {


$TagIDTagLength getid3_lib::LittleEndian2Int(substr($SWFfileData$CurrentOffset2));
$TagID = ($TagIDTagLength 0xFFFC) >> 6;
$TagLength = ($TagIDTagLength 0x003F);
$CurrentOffset += 2;
if (
$TagLength == 0x3F) {
$TagLength getid3_lib::LittleEndian2Int(substr($SWFfileData$CurrentOffset4));
$CurrentOffset += 4;
}

unset(
$TagData);
$TagData['offset'] = $CurrentOffset;
$TagData['size'] = $TagLength;
$TagData['id'] = $TagID;
$TagData['data'] = substr($SWFfileData$CurrentOffset$TagLength);
switch (
$TagID) {
case 
0
 break 
2;

case 
9
 
 
$info['swf']['bgcolor'] = strtoupper(str_pad(dechex(getid3_lib::BigEndian2Int($TagData['data'])), 6'0'STR_PAD_LEFT));
break;

default:
if (
$this->ReturnAllTagData) {
$info['swf']['tags'][] = $TagData;
}
break;
}

$CurrentOffset += $TagLength;
}

return 
true;
}

}

For more information about the PHK package format: http://phk.tekwire.net