23 $info = &$this->getid3->info;
25 $info[
'fileformat'] =
'ofr';
26 $info[
'audio'][
'dataformat'] =
'ofr';
27 $info[
'audio'][
'bitrate_mode'] =
'vbr';
28 $info[
'audio'][
'lossless'] =
true;
31 $OFRheader = $this->
fread(8);
32 if (substr($OFRheader, 0, 5) ==
'*RIFF') {
36 } elseif (substr($OFRheader, 0, 3) ==
'OFR') {
43 unset(
$info[
'fileformat']);
51 $info = &$this->getid3->info;
53 $OptimFROGheaderData = $this->
fread(45);
54 $info[
'avdataoffset'] = 45;
57 $OptimFROGencoderVersion_major = floor($OptimFROGencoderVersion_raw / 10);
58 $OptimFROGencoderVersion_minor = $OptimFROGencoderVersion_raw - ($OptimFROGencoderVersion_major * 10);
59 $RIFFdata = substr($OptimFROGheaderData, 1, 44);
63 if ($OrignalRIFFheaderSize > $OrignalRIFFdataSize) {
64 $info[
'avdataend'] -= ($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
66 $RIFFdata .= $this->
fread($OrignalRIFFheaderSize - $OrignalRIFFdataSize);
72 $RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8);
74 $getid3_temp =
new getID3();
75 $getid3_temp->openfile($this->getid3->filename);
76 $getid3_temp->info[
'avdataoffset'] =
$info[
'avdataoffset'];
77 $getid3_temp->info[
'avdataend'] =
$info[
'avdataend'];
79 $getid3_riff->ParseRIFFdata($RIFFdata);
80 $info[
'riff'] = $getid3_temp->info[
'riff'];
82 $info[
'audio'][
'encoder'] =
'OptimFROG '.$OptimFROGencoderVersion_major.
'.'.$OptimFROGencoderVersion_minor;
83 $info[
'audio'][
'channels'] =
$info[
'riff'][
'audio'][0][
'channels'];
84 $info[
'audio'][
'sample_rate'] =
$info[
'riff'][
'audio'][0][
'sample_rate'];
85 $info[
'audio'][
'bits_per_sample'] =
$info[
'riff'][
'audio'][0][
'bits_per_sample'];
86 $info[
'playtime_seconds'] = $OrignalRIFFdataSize / (
$info[
'audio'][
'channels'] *
$info[
'audio'][
'sample_rate'] * (
$info[
'audio'][
'bits_per_sample'] / 8));
87 $info[
'audio'][
'bitrate'] = ((
$info[
'avdataend'] -
$info[
'avdataoffset']) * 8) /
$info[
'playtime_seconds'];
89 unset($getid3_riff, $getid3_temp, $RIFFdata);
98 $info = &$this->getid3->info;
101 while (!
feof($this->getid3->fp) && ($this->ftell() <
$info[
'avdataend'])) {
102 $BlockOffset = $this->
ftell();
103 $BlockData = $this->
fread(8);
105 $BlockName = substr($BlockData, 0, 4);
108 if ($BlockName ==
'OFRX') {
111 if (!isset(
$info[
'ofr'][$BlockName])) {
112 $info[
'ofr'][$BlockName] = array();
114 $thisfile_ofr_thisblock = &
$info[
'ofr'][$BlockName];
116 switch ($BlockName) {
120 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
121 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
123 $info[
'audio'][
'encoder'] =
'OptimFROG 4.50 alpha';
124 switch ($BlockSize) {
131 $this->
warning(
'"'.$BlockName.
'" contains more data than expected (expected 12 or 15 bytes, found '.$BlockSize.
' bytes)');
134 $BlockData .= $this->
fread($BlockSize);
139 $thisfile_ofr_thisblock[
'sample_type'] = $this->
OptimFROGsampleTypeLookup($thisfile_ofr_thisblock[
'raw'][
'sample_type']);
142 $thisfile_ofr_thisblock[
'channels'] = $thisfile_ofr_thisblock[
'channel_config'];
147 if ($BlockSize > 12) {
156 $thisfile_ofr_thisblock[
'speedup'] = $this->
OptimFROGspeedupLookup($thisfile_ofr_thisblock[
'raw'][
'compression']);
159 $info[
'audio'][
'encoder'] =
'OptimFROG '.$thisfile_ofr_thisblock[
'encoder'];
160 $info[
'audio'][
'encoder_options'] =
'--mode '.$thisfile_ofr_thisblock[
'compression'];
162 if ((($thisfile_ofr_thisblock[
'raw'][
'encoder_id'] & 0xF0) >> 4) == 7) {
166 $info[
'audio'][
'dataformat'] =
'ofs';
167 $info[
'audio'][
'lossless'] =
true;
173 $info[
'audio'][
'channels'] = $thisfile_ofr_thisblock[
'channels'];
174 $info[
'audio'][
'sample_rate'] = $thisfile_ofr_thisblock[
'sample_rate'];
182 $COMPdata[
'offset'] = $BlockOffset;
183 $COMPdata[
'size'] = $BlockSize;
185 if (
$info[
'avdataoffset'] == 0) {
186 $info[
'avdataoffset'] = $BlockOffset;
190 $BlockData .= $this->
fread(14);
191 $this->
fseek($BlockSize - 14, SEEK_CUR);
207 if (
$info[
'ofr'][
'OFR '][
'size'] > 12) {
216 if ($COMPdata[
'crc_32'] == 0x454E4F4E) {
218 $COMPdata[
'crc_32'] =
false;
221 $thisfile_ofr_thisblock[] = $COMPdata;
225 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
226 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
228 $RIFFdata .= $this->
fread($BlockSize);
232 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
233 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
235 if ($BlockSize > 0) {
236 $RIFFdata .= $this->
fread($BlockSize);
243 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
244 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
246 $this->
fseek($BlockSize, SEEK_CUR);
253 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
254 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
255 $this->
warning(
'APEtag processing inside OptimFROG not supported in this version ('.$this->getid3->version().
') of getID3()');
257 $this->
fseek($BlockSize, SEEK_CUR);
264 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
265 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
267 if ($BlockSize == 16) {
269 $thisfile_ofr_thisblock[
'md5_binary'] = $this->
fread($BlockSize);
270 $thisfile_ofr_thisblock[
'md5_string'] =
getid3_lib::PrintHexBytes($thisfile_ofr_thisblock[
'md5_binary'],
true,
false,
false);
271 $info[
'md5_data_source'] = $thisfile_ofr_thisblock[
'md5_string'];
275 $this->
warning(
'Expecting block size of 16 in "MD5 " chunk, found '.$BlockSize.
' instead');
276 $this->
fseek($BlockSize, SEEK_CUR);
283 $thisfile_ofr_thisblock[
'offset'] = $BlockOffset;
284 $thisfile_ofr_thisblock[
'size'] = $BlockSize;
286 $this->
warning(
'Unhandled OptimFROG block type "'.$BlockName.
'" at offset '.$thisfile_ofr_thisblock[
'offset']);
287 $this->
fseek($BlockSize, SEEK_CUR);
291 if (isset(
$info[
'ofr'][
'TAIL'][
'offset'])) {
292 $info[
'avdataend'] =
$info[
'ofr'][
'TAIL'][
'offset'];
295 $info[
'playtime_seconds'] = (float)
$info[
'ofr'][
'OFR '][
'total_samples'] / (
$info[
'audio'][
'channels'] *
$info[
'audio'][
'sample_rate']);
296 $info[
'audio'][
'bitrate'] = (($info[
'avdataend'] - $info[
'avdataoffset']) * 8) / $info[
'playtime_seconds'];
301 $RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8);
303 $getid3_temp =
new getID3();
304 $getid3_temp->openfile($this->getid3->filename);
305 $getid3_temp->info[
'avdataoffset'] = $info[
'avdataoffset'];
306 $getid3_temp->info[
'avdataend'] = $info[
'avdataend'];
308 $getid3_riff->ParseRIFFdata($RIFFdata);
309 $info[
'riff'] = $getid3_temp->info[
'riff'];
311 unset($getid3_riff, $getid3_temp, $RIFFdata);
318 static $OptimFROGsampleTypeLookup = array(
319 0 =>
'unsigned int (8-bit)',
320 1 =>
'signed int (8-bit)',
321 2 =>
'unsigned int (16-bit)',
322 3 =>
'signed int (16-bit)',
323 4 =>
'unsigned int (24-bit)',
324 5 =>
'signed int (24-bit)',
325 6 =>
'unsigned int (32-bit)',
326 7 =>
'signed int (32-bit)',
327 8 =>
'float 0.24 (32-bit)',
328 9 =>
'float 16.8 (32-bit)',
329 10 =>
'float 24.0 (32-bit)' 331 return (isset($OptimFROGsampleTypeLookup[$SampleType]) ? $OptimFROGsampleTypeLookup[$SampleType] :
false);
335 static $OptimFROGbitsPerSampleTypeLookup = array(
348 return (isset($OptimFROGbitsPerSampleTypeLookup[$SampleType]) ? $OptimFROGbitsPerSampleTypeLookup[$SampleType] :
false);
352 static $OptimFROGchannelConfigurationLookup = array(
356 return (isset($OptimFROGchannelConfigurationLookup[$ChannelConfiguration]) ? $OptimFROGchannelConfigurationLookup[$ChannelConfiguration] :
false);
360 static $OptimFROGchannelConfigNumChannelsLookup = array(
364 return (isset($OptimFROGchannelConfigNumChannelsLookup[$ChannelConfiguration]) ? $OptimFROGchannelConfigNumChannelsLookup[$ChannelConfiguration] :
false);
379 $EncoderVersion = number_format(((($EncoderID & 0xF0) >> 4) + 4500) / 1000, 3);
380 $EncoderSystemID = ($EncoderID & 0x0F);
382 static $OptimFROGencoderSystemLookup = array(
383 0x00 =>
'Windows console',
384 0x01 =>
'Linux console',
387 return $EncoderVersion.
' ('.(isset($OptimFROGencoderSystemLookup[$EncoderSystemID]) ? $OptimFROGencoderSystemLookup[$EncoderSystemID] :
'undefined encoder type (0x'.dechex($EncoderSystemID).
')').
')';
394 $CompressionModeID = ($CompressionID & 0xF8) >> 3;
397 static $OptimFROGencoderModeLookup = array(
409 return (isset($OptimFROGencoderModeLookup[$CompressionModeID]) ? $OptimFROGencoderModeLookup[$CompressionModeID] :
'undefined mode (0x'.str_pad(dechex($CompressionModeID), 2,
'0', STR_PAD_LEFT).
')');
417 $CompressionSpeedupID = ($CompressionID & 0x07);
419 static $OptimFROGencoderSpeedupLookup = array(
424 return (isset($OptimFROGencoderSpeedupLookup[$CompressionSpeedupID]) ? $OptimFROGencoderSpeedupLookup[$CompressionSpeedupID] :
'undefined mode (0x'.dechex($CompressionSpeedupID));
static fileextension($filename, $numextensions=1)
static OptimFROGspeedupLookup($CompressionID)
static OptimFROGencoderNameLookup($EncoderID)
static OptimFROGbitsPerSampleTypeLookup($SampleType)
static LittleEndian2Int($byteword, $signed=false)
static OptimFROGchannelConfigurationLookup($ChannelConfiguration)
static IncludeDependency($filename, $sourcefile, $DieOnFailure=false)
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
static OptimFROGcompressionLookup($CompressionID)
static OptimFROGchannelConfigNumChannelsLookup($ChannelConfiguration)
fseek($bytes, $whence=SEEK_SET)
static OptimFROGsampleTypeLookup($SampleType)