- Timestamp:
- 10/20/2023 01:27:56 PM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/module.audio-video.quicktime.php
r54376 r56975 153 153 $ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lat_deg, 0, 2), '0')) + floatval(ltrim(substr($lat_deg, 2, 2), '0').$lat_deg_dec / 60); 154 154 } elseif (strlen($lat_deg) == 6) { // [+-]DDMMSS.S 155 $ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lat_deg, 0, 2), '0')) + floatval( ltrim(substr($lat_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lat_deg, 4, 2), '0').$lat_deg_dec / 3600);155 $ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lat_deg, 0, 2), '0')) + floatval((int) ltrim(substr($lat_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lat_deg, 4, 2), '0').$lat_deg_dec / 3600); 156 156 } 157 157 … … 161 161 $ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lon_deg, 0, 2), '0')) + floatval(ltrim(substr($lon_deg, 2, 2), '0').$lon_deg_dec / 60); 162 162 } elseif (strlen($lon_deg) == 7) { // [+-]DDDMMSS.S 163 $ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lon_deg, 0, 2), '0')) + floatval( ltrim(substr($lon_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lon_deg, 4, 2), '0').$lon_deg_dec / 3600);163 $ISO6709parsed['longitude'] = (($lon_sign == '-') ? -1 : 1) * floatval(ltrim(substr($lon_deg, 0, 2), '0')) + floatval((int) ltrim(substr($lon_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lon_deg, 4, 2), '0').$lon_deg_dec / 3600); 164 164 } 165 165 … … 169 169 $ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * floatval(ltrim(substr($alt_deg, 0, 2), '0')) + floatval(ltrim(substr($alt_deg, 2, 2), '0').$alt_deg_dec / 60); 170 170 } elseif (strlen($alt_deg) == 7) { // [+-]DDDMMSS.S 171 $ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * floatval(ltrim(substr($alt_deg, 0, 2), '0')) + floatval( ltrim(substr($alt_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($alt_deg, 4, 2), '0').$alt_deg_dec / 3600);171 $ISO6709parsed['altitude'] = (($alt_sign == '-') ? -1 : 1) * floatval(ltrim(substr($alt_deg, 0, 2), '0')) + floatval((int) ltrim(substr($alt_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($alt_deg, 4, 2), '0').$alt_deg_dec / 3600); 172 172 } 173 173 … … 333 333 } elseif (isset($value_array['time_to_sample_table'])) { 334 334 foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) { 335 if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0) ) {335 if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0) && !empty($info['quicktime']['time_scale'])) { 336 336 $framerate = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3); 337 337 $framecount = $value_array2['sample_count']; … … 777 777 778 778 case 'stsd': // Sample Table Sample Description atom 779 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); 780 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 779 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); // hardcoded: 0x00 780 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x000000 781 781 $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); 782 782 … … 806 806 $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2)); 807 807 $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2); 808 809 808 if (substr($atom_structure['sample_description_table'][$i]['data'], 1, 54) == 'application/octet-stream;type=com.parrot.videometadata') { 810 809 // special handling for apparently-malformed (TextMetaDataSampleEntry?) data for some version of Parrot drones … … 894 893 895 894 case 'mp4a': 896 default: 895 $atom_structure['sample_description_table'][$i]['subatoms'] = $this->QuicktimeParseContainerAtom(substr($atom_structure['sample_description_table'][$i]['data'], 20), $baseoffset + $stsdEntriesDataOffset - 20 - 16, $atomHierarchy, $ParseAllPossibleAtoms); 896 897 897 $info['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']); 898 898 $info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate']; … … 919 919 break; 920 920 } 921 break; 922 923 default: 921 924 break; 922 925 } … … 1667 1670 $atom_structure['data'] = $atom_data; 1668 1671 $atom_structure['image_mime'] = 'image/jpeg'; 1669 $atom_structure['description'] = isset($descriptions[$atomname]) ? $descriptions[$atomname] : 'Nikon preview image';1672 $atom_structure['description'] = $descriptions[$atomname]; 1670 1673 $info['quicktime']['comments']['picture'][] = array( 1671 1674 'image_mime' => $atom_structure['image_mime'], … … 1684 1687 $makerNoteVersion = ''; 1685 1688 for ($i = 0, $iMax = strlen($atom_data); $i < $iMax; ++$i) { 1686 if (ord($atom_data[$i]) >= 0x00 && ord($atom_data[$i])<= 0x1F) {1689 if (ord($atom_data[$i]) <= 0x1F) { 1687 1690 $makerNoteVersion .= ' '.ord($atom_data[$i]); 1688 1691 } else { … … 2101 2104 break; 2102 2105 2106 2107 case 'esds': // Elementary Stream DeScriptor 2108 // https://github.com/JamesHeinrich/getID3/issues/414 2109 // https://chromium.googlesource.com/chromium/src/media/+/refs/heads/main/formats/mp4/es_descriptor.cc 2110 // https://chromium.googlesource.com/chromium/src/media/+/refs/heads/main/formats/mp4/es_descriptor.h 2111 $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); // hardcoded: 0x00 2112 $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x000000 2113 $esds_offset = 4; 2114 2115 $atom_structure['ES_DescrTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1)); 2116 $esds_offset += 1; 2117 if ($atom_structure['ES_DescrTag'] != 0x03) { 2118 $this->warning('expecting esds.ES_DescrTag = 0x03, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_DescrTag']).'), at offset '.$atom_structure['offset']); 2119 break; 2120 } 2121 $atom_structure['ES_DescrSize'] = $this->quicktime_read_mp4_descr_length($atom_data, $esds_offset); 2122 2123 $atom_structure['ES_ID'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 2)); 2124 $esds_offset += 2; 2125 $atom_structure['ES_flagsraw'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1)); 2126 $esds_offset += 1; 2127 $atom_structure['ES_flags']['stream_dependency'] = (bool) ($atom_structure['ES_flagsraw'] & 0x80); 2128 $atom_structure['ES_flags']['url_flag'] = (bool) ($atom_structure['ES_flagsraw'] & 0x40); 2129 $atom_structure['ES_flags']['ocr_stream'] = (bool) ($atom_structure['ES_flagsraw'] & 0x20); 2130 $atom_structure['ES_stream_priority'] = ($atom_structure['ES_flagsraw'] & 0x1F); 2131 if ($atom_structure['ES_flags']['url_flag']) { 2132 $this->warning('Unsupported esds.url_flag enabled at offset '.$atom_structure['offset']); 2133 break; 2134 } 2135 if ($atom_structure['ES_flags']['stream_dependency']) { 2136 $atom_structure['ES_dependsOn_ES_ID'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 2)); 2137 $esds_offset += 2; 2138 } 2139 if ($atom_structure['ES_flags']['ocr_stream']) { 2140 $atom_structure['ES_OCR_ES_Id'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 2)); 2141 $esds_offset += 2; 2142 } 2143 2144 $atom_structure['ES_DecoderConfigDescrTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1)); 2145 $esds_offset += 1; 2146 if ($atom_structure['ES_DecoderConfigDescrTag'] != 0x04) { 2147 $this->warning('expecting esds.ES_DecoderConfigDescrTag = 0x04, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_DecoderConfigDescrTag']).'), at offset '.$atom_structure['offset']); 2148 break; 2149 } 2150 $atom_structure['ES_DecoderConfigDescrTagSize'] = $this->quicktime_read_mp4_descr_length($atom_data, $esds_offset); 2151 2152 $atom_structure['ES_objectTypeIndication'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1)); 2153 $esds_offset += 1; 2154 // https://stackoverflow.com/questions/3987850 2155 // 0x40 = "Audio ISO/IEC 14496-3" = MPEG-4 Audio 2156 // 0x67 = "Audio ISO/IEC 13818-7 LowComplexity Profile" = MPEG-2 AAC LC 2157 // 0x69 = "Audio ISO/IEC 13818-3" = MPEG-2 Backward Compatible Audio (MPEG-2 Layers 1, 2, and 3) 2158 // 0x6B = "Audio ISO/IEC 11172-3" = MPEG-1 Audio (MPEG-1 Layers 1, 2, and 3) 2159 2160 $streamTypePlusFlags = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1)); 2161 $esds_offset += 1; 2162 $atom_structure['ES_streamType'] = ($streamTypePlusFlags & 0xFC) >> 2; 2163 $atom_structure['ES_upStream'] = (bool) ($streamTypePlusFlags & 0x02) >> 1; 2164 $atom_structure['ES_bufferSizeDB'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 3)); 2165 $esds_offset += 3; 2166 $atom_structure['ES_maxBitrate'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 4)); 2167 $esds_offset += 4; 2168 $atom_structure['ES_avgBitrate'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 4)); 2169 $esds_offset += 4; 2170 if ($atom_structure['ES_avgBitrate']) { 2171 $info['quicktime']['audio']['bitrate'] = $atom_structure['ES_avgBitrate']; 2172 $info['audio']['bitrate'] = $atom_structure['ES_avgBitrate']; 2173 } 2174 2175 $atom_structure['ES_DecSpecificInfoTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1)); 2176 $esds_offset += 1; 2177 if ($atom_structure['ES_DecSpecificInfoTag'] != 0x05) { 2178 $this->warning('expecting esds.ES_DecSpecificInfoTag = 0x05, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_DecSpecificInfoTag']).'), at offset '.$atom_structure['offset']); 2179 break; 2180 } 2181 $atom_structure['ES_DecSpecificInfoTagSize'] = $this->quicktime_read_mp4_descr_length($atom_data, $esds_offset); 2182 2183 $atom_structure['ES_DecSpecificInfo'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, $atom_structure['ES_DecSpecificInfoTagSize'])); 2184 $esds_offset += $atom_structure['ES_DecSpecificInfoTagSize']; 2185 2186 $atom_structure['ES_SLConfigDescrTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, 1)); 2187 $esds_offset += 1; 2188 if ($atom_structure['ES_SLConfigDescrTag'] != 0x06) { 2189 $this->warning('expecting esds.ES_SLConfigDescrTag = 0x05, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_SLConfigDescrTag']).'), at offset '.$atom_structure['offset']); 2190 break; 2191 } 2192 $atom_structure['ES_SLConfigDescrTagSize'] = $this->quicktime_read_mp4_descr_length($atom_data, $esds_offset); 2193 2194 $atom_structure['ES_SLConfigDescr'] = getid3_lib::BigEndian2Int(substr($atom_data, $esds_offset, $atom_structure['ES_SLConfigDescrTagSize'])); 2195 $esds_offset += $atom_structure['ES_SLConfigDescrTagSize']; 2196 break; 2103 2197 2104 2198 // AVIF-related - https://docs.rs/avif-parse/0.13.2/src/avif_parse/boxes.rs.html … … 2992 3086 } 2993 3087 3088 2994 3089 /** 2995 3090 * @param array $info
Note: See TracChangeset
for help on using the changeset viewer.