Commit 1a9653ba authored by Karl Sharman's avatar Karl Sharman
Browse files

Added partial decoder conformance checking (currently disabled by default).

parent a2e34fd2
......@@ -50,6 +50,7 @@ OBJS = \
$(OBJ_DIR)/TDecSbac.o \
$(OBJ_DIR)/TDecSlice.o \
$(OBJ_DIR)/TDecTop.o \
$(OBJ_DIR)/TDecConformance.o \
LIBS = -lpthread
......
......@@ -50,6 +50,7 @@ OBJS = \
$(OBJ_DIR)/TDecSbac.o \
$(OBJ_DIR)/TDecSlice.o \
$(OBJ_DIR)/TDecTop.o \
$(OBJ_DIR)/TDecConformance.o \
LIBS = -lpthread
......
......@@ -94,6 +94,8 @@
// Tool Switches
// ====================================================================================================================
// Please also refer to "TDecConformance.h" for DECODER_PARTIAL_CONFORMANCE_CHECK
#define REDUCED_ENCODER_MEMORY 1 ///< When 1, the encoder will allocate TComPic memory when required and release it when no longer required.
#define ADAPTIVE_QP_SELECTION 1 ///< G382: Adaptive reconstruction levels, non-normative part for adaptive QP selection
......@@ -580,6 +582,7 @@ namespace Level
{
MAIN = 0,
HIGH = 1,
NUMBER_OF_TIERS = 2
};
enum Name
......
......@@ -48,94 +48,79 @@
#if ENC_DEC_TRACE
Void SyntaxElementParser::xReadCodeTr (UInt length, UInt& rValue, const TChar *pSymbolName)
Void xTraceAccessUnitDelimiter ()
{
#if RExt__DECODER_DEBUG_BIT_STATISTICS
xReadCode (length, rValue, pSymbolName);
#else
xReadCode (length, rValue);
#endif
fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ );
if (length < 10)
{
fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue );
}
else
{
fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue );
}
fflush ( g_hTrace );
fprintf( g_hTrace, "=========== Access Unit Delimiter ===========\n");
}
Void SyntaxElementParser::xReadUvlcTr (UInt& rValue, const TChar *pSymbolName)
Void xTraceFillerData ()
{
#if RExt__DECODER_DEBUG_BIT_STATISTICS
xReadUvlc (rValue, pSymbolName);
#else
xReadUvlc (rValue);
#endif
fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ );
fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue );
fflush ( g_hTrace );
fprintf( g_hTrace, "=========== Filler Data ===========\n");
}
Void SyntaxElementParser::xReadSvlcTr (Int& rValue, const TChar *pSymbolName)
{
#if RExt__DECODER_DEBUG_BIT_STATISTICS
xReadSvlc (rValue, pSymbolName);
#else
xReadSvlc (rValue);
#endif
fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ );
fprintf( g_hTrace, "%-50s se(v) : %d\n", pSymbolName, rValue );
fflush ( g_hTrace );
}
Void SyntaxElementParser::xReadFlagTr (UInt& rValue, const TChar *pSymbolName)
#if DECODER_PARTIAL_CONFORMANCE_CHECK!=0
Void SyntaxElementParser::xReadCodeChk ( UInt length, UInt& val, const TChar *pSymbolName, const UInt minValIncl, const UInt maxValIncl )
{
#if RExt__DECODER_DEBUG_BIT_STATISTICS
xReadFlag (rValue, pSymbolName);
#else
xReadFlag (rValue);
#endif
fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ );
fprintf( g_hTrace, "%-50s u(1) : %d\n", pSymbolName, rValue );
fflush ( g_hTrace );
READ_CODE(length, val, pSymbolName);
TDecConformanceCheck::checkRange(val, pSymbolName, minValIncl, maxValIncl);
}
Void xTraceAccessUnitDelimiter ()
Void SyntaxElementParser::xReadUvlcChk ( UInt& val, const TChar *pSymbolName, const UInt minValIncl, const UInt maxValIncl )
{
fprintf( g_hTrace, "=========== Access Unit Delimiter ===========\n");
READ_UVLC(val, pSymbolName);
TDecConformanceCheck::checkRange(val, pSymbolName, minValIncl, maxValIncl);
}
Void xTraceFillerData ()
Void SyntaxElementParser::xReadSvlcChk ( Int& val, const TChar *pSymbolName, const Int minValIncl, const Int maxValIncl )
{
fprintf( g_hTrace, "=========== Filler Data ===========\n");
READ_SVLC(val, pSymbolName);
TDecConformanceCheck::checkRange(val, pSymbolName, minValIncl, maxValIncl);
}
Void SyntaxElementParser::xReadFlagChk ( UInt& val, const TChar *pSymbolName, const UInt minValIncl, const UInt maxValIncl )
{
READ_FLAG(val, pSymbolName);
TDecConformanceCheck::checkRange(val, pSymbolName, minValIncl, maxValIncl);
}
#endif
// ====================================================================================================================
// Protected member functions
// ====================================================================================================================
#if RExt__DECODER_DEBUG_BIT_STATISTICS
Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& ruiCode, const TChar *pSymbolName)
#if RExt__DECODER_DEBUG_BIT_STATISTICS || ENC_DEC_TRACE
Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& rValue, const TChar *pSymbolName)
#else
Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& ruiCode)
Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& rValue)
#endif
{
assert ( uiLength > 0 );
m_pcBitstream->read (uiLength, ruiCode);
m_pcBitstream->read (uiLength, rValue);
#if RExt__DECODER_DEBUG_BIT_STATISTICS
TComCodingStatistics::IncrementStatisticEP(pSymbolName, uiLength, ruiCode);
TComCodingStatistics::IncrementStatisticEP(pSymbolName, uiLength, rValue);
#endif
#if ENC_DEC_TRACE
fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ );
if (length < 10)
{
fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue );
}
else
{
fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue );
}
fflush ( g_hTrace );
#endif
}
#if RExt__DECODER_DEBUG_BIT_STATISTICS
Void SyntaxElementParser::xReadUvlc( UInt& ruiVal, const TChar *pSymbolName)
#if RExt__DECODER_DEBUG_BIT_STATISTICS || ENC_DEC_TRACE
Void SyntaxElementParser::xReadUvlc( UInt& rValue, const TChar *pSymbolName)
#else
Void SyntaxElementParser::xReadUvlc( UInt& ruiVal)
Void SyntaxElementParser::xReadUvlc( UInt& rValue)
#endif
{
UInt uiVal = 0;
......@@ -164,16 +149,22 @@ Void SyntaxElementParser::xReadUvlc( UInt& ruiVal)
#endif
}
ruiVal = uiVal;
rValue = uiVal;
#if RExt__DECODER_DEBUG_BIT_STATISTICS
TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), ruiVal);
TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), rValue);
#endif
#if ENC_DEC_TRACE
fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ );
fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue );
fflush ( g_hTrace );
#endif
}
#if RExt__DECODER_DEBUG_BIT_STATISTICS
Void SyntaxElementParser::xReadSvlc( Int& riVal, const TChar *pSymbolName)
#if RExt__DECODER_DEBUG_BIT_STATISTICS || ENC_DEC_TRACE
Void SyntaxElementParser::xReadSvlc( Int& rValue, const TChar *pSymbolName)
#else
Void SyntaxElementParser::xReadSvlc( Int& riVal)
Void SyntaxElementParser::xReadSvlc( Int& rValue)
#endif
{
UInt uiBits = 0;
......@@ -194,29 +185,42 @@ Void SyntaxElementParser::xReadSvlc( Int& riVal)
m_pcBitstream->read( uiLength, uiBits );
uiBits += (1 << uiLength);
riVal = ( uiBits & 1) ? -(Int)(uiBits>>1) : (Int)(uiBits>>1);
rValue = ( uiBits & 1) ? -(Int)(uiBits>>1) : (Int)(uiBits>>1);
#if RExt__DECODER_DEBUG_BIT_STATISTICS
totalLen+=uiLength+uiLength;
#endif
}
else
{
riVal = 0;
rValue = 0;
}
#if RExt__DECODER_DEBUG_BIT_STATISTICS
TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), riVal);
TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), rValue);
#endif
#if ENC_DEC_TRACE
fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ );
fprintf( g_hTrace, "%-50s se(v) : %d\n", pSymbolName, rValue );
fflush ( g_hTrace );
#endif
}
#if RExt__DECODER_DEBUG_BIT_STATISTICS
Void SyntaxElementParser::xReadFlag (UInt& ruiCode, const TChar *pSymbolName)
#if RExt__DECODER_DEBUG_BIT_STATISTICS || ENC_DEC_TRACE
Void SyntaxElementParser::xReadFlag (UInt& rValue, const TChar *pSymbolName)
#else
Void SyntaxElementParser::xReadFlag (UInt& ruiCode)
Void SyntaxElementParser::xReadFlag (UInt& rValue)
#endif
{
m_pcBitstream->read( 1, ruiCode );
m_pcBitstream->read( 1, rValue );
#if RExt__DECODER_DEBUG_BIT_STATISTICS
TComCodingStatistics::IncrementStatisticEP(pSymbolName, 1, Int(ruiCode));
TComCodingStatistics::IncrementStatisticEP(pSymbolName, 1, Int(rValue));
#endif
#if ENC_DEC_TRACE
fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ );
fprintf( g_hTrace, "%-50s u(1) : %d\n", pSymbolName, rValue );
fflush ( g_hTrace );
#endif
}
......
......@@ -43,25 +43,33 @@
#endif // _MSC_VER > 1000
#include "TLibCommon/TComRom.h"
#if ENC_DEC_TRACE
#define READ_CODE(length, code, name) xReadCodeTr ( length, code, name )
#define READ_UVLC( code, name) xReadUvlcTr ( code, name )
#define READ_SVLC( code, name) xReadSvlcTr ( code, name )
#define READ_FLAG( code, name) xReadFlagTr ( code, name )
#include "TDecConformance.h"
#if DECODER_PARTIAL_CONFORMANCE_CHECK!=0
#define READ_CODE_CHK(length, code, name, minValIncl, maxValIncl) xReadCodeChk ( length, code, name, minValIncl, maxValIncl )
#define READ_UVLC_CHK( code, name, minValIncl, maxValIncl) xReadUvlcChk ( code, name, minValIncl, maxValIncl )
#define READ_SVLC_CHK( code, name, minValIncl, maxValIncl) xReadSvlcChk ( code, name, minValIncl, maxValIncl )
#define READ_FLAG_CHK( code, name, minValIncl, maxValIncl) xReadFlagChk ( code, name, minValIncl, maxValIncl )
#elif RExt__DECODER_DEBUG_BIT_STATISTICS || ENC_DEC_TRACE
#define READ_CODE_CHK(length, code, name, minValIncl, maxValIncl) xReadCode ( length, code, name )
#define READ_UVLC_CHK( code, name, minValIncl, maxValIncl) xReadUvlc ( code, name )
#define READ_SVLC_CHK( code, name, minValIncl, maxValIncl) xReadSvlc ( code, name )
#define READ_FLAG_CHK( code, name, minValIncl, maxValIncl) xReadFlag ( code, name )
#else
#define READ_CODE_CHK(length, code, name, minValIncl, maxValIncl) xReadCode ( length, code )
#define READ_UVLC_CHK( code, name, minValIncl, maxValIncl) xReadUvlc ( code )
#define READ_SVLC_CHK( code, name, minValIncl, maxValIncl) xReadSvlc ( code )
#define READ_FLAG_CHK( code, name, minValIncl, maxValIncl) xReadFlag ( code )
#endif
#if RExt__DECODER_DEBUG_BIT_STATISTICS
#if RExt__DECODER_DEBUG_BIT_STATISTICS || ENC_DEC_TRACE
#define READ_CODE(length, code, name) xReadCode ( length, code, name )
#define READ_UVLC( code, name) xReadUvlc ( code, name )
#define READ_SVLC( code, name) xReadSvlc ( code, name )
#define READ_FLAG( code, name) xReadFlag ( code, name )
#else
#define READ_CODE(length, code, name) xReadCode ( length, code )
#define READ_UVLC( code, name) xReadUvlc ( code )
#define READ_SVLC( code, name) xReadSvlc ( code )
......@@ -69,8 +77,6 @@
#endif
#endif
//! \ingroup TLibDecoder
//! \{
......@@ -88,7 +94,14 @@ protected:
{};
virtual ~SyntaxElementParser() {};
#if RExt__DECODER_DEBUG_BIT_STATISTICS
#if DECODER_PARTIAL_CONFORMANCE_CHECK!=0
Void xReadCodeChk ( UInt length, UInt& val, const TChar *pSymbolName, const UInt minValIncl, const UInt maxValIncl );
Void xReadUvlcChk ( UInt& val, const TChar *pSymbolName, const UInt minValIncl, const UInt maxValIncl );
Void xReadSvlcChk ( Int& val, const TChar *pSymbolName, const Int minValIncl, const Int maxValIncl );
Void xReadFlagChk ( UInt& val, const TChar *pSymbolName, const UInt minValIncl, const UInt maxValIncl );
#endif
#if RExt__DECODER_DEBUG_BIT_STATISTICS || ENC_DEC_TRACE
Void xReadCode ( UInt length, UInt& val, const TChar *pSymbolName );
Void xReadUvlc ( UInt& val, const TChar *pSymbolName );
Void xReadSvlc ( Int& val, const TChar *pSymbolName );
......@@ -99,12 +112,6 @@ protected:
Void xReadSvlc ( Int& val );
Void xReadFlag ( UInt& val );
#endif
#if ENC_DEC_TRACE
Void xReadCodeTr (UInt length, UInt& rValue, const TChar *pSymbolName);
Void xReadUvlcTr ( UInt& rValue, const TChar *pSymbolName);
Void xReadSvlcTr ( Int& rValue, const TChar *pSymbolName);
Void xReadFlagTr ( UInt& rValue, const TChar *pSymbolName);
#endif
public:
Void setBitstream ( TComInputBitstream* p ) { m_pcBitstream = p; }
TComInputBitstream* getBitstream() { return m_pcBitstream; }
......
......@@ -42,6 +42,7 @@
#if RExt__DECODER_DEBUG_BIT_STATISTICS
#include "TLibCommon/TComCodingStatistics.h"
#endif
#include "TDecConformance.h"
//! \ingroup TLibDecoder
//! \{
......@@ -192,11 +193,11 @@ Void TDecCavlc::parsePPS(TComPPS* pcPPS)
Int iCode;
READ_UVLC( uiCode, "pps_pic_parameter_set_id");
READ_UVLC_CHK( uiCode, "pps_pic_parameter_set_id", 0, 63);
assert(uiCode <= 63);
pcPPS->setPPSId (uiCode);
READ_UVLC( uiCode, "pps_seq_parameter_set_id");
READ_UVLC_CHK( uiCode, "pps_seq_parameter_set_id", 0, 15);
assert(uiCode <= 15);
pcPPS->setSPSId (uiCode);
......@@ -210,15 +211,15 @@ Void TDecCavlc::parsePPS(TComPPS* pcPPS)
READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false );
READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1");
READ_UVLC_CHK(uiCode, "num_ref_idx_l0_default_active_minus1", 0, 14);
assert(uiCode <= 14);
pcPPS->setNumRefIdxL0DefaultActive(uiCode+1);
READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1");
READ_UVLC_CHK(uiCode, "num_ref_idx_l1_default_active_minus1", 0, 14);
assert(uiCode <= 14);
pcPPS->setNumRefIdxL1DefaultActive(uiCode+1);
READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode);
READ_SVLC_CHK(iCode, "init_qp_minus26", std::numeric_limits<Int>::min(), 25 ); pcPPS->setPicInitQPMinus26(iCode);
READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false );
READ_FLAG( uiCode, "transform_skip_enabled_flag" );
pcPPS->setUseTransformSkip ( uiCode ? true : false );
......@@ -233,12 +234,12 @@ Void TDecCavlc::parsePPS(TComPPS* pcPPS)
{
pcPPS->setMaxCuDQPDepth( 0 );
}
READ_SVLC( iCode, "pps_cb_qp_offset");
READ_SVLC_CHK( iCode, "pps_cb_qp_offset", -12, 12);
pcPPS->setQpOffset(COMPONENT_Cb, iCode);
assert( pcPPS->getQpOffset(COMPONENT_Cb) >= -12 );
assert( pcPPS->getQpOffset(COMPONENT_Cb) <= 12 );
READ_SVLC( iCode, "pps_cr_qp_offset");
READ_SVLC_CHK( iCode, "pps_cr_qp_offset", -12, 12);
pcPPS->setQpOffset(COMPONENT_Cr, iCode);
assert( pcPPS->getQpOffset(COMPONENT_Cr) >= -12 );
assert( pcPPS->getQpOffset(COMPONENT_Cr) <= 12 );
......@@ -373,16 +374,16 @@ Void TDecCavlc::parsePPS(TComPPS* pcPPS)
{
READ_UVLC(uiCode, "diff_cu_chroma_qp_offset_depth"); ppsRangeExtension.setDiffCuChromaQpOffsetDepth(uiCode);
UInt tableSizeMinus1 = 0;
READ_UVLC(tableSizeMinus1, "chroma_qp_offset_list_len_minus1");
READ_UVLC_CHK(tableSizeMinus1, "chroma_qp_offset_list_len_minus1", 0, MAX_QP_OFFSET_LIST_SIZE-1);
assert(tableSizeMinus1 < MAX_QP_OFFSET_LIST_SIZE);
for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx <= (tableSizeMinus1); cuChromaQpOffsetIdx++)
{
Int cbOffset;
Int crOffset;
READ_SVLC(cbOffset, "cb_qp_offset_list[i]");
READ_SVLC_CHK(cbOffset, "cb_qp_offset_list[i]", -12, 12);
assert(cbOffset >= -12 && cbOffset <= 12);
READ_SVLC(crOffset, "cr_qp_offset_list[i]");
READ_SVLC_CHK(crOffset, "cr_qp_offset_list[i]", -12, 12);
assert(crOffset >= -12 && crOffset <= 12);
// table uses +1 for index (see comment inside the function)
ppsRangeExtension.setChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1, cbOffset, crOffset);
......@@ -593,42 +594,49 @@ Void TDecCavlc::parseSPS(TComSPS* pcSPS)
#endif
UInt uiCode;
READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode );
READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 );
READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode );
READ_CODE_CHK( 3, uiCode, "sps_max_sub_layers_minus1", 0, 6 ); pcSPS->setMaxTLayers ( uiCode+1 );
assert(uiCode <= 6);
READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );
if ( pcSPS->getMaxTLayers() == 1 )
{
// sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0
TDecConformanceCheck::checkRange(uiCode, "sps_temporal_id_nesting_flag", 1U, 1U);
assert( uiCode == 1 );
}
parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode );
READ_UVLC_CHK( uiCode, "sps_seq_parameter_set_id", 0, 15 ); pcSPS->setSPSId( uiCode );
assert(uiCode <= 15);
READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) );
READ_UVLC_CHK( uiCode, "chroma_format_idc", 0, 3 ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) );
assert(uiCode <= 3);
if( pcSPS->getChromaFormatIdc() == CHROMA_444 )
{
READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0);
READ_FLAG_CHK( uiCode, "separate_colour_plane_flag", 0, 0);
assert(uiCode == 0);
}
READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode );
READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode );
// pic_width_in_luma_samples and pic_height_in_luma_samples needs conformance checking - multiples of MinCbSizeY
READ_UVLC_CHK ( uiCode, "pic_width_in_luma_samples", 1, std::numeric_limits<UInt>::max() ); pcSPS->setPicWidthInLumaSamples ( uiCode );
READ_UVLC_CHK ( uiCode, "pic_height_in_luma_samples", 1, std::numeric_limits<UInt>::max() ); pcSPS->setPicHeightInLumaSamples( uiCode );
READ_FLAG( uiCode, "conformance_window_flag");
if (uiCode != 0)
{
Window &conf = pcSPS->getConformanceWindow();
READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
const UInt subWidthC = TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() );
const UInt subHeightC = TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() );
READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * subWidthC );
READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * subWidthC );
READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * subHeightC );
READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * subHeightC );
TDecConformanceCheck::checkRange<UInt>(conf.getWindowLeftOffset()+conf.getWindowRightOffset(), "conformance window width in pixels", 0, pcSPS->getPicWidthInLumaSamples()-1);
}
READ_UVLC( uiCode, "bit_depth_luma_minus8" );
READ_UVLC_CHK( uiCode, "bit_depth_luma_minus8", 0, 8 );
assert(uiCode <= 8);
#if O0043_BEST_EFFORT_DECODING
pcSPS->setStreamBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode);
const UInt forceDecodeBitDepth = pcSPS->getForceDecodeBitDepth();
......@@ -636,8 +644,8 @@ Void TDecCavlc::parseSPS(TComSPS* pcSPS)
{
uiCode = forceDecodeBitDepth - 8;
}
#endif
assert(uiCode <= 8);
#endif
pcSPS->setBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode);
#if O0043_BEST_EFFORT_DECODING
......@@ -646,15 +654,16 @@ Void TDecCavlc::parseSPS(TComSPS* pcSPS)
pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*uiCode) );
#endif
READ_UVLC( uiCode, "bit_depth_chroma_minus8" );
READ_UVLC_CHK( uiCode, "bit_depth_chroma_minus8", 0, 8 );
assert(uiCode <= 8);
#if O0043_BEST_EFFORT_DECODING
pcSPS->setStreamBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode);
if (forceDecodeBitDepth != 0)
{
uiCode = forceDecodeBitDepth - 8;
}
#endif
assert(uiCode <= 8);
#endif
pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode);
#if O0043_BEST_EFFORT_DECODING
pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*(pcSPS->getStreamBitDepth(CHANNEL_TYPE_CHROMA)-8)) );
......@@ -662,8 +671,7 @@ Void TDecCavlc::parseSPS(TComSPS* pcSPS)
pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*uiCode) );
#endif
READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode );
assert(uiCode <= 12);
READ_UVLC_CHK( uiCode, "log2_max_pic_order_cnt_lsb_minus4", 0, 12 ); pcSPS->setBitsForPOC( 4 + uiCode );
UInt subLayerOrderingInfoPresentFlag;
READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag");
......@@ -689,29 +697,39 @@ Void TDecCavlc::parseSPS(TComSPS* pcSPS)
}
}
READ_UVLC( uiCode, "log2_min_luma_coding_block_size_minus3" );
Int log2MinCUSize = uiCode + 3;
pcSPS->setLog2MinCodingBlockSize(log2MinCUSize);
READ_UVLC( uiCode, "log2_diff_max_min_luma_coding_block_size" );
const UInt maxLog2CtbSize = TDecConformanceCheck::getMaxLog2CtbSize(*(pcSPS->getPTL()));
const UInt minLog2CtbSize = TDecConformanceCheck::getMinLog2CtbSize(*(pcSPS->getPTL()));
READ_UVLC_CHK( uiCode, "log2_min_luma_coding_block_size_minus3", 0, maxLog2CtbSize-3 );
assert(uiCode <= maxLog2CtbSize-3);
Int minCbLog2SizeY = uiCode + 3;
pcSPS->setLog2MinCodingBlockSize(minCbLog2SizeY);
// Difference + log2MinCUSize must be <= maxLog2CtbSize
// Difference + log2MinCUSize must be >= minLog2CtbSize
const UInt minLog2DiffMaxMinLumaCodingBlockSize = minLog2CtbSize < minCbLog2SizeY ? 0 : minLog2CtbSize - minCbLog2SizeY;
const UInt maxLog2DiffMaxMinLumaCodingBlockSize = maxLog2CtbSize - minCbLog2SizeY;
READ_UVLC_CHK( uiCode, "log2_diff_max_min_luma_coding_block_size", minLog2DiffMaxMinLumaCodingBlockSize, maxLog2DiffMaxMinLumaCodingBlockSize);
assert(uiCode >= minLog2DiffMaxMinLumaCodingBlockSize && uiCode <= maxLog2DiffMaxMinLumaCodingBlockSize);
pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode);
if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5)
{
assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5);
}
Int maxCUDepthDelta = uiCode;
pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) );
pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) );
READ_UVLC( uiCode, "log2_min_luma_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 );
READ_UVLC( uiCode, "log2_diff_max_min_luma_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() );
const Int maxCUDepthDelta = uiCode;
const Int ctbLog2SizeY = minCbLog2SizeY + maxCUDepthDelta;
pcSPS->setMaxCUWidth ( 1<<ctbLog2SizeY );
pcSPS->setMaxCUHeight ( 1<<ctbLog2SizeY );
READ_UVLC_CHK( uiCode, "log2_min_luma_transform_block_size_minus2", 0, minCbLog2SizeY-1-2 );
const UInt minTbLog2SizeY = uiCode + 2;
pcSPS->setQuadtreeTULog2MinSize( minTbLog2SizeY );
// log2_diff <= Min(CtbLog2SizeY, 5) - minTbLog2SizeY
READ_UVLC_CHK( uiCode, "log2_diff_max_min_luma_transform_block_size", 0, min<UInt>(5U, ctbLog2SizeY) - minTbLog2SizeY );
pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() );
pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) );
READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 );
READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 );
READ_UVLC_CHK( uiCode, "max_transform_hierarchy_depth_inter", 0, ctbLog2SizeY - minTbLog2SizeY); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 );
READ_UVLC_CHK( uiCode, "max_transform_hierarchy_depth_intra", 0, ctbLog2SizeY - minTbLog2SizeY); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 );
Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() );
Int addCuDepth = max (0, minCbLog2SizeY - (Int)pcSPS->getQuadtreeTULog2MinSize() );
pcSPS->setMaxTotalCUDepth( maxCUDepthDelta + addCuDepth + getMaxCUDepthOffset(pcSPS->getChromaFormatIdc(), pcSPS->getQuadtreeTULog2MinSize()) );
READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode );
......@@ -729,14 +747,22 @@ Void TDecCavlc::parseSPS(TComSPS* pcSPS)
READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false );
if( pcSPS->getUsePCM() )
{
READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_LUMA, 1 + uiCode );
READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_CHROMA, 1 + uiCode );
READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3);
READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() );
#if O0043_BEST_EFFORT_DECODING
READ_CODE_CHK( 4, uiCode, "pcm_sample_bit_depth_luma_minus1", 0, pcSPS->getStreamBitDepth(CHANNEL_TYPE_LUMA) ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_LUMA, 1 + uiCode );
READ_CODE_CHK( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1", 0, pcSPS->getStreamBitDepth(CHANNEL_TYPE_LUMA) ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_CHROMA, 1 + uiCode );
#else
READ_CODE_CHK( 4, uiCode, "pcm_sample_bit_depth_luma_minus1", 0, pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_LUMA, 1 + uiCode );
READ_CODE_CHK( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1", 0, pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA) ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_CHROMA, 1 + uiCode );
#endif
READ_UVLC_CHK( uiCode, "log2_min_pcm_luma_coding_block_size_minus3", std::min<UInt>(minCbLog2SizeY, 5 )-3, std::min<UInt>(ctbLog2SizeY, 5)-3);
const UInt log2MinIpcmCbSizeY = uiCode+3;
pcSPS->setPCMLog2MinSize (log2MinIpcmCbSizeY);
READ_UVLC_CHK( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size", 0, (std::min<UInt>(ctbLog2SizeY,5) - log2MinIpcmCbSizeY) );
pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinS