引自:https://www.freesion.com/article/6203385847/
BD-RATE计算原理
BD-RATE介绍
BD-rate是评价视频编码算法性能的主要参数之一,表示新算法编码的视频相对于原来的算法在码率和PSNR上的变化情况。
在视频编码中,码率低表示压缩量大,PSNR值高表示客观质量好。因此,对于一种编码算法,如果压缩视频码率降低、PSNR值提高,那么该算法具有良好的性能。但是通常视频编码算法在提高压缩量的同时会损失压缩质量,即码率减小的同时PSNR值也减小,此时就需要使用BD-rate进行衡量。
VB程序分析
本部分首先对程序进行注解,再按模块进行分析。
Public Function bdrate(rateA As Range, distA As Range, rateB As Range, distB As Range) As Double
'rateA是anchor码率,distA是ancher的PSNR,rateB是test码率,distB是test的PSNR
Dim minPSNR As Double
Dim maxPSNR As Double
'取出积分区间
minPSNR = WorksheetFunction.Max(WorksheetFunction.Min(distA), WorksheetFunction.Min(distB))
maxPSNR = WorksheetFunction.Min(WorksheetFunction.Max(distA), WorksheetFunction.Max(distB))
Dim vA As Double
Dim vB As Double
'积分。bdrint函数先对码率取了对数,然后进行积分
vA = bdrint(rateA, distA, minPSNR, maxPSNR)
vB = bdrint(rateB, distB, minPSNR, maxPSNR)
'计算积分差值,除以积分区间
Dim avg As Double
avg = (vB - vA) / (maxPSNR - minPSNR)
'对数反变换。得到被测算法的码率相对于anchor的倍数,减1后得到变化率
bdrate = WorksheetFunction.Power(10, avg) - 1
End Function
Public Function bdrint(rate As Range, dist As Range, low As Double, high As Double) As Double
Dim log_rate(1 To 4) As Double
Dim log_dist(1 To 4) As Double
Dim i As Long
'数据重排。输入数据小qp在前,因此前面数据的码率和PSNR大,重排后小值在前
For i = 1 To 4
log_rate(i) = WorksheetFunction.Log(rate(5 - i), 10)
log_dist(i) = dist(5 - i)
Next i
Dim H(1 To 3) As Double
Dim delta(1 To 3) As Double
For i = 1 To 3
H(i) = log_dist(i + 1) - log_dist(i) '差值
delta(i) = (log_rate(i + 1) - log_rate(i)) / H(i) '以PSNR为横轴的斜率
Next i
'd、c、b为分段多项式系数,本程序采用pchip三次分段插值方法获得拟合曲线
Dim d(1 To 4) As Double
d(1) = pchipend(H(1), H(2), delta(1), delta(2))
For i = 2 To 3
d(i) = (3 * H(i - 1) + 3 * H(i)) / ((2 * H(i) + H(i - 1)) / delta(i - 1) + (H(i) + 2 * H(i - 1)) / delta(i))
Next i
d(4) = pchipend(H(3), H(2), delta(3), delta(2))
Dim c(1 To 3) As Double
Dim b(1 To 3) As Double
For i = 1 To 3
c(i) = (3