MythTV  master
HEVCParser.cpp
Go to the documentation of this file.
1 // MythTV headers
2 #include "HEVCParser.h"
3 #include <iostream>
4 
6 #include "recorders/dtvrecorder.h" // for FrameRate
7 
8 #include <cmath>
9 #include <strings.h>
10 
11 #include "bitreader.h"
12 #include "bytereader.h"
13 
14 static const QString LOC { QStringLiteral("HEVCParser ") };
15 
16 /*
17  References:
18  http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.352.3388&rep=rep1&type=pdf
19  https://www.itu.int/rec/T-REC-H.265-201911-I/en
20  https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=6316136
21  */
22 
23 static uint ceil_log2 (uint32_t v)
24 {
25  uint r = 0;
26  uint shift = 0;
27 
28  --v;
29  r = (v > 0xFFFF) << 4;
30  v >>= r;
31  shift = (v > 0xFF) << 3;
32  v >>= shift;
33  r |= shift;
34  shift = (v > 0xF) << 2;
35  v >>= shift;
36  r |= shift;
37  shift = (v > 0x3) << 1;
38  v >>= shift;
39  r |= shift;
40  r |= (v >> 1);
41 
42  return r + 1;
43 }
44 
46 {
48 }
49 
51 {
52  switch (type)
53  {
54  case UNKNOWN:
55  return "UNKNOWN";
56  case TAIL_N:
57  return "TAIL_N";
58  case TAIL_R:
59  return "TAIL_R";
60  case TSA_N:
61  return "TSA_N";
62  case TSA_R:
63  return "TSA_R";
64  case STSA_N:
65  return "STSA_N";
66  case STSA_R:
67  return "STSA_R";
68  case RADL_N:
69  return "RADL_N";
70  case RADL_R:
71  return "RADL_R";
72  case RASL_N:
73  return "RASL_N";
74  case RASL_R:
75  return "RASL_R";
76  case RSV_VCL_N10:
77  return "RSV_VCL_N10";
78  case RSV_VCL_N12:
79  return "RSV_VCL_N12";
80  case RSV_VCL_N14:
81  return "RSV_VCL_N14";
82  case RSV_VCL_R11:
83  return "RSV_VCL_R11";
84  case RSV_VCL_R13:
85  return "RSV_VCL_R13";
86  case RSV_VCL_R15:
87  return "RSV_VCL_R15";
88  case BLA_W_LP:
89  return "BLA_W_LP";
90  case BLA_W_RADL:
91  return "BLA_W_RADL";
92  case BLA_N_LP:
93  return "BLA_N_LP";
94  case IDR_W_RADL:
95  return "IDR_W_RADL";
96  case IDR_N_LP:
97  return "IDR_N_LP";
98  case CRA_NUT:
99  return "CRA_NUT";
100  case RSV_IRAP_VCL22:
101  return "RSV_IRAP_VCL22";
102  case RSV_IRAP_VCL23:
103  return "RSV_IRAP_VCL23";
104  case VPS_NUT:
105  return "VPS_NUT";
106  case SPS_NUT:
107  return "SPS_NUT";
108  case PPS_NUT:
109  return "PPS_NUT";
110  case AUD_NUT:
111  return "AUD_NUT";
112  case EOS_NUT:
113  return "EOS_NUT";
114  case EOB_NUT:
115  return "EOB_NUT";
116  case FD_NUT:
117  return "FD_NUT";
118  case PREFIX_SEI_NUT:
119  return "PREFIX_SEI_NUT";
120  case SUFFIX_SEI_NUT:
121  return "SUFFIX_SEI_NUT";
122  }
123  return "OTHER";
124 }
125 
126 uint32_t HEVCParser::addBytes(const uint8_t *bytes,
127  const uint32_t byte_count,
128  const uint64_t stream_offset)
129 {
130  const uint8_t *startP = bytes;
131 
132  m_stateChanged = false;
133  m_onFrame = false;
134  m_onKeyFrame = false;
135 
136 #if 0
137  static MythTimer timer(MythTimer::kStartRunning);
138  static int nexttime = 60000;
139 
140  if (timer.elapsed() > nexttime)
141  {
142  LOG(VB_GENERAL, LOG_DEBUG,
143  QString("Frames %1 KeyFrames %2 | Total Frames %3 KeyFrames %4")
144  .arg(m_framecnt)
145  .arg(m_keyframecnt)
146  .arg(m_totalframecnt)
147  .arg(m_totalkeyframecnt));
148 
149  m_framecnt = 0;
150  m_keyframecnt = 0;
151  nexttime += 60000;
152  }
153 #endif
154 
155  while (!m_onFrame && (startP < bytes + byte_count))
156  {
157  const uint8_t *endP =
159 
160  bool found_start_code = ByteReader::start_code_is_valid(m_syncAccumulator);
161 
162  /* Between startP and endP we potentially have some more
163  * bytes of a NAL that we've been parsing (plus some bytes of
164  * start code)
165  */
167  {
168  if (!fillRBSP(startP, endP - startP, found_start_code))
169  {
170  resetRBSP();
171  return endP - bytes;
172  }
173  }
174  processRBSP(found_start_code); /* Call may set have_uinfinished_NAL
175  * to false */
176 
177  /* Dealt with everything up to endP */
178  startP = endP;
179 
180  if (found_start_code)
181  {
183  {
184  /* We've found a new start code, without completely
185  * parsing the previous NAL. Either there's a
186  * problem with the stream or with this parser.
187  */
188  LOG(VB_GENERAL, LOG_ERR,
189  "HEVCParser::addBytes: Found new start "
190  "code, but previous NAL is incomplete!");
191  }
192 
193  /* Prepare for accepting the new NAL */
194  resetRBSP();
195 
196  /* If we find the start of an AU somewhere from here
197  * to the next start code, the offset to associate with
198  * it is the one passed in to this call, not any of the
199  * subsequent calls.
200  */
201  m_pktOffset = stream_offset; // + (startP - bytes);
202 
203  uint16_t nal_unit_header = ((m_syncAccumulator & 0xff) << 8)
204  | *startP;
205  ++startP;
206 
207  // nal_unit header
208  if (nal_unit_header & 0x8000)
209  {
210  LOG(VB_GENERAL, LOG_ERR, "HEVCParser::parseNAL: "
211  "NAL header forbidden_zero_bit is not zero!");
212  return false;
213  }
214 
215  m_nalTemperalId = (nal_unit_header & 0x7) - 1;
216  m_nuhLayerId = (nal_unit_header >> 3) & 0x3f;
217  m_nalUnitType = (nal_unit_header >> 9) & 0x3f;
218 
219 #if 0
220  LOG(VB_RECORD, LOG_INFO,
221  QString("nalTemperalId: %1, "
222  "nuhLayerId: %2, "
223  "nalUnitType: %3 %4")
224  .arg(m_nalTemperalId)
225  .arg(m_nuhLayerId)
226  .arg(m_nalUnitType)
227  .arg(NAL_type_str(m_nalUnitType)));
228 #endif
229 
230  if (m_nalUnitType == SPS_NUT ||
231  m_nalUnitType == VPS_NUT ||
233  {
234  /* This is a NAL we need to parse. We may have the body
235  * of it in the part of the stream past to us this call,
236  * or we may get the rest in subsequent calls to addBytes.
237  * Either way, we set m_haveUnfinishedNAL, so that we
238  * start filling the rbsp buffer
239  */
240  m_haveUnfinishedNAL = true;
241  }
242  } //found start code
243  }
244 
245  return startP - bytes;
246 }
247 
249 {
250  /*
251  3.1 access unit: A set of NAL units that are associated with
252  each other according to a specified classification rule, are
253  consecutive in decoding order, and contain exactly one coded
254  picture with nuh_layer_id equal to 0.
255  NOTE 1 – In addition to containing the video coding layer
256  (VCL) NAL units of the coded picture with
257  nuh_layer_id equal to 0, an access unit may also
258  contain non-VCL NAL units. The decoding of an
259  access unit with the decoding process specified in
260  clause 8 always results in a decoded picture with
261  nuh_layer_id equal to 0.
262  NOTE 2 – An access unit is defined differently in Annex F
263  and does not need to contain a coded picture with
264  nuh_layer_id equal to 0.
265  */
266 
267  /*
268  F.3.1 access unit: A set of NAL units that are associated with
269  each other according to a specified classification rule,
270  are consecutive in decoding order and contain at most one
271  coded picture with any specific value of nuh_layer_id.
272  */
273 
274  /*
275  F.7.4.2.4.4
276 
277  The first of any of the following NAL units preceding the first VCL
278  NAL unit firstVclNalUnitInAu and succeeding the last VCL NAL unit
279  preceding firstVclNalUnitInAu, if any, specifies the start of a new
280  access unit:
281 
282  – Access unit delimiter NAL unit (when present).
283  – VPS NAL unit (when present)
284  – SPS NAL unit (when present)
285  – PPS NAL unit (when present)
286  – Prefix SEI NAL unit (when present)
287  – NAL units with nal_unit_type in the range of
288  RSV_NVCL41..RSV_NVCL44 (when present)
289  – NAL units with nal_unit_type in the range of
290  UNSPEC48..UNSPEC55 (when present)
291 
292  When there is none of the above NAL units preceding
293  firstVclNalUnitInAu and succeeding the last VCL NAL unit
294  preceding firstVclNalUnitInAu, if any, firstVclNalUnitInAu
295  starts a new access unit.
296  */
297 
298 
299  /*
300  7.4.2.4.4
301 
302  An access unit consists of one coded picture with nuh_layer_id
303  equal to 0, zero or more VCL NAL units with nuh_layer_id greater
304  than 0 and zero or more non-VCL NAL units. The association of
305  VCL NAL units to coded pictures is described in clause
306  7.4.2.4.5.
307 
308  The first access unit in the bitstream starts with the first NAL
309  unit of the bitstream.
310 
311  Let firstBlPicNalUnit be the first VCL NAL unit of a coded
312  picture with nuh_layer_id equal to 0. The first of any of the
313  following NAL units preceding firstBlPicNalUnit and succeeding
314  the last VCL NAL unit preceding firstBlPicNalUnit, if any,
315  specifies the start of a new access unit:
316 
317  NOTE 1 – The last VCL NAL unit preceding firstBlPicNalUnit in
318  decoding order may have nuh_layer_id greater than 0.
319 
320  – access unit delimiter NAL unit with nuh_layer_id equal to 0
321  (when present),
322  – VPS NAL unit with nuh_layer_id equal to 0 (when present),
323  – SPS NAL unit with nuh_layer_id equal to 0 (when present),
324  – PPS NAL unit with nuh_layer_id equal to 0 (when present),
325  – Prefix SEI NAL unit with nuh_layer_id equal to 0 (when present),
326  – NAL units with nal_unit_type in the range of
327  RSV_NVCL41..RSV_NVCL44 with nuh_layer_id equal to 0 (when
328  present),
329  – NAL units with nal_unit_type in the range of
330  UNSPEC48..UNSPEC55 with nuh_layer_id equal to 0 (when
331  present).
332 
333  NOTE 2 – The first NAL unit preceding firstBlPicNalUnit and
334  succeeding the last VCL NAL unit preceding
335  firstBlPicNalUnit, if any, can only be one of the
336  above-listed NAL units.
337 
338  When there is none of the above NAL units preceding
339  firstBlPicNalUnit and succeeding the last VCL NAL preceding
340  firstBlPicNalUnit, if any, firstBlPicNalUnit starts a new access
341  unit.
342 
343  The order of the coded pictures and non-VCL NAL units within an
344  access unit shall obey the following constraints:
345 
346  – When an access unit delimiter NAL unit with nuh_layer_id equal
347  to 0 is present, it shall be the first NAL unit. There shall
348  be at most one access unit delimiter NAL unit with
349  nuh_layer_id equal to 0 in any access unit.
350  – When any VPS NAL units, SPS NAL units, PPS NAL units, prefix
351  SEI NAL units, NAL units with nal_unit_type in the range of
352  RSV_NVCL41..RSV_NVCL44, or NAL units with nal_unit_type in the
353  range of UNSPEC48..UNSPEC55 are present, they shall not follow
354  the last VCL NAL unit of the access unit.
355  – NAL units having nal_unit_type equal to FD_NUT or
356  SUFFIX_SEI_NUT or in the range of RSV_NVCL45..RSV_NVCL47 or
357  UNSPEC56..UNSPEC63 shall not precede the first VCL NAL unit of
358  the access unit.
359  – When an end of sequence NAL unit with nuh_layer_id equal to 0
360  is present, it shall be the last NAL unit among all NAL units
361  with nuh_layer_id equal to 0 in the access unit other than an
362  end of bitstream NAL unit (when present).
363  – When an end of bitstream NAL unit is present, it shall be the
364  last NAL unit in the access unit.
365 
366  NOTE 3 – Decoders conforming to profiles specified in Annex A do
367  not use NAL units with nuh_layer_id greater than 0,
368  e.g., access unit delimiter NAL units with nuh_layer_id
369  greater than 0, for access unit boundary detection,
370  except for identification of a NAL unit as a VCL or
371  non-VCL NAL unit.
372 
373  The structure of access units not containing any NAL units with
374  nal_unit_type equal to FD_NUT, VPS_NUT, SPS_NUT, PPS_NUT,
375  RSV_VCL_N10, RSV_VCL_R11, RSV_VCL_N12, RSV_VCL_R13, RSV_VCL_N14
376  or RSV_VCL_R15, RSV_IRAP_VCL22 or RSV_IRAP_VCL23, or in the
377  range of RSV_VCL24..RSV_VCL31, RSV_NVCL41..RSV_NVCL47 or
378  UNSPEC48..UNSPEC63 is shown in Figure 7-1.
379  */
380 
381  if (m_nuhLayerId == 0)
382  {
383  if (m_nalUnitType == AUD_NUT)
384  return true;
385 
386  if (m_nalUnitType == EOS_NUT)
387  {
388  // The next NAL is the start of a new AU
389  m_nextNALisAU = true;
390  m_seenEOS = true;
391  m_onAU = false;
392  m_noRaslOutputFlag = true;
393  return false;
394  }
395 
396  if (m_nextNALisAU)
397  {
398  m_nextNALisAU = false;
399  return true;
400  }
401  }
402 
403  if (m_nalUnitType == SUFFIX_SEI_NUT ||
406  {
407  m_auPending = false;
408  m_onAU = false;
409  return false;
410  }
411 
412  if (m_auPending || m_onAU)
413  return false;
414 
415  if (m_nalUnitType == VPS_NUT ||
416  m_nalUnitType == SPS_NUT ||
417  m_nalUnitType == PPS_NUT ||
421  {
422  return true;
423  }
424 
425 
426  /*
427  7.4.2.4.5 Order of VCL NAL units and association to coded pictures
428 
429  This clause specifies the order of VCL NAL units and association
430  to coded pictures.
431 
432  Each VCL NAL unit is part of a coded picture. The order of the
433  VCL NAL units within a coded picture is constrained as follows:
434 
435  A VCL NAL unit is the first VCL NAL unit of an access unit, when
436  all of the following conditions are true:
437  – first_slice_segment_in_pic_flag is equal to 1.
438 
439  and F.7.4.2.4.4 Common specifications for multi-layer extensions
440 
441  – At least one of the following conditions is true:
442  – The previous picture in decoding order belongs to a
443  different picture order count (POC) resetting period than
444  the picture containing the VCL NAL unit.
445  – PicOrderCntVal derived for the VCL NAL unit differs from the
446  PicOrderCntVal of the previous picture in decoding order.
447  */
449  {
450  return true;
451  }
452 
453  return false;
454 }
455 
456 
457 void HEVCParser::processRBSP(bool rbsp_complete)
458 {
459  auto br = BitReader(m_rbspBuffer, m_rbspIndex);
460 
461  if (m_nalUnitType == SPS_NUT ||
462  m_nalUnitType == VPS_NUT ||
464  {
465  /* Best wait until we have the whole thing */
466  if (!rbsp_complete)
467  return;
468 
469  if (!m_seenSPS)
471 
472  if (m_nalUnitType == SPS_NUT)
473  parseSPS(br);
474  else if (m_nalUnitType == VPS_NUT)
475  parseVPS(br);
476  else if (NALisVCL(m_nalUnitType))
478  }
479 
480  /* If we got this far, we managed to parse a sufficient
481  * prefix of the current NAL. We can go onto the next. */
482  m_haveUnfinishedNAL = false;
483 
484  if (newAU())
485  {
486  m_auPending = true;
488  }
489 
491  {
492  m_onAU = true;
493  m_auPending = false;
495 
496  m_onFrame = true;
498 
500  {
501  m_onKeyFrame = true;
503 
504  ++m_keyframecnt;
506  }
507 
508  LOG(VB_RECORD, LOG_DEBUG, LOC +
509  QString("On %2Frame").arg(m_onKeyFrame ? "Key" : ""));
510 
511  ++m_framecnt;
512  ++m_totalframecnt;
513  }
514 
515 }
516 
517 /*
518  7.4.4 Profile, tier and level semantics
519 
520  When the profile_tier_level( ) syntax structure is included in an
521  SPS or is the first profile_tier_level( ) syntax structure in a VPS,
522  and any of the syntax elements
523 
524  sub_layer_profile_space[ i ],
525  sub_layer_profile_idc[ i ],
526  sub_layer_profile_compatibility_flag[ i ][j ],
527  sub_layer_progressive_source_flag[ i ],
528  sub_layer_interlaced_source_ flag[ i ],
529  sub_layer_non_packed_constraint_flag[ i ],
530  sub_layer_frame_only_constraint_flag[ i ],
531  sub_layer_max_12bit_constraint_flag[ i ],
532  sub_layer_max_10bit_constraint_flag[ i ],
533  sub_layer_max_8bit_constraint_flag[ i ],
534  sub_layer_max_422chroma_constraint_flag[ i ],
535  sub_layer_max_420chroma_constraint_flag[ i ],
536  sub_layer_max_monochrome_ constraint_flag[ i ],
537  sub_layer_intra_constraint_flag[ i ],
538  sub_layer_one_picture_only_constraint_flag[ i ],
539  sub_layer_lower_bit_rate_constraint_flag[ i ],
540  sub_layer_max_14bit_constraint_flag,
541  sub_layer_reserved_zero_33bits[ i ],
542  sub_layer_reserved_zero_34bits[ i ],
543  sub_layer_reserved_zero_43bits[ i ],
544  sub_layer_inbld_flag[ i ],
545  sub_layer_reserved_zero_1bit[ i ] and
546  sub_layer_level_idc[ i ]
547 
548  is not present for any value of i in the range of 0 to
549  maxNumSubLayersMinus1 − 1, inclusive, in the profile_tier_level(
550  ) syntax structure, the value of the syntax element is inferred
551  as follows (in decreasing order of i values from
552  maxNumSubLayersMinus1 − 1 to 0):
553 
554  – If the value of i is equal to maxNumSubLayersMinus1, the value
555  of the syntax element is inferred to be equal to the value of
556  the corresponding syntax element prefixed with "general_" of
557  the same profile_tier_level( ) syntax structure.
558 
559  NOTE 9 – For example, in this case, if
560  sub_layer_profile_space[ i ] is not present, the
561  value is inferred to be equal to
562  general_profile_space of the same profile_tier_level(
563  ) syntax structure.
564 
565  – Otherwise (the value of i is less than maxNumSubLayersMinus1),
566  the value of the syntax element is inferred to be equal to the
567  corresponding syntax element with i being replaced with i + 1
568  of the same profile_tier_level( ) syntax structure.
569 
570  NOTE 10 – For example, in this case, if
571  sub_layer_profile_space[ i ] is not present, the
572  value is inferred to be equal to
573  sub_layer_profile_space[ i + 1 ] of the same
574  profile_tier_level( ) syntax structure.
575 */
577  bool profilePresentFlag,
578  int maxNumSubLayersMinus1)
579 {
580  int i = 0;
581 
582  if (profilePresentFlag)
583  {
584  br.get_bits(2); // general_profile_space u(2);
585  br.get_bits(1); // general_tier_flag u(1)
586  br.get_bits(5); // general_profile_idc u(5);
587  for (int j = 0; j < 32; ++j)
588  br.get_bits(1); // general_profile_compatibility_flag[j] u(1);
589 
590  /*
591  general_progressive_source_flag and
592  general_interlaced_source_flag are interpreted as follows:
593  – If general_progressive_source_flag is equal to 1 and
594  general_interlac ed_source_flag is equal to 0, the source
595  scan type of the pictures in the CVS should be interpreted
596  as progressive only.
597  – Otherwise, if general_progressive_source_flag is equal to
598  0 and general_interlaced_source_flag is equal to 1, the
599  source scan type of the pictures in the CVS should be
600  interpreted as interlaced only.
601  – Otherwise, if general_progressive_source_flag is equal to
602  0 and general_interlaced_source_flag is equal to 0, the
603  source scan type of the pictures in the CVS should be
604  interpreted as unknown or unspecified.
605  – Otherwise (general_progressive_source_flag is equal to 1
606  and general_interlaced_source_flag is equal to 1), the
607  source scan type of each picture in the CVS is indicated
608  at the picture level using the syntax element
609  source_scan_type in a picture timing SEI message.
610 
611  NOTE 1 – Decoders may ignore the values of
612  general_progressive_source_flag and
613  general_interlaced_source_flag for purposes other
614  than determining the value to be inferred for
615  frame_field_info_present_flag when
616  vui_parameters_present_flag is equal to 0, as there
617  are no other decoding process requirements
618  associated with the values of these
619  flags. Moreover, the actual source scan type of the
620  pictures is outside the scope of this Specification
621  and the method by which the encoder selects the
622  values of general_progressive_source_flag and
623  general_interlaced_source_flag is unspecified.
624  */
625  bool general_progressive_source_flag = br.get_bits(1); // u(1)
626  bool general_interlaced_source_flag = br.get_bits(1); // u(1)
627  if (!general_progressive_source_flag &&
628  general_interlaced_source_flag)
630  else
632 
633  br.get_bits(1); // general_non_packed_constraint_flag u(1)
634  br.get_bits(1); // general_frame_only_constraint_flag u(1)
635 
636 #if 0
637  /* The number of bits in this syntax structure is not
638  * affected by this condition */
639  if (general_profile_idc == 4 ||
640  general_profile_compatibility_flag[4] ||
641  general_profile_idc == 5 ||
642  general_profile_compatibility_flag[5] ||
643  general_profile_idc == 6 ||
644  general_profile_compatibility_flag[6] ||
645  general_profile_idc == 7 ||
646  general_profile_compatibility_flag[7] ||
647  general_profile_idc == 8 ||
648  general_profile_compatibility_flag[8] ||
649  general_profile_idc == 9 ||
650  general_profile_compatibility_flag[9] ||
651  general_profile_idc == 10 ||
652  general_profile_compatibility_flag[10] ||
653  general_profile_idc == 11 ||
654  general_profile_compatibility_flag[11])
655  {
656  br.get_bits(1); //general_max_12bit_constraint_flag u(1)
657  br.get_bits(1); //general_max_10bit_constraint_flag u(1)
658  br.get_bits(1); //general_max_8bit_constraint_flag u(1)
659  br.get_bits(1); //general_max_422chroma_constraint_flag u(1)
660  br.get_bits(1); //general_max_420chroma_constraint_flag u(1)
661  br.get_bits(1); //general_max_monochrome_constraint_flag u(1)
662  br.get_bits(1); //general_intra_constraint_flag u(1)
663  br.get_bits(1); //general_one_picture_only_constraint_flag u(1)
664  br.get_bits(1); //general_lower_bit_rate_constraint_flag u(1)
665 
666  if (general_profile_idc == 5 ||
667  general_profile_compatibility_flag[5] ||
668  general_profile_idc == 9 ||
669  general_profile_compatibility_flag[9] ||
670  general_profile_idc == 10 ||
671  general_profile_compatibility_flag[10] ||
672  general_profile_idc == 11 ||
673  general_profile_compatibility_flag[11])
674  {
675  br.get_bits(1); //general_max_14bit_constraint_flag u(1)
676  // general_reserved_zero_33bits
677  br.skip_bits(16); // bits[0..15]
678  br.skip_bits(16); // bits[16..31]
679  br.skip_bits(1); // bits[32]
680  }
681  else
682  {
683  // general_reserved_zero_34bits u(34);
684  br.skip_bits(16); // bits[0..15]
685  br.skip_bits(16); // bits[16..31]
686  br.skip_bits(2); // bits[32..33]
687  }
688  }
689  else if (general_profile_idc == 2 ||
690  general_profile_compatibility_flag[2])
691  {
692  br.get_bits(7); // general_reserved_zero_7bits u(7);
693  br.get_bits(1); //general_one_picture_only_constraint_flag u(1)
694  // general_reserved_zero_35bits u(35);
695  br.skip_bits(16); // bits[0..15]
696  br.skip_bits(16); // bits[16..31]
697  br.skip_bits(3); // bits[32..34]
698  }
699  else
700 #endif
701  {
702  // general_reserved_zero_43bits
703  br.skip_bits(16); // bits[0..15]
704  br.skip_bits(16); // bits[16..31]
705  br.skip_bits(11); // bits[32..42]
706  }
707 
708 #if 0
709  /* The number of bits in this syntax structure is not
710  * affected by this condition */
711  if (general_profile_idc == 1 ||
712  general_profile_compatibility_flag[1] ||
713  general_profile_idc == 2 ||
714  general_profile_compatibility_flag[2] ||
715  general_profile_idc == 3 ||
716  general_profile_compatibility_flag[3] ||
717  general_profile_idc == 4 ||
718  general_profile_compatibility_flag[4] ||
719  general_profile_idc == 5 ||
720  general_profile_compatibility_flag[5] ||
721  general_profile_idc == 9 ||
722  general_profile_compatibility_flag[9] ||
723  general_profile_idc == 11 ||
724  general_profile_compatibility_flag[11])
725  br.get_bits(1); //general_inbld_flag u(1)
726  else
727 #endif
728  br.get_bits(1); //general_reserved_zero_bit u(1)
729  }
730 
731  br.get_bits(8); // general_level_idc u(8);
732 
733  /*
734  sub_layer_profile_present_flag[i] equal to 1, specifies that
735  profile information is present in the profile_tier_level()
736  syntax structure for the sub-layer representation with
737  TemporalId equal to i. sub_layer_profile_present_flag[i]
738  equal to 0 specifies that profile information is not present in
739  the profile_tier_level() syntax structure for the sub-layer
740  representation with TemporalId equal to i. When
741  profilePresentFlag is equal to 0,
742  sub_layer_profile_present_flag[i] shall be equal to 0.
743  */
744 
745  std::vector<bool> sub_layer_profile_present_flag;
746  std::vector<bool> sub_layer_level_present_flag;
747  for (i = 0; i < maxNumSubLayersMinus1; ++i)
748  {
749  sub_layer_profile_present_flag.push_back(br.get_bits(1)); // u(1)
750  sub_layer_level_present_flag.push_back( br.get_bits(1)); // u(1)
751  }
752 
753  if (maxNumSubLayersMinus1 > 0)
754  {
755  for (i = maxNumSubLayersMinus1; i < 8; ++i)
756  br.get_bits(2); // reserved_zero_2bits[i] u(2);
757  }
758 
759  for (i = 0; i < maxNumSubLayersMinus1; ++i)
760  {
761  if (sub_layer_profile_present_flag[i])
762  {
763  br.get_bits(2); // sub_layer_profile_space[i] u(2);
764  br.get_bits(1); // sub_layer_tier_flag[i] u(1)
765  br.get_bits(5); // sub_layer_profile_idc[i] u(5);
766 
767  for (int j = 0; j < 32; ++j)
768  br.get_bits(1); //sub_layer_profile_compatibility_flag[i][j] u(1)
769 
770  br.get_bits(1); //sub_layer_progressive_source_flag[i] u(1)
771  br.get_bits(1); //sub_layer_interlaced_source_flag[i] u(1)
772  br.get_bits(1); //sub_layer_non_packed_constraint_flag[i] u(1)
773  br.get_bits(1); //sub_layer_frame_only_constraint_flag[i] u(1)
774 
775 #if 0
776  /* The number of bits in this syntax structure is not
777  * affected by this condition */
778  if (sub_layer_profile_idc[i] == 4 ||
779  sub_layer_profile_compatibility_flag[i][4] ||
780  sub_layer_profile_idc[i] == 5 ||
781  sub_layer_profile_compatibility_flag[i][5] ||
782  sub_layer_profile_idc[i] == 6 ||
783  sub_layer_profile_compatibility_flag[i][6] ||
784  sub_layer_profile_idc[i] == 7 ||
785  sub_layer_profile_compatibility_flag[i][7] ||
786  sub_layer_profile_idc[i] == 8 ||
787  sub_layer_profile_compatibility_flag[i][8] ||
788  sub_layer_profile_idc[i] == 9 ||
789  sub_layer_profile_compatibility_flag[i][9] ||
790  sub_layer_profile_idc[i] == 10 ||
791  sub_layer_profile_compatibility_flag[i][10] ||
792  sub_layer_profile_idc[i] == 11 ||
793  sub_layer_profile_compatibility_flag[i][11])
794  {
795  br.get_bits(1); //sub_layer_max_12bit_constraint_flag[i] u(1)
796  br.get_bits(1); //sub_layer_max_10bit_constraint_flag[i] u(1)
797  br.get_bits(1); //sub_layer_max_8bit_constraint_flag[i] u(1)
798  br.get_bits(1); //sub_layer_max_422chroma_constraint_flag[i] u(1)
799  br.get_bits(1); //sub_layer_max_420chroma_constraint_flag[i] u(1)
800  br.get_bits(1); //sub_layer_max_monochrome_constraint_flag[i] u(1)
801  br.get_bits(1); //sub_layer_intra_constraint_flag[i] u(1)
802  br.get_bits(1); //sub_layer_one_picture_only_constraint_flag[i] u(1)
803  br.get_bits(1); //sub_layer_lower_bit_rate_constraint_flag[i] u(1)
804  if (sub_layer_profile_idc[i] == 5 ||
805  sub_layer_profile_compatibility_flag[i][5] ||
806  sub_layer_profile_idc[i] == 9 ||
807  sub_layer_profile_compatibility_flag[i][9] ||
808  sub_layer_profile_idc[i] == 10 ||
809  sub_layer_profile_compatibility_flag[i][10] ||
810  sub_layer_profile_idc[i] == 11 ||
811  sub_layer_profile_compatibility_flag[i][11])
812  {
813  br.get_bits(1); //sub_layer_max_14bit_constraint_flag[i] u(1)
814  // sub_layer_reserved_zero_33bits[i] u(33);
815  br.skip_bits(16); // bits[ 0..15]
816  br.skip_bits(16); // bits[16..31]
817  br.skip_bits( 1); // bits[32..32]
818  }
819  else
820  {
821  // sub_layer_reserved_zero_34bits[i] u(34);
822  br.skip_bits(16); // bits[ 0..15]
823  br.skip_bits(16); // bits[16..31]
824  br.skip_bits( 2); // bits[32..33]
825  }
826  }
827  else if(sub_layer_profile_idc[i] == 2 ||
828  sub_layer_profile_compatibility_flag[i][2])
829  {
830  br.get_bits(7); // sub_layer_reserved_zero_7bits[i] u(7);
831  br.get_bits(1); // sub_layer_one_picture_only_constraint_flag[i] u(1)
832  // sub_layer_reserved_zero_35bits[i] u(35);
833  br.skip_bits(16); // bits[ 0..15]
834  br.skip_bits(16); // bits[16..31]
835  br.skip_bits( 3); // bits[32..34]
836  }
837  else
838 #endif
839  {
840  // sub_layer_reserved_zero_43bits[i] u(43);
841  br.skip_bits(16); // bits[ 0..15]
842  br.skip_bits(16); // bits[16..31]
843  br.skip_bits(12); // bits[32..43]
844  }
845 
846 #if 0
847  /* The number of bits in this syntax structure is not
848  * affected by this condition */
849  if (sub_layer_profile_idc[i] == 1 ||
850  sub_layer_profile_compatibility_flag[i][1] ||
851  sub_layer_profile_idc[i] == 2 ||
852  sub_layer_profile_compatibility_flag[i][2] ||
853  sub_layer_profile_idc[i] == 3 ||
854  sub_layer_profile_compatibility_flag[i][3] ||
855  sub_layer_profile_idc[i] == 4 ||
856  sub_layer_profile_compatibility_flag[i][4] ||
857  sub_layer_profile_idc[i] == 5 ||
858  sub_layer_profile_compatibility_flag[i][5] ||
859  sub_layer_profile_idc[i] == 9 ||
860  sub_layer_profile_compatibility_flag[i][9] ||
861  sub_layer_profile_idc[i] == 11 ||
862  sub_layer_profile_compatibility_flag[i][11])
863 
864  br.get_bits(1); //sub_layer_inbld_flag[i] u(1)
865  else
866 #endif
867  br.get_bits(1); //sub_layer_reserved_zero_bit[i] u(1)
868  }
869 
870  if (sub_layer_level_present_flag[i])
871  br.get_bits(8); // sub_layer_level_idc[i] u(8);
872  }
873 
874  return true;
875 }
876 
877 static bool getScalingListParams(uint8_t sizeId, uint8_t matrixId,
878  HEVCParser::ScalingList & dest_scaling_list,
879  uint8_t* &sl, uint8_t &size,
880  std::vector<int16_t> &scaling_list_dc_coef_minus8)
881 {
882  switch (sizeId)
883  {
885  sl = dest_scaling_list.scaling_lists_4x4[matrixId].data();
886  size = dest_scaling_list.scaling_lists_4x4[matrixId].size();;
887  break;
889  sl = dest_scaling_list.scaling_lists_8x8[matrixId].data();
890  size = dest_scaling_list.scaling_lists_8x8[matrixId].size();
891  break;
893  sl = dest_scaling_list.scaling_lists_16x16[matrixId].data();
894  size = dest_scaling_list.scaling_lists_16x16[matrixId].size();
895  scaling_list_dc_coef_minus8 =
896  dest_scaling_list.scaling_list_dc_coef_minus8_16x16;
897  break;
899  sl = dest_scaling_list.scaling_lists_32x32[matrixId].data();
900  size = dest_scaling_list.scaling_lists_32x32[matrixId].size();
901  scaling_list_dc_coef_minus8 =
902  dest_scaling_list.scaling_list_dc_coef_minus8_32x32;
903  break;
904  default:
905  return false;
906  }
907  return true;
908 }
909 
910 /*
911  7.3.4 Scaling list data syntax
912  We dont' need any of this data. We just need to get past the bits.
913 */
914 static bool scalingListData(BitReader& br,
915  HEVCParser::ScalingList & dest_scaling_list,
916  bool use_default)
917 {
918  uint8_t sizeId = 0;
919  uint8_t size = 0;
920 
921  for (sizeId = 0; sizeId < 4; ++sizeId)
922  {
923  for (uint matrixId = 0; matrixId < ((sizeId == 3) ? 2 : 6); ++matrixId)
924  {
925  std::vector<int16_t> scaling_list_dc_coef_minus8 {};
926  uint8_t *sl = nullptr;
927 
928  if (!getScalingListParams(sizeId, matrixId,
929  dest_scaling_list, sl, size,
930  scaling_list_dc_coef_minus8))
931  {
932  LOG(VB_RECORD, LOG_WARNING, LOC +
933  QString("Failed to process scaling list params"));
934  return false;
935  }
936 
937  /* use_default_scaling_matrices forcefully which means,
938  * sps_scaling_list_enabled_flag=TRUE,
939  * sps_scaling_list_data_present_flag=FALSE,
940  * pps_scaling_list_data_present_falg=FALSE */
941  if (use_default)
942  {
943 #if 0 // Unneeded
944  if (!getDefaultScalingLists(&sl, sizeId, matrixId))
945  {
946  LOG(VB_RECORD, LOG_WARNING, LOC +
947  QString("Failed to process default scaling lists"));
948  return false;
949  }
950 
951  if (sizeId > 1)
952  /* Inferring the value of scaling_list_dc_coef_minus8 */
953  scaling_list_dc_coef_minus8[matrixId] = 8;
954 #endif
955  }
956  else
957  {
958  if (!br.get_bits(1)) // scaling_list_pred_mode_flag u(1)
959  {
960  br.get_ue_golomb(); // scaling_list_pred_matrix_id_delta ue(v)
961 #if 0 // Unneeded
962  if (!scaling_list_pred_matrix_id_delta)
963  {
964  if (!getDefaultScalingLists(&sl, sizeId, matrixId))
965  {
966  LOG(VB_RECORD, LOG_WARNING, LOC +
967  QString("Failed to process default "
968  "scaling list"));
969  return false;
970  }
971 
972  /* Inferring the value of scaling_list_dc_coef_minus8 */
973  if (sizeId > 1)
974  scaling_list_dc_coef_minus8[matrixId] = 8;
975  }
976  else
977  {
978  uint8_t *temp_sl;
979  uint8_t refMatrixId = matrixId -
980  scaling_list_pred_matrix_id_delta;
981  if (!getScalingListParams(dest_scaling_list, sizeId,
982  refMatrixId, &temp_sl,
983  NULL, {}))
984  {
985  LOG(VB_RECORD, LOG_WARNING, LOC +
986  QString("Failed to process scaling "
987  "list params"));
988  return false;
989  }
990 
991  for (i = 0; i < size; ++i)
992  sl[i] = temp_sl[i];
993 
994  /* Inferring the value of scaling_list_dc_coef_minus8 */
995  if (sizeId > 1)
996  scaling_list_dc_coef_minus8[matrixId] =
997  scaling_list_dc_coef_minus8[refMatrixId];
998  }
999 #endif
1000  }
1001  else
1002  {
1003 // uint nextCoef = 8;
1004 
1005  if (sizeId > 1)
1006  {
1007 // scaling_list_dc_coef_minus8[matrixId] =
1008  br.get_se_golomb(); // se(v)
1009 #if 0 // Unneeded
1010  if (scaling_list_dc_coef_minus8[matrixId] < -7 ||
1011  247 < scaling_list_dc_coef_minus8[matrixId])
1012  {
1013  LOG(VB_RECORD, LOG_WARNING, LOC +
1014  QString("scaling_list_dc_coef_minus8[%1] %2 "
1015  "outside -7 and 247")
1016  .arg(matrixId)
1017  .arg(scaling_list_dc_coef_minus8[matrixId]));
1018  }
1019  nextCoef = scaling_list_dc_coef_minus8[matrixId] + 8;
1020 #endif
1021  }
1022 
1023  for (uint8_t i = 0; i < size; ++i)
1024  {
1025  br.get_se_golomb(); // scaling_list_delta_coef se(v)
1026 #if 0 // Unneeded
1027  if (scaling_list_delta_coef < -128 ||
1028  scaling_list_delta_coef > 127)
1029  {
1030  LOG(VB_RECORD, LOG_WARNING, LOC +
1031  QString("scaling_list_delta_coef %1 "
1032  "outside -128 and 127")
1033  .arg(scaling_list_delta_coef));
1034  }
1035  nextCoef = (nextCoef + scaling_list_delta_coef) & 0xff;
1036  sl[i] = nextCoef;
1037 #endif
1038  }
1039 
1040  }
1041  }
1042  }
1043  }
1044 
1045  return true;
1046 }
1047 
1048 /*
1049  7.3.7 Short-term reference picture set syntax
1050  We don't any of this data, but we have to get past the bits
1051 */
1052 static bool shortTermRefPicSet(BitReader& br, int stRPSIdx,
1053  int num_short_term_ref_pic_sets,
1054  std::array<HEVCParser::ShortTermRefPicSet,65> & stRPS,
1055  uint8_t max_dec_pic_buffering_minus1)
1056 {
1057  std::array<bool,16> use_delta_flag { false };
1058  std::array<bool,16> used_by_curr_pic_flag { false };
1059  std::array<uint32_t,16> delta_poc_s0_minus1 { 0 };
1060  std::array<uint32_t,16> delta_poc_s1_minus1 { 0 };
1061  uint i = 0;
1062 
1063  /* 7.4.8 inter_ref_pic_set_prediction_flag equal to 1 specifies
1064  that the stRPSIdx-th candidate short-term RPS is predicted from
1065  another candidate short-term RPS, which is referred to as the
1066  source candidate short-term RPS. When
1067  inter_ref_pic_set_prediction_flag is not present, it is
1068  inferred to be equal to 0.
1069  */
1070  bool inter_ref_pic_set_prediction_flag = (stRPSIdx != 0) ?
1071  br.get_bits(1) : false; // u(1)
1072 
1073  if (inter_ref_pic_set_prediction_flag)
1074  {
1075  /*
1076  delta_idx_minus1 plus 1 specifies the difference between the
1077  value of stRPSIdx and the index, into the list of the
1078  candidate short-term RPSs specified in the SPS, of the
1079  source candidate short-term RPS. The value of
1080  delta_idx_minus1 shall be in the range of 0 to stRPSIdx − 1,
1081  inclusive. When delta_idx_minus1 is not present, it is
1082  inferred to be equal to 0.
1083  */
1084  int delta_idx_minus1 = (stRPSIdx == num_short_term_ref_pic_sets) ?
1085  br.get_ue_golomb() : 0; // ue(v)
1086  if (delta_idx_minus1 > stRPSIdx - 1)
1087  LOG(VB_RECORD, LOG_WARNING, LOC +
1088  QString("Invalid delta_idx_minus1? %1").arg(delta_idx_minus1));
1089 
1090  int8_t delta_rps_sign = br.get_bits(1); // u(1)
1091  int abs_delta_rps_minus1 = br.get_ue_golomb(); // ue(v)
1092  if (abs_delta_rps_minus1 > 32767)
1093  LOG(VB_RECORD, LOG_WARNING, LOC +
1094  QString("Invalid abs_delta_rps_minus1"));
1095  int deltaRPS = ( 1 - 2 * delta_rps_sign ) * ( abs_delta_rps_minus1 + 1 );
1096 
1097  /*
1098  The variable RefRPSIdx is derived as follows:
1099  RefRPSIdx = stRPSIdx − ( delta_idx_minus1 + 1)
1100  */
1101  int RefRPSIdx = stRPSIdx - (delta_idx_minus1 + 1);
1102  HEVCParser::ShortTermRefPicSet *RefRPS = &stRPS[RefRPSIdx];
1103 
1104  for (int j = 0; j <= RefRPS->NumDeltaPocs; ++j)
1105  {
1106  used_by_curr_pic_flag[j] = br.get_bits(1); // u(1)
1107  /*
1108  use_delta_flag[ j ] equal to 1 specifies that the
1109  j-th entry in the source candidate short-term RPS
1110  is included in the stRPSIdx-th candidate short-term
1111  RPS. use_delta_flag[ j ] equal to 0 specifies that
1112  the j-th entry in the source candidate short-term
1113  RPS is not included in the stRPSIdx-th candidate
1114  short-term RPS. When use_delta_flag[ j ] is not
1115  present, its value is inferred to be equal to 1.
1116  */
1117  if (!used_by_curr_pic_flag[j])
1118  {
1119  use_delta_flag[j] = br.get_bits(1); // u(1)
1120  }
1121  else
1122  {
1123  use_delta_flag[j] = true;
1124  }
1125  }
1126 
1127 
1128  /* 7.4.8 Short-term reference picture set semantics */
1129  i = 0;
1130  for (int k = (RefRPS->NumPositivePics - 1); k >= 0; --k)
1131  {
1132  int dPoc = RefRPS->DeltaPocS1[k] + deltaRPS;
1133  if (dPoc < 0 && use_delta_flag[RefRPS->NumNegativePics + k])
1134  {
1135  stRPS[stRPSIdx].DeltaPocS0[i] = dPoc;
1136  stRPS[stRPSIdx].UsedByCurrPicS0[i++] =
1137  used_by_curr_pic_flag[RefRPS->NumNegativePics + k];
1138  }
1139  }
1140 
1141  if (deltaRPS < 0 && use_delta_flag[RefRPS->NumDeltaPocs])
1142  {
1143  stRPS[stRPSIdx].DeltaPocS0[i] = deltaRPS;
1144  stRPS[stRPSIdx].UsedByCurrPicS0[i++] =
1145  used_by_curr_pic_flag[RefRPS->NumDeltaPocs];
1146  }
1147 
1148  for (int j = 0; j < RefRPS->NumNegativePics; ++j)
1149  {
1150  int dPoc = RefRPS->DeltaPocS0[j] + deltaRPS;
1151  if (dPoc < 0 && use_delta_flag[j])
1152  {
1153  stRPS[stRPSIdx].DeltaPocS0[i] = dPoc;
1154  stRPS[stRPSIdx].UsedByCurrPicS0[i++] = used_by_curr_pic_flag[j];
1155  }
1156  }
1157  stRPS[stRPSIdx].NumNegativePics = i;
1158 
1159  i = 0;
1160  for (int k = (RefRPS->NumNegativePics - 1); k >= 0; --k)
1161  {
1162  int dPoc = RefRPS->DeltaPocS0[k] + deltaRPS;
1163  if (dPoc > 0 && use_delta_flag[k])
1164  {
1165  stRPS[stRPSIdx].DeltaPocS1[i] = dPoc;
1166  stRPS[stRPSIdx].UsedByCurrPicS1[i++] = used_by_curr_pic_flag[k];
1167  }
1168  }
1169 
1170  if (deltaRPS > 0 && use_delta_flag[RefRPS->NumDeltaPocs])
1171  {
1172  stRPS[stRPSIdx].DeltaPocS1[i] = deltaRPS;
1173  stRPS[stRPSIdx].UsedByCurrPicS1[i++] =
1174  used_by_curr_pic_flag[RefRPS->NumDeltaPocs];
1175  }
1176 
1177  for (int j = 0; j < RefRPS->NumPositivePics; ++j)
1178  {
1179  int dPoc = RefRPS->DeltaPocS1[j] + deltaRPS;
1180  if (dPoc > 0 && use_delta_flag[RefRPS->NumNegativePics + j])
1181  {
1182  stRPS[stRPSIdx].DeltaPocS1[i] = dPoc;
1183  stRPS[stRPSIdx].UsedByCurrPicS1[i++] =
1184  used_by_curr_pic_flag[RefRPS->NumNegativePics + j];
1185  }
1186  }
1187  stRPS[stRPSIdx].NumPositivePics= i;
1188  }
1189  else
1190  {
1191  stRPS[stRPSIdx].NumNegativePics = std::min((uint8_t)br.get_ue_golomb(), // ue(v)
1192  max_dec_pic_buffering_minus1);
1193  stRPS[stRPSIdx].NumPositivePics = std::min((uint8_t)br.get_ue_golomb(), // ue(v)
1194  max_dec_pic_buffering_minus1);
1195 
1196  for (i = 0; i < stRPS[stRPSIdx].NumNegativePics; ++i)
1197  {
1198  delta_poc_s0_minus1[i] = br.get_ue_golomb(); // ue(v)
1199  br.get_bits(1); // used_by_curr_pic_s0_flag[i]; u(1)
1200 
1201  if (i == 0)
1202  stRPS[stRPSIdx].DeltaPocS0[i] = -(delta_poc_s0_minus1[i] + 1);
1203  else
1204  stRPS[stRPSIdx].DeltaPocS0[i] = stRPS[stRPSIdx].DeltaPocS0[i - 1] -
1205  (delta_poc_s0_minus1[i] + 1);
1206  }
1207  for (i = 0; i < stRPS[stRPSIdx].NumPositivePics; ++i)
1208  {
1209  delta_poc_s1_minus1[i] = br.get_ue_golomb(); // ue(v)
1210  br.get_bits(1); // used_by_curr_pic_s1_flag[i]; u(1)
1211 
1212  if (i == 0)
1213  stRPS[stRPSIdx].DeltaPocS1[i] = delta_poc_s1_minus1[i] + 1;
1214  else
1215  stRPS[stRPSIdx].DeltaPocS1[i] = stRPS[stRPSIdx].DeltaPocS1[i - 1] +
1216  (delta_poc_s1_minus1[i] + 1);
1217  }
1218  }
1219 
1220  /*
1221  The variable NumDeltaPocs[ stRPSIdx ] is derived as follows:
1222  NumDeltaPocs[ stRPSIdx ] = NumNegativePics[ stRPSIdx ] +
1223  NumPositivePics[ stRPSIdx ]
1224  */
1225  stRPS[stRPSIdx].NumDeltaPocs = stRPS[stRPSIdx].NumNegativePics +
1226  stRPS[stRPSIdx].NumPositivePics;
1227  return true;
1228 }
1229 
1230 /* 7.3.2.9 Slice segment layer RBSP syntax */
1232 {
1233  if (!m_seenSPS)
1234  return false;
1235 
1237 #if 0
1238  slice_segment_data(br);
1239  rbsp_slice_segment_trailing_bits(br);
1240 #endif
1241  return true;
1242 }
1243 
1244 /*
1245  7.3.6.1 General slice segment header syntax
1246  All we are after is the pic order count
1247 */
1249 {
1250  bool dependent_slice_segment_flag = false; // check!
1251 
1253 
1255  {
1256  br.get_bits(1); // no_output_of_prior_pics_flag; u(1)
1257  }
1258 
1259  int pps_id = br.get_ue_golomb(); // slice_pic_parameter_set_id; ue(v)
1260  if (m_pps.find(pps_id) == m_pps.end())
1261  {
1262  LOG(VB_RECORD, LOG_DEBUG, LOC +
1263  QString("PPS Id %1 not valid yet. Skipping parsing of slice.")
1264  .arg(pps_id));
1265  return false;
1266  }
1267  PPS* pps = &m_pps[pps_id];
1268  SPS* sps = &m_sps[pps->sps_id];
1269 
1271  {
1273  {
1274  dependent_slice_segment_flag = br.get_bits(1); // u(1)
1275  }
1276 
1277  /* Figure out how many bits are in the slice_segment_address */
1278  uint32_t MinCbLog2SizeY = sps->log2_min_luma_coding_block_size;
1279  uint32_t CtbLog2SizeY = MinCbLog2SizeY +
1281  uint32_t CtbSizeY = 1 << CtbLog2SizeY;
1282  uint32_t PicHeightInCtbsY =
1283  ceil (static_cast<double>(m_picHeight) /
1284  static_cast<double>(CtbSizeY));
1285  uint32_t PicWidthInCtbsY =
1286  ceil (static_cast<double>(m_picWidth) /
1287  static_cast<double>(CtbSizeY));
1288 
1289  uint address_size = ceil_log2(PicWidthInCtbsY *
1290  PicHeightInCtbsY);
1291 
1292  br.get_bits(address_size); // slice_segment_address u(v)
1293  }
1294 
1295  // CuQpDeltaVal = 0;
1296  if (!dependent_slice_segment_flag)
1297  {
1298  for (int i = 0; i < pps->num_extra_slice_header_bits; ++i)
1299  {
1300  br.get_bits(1); // slice_reserved_flag[i]; // u(1)
1301  }
1302  br.get_ue_golomb(); // slice_type; // ue(v)
1303  if (pps->output_flag_present_flag)
1304  {
1305  br.get_bits(1); // pic_output_flag; // u(1)
1306  }
1307  if (sps->separate_colour_plane_flag)
1308  {
1309  br.get_bits(2); // colour_plane_id; // u(2)
1310  }
1312  {
1313  m_picOrderCntMsb = 0;
1316  }
1317  else
1318  {
1319  uint16_t slice_pic_order_cnt_lsb =
1320  br.get_bits(sps->log2_max_pic_order_cnt_lsb); // u(v)
1321 
1322  /*
1323  8.1.3 Decoding process for a coded picture with
1324  nuh_layer_id equal to 0
1325 
1326  When the current picture is an IRAP picture, the
1327  following applies:
1328  – If the current picture is an IDR picture, a BLA
1329  picture, the first picture in the bitstream in
1330  decoding order, or the first picture that follows an
1331  end of sequence NAL unit in decoding order, the
1332  variable NoRaslOutputFlag is set equal to 1.
1333  - Otherwise, it is magic!
1334  - If not magic, then NoRaslOutputFlag equals 0.
1335 
1336  Meanwhile...
1337  F.8.1.3 Common decoding process for a coded picture
1338 
1339  When the current picture is an IRAP picture, the following applies:
1340  – If the current picture with a particular value of
1341  nuh_layer_id is an IDR picture, a BLA picture, the
1342  first picture with that particular value of
1343  nuh_layer_id in the bitstream in decoding order or the
1344  first picture with that particular value of
1345  nuh_layer_id that follows an end of sequence NAL unit
1346  with that particular value of nuh_layer_id in decoding
1347  order, the variable NoRaslOutputFlag is set equal to
1348  1.
1349  */
1351  m_nalUnitType <= IDR_N_LP);
1352 
1353  /*
1354  8.3.1 Decoding process for picture order count
1355  The variable PicOrderCntMsb of the current picture is
1356  derived as follows:
1357  – If the current picture is an IRAP picture with
1358  NoRaslOutputFlag equal to 1, PicOrderCntMsb is set
1359  equal to 0.
1360 
1361  – Otherwise...
1362 
1363  NOTE 1 – All IDR pictures will have PicOrderCntVal
1364  equal to 0 since slice_pic_order_cnt_lsb is
1365  inferred to be 0 for IDR pictures and
1366  prevPicOrderCntLsb and prevPicOrderCntMsb are
1367  both set equal to 0.
1368  */
1369 
1371  {
1372  m_picOrderCntMsb = 0;
1373  }
1374  else
1375  {
1376  /* 8.3.1 Decoding process for picture order count */
1377  uint MaxPicOrderCntLsb = pow(2, sps->log2_max_pic_order_cnt_lsb);
1378 
1379  if ((slice_pic_order_cnt_lsb < m_prevPicOrderCntLsb) &&
1380  ((m_prevPicOrderCntLsb - slice_pic_order_cnt_lsb) >=
1381  (MaxPicOrderCntLsb / 2)))
1382  {
1384  MaxPicOrderCntLsb;
1385  }
1386  else if ((slice_pic_order_cnt_lsb > m_prevPicOrderCntLsb) &&
1387  ((slice_pic_order_cnt_lsb - m_prevPicOrderCntLsb) >
1388  (MaxPicOrderCntLsb / 2)))
1389  {
1391  MaxPicOrderCntLsb;
1392  }
1393  else
1394  {
1396  }
1397  }
1398  m_picOrderCntVal = m_picOrderCntMsb + slice_pic_order_cnt_lsb;
1399 
1400  LOG(VB_RECORD, LOG_INFO, LOC +
1401  QString("picOrderCntVal: %1 = %2 + %3")
1402  .arg(m_picOrderCntVal)
1403  .arg(m_picOrderCntMsb)
1404  .arg(slice_pic_order_cnt_lsb));
1405 
1406  m_noRaslOutputFlag = false;
1407 
1408 #if 0 // We dont' need the rest
1409  br.get_bits(1); // short_term_ref_pic_set_sps_flag; // u(1)
1410  if (!short_term_ref_pic_set_sps_flag)
1411  {
1412  shortTermRefPicSet(num_short_term_ref_pic_sets);
1413  }
1414  else if(num_short_term_ref_pic_sets > 1)
1415  {
1416  br.get_bits(??? ); // short_term_ref_pic_set_idx; // u(v)
1417  }
1418  if (long_term_ref_pics_present_flag)
1419  {
1420  if (num_long_term_ref_pics_sps > 0)
1421  {
1422  br.get_ue_golomb(); // num_long_term_sps; // ue(v)
1423  }
1424  br.get_ue_golomb(); // num_long_term_pics; // ue(v)
1425  for (i = 0; i < num_long_term_sps + num_long_term_pics; ++i)
1426  {
1427  if (i < num_long_term_sps)
1428  {
1429  if (num_long_term_ref_pics_sps > 1)
1430  br.get_bits(??? ); // lt_idx_sps[i]; // u(v)
1431  }
1432  else
1433  {
1434  poc_lsb_lt[i] =
1435  br.get_bits(sps->Log2MaxPicOrderCntLsb); // u(v)
1436  br.get_bits(1); // used_by_curr_pic_lt_flag[i]; // u(1)
1437  }
1438  br.get_bits(1); // delta_poc_msb_present_flag[i]; // u(1)
1439  if (delta_poc_msb_present_flag[i])
1440  {
1441  br.get_ue_golomb(); // delta_poc_msb_cycle_lt[i]; // ue(v)
1442  }
1443  }
1444  }
1445  if (sps_temporal_mvp_enabled_flag)
1446  {
1447  br.get_bits(1); // slice_temporal_mvp_enabled_flag; // u(1)
1448  }
1449 #endif
1450  }
1451 #if 0 // We don't need the rest
1452  if (sample_adaptive_offset_enabled_flag)
1453  {
1454  br.get_bits(1); // slice_sao_luma_flag; // u(1)
1455  if (ChromaArrayType != 0)
1456  {
1457  br.get_bits(1); // slice_sao_chroma_flag; // u(1)
1458  }
1459  }
1460  if (slice_type == P || slice_type == B)
1461  {
1462  br.get_bits(1); // num_ref_idx_active_override_flag; // u(1)
1463  if (num_ref_idx_active_override_flag)
1464  {
1465  br.get_ue_golomb(); // num_ref_idx_l0_active_minus1; // ue(v)
1466  if (slice_type == B)
1467  {
1468  br.get_ue_golomb(); // num_ref_idx_l1_active_minus1; // ue(v)
1469  }
1470  }
1471  if (lists_modification_present_flag && NumPicTotalCurr > 1)
1472  {
1473  ref_pic_lists_modification();
1474  if (slice_type == B)
1475  {
1476  br.get_bits(1); // mvd_l1_zero_flag; // u(1)
1477  }
1478  }
1479  if (cabac_init_present_flag)
1480  {
1481  br.get_bits(1); // cabac_init_flag; // u(1)
1482  }
1483  if (slice_temporal_mvp_enabled_flag)
1484  {
1485  if (slice_type == B)
1486  {
1487  br.get_bits(1); // collocated_from_l0_flag; // u(1)
1488  }
1489  if (( collocated_from_l0_flag &&
1490  num_ref_idx_l0_active_minus1 > 0) ||
1491  (!collocated_from_l0_flag &&
1492  num_ref_idx_l1_active_minus1 > 0))
1493  {
1494  br.get_ue_golomb(); // collocated_ref_idx; // ue(v)
1495  }
1496  }
1497  if ((weighted_pred_flag && slice_type == P) ||
1498  (weighted_bipred_flag && slice_type == B))
1499  {
1500  pred_weight_table();
1501  }
1502  br.get_ue_golomb(); // five_minus_max_num_merge_cand; // ue(v)
1503  if (motion_vector_resolution_control_idc == 2)
1504  {
1505  br.get_bits(1); // use_integer_mv_flag; // u(1)
1506  }
1507  }
1508  br.get_se_golomb(); // slice_qp_delta; //se(v)
1509  if (pps_slice_chroma_qp_offsets_present_flag)
1510  {
1511  br.get_se_golomb(); // slice_cb_qp_offset; //se(v)
1512  br.get_se_golomb(); // slice_cr_qp_offset; //se(v)
1513  }
1514  if (pps_slice_act_qp_offsets_present_flag)
1515  {
1516  br.get_se_golomb(); // slice_act_y_qp_offset; //se(v)
1517  br.get_se_golomb(); // slice_act_cb_qp_offset; //se(v)
1518  br.get_se_golomb(); // slice_act_cr_qp_offset; //se(v)
1519  }
1520  if (chroma_qp_offset_list_enabled_flag)
1521  {
1522  br.get_bits(1); // cu_chroma_qp_offset_enabled_flag; // u(1)
1523  }
1524  if (deblocking_filter_override_enabled_flag)
1525  {
1526  br.get_bits(1); // deblocking_filter_override_flag; // u(1)
1527  }
1528  if (deblocking_filter_override_flag)
1529  {
1530  br.get_bits(1); // slice_deblocking_filter_disabled_flag; // u(1)
1531  if (!slice_deblocking_filter_disabled_flag)
1532  {
1533  br.get_se_golomb(); // slice_beta_offset_div2; //se(v)
1534  br.get_se_golomb(); // slice_tc_offset_div2; //se(v)
1535  }
1536  }
1537  if (pps_loop_filter_across_slices_enabled_flag &&
1538  ( slice_sao_luma_flag || slice_sao_chroma_flag ||
1539  !slice_deblocking_filter_disabled_flag))
1540  {
1541  br.get_bits(1); // slice_loop_filter_across_slices_enabled_flag; // u(1)
1542  }
1543 #endif
1544  }
1545 #if 0 // We don't need the rest
1546  if (tiles_enabled_flag || entropy_coding_sync_enabled_flag)
1547  {
1548  br.get_ue_golomb(); // num_entry_point_offsets; // ue(v)
1549  if (num_entry_point_offsets > 0)
1550  {
1551  br.get_ue_golomb(); // offset_len_minus1; // ue(v)
1552  for (i = 0; i < num_entry_point_offsets; ++i)
1553  {
1554  br.get_bits(??? ); // entry_point_offset_minus1[i]; // u(v)
1555  }
1556  }
1557  }
1558  if (slice_segment_header_extension_present_flag)
1559  {
1560  br.get_ue_golomb(); // slice_segment_header_extension_length; // ue(v)
1561  for (i = 0; i < slice_segment_header_extension_length; ++i)
1562  {
1563  slice_segment_header_extension_data_byte[i]; // u(8)
1564  }
1565  }
1566  byte_alignment();
1567 #endif
1568 
1569  return true;
1570 }
1571 
1572 /*
1573  F.7.3.2.2.1 General sequence parameter set RBSP
1574 */
1576 {
1577  uint i = 0;
1578  static std::array<ShortTermRefPicSet,65> short_term_ref_pic_set;
1579 
1580  static uint sub_layer_size = 0;
1581  static uint8_t* max_dec_pic_buffering_minus1 = nullptr;
1582 
1583  m_seenSPS = true;
1584 
1585  uint vps_id = br.get_bits(4); // sps_video_parameter_set_id u(4)
1586 
1587  uint ext_or_max_sub_layers_minus1 = br.get_bits(3); // u(3)
1588  uint max_sub_layers_minus1 = 0;
1589 
1590  if (m_nuhLayerId == 0)
1591  max_sub_layers_minus1 = ext_or_max_sub_layers_minus1;
1592  else
1593  {
1594  if (m_vps.find(vps_id) == m_vps.end())
1595  {
1596  LOG(VB_RECORD, LOG_WARNING, LOC +
1597  QString("Could not find VPS[%1]").arg(vps_id));
1598  max_sub_layers_minus1 = ext_or_max_sub_layers_minus1;
1599  }
1600  else
1601  {
1602  /*
1603  When not present, the value of sps_max_sub_layers_minus1 is
1604  inferred to be equal to ( sps_ext_or_max_sub_layers_minus1
1605  == 7) ? vps_max_sub_layers_minus1 :
1606  sps_ext_or_max_sub_layers_minus1
1607  */
1608  max_sub_layers_minus1 = (ext_or_max_sub_layers_minus1 == 7) ?
1609  m_vps[vps_id].max_sub_layers :
1610  ext_or_max_sub_layers_minus1;
1611  }
1612  }
1613 
1614  if (sub_layer_size <= max_sub_layers_minus1)
1615  {
1616  delete[] max_dec_pic_buffering_minus1;
1617  sub_layer_size = max_sub_layers_minus1 + 1;
1618  max_dec_pic_buffering_minus1 = new uint8_t[sub_layer_size];
1619  }
1620 
1621  bool MultiLayerExtSpsFlag =
1622  (m_nuhLayerId != 0 && ext_or_max_sub_layers_minus1 == 7);
1623 
1624  if (!MultiLayerExtSpsFlag)
1625  {
1626  br.get_bits(1); // sps_temporal_id_nesting_flag u(1)
1627  if (!profileTierLevel(br, true, max_sub_layers_minus1))
1628  {
1629  LOG(VB_RECORD, LOG_WARNING, LOC +
1630  QString("Failed to parse SPS profiel tier level."));
1631  return false;
1632  }
1633  }
1634 
1635  uint sps_id = br.get_ue_golomb(); // sps_seq_parameter_set_id ue(v);
1636  SPS* sps = &m_sps[sps_id];
1637 
1638  if (MultiLayerExtSpsFlag)
1639  {
1640  if (br.get_bits(1)) // update_rep_format_flag u(1)
1641  {
1642  br.get_bits(8); // sps_rep_format_idx
1643  }
1644  }
1645  else
1646  {
1647  m_chromaFormatIdc = br.get_ue_golomb(); // ue(v);
1648  if (m_chromaFormatIdc == 3)
1649  m_separateColourPlaneFlag = br.get_bits(1); // u(1)
1650 
1651  /*
1652  pic_width_in_luma_samples specifies the width of each decoded
1653  picture in units of luma samples.
1654 
1655  pic_width_in_luma_samples shall not be equal to 0 and shall be
1656  an integer multiple of MinCbSizeY.
1657  */
1658  m_picWidth = br.get_ue_golomb(); // pic_width_in_luma_samples ue(v);
1659 
1660  /*
1661  pic_height_in_luma_samples specifies the height of each decoded
1662  picture in units of luma samples.
1663 
1664  pic_height_in_luma_samples shall not be equal to 0 and shall be
1665  an integer multiple of MinCbSizeY.
1666  */
1667  m_picHeight = br.get_ue_golomb(); // pic_height_in_luma_samples ue(v);
1668 
1669  if (br.get_bits(1)) //conformance_window_flag u(1)
1670  {
1671  m_frameCropLeftOffset = br.get_ue_golomb(); // ue(v);
1672  m_frameCropRightOffset = br.get_ue_golomb(); // ue(v);
1673  m_frameCropTopOffset = br.get_ue_golomb(); // ue(v);
1674  m_frameCropBottomOffset = br.get_ue_golomb(); // ue(v);
1675  }
1676 
1677  br.get_ue_golomb(); // bit_depth_luma_minus8 ue(v);
1678  br.get_ue_golomb(); // bit_depth_chroma_minus8 ue(v);
1679  }
1680 
1681 #if 1
1682  /* Potentially a lot more bits to wade through to get to the VUI
1683  information, so only do it if it looks like the info has changed.
1684  */
1685  if (m_sarWidth != 0 && m_sarHeight != 0 &&
1686  (m_picWidth + m_picHeight +
1689  return true;
1693 #endif
1694 
1695  sps->log2_max_pic_order_cnt_lsb = br.get_ue_golomb() + 4; // ue(v);
1696  if (sps->log2_max_pic_order_cnt_lsb > 16)
1697  {
1698  LOG(VB_RECORD, LOG_WARNING, LOC +
1699  QString("SPS log2_max_pic_order_cnt_lsb %1 > 16")
1700  .arg(sps->log2_max_pic_order_cnt_lsb));
1701  sps->log2_max_pic_order_cnt_lsb = 16;
1702  }
1703  // MaxPicOrderCntLsb = 2 ^ ( log2_max_pic_order_cnt_lsb_minus4 + 4 )
1704 
1705  sps->sub_layer_ordering_info_present_flag = br.get_bits(1); // u(1)
1706  for (i = (sps->sub_layer_ordering_info_present_flag ? 0 :
1707  max_sub_layers_minus1); i <= max_sub_layers_minus1; ++i)
1708  {
1709  max_dec_pic_buffering_minus1[i] = br.get_ue_golomb(); // ue(v);
1710  if (max_dec_pic_buffering_minus1[i] > 16)
1711  {
1712  LOG(VB_RECORD, LOG_WARNING, LOC +
1713  QString("max_dec_pic_bufering_minus1[%1] %2 > 16")
1714  .arg(i)
1715  .arg(max_dec_pic_buffering_minus1[i]));
1716  }
1717  br.get_ue_golomb(); // sps_max_num_reorder_pics[i] ue(v);
1718  br.get_ue_golomb(); // sps_max_latency_increase_plus1[i] ue(v);
1719  }
1720 
1721 #if 0 // Unneeded
1722  /* setting default values if
1723  * sps->sub_layer_ordering_info_present_flag is zero */
1724  if (!sps_sub_layer_ordering_info_present_flag && sps_max_sub_layers_minus1)
1725  {
1726  for (i = 0; i <= (sps_max_sub_layers_minus1 - 1); ++i)
1727  {
1728  max_dec_pic_buffering_minus1[i] =
1729  max_dec_pic_buffering_minus1[sps_max_sub_layers_minus1];
1730  max_num_reorder_pics[i] =
1731  max_num_reorder_pics[sps_max_sub_layers_minus1];
1732  max_latency_increase_plus1[i] =
1733  max_latency_increase_plus1[sps_max_sub_layers_minus1];
1734  }
1735  }
1736 #endif
1737 
1738  sps->log2_min_luma_coding_block_size = br.get_ue_golomb() + 3; // _minus3 ue(v);
1740  br.get_ue_golomb(); // log2_min_luma_transform_block_size_minus2 ue(v);
1741  br.get_ue_golomb(); // log2_diff_max_min_luma_transform_block_size ue(v);
1742  br.get_ue_golomb(); // max_transform_hierarchy_depth_inter ue(v);
1743  br.get_ue_golomb(); // max_transform_hierarchy_depth_intra ue(v);
1744 
1745  if (br.get_bits(1)) // scaling_list_enabled_flag // u(1)
1746  {
1747  ScalingList scaling_list;
1748 
1749  /* When not present, the value of
1750  * sps_infer_scaling_list_flag is inferred to be 0 */
1751  bool sps_infer_scaling_list_flag = MultiLayerExtSpsFlag ?
1752  br.get_bits(1) : false; // u(1)
1753  if (sps_infer_scaling_list_flag)
1754  {
1755  br.get_bits(6); // sps_scaling_list_ref_layer_id; u(6)
1756  }
1757  else
1758  {
1759  if (br.get_bits(1)) // sps_scaling_list_data_present_flag;
1760  scalingListData(br, scaling_list, false);
1761  }
1762  }
1763 
1764  br.get_bits(1); // amp_enabled_flag u(1)
1765  br.get_bits(1); // sample_adaptive_offset_enabled_flag u(1)
1766  if (br.get_bits(1)) // pcm_enabled_flag u(1)
1767  {
1768  br.get_bits(4); // pcm_sample_bit_depth_luma_minus1 u(4);
1769  br.get_bits(4); // pcm_sample_bit_depth_chroma_minus1 u(4);
1770  br.get_ue_golomb(); // log2_min_pcm_luma_coding_block_size_minus3 ue(v);
1771  br.get_ue_golomb(); // log2_diff_max_min_pcm_luma_coding_block_size ue(v);
1772  br.get_bits(1); // pcm_loop_filter_disabled_flag u(1)
1773  }
1774 
1775  uint num_short_term_ref_pic_sets = br.get_ue_golomb(); // ue(v);
1776  if (num_short_term_ref_pic_sets > short_term_ref_pic_set.size() - 1 )
1777  {
1778  LOG(VB_RECORD, LOG_WARNING, LOC +
1779  QString("num_short_term_ref_pic_sets %1 > 64")
1780  .arg(num_short_term_ref_pic_sets));
1781  num_short_term_ref_pic_sets = short_term_ref_pic_set.size() - 1;
1782  }
1783  for(i = 0; i < num_short_term_ref_pic_sets; ++i)
1784  {
1785  if (!shortTermRefPicSet(br, i, num_short_term_ref_pic_sets,
1786  short_term_ref_pic_set,
1787  max_dec_pic_buffering_minus1[max_sub_layers_minus1]))
1788  {
1789  return false;
1790  }
1791  }
1792 
1793  if (br.get_bits(1)) // long_term_ref_pics_present_flag u(1)
1794  {
1795  uint num_long_term_ref_pics_sps = br.get_ue_golomb(); // ue(v);
1796  for (i = 0; i < num_long_term_ref_pics_sps; ++i)
1797  {
1798  /*
1799  lt_ref_pic_poc_lsb_sps[i] specifies the picture order
1800  count modulo MaxPicOrderCntLsb of the i-th candidate
1801  long-term reference picture specified in the SPS. The
1802  number of bits used to represent lt_ref_pic_poc_lsb_sps[
1803  i ] is equal to log2_max_pic_order_cnt_lsb_minus4 + 4.
1804  */
1805  m_poc[i] = br.get_bits(sps->log2_max_pic_order_cnt_lsb); // u(v)
1806  LOG(VB_RECORD, LOG_WARNING, LOC +
1807  QString("POC[%1] %2").arg(i).arg(m_poc[i]));
1808  br.get_bits(1); // used_by_curr_pic_lt_sps_flag[i] u(1)
1809  }
1810  }
1811 
1812  br.get_bits(1); //sps_temporal_mvp_enabled_flag u(1)
1813  br.get_bits(1); //strong_intra_smoothing_enabled_flag u(1)
1814 
1815  /*
1816  vui_parameters_present_flag equal to 1 specifies that the
1817  vui_parameters() syntax structure as specified in Annex E is
1818  present. vui_parameters_present_flag equal to 0 specifies that
1819  the vui_parameters() syntax structure as specified in Annex E
1820  is not present.
1821  */
1822  if (br.get_bits(1)) // vui_parameters_present_flag
1823  vui_parameters(br, true);
1824 
1825  return true;
1826 }
1827 
1828 
1829 /*
1830  F.7.3.2.1 Video parameter set RBSP
1831 */
1833 {
1834  int i = 0;
1835 
1836  uint8_t vps_id = br.get_bits(4); // vps_video_parameter_set_id u(4)
1837  br.get_bits(1); // vps_base_layer_internal_flag u(1)
1838  br.get_bits(1); // vps_base_layer_available_flag u(1)
1839  br.get_bits(6); // vps_max_layers_minus1 u(6)
1840  uint8_t max_sub_layers_minus1 = br.get_bits(3); // u(3)
1841  br.get_bits(1); // vps_temporal_id_nesting_flag u(1)
1842 
1843  /* uint16_t check = */ br.get_bits(16); // vps_reserved_0xffff_16bits u(16)
1844 
1845  m_vps[vps_id].max_sub_layers = max_sub_layers_minus1 + 1;
1846  if (!profileTierLevel(br, true, max_sub_layers_minus1))
1847  {
1848  LOG(VB_RECORD, LOG_WARNING, LOC +
1849  QString("Failed to parse VPS profile tier level."));
1850  return false;
1851  }
1852 
1853  bool vps_sub_layer_ordering_info_present_flag = br.get_bits(1); // u(1)
1854  for (i = (vps_sub_layer_ordering_info_present_flag ? 0 :
1855  max_sub_layers_minus1);
1856  i <= max_sub_layers_minus1; ++i)
1857  {
1858  br.get_ue_golomb(); // vps_max_dec_pic_buffering_minus1[i]; ue(v)
1859  br.get_ue_golomb(); // vps_max_num_reorder_pics[i]; ue(v)
1860  br.get_ue_golomb(); // vps_max_latency_increase_plus1[i]; ue(v)
1861  }
1862 
1863 #if 0 // Unneeded
1864  /* setting default values if
1865  * vps->sub_layer_ordering_info_present_flag is zero */
1866  if (!vps_sub_layer_ordering_info_present_flag &&
1867  max_sub_layers_minus1)
1868  {
1869  for (i = 0; i <= (max_sub_layers_minus1 - 1); ++i)
1870  {
1871  max_dec_pic_buffering_minus1[i] =
1872  max_dec_pic_buffering_minus1[max_sub_layers_minus1];
1873  max_num_reorder_pics[i] =
1874  max_num_reorder_pics[max_sub_layers_minus1];
1875  max_latency_increase_plus1[i] =
1876  max_latency_increase_plus1[max_sub_layers_minus1];
1877  }
1878  }
1879 #endif
1880 
1881  uint8_t vps_max_layer_id = br.get_bits(6); // u(6)
1882  int vps_num_layer_sets_minus1 = br.get_ue_golomb(); // ue(v)
1883  for (i = 1; i <= vps_num_layer_sets_minus1; ++i)
1884  {
1885  for (int j = 0; j <= vps_max_layer_id; ++j)
1886  {
1887  br.get_bits(1); // layer_id_included_flag[i][j] u(1)
1888  }
1889  }
1890  if (vps_num_layer_sets_minus1 < 0)
1891  {
1892  LOG(VB_RECORD, LOG_WARNING, LOC +
1893  QString("vps_num_layer_sets_minus1 %1 < 0")
1894  .arg(vps_num_layer_sets_minus1));
1895  }
1896 
1897  if (br.get_bits(1)) // vps_timing_info_present_flag u(1)
1898  {
1899  /*
1900  vps_num_units_in_tick is the number of time units of a clock
1901  operating at the frequency vps_time_scale Hz that
1902  corresponds to one increment (called a clock tick) of a
1903  clock tick counter. The value of vps_num_units_in_tick shall
1904  be greater than 0. A clock tick, in units of seconds, is
1905  equal to the quotient of vps_num_units_in_tick divided by
1906  vps_time_scale. For example, when the picture rate of a
1907  video signal is 25 Hz, vps_time_scale may be equal to 27 000
1908  000 and vps_num_units_in_tick may be equal to 1 080 000, and
1909  consequently a clock tick may be 0.04 seconds.
1910  */
1911  m_unitsInTick = br.get_bits(32); // vps_num_units_in_tick
1912 
1913  /*
1914  vps_time_scale is the number of time units that pass in one
1915  second. For example, a time coordinate system that measures
1916  time using a 27 MHz clock has a vps_time_scale of 27 000
1917  000. The value of vps_time_scale shall be greater than 0.
1918  */
1919  m_timeScale = br.get_bits(32); // vps_time_scale
1920 
1921  if (br.get_bits(1)) // vps_poc_proportional_to_timing_flag) u(1)
1922  br.get_ue_golomb_long(); // vps_num_ticks_poc_diff_one_minus1 ue(v)
1923 
1924  LOG(VB_RECORD, LOG_DEBUG,
1925  QString("VUI unitsInTick %1 timeScale %2 fixedRate %3")
1926  .arg(m_unitsInTick)
1927  .arg(m_timeScale)
1928  .arg(m_fixedRate));
1929 
1930 #if 0 // We don't need the rest.
1931  uint vps_num_hrd_parameters = br.get_ue_golomb(); // ue(v)
1932  for (i = 0; i < vps_num_hrd_parameters; ++i)
1933  {
1934  br.get_ue_golomb(); // hrd_layer_set_idx[i] ue(v)
1935  if (i > 0)
1936  cprms_present_flag[i] = br.get_bits(1); // u(1)
1937  hrd_parameters(cprms_present_flag[i], max_sub_layers_minus1);
1938  }
1939 #endif
1940  }
1941 
1942 #if 0 // We don't need the rest.
1943  bool vps_extension_flag = br.get_bits(1); // u(1)
1944  if (vps_extension_flag)
1945  {
1946  while (!byte_aligned())
1947  {
1948  br.get_bits(1); // vps_extension_alignment_bit_equal_to_one u(1)
1949  }
1950  vps_extension();
1951  vps_extension2_flag = br.get_bits(1); // u(1)
1952  if (vps_extension2_flag)
1953  {
1954  while (more_rbsp_data())
1955  br.get_bits(1); // vps_extension_data_flag u(1)
1956  }
1957  }
1958  rbsp_trailing_bits();
1959 #endif
1960 
1961  return true;
1962 }
1963 
1964 /* 7.3.2.3.1 General picture parameter set RBSP syntax */
1966 {
1967  uint pps_id = br.get_ue_golomb(); // pps_pic_parameter_set_id ue(v)
1968  PPS* pps = &m_pps[pps_id];
1969 
1970  pps->sps_id = br.get_ue_golomb(); // pps_seq_parameter_set_id; ue(v)
1971  pps->dependent_slice_segments_enabled_flag = br.get_bits(1); // u(1)
1972 
1973  pps->output_flag_present_flag = br.get_bits(1); // u(1)
1974  pps->num_extra_slice_header_bits = br.get_bits(3); // u(3)
1975 
1976 #if 0 // Rest not needed
1977  sign_data_hiding_enabled_flag;
1978  cabac_init_present_flag;
1979  num_ref_idx_l0_default_active_minus1;
1980  num_ref_idx_l1_default_active_minus1;
1981  init_qp_minus26;
1982  constrained_intra_pred_flag;
1983  transform_skip_enabled_flag;
1984  cu_qp_delta_enabled_flag;
1985  if( cu_qp_delta_enabled_flag )
1986  diff_cu_qp_delta_depth;
1987  pps_cb_qp_offset;
1988  pps_cr_qp_offset;
1989  pps_slice_chroma_qp_offsets_present_flag;
1990  weighted_pred_flag;
1991  weighted_bipred_flag;
1992  transquant_bypass_enabled_flag;
1993  tiles_enabled_flag;
1994  entropy_coding_sync_enabled_flag;
1995  if( tiles_enabled_flag ) {
1996  num_tile_columns_minus1;
1997  num_tile_rows_minus1;
1998  uniform_spacing_flag;
1999  if( !uniform_spacing_flag ) {
2000  for( i = 0; i < num_tile_columns_minus1; i++ )
2001  column_width_minus1[ i ];
2002  for( i = 0; i < num_tile_rows_minus1; i++ )
2003  row_height_minus1[ i ];
2004  }
2005  loop_filter_across_tiles_enabled_flag;
2006  pps_loop_filter_across_slices_enabled_flag;
2007  deblocking_filter_control_present_flag;
2008  if( deblocking_filter_control_present_flag ) {
2009  }
2010  deblocking_filter_override_enabled_flag;
2011  pps_deblocking_filter_disabled_flag;
2012  if( !pps_deblocking_filter_disabled_flag ) {
2013  pps_beta_offset_div2;
2014  pps_tc_offset_div2;
2015  }
2016  }
2017  pps_scaling_list_data_present_flag;
2018  if( pps_scaling_list_data_present_flag )
2019  scaling_list_data( );
2020  lists_modification_present_flag;
2021  log2_parallel_merge_level_minus2;
2022  slice_segment_header_extension_present_flag;
2023  pps_extension_present_flag;
2024  if( pps_extension_present_flag ) {
2025  pps_range_extension_flag;
2026  pps_multilayer_extension_flag;
2027  pps_3d_extension_flag;
2028  pps_scc_extension_flag;
2029  pps_extension_4bits;
2030  }
2031  if( pps_range_extension_flag )
2032  pps_range_extension( );
2033  if( pps_multilayer_extension_flag )
2034  pps_multilayer_extension( ); /* specified in Annex F */
2035  if( pps_3d_extension_flag )
2036  pps_3d_extension( ); /* specified in Annex I */
2037  if( pps_scc_extension_flag )
2038  pps_scc_extension( );
2039  if( pps_extension_4bits )
2040  while( more_rbsp_data( ) )
2041  pps_extension_data_flag;
2042  rbsp_trailing_bits( )
2043 #endif
2044 
2045  return true;
2046 }
2047 
2048 // Following the lead of AVCParser, ignore the left cropping.
2050 {
2051  static const std::array<const uint8_t,5> subwc {1, 2, 2, 1, 1};
2052  const uint8_t crop_unit_x = subwc[m_chromaFormatIdc];
2053  // uint crop_rect_x = m_frameCropLeftOffset * crop_unit_x;
2054 
2055  return m_picWidth - ((/* m_frameCropLeftOffset + */
2056  m_frameCropRightOffset) * crop_unit_x);
2057 }
2058 
2059 // Following the lead of AVCParser, ignore the top cropping.
2061 {
2062  static const std::array<const uint8_t,5> subhc {1, 2, 1, 1, 1};
2063  const uint8_t crop_unit_y = subhc[m_chromaFormatIdc];
2064  // uint crop_rect_y = m_frameCropTopOffset * crop_unit_y;
2065 
2066  return m_picHeight - ((/* m_frameCropTopOffset + */
2067  m_frameCropBottomOffset) * crop_unit_y);
2068 }
2069 
2071 {
2072  result = (m_unitsInTick == 0) ? FrameRate(0) :
2074 }
H2645Parser::m_onAU
bool m_onAU
Definition: H2645Parser.h:148
bytereader.h
H2645Parser::m_seenSPS
bool m_seenSPS
Definition: H2645Parser.h:151
HEVCParser::NALisVCL
static bool NALisVCL(uint type)
Definition: HEVCParser.h:257
H2645Parser::m_frameCropRightOffset
uint m_frameCropRightOffset
Definition: H2645Parser.h:132
HEVCParser::RSV_VCL_R15
@ RSV_VCL_R15
Definition: HEVCParser.h:96
MythTimer::elapsed
std::chrono::milliseconds elapsed(void)
Returns milliseconds elapsed since last start() or restart()
Definition: mythtimer.cpp:91
H2645Parser::m_frameStartOffset
uint64_t m_frameStartOffset
Definition: H2645Parser.h:116
shortTermRefPicSet
static bool shortTermRefPicSet(BitReader &br, int stRPSIdx, int num_short_term_ref_pic_sets, std::array< HEVCParser::ShortTermRefPicSet, 65 > &stRPS, uint8_t max_dec_pic_buffering_minus1)
Definition: HEVCParser.cpp:1052
HEVCParser::STSA_R
@ STSA_R
Definition: HEVCParser.h:81
HEVCParser::SPS::separate_colour_plane_flag
bool separate_colour_plane_flag
Definition: HEVCParser.h:170
H2645Parser::fillRBSP
bool fillRBSP(const uint8_t *byteP, uint32_t byte_count, bool found_start_code)
Definition: H2645Parser.cpp:134
H2645Parser::m_separateColourPlaneFlag
bool m_separateColourPlaneFlag
Definition: H2645Parser.h:152
HEVCParser::UNSPEC48
@ UNSPEC48
Definition: HEVCParser.h:167
SCAN_t::PROGRESSIVE
@ PROGRESSIVE
HEVCParser::QUANT_MATIX_4X4
@ QUANT_MATIX_4X4
Definition: HEVCParser.h:226
H2645Parser::m_sarWidth
uint m_sarWidth
Definition: H2645Parser.h:137
HEVCParser::SPS::sub_layer_ordering_info_present_flag
bool sub_layer_ordering_info_present_flag
Definition: HEVCParser.h:171
dtvrecorder.h
H2645Parser::m_keyframeStartOffset
uint64_t m_keyframeStartOffset
Definition: H2645Parser.h:117
HEVCParser::m_noRaslOutputFlag
bool m_noRaslOutputFlag
Definition: HEVCParser.h:303
MythTimer
A QElapsedTimer based timer to replace use of QTime as a timer.
Definition: mythtimer.h:13
HEVCParser::m_nalTemperalId
uint8_t m_nalTemperalId
Definition: HEVCParser.h:298
HEVCParser::RSV_IRAP_VCL23
@ RSV_IRAP_VCL23
Definition: HEVCParser.h:137
H2645Parser::m_unitsInTick
uint32_t m_unitsInTick
Definition: H2645Parser.h:126
H2645Parser::m_framecnt
uint64_t m_framecnt
Definition: H2645Parser.h:111
HEVCParser::ScalingList::scaling_lists_4x4
std::array< std::array< uint8_t, 16 >, 6 > scaling_lists_4x4
Definition: HEVCParser.h:218
H2645Parser::m_picWidth
uint m_picWidth
Definition: H2645Parser.h:135
SCAN_t::INTERLACED
@ INTERLACED
HEVCParser::RADL_N
@ RADL_N
Definition: HEVCParser.h:83
H2645Parser::m_pktOffset
uint64_t m_pktOffset
Definition: H2645Parser.h:118
H2645Parser::m_scanType
SCAN_t m_scanType
Definition: H2645Parser.h:128
H2645Parser::m_frameCropLeftOffset
uint m_frameCropLeftOffset
Definition: H2645Parser.h:131
H2645Parser::Reset
virtual void Reset(void)
Definition: H2645Parser.cpp:93
BitReader::get_bits
uint32_t get_bits(unsigned n)
Read 0-32 bits.
Definition: bitreader.h:86
HEVCParser::parseVPS
bool parseVPS(BitReader &br)
Definition: HEVCParser.cpp:1832
HEVCParser::RASL_N
@ RASL_N
Definition: HEVCParser.h:87
HEVCParser::SPS
Definition: HEVCParser.h:166
HEVCParser::QUANT_MATIX_32X32
@ QUANT_MATIX_32X32
Definition: HEVCParser.h:229
HEVCParser::m_picOrderCntMsb
uint32_t m_picOrderCntMsb
Definition: HEVCParser.h:290
HEVCParser::PPS
Definition: HEVCParser.h:179
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
HEVCParser::m_nalUnitType
uint m_nalUnitType
Definition: HEVCParser.h:296
HEVCParser::BLA_W_LP
@ BLA_W_LP
Definition: HEVCParser.h:112
H2645Parser::UNKNOWN
@ UNKNOWN
Definition: H2645Parser.h:85
HEVCParser::parseSPS
bool parseSPS(BitReader &br)
Definition: HEVCParser.cpp:1575
HEVCParser::SPS::log2_min_luma_coding_block_size
uint8_t log2_min_luma_coding_block_size
Definition: HEVCParser.h:167
HEVCParser::SUFFIX_SEI_NUT
@ SUFFIX_SEI_NUT
Definition: HEVCParser.h:157
getScalingListParams
static bool getScalingListParams(uint8_t sizeId, uint8_t matrixId, HEVCParser::ScalingList &dest_scaling_list, uint8_t *&sl, uint8_t &size, std::vector< int16_t > &scaling_list_dc_coef_minus8)
Definition: HEVCParser.cpp:877
HEVCParser::RASL_R
@ RASL_R
Definition: HEVCParser.h:88
HEVCParser::AUD_NUT
@ AUD_NUT
Definition: HEVCParser.h:151
HEVCParser::PPS::num_extra_slice_header_bits
uint8_t num_extra_slice_header_bits
Definition: HEVCParser.h:182
bitreader.h
HEVCParser::TSA_N
@ TSA_N
Definition: HEVCParser.h:77
H2645Parser::vui_parameters
void vui_parameters(BitReader &br, bool hevc)
Definition: H2645Parser.cpp:215
HEVCParser::UNSPEC63
@ UNSPEC63
Definition: HEVCParser.h:182
BitReader
Definition: bitreader.h:38
BitReader::get_se_golomb
int get_se_golomb()
read signed exp golomb code.
Definition: bitreader.h:144
HEVCParser::EOB_NUT
@ EOB_NUT
Definition: HEVCParser.h:153
HEVCParser::BLA_W_RADL
@ BLA_W_RADL
Definition: HEVCParser.h:113
HEVCParser::VPS_NUT
@ VPS_NUT
Definition: HEVCParser.h:148
mythlogging.h
HEVCParser::m_pps
std::map< uint, PPS > m_pps
Definition: HEVCParser.h:307
HEVCParser::RSV_VCL_N14
@ RSV_VCL_N14
Definition: HEVCParser.h:92
HEVCParser::Reset
void Reset(void) override
Definition: HEVCParser.cpp:45
H2645Parser::m_keyframecnt
uint64_t m_keyframecnt
Definition: H2645Parser.h:112
H2645Parser::m_rbspIndex
uint32_t m_rbspIndex
Definition: H2645Parser.h:123
H2645Parser::m_fixedRate
bool m_fixedRate
Definition: H2645Parser.h:145
H2645Parser::m_frameCropBottomOffset
uint m_frameCropBottomOffset
Definition: H2645Parser.h:130
HEVCParser::pictureWidthCropped
uint pictureWidthCropped(void) const override
Definition: HEVCParser.cpp:2049
HEVCParser::ScalingList::scaling_list_dc_coef_minus8_16x16
std::vector< int16_t > scaling_list_dc_coef_minus8_16x16
Definition: HEVCParser.h:215
HEVCParser::STSA_N
@ STSA_N
Definition: HEVCParser.h:80
FrameRate
Definition: recorderbase.h:38
HEVCParser::ShortTermRefPicSet
Definition: HEVCParser.h:186
H2645Parser::m_rbspBuffer
uint8_t * m_rbspBuffer
Definition: H2645Parser.h:139
HEVCParser::addBytes
uint32_t addBytes(const uint8_t *bytes, uint32_t byte_count, uint64_t stream_offset) override
Definition: HEVCParser.cpp:126
HEVCParser::PREFIX_SEI_NUT
@ PREFIX_SEI_NUT
Definition: HEVCParser.h:156
H2645Parser::m_auOffset
uint64_t m_auOffset
Definition: H2645Parser.h:115
HEVCParser::SPS::log2_diff_max_min_luma_coding_block_size
uint8_t log2_diff_max_min_luma_coding_block_size
Definition: HEVCParser.h:168
HEVCParser::CRA_NUT
@ CRA_NUT
Definition: HEVCParser.h:133
H2645Parser::m_auPending
bool m_auPending
Definition: H2645Parser.h:144
H2645Parser::m_onKeyFrame
bool m_onKeyFrame
Definition: H2645Parser.h:150
HEVCParser::UNSPEC55
@ UNSPEC55
Definition: HEVCParser.h:174
HEVCParser::UNSPEC56
@ UNSPEC56
Definition: HEVCParser.h:175
HEVCParser::m_resolutionCheck
uint32_t m_resolutionCheck
Definition: HEVCParser.h:294
HEVCParser.h
HEVCParser::PPS_NUT
@ PPS_NUT
Definition: HEVCParser.h:150
HEVCParser::m_prevPicOrderCntMsb
uint32_t m_prevPicOrderCntMsb
Definition: HEVCParser.h:293
HEVCParser::pictureHeightCropped
uint pictureHeightCropped(void) const override
Definition: HEVCParser.cpp:2060
uint
unsigned int uint
Definition: compat.h:81
H2645Parser::m_spsOffset
uint64_t m_spsOffset
Definition: H2645Parser.h:119
HEVCParser::profileTierLevel
bool profileTierLevel(BitReader &br, bool profilePresentFlag, int maxNumSubLayersMinus1)
Definition: HEVCParser.cpp:576
HEVCParser::ScalingList::scaling_lists_16x16
std::array< std::array< uint8_t, 64 >, 6 > scaling_lists_16x16
Definition: HEVCParser.h:220
H2645Parser::m_stateChanged
bool m_stateChanged
Definition: H2645Parser.h:153
HEVCParser::RSV_VCL_N12
@ RSV_VCL_N12
Definition: HEVCParser.h:91
ByteReader::start_code_is_valid
bool start_code_is_valid(uint32_t start_code)
Test whether a start code found by find_start_code() is valid.
Definition: bytereader.h:54
ceil_log2
static uint ceil_log2(uint32_t v)
Definition: HEVCParser.cpp:23
H2645Parser::m_timeScale
uint32_t m_timeScale
Definition: H2645Parser.h:125
H2645Parser::m_onFrame
bool m_onFrame
Definition: H2645Parser.h:149
HEVCParser::RSV_VCL_R11
@ RSV_VCL_R11
Definition: HEVCParser.h:94
HEVCParser::TAIL_N
@ TAIL_N
Definition: HEVCParser.h:74
LOC
static const QString LOC
Definition: HEVCParser.cpp:14
H2645Parser::m_haveUnfinishedNAL
bool m_haveUnfinishedNAL
Definition: H2645Parser.h:146
HEVCParser::RSV_VCL_R13
@ RSV_VCL_R13
Definition: HEVCParser.h:95
HEVCParser::EOS_NUT
@ EOS_NUT
Definition: HEVCParser.h:152
H2645Parser::m_frameCropTopOffset
uint m_frameCropTopOffset
Definition: H2645Parser.h:133
HEVCParser::TAIL_R
@ TAIL_R
Definition: HEVCParser.h:75
HEVCParser::BLA_N_LP
@ BLA_N_LP
Definition: HEVCParser.h:114
H2645Parser::m_syncAccumulator
uint32_t m_syncAccumulator
Definition: H2645Parser.h:124
musicbrainzngs.compat.bytes
bytes
Definition: compat.py:49
HEVCParser::m_vps
std::map< uint, VPS > m_vps
Definition: HEVCParser.h:308
HEVCParser::parseSliceSegmentHeader
bool parseSliceSegmentHeader(BitReader &br)
Definition: HEVCParser.cpp:1248
scalingListData
static bool scalingListData(BitReader &br, HEVCParser::ScalingList &dest_scaling_list, bool use_default)
Definition: HEVCParser.cpp:914
HEVCParser::m_firstSliceSegmentInPicFlag
bool m_firstSliceSegmentInPicFlag
Definition: HEVCParser.h:301
HEVCParser::ScalingList::scaling_list_dc_coef_minus8_32x32
std::vector< int16_t > scaling_list_dc_coef_minus8_32x32
Definition: HEVCParser.h:216
HEVCParser::IDR_W_RADL
@ IDR_W_RADL
Definition: HEVCParser.h:125
H2645Parser::m_totalframecnt
uint64_t m_totalframecnt
Definition: H2645Parser.h:113
HEVCParser::IDR_N_LP
@ IDR_N_LP
Definition: HEVCParser.h:126
HEVCParser::m_sps
std::map< uint, SPS > m_sps
Definition: HEVCParser.h:306
BitReader::get_ue_golomb_long
uint32_t get_ue_golomb_long()
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
Definition: bitreader.h:115
HEVCParser::RADL_R
@ RADL_R
Definition: HEVCParser.h:84
HEVCParser::SPS::log2_max_pic_order_cnt_lsb
uint8_t log2_max_pic_order_cnt_lsb
Definition: HEVCParser.h:169
MythTimer::kStartRunning
@ kStartRunning
Definition: mythtimer.h:17
HEVCParser::processRBSP
void processRBSP(bool rbsp_complete)
Definition: HEVCParser.cpp:457
HEVCParser::SPS_NUT
@ SPS_NUT
Definition: HEVCParser.h:149
HEVCParser::ScalingList::scaling_lists_32x32
std::array< std::array< uint8_t, 64 >, 2 > scaling_lists_32x32
Definition: HEVCParser.h:221
HEVCParser::PPS::dependent_slice_segments_enabled_flag
bool dependent_slice_segments_enabled_flag
Definition: HEVCParser.h:180
H2645Parser::m_chromaFormatIdc
int8_t m_chromaFormatIdc
Definition: H2645Parser.h:142
HEVCParser::FD_NUT
@ FD_NUT
Definition: HEVCParser.h:154
HEVCParser::RSV_NVCL45
@ RSV_NVCL45
Definition: HEVCParser.h:163
HEVCParser::QUANT_MATIX_8X8
@ QUANT_MATIX_8X8
Definition: HEVCParser.h:227
HEVCParser::NALisIRAP
static bool NALisIRAP(uint type)
Definition: HEVCParser.h:252
HEVCParser::m_poc
std::map< uint, uint > m_poc
Definition: HEVCParser.h:309
H2645Parser::m_picHeight
uint m_picHeight
Definition: H2645Parser.h:134
HEVCParser::parsePPS
bool parsePPS(BitReader &br)
Definition: HEVCParser.cpp:1965
uint16_t
unsigned short uint16_t
Definition: iso6937tables.h:3
HEVCParser::RSV_NVCL44
@ RSV_NVCL44
Definition: HEVCParser.h:162
HEVCParser::parseSliceSegmentLayer
bool parseSliceSegmentLayer(BitReader &br)
Definition: HEVCParser.cpp:1231
HEVCParser::newAU
bool newAU(void)
Definition: HEVCParser.cpp:248
HEVCParser::PPS::output_flag_present_flag
bool output_flag_present_flag
Definition: HEVCParser.h:181
HEVCParser::NAL_type_str
QString NAL_type_str(int8_t type) override
Definition: HEVCParser.cpp:50
HEVCParser::getFrameRate
void getFrameRate(FrameRate &result) const override
Definition: HEVCParser.cpp:2070
HEVCParser::RSV_VCL_N10
@ RSV_VCL_N10
Definition: HEVCParser.h:90
HEVCParser::RSV_IRAP_VCL22
@ RSV_IRAP_VCL22
Definition: HEVCParser.h:136
HEVCParser::m_nuhLayerId
uint8_t m_nuhLayerId
Definition: HEVCParser.h:299
H2645Parser::m_sarHeight
uint m_sarHeight
Definition: H2645Parser.h:136
BitReader::skip_bits
void skip_bits(unsigned n)
Definition: bitreader.h:48
H2645Parser::resetRBSP
void resetRBSP(void)
Definition: H2645Parser.cpp:127
BitReader::get_ue_golomb
int get_ue_golomb()
Read an unsigned Exp-Golomb code in the range 0 to 8190 (2^13 - 2).
Definition: bitreader.h:105
HEVCParser::ScalingList::scaling_lists_8x8
std::array< std::array< uint8_t, 64 >, 6 > scaling_lists_8x8
Definition: HEVCParser.h:219
HEVCParser::m_picOrderCntVal
uint32_t m_picOrderCntVal
Definition: HEVCParser.h:291
ByteReader::find_start_code_truncated
const MTV_PUBLIC uint8_t * find_start_code_truncated(const uint8_t *p, const uint8_t *end, uint32_t *start_code)
By preserving the start_code value between subsequent calls, the caller can detect start codes across...
Definition: bytereader.cpp:74
HEVCParser::m_nextNALisAU
bool m_nextNALisAU
Definition: HEVCParser.h:302
HEVCParser::RSV_NVCL47
@ RSV_NVCL47
Definition: HEVCParser.h:165
HEVCParser::TSA_R
@ TSA_R
Definition: HEVCParser.h:78
HEVCParser::m_seenEOS
bool m_seenEOS
Definition: HEVCParser.h:304
HEVCParser::RSV_NVCL41
@ RSV_NVCL41
Definition: HEVCParser.h:159
HEVCParser::PPS::sps_id
int sps_id
Definition: HEVCParser.h:183
H2645Parser::m_totalkeyframecnt
uint64_t m_totalkeyframecnt
Definition: H2645Parser.h:114
HEVCParser::m_prevPicOrderCntLsb
uint32_t m_prevPicOrderCntLsb
Definition: HEVCParser.h:292
HEVCParser::ScalingList
Definition: HEVCParser.h:214
HEVCParser::QUANT_MATIX_16X16
@ QUANT_MATIX_16X16
Definition: HEVCParser.h:228