146 lines
4.4 KiB
Go
146 lines
4.4 KiB
Go
package testdata
|
|
|
|
import (
|
|
"git.gammaspectra.live/S.O.N.G/Ignite/color"
|
|
"git.gammaspectra.live/S.O.N.G/Ignite/utilities"
|
|
"io"
|
|
"net/http"
|
|
"os"
|
|
"path"
|
|
"runtime"
|
|
"time"
|
|
)
|
|
|
|
func init() {
|
|
_, filename, _, _ := runtime.Caller(0)
|
|
// The ".." may change depending on you folder structure
|
|
dir := path.Join(path.Dir(filename), "..")
|
|
err := os.Chdir(dir)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
type TestSample struct {
|
|
Path string
|
|
Url string
|
|
Type string
|
|
Width, Height int
|
|
Frames int
|
|
TimeBase utilities.Ratio
|
|
ColorSpace color.Space
|
|
SkipNotFound bool
|
|
}
|
|
|
|
func (sample *TestSample) Duration() time.Duration {
|
|
return sample.TimeBase.PTSToDuration(int64(sample.Frames - 1))
|
|
}
|
|
|
|
func (sample *TestSample) Open(t TestRunner) (io.ReadCloser, error) {
|
|
var reader io.ReadCloser
|
|
var err error
|
|
|
|
if _, err = os.Stat(sample.Path); err != nil {
|
|
if sample.SkipNotFound || sample.Url == "" {
|
|
t.Skip("skipping without sample")
|
|
}
|
|
response, err := http.DefaultClient.Get(sample.Url)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
reader = response.Body
|
|
} else {
|
|
f, err := os.Open(sample.Path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
reader = f
|
|
}
|
|
|
|
return reader, nil
|
|
}
|
|
|
|
type TestRunner interface {
|
|
Skip(args ...any)
|
|
Fatal(args ...any)
|
|
}
|
|
|
|
var (
|
|
Y4M_Sintel_Trailer_720p24_YUV420_8bit = TestSample{
|
|
Path: "testdata/sintel_trailer_2k_720p24.y4m",
|
|
// https://media.xiph.org/video/derf/y4m/sintel_trailer_2k_720p24.y4m
|
|
Url: "https://git.gammaspectra.live/S.O.N.G/Video-Samples/media/branch/master/sintel_trailer_2k_720p24.y4m",
|
|
Type: "y4m",
|
|
Width: 1280,
|
|
Height: 720,
|
|
Frames: 1253,
|
|
TimeBase: utilities.NewRatio(1, 24),
|
|
ColorSpace: color.MustColorFormatFromString("420jpeg"),
|
|
}
|
|
Y4M_Big_Buck_Bunny_360p24_YUV420_8bit = TestSample{
|
|
Path: "testdata/big_buck_bunny_360p24.y4m.xz",
|
|
Url: "https://media.xiph.org/video/derf/y4m/big_buck_bunny_360p24.y4m.xz",
|
|
Type: "y4m.xz",
|
|
Width: 640,
|
|
Height: 360,
|
|
Frames: 14315,
|
|
TimeBase: utilities.NewRatio(1, 24),
|
|
ColorSpace: color.MustColorFormatFromString("420jpeg"),
|
|
SkipNotFound: true,
|
|
}
|
|
Y4M_Ducks_Take_Off_720p50_YUV444_8bit = TestSample{
|
|
Path: "testdata/ducks_take_off_444_720p50.y4m",
|
|
// https://media.xiph.org/video/derf/y4m/ducks_take_off_444_720p50.y4m
|
|
Url: "https://git.gammaspectra.live/S.O.N.G/Video-Samples/media/branch/master/ducks_take_off_444_720p50.y4m",
|
|
Type: "y4m",
|
|
Width: 1280,
|
|
Height: 720,
|
|
Frames: 500,
|
|
TimeBase: utilities.NewRatio(1, 50),
|
|
ColorSpace: color.MustColorFormatFromString("444p8"),
|
|
}
|
|
Y4M_Ducks_Take_Off_720p50_YUV422_8bit = TestSample{
|
|
Path: "testdata/ducks_take_off_422_720p50.y4m",
|
|
// https://media.xiph.org/video/derf/y4m/ducks_take_off_422_720p50.y4m
|
|
Url: "https://git.gammaspectra.live/S.O.N.G/Video-Samples/media/branch/master/ducks_take_off_422_720p50.y4m",
|
|
Type: "y4m",
|
|
Width: 1280,
|
|
Height: 720,
|
|
Frames: 500,
|
|
TimeBase: utilities.NewRatio(1, 50),
|
|
ColorSpace: color.MustColorFormatFromString("422p8"),
|
|
}
|
|
Y4M_Netflix_FoodMarket_2160p60_YUV420_10bit = TestSample{
|
|
Path: "testdata/Netflix_FoodMarket_4096x2160_60fps_10bit_420.y4m",
|
|
Url: "https://media.xiph.org/video/derf/ElFuente/Netflix_FoodMarket_4096x2160_60fps_10bit_420.y4m",
|
|
Type: "y4m",
|
|
Width: 4096,
|
|
Height: 2160,
|
|
Frames: 600,
|
|
TimeBase: utilities.NewRatio(1, 60),
|
|
ColorSpace: color.MustColorFormatFromString("420p10"),
|
|
SkipNotFound: true,
|
|
}
|
|
|
|
AV1_Sintel_Trailer_720p24_YUV420_8bit_Low = TestSample{
|
|
Path: "testdata/sintel_trailer_2k_720p24_av1_low.ivf",
|
|
Url: "https://git.gammaspectra.live/S.O.N.G/Video-Samples/media/branch/master/sintel_trailer_2k_720p24_av1_low.ivf",
|
|
Type: "ivf",
|
|
Width: 1280,
|
|
Height: 720,
|
|
Frames: 1253,
|
|
TimeBase: utilities.NewRatio(1, 24),
|
|
ColorSpace: color.MustColorFormatFromString("420jpeg"),
|
|
}
|
|
AV1_Netflix_Sol_Levante_2160p24_YUV444_12bit_Lossy = TestSample{
|
|
Path: "testdata/netflix_sol_levante_2160p24_12bit_av1_lossy.ivf",
|
|
Url: "https://git.gammaspectra.live/S.O.N.G/Video-Samples/media/branch/master/netflix_sol_levante_2160p24_12bit_av1_lossy.ivf",
|
|
Type: "ivf",
|
|
Width: 3840,
|
|
Height: 2160,
|
|
Frames: 6313,
|
|
TimeBase: utilities.NewRatio(1, 24),
|
|
ColorSpace: color.MustColorFormatFromString("444p12"),
|
|
}
|
|
)
|