本文主要参考了
HEVC之路0:HM16.18的运行+码流分析 - 只因有你pi - 博客园 (cnblogs.com)
在此表示感谢。
HM下载
HM不能直接从网页下载,而是采用SVN管理代码的——首先,下载合适版本的TortoiseSVN,这里我们下载的是最新版本1.14.1-64bit:
下载后双击安装,一直点确定就行。安装完成后在要下载HM的文件夹(此处为D:\HM
)右键,选择Repo-browser
:
在弹出的URL框中输入HM的下载地址:https://hevc.hhi.fraunhofer.de/svn/svn_HEVCSoftware/tags/
,可以看到不同版本的HM,这里我们选择最新的HM版本,并右键选择checkout
,即可进行下载:
补充说明:后期版本的SCM
表示该版本含有SHVC、MV-HEVC和3D-HEVC版本分支。
HM运行
这里使用VS2017打开HM->build文件夹,选择vs2015.sln,此时可在解决方案资源管理器中看到九个项目:
右击“解决方案’HM_vc2015’(10个项目)”->“生成解决方案”,可以选择debug或者win32模式,与系统是否是64位系统无关:
生成解决方案成功后,可在项目bin\vc2015\Win32\Debug下面看到TAppDecoder.exe
和TAppEncoder.exe
两个可执行文件:
一般我们更关注编码端,即如何将yuv文件转为HEVC文件,这里关注TAppEncoder
项目:
在VS2017的解决方案资源管理器中右击TAppEncoder
->“设为启动项目”,然后在此右击TAppEncoder
->“属性”->“配置属性”->“调试”:
我们只需要修改工作目录,用于放置配置文件,这里按照日期命名,设为..\..\workspace\21_1215
,即在HM->workspace下创建一个名为21_1215的空文件夹(自己创建),命令参数此处填入-c encoder_intra_main.cfg -c sintel.cfg
,分别为帧内编码的配置文件 和 一个名为sintel的YUV序列文件的配置文件。
下面我们在刚才的workspace\21_1215
中放置配置文件和视频序列:
encoder_intra_main.cfg
可在HM->cfg中找到模板- sintel.cfg`可以在HM->cfg->per-sequence中找到模板
- 视频序列可以从Index of /hevc/hm-15.0-anchors/bitstreams/i_main/ (bbc.co.uk)中下载.bin格式的265压缩文件,然后在本地转为YUV序列,这里我们采用的是提前准备好的YUV序列:sintel.yuv
下面我们修改encoder_intra_main.cfg:
- BitstreamFile 编码后的码流序列文件名,默认为str.bin
- ReconFile 编码后重建的YUV文件名,默认为rec.yuv
- QP 编码的量化系数,此处设为最大值51
然后修改sintel.cfg:
- InputFile:可以写绝对地址,也可以直接写要编码的YUV文件名,但是此时要把文件放在workspace
- SourceWidth和SourceHeight:帧宽和帧高
- FramesToBeEncoded:要编码的帧的数目,此处设置为5
然后编译运行就可以了,结束后会在workspace下面看到编码后的码流序列str.bin和编码后重建的YUV文件rec.yuv。
后编译运行就可以了,结束后会在workspace下面看到编码后的码流序列str.bin和编码后重建的YUV文件rec.yuv。
配置文件
下面是配置文件21_1225\
下面encoder_intra_main.cfg
#======== File I/O =====================
BitstreamFile : str.bin
ReconFile : rec.yuv
#======== Profile ================
Profile : main
#======== Unit definition ================
MaxCUWidth : 64 # Maximum coding unit width in pixel
MaxCUHeight : 64 # Maximum coding unit height in pixel
MaxPartitionDepth : 4 # Maximum coding unit depth
QuadtreeTULog2MaxSize : 5 # Log2 of maximum transform size for
# quadtree-based TU coding (2...6)
QuadtreeTULog2MinSize : 2 # Log2 of minimum transform size for
# quadtree-based TU coding (2...6)
QuadtreeTUMaxDepthInter : 3
QuadtreeTUMaxDepthIntra : 3
#======== Coding Structure =============
IntraPeriod : 1 # Period of I-Frame ( -1 = only first)
DecodingRefreshType : 1 # Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI
GOPSize : 1 # GOP Size (number of B slice = GOPSize-1)
ReWriteParamSetsFlag : 1 # Write parameter sets with every IRAP
#=========== Motion Search =============
FastSearch : 1 # 0:Full search 1:TZ search
SearchRange : 64 # (0: Search range is a Full frame)
HadamardME : 1 # Use of hadamard measure for fractional ME
FEN : 1 # Fast encoder decision
FDM : 1 # Fast Decision for Merge RD cost
#======== Quantization =============
QP : 51 # Quantization parameter(0-51)
MaxDeltaQP : 0 # CU-based multi-QP optimization
MaxCuDQPDepth : 0 # Max depth of a minimum CuDQP for sub-LCU-level delta QP
DeltaQpRD : 0 # Slice-based multi-QP optimization
RDOQ : 1 # RDOQ
RDOQTS : 1 # RDOQ for transform skip
#=========== Deblock Filter ============
LoopFilterOffsetInPPS : 1 # Dbl params: 0=varying params in SliceHeader, param = base_param + GOP_offset_param; 1 (default) =constant params in PPS, param = base_param)
LoopFilterDisable : 0 # Disable deblocking filter (0=Filter, 1=No Filter)
LoopFilterBetaOffset_div2 : 0 # base_param: -6 ~ 6
LoopFilterTcOffset_div2 : 0 # base_param: -6 ~ 6
DeblockingFilterMetric : 0 # blockiness metric (automatically configures deblocking parameters in bitstream). Applies slice-level loop filter offsets (LoopFilterOffsetInPPS and LoopFilterDisable must be 0)
#=========== Misc. ============
InternalBitDepth : 8 # codec operating bit-depth
#=========== Coding Tools =================
SAO : 1 # Sample adaptive offset (0: OFF, 1: ON)
AMP : 1 # Asymmetric motion partitions (0: OFF, 1: ON)
TransformSkip : 1 # Transform skipping (0: OFF, 1: ON)
TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1: ON)
SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON)
#============ Slices ================
SliceMode : 0 # 0: Disable all slice options.
# 1: Enforce maximum number of LCU in an slice,
# 2: Enforce maximum number of bytes in an 'slice'
# 3: Enforce maximum number of tiles in a slice
SliceArgument : 1500 # Argument for 'SliceMode'.
# If SliceMode==1 it represents max. SliceGranularity-sized blocks per slice.
# If SliceMode==2 it represents max. bytes per slice.
# If SliceMode==3 it represents max. tiles per slice.
LFCrossSliceBoundaryFlag : 1 # In-loop filtering, including ALF and DB, is across or not across slice boundary.
# 0:not across, 1: across
#============ PCM ================
PCMEnabledFlag : 0 # 0: No PCM mode
PCMLog2MaxSize : 5 # Log2 of maximum PCM block size.
PCMLog2MinSize : 3 # Log2 of minimum PCM block size.
PCMInputBitDepthFlag : 1 # 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
PCMFilterDisableFlag : 0 # 0: Enable loop filtering on I_PCM samples. 1: Disable loop filtering on I_PCM samples.
#============ Tiles ================
TileUniformSpacing : 0 # 0: the column boundaries are indicated by TileColumnWidth array, the row boundaries are indicated by TileRowHeight array
# 1: the column and row boundaries are distributed uniformly
NumTileColumnsMinus1 : 0 # Number of tile columns in a picture minus 1
TileColumnWidthArray : 2 3 # Array containing tile column width values in units of CTU (from left to right in picture)
NumTileRowsMinus1 : 0 # Number of tile rows in a picture minus 1
TileRowHeightArray : 2 # Array containing tile row height values in units of CTU (from top to bottom in picture)
LFCrossTileBoundaryFlag : 1 # In-loop filtering is across or not across tile boundary.
# 0:not across, 1: across
#============ WaveFront ================
WaveFrontSynchro : 0 # 0: No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
# >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
#=========== Quantization Matrix =================
ScalingList : 0 # ScalingList 0 : off, 1 : default, 2 : file read
ScalingListFile : scaling_list.txt # Scaling List file name. If file is not exist, use Default Matrix.
#============ Lossless ================
TransquantBypassEnable : 0 # Value of PPS flag.
CUTransquantBypassFlagForce: 0 # Force transquant bypass mode, when transquant_bypass_enable_flag is enabled
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
和sintel.cfg
#======== File I/O ===============
InputFile : sintel_640_360.yuv
InputBitDepth : 8 # Input bitdepth
InputChromaFormat : 420 # Ratio of luminance to chrominance samples
FrameRate : 50 # Frame Rate per second
FrameSkip : 0 # Number of frames to be skipped in input
SourceWidth : 640 # Input frame width
SourceHeight : 360 # Input frame height
FramesToBeEncoded : 5 # Number of frames to be coded
Level : 2.1
YUV文件从官网下载Index of /hevc/hm-15.0-anchors/bitstreams/i_main/ (bbc.co.uk),或者从百度云下载
链接:https://pan.baidu.com/s/1wEVowxJTX-gPdhPlsi2FbQ
提取码:ryhv