Skip to content

Commit

Permalink
codecs/h265: support SPS with long_term_ref_pics_present_flag (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Mar 9, 2023
1 parent c88c5c8 commit 8be6bf7
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/codecs/h265/sps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
52 changes: 52 additions & 0 deletions pkg/codecs/h265/sps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go test fuzz v1
[]byte("000000000000000\xf571*07")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go test fuzz v1
[]byte("00000000000000000%00000000A$0")

0 comments on commit 8be6bf7

Please sign in to comment.