source: SHVCSoftware/branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/SEIread.cpp @ 503

Last change on this file since 503 was 51, checked in by suehring, 12 years ago

import HM 10.0 (HEVCSoftware/trunk rev. 3352)

File size: 22.7 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2013, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/**
35 \file     SEIread.cpp
36 \brief    reading functionality for SEI messages
37 */
38
39#include "TLibCommon/CommonDef.h"
40#include "TLibCommon/TComBitStream.h"
41#include "TLibCommon/SEI.h"
42#include "TLibCommon/TComSlice.h"
43#include "SyntaxElementParser.h"
44#include "SEIread.h"
45
46//! \ingroup TLibDecoder
47//! \{
48
49#if ENC_DEC_TRACE
50Void  xTraceSEIHeader()
51{
52  fprintf( g_hTrace, "=========== SEI message ===========\n");
53}
54
55Void  xTraceSEIMessageType(SEI::PayloadType payloadType)
56{
57  switch (payloadType)
58  {
59  case SEI::DECODED_PICTURE_HASH:
60    fprintf( g_hTrace, "=========== Decoded picture hash SEI message ===========\n");
61    break;
62  case SEI::USER_DATA_UNREGISTERED:
63    fprintf( g_hTrace, "=========== User Data Unregistered SEI message ===========\n");
64    break;
65  case SEI::ACTIVE_PARAMETER_SETS:
66    fprintf( g_hTrace, "=========== Active Parameter sets SEI message ===========\n");
67    break;
68  case SEI::BUFFERING_PERIOD:
69    fprintf( g_hTrace, "=========== Buffering period SEI message ===========\n");
70    break;
71  case SEI::PICTURE_TIMING:
72    fprintf( g_hTrace, "=========== Picture timing SEI message ===========\n");
73    break;
74  case SEI::RECOVERY_POINT:
75    fprintf( g_hTrace, "=========== Recovery point SEI message ===========\n");
76    break;
77  case SEI::FRAME_PACKING:
78    fprintf( g_hTrace, "=========== Frame Packing Arrangement SEI message ===========\n");
79    break;
80  case SEI::DISPLAY_ORIENTATION:
81    fprintf( g_hTrace, "=========== Display Orientation SEI message ===========\n");
82    break;
83  case SEI::TEMPORAL_LEVEL0_INDEX:
84    fprintf( g_hTrace, "=========== Temporal Level Zero Index SEI message ===========\n");
85    break;
86  case SEI::REGION_REFRESH_INFO:
87    fprintf( g_hTrace, "=========== Gradual Decoding Refresh Information SEI message ===========\n");
88    break;
89  case SEI::DECODING_UNIT_INFO:
90    fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n");
91    break;
92  default:
93    fprintf( g_hTrace, "=========== Unknown SEI message ===========\n");
94    break;
95  }
96}
97#endif
98
99/**
100 * unmarshal a single SEI message from bitstream bs
101 */
102void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps)
103{
104  setBitstream(bs);
105
106  assert(!m_pcBitstream->getNumBitsUntilByteAligned());
107  do
108  {
109    xReadSEImessage(seis, nalUnitType, sps);
110    /* SEI messages are an integer number of bytes, something has failed
111    * in the parsing if bitstream not byte-aligned */
112    assert(!m_pcBitstream->getNumBitsUntilByteAligned());
113  } while (m_pcBitstream->getNumBitsLeft() > 8);
114
115  UInt rbspTrailingBits;
116  READ_CODE(8, rbspTrailingBits, "rbsp_trailing_bits");
117  assert(rbspTrailingBits == 0x80);
118}
119
120Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps)
121{
122#if ENC_DEC_TRACE
123  xTraceSEIHeader();
124#endif
125  Int payloadType = 0;
126  UInt val = 0;
127
128  do
129  {
130    READ_CODE (8, val, "payload_type");
131    payloadType += val;
132  } while (val==0xFF);
133
134  UInt payloadSize = 0;
135  do
136  {
137    READ_CODE (8, val, "payload_size");
138    payloadSize += val;
139  } while (val==0xFF);
140
141#if ENC_DEC_TRACE
142  xTraceSEIMessageType((SEI::PayloadType)payloadType);
143#endif
144
145  /* extract the payload for this single SEI message.
146   * This allows greater safety in erroneous parsing of an SEI message
147   * from affecting subsequent messages.
148   * After parsing the payload, bs needs to be restored as the primary
149   * bitstream.
150   */
151  TComInputBitstream *bs = getBitstream();
152  setBitstream(bs->extractSubstream(payloadSize * 8));
153
154  SEI *sei = NULL;
155
156  if(nalUnitType == NAL_UNIT_SEI)
157  {
158    switch (payloadType)
159    {
160    case SEI::USER_DATA_UNREGISTERED:
161      sei = new SEIuserDataUnregistered;
162      xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize);
163      break;
164    case SEI::ACTIVE_PARAMETER_SETS:
165      sei = new SEIActiveParameterSets; 
166      xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize); 
167      break; 
168    case SEI::DECODING_UNIT_INFO:
169      if (!sps)
170      {
171        printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring.");
172      }
173      else
174      {
175        sei = new SEIDecodingUnitInfo; 
176        xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps);
177      }
178      break; 
179    case SEI::BUFFERING_PERIOD:
180      if (!sps)
181      {
182        printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring.");
183      }
184      else
185      {
186        sei = new SEIBufferingPeriod;
187        xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps);
188      }
189      break;
190    case SEI::PICTURE_TIMING:
191      if (!sps)
192      {
193        printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring.");
194      }
195      else
196      {
197        sei = new SEIPictureTiming;
198        xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps);
199      }
200      break;
201    case SEI::RECOVERY_POINT:
202      sei = new SEIRecoveryPoint;
203      xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize);
204      break;
205    case SEI::FRAME_PACKING:
206      sei = new SEIFramePacking;
207      xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize);
208      break;
209    case SEI::DISPLAY_ORIENTATION:
210      sei = new SEIDisplayOrientation;
211      xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize);
212      break;
213    case SEI::TEMPORAL_LEVEL0_INDEX:
214      sei = new SEITemporalLevel0Index;
215      xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize);
216      break;
217    case SEI::REGION_REFRESH_INFO:
218      sei = new SEIGradualDecodingRefreshInfo;
219      xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize);
220      break;
221    default:
222      for (UInt i = 0; i < payloadSize; i++)
223      {
224        UInt seiByte;
225        READ_CODE (8, seiByte, "unknown prefix SEI payload byte");
226      }
227      printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType);
228    }
229  }
230  else
231  {
232    switch (payloadType)
233    {
234#if L0363_SEI_ALLOW_SUFFIX
235      case SEI::USER_DATA_UNREGISTERED:
236        sei = new SEIuserDataUnregistered;
237        xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize);
238        break;
239#endif
240      case SEI::DECODED_PICTURE_HASH:
241        sei = new SEIDecodedPictureHash;
242        xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize);
243        break;
244      default:
245        for (UInt i = 0; i < payloadSize; i++)
246        {
247          UInt seiByte;
248          READ_CODE (8, seiByte, "unknown suffix SEI payload byte");
249        }
250        printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType);
251    }
252  }
253  if (sei != NULL)
254  {
255    seis.push_back(sei);
256  }
257
258  /* By definition the underlying bitstream terminates in a byte-aligned manner.
259   * 1. Extract all bar the last MIN(bitsremaining,nine) bits as reserved_payload_extension_data
260   * 2. Examine the final 8 bits to determine the payload_bit_equal_to_one marker
261   * 3. Extract the remainingreserved_payload_extension_data bits.
262   *
263   * If there are fewer than 9 bits available, extract them.
264   */
265  Int payloadBitsRemaining = getBitstream()->getNumBitsLeft();
266  if (payloadBitsRemaining) /* more_data_in_payload() */
267  {
268    for (; payloadBitsRemaining > 9; payloadBitsRemaining--)
269    {
270      UInt reservedPayloadExtensionData;
271      READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data");
272    }
273
274    /* 2 */
275    Int finalBits = getBitstream()->peekBits(payloadBitsRemaining);
276    Int finalPayloadBits = 0;
277    for (Int mask = 0xff; finalBits & (mask >> finalPayloadBits); finalPayloadBits++)
278    {
279      continue;
280    }
281
282    /* 3 */
283    for (; payloadBitsRemaining > 9 - finalPayloadBits; payloadBitsRemaining--)
284    {
285      UInt reservedPayloadExtensionData;
286      READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data");
287    }
288
289    UInt dummy;
290    READ_CODE (1, dummy, "payload_bit_equal_to_one");
291    READ_CODE (payloadBitsRemaining-1, dummy, "payload_bit_equal_to_zero");
292  }
293
294  /* restore primary bitstream for sei_message */
295  delete getBitstream();
296  setBitstream(bs);
297}
298
299/**
300 * parse bitstream bs and unpack a user_data_unregistered SEI message
301 * of payloasSize bytes into sei.
302 */
303Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize)
304{
305  assert(payloadSize >= 16);
306  UInt val;
307
308  for (UInt i = 0; i < 16; i++)
309  {
310    READ_CODE (8, val, "uuid_iso_iec_11578");
311    sei.uuid_iso_iec_11578[i] = val;
312  }
313
314  sei.userDataLength = payloadSize - 16;
315  if (!sei.userDataLength)
316  {
317    sei.userData = 0;
318    return;
319  }
320
321  sei.userData = new UChar[sei.userDataLength];
322  for (UInt i = 0; i < sei.userDataLength; i++)
323  {
324    READ_CODE (8, val, "user_data" );
325    sei.userData[i] = val;
326  }
327}
328
329/**
330 * parse bitstream bs and unpack a decoded picture hash SEI message
331 * of payloadSize bytes into sei.
332 */
333Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt /*payloadSize*/)
334{
335  UInt val;
336  READ_CODE (8, val, "hash_type");
337  sei.method = static_cast<SEIDecodedPictureHash::Method>(val);
338  for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++)
339  {
340    if(SEIDecodedPictureHash::MD5 == sei.method)
341    {
342      for (UInt i = 0; i < 16; i++)
343      {
344        READ_CODE(8, val, "picture_md5");
345        sei.digest[yuvIdx][i] = val;
346      }
347    }
348    else if(SEIDecodedPictureHash::CRC == sei.method)
349    {
350      READ_CODE(16, val, "picture_crc");
351      sei.digest[yuvIdx][0] = val >> 8 & 0xFF;
352      sei.digest[yuvIdx][1] = val & 0xFF;
353    }
354    else if(SEIDecodedPictureHash::CHECKSUM == sei.method)
355    {
356      READ_CODE(32, val, "picture_checksum");
357      sei.digest[yuvIdx][0] = (val>>24) & 0xff;
358      sei.digest[yuvIdx][1] = (val>>16) & 0xff;
359      sei.digest[yuvIdx][2] = (val>>8)  & 0xff;
360      sei.digest[yuvIdx][3] =  val      & 0xff;
361    }
362  }
363}
364Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt /*payloadSize*/)
365{
366  UInt val; 
367  READ_CODE(4, val, "active_vps_id");      sei.activeVPSId = val; 
368#if L0047_APS_FLAGS
369  READ_FLAG( val, "full_random_access_flag");  sei.m_fullRandomAccessFlag = val ? true : false;
370  READ_FLAG( val, "no_param_set_update_flag"); sei.m_noParamSetUpdateFlag = val ? true : false;
371#endif
372  READ_UVLC(   val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val;
373
374  sei.activeSeqParamSetId.resize(sei.numSpsIdsMinus1 + 1);
375  for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++)
376  {
377    READ_UVLC(val, "active_seq_param_set_id");  sei.activeSeqParamSetId[i] = val; 
378  }
379
380  UInt uibits = m_pcBitstream->getNumBitsUntilByteAligned(); 
381 
382  while(uibits--)
383  {
384    READ_FLAG(val, "alignment_bit");
385  }
386}
387
388Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps)
389{
390  UInt val;
391  READ_UVLC(val, "decoding_unit_idx");
392  sei.m_decodingUnitIdx = val;
393
394  TComVUI *vui = sps->getVuiParameters();
395  if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
396  {
397    READ_CODE( ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay");
398    sei.m_duSptCpbRemovalDelay = val;
399  }
400  else
401  {
402    sei.m_duSptCpbRemovalDelay = 0;
403  }
404#if L0044_DU_DPB_OUTPUT_DELAY_HRD
405  READ_FLAG( val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = val ? true : false;
406  if(sei.m_dpbOutputDuDelayPresentFlag)
407  {
408    READ_CODE(vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); 
409    sei.m_picSptDpbOutputDuDelay = val;
410  }
411#endif
412  xParseByteAlign();
413}
414
415Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps)
416{
417  Int i, nalOrVcl;
418  UInt code;
419
420  TComVUI *pVUI = sps->getVuiParameters();
421  TComHRD *pHRD = pVUI->getHrdParameters();
422
423  READ_UVLC( code, "bp_seq_parameter_set_id" );                         sei.m_bpSeqParameterSetId     = code;
424  if( !pHRD->getSubPicCpbParamsPresentFlag() )
425  {
426    READ_FLAG( code, "rap_cpb_params_present_flag" );                   sei.m_rapCpbParamsPresentFlag = code;
427  }
428#if L0328_SPLICING
429  //read splicing flag and cpb_removal_delay_delta
430  READ_FLAG( code, "concatenation_flag"); 
431  sei.m_concatenationFlag = code;
432  READ_CODE( ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" );
433  sei.m_auCpbRemovalDelayDelta = code + 1;
434#endif
435#if L0044_CPB_DPB_DELAY_OFFSET
436  if( sei.m_rapCpbParamsPresentFlag )
437  {
438    READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" );      sei.m_cpbDelayOffset = code;
439    READ_CODE( pHRD->getDpbOutputDelayLengthMinus1()  + 1, code, "dpb_delay_offset" );      sei.m_dpbDelayOffset = code;
440  }
441#endif
442  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
443  {
444    if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) ||
445        ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) )
446    {
447      for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ )
448      {
449        READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay" );
450        sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code;
451        READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay_offset" );
452        sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code;
453        if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag )
454        {
455          READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay" );
456          sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code;
457          READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay_offset" );
458          sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code;
459        }
460      }
461    }
462  }
463  xParseByteAlign();
464}
465Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps)
466{
467  Int i;
468  UInt code;
469
470  TComVUI *vui = sps->getVuiParameters();
471  TComHRD *hrd = vui->getHrdParameters();
472
473#if !L0045_CONDITION_SIGNALLING
474  // This condition was probably OK before the pic_struct, progressive_source_idc, duplicate_flag were added
475  if( !hrd->getNalHrdParametersPresentFlag() && !hrd->getVclHrdParametersPresentFlag() )
476  {
477    return;
478  }
479#endif
480
481  if( vui->getFrameFieldInfoPresentFlag() )
482  {
483    READ_CODE( 4, code, "pic_struct" );             sei.m_picStruct            = code;
484#if L0046_RENAME_PROG_SRC_IDC
485    READ_CODE( 2, code, "source_scan_type" );       sei.m_sourceScanType = code;
486#else
487    READ_CODE( 2, code, "progressive_source_idc" ); sei.m_progressiveSourceIdc = code;
488#endif
489    READ_FLAG(    code, "duplicate_flag" );         sei.m_duplicateFlag        = ( code == 1 ? true : false );
490  }
491
492#if L0045_CONDITION_SIGNALLING
493  if( hrd->getCpbDpbDelaysPresentFlag())
494  {
495#endif
496    READ_CODE( ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" );
497    sei.m_auCpbRemovalDelay = code + 1;
498    READ_CODE( ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" );
499    sei.m_picDpbOutputDelay = code;
500
501#if L0044_DU_DPB_OUTPUT_DELAY_HRD
502    if(hrd->getSubPicCpbParamsPresentFlag())
503    {
504      READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" );
505      sei.m_picDpbOutputDuDelay = code;
506    }
507#endif
508    if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() )
509    {
510      READ_UVLC( code, "num_decoding_units_minus1");
511      sei.m_numDecodingUnitsMinus1 = code;
512      READ_FLAG( code, "du_common_cpb_removal_delay_flag" );
513      sei.m_duCommonCpbRemovalDelayFlag = code;
514      if( sei.m_duCommonCpbRemovalDelayFlag )
515      {
516        READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_minus1" );
517        sei.m_duCommonCpbRemovalDelayMinus1 = code;
518      }
519      if( sei.m_numNalusInDuMinus1 != NULL )
520      {
521        delete sei.m_numNalusInDuMinus1;
522      }
523      sei.m_numNalusInDuMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ];
524      if( sei.m_duCpbRemovalDelayMinus1  != NULL )
525      {
526        delete sei.m_duCpbRemovalDelayMinus1;
527      }
528      sei.m_duCpbRemovalDelayMinus1  = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ];
529
530      for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ )
531      {
532        READ_UVLC( code, "num_nalus_in_du_minus1");
533        sei.m_numNalusInDuMinus1[ i ] = code;
534        if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) )
535        {
536          READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1" );
537          sei.m_duCpbRemovalDelayMinus1[ i ] = code;
538        }
539      }
540    }
541#if L0045_CONDITION_SIGNALLING
542  }
543#endif
544  xParseByteAlign();
545}
546Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt /*payloadSize*/)
547{
548  Int  iCode;
549  UInt uiCode;
550  READ_SVLC( iCode,  "recovery_poc_cnt" );      sei.m_recoveryPocCnt     = iCode;
551  READ_FLAG( uiCode, "exact_matching_flag" );   sei.m_exactMatchingFlag  = uiCode;
552  READ_FLAG( uiCode, "broken_link_flag" );      sei.m_brokenLinkFlag     = uiCode;
553  xParseByteAlign();
554}
555Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt /*payloadSize*/)
556{
557  UInt val;
558  READ_UVLC( val, "frame_packing_arrangement_id" );                 sei.m_arrangementId = val;
559  READ_FLAG( val, "frame_packing_arrangement_cancel_flag" );        sei.m_arrangementCancelFlag = val;
560
561  if ( !sei.m_arrangementCancelFlag )
562  {
563    READ_CODE( 7, val, "frame_packing_arrangement_type" );          sei.m_arrangementType = val;
564#if L0444_FPA_TYPE
565    assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) );
566#endif
567    READ_FLAG( val, "quincunx_sampling_flag" );                     sei.m_quincunxSamplingFlag = val;
568
569    READ_CODE( 6, val, "content_interpretation_type" );             sei.m_contentInterpretationType = val;
570    READ_FLAG( val, "spatial_flipping_flag" );                      sei.m_spatialFlippingFlag = val;
571    READ_FLAG( val, "frame0_flipped_flag" );                        sei.m_frame0FlippedFlag = val;
572    READ_FLAG( val, "field_views_flag" );                           sei.m_fieldViewsFlag = val;
573    READ_FLAG( val, "current_frame_is_frame0_flag" );               sei.m_currentFrameIsFrame0Flag = val;
574    READ_FLAG( val, "frame0_self_contained_flag" );                 sei.m_frame0SelfContainedFlag = val;
575    READ_FLAG( val, "frame1_self_contained_flag" );                 sei.m_frame1SelfContainedFlag = val;
576
577    if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5)
578    {
579      READ_CODE( 4, val, "frame0_grid_position_x" );                sei.m_frame0GridPositionX = val;
580      READ_CODE( 4, val, "frame0_grid_position_y" );                sei.m_frame0GridPositionY = val;
581      READ_CODE( 4, val, "frame1_grid_position_x" );                sei.m_frame1GridPositionX = val;
582      READ_CODE( 4, val, "frame1_grid_position_y" );                sei.m_frame1GridPositionY = val;
583    }
584
585    READ_CODE( 8, val, "frame_packing_arrangement_reserved_byte" );   sei.m_arrangementReservedByte = val;
586#if L0045_PERSISTENCE_FLAGS
587    READ_FLAG( val,  "frame_packing_arrangement_persistence_flag" );  sei.m_arrangementPersistenceFlag = val ? true : false;
588#else
589    READ_UVLC( val, "frame_packing_arrangement_repetition_period" );  sei.m_arrangementRepetetionPeriod = val;
590#endif
591  }
592  READ_FLAG( val, "upsampled_aspect_ratio" );                       sei.m_upsampledAspectRatio = val;
593
594  xParseByteAlign();
595}
596
597Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt /*payloadSize*/)
598{
599  UInt val;
600  READ_FLAG( val,       "display_orientation_cancel_flag" );       sei.cancelFlag            = val;
601  if( !sei.cancelFlag ) 
602  {
603    READ_FLAG( val,     "hor_flip" );                              sei.horFlip               = val;
604    READ_FLAG( val,     "ver_flip" );                              sei.verFlip               = val;
605    READ_CODE( 16, val, "anticlockwise_rotation" );                sei.anticlockwiseRotation = val;
606#if L0045_PERSISTENCE_FLAGS
607    READ_FLAG( val,     "display_orientation_persistence_flag" );  sei.persistenceFlag       = val;
608#else
609    READ_UVLC( val,     "display_orientation_repetition_period" ); sei.repetitionPeriod      = val;
610#endif
611#if !REMOVE_SINGLE_SEI_EXTENSION_FLAGS
612    READ_FLAG( val,     "display_orientation_extension_flag" );    sei.extensionFlag         = val;
613    assert( !sei.extensionFlag );
614#endif
615  }
616  xParseByteAlign();
617}
618
619Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt /*payloadSize*/)
620{
621  UInt val;
622  READ_CODE ( 8, val, "tl0_idx" );  sei.tl0Idx = val;
623  READ_CODE ( 8, val, "rap_idx" );  sei.rapIdx = val;
624  xParseByteAlign();
625}
626
627Void SEIReader::xParseSEIGradualDecodingRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt /*payloadSize*/)
628{
629  UInt val;
630  READ_FLAG( val, "gdr_foreground_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0;
631  xParseByteAlign();
632}
633
634Void SEIReader::xParseByteAlign()
635{
636  UInt code;
637  if( m_pcBitstream->getNumBitsRead() % 8 != 0 )
638  {
639    READ_FLAG( code, "bit_equal_to_one" );          assert( code == 1 );
640  }
641  while( m_pcBitstream->getNumBitsRead() % 8 != 0 )
642  {
643    READ_FLAG( code, "bit_equal_to_zero" );         assert( code == 0 );
644  }
645}
646//! \}
Note: See TracBrowser for help on using the repository browser.