MythTV  master
HEVCParser.cpp
Go to the documentation of this file.
1 // MythTV headers
2 #include "HEVCParser.h"
3 #include <iostream>
4 
5 #include "mythlogging.h"
6 #include "recorders/dtvrecorder.h" // for FrameRate
7 
8 
9 extern "C" {
10 #include "libavcodec/avcodec.h"
11 #include "libavutil/internal.h"
12 #include "libavcodec/golomb.h"
13 }
14 
15 #include <cmath>
16 #include <strings.h>
17 
18 #define LOC "HEVCParser "
19 
20 /*
21  References:
22  http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.352.3388&rep=rep1&type=pdf
23  https://www.itu.int/rec/T-REC-H.265-201911-I/en
24  https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=6316136
25  */
26 
27 static uint ceil_log2 (uint32_t v)
28 {
29  uint r = 0;
30  uint shift = 0;
31 
32  --v;
33  r = (v > 0xFFFF) << 4;
34  v >>= r;
35  shift = (v > 0xFF) << 3;
36  v >>= shift;
37  r |= shift;
38  shift = (v > 0xF) << 2;
39  v >>= shift;
40  r |= shift;
41  shift = (v > 0x3) << 1;
42  v >>= shift;
43  r |= shift;
44  r |= (v >> 1);
45 
46  return r + 1;
47 }
48 
50 {
52 }
53 
55 {
56  switch (type)
57  {
58  case UNKNOWN:
59  return "UNKNOWN";
60  case TAIL_N:
61  return "TAIL_N";
62  case TAIL_R:
63  return "TAIL_R";
64  case TSA_N:
65  return "TSA_N";
66  case TSA_R:
67  return "TSA_R";
68  case STSA_N:
69  return "STSA_N";
70  case STSA_R:
71  return "STSA_R";
72  case RADL_N:
73  return "RADL_N";
74  case RADL_R:
75  return "RADL_R";
76  case RASL_N:
77  return "RASL_N";
78  case RASL_R:
79  return "RASL_R";
80  case RSV_VCL_N10:
81  return "RSV_VCL_N10";
82  case RSV_VCL_N12:
83  return "RSV_VCL_N12";
84  case RSV_VCL_N14:
85  return "RSV_VCL_N14";
86  case RSV_VCL_R11:
87  return "RSV_VCL_R11";
88  case RSV_VCL_R13:
89  return "RSV_VCL_R13";
90  case RSV_VCL_R15:
91  return "RSV_VCL_R15";
92  case BLA_W_LP:
93  return "BLA_W_LP";
94  case BLA_W_RADL:
95  return "BLA_W_RADL";
96  case BLA_N_LP:
97  return "BLA_N_LP";
98  case IDR_W_RADL:
99  return "IDR_W_RADL";
100  case IDR_N_LP:
101  return "IDR_N_LP";
102  case CRA_NUT:
103  return "CRA_NUT";
104  case RSV_IRAP_VCL22:
105  return "RSV_IRAP_VCL22";
106  case RSV_IRAP_VCL23:
107  return "RSV_IRAP_VCL23";
108  case VPS_NUT:
109  return "VPS_NUT";
110  case SPS_NUT:
111  return "SPS_NUT";
112  case PPS_NUT:
113  return "PPS_NUT";
114  case AUD_NUT:
115  return "AUD_NUT";
116  case EOS_NUT:
117  return "EOS_NUT";
118  case EOB_NUT:
119  return "EOB_NUT";
120  case FD_NUT:
121  return "FD_NUT";
122  case PREFIX_SEI_NUT:
123  return "PREFIX_SEI_NUT";
124  case SUFFIX_SEI_NUT:
125  return "SUFFIX_SEI_NUT";
126  }
127  return "OTHER";
128 }
129 
130 uint32_t HEVCParser::addBytes(const uint8_t *bytes,
131  const uint32_t byte_count,
132  const uint64_t stream_offset)
133 {
134  const uint8_t *startP = bytes;
135 
136  m_stateChanged = false;
137  m_onFrame = false;
138  m_onKeyFrame = false;
139 
140 #if 0
141  static MythTimer timer(MythTimer::kStartRunning);
142  static int nexttime = 60000;
143 
144  if (timer.elapsed() > nexttime)
145  {
146  LOG(VB_GENERAL, LOG_DEBUG,
147  QString("Frames %1 KeyFrames %2 | Total Frames %3 KeyFrames %4")
148  .arg(m_framecnt)
152 
153  m_framecnt = 0;
154  m_keyframecnt = 0;
155  nexttime += 60000;
156  }
157 #endif
158 
159  while (!m_onFrame && (startP < bytes + byte_count))
160  {
161  const uint8_t *endP = avpriv_find_start_code(startP,
162  bytes + byte_count,
164 
165  // start_code_prefix_one_3bytes
166  bool found_start_code = ((m_syncAccumulator & 0xffffff00) == 0x00000100);
167 
168  /* Between startP and endP we potentially have some more
169  * bytes of a NAL that we've been parsing (plus some bytes of
170  * start code)
171  */
173  {
174  if (!fillRBSP(startP, endP - startP, found_start_code))
175  {
176  resetRBSP();
177  return endP - bytes;
178  }
179  }
180  processRBSP(found_start_code); /* Call may set have_uinfinished_NAL
181  * to false */
182 
183  /* Dealt with everything up to endP */
184  startP = endP;
185 
186  if (found_start_code)
187  {
189  {
190  /* We've found a new start code, without completely
191  * parsing the previous NAL. Either there's a
192  * problem with the stream or with this parser.
193  */
194  LOG(VB_GENERAL, LOG_ERR,
195  "HEVCParser::addBytes: Found new start "
196  "code, but previous NAL is incomplete!");
197  }
198 
199  /* Prepare for accepting the new NAL */
200  resetRBSP();
201 
202  /* If we find the start of an AU somewhere from here
203  * to the next start code, the offset to associate with
204  * it is the one passed in to this call, not any of the
205  * subsequent calls.
206  */
207  m_pktOffset = stream_offset; // + (startP - bytes);
208 
209  uint16_t nal_unit_header = ((m_syncAccumulator & 0xff) << 8)
210  | *startP;
211  ++startP;
212 
213  // nal_unit header
214  if (nal_unit_header & 0x8000)
215  {
216  LOG(VB_GENERAL, LOG_ERR, "HEVCParser::parseNAL: "
217  "NAL header forbidden_zero_bit is not zero!");
218  return false;
219  }
220 
221  m_nalTemperalId = (nal_unit_header & 0x7) - 1;
222  m_nuhLayerId = (nal_unit_header >> 3) & 0x3f;
223  m_nalUnitType = (nal_unit_header >> 9) & 0x3f;
224 
225 #if 0
226  LOG(VB_RECORD, LOG_INFO,
227  QString("nalTemperalId: %1, "
228  "nuhLayerId: %2, "
229  "nalUnitType: %3 %4")
231  .arg(m_nuhLayerId)
234 #endif
235 
236  if (m_nalUnitType == SPS_NUT ||
237  m_nalUnitType == VPS_NUT ||
239  {
240  /* This is a NAL we need to parse. We may have the body
241  * of it in the part of the stream past to us this call,
242  * or we may get the rest in subsequent calls to addBytes.
243  * Either way, we set m_haveUnfinishedNAL, so that we
244  * start filling the rbsp buffer
245  */
246  m_haveUnfinishedNAL = true;
247  }
248  } //found start code
249  }
250 
251  return startP - bytes;
252 }
253 
255 {
256  /*
257  3.1 access unit: A set of NAL units that are associated with
258  each other according to a specified classification rule, are
259  consecutive in decoding order, and contain exactly one coded
260  picture with nuh_layer_id equal to 0.
261  NOTE 1 – In addition to containing the video coding layer
262  (VCL) NAL units of the coded picture with
263  nuh_layer_id equal to 0, an access unit may also
264  contain non-VCL NAL units. The decoding of an
265  access unit with the decoding process specified in
266  clause 8 always results in a decoded picture with
267  nuh_layer_id equal to 0.
268  NOTE 2 – An access unit is defined differently in Annex F
269  and does not need to contain a coded picture with
270  nuh_layer_id equal to 0.
271  */
272 
273  /*
274  F.3.1 access unit: A set of NAL units that are associated with
275  each other according to a specified classification rule,
276  are consecutive in decoding order and contain at most one
277  coded picture with any specific value of nuh_layer_id.
278  */
279 
280  /*
281  F.7.4.2.4.4
282 
283  The first of any of the following NAL units preceding the first VCL
284  NAL unit firstVclNalUnitInAu and succeeding the last VCL NAL unit
285  preceding firstVclNalUnitInAu, if any, specifies the start of a new
286  access unit:
287 
288  – Access unit delimiter NAL unit (when present).
289  – VPS NAL unit (when present)
290  – SPS NAL unit (when present)
291  – PPS NAL unit (when present)
292  – Prefix SEI NAL unit (when present)
293  – NAL units with nal_unit_type in the range of
294  RSV_NVCL41..RSV_NVCL44 (when present)
295  – NAL units with nal_unit_type in the range of
296  UNSPEC48..UNSPEC55 (when present)
297 
298  When there is none of the above NAL units preceding
299  firstVclNalUnitInAu and succeeding the last VCL NAL unit
300  preceding firstVclNalUnitInAu, if any, firstVclNalUnitInAu
301  starts a new access unit.
302  */
303 
304 
305  /*
306  7.4.2.4.4
307 
308  An access unit consists of one coded picture with nuh_layer_id
309  equal to 0, zero or more VCL NAL units with nuh_layer_id greater
310  than 0 and zero or more non-VCL NAL units. The association of
311  VCL NAL units to coded pictures is described in clause
312  7.4.2.4.5.
313 
314  The first access unit in the bitstream starts with the first NAL
315  unit of the bitstream.
316 
317  Let firstBlPicNalUnit be the first VCL NAL unit of a coded
318  picture with nuh_layer_id equal to 0. The first of any of the
319  following NAL units preceding firstBlPicNalUnit and succeeding
320  the last VCL NAL unit preceding firstBlPicNalUnit, if any,
321  specifies the start of a new access unit:
322 
323  NOTE 1 – The last VCL NAL unit preceding firstBlPicNalUnit in
324  decoding order may have nuh_layer_id greater than 0.
325 
326  – access unit delimiter NAL unit with nuh_layer_id equal to 0
327  (when present),
328  – VPS NAL unit with nuh_layer_id equal to 0 (when present),
329  – SPS NAL unit with nuh_layer_id equal to 0 (when present),
330  – PPS NAL unit with nuh_layer_id equal to 0 (when present),
331  – Prefix SEI NAL unit with nuh_layer_id equal to 0 (when present),
332  – NAL units with nal_unit_type in the range of
333  RSV_NVCL41..RSV_NVCL44 with nuh_layer_id equal to 0 (when
334  present),
335  – NAL units with nal_unit_type in the range of
336  UNSPEC48..UNSPEC55 with nuh_layer_id equal to 0 (when
337  present).
338 
339  NOTE 2 – The first NAL unit preceding firstBlPicNalUnit and
340  succeeding the last VCL NAL unit preceding
341  firstBlPicNalUnit, if any, can only be one of the
342  above-listed NAL units.
343 
344  When there is none of the above NAL units preceding
345  firstBlPicNalUnit and succeeding the last VCL NAL preceding
346  firstBlPicNalUnit, if any, firstBlPicNalUnit starts a new access
347  unit.
348 
349  The order of the coded pictures and non-VCL NAL units within an
350  access unit shall obey the following constraints:
351 
352  – When an access unit delimiter NAL unit with nuh_layer_id equal
353  to 0 is present, it shall be the first NAL unit. There shall
354  be at most one access unit delimiter NAL unit with
355  nuh_layer_id equal to 0 in any access unit.
356  – When any VPS NAL units, SPS NAL units, PPS NAL units, prefix
357  SEI NAL units, NAL units with nal_unit_type in the range of
358  RSV_NVCL41..RSV_NVCL44, or NAL units with nal_unit_type in the
359  range of UNSPEC48..UNSPEC55 are present, they shall not follow
360  the last VCL NAL unit of the access unit.
361  – NAL units having nal_unit_type equal to FD_NUT or
362  SUFFIX_SEI_NUT or in the range of RSV_NVCL45..RSV_NVCL47 or
363  UNSPEC56..UNSPEC63 shall not precede the first VCL NAL unit of
364  the access unit.
365  – When an end of sequence NAL unit with nuh_layer_id equal to 0
366  is present, it shall be the last NAL unit among all NAL units
367  with nuh_layer_id equal to 0 in the access unit other than an
368  end of bitstream NAL unit (when present).
369  – When an end of bitstream NAL unit is present, it shall be the
370  last NAL unit in the access unit.
371 
372  NOTE 3 – Decoders conforming to profiles specified in Annex A do
373  not use NAL units with nuh_layer_id greater than 0,
374  e.g., access unit delimiter NAL units with nuh_layer_id
375  greater than 0, for access unit boundary detection,
376  except for identification of a NAL unit as a VCL or
377  non-VCL NAL unit.
378 
379  The structure of access units not containing any NAL units with
380  nal_unit_type equal to FD_NUT, VPS_NUT, SPS_NUT, PPS_NUT,
381  RSV_VCL_N10, RSV_VCL_R11, RSV_VCL_N12, RSV_VCL_R13, RSV_VCL_N14
382  or RSV_VCL_R15, RSV_IRAP_VCL22 or RSV_IRAP_VCL23, or in the
383  range of RSV_VCL24..RSV_VCL31, RSV_NVCL41..RSV_NVCL47 or
384  UNSPEC48..UNSPEC63 is shown in Figure 7-1.
385  */
386 
387  if (m_nuhLayerId == 0)
388  {
389  if (m_nalUnitType == AUD_NUT)
390  return true;
391 
392  if (m_nalUnitType == EOS_NUT)
393  {
394  // The next NAL is the start of a new AU
395  m_nextNALisAU = true;
396  m_seenEOS = true;
397  m_onAU = false;
398  m_noRaslOutputFlag = true;
399  return false;
400  }
401 
402  if (m_nextNALisAU)
403  {
404  m_nextNALisAU = false;
405  return true;
406  }
407  }
408 
409  if (m_nalUnitType == SUFFIX_SEI_NUT ||
412  {
413  m_auPending = false;
414  m_onAU = false;
415  return false;
416  }
417 
418  if (m_auPending || m_onAU)
419  return false;
420 
421  if (m_nalUnitType == VPS_NUT ||
422  m_nalUnitType == SPS_NUT ||
423  m_nalUnitType == PPS_NUT ||
427  {
428  return true;
429  }
430 
431 
432  /*
433  7.4.2.4.5 Order of VCL NAL units and association to coded pictures
434 
435  This clause specifies the order of VCL NAL units and association
436  to coded pictures.
437 
438  Each VCL NAL unit is part of a coded picture. The order of the
439  VCL NAL units within a coded picture is constrained as follows:
440 
441  A VCL NAL unit is the first VCL NAL unit of an access unit, when
442  all of the following conditions are true:
443  – first_slice_segment_in_pic_flag is equal to 1.
444 
445  and F.7.4.2.4.4 Common specifications for multi-layer extensions
446 
447  – At least one of the following conditions is true:
448  – The previous picture in decoding order belongs to a
449  different picture order count (POC) resetting period than
450  the picture containing the VCL NAL unit.
451  – PicOrderCntVal derived for the VCL NAL unit differs from the
452  PicOrderCntVal of the previous picture in decoding order.
453  */
455  {
456  return true;
457  }
458 
459  return false;
460 }
461 
462 
463 void HEVCParser::processRBSP(bool rbsp_complete)
464 {
465  GetBitContext gb;
466  init_get_bits(&gb, m_rbspBuffer, 8 * m_rbspIndex);
467 
468  if (m_nalUnitType == SPS_NUT ||
469  m_nalUnitType == VPS_NUT ||
471  {
472  /* Best wait until we have the whole thing */
473  if (!rbsp_complete)
474  return;
475 
476  if (!m_seenSPS)
478 
479  if (m_nalUnitType == SPS_NUT)
480  parseSPS(&gb);
481  else if (m_nalUnitType == VPS_NUT)
482  parseVPS(&gb);
483  else if (NALisVCL(m_nalUnitType))
485  }
486 
487  /* If we got this far, we managed to parse a sufficient
488  * prefix of the current NAL. We can go onto the next. */
489  m_haveUnfinishedNAL = false;
490 
491  if (newAU())
492  {
493  m_auPending = true;
495  }
496 
498  {
499  m_onAU = true;
500  m_auPending = false;
502 
503  m_onFrame = true;
505 
507  {
508  m_onKeyFrame = true;
510 
511  ++m_keyframecnt;
513  }
514 
515  LOG(VB_RECORD, LOG_DEBUG, LOC +
516  QString("On %2Frame").arg(m_onKeyFrame ? "Key" : ""));
517 
518  ++m_framecnt;
519  ++m_totalframecnt;
520  }
521 
522 }
523 
524 /*
525  7.4.4 Profile, tier and level semantics
526 
527  When the profile_tier_level( ) syntax structure is included in an
528  SPS or is the first profile_tier_level( ) syntax structure in a VPS,
529  and any of the syntax elements
530 
531  sub_layer_profile_space[ i ],
532  sub_layer_profile_idc[ i ],
533  sub_layer_profile_compatibility_flag[ i ][j ],
534  sub_layer_progressive_source_flag[ i ],
535  sub_layer_interlaced_source_ flag[ i ],
536  sub_layer_non_packed_constraint_flag[ i ],
537  sub_layer_frame_only_constraint_flag[ i ],
538  sub_layer_max_12bit_constraint_flag[ i ],
539  sub_layer_max_10bit_constraint_flag[ i ],
540  sub_layer_max_8bit_constraint_flag[ i ],
541  sub_layer_max_422chroma_constraint_flag[ i ],
542  sub_layer_max_420chroma_constraint_flag[ i ],
543  sub_layer_max_monochrome_ constraint_flag[ i ],
544  sub_layer_intra_constraint_flag[ i ],
545  sub_layer_one_picture_only_constraint_flag[ i ],
546  sub_layer_lower_bit_rate_constraint_flag[ i ],
547  sub_layer_max_14bit_constraint_flag,
548  sub_layer_reserved_zero_33bits[ i ],
549  sub_layer_reserved_zero_34bits[ i ],
550  sub_layer_reserved_zero_43bits[ i ],
551  sub_layer_inbld_flag[ i ],
552  sub_layer_reserved_zero_1bit[ i ] and
553  sub_layer_level_idc[ i ]
554 
555  is not present for any value of i in the range of 0 to
556  maxNumSubLayersMinus1 − 1, inclusive, in the profile_tier_level(
557  ) syntax structure, the value of the syntax element is inferred
558  as follows (in decreasing order of i values from
559  maxNumSubLayersMinus1 − 1 to 0):
560 
561  – If the value of i is equal to maxNumSubLayersMinus1, the value
562  of the syntax element is inferred to be equal to the value of
563  the corresponding syntax element prefixed with "general_" of
564  the same profile_tier_level( ) syntax structure.
565 
566  NOTE 9 – For example, in this case, if
567  sub_layer_profile_space[ i ] is not present, the
568  value is inferred to be equal to
569  general_profile_space of the same profile_tier_level(
570  ) syntax structure.
571 
572  – Otherwise (the value of i is less than maxNumSubLayersMinus1),
573  the value of the syntax element is inferred to be equal to the
574  corresponding syntax element with i being replaced with i + 1
575  of the same profile_tier_level( ) syntax structure.
576 
577  NOTE 10 – For example, in this case, if
578  sub_layer_profile_space[ i ] is not present, the
579  value is inferred to be equal to
580  sub_layer_profile_space[ i + 1 ] of the same
581  profile_tier_level( ) syntax structure.
582 */
583 bool HEVCParser::profileTierLevel(GetBitContext *gb,
584  bool profilePresentFlag,
585  int maxNumSubLayersMinus1)
586 {
587  int i = 0;
588 
589  if (profilePresentFlag)
590  {
591  get_bits(gb, 2); // general_profile_space u(2);
592  get_bits1(gb); // general_tier_flag u(1)
593  get_bits(gb, 5); // general_profile_idc u(5);
594  for (int j = 0; j < 32; ++j)
595  get_bits1(gb); // general_profile_compatibility_flag[j] u(1);
596 
597  /*
598  general_progressive_source_flag and
599  general_interlaced_source_flag are interpreted as follows:
600  – If general_progressive_source_flag is equal to 1 and
601  general_interlac ed_source_flag is equal to 0, the source
602  scan type of the pictures in the CVS should be interpreted
603  as progressive only.
604  – Otherwise, if general_progressive_source_flag is equal to
605  0 and general_interlaced_source_flag is equal to 1, the
606  source scan type of the pictures in the CVS should be
607  interpreted as interlaced only.
608  – Otherwise, if general_progressive_source_flag is equal to
609  0 and general_interlaced_source_flag is equal to 0, the
610  source scan type of the pictures in the CVS should be
611  interpreted as unknown or unspecified.
612  – Otherwise (general_progressive_source_flag is equal to 1
613  and general_interlaced_source_flag is equal to 1), the
614  source scan type of each picture in the CVS is indicated
615  at the picture level using the syntax element
616  source_scan_type in a picture timing SEI message.
617 
618  NOTE 1 – Decoders may ignore the values of
619  general_progressive_source_flag and
620  general_interlaced_source_flag for purposes other
621  than determining the value to be inferred for
622  frame_field_info_present_flag when
623  vui_parameters_present_flag is equal to 0, as there
624  are no other decoding process requirements
625  associated with the values of these
626  flags. Moreover, the actual source scan type of the
627  pictures is outside the scope of this Specification
628  and the method by which the encoder selects the
629  values of general_progressive_source_flag and
630  general_interlaced_source_flag is unspecified.
631  */
632  bool general_progressive_source_flag = get_bits1(gb); // u(1)
633  bool general_interlaced_source_flag = get_bits1(gb); // u(1)
634  if (!general_progressive_source_flag &&
635  general_interlaced_source_flag)
636  m_scanType = SCAN_t::INTERLACED;
637  else
638  m_scanType = SCAN_t::PROGRESSIVE;
639 
640  get_bits1(gb); // general_non_packed_constraint_flag u(1)
641  get_bits1(gb); // general_frame_only_constraint_flag u(1)
642 
643 #if 0
644  /* The number of bits in this syntax structure is not
645  * affected by this condition */
646  if (general_profile_idc == 4 ||
647  general_profile_compatibility_flag[4] ||
648  general_profile_idc == 5 ||
649  general_profile_compatibility_flag[5] ||
650  general_profile_idc == 6 ||
651  general_profile_compatibility_flag[6] ||
652  general_profile_idc == 7 ||
653  general_profile_compatibility_flag[7] ||
654  general_profile_idc == 8 ||
655  general_profile_compatibility_flag[8] ||
656  general_profile_idc == 9 ||
657  general_profile_compatibility_flag[9] ||
658  general_profile_idc == 10 ||
659  general_profile_compatibility_flag[10] ||
660  general_profile_idc == 11 ||
661  general_profile_compatibility_flag[11])
662  {
663  get_bits1(gb); //general_max_12bit_constraint_flag u(1)
664  get_bits1(gb); //general_max_10bit_constraint_flag u(1)
665  get_bits1(gb); //general_max_8bit_constraint_flag u(1)
666  get_bits1(gb); //general_max_422chroma_constraint_flag u(1)
667  get_bits1(gb); //general_max_420chroma_constraint_flag u(1)
668  get_bits1(gb); //general_max_monochrome_constraint_flag u(1)
669  get_bits1(gb); //general_intra_constraint_flag u(1)
670  get_bits1(gb); //general_one_picture_only_constraint_flag u(1)
671  get_bits1(gb); //general_lower_bit_rate_constraint_flag u(1)
672 
673  if (general_profile_idc == 5 ||
674  general_profile_compatibility_flag[5] ||
675  general_profile_idc == 9 ||
676  general_profile_compatibility_flag[9] ||
677  general_profile_idc == 10 ||
678  general_profile_compatibility_flag[10] ||
679  general_profile_idc == 11 ||
680  general_profile_compatibility_flag[11])
681  {
682  get_bits1(gb); //general_max_14bit_constraint_flag u(1)
683  // general_reserved_zero_33bits
684  skip_bits(gb, 16); // bits[0..15]
685  skip_bits(gb, 16); // bits[16..31]
686  skip_bits(gb, 1); // bits[32]
687  }
688  else
689  {
690  // general_reserved_zero_34bits u(34);
691  skip_bits(gb, 16); // bits[0..15]
692  skip_bits(gb, 16); // bits[16..31]
693  skip_bits(gb, 2); // bits[32..33]
694  }
695  }
696  else if (general_profile_idc == 2 ||
697  general_profile_compatibility_flag[2])
698  {
699  get_bits(gb, 7); // general_reserved_zero_7bits u(7);
700  get_bits1(gb); //general_one_picture_only_constraint_flag u(1)
701  // general_reserved_zero_35bits u(35);
702  skip_bits(gb, 16); // bits[0..15]
703  skip_bits(gb, 16); // bits[16..31]
704  skip_bits(gb, 3); // bits[32..34]
705  }
706  else
707 #endif
708  {
709  // general_reserved_zero_43bits
710  skip_bits(gb, 16); // bits[0..15]
711  skip_bits(gb, 16); // bits[16..31]
712  skip_bits(gb, 11); // bits[32..42]
713  }
714 
715 #if 0
716  /* The number of bits in this syntax structure is not
717  * affected by this condition */
718  if (general_profile_idc == 1 ||
719  general_profile_compatibility_flag[1] ||
720  general_profile_idc == 2 ||
721  general_profile_compatibility_flag[2] ||
722  general_profile_idc == 3 ||
723  general_profile_compatibility_flag[3] ||
724  general_profile_idc == 4 ||
725  general_profile_compatibility_flag[4] ||
726  general_profile_idc == 5 ||
727  general_profile_compatibility_flag[5] ||
728  general_profile_idc == 9 ||
729  general_profile_compatibility_flag[9] ||
730  general_profile_idc == 11 ||
731  general_profile_compatibility_flag[11])
732  get_bits1(gb); //general_inbld_flag u(1)
733  else
734 #endif
735  get_bits1(gb); //general_reserved_zero_bit u(1)
736  }
737 
738  get_bits(gb, 8); // general_level_idc u(8);
739 
740  /*
741  sub_layer_profile_present_flag[i] equal to 1, specifies that
742  profile information is present in the profile_tier_level()
743  syntax structure for the sub-layer representation with
744  TemporalId equal to i. sub_layer_profile_present_flag[i]
745  equal to 0 specifies that profile information is not present in
746  the profile_tier_level() syntax structure for the sub-layer
747  representation with TemporalId equal to i. When
748  profilePresentFlag is equal to 0,
749  sub_layer_profile_present_flag[i] shall be equal to 0.
750  */
751 
752  std::vector<bool> sub_layer_profile_present_flag;
753  std::vector<bool> sub_layer_level_present_flag;
754  for (i = 0; i < maxNumSubLayersMinus1; ++i)
755  {
756  sub_layer_profile_present_flag.push_back(get_bits1(gb)); // u(1)
757  sub_layer_level_present_flag.push_back(get_bits1(gb)); // u(1)
758  }
759 
760  if (maxNumSubLayersMinus1 > 0)
761  {
762  for (i = maxNumSubLayersMinus1; i < 8; ++i)
763  get_bits(gb, 2); // reserved_zero_2bits[i] u(2);
764  }
765 
766  for (i = 0; i < maxNumSubLayersMinus1; ++i)
767  {
768  if (sub_layer_profile_present_flag[i])
769  {
770  get_bits(gb, 2); // sub_layer_profile_space[i] u(2);
771  get_bits1(gb); //sub_layer_tier_flag[i] u(1)
772  get_bits(gb, 5); // sub_layer_profile_idc[i] u(5);
773 
774  for (int j = 0; j < 32; ++j)
775  get_bits1(gb); //sub_layer_profile_compatibility_flag[i][j] u(1)
776 
777  get_bits1(gb); //sub_layer_progressive_source_flag[i] u(1)
778  get_bits1(gb); //sub_layer_interlaced_source_flag[i] u(1)
779  get_bits1(gb); //sub_layer_non_packed_constraint_flag[i] u(1)
780  get_bits1(gb); //sub_layer_frame_only_constraint_flag[i] u(1)
781 
782 #if 0
783  /* The number of bits in this syntax structure is not
784  * affected by this condition */
785  if (sub_layer_profile_idc[i] == 4 ||
786  sub_layer_profile_compatibility_flag[i][4] ||
787  sub_layer_profile_idc[i] == 5 ||
788  sub_layer_profile_compatibility_flag[i][5] ||
789  sub_layer_profile_idc[i] == 6 ||
790  sub_layer_profile_compatibility_flag[i][6] ||
791  sub_layer_profile_idc[i] == 7 ||
792  sub_layer_profile_compatibility_flag[i][7] ||
793  sub_layer_profile_idc[i] == 8 ||
794  sub_layer_profile_compatibility_flag[i][8] ||
795  sub_layer_profile_idc[i] == 9 ||
796  sub_layer_profile_compatibility_flag[i][9] ||
797  sub_layer_profile_idc[i] == 10 ||
798  sub_layer_profile_compatibility_flag[i][10] ||
799  sub_layer_profile_idc[i] == 11 ||
800  sub_layer_profile_compatibility_flag[i][11])
801  {
802  get_bits1(gb); //sub_layer_max_12bit_constraint_flag[i] u(1)
803  get_bits1(gb); //sub_layer_max_10bit_constraint_flag[i] u(1)
804  get_bits1(gb); //sub_layer_max_8bit_constraint_flag[i] u(1)
805  get_bits1(gb); //sub_layer_max_422chroma_constraint_flag[i] u(1)
806  get_bits1(gb); //sub_layer_max_420chroma_constraint_flag[i] u(1)
807  get_bits1(gb); //sub_layer_max_monochrome_constraint_flag[i] u(1)
808  get_bits1(gb); //sub_layer_intra_constraint_flag[i] u(1)
809  get_bits1(gb); //sub_layer_one_picture_only_constraint_flag[i] u(1)
810  get_bits1(gb); //sub_layer_lower_bit_rate_constraint_flag[i] u(1)
811  if (sub_layer_profile_idc[i] == 5 ||
812  sub_layer_profile_compatibility_flag[i][5] ||
813  sub_layer_profile_idc[i] == 9 ||
814  sub_layer_profile_compatibility_flag[i][9] ||
815  sub_layer_profile_idc[i] == 10 ||
816  sub_layer_profile_compatibility_flag[i][10] ||
817  sub_layer_profile_idc[i] == 11 ||
818  sub_layer_profile_compatibility_flag[i][11])
819  {
820  get_bits1(gb); //sub_layer_max_14bit_constraint_flag[i] u(1)
821  // sub_layer_reserved_zero_33bits[i] u(33);
822  skip_bits(gb, 16); // bits[0..15]
823  skip_bits(gb, 16); // bits[16..31]
824  skip_bits(gb, 1); // bits[32..32]
825  }
826  else
827  {
828  // sub_layer_reserved_zero_34bits[i] u(34);
829  skip_bits(gb, 16); // bits[0..15]
830  skip_bits(gb, 16); // bits[16..31]
831  skip_bits(gb, 2); // bits[32..33]
832  }
833  }
834  else if(sub_layer_profile_idc[i] == 2 ||
835  sub_layer_profile_compatibility_flag[i][2])
836  {
837  get_bits(gb, 7); // sub_layer_reserved_zero_7bits[i] u(7);
838  get_bits1(gb); //sub_layer_one_picture_only_constraint_flag[i] u(1)
839  // sub_layer_reserved_zero_35bits[i] u(35);
840  skip_bits(gb, 16); // bits[0..15]
841  skip_bits(gb, 16); // bits[16..31]
842  skip_bits(gb, 3); // bits[32..34]
843  }
844  else
845 #endif
846  {
847  // sub_layer_reserved_zero_43bits[i] u(43);
848  skip_bits(gb, 16); // bits[0..15]
849  skip_bits(gb, 16); // bits[16..31]
850  skip_bits(gb, 12); // bits[32..43]
851  }
852 
853 #if 0
854  /* The number of bits in this syntax structure is not
855  * affected by this condition */
856  if (sub_layer_profile_idc[i] == 1 ||
857  sub_layer_profile_compatibility_flag[i][1] ||
858  sub_layer_profile_idc[i] == 2 ||
859  sub_layer_profile_compatibility_flag[i][2] ||
860  sub_layer_profile_idc[i] == 3 ||
861  sub_layer_profile_compatibility_flag[i][3] ||
862  sub_layer_profile_idc[i] == 4 ||
863  sub_layer_profile_compatibility_flag[i][4] ||
864  sub_layer_profile_idc[i] == 5 ||
865  sub_layer_profile_compatibility_flag[i][5] ||
866  sub_layer_profile_idc[i] == 9 ||
867  sub_layer_profile_compatibility_flag[i][9] ||
868  sub_layer_profile_idc[i] == 11 ||
869  sub_layer_profile_compatibility_flag[i][11])
870 
871  get_bits1(gb); //sub_layer_inbld_flag[i] u(1)
872  else
873 #endif
874  get_bits1(gb); //sub_layer_reserved_zero_bit[i] u(1)
875  }
876 
877  if (sub_layer_level_present_flag[i])
878  get_bits(gb, 8); // sub_layer_level_idc[i] u(8);
879  }
880 
881  return true;
882 }
883 
884 static bool getScalingListParams(uint8_t sizeId, uint8_t matrixId,
885  HEVCParser::ScalingList & dest_scaling_list,
886  uint8_t* &sl, uint8_t &size,
887  std::vector<int16_t> &scaling_list_dc_coef_minus8)
888 {
889  switch (sizeId)
890  {
892  sl = dest_scaling_list.scaling_lists_4x4[matrixId].data();
893  size = dest_scaling_list.scaling_lists_4x4[matrixId].size();;
894  break;
896  sl = dest_scaling_list.scaling_lists_8x8[matrixId].data();
897  size = dest_scaling_list.scaling_lists_8x8[matrixId].size();
898  break;
900  sl = dest_scaling_list.scaling_lists_16x16[matrixId].data();
901  size = dest_scaling_list.scaling_lists_16x16[matrixId].size();
902  scaling_list_dc_coef_minus8 =
903  dest_scaling_list.scaling_list_dc_coef_minus8_16x16;
904  break;
906  sl = dest_scaling_list.scaling_lists_32x32[matrixId].data();
907  size = dest_scaling_list.scaling_lists_32x32[matrixId].size();
908  scaling_list_dc_coef_minus8 =
909  dest_scaling_list.scaling_list_dc_coef_minus8_32x32;
910  break;
911  default:
912  return false;
913  }
914  return true;
915 }
916 
917 /*
918  7.3.4 Scaling list data syntax
919  We dont' need any of this data. We just need to get past the bits.
920 */
921 static bool scalingListData(GetBitContext * gb,
922  HEVCParser::ScalingList & dest_scaling_list,
923  bool use_default)
924 {
925  uint8_t sizeId = 0;
926  uint8_t size = 0;
927 
928  for (sizeId = 0; sizeId < 4; ++sizeId)
929  {
930  for (uint matrixId = 0; matrixId < ((sizeId == 3) ? 2 : 6); ++matrixId)
931  {
932  std::vector<int16_t> scaling_list_dc_coef_minus8 {};
933  uint8_t *sl = nullptr;
934 
935  if (!getScalingListParams(sizeId, matrixId,
936  dest_scaling_list, sl, size,
937  scaling_list_dc_coef_minus8))
938  {
939  LOG(VB_RECORD, LOG_WARNING, LOC +
940  QString("Failed to process scaling list params"));
941  return false;
942  }
943 
944  /* use_default_scaling_matrices forcefully which means,
945  * sps_scaling_list_enabled_flag=TRUE,
946  * sps_scaling_list_data_present_flag=FALSE,
947  * pps_scaling_list_data_present_falg=FALSE */
948  if (use_default)
949  {
950 #if 0 // Unneeded
951  if (!getDefaultScalingLists(&sl, sizeId, matrixId))
952  {
953  LOG(VB_RECORD, LOG_WARNING, LOC +
954  QString("Failed to process default scaling lists"));
955  return false;
956  }
957 
958  if (sizeId > 1)
959  /* Inferring the value of scaling_list_dc_coef_minus8 */
960  scaling_list_dc_coef_minus8[matrixId] = 8;
961 #endif
962  }
963  else
964  {
965  if (!get_bits1(gb)) // scaling_list_pred_mode_flag u(1)
966  {
967  get_ue_golomb(gb); // scaling_list_pred_matrix_id_delta ue(v)
968 #if 0 // Unneeded
969  if (!scaling_list_pred_matrix_id_delta)
970  {
971  if (!getDefaultScalingLists(&sl, sizeId, matrixId))
972  {
973  LOG(VB_RECORD, LOG_WARNING, LOC +
974  QString("Failed to process default "
975  "scaling list"));
976  return false;
977  }
978 
979  /* Inferring the value of scaling_list_dc_coef_minus8 */
980  if (sizeId > 1)
981  scaling_list_dc_coef_minus8[matrixId] = 8;
982  }
983  else
984  {
985  uint8_t *temp_sl;
986  uint8_t refMatrixId = matrixId -
987  scaling_list_pred_matrix_id_delta;
988  if (!getScalingListParams(dest_scaling_list, sizeId,
989  refMatrixId, &temp_sl,
990  NULL, {}))
991  {
992  LOG(VB_RECORD, LOG_WARNING, LOC +
993  QString("Failed to process scaling "
994  "list params"));
995  return false;
996  }
997 
998  for (i = 0; i < size; ++i)
999  sl[i] = temp_sl[i];
1000 
1001  /* Inferring the value of scaling_list_dc_coef_minus8 */
1002  if (sizeId > 1)
1003  scaling_list_dc_coef_minus8[matrixId] =
1004  scaling_list_dc_coef_minus8[refMatrixId];
1005  }
1006 #endif
1007  }
1008  else
1009  {
1010 // uint nextCoef = 8;
1011 
1012  if (sizeId > 1)
1013  {
1014 // scaling_list_dc_coef_minus8[matrixId] =
1015  get_se_golomb(gb); // se(v)
1016 #if 0 // Unneeded
1017  if (scaling_list_dc_coef_minus8[matrixId] < -7 ||
1018  247 < scaling_list_dc_coef_minus8[matrixId])
1019  {
1020  LOG(VB_RECORD, LOG_WARNING, LOC +
1021  QString("scaling_list_dc_coef_minus8[%1] %2 "
1022  "outside -7 and 247")
1023  .arg(matrixId)
1024  .arg(scaling_list_dc_coef_minus8[matrixId]));
1025  }
1026  nextCoef = scaling_list_dc_coef_minus8[matrixId] + 8;
1027 #endif
1028  }
1029 
1030  for (uint8_t i = 0; i < size; ++i)
1031  {
1032  get_se_golomb(gb); // scaling_list_delta_coef se(v)
1033 #if 0 // Unneeded
1034  if (scaling_list_delta_coef < -128 ||
1035  scaling_list_delta_coef > 127)
1036  {
1037  LOG(VB_RECORD, LOG_WARNING, LOC +
1038  QString("scaling_list_delta_coef %1 "
1039  "outside -128 and 127")
1040  .arg(scaling_list_delta_coef));
1041  }
1042  nextCoef = (nextCoef + scaling_list_delta_coef) & 0xff;
1043  sl[i] = nextCoef;
1044 #endif
1045  }
1046 
1047  }
1048  }
1049  }
1050  }
1051 
1052  return true;
1053 }
1054 
1055 /*
1056  7.3.7 Short-term reference picture set syntax
1057  We don't any of this data, but we have to get past the bits
1058 */
1059 static bool shortTermRefPicSet(GetBitContext * gb, int stRPSIdx,
1060  int num_short_term_ref_pic_sets,
1061  std::array<HEVCParser::ShortTermRefPicSet,65> & stRPS,
1062  uint8_t max_dec_pic_buffering_minus1)
1063 {
1064  std::array<bool,16> use_delta_flag { false };
1065  std::array<bool,16> used_by_curr_pic_flag { false };
1066  std::array<uint32_t,16> delta_poc_s0_minus1 { 0 };
1067  std::array<uint32_t,16> delta_poc_s1_minus1 { 0 };
1068  uint i = 0;
1069 
1070  /* 7.4.8 inter_ref_pic_set_prediction_flag equal to 1 specifies
1071  that the stRPSIdx-th candidate short-term RPS is predicted from
1072  another candidate short-term RPS, which is referred to as the
1073  source candidate short-term RPS. When
1074  inter_ref_pic_set_prediction_flag is not present, it is
1075  inferred to be equal to 0.
1076  */
1077  bool inter_ref_pic_set_prediction_flag = (stRPSIdx != 0) ?
1078  get_bits1(gb) : false; // u(1)
1079 
1080  if (inter_ref_pic_set_prediction_flag)
1081  {
1082  int16_t deltaRPS = 0;
1083 
1084  /*
1085  delta_idx_minus1 plus 1 specifies the difference between the
1086  value of stRPSIdx and the index, into the list of the
1087  candidate short-term RPSs specified in the SPS, of the
1088  source candidate short-term RPS. The value of
1089  delta_idx_minus1 shall be in the range of 0 to stRPSIdx − 1,
1090  inclusive. When delta_idx_minus1 is not present, it is
1091  inferred to be equal to 0.
1092  */
1093  int delta_idx_minus1 = (stRPSIdx == num_short_term_ref_pic_sets) ?
1094  get_ue_golomb(gb) : 0; // ue(v)
1095  if (delta_idx_minus1 > stRPSIdx - 1)
1096  LOG(VB_RECORD, LOG_WARNING, LOC +
1097  QString("Invalid delta_idx_minus1? %1").arg(delta_idx_minus1));
1098 
1099  get_bits1(gb); // delta_rps_sign; u(1)
1100  if (get_ue_golomb(gb) > 32767) // abs_delta_rps_minus1; ue(v)
1101  LOG(VB_RECORD, LOG_WARNING, LOC +
1102  QString("Invalid abs_delta_rps_minus1"));
1103 
1104  /*
1105  The variable RefRPSIdx is derived as follows:
1106  RefRPSIdx = stRPSIdx − ( delta_idx_minus1 + 1)
1107  */
1108  int RefRPSIdx = stRPSIdx - (delta_idx_minus1 + 1);
1109  HEVCParser::ShortTermRefPicSet *RefRPS = &stRPS[RefRPSIdx];
1110 
1111  for (int j = 0; j <= RefRPS->NumDeltaPocs; ++j)
1112  {
1113  /*
1114  use_delta_flag[ j ] equal to 1 specifies that the
1115  j-th entry in the source candidate short-term RPS
1116  is included in the stRPSIdx-th candidate short-term
1117  RPS. use_delta_flag[ j ] equal to 0 specifies that
1118  the j-th entry in the source candidate short-term
1119  RPS is not included in the stRPSIdx-th candidate
1120  short-term RPS. When use_delta_flag[ j ] is not
1121  present, its value is inferred to be equal to 1.
1122  */
1123  bool val = get_bits1(gb);
1124  use_delta_flag[j] = used_by_curr_pic_flag[j] ? val : true;
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)get_ue_golomb(gb), // ue(v)
1192  max_dec_pic_buffering_minus1);
1193  stRPS[stRPSIdx].NumPositivePics = std::min((uint8_t)get_ue_golomb(gb), // 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] = get_ue_golomb(gb); // ue(v)
1199  get_bits1(gb); // 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] = get_ue_golomb(gb); // ue(v)
1210  get_bits1(gb); // 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 */
1231 bool HEVCParser::parseSliceSegmentLayer(GetBitContext *gb)
1232 {
1233  if (!m_seenSPS)
1234  return false;
1235 
1237 #if 0
1238  slice_segment_data(gb);
1239  rbsp_slice_segment_trailing_bits(gb);
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 
1252  m_firstSliceSegmentInPicFlag = get_bits1(gb);
1253 
1255  {
1256  get_bits1(gb); // no_output_of_prior_pics_flag; u(1)
1257  }
1258 
1259  int pps_id = get_ue_golomb(gb); // 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 = get_bits1(gb); // 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  get_bits(gb, 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  get_bits1(gb); // slice_reserved_flag[i]; // u(1)
1301  }
1302  get_ue_golomb(gb); // slice_type; // ue(v)
1303  if (pps->output_flag_present_flag)
1304  {
1305  get_bits1(gb); // pic_output_flag; // u(1)
1306  }
1307  if (sps->separate_colour_plane_flag)
1308  {
1309  get_bits(gb, 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  get_bits(gb, 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")
1404  .arg(slice_pic_order_cnt_lsb));
1405 
1406  m_noRaslOutputFlag = false;
1407 
1408 #if 0 // We dont' need the rest
1409  get_bit1(gb); // 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  get_bits(gb, ); // 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  get_ue_golomb(gb); // num_long_term_sps; // ue(v)
1423  }
1424  get_ue_golomb(gb); // 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  get_bits(gb, ); // lt_idx_sps[i]; // u(v)
1431  }
1432  else
1433  {
1434  poc_lsb_lt[i] =
1435  get_bits(gb, sps->Log2MaxPicOrderCntLsb); // u(v)
1436  get_bit1(gb); // used_by_curr_pic_lt_flag[i]; // u(1)
1437  }
1438  get_bit1(gb); // delta_poc_msb_present_flag[i]; // u(1)
1439  if (delta_poc_msb_present_flag[i])
1440  {
1441  get_ue_golomb(gb); // delta_poc_msb_cycle_lt[i]; // ue(v)
1442  }
1443  }
1444  }
1445  if (sps_temporal_mvp_enabled_flag)
1446  {
1447  get_bit1(gb); // 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  get_bit1(gb); // slice_sao_luma_flag; // u(1)
1455  if (ChromaArrayType != 0)
1456  {
1457  get_bit1(gb); // slice_sao_chroma_flag; // u(1)
1458  }
1459  }
1460  if (slice_type == P || slice_type == B)
1461  {
1462  get_bit1(gb); // num_ref_idx_active_override_flag; // u(1)
1463  if (num_ref_idx_active_override_flag)
1464  {
1465  get_ue_golomb(gb); // num_ref_idx_l0_active_minus1; // ue(v)
1466  if (slice_type == B)
1467  {
1468  get_ue_golomb(gb); // 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  get_bit1(gb); // mvd_l1_zero_flag; // u(1)
1477  }
1478  }
1479  if (cabac_init_present_flag)
1480  {
1481  get_bit1(gb); // cabac_init_flag; // u(1)
1482  }
1483  if (slice_temporal_mvp_enabled_flag)
1484  {
1485  if (slice_type == B)
1486  {
1487  get_bit1(gb); // 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  get_ue_golomb(gb); // 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  get_ue_golomb(gb); // five_minus_max_num_merge_cand; // ue(v)
1503  if (motion_vector_resolution_control_idc == 2)
1504  {
1505  get_bit1(gb); // use_integer_mv_flag; // u(1)
1506  }
1507  }
1508  get_se_golomb(gb); // slice_qp_delta; //se(v)
1509  if (pps_slice_chroma_qp_offsets_present_flag)
1510  {
1511  get_se_golomb(gb); // slice_cb_qp_offset; //se(v)
1512  get_se_golomb(gb); // slice_cr_qp_offset; //se(v)
1513  }
1514  if (pps_slice_act_qp_offsets_present_flag)
1515  {
1516  get_se_golomb(gb); // slice_act_y_qp_offset; //se(v)
1517  get_se_golomb(gb); // slice_act_cb_qp_offset; //se(v)
1518  get_se_golomb(gb); // slice_act_cr_qp_offset; //se(v)
1519  }
1520  if (chroma_qp_offset_list_enabled_flag)
1521  {
1522  get_bit1(gb); // cu_chroma_qp_offset_enabled_flag; // u(1)
1523  }
1524  if (deblocking_filter_override_enabled_flag)
1525  {
1526  get_bit1(gb); // deblocking_filter_override_flag; // u(1)
1527  }
1528  if (deblocking_filter_override_flag)
1529  {
1530  get_bit1(gb); // slice_deblocking_filter_disabled_flag; // u(1)
1531  if (!slice_deblocking_filter_disabled_flag)
1532  {
1533  get_se_golomb(gb); // slice_beta_offset_div2; //se(v)
1534  get_se_golomb(gb); // 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  get_bit1(gb); // 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  get_ue_golomb(gb); // num_entry_point_offsets; // ue(v)
1549  if (num_entry_point_offsets > 0)
1550  {
1551  get_ue_golomb(gb); // offset_len_minus1; // ue(v)
1552  for (i = 0; i < num_entry_point_offsets; ++i)
1553  {
1554  get_bits(gb, ); // entry_point_offset_minus1[i]; // u(v)
1555  }
1556  }
1557  }
1558  if (slice_segment_header_extension_present_flag)
1559  {
1560  get_ue_golomb(gb); // 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 */
1575 bool HEVCParser::parseSPS(GetBitContext *gb)
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 = get_bits(gb, 4); // sps_video_parameter_set_id u(4)
1586 
1587  uint ext_or_max_sub_layers_minus1 = get_bits(gb, 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  get_bits1(gb); // sps_temporal_id_nesting_flag u(1)
1627  if (!profileTierLevel(gb, 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 = get_ue_golomb(gb); // sps_seq_parameter_set_id ue(v);
1636  SPS* sps = &m_sps[sps_id];
1637 
1638  if (MultiLayerExtSpsFlag)
1639  {
1640  if (get_bits1(gb)) // update_rep_format_flag u(1)
1641  {
1642  get_bits(gb, 8); // sps_rep_format_idx
1643  }
1644  }
1645  else
1646  {
1647  m_chromaFormatIdc = get_ue_golomb(gb); // ue(v);
1648  if (m_chromaFormatIdc == 3)
1649  m_separateColourPlaneFlag = get_bits1(gb); // 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 = get_ue_golomb(gb); // 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 = get_ue_golomb(gb); // pic_height_in_luma_samples ue(v);
1668 
1669  if (get_bits1(gb)) //conformance_window_flag u(1)
1670  {
1671  m_frameCropLeftOffset = get_ue_golomb(gb); // ue(v);
1672  m_frameCropRightOffset = get_ue_golomb(gb); // ue(v);
1673  m_frameCropTopOffset = get_ue_golomb(gb); // ue(v);
1674  m_frameCropBottomOffset = get_ue_golomb(gb); // ue(v);
1675  }
1676 
1677  get_ue_golomb(gb); // bit_depth_luma_minus8 ue(v);
1678  get_ue_golomb(gb); // 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 = get_ue_golomb(gb) + 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")
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 = get_bits1(gb); // 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] = get_ue_golomb(gb); // 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  get_ue_golomb(gb); // sps_max_num_reorder_pics[i] ue(v);
1718  get_ue_golomb(gb); // 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 = get_ue_golomb(gb) + 3; // _minus3 ue(v);
1739  sps->log2_diff_max_min_luma_coding_block_size = get_ue_golomb(gb); // ue(v);
1740  get_ue_golomb(gb); // log2_min_luma_transform_block_size_minus2 ue(v);
1741  get_ue_golomb(gb); // log2_diff_max_min_luma_transform_block_size ue(v);
1742  get_ue_golomb(gb); // max_transform_hierarchy_depth_inter ue(v);
1743  get_ue_golomb(gb); // max_transform_hierarchy_depth_intra ue(v);
1744 
1745  if (get_bits1(gb)) // 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  get_bits1(gb) : false; // u(1)
1753  if (sps_infer_scaling_list_flag)
1754  {
1755  get_bits(gb, 6); // sps_scaling_list_ref_layer_id; u(6)
1756  }
1757  else
1758  {
1759  if (get_bits1(gb)) // sps_scaling_list_data_present_flag;
1760  scalingListData(gb, scaling_list, false);
1761  }
1762  }
1763 
1764  get_bits1(gb); // amp_enabled_flag u(1)
1765  get_bits1(gb); // sample_adaptive_offset_enabled_flag u(1)
1766  if (get_bits1(gb)) // pcm_enabled_flag u(1)
1767  {
1768  get_bits(gb, 4); // pcm_sample_bit_depth_luma_minus1 u(4);
1769  get_bits(gb, 4); // pcm_sample_bit_depth_chroma_minus1 u(4);
1770  get_ue_golomb(gb); // log2_min_pcm_luma_coding_block_size_minus3 ue(v);
1771  get_ue_golomb(gb); // log2_diff_max_min_pcm_luma_coding_block_size ue(v);
1772  get_bits1(gb); // pcm_loop_filter_disabled_flag u(1)
1773  }
1774 
1775  uint num_short_term_ref_pic_sets = get_ue_golomb(gb); // 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(gb, 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 (get_bits1(gb)) // long_term_ref_pics_present_flag u(1)
1794  {
1795  uint num_long_term_ref_pics_sps = get_ue_golomb(gb); // 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] = get_bits(gb, 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  get_bits1(gb); // used_by_curr_pic_lt_sps_flag[i] u(1)
1809  }
1810  }
1811 
1812  get_bits1(gb); //sps_temporal_mvp_enabled_flag u(1)
1813  get_bits1(gb); //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 (get_bits1(gb)) // vui_parameters_present_flag
1823  vui_parameters(gb, true);
1824 
1825  return true;
1826 }
1827 
1828 
1829 /*
1830  F.7.3.2.1 Video parameter set RBSP
1831 */
1832 bool HEVCParser::parseVPS(GetBitContext *gb)
1833 {
1834  uint i = 0;
1835 
1836  uint8_t vps_id = get_bits(gb, 4); // vps_video_parameter_set_id u(4)
1837  get_bits1(gb); // vps_base_layer_internal_flag u(1)
1838  get_bits1(gb); // vps_base_layer_available_flag u(1)
1839  get_bits(gb, 6); // vps_max_layers_minus1 u(6)
1840  uint8_t max_sub_layers_minus1 = get_bits(gb, 3); // u(3)
1841  get_bits1(gb); // vps_temporal_id_nesting_flag u(1)
1842 
1843  /* uint16_t check = */ get_bits(gb, 16); // vps_reserved_0xffff_16bits u(16)
1844 
1845  m_vps[vps_id].max_sub_layers = max_sub_layers_minus1 + 1;
1846  if (!profileTierLevel(gb, 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 = get_bits1(gb); // 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  get_ue_golomb(gb); // vps_max_dec_pic_buffering_minus1[i]; ue(v)
1859  get_ue_golomb(gb); // vps_max_num_reorder_pics[i]; ue(v)
1860  get_ue_golomb(gb); // 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 = get_bits(gb, 6); // u(6)
1882  uint vps_num_layer_sets_minus1 = get_ue_golomb(gb); // 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  get_bits1(gb); // layer_id_included_flag[i][j] u(1)
1888  }
1889  }
1890 
1891  if (get_bits1(gb)) // vps_timing_info_present_flag u(1)
1892  {
1893  /*
1894  vps_num_units_in_tick is the number of time units of a clock
1895  operating at the frequency vps_time_scale Hz that
1896  corresponds to one increment (called a clock tick) of a
1897  clock tick counter. The value of vps_num_units_in_tick shall
1898  be greater than 0. A clock tick, in units of seconds, is
1899  equal to the quotient of vps_num_units_in_tick divided by
1900  vps_time_scale. For example, when the picture rate of a
1901  video signal is 25 Hz, vps_time_scale may be equal to 27 000
1902  000 and vps_num_units_in_tick may be equal to 1 080 000, and
1903  consequently a clock tick may be 0.04 seconds.
1904  */
1905  m_unitsInTick = get_bits_long(gb, 32); // vps_num_units_in_tick
1906 
1907  /*
1908  vps_time_scale is the number of time units that pass in one
1909  second. For example, a time coordinate system that measures
1910  time using a 27 MHz clock has a vps_time_scale of 27 000
1911  000. The value of vps_time_scale shall be greater than 0.
1912  */
1913  m_timeScale = get_bits_long(gb, 32); // vps_time_scale
1914 
1915  if (get_bits1(gb)) // vps_poc_proportional_to_timing_flag) u(1)
1916  get_ue_golomb_long(gb); // vps_num_ticks_poc_diff_one_minus1 ue(v)
1917 
1918  LOG(VB_RECORD, LOG_DEBUG,
1919  QString("VUI unitsInTick %1 timeScale %2 fixedRate %3")
1920  .arg(m_unitsInTick)
1921  .arg(m_timeScale)
1922  .arg(m_fixedRate));
1923 
1924 #if 0 // We don't need the rest.
1925  uint vps_num_hrd_parameters = get_ue_golomb(gb); // ue(v)
1926  for (i = 0; i < vps_num_hrd_parameters; ++i)
1927  {
1928  get_ue_golomb(gb); // hrd_layer_set_idx[i] ue(v)
1929  if (i > 0)
1930  cprms_present_flag[i] = get_bits1(gb); // u(1)
1931  hrd_parameters(cprms_present_flag[i], max_sub_layers_minus1);
1932  }
1933 #endif
1934  }
1935 
1936 #if 0 // We don't need the rest.
1937  bool vps_extension_flag = get_bits(1); // u(1)
1938  if (vps_extension_flag)
1939  {
1940  while (!byte_aligned())
1941  {
1942  get_bits1(gb); // vps_extension_alignment_bit_equal_to_one u(1)
1943  }
1944  vps_extension();
1945  vps_extension2_flag = get_bits1(gb); // u(1)
1946  if (vps_extension2_flag)
1947  {
1948  while (more_rbsp_data())
1949  get_bits1(gb); // vps_extension_data_flag u(1)
1950  }
1951  }
1952  rbsp_trailing_bits();
1953 #endif
1954 
1955  return true;
1956 }
1957 
1958 /* 7.3.2.3.1 General picture parameter set RBSP syntax */
1959 bool HEVCParser::parsePPS(GetBitContext *gb)
1960 {
1961  uint pps_id = get_ue_golomb(gb); // pps_pic_parameter_set_id ue(v)
1962  PPS* pps = &m_pps[pps_id];
1963 
1964  pps->sps_id = get_ue_golomb(gb); // pps_seq_parameter_set_id; ue(v)
1965  pps->dependent_slice_segments_enabled_flag = get_bits1(gb); // u(1)
1966 
1967  pps->output_flag_present_flag = get_bits1(gb); // u(1)
1968  pps->num_extra_slice_header_bits = get_bits(gb, 3); // u(3)
1969 
1970 #if 0 // Rest not needed
1971  sign_data_hiding_enabled_flag;
1972  cabac_init_present_flag;
1973  num_ref_idx_l0_default_active_minus1;
1974  num_ref_idx_l1_default_active_minus1;
1975  init_qp_minus26;
1976  constrained_intra_pred_flag;
1977  transform_skip_enabled_flag;
1978  cu_qp_delta_enabled_flag;
1979  if( cu_qp_delta_enabled_flag )
1980  diff_cu_qp_delta_depth;
1981  pps_cb_qp_offset;
1982  pps_cr_qp_offset;
1983  pps_slice_chroma_qp_offsets_present_flag;
1984  weighted_pred_flag;
1985  weighted_bipred_flag;
1986  transquant_bypass_enabled_flag;
1987  tiles_enabled_flag;
1988  entropy_coding_sync_enabled_flag;
1989  if( tiles_enabled_flag ) {
1990  num_tile_columns_minus1;
1991  num_tile_rows_minus1;
1992  uniform_spacing_flag;
1993  if( !uniform_spacing_flag ) {
1994  for( i = 0; i < num_tile_columns_minus1; i++ )
1995  column_width_minus1[ i ];
1996  for( i = 0; i < num_tile_rows_minus1; i++ )
1997  row_height_minus1[ i ];
1998  }
1999  loop_filter_across_tiles_enabled_flag;
2000  pps_loop_filter_across_slices_enabled_flag;
2001  deblocking_filter_control_present_flag;
2002  if( deblocking_filter_control_present_flag ) {
2003  }
2004  deblocking_filter_override_enabled_flag;
2005  pps_deblocking_filter_disabled_flag;
2006  if( !pps_deblocking_filter_disabled_flag ) {
2007  pps_beta_offset_div2;
2008  pps_tc_offset_div2;
2009  }
2010  }
2011  pps_scaling_list_data_present_flag;
2012  if( pps_scaling_list_data_present_flag )
2013  scaling_list_data( );
2014  lists_modification_present_flag;
2015  log2_parallel_merge_level_minus2;
2016  slice_segment_header_extension_present_flag;
2017  pps_extension_present_flag;
2018  if( pps_extension_present_flag ) {
2019  pps_range_extension_flag;
2020  pps_multilayer_extension_flag;
2021  pps_3d_extension_flag;
2022  pps_scc_extension_flag;
2023  pps_extension_4bits;
2024  }
2025  if( pps_range_extension_flag )
2026  pps_range_extension( );
2027  if( pps_multilayer_extension_flag )
2028  pps_multilayer_extension( ); /* specified in Annex F */
2029  if( pps_3d_extension_flag )
2030  pps_3d_extension( ); /* specified in Annex I */
2031  if( pps_scc_extension_flag )
2032  pps_scc_extension( );
2033  if( pps_extension_4bits )
2034  while( more_rbsp_data( ) )
2035  pps_extension_data_flag;
2036  rbsp_trailing_bits( )
2037 #endif
2038 
2039  return true;
2040 }
2041 
2042 // Following the lead of AVCParser, ignore the left cropping.
2044 {
2045  static const std::array<const uint8_t,5> subwc {1, 2, 2, 1, 1};
2046  const uint8_t crop_unit_x = subwc[m_chromaFormatIdc];
2047  // uint crop_rect_x = m_frameCropLeftOffset * crop_unit_x;
2048 
2049  return m_picWidth - ((/* m_frameCropLeftOffset + */
2050  m_frameCropRightOffset) * crop_unit_x);
2051 }
2052 
2053 // Following the lead of AVCParser, ignore the top cropping.
2055 {
2056  static const std::array<const uint8_t,5> subhc {1, 2, 1, 1, 1};
2057  const uint8_t crop_unit_y = subhc[m_chromaFormatIdc];
2058  // uint crop_rect_y = m_frameCropTopOffset * crop_unit_y;
2059 
2060  return m_picHeight - ((/* m_frameCropTopOffset + */
2061  m_frameCropBottomOffset) * crop_unit_y);
2062 }
2063 
2065 {
2066  result = (m_unitsInTick == 0) ? FrameRate(0) :
2068 }
H2645Parser::m_onAU
bool m_onAU
Definition: H2645Parser.h:185
HEVCParser::TAIL_R
@ TAIL_R
Definition: HEVCParser.h:35
HEVCParser::profileTierLevel
bool profileTierLevel(GetBitContext *gb, bool profilePresentFlag, int maxNumSubLayersMinus1)
Definition: HEVCParser.cpp:583
HEVCParser::EOS_NUT
@ EOS_NUT
Definition: HEVCParser.h:112
H2645Parser::m_seenSPS
bool m_seenSPS
Definition: H2645Parser.h:188
HEVCParser::NALisVCL
static bool NALisVCL(uint type)
Definition: HEVCParser.h:236
H2645Parser::m_frameCropRightOffset
uint m_frameCropRightOffset
Definition: H2645Parser.h:169
H2645Parser::m_frameStartOffset
uint64_t m_frameStartOffset
Definition: H2645Parser.h:153
HEVCParser::CRA_NUT
@ CRA_NUT
Definition: HEVCParser.h:93
HEVCParser::SPS::separate_colour_plane_flag
bool separate_colour_plane_flag
Definition: HEVCParser.h:149
H2645Parser::fillRBSP
bool fillRBSP(const uint8_t *byteP, uint32_t byte_count, bool found_start_code)
Definition: H2645Parser.cpp:141
H2645Parser::m_separateColourPlaneFlag
bool m_separateColourPlaneFlag
Definition: H2645Parser.h:189
HEVCParser::RASL_R
@ RASL_R
Definition: HEVCParser.h:48
HEVCParser::UNSPEC55
@ UNSPEC55
Definition: HEVCParser.h:134
HEVCParser::TSA_N
@ TSA_N
Definition: HEVCParser.h:37
H2645Parser::m_sarWidth
uint m_sarWidth
Definition: H2645Parser.h:174
HEVCParser::SPS::sub_layer_ordering_info_present_flag
bool sub_layer_ordering_info_present_flag
Definition: HEVCParser.h:150
dtvrecorder.h
H2645Parser::vui_parameters
void vui_parameters(GetBitContext *gb, bool hevc)
Definition: H2645Parser.cpp:229
H2645Parser::m_keyframeStartOffset
uint64_t m_keyframeStartOffset
Definition: H2645Parser.h:154
HEVCParser::m_noRaslOutputFlag
bool m_noRaslOutputFlag
Definition: HEVCParser.h:282
MythTimer
A QElapsedTimer based timer to replace use of QTime as a timer.
Definition: mythtimer.h:14
HEVCParser::m_nalTemperalId
uint8_t m_nalTemperalId
Definition: HEVCParser.h:277
HEVCParser::QUANT_MATIX_32X32
@ QUANT_MATIX_32X32
Definition: HEVCParser.h:208
H2645Parser::m_unitsInTick
uint32_t m_unitsInTick
Definition: H2645Parser.h:163
H2645Parser::m_framecnt
uint64_t m_framecnt
Definition: H2645Parser.h:148
HEVCParser::ScalingList::scaling_lists_4x4
std::array< std::array< uint8_t, 16 >, 6 > scaling_lists_4x4
Definition: HEVCParser.h:197
HEVCParser::TAIL_N
@ TAIL_N
Definition: HEVCParser.h:34
H2645Parser::m_picWidth
uint m_picWidth
Definition: H2645Parser.h:172
HEVCParser::RSV_VCL_R13
@ RSV_VCL_R13
Definition: HEVCParser.h:55
HEVCParser::SPS_NUT
@ SPS_NUT
Definition: HEVCParser.h:109
H2645Parser::m_pktOffset
uint64_t m_pktOffset
Definition: H2645Parser.h:155
H2645Parser::m_scanType
SCAN_t m_scanType
Definition: H2645Parser.h:165
H2645Parser::m_frameCropLeftOffset
uint m_frameCropLeftOffset
Definition: H2645Parser.h:168
H2645Parser::Reset
virtual void Reset(void)
Definition: H2645Parser.cpp:100
arg
arg(title).arg(filename).arg(doDelete))
HEVCParser::parsePPS
bool parsePPS(GetBitContext *gb)
Definition: HEVCParser.cpp:1959
HEVCParser::SPS
Definition: HEVCParser.h:145
HEVCParser::m_picOrderCntMsb
uint32_t m_picOrderCntMsb
Definition: HEVCParser.h:269
HEVCParser::PPS
Definition: HEVCParser.h:158
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
HEVCParser::RSV_VCL_R15
@ RSV_VCL_R15
Definition: HEVCParser.h:56
HEVCParser::m_nalUnitType
uint m_nalUnitType
Definition: HEVCParser.h:275
shortTermRefPicSet
static bool shortTermRefPicSet(GetBitContext *gb, 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:1059
HEVCParser::STSA_N
@ STSA_N
Definition: HEVCParser.h:40
HEVCParser::SPS::log2_min_luma_coding_block_size
uint8_t log2_min_luma_coding_block_size
Definition: HEVCParser.h:146
NULL
#define NULL
Definition: H2645Parser.h:67
HEVCParser::RSV_VCL_N10
@ RSV_VCL_N10
Definition: HEVCParser.h:50
LOC
#define LOC
Definition: HEVCParser.cpp:18
HEVCParser::AUD_NUT
@ AUD_NUT
Definition: HEVCParser.h:111
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:884
HEVCParser::parseSliceSegmentLayer
bool parseSliceSegmentLayer(GetBitContext *gb)
Definition: HEVCParser.cpp:1231
HEVCParser::PPS::num_extra_slice_header_bits
uint8_t num_extra_slice_header_bits
Definition: HEVCParser.h:161
HEVCParser::parseVPS
bool parseVPS(GetBitContext *gb)
Definition: HEVCParser.cpp:1832
HEVCParser::PPS_NUT
@ PPS_NUT
Definition: HEVCParser.h:110
mythlogging.h
HEVCParser::UNSPEC56
@ UNSPEC56
Definition: HEVCParser.h:135
HEVCParser::m_pps
std::map< uint, PPS > m_pps
Definition: HEVCParser.h:286
HEVCParser::Reset
void Reset(void) override
Definition: HEVCParser.cpp:49
HEVCParser::RADL_N
@ RADL_N
Definition: HEVCParser.h:43
H2645Parser::m_keyframecnt
uint64_t m_keyframecnt
Definition: H2645Parser.h:149
HEVCParser::RASL_N
@ RASL_N
Definition: HEVCParser.h:47
HEVCParser::RSV_IRAP_VCL23
@ RSV_IRAP_VCL23
Definition: HEVCParser.h:97
HEVCParser::STSA_R
@ STSA_R
Definition: HEVCParser.h:41
HEVCParser::parseSliceSegmentHeader
bool parseSliceSegmentHeader(GetBitContext *gb)
Definition: HEVCParser.cpp:1248
H2645Parser::m_rbspIndex
uint32_t m_rbspIndex
Definition: H2645Parser.h:160
H2645Parser::m_fixedRate
bool m_fixedRate
Definition: H2645Parser.h:182
H2645Parser::m_frameCropBottomOffset
uint m_frameCropBottomOffset
Definition: H2645Parser.h:167
HEVCParser::pictureWidthCropped
uint pictureWidthCropped(void) const override
Definition: HEVCParser.cpp:2043
HEVCParser::PREFIX_SEI_NUT
@ PREFIX_SEI_NUT
Definition: HEVCParser.h:116
HEVCParser::ScalingList::scaling_list_dc_coef_minus8_16x16
std::vector< int16_t > scaling_list_dc_coef_minus8_16x16
Definition: HEVCParser.h:194
HEVCParser::EOB_NUT
@ EOB_NUT
Definition: HEVCParser.h:113
HEVCParser::RSV_IRAP_VCL22
@ RSV_IRAP_VCL22
Definition: HEVCParser.h:96
HEVCParser::BLA_W_LP
@ BLA_W_LP
Definition: HEVCParser.h:72
FrameRate
Definition: recorderbase.h:37
HEVCParser::ShortTermRefPicSet
Definition: HEVCParser.h:165
H2645Parser::m_rbspBuffer
uint8_t * m_rbspBuffer
Definition: H2645Parser.h:176
HEVCParser::addBytes
uint32_t addBytes(const uint8_t *bytes, uint32_t byte_count, uint64_t stream_offset) override
Definition: HEVCParser.cpp:130
H2645Parser::m_auOffset
uint64_t m_auOffset
Definition: H2645Parser.h:152
HEVCParser::SPS::log2_diff_max_min_luma_coding_block_size
uint8_t log2_diff_max_min_luma_coding_block_size
Definition: HEVCParser.h:147
H2645Parser::m_auPending
bool m_auPending
Definition: H2645Parser.h:181
H2645Parser::m_onKeyFrame
bool m_onKeyFrame
Definition: H2645Parser.h:187
HEVCParser::IDR_W_RADL
@ IDR_W_RADL
Definition: HEVCParser.h:85
HEVCParser::m_resolutionCheck
uint32_t m_resolutionCheck
Definition: HEVCParser.h:273
HEVCParser.h
HEVCParser::RSV_NVCL41
@ RSV_NVCL41
Definition: HEVCParser.h:119
HEVCParser::m_prevPicOrderCntMsb
uint32_t m_prevPicOrderCntMsb
Definition: HEVCParser.h:272
HEVCParser::pictureHeightCropped
uint pictureHeightCropped(void) const override
Definition: HEVCParser.cpp:2054
scalingListData
static bool scalingListData(GetBitContext *gb, HEVCParser::ScalingList &dest_scaling_list, bool use_default)
Definition: HEVCParser.cpp:921
uint
unsigned int uint
Definition: compat.h:141
H2645Parser::m_spsOffset
uint64_t m_spsOffset
Definition: H2645Parser.h:156
HEVCParser::ScalingList::scaling_lists_16x16
std::array< std::array< uint8_t, 64 >, 6 > scaling_lists_16x16
Definition: HEVCParser.h:199
strings.h
H2645Parser::m_stateChanged
bool m_stateChanged
Definition: H2645Parser.h:190
ceil_log2
static uint ceil_log2(uint32_t v)
Definition: HEVCParser.cpp:27
H2645Parser::m_timeScale
uint32_t m_timeScale
Definition: H2645Parser.h:162
H2645Parser::m_onFrame
bool m_onFrame
Definition: H2645Parser.h:186
H2645Parser::m_haveUnfinishedNAL
bool m_haveUnfinishedNAL
Definition: H2645Parser.h:183
MythTimer::elapsed
int elapsed(void)
Returns milliseconds elapsed since last start() or restart()
Definition: mythtimer.cpp:90
H2645Parser::m_frameCropTopOffset
uint m_frameCropTopOffset
Definition: H2645Parser.h:170
MythTimer::kStartRunning
@ kStartRunning
Definition: mythtimer.h:17
H2645Parser::m_syncAccumulator
uint32_t m_syncAccumulator
Definition: H2645Parser.h:161
musicbrainzngs.compat.bytes
bytes
Definition: compat.py:49
HEVCParser::m_vps
std::map< uint, VPS > m_vps
Definition: HEVCParser.h:287
HEVCParser::QUANT_MATIX_8X8
@ QUANT_MATIX_8X8
Definition: HEVCParser.h:206
HEVCParser::RSV_NVCL45
@ RSV_NVCL45
Definition: HEVCParser.h:123
HEVCParser::m_firstSliceSegmentInPicFlag
bool m_firstSliceSegmentInPicFlag
Definition: HEVCParser.h:280
HEVCParser::ScalingList::scaling_list_dc_coef_minus8_32x32
std::vector< int16_t > scaling_list_dc_coef_minus8_32x32
Definition: HEVCParser.h:195
H2645Parser::m_totalframecnt
uint64_t m_totalframecnt
Definition: H2645Parser.h:150
HEVCParser::SUFFIX_SEI_NUT
@ SUFFIX_SEI_NUT
Definition: HEVCParser.h:117
HEVCParser::m_sps
std::map< uint, SPS > m_sps
Definition: HEVCParser.h:285
HEVCParser::SPS::log2_max_pic_order_cnt_lsb
uint8_t log2_max_pic_order_cnt_lsb
Definition: HEVCParser.h:148
HEVCParser::processRBSP
void processRBSP(bool rbsp_complete)
Definition: HEVCParser.cpp:463
HEVCParser::ScalingList::scaling_lists_32x32
std::array< std::array< uint8_t, 64 >, 2 > scaling_lists_32x32
Definition: HEVCParser.h:200
HEVCParser::PPS::dependent_slice_segments_enabled_flag
bool dependent_slice_segments_enabled_flag
Definition: HEVCParser.h:159
HEVCParser::IDR_N_LP
@ IDR_N_LP
Definition: HEVCParser.h:86
H2645Parser::m_chromaFormatIdc
int8_t m_chromaFormatIdc
Definition: H2645Parser.h:179
HEVCParser::UNSPEC48
@ UNSPEC48
Definition: HEVCParser.h:127
HEVCParser::BLA_W_RADL
@ BLA_W_RADL
Definition: HEVCParser.h:73
HEVCParser::NALisIRAP
static bool NALisIRAP(uint type)
Definition: HEVCParser.h:231
HEVCParser::m_poc
std::map< uint, uint > m_poc
Definition: HEVCParser.h:288
HEVCParser::QUANT_MATIX_4X4
@ QUANT_MATIX_4X4
Definition: HEVCParser.h:205
H2645Parser::m_picHeight
uint m_picHeight
Definition: H2645Parser.h:171
uint16_t
unsigned short uint16_t
Definition: iso6937tables.h:3
HEVCParser::FD_NUT
@ FD_NUT
Definition: HEVCParser.h:114
HEVCParser::RSV_VCL_N12
@ RSV_VCL_N12
Definition: HEVCParser.h:51
HEVCParser::parseSPS
bool parseSPS(GetBitContext *gb)
Definition: HEVCParser.cpp:1575
HEVCParser::newAU
bool newAU(void)
Definition: HEVCParser.cpp:254
HEVCParser::PPS::output_flag_present_flag
bool output_flag_present_flag
Definition: HEVCParser.h:160
HEVCParser::NAL_type_str
QString NAL_type_str(int8_t type) override
Definition: HEVCParser.cpp:54
HEVCParser::getFrameRate
void getFrameRate(FrameRate &result) const override
Definition: HEVCParser.cpp:2064
H2645Parser::UNKNOWN
@ UNKNOWN
Definition: H2645Parser.h:122
HEVCParser::VPS_NUT
@ VPS_NUT
Definition: HEVCParser.h:108
HEVCParser::RADL_R
@ RADL_R
Definition: HEVCParser.h:44
HEVCParser::RSV_NVCL44
@ RSV_NVCL44
Definition: HEVCParser.h:122
HEVCParser::m_nuhLayerId
uint8_t m_nuhLayerId
Definition: HEVCParser.h:278
HEVCParser::TSA_R
@ TSA_R
Definition: HEVCParser.h:38
H2645Parser::m_sarHeight
uint m_sarHeight
Definition: H2645Parser.h:173
HEVCParser::UNSPEC63
@ UNSPEC63
Definition: HEVCParser.h:142
H2645Parser::resetRBSP
void resetRBSP(void)
Definition: H2645Parser.cpp:134
HEVCParser::ScalingList::scaling_lists_8x8
std::array< std::array< uint8_t, 64 >, 6 > scaling_lists_8x8
Definition: HEVCParser.h:198
HEVCParser::m_picOrderCntVal
uint32_t m_picOrderCntVal
Definition: HEVCParser.h:270
HEVCParser::QUANT_MATIX_16X16
@ QUANT_MATIX_16X16
Definition: HEVCParser.h:207
HEVCParser::m_nextNALisAU
bool m_nextNALisAU
Definition: HEVCParser.h:281
HEVCParser::RSV_VCL_R11
@ RSV_VCL_R11
Definition: HEVCParser.h:54
HEVCParser::m_seenEOS
bool m_seenEOS
Definition: HEVCParser.h:283
HEVCParser::PPS::sps_id
int sps_id
Definition: HEVCParser.h:162
H2645Parser::m_totalkeyframecnt
uint64_t m_totalkeyframecnt
Definition: H2645Parser.h:151
HEVCParser::m_prevPicOrderCntLsb
uint32_t m_prevPicOrderCntLsb
Definition: HEVCParser.h:271
HEVCParser::ScalingList
Definition: HEVCParser.h:193
HEVCParser::RSV_NVCL47
@ RSV_NVCL47
Definition: HEVCParser.h:125
HEVCParser::BLA_N_LP
@ BLA_N_LP
Definition: HEVCParser.h:74
HEVCParser::RSV_VCL_N14
@ RSV_VCL_N14
Definition: HEVCParser.h:52