module.audio-video.mpeg.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <?php
  2. /////////////////////////////////////////////////////////////////
  3. /// getID3() by James Heinrich <info@getid3.org> //
  4. // available at http://getid3.sourceforge.net //
  5. // or http://www.getid3.org //
  6. // also https://github.com/JamesHeinrich/getID3 //
  7. /////////////////////////////////////////////////////////////////
  8. // See readme.txt for more details //
  9. /////////////////////////////////////////////////////////////////
  10. // //
  11. // module.audio-video.mpeg.php //
  12. // module for analyzing MPEG files //
  13. // dependencies: module.audio.mp3.php //
  14. // ///
  15. /////////////////////////////////////////////////////////////////
  16. getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
  17. class getid3_mpeg extends getid3_handler {
  18. const START_CODE_BASE = "\x00\x00\x01";
  19. const VIDEO_PICTURE_START = "\x00\x00\x01\x00";
  20. const VIDEO_USER_DATA_START = "\x00\x00\x01\xB2";
  21. const VIDEO_SEQUENCE_HEADER = "\x00\x00\x01\xB3";
  22. const VIDEO_SEQUENCE_ERROR = "\x00\x00\x01\xB4";
  23. const VIDEO_EXTENSION_START = "\x00\x00\x01\xB5";
  24. const VIDEO_SEQUENCE_END = "\x00\x00\x01\xB7";
  25. const VIDEO_GROUP_START = "\x00\x00\x01\xB8";
  26. const AUDIO_START = "\x00\x00\x01\xC0";
  27. public function Analyze() {
  28. $info = &$this->getid3->info;
  29. $info['fileformat'] = 'mpeg';
  30. $this->fseek($info['avdataoffset']);
  31. $MPEGstreamData = $this->fread($this->getid3->option_fread_buffer_size);
  32. $MPEGstreamBaseOffset = 0; // how far are we from the beginning of the file data ($info['avdataoffset'])
  33. $MPEGstreamDataOffset = 0; // how far are we from the beginning of the buffer data (~32kB)
  34. $StartCodeValue = false;
  35. $prevStartCodeValue = false;
  36. $GOPcounter = -1;
  37. $FramesByGOP = array();
  38. $ParsedAVchannels = array();
  39. do {
  40. //echo $MPEGstreamDataOffset.' vs '.(strlen($MPEGstreamData) - 1024).'<Br>';
  41. if ($MPEGstreamDataOffset > (strlen($MPEGstreamData) - 16384)) {
  42. // buffer running low, get more data
  43. //echo 'reading more data<br>';
  44. $MPEGstreamData .= $this->fread($this->getid3->option_fread_buffer_size);
  45. if (strlen($MPEGstreamData) > $this->getid3->option_fread_buffer_size) {
  46. $MPEGstreamData = substr($MPEGstreamData, $MPEGstreamDataOffset);
  47. $MPEGstreamBaseOffset += $MPEGstreamDataOffset;
  48. $MPEGstreamDataOffset = 0;
  49. }
  50. }
  51. if (($StartCodeOffset = strpos($MPEGstreamData, self::START_CODE_BASE, $MPEGstreamDataOffset)) === false) {
  52. //echo 'no more start codes found.<br>';
  53. break;
  54. } else {
  55. $MPEGstreamDataOffset = $StartCodeOffset;
  56. $prevStartCodeValue = $StartCodeValue;
  57. $StartCodeValue = ord(substr($MPEGstreamData, $StartCodeOffset + 3, 1));
  58. //echo 'Found "'.strtoupper(dechex($StartCodeValue)).'" at offset '.($MPEGstreamBaseOffset + $StartCodeOffset).' ($MPEGstreamDataOffset = '.$MPEGstreamDataOffset.')<br>';
  59. }
  60. $MPEGstreamDataOffset += 4;
  61. switch ($StartCodeValue) {
  62. case 0x00: // picture_start_code
  63. if (!empty($info['mpeg']['video']['bitrate_mode']) && ($info['mpeg']['video']['bitrate_mode'] == 'vbr')) {
  64. $bitstream = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $StartCodeOffset + 4, 4));
  65. $bitstreamoffset = 0;
  66. $PictureHeader = array();
  67. $PictureHeader['temporal_reference'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 10); // 10-bit unsigned integer associated with each input picture. It is incremented by one, modulo 1024, for each input frame. When a frame is coded as two fields the temporal reference in the picture header of both fields is the same. Following a group start header the temporal reference of the earliest picture (in display order) shall be reset to zero.
  68. $PictureHeader['picture_coding_type'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 3); // 3 bits for picture_coding_type
  69. $PictureHeader['vbv_delay'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 16); // 16 bits for vbv_delay
  70. //... etc
  71. $FramesByGOP[$GOPcounter][] = $PictureHeader;
  72. }
  73. break;
  74. case 0xB3: // sequence_header_code
  75. /*
  76. Note: purposely doing the less-pretty (and probably a bit slower) method of using string of bits rather than bitwise operations.
  77. Mostly because PHP 32-bit doesn't handle unsigned integers well for bitwise operation.
  78. Also the MPEG stream is designed as a bitstream and often doesn't align nicely with byte boundaries.
  79. */
  80. $info['video']['codec'] = 'MPEG-1'; // will be updated if extension_start_code found
  81. $bitstream = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $StartCodeOffset + 4, 8));
  82. $bitstreamoffset = 0;
  83. $info['mpeg']['video']['raw']['horizontal_size_value'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 12); // 12 bits for horizontal frame size. Note: horizontal_size_extension, if present, will add 2 most-significant bits to this value
  84. $info['mpeg']['video']['raw']['vertical_size_value'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 12); // 12 bits for vertical frame size. Note: vertical_size_extension, if present, will add 2 most-significant bits to this value
  85. $info['mpeg']['video']['raw']['aspect_ratio_information'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 4); // 4 bits for aspect_ratio_information
  86. $info['mpeg']['video']['raw']['frame_rate_code'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 4); // 4 bits for Frame Rate id code
  87. $info['mpeg']['video']['raw']['bitrate'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 18); // 18 bits for bit_rate_value (18 set bits = VBR, otherwise bitrate = this value * 400)
  88. $marker_bit = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // The term "marker_bit" indicates a one bit field in which the value zero is forbidden. These marker bits are introduced at several points in the syntax to avoid start code emulation.
  89. $info['mpeg']['video']['raw']['vbv_buffer_size'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 10); // 10 bits vbv_buffer_size_value
  90. $info['mpeg']['video']['raw']['constrained_param_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: constrained_param_flag
  91. $info['mpeg']['video']['raw']['load_intra_quantiser_matrix'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: load_intra_quantiser_matrix
  92. if ($info['mpeg']['video']['raw']['load_intra_quantiser_matrix']) {
  93. $bitstream .= getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $StartCodeOffset + 12, 64));
  94. for ($i = 0; $i < 64; $i++) {
  95. $info['mpeg']['video']['raw']['intra_quantiser_matrix'][$i] = self::readBitsFromStream($bitstream, $bitstreamoffset, 8);
  96. }
  97. }
  98. $info['mpeg']['video']['raw']['load_non_intra_quantiser_matrix'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1);
  99. if ($info['mpeg']['video']['raw']['load_non_intra_quantiser_matrix']) {
  100. $bitstream .= getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $StartCodeOffset + 12 + ($info['mpeg']['video']['raw']['load_intra_quantiser_matrix'] ? 64 : 0), 64));
  101. for ($i = 0; $i < 64; $i++) {
  102. $info['mpeg']['video']['raw']['non_intra_quantiser_matrix'][$i] = self::readBitsFromStream($bitstream, $bitstreamoffset, 8);
  103. }
  104. }
  105. $info['mpeg']['video']['pixel_aspect_ratio'] = self::videoAspectRatioLookup($info['mpeg']['video']['raw']['aspect_ratio_information']);
  106. $info['mpeg']['video']['pixel_aspect_ratio_text'] = self::videoAspectRatioTextLookup($info['mpeg']['video']['raw']['aspect_ratio_information']);
  107. $info['mpeg']['video']['frame_rate'] = self::videoFramerateLookup($info['mpeg']['video']['raw']['frame_rate_code']);
  108. if ($info['mpeg']['video']['raw']['bitrate'] == 0x3FFFF) { // 18 set bits = VBR
  109. //$this->warning('This version of getID3() ['.$this->getid3->version().'] cannot determine average bitrate of VBR MPEG video files');
  110. $info['mpeg']['video']['bitrate_mode'] = 'vbr';
  111. } else {
  112. $info['mpeg']['video']['bitrate'] = $info['mpeg']['video']['raw']['bitrate'] * 400;
  113. $info['mpeg']['video']['bitrate_mode'] = 'cbr';
  114. $info['video']['bitrate'] = $info['mpeg']['video']['bitrate'];
  115. }
  116. $info['video']['resolution_x'] = $info['mpeg']['video']['raw']['horizontal_size_value'];
  117. $info['video']['resolution_y'] = $info['mpeg']['video']['raw']['vertical_size_value'];
  118. $info['video']['frame_rate'] = $info['mpeg']['video']['frame_rate'];
  119. $info['video']['bitrate_mode'] = $info['mpeg']['video']['bitrate_mode'];
  120. $info['video']['pixel_aspect_ratio'] = $info['mpeg']['video']['pixel_aspect_ratio'];
  121. $info['video']['lossless'] = false;
  122. $info['video']['bits_per_sample'] = 24;
  123. break;
  124. case 0xB5: // extension_start_code
  125. $info['video']['codec'] = 'MPEG-2';
  126. $bitstream = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $StartCodeOffset + 4, 8)); // 48 bits for Sequence Extension ID; 61 bits for Sequence Display Extension ID; 59 bits for Sequence Scalable Extension ID
  127. $bitstreamoffset = 0;
  128. $info['mpeg']['video']['raw']['extension_start_code_identifier'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 4); // 4 bits for extension_start_code_identifier
  129. //echo $info['mpeg']['video']['raw']['extension_start_code_identifier'].'<br>';
  130. switch ($info['mpeg']['video']['raw']['extension_start_code_identifier']) {
  131. case 1: // 0001 Sequence Extension ID
  132. $info['mpeg']['video']['raw']['profile_and_level_indication'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 8); // 8 bits for profile_and_level_indication
  133. $info['mpeg']['video']['raw']['progressive_sequence'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: progressive_sequence
  134. $info['mpeg']['video']['raw']['chroma_format'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 2); // 2 bits for chroma_format
  135. $info['mpeg']['video']['raw']['horizontal_size_extension'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 2); // 2 bits for horizontal_size_extension
  136. $info['mpeg']['video']['raw']['vertical_size_extension'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 2); // 2 bits for vertical_size_extension
  137. $info['mpeg']['video']['raw']['bit_rate_extension'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 12); // 12 bits for bit_rate_extension
  138. $marker_bit = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // The term "marker_bit" indicates a one bit field in which the value zero is forbidden. These marker bits are introduced at several points in the syntax to avoid start code emulation.
  139. $info['mpeg']['video']['raw']['vbv_buffer_size_extension'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 8); // 8 bits for vbv_buffer_size_extension
  140. $info['mpeg']['video']['raw']['low_delay'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: low_delay
  141. $info['mpeg']['video']['raw']['frame_rate_extension_n'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 2); // 2 bits for frame_rate_extension_n
  142. $info['mpeg']['video']['raw']['frame_rate_extension_d'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 5); // 5 bits for frame_rate_extension_d
  143. $info['video']['resolution_x'] = ($info['mpeg']['video']['raw']['horizontal_size_extension'] << 12) | $info['mpeg']['video']['raw']['horizontal_size_value'];
  144. $info['video']['resolution_y'] = ($info['mpeg']['video']['raw']['vertical_size_extension'] << 12) | $info['mpeg']['video']['raw']['vertical_size_value'];
  145. $info['video']['interlaced'] = !$info['mpeg']['video']['raw']['progressive_sequence'];
  146. $info['mpeg']['video']['interlaced'] = !$info['mpeg']['video']['raw']['progressive_sequence'];
  147. $info['mpeg']['video']['chroma_format'] = self::chromaFormatTextLookup($info['mpeg']['video']['raw']['chroma_format']);
  148. break;
  149. case 2: // 0010 Sequence Display Extension ID
  150. $info['mpeg']['video']['raw']['video_format'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 3); // 3 bits for video_format
  151. $info['mpeg']['video']['raw']['colour_description'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: colour_description
  152. if ($info['mpeg']['video']['raw']['colour_description']) {
  153. $info['mpeg']['video']['raw']['colour_primaries'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 8); // 8 bits for colour_primaries
  154. $info['mpeg']['video']['raw']['transfer_characteristics'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 8); // 8 bits for transfer_characteristics
  155. $info['mpeg']['video']['raw']['matrix_coefficients'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 8); // 8 bits for matrix_coefficients
  156. }
  157. $info['mpeg']['video']['raw']['display_horizontal_size'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 14); // 14 bits for display_horizontal_size
  158. $marker_bit = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // The term "marker_bit" indicates a one bit field in which the value zero is forbidden. These marker bits are introduced at several points in the syntax to avoid start code emulation.
  159. $info['mpeg']['video']['raw']['display_vertical_size'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 14); // 14 bits for display_vertical_size
  160. $info['mpeg']['video']['video_format'] = self::videoFormatTextLookup($info['mpeg']['video']['raw']['video_format']);
  161. break;
  162. case 3: // 0011 Quant Matrix Extension ID
  163. break;
  164. case 5: // 0101 Sequence Scalable Extension ID
  165. $info['mpeg']['video']['raw']['scalable_mode'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 2); // 2 bits for scalable_mode
  166. $info['mpeg']['video']['raw']['layer_id'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 4); // 4 bits for layer_id
  167. if ($info['mpeg']['video']['raw']['scalable_mode'] == 1) { // "spatial scalability"
  168. $info['mpeg']['video']['raw']['lower_layer_prediction_horizontal_size'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 14); // 14 bits for lower_layer_prediction_horizontal_size
  169. $marker_bit = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // The term "marker_bit" indicates a one bit field in which the value zero is forbidden. These marker bits are introduced at several points in the syntax to avoid start code emulation.
  170. $info['mpeg']['video']['raw']['lower_layer_prediction_vertical_size'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 14); // 14 bits for lower_layer_prediction_vertical_size
  171. $info['mpeg']['video']['raw']['horizontal_subsampling_factor_m'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 5); // 5 bits for horizontal_subsampling_factor_m
  172. $info['mpeg']['video']['raw']['horizontal_subsampling_factor_n'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 5); // 5 bits for horizontal_subsampling_factor_n
  173. $info['mpeg']['video']['raw']['vertical_subsampling_factor_m'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 5); // 5 bits for vertical_subsampling_factor_m
  174. $info['mpeg']['video']['raw']['vertical_subsampling_factor_n'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 5); // 5 bits for vertical_subsampling_factor_n
  175. } elseif ($info['mpeg']['video']['raw']['scalable_mode'] == 3) { // "temporal scalability"
  176. $info['mpeg']['video']['raw']['picture_mux_enable'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: picture_mux_enable
  177. if ($info['mpeg']['video']['raw']['picture_mux_enable']) {
  178. $info['mpeg']['video']['raw']['mux_to_progressive_sequence'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: mux_to_progressive_sequence
  179. }
  180. $info['mpeg']['video']['raw']['picture_mux_order'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 3); // 3 bits for picture_mux_order
  181. $info['mpeg']['video']['raw']['picture_mux_factor'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 3); // 3 bits for picture_mux_factor
  182. }
  183. $info['mpeg']['video']['scalable_mode'] = self::scalableModeTextLookup($info['mpeg']['video']['raw']['scalable_mode']);
  184. break;
  185. case 7: // 0111 Picture Display Extension ID
  186. break;
  187. case 8: // 1000 Picture Coding Extension ID
  188. $info['mpeg']['video']['raw']['f_code_00'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 4); // 4 bits for f_code[0][0] (forward horizontal)
  189. $info['mpeg']['video']['raw']['f_code_01'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 4); // 4 bits for f_code[0][1] (forward vertical)
  190. $info['mpeg']['video']['raw']['f_code_10'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 4); // 4 bits for f_code[1][0] (backward horizontal)
  191. $info['mpeg']['video']['raw']['f_code_11'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 4); // 4 bits for f_code[1][1] (backward vertical)
  192. $info['mpeg']['video']['raw']['intra_dc_precision'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 2); // 2 bits for intra_dc_precision
  193. $info['mpeg']['video']['raw']['picture_structure'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 2); // 2 bits for picture_structure
  194. $info['mpeg']['video']['raw']['top_field_first'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: top_field_first
  195. $info['mpeg']['video']['raw']['frame_pred_frame_dct'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: frame_pred_frame_dct
  196. $info['mpeg']['video']['raw']['concealment_motion_vectors'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: concealment_motion_vectors
  197. $info['mpeg']['video']['raw']['q_scale_type'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: q_scale_type
  198. $info['mpeg']['video']['raw']['intra_vlc_format'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: intra_vlc_format
  199. $info['mpeg']['video']['raw']['alternate_scan'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: alternate_scan
  200. $info['mpeg']['video']['raw']['repeat_first_field'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: repeat_first_field
  201. $info['mpeg']['video']['raw']['chroma_420_type'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: chroma_420_type
  202. $info['mpeg']['video']['raw']['progressive_frame'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: progressive_frame
  203. $info['mpeg']['video']['raw']['composite_display_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: composite_display_flag
  204. if ($info['mpeg']['video']['raw']['composite_display_flag']) {
  205. $info['mpeg']['video']['raw']['v_axis'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: v_axis
  206. $info['mpeg']['video']['raw']['field_sequence'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 3); // 3 bits for field_sequence
  207. $info['mpeg']['video']['raw']['sub_carrier'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: sub_carrier
  208. $info['mpeg']['video']['raw']['burst_amplitude'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 7); // 7 bits for burst_amplitude
  209. $info['mpeg']['video']['raw']['sub_carrier_phase'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 8); // 8 bits for sub_carrier_phase
  210. }
  211. $info['mpeg']['video']['intra_dc_precision_bits'] = $info['mpeg']['video']['raw']['intra_dc_precision'] + 8;
  212. $info['mpeg']['video']['picture_structure'] = self::pictureStructureTextLookup($info['mpeg']['video']['raw']['picture_structure']);
  213. break;
  214. case 9: // 1001 Picture Spatial Scalable Extension ID
  215. break;
  216. case 10: // 1010 Picture Temporal Scalable Extension ID
  217. break;
  218. default:
  219. $this->warning('Unexpected $info[mpeg][video][raw][extension_start_code_identifier] value of '.$info['mpeg']['video']['raw']['extension_start_code_identifier']);
  220. break;
  221. }
  222. break;
  223. case 0xB8: // group_of_pictures_header
  224. $GOPcounter++;
  225. if ($info['mpeg']['video']['bitrate_mode'] == 'vbr') {
  226. $bitstream = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $StartCodeOffset + 4, 4)); // 27 bits needed for group_of_pictures_header
  227. $bitstreamoffset = 0;
  228. $GOPheader = array();
  229. $GOPheader['byte_offset'] = $MPEGstreamBaseOffset + $StartCodeOffset;
  230. $GOPheader['drop_frame_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: drop_frame_flag
  231. $GOPheader['time_code_hours'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 5); // 5 bits for time_code_hours
  232. $GOPheader['time_code_minutes'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 6); // 6 bits for time_code_minutes
  233. $marker_bit = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // The term "marker_bit" indicates a one bit field in which the value zero is forbidden. These marker bits are introduced at several points in the syntax to avoid start code emulation.
  234. $GOPheader['time_code_seconds'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 6); // 6 bits for time_code_seconds
  235. $GOPheader['time_code_pictures'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 6); // 6 bits for time_code_pictures
  236. $GOPheader['closed_gop'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: closed_gop
  237. $GOPheader['broken_link'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: broken_link
  238. $time_code_separator = ($GOPheader['drop_frame_flag'] ? ';' : ':'); // While non-drop time code is displayed with colons separating the digit pairs—"HH:MM:SS:FF"—drop frame is usually represented with a semi-colon (;) or period (.) as the divider between all the digit pairs—"HH;MM;SS;FF", "HH.MM.SS.FF"
  239. $GOPheader['time_code'] = sprintf('%02d'.$time_code_separator.'%02d'.$time_code_separator.'%02d'.$time_code_separator.'%02d', $GOPheader['time_code_hours'], $GOPheader['time_code_minutes'], $GOPheader['time_code_seconds'], $GOPheader['time_code_pictures']);
  240. $info['mpeg']['group_of_pictures'][] = $GOPheader;
  241. }
  242. break;
  243. case 0xC0: // audio stream
  244. case 0xC1: // audio stream
  245. case 0xC2: // audio stream
  246. case 0xC3: // audio stream
  247. case 0xC4: // audio stream
  248. case 0xC5: // audio stream
  249. case 0xC6: // audio stream
  250. case 0xC7: // audio stream
  251. case 0xC8: // audio stream
  252. case 0xC9: // audio stream
  253. case 0xCA: // audio stream
  254. case 0xCB: // audio stream
  255. case 0xCC: // audio stream
  256. case 0xCD: // audio stream
  257. case 0xCE: // audio stream
  258. case 0xCF: // audio stream
  259. case 0xD0: // audio stream
  260. case 0xD1: // audio stream
  261. case 0xD2: // audio stream
  262. case 0xD3: // audio stream
  263. case 0xD4: // audio stream
  264. case 0xD5: // audio stream
  265. case 0xD6: // audio stream
  266. case 0xD7: // audio stream
  267. case 0xD8: // audio stream
  268. case 0xD9: // audio stream
  269. case 0xDA: // audio stream
  270. case 0xDB: // audio stream
  271. case 0xDC: // audio stream
  272. case 0xDD: // audio stream
  273. case 0xDE: // audio stream
  274. case 0xDF: // audio stream
  275. //case 0xE0: // video stream
  276. //case 0xE1: // video stream
  277. //case 0xE2: // video stream
  278. //case 0xE3: // video stream
  279. //case 0xE4: // video stream
  280. //case 0xE5: // video stream
  281. //case 0xE6: // video stream
  282. //case 0xE7: // video stream
  283. //case 0xE8: // video stream
  284. //case 0xE9: // video stream
  285. //case 0xEA: // video stream
  286. //case 0xEB: // video stream
  287. //case 0xEC: // video stream
  288. //case 0xED: // video stream
  289. //case 0xEE: // video stream
  290. //case 0xEF: // video stream
  291. if (isset($ParsedAVchannels[$StartCodeValue])) {
  292. break;
  293. }
  294. $ParsedAVchannels[$StartCodeValue] = $StartCodeValue;
  295. // http://en.wikipedia.org/wiki/Packetized_elementary_stream
  296. // http://dvd.sourceforge.net/dvdinfo/pes-hdr.html
  297. /*
  298. $PackedElementaryStream = array();
  299. if ($StartCodeValue >= 0xE0) {
  300. $PackedElementaryStream['stream_type'] = 'video';
  301. $PackedElementaryStream['stream_id'] = $StartCodeValue - 0xE0;
  302. } else {
  303. $PackedElementaryStream['stream_type'] = 'audio';
  304. $PackedElementaryStream['stream_id'] = $StartCodeValue - 0xC0;
  305. }
  306. $PackedElementaryStream['packet_length'] = getid3_lib::BigEndian2Int(substr($MPEGstreamData, $StartCodeOffset + 4, 2));
  307. $bitstream = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $StartCodeOffset + 6, 3)); // more may be needed below
  308. $bitstreamoffset = 0;
  309. $PackedElementaryStream['marker_bits'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 2); // 2 bits for marker_bits -- should be "10" = 2
  310. echo 'marker_bits = '.$PackedElementaryStream['marker_bits'].'<br>';
  311. $PackedElementaryStream['scrambling_control'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 2); // 2 bits for scrambling_control -- 00 implies not scrambled
  312. $PackedElementaryStream['priority'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: priority
  313. $PackedElementaryStream['data_alignment_indicator'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: data_alignment_indicator -- 1 indicates that the PES packet header is immediately followed by the video start code or audio syncword
  314. $PackedElementaryStream['copyright'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: copyright -- 1 implies copyrighted
  315. $PackedElementaryStream['original_or_copy'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: original_or_copy -- 1 implies original
  316. $PackedElementaryStream['pts_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: pts_flag -- Presentation Time Stamp
  317. $PackedElementaryStream['dts_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: dts_flag -- Decode Time Stamp
  318. $PackedElementaryStream['escr_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: escr_flag -- Elementary Stream Clock Reference
  319. $PackedElementaryStream['es_rate_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: es_rate_flag -- Elementary Stream [data] Rate
  320. $PackedElementaryStream['dsm_trick_mode_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: dsm_trick_mode_flag -- DSM trick mode - not used by DVD
  321. $PackedElementaryStream['additional_copy_info_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: additional_copy_info_flag
  322. $PackedElementaryStream['crc_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: crc_flag
  323. $PackedElementaryStream['extension_flag'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 1); // 1 bit flag: extension_flag
  324. $PackedElementaryStream['pes_remain_header_length'] = self::readBitsFromStream($bitstream, $bitstreamoffset, 8); // 1 bit flag: priority
  325. $additional_header_bytes = 0;
  326. $additional_header_bytes += ($PackedElementaryStream['pts_flag'] ? 5 : 0);
  327. $additional_header_bytes += ($PackedElementaryStream['dts_flag'] ? 5 : 0);
  328. $additional_header_bytes += ($PackedElementaryStream['escr_flag'] ? 6 : 0);
  329. $additional_header_bytes += ($PackedElementaryStream['es_rate_flag'] ? 3 : 0);
  330. $additional_header_bytes += ($PackedElementaryStream['additional_copy_info_flag'] ? 1 : 0);
  331. $additional_header_bytes += ($PackedElementaryStream['crc_flag'] ? 2 : 0);
  332. $additional_header_bytes += ($PackedElementaryStream['extension_flag'] ? 1 : 0);
  333. $PackedElementaryStream['additional_header_bytes'] = $additional_header_bytes;
  334. $bitstream .= getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $StartCodeOffset + 9, $additional_header_bytes));
  335. $info['mpeg']['packed_elementary_streams'][$PackedElementaryStream['stream_type']][$PackedElementaryStream['stream_id']][] = $PackedElementaryStream;
  336. */
  337. $getid3_temp = new getID3();
  338. $getid3_temp->openfile($this->getid3->filename);
  339. $getid3_temp->info = $info;
  340. $getid3_mp3 = new getid3_mp3($getid3_temp);
  341. for ($i = 0; $i <= 7; $i++) {
  342. // some files have the MPEG-audio header 8 bytes after the end of the $00 $00 $01 $C0 signature, some have it up to 13 bytes (or more?) after
  343. // I have no idea why or what the difference is, so this is a stupid hack.
  344. // If anybody has any better idea of what's going on, please let me know - info@getid3.org
  345. $getid3_temp->info = $info; // only overwrite real data if valid header found
  346. //echo 'audio at? '.($MPEGstreamBaseOffset + $StartCodeOffset + 4 + 8 + $i).'<br>';
  347. if ($getid3_mp3->decodeMPEGaudioHeader($MPEGstreamBaseOffset + $StartCodeOffset + 4 + 8 + $i, $getid3_temp->info, false)) {
  348. //echo 'yes!<br>';
  349. $info = $getid3_temp->info;
  350. $info['audio']['bitrate_mode'] = 'cbr';
  351. $info['audio']['lossless'] = false;
  352. break;
  353. }
  354. }
  355. unset($getid3_temp, $getid3_mp3);
  356. break;
  357. case 0xBC: // Program Stream Map
  358. case 0xBD: // Private stream 1 (non MPEG audio, subpictures)
  359. case 0xBE: // Padding stream
  360. case 0xBF: // Private stream 2 (navigation data)
  361. case 0xF0: // ECM stream
  362. case 0xF1: // EMM stream
  363. case 0xF2: // DSM-CC stream
  364. case 0xF3: // ISO/IEC_13522_stream
  365. case 0xF4: // ITU-I Rec. H.222.1 type A
  366. case 0xF5: // ITU-I Rec. H.222.1 type B
  367. case 0xF6: // ITU-I Rec. H.222.1 type C
  368. case 0xF7: // ITU-I Rec. H.222.1 type D
  369. case 0xF8: // ITU-I Rec. H.222.1 type E
  370. case 0xF9: // ancilliary stream
  371. case 0xFA: // ISO/IEC 14496-1 SL-packtized stream
  372. case 0xFB: // ISO/IEC 14496-1 FlexMux stream
  373. case 0xFC: // metadata stream
  374. case 0xFD: // extended stream ID
  375. case 0xFE: // reserved data stream
  376. case 0xFF: // program stream directory
  377. // ignore
  378. break;
  379. default:
  380. // ignore
  381. break;
  382. }
  383. } while (true);
  384. // // Temporary hack to account for interleaving overhead:
  385. // if (!empty($info['video']['bitrate']) && !empty($info['audio']['bitrate'])) {
  386. // $info['playtime_seconds'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($info['video']['bitrate'] + $info['audio']['bitrate']);
  387. //
  388. // // Interleaved MPEG audio/video files have a certain amount of overhead that varies
  389. // // by both video and audio bitrates, and not in any sensible, linear/logarithmic pattern
  390. // // Use interpolated lookup tables to approximately guess how much is overhead, because
  391. // // playtime is calculated as filesize / total-bitrate
  392. // $info['playtime_seconds'] *= self::systemNonOverheadPercentage($info['video']['bitrate'], $info['audio']['bitrate']);
  393. //
  394. // //switch ($info['video']['bitrate']) {
  395. // // case('5000000'):
  396. // // $multiplier = 0.93292642112380355828048824319889;
  397. // // break;
  398. // // case('5500000'):
  399. // // $multiplier = 0.93582895375200989965359777343219;
  400. // // break;
  401. // // case('6000000'):
  402. // // $multiplier = 0.93796247714820932532911373859139;
  403. // // break;
  404. // // case('7000000'):
  405. // // $multiplier = 0.9413264083635103463010117778776;
  406. // // break;
  407. // // default:
  408. // // $multiplier = 1;
  409. // // break;
  410. // //}
  411. // //$info['playtime_seconds'] *= $multiplier;
  412. // //$info['warning'][] = 'Interleaved MPEG audio/video playtime may be inaccurate. With current hack should be within a few seconds of accurate. Report to info@getid3.org if off by more than 10 seconds.';
  413. // if ($info['video']['bitrate'] < 50000) {
  414. // $this->warning('Interleaved MPEG audio/video playtime may be slightly inaccurate for video bitrates below 100kbps. Except in extreme low-bitrate situations, error should be less than 1%. Report to info@getid3.org if greater than this.');
  415. // }
  416. // }
  417. //
  418. /*
  419. $time_prev = 0;
  420. $byte_prev = 0;
  421. $vbr_bitrates = array();
  422. foreach ($info['mpeg']['group_of_pictures'] as $gopkey => $gopdata) {
  423. $time_this = ($gopdata['time_code_hours'] * 3600) + ($gopdata['time_code_minutes'] * 60) + $gopdata['time_code_seconds'] + ($gopdata['time_code_seconds'] / 30);
  424. $byte_this = $gopdata['byte_offset'];
  425. if ($gopkey > 0) {
  426. if ($time_this > $time_prev) {
  427. $bytedelta = $byte_this - $byte_prev;
  428. $timedelta = $time_this - $time_prev;
  429. $this_bitrate = ($bytedelta * 8) / $timedelta;
  430. echo $gopkey.': ('.number_format($time_prev, 2).'-'.number_format($time_this, 2).') '.number_format($bytedelta).' bytes over '.number_format($timedelta, 3).' seconds = '.number_format($this_bitrate / 1000, 2).'kbps<br>';
  431. $time_prev = $time_this;
  432. $byte_prev = $byte_this;
  433. $vbr_bitrates[] = $this_bitrate;
  434. }
  435. }
  436. }
  437. echo 'average_File_bitrate = '.number_format(array_sum($vbr_bitrates) / count($vbr_bitrates), 1).'<br>';
  438. */
  439. //echo '<pre>'.print_r($FramesByGOP, true).'</pre>';
  440. if (!empty($info['mpeg']['video']['bitrate_mode']) && ($info['mpeg']['video']['bitrate_mode'] == 'vbr')) {
  441. $last_GOP_id = max(array_keys($FramesByGOP));
  442. $frames_in_last_GOP = count($FramesByGOP[$last_GOP_id]);
  443. $gopdata = &$info['mpeg']['group_of_pictures'][$last_GOP_id];
  444. $info['playtime_seconds'] = ($gopdata['time_code_hours'] * 3600) + ($gopdata['time_code_minutes'] * 60) + $gopdata['time_code_seconds'] + (($gopdata['time_code_pictures'] + $frames_in_last_GOP + 1) / $info['mpeg']['video']['frame_rate']);
  445. if (!isset($info['video']['bitrate'])) {
  446. $overall_bitrate = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];
  447. $info['video']['bitrate'] = $overall_bitrate - (isset($info['audio']['bitrate']) ? $info['audio']['bitrate'] : 0);
  448. }
  449. unset($info['mpeg']['group_of_pictures']);
  450. }
  451. return true;
  452. }
  453. private function readBitsFromStream(&$bitstream, &$bitstreamoffset, $bits_to_read, $return_singlebit_as_boolean=true) {
  454. $return = bindec(substr($bitstream, $bitstreamoffset, $bits_to_read));
  455. $bitstreamoffset += $bits_to_read;
  456. if (($bits_to_read == 1) && $return_singlebit_as_boolean) {
  457. $return = (bool) $return;
  458. }
  459. return $return;
  460. }
  461. public static function systemNonOverheadPercentage($VideoBitrate, $AudioBitrate) {
  462. $OverheadPercentage = 0;
  463. $AudioBitrate = max(min($AudioBitrate / 1000, 384), 32); // limit to range of 32kbps - 384kbps (should be only legal bitrates, but maybe VBR?)
  464. $VideoBitrate = max(min($VideoBitrate / 1000, 10000), 10); // limit to range of 10kbps - 10Mbps (beyond that curves flatten anyways, no big loss)
  465. //OMBB[audiobitrate] = array(video-10kbps, video-100kbps, video-1000kbps, video-10000kbps)
  466. $OverheadMultiplierByBitrate[32] = array(0, 0.9676287944368530, 0.9802276264360310, 0.9844916183244460, 0.9852821845179940);
  467. $OverheadMultiplierByBitrate[48] = array(0, 0.9779100089209830, 0.9787770035359320, 0.9846738664076130, 0.9852683013799960);
  468. $OverheadMultiplierByBitrate[56] = array(0, 0.9731249855367600, 0.9776624308938040, 0.9832606361852130, 0.9843922606633340);
  469. $OverheadMultiplierByBitrate[64] = array(0, 0.9755642683275760, 0.9795256705493390, 0.9836573009193170, 0.9851122539404470);
  470. $OverheadMultiplierByBitrate[96] = array(0, 0.9788025247497290, 0.9798553314148700, 0.9822956869792560, 0.9834815119124690);
  471. $OverheadMultiplierByBitrate[128] = array(0, 0.9816940050925480, 0.9821675936072120, 0.9829756927470870, 0.9839763420152050);
  472. $OverheadMultiplierByBitrate[160] = array(0, 0.9825894094561180, 0.9820913399073960, 0.9823907143253970, 0.9832821783651570);
  473. $OverheadMultiplierByBitrate[192] = array(0, 0.9832038474336260, 0.9825731694317960, 0.9821028622712400, 0.9828262076447620);
  474. $OverheadMultiplierByBitrate[224] = array(0, 0.9836516298538770, 0.9824718601823890, 0.9818302180625380, 0.9823735101626480);
  475. $OverheadMultiplierByBitrate[256] = array(0, 0.9845863022094920, 0.9837229411967540, 0.9824521662210830, 0.9828645172100790);
  476. $OverheadMultiplierByBitrate[320] = array(0, 0.9849565280263180, 0.9837683142805110, 0.9822885275960400, 0.9824424382727190);
  477. $OverheadMultiplierByBitrate[384] = array(0, 0.9856094774357600, 0.9844573394432720, 0.9825970399837330, 0.9824673808303890);
  478. $BitrateToUseMin = 32;
  479. $BitrateToUseMax = 32;
  480. $previousBitrate = 32;
  481. foreach ($OverheadMultiplierByBitrate as $key => $value) {
  482. if ($AudioBitrate >= $previousBitrate) {
  483. $BitrateToUseMin = $previousBitrate;
  484. }
  485. if ($AudioBitrate < $key) {
  486. $BitrateToUseMax = $key;
  487. break;
  488. }
  489. $previousBitrate = $key;
  490. }
  491. $FactorA = ($BitrateToUseMax - $AudioBitrate) / ($BitrateToUseMax - $BitrateToUseMin);
  492. $VideoBitrateLog10 = log10($VideoBitrate);
  493. $VideoFactorMin1 = $OverheadMultiplierByBitrate[$BitrateToUseMin][floor($VideoBitrateLog10)];
  494. $VideoFactorMin2 = $OverheadMultiplierByBitrate[$BitrateToUseMax][floor($VideoBitrateLog10)];
  495. $VideoFactorMax1 = $OverheadMultiplierByBitrate[$BitrateToUseMin][ceil($VideoBitrateLog10)];
  496. $VideoFactorMax2 = $OverheadMultiplierByBitrate[$BitrateToUseMax][ceil($VideoBitrateLog10)];
  497. $FactorV = $VideoBitrateLog10 - floor($VideoBitrateLog10);
  498. $OverheadPercentage = $VideoFactorMin1 * $FactorA * $FactorV;
  499. $OverheadPercentage += $VideoFactorMin2 * (1 - $FactorA) * $FactorV;
  500. $OverheadPercentage += $VideoFactorMax1 * $FactorA * (1 - $FactorV);
  501. $OverheadPercentage += $VideoFactorMax2 * (1 - $FactorA) * (1 - $FactorV);
  502. return $OverheadPercentage;
  503. }
  504. public static function videoFramerateLookup($rawframerate) {
  505. $lookup = array(0, 23.976, 24, 25, 29.97, 30, 50, 59.94, 60);
  506. return (isset($lookup[$rawframerate]) ? (float) $lookup[$rawframerate] : (float) 0);
  507. }
  508. public static function videoAspectRatioLookup($rawaspectratio) {
  509. $lookup = array(0, 1, 0.6735, 0.7031, 0.7615, 0.8055, 0.8437, 0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575, 1.2015, 0);
  510. return (isset($lookup[$rawaspectratio]) ? (float) $lookup[$rawaspectratio] : (float) 0);
  511. }
  512. public static function videoAspectRatioTextLookup($rawaspectratio) {
  513. $lookup = array('forbidden', 'square pixels', '0.6735', '16:9, 625 line, PAL', '0.7615', '0.8055', '16:9, 525 line, NTSC', '0.8935', '4:3, 625 line, PAL, CCIR601', '0.9815', '1.0255', '1.0695', '4:3, 525 line, NTSC, CCIR601', '1.1575', '1.2015', 'reserved');
  514. return (isset($lookup[$rawaspectratio]) ? $lookup[$rawaspectratio] : '');
  515. }
  516. public static function videoFormatTextLookup($video_format) {
  517. // ISO/IEC 13818-2, section 6.3.6, Table 6-6. Meaning of video_format
  518. $lookup = array('component', 'PAL', 'NTSC', 'SECAM', 'MAC', 'Unspecified video format', 'reserved(6)', 'reserved(7)');
  519. return (isset($lookup[$video_format]) ? $lookup[$video_format] : '');
  520. }
  521. public static function scalableModeTextLookup($scalable_mode) {
  522. // ISO/IEC 13818-2, section 6.3.8, Table 6-10. Definition of scalable_mode
  523. $lookup = array('data partitioning', 'spatial scalability', 'SNR scalability', 'temporal scalability');
  524. return (isset($lookup[$scalable_mode]) ? $lookup[$scalable_mode] : '');
  525. }
  526. public static function pictureStructureTextLookup($picture_structure) {
  527. // ISO/IEC 13818-2, section 6.3.11, Table 6-14 Meaning of picture_structure
  528. $lookup = array('reserved', 'Top Field', 'Bottom Field', 'Frame picture');
  529. return (isset($lookup[$picture_structure]) ? $lookup[$picture_structure] : '');
  530. }
  531. public static function chromaFormatTextLookup($chroma_format) {
  532. // ISO/IEC 13818-2, section 6.3.11, Table 6-14 Meaning of picture_structure
  533. $lookup = array('reserved', '4:2:0', '4:2:2', '4:4:4');
  534. return (isset($lookup[$chroma_format]) ? $lookup[$chroma_format] : '');
  535. }
  536. }