hevc移植/优化-day 3:profiling

为了找出耗时的函数,需要用gprof之类的工具来分析性能/耗时,如果手动加代码测耗时部分过于繁锁。本文简述如何在linux下分析编解码器的性能。

首先修改makefile支持profiling。

修改build/linux/common/makefile.base:

########## 
# do profiling : 1=yes, 0=no
##########
PROFILING?= 0
ifeq ($(PROFILING),1)
CPPFLAGS+=-pg
endif
##########

########## 
# do profiling : 1=yes, 0=no
##########
PROFILING?= 0
ifeq ($(PROFILING),1)
ALL_LDFLAGS+=-pg
endif
##########

修改build/linux/makefile

### do profiling : 1=yes, 0=no
PROFILING?= 1
export PROFILING

重新make生成TAppEncoderStatic/TAppDecoderStatic。

接着开始测试编码:

./TAppEncoderStatic -c ../cfg/encoder_randomaccess.cfg -i ../video/RaceHorses_416x240_30.yuv -wdt 416 -hgt 240 -fr 30 --InputBitDepth=8 --OutputBitDepth=8 --InternalBitDepth=8 -b RaceHorses_416x240_30.265 -f 60
附编码主要参数说明:

  -c                             configuration file name
  -i,   --InputFile              original YUV input file name
  -b,   --BitstreamFile          bitstream output file name
  -wdt, --SourceWidth            Source picture width
  -hgt, --SourceHeight           Source picture height
  -fr,  --FrameRate              Frame rate
        --InputBitDepth          bit-depth of input file
        --OutputBitDepth         bit-depth of output file

yuv文件可以在ftp://hvc:[email protected]/testsequences下载,注意要加-f参数,此步编码生成文件RaceHorses_416x240_30.265,用于测试解码:

./TAppDecoderStatic -d 0 -o decout.yuv -b RaceHorses_416x240_30.265

运行编码/解码程序后都会生成gmon.out,运行gprof TAppDecoderStatic输出性能分析结果,以下是较耗时的几个函数:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 12.09      0.11     0.11    26707     0.00     0.00  void TComInterpolationFilter::filter<8, false, true, false>(short const*, int, short*, int, int, int, short const*)
  7.69      0.18     0.07    12952     0.01     0.01  void TComInterpolationFilter::filter<8, true, false, false>(short const*, int, short*, int, int, int, short const*)
  5.49      0.23     0.05       14     3.57     3.57  TComAdaptiveLoopFilter::filterFrame(unsigned short*, unsigned short*, int, int)
  4.40      0.27     0.04   641709     0.00     0.00  TDecBinCABAC::decodeBin(unsigned int&, ContextModel&)
  4.40      0.31     0.04    91284     0.00     0.00  TComLoopFilter::xEdgeFilterLuma(TComDataCU*, unsigned int, unsigned int, int, int)
  4.40      0.35     0.04    53182     0.00     0.00  TComDataCU::xGetColMVP(RefPicList, int, int, TComMv&, int&)
  4.40      0.39     0.04     7700     0.01     0.01  TComAdaptiveLoopFilter::subfilterFrame(unsigned short*, unsigned short*, int, int, int, int, int, int)
  3.30      0.42     0.03    64944     0.00     0.00  void TComInterpolationFilter::filter<4, false, true, false>(short const*, int, short*, int, int, int, short const*)
由gprof输出就可以很容易的看出哪些函数比较耗时,哪些函数被调用的次数较多。

vs2008下的分析办法(参考http://www.codeproject.com/KB/tips/profileWithVsPerfCmd.aspx):

安装Visual Studio 2008 Service Pack 1 Stand-Alone Profiler.在工程设置里面的链接选项里面开启:高级->探查,即启用探查信息。

使用如下脚本进行profiling,生成的报表为csv格式。

set pt="C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools"
%pt%\vsperfcmd /start:sample /output:TAppDecoder.vsp
%pt%\vsperfcmd /launch:J:\git\hevc\bin\vc9\Win32\Release\TAppDecoder.exe /ARGS:"-d 0 -o decout.yuv -b RaceHorses_416x240_30.265"
%pt%\vsperfcmd /shutdown
%pt%\VSPerfReport /SUMMARY:ALL TAppDecoder.vsp /OUTPUT:TAppDecoder
pause

NOTE:若使用day 2的代码(去掉异常支持),将会出现异常terminate called after throwing an instance of 'std::ios_base::failure',what(): basic_ios::clear。本文测试时使用svn原版本代码。


你可能感兴趣的:(Linux,dsp,hevc)