diff --git a/pkg/codecs/h265/sps.go b/pkg/codecs/h265/sps.go index df145f18..af1fb463 100644 --- a/pkg/codecs/h265/sps.go +++ b/pkg/codecs/h265/sps.go @@ -789,7 +789,14 @@ func (s *SPS) Unmarshal(buf []byte) error { } if s.LongTermRefPicsPresentFlag { - return fmt.Errorf("LongTermRefPicsPresentFlag not supported yet") + numLongTermRefPicsSPS, err := bits.ReadGolombUnsigned(buf, &pos) + if err != nil { + return err + } + + if numLongTermRefPicsSPS > 0 { + return fmt.Errorf("long term ref pics inside SPS are not supported yet") + } } s.TemporalMvpEnabledFlag, err = bits.ReadFlag(buf, &pos) diff --git a/pkg/codecs/h265/sps_test.go b/pkg/codecs/h265/sps_test.go index 570e697b..eac88c16 100644 --- a/pkg/codecs/h265/sps_test.go +++ b/pkg/codecs/h265/sps_test.go @@ -373,6 +373,58 @@ func TestSPSUnmarshal(t *testing.T) { 1728, 17, }, + { + "long_term_ref_pics_present_flag", + []byte{ + 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, + 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, + 0x00, 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x2d, 0x16, + 0x36, 0xb9, 0x24, 0xcb, 0xf0, 0x08, 0x00, 0x00, + 0x03, 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x95, + 0x08, + }, + SPS{ + TemporalIDNestingFlag: true, + ProfileTierLevel: SPS_ProfileTierLevel{ + GeneralProfileIdc: 1, + GeneralProfileCompatibilityFlag: [32]bool{ + false, true, true, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + }, + GeneralProgressiveSourceFlag: true, + GeneralNonPackedConstraintFlag: true, + GeneralFrameOnlyConstraintFlag: true, + GeneralLevelIdc: 93, + }, + ChromaFormatIdc: 1, + PicWidthInLumaSamples: 1280, + PicHeightInLumaSamples: 720, + Log2MaxPicOrderCntLsbMinus4: 12, + SubLayerOrderingInfoPresentFlag: true, + MaxDecPicBufferingMinus1: []uint32{1}, + MaxNumReorderPics: []uint32{0}, + MaxLatencyIncreasePlus1: []uint32{0}, + Log2DiffMaxMinLumaCodingBlockSize: 3, + Log2DiffMaxMinLumaTransformBlockSize: 3, + SampleAdaptiveOffsetEnabledFlag: true, + LongTermRefPicsPresentFlag: true, + TemporalMvpEnabledFlag: true, + StrongIntraSmoothingEnabledFlag: true, + VUI: &SPS_VUI{ + TimingInfo: &SPS_TimingInfo{ + NumUnitsInTick: 1, + TimeScale: 50, + POCProportionalToTimingFlag: true, + NumTicksPOCDiffOneMinus1: 1, + }, + }, + }, + 1280, + 720, + 50, + }, } { t.Run(ca.name, func(t *testing.T) { var sps SPS diff --git a/pkg/codecs/h265/testdata/fuzz/FuzzSPSUnmarshal/0f8f18804076a2178ba242cfc92d30a0fd17a6f4aa63a8005253a16205b4e3c6 b/pkg/codecs/h265/testdata/fuzz/FuzzSPSUnmarshal/0f8f18804076a2178ba242cfc92d30a0fd17a6f4aa63a8005253a16205b4e3c6 new file mode 100644 index 00000000..7c50150a --- /dev/null +++ b/pkg/codecs/h265/testdata/fuzz/FuzzSPSUnmarshal/0f8f18804076a2178ba242cfc92d30a0fd17a6f4aa63a8005253a16205b4e3c6 @@ -0,0 +1,2 @@ +go test fuzz v1 +[]byte("000000000000000\xf571*07") diff --git a/pkg/codecs/h265/testdata/fuzz/FuzzSPSUnmarshal/ed6952414b61c4c80820200ed4cfa0c873900d9311619e6590fa18cf8b28ef04 b/pkg/codecs/h265/testdata/fuzz/FuzzSPSUnmarshal/ed6952414b61c4c80820200ed4cfa0c873900d9311619e6590fa18cf8b28ef04 new file mode 100644 index 00000000..f89ca5ce --- /dev/null +++ b/pkg/codecs/h265/testdata/fuzz/FuzzSPSUnmarshal/ed6952414b61c4c80820200ed4cfa0c873900d9311619e6590fa18cf8b28ef04 @@ -0,0 +1,2 @@ +go test fuzz v1 +[]byte("00000000000000000%00000000A$0")