Commit 5547da95 authored by jamesxxiu's avatar jamesxxiu

sync to master

parent cff4f429
...@@ -70,9 +70,11 @@ if( OpenMP_FOUND ) ...@@ -70,9 +70,11 @@ if( OpenMP_FOUND )
endif() endif()
# Enable warnings for some generators and toolsets. # Enable warnings for some generators and toolsets.
bb_enable_warnings( gcc warnings-as-errors -Wno-sign-compare ) # bb_enable_warnings( gcc warnings-as-errors -Wno-sign-compare )
# bb_enable_warnings( gcc -Wno-unused-variable ) # bb_enable_warnings( gcc -Wno-unused-variable )
# bb_enable_warnings( gcc-4.8 warnings-as-errors -Wno-unused-variable ) # bb_enable_warnings( gcc-4.8 warnings-as-errors -Wno-unused-variable )
# for gcc 8.2:
bb_enable_warnings( gcc warnings-as-errors -Wno-sign-compare -Wno-class-memaccess)
if( XCODE ) if( XCODE )
bb_enable_warnings( clang warnings-as-errors bb_enable_warnings( clang warnings-as-errors
...@@ -104,6 +106,7 @@ endif() ...@@ -104,6 +106,7 @@ endif()
if( MSVC ) if( MSVC )
add_compile_options( "/MP" ) add_compile_options( "/MP" )
add_compile_options( "/EHsc" ) add_compile_options( "/EHsc" )
add_compile_options( "/MT" )
endif() endif()
# set address sanitizer compiler arguments # set address sanitizer compiler arguments
......
...@@ -104,16 +104,21 @@ MTT : 1 ...@@ -104,16 +104,21 @@ MTT : 1
EMT : 3 EMT : 3
EMTFast : 3 EMTFast : 3
NSST : 1
Affine : 1 Affine : 1
HighPrecMv : 1 HighPrecMv : 1
ALF : 1
SubPuMvp : 1 SubPuMvp : 1
MaxNumMergeCand : 6 MaxNumMergeCand : 6
LMChroma : 1 LMChroma : 1
DMVR : 1
IMV : 2
DepQuant : 1 DepQuant : 1
IMV : 2
ALF : 1
NSST : 1
CPR : 1
DMVR : 1
GBi : 1
GBiFast : 1
# Fast tools # Fast tools
PBIntraFast : 1 PBIntraFast : 1
......
...@@ -106,13 +106,11 @@ EMT : 1 ...@@ -106,13 +106,11 @@ EMT : 1
EMTFast : 1 EMTFast : 1
Affine : 1 Affine : 1
HighPrecMv : 1 HighPrecMv : 1
SubPuMvp : 1 SubPuMvp : 1
MaxNumMergeCand : 6 MaxNumMergeCand : 6
LMChroma : 1 # use CCLM only LMChroma : 1 # use CCLM only
DepQuant : 1 DepQuant : 1
IMV : 2 IMV : 2
ALF : 1 ALF : 1
# Fast tools # Fast tools
......
...@@ -120,16 +120,21 @@ MTT : 1 ...@@ -120,16 +120,21 @@ MTT : 1
EMT : 3 EMT : 3
EMTFast : 3 EMTFast : 3
NSST : 1
Affine : 1 Affine : 1
HighPrecMv : 1 HighPrecMv : 1
ALF : 1
SubPuMvp : 1 SubPuMvp : 1
MaxNumMergeCand : 6 MaxNumMergeCand : 6
LMChroma : 1 LMChroma : 1
DMVR : 1
IMV : 2
DepQuant : 1 DepQuant : 1
IMV : 2
ALF : 1
NSST : 1
CPR : 1
DMVR : 1
GBi : 1
GBiFast : 1
# Fast tools # Fast tools
PBIntraFast : 1 PBIntraFast : 1
......
...@@ -122,13 +122,11 @@ EMT : 1 ...@@ -122,13 +122,11 @@ EMT : 1
EMTFast : 1 EMTFast : 1
Affine : 1 Affine : 1
HighPrecMv : 1 HighPrecMv : 1
SubPuMvp : 1 SubPuMvp : 1
MaxNumMergeCand : 6 MaxNumMergeCand : 6
LMChroma : 1 # use CCLM only LMChroma : 1 # use CCLM only
DepQuant : 1 DepQuant : 1
IMV : 2 IMV : 2
ALF : 1 ALF : 1
# Fast tools # Fast tools
......
...@@ -120,16 +120,21 @@ MTT : 1 ...@@ -120,16 +120,21 @@ MTT : 1
EMT : 3 EMT : 3
EMTFast : 3 EMTFast : 3
NSST : 1
Affine : 1 Affine : 1
HighPrecMv : 1 HighPrecMv : 1
ALF : 1
SubPuMvp : 1 SubPuMvp : 1
MaxNumMergeCand : 6 MaxNumMergeCand : 6
LMChroma : 1 LMChroma : 1
DMVR : 1
IMV : 2
DepQuant : 1 DepQuant : 1
IMV : 2
ALF : 1
NSST : 1
CPR : 1
DMVR : 1
GBi : 1
GBiFast : 1
# Fast tools # Fast tools
PBIntraFast : 1 PBIntraFast : 1
......
...@@ -122,13 +122,11 @@ EMT : 1 ...@@ -122,13 +122,11 @@ EMT : 1
EMTFast : 1 EMTFast : 1
Affine : 1 Affine : 1
HighPrecMv : 1 HighPrecMv : 1
SubPuMvp : 1 SubPuMvp : 1
MaxNumMergeCand : 6 MaxNumMergeCand : 6
LMChroma : 1 # use CCLM only LMChroma : 1 # use CCLM only
DepQuant : 1 DepQuant : 1
IMV : 2 IMV : 2
ALF : 1 ALF : 1
# Fast tools # Fast tools
......
...@@ -134,18 +134,23 @@ MTT : 1 ...@@ -134,18 +134,23 @@ MTT : 1
EMT : 3 EMT : 3
EMTFast : 3 EMTFast : 3
NSST : 1
Affine : 1 Affine : 1
HighPrecMv : 1 HighPrecMv : 1
ALF : 1
SubPuMvp : 1 SubPuMvp : 1
MaxNumMergeCand : 6 MaxNumMergeCand : 6
LMChroma : 1 LMChroma : 1
DMVR : 1
IMV : 2
DepQuant : 1 DepQuant : 1
IMV : 2
ALF : 1
NSST : 1
CPR : 1
DMVR : 1
BIO : 1 BIO : 1
GBi : 1
GBiFast : 1
# Fast tools # Fast tools
PBIntraFast : 1 PBIntraFast : 1
FastMrg : 1 FastMrg : 1
......
...@@ -136,13 +136,11 @@ EMT : 1 ...@@ -136,13 +136,11 @@ EMT : 1
EMTFast : 1 EMTFast : 1
Affine : 1 Affine : 1
HighPrecMv : 1 HighPrecMv : 1
SubPuMvp : 1 SubPuMvp : 1
MaxNumMergeCand : 6 MaxNumMergeCand : 6
LMChroma : 1 # use CCLM only LMChroma : 1 # use CCLM only
DepQuant : 1 DepQuant : 1
IMV : 2 IMV : 2
ALF : 1 ALF : 1
# Fast tools # Fast tools
...@@ -150,7 +148,6 @@ PBIntraFast : 1 ...@@ -150,7 +148,6 @@ PBIntraFast : 1
FastMrg : 1 FastMrg : 1
AMaxBT : 1 AMaxBT : 1
### DO NOT ADD ANYTHING BELOW THIS LINE ### ### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ### ### DO NOT DELETE THE EMPTY LINE BELOW ###
# ignore these Latex files
jctvcdoc.cls
*.aux
*.log
*.lot
*.out
*.toc
*~
No preview for this file type
...@@ -3021,4 +3021,226 @@ If the decoder is compiled with the macro RExt__DECODER_DEBUG_BIT_STATISTICS def ...@@ -3021,4 +3021,226 @@ If the decoder is compiled with the macro RExt__DECODER_DEBUG_BIT_STATISTICS def
The Linux makefile will compile both the analyser and standard version when the `all' or `everything' target is used (where the latter will also build high-bit-depth executables). The Linux makefile will compile both the analyser and standard version when the `all' or `everything' target is used (where the latter will also build high-bit-depth executables).
\section{Block statistics extension}
\label{sec:block-stat-extens}
The block statistics extension enables straightforward visualization and statistical analysis of coding tool
usage in encoded bitstreams. The extension enables the reference
software encoder and decoder to write out statistics files in a configurable
way, which in turn can be loaded into a suitable YUV player for overlay of the
reconstructed YUV sequence, or can be used for statistical analysis at a
selectable scope (e.g. block/picture/sequence level). An example implementation
for such visualization is available with the open-source YUView player
(https://github.com/IENT/YUView).
\subsection{Usage}
\label{sec:usage}
The software has to be compiled with the macros ENABLE_TRACING and
K0149_BLOCK_STATISTICS defined as 1. The statistics can be written by either
encoder or decoder.
The extension adds additional trace channels to the ``dtrace'' functionality of
the software. The following trace channels were added:
\begin{description}
\item[D_BLOCK_STATISTICS_ALL] All syntax elements are written, no matter whether
they are actually encoded or derived.
\item[D_BLOCK_STATISTICS_CODED] Tries to write only syntax elements, which have
also been encoded.
\end{description}
The following additional encoder options are available (part of ``dtrace''). See
the file dtrace_next.h for more details.
\begin{OptionTableNoShorthand}{Decoder options}{tab:decoder-block-statistics}
\Option{TraceFile} &
%\ShortOption{\None} &
\Default{\None} &
File name of the produced trace file.
\\
\Option{TraceRule} &
%\ShortOption{-b} &
\Default{\NotSet} &
Specifies which traces should be saved, and for which POCs.
\\
\end{OptionTableNoShorthand}
Concrete examples of calls for generating a block statistics file are:
\begin{verbatim}
bin/DecoderAppStatic -b str/BasketballDrive_1920x1080_QP37.vvc \
--TraceFile="stats/BasketballDrive_1920x1080_QP37_coded.vtmbmsstats" \
--TraceRule="D_BLOCK_STATISTICS_CODED:poc>=0"
bin/DecoderAppStatic -b str/BasketballDrive_1920x1080_QP37.vvc \
--TraceFile="stats/BasketballDrive_1920x1080_QP37_all.vtmbmsstats" \
--TraceRule="D_BLOCK_STATISTICS_ALL:poc>=0"
\end{verbatim}
\subsection{Block statistics file formats}
\label{sec:block-stat-file}
The trace file will contain a header listing information of all available block
statistics. For each statistic it lists a type and a scale for vectors or range
for integers if applicable:
\begin{verbatim}
# VTMBMS Block Statistics
# Sequence size: [832x 480]
# Block Statistic Type: PredMode; Flag;
# Block Statistic Type: MergeFlag; Flag;
# Block Statistic Type: MVL0; Vector; Scale: 4
# Block Statistic Type: MVL1; Vector; Scale: 4
# Block Statistic Type: IPCM; Flag;
# Block Statistic Type: Y_IntraMode; Integer; [0, 73]
# Block Statistic Type: Cb_IntraMode; Integer; [0, 73]
\end{verbatim}
Two formats are available for the statistics for each block, a human readable
format and a CSV based format. The header remains the same for both cases.
For both formats each row contains the information for one block statistic. The
order of the data is: picture order count (POC), location of top left corner of
the block, size of the block, name of the statistic, and value of the
statistic.
The macro BLOCK_STATS_AS_CSV is available in order to choose the required format.
The human readable format can also be easily processed with other software, for
example YUView, using regular expressions. The CSV based formats provides the
universal interface required by spreadsheet applications.
The human readable format is based on the format used for the other dtrace
statistics. Some examples for this format are:
\begin{verbatim}
BlockStat: POC 16 @( 112, 0) [ 8x 8] SkipFlag=1
BlockStat: POC 16 @( 112, 0) [ 8x 8] InterDir=1
BlockStat: POC 16 @( 112, 0) [ 8x 8] MergeFlag=1
BlockStat: POC 16 @( 112, 0) [ 8x 8] MergeIdx=0
BlockStat: POC 16 @( 112, 0) [ 8x 8] MergeType=0
BlockStat: POC 16 @( 112, 0) [ 8x 8] MVPIdxL0=255
BlockStat: POC 16 @( 112, 0) [ 8x 8] MVPNumL0=255
BlockStat: POC 16 @( 112, 0) [ 8x 8] RefIdxL0=0
BlockStat: POC 16 @( 112, 0) [ 8x 8] MVDL0={ 0, 0}
BlockStat: POC 16 @( 112, 0) [ 8x 8] MVL0={ -70, 18}
BlockStat: POC 16 @( 112, 8) [ 8x 8] PredMode=0
BlockStat: POC 16 @( 112, 8) [ 8x 8] PartSize=0
\end{verbatim}
Some examples of the CSV based format are:
\begin{verbatim}
BlockStat;16; 112; 0; 8; 8;SkipFlag;1
BlockStat;16; 112; 0; 8; 8;InterDir;1
BlockStat;16; 112; 0; 8; 8;MergeFlag;1
BlockStat;16; 112; 0; 8; 8;MergeIdx;0
BlockStat;16; 112; 0; 8; 8;MergeType;0
BlockStat;16; 112; 0; 8; 8;MVPIdxL0;255
BlockStat;16; 112; 0; 8; 8;MVPNumL0;255
BlockStat;16; 112; 0; 8; 8;RefIdxL0;0
BlockStat;16; 112; 0; 8; 8;MVDL0; 0; 0
BlockStat;16; 112; 0; 8; 8;MVL0; -70; 18
BlockStat;16; 112; 8; 8; 8;PredMode;0
BlockStat;16; 112; 8; 8; 8;PartSize;0
\end{verbatim}
\subsection{Visualization}
\label{sec:visualization}
The block statistics can be viewed with YUView, which is freely available under
GPLv3: \url{https://github.com/IENT/YUView}. The latest releases and the master
branch have the functionality required for viewing the block statistics. YUView
assumes that the file extension of block statistics file is
“.vtmbmsstats”. However, if a file is not recognized you can choose from a list
of supported file formats.
Statistics can be overlaid with YUV sequences. Some example snapshots are:
\begin{figure}[htpb]
\centering
\includegraphics[width=0.8\linewidth]{figures/YUView}
\caption{YUView}
\label{fig:yuview}
\end{figure}
\begin{figure}[htpb]
\centering
\includegraphics[width=0.5\linewidth]{figures/raceHorsesShot2MotionVectors}
\caption{Motion vectors}
\label{fig:motion-vectors}
\end{figure}
\begin{figure}[htpb]
\centering
\includegraphics[width=0.5\linewidth]{figures/raceHorsesShot3SkipFlag}
\caption{Skip flag}
\label{fig:skip-flag}
\end{figure}
\subsection{Adding statistics}
\label{sec:adding-statistics}
In order to add further block statistics, do the following:
\begin{description}
\item[source/Lib/CommonLib/dtrace_blockstatistics.h]
Add your statistic to the BlockStatistic enum:
\begin{verbatim}
enum class BlockStatistic {
// general
PredMode,
PartSize,
Depth,
\end{verbatim}
Further, add your statistic to the map blockstatistic2description:
\begin{verbatim}
static const std::map<BlockStatistic,
std::tuple<std::string, BlockStatisticType, std::string>>
blockstatistic2description =
{
{ BlockStatistic::PredMode,
std::tuple<std::string, BlockStatisticType, std::string>
{"PredMode", BlockStatisticType::Flag, ""}},
{ BlockStatistic::MergeFlag,
std::tuple<std::string, BlockStatisticType, std::string>
{"MergeFlag", BlockStatisticType::Flag, ""}},
{ BlockStatistic::MVL0,
std::tuple<std::string, BlockStatisticType, std::string>
{"MVL0", BlockStatisticType::Vector, "Scale: 4"}},
YOURS
\end{verbatim}
\item[source/Lib/CommonLib/dtrace_blockstatistics.cpp] All code for
writing syntax elements is kept in this file in
getAndStoreBlockStatistics. This function is called once for each
CTU, after it has been en/decoded. The following macros have been
defined to facilitate writing of block statistics:
\begin{verbatim}
DTRACE_BLOCK_SCALAR(ctx,channel,cs_cu_pu,stat_type,val)
DTRACE_BLOCK_SCALAR_CHROMA(ctx,channel,cs_cu_pu,stat_type,val)
DTRACE_BLOCK_VECTOR(ctx,channel,cu_pu,stat_type,v_x,v_y)
DTRACE_BLOCK_AFFINETF(ctx,channel,pu,stat_type,v_x0,v_y0,v_x1,v_y1,v_x2,v_y2)
\end{verbatim}
An example:
\begin{verbatim}
DTRACE_BLOCK_SCALAR(g_trace_ctx, D_BLOCK_STATISTICS_ALL,
cu, GetBlockStatisticName(BlockStatistic::PredMode), cu.predMode);
\end{verbatim}
\item[Block statistics for debugging] The statistics can also be used
to write out other data, not just syntax elements. Add your
statistics to dtrace_blockstatistics.h. Where it should be used the
following headers have to be included:
\begin{verbatim}
#include "dtrace_next.h"
#include "dtrace_blockstatistics.h"
\end{verbatim}
\end{description}
\end{document} \end{document}
...@@ -121,6 +121,10 @@ uint32_t DecApp::decode() ...@@ -121,6 +121,10 @@ uint32_t DecApp::decode()
* requires the DecApp::decode() method to be called again with the same * requires the DecApp::decode() method to be called again with the same
* nal unit. */ * nal unit. */
#if RExt__DECODER_DEBUG_STATISTICS #if RExt__DECODER_DEBUG_STATISTICS
CodingStatistics& stat = CodingStatistics::GetSingletonInstance();
CHECK(m_statMode < STATS__MODE_NONE || m_statMode > STATS__MODE_ALL, "Wrong coding statistics output mode");
stat.m_mode = m_statMode;
CodingStatistics::CodingStatisticsData* backupStats = new CodingStatistics::CodingStatisticsData(CodingStatistics::GetStatistics()); CodingStatistics::CodingStatisticsData* backupStats = new CodingStatistics::CodingStatisticsData(CodingStatistics::GetStatistics());
#endif #endif
...@@ -210,6 +214,11 @@ uint32_t DecApp::decode() ...@@ -210,6 +214,11 @@ uint32_t DecApp::decode()
} }
} }
if (m_packedYUVMode && (m_outputBitDepth[CH_L] != 10 && m_outputBitDepth[CH_L] != 12))
{
EXIT ("Invalid output bit-depth for packed YUV output, aborting\n");
}
m_cVideoIOYuvReconFile.open( m_reconFileName, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode m_cVideoIOYuvReconFile.open( m_reconFileName, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
openedReconFile = true; openedReconFile = true;
} }
...@@ -279,9 +288,9 @@ void DecApp::xCreateDecLib() ...@@ -279,9 +288,9 @@ void DecApp::xCreateDecLib()
m_cDecLib.create(); m_cDecLib.create();
// initialize decoder class // initialize decoder class
m_cDecLib.init( m_cDecLib.init(
#if JVET_J0090_MEMORY_BANDWITH_MEASURE #if JVET_J0090_MEMORY_BANDWITH_MEASURE
m_cacheCfgFile m_cacheCfgFile
#endif #endif
); );
m_cDecLib.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); m_cDecLib.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
...@@ -394,11 +403,13 @@ void DecApp::xWriteOutput( PicList* pcListPic, uint32_t tId ) ...@@ -394,11 +403,13 @@ void DecApp::xWriteOutput( PicList* pcListPic, uint32_t tId )
if (display) if (display)
{ {
m_cVideoIOYuvReconFile.write( pcPicTop->getRecoBuf(), pcPicBottom->getRecoBuf(), m_cVideoIOYuvReconFile.write( pcPicTop->getRecoBuf(), pcPicBottom->getRecoBuf(),
m_outputColourSpaceConvert, m_outputColourSpaceConvert,
conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), false, // TODO: m_packedYUVMode,
conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), NUM_CHROMA_FORMAT, isTff ); conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(),
NUM_CHROMA_FORMAT, isTff );
} }
} }
...@@ -445,6 +456,7 @@ void DecApp::xWriteOutput( PicList* pcListPic, uint32_t tId ) ...@@ -445,6 +456,7 @@ void DecApp::xWriteOutput( PicList* pcListPic, uint32_t tId )
m_cVideoIOYuvReconFile.write( pcPic->getRecoBuf(), m_cVideoIOYuvReconFile.write( pcPic->getRecoBuf(),
m_outputColourSpaceConvert, m_outputColourSpaceConvert,
m_packedYUVMode,
conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
...@@ -502,15 +514,18 @@ void DecApp::xFlushOutput( PicList* pcListPic ) ...@@ -502,15 +514,18 @@ void DecApp::xFlushOutput( PicList* pcListPic )
// write to file // write to file
if ( !m_reconFileName.empty() ) if ( !m_reconFileName.empty() )
{ {
const Window &conf = pcPicTop->cs->sps->getConformanceWindow(); const Window &conf = pcPicTop->cs->sps->getConformanceWindow();
const Window defDisp = (m_respectDefDispWindow && pcPicTop->cs->sps->getVuiParametersPresentFlag()) ? pcPicTop->cs->sps->getVuiParameters()->getDefaultDisplayWindow() : Window(); const Window defDisp = (m_respectDefDispWindow && pcPicTop->cs->sps->getVuiParametersPresentFlag()) ? pcPicTop->cs->sps->getVuiParameters()->getDefaultDisplayWindow() : Window();
const bool isTff = pcPicTop->topField; const bool isTff = pcPicTop->topField;
m_cVideoIOYuvReconFile.write( pcPicTop->getRecoBuf(), pcPicBottom->getRecoBuf(), m_cVideoIOYuvReconFile.write( pcPicTop->getRecoBuf(), pcPicBottom->getRecoBuf(),
m_outputColourSpaceConvert, m_outputColourSpaceConvert,
conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), false, // TODO: m_packedYUVMode,