Mercurial > judyates
diff e2gallerypro/e2upload/Backend/Assets/getid3/module.audio-video.swf.php @ 3:3f6b44aa6b35 judyates
[svn r4] added ability to buy stuff, from a Prints page, but it doesn't work well with the css, and it also has not been fitted into the perl make system.
author | rlm |
---|---|
date | Mon, 22 Feb 2010 08:02:39 -0500 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/e2gallerypro/e2upload/Backend/Assets/getid3/module.audio-video.swf.php Mon Feb 22 08:02:39 2010 -0500 1.3 @@ -0,0 +1,154 @@ 1.4 +<?php 1.5 +// +----------------------------------------------------------------------+ 1.6 +// | PHP version 5 | 1.7 +// +----------------------------------------------------------------------+ 1.8 +// | Copyright (c) 2002-2006 James Heinrich, Allan Hansen | 1.9 +// +----------------------------------------------------------------------+ 1.10 +// | This source file is subject to version 2 of the GPL license, | 1.11 +// | that is bundled with this package in the file license.txt and is | 1.12 +// | available through the world-wide-web at the following url: | 1.13 +// | http://www.gnu.org/copyleft/gpl.html | 1.14 +// +----------------------------------------------------------------------+ 1.15 +// | getID3() - http://getid3.sourceforge.net or http://www.getid3.org | 1.16 +// +----------------------------------------------------------------------+ 1.17 +// | Authors: James Heinrich <infoØgetid3*org> | 1.18 +// | Allan Hansen <ahØartemis*dk> | 1.19 +// +----------------------------------------------------------------------+ 1.20 +// | module.audio-video.swf.php | 1.21 +// | module for analyzing Macromedia Shockwave Flash files. | 1.22 +// | dependencies: zlib support in PHP | 1.23 +// +----------------------------------------------------------------------+ 1.24 +// 1.25 +// $Id: module.audio-video.swf.php,v 1.2 2006/11/02 10:48:00 ah Exp $ 1.26 + 1.27 + 1.28 + 1.29 +class getid3_swf extends getid3_handler 1.30 +{ 1.31 + 1.32 + public function Analyze() { 1.33 + 1.34 + $getid3 = $this->getid3; 1.35 + 1.36 + $getid3->info['fileformat'] = 'swf'; 1.37 + $getid3->info['video']['dataformat'] = 'swf'; 1.38 + 1.39 + // http://www.openswf.org/spec/SWFfileformat.html 1.40 + 1.41 + fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET); 1.42 + 1.43 + $swf_file_data = fread($getid3->fp, $getid3->info['avdataend'] - $getid3->info['avdataoffset']); // 8 + 2 + 2 + max(9) bytes NOT including Frame_Size RECT data 1.44 + 1.45 + $getid3->info['swf']['header']['signature'] = substr($swf_file_data, 0, 3); 1.46 + switch ($getid3->info['swf']['header']['signature']) { 1.47 + 1.48 + case 'FWS': 1.49 + $getid3->info['swf']['header']['compressed'] = false; 1.50 + break; 1.51 + 1.52 + case 'CWS': 1.53 + $getid3->info['swf']['header']['compressed'] = true; 1.54 + break; 1.55 + 1.56 + default: 1.57 + throw new getid3_exception('Expecting "FWS" or "CWS" at offset '.$getid3->info['avdataoffset'].', found "'.$getid3->info['swf']['header']['signature'].'"'); 1.58 + } 1.59 + $getid3->info['swf']['header']['version'] = getid3_lib::LittleEndian2Int($swf_file_data{3}); 1.60 + $getid3->info['swf']['header']['length'] = getid3_lib::LittleEndian2Int(substr($swf_file_data, 4, 4)); 1.61 + 1.62 + if (!function_exists('gzuncompress')) { 1.63 + throw new getid3_exception('getid3_swf requires --zlib support in PHP.'); 1.64 + } 1.65 + 1.66 + if ($getid3->info['swf']['header']['compressed']) { 1.67 + 1.68 + if ($uncompressed_file_data = @gzuncompress(substr($swf_file_data, 8))) { 1.69 + $swf_file_data = substr($swf_file_data, 0, 8).$uncompressed_file_data; 1.70 + 1.71 + } else { 1.72 + throw new getid3_exception('Error decompressing compressed SWF data'); 1.73 + } 1.74 + 1.75 + } 1.76 + 1.77 + $frame_size_bits_per_value = (ord(substr($swf_file_data, 8, 1)) & 0xF8) >> 3; 1.78 + $frame_size_data_length = ceil((5 + (4 * $frame_size_bits_per_value)) / 8); 1.79 + $frame_size_data_string = str_pad(decbin(ord($swf_file_data[8]) & 0x07), 3, '0', STR_PAD_LEFT); 1.80 + 1.81 + for ($i = 1; $i < $frame_size_data_length; $i++) { 1.82 + $frame_size_data_string .= str_pad(decbin(ord(substr($swf_file_data, 8 + $i, 1))), 8, '0', STR_PAD_LEFT); 1.83 + } 1.84 + 1.85 + list($x1, $x2, $y1, $y2) = explode("\n", wordwrap($frame_size_data_string, $frame_size_bits_per_value, "\n", 1)); 1.86 + $getid3->info['swf']['header']['frame_width'] = bindec($x2); 1.87 + $getid3->info['swf']['header']['frame_height'] = bindec($y2); 1.88 + 1.89 + // http://www-lehre.informatik.uni-osnabrueck.de/~fbstark/diplom/docs/swf/Flash_Uncovered.htm 1.90 + // Next in the header is the frame rate, which is kind of weird. 1.91 + // It is supposed to be stored as a 16bit integer, but the first byte 1.92 + // (or last depending on how you look at it) is completely ignored. 1.93 + // Example: 0x000C -> 0x0C -> 12 So the frame rate is 12 fps. 1.94 + 1.95 + // Byte at (8 + $frame_size_data_length) is always zero and ignored 1.96 + $getid3->info['swf']['header']['frame_rate'] = getid3_lib::LittleEndian2Int($swf_file_data[9 + $frame_size_data_length]); 1.97 + $getid3->info['swf']['header']['frame_count'] = getid3_lib::LittleEndian2Int(substr($swf_file_data, 10 + $frame_size_data_length, 2)); 1.98 + 1.99 + $getid3->info['video']['frame_rate'] = $getid3->info['swf']['header']['frame_rate']; 1.100 + $getid3->info['video']['resolution_x'] = intval(round($getid3->info['swf']['header']['frame_width'] / 20)); 1.101 + $getid3->info['video']['resolution_y'] = intval(round($getid3->info['swf']['header']['frame_height'] / 20)); 1.102 + $getid3->info['video']['pixel_aspect_ratio'] = (float)1; 1.103 + 1.104 + if (($getid3->info['swf']['header']['frame_count'] > 0) && ($getid3->info['swf']['header']['frame_rate'] > 0)) { 1.105 + $getid3->info['playtime_seconds'] = $getid3->info['swf']['header']['frame_count'] / $getid3->info['swf']['header']['frame_rate']; 1.106 + } 1.107 + 1.108 + 1.109 + // SWF tags 1.110 + 1.111 + $current_offset = 12 + $frame_size_data_length; 1.112 + $swf_data_length = strlen($swf_file_data); 1.113 + 1.114 + while ($current_offset < $swf_data_length) { 1.115 + 1.116 + $tag_ID_tag_length = getid3_lib::LittleEndian2Int(substr($swf_file_data, $current_offset, 2)); 1.117 + $tag_ID = ($tag_ID_tag_length & 0xFFFC) >> 6; 1.118 + $tag_length = ($tag_ID_tag_length & 0x003F); 1.119 + $current_offset += 2; 1.120 + if ($tag_length == 0x3F) { 1.121 + $tag_length = getid3_lib::LittleEndian2Int(substr($swf_file_data, $current_offset, 4)); 1.122 + $current_offset += 4; 1.123 + } 1.124 + 1.125 + unset($tag_data); 1.126 + $tag_data['offset'] = $current_offset; 1.127 + $tag_data['size'] = $tag_length; 1.128 + $tag_data['id'] = $tag_ID; 1.129 + $tag_data['data'] = substr($swf_file_data, $current_offset, $tag_length); 1.130 + switch ($tag_ID) { 1.131 + 1.132 + case 0: // end of movie 1.133 + break 2; 1.134 + 1.135 + case 9: // Set background color 1.136 + $getid3->info['swf']['bgcolor'] = strtoupper(str_pad(dechex(getid3_lib::BigEndian2Int($tag_data['data'])), 6, '0', STR_PAD_LEFT)); 1.137 + break; 1.138 + 1.139 + default: 1.140 + /* 1.141 + if ($ReturnAllTagData) { 1.142 + $getid3->info['swf']['tags'][] = $tag_data; 1.143 + } 1.144 + */ 1.145 + break; 1.146 + } 1.147 + 1.148 + $current_offset += $tag_length; 1.149 + } 1.150 + 1.151 + return true; 1.152 + } 1.153 + 1.154 +} 1.155 + 1.156 + 1.157 +?> 1.158 \ No newline at end of file