1. 参考文档及代码下载
1.1 SHVC官网 上面有相关资料及一篇Overview:“Overview of SHVC: Scalable Extensions of the High Efficiency Video Coding Standard”
1.2 开始入门SHVC,建议看一些国内的硕士论文,有些论文写的比较详细,可以参考。
1.3 参考软件 SHM下载及安装跟HEVC类似。使用高版本VS需要升级工程。在编译时可能会报错:int_least8_t”: 不是“`global namespace’”的成员等错误,参考博客,将VS自带的stdint.h文件代替compat/msvc下的stdint.h文件。
2. SHVC平台配置及简介
2.1配置一个增强层
可以参考博客
编码配置:
TAppEncoder.exe -c cfg/encoder_randomaccess_main.cfg -c cfg/per-sequence-svc/BasketballDrive-2x.cfg –c cfg/layers.cfg
解码配置(以一个基本层+一个增强层为例)
TAppDecoder.exe -ls 2 -b BasketballDrive.bin -o0 recBL.yuv -o1 recEL.yuv
layers_avcbase 表示的是avc来编码基础层。
layers表示hevc来编码基础层。
-ls 2 表示两个层
-b BasketballDrive.bin 是已存在的码率文件
-o0 recBL.yuv 输出重建的基本层yuv,是原视频分辨率下采样后的尺寸
-o1 recEL.yuv 输出重建的增强层yuv,是原视频分辨率大小
2.2配置多个增强层
SHVC配置文件默认为一个增强层,且做标准时也只测试一个增强层的性能来决定是否接收对应的提案,但是SHVC支持多个增强层。下面的配置个人验证是对的,如果有问题可以在下面评论。
2.2.1
首先需要在cfg\per-sequence-svc文件夹下将序列的配置更改,以3个增强层的配置为例
FrameSkip : 0 # Number of frames to be skipped in input
FramesToBeEncoded : 2 # Number of frames to be coded
PhaseAlignment : 0 # Sample location alignment between layers (0: zero position aligned, 1: central position aligned)
Level : 4.1
#======== File I/O ===============
InputFile0 : F:\sequence\HEVC_Test_Sequence/BasketballDrill_832x480_50.yuv
FrameRate0 : 50 # Frame Rate per second
InputBitDepth0 : 8 # Input bitdepth for layer 0
SourceWidth0 : 832 # Input frame width
SourceHeight0 : 480 # Input frame height
RepFormatIdx0 : 0 # Index of corresponding rep_format() in the VPS
IntraPeriod0 : 48 # Period of I-Frame ( -1 = only first)
ConformanceMode0 : 1 # conformance mode
QP0 : 37
InputFile1 : F:\sequence\HEVC_Test_Sequence/BasketballDrill_832x480_50.yuv
FrameRate1 : 50 # Frame Rate per second
InputBitDepth1 : 8 # Input bitdepth for layer 1
SourceWidth1 : 832 # Input frame width
SourceHeight1 : 480 # Input frame height
RepFormatIdx1 : 0 # Index of corresponding rep_format() in the VPS
IntraPeriod1 : 48 # Period of I-Frame ( -1 = only first)
ConformanceMode1 : 1 # conformance mode
QP1 : 32
InputFile2 : F:\sequence\HEVC_Test_Sequence/BasketballDrill_832x480_50.yuv
FrameRate2 : 50 # Frame Rate per second
InputBitDepth2 : 8 # Input bitdepth for layer 2
SourceWidth2 : 832 # Input frame width
SourceHeight2 : 480 # Input frame height
RepFormatIdx2 : 0 # Index of corresponding rep_format() in the VPS
IntraPeriod2 : 48 # Period of I-Frame ( -2 = only first)
ConformanceMode2 : 1 # conformance mode
QP2 : 27
InputFile3 : F:\sequence\HEVC_Test_Sequence/BasketballDrill_832x480_50.yuv
FrameRate3 : 50 # Frame Rate per second
InputBitDepth3 : 8 # Input bitdepth for layer 3
SourceWidth3 : 832 # Input frame width
SourceHeight3 : 480 # Input frame height
RepFormatIdx3 : 0 # Index of corresponding rep_format() in the VPS
IntraPeriod3 : 48 # Period of I-Frame ( -3 = only first)
ConformanceMode3 : 1 # conformance mode
QP3 : 22
2.2.2
更改cfg/layers.cfg文件,以3个增强层为例
NumLayers : 4
NonHEVCBase : 0
ScalabilityMask1 : 0 # Multiview
ScalabilityMask2 : 1 # Scalable
ScalabilityMask3 : 0 # Auxiliary pictures
AdaptiveResolutionChange : 0 # Resolution change frame (0: disable)
SkipPictureAtArcSwitch : 0 # Code higher layer picture as skip at ARC switching (0: disable (default), 1: enable)
MaxTidRefPresentFlag : 1 # max_tid_ref_present_flag (0=not present, 1=present(default))
CrossLayerPictureTypeAlignFlag: 1 # Picture type alignment across layers
CrossLayerIrapAlignFlag : 1 # Align IRAP across layers
SEIpictureDigest : 1
#============= LAYER 0 ==================
QP0 : 22
MaxTidIlRefPicsPlus10 : 1 # max_tid_il_ref_pics_plus1 for layer0
#============ Rate Control ==============
RateControl0 : 0 # Rate control: enable rate control for layer 0
TargetBitrate0 : 1000000 # Rate control: target bitrate for layer 0, in bps
KeepHierarchicalBit0 : 1 # Rate control: keep hierarchical bit allocation for layer 0 in rate control algorithm
LCULevelRateControl0 : 1 # Rate control: 1: LCU level RC for layer 0; 0: picture level RC for layer 0
RCLCUSeparateModel0 : 1 # Rate control: use LCU level separate R-lambda model for layer 0
InitialQP0 : 0 # Rate control: initial QP for layer 0
RCForceIntraQP0 : 0 # Rate control: force intra QP to be equal to initial QP for layer 0
#============ WaveFront ================
WaveFrontSynchro0 : 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.
#============= LAYER 1 ==================
QP1 : 20
NumSamplePredRefLayers1 : 1 # number of sample pred reference layers
SamplePredRefLayerIds1 : 0 # reference layer id
NumMotionPredRefLayers1 : 1 # number of motion pred reference layers
MotionPredRefLayerIds1 : 0 # reference layer id
NumActiveRefLayers1 : 1 # number of active reference layers
PredLayerIds1 : 0 # inter-layer prediction layer index within available reference layers
#============ Rate Control ==============
RateControl1 : 0 # Rate control: enable rate control for layer 1
TargetBitrate1 : 1000000 # Rate control: target bitrate for layer 1, in bps
KeepHierarchicalBit1 : 1 # Rate control: keep hierarchical bit allocation for layer 1 in rate control algorithm
LCULevelRateControl1 : 1 # Rate control: 1: LCU level RC for layer 1; 0: picture level RC for layer 1
RCLCUSeparateModel1 : 1 # Rate control: use LCU level separate R-lambda model for layer 1
InitialQP1 : 0 # Rate control: initial QP for layer 1
RCForceIntraQP1 : 0 # Rate control: force intra QP to be equal to initial QP for layer 1
#============ WaveFront ================
WaveFrontSynchro1 : 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.
#============= LAYER 2 ==================
QP2 : 18
NumSamplePredRefLayers2 : 2 # number of sample pred reference layers
SamplePredRefLayerIds2 : 0 1 # reference layer id
NumMotionPredRefLayers2 : 2 # number of motion pred reference layers
MotionPredRefLayerIds2 : 0 1 # reference layer id
NumActiveRefLayers2 : 2 # number of active reference layers
PredLayerIds2 : 0 1 # inter-layer prediction layer index within available reference layers
#============ Rate Control ==============
RateControl2 : 0 # Rate control: enable rate control for layer 1
TargetBitrate2 : 1000000 # Rate control: target bitrate for layer 1, in bps
KeepHierarchicalBit2 : 1 # Rate control: keep hierarchical bit allocation for layer 1 in rate control algorithm
LCULevelRateControl2 : 1 # Rate control: 1: LCU level RC for layer 1; 0: picture level RC for layer 1
RCLCUSeparateModel2 : 1 # Rate control: use LCU level separate R-lambda model for layer 1
InitialQP2 : 0 # Rate control: initial QP for layer 1
RCForceIntraQP2 : 0 # Rate control: force intra QP to be equal to initial QP for layer 1
#============ WaveFront ================
WaveFrontSynchro2 : 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.
#============= LAYER 3 ==================
QP3 : 16
NumSamplePredRefLayers3 : 3 # number of sample pred reference layers
SamplePredRefLayerIds3 : 0 1 2 # reference layer id
NumMotionPredRefLayers3 : 3 # number of motion pred reference layers
MotionPredRefLayerIds3 : 0 1 2 # reference layer id
NumActiveRefLayers3 : 3 # number of active reference layers
PredLayerIds3 : 0 1 2 # inter-layer prediction layer index within available reference layers
#============ Rate Control ==============
RateControl3 : 0 # Rate control: enable rate control for layer 1
TargetBitrate3 : 1000000 # Rate control: target bitrate for layer 1, in bps
KeepHierarchicalBit3 : 1 # Rate control: keep hierarchical bit allocation for layer 1 in rate control algorithm
LCULevelRateControl3 : 1 # Rate control: 1: LCU level RC for layer 1; 0: picture level RC for layer 1
RCLCUSeparateModel3 : 1 # Rate control: use LCU level separate R-lambda model for layer 1
InitialQP3 : 0 # Rate control: initial QP for layer 1
RCForceIntraQP3 : 0 # Rate control: force intra QP to be equal to initial QP for layer 1
#============ WaveFront ================
WaveFrontSynchro3 : 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.
NumLayerSets : 4 # Include default layer set, value of 0 not allowed
NumLayerInIdList1 : 2 # 0-th layer set is default, need not specify LayerSetLayerIdList0 or NumLayerInIdList0
LayerSetLayerIdList1 : 0 1
NumLayerInIdList2 : 3 # 0-th layer set is default, need not specify LayerSetLayerIdList0 or NumLayerInIdList0
LayerSetLayerIdList2 : 0 1 2
NumLayerInIdList3 : 4 # 0-th layer set is default, need not specify LayerSetLayerIdList0 or NumLayerInIdList0
LayerSetLayerIdList3 : 0 1 2 3
NumAddLayerSets : 0
NumOutputLayerSets : 4 # Include defualt OLS, value of 0 not allowed
DefaultTargetOutputLayerIdc : 3
NumLayersInOutputLayerSet : 1 2 3 # The number of layers in the 0-th OLS should not be specified,
# ListOfOutputLayers0 need not be specified
ListOfOutputLayers1 : 1
ListOfOutputLayers2 : 1 2
ListOfOutputLayers3 : 1 2 3
2.2.3
编码命令:
-c ../cfg/encoder_randomaccess_main.cfg -c BasketballDrill-SNR.cfg -c ../cfg/layers.cfg -q0 37 -q1 32 -q2 27 -q3 22 -ip0 8 -ip1 8 -ip2 8 -ip3 8 -f 8 -b BasketballDrill-SNR.bit -o0 ./BasketballDrill-SNR_rec_0.yuv -o1 ./BasketballDrill-SNR_rec_1.yuv -o2 ./BasketballDrill-SNR_rec_2.yuv -o3 ./BasketballDrill-SNR_rec_3.yuv --SEIDecodedPictureHash=1
解码命令:
-ls 4 -b BasketballDrill-SNR.bit -o0 recBL.yuv -o1 recEL1.yuv -o2 recEL2.yuv -o3 recEL3.yuv