Annotation of /trunk/lib/getid3/module.audio.optimfrog.php
Parent Directory
|
Revision Log
Revision 2 - (view) (download)
| 1 : | andphe | 2 | <?php |
| 2 : | ///////////////////////////////////////////////////////////////// | ||
| 3 : | /// getID3() by James Heinrich <info@getid3.org> // | ||
| 4 : | // available at http://getid3.sourceforge.net // | ||
| 5 : | // or http://www.getid3.org // | ||
| 6 : | ///////////////////////////////////////////////////////////////// | ||
| 7 : | // See readme.txt for more details // | ||
| 8 : | ///////////////////////////////////////////////////////////////// | ||
| 9 : | // // | ||
| 10 : | // module.audio.optimfrog.php // | ||
| 11 : | // module for analyzing OptimFROG audio files // | ||
| 12 : | // dependencies: module.audio.riff.php // | ||
| 13 : | // /// | ||
| 14 : | ///////////////////////////////////////////////////////////////// | ||
| 15 : | // MOS Intruder Alerts | ||
| 16 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 17 : | |||
| 18 : | getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true); | ||
| 19 : | |||
| 20 : | class getid3_optimfrog | ||
| 21 : | { | ||
| 22 : | |||
| 23 : | function getid3_optimfrog(&$fd, &$ThisFileInfo) { | ||
| 24 : | $ThisFileInfo['fileformat'] = 'ofr'; | ||
| 25 : | $ThisFileInfo['audio']['dataformat'] = 'ofr'; | ||
| 26 : | $ThisFileInfo['audio']['bitrate_mode'] = 'vbr'; | ||
| 27 : | $ThisFileInfo['audio']['lossless'] = true; | ||
| 28 : | |||
| 29 : | fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET); | ||
| 30 : | $OFRheader = fread($fd, 8); | ||
| 31 : | if (substr($OFRheader, 0, 5) == '*RIFF') { | ||
| 32 : | |||
| 33 : | return $this->ParseOptimFROGheader42($fd, $ThisFileInfo); | ||
| 34 : | |||
| 35 : | } elseif (substr($OFRheader, 0, 3) == 'OFR') { | ||
| 36 : | |||
| 37 : | return $this->ParseOptimFROGheader45($fd, $ThisFileInfo); | ||
| 38 : | |||
| 39 : | } | ||
| 40 : | |||
| 41 : | $ThisFileInfo['error'][] = 'Expecting "*RIFF" or "OFR " at offset '.$ThisFileInfo['avdataoffset'].', found "'.$OFRheader.'"'; | ||
| 42 : | unset($ThisFileInfo['fileformat']); | ||
| 43 : | return false; | ||
| 44 : | } | ||
| 45 : | |||
| 46 : | |||
| 47 : | function ParseOptimFROGheader42(&$fd, &$ThisFileInfo) { | ||
| 48 : | // for fileformat of v4.21 and older | ||
| 49 : | |||
| 50 : | fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET); | ||
| 51 : | $OptimFROGheaderData = fread($fd, 45); | ||
| 52 : | $ThisFileInfo['avdataoffset'] = 45; | ||
| 53 : | |||
| 54 : | $OptimFROGencoderVersion_raw = getid3_lib::LittleEndian2Int(substr($OptimFROGheaderData, 0, 1)); | ||
| 55 : | $OptimFROGencoderVersion_major = floor($OptimFROGencoderVersion_raw / 10); | ||
| 56 : | $OptimFROGencoderVersion_minor = $OptimFROGencoderVersion_raw - ($OptimFROGencoderVersion_major * 10); | ||
| 57 : | $RIFFdata = substr($OptimFROGheaderData, 1, 44); | ||
| 58 : | $OrignalRIFFheaderSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 4, 4)) + 8; | ||
| 59 : | $OrignalRIFFdataSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 40, 4)) + 44; | ||
| 60 : | |||
| 61 : | if ($OrignalRIFFheaderSize > $OrignalRIFFdataSize) { | ||
| 62 : | $ThisFileInfo['avdataend'] -= ($OrignalRIFFheaderSize - $OrignalRIFFdataSize); | ||
| 63 : | fseek($fd, $ThisFileInfo['avdataend'], SEEK_SET); | ||
| 64 : | $RIFFdata .= fread($fd, $OrignalRIFFheaderSize - $OrignalRIFFdataSize); | ||
| 65 : | } | ||
| 66 : | |||
| 67 : | // move the data chunk after all other chunks (if any) | ||
| 68 : | // so that the RIFF parser doesn't see EOF when trying | ||
| 69 : | // to skip over the data chunk | ||
| 70 : | $RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8); | ||
| 71 : | getid3_riff::ParseRIFFdata($RIFFdata, $ThisFileInfo); | ||
| 72 : | |||
| 73 : | $ThisFileInfo['audio']['encoder'] = 'OptimFROG '.$OptimFROGencoderVersion_major.'.'.$OptimFROGencoderVersion_minor; | ||
| 74 : | $ThisFileInfo['audio']['channels'] = $ThisFileInfo['riff']['audio'][0]['channels']; | ||
| 75 : | $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['riff']['audio'][0]['sample_rate']; | ||
| 76 : | $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['riff']['audio'][0]['bits_per_sample']; | ||
| 77 : | $ThisFileInfo['playtime_seconds'] = $OrignalRIFFdataSize / ($ThisFileInfo['audio']['channels'] * $ThisFileInfo['audio']['sample_rate'] * ($ThisFileInfo['audio']['bits_per_sample'] / 8)); | ||
| 78 : | $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds']; | ||
| 79 : | |||
| 80 : | return true; | ||
| 81 : | } | ||
| 82 : | |||
| 83 : | |||
| 84 : | function ParseOptimFROGheader45(&$fd, &$ThisFileInfo) { | ||
| 85 : | // for fileformat of v4.50a and higher | ||
| 86 : | |||
| 87 : | $RIFFdata = ''; | ||
| 88 : | fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET); | ||
| 89 : | while (!feof($fd) && (ftell($fd) < $ThisFileInfo['avdataend'])) { | ||
| 90 : | $BlockOffset = ftell($fd); | ||
| 91 : | $BlockData = fread($fd, 8); | ||
| 92 : | $offset = 8; | ||
| 93 : | $BlockName = substr($BlockData, 0, 4); | ||
| 94 : | $BlockSize = getid3_lib::LittleEndian2Int(substr($BlockData, 4, 4)); | ||
| 95 : | |||
| 96 : | if ($BlockName == 'OFRX') { | ||
| 97 : | $BlockName = 'OFR '; | ||
| 98 : | } | ||
| 99 : | if (!isset($ThisFileInfo['ofr'][$BlockName])) { | ||
| 100 : | $ThisFileInfo['ofr'][$BlockName] = array(); | ||
| 101 : | } | ||
| 102 : | $thisfile_ofr_thisblock = &$ThisFileInfo['ofr'][$BlockName]; | ||
| 103 : | |||
| 104 : | switch ($BlockName) { | ||
| 105 : | case 'OFR ': | ||
| 106 : | |||
| 107 : | // shortcut | ||
| 108 : | $thisfile_ofr_thisblock['offset'] = $BlockOffset; | ||
| 109 : | $thisfile_ofr_thisblock['size'] = $BlockSize; | ||
| 110 : | |||
| 111 : | $ThisFileInfo['audio']['encoder'] = 'OptimFROG 4.50 alpha'; | ||
| 112 : | switch ($BlockSize) { | ||
| 113 : | case 12: | ||
| 114 : | case 15: | ||
| 115 : | // good | ||
| 116 : | break; | ||
| 117 : | |||
| 118 : | default: | ||
| 119 : | $ThisFileInfo['warning'][] = '"'.$BlockName.'" contains more data than expected (expected 12 or 15 bytes, found '.$BlockSize.' bytes)'; | ||
| 120 : | break; | ||
| 121 : | } | ||
| 122 : | $BlockData .= fread($fd, $BlockSize); | ||
| 123 : | |||
| 124 : | $thisfile_ofr_thisblock['total_samples'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 6)); | ||
| 125 : | $offset += 6; | ||
| 126 : | $thisfile_ofr_thisblock['raw']['sample_type'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 1)); | ||
| 127 : | $thisfile_ofr_thisblock['sample_type'] = $this->OptimFROGsampleTypeLookup($thisfile_ofr_thisblock['raw']['sample_type']); | ||
| 128 : | $offset += 1; | ||
| 129 : | $thisfile_ofr_thisblock['channel_config'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 1)); | ||
| 130 : | $thisfile_ofr_thisblock['channels'] = $thisfile_ofr_thisblock['channel_config']; | ||
| 131 : | $offset += 1; | ||
| 132 : | $thisfile_ofr_thisblock['sample_rate'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 4)); | ||
| 133 : | $offset += 4; | ||
| 134 : | |||
| 135 : | if ($BlockSize > 12) { | ||
| 136 : | |||
| 137 : | // OFR 4.504b or higher | ||
| 138 : | $thisfile_ofr_thisblock['channels'] = $this->OptimFROGchannelConfigNumChannelsLookup($thisfile_ofr_thisblock['channel_config']); | ||
| 139 : | $thisfile_ofr_thisblock['raw']['encoder_id'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 2)); | ||
| 140 : | $thisfile_ofr_thisblock['encoder'] = $this->OptimFROGencoderNameLookup($thisfile_ofr_thisblock['raw']['encoder_id']); | ||
| 141 : | $offset += 2; | ||
| 142 : | $thisfile_ofr_thisblock['raw']['compression'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 1)); | ||
| 143 : | $thisfile_ofr_thisblock['compression'] = $this->OptimFROGcompressionLookup($thisfile_ofr_thisblock['raw']['compression']); | ||
| 144 : | $thisfile_ofr_thisblock['speedup'] = $this->OptimFROGspeedupLookup($thisfile_ofr_thisblock['raw']['compression']); | ||
| 145 : | $offset += 1; | ||
| 146 : | |||
| 147 : | $ThisFileInfo['audio']['encoder'] = 'OptimFROG '.$thisfile_ofr_thisblock['encoder']; | ||
| 148 : | $ThisFileInfo['audio']['encoder_options'] = '--mode '.$thisfile_ofr_thisblock['compression']; | ||
| 149 : | |||
| 150 : | if ((($thisfile_ofr_thisblock['raw']['encoder_id'] & 0xF0) >> 4) == 7) { // v4.507 | ||
| 151 : | if (strtolower(getid3_lib::fileextension($ThisFileInfo['filename'])) == 'ofs') { | ||
| 152 : | // OptimFROG DualStream format is lossy, but as of v4.507 there is no way to tell the difference | ||
| 153 : | // between lossless and lossy other than the file extension. | ||
| 154 : | $ThisFileInfo['audio']['dataformat'] = 'ofs'; | ||
| 155 : | $ThisFileInfo['audio']['lossless'] = true; | ||
| 156 : | } | ||
| 157 : | } | ||
| 158 : | |||
| 159 : | } | ||
| 160 : | |||
| 161 : | $ThisFileInfo['audio']['channels'] = $thisfile_ofr_thisblock['channels']; | ||
| 162 : | $ThisFileInfo['audio']['sample_rate'] = $thisfile_ofr_thisblock['sample_rate']; | ||
| 163 : | $ThisFileInfo['audio']['bits_per_sample'] = $this->OptimFROGbitsPerSampleTypeLookup($thisfile_ofr_thisblock['raw']['sample_type']); | ||
| 164 : | break; | ||
| 165 : | |||
| 166 : | |||
| 167 : | case 'COMP': | ||
| 168 : | // unlike other block types, there CAN be multiple COMP blocks | ||
| 169 : | |||
| 170 : | $COMPdata['offset'] = $BlockOffset; | ||
| 171 : | $COMPdata['size'] = $BlockSize; | ||
| 172 : | |||
| 173 : | if ($ThisFileInfo['avdataoffset'] == 0) { | ||
| 174 : | $ThisFileInfo['avdataoffset'] = $BlockOffset; | ||
| 175 : | } | ||
| 176 : | |||
| 177 : | // Only interested in first 14 bytes (only first 12 needed for v4.50 alpha), not actual audio data | ||
| 178 : | $BlockData .= fread($fd, 14); | ||
| 179 : | fseek($fd, $BlockSize - 14, SEEK_CUR); | ||
| 180 : | |||
| 181 : | $COMPdata['crc_32'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 4)); | ||
| 182 : | $offset += 4; | ||
| 183 : | $COMPdata['sample_count'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 4)); | ||
| 184 : | $offset += 4; | ||
| 185 : | $COMPdata['raw']['sample_type'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 1)); | ||
| 186 : | $COMPdata['sample_type'] = $this->OptimFROGsampleTypeLookup($COMPdata['raw']['sample_type']); | ||
| 187 : | $offset += 1; | ||
| 188 : | $COMPdata['raw']['channel_configuration'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 1)); | ||
| 189 : | $COMPdata['channel_configuration'] = $this->OptimFROGchannelConfigurationLookup($COMPdata['raw']['channel_configuration']); | ||
| 190 : | $offset += 1; | ||
| 191 : | $COMPdata['raw']['algorithm_id'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 2)); | ||
| 192 : | //$COMPdata['algorithm'] = OptimFROGalgorithmNameLookup($COMPdata['raw']['algorithm_id']); | ||
| 193 : | $offset += 2; | ||
| 194 : | |||
| 195 : | if ($ThisFileInfo['ofr']['OFR ']['size'] > 12) { | ||
| 196 : | |||
| 197 : | // OFR 4.504b or higher | ||
| 198 : | $COMPdata['raw']['encoder_id'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 2)); | ||
| 199 : | $COMPdata['encoder'] = $this->OptimFROGencoderNameLookup($COMPdata['raw']['encoder_id']); | ||
| 200 : | $offset += 2; | ||
| 201 : | |||
| 202 : | } | ||
| 203 : | |||
| 204 : | if ($COMPdata['crc_32'] == 0x454E4F4E) { | ||
| 205 : | // ASCII value of 'NONE' - placeholder value in v4.50a | ||
| 206 : | $COMPdata['crc_32'] = false; | ||
| 207 : | } | ||
| 208 : | |||
| 209 : | $thisfile_ofr_thisblock[] = $COMPdata; | ||
| 210 : | break; | ||
| 211 : | |||
| 212 : | case 'HEAD': | ||
| 213 : | $thisfile_ofr_thisblock['offset'] = $BlockOffset; | ||
| 214 : | $thisfile_ofr_thisblock['size'] = $BlockSize; | ||
| 215 : | |||
| 216 : | $RIFFdata .= fread($fd, $BlockSize); | ||
| 217 : | break; | ||
| 218 : | |||
| 219 : | case 'TAIL': | ||
| 220 : | $thisfile_ofr_thisblock['offset'] = $BlockOffset; | ||
| 221 : | $thisfile_ofr_thisblock['size'] = $BlockSize; | ||
| 222 : | |||
| 223 : | if ($BlockSize > 0) { | ||
| 224 : | $RIFFdata .= fread($fd, $BlockSize); | ||
| 225 : | } | ||
| 226 : | break; | ||
| 227 : | |||
| 228 : | case 'RECV': | ||
| 229 : | // block contains no useful meta data - simply note and skip | ||
| 230 : | |||
| 231 : | $thisfile_ofr_thisblock['offset'] = $BlockOffset; | ||
| 232 : | $thisfile_ofr_thisblock['size'] = $BlockSize; | ||
| 233 : | |||
| 234 : | fseek($fd, $BlockSize, SEEK_CUR); | ||
| 235 : | break; | ||
| 236 : | |||
| 237 : | |||
| 238 : | case 'APET': | ||
| 239 : | // APEtag v2 | ||
| 240 : | |||
| 241 : | $thisfile_ofr_thisblock['offset'] = $BlockOffset; | ||
| 242 : | $thisfile_ofr_thisblock['size'] = $BlockSize; | ||
| 243 : | $ThisFileInfo['warning'][] = 'APEtag processing inside OptimFROG not supported in this version ('.GETID3_VERSION.') of getID3()'; | ||
| 244 : | |||
| 245 : | fseek($fd, $BlockSize, SEEK_CUR); | ||
| 246 : | break; | ||
| 247 : | |||
| 248 : | |||
| 249 : | case 'MD5 ': | ||
| 250 : | // APEtag v2 | ||
| 251 : | |||
| 252 : | $thisfile_ofr_thisblock['offset'] = $BlockOffset; | ||
| 253 : | $thisfile_ofr_thisblock['size'] = $BlockSize; | ||
| 254 : | |||
| 255 : | if ($BlockSize == 16) { | ||
| 256 : | |||
| 257 : | $thisfile_ofr_thisblock['md5_binary'] = fread($fd, $BlockSize); | ||
| 258 : | $thisfile_ofr_thisblock['md5_string'] = getid3_lib::PrintHexBytes($thisfile_ofr_thisblock['md5_binary'], true, false, false); | ||
| 259 : | $ThisFileInfo['md5_data_source'] = $thisfile_ofr_thisblock['md5_string']; | ||
| 260 : | |||
| 261 : | } else { | ||
| 262 : | |||
| 263 : | $ThisFileInfo['warning'][] = 'Expecting block size of 16 in "MD5 " chunk, found '.$BlockSize.' instead'; | ||
| 264 : | fseek($fd, $BlockSize, SEEK_CUR); | ||
| 265 : | |||
| 266 : | } | ||
| 267 : | break; | ||
| 268 : | |||
| 269 : | |||
| 270 : | default: | ||
| 271 : | $thisfile_ofr_thisblock['offset'] = $BlockOffset; | ||
| 272 : | $thisfile_ofr_thisblock['size'] = $BlockSize; | ||
| 273 : | |||
| 274 : | $ThisFileInfo['warning'][] = 'Unhandled OptimFROG block type "'.$BlockName.'" at offset '.$thisfile_ofr_thisblock['offset']; | ||
| 275 : | fseek($fd, $BlockSize, SEEK_CUR); | ||
| 276 : | break; | ||
| 277 : | } | ||
| 278 : | } | ||
| 279 : | if (isset($ThisFileInfo['ofr']['TAIL']['offset'])) { | ||
| 280 : | $ThisFileInfo['avdataend'] = $ThisFileInfo['ofr']['TAIL']['offset']; | ||
| 281 : | } | ||
| 282 : | |||
| 283 : | $ThisFileInfo['playtime_seconds'] = (float) $ThisFileInfo['ofr']['OFR ']['total_samples'] / ($ThisFileInfo['audio']['channels'] * $ThisFileInfo['audio']['sample_rate']); | ||
| 284 : | $ThisFileInfo['audio']['bitrate'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / $ThisFileInfo['playtime_seconds']; | ||
| 285 : | |||
| 286 : | // move the data chunk after all other chunks (if any) | ||
| 287 : | // so that the RIFF parser doesn't see EOF when trying | ||
| 288 : | // to skip over the data chunk | ||
| 289 : | $RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8); | ||
| 290 : | getid3_riff::ParseRIFFdata($RIFFdata, $ThisFileInfo); | ||
| 291 : | |||
| 292 : | return true; | ||
| 293 : | } | ||
| 294 : | |||
| 295 : | |||
| 296 : | function OptimFROGsampleTypeLookup($SampleType) { | ||
| 297 : | static $OptimFROGsampleTypeLookup = array( | ||
| 298 : | 0 => 'unsigned int (8-bit)', | ||
| 299 : | 1 => 'signed int (8-bit)', | ||
| 300 : | 2 => 'unsigned int (16-bit)', | ||
| 301 : | 3 => 'signed int (16-bit)', | ||
| 302 : | 4 => 'unsigned int (24-bit)', | ||
| 303 : | 5 => 'signed int (24-bit)', | ||
| 304 : | 6 => 'unsigned int (32-bit)', | ||
| 305 : | 7 => 'signed int (32-bit)', | ||
| 306 : | 8 => 'float 0.24 (32-bit)', | ||
| 307 : | 9 => 'float 16.8 (32-bit)', | ||
| 308 : | 10 => 'float 24.0 (32-bit)' | ||
| 309 : | ); | ||
| 310 : | return (isset($OptimFROGsampleTypeLookup[$SampleType]) ? $OptimFROGsampleTypeLookup[$SampleType] : false); | ||
| 311 : | } | ||
| 312 : | |||
| 313 : | function OptimFROGbitsPerSampleTypeLookup($SampleType) { | ||
| 314 : | static $OptimFROGbitsPerSampleTypeLookup = array( | ||
| 315 : | 0 => 8, | ||
| 316 : | 1 => 8, | ||
| 317 : | 2 => 16, | ||
| 318 : | 3 => 16, | ||
| 319 : | 4 => 24, | ||
| 320 : | 5 => 24, | ||
| 321 : | 6 => 32, | ||
| 322 : | 7 => 32, | ||
| 323 : | 8 => 32, | ||
| 324 : | 9 => 32, | ||
| 325 : | 10 => 32 | ||
| 326 : | ); | ||
| 327 : | return (isset($OptimFROGbitsPerSampleTypeLookup[$SampleType]) ? $OptimFROGbitsPerSampleTypeLookup[$SampleType] : false); | ||
| 328 : | } | ||
| 329 : | |||
| 330 : | function OptimFROGchannelConfigurationLookup($ChannelConfiguration) { | ||
| 331 : | static $OptimFROGchannelConfigurationLookup = array( | ||
| 332 : | 0 => 'mono', | ||
| 333 : | 1 => 'stereo' | ||
| 334 : | ); | ||
| 335 : | return (isset($OptimFROGchannelConfigurationLookup[$ChannelConfiguration]) ? $OptimFROGchannelConfigurationLookup[$ChannelConfiguration] : false); | ||
| 336 : | } | ||
| 337 : | |||
| 338 : | function OptimFROGchannelConfigNumChannelsLookup($ChannelConfiguration) { | ||
| 339 : | static $OptimFROGchannelConfigNumChannelsLookup = array( | ||
| 340 : | 0 => 1, | ||
| 341 : | 1 => 2 | ||
| 342 : | ); | ||
| 343 : | return (isset($OptimFROGchannelConfigNumChannelsLookup[$ChannelConfiguration]) ? $OptimFROGchannelConfigNumChannelsLookup[$ChannelConfiguration] : false); | ||
| 344 : | } | ||
| 345 : | |||
| 346 : | |||
| 347 : | |||
| 348 : | // function OptimFROGalgorithmNameLookup($AlgorithID) { | ||
| 349 : | // static $OptimFROGalgorithmNameLookup = array(); | ||
| 350 : | // return (isset($OptimFROGalgorithmNameLookup[$AlgorithID]) ? $OptimFROGalgorithmNameLookup[$AlgorithID] : false); | ||
| 351 : | // } | ||
| 352 : | |||
| 353 : | |||
| 354 : | function OptimFROGencoderNameLookup($EncoderID) { | ||
| 355 : | // version = (encoderID >> 4) + 4500 | ||
| 356 : | // system = encoderID & 0xF | ||
| 357 : | |||
| 358 : | $EncoderVersion = number_format(((($EncoderID & 0xF0) >> 4) + 4500) / 1000, 3); | ||
| 359 : | $EncoderSystemID = ($EncoderID & 0x0F); | ||
| 360 : | |||
| 361 : | static $OptimFROGencoderSystemLookup = array( | ||
| 362 : | 0x00 => 'Windows console', | ||
| 363 : | 0x01 => 'Linux console', | ||
| 364 : | 0x0F => 'unknown' | ||
| 365 : | ); | ||
| 366 : | return $EncoderVersion.' ('.(isset($OptimFROGencoderSystemLookup[$EncoderSystemID]) ? $OptimFROGencoderSystemLookup[$EncoderSystemID] : 'undefined encoder type (0x'.dechex($EncoderSystemID).')').')'; | ||
| 367 : | } | ||
| 368 : | |||
| 369 : | function OptimFROGcompressionLookup($CompressionID) { | ||
| 370 : | // mode = compression >> 3 | ||
| 371 : | // speedup = compression & 0x07 | ||
| 372 : | |||
| 373 : | $CompressionModeID = ($CompressionID & 0xF8) >> 3; | ||
| 374 : | //$CompressionSpeedupID = ($CompressionID & 0x07); | ||
| 375 : | |||
| 376 : | static $OptimFROGencoderModeLookup = array( | ||
| 377 : | 0x00 => 'fast', | ||
| 378 : | 0x01 => 'normal', | ||
| 379 : | 0x02 => 'high', | ||
| 380 : | 0x03 => 'extra', // extranew (some versions) | ||
| 381 : | 0x04 => 'best', // bestnew (some versions) | ||
| 382 : | 0x05 => 'ultra', | ||
| 383 : | 0x06 => 'insane', | ||
| 384 : | 0x07 => 'highnew', | ||
| 385 : | 0x08 => 'extranew', | ||
| 386 : | 0x09 => 'bestnew' | ||
| 387 : | ); | ||
| 388 : | return (isset($OptimFROGencoderModeLookup[$CompressionModeID]) ? $OptimFROGencoderModeLookup[$CompressionModeID] : 'undefined mode (0x'.str_pad(dechex($CompressionModeID), 2, '0', STR_PAD_LEFT).')'); | ||
| 389 : | } | ||
| 390 : | |||
| 391 : | function OptimFROGspeedupLookup($CompressionID) { | ||
| 392 : | // mode = compression >> 3 | ||
| 393 : | // speedup = compression & 0x07 | ||
| 394 : | |||
| 395 : | //$CompressionModeID = ($CompressionID & 0xF8) >> 3; | ||
| 396 : | $CompressionSpeedupID = ($CompressionID & 0x07); | ||
| 397 : | |||
| 398 : | static $OptimFROGencoderSpeedupLookup = array( | ||
| 399 : | 0x00 => '1x', | ||
| 400 : | 0x01 => '2x', | ||
| 401 : | 0x02 => '4x' | ||
| 402 : | ); | ||
| 403 : | |||
| 404 : | return (isset($OptimFROGencoderSpeedupLookup[$CompressionSpeedupID]) ? $OptimFROGencoderSpeedupLookup[$CompressionSpeedupID] : 'undefined mode (0x'.dechex($CompressionSpeedupID)); | ||
| 405 : | } | ||
| 406 : | |||
| 407 : | } | ||
| 408 : | |||
| 409 : | |||
| 410 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

