source: SHVCSoftware/branches/SHM-1.1-dev/source/Lib/TLibCommon/NAL.h @ 854

Last change on this file since 854 was 2, checked in by seregin, 12 years ago

Initial import by Vadim Seregin <vseregin@…>

File size: 4.9 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 !REMOVE_NAL_REF_FLAG
49  Bool        m_nalRefFlag;  ///< nal_ref_flag
50#endif
51  UInt        m_temporalId;  ///< temporal_id
52#if SVC_EXTENSION
53  UInt        m_layerId;   ///< layer id
54#endif
55#if TARGET_DECLAYERID_SET
56  UInt        m_reservedZero6Bits; ///< reserved_zero_6bits
57#endif
58
59  /** construct an NALunit structure with given header values. */
60  NALUnit(
61    NalUnitType nalUnitType,
62#if !REMOVE_NAL_REF_FLAG
63    Bool        nalRefFlag,
64#endif
65#if TARGET_DECLAYERID_SET
66    Int         temporalId = 0,
67#if SVC_EXTENSION
68    UInt        layerId = 0,
69#endif
70    Int         reservedZero6Bits = 0)
71#else
72#if SVC_EXTENSION
73    UInt        layerId = 0,
74    Int         temporalId = 0)
75#else
76    Int         temporalId = 0)
77#endif
78#endif
79    :m_nalUnitType (nalUnitType)
80#if !REMOVE_NAL_REF_FLAG
81    ,m_nalRefFlag  (nalRefFlag)
82#endif
83    ,m_temporalId  (temporalId)
84#if SVC_EXTENSION
85    ,m_layerId   (layerId)
86#endif
87#if TARGET_DECLAYERID_SET
88    ,m_reservedZero6Bits(reservedZero6Bits)
89#endif
90  {}
91
92  /** default constructor - no initialization; must be perfomed by user */
93  NALUnit() {}
94
95  /** returns true if the NALunit is a slice NALunit */
96  bool isSlice()
97  {
98#if NAL_UNIT_TYPES_J1003_D7
99    return m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R
100        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N
101        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA
102        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N
103        || m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R
104        || m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_N
105        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA
106        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
107        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
108        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
109        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
110        || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA
111        || m_nalUnitType == NAL_UNIT_CODED_SLICE_DLP
112        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TFD;
113#else
114    return m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
115        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
116        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA
117        || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRANT
118        || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA
119        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA
120        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TFD
121        || m_nalUnitType == NAL_UNIT_CODED_SLICE;
122#endif
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.