wppaste
WordPress

Box

Source
wp-includes/class-avif-info.php:216

Compatibility

WordPress
core
  • 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).

Properties · 5

$sizepublic
$typepublic
$versionpublic
$flagspublic
$content_sizepublic

Methods · 1

Source code

class Box {  public $size; // In bytes.  public $type; // Four characters.  public $version; // 0 or actual version if this is a full box.  public $flags; // 0 or actual value if this is a full box.  public $content_size; // 'size' minus the header size.   /**   * Reads the box header.   *   * @param stream  $handle              The resource the header will be parsed from.   * @param int     $num_parsed_boxes    The total number of parsed boxes. Prevents timeouts.   * @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.   */  public function parse( $handle, &$num_parsed_boxes, $num_remaining_bytes = MAX_SIZE ) {    // See ISO/IEC 14496-12:2012(E) 4.2    $header_size = 8; // box 32b size + 32b type (at least)    if ( $header_size > $num_remaining_bytes ) {      return INVALID;    }    if ( !( $data = read( $handle, 8 ) ) ) {      return TRUNCATED;    }    $this->size = read_big_endian( $data, 4 );    $this->type = substr( $data, 4, 4 );    // 'box->size==1' means 64-bit size should be read after the box type.    // 'box->size==0' means this box extends to all remaining bytes.    if ( $this->size == 1 ) {      $header_size += 8;      if ( $header_size > $num_remaining_bytes ) {        return INVALID;      }      if ( !( $data = read( $handle, 8 ) ) ) {        return TRUNCATED;      }      // Stop the parsing if any box has a size greater than 4GB.      if ( read_big_endian( $data, 4 ) != 0 ) {        return ABORTED;      }      // Read the 32 least-significant bits.      $this->size = read_big_endian( substr( $data, 4, 4 ), 4 );    } else if ( $this->size == 0 ) {      // ISO/IEC 14496-12 4.2.2:      //   if size is 0, then this box shall be in a top-level box      //   (i.e. not contained in another box)      // Unfortunately the presence of a parent box is unknown here.      $this->size = $num_remaining_bytes;    }    if ( $this->size < $header_size ) {      return INVALID;    }    if ( $this->size > $num_remaining_bytes ) {      return INVALID;    }     // 16 bytes of usertype should be read here if the box type is 'uuid'.    // 'uuid' boxes are skipped so usertype is part of the skipped body.     $has_fullbox_header = $this->type == 'meta' || $this->type == 'pitm' ||                          $this->type == 'ipma' || $this->type == 'ispe' ||                          $this->type == 'pixi' || $this->type == 'iref' ||                          $this->type == 'auxC';    if ( $has_fullbox_header ) {      $header_size += 4;    }    if ( $this->size < $header_size ) {      return INVALID;    }    $this->content_size = $this->size - $header_size;    // Avoid timeouts. The maximum number of parsed boxes is arbitrary.    ++$num_parsed_boxes;    if ( $num_parsed_boxes >= MAX_NUM_BOXES ) {      return ABORTED;    }     $this->version = 0;    $this->flags   = 0;    if ( $has_fullbox_header ) {      if ( !( $data = read( $handle, 4 ) ) ) {

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.0.4 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.