这两天在写HEVC中读CTU的部分,包括PartMode,partSize,PredInfo
还有特别重要的扫描表和残差系数的几个函数,经过调试已经没有问题,但是在调试过程中因为涉及到码字等相关问题,调试的复杂度比较大,
后来根据写TRACE文件的方法,调试基本就是流程性的工作了,不再会出现没有头绪的情况
在HM代码模型中,在
/** \file TComRom.h
\brief global variables & functions (header)
*/
当中有一个宏
#ifndef ENC_DEC_TRACE #define ENC_DEC_TRACE 1
在主程序中的输出宏:
#define DTRACE_CABAC_F(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%f", x ); #define DTRACE_CABAC_V(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%d", x ); #define DTRACE_CABAC_VL(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%lld", x ); #define DTRACE_CABAC_T(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%s", x ); #define DTRACE_CABAC_X(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%x", x ); #define DTRACE_CABAC_R( x,y ) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, x, y ); #define DTRACE_CABAC_N if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "\n" );g_nSymbolCounter 全局变量,标示当前元素的系数,这样匹配到不同点位置的时候可以根据他打条件断点进行调试
除了一些常规的信息跟踪以外,在HEVC中很重要的就是对底层熵解码的码流进行跟踪,因此再开一个文件,用于存储底层的码流信息,至于为什么要单开一个文件,因为项目是协同合作,你负责熵解码部分,那么这部分调试输出文件自己拥有就可以了,不用放到主调试文件中上传到版本库
#if XT_DEBUG #define TRACE_BIN_VL(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_binTrace, "%lld", x ); #define TRACE_BIN_V(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt )fprintf( g_binTrace, "%d", x ); #define TRACE_BIN_T(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt )fprintf( g_binTrace, "%s", x ); #define TRACE_BIN_N if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt )fprintf( g_binTrace, "\n" ); #endif
DTRACE_CABAC_VL( g_nSymbolCounter++ ) DTRACE_CABAC_T( "\tparseQtCbf()" ) DTRACE_CABAC_T( "\tsub-TU=" ) DTRACE_CABAC_V( subTU ) DTRACE_CABAC_T( "\tsymbol=" ) DTRACE_CABAC_V( uiCbf ) DTRACE_CABAC_T( "\tctx=" ) DTRACE_CABAC_V( uiCtx ) DTRACE_CABAC_T( "\tetype=" ) DTRACE_CABAC_V( compID ) DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) DTRACE_CABAC_V( subTUAbsPartIdx ) DTRACE_CABAC_T( "\n" )
#if XT_DEBUG TRACE_BIN_VL( g_binTraceCounter++ ) TRACE_BIN_T( " Value=" ) TRACE_BIN_V( m_uiValue ) TRACE_BIN_T( " Range=" ) TRACE_BIN_V( m_uiRange) TRACE_BIN_T( " DecodeBin" ) TRACE_BIN_T( "\n" ) fflush(g_binTrace); #endif
一般这个过程找出问题是很简单的,调试就变得容易了,如果码流没有出错,一般就是逻辑出问题,小心一点就问题不大
原文地址:http://blog.csdn.net/xietingcandice/article/details/42266037