wppaste
WordPress

Parser::parse_iprp( int $num_remaining_bytes ): Avifinfo\Status

Source
wp-includes/class-avif-info.php:499
Parses an "iprp" box.

Description

The "ipco" box contains the properties which are linked to items by the "ipma" box.

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_iprp() 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

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
18–139

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 231.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What one call costs · 12 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost Parser::parse_iprp() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always18–29->parse()
$status == false30–35->parse(), ->parse_ipco()
$status == false34–38->parse(), skip()
$status == false && !$num_read_bytes && !$data37->parse(), read()
$status == false && !$num_read_bytes && $data && $status != false67–82->parse(), read(), read_big_endian(), ->get_primary_item_features()
$status == false && $data75–78->parse(), read(), read_big_endian()
$status == false && !$num_read_bytes && $data77–96->parse(), read(), read_big_endian(), ->get_primary_item_features(), skip()
$status == false && !$num_read_bytes84–87->parse(), read(), read_big_endian(), read()
$status == false && !$num_read_bytes && $data && $property && $status != false110–125->parse(), read(), read_big_endian(), read(), read_big_endian(), read_big_endian(), ->get_primary_item_features()
$status == false && $data115–118->parse(), read(), read_big_endian(), read(), read_big_endian(), read_big_endian()
$status == false && !$num_read_bytes && $data && $property120–139->parse(), read(), read_big_endian(), read(), read_big_endian(), read_big_endian(), ->get_primary_item_features(), skip()
$status == false && !$num_read_bytes123–126->parse(), read(), read_big_endian(), read(), read_big_endian(), read_big_endian(), read()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev23118–13926
8.523118–13926
8.423118–139266 fewer instructions than PHP 8.3
8.323718–14526
8.223718–14526
8.123718–14526
7.423718–14526

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_ipco()
  • \Avifinfo\Prop::__construct()

Source code

  private function parse_iprp( $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 == 'ipco' ) {        $status = $this->parse_ipco( $box->content_size );        if ( $status != NOT_FOUND ) {          return $status;        }      } else if ( $box->type == 'ipma' ) {        // See ISO/IEC 23008-12:2017(E) 9.3.2        $num_read_bytes = 4;        if ( $box->content_size < $num_read_bytes ) {          return INVALID;        }        if ( !( $data = read( $this->handle, $num_read_bytes ) ) ) {          return TRUNCATED;        }        $entry_count        = read_big_endian( $data, 4 );        $id_num_bytes       = ( $box->version < 1 ) ? 2 : 4;        $index_num_bytes    = ( $box->flags & 1 ) ? 2 : 1;        $essential_bit_mask = ( $box->flags & 1 ) ? 0x8000 : 0x80;         for ( $entry = 0; $entry < $entry_count; ++$entry ) {          if ( $entry >= MAX_PROPS ||               count( $this->features->props ) >= MAX_PROPS ) {            $this->data_was_skipped = true;            break;          }          $num_read_bytes += $id_num_bytes + 1;          if ( $box->content_size < $num_read_bytes ) {            return INVALID;          }          if ( !( $data = read( $this->handle, $id_num_bytes + 1 ) ) ) {            return TRUNCATED;          }          $item_id           = read_big_endian(              substr( $data, 0, $id_num_bytes ), $id_num_bytes );          $association_count = read_big_endian(              substr( $data, $id_num_bytes, 1 ), 1 );           for ( $property = 0; $property < $association_count; ++$property ) {            if ( $property >= MAX_PROPS ||                 count( $this->features->props ) >= MAX_PROPS ) {              $this->data_was_skipped = true;              break;            }            $num_read_bytes += $index_num_bytes;            if ( $box->content_size < $num_read_bytes ) {              return INVALID;            }            if ( !( $data = read( $this->handle, $index_num_bytes ) ) ) {              return TRUNCATED;            }            $value          = read_big_endian( $data, $index_num_bytes );            // $essential = ($value & $essential_bit_mask);  // Unused.            $property_index = ( $value & ~$essential_bit_mask );            if ( $property_index <= MAX_VALUE && $item_id <= MAX_VALUE ) {              $prop_count = count( $this->features->props );              $this->features->props[$prop_count]                 = new Prop();              $this->features->props[$prop_count]->property_index = $property_index;              $this->features->props[$prop_count]->item_id        = $item_id;            } else {              $this->data_was_skipped = true;            }          }          if ( $property < $association_count ) {            break; // Do not read garbage.          }        }         // If all features are available now, do not look further.        $status = $this->features->get_primary_item_features();        if ( $status != NOT_FOUND ) {          return $status;        }

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 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.