source: 3DVCSoftware/trunk/source/Lib/TLibCommon/NAL.h @ 72

Last change on this file since 72 was 56, checked in by hschwarz, 13 years ago

updated trunk (move to HM6.1)

File size: 4.5 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-2012, 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#pragma once
35
36#include <vector>
37#include <sstream>
38#include "CommonDef.h"
39
40class TComOutputBitstream;
41
42/**
43 * Represents a single NALunit header and the associated RBSPayload
44 */
45struct NALUnit
46{
47  NalUnitType m_nalUnitType; ///< nal_unit_type
48#if NAL_REF_FLAG
49  Bool        m_nalRefFlag;  ///< nal_ref_flag
50#else
51  NalRefIdc   m_nalRefIDC;   ///< nal_ref_idc
52#endif
53  Int         m_viewId;      ///< view_id
54  Bool        m_isDepth;     ///< is_depth
55  unsigned    m_temporalId;  ///< temporal_id
56#if !H0388
57  bool        m_OutputFlag;  ///< output_flag
58#endif
59
60  /** construct an NALunit structure with given header values. */
61#if H0388
62#if NAL_REF_FLAG
63  NALUnit(
64    NalUnitType nalUnitType,
65    Bool        nalRefFlag,
66    Int         viewId,
67    Bool        isDepth,
68    Int         temporalId = 0)
69    :m_nalUnitType (nalUnitType)
70    ,m_nalRefFlag  (nalRefFlag)
71    ,m_viewId      (viewId)
72    ,m_isDepth     (isDepth)
73    ,m_temporalId  (temporalId)
74  {}
75#else
76  NALUnit(
77    NalUnitType  nalUnitType,
78    NalRefIdc    nalRefIDC,
79    Int          viewId,
80    Bool         isDepth,
81    unsigned temporalID = 0)
82  {
83    m_nalUnitType = nalUnitType;
84    m_nalRefIDC   = nalRefIDC;
85    m_viewId      = viewId;
86    m_isDepth     = isDepth;
87    m_temporalId  = temporalID;
88  }
89#endif
90#else
91  NALUnit(
92    NalUnitType  nalUnitType,
93    NalRefIdc    nalRefIDC,
94    Int          viewId,
95    Bool         isDepth,
96    unsigned     temporalID = 0,
97    bool         outputFlag = true)
98  {
99    m_nalUnitType = nalUnitType;
100    m_nalRefIDC   = nalRefIDC;
101    m_viewId      = viewId;
102    m_isDepth     = isDepth;
103    m_temporalId  = temporalID;
104    m_OutputFlag  = outputFlag;
105  }
106#endif
107
108  /** default constructor - no initialization; must be perfomed by user */
109  NALUnit() {}
110
111  /** returns true if the NALunit is a slice NALunit */
112  bool isSlice()
113  {
114    return m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
115#if H0566_TLA
116        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDV
117        || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA
118        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA
119#else
120        || m_nalUnitType == NAL_UNIT_CODED_SLICE_CDR
121#endif
122        || m_nalUnitType == NAL_UNIT_CODED_SLICE;
123  }
124};
125
126struct OutputNALUnit;
127
128/**
129 * A single NALunit, with complete payload in EBSP format.
130 */
131struct NALUnitEBSP : public NALUnit
132{
133  std::ostringstream m_nalUnitData;
134
135  /**
136   * convert the OutputNALUnit #nalu# into EBSP format by writing out
137   * the NALUnit header, then the rbsp_bytes including any
138   * emulation_prevention_three_byte symbols.
139   */
140  NALUnitEBSP(OutputNALUnit& nalu);
141};
142//! \}
143//! \}
Note: See TracBrowser for help on using the repository browser.