WordPress 4.3
[autoinstalls/wordpress.git] / wp-includes / ID3 / module.audio-video.quicktime.php
index 03f7a922f3e75799f71a62df463ef515012aca30..482c091237ed7ba0afa273c162d9fca324374ef1 100644 (file)
@@ -35,7 +35,7 @@ class getid3_quicktime extends getid3_handler
 
                $offset      = 0;
                $atomcounter = 0;
-
+               $atom_data_read_buffer_size = ($info['php_memory_limit'] ? round($info['php_memory_limit'] / 2) : $this->getid3->option_fread_buffer_size * 1024); // allow [default: 32MB] if PHP configured with no memory_limit
                while ($offset < $info['avdataend']) {
                        if (!getid3_lib::intValueSupported($offset)) {
                                $info['error'][] = 'Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
@@ -68,7 +68,7 @@ class getid3_quicktime extends getid3_handler
                                break;
                        }
                        $atomHierarchy = array();
-                       $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, $this->fread(min($atomsize, round($this->getid3->memory_limit / 2))), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);
+                       $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, $this->fread(min($atomsize, $atom_data_read_buffer_size)), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);
 
                        $offset += $atomsize;
                        $atomcounter++;
@@ -799,9 +799,9 @@ if (!empty($atom_structure['sample_description_table'][$i]['width']) && !empty($
                                //$FrameRateCalculatorArray = array();
                                $frames_count = 0;
 
-                               $max_stts_entries_to_scan = min(floor($this->getid3->memory_limit / 10000), $atom_structure['number_entries']);
+                               $max_stts_entries_to_scan = ($info['php_memory_limit'] ? min(floor($this->getid3->memory_limit / 10000), $atom_structure['number_entries']) : $atom_structure['number_entries']);
                                if ($max_stts_entries_to_scan < $atom_structure['number_entries']) {
-                                       $info['warning'][] = 'QuickTime atom "stts" has '.$atom_structure['number_entries'].' but only scanning the first '.$max_stts_entries_to_scan.' entries due to limited PHP memory available ('.floor($this->getid3->memory_limit / 1048576).'MB).';
+                                       $info['warning'][] = 'QuickTime atom "stts" has '.$atom_structure['number_entries'].' but only scanning the first '.$max_stts_entries_to_scan.' entries due to limited PHP memory available ('.floor($atom_structure['number_entries'] / 1048576).'MB).';
                                }
                                for ($i = 0; $i < $max_stts_entries_to_scan; $i++) {
                                        $atom_structure['time_to_sample_table'][$i]['sample_count']    = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
@@ -1399,7 +1399,7 @@ if (!empty($atom_structure['sample_description_table'][$i]['width']) && !empty($
                        case "\x00\x00\x00\x00":
                        case 'meta': // METAdata atom
                                // some kind of metacontainer, may contain a big data dump such as:
-                               // mdta keys \ 5 mdtacom.apple.quicktime.make (mdtacom.apple.quicktime.creationdate ,mdtacom.apple.quicktime.location.ISO6709 $mdtacom.apple.quicktime.software !mdtacom.apple.quicktime.model ilst \1d \ 1 \15data \ 1DE\10Apple 0 \ 2 (data \ 1DE\102011-05-11T17:54:04+0200 2 \ 3 *data \ 1DE\10+52.4936+013.3897+040.247/ \1d \ 4 \15data \ 1DE\104.3.1 \ 5 \18data \ 1DE\10iPhone 4
+                               // mdta keys \005 mdtacom.apple.quicktime.make (mdtacom.apple.quicktime.creationdate ,mdtacom.apple.quicktime.location.ISO6709 $mdtacom.apple.quicktime.software !mdtacom.apple.quicktime.model ilst \01D \001 \015data \001DE\010Apple 0 \002 (data \001DE\0102011-05-11T17:54:04+0200 2 \003 *data \001DE\010+52.4936+013.3897+040.247/ \01D \004 \015data \001DE\0104.3.1 \005 \018data \001DE\010iPhone 4
                                // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt
 
                    $atom_structure['version']   =          getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
@@ -2243,4 +2243,4 @@ echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br
                return substr($pascalstring, 1);
        }
 
-}
\ No newline at end of file
+}