Changeset 41196 for trunk/src/wp-includes/ID3/module.audio-video.riff.php
- Timestamp:
- 07/31/2017 07:49:31 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/module.audio-video.riff.php
r29734 r41196 191 191 $thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag']; 192 192 if (!isset($thisfile_riff_audio[$streamindex]['bitrate']) || ($thisfile_riff_audio[$streamindex]['bitrate'] == 0)) { 193 $ info['error'][] = 'Corrupt RIFF file: bitrate_audio == zero';193 $this->error('Corrupt RIFF file: bitrate_audio == zero'); 194 194 return false; 195 195 } … … 200 200 $thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]); 201 201 if (substr($thisfile_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') { 202 $ info['warning'][] = 'Audio codec = '.$thisfile_audio['codec'];202 $this->warning('Audio codec = '.$thisfile_audio['codec']); 203 203 } 204 204 $thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate']; … … 303 303 $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']); 304 304 } else { 305 $ info['warning'][] = 'RIFF.WAVE.BEXT.origin_time is invalid';305 $this->warning('RIFF.WAVE.BEXT.origin_time is invalid'); 306 306 } 307 307 } else { 308 $ info['warning'][] = 'RIFF.WAVE.BEXT.origin_date is invalid';308 $this->warning('RIFF.WAVE.BEXT.origin_date is invalid'); 309 309 } 310 310 $thisfile_riff['comments']['author'][] = $thisfile_riff_WAVE_bext_0['author']; … … 386 386 387 387 if ($SNDM_thisTagSize != (4 + 4 + 2 + 2 + $SNDM_thisTagDataSize)) { 388 $ 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).')';388 $this->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).')'); 389 389 break; 390 390 } elseif ($SNDM_thisTagSize <= 0) { 391 $ info['warning'][] = 'RIFF.WAVE.SNDM.data contains zero-size tag at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')';391 $this->warning('RIFF.WAVE.SNDM.data contains zero-size tag at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')'); 392 392 break; 393 393 } … … 398 398 $thisfile_riff_WAVE_SNDM_0['parsed'][$parsedkey] = $SNDM_thisTagDataText; 399 399 } else { 400 $ info['warning'][] = 'RIFF.WAVE.SNDM contains unknown tag "'.$SNDM_thisTagKey.'" at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')';400 $this->warning('RIFF.WAVE.SNDM contains unknown tag "'.$SNDM_thisTagKey.'" at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')'); 401 401 } 402 402 } … … 429 429 if (isset($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO']) && !empty($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) && !empty($thisfile_riff_WAVE['iXML'][0]['timecode_rate'])) { 430 430 $samples_since_midnight = floatval(ltrim($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_HI'].$parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO'], '0')); 431 $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] = $samples_since_midnight / $parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']; 431 $timestamp_sample_rate = (is_array($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) ? max($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) : $parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']); // XML could possibly contain more than one TIMESTAMP_SAMPLE_RATE tag, returning as array instead of integer [why? does it make sense? perhaps doesn't matter but getID3 needs to deal with it] - see https://github.com/JamesHeinrich/getID3/issues/105 432 $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] = $samples_since_midnight / $timestamp_sample_rate; 432 433 $h = floor( $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] / 3600); 433 434 $m = floor(($thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - ($h * 3600)) / 60); … … 436 437 $thisfile_riff_WAVE['iXML'][0]['timecode_string'] = sprintf('%02d:%02d:%02d:%05.2f', $h, $m, $s, $f); 437 438 $thisfile_riff_WAVE['iXML'][0]['timecode_string_round'] = sprintf('%02d:%02d:%02d:%02d', $h, $m, $s, round($f)); 439 unset($samples_since_midnight, $timestamp_sample_rate, $h, $m, $s, $f); 438 440 } 439 441 unset($parsedXML); … … 571 573 } else { 572 574 // Short by more than one byte, throw warning 573 $ 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)';575 $this->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)'); 574 576 $info['avdataend'] = $info['filesize']; 575 577 } … … 580 582 // output file appears to be incorrectly *not* padded to nearest WORD boundary 581 583 // Output less severe warning 582 $ 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)';584 $this->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)'); 583 585 $info['avdataend'] = $info['filesize']; 584 586 } else { 585 587 // Short by more than one byte, throw warning 586 $ 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)';588 $this->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)'); 587 589 $info['avdataend'] = $info['filesize']; 588 590 } … … 593 595 if ((($info['avdataend'] - $info['avdataoffset']) - $info['mpeg']['audio']['LAME']['audio_bytes']) == 1) { 594 596 $info['avdataend']--; 595 $ info['warning'][] = 'Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored';597 $this->warning('Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored'); 596 598 } 597 599 } … … 620 622 } 621 623 if ($info['avdataend'] > $info['filesize']) { 622 $ 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)';624 $this->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)'); 623 625 $info['avdataend'] = $info['filesize']; 624 626 } … … 661 663 $thisfile_riff_raw_avih['dwMicroSecPerFrame'] = $this->EitherEndian2Int(substr($avihData, 0, 4)); // frame display rate (or 0L) 662 664 if ($thisfile_riff_raw_avih['dwMicroSecPerFrame'] == 0) { 663 $ info['error'][] = 'Corrupt RIFF file: avih.dwMicroSecPerFrame == zero';665 $this->error('Corrupt RIFF file: avih.dwMicroSecPerFrame == zero'); 664 666 return false; 665 667 } … … 859 861 860 862 default: 861 $ info['warning'][] = 'Unhandled fccType for stream ('.$i.'): "'.$strhfccType.'"';863 $this->warning('Unhandled fccType for stream ('.$i.'): "'.$strhfccType.'"'); 862 864 break; 863 865 … … 964 966 // forget to pad end of file to make this actually work 965 967 } else { 966 $ info['warning'][] = 'Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['SSND'][0]['size'].' bytes of audio data, only '.($info['filesize'] - $info['avdataoffset']).' bytes found';968 $this->warning('Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['SSND'][0]['size'].' bytes of audio data, only '.($info['filesize'] - $info['avdataoffset']).' bytes found'); 967 969 } 968 970 $info['avdataend'] = $info['filesize']; … … 1021 1023 $thisfile_audio['sample_rate'] = $thisfile_riff_audio['sample_rate']; 1022 1024 if ($thisfile_audio['sample_rate'] == 0) { 1023 $ info['error'][] = 'Corrupted AIFF file: sample_rate == zero';1025 $this->error('Corrupted AIFF file: sample_rate == zero'); 1024 1026 return false; 1025 1027 } … … 1081 1083 $info['avdataend'] = $info['avdataoffset'] + $thisfile_riff[$RIFFsubtype]['BODY'][0]['size']; 1082 1084 if ($info['avdataend'] > $info['filesize']) { 1083 $ info['warning'][] = 'Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['BODY'][0]['size'].' bytes of audio data, only '.($info['filesize'] - $info['avdataoffset']).' bytes found';1085 $this->warning('Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['BODY'][0]['size'].' bytes of audio data, only '.($info['filesize'] - $info['avdataoffset']).' bytes found'); 1084 1086 } 1085 1087 } … … 1113 1115 1114 1116 default: 1115 $ info['warning'][] = 'Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "'.sCompression.'"';1117 $this->warning('Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "'.sCompression.'"'); 1116 1118 break; 1117 1119 } … … 1131 1133 1132 1134 default: 1133 $ info['warning'][] = 'Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "'.$ChannelsIndex.'"';1135 $this->warning('Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "'.$ChannelsIndex.'"'); 1134 1136 break; 1135 1137 } … … 1171 1173 break; 1172 1174 1175 case 'WEBP': 1176 // https://developers.google.com/speed/webp/docs/riff_container 1177 // https://tools.ietf.org/html/rfc6386 1178 // https://chromium.googlesource.com/webm/libwebp/+/master/doc/webp-lossless-bitstream-spec.txt 1179 $info['fileformat'] = 'webp'; 1180 $info['mime_type'] = 'image/webp'; 1181 1182 if (!empty($thisfile_riff['WEBP']['VP8 '][0]['size'])) { 1183 $old_offset = $this->ftell(); 1184 $this->fseek($thisfile_riff['WEBP']['VP8 '][0]['offset'] + 8); // 4 bytes "VP8 " + 4 bytes chunk size 1185 $WEBP_VP8_header = $this->fread(10); 1186 $this->fseek($old_offset); 1187 if (substr($WEBP_VP8_header, 3, 3) == "\x9D\x01\x2A") { 1188 $thisfile_riff['WEBP']['VP8 '][0]['keyframe'] = !(getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 0, 3)) & 0x800000); 1189 $thisfile_riff['WEBP']['VP8 '][0]['version'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 0, 3)) & 0x700000) >> 20; 1190 $thisfile_riff['WEBP']['VP8 '][0]['show_frame'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 0, 3)) & 0x080000); 1191 $thisfile_riff['WEBP']['VP8 '][0]['data_bytes'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 0, 3)) & 0x07FFFF) >> 0; 1192 1193 $thisfile_riff['WEBP']['VP8 '][0]['scale_x'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 6, 2)) & 0xC000) >> 14; 1194 $thisfile_riff['WEBP']['VP8 '][0]['width'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 6, 2)) & 0x3FFF); 1195 $thisfile_riff['WEBP']['VP8 '][0]['scale_y'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 8, 2)) & 0xC000) >> 14; 1196 $thisfile_riff['WEBP']['VP8 '][0]['height'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 8, 2)) & 0x3FFF); 1197 1198 $info['video']['resolution_x'] = $thisfile_riff['WEBP']['VP8 '][0]['width']; 1199 $info['video']['resolution_y'] = $thisfile_riff['WEBP']['VP8 '][0]['height']; 1200 } else { 1201 $this->error('Expecting 9D 01 2A at offset '.($thisfile_riff['WEBP']['VP8 '][0]['offset'] + 8 + 3).', found "'.getid3_lib::PrintHexBytes(substr($WEBP_VP8_header, 3, 3)).'"'); 1202 } 1203 1204 } 1205 if (!empty($thisfile_riff['WEBP']['VP8L'][0]['size'])) { 1206 $old_offset = $this->ftell(); 1207 $this->fseek($thisfile_riff['WEBP']['VP8L'][0]['offset'] + 8); // 4 bytes "VP8L" + 4 bytes chunk size 1208 $WEBP_VP8L_header = $this->fread(10); 1209 $this->fseek($old_offset); 1210 if (substr($WEBP_VP8L_header, 0, 1) == "\x2F") { 1211 $width_height_flags = getid3_lib::LittleEndian2Bin(substr($WEBP_VP8L_header, 1, 4)); 1212 $thisfile_riff['WEBP']['VP8L'][0]['width'] = bindec(substr($width_height_flags, 18, 14)) + 1; 1213 $thisfile_riff['WEBP']['VP8L'][0]['height'] = bindec(substr($width_height_flags, 4, 14)) + 1; 1214 $thisfile_riff['WEBP']['VP8L'][0]['alpha_is_used'] = (bool) bindec(substr($width_height_flags, 3, 1)); 1215 $thisfile_riff['WEBP']['VP8L'][0]['version'] = bindec(substr($width_height_flags, 0, 3)); 1216 1217 $info['video']['resolution_x'] = $thisfile_riff['WEBP']['VP8L'][0]['width']; 1218 $info['video']['resolution_y'] = $thisfile_riff['WEBP']['VP8L'][0]['height']; 1219 } else { 1220 $this->error('Expecting 2F at offset '.($thisfile_riff['WEBP']['VP8L'][0]['offset'] + 8).', found "'.getid3_lib::PrintHexBytes(substr($WEBP_VP8L_header, 0, 1)).'"'); 1221 } 1222 1223 } 1224 break; 1173 1225 1174 1226 default: 1175 $ info['error'][] = 'Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "'.$RIFFsubtype.'" instead';1227 $this->error('Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA|WEBP), found "'.$RIFFsubtype.'" instead'); 1176 1228 //unset($info['fileformat']); 1177 1229 } … … 1186 1238 if (isset($thisfile_riff[$RIFFsubtype][$ID3v2_key_bad]) && !array_key_exists($ID3v2_key_good, $thisfile_riff[$RIFFsubtype])) { 1187 1239 $thisfile_riff[$RIFFsubtype][$ID3v2_key_good] = $thisfile_riff[$RIFFsubtype][$ID3v2_key_bad]; 1188 $ info['warning'][] = 'mapping "'.$ID3v2_key_bad.'" chunk to "'.$ID3v2_key_good.'"';1240 $this->warning('mapping "'.$ID3v2_key_bad.'" chunk to "'.$ID3v2_key_good.'"'); 1189 1241 } 1190 1242 } … … 1510 1562 if (!empty($getid3_temp->info['warning'])) { 1511 1563 foreach ($getid3_temp->info['warning'] as $key => $value) { 1512 $ info['warning'][] = $value;1564 $this->warning($value); 1513 1565 } 1514 1566 }
Note: See TracChangeset
for help on using the changeset viewer.