h264: fix FPS computation when NUmUnitsInTick != 1

This commit is contained in:
aler9
2022-05-25 15:36:13 +02:00
parent 7e8ec60aad
commit 91d1675c0c
2 changed files with 26 additions and 1 deletions

View File

@@ -714,5 +714,5 @@ func (s SPS) FPS() float64 {
return 0
}
return float64(s.VUI.TimeScale) / 2 * float64(s.VUI.NumUnitsInTick)
return float64(s.VUI.TimeScale) / (2 * float64(s.VUI.NumUnitsInTick))
}

View File

@@ -198,6 +198,31 @@ func TestSPSUnmarshal(t *testing.T) {
1084,
25,
},
{
"hikvision",
[]byte{103, 100, 0, 32, 172, 23, 42, 1, 64, 30, 104, 64, 0, 1, 194, 0, 0, 87, 228, 33},
SPS{
ProfileIdc: 100,
LevelIdc: 32,
ChromeFormatIdc: 1,
Log2MaxPicOrderCntLsbMinus4: 4,
MaxNumRefFrames: 1,
PicWidthInMbsMinus1: 79,
PicHeightInMbsMinus1: 59,
FrameMbsOnlyFlag: true,
Direct8x8InferenceFlag: true,
Log2MaxFrameNumMinus4: 10,
VUI: &VUI{
TimingInfoPresentFlag: true,
NumUnitsInTick: 1800,
TimeScale: 90000,
FixedFrameRateFlag: true,
},
},
1280,
960,
25,
},
} {
t.Run(ca.name, func(t *testing.T) {
var sps SPS