Mercurial > judyates
comparison 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 |
comparison
equal
deleted
inserted
replaced
2:670229c4eb4b | 3:3f6b44aa6b35 |
---|---|
1 <?php | |
2 // +----------------------------------------------------------------------+ | |
3 // | PHP version 5 | | |
4 // +----------------------------------------------------------------------+ | |
5 // | Copyright (c) 2002-2006 James Heinrich, Allan Hansen | | |
6 // +----------------------------------------------------------------------+ | |
7 // | This source file is subject to version 2 of the GPL license, | | |
8 // | that is bundled with this package in the file license.txt and is | | |
9 // | available through the world-wide-web at the following url: | | |
10 // | http://www.gnu.org/copyleft/gpl.html | | |
11 // +----------------------------------------------------------------------+ | |
12 // | getID3() - http://getid3.sourceforge.net or http://www.getid3.org | | |
13 // +----------------------------------------------------------------------+ | |
14 // | Authors: James Heinrich <infoØgetid3*org> | | |
15 // | Allan Hansen <ahØartemis*dk> | | |
16 // +----------------------------------------------------------------------+ | |
17 // | module.audio-video.swf.php | | |
18 // | module for analyzing Macromedia Shockwave Flash files. | | |
19 // | dependencies: zlib support in PHP | | |
20 // +----------------------------------------------------------------------+ | |
21 // | |
22 // $Id: module.audio-video.swf.php,v 1.2 2006/11/02 10:48:00 ah Exp $ | |
23 | |
24 | |
25 | |
26 class getid3_swf extends getid3_handler | |
27 { | |
28 | |
29 public function Analyze() { | |
30 | |
31 $getid3 = $this->getid3; | |
32 | |
33 $getid3->info['fileformat'] = 'swf'; | |
34 $getid3->info['video']['dataformat'] = 'swf'; | |
35 | |
36 // http://www.openswf.org/spec/SWFfileformat.html | |
37 | |
38 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET); | |
39 | |
40 $swf_file_data = fread($getid3->fp, $getid3->info['avdataend'] - $getid3->info['avdataoffset']); // 8 + 2 + 2 + max(9) bytes NOT including Frame_Size RECT data | |
41 | |
42 $getid3->info['swf']['header']['signature'] = substr($swf_file_data, 0, 3); | |
43 switch ($getid3->info['swf']['header']['signature']) { | |
44 | |
45 case 'FWS': | |
46 $getid3->info['swf']['header']['compressed'] = false; | |
47 break; | |
48 | |
49 case 'CWS': | |
50 $getid3->info['swf']['header']['compressed'] = true; | |
51 break; | |
52 | |
53 default: | |
54 throw new getid3_exception('Expecting "FWS" or "CWS" at offset '.$getid3->info['avdataoffset'].', found "'.$getid3->info['swf']['header']['signature'].'"'); | |
55 } | |
56 $getid3->info['swf']['header']['version'] = getid3_lib::LittleEndian2Int($swf_file_data{3}); | |
57 $getid3->info['swf']['header']['length'] = getid3_lib::LittleEndian2Int(substr($swf_file_data, 4, 4)); | |
58 | |
59 if (!function_exists('gzuncompress')) { | |
60 throw new getid3_exception('getid3_swf requires --zlib support in PHP.'); | |
61 } | |
62 | |
63 if ($getid3->info['swf']['header']['compressed']) { | |
64 | |
65 if ($uncompressed_file_data = @gzuncompress(substr($swf_file_data, 8))) { | |
66 $swf_file_data = substr($swf_file_data, 0, 8).$uncompressed_file_data; | |
67 | |
68 } else { | |
69 throw new getid3_exception('Error decompressing compressed SWF data'); | |
70 } | |
71 | |
72 } | |
73 | |
74 $frame_size_bits_per_value = (ord(substr($swf_file_data, 8, 1)) & 0xF8) >> 3; | |
75 $frame_size_data_length = ceil((5 + (4 * $frame_size_bits_per_value)) / 8); | |
76 $frame_size_data_string = str_pad(decbin(ord($swf_file_data[8]) & 0x07), 3, '0', STR_PAD_LEFT); | |
77 | |
78 for ($i = 1; $i < $frame_size_data_length; $i++) { | |
79 $frame_size_data_string .= str_pad(decbin(ord(substr($swf_file_data, 8 + $i, 1))), 8, '0', STR_PAD_LEFT); | |
80 } | |
81 | |
82 list($x1, $x2, $y1, $y2) = explode("\n", wordwrap($frame_size_data_string, $frame_size_bits_per_value, "\n", 1)); | |
83 $getid3->info['swf']['header']['frame_width'] = bindec($x2); | |
84 $getid3->info['swf']['header']['frame_height'] = bindec($y2); | |
85 | |
86 // http://www-lehre.informatik.uni-osnabrueck.de/~fbstark/diplom/docs/swf/Flash_Uncovered.htm | |
87 // Next in the header is the frame rate, which is kind of weird. | |
88 // It is supposed to be stored as a 16bit integer, but the first byte | |
89 // (or last depending on how you look at it) is completely ignored. | |
90 // Example: 0x000C -> 0x0C -> 12 So the frame rate is 12 fps. | |
91 | |
92 // Byte at (8 + $frame_size_data_length) is always zero and ignored | |
93 $getid3->info['swf']['header']['frame_rate'] = getid3_lib::LittleEndian2Int($swf_file_data[9 + $frame_size_data_length]); | |
94 $getid3->info['swf']['header']['frame_count'] = getid3_lib::LittleEndian2Int(substr($swf_file_data, 10 + $frame_size_data_length, 2)); | |
95 | |
96 $getid3->info['video']['frame_rate'] = $getid3->info['swf']['header']['frame_rate']; | |
97 $getid3->info['video']['resolution_x'] = intval(round($getid3->info['swf']['header']['frame_width'] / 20)); | |
98 $getid3->info['video']['resolution_y'] = intval(round($getid3->info['swf']['header']['frame_height'] / 20)); | |
99 $getid3->info['video']['pixel_aspect_ratio'] = (float)1; | |
100 | |
101 if (($getid3->info['swf']['header']['frame_count'] > 0) && ($getid3->info['swf']['header']['frame_rate'] > 0)) { | |
102 $getid3->info['playtime_seconds'] = $getid3->info['swf']['header']['frame_count'] / $getid3->info['swf']['header']['frame_rate']; | |
103 } | |
104 | |
105 | |
106 // SWF tags | |
107 | |
108 $current_offset = 12 + $frame_size_data_length; | |
109 $swf_data_length = strlen($swf_file_data); | |
110 | |
111 while ($current_offset < $swf_data_length) { | |
112 | |
113 $tag_ID_tag_length = getid3_lib::LittleEndian2Int(substr($swf_file_data, $current_offset, 2)); | |
114 $tag_ID = ($tag_ID_tag_length & 0xFFFC) >> 6; | |
115 $tag_length = ($tag_ID_tag_length & 0x003F); | |
116 $current_offset += 2; | |
117 if ($tag_length == 0x3F) { | |
118 $tag_length = getid3_lib::LittleEndian2Int(substr($swf_file_data, $current_offset, 4)); | |
119 $current_offset += 4; | |
120 } | |
121 | |
122 unset($tag_data); | |
123 $tag_data['offset'] = $current_offset; | |
124 $tag_data['size'] = $tag_length; | |
125 $tag_data['id'] = $tag_ID; | |
126 $tag_data['data'] = substr($swf_file_data, $current_offset, $tag_length); | |
127 switch ($tag_ID) { | |
128 | |
129 case 0: // end of movie | |
130 break 2; | |
131 | |
132 case 9: // Set background color | |
133 $getid3->info['swf']['bgcolor'] = strtoupper(str_pad(dechex(getid3_lib::BigEndian2Int($tag_data['data'])), 6, '0', STR_PAD_LEFT)); | |
134 break; | |
135 | |
136 default: | |
137 /* | |
138 if ($ReturnAllTagData) { | |
139 $getid3->info['swf']['tags'][] = $tag_data; | |
140 } | |
141 */ | |
142 break; | |
143 } | |
144 | |
145 $current_offset += $tag_length; | |
146 } | |
147 | |
148 return true; | |
149 } | |
150 | |
151 } | |
152 | |
153 | |
154 ?> |