V210 issue fix + correct packing
This commit is contained in:
@@ -54,3 +54,37 @@ func TestWGPUSMPTEPattern(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWGPUGeneratorUsesPaddedV210Rows(t *testing.T) {
|
||||
const width, height = 100, 2
|
||||
shader, err := kernels.Read("static/ebu75.wgsl")
|
||||
if err != nil {
|
||||
t.Fatalf("read shader: %v", err)
|
||||
}
|
||||
g, err := NewWGPUGenerator(width, height, string(shader))
|
||||
if err != nil {
|
||||
t.Fatalf("init: %v", err)
|
||||
}
|
||||
defer g.Close()
|
||||
|
||||
buf := make([]byte, V210FrameSize(width, height))
|
||||
for i := range buf {
|
||||
buf[i] = 0xff
|
||||
}
|
||||
if err := g.GenerateFrame(buf, 0); err != nil {
|
||||
t.Fatalf("GenerateFrame: %v", err)
|
||||
}
|
||||
|
||||
for y := 0; y < height; y++ {
|
||||
gotY, gotCb, gotCr := sampleV210(buf, width, 0, y)
|
||||
if gotY != 721 || gotCb != 512 || gotCr != 512 {
|
||||
t.Fatalf("row %d first pixel = %d/%d/%d, want 721/512/512", y, gotY, gotCb, gotCr)
|
||||
}
|
||||
padding := buf[y*V210LineSize(width)+V210ActiveLineSize(width) : (y+1)*V210LineSize(width)]
|
||||
for i, b := range padding {
|
||||
if b != 0 {
|
||||
t.Fatalf("row %d padding byte %d = %#x, want 0", y, i, b)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user