Incorrect logic in parsing of HEVC SPS NALU
LinkdxTTV opened this issue · comments
@LinkdxTTV Thanks for the reporting this issue. Your findings seem absolutely correct, so I made a PR to fix this problem.
Do you possibly have some HEVC SPS data, that could be added to a test to trigger this issue?
Hello
Here is a sample test including a byte array that failed to parse before but should succeed after this commit
import (
"testing"
"github.com/Eyevinn/mp4ff/hevc"
)
func TestSPS(t *testing.T) {
test := []byte{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 3, 32, 0, 1, 0, 25, 64, 1, 12, 1, 255, 255, 1, 96, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 153, 53, 2, 64, 33, 0, 1, 0, 40, 66, 1, 1, 1, 96, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 153, 160, 2, 128, 128, 45, 22, 141, 82, 187, 34, 186, 173, 146, 169, 119, 53, 1, 1, 1, 0, 128, 34, 0, 1, 0, 8, 68, 1, 192, 36, 103, 192, 204, 100}
hevcd, err := hevc.DecodeHEVCDecConfRec(test)
if err != nil {
t.Error(err)
}
spsBytes := hevcd.GetNalusForType(hevc.NALU_SPS)
if len(spsBytes) != 1 {
t.Error("expected 1 sps NALU")
}
sps, err := hevc.ParseSPSNALUnit(spsBytes[0])
if err != nil {
t.Error(err)
}
t.Log(sps)
}
Prior to this commit, it should fail with err.EOF
LMK if i can help any way further. Thanks for the fast fix
@LinkdxTTV Thanks! That is very good. I included a variant of your test, and will merge the PR.