source: 3DVCSoftware/branches/HTM-5.1-tests/source/Lib/TLibCommon/NAL.h @ 605

Last change on this file since 605 was 210, checked in by tech, 12 years ago

Reintegrated /branches/HTM-5.0-dev0 rev. 207.

File size: 5.0 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#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
54  unsigned    m_layerId;
55  unsigned    m_temporalId;  ///< temporal_id
56#else
57  Int         m_viewId;      ///< view_id
58  Bool        m_isDepth;     ///< is_depth
59  unsigned    m_temporalId;  ///< temporal_id
60#if !H0388
61  bool        m_OutputFlag;  ///< output_flag
62#endif
63#endif
64
65  /** construct an NALunit structure with given header values. */
66#if H0388
67#if NAL_REF_FLAG
68  NALUnit(
69    NalUnitType nalUnitType,
70    Bool        nalRefFlag,
71#if !VIDYO_VPS_INTEGRATION & !QC_MVHEVC_B0046   
72    Int         viewId,
73    Bool        isDepth,
74#else
75    unsigned    layerId,
76#endif
77    unsigned       temporalId = 0)
78    :m_nalUnitType (nalUnitType)
79    ,m_nalRefFlag  (nalRefFlag)
80#if !VIDYO_VPS_INTEGRATION & !QC_MVHEVC_B0046
81    ,m_viewId      (viewId)
82    ,m_isDepth     (isDepth)
83#else
84    ,m_layerId     (layerId)
85#endif
86    ,m_temporalId  (temporalId)
87  {}
88#else
89  NALUnit(
90    NalUnitType  nalUnitType,
91    NalRefIdc    nalRefIDC,
92    Int          viewId,
93    Bool         isDepth,
94    unsigned temporalID = 0)
95  {
96    m_nalUnitType = nalUnitType;
97    m_nalRefIDC   = nalRefIDC;
98#if !VIDYO_VPS_INTEGRATION
99    m_viewId      = viewId;
100    m_isDepth     = isDepth;
101#else
102    m_layerId = layerId;
103#endif
104    m_temporalId  = temporalID;
105  }
106#endif
107#else
108  NALUnit(
109    NalUnitType  nalUnitType,
110    NalRefIdc    nalRefIDC,
111#if !VIDYO_VPS_INTEGRATION   
112    Int          viewId,
113    Bool         isDepth,
114#else
115    unsigned         layerId,
116#endif
117    unsigned     temporalID = 0,
118    bool         outputFlag = true)
119  {
120    m_nalUnitType = nalUnitType;
121    m_nalRefIDC   = nalRefIDC;
122#if !VIDYO_VPS_INTEGRATION
123    m_viewId      = viewId;
124    m_isDepth     = isDepth;
125#else
126    m_layerId = layerId;
127#endif
128    m_temporalId  = temporalID;
129    m_OutputFlag  = outputFlag;
130  }
131#endif
132
133  /** default constructor - no initialization; must be perfomed by user */
134  NALUnit() {}
135
136  /** returns true if the NALunit is a slice NALunit */
137  bool isSlice()
138  {
139    return m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
140#if H0566_TLA
141#if !QC_REM_IDV_B0046   
142        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDV
143#endif
144        || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA
145        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA
146#else
147        || m_nalUnitType == NAL_UNIT_CODED_SLICE_CDR
148#endif
149        || m_nalUnitType == NAL_UNIT_CODED_SLICE;
150  }
151};
152
153struct OutputNALUnit;
154
155/**
156 * A single NALunit, with complete payload in EBSP format.
157 */
158struct NALUnitEBSP : public NALUnit
159{
160  std::ostringstream m_nalUnitData;
161
162  /**
163   * convert the OutputNALUnit #nalu# into EBSP format by writing out
164   * the NALUnit header, then the rbsp_bytes including any
165   * emulation_prevention_three_byte symbols.
166   */
167  NALUnitEBSP(OutputNALUnit& nalu);
168};
169//! \}
170//! \}
Note: See TracBrowser for help on using the repository browser.