refactoring finished
This commit is contained in:
+35
-22
@@ -1,6 +1,11 @@
|
||||
package video
|
||||
|
||||
import "sort"
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"mxl-pattern-generator/kernels"
|
||||
)
|
||||
|
||||
type PatternInfo struct {
|
||||
Name string
|
||||
@@ -9,52 +14,60 @@ type PatternInfo struct {
|
||||
|
||||
type pattern struct {
|
||||
PatternInfo
|
||||
kernelPath string
|
||||
kernelSource string
|
||||
}
|
||||
|
||||
var patterns = map[string]pattern{
|
||||
"ebu75": {
|
||||
PatternInfo: PatternInfo{Name: "ebu75", Description: "EBU 75% Color Bar Signal"},
|
||||
kernelPath: "kernels/static/ebu75.wgsl",
|
||||
PatternInfo: PatternInfo{Name: "ebu75", Description: "EBU 75% Color Bar Signal"},
|
||||
kernelSource: mustReadKernel("static/ebu75.wgsl"),
|
||||
},
|
||||
"ebu75-move": {
|
||||
PatternInfo: PatternInfo{Name: "ebu75-move", Description: "EBU 75% Color Bar Signal with moving square"},
|
||||
kernelPath: "kernels/dynamic/ebu75.wgsl",
|
||||
PatternInfo: PatternInfo{Name: "ebu75-move", Description: "EBU 75% Color Bar Signal with moving square"},
|
||||
kernelSource: mustReadKernel("dynamic/ebu75.wgsl"),
|
||||
},
|
||||
"ebu100": {
|
||||
PatternInfo: PatternInfo{Name: "ebu100", Description: "EBU 100% Color Bar Signal"},
|
||||
kernelPath: "kernels/static/ebu100.wgsl",
|
||||
PatternInfo: PatternInfo{Name: "ebu100", Description: "EBU 100% Color Bar Signal"},
|
||||
kernelSource: mustReadKernel("static/ebu100.wgsl"),
|
||||
},
|
||||
"ebu100-move": {
|
||||
PatternInfo: PatternInfo{Name: "ebu100-move", Description: "EBU 100% Color Bar Signal with moving square"},
|
||||
kernelPath: "kernels/dynamic/ebu100.wgsl",
|
||||
PatternInfo: PatternInfo{Name: "ebu100-move", Description: "EBU 100% Color Bar Signal with moving square"},
|
||||
kernelSource: mustReadKernel("dynamic/ebu100.wgsl"),
|
||||
},
|
||||
"smpte": {
|
||||
PatternInfo: PatternInfo{Name: "smpte", Description: "SMPTE RP-219 Color Bar Signal"},
|
||||
kernelPath: "kernels/static/smpteBars.wgsl",
|
||||
PatternInfo: PatternInfo{Name: "smpte", Description: "SMPTE RP-219 Color Bar Signal"},
|
||||
kernelSource: mustReadKernel("static/smpteBars.wgsl"),
|
||||
},
|
||||
"smpte-move": {
|
||||
PatternInfo: PatternInfo{Name: "smpte-move", Description: "SMPTE RP-219 Color Bar Signal with moving square"},
|
||||
kernelPath: "kernels/dynamic/smpteBars.wgsl",
|
||||
PatternInfo: PatternInfo{Name: "smpte-move", Description: "SMPTE RP-219 Color Bar Signal with moving square"},
|
||||
kernelSource: mustReadKernel("dynamic/smpteBars.wgsl"),
|
||||
},
|
||||
"gray-bars": {
|
||||
PatternInfo: PatternInfo{Name: "gray-bars", Description: "13-step grayscale bars (Y 64..940)"},
|
||||
kernelPath: "kernels/static/yBars.wgsl",
|
||||
PatternInfo: PatternInfo{Name: "gray-bars", Description: "13-step grayscale bars (Y 64..940)"},
|
||||
kernelSource: mustReadKernel("static/yBars.wgsl"),
|
||||
},
|
||||
"gray-bars-move": {
|
||||
PatternInfo: PatternInfo{Name: "gray-bars-move", Description: "13-step grayscale bars (Y 64..940) with moving square"},
|
||||
kernelPath: "kernels/dynamic/yBars.wgsl",
|
||||
PatternInfo: PatternInfo{Name: "gray-bars-move", Description: "13-step grayscale bars (Y 64..940) with moving square"},
|
||||
kernelSource: mustReadKernel("dynamic/yBars.wgsl"),
|
||||
},
|
||||
"gray-ramp": {
|
||||
PatternInfo: PatternInfo{Name: "gray-ramp", Description: "Y gradient (black -> 100% white)"},
|
||||
kernelPath: "kernels/static/yRamp.wgsl",
|
||||
PatternInfo: PatternInfo{Name: "gray-ramp", Description: "Y gradient (black -> 100% white)"},
|
||||
kernelSource: mustReadKernel("static/yRamp.wgsl"),
|
||||
},
|
||||
"gray-ramp-move": {
|
||||
PatternInfo: PatternInfo{Name: "gray-ramp-move", Description: "Y gradient with moving square"},
|
||||
kernelPath: "kernels/dynamic/yRamp.wgsl",
|
||||
PatternInfo: PatternInfo{Name: "gray-ramp-move", Description: "Y gradient with moving square"},
|
||||
kernelSource: mustReadKernel("dynamic/yRamp.wgsl"),
|
||||
},
|
||||
}
|
||||
|
||||
func mustReadKernel(name string) string {
|
||||
source, err := kernels.Read(name)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("read embedded video kernel %q: %v", name, err))
|
||||
}
|
||||
return string(source)
|
||||
}
|
||||
|
||||
func HasPattern(name string) bool {
|
||||
_, ok := patterns[name]
|
||||
return ok
|
||||
|
||||
Reference in New Issue
Block a user