Title: Parser::parse_iprp
Published: April 3, 2024
Last modified: April 28, 2025

---

# Parser::parse_iprp( int $num_remaining_bytes ): AvifinfoStatus

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/avifinfo-parser/parse_iprp/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/avifinfo-parser/parse_iprp/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/avifinfo-parser/parse_iprp/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/avifinfo-parser/parse_iprp/?output_format=md#source)

[ Back to top](https://developer.wordpress.org/reference/classes/avifinfo-parser/parse_iprp/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Parses an “iprp” box.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/avifinfo-parser/parse_iprp/?output_format=md#description)󠁿

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/avifinfo-parser/parse_iprp/?output_format=md#parameters)󠁿

 `$handle`Avifinfostreamrequired

The resource the box will be parsed from.

`$num_remaining_bytes`intrequired

The number of bytes that should be available from the resource.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/avifinfo-parser/parse_iprp/?output_format=md#return)󠁿

 AvifinfoStatus FOUND on success or an error on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/avifinfo-parser/parse_iprp/?output_format=md#source)󠁿

    ```php
     *
     * The "ipco" box contains the properties which are linked to items by the "ipma" box.
     *
     * @param stream  $handle              The resource the box will be parsed from.
     * @param int     $num_remaining_bytes The number of bytes that should be available from the resource.
     * @return Status                      FOUND on success or an error on failure.
     */
    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;
          }

          // Mostly if 'data_was_skipped'.
          if ( !skip( $this->handle, $box->content_size - $num_read_bytes ) ) {
            return TRUNCATED;
          }
        } else {
          if ( !skip( $this->handle, $box->content_size ) ) {
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-avif-info.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-avif-info.php#L492)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-avif-info.php#L492-L585)

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Favifinfo-parser%2Fparse_iprp%2F)
before being able to contribute a note or feedback.