annotate e2gallerypro/e2upload/Backend/Assets/getid3/module.audio.optimfrog.php @ 25:6a3d04638a89 judyates

mailto links.
author Robert McIntyre <rlm@mit.edu>
date Sat, 19 Jul 2014 14:35:52 -0400
parents 3f6b44aa6b35
children
rev   line source
rlm@3 1 <?php
rlm@3 2 // +----------------------------------------------------------------------+
rlm@3 3 // | PHP version 5 |
rlm@3 4 // +----------------------------------------------------------------------+
rlm@3 5 // | Copyright (c) 2002-2006 James Heinrich, Allan Hansen |
rlm@3 6 // +----------------------------------------------------------------------+
rlm@3 7 // | This source file is subject to version 2 of the GPL license, |
rlm@3 8 // | that is bundled with this package in the file license.txt and is |
rlm@3 9 // | available through the world-wide-web at the following url: |
rlm@3 10 // | http://www.gnu.org/copyleft/gpl.html |
rlm@3 11 // +----------------------------------------------------------------------+
rlm@3 12 // | getID3() - http://getid3.sourceforge.net or http://www.getid3.org |
rlm@3 13 // +----------------------------------------------------------------------+
rlm@3 14 // | Authors: James Heinrich <infoØgetid3*org> |
rlm@3 15 // | Allan Hansen <ahØartemis*dk> |
rlm@3 16 // +----------------------------------------------------------------------+
rlm@3 17 // | module.audio.optimfrog.php |
rlm@3 18 // | Module for analyzing OptimFROG Audio files |
rlm@3 19 // | dependencies: module.audio-video.riff.php |
rlm@3 20 // +----------------------------------------------------------------------+
rlm@3 21 //
rlm@3 22 // $Id: module.audio.optimfrog.php,v 1.3 2006/11/02 10:48:01 ah Exp $
rlm@3 23
rlm@3 24
rlm@3 25
rlm@3 26 class getid3_optimfrog extends getid3_handler
rlm@3 27 {
rlm@3 28
rlm@3 29 public function Analyze() {
rlm@3 30
rlm@3 31 $getid3 = $this->getid3;
rlm@3 32
rlm@3 33 $getid3->include_module('audio-video.riff');
rlm@3 34
rlm@3 35 $getid3->info['audio']['dataformat'] = 'ofr';
rlm@3 36 $getid3->info['audio']['bitrate_mode'] = 'vbr';
rlm@3 37 $getid3->info['audio']['lossless'] = true;
rlm@3 38
rlm@3 39 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
rlm@3 40 $ofr_header = fread($getid3->fp, 8);
rlm@3 41
rlm@3 42 if (substr($ofr_header, 0, 5) == '*RIFF') {
rlm@3 43 return $this->ParseOptimFROGheader42($getid3->fp, $getid3->info);
rlm@3 44
rlm@3 45 } elseif (substr($ofr_header, 0, 3) == 'OFR') {
rlm@3 46 return $this->ParseOptimFROGheader45($getid3->fp, $getid3->info);
rlm@3 47 }
rlm@3 48
rlm@3 49 throw new getid3_exception('Expecting "*RIFF" or "OFR " at offset '.$getid3->info['avdataoffset'].', found "'.$ofr_header.'"');
rlm@3 50 }
rlm@3 51
rlm@3 52
rlm@3 53
rlm@3 54 private function ParseOptimFROGheader42() {
rlm@3 55
rlm@3 56 $getid3 = $this->getid3;
rlm@3 57
rlm@3 58 // for fileformat of v4.21 and older
rlm@3 59
rlm@3 60 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
rlm@3 61
rlm@3 62 $ofr_header_data = fread($getid3->fp, 45);
rlm@3 63 $getid3->info['avdataoffset'] = 45;
rlm@3 64
rlm@3 65 $ofr_encoder_version_raw = getid3_lib::LittleEndian2Int(substr($ofr_header_data, 0, 1));
rlm@3 66 $ofr_encoder_version_major = floor($ofr_encoder_version_raw / 10);
rlm@3 67 $ofr_encoder_version_minor = $ofr_encoder_version_raw - ($ofr_encoder_version_major * 10);
rlm@3 68 $riff_data = substr($ofr_header_data, 1, 44);
rlm@3 69 $origna_riff_header_size = getid3_lib::LittleEndian2Int(substr($riff_data, 4, 4)) + 8;
rlm@3 70 $origna_riff_data_size = getid3_lib::LittleEndian2Int(substr($riff_data, 40, 4)) + 44;
rlm@3 71
rlm@3 72 if ($origna_riff_header_size > $origna_riff_data_size) {
rlm@3 73 $getid3->info['avdataend'] -= ($origna_riff_header_size - $origna_riff_data_size);
rlm@3 74 fseek($getid3->fp, $getid3->info['avdataend'], SEEK_SET);
rlm@3 75 $riff_data .= fread($getid3->fp, $origna_riff_header_size - $origna_riff_data_size);
rlm@3 76 }
rlm@3 77
rlm@3 78 // move the data chunk after all other chunks (if any)
rlm@3 79 // so that the RIFF parser doesn't see EOF when trying
rlm@3 80 // to skip over the data chunk
rlm@3 81
rlm@3 82 $riff_data = substr($riff_data, 0, 36).substr($riff_data, 44).substr($riff_data, 36, 8);
rlm@3 83
rlm@3 84 // Save audio info key
rlm@3 85 $saved_info_audio = $getid3->info['audio'];
rlm@3 86
rlm@3 87 // Instantiate riff module and analyze string
rlm@3 88 $riff = new getid3_riff($getid3);
rlm@3 89 $riff->AnalyzeString($riff_data);
rlm@3 90
rlm@3 91 // Restore info key
rlm@3 92 $getid3->info['audio'] = $saved_info_audio;
rlm@3 93
rlm@3 94 $getid3->info['audio']['encoder'] = 'OptimFROG '.$ofr_encoder_version_major.'.'.$ofr_encoder_version_minor;
rlm@3 95 $getid3->info['audio']['channels'] = $getid3->info['riff']['audio'][0]['channels'];
rlm@3 96 $getid3->info['audio']['sample_rate'] = $getid3->info['riff']['audio'][0]['sample_rate'];
rlm@3 97 $getid3->info['audio']['bits_per_sample'] = $getid3->info['riff']['audio'][0]['bits_per_sample'];
rlm@3 98 $getid3->info['playtime_seconds'] = $origna_riff_data_size / ($getid3->info['audio']['channels'] * $getid3->info['audio']['sample_rate'] * ($getid3->info['audio']['bits_per_sample'] / 8));
rlm@3 99 $getid3->info['audio']['bitrate'] = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['playtime_seconds'];
rlm@3 100
rlm@3 101 $getid3->info['fileformat'] = 'ofr';
rlm@3 102
rlm@3 103 return true;
rlm@3 104 }
rlm@3 105
rlm@3 106
rlm@3 107
rlm@3 108 private function ParseOptimFROGheader45() {
rlm@3 109
rlm@3 110 $getid3 = $this->getid3;
rlm@3 111
rlm@3 112 // for fileformat of v4.50a and higher
rlm@3 113
rlm@3 114 $riff_data = '';
rlm@3 115 fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
rlm@3 116
rlm@3 117 while (!feof($getid3->fp) && (ftell($getid3->fp) < $getid3->info['avdataend'])) {
rlm@3 118
rlm@3 119 $block_offset = ftell($getid3->fp);
rlm@3 120 $block_data = fread($getid3->fp, 8);
rlm@3 121 $offset = 8;
rlm@3 122 $block_name = substr($block_data, 0, 4);
rlm@3 123 $block_size = getid3_lib::LittleEndian2Int(substr($block_data, 4, 4));
rlm@3 124
rlm@3 125 if ($block_name == 'OFRX') {
rlm@3 126 $block_name = 'OFR ';
rlm@3 127 }
rlm@3 128 if (!isset($getid3->info['ofr'][$block_name])) {
rlm@3 129 $getid3->info['ofr'][$block_name] = array ();
rlm@3 130 }
rlm@3 131 $info_ofr_this_block = &$getid3->info['ofr'][$block_name];
rlm@3 132
rlm@3 133 switch ($block_name) {
rlm@3 134 case 'OFR ':
rlm@3 135
rlm@3 136 // shortcut
rlm@3 137 $info_ofr_this_block['offset'] = $block_offset;
rlm@3 138 $info_ofr_this_block['size'] = $block_size;
rlm@3 139
rlm@3 140 $getid3->info['audio']['encoder'] = 'OptimFROG 4.50 alpha';
rlm@3 141 switch ($block_size) {
rlm@3 142 case 12:
rlm@3 143 case 15:
rlm@3 144 // good
rlm@3 145 break;
rlm@3 146
rlm@3 147 default:
rlm@3 148 $getid3->warning('"'.$block_name.'" contains more data than expected (expected 12 or 15 bytes, found '.$block_size.' bytes)');
rlm@3 149 break;
rlm@3 150 }
rlm@3 151 $block_data .= fread($getid3->fp, $block_size);
rlm@3 152
rlm@3 153 $info_ofr_this_block['total_samples'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 6));
rlm@3 154 $offset += 6;
rlm@3 155
rlm@3 156 $info_ofr_this_block['raw']['sample_type'] = getid3_lib::LittleEndian2Int($block_data{$offset++});
rlm@3 157 $info_ofr_this_block['sample_type'] = $this->OptimFROGsampleTypeLookup($info_ofr_this_block['raw']['sample_type']);
rlm@3 158
rlm@3 159 $info_ofr_this_block['channel_config'] = getid3_lib::LittleEndian2Int($block_data{$offset++});
rlm@3 160 $info_ofr_this_block['channels'] = $info_ofr_this_block['channel_config'];
rlm@3 161
rlm@3 162 $info_ofr_this_block['sample_rate'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 4));
rlm@3 163 $offset += 4;
rlm@3 164
rlm@3 165 if ($block_size > 12) {
rlm@3 166
rlm@3 167 // OFR 4.504b or higher
rlm@3 168 $info_ofr_this_block['channels'] = $this->OptimFROGchannelConfigNumChannelsLookup($info_ofr_this_block['channel_config']);
rlm@3 169 $info_ofr_this_block['raw']['encoder_id'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 2));
rlm@3 170 $info_ofr_this_block['encoder'] = $this->OptimFROGencoderNameLookup($info_ofr_this_block['raw']['encoder_id']);
rlm@3 171 $offset += 2;
rlm@3 172
rlm@3 173 $info_ofr_this_block['raw']['compression'] = getid3_lib::LittleEndian2Int($block_data{$offset++});
rlm@3 174 $info_ofr_this_block['compression'] = $this->OptimFROGcompressionLookup($info_ofr_this_block['raw']['compression']);
rlm@3 175 $info_ofr_this_block['speedup'] = $this->OptimFROGspeedupLookup($info_ofr_this_block['raw']['compression']);
rlm@3 176
rlm@3 177 $getid3->info['audio']['encoder'] = 'OptimFROG '.$info_ofr_this_block['encoder'];
rlm@3 178 $getid3->info['audio']['encoder_options'] = '--mode '.$info_ofr_this_block['compression'];
rlm@3 179
rlm@3 180 if ((($info_ofr_this_block['raw']['encoder_id'] & 0xF0) >> 4) == 7) { // v4.507
rlm@3 181 if (preg_match('/\.ofs$/i', $getid3->filename)) {
rlm@3 182 // OptimFROG DualStream format is lossy, but as of v4.507 there is no way to tell the difference
rlm@3 183 // between lossless and lossy other than the file extension.
rlm@3 184 $getid3->info['audio']['dataformat'] = 'ofs';
rlm@3 185 $getid3->info['audio']['lossless'] = true;
rlm@3 186 }
rlm@3 187 }
rlm@3 188 }
rlm@3 189
rlm@3 190 $getid3->info['audio']['channels'] = $info_ofr_this_block['channels'];
rlm@3 191 $getid3->info['audio']['sample_rate'] = $info_ofr_this_block['sample_rate'];
rlm@3 192 $getid3->info['audio']['bits_per_sample'] = $this->OptimFROGbitsPerSampleTypeLookup($info_ofr_this_block['raw']['sample_type']);
rlm@3 193 break;
rlm@3 194
rlm@3 195
rlm@3 196 case 'COMP':
rlm@3 197 // unlike other block types, there CAN be multiple COMP blocks
rlm@3 198
rlm@3 199 $comp_data['offset'] = $block_offset;
rlm@3 200 $comp_data['size'] = $block_size;
rlm@3 201
rlm@3 202 if ($getid3->info['avdataoffset'] == 0) {
rlm@3 203 $getid3->info['avdataoffset'] = $block_offset;
rlm@3 204 }
rlm@3 205
rlm@3 206 // Only interested in first 14 bytes (only first 12 needed for v4.50 alpha), not actual audio data
rlm@3 207 $block_data .= fread($getid3->fp, 14);
rlm@3 208 fseek($getid3->fp, $block_size - 14, SEEK_CUR);
rlm@3 209
rlm@3 210 $comp_data['crc_32'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 4));
rlm@3 211 $offset += 4;
rlm@3 212
rlm@3 213 $comp_data['sample_count'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 4));
rlm@3 214 $offset += 4;
rlm@3 215
rlm@3 216 $comp_data['raw']['sample_type'] = getid3_lib::LittleEndian2Int($block_data{$offset++});
rlm@3 217 $comp_data['sample_type'] = $this->OptimFROGsampleTypeLookup($comp_data['raw']['sample_type']);
rlm@3 218
rlm@3 219 $comp_data['raw']['channel_configuration'] = getid3_lib::LittleEndian2Int($block_data{$offset++});
rlm@3 220 $comp_data['channel_configuration'] = $this->OptimFROGchannelConfigurationLookup($comp_data['raw']['channel_configuration']);
rlm@3 221
rlm@3 222 $comp_data['raw']['algorithm_id'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 2));
rlm@3 223 $offset += 2;
rlm@3 224
rlm@3 225 if ($getid3->info['ofr']['OFR ']['size'] > 12) {
rlm@3 226
rlm@3 227 // OFR 4.504b or higher
rlm@3 228 $comp_data['raw']['encoder_id'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 2));
rlm@3 229 $comp_data['encoder'] = $this->OptimFROGencoderNameLookup($comp_data['raw']['encoder_id']);
rlm@3 230 $offset += 2;
rlm@3 231 }
rlm@3 232
rlm@3 233 if ($comp_data['crc_32'] == 0x454E4F4E) {
rlm@3 234 // ASCII value of 'NONE' - placeholder value in v4.50a
rlm@3 235 $comp_data['crc_32'] = false;
rlm@3 236 }
rlm@3 237
rlm@3 238 $info_ofr_this_block[] = $comp_data;
rlm@3 239 break;
rlm@3 240
rlm@3 241 case 'HEAD':
rlm@3 242 $info_ofr_this_block['offset'] = $block_offset;
rlm@3 243 $info_ofr_this_block['size'] = $block_size;
rlm@3 244
rlm@3 245 $riff_data .= fread($getid3->fp, $block_size);
rlm@3 246 break;
rlm@3 247
rlm@3 248 case 'TAIL':
rlm@3 249 $info_ofr_this_block['offset'] = $block_offset;
rlm@3 250 $info_ofr_this_block['size'] = $block_size;
rlm@3 251
rlm@3 252 if ($block_size > 0) {
rlm@3 253 $riff_data .= fread($getid3->fp, $block_size);
rlm@3 254 }
rlm@3 255 break;
rlm@3 256
rlm@3 257 case 'RECV':
rlm@3 258 // block contains no useful meta data - simply note and skip
rlm@3 259
rlm@3 260 $info_ofr_this_block['offset'] = $block_offset;
rlm@3 261 $info_ofr_this_block['size'] = $block_size;
rlm@3 262
rlm@3 263 fseek($getid3->fp, $block_size, SEEK_CUR);
rlm@3 264 break;
rlm@3 265
rlm@3 266
rlm@3 267 case 'APET':
rlm@3 268 // APEtag v2
rlm@3 269
rlm@3 270 $info_ofr_this_block['offset'] = $block_offset;
rlm@3 271 $info_ofr_this_block['size'] = $block_size;
rlm@3 272 $getid3->warning('APEtag processing inside OptimFROG not supported in this version ('.GETID3_VERSION.') of getID3()');
rlm@3 273
rlm@3 274 fseek($getid3->fp, $block_size, SEEK_CUR);
rlm@3 275 break;
rlm@3 276
rlm@3 277
rlm@3 278 case 'MD5 ':
rlm@3 279 // APEtag v2
rlm@3 280
rlm@3 281 $info_ofr_this_block['offset'] = $block_offset;
rlm@3 282 $info_ofr_this_block['size'] = $block_size;
rlm@3 283
rlm@3 284 if ($block_size == 16) {
rlm@3 285
rlm@3 286 $info_ofr_this_block['md5_binary'] = fread($getid3->fp, $block_size);
rlm@3 287 $info_ofr_this_block['md5_string'] = getid3_lib::PrintHexBytes($info_ofr_this_block['md5_binary'], true, false, false);
rlm@3 288 $getid3->info['md5_data_source'] = $info_ofr_this_block['md5_string'];
rlm@3 289
rlm@3 290 } else {
rlm@3 291
rlm@3 292 $getid3->warning('Expecting block size of 16 in "MD5 " chunk, found '.$block_size.' instead');
rlm@3 293 fseek($getid3->fp, $block_size, SEEK_CUR);
rlm@3 294
rlm@3 295 }
rlm@3 296 break;
rlm@3 297
rlm@3 298
rlm@3 299 default:
rlm@3 300 $info_ofr_this_block['offset'] = $block_offset;
rlm@3 301 $info_ofr_this_block['size'] = $block_size;
rlm@3 302
rlm@3 303 $getid3->warning('Unhandled OptimFROG block type "'.$block_name.'" at offset '.$info_ofr_this_block['offset']);
rlm@3 304 fseek($getid3->fp, $block_size, SEEK_CUR);
rlm@3 305 break;
rlm@3 306 }
rlm@3 307 }
rlm@3 308
rlm@3 309 if (isset($getid3->info['ofr']['TAIL']['offset'])) {
rlm@3 310 $getid3->info['avdataend'] = $getid3->info['ofr']['TAIL']['offset'];
rlm@3 311 }
rlm@3 312
rlm@3 313 $getid3->info['playtime_seconds'] = (float)$getid3->info['ofr']['OFR ']['total_samples'] / ($getid3->info['audio']['channels'] * $getid3->info['audio']['sample_rate']);
rlm@3 314 $getid3->info['audio']['bitrate'] = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['playtime_seconds'];
rlm@3 315
rlm@3 316 // move the data chunk after all other chunks (if any)
rlm@3 317 // so that the RIFF parser doesn't see EOF when trying
rlm@3 318 // to skip over the data chunk
rlm@3 319
rlm@3 320 $riff_data = substr($riff_data, 0, 36).substr($riff_data, 44).substr($riff_data, 36, 8);
rlm@3 321
rlm@3 322 // Save audio info key
rlm@3 323 $saved_info_audio = $getid3->info['audio'];
rlm@3 324
rlm@3 325 // Instantiate riff module and analyze string
rlm@3 326 $riff = new getid3_riff($getid3);
rlm@3 327 $riff->AnalyzeString($riff_data);
rlm@3 328
rlm@3 329 // Restore info key
rlm@3 330 $getid3->info['audio'] = $saved_info_audio;
rlm@3 331
rlm@3 332 $getid3->info['fileformat'] = 'ofr';
rlm@3 333
rlm@3 334 return true;
rlm@3 335 }
rlm@3 336
rlm@3 337
rlm@3 338
rlm@3 339 public static function OptimFROGsampleTypeLookup($sample_type) {
rlm@3 340
rlm@3 341 static $lookup = array (
rlm@3 342 0 => 'unsigned int (8-bit)',
rlm@3 343 1 => 'signed int (8-bit)',
rlm@3 344 2 => 'unsigned int (16-bit)',
rlm@3 345 3 => 'signed int (16-bit)',
rlm@3 346 4 => 'unsigned int (24-bit)',
rlm@3 347 5 => 'signed int (24-bit)',
rlm@3 348 6 => 'unsigned int (32-bit)',
rlm@3 349 7 => 'signed int (32-bit)',
rlm@3 350 8 => 'float 0.24 (32-bit)',
rlm@3 351 9 => 'float 16.8 (32-bit)',
rlm@3 352 10 => 'float 24.0 (32-bit)'
rlm@3 353 );
rlm@3 354
rlm@3 355 return @$lookup[$sample_type];
rlm@3 356 }
rlm@3 357
rlm@3 358
rlm@3 359
rlm@3 360 public static function OptimFROGbitsPerSampleTypeLookup($sample_type) {
rlm@3 361
rlm@3 362 static $lookup = array (
rlm@3 363 0 => 8,
rlm@3 364 1 => 8,
rlm@3 365 2 => 16,
rlm@3 366 3 => 16,
rlm@3 367 4 => 24,
rlm@3 368 5 => 24,
rlm@3 369 6 => 32,
rlm@3 370 7 => 32,
rlm@3 371 8 => 32,
rlm@3 372 9 => 32,
rlm@3 373 10 => 32
rlm@3 374 );
rlm@3 375
rlm@3 376 return @$lookup[$sample_type];
rlm@3 377 }
rlm@3 378
rlm@3 379
rlm@3 380
rlm@3 381 public static function OptimFROGchannelConfigurationLookup($channel_configuration) {
rlm@3 382
rlm@3 383 static $lookup = array (
rlm@3 384 0 => 'mono',
rlm@3 385 1 => 'stereo'
rlm@3 386 );
rlm@3 387
rlm@3 388 return @$lookup[$channel_configuration];
rlm@3 389 }
rlm@3 390
rlm@3 391
rlm@3 392
rlm@3 393 public static function OptimFROGchannelConfigNumChannelsLookup($channel_configuration) {
rlm@3 394
rlm@3 395 static $lookup = array (
rlm@3 396 0 => 1,
rlm@3 397 1 => 2
rlm@3 398 );
rlm@3 399
rlm@3 400 return @$lookup[$channel_configuration];
rlm@3 401 }
rlm@3 402
rlm@3 403
rlm@3 404
rlm@3 405 public static function OptimFROGencoderNameLookup($encoder_id) {
rlm@3 406
rlm@3 407 // version = (encoderID >> 4) + 4500
rlm@3 408 // system = encoderID & 0xF
rlm@3 409
rlm@3 410 $encoder_version = number_format(((($encoder_id & 0xF0) >> 4) + 4500) / 1000, 3);
rlm@3 411 $encoder_system_id = ($encoder_id & 0x0F);
rlm@3 412
rlm@3 413 static $lookup = array (
rlm@3 414 0x00 => 'Windows console',
rlm@3 415 0x01 => 'Linux console',
rlm@3 416 0x0F => 'unknown'
rlm@3 417 );
rlm@3 418 return $encoder_version.' ('.(isset($lookup[$encoder_system_id]) ? $lookup[$encoder_system_id] : 'undefined encoder type (0x'.dechex($encoder_system_id).')').')';
rlm@3 419 }
rlm@3 420
rlm@3 421
rlm@3 422
rlm@3 423 public static function OptimFROGcompressionLookup($compression_id) {
rlm@3 424
rlm@3 425 // mode = compression >> 3
rlm@3 426 // speedup = compression & 0x07
rlm@3 427
rlm@3 428 $compression_mode_id = ($compression_id & 0xF8) >> 3;
rlm@3 429 //$compression_speed_up_id = ($compression_id & 0x07);
rlm@3 430
rlm@3 431 static $lookup = array (
rlm@3 432 0x00 => 'fast',
rlm@3 433 0x01 => 'normal',
rlm@3 434 0x02 => 'high',
rlm@3 435 0x03 => 'extra', // extranew (some versions)
rlm@3 436 0x04 => 'best', // bestnew (some versions)
rlm@3 437 0x05 => 'ultra',
rlm@3 438 0x06 => 'insane',
rlm@3 439 0x07 => 'highnew',
rlm@3 440 0x08 => 'extranew',
rlm@3 441 0x09 => 'bestnew'
rlm@3 442 );
rlm@3 443 return (isset($lookup[$compression_mode_id]) ? $lookup[$compression_mode_id] : 'undefined mode (0x'.str_pad(dechex($compression_mode_id), 2, '0', STR_PAD_LEFT).')');
rlm@3 444 }
rlm@3 445
rlm@3 446
rlm@3 447
rlm@3 448 public static function OptimFROGspeedupLookup($compression_id) {
rlm@3 449
rlm@3 450 // mode = compression >> 3
rlm@3 451 // speedup = compression & 0x07
rlm@3 452
rlm@3 453 //$compression_mode_id = ($compression_id & 0xF8) >> 3;
rlm@3 454 $compression_speed_up_id = ($compression_id & 0x07);
rlm@3 455
rlm@3 456 static $lookup = array (
rlm@3 457 0x00 => '1x',
rlm@3 458 0x01 => '2x',
rlm@3 459 0x02 => '4x'
rlm@3 460 );
rlm@3 461
rlm@3 462 return (isset($lookup[$compression_speed_up_id]) ? $lookup[$compression_speed_up_id] : 'undefined mode (0x'.dechex($compression_speed_up_id));
rlm@3 463 }
rlm@3 464
rlm@3 465 }
rlm@3 466
rlm@3 467
rlm@3 468 ?>