コード例 #1
0
ファイル: Bonk.php プロジェクト: Nattpyre/rocketfiles
 /**
  * @param type $BonkTagName
  */
 public function HandleBonkTags($BonkTagName)
 {
     $info =& $this->getid3->info;
     switch ($BonkTagName) {
         case 'BONK':
             // shortcut
             $thisfile_bonk_BONK =& $info['bonk']['BONK'];
             $BonkData = "" . 'BONK' . fread($this->getid3->fp, 17);
             $thisfile_bonk_BONK['version'] = Helper::LittleEndian2Int(substr($BonkData, 5, 1));
             $thisfile_bonk_BONK['number_samples'] = Helper::LittleEndian2Int(substr($BonkData, 6, 4));
             $thisfile_bonk_BONK['sample_rate'] = Helper::LittleEndian2Int(substr($BonkData, 10, 4));
             $thisfile_bonk_BONK['channels'] = Helper::LittleEndian2Int(substr($BonkData, 14, 1));
             $thisfile_bonk_BONK['lossless'] = (bool) Helper::LittleEndian2Int(substr($BonkData, 15, 1));
             $thisfile_bonk_BONK['joint_stereo'] = (bool) Helper::LittleEndian2Int(substr($BonkData, 16, 1));
             $thisfile_bonk_BONK['number_taps'] = Helper::LittleEndian2Int(substr($BonkData, 17, 2));
             $thisfile_bonk_BONK['downsampling_ratio'] = Helper::LittleEndian2Int(substr($BonkData, 19, 1));
             $thisfile_bonk_BONK['samples_per_packet'] = Helper::LittleEndian2Int(substr($BonkData, 20, 2));
             $info['avdataoffset'] = $thisfile_bonk_BONK['offset'] + 5 + 17;
             $info['avdataend'] = $thisfile_bonk_BONK['offset'] + $thisfile_bonk_BONK['size'];
             $info['fileformat'] = 'bonk';
             $info['audio']['dataformat'] = 'bonk';
             $info['audio']['bitrate_mode'] = 'vbr';
             // assumed
             $info['audio']['channels'] = $thisfile_bonk_BONK['channels'];
             $info['audio']['sample_rate'] = $thisfile_bonk_BONK['sample_rate'];
             $info['audio']['channelmode'] = $thisfile_bonk_BONK['joint_stereo'] ? 'joint stereo' : 'stereo';
             $info['audio']['lossless'] = $thisfile_bonk_BONK['lossless'];
             $info['audio']['codec'] = 'bonk';
             $info['playtime_seconds'] = $thisfile_bonk_BONK['number_samples'] / ($thisfile_bonk_BONK['sample_rate'] * $thisfile_bonk_BONK['channels']);
             if ($info['playtime_seconds'] > 0) {
                 $info['audio']['bitrate'] = ($info['bonk']['dataend'] - $info['bonk']['dataoffset']) * 8 / $info['playtime_seconds'];
             }
             break;
         case 'INFO':
             // shortcut
             $thisfile_bonk_INFO =& $info['bonk']['INFO'];
             $thisfile_bonk_INFO['version'] = Helper::LittleEndian2Int(fread($this->getid3->fp, 1));
             $thisfile_bonk_INFO['entries_count'] = 0;
             $NextInfoDataPair = fread($this->getid3->fp, 5);
             if (!$this->BonkIsValidTagName(substr($NextInfoDataPair, 1, 4))) {
                 while (!feof($this->getid3->fp)) {
                     //$CurrentSeekInfo['offset']  = GetId3_lib::LittleEndian2Int(substr($NextInfoDataPair, 0, 4));
                     //$CurrentSeekInfo['nextbit'] = GetId3_lib::LittleEndian2Int(substr($NextInfoDataPair, 4, 1));
                     //$thisfile_bonk_INFO[] = $CurrentSeekInfo;
                     $NextInfoDataPair = fread($this->getid3->fp, 5);
                     if ($this->BonkIsValidTagName(substr($NextInfoDataPair, 1, 4))) {
                         fseek($this->getid3->fp, -5, SEEK_CUR);
                         break;
                     }
                     ++$thisfile_bonk_INFO['entries_count'];
                 }
             }
             break;
         case 'META':
             $BonkData = "" . 'META' . fread($this->getid3->fp, $info['bonk']['META']['size'] - 5);
             $info['bonk']['META']['version'] = Helper::LittleEndian2Int(substr($BonkData, 5, 1));
             $MetaTagEntries = floor((strlen($BonkData) - 8 - 6) / 8);
             // BonkData - xxxxmeta - ØMETA
             $offset = 6;
             for ($i = 0; $i < $MetaTagEntries; ++$i) {
                 $MetaEntryTagName = substr($BonkData, $offset, 4);
                 $offset += 4;
                 $MetaEntryTagOffset = Helper::LittleEndian2Int(substr($BonkData, $offset, 4));
                 $offset += 4;
                 $info['bonk']['META']['tags'][$MetaEntryTagName] = $MetaEntryTagOffset;
             }
             break;
         case ' ID3':
             $info['audio']['encoder'] = 'Extended BONK v0.9+';
             // ID3v2 checking is optional
             if (class_exists('Helpers\\GetId3\\Module\\Tag\\Id3v2')) {
                 $getid3_temp = new GetId3Core();
                 $getid3_temp->openfile($this->getid3->filename);
                 $getid3_id3v2 = new Id3v2($getid3_temp);
                 $getid3_id3v2->StartingOffset = $info['bonk'][' ID3']['offset'] + 2;
                 $info['bonk'][' ID3']['valid'] = $getid3_id3v2->analyze();
                 if ($info['bonk'][' ID3']['valid']) {
                     $info['id3v2'] = $getid3_temp->info['id3v2'];
                 }
                 unset($getid3_temp, $getid3_id3v2);
             }
             break;
         default:
             $info['warning'][] = 'Unexpected Bonk tag "' . $BonkTagName . '" at offset ' . $info['bonk'][$BonkTagName]['offset'];
             break;
     }
 }
コード例 #2
0
ファイル: Asf.php プロジェクト: Nattpyre/rocketfiles
 /**
  * @return bool
  */
 public function analyze()
 {
     $info =& $this->getid3->info;
     // Shortcuts
     $thisfile_audio =& $info['audio'];
     $thisfile_video =& $info['video'];
     $info['asf'] = array();
     $thisfile_asf =& $info['asf'];
     $thisfile_asf['comments'] = array();
     $thisfile_asf_comments =& $thisfile_asf['comments'];
     $thisfile_asf['header_object'] = array();
     $thisfile_asf_headerobject =& $thisfile_asf['header_object'];
     // ASF structure:
     // * Header Object [required]
     //   * File Properties Object [required]   (global file attributes)
     //   * Stream Properties Object [required] (defines media stream & characteristics)
     //   * Header Extension Object [required]  (additional functionality)
     //   * Content Description Object          (bibliographic information)
     //   * Script Command Object               (commands for during playback)
     //   * Marker Object                       (named jumped points within the file)
     // * Data Object [required]
     //   * Data Packets
     // * Index Object
     // Header Object: (mandatory, one only)
     // Field Name                   Field Type   Size (bits)
     // Object ID                    GUID         128             // GUID for header object - GETID3_ASF_Header_Object
     // Object Size                  QWORD        64              // size of header object, including 30 bytes of Header Object header
     // Number of Header Objects     DWORD        32              // number of objects in header object
     // Reserved1                    BYTE         8               // hardcoded: 0x01
     // Reserved2                    BYTE         8               // hardcoded: 0x02
     $info['fileformat'] = 'asf';
     fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     $HeaderObjectData = fread($this->getid3->fp, 30);
     $thisfile_asf_headerobject['objectid'] = substr($HeaderObjectData, 0, 16);
     $thisfile_asf_headerobject['objectid_guid'] = self::BytestringToGUID($thisfile_asf_headerobject['objectid']);
     if ($thisfile_asf_headerobject['objectid'] != self::$GETID3_ASF_Header_Object) {
         $info['warning'][] = 'ASF header GUID {' . self::BytestringToGUID($thisfile_asf_headerobject['objectid']) . '} does not match expected "GETID3_ASF_Header_Object" GUID {' . self::BytestringToGUID(self::$GETID3_ASF_Header_Object) . '}';
         unset($info['fileformat']);
         unset($info['asf']);
         return false;
     }
     $thisfile_asf_headerobject['objectsize'] = Helper::LittleEndian2Int(substr($HeaderObjectData, 16, 8));
     $thisfile_asf_headerobject['headerobjects'] = Helper::LittleEndian2Int(substr($HeaderObjectData, 24, 4));
     $thisfile_asf_headerobject['reserved1'] = Helper::LittleEndian2Int(substr($HeaderObjectData, 28, 1));
     $thisfile_asf_headerobject['reserved2'] = Helper::LittleEndian2Int(substr($HeaderObjectData, 29, 1));
     $NextObjectOffset = ftell($this->getid3->fp);
     $ASFHeaderData = fread($this->getid3->fp, $thisfile_asf_headerobject['objectsize'] - 30);
     $offset = 0;
     for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; ++$HeaderObjectsCounter) {
         $NextObjectGUID = substr($ASFHeaderData, $offset, 16);
         $offset += 16;
         $NextObjectGUIDtext = self::BytestringToGUID($NextObjectGUID);
         $NextObjectSize = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
         $offset += 8;
         switch ($NextObjectGUID) {
             case self::$GETID3_ASF_File_Properties_Object:
                 // File Properties Object: (mandatory, one only)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for file properties object - GETID3_ASF_File_Properties_Object
                 // Object Size                  QWORD        64              // size of file properties object, including 104 bytes of File Properties Object header
                 // File ID                      GUID         128             // unique ID - identical to File ID in Data Object
                 // File Size                    QWORD        64              // entire file in bytes. Invalid if Broadcast Flag == 1
                 // Creation Date                QWORD        64              // date & time of file creation. Maybe invalid if Broadcast Flag == 1
                 // Data Packets Count           QWORD        64              // number of data packets in Data Object. Invalid if Broadcast Flag == 1
                 // Play Duration                QWORD        64              // playtime, in 100-nanosecond units. Invalid if Broadcast Flag == 1
                 // Send Duration                QWORD        64              // time needed to send file, in 100-nanosecond units. Players can ignore this value. Invalid if Broadcast Flag == 1
                 // Preroll                      QWORD        64              // time to buffer data before starting to play file, in 1-millisecond units. If <> 0, PlayDuration and PresentationTime have been offset by this amount
                 // Flags                        DWORD        32              //
                 // * Broadcast Flag             bits         1  (0x01)       // file is currently being written, some header values are invalid
                 // * Seekable Flag              bits         1  (0x02)       // is file seekable
                 // * Reserved                   bits         30 (0xFFFFFFFC) // reserved - set to zero
                 // Minimum Data Packet Size     DWORD        32              // in bytes. should be same as Maximum Data Packet Size. Invalid if Broadcast Flag == 1
                 // Maximum Data Packet Size     DWORD        32              // in bytes. should be same as Minimum Data Packet Size. Invalid if Broadcast Flag == 1
                 // Maximum Bitrate              DWORD        32              // maximum instantaneous bitrate in bits per second for entire file, including all data streams and ASF overhead
                 // shortcut
                 $thisfile_asf['file_properties_object'] = array();
                 $thisfile_asf_filepropertiesobject =& $thisfile_asf['file_properties_object'];
                 $thisfile_asf_filepropertiesobject['offset'] = $NextObjectOffset + $offset;
                 $thisfile_asf_filepropertiesobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_filepropertiesobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_filepropertiesobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_filepropertiesobject['fileid'] = substr($ASFHeaderData, $offset, 16);
                 $offset += 16;
                 $thisfile_asf_filepropertiesobject['fileid_guid'] = self::BytestringToGUID($thisfile_asf_filepropertiesobject['fileid']);
                 $thisfile_asf_filepropertiesobject['filesize'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                 $offset += 8;
                 $thisfile_asf_filepropertiesobject['creation_date'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                 $thisfile_asf_filepropertiesobject['creation_date_unix'] = self::FILETIMEtoUNIXtime($thisfile_asf_filepropertiesobject['creation_date']);
                 $offset += 8;
                 $thisfile_asf_filepropertiesobject['data_packets'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                 $offset += 8;
                 $thisfile_asf_filepropertiesobject['play_duration'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                 $offset += 8;
                 $thisfile_asf_filepropertiesobject['send_duration'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                 $offset += 8;
                 $thisfile_asf_filepropertiesobject['preroll'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                 $offset += 8;
                 $thisfile_asf_filepropertiesobject['flags_raw'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                 $offset += 4;
                 $thisfile_asf_filepropertiesobject['flags']['broadcast'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x1);
                 $thisfile_asf_filepropertiesobject['flags']['seekable'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x2);
                 $thisfile_asf_filepropertiesobject['min_packet_size'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                 $offset += 4;
                 $thisfile_asf_filepropertiesobject['max_packet_size'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                 $offset += 4;
                 $thisfile_asf_filepropertiesobject['max_bitrate'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                 $offset += 4;
                 if ($thisfile_asf_filepropertiesobject['flags']['broadcast']) {
                     // broadcast flag is set, some values invalid
                     unset($thisfile_asf_filepropertiesobject['filesize']);
                     unset($thisfile_asf_filepropertiesobject['data_packets']);
                     unset($thisfile_asf_filepropertiesobject['play_duration']);
                     unset($thisfile_asf_filepropertiesobject['send_duration']);
                     unset($thisfile_asf_filepropertiesobject['min_packet_size']);
                     unset($thisfile_asf_filepropertiesobject['max_packet_size']);
                 } else {
                     // broadcast flag NOT set, perform calculations
                     $info['playtime_seconds'] = $thisfile_asf_filepropertiesobject['play_duration'] / 10000000 - $thisfile_asf_filepropertiesobject['preroll'] / 1000;
                     //$info['bitrate'] = $thisfile_asf_filepropertiesobject['max_bitrate'];
                     $info['bitrate'] = (isset($thisfile_asf_filepropertiesobject['filesize']) ? $thisfile_asf_filepropertiesobject['filesize'] : $info['filesize']) * 8 / $info['playtime_seconds'];
                 }
                 break;
             case self::$GETID3_ASF_Stream_Properties_Object:
                 // Stream Properties Object: (mandatory, one per media stream)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for stream properties object - GETID3_ASF_Stream_Properties_Object
                 // Object Size                  QWORD        64              // size of stream properties object, including 78 bytes of Stream Properties Object header
                 // Stream Type                  GUID         128             // GETID3_ASF_Audio_Media, GETID3_ASF_Video_Media or GETID3_ASF_Command_Media
                 // Error Correction Type        GUID         128             // GETID3_ASF_Audio_Spread for audio-only streams, GETID3_ASF_No_Error_Correction for other stream types
                 // Time Offset                  QWORD        64              // 100-nanosecond units. typically zero. added to all timestamps of samples in the stream
                 // Type-Specific Data Length    DWORD        32              // number of bytes for Type-Specific Data field
                 // Error Correction Data Length DWORD        32              // number of bytes for Error Correction Data field
                 // Flags                        WORD         16              //
                 // * Stream Number              bits         7 (0x007F)      // number of this stream.  1 <= valid <= 127
                 // * Reserved                   bits         8 (0x7F80)      // reserved - set to zero
                 // * Encrypted Content Flag     bits         1 (0x8000)      // stream contents encrypted if set
                 // Reserved                     DWORD        32              // reserved - set to zero
                 // Type-Specific Data           BYTESTREAM   variable        // type-specific format data, depending on value of Stream Type
                 // Error Correction Data        BYTESTREAM   variable        // error-correction-specific format data, depending on value of Error Correct Type
                 // There is one self::$GETID3_ASF_Stream_Properties_Object for each stream (audio, video) but the
                 // stream number isn't known until halfway through decoding the structure, hence it
                 // it is decoded to a temporary variable and then stuck in the appropriate index later
                 $StreamPropertiesObjectData = array();
                 $StreamPropertiesObjectData['offset'] = $NextObjectOffset + $offset;
                 $StreamPropertiesObjectData['objectid'] = $NextObjectGUID;
                 $StreamPropertiesObjectData['objectid_guid'] = $NextObjectGUIDtext;
                 $StreamPropertiesObjectData['objectsize'] = $NextObjectSize;
                 $StreamPropertiesObjectData['stream_type'] = substr($ASFHeaderData, $offset, 16);
                 $offset += 16;
                 $StreamPropertiesObjectData['stream_type_guid'] = self::BytestringToGUID($StreamPropertiesObjectData['stream_type']);
                 $StreamPropertiesObjectData['error_correct_type'] = substr($ASFHeaderData, $offset, 16);
                 $offset += 16;
                 $StreamPropertiesObjectData['error_correct_guid'] = self::BytestringToGUID($StreamPropertiesObjectData['error_correct_type']);
                 $StreamPropertiesObjectData['time_offset'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                 $offset += 8;
                 $StreamPropertiesObjectData['type_data_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                 $offset += 4;
                 $StreamPropertiesObjectData['error_data_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                 $offset += 4;
                 $StreamPropertiesObjectData['flags_raw'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 $StreamPropertiesObjectStreamNumber = $StreamPropertiesObjectData['flags_raw'] & 0x7f;
                 $StreamPropertiesObjectData['flags']['encrypted'] = (bool) ($StreamPropertiesObjectData['flags_raw'] & 0x8000);
                 $offset += 4;
                 // reserved - DWORD
                 $StreamPropertiesObjectData['type_specific_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['type_data_length']);
                 $offset += $StreamPropertiesObjectData['type_data_length'];
                 $StreamPropertiesObjectData['error_correct_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['error_data_length']);
                 $offset += $StreamPropertiesObjectData['error_data_length'];
                 switch ($StreamPropertiesObjectData['stream_type']) {
                     case self::$GETID3_ASF_Audio_Media:
                         $thisfile_audio['dataformat'] = !empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf';
                         $thisfile_audio['bitrate_mode'] = !empty($thisfile_audio['bitrate_mode']) ? $thisfile_audio['bitrate_mode'] : 'cbr';
                         $audiodata = Riff::RIFFparseWAVEFORMATex(substr($StreamPropertiesObjectData['type_specific_data'], 0, 16));
                         unset($audiodata['raw']);
                         $thisfile_audio = Helper::array_merge_noclobber($audiodata, $thisfile_audio);
                         break;
                     case self::$GETID3_ASF_Video_Media:
                         $thisfile_video['dataformat'] = !empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf';
                         $thisfile_video['bitrate_mode'] = !empty($thisfile_video['bitrate_mode']) ? $thisfile_video['bitrate_mode'] : 'cbr';
                         break;
                     case self::$GETID3_ASF_Command_Media:
                     default:
                         // do nothing
                         break;
                 }
                 $thisfile_asf['stream_properties_object'][$StreamPropertiesObjectStreamNumber] = $StreamPropertiesObjectData;
                 unset($StreamPropertiesObjectData);
                 // clear for next stream, if any
                 break;
             case self::$GETID3_ASF_Header_Extension_Object:
                 // Header Extension Object: (mandatory, one only)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for Header Extension object - GETID3_ASF_Header_Extension_Object
                 // Object Size                  QWORD        64              // size of Header Extension object, including 46 bytes of Header Extension Object header
                 // Reserved Field 1             GUID         128             // hardcoded: GETID3_ASF_Reserved_1
                 // Reserved Field 2             WORD         16              // hardcoded: 0x00000006
                 // Header Extension Data Size   DWORD        32              // in bytes. valid: 0, or > 24. equals object size minus 46
                 // Header Extension Data        BYTESTREAM   variable        // array of zero or more extended header objects
                 // shortcut
                 $thisfile_asf['header_extension_object'] = array();
                 $thisfile_asf_headerextensionobject =& $thisfile_asf['header_extension_object'];
                 $thisfile_asf_headerextensionobject['offset'] = $NextObjectOffset + $offset;
                 $thisfile_asf_headerextensionobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_headerextensionobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_headerextensionobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_headerextensionobject['reserved_1'] = substr($ASFHeaderData, $offset, 16);
                 $offset += 16;
                 $thisfile_asf_headerextensionobject['reserved_1_guid'] = self::BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']);
                 if ($thisfile_asf_headerextensionobject['reserved_1'] != self::$GETID3_ASF_Reserved_1) {
                     $info['warning'][] = 'header_extension_object.reserved_1 GUID (' . self::BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']) . ') does not match expected "GETID3_ASF_Reserved_1" GUID (' . self::BytestringToGUID(self::$GETID3_ASF_Reserved_1) . ')';
                     //return false;
                     break;
                 }
                 $thisfile_asf_headerextensionobject['reserved_2'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 if ($thisfile_asf_headerextensionobject['reserved_2'] != 6) {
                     $info['warning'][] = 'header_extension_object.reserved_2 (' . Helper::PrintHexBytes($thisfile_asf_headerextensionobject['reserved_2']) . ') does not match expected value of "6"';
                     //return false;
                     break;
                 }
                 $thisfile_asf_headerextensionobject['extension_data_size'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                 $offset += 4;
                 $thisfile_asf_headerextensionobject['extension_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_headerextensionobject['extension_data_size']);
                 $unhandled_sections = 0;
                 $thisfile_asf_headerextensionobject['extension_data_parsed'] = $this->ASF_HeaderExtensionObjectDataParse($thisfile_asf_headerextensionobject['extension_data'], $unhandled_sections);
                 if ($unhandled_sections === 0) {
                     unset($thisfile_asf_headerextensionobject['extension_data']);
                 }
                 $offset += $thisfile_asf_headerextensionobject['extension_data_size'];
                 break;
             case self::$GETID3_ASF_Codec_List_Object:
                 // Codec List Object: (optional, one only)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for Codec List object - GETID3_ASF_Codec_List_Object
                 // Object Size                  QWORD        64              // size of Codec List object, including 44 bytes of Codec List Object header
                 // Reserved                     GUID         128             // hardcoded: 86D15241-311D-11D0-A3A4-00A0C90348F6
                 // Codec Entries Count          DWORD        32              // number of entries in Codec Entries array
                 // Codec Entries                array of:    variable        //
                 // * Type                       WORD         16              // 0x0001 = Video Codec, 0x0002 = Audio Codec, 0xFFFF = Unknown Codec
                 // * Codec Name Length          WORD         16              // number of Unicode characters stored in the Codec Name field
                 // * Codec Name                 WCHAR        variable        // array of Unicode characters - name of codec used to create the content
                 // * Codec Description Length   WORD         16              // number of Unicode characters stored in the Codec Description field
                 // * Codec Description          WCHAR        variable        // array of Unicode characters - description of format used to create the content
                 // * Codec Information Length   WORD         16              // number of Unicode characters stored in the Codec Information field
                 // * Codec Information          BYTESTREAM   variable        // opaque array of information bytes about the codec used to create the content
                 // shortcut
                 $thisfile_asf['codec_list_object'] = array();
                 $thisfile_asf_codeclistobject =& $thisfile_asf['codec_list_object'];
                 $thisfile_asf_codeclistobject['offset'] = $NextObjectOffset + $offset;
                 $thisfile_asf_codeclistobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_codeclistobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_codeclistobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_codeclistobject['reserved'] = substr($ASFHeaderData, $offset, 16);
                 $offset += 16;
                 $thisfile_asf_codeclistobject['reserved_guid'] = self::BytestringToGUID($thisfile_asf_codeclistobject['reserved']);
                 if ($thisfile_asf_codeclistobject['reserved'] != self::GUIDtoBytestring('86D15241-311D-11D0-A3A4-00A0C90348F6')) {
                     $info['warning'][] = 'codec_list_object.reserved GUID {' . self::BytestringToGUID($thisfile_asf_codeclistobject['reserved']) . '} does not match expected "GETID3_ASF_Reserved_1" GUID {86D15241-311D-11D0-A3A4-00A0C90348F6}';
                     //return false;
                     break;
                 }
                 $thisfile_asf_codeclistobject['codec_entries_count'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                 $offset += 4;
                 for ($CodecEntryCounter = 0; $CodecEntryCounter < $thisfile_asf_codeclistobject['codec_entries_count']; ++$CodecEntryCounter) {
                     // shortcut
                     $thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter] = array();
                     $thisfile_asf_codeclistobject_codecentries_current =& $thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter];
                     $thisfile_asf_codeclistobject_codecentries_current['type_raw'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                     $offset += 2;
                     $thisfile_asf_codeclistobject_codecentries_current['type'] = $this->ASFCodecListObjectTypeLookup($thisfile_asf_codeclistobject_codecentries_current['type_raw']);
                     $CodecNameLength = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2;
                     // 2 bytes per character
                     $offset += 2;
                     $thisfile_asf_codeclistobject_codecentries_current['name'] = substr($ASFHeaderData, $offset, $CodecNameLength);
                     $offset += $CodecNameLength;
                     $CodecDescriptionLength = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2;
                     // 2 bytes per character
                     $offset += 2;
                     $thisfile_asf_codeclistobject_codecentries_current['description'] = substr($ASFHeaderData, $offset, $CodecDescriptionLength);
                     $offset += $CodecDescriptionLength;
                     $CodecInformationLength = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                     $offset += 2;
                     $thisfile_asf_codeclistobject_codecentries_current['information'] = substr($ASFHeaderData, $offset, $CodecInformationLength);
                     $offset += $CodecInformationLength;
                     if ($thisfile_asf_codeclistobject_codecentries_current['type_raw'] == 2) {
                         // audio codec
                         if (strpos($thisfile_asf_codeclistobject_codecentries_current['description'], ',') === false) {
                             $info['warning'][] = '[asf][codec_list_object][codec_entries][' . $CodecEntryCounter . '][description] expected to contain comma-seperated list of parameters: "' . $thisfile_asf_codeclistobject_codecentries_current['description'] . '"';
                         } else {
                             list($AudioCodecBitrate, $AudioCodecFrequency, $AudioCodecChannels) = explode(',', self::TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']));
                             $thisfile_audio['codec'] = self::TrimConvert($thisfile_asf_codeclistobject_codecentries_current['name']);
                             if (!isset($thisfile_audio['bitrate']) && strstr($AudioCodecBitrate, 'kbps')) {
                                 $thisfile_audio['bitrate'] = (int) (trim(str_replace('kbps', '', $AudioCodecBitrate)) * 1000);
                             }
                             //if (!isset($thisfile_video['bitrate']) && isset($thisfile_audio['bitrate']) && isset($thisfile_asf['file_properties_object']['max_bitrate']) && ($thisfile_asf_codeclistobject['codec_entries_count'] > 1)) {
                             if (empty($thisfile_video['bitrate']) && !empty($thisfile_audio['bitrate']) && !empty($info['bitrate'])) {
                                 //$thisfile_video['bitrate'] = $thisfile_asf['file_properties_object']['max_bitrate'] - $thisfile_audio['bitrate'];
                                 $thisfile_video['bitrate'] = $info['bitrate'] - $thisfile_audio['bitrate'];
                             }
                             $AudioCodecFrequency = (int) trim(str_replace('kHz', '', $AudioCodecFrequency));
                             switch ($AudioCodecFrequency) {
                                 case 8:
                                 case 8000:
                                     $thisfile_audio['sample_rate'] = 8000;
                                     break;
                                 case 11:
                                 case 11025:
                                     $thisfile_audio['sample_rate'] = 11025;
                                     break;
                                 case 12:
                                 case 12000:
                                     $thisfile_audio['sample_rate'] = 12000;
                                     break;
                                 case 16:
                                 case 16000:
                                     $thisfile_audio['sample_rate'] = 16000;
                                     break;
                                 case 22:
                                 case 22050:
                                     $thisfile_audio['sample_rate'] = 22050;
                                     break;
                                 case 24:
                                 case 24000:
                                     $thisfile_audio['sample_rate'] = 24000;
                                     break;
                                 case 32:
                                 case 32000:
                                     $thisfile_audio['sample_rate'] = 32000;
                                     break;
                                 case 44:
                                 case 441000:
                                     $thisfile_audio['sample_rate'] = 44100;
                                     break;
                                 case 48:
                                 case 48000:
                                     $thisfile_audio['sample_rate'] = 48000;
                                     break;
                                 default:
                                     $info['warning'][] = 'unknown frequency: "' . $AudioCodecFrequency . '" (' . self::TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']) . ')';
                                     break;
                             }
                             if (!isset($thisfile_audio['channels'])) {
                                 if (strstr($AudioCodecChannels, 'stereo')) {
                                     $thisfile_audio['channels'] = 2;
                                 } elseif (strstr($AudioCodecChannels, 'mono')) {
                                     $thisfile_audio['channels'] = 1;
                                 }
                             }
                         }
                     }
                 }
                 break;
             case self::$GETID3_ASF_Script_Command_Object:
                 // Script Command Object: (optional, one only)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for Script Command object - GETID3_ASF_Script_Command_Object
                 // Object Size                  QWORD        64              // size of Script Command object, including 44 bytes of Script Command Object header
                 // Reserved                     GUID         128             // hardcoded: 4B1ACBE3-100B-11D0-A39B-00A0C90348F6
                 // Commands Count               WORD         16              // number of Commands structures in the Script Commands Objects
                 // Command Types Count          WORD         16              // number of Command Types structures in the Script Commands Objects
                 // Command Types                array of:    variable        //
                 // * Command Type Name Length   WORD         16              // number of Unicode characters for Command Type Name
                 // * Command Type Name          WCHAR        variable        // array of Unicode characters - name of a type of command
                 // Commands                     array of:    variable        //
                 // * Presentation Time          DWORD        32              // presentation time of that command, in milliseconds
                 // * Type Index                 WORD         16              // type of this command, as a zero-based index into the array of Command Types of this object
                 // * Command Name Length        WORD         16              // number of Unicode characters for Command Name
                 // * Command Name               WCHAR        variable        // array of Unicode characters - name of this command
                 // shortcut
                 $thisfile_asf['script_command_object'] = array();
                 $thisfile_asf_scriptcommandobject =& $thisfile_asf['script_command_object'];
                 $thisfile_asf_scriptcommandobject['offset'] = $NextObjectOffset + $offset;
                 $thisfile_asf_scriptcommandobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_scriptcommandobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_scriptcommandobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_scriptcommandobject['reserved'] = substr($ASFHeaderData, $offset, 16);
                 $offset += 16;
                 $thisfile_asf_scriptcommandobject['reserved_guid'] = self::BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']);
                 if ($thisfile_asf_scriptcommandobject['reserved'] != self::GUIDtoBytestring('4B1ACBE3-100B-11D0-A39B-00A0C90348F6')) {
                     $info['warning'][] = 'script_command_object.reserved GUID {' . self::BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']) . '} does not match expected "GETID3_ASF_Reserved_1" GUID {4B1ACBE3-100B-11D0-A39B-00A0C90348F6}';
                     //return false;
                     break;
                 }
                 $thisfile_asf_scriptcommandobject['commands_count'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 $thisfile_asf_scriptcommandobject['command_types_count'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 for ($CommandTypesCounter = 0; $CommandTypesCounter < $thisfile_asf_scriptcommandobject['command_types_count']; ++$CommandTypesCounter) {
                     $CommandTypeNameLength = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2;
                     // 2 bytes per character
                     $offset += 2;
                     $thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
                     $offset += $CommandTypeNameLength;
                 }
                 for ($CommandsCounter = 0; $CommandsCounter < $thisfile_asf_scriptcommandobject['commands_count']; ++$CommandsCounter) {
                     $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['presentation_time'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                     $offset += 4;
                     $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['type_index'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                     $offset += 2;
                     $CommandTypeNameLength = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2;
                     // 2 bytes per character
                     $offset += 2;
                     $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
                     $offset += $CommandTypeNameLength;
                 }
                 break;
             case self::$GETID3_ASF_Marker_Object:
                 // Marker Object: (optional, one only)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for Marker object - GETID3_ASF_Marker_Object
                 // Object Size                  QWORD        64              // size of Marker object, including 48 bytes of Marker Object header
                 // Reserved                     GUID         128             // hardcoded: 4CFEDB20-75F6-11CF-9C0F-00A0C90349CB
                 // Markers Count                DWORD        32              // number of Marker structures in Marker Object
                 // Reserved                     WORD         16              // hardcoded: 0x0000
                 // Name Length                  WORD         16              // number of bytes in the Name field
                 // Name                         WCHAR        variable        // name of the Marker Object
                 // Markers                      array of:    variable        //
                 // * Offset                     QWORD        64              // byte offset into Data Object
                 // * Presentation Time          QWORD        64              // in 100-nanosecond units
                 // * Entry Length               WORD         16              // length in bytes of (Send Time + Flags + Marker Description Length + Marker Description + Padding)
                 // * Send Time                  DWORD        32              // in milliseconds
                 // * Flags                      DWORD        32              // hardcoded: 0x00000000
                 // * Marker Description Length  DWORD        32              // number of bytes in Marker Description field
                 // * Marker Description         WCHAR        variable        // array of Unicode characters - description of marker entry
                 // * Padding                    BYTESTREAM   variable        // optional padding bytes
                 // shortcut
                 $thisfile_asf['marker_object'] = array();
                 $thisfile_asf_markerobject =& $thisfile_asf['marker_object'];
                 $thisfile_asf_markerobject['offset'] = $NextObjectOffset + $offset;
                 $thisfile_asf_markerobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_markerobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_markerobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_markerobject['reserved'] = substr($ASFHeaderData, $offset, 16);
                 $offset += 16;
                 $thisfile_asf_markerobject['reserved_guid'] = self::BytestringToGUID($thisfile_asf_markerobject['reserved']);
                 if ($thisfile_asf_markerobject['reserved'] != self::GUIDtoBytestring('4CFEDB20-75F6-11CF-9C0F-00A0C90349CB')) {
                     $info['warning'][] = 'marker_object.reserved GUID {' . self::BytestringToGUID($thisfile_asf_markerobject['reserved_1']) . '} does not match expected "GETID3_ASF_Reserved_1" GUID {4CFEDB20-75F6-11CF-9C0F-00A0C90349CB}';
                     break;
                 }
                 $thisfile_asf_markerobject['markers_count'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                 $offset += 4;
                 $thisfile_asf_markerobject['reserved_2'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 if ($thisfile_asf_markerobject['reserved_2'] != 0) {
                     $info['warning'][] = 'marker_object.reserved_2 (' . Helper::PrintHexBytes($thisfile_asf_markerobject['reserved_2']) . ') does not match expected value of "0"';
                     break;
                 }
                 $thisfile_asf_markerobject['name_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 $thisfile_asf_markerobject['name'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['name_length']);
                 $offset += $thisfile_asf_markerobject['name_length'];
                 for ($MarkersCounter = 0; $MarkersCounter < $thisfile_asf_markerobject['markers_count']; ++$MarkersCounter) {
                     $thisfile_asf_markerobject['markers'][$MarkersCounter]['offset'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                     $offset += 8;
                     $thisfile_asf_markerobject['markers'][$MarkersCounter]['presentation_time'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
                     $offset += 8;
                     $thisfile_asf_markerobject['markers'][$MarkersCounter]['entry_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                     $offset += 2;
                     $thisfile_asf_markerobject['markers'][$MarkersCounter]['send_time'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                     $offset += 4;
                     $thisfile_asf_markerobject['markers'][$MarkersCounter]['flags'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                     $offset += 4;
                     $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                     $offset += 4;
                     $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length']);
                     $offset += $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'];
                     $PaddingLength = $thisfile_asf_markerobject['markers'][$MarkersCounter]['entry_length'] - 4 - 4 - 4 - $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'];
                     if ($PaddingLength > 0) {
                         $thisfile_asf_markerobject['markers'][$MarkersCounter]['padding'] = substr($ASFHeaderData, $offset, $PaddingLength);
                         $offset += $PaddingLength;
                     }
                 }
                 break;
             case self::$GETID3_ASF_Bitrate_Mutual_Exclusion_Object:
                 // Bitrate Mutual Exclusion Object: (optional)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for Bitrate Mutual Exclusion object - GETID3_ASF_Bitrate_Mutual_Exclusion_Object
                 // Object Size                  QWORD        64              // size of Bitrate Mutual Exclusion object, including 42 bytes of Bitrate Mutual Exclusion Object header
                 // Exlusion Type                GUID         128             // nature of mutual exclusion relationship. one of: (GETID3_ASF_Mutex_Bitrate, GETID3_ASF_Mutex_Unknown)
                 // Stream Numbers Count         WORD         16              // number of video streams
                 // Stream Numbers               WORD         variable        // array of mutually exclusive video stream numbers. 1 <= valid <= 127
                 // shortcut
                 $thisfile_asf['bitrate_mutual_exclusion_object'] = array();
                 $thisfile_asf_bitratemutualexclusionobject =& $thisfile_asf['bitrate_mutual_exclusion_object'];
                 $thisfile_asf_bitratemutualexclusionobject['offset'] = $NextObjectOffset + $offset;
                 $thisfile_asf_bitratemutualexclusionobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_bitratemutualexclusionobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_bitratemutualexclusionobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_bitratemutualexclusionobject['reserved'] = substr($ASFHeaderData, $offset, 16);
                 $thisfile_asf_bitratemutualexclusionobject['reserved_guid'] = self::BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']);
                 $offset += 16;
                 if ($thisfile_asf_bitratemutualexclusionobject['reserved'] != self::$GETID3_ASF_Mutex_Bitrate && $thisfile_asf_bitratemutualexclusionobject['reserved'] != self::$GETID3_ASF_Mutex_Unknown) {
                     $info['warning'][] = 'bitrate_mutual_exclusion_object.reserved GUID {' . self::BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']) . '} does not match expected "GETID3_ASF_Mutex_Bitrate" GUID {' . self::BytestringToGUID(self::$GETID3_ASF_Mutex_Bitrate) . '} or  "GETID3_ASF_Mutex_Unknown" GUID {' . self::BytestringToGUID(self::$GETID3_ASF_Mutex_Unknown) . '}';
                     //return false;
                     break;
                 }
                 $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 for ($StreamNumberCounter = 0; $StreamNumberCounter < $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count']; ++$StreamNumberCounter) {
                     $thisfile_asf_bitratemutualexclusionobject['stream_numbers'][$StreamNumberCounter] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                     $offset += 2;
                 }
                 break;
             case self::$GETID3_ASF_Error_Correction_Object:
                 // Error Correction Object: (optional, one only)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for Error Correction object - GETID3_ASF_Error_Correction_Object
                 // Object Size                  QWORD        64              // size of Error Correction object, including 44 bytes of Error Correction Object header
                 // Error Correction Type        GUID         128             // type of error correction. one of: (GETID3_ASF_No_Error_Correction, GETID3_ASF_Audio_Spread)
                 // Error Correction Data Length DWORD        32              // number of bytes in Error Correction Data field
                 // Error Correction Data        BYTESTREAM   variable        // structure depends on value of Error Correction Type field
                 // shortcut
                 $thisfile_asf['error_correction_object'] = array();
                 $thisfile_asf_errorcorrectionobject =& $thisfile_asf['error_correction_object'];
                 $thisfile_asf_errorcorrectionobject['offset'] = $NextObjectOffset + $offset;
                 $thisfile_asf_errorcorrectionobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_errorcorrectionobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_errorcorrectionobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_errorcorrectionobject['error_correction_type'] = substr($ASFHeaderData, $offset, 16);
                 $offset += 16;
                 $thisfile_asf_errorcorrectionobject['error_correction_guid'] = self::BytestringToGUID($thisfile_asf_errorcorrectionobject['error_correction_type']);
                 $thisfile_asf_errorcorrectionobject['error_correction_data_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                 $offset += 4;
                 switch ($thisfile_asf_errorcorrectionobject['error_correction_type']) {
                     case self::$GETID3_ASF_No_Error_Correction:
                         // should be no data, but just in case there is, skip to the end of the field
                         $offset += $thisfile_asf_errorcorrectionobject['error_correction_data_length'];
                         break;
                     case self::$GETID3_ASF_Audio_Spread:
                         // Field Name                   Field Type   Size (bits)
                         // Span                         BYTE         8               // number of packets over which audio will be spread.
                         // Virtual Packet Length        WORD         16              // size of largest audio payload found in audio stream
                         // Virtual Chunk Length         WORD         16              // size of largest audio payload found in audio stream
                         // Silence Data Length          WORD         16              // number of bytes in Silence Data field
                         // Silence Data                 BYTESTREAM   variable        // hardcoded: 0x00 * (Silence Data Length) bytes
                         $thisfile_asf_errorcorrectionobject['span'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 1));
                         $offset += 1;
                         $thisfile_asf_errorcorrectionobject['virtual_packet_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                         $offset += 2;
                         $thisfile_asf_errorcorrectionobject['virtual_chunk_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                         $offset += 2;
                         $thisfile_asf_errorcorrectionobject['silence_data_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                         $offset += 2;
                         $thisfile_asf_errorcorrectionobject['silence_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_errorcorrectionobject['silence_data_length']);
                         $offset += $thisfile_asf_errorcorrectionobject['silence_data_length'];
                         break;
                     default:
                         $info['warning'][] = 'error_correction_object.error_correction_type GUID {' . self::BytestringToGUID($thisfile_asf_errorcorrectionobject['reserved']) . '} does not match expected "GETID3_ASF_No_Error_Correction" GUID {' . self::BytestringToGUID(self::$GETID3_ASF_No_Error_Correction) . '} or  "GETID3_ASF_Audio_Spread" GUID {' . self::BytestringToGUID(self::$GETID3_ASF_Audio_Spread) . '}';
                         //return false;
                         break;
                 }
                 break;
             case self::$GETID3_ASF_Content_Description_Object:
                 // Content Description Object: (optional, one only)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for Content Description object - GETID3_ASF_Content_Description_Object
                 // Object Size                  QWORD        64              // size of Content Description object, including 34 bytes of Content Description Object header
                 // Title Length                 WORD         16              // number of bytes in Title field
                 // Author Length                WORD         16              // number of bytes in Author field
                 // Copyright Length             WORD         16              // number of bytes in Copyright field
                 // Description Length           WORD         16              // number of bytes in Description field
                 // Rating Length                WORD         16              // number of bytes in Rating field
                 // Title                        WCHAR        16              // array of Unicode characters - Title
                 // Author                       WCHAR        16              // array of Unicode characters - Author
                 // Copyright                    WCHAR        16              // array of Unicode characters - Copyright
                 // Description                  WCHAR        16              // array of Unicode characters - Description
                 // Rating                       WCHAR        16              // array of Unicode characters - Rating
                 // shortcut
                 $thisfile_asf['content_description_object'] = array();
                 $thisfile_asf_contentdescriptionobject =& $thisfile_asf['content_description_object'];
                 $thisfile_asf_contentdescriptionobject['offset'] = $NextObjectOffset + $offset;
                 $thisfile_asf_contentdescriptionobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_contentdescriptionobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_contentdescriptionobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_contentdescriptionobject['title_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 $thisfile_asf_contentdescriptionobject['author_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 $thisfile_asf_contentdescriptionobject['copyright_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 $thisfile_asf_contentdescriptionobject['description_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 $thisfile_asf_contentdescriptionobject['rating_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 $thisfile_asf_contentdescriptionobject['title'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['title_length']);
                 $offset += $thisfile_asf_contentdescriptionobject['title_length'];
                 $thisfile_asf_contentdescriptionobject['author'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['author_length']);
                 $offset += $thisfile_asf_contentdescriptionobject['author_length'];
                 $thisfile_asf_contentdescriptionobject['copyright'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['copyright_length']);
                 $offset += $thisfile_asf_contentdescriptionobject['copyright_length'];
                 $thisfile_asf_contentdescriptionobject['description'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['description_length']);
                 $offset += $thisfile_asf_contentdescriptionobject['description_length'];
                 $thisfile_asf_contentdescriptionobject['rating'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['rating_length']);
                 $offset += $thisfile_asf_contentdescriptionobject['rating_length'];
                 $ASFcommentKeysToCopy = array('title' => 'title', 'author' => 'artist', 'copyright' => 'copyright', 'description' => 'comment', 'rating' => 'rating');
                 foreach ($ASFcommentKeysToCopy as $keytocopyfrom => $keytocopyto) {
                     if (!empty($thisfile_asf_contentdescriptionobject[$keytocopyfrom])) {
                         $thisfile_asf_comments[$keytocopyto][] = self::TrimTerm($thisfile_asf_contentdescriptionobject[$keytocopyfrom]);
                     }
                 }
                 break;
             case self::$GETID3_ASF_Extended_Content_Description_Object:
                 // Extended Content Description Object: (optional, one only)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for Extended Content Description object - GETID3_ASF_Extended_Content_Description_Object
                 // Object Size                  QWORD        64              // size of ExtendedContent Description object, including 26 bytes of Extended Content Description Object header
                 // Content Descriptors Count    WORD         16              // number of entries in Content Descriptors list
                 // Content Descriptors          array of:    variable        //
                 // * Descriptor Name Length     WORD         16              // size in bytes of Descriptor Name field
                 // * Descriptor Name            WCHAR        variable        // array of Unicode characters - Descriptor Name
                 // * Descriptor Value Data Type WORD         16              // Lookup array:
                 // 0x0000 = Unicode String (variable length)
                 // 0x0001 = BYTE array     (variable length)
                 // 0x0002 = BOOL           (DWORD, 32 bits)
                 // 0x0003 = DWORD          (DWORD, 32 bits)
                 // 0x0004 = QWORD          (QWORD, 64 bits)
                 // 0x0005 = WORD           (WORD,  16 bits)
                 // * Descriptor Value Length    WORD         16              // number of bytes stored in Descriptor Value field
                 // * Descriptor Value           variable     variable        // value for Content Descriptor
                 // shortcut
                 $thisfile_asf['extended_content_description_object'] = array();
                 $thisfile_asf_extendedcontentdescriptionobject =& $thisfile_asf['extended_content_description_object'];
                 $thisfile_asf_extendedcontentdescriptionobject['offset'] = $NextObjectOffset + $offset;
                 $thisfile_asf_extendedcontentdescriptionobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_extendedcontentdescriptionobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_extendedcontentdescriptionobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count']; ++$ExtendedContentDescriptorsCounter) {
                     // shortcut
                     $thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter] = array();
                     $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current =& $thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter];
                     $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['base_offset'] = $offset + 30;
                     $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                     $offset += 2;
                     $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name'] = substr($ASFHeaderData, $offset, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length']);
                     $offset += $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length'];
                     $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                     $offset += 2;
                     $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                     $offset += 2;
                     $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = substr($ASFHeaderData, $offset, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length']);
                     $offset += $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length'];
                     switch ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type']) {
                         case 0x0:
                             // Unicode string
                             break;
                         case 0x1:
                             // BYTE array
                             // do nothing
                             break;
                         case 0x2:
                             // BOOL
                             $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = (bool) Helper::LittleEndian2Int($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
                             break;
                         case 0x3:
                             // DWORD
                         // DWORD
                         case 0x4:
                             // QWORD
                         // QWORD
                         case 0x5:
                             // WORD
                             $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = Helper::LittleEndian2Int($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
                             break;
                         default:
                             $info['warning'][] = 'extended_content_description.content_descriptors.' . $ExtendedContentDescriptorsCounter . '.value_type is invalid (' . $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type'] . ')';
                             //return false;
                             break;
                     }
                     switch (self::TrimConvert(strtolower($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name']))) {
                         case 'wm/albumartist':
                         case 'artist':
                             // Note: not 'artist', that comes from 'author' tag
                             $thisfile_asf_comments['albumartist'] = array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
                             break;
                         case 'wm/albumtitle':
                         case 'album':
                             $thisfile_asf_comments['album'] = array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
                             break;
                         case 'wm/genre':
                         case 'genre':
                             $thisfile_asf_comments['genre'] = array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
                             break;
                         case 'wm/partofset':
                             $thisfile_asf_comments['partofset'] = array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
                             break;
                         case 'wm/tracknumber':
                         case 'tracknumber':
                             // be careful casting to int: casting unicode strings to int gives unexpected results (stops parsing at first non-numeric character)
                             $thisfile_asf_comments['track'] = array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
                             foreach ($thisfile_asf_comments['track'] as $key => $value) {
                                 if (preg_match('/^[0-9\\x00]+$/', $value)) {
                                     $thisfile_asf_comments['track'][$key] = intval(str_replace("", '', $value));
                                 }
                             }
                             break;
                         case 'wm/track':
                             if (empty($thisfile_asf_comments['track'])) {
                                 $thisfile_asf_comments['track'] = array(1 + self::TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
                             }
                             break;
                         case 'wm/year':
                         case 'year':
                         case 'date':
                             $thisfile_asf_comments['year'] = array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
                             break;
                         case 'wm/lyrics':
                         case 'lyrics':
                             $thisfile_asf_comments['lyrics'] = array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
                             break;
                         case 'isvbr':
                             if ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']) {
                                 $thisfile_audio['bitrate_mode'] = 'vbr';
                                 $thisfile_video['bitrate_mode'] = 'vbr';
                             }
                             break;
                         case 'id3':
                             // id3v2 module might not be loaded
                             if (class_exists('getid3_id3v2')) {
                                 $tempfile = tempnam(GetId3Core::getTempDir(), 'getID3');
                                 $tempfilehandle = fopen($tempfile, 'wb');
                                 $tempThisfileInfo = array('encoding' => $info['encoding']);
                                 fwrite($tempfilehandle, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
                                 fclose($tempfilehandle);
                                 $getid3_temp = new GetId3Core();
                                 $getid3_temp->openfile($tempfile);
                                 $getid3_id3v2 = new Id3v2($getid3_temp);
                                 $getid3_id3v2->analyze();
                                 $info['id3v2'] = $getid3_temp->info['id3v2'];
                                 unset($getid3_temp, $getid3_id3v2);
                                 unlink($tempfile);
                             }
                             break;
                         case 'wm/encodingtime':
                             $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['encoding_time_unix'] = self::FILETIMEtoUNIXtime($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
                             $thisfile_asf_comments['encoding_time_unix'] = array($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['encoding_time_unix']);
                             break;
                         case 'wm/picture':
                             $WMpicture = $this->ASF_WMpicture($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
                             foreach ($WMpicture as $key => $value) {
                                 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[$key] = $value;
                             }
                             unset($WMpicture);
                             /*
                              $wm_picture_offset = 0;
                              $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id'] = GetId3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 1));
                              $wm_picture_offset += 1;
                              $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type']    = $this->WMpictureTypeLookup($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id']);
                              $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_size']    = GetId3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 4));
                              $wm_picture_offset += 4;
                             
                              $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = '';
                              do {
                              $next_byte_pair = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 2);
                              $wm_picture_offset += 2;
                              $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] .= $next_byte_pair;
                              } while ($next_byte_pair !== "\x00\x00");
                             
                              $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_description'] = '';
                              do {
                              $next_byte_pair = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 2);
                              $wm_picture_offset += 2;
                              $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_description'] .= $next_byte_pair;
                              } while ($next_byte_pair !== "\x00\x00");
                             
                              $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['dataoffset'] = $wm_picture_offset;
                              $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'] = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset);
                              unset($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
                             
                              $imageinfo = array();
                              $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = '';
                              $imagechunkcheck = GetId3_lib::GetDataImageSize($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'], $imageinfo);
                              unset($imageinfo);
                              if (!empty($imagechunkcheck)) {
                              $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
                              }
                              if (!isset($thisfile_asf_comments['picture'])) {
                              $thisfile_asf_comments['picture'] = array();
                              }
                              $thisfile_asf_comments['picture'][] = array('data'=>$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'], 'image_mime'=>$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime']);
                             */
                             break;
                         default:
                             switch ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type']) {
                                 case 0:
                                     // Unicode string
                                     if (substr(self::TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name']), 0, 3) == 'WM/') {
                                         $thisfile_asf_comments[str_replace('wm/', '', strtolower(self::TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name'])))] = array(self::TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
                                     }
                                     break;
                                 case 1:
                                     break;
                             }
                             break;
                     }
                 }
                 break;
             case self::$GETID3_ASF_Stream_Bitrate_Properties_Object:
                 // Stream Bitrate Properties Object: (optional, one only)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for Stream Bitrate Properties object - GETID3_ASF_Stream_Bitrate_Properties_Object
                 // Object Size                  QWORD        64              // size of Extended Content Description object, including 26 bytes of Stream Bitrate Properties Object header
                 // Bitrate Records Count        WORD         16              // number of records in Bitrate Records
                 // Bitrate Records              array of:    variable        //
                 // * Flags                      WORD         16              //
                 // * * Stream Number            bits         7  (0x007F)     // number of this stream
                 // * * Reserved                 bits         9  (0xFF80)     // hardcoded: 0
                 // * Average Bitrate            DWORD        32              // in bits per second
                 // shortcut
                 $thisfile_asf['stream_bitrate_properties_object'] = array();
                 $thisfile_asf_streambitratepropertiesobject =& $thisfile_asf['stream_bitrate_properties_object'];
                 $thisfile_asf_streambitratepropertiesobject['offset'] = $NextObjectOffset + $offset;
                 $thisfile_asf_streambitratepropertiesobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_streambitratepropertiesobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_streambitratepropertiesobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_streambitratepropertiesobject['bitrate_records_count'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                 $offset += 2;
                 for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; ++$BitrateRecordsCounter) {
                     $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
                     $offset += 2;
                     $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags']['stream_number'] = $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] & 0x7f;
                     $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['bitrate'] = Helper::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
                     $offset += 4;
                 }
                 break;
             case self::$GETID3_ASF_Padding_Object:
                 // Padding Object: (optional)
                 // Field Name                   Field Type   Size (bits)
                 // Object ID                    GUID         128             // GUID for Padding object - GETID3_ASF_Padding_Object
                 // Object Size                  QWORD        64              // size of Padding object, including 24 bytes of ASF Padding Object header
                 // Padding Data                 BYTESTREAM   variable        // ignore
                 // shortcut
                 $thisfile_asf['padding_object'] = array();
                 $thisfile_asf_paddingobject =& $thisfile_asf['padding_object'];
                 $thisfile_asf_paddingobject['offset'] = $NextObjectOffset + $offset;
                 $thisfile_asf_paddingobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_paddingobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_paddingobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_paddingobject['padding_length'] = $thisfile_asf_paddingobject['objectsize'] - 16 - 8;
                 $thisfile_asf_paddingobject['padding'] = substr($ASFHeaderData, $offset, $thisfile_asf_paddingobject['padding_length']);
                 $offset += $NextObjectSize - 16 - 8;
                 break;
             case self::$GETID3_ASF_Extended_Content_Encryption_Object:
             case self::$GETID3_ASF_Content_Encryption_Object:
                 // WMA DRM - just ignore
                 $offset += $NextObjectSize - 16 - 8;
                 break;
             default:
                 // Implementations shall ignore any standard or non-standard object that they do not know how to handle.
                 if (self::GUIDname($NextObjectGUIDtext)) {
                     $info['warning'][] = 'unhandled GUID "' . self::GUIDname($NextObjectGUIDtext) . '" {' . $NextObjectGUIDtext . '} in ASF header at offset ' . ($offset - 16 - 8);
                 } else {
                     $info['warning'][] = 'unknown GUID {' . $NextObjectGUIDtext . '} in ASF header at offset ' . ($offset - 16 - 8);
                 }
                 $offset += $NextObjectSize - 16 - 8;
                 break;
         }
     }
     if (isset($thisfile_asf_streambitrateproperties['bitrate_records_count'])) {
         $ASFbitrateAudio = 0;
         $ASFbitrateVideo = 0;
         for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitrateproperties['bitrate_records_count']; ++$BitrateRecordsCounter) {
             if (isset($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter])) {
                 switch ($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter]['type_raw']) {
                     case 1:
                         $ASFbitrateVideo += $thisfile_asf_streambitrateproperties['bitrate_records'][$BitrateRecordsCounter]['bitrate'];
                         break;
                     case 2:
                         $ASFbitrateAudio += $thisfile_asf_streambitrateproperties['bitrate_records'][$BitrateRecordsCounter]['bitrate'];
                         break;
                     default:
                         // do nothing
                         break;
                 }
             }
         }
         if ($ASFbitrateAudio > 0) {
             $thisfile_audio['bitrate'] = $ASFbitrateAudio;
         }
         if ($ASFbitrateVideo > 0) {
             $thisfile_video['bitrate'] = $ASFbitrateVideo;
         }
     }
     if (isset($thisfile_asf['stream_properties_object']) && is_array($thisfile_asf['stream_properties_object'])) {
         $thisfile_audio['bitrate'] = 0;
         $thisfile_video['bitrate'] = 0;
         foreach ($thisfile_asf['stream_properties_object'] as $streamnumber => $streamdata) {
             switch ($streamdata['stream_type']) {
                 case self::$GETID3_ASF_Audio_Media:
                     // Field Name                   Field Type   Size (bits)
                     // Codec ID / Format Tag        WORD         16              // unique ID of audio codec - defined as wFormatTag field of WAVEFORMATEX structure
                     // Number of Channels           WORD         16              // number of channels of audio - defined as nChannels field of WAVEFORMATEX structure
                     // Samples Per Second           DWORD        32              // in Hertz - defined as nSamplesPerSec field of WAVEFORMATEX structure
                     // Average number of Bytes/sec  DWORD        32              // bytes/sec of audio stream  - defined as nAvgBytesPerSec field of WAVEFORMATEX structure
                     // Block Alignment              WORD         16              // block size in bytes of audio codec - defined as nBlockAlign field of WAVEFORMATEX structure
                     // Bits per sample              WORD         16              // bits per sample of mono data. set to zero for variable bitrate codecs. defined as wBitsPerSample field of WAVEFORMATEX structure
                     // Codec Specific Data Size     WORD         16              // size in bytes of Codec Specific Data buffer - defined as cbSize field of WAVEFORMATEX structure
                     // Codec Specific Data          BYTESTREAM   variable        // array of codec-specific data bytes
                     // shortcut
                     $thisfile_asf['audio_media'][$streamnumber] = array();
                     $thisfile_asf_audiomedia_currentstream =& $thisfile_asf['audio_media'][$streamnumber];
                     $audiomediaoffset = 0;
                     $thisfile_asf_audiomedia_currentstream = Riff::RIFFparseWAVEFORMATex(substr($streamdata['type_specific_data'], $audiomediaoffset, 16));
                     $audiomediaoffset += 16;
                     $thisfile_audio['lossless'] = false;
                     switch ($thisfile_asf_audiomedia_currentstream['raw']['wFormatTag']) {
                         case 0x1:
                             // PCM
                         // PCM
                         case 0x163:
                             // WMA9 Lossless
                             $thisfile_audio['lossless'] = true;
                             break;
                     }
                     if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) {
                         foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
                             if (isset($dataarray['flags']['stream_number']) && $dataarray['flags']['stream_number'] == $streamnumber) {
                                 $thisfile_asf_audiomedia_currentstream['bitrate'] = $dataarray['bitrate'];
                                 $thisfile_audio['bitrate'] += $dataarray['bitrate'];
                                 break;
                             }
                         }
                     } else {
                         if (!empty($thisfile_asf_audiomedia_currentstream['bytes_sec'])) {
                             $thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bytes_sec'] * 8;
                         } elseif (!empty($thisfile_asf_audiomedia_currentstream['bitrate'])) {
                             $thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bitrate'];
                         }
                     }
                     $thisfile_audio['streams'][$streamnumber] = $thisfile_asf_audiomedia_currentstream;
                     $thisfile_audio['streams'][$streamnumber]['wformattag'] = $thisfile_asf_audiomedia_currentstream['raw']['wFormatTag'];
                     $thisfile_audio['streams'][$streamnumber]['lossless'] = $thisfile_audio['lossless'];
                     $thisfile_audio['streams'][$streamnumber]['bitrate'] = $thisfile_audio['bitrate'];
                     $thisfile_audio['streams'][$streamnumber]['dataformat'] = 'wma';
                     unset($thisfile_audio['streams'][$streamnumber]['raw']);
                     $thisfile_asf_audiomedia_currentstream['codec_data_size'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $audiomediaoffset, 2));
                     $audiomediaoffset += 2;
                     $thisfile_asf_audiomedia_currentstream['codec_data'] = substr($streamdata['type_specific_data'], $audiomediaoffset, $thisfile_asf_audiomedia_currentstream['codec_data_size']);
                     $audiomediaoffset += $thisfile_asf_audiomedia_currentstream['codec_data_size'];
                     break;
                 case self::$GETID3_ASF_Video_Media:
                     // Field Name                   Field Type   Size (bits)
                     // Encoded Image Width          DWORD        32              // width of image in pixels
                     // Encoded Image Height         DWORD        32              // height of image in pixels
                     // Reserved Flags               BYTE         8               // hardcoded: 0x02
                     // Format Data Size             WORD         16              // size of Format Data field in bytes
                     // Format Data                  array of:    variable        //
                     // * Format Data Size           DWORD        32              // number of bytes in Format Data field, in bytes - defined as biSize field of BITMAPINFOHEADER structure
                     // * Image Width                LONG         32              // width of encoded image in pixels - defined as biWidth field of BITMAPINFOHEADER structure
                     // * Image Height               LONG         32              // height of encoded image in pixels - defined as biHeight field of BITMAPINFOHEADER structure
                     // * Reserved                   WORD         16              // hardcoded: 0x0001 - defined as biPlanes field of BITMAPINFOHEADER structure
                     // * Bits Per Pixel Count       WORD         16              // bits per pixel - defined as biBitCount field of BITMAPINFOHEADER structure
                     // * Compression ID             FOURCC       32              // fourcc of video codec - defined as biCompression field of BITMAPINFOHEADER structure
                     // * Image Size                 DWORD        32              // image size in bytes - defined as biSizeImage field of BITMAPINFOHEADER structure
                     // * Horizontal Pixels / Meter  DWORD        32              // horizontal resolution of target device in pixels per meter - defined as biXPelsPerMeter field of BITMAPINFOHEADER structure
                     // * Vertical Pixels / Meter    DWORD        32              // vertical resolution of target device in pixels per meter - defined as biYPelsPerMeter field of BITMAPINFOHEADER structure
                     // * Colors Used Count          DWORD        32              // number of color indexes in the color table that are actually used - defined as biClrUsed field of BITMAPINFOHEADER structure
                     // * Important Colors Count     DWORD        32              // number of color index required for displaying bitmap. if zero, all colors are required. defined as biClrImportant field of BITMAPINFOHEADER structure
                     // * Codec Specific Data        BYTESTREAM   variable        // array of codec-specific data bytes
                     // shortcut
                     $thisfile_asf['video_media'][$streamnumber] = array();
                     $thisfile_asf_videomedia_currentstream =& $thisfile_asf['video_media'][$streamnumber];
                     $videomediaoffset = 0;
                     $thisfile_asf_videomedia_currentstream['image_width'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                     $videomediaoffset += 4;
                     $thisfile_asf_videomedia_currentstream['image_height'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                     $videomediaoffset += 4;
                     $thisfile_asf_videomedia_currentstream['flags'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 1));
                     $videomediaoffset += 1;
                     $thisfile_asf_videomedia_currentstream['format_data_size'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
                     $videomediaoffset += 2;
                     $thisfile_asf_videomedia_currentstream['format_data']['format_data_size'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                     $videomediaoffset += 4;
                     $thisfile_asf_videomedia_currentstream['format_data']['image_width'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                     $videomediaoffset += 4;
                     $thisfile_asf_videomedia_currentstream['format_data']['image_height'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                     $videomediaoffset += 4;
                     $thisfile_asf_videomedia_currentstream['format_data']['reserved'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
                     $videomediaoffset += 2;
                     $thisfile_asf_videomedia_currentstream['format_data']['bits_per_pixel'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
                     $videomediaoffset += 2;
                     $thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc'] = substr($streamdata['type_specific_data'], $videomediaoffset, 4);
                     $videomediaoffset += 4;
                     $thisfile_asf_videomedia_currentstream['format_data']['image_size'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                     $videomediaoffset += 4;
                     $thisfile_asf_videomedia_currentstream['format_data']['horizontal_pels'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                     $videomediaoffset += 4;
                     $thisfile_asf_videomedia_currentstream['format_data']['vertical_pels'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                     $videomediaoffset += 4;
                     $thisfile_asf_videomedia_currentstream['format_data']['colors_used'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                     $videomediaoffset += 4;
                     $thisfile_asf_videomedia_currentstream['format_data']['colors_important'] = Helper::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
                     $videomediaoffset += 4;
                     $thisfile_asf_videomedia_currentstream['format_data']['codec_data'] = substr($streamdata['type_specific_data'], $videomediaoffset);
                     if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) {
                         foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
                             if (isset($dataarray['flags']['stream_number']) && $dataarray['flags']['stream_number'] == $streamnumber) {
                                 $thisfile_asf_videomedia_currentstream['bitrate'] = $dataarray['bitrate'];
                                 $thisfile_video['streams'][$streamnumber]['bitrate'] = $dataarray['bitrate'];
                                 $thisfile_video['bitrate'] += $dataarray['bitrate'];
                                 break;
                             }
                         }
                     }
                     $thisfile_asf_videomedia_currentstream['format_data']['codec'] = Riff::RIFFfourccLookup($thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc']);
                     $thisfile_video['streams'][$streamnumber]['fourcc'] = $thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc'];
                     $thisfile_video['streams'][$streamnumber]['codec'] = $thisfile_asf_videomedia_currentstream['format_data']['codec'];
                     $thisfile_video['streams'][$streamnumber]['resolution_x'] = $thisfile_asf_videomedia_currentstream['image_width'];
                     $thisfile_video['streams'][$streamnumber]['resolution_y'] = $thisfile_asf_videomedia_currentstream['image_height'];
                     $thisfile_video['streams'][$streamnumber]['bits_per_sample'] = $thisfile_asf_videomedia_currentstream['format_data']['bits_per_pixel'];
                     break;
                 default:
                     break;
             }
         }
     }
     while (ftell($this->getid3->fp) < $info['avdataend']) {
         $NextObjectDataHeader = fread($this->getid3->fp, 24);
         $offset = 0;
         $NextObjectGUID = substr($NextObjectDataHeader, 0, 16);
         $offset += 16;
         $NextObjectGUIDtext = self::BytestringToGUID($NextObjectGUID);
         $NextObjectSize = Helper::LittleEndian2Int(substr($NextObjectDataHeader, $offset, 8));
         $offset += 8;
         switch ($NextObjectGUID) {
             case self::$GETID3_ASF_Data_Object:
                 // Data Object: (mandatory, one only)
                 // Field Name                       Field Type   Size (bits)
                 // Object ID                        GUID         128             // GUID for Data object - GETID3_ASF_Data_Object
                 // Object Size                      QWORD        64              // size of Data object, including 50 bytes of Data Object header. may be 0 if FilePropertiesObject.BroadcastFlag == 1
                 // File ID                          GUID         128             // unique identifier. identical to File ID field in Header Object
                 // Total Data Packets               QWORD        64              // number of Data Packet entries in Data Object. invalid if FilePropertiesObject.BroadcastFlag == 1
                 // Reserved                         WORD         16              // hardcoded: 0x0101
                 // shortcut
                 $thisfile_asf['data_object'] = array();
                 $thisfile_asf_dataobject =& $thisfile_asf['data_object'];
                 $DataObjectData = $NextObjectDataHeader . fread($this->getid3->fp, 50 - 24);
                 $offset = 24;
                 $thisfile_asf_dataobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_dataobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_dataobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_dataobject['fileid'] = substr($DataObjectData, $offset, 16);
                 $offset += 16;
                 $thisfile_asf_dataobject['fileid_guid'] = self::BytestringToGUID($thisfile_asf_dataobject['fileid']);
                 $thisfile_asf_dataobject['total_data_packets'] = Helper::LittleEndian2Int(substr($DataObjectData, $offset, 8));
                 $offset += 8;
                 $thisfile_asf_dataobject['reserved'] = Helper::LittleEndian2Int(substr($DataObjectData, $offset, 2));
                 $offset += 2;
                 if ($thisfile_asf_dataobject['reserved'] != 0x101) {
                     $info['warning'][] = 'data_object.reserved (' . Helper::PrintHexBytes($thisfile_asf_dataobject['reserved']) . ') does not match expected value of "0x0101"';
                     //return false;
                     break;
                 }
                 // Data Packets                     array of:    variable        //
                 // * Error Correction Flags         BYTE         8               //
                 // * * Error Correction Data Length bits         4               // if Error Correction Length Type == 00, size of Error Correction Data in bytes, else hardcoded: 0000
                 // * * Opaque Data Present          bits         1               //
                 // * * Error Correction Length Type bits         2               // number of bits for size of the error correction data. hardcoded: 00
                 // * * Error Correction Present     bits         1               // If set, use Opaque Data Packet structure, else use Payload structure
                 // * Error Correction Data
                 $info['avdataoffset'] = ftell($this->getid3->fp);
                 fseek($this->getid3->fp, $thisfile_asf_dataobject['objectsize'] - 50, SEEK_CUR);
                 // skip actual audio/video data
                 $info['avdataend'] = ftell($this->getid3->fp);
                 break;
             case self::$GETID3_ASF_Simple_Index_Object:
                 // Simple Index Object: (optional, recommended, one per video stream)
                 // Field Name                       Field Type   Size (bits)
                 // Object ID                        GUID         128             // GUID for Simple Index object - GETID3_ASF_Data_Object
                 // Object Size                      QWORD        64              // size of Simple Index object, including 56 bytes of Simple Index Object header
                 // File ID                          GUID         128             // unique identifier. may be zero or identical to File ID field in Data Object and Header Object
                 // Index Entry Time Interval        QWORD        64              // interval between index entries in 100-nanosecond units
                 // Maximum Packet Count             DWORD        32              // maximum packet count for all index entries
                 // Index Entries Count              DWORD        32              // number of Index Entries structures
                 // Index Entries                    array of:    variable        //
                 // * Packet Number                  DWORD        32              // number of the Data Packet associated with this index entry
                 // * Packet Count                   WORD         16              // number of Data Packets to sent at this index entry
                 // shortcut
                 $thisfile_asf['simple_index_object'] = array();
                 $thisfile_asf_simpleindexobject =& $thisfile_asf['simple_index_object'];
                 $SimpleIndexObjectData = $NextObjectDataHeader . fread($this->getid3->fp, 56 - 24);
                 $offset = 24;
                 $thisfile_asf_simpleindexobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_simpleindexobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_simpleindexobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_simpleindexobject['fileid'] = substr($SimpleIndexObjectData, $offset, 16);
                 $offset += 16;
                 $thisfile_asf_simpleindexobject['fileid_guid'] = self::BytestringToGUID($thisfile_asf_simpleindexobject['fileid']);
                 $thisfile_asf_simpleindexobject['index_entry_time_interval'] = Helper::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 8));
                 $offset += 8;
                 $thisfile_asf_simpleindexobject['maximum_packet_count'] = Helper::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
                 $offset += 4;
                 $thisfile_asf_simpleindexobject['index_entries_count'] = Helper::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
                 $offset += 4;
                 $IndexEntriesData = $SimpleIndexObjectData . fread($this->getid3->fp, 6 * $thisfile_asf_simpleindexobject['index_entries_count']);
                 for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $thisfile_asf_simpleindexobject['index_entries_count']; ++$IndexEntriesCounter) {
                     $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_number'] = Helper::LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
                     $offset += 4;
                     $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_count'] = Helper::LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
                     $offset += 2;
                 }
                 break;
             case self::$GETID3_ASF_Index_Object:
                 // 6.2 ASF top-level Index Object (optional but recommended when appropriate, 0 or 1)
                 // Field Name                       Field Type   Size (bits)
                 // Object ID                        GUID         128             // GUID for the Index Object - GETID3_ASF_Index_Object
                 // Object Size                      QWORD        64              // Specifies the size, in bytes, of the Index Object, including at least 34 bytes of Index Object header
                 // Index Entry Time Interval        DWORD        32              // Specifies the time interval between each index entry in ms.
                 // Index Specifiers Count           WORD         16              // Specifies the number of Index Specifiers structures in this Index Object.
                 // Index Blocks Count               DWORD        32              // Specifies the number of Index Blocks structures in this Index Object.
                 // Index Entry Time Interval        DWORD        32              // Specifies the time interval between index entries in milliseconds.  This value cannot be 0.
                 // Index Specifiers Count           WORD         16              // Specifies the number of entries in the Index Specifiers list.  Valid values are 1 and greater.
                 // Index Specifiers                 array of:    varies          //
                 // * Stream Number                  WORD         16              // Specifies the stream number that the Index Specifiers refer to. Valid values are between 1 and 127.
                 // * Index Type                     WORD         16              // Specifies Index Type values as follows:
                 //   1 = Nearest Past Data Packet - indexes point to the data packet whose presentation time is closest to the index entry time.
                 //   2 = Nearest Past Media Object - indexes point to the closest data packet containing an entire object or first fragment of an object.
                 //   3 = Nearest Past Cleanpoint. - indexes point to the closest data packet containing an entire object (or first fragment of an object) that has the Cleanpoint Flag set.
                 //   Nearest Past Cleanpoint is the most common type of index.
                 // Index Entry Count                DWORD        32              // Specifies the number of Index Entries in the block.
                 // * Block Positions                QWORD        varies          // Specifies a list of byte offsets of the beginnings of the blocks relative to the beginning of the first Data Packet (i.e., the beginning of the Data Object + 50 bytes). The number of entries in this list is specified by the value of the Index Specifiers Count field. The order of those byte offsets is tied to the order in which Index Specifiers are listed.
                 // * Index Entries                  array of:    varies          //
                 // * * Offsets                      DWORD        varies          // An offset value of 0xffffffff indicates an invalid offset value
                 // shortcut
                 $thisfile_asf['asf_index_object'] = array();
                 $thisfile_asf_asfindexobject =& $thisfile_asf['asf_index_object'];
                 $ASFIndexObjectData = $NextObjectDataHeader . fread($this->getid3->fp, 34 - 24);
                 $offset = 24;
                 $thisfile_asf_asfindexobject['objectid'] = $NextObjectGUID;
                 $thisfile_asf_asfindexobject['objectid_guid'] = $NextObjectGUIDtext;
                 $thisfile_asf_asfindexobject['objectsize'] = $NextObjectSize;
                 $thisfile_asf_asfindexobject['entry_time_interval'] = Helper::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
                 $offset += 4;
                 $thisfile_asf_asfindexobject['index_specifiers_count'] = Helper::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
                 $offset += 2;
                 $thisfile_asf_asfindexobject['index_blocks_count'] = Helper::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
                 $offset += 4;
                 $ASFIndexObjectData .= fread($this->getid3->fp, 4 * $thisfile_asf_asfindexobject['index_specifiers_count']);
                 for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; ++$IndexSpecifiersCounter) {
                     $IndexSpecifierStreamNumber = Helper::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
                     $offset += 2;
                     $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['stream_number'] = $IndexSpecifierStreamNumber;
                     $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type'] = Helper::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
                     $offset += 2;
                     $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type_text'] = $this->ASFIndexObjectIndexTypeLookup($thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type']);
                 }
                 $ASFIndexObjectData .= fread($this->getid3->fp, 4);
                 $thisfile_asf_asfindexobject['index_entry_count'] = Helper::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
                 $offset += 4;
                 $ASFIndexObjectData .= fread($this->getid3->fp, 8 * $thisfile_asf_asfindexobject['index_specifiers_count']);
                 for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; ++$IndexSpecifiersCounter) {
                     $thisfile_asf_asfindexobject['block_positions'][$IndexSpecifiersCounter] = Helper::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8));
                     $offset += 8;
                 }
                 $ASFIndexObjectData .= fread($this->getid3->fp, 4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']);
                 for ($IndexEntryCounter = 0; $IndexEntryCounter < $thisfile_asf_asfindexobject['index_entry_count']; ++$IndexEntryCounter) {
                     for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; ++$IndexSpecifiersCounter) {
                         $thisfile_asf_asfindexobject['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = Helper::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
                         $offset += 4;
                     }
                 }
                 break;
             default:
                 // Implementations shall ignore any standard or non-standard object that they do not know how to handle.
                 if (self::GUIDname($NextObjectGUIDtext)) {
                     $info['warning'][] = 'unhandled GUID "' . self::GUIDname($NextObjectGUIDtext) . '" {' . $NextObjectGUIDtext . '} in ASF body at offset ' . ($offset - 16 - 8);
                 } else {
                     $info['warning'][] = 'unknown GUID {' . $NextObjectGUIDtext . '} in ASF body at offset ' . (ftell($this->getid3->fp) - 16 - 8);
                 }
                 fseek($this->getid3->fp, $NextObjectSize - 16 - 8, SEEK_CUR);
                 break;
         }
     }
     if (isset($thisfile_asf_codeclistobject['codec_entries']) && is_array($thisfile_asf_codeclistobject['codec_entries'])) {
         foreach ($thisfile_asf_codeclistobject['codec_entries'] as $streamnumber => $streamdata) {
             switch ($streamdata['information']) {
                 case 'WMV1':
                 case 'WMV2':
                 case 'WMV3':
                 case 'MSS1':
                 case 'MSS2':
                 case 'WMVA':
                 case 'WVC1':
                 case 'WMVP':
                 case 'WVP2':
                     $thisfile_video['dataformat'] = 'wmv';
                     $info['mime_type'] = 'video/x-ms-wmv';
                     break;
                 case 'MP42':
                 case 'MP43':
                 case 'MP4S':
                 case 'mp4s':
                     $thisfile_video['dataformat'] = 'asf';
                     $info['mime_type'] = 'video/x-ms-asf';
                     break;
                 default:
                     switch ($streamdata['type_raw']) {
                         case 1:
                             if (strstr(self::TrimConvert($streamdata['name']), 'Windows Media')) {
                                 $thisfile_video['dataformat'] = 'wmv';
                                 if ($info['mime_type'] == 'video/x-ms-asf') {
                                     $info['mime_type'] = 'video/x-ms-wmv';
                                 }
                             }
                             break;
                         case 2:
                             if (strstr(self::TrimConvert($streamdata['name']), 'Windows Media')) {
                                 $thisfile_audio['dataformat'] = 'wma';
                                 if ($info['mime_type'] == 'video/x-ms-asf') {
                                     $info['mime_type'] = 'audio/x-ms-wma';
                                 }
                             }
                             break;
                     }
                     break;
             }
         }
     }
     switch (isset($thisfile_audio['codec']) ? $thisfile_audio['codec'] : '') {
         case 'MPEG Layer-3':
             $thisfile_audio['dataformat'] = 'mp3';
             break;
         default:
             break;
     }
     if (isset($thisfile_asf_codeclistobject['codec_entries'])) {
         foreach ($thisfile_asf_codeclistobject['codec_entries'] as $streamnumber => $streamdata) {
             switch ($streamdata['type_raw']) {
                 case 1:
                     // video
                     $thisfile_video['encoder'] = self::TrimConvert($thisfile_asf_codeclistobject['codec_entries'][$streamnumber]['name']);
                     break;
                 case 2:
                     // audio
                     $thisfile_audio['encoder'] = self::TrimConvert($thisfile_asf_codeclistobject['codec_entries'][$streamnumber]['name']);
                     // AH 2003-10-01
                     $thisfile_audio['encoder_options'] = self::TrimConvert($thisfile_asf_codeclistobject['codec_entries'][0]['description']);
                     $thisfile_audio['codec'] = $thisfile_audio['encoder'];
                     break;
                 default:
                     $info['warning'][] = 'Unknown streamtype: [codec_list_object][codec_entries][' . $streamnumber . '][type_raw] == ' . $streamdata['type_raw'];
                     break;
             }
         }
     }
     if (isset($info['audio'])) {
         $thisfile_audio['lossless'] = isset($thisfile_audio['lossless']) ? $thisfile_audio['lossless'] : false;
         $thisfile_audio['dataformat'] = !empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf';
     }
     if (!empty($thisfile_video['dataformat'])) {
         $thisfile_video['lossless'] = isset($thisfile_audio['lossless']) ? $thisfile_audio['lossless'] : false;
         $thisfile_video['pixel_aspect_ratio'] = isset($thisfile_audio['pixel_aspect_ratio']) ? $thisfile_audio['pixel_aspect_ratio'] : (double) 1;
         $thisfile_video['dataformat'] = !empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf';
     }
     if (!empty($thisfile_video['streams'])) {
         $thisfile_video['streams']['resolution_x'] = 0;
         $thisfile_video['streams']['resolution_y'] = 0;
         foreach ($thisfile_video['streams'] as $key => $valuearray) {
             if ($valuearray['resolution_x'] > $thisfile_video['streams']['resolution_x'] || $valuearray['resolution_y'] > $thisfile_video['streams']['resolution_y']) {
                 $thisfile_video['resolution_x'] = $valuearray['resolution_x'];
                 $thisfile_video['resolution_y'] = $valuearray['resolution_y'];
             }
         }
     }
     $info['bitrate'] = (isset($thisfile_audio['bitrate']) ? $thisfile_audio['bitrate'] : 0) + (isset($thisfile_video['bitrate']) ? $thisfile_video['bitrate'] : 0);
     if ((!isset($info['playtime_seconds']) || $info['playtime_seconds'] <= 0) && $info['bitrate'] > 0) {
         $info['playtime_seconds'] = ($info['filesize'] - $info['avdataoffset']) / ($info['bitrate'] / 8);
     }
     return true;
 }
コード例 #3
0
ファイル: Riff.php プロジェクト: Nattpyre/rocketfiles
 /**
  * @return bool
  */
 public function analyze()
 {
     $info =& $this->getid3->info;
     // initialize these values to an empty array, otherwise they default to NULL
     // and you can't append array values to a NULL value
     $info['riff'] = array('raw' => array());
     // Shortcuts
     $thisfile_riff =& $info['riff'];
     $thisfile_riff_raw =& $thisfile_riff['raw'];
     $thisfile_audio =& $info['audio'];
     $thisfile_video =& $info['video'];
     $thisfile_audio_dataformat =& $thisfile_audio['dataformat'];
     $thisfile_riff_audio =& $thisfile_riff['audio'];
     $thisfile_riff_video =& $thisfile_riff['video'];
     $Original['avdataoffset'] = $info['avdataoffset'];
     $Original['avdataend'] = $info['avdataend'];
     fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     $RIFFheader = fread($this->getid3->fp, 12);
     $RIFFsubtype = substr($RIFFheader, 8, 4);
     switch (substr($RIFFheader, 0, 4)) {
         case 'FORM':
             $info['fileformat'] = 'aiff';
             $thisfile_riff['header_size'] = $this->EitherEndian2Int(substr($RIFFheader, 4, 4));
             $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($info['avdataoffset'] + 12, $info['avdataoffset'] + $thisfile_riff['header_size']);
             break;
         case 'RIFF':
             // AVI, WAV, etc
         // AVI, WAV, etc
         case 'SDSS':
             // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
         // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com)
         case 'RMP3':
             // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s
             $info['fileformat'] = 'riff';
             $thisfile_riff['header_size'] = $this->EitherEndian2Int(substr($RIFFheader, 4, 4));
             if ($RIFFsubtype == 'RMP3') {
                 // RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s
                 $RIFFsubtype = 'WAVE';
             }
             $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($info['avdataoffset'] + 12, $info['avdataoffset'] + $thisfile_riff['header_size']);
             if ($info['avdataend'] - $info['filesize'] == 1) {
                 // LiteWave appears to incorrectly *not* pad actual output file
                 // to nearest WORD boundary so may appear to be short by one
                 // byte, in which case - skip warning
                 $info['avdataend'] = $info['filesize'];
             }
             $nextRIFFoffset = $Original['avdataoffset'] + 8 + $thisfile_riff['header_size'];
             // 8 = "RIFF" + 32-bit offset
             while ($nextRIFFoffset < min($info['filesize'], $info['avdataend'])) {
                 if (!Helper::intValueSupported($nextRIFFoffset + 1024)) {
                     $info['error'][] = 'AVI extends beyond ' . round(PHP_INT_MAX / 1073741824) . 'GB and PHP filesystem functions cannot read that far, playtime is probably wrong';
                     $info['warning'][] = '[avdataend] value may be incorrect, multiple AVIX chunks may be present';
                     break;
                 } else {
                     fseek($this->getid3->fp, $nextRIFFoffset, SEEK_SET);
                     $nextRIFFheader = fread($this->getid3->fp, 12);
                     if ($nextRIFFoffset == $info['avdataend'] - 1) {
                         if (substr($nextRIFFheader, 0, 1) == "") {
                             // RIFF padded to WORD boundary, we're actually already at the end
                             break;
                         }
                     }
                     $nextRIFFheaderID = substr($nextRIFFheader, 0, 4);
                     $nextRIFFsize = $this->EitherEndian2Int(substr($nextRIFFheader, 4, 4));
                     $nextRIFFtype = substr($nextRIFFheader, 8, 4);
                     $chunkdata = array();
                     $chunkdata['offset'] = $nextRIFFoffset + 8;
                     $chunkdata['size'] = $nextRIFFsize;
                     $nextRIFFoffset = $chunkdata['offset'] + $chunkdata['size'];
                     switch ($nextRIFFheaderID) {
                         case 'RIFF':
                             $info['avdataend'] = $nextRIFFoffset;
                             if (!Helper::intValueSupported($info['avdataend'])) {
                                 $info['error'][] = 'AVI extends beyond ' . round(PHP_INT_MAX / 1073741824) . 'GB and PHP filesystem functions cannot read that far, playtime is probably wrong';
                                 $info['warning'][] = '[avdataend] value may be incorrect, multiple AVIX chunks may be present';
                             }
                             $chunkdata['chunks'] = $this->ParseRIFF($chunkdata['offset'] + 4, $chunkdata['offset'] + $chunkdata['size']);
                             if (!isset($thisfile_riff[$nextRIFFtype])) {
                                 $thisfile_riff[$nextRIFFtype] = array();
                             }
                             $thisfile_riff[$nextRIFFtype][] = $chunkdata;
                             break;
                         case 'JUNK':
                             // ignore
                             $thisfile_riff[$nextRIFFheaderID][] = $chunkdata;
                             break;
                         default:
                             if ($info['filesize'] == $chunkdata['offset'] - 8 + 128) {
                                 $DIVXTAG = $nextRIFFheader . fread($this->getid3->fp, 128 - 12);
                                 if (substr($DIVXTAG, -7) == 'DIVXTAG') {
                                     // DIVXTAG is supposed to be inside an IDVX chunk in a LIST chunk, but some bad encoders just slap it on the end of a file
                                     $info['warning'][] = 'Found wrongly-structured DIVXTAG at offset ' . (ftell($this->getid3->fp) - 128 + 12) . ', parsing anyway';
                                     $thisfile_riff['DIVXTAG'] = $this->ParseDIVXTAG($DIVXTAG);
                                     foreach ($thisfile_riff['DIVXTAG'] as $key => $value) {
                                         if ($value && !preg_match('#_id$#', $key)) {
                                             $thisfile_riff['comments'][$key][] = $value;
                                         }
                                     }
                                     break 2;
                                 }
                             }
                             $info['warning'][] = 'expecting "RIFF" or "JUNK" at ' . $nextRIFFoffset . ', found ' . Helper::PrintHexBytes(substr($nextRIFFheader, 0, 4)) . ' - skipping rest of file';
                             break 2;
                     }
                 }
             }
             if ($RIFFsubtype == 'WAVE') {
                 $thisfile_riff_WAVE =& $thisfile_riff['WAVE'];
             }
             break;
         default:
             $info['error'][] = 'Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "' . $RIFFsubtype . '" instead';
             unset($info['fileformat']);
             return false;
             break;
     }
     $streamindex = 0;
     switch ($RIFFsubtype) {
         case 'WAVE':
             if (empty($thisfile_audio['bitrate_mode'])) {
                 $thisfile_audio['bitrate_mode'] = 'cbr';
             }
             if (empty($thisfile_audio_dataformat)) {
                 $thisfile_audio_dataformat = 'wav';
             }
             if (isset($thisfile_riff_WAVE['data'][0]['offset'])) {
                 $info['avdataoffset'] = $thisfile_riff_WAVE['data'][0]['offset'] + 8;
                 $info['avdataend'] = $info['avdataoffset'] + $thisfile_riff_WAVE['data'][0]['size'];
             }
             if (isset($thisfile_riff_WAVE['fmt '][0]['data'])) {
                 $thisfile_riff_audio[$streamindex] = self::RIFFparseWAVEFORMATex($thisfile_riff_WAVE['fmt '][0]['data']);
                 $thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
                 if (!isset($thisfile_riff_audio[$streamindex]['bitrate']) || $thisfile_riff_audio[$streamindex]['bitrate'] == 0) {
                     $info['error'][] = 'Corrupt RIFF file: bitrate_audio == zero';
                     return false;
                 }
                 $thisfile_riff_raw['fmt '] = $thisfile_riff_audio[$streamindex]['raw'];
                 unset($thisfile_riff_audio[$streamindex]['raw']);
                 $thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex];
                 $thisfile_audio = Helper::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
                 if (substr($thisfile_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') {
                     $info['warning'][] = 'Audio codec = ' . $thisfile_audio['codec'];
                 }
                 $thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
                 $info['playtime_seconds'] = (double) (($info['avdataend'] - $info['avdataoffset']) * 8 / $thisfile_audio['bitrate']);
                 $thisfile_audio['lossless'] = false;
                 if (isset($thisfile_riff_WAVE['data'][0]['offset']) && isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
                     switch ($thisfile_riff_raw['fmt ']['wFormatTag']) {
                         case 0x1:
                             // PCM
                             $thisfile_audio['lossless'] = true;
                             break;
                         case 0x2000:
                             // AC-3
                             $thisfile_audio_dataformat = 'ac3';
                             break;
                         default:
                             // do nothing
                             break;
                     }
                 }
                 $thisfile_audio['streams'][$streamindex]['wformattag'] = $thisfile_audio['wformattag'];
                 $thisfile_audio['streams'][$streamindex]['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
                 $thisfile_audio['streams'][$streamindex]['lossless'] = $thisfile_audio['lossless'];
                 $thisfile_audio['streams'][$streamindex]['dataformat'] = $thisfile_audio_dataformat;
             }
             if (isset($thisfile_riff_WAVE['rgad'][0]['data'])) {
                 // shortcuts
                 $rgadData =& $thisfile_riff_WAVE['rgad'][0]['data'];
                 $thisfile_riff_raw['rgad'] = array('track' => array(), 'album' => array());
                 $thisfile_riff_raw_rgad =& $thisfile_riff_raw['rgad'];
                 $thisfile_riff_raw_rgad_track =& $thisfile_riff_raw_rgad['track'];
                 $thisfile_riff_raw_rgad_album =& $thisfile_riff_raw_rgad['album'];
                 $thisfile_riff_raw_rgad['fPeakAmplitude'] = Helper::LittleEndian2Float(substr($rgadData, 0, 4));
                 $thisfile_riff_raw_rgad['nRadioRgAdjust'] = $this->EitherEndian2Int(substr($rgadData, 4, 2));
                 $thisfile_riff_raw_rgad['nAudiophileRgAdjust'] = $this->EitherEndian2Int(substr($rgadData, 6, 2));
                 $nRadioRgAdjustBitstring = str_pad(Helper::Dec2Bin($thisfile_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT);
                 $nAudiophileRgAdjustBitstring = str_pad(Helper::Dec2Bin($thisfile_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT);
                 $thisfile_riff_raw_rgad_track['name'] = Helper::Bin2Dec(substr($nRadioRgAdjustBitstring, 0, 3));
                 $thisfile_riff_raw_rgad_track['originator'] = Helper::Bin2Dec(substr($nRadioRgAdjustBitstring, 3, 3));
                 $thisfile_riff_raw_rgad_track['signbit'] = Helper::Bin2Dec(substr($nRadioRgAdjustBitstring, 6, 1));
                 $thisfile_riff_raw_rgad_track['adjustment'] = Helper::Bin2Dec(substr($nRadioRgAdjustBitstring, 7, 9));
                 $thisfile_riff_raw_rgad_album['name'] = Helper::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 0, 3));
                 $thisfile_riff_raw_rgad_album['originator'] = Helper::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 3, 3));
                 $thisfile_riff_raw_rgad_album['signbit'] = Helper::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 6, 1));
                 $thisfile_riff_raw_rgad_album['adjustment'] = Helper::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 7, 9));
                 $thisfile_riff['rgad']['peakamplitude'] = $thisfile_riff_raw_rgad['fPeakAmplitude'];
                 if ($thisfile_riff_raw_rgad_track['name'] != 0 && $thisfile_riff_raw_rgad_track['originator'] != 0) {
                     $thisfile_riff['rgad']['track']['name'] = Helper::RGADnameLookup($thisfile_riff_raw_rgad_track['name']);
                     $thisfile_riff['rgad']['track']['originator'] = Helper::RGADoriginatorLookup($thisfile_riff_raw_rgad_track['originator']);
                     $thisfile_riff['rgad']['track']['adjustment'] = Helper::RGADadjustmentLookup($thisfile_riff_raw_rgad_track['adjustment'], $thisfile_riff_raw_rgad_track['signbit']);
                 }
                 if ($thisfile_riff_raw_rgad_album['name'] != 0 && $thisfile_riff_raw_rgad_album['originator'] != 0) {
                     $thisfile_riff['rgad']['album']['name'] = Helper::RGADnameLookup($thisfile_riff_raw_rgad_album['name']);
                     $thisfile_riff['rgad']['album']['originator'] = Helper::RGADoriginatorLookup($thisfile_riff_raw_rgad_album['originator']);
                     $thisfile_riff['rgad']['album']['adjustment'] = Helper::RGADadjustmentLookup($thisfile_riff_raw_rgad_album['adjustment'], $thisfile_riff_raw_rgad_album['signbit']);
                 }
             }
             if (isset($thisfile_riff_WAVE['fact'][0]['data'])) {
                 $thisfile_riff_raw['fact']['NumberOfSamples'] = $this->EitherEndian2Int(substr($thisfile_riff_WAVE['fact'][0]['data'], 0, 4));
                 // This should be a good way of calculating exact playtime,
                 // but some sample files have had incorrect number of samples,
                 // so cannot use this method
                 // if (!empty($thisfile_riff_raw['fmt ']['nSamplesPerSec'])) {
                 //     $info['playtime_seconds'] = (float) $thisfile_riff_raw['fact']['NumberOfSamples'] / $thisfile_riff_raw['fmt ']['nSamplesPerSec'];
                 // }
             }
             if (!empty($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'])) {
                 $thisfile_audio['bitrate'] = Helper::CastAsInt($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'] * 8);
             }
             if (isset($thisfile_riff_WAVE['bext'][0]['data'])) {
                 // shortcut
                 $thisfile_riff_WAVE_bext_0 =& $thisfile_riff_WAVE['bext'][0];
                 $thisfile_riff_WAVE_bext_0['title'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 0, 256));
                 $thisfile_riff_WAVE_bext_0['author'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 256, 32));
                 $thisfile_riff_WAVE_bext_0['reference'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 288, 32));
                 $thisfile_riff_WAVE_bext_0['origin_date'] = substr($thisfile_riff_WAVE_bext_0['data'], 320, 10);
                 $thisfile_riff_WAVE_bext_0['origin_time'] = substr($thisfile_riff_WAVE_bext_0['data'], 330, 8);
                 $thisfile_riff_WAVE_bext_0['time_reference'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 338, 8));
                 $thisfile_riff_WAVE_bext_0['bwf_version'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 346, 1));
                 $thisfile_riff_WAVE_bext_0['reserved'] = substr($thisfile_riff_WAVE_bext_0['data'], 347, 254);
                 $thisfile_riff_WAVE_bext_0['coding_history'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_bext_0['data'], 601)));
                 if (preg_match('#^([0-9]{4}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_date'], $matches_bext_date)) {
                     if (preg_match('#^([0-9]{2}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_time'], $matches_bext_time)) {
                         list($dummy, $bext_timestamp['year'], $bext_timestamp['month'], $bext_timestamp['day']) = $matches_bext_date;
                         list($dummy, $bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second']) = $matches_bext_time;
                         $thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime($bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second'], $bext_timestamp['month'], $bext_timestamp['day'], $bext_timestamp['year']);
                     } else {
                         $info['warning'][] = 'RIFF.WAVE.BEXT.origin_time is invalid';
                     }
                 } else {
                     $info['warning'][] = 'RIFF.WAVE.BEXT.origin_date is invalid';
                 }
                 $thisfile_riff['comments']['author'][] = $thisfile_riff_WAVE_bext_0['author'];
                 $thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_bext_0['title'];
             }
             if (isset($thisfile_riff_WAVE['MEXT'][0]['data'])) {
                 // shortcut
                 $thisfile_riff_WAVE_MEXT_0 =& $thisfile_riff_WAVE['MEXT'][0];
                 $thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 0, 2));
                 $thisfile_riff_WAVE_MEXT_0['flags']['homogenous'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x1);
                 if ($thisfile_riff_WAVE_MEXT_0['flags']['homogenous']) {
                     $thisfile_riff_WAVE_MEXT_0['flags']['padding'] = $thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x2 ? false : true;
                     $thisfile_riff_WAVE_MEXT_0['flags']['22_or_44'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x4);
                     $thisfile_riff_WAVE_MEXT_0['flags']['free_format'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x8);
                     $thisfile_riff_WAVE_MEXT_0['nominal_frame_size'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 2, 2));
                 }
                 $thisfile_riff_WAVE_MEXT_0['anciliary_data_length'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 6, 2));
                 $thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 8, 2));
                 $thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_left'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x1);
                 $thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_free'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x2);
                 $thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_right'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x4);
             }
             if (isset($thisfile_riff_WAVE['cart'][0]['data'])) {
                 // shortcut
                 $thisfile_riff_WAVE_cart_0 =& $thisfile_riff_WAVE['cart'][0];
                 $thisfile_riff_WAVE_cart_0['version'] = substr($thisfile_riff_WAVE_cart_0['data'], 0, 4);
                 $thisfile_riff_WAVE_cart_0['title'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 4, 64));
                 $thisfile_riff_WAVE_cart_0['artist'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 68, 64));
                 $thisfile_riff_WAVE_cart_0['cut_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 132, 64));
                 $thisfile_riff_WAVE_cart_0['client_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 196, 64));
                 $thisfile_riff_WAVE_cart_0['category'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 260, 64));
                 $thisfile_riff_WAVE_cart_0['classification'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 324, 64));
                 $thisfile_riff_WAVE_cart_0['out_cue'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 388, 64));
                 $thisfile_riff_WAVE_cart_0['start_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 452, 10));
                 $thisfile_riff_WAVE_cart_0['start_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 462, 8));
                 $thisfile_riff_WAVE_cart_0['end_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 470, 10));
                 $thisfile_riff_WAVE_cart_0['end_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 480, 8));
                 $thisfile_riff_WAVE_cart_0['producer_app_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 488, 64));
                 $thisfile_riff_WAVE_cart_0['producer_app_version'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 552, 64));
                 $thisfile_riff_WAVE_cart_0['user_defined_text'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 616, 64));
                 $thisfile_riff_WAVE_cart_0['zero_db_reference'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE_cart_0['data'], 680, 4), true);
                 for ($i = 0; $i < 8; ++$i) {
                     $thisfile_riff_WAVE_cart_0['post_time'][$i]['usage_fourcc'] = substr($thisfile_riff_WAVE_cart_0['data'], 684 + $i * 8, 4);
                     $thisfile_riff_WAVE_cart_0['post_time'][$i]['timer_value'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE_cart_0['data'], 684 + $i * 8 + 4, 4));
                 }
                 $thisfile_riff_WAVE_cart_0['url'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 748, 1024));
                 $thisfile_riff_WAVE_cart_0['tag_text'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_cart_0['data'], 1772)));
                 $thisfile_riff['comments']['artist'][] = $thisfile_riff_WAVE_cart_0['artist'];
                 $thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_cart_0['title'];
             }
             if (isset($thisfile_riff_WAVE['SNDM'][0]['data'])) {
                 // SoundMiner metadata
                 // shortcuts
                 $thisfile_riff_WAVE_SNDM_0 =& $thisfile_riff_WAVE['SNDM'][0];
                 $thisfile_riff_WAVE_SNDM_0_data =& $thisfile_riff_WAVE_SNDM_0['data'];
                 $SNDM_startoffset = 0;
                 $SNDM_endoffset = $thisfile_riff_WAVE_SNDM_0['size'];
                 while ($SNDM_startoffset < $SNDM_endoffset) {
                     $SNDM_thisTagOffset = 0;
                     $SNDM_thisTagSize = Helper::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 4));
                     $SNDM_thisTagOffset += 4;
                     $SNDM_thisTagKey = substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 4);
                     $SNDM_thisTagOffset += 4;
                     $SNDM_thisTagDataSize = Helper::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 2));
                     $SNDM_thisTagOffset += 2;
                     $SNDM_thisTagDataFlags = Helper::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 2));
                     $SNDM_thisTagOffset += 2;
                     $SNDM_thisTagDataText = substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, $SNDM_thisTagDataSize);
                     $SNDM_thisTagOffset += $SNDM_thisTagDataSize;
                     if ($SNDM_thisTagSize != 4 + 4 + 2 + 2 + $SNDM_thisTagDataSize) {
                         $info['warning'][] = 'RIFF.WAVE.SNDM.data contains tag not expected length (expected: ' . $SNDM_thisTagSize . ', found: ' . (4 + 4 + 2 + 2 + $SNDM_thisTagDataSize) . ') at offset ' . $SNDM_startoffset . ' (file offset ' . ($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset) . ')';
                         break;
                     } elseif ($SNDM_thisTagSize <= 0) {
                         $info['warning'][] = 'RIFF.WAVE.SNDM.data contains zero-size tag at offset ' . $SNDM_startoffset . ' (file offset ' . ($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset) . ')';
                         break;
                     }
                     $SNDM_startoffset += $SNDM_thisTagSize;
                     $thisfile_riff_WAVE_SNDM_0['parsed_raw'][$SNDM_thisTagKey] = $SNDM_thisTagDataText;
                     if ($parsedkey = $this->RIFFwaveSNDMtagLookup($SNDM_thisTagKey)) {
                         $thisfile_riff_WAVE_SNDM_0['parsed'][$parsedkey] = $SNDM_thisTagDataText;
                     } else {
                         $info['warning'][] = 'RIFF.WAVE.SNDM contains unknown tag "' . $SNDM_thisTagKey . '" at offset ' . $SNDM_startoffset . ' (file offset ' . ($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset) . ')';
                     }
                 }
                 $tagmapping = array('tracktitle' => 'title', 'category' => 'genre', 'cdtitle' => 'album', 'tracktitle' => 'title');
                 foreach ($tagmapping as $fromkey => $tokey) {
                     if (isset($thisfile_riff_WAVE_SNDM_0['parsed'][$fromkey])) {
                         $thisfile_riff['comments'][$tokey][] = $thisfile_riff_WAVE_SNDM_0['parsed'][$fromkey];
                     }
                 }
             }
             if (isset($thisfile_riff_WAVE['iXML'][0]['data'])) {
                 // requires functions simplexml_load_string and get_object_vars
                 if ($parsedXML = Helper::XML2array($thisfile_riff_WAVE['iXML'][0]['data'])) {
                     $thisfile_riff_WAVE['iXML'][0]['parsed'] = $parsedXML;
                     if (isset($parsedXML['SPEED']['MASTER_SPEED'])) {
                         @(list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['MASTER_SPEED']));
                         $thisfile_riff_WAVE['iXML'][0]['master_speed'] = $numerator / ($denominator ? $denominator : 1000);
                     }
                     if (isset($parsedXML['SPEED']['TIMECODE_RATE'])) {
                         @(list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['TIMECODE_RATE']));
                         $thisfile_riff_WAVE['iXML'][0]['timecode_rate'] = $numerator / ($denominator ? $denominator : 1000);
                     }
                     if (isset($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO']) && !empty($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) && !empty($thisfile_riff_WAVE['iXML'][0]['timecode_rate'])) {
                         $samples_since_midnight = floatval(ltrim($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_HI'] . $parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO'], '0'));
                         $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] = $samples_since_midnight / $parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE'];
                         $h = floor($thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] / 3600);
                         $m = floor(($thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - $h * 3600) / 60);
                         $s = floor($thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - $h * 3600 - $m * 60);
                         $f = ($thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - $h * 3600 - $m * 60 - $s) * $thisfile_riff_WAVE['iXML'][0]['timecode_rate'];
                         $thisfile_riff_WAVE['iXML'][0]['timecode_string'] = sprintf('%02d:%02d:%02d:%05.2f', $h, $m, $s, $f);
                         $thisfile_riff_WAVE['iXML'][0]['timecode_string_round'] = sprintf('%02d:%02d:%02d:%02d', $h, $m, $s, round($f));
                     }
                     unset($parsedXML);
                 }
             }
             if (!isset($thisfile_audio['bitrate']) && isset($thisfile_riff_audio[$streamindex]['bitrate'])) {
                 $thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate'];
                 $info['playtime_seconds'] = (double) (($info['avdataend'] - $info['avdataoffset']) * 8 / $thisfile_audio['bitrate']);
             }
             if (!empty($info['wavpack'])) {
                 $thisfile_audio_dataformat = 'wavpack';
                 $thisfile_audio['bitrate_mode'] = 'vbr';
                 $thisfile_audio['encoder'] = 'WavPack v' . $info['wavpack']['version'];
                 // Reset to the way it was - RIFF parsing will have messed this up
                 $info['avdataend'] = $Original['avdataend'];
                 $thisfile_audio['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];
                 fseek($this->getid3->fp, $info['avdataoffset'] - 44, SEEK_SET);
                 $RIFFdata = fread($this->getid3->fp, 44);
                 $OrignalRIFFheaderSize = Helper::LittleEndian2Int(substr($RIFFdata, 4, 4)) + 8;
                 $OrignalRIFFdataSize = Helper::LittleEndian2Int(substr($RIFFdata, 40, 4)) + 44;
                 if ($OrignalRIFFheaderSize > $OrignalRIFFdataSize) {
                     $info['avdataend'] -= $OrignalRIFFheaderSize - $OrignalRIFFdataSize;
                     fseek($this->getid3->fp, $info['avdataend'], SEEK_SET);
                     $RIFFdata .= fread($this->getid3->fp, $OrignalRIFFheaderSize - $OrignalRIFFdataSize);
                 }
                 // move the data chunk after all other chunks (if any)
                 // so that the RIFF parser doesn't see EOF when trying
                 // to skip over the data chunk
                 $RIFFdata = substr($RIFFdata, 0, 36) . substr($RIFFdata, 44) . substr($RIFFdata, 36, 8);
                 $getid3_riff = new self($this->getid3);
                 $getid3_riff->ParseRIFFdata($RIFFdata);
                 unset($getid3_riff);
             }
             if (isset($thisfile_riff_raw['fmt ']['wFormatTag'])) {
                 switch ($thisfile_riff_raw['fmt ']['wFormatTag']) {
                     case 0x1:
                         // PCM
                         if (!empty($info['ac3'])) {
                             // Dolby Digital WAV files masquerade as PCM-WAV, but they're not
                             $thisfile_audio['wformattag'] = 0x2000;
                             $thisfile_audio['codec'] = $this->RIFFwFormatTagLookup($thisfile_audio['wformattag']);
                             $thisfile_audio['lossless'] = false;
                             $thisfile_audio['bitrate'] = $info['ac3']['bitrate'];
                             $thisfile_audio['sample_rate'] = $info['ac3']['sample_rate'];
                         }
                         break;
                     case 0x8ae:
                         // ClearJump LiteWave
                         $thisfile_audio['bitrate_mode'] = 'vbr';
                         $thisfile_audio_dataformat = 'litewave';
                         //typedef struct tagSLwFormat {
                         //  WORD    m_wCompFormat;     // low byte defines compression method, high byte is compression flags
                         //  DWORD   m_dwScale;         // scale factor for lossy compression
                         //  DWORD   m_dwBlockSize;     // number of samples in encoded blocks
                         //  WORD    m_wQuality;        // alias for the scale factor
                         //  WORD    m_wMarkDistance;   // distance between marks in bytes
                         //  WORD    m_wReserved;
                         //
                         //  //following paramters are ignored if CF_FILESRC is not set
                         //  DWORD   m_dwOrgSize;       // original file size in bytes
                         //  WORD    m_bFactExists;     // indicates if 'fact' chunk exists in the original file
                         //  DWORD   m_dwRiffChunkSize; // riff chunk size in the original file
                         //
                         //  PCMWAVEFORMAT m_OrgWf;     // original wave format
                         // }SLwFormat, *PSLwFormat;
                         // shortcut
                         $thisfile_riff['litewave']['raw'] = array();
                         $thisfile_riff_litewave =& $thisfile_riff['litewave'];
                         $thisfile_riff_litewave_raw =& $thisfile_riff_litewave['raw'];
                         $thisfile_riff_litewave_raw['compression_method'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 18, 1));
                         $thisfile_riff_litewave_raw['compression_flags'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 19, 1));
                         $thisfile_riff_litewave_raw['m_dwScale'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 20, 4));
                         $thisfile_riff_litewave_raw['m_dwBlockSize'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 24, 4));
                         $thisfile_riff_litewave_raw['m_wQuality'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 28, 2));
                         $thisfile_riff_litewave_raw['m_wMarkDistance'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 30, 2));
                         $thisfile_riff_litewave_raw['m_wReserved'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 32, 2));
                         $thisfile_riff_litewave_raw['m_dwOrgSize'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 34, 4));
                         $thisfile_riff_litewave_raw['m_bFactExists'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 38, 2));
                         $thisfile_riff_litewave_raw['m_dwRiffChunkSize'] = Helper::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], 40, 4));
                         //$thisfile_riff_litewave['quality_factor'] = intval(round((2000 - $thisfile_riff_litewave_raw['m_dwScale']) / 20));
                         $thisfile_riff_litewave['quality_factor'] = $thisfile_riff_litewave_raw['m_wQuality'];
                         $thisfile_riff_litewave['flags']['raw_source'] = $thisfile_riff_litewave_raw['compression_flags'] & 0x1 ? false : true;
                         $thisfile_riff_litewave['flags']['vbr_blocksize'] = $thisfile_riff_litewave_raw['compression_flags'] & 0x2 ? false : true;
                         $thisfile_riff_litewave['flags']['seekpoints'] = (bool) ($thisfile_riff_litewave_raw['compression_flags'] & 0x4);
                         $thisfile_audio['lossless'] = $thisfile_riff_litewave_raw['m_wQuality'] == 100 ? true : false;
                         $thisfile_audio['encoder_options'] = '-q' . $thisfile_riff_litewave['quality_factor'];
                         break;
                     default:
                         break;
                 }
             }
             if ($info['avdataend'] > $info['filesize']) {
                 switch (!empty($thisfile_audio_dataformat) ? $thisfile_audio_dataformat : '') {
                     case 'wavpack':
                         // WavPack
                     // WavPack
                     case 'lpac':
                         // LPAC
                     // LPAC
                     case 'ofr':
                         // OptimFROG
                     // OptimFROG
                     case 'ofs':
                         // OptimFROG DualStream
                         // lossless compressed audio formats that keep original RIFF headers - skip warning
                         break;
                     case 'litewave':
                         if ($info['avdataend'] - $info['filesize'] == 1) {
                             // LiteWave appears to incorrectly *not* pad actual output file
                             // to nearest WORD boundary so may appear to be short by one
                             // byte, in which case - skip warning
                         } else {
                             // Short by more than one byte, throw warning
                             $info['warning'][] = 'Probably truncated file - expecting ' . $thisfile_riff[$RIFFsubtype]['data'][0]['size'] . ' bytes of data, only found ' . ($info['filesize'] - $info['avdataoffset']) . ' (short by ' . ($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])) . ' bytes)';
                             $info['avdataend'] = $info['filesize'];
                         }
                         break;
                     default:
                         if ($info['avdataend'] - $info['filesize'] == 1 && $thisfile_riff[$RIFFsubtype]['data'][0]['size'] % 2 == 0 && ($info['filesize'] - $info['avdataoffset']) % 2 == 1) {
                             // output file appears to be incorrectly *not* padded to nearest WORD boundary
                             // Output less severe warning
                             $info['warning'][] = 'File should probably be padded to nearest WORD boundary, but it is not (expecting ' . $thisfile_riff[$RIFFsubtype]['data'][0]['size'] . ' bytes of data, only found ' . ($info['filesize'] - $info['avdataoffset']) . ' therefore short by ' . ($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])) . ' bytes)';
                             $info['avdataend'] = $info['filesize'];
                         } else {
                             // Short by more than one byte, throw warning
                             $info['warning'][] = 'Probably truncated file - expecting ' . $thisfile_riff[$RIFFsubtype]['data'][0]['size'] . ' bytes of data, only found ' . ($info['filesize'] - $info['avdataoffset']) . ' (short by ' . ($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])) . ' bytes)';
                             $info['avdataend'] = $info['filesize'];
                         }
                         break;
                 }
             }
             if (!empty($info['mpeg']['audio']['LAME']['audio_bytes'])) {
                 if ($info['avdataend'] - $info['avdataoffset'] - $info['mpeg']['audio']['LAME']['audio_bytes'] == 1) {
                     --$info['avdataend'];
                     $info['warning'][] = 'Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored';
                 }
             }
             if (isset($thisfile_audio_dataformat) && $thisfile_audio_dataformat == 'ac3') {
                 unset($thisfile_audio['bits_per_sample']);
                 if (!empty($info['ac3']['bitrate']) && $info['ac3']['bitrate'] != $thisfile_audio['bitrate']) {
                     $thisfile_audio['bitrate'] = $info['ac3']['bitrate'];
                 }
             }
             break;
         case 'AVI ':
             $thisfile_video['bitrate_mode'] = 'vbr';
             // maybe not, but probably
             $thisfile_video['dataformat'] = 'avi';
             $info['mime_type'] = 'video/avi';
             if (isset($thisfile_riff[$RIFFsubtype]['movi']['offset'])) {
                 $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['movi']['offset'] + 8;
                 if (isset($thisfile_riff['AVIX'])) {
                     $info['avdataend'] = $thisfile_riff['AVIX'][count($thisfile_riff['AVIX']) - 1]['chunks']['movi']['offset'] + $thisfile_riff['AVIX'][count($thisfile_riff['AVIX']) - 1]['chunks']['movi']['size'];
                 } else {
                     $info['avdataend'] = $thisfile_riff['AVI ']['movi']['offset'] + $thisfile_riff['AVI ']['movi']['size'];
                 }
                 if ($info['avdataend'] > $info['filesize']) {
                     $info['warning'][] = 'Probably truncated file - expecting ' . ($info['avdataend'] - $info['avdataoffset']) . ' bytes of data, only found ' . ($info['filesize'] - $info['avdataoffset']) . ' (short by ' . ($info['avdataend'] - $info['filesize']) . ' bytes)';
                     $info['avdataend'] = $info['filesize'];
                 }
             }
             if (isset($thisfile_riff['AVI ']['hdrl']['strl']['indx'])) {
                 //$bIndexType = array(
                 //    0x00 => 'AVI_INDEX_OF_INDEXES',
                 //	0x01 => 'AVI_INDEX_OF_CHUNKS',
                 //	0x80 => 'AVI_INDEX_IS_DATA',
                 //);
                 //$bIndexSubtype = array(
                 //	0x01 => array(
                 //		0x01 => 'AVI_INDEX_2FIELD',
                 //	),
                 //);
                 foreach ($thisfile_riff['AVI ']['hdrl']['strl']['indx'] as $streamnumber => $steamdataarray) {
                     $thisfile_riff_avi_hdrl_strl_indx_stream_data =& $thisfile_riff['AVI ']['hdrl']['strl']['indx'][$streamnumber]['data'];
                     $thisfile_riff_raw['indx'][$streamnumber]['wLongsPerEntry'] = $this->EitherEndian2Int(substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 0, 2));
                     $thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType'] = $this->EitherEndian2Int(substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 2, 1));
                     $thisfile_riff_raw['indx'][$streamnumber]['bIndexType'] = $this->EitherEndian2Int(substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 3, 1));
                     $thisfile_riff_raw['indx'][$streamnumber]['nEntriesInUse'] = $this->EitherEndian2Int(substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 4, 4));
                     $thisfile_riff_raw['indx'][$streamnumber]['dwChunkId'] = substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 8, 4);
                     $thisfile_riff_raw['indx'][$streamnumber]['dwReserved'] = $this->EitherEndian2Int(substr($thisfile_riff_avi_hdrl_strl_indx_stream_data, 12, 4));
                     //$thisfile_riff_raw['indx'][$streamnumber]['bIndexType_name']    =    $bIndexType[$thisfile_riff_raw['indx'][$streamnumber]['bIndexType']];
                     //$thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType_name'] = $bIndexSubtype[$thisfile_riff_raw['indx'][$streamnumber]['bIndexType']][$thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType']];
                     unset($thisfile_riff_avi_hdrl_strl_indx_stream_data);
                 }
             }
             if (isset($thisfile_riff['AVI ']['hdrl']['avih'][$streamindex]['data'])) {
                 $avihData = $thisfile_riff['AVI ']['hdrl']['avih'][$streamindex]['data'];
                 // shortcut
                 $thisfile_riff_raw['avih'] = array();
                 $thisfile_riff_raw_avih =& $thisfile_riff_raw['avih'];
                 $thisfile_riff_raw_avih['dwMicroSecPerFrame'] = $this->EitherEndian2Int(substr($avihData, 0, 4));
                 // frame display rate (or 0L)
                 if ($thisfile_riff_raw_avih['dwMicroSecPerFrame'] == 0) {
                     $info['error'][] = 'Corrupt RIFF file: avih.dwMicroSecPerFrame == zero';
                     return false;
                 }
                 $thisfile_riff_raw_avih['dwMaxBytesPerSec'] = $this->EitherEndian2Int(substr($avihData, 4, 4));
                 // max. transfer rate
                 $thisfile_riff_raw_avih['dwPaddingGranularity'] = $this->EitherEndian2Int(substr($avihData, 8, 4));
                 // pad to multiples of this size; normally 2K.
                 $thisfile_riff_raw_avih['dwFlags'] = $this->EitherEndian2Int(substr($avihData, 12, 4));
                 // the ever-present flags
                 $thisfile_riff_raw_avih['dwTotalFrames'] = $this->EitherEndian2Int(substr($avihData, 16, 4));
                 // # frames in file
                 $thisfile_riff_raw_avih['dwInitialFrames'] = $this->EitherEndian2Int(substr($avihData, 20, 4));
                 $thisfile_riff_raw_avih['dwStreams'] = $this->EitherEndian2Int(substr($avihData, 24, 4));
                 $thisfile_riff_raw_avih['dwSuggestedBufferSize'] = $this->EitherEndian2Int(substr($avihData, 28, 4));
                 $thisfile_riff_raw_avih['dwWidth'] = $this->EitherEndian2Int(substr($avihData, 32, 4));
                 $thisfile_riff_raw_avih['dwHeight'] = $this->EitherEndian2Int(substr($avihData, 36, 4));
                 $thisfile_riff_raw_avih['dwScale'] = $this->EitherEndian2Int(substr($avihData, 40, 4));
                 $thisfile_riff_raw_avih['dwRate'] = $this->EitherEndian2Int(substr($avihData, 44, 4));
                 $thisfile_riff_raw_avih['dwStart'] = $this->EitherEndian2Int(substr($avihData, 48, 4));
                 $thisfile_riff_raw_avih['dwLength'] = $this->EitherEndian2Int(substr($avihData, 52, 4));
                 $thisfile_riff_raw_avih['flags']['hasindex'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x10);
                 $thisfile_riff_raw_avih['flags']['mustuseindex'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x20);
                 $thisfile_riff_raw_avih['flags']['interleaved'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x100);
                 $thisfile_riff_raw_avih['flags']['trustcktype'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x800);
                 $thisfile_riff_raw_avih['flags']['capturedfile'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x10000);
                 $thisfile_riff_raw_avih['flags']['copyrighted'] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & 0x20010);
                 // shortcut
                 $thisfile_riff_video[$streamindex] = array();
                 $thisfile_riff_video_current =& $thisfile_riff_video[$streamindex];
                 if ($thisfile_riff_raw_avih['dwWidth'] > 0) {
                     $thisfile_riff_video_current['frame_width'] = $thisfile_riff_raw_avih['dwWidth'];
                     $thisfile_video['resolution_x'] = $thisfile_riff_video_current['frame_width'];
                 }
                 if ($thisfile_riff_raw_avih['dwHeight'] > 0) {
                     $thisfile_riff_video_current['frame_height'] = $thisfile_riff_raw_avih['dwHeight'];
                     $thisfile_video['resolution_y'] = $thisfile_riff_video_current['frame_height'];
                 }
                 if ($thisfile_riff_raw_avih['dwTotalFrames'] > 0) {
                     $thisfile_riff_video_current['total_frames'] = $thisfile_riff_raw_avih['dwTotalFrames'];
                     $thisfile_video['total_frames'] = $thisfile_riff_video_current['total_frames'];
                 }
                 $thisfile_riff_video_current['frame_rate'] = round(1000000 / $thisfile_riff_raw_avih['dwMicroSecPerFrame'], 3);
                 $thisfile_video['frame_rate'] = $thisfile_riff_video_current['frame_rate'];
             }
             if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][0]['data'])) {
                 if (is_array($thisfile_riff['AVI ']['hdrl']['strl']['strh'])) {
                     for ($i = 0; $i < count($thisfile_riff['AVI ']['hdrl']['strl']['strh']); ++$i) {
                         if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'])) {
                             $strhData = $thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'];
                             $strhfccType = substr($strhData, 0, 4);
                             if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'])) {
                                 $strfData = $thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'];
                                 // shortcut
                                 $thisfile_riff_raw_strf_strhfccType_streamindex =& $thisfile_riff_raw['strf'][$strhfccType][$streamindex];
                                 switch ($strhfccType) {
                                     case 'auds':
                                         $thisfile_audio['bitrate_mode'] = 'cbr';
                                         $thisfile_audio_dataformat = 'wav';
                                         if (isset($thisfile_riff_audio) && is_array($thisfile_riff_audio)) {
                                             $streamindex = count($thisfile_riff_audio);
                                         }
                                         $thisfile_riff_audio[$streamindex] = self::RIFFparseWAVEFORMATex($strfData);
                                         $thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag'];
                                         // shortcut
                                         $thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex];
                                         $thisfile_audio_streams_currentstream =& $thisfile_audio['streams'][$streamindex];
                                         if ($thisfile_audio_streams_currentstream['bits_per_sample'] == 0) {
                                             unset($thisfile_audio_streams_currentstream['bits_per_sample']);
                                         }
                                         $thisfile_audio_streams_currentstream['wformattag'] = $thisfile_audio_streams_currentstream['raw']['wFormatTag'];
                                         unset($thisfile_audio_streams_currentstream['raw']);
                                         // shortcut
                                         $thisfile_riff_raw['strf'][$strhfccType][$streamindex] = $thisfile_riff_audio[$streamindex]['raw'];
                                         unset($thisfile_riff_audio[$streamindex]['raw']);
                                         $thisfile_audio = Helper::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]);
                                         $thisfile_audio['lossless'] = false;
                                         switch ($thisfile_riff_raw_strf_strhfccType_streamindex['wFormatTag']) {
                                             case 0x1:
                                                 // PCM
                                                 $thisfile_audio_dataformat = 'wav';
                                                 $thisfile_audio['lossless'] = true;
                                                 break;
                                             case 0x50:
                                                 // MPEG Layer 2 or Layer 1
                                                 $thisfile_audio_dataformat = 'mp2';
                                                 // Assume Layer-2
                                                 break;
                                             case 0x55:
                                                 // MPEG Layer 3
                                                 $thisfile_audio_dataformat = 'mp3';
                                                 break;
                                             case 0xff:
                                                 // AAC
                                                 $thisfile_audio_dataformat = 'aac';
                                                 break;
                                             case 0x161:
                                                 // Windows Media v7 / v8 / v9
                                             // Windows Media v7 / v8 / v9
                                             case 0x162:
                                                 // Windows Media Professional v9
                                             // Windows Media Professional v9
                                             case 0x163:
                                                 // Windows Media Lossess v9
                                                 $thisfile_audio_dataformat = 'wma';
                                                 break;
                                             case 0x2000:
                                                 // AC-3
                                                 $thisfile_audio_dataformat = 'ac3';
                                                 break;
                                             case 0x2001:
                                                 // DTS
                                                 $thisfile_audio_dataformat = 'dts';
                                                 break;
                                             default:
                                                 $thisfile_audio_dataformat = 'wav';
                                                 break;
                                         }
                                         $thisfile_audio_streams_currentstream['dataformat'] = $thisfile_audio_dataformat;
                                         $thisfile_audio_streams_currentstream['lossless'] = $thisfile_audio['lossless'];
                                         $thisfile_audio_streams_currentstream['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
                                         break;
                                     case 'iavs':
                                     case 'vids':
                                         // shortcut
                                         $thisfile_riff_raw['strh'][$i] = array();
                                         $thisfile_riff_raw_strh_current =& $thisfile_riff_raw['strh'][$i];
                                         $thisfile_riff_raw_strh_current['fccType'] = substr($strhData, 0, 4);
                                         // same as $strhfccType;
                                         $thisfile_riff_raw_strh_current['fccHandler'] = substr($strhData, 4, 4);
                                         $thisfile_riff_raw_strh_current['dwFlags'] = $this->EitherEndian2Int(substr($strhData, 8, 4));
                                         // Contains AVITF_* flags
                                         $thisfile_riff_raw_strh_current['wPriority'] = $this->EitherEndian2Int(substr($strhData, 12, 2));
                                         $thisfile_riff_raw_strh_current['wLanguage'] = $this->EitherEndian2Int(substr($strhData, 14, 2));
                                         $thisfile_riff_raw_strh_current['dwInitialFrames'] = $this->EitherEndian2Int(substr($strhData, 16, 4));
                                         $thisfile_riff_raw_strh_current['dwScale'] = $this->EitherEndian2Int(substr($strhData, 20, 4));
                                         $thisfile_riff_raw_strh_current['dwRate'] = $this->EitherEndian2Int(substr($strhData, 24, 4));
                                         $thisfile_riff_raw_strh_current['dwStart'] = $this->EitherEndian2Int(substr($strhData, 28, 4));
                                         $thisfile_riff_raw_strh_current['dwLength'] = $this->EitherEndian2Int(substr($strhData, 32, 4));
                                         $thisfile_riff_raw_strh_current['dwSuggestedBufferSize'] = $this->EitherEndian2Int(substr($strhData, 36, 4));
                                         $thisfile_riff_raw_strh_current['dwQuality'] = $this->EitherEndian2Int(substr($strhData, 40, 4));
                                         $thisfile_riff_raw_strh_current['dwSampleSize'] = $this->EitherEndian2Int(substr($strhData, 44, 4));
                                         $thisfile_riff_raw_strh_current['rcFrame'] = $this->EitherEndian2Int(substr($strhData, 48, 4));
                                         $thisfile_riff_video_current['codec'] = self::RIFFfourccLookup($thisfile_riff_raw_strh_current['fccHandler']);
                                         $thisfile_video['fourcc'] = $thisfile_riff_raw_strh_current['fccHandler'];
                                         if (!$thisfile_riff_video_current['codec'] && isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) && self::RIFFfourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) {
                                             $thisfile_riff_video_current['codec'] = self::RIFFfourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']);
                                             $thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'];
                                         }
                                         $thisfile_video['codec'] = $thisfile_riff_video_current['codec'];
                                         $thisfile_video['pixel_aspect_ratio'] = (double) 1;
                                         switch ($thisfile_riff_raw_strh_current['fccHandler']) {
                                             case 'HFYU':
                                                 // Huffman Lossless Codec
                                             // Huffman Lossless Codec
                                             case 'IRAW':
                                                 // Intel YUV Uncompressed
                                             // Intel YUV Uncompressed
                                             case 'YUY2':
                                                 // Uncompressed YUV 4:2:2
                                                 $thisfile_video['lossless'] = true;
                                                 break;
                                             default:
                                                 $thisfile_video['lossless'] = false;
                                                 break;
                                         }
                                         switch ($strhfccType) {
                                             case 'vids':
                                                 $thisfile_riff_raw_strf_strhfccType_streamindex = self::ParseBITMAPINFOHEADER(substr($strfData, 0, 40), $info['fileformat'] == 'riff');
                                                 //echo '<pre>'.print_r($thisfile_riff_raw_strf_strhfccType_streamindex, true).'</pre>';
                                                 $thisfile_video['bits_per_sample'] = $thisfile_riff_raw_strf_strhfccType_streamindex['biBitCount'];
                                                 if ($thisfile_riff_video_current['codec'] == 'DV') {
                                                     $thisfile_riff_video_current['dv_type'] = 2;
                                                 }
                                                 break;
                                             case 'iavs':
                                                 $thisfile_riff_video_current['dv_type'] = 1;
                                                 break;
                                         }
                                         break;
                                     default:
                                         $info['warning'][] = 'Unhandled fccType for stream (' . $i . '): "' . $strhfccType . '"';
                                         break;
                                 }
                             }
                         }
                         if (isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) {
                             $thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'];
                             if (self::RIFFfourccLookup($thisfile_video['fourcc'])) {
                                 $thisfile_riff_video_current['codec'] = self::RIFFfourccLookup($thisfile_video['fourcc']);
                                 $thisfile_video['codec'] = $thisfile_riff_video_current['codec'];
                             }
                             switch ($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) {
                                 case 'HFYU':
                                     // Huffman Lossless Codec
                                 // Huffman Lossless Codec
                                 case 'IRAW':
                                     // Intel YUV Uncompressed
                                 // Intel YUV Uncompressed
                                 case 'YUY2':
                                     // Uncompressed YUV 4:2:2
                                     $thisfile_video['lossless'] = true;
                                     //$thisfile_video['bits_per_sample'] = 24;
                                     break;
                                 default:
                                     $thisfile_video['lossless'] = false;
                                     //$thisfile_video['bits_per_sample'] = 24;
                                     break;
                             }
                         }
                     }
                 }
             }
             break;
         case 'CDDA':
             $thisfile_audio['bitrate_mode'] = 'cbr';
             $thisfile_audio_dataformat = 'cda';
             $thisfile_audio['lossless'] = true;
             unset($info['mime_type']);
             $info['avdataoffset'] = 44;
             if (isset($thisfile_riff['CDDA']['fmt '][0]['data'])) {
                 // shortcut
                 $thisfile_riff_CDDA_fmt_0 =& $thisfile_riff['CDDA']['fmt '][0];
                 $thisfile_riff_CDDA_fmt_0['unknown1'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 0, 2));
                 $thisfile_riff_CDDA_fmt_0['track_num'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 2, 2));
                 $thisfile_riff_CDDA_fmt_0['disc_id'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 4, 4));
                 $thisfile_riff_CDDA_fmt_0['start_offset_frame'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 8, 4));
                 $thisfile_riff_CDDA_fmt_0['playtime_frames'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 12, 4));
                 $thisfile_riff_CDDA_fmt_0['unknown6'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 16, 4));
                 $thisfile_riff_CDDA_fmt_0['unknown7'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 20, 4));
                 $thisfile_riff_CDDA_fmt_0['start_offset_seconds'] = (double) $thisfile_riff_CDDA_fmt_0['start_offset_frame'] / 75;
                 $thisfile_riff_CDDA_fmt_0['playtime_seconds'] = (double) $thisfile_riff_CDDA_fmt_0['playtime_frames'] / 75;
                 $info['comments']['track'] = $thisfile_riff_CDDA_fmt_0['track_num'];
                 $info['playtime_seconds'] = $thisfile_riff_CDDA_fmt_0['playtime_seconds'];
                 // hardcoded data for CD-audio
                 $thisfile_audio['sample_rate'] = 44100;
                 $thisfile_audio['channels'] = 2;
                 $thisfile_audio['bits_per_sample'] = 16;
                 $thisfile_audio['bitrate'] = $thisfile_audio['sample_rate'] * $thisfile_audio['channels'] * $thisfile_audio['bits_per_sample'];
                 $thisfile_audio['bitrate_mode'] = 'cbr';
             }
             break;
         case 'AIFF':
         case 'AIFC':
             $thisfile_audio['bitrate_mode'] = 'cbr';
             $thisfile_audio_dataformat = 'aiff';
             $thisfile_audio['lossless'] = true;
             $info['mime_type'] = 'audio/x-aiff';
             if (isset($thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'])) {
                 $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'] + 8;
                 $info['avdataend'] = $info['avdataoffset'] + $thisfile_riff[$RIFFsubtype]['SSND'][0]['size'];
                 if ($info['avdataend'] > $info['filesize']) {
                     if ($info['avdataend'] == $info['filesize'] + 1 && $info['filesize'] % 2 == 1) {
                         // structures rounded to 2-byte boundary, but dumb encoders
                         // forget to pad end of file to make this actually work
                     } else {
                         $info['warning'][] = 'Probable truncated AIFF file: expecting ' . $thisfile_riff[$RIFFsubtype]['SSND'][0]['size'] . ' bytes of audio data, only ' . ($info['filesize'] - $info['avdataoffset']) . ' bytes found';
                     }
                     $info['avdataend'] = $info['filesize'];
                 }
             }
             if (isset($thisfile_riff[$RIFFsubtype]['COMM'][0]['data'])) {
                 // shortcut
                 $thisfile_riff_RIFFsubtype_COMM_0_data =& $thisfile_riff[$RIFFsubtype]['COMM'][0]['data'];
                 $thisfile_riff_audio['channels'] = Helper::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 0, 2), true);
                 $thisfile_riff_audio['total_samples'] = Helper::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 2, 4), false);
                 $thisfile_riff_audio['bits_per_sample'] = Helper::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 6, 2), true);
                 $thisfile_riff_audio['sample_rate'] = (int) Helper::BigEndian2Float(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 8, 10));
                 if ($thisfile_riff[$RIFFsubtype]['COMM'][0]['size'] > 18) {
                     $thisfile_riff_audio['codec_fourcc'] = substr($thisfile_riff_RIFFsubtype_COMM_0_data, 18, 4);
                     $CodecNameSize = Helper::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 22, 1), false);
                     $thisfile_riff_audio['codec_name'] = substr($thisfile_riff_RIFFsubtype_COMM_0_data, 23, $CodecNameSize);
                     switch ($thisfile_riff_audio['codec_name']) {
                         case 'NONE':
                             $thisfile_audio['codec'] = 'Pulse Code Modulation (PCM)';
                             $thisfile_audio['lossless'] = true;
                             break;
                         case '':
                             switch ($thisfile_riff_audio['codec_fourcc']) {
                                 // http://developer.apple.com/qa/snd/snd07.html
                                 case 'sowt':
                                     $thisfile_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM';
                                     $thisfile_audio['lossless'] = true;
                                     break;
                                 case 'twos':
                                     $thisfile_riff_audio['codec_name'] = 'Two\'s Compliment Big-Endian PCM';
                                     $thisfile_audio['lossless'] = true;
                                     break;
                                 default:
                                     break;
                             }
                             break;
                         default:
                             $thisfile_audio['codec'] = $thisfile_riff_audio['codec_name'];
                             $thisfile_audio['lossless'] = false;
                             break;
                     }
                 }
                 $thisfile_audio['channels'] = $thisfile_riff_audio['channels'];
                 if ($thisfile_riff_audio['bits_per_sample'] > 0) {
                     $thisfile_audio['bits_per_sample'] = $thisfile_riff_audio['bits_per_sample'];
                 }
                 $thisfile_audio['sample_rate'] = $thisfile_riff_audio['sample_rate'];
                 if ($thisfile_audio['sample_rate'] == 0) {
                     $info['error'][] = 'Corrupted AIFF file: sample_rate == zero';
                     return false;
                 }
                 $info['playtime_seconds'] = $thisfile_riff_audio['total_samples'] / $thisfile_audio['sample_rate'];
             }
             if (isset($thisfile_riff[$RIFFsubtype]['COMT'])) {
                 $offset = 0;
                 $CommentCount = Helper::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);
                 $offset += 2;
                 for ($i = 0; $i < $CommentCount; ++$i) {
                     $info['comments_raw'][$i]['timestamp'] = Helper::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 4), false);
                     $offset += 4;
                     $info['comments_raw'][$i]['marker_id'] = Helper::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), true);
                     $offset += 2;
                     $CommentLength = Helper::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false);
                     $offset += 2;
                     $info['comments_raw'][$i]['comment'] = substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, $CommentLength);
                     $offset += $CommentLength;
                     $info['comments_raw'][$i]['timestamp_unix'] = Helper::DateMac2Unix($info['comments_raw'][$i]['timestamp']);
                     $thisfile_riff['comments']['comment'][] = $info['comments_raw'][$i]['comment'];
                 }
             }
             $CommentsChunkNames = array('NAME' => 'title', 'author' => 'artist', '(c) ' => 'copyright', 'ANNO' => 'comment');
             foreach ($CommentsChunkNames as $key => $value) {
                 if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) {
                     $thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data'];
                 }
             }
             break;
         case '8SVX':
             $thisfile_audio['bitrate_mode'] = 'cbr';
             $thisfile_audio_dataformat = '8svx';
             $thisfile_audio['bits_per_sample'] = 8;
             $thisfile_audio['channels'] = 1;
             // overridden below, if need be
             $info['mime_type'] = 'audio/x-aiff';
             if (isset($thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'])) {
                 $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'] + 8;
                 $info['avdataend'] = $info['avdataoffset'] + $thisfile_riff[$RIFFsubtype]['BODY'][0]['size'];
                 if ($info['avdataend'] > $info['filesize']) {
                     $info['warning'][] = 'Probable truncated AIFF file: expecting ' . $thisfile_riff[$RIFFsubtype]['BODY'][0]['size'] . ' bytes of audio data, only ' . ($info['filesize'] - $info['avdataoffset']) . ' bytes found';
                 }
             }
             if (isset($thisfile_riff[$RIFFsubtype]['VHDR'][0]['offset'])) {
                 // shortcut
                 $thisfile_riff_RIFFsubtype_VHDR_0 =& $thisfile_riff[$RIFFsubtype]['VHDR'][0];
                 $thisfile_riff_RIFFsubtype_VHDR_0['oneShotHiSamples'] = Helper::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 0, 4));
                 $thisfile_riff_RIFFsubtype_VHDR_0['repeatHiSamples'] = Helper::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 4, 4));
                 $thisfile_riff_RIFFsubtype_VHDR_0['samplesPerHiCycle'] = Helper::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 8, 4));
                 $thisfile_riff_RIFFsubtype_VHDR_0['samplesPerSec'] = Helper::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 12, 2));
                 $thisfile_riff_RIFFsubtype_VHDR_0['ctOctave'] = Helper::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 14, 1));
                 $thisfile_riff_RIFFsubtype_VHDR_0['sCompression'] = Helper::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 15, 1));
                 $thisfile_riff_RIFFsubtype_VHDR_0['Volume'] = Helper::FixedPoint16_16(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 16, 4));
                 $thisfile_audio['sample_rate'] = $thisfile_riff_RIFFsubtype_VHDR_0['samplesPerSec'];
                 switch ($thisfile_riff_RIFFsubtype_VHDR_0['sCompression']) {
                     case 0:
                         $thisfile_audio['codec'] = 'Pulse Code Modulation (PCM)';
                         $thisfile_audio['lossless'] = true;
                         $ActualBitsPerSample = 8;
                         break;
                     case 1:
                         $thisfile_audio['codec'] = 'Fibonacci-delta encoding';
                         $thisfile_audio['lossless'] = false;
                         $ActualBitsPerSample = 4;
                         break;
                     default:
                         $info['warning'][] = 'Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "' . sCompression . '"';
                         break;
                 }
             }
             if (isset($thisfile_riff[$RIFFsubtype]['CHAN'][0]['data'])) {
                 $ChannelsIndex = Helper::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['CHAN'][0]['data'], 0, 4));
                 switch ($ChannelsIndex) {
                     case 6:
                         // Stereo
                         $thisfile_audio['channels'] = 2;
                         break;
                     case 2:
                         // Left channel only
                     // Left channel only
                     case 4:
                         // Right channel only
                         $thisfile_audio['channels'] = 1;
                         break;
                     default:
                         $info['warning'][] = 'Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "' . $ChannelsIndex . '"';
                         break;
                 }
             }
             $CommentsChunkNames = array('NAME' => 'title', 'author' => 'artist', '(c) ' => 'copyright', 'ANNO' => 'comment');
             foreach ($CommentsChunkNames as $key => $value) {
                 if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) {
                     $thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data'];
                 }
             }
             $thisfile_audio['bitrate'] = $thisfile_audio['sample_rate'] * $ActualBitsPerSample * $thisfile_audio['channels'];
             if (!empty($thisfile_audio['bitrate'])) {
                 $info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) / ($thisfile_audio['bitrate'] / 8);
             }
             break;
         case 'CDXA':
             $info['mime_type'] = 'video/mpeg';
             if (!empty($thisfile_riff['CDXA']['data'][0]['size'])) {
                 if (class_exists('GetId3\\Module\\AudioVideo\\Mpeg')) {
                     $getid3_temp = new GetId3Core();
                     $getid3_temp->openfile($this->getid3->filename);
                     $getid3_mpeg = new Mpeg($getid3_temp);
                     $getid3_mpeg->analyze();
                     if (empty($getid3_temp->info['error'])) {
                         $info['audio'] = $getid3_temp->info['audio'];
                         $info['video'] = $getid3_temp->info['video'];
                         $info['mpeg'] = $getid3_temp->info['mpeg'];
                         $info['warning'] = $getid3_temp->info['warning'];
                     }
                     unset($getid3_temp, $getid3_mpeg);
                 }
             }
             break;
         default:
             $info['error'][] = 'Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "' . $RIFFsubtype . '" instead';
             unset($info['fileformat']);
             break;
     }
     switch ($RIFFsubtype) {
         case 'WAVE':
         case 'AIFF':
         case 'AIFC':
             if (isset($thisfile_riff[$RIFFsubtype]['ID3 ']) && !array_key_exists('id3 ', $thisfile_riff[$RIFFsubtype])) {
                 $info['warning'][] = 'mapping "ID3 " chunk to "id3 "';
             }
             if (isset($thisfile_riff[$RIFFsubtype]['tag ']) && !array_key_exists('id3 ', $thisfile_riff[$RIFFsubtype])) {
                 $info['warning'][] = 'mapping "tag " chunk to "id3 "';
             }
             if (isset($thisfile_riff[$RIFFsubtype]['id3 '])) {
                 $getid3_temp = new GetId3Core();
                 $getid3_temp->openfile($this->getid3->filename);
                 $getid3_id3v2 = new Id3v2($getid3_temp);
                 $getid3_id3v2->StartingOffset = $thisfile_riff[$RIFFsubtype]['id3 '][0]['offset'] + 8;
                 if ($thisfile_riff[$RIFFsubtype]['id3 '][0]['valid'] = $getid3_id3v2->analyze()) {
                     $info['id3v2'] = $getid3_temp->info['id3v2'];
                 }
                 unset($getid3_temp, $getid3_id3v2);
             }
             break;
     }
     if (isset($thisfile_riff_raw['fmt ']['wFormatTag']) && $thisfile_riff_raw['fmt ']['wFormatTag'] == 1) {
         // http://www.mega-nerd.com/erikd/Blog/Windiots/dts.html
         fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
         $FirstFourBytes = fread($this->getid3->fp, 4);
         if (preg_match('/^\\xFF\\x1F\\x00\\xE8/s', $FirstFourBytes)) {
             // DTSWAV
             $thisfile_audio_dataformat = 'dts';
         } elseif (preg_match('/^\\x7F\\xFF\\x80\\x01/s', $FirstFourBytes)) {
             // DTS, but this probably shouldn't happen
             $thisfile_audio_dataformat = 'dts';
         }
     }
     if (isset($thisfile_riff_WAVE['DISP']) && is_array($thisfile_riff_WAVE['DISP'])) {
         $thisfile_riff['comments']['title'][] = trim(substr($thisfile_riff_WAVE['DISP'][count($thisfile_riff_WAVE['DISP']) - 1]['data'], 4));
     }
     if (isset($thisfile_riff_WAVE['INFO']) && is_array($thisfile_riff_WAVE['INFO'])) {
         $this->RIFFcommentsParse($thisfile_riff_WAVE['INFO'], $thisfile_riff['comments']);
     }
     if (isset($thisfile_riff['AVI ']['INFO']) && is_array($thisfile_riff['AVI ']['INFO'])) {
         $this->RIFFcommentsParse($thisfile_riff['AVI ']['INFO'], $thisfile_riff['comments']);
     }
     if (empty($thisfile_audio['encoder']) && !empty($info['mpeg']['audio']['LAME']['short_version'])) {
         $thisfile_audio['encoder'] = $info['mpeg']['audio']['LAME']['short_version'];
     }
     if (!isset($info['playtime_seconds'])) {
         $info['playtime_seconds'] = 0;
     }
     if (isset($thisfile_riff_raw['strh'][0]['dwLength']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) {
         // needed for >2GB AVIs where 'avih' chunk only lists number of frames in that chunk, not entire movie
         $info['playtime_seconds'] = $thisfile_riff_raw['strh'][0]['dwLength'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
     } elseif (isset($thisfile_riff_raw['avih']['dwTotalFrames']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) {
         $info['playtime_seconds'] = $thisfile_riff_raw['avih']['dwTotalFrames'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000);
     }
     if ($info['playtime_seconds'] > 0) {
         if (isset($thisfile_riff_audio) && isset($thisfile_riff_video)) {
             if (!isset($info['bitrate'])) {
                 $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds'] * 8;
             }
         } elseif (isset($thisfile_riff_audio) && !isset($thisfile_riff_video)) {
             if (!isset($thisfile_audio['bitrate'])) {
                 $thisfile_audio['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds'] * 8;
             }
         } elseif (!isset($thisfile_riff_audio) && isset($thisfile_riff_video)) {
             if (!isset($thisfile_video['bitrate'])) {
                 $thisfile_video['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds'] * 8;
             }
         }
     }
     if (isset($thisfile_riff_video) && isset($thisfile_audio['bitrate']) && $thisfile_audio['bitrate'] > 0 && $info['playtime_seconds'] > 0) {
         $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds'] * 8;
         $thisfile_audio['bitrate'] = 0;
         $thisfile_video['bitrate'] = $info['bitrate'];
         foreach ($thisfile_riff_audio as $channelnumber => $audioinfoarray) {
             $thisfile_video['bitrate'] -= $audioinfoarray['bitrate'];
             $thisfile_audio['bitrate'] += $audioinfoarray['bitrate'];
         }
         if ($thisfile_video['bitrate'] <= 0) {
             unset($thisfile_video['bitrate']);
         }
         if ($thisfile_audio['bitrate'] <= 0) {
             unset($thisfile_audio['bitrate']);
         }
     }
     if (isset($info['mpeg']['audio'])) {
         $thisfile_audio_dataformat = 'mp' . $info['mpeg']['audio']['layer'];
         $thisfile_audio['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
         $thisfile_audio['channels'] = $info['mpeg']['audio']['channels'];
         $thisfile_audio['bitrate'] = $info['mpeg']['audio']['bitrate'];
         $thisfile_audio['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
         if (!empty($info['mpeg']['audio']['codec'])) {
             $thisfile_audio['codec'] = $info['mpeg']['audio']['codec'] . ' ' . $thisfile_audio['codec'];
         }
         if (!empty($thisfile_audio['streams'])) {
             foreach ($thisfile_audio['streams'] as $streamnumber => $streamdata) {
                 if ($streamdata['dataformat'] == $thisfile_audio_dataformat) {
                     $thisfile_audio['streams'][$streamnumber]['sample_rate'] = $thisfile_audio['sample_rate'];
                     $thisfile_audio['streams'][$streamnumber]['channels'] = $thisfile_audio['channels'];
                     $thisfile_audio['streams'][$streamnumber]['bitrate'] = $thisfile_audio['bitrate'];
                     $thisfile_audio['streams'][$streamnumber]['bitrate_mode'] = $thisfile_audio['bitrate_mode'];
                     $thisfile_audio['streams'][$streamnumber]['codec'] = $thisfile_audio['codec'];
                 }
             }
         }
         $getid3_mp3 = new Mp3($this->getid3);
         $thisfile_audio['encoder_options'] = $getid3_mp3->GuessEncoderOptions();
         unset($getid3_mp3);
     }
     if (!empty($thisfile_riff_raw['fmt ']['wBitsPerSample']) && $thisfile_riff_raw['fmt ']['wBitsPerSample'] > 0) {
         switch ($thisfile_audio_dataformat) {
             case 'ac3':
                 // ignore bits_per_sample
                 break;
             default:
                 $thisfile_audio['bits_per_sample'] = $thisfile_riff_raw['fmt ']['wBitsPerSample'];
                 break;
         }
     }
     if (empty($thisfile_riff_raw)) {
         unset($thisfile_riff['raw']);
     }
     if (empty($thisfile_riff_audio)) {
         unset($thisfile_riff['audio']);
     }
     if (empty($thisfile_riff_video)) {
         unset($thisfile_riff['video']);
     }
     return true;
 }
コード例 #4
0
ファイル: Id3v2.php プロジェクト: Nattpyre/rocketfiles
 /**
  * @param  type    $pricestring
  *
  * @return bool
  */
 public function ID3v2IsValidPriceString($pricestring)
 {
     if (Tag\Id3v2::LanguageLookup(substr($pricestring, 0, 3), true) == '') {
         return false;
     } elseif (!$this->IsANumber(substr($pricestring, 3), true)) {
         return false;
     }
     return true;
 }