mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-19 09:34:12 +00:00
Add new YUV converter with 2x2 pixel matrix YUV color estimation. The new YUV color converter, as opposed to the original one, uses more precise color calculations based on four neighboring pixels' average color values which helps a great deal with image aliasing / shimmering artifacts. By default, it runs in the multithreaded mode with the game frames sliced between 2*(CPU cores) goroutines. In case if this estimation mode doesn't work as expected it is possible to switch back to the original mode. The default encoder is switched to x264 since it's faster now.
42 lines
673 B
Go
42 lines
673 B
Go
package yuv
|
|
|
|
type Options struct {
|
|
ChromaP ChromaPos
|
|
Threaded bool
|
|
Threads int
|
|
}
|
|
|
|
func (o *Options) override(options ...Option) {
|
|
for _, opt := range options {
|
|
opt(o)
|
|
}
|
|
}
|
|
|
|
type Option func(*Options)
|
|
|
|
func Threaded(t bool) Option {
|
|
return func(opts *Options) {
|
|
opts.Threaded = t
|
|
}
|
|
}
|
|
|
|
func Threads(t int) Option {
|
|
return func(opts *Options) {
|
|
opts.Threads = t
|
|
}
|
|
}
|
|
|
|
func ChromaP(cp ChromaPos) Option {
|
|
return func(opts *Options) {
|
|
opts.ChromaP = cp
|
|
}
|
|
}
|
|
|
|
// WithOptions used for config files.
|
|
func WithOptions(arg Options) Option {
|
|
return func(args *Options) {
|
|
args.ChromaP = arg.ChromaP
|
|
args.Threaded = arg.Threaded
|
|
args.Threads = arg.Threads
|
|
}
|
|
}
|