74 lines
1.7 KiB
Go
74 lines
1.7 KiB
Go
//go:build cgo && !disable_codec_livdav1d
|
|
|
|
package libdav1d
|
|
|
|
import (
|
|
"git.gammaspectra.live/S.O.N.G/Ignite/frame"
|
|
"git.gammaspectra.live/S.O.N.G/Ignite/testdata"
|
|
"testing"
|
|
)
|
|
|
|
func TestVersion(t *testing.T) {
|
|
t.Logf("dav1d version: %s", Version())
|
|
}
|
|
|
|
func testDecode(sample testdata.TestSample, t *testing.T) {
|
|
reader, err := sample.Open(t)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer reader.Close()
|
|
|
|
if decoder, err := NewDecoder(reader, nil); err != nil {
|
|
t.Fatal(err)
|
|
} else {
|
|
defer decoder.Close()
|
|
decoded := 0
|
|
|
|
var frameProperties frame.Properties
|
|
for decodedFrame := range decoder.DecodeStream().Channel() {
|
|
if decoded == 0 {
|
|
frameProperties = decodedFrame.Properties()
|
|
}
|
|
//ingest
|
|
decoded++
|
|
if decoded%50 == 0 {
|
|
t.Logf("%d/%d", decoded, sample.Frames)
|
|
}
|
|
decodedFrame.Return()
|
|
}
|
|
|
|
if decoded != sample.Frames {
|
|
t.Fatalf("expected %d frames, got %d", sample.Frames, decoded)
|
|
}
|
|
|
|
if frameProperties.Width != sample.Width {
|
|
t.Fatalf("expected %d width, got %d", sample.Width, frameProperties.Width)
|
|
}
|
|
|
|
if frameProperties.Height != sample.Height {
|
|
t.Fatalf("expected %d height, got %d", sample.Height, frameProperties.Height)
|
|
}
|
|
|
|
if frameProperties.ColorSpace.String() != sample.ColorSpace.String() {
|
|
t.Fatalf("expected %s color space, got %s", sample.ColorSpace.String(), frameProperties.ColorSpace.String())
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestDecode_YUV420_8bit(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping test in short mode")
|
|
}
|
|
|
|
testDecode(testdata.AV1_Sintel_Trailer_720p24_YUV420_8bit_Low, t)
|
|
}
|
|
|
|
func TestDecode_YUV444_12bit(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping test in short mode")
|
|
}
|
|
|
|
testDecode(testdata.AV1_Netflix_Sol_Levante_2160p24_YUV444_12bit_Lossy, t)
|
|
}
|