Parser::parse_meta( int $num_remaining_bytes ): Avifinfo\Status
- Source
wp-includes/class-avif-info.php:673
Description
It looks for the primary item ID in the "pitm" box and recurses into other boxes to find its features.
Compatibility
- WordPress
- core
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$num_remaining_bytesint- The number of bytes that should be available from the resource.
Return value
Avifinfo\Status- FOUND on success or an error on failure.
Performance profile
How much work a call to Parser::parse_meta() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Light
- Scaling
- Scales with input
- Instructions
- 18–65
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 112.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What one call costs · 7 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost Parser::parse_meta() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 18–30 | ->parse() |
$status == false | 33–38 | ->parse(), ->parse_iprp() |
$status == false | 36–41 | ->parse(), ->parse_iref() |
$status == false | 37–41 | ->parse(), skip() |
$status == false && !$num_remaining_bytes && !$data | 37–38 | ->parse(), read() |
$status == false && !$num_remaining_bytes && $data && $primary_item_id | 45–46 | ->parse(), read(), read_big_endian() |
$status == false && !$num_remaining_bytes && $data && !$primary_item_id | 60–65 | ->parse(), read(), read_big_endian(), skip() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 112 instructions, 18–65 executed per call, 13 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 6
- read()Reads bytes and advances the stream position by the same count.
- read_big_endian()Reads an unsigned integer with most significant bits first.
- skip()Advances the stream position by the given offset.
- \Avifinfo\Box::__construct()
- \Avifinfo\Parser::parse_iprp()
- \Avifinfo\Parser::parse_iref()
Source code
private function parse_meta( $num_remaining_bytes ) { do { $box = new Box(); $status = $box->parse( $this->handle, $this->num_parsed_boxes, $num_remaining_bytes ); if ( $status != FOUND ) { return $status; } if ( $box->type == 'pitm' ) { // See ISO/IEC 14496-12:2015(E) 8.11.4.2 $num_bytes_per_id = ( $box->version == 0 ) ? 2 : 4; if ( $num_bytes_per_id > $num_remaining_bytes ) { return INVALID; } if ( !( $data = read( $this->handle, $num_bytes_per_id ) ) ) { return TRUNCATED; } $primary_item_id = read_big_endian( $data, $num_bytes_per_id ); if ( $primary_item_id > MAX_VALUE ) { return ABORTED; } $this->features->has_primary_item = true; $this->features->primary_item_id = $primary_item_id; if ( !skip( $this->handle, $box->content_size - $num_bytes_per_id ) ) { return TRUNCATED; } } else if ( $box->type == 'iprp' ) { $status = $this->parse_iprp( $box->content_size ); if ( $status != NOT_FOUND ) { return $status; } } else if ( $box->type == 'iref' ) { $status = $this->parse_iref( $box->content_size ); if ( $status != NOT_FOUND ) { return $status; } } else { if ( !skip( $this->handle, $box->content_size ) ) { return TRUNCATED; } } $num_remaining_bytes -= $box->size; } while ( $num_remaining_bytes != 0 ); // According to ISO/IEC 14496-12:2012(E) 8.11.1.1 there is at most one "meta". return INVALID; }Changelog
Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/class-avif-info.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.