AVCSequenceParameterSetReader

The WordPress Core AVCSequenceParameterSetReader class.

Defined (1)

The class is defined in the following location(s).

/wp-includes/ID3/module.audio-video.flv.php  
  1. class AVCSequenceParameterSetReader { 
  2. public $sps; 
  3. public $start = 0; 
  4. public $currentBytes = 0; 
  5. public $currentBits = 0; 
  6. public $width; 
  7. public $height; 
  8.  
  9. public function __construct($sps) { 
  10. $this->sps = $sps; 
  11.  
  12. public function readData() { 
  13. $this->skipBits(8); 
  14. $this->skipBits(8); 
  15. $profile = $this->getBits(8); // read profile 
  16. if ($profile > 0) { 
  17. $this->skipBits(8); 
  18. $level_idc = $this->getBits(8); // level_idc 
  19. $this->expGolombUe(); // seq_parameter_set_id // sps 
  20. $this->expGolombUe(); // log2_max_frame_num_minus4 
  21. $picOrderType = $this->expGolombUe(); // pic_order_cnt_type 
  22. if ($picOrderType == 0) { 
  23. $this->expGolombUe(); // log2_max_pic_order_cnt_lsb_minus4 
  24. } elseif ($picOrderType == 1) { 
  25. $this->skipBits(1); // delta_pic_order_always_zero_flag 
  26. $this->expGolombSe(); // offset_for_non_ref_pic 
  27. $this->expGolombSe(); // offset_for_top_to_bottom_field 
  28. $num_ref_frames_in_pic_order_cnt_cycle = $this->expGolombUe(); // num_ref_frames_in_pic_order_cnt_cycle 
  29. for ($i = 0; $i < $num_ref_frames_in_pic_order_cnt_cycle; $i++) { 
  30. $this->expGolombSe(); // offset_for_ref_frame[ i ] 
  31. $this->expGolombUe(); // num_ref_frames 
  32. $this->skipBits(1); // gaps_in_frame_num_value_allowed_flag 
  33. $pic_width_in_mbs_minus1 = $this->expGolombUe(); // pic_width_in_mbs_minus1 
  34. $pic_height_in_map_units_minus1 = $this->expGolombUe(); // pic_height_in_map_units_minus1 
  35.  
  36. $frame_mbs_only_flag = $this->getBits(1); // frame_mbs_only_flag 
  37. if ($frame_mbs_only_flag == 0) { 
  38. $this->skipBits(1); // mb_adaptive_frame_field_flag 
  39. $this->skipBits(1); // direct_8x8_inference_flag 
  40. $frame_cropping_flag = $this->getBits(1); // frame_cropping_flag 
  41.  
  42. $frame_crop_left_offset = 0; 
  43. $frame_crop_right_offset = 0; 
  44. $frame_crop_top_offset = 0; 
  45. $frame_crop_bottom_offset = 0; 
  46.  
  47. if ($frame_cropping_flag) { 
  48. $frame_crop_left_offset = $this->expGolombUe(); // frame_crop_left_offset 
  49. $frame_crop_right_offset = $this->expGolombUe(); // frame_crop_right_offset 
  50. $frame_crop_top_offset = $this->expGolombUe(); // frame_crop_top_offset 
  51. $frame_crop_bottom_offset = $this->expGolombUe(); // frame_crop_bottom_offset 
  52. $this->skipBits(1); // vui_parameters_present_flag 
  53. // etc 
  54.  
  55. $this->width = (($pic_width_in_mbs_minus1 + 1) * 16) - ($frame_crop_left_offset * 2) - ($frame_crop_right_offset * 2); 
  56. $this->height = ((2 - $frame_mbs_only_flag) * ($pic_height_in_map_units_minus1 + 1) * 16) - ($frame_crop_top_offset * 2) - ($frame_crop_bottom_offset * 2); 
  57.  
  58. public function skipBits($bits) { 
  59. $newBits = $this->currentBits + $bits; 
  60. $this->currentBytes += (int)floor($newBits / 8); 
  61. $this->currentBits = $newBits % 8; 
  62.  
  63. public function getBit() { 
  64. $result = (getid3_lib::BigEndian2Int(substr($this->sps, $this->currentBytes, 1)) >> (7 - $this->currentBits)) & 0x01; 
  65. $this->skipBits(1); 
  66. return $result; 
  67.  
  68. public function getBits($bits) { 
  69. $result = 0; 
  70. for ($i = 0; $i < $bits; $i++) { 
  71. $result = ($result << 1) + $this->getBit(); 
  72. return $result; 
  73.  
  74. public function expGolombUe() { 
  75. $significantBits = 0; 
  76. $bit = $this->getBit(); 
  77. while ($bit == 0) { 
  78. $significantBits++; 
  79. $bit = $this->getBit(); 
  80.  
  81. if ($significantBits > 31) { 
  82. // something is broken, this is an emergency escape to prevent infinite loops 
  83. return 0; 
  84. return (1 << $significantBits) + $this->getBits($significantBits) - 1; 
  85.  
  86. public function expGolombSe() { 
  87. $result = $this->expGolombUe(); 
  88. if (($result & 0x01) == 0) { 
  89. return -($result >> 1); 
  90. } else { 
  91. return ($result + 1) >> 1; 
  92.  
  93. public function getWidth() { 
  94. return $this->width; 
  95.  
  96. public function getHeight() { 
  97. return $this->height;