HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TDecConformance.h
Go to the documentation of this file.
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-2017, 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 
38 #ifndef __TDECCONFORMANCE__
39 #define __TDECCONFORMANCE__
40 
41 // This can be enabled externally. Note that this is a PARTIAL CONFORMANCE CHECK - not a full check. More checks may be added later
42 #ifndef DECODER_PARTIAL_CONFORMANCE_CHECK
43 #define DECODER_PARTIAL_CONFORMANCE_CHECK 0
44 #endif
45 
46 
47 
48 #if _MSC_VER > 1000
49 #pragma once
50 #endif // _MSC_VER > 1000
51 
52 #include "TLibCommon/CommonDef.h"
53 #include <stdio.h>
54 #include <iostream>
55 #if DECODER_PARTIAL_CONFORMANCE_CHECK == 2
56 #include <stdlib.h>
57 #endif
58 
59 
60 // Forward declarations
61 class TComSlice;
62 class TComSPS;
63 class TComPPS;
64 class InputNALUnit;
65 class TComPTL;
66 class TComPic;
67 
68 typedef enum TRISTATE
69 {
73 } TRISTATE;
74 
75 
76 typedef enum HBRFACTOREQN
77 {
78  HBR_1 = 0,
81 } HBRFACTOREQN;
82 
83 
85 {
88  UInt maxCpb[Level::NUMBER_OF_TIERS]; // in units of CpbVclFactor or CpbNalFactor bits
93  UInt maxBr[Level::NUMBER_OF_TIERS]; // in units of BrVclFactor or BrNalFactor bits/s
97 };
98 
99 
101 {
115 
120  UInt cpbNalFactor; // currently not used for checking
121  UInt formatCapabilityFactorx1000; // currently not used for checking
122  UInt minCrScaleFactorx10; // currently not used for checking
124 
127  UInt getHbrFactor(Bool bLowerBitRateConstraintFlag) const // currently not used for checking
128  {
129  return hbrFactorEqn==HBR_1_OR_2 ? (2-(bLowerBitRateConstraintFlag?1:0)) :
130  (hbrFactorEqn==HBR_12_OR_24 ? 12*(2-(bLowerBitRateConstraintFlag?1:0)) :
131  1);
132  }
133 };
134 
135 
137 {
138  private:
141  UInt m_hbrFactor; // currently not used for checking
144  public:
146 
147  Void activate(const TComSPS &sps);
148 
149  const ProfileFeatures *getProfileFeatures() const { return m_pProfile; }
151  Level::Tier getTier() const { return m_tier; }
153  Double getMinCr() const { return (m_pLevelTier!=0 && m_pProfile!=0) ? (m_pProfile->minCrScaleFactorx10 * m_pLevelTier->minCrBase[m_tier?1:0])/10.0 : 0.0 ; } // currently not used for checking
155 };
156 
157 
159 {
160 private:
161 #if MCTS_ENC_CHECK
163 #endif
164 #if DECODER_PARTIAL_CONFORMANCE_CHECK
165  UInt m_numberOfSlicesInPicture;
166  UInt64 m_bytesInPicture;
167 #endif
169 
170 public:
171 
172  // Static member functions
173 
174  static inline Bool doChecking()
175  {
177  }
178 
179  static UInt getMinLog2CtbSize(const TComPTL &ptl, UInt layerPlus1=0);
180  static UInt getMaxLog2CtbSize(const TComPTL &ptl, UInt layerPlus1=0);
181 
182 
183 #if DECODER_PARTIAL_CONFORMANCE_CHECK == 0
184  static inline std::ostream &getStream() { return std::cout; }
185 
186  static inline Void finishWarningReport() { }
187 
188  template <class T>
189  static Void checkRange(const T& , const TChar *, const T& , const T& ) { }
190 
191 #else
192 
193 
194  static inline std::ostream &getStream()
195  {
196 #if DECODER_PARTIAL_CONFORMANCE_CHECK == 1
197  std::cout << "WARNING: Conformance failure - ";
198  return std::cout;
199 #else
200  std::cerr << "ERROR: Conformance failure - ";
201  return std::cerr;
202 #endif
203  }
204 
205  static inline Void finishWarningReport()
206  {
207 #if DECODER_PARTIAL_CONFORMANCE_CHECK == 2
208  exit(1);
209 #endif
210  }
211 
212  template <class T>
213  static Void checkRange(const T& val, const TChar *name, const T& minValInclusive, const T& maxValInclusive)
214  {
215  if (val<minValInclusive || val>maxValInclusive)
216  {
217  getStream() << name << " must be in the range of " << minValInclusive << " to " << maxValInclusive << " (inclusive) - decoded value of " << val << "\n";
219  }
220  }
221 
222 #endif
223 
224 
225  // Member functions
226 
228 
229 #if DECODER_PARTIAL_CONFORMANCE_CHECK == 0
230  Void
231  checkSliceActivation(const TComSlice &/*slice*/,
232  const InputNALUnit &/*nalu*/,
233  const TComPic &/*pic*/,
234  const Bool /*bFirstSliceInStream*/,
235  const Bool /*bFirstSliceInSequence*/,
236  const Bool /*bFirstSliceInPicture*/) { }
237 
238  Void
239  checkCtuDecoding(const UInt numUsedBits) { }
240 #else
241  Void
242  checkSliceActivation(const TComSlice &slice,
243  const InputNALUnit &nalu,
244  const TComPic &pic,
245  const Bool bFirstSliceInStream,
246  const Bool bFirstSliceInSequence,
247  const Bool bFirstSliceInPicture);
248 
249  Void
250  checkCtuDecoding(const UInt numUsedBits);
251 #endif
252 
253 #if MCTS_ENC_CHECK
256  Void flagTMctsError(const char *error)
257  {
258  fprintf(stderr, "TMCTS check error: %s\n", error);
259  }
260 #endif
261 };
262 
263 
264 #endif
TRISTATE generalLowerBitRateConstraint
TRISTATE chromaQpOffsetListEnabledFlag
picture class (symbol + YUV buffers)
Definition: TComPic.h:56
Defines version information, constants and small in-line functions.
const LevelTierFeatures * getLevelTierFeatures() const
void Void
Definition: TypeDef.h:203
const LevelTierFeatures * m_pLevelTier
TRISTATE extendedPrecisionProcessingFlag
HBRFACTOREQN
static UInt getMaxLog2CtbSize(const TComPTL &ptl, UInt layerPlus1=0)
Bool generalIntraConstraintFlag
unsigned int UInt
Definition: TypeDef.h:212
TRISTATE cabacBypassAlignmentEnabledFlag
UInt64 getCpbSizeInBits() const
ChromaFormat maxChromaFormat
#define DECODER_PARTIAL_CONFORMANCE_CHECK
0 (default) = do not check conformance. 1 = warn if conformance checks fail. 2 = error and quit if co...
UInt getHbrFactor(Bool bLowerBitRateConstraintFlag) const
Void activate(const TComSPS &sps)
char TChar
Definition: TypeDef.h:206
Bool getTMctsCheck() const
const ProfileFeatures * m_pProfile
Level::Tier getTier() const
static Void checkRange(const T &, const TChar *, const T &, const T &)
static Void finishWarningReport()
static std::ostream & getStream()
ProfileLevelTierFeatures m_activatedFeatures
bool Bool
Definition: TypeDef.h:204
Bool chromaFormatValid(ChromaFormat chFmt) const
PPS class.
Definition: TComSlice.h:1034
Bool generalOnePictureOnlyConstraintFlag
Bool bWavefrontsAndTilesCanBeUsedSimultaneously
HBRFACTOREQN hbrFactorEqn
Void checkSliceActivation(const TComSlice &, const InputNALUnit &, const TComPic &, const Bool, const Bool, const Bool)
static UInt getMinLog2CtbSize(const TComPTL &ptl, UInt layerPlus1=0)
const LevelTierFeatures * pLevelTiersListInfo
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
Definition: TypeDef.h:292
TRISTATE
Name
Definition: TypeDef.h:599
Bool onlyIRAPPictures() const
UInt formatCapabilityFactorx1000
UInt minCrBase[Level::NUMBER_OF_TIERS]
unsigned long long UInt64
Definition: TypeDef.h:233
UInt getMaxRawCtuBits() const
UInt getMaxPicHeightInLumaSamples() const
UInt getMaxPicWidthInLumaSamples() const
Void flagTMctsError(const char *error)
Tier
Definition: TypeDef.h:592
Void enableTMctsCheck(Bool enabled)
Profile::Name profile
UInt maxCpb[Level::NUMBER_OF_TIERS]
double Double
Definition: TypeDef.h:213
UInt maxBr[Level::NUMBER_OF_TIERS]
static Bool doChecking()
slice header class
Definition: TComSlice.h:1225
Void checkCtuDecoding(const UInt numUsedBits)
const TChar * pNameString
const ProfileFeatures * getProfileFeatures() const
TRISTATE generalRExtToolsEnabled
UInt minTileColumnWidthInLumaSamples
SPS class.
Definition: TComSlice.h:740
UInt minTileRowHeightInLumaSamples